Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 31 Dec 2009 19:12:35 +0000 (11:12 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 31 Dec 2009 19:12:35 +0000 (11:12 -0800)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: iforce - wait for command completion when closing the device
  Input: twl4030-pwrbutton - switch to using threaded IRQ
  Input: twl4030_keypad - switch to using threaded IRQ
  Input: lifebook - add CONFIG_DMI dependency
  Input: wistron - fix test for CONFIG_PM
  Input: psmouse - fix compile warning in hgpk module
  Input: matrix-keypad - handle cases when GPIOs can't be wakeup sources
  Input: iforce - fix oops on device disconnect
  Input: ff-memless - add notion of direction to for rumble effects
  Input: ff-memless - another fix for signed to unsigned overflow
  Input: ff-memless - start playing FF effects immediately
  Input: serio - do not mark kseriod freezable anymore
  Input: speed up suspend/shutdown for PS/2 mice and keyboards

3149 files changed:
.gitignore
Documentation/ABI/testing/sysfs-bus-usb
Documentation/ABI/testing/sysfs-devices-memory
Documentation/ABI/testing/sysfs-devices-system-cpu
Documentation/ABI/testing/sysfs-memory-page-offline [new file with mode: 0644]
Documentation/Changes
Documentation/DocBook/Makefile
Documentation/DocBook/media-entities.tmpl
Documentation/DocBook/media-indices.tmpl
Documentation/DocBook/procfs-guide.tmpl [deleted file]
Documentation/DocBook/procfs_example.c [deleted file]
Documentation/DocBook/v4l/common.xml
Documentation/DocBook/v4l/compat.xml
Documentation/DocBook/v4l/v4l2.xml
Documentation/DocBook/v4l/videodev2.h.xml
Documentation/DocBook/v4l/vidioc-enum-dv-presets.xml [new file with mode: 0644]
Documentation/DocBook/v4l/vidioc-enuminput.xml
Documentation/DocBook/v4l/vidioc-enumoutput.xml
Documentation/DocBook/v4l/vidioc-g-dv-preset.xml [new file with mode: 0644]
Documentation/DocBook/v4l/vidioc-g-dv-timings.xml [new file with mode: 0644]
Documentation/DocBook/v4l/vidioc-g-std.xml
Documentation/DocBook/v4l/vidioc-query-dv-preset.xml [new file with mode: 0644]
Documentation/DocBook/v4l/vidioc-querystd.xml
Documentation/SubmitChecklist
Documentation/acpi/method-customizing.txt [new file with mode: 0644]
Documentation/blackfin/00-INDEX
Documentation/blackfin/Makefile [new file with mode: 0644]
Documentation/blackfin/cache-lock.txt [deleted file]
Documentation/blackfin/cachefeatures.txt
Documentation/blackfin/gptimers-example.c [new file with mode: 0644]
Documentation/block/00-INDEX
Documentation/block/as-iosched.txt [deleted file]
Documentation/cpu-hotplug.txt
Documentation/device-mapper/snapshot.txt
Documentation/dontdiff
Documentation/driver-model/driver.txt
Documentation/fb/viafb.txt
Documentation/feature-removal-schedule.txt
Documentation/filesystems/00-INDEX
Documentation/filesystems/ext4.txt
Documentation/filesystems/nfs/00-INDEX [new file with mode: 0644]
Documentation/filesystems/nfs/Exporting [moved from Documentation/filesystems/Exporting with 100% similarity]
Documentation/filesystems/nfs/knfsd-stats.txt [moved from Documentation/filesystems/knfsd-stats.txt with 100% similarity]
Documentation/filesystems/nfs/nfs-rdma.txt [moved from Documentation/filesystems/nfs-rdma.txt with 100% similarity]
Documentation/filesystems/nfs/nfs.txt [moved from Documentation/filesystems/nfs.txt with 100% similarity]
Documentation/filesystems/nfs/nfs41-server.txt [moved from Documentation/filesystems/nfs41-server.txt with 96% similarity]
Documentation/filesystems/nfs/nfsroot.txt [moved from Documentation/filesystems/nfsroot.txt with 100% similarity]
Documentation/filesystems/nfs/rpc-cache.txt [moved from Documentation/filesystems/rpc-cache.txt with 100% similarity]
Documentation/filesystems/porting
Documentation/filesystems/proc.txt
Documentation/filesystems/seq_file.txt
Documentation/filesystems/sysfs.txt
Documentation/gpio.txt
Documentation/hwmon/k10temp [new file with mode: 0644]
Documentation/hwmon/lis3lv02d
Documentation/hwmon/w83627ehf
Documentation/i2c/writing-clients
Documentation/infiniband/ipoib.txt
Documentation/kbuild/kbuild.txt
Documentation/kbuild/kconfig.txt
Documentation/kernel-parameters.txt
Documentation/kvm/api.txt
Documentation/laptops/thinkpad-acpi.txt
Documentation/memory-hotplug.txt
Documentation/misc-devices/ad525x_dpot.txt [new file with mode: 0644]
Documentation/nommu-mmap.txt
Documentation/power/runtime_pm.txt
Documentation/powerpc/dts-bindings/4xx/ppc440spe-adma.txt [new file with mode: 0644]
Documentation/powerpc/dts-bindings/fsl/mpic.txt [new file with mode: 0644]
Documentation/powerpc/dts-bindings/nintendo/gamecube.txt [new file with mode: 0644]
Documentation/powerpc/dts-bindings/nintendo/wii.txt [new file with mode: 0644]
Documentation/sound/alsa/HD-Audio-Models.txt
Documentation/sound/alsa/Procfile.txt
Documentation/stable_kernel_rules.txt
Documentation/thermal/sysfs-api.txt
Documentation/trace/events-kmem.txt
Documentation/usb/power-management.txt
Documentation/vgaarbiter.txt
Documentation/video4linux/gspca.txt
Documentation/video4linux/sh_mobile_ceu_camera.txt [new file with mode: 0644]
Documentation/video4linux/v4l2-framework.txt
Documentation/vm/hugetlbpage.txt
Documentation/vm/hwpoison.txt
Documentation/vm/ksm.txt
Documentation/vm/page-types.c
Kbuild
MAINTAINERS
Makefile
arch/Kconfig
arch/alpha/Kconfig
arch/alpha/boot/bootp.c
arch/alpha/boot/bootpz.c
arch/alpha/boot/main.c
arch/alpha/include/asm/asm-offsets.h [new file with mode: 0644]
arch/alpha/include/asm/bug.h
arch/alpha/include/asm/core_t2.h
arch/alpha/include/asm/elf.h
arch/alpha/include/asm/fcntl.h
arch/alpha/include/asm/perf_event.h [new file with mode: 0644]
arch/alpha/include/asm/spinlock.h
arch/alpha/include/asm/spinlock_types.h
arch/alpha/include/asm/unistd.h
arch/alpha/kernel/core_t2.c
arch/alpha/kernel/irq.c
arch/alpha/kernel/srm_env.c
arch/alpha/kernel/systbls.S
arch/arm/Makefile
arch/arm/common/dmabounce.c
arch/arm/configs/acs5k_defconfig
arch/arm/configs/acs5k_tiny_defconfig
arch/arm/configs/afeb9260_defconfig
arch/arm/configs/am200epdkit_defconfig
arch/arm/configs/am3517_evm_defconfig
arch/arm/configs/ams_delta_defconfig
arch/arm/configs/assabet_defconfig
arch/arm/configs/at91cap9adk_defconfig
arch/arm/configs/at91rm9200dk_defconfig
arch/arm/configs/at91rm9200ek_defconfig
arch/arm/configs/at91sam9260ek_defconfig
arch/arm/configs/at91sam9261ek_defconfig
arch/arm/configs/at91sam9263ek_defconfig
arch/arm/configs/at91sam9g20ek_defconfig
arch/arm/configs/at91sam9rlek_defconfig
arch/arm/configs/ateb9200_defconfig
arch/arm/configs/badge4_defconfig
arch/arm/configs/bcmring_defconfig
arch/arm/configs/cam60_defconfig
arch/arm/configs/carmeva_defconfig
arch/arm/configs/cerfcube_defconfig
arch/arm/configs/cm_t35_defconfig
arch/arm/configs/cm_x2xx_defconfig
arch/arm/configs/cm_x300_defconfig
arch/arm/configs/colibri_pxa270_defconfig
arch/arm/configs/colibri_pxa300_defconfig
arch/arm/configs/collie_defconfig
arch/arm/configs/corgi_defconfig
arch/arm/configs/cpu9260_defconfig
arch/arm/configs/cpu9g20_defconfig
arch/arm/configs/cpuat91_defconfig
arch/arm/configs/csb337_defconfig
arch/arm/configs/csb637_defconfig
arch/arm/configs/da8xx_omapl_defconfig
arch/arm/configs/davinci_all_defconfig
arch/arm/configs/dove_defconfig
arch/arm/configs/ebsa110_defconfig
arch/arm/configs/ecbat91_defconfig
arch/arm/configs/edb7211_defconfig
arch/arm/configs/em_x270_defconfig
arch/arm/configs/ep93xx_defconfig
arch/arm/configs/eseries_pxa_defconfig
arch/arm/configs/ezx_defconfig
arch/arm/configs/footbridge_defconfig
arch/arm/configs/fortunet_defconfig
arch/arm/configs/h3600_defconfig
arch/arm/configs/h5000_defconfig
arch/arm/configs/h7201_defconfig
arch/arm/configs/h7202_defconfig
arch/arm/configs/hackkit_defconfig
arch/arm/configs/htcherald_defconfig
arch/arm/configs/igep0020_defconfig
arch/arm/configs/integrator_defconfig
arch/arm/configs/iop13xx_defconfig
arch/arm/configs/iop32x_defconfig
arch/arm/configs/iop33x_defconfig
arch/arm/configs/ixp2000_defconfig
arch/arm/configs/ixp23xx_defconfig
arch/arm/configs/ixp4xx_defconfig
arch/arm/configs/jornada720_defconfig
arch/arm/configs/kafa_defconfig
arch/arm/configs/kb9202_defconfig
arch/arm/configs/kirkwood_defconfig
arch/arm/configs/ks8695_defconfig
arch/arm/configs/lart_defconfig
arch/arm/configs/loki_defconfig
arch/arm/configs/lpd270_defconfig
arch/arm/configs/lpd7a400_defconfig
arch/arm/configs/lpd7a404_defconfig
arch/arm/configs/lubbock_defconfig
arch/arm/configs/lusl7200_defconfig
arch/arm/configs/magician_defconfig
arch/arm/configs/mainstone_defconfig
arch/arm/configs/mini2440_defconfig
arch/arm/configs/msm_defconfig
arch/arm/configs/mv78xx0_defconfig
arch/arm/configs/mx1_defconfig
arch/arm/configs/mx1ads_defconfig
arch/arm/configs/mx21_defconfig
arch/arm/configs/mx27_defconfig
arch/arm/configs/mx31pdk_defconfig
arch/arm/configs/mx3_defconfig
arch/arm/configs/n770_defconfig
arch/arm/configs/n8x0_defconfig
arch/arm/configs/neocore926_defconfig
arch/arm/configs/neponset_defconfig
arch/arm/configs/netwinder_defconfig
arch/arm/configs/netx_defconfig
arch/arm/configs/nhk8815_defconfig
arch/arm/configs/nuc910_defconfig
arch/arm/configs/nuc950_defconfig
arch/arm/configs/nuc960_defconfig
arch/arm/configs/omap3_beagle_defconfig
arch/arm/configs/omap3_defconfig
arch/arm/configs/omap3_evm_defconfig
arch/arm/configs/omap3_pandora_defconfig
arch/arm/configs/omap3_touchbook_defconfig
arch/arm/configs/omap_2430sdp_defconfig
arch/arm/configs/omap_3430sdp_defconfig
arch/arm/configs/omap_3630sdp_defconfig
arch/arm/configs/omap_4430sdp_defconfig
arch/arm/configs/omap_apollon_2420_defconfig
arch/arm/configs/omap_generic_1510_defconfig
arch/arm/configs/omap_generic_1610_defconfig
arch/arm/configs/omap_generic_1710_defconfig
arch/arm/configs/omap_generic_2420_defconfig
arch/arm/configs/omap_h2_1610_defconfig
arch/arm/configs/omap_h4_2420_defconfig
arch/arm/configs/omap_innovator_1510_defconfig
arch/arm/configs/omap_innovator_1610_defconfig
arch/arm/configs/omap_ldp_defconfig
arch/arm/configs/omap_osk_5912_defconfig
arch/arm/configs/omap_perseus2_730_defconfig
arch/arm/configs/omap_zoom2_defconfig
arch/arm/configs/omap_zoom3_defconfig
arch/arm/configs/onearm_defconfig
arch/arm/configs/orion5x_defconfig
arch/arm/configs/overo_defconfig
arch/arm/configs/palmte_defconfig
arch/arm/configs/palmtt_defconfig
arch/arm/configs/palmz71_defconfig
arch/arm/configs/palmz72_defconfig
arch/arm/configs/pcm027_defconfig
arch/arm/configs/picotux200_defconfig
arch/arm/configs/pleb_defconfig
arch/arm/configs/pnx4008_defconfig
arch/arm/configs/pxa168_defconfig
arch/arm/configs/pxa255-idp_defconfig
arch/arm/configs/pxa3xx_defconfig
arch/arm/configs/pxa910_defconfig
arch/arm/configs/qil-a9260_defconfig
arch/arm/configs/realview-smp_defconfig
arch/arm/configs/realview_defconfig
arch/arm/configs/rpc_defconfig
arch/arm/configs/rx51_defconfig
arch/arm/configs/s3c2410_defconfig
arch/arm/configs/s3c6400_defconfig
arch/arm/configs/s5pc100_defconfig
arch/arm/configs/sam9_l9260_defconfig
arch/arm/configs/shannon_defconfig
arch/arm/configs/shark_defconfig
arch/arm/configs/simpad_defconfig
arch/arm/configs/spitz_defconfig
arch/arm/configs/stmp378x_defconfig
arch/arm/configs/stmp37xx_defconfig
arch/arm/configs/sx1_defconfig
arch/arm/configs/tct_hammer_defconfig
arch/arm/configs/trizeps4_defconfig
arch/arm/configs/u300_defconfig
arch/arm/configs/u8500_defconfig
arch/arm/configs/usb-a9260_defconfig
arch/arm/configs/usb-a9263_defconfig
arch/arm/configs/versatile_defconfig
arch/arm/configs/viper_defconfig
arch/arm/configs/xcep_defconfig
arch/arm/configs/yl9200_defconfig
arch/arm/configs/zeus_defconfig
arch/arm/include/asm/asm-offsets.h [new file with mode: 0644]
arch/arm/include/asm/cacheflush.h
arch/arm/include/asm/elf.h
arch/arm/include/asm/mach-types.h [new file with mode: 0644]
arch/arm/include/asm/mach/irq.h
arch/arm/include/asm/proc-fns.h
arch/arm/include/asm/spinlock.h
arch/arm/include/asm/spinlock_types.h
arch/arm/include/asm/thread_notify.h
arch/arm/kernel/armksyms.c
arch/arm/kernel/crunch.c
arch/arm/kernel/dma-isa.c
arch/arm/kernel/irq.c
arch/arm/kernel/process.c
arch/arm/kernel/vmlinux.lds.S
arch/arm/kernel/xscale-cp0.c
arch/arm/mach-at91/include/mach/atmel-mci.h [new file with mode: 0644]
arch/arm/mach-bcmring/arch.c
arch/arm/mach-bcmring/include/mach/reg_nand.h [new file with mode: 0644]
arch/arm/mach-bcmring/include/mach/reg_umi.h [new file with mode: 0644]
arch/arm/mach-davinci/board-da850-evm.c
arch/arm/mach-davinci/include/mach/nand.h
arch/arm/mach-footbridge/Makefile
arch/arm/mach-footbridge/dc21285-timer.c
arch/arm/mach-footbridge/isa-rtc.c [new file with mode: 0644]
arch/arm/mach-footbridge/isa-timer.c
arch/arm/mach-footbridge/isa.c
arch/arm/mach-footbridge/time.c [deleted file]
arch/arm/mach-kirkwood/Kconfig
arch/arm/mach-kirkwood/Makefile
arch/arm/mach-kirkwood/netspace_v2-setup.c [new file with mode: 0644]
arch/arm/mach-nomadik/board-nhk8815.c
arch/arm/mach-ns9xxx/irq.c
arch/arm/mach-omap2/Kconfig
arch/arm/mach-omap2/board-cm-t35.c
arch/arm/mach-omap2/board-igep0020.c
arch/arm/mach-omap2/board-omap3evm.c
arch/arm/mach-omap2/board-omap3touchbook.c
arch/arm/mach-omap2/board-rx51-peripherals.c
arch/arm/mach-omap2/board-zoom-peripherals.c
arch/arm/mach-omap2/serial.c
arch/arm/mach-pxa/Kconfig
arch/arm/mach-pxa/devices.c
arch/arm/mach-s3c2410/include/mach/spi.h
arch/arm/mach-s3c2442/mach-gta02.c
arch/arm/mach-u300/include/mach/coh901318.h [new file with mode: 0644]
arch/arm/mach-w90x900/cpu.c
arch/arm/mach-w90x900/dev.c
arch/arm/mach-w90x900/include/mach/uncompress.h
arch/arm/mm/Kconfig
arch/arm/mm/cache-fa.S
arch/arm/mm/cache-l2x0.c
arch/arm/mm/cache-v3.S
arch/arm/mm/cache-v4.S
arch/arm/mm/cache-v4wb.S
arch/arm/mm/cache-v4wt.S
arch/arm/mm/cache-v6.S
arch/arm/mm/cache-v7.S
arch/arm/mm/copypage-v6.c
arch/arm/mm/fault-armv.c
arch/arm/mm/flush.c
arch/arm/mm/highmem.c
arch/arm/mm/mmu.c
arch/arm/mm/nommu.c
arch/arm/mm/proc-arm1020.S
arch/arm/mm/proc-arm1020e.S
arch/arm/mm/proc-arm1022.S
arch/arm/mm/proc-arm1026.S
arch/arm/mm/proc-arm920.S
arch/arm/mm/proc-arm922.S
arch/arm/mm/proc-arm925.S
arch/arm/mm/proc-arm926.S
arch/arm/mm/proc-arm940.S
arch/arm/mm/proc-arm946.S
arch/arm/mm/proc-feroceon.S
arch/arm/mm/proc-mohawk.S
arch/arm/mm/proc-syms.c
arch/arm/mm/proc-v6.S
arch/arm/mm/proc-xsc3.S
arch/arm/mm/proc-xscale.S
arch/arm/nwfpe/Makefile
arch/arm/oprofile/op_model_v7.c
arch/arm/plat-mxc/include/mach/mxc_nand.h
arch/arm/plat-omap/debug-leds.c
arch/arm/plat-omap/gpio.c
arch/arm/plat-s3c/include/plat/nand.h
arch/arm/tools/Makefile
arch/arm/tools/gen-mach-types
arch/arm/tools/mach-types
arch/arm/vfp/vfpmodule.c
arch/avr32/Kconfig
arch/avr32/Makefile
arch/avr32/boards/atngw100/Kconfig
arch/avr32/boards/atngw100/evklcd10x.c
arch/avr32/boards/atngw100/mrmt.c
arch/avr32/boards/atngw100/setup.c
arch/avr32/configs/atngw100_defconfig
arch/avr32/configs/atngw100_evklcd100_defconfig
arch/avr32/configs/atngw100_evklcd101_defconfig
arch/avr32/configs/atngw100mkii_defconfig [new file with mode: 0644]
arch/avr32/configs/atngw100mkii_evklcd100_defconfig [new file with mode: 0644]
arch/avr32/configs/atngw100mkii_evklcd101_defconfig [new file with mode: 0644]
arch/avr32/configs/atstk1002_defconfig
arch/avr32/configs/atstk1006_defconfig
arch/avr32/include/asm/asm-offsets.h [new file with mode: 0644]
arch/avr32/include/asm/elf.h
arch/avr32/include/asm/hardirq.h
arch/avr32/kernel/irq.c
arch/avr32/kernel/vmlinux.lds.S
arch/avr32/mach-at32ap/at32ap700x.c
arch/avr32/mach-at32ap/include/mach/atmel-mci.h [new file with mode: 0644]
arch/avr32/mach-at32ap/include/mach/board.h
arch/blackfin/Kconfig
arch/blackfin/Makefile
arch/blackfin/boot/Makefile
arch/blackfin/configs/BF518F-EZBRD_defconfig
arch/blackfin/configs/BF526-EZBRD_defconfig
arch/blackfin/configs/BF527-EZKIT_defconfig
arch/blackfin/configs/BF533-EZKIT_defconfig
arch/blackfin/configs/BF533-STAMP_defconfig
arch/blackfin/configs/BF537-STAMP_defconfig
arch/blackfin/configs/BF538-EZKIT_defconfig
arch/blackfin/configs/BF548-EZKIT_defconfig
arch/blackfin/configs/BF561-ACVILON_defconfig [new file with mode: 0644]
arch/blackfin/configs/BF561-EZKIT_defconfig
arch/blackfin/configs/BlackStamp_defconfig
arch/blackfin/configs/CM-BF527_defconfig
arch/blackfin/configs/CM-BF533_defconfig
arch/blackfin/configs/CM-BF537E_defconfig
arch/blackfin/configs/CM-BF537U_defconfig
arch/blackfin/configs/CM-BF548_defconfig
arch/blackfin/configs/CM-BF561_defconfig
arch/blackfin/configs/H8606_defconfig
arch/blackfin/configs/IP0X_defconfig
arch/blackfin/configs/PNAV-10_defconfig
arch/blackfin/configs/SRV1_defconfig
arch/blackfin/configs/TCM-BF537_defconfig
arch/blackfin/include/asm/asm-offsets.h [new file with mode: 0644]
arch/blackfin/include/asm/bfin-global.h
arch/blackfin/include/asm/bfin-lq035q1.h [new file with mode: 0644]
arch/blackfin/include/asm/bug.h
arch/blackfin/include/asm/cacheflush.h
arch/blackfin/include/asm/checksum.h
arch/blackfin/include/asm/clocks.h
arch/blackfin/include/asm/dma-mapping.h
arch/blackfin/include/asm/dma.h
arch/blackfin/include/asm/dpmc.h
arch/blackfin/include/asm/elf.h
arch/blackfin/include/asm/gpio.h
arch/blackfin/include/asm/gptimers.h
arch/blackfin/include/asm/io.h
arch/blackfin/include/asm/ipipe.h
arch/blackfin/include/asm/ipipe_base.h
arch/blackfin/include/asm/irqflags.h
arch/blackfin/include/asm/kgdb.h
arch/blackfin/include/asm/mem_init.h
arch/blackfin/include/asm/mmu_context.h
arch/blackfin/include/asm/module.h
arch/blackfin/include/asm/pci.h
arch/blackfin/include/asm/ptrace.h
arch/blackfin/include/asm/sections.h
arch/blackfin/include/asm/spinlock.h
arch/blackfin/include/asm/spinlock_types.h
arch/blackfin/include/asm/thread_info.h
arch/blackfin/include/asm/trace.h
arch/blackfin/include/asm/uaccess.h
arch/blackfin/include/asm/unistd.h
arch/blackfin/kernel/bfin_dma_5xx.c
arch/blackfin/kernel/bfin_gpio.c
arch/blackfin/kernel/cplb-mpu/cplbinit.c
arch/blackfin/kernel/cplb-mpu/cplbmgr.c
arch/blackfin/kernel/cplb-nompu/cplbinit.c
arch/blackfin/kernel/dma-mapping.c
arch/blackfin/kernel/gptimers.c
arch/blackfin/kernel/ipipe.c
arch/blackfin/kernel/irqchip.c
arch/blackfin/kernel/kgdb.c
arch/blackfin/kernel/kgdb_test.c
arch/blackfin/kernel/process.c
arch/blackfin/kernel/ptrace.c
arch/blackfin/kernel/setup.c
arch/blackfin/kernel/signal.c
arch/blackfin/kernel/time-ts.c
arch/blackfin/kernel/time.c
arch/blackfin/kernel/traps.c
arch/blackfin/kernel/vmlinux.lds.S
arch/blackfin/lib/Makefile
arch/blackfin/lib/checksum.c [deleted file]
arch/blackfin/mach-bf518/Kconfig
arch/blackfin/mach-bf518/include/mach/blackfin.h
arch/blackfin/mach-bf518/include/mach/cdefBF514.h
arch/blackfin/mach-bf518/include/mach/cdefBF516.h
arch/blackfin/mach-bf518/include/mach/cdefBF518.h
arch/blackfin/mach-bf518/include/mach/cdefBF51x_base.h
arch/blackfin/mach-bf518/include/mach/defBF514.h
arch/blackfin/mach-bf518/include/mach/defBF516.h
arch/blackfin/mach-bf518/include/mach/defBF518.h
arch/blackfin/mach-bf518/include/mach/defBF51x_base.h
arch/blackfin/mach-bf527/Kconfig
arch/blackfin/mach-bf527/boards/cm_bf527.c
arch/blackfin/mach-bf527/boards/ezkit.c
arch/blackfin/mach-bf527/include/mach/blackfin.h
arch/blackfin/mach-bf527/include/mach/cdefBF525.h
arch/blackfin/mach-bf527/include/mach/cdefBF527.h
arch/blackfin/mach-bf527/include/mach/cdefBF52x_base.h
arch/blackfin/mach-bf527/include/mach/defBF525.h
arch/blackfin/mach-bf527/include/mach/defBF527.h
arch/blackfin/mach-bf527/include/mach/defBF52x_base.h
arch/blackfin/mach-bf533/boards/H8606.c
arch/blackfin/mach-bf533/boards/ip0x.c
arch/blackfin/mach-bf533/boards/stamp.c
arch/blackfin/mach-bf533/include/mach/defBF532.h
arch/blackfin/mach-bf537/boards/pnav10.c
arch/blackfin/mach-bf537/boards/stamp.c
arch/blackfin/mach-bf537/include/mach/bf537.h
arch/blackfin/mach-bf537/include/mach/blackfin.h
arch/blackfin/mach-bf537/include/mach/defBF534.h
arch/blackfin/mach-bf538/Makefile
arch/blackfin/mach-bf538/boards/ezkit.c
arch/blackfin/mach-bf538/ext-gpio.c [new file with mode: 0644]
arch/blackfin/mach-bf538/include/mach/blackfin.h
arch/blackfin/mach-bf538/include/mach/defBF539.h
arch/blackfin/mach-bf538/include/mach/gpio.h
arch/blackfin/mach-bf538/include/mach/portmux.h
arch/blackfin/mach-bf548/Kconfig
arch/blackfin/mach-bf548/boards/ezkit.c
arch/blackfin/mach-bf548/include/mach/bf548.h
arch/blackfin/mach-bf548/include/mach/blackfin.h
arch/blackfin/mach-bf548/include/mach/cdefBF547.h
arch/blackfin/mach-bf548/include/mach/cdefBF548.h
arch/blackfin/mach-bf548/include/mach/cdefBF549.h
arch/blackfin/mach-bf548/include/mach/cdefBF54x_base.h
arch/blackfin/mach-bf548/include/mach/defBF544.h
arch/blackfin/mach-bf548/include/mach/defBF547.h
arch/blackfin/mach-bf548/include/mach/defBF548.h
arch/blackfin/mach-bf548/include/mach/defBF549.h
arch/blackfin/mach-bf548/include/mach/defBF54x_base.h
arch/blackfin/mach-bf561/boards/Kconfig
arch/blackfin/mach-bf561/boards/Makefile
arch/blackfin/mach-bf561/boards/acvilon.c [new file with mode: 0644]
arch/blackfin/mach-bf561/boards/ezkit.c
arch/blackfin/mach-bf561/coreb.c
arch/blackfin/mach-bf561/include/mach/defBF561.h
arch/blackfin/mach-bf561/smp.c
arch/blackfin/mach-common/clocks-init.c
arch/blackfin/mach-common/cpufreq.c
arch/blackfin/mach-common/dpmc_modes.S
arch/blackfin/mach-common/entry.S
arch/blackfin/mach-common/ints-priority.c
arch/blackfin/mach-common/smp.c
arch/cris/arch-v32/kernel/head.S
arch/cris/include/arch-v32/arch/spinlock.h
arch/cris/include/asm/asm-offsets.h [new file with mode: 0644]
arch/cris/include/asm/elf.h
arch/cris/kernel/asm-offsets.c
arch/cris/kernel/irq.c
arch/cris/kernel/vmlinux.lds.S
arch/frv/include/asm/asm-offsets.h [new file with mode: 0644]
arch/frv/include/asm/elf.h
arch/frv/kernel/irq.c
arch/frv/kernel/setup.c
arch/h8300/Kconfig
arch/h8300/include/asm/asm-offsets.h [new file with mode: 0644]
arch/h8300/include/asm/elf.h
arch/h8300/include/asm/module.h
arch/h8300/kernel/irq.c
arch/h8300/kernel/vmlinux.lds.S
arch/ia64/Makefile
arch/ia64/hp/common/sba_iommu.c
arch/ia64/ia32/elfcore32.h
arch/ia64/include/asm/acpi.h
arch/ia64/include/asm/asm-offsets.h [new file with mode: 0644]
arch/ia64/include/asm/bitops.h
arch/ia64/include/asm/dma-mapping.h
arch/ia64/include/asm/elf.h
arch/ia64/include/asm/hw_irq.h
arch/ia64/include/asm/io.h
arch/ia64/include/asm/irq.h
arch/ia64/include/asm/mca.h
arch/ia64/include/asm/numa.h
arch/ia64/include/asm/rwsem.h
arch/ia64/include/asm/spinlock.h
arch/ia64/include/asm/spinlock_types.h
arch/ia64/kernel/Makefile
arch/ia64/kernel/acpi-processor.c [deleted file]
arch/ia64/kernel/iosapic.c
arch/ia64/kernel/irq.c
arch/ia64/kernel/irq_ia64.c
arch/ia64/kernel/mca.c
arch/ia64/kernel/perfmon.c
arch/ia64/kvm/asm-offsets.c
arch/ia64/kvm/vcpu.h
arch/ia64/kvm/vmm.c
arch/ia64/kvm/vtlb.c
arch/ia64/mm/ioremap.c
arch/ia64/sn/pci/tioca_provider.c
arch/m32r/include/asm/elf.h
arch/m32r/include/asm/spinlock.h
arch/m32r/include/asm/spinlock_types.h
arch/m32r/kernel/irq.c
arch/m68k/include/asm/asm-offsets.h [new file with mode: 0644]
arch/m68k/include/asm/elf.h
arch/m68k/kernel/head.S
arch/microblaze/include/asm/asm-offsets.h [new file with mode: 0644]
arch/microblaze/include/asm/elf.h
arch/microblaze/kernel/irq.c
arch/mips/Kconfig
arch/mips/Kconfig.debug
arch/mips/Makefile
arch/mips/ar7/platform.c
arch/mips/basler/excite/Kconfig [deleted file]
arch/mips/basler/excite/Makefile [deleted file]
arch/mips/basler/excite/excite_device.c [deleted file]
arch/mips/basler/excite/excite_iodev.c [deleted file]
arch/mips/basler/excite/excite_iodev.h [deleted file]
arch/mips/basler/excite/excite_irq.c [deleted file]
arch/mips/basler/excite/excite_procfs.c [deleted file]
arch/mips/basler/excite/excite_prom.c [deleted file]
arch/mips/basler/excite/excite_setup.c [deleted file]
arch/mips/bcm47xx/prom.c
arch/mips/boot/Makefile
arch/mips/boot/addinitrd.c [deleted file]
arch/mips/boot/compressed/Makefile [new file with mode: 0644]
arch/mips/boot/compressed/dbg.c [new file with mode: 0644]
arch/mips/boot/compressed/decompress.c [new file with mode: 0644]
arch/mips/boot/compressed/dummy.c [new file with mode: 0644]
arch/mips/boot/compressed/head.S [new file with mode: 0644]
arch/mips/boot/compressed/ld.script [new file with mode: 0644]
arch/mips/boot/compressed/uart-16550.c [new file with mode: 0644]
arch/mips/cavium-octeon/Makefile
arch/mips/cavium-octeon/cpu.c [new file with mode: 0644]
arch/mips/cavium-octeon/octeon-platform.c
arch/mips/configs/ar7_defconfig
arch/mips/configs/bcm47xx_defconfig
arch/mips/configs/bcm63xx_defconfig
arch/mips/configs/bigsur_defconfig
arch/mips/configs/capcella_defconfig
arch/mips/configs/cavium-octeon_defconfig
arch/mips/configs/cobalt_defconfig
arch/mips/configs/db1000_defconfig
arch/mips/configs/db1100_defconfig
arch/mips/configs/db1200_defconfig
arch/mips/configs/db1500_defconfig
arch/mips/configs/db1550_defconfig
arch/mips/configs/decstation_defconfig
arch/mips/configs/e55_defconfig
arch/mips/configs/excite_defconfig [deleted file]
arch/mips/configs/fuloong2e_defconfig
arch/mips/configs/ip22_defconfig
arch/mips/configs/ip27_defconfig
arch/mips/configs/ip28_defconfig
arch/mips/configs/ip32_defconfig
arch/mips/configs/jazz_defconfig
arch/mips/configs/jmr3927_defconfig
arch/mips/configs/lasat_defconfig
arch/mips/configs/lemote2f_defconfig [new file with mode: 0644]
arch/mips/configs/malta_defconfig
arch/mips/configs/markeins_defconfig
arch/mips/configs/mipssim_defconfig
arch/mips/configs/mpc30x_defconfig
arch/mips/configs/msp71xx_defconfig
arch/mips/configs/mtx1_defconfig
arch/mips/configs/pb1100_defconfig
arch/mips/configs/pb1500_defconfig
arch/mips/configs/pb1550_defconfig
arch/mips/configs/pnx8335-stb225_defconfig
arch/mips/configs/pnx8550-jbs_defconfig
arch/mips/configs/pnx8550-stb810_defconfig
arch/mips/configs/powertv_defconfig [new file with mode: 0644]
arch/mips/configs/rb532_defconfig
arch/mips/configs/rbtx49xx_defconfig
arch/mips/configs/rm200_defconfig
arch/mips/configs/sb1250-swarm_defconfig
arch/mips/configs/tb0219_defconfig
arch/mips/configs/tb0226_defconfig
arch/mips/configs/tb0287_defconfig
arch/mips/configs/workpad_defconfig
arch/mips/configs/wrppmc_defconfig
arch/mips/configs/yosemite_defconfig
arch/mips/fw/arc/cmdline.c
arch/mips/include/asm/asm-offsets.h [new file with mode: 0644]
arch/mips/include/asm/bootinfo.h
arch/mips/include/asm/clock.h [new file with mode: 0644]
arch/mips/include/asm/cop2.h [new file with mode: 0644]
arch/mips/include/asm/cpu.h
arch/mips/include/asm/elf.h
arch/mips/include/asm/fcntl.h
arch/mips/include/asm/fpu.h
arch/mips/include/asm/fpu_emulator.h
arch/mips/include/asm/ftrace.h
arch/mips/include/asm/irq.h
arch/mips/include/asm/mach-excite/cpu-feature-overrides.h [deleted file]
arch/mips/include/asm/mach-excite/excite.h [deleted file]
arch/mips/include/asm/mach-excite/excite_fpga.h [deleted file]
arch/mips/include/asm/mach-excite/excite_nandflash.h [deleted file]
arch/mips/include/asm/mach-excite/rm9k_eth.h [deleted file]
arch/mips/include/asm/mach-excite/rm9k_wdt.h [deleted file]
arch/mips/include/asm/mach-excite/rm9k_xicap.h [deleted file]
arch/mips/include/asm/mach-loongson/cs5536/cs5536.h [new file with mode: 0644]
arch/mips/include/asm/mach-loongson/cs5536/cs5536_mfgpt.h [new file with mode: 0644]
arch/mips/include/asm/mach-loongson/cs5536/cs5536_pci.h [new file with mode: 0644]
arch/mips/include/asm/mach-loongson/cs5536/cs5536_vsm.h [new file with mode: 0644]
arch/mips/include/asm/mach-loongson/dma-coherence.h
arch/mips/include/asm/mach-loongson/loongson.h
arch/mips/include/asm/mach-loongson/machine.h
arch/mips/include/asm/mach-loongson/mem.h
arch/mips/include/asm/mach-loongson/pci.h
arch/mips/include/asm/mach-powertv/asic.h [new file with mode: 0644]
arch/mips/include/asm/mach-powertv/asic_regs.h [new file with mode: 0644]
arch/mips/include/asm/mach-powertv/dma-coherence.h [new file with mode: 0644]
arch/mips/include/asm/mach-powertv/interrupts.h [new file with mode: 0644]
arch/mips/include/asm/mach-powertv/ioremap.h [new file with mode: 0644]
arch/mips/include/asm/mach-powertv/irq.h [new file with mode: 0644]
arch/mips/include/asm/mach-powertv/powertv-clock.h [new file with mode: 0644]
arch/mips/include/asm/mach-powertv/war.h [moved from arch/mips/include/asm/mach-excite/war.h with 56% similarity]
arch/mips/include/asm/mips-boards/bonito64.h
arch/mips/include/asm/mmu_context.h
arch/mips/include/asm/octeon/cvmx-agl-defs.h [new file with mode: 0644]
arch/mips/include/asm/octeon/cvmx-mixx-defs.h [new file with mode: 0644]
arch/mips/include/asm/octeon/cvmx-smix-defs.h [new file with mode: 0644]
arch/mips/include/asm/octeon/octeon.h
arch/mips/include/asm/pgtable.h
arch/mips/include/asm/sgialib.h
arch/mips/include/asm/spinlock.h
arch/mips/include/asm/spinlock_types.h
arch/mips/include/asm/stackframe.h
arch/mips/kernel/Makefile
arch/mips/kernel/cpu-probe.c
arch/mips/kernel/cpufreq/Kconfig [new file with mode: 0644]
arch/mips/kernel/cpufreq/Makefile [new file with mode: 0644]
arch/mips/kernel/cpufreq/loongson2_clock.c [new file with mode: 0644]
arch/mips/kernel/cpufreq/loongson2_cpufreq.c [new file with mode: 0644]
arch/mips/kernel/csrc-powertv.c [new file with mode: 0644]
arch/mips/kernel/ftrace.c [new file with mode: 0644]
arch/mips/kernel/irq.c
arch/mips/kernel/mcount.S [new file with mode: 0644]
arch/mips/kernel/mips_ksyms.c
arch/mips/kernel/setup.c
arch/mips/kernel/signal.c
arch/mips/kernel/signal32.c
arch/mips/kernel/smp.c
arch/mips/kernel/smtc.c
arch/mips/kernel/traps.c
arch/mips/kernel/unaligned.c
arch/mips/kernel/vmlinux.lds.S
arch/mips/lasat/picvue_proc.c
arch/mips/lasat/prom.c
arch/mips/lasat/sysctl.c
arch/mips/loongson/Kconfig
arch/mips/loongson/Makefile
arch/mips/loongson/common/Makefile
arch/mips/loongson/common/bonito-irq.c
arch/mips/loongson/common/cmdline.c
arch/mips/loongson/common/cs5536/Makefile [new file with mode: 0644]
arch/mips/loongson/common/cs5536/cs5536_acc.c [new file with mode: 0644]
arch/mips/loongson/common/cs5536/cs5536_ehci.c [new file with mode: 0644]
arch/mips/loongson/common/cs5536/cs5536_ide.c [new file with mode: 0644]
arch/mips/loongson/common/cs5536/cs5536_isa.c [new file with mode: 0644]
arch/mips/loongson/common/cs5536/cs5536_mfgpt.c [new file with mode: 0644]
arch/mips/loongson/common/cs5536/cs5536_ohci.c [new file with mode: 0644]
arch/mips/loongson/common/cs5536/cs5536_pci.c [new file with mode: 0644]
arch/mips/loongson/common/early_printk.c
arch/mips/loongson/common/env.c
arch/mips/loongson/common/init.c
arch/mips/loongson/common/irq.c
arch/mips/loongson/common/machtype.c
arch/mips/loongson/common/mem.c
arch/mips/loongson/common/pci.c
arch/mips/loongson/common/platform.c [new file with mode: 0644]
arch/mips/loongson/common/pm.c [new file with mode: 0644]
arch/mips/loongson/common/reset.c
arch/mips/loongson/common/serial.c [new file with mode: 0644]
arch/mips/loongson/common/time.c
arch/mips/loongson/common/uart_base.c [new file with mode: 0644]
arch/mips/loongson/fuloong-2e/irq.c
arch/mips/loongson/fuloong-2e/reset.c
arch/mips/loongson/lemote-2f/Makefile [new file with mode: 0644]
arch/mips/loongson/lemote-2f/ec_kb3310b.c [new file with mode: 0644]
arch/mips/loongson/lemote-2f/ec_kb3310b.h [new file with mode: 0644]
arch/mips/loongson/lemote-2f/irq.c [new file with mode: 0644]
arch/mips/loongson/lemote-2f/pm.c [new file with mode: 0644]
arch/mips/loongson/lemote-2f/reset.c [new file with mode: 0644]
arch/mips/math-emu/cp1emu.c
arch/mips/math-emu/dsemul.c
arch/mips/mipssim/Makefile
arch/mips/mipssim/sim_setup.c
arch/mips/mm/cerr-sb1.c
arch/mips/mm/init.c
arch/mips/mm/tlbex.c
arch/mips/mm/uasm.c
arch/mips/mm/uasm.h
arch/mips/mti-malta/malta-memory.c
arch/mips/nxp/pnx833x/common/interrupts.c
arch/mips/oprofile/op_model_loongson2.c
arch/mips/pci/Makefile
arch/mips/pci/fixup-excite.c [deleted file]
arch/mips/pci/fixup-fuloong2e.c
arch/mips/pci/fixup-lemote2f.c [new file with mode: 0644]
arch/mips/pci/ops-bonito64.c
arch/mips/pci/ops-loongson2.c [new file with mode: 0644]
arch/mips/pci/pci-excite.c [deleted file]
arch/mips/powertv/Kconfig [new file with mode: 0644]
arch/mips/powertv/Makefile [new file with mode: 0644]
arch/mips/powertv/asic/Kconfig [new file with mode: 0644]
arch/mips/powertv/asic/Makefile [new file with mode: 0644]
arch/mips/powertv/asic/asic-calliope.c [new file with mode: 0644]
arch/mips/powertv/asic/asic-cronus.c [new file with mode: 0644]
arch/mips/powertv/asic/asic-zeus.c [new file with mode: 0644]
arch/mips/powertv/asic/asic_devices.c [new file with mode: 0644]
arch/mips/powertv/asic/asic_int.c [new file with mode: 0644]
arch/mips/powertv/asic/irq_asic.c [new file with mode: 0644]
arch/mips/powertv/asic/prealloc-calliope.c [new file with mode: 0644]
arch/mips/powertv/asic/prealloc-cronus.c [new file with mode: 0644]
arch/mips/powertv/asic/prealloc-cronuslite.c [new file with mode: 0644]
arch/mips/powertv/asic/prealloc-zeus.c [new file with mode: 0644]
arch/mips/powertv/cmdline.c [new file with mode: 0644]
arch/mips/powertv/init.c [new file with mode: 0644]
arch/mips/powertv/init.h [new file with mode: 0644]
arch/mips/powertv/memory.c [new file with mode: 0644]
arch/mips/powertv/pci/Makefile [new file with mode: 0644]
arch/mips/powertv/pci/fixup-powertv.c [new file with mode: 0644]
arch/mips/powertv/pci/powertv-pci.h [new file with mode: 0644]
arch/mips/powertv/powertv-clock.h [new file with mode: 0644]
arch/mips/powertv/powertv_setup.c [new file with mode: 0644]
arch/mips/powertv/reset.c [new file with mode: 0644]
arch/mips/powertv/reset.h [new file with mode: 0644]
arch/mips/powertv/time.c [moved from arch/mips/mipssim/sim_cmdline.c with 60% similarity]
arch/mips/rb532/prom.c
arch/mips/sgi-ip22/ip22-eisa.c
arch/mips/sgi-ip22/ip22-int.c
arch/mips/sgi-ip22/ip22-setup.c
arch/mips/sgi-ip22/ip22-time.c
arch/mips/sgi-ip32/ip32-setup.c
arch/mips/sibyte/common/cfe.c
arch/mips/sni/a20r.c
arch/mips/sni/pcimt.c
arch/mips/sni/pcit.c
arch/mips/sni/rm200.c
arch/mips/sni/setup.c
arch/mips/txx9/generic/setup.c
arch/mips/vr41xx/common/icu.c
arch/mn10300/include/asm/asm-offsets.h [new file with mode: 0644]
arch/mn10300/include/asm/elf.h
arch/mn10300/kernel/irq.c
arch/parisc/hpux/sys_hpux.c
arch/parisc/include/asm/asm-offsets.h [new file with mode: 0644]
arch/parisc/include/asm/atomic.h
arch/parisc/include/asm/bug.h
arch/parisc/include/asm/elf.h
arch/parisc/include/asm/ftrace.h
arch/parisc/include/asm/spinlock.h
arch/parisc/include/asm/spinlock_types.h
arch/parisc/kernel/asm-offsets.c
arch/parisc/kernel/irq.c
arch/parisc/kernel/signal.c
arch/parisc/kernel/smp.c
arch/parisc/kernel/sys_parisc32.c
arch/parisc/kernel/unwind.c
arch/parisc/lib/bitops.c
arch/powerpc/Kconfig
arch/powerpc/Kconfig.debug
arch/powerpc/boot/Makefile
arch/powerpc/boot/dts/gamecube.dts [new file with mode: 0644]
arch/powerpc/boot/dts/katmai.dts
arch/powerpc/boot/dts/mpc8315erdb.dts
arch/powerpc/boot/dts/mpc8349emitx.dts
arch/powerpc/boot/dts/warp.dts
arch/powerpc/boot/dts/wii.dts [new file with mode: 0644]
arch/powerpc/boot/gamecube-head.S [new file with mode: 0644]
arch/powerpc/boot/gamecube.c [new file with mode: 0644]
arch/powerpc/boot/ugecon.c [new file with mode: 0644]
arch/powerpc/boot/ugecon.h [new file with mode: 0644]
arch/powerpc/boot/wii-head.S [new file with mode: 0644]
arch/powerpc/boot/wii.c [new file with mode: 0644]
arch/powerpc/boot/wrapper
arch/powerpc/configs/g5_defconfig
arch/powerpc/configs/gamecube_defconfig [new file with mode: 0644]
arch/powerpc/configs/iseries_defconfig
arch/powerpc/configs/ppc64_defconfig
arch/powerpc/configs/ppc64e_defconfig
arch/powerpc/configs/pseries_defconfig
arch/powerpc/configs/wii_defconfig [new file with mode: 0644]
arch/powerpc/include/asm/asm-offsets.h [new file with mode: 0644]
arch/powerpc/include/asm/async_tx.h [new file with mode: 0644]
arch/powerpc/include/asm/bug.h
arch/powerpc/include/asm/dcr-regs.h
arch/powerpc/include/asm/dma-mapping.h
arch/powerpc/include/asm/elf.h
arch/powerpc/include/asm/fixmap.h
arch/powerpc/include/asm/gpio.h
arch/powerpc/include/asm/module.h
arch/powerpc/include/asm/ptrace.h
arch/powerpc/include/asm/rtas.h
arch/powerpc/include/asm/spinlock.h
arch/powerpc/include/asm/spinlock_types.h
arch/powerpc/include/asm/udbg.h
arch/powerpc/kernel/align.c
arch/powerpc/kernel/cputable.c
arch/powerpc/kernel/head_32.S
arch/powerpc/kernel/iommu.c
arch/powerpc/kernel/irq.c
arch/powerpc/kernel/pci-common.c
arch/powerpc/kernel/rtas.c
arch/powerpc/kernel/traps.c
arch/powerpc/kernel/udbg.c
arch/powerpc/kernel/vmlinux.lds.S
arch/powerpc/kvm/book3s_64_mmu.c
arch/powerpc/lib/locks.c
arch/powerpc/mm/40x_mmu.c
arch/powerpc/mm/44x_mmu.c
arch/powerpc/mm/fsl_booke_mmu.c
arch/powerpc/mm/hash_utils_64.c
arch/powerpc/mm/init_32.c
arch/powerpc/mm/mmu_context_nohash.c
arch/powerpc/mm/mmu_decl.h
arch/powerpc/mm/pgtable_32.c
arch/powerpc/mm/ppc_mmu_32.c
arch/powerpc/platforms/52xx/efika.c
arch/powerpc/platforms/52xx/media5200.c
arch/powerpc/platforms/83xx/suspend.c
arch/powerpc/platforms/85xx/mpc85xx_mds.c
arch/powerpc/platforms/Kconfig.cputype
arch/powerpc/platforms/amigaone/setup.c
arch/powerpc/platforms/cell/interrupt.c
arch/powerpc/platforms/cell/spufs/Makefile
arch/powerpc/platforms/chrp/setup.c
arch/powerpc/platforms/embedded6xx/Kconfig
arch/powerpc/platforms/embedded6xx/Makefile
arch/powerpc/platforms/embedded6xx/flipper-pic.c [new file with mode: 0644]
arch/powerpc/platforms/embedded6xx/flipper-pic.h [new file with mode: 0644]
arch/powerpc/platforms/embedded6xx/gamecube.c [new file with mode: 0644]
arch/powerpc/platforms/embedded6xx/hlwd-pic.c [new file with mode: 0644]
arch/powerpc/platforms/embedded6xx/hlwd-pic.h [new file with mode: 0644]
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c [new file with mode: 0644]
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h [new file with mode: 0644]
arch/powerpc/platforms/embedded6xx/wii.c [new file with mode: 0644]
arch/powerpc/platforms/iseries/irq.c
arch/powerpc/platforms/iseries/mf.c
arch/powerpc/platforms/iseries/viopath.c
arch/powerpc/platforms/pasemi/setup.c
arch/powerpc/platforms/powermac/bootx_init.c
arch/powerpc/platforms/pseries/Kconfig
arch/powerpc/platforms/pseries/cmm.c
arch/powerpc/platforms/pseries/dlpar.c
arch/powerpc/platforms/pseries/smp.c
arch/powerpc/platforms/pseries/xics.c
arch/powerpc/sysdev/cpm2_pic.c
arch/powerpc/sysdev/fsl_msi.c
arch/powerpc/sysdev/fsl_pci.c
arch/powerpc/sysdev/mpc8xxx_gpio.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/sysdev/mpic_msi.c
arch/powerpc/sysdev/mpic_u3msi.c
arch/powerpc/sysdev/uic.c
arch/s390/appldata/appldata_base.c
arch/s390/crypto/aes_s390.c
arch/s390/hypfs/hypfs_diag.c
arch/s390/hypfs/hypfs_vm.c
arch/s390/include/asm/asm-offsets.h [new file with mode: 0644]
arch/s390/include/asm/elf.h
arch/s390/include/asm/spinlock.h
arch/s390/include/asm/spinlock_types.h
arch/s390/include/asm/unistd.h
arch/s390/kernel/compat_wrapper.S
arch/s390/kernel/debug.c
arch/s390/kernel/ipl.c
arch/s390/kernel/ptrace.c
arch/s390/kernel/syscalls.S
arch/s390/kernel/traps.c
arch/s390/lib/spinlock.c
arch/score/include/asm/asm-offsets.h [new file with mode: 0644]
arch/score/include/asm/cacheflush.h
arch/score/include/asm/delay.h
arch/score/include/asm/elf.h
arch/score/include/asm/page.h
arch/score/kernel/setup.c
arch/score/mm/cache.c
arch/score/mm/init.c
arch/sh/Kconfig.debug
arch/sh/Makefile
arch/sh/boards/mach-ap325rxa/setup.c
arch/sh/boards/mach-ecovec24/setup.c
arch/sh/boards/mach-kfr2r09/lcd_wqvga.c
arch/sh/boards/mach-kfr2r09/setup.c
arch/sh/boards/mach-migor/setup.c
arch/sh/boards/mach-se/7722/irq.c
arch/sh/boards/mach-se/7724/setup.c
arch/sh/configs/ecovec24-romimage_defconfig
arch/sh/configs/ecovec24_defconfig
arch/sh/configs/rts7751r2d1_defconfig
arch/sh/configs/rts7751r2dplus_defconfig
arch/sh/drivers/pci/fixups-rts7751r2d.c
arch/sh/include/asm/.gitignore [deleted file]
arch/sh/include/asm/asm-offsets.h [new file with mode: 0644]
arch/sh/include/asm/dma.h
arch/sh/include/asm/elf.h
arch/sh/include/asm/io.h
arch/sh/include/asm/machvec.h
arch/sh/include/asm/pgtable_32.h
arch/sh/include/asm/spinlock.h
arch/sh/include/asm/spinlock_types.h
arch/sh/include/asm/unistd_32.h
arch/sh/include/asm/unistd_64.h
arch/sh/include/cpu-sh4/cpu/dma-sh4a.h
arch/sh/include/mach-kfr2r09/mach/kfr2r09.h
arch/sh/kernel/Makefile
arch/sh/kernel/cpu/irq/ipr.c
arch/sh/kernel/cpu/sh2/setup-sh7619.c
arch/sh/kernel/cpu/sh2a/setup-mxg.c
arch/sh/kernel/cpu/sh2a/setup-sh7201.c
arch/sh/kernel/cpu/sh2a/setup-sh7203.c
arch/sh/kernel/cpu/sh2a/setup-sh7206.c
arch/sh/kernel/cpu/sh3/setup-sh7705.c
arch/sh/kernel/cpu/sh3/setup-sh770x.c
arch/sh/kernel/cpu/sh3/setup-sh7710.c
arch/sh/kernel/cpu/sh3/setup-sh7720.c
arch/sh/kernel/cpu/sh4/setup-sh4-202.c
arch/sh/kernel/cpu/sh4/setup-sh7750.c
arch/sh/kernel/cpu/sh4/setup-sh7760.c
arch/sh/kernel/cpu/sh4a/setup-sh7343.c
arch/sh/kernel/cpu/sh4a/setup-sh7366.c
arch/sh/kernel/cpu/sh4a/setup-sh7722.c
arch/sh/kernel/cpu/sh4a/setup-sh7723.c
arch/sh/kernel/cpu/sh4a/setup-sh7724.c
arch/sh/kernel/cpu/sh4a/setup-sh7757.c
arch/sh/kernel/cpu/sh4a/setup-sh7763.c
arch/sh/kernel/cpu/sh4a/setup-sh7770.c
arch/sh/kernel/cpu/sh4a/setup-sh7780.c
arch/sh/kernel/cpu/sh4a/setup-sh7785.c
arch/sh/kernel/cpu/sh4a/setup-sh7786.c
arch/sh/kernel/cpu/sh4a/setup-shx3.c
arch/sh/kernel/cpu/sh5/fpu.c
arch/sh/kernel/cpu/sh5/setup-sh5.c
arch/sh/kernel/early_printk.c
arch/sh/kernel/ftrace.c
arch/sh/kernel/idle.c
arch/sh/kernel/irq.c
arch/sh/kernel/process_64.c
arch/sh/kernel/ptrace_64.c
arch/sh/kernel/setup.c
arch/sh/kernel/signal_64.c
arch/sh/kernel/syscalls_32.S
arch/sh/kernel/traps_32.c
arch/sh/kernel/traps_64.c
arch/sh/mm/cache-sh4.c
arch/sh/mm/cache.c
arch/sh/mm/ioremap_32.c
arch/sh/mm/ioremap_64.c
arch/sh/mm/numa.c
arch/sh/tools/Makefile
arch/sh/tools/gen-mach-types
arch/sparc/Kconfig
arch/sparc/Kconfig.debug
arch/sparc/include/asm/asm-offsets.h [new file with mode: 0644]
arch/sparc/include/asm/elf_32.h
arch/sparc/include/asm/elf_64.h
arch/sparc/include/asm/fcntl.h
arch/sparc/include/asm/spinlock_32.h
arch/sparc/include/asm/spinlock_64.h
arch/sparc/include/asm/spinlock_types.h
arch/sparc/include/asm/string_32.h
arch/sparc/include/asm/string_64.h
arch/sparc/include/asm/thread_info_64.h
arch/sparc/include/asm/uaccess_32.h
arch/sparc/include/asm/uaccess_64.h
arch/sparc/include/asm/unistd.h
arch/sparc/kernel/entry.S
arch/sparc/kernel/ftrace.c
arch/sparc/kernel/iommu.c
arch/sparc/kernel/irq_64.c
arch/sparc/kernel/kprobes.c
arch/sparc/kernel/ldc.c
arch/sparc/kernel/mdesc.c
arch/sparc/kernel/of_device_64.c
arch/sparc/kernel/pci.c
arch/sparc/kernel/ptrace_64.c
arch/sparc/kernel/sparc_ksyms_64.c
arch/sparc/kernel/syscalls.S
arch/sparc/kernel/time_64.c
arch/sparc/kernel/unaligned_32.c
arch/sparc/kernel/unaligned_64.c
arch/sparc/kernel/visemul.c
arch/sparc/lib/Makefile
arch/sparc/lib/bzero.S
arch/sparc/lib/checksum_32.S
arch/sparc/lib/ksyms.c
arch/sparc/lib/mcount.S
arch/sparc/lib/memcpy.S
arch/sparc/lib/memset.S
arch/sparc/lib/usercopy.c [new file with mode: 0644]
arch/sparc/math-emu/math_32.c
arch/sparc/math-emu/math_64.c
arch/sparc/mm/fault_64.c
arch/sparc/mm/sun4c.c
arch/um/Makefile
arch/um/drivers/mconsole_kern.c
arch/um/drivers/ubd_kern.c
arch/um/include/asm/asm-offsets.h [new file with mode: 0644]
arch/um/kernel/exitcode.c
arch/um/kernel/irq.c
arch/um/kernel/process.c
arch/um/sys-i386/asm/elf.h
arch/um/sys-ppc/asm/elf.h
arch/um/sys-x86_64/asm/elf.h
arch/x86/Kconfig
arch/x86/boot/compressed/relocs.c
arch/x86/boot/header.S
arch/x86/boot/version.c
arch/x86/include/asm/acpi.h
arch/x86/include/asm/asm-offsets.h [new file with mode: 0644]
arch/x86/include/asm/cpufeature.h
arch/x86/include/asm/dma-mapping.h
arch/x86/include/asm/elf.h
arch/x86/include/asm/geode.h
arch/x86/include/asm/hw_irq.h
arch/x86/include/asm/kvm.h
arch/x86/include/asm/msr-index.h
arch/x86/include/asm/msr.h
arch/x86/include/asm/olpc.h
arch/x86/include/asm/paravirt.h
arch/x86/include/asm/paravirt_types.h
arch/x86/include/asm/processor.h
arch/x86/include/asm/ptrace.h
arch/x86/include/asm/spinlock.h
arch/x86/include/asm/spinlock_types.h
arch/x86/include/asm/stacktrace.h
arch/x86/include/asm/swiotlb.h
arch/x86/include/asm/sys_ia32.h
arch/x86/include/asm/syscalls.h
arch/x86/include/asm/topology.h
arch/x86/include/asm/uv/bios.h
arch/x86/include/asm/uv/uv_hub.h
arch/x86/kernel/Makefile
arch/x86/kernel/acpi/Makefile
arch/x86/kernel/acpi/cstate.c
arch/x86/kernel/acpi/processor.c [deleted file]
arch/x86/kernel/acpi/sleep.c
arch/x86/kernel/amd_iommu.c
arch/x86/kernel/apic/apic_flat_64.c
arch/x86/kernel/apic/bigsmp_32.c
arch/x86/kernel/apic/io_apic.c
arch/x86/kernel/apic/x2apic_cluster.c
arch/x86/kernel/apic/x2apic_phys.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/kernel/bios_uv.c
arch/x86/kernel/cpu/amd.c
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
arch/x86/kernel/cpu/cpufreq/powernow-k8.c
arch/x86/kernel/cpu/intel.c
arch/x86/kernel/cpu/mcheck/mce-inject.c
arch/x86/kernel/cpu/mtrr/if.c
arch/x86/kernel/cpu/perf_event.c
arch/x86/kernel/cpuid.c
arch/x86/kernel/dumpstack.c
arch/x86/kernel/dumpstack.h
arch/x86/kernel/dumpstack_32.c
arch/x86/kernel/dumpstack_64.c
arch/x86/kernel/e820.c
arch/x86/kernel/entry_32.S
arch/x86/kernel/entry_64.S
arch/x86/kernel/geode_32.c [deleted file]
arch/x86/kernel/ioport.c
arch/x86/kernel/irq.c
arch/x86/kernel/mfgpt_32.c [deleted file]
arch/x86/kernel/microcode_core.c
arch/x86/kernel/msr.c
arch/x86/kernel/olpc.c
arch/x86/kernel/paravirt-spinlocks.c
arch/x86/kernel/pci-calgary_64.c
arch/x86/kernel/pci-dma.c
arch/x86/kernel/pci-gart_64.c
arch/x86/kernel/pci-swiotlb.c
arch/x86/kernel/process.c
arch/x86/kernel/process_32.c
arch/x86/kernel/process_64.c
arch/x86/kernel/ptrace.c
arch/x86/kernel/reboot_fixups_32.c
arch/x86/kernel/signal.c
arch/x86/kernel/stacktrace.c
arch/x86/kernel/tsc.c
arch/x86/kernel/tsc_sync.c
arch/x86/kernel/uv_irq.c
arch/x86/kernel/vm86_32.c
arch/x86/kernel/vmlinux.lds.S
arch/x86/kernel/x8664_ksyms_64.c
arch/x86/kvm/lapic.c
arch/x86/kvm/paging_tmpl.h
arch/x86/kvm/x86.c
arch/x86/lib/Makefile
arch/x86/lib/msr-smp.c [new file with mode: 0644]
arch/x86/lib/msr.c
arch/x86/mm/srat_32.c
arch/x86/mm/srat_64.c
arch/x86/oprofile/backtrace.c
arch/x86/pci/bus_numa.c
arch/x86/tools/chkobjdump.awk
arch/x86/tools/gen-insn-attr-x86.awk
arch/x86/xen/spinlock.c
arch/xtensa/include/asm/asm-offsets.h [new file with mode: 0644]
arch/xtensa/include/asm/elf.h
arch/xtensa/include/asm/syscall.h
arch/xtensa/include/asm/unistd.h
arch/xtensa/kernel/irq.c
arch/xtensa/kernel/syscall.c
block/blk-barrier.c
block/blk-settings.c
block/cfq-iosched.c
crypto/async_tx/raid6test.c
drivers/Kconfig
drivers/accessibility/braille/braille_console.c
drivers/acpi/Makefile
drivers/acpi/acpi_pad.c
drivers/acpi/acpica/acnamesp.h
drivers/acpi/acpica/acobject.h
drivers/acpi/acpica/dsmethod.c
drivers/acpi/acpica/dswload.c
drivers/acpi/acpica/evregion.c
drivers/acpi/acpica/evrgnini.c
drivers/acpi/acpica/evxface.c
drivers/acpi/acpica/evxfevnt.c
drivers/acpi/acpica/evxfregn.c
drivers/acpi/acpica/exmutex.c
drivers/acpi/acpica/nsaccess.c
drivers/acpi/acpica/nsdump.c
drivers/acpi/acpica/nseval.c
drivers/acpi/acpica/nsnames.c
drivers/acpi/acpica/nspredef.c
drivers/acpi/acpica/nsrepair.c
drivers/acpi/acpica/nsrepair2.c
drivers/acpi/acpica/nsutils.c
drivers/acpi/acpica/nsxfeval.c
drivers/acpi/acpica/nsxfname.c
drivers/acpi/acpica/nsxfobj.c
drivers/acpi/acpica/psxface.c
drivers/acpi/acpica/rsxface.c
drivers/acpi/acpica/utcopy.c
drivers/acpi/battery.c
drivers/acpi/blacklist.c
drivers/acpi/bus.c
drivers/acpi/button.c
drivers/acpi/debug.c
drivers/acpi/dock.c
drivers/acpi/ec.c
drivers/acpi/fan.c
drivers/acpi/internal.h
drivers/acpi/numa.c
drivers/acpi/osl.c
drivers/acpi/pci_root.c
drivers/acpi/processor_core.c
drivers/acpi/processor_idle.c
drivers/acpi/processor_pdc.c [new file with mode: 0644]
drivers/acpi/processor_perflib.c
drivers/acpi/sleep.c
drivers/acpi/thermal.c
drivers/acpi/video.c
drivers/ata/Kconfig
drivers/ata/libata-scsi.c
drivers/ata/libata-sff.c
drivers/ata/pata_bf54x.c
drivers/ata/pata_cmd64x.c
drivers/ata/pata_hpt3x2n.c
drivers/ata/pata_octeon_cf.c
drivers/ata/sata_mv.c
drivers/atm/iphase.c
drivers/base/bus.c
drivers/base/core.c
drivers/base/devtmpfs.c
drivers/base/driver.c
drivers/base/memory.c
drivers/base/node.c
drivers/base/platform.c
drivers/base/power/main.c
drivers/base/power/runtime.c
drivers/block/DAC960.c
drivers/block/aoe/aoecmd.c
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_nl.c
drivers/block/drbd/drbd_proc.c
drivers/block/drbd/drbd_receiver.c
drivers/block/drbd/drbd_worker.c
drivers/block/floppy.c
drivers/block/mg_disk.c
drivers/block/xd.c
drivers/bluetooth/btusb.c
drivers/char/Kconfig
drivers/char/efirtc.c
drivers/char/hvc_iucv.c
drivers/char/hw_random/core.c
drivers/char/ipmi/ipmi_kcs_sm.c
drivers/char/ipmi/ipmi_si_intf.c
drivers/char/mem.c
drivers/char/misc.c
drivers/char/nozomi.c
drivers/char/nwflash.c
drivers/char/random.c
drivers/char/sonypi.c
drivers/char/sysrq.c
drivers/char/vt.c
drivers/clocksource/Kconfig [new file with mode: 0644]
drivers/clocksource/Makefile
drivers/clocksource/cs5535-clockevt.c [new file with mode: 0644]
drivers/cpuidle/governors/ladder.c
drivers/dma/Kconfig
drivers/dma/Makefile
drivers/dma/at_hdmac.c
drivers/dma/coh901318.c [new file with mode: 0644]
drivers/dma/coh901318_lli.c [new file with mode: 0644]
drivers/dma/coh901318_lli.h [new file with mode: 0644]
drivers/dma/dmatest.c
drivers/dma/dw_dmac.c
drivers/dma/ioat/dma.c
drivers/dma/ioat/dma.h
drivers/dma/ioat/dma_v2.c
drivers/dma/ioat/dma_v2.h
drivers/dma/ioat/dma_v3.c
drivers/dma/ioat/registers.h
drivers/dma/iop-adma.c
drivers/dma/ppc4xx/Makefile [new file with mode: 0644]
drivers/dma/ppc4xx/adma.c [new file with mode: 0644]
drivers/dma/ppc4xx/adma.h [new file with mode: 0644]
drivers/dma/ppc4xx/dma.h [new file with mode: 0644]
drivers/dma/ppc4xx/xor.h [new file with mode: 0644]
drivers/dma/shdma.c
drivers/dma/shdma.h
drivers/dma/txx9dmac.c
drivers/edac/amd64_edac.c
drivers/edac/edac_mce_amd.c
drivers/edac/edac_pci_sysfs.c
drivers/edac/i5100_edac.c
drivers/firmware/Kconfig
drivers/firmware/dmi_scan.c
drivers/gpio/Kconfig
drivers/gpio/Makefile
drivers/gpio/cs5535-gpio.c [new file with mode: 0644]
drivers/gpio/gpiolib.c
drivers/gpio/langwell_gpio.c
drivers/gpio/timbgpio.c [new file with mode: 0644]
drivers/gpu/drm/Makefile
drivers/gpu/drm/drm_drv.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_ioc32.c
drivers/gpu/drm/drm_mm.c
drivers/gpu/drm/i2c/ch7006_drv.c
drivers/gpu/drm/i2c/ch7006_mode.c
drivers/gpu/drm/i810/i810_dma.c
drivers/gpu/drm/i810/i810_drv.c
drivers/gpu/drm/i830/i830_dma.c
drivers/gpu/drm/i830/i830_drv.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_ioc32.c
drivers/gpu/drm/mga/mga_drv.c
drivers/gpu/drm/mga/mga_ioc32.c
drivers/gpu/drm/nouveau/Kconfig
drivers/gpu/drm/nouveau/Makefile
drivers/gpu/drm/nouveau/nouveau_bios.c
drivers/gpu/drm/nouveau/nouveau_bios.h
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_connector.c
drivers/gpu/drm/nouveau/nouveau_dp.c
drivers/gpu/drm/nouveau/nouveau_drv.c
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_fbcon.c
drivers/gpu/drm/nouveau/nouveau_fence.c
drivers/gpu/drm/nouveau/nouveau_gem.c
drivers/gpu/drm/nouveau/nouveau_grctx.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nouveau_grctx.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/nouveau_ioc32.c
drivers/gpu/drm/nouveau/nouveau_mem.c
drivers/gpu/drm/nouveau/nouveau_state.c
drivers/gpu/drm/nouveau/nv04_crtc.c
drivers/gpu/drm/nouveau/nv04_dac.c
drivers/gpu/drm/nouveau/nv04_dfp.c
drivers/gpu/drm/nouveau/nv04_display.c
drivers/gpu/drm/nouveau/nv04_graph.c
drivers/gpu/drm/nouveau/nv10_graph.c
drivers/gpu/drm/nouveau/nv17_tv.c
drivers/gpu/drm/nouveau/nv40_graph.c
drivers/gpu/drm/nouveau/nv40_grctx.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nv50_crtc.c
drivers/gpu/drm/nouveau/nv50_cursor.c
drivers/gpu/drm/nouveau/nv50_dac.c
drivers/gpu/drm/nouveau/nv50_display.c
drivers/gpu/drm/nouveau/nv50_fifo.c
drivers/gpu/drm/nouveau/nv50_graph.c
drivers/gpu/drm/nouveau/nv50_sor.c
drivers/gpu/drm/r128/r128_drv.c
drivers/gpu/drm/r128/r128_ioc32.c
drivers/gpu/drm/radeon/Makefile
drivers/gpu/drm/radeon/atom.c
drivers/gpu/drm/radeon/atom.h
drivers/gpu/drm/radeon/atombios.h
drivers/gpu/drm/radeon/r100.c
drivers/gpu/drm/radeon/r100_track.h
drivers/gpu/drm/radeon/r200.c
drivers/gpu/drm/radeon/r300.c
drivers/gpu/drm/radeon/r300_cmdbuf.c
drivers/gpu/drm/radeon/r300_reg.h
drivers/gpu/drm/radeon/r600.c
drivers/gpu/drm/radeon/r600_audio.c [new file with mode: 0644]
drivers/gpu/drm/radeon/r600_cs.c
drivers/gpu/drm/radeon/r600_hdmi.c [new file with mode: 0644]
drivers/gpu/drm/radeon/r600_reg.h
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/radeon_atombios.c
drivers/gpu/drm/radeon/radeon_clocks.c
drivers/gpu/drm/radeon/radeon_combios.c
drivers/gpu/drm/radeon/radeon_connectors.c
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/radeon/radeon_encoders.c
drivers/gpu/drm/radeon/radeon_fence.c
drivers/gpu/drm/radeon/radeon_gem.c
drivers/gpu/drm/radeon/radeon_ioc32.c
drivers/gpu/drm/radeon/radeon_legacy_crtc.c
drivers/gpu/drm/radeon/radeon_legacy_encoders.c
drivers/gpu/drm/radeon/radeon_mode.h
drivers/gpu/drm/radeon/radeon_object.c
drivers/gpu/drm/radeon/radeon_object.h
drivers/gpu/drm/radeon/radeon_pm.c
drivers/gpu/drm/radeon/radeon_test.c
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/gpu/drm/radeon/rs400.c
drivers/gpu/drm/radeon/rv770.c
drivers/gpu/drm/savage/savage_drv.c
drivers/gpu/drm/sis/sis_drv.c
drivers/gpu/drm/tdfx/tdfx_drv.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_bo_vm.c
drivers/gpu/drm/via/via_drv.c
drivers/gpu/drm/vmwgfx/Kconfig [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/Makefile [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/svga3d_reg.h [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/svga_escape.h [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/svga_overlay.h [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/svga_reg.h [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/svga_types.h [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_irq.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_reg.h [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c [new file with mode: 0644]
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c [new file with mode: 0644]
drivers/hid/hid-lg.h
drivers/hwmon/Kconfig
drivers/hwmon/Makefile
drivers/hwmon/adm1021.c
drivers/hwmon/adm1025.c
drivers/hwmon/adm1026.c
drivers/hwmon/adm1029.c
drivers/hwmon/adm1031.c
drivers/hwmon/adm9240.c
drivers/hwmon/ads7828.c
drivers/hwmon/adt7462.c
drivers/hwmon/adt7470.c
drivers/hwmon/adt7473.c
drivers/hwmon/adt7475.c
drivers/hwmon/applesmc.c
drivers/hwmon/asb100.c
drivers/hwmon/atxp1.c
drivers/hwmon/dme1737.c
drivers/hwmon/ds1621.c
drivers/hwmon/f75375s.c
drivers/hwmon/fschmd.c
drivers/hwmon/gl518sm.c
drivers/hwmon/gl520sm.c
drivers/hwmon/k10temp.c [new file with mode: 0644]
drivers/hwmon/lis3lv02d.c
drivers/hwmon/lis3lv02d.h
drivers/hwmon/lis3lv02d_i2c.c [new file with mode: 0644]
drivers/hwmon/lm63.c
drivers/hwmon/lm73.c
drivers/hwmon/lm75.c
drivers/hwmon/lm77.c
drivers/hwmon/lm78.c
drivers/hwmon/lm80.c
drivers/hwmon/lm83.c
drivers/hwmon/lm85.c
drivers/hwmon/lm87.c
drivers/hwmon/lm90.c
drivers/hwmon/lm92.c
drivers/hwmon/lm93.c
drivers/hwmon/lm95241.c
drivers/hwmon/max1619.c
drivers/hwmon/max6650.c
drivers/hwmon/pcf8591.c
drivers/hwmon/sht15.c
drivers/hwmon/smsc47m1.c
drivers/hwmon/smsc47m192.c
drivers/hwmon/thmc50.c
drivers/hwmon/tmp401.c
drivers/hwmon/tmp421.c
drivers/hwmon/via-cputemp.c [new file with mode: 0644]
drivers/hwmon/w83627ehf.c
drivers/hwmon/w83627hf.c
drivers/hwmon/w83781d.c
drivers/hwmon/w83791d.c
drivers/hwmon/w83792d.c
drivers/hwmon/w83793.c
drivers/hwmon/w83l785ts.c
drivers/hwmon/w83l786ng.c
drivers/i2c/busses/i2c-bfin-twi.c
drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-pxa.c
drivers/i2c/busses/i2c-s3c2410.c
drivers/i2c/busses/i2c-sh_mobile.c
drivers/i2c/i2c-core.c
drivers/idle/i7300_idle.c
drivers/infiniband/core/addr.c
drivers/infiniband/core/cma.c
drivers/infiniband/core/sa_query.c
drivers/infiniband/core/ucma.c
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/amso1100/c2_qp.c
drivers/infiniband/hw/cxgb3/cxio_hal.h
drivers/infiniband/hw/cxgb3/cxio_resource.c
drivers/infiniband/hw/cxgb3/iwch_qp.c
drivers/infiniband/hw/ehca/ehca_classes.h
drivers/infiniband/hw/ehca/ehca_eq.c
drivers/infiniband/hw/ehca/ehca_main.c
drivers/infiniband/hw/ehca/ehca_reqs.c
drivers/infiniband/hw/ipath/ipath_driver.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/hw/nes/Kconfig
drivers/infiniband/hw/nes/nes.c
drivers/infiniband/hw/nes/nes.h
drivers/infiniband/hw/nes/nes_cm.c
drivers/infiniband/hw/nes/nes_cm.h
drivers/infiniband/hw/nes/nes_context.h
drivers/infiniband/hw/nes/nes_hw.c
drivers/infiniband/hw/nes/nes_hw.h
drivers/infiniband/hw/nes/nes_nic.c
drivers/infiniband/hw/nes/nes_user.h
drivers/infiniband/hw/nes/nes_utils.c
drivers/infiniband/hw/nes/nes_verbs.c
drivers/infiniband/hw/nes/nes_verbs.h
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/iser/iser_memory.c
drivers/input/keyboard/adp5588-keys.c
drivers/input/keyboard/sh_keysc.c
drivers/input/misc/bfin_rotary.c
drivers/input/misc/pcspkr.c
drivers/input/touchscreen/pcap_ts.c
drivers/isdn/mISDN/l1oip_core.c
drivers/leds/Kconfig
drivers/leds/Makefile
drivers/leds/led-class.c
drivers/leds/leds-adp5520.c [new file with mode: 0644]
drivers/leds/leds-alix2.c
drivers/leds/leds-cobalt-qube.c
drivers/leds/leds-cobalt-raq.c
drivers/leds/leds-lt3593.c [new file with mode: 0644]
drivers/leds/leds-pwm.c
drivers/leds/leds-regulator.c [new file with mode: 0644]
drivers/leds/leds-ss4200.c [new file with mode: 0644]
drivers/leds/ledtrig-timer.c
drivers/md/dm-crypt.c
drivers/md/dm-exception-store.c
drivers/md/dm-exception-store.h
drivers/md/dm-io.c
drivers/md/dm-ioctl.c
drivers/md/dm-kcopyd.c
drivers/md/dm-log.c
drivers/md/dm-mpath.c
drivers/md/dm-raid1.c
drivers/md/dm-region-hash.c
drivers/md/dm-snap-persistent.c
drivers/md/dm-snap-transient.c
drivers/md/dm-snap.c
drivers/md/dm-sysfs.c
drivers/md/dm-table.c
drivers/md/dm-uevent.c
drivers/md/dm.c
drivers/md/dm.h
drivers/md/md.c
drivers/media/IR/Kconfig [new file with mode: 0644]
drivers/media/IR/Makefile [new file with mode: 0644]
drivers/media/IR/ir-functions.c [moved from drivers/media/common/ir-functions.c with 92% similarity]
drivers/media/IR/ir-keymaps.c [moved from drivers/media/common/ir-keymaps.c with 97% similarity]
drivers/media/IR/ir-keytable.c [moved from drivers/media/common/ir-keytable.c with 81% similarity]
drivers/media/Kconfig
drivers/media/Makefile
drivers/media/common/Makefile
drivers/media/common/saa7146_fops.c
drivers/media/dvb/dm1105/dm1105.c
drivers/media/dvb/dvb-usb/Kconfig
drivers/media/dvb/dvb-usb/dib0700.h
drivers/media/dvb/dvb-usb/dib0700_core.c
drivers/media/dvb/dvb-usb/dib0700_devices.c
drivers/media/dvb/dvb-usb/dibusb-common.c
drivers/media/dvb/dvb-usb/dvb-usb-ids.h
drivers/media/dvb/dvb-usb/dw2102.c
drivers/media/dvb/dvb-usb/friio-fe.c
drivers/media/dvb/dvb-usb/gp8psk-fe.c
drivers/media/dvb/frontends/Kconfig
drivers/media/dvb/frontends/Makefile
drivers/media/dvb/frontends/au8522_decoder.c
drivers/media/dvb/frontends/dib0070.c
drivers/media/dvb/frontends/dib0070.h
drivers/media/dvb/frontends/dib0090.c [new file with mode: 0644]
drivers/media/dvb/frontends/dib0090.h [new file with mode: 0644]
drivers/media/dvb/frontends/dib8000.c
drivers/media/dvb/frontends/dib8000.h
drivers/media/dvb/frontends/dibx000_common.c
drivers/media/dvb/frontends/dibx000_common.h
drivers/media/dvb/frontends/lgs8gxx.c
drivers/media/dvb/frontends/lnbp21.c
drivers/media/dvb/frontends/stv0900_core.c
drivers/media/dvb/frontends/stv090x.c
drivers/media/dvb/frontends/stv090x.h
drivers/media/dvb/siano/smsdvb.c
drivers/media/dvb/siano/smssdio.c
drivers/media/dvb/siano/smsusb.c
drivers/media/dvb/ttpci/budget-ci.c
drivers/media/radio/Kconfig
drivers/media/radio/radio-aimslab.c
drivers/media/radio/radio-aztech.c
drivers/media/radio/radio-gemtek-pci.c
drivers/media/radio/radio-maestro.c
drivers/media/radio/radio-maxiradio.c
drivers/media/radio/radio-mr800.c
drivers/media/radio/radio-rtrack2.c
drivers/media/radio/radio-sf16fmi.c
drivers/media/radio/radio-sf16fmr2.c
drivers/media/radio/radio-tea5764.c
drivers/media/radio/radio-terratec.c
drivers/media/radio/radio-trust.c
drivers/media/radio/radio-typhoon.c
drivers/media/radio/radio-zoltrix.c
drivers/media/radio/si470x/radio-si470x-common.c
drivers/media/radio/si470x/radio-si470x-i2c.c
drivers/media/radio/si470x/radio-si470x-usb.c
drivers/media/radio/si470x/radio-si470x.h
drivers/media/video/Kconfig
drivers/media/video/Makefile
drivers/media/video/arv.c
drivers/media/video/au0828/au0828-video.c
drivers/media/video/au0828/au0828.h
drivers/media/video/bt8xx/bttv-driver.c
drivers/media/video/bt8xx/bttv-i2c.c
drivers/media/video/bt8xx/bttv-input.c
drivers/media/video/c-qcam.c
drivers/media/video/cafe_ccic.c
drivers/media/video/cpia.c
drivers/media/video/cpia2/cpia2_v4l.c
drivers/media/video/cx18/cx18-fileops.c
drivers/media/video/cx18/cx18-streams.c
drivers/media/video/cx231xx/cx231xx-cards.c
drivers/media/video/cx231xx/cx231xx-core.c
drivers/media/video/cx231xx/cx231xx-input.c
drivers/media/video/cx231xx/cx231xx-video.c
drivers/media/video/cx231xx/cx231xx.h
drivers/media/video/cx23885/cimax2.c
drivers/media/video/cx23885/cx23885-417.c
drivers/media/video/cx23885/cx23885-core.c
drivers/media/video/cx23885/cx23885-input.c
drivers/media/video/cx23885/cx23885-video.c
drivers/media/video/cx23885/cx23885.h
drivers/media/video/cx23885/cx23888-ir.c
drivers/media/video/cx88/cx88-blackbird.c
drivers/media/video/cx88/cx88-input.c
drivers/media/video/cx88/cx88-mpeg.c
drivers/media/video/cx88/cx88-video.c
drivers/media/video/cx88/cx88.h
drivers/media/video/davinci/vpfe_capture.c
drivers/media/video/davinci/vpif.c
drivers/media/video/davinci/vpif_capture.c
drivers/media/video/davinci/vpif_display.c
drivers/media/video/davinci/vpss.c
drivers/media/video/em28xx/em28xx-cards.c
drivers/media/video/em28xx/em28xx-core.c
drivers/media/video/em28xx/em28xx-input.c
drivers/media/video/em28xx/em28xx-video.c
drivers/media/video/em28xx/em28xx.h
drivers/media/video/et61x251/et61x251_core.c
drivers/media/video/gspca/conex.c
drivers/media/video/gspca/etoms.c
drivers/media/video/gspca/gl860/gl860-mi1320.c
drivers/media/video/gspca/gl860/gl860-mi2020.c
drivers/media/video/gspca/gl860/gl860.c
drivers/media/video/gspca/gspca.c
drivers/media/video/gspca/gspca.h
drivers/media/video/gspca/m5602/m5602_core.c
drivers/media/video/gspca/m5602/m5602_ov9650.c
drivers/media/video/gspca/m5602/m5602_s5k4aa.c
drivers/media/video/gspca/mr97310a.c
drivers/media/video/gspca/ov519.c
drivers/media/video/gspca/pac7302.c
drivers/media/video/gspca/pac7311.c
drivers/media/video/gspca/sn9c20x.c
drivers/media/video/gspca/sonixb.c
drivers/media/video/gspca/spca506.c
drivers/media/video/gspca/stk014.c
drivers/media/video/gspca/sunplus.c
drivers/media/video/gspca/zc3xx.c
drivers/media/video/hdpvr/hdpvr-core.c
drivers/media/video/hdpvr/hdpvr-video.c
drivers/media/video/ir-kbd-i2c.c
drivers/media/video/ivtv/ivtv-fileops.c
drivers/media/video/ivtv/ivtv-streams.c
drivers/media/video/meye.c
drivers/media/video/meye.h
drivers/media/video/mt9m001.c
drivers/media/video/mt9m111.c
drivers/media/video/mt9t031.c
drivers/media/video/mt9t112.c [new file with mode: 0644]
drivers/media/video/mt9v022.c
drivers/media/video/mx1_camera.c
drivers/media/video/mx3_camera.c
drivers/media/video/omap24xxcam.c
drivers/media/video/ov511.c
drivers/media/video/ov772x.c
drivers/media/video/ov9640.c
drivers/media/video/pms.c
drivers/media/video/pvrusb2/pvrusb2-v4l2.c
drivers/media/video/pwc/pwc-if.c
drivers/media/video/pxa_camera.c
drivers/media/video/rj54n1cb0c.c
drivers/media/video/s2255drv.c
drivers/media/video/saa5246a.c
drivers/media/video/saa7134/saa7134-cards.c
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-empress.c
drivers/media/video/saa7134/saa7134-input.c
drivers/media/video/saa7134/saa7134-video.c
drivers/media/video/se401.c
drivers/media/video/sh_mobile_ceu_camera.c
drivers/media/video/sn9c102/sn9c102_core.c
drivers/media/video/soc_camera.c
drivers/media/video/soc_camera_platform.c
drivers/media/video/soc_mediabus.c [new file with mode: 0644]
drivers/media/video/stk-webcam.c
drivers/media/video/stradis.c
drivers/media/video/stv680.c
drivers/media/video/tw9910.c
drivers/media/video/usbvideo/usbvideo.c
drivers/media/video/usbvideo/vicam.c
drivers/media/video/usbvision/usbvision-i2c.c
drivers/media/video/usbvision/usbvision-video.c
drivers/media/video/uvc/uvc_driver.c
drivers/media/video/uvc/uvc_video.c
drivers/media/video/v4l2-common.c
drivers/media/video/v4l2-compat-ioctl32.c
drivers/media/video/v4l2-dev.c
drivers/media/video/v4l2-ioctl.c
drivers/media/video/videobuf-dma-contig.c
drivers/media/video/vino.c
drivers/media/video/vivi.c
drivers/media/video/w9968cf.c
drivers/media/video/zc0301/zc0301_core.c
drivers/media/video/zoran/zoran_driver.c
drivers/media/video/zr364xx.c
drivers/message/fusion/mptbase.c
drivers/mfd/twl4030-codec.c
drivers/mfd/wm831x-core.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/ad525x_dpot.c [new file with mode: 0644]
drivers/misc/cs5535-mfgpt.c [new file with mode: 0644]
drivers/misc/eeprom/eeprom.c
drivers/misc/enclosure.c
drivers/misc/ics932s401.c
drivers/misc/ioc4.c
drivers/misc/sgi-gru/gru.h
drivers/misc/sgi-gru/gru_instructions.h
drivers/misc/sgi-gru/grufault.c
drivers/misc/sgi-gru/grufile.c
drivers/misc/sgi-gru/gruhandles.c
drivers/misc/sgi-gru/gruhandles.h
drivers/misc/sgi-gru/grukdump.c
drivers/misc/sgi-gru/grukservices.c
drivers/misc/sgi-gru/grukservices.h
drivers/misc/sgi-gru/grulib.h
drivers/misc/sgi-gru/grumain.c
drivers/misc/sgi-gru/gruprocfs.c
drivers/misc/sgi-gru/grutables.h
drivers/misc/sgi-gru/grutlbpurge.c
drivers/misc/sgi-xp/xp.h
drivers/misc/sgi-xp/xp_main.c
drivers/misc/sgi-xp/xp_sn2.c
drivers/misc/sgi-xp/xp_uv.c
drivers/misc/sgi-xp/xpc_partition.c
drivers/misc/sgi-xp/xpc_uv.c
drivers/misc/ti_dac7512.c [new file with mode: 0644]
drivers/mmc/core/Kconfig
drivers/mmc/core/core.c
drivers/mmc/core/core.h
drivers/mmc/core/mmc.c
drivers/mmc/core/sd.c
drivers/mmc/core/sdio.c
drivers/mmc/core/sdio_bus.c
drivers/mmc/core/sdio_cis.c
drivers/mmc/host/Kconfig
drivers/mmc/host/Makefile
drivers/mmc/host/atmel-mci.c
drivers/mmc/host/bfin_sdh.c [new file with mode: 0644]
drivers/mmc/host/davinci_mmc.c [new file with mode: 0644]
drivers/mmc/host/mxcmmc.c
drivers/mmc/host/omap.c
drivers/mmc/host/pxamci.c
drivers/mmc/host/s3cmci.c
drivers/mmc/host/sdhci-of-core.c [moved from drivers/mmc/host/sdhci-of.c with 58% similarity]
drivers/mmc/host/sdhci-of-esdhc.c [new file with mode: 0644]
drivers/mmc/host/sdhci-of-hlwd.c [new file with mode: 0644]
drivers/mmc/host/sdhci-of.h [new file with mode: 0644]
drivers/mmc/host/sdhci-pci.c
drivers/mmc/host/sdhci.h
drivers/mmc/host/tmio_mmc.c
drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/cfi_cmdset_0002.c
drivers/mtd/chips/cfi_util.c
drivers/mtd/chips/jedec_probe.c
drivers/mtd/devices/m25p80.c
drivers/mtd/devices/mtd_dataflash.c
drivers/mtd/maps/Kconfig
drivers/mtd/maps/Makefile
drivers/mtd/maps/ipaq-flash.c [deleted file]
drivers/mtd/maps/ixp4xx.c
drivers/mtd/maps/physmap.c
drivers/mtd/maps/pxa2xx-flash.c
drivers/mtd/maps/sa1100-flash.c
drivers/mtd/maps/vmu-flash.c
drivers/mtd/mtd_blkdevs.c
drivers/mtd/mtdcore.c
drivers/mtd/mtdoops.c
drivers/mtd/nand/Kconfig
drivers/mtd/nand/Makefile
drivers/mtd/nand/alauda.c
drivers/mtd/nand/atmel_nand.c
drivers/mtd/nand/bcm_umi_bch.c [new file with mode: 0644]
drivers/mtd/nand/bcm_umi_nand.c [new file with mode: 0644]
drivers/mtd/nand/davinci_nand.c
drivers/mtd/nand/excite_nandflash.c [deleted file]
drivers/mtd/nand/fsl_elbc_nand.c
drivers/mtd/nand/fsl_upm.c
drivers/mtd/nand/mxc_nand.c
drivers/mtd/nand/nand_base.c
drivers/mtd/nand/nand_bcm_umi.c [new file with mode: 0644]
drivers/mtd/nand/nand_bcm_umi.h [new file with mode: 0644]
drivers/mtd/nand/nand_ecc.c
drivers/mtd/nand/nandsim.c
drivers/mtd/nand/nomadik_nand.c
drivers/mtd/nand/plat_nand.c
drivers/mtd/nand/s3c2410.c
drivers/mtd/nand/txx9ndfmc.c
drivers/mtd/onenand/omap2.c
drivers/mtd/onenand/onenand_base.c
drivers/mtd/tests/Makefile
drivers/mtd/tests/mtd_nandecctest.c [new file with mode: 0644]
drivers/mtd/tests/mtd_oobtest.c
drivers/mtd/tests/mtd_pagetest.c
drivers/net/3c507.c
drivers/net/3c59x.c
drivers/net/Kconfig
drivers/net/Makefile
drivers/net/bcm63xx_enet.c
drivers/net/benet/be.h
drivers/net/benet/be_cmds.c
drivers/net/benet/be_cmds.h
drivers/net/benet/be_ethtool.c
drivers/net/bnx2.c
drivers/net/bnx2x_main.c
drivers/net/bonding/bond_3ad.c
drivers/net/bonding/bond_alb.c
drivers/net/bonding/bond_ipv6.c
drivers/net/bonding/bond_main.c
drivers/net/bonding/bond_sysfs.c
drivers/net/can/Kconfig
drivers/net/can/at91_can.c
drivers/net/can/bfin_can.c
drivers/net/can/mcp251x.c
drivers/net/can/mscan/mscan.c
drivers/net/can/sja1000/sja1000.c
drivers/net/can/ti_hecc.c
drivers/net/can/usb/ems_usb.c
drivers/net/cpmac.c
drivers/net/davinci_emac.c
drivers/net/dm9000.c
drivers/net/e100.c
drivers/net/e1000e/82571.c
drivers/net/gianfar.c
drivers/net/gianfar.h
drivers/net/ibmlana.c
drivers/net/igb/e1000_82575.c
drivers/net/igb/e1000_phy.c
drivers/net/igb/igb_ethtool.c
drivers/net/igb/igb_main.c
drivers/net/igbvf/netdev.c
drivers/net/ixgbe/ixgbe_82598.c
drivers/net/ixgbe/ixgbe_main.c
drivers/net/ixgbe/ixgbe_type.h
drivers/net/mlx4/alloc.c
drivers/net/mlx4/fw.c
drivers/net/mlx4/sense.c
drivers/net/netxen/netxen_nic_main.c
drivers/net/octeon/Kconfig [new file with mode: 0644]
drivers/net/octeon/Makefile [new file with mode: 0644]
drivers/net/octeon/octeon_mgmt.c [new file with mode: 0644]
drivers/net/pcmcia/3c574_cs.c
drivers/net/pcmcia/3c589_cs.c
drivers/net/pcnet32.c
drivers/net/phy/Kconfig
drivers/net/phy/Makefile
drivers/net/phy/broadcom.c
drivers/net/phy/mdio-octeon.c [new file with mode: 0644]
drivers/net/r8169.c
drivers/net/sfc/efx.c
drivers/net/sfc/falcon.c
drivers/net/sfc/falcon_xmac.c
drivers/net/sfc/mcdi_phy.c
drivers/net/sfc/net_driver.h
drivers/net/sfc/nic.c
drivers/net/sfc/qt202x_phy.c
drivers/net/sfc/selftest.c
drivers/net/sfc/siena.c
drivers/net/sfc/tenxpress.c
drivers/net/sfc/tx.c
drivers/net/sh_eth.c
drivers/net/sky2.c
drivers/net/smsc911x.c
drivers/net/tun.c
drivers/net/ucc_geth.c
drivers/net/usb/rtl8150.c
drivers/net/via-rhine.c
drivers/net/vmxnet3/vmxnet3_drv.c
drivers/net/vxge/vxge-main.c
drivers/net/wireless/ath/ath5k/base.c
drivers/net/wireless/ath/ath9k/mac.c
drivers/net/wireless/ath/ath9k/mac.h
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/ath/ath9k/pci.c
drivers/net/wireless/ath/ath9k/xmit.c
drivers/net/wireless/b43/dma.c
drivers/net/wireless/b43/dma.h
drivers/net/wireless/iwlwifi/iwl-3945.c
drivers/net/wireless/iwlwifi/iwl-3945.h
drivers/net/wireless/iwlwifi/iwl-4965.c
drivers/net/wireless/iwlwifi/iwl-5000-hw.h
drivers/net/wireless/iwlwifi/iwl-5000.c
drivers/net/wireless/iwlwifi/iwl-agn-rs.c
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-core.h
drivers/net/wireless/iwlwifi/iwl-csr.h
drivers/net/wireless/iwlwifi/iwl-dev.h
drivers/net/wireless/iwlwifi/iwl-eeprom.c
drivers/net/wireless/iwlwifi/iwl-eeprom.h
drivers/net/wireless/iwlwifi/iwl-hcmd.c
drivers/net/wireless/iwlwifi/iwl-rx.c
drivers/net/wireless/iwlwifi/iwl-scan.c
drivers/net/wireless/iwlwifi/iwl-sta.c
drivers/net/wireless/iwlwifi/iwl-tx.c
drivers/net/wireless/iwlwifi/iwl3945-base.c
drivers/net/wireless/iwmc3200wifi/iwm.h
drivers/net/wireless/iwmc3200wifi/netdev.c
drivers/net/wireless/iwmc3200wifi/rx.c
drivers/net/wireless/libertas/cmd.c
drivers/net/wireless/libertas/dev.h
drivers/net/wireless/libertas/main.c
drivers/net/wireless/libertas/mesh.c
drivers/net/wireless/libertas/scan.c
drivers/net/wireless/libertas/wext.c
drivers/net/wireless/libertas_tf/main.c
drivers/net/wireless/orinoco/wext.c
drivers/net/wireless/rt2x00/rt2800.h
drivers/net/wireless/rt2x00/rt2800lib.c
drivers/net/wireless/rt2x00/rt2800usb.c
drivers/net/wireless/rt2x00/rt61pci.c
drivers/net/wireless/rtl818x/rtl8180_dev.c
drivers/net/wireless/wl12xx/wl1251_boot.c
drivers/net/wireless/wl12xx/wl1271_cmd.c
drivers/net/wireless/zd1211rw/zd_chip.c
drivers/net/wireless/zd1211rw/zd_chip.h
drivers/net/wireless/zd1211rw/zd_mac.c
drivers/parisc/dino.c
drivers/parisc/eisa.c
drivers/parisc/gsc.c
drivers/parisc/iosapic.c
drivers/parisc/led.c
drivers/parisc/pdc_stable.c
drivers/parisc/superio.c
drivers/parport/parport_pc.c
drivers/pci/dmar.c
drivers/pci/hotplug/shpchp.h
drivers/pci/intel-iommu.c
drivers/pci/intr_remapping.c
drivers/pci/pci-acpi.c
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/pcie/aer/Kconfig.debug
drivers/pci/pcie/aer/aer_inject.c
drivers/pci/pcie/aer/aerdrv.c
drivers/pci/pcie/aer/aerdrv_acpi.c
drivers/pci/pcie/aer/aerdrv_core.c
drivers/pci/pcie/aer/aerdrv_errprint.c
drivers/pci/pcie/aspm.c
drivers/pci/pcie/portdrv_pci.c
drivers/pci/quirks.c
drivers/pci/search.c
drivers/pcmcia/cardbus.c
drivers/pcmcia/pxa2xx_base.c
drivers/pcmcia/yenta_socket.c
drivers/platform/x86/Kconfig
drivers/platform/x86/Makefile
drivers/platform/x86/acer-wmi.c
drivers/platform/x86/acerhdf.c
drivers/platform/x86/asus-laptop.c
drivers/platform/x86/asus_acpi.c
drivers/platform/x86/classmate-laptop.c [new file with mode: 0644]
drivers/platform/x86/compal-laptop.c
drivers/platform/x86/dell-laptop.c
drivers/platform/x86/dell-wmi.c
drivers/platform/x86/eeepc-laptop.c
drivers/platform/x86/fujitsu-laptop.c
drivers/platform/x86/hp-wmi.c
drivers/platform/x86/msi-wmi.c [new file with mode: 0644]
drivers/platform/x86/sony-laptop.c
drivers/platform/x86/tc1100-wmi.c
drivers/platform/x86/thinkpad_acpi.c
drivers/platform/x86/toshiba_acpi.c
drivers/platform/x86/toshiba_bluetooth.c [new file with mode: 0644]
drivers/platform/x86/wmi.c
drivers/pnp/interface.c
drivers/pnp/pnpacpi/core.c
drivers/pnp/pnpacpi/rsparser.c
drivers/pnp/pnpbios/proc.c
drivers/power/Kconfig
drivers/power/Makefile
drivers/power/pcf50633-charger.c
drivers/power/power_supply_sysfs.c
drivers/power/wm831x_backup.c [new file with mode: 0644]
drivers/power/wm831x_power.c
drivers/power/wm97xx_battery.c
drivers/regulator/88pm8607.c [new file with mode: 0644]
drivers/regulator/Kconfig
drivers/regulator/Makefile
drivers/regulator/ab3100.c
drivers/regulator/core.c
drivers/regulator/da903x.c
drivers/regulator/lp3971.c
drivers/regulator/max8660.c [new file with mode: 0644]
drivers/regulator/mc13783-regulator.c [new file with mode: 0644]
drivers/regulator/mc13783.c [deleted file]
drivers/regulator/twl-regulator.c
drivers/regulator/wm831x-dcdc.c
drivers/regulator/wm831x-ldo.c
drivers/rtc/Kconfig
drivers/rtc/Makefile
drivers/rtc/rtc-at32ap700x.c
drivers/rtc/rtc-bq32k.c [new file with mode: 0644]
drivers/rtc/rtc-bq4802.c
drivers/rtc/rtc-cmos.c
drivers/rtc/rtc-ds1302.c
drivers/rtc/rtc-ds1305.c
drivers/rtc/rtc-ds1307.c
drivers/rtc/rtc-ds1374.c
drivers/rtc/rtc-ds1511.c
drivers/rtc/rtc-ds1553.c
drivers/rtc/rtc-ds1742.c
drivers/rtc/rtc-m48t35.c
drivers/rtc/rtc-m48t59.c
drivers/rtc/rtc-mc13783.c [new file with mode: 0644]
drivers/rtc/rtc-mv.c
drivers/rtc/rtc-nuc900.c [new file with mode: 0644]
drivers/rtc/rtc-omap.c
drivers/rtc/rtc-pcf50633.c
drivers/rtc/rtc-pcf8563.c
drivers/rtc/rtc-pcf8583.c
drivers/rtc/rtc-pl031.c
drivers/rtc/rtc-pxa.c
drivers/rtc/rtc-sa1100.c
drivers/rtc/rtc-sh.c
drivers/rtc/rtc-stk17ta8.c
drivers/rtc/rtc-tx4939.c
drivers/rtc/rtc-v3020.c
drivers/rtc/rtc-vr41xx.c
drivers/rtc/rtc-wm831x.c
drivers/rtc/rtc-wm8350.c
drivers/rtc/rtc-x1205.c
drivers/s390/block/dasd_alias.c
drivers/s390/block/dasd_diag.c
drivers/s390/block/dasd_proc.c
drivers/s390/block/dcssblk.c
drivers/s390/block/xpram.c
drivers/s390/char/fs3270.c
drivers/s390/char/monreader.c
drivers/s390/char/monwriter.c
drivers/s390/char/sclp.c
drivers/s390/char/sclp_cmd.c
drivers/s390/char/tape_34xx.c
drivers/s390/char/tape_3590.c
drivers/s390/char/tape_block.c
drivers/s390/char/tape_char.c
drivers/s390/char/tape_class.c
drivers/s390/char/tape_core.c
drivers/s390/char/tape_proc.c
drivers/s390/char/tape_std.c
drivers/s390/char/vmlogrdr.c
drivers/s390/cio/ccwgroup.c
drivers/s390/cio/ccwreq.c
drivers/s390/cio/css.c
drivers/s390/cio/device.c
drivers/s390/cio/device_pgid.c
drivers/s390/cio/fcx.c
drivers/s390/cio/io_sch.h
drivers/s390/cio/qdio_main.c
drivers/s390/cio/qdio_perf.c
drivers/s390/cio/qdio_perf.h
drivers/s390/cio/qdio_setup.c
drivers/s390/net/netiucv.c
drivers/s390/net/smsgiucv.c
drivers/scsi/3w-9xxx.c
drivers/scsi/Kconfig
drivers/scsi/Makefile
drivers/scsi/be2iscsi/be_cmds.c
drivers/scsi/bnx2i/bnx2i.h
drivers/scsi/bnx2i/bnx2i_hwi.c
drivers/scsi/bnx2i/bnx2i_init.c
drivers/scsi/bnx2i/bnx2i_iscsi.c
drivers/scsi/cxgb3i/cxgb3i_offload.c
drivers/scsi/cxgb3i/cxgb3i_pdu.c
drivers/scsi/device_handler/scsi_dh_rdac.c
drivers/scsi/fcoe/fcoe.c
drivers/scsi/hpsa.c [new file with mode: 0644]
drivers/scsi/hpsa.h [new file with mode: 0644]
drivers/scsi/hpsa_cmd.h [new file with mode: 0644]
drivers/scsi/ipr.c
drivers/scsi/libfc/fc_fcp.c
drivers/scsi/libfc/fc_lport.c
drivers/scsi/libfc/fc_rport.c
drivers/scsi/libiscsi.c
drivers/scsi/libiscsi_tcp.c
drivers/scsi/libsrp.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/megaraid/megaraid_sas.c
drivers/scsi/mpt2sas/mpt2sas_base.c
drivers/scsi/mvsas/mv_init.c
drivers/scsi/osd/osd_initiator.c
drivers/scsi/pm8001/pm8001_ctl.h
drivers/scsi/pm8001/pm8001_hwi.c
drivers/scsi/pm8001/pm8001_hwi.h
drivers/scsi/pm8001/pm8001_init.c
drivers/scsi/pm8001/pm8001_sas.c
drivers/scsi/pm8001/pm8001_sas.h
drivers/scsi/pmcraid.c
drivers/scsi/pmcraid.h
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_gbl.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla2xxx/qla_mid.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_version.h
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_transport_fc.c
drivers/scsi/sd.c
drivers/scsi/sd.h
drivers/scsi/st.c
drivers/scsi/st.h
drivers/scsi/sym53c8xx_2/sym_glue.c
drivers/serial/ioc3_serial.c
drivers/serial/ioc4_serial.c
drivers/serial/pxa.c
drivers/serial/sh-sci.c
drivers/serial/sh-sci.h
drivers/sh/intc.c
drivers/sh/pfc.c
drivers/sn/ioc3.c
drivers/spi/Kconfig
drivers/spi/Makefile
drivers/spi/atmel_spi.c
drivers/spi/dw_spi.c [new file with mode: 0644]
drivers/spi/dw_spi_pci.c [new file with mode: 0644]
drivers/spi/pxa2xx_spi.c
drivers/spi/spi_bfin5xx.c
drivers/spi/spi_mpc8xxx.c
drivers/spi/spi_s3c24xx.c
drivers/spi/spi_s3c24xx_fiq.S [new file with mode: 0644]
drivers/spi/spi_s3c24xx_fiq.h [new file with mode: 0644]
drivers/spi/spi_s3c64xx.c [new file with mode: 0644]
drivers/spi/spi_sh_sci.c
drivers/spi/spi_txx9.c
drivers/spi/spidev.c
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/batman-adv/Kconfig
drivers/staging/batman-adv/send.c
drivers/staging/comedi/comedi.h
drivers/staging/comedi/drivers/jr3_pci.c
drivers/staging/comedi/drivers/usbdux.c
drivers/staging/cx25821/cx25821-audups11.c
drivers/staging/cx25821/cx25821-video.c
drivers/staging/cx25821/cx25821-video0.c
drivers/staging/cx25821/cx25821-video1.c
drivers/staging/cx25821/cx25821-video2.c
drivers/staging/cx25821/cx25821-video3.c
drivers/staging/cx25821/cx25821-video4.c
drivers/staging/cx25821/cx25821-video5.c
drivers/staging/cx25821/cx25821-video6.c
drivers/staging/cx25821/cx25821-video7.c
drivers/staging/cx25821/cx25821-videoioctl.c
drivers/staging/cx25821/cx25821-vidups10.c
drivers/staging/cx25821/cx25821-vidups9.c
drivers/staging/dst/Kconfig [deleted file]
drivers/staging/dst/Makefile [deleted file]
drivers/staging/dst/crypto.c [deleted file]
drivers/staging/dst/dcore.c [deleted file]
drivers/staging/dst/export.c [deleted file]
drivers/staging/dst/state.c [deleted file]
drivers/staging/dst/thread_pool.c [deleted file]
drivers/staging/dst/trans.c [deleted file]
drivers/staging/go7007/go7007-v4l2.c
drivers/staging/iio/ring_sw.h
drivers/staging/octeon/Kconfig
drivers/staging/octeon/ethernet-mdio.c
drivers/staging/octeon/ethernet-mdio.h
drivers/staging/octeon/ethernet-proc.c
drivers/staging/octeon/ethernet-rgmii.c
drivers/staging/octeon/ethernet-sgmii.c
drivers/staging/octeon/ethernet-xaui.c
drivers/staging/octeon/ethernet.c
drivers/staging/octeon/octeon-ethernet.h
drivers/staging/panel/Kconfig
drivers/staging/panel/panel.c
drivers/staging/pohmelfs/dir.c
drivers/staging/ramzswap/TODO
drivers/staging/ramzswap/ramzswap_drv.c
drivers/staging/rtl8187se/ieee80211/ieee80211.h
drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
drivers/staging/rtl8187se/r8180_core.c
drivers/staging/rtl8187se/r8180_wx.c
drivers/staging/rtl8192e/ieee80211.h
drivers/staging/rtl8192e/ieee80211/ieee80211.h
drivers/staging/rtl8192e/ieee80211/ieee80211_module.c
drivers/staging/rtl8192e/ieee80211/ieee80211_rx.c
drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8192e/ieee80211/ieee80211_tx.c
drivers/staging/rtl8192e/ieee80211/ieee80211_wx.c
drivers/staging/rtl8192e/ieee80211/rtl819x_BAProc.c
drivers/staging/rtl8192e/r8192E_core.c
drivers/staging/rtl8192su/ieee80211/ieee80211.h
drivers/staging/rtl8192su/ieee80211/ieee80211_rx.c
drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
drivers/staging/rtl8192su/r8192U_core.c
drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
drivers/staging/sm7xx/Kconfig [new file with mode: 0644]
drivers/staging/sm7xx/Makefile [new file with mode: 0644]
drivers/staging/sm7xx/TODO [new file with mode: 0644]
drivers/staging/sm7xx/smtc2d.c [new file with mode: 0644]
drivers/staging/sm7xx/smtc2d.h [new file with mode: 0644]
drivers/staging/sm7xx/smtcfb.c [new file with mode: 0644]
drivers/staging/sm7xx/smtcfb.h [new file with mode: 0644]
drivers/staging/vt6655/Kconfig
drivers/staging/vt6656/Kconfig
drivers/staging/wlan-ng/prism2fw.c
drivers/thermal/thermal_sys.c
drivers/uio/uio_pdrv_genirq.c
drivers/usb/Makefile
drivers/usb/core/hcd-pci.c
drivers/usb/core/hcd.c
drivers/usb/core/hcd.h
drivers/usb/core/hub.c
drivers/usb/core/sysfs.c
drivers/usb/core/usb.c
drivers/usb/early/ehci-dbgp.c
drivers/usb/gadget/audio.c
drivers/usb/gadget/f_audio.c
drivers/usb/gadget/u_audio.c
drivers/usb/gadget/u_audio.h
drivers/usb/host/ehci-au1xxx.c
drivers/usb/host/ehci-omap.c
drivers/usb/host/fhci-sched.c
drivers/usb/host/fhci-tds.c
drivers/usb/host/fhci.h
drivers/usb/host/isp1362-hcd.c
drivers/usb/host/ohci-au1xxx.c
drivers/usb/host/ohci-pxa27x.c
drivers/usb/host/r8a66597-hcd.c
drivers/usb/misc/appledisplay.c
drivers/usb/misc/emi62.c
drivers/usb/musb/blackfin.c
drivers/usb/musb/blackfin.h
drivers/usb/musb/cppi_dma.c
drivers/usb/musb/davinci.c
drivers/usb/musb/musb_core.c
drivers/usb/musb/musb_gadget.c
drivers/usb/musb/musb_gadget_ep0.c
drivers/usb/otg/isp1301_omap.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/ftdi_sio.h
drivers/usb/serial/ftdi_sio_ids.h [new file with mode: 0644]
drivers/usb/serial/generic.c
drivers/usb/serial/mos7840.c
drivers/usb/serial/option.c
drivers/usb/serial/usb-serial.c
drivers/video/Kconfig
drivers/video/Makefile
drivers/video/backlight/adp5520_bl.c
drivers/video/backlight/adx_bl.c
drivers/video/backlight/atmel-pwm-bl.c
drivers/video/backlight/backlight.c
drivers/video/backlight/corgi_lcd.c
drivers/video/backlight/cr_bllcd.c
drivers/video/backlight/da903x_bl.c
drivers/video/backlight/generic_bl.c
drivers/video/backlight/hp680_bl.c
drivers/video/backlight/jornada720_bl.c
drivers/video/backlight/kb3886_bl.c
drivers/video/backlight/lcd.c
drivers/video/backlight/locomolcd.c
drivers/video/backlight/mbp_nvidia_bl.c
drivers/video/backlight/omap1_bl.c
drivers/video/backlight/progear_bl.c
drivers/video/backlight/pwm_bl.c
drivers/video/backlight/tosa_bl.c
drivers/video/backlight/wm831x_bl.c
drivers/video/bfin-lq035q1-fb.c [new file with mode: 0644]
drivers/video/bfin-t350mcqb-fb.c
drivers/video/clps711xfb.c
drivers/video/cyber2000fb.c
drivers/video/da8xx-fb.c
drivers/video/display/display-sysfs.c
drivers/video/ep93xx-fb.c
drivers/video/geode/display_gx.c
drivers/video/geode/gxfb.h
drivers/video/geode/gxfb_core.c
drivers/video/geode/lxfb.h
drivers/video/geode/lxfb_ops.c
drivers/video/geode/suspend_gx.c
drivers/video/geode/video_gx.c
drivers/video/hitfb.c
drivers/video/i810/i810_dvt.c
drivers/video/intelfb/intelfbdrv.c
drivers/video/intelfb/intelfbhw.c
drivers/video/intelfb/intelfbhw.h
drivers/video/matrox/g450_pll.c
drivers/video/maxinefb.c
drivers/video/mb862xx/Makefile
drivers/video/mb862xx/mb862xxfb.c
drivers/video/mb862xx/mb862xxfb.h
drivers/video/mb862xx/mb862xxfb_accel.c [new file with mode: 0644]
drivers/video/mb862xx/mb862xxfb_accel.h [new file with mode: 0644]
drivers/video/modedb.c
drivers/video/omap/lcd_ldp.c
drivers/video/omap/lcd_omap2evm.c
drivers/video/omap/lcd_omap3beagle.c
drivers/video/omap/lcd_omap3evm.c
drivers/video/omap/lcd_overo.c
drivers/video/output.c
drivers/video/pmag-ba-fb.c
drivers/video/pmagb-b-fb.c
drivers/video/pxafb.c
drivers/video/sh_mobile_lcdcfb.c
drivers/video/sis/sis_main.c
drivers/video/sm501fb.c
drivers/video/via/lcd.c
drivers/video/via/viafbdev.c
drivers/watchdog/Kconfig
drivers/watchdog/Makefile
drivers/watchdog/adx_wdt.c
drivers/watchdog/at32ap700x_wdt.c
drivers/watchdog/davinci_wdt.c
drivers/watchdog/geodewdt.c
drivers/watchdog/iTCO_wdt.c
drivers/watchdog/mpcore_wdt.c
drivers/watchdog/mv64x60_wdt.c
drivers/watchdog/omap_wdt.c
drivers/watchdog/pnx4008_wdt.c
drivers/watchdog/rm9k_wdt.c [deleted file]
drivers/watchdog/s3c2410_wdt.c
drivers/watchdog/txx9wdt.c
fs/aio.c
fs/anon_inodes.c
fs/autofs4/autofs_i.h
fs/autofs4/expire.c
fs/autofs4/inode.c
fs/autofs4/root.c
fs/binfmt_aout.c
fs/binfmt_elf.c
fs/binfmt_elf_fdpic.c
fs/binfmt_flat.c
fs/binfmt_som.c
fs/btrfs/acl.c
fs/btrfs/btrfs_inode.h
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/dir-item.c
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/ordered-data.c
fs/btrfs/ordered-data.h
fs/btrfs/relocation.c
fs/btrfs/super.c
fs/btrfs/transaction.c
fs/btrfs/transaction.h
fs/btrfs/tree-log.c
fs/btrfs/volumes.c
fs/btrfs/xattr.c
fs/btrfs/xattr.h
fs/cachefiles/bind.c
fs/cachefiles/daemon.c
fs/cachefiles/rdwr.c
fs/cifs/export.c
fs/compat.c
fs/compat_ioctl.c
fs/dcache.c
fs/direct-io.c
fs/ecryptfs/dentry.c
fs/ecryptfs/inode.c
fs/ecryptfs/main.c
fs/eventfd.c
fs/eventpoll.c
fs/exec.c
fs/exportfs/expfs.c
fs/ext2/acl.c
fs/ext2/dir.c
fs/ext2/ext2.h
fs/ext2/file.c
fs/ext2/super.c
fs/ext2/xattr.c
fs/ext2/xattr_security.c
fs/ext2/xattr_trusted.c
fs/ext2/xattr_user.c
fs/ext3/acl.c
fs/ext3/inode.c
fs/ext3/namei.c
fs/ext3/resize.c
fs/ext3/super.c
fs/ext3/xattr.c
fs/ext3/xattr_security.c
fs/ext3/xattr_trusted.c
fs/ext3/xattr_user.c
fs/ext4/Kconfig
fs/ext4/acl.c
fs/ext4/block_validity.c
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/fsync.c
fs/ext4/inode.c
fs/ext4/mballoc.c
fs/ext4/mballoc.h
fs/ext4/super.c
fs/ext4/xattr.c
fs/ext4/xattr_security.c
fs/ext4/xattr_trusted.c
fs/ext4/xattr_user.c
fs/fat/fat.h
fs/fat/fatent.c
fs/fat/inode.c
fs/fat/misc.c
fs/file_table.c
fs/fs-writeback.c
fs/fscache/object-list.c
fs/generic_acl.c
fs/gfs2/acl.c
fs/gfs2/inode.c
fs/gfs2/sys.c
fs/gfs2/xattr.c
fs/gfs2/xattr.h
fs/hfs/catalog.c
fs/hfs/dir.c
fs/hfs/super.c
fs/hpfs/super.c
fs/hugetlbfs/inode.c
fs/inode.c
fs/internal.h
fs/isofs/export.c
fs/jbd/journal.c
fs/jbd2/checkpoint.c
fs/jbd2/commit.c
fs/jbd2/journal.c
fs/jffs2/acl.c
fs/jffs2/gc.c
fs/jffs2/readinode.c
fs/jffs2/security.c
fs/jffs2/summary.c
fs/jffs2/xattr.c
fs/jffs2/xattr_trusted.c
fs/jffs2/xattr_user.c
fs/jfs/jfs_txnmgr.c
fs/jfs/super.c
fs/libfs.c
fs/lockd/svc4proc.c
fs/lockd/svcproc.c
fs/namei.c
fs/nfs/Kconfig
fs/nfs/nfs4_fs.h
fs/nfs/nfs4proc.c
fs/nfs/nfs4state.c
fs/nfsctl.c
fs/nfsd/auth.c
fs/nfsd/cache.h [moved from include/linux/nfsd/cache.h with 95% similarity]
fs/nfsd/export.c
fs/nfsd/lockd.c
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/nfs3proc.c
fs/nfsd/nfs3xdr.c
fs/nfsd/nfs4acl.c
fs/nfsd/nfs4callback.c
fs/nfsd/nfs4idmap.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4recover.c
fs/nfsd/nfs4state.c
fs/nfsd/nfs4xdr.c
fs/nfsd/nfscache.c
fs/nfsd/nfsctl.c
fs/nfsd/nfsd.h [moved from include/linux/nfsd/nfsd.h with 79% similarity]
fs/nfsd/nfsfh.c
fs/nfsd/nfsfh.h [new file with mode: 0644]
fs/nfsd/nfsproc.c
fs/nfsd/nfssvc.c
fs/nfsd/nfsxdr.c
fs/nfsd/state.h [moved from include/linux/nfsd/state.h with 98% similarity]
fs/nfsd/stats.c
fs/nfsd/vfs.c
fs/nfsd/vfs.h [new file with mode: 0644]
fs/nfsd/xdr.h [moved from include/linux/nfsd/xdr.h with 96% similarity]
fs/nfsd/xdr3.h [moved from include/linux/nfsd/xdr3.h with 99% similarity]
fs/nfsd/xdr4.h [moved from include/linux/nfsd/xdr4.h with 99% similarity]
fs/nilfs2/super.c
fs/notify/inotify/inotify_user.c
fs/ntfs/inode.c
fs/ocfs2/Kconfig
fs/ocfs2/Makefile
fs/ocfs2/acl.c
fs/ocfs2/acl.h
fs/ocfs2/alloc.c
fs/ocfs2/alloc.h
fs/ocfs2/aops.c
fs/ocfs2/cluster/heartbeat.c
fs/ocfs2/cluster/nodemanager.c
fs/ocfs2/cluster/nodemanager.h
fs/ocfs2/cluster/quorum.c
fs/ocfs2/dlm/dlmrecovery.c
fs/ocfs2/extent_map.c
fs/ocfs2/namei.c
fs/ocfs2/ocfs2.h
fs/ocfs2/ocfs2_fs.h
fs/ocfs2/refcounttree.c
fs/ocfs2/stack_user.c
fs/ocfs2/super.c
fs/ocfs2/symlink.c
fs/ocfs2/xattr.c
fs/ocfs2/xattr.h
fs/open.c
fs/pipe.c
fs/proc/array.c
fs/proc/base.c
fs/proc/generic.c
fs/proc/inode.c
fs/proc/internal.h
fs/proc/page.c
fs/proc/task_mmu.c
fs/proc/task_nommu.c
fs/qnx4/bitmap.c
fs/qnx4/inode.c
fs/quota/dquot.c
fs/quota/quota_v2.c
fs/ramfs/file-nommu.c
fs/reiserfs/Makefile
fs/reiserfs/inode.c
fs/reiserfs/procfs.c
fs/reiserfs/super.c
fs/reiserfs/xattr.c
fs/reiserfs/xattr_acl.c
fs/reiserfs/xattr_security.c
fs/reiserfs/xattr_trusted.c
fs/reiserfs/xattr_user.c
fs/signalfd.c
fs/stack.c
fs/stat.c
fs/super.c
fs/sync.c
fs/sysfs/bin.c
fs/timerfd.c
fs/ubifs/debug.c
fs/ubifs/file.c
fs/ubifs/super.c
fs/ufs/dir.c
fs/ufs/namei.c
fs/ufs/super.c
fs/ufs/ufs.h
fs/xattr.c
fs/xfs/Makefile
fs/xfs/linux-2.6/xfs_acl.c
fs/xfs/linux-2.6/xfs_aops.c
fs/xfs/linux-2.6/xfs_aops.h
fs/xfs/linux-2.6/xfs_buf.c
fs/xfs/linux-2.6/xfs_buf.h
fs/xfs/linux-2.6/xfs_fs_subr.c
fs/xfs/linux-2.6/xfs_ioctl.c
fs/xfs/linux-2.6/xfs_ioctl32.c
fs/xfs/linux-2.6/xfs_iops.c
fs/xfs/linux-2.6/xfs_linux.h
fs/xfs/linux-2.6/xfs_lrw.c
fs/xfs/linux-2.6/xfs_lrw.h
fs/xfs/linux-2.6/xfs_super.c
fs/xfs/linux-2.6/xfs_super.h
fs/xfs/linux-2.6/xfs_sync.c
fs/xfs/linux-2.6/xfs_trace.c [new file with mode: 0644]
fs/xfs/linux-2.6/xfs_trace.h [new file with mode: 0644]
fs/xfs/linux-2.6/xfs_vnode.h
fs/xfs/linux-2.6/xfs_xattr.c
fs/xfs/quota/xfs_dquot.c
fs/xfs/quota/xfs_dquot.h
fs/xfs/quota/xfs_qm.c
fs/xfs/quota/xfs_qm_syscalls.c
fs/xfs/support/ktrace.c [deleted file]
fs/xfs/support/ktrace.h [deleted file]
fs/xfs/xfs.h
fs/xfs/xfs_acl.h
fs/xfs/xfs_ag.h
fs/xfs/xfs_alloc.c
fs/xfs/xfs_alloc.h
fs/xfs/xfs_alloc_btree.c
fs/xfs/xfs_attr.c
fs/xfs/xfs_attr.h
fs/xfs/xfs_attr_leaf.c
fs/xfs/xfs_attr_sf.h
fs/xfs/xfs_bmap.c
fs/xfs/xfs_bmap.h
fs/xfs/xfs_bmap_btree.c
fs/xfs/xfs_bmap_btree.h
fs/xfs/xfs_btree.c
fs/xfs/xfs_btree_trace.h
fs/xfs/xfs_buf_item.c
fs/xfs/xfs_buf_item.h
fs/xfs/xfs_da_btree.c
fs/xfs/xfs_da_btree.h
fs/xfs/xfs_dfrag.c
fs/xfs/xfs_dir2.c
fs/xfs/xfs_dir2_block.c
fs/xfs/xfs_dir2_leaf.c
fs/xfs/xfs_dir2_node.c
fs/xfs/xfs_dir2_sf.c
fs/xfs/xfs_dir2_trace.c [deleted file]
fs/xfs/xfs_dir2_trace.h [deleted file]
fs/xfs/xfs_filestream.c
fs/xfs/xfs_fsops.c
fs/xfs/xfs_iget.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_inode_item.c
fs/xfs/xfs_inode_item.h
fs/xfs/xfs_iomap.c
fs/xfs/xfs_iomap.h
fs/xfs/xfs_log.c
fs/xfs/xfs_log_priv.h
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_quota.h
fs/xfs/xfs_rename.c
fs/xfs/xfs_rtalloc.c
fs/xfs/xfs_rw.c
fs/xfs/xfs_trans.h
fs/xfs/xfs_trans_buf.c
fs/xfs/xfs_vnodeops.c
include/acpi/acoutput.h
include/acpi/acpixf.h
include/acpi/processor.h
include/asm-generic/bitops/atomic.h
include/asm-generic/bug.h
include/asm-generic/fcntl.h
include/asm-generic/gpio.h
include/asm-generic/mman-common.h
include/asm-generic/vmlinux.lds.h
include/drm/Kbuild
include/drm/drmP.h
include/drm/ttm/ttm_object.h
include/drm/vmwgfx_drm.h [new file with mode: 0644]
include/linux/Kbuild
include/linux/acpi.h
include/linux/aio.h
include/linux/atmel-mci.h
include/linux/backlight.h
include/linux/binfmts.h
include/linux/bitmap.h
include/linux/blkdev.h
include/linux/can/dev.h
include/linux/cs5535.h [new file with mode: 0644]
include/linux/ctype.h
include/linux/decompress/mm.h
include/linux/device-mapper.h
include/linux/device.h
include/linux/dm-dirty-log.h
include/linux/dm-ioctl.h
include/linux/dm-region-hash.h
include/linux/dmaengine.h
include/linux/dst.h [deleted file]
include/linux/dynamic_debug.h
include/linux/efi.h
include/linux/elf.h
include/linux/enclosure.h
include/linux/err.h
include/linux/exportfs.h
include/linux/ext3_fs_sb.h
include/linux/ext3_jbd.h
include/linux/fiemap.h
include/linux/file.h
include/linux/fs.h
include/linux/fs_stack.h
include/linux/ftrace_event.h
include/linux/generic_acl.h
include/linux/gpio.h
include/linux/hrtimer.h
include/linux/hugetlb.h
include/linux/i2c.h
include/linux/ieee80211.h
include/linux/ima.h
include/linux/inetdevice.h
include/linux/init.h
include/linux/init_task.h
include/linux/intel-iommu.h
include/linux/iommu-helper.h
include/linux/ioport.h
include/linux/ipc_namespace.h
include/linux/irq.h
include/linux/jbd2.h
include/linux/kallsyms.h
include/linux/kernel-page-flags.h [new file with mode: 0644]
include/linux/kernel.h
include/linux/kexec.h
include/linux/kfifo.h
include/linux/kmemleak.h
include/linux/kmsg_dump.h [new file with mode: 0644]
include/linux/ksm.h
include/linux/leds-lp3944.h
include/linux/leds-pca9532.h
include/linux/leds-regulator.h [new file with mode: 0644]
include/linux/lis3lv02d.h
include/linux/lmb.h
include/linux/memcontrol.h
include/linux/memory.h
include/linux/memory_hotplug.h
include/linux/mempolicy.h
include/linux/mfd/pcf50633/core.h
include/linux/mfd/pcf50633/mbc.h
include/linux/mfd/wm831x/pdata.h
include/linux/migrate.h
include/linux/mlx4/device.h
include/linux/mm.h
include/linux/mmdebug.h
include/linux/mmzone.h
include/linux/module.h
include/linux/mtd/bbm.h
include/linux/mtd/cfi.h
include/linux/mtd/flashchip.h
include/linux/mtd/nand.h
include/linux/mtd/nand_ecc.h
include/linux/mtd/onenand.h
include/linux/mtd/onenand_regs.h
include/linux/namei.h
include/linux/nfs_xdr.h
include/linux/nfsacl.h
include/linux/nfsd/export.h
include/linux/nfsd/nfsfh.h
include/linux/nfsd/syscall.h
include/linux/node.h
include/linux/nodemask.h
include/linux/numa.h
include/linux/oom.h
include/linux/page-flags.h
include/linux/page_cgroup.h
include/linux/pci.h
include/linux/perf_counter.h [deleted file]
include/linux/perf_event.h
include/linux/plist.h
include/linux/pm.h
include/linux/pnp.h
include/linux/ptrace.h
include/linux/pwm_backlight.h
include/linux/quota.h
include/linux/rcutiny.h
include/linux/rcutree.h
include/linux/regulator/consumer.h
include/linux/regulator/machine.h
include/linux/regulator/max8660.h [new file with mode: 0644]
include/linux/reiserfs_fs.h
include/linux/rmap.h
include/linux/rtmutex.h
include/linux/rtnetlink.h
include/linux/rwlock.h [new file with mode: 0644]
include/linux/rwlock_api_smp.h [new file with mode: 0644]
include/linux/rwlock_types.h [new file with mode: 0644]
include/linux/rwsem-spinlock.h
include/linux/sched.h
include/linux/security.h
include/linux/sem.h
include/linux/shmem_fs.h
include/linux/sm501-regs.h
include/linux/sonypi.h
include/linux/spi/dw_spi.h [new file with mode: 0644]
include/linux/spinlock.h
include/linux/spinlock_api_smp.h
include/linux/spinlock_api_up.h
include/linux/spinlock_types.h
include/linux/spinlock_types_up.h
include/linux/spinlock_up.h
include/linux/string.h
include/linux/sunrpc/debug.h
include/linux/sunrpc/rpc_rdma.h
include/linux/sunrpc/sched.h
include/linux/sunrpc/svc.h
include/linux/swap.h
include/linux/syscalls.h
include/linux/sysctl.h
include/linux/sysfs.h
include/linux/timb_gpio.h [new file with mode: 0644]
include/linux/tracehook.h
include/linux/tty.h
include/linux/usb/serial.h
include/linux/vermagic.h
include/linux/videodev2.h
include/linux/vmstat.h
include/linux/vt.h
include/linux/writeback.h
include/linux/xattr.h
include/media/ir-common.h
include/media/ir-core.h [new file with mode: 0644]
include/media/mt9t112.h [new file with mode: 0644]
include/media/ov772x.h
include/media/rj54n1cb0c.h [new file with mode: 0644]
include/media/saa7146_vv.h
include/media/sh_mobile_ceu.h
include/media/soc_camera.h
include/media/soc_camera_platform.h
include/media/soc_mediabus.h [new file with mode: 0644]
include/media/tw9910.h
include/media/v4l2-chip-ident.h
include/media/v4l2-common.h
include/media/v4l2-dev.h
include/media/v4l2-ioctl.h
include/media/v4l2-mediabus.h [new file with mode: 0644]
include/media/v4l2-subdev.h
include/net/dst.h
include/net/ip.h
include/net/ipv6.h
include/net/mac80211.h
include/net/netfilter/ipv6/nf_conntrack_ipv6.h
include/net/tcp.h
include/rdma/ib_addr.h
include/rdma/ib_sa.h
include/rdma/ib_user_sa.h
include/rdma/ib_verbs.h
include/rdma/rdma_user_cm.h
include/scsi/libiscsi.h
include/scsi/libiscsi_tcp.h
include/scsi/libsrp.h
include/scsi/osd_initiator.h
include/trace/ftrace.h
include/video/da8xx-fb.h
include/video/sh_mobile_lcdc.h
init/Kconfig
init/Makefile
init/initramfs.c
init/main.c
init/version.c
ipc/mqueue.c
ipc/msg.c
ipc/sem.c
ipc/shm.c
kernel/acct.c
kernel/audit_tree.c
kernel/auditsc.c
kernel/bounds.c
kernel/cpu.c
kernel/exit.c
kernel/fork.c
kernel/futex.c
kernel/hrtimer.c
kernel/hw_breakpoint.c
kernel/irq/autoprobe.c
kernel/irq/chip.c
kernel/irq/handle.c
kernel/irq/internals.h
kernel/irq/manage.c
kernel/irq/migration.c
kernel/irq/numa_migrate.c
kernel/irq/pm.c
kernel/irq/proc.c
kernel/irq/spurious.c
kernel/kexec.c
kernel/kfifo.c
kernel/ksysfs.c
kernel/kthread.c
kernel/lockdep.c
kernel/module.c
kernel/mutex-debug.h
kernel/panic.c
kernel/params.c
kernel/perf_event.c
kernel/pid.c
kernel/power/console.c
kernel/printk.c
kernel/relay.c
kernel/resource.c
kernel/rtmutex-debug.c
kernel/rtmutex.c
kernel/sched.c
kernel/sched_clock.c
kernel/sched_cpupri.c
kernel/sched_cpupri.h
kernel/sched_debug.c
kernel/sched_fair.c
kernel/sched_idletask.c
kernel/sched_rt.c
kernel/signal.c
kernel/smp.c
kernel/spinlock.c
kernel/sys.c
kernel/sysctl.c
kernel/sysctl_binary.c
kernel/time.c
kernel/time/clockevents.c
kernel/time/tick-broadcast.c
kernel/time/tick-common.c
kernel/time/tick-internal.h
kernel/time/timecompare.c
kernel/time/timekeeping.c
kernel/time/timer_list.c
kernel/time/timer_stats.c
kernel/timer.c
kernel/trace/ftrace.c
kernel/trace/power-traces.c
kernel/trace/ring_buffer.c
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_clock.c
kernel/trace/trace_event_profile.c
kernel/trace/trace_events.c
kernel/trace/trace_export.c
kernel/trace/trace_irqsoff.c
kernel/trace/trace_kprobe.c
kernel/trace/trace_ksym.c
kernel/trace/trace_sched_wakeup.c
kernel/trace/trace_selftest.c
kernel/trace/trace_stack.c
kernel/trace/trace_syscalls.c
kernel/trace/trace_sysprof.c
lib/Kconfig.debug
lib/argv_split.c
lib/bitmap.c
lib/crc32.c
lib/ctype.c
lib/debugobjects.c
lib/decompress_bunzip2.c
lib/dynamic_debug.c
lib/genalloc.c
lib/iommu-helper.c
lib/kernel_lock.c
lib/lmb.c
lib/parser.c
lib/plist.c
lib/rwsem-spinlock.c
lib/spinlock_debug.c
lib/string.c
lib/swiotlb.c
lib/vsprintf.c
mm/Kconfig
mm/Makefile
mm/bootmem.c
mm/filemap.c
mm/hugetlb.c
mm/hwpoison-inject.c
mm/internal.h
mm/kmemleak.c
mm/ksm.c
mm/madvise.c
mm/memcontrol.c
mm/memory-failure.c
mm/memory.c
mm/memory_hotplug.c
mm/mempolicy.c
mm/migrate.c
mm/mincore.c
mm/mlock.c
mm/mmap.c
mm/nommu.c
mm/oom_kill.c
mm/page_alloc.c
mm/page_io.c
mm/pagewalk.c
mm/readahead.c
mm/rmap.c
mm/shmem.c
mm/shmem_acl.c [deleted file]
mm/slab.c
mm/swapfile.c
mm/truncate.c
mm/util.c
mm/vmalloc.c
mm/vmscan.c
mm/vmstat.c
net/9p/trans_fd.c
net/bluetooth/hidp/core.c
net/bluetooth/l2cap.c
net/core/dev.c
net/core/pktgen.c
net/core/rtnetlink.c
net/core/skbuff.c
net/dccp/probe.c
net/ipv4/Kconfig
net/ipv4/devinet.c
net/ipv4/fib_frontend.c
net/ipv4/ipconfig.c
net/ipv4/netfilter/nf_defrag_ipv4.c
net/ipv4/syncookies.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_output.c
net/ipv4/udp.c
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
net/ipv6/netfilter/nf_conntrack_reasm.c
net/ipv6/reassembly.c
net/ipv6/route.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c
net/irda/irnet/irnet.h
net/irda/irnet/irnet_ppp.c
net/iucv/af_iucv.c
net/iucv/iucv.c
net/mac80211/ht.c
net/mac80211/ibss.c
net/mac80211/main.c
net/mac80211/mlme.c
net/mac80211/tx.c
net/mac80211/util.c
net/netfilter/ipvs/ip_vs_core.c
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/xt_recent.c
net/packet/af_packet.c
net/rds/ib.c
net/rds/iw.c
net/socket.c
net/sunrpc/sched.c
net/sunrpc/svc_xprt.c
net/sunrpc/svcauth_unix.c
net/wireless/mlme.c
net/wireless/scan.c
net/xfrm/xfrm_policy.c
scripts/Kbuild.include
scripts/Makefile.build
scripts/Makefile.lib
scripts/Makefile.modbuiltin [new file with mode: 0644]
scripts/basic/fixdep.c
scripts/genksyms/keywords.c_shipped
scripts/genksyms/keywords.gperf
scripts/get_maintainer.pl
scripts/headers.sh
scripts/kconfig/Makefile
scripts/kconfig/confdata.c
scripts/mkcompile_h
scripts/mod/Makefile
scripts/mod/mk_elfconfig.c
scripts/mod/modpost.c
scripts/mod/modpost.h
scripts/package/Makefile
scripts/package/buildtar
scripts/recordmcount.pl
scripts/tags.sh
scripts/unifdef.c
security/Makefile
security/integrity/ima/ima.h
security/integrity/ima/ima_iint.c
security/integrity/ima/ima_main.c
security/keys/keyctl.c
security/min_addr.c
security/tomoyo/file.c
sound/arm/aaci.c
sound/arm/aaci.h
sound/arm/pxa2xx-ac97.c
sound/core/Kconfig
sound/core/pcm_lib.c
sound/core/pcm_native.c
sound/core/pcm_timer.c
sound/isa/gus/gus_mem.c
sound/isa/msnd/msnd_midi.c
sound/isa/sb/emu8000.c
sound/mips/sgio2audio.c
sound/oss/pss.c
sound/pci/ac97/ac97_codec.c
sound/pci/cs5535audio/Makefile
sound/pci/cs5535audio/cs5535audio.c
sound/pci/cs5535audio/cs5535audio.h
sound/pci/cs5535audio/cs5535audio_olpc.c
sound/pci/hda/hda_beep.c
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/hda_hwdep.c
sound/pci/hda/hda_intel.c
sound/pci/hda/patch_analog.c
sound/pci/hda/patch_cirrus.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c
sound/soc/codecs/ak4642.c
sound/soc/codecs/stac9766.c
sound/soc/codecs/wm8900.c
sound/soc/codecs/wm8974.c
sound/soc/codecs/wm9712.c
sound/soc/imx/mx27vis_wm8974.c
sound/soc/omap/sdp3430.c
sound/soc/s3c24xx/s3c24xx_simtec.c
sound/soc/s3c24xx/s3c24xx_simtec.h
sound/soc/sh/fsi.c
sound/soc/soc-core.c
sound/usb/usbaudio.c
tools/perf/Documentation/perf-diff.txt [new file with mode: 0644]
tools/perf/Documentation/perf-probe.txt
tools/perf/Documentation/perf-report.txt
tools/perf/Documentation/perf-trace.txt
tools/perf/Makefile
tools/perf/builtin-annotate.c
tools/perf/builtin-buildid-list.c
tools/perf/builtin-diff.c [new file with mode: 0644]
tools/perf/builtin-kmem.c
tools/perf/builtin-probe.c
tools/perf/builtin-record.c
tools/perf/builtin-report.c
tools/perf/builtin-sched.c
tools/perf/builtin-timechart.c
tools/perf/builtin-top.c
tools/perf/builtin-trace.c
tools/perf/builtin.h
tools/perf/command-list.txt
tools/perf/perf.c
tools/perf/scripts/perl/bin/check-perf-trace-report
tools/perf/scripts/perl/bin/rw-by-file-report
tools/perf/scripts/perl/bin/rw-by-pid-report
tools/perf/scripts/perl/bin/wakeup-latency-report
tools/perf/scripts/perl/bin/workqueue-stats-report
tools/perf/scripts/perl/rw-by-file.pl
tools/perf/util/data_map.c
tools/perf/util/data_map.h [deleted file]
tools/perf/util/event.c
tools/perf/util/event.h
tools/perf/util/header.c
tools/perf/util/hist.c
tools/perf/util/hist.h
tools/perf/util/map.c
tools/perf/util/probe-event.c
tools/perf/util/probe-event.h
tools/perf/util/probe-finder.c
tools/perf/util/probe-finder.h
tools/perf/util/session.c
tools/perf/util/session.h
tools/perf/util/sort.c
tools/perf/util/sort.h
tools/perf/util/string.c
tools/perf/util/string.h
tools/perf/util/strlist.c
tools/perf/util/strlist.h
tools/perf/util/symbol.c
tools/perf/util/symbol.h
tools/perf/util/thread.c
tools/perf/util/thread.h
tools/perf/util/trace-event-perl.c
tools/perf/util/trace-event.h
usr/gen_init_cpio.c
virt/kvm/assigned-dev.c
virt/kvm/kvm_main.c

index 946c7ec5c922ff5bb02726144178f56f57c3378d..fb2190c61af0982ae9b8792b51d970bddaafdf5f 100644 (file)
@@ -22,6 +22,7 @@
 *.lst
 *.symtypes
 *.order
+modules.builtin
 *.elf
 *.bin
 *.gz
@@ -45,14 +46,8 @@ Module.symvers
 #
 # Generated include files
 #
-include/asm
-include/asm-*/asm-offsets.h
 include/config
-include/linux/autoconf.h
-include/linux/compile.h
 include/linux/version.h
-include/linux/utsrelease.h
-include/linux/bounds.h
 include/generated
 
 # stgit generated dirs
index deb6b489e4e5da71d80f367961dc46cfafcd8f08..a07c0f366f91827fa869ec4751d3586280aff2d4 100644 (file)
@@ -21,25 +21,27 @@ Contact:    Alan Stern <stern@rowland.harvard.edu>
 Description:
                Each USB device directory will contain a file named
                power/level.  This file holds a power-level setting for
-               the device, one of "on", "auto", or "suspend".
+               the device, either "on" or "auto".
 
                "on" means that the device is not allowed to autosuspend,
                although normal suspends for system sleep will still
                be honored.  "auto" means the device will autosuspend
                and autoresume in the usual manner, according to the
-               capabilities of its driver.  "suspend" means the device
-               is forced into a suspended state and it will not autoresume
-               in response to I/O requests.  However remote-wakeup requests
-               from the device may still be enabled (the remote-wakeup
-               setting is controlled separately by the power/wakeup
-               attribute).
+               capabilities of its driver.
 
                During normal use, devices should be left in the "auto"
-               level.  The other levels are meant for administrative uses.
+               level.  The "on" level is meant for administrative uses.
                If you want to suspend a device immediately but leave it
                free to wake up in response to I/O requests, you should
                write "0" to power/autosuspend.
 
+               Device not capable of proper suspend and resume should be
+               left in the "on" level.  Although the USB spec requires
+               devices to support suspend/resume, many of them do not.
+               In fact so many don't that by default, the USB core
+               initializes all non-hub devices in the "on" level.  Some
+               drivers may change this setting when they are bound.
+
 What:          /sys/bus/usb/devices/.../power/persist
 Date:          May 2007
 KernelVersion: 2.6.23
index 9fe91c02ee40e4fb4bca0b1e7fb010f14d5554e3..bf1627b02a0357a1f38362ac61ab741f274d6f10 100644 (file)
@@ -60,6 +60,19 @@ Description:
 Users:         hotplug memory remove tools
                https://w3.opensource.ibm.com/projects/powerpc-utils/
 
+
+What:          /sys/devices/system/memoryX/nodeY
+Date:          October 2009
+Contact:       Linux Memory Management list <linux-mm@kvack.org>
+Description:
+               When CONFIG_NUMA is enabled, a symbolic link that
+               points to the corresponding NUMA node directory.
+
+               For example, the following symbolic link is created for
+               memory section 9 on node0:
+               /sys/devices/system/memory/memory9/node0 -> ../../node/node0
+
+
 What:          /sys/devices/system/node/nodeX/memoryY
 Date:          September 2008
 Contact:       Gary Hade <garyhade@us.ibm.com>
@@ -70,4 +83,3 @@ Description:
                memory section directory.  For example, the following symbolic
                link is created for memory section 9 on node0.
                /sys/devices/system/node/node0/memory9 -> ../../memory/memory9
-
index 2aae06fcbed7ae8d57489d89c5fea158beb37748..84a710f87c64b17b2eab79a3a2b860c7a9c97319 100644 (file)
@@ -92,6 +92,20 @@ Description: Discover NUMA node a CPU belongs to
                /sys/devices/system/cpu/cpu42/node2 -> ../../node/node2
 
 
+What:          /sys/devices/system/cpu/cpu#/node
+Date:          October 2009
+Contact:       Linux memory management mailing list <linux-mm@kvack.org>
+Description:   Discover NUMA node a CPU belongs to
+
+               When CONFIG_NUMA is enabled, a symbolic link that points
+               to the corresponding NUMA node directory.
+
+               For example, the following symlink is created for cpu42
+               in NUMA node 2:
+
+               /sys/devices/system/cpu/cpu42/node2 -> ../../node/node2
+
+
 What:          /sys/devices/system/cpu/cpu#/topology/core_id
                /sys/devices/system/cpu/cpu#/topology/core_siblings
                /sys/devices/system/cpu/cpu#/topology/core_siblings_list
diff --git a/Documentation/ABI/testing/sysfs-memory-page-offline b/Documentation/ABI/testing/sysfs-memory-page-offline
new file mode 100644 (file)
index 0000000..e14703f
--- /dev/null
@@ -0,0 +1,44 @@
+What:          /sys/devices/system/memory/soft_offline_page
+Date:          Sep 2009
+KernelVersion: 2.6.33
+Contact:       andi@firstfloor.org
+Description:
+               Soft-offline the memory page containing the physical address
+               written into this file. Input is a hex number specifying the
+               physical address of the page. The kernel will then attempt
+               to soft-offline it, by moving the contents elsewhere or
+               dropping it if possible. The kernel will then be placed
+               on the bad page list and never be reused.
+
+               The offlining is done in kernel specific granuality.
+               Normally it's the base page size of the kernel, but
+               this might change.
+
+               The page must be still accessible, not poisoned. The
+               kernel will never kill anything for this, but rather
+               fail the offline.  Return value is the size of the
+               number, or a error when the offlining failed.  Reading
+               the file is not allowed.
+
+What:          /sys/devices/system/memory/hard_offline_page
+Date:          Sep 2009
+KernelVersion: 2.6.33
+Contact:       andi@firstfloor.org
+Description:
+               Hard-offline the memory page containing the physical
+               address written into this file. Input is a hex number
+               specifying the physical address of the page. The
+               kernel will then attempt to hard-offline the page, by
+               trying to drop the page or killing any owner or
+               triggering IO errors if needed.  Note this may kill
+               any processes owning the page. The kernel will avoid
+               to access this page assuming it's poisoned by the
+               hardware.
+
+               The offlining is done in kernel specific granuality.
+               Normally it's the base page size of the kernel, but
+               this might change.
+
+               Return value is the size of the number, or a error when
+               the offlining failed.
+               Reading the file is not allowed.
index 6d0f1efc5bf60220e97277aa381df6ecec2971bb..f08b313cd235fa6728f7780f3b4812eae543f971 100644 (file)
@@ -49,6 +49,8 @@ o  oprofile               0.9                     # oprofiled --version
 o  udev                   081                     # udevinfo -V
 o  grub                   0.93                    # grub --version
 o  mcelog                0.6
+o  iptables               1.4.1                   # iptables -V
+
 
 Kernel compilation
 ==================
index ab8300f67182a1a65e2fbaf5b3956b4869eb8823..325cfd1d6d9929686c6f5c42f93272c3147a7b9c 100644 (file)
@@ -8,7 +8,7 @@
 
 DOCBOOKS := z8530book.xml mcabook.xml device-drivers.xml \
            kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
-           procfs-guide.xml writing_usb_driver.xml networking.xml \
+           writing_usb_driver.xml networking.xml \
            kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \
            gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
            genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \
@@ -32,10 +32,10 @@ PS_METHOD   = $(prefer-db2x)
 
 ###
 # The targets that may be used.
-PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs media
+PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs cleandocs xmldoclinks
 
 BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
-xmldocs: $(BOOKS)
+xmldocs: $(BOOKS) xmldoclinks
 sgmldocs: xmldocs
 
 PS := $(patsubst %.xml, %.ps, $(BOOKS))
@@ -45,15 +45,24 @@ PDF := $(patsubst %.xml, %.pdf, $(BOOKS))
 pdfdocs: $(PDF)
 
 HTML := $(sort $(patsubst %.xml, %.html, $(BOOKS)))
-htmldocs: media $(HTML)
+htmldocs: $(HTML)
        $(call build_main_index)
+       $(call build_images)
 
 MAN := $(patsubst %.xml, %.9, $(BOOKS))
 mandocs: $(MAN)
 
-media:
-       mkdir -p $(srctree)/Documentation/DocBook/media/
-       cp $(srctree)/Documentation/DocBook/dvb/*.png $(srctree)/Documentation/DocBook/v4l/*.gif $(srctree)/Documentation/DocBook/media/
+build_images = mkdir -p $(objtree)/Documentation/DocBook/media/ && \
+              cp $(srctree)/Documentation/DocBook/dvb/*.png $(srctree)/Documentation/DocBook/v4l/*.gif $(objtree)/Documentation/DocBook/media/
+
+xmldoclinks:
+ifneq ($(objtree),$(srctree))
+       for dep in dvb media-entities.tmpl media-indices.tmpl v4l; do \
+               rm -f $(objtree)/Documentation/DocBook/$$dep \
+               && ln -s $(srctree)/Documentation/DocBook/$$dep $(objtree)/Documentation/DocBook/ \
+               || exit; \
+       done
+endif
 
 installmandocs: mandocs
        mkdir -p /usr/local/man/man9/
@@ -65,7 +74,7 @@ KERNELDOC = $(srctree)/scripts/kernel-doc
 DOCPROC   = $(objtree)/scripts/basic/docproc
 
 XMLTOFLAGS = -m $(srctree)/Documentation/DocBook/stylesheet.xsl
-#XMLTOFLAGS += --skip-validation
+XMLTOFLAGS += --skip-validation
 
 ###
 # DOCPROC is used for two purposes:
@@ -101,17 +110,6 @@ endif
 # Changes in kernel-doc force a rebuild of all documentation
 $(BOOKS): $(KERNELDOC)
 
-###
-# procfs guide uses a .c file as example code.
-# This requires an explicit dependency
-C-procfs-example = procfs_example.xml
-C-procfs-example2 = $(addprefix $(obj)/,$(C-procfs-example))
-$(obj)/procfs-guide.xml: $(C-procfs-example2)
-
-# List of programs to build
-##oops, this is a kernel module::hostprogs-y := procfs_example
-obj-m += procfs_example.o
-
 # Tell kbuild to always build the programs
 always := $(hostprogs-y)
 
@@ -238,7 +236,7 @@ clean-files := $(DOCBOOKS) \
        $(patsubst %.xml, %.pdf,  $(DOCBOOKS)) \
        $(patsubst %.xml, %.html, $(DOCBOOKS)) \
        $(patsubst %.xml, %.9,    $(DOCBOOKS)) \
-       $(C-procfs-example) $(index)
+       $(index)
 
 clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man
 
index bb5ab741220ef3ed3a8dbdedbbae87787e2a8825..c725cb852c540df0d5d061d19c9f467ae921c8e7 100644 (file)
@@ -23,6 +23,7 @@
 <!ENTITY VIDIOC-ENUMINPUT "<link linkend='vidioc-enuminput'><constant>VIDIOC_ENUMINPUT</constant></link>">
 <!ENTITY VIDIOC-ENUMOUTPUT "<link linkend='vidioc-enumoutput'><constant>VIDIOC_ENUMOUTPUT</constant></link>">
 <!ENTITY VIDIOC-ENUMSTD "<link linkend='vidioc-enumstd'><constant>VIDIOC_ENUMSTD</constant></link>">
+<!ENTITY VIDIOC-ENUM-DV-PRESETS "<link linkend='vidioc-enum-dv-presets'><constant>VIDIOC_ENUM_DV_PRESETS</constant></link>">
 <!ENTITY VIDIOC-ENUM-FMT "<link linkend='vidioc-enum-fmt'><constant>VIDIOC_ENUM_FMT</constant></link>">
 <!ENTITY VIDIOC-ENUM-FRAMEINTERVALS "<link linkend='vidioc-enum-frameintervals'><constant>VIDIOC_ENUM_FRAMEINTERVALS</constant></link>">
 <!ENTITY VIDIOC-ENUM-FRAMESIZES "<link linkend='vidioc-enum-framesizes'><constant>VIDIOC_ENUM_FRAMESIZES</constant></link>">
@@ -30,6 +31,8 @@
 <!ENTITY VIDIOC-G-AUDOUT "<link linkend='vidioc-g-audioout'><constant>VIDIOC_G_AUDOUT</constant></link>">
 <!ENTITY VIDIOC-G-CROP "<link linkend='vidioc-g-crop'><constant>VIDIOC_G_CROP</constant></link>">
 <!ENTITY VIDIOC-G-CTRL "<link linkend='vidioc-g-ctrl'><constant>VIDIOC_G_CTRL</constant></link>">
+<!ENTITY VIDIOC-G-DV-PRESET "<link linkend='vidioc-g-dv-preset'><constant>VIDIOC_G_DV_PRESET</constant></link>">
+<!ENTITY VIDIOC-G-DV-TIMINGS "<link linkend='vidioc-g-dv-timings'><constant>VIDIOC_G_DV_TIMINGS</constant></link>">
 <!ENTITY VIDIOC-G-ENC-INDEX "<link linkend='vidioc-g-enc-index'><constant>VIDIOC_G_ENC_INDEX</constant></link>">
 <!ENTITY VIDIOC-G-EXT-CTRLS "<link linkend='vidioc-g-ext-ctrls'><constant>VIDIOC_G_EXT_CTRLS</constant></link>">
 <!ENTITY VIDIOC-G-FBUF "<link linkend='vidioc-g-fbuf'><constant>VIDIOC_G_FBUF</constant></link>">
@@ -53,6 +56,7 @@
 <!ENTITY VIDIOC-QUERYCTRL "<link linkend='vidioc-queryctrl'><constant>VIDIOC_QUERYCTRL</constant></link>">
 <!ENTITY VIDIOC-QUERYMENU "<link linkend='vidioc-queryctrl'><constant>VIDIOC_QUERYMENU</constant></link>">
 <!ENTITY VIDIOC-QUERYSTD "<link linkend='vidioc-querystd'><constant>VIDIOC_QUERYSTD</constant></link>">
+<!ENTITY VIDIOC-QUERY-DV-PRESET "<link linkend='vidioc-query-dv-preset'><constant>VIDIOC_QUERY_DV_PRESET</constant></link>">
 <!ENTITY VIDIOC-REQBUFS "<link linkend='vidioc-reqbufs'><constant>VIDIOC_REQBUFS</constant></link>">
 <!ENTITY VIDIOC-STREAMOFF "<link linkend='vidioc-streamon'><constant>VIDIOC_STREAMOFF</constant></link>">
 <!ENTITY VIDIOC-STREAMON "<link linkend='vidioc-streamon'><constant>VIDIOC_STREAMON</constant></link>">
@@ -60,6 +64,8 @@
 <!ENTITY VIDIOC-S-AUDOUT "<link linkend='vidioc-g-audioout'><constant>VIDIOC_S_AUDOUT</constant></link>">
 <!ENTITY VIDIOC-S-CROP "<link linkend='vidioc-g-crop'><constant>VIDIOC_S_CROP</constant></link>">
 <!ENTITY VIDIOC-S-CTRL "<link linkend='vidioc-g-ctrl'><constant>VIDIOC_S_CTRL</constant></link>">
+<!ENTITY VIDIOC-S-DV-PRESET "<link linkend='vidioc-g-dv-preset'><constant>VIDIOC_S_DV_PRESET</constant></link>">
+<!ENTITY VIDIOC-S-DV-TIMINGS "<link linkend='vidioc-g-dv-timings'><constant>VIDIOC_S_DV_TIMINGS</constant></link>">
 <!ENTITY VIDIOC-S-EXT-CTRLS "<link linkend='vidioc-g-ext-ctrls'><constant>VIDIOC_S_EXT_CTRLS</constant></link>">
 <!ENTITY VIDIOC-S-FBUF "<link linkend='vidioc-g-fbuf'><constant>VIDIOC_S_FBUF</constant></link>">
 <!ENTITY VIDIOC-S-FMT "<link linkend='vidioc-g-fmt'><constant>VIDIOC_S_FMT</constant></link>">
 <!-- Structures -->
 <!ENTITY v4l2-audio "struct&nbsp;<link linkend='v4l2-audio'>v4l2_audio</link>">
 <!ENTITY v4l2-audioout "struct&nbsp;<link linkend='v4l2-audioout'>v4l2_audioout</link>">
+<!ENTITY v4l2-bt-timings "struct&nbsp;<link linkend='v4l2-bt-timings'>v4l2_bt_timings</link>">
 <!ENTITY v4l2-buffer "struct&nbsp;<link linkend='v4l2-buffer'>v4l2_buffer</link>">
 <!ENTITY v4l2-capability "struct&nbsp;<link linkend='v4l2-capability'>v4l2_capability</link>">
 <!ENTITY v4l2-captureparm "struct&nbsp;<link linkend='v4l2-captureparm'>v4l2_captureparm</link>">
 <!ENTITY v4l2-dbg-chip-ident "struct&nbsp;<link linkend='v4l2-dbg-chip-ident'>v4l2_dbg_chip_ident</link>">
 <!ENTITY v4l2-dbg-match "struct&nbsp;<link linkend='v4l2-dbg-match'>v4l2_dbg_match</link>">
 <!ENTITY v4l2-dbg-register "struct&nbsp;<link linkend='v4l2-dbg-register'>v4l2_dbg_register</link>">
+<!ENTITY v4l2-dv-enum-preset "struct&nbsp;<link linkend='v4l2-dv-enum-preset'>v4l2_dv_enum_preset</link>">
+<!ENTITY v4l2-dv-preset "struct&nbsp;<link linkend='v4l2-dv-preset'>v4l2_dv_preset</link>">
+<!ENTITY v4l2-dv-timings "struct&nbsp;<link linkend='v4l2-dv-timings'>v4l2_dv_timings</link>">
 <!ENTITY v4l2-enc-idx "struct&nbsp;<link linkend='v4l2-enc-idx'>v4l2_enc_idx</link>">
 <!ENTITY v4l2-enc-idx-entry "struct&nbsp;<link linkend='v4l2-enc-idx-entry'>v4l2_enc_idx_entry</link>">
 <!ENTITY v4l2-encoder-cmd "struct&nbsp;<link linkend='v4l2-encoder-cmd'>v4l2_encoder_cmd</link>">
 <!ENTITY sub-enumaudioout SYSTEM "v4l/vidioc-enumaudioout.xml">
 <!ENTITY sub-enuminput SYSTEM "v4l/vidioc-enuminput.xml">
 <!ENTITY sub-enumoutput SYSTEM "v4l/vidioc-enumoutput.xml">
+<!ENTITY sub-enum-dv-presets SYSTEM "v4l/vidioc-enum-dv-presets.xml">
+<!ENTITY sub-g-dv-preset SYSTEM "v4l/vidioc-g-dv-preset.xml">
+<!ENTITY sub-query-dv-preset SYSTEM "v4l/vidioc-query-dv-preset.xml">
+<!ENTITY sub-g-dv-timings SYSTEM "v4l/vidioc-g-dv-timings.xml">
 <!ENTITY sub-enumstd SYSTEM "v4l/vidioc-enumstd.xml">
 <!ENTITY sub-g-audio SYSTEM "v4l/vidioc-g-audio.xml">
 <!ENTITY sub-g-audioout SYSTEM "v4l/vidioc-g-audioout.xml">
 <!ENTITY enumaudioout SYSTEM "v4l/vidioc-enumaudioout.xml">
 <!ENTITY enuminput SYSTEM "v4l/vidioc-enuminput.xml">
 <!ENTITY enumoutput SYSTEM "v4l/vidioc-enumoutput.xml">
+<!ENTITY enum-dv-presets SYSTEM "v4l/vidioc-enum-dv-presets.xml">
+<!ENTITY g-dv-preset SYSTEM "v4l/vidioc-g-dv-preset.xml">
+<!ENTITY query-dv-preset SYSTEM "v4l/vidioc-query-dv-preset.xml">
+<!ENTITY g-dv-timings SYSTEM "v4l/vidioc-g-dv-timings.xml">
 <!ENTITY enumstd SYSTEM "v4l/vidioc-enumstd.xml">
 <!ENTITY g-audio SYSTEM "v4l/vidioc-g-audio.xml">
 <!ENTITY g-audioout SYSTEM "v4l/vidioc-g-audioout.xml">
index 9e30a236d74f7af2aaa1fc71e914266cf7b17660..78d6031de001bc5fd46a926c91037058e85aa3ff 100644 (file)
@@ -36,6 +36,7 @@
 <indexentry><primaryie>enum&nbsp;<link linkend='v4l2-preemphasis'>v4l2_preemphasis</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-audio'>v4l2_audio</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-audioout'>v4l2_audioout</link></primaryie></indexentry>
+<indexentry><primaryie>struct&nbsp;<link linkend='v4l2-bt-timings'>v4l2_bt_timings</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-buffer'>v4l2_buffer</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-capability'>v4l2_capability</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-captureparm'>v4l2_captureparm</link></primaryie></indexentry>
@@ -46,6 +47,9 @@
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-dbg-chip-ident'>v4l2_dbg_chip_ident</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-dbg-match'>v4l2_dbg_match</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-dbg-register'>v4l2_dbg_register</link></primaryie></indexentry>
+<indexentry><primaryie>struct&nbsp;<link linkend='v4l2-dv-enum-preset'>v4l2_dv_enum_preset</link></primaryie></indexentry>
+<indexentry><primaryie>struct&nbsp;<link linkend='v4l2-dv-preset'>v4l2_dv_preset</link></primaryie></indexentry>
+<indexentry><primaryie>struct&nbsp;<link linkend='v4l2-dv-timings'>v4l2_dv_timings</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-enc-idx'>v4l2_enc_idx</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-enc-idx-entry'>v4l2_enc_idx_entry</link></primaryie></indexentry>
 <indexentry><primaryie>struct&nbsp;<link linkend='v4l2-encoder-cmd'>v4l2_encoder_cmd</link></primaryie></indexentry>
diff --git a/Documentation/DocBook/procfs-guide.tmpl b/Documentation/DocBook/procfs-guide.tmpl
deleted file mode 100644 (file)
index 9eba4b7..0000000
+++ /dev/null
@@ -1,626 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
-       "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
-<!ENTITY procfsexample SYSTEM "procfs_example.xml">
-]>
-
-<book id="LKProcfsGuide">
-  <bookinfo>
-    <title>Linux Kernel Procfs Guide</title>
-
-    <authorgroup>
-      <author>
-       <firstname>Erik</firstname>
-       <othername>(J.A.K.)</othername>
-       <surname>Mouw</surname>
-       <affiliation>
-         <address>
-            <email>mouw@nl.linux.org</email>
-          </address>
-       </affiliation>
-      </author>
-      <othercredit>
-       <contrib>
-       This software and documentation were written while working on the
-       LART computing board
-       (<ulink url="http://www.lartmaker.nl/">http://www.lartmaker.nl/</ulink>),
-       which was sponsored by the Delt University of Technology projects
-       Mobile Multi-media Communications and Ubiquitous Communications.
-       </contrib>
-      </othercredit>
-    </authorgroup>
-
-    <revhistory>
-      <revision>
-       <revnumber>1.0</revnumber>
-       <date>May 30, 2001</date>
-       <revremark>Initial revision posted to linux-kernel</revremark>
-      </revision>
-      <revision>
-       <revnumber>1.1</revnumber>
-       <date>June 3, 2001</date>
-       <revremark>Revised after comments from linux-kernel</revremark>
-      </revision>
-    </revhistory>
-
-    <copyright>
-      <year>2001</year>
-      <holder>Erik Mouw</holder>
-    </copyright>
-
-
-    <legalnotice>
-      <para>
-        This documentation is free software; you can redistribute it
-        and/or modify it under the terms of the GNU General Public
-        License as published by the Free Software Foundation; either
-        version 2 of the License, or (at your option) any later
-        version.
-      </para>
-      
-      <para>
-        This documentation is distributed in the hope that it will be
-        useful, but WITHOUT ANY WARRANTY; without even the implied
-        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-        PURPOSE.  See the GNU General Public License for more details.
-      </para>
-      
-      <para>
-        You should have received a copy of the GNU General Public
-        License along with this program; if not, write to the Free
-        Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-        MA 02111-1307 USA
-      </para>
-      
-      <para>
-        For more details see the file COPYING in the source
-        distribution of Linux.
-      </para>
-    </legalnotice>
-  </bookinfo>
-
-
-
-
-  <toc>
-  </toc>
-
-
-
-
-  <preface id="Preface">
-    <title>Preface</title>
-
-    <para>
-      This guide describes the use of the procfs file system from
-      within the Linux kernel. The idea to write this guide came up on
-      the #kernelnewbies IRC channel (see <ulink
-      url="http://www.kernelnewbies.org/">http://www.kernelnewbies.org/</ulink>),
-      when Jeff Garzik explained the use of procfs and forwarded me a
-      message Alexander Viro wrote to the linux-kernel mailing list. I
-      agreed to write it up nicely, so here it is.
-    </para>
-
-    <para>
-      I'd like to thank Jeff Garzik
-      <email>jgarzik@pobox.com</email> and Alexander Viro
-      <email>viro@parcelfarce.linux.theplanet.co.uk</email> for their input,
-      Tim Waugh <email>twaugh@redhat.com</email> for his <ulink
-      url="http://people.redhat.com/twaugh/docbook/selfdocbook/">Selfdocbook</ulink>,
-      and Marc Joosen <email>marcj@historia.et.tudelft.nl</email> for
-      proofreading.
-    </para>
-
-    <para>
-      Erik
-    </para>
-  </preface>
-
-
-
-
-  <chapter id="intro">
-    <title>Introduction</title>
-
-    <para>
-      The <filename class="directory">/proc</filename> file system
-      (procfs) is a special file system in the linux kernel. It's a
-      virtual file system: it is not associated with a block device
-      but exists only in memory. The files in the procfs are there to
-      allow userland programs access to certain information from the
-      kernel (like process information in <filename
-      class="directory">/proc/[0-9]+/</filename>), but also for debug
-      purposes (like <filename>/proc/ksyms</filename>).
-    </para>
-
-    <para>
-      This guide describes the use of the procfs file system from
-      within the Linux kernel. It starts by introducing all relevant
-      functions to manage the files within the file system. After that
-      it shows how to communicate with userland, and some tips and
-      tricks will be pointed out. Finally a complete example will be
-      shown.
-    </para>
-
-    <para>
-      Note that the files in <filename
-      class="directory">/proc/sys</filename> are sysctl files: they
-      don't belong to procfs and are governed by a completely
-      different API described in the Kernel API book.
-    </para>
-  </chapter>
-
-
-
-
-  <chapter id="managing">
-    <title>Managing procfs entries</title>
-    
-    <para>
-      This chapter describes the functions that various kernel
-      components use to populate the procfs with files, symlinks,
-      device nodes, and directories.
-    </para>
-
-    <para>
-      A minor note before we start: if you want to use any of the
-      procfs functions, be sure to include the correct header file! 
-      This should be one of the first lines in your code:
-    </para>
-
-    <programlisting>
-#include &lt;linux/proc_fs.h&gt;
-    </programlisting>
-
-
-
-
-    <sect1 id="regularfile">
-      <title>Creating a regular file</title>
-      
-      <funcsynopsis>
-       <funcprototype>
-         <funcdef>struct proc_dir_entry* <function>create_proc_entry</function></funcdef>
-         <paramdef>const char* <parameter>name</parameter></paramdef>
-         <paramdef>mode_t <parameter>mode</parameter></paramdef>
-         <paramdef>struct proc_dir_entry* <parameter>parent</parameter></paramdef>
-       </funcprototype>
-      </funcsynopsis>
-
-      <para>
-        This function creates a regular file with the name
-        <parameter>name</parameter>, file mode
-        <parameter>mode</parameter> in the directory
-        <parameter>parent</parameter>. To create a file in the root of
-        the procfs, use <constant>NULL</constant> as
-        <parameter>parent</parameter> parameter. When successful, the
-        function will return a pointer to the freshly created
-        <structname>struct proc_dir_entry</structname>; otherwise it
-        will return <constant>NULL</constant>. <xref
-        linkend="userland"/> describes how to do something useful with
-        regular files.
-      </para>
-
-      <para>
-        Note that it is specifically supported that you can pass a
-        path that spans multiple directories. For example
-        <function>create_proc_entry</function>(<parameter>"drivers/via0/info"</parameter>)
-        will create the <filename class="directory">via0</filename>
-        directory if necessary, with standard
-        <constant>0755</constant> permissions.
-      </para>
-
-    <para>
-      If you only want to be able to read the file, the function
-      <function>create_proc_read_entry</function> described in <xref
-      linkend="convenience"/> may be used to create and initialise
-      the procfs entry in one single call.
-    </para>
-    </sect1>
-
-
-
-
-    <sect1 id="Creating_a_symlink">
-      <title>Creating a symlink</title>
-
-      <funcsynopsis>
-       <funcprototype>
-         <funcdef>struct proc_dir_entry*
-         <function>proc_symlink</function></funcdef> <paramdef>const
-         char* <parameter>name</parameter></paramdef>
-         <paramdef>struct proc_dir_entry*
-         <parameter>parent</parameter></paramdef> <paramdef>const
-         char* <parameter>dest</parameter></paramdef>
-       </funcprototype>
-      </funcsynopsis>
-      
-      <para>
-        This creates a symlink in the procfs directory
-        <parameter>parent</parameter> that points from
-        <parameter>name</parameter> to
-        <parameter>dest</parameter>. This translates in userland to
-        <literal>ln -s</literal> <parameter>dest</parameter>
-        <parameter>name</parameter>.
-      </para>
-    </sect1>
-
-    <sect1 id="Creating_a_directory">
-      <title>Creating a directory</title>
-      
-      <funcsynopsis>
-       <funcprototype>
-         <funcdef>struct proc_dir_entry* <function>proc_mkdir</function></funcdef>
-         <paramdef>const char* <parameter>name</parameter></paramdef>
-         <paramdef>struct proc_dir_entry* <parameter>parent</parameter></paramdef>
-       </funcprototype>
-      </funcsynopsis>
-
-      <para>
-        Create a directory <parameter>name</parameter> in the procfs
-        directory <parameter>parent</parameter>.
-      </para>
-    </sect1>
-
-
-
-
-    <sect1 id="Removing_an_entry">
-      <title>Removing an entry</title>
-      
-      <funcsynopsis>
-       <funcprototype>
-         <funcdef>void <function>remove_proc_entry</function></funcdef>
-         <paramdef>const char* <parameter>name</parameter></paramdef>
-         <paramdef>struct proc_dir_entry* <parameter>parent</parameter></paramdef>
-       </funcprototype>
-      </funcsynopsis>
-
-      <para>
-        Removes the entry <parameter>name</parameter> in the directory
-        <parameter>parent</parameter> from the procfs. Entries are
-        removed by their <emphasis>name</emphasis>, not by the
-        <structname>struct proc_dir_entry</structname> returned by the
-        various create functions. Note that this function doesn't
-        recursively remove entries.
-      </para>
-
-      <para>
-        Be sure to free the <structfield>data</structfield> entry from
-        the <structname>struct proc_dir_entry</structname> before
-        <function>remove_proc_entry</function> is called (that is: if
-        there was some <structfield>data</structfield> allocated, of
-        course). See <xref linkend="usingdata"/> for more information
-        on using the <structfield>data</structfield> entry.
-      </para>
-    </sect1>
-  </chapter>
-
-
-
-
-  <chapter id="userland">
-    <title>Communicating with userland</title>
-    
-    <para>
-       Instead of reading (or writing) information directly from
-       kernel memory, procfs works with <emphasis>call back
-       functions</emphasis> for files: functions that are called when
-       a specific file is being read or written. Such functions have
-       to be initialised after the procfs file is created by setting
-       the <structfield>read_proc</structfield> and/or
-       <structfield>write_proc</structfield> fields in the
-       <structname>struct proc_dir_entry*</structname> that the
-       function <function>create_proc_entry</function> returned:
-    </para>
-
-    <programlisting>
-struct proc_dir_entry* entry;
-
-entry->read_proc = read_proc_foo;
-entry->write_proc = write_proc_foo;
-    </programlisting>
-
-    <para>
-      If you only want to use a the
-      <structfield>read_proc</structfield>, the function
-      <function>create_proc_read_entry</function> described in <xref
-      linkend="convenience"/> may be used to create and initialise the
-      procfs entry in one single call.
-    </para>
-
-
-
-    <sect1 id="Reading_data">
-      <title>Reading data</title>
-
-      <para>
-        The read function is a call back function that allows userland
-        processes to read data from the kernel. The read function
-        should have the following format:
-      </para>
-
-      <funcsynopsis>
-       <funcprototype>
-         <funcdef>int <function>read_func</function></funcdef>
-         <paramdef>char* <parameter>buffer</parameter></paramdef>
-         <paramdef>char** <parameter>start</parameter></paramdef>
-         <paramdef>off_t <parameter>off</parameter></paramdef>
-         <paramdef>int <parameter>count</parameter></paramdef>
-         <paramdef>int* <parameter>peof</parameter></paramdef>
-         <paramdef>void* <parameter>data</parameter></paramdef>
-       </funcprototype>
-      </funcsynopsis>
-
-      <para>
-        The read function should write its information into the
-        <parameter>buffer</parameter>, which will be exactly
-        <literal>PAGE_SIZE</literal> bytes long.
-      </para>
-
-      <para>
-        The parameter
-        <parameter>peof</parameter> should be used to signal that the
-        end of the file has been reached by writing
-        <literal>1</literal> to the memory location
-        <parameter>peof</parameter> points to.
-      </para>
-
-      <para>
-        The <parameter>data</parameter>
-        parameter can be used to create a single call back function for
-        several files, see <xref linkend="usingdata"/>.
-      </para>
-
-      <para>
-        The rest of the parameters and the return value are described
-       by a comment in <filename>fs/proc/generic.c</filename> as follows:
-      </para>
-
-      <blockquote>
-        <para>
-       You have three ways to return data:
-               </para>
-        <orderedlist>
-          <listitem>
-            <para>
-             Leave <literal>*start = NULL</literal>.  (This is the default.)
-             Put the data of the requested offset at that
-             offset within the buffer.  Return the number (<literal>n</literal>)
-             of bytes there are from the beginning of the
-             buffer up to the last byte of data.  If the
-             number of supplied bytes (<literal>= n - offset</literal>) is
-             greater than zero and you didn't signal eof
-             and the reader is prepared to take more data
-             you will be called again with the requested
-             offset advanced by the number of bytes
-             absorbed.  This interface is useful for files
-             no larger than the buffer.
-           </para>
-         </listitem>
-         <listitem>
-            <para>
-             Set <literal>*start</literal> to an unsigned long value less than
-             the buffer address but greater than zero.
-             Put the data of the requested offset at the
-             beginning of the buffer.  Return the number of
-             bytes of data placed there.  If this number is
-             greater than zero and you didn't signal eof
-             and the reader is prepared to take more data
-             you will be called again with the requested
-             offset advanced by <literal>*start</literal>.  This interface is
-             useful when you have a large file consisting
-             of a series of blocks which you want to count
-             and return as wholes.
-             (Hack by Paul.Russell@rustcorp.com.au)
-           </para>
-         </listitem>
-         <listitem>
-            <para>
-             Set <literal>*start</literal> to an address within the buffer.
-             Put the data of the requested offset at <literal>*start</literal>.
-             Return the number of bytes of data placed there.
-             If this number is greater than zero and you
-             didn't signal eof and the reader is prepared to
-             take more data you will be called again with the
-             requested offset advanced by the number of bytes
-             absorbed.
-           </para>
-         </listitem>
-       </orderedlist>
-      </blockquote>
-
-      <para>
-        <xref linkend="example"/> shows how to use a read call back
-        function.
-      </para>
-    </sect1>
-
-
-
-
-    <sect1 id="Writing_data">
-      <title>Writing data</title>
-
-      <para>
-        The write call back function allows a userland process to write
-        data to the kernel, so it has some kind of control over the
-        kernel. The write function should have the following format:
-      </para>
-
-      <funcsynopsis>
-       <funcprototype>
-         <funcdef>int <function>write_func</function></funcdef>
-         <paramdef>struct file* <parameter>file</parameter></paramdef>
-         <paramdef>const char* <parameter>buffer</parameter></paramdef>
-         <paramdef>unsigned long <parameter>count</parameter></paramdef>
-         <paramdef>void* <parameter>data</parameter></paramdef>
-       </funcprototype>
-      </funcsynopsis>
-
-      <para>
-        The write function should read <parameter>count</parameter>
-        bytes at maximum from the <parameter>buffer</parameter>. Note
-        that the <parameter>buffer</parameter> doesn't live in the
-        kernel's memory space, so it should first be copied to kernel
-        space with <function>copy_from_user</function>. The
-        <parameter>file</parameter> parameter is usually
-        ignored. <xref linkend="usingdata"/> shows how to use the
-        <parameter>data</parameter> parameter.
-      </para>
-
-      <para>
-        Again, <xref linkend="example"/> shows how to use this call back
-        function.
-      </para>
-    </sect1>
-
-
-
-
-    <sect1 id="usingdata">
-      <title>A single call back for many files</title>
-
-      <para>
-         When a large number of almost identical files is used, it's
-         quite inconvenient to use a separate call back function for
-         each file. A better approach is to have a single call back
-         function that distinguishes between the files by using the
-         <structfield>data</structfield> field in <structname>struct
-         proc_dir_entry</structname>. First of all, the
-         <structfield>data</structfield> field has to be initialised:
-      </para>
-
-      <programlisting>
-struct proc_dir_entry* entry;
-struct my_file_data *file_data;
-
-file_data = kmalloc(sizeof(struct my_file_data), GFP_KERNEL);
-entry->data = file_data;
-      </programlisting>
-     
-      <para>
-          The <structfield>data</structfield> field is a <type>void
-          *</type>, so it can be initialised with anything.
-      </para>
-
-      <para>
-        Now that the <structfield>data</structfield> field is set, the
-        <function>read_proc</function> and
-        <function>write_proc</function> can use it to distinguish
-        between files because they get it passed into their
-        <parameter>data</parameter> parameter:
-      </para>
-
-      <programlisting>
-int foo_read_func(char *page, char **start, off_t off,
-                  int count, int *eof, void *data)
-{
-        int len;
-
-        if(data == file_data) {
-                /* special case for this file */
-        } else {
-                /* normal processing */
-        }
-
-        return len;
-}
-      </programlisting>
-
-      <para>
-        Be sure to free the <structfield>data</structfield> data field
-        when removing the procfs entry.
-      </para>
-    </sect1>
-  </chapter>
-
-
-
-
-  <chapter id="tips">
-    <title>Tips and tricks</title>
-
-
-
-
-    <sect1 id="convenience">
-      <title>Convenience functions</title>
-
-      <funcsynopsis>
-       <funcprototype>
-         <funcdef>struct proc_dir_entry* <function>create_proc_read_entry</function></funcdef>
-         <paramdef>const char* <parameter>name</parameter></paramdef>
-         <paramdef>mode_t <parameter>mode</parameter></paramdef>
-         <paramdef>struct proc_dir_entry* <parameter>parent</parameter></paramdef>
-         <paramdef>read_proc_t* <parameter>read_proc</parameter></paramdef>
-         <paramdef>void* <parameter>data</parameter></paramdef>
-       </funcprototype>
-      </funcsynopsis>
-      
-      <para>
-        This function creates a regular file in exactly the same way
-        as <function>create_proc_entry</function> from <xref
-        linkend="regularfile"/> does, but also allows to set the read
-        function <parameter>read_proc</parameter> in one call. This
-        function can set the <parameter>data</parameter> as well, like
-        explained in <xref linkend="usingdata"/>.
-      </para>
-    </sect1>
-
-
-
-    <sect1 id="Modules">
-      <title>Modules</title>
-
-      <para>
-        If procfs is being used from within a module, be sure to set
-        the <structfield>owner</structfield> field in the
-        <structname>struct proc_dir_entry</structname> to
-        <constant>THIS_MODULE</constant>.
-      </para>
-
-      <programlisting>
-struct proc_dir_entry* entry;
-
-entry->owner = THIS_MODULE;
-      </programlisting>
-    </sect1>
-
-
-
-
-    <sect1 id="Mode_and_ownership">
-      <title>Mode and ownership</title>
-
-      <para>
-        Sometimes it is useful to change the mode and/or ownership of
-        a procfs entry. Here is an example that shows how to achieve
-        that:
-      </para>
-
-      <programlisting>
-struct proc_dir_entry* entry;
-
-entry->mode =  S_IWUSR |S_IRUSR | S_IRGRP | S_IROTH;
-entry->uid = 0;
-entry->gid = 100;
-      </programlisting>
-
-    </sect1>
-  </chapter>
-
-
-
-
-  <chapter id="example">
-    <title>Example</title>
-
-    <!-- be careful with the example code: it shouldn't be wider than
-    approx. 60 columns, or otherwise it won't fit properly on a page
-    -->
-
-&procfsexample;
-
-  </chapter>
-</book>
diff --git a/Documentation/DocBook/procfs_example.c b/Documentation/DocBook/procfs_example.c
deleted file mode 100644 (file)
index a5b1179..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * procfs_example.c: an example proc interface
- *
- * Copyright (C) 2001, Erik Mouw (mouw@nl.linux.org)
- *
- * This file accompanies the procfs-guide in the Linux kernel
- * source. Its main use is to demonstrate the concepts and
- * functions described in the guide.
- *
- * This software has been developed while working on the LART
- * computing board (http://www.lartmaker.nl), which was sponsored
- * by the Delt University of Technology projects Mobile Multi-media
- * Communications and Ubiquitous Communications.
- *
- * This program is free software; you can redistribute
- * it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be
- * useful, but WITHOUT ANY WARRANTY; without even the implied
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more
- * details.
- * 
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place,
- * Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/proc_fs.h>
-#include <linux/jiffies.h>
-#include <asm/uaccess.h>
-
-
-#define MODULE_VERS "1.0"
-#define MODULE_NAME "procfs_example"
-
-#define FOOBAR_LEN 8
-
-struct fb_data_t {
-       char name[FOOBAR_LEN + 1];
-       char value[FOOBAR_LEN + 1];
-};
-
-
-static struct proc_dir_entry *example_dir, *foo_file,
-       *bar_file, *jiffies_file, *symlink;
-
-
-struct fb_data_t foo_data, bar_data;
-
-
-static int proc_read_jiffies(char *page, char **start,
-                            off_t off, int count,
-                            int *eof, void *data)
-{
-       int len;
-
-       len = sprintf(page, "jiffies = %ld\n",
-                      jiffies);
-
-       return len;
-}
-
-
-static int proc_read_foobar(char *page, char **start,
-                           off_t off, int count, 
-                           int *eof, void *data)
-{
-       int len;
-       struct fb_data_t *fb_data = (struct fb_data_t *)data;
-
-       /* DON'T DO THAT - buffer overruns are bad */
-       len = sprintf(page, "%s = '%s'\n", 
-                     fb_data->name, fb_data->value);
-
-       return len;
-}
-
-
-static int proc_write_foobar(struct file *file,
-                            const char *buffer,
-                            unsigned long count, 
-                            void *data)
-{
-       int len;
-       struct fb_data_t *fb_data = (struct fb_data_t *)data;
-
-       if(count > FOOBAR_LEN)
-               len = FOOBAR_LEN;
-       else
-               len = count;
-
-       if(copy_from_user(fb_data->value, buffer, len))
-               return -EFAULT;
-
-       fb_data->value[len] = '\0';
-
-       return len;
-}
-
-
-static int __init init_procfs_example(void)
-{
-       int rv = 0;
-
-       /* create directory */
-       example_dir = proc_mkdir(MODULE_NAME, NULL);
-       if(example_dir == NULL) {
-               rv = -ENOMEM;
-               goto out;
-       }
-       /* create jiffies using convenience function */
-       jiffies_file = create_proc_read_entry("jiffies", 
-                                             0444, example_dir, 
-                                             proc_read_jiffies,
-                                             NULL);
-       if(jiffies_file == NULL) {
-               rv  = -ENOMEM;
-               goto no_jiffies;
-       }
-
-       /* create foo and bar files using same callback
-        * functions 
-        */
-       foo_file = create_proc_entry("foo", 0644, example_dir);
-       if(foo_file == NULL) {
-               rv = -ENOMEM;
-               goto no_foo;
-       }
-
-       strcpy(foo_data.name, "foo");
-       strcpy(foo_data.value, "foo");
-       foo_file->data = &foo_data;
-       foo_file->read_proc = proc_read_foobar;
-       foo_file->write_proc = proc_write_foobar;
-               
-       bar_file = create_proc_entry("bar", 0644, example_dir);
-       if(bar_file == NULL) {
-               rv = -ENOMEM;
-               goto no_bar;
-       }
-
-       strcpy(bar_data.name, "bar");
-       strcpy(bar_data.value, "bar");
-       bar_file->data = &bar_data;
-       bar_file->read_proc = proc_read_foobar;
-       bar_file->write_proc = proc_write_foobar;
-               
-       /* create symlink */
-       symlink = proc_symlink("jiffies_too", example_dir, 
-                              "jiffies");
-       if(symlink == NULL) {
-               rv = -ENOMEM;
-               goto no_symlink;
-       }
-
-       /* everything OK */
-       printk(KERN_INFO "%s %s initialised\n",
-              MODULE_NAME, MODULE_VERS);
-       return 0;
-
-no_symlink:
-       remove_proc_entry("bar", example_dir);
-no_bar:
-       remove_proc_entry("foo", example_dir);
-no_foo:
-       remove_proc_entry("jiffies", example_dir);
-no_jiffies:                          
-       remove_proc_entry(MODULE_NAME, NULL);
-out:
-       return rv;
-}
-
-
-static void __exit cleanup_procfs_example(void)
-{
-       remove_proc_entry("jiffies_too", example_dir);
-       remove_proc_entry("bar", example_dir);
-       remove_proc_entry("foo", example_dir);
-       remove_proc_entry("jiffies", example_dir);
-       remove_proc_entry(MODULE_NAME, NULL);
-
-       printk(KERN_INFO "%s %s removed\n",
-              MODULE_NAME, MODULE_VERS);
-}
-
-
-module_init(init_procfs_example);
-module_exit(cleanup_procfs_example);
-
-MODULE_AUTHOR("Erik Mouw");
-MODULE_DESCRIPTION("procfs examples");
-MODULE_LICENSE("GPL");
index b1a81d246d581913af349d7adbec4be57ec58c79..c65f0ac9b6eec58942562c7e8d1a5386554a4fa9 100644 (file)
@@ -716,6 +716,41 @@ if (-1 == ioctl (fd, &VIDIOC-S-STD;, &amp;std_id)) {
 }
       </programlisting>
     </example>
+  <section id="dv-timings">
+       <title>Digital Video (DV) Timings</title>
+       <para>
+       The video standards discussed so far has been dealing with Analog TV and the
+corresponding video timings. Today there are many more different hardware interfaces
+such as High Definition TV interfaces (HDMI), VGA, DVI connectors etc., that carry
+video signals and there is a need to extend the API to select the video timings
+for these interfaces. Since it is not possible to extend the &v4l2-std-id; due to
+the limited bits available, a new set of IOCTLs is added to set/get video timings at
+the input and output: </para><itemizedlist>
+       <listitem>
+       <para>DV Presets: Digital Video (DV) presets. These are IDs representing a
+video timing at the input/output. Presets are pre-defined timings implemented
+by the hardware according to video standards. A __u32 data type is used to represent
+a preset unlike the bit mask that is used in &v4l2-std-id; allowing future extensions
+to support as many different presets as needed.</para>
+       </listitem>
+       <listitem>
+       <para>Custom DV Timings: This will allow applications to define more detailed
+custom video timings for the interface. This includes parameters such as width, height,
+polarities, frontporch, backporch etc.
+       </para>
+       </listitem>
+       </itemizedlist>
+       <para>To enumerate and query the attributes of DV presets supported by a device,
+applications use the &VIDIOC-ENUM-DV-PRESETS; ioctl. To get the current DV preset,
+applications use the &VIDIOC-G-DV-PRESET; ioctl and to set a preset they use the
+&VIDIOC-S-DV-PRESET; ioctl.</para>
+       <para>To set custom DV timings for the device, applications use the
+&VIDIOC-S-DV-TIMINGS; ioctl and to get current custom DV timings they use the
+&VIDIOC-G-DV-TIMINGS; ioctl.</para>
+       <para>Applications can make use of the <xref linkend="input-capabilities" /> and
+<xref linkend="output-capabilities"/> flags to decide what ioctls are available to set the
+video timings for the device.</para>
+       </section>
   </section>
 
   &sub-controls;
index 4d1902a54d613fe6ca2169b1046f8ba3bf544dc9..b9dbdf9e6d29bd29b3df3617a77311b947b27e80 100644 (file)
@@ -2291,8 +2291,8 @@ was renamed to <structname id="v4l2-chip-ident-old">v4l2_chip_ident_old</structn
        <listitem>
          <para>New control <constant>V4L2_CID_COLORFX</constant> was added.</para>
        </listitem>
-       </orderedlist>
-     </section>
+      </orderedlist>
+    </section>
     <section>
       <title>V4L2 in Linux 2.6.32</title>
       <orderedlist>
@@ -2322,8 +2322,16 @@ more information.</para>
        <listitem>
          <para>Added Remote Controller chapter, describing the default Remote Controller mapping for media devices.</para>
        </listitem>
-       </orderedlist>
-     </section>
+      </orderedlist>
+    </section>
+    <section>
+      <title>V4L2 in Linux 2.6.33</title>
+      <orderedlist>
+       <listitem>
+         <para>Added support for Digital Video timings in order to support HDTV receivers and transmitters.</para>
+       </listitem>
+      </orderedlist>
+    </section>
    </section>
 
    <section id="other">
index 937b4157a5d07ba48322d34a289154a7cf9c2823..060105af49e5989b2f1dad9a9c38f00d532e1602 100644 (file)
@@ -74,6 +74,17 @@ Remote Controller chapter.</contrib>
          </address>
        </affiliation>
       </author>
+
+      <author>
+       <firstname>Muralidharan</firstname>
+       <surname>Karicheri</surname>
+       <contrib>Documented the Digital Video timings API.</contrib>
+       <affiliation>
+         <address>
+           <email>m-karicheri2@ti.com</email>
+         </address>
+       </affiliation>
+      </author>
     </authorgroup>
 
     <copyright>
@@ -89,7 +100,7 @@ Remote Controller chapter.</contrib>
       <year>2008</year>
       <year>2009</year>
       <holder>Bill Dirks, Michael H. Schimek, Hans Verkuil, Martin
-Rubli, Andy Walls, Mauro Carvalho Chehab</holder>
+Rubli, Andy Walls, Muralidharan Karicheri, Mauro Carvalho Chehab</holder>
     </copyright>
     <legalnotice>
     <para>Except when explicitly stated as GPL, programming examples within
@@ -102,6 +113,13 @@ structs, ioctls) must be noted in more detail in the history chapter
 (compat.sgml), along with the possible impact on existing drivers and
 applications. -->
 
+      <revision>
+       <revnumber>2.6.33</revnumber>
+       <date>2009-12-03</date>
+       <authorinitials>mk</authorinitials>
+       <revremark>Added documentation for the Digital Video timings API.</revremark>
+      </revision>
+
       <revision>
        <revnumber>2.6.32</revnumber>
        <date>2009-08-31</date>
@@ -355,7 +373,7 @@ and discussions on the V4L mailing list.</revremark>
 </partinfo>
 
 <title>Video for Linux Two API Specification</title>
- <subtitle>Revision 2.6.32</subtitle>
+ <subtitle>Revision 2.6.33</subtitle>
 
   <chapter id="common">
     &sub-common;
@@ -411,6 +429,7 @@ and discussions on the V4L mailing list.</revremark>
     &sub-encoder-cmd;
     &sub-enumaudio;
     &sub-enumaudioout;
+    &sub-enum-dv-presets;
     &sub-enum-fmt;
     &sub-enum-framesizes;
     &sub-enum-frameintervals;
@@ -421,6 +440,8 @@ and discussions on the V4L mailing list.</revremark>
     &sub-g-audioout;
     &sub-g-crop;
     &sub-g-ctrl;
+    &sub-g-dv-preset;
+    &sub-g-dv-timings;
     &sub-g-enc-index;
     &sub-g-ext-ctrls;
     &sub-g-fbuf;
@@ -441,6 +462,7 @@ and discussions on the V4L mailing list.</revremark>
     &sub-querybuf;
     &sub-querycap;
     &sub-queryctrl;
+    &sub-query-dv-preset;
     &sub-querystd;
     &sub-reqbufs;
     &sub-s-hw-freq-seek;
index 3e282ed9f593820d3240d025ffdb186a405f948f..068325940658ee78ed9515f6270f17b3360eede2 100644 (file)
@@ -733,6 +733,99 @@ struct <link linkend="v4l2-standard">v4l2_standard</link> {
         __u32                reserved[4];
 };
 
+/*
+ *      V I D E O       T I M I N G S   D V     P R E S E T
+ */
+struct <link linkend="v4l2-dv-preset">v4l2_dv_preset</link> {
+        __u32   preset;
+        __u32   reserved[4];
+};
+
+/*
+ *      D V     P R E S E T S   E N U M E R A T I O N
+ */
+struct <link linkend="v4l2-dv-enum-preset">v4l2_dv_enum_preset</link> {
+        __u32   index;
+        __u32   preset;
+        __u8    name[32]; /* Name of the preset timing */
+        __u32   width;
+        __u32   height;
+        __u32   reserved[4];
+};
+
+/*
+ *      D V     P R E S E T     V A L U E S
+ */
+#define         V4L2_DV_INVALID         0
+#define         V4L2_DV_480P59_94       1 /* BT.1362 */
+#define         V4L2_DV_576P50          2 /* BT.1362 */
+#define         V4L2_DV_720P24          3 /* SMPTE 296M */
+#define         V4L2_DV_720P25          4 /* SMPTE 296M */
+#define         V4L2_DV_720P30          5 /* SMPTE 296M */
+#define         V4L2_DV_720P50          6 /* SMPTE 296M */
+#define         V4L2_DV_720P59_94       7 /* SMPTE 274M */
+#define         V4L2_DV_720P60          8 /* SMPTE 274M/296M */
+#define         V4L2_DV_1080I29_97      9 /* BT.1120/ SMPTE 274M */
+#define         V4L2_DV_1080I30         10 /* BT.1120/ SMPTE 274M */
+#define         V4L2_DV_1080I25         11 /* BT.1120 */
+#define         V4L2_DV_1080I50         12 /* SMPTE 296M */
+#define         V4L2_DV_1080I60         13 /* SMPTE 296M */
+#define         V4L2_DV_1080P24         14 /* SMPTE 296M */
+#define         V4L2_DV_1080P25         15 /* SMPTE 296M */
+#define         V4L2_DV_1080P30         16 /* SMPTE 296M */
+#define         V4L2_DV_1080P50         17 /* BT.1120 */
+#define         V4L2_DV_1080P60         18 /* BT.1120 */
+
+/*
+ *      D V     B T     T I M I N G S
+ */
+
+/* BT.656/BT.1120 timing data */
+struct <link linkend="v4l2-bt-timings">v4l2_bt_timings</link> {
+        __u32   width;          /* width in pixels */
+        __u32   height;         /* height in lines */
+        __u32   interlaced;     /* Interlaced or progressive */
+        __u32   polarities;     /* Positive or negative polarity */
+        __u64   pixelclock;     /* Pixel clock in HZ. Ex. 74.25MHz-&gt;74250000 */
+        __u32   hfrontporch;    /* Horizpontal front porch in pixels */
+        __u32   hsync;          /* Horizontal Sync length in pixels */
+        __u32   hbackporch;     /* Horizontal back porch in pixels */
+        __u32   vfrontporch;    /* Vertical front porch in pixels */
+        __u32   vsync;          /* Vertical Sync length in lines */
+        __u32   vbackporch;     /* Vertical back porch in lines */
+        __u32   il_vfrontporch; /* Vertical front porch for bottom field of
+                                 * interlaced field formats
+                                 */
+        __u32   il_vsync;       /* Vertical sync length for bottom field of
+                                 * interlaced field formats
+                                 */
+        __u32   il_vbackporch;  /* Vertical back porch for bottom field of
+                                 * interlaced field formats
+                                 */
+        __u32   reserved[16];
+} __attribute__ ((packed));
+
+/* Interlaced or progressive format */
+#define V4L2_DV_PROGRESSIVE     0
+#define V4L2_DV_INTERLACED      1
+
+/* Polarities. If bit is not set, it is assumed to be negative polarity */
+#define V4L2_DV_VSYNC_POS_POL   0x00000001
+#define V4L2_DV_HSYNC_POS_POL   0x00000002
+
+
+/* DV timings */
+struct <link linkend="v4l2-dv-timings">v4l2_dv_timings</link> {
+        __u32 type;
+        union {
+                struct <link linkend="v4l2-bt-timings">v4l2_bt_timings</link>  bt;
+                __u32   reserved[32];
+        };
+} __attribute__ ((packed));
+
+/* Values for the type field */
+#define V4L2_DV_BT_656_1120     0       /* BT.656/1120 timing type */
+
 /*
  *      V I D E O   I N P U T S
  */
@@ -744,7 +837,8 @@ struct <link linkend="v4l2-input">v4l2_input</link> {
         __u32        tuner;             /*  Associated tuner */
         v4l2_std_id  std;
         __u32        status;
-        __u32        reserved[4];
+        __u32        capabilities;
+        __u32        reserved[3];
 };
 
 /*  Values for the 'type' field */
@@ -775,6 +869,11 @@ struct <link linkend="v4l2-input">v4l2_input</link> {
 #define V4L2_IN_ST_NO_ACCESS   0x02000000  /* Conditional access denied */
 #define V4L2_IN_ST_VTR         0x04000000  /* VTR time constant */
 
+/* capabilities flags */
+#define V4L2_IN_CAP_PRESETS             0x00000001 /* Supports S_DV_PRESET */
+#define V4L2_IN_CAP_CUSTOM_TIMINGS      0x00000002 /* Supports S_DV_TIMINGS */
+#define V4L2_IN_CAP_STD                 0x00000004 /* Supports S_STD */
+
 /*
  *      V I D E O   O U T P U T S
  */
@@ -785,13 +884,19 @@ struct <link linkend="v4l2-output">v4l2_output</link> {
         __u32        audioset;          /*  Associated audios (bitfield) */
         __u32        modulator;         /*  Associated modulator */
         v4l2_std_id  std;
-        __u32        reserved[4];
+        __u32        capabilities;
+        __u32        reserved[3];
 };
 /*  Values for the 'type' field */
 #define V4L2_OUTPUT_TYPE_MODULATOR              1
 #define V4L2_OUTPUT_TYPE_ANALOG                 2
 #define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY       3
 
+/* capabilities flags */
+#define V4L2_OUT_CAP_PRESETS            0x00000001 /* Supports S_DV_PRESET */
+#define V4L2_OUT_CAP_CUSTOM_TIMINGS     0x00000002 /* Supports S_DV_TIMINGS */
+#define V4L2_OUT_CAP_STD                0x00000004 /* Supports S_STD */
+
 /*
  *      C O N T R O L S
  */
@@ -1626,6 +1731,13 @@ struct <link linkend="v4l2-dbg-chip-ident">v4l2_dbg_chip_ident</link> {
 #endif
 
 #define VIDIOC_S_HW_FREQ_SEEK    _IOW('V', 82, struct <link linkend="v4l2-hw-freq-seek">v4l2_hw_freq_seek</link>)
+#define VIDIOC_ENUM_DV_PRESETS  _IOWR('V', 83, struct <link linkend="v4l2-dv-enum-preset">v4l2_dv_enum_preset</link>)
+#define VIDIOC_S_DV_PRESET      _IOWR('V', 84, struct <link linkend="v4l2-dv-preset">v4l2_dv_preset</link>)
+#define VIDIOC_G_DV_PRESET      _IOWR('V', 85, struct <link linkend="v4l2-dv-preset">v4l2_dv_preset</link>)
+#define VIDIOC_QUERY_DV_PRESET  _IOR('V',  86, struct <link linkend="v4l2-dv-preset">v4l2_dv_preset</link>)
+#define VIDIOC_S_DV_TIMINGS     _IOWR('V', 87, struct <link linkend="v4l2-dv-timings">v4l2_dv_timings</link>)
+#define VIDIOC_G_DV_TIMINGS     _IOWR('V', 88, struct <link linkend="v4l2-dv-timings">v4l2_dv_timings</link>)
+
 /* Reminder: when adding new ioctls please add support for them to
    drivers/media/video/v4l2-compat-ioctl32.c as well! */
 
diff --git a/Documentation/DocBook/v4l/vidioc-enum-dv-presets.xml b/Documentation/DocBook/v4l/vidioc-enum-dv-presets.xml
new file mode 100644 (file)
index 0000000..1d31427
--- /dev/null
@@ -0,0 +1,238 @@
+<refentry id="vidioc-enum-dv-presets">
+  <refmeta>
+    <refentrytitle>ioctl VIDIOC_ENUM_DV_PRESETS</refentrytitle>
+    &manvol;
+  </refmeta>
+
+  <refnamediv>
+    <refname>VIDIOC_ENUM_DV_PRESETS</refname>
+    <refpurpose>Enumerate supported Digital Video presets</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcprototype>
+       <funcdef>int <function>ioctl</function></funcdef>
+       <paramdef>int <parameter>fd</parameter></paramdef>
+       <paramdef>int <parameter>request</parameter></paramdef>
+       <paramdef>struct v4l2_dv_enum_preset *<parameter>argp</parameter></paramdef>
+      </funcprototype>
+    </funcsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Arguments</title>
+
+    <variablelist>
+      <varlistentry>
+       <term><parameter>fd</parameter></term>
+       <listitem>
+         <para>&fd;</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>request</parameter></term>
+       <listitem>
+         <para>VIDIOC_ENUM_DV_PRESETS</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>argp</parameter></term>
+       <listitem>
+         <para></para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para>To query the attributes of a DV preset, applications initialize the
+<structfield>index</structfield> field and zero the reserved array of &v4l2-dv-enum-preset;
+and call the <constant>VIDIOC_ENUM_DV_PRESETS</constant> ioctl with a pointer to this
+structure. Drivers fill the rest of the structure or return an
+&EINVAL; when the index is out of bounds. To enumerate all DV Presets supported,
+applications shall begin at index zero, incrementing by one until the
+driver returns <errorcode>EINVAL</errorcode>. Drivers may enumerate a
+different set of DV presets after switching the video input or
+output.</para>
+
+    <table pgwide="1" frame="none" id="v4l2-dv-enum-preset">
+      <title>struct <structname>v4l2_dv_enum_presets</structname></title>
+      <tgroup cols="3">
+       &cs-str;
+       <tbody valign="top">
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>index</structfield></entry>
+           <entry>Number of the DV preset, set by the
+application.</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>preset</structfield></entry>
+           <entry>This field identifies one of the DV preset values listed in <xref linkend="v4l2-dv-presets-vals"/>.</entry>
+         </row>
+         <row>
+           <entry>__u8</entry>
+           <entry><structfield>name</structfield>[24]</entry>
+           <entry>Name of the preset, a NUL-terminated ASCII string, for example: "720P-60", "1080I-60". This information is
+intended for the user.</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>width</structfield></entry>
+           <entry>Width of the active video in pixels for the DV preset.</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>height</structfield></entry>
+           <entry>Height of the active video in lines for the DV preset.</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>reserved</structfield>[4]</entry>
+           <entry>Reserved for future extensions. Drivers must set the array to zero.</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+
+    <table pgwide="1" frame="none" id="v4l2-dv-presets-vals">
+      <title>struct <structname>DV Presets</structname></title>
+      <tgroup cols="3">
+       &cs-str;
+       <tbody valign="top">
+         <row>
+           <entry>Preset</entry>
+           <entry>Preset value</entry>
+           <entry>Description</entry>
+         </row>
+         <row>
+           <entry></entry>
+           <entry></entry>
+           <entry></entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_INVALID</entry>
+           <entry>0</entry>
+           <entry>Invalid preset value.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_480P59_94</entry>
+           <entry>1</entry>
+           <entry>720x480 progressive video at 59.94 fps as per BT.1362.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_576P50</entry>
+           <entry>2</entry>
+           <entry>720x576 progressive video at 50 fps as per BT.1362.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_720P24</entry>
+           <entry>3</entry>
+           <entry>1280x720 progressive video at 24 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_720P25</entry>
+           <entry>4</entry>
+           <entry>1280x720 progressive video at 25 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_720P30</entry>
+           <entry>5</entry>
+           <entry>1280x720 progressive video at 30 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_720P50</entry>
+           <entry>6</entry>
+           <entry>1280x720 progressive video at 50 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_720P59_94</entry>
+           <entry>7</entry>
+           <entry>1280x720 progressive video at 59.94 fps as per SMPTE 274M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_720P60</entry>
+           <entry>8</entry>
+           <entry>1280x720 progressive video at 60 fps as per SMPTE 274M/296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080I29_97</entry>
+           <entry>9</entry>
+           <entry>1920x1080 interlaced video at 29.97 fps as per BT.1120/SMPTE 274M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080I30</entry>
+           <entry>10</entry>
+           <entry>1920x1080 interlaced video at 30 fps as per BT.1120/SMPTE 274M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080I25</entry>
+           <entry>11</entry>
+           <entry>1920x1080 interlaced video at 25 fps as per BT.1120.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080I50</entry>
+           <entry>12</entry>
+           <entry>1920x1080 interlaced video at 50 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080I60</entry>
+           <entry>13</entry>
+           <entry>1920x1080 interlaced video at 60 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080P24</entry>
+           <entry>14</entry>
+           <entry>1920x1080 progressive video at 24 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080P25</entry>
+           <entry>15</entry>
+           <entry>1920x1080 progressive video at 25 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080P30</entry>
+           <entry>16</entry>
+           <entry>1920x1080 progressive video at 30 fps as per SMPTE 296M.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080P50</entry>
+           <entry>17</entry>
+           <entry>1920x1080 progressive video at 50 fps as per BT.1120.</entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_1080P60</entry>
+           <entry>18</entry>
+           <entry>1920x1080 progressive video at 60 fps as per BT.1120.</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+  </refsect1>
+
+  <refsect1>
+    &return-value;
+
+    <variablelist>
+      <varlistentry>
+       <term><errorcode>EINVAL</errorcode></term>
+       <listitem>
+         <para>The &v4l2-dv-enum-preset; <structfield>index</structfield>
+is out of bounds.</para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+</refentry>
+
+<!--
+Local Variables:
+mode: sgml
+sgml-parent-document: "v4l2.sgml"
+indent-tabs-mode: nil
+End:
+-->
index 414856b824730ec83a348e9187c896c2a617987e..71b868e2fb8fd5eb36de50f6f9c397844aafdea2 100644 (file)
@@ -124,7 +124,13 @@ current input.</entry>
          </row>
          <row>
            <entry>__u32</entry>
-           <entry><structfield>reserved</structfield>[4]</entry>
+           <entry><structfield>capabilities</structfield></entry>
+           <entry>This field provides capabilities for the
+input. See <xref linkend="input-capabilities" /> for flags.</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>reserved</structfield>[3]</entry>
            <entry>Reserved for future extensions. Drivers must set
 the array to zero.</entry>
          </row>
@@ -261,6 +267,34 @@ flag is set Macrovision has been detected.</entry>
        </tbody>
       </tgroup>
     </table>
+
+    <!-- Capability flags based on video timings RFC by Muralidharan
+Karicheri, titled RFC (v1.2): V4L - Support for video timings at the
+input/output interface to linux-media@vger.kernel.org on 19 Oct 2009.
+       -->
+    <table frame="none" pgwide="1" id="input-capabilities">
+      <title>Input capabilities</title>
+      <tgroup cols="3">
+       &cs-def;
+       <tbody valign="top">
+         <row>
+           <entry><constant>V4L2_IN_CAP_PRESETS</constant></entry>
+           <entry>0x00000001</entry>
+           <entry>This input supports setting DV presets by using VIDIOC_S_DV_PRESET.</entry>
+         </row>
+         <row>
+           <entry><constant>V4L2_OUT_CAP_CUSTOM_TIMINGS</constant></entry>
+           <entry>0x00000002</entry>
+           <entry>This input supports setting custom video timings by using VIDIOC_S_DV_TIMINGS.</entry>
+         </row>
+         <row>
+           <entry><constant>V4L2_IN_CAP_STD</constant></entry>
+           <entry>0x00000004</entry>
+           <entry>This input supports setting the TV standard by using VIDIOC_S_STD.</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
   </refsect1>
 
   <refsect1>
index e8d16dcd50cf0e293cc73c607cad9653db807f36..a281d26a195fbb501fcd96059080b8965ff7a69f 100644 (file)
@@ -114,7 +114,13 @@ details on video standards and how to switch see <xref
          </row>
          <row>
            <entry>__u32</entry>
-           <entry><structfield>reserved</structfield>[4]</entry>
+           <entry><structfield>capabilities</structfield></entry>
+           <entry>This field provides capabilities for the
+output. See <xref linkend="output-capabilities" /> for flags.</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>reserved</structfield>[3]</entry>
            <entry>Reserved for future extensions. Drivers must set
 the array to zero.</entry>
          </row>
@@ -147,6 +153,34 @@ CVBS, S-Video, RGB.</entry>
       </tgroup>
     </table>
 
+    <!-- Capabilities flags based on video timings RFC by Muralidharan
+Karicheri, titled RFC (v1.2): V4L - Support for video timings at the
+input/output interface to linux-media@vger.kernel.org on 19 Oct 2009.
+       -->
+    <table frame="none" pgwide="1" id="output-capabilities">
+      <title>Output capabilities</title>
+      <tgroup cols="3">
+       &cs-def;
+       <tbody valign="top">
+         <row>
+           <entry><constant>V4L2_OUT_CAP_PRESETS</constant></entry>
+           <entry>0x00000001</entry>
+           <entry>This output supports setting DV presets by using VIDIOC_S_DV_PRESET.</entry>
+         </row>
+         <row>
+           <entry><constant>V4L2_OUT_CAP_CUSTOM_TIMINGS</constant></entry>
+           <entry>0x00000002</entry>
+           <entry>This output supports setting custom video timings by using VIDIOC_S_DV_TIMINGS.</entry>
+         </row>
+         <row>
+           <entry><constant>V4L2_OUT_CAP_STD</constant></entry>
+           <entry>0x00000004</entry>
+           <entry>This output supports setting the TV standard by using VIDIOC_S_STD.</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+
   </refsect1>
   <refsect1>
     &return-value;
diff --git a/Documentation/DocBook/v4l/vidioc-g-dv-preset.xml b/Documentation/DocBook/v4l/vidioc-g-dv-preset.xml
new file mode 100644 (file)
index 0000000..3c6784e
--- /dev/null
@@ -0,0 +1,111 @@
+<refentry id="vidioc-g-dv-preset">
+  <refmeta>
+    <refentrytitle>ioctl VIDIOC_G_DV_PRESET, VIDIOC_S_DV_PRESET</refentrytitle>
+    &manvol;
+  </refmeta>
+
+  <refnamediv>
+    <refname>VIDIOC_G_DV_PRESET</refname>
+    <refname>VIDIOC_S_DV_PRESET</refname>
+    <refpurpose>Query or select the DV preset of the current input or output</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcprototype>
+       <funcdef>int <function>ioctl</function></funcdef>
+       <paramdef>int <parameter>fd</parameter></paramdef>
+       <paramdef>int <parameter>request</parameter></paramdef>
+       <paramdef>&v4l2-dv-preset;
+*<parameter>argp</parameter></paramdef>
+      </funcprototype>
+    </funcsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Arguments</title>
+
+    <variablelist>
+      <varlistentry>
+       <term><parameter>fd</parameter></term>
+       <listitem>
+         <para>&fd;</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>request</parameter></term>
+       <listitem>
+         <para>VIDIOC_G_DV_PRESET, VIDIOC_S_DV_PRESET</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>argp</parameter></term>
+       <listitem>
+         <para></para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>Description</title>
+    <para>To query and select the current DV preset, applications
+use the <constant>VIDIOC_G_DV_PRESET</constant> and <constant>VIDIOC_S_DV_PRESET</constant>
+ioctls which take a pointer to a &v4l2-dv-preset; type as argument.
+Applications must zero the reserved array in &v4l2-dv-preset;.
+<constant>VIDIOC_G_DV_PRESET</constant> returns a dv preset in the field
+<structfield>preset</structfield> of &v4l2-dv-preset;.</para>
+
+    <para><constant>VIDIOC_S_DV_PRESET</constant> accepts a pointer to a &v4l2-dv-preset;
+that has the preset value to be set. Applications must zero the reserved array in &v4l2-dv-preset;.
+If the preset is not supported, it returns an &EINVAL; </para>
+  </refsect1>
+
+  <refsect1>
+    &return-value;
+
+    <variablelist>
+      <varlistentry>
+       <term><errorcode>EINVAL</errorcode></term>
+       <listitem>
+         <para>This ioctl is not supported, or the
+<constant>VIDIOC_S_DV_PRESET</constant>,<constant>VIDIOC_S_DV_PRESET</constant> parameter was unsuitable.</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><errorcode>EBUSY</errorcode></term>
+       <listitem>
+         <para>The device is busy and therefore can not change the preset.</para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <table pgwide="1" frame="none" id="v4l2-dv-preset">
+      <title>struct <structname>v4l2_dv_preset</structname></title>
+      <tgroup cols="3">
+       &cs-str;
+       <tbody valign="top">
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>preset</structfield></entry>
+           <entry>Preset value to represent the digital video timings</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>reserved[4]</structfield></entry>
+           <entry>Reserved fields for future use</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+
+  </refsect1>
+</refentry>
+
+<!--
+Local Variables:
+mode: sgml
+sgml-parent-document: "v4l2.sgml"
+indent-tabs-mode: nil
+End:
+-->
diff --git a/Documentation/DocBook/v4l/vidioc-g-dv-timings.xml b/Documentation/DocBook/v4l/vidioc-g-dv-timings.xml
new file mode 100644 (file)
index 0000000..ecc1957
--- /dev/null
@@ -0,0 +1,224 @@
+<refentry id="vidioc-g-dv-timings">
+  <refmeta>
+    <refentrytitle>ioctl VIDIOC_G_DV_TIMINGS, VIDIOC_S_DV_TIMINGS</refentrytitle>
+    &manvol;
+  </refmeta>
+
+  <refnamediv>
+    <refname>VIDIOC_G_DV_TIMINGS</refname>
+    <refname>VIDIOC_S_DV_TIMINGS</refname>
+    <refpurpose>Get or set custom DV timings for input or output</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcprototype>
+       <funcdef>int <function>ioctl</function></funcdef>
+       <paramdef>int <parameter>fd</parameter></paramdef>
+       <paramdef>int <parameter>request</parameter></paramdef>
+       <paramdef>&v4l2-dv-timings;
+*<parameter>argp</parameter></paramdef>
+      </funcprototype>
+    </funcsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Arguments</title>
+
+    <variablelist>
+      <varlistentry>
+       <term><parameter>fd</parameter></term>
+       <listitem>
+         <para>&fd;</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>request</parameter></term>
+       <listitem>
+         <para>VIDIOC_G_DV_TIMINGS, VIDIOC_S_DV_TIMINGS</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>argp</parameter></term>
+       <listitem>
+         <para></para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>Description</title>
+    <para>To set custom DV timings for the input or output, applications use the
+<constant>VIDIOC_S_DV_TIMINGS</constant> ioctl and to get the current custom timings,
+applications use the <constant>VIDIOC_G_DV_TIMINGS</constant> ioctl. The detailed timing
+information is filled in using the structure &v4l2-dv-timings;. These ioctls take
+a pointer to the &v4l2-dv-timings; structure as argument. If the ioctl is not supported
+or the timing values are not correct, the driver returns &EINVAL;.</para>
+  </refsect1>
+
+  <refsect1>
+    &return-value;
+
+    <variablelist>
+      <varlistentry>
+       <term><errorcode>EINVAL</errorcode></term>
+       <listitem>
+         <para>This ioctl is not supported, or the
+<constant>VIDIOC_S_DV_TIMINGS</constant> parameter was unsuitable.</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><errorcode>EBUSY</errorcode></term>
+       <listitem>
+         <para>The device is busy and therefore can not change the timings.</para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+
+    <table pgwide="1" frame="none" id="v4l2-bt-timings">
+      <title>struct <structname>v4l2_bt_timings</structname></title>
+      <tgroup cols="3">
+       &cs-str;
+       <tbody valign="top">
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>width</structfield></entry>
+           <entry>Width of the active video in pixels</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>height</structfield></entry>
+           <entry>Height of the active video in lines</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>interlaced</structfield></entry>
+           <entry>Progressive (0) or interlaced (1)</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>polarities</structfield></entry>
+           <entry>This is a bit mask that defines polarities of sync signals.
+bit 0 (V4L2_DV_VSYNC_POS_POL) is for vertical sync polarity and bit 1 (V4L2_DV_HSYNC_POS_POL) is for horizontal sync polarity. If the bit is set
+(1) it is positive polarity and if is cleared (0), it is negative polarity.</entry>
+         </row>
+         <row>
+           <entry>__u64</entry>
+           <entry><structfield>pixelclock</structfield></entry>
+           <entry>Pixel clock in Hz. Ex. 74.25MHz->74250000</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>hfrontporch</structfield></entry>
+           <entry>Horizontal front porch in pixels</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>hsync</structfield></entry>
+           <entry>Horizontal sync length in pixels</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>hbackporch</structfield></entry>
+           <entry>Horizontal back porch in pixels</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>vfrontporch</structfield></entry>
+           <entry>Vertical front porch in lines</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>vsync</structfield></entry>
+           <entry>Vertical sync length in lines</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>vbackporch</structfield></entry>
+           <entry>Vertical back porch in lines</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>il_vfrontporch</structfield></entry>
+           <entry>Vertical front porch in lines for bottom field of interlaced field formats</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>il_vsync</structfield></entry>
+           <entry>Vertical sync length in lines for bottom field of interlaced field formats</entry>
+         </row>
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>il_vbackporch</structfield></entry>
+           <entry>Vertical back porch in lines for bottom field of interlaced field formats</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+
+    <table pgwide="1" frame="none" id="v4l2-dv-timings">
+      <title>struct <structname>v4l2_dv_timings</structname></title>
+      <tgroup cols="4">
+       &cs-str;
+       <tbody valign="top">
+         <row>
+           <entry>__u32</entry>
+           <entry><structfield>type</structfield></entry>
+           <entry></entry>
+           <entry>Type of DV timings as listed in <xref linkend="dv-timing-types"/>.</entry>
+         </row>
+         <row>
+           <entry>union</entry>
+           <entry><structfield></structfield></entry>
+           <entry></entry>
+         </row>
+         <row>
+           <entry></entry>
+           <entry>&v4l2-bt-timings;</entry>
+           <entry><structfield>bt</structfield></entry>
+           <entry>Timings defined by BT.656/1120 specifications</entry>
+         </row>
+         <row>
+           <entry></entry>
+           <entry>__u32</entry>
+           <entry><structfield>reserved</structfield>[32]</entry>
+           <entry></entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+
+    <table pgwide="1" frame="none" id="dv-timing-types">
+      <title>DV Timing types</title>
+      <tgroup cols="3">
+       &cs-str;
+       <tbody valign="top">
+         <row>
+           <entry>Timing type</entry>
+           <entry>value</entry>
+           <entry>Description</entry>
+         </row>
+         <row>
+           <entry></entry>
+           <entry></entry>
+           <entry></entry>
+         </row>
+         <row>
+           <entry>V4L2_DV_BT_656_1120</entry>
+           <entry>0</entry>
+           <entry>BT.656/1120 timings</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
+  </refsect1>
+</refentry>
+
+<!--
+Local Variables:
+mode: sgml
+sgml-parent-document: "v4l2.sgml"
+indent-tabs-mode: nil
+End:
+-->
index b6f5d267e85612ed0d7e0aa575b2f1390eb795d1..912f8513e5daeb5ef0fe2a91876ae49af19f5a79 100644 (file)
@@ -86,6 +86,12 @@ standards.</para>
 <constant>VIDIOC_S_STD</constant> parameter was unsuitable.</para>
        </listitem>
       </varlistentry>
+      <varlistentry>
+       <term><errorcode>EBUSY</errorcode></term>
+       <listitem>
+         <para>The device is busy and therefore can not change the standard</para>
+       </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 </refentry>
diff --git a/Documentation/DocBook/v4l/vidioc-query-dv-preset.xml b/Documentation/DocBook/v4l/vidioc-query-dv-preset.xml
new file mode 100644 (file)
index 0000000..87e4f0f
--- /dev/null
@@ -0,0 +1,85 @@
+<refentry id="vidioc-query-dv-preset">
+  <refmeta>
+    <refentrytitle>ioctl VIDIOC_QUERY_DV_PRESET</refentrytitle>
+    &manvol;
+  </refmeta>
+
+  <refnamediv>
+    <refname>VIDIOC_QUERY_DV_PRESET</refname>
+    <refpurpose>Sense the DV preset received by the current
+input</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcprototype>
+       <funcdef>int <function>ioctl</function></funcdef>
+       <paramdef>int <parameter>fd</parameter></paramdef>
+       <paramdef>int <parameter>request</parameter></paramdef>
+       <paramdef>&v4l2-dv-preset; *<parameter>argp</parameter></paramdef>
+      </funcprototype>
+    </funcsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Arguments</title>
+
+    <variablelist>
+       <varlistentry>
+       <term><parameter>fd</parameter></term>
+       <listitem>
+         <para>&fd;</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>request</parameter></term>
+       <listitem>
+         <para>VIDIOC_QUERY_DV_PRESET</para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><parameter>argp</parameter></term>
+       <listitem>
+         <para></para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para>The hardware may be able to detect the current DV preset
+automatically, similar to sensing the video standard. To do so, applications
+call <constant> VIDIOC_QUERY_DV_PRESET</constant> with a pointer to a
+&v4l2-dv-preset; type. Once the hardware detects a preset, that preset is
+returned in the preset field of &v4l2-dv-preset;. When detection is not
+possible or fails, the value V4L2_DV_INVALID is returned.</para>
+  </refsect1>
+
+  <refsect1>
+    &return-value;
+    <variablelist>
+      <varlistentry>
+       <term><errorcode>EINVAL</errorcode></term>
+       <listitem>
+         <para>This ioctl is not supported.</para>
+       </listitem>
+    </varlistentry>
+      <varlistentry>
+       <term><errorcode>EBUSY</errorcode></term>
+       <listitem>
+         <para>The device is busy and therefore can not sense the preset</para>
+       </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+</refentry>
+
+<!--
+Local Variables:
+mode: sgml
+sgml-parent-document: "v4l2.sgml"
+indent-tabs-mode: nil
+End:
+-->
index b5a7ff934486523e8989a1e7c4c0eebb0f578bcd..1a9e60393091e0519ecd1a53848b2d1ad872b359 100644 (file)
@@ -70,6 +70,12 @@ current video input or output.</para>
          <para>This ioctl is not supported.</para>
        </listitem>
       </varlistentry>
+      <varlistentry>
+       <term><errorcode>EBUSY</errorcode></term>
+       <listitem>
+         <para>The device is busy and therefore can not detect the standard</para>
+       </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 </refentry>
index 78a9168ff37784ff9692e18a241d930b268f543d..1053a56be3b180c8ce202380ed9e882b5d97914a 100644 (file)
@@ -15,7 +15,7 @@ kernel patches.
 2: Passes allnoconfig, allmodconfig
 
 3: Builds on multiple CPU architectures by using local cross-compile tools
-   or something like PLM at OSDL.
+   or some other build farm.
 
 4: ppc64 is a good architecture for cross-compilation checking because it
    tends to use `unsigned long' for 64-bit quantities.
@@ -88,3 +88,6 @@ kernel patches.
 
 24: All memory barriers {e.g., barrier(), rmb(), wmb()} need a comment in the
     source code that explains the logic of what they are doing and why.
+
+25: If any ioctl's are added by the patch, then also update
+    Documentation/ioctl/ioctl-number.txt.
diff --git a/Documentation/acpi/method-customizing.txt b/Documentation/acpi/method-customizing.txt
new file mode 100644 (file)
index 0000000..e628cd2
--- /dev/null
@@ -0,0 +1,66 @@
+Linux ACPI Custom Control Method How To
+=======================================
+
+Written by Zhang Rui <rui.zhang@intel.com>
+
+
+Linux supports customizing ACPI control methods at runtime.
+
+Users can use this to
+1. override an existing method which may not work correctly,
+   or just for debugging purposes.
+2. insert a completely new method in order to create a missing
+   method such as _OFF, _ON, _STA, _INI, etc.
+For these cases, it is far simpler to dynamically install a single
+control method rather than override the entire DSDT, because kernel
+rebuild/reboot is not needed and test result can be got in minutes.
+
+Note: Only ACPI METHOD can be overridden, any other object types like
+      "Device", "OperationRegion", are not recognized.
+Note: The same ACPI control method can be overridden for many times,
+      and it's always the latest one that used by Linux/kernel.
+
+1. override an existing method
+   a) get the ACPI table via ACPI sysfs I/F. e.g. to get the DSDT,
+      just run "cat /sys/firmware/acpi/tables/DSDT > /tmp/dsdt.dat"
+   b) disassemble the table by running "iasl -d dsdt.dat".
+   c) rewrite the ASL code of the method and save it in a new file,
+   d) package the new file (psr.asl) to an ACPI table format.
+      Here is an example of a customized \_SB._AC._PSR method,
+
+      DefinitionBlock ("", "SSDT", 1, "", "", 0x20080715)
+      {
+       External (ACON)
+
+       Method (\_SB_.AC._PSR, 0, NotSerialized)
+       {
+               Store ("In AC _PSR", Debug)
+               Return (ACON)
+       }
+      }
+      Note that the full pathname of the method in ACPI namespace
+      should be used.
+      And remember to use "External" to declare external objects.
+   e) assemble the file to generate the AML code of the method.
+      e.g. "iasl psr.asl" (psr.aml is generated as a result)
+   f) mount debugfs by "mount -t debugfs none /sys/kernel/debug"
+   g) override the old method via the debugfs by running
+      "cat /tmp/psr.aml > /sys/kernel/debug/acpi/custom_method"
+
+2. insert a new method
+   This is easier than overriding an existing method.
+   We just need to create the ASL code of the method we want to
+   insert and then follow the step c) ~ g) in section 1.
+
+3. undo your changes
+   The "undo" operation is not supported for a new inserted method
+   right now, i.e. we can not remove a method currently.
+   For an overrided method, in order to undo your changes, please
+   save a copy of the method original ASL code in step c) section 1,
+   and redo step c) ~ g) to override the method with the original one.
+
+
+Note: We can use a kernel with multiple custom ACPI method running,
+      But each individual write to debugfs can implement a SINGLE
+      method override. i.e. if we want to insert/override multiple
+      ACPI methods, we need to redo step c) ~ g) for multiple times.
index d6840a91e1e19e4816325dd532e6fd310f0a7b8e..c34e12440fec39f6191418877ba13085b5b3edb1 100644 (file)
@@ -1,9 +1,6 @@
 00-INDEX
        - This file
 
-cache-lock.txt
-       - HOWTO for blackfin cache locking.
-
 cachefeatures.txt
        - Supported cache features.
 
diff --git a/Documentation/blackfin/Makefile b/Documentation/blackfin/Makefile
new file mode 100644 (file)
index 0000000..773dbb1
--- /dev/null
@@ -0,0 +1,6 @@
+obj-m := gptimers-example.o
+
+all: modules
+
+modules clean:
+       $(MAKE) -C ../.. SUBDIRS=$(PWD) $@
diff --git a/Documentation/blackfin/cache-lock.txt b/Documentation/blackfin/cache-lock.txt
deleted file mode 100644 (file)
index 88ba1e6..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * File:         Documentation/blackfin/cache-lock.txt
- * Based on:
- * Author:
- *
- * Created:
- * Description:  This file contains the simple DMA Implementation for Blackfin
- *
- * Rev:          $Id: cache-lock.txt 2384 2006-11-01 04:12:43Z magicyang $
- *
- * Modified:
- *               Copyright 2004-2006 Analog Devices Inc.
- *
- * Bugs:         Enter bugs at http://blackfin.uclinux.org/
- *
- */
-
-How to lock your code in cache in uClinux/blackfin
---------------------------------------------------
-
-There are only a few steps required to lock your code into the cache.
-Currently you can lock the code by Way.
-
-Below are the interface provided for locking the cache.
-
-
-1. cache_grab_lock(int Ways);
-
-This function grab the lock for locking your code into the cache specified
-by Ways.
-
-
-2. cache_lock(int Ways);
-
-This function should be called after your critical code has been executed.
-Once the critical code exits, the code is now loaded into the cache. This
-function locks the code into the cache.
-
-
-So, the example sequence will be:
-
-       cache_grab_lock(WAY0_L);        /* Grab the lock */
-
-       critical_code();                /* Execute the code of interest */
-
-       cache_lock(WAY0_L);             /* Lock the cache */
-
-Where WAY0_L signifies WAY0 locking.
index 0fbec23becb5b0903b90e7bbeed62e30af3809ca..75de51f945152af580d0a84b0bcf2163af95abce 100644 (file)
                icplb_flush();
                dcplb_flush();
 
-       - Locking the cache.
-
-               cache_grab_lock();
-               cache_lock();
-
-       Please refer linux-2.6.x/Documentation/blackfin/cache-lock.txt for how to
-       lock the cache.
-
-       Locking the cache is optional feature.
-
        - Miscellaneous cache functions.
 
                flush_cache_all();
diff --git a/Documentation/blackfin/gptimers-example.c b/Documentation/blackfin/gptimers-example.c
new file mode 100644 (file)
index 0000000..b1bd634
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Simple gptimers example
+ *     http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gptimers
+ *
+ * Copyright 2007-2009 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/module.h>
+
+#include <asm/gptimers.h>
+#include <asm/portmux.h>
+
+/* ... random driver includes ... */
+
+#define DRIVER_NAME "gptimer_example"
+
+struct gptimer_data {
+       uint32_t period, width;
+};
+static struct gptimer_data data;
+
+/* ... random driver state ... */
+
+static irqreturn_t gptimer_example_irq(int irq, void *dev_id)
+{
+       struct gptimer_data *data = dev_id;
+
+       /* make sure it was our timer which caused the interrupt */
+       if (!get_gptimer_intr(TIMER5_id))
+               return IRQ_NONE;
+
+       /* read the width/period values that were captured for the waveform */
+       data->width = get_gptimer_pwidth(TIMER5_id);
+       data->period = get_gptimer_period(TIMER5_id);
+
+       /* acknowledge the interrupt */
+       clear_gptimer_intr(TIMER5_id);
+
+       /* tell the upper layers we took care of things */
+       return IRQ_HANDLED;
+}
+
+/* ... random driver code ... */
+
+static int __init gptimer_example_init(void)
+{
+       int ret;
+
+       /* grab the peripheral pins */
+       ret = peripheral_request(P_TMR5, DRIVER_NAME);
+       if (ret) {
+               printk(KERN_NOTICE DRIVER_NAME ": peripheral request failed\n");
+               return ret;
+       }
+
+       /* grab the IRQ for the timer */
+       ret = request_irq(IRQ_TIMER5, gptimer_example_irq, IRQF_SHARED, DRIVER_NAME, &data);
+       if (ret) {
+               printk(KERN_NOTICE DRIVER_NAME ": IRQ request failed\n");
+               peripheral_free(P_TMR5);
+               return ret;
+       }
+
+       /* setup the timer and enable it */
+       set_gptimer_config(TIMER5_id, WDTH_CAP | PULSE_HI | PERIOD_CNT | IRQ_ENA);
+       enable_gptimers(TIMER5bit);
+
+       return 0;
+}
+module_init(gptimer_example_init);
+
+static void __exit gptimer_example_exit(void)
+{
+       disable_gptimers(TIMER5bit);
+       free_irq(IRQ_TIMER5, &data);
+       peripheral_free(P_TMR5);
+}
+module_exit(gptimer_example_exit);
+
+MODULE_LICENSE("BSD");
index 961a0513f8c34a4328313094b7d6fff179f17e32..a406286f6f3e64e5d2cf043be83dd2e206e28633 100644 (file)
@@ -1,7 +1,5 @@
 00-INDEX
        - This file
-as-iosched.txt
-       - Anticipatory IO scheduler
 barrier.txt
        - I/O Barriers
 biodoc.txt
diff --git a/Documentation/block/as-iosched.txt b/Documentation/block/as-iosched.txt
deleted file mode 100644 (file)
index 738b72b..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-Anticipatory IO scheduler
--------------------------
-Nick Piggin <piggin@cyberone.com.au>    13 Sep 2003
-
-Attention! Database servers, especially those using "TCQ" disks should
-investigate performance with the 'deadline' IO scheduler. Any system with high
-disk performance requirements should do so, in fact.
-
-If you see unusual performance characteristics of your disk systems, or you
-see big performance regressions versus the deadline scheduler, please email
-me. Database users don't bother unless you're willing to test a lot of patches
-from me ;) its a known issue.
-
-Also, users with hardware RAID controllers, doing striping, may find
-highly variable performance results with using the as-iosched. The
-as-iosched anticipatory implementation is based on the notion that a disk
-device has only one physical seeking head.  A striped RAID controller
-actually has a head for each physical device in the logical RAID device.
-
-However, setting the antic_expire (see tunable parameters below) produces
-very similar behavior to the deadline IO scheduler.
-
-Selecting IO schedulers
------------------------
-Refer to Documentation/block/switching-sched.txt for information on
-selecting an io scheduler on a per-device basis.
-
-Anticipatory IO scheduler Policies
-----------------------------------
-The as-iosched implementation implements several layers of policies
-to determine when an IO request is dispatched to the disk controller.
-Here are the policies outlined, in order of application.
-
-1. one-way Elevator algorithm.
-
-The elevator algorithm is similar to that used in deadline scheduler, with
-the addition that it allows limited backward movement of the elevator
-(i.e. seeks backwards).  A seek backwards can occur when choosing between
-two IO requests where one is behind the elevator's current position, and
-the other is in front of the elevator's position. If the seek distance to
-the request in back of the elevator is less than half the seek distance to
-the request in front of the elevator, then the request in back can be chosen.
-Backward seeks are also limited to a maximum of MAXBACK (1024*1024) sectors.
-This favors forward movement of the elevator, while allowing opportunistic
-"short" backward seeks.
-
-2. FIFO expiration times for reads and for writes.
-
-This is again very similar to the deadline IO scheduler.  The expiration
-times for requests on these lists is tunable using the parameters read_expire
-and write_expire discussed below.  When a read or a write expires in this way,
-the IO scheduler will interrupt its current elevator sweep or read anticipation
-to service the expired request.
-
-3. Read and write request batching
-
-A batch is a collection of read requests or a collection of write
-requests.  The as scheduler alternates dispatching read and write batches
-to the driver.  In the case a read batch, the scheduler submits read
-requests to the driver as long as there are read requests to submit, and
-the read batch time limit has not been exceeded (read_batch_expire).
-The read batch time limit begins counting down only when there are
-competing write requests pending.
-
-In the case of a write batch, the scheduler submits write requests to
-the driver as long as there are write requests available, and the
-write batch time limit has not been exceeded (write_batch_expire).
-However, the length of write batches will be gradually shortened
-when read batches frequently exceed their time limit.
-
-When changing between batch types, the scheduler waits for all requests
-from the previous batch to complete before scheduling requests for the
-next batch.
-
-The read and write fifo expiration times described in policy 2 above
-are checked only when in scheduling IO of a batch for the corresponding
-(read/write) type.  So for example, the read FIFO timeout values are
-tested only during read batches.  Likewise, the write FIFO timeout
-values are tested only during write batches.  For this reason,
-it is generally not recommended for the read batch time
-to be longer than the write expiration time, nor for the write batch
-time to exceed the read expiration time (see tunable parameters below).
-
-When the IO scheduler changes from a read to a write batch,
-it begins the elevator from the request that is on the head of the
-write expiration FIFO.  Likewise, when changing from a write batch to
-a read batch, scheduler begins the elevator from the first entry
-on the read expiration FIFO.
-
-4. Read anticipation.
-
-Read anticipation occurs only when scheduling a read batch.
-This implementation of read anticipation allows only one read request
-to be dispatched to the disk controller at a time.  In
-contrast, many write requests may be dispatched to the disk controller
-at a time during a write batch.  It is this characteristic that can make
-the anticipatory scheduler perform anomalously with controllers supporting
-TCQ, or with hardware striped RAID devices. Setting the antic_expire
-queue parameter (see below) to zero disables this behavior, and the 
-anticipatory scheduler behaves essentially like the deadline scheduler.
-
-When read anticipation is enabled (antic_expire is not zero), reads
-are dispatched to the disk controller one at a time.
-At the end of each read request, the IO scheduler examines its next
-candidate read request from its sorted read list.  If that next request
-is from the same process as the request that just completed,
-or if the next request in the queue is "very close" to the
-just completed request, it is dispatched immediately.  Otherwise,
-statistics (average think time, average seek distance) on the process
-that submitted the just completed request are examined.  If it seems
-likely that that process will submit another request soon, and that
-request is likely to be near the just completed request, then the IO
-scheduler will stop dispatching more read requests for up to (antic_expire)
-milliseconds, hoping that process will submit a new request near the one
-that just completed.  If such a request is made, then it is dispatched
-immediately.  If the antic_expire wait time expires, then the IO scheduler
-will dispatch the next read request from the sorted read queue.
-
-To decide whether an anticipatory wait is worthwhile, the scheduler
-maintains statistics for each process that can be used to compute
-mean "think time" (the time between read requests), and mean seek
-distance for that process.  One observation is that these statistics
-are associated with each process, but those statistics are not associated
-with a specific IO device.  So for example, if a process is doing IO
-on several file systems on separate devices, the statistics will be
-a combination of IO behavior from all those devices.
-
-
-Tuning the anticipatory IO scheduler
-------------------------------------
-When using 'as', the anticipatory IO scheduler there are 5 parameters under
-/sys/block/*/queue/iosched/. All are units of milliseconds.
-
-The parameters are:
-* read_expire
-    Controls how long until a read request becomes "expired". It also controls the
-    interval between which expired requests are served, so set to 50, a request
-    might take anywhere < 100ms to be serviced _if_ it is the next on the
-    expired list. Obviously request expiration strategies won't make the disk
-    go faster. The result basically equates to the timeslice a single reader
-    gets in the presence of other IO. 100*((seek time / read_expire) + 1) is
-    very roughly the % streaming read efficiency your disk should get with
-    multiple readers.
-
-* read_batch_expire
-    Controls how much time a batch of reads is given before pending writes are
-    served. A higher value is more efficient. This might be set below read_expire
-    if writes are to be given higher priority than reads, but reads are to be
-    as efficient as possible when there are no writes. Generally though, it
-    should be some multiple of read_expire.
-
-* write_expire, and
-* write_batch_expire are equivalent to the above, for writes.
-
-* antic_expire
-    Controls the maximum amount of time we can anticipate a good read (one
-    with a short seek distance from the most recently completed request) before
-    giving up. Many other factors may cause anticipation to be stopped early,
-    or some processes will not be "anticipated" at all. Should be a bit higher
-    for big seek time devices though not a linear correspondence - most
-    processes have only a few ms thinktime.
-
-In addition to the tunables above there is a read-only file named est_time
-which, when read, will show:
-
-    - The probability of a task exiting without a cooperating task
-      submitting an anticipated IO.
-
-    - The current mean think time.
-
-    - The seek distance used to determine if an incoming IO is better.
-
index 4d4a644b505eeb42cb5acae0b69f162c3f053a4d..a99d7031cdf978f321dce744a3a1f22d0bf7206e 100644 (file)
@@ -315,41 +315,26 @@ A: The following are what is required for CPU hotplug infrastructure to work
 
 Q: I need to ensure that a particular cpu is not removed when there is some
    work specific to this cpu is in progress.
-A: First switch the current thread context to preferred cpu
+A: There are two ways.  If your code can be run in interrupt context, use
+   smp_call_function_single(), otherwise use work_on_cpu().  Note that
+   work_on_cpu() is slow, and can fail due to out of memory:
 
        int my_func_on_cpu(int cpu)
        {
-               cpumask_t saved_mask, new_mask = CPU_MASK_NONE;
-               int curr_cpu, err = 0;
-
-               saved_mask = current->cpus_allowed;
-               cpu_set(cpu, new_mask);
-               err = set_cpus_allowed(current, new_mask);
-
-               if (err)
-                       return err;
-
-               /*
-                * If we got scheduled out just after the return from
-                * set_cpus_allowed() before running the work, this ensures
-                * we stay locked.
-                */
-               curr_cpu = get_cpu();
-
-               if (curr_cpu != cpu) {
-                       err = -EAGAIN;
-                       goto ret;
-               } else {
-                       /*
-                        * Do work : But cant sleep, since get_cpu() disables preempt
-                        */
-               }
-               ret:
-                       put_cpu();
-                       set_cpus_allowed(current, saved_mask);
-                       return err;
-               }
-
+               int err;
+               get_online_cpus();
+               if (!cpu_online(cpu))
+                       err = -EINVAL;
+               else
+#if NEEDS_BLOCKING
+                       err = work_on_cpu(cpu, __my_func_on_cpu, NULL);
+#else
+                       smp_call_function_single(cpu, __my_func_on_cpu, &err,
+                                                true);
+#endif
+               put_online_cpus();
+               return err;
+       }
 
 Q: How do we determine how many CPUs are available for hotplug.
 A: There is no clear spec defined way from ACPI that can give us that
index a5009c8300f3364a98e8982c9697f1dee789346f..e3a77b215135eeef2350fc0471dfe8633184384e 100644 (file)
@@ -8,13 +8,19 @@ the block device which are also writable without interfering with the
 original content;
 *) To create device "forks", i.e. multiple different versions of the
 same data stream.
+*) To merge a snapshot of a block device back into the snapshot's origin
+device.
 
+In the first two cases, dm copies only the chunks of data that get
+changed and uses a separate copy-on-write (COW) block device for
+storage.
 
-In both cases, dm copies only the chunks of data that get changed and
-uses a separate copy-on-write (COW) block device for storage.
+For snapshot merge the contents of the COW storage are merged back into
+the origin device.
 
 
-There are two dm targets available: snapshot and snapshot-origin.
+There are three dm targets available:
+snapshot, snapshot-origin, and snapshot-merge.
 
 *) snapshot-origin <origin>
 
@@ -40,8 +46,25 @@ The difference is that for transient snapshots less metadata must be
 saved on disk - they can be kept in memory by the kernel.
 
 
-How this is used by LVM2
-========================
+* snapshot-merge <origin> <COW device> <persistent> <chunksize>
+
+takes the same table arguments as the snapshot target except it only
+works with persistent snapshots.  This target assumes the role of the
+"snapshot-origin" target and must not be loaded if the "snapshot-origin"
+is still present for <origin>.
+
+Creates a merging snapshot that takes control of the changed chunks
+stored in the <COW device> of an existing snapshot, through a handover
+procedure, and merges these chunks back into the <origin>.  Once merging
+has started (in the background) the <origin> may be opened and the merge
+will continue while I/O is flowing to it.  Changes to the <origin> are
+deferred until the merging snapshot's corresponding chunk(s) have been
+merged.  Once merging has started the snapshot device, associated with
+the "snapshot" target, will return -EIO when accessed.
+
+
+How snapshot is used by LVM2
+============================
 When you create the first LVM2 snapshot of a volume, four dm devices are used:
 
 1) a device containing the original mapping table of the source volume;
@@ -72,3 +95,30 @@ brw-------  1 root root 254, 12 29 ago 18:15 /dev/mapper/volumeGroup-snap-cow
 brw-------  1 root root 254, 13 29 ago 18:15 /dev/mapper/volumeGroup-snap
 brw-------  1 root root 254, 10 29 ago 18:14 /dev/mapper/volumeGroup-base
 
+
+How snapshot-merge is used by LVM2
+==================================
+A merging snapshot assumes the role of the "snapshot-origin" while
+merging.  As such the "snapshot-origin" is replaced with
+"snapshot-merge".  The "-real" device is not changed and the "-cow"
+device is renamed to <origin name>-cow to aid LVM2's cleanup of the
+merging snapshot after it completes.  The "snapshot" that hands over its
+COW device to the "snapshot-merge" is deactivated (unless using lvchange
+--refresh); but if it is left active it will simply return I/O errors.
+
+A snapshot will merge into its origin with the following command:
+
+lvconvert --merge volumeGroup/snap
+
+we'll now have this situation:
+
+# dmsetup table|grep volumeGroup
+
+volumeGroup-base-real: 0 2097152 linear 8:19 384
+volumeGroup-base-cow: 0 204800 linear 8:19 2097536
+volumeGroup-base: 0 2097152 snapshot-merge 254:11 254:12 P 16
+
+# ls -lL /dev/mapper/volumeGroup-*
+brw-------  1 root root 254, 11 29 ago 18:15 /dev/mapper/volumeGroup-base-real
+brw-------  1 root root 254, 12 29 ago 18:16 /dev/mapper/volumeGroup-base-cow
+brw-------  1 root root 254, 10 29 ago 18:16 /dev/mapper/volumeGroup-base
index e151b2a36267c17fdb7da317e309bea3de408a4b..3ad6acead94950a3b83e4f14912e01cc64973b6b 100644 (file)
@@ -103,6 +103,7 @@ gconf
 gen-devlist
 gen_crc32table
 gen_init_cpio
+generated
 genheaders
 genksyms
 *_gray256.c
index 60120fb3b9618181a9e58f855cdef3ecdc5d0649..d2cd6fb8ba9efc649eb14cf4af8805ba762f0fe8 100644 (file)
@@ -226,5 +226,5 @@ struct driver_attribute driver_attr_debug;
 This can then be used to add and remove the attribute from the
 driver's directory using:
 
-int driver_create_file(struct device_driver *, struct driver_attribute *);
-void driver_remove_file(struct device_driver *, struct driver_attribute *);
+int driver_create_file(struct device_driver *, const struct driver_attribute *);
+void driver_remove_file(struct device_driver *, const struct driver_attribute *);
index 67dbf442b0b6c6ce8a2a04a19c2b92946512619c..f3e046a6a987a685910bafc171c2cc9cf243df1b 100644 (file)
@@ -7,7 +7,7 @@
     VIA UniChrome Family(CLE266, PM800 / CN400 / CN300,
                         P4M800CE / P4M800Pro / CN700 / VN800,
                         CX700 / VX700, K8M890, P4M890,
-                        CN896 / P4M900, VX800)
+                        CN896 / P4M900, VX800, VX855)
 
 [Driver features]
 ------------------------
         0 : No Dual Edge Panel (default)
         1 : Dual Edge Panel
 
-    viafb_video_dev:
-        This option is used to specify video output devices(CRT, DVI, LCD) for
-        duoview case.
-        For example:
-        To output video on DVI, we should use:
-            modprobe viafb viafb_video_dev=DVI...
-
     viafb_lcd_port:
         This option is used to specify LCD output port,
         available values are "DVP0" "DVP1" "DFP_HIGHLOW" "DFP_HIGH" "DFP_LOW".
@@ -181,9 +174,6 @@ Notes:
        and bpp, need to call VIAFB specified ioctl interface VIAFB_SET_DEVICE
        instead of calling common ioctl function FBIOPUT_VSCREENINFO since
        viafb doesn't support multi-head well, or it will cause screen crush.
-    4. VX800 2D accelerator hasn't been supported in this driver yet. When
-       using driver on VX800, the driver will disable the acceleration
-       function as default.
 
 
 [Configure viafb with "fbset" tool]
index eb2c138c277c45ec66b25116cbd744d42c41878f..870d190fe6178676067b4f2adadbfd07b56beacb 100644 (file)
@@ -291,15 +291,6 @@ Who:       Michael Buesch <mb@bu3sch.de>
 
 ---------------------------
 
-What: print_fn_descriptor_symbol()
-When: October 2009
-Why:  The %pF vsprintf format provides the same functionality in a
-      simpler way.  print_fn_descriptor_symbol() is deprecated but
-      still present to give out-of-tree modules time to change.
-Who:  Bjorn Helgaas <bjorn.helgaas@hp.com>
-
----------------------------
-
 What:  /sys/o2cb symlink
 When:  January 2010
 Why:   /sys/fs/o2cb is the proper location for this information - /sys/o2cb
@@ -483,3 +474,22 @@ Why:       Obsoleted by the adt7475 driver.
 Who:   Jean Delvare <khali@linux-fr.org>
 
 ---------------------------
+What:  Support for lcd_switch and display_get in asus-laptop driver
+When:  March 2010
+Why:   These two features use non-standard interfaces. There are the
+       only features that really need multiple path to guess what's
+       the right method name on a specific laptop.
+
+       Removing them will allow to remove a lot of code an significantly
+       clean the drivers.
+
+       This will affect the backlight code which won't be able to know
+       if the backlight is on or off. The platform display file will also be
+       write only (like the one in eeepc-laptop).
+
+       This should'nt affect a lot of user because they usually know
+       when their display is on or off.
+
+Who:   Corentin Chary <corentin.chary@gmail.com>
+
+----------------------------
index 7001782ab932dbc3a8b5a16b8188c8a2605d84d3..875d49696b6e6acf4386b8a1b71e797d3944da39 100644 (file)
@@ -1,7 +1,5 @@
 00-INDEX
        - this file (info on some of the filesystems supported by linux).
-Exporting
-       - explanation of how to make filesystems exportable.
 Locking
        - info on locking rules as they pertain to Linux VFS.
 9p.txt
@@ -68,12 +66,8 @@ mandatory-locking.txt
        - info on the Linux implementation of Sys V mandatory file locking.
 ncpfs.txt
        - info on Novell Netware(tm) filesystem using NCP protocol.
-nfs41-server.txt
-       - info on the Linux server implementation of NFSv4 minor version 1.
-nfs-rdma.txt
-       - how to install and setup the Linux NFS/RDMA client and server software.
-nfsroot.txt
-       - short guide on setting up a diskless box with NFS root filesystem.
+nfs/
+       - nfs-related documentation.
 nilfs2.txt
        - info and mount options for the NILFS2 filesystem.
 ntfs.txt
@@ -92,8 +86,6 @@ relay.txt
        - info on relay, for efficient streaming from kernel to user space.
 romfs.txt
        - description of the ROMFS filesystem.
-rpc-cache.txt
-       - introduction to the caching mechanisms in the sunrpc layer.
 seq_file.txt
        - how to use the seq_file API
 sharedsubtree.txt
index af6885c3c821f621f5827a46cb0728c61a9e768c..e1def1786e5074e5d8f3cf89b5f14cbfc9fab4af 100644 (file)
@@ -196,7 +196,7 @@ nobarrier           This also requires an IO stack which can support
                        also be used to enable or disable barriers, for
                        consistency with other ext4 mount options.
 
-inode_readahead=n      This tuning parameter controls the maximum
+inode_readahead_blks=n This tuning parameter controls the maximum
                        number of inode table blocks that ext4's inode
                        table readahead algorithm will pre-read into
                        the buffer cache.  The default value is 32 blocks.
diff --git a/Documentation/filesystems/nfs/00-INDEX b/Documentation/filesystems/nfs/00-INDEX
new file mode 100644 (file)
index 0000000..2f68cd6
--- /dev/null
@@ -0,0 +1,16 @@
+00-INDEX
+       - this file (nfs-related documentation).
+Exporting
+       - explanation of how to make filesystems exportable.
+knfsd-stats.txt
+       - statistics which the NFS server makes available to user space.
+nfs.txt
+       - nfs client, and DNS resolution for fs_locations.
+nfs41-server.txt
+       - info on the Linux server implementation of NFSv4 minor version 1.
+nfs-rdma.txt
+       - how to install and setup the Linux NFS/RDMA client and server software
+nfsroot.txt
+       - short guide on setting up a diskless box with NFS root filesystem.
+rpc-cache.txt
+       - introduction to the caching mechanisms in the sunrpc layer.
similarity index 96%
rename from Documentation/filesystems/nfs41-server.txt
rename to Documentation/filesystems/nfs/nfs41-server.txt
index 5920fe26e6ff5cb006372571b1f1da5a80cd526e..1bd0d0c05171efed3c12863300a71e3bc4f36bd8 100644 (file)
@@ -41,7 +41,7 @@ interoperability problems with future clients.  Known issues:
          conformant with the spec (for example, we don't use kerberos
          on the backchannel correctly).
        - no trunking support: no clients currently take advantage of
-         trunking, but this is a mandatory failure, and its use is
+         trunking, but this is a mandatory feature, and its use is
          recommended to clients in a number of places.  (E.g. to ensure
          timely renewal in case an existing connection's retry timeouts
          have gotten too long; see section 8.3 of the draft.)
@@ -213,3 +213,10 @@ The following cases aren't supported yet:
   DESTROY_CLIENTID, DESTROY_SESSION, EXCHANGE_ID.
 * DESTROY_SESSION MUST be the final operation in the COMPOUND request.
 
+Nonstandard compound limitations:
+* No support for a sessions fore channel RPC compound that requires both a
+  ca_maxrequestsize request and a ca_maxresponsesize reply, so we may
+  fail to live up to the promise we made in CREATE_SESSION fore channel
+  negotiation.
+* No more than one IO operation (read, write, readdir) allowed per
+  compound.
index 92b888d540a667c17a630e8dc005cd672c726058..a7e9746ee7ea44934c017b4c2a26ef6df9361db8 100644 (file)
@@ -140,7 +140,7 @@ Callers of notify_change() need ->i_mutex now.
 New super_block field "struct export_operations *s_export_op" for
 explicit support for exporting, e.g. via NFS.  The structure is fully
 documented at its declaration in include/linux/fs.h, and in
-Documentation/filesystems/Exporting.
+Documentation/filesystems/nfs/Exporting.
 
 Briefly it allows for the definition of decode_fh and encode_fh operations
 to encode and decode filehandles, and allows the filesystem to use
index 94b9f2056f4cf97fcddcad5c79f1130a95abe6b9..220cc6376ef80e0c9bcfec162d45552e729cdf5a 100644 (file)
@@ -38,6 +38,7 @@ Table of Contents
   3.3  /proc/<pid>/io - Display the IO accounting fields
   3.4  /proc/<pid>/coredump_filter - Core dump filtering settings
   3.5  /proc/<pid>/mountinfo - Information about mounts
+  3.6  /proc/<pid>/comm  & /proc/<pid>/task/<tid>/comm
 
 
 ------------------------------------------------------------------------------
@@ -1409,3 +1410,11 @@ For more information on mount propagation see:
 
   Documentation/filesystems/sharedsubtree.txt
 
+
+3.6    /proc/<pid>/comm  & /proc/<pid>/task/<tid>/comm
+--------------------------------------------------------
+These files provide a method to access a tasks comm value. It also allows for
+a task to set its own or one of its thread siblings comm value. The comm value
+is limited in size compared to the cmdline value, so writing anything longer
+then the kernel's TASK_COMM_LEN (currently 16 chars) will result in a truncated
+comm value.
index 0d15ebccf5b037a6590ee8ab9c616172d28cdf82..a1e2e0dda9074d1d8a3102df3488a8a5f29cfb17 100644 (file)
@@ -248,9 +248,7 @@ code, that is done in the initialization code in the usual way:
        {
                struct proc_dir_entry *entry;
 
-               entry = create_proc_entry("sequence", 0, NULL);
-               if (entry)
-                       entry->proc_fops = &ct_file_ops;
+               proc_create("sequence", 0, NULL, &ct_file_ops);
                return 0;
        }
 
index b245d524d5682afe30a194821ab62e619092ff3c..931c806642c5939a61c5f6ad01c7b9fedbd4a0a9 100644 (file)
@@ -91,8 +91,8 @@ struct device_attribute {
                         const char *buf, size_t count);
 };
 
-int device_create_file(struct device *, struct device_attribute *);
-void device_remove_file(struct device *, struct device_attribute *);
+int device_create_file(struct device *, const struct device_attribute *);
+void device_remove_file(struct device *, const struct device_attribute *);
 
 It also defines this helper for defining device attributes: 
 
@@ -316,8 +316,8 @@ DEVICE_ATTR(_name, _mode, _show, _store);
 
 Creation/Removal:
 
-int device_create_file(struct device *device, struct device_attribute * attr);
-void device_remove_file(struct device * dev, struct device_attribute * attr);
+int device_create_file(struct device *dev, const struct device_attribute * attr);
+void device_remove_file(struct device *dev, const struct device_attribute * attr);
 
 
 - bus drivers (include/linux/device.h)
@@ -358,7 +358,7 @@ DRIVER_ATTR(_name, _mode, _show, _store)
 
 Creation/Removal:
 
-int driver_create_file(struct device_driver *, struct driver_attribute *);
-void driver_remove_file(struct device_driver *, struct driver_attribute *);
+int driver_create_file(struct device_driver *, const struct driver_attribute *);
+void driver_remove_file(struct device_driver *, const struct driver_attribute *);
 
 
index e4e7daed2ba88dc2dbf7d0bf9c9eb16037e3e6c7..1866c27eec693e7e88f7420e3ac895079cba02d9 100644 (file)
@@ -531,6 +531,13 @@ and have the following read/write attributes:
                This file exists only if the pin can be configured as an
                interrupt generating input pin.
 
+       "active_low" ... reads as either 0 (false) or 1 (true).  Write
+               any nonzero value to invert the value attribute both
+               for reading and writing.  Existing and subsequent
+               poll(2) support configuration via the edge attribute
+               for "rising" and "falling" edges will follow this
+               setting.
+
 GPIO controllers have paths like /sys/class/gpio/gpiochip42/ (for the
 controller implementing GPIOs starting at #42) and have the following
 read-only attributes:
@@ -566,6 +573,8 @@ requested using gpio_request():
        int gpio_export_link(struct device *dev, const char *name,
                unsigned gpio)
 
+       /* change the polarity of a GPIO node in sysfs */
+       int gpio_sysfs_set_active_low(unsigned gpio, int value);
 
 After a kernel driver requests a GPIO, it may only be made available in
 the sysfs interface by gpio_export().  The driver can control whether the
@@ -580,3 +589,9 @@ After the GPIO has been exported, gpio_export_link() allows creating
 symlinks from elsewhere in sysfs to the GPIO sysfs node.  Drivers can
 use this to provide the interface under their own device in sysfs with
 a descriptive name.
+
+Drivers can use gpio_sysfs_set_active_low() to hide GPIO line polarity
+differences between boards from user space.  This only affects the
+sysfs interface.  Polarity change can be done both before and after
+gpio_export(), and previously enabled poll(2) support for either
+rising or falling edge will be reconfigured to follow this setting.
diff --git a/Documentation/hwmon/k10temp b/Documentation/hwmon/k10temp
new file mode 100644 (file)
index 0000000..a7a18d4
--- /dev/null
@@ -0,0 +1,60 @@
+Kernel driver k10temp
+=====================
+
+Supported chips:
+* AMD Family 10h processors:
+  Socket F: Quad-Core/Six-Core/Embedded Opteron
+  Socket AM2+: Opteron, Phenom (II) X3/X4
+  Socket AM3: Quad-Core Opteron, Athlon/Phenom II X2/X3/X4, Sempron II
+  Socket S1G3: Athlon II, Sempron, Turion II
+* AMD Family 11h processors:
+  Socket S1G2: Athlon (X2), Sempron (X2), Turion X2 (Ultra)
+
+  Prefix: 'k10temp'
+  Addresses scanned: PCI space
+  Datasheets:
+  BIOS and Kernel Developer's Guide (BKDG) For AMD Family 10h Processors:
+    http://support.amd.com/us/Processor_TechDocs/31116.pdf
+  BIOS and Kernel Developer's Guide (BKDG) for AMD Family 11h Processors:
+    http://support.amd.com/us/Processor_TechDocs/41256.pdf
+  Revision Guide for AMD Family 10h Processors:
+    http://support.amd.com/us/Processor_TechDocs/41322.pdf
+  Revision Guide for AMD Family 11h Processors:
+    http://support.amd.com/us/Processor_TechDocs/41788.pdf
+  AMD Family 11h Processor Power and Thermal Data Sheet for Notebooks:
+    http://support.amd.com/us/Processor_TechDocs/43373.pdf
+  AMD Family 10h Server and Workstation Processor Power and Thermal Data Sheet:
+    http://support.amd.com/us/Processor_TechDocs/43374.pdf
+  AMD Family 10h Desktop Processor Power and Thermal Data Sheet:
+    http://support.amd.com/us/Processor_TechDocs/43375.pdf
+
+Author: Clemens Ladisch <clemens@ladisch.de>
+
+Description
+-----------
+
+This driver permits reading of the internal temperature sensor of AMD
+Family 10h and 11h processors.
+
+All these processors have a sensor, but on older revisions of Family 10h
+processors, the sensor may return inconsistent values (erratum 319). The
+driver will refuse to load on these revisions unless you specify the
+"force=1" module parameter.
+
+There is one temperature measurement value, available as temp1_input in
+sysfs. It is measured in degrees Celsius with a resolution of 1/8th degree.
+Please note that it is defined as a relative value; to quote the AMD manual:
+
+  Tctl is the processor temperature control value, used by the platform to
+  control cooling systems. Tctl is a non-physical temperature on an
+  arbitrary scale measured in degrees. It does _not_ represent an actual
+  physical temperature like die or case temperature. Instead, it specifies
+  the processor temperature relative to the point at which the system must
+  supply the maximum cooling for the processor's specified maximum case
+  temperature and maximum thermal power dissipation.
+
+The maximum value for Tctl is available in the file temp1_max.
+
+If the BIOS has enabled hardware temperature control, the threshold at
+which the processor will throttle itself to avoid damage is available in
+temp1_crit and temp1_crit_hyst.
index effe949a7282cccd600365bffe78dd70541b9aa3..06534f25e643e15be91bb9eda118898a3241e5ed 100644 (file)
@@ -3,7 +3,8 @@ Kernel driver lis3lv02d
 
 Supported chips:
 
-  * STMicroelectronics LIS3LV02DL and LIS3LV02DQ
+  * STMicroelectronics LIS3LV02DL, LIS3LV02DQ (12 bits precision)
+  * STMicroelectronics LIS302DL, LIS3L02DQ, LIS331DL (8 bits)
 
 Authors:
         Yan Burman <burman.yan@gmail.com>
@@ -13,32 +14,52 @@ Authors:
 Description
 -----------
 
-This driver provides support for the accelerometer found in various HP
-laptops sporting the feature officially called "HP Mobile Data
-Protection System 3D" or "HP 3D DriveGuard". It detects automatically
-laptops with this sensor. Known models (for now the HP 2133, nc6420,
-nc2510, nc8510, nc84x0, nw9440 and nx9420) will have their axis
-automatically oriented on standard way (eg: you can directly play
-neverball).  The accelerometer data is readable via
-/sys/devices/platform/lis3lv02d.
+This driver provides support for the accelerometer found in various HP laptops
+sporting the feature officially called "HP Mobile Data Protection System 3D" or
+"HP 3D DriveGuard". It detects automatically laptops with this sensor. Known
+models (full list can be found in drivers/hwmon/hp_accel.c) will have their
+axis automatically oriented on standard way (eg: you can directly play
+neverball). The accelerometer data is readable via
+/sys/devices/platform/lis3lv02d. Reported values are scaled
+to mg values (1/1000th of earth gravity).
 
 Sysfs attributes under /sys/devices/platform/lis3lv02d/:
 position - 3D position that the accelerometer reports. Format: "(x,y,z)"
-calibrate - read: values (x, y, z) that are used as the base for input
-                 class device operation.
-            write: forces the base to be recalibrated with the current
-                  position.
-rate - reports the sampling rate of the accelerometer device in HZ
+rate - read reports the sampling rate of the accelerometer device in HZ.
+       write changes sampling rate of the accelerometer device.
+       Only values which are supported by HW are accepted.
+selftest - performs selftest for the chip as specified by chip manufacturer.
 
 This driver also provides an absolute input class device, allowing
-the laptop to act as a pinball machine-esque joystick.
+the laptop to act as a pinball machine-esque joystick. Joystick device can be
+calibrated. Joystick device can be in two different modes.
+By default output values are scaled between -32768 .. 32767. In joystick raw
+mode, joystick and sysfs position entry have the same scale. There can be
+small difference due to input system fuzziness feature.
+Events are also available as input event device.
+
+Selftest is meant only for hardware diagnostic purposes. It is not meant to be
+used during normal operations. Position data is not corrupted during selftest
+but interrupt behaviour is not guaranteed to work reliably. In test mode, the
+sensing element is internally moved little bit. Selftest measures difference
+between normal mode and test mode. Chip specifications tell the acceptance
+limit for each type of the chip. Limits are provided via platform data
+to allow adjustment of the limits without a change to the actual driver.
+Seltest returns either "OK x y z" or "FAIL x y z" where x, y and z are
+measured difference between modes. Axes are not remapped in selftest mode.
+Measurement values are provided to help HW diagnostic applications to make
+final decision.
+
+On HP laptops, if the led infrastructure is activated, support for a led
+indicating disk protection will be provided as /sys/class/leds/hp::hddprotect.
 
 Another feature of the driver is misc device called "freefall" that
 acts similar to /dev/rtc and reacts on free-fall interrupts received
 from the device. It supports blocking operations, poll/select and
 fasync operation modes. You must read 1 bytes from the device.  The
 result is number of free-fall interrupts since the last successful
-read (or 255 if number of interrupts would not fit).
+read (or 255 if number of interrupts would not fit). See the hpfall.c
+file for an example on using the device.
 
 
 Axes orientation
@@ -55,7 +76,7 @@ the accelerometer are converted into a "standard" organisation of the axes
  * If the laptop is put upside-down, Z becomes negative
 
 If your laptop model is not recognized (cf "dmesg"), you can send an
-email to the authors to add it to the database.  When reporting a new
+email to the maintainer to add it to the database.  When reporting a new
 laptop, please include the output of "dmidecode" plus the value of
 /sys/devices/platform/lis3lv02d/position in these four cases.
 
index 02b74899edaf42e5c1a266399aeb51c890fc5c5c..b7e42ec4b26ba4465691710ba4071ebebb4f61b6 100644 (file)
@@ -81,8 +81,14 @@ pwm[1-4] - this file stores PWM duty cycle or DC value (fan speed) in range:
           0 (stop) to 255 (full)
 
 pwm[1-4]_enable - this file controls mode of fan/temperature control:
-       * 1 Manual Mode, write to pwm file any value 0-255 (full speed)
-       * 2 Thermal Cruise
+       * 1 Manual mode, write to pwm file any value 0-255 (full speed)
+       * 2 "Thermal Cruise" mode
+       * 3 "Fan Speed Cruise" mode
+       * 4 "Smart Fan III" mode
+
+pwm[1-4]_mode - controls if output is PWM or DC level
+        * 0 DC output (0 - 12v)
+        * 1 PWM output
 
 Thermal Cruise mode
 -------------------
index 7860aafb483dfba05aea315fce424ff6b6d936cb..0a74603eb671c84590b0a91976cc2ea3e0150728 100644 (file)
@@ -44,7 +44,7 @@ static struct i2c_driver foo_driver = {
        /* if device autodetection is needed: */
        .class          = I2C_CLASS_SOMETHING,
        .detect         = foo_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 
        .shutdown       = foo_shutdown, /* optional */
        .suspend        = foo_suspend,  /* optional */
index 6d40f00b358caa42a1d217fb7f6c6a185915ea86..64eeb55d0c09d05f6ec5788a150ddcf2119fdfd8 100644 (file)
@@ -36,11 +36,11 @@ Datagram vs Connected modes
   fabric with a 2K MTU, the IPoIB MTU will be 2048 - 4 = 2044 bytes.
 
   In connected mode, the IB RC (Reliable Connected) transport is used.
-  Connected mode is to takes advantage of the connected nature of the
-  IB transport and allows an MTU up to the maximal IP packet size of
-  64K, which reduces the number of IP packets needed for handling
-  large UDP datagrams, TCP segments, etc and increases the performance
-  for large messages.
+  Connected mode takes advantage of the connected nature of the IB
+  transport and allows an MTU up to the maximal IP packet size of 64K,
+  which reduces the number of IP packets needed for handling large UDP
+  datagrams, TCP segments, etc and increases the performance for large
+  messages.
 
   In connected mode, the interface's UD QP is still used for multicast
   and communication with peers that don't support connected mode. In
index bb3bf38f03dac1e055dc973ce65d49d14defbe42..6f8c1cabbc5d1fefe2a18d3c77354b54426d3363 100644 (file)
@@ -1,3 +1,17 @@
+Output files
+
+modules.order
+--------------------------------------------------
+This file records the order in which modules appear in Makefiles. This
+is used by modprobe to deterministically resolve aliases that match
+multiple modules.
+
+modules.builtin
+--------------------------------------------------
+This file lists all modules that are built into the kernel. This is used
+by modprobe to not fail when trying to load something builtin.
+
+
 Environment variables
 
 KCPPFLAGS
index 849b5e56d06fc95927f47aaa8b006cfb73cf34c6..49efae703979ca793383463bce7c2d1eda42468b 100644 (file)
@@ -103,10 +103,16 @@ KCONFIG_AUTOCONFIG
 This environment variable can be set to specify the path & name of the
 "auto.conf" file.  Its default value is "include/config/auto.conf".
 
+KCONFIG_TRISTATE
+--------------------------------------------------
+This environment variable can be set to specify the path & name of the
+"tristate.conf" file.  Its default value is "include/config/tristate.conf".
+
 KCONFIG_AUTOHEADER
 --------------------------------------------------
 This environment variable can be set to specify the path & name of the
-"autoconf.h" (header) file.  Its default value is "include/linux/autoconf.h".
+"autoconf.h" (header) file.
+Its default value is "include/generated/autoconf.h".
 
 
 ======================================================================
index ab95d3ada5c7f7210d2a13adc619ec3d4b9548bd..736d45602886ea7b08024f246f06e9c7c6dc1a05 100644 (file)
@@ -240,7 +240,7 @@ and is between 256 and 4096 characters. It is defined in the file
 
        acpi_sleep=     [HW,ACPI] Sleep options
                        Format: { s3_bios, s3_mode, s3_beep, s4_nohwsig,
-                                 old_ordering, s4_nonvs }
+                                 old_ordering, s4_nonvs, sci_force_enable }
                        See Documentation/power/video.txt for information on
                        s3_bios and s3_mode.
                        s3_beep is for debugging; it makes the PC's speaker beep
@@ -253,6 +253,9 @@ and is between 256 and 4096 characters. It is defined in the file
                        of _PTS is used by default).
                        s4_nonvs prevents the kernel from saving/restoring the
                        ACPI NVS memory during hibernation.
+                       sci_force_enable causes the kernel to set SCI_EN directly
+                       on resume from S1/S3 (which is against the ACPI spec,
+                       but some broken systems don't work without it).
 
        acpi_use_timer_override [HW,ACPI]
                        Use timer override. For some broken Nvidia NF5 boards
@@ -1032,7 +1035,7 @@ and is between 256 and 4096 characters. It is defined in the file
                        No delay
 
        ip=             [IP_PNP]
-                       See Documentation/filesystems/nfsroot.txt.
+                       See Documentation/filesystems/nfs/nfsroot.txt.
 
        ip2=            [HW] Set IO/IRQ pairs for up to 4 IntelliPort boards
                        See comment before ip2_setup() in
@@ -1553,10 +1556,10 @@ and is between 256 and 4096 characters. It is defined in the file
                        going to be removed in 2.6.29.
 
        nfsaddrs=       [NFS]
-                       See Documentation/filesystems/nfsroot.txt.
+                       See Documentation/filesystems/nfs/nfsroot.txt.
 
        nfsroot=        [NFS] nfs root filesystem for disk-less boxes.
-                       See Documentation/filesystems/nfsroot.txt.
+                       See Documentation/filesystems/nfs/nfsroot.txt.
 
        nfs.callback_tcpport=
                        [NFS] set the TCP port on which the NFSv4 callback
@@ -2729,6 +2732,11 @@ and is between 256 and 4096 characters. It is defined in the file
        vmpoff=         [KNL,S390] Perform z/VM CP command after power off.
                        Format: <command>
 
+       vt.cur_default= [VT] Default cursor shape.
+                       Format: 0xCCBBAA, where AA, BB, and CC are the same as
+                       the parameters of the <Esc>[?A;B;Cc escape sequence;
+                       see VGA-softcursor.txt. Default: 2 = underline.
+
        vt.default_blu= [VT]
                        Format: <blue0>,<blue1>,<blue2>,...,<blue15>
                        Change the default blue palette of the console.
index e1a114161027d6598234959e2605af08018f6fc6..2811e452f7566f5f5fe4fa6242f8724a9970ba11 100644 (file)
@@ -685,7 +685,7 @@ struct kvm_vcpu_events {
                __u8 pad;
        } nmi;
        __u32 sipi_vector;
-       __u32 flags;   /* must be zero */
+       __u32 flags;
 };
 
 4.30 KVM_SET_VCPU_EVENTS
@@ -701,6 +701,14 @@ vcpu.
 
 See KVM_GET_VCPU_EVENTS for the data structure.
 
+Fields that may be modified asynchronously by running VCPUs can be excluded
+from the update. These fields are nmi.pending and sipi_vector. Keep the
+corresponding bits in the flags field cleared to suppress overwriting the
+current in-kernel state. The bits are:
+
+KVM_VCPUEVENT_VALID_NMI_PENDING - transfer nmi.pending to the kernel
+KVM_VCPUEVENT_VALID_SIPI_VECTOR - transfer sipi_vector
+
 
 5. The kvm_run structure
 
index aafcaa6341915bb001c27d1bd05006add6606224..75afa1229fd7e72059ffce02b8c450192617e0c7 100644 (file)
@@ -1,7 +1,7 @@
                     ThinkPad ACPI Extras Driver
 
-                            Version 0.23
-                          April 10th, 2009
+                            Version 0.24
+                        December 11th,  2009
 
                Borislav Deianov <borislav@users.sf.net>
              Henrique de Moraes Holschuh <hmh@hmh.eng.br>
@@ -460,6 +460,8 @@ event       code    Key             Notes
                                For Lenovo ThinkPads with a new
                                BIOS, it has to be handled either
                                by the ACPI OSI, or by userspace.
+                               The driver does the right thing,
+                               never mess with this.
 0x1011 0x10    FN+END          Brightness down.  See brightness
                                up for details.
 
@@ -582,46 +584,15 @@ with hotkey_report_mode.
 
 Brightness hotkey notes:
 
-These are the current sane choices for brightness key mapping in
-thinkpad-acpi:
+Don't mess with the brightness hotkeys in a Thinkpad.  If you want
+notifications for OSD, use the sysfs backlight class event support.
 
-For IBM and Lenovo models *without* ACPI backlight control (the ones on
-which thinkpad-acpi will autoload its backlight interface by default,
-and on which ACPI video does not export a backlight interface):
-
-1. Don't enable or map the brightness hotkeys in thinkpad-acpi, as
-   these older firmware versions unfortunately won't respect the hotkey
-   mask for brightness keys anyway, and always reacts to them.  This
-   usually work fine, unless X.org drivers are doing something to block
-   the BIOS.  In that case, use (3) below.  This is the default mode of
-   operation.
-
-2. Enable the hotkeys, but map them to something else that is NOT
-   KEY_BRIGHTNESS_UP/DOWN or any other keycode that would cause
-   userspace to try to change the backlight level, and use that as an
-   on-screen-display hint.
-
-3. IF AND ONLY IF X.org drivers find a way to block the firmware from
-   automatically changing the brightness, enable the hotkeys and map
-   them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN, and feed that to
-   something that calls xbacklight.  thinkpad-acpi will not be able to
-   change brightness in that case either, so you should disable its
-   backlight interface.
-
-For Lenovo models *with* ACPI backlight control:
-
-1. Load up ACPI video and use that.  ACPI video will report ACPI
-   events for brightness change keys.  Do not mess with thinkpad-acpi
-   defaults in this case.  thinkpad-acpi should not have anything to do
-   with backlight events in a scenario where ACPI video is loaded:
-   brightness hotkeys must be disabled, and the backlight interface is
-   to be kept disabled as well.  This is the default mode of operation.
-
-2. Do *NOT* load up ACPI video, enable the hotkeys in thinkpad-acpi,
-   and map them to KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN.  Process
-   these keys on userspace somehow (e.g. by calling xbacklight).
-   The driver will do this automatically if it detects that ACPI video
-   has been disabled.
+The driver will issue KEY_BRIGHTNESS_UP and KEY_BRIGHTNESS_DOWN events
+automatically for the cases were userspace has to do something to
+implement brightness changes.  When you override these events, you will
+either fail to handle properly the ThinkPads that require explicit
+action to change backlight brightness, or the ThinkPads that require
+that no action be taken to work properly.
 
 
 Bluetooth
@@ -1121,25 +1092,103 @@ WARNING:
     its level up and down at every change.
 
 
-Volume control -- /proc/acpi/ibm/volume
----------------------------------------
+Volume control (Console Audio control)
+--------------------------------------
+
+procfs: /proc/acpi/ibm/volume
+ALSA: "ThinkPad Console Audio Control", default ID: "ThinkPadEC"
+
+NOTE: by default, the volume control interface operates in read-only
+mode, as it is supposed to be used for on-screen-display purposes.
+The read/write mode can be enabled through the use of the
+"volume_control=1" module parameter.
+
+NOTE: distros are urged to not enable volume_control by default, this
+should be done by the local admin only.  The ThinkPad UI is for the
+console audio control to be done through the volume keys only, and for
+the desktop environment to just provide on-screen-display feedback.
+Software volume control should be done only in the main AC97/HDA
+mixer.
+
+
+About the ThinkPad Console Audio control:
+
+ThinkPads have a built-in amplifier and muting circuit that drives the
+console headphone and speakers.  This circuit is after the main AC97
+or HDA mixer in the audio path, and under exclusive control of the
+firmware.
+
+ThinkPads have three special hotkeys to interact with the console
+audio control: volume up, volume down and mute.
+
+It is worth noting that the normal way the mute function works (on
+ThinkPads that do not have a "mute LED") is:
 
-This feature allows volume control on ThinkPad models which don't have
-a hardware volume knob. The available commands are:
+1. Press mute to mute.  It will *always* mute, you can press it as
+   many times as you want, and the sound will remain mute.
+
+2. Press either volume key to unmute the ThinkPad (it will _not_
+   change the volume, it will just unmute).
+
+This is a very superior design when compared to the cheap software-only
+mute-toggle solution found on normal consumer laptops:  you can be
+absolutely sure the ThinkPad will not make noise if you press the mute
+button, no matter the previous state.
+
+The IBM ThinkPads, and the earlier Lenovo ThinkPads have variable-gain
+amplifiers driving the speakers and headphone output, and the firmware
+also handles volume control for the headphone and speakers on these
+ThinkPads without any help from the operating system (this volume
+control stage exists after the main AC97 or HDA mixer in the audio
+path).
+
+The newer Lenovo models only have firmware mute control, and depend on
+the main HDA mixer to do volume control (which is done by the operating
+system).  In this case, the volume keys are filtered out for unmute
+key press (there are some firmware bugs in this area) and delivered as
+normal key presses to the operating system (thinkpad-acpi is not
+involved).
+
+
+The ThinkPad-ACPI volume control:
+
+The preferred way to interact with the Console Audio control is the
+ALSA interface.
+
+The legacy procfs interface allows one to read the current state,
+and if volume control is enabled, accepts the following commands:
 
        echo up   >/proc/acpi/ibm/volume
        echo down >/proc/acpi/ibm/volume
        echo mute >/proc/acpi/ibm/volume
+       echo unmute >/proc/acpi/ibm/volume
        echo 'level <level>' >/proc/acpi/ibm/volume
 
-The <level> number range is 0 to 15 although not all of them may be
-distinct. The unmute the volume after the mute command, use either the
-up or down command (the level command will not unmute the volume).
-The current volume level and mute state is shown in the file.
+The <level> number range is 0 to 14 although not all of them may be
+distinct. To unmute the volume after the mute command, use either the
+up or down command (the level command will not unmute the volume), or
+the unmute command.
+
+You can use the volume_capabilities parameter to tell the driver
+whether your thinkpad has volume control or mute-only control:
+volume_capabilities=1 for mixers with mute and volume control,
+volume_capabilities=2 for mixers with only mute control.
+
+If the driver misdetects the capabilities for your ThinkPad model,
+please report this to ibm-acpi-devel@lists.sourceforge.net, so that we
+can update the driver.
+
+There are two strategies for volume control.  To select which one
+should be used, use the volume_mode module parameter: volume_mode=1
+selects EC mode, and volume_mode=3 selects EC mode with NVRAM backing
+(so that volume/mute changes are remembered across shutdown/reboot).
 
-The ALSA mixer interface to this feature is still missing, but patches
-to add it exist.  That problem should be addressed in the not so
-distant future.
+The driver will operate in volume_mode=3 by default. If that does not
+work well on your ThinkPad model, please report this to
+ibm-acpi-devel@lists.sourceforge.net.
+
+The driver supports the standard ALSA module parameters.  If the ALSA
+mixer is disabled, the driver will disable all volume functionality.
 
 
 Fan control and monitoring: fan speed, fan enable/disable
@@ -1405,6 +1454,7 @@ to enable more than one output class, just add their values.
        0x0008                  HKEY event interface, hotkeys
        0x0010                  Fan control
        0x0020                  Backlight brightness
+       0x0040                  Audio mixer/volume control
 
 There is also a kernel build option to enable more debugging
 information, which may be necessary to debug driver problems.
@@ -1465,3 +1515,9 @@ Sysfs interface changelog:
                and it is always able to disable hot keys.  Very old
                thinkpads are properly supported.  hotkey_bios_mask
                is deprecated and marked for removal.
+
+0x020600:      Marker for backlight change event support.
+
+0x020700:      Support for mute-only mixers.
+               Volume control in read-only mode by default.
+               Marker for ALSA mixer support.
index bbc8a6a3692169a53aeb9ac1ab271018a53531d0..57e7e9cc1870ad095f7daa21ff051a68ec34d12c 100644 (file)
@@ -160,12 +160,15 @@ Under each section, you can see 4 files.
 NOTE:
   These directories/files appear after physical memory hotplug phase.
 
-If CONFIG_NUMA is enabled the
-/sys/devices/system/memory/memoryXXX memory section
-directories can also be accessed via symbolic links located in
-the /sys/devices/system/node/node* directories.  For example:
+If CONFIG_NUMA is enabled the memoryXXX/ directories can also be accessed
+via symbolic links located in the /sys/devices/system/node/node* directories.
+
+For example:
 /sys/devices/system/node/node0/memory9 -> ../../memory/memory9
 
+A backlink will also be created:
+/sys/devices/system/memory/memory9/node0 -> ../../node/node0
+
 --------------------------------
 4. Physical memory hot-add phase
 --------------------------------
diff --git a/Documentation/misc-devices/ad525x_dpot.txt b/Documentation/misc-devices/ad525x_dpot.txt
new file mode 100644 (file)
index 0000000..0c9413b
--- /dev/null
@@ -0,0 +1,57 @@
+---------------------------------
+  AD525x Digital Potentiometers
+---------------------------------
+
+The ad525x_dpot driver exports a simple sysfs interface.  This allows you to
+work with the immediate resistance settings as well as update the saved startup
+settings.  Access to the factory programmed tolerance is also provided, but
+interpretation of this settings is required by the end application according to
+the specific part in use.
+
+---------
+  Files
+---------
+
+Each dpot device will have a set of eeprom, rdac, and tolerance files.  How
+many depends on the actual part you have, as will the range of allowed values.
+
+The eeprom files are used to program the startup value of the device.
+
+The rdac files are used to program the immediate value of the device.
+
+The tolerance files are the read-only factory programmed tolerance settings
+and may vary greatly on a part-by-part basis.  For exact interpretation of
+this field, please consult the datasheet for your part.  This is presented
+as a hex file for easier parsing.
+
+-----------
+  Example
+-----------
+
+Locate the device in your sysfs tree.  This is probably easiest by going into
+the common i2c directory and locating the device by the i2c slave address.
+
+       # ls /sys/bus/i2c/devices/
+       0-0022  0-0027  0-002f
+
+So assuming the device in question is on the first i2c bus and has the slave
+address of 0x2f, we descend (unrelated sysfs entries have been trimmed).
+
+       # ls /sys/bus/i2c/devices/0-002f/
+       eeprom0 rdac0 tolerance0
+
+You can use simple reads/writes to access these files:
+
+       # cd /sys/bus/i2c/devices/0-002f/
+
+       # cat eeprom0
+       0
+       # echo 10 > eeprom0
+       # cat eeprom0
+       10
+
+       # cat rdac0
+       5
+       # echo 3 > rdac0
+       # cat rdac0
+       3
index b565e8279d133f969fbd6cc2642592c3d44058ed..8e1ddec2c78a2b9b9f4e73c745b9ae28e4b963b3 100644 (file)
@@ -119,6 +119,32 @@ FURTHER NOTES ON NO-MMU MMAP
      granule but will only discard the excess if appropriately configured as
      this has an effect on fragmentation.
 
+ (*) The memory allocated by a request for an anonymous mapping will normally
+     be cleared by the kernel before being returned in accordance with the
+     Linux man pages (ver 2.22 or later).
+
+     In the MMU case this can be achieved with reasonable performance as
+     regions are backed by virtual pages, with the contents only being mapped
+     to cleared physical pages when a write happens on that specific page
+     (prior to which, the pages are effectively mapped to the global zero page
+     from which reads can take place).  This spreads out the time it takes to
+     initialize the contents of a page - depending on the write-usage of the
+     mapping.
+
+     In the no-MMU case, however, anonymous mappings are backed by physical
+     pages, and the entire map is cleared at allocation time.  This can cause
+     significant delays during a userspace malloc() as the C library does an
+     anonymous mapping and the kernel then does a memset for the entire map.
+
+     However, for memory that isn't required to be precleared - such as that
+     returned by malloc() - mmap() can take a MAP_UNINITIALIZED flag to
+     indicate to the kernel that it shouldn't bother clearing the memory before
+     returning it.  Note that CONFIG_MMAP_ALLOW_UNINITIALIZED must be enabled
+     to permit this, otherwise the flag will be ignored.
+
+     uClibc uses this to speed up malloc(), and the ELF-FDPIC binfmt uses this
+     to allocate the brk and stack region.
+
  (*) A list of all the private copy and anonymous mappings on the system is
      visible through /proc/maps in no-MMU mode.
 
index 4a3109b28847176bee1bb0115c24ae63acb34c31..356fd86f4ea8279b1a6175410e076f460f9a7da6 100644 (file)
@@ -42,80 +42,81 @@ struct dev_pm_ops {
        ...
 };
 
-The ->runtime_suspend() callback is executed by the PM core for the bus type of
-the device being suspended.  The bus type's callback is then _entirely_
-_responsible_ for handling the device as appropriate, which may, but need not
-include executing the device driver's own ->runtime_suspend() callback (from the
+The ->runtime_suspend(), ->runtime_resume() and ->runtime_idle() callbacks are
+executed by the PM core for either the bus type, or device type (if the bus
+type's callback is not defined), or device class (if the bus type's and device
+type's callbacks are not defined) of given device.  The bus type, device type
+and device class callbacks are referred to as subsystem-level callbacks in what
+follows.
+
+The subsystem-level suspend callback is _entirely_ _responsible_ for handling
+the suspend of the device as appropriate, which may, but need not include
+executing the device driver's own ->runtime_suspend() callback (from the
 PM core's point of view it is not necessary to implement a ->runtime_suspend()
-callback in a device driver as long as the bus type's ->runtime_suspend() knows
-what to do to handle the device).
+callback in a device driver as long as the subsystem-level suspend callback
+knows what to do to handle the device).
 
-  * Once the bus type's ->runtime_suspend() callback has completed successfully
+  * Once the subsystem-level suspend callback has completed successfully
     for given device, the PM core regards the device as suspended, which need
     not mean that the device has been put into a low power state.  It is
     supposed to mean, however, that the device will not process data and will
-    not communicate with the CPU(s) and RAM until its bus type's
-    ->runtime_resume() callback is executed for it.  The run-time PM status of
-    a device after successful execution of its bus type's ->runtime_suspend()
-    callback is 'suspended'.
-
-  * If the bus type's ->runtime_suspend() callback returns -EBUSY or -EAGAIN,
-    the device's run-time PM status is supposed to be 'active', which means that
-    the device _must_ be fully operational afterwards.
-
-  * If the bus type's ->runtime_suspend() callback returns an error code
-    different from -EBUSY or -EAGAIN, the PM core regards this as a fatal
-    error and will refuse to run the helper functions described in Section 4
-    for the device, until the status of it is directly set either to 'active'
-    or to 'suspended' (the PM core provides special helper functions for this
-    purpose).
-
-In particular, if the driver requires remote wakeup capability for proper
-functioning and device_run_wake() returns 'false' for the device, then
-->runtime_suspend() should return -EBUSY.  On the other hand, if
-device_run_wake() returns 'true' for the device and the device is put
-into a low power state during the execution of its bus type's
-->runtime_suspend(), it is expected that remote wake-up (i.e. hardware mechanism
-allowing the device to request a change of its power state, such as PCI PME)
-will be enabled for the device.  Generally, remote wake-up should be enabled
-for all input devices put into a low power state at run time.
-
-The ->runtime_resume() callback is executed by the PM core for the bus type of
-the device being woken up.  The bus type's callback is then _entirely_
-_responsible_ for handling the device as appropriate, which may, but need not
-include executing the device driver's own ->runtime_resume() callback (from the
-PM core's point of view it is not necessary to implement a ->runtime_resume()
-callback in a device driver as long as the bus type's ->runtime_resume() knows
-what to do to handle the device).
-
-  * Once the bus type's ->runtime_resume() callback has completed successfully,
-    the PM core regards the device as fully operational, which means that the
-    device _must_ be able to complete I/O operations as needed.  The run-time
-    PM status of the device is then 'active'.
-
-  * If the bus type's ->runtime_resume() callback returns an error code, the PM
-    core regards this as a fatal error and will refuse to run the helper
-    functions described in Section 4 for the device, until its status is
-    directly set either to 'active' or to 'suspended' (the PM core provides
-    special helper functions for this purpose).
-
-The ->runtime_idle() callback is executed by the PM core for the bus type of
-given device whenever the device appears to be idle, which is indicated to the
-PM core by two counters, the device's usage counter and the counter of 'active'
-children of the device.
+    not communicate with the CPU(s) and RAM until the subsystem-level resume
+    callback is executed for it.  The run-time PM status of a device after
+    successful execution of the subsystem-level suspend callback is 'suspended'.
+
+  * If the subsystem-level suspend callback returns -EBUSY or -EAGAIN,
+    the device's run-time PM status is 'active', which means that the device
+    _must_ be fully operational afterwards.
+
+  * If the subsystem-level suspend callback returns an error code different
+    from -EBUSY or -EAGAIN, the PM core regards this as a fatal error and will
+    refuse to run the helper functions described in Section 4 for the device,
+    until the status of it is directly set either to 'active', or to 'suspended'
+    (the PM core provides special helper functions for this purpose).
+
+In particular, if the driver requires remote wake-up capability (i.e. hardware
+mechanism allowing the device to request a change of its power state, such as
+PCI PME) for proper functioning and device_run_wake() returns 'false' for the
+device, then ->runtime_suspend() should return -EBUSY.  On the other hand, if
+device_run_wake() returns 'true' for the device and the device is put into a low
+power state during the execution of the subsystem-level suspend callback, it is
+expected that remote wake-up will be enabled for the device.  Generally, remote
+wake-up should be enabled for all input devices put into a low power state at
+run time.
+
+The subsystem-level resume callback is _entirely_ _responsible_ for handling the
+resume of the device as appropriate, which may, but need not include executing
+the device driver's own ->runtime_resume() callback (from the PM core's point of
+view it is not necessary to implement a ->runtime_resume() callback in a device
+driver as long as the subsystem-level resume callback knows what to do to handle
+the device).
+
+  * Once the subsystem-level resume callback has completed successfully, the PM
+    core regards the device as fully operational, which means that the device
+    _must_ be able to complete I/O operations as needed.  The run-time PM status
+    of the device is then 'active'.
+
+  * If the subsystem-level resume callback returns an error code, the PM core
+    regards this as a fatal error and will refuse to run the helper functions
+    described in Section 4 for the device, until its status is directly set
+    either to 'active' or to 'suspended' (the PM core provides special helper
+    functions for this purpose).
+
+The subsystem-level idle callback is executed by the PM core whenever the device
+appears to be idle, which is indicated to the PM core by two counters, the
+device's usage counter and the counter of 'active' children of the device.
 
   * If any of these counters is decreased using a helper function provided by
     the PM core and it turns out to be equal to zero, the other counter is
     checked.  If that counter also is equal to zero, the PM core executes the
-    device bus type's ->runtime_idle() callback (with the device as an
-    argument).
+    subsystem-level idle callback with the device as an argument.
 
-The action performed by a bus type's ->runtime_idle() callback is totally
-dependent on the bus type in question, but the expected and recommended action
-is to check if the device can be suspended (i.e. if all of the conditions
-necessary for suspending the device are satisfied) and to queue up a suspend
-request for the device in that case.  The value returned by this callback is
-ignored by the PM core.
+The action performed by a subsystem-level idle callback is totally dependent on
+the subsystem in question, but the expected and recommended action is to check
+if the device can be suspended (i.e. if all of the conditions necessary for
+suspending the device are satisfied) and to queue up a suspend request for the
+device in that case.  The value returned by this callback is ignored by the PM
+core.
 
 The helper functions provided by the PM core, described in Section 4, guarantee
 that the following constraints are met with respect to the bus type's run-time
@@ -238,41 +239,41 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
       removing the device from device hierarchy
 
   int pm_runtime_idle(struct device *dev);
-    - execute ->runtime_idle() for the device's bus type; returns 0 on success
-      or error code on failure, where -EINPROGRESS means that ->runtime_idle()
-      is already being executed
+    - execute the subsystem-level idle callback for the device; returns 0 on
+      success or error code on failure, where -EINPROGRESS means that
+      ->runtime_idle() is already being executed
 
   int pm_runtime_suspend(struct device *dev);
-    - execute ->runtime_suspend() for the device's bus type; returns 0 on
+    - execute the subsystem-level suspend callback for the device; returns 0 on
       success, 1 if the device's run-time PM status was already 'suspended', or
       error code on failure, where -EAGAIN or -EBUSY means it is safe to attempt
       to suspend the device again in future
 
   int pm_runtime_resume(struct device *dev);
-    - execute ->runtime_resume() for the device's bus type; returns 0 on
+    - execute the subsystem-leve resume callback for the device; returns 0 on
       success, 1 if the device's run-time PM status was already 'active' or
       error code on failure, where -EAGAIN means it may be safe to attempt to
       resume the device again in future, but 'power.runtime_error' should be
       checked additionally
 
   int pm_request_idle(struct device *dev);
-    - submit a request to execute ->runtime_idle() for the device's bus type
-      (the request is represented by a work item in pm_wq); returns 0 on success
-      or error code if the request has not been queued up
+    - submit a request to execute the subsystem-level idle callback for the
+      device (the request is represented by a work item in pm_wq); returns 0 on
+      success or error code if the request has not been queued up
 
   int pm_schedule_suspend(struct device *dev, unsigned int delay);
-    - schedule the execution of ->runtime_suspend() for the device's bus type
-      in future, where 'delay' is the time to wait before queuing up a suspend
-      work item in pm_wq, in milliseconds (if 'delay' is zero, the work item is
-      queued up immediately); returns 0 on success, 1 if the device's PM
+    - schedule the execution of the subsystem-level suspend callback for the
+      device in future, where 'delay' is the time to wait before queuing up a
+      suspend work item in pm_wq, in milliseconds (if 'delay' is zero, the work
+      item is queued up immediately); returns 0 on success, 1 if the device's PM
       run-time status was already 'suspended', or error code if the request
       hasn't been scheduled (or queued up if 'delay' is 0); if the execution of
       ->runtime_suspend() is already scheduled and not yet expired, the new
       value of 'delay' will be used as the time to wait
 
   int pm_request_resume(struct device *dev);
-    - submit a request to execute ->runtime_resume() for the device's bus type
-      (the request is represented by a work item in pm_wq); returns 0 on
+    - submit a request to execute the subsystem-level resume callback for the
+      device (the request is represented by a work item in pm_wq); returns 0 on
       success, 1 if the device's run-time PM status was already 'active', or
       error code if the request hasn't been queued up
 
@@ -303,12 +304,12 @@ drivers/base/power/runtime.c and include/linux/pm_runtime.h:
       run-time PM callbacks described in Section 2
 
   int pm_runtime_disable(struct device *dev);
-    - prevent the run-time PM helper functions from running the device bus
-      type's run-time PM callbacks, make sure that all of the pending run-time
-      PM operations on the device are either completed or canceled; returns
-      1 if there was a resume request pending and it was necessary to execute
-      ->runtime_resume() for the device's bus type to satisfy that request,
-      otherwise 0 is returned
+    - prevent the run-time PM helper functions from running subsystem-level
+      run-time PM callbacks for the device, make sure that all of the pending
+      run-time PM operations on the device are either completed or canceled;
+      returns 1 if there was a resume request pending and it was necessary to
+      execute the subsystem-level resume callback for the device to satisfy that
+      request, otherwise 0 is returned
 
   void pm_suspend_ignore_children(struct device *dev, bool enable);
     - set/unset the power.ignore_children flag of the device
@@ -378,5 +379,55 @@ pm_runtime_suspend() or pm_runtime_idle() or their asynchronous counterparts,
 they will fail returning -EAGAIN, because the device's usage counter is
 incremented by the core before executing ->probe() and ->remove().  Still, it
 may be desirable to suspend the device as soon as ->probe() or ->remove() has
-finished, so the PM core uses pm_runtime_idle_sync() to invoke the device bus
-type's ->runtime_idle() callback at that time.
+finished, so the PM core uses pm_runtime_idle_sync() to invoke the
+subsystem-level idle callback for the device at that time.
+
+6. Run-time PM and System Sleep
+
+Run-time PM and system sleep (i.e., system suspend and hibernation, also known
+as suspend-to-RAM and suspend-to-disk) interact with each other in a couple of
+ways.  If a device is active when a system sleep starts, everything is
+straightforward.  But what should happen if the device is already suspended?
+
+The device may have different wake-up settings for run-time PM and system sleep.
+For example, remote wake-up may be enabled for run-time suspend but disallowed
+for system sleep (device_may_wakeup(dev) returns 'false').  When this happens,
+the subsystem-level system suspend callback is responsible for changing the
+device's wake-up setting (it may leave that to the device driver's system
+suspend routine).  It may be necessary to resume the device and suspend it again
+in order to do so.  The same is true if the driver uses different power levels
+or other settings for run-time suspend and system sleep.
+
+During system resume, devices generally should be brought back to full power,
+even if they were suspended before the system sleep began.  There are several
+reasons for this, including:
+
+  * The device might need to switch power levels, wake-up settings, etc.
+
+  * Remote wake-up events might have been lost by the firmware.
+
+  * The device's children may need the device to be at full power in order
+    to resume themselves.
+
+  * The driver's idea of the device state may not agree with the device's
+    physical state.  This can happen during resume from hibernation.
+
+  * The device might need to be reset.
+
+  * Even though the device was suspended, if its usage counter was > 0 then most
+    likely it would need a run-time resume in the near future anyway.
+
+  * Always going back to full power is simplest.
+
+If the device was suspended before the sleep began, then its run-time PM status
+will have to be updated to reflect the actual post-system sleep status.  The way
+to do this is:
+
+       pm_runtime_disable(dev);
+       pm_runtime_set_active(dev);
+       pm_runtime_enable(dev);
+
+The PM core always increments the run-time usage counter before calling the
+->prepare() callback and decrements it after calling the ->complete() callback.
+Hence disabling run-time PM temporarily like this will not cause any run-time
+suspend callbacks to be lost.
diff --git a/Documentation/powerpc/dts-bindings/4xx/ppc440spe-adma.txt b/Documentation/powerpc/dts-bindings/4xx/ppc440spe-adma.txt
new file mode 100644 (file)
index 0000000..515ebcf
--- /dev/null
@@ -0,0 +1,93 @@
+PPC440SPe DMA/XOR (DMA Controller and XOR Accelerator)
+
+Device nodes needed for operation of the ppc440spe-adma driver
+are specified hereby. These are I2O/DMA, DMA and XOR nodes
+for DMA engines and Memory Queue Module node. The latter is used
+by ADMA driver for configuration of RAID-6 H/W capabilities of
+the PPC440SPe. In addition to the nodes and properties described
+below, the ranges property of PLB node must specify ranges for
+DMA devices.
+
+ i) The I2O node
+
+ Required properties:
+
+ - compatible          : "ibm,i2o-440spe";
+ - reg                 : <registers mapping>
+ - dcr-reg             : <DCR registers range>
+
+ Example:
+
+       I2O: i2o@400100000 {
+               compatible = "ibm,i2o-440spe";
+               reg = <0x00000004 0x00100000 0x100>;
+               dcr-reg = <0x060 0x020>;
+       };
+
+
+ ii) The DMA node
+
+ Required properties:
+
+ - compatible          : "ibm,dma-440spe";
+ - cell-index          : 1 cell, hardware index of the DMA engine
+                         (typically 0x0 and 0x1 for DMA0 and DMA1)
+ - reg                 : <registers mapping>
+ - dcr-reg             : <DCR registers range>
+ - interrupts          : <interrupt mapping for DMA0/1 interrupts sources:
+                          2 sources: DMAx CS FIFO Needs Service IRQ (on UIC0)
+                          and DMA Error IRQ (on UIC1). The latter is common
+                          for both DMA engines>.
+ - interrupt-parent    : needed for interrupt mapping
+
+ Example:
+
+       DMA0: dma0@400100100 {
+               compatible = "ibm,dma-440spe";
+               cell-index = <0>;
+               reg = <0x00000004 0x00100100 0x100>;
+               dcr-reg = <0x060 0x020>;
+               interrupt-parent = <&DMA0>;
+               interrupts = <0 1>;
+               #interrupt-cells = <1>;
+               #address-cells = <0>;
+               #size-cells = <0>;
+               interrupt-map = <
+                       0 &UIC0 0x14 4
+                       1 &UIC1 0x16 4>;
+       };
+
+
+ iii) XOR Accelerator node
+
+ Required properties:
+
+ - compatible          : "amcc,xor-accelerator";
+ - reg                 : <registers mapping>
+ - interrupts          : <interrupt mapping for XOR interrupt source>
+ - interrupt-parent    : for interrupt mapping
+
+ Example:
+
+       xor-accel@400200000 {
+               compatible = "amcc,xor-accelerator";
+               reg = <0x00000004 0x00200000 0x400>;
+               interrupt-parent = <&UIC1>;
+               interrupts = <0x1f 4>;
+       };
+
+
+ iv) Memory Queue Module node
+
+ Required properties:
+
+ - compatible          : "ibm,mq-440spe";
+ - dcr-reg             : <DCR registers range>
+
+ Example:
+
+       MQ0: mq {
+               compatible = "ibm,mq-440spe";
+               dcr-reg = <0x040 0x020>;
+       };
+
diff --git a/Documentation/powerpc/dts-bindings/fsl/mpic.txt b/Documentation/powerpc/dts-bindings/fsl/mpic.txt
new file mode 100644 (file)
index 0000000..71e39cf
--- /dev/null
@@ -0,0 +1,42 @@
+* OpenPIC and its interrupt numbers on Freescale's e500/e600 cores
+
+The OpenPIC specification does not specify which interrupt source has to
+become which interrupt number. This is up to the software implementation
+of the interrupt controller. The only requirement is that every
+interrupt source has to have an unique interrupt number / vector number.
+To accomplish this the current implementation assigns the number zero to
+the first source, the number one to the second source and so on until
+all interrupt sources have their unique number.
+Usually the assigned vector number equals the interrupt number mentioned
+in the documentation for a given core / CPU. This is however not true
+for the e500 cores (MPC85XX CPUs) where the documentation distinguishes
+between internal and external interrupt sources and starts counting at
+zero for both of them.
+
+So what to write for external interrupt source X or internal interrupt
+source Y into the device tree? Here is an example:
+
+The memory map for the interrupt controller in the MPC8544[0] shows,
+that the first interrupt source starts at 0x5_0000 (PIC Register Address
+Map-Interrupt Source Configuration Registers). This source becomes the
+number zero therefore:
+ External interrupt 0 = interrupt number 0
+ External interrupt 1 = interrupt number 1
+ External interrupt 2 = interrupt number 2
+ ...
+Every interrupt number allocates 0x20 bytes register space. So to get
+its number it is sufficient to shift the lower 16bits to right by five.
+So for the external interrupt 10 we have:
+  0x0140 >> 5 = 10
+
+After the external sources, the internal sources follow. The in core I2C
+controller on the MPC8544 for instance has the internal source number
+27. Oo obtain its interrupt number we take the lower 16bits of its memory
+address (0x5_0560) and shift it right:
+ 0x0560 >> 5 = 43
+
+Therefore the I2C device node for the MPC8544 CPU has to have the
+interrupt number 43 specified in the device tree.
+
+[0] MPC8544E PowerQUICCTM III, Integrated Host Processor Family Reference Manual
+    MPC8544ERM Rev. 1 10/2007
diff --git a/Documentation/powerpc/dts-bindings/nintendo/gamecube.txt b/Documentation/powerpc/dts-bindings/nintendo/gamecube.txt
new file mode 100644 (file)
index 0000000..b558585
--- /dev/null
@@ -0,0 +1,109 @@
+
+Nintendo GameCube device tree
+=============================
+
+1) The "flipper" node
+
+  This node represents the multi-function "Flipper" chip, which packages
+  many of the devices found in the Nintendo GameCube.
+
+  Required properties:
+
+   - compatible : Should be "nintendo,flipper"
+
+1.a) The Video Interface (VI) node
+
+  Represents the interface between the graphics processor and a external
+  video encoder.
+
+  Required properties:
+
+   - compatible : should be "nintendo,flipper-vi"
+   - reg : should contain the VI registers location and length
+   - interrupts : should contain the VI interrupt
+
+1.b) The Processor Interface (PI) node
+
+  Represents the data and control interface between the main processor
+  and graphics and audio processor.
+
+  Required properties:
+
+  - compatible : should be "nintendo,flipper-pi"
+  - reg : should contain the PI registers location and length
+
+1.b.i) The "Flipper" interrupt controller node
+
+  Represents the interrupt controller within the "Flipper" chip.
+  The node for the "Flipper" interrupt controller must be placed under
+  the PI node.
+
+  Required properties:
+
+  - compatible : should be "nintendo,flipper-pic"
+
+1.c) The Digital Signal Procesor (DSP) node
+
+  Represents the digital signal processor interface, designed to offload
+  audio related tasks.
+
+  Required properties:
+
+   - compatible : should be "nintendo,flipper-dsp"
+   - reg : should contain the DSP registers location and length
+   - interrupts : should contain the DSP interrupt
+
+1.c.i) The Auxiliary RAM (ARAM) node
+
+  Represents the non cpu-addressable ram designed mainly to store audio
+  related information.
+  The ARAM node must be placed under the DSP node.
+
+  Required properties:
+
+   - compatible : should be "nintendo,flipper-aram"
+   - reg : should contain the ARAM start (zero-based) and length
+
+1.d) The Disk Interface (DI) node
+
+  Represents the interface used to communicate with mass storage devices.
+
+  Required properties:
+
+   - compatible : should be "nintendo,flipper-di"
+   - reg : should contain the DI registers location and length
+   - interrupts : should contain the DI interrupt
+
+1.e) The Audio Interface (AI) node
+
+  Represents the interface to the external 16-bit stereo digital-to-analog
+  converter.
+
+  Required properties:
+
+   - compatible : should be "nintendo,flipper-ai"
+   - reg : should contain the AI registers location and length
+   - interrupts : should contain the AI interrupt
+
+1.f) The Serial Interface (SI) node
+
+  Represents the interface to the four single bit serial interfaces.
+  The SI is a proprietary serial interface used normally to control gamepads.
+  It's NOT a RS232-type interface.
+
+  Required properties:
+
+   - compatible : should be "nintendo,flipper-si"
+   - reg : should contain the SI registers location and length
+   - interrupts : should contain the SI interrupt
+
+1.g) The External Interface (EXI) node
+
+  Represents the multi-channel SPI-like interface.
+
+  Required properties:
+
+   - compatible : should be "nintendo,flipper-exi"
+   - reg : should contain the EXI registers location and length
+   - interrupts : should contain the EXI interrupt
+
diff --git a/Documentation/powerpc/dts-bindings/nintendo/wii.txt b/Documentation/powerpc/dts-bindings/nintendo/wii.txt
new file mode 100644 (file)
index 0000000..a7e155a
--- /dev/null
@@ -0,0 +1,184 @@
+
+Nintendo Wii device tree
+========================
+
+0) The root node
+
+  This node represents the Nintendo Wii video game console.
+
+  Required properties:
+
+   - model : Should be "nintendo,wii"
+   - compatible : Should be "nintendo,wii"
+
+1) The "hollywood" node
+
+  This node represents the multi-function "Hollywood" chip, which packages
+  many of the devices found in the Nintendo Wii.
+
+  Required properties:
+
+   - compatible : Should be "nintendo,hollywood"
+
+1.a) The Video Interface (VI) node
+
+  Represents the interface between the graphics processor and a external
+  video encoder.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-vi","nintendo,flipper-vi"
+   - reg : should contain the VI registers location and length
+   - interrupts : should contain the VI interrupt
+
+1.b) The Processor Interface (PI) node
+
+  Represents the data and control interface between the main processor
+  and graphics and audio processor.
+
+  Required properties:
+
+  - compatible : should be "nintendo,hollywood-pi","nintendo,flipper-pi"
+  - reg : should contain the PI registers location and length
+
+1.b.i) The "Flipper" interrupt controller node
+
+  Represents the "Flipper" interrupt controller within the "Hollywood" chip.
+  The node for the "Flipper" interrupt controller must be placed under
+  the PI node.
+
+  Required properties:
+
+  - #interrupt-cells : <1>
+  - compatible : should be "nintendo,flipper-pic"
+  - interrupt-controller
+
+1.c) The Digital Signal Procesor (DSP) node
+
+  Represents the digital signal processor interface, designed to offload
+  audio related tasks.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-dsp","nintendo,flipper-dsp"
+   - reg : should contain the DSP registers location and length
+   - interrupts : should contain the DSP interrupt
+
+1.d) The Serial Interface (SI) node
+
+  Represents the interface to the four single bit serial interfaces.
+  The SI is a proprietary serial interface used normally to control gamepads.
+  It's NOT a RS232-type interface.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-si","nintendo,flipper-si"
+   - reg : should contain the SI registers location and length
+   - interrupts : should contain the SI interrupt
+
+1.e) The Audio Interface (AI) node
+
+  Represents the interface to the external 16-bit stereo digital-to-analog
+  converter.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-ai","nintendo,flipper-ai"
+   - reg : should contain the AI registers location and length
+   - interrupts : should contain the AI interrupt
+
+1.f) The External Interface (EXI) node
+
+  Represents the multi-channel SPI-like interface.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-exi","nintendo,flipper-exi"
+   - reg : should contain the EXI registers location and length
+   - interrupts : should contain the EXI interrupt
+
+1.g) The Open Host Controller Interface (OHCI) nodes
+
+  Represent the USB 1.x Open Host Controller Interfaces.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-usb-ohci","usb-ohci"
+   - reg : should contain the OHCI registers location and length
+   - interrupts : should contain the OHCI interrupt
+
+1.h) The Enhanced Host Controller Interface (EHCI) node
+
+  Represents the USB 2.0 Enhanced Host Controller Interface.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-usb-ehci","usb-ehci"
+   - reg : should contain the EHCI registers location and length
+   - interrupts : should contain the EHCI interrupt
+
+1.i) The Secure Digital Host Controller Interface (SDHCI) nodes
+
+  Represent the Secure Digital Host Controller Interfaces.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-sdhci","sdhci"
+   - reg : should contain the SDHCI registers location and length
+   - interrupts : should contain the SDHCI interrupt
+
+1.j) The Inter-Processsor Communication (IPC) node
+
+  Represent the Inter-Processor Communication interface. This interface
+  enables communications between the Broadway and the Starlet processors.
+
+   - compatible : should be "nintendo,hollywood-ipc"
+   - reg : should contain the IPC registers location and length
+   - interrupts : should contain the IPC interrupt
+
+1.k) The "Hollywood" interrupt controller node
+
+  Represents the "Hollywood" interrupt controller within the
+  "Hollywood" chip.
+
+  Required properties:
+
+  - #interrupt-cells : <1>
+  - compatible : should be "nintendo,hollywood-pic"
+  - reg : should contain the controller registers location and length
+  - interrupt-controller
+  - interrupts : should contain the cascade interrupt of the "flipper" pic
+  - interrupt-parent: should contain the phandle of the "flipper" pic
+
+1.l) The General Purpose I/O (GPIO) controller node
+
+  Represents the dual access 32 GPIO controller interface.
+
+  Required properties:
+
+  - #gpio-cells : <2>
+  - compatible : should be "nintendo,hollywood-gpio"
+  - reg : should contain the IPC registers location and length
+  - gpio-controller
+
+1.m) The control node
+
+  Represents the control interface used to setup several miscellaneous
+  settings of the "Hollywood" chip like boot memory mappings, resets,
+  disk interface mode, etc.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-control"
+   - reg : should contain the control registers location and length
+
+1.n) The Disk Interface (DI) node
+
+  Represents the interface used to communicate with mass storage devices.
+
+  Required properties:
+
+   - compatible : should be "nintendo,hollywood-di"
+   - reg : should contain the DI registers location and length
+   - interrupts : should contain the DI interrupt
+
index e93affff3af89e0a5526b1b2909e40d550ced418..e72cee9e2a71e72a5b99fc9a29668099ce667ae6 100644 (file)
@@ -403,4 +403,5 @@ STAC9872
 Cirrus Logic CS4206/4207
 ========================
   mbp55                MacBook Pro 5,5
+  imac27       IMac 27 Inch
   auto         BIOS setup (default)
index 719a819f8cc2c0e597e27b2b8bcd7caa17638ea2..07301de12cc4d7c6048f50f5e8cef7b99d8846df 100644 (file)
@@ -95,7 +95,7 @@ card*/pcm*/xrun_debug
        It takes an integer value, can be changed by writing to this
        file, such as
 
-                # cat 5 > /proc/asound/card0/pcm0p/xrun_debug
+                # echo 5 > /proc/asound/card0/pcm0p/xrun_debug
 
        The value consists of the following bit flags:
          bit 0 = Enable XRUN/jiffies debug messages
index a452227361b18a88d695d203e40e33151f93af89..5effa5bd993bb47fd9d02d4acd7d4e5c75cb6b78 100644 (file)
@@ -26,13 +26,33 @@ Procedure for submitting patches to the -stable tree:
 
  - Send the patch, after verifying that it follows the above rules, to
    stable@kernel.org.
+ - To have the patch automatically included in the stable tree, add the
+   the tag
+     Cc: stable@kernel.org
+   in the sign-off area. Once the patch is merged it will be applied to
+   the stable tree without anything else needing to be done by the author
+   or subsystem maintainer.
+ - If the patch requires other patches as prerequisites which can be
+   cherry-picked than this can be specified in the following format in
+   the sign-off area:
+
+     Cc: <stable@kernel.org> # .32.x: a1f84a3: sched: Check for idle
+     Cc: <stable@kernel.org> # .32.x: 1b9508f: sched: Rate-limit newidle
+     Cc: <stable@kernel.org> # .32.x: fd21073: sched: Fix affinity logic
+     Cc: <stable@kernel.org> # .32.x
+    Signed-off-by: Ingo Molnar <mingo@elte.hu>
+
+   The tag sequence has the meaning of:
+     git cherry-pick a1f84a3
+     git cherry-pick 1b9508f
+     git cherry-pick fd21073
+     git cherry-pick <this commit>
+
  - The sender will receive an ACK when the patch has been accepted into the
    queue, or a NAK if the patch is rejected.  This response might take a few
    days, according to the developer's schedules.
  - If accepted, the patch will be added to the -stable queue, for review by
    other developers and by the relevant subsystem maintainer.
- - If the stable@kernel.org address is added to a patch, when it goes into
-   Linus's tree it will automatically be emailed to the stable team.
  - Security patches should not be sent to this alias, but instead to the
    documented security@kernel.org address.
 
index a87dc277a5ca4937bd3ebff2b7eeb829b6b9ee1a..cb3d15bc1aeb47f2d05f00394a176c01430568e8 100644 (file)
@@ -206,6 +206,7 @@ passive
        passive trip point for the zone. Activation is done by polling with
        an interval of 1 second.
        Unit: millidegrees Celsius
+       Valid values: 0 (disabled) or greater than 1000
        RW, Optional
 
 *****************************
index 6ef2a8652e17b12b27cc2aac3f1c7a144d8e6f9a..aa82ee4a5a8762ef9528ef382b07b906c3d6094b 100644 (file)
@@ -1,7 +1,7 @@
                        Subsystem Trace Points: kmem
 
-The tracing system kmem captures events related to object and page allocation
-within the kernel. Broadly speaking there are four major subheadings.
+The kmem tracing system captures events related to object and page allocation
+within the kernel. Broadly speaking there are five major subheadings.
 
   o Slab allocation of small objects of unknown type (kmalloc)
   o Slab allocation of small objects of known type
@@ -9,7 +9,7 @@ within the kernel. Broadly speaking there are four major subheadings.
   o Per-CPU Allocator Activity
   o External Fragmentation
 
-This document will describe what each of the tracepoints are and why they
+This document describes what each of the tracepoints is and why they
 might be useful.
 
 1. Slab allocation of small objects of unknown type
@@ -34,7 +34,7 @@ kmem_cache_free               call_site=%lx ptr=%p
 These events are similar in usage to the kmalloc-related events except that
 it is likely easier to pin the event down to a specific cache. At the time
 of writing, no information is available on what slab is being allocated from,
-but the call_site can usually be used to extrapolate that information
+but the call_site can usually be used to extrapolate that information.
 
 3. Page allocation
 ==================
@@ -80,9 +80,9 @@ event indicating whether it is for a percpu_refill or not.
 When the per-CPU list is too full, a number of pages are freed, each one
 which triggers a mm_page_pcpu_drain event.
 
-The individual nature of the events are so that pages can be tracked
+The individual nature of the events is so that pages can be tracked
 between allocation and freeing. A number of drain or refill pages that occur
-consecutively imply the zone->lock being taken once. Large amounts of PCP
+consecutively imply the zone->lock being taken once. Large amounts of per-CPU
 refills and drains could imply an imbalance between CPUs where too much work
 is being concentrated in one place. It could also indicate that the per-CPU
 lists should be a larger size. Finally, large amounts of refills on one CPU
@@ -102,6 +102,6 @@ is important.
 
 Large numbers of this event implies that memory is fragmenting and
 high-order allocations will start failing at some time in the future. One
-means of reducing the occurange of this event is to increase the size of
+means of reducing the occurrence of this event is to increase the size of
 min_free_kbytes in increments of 3*pageblock_size*nr_online_nodes where
 pageblock_size is usually the size of the default hugepage size.
index c7c1dc2f80179755f29cb2f86c8a5792029084f7..3bf6818c8cf58dd386e03a2c6e085718f58d0004 100644 (file)
@@ -71,12 +71,10 @@ being accessed through sysfs, then it definitely is idle.
        Forms of dynamic PM
        -------------------
 
-Dynamic suspends can occur in two ways: manual and automatic.
-"Manual" means that the user has told the kernel to suspend a device,
-whereas "automatic" means that the kernel has decided all by itself to
-suspend a device.  Automatic suspend is called "autosuspend" for
-short.  In general, a device won't be autosuspended unless it has been
-idle for some minimum period of time, the so-called idle-delay time.
+Dynamic suspends occur when the kernel decides to suspend an idle
+device.  This is called "autosuspend" for short.  In general, a device
+won't be autosuspended unless it has been idle for some minimum period
+of time, the so-called idle-delay time.
 
 Of course, nothing the kernel does on its own initiative should
 prevent the computer or its devices from working properly.  If a
@@ -96,10 +94,11 @@ idle.
 We can categorize power management events in two broad classes:
 external and internal.  External events are those triggered by some
 agent outside the USB stack: system suspend/resume (triggered by
-userspace), manual dynamic suspend/resume (also triggered by
-userspace), and remote wakeup (triggered by the device).  Internal
-events are those triggered within the USB stack: autosuspend and
-autoresume.
+userspace), manual dynamic resume (also triggered by userspace), and
+remote wakeup (triggered by the device).  Internal events are those
+triggered within the USB stack: autosuspend and autoresume.  Note that
+all dynamic suspend events are internal; external agents are not
+allowed to issue dynamic suspends.
 
 
        The user interface for dynamic PM
@@ -145,9 +144,9 @@ relevant attribute files are: wakeup, level, and autosuspend.
                number of seconds the device should remain idle before
                the kernel will autosuspend it (the idle-delay time).
                The default is 2.  0 means to autosuspend as soon as
-               the device becomes idle, and -1 means never to
-               autosuspend.  You can write a number to the file to
-               change the autosuspend idle-delay time.
+               the device becomes idle, and negative values mean
+               never to autosuspend.  You can write a number to the
+               file to change the autosuspend idle-delay time.
 
 Writing "-1" to power/autosuspend and writing "on" to power/level do
 essentially the same thing -- they both prevent the device from being
@@ -377,9 +376,9 @@ the device hasn't been idle for long enough, a delayed workqueue
 routine is automatically set up to carry out the operation when the
 autosuspend idle-delay has expired.
 
-Autoresume attempts also can fail.  This will happen if power/level is
-set to "suspend" or if the device doesn't manage to resume properly.
-Unlike autosuspend, there's no delay for an autoresume.
+Autoresume attempts also can fail, although failure would mean that
+the device is no longer present or operating properly.  Unlike
+autosuspend, there's no delay for an autoresume.
 
 
        Other parts of the driver interface
@@ -527,13 +526,3 @@ succeed, it may still remain active and thus cause the system to
 resume as soon as the system suspend is complete.  Or the remote
 wakeup may fail and get lost.  Which outcome occurs depends on timing
 and on the hardware and firmware design.
-
-More interestingly, a device might undergo a manual resume or
-autoresume during system suspend.  With current kernels this shouldn't
-happen, because manual resumes must be initiated by userspace and
-autoresumes happen in response to I/O requests, but all user processes
-and I/O should be quiescent during a system suspend -- thanks to the
-freezer.  However there are plans to do away with the freezer, which
-would mean these things would become possible.  If and when this comes
-about, the USB core will carefully arrange matters so that either type
-of resume will block until the entire system has resumed.
index 987f9b0a5ecea5b2d5768571fb91b59249860d2c..43a9b0694fddbc5b65b8c4286ab6feb8f9c4cc26 100644 (file)
@@ -103,7 +103,7 @@ I.2 libpciaccess
 ----------------
 
 To use the vga arbiter char device it was implemented an API inside the
-libpciaccess library. One fieldd was added to struct pci_device (each device
+libpciaccess library. One field was added to struct pci_device (each device
 on the system):
 
     /* the type of resource decoded by the device */
index 319d9838e87e0ffbd1f35945c84d8c1ff1c38d3c..1800a62cf13538e72e61d90e23d0abf327159210 100644 (file)
@@ -12,6 +12,7 @@ m5602         0402:5602       ALi Video Camera Controller
 spca501                040a:0002       Kodak DVC-325
 spca500                040a:0300       Kodak EZ200
 zc3xx          041e:041e       Creative WebCam Live!
+ov519          041e:4003       Video Blaster WebCam Go Plus
 spca500                041e:400a       Creative PC-CAM 300
 sunplus                041e:400b       Creative PC-CAM 600
 sunplus                041e:4012       PC-Cam350
@@ -168,10 +169,14 @@ sunplus           055f:c650       Mustek MDC5500Z
 zc3xx          055f:d003       Mustek WCam300A
 zc3xx          055f:d004       Mustek WCam300 AN
 conex          0572:0041       Creative Notebook cx11646
+ov519          05a9:0511       Video Blaster WebCam 3/WebCam Plus, D-Link USB Digital Video Camera
+ov519          05a9:0518       Creative WebCam
 ov519          05a9:0519       OV519 Microphone
 ov519          05a9:0530       OmniVision
+ov519          05a9:2800       OmniVision SuperCAM
 ov519          05a9:4519       Webcam Classic
 ov519          05a9:8519       OmniVision
+ov519          05a9:a511       D-Link USB Digital Video Camera
 ov519          05a9:a518       D-Link DSB-C310 Webcam
 sunplus                05da:1018       Digital Dream Enigma 1.3
 stk014         05e1:0893       Syntek DV4000
@@ -187,7 +192,7 @@ ov534               06f8:3002       Hercules Blog Webcam
 ov534          06f8:3003       Hercules Dualpix HD Weblog
 sonixj         06f8:3004       Hercules Classic Silver
 sonixj         06f8:3008       Hercules Deluxe Optical Glass
-pac7311                06f8:3009       Hercules Classic Link
+pac7302                06f8:3009       Hercules Classic Link
 spca508                0733:0110       ViewQuest VQ110
 spca501                0733:0401       Intel Create and Share
 spca501                0733:0402       ViewQuest M318B
@@ -199,6 +204,7 @@ sunplus             0733:2221       Mercury Digital Pro 3.1p
 sunplus                0733:3261       Concord 3045 spca536a
 sunplus                0733:3281       Cyberpix S550V
 spca506                0734:043b       3DeMon USB Capture aka
+ov519          0813:0002       Dual Mode USB Camera Plus
 spca500                084d:0003       D-Link DSC-350
 spca500                08ca:0103       Aiptek PocketDV
 sunplus                08ca:0104       Aiptek PocketDVII 1.3
@@ -236,15 +242,15 @@ pac7311           093a:2603       Philips SPC 500 NC
 pac7311                093a:2608       Trust WB-3300p
 pac7311                093a:260e       Gigaware VGA PC Camera, Trust WB-3350p, SIGMA cam 2350
 pac7311                093a:260f       SnakeCam
-pac7311                093a:2620       Apollo AC-905
-pac7311                093a:2621       PAC731x
-pac7311                093a:2622       Genius Eye 312
-pac7311                093a:2624       PAC7302
-pac7311                093a:2626       Labtec 2200
-pac7311                093a:2628       Genius iLook 300
-pac7311                093a:2629       Genious iSlim 300
-pac7311                093a:262a       Webcam 300k
-pac7311                093a:262c       Philips SPC 230 NC
+pac7302                093a:2620       Apollo AC-905
+pac7302                093a:2621       PAC731x
+pac7302                093a:2622       Genius Eye 312
+pac7302                093a:2624       PAC7302
+pac7302                093a:2626       Labtec 2200
+pac7302                093a:2628       Genius iLook 300
+pac7302                093a:2629       Genious iSlim 300
+pac7302                093a:262a       Webcam 300k
+pac7302                093a:262c       Philips SPC 230 NC
 jeilinj                0979:0280       Sakar 57379
 zc3xx          0ac8:0302       Z-star Vimicro zc0302
 vc032x         0ac8:0321       Vimicro generic vc0321
@@ -259,6 +265,7 @@ vc032x              0ac8:c002       Sony embedded vimicro
 vc032x         0ac8:c301       Samsung Q1 Ultra Premium
 spca508                0af9:0010       Hama USB Sightcam 100
 spca508                0af9:0011       Hama USB Sightcam 100
+ov519          0b62:0059       iBOT2 Webcam
 sonixb         0c45:6001       Genius VideoCAM NB
 sonixb         0c45:6005       Microdia Sweex Mini Webcam
 sonixb         0c45:6007       Sonix sn9c101 + Tas5110D
@@ -318,8 +325,10 @@ sn9c20x            0c45:62b3       PC Camera (SN9C202 + OV9655)
 sn9c20x                0c45:62bb       PC Camera (SN9C202 + OV7660)
 sn9c20x                0c45:62bc       PC Camera (SN9C202 + HV7131R)
 sunplus                0d64:0303       Sunplus FashionCam DXG
+ov519          0e96:c001       TRUST 380 USB2 SPACEC@M
 etoms          102c:6151       Qcam Sangha CIF
 etoms          102c:6251       Qcam xxxxxx VGA
+ov519          1046:9967       W9967CF/W9968CF WebCam IC, Video Blaster WebCam Go
 zc3xx          10fd:0128       Typhoon Webshot II USB 300k 0x0128
 spca561                10fd:7e50       FlyCam Usb 100
 zc3xx          10fd:8050       Typhoon Webshot II USB 300k
@@ -332,7 +341,12 @@ spca501            1776:501c       Arowana 300K CMOS Camera
 t613           17a1:0128       TASCORP JPEG Webcam, NGS Cyclops
 vc032x         17ef:4802       Lenovo Vc0323+MI1310_SOC
 pac207         2001:f115       D-Link DSB-C120
+sq905c         2770:9050       sq905c
+sq905c         2770:905c       DualCamera
+sq905          2770:9120       Argus Digital Camera DC1512
+sq905c         2770:913d       sq905c
 spca500                2899:012c       Toptro Industrial
+ov519          8020:ef04       ov519
 spca508                8086:0110       Intel Easy PC Camera
 spca500                8086:0630       Intel Pocket PC Camera
 spca506                99fa:8988       Grandtec V.cap
diff --git a/Documentation/video4linux/sh_mobile_ceu_camera.txt b/Documentation/video4linux/sh_mobile_ceu_camera.txt
new file mode 100644 (file)
index 0000000..2ae1634
--- /dev/null
@@ -0,0 +1,157 @@
+       Cropping and Scaling algorithm, used in the sh_mobile_ceu_camera driver
+       =======================================================================
+
+Terminology
+-----------
+
+sensor scales: horizontal and vertical scales, configured by the sensor driver
+host scales: -"- host driver
+combined scales: sensor_scale * host_scale
+
+
+Generic scaling / cropping scheme
+---------------------------------
+
+-1--
+|
+-2-- -\
+|      --\
+|         --\
++-5-- -\     -- -3--
+|       ---\
+|           --- -4-- -\
+|                      -\
+|                        - -6--
+|
+|                        - -6'-
+|                      -/
+|           --- -4'- -/
+|       ---/
++-5'- -/
+|            -- -3'-
+|         --/
+|      --/
+-2'- -/
+|
+|
+-1'-
+
+Produced by user requests:
+
+S_CROP(left / top = (5) - (1), width / height = (5') - (5))
+S_FMT(width / height = (6') - (6))
+
+Here:
+
+(1) to (1') - whole max width or height
+(1) to (2)  - sensor cropped left or top
+(2) to (2') - sensor cropped width or height
+(3) to (3') - sensor scale
+(3) to (4)  - CEU cropped left or top
+(4) to (4') - CEU cropped width or height
+(5) to (5') - reverse sensor scale applied to CEU cropped width or height
+(2) to (5)  - reverse sensor scale applied to CEU cropped left or top
+(6) to (6') - CEU scale - user window
+
+
+S_FMT
+-----
+
+Do not touch input rectangle - it is already optimal.
+
+1. Calculate current sensor scales:
+
+       scale_s = ((3') - (3)) / ((2') - (2))
+
+2. Calculate "effective" input crop (sensor subwindow) - CEU crop scaled back at
+current sensor scales onto input window - this is user S_CROP:
+
+       width_u = (5') - (5) = ((4') - (4)) * scale_s
+
+3. Calculate new combined scales from "effective" input window to requested user
+window:
+
+       scale_comb = width_u / ((6') - (6))
+
+4. Calculate sensor output window by applying combined scales to real input
+window:
+
+       width_s_out = ((2') - (2)) / scale_comb
+
+5. Apply iterative sensor S_FMT for sensor output window.
+
+       subdev->video_ops->s_fmt(.width = width_s_out)
+
+6. Retrieve sensor output window (g_fmt)
+
+7. Calculate new sensor scales:
+
+       scale_s_new = ((3')_new - (3)_new) / ((2') - (2))
+
+8. Calculate new CEU crop - apply sensor scales to previously calculated
+"effective" crop:
+
+       width_ceu = (4')_new - (4)_new = width_u / scale_s_new
+       left_ceu = (4)_new - (3)_new = ((5) - (2)) / scale_s_new
+
+9. Use CEU cropping to crop to the new window:
+
+       ceu_crop(.width = width_ceu, .left = left_ceu)
+
+10. Use CEU scaling to scale to the requested user window:
+
+       scale_ceu = width_ceu / width
+
+
+S_CROP
+------
+
+If old scale applied to new crop is invalid produce nearest new scale possible
+
+1. Calculate current combined scales.
+
+       scale_comb = (((4') - (4)) / ((6') - (6))) * (((2') - (2)) / ((3') - (3)))
+
+2. Apply iterative sensor S_CROP for new input window.
+
+3. If old combined scales applied to new crop produce an impossible user window,
+adjust scales to produce nearest possible window.
+
+       width_u_out = ((5') - (5)) / scale_comb
+
+       if (width_u_out > max)
+               scale_comb = ((5') - (5)) / max;
+       else if (width_u_out < min)
+               scale_comb = ((5') - (5)) / min;
+
+4. Issue G_CROP to retrieve actual input window.
+
+5. Using actual input window and calculated combined scales calculate sensor
+target output window.
+
+       width_s_out = ((3') - (3)) = ((2') - (2)) / scale_comb
+
+6. Apply iterative S_FMT for new sensor target output window.
+
+7. Issue G_FMT to retrieve the actual sensor output window.
+
+8. Calculate sensor scales.
+
+       scale_s = ((3') - (3)) / ((2') - (2))
+
+9. Calculate sensor output subwindow to be cropped on CEU by applying sensor
+scales to the requested window.
+
+       width_ceu = ((5') - (5)) / scale_s
+
+10. Use CEU cropping for above calculated window.
+
+11. Calculate CEU scales from sensor scales from results of (10) and user window
+from (3)
+
+       scale_ceu = calc_scale(((5') - (5)), &width_u_out)
+
+12. Apply CEU scales.
+
+--
+Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
index b806edaf3e752027a7101b006251dd1a1e9faae6..74d677c8b036c076b49ffa8cc287f7948fe9f0e1 100644 (file)
@@ -561,6 +561,8 @@ video_device helper functions
 
 There are a few useful helper functions:
 
+- file/video_device private data
+
 You can set/get driver private data in the video_device struct using:
 
 void *video_get_drvdata(struct video_device *vdev);
@@ -575,8 +577,7 @@ struct video_device *video_devdata(struct file *file);
 
 returns the video_device belonging to the file struct.
 
-The final helper function combines video_get_drvdata with
-video_devdata:
+The video_drvdata function combines video_get_drvdata with video_devdata:
 
 void *video_drvdata(struct file *file);
 
@@ -584,6 +585,17 @@ You can go from a video_device struct to the v4l2_device struct using:
 
 struct v4l2_device *v4l2_dev = vdev->v4l2_dev;
 
+- Device node name
+
+The video_device node kernel name can be retrieved using
+
+const char *video_device_node_name(struct video_device *vdev);
+
+The name is used as a hint by userspace tools such as udev. The function
+should be used where possible instead of accessing the video_device::num and
+video_device::minor fields.
+
+
 video buffer helper functions
 -----------------------------
 
index 82a7bd1800b2fba2a19aca1a69ac9c0a1274852c..bc31636973e312f27545bcdb38e2936a78e9fe44 100644 (file)
@@ -11,23 +11,21 @@ This optimization is more critical now as bigger and bigger physical memories
 (several GBs) are more readily available.
 
 Users can use the huge page support in Linux kernel by either using the mmap
-system call or standard SYSv shared memory system calls (shmget, shmat).
+system call or standard SYSV shared memory system calls (shmget, shmat).
 
 First the Linux kernel needs to be built with the CONFIG_HUGETLBFS
 (present under "File systems") and CONFIG_HUGETLB_PAGE (selected
 automatically when CONFIG_HUGETLBFS is selected) configuration
 options.
 
-The kernel built with huge page support should show the number of configured
-huge pages in the system by running the "cat /proc/meminfo" command.
+The /proc/meminfo file provides information about the total number of
+persistent hugetlb pages in the kernel's huge page pool.  It also displays
+information about the number of free, reserved and surplus huge pages and the
+default huge page size.  The huge page size is needed for generating the
+proper alignment and size of the arguments to system calls that map huge page
+regions.
 
-/proc/meminfo also provides information about the total number of hugetlb
-pages configured in the kernel.  It also displays information about the
-number of free hugetlb pages at any time.  It also displays information about
-the configured huge page size - this is needed for generating the proper
-alignment and size of the arguments to the above system calls.
-
-The output of "cat /proc/meminfo" will have lines like:
+The output of "cat /proc/meminfo" will include lines like:
 
 .....
 HugePages_Total: vvv
@@ -53,59 +51,63 @@ HugePages_Surp  is short for "surplus," and is the number of huge pages in
 /proc/filesystems should also show a filesystem of type "hugetlbfs" configured
 in the kernel.
 
-/proc/sys/vm/nr_hugepages indicates the current number of configured hugetlb
-pages in the kernel.  Super user can dynamically request more (or free some
-pre-configured) huge pages.
-The allocation (or deallocation) of hugetlb pages is possible only if there are
-enough physically contiguous free pages in system (freeing of huge pages is
-possible only if there are enough hugetlb pages free that can be transferred
-back to regular memory pool).
+/proc/sys/vm/nr_hugepages indicates the current number of "persistent" huge
+pages in the kernel's huge page pool.  "Persistent" huge pages will be
+returned to the huge page pool when freed by a task.  A user with root
+privileges can dynamically allocate more or free some persistent huge pages
+by increasing or decreasing the value of 'nr_hugepages'.
 
-Pages that are used as hugetlb pages are reserved inside the kernel and cannot
-be used for other purposes.
+Pages that are used as huge pages are reserved inside the kernel and cannot
+be used for other purposes.  Huge pages cannot be swapped out under
+memory pressure.
 
-Once the kernel with Hugetlb page support is built and running, a user can
-use either the mmap system call or shared memory system calls to start using
-the huge pages.  It is required that the system administrator preallocate
-enough memory for huge page purposes.
+Once a number of huge pages have been pre-allocated to the kernel huge page
+pool, a user with appropriate privilege can use either the mmap system call
+or shared memory system calls to use the huge pages.  See the discussion of
+Using Huge Pages, below.
 
-The administrator can preallocate huge pages on the kernel boot command line by
-specifying the "hugepages=N" parameter, where 'N' = the number of huge pages
-requested.  This is the most reliable method for preallocating huge pages as
-memory has not yet become fragmented.
+The administrator can allocate persistent huge pages on the kernel boot
+command line by specifying the "hugepages=N" parameter, where 'N' = the
+number of huge pages requested.  This is the most reliable method of
+allocating huge pages as memory has not yet become fragmented.
 
-Some platforms support multiple huge page sizes.  To preallocate huge pages
+Some platforms support multiple huge page sizes.  To allocate huge pages
 of a specific size, one must preceed the huge pages boot command parameters
 with a huge page size selection parameter "hugepagesz=<size>".  <size> must
 be specified in bytes with optional scale suffix [kKmMgG].  The default huge
 page size may be selected with the "default_hugepagesz=<size>" boot parameter.
 
-/proc/sys/vm/nr_hugepages indicates the current number of configured [default
-size] hugetlb pages in the kernel.  Super user can dynamically request more
-(or free some pre-configured) huge pages.
-
-Use the following command to dynamically allocate/deallocate default sized
-huge pages:
+When multiple huge page sizes are supported, /proc/sys/vm/nr_hugepages
+indicates the current number of pre-allocated huge pages of the default size.
+Thus, one can use the following command to dynamically allocate/deallocate
+default sized persistent huge pages:
 
        echo 20 > /proc/sys/vm/nr_hugepages
 
-This command will try to configure 20 default sized huge pages in the system.
+This command will try to adjust the number of default sized huge pages in the
+huge page pool to 20, allocating or freeing huge pages, as required.
+
 On a NUMA platform, the kernel will attempt to distribute the huge page pool
-over the all on-line nodes.  These huge pages, allocated when nr_hugepages
-is increased, are called "persistent huge pages".
+over all the set of allowed nodes specified by the NUMA memory policy of the
+task that modifies nr_hugepages.  The default for the allowed nodes--when the
+task has default memory policy--is all on-line nodes with memory.  Allowed
+nodes with insufficient available, contiguous memory for a huge page will be
+silently skipped when allocating persistent huge pages.  See the discussion
+below of the interaction of task memory policy, cpusets and per node attributes
+with the allocation and freeing of persistent huge pages.
 
 The success or failure of huge page allocation depends on the amount of
-physically contiguous memory that is preset in system at the time of the
+physically contiguous memory that is present in system at the time of the
 allocation attempt.  If the kernel is unable to allocate huge pages from
 some nodes in a NUMA system, it will attempt to make up the difference by
 allocating extra pages on other nodes with sufficient available contiguous
 memory, if any.
 
-System administrators may want to put this command in one of the local rc init
-files.  This will enable the kernel to request huge pages early in the boot
-process when the possibility of getting physical contiguous pages is still
-very high.  Administrators can verify the number of huge pages actually
-allocated by checking the sysctl or meminfo.  To check the per node
+System administrators may want to put this command in one of the local rc
+init files.  This will enable the kernel to allocate huge pages early in
+the boot process when the possibility of getting physical contiguous pages
+is still very high.  Administrators can verify the number of huge pages
+actually allocated by checking the sysctl or meminfo.  To check the per node
 distribution of huge pages in a NUMA system, use:
 
        cat /sys/devices/system/node/node*/meminfo | fgrep Huge
@@ -113,45 +115,47 @@ distribution of huge pages in a NUMA system, use:
 /proc/sys/vm/nr_overcommit_hugepages specifies how large the pool of
 huge pages can grow, if more huge pages than /proc/sys/vm/nr_hugepages are
 requested by applications.  Writing any non-zero value into this file
-indicates that the hugetlb subsystem is allowed to try to obtain "surplus"
-huge pages from the buddy allocator, when the normal pool is exhausted. As
-these surplus huge pages go out of use, they are freed back to the buddy
-allocator.
+indicates that the hugetlb subsystem is allowed to try to obtain that
+number of "surplus" huge pages from the kernel's normal page pool, when the
+persistent huge page pool is exhausted. As these surplus huge pages become
+unused, they are freed back to the kernel's normal page pool.
 
-When increasing the huge page pool size via nr_hugepages, any surplus
+When increasing the huge page pool size via nr_hugepages, any existing surplus
 pages will first be promoted to persistent huge pages.  Then, additional
 huge pages will be allocated, if necessary and if possible, to fulfill
-the new huge page pool size.
+the new persistent huge page pool size.
 
-The administrator may shrink the pool of preallocated huge pages for
+The administrator may shrink the pool of persistent huge pages for
 the default huge page size by setting the nr_hugepages sysctl to a
 smaller value.  The kernel will attempt to balance the freeing of huge pages
-across all on-line nodes.  Any free huge pages on the selected nodes will
-be freed back to the buddy allocator.
-
-Caveat: Shrinking the pool via nr_hugepages such that it becomes less
-than the number of huge pages in use will convert the balance to surplus
-huge pages even if it would exceed the overcommit value.  As long as
-this condition holds, however, no more surplus huge pages will be
-allowed on the system until one of the two sysctls are increased
-sufficiently, or the surplus huge pages go out of use and are freed.
+across all nodes in the memory policy of the task modifying nr_hugepages.
+Any free huge pages on the selected nodes will be freed back to the kernel's
+normal page pool.
+
+Caveat: Shrinking the persistent huge page pool via nr_hugepages such that
+it becomes less than the number of huge pages in use will convert the balance
+of the in-use huge pages to surplus huge pages.  This will occur even if
+the number of surplus pages it would exceed the overcommit value.  As long as
+this condition holds--that is, until nr_hugepages+nr_overcommit_hugepages is
+increased sufficiently, or the surplus huge pages go out of use and are freed--
+no more surplus huge pages will be allowed to be allocated.
 
 With support for multiple huge page pools at run-time available, much of
-the huge page userspace interface has been duplicated in sysfs. The above
-information applies to the default huge page size which will be
-controlled by the /proc interfaces for backwards compatibility. The root
-huge page control directory in sysfs is:
+the huge page userspace interface in /proc/sys/vm has been duplicated in sysfs.
+The /proc interfaces discussed above have been retained for backwards
+compatibility. The root huge page control directory in sysfs is:
 
        /sys/kernel/mm/hugepages
 
 For each huge page size supported by the running kernel, a subdirectory
-will exist, of the form
+will exist, of the form:
 
        hugepages-${size}kB
 
 Inside each of these directories, the same set of files will exist:
 
        nr_hugepages
+       nr_hugepages_mempolicy
        nr_overcommit_hugepages
        free_hugepages
        resv_hugepages
@@ -159,6 +163,102 @@ Inside each of these directories, the same set of files will exist:
 
 which function as described above for the default huge page-sized case.
 
+
+Interaction of Task Memory Policy with Huge Page Allocation/Freeing
+
+Whether huge pages are allocated and freed via the /proc interface or
+the /sysfs interface using the nr_hugepages_mempolicy attribute, the NUMA
+nodes from which huge pages are allocated or freed are controlled by the
+NUMA memory policy of the task that modifies the nr_hugepages_mempolicy
+sysctl or attribute.  When the nr_hugepages attribute is used, mempolicy
+is ignored.
+
+The recommended method to allocate or free huge pages to/from the kernel
+huge page pool, using the nr_hugepages example above, is:
+
+    numactl --interleave <node-list> echo 20 \
+                               >/proc/sys/vm/nr_hugepages_mempolicy
+
+or, more succinctly:
+
+    numactl -m <node-list> echo 20 >/proc/sys/vm/nr_hugepages_mempolicy
+
+This will allocate or free abs(20 - nr_hugepages) to or from the nodes
+specified in <node-list>, depending on whether number of persistent huge pages
+is initially less than or greater than 20, respectively.  No huge pages will be
+allocated nor freed on any node not included in the specified <node-list>.
+
+When adjusting the persistent hugepage count via nr_hugepages_mempolicy, any
+memory policy mode--bind, preferred, local or interleave--may be used.  The
+resulting effect on persistent huge page allocation is as follows:
+
+1) Regardless of mempolicy mode [see Documentation/vm/numa_memory_policy.txt],
+   persistent huge pages will be distributed across the node or nodes
+   specified in the mempolicy as if "interleave" had been specified.
+   However, if a node in the policy does not contain sufficient contiguous
+   memory for a huge page, the allocation will not "fallback" to the nearest
+   neighbor node with sufficient contiguous memory.  To do this would cause
+   undesirable imbalance in the distribution of the huge page pool, or
+   possibly, allocation of persistent huge pages on nodes not allowed by
+   the task's memory policy.
+
+2) One or more nodes may be specified with the bind or interleave policy.
+   If more than one node is specified with the preferred policy, only the
+   lowest numeric id will be used.  Local policy will select the node where
+   the task is running at the time the nodes_allowed mask is constructed.
+   For local policy to be deterministic, the task must be bound to a cpu or
+   cpus in a single node.  Otherwise, the task could be migrated to some
+   other node at any time after launch and the resulting node will be
+   indeterminate.  Thus, local policy is not very useful for this purpose.
+   Any of the other mempolicy modes may be used to specify a single node.
+
+3) The nodes allowed mask will be derived from any non-default task mempolicy,
+   whether this policy was set explicitly by the task itself or one of its
+   ancestors, such as numactl.  This means that if the task is invoked from a
+   shell with non-default policy, that policy will be used.  One can specify a
+   node list of "all" with numactl --interleave or --membind [-m] to achieve
+   interleaving over all nodes in the system or cpuset.
+
+4) Any task mempolicy specifed--e.g., using numactl--will be constrained by
+   the resource limits of any cpuset in which the task runs.  Thus, there will
+   be no way for a task with non-default policy running in a cpuset with a
+   subset of the system nodes to allocate huge pages outside the cpuset
+   without first moving to a cpuset that contains all of the desired nodes.
+
+5) Boot-time huge page allocation attempts to distribute the requested number
+   of huge pages over all on-lines nodes with memory.
+
+Per Node Hugepages Attributes
+
+A subset of the contents of the root huge page control directory in sysfs,
+described above, will be replicated under each the system device of each
+NUMA node with memory in:
+
+       /sys/devices/system/node/node[0-9]*/hugepages/
+
+Under this directory, the subdirectory for each supported huge page size
+contains the following attribute files:
+
+       nr_hugepages
+       free_hugepages
+       surplus_hugepages
+
+The free_' and surplus_' attribute files are read-only.  They return the number
+of free and surplus [overcommitted] huge pages, respectively, on the parent
+node.
+
+The nr_hugepages attribute returns the total number of huge pages on the
+specified node.  When this attribute is written, the number of persistent huge
+pages on the parent node will be adjusted to the specified value, if sufficient
+resources exist, regardless of the task's mempolicy or cpuset constraints.
+
+Note that the number of overcommit and reserve pages remain global quantities,
+as we don't know until fault time, when the faulting task's mempolicy is
+applied, from which node the huge page allocation will be attempted.
+
+
+Using Huge Pages
+
 If the user applications are going to request huge pages using mmap system
 call, then it is required that system administrator mount a file system of
 type hugetlbfs:
@@ -206,9 +306,11 @@ map_hugetlb.c.
  * requesting huge pages.
  *
  * For the ia64 architecture, the Linux kernel reserves Region number 4 for
- * huge pages.  That means the addresses starting with 0x800000... will need
- * to be specified.  Specifying a fixed address is not required on ppc64,
- * i386 or x86_64.
+ * huge pages.  That means that if one requires a fixed address, a huge page
+ * aligned address starting with 0x800000... will be required.  If a fixed
+ * address is not required, the kernel will select an address in the proper
+ * range.
+ * Other architectures, such as ppc64, i386 or x86_64 are not so constrained.
  *
  * Note: The default shared memory limit is quite low on many kernels,
  * you may need to increase it via:
@@ -237,14 +339,8 @@ map_hugetlb.c.
 
 #define dprintf(x)  printf(x)
 
-/* Only ia64 requires this */
-#ifdef __ia64__
-#define ADDR (void *)(0x8000000000000000UL)
-#define SHMAT_FLAGS (SHM_RND)
-#else
-#define ADDR (void *)(0x0UL)
+#define ADDR (void *)(0x0UL)   /* let kernel choose address */
 #define SHMAT_FLAGS (0)
-#endif
 
 int main(void)
 {
@@ -302,10 +398,12 @@ int main(void)
  * example, the app is requesting memory of size 256MB that is backed by
  * huge pages.
  *
- * For ia64 architecture, Linux kernel reserves Region number 4 for huge pages.
- * That means the addresses starting with 0x800000... will need to be
- * specified.  Specifying a fixed address is not required on ppc64, i386
- * or x86_64.
+ * For the ia64 architecture, the Linux kernel reserves Region number 4 for
+ * huge pages.  That means that if one requires a fixed address, a huge page
+ * aligned address starting with 0x800000... will be required.  If a fixed
+ * address is not required, the kernel will select an address in the proper
+ * range.
+ * Other architectures, such as ppc64, i386 or x86_64 are not so constrained.
  */
 #include <stdlib.h>
 #include <stdio.h>
@@ -317,14 +415,8 @@ int main(void)
 #define LENGTH (256UL*1024*1024)
 #define PROTECTION (PROT_READ | PROT_WRITE)
 
-/* Only ia64 requires this */
-#ifdef __ia64__
-#define ADDR (void *)(0x8000000000000000UL)
-#define FLAGS (MAP_SHARED | MAP_FIXED)
-#else
-#define ADDR (void *)(0x0UL)
+#define ADDR (void *)(0x0UL)   /* let kernel choose address */
 #define FLAGS (MAP_SHARED)
-#endif
 
 void check_bytes(char *addr)
 {
index 3ffadf8da61fab911bbeadbb96ef993359c89b57..12f9ba20ccb7aebd72aab882f9b6d6d7d9b4a135 100644 (file)
@@ -92,16 +92,62 @@ PR_MCE_KILL_GET
 
 Testing:
 
-madvise(MADV_POISON, ....)
+madvise(MADV_HWPOISON, ....)
        (as root)
        Poison a page in the process for testing
 
 
 hwpoison-inject module through debugfs
-       /sys/debug/hwpoison/corrupt-pfn
 
-Inject hwpoison fault at PFN echoed into this file
+/sys/debug/hwpoison/
 
+corrupt-pfn
+
+Inject hwpoison fault at PFN echoed into this file. This does
+some early filtering to avoid corrupted unintended pages in test suites.
+
+unpoison-pfn
+
+Software-unpoison page at PFN echoed into this file. This
+way a page can be reused again.
+This only works for Linux injected failures, not for real
+memory failures.
+
+Note these injection interfaces are not stable and might change between
+kernel versions
+
+corrupt-filter-dev-major
+corrupt-filter-dev-minor
+
+Only handle memory failures to pages associated with the file system defined
+by block device major/minor.  -1U is the wildcard value.
+This should be only used for testing with artificial injection.
+
+corrupt-filter-memcg
+
+Limit injection to pages owned by memgroup. Specified by inode number
+of the memcg.
+
+Example:
+        mkdir /cgroup/hwpoison
+
+        usemem -m 100 -s 1000 &
+        echo `jobs -p` > /cgroup/hwpoison/tasks
+
+        memcg_ino=$(ls -id /cgroup/hwpoison | cut -f1 -d' ')
+        echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg
+
+        page-types -p `pidof init`   --hwpoison  # shall do nothing
+        page-types -p `pidof usemem` --hwpoison  # poison its pages
+
+corrupt-filter-flags-mask
+corrupt-filter-flags-value
+
+When specified, only poison pages if ((page_flags & mask) == value).
+This allows stress testing of many kinds of pages. The page_flags
+are the same as in /proc/kpageflags. The flag bits are defined in
+include/linux/kernel-page-flags.h and documented in
+Documentation/vm/pagemap.txt
 
 Architecture specific MCE injector
 
index 262d8e6793a3e008c36bb39905f49634f9e570ae..b392e496f816ac6c77fccd9c0c367de4efa57034 100644 (file)
@@ -16,9 +16,9 @@ by sharing the data common between them.  But it can be useful to any
 application which generates many instances of the same data.
 
 KSM only merges anonymous (private) pages, never pagecache (file) pages.
-KSM's merged pages are at present locked into kernel memory for as long
-as they are shared: so cannot be swapped out like the user pages they
-replace (but swapping KSM pages should follow soon in a later release).
+KSM's merged pages were originally locked into kernel memory, but can now
+be swapped out just like other user pages (but sharing is broken when they
+are swapped back in: ksmd must rediscover their identity and merge again).
 
 KSM only operates on those areas of address space which an application
 has advised to be likely candidates for merging, by using the madvise(2)
@@ -44,20 +44,12 @@ includes unmapped gaps (though working on the intervening mapped areas),
 and might fail with EAGAIN if not enough memory for internal structures.
 
 Applications should be considerate in their use of MADV_MERGEABLE,
-restricting its use to areas likely to benefit.  KSM's scans may use
-a lot of processing power, and its kernel-resident pages are a limited
-resource.  Some installations will disable KSM for these reasons.
+restricting its use to areas likely to benefit.  KSM's scans may use a lot
+of processing power: some installations will disable KSM for that reason.
 
 The KSM daemon is controlled by sysfs files in /sys/kernel/mm/ksm/,
 readable by all but writable only by root:
 
-max_kernel_pages - set to maximum number of kernel pages that KSM may use
-                   e.g. "echo 100000 > /sys/kernel/mm/ksm/max_kernel_pages"
-                   Value 0 imposes no limit on the kernel pages KSM may use;
-                   but note that any process using MADV_MERGEABLE can cause
-                   KSM to allocate these pages, unswappable until it exits.
-                   Default: quarter of memory (chosen to not pin too much)
-
 pages_to_scan    - how many present pages to scan before ksmd goes to sleep
                    e.g. "echo 100 > /sys/kernel/mm/ksm/pages_to_scan"
                    Default: 100 (chosen for demonstration purposes)
@@ -75,7 +67,7 @@ run              - set 0 to stop ksmd from running but keep merged pages,
 
 The effectiveness of KSM and MADV_MERGEABLE is shown in /sys/kernel/mm/ksm/:
 
-pages_shared     - how many shared unswappable kernel pages KSM is using
+pages_shared     - how many shared pages are being used
 pages_sharing    - how many more sites are sharing them i.e. how much saved
 pages_unshared   - how many pages unique but repeatedly checked for merging
 pages_volatile   - how many pages changing too fast to be placed in a tree
@@ -87,4 +79,4 @@ pages_volatile embraces several different kinds of activity, but a high
 proportion there would also indicate poor use of madvise MADV_MERGEABLE.
 
 Izik Eidus,
-Hugh Dickins, 24 Sept 2009
+Hugh Dickins, 17 Nov 2009
index ea44ea502da1ef60e2a04b3ab9e42cf643ac7711..66e9358e2144233323e8b90ce75f9007999e7b2f 100644 (file)
@@ -1,11 +1,22 @@
 /*
  * page-types: Tool for querying page flags
  *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should find a copy of v2 of the GNU General Public License somewhere on
+ * your Linux system; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
  * Copyright (C) 2009 Intel corporation
  *
  * Authors: Wu Fengguang <fengguang.wu@intel.com>
- *
- * Released under the General Public License (GPL).
  */
 
 #define _LARGEFILE64_SOURCE
 #define BIT(name)              (1ULL << KPF_##name)
 #define BITS_COMPOUND          (BIT(COMPOUND_HEAD) | BIT(COMPOUND_TAIL))
 
-static char *page_flag_names[] = {
+static const char *page_flag_names[] = {
        [KPF_LOCKED]            = "L:locked",
        [KPF_ERROR]             = "E:error",
        [KPF_REFERENCED]        = "R:referenced",
@@ -173,7 +184,7 @@ static int          kpageflags_fd;
 static int             opt_hwpoison;
 static int             opt_unpoison;
 
-static char            *hwpoison_debug_fs = "/debug/hwpoison";
+static const char      hwpoison_debug_fs[] = "/debug/hwpoison";
 static int             hwpoison_inject_fd;
 static int             hwpoison_forget_fd;
 
@@ -560,7 +571,7 @@ static void walk_pfn(unsigned long voffset,
 {
        uint64_t buf[KPAGEFLAGS_BATCH];
        unsigned long batch;
-       unsigned long pages;
+       long pages;
        unsigned long i;
 
        while (count) {
@@ -673,30 +684,35 @@ static void usage(void)
 
        printf(
 "page-types [options]\n"
-"            -r|--raw                  Raw mode, for kernel developers\n"
-"            -a|--addr    addr-spec    Walk a range of pages\n"
-"            -b|--bits    bits-spec    Walk pages with specified bits\n"
-"            -p|--pid     pid          Walk process address space\n"
+"            -r|--raw                   Raw mode, for kernel developers\n"
+"            -d|--describe flags        Describe flags\n"
+"            -a|--addr    addr-spec     Walk a range of pages\n"
+"            -b|--bits    bits-spec     Walk pages with specified bits\n"
+"            -p|--pid     pid           Walk process address space\n"
 #if 0 /* planned features */
-"            -f|--file    filename     Walk file address space\n"
+"            -f|--file    filename      Walk file address space\n"
 #endif
-"            -l|--list                 Show page details in ranges\n"
-"            -L|--list-each            Show page details one by one\n"
-"            -N|--no-summary           Don't show summay info\n"
-"            -X|--hwpoison             hwpoison pages\n"
-"            -x|--unpoison             unpoison pages\n"
-"            -h|--help                 Show this usage message\n"
+"            -l|--list                  Show page details in ranges\n"
+"            -L|--list-each             Show page details one by one\n"
+"            -N|--no-summary            Don't show summay info\n"
+"            -X|--hwpoison              hwpoison pages\n"
+"            -x|--unpoison              unpoison pages\n"
+"            -h|--help                  Show this usage message\n"
+"flags:\n"
+"            0x10                       bitfield format, e.g.\n"
+"            anon                       bit-name, e.g.\n"
+"            0x10,anon                  comma-separated list, e.g.\n"
 "addr-spec:\n"
-"            N                         one page at offset N (unit: pages)\n"
-"            N+M                       pages range from N to N+M-1\n"
-"            N,M                       pages range from N to M-1\n"
-"            N,                        pages range from N to end\n"
-"            ,M                        pages range from 0 to M-1\n"
+"            N                          one page at offset N (unit: pages)\n"
+"            N+M                        pages range from N to N+M-1\n"
+"            N,M                        pages range from N to M-1\n"
+"            N,                         pages range from N to end\n"
+"            ,M                         pages range from 0 to M-1\n"
 "bits-spec:\n"
-"            bit1,bit2                 (flags & (bit1|bit2)) != 0\n"
-"            bit1,bit2=bit1            (flags & (bit1|bit2)) == bit1\n"
-"            bit1,~bit2                (flags & (bit1|bit2)) == bit1\n"
-"            =bit1,bit2                flags == (bit1|bit2)\n"
+"            bit1,bit2                  (flags & (bit1|bit2)) != 0\n"
+"            bit1,bit2=bit1             (flags & (bit1|bit2)) == bit1\n"
+"            bit1,~bit2                 (flags & (bit1|bit2)) == bit1\n"
+"            =bit1,bit2                 flags == (bit1|bit2)\n"
 "bit-names:\n"
        );
 
@@ -884,13 +900,23 @@ static void parse_bits_mask(const char *optarg)
        add_bits_filter(mask, bits);
 }
 
+static void describe_flags(const char *optarg)
+{
+       uint64_t flags = parse_flag_names(optarg, 0);
+
+       printf("0x%016llx\t%s\t%s\n",
+               (unsigned long long)flags,
+               page_flag_name(flags),
+               page_flag_longname(flags));
+}
 
-static struct option opts[] = {
+static const struct option opts[] = {
        { "raw"       , 0, NULL, 'r' },
        { "pid"       , 1, NULL, 'p' },
        { "file"      , 1, NULL, 'f' },
        { "addr"      , 1, NULL, 'a' },
        { "bits"      , 1, NULL, 'b' },
+       { "describe"  , 1, NULL, 'd' },
        { "list"      , 0, NULL, 'l' },
        { "list-each" , 0, NULL, 'L' },
        { "no-summary", 0, NULL, 'N' },
@@ -907,7 +933,7 @@ int main(int argc, char *argv[])
        page_size = getpagesize();
 
        while ((c = getopt_long(argc, argv,
-                               "rp:f:a:b:lLNXxh", opts, NULL)) != -1) {
+                               "rp:f:a:b:d:lLNXxh", opts, NULL)) != -1) {
                switch (c) {
                case 'r':
                        opt_raw = 1;
@@ -924,6 +950,9 @@ int main(int argc, char *argv[])
                case 'b':
                        parse_bits_mask(optarg);
                        break;
+               case 'd':
+                       describe_flags(optarg);
+                       exit(0);
                case 'l':
                        opt_list = 1;
                        break;
diff --git a/Kbuild b/Kbuild
index f056b4feee519748ae6ef22fde3df1da532e177b..e3737ad72b5a7ab8ad916b5b6b2725eaf89122a1 100644 (file)
--- a/Kbuild
+++ b/Kbuild
@@ -8,7 +8,7 @@
 #####
 # 1) Generate bounds.h
 
-bounds-file := include/linux/bounds.h
+bounds-file := include/generated/bounds.h
 
 always  := $(bounds-file)
 targets := $(bounds-file) kernel/bounds.s
@@ -43,7 +43,7 @@ $(obj)/$(bounds-file): kernel/bounds.s Kbuild
 # 2) Generate asm-offsets.h
 #
 
-offsets-file := include/asm/asm-offsets.h
+offsets-file := include/generated/asm-offsets.h
 
 always  += $(offsets-file)
 targets += $(offsets-file)
index 1f21c34124db44d77fabe9ed7f9b8b1decfb299b..66f5f7dab285660aa1aa970c8e8f09de85a2ff37 100644 (file)
@@ -835,13 +835,13 @@ F:        arch/arm/mach-pxa/palmte2.c
 F:     arch/arm/mach-pxa/include/mach/palmtc.h
 F:     arch/arm/mach-pxa/palmtc.c
 
-ARM/PALM TREO 680 SUPPORT
+ARM/PALM TREO SUPPORT
 M:     Tomas Cech <sleep_walker@suse.cz>
 L:     linux-arm-kernel@lists.infradead.org
 W:     http://hackndev.com
 S:     Maintained
-F:     arch/arm/mach-pxa/include/mach/treo680.h
-F:     arch/arm/mach-pxa/treo680.c
+F:     arch/arm/mach-pxa/include/mach/palmtreo.h
+F:     arch/arm/mach-pxa/palmtreo.c
 
 ARM/PALMZ72 SUPPORT
 M:     Sergey Lapin <slapin@ossfans.org>
@@ -1402,6 +1402,8 @@ L:        linux-usb@vger.kernel.org
 S:     Supported
 F:     Documentation/usb/WUSB-Design-overview.txt
 F:     Documentation/usb/wusb-cbaf
+F:     drivers/usb/host/hwa-hc.c
+F:     drivers/usb/host/whci/
 F:     drivers/usb/wusbcore/
 F:     include/linux/usb/wusb*
 
@@ -1470,6 +1472,12 @@ L:       linux-scsi@vger.kernel.org
 S:     Supported
 F:     drivers/scsi/fnic/
 
+CMPC ACPI DRIVER
+M:     Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+M:     Daniel Oliveira Nascimento <don@syst.com.br>
+S:     Supported
+F:     drivers/platform/x86/classmate-laptop.c
+
 CODA FILE SYSTEM
 M:     Jan Harkes <jaharkes@cs.cmu.edu>
 M:     coda@cs.cmu.edu
@@ -1482,8 +1490,8 @@ F:        include/linux/coda*.h
 
 COMMON INTERNET FILE SYSTEM (CIFS)
 M:     Steve French <sfrench@samba.org>
-L:     linux-cifs-client@lists.samba.org
-L:     samba-technical@lists.samba.org
+L:     linux-cifs-client@lists.samba.org (moderated for non-subscribers)
+L:     samba-technical@lists.samba.org (moderated for non-subscribers)
 W:     http://linux-cifs.samba.org/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6.git
 S:     Supported
@@ -2377,6 +2385,15 @@ W:       http://www.kernel.org/pub/linux/kernel/people/fseidel/hdaps/
 S:     Maintained
 F:     drivers/hwmon/hdaps.c
 
+HWPOISON MEMORY FAILURE HANDLING
+M:     Andi Kleen <andi@firstfloor.org>
+L:     linux-mm@kvack.org
+L:     linux-kernel@vger.kernel.org
+T:     git git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6.git hwpoison
+S:     Maintained
+F:     mm/memory-failure.c
+F:     mm/hwpoison-inject.c
+
 HYPERVISOR VIRTUAL CONSOLE DRIVER
 L:     linuxppc-dev@ozlabs.org
 S:     Odd Fixes
@@ -3081,8 +3098,11 @@ S:       Maintained
 F:     fs/autofs4/
 
 KERNEL BUILD
+M:     Michal Marek <mmarek@suse.cz>
+T:     git git://repo.or.cz/linux-kbuild.git for-next
+T:     git git://repo.or.cz/linux-kbuild.git for-linus
 L:     linux-kbuild@vger.kernel.org
-S:     Orphan
+S:     Maintained
 F:     Documentation/kbuild/
 F:     Makefile
 F:     scripts/Makefile.*
@@ -3124,7 +3144,6 @@ L:        kvm@vger.kernel.org
 W:     http://kvm.qumranet.com
 S:     Supported
 F:     arch/x86/include/asm/svm.h
-F:     arch/x86/kvm/kvm_svm.h
 F:     arch/x86/kvm/svm.c
 
 KERNEL VIRTUAL MACHINE (KVM) FOR POWERPC
@@ -3633,6 +3652,11 @@ W:       http://0pointer.de/lennart/tchibo.html
 S:     Maintained
 F:     drivers/platform/x86/msi-laptop.c
 
+MSI WMI SUPPORT
+M:     Anisse Astier <anisse@astier.eu>
+S:     Supported
+F:     drivers/platform/x86/msi-wmi.c
+
 MULTIFUNCTION DEVICES (MFD)
 M:     Samuel Ortiz <sameo@linux.intel.com>
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6.git
@@ -3666,7 +3690,7 @@ F:        include/linux/isicom.h
 MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER
 M:     Felipe Balbi <felipe.balbi@nokia.com>
 L:     linux-usb@vger.kernel.org
-T:     git git://gitorious.org/musb/mainline.git
+T:     git git://gitorious.org/usb/usb.git
 S:     Maintained
 F:     drivers/usb/musb/
 
@@ -5419,10 +5443,19 @@ ULTRA-WIDEBAND (UWB) SUBSYSTEM:
 M:     David Vrabel <david.vrabel@csr.com>
 L:     linux-usb@vger.kernel.org
 S:     Supported
-F:     drivers/uwb/*
+F:     drivers/uwb/
+X:     drivers/uwb/wlp/
+X:     drivers/uwb/i1480/i1480u-wlp/
+X:     drivers/uwb/i1480/i1480-wlp.h
 F:     include/linux/uwb.h
 F:     include/linux/uwb/
 
+UNIFDEF
+M:     Tony Finch <dot@dotat.at>
+W:     http://dotat.at/prog/unifdef
+S:     Maintained
+F:     scripts/unifdef.c
+
 UNIFORM CDROM DRIVER
 M:     Jens Axboe <axboe@kernel.dk>
 W:     http://www.kernel.dk
@@ -5926,9 +5959,12 @@ W:       http://linuxwimax.org
 
 WIMEDIA LLC PROTOCOL (WLP) SUBSYSTEM
 M:     David Vrabel <david.vrabel@csr.com>
+L:     netdev@vger.kernel.org
 S:     Maintained
 F:     include/linux/wlp.h
 F:     drivers/uwb/wlp/
+F:     drivers/uwb/i1480/i1480u-wlp/
+F:     drivers/uwb/i1480/i1480-wlp.h
 
 WISTRON LAPTOP BUTTON DRIVER
 M:     Miloslav Trmac <mitr@volny.cz>
@@ -5974,6 +6010,7 @@ M:        Mark Brown <broonie@opensource.wolfsonmicro.com>
 T:     git git://opensource.wolfsonmicro.com/linux-2.6-audioplus
 W:     http://opensource.wolfsonmicro.com/node/8
 S:     Supported
+F:     Documentation/hwmon/wm83??
 F:     drivers/leds/leds-wm83*.c
 F:     drivers/mfd/wm8*.c
 F:     drivers/power/wm83*.c
@@ -5983,14 +6020,14 @@ F:      drivers/video/backlight/wm83*_bl.c
 F:     drivers/watchdog/wm83*_wdt.c
 F:     include/linux/mfd/wm831x/
 F:     include/linux/mfd/wm8350/
-F:     include/linux/mfd/wm8400/
-F:     sound/soc/codecs/wm8350.c
-F:     sound/soc/codecs/wm8400.c
+F:     include/linux/mfd/wm8400*
+F:     sound/soc/codecs/wm8350.*
+F:     sound/soc/codecs/wm8400.*
 
 X.25 NETWORK LAYER
-M:     Henner Eisen <eis@baty.hanse.de>
+M:     Andrew Hendry <andrew.hendry@gmail.com>
 L:     linux-x25@vger.kernel.org
-S:     Maintained
+S:     Odd Fixes
 F:     Documentation/networking/x25*
 F:     include/net/x25*
 F:     net/x25/
index 33d4732a6c4a319c4479933c826dd37be489684b..c628a5cfe422d3109c7a0dfca812c03b58639e8c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 6
-SUBLEVEL = 32
-EXTRAVERSION =
+SUBLEVEL = 33
+EXTRAVERSION = -rc2
 NAME = Man-Eating Seals of Antiquity
 
 # *DOCUMENTATION*
@@ -16,6 +16,13 @@ NAME = Man-Eating Seals of Antiquity
 # o  print "Entering directory ...";
 MAKEFLAGS += -rR --no-print-directory
 
+# Avoid funny character set dependencies
+unexport LC_ALL
+LC_CTYPE=C
+LC_COLLATE=C
+LC_NUMERIC=C
+export LC_CTYPE LC_COLLATE LC_NUMERIC
+
 # We are using a recursive build, so we need to do a little thinking
 # to get the ordering right.
 #
@@ -334,10 +341,9 @@ CFLAGS_GCOV        = -fprofile-arcs -ftest-coverage
 
 # Use LINUXINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
-LINUXINCLUDE    := -Iinclude \
-                   $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
-                   -I$(srctree)/arch/$(hdr-arch)/include               \
-                   -include include/linux/autoconf.h
+LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
+                   $(if $(KBUILD_SRC), -I$(srctree)/include) \
+                   -include include/generated/autoconf.h
 
 KBUILD_CPPFLAGS := -D__KERNEL__
 
@@ -465,7 +471,7 @@ ifeq ($(KBUILD_EXTMOD),)
 # Carefully list dependencies so we do not try to build scripts twice
 # in parallel
 PHONY += scripts
-scripts: scripts_basic include/config/auto.conf
+scripts: scripts_basic include/config/auto.conf include/config/tristate.conf
        $(Q)$(MAKE) $(build)=$(@)
 
 # Objects we will link into vmlinux / subdirs we need to visit
@@ -492,18 +498,18 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
 # with it and forgot to run make oldconfig.
 # if auto.conf.cmd is missing then we are probably in a cleaned tree so
 # we execute the config step to be sure to catch updated Kconfig files
-include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
+include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
        $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
 else
-# external modules needs include/linux/autoconf.h and include/config/auto.conf
+# external modules needs include/generated/autoconf.h and include/config/auto.conf
 # but do not care if they are up-to-date. Use auto.conf to trigger the test
 PHONY += include/config/auto.conf
 
 include/config/auto.conf:
-       $(Q)test -e include/linux/autoconf.h -a -e $@ || (              \
+       $(Q)test -e include/generated/autoconf.h -a -e $@ || (          \
        echo;                                                           \
        echo "  ERROR: Kernel configuration is invalid.";               \
-       echo "         include/linux/autoconf.h or $@ are missing.";    \
+       echo "         include/generated/autoconf.h or $@ are missing.";\
        echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
        echo;                                                           \
        /bin/false)
@@ -877,6 +883,9 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
 PHONY += $(vmlinux-dirs)
 $(vmlinux-dirs): prepare scripts
        $(Q)$(MAKE) $(build)=$@
+ifdef CONFIG_MODULES
+       $(Q)$(MAKE) $(modbuiltin)=$@
+endif
 
 # Build the kernel release string
 #
@@ -955,7 +964,6 @@ PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
 # prepare3 is used to check if we are building in a separate output directory,
 # and if so do:
 # 1) Check that make has not been executed in the kernel src $(srctree)
-# 2) Create the include2 directory, used for the second asm symlink
 prepare3: include/config/kernel.release
 ifneq ($(KBUILD_SRC),)
        @$(kecho) '  Using $(srctree) as source for kernel'
@@ -964,17 +972,13 @@ ifneq ($(KBUILD_SRC),)
                echo "  in the '$(srctree)' directory.";\
                /bin/false; \
        fi;
-       $(Q)if [ ! -d include2 ]; then                                  \
-           mkdir -p include2;                                          \
-           ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm;     \
-       fi
 endif
 
 # prepare2 creates a makefile if using a separate output directory
 prepare2: prepare3 outputmakefile
 
-prepare1: prepare2 include/linux/version.h include/linux/utsrelease.h \
-                   include/asm include/config/auto.conf
+prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
+                   include/config/auto.conf
        $(cmd_crmodverdir)
 
 archprepare: prepare1 scripts_basic
@@ -986,42 +990,6 @@ prepare0: archprepare FORCE
 # All the preparing..
 prepare: prepare0
 
-# The asm symlink changes when $(ARCH) changes.
-# Detect this and ask user to run make mrproper
-# If asm is a stale symlink (point to dir that does not exist) remove it
-define check-symlink
-       set -e;                                                            \
-       if [ -L include/asm ]; then                                        \
-               asmlink=`readlink include/asm | cut -d '-' -f 2`;          \
-               if [ "$$asmlink" != "$(SRCARCH)" ]; then                   \
-                       echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
-                       echo "       set ARCH or save .config and run 'make mrproper' to fix it";             \
-                       exit 1;                                            \
-               fi;                                                        \
-               test -e $$asmlink || rm include/asm;                       \
-       elif [ -d include/asm ]; then                                      \
-               echo "ERROR: $@ is a directory but a symlink was expected";\
-               exit 1;                                                    \
-       fi
-endef
-
-# We create the target directory of the symlink if it does
-# not exist so the test in check-symlink works and we have a
-# directory for generated filesas used by some architectures.
-define create-symlink
-       if [ ! -L include/asm ]; then                                      \
-                       $(kecho) '  SYMLINK $@ -> include/asm-$(SRCARCH)'; \
-                       if [ ! -d include/asm-$(SRCARCH) ]; then           \
-                               mkdir -p include/asm-$(SRCARCH);           \
-                       fi;                                                \
-                       ln -fsn asm-$(SRCARCH) $@;                         \
-       fi
-endef
-
-include/asm: FORCE
-       $(Q)$(check-symlink)
-       $(Q)$(create-symlink)
-
 # Generate some files
 # ---------------------------------------------------------------------------
 
@@ -1046,7 +1014,7 @@ endef
 include/linux/version.h: $(srctree)/Makefile FORCE
        $(call filechk,version.h)
 
-include/linux/utsrelease.h: include/config/kernel.release FORCE
+include/generated/utsrelease.h: include/config/kernel.release FORCE
        $(call filechk,utsrelease.h)
 
 PHONY += headerdep
@@ -1076,11 +1044,6 @@ firmware_install: FORCE
 export INSTALL_HDR_PATH = $(objtree)/usr
 
 hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
-# Find out where the Kbuild file is located to support
-# arch/$(ARCH)/include/asm
-hdr-dir = $(strip                                                         \
-          $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild), \
-               arch/$(hdr-arch)/include/asm, include/asm-$(hdr-arch)))
 
 # If we do an all arch process set dst to asm-$(hdr-arch)
 hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
@@ -1095,10 +1058,10 @@ headers_install_all:
 
 PHONY += headers_install
 headers_install: __headers
-       $(if $(wildcard $(srctree)/$(hdr-dir)/Kbuild),, \
+       $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild),, \
        $(error Headers not exportable for the $(SRCARCH) architecture))
        $(Q)$(MAKE) $(hdr-inst)=include
-       $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst)
+       $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/asm $(hdr-dst)
 
 PHONY += headers_check_all
 headers_check_all: headers_install_all
@@ -1107,7 +1070,7 @@ headers_check_all: headers_install_all
 PHONY += headers_check
 headers_check: headers_install
        $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1
-       $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst) HDRCHECK=1
+       $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/asm $(hdr-dst) HDRCHECK=1
 
 # ---------------------------------------------------------------------------
 # Modules
@@ -1127,6 +1090,7 @@ all: modules
 PHONY += modules
 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
        $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
+       $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.builtin) > $(objtree)/modules.builtin
        @$(kecho) '  Building modules, stage 2.';
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
@@ -1156,6 +1120,7 @@ _modinst_:
                ln -s $(objtree) $(MODLIB)/build ; \
        fi
        @cp -f $(objtree)/modules.order $(MODLIB)/
+       @cp -f $(objtree)/modules.builtin $(MODLIB)/
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
 
 # This depmod is only for convenience to give the initial
@@ -1194,12 +1159,10 @@ CLEAN_FILES +=  vmlinux System.map \
                 .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
 
 # Directories & files removed with 'make mrproper'
-MRPROPER_DIRS  += include/config include2 usr/include include/generated
-MRPROPER_FILES += .config .config.old include/asm .version .old_version \
-                  include/linux/autoconf.h include/linux/version.h      \
-                  include/linux/utsrelease.h                            \
-                  include/linux/bounds.h include/asm*/asm-offsets.h     \
-                 Module.symvers Module.markers tags TAGS cscope*
+MRPROPER_DIRS  += include/config usr/include include/generated
+MRPROPER_FILES += .config .config.old .version .old_version             \
+                  include/linux/version.h                               \
+                 Module.symvers tags TAGS cscope*
 
 # clean - Delete most, but leave enough to build external modules
 #
@@ -1218,7 +1181,7 @@ clean: archclean $(clean-dirs)
                \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
                -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
                -o -name '*.symtypes' -o -name 'modules.order' \
-               -o -name 'Module.markers' -o -name '.tmp_*.o.*' \
+               -o -name modules.builtin -o -name '.tmp_*.o.*' \
                -o -name '*.gcno' \) -type f -print | xargs rm -f
 
 # mrproper - Delete all generated files, including .config
@@ -1416,8 +1379,8 @@ $(clean-dirs):
 
 clean: rm-dirs := $(MODVERDIR)
 clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \
-                   $(KBUILD_EXTMOD)/Module.markers \
-                   $(KBUILD_EXTMOD)/modules.order
+                   $(KBUILD_EXTMOD)/modules.order \
+                   $(KBUILD_EXTMOD)/modules.builtin
 clean: $(clean-dirs)
        $(call cmd,rmdirs)
        $(call cmd,rmfiles)
index d82875820a15a318134490eeb599802db209c4b7..9d055b4f058556450363c3843ad17f07518fae93 100644 (file)
@@ -135,9 +135,7 @@ config HAVE_DEFAULT_NO_SPIN_MUTEXES
 
 config HAVE_HW_BREAKPOINT
        bool
-       depends on HAVE_PERF_EVENTS
-       select ANON_INODES
-       select PERF_EVENTS
+       depends on PERF_EVENTS
 
 config HAVE_USER_RETURN_NOTIFIER
        bool
index 443448154f32e9c7143ca759fe32ee475f9e818e..bd7261ea8f9401adcf96e7df1664a9042401cdd6 100644 (file)
@@ -9,6 +9,7 @@ config ALPHA
        select HAVE_IDE
        select HAVE_OPROFILE
        select HAVE_SYSCALL_WRAPPERS
+       select HAVE_PERF_EVENTS
        help
          The Alpha is a 64-bit general-purpose processor designed and
          marketed by the Digital Equipment Corporation of blessed memory,
index 3af21c78933943df7e3750b3d61d3fd391581b87..3c8d1b25c66105b3fb34f9b693c712d9b3d05d52 100644 (file)
@@ -9,7 +9,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/mm.h>
 
 #include <asm/system.h>
index 1036b515e20c80f55fa04db8c8dbd88ac7c749c0..ade3f129dc2722e26168495bdc28066d24fcd609 100644 (file)
@@ -11,7 +11,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/mm.h>
 
 #include <asm/system.h>
index 89f3be071ae5df5f947c7d7ee9fb888e93fa2912..644b7db55438f4f1d1b8136bd9f680bbcf4f75a8 100644 (file)
@@ -7,7 +7,7 @@
  */
 #include <linux/kernel.h>
 #include <linux/string.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/mm.h>
 
 #include <asm/system.h>
diff --git a/arch/alpha/include/asm/asm-offsets.h b/arch/alpha/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 1720c8ad86fec780ca054e42ed8baaa21735e899..f091682e3cc84b4a9bffccc136147870b42fa6e0 100644 (file)
@@ -13,7 +13,8 @@
                "call_pal %0  # bugchk\n\t"                             \
                ".long %1\n\t.8byte %2"                                 \
                : : "i"(PAL_bugchk), "i"(__LINE__), "i"(__FILE__));     \
-       for ( ; ; ); } while (0)
+       unreachable();                                                  \
+  } while (0)
 
 #define HAVE_ARCH_BUG
 #endif
index 46bfff58f67093877e4815a30c6c165d9be192d3..471c07292e0b88f881393036b46ea3594f106b50 100644 (file)
@@ -435,7 +435,7 @@ extern inline void t2_outl(u32 b, unsigned long addr)
        set_hae(msb); \
 }
 
-extern spinlock_t t2_hae_lock;
+extern raw_spinlock_t t2_hae_lock;
 
 /*
  * NOTE: take T2_DENSE_MEM off in each readX/writeX routine, since
@@ -448,12 +448,12 @@ __EXTERN_INLINE u8 t2_readb(const volatile void __iomem *xaddr)
        unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
        unsigned long result, msb;
        unsigned long flags;
-       spin_lock_irqsave(&t2_hae_lock, flags);
+       raw_spin_lock_irqsave(&t2_hae_lock, flags);
 
        t2_set_hae;
 
        result = *(vip) ((addr << 5) + T2_SPARSE_MEM + 0x00);
-       spin_unlock_irqrestore(&t2_hae_lock, flags);
+       raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
        return __kernel_extbl(result, addr & 3);
 }
 
@@ -462,12 +462,12 @@ __EXTERN_INLINE u16 t2_readw(const volatile void __iomem *xaddr)
        unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
        unsigned long result, msb;
        unsigned long flags;
-       spin_lock_irqsave(&t2_hae_lock, flags);
+       raw_spin_lock_irqsave(&t2_hae_lock, flags);
 
        t2_set_hae;
 
        result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08);
-       spin_unlock_irqrestore(&t2_hae_lock, flags);
+       raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
        return __kernel_extwl(result, addr & 3);
 }
 
@@ -480,12 +480,12 @@ __EXTERN_INLINE u32 t2_readl(const volatile void __iomem *xaddr)
        unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
        unsigned long result, msb;
        unsigned long flags;
-       spin_lock_irqsave(&t2_hae_lock, flags);
+       raw_spin_lock_irqsave(&t2_hae_lock, flags);
 
        t2_set_hae;
 
        result = *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18);
-       spin_unlock_irqrestore(&t2_hae_lock, flags);
+       raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
        return result & 0xffffffffUL;
 }
 
@@ -494,14 +494,14 @@ __EXTERN_INLINE u64 t2_readq(const volatile void __iomem *xaddr)
        unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
        unsigned long r0, r1, work, msb;
        unsigned long flags;
-       spin_lock_irqsave(&t2_hae_lock, flags);
+       raw_spin_lock_irqsave(&t2_hae_lock, flags);
 
        t2_set_hae;
 
        work = (addr << 5) + T2_SPARSE_MEM + 0x18;
        r0 = *(vuip)(work);
        r1 = *(vuip)(work + (4 << 5));
-       spin_unlock_irqrestore(&t2_hae_lock, flags);
+       raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
        return r1 << 32 | r0;
 }
 
@@ -510,13 +510,13 @@ __EXTERN_INLINE void t2_writeb(u8 b, volatile void __iomem *xaddr)
        unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
        unsigned long msb, w;
        unsigned long flags;
-       spin_lock_irqsave(&t2_hae_lock, flags);
+       raw_spin_lock_irqsave(&t2_hae_lock, flags);
 
        t2_set_hae;
 
        w = __kernel_insbl(b, addr & 3);
        *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x00) = w;
-       spin_unlock_irqrestore(&t2_hae_lock, flags);
+       raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
 }
 
 __EXTERN_INLINE void t2_writew(u16 b, volatile void __iomem *xaddr)
@@ -524,13 +524,13 @@ __EXTERN_INLINE void t2_writew(u16 b, volatile void __iomem *xaddr)
        unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
        unsigned long msb, w;
        unsigned long flags;
-       spin_lock_irqsave(&t2_hae_lock, flags);
+       raw_spin_lock_irqsave(&t2_hae_lock, flags);
 
        t2_set_hae;
 
        w = __kernel_inswl(b, addr & 3);
        *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x08) = w;
-       spin_unlock_irqrestore(&t2_hae_lock, flags);
+       raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
 }
 
 /*
@@ -542,12 +542,12 @@ __EXTERN_INLINE void t2_writel(u32 b, volatile void __iomem *xaddr)
        unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
        unsigned long msb;
        unsigned long flags;
-       spin_lock_irqsave(&t2_hae_lock, flags);
+       raw_spin_lock_irqsave(&t2_hae_lock, flags);
 
        t2_set_hae;
 
        *(vuip) ((addr << 5) + T2_SPARSE_MEM + 0x18) = b;
-       spin_unlock_irqrestore(&t2_hae_lock, flags);
+       raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
 }
 
 __EXTERN_INLINE void t2_writeq(u64 b, volatile void __iomem *xaddr)
@@ -555,14 +555,14 @@ __EXTERN_INLINE void t2_writeq(u64 b, volatile void __iomem *xaddr)
        unsigned long addr = (unsigned long) xaddr - T2_DENSE_MEM;
        unsigned long msb, work;
        unsigned long flags;
-       spin_lock_irqsave(&t2_hae_lock, flags);
+       raw_spin_lock_irqsave(&t2_hae_lock, flags);
 
        t2_set_hae;
 
        work = (addr << 5) + T2_SPARSE_MEM + 0x18;
        *(vuip)work = b;
        *(vuip)(work + (4 << 5)) = b >> 32;
-       spin_unlock_irqrestore(&t2_hae_lock, flags);
+       raw_spin_unlock_irqrestore(&t2_hae_lock, flags);
 }
 
 __EXTERN_INLINE void __iomem *t2_ioportmap(unsigned long addr)
index 5c75c1b2352a9cacf7c47de5c04d57b1bab7211b..9baae8afe8a372d20e88537691fc555d8dd6bb6d 100644 (file)
@@ -81,7 +81,6 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 #define ELF_DATA       ELFDATA2LSB
 #define ELF_ARCH       EM_ALPHA
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      8192
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
index 21b1117a0c61344af1acc94c36dc2f6e475d67a0..70145cbb21cb48ff27cbbe949d0c519f6bd55565 100644 (file)
@@ -16,7 +16,7 @@
 #define O_NOATIME      04000000
 #define O_CLOEXEC      010000000 /* set close_on_exec */
 /*
- * Before Linux 2.6.32 only O_DSYNC semantics were implemented, but using
+ * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
  * the O_SYNC flag.  We continue to use the existing numerical value
  * for O_DSYNC semantics now, but using the correct symbolic name for it.
  * This new value is used to request true Posix O_SYNC semantics.  It is
diff --git a/arch/alpha/include/asm/perf_event.h b/arch/alpha/include/asm/perf_event.h
new file mode 100644 (file)
index 0000000..3bef852
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef __ASM_ALPHA_PERF_EVENT_H
+#define __ASM_ALPHA_PERF_EVENT_H
+
+/* Alpha only supports software events through this interface. */
+static inline void set_perf_event_pending(void) { }
+
+#define PERF_EVENT_INDEX_OFFSET 0
+
+#endif /* __ASM_ALPHA_PERF_EVENT_H */
index e38fb95cb3352fd15c5bf3e505459bc8f702500f..d0faca1e992df0ffc9ca0ed12408e132da9b798a 100644 (file)
  * We make no fairness assumptions. They have a cost.
  */
 
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
-#define __raw_spin_is_locked(x)        ((x)->lock != 0)
-#define __raw_spin_unlock_wait(x) \
+#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
+#define arch_spin_is_locked(x) ((x)->lock != 0)
+#define arch_spin_unlock_wait(x) \
                do { cpu_relax(); } while ((x)->lock)
 
-static inline void __raw_spin_unlock(raw_spinlock_t * lock)
+static inline void arch_spin_unlock(arch_spinlock_t * lock)
 {
        mb();
        lock->lock = 0;
 }
 
-static inline void __raw_spin_lock(raw_spinlock_t * lock)
+static inline void arch_spin_lock(arch_spinlock_t * lock)
 {
        long tmp;
 
@@ -43,24 +43,24 @@ static inline void __raw_spin_lock(raw_spinlock_t * lock)
        : "m"(lock->lock) : "memory");
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        return !test_and_set_bit(0, &lock->lock);
 }
 
 /***********************************************************/
 
-static inline int __raw_read_can_lock(raw_rwlock_t *lock)
+static inline int arch_read_can_lock(arch_rwlock_t *lock)
 {
        return (lock->lock & 1) == 0;
 }
 
-static inline int __raw_write_can_lock(raw_rwlock_t *lock)
+static inline int arch_write_can_lock(arch_rwlock_t *lock)
 {
        return lock->lock == 0;
 }
 
-static inline void __raw_read_lock(raw_rwlock_t *lock)
+static inline void arch_read_lock(arch_rwlock_t *lock)
 {
        long regx;
 
@@ -80,7 +80,7 @@ static inline void __raw_read_lock(raw_rwlock_t *lock)
        : "m" (*lock) : "memory");
 }
 
-static inline void __raw_write_lock(raw_rwlock_t *lock)
+static inline void arch_write_lock(arch_rwlock_t *lock)
 {
        long regx;
 
@@ -100,7 +100,7 @@ static inline void __raw_write_lock(raw_rwlock_t *lock)
        : "m" (*lock) : "memory");
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t * lock)
+static inline int arch_read_trylock(arch_rwlock_t * lock)
 {
        long regx;
        int success;
@@ -122,7 +122,7 @@ static inline int __raw_read_trylock(raw_rwlock_t * lock)
        return success;
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t * lock)
+static inline int arch_write_trylock(arch_rwlock_t * lock)
 {
        long regx;
        int success;
@@ -144,7 +144,7 @@ static inline int __raw_write_trylock(raw_rwlock_t * lock)
        return success;
 }
 
-static inline void __raw_read_unlock(raw_rwlock_t * lock)
+static inline void arch_read_unlock(arch_rwlock_t * lock)
 {
        long regx;
        __asm__ __volatile__(
@@ -160,17 +160,17 @@ static inline void __raw_read_unlock(raw_rwlock_t * lock)
        : "m" (*lock) : "memory");
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t * lock)
+static inline void arch_write_unlock(arch_rwlock_t * lock)
 {
        mb();
        lock->lock = 0;
 }
 
-#define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock)
-#define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock)
+#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* _ALPHA_SPINLOCK_H */
index 8141eb5ebf0d207705f74a29364aec095339864d..54c2afce0a1d7a4b117d4fd5332cb77bee787e62 100644 (file)
@@ -7,14 +7,14 @@
 
 typedef struct {
        volatile unsigned int lock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        volatile unsigned int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { 0 }
+#define __ARCH_RW_LOCK_UNLOCKED                { 0 }
 
 #endif
index 7f23665122dfabda7f6e9d666164d6b5f277b344..804e5311c84188fbc14a62b7afb97bc35a232003 100644 (file)
 #define __IGNORE_pause
 #define __IGNORE_time
 #define __IGNORE_utime
+#define __IGNORE_umount2
 
 /*
  * Linux-specific system calls begin at 300
 #define __NR_timerfd                   477
 #define __NR_eventfd                   478
 #define __NR_recvmmsg                  479
+#define __NR_fallocate                 480
+#define __NR_timerfd_create            481
+#define __NR_timerfd_settime           482
+#define __NR_timerfd_gettime           483
+#define __NR_signalfd4                 484
+#define __NR_eventfd2                  485
+#define __NR_epoll_create1             486
+#define __NR_dup3                      487
+#define __NR_pipe2                     488
+#define __NR_inotify_init1             489
+#define __NR_preadv                    490
+#define __NR_pwritev                   491
+#define __NR_rt_tgsigqueueinfo         492
+#define __NR_perf_event_open           493
 
 #ifdef __KERNEL__
 
-#define NR_SYSCALLS                    480
+#define NR_SYSCALLS                    494
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
index d9980d47ab81adbcdd0bfb0d4ca80dc2a04cf22e..e6d90568b65d62a378525dfaf0af8fe3366d160f 100644 (file)
@@ -74,7 +74,7 @@
 # define DBG(args)
 #endif
 
-DEFINE_SPINLOCK(t2_hae_lock);
+DEFINE_RAW_SPINLOCK(t2_hae_lock);
 
 static volatile unsigned int t2_mcheck_any_expected;
 static volatile unsigned int t2_mcheck_last_taken;
index c0de072b8305bab3c507b96f92da2536aab9667c..5f2cf23c4648f9d7173fe047448459fc8ff6d752 100644 (file)
@@ -81,7 +81,7 @@ show_interrupts(struct seq_file *p, void *v)
 #endif
 
        if (irq < ACTUAL_NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[irq].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[irq].lock, flags);
                action = irq_desc[irq].action;
                if (!action) 
                        goto unlock;
@@ -105,7 +105,7 @@ show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 unlock:
-               spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
        } else if (irq == ACTUAL_NR_IRQS) {
 #ifdef CONFIG_SMP
                seq_puts(p, "IPI: ");
index d12af472e1c0ec4aa380e8bdc73aab15627d7a2c..dbbf04f9230ed0890011e8c63a2db30f8e8d94fe 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <asm/console.h>
 #include <asm/uaccess.h>
 #include <asm/machvec.h>
@@ -79,42 +80,41 @@ static srm_env_t    srm_named_entries[] = {
 static srm_env_t       srm_numbered_entries[256];
 
 
-static int
-srm_env_read(char *page, char **start, off_t off, int count, int *eof,
-               void *data)
+static int srm_env_proc_show(struct seq_file *m, void *v)
 {
-       int             nbytes;
        unsigned long   ret;
        srm_env_t       *entry;
+       char            *page;
 
-       if (off != 0) {
-               *eof = 1;
-               return 0;
-       }
+       entry = (srm_env_t *)m->private;
+       page = (char *)__get_free_page(GFP_USER);
+       if (!page)
+               return -ENOMEM;
 
-       entry   = (srm_env_t *) data;
-       ret     = callback_getenv(entry->id, page, count);
+       ret = callback_getenv(entry->id, page, PAGE_SIZE);
 
        if ((ret >> 61) == 0) {
-               nbytes = (int) ret;
-               *eof = 1;
+               seq_write(m, page, ret);
+               ret = 0;
        } else
-               nbytes = -EFAULT;
+               ret = -EFAULT;
+       free_page((unsigned long)page);
+       return ret;
+}
 
-       return nbytes;
+static int srm_env_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, srm_env_proc_show, PDE(inode)->data);
 }
 
-static int
-srm_env_write(struct file *file, const char __user *buffer, unsigned long count,
-               void *data)
+static ssize_t srm_env_proc_write(struct file *file, const char __user *buffer,
+                                 size_t count, loff_t *pos)
 {
        int res;
-       srm_env_t       *entry;
+       srm_env_t       *entry = PDE(file->f_path.dentry->d_inode)->data;
        char            *buf = (char *) __get_free_page(GFP_USER);
        unsigned long   ret1, ret2;
 
-       entry = (srm_env_t *) data;
-
        if (!buf)
                return -ENOMEM;
 
@@ -140,6 +140,15 @@ srm_env_write(struct file *file, const char __user *buffer, unsigned long count,
        return res;
 }
 
+static const struct file_operations srm_env_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = srm_env_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = srm_env_proc_write,
+};
+
 static void
 srm_env_cleanup(void)
 {
@@ -245,15 +254,10 @@ srm_env_init(void)
         */
        entry = srm_named_entries;
        while (entry->name && entry->id) {
-               entry->proc_entry = create_proc_entry(entry->name,
-                               0644, named_dir);
+               entry->proc_entry = proc_create_data(entry->name, 0644, named_dir,
+                                                    &srm_env_proc_fops, entry);
                if (!entry->proc_entry)
                        goto cleanup;
-
-               entry->proc_entry->data         = (void *) entry;
-               entry->proc_entry->read_proc    = srm_env_read;
-               entry->proc_entry->write_proc   = srm_env_write;
-
                entry++;
        }
 
@@ -264,15 +268,12 @@ srm_env_init(void)
                entry = &srm_numbered_entries[var_num];
                entry->name = number[var_num];
 
-               entry->proc_entry = create_proc_entry(entry->name,
-                               0644, numbered_dir);
+               entry->proc_entry = proc_create_data(entry->name, 0644, numbered_dir,
+                                                    &srm_env_proc_fops, entry);
                if (!entry->proc_entry)
                        goto cleanup;
 
                entry->id                       = var_num;
-               entry->proc_entry->data         = (void *) entry;
-               entry->proc_entry->read_proc    = srm_env_read;
-               entry->proc_entry->write_proc   = srm_env_write;
        }
 
        printk(KERN_INFO "%s: version %s loaded successfully\n", NAME,
index cda6b8b3d573cb9322acf887e507c5503fe4ba6a..09acb786e72b0d665d3aa9e38346148adbdb08c5 100644 (file)
@@ -495,9 +495,23 @@ sys_call_table:
        .quad sys_epoll_pwait
        .quad sys_utimensat                     /* 475 */
        .quad sys_signalfd
-       .quad sys_ni_syscall
+       .quad sys_ni_syscall                    /* sys_timerfd */
        .quad sys_eventfd
        .quad sys_recvmmsg
+       .quad sys_fallocate                             /* 480 */
+       .quad sys_timerfd_create
+       .quad sys_timerfd_settime
+       .quad sys_timerfd_gettime
+       .quad sys_signalfd4
+       .quad sys_eventfd2                              /* 485 */
+       .quad sys_epoll_create1
+       .quad sys_dup3
+       .quad sys_pipe2
+       .quad sys_inotify_init1
+       .quad sys_preadv                                /* 490 */
+       .quad sys_pwritev
+       .quad sys_rt_tgsigqueueinfo
+       .quad sys_perf_event_open
 
        .size sys_call_table, . - sys_call_table
        .type sys_call_table, @object
index fa0cdab2e1d3109d75418f2022314dd796f8f0da..e9da08483b3cdb74bd687cf3601ec4dccf395c25 100644 (file)
@@ -242,15 +242,8 @@ all:       $(KBUILD_IMAGE)
 
 boot := arch/arm/boot
 
-#      Update machine arch and proc symlinks if something which affects
-#      them changed.  We use .arch to indicate when they were updated
-#      last, otherwise make uses the target directory mtime.
-
-archprepare: maketools
-
-PHONY += maketools FORCE
-maketools: include/linux/version.h FORCE
-       $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h
+archprepare:
+       $(Q)$(MAKE) $(build)=arch/arm/tools include/generated/mach-types.h
 
 # Convert bzImage to zImage
 bzImage: zImage
@@ -261,9 +254,6 @@ zImage Image xipImage bootpImage uImage: vmlinux
 zinstall install: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@
 
-CLEAN_FILES += include/asm-arm/mach-types.h \
-              include/asm-arm/arch include/asm-arm/.arch
-
 # We use MRPROPER_FILES and CLEAN_FILES now
 archclean:
        $(Q)$(MAKE) $(clean)=$(boot)
index 5a375e5fef21766c3a5120c16c7cd2f8929b42ea..cc32c1e54a59825dc93fcbba098fcdbd51d9c8f0 100644 (file)
@@ -308,15 +308,11 @@ static inline void unmap_single(struct device *dev, dma_addr_t dma_addr,
                        memcpy(ptr, buf->safe, size);
 
                        /*
-                        * DMA buffers must have the same cache properties
-                        * as if they were really used for DMA - which means
-                        * data must be written back to RAM.  Note that
-                        * we don't use dmac_flush_range() here for the
-                        * bidirectional case because we know the cache
-                        * lines will be coherent with the data written.
+                        * Since we may have written to a page cache page,
+                        * we need to ensure that the data will be coherent
+                        * with user mappings.
                         */
-                       dmac_clean_range(ptr, ptr + size);
-                       outer_clean_range(__pa(ptr), __pa(ptr) + size);
+                       __cpuc_flush_dcache_area(ptr, size);
                }
                free_safe_buffer(dev->archdata.dmabounce, buf);
        }
index 1cab4e79d3689bc7949955ac07ad38d9cfc33915..6e32a85641a75b9f923ba71bbfd51bb36a5de42c 100644 (file)
@@ -187,7 +187,6 @@ CONFIG_MACH_ACS5K=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM922T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 8e3d084afd78b0a557669979d803de1df2731bc6..b34b1eabac3b417f33e162d6c22953e511b6ae5e 100644 (file)
@@ -186,7 +186,6 @@ CONFIG_MACH_ACS5K=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM922T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index f7a272cb3da0a8e5a01685de2796aeb9b801790e..64fe7f10c12afeb4537e476e4e056cf285ec8ac0 100644 (file)
@@ -227,7 +227,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 5e68420f468046c306386e1f05275d0902ae3aea..30927cac6a9a17032395470b80310db8922f9b58 100644 (file)
@@ -189,7 +189,6 @@ CONFIG_PXA25x=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index ad54e92dd4366145cf486f41983b8c549af873f5..abe9966781ce7c6b0d2f215b3b908b13fcf4ade7 100644 (file)
@@ -233,7 +233,6 @@ CONFIG_MACH_OMAP3517EVM=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index e8f7380b67d65ba3117d04e2bf55b946c8cfc31a..3b3a3775bbf455ac413f7961366c48752a225991 100644 (file)
@@ -210,7 +210,6 @@ CONFIG_OMAP_ARM_150MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM925T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index c66dd399e426fcba5b81807e2037b7510beb974d..daa75bc98d46f334bec1aa0b54d6ab713fad8659 100644 (file)
@@ -101,7 +101,6 @@ CONFIG_SA1100_ASSABET=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index bc6bd9f6174d50da82c73c783be7896b5f7ab1b1..b1ab50bee461b97c572d855f90f0e44f6bec2a11 100644 (file)
@@ -181,7 +181,6 @@ CONFIG_AT91_TIMER_HZ=100
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index c97e1022ada130c9858042e94f2da0a08b9267eb..1fffec86a113262127bc89217296091c1128c9c2 100644 (file)
@@ -130,7 +130,6 @@ CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
index 9f7a99ace514d9c49df372d49ade7e947eb3f546..c846a795d1d5f7e1024598d2fc84fa8f783548ba 100644 (file)
@@ -129,7 +129,6 @@ CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
index 98e2f3de4bc5819420c7f538fdfd2937a682e692..472ea11eedf14526904c701dd8102784ccead037 100644 (file)
@@ -188,7 +188,6 @@ CONFIG_AT91_TIMER_HZ=100
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 149456142392b84d2a12d9cdd92b08d0595175c3..4ecde429cf15c42fe3cd11a2355548692c4ce91d 100644 (file)
@@ -181,7 +181,6 @@ CONFIG_AT91_TIMER_HZ=100
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 21599f3c6275bc98fafe4331490cc17e853fef92..9b792b60c7ffaac77eab86aa109fe0a8ad052a81 100644 (file)
@@ -181,7 +181,6 @@ CONFIG_AT91_TIMER_HZ=100
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 7e018a04c31bd3aadad2a2ebbed2a80c6677127f..64ce106d53eb4a9bfa46cbec7db4268a8dcac256 100644 (file)
@@ -187,7 +187,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index e2df81a3e804199da7b3701924df98db70ede1a8..90e48bfda16f99bb1103b06e46bb445ce31903ee 100644 (file)
@@ -179,7 +179,6 @@ CONFIG_AT91_TIMER_HZ=100
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index a19e824cf7f8e6397a9d9a9e42f8ff70eb86d203..6315534976cf32486a5c81096259ee481024f931 100644 (file)
@@ -132,7 +132,6 @@ CONFIG_MACH_ATEB9200=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
index f264846218a2a7760674e981b2cea53510980c1c..b175b6b8feb4d454a4d2b03bd56a50a27d5858b1 100644 (file)
@@ -103,7 +103,6 @@ CONFIG_SA1100_BADGE4=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index bcc0bac551a5812ccb3de9e8b05fd0e6db96650b..1e12167c89b7210abad6f3a789cdc4d595d89fd7 100644 (file)
@@ -181,7 +181,6 @@ CONFIG_BCM_ZRELADDR=0x8000
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_32v6=y
index 8448108347cfeb9ec844b5084b33996b44287223..eef33de3ca1225ea09df1d739aed7ec7ddd33f3c 100644 (file)
@@ -196,7 +196,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index d392833b31fbb40bf30f481218854a5244eb77a5..b6a706306781986c5e2ba2163320ba4a4ec22e3a 100644 (file)
@@ -97,7 +97,6 @@ CONFIG_MACH_CARMEVA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
index 2b4c0668b1b4d3fa70e1dc67998957f3bf5b6b8a..d662cab9cc21e68d73cf2b7f4e877b6421afae3d 100644 (file)
@@ -105,7 +105,6 @@ CONFIG_SA1100_CERF_FLASH_16MB=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index e42c5c873eb22094c53dcd7a8644c4b5efb892d9..893cd267e075267a1fd6714057b8490857112ce1 100644 (file)
@@ -236,7 +236,6 @@ CONFIG_MACH_CM_T35=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 797b790cba78f9f23348fd19a0778687669da994..47d22d09e70e1fccf550ba97ae62ab178a793cf2 100644 (file)
@@ -205,7 +205,6 @@ CONFIG_PXA_SSP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index a0170867130eb89f510e665dc948d58a89636154..a334069c7904ca7e02cdd9556fc7b8e489586f50 100644 (file)
@@ -247,7 +247,6 @@ CONFIG_PLAT_PXA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSC3=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 4cf3bde1c522c3c5b14dd7b380d9fec2966c9990..c962870b3f856e711c75e248d3a35e10df0192a7 100644 (file)
@@ -204,7 +204,6 @@ CONFIG_PXA27x=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 4774a36fa7407f7a93e795d77525a9844d32fbb5..11fdb5afdec7759802dab4177277b62b26877802 100644 (file)
@@ -212,7 +212,6 @@ CONFIG_PXA3xx=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSC3=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 1aa62249031be53989605dfed4ea72c60c9d7113..26e458d826341731f52fcb57421d162981fe8fb6 100644 (file)
@@ -125,7 +125,6 @@ CONFIG_SA1100_COLLIE=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index d6cd165e931059e94d455b67095980827782b94c..5e4069f4275439f9fe75edd3507337290e22f958 100644 (file)
@@ -214,7 +214,6 @@ CONFIG_PXA_HAVE_BOARD_IRQS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 601e7f3d5e97d20f9b81e1707ba8c2b7b9355577..c9137aaf23a9134f026d9f7a4a02f2de57aa50d7 100644 (file)
@@ -229,7 +229,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index b5b9cbbc6977bd189a60857a727c53ff88efefbb..d2344799171a7c10b01933ac7c9897adf70c7684 100644 (file)
@@ -219,7 +219,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 4901827253fbe23970b35c48c6e21acac77093b7..1f8dda6e37c36b8b3199c240cecb7b669bce11af 100644 (file)
@@ -230,7 +230,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 29f68c2effe68799aaf217b14428f7f0990eca05..f095040dab0776de049c6cab385cb81c172c1811 100644 (file)
@@ -193,7 +193,6 @@ CONFIG_AT91_TIMER_HZ=128
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index f7b60ceed6c7b3918be32aec516c66c2d7a2702c..507154016fc8b571e9e8eae25453eb747de8b540 100644 (file)
@@ -215,7 +215,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 50bd25a10f0da2324f00bf7957c528e968617ba5..e14c99c2b5743dc6c28df5c18a94b24f80c4dab0 100644 (file)
@@ -225,7 +225,6 @@ CONFIG_DAVINCI_RESET_CLOCKS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index bd656e8e6e4cba867300c0db59a71230877ee6d6..625035fd0a6c46cb8325f163fe1c20b1ee486a50 100644 (file)
@@ -223,7 +223,6 @@ CONFIG_DAVINCI_RESET_CLOCKS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index b3a491675d59e60dcb319d42c82ec8e8325094e4..b7b2ab088dd90faef48818f25797e812904f6e3f 100644 (file)
@@ -186,7 +186,6 @@ CONFIG_PLAT_ORION=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_32v6=y
index afcfff6140f275ca518a1b765ecb62c5d377fc17..d5e827969118b2c11334df65465206817069b5e7 100644 (file)
@@ -83,7 +83,6 @@ CONFIG_ARCH_EBSA110=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA110=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index ca520733bdb01802cd7d86c474b4ae843dcb690e..25dd53b7cefd680fd84efefc9507f6b1faa06e85 100644 (file)
@@ -186,7 +186,6 @@ CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 6ba7355ff85b7765e584ef76249cdda9ddb8913a..e3a6cd32669de883f31b8c7576330f2cd60aceb2 100644 (file)
@@ -90,7 +90,6 @@ CONFIG_ARCH_EP7211=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM720T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_LV4T=y
index e9955b786c8041f5f07553f2b40a0946a1afa156..2bee932439f6f7a9ee33322366f3b7fb874f169f 100644 (file)
@@ -202,7 +202,6 @@ CONFIG_PXA_SSP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 3fb083b81b0a53b41c06b3617a7c2bf2ee7cf07c..35d735ede9b802a6e4f4e46f334c0fef44f4988d 100644 (file)
@@ -198,7 +198,6 @@ CONFIG_EP93XX_EARLY_UART1=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index b6c5cbbf4c85dcc4c26265edc00d3f46e3b7961f..74baf5709290a6e096c73e72646765475398bae2 100644 (file)
@@ -203,7 +203,6 @@ CONFIG_PXA_HAVE_BOARD_IRQS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 492f29aba3322b3811e54a329bbaaa2cab94038b..9e9057c5a2a372d66d673cc31cf3eeca1963722f 100644 (file)
@@ -240,7 +240,6 @@ CONFIG_PLAT_PXA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 6ace512fa10114a12e2ff455137def6ec4f12021..04d97937afe2b602198aa516bf9cf14b68be4837 100644 (file)
@@ -95,7 +95,6 @@ CONFIG_ARCH_EBSA285=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA110=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 65dc73a88c439276d6e4df0cc2768b73fd18d890..d58142bf6fa18fe3f951c24b2b57a7ef1289423f 100644 (file)
@@ -88,7 +88,6 @@ CONFIG_ARCH_FORTUNET=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM720T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_LV4T=y
index efa78e144e5c6dd4b13b9004d2e5df8b450ba104..a8ad8fbe118837a652a8408d9e96d115cf972dd4 100644 (file)
@@ -205,7 +205,6 @@ CONFIG_SA1100_H3600=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 649baa37049543aa5e8abc7902a45f5b632fe7db..5bb73728fad6c184e9fd70472351808a76232335 100644 (file)
@@ -206,7 +206,6 @@ CONFIG_PXA25x=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 116920aecef7847a8164b16bb00f3b8753fa0640..09a6c6a27bdcb66b45cd6080518d96c6ec1938c3 100644 (file)
@@ -87,7 +87,6 @@ CONFIG_CPU_H7201=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM720T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_LV4T=y
index 0e739af527135c49e87a13116fa3ae3edb96a684..fedc52bd22b3c49a123a87c7ee0e93c637d1d661 100644 (file)
@@ -91,7 +91,6 @@ CONFIG_CPU_H7202=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM720T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_LV4T=y
index db0708d5cbead9fc7c86db2d19da4dc4f1822b81..2da1acf41f4be13dfaf3a01f0b8c08111181c4ca 100644 (file)
@@ -103,7 +103,6 @@ CONFIG_SA1100_HACKKIT=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 1b39691b816f1962f744f2279f2d575766f9f541..e0ef0d121aac9368ef09cd55734fabaa8dfeb520 100644 (file)
@@ -241,7 +241,6 @@ CONFIG_OMAP_ARM_195MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM925T=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v4T=y
index c97f8d0ded4800297fc142ca65be9878fe3d0d88..a192248c6dd60f590fc5b2f7f8538d9a379a87d4 100644 (file)
@@ -238,7 +238,6 @@ CONFIG_MACH_IGEP0020=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 3ce96e60b4094417eb4e807b601d61cd6ad8c9c9..6b0d043956391a2692ac2683274410da5aa6fdce 100644 (file)
@@ -92,7 +92,6 @@ CONFIG_ARCH_INTEGRATOR_AP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM720T=y
 CONFIG_CPU_ARM920T=y
 # CONFIG_CPU_ARM922T is not set
index 89c17761726be4f7c0099022bbd5d63b4694eb92..3c040cc9f3b6d9c7e5c6de121f3a0385e38a99cb 100644 (file)
@@ -163,7 +163,6 @@ CONFIG_PLAT_IOP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSC3=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index d70177b38f5f35b09f1b5115c5941cc4f0d88c4c..62a854996be100cb1d1334ae7c3b84e0dedf287c 100644 (file)
@@ -168,7 +168,6 @@ CONFIG_PLAT_IOP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index ed2d59d01829f88cd9e7f7a4c76377902ad9f968..0bc23ece4c2fbe0e99947628d160edf007f541cb 100644 (file)
@@ -198,7 +198,6 @@ CONFIG_PLAT_IOP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 57526c15e854c4f65b8f7baa3bd7eac2b7a6c4bd..8b5b5764a2288ac76b1865f5ca5ea99bd127aa02 100644 (file)
@@ -151,7 +151,6 @@ CONFIG_ARCH_IXDP2X01=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index ef97561ed75b642fdec7a72acf5dbd12f7cbc83f..59c11c93180f6457adbefebf7b9db167a5b91bd8 100644 (file)
@@ -145,7 +145,6 @@ CONFIG_MACH_ROADRUNNER=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSC3=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 95cd8dfb5f1e6df6c3d56582457a74217e9411c9..a907ad50ad3303f972e869b741f93ce6c7998eb0 100644 (file)
@@ -189,7 +189,6 @@ CONFIG_IXP4XX_NPE=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index df9bfbea861292bf61d37abe54fbfd5e2c848786..d1f1646e23c520688f6479599b91b5453a3b1b43 100644 (file)
@@ -202,7 +202,6 @@ CONFIG_SA1100_SSP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 9f92fc527f59a460be66a2e9035ad70df1a84be0..f661e765d9ba70cdc0023f645b47d99991598973 100644 (file)
@@ -132,7 +132,6 @@ CONFIG_MACH_KAFA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
index 605a8462f17263cb2547d16dcdd1e73f37d3034a..668ba59946d9edee5c408747396c86c0245c615b 100644 (file)
@@ -230,7 +230,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index bcfade33bca954f1b440b96172187af2b079ddac..5fc44c94b0ada0c7a7e7fe938997180dfc11c71a 100644 (file)
@@ -201,7 +201,6 @@ CONFIG_PLAT_ORION=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_FEROCEON=y
 # CONFIG_CPU_FEROCEON_OLD_ID is not set
 CONFIG_CPU_32v5=y
index d25c41bab06cccccf20cd3836c4aa03de289134d..e6f2276904f2e2ebe0c90558b3dfc3f2ca1dede8 100644 (file)
@@ -186,7 +186,6 @@ CONFIG_MACH_DSM320=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM922T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 56ae56899d2e1ea4b4f84c047cd848dbee15bf94..af7595176939b588010bf6d3bf569b758b2e1063 100644 (file)
@@ -99,7 +99,6 @@ CONFIG_SA1100_LART=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index b720fcffbcd45a0b8930dc9346656c39d79205e9..6df7b147161c9c24ac65aedd565ff8799fc9b891 100644 (file)
@@ -174,7 +174,6 @@ CONFIG_PLAT_ORION=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_FEROCEON=y
 # CONFIG_CPU_FEROCEON_OLD_ID is not set
 CONFIG_CPU_32v5=y
index 1a38d8e3fe66ba59c2b189a1d89d42c9ce88a91a..aeb768615347a023ee27efe3454c7a8893f7ac41 100644 (file)
@@ -143,7 +143,6 @@ CONFIG_PXA27x=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index f8ac29d5c654221d336233f77fe9c6ec9368a266..6116feea2e127f70a09faf43838e92d130da12ef 100644 (file)
@@ -95,7 +95,6 @@ CONFIG_LPD7A40X_CPLD_SSP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM922T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
index 7a2e932da1c644fc8bd4390eb1a99005a0040f14..142cccdd971eaa3dad14e664c9a1bc80b0d49dd0 100644 (file)
@@ -117,7 +117,6 @@ CONFIG_ARCH_LH7A404=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM922T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
index e544bfbbde5d4d55ae2e04529d876754ca1f9e0e..75c6293376bbc838d27242de2403ab789b0465ea 100644 (file)
@@ -92,7 +92,6 @@ CONFIG_PXA25x=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 42f6a77bc3c0af6c5d1c12c78df50ea7e9ef2c4c..c1a1fb049a7ce675b01fde0ca94427347153056e 100644 (file)
@@ -82,7 +82,6 @@ CONFIG_ARCH_L7200=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM720T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_LV4T=y
index 957fd5fa27ca26d6b375dee680e4a426b5e863d5..8e9a7232bc42ca71bd2a04a6656baa1e5985ee46 100644 (file)
@@ -204,7 +204,6 @@ CONFIG_PXA_HAVE_BOARD_IRQS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index cc8c95b992923d4211b19d2cc0158fd57e847965..1cddb61784966e072ebc80d3c7a2669fa581680d 100644 (file)
@@ -93,7 +93,6 @@ CONFIG_IWMMXT=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index e49ed40f3be7bf7343f0bd298176594e636beb5c..d2a90eb844a9d89d0833540e7ccf597bb7054a15 100644 (file)
@@ -256,7 +256,6 @@ CONFIG_MACH_MINI2440=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index cc3b06ee24f9eea947365ebcddc65b1be8900eb3..fe25e3b9a45ab14147fc6c34778b29f80857794b 100644 (file)
@@ -155,7 +155,6 @@ CONFIG_MSM_SMD=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
 CONFIG_CPU_32v6=y
index 398274b0771aa3538987eafad9143b063f34fc30..6afa2c108eaaf56ba740c9fbfa1fd80b812fc0cc 100644 (file)
@@ -181,7 +181,6 @@ CONFIG_PLAT_ORION=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_FEROCEON=y
 CONFIG_CPU_FEROCEON_OLD_ID=y
 CONFIG_CPU_32v5=y
index 0200d67e30ba4126d217217627023cdcbaa76c2d..f5750703b70717868c16a033c3728280550fe86b 100644 (file)
@@ -190,7 +190,6 @@ CONFIG_MXC_IRQ_PRIOR=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 577d7e1b5d42c5955e07d95cf084a91c92e48f8a..3cabbb6d9276ecc678366339fcc25e4aa9412c83 100644 (file)
@@ -88,7 +88,6 @@ CONFIG_ARCH_MX1ADS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4T=y
index 4b04290d8e8131723924470421d34062f79d3045..1ecd6276e0f1a1e488c8a509884e90993bd773a5 100644 (file)
@@ -185,7 +185,6 @@ CONFIG_MXC_PWM=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 75263a83741c89f70ba8f1d49fec338b4e2a070c..edfdd6faf800f496006a164d5661e54eb9cfc573 100644 (file)
@@ -207,7 +207,6 @@ CONFIG_MXC_PWM=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 95ffc0db95a011c2f07d9af29ecff1300b131102..d40953798d9ed3d4ae7599885fb3bc94157f128b 100644 (file)
@@ -173,7 +173,6 @@ CONFIG_MACH_MX31_3DS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
 CONFIG_CPU_32v6=y
index 7734ccab211984e0572e54ee802f1a6583dfd68e..8a06bc64fe595ebb43039f788f17620cb441bb16 100644 (file)
@@ -218,7 +218,6 @@ CONFIG_ARCH_MXC_IOMUX_V3=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
 CONFIG_CPU_32v6=y
index a1657b73683fb0ab56f53a522ce89c7a73ef1658..75cae18fbcb6d218a3fe30618c2a3be22f9432eb 100644 (file)
@@ -210,7 +210,6 @@ CONFIG_OMAP_ARM_216MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 264f52b5c52dddfe454e514c6903d3ea3291cc84..e6f667c5e58a20bf6ccb88272d3f1f5a805e6c98 100644 (file)
@@ -232,7 +232,6 @@ CONFIG_MACH_NOKIA_N8X0=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
 CONFIG_CPU_32v6=y
index e0e4e98b5aa20104691eecd6cf37e9f271d81653..d165c757e44cd3aa47195db6be02a29f31b42dc8 100644 (file)
@@ -218,7 +218,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 36cd62edd05cfd7636f422af72ba21b475e95683..171265ed02efa3ec4a16e158d8f267b38dbda4e9 100644 (file)
@@ -103,7 +103,6 @@ CONFIG_ASSABET_NEPONSET=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index c1a63a35c58d6df59d0499df7d01b8dc739ca297..78f58a99c5a32396a1d1ba6a18069a826bda6c8c 100644 (file)
@@ -89,7 +89,6 @@ CONFIG_FOOTBRIDGE_HOST=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA110=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 61d0fc5b2417f486fa3d0e71dcaec59a210a339e..2a97e361ec7b9f410120fb1e54ca9274d794e142 100644 (file)
@@ -122,7 +122,6 @@ CONFIG_MACH_NXEB500HMI=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 600cb270f2bfee936c42448826c37b4678e02156..92d90862f5ed58f05ef338d69ec144e8ebaf6c9c 100644 (file)
@@ -191,7 +191,6 @@ CONFIG_I2C_BITBANG_8815NHK=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 5245655a0ad32d913a4c5a4463b8bfbe40e387f7..f80848a929aee71186549cc6618fa9e6272b20e2 100644 (file)
@@ -180,7 +180,6 @@ CONFIG_MACH_W90P910EVB=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index df1de9b45ca4c43e39ea297a2604d0f6106679fc..97300ec478dd74e545ab74d2015ac28563f9c5b6 100644 (file)
@@ -201,7 +201,6 @@ CONFIG_MACH_W90P950EVB=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 4b2cd9eae9bc7abed00328fbeb9ce7f0c59e39c0..aa7e128f5d79ab55bcd92516c3b36ff1af2076e6 100644 (file)
@@ -201,7 +201,6 @@ CONFIG_MACH_W90N960EVB=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 9cfae374e041b387417ea50bb95560f2147620a6..c7999f5b1c9a7a6c37d0673f203d719ded08d5c8 100644 (file)
@@ -213,7 +213,6 @@ CONFIG_MACH_OMAP3_BEAGLE=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 2af28eab9060b0c6e98cfa98253b97f575534d23..367be98a6aefe7c619d11aa84e808fc5e6186d91 100644 (file)
@@ -245,7 +245,6 @@ CONFIG_MACH_OMAP_3630SDP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index e190fc8b9a7c5bdfb734423ef744eb009fd9bd59..86cc4bea616bc0689a15a39dbf0e927986fad4d2 100644 (file)
@@ -220,7 +220,6 @@ CONFIG_MACH_OMAP3EVM=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index b7a8d9fa49db0e76cbda4828ec490500b961740c..f74eb9a1d19129152c908eb9c630f39febdc3061 100644 (file)
@@ -211,7 +211,6 @@ CONFIG_MACH_OMAP3_PANDORA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 7c8515e65c0266c3049999c399d03932f453567a..74fe6be9c5ecbd5967ee90cc2da8a3655812f3a0 100644 (file)
@@ -246,7 +246,6 @@ CONFIG_MACH_OMAP3_TOUCHBOOK=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 640e9afc46303446db8424c038268886a1da691b..45b4ebae30567e98781251dcfad161efca7d6ea9 100644 (file)
@@ -197,7 +197,6 @@ CONFIG_MACH_OMAP_2430SDP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
 CONFIG_CPU_32v6=y
index 592457cfbbe577139968b9bfd85b1d9afc3a480a..bb2917e5cb478776c083361e2a6eff763355a55d 100644 (file)
@@ -232,7 +232,6 @@ CONFIG_MACH_OMAP_3430SDP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index e836c8a00148b8d3aa965975529e4575112e1c10..d25c3d4424ca9c9dba76751e078169a2a4eaf08e 100644 (file)
@@ -236,7 +236,6 @@ CONFIG_MACH_OMAP_3630SDP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 2319113c86bfc2c7ac3fb2eb4a8306095f0c348d..3de640ac294b300cb874ef80e8b9f31a0bd3c4a3 100644 (file)
@@ -220,7 +220,6 @@ CONFIG_MACH_OMAP_4430SDP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index ac7adf34c54ae5169a0545ae53b829cda1b62601..cc86342896a080e2b85ec66ab146437932fd565c 100644 (file)
@@ -196,7 +196,6 @@ CONFIG_MACH_OMAP_APOLLON=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
 CONFIG_CPU_32v6=y
index ccdc661b5856e123acb74c1f33f8850ecb86071d..61744e507e47574878fca74076d7e41e13f9f469 100644 (file)
@@ -205,7 +205,6 @@ CONFIG_OMAP_ARM_168MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM925T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 0c42c8955047bebfe6e9810ea0f31cd8493be921..d773857ed0cd56a738576a5a10069826a42d0130 100644 (file)
@@ -207,7 +207,6 @@ CONFIG_OMAP_ARM_192MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 0a00a708a4fcbc62802156bb40d6db4d187b6301..6ec487e6e027c1e92349ef962f0806c87c1c60a8 100644 (file)
@@ -201,7 +201,6 @@ CONFIG_OMAP_ARM_192MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index cf4073b47aaaa81bd697a226bc65edfc15afb451..7218b96c0b768898e0feb4549fbee32fea5081fc 100644 (file)
@@ -191,7 +191,6 @@ CONFIG_ARCH_OMAP2420=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
 CONFIG_CPU_32v6=y
index 74dbdc644d32bd81a9d502125e23cb53b64f8ad6..523189586a4bf62cd00a0c2bbbb903c35d36c212 100644 (file)
@@ -231,7 +231,6 @@ CONFIG_OMAP_ARM_60MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index a4aab8e4c29bad3e4cd503fb298066d1571fa137..b12b406c196063a09c16e849df3b01496a5d8de0 100644 (file)
@@ -201,7 +201,6 @@ CONFIG_MACH_OMAP_H4=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
 CONFIG_CPU_32v6=y
index 0cfe363e33657eaecf30915859227307dcef16a0..e9c14082125676c4e4215d92037a6042d80615cc 100644 (file)
@@ -205,7 +205,6 @@ CONFIG_OMAP_ARM_168MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM925T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 95d9f2be53e09c3403627e4325dfb5ade5e6eb74..fea9319ed7fdd8924ed43fa3b9c1dad871b799e9 100644 (file)
@@ -206,7 +206,6 @@ CONFIG_OMAP_ARM_192MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 9139532c3be7ec11a82dbba631b64e2459e0eaf7..0efb4b044fff045a24315b63184085a382138003 100644 (file)
@@ -214,7 +214,6 @@ CONFIG_MACH_OMAP_LDP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 6b3b5c610da0a1d033f6fc7fe82f6b221fd48ced..556fcca1b1db2abe58c31b9c17df5dbda8bae490 100644 (file)
@@ -212,7 +212,6 @@ CONFIG_OMAP_ARM_192MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index b94800c0e000b6658435c3b9e9c34e79fb277060..9a15d5da57f9df20106c3ea74f17f38f06d4b3ae 100644 (file)
@@ -199,7 +199,6 @@ CONFIG_OMAP_ARM_182MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 4b00a4306812117c66c7983c5512f5d9b425d7fc..a82e81332a030a714a9e2f0e159f6bd172e47047 100644 (file)
@@ -222,7 +222,6 @@ CONFIG_MACH_OMAP_ZOOM2=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 0d7e37a3651bf01b7004af893a6b92fea3409124..a3e3c8274c9b0a070ba01f1a1307f99db7afdb20 100644 (file)
@@ -236,7 +236,6 @@ CONFIG_MACH_OMAP_ZOOM3=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index f8701fadb600c04dc10e95b0e9383197c5a66d2f..19b91dedc7feeed6817501869aaa72b191f81829 100644 (file)
@@ -161,7 +161,6 @@ CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 5383cd0dff54e7dfe7aa01303092d82640fc0eaf..85b05d3e279b6c75f4a6f9c1da78311f470bfd5c 100644 (file)
@@ -210,7 +210,6 @@ CONFIG_PLAT_ORION=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_FEROCEON=y
 CONFIG_CPU_FEROCEON_OLD_ID=y
 CONFIG_CPU_32v5=y
index b3ea2c4c0f916b8b8feade5128c774359329e811..bf06d3660a306343553fd3bca9336e05f41f8bbd 100644 (file)
@@ -217,7 +217,6 @@ CONFIG_MACH_OVERO=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 40fc6a778e0079daec7c607d9384864c057caa61..feffaa2deae2ea3a818f1de87d9e7511a1fd61a0 100644 (file)
@@ -196,7 +196,6 @@ CONFIG_OMAP_CLOCKS_SET_BY_BOOTLOADER=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM925T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index e54ced41217e9956cde828a85ca6ebf7c23804c0..55d5b7dfb7a6d8ad85ae75333e0cc27e0467570a 100644 (file)
@@ -176,7 +176,6 @@ CONFIG_OMAP_CLOCKS_SET_BY_BOOTLOADER=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM925T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 08e14068fff7aae7d21fb5b48b75c0c37e238d51..6efc7465a76c851f34e7405fc19b8ac0e78806b5 100644 (file)
@@ -200,7 +200,6 @@ CONFIG_OMAP_CLOCKS_SET_BY_BOOTLOADER=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM925T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index a0dc37c05dea910b28e64a23d00686205ed38d93..6d162b137ce894d28699df863e79df5d5678f1eb 100644 (file)
@@ -209,7 +209,6 @@ CONFIG_PXA_PWM=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 05ad96a43b1d1ae68a5c8895b5c5a0a7c3b53b69..fa153f2711bbb1c7f6315172db80f01bf6614b11 100644 (file)
@@ -168,7 +168,6 @@ CONFIG_PXA27x=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 9018f0f298aa1a74c4bfa1e76d66bd519308ffaa..6e7155c122a4b9292d1741882c69b96be8614e45 100644 (file)
@@ -168,7 +168,6 @@ CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index f2d2dda25949ebe6ff2e90d2aa3bd2fbafbdc18c..dbfabb5eede88251bf6efeba482d5bd5e5246667 100644 (file)
@@ -100,7 +100,6 @@ CONFIG_SA1100_PLEB=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 67b5f1e15f4a2bd222797261e4c1ec95a0944bf9..2f7b9ce7dad3c6264c443ce19efcac3941bd5bc6 100644 (file)
@@ -121,7 +121,6 @@ CONFIG_ARCH_PNX4008=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index db5faeaec96cf119b3839008a01c132e2357b313..791b8c39aefc4d526169e90375fa3d8ff115d182 100644 (file)
@@ -184,7 +184,6 @@ CONFIG_PLAT_PXA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_MOHAWK=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 46e5089df0aea9b79e9a792c74adc5e772b1bcf4..3365c5d77cad29725e711080bc424ca8951c63f6 100644 (file)
@@ -92,7 +92,6 @@ CONFIG_PXA25x=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 733b851e5b7e233ca40febf54f4550caa1cfc801..82ca6c80d6af7838f02b3bc9673b8f3a38d050c4 100644 (file)
@@ -240,7 +240,6 @@ CONFIG_PLAT_PXA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSC3=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 8c7e299f1d664cc4add9af2b65de8a5ea4c12888..94e20fe6dbde89654fe907b54d1d19cacc7ec73a 100644 (file)
@@ -184,7 +184,6 @@ CONFIG_PLAT_PXA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_MOHAWK=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 9b32d0eb89bac0a93e09000f1ab2897ecc10b5bd..12d0d64e32161c5347aec7bc70bfe7a6800bcd64 100644 (file)
@@ -195,7 +195,6 @@ CONFIG_AT91_EARLY_USART0=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 21db4b3ec8ff104c8b95e9c9eb1d3854536c2d25..123701754d427d0caf17f5b33c714e1928730dba 100644 (file)
@@ -186,7 +186,6 @@ CONFIG_REALVIEW_HIGH_PHYS_OFFSET=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 # CONFIG_CPU_ARM926T is not set
 CONFIG_CPU_V6=y
 CONFIG_CPU_32v6K=y
index 9a75c30b910d4564a5dc78b55cfb7a378dcf21d6..a509a5e59d2cd9e2b1f11b4c5655f0916128a285 100644 (file)
@@ -184,7 +184,6 @@ CONFIG_MACH_REALVIEW_PB1176=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 # CONFIG_CPU_ARM926T is not set
 CONFIG_CPU_V6=y
 # CONFIG_CPU_32v6K is not set
index a29d61fe4c6aea11ba18e55221a080a671337c7e..e9124a00039357ea3de4c884c541ce564d674982 100644 (file)
@@ -150,7 +150,6 @@ CONFIG_ARCH_ACORN=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM610=y
 CONFIG_CPU_ARM710=y
 CONFIG_CPU_SA110=y
index 15597342602527a87dddb321c64902472fcec108..b6eeebb3176112afc0386ccefcdd36c3a2e0f48f 100644 (file)
@@ -212,7 +212,6 @@ CONFIG_MACH_NOKIA_RX51=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index b49810461e41f7e90b57c9cb8de2ff833cbe2d49..2f10dae0279630b3e1da4c21fa99044d5fc57450 100644 (file)
@@ -277,7 +277,6 @@ CONFIG_MACH_SMDK2443=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v4T=y
index 32860609e057764caa9c1b1f34331717c4dfb734..f56e50fab79b103d47dc669279b3c6b026bf7a9c 100644 (file)
@@ -192,7 +192,6 @@ CONFIG_SMDK6410_SD_CH0=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_V6=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_32v6=y
index b0d7d3d3a5e3f6a9ddbabaeb4a87b86cfb87d6fc..dc108afc060c0d433a3ab9c293d311f673c963c2 100644 (file)
@@ -202,7 +202,6 @@ CONFIG_MACH_SMDKC100=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index 1174e276487577d92585066e5f69b78aae2b57e2..81b290ad5d257dafe96c9bb72ea25ab5d5cdd63d 100644 (file)
@@ -175,7 +175,6 @@ CONFIG_MTD_AT91_DATAFLASH_CARD=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 984f7096a5338dd327851d5653025d7aa9dba7f7..7c49bc3524624fa9212dd913d463d6e2667b1cab 100644 (file)
@@ -99,7 +99,6 @@ CONFIG_SA1100_SHANNON=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 90235bf7a1de8df9f195f5bdacb6054e5797e6be..46de1247d127a82b81c12e9e8962561b9793716a 100644 (file)
@@ -173,7 +173,6 @@ CONFIG_ARCH_SHARK=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA110=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 685d2b5132063ace25750c98b791c8b4b1316d11..ee25e63441518b45b433008f04ac78730a79d0b8 100644 (file)
@@ -101,7 +101,6 @@ CONFIG_SA1100_SIMPAD=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_SA1100=y
 CONFIG_CPU_32v4=y
 CONFIG_CPU_ABRT_EV4=y
index 745c68ffb885a1975a655b3883b81d4412a40e5d..7d894894194f3ac745d4cdb6676f82f1415826e2 100644 (file)
@@ -212,7 +212,6 @@ CONFIG_PXA_SSP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 44461f197a17d13bbf86c6ae065d2a61af4d93c0..b1a3a97d46ee0ef0f0a971e803f087be08a503d7 100644 (file)
@@ -193,7 +193,6 @@ CONFIG_MACH_STMP378X=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 401279d531d57ab2d8a03e20e35825f3f3c1081b..a3751c9e1416f9047212b74fe7c1a6ed7b009dcb 100644 (file)
@@ -182,7 +182,6 @@ CONFIG_MACH_STMP37XX=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 25b007ff8bab36dbda7fae78272da9239bc1190c..8a9e7e6bd03b5d641619ddbf83d6418fd5e2c415 100644 (file)
@@ -210,7 +210,6 @@ CONFIG_OMAP_ARM_168MHZ=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM925T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 9d32faef05f6e1b183f5d5fc23f4728413aa2b88..dccf14b4ee02ee6cf6398e66d97cc589c479403f 100644 (file)
@@ -215,7 +215,6 @@ CONFIG_MACH_TCT_HAMMER=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index b6f83819781660f565c142568a3290f18468a5d0..1e8f5a211856b075143ca53d6e61b6f7ce1bfb73 100644 (file)
@@ -156,7 +156,6 @@ CONFIG_PXA27x=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 953ba0297fc4f8e50c49f4c7168854b2b8b7ac34..610ac3c47b0f5009df7977ed3b57df17d91c41a3 100644 (file)
@@ -207,7 +207,6 @@ CONFIG_MACH_U300_SPIDUMMY=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 15fde22ce3f355581a6bc699036627ff458c683c..727aff9fe3476c5dd53ea0b86ec060393bfb36e6 100644 (file)
@@ -201,7 +201,6 @@ CONFIG_MACH_U8500_MOP=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_32v6K=y
 CONFIG_CPU_V7=y
 CONFIG_CPU_32v7=y
index fd7774033d64fcb8df5e8d336399dceb13ee767d..87b700e2db845e07ec532a05ae6be87cdbce73e3 100644 (file)
@@ -195,7 +195,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index e7c19dd92557237e6136086cacaac53b78935d28..7f018edd24802bc7c73f634de2dc3e7d9ecb1da8 100644 (file)
@@ -187,7 +187,6 @@ CONFIG_AT91_EARLY_DBGU=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index b11c5da3996cee1b1336dda6c3381c5e9d2cdcd1..a1af0b972c0dd2b67ed7238b227cb014b72ed694 100644 (file)
@@ -117,7 +117,6 @@ CONFIG_MACH_VERSATILE_AB=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM926T=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5TJ=y
index 6ab5dd5868de5d6d6c33e19f26fe48fa6bf58755..909887ae524c1ce2fa02b83a7e61cfe46af5b5ab 100644 (file)
@@ -204,7 +204,6 @@ CONFIG_PXA_HAVE_ISA_IRQS=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 33bb7250946bec90791c8f2d6afdfad3729cbeab..84a72ac222cf3a56e3b8bffc82aa0e2c6ec33498 100644 (file)
@@ -208,7 +208,6 @@ CONFIG_PLAT_PXA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
index 9192e5977674196f7adcab1ab5b5b801366a6ca1..3b627aadeb54fab52c45276af88a6ba6db84afaa 100644 (file)
@@ -183,7 +183,6 @@ CONFIG_MACH_YL9200=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_ARM920T=y
 CONFIG_CPU_32v4T=y
 CONFIG_CPU_ABRT_EV4T=y
index 823b11e7091af4c21fc6d8b6b978b4616a1f459e..fca5ff68ea67de5b71947a2c9d52ac185c5bc5fa 100644 (file)
@@ -271,7 +271,6 @@ CONFIG_PLAT_PXA=y
 #
 # Processor Type
 #
-CONFIG_CPU_32=y
 CONFIG_CPU_XSCALE=y
 CONFIG_CPU_32v5=y
 CONFIG_CPU_ABRT_EV5T=y
diff --git a/arch/arm/include/asm/asm-offsets.h b/arch/arm/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 73eceb87e58869ffa978bf35cc71b015a2d40d03..730aefcfbee3eb8e0c46ea0a6dc0b9ba0fd1e27f 100644 (file)
@@ -211,7 +211,7 @@ struct cpu_cache_fns {
 
        void (*coherent_kern_range)(unsigned long, unsigned long);
        void (*coherent_user_range)(unsigned long, unsigned long);
-       void (*flush_kern_dcache_page)(void *);
+       void (*flush_kern_dcache_area)(void *, size_t);
 
        void (*dma_inv_range)(const void *, const void *);
        void (*dma_clean_range)(const void *, const void *);
@@ -236,7 +236,7 @@ extern struct cpu_cache_fns cpu_cache;
 #define __cpuc_flush_user_range                cpu_cache.flush_user_range
 #define __cpuc_coherent_kern_range     cpu_cache.coherent_kern_range
 #define __cpuc_coherent_user_range     cpu_cache.coherent_user_range
-#define __cpuc_flush_dcache_page       cpu_cache.flush_kern_dcache_page
+#define __cpuc_flush_dcache_area       cpu_cache.flush_kern_dcache_area
 
 /*
  * These are private to the dma-mapping API.  Do not use directly.
@@ -255,14 +255,14 @@ extern struct cpu_cache_fns cpu_cache;
 #define __cpuc_flush_user_range                __glue(_CACHE,_flush_user_cache_range)
 #define __cpuc_coherent_kern_range     __glue(_CACHE,_coherent_kern_range)
 #define __cpuc_coherent_user_range     __glue(_CACHE,_coherent_user_range)
-#define __cpuc_flush_dcache_page       __glue(_CACHE,_flush_kern_dcache_page)
+#define __cpuc_flush_dcache_area       __glue(_CACHE,_flush_kern_dcache_area)
 
 extern void __cpuc_flush_kern_all(void);
 extern void __cpuc_flush_user_all(void);
 extern void __cpuc_flush_user_range(unsigned long, unsigned long, unsigned int);
 extern void __cpuc_coherent_kern_range(unsigned long, unsigned long);
 extern void __cpuc_coherent_user_range(unsigned long, unsigned long);
-extern void __cpuc_flush_dcache_page(void *);
+extern void __cpuc_flush_dcache_area(void *, size_t);
 
 /*
  * These are private to the dma-mapping API.  Do not use directly.
@@ -448,7 +448,7 @@ static inline void flush_kernel_dcache_page(struct page *page)
 {
        /* highmem pages are always flushed upon kunmap already */
        if ((cache_is_vivt() || cache_is_vipt_aliasing()) && !PageHighMem(page))
-               __cpuc_flush_dcache_page(page_address(page));
+               __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
 }
 
 #define flush_dcache_mmap_lock(mapping) \
@@ -465,13 +465,6 @@ static inline void flush_kernel_dcache_page(struct page *page)
  */
 #define flush_icache_page(vma,page)    do { } while (0)
 
-static inline void flush_ioremap_region(unsigned long phys, void __iomem *virt,
-       unsigned offset, size_t size)
-{
-       const void *start = (void __force *)virt + offset;
-       dmac_inv_range(start, start + size);
-}
-
 /*
  * flush_cache_vmap() is used when creating mappings (eg, via vmap,
  * vmalloc, ioremap etc) in kernel space for pages.  On non-VIPT
index 6aac3f5bb2f3ee1975f53578d2742a5e5d1295b9..a399bb5730f15210aa2b6b42527ea6ada7d19f15 100644 (file)
@@ -101,7 +101,6 @@ extern int arm_elf_read_implies_exec(const struct elf32_hdr *, int);
 int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
 #define ELF_CORE_COPY_TASK_REGS dump_task_regs
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      4096
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
diff --git a/arch/arm/include/asm/mach-types.h b/arch/arm/include/asm/mach-types.h
new file mode 100644 (file)
index 0000000..948178c
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/mach-types.h>
index acac5302e4eaf1860e2db8d77d2b47ee0f4cf399..8920b2d6e3b850634c501abe7f1512c6eea4a46f 100644 (file)
@@ -26,9 +26,9 @@ extern int show_fiq_list(struct seq_file *, void *);
  */
 #define do_bad_IRQ(irq,desc)                           \
 do {                                                   \
-       spin_lock(&desc->lock);                         \
+       raw_spin_lock(&desc->lock);                     \
        handle_bad_irq(irq, desc);                      \
-       spin_unlock(&desc->lock);                       \
+       raw_spin_unlock(&desc->lock);                   \
 } while(0)
 
 #endif
index 3976412685f8c2b43280fffb926a78da9a00688f..8fdae9bc9abba945dcfb4406fae70b07ae4cf957 100644 (file)
  * CPU_NAME - the prefix for CPU related functions
  */
 
-#ifdef CONFIG_CPU_32
-# ifdef CONFIG_CPU_ARM610
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm6
-#  endif
+#ifdef CONFIG_CPU_ARM610
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm6
 # endif
-# ifdef CONFIG_CPU_ARM7TDMI
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm7tdmi
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM7TDMI
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm7tdmi
 # endif
-# ifdef CONFIG_CPU_ARM710
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm7
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM710
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm7
 # endif
-# ifdef CONFIG_CPU_ARM720T
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm720
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM720T
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm720
 # endif
-# ifdef CONFIG_CPU_ARM740T
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm740
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM740T
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm740
 # endif
-# ifdef CONFIG_CPU_ARM9TDMI
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm9tdmi
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM9TDMI
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm9tdmi
 # endif
-# ifdef CONFIG_CPU_ARM920T
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm920
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM920T
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm920
 # endif
-# ifdef CONFIG_CPU_ARM922T
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm922
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM922T
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm922
 # endif
-# ifdef CONFIG_CPU_FA526
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_fa526
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_FA526
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_fa526
 # endif
-# ifdef CONFIG_CPU_ARM925T
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm925
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM925T
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm925
 # endif
-# ifdef CONFIG_CPU_ARM926T
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm926
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM926T
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm926
 # endif
-# ifdef CONFIG_CPU_ARM940T
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm940
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM940T
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm940
 # endif
-# ifdef CONFIG_CPU_ARM946E
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm946
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM946E
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm946
 # endif
-# ifdef CONFIG_CPU_SA110
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_sa110
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_SA110
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_sa110
 # endif
-# ifdef CONFIG_CPU_SA1100
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_sa1100
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_SA1100
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_sa1100
 # endif
-# ifdef CONFIG_CPU_ARM1020
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm1020
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM1020
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm1020
 # endif
-# ifdef CONFIG_CPU_ARM1020E
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm1020e
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM1020E
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm1020e
 # endif
-# ifdef CONFIG_CPU_ARM1022
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm1022
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM1022
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm1022
 # endif
-# ifdef CONFIG_CPU_ARM1026
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_arm1026
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_ARM1026
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_arm1026
 # endif
-# ifdef CONFIG_CPU_XSCALE
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_xscale
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_XSCALE
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_xscale
 # endif
-# ifdef CONFIG_CPU_XSC3
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_xsc3
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_XSC3
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_xsc3
 # endif
-# ifdef CONFIG_CPU_MOHAWK
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_mohawk
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_MOHAWK
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_mohawk
 # endif
-# ifdef CONFIG_CPU_FEROCEON
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_feroceon
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_FEROCEON
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_feroceon
 # endif
-# ifdef CONFIG_CPU_V6
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_v6
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_V6
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_v6
 # endif
-# ifdef CONFIG_CPU_V7
-#  ifdef CPU_NAME
-#   undef  MULTI_CPU
-#   define MULTI_CPU
-#  else
-#   define CPU_NAME cpu_v7
-#  endif
+#endif
+
+#ifdef CONFIG_CPU_V7
+# ifdef CPU_NAME
+#  undef  MULTI_CPU
+#  define MULTI_CPU
+# else
+#  define CPU_NAME cpu_v7
 # endif
 #endif
 
index c13681ac1ede0cada819fb8c577b2e0e7c82ae5c..c91c64cab922c908186511a530f72673dd82d3b0 100644 (file)
  * Locked value: 1
  */
 
-#define __raw_spin_is_locked(x)                ((x)->lock != 0)
-#define __raw_spin_unlock_wait(lock) \
-       do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0)
+#define arch_spin_is_locked(x)         ((x)->lock != 0)
+#define arch_spin_unlock_wait(lock) \
+       do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)
 
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
+#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        unsigned long tmp;
 
@@ -43,7 +43,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
        smp_mb();
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        unsigned long tmp;
 
@@ -63,7 +63,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
        }
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        smp_mb();
 
@@ -86,7 +86,7 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
  * just write zero since the lock is exclusively held.
  */
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
        unsigned long tmp;
 
@@ -106,7 +106,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
        smp_mb();
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *rw)
+static inline int arch_write_trylock(arch_rwlock_t *rw)
 {
        unsigned long tmp;
 
@@ -126,7 +126,7 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
        }
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t *rw)
+static inline void arch_write_unlock(arch_rwlock_t *rw)
 {
        smp_mb();
 
@@ -142,7 +142,7 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
 }
 
 /* write_can_lock - would write_trylock() succeed? */
-#define __raw_write_can_lock(x)                ((x)->lock == 0)
+#define arch_write_can_lock(x)         ((x)->lock == 0)
 
 /*
  * Read locks are a bit more hairy:
@@ -156,7 +156,7 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
  * currently active.  However, we know we won't have any write
  * locks.
  */
-static inline void __raw_read_lock(raw_rwlock_t *rw)
+static inline void arch_read_lock(arch_rwlock_t *rw)
 {
        unsigned long tmp, tmp2;
 
@@ -176,7 +176,7 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
        smp_mb();
 }
 
-static inline void __raw_read_unlock(raw_rwlock_t *rw)
+static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
        unsigned long tmp, tmp2;
 
@@ -198,7 +198,7 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
        : "cc");
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t *rw)
+static inline int arch_read_trylock(arch_rwlock_t *rw)
 {
        unsigned long tmp, tmp2 = 1;
 
@@ -215,13 +215,13 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw)
 }
 
 /* read_can_lock - would read_trylock() succeed? */
-#define __raw_read_can_lock(x)         ((x)->lock < 0x80000000)
+#define arch_read_can_lock(x)          ((x)->lock < 0x80000000)
 
-#define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock)
-#define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock)
+#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* __ASM_SPINLOCK_H */
index 43e83f6d2ee5321e5ee08ddb1ef2b8dfb5904c1a..d14d197ae04aa6819c780d62ebfa1245de634db1 100644 (file)
@@ -7,14 +7,14 @@
 
 typedef struct {
        volatile unsigned int lock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        volatile unsigned int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { 0 }
+#define __ARCH_RW_LOCK_UNLOCKED                { 0 }
 
 #endif
index f27379d7f72a670b01e2e70b2b09b97cc9c98862..c4391ba203507a2b1c34a9634ad6fb9c4ff7eb64 100644 (file)
@@ -41,7 +41,7 @@ static inline void thread_notify(unsigned long rc, struct thread_info *thread)
  * These are the reason codes for the thread notifier.
  */
 #define THREAD_NOTIFY_FLUSH    0
-#define THREAD_NOTIFY_RELEASE  1
+#define THREAD_NOTIFY_EXIT     1
 #define THREAD_NOTIFY_SWITCH   2
 
 #endif
index 0e627705f74632d9dab0ae5079bc5eb2910a83b3..8214bfebfaca6625226f8b2dd041d978e5ddc25e 100644 (file)
@@ -48,27 +48,7 @@ extern void __aeabi_uidivmod(void);
 extern void __aeabi_ulcmp(void);
 
 extern void fpundefinstr(void);
-extern void fp_enter(void);
 
-/*
- * This has a special calling convention; it doesn't
- * modify any of the usual registers, except for LR.
- */
-#define EXPORT_CRC_ALIAS(sym) __CRC_SYMBOL(sym, "")
-
-#define EXPORT_SYMBOL_ALIAS(sym,orig)          \
- EXPORT_CRC_ALIAS(sym)                         \
- static const struct kernel_symbol __ksymtab_##sym     \
-  __used __attribute__((section("__ksymtab"))) =       \
-    { (unsigned long)&orig, #sym };
-
-/*
- * floating point math emulator support.
- * These symbols will never change their calling convention...
- */
-EXPORT_SYMBOL_ALIAS(kern_fp_enter,fp_enter);
-EXPORT_SYMBOL_ALIAS(fp_printk,printk);
-EXPORT_SYMBOL_ALIAS(fp_send_sig,send_sig);
 
 EXPORT_SYMBOL(__backtrace);
 
index 769abe15cf91d280425a95bf7042642c2214e68b..25ef223ba7f34e945bc490f23eef4dc0df424677 100644 (file)
@@ -51,7 +51,7 @@ static int crunch_do(struct notifier_block *self, unsigned long cmd, void *t)
                 * initialised state information on the first fault.
                 */
 
-       case THREAD_NOTIFY_RELEASE:
+       case THREAD_NOTIFY_EXIT:
                crunch_task_release(thread);
                break;
 
index 0e88e46fc7321753f064c6996528d7a81bea0ee4..360bb6d701f5bf2eab294cfd6c202b2c1db6f442 100644 (file)
@@ -207,8 +207,6 @@ void __init isa_init_dma(void)
                outb(0x32, 0x4d6);
                outb(0x33, 0x4d6);
 
-               request_dma(DMA_ISA_CASCADE, "cascade");
-
                for (i = 0; i < ARRAY_SIZE(dma_resources); i++)
                        request_resource(&ioport_resource, dma_resources + i);
 
@@ -218,5 +216,7 @@ void __init isa_init_dma(void)
                                printk(KERN_ERR "ISADMA%u: unable to register: %d\n",
                                        chan, ret);
                }
+
+               request_dma(DMA_ISA_CASCADE, "cascade");
        }
 }
index c9a8619f385632014ea1d7814d77f740cc786fb0..b7cb45bb91e8f1cb80eeb18bb05d477aa57fcdc1 100644 (file)
@@ -69,7 +69,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto unlock;
@@ -84,7 +84,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 unlock:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        } else if (i == NR_IRQS) {
 #ifdef CONFIG_FIQ
                show_fiq_list(p, v);
@@ -139,7 +139,7 @@ void set_irq_flags(unsigned int irq, unsigned int iflags)
        }
 
        desc = irq_desc + irq;
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
        if (iflags & IRQF_VALID)
                desc->status &= ~IRQ_NOREQUEST;
@@ -147,7 +147,7 @@ void set_irq_flags(unsigned int irq, unsigned int iflags)
                desc->status &= ~IRQ_NOPROBE;
        if (!(iflags & IRQF_NOAUTOEN))
                desc->status &= ~IRQ_NOAUTOEN;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 void __init init_IRQ(void)
@@ -166,9 +166,9 @@ static void route_irq(struct irq_desc *desc, unsigned int irq, unsigned int cpu)
 {
        pr_debug("IRQ%u: moving from cpu%u to cpu%u\n", irq, desc->node, cpu);
 
-       spin_lock_irq(&desc->lock);
+       raw_spin_lock_irq(&desc->lock);
        desc->chip->set_affinity(irq, cpumask_of(cpu));
-       spin_unlock_irq(&desc->lock);
+       raw_spin_unlock_irq(&desc->lock);
 }
 
 /*
index 0d96d0171c05601bf59a5e44c579cd7f59e9af23..67304138a2ca025d0ef494e40d3d513fd3bb3b8b 100644 (file)
@@ -274,17 +274,18 @@ void show_regs(struct pt_regs * regs)
        __backtrace();
 }
 
+ATOMIC_NOTIFIER_HEAD(thread_notify_head);
+
+EXPORT_SYMBOL_GPL(thread_notify_head);
+
 /*
  * Free current thread data structures etc..
  */
 void exit_thread(void)
 {
+       thread_notify(THREAD_NOTIFY_EXIT, current_thread_info());
 }
 
-ATOMIC_NOTIFIER_HEAD(thread_notify_head);
-
-EXPORT_SYMBOL_GPL(thread_notify_head);
-
 void flush_thread(void)
 {
        struct thread_info *thread = current_thread_info();
@@ -299,9 +300,6 @@ void flush_thread(void)
 
 void release_thread(struct task_struct *dead_task)
 {
-       struct thread_info *thread = task_thread_info(dead_task);
-
-       thread_notify(THREAD_NOTIFY_RELEASE, thread);
 }
 
 asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
index 71151bd87a367efce4985e309cb159d6604b9f8d..4957e13ef55ba6be1d396f5dc72d3eebb2b43450 100644 (file)
@@ -65,11 +65,11 @@ SECTIONS
        __init_end = .;
 #endif
 
-       /DISCARD/ : {                   /* Exit code and data           */
-               EXIT_TEXT
-               EXIT_DATA
-               *(.exitcall.exit)
-               *(.discard)
+       /*
+        * unwind exit sections must be discarded before the rest of the
+        * unwind sections get included.
+        */
+       /DISCARD/ : {
                *(.ARM.exidx.exit.text)
                *(.ARM.extab.exit.text)
 #ifndef CONFIG_HOTPLUG_CPU
@@ -238,6 +238,9 @@ SECTIONS
 
        STABS_DEBUG
        .comment 0 : { *(.comment) }
+
+       /* Default discards */
+       DISCARDS
 }
 
 /*
index 17127db906faf331cd21bd6d33c47dceaa8a6e65..1796157e3dd540dcb3772867a43d2018f10eef11 100644 (file)
@@ -70,7 +70,7 @@ static int iwmmxt_do(struct notifier_block *self, unsigned long cmd, void *t)
                 * initialised state information on the first fault.
                 */
 
-       case THREAD_NOTIFY_RELEASE:
+       case THREAD_NOTIFY_EXIT:
                iwmmxt_task_release(thread);
                break;
 
diff --git a/arch/arm/mach-at91/include/mach/atmel-mci.h b/arch/arm/mach-at91/include/mach/atmel-mci.h
new file mode 100644 (file)
index 0000000..998cb0c
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __MACH_ATMEL_MCI_H
+#define __MACH_ATMEL_MCI_H
+
+#include <mach/at_hdmac.h>
+
+/**
+ * struct mci_dma_data - DMA data for MCI interface
+ */
+struct mci_dma_data {
+       struct at_dma_slave     sdata;
+};
+
+/* accessor macros */
+#define        slave_data_ptr(s)       (&(s)->sdata)
+#define find_slave_dev(s)      ((s)->sdata.dma_dev)
+
+#define        setup_dma_addr(s, t, r) do {            \
+       if (s) {                                \
+               (s)->sdata.tx_reg = (t);        \
+               (s)->sdata.rx_reg = (r);        \
+       }                                       \
+} while (0)
+
+#endif /* __MACH_ATMEL_MCI_H */
index fbe6fa02c8820f71e0f3343e06b9628e68e71a5f..53dd2a9eecf9b1848d4d3514ebee97821bb7ada6 100644 (file)
@@ -70,9 +70,19 @@ static struct ctl_table bcmring_sysctl_reboot[] = {
        {}
 };
 
+static struct resource nand_resource[] = {
+       [0] = {
+               .start = MM_ADDR_IO_NAND,
+               .end = MM_ADDR_IO_NAND + 0x1000 - 1,
+               .flags = IORESOURCE_MEM,
+       },
+};
+
 static struct platform_device nand_device = {
        .name = "bcm-nand",
        .id = -1,
+       .resource = nand_resource,
+       .num_resources  = ARRAY_SIZE(nand_resource),
 };
 
 static struct platform_device *devices[] __initdata = {
diff --git a/arch/arm/mach-bcmring/include/mach/reg_nand.h b/arch/arm/mach-bcmring/include/mach/reg_nand.h
new file mode 100644 (file)
index 0000000..387376f
--- /dev/null
@@ -0,0 +1,66 @@
+/*****************************************************************************
+* Copyright 2001 - 2008 Broadcom Corporation.  All rights reserved.
+*
+* Unless you and Broadcom execute a separate written software license
+* agreement governing use of this software, this software is licensed to you
+* under the terms of the GNU General Public License version 2, available at
+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
+*
+* Notwithstanding the above, under no circumstances may you combine this
+* software in any way with any other Broadcom software provided under a
+* license other than the GPL, without Broadcom's express prior written
+* consent.
+*****************************************************************************/
+
+/*
+*
+*****************************************************************************
+*
+*  REG_NAND.h
+*
+*  PURPOSE:
+*
+*     This file contains definitions for the nand registers:
+*
+*  NOTES:
+*
+*****************************************************************************/
+
+#if !defined(__ASM_ARCH_REG_NAND_H)
+#define __ASM_ARCH_REG_NAND_H
+
+/* ---- Include Files ---------------------------------------------------- */
+#include <csp/reg.h>
+#include <mach/reg_umi.h>
+
+/* ---- Constants and Types ---------------------------------------------- */
+
+#define HW_NAND_BASE       MM_IO_BASE_NAND     /* NAND Flash */
+
+/* DMA accesses by the bootstrap need hard nonvirtual addresses */
+#define REG_NAND_CMD            __REG16(HW_NAND_BASE + 0)
+#define REG_NAND_ADDR           __REG16(HW_NAND_BASE + 4)
+
+#define REG_NAND_PHYS_DATA16   (HW_NAND_BASE + 8)
+#define REG_NAND_PHYS_DATA8    (HW_NAND_BASE + 8)
+#define REG_NAND_DATA16         __REG16(REG_NAND_PHYS_DATA16)
+#define REG_NAND_DATA8          __REG8(REG_NAND_PHYS_DATA8)
+
+/* use appropriate offset to make sure it start at the 1K boundary */
+#define REG_NAND_PHYS_DATA_DMA   (HW_NAND_BASE + 0x400)
+#define REG_NAND_DATA_DMA         __REG32(REG_NAND_PHYS_DATA_DMA)
+
+/* Linux DMA requires physical address of the data register */
+#define REG_NAND_DATA16_PADDR    HW_IO_VIRT_TO_PHYS(REG_NAND_PHYS_DATA16)
+#define REG_NAND_DATA8_PADDR     HW_IO_VIRT_TO_PHYS(REG_NAND_PHYS_DATA8)
+#define REG_NAND_DATA_PADDR      HW_IO_VIRT_TO_PHYS(REG_NAND_PHYS_DATA_DMA)
+
+#define NAND_BUS_16BIT()        (0)
+#define NAND_BUS_8BIT()         (!NAND_BUS_16BIT())
+
+/* Register offsets */
+#define REG_NAND_CMD_OFFSET     (0)
+#define REG_NAND_ADDR_OFFSET    (4)
+#define REG_NAND_DATA8_OFFSET   (8)
+
+#endif
diff --git a/arch/arm/mach-bcmring/include/mach/reg_umi.h b/arch/arm/mach-bcmring/include/mach/reg_umi.h
new file mode 100644 (file)
index 0000000..06a3554
--- /dev/null
@@ -0,0 +1,237 @@
+/*****************************************************************************
+* Copyright 2005 - 2008 Broadcom Corporation.  All rights reserved.
+*
+* Unless you and Broadcom execute a separate written software license
+* agreement governing use of this software, this software is licensed to you
+* under the terms of the GNU General Public License version 2, available at
+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
+*
+* Notwithstanding the above, under no circumstances may you combine this
+* software in any way with any other Broadcom software provided under a
+* license other than the GPL, without Broadcom's express prior written
+* consent.
+*****************************************************************************/
+
+/*
+*
+*****************************************************************************
+*
+*  REG_UMI.h
+*
+*  PURPOSE:
+*
+*     This file contains definitions for the nand registers:
+*
+*  NOTES:
+*
+*****************************************************************************/
+
+#if !defined(__ASM_ARCH_REG_UMI_H)
+#define __ASM_ARCH_REG_UMI_H
+
+/* ---- Include Files ---------------------------------------------------- */
+#include <csp/reg.h>
+#include <mach/csp/mm_io.h>
+
+/* ---- Constants and Types ---------------------------------------------- */
+
+/* Unified Memory Interface Ctrl Register */
+#define HW_UMI_BASE       MM_IO_BASE_UMI
+
+/* Flash bank 0 timing and control register */
+#define REG_UMI_FLASH0_TCR         __REG32(HW_UMI_BASE  + 0x00)
+/* Flash bank 1 timing and control register */
+#define REG_UMI_FLASH1_TCR         __REG32(HW_UMI_BASE  + 0x04)
+/* Flash bank 2 timing and control register */
+#define REG_UMI_FLASH2_TCR         __REG32(HW_UMI_BASE  + 0x08)
+/* MMD interface and control register */
+#define REG_UMI_MMD_ICR            __REG32(HW_UMI_BASE  + 0x0c)
+/* NAND timing and control register */
+#define REG_UMI_NAND_TCR           __REG32(HW_UMI_BASE  + 0x18)
+/* NAND ready/chip select register */
+#define REG_UMI_NAND_RCSR          __REG32(HW_UMI_BASE  + 0x1c)
+/* NAND ECC control & status register */
+#define REG_UMI_NAND_ECC_CSR       __REG32(HW_UMI_BASE  + 0x20)
+/* NAND ECC data register XXB2B1B0 */
+#define REG_UMI_NAND_ECC_DATA      __REG32(HW_UMI_BASE  + 0x24)
+/* BCH ECC Parameter N */
+#define REG_UMI_BCH_N              __REG32(HW_UMI_BASE  + 0x40)
+/* BCH ECC Parameter T */
+#define REG_UMI_BCH_K              __REG32(HW_UMI_BASE  + 0x44)
+/* BCH ECC Parameter K */
+#define REG_UMI_BCH_T              __REG32(HW_UMI_BASE  + 0x48)
+/* BCH ECC Contro Status */
+#define REG_UMI_BCH_CTRL_STATUS    __REG32(HW_UMI_BASE  + 0x4C)
+/* BCH WR ECC 31:0 */
+#define REG_UMI_BCH_WR_ECC_0       __REG32(HW_UMI_BASE  + 0x50)
+/* BCH WR ECC 63:32 */
+#define REG_UMI_BCH_WR_ECC_1       __REG32(HW_UMI_BASE  + 0x54)
+/* BCH WR ECC 95:64 */
+#define REG_UMI_BCH_WR_ECC_2       __REG32(HW_UMI_BASE  + 0x58)
+/* BCH WR ECC 127:96 */
+#define REG_UMI_BCH_WR_ECC_3       __REG32(HW_UMI_BASE  + 0x5c)
+/* BCH WR ECC 155:128 */
+#define REG_UMI_BCH_WR_ECC_4       __REG32(HW_UMI_BASE  + 0x60)
+/* BCH Read Error Location 1,0 */
+#define REG_UMI_BCH_RD_ERR_LOC_1_0 __REG32(HW_UMI_BASE  + 0x64)
+/* BCH Read Error Location 3,2 */
+#define REG_UMI_BCH_RD_ERR_LOC_3_2 __REG32(HW_UMI_BASE  + 0x68)
+/* BCH Read Error Location 5,4 */
+#define REG_UMI_BCH_RD_ERR_LOC_5_4 __REG32(HW_UMI_BASE  + 0x6c)
+/* BCH Read Error Location 7,6 */
+#define REG_UMI_BCH_RD_ERR_LOC_7_6 __REG32(HW_UMI_BASE  + 0x70)
+/* BCH Read Error Location 9,8 */
+#define REG_UMI_BCH_RD_ERR_LOC_9_8 __REG32(HW_UMI_BASE  + 0x74)
+/* BCH Read Error Location 11,10 */
+#define REG_UMI_BCH_RD_ERR_LOC_B_A __REG32(HW_UMI_BASE  + 0x78)
+
+/* REG_UMI_FLASH0/1/2_TCR, REG_UMI_SRAM0/1_TCR bits */
+/* Enable wait pin during burst write or read */
+#define REG_UMI_TCR_WAITEN              0x80000000
+/* Enable mem ctrlr to work iwth ext mem of lower freq than AHB clk */
+#define REG_UMI_TCR_LOWFREQ             0x40000000
+/* 1=synch write, 0=async write */
+#define REG_UMI_TCR_MEMTYPE_SYNCWRITE   0x20000000
+/* 1=synch read, 0=async read */
+#define REG_UMI_TCR_MEMTYPE_SYNCREAD    0x10000000
+/* 1=page mode read, 0=normal mode read */
+#define REG_UMI_TCR_MEMTYPE_PAGEREAD    0x08000000
+/* page size/burst size (wrap only) */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_MASK   0x07000000
+/* 4 word */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_4      0x00000000
+/* 8 word */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_8      0x01000000
+/* 16 word */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_16     0x02000000
+/* 32 word */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_32     0x03000000
+/* 64 word */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_64     0x04000000
+/* 128 word */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_128    0x05000000
+/* 256 word */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_256    0x06000000
+/* 512 word */
+#define REG_UMI_TCR_MEMTYPE_PGSZ_512    0x07000000
+/* Page read access cycle / Burst write latency (n+2 / n+1) */
+#define REG_UMI_TCR_TPRC_TWLC_MASK      0x00f80000
+/* Bus turnaround cycle (n) */
+#define REG_UMI_TCR_TBTA_MASK           0x00070000
+/* Write pulse width cycle (n+1) */
+#define REG_UMI_TCR_TWP_MASK            0x0000f800
+/* Write recovery cycle (n+1) */
+#define REG_UMI_TCR_TWR_MASK            0x00000600
+/* Write address setup cycle (n+1) */
+#define REG_UMI_TCR_TAS_MASK            0x00000180
+/* Output enable delay cycle (n) */
+#define REG_UMI_TCR_TOE_MASK            0x00000060
+/* Read access cycle / Burst read latency (n+2 / n+1) */
+#define REG_UMI_TCR_TRC_TLC_MASK        0x0000001f
+
+/* REG_UMI_MMD_ICR bits */
+/* Flash write protection pin control */
+#define REG_UMI_MMD_ICR_FLASH_WP            0x8000
+/* Extend hold time for sram0, sram1 csn (39 MHz operation) */
+#define REG_UMI_MMD_ICR_XHCS                0x4000
+/* Enable SDRAM 2 interface control */
+#define REG_UMI_MMD_ICR_SDRAM2EN            0x2000
+/* Enable merge of flash banks 0/1 to 512 MBit bank */
+#define REG_UMI_MMD_ICR_INST512             0x1000
+/* Enable merge of flash banks 1/2 to 512 MBit bank */
+#define REG_UMI_MMD_ICR_DATA512             0x0800
+/* Enable SDRAM interface control */
+#define REG_UMI_MMD_ICR_SDRAMEN             0x0400
+/* Polarity of busy state of Burst Wait Signal */
+#define REG_UMI_MMD_ICR_WAITPOL             0x0200
+/* Enable burst clock stopped when not accessing external burst flash/sram */
+#define REG_UMI_MMD_ICR_BCLKSTOP            0x0100
+/* Enable the peri1_csn to replace flash1_csn in 512 Mb flash mode */
+#define REG_UMI_MMD_ICR_PERI1EN             0x0080
+/* Enable the peri2_csn to replace sdram_csn */
+#define REG_UMI_MMD_ICR_PERI2EN             0x0040
+/* Enable the peri3_csn to replace sdram2_csn */
+#define REG_UMI_MMD_ICR_PERI3EN             0x0020
+/* Enable sram bank1 for H/W controlled MRS */
+#define REG_UMI_MMD_ICR_MRSB1               0x0010
+/* Enable sram bank0 for H/W controlled MRS */
+#define REG_UMI_MMD_ICR_MRSB0               0x0008
+/* Polarity for assert3ed state of H/W controlled MRS */
+#define REG_UMI_MMD_ICR_MRSPOL              0x0004
+/* 0: S/W controllable ZZ/MRS/CRE/P-Mode pin */
+/* 1: H/W controlled ZZ/MRS/CRE/P-Mode, same timing as CS */
+#define REG_UMI_MMD_ICR_MRSMODE             0x0002
+/* MRS state for S/W controlled mode */
+#define REG_UMI_MMD_ICR_MRSSTATE            0x0001
+
+/* REG_UMI_NAND_TCR bits */
+/* Enable software to control CS */
+#define REG_UMI_NAND_TCR_CS_SWCTRL          0x80000000
+/* 16-bit nand wordsize if set */
+#define REG_UMI_NAND_TCR_WORD16             0x40000000
+/* Bus turnaround cycle (n) */
+#define REG_UMI_NAND_TCR_TBTA_MASK          0x00070000
+/* Write pulse width cycle (n+1) */
+#define REG_UMI_NAND_TCR_TWP_MASK           0x0000f800
+/* Write recovery cycle (n+1) */
+#define REG_UMI_NAND_TCR_TWR_MASK           0x00000600
+/* Write address setup cycle (n+1) */
+#define REG_UMI_NAND_TCR_TAS_MASK           0x00000180
+/* Output enable delay cycle (n) */
+#define REG_UMI_NAND_TCR_TOE_MASK           0x00000060
+/* Read access cycle (n+2) */
+#define REG_UMI_NAND_TCR_TRC_TLC_MASK       0x0000001f
+
+/* REG_UMI_NAND_RCSR bits */
+/* Status: Ready=1, Busy=0 */
+#define REG_UMI_NAND_RCSR_RDY               0x02
+/* Keep CS asserted during operation */
+#define REG_UMI_NAND_RCSR_CS_ASSERTED       0x01
+
+/* REG_UMI_NAND_ECC_CSR bits */
+/* Interrupt status - read-only */
+#define REG_UMI_NAND_ECC_CSR_NANDINT        0x80000000
+/* Read: Status of ECC done, Write: clear ECC interrupt */
+#define REG_UMI_NAND_ECC_CSR_ECCINT_RAW     0x00800000
+/* Read: Status of R/B, Write: clear R/B interrupt */
+#define REG_UMI_NAND_ECC_CSR_RBINT_RAW      0x00400000
+/* 1 = Enable ECC Interrupt */
+#define REG_UMI_NAND_ECC_CSR_ECCINT_ENABLE  0x00008000
+/* 1 = Assert interrupt at rising edge of R/B_ */
+#define REG_UMI_NAND_ECC_CSR_RBINT_ENABLE   0x00004000
+/* Calculate ECC by 0=512 bytes, 1=256 bytes */
+#define REG_UMI_NAND_ECC_CSR_256BYTE        0x00000080
+/* Enable ECC in hardware */
+#define REG_UMI_NAND_ECC_CSR_ECC_ENABLE     0x00000001
+
+/* REG_UMI_BCH_CTRL_STATUS bits */
+/* Shift to Indicate Number of correctable errors detected */
+#define REG_UMI_BCH_CTRL_STATUS_NB_CORR_ERROR_SHIFT 20
+/* Indicate Number of correctable errors detected */
+#define REG_UMI_BCH_CTRL_STATUS_NB_CORR_ERROR 0x00F00000
+/* Indicate Errors detected during read but uncorrectable */
+#define REG_UMI_BCH_CTRL_STATUS_UNCORR_ERR    0x00080000
+/* Indicate Errors detected during read and are correctable */
+#define REG_UMI_BCH_CTRL_STATUS_CORR_ERR      0x00040000
+/* Flag indicates BCH's ECC status of read process are valid */
+#define REG_UMI_BCH_CTRL_STATUS_RD_ECC_VALID  0x00020000
+/* Flag indicates BCH's ECC status of write process are valid */
+#define REG_UMI_BCH_CTRL_STATUS_WR_ECC_VALID  0x00010000
+/* Pause ECC calculation */
+#define REG_UMI_BCH_CTRL_STATUS_PAUSE_ECC_DEC 0x00000010
+/* Enable Interrupt */
+#define REG_UMI_BCH_CTRL_STATUS_INT_EN        0x00000004
+/* Enable ECC during read */
+#define REG_UMI_BCH_CTRL_STATUS_ECC_RD_EN     0x00000002
+/* Enable ECC during write */
+#define REG_UMI_BCH_CTRL_STATUS_ECC_WR_EN     0x00000001
+/* Mask for location */
+#define REG_UMI_BCH_ERR_LOC_MASK              0x00001FFF
+/* location within a byte */
+#define REG_UMI_BCH_ERR_LOC_BYTE              0x00000007
+/* location within a word */
+#define REG_UMI_BCH_ERR_LOC_WORD              0x00000018
+/* location within a page (512 byte) */
+#define REG_UMI_BCH_ERR_LOC_PAGE              0x00001FE0
+#define REG_UMI_BCH_ERR_LOC_ADDR(index)     (__REG32(HW_UMI_BASE + 0x64 + (index / 2)*4) >> ((index % 2) * 16))
+#endif
index 62b98bffc158c452e5a063e014f78e5b7c497cf7..07de8db145812c68a6cf386ef68ff10c2251f9b7 100644 (file)
@@ -339,6 +339,15 @@ static struct davinci_mmc_config da850_mmc_config = {
        .version        = MMC_CTLR_VERSION_2,
 };
 
+static void da850_panel_power_ctrl(int val)
+{
+       /* lcd backlight */
+       gpio_set_value(DA850_LCD_BL_PIN, val);
+
+       /* lcd power */
+       gpio_set_value(DA850_LCD_PWR_PIN, val);
+}
+
 static int da850_lcd_hw_init(void)
 {
        int status;
@@ -356,17 +365,11 @@ static int da850_lcd_hw_init(void)
        gpio_direction_output(DA850_LCD_BL_PIN, 0);
        gpio_direction_output(DA850_LCD_PWR_PIN, 0);
 
-       /* disable lcd backlight */
-       gpio_set_value(DA850_LCD_BL_PIN, 0);
-
-       /* disable lcd power */
-       gpio_set_value(DA850_LCD_PWR_PIN, 0);
-
-       /* enable lcd power */
-       gpio_set_value(DA850_LCD_PWR_PIN, 1);
+       /* Switch off panel power and backlight */
+       da850_panel_power_ctrl(0);
 
-       /* enable lcd backlight */
-       gpio_set_value(DA850_LCD_BL_PIN, 1);
+       /* Switch on panel power and backlight */
+       da850_panel_power_ctrl(1);
 
        return 0;
 }
@@ -674,6 +677,7 @@ static __init void da850_evm_init(void)
                pr_warning("da850_evm_init: lcd initialization failed: %d\n",
                                ret);
 
+       sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
        ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
        if (ret)
                pr_warning("da850_evm_init: lcdc registration failed: %d\n",
index b520c4b5678a2480b8e454b25b7f3b9034c84dae..b2ad8090bd1058b86367c19456a3a0ef42d57efb 100644 (file)
@@ -79,6 +79,10 @@ struct davinci_nand_pdata {          /* platform_data */
 
        /* e.g. NAND_BUSWIDTH_16 or NAND_USE_FLASH_BBT */
        unsigned                options;
+
+       /* Main and mirror bbt descriptor overrides */
+       struct nand_bbt_descr   *bbt_td;
+       struct nand_bbt_descr   *bbt_md;
 };
 
 #endif /* __ARCH_ARM_DAVINCI_NAND_H */
index 32f8609e4f858a18008ba7499e59bfe2b3ad061a..3afb1b25946f96b88b5390ab2ec59414b53ba5b5 100644 (file)
@@ -4,7 +4,7 @@
 
 # Object file lists.
 
-obj-y                  := common.o dc21285.o dma.o isa-irq.o time.o
+obj-y                  := common.o dc21285.o dma.o isa-irq.o
 obj-m                  :=
 obj-n                  :=
 obj-                   :=
@@ -25,4 +25,4 @@ obj-$(CONFIG_ARCH_PERSONAL_SERVER) += personal.o dc21285-timer.o
 obj-$(CONFIG_PCI)      +=$(pci-y)
 obj-$(CONFIG_LEDS)     +=$(leds-y)
 
-obj-$(CONFIG_ISA)      += isa.o
+obj-$(CONFIG_ISA)      += isa.o isa-rtc.o
index da35bc5c5ccc527a139852843fd3702efb8e116f..bc5e83fb5819edacfc17c1315a16028b3dd4cc8c 100644 (file)
@@ -56,8 +56,6 @@ static void __init footbridge_timer_init(void)
        *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
 
        setup_irq(IRQ_TIMER1, &footbridge_timer_irq);
-
-       isa_rtc_init();
 }
 
 struct sys_timer footbridge_timer = {
diff --git a/arch/arm/mach-footbridge/isa-rtc.c b/arch/arm/mach-footbridge/isa-rtc.c
new file mode 100644 (file)
index 0000000..07fde40
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ *  arch/arm/mach-footbridge/isa-rtc.c
+ *
+ *  Copyright (C) 1998 Russell King.
+ *  Copyright (C) 1998 Phil Blundell
+ *
+ * CATS has a real-time clock, though the evaluation board doesn't.
+ *
+ * Changelog:
+ *  21-Mar-1998        RMK     Created
+ *  27-Aug-1998        PJB     CATS support
+ *  28-Dec-1998        APH     Made leds optional
+ *  20-Jan-1999        RMK     Started merge of EBSA285, CATS and NetWinder
+ *  16-Mar-1999        RMK     More support for EBSA285-like machines with RTCs in
+ */
+
+#define RTC_PORT(x)            (0x70+(x))
+#define RTC_ALWAYS_BCD         0
+
+#include <linux/init.h>
+#include <linux/mc146818rtc.h>
+#include <linux/bcd.h>
+#include <linux/io.h>
+
+#include "common.h"
+
+void __init isa_rtc_init(void)
+{
+       int reg_d, reg_b;
+
+       /*
+        * Probe for the RTC.
+        */
+       reg_d = CMOS_READ(RTC_REG_D);
+
+       /*
+        * make sure the divider is set
+        */
+       CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_REG_A);
+
+       /*
+        * Set control reg B
+        *   (24 hour mode, update enabled)
+        */
+       reg_b = CMOS_READ(RTC_REG_B) & 0x7f;
+       reg_b |= 2;
+       CMOS_WRITE(reg_b, RTC_REG_B);
+
+       if ((CMOS_READ(RTC_REG_A) & 0x7f) == RTC_REF_CLCK_32KHZ &&
+           CMOS_READ(RTC_REG_B) == reg_b) {
+               /*
+                * We have a RTC.  Check the battery
+                */
+               if ((reg_d & 0x80) == 0)
+                       printk(KERN_WARNING "RTC: *** warning: CMOS battery bad\n");
+       }
+}
index 0c8390082fa8a49ef23c02071d7373c3d299c7d0..f488fa2082d76c07e51c890bb81856cb69b1618f 100644 (file)
@@ -76,8 +76,6 @@ static struct irqaction isa_timer_irq = {
 
 static void __init isa_timer_init(void)
 {
-       isa_rtc_init();
-
        /* enable PIT timer */
        /* set for periodic (4) and LSB/MSB write (0x30) */
        outb(0x34, 0x43);
index 725a219d0ed594e7a2b39b3d9f4ef86e66335c42..4d9276c27d6f309bba9be58bb2ae773c9725bc81 100644 (file)
@@ -11,6 +11,9 @@
 #include <linux/serial_8250.h>
 
 #include <asm/irq.h>
+#include <asm/hardware/dec21285.h>
+
+#include "common.h"
 
 static struct resource rtc_resources[] = {
        [0] = {
@@ -77,11 +80,18 @@ static struct platform_device serial_device = {
 
 static int __init footbridge_isa_init(void)
 {
-       int err;
+       int err = 0;
 
-       err = platform_device_register(&rtc_device);
-       if (err)
-               printk(KERN_ERR "Unable to register RTC device: %d\n", err);
+       if (!footbridge_cfn_mode())
+               return 0;
+
+       /* Personal server doesn't have RTC */
+       if (!machine_is_personal_server()) {
+               isa_rtc_init();
+               err = platform_device_register(&rtc_device);
+               if (err)
+                       printk(KERN_ERR "Unable to register RTC device: %d\n", err);
+       }
        err = platform_device_register(&serial_device);
        if (err)
                printk(KERN_ERR "Unable to register serial device: %d\n", err);
diff --git a/arch/arm/mach-footbridge/time.c b/arch/arm/mach-footbridge/time.c
deleted file mode 100644 (file)
index cd1b54f..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- *  arch/arm/mach-footbridge/include/mach/time.h
- *
- *  Copyright (C) 1998 Russell King.
- *  Copyright (C) 1998 Phil Blundell
- *
- * CATS has a real-time clock, though the evaluation board doesn't.
- *
- * Changelog:
- *  21-Mar-1998        RMK     Created
- *  27-Aug-1998        PJB     CATS support
- *  28-Dec-1998        APH     Made leds optional
- *  20-Jan-1999        RMK     Started merge of EBSA285, CATS and NetWinder
- *  16-Mar-1999        RMK     More support for EBSA285-like machines with RTCs in
- */
-
-#define RTC_PORT(x)            (rtc_base+(x))
-#define RTC_ALWAYS_BCD         0
-
-#include <linux/timex.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/mc146818rtc.h>
-#include <linux/bcd.h>
-#include <linux/io.h>
-
-#include <mach/hardware.h>
-
-#include <asm/mach/time.h>
-#include "common.h"
-
-static int rtc_base;
-
-static unsigned long __init get_isa_cmos_time(void)
-{
-       unsigned int year, mon, day, hour, min, sec;
-
-       // check to see if the RTC makes sense.....
-       if ((CMOS_READ(RTC_VALID) & RTC_VRT) == 0)
-               return mktime(1970, 1, 1, 0, 0, 0);
-
-       do {
-               sec  = CMOS_READ(RTC_SECONDS);
-               min  = CMOS_READ(RTC_MINUTES);
-               hour = CMOS_READ(RTC_HOURS);
-               day  = CMOS_READ(RTC_DAY_OF_MONTH);
-               mon  = CMOS_READ(RTC_MONTH);
-               year = CMOS_READ(RTC_YEAR);
-       } while (sec != CMOS_READ(RTC_SECONDS));
-
-       if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-               sec = bcd2bin(sec);
-               min = bcd2bin(min);
-               hour = bcd2bin(hour);
-               day = bcd2bin(day);
-               mon = bcd2bin(mon);
-               year = bcd2bin(year);
-       }
-       if ((year += 1900) < 1970)
-               year += 100;
-       return mktime(year, mon, day, hour, min, sec);
-}
-
-static int set_isa_cmos_time(void)
-{
-       int retval = 0;
-       int real_seconds, real_minutes, cmos_minutes;
-       unsigned char save_control, save_freq_select;
-       unsigned long nowtime = xtime.tv_sec;
-
-       save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
-       CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
-
-       save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
-       CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
-
-       cmos_minutes = CMOS_READ(RTC_MINUTES);
-       if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
-               cmos_minutes = bcd2bin(cmos_minutes);
-
-       /*
-        * since we're only adjusting minutes and seconds,
-        * don't interfere with hour overflow. This avoids
-        * messing with unknown time zones but requires your
-        * RTC not to be off by more than 15 minutes
-        */
-       real_seconds = nowtime % 60;
-       real_minutes = nowtime / 60;
-       if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
-               real_minutes += 30;             /* correct for half hour time zone */
-       real_minutes %= 60;
-
-       if (abs(real_minutes - cmos_minutes) < 30) {
-               if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
-                       real_seconds = bin2bcd(real_seconds);
-                       real_minutes = bin2bcd(real_minutes);
-               }
-               CMOS_WRITE(real_seconds,RTC_SECONDS);
-               CMOS_WRITE(real_minutes,RTC_MINUTES);
-       } else
-               retval = -1;
-
-       /* The following flags have to be released exactly in this order,
-        * otherwise the DS12887 (popular MC146818A clone with integrated
-        * battery and quartz) will not reset the oscillator and will not
-        * update precisely 500 ms later. You won't find this mentioned in
-        * the Dallas Semiconductor data sheets, but who believes data
-        * sheets anyway ...                           -- Markus Kuhn
-        */
-       CMOS_WRITE(save_control, RTC_CONTROL);
-       CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
-
-       return retval;
-}
-
-void __init isa_rtc_init(void)
-{
-       if (machine_is_personal_server())
-               /*
-                * Add-in 21285s shouldn't access the RTC
-                */
-               rtc_base = 0;
-       else
-               rtc_base = 0x70;
-
-       if (rtc_base) {
-               int reg_d, reg_b;
-
-               /*
-                * Probe for the RTC.
-                */
-               reg_d = CMOS_READ(RTC_REG_D);
-
-               /*
-                * make sure the divider is set
-                */
-               CMOS_WRITE(RTC_REF_CLCK_32KHZ, RTC_REG_A);
-
-               /*
-                * Set control reg B
-                *   (24 hour mode, update enabled)
-                */
-               reg_b = CMOS_READ(RTC_REG_B) & 0x7f;
-               reg_b |= 2;
-               CMOS_WRITE(reg_b, RTC_REG_B);
-
-               if ((CMOS_READ(RTC_REG_A) & 0x7f) == RTC_REF_CLCK_32KHZ &&
-                   CMOS_READ(RTC_REG_B) == reg_b) {
-                       struct timespec tv;
-
-                       /*
-                        * We have a RTC.  Check the battery
-                        */
-                       if ((reg_d & 0x80) == 0)
-                               printk(KERN_WARNING "RTC: *** warning: CMOS battery bad\n");
-
-                       tv.tv_nsec = 0;
-                       tv.tv_sec = get_isa_cmos_time();
-                       do_settimeofday(&tv);
-                       set_rtc = set_isa_cmos_time;
-               } else
-                       rtc_base = 0;
-       }
-}
index 8bf09ae5b347dd19351a491d0c55d4c27ea0f614..f6c6196a51fa489cb1338a9ced5a06e0e6f52cb9 100644 (file)
@@ -52,6 +52,12 @@ config MACH_OPENRD_BASE
          Say 'Y' here if you want your kernel to support the
          Marvell OpenRD Base Board.
 
+config MACH_NETSPACE_V2
+       bool "LaCie Network Space v2 NAS Board"
+       help
+         Say 'Y' here if you want your kernel to support the
+         LaCie Network Space v2 NAS.
+
 endmenu
 
 endif
index 9f2f67b2b63d92aafc166a73ff86906ec837a12f..d4d7f53b0fb9d51c6b4cba7174c6749944e4bdc9 100644 (file)
@@ -8,5 +8,6 @@ obj-$(CONFIG_MACH_SHEEVAPLUG)           += sheevaplug-setup.o
 obj-$(CONFIG_MACH_TS219)               += ts219-setup.o tsx1x-common.o
 obj-$(CONFIG_MACH_TS41X)               += ts41x-setup.o tsx1x-common.o
 obj-$(CONFIG_MACH_OPENRD_BASE)         += openrd_base-setup.o
+obj-$(CONFIG_MACH_NETSPACE_V2)         += netspace_v2-setup.o
 
 obj-$(CONFIG_CPU_IDLE)                 += cpuidle.o
diff --git a/arch/arm/mach-kirkwood/netspace_v2-setup.c b/arch/arm/mach-kirkwood/netspace_v2-setup.c
new file mode 100644 (file)
index 0000000..9a06406
--- /dev/null
@@ -0,0 +1,325 @@
+/*
+ * arch/arm/mach-kirkwood/netspace_v2-setup.c
+ *
+ * LaCie Network Space v2 board setup
+ *
+ * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
+ * Copyright (C) 2009 Benoît Canet <benoit.canet@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/physmap.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/spi.h>
+#include <linux/ata_platform.h>
+#include <linux/mv643xx_eth.h>
+#include <linux/i2c.h>
+#include <linux/i2c/at24.h>
+#include <linux/input.h>
+#include <linux/gpio.h>
+#include <linux/gpio_keys.h>
+#include <linux/leds.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/time.h>
+#include <mach/kirkwood.h>
+#include <plat/time.h>
+#include "common.h"
+#include "mpp.h"
+
+/*****************************************************************************
+ * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
+ ****************************************************************************/
+
+static struct mtd_partition netspace_v2_flash_parts[] = {
+       {
+               .name = "u-boot",
+               .size = MTDPART_SIZ_FULL,
+               .offset = 0,
+               .mask_flags = MTD_WRITEABLE, /* force read-only */
+       },
+};
+
+static const struct flash_platform_data netspace_v2_flash = {
+       .type           = "mx25l4005a",
+       .name           = "spi_flash",
+       .parts          = netspace_v2_flash_parts,
+       .nr_parts       = ARRAY_SIZE(netspace_v2_flash_parts),
+};
+
+static struct spi_board_info __initdata netspace_v2_spi_slave_info[] = {
+       {
+               .modalias       = "m25p80",
+               .platform_data  = &netspace_v2_flash,
+               .irq            = -1,
+               .max_speed_hz   = 20000000,
+               .bus_num        = 0,
+               .chip_select    = 0,
+       },
+};
+
+/*****************************************************************************
+ * Ethernet
+ ****************************************************************************/
+
+static struct mv643xx_eth_platform_data netspace_v2_ge00_data = {
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
+};
+
+/*****************************************************************************
+ * I2C devices
+ ****************************************************************************/
+
+static struct at24_platform_data at24c04 = {
+       .byte_len       = SZ_4K / 8,
+       .page_size      = 16,
+};
+
+/*
+ * i2c addr | chip         | description
+ * 0x50     | HT24LC04     | eeprom (512B)
+ */
+
+static struct i2c_board_info __initdata netspace_v2_i2c_info[] = {
+       {
+               I2C_BOARD_INFO("24c04", 0x50),
+               .platform_data  = &at24c04,
+       }
+};
+
+/*****************************************************************************
+ * SATA
+ ****************************************************************************/
+
+static struct mv_sata_platform_data netspace_v2_sata_data = {
+       .n_ports        = 2,
+};
+
+#define NETSPACE_V2_GPIO_SATA0_POWER   16
+#define NETSPACE_V2_GPIO_SATA1_POWER   17
+
+static void __init netspace_v2_sata_power_init(void)
+{
+       int err;
+
+       err = gpio_request(NETSPACE_V2_GPIO_SATA0_POWER, "SATA0 power");
+       if (err == 0) {
+               err = gpio_direction_output(NETSPACE_V2_GPIO_SATA0_POWER, 1);
+               if (err)
+                       gpio_free(NETSPACE_V2_GPIO_SATA0_POWER);
+       }
+       if (err)
+               pr_err("netspace_v2: failed to setup SATA0 power\n");
+}
+
+/*****************************************************************************
+ * GPIO keys
+ ****************************************************************************/
+
+#define NETSPACE_V2_PUSH_BUTTON                32
+
+static struct gpio_keys_button netspace_v2_buttons[] = {
+       [0] = {
+               .code           = KEY_POWER,
+               .gpio           = NETSPACE_V2_PUSH_BUTTON,
+               .desc           = "Power push button",
+               .active_low     = 0,
+       },
+};
+
+static struct gpio_keys_platform_data netspace_v2_button_data = {
+       .buttons        = netspace_v2_buttons,
+       .nbuttons       = ARRAY_SIZE(netspace_v2_buttons),
+};
+
+static struct platform_device netspace_v2_gpio_buttons = {
+       .name           = "gpio-keys",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &netspace_v2_button_data,
+       },
+};
+
+/*****************************************************************************
+ * GPIO LEDs
+ ****************************************************************************/
+
+/*
+ * The blue front LED is wired to a CPLD and can blink in relation with the
+ * SATA activity.
+ *
+ * The following array detail the different LED registers and the combination
+ * of their possible values:
+ *
+ *  cmd_led   |  slow_led  | /SATA active | LED state
+ *            |            |              |
+ *     1      |     0      |      x       |  off
+ *     -      |     1      |      x       |  on
+ *     0      |     0      |      1       |  on
+ *     0      |     0      |      0       |  blink (rate 300ms)
+ */
+
+#define NETSPACE_V2_GPIO_RED_LED       12
+#define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29
+#define NETSPACE_V2_GPIO_BLUE_LED_CMD  30
+
+
+static struct gpio_led netspace_v2_gpio_led_pins[] = {
+       {
+               .name   = "ns_v2:red:fail",
+               .gpio   = NETSPACE_V2_GPIO_RED_LED,
+       },
+};
+
+static struct gpio_led_platform_data netspace_v2_gpio_leds_data = {
+       .num_leds       = ARRAY_SIZE(netspace_v2_gpio_led_pins),
+       .leds           = netspace_v2_gpio_led_pins,
+};
+
+static struct platform_device netspace_v2_gpio_leds = {
+       .name           = "leds-gpio",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &netspace_v2_gpio_leds_data,
+       },
+};
+
+static void __init netspace_v2_gpio_leds_init(void)
+{
+       platform_device_register(&netspace_v2_gpio_leds);
+
+       /*
+        * Configure the front blue LED to blink in relation with the SATA
+        * activity.
+        */
+       if (gpio_request(NETSPACE_V2_GPIO_BLUE_LED_SLOW,
+                        "SATA blue LED slow") != 0)
+               return;
+       if (gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_SLOW, 0) != 0)
+               goto err_free_1;
+       if (gpio_request(NETSPACE_V2_GPIO_BLUE_LED_CMD,
+                        "SATA blue LED command") != 0)
+               goto err_free_1;
+       if (gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_CMD, 0) != 0)
+               goto err_free_2;
+
+       return;
+
+err_free_2:
+       gpio_free(NETSPACE_V2_GPIO_BLUE_LED_CMD);
+err_free_1:
+       gpio_free(NETSPACE_V2_GPIO_BLUE_LED_SLOW);
+       pr_err("netspace_v2: failed to configure SATA blue LED\n");
+}
+
+/*****************************************************************************
+ * Timer
+ ****************************************************************************/
+
+static void netspace_v2_timer_init(void)
+{
+       kirkwood_tclk = 166666667;
+       orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk);
+}
+
+struct sys_timer netspace_v2_timer = {
+       .init = netspace_v2_timer_init,
+};
+
+/*****************************************************************************
+ * General Setup
+ ****************************************************************************/
+
+static unsigned int netspace_v2_mpp_config[] __initdata = {
+       MPP0_SPI_SCn,
+       MPP1_SPI_MOSI,
+       MPP2_SPI_SCK,
+       MPP3_SPI_MISO,
+       MPP4_NF_IO6,
+       MPP5_NF_IO7,
+       MPP6_SYSRST_OUTn,
+       MPP8_TW_SDA,
+       MPP9_TW_SCK,
+       MPP10_UART0_TXD,
+       MPP11_UART0_RXD,
+       MPP12_GPO,              /* Red led */
+       MPP14_GPIO,             /* USB fuse */
+       MPP16_GPIO,             /* SATA 0 power */
+       MPP18_NF_IO0,
+       MPP19_NF_IO1,
+       MPP20_SATA1_ACTn,
+       MPP21_SATA0_ACTn,
+       MPP24_GPIO,             /* USB mode select */
+       MPP25_GPIO,             /* Fan rotation fail */
+       MPP26_GPIO,             /* USB device vbus */
+       MPP28_GPIO,             /* USB enable host vbus */
+       MPP29_GPIO,             /* Blue led (slow register) */
+       MPP30_GPIO,             /* Blue led (command register) */
+       MPP31_GPIO,             /* Board power off */
+       MPP32_GPIO,             /* Power button (0 = Released, 1 = Pushed) */
+       0
+};
+
+#define NETSPACE_V2_GPIO_POWER_OFF     31
+
+static void netspace_v2_power_off(void)
+{
+       gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1);
+}
+
+static void __init netspace_v2_init(void)
+{
+       /*
+        * Basic setup. Needs to be called early.
+        */
+       kirkwood_init();
+       kirkwood_mpp_conf(netspace_v2_mpp_config);
+
+       netspace_v2_sata_power_init();
+
+       kirkwood_ehci_init();
+       kirkwood_ge00_init(&netspace_v2_ge00_data);
+       kirkwood_sata_init(&netspace_v2_sata_data);
+       kirkwood_uart0_init();
+       spi_register_board_info(netspace_v2_spi_slave_info,
+                               ARRAY_SIZE(netspace_v2_spi_slave_info));
+       kirkwood_spi_init();
+       kirkwood_i2c_init();
+       i2c_register_board_info(0, netspace_v2_i2c_info,
+                               ARRAY_SIZE(netspace_v2_i2c_info));
+
+       netspace_v2_gpio_leds_init();
+       platform_device_register(&netspace_v2_gpio_buttons);
+
+       if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&
+           gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0)
+               pm_power_off = netspace_v2_power_off;
+       else
+               pr_err("netspace_v2: failed to configure power-off GPIO\n");
+}
+
+MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")
+       .phys_io        = KIRKWOOD_REGS_PHYS_BASE,
+       .io_pg_offst    = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
+       .boot_params    = 0x00000100,
+       .init_machine   = netspace_v2_init,
+       .map_io         = kirkwood_map_io,
+       .init_irq       = kirkwood_init_irq,
+       .timer          = &netspace_v2_timer,
+MACHINE_END
index 116394484e7184d343fdfd18868bfc65ba4c613f..9438bf6613a3f30ac0333b14f11d88ef1647a4b7 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/gpio.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
+#include <linux/mtd/onenand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/io.h>
 #include <asm/sizes.h>
@@ -149,7 +150,7 @@ static struct mtd_partition nhk8815_onenand_partitions[] = {
        }
 };
 
-static struct flash_platform_data nhk8815_onenand_data = {
+static struct onenand_platform_data nhk8815_onenand_data = {
        .parts          = nhk8815_onenand_partitions,
        .nr_parts       = ARRAY_SIZE(nhk8815_onenand_partitions),
 };
@@ -163,7 +164,7 @@ static struct resource nhk8815_onenand_resource[] = {
 };
 
 static struct platform_device nhk8815_onenand_device = {
-       .name           = "onenand",
+       .name           = "onenand-flash",
        .id             = -1,
        .dev            = {
                .platform_data  = &nhk8815_onenand_data,
@@ -174,10 +175,10 @@ static struct platform_device nhk8815_onenand_device = {
 
 static void __init nhk8815_onenand_init(void)
 {
-#ifdef CONFIG_ONENAND
+#ifdef CONFIG_MTD_ONENAND
        /* Set up SMCS0 for OneNand */
-       writel(0x000030db, FSMC_BCR0);
-       writel(0x02100551, FSMC_BTR0);
+       writel(0x000030db, FSMC_BCR(0));
+       writel(0x02100551, FSMC_BTR(0));
 #endif
 }
 
index feb0e54a91de6de4c27c5210d2a1b5bc9ff39da8..038f24d47023938518728baead07fc2b3136ae6c 100644 (file)
@@ -66,7 +66,7 @@ static void handle_prio_irq(unsigned int irq, struct irq_desc *desc)
        struct irqaction *action;
        irqreturn_t action_ret;
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
 
        BUG_ON(desc->status & IRQ_INPROGRESS);
 
@@ -78,7 +78,7 @@ static void handle_prio_irq(unsigned int irq, struct irq_desc *desc)
                goto out_mask;
 
        desc->status |= IRQ_INPROGRESS;
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        action_ret = handle_IRQ_event(irq, action);
 
@@ -87,7 +87,7 @@ static void handle_prio_irq(unsigned int irq, struct irq_desc *desc)
         * Maybe this function should go to kernel/irq/chip.c? */
        note_interrupt(irq, desc, action_ret);
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
 
        if (desc->status & IRQ_DISABLED)
@@ -97,7 +97,7 @@ out_mask:
        /* ack unconditionally to unmask lower prio irqs */
        desc->chip->ack(irq);
 
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 #define handle_irq handle_prio_irq
 #endif
index 76c11ee113e9f38cbbb96e3f177de65fe7396232..10eafa70a909de702361949de09f30069da8fd88 100644 (file)
@@ -18,6 +18,7 @@ config ARCH_OMAP2430
 config ARCH_OMAP34XX
        bool "OMAP34xx Based System"
        depends on ARCH_OMAP3
+       select USB_ARCH_HAS_EHCI
 
 config ARCH_OMAP3430
        bool "OMAP3430 support"
index 1591aae645006be6f47edcc322ad49b175bd83ab..2626a9f8a73ae7c852c583d551502ff86aeaac9c 100644 (file)
@@ -29,7 +29,7 @@
 #include <linux/gpio.h>
 
 #include <linux/i2c/at24.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
index 44239e3ec02e802ec45d281043e56bec3207aec0..117b8fd7e3a6445cba151b787749df9419acc00d 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/interrupt.h>
 
 #include <linux/regulator/machine.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
index 18913e96e34d3fd3b66200156175938fc3c0e214..34de17851572e746858d84050475eb23ddb620c8 100644 (file)
@@ -26,7 +26,7 @@
 
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 #include <linux/usb/otg.h>
 #include <linux/smsc911x.h>
 
index c9e5ebb4d91d5ba4b8090e5631b9fdfc0e0f3840..fe3d22cb24573390540295730ca4b4f58f6a7d00 100644 (file)
@@ -34,7 +34,7 @@
 #include <linux/spi/ads7846.h>
 
 #include <linux/regulator/machine.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
index 17f3c91231dbfb066725d730984b2e99dc9f1b1d..acafdbc8aa16c91ddce87bcec6b3c425cb0e4f7b 100644 (file)
@@ -16,7 +16,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/wl12xx.h>
 #include <linux/i2c.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/regulator/machine.h>
index 258794db488f53a49ca8c4aab56ec6da1f060631..8dd277c36661dc39f0833151ce77218824599785 100755 (executable)
@@ -14,7 +14,7 @@
 #include <linux/input.h>
 #include <linux/input/matrix_keypad.h>
 #include <linux/gpio.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 #include <linux/regulator/machine.h>
 
 #include <asm/mach-types.h>
index 39b797bc14d62045c8f1d7f198f9522b4c5c78a2..19805a7de06c7f5e9858c664b5164b86df10b508 100644 (file)
@@ -640,12 +640,9 @@ void __init omap_serial_early_init(void)
                uart->num = i;
                p->private_data = uart;
                uart->p = p;
-               list_add_tail(&uart->node, &uart_list);
 
                if (cpu_is_omap44xx())
                        p->irq += 32;
-
-               omap_uart_enable_clocks(uart);
        }
 }
 
@@ -673,9 +670,13 @@ void __init omap_serial_init_port(int port)
        pdev = &uart->pdev;
        dev = &pdev->dev;
 
+       omap_uart_enable_clocks(uart);
+
        omap_uart_reset(uart);
        omap_uart_idle_init(uart);
 
+       list_add_tail(&uart->node, &uart_list);
+
        if (WARN_ON(platform_device_register(pdev)))
                return;
 
index e6d8e10ae5d1fe74c8e8b17414a325c69a763f6c..8a0837ea0294218a6f9ed85d43ba4862d4afc3fd 100644 (file)
@@ -110,6 +110,8 @@ config MACH_CM_X300
        bool "CompuLab CM-X300 modules"
        select PXA3xx
        select CPU_PXA300
+       select CPU_PXA310
+       select HAVE_PWM
 
 config ARCH_GUMSTIX
        bool "Gumstix XScale 255 boards"
@@ -240,7 +242,6 @@ config MACH_COLIBRI300
        select PXA3xx
        select CPU_PXA300
        select CPU_PXA310
-       select HAVE_PWM
 
 config MACH_COLIBRI320
        bool "Toradex Colibri PXA320"
index 3395463bb5a654e6327a51028c17a4ce0dfd6301..8e10db148f1b2cccdc70b07ba0785b280a80dcfc 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 
-#include <mach/hardware.h>
 #include <mach/udc.h>
 #include <mach/pxafb.h>
 #include <mach/mmc.h>
@@ -14,6 +13,7 @@
 #include <mach/pxa2xx_spi.h>
 #include <mach/camera.h>
 #include <mach/audio.h>
+#include <mach/hardware.h>
 #include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
index 193b39d654edc41b4ef9569b5d2927c29751f87d..4d9588373aa55a624de6ac4e8c451fe7dca0759e 100644 (file)
@@ -18,6 +18,8 @@ struct s3c2410_spi_info {
        unsigned int             num_cs;        /* total chipselects */
        int                      bus_num;       /* bus number to use. */
 
+       unsigned int             use_fiq:1;     /* use fiq */
+
        void (*gpio_setup)(struct s3c2410_spi_info *spi, int enable);
        void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol);
 };
index f76d6ff4aeb932359eacdeed6a758d79f691ed57..0b4a3a03071f2b72047d8e41295b8a8171057c44 100644 (file)
@@ -268,6 +268,9 @@ struct pcf50633_platform_data gta02_pcf_pdata = {
 
        .batteries = gta02_batteries,
        .num_batteries = ARRAY_SIZE(gta02_batteries),
+
+       .charger_reference_current_ma = 1000,
+
        .reg_init_data = {
                [PCF50633_REGULATOR_AUTO] = {
                        .constraints = {
diff --git a/arch/arm/mach-u300/include/mach/coh901318.h b/arch/arm/mach-u300/include/mach/coh901318.h
new file mode 100644 (file)
index 0000000..f4cfee9
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ *
+ * include/linux/coh901318.h
+ *
+ *
+ * Copyright (C) 2007-2009 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ * DMA driver for COH 901 318
+ * Author: Per Friden <per.friden@stericsson.com>
+ */
+
+#ifndef COH901318_H
+#define COH901318_H
+
+#include <linux/device.h>
+#include <linux/dmaengine.h>
+
+#define MAX_DMA_PACKET_SIZE_SHIFT 11
+#define MAX_DMA_PACKET_SIZE (1 << MAX_DMA_PACKET_SIZE_SHIFT)
+
+/**
+ * struct coh901318_lli - linked list item for DMAC
+ * @control: control settings for DMAC
+ * @src_addr: transfer source address
+ * @dst_addr: transfer destination address
+ * @link_addr:  physical address to next lli
+ * @virt_link_addr: virtual addres of next lli (only used by pool_free)
+ * @phy_this: physical address of current lli (only used by pool_free)
+ */
+struct coh901318_lli {
+       u32 control;
+       dma_addr_t src_addr;
+       dma_addr_t dst_addr;
+       dma_addr_t link_addr;
+
+       void *virt_link_addr;
+       dma_addr_t phy_this;
+};
+/**
+ * struct coh901318_params - parameters for DMAC configuration
+ * @config: DMA config register
+ * @ctrl_lli_last: DMA control register for the last lli in the list
+ * @ctrl_lli: DMA control register for an lli
+ * @ctrl_lli_chained: DMA control register for a chained lli
+ */
+struct coh901318_params {
+       u32 config;
+       u32 ctrl_lli_last;
+       u32 ctrl_lli;
+       u32 ctrl_lli_chained;
+};
+/**
+ * struct coh_dma_channel - dma channel base
+ * @name: ascii name of dma channel
+ * @number: channel id number
+ * @desc_nbr_max: number of preallocated descriptortors
+ * @priority_high: prio of channel, 0 low otherwise high.
+ * @param: configuration parameters
+ * @dev_addr: physical address of periphal connected to channel
+ */
+struct coh_dma_channel {
+       const char name[32];
+       const int number;
+       const int desc_nbr_max;
+       const int priority_high;
+       const struct coh901318_params param;
+       const dma_addr_t dev_addr;
+};
+
+/**
+ * dma_access_memory_state_t - register dma for memory access
+ *
+ * @dev: The dma device
+ * @active:  1 means dma intends to access memory
+ *           0 means dma wont access memory
+ */
+typedef void (*dma_access_memory_state_t)(struct device *dev,
+                                         bool active);
+
+/**
+ * struct powersave - DMA power save structure
+ * @lock: lock protecting data in this struct
+ * @started_channels: bit mask indicating active dma channels
+ */
+struct powersave {
+       spinlock_t lock;
+       u64 started_channels;
+};
+/**
+ * struct coh901318_platform - platform arch structure
+ * @chans_slave: specifying dma slave channels
+ * @chans_memcpy: specifying dma memcpy channels
+ * @access_memory_state: requesting DMA memeory access (on / off)
+ * @chan_conf: dma channel configurations
+ * @max_channels: max number of dma chanenls
+ */
+struct coh901318_platform {
+       const int *chans_slave;
+       const int *chans_memcpy;
+       const dma_access_memory_state_t access_memory_state;
+       const struct coh_dma_channel *chan_conf;
+       const int max_channels;
+};
+
+/**
+ * coh901318_get_bytes_left() - Get number of bytes left on a current transfer
+ * @chan: dma channel handle
+ * return number of bytes left, or negative on error
+ */
+u32 coh901318_get_bytes_left(struct dma_chan *chan);
+
+/**
+ * coh901318_stop() - Stops dma transfer
+ * @chan: dma channel handle
+ * return 0 on success otherwise negative value
+ */
+void coh901318_stop(struct dma_chan *chan);
+
+/**
+ * coh901318_continue() - Resumes a stopped dma transfer
+ * @chan: dma channel handle
+ * return 0 on success otherwise negative value
+ */
+void coh901318_continue(struct dma_chan *chan);
+
+/**
+ * coh901318_filter_id() - DMA channel filter function
+ * @chan: dma channel handle
+ * @chan_id: id of dma channel to be filter out
+ *
+ * In dma_request_channel() it specifies what channel id to be requested
+ */
+bool coh901318_filter_id(struct dma_chan *chan, void *chan_id);
+
+/*
+ * DMA Controller - this access the static mappings of the coh901318 dma.
+ *
+ */
+
+#define COH901318_MOD32_MASK                                   (0x1F)
+#define COH901318_WORD_MASK                                    (0xFFFFFFFF)
+/* INT_STATUS - Interrupt Status Registers 32bit (R/-) */
+#define COH901318_INT_STATUS1                                  (0x0000)
+#define COH901318_INT_STATUS2                                  (0x0004)
+/* TC_INT_STATUS - Terminal Count Interrupt Status Registers 32bit (R/-) */
+#define COH901318_TC_INT_STATUS1                               (0x0008)
+#define COH901318_TC_INT_STATUS2                               (0x000C)
+/* TC_INT_CLEAR - Terminal Count Interrupt Clear Registers 32bit (-/W) */
+#define COH901318_TC_INT_CLEAR1                                        (0x0010)
+#define COH901318_TC_INT_CLEAR2                                        (0x0014)
+/* RAW_TC_INT_STATUS - Raw Term Count Interrupt Status Registers 32bit (R/-) */
+#define COH901318_RAW_TC_INT_STATUS1                           (0x0018)
+#define COH901318_RAW_TC_INT_STATUS2                           (0x001C)
+/* BE_INT_STATUS - Bus Error Interrupt Status Registers 32bit (R/-) */
+#define COH901318_BE_INT_STATUS1                               (0x0020)
+#define COH901318_BE_INT_STATUS2                               (0x0024)
+/* BE_INT_CLEAR - Bus Error Interrupt Clear Registers 32bit (-/W) */
+#define COH901318_BE_INT_CLEAR1                                        (0x0028)
+#define COH901318_BE_INT_CLEAR2                                        (0x002C)
+/* RAW_BE_INT_STATUS - Raw Term Count Interrupt Status Registers 32bit (R/-) */
+#define COH901318_RAW_BE_INT_STATUS1                           (0x0030)
+#define COH901318_RAW_BE_INT_STATUS2                           (0x0034)
+
+/*
+ * CX_CFG - Channel Configuration Registers 32bit (R/W)
+ */
+#define COH901318_CX_CFG                                       (0x0100)
+#define COH901318_CX_CFG_SPACING                               (0x04)
+/* Channel enable activates tha dma job */
+#define COH901318_CX_CFG_CH_ENABLE                             (0x00000001)
+#define COH901318_CX_CFG_CH_DISABLE                            (0x00000000)
+/* Request Mode */
+#define COH901318_CX_CFG_RM_MASK                               (0x00000006)
+#define COH901318_CX_CFG_RM_MEMORY_TO_MEMORY                   (0x0 << 1)
+#define COH901318_CX_CFG_RM_PRIMARY_TO_MEMORY                  (0x1 << 1)
+#define COH901318_CX_CFG_RM_MEMORY_TO_PRIMARY                  (0x1 << 1)
+#define COH901318_CX_CFG_RM_PRIMARY_TO_SECONDARY               (0x3 << 1)
+#define COH901318_CX_CFG_RM_SECONDARY_TO_PRIMARY               (0x3 << 1)
+/* Linked channel request field. RM must == 11 */
+#define COH901318_CX_CFG_LCRF_SHIFT                            3
+#define COH901318_CX_CFG_LCRF_MASK                             (0x000001F8)
+#define COH901318_CX_CFG_LCR_DISABLE                           (0x00000000)
+/* Terminal Counter Interrupt Request Mask */
+#define COH901318_CX_CFG_TC_IRQ_ENABLE                         (0x00000200)
+#define COH901318_CX_CFG_TC_IRQ_DISABLE                                (0x00000000)
+/* Bus Error interrupt Mask */
+#define COH901318_CX_CFG_BE_IRQ_ENABLE                         (0x00000400)
+#define COH901318_CX_CFG_BE_IRQ_DISABLE                                (0x00000000)
+
+/*
+ * CX_STAT - Channel Status Registers 32bit (R/-)
+ */
+#define COH901318_CX_STAT                                      (0x0200)
+#define COH901318_CX_STAT_SPACING                              (0x04)
+#define COH901318_CX_STAT_RBE_IRQ_IND                          (0x00000008)
+#define COH901318_CX_STAT_RTC_IRQ_IND                          (0x00000004)
+#define COH901318_CX_STAT_ACTIVE                               (0x00000002)
+#define COH901318_CX_STAT_ENABLED                              (0x00000001)
+
+/*
+ * CX_CTRL - Channel Control Registers 32bit (R/W)
+ */
+#define COH901318_CX_CTRL                                      (0x0400)
+#define COH901318_CX_CTRL_SPACING                              (0x10)
+/* Transfer Count Enable */
+#define COH901318_CX_CTRL_TC_ENABLE                            (0x00001000)
+#define COH901318_CX_CTRL_TC_DISABLE                           (0x00000000)
+/* Transfer Count Value 0 - 4095 */
+#define COH901318_CX_CTRL_TC_VALUE_MASK                                (0x00000FFF)
+/* Burst count */
+#define COH901318_CX_CTRL_BURST_COUNT_MASK                     (0x0000E000)
+#define COH901318_CX_CTRL_BURST_COUNT_64_BYTES                 (0x7 << 13)
+#define COH901318_CX_CTRL_BURST_COUNT_48_BYTES                 (0x6 << 13)
+#define COH901318_CX_CTRL_BURST_COUNT_32_BYTES                 (0x5 << 13)
+#define COH901318_CX_CTRL_BURST_COUNT_16_BYTES                 (0x4 << 13)
+#define COH901318_CX_CTRL_BURST_COUNT_8_BYTES                  (0x3 << 13)
+#define COH901318_CX_CTRL_BURST_COUNT_4_BYTES                  (0x2 << 13)
+#define COH901318_CX_CTRL_BURST_COUNT_2_BYTES                  (0x1 << 13)
+#define COH901318_CX_CTRL_BURST_COUNT_1_BYTE                   (0x0 << 13)
+/* Source bus size  */
+#define COH901318_CX_CTRL_SRC_BUS_SIZE_MASK                    (0x00030000)
+#define COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS                 (0x2 << 16)
+#define COH901318_CX_CTRL_SRC_BUS_SIZE_16_BITS                 (0x1 << 16)
+#define COH901318_CX_CTRL_SRC_BUS_SIZE_8_BITS                  (0x0 << 16)
+/* Source address increment */
+#define COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE                  (0x00040000)
+#define COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE                 (0x00000000)
+/* Destination Bus Size */
+#define COH901318_CX_CTRL_DST_BUS_SIZE_MASK                    (0x00180000)
+#define COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS                 (0x2 << 19)
+#define COH901318_CX_CTRL_DST_BUS_SIZE_16_BITS                 (0x1 << 19)
+#define COH901318_CX_CTRL_DST_BUS_SIZE_8_BITS                  (0x0 << 19)
+/* Destination address increment */
+#define COH901318_CX_CTRL_DST_ADDR_INC_ENABLE                  (0x00200000)
+#define COH901318_CX_CTRL_DST_ADDR_INC_DISABLE                 (0x00000000)
+/* Master Mode (Master2 is only connected to MSL) */
+#define COH901318_CX_CTRL_MASTER_MODE_MASK                     (0x00C00000)
+#define COH901318_CX_CTRL_MASTER_MODE_M2R_M1W                  (0x3 << 22)
+#define COH901318_CX_CTRL_MASTER_MODE_M1R_M2W                  (0x2 << 22)
+#define COH901318_CX_CTRL_MASTER_MODE_M2RW                     (0x1 << 22)
+#define COH901318_CX_CTRL_MASTER_MODE_M1RW                     (0x0 << 22)
+/* Terminal Count flag to PER enable */
+#define COH901318_CX_CTRL_TCP_ENABLE                           (0x01000000)
+#define COH901318_CX_CTRL_TCP_DISABLE                          (0x00000000)
+/* Terminal Count flags to CPU enable */
+#define COH901318_CX_CTRL_TC_IRQ_ENABLE                                (0x02000000)
+#define COH901318_CX_CTRL_TC_IRQ_DISABLE                       (0x00000000)
+/* Hand shake to peripheral */
+#define COH901318_CX_CTRL_HSP_ENABLE                           (0x04000000)
+#define COH901318_CX_CTRL_HSP_DISABLE                          (0x00000000)
+#define COH901318_CX_CTRL_HSS_ENABLE                           (0x08000000)
+#define COH901318_CX_CTRL_HSS_DISABLE                          (0x00000000)
+/* DMA mode */
+#define COH901318_CX_CTRL_DDMA_MASK                            (0x30000000)
+#define COH901318_CX_CTRL_DDMA_LEGACY                          (0x0 << 28)
+#define COH901318_CX_CTRL_DDMA_DEMAND_DMA1                     (0x1 << 28)
+#define COH901318_CX_CTRL_DDMA_DEMAND_DMA2                     (0x2 << 28)
+/* Primary Request Data Destination */
+#define COH901318_CX_CTRL_PRDD_MASK                            (0x40000000)
+#define COH901318_CX_CTRL_PRDD_DEST                            (0x1 << 30)
+#define COH901318_CX_CTRL_PRDD_SOURCE                          (0x0 << 30)
+
+/*
+ * CX_SRC_ADDR - Channel Source Address Registers 32bit (R/W)
+ */
+#define COH901318_CX_SRC_ADDR                                  (0x0404)
+#define COH901318_CX_SRC_ADDR_SPACING                          (0x10)
+
+/*
+ * CX_DST_ADDR - Channel Destination Address Registers 32bit R/W
+ */
+#define COH901318_CX_DST_ADDR                                  (0x0408)
+#define COH901318_CX_DST_ADDR_SPACING                          (0x10)
+
+/*
+ * CX_LNK_ADDR - Channel Link Address Registers 32bit (R/W)
+ */
+#define COH901318_CX_LNK_ADDR                                  (0x040C)
+#define COH901318_CX_LNK_ADDR_SPACING                          (0x10)
+#define COH901318_CX_LNK_LINK_IMMEDIATE                                (0x00000001)
+#endif /* COH901318_H */
index 921cef991bf014d7f1be4f45a81d71b6758545a5..20dc0c96214dcae4e93bb67910e5c0027eb6cf8f 100644 (file)
@@ -96,6 +96,7 @@ static struct clk_lookup nuc900_clkregs[] = {
 
 struct plat_serial8250_port nuc900_uart_data[] = {
        NUC900_8250PORT(UART0),
+       {},
 };
 
 struct platform_device nuc900_serial_device = {
index 51f17b753348bd3e5f3ca508a061bdb7150e9f2e..ec711f4b40191affdef9fb1e021780e4b900747e 100644 (file)
@@ -197,7 +197,7 @@ static struct platform_device nuc900_device_emc = {
 
 /* SPI device */
 
-static struct w90p910_spi_info nuc900_spiflash_data = {
+static struct nuc900_spi_info nuc900_spiflash_data = {
        .num_cs         = 1,
        .lsb            = 0,
        .txneg          = 1,
index 050d9fe5ae1b851f15477b8919d3d150b736ab7d..56f1a74d7016ff3cb74750de05c920210639347a 100644 (file)
 
 #include <mach/regs-serial.h>
 #include <mach/map.h>
+#include <linux/serial_reg.h>
 
 #define arch_decomp_wdog()
 
+#define TX_DONE        (UART_LSR_TEMT | UART_LSR_THRE)
+static volatile u32 * uart_base = (u32 *)UART0_PA;
+
 static void putc(int ch)
 {
+       /* Check THRE and TEMT bits before we transmit the character.
+        */
+       while ((uart_base[UART_LSR] & TX_DONE) != TX_DONE)
+               barrier();
+
+       *uart_base = ch;
 }
 
 static inline void flush(void)
index dd4698c67cc383977ad2e7c1a798c19941081c42..baf638487a2d530acaf30c7cab9581b3ec5b6f47 100644 (file)
@@ -1,9 +1,5 @@
 comment "Processor Type"
 
-config CPU_32
-       bool
-       default y
-
 # Select CPU types depending on the architecture selected.  This selects
 # which CPUs we support in the kernel image, and the compiler instruction
 # optimiser behaviour.
index b63a8f7b95cf5a2575f012b91324cc2e273563cf..a89444a3c016f0c2ecee35d38655b109664bc91b 100644 (file)
@@ -127,15 +127,16 @@ ENTRY(fa_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(kaddr)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure that the data held in the page kaddr is written back
  *     to the page in question.
  *
- *     - kaddr   - kernel address (guaranteed to be page aligned)
+ *     - addr  - kernel address
+ *     - size  - size of region
  */
-ENTRY(fa_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(fa_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean & invalidate D line
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -213,7 +214,7 @@ ENTRY(fa_cache_fns)
        .long   fa_flush_user_cache_range
        .long   fa_coherent_kern_range
        .long   fa_coherent_user_range
-       .long   fa_flush_kern_dcache_page
+       .long   fa_flush_kern_dcache_area
        .long   fa_dma_inv_range
        .long   fa_dma_clean_range
        .long   fa_dma_flush_range
index 747f9a9021bb9d97de9e22d13b04bb5c38ecc15b..cb8fc6573b1b2c9dedbeeec0f9a87c491a78ba85 100644 (file)
 static void __iomem *l2x0_base;
 static DEFINE_SPINLOCK(l2x0_lock);
 
-static inline void sync_writel(unsigned long val, unsigned long reg,
-                              unsigned long complete_mask)
+static inline void cache_wait(void __iomem *reg, unsigned long mask)
 {
-       unsigned long flags;
-
-       spin_lock_irqsave(&l2x0_lock, flags);
-       writel(val, l2x0_base + reg);
        /* wait for the operation to complete */
-       while (readl(l2x0_base + reg) & complete_mask)
+       while (readl(reg) & mask)
                ;
-       spin_unlock_irqrestore(&l2x0_lock, flags);
 }
 
 static inline void cache_sync(void)
 {
-       sync_writel(0, L2X0_CACHE_SYNC, 1);
+       void __iomem *base = l2x0_base;
+       writel(0, base + L2X0_CACHE_SYNC);
+       cache_wait(base + L2X0_CACHE_SYNC, 1);
 }
 
 static inline void l2x0_inv_all(void)
 {
+       unsigned long flags;
+
        /* invalidate all ways */
-       sync_writel(0xff, L2X0_INV_WAY, 0xff);
+       spin_lock_irqsave(&l2x0_lock, flags);
+       writel(0xff, l2x0_base + L2X0_INV_WAY);
+       cache_wait(l2x0_base + L2X0_INV_WAY, 0xff);
        cache_sync();
+       spin_unlock_irqrestore(&l2x0_lock, flags);
 }
 
 static void l2x0_inv_range(unsigned long start, unsigned long end)
 {
-       unsigned long addr;
+       void __iomem *base = l2x0_base;
+       unsigned long flags;
 
+       spin_lock_irqsave(&l2x0_lock, flags);
        if (start & (CACHE_LINE_SIZE - 1)) {
                start &= ~(CACHE_LINE_SIZE - 1);
-               sync_writel(start, L2X0_CLEAN_INV_LINE_PA, 1);
+               cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1);
+               writel(start, base + L2X0_CLEAN_INV_LINE_PA);
                start += CACHE_LINE_SIZE;
        }
 
        if (end & (CACHE_LINE_SIZE - 1)) {
                end &= ~(CACHE_LINE_SIZE - 1);
-               sync_writel(end, L2X0_CLEAN_INV_LINE_PA, 1);
+               cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1);
+               writel(end, base + L2X0_CLEAN_INV_LINE_PA);
        }
 
-       for (addr = start; addr < end; addr += CACHE_LINE_SIZE)
-               sync_writel(addr, L2X0_INV_LINE_PA, 1);
+       while (start < end) {
+               unsigned long blk_end = start + min(end - start, 4096UL);
+
+               while (start < blk_end) {
+                       cache_wait(base + L2X0_INV_LINE_PA, 1);
+                       writel(start, base + L2X0_INV_LINE_PA);
+                       start += CACHE_LINE_SIZE;
+               }
+
+               if (blk_end < end) {
+                       spin_unlock_irqrestore(&l2x0_lock, flags);
+                       spin_lock_irqsave(&l2x0_lock, flags);
+               }
+       }
+       cache_wait(base + L2X0_INV_LINE_PA, 1);
        cache_sync();
+       spin_unlock_irqrestore(&l2x0_lock, flags);
 }
 
 static void l2x0_clean_range(unsigned long start, unsigned long end)
 {
-       unsigned long addr;
+       void __iomem *base = l2x0_base;
+       unsigned long flags;
 
+       spin_lock_irqsave(&l2x0_lock, flags);
        start &= ~(CACHE_LINE_SIZE - 1);
-       for (addr = start; addr < end; addr += CACHE_LINE_SIZE)
-               sync_writel(addr, L2X0_CLEAN_LINE_PA, 1);
+       while (start < end) {
+               unsigned long blk_end = start + min(end - start, 4096UL);
+
+               while (start < blk_end) {
+                       cache_wait(base + L2X0_CLEAN_LINE_PA, 1);
+                       writel(start, base + L2X0_CLEAN_LINE_PA);
+                       start += CACHE_LINE_SIZE;
+               }
+
+               if (blk_end < end) {
+                       spin_unlock_irqrestore(&l2x0_lock, flags);
+                       spin_lock_irqsave(&l2x0_lock, flags);
+               }
+       }
+       cache_wait(base + L2X0_CLEAN_LINE_PA, 1);
        cache_sync();
+       spin_unlock_irqrestore(&l2x0_lock, flags);
 }
 
 static void l2x0_flush_range(unsigned long start, unsigned long end)
 {
-       unsigned long addr;
+       void __iomem *base = l2x0_base;
+       unsigned long flags;
 
+       spin_lock_irqsave(&l2x0_lock, flags);
        start &= ~(CACHE_LINE_SIZE - 1);
-       for (addr = start; addr < end; addr += CACHE_LINE_SIZE)
-               sync_writel(addr, L2X0_CLEAN_INV_LINE_PA, 1);
+       while (start < end) {
+               unsigned long blk_end = start + min(end - start, 4096UL);
+
+               while (start < blk_end) {
+                       cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1);
+                       writel(start, base + L2X0_CLEAN_INV_LINE_PA);
+                       start += CACHE_LINE_SIZE;
+               }
+
+               if (blk_end < end) {
+                       spin_unlock_irqrestore(&l2x0_lock, flags);
+                       spin_lock_irqsave(&l2x0_lock, flags);
+               }
+       }
+       cache_wait(base + L2X0_CLEAN_INV_LINE_PA, 1);
        cache_sync();
+       spin_unlock_irqrestore(&l2x0_lock, flags);
 }
 
 void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
index 8a4abebc478a29617a55efeabd871480ca4ab9c2..2a482731ea36914f2f6ca2b6bb4299e7dee84742 100644 (file)
@@ -72,14 +72,15 @@ ENTRY(v3_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *page, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(v3_flush_kern_dcache_page)
+ENTRY(v3_flush_kern_dcache_area)
        /* FALLTHROUGH */
 
 /*
@@ -129,7 +130,7 @@ ENTRY(v3_cache_fns)
        .long   v3_flush_user_cache_range
        .long   v3_coherent_kern_range
        .long   v3_coherent_user_range
-       .long   v3_flush_kern_dcache_page
+       .long   v3_flush_kern_dcache_area
        .long   v3_dma_inv_range
        .long   v3_dma_clean_range
        .long   v3_dma_flush_range
index 3668611cb400325d9368e2707f41a25d0da93c50..5c7da3e372e94faa6f85a07b2c154730140f44b6 100644 (file)
@@ -82,14 +82,15 @@ ENTRY(v4_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(v4_flush_kern_dcache_page)
+ENTRY(v4_flush_kern_dcache_area)
        /* FALLTHROUGH */
 
 /*
@@ -141,7 +142,7 @@ ENTRY(v4_cache_fns)
        .long   v4_flush_user_cache_range
        .long   v4_coherent_kern_range
        .long   v4_coherent_user_range
-       .long   v4_flush_kern_dcache_page
+       .long   v4_flush_kern_dcache_area
        .long   v4_dma_inv_range
        .long   v4_dma_clean_range
        .long   v4_dma_flush_range
index 2ebc1b3bf856ff454f5a0c114ef0dea9e9fbcaed..3dbedf1ec0e7790612385b34def041378af5f0d9 100644 (file)
@@ -114,15 +114,16 @@ ENTRY(v4wb_flush_user_cache_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(v4wb_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(v4wb_flush_kern_dcache_area)
+       add     r1, r0, r1
        /* fall through */
 
 /*
@@ -224,7 +225,7 @@ ENTRY(v4wb_cache_fns)
        .long   v4wb_flush_user_cache_range
        .long   v4wb_coherent_kern_range
        .long   v4wb_coherent_user_range
-       .long   v4wb_flush_kern_dcache_page
+       .long   v4wb_flush_kern_dcache_area
        .long   v4wb_dma_inv_range
        .long   v4wb_dma_clean_range
        .long   v4wb_dma_flush_range
index c54fa2cc40e6e2f8ebfa2c60c7849ea94682bd70..b3b7410270b48e6bf3414de930e2eff0010cf6b3 100644 (file)
@@ -117,17 +117,18 @@ ENTRY(v4wt_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(v4wt_flush_kern_dcache_page)
+ENTRY(v4wt_flush_kern_dcache_area)
        mov     r2, #0
        mcr     p15, 0, r2, c7, c5, 0           @ invalidate I cache
-       add     r1, r0, #PAGE_SZ
+       add     r1, r0, r1
        /* fallthrough */
 
 /*
@@ -180,7 +181,7 @@ ENTRY(v4wt_cache_fns)
        .long   v4wt_flush_user_cache_range
        .long   v4wt_coherent_kern_range
        .long   v4wt_coherent_user_range
-       .long   v4wt_flush_kern_dcache_page
+       .long   v4wt_flush_kern_dcache_area
        .long   v4wt_dma_inv_range
        .long   v4wt_dma_clean_range
        .long   v4wt_dma_flush_range
index 295e25dd6381f69da0eaf59c8e9da1854434ddd8..4ba0a24ce6f58341bcf0a78aef56531709e7b774 100644 (file)
@@ -159,15 +159,16 @@ ENDPROC(v6_coherent_user_range)
 ENDPROC(v6_coherent_kern_range)
 
 /*
- *     v6_flush_kern_dcache_page(kaddr)
+ *     v6_flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure that the data held in the page kaddr is written back
  *     to the page in question.
  *
- *     - kaddr   - kernel address (guaranteed to be page aligned)
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(v6_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(v6_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:
 #ifdef HARVARD_CACHE
        mcr     p15, 0, r0, c7, c14, 1          @ clean & invalidate D line
@@ -271,7 +272,7 @@ ENTRY(v6_cache_fns)
        .long   v6_flush_user_cache_range
        .long   v6_coherent_kern_range
        .long   v6_coherent_user_range
-       .long   v6_flush_kern_dcache_page
+       .long   v6_flush_kern_dcache_area
        .long   v6_dma_inv_range
        .long   v6_dma_clean_range
        .long   v6_dma_flush_range
index e1bd9759617f16cce4d8b59c738e340afa22b2e2..9073db849fb46a75f08c18c1ae9790614696e377 100644 (file)
@@ -186,16 +186,17 @@ ENDPROC(v7_coherent_kern_range)
 ENDPROC(v7_coherent_user_range)
 
 /*
- *     v7_flush_kern_dcache_page(kaddr)
+ *     v7_flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure that the data held in the page kaddr is written back
  *     to the page in question.
  *
- *     - kaddr   - kernel address (guaranteed to be page aligned)
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(v7_flush_kern_dcache_page)
+ENTRY(v7_flush_kern_dcache_area)
        dcache_line_size r2, r3
-       add     r1, r0, #PAGE_SZ
+       add     r1, r0, r1
 1:
        mcr     p15, 0, r0, c7, c14, 1          @ clean & invalidate D line / unified line
        add     r0, r0, r2
@@ -203,7 +204,7 @@ ENTRY(v7_flush_kern_dcache_page)
        blo     1b
        dsb
        mov     pc, lr
-ENDPROC(v7_flush_kern_dcache_page)
+ENDPROC(v7_flush_kern_dcache_area)
 
 /*
  *     v7_dma_inv_range(start,end)
@@ -279,7 +280,7 @@ ENTRY(v7_cache_fns)
        .long   v7_flush_user_cache_range
        .long   v7_coherent_kern_range
        .long   v7_coherent_user_range
-       .long   v7_flush_kern_dcache_page
+       .long   v7_flush_kern_dcache_area
        .long   v7_dma_inv_range
        .long   v7_dma_clean_range
        .long   v7_dma_flush_range
index 841f355319bfee86725ef6348d07d96b9b4f446e..0fa1319273dead26070b178751828f025d661561 100644 (file)
@@ -48,7 +48,7 @@ static void v6_copy_user_highpage_nonaliasing(struct page *to,
         */
        if (page_address(to) != NULL)
 #endif
-               __cpuc_flush_dcache_page(kto);
+               __cpuc_flush_dcache_area(kto, PAGE_SIZE);
        kunmap_atomic(kto, KM_USER1);
        kunmap_atomic(kfrom, KM_USER0);
 }
index 729602291958871bfc749c7a1af708620f97cfd9..56ee15321b005f0ae9a6cc62dfaaa5bd8ad5cf73 100644 (file)
@@ -207,9 +207,8 @@ void __init check_writebuffer_bugs(void)
        page = alloc_page(GFP_KERNEL);
        if (page) {
                unsigned long *p1, *p2;
-               pgprot_t prot = __pgprot(L_PTE_PRESENT|L_PTE_YOUNG|
-                                        L_PTE_DIRTY|L_PTE_WRITE|
-                                        L_PTE_MT_BUFFERABLE);
+               pgprot_t prot = __pgprot_modify(PAGE_KERNEL,
+                                       L_PTE_MT_MASK, L_PTE_MT_BUFFERABLE);
 
                p1 = vmap(&page, 1, VM_IOREMAP, prot);
                p2 = vmap(&page, 1, VM_IOREMAP, prot);
index 329594e760cdb09e868b1e1ad42a30dfda78f429..6f3a4b7a3b8276e5c442e4bbfc8273c8e9745f54 100644 (file)
@@ -131,7 +131,7 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page)
         */
        if (addr)
 #endif
-               __cpuc_flush_dcache_page(addr);
+               __cpuc_flush_dcache_area(addr, PAGE_SIZE);
 
        /*
         * If this is a page cache page, and we have an aliasing VIPT cache,
@@ -258,5 +258,5 @@ void __flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned l
         * in this mapping of the page.  FIXME: this is overkill
         * since we actually ask for a write-back and invalidate.
         */
-       __cpuc_flush_dcache_page(page_address(page));
+       __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
 }
index 30f82fb5918c9e2a8b3cce49849ff4fd7d97c2dc..2be1ec7c1b41acea66987a3ef532e96020b71c5b 100644 (file)
@@ -79,7 +79,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
        unsigned int idx = type + KM_TYPE_NR * smp_processor_id();
 
        if (kvaddr >= (void *)FIXADDR_START) {
-               __cpuc_flush_dcache_page((void *)vaddr);
+               __cpuc_flush_dcache_area((void *)vaddr, PAGE_SIZE);
 #ifdef CONFIG_DEBUG_HIGHMEM
                BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
                set_pte_ext(TOP_PTE(vaddr), __pte(0), 0);
index 8c7fbd19a4b381141efce57ea57e56f3ad279d41..1708da82da96c127267b8edc59f916a0bec6a286 100644 (file)
@@ -453,8 +453,7 @@ static void __init build_mem_type_table(void)
 
        pgprot_user   = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | user_pgprot);
        pgprot_kernel = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG |
-                                L_PTE_DIRTY | L_PTE_WRITE |
-                                L_PTE_EXEC | kern_pgprot);
+                                L_PTE_DIRTY | L_PTE_WRITE | kern_pgprot);
 
        mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
        mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
index 900811cc9130669b0377f7a155b95cd57c64ca34..374a8311bc84b0eeadaa37a14004ee53f499ab67 100644 (file)
@@ -61,7 +61,7 @@ void setup_mm_for_reboot(char mode)
 
 void flush_dcache_page(struct page *page)
 {
-       __cpuc_flush_dcache_page(page_address(page));
+       __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
 }
 EXPORT_SYMBOL(flush_dcache_page);
 
index d9fb4b98c49ff8866a1d36288d431ce364ad1180..8012e24282b2d0ffbbab5a38cd963c6cb9acf6e5 100644 (file)
@@ -231,17 +231,18 @@ ENTRY(arm1020_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - page  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm1020_flush_kern_dcache_page)
+ENTRY(arm1020_flush_kern_dcache_area)
        mov     ip, #0
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-       add     r1, r0, #PAGE_SZ
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        mcr     p15, 0, ip, c7, c10, 4          @ drain WB
        add     r0, r0, #CACHE_DLINESIZE
@@ -335,7 +336,7 @@ ENTRY(arm1020_cache_fns)
        .long   arm1020_flush_user_cache_range
        .long   arm1020_coherent_kern_range
        .long   arm1020_coherent_user_range
-       .long   arm1020_flush_kern_dcache_page
+       .long   arm1020_flush_kern_dcache_area
        .long   arm1020_dma_inv_range
        .long   arm1020_dma_clean_range
        .long   arm1020_dma_flush_range
index 7453b75dcea5f1527790e940263f113a70aec417..41fe25d234f50b76b563c6b5516a258d45c014fe 100644 (file)
@@ -225,17 +225,18 @@ ENTRY(arm1020e_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - page  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm1020e_flush_kern_dcache_page)
+ENTRY(arm1020e_flush_kern_dcache_area)
        mov     ip, #0
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-       add     r1, r0, #PAGE_SZ
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -321,7 +322,7 @@ ENTRY(arm1020e_cache_fns)
        .long   arm1020e_flush_user_cache_range
        .long   arm1020e_coherent_kern_range
        .long   arm1020e_coherent_user_range
-       .long   arm1020e_flush_kern_dcache_page
+       .long   arm1020e_flush_kern_dcache_area
        .long   arm1020e_dma_inv_range
        .long   arm1020e_dma_clean_range
        .long   arm1020e_dma_flush_range
index 8eb72d75a8b6fe2757e0c6c8bcfa7325519c2a11..20a5b1b31a706051ac2c1b6cb58b293b3b2794a2 100644 (file)
@@ -214,17 +214,18 @@ ENTRY(arm1022_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - page  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm1022_flush_kern_dcache_page)
+ENTRY(arm1022_flush_kern_dcache_area)
        mov     ip, #0
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-       add     r1, r0, #PAGE_SZ
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -310,7 +311,7 @@ ENTRY(arm1022_cache_fns)
        .long   arm1022_flush_user_cache_range
        .long   arm1022_coherent_kern_range
        .long   arm1022_coherent_user_range
-       .long   arm1022_flush_kern_dcache_page
+       .long   arm1022_flush_kern_dcache_area
        .long   arm1022_dma_inv_range
        .long   arm1022_dma_clean_range
        .long   arm1022_dma_flush_range
index 3b59f0d6713962d3e83222d1d05dc2c10606157c..96aedb10fcc418c528f536fb9a06f77185a3fa9c 100644 (file)
@@ -208,17 +208,18 @@ ENTRY(arm1026_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - page  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm1026_flush_kern_dcache_page)
+ENTRY(arm1026_flush_kern_dcache_area)
        mov     ip, #0
 #ifndef CONFIG_CPU_DCACHE_DISABLE
-       add     r1, r0, #PAGE_SZ
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -304,7 +305,7 @@ ENTRY(arm1026_cache_fns)
        .long   arm1026_flush_user_cache_range
        .long   arm1026_coherent_kern_range
        .long   arm1026_coherent_user_range
-       .long   arm1026_flush_kern_dcache_page
+       .long   arm1026_flush_kern_dcache_area
        .long   arm1026_dma_inv_range
        .long   arm1026_dma_clean_range
        .long   arm1026_dma_flush_range
index 2b7c197cc58d2ab4babcf39920220b96a973570e..471669e2d7cb458567d9233a805dd8ce772bf719 100644 (file)
@@ -207,15 +207,16 @@ ENTRY(arm920_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm920_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(arm920_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -293,7 +294,7 @@ ENTRY(arm920_cache_fns)
        .long   arm920_flush_user_cache_range
        .long   arm920_coherent_kern_range
        .long   arm920_coherent_user_range
-       .long   arm920_flush_kern_dcache_page
+       .long   arm920_flush_kern_dcache_area
        .long   arm920_dma_inv_range
        .long   arm920_dma_clean_range
        .long   arm920_dma_flush_range
index 06a1aa4e33989976465155586fe0390e19109bb9..ee111b00fa41951619593c758fe22eb06a4e4ee4 100644 (file)
@@ -209,15 +209,16 @@ ENTRY(arm922_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm922_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(arm922_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -295,7 +296,7 @@ ENTRY(arm922_cache_fns)
        .long   arm922_flush_user_cache_range
        .long   arm922_coherent_kern_range
        .long   arm922_coherent_user_range
-       .long   arm922_flush_kern_dcache_page
+       .long   arm922_flush_kern_dcache_area
        .long   arm922_dma_inv_range
        .long   arm922_dma_clean_range
        .long   arm922_dma_flush_range
index cb53435a85aee2120f2e97f6b01c24561f32e860..8deb5bde58e4883765e1d7bb6b81b10e0388911b 100644 (file)
@@ -251,15 +251,16 @@ ENTRY(arm925_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm925_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(arm925_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -346,7 +347,7 @@ ENTRY(arm925_cache_fns)
        .long   arm925_flush_user_cache_range
        .long   arm925_coherent_kern_range
        .long   arm925_coherent_user_range
-       .long   arm925_flush_kern_dcache_page
+       .long   arm925_flush_kern_dcache_area
        .long   arm925_dma_inv_range
        .long   arm925_dma_clean_range
        .long   arm925_dma_flush_range
index 1c4848704bb358c98a0e4c87141f7326e802d3fb..64db6e275a442f610239fe9b692753c4d88d14f9 100644 (file)
@@ -214,15 +214,16 @@ ENTRY(arm926_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm926_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(arm926_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -309,7 +310,7 @@ ENTRY(arm926_cache_fns)
        .long   arm926_flush_user_cache_range
        .long   arm926_coherent_kern_range
        .long   arm926_coherent_user_range
-       .long   arm926_flush_kern_dcache_page
+       .long   arm926_flush_kern_dcache_area
        .long   arm926_dma_inv_range
        .long   arm926_dma_clean_range
        .long   arm926_dma_flush_range
index 5b0f8464c8f29f9cc908cd2bbff5a820652f7751..8196b9f401fb53f17cd0a215c384a872330e054d 100644 (file)
@@ -141,14 +141,15 @@ ENTRY(arm940_coherent_user_range)
        /* FALLTHROUGH */
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(arm940_flush_kern_dcache_page)
+ENTRY(arm940_flush_kern_dcache_area)
        mov     ip, #0
        mov     r1, #(CACHE_DSEGMENTS - 1) << 4 @ 4 segments
 1:     orr     r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
@@ -238,7 +239,7 @@ ENTRY(arm940_cache_fns)
        .long   arm940_flush_user_cache_range
        .long   arm940_coherent_kern_range
        .long   arm940_coherent_user_range
-       .long   arm940_flush_kern_dcache_page
+       .long   arm940_flush_kern_dcache_area
        .long   arm940_dma_inv_range
        .long   arm940_dma_clean_range
        .long   arm940_dma_flush_range
index 40c0449a139b829a709525984442b36561494e13..9a951239c86c0a1b93dcefdf6687312b6c3c51c7 100644 (file)
@@ -183,16 +183,17 @@ ENTRY(arm946_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  * (same as arm926)
  */
-ENTRY(arm946_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(arm946_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -280,7 +281,7 @@ ENTRY(arm946_cache_fns)
        .long   arm946_flush_user_cache_range
        .long   arm946_coherent_kern_range
        .long   arm946_coherent_user_range
-       .long   arm946_flush_kern_dcache_page
+       .long   arm946_flush_kern_dcache_area
        .long   arm946_dma_inv_range
        .long   arm946_dma_clean_range
        .long   arm946_dma_flush_range
index d0d7795200fc143a0362312c960f334deb5f1957..dbc39383e66aaf0d2ec0e5865f15e21dafb02ec7 100644 (file)
@@ -226,16 +226,17 @@ ENTRY(feroceon_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
        .align  5
-ENTRY(feroceon_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(feroceon_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -246,7 +247,7 @@ ENTRY(feroceon_flush_kern_dcache_page)
        mov     pc, lr
 
        .align  5
-ENTRY(feroceon_range_flush_kern_dcache_page)
+ENTRY(feroceon_range_flush_kern_dcache_area)
        mrs     r2, cpsr
        add     r1, r0, #PAGE_SZ - CACHE_DLINESIZE      @ top addr is inclusive
        orr     r3, r2, #PSR_I_BIT
@@ -372,7 +373,7 @@ ENTRY(feroceon_cache_fns)
        .long   feroceon_flush_user_cache_range
        .long   feroceon_coherent_kern_range
        .long   feroceon_coherent_user_range
-       .long   feroceon_flush_kern_dcache_page
+       .long   feroceon_flush_kern_dcache_area
        .long   feroceon_dma_inv_range
        .long   feroceon_dma_clean_range
        .long   feroceon_dma_flush_range
@@ -383,7 +384,7 @@ ENTRY(feroceon_range_cache_fns)
        .long   feroceon_flush_user_cache_range
        .long   feroceon_coherent_kern_range
        .long   feroceon_coherent_user_range
-       .long   feroceon_range_flush_kern_dcache_page
+       .long   feroceon_range_flush_kern_dcache_area
        .long   feroceon_range_dma_inv_range
        .long   feroceon_range_dma_clean_range
        .long   feroceon_range_dma_flush_range
index 52b5fd74fbb3fcbfe3295d570a2e121001318562..9674d36cc97d4c1a6489599d2047b3c29ef58110 100644 (file)
@@ -186,15 +186,16 @@ ENTRY(mohawk_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(mohawk_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(mohawk_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean+invalidate D entry
        add     r0, r0, #CACHE_DLINESIZE
        cmp     r0, r1
@@ -273,7 +274,7 @@ ENTRY(mohawk_cache_fns)
        .long   mohawk_flush_user_cache_range
        .long   mohawk_coherent_kern_range
        .long   mohawk_coherent_user_range
-       .long   mohawk_flush_kern_dcache_page
+       .long   mohawk_flush_kern_dcache_area
        .long   mohawk_dma_inv_range
        .long   mohawk_dma_clean_range
        .long   mohawk_dma_flush_range
index ac5c80062b704b791d0d9af9be34e7484f8d4311..3e6210b4d6d4cc713ba524ab3966760ad1d6f6f8 100644 (file)
@@ -27,8 +27,7 @@ EXPORT_SYMBOL(__cpuc_flush_kern_all);
 EXPORT_SYMBOL(__cpuc_flush_user_all);
 EXPORT_SYMBOL(__cpuc_flush_user_range);
 EXPORT_SYMBOL(__cpuc_coherent_kern_range);
-EXPORT_SYMBOL(__cpuc_flush_dcache_page);
-EXPORT_SYMBOL(dmac_inv_range);  /* because of flush_ioremap_region() */
+EXPORT_SYMBOL(__cpuc_flush_dcache_area);
 #else
 EXPORT_SYMBOL(cpu_cache);
 #endif
index 5485c821101ca1a9d242f28eedef1b02e1be47ff..395cc90c6613d616f56c502102747464baa2b159 100644 (file)
@@ -254,10 +254,9 @@ __pj4_v6_proc_info:
        .long   0x560f5810
        .long   0xff0ffff0
        .long   PMD_TYPE_SECT | \
-               PMD_SECT_BUFFERABLE | \
-               PMD_SECT_CACHEABLE | \
                PMD_SECT_AP_WRITE | \
-               PMD_SECT_AP_READ
+               PMD_SECT_AP_READ | \
+               PMD_FLAGS
        .long   PMD_TYPE_SECT | \
                PMD_SECT_XN | \
                PMD_SECT_AP_WRITE | \
index fab134e29826d626c3ec7b5ca0da5ac37d203f40..96456f5487986f349513b154be2ed22de1bd9eab 100644 (file)
@@ -226,15 +226,16 @@ ENTRY(xsc3_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache.
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(xsc3_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(xsc3_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c14, 1          @ clean/invalidate L1 D line
        add     r0, r0, #CACHELINESIZE
        cmp     r0, r1
@@ -309,7 +310,7 @@ ENTRY(xsc3_cache_fns)
        .long   xsc3_flush_user_cache_range
        .long   xsc3_coherent_kern_range
        .long   xsc3_coherent_user_range
-       .long   xsc3_flush_kern_dcache_page
+       .long   xsc3_flush_kern_dcache_area
        .long   xsc3_dma_inv_range
        .long   xsc3_dma_clean_range
        .long   xsc3_dma_flush_range
index f056c283682db09b37b3b282a1cded25d9683367..93df47265f2dfda487fcb7c11425d14b0a9ea02f 100644 (file)
@@ -284,15 +284,16 @@ ENTRY(xscale_coherent_user_range)
        mov     pc, lr
 
 /*
- *     flush_kern_dcache_page(void *page)
+ *     flush_kern_dcache_area(void *addr, size_t size)
  *
  *     Ensure no D cache aliasing occurs, either with itself or
  *     the I cache
  *
- *     - addr  - page aligned address
+ *     - addr  - kernel address
+ *     - size  - region size
  */
-ENTRY(xscale_flush_kern_dcache_page)
-       add     r1, r0, #PAGE_SZ
+ENTRY(xscale_flush_kern_dcache_area)
+       add     r1, r0, r1
 1:     mcr     p15, 0, r0, c7, c10, 1          @ clean D entry
        mcr     p15, 0, r0, c7, c6, 1           @ invalidate D entry
        add     r0, r0, #CACHELINESIZE
@@ -368,7 +369,7 @@ ENTRY(xscale_cache_fns)
        .long   xscale_flush_user_cache_range
        .long   xscale_coherent_kern_range
        .long   xscale_coherent_user_range
-       .long   xscale_flush_kern_dcache_page
+       .long   xscale_flush_kern_dcache_area
        .long   xscale_dma_inv_range
        .long   xscale_dma_clean_range
        .long   xscale_dma_flush_range
@@ -392,7 +393,7 @@ ENTRY(xscale_80200_A0_A1_cache_fns)
        .long   xscale_flush_user_cache_range
        .long   xscale_coherent_kern_range
        .long   xscale_coherent_user_range
-       .long   xscale_flush_kern_dcache_page
+       .long   xscale_flush_kern_dcache_area
        .long   xscale_dma_flush_range
        .long   xscale_dma_clean_range
        .long   xscale_dma_flush_range
index b29178c0414ebca807db4bc7b7bcedad5e15075b..deb3a82ddbdf9aa23ab052a1e17cd79cd2b7c048 100644 (file)
@@ -6,7 +6,7 @@ obj-$(CONFIG_FPE_NWFPE)         += nwfpe.o
 
 nwfpe-y                                += fpa11.o fpa11_cpdo.o fpa11_cpdt.o \
                                   fpa11_cprt.o fpmodule.o fpopcode.o \
-                                  softfloat.o single_cpdo.o double_cpdo.o
+                                  softfloat.o single_cpdo.o double_cpdo.o \
+                                  entry.o
 
 nwfpe-$(CONFIG_FPE_NWFPE_XP)   += extended_cpdo.o
-nwfpe-$(CONFIG_CPU_32)         += entry.o
index f20295f14adbdd49ec3751c693120fd15339dbc1..2088a6c0cc0e36f3e8ba23239f1a62fbb80e4858 100644 (file)
@@ -191,12 +191,8 @@ int armv7_setup_pmnc(void)
                return -EBUSY;
        }
 
-       /*
-        * Initialize & Reset PMNC: C bit, D bit and P bit.
-        *  Note: Using a slower count for CCNT (D bit: divide by 64) results
-        *   in a more stable system
-        */
-       armv7_pmnc_write(PMNC_P | PMNC_C | PMNC_D);
+       /* Initialize & Reset PMNC: C bit and P bit */
+       armv7_pmnc_write(PMNC_P | PMNC_C);
 
 
        for (cnt = CCNT; cnt < CNTMAX; cnt++) {
index 2b972df22d122f62f2597b8fd7656b741ead746b..5d2d21d414e0e71716ab8878a14548010faff253 100644 (file)
@@ -22,6 +22,7 @@
 
 struct mxc_nand_platform_data {
        int width;      /* data bus width in bytes */
-       int hw_ecc;     /* 0 if supress hardware ECC */
+       int hw_ecc:1;   /* 0 if supress hardware ECC */
+       int flash_bbt:1; /* set to 1 to use a flash based bbt */
 };
 #endif /* __ASM_ARCH_NAND_H */
index 6c768b71ad64b42268d024012e7dce5f0a366f93..53fcef7c5201b10550305cc96db32538c3f31feb 100644 (file)
@@ -293,7 +293,7 @@ static int fpga_resume_noirq(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops fpga_dev_pm_ops = {
+static const struct dev_pm_ops fpga_dev_pm_ops = {
        .suspend_noirq = fpga_suspend_noirq,
        .resume_noirq = fpga_resume_noirq,
 };
index 055160e0620e33db3c31e0d2182e27b3381d2964..04846811d0aaf83696e2b6c641785d902af7f1c5 100644 (file)
@@ -1431,7 +1431,7 @@ static int omap_mpuio_resume_noirq(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops omap_mpuio_dev_pm_ops = {
+static const struct dev_pm_ops omap_mpuio_dev_pm_ops = {
        .suspend_noirq = omap_mpuio_suspend_noirq,
        .resume_noirq = omap_mpuio_resume_noirq,
 };
index 065985978413087f432d0b171dc2f2fd19d138c6..226147b7e0261ee3d17434ce3fa452461c837e50 100644 (file)
@@ -17,6 +17,7 @@
  *                     Setting this flag will allow the kernel to
  *                     look for it at boot time and also skip the NAND
  *                     scan.
+ * @options:           Default value to set into 'struct nand_chip' options.
  * @nr_chips:          Number of chips in this set
  * @nr_partitions:     Number of partitions pointed to by @partitions
  * @name:              Name of set (optional)
@@ -31,6 +32,7 @@ struct s3c2410_nand_set {
        unsigned int            disable_ecc:1;
        unsigned int            flash_bbt:1;
 
+       unsigned int            options;
        int                     nr_chips;
        int                     nr_partitions;
        char                    *name;
index 1dbaa29ac4d7b3658f4f40e22ba35db1413c2db4..635cb1865e4d56af08b8579eb72dbaadfa77f211 100644 (file)
@@ -4,7 +4,7 @@
 # Copyright (C) 2001 Russell King
 #
 
-include/asm-arm/mach-types.h: $(src)/gen-mach-types $(src)/mach-types
+include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types
        @echo '  Generating $@'
        @mkdir -p $(dir $@)
        $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
index ce319ef64bc108c6df94ac2b7b2c02e888050d35..04fef71d7be964f9cdaea5f30c80929e89befe78 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/awk
 #
-# Awk script to generate include/asm-arm/mach-types.h
+# Awk script to generate include/generated/mach-types.h
 #
 BEGIN  { nr = 0 }
 /^#/   { next }
index 07b976da617418d32b6c0a7d2d84a4ffeb7a5ace..c3a74ce24ef6c16f101bb5898a0c23056e0ee9e8 100644 (file)
@@ -12,7 +12,7 @@
 #
 #   http://www.arm.linux.org.uk/developer/machines/?action=new
 #
-# Last update: Wed Nov 25 22:14:58 2009
+# Last update: Wed Dec 16 20:06:34 2009
 #
 # machine_is_xxx       CONFIG_xxxx             MACH_TYPE_xxx           number
 #
@@ -1776,6 +1776,7 @@ cybook3                   MACH_CYBOOK3            CYBOOK3                 1784
 wdg002                 MACH_WDG002             WDG002                  1785
 sg560adsl              MACH_SG560ADSL          SG560ADSL               1786
 nextio_n2800_ica       MACH_NEXTIO_N2800_ICA   NEXTIO_N2800_ICA        1787
+dove_db                        MACH_DOVE_DB            DOVE_DB                 1788
 marvell_newdb          MACH_MARVELL_NEWDB      MARVELL_NEWDB           1789
 vandihud               MACH_VANDIHUD           VANDIHUD                1790
 magx_e8                        MACH_MAGX_E8            MAGX_E8                 1791
@@ -2536,3 +2537,44 @@ c3ax03                   MACH_C3AX03             C3AX03                  2549
 mxt_td60               MACH_MXT_TD60           MXT_TD60                2550
 esyx                   MACH_ESYX               ESYX                    2551
 bulldog                        MACH_BULLDOG            BULLDOG                 2553
+derell_me2000          MACH_DERELL_ME2000      DERELL_ME2000           2554
+bcmring_base           MACH_BCMRING_BASE       BCMRING_BASE            2555
+bcmring_evm            MACH_BCMRING_EVM        BCMRING_EVM             2556
+bcmring_evm_jazz       MACH_BCMRING_EVM_JAZZ   BCMRING_EVM_JAZZ        2557
+bcmring_sp             MACH_BCMRING_SP         BCMRING_SP              2558
+bcmring_sv             MACH_BCMRING_SV         BCMRING_SV              2559
+bcmring_sv_jazz                MACH_BCMRING_SV_JAZZ    BCMRING_SV_JAZZ         2560
+bcmring_tablet         MACH_BCMRING_TABLET     BCMRING_TABLET          2561
+bcmring_vp             MACH_BCMRING_VP         BCMRING_VP              2562
+bcmring_evm_seikor     MACH_BCMRING_EVM_SEIKOR BCMRING_EVM_SEIKOR      2563
+bcmring_sp_wqvga       MACH_BCMRING_SP_WQVGA   BCMRING_SP_WQVGA        2564
+bcmring_custom         MACH_BCMRING_CUSTOM     BCMRING_CUSTOM          2565
+acer_s200              MACH_ACER_S200          ACER_S200               2566
+bt270                  MACH_BT270              BT270                   2567
+iseo                   MACH_ISEO               ISEO                    2568
+cezanne                        MACH_CEZANNE            CEZANNE                 2569
+lucca                  MACH_LUCCA              LUCCA                   2570
+supersmart             MACH_SUPERSMART         SUPERSMART              2571
+magnolia2              MACH_MAGNOLIA2          MAGNOLIA2               2573
+emxx                   MACH_EMXX               EMXX                    2574
+outlaw                 MACH_OUTLAW             OUTLAW                  2575
+riot_bei2              MACH_RIOT_BEI2          RIOT_BEI2               2576
+riot_vox               MACH_RIOT_VOX           RIOT_VOX                2577
+riot_x37               MACH_RIOT_X37           RIOT_X37                2578
+mega25mx               MACH_MEGA25MX           MEGA25MX                2579
+benzina2               MACH_BENZINA2           BENZINA2                2580
+ignite                 MACH_IGNITE             IGNITE                  2581
+foggia                 MACH_FOGGIA             FOGGIA                  2582
+arezzo                 MACH_AREZZO             AREZZO                  2583
+leica_skywalker                MACH_LEICA_SKYWALKER    LEICA_SKYWALKER         2584
+jacinto2_jamr          MACH_JACINTO2_JAMR      JACINTO2_JAMR           2585
+gts_nova               MACH_GTS_NOVA           GTS_NOVA                2586
+p3600                  MACH_P3600              P3600                   2587
+dlt2                   MACH_DLT2               DLT2                    2588
+df3120                 MACH_DF3120             DF3120                  2589
+ecucore_9g20           MACH_ECUCORE_9G20       ECUCORE_9G20            2590
+nautel_lpc3240         MACH_NAUTEL_LPC3240     NAUTEL_LPC3240          2591
+glacier                        MACH_GLACIER            GLACIER                 2592
+phrazer_bulldog                MACH_PHRAZER_BULLDOG    PHRAZER_BULLDOG         2593
+omap3_bulldog          MACH_OMAP3_BULLDOG      OMAP3_BULLDOG           2594
+pca101                 MACH_PCA101             PCA101                  2595
index aed05bc3c2eaecf29ddd63c1aabf1842d8f9440f..f60a5400a25b055919621d572bf31fa45c2a94bb 100644 (file)
@@ -63,14 +63,15 @@ static void vfp_thread_flush(struct thread_info *thread)
        put_cpu();
 }
 
-static void vfp_thread_release(struct thread_info *thread)
+static void vfp_thread_exit(struct thread_info *thread)
 {
        /* release case: Per-thread VFP cleanup. */
        union vfp_state *vfp = &thread->vfpstate;
-       unsigned int cpu = thread->cpu;
+       unsigned int cpu = get_cpu();
 
        if (last_VFP_context[cpu] == vfp)
                last_VFP_context[cpu] = NULL;
+       put_cpu();
 }
 
 /*
@@ -88,11 +89,13 @@ static void vfp_thread_release(struct thread_info *thread)
  *     but may change at any time.
  *   - we could be preempted if tree preempt rcu is enabled, so
  *     it is unsafe to use thread->cpu.
- *  THREAD_NOTIFY_RELEASE:
- *   - the thread (v) will not be running on any CPU; it is a dead thread.
- *   - thread->cpu will be the last CPU the thread ran on, which may not
- *     be the current CPU.
- *   - we could be preempted if tree preempt rcu is enabled.
+ *  THREAD_NOTIFY_EXIT
+ *   - the thread (v) will be running on the local CPU, so
+ *     v === current_thread_info()
+ *   - thread->cpu is the local CPU number at the time it is accessed,
+ *     but may change at any time.
+ *   - we could be preempted if tree preempt rcu is enabled, so
+ *     it is unsafe to use thread->cpu.
  */
 static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
 {
@@ -133,7 +136,7 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
        if (cmd == THREAD_NOTIFY_FLUSH)
                vfp_thread_flush(thread);
        else
-               vfp_thread_release(thread);
+               vfp_thread_exit(thread);
 
        return NOTIFY_DONE;
 }
index d856354f427293095246bfc29200b12637d1a498..f2b3193331841b7ecec7263658de1590da42a9cc 100644 (file)
@@ -112,6 +112,11 @@ config CPU_AT32AP7002
        bool
        select CPU_AT32AP700X
 
+# AP700X boards
+config BOARD_ATNGW100_COMMON
+       bool
+       select CPU_AT32AP7000
+
 choice
        prompt "AVR32 board type"
        default BOARD_ATSTK1000
@@ -119,9 +124,13 @@ choice
 config BOARD_ATSTK1000
        bool "ATSTK1000 evaluation board"
 
-config BOARD_ATNGW100
+config BOARD_ATNGW100_MKI
        bool "ATNGW100 Network Gateway"
-       select CPU_AT32AP7000
+       select BOARD_ATNGW100_COMMON
+
+config BOARD_ATNGW100_MKII
+       bool "ATNGW100 mkII Network Gateway"
+       select BOARD_ATNGW100_COMMON
 
 config BOARD_HAMMERHEAD
        bool "Hammerhead board"
index c21a3290d542ddbcbeb4789f82b48de7255a9bba..ead8a75203a98e6dc94276c148871929fa452539 100644 (file)
@@ -32,7 +32,7 @@ head-$(CONFIG_LOADER_U_BOOT)          += arch/avr32/boot/u-boot/head.o
 head-y                                 += arch/avr32/kernel/head.o
 core-y                                 += $(machdirs)
 core-$(CONFIG_BOARD_ATSTK1000)         += arch/avr32/boards/atstk1000/
-core-$(CONFIG_BOARD_ATNGW100)          += arch/avr32/boards/atngw100/
+core-$(CONFIG_BOARD_ATNGW100_COMMON)   += arch/avr32/boards/atngw100/
 core-$(CONFIG_BOARD_HAMMERHEAD)                += arch/avr32/boards/hammerhead/
 core-$(CONFIG_BOARD_FAVR_32)           += arch/avr32/boards/favr-32/
 core-$(CONFIG_BOARD_MERISC)            += arch/avr32/boards/merisc/
index be27a0218ab4e050a2f5637f12fd88c3e698b966..4e55617ade2d2f7110bf2cdcfa221228480a01f0 100644 (file)
@@ -1,6 +1,17 @@
 # NGW100 customization
 
-if BOARD_ATNGW100
+if BOARD_ATNGW100_COMMON
+
+config BOARD_ATNGW100_MKII_LCD
+       bool "Enable ATNGW100 mkII LCD interface"
+       depends on BOARD_ATNGW100_MKII
+       help
+         This enables the LCD controller (LCDC) in the AT32AP7000. Since the
+         LCDC is multiplexed with MACB1 (LAN) Ethernet port, only one can be
+         enabled at a time.
+
+         This choice enables the LCDC and disables the MACB1 interface marked
+         LAN on the PCB.
 
 choice
        prompt "Select an NGW100 add-on board to support"
@@ -11,15 +22,11 @@ config BOARD_ATNGW100_ADDON_NONE
 
 config BOARD_ATNGW100_EVKLCD10X
        bool "EVKLCD10X addon board"
+       depends on BOARD_ATNGW100_MKI || BOARD_ATNGW100_MKII_LCD
        help
          This enables support for the EVKLCD100 (QVGA) or EVKLCD101 (VGA)
-         addon board for the NGW100. By enabling this the LCD controller and
-         AC97 controller is added as platform devices.
-
-         This choice disables the detect pin and the write-protect pin for the
-         MCI platform device, since it conflicts with the LCD platform device.
-         The MCI pins can be reenabled by editing the "add device function" but
-         this may break the setup for other displays that use these pins.
+         addon board for the NGW100 and NGW100 mkII. By enabling this the LCD
+         controller and AC97 controller is added as platform devices.
 
 config BOARD_ATNGW100_MRMT
        bool "Mediama RMT1/2 add-on board"
@@ -55,4 +62,4 @@ if BOARD_ATNGW100_MRMT
 source "arch/avr32/boards/atngw100/Kconfig_mrmt"
 endif
 
-endif  # BOARD_ATNGW100
+endif  # BOARD_ATNGW100_COMMON
index 00337112c5ac13e3fdc761f4a887d3757a72cb65..20388750d56447ee92324ee50cadfc0dacb5c89b 100644 (file)
@@ -164,7 +164,12 @@ static int __init atevklcd10x_init(void)
 
        at32_add_device_lcdc(0, &atevklcd10x_lcdc_data,
                        fbmem_start, fbmem_size,
-                       ATMEL_LCDC_ALT_18BIT | ATMEL_LCDC_PE_DVAL);
+#ifdef CONFIG_BOARD_ATNGW100_MKII
+                       ATMEL_LCDC_PRI_18BIT | ATMEL_LCDC_PC_DVAL
+#else
+                       ATMEL_LCDC_ALT_18BIT | ATMEL_LCDC_PE_DVAL
+#endif
+                       );
 
        at32_add_device_ac97c(0, &ac97c0_data, AC97C_BOTH);
 
index bf78e516a85fe66776b64d251e09e26eef50184d..7919be311f4ab99c7f78d1e476a9088a6c2c67c4 100644 (file)
@@ -302,6 +302,7 @@ static int __init mrmt1_init(void)
        at32_select_periph( GPIO_PIOB_BASE, 1 << (PB_EXTINT_BASE+TS_IRQ),
                        GPIO_PERIPH_A, AT32_GPIOF_DEGLITCH);
        set_irq_type( AT32_EXTINT(TS_IRQ), IRQ_TYPE_EDGE_FALLING );
+       at32_spi_setup_slaves(0,spi01_board_info,ARRAY_SIZE(spi01_board_info));
        spi_register_board_info(spi01_board_info,ARRAY_SIZE(spi01_board_info));
 #endif
 
index bc299fbbeb4e3f94a65f8747ac3e9f6b2e8c4cdd..8c6a2440e3458b00e756899743f09465c2d06a78 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/leds.h>
 #include <linux/spi/spi.h>
 #include <linux/atmel-mci.h>
+#include <linux/usb/atmel_usba_udc.h>
 
 #include <asm/io.h>
 #include <asm/setup.h>
@@ -36,6 +37,75 @@ unsigned long at32_board_osc_rates[3] = {
        [2] = 12000000, /* 12 MHz on osc1 */
 };
 
+/*
+ * The ATNGW100 mkII is very similar to the ATNGW100. Both have the AT32AP7000
+ * chip on board; the difference is that the ATNGW100 mkII has 128 MB 32-bit
+ * SDRAM (the ATNGW100 has 32 MB 16-bit SDRAM) and 256 MB 16-bit NAND flash
+ * (the ATNGW100 has none.)
+ *
+ * The RAM difference is handled by the boot loader, so the only difference we
+ * end up handling here is the NAND flash, EBI pin reservation and if LCDC or
+ * MACB1 should be enabled.
+ */
+#ifdef CONFIG_BOARD_ATNGW100_MKII
+#include <linux/mtd/partitions.h>
+#include <mach/smc.h>
+
+static struct smc_timing nand_timing __initdata = {
+       .ncs_read_setup         = 0,
+       .nrd_setup              = 10,
+       .ncs_write_setup        = 0,
+       .nwe_setup              = 10,
+
+       .ncs_read_pulse         = 30,
+       .nrd_pulse              = 15,
+       .ncs_write_pulse        = 30,
+       .nwe_pulse              = 15,
+
+       .read_cycle             = 30,
+       .write_cycle            = 30,
+
+       .ncs_read_recover       = 0,
+       .nrd_recover            = 15,
+       .ncs_write_recover      = 0,
+       /* WE# high -> RE# low min 60 ns */
+       .nwe_recover            = 50,
+};
+
+static struct smc_config nand_config __initdata = {
+       .bus_width              = 2,
+       .nrd_controlled         = 1,
+       .nwe_controlled         = 1,
+       .nwait_mode             = 0,
+       .byte_write             = 0,
+       .tdf_cycles             = 2,
+       .tdf_mode               = 0,
+};
+
+static struct mtd_partition nand_partitions[] = {
+       {
+               .name           = "main",
+               .offset         = 0x00000000,
+               .size           = MTDPART_SIZ_FULL,
+       },
+};
+
+static struct mtd_partition *nand_part_info(int size, int *num_partitions)
+{
+       *num_partitions = ARRAY_SIZE(nand_partitions);
+       return nand_partitions;
+}
+
+static struct atmel_nand_data atngw100mkii_nand_data __initdata = {
+       .cle            = 21,
+       .ale            = 22,
+       .rdy_pin        = GPIO_PIN_PB(28),
+       .enable_pin     = GPIO_PIN_PE(23),
+       .bus_width_16   = true,
+       .partition_info = nand_part_info,
+};
+#endif
+
 /* Initialized by bootloader-specific startup code. */
 struct tag *bootloader_tags __initdata;
 
@@ -56,9 +126,9 @@ static struct spi_board_info spi0_board_info[] __initdata = {
 static struct mci_platform_data __initdata mci0_data = {
        .slot[0] = {
                .bus_width      = 4,
-#if defined(CONFIG_BOARD_ATNGW100_EVKLCD10X) || defined(CONFIG_BOARD_ATNGW100_MRMT1)
-               .detect_pin     = GPIO_PIN_NONE,
-               .wp_pin         = GPIO_PIN_NONE,
+#if defined(CONFIG_BOARD_ATNGW100_MKII)
+               .detect_pin     = GPIO_PIN_PC(25),
+               .wp_pin         = GPIO_PIN_PE(22),
 #else
                .detect_pin     = GPIO_PIN_PC(25),
                .wp_pin         = GPIO_PIN_PE(0),
@@ -66,6 +136,14 @@ static struct mci_platform_data __initdata mci0_data = {
        },
 };
 
+static struct usba_platform_data atngw100_usba_data __initdata = {
+#if defined(CONFIG_BOARD_ATNGW100_MKII)
+       .vbus_pin       = GPIO_PIN_PE(26),
+#else
+       .vbus_pin       = -ENODEV,
+#endif
+};
+
 /*
  * The next two functions should go away as the boot loader is
  * supposed to initialize the macb address registers with a valid
@@ -173,18 +251,27 @@ static int __init atngw100_init(void)
        unsigned        i;
 
        /*
-        * ATNGW100 uses 16-bit SDRAM interface, so we don't need to
-        * reserve any pins for it.
+        * ATNGW100 mkII uses 32-bit SDRAM interface. Reserve the
+        * SDRAM-specific pins so that nobody messes with them.
         */
+#ifdef CONFIG_BOARD_ATNGW100_MKII
+       at32_reserve_pin(GPIO_PIOE_BASE, ATMEL_EBI_PE_DATA_ALL);
+
+       smc_set_timing(&nand_config, &nand_timing);
+       smc_set_configuration(3, &nand_config);
+       at32_add_device_nand(0, &atngw100mkii_nand_data);
+#endif
 
        at32_add_device_usart(0);
 
        set_hw_addr(at32_add_device_eth(0, &eth_data[0]));
+#ifndef CONFIG_BOARD_ATNGW100_MKII_LCD
        set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
+#endif
 
        at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
        at32_add_device_mci(0, &mci0_data);
-       at32_add_device_usba(0, NULL);
+       at32_add_device_usba(0, &atngw100_usba_data);
 
        for (i = 0; i < ARRAY_SIZE(ngw_leds); i++) {
                at32_select_gpio(ngw_leds[i].gpio,
@@ -194,10 +281,14 @@ static int __init atngw100_init(void)
 
        /* all these i2c/smbus pins should have external pullups for
         * open-drain sharing among all I2C devices.  SDA and SCL do;
-        * PB28/EXTINT3 doesn't; it should be SMBALERT# (for PMBus),
-        * but it's not available off-board.
+        * PB28/EXTINT3 (ATNGW100) and PE21 (ATNGW100 mkII) doesn't; it should
+        * be SMBALERT# (for PMBus), but it's not available off-board.
         */
+#ifdef CONFIG_BOARD_ATNGW100_MKII
+       at32_select_periph(GPIO_PIOE_BASE, 1 << 21, 0, AT32_GPIOF_PULLUP);
+#else
        at32_select_periph(GPIO_PIOB_BASE, 1 << 28, 0, AT32_GPIOF_PULLUP);
+#endif
        at32_select_gpio(i2c_gpio_data.sda_pin,
                AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
        at32_select_gpio(i2c_gpio_data.scl_pin,
@@ -211,14 +302,22 @@ postcore_initcall(atngw100_init);
 
 static int __init atngw100_arch_init(void)
 {
-       /* PB30 is the otherwise unused jumper on the mainboard, with an
-        * external pullup; the jumper grounds it.  Use it however you
-        * like, including letting U-Boot or Linux tweak boot sequences.
+       /* PB30 (ATNGW100) and PE30 (ATNGW100 mkII) is the otherwise unused
+        * jumper on the mainboard, with an external pullup; the jumper grounds
+        * it. Use it however you like, including letting U-Boot or Linux tweak
+        * boot sequences.
         */
+#ifdef CONFIG_BOARD_ATNGW100_MKII
+       at32_select_gpio(GPIO_PIN_PE(30), 0);
+       gpio_request(GPIO_PIN_PE(30), "j15");
+       gpio_direction_input(GPIO_PIN_PE(30));
+       gpio_export(GPIO_PIN_PE(30), false);
+#else
        at32_select_gpio(GPIO_PIN_PB(30), 0);
        gpio_request(GPIO_PIN_PB(30), "j15");
        gpio_direction_input(GPIO_PIN_PB(30));
        gpio_export(GPIO_PIN_PB(30), false);
+#endif
 
        /* set_irq_type() after the arch_initcall for EIC has run, and
         * before the I2C subsystem could try using this IRQ.
index 574aca975334f9079023ace848c68965d6f7ff47..32205c9d37d49af17d44c006e0ab2e851a5e711d 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.27-rc1
-# Tue Aug  5 16:00:47 2008
+# Linux kernel version: 2.6.32-rc5
+# Thu Oct 29 09:39:22 2009
 #
 CONFIG_AVR32=y
 CONFIG_GENERIC_GPIO=y
@@ -21,6 +21,7 @@ CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_GENERIC_BUG=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
 
 #
 # General setup
@@ -34,22 +35,37 @@ CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_BSD_PROCESS_ACCT_V3=y
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
 # CONFIG_IKCONFIG is not set
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_SYSFS_DEPRECATED_V2=y
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
@@ -59,38 +75,40 @@ CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 CONFIG_ELF_CORE=y
-# CONFIG_COMPAT_BRK is not set
 # CONFIG_BASE_FULL is not set
 CONFIG_FUTEX=y
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
 CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
 CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
 CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_SLUB_DEBUG=y
+# CONFIG_COMPAT_BRK is not set
 # CONFIG_SLAB is not set
 CONFIG_SLUB=y
 # CONFIG_SLOB is not set
 CONFIG_PROFILING=y
-# CONFIG_MARKERS is not set
+CONFIG_TRACEPOINTS=y
 CONFIG_OPROFILE=m
 CONFIG_HAVE_OPROFILE=y
 CONFIG_KPROBES=y
-# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
-# CONFIG_HAVE_IOREMAP_PROT is not set
 CONFIG_HAVE_KPROBES=y
-# CONFIG_HAVE_KRETPROBES is not set
-# CONFIG_HAVE_ARCH_TRACEHOOK is not set
-# CONFIG_HAVE_DMA_ATTRS is not set
-# CONFIG_USE_GENERIC_SMP_HELPERS is not set
 CONFIG_HAVE_CLK=y
-CONFIG_PROC_PAGE_MONITOR=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_SLOW_WORK=y
 # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
-# CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=1
 CONFIG_MODULES=y
 # CONFIG_MODULE_FORCE_LOAD is not set
@@ -98,11 +116,8 @@ CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
-# CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+CONFIG_LBDAF=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_BLK_DEV_INTEGRITY is not set
 
@@ -118,7 +133,7 @@ CONFIG_IOSCHED_CFQ=y
 CONFIG_DEFAULT_CFQ=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="cfq"
-CONFIG_CLASSIC_RCU=y
+CONFIG_FREEZER=y
 
 #
 # System Type and features
@@ -133,8 +148,23 @@ CONFIG_PERFORMANCE_COUNTERS=y
 CONFIG_PLATFORM_AT32AP=y
 CONFIG_CPU_AT32AP700X=y
 CONFIG_CPU_AT32AP7000=y
+CONFIG_BOARD_ATNGW100_COMMON=y
 # CONFIG_BOARD_ATSTK1000 is not set
-CONFIG_BOARD_ATNGW100=y
+CONFIG_BOARD_ATNGW100_MKI=y
+# CONFIG_BOARD_ATNGW100_MKII is not set
+# CONFIG_BOARD_HAMMERHEAD is not set
+# CONFIG_BOARD_FAVR_32 is not set
+# CONFIG_BOARD_MERISC is not set
+# CONFIG_BOARD_MIMC200 is not set
+# CONFIG_BOARD_ATSTK1002 is not set
+# CONFIG_BOARD_ATSTK1003 is not set
+# CONFIG_BOARD_ATSTK1004 is not set
+# CONFIG_BOARD_ATSTK1006 is not set
+# CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
+# CONFIG_BOARD_ATSTK1000_J2_RGB is not set
+CONFIG_BOARD_ATNGW100_ADDON_NONE=y
+# CONFIG_BOARD_ATNGW100_EVKLCD10X is not set
+# CONFIG_BOARD_ATNGW100_MRMT is not set
 CONFIG_LOADER_U_BOOT=y
 
 #
@@ -150,7 +180,7 @@ CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
 CONFIG_QUICKLIST=y
-# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
+# CONFIG_HAVE_ARCH_BOOTMEM is not set
 # CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
 # CONFIG_NEED_NODE_MEMMAP_SIZE is not set
 CONFIG_ARCH_FLATMEM_ENABLE=y
@@ -162,14 +192,16 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=0
 CONFIG_NR_QUICK=2
 CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
 # CONFIG_OWNERSHIP_TRACE is not set
 CONFIG_NMI_DEBUGGING=y
 # CONFIG_HZ_100 is not set
@@ -177,7 +209,7 @@ CONFIG_HZ_250=y
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
 CONFIG_HZ=250
-# CONFIG_SCHED_HRTICK is not set
+CONFIG_SCHED_HRTICK=y
 CONFIG_CMDLINE=""
 
 #
@@ -188,6 +220,7 @@ CONFIG_PM=y
 CONFIG_PM_SLEEP=y
 CONFIG_SUSPEND=y
 CONFIG_SUSPEND_FREEZER=y
+# CONFIG_PM_RUNTIME is not set
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
@@ -219,6 +252,8 @@ CONFIG_CPU_FREQ_AT32AP=y
 # Executable file formats
 #
 CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
 CONFIG_NET=y
 
@@ -271,7 +306,6 @@ CONFIG_INET_TCP_DIAG=y
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TCP_MD5SIG is not set
-# CONFIG_IP_VS is not set
 CONFIG_IPV6=y
 # CONFIG_IPV6_PRIVACY is not set
 # CONFIG_IPV6_ROUTER_PREF is not set
@@ -314,10 +348,12 @@ CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
 CONFIG_NETFILTER_XT_MATCH_MARK=m
 CONFIG_NETFILTER_XT_MATCH_POLICY=m
 CONFIG_NETFILTER_XT_MATCH_STATE=m
+# CONFIG_IP_VS is not set
 
 #
 # IP: Netfilter Configuration
 #
+CONFIG_NF_DEFRAG_IPV4=m
 CONFIG_NF_CONNTRACK_IPV4=m
 CONFIG_NF_CONNTRACK_PROC_COMPAT=y
 CONFIG_IP_NF_IPTABLES=m
@@ -343,16 +379,18 @@ CONFIG_IP_NF_MANGLE=m
 CONFIG_NF_CONNTRACK_IPV6=m
 CONFIG_IP6_NF_IPTABLES=m
 CONFIG_IP6_NF_MATCH_IPV6HEADER=m
-CONFIG_IP6_NF_FILTER=m
 CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_FILTER=m
 CONFIG_IP6_NF_TARGET_REJECT=m
 CONFIG_IP6_NF_MANGLE=m
 # CONFIG_IP_DCCP is not set
 # CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 CONFIG_STP=m
 CONFIG_BRIDGE=m
+# CONFIG_NET_DSA is not set
 CONFIG_VLAN_8021Q=m
 # CONFIG_VLAN_8021Q_GVRP is not set
 # CONFIG_DECNET is not set
@@ -364,26 +402,33 @@ CONFIG_LLC=m
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_NET_TCPPROBE is not set
+# CONFIG_NET_DROP_MONITOR is not set
 # CONFIG_HAMRADIO is not set
 # CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+# CONFIG_WIRELESS_EXT is not set
+# CONFIG_LIB80211 is not set
 
 #
-# Wireless
+# CFG80211 needs to be enabled for MAC80211
 #
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -395,6 +440,7 @@ CONFIG_LLC=m
 # Generic Driver Options
 #
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
 CONFIG_STANDALONE=y
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FW_LOADER is not set
@@ -404,6 +450,7 @@ CONFIG_STANDALONE=y
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
@@ -453,16 +500,17 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x80000000
-CONFIG_MTD_PHYSMAP_LEN=0x0
-CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
 CONFIG_MTD_DATAFLASH=y
+# CONFIG_MTD_DATAFLASH_WRITE_VERIFY is not set
+# CONFIG_MTD_DATAFLASH_OTP is not set
 # CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -477,10 +525,23 @@ CONFIG_MTD_DATAFLASH=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
-# CONFIG_MTD_UBI is not set
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
 # CONFIG_PARPORT is not set
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
@@ -498,10 +559,20 @@ CONFIG_MISC_DEVICES=y
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_TCB_CLKSRC=y
 CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
-# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_ICS932S401 is not set
 # CONFIG_ATMEL_SSC is not set
 # CONFIG_ENCLOSURE_SERVICES is not set
-# CONFIG_HAVE_IDE is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+CONFIG_EEPROM_AT24=m
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
 
 #
 # SCSI device support
@@ -534,26 +605,37 @@ CONFIG_PHYLIB=y
 # CONFIG_BROADCOM_PHY is not set
 # CONFIG_ICPLUS_PHY is not set
 # CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
 # CONFIG_FIXED_PHY is not set
 # CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
 CONFIG_MACB=y
 # CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
 # CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
 
 #
-# Wireless LAN
+# Enable WiMAX (Networking options) to see the WiMAX drivers
 #
-# CONFIG_WLAN_PRE80211 is not set
-# CONFIG_WLAN_80211 is not set
-# CONFIG_IWLWIFI_LEDS is not set
 # CONFIG_WAN is not set
 CONFIG_PPP=m
 # CONFIG_PPP_MULTILINK is not set
@@ -603,9 +685,11 @@ CONFIG_SERIAL_ATMEL=y
 CONFIG_SERIAL_ATMEL_CONSOLE=y
 CONFIG_SERIAL_ATMEL_PDC=y
 # CONFIG_SERIAL_ATMEL_TTYAT is not set
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
@@ -614,7 +698,9 @@ CONFIG_UNIX98_PTYS=y
 # CONFIG_TCG_TPM is not set
 CONFIG_I2C=m
 CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
 CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
 CONFIG_I2C_ALGOBIT=m
 
 #
@@ -624,6 +710,7 @@ CONFIG_I2C_ALGOBIT=m
 #
 # I2C system bus drivers (mostly embedded / system-on-chip)
 #
+# CONFIG_I2C_DESIGNWARE is not set
 CONFIG_I2C_GPIO=m
 # CONFIG_I2C_OCORES is not set
 # CONFIG_I2C_SIMTEC is not set
@@ -644,14 +731,6 @@ CONFIG_I2C_GPIO=m
 # Miscellaneous I2C Chip support
 #
 # CONFIG_DS1682 is not set
-CONFIG_EEPROM_AT24=m
-# CONFIG_EEPROM_LEGACY is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_PCF8575 is not set
-# CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_TPS65010 is not set
-# CONFIG_SENSORS_MAX6875 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
@@ -666,18 +745,27 @@ CONFIG_SPI_MASTER=y
 #
 CONFIG_SPI_ATMEL=y
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 CONFIG_SPI_SPIDEV=m
 # CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
 CONFIG_ARCH_REQUIRE_GPIOLIB=y
 CONFIG_GPIOLIB=y
 # CONFIG_DEBUG_GPIO is not set
 CONFIG_GPIO_SYSFS=y
 
+#
+# Memory mapped GPIO expanders:
+#
+
 #
 # I2C GPIO expanders:
 #
@@ -694,11 +782,15 @@ CONFIG_GPIO_SYSFS=y
 #
 # CONFIG_GPIO_MAX7301 is not set
 # CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
 # CONFIG_THERMAL is not set
-# CONFIG_THERMAL_HWMON is not set
 CONFIG_WATCHDOG=y
 # CONFIG_WATCHDOG_NOWAYOUT is not set
 
@@ -707,11 +799,11 @@ CONFIG_WATCHDOG=y
 #
 # CONFIG_SOFT_WATCHDOG is not set
 CONFIG_AT32AP700X_WDT=y
+CONFIG_SSB_POSSIBLE=y
 
 #
 # Sonics Silicon Backplane
 #
-CONFIG_SSB_POSSIBLE=y
 # CONFIG_SSB is not set
 
 #
@@ -720,22 +812,17 @@ CONFIG_SSB_POSSIBLE=y
 # CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
 # CONFIG_HTC_PASIC3 is not set
-
-#
-# Multimedia devices
-#
-
-#
-# Multimedia core support
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-# CONFIG_VIDEO_MEDIA is not set
-
-#
-# Multimedia drivers
-#
-# CONFIG_DAB is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
 
 #
 # Graphics support
@@ -756,32 +843,43 @@ CONFIG_USB_SUPPORT=y
 # CONFIG_USB_ARCH_HAS_EHCI is not set
 # CONFIG_USB_OTG_WHITELIST is not set
 # CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
 
 #
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 CONFIG_USB_GADGET=y
 # CONFIG_USB_GADGET_DEBUG is not set
 # CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
 CONFIG_USB_GADGET_SELECTED=y
-# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_AT91 is not set
 CONFIG_USB_GADGET_ATMEL_USBA=y
 CONFIG_USB_ATMEL_USBA=y
 # CONFIG_USB_GADGET_FSL_USB2 is not set
-# CONFIG_USB_GADGET_NET2280 is not set
-# CONFIG_USB_GADGET_PXA25X is not set
-# CONFIG_USB_GADGET_M66592 is not set
-# CONFIG_USB_GADGET_PXA27X is not set
-# CONFIG_USB_GADGET_GOKU is not set
 # CONFIG_USB_GADGET_LH7A40X is not set
 # CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
 # CONFIG_USB_GADGET_S3C2410 is not set
-# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
 # CONFIG_USB_GADGET_DUMMY_HCD is not set
 CONFIG_USB_GADGET_DUALSPEED=y
 CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
 CONFIG_USB_ETH=m
 CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_ETH_EEM is not set
 CONFIG_USB_GADGETFS=m
 CONFIG_USB_FILE_STORAGE=m
 # CONFIG_USB_FILE_STORAGE_TEST is not set
@@ -789,12 +887,18 @@ CONFIG_USB_G_SERIAL=m
 # CONFIG_USB_MIDI_GADGET is not set
 # CONFIG_USB_G_PRINTER is not set
 CONFIG_USB_CDC_COMPOSITE=m
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
 CONFIG_MMC=y
 # CONFIG_MMC_DEBUG is not set
 # CONFIG_MMC_UNSAFE_RESUME is not set
 
 #
-# MMC/SD Card Drivers
+# MMC/SD/SDIO Card Drivers
 #
 CONFIG_MMC_BLOCK=y
 CONFIG_MMC_BLOCK_BOUNCE=y
@@ -802,10 +906,12 @@ CONFIG_MMC_BLOCK_BOUNCE=y
 CONFIG_MMC_TEST=m
 
 #
-# MMC/SD Host Controller Drivers
+# MMC/SD/SDIO Host Controller Drivers
 #
 # CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
 CONFIG_MMC_ATMELMCI=y
+# CONFIG_MMC_ATMELMCI_DMA is not set
 CONFIG_MMC_SPI=m
 # CONFIG_MEMSTICK is not set
 CONFIG_NEW_LEDS=y
@@ -815,7 +921,11 @@ CONFIG_LEDS_CLASS=y
 # LED drivers
 #
 CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_GPIO_PLATFORM=y
+# CONFIG_LEDS_LP3944 is not set
 # CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
 
 #
 # LED Triggers
@@ -823,7 +933,13 @@ CONFIG_LEDS_GPIO=y
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
 CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
 # CONFIG_ACCESSIBILITY is not set
 CONFIG_RTC_LIB=y
 CONFIG_RTC_CLASS=y
@@ -855,25 +971,33 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_M41T80 is not set
 # CONFIG_RTC_DRV_S35390A is not set
 # CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
 
 #
 # SPI RTC drivers
 #
 # CONFIG_RTC_DRV_M41T94 is not set
 # CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
 # CONFIG_RTC_DRV_MAX6902 is not set
 # CONFIG_RTC_DRV_R9701 is not set
 # CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
 
 #
 # Platform RTC drivers
 #
+# CONFIG_RTC_DRV_DS1286 is not set
 # CONFIG_RTC_DRV_DS1511 is not set
 # CONFIG_RTC_DRV_DS1553 is not set
 # CONFIG_RTC_DRV_DS1742 is not set
 # CONFIG_RTC_DRV_STK17TA8 is not set
 # CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
 # CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
 # CONFIG_RTC_DRV_V3020 is not set
 
 #
@@ -892,24 +1016,38 @@ CONFIG_DMA_ENGINE=y
 # DMA Clients
 #
 # CONFIG_NET_DMA is not set
+# CONFIG_ASYNC_TX_DMA is not set
 # CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
 
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
 #
 # File systems
 #
-CONFIG_EXT2_FS=m
+CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_EXT2_FS_XIP is not set
-CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
 # CONFIG_EXT3_FS_XATTR is not set
-# CONFIG_EXT4DEV_FS is not set
-CONFIG_JBD=m
+# CONFIG_EXT4_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -917,6 +1055,12 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -940,15 +1084,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 CONFIG_PROC_FS=y
 # CONFIG_PROC_KCORE is not set
 CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
 CONFIG_SYSFS=y
 CONFIG_TMPFS=y
 # CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_CONFIGFS_FS=m
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -967,7 +1109,9 @@ CONFIG_JFFS2_ZLIB=y
 # CONFIG_JFFS2_LZO is not set
 CONFIG_JFFS2_RTIME=y
 # CONFIG_JFFS2_RUBIN is not set
+# CONFIG_UBIFS_FS is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_OMFS_FS is not set
@@ -975,7 +1119,9 @@ CONFIG_JFFS2_RTIME=y
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
+CONFIG_UFS_FS=y
+# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_UFS_DEBUG is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
@@ -1060,14 +1206,18 @@ CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
 CONFIG_FRAME_WARN=1024
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
 # CONFIG_UNUSED_SYMBOLS is not set
-# CONFIG_DEBUG_FS is not set
+CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
 CONFIG_DEBUG_KERNEL=y
 # CONFIG_DEBUG_SHIRQ is not set
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
 CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
 CONFIG_SCHED_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_TIMER_STATS is not set
@@ -1083,6 +1233,7 @@ CONFIG_SCHED_DEBUG=y
 # CONFIG_LOCK_STAT is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_INFO is not set
@@ -1091,13 +1242,39 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_BOOT_PRINTK_DELAY is not set
 # CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
 # CONFIG_KPROBES_SANITY_TEST is not set
 # CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
 # CONFIG_LKDTM is not set
 # CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_NOP_TRACER=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
+CONFIG_TRACING=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 
 #
@@ -1105,19 +1282,30 @@ CONFIG_FRAME_POINTER=y
 #
 # CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
 CONFIG_CRYPTO=y
 
 #
 # Crypto core or helper
 #
+# CONFIG_CRYPTO_FIPS is not set
 CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
 CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
 CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
 CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
 CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
 # CONFIG_CRYPTO_GF128MUL is not set
 # CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
 # CONFIG_CRYPTO_CRYPTD is not set
 CONFIG_CRYPTO_AUTHENC=y
 # CONFIG_CRYPTO_TEST is not set
@@ -1145,11 +1333,13 @@ CONFIG_CRYPTO_PCBC=m
 #
 CONFIG_CRYPTO_HMAC=y
 # CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
 
 #
 # Digest
 #
 # CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
 # CONFIG_CRYPTO_MD4 is not set
 CONFIG_CRYPTO_MD5=y
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
@@ -1166,7 +1356,7 @@ CONFIG_CRYPTO_SHA1=y
 #
 # Ciphers
 #
-# CONFIG_CRYPTO_AES is not set
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_ANUBIS is not set
 CONFIG_CRYPTO_ARC4=m
 # CONFIG_CRYPTO_BLOWFISH is not set
@@ -1186,15 +1376,21 @@ CONFIG_CRYPTO_DES=y
 # Compression
 #
 CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
 # CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
 CONFIG_CRYPTO_HW=y
+CONFIG_BINARY_PRINTF=y
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
-# CONFIG_GENERIC_FIND_FIRST_BIT is not set
-# CONFIG_GENERIC_FIND_NEXT_BIT is not set
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
 # CONFIG_CRC_T10DIF is not set
@@ -1204,8 +1400,9 @@ CONFIG_CRC7=m
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_GZIP=y
 CONFIG_GENERIC_ALLOCATOR=y
-CONFIG_PLIST=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index 86a45b5c9d0db730d066178aaee217bfaad3073f..c732cc397ad0482d10ea7fae693c1196a20fc4b3 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.25.6
-# Wed Jun 18 16:06:32 2008
+# Linux kernel version: 2.6.32-rc5
+# Thu Oct 29 09:36:39 2009
 #
 CONFIG_AVR32=y
 CONFIG_GENERIC_GPIO=y
@@ -21,6 +21,7 @@ CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_GENERIC_BUG=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
 
 #
 # General setup
@@ -34,22 +35,37 @@ CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_BSD_PROCESS_ACCT_V3=y
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
 # CONFIG_IKCONFIG is not set
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_SYSFS_DEPRECATED_V2=y
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
@@ -59,43 +75,51 @@ CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 CONFIG_ELF_CORE=y
-# CONFIG_COMPAT_BRK is not set
 # CONFIG_BASE_FULL is not set
 CONFIG_FUTEX=y
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
 CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
 CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
 CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_SLUB_DEBUG=y
+# CONFIG_COMPAT_BRK is not set
 # CONFIG_SLAB is not set
 CONFIG_SLUB=y
 # CONFIG_SLOB is not set
 CONFIG_PROFILING=y
-# CONFIG_MARKERS is not set
+CONFIG_TRACEPOINTS=y
 CONFIG_OPROFILE=m
 CONFIG_HAVE_OPROFILE=y
 CONFIG_KPROBES=y
 CONFIG_HAVE_KPROBES=y
-# CONFIG_HAVE_KRETPROBES is not set
-CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_HAVE_CLK=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_SLOW_WORK=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
-# CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=1
 CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
 CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
-# CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+CONFIG_LBDAF=y
 # CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
 
 #
 # IO Schedulers
@@ -109,7 +133,7 @@ CONFIG_IOSCHED_CFQ=y
 CONFIG_DEFAULT_CFQ=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="cfq"
-CONFIG_CLASSIC_RCU=y
+CONFIG_FREEZER=y
 
 #
 # System Type and features
@@ -124,13 +148,26 @@ CONFIG_PERFORMANCE_COUNTERS=y
 CONFIG_PLATFORM_AT32AP=y
 CONFIG_CPU_AT32AP700X=y
 CONFIG_CPU_AT32AP7000=y
+CONFIG_BOARD_ATNGW100_COMMON=y
 # CONFIG_BOARD_ATSTK1000 is not set
-CONFIG_BOARD_ATNGW100=y
+CONFIG_BOARD_ATNGW100_MKI=y
+# CONFIG_BOARD_ATNGW100_MKII is not set
+# CONFIG_BOARD_HAMMERHEAD is not set
+# CONFIG_BOARD_FAVR_32 is not set
+# CONFIG_BOARD_MERISC is not set
+# CONFIG_BOARD_MIMC200 is not set
+# CONFIG_BOARD_ATSTK1002 is not set
+# CONFIG_BOARD_ATSTK1003 is not set
+# CONFIG_BOARD_ATSTK1004 is not set
+# CONFIG_BOARD_ATSTK1006 is not set
+# CONFIG_BOARD_ATSTK1000_J2_LED8 is not set
+# CONFIG_BOARD_ATSTK1000_J2_RGB is not set
+# CONFIG_BOARD_ATNGW100_ADDON_NONE is not set
 CONFIG_BOARD_ATNGW100_EVKLCD10X=y
+# CONFIG_BOARD_ATNGW100_MRMT is not set
 CONFIG_BOARD_ATNGW100_EVKLCD10X_QVGA=y
 # CONFIG_BOARD_ATNGW100_EVKLCD10X_VGA is not set
 # CONFIG_BOARD_ATNGW100_EVKLCD10X_POW_QVGA is not set
-CONFIG_BOARD_ATNGW100_I2C_GPIO=y
 CONFIG_LOADER_U_BOOT=y
 
 #
@@ -139,14 +176,14 @@ CONFIG_LOADER_U_BOOT=y
 # CONFIG_AP700X_32_BIT_SMC is not set
 CONFIG_AP700X_16_BIT_SMC=y
 # CONFIG_AP700X_8_BIT_SMC is not set
-CONFIG_GPIO_DEV=y
 CONFIG_LOAD_ADDRESS=0x10000000
 CONFIG_ENTRY_ADDRESS=0x90000000
 CONFIG_PHYS_OFFSET=0x10000000
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
-# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
+CONFIG_QUICKLIST=y
+# CONFIG_HAVE_ARCH_BOOTMEM is not set
 # CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
 # CONFIG_NEED_NODE_MEMMAP_SIZE is not set
 CONFIG_ARCH_FLATMEM_ENABLE=y
@@ -158,33 +195,36 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=0
+CONFIG_NR_QUICK=2
 CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
 # CONFIG_OWNERSHIP_TRACE is not set
 CONFIG_NMI_DEBUGGING=y
-CONFIG_DW_DMAC=y
 # CONFIG_HZ_100 is not set
 CONFIG_HZ_250=y
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
 CONFIG_HZ=250
-# CONFIG_SCHED_HRTICK is not set
+CONFIG_SCHED_HRTICK=y
 CONFIG_CMDLINE=""
 
 #
 # Power management options
 #
-CONFIG_ARCH_SUSPEND_POSSIBLE=y
 CONFIG_PM=y
-# CONFIG_PM_LEGACY is not set
 # CONFIG_PM_DEBUG is not set
 CONFIG_PM_SLEEP=y
 CONFIG_SUSPEND=y
 CONFIG_SUSPEND_FREEZER=y
+# CONFIG_PM_RUNTIME is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
 # CPU Frequency scaling
@@ -194,6 +234,7 @@ CONFIG_CPU_FREQ_TABLE=y
 # CONFIG_CPU_FREQ_DEBUG is not set
 # CONFIG_CPU_FREQ_STAT is not set
 # CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
 # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
@@ -214,11 +255,9 @@ CONFIG_CPU_FREQ_AT32AP=y
 # Executable file formats
 #
 CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
-
-#
-# Networking
-#
 CONFIG_NET=y
 
 #
@@ -232,6 +271,7 @@ CONFIG_XFRM_USER=y
 # CONFIG_XFRM_SUB_POLICY is not set
 # CONFIG_XFRM_MIGRATE is not set
 # CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=y
 CONFIG_NET_KEY=y
 # CONFIG_NET_KEY_MIGRATE is not set
 CONFIG_INET=y
@@ -269,7 +309,6 @@ CONFIG_INET_TCP_DIAG=y
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TCP_MD5SIG is not set
-# CONFIG_IP_VS is not set
 CONFIG_IPV6=y
 # CONFIG_IPV6_PRIVACY is not set
 # CONFIG_IPV6_ROUTER_PREF is not set
@@ -285,8 +324,10 @@ CONFIG_INET6_XFRM_MODE_TUNNEL=y
 CONFIG_INET6_XFRM_MODE_BEET=y
 # CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
 CONFIG_IPV6_SIT=y
+CONFIG_IPV6_NDISC_NODETYPE=y
 # CONFIG_IPV6_TUNNEL is not set
 # CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_IPV6_MROUTE is not set
 # CONFIG_NETWORK_SECMARK is not set
 CONFIG_NETFILTER=y
 # CONFIG_NETFILTER_DEBUG is not set
@@ -310,10 +351,12 @@ CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
 CONFIG_NETFILTER_XT_MATCH_MARK=m
 CONFIG_NETFILTER_XT_MATCH_POLICY=m
 CONFIG_NETFILTER_XT_MATCH_STATE=m
+# CONFIG_IP_VS is not set
 
 #
 # IP: Netfilter Configuration
 #
+CONFIG_NF_DEFRAG_IPV4=m
 CONFIG_NF_CONNTRACK_IPV4=m
 CONFIG_NF_CONNTRACK_PROC_COMPAT=y
 CONFIG_IP_NF_IPTABLES=m
@@ -339,16 +382,20 @@ CONFIG_IP_NF_MANGLE=m
 CONFIG_NF_CONNTRACK_IPV6=m
 CONFIG_IP6_NF_IPTABLES=m
 CONFIG_IP6_NF_MATCH_IPV6HEADER=m
-CONFIG_IP6_NF_FILTER=m
 CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_FILTER=m
 CONFIG_IP6_NF_TARGET_REJECT=m
 CONFIG_IP6_NF_MANGLE=m
 # CONFIG_IP_DCCP is not set
 # CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
+CONFIG_STP=m
 CONFIG_BRIDGE=m
+# CONFIG_NET_DSA is not set
 CONFIG_VLAN_8021Q=m
+# CONFIG_VLAN_8021Q_GVRP is not set
 # CONFIG_DECNET is not set
 CONFIG_LLC=m
 # CONFIG_LLC2 is not set
@@ -358,26 +405,33 @@ CONFIG_LLC=m
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_NET_TCPPROBE is not set
+# CONFIG_NET_DROP_MONITOR is not set
 # CONFIG_HAMRADIO is not set
 # CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+# CONFIG_WIRELESS_EXT is not set
+# CONFIG_LIB80211 is not set
 
 #
-# Wireless
+# CFG80211 needs to be enabled for MAC80211
 #
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -389,6 +443,7 @@ CONFIG_LLC=m
 # Generic Driver Options
 #
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
 CONFIG_STANDALONE=y
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FW_LOADER is not set
@@ -398,10 +453,12 @@ CONFIG_STANDALONE=y
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
 CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
 
 #
 # User Modules And Translation Layers
@@ -446,16 +503,17 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x80000000
-CONFIG_MTD_PHYSMAP_LEN=0x0
-CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
 CONFIG_MTD_DATAFLASH=y
+# CONFIG_MTD_DATAFLASH_WRITE_VERIFY is not set
+# CONFIG_MTD_DATAFLASH_OTP is not set
 # CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -470,6 +528,11 @@ CONFIG_MTD_DATAFLASH=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -499,10 +562,20 @@ CONFIG_MISC_DEVICES=y
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_TCB_CLKSRC=y
 CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
-# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_ICS932S401 is not set
 # CONFIG_ATMEL_SSC is not set
 # CONFIG_ENCLOSURE_SERVICES is not set
-# CONFIG_HAVE_IDE is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
 
 #
 # SCSI device support
@@ -514,7 +587,6 @@ CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
 # CONFIG_ATA is not set
 # CONFIG_MD is not set
 CONFIG_NETDEVICES=y
-# CONFIG_NETDEVICES_MULTIQUEUE is not set
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_MACVLAN is not set
@@ -536,25 +608,37 @@ CONFIG_PHYLIB=y
 # CONFIG_BROADCOM_PHY is not set
 # CONFIG_ICPLUS_PHY is not set
 # CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
 # CONFIG_FIXED_PHY is not set
 # CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
 CONFIG_MACB=y
 # CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
 # CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
 
 #
-# Wireless LAN
+# Enable WiMAX (Networking options) to see the WiMAX drivers
 #
-# CONFIG_WLAN_PRE80211 is not set
-# CONFIG_WLAN_80211 is not set
 # CONFIG_WAN is not set
 CONFIG_PPP=m
 # CONFIG_PPP_MULTILINK is not set
@@ -598,15 +682,30 @@ CONFIG_INPUT_EVDEV=m
 # CONFIG_INPUT_TABLET is not set
 CONFIG_INPUT_TOUCHSCREEN=y
 # CONFIG_TOUCHSCREEN_ADS7846 is not set
+# CONFIG_TOUCHSCREEN_AD7877 is not set
+# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
+# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
+# CONFIG_TOUCHSCREEN_AD7879 is not set
+# CONFIG_TOUCHSCREEN_EETI is not set
 # CONFIG_TOUCHSCREEN_FUJITSU is not set
 # CONFIG_TOUCHSCREEN_GUNZE is not set
 # CONFIG_TOUCHSCREEN_ELO is not set
+# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
+# CONFIG_TOUCHSCREEN_MCS5000 is not set
 # CONFIG_TOUCHSCREEN_MTOUCH is not set
+# CONFIG_TOUCHSCREEN_INEXIO is not set
 # CONFIG_TOUCHSCREEN_MK712 is not set
 # CONFIG_TOUCHSCREEN_PENMOUNT is not set
 # CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
 # CONFIG_TOUCHSCREEN_TOUCHWIN is not set
-# CONFIG_TOUCHSCREEN_UCB1400 is not set
+CONFIG_TOUCHSCREEN_WM97XX=m
+CONFIG_TOUCHSCREEN_WM9705=y
+CONFIG_TOUCHSCREEN_WM9712=y
+CONFIG_TOUCHSCREEN_WM9713=y
+# CONFIG_TOUCHSCREEN_WM97XX_ATMEL is not set
+# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
+# CONFIG_TOUCHSCREEN_TSC2007 is not set
+# CONFIG_TOUCHSCREEN_W90X900 is not set
 # CONFIG_INPUT_MISC is not set
 
 #
@@ -619,9 +718,11 @@ CONFIG_INPUT_TOUCHSCREEN=y
 # Character devices
 #
 CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
 # CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_DEVKMEM=y
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -636,9 +737,11 @@ CONFIG_SERIAL_ATMEL=y
 CONFIG_SERIAL_ATMEL_CONSOLE=y
 CONFIG_SERIAL_ATMEL_PDC=y
 # CONFIG_SERIAL_ATMEL_TTYAT is not set
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
@@ -647,45 +750,44 @@ CONFIG_UNIX98_PTYS=y
 # CONFIG_TCG_TPM is not set
 CONFIG_I2C=m
 CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
 CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
 
 #
-# I2C Algorithms
+# I2C Hardware Bus support
 #
-CONFIG_I2C_ALGOBIT=m
-# CONFIG_I2C_ALGOPCF is not set
-# CONFIG_I2C_ALGOPCA is not set
 
 #
-# I2C Hardware Bus support
+# I2C system bus drivers (mostly embedded / system-on-chip)
 #
-CONFIG_I2C_ATMELTWI=m
+# CONFIG_I2C_DESIGNWARE is not set
 CONFIG_I2C_GPIO=m
 # CONFIG_I2C_OCORES is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_PCA_PLATFORM is not set
 # CONFIG_I2C_STUB is not set
 
 #
 # Miscellaneous I2C Chip support
 #
 # CONFIG_DS1682 is not set
-# CONFIG_EEPROM_LEGACY is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_PCF8575 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_TPS65010 is not set
-# CONFIG_SENSORS_MAX6875 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
 # CONFIG_I2C_DEBUG_BUS is not set
 # CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# SPI support
-#
 CONFIG_SPI=y
 # CONFIG_SPI_DEBUG is not set
 CONFIG_SPI_MASTER=y
@@ -695,30 +797,48 @@ CONFIG_SPI_MASTER=y
 #
 CONFIG_SPI_ATMEL=y
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 CONFIG_SPI_SPIDEV=m
 # CONFIG_SPI_TLE62X0 is not set
-CONFIG_HAVE_GPIO_LIB=y
 
 #
-# GPIO Support
+# PPS support
 #
+# CONFIG_PPS is not set
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
 # CONFIG_DEBUG_GPIO is not set
+# CONFIG_GPIO_SYSFS is not set
+
+#
+# Memory mapped GPIO expanders:
+#
 
 #
 # I2C GPIO expanders:
 #
+# CONFIG_GPIO_MAX732X is not set
 # CONFIG_GPIO_PCA953X is not set
 # CONFIG_GPIO_PCF857X is not set
 
+#
+# PCI GPIO expanders:
+#
+
 #
 # SPI GPIO expanders:
 #
+# CONFIG_GPIO_MAX7301 is not set
 # CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
@@ -731,24 +851,31 @@ CONFIG_WATCHDOG=y
 #
 # CONFIG_SOFT_WATCHDOG is not set
 CONFIG_AT32AP700X_WDT=y
+CONFIG_SSB_POSSIBLE=y
 
 #
 # Sonics Silicon Backplane
 #
-CONFIG_SSB_POSSIBLE=y
 # CONFIG_SSB is not set
 
 #
 # Multifunction device drivers
 #
+# CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-# CONFIG_DAB is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_UCB1400_CORE is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
 
 #
 # Graphics support
@@ -758,6 +885,7 @@ CONFIG_SSB_POSSIBLE=y
 CONFIG_FB=y
 # CONFIG_FIRMWARE_EDID is not set
 # CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
 CONFIG_FB_CFB_FILLRECT=y
 CONFIG_FB_CFB_COPYAREA=y
 CONFIG_FB_CFB_IMAGEBLIT=y
@@ -765,8 +893,8 @@ CONFIG_FB_CFB_IMAGEBLIT=y
 # CONFIG_FB_SYS_FILLRECT is not set
 # CONFIG_FB_SYS_COPYAREA is not set
 # CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
 # CONFIG_FB_SYS_FOPS is not set
-CONFIG_FB_DEFERRED_IO=y
 # CONFIG_FB_SVGALIB is not set
 # CONFIG_FB_MACMODES is not set
 # CONFIG_FB_BACKLIGHT is not set
@@ -779,6 +907,9 @@ CONFIG_FB_DEFERRED_IO=y
 # CONFIG_FB_S1D13XXX is not set
 CONFIG_FB_ATMEL=y
 # CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
@@ -792,119 +923,124 @@ CONFIG_FB_ATMEL=y
 CONFIG_DUMMY_CONSOLE=y
 # CONFIG_FRAMEBUFFER_CONSOLE is not set
 # CONFIG_LOGO is not set
-
-#
-# Sound
-#
 CONFIG_SOUND=y
-
-#
-# Advanced Linux Sound Architecture
-#
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
 CONFIG_SND=y
-CONFIG_SND_TIMER=m
+CONFIG_SND_TIMER=y
 CONFIG_SND_PCM=m
 # CONFIG_SND_SEQUENCER is not set
 CONFIG_SND_OSSEMUL=y
 CONFIG_SND_MIXER_OSS=m
 CONFIG_SND_PCM_OSS=m
 CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_HRTIMER=y
 # CONFIG_SND_DYNAMIC_MINORS is not set
 # CONFIG_SND_SUPPORT_OLD_API is not set
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
-
-#
-# Generic devices
-#
+CONFIG_SND_VMASTER=y
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
 CONFIG_SND_AC97_CODEC=m
-# CONFIG_SND_DUMMY is not set
-# CONFIG_SND_MTPAV is not set
-# CONFIG_SND_SERIAL_U16550 is not set
-# CONFIG_SND_MPU401 is not set
+# CONFIG_SND_DRIVERS is not set
 
 #
-# AVR32 devices
-#
-CONFIG_SND_ATMEL_AC97=m
-
-#
-# SPI devices
-#
-
-#
-# System on Chip audio support
+# Atmel devices (AVR32 and AT91)
 #
+# CONFIG_SND_ATMEL_ABDAC is not set
+CONFIG_SND_ATMEL_AC97C=m
+# CONFIG_SND_SPI is not set
 # CONFIG_SND_SOC is not set
-
-#
-# SoC Audio support for SuperH
-#
-
-#
-# ALSA SoC audio for Freescale SOCs
-#
-
-#
-# Open Sound System
-#
 # CONFIG_SOUND_PRIME is not set
 CONFIG_AC97_BUS=m
 CONFIG_HID_SUPPORT=y
 CONFIG_HID=y
-# CONFIG_HID_DEBUG is not set
 # CONFIG_HIDRAW is not set
+# CONFIG_HID_PID is not set
+
+#
+# Special HID drivers
+#
 CONFIG_USB_SUPPORT=y
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
 # CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
 
 #
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 CONFIG_USB_GADGET=y
 # CONFIG_USB_GADGET_DEBUG is not set
 # CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=350
 CONFIG_USB_GADGET_SELECTED=y
-# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_AT91 is not set
 CONFIG_USB_GADGET_ATMEL_USBA=y
 CONFIG_USB_ATMEL_USBA=y
 # CONFIG_USB_GADGET_FSL_USB2 is not set
-# CONFIG_USB_GADGET_NET2280 is not set
-# CONFIG_USB_GADGET_PXA2XX is not set
-# CONFIG_USB_GADGET_M66592 is not set
-# CONFIG_USB_GADGET_GOKU is not set
 # CONFIG_USB_GADGET_LH7A40X is not set
 # CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
 # CONFIG_USB_GADGET_S3C2410 is not set
-# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
 # CONFIG_USB_GADGET_DUMMY_HCD is not set
 CONFIG_USB_GADGET_DUALSPEED=y
 CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
 CONFIG_USB_ETH=m
 CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_ETH_EEM is not set
 CONFIG_USB_GADGETFS=m
 CONFIG_USB_FILE_STORAGE=m
 # CONFIG_USB_FILE_STORAGE_TEST is not set
 CONFIG_USB_G_SERIAL=m
 # CONFIG_USB_MIDI_GADGET is not set
 # CONFIG_USB_G_PRINTER is not set
+CONFIG_USB_CDC_COMPOSITE=m
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
 CONFIG_MMC=y
 # CONFIG_MMC_DEBUG is not set
 # CONFIG_MMC_UNSAFE_RESUME is not set
 
 #
-# MMC/SD Card Drivers
+# MMC/SD/SDIO Card Drivers
 #
 CONFIG_MMC_BLOCK=y
 CONFIG_MMC_BLOCK_BOUNCE=y
 # CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
 
 #
-# MMC/SD Host Controller Drivers
+# MMC/SD/SDIO Host Controller Drivers
 #
+# CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
 CONFIG_MMC_ATMELMCI=y
+# CONFIG_MMC_ATMELMCI_DMA is not set
 # CONFIG_MMC_SPI is not set
 # CONFIG_MEMSTICK is not set
 CONFIG_NEW_LEDS=y
@@ -913,7 +1049,13 @@ CONFIG_LEDS_CLASS=y
 #
 # LED drivers
 #
+# CONFIG_LEDS_PCA9532 is not set
 CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_GPIO_PLATFORM=y
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
 
 #
 # LED Triggers
@@ -921,6 +1063,14 @@ CONFIG_LEDS_GPIO=y
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
+# CONFIG_ACCESSIBILITY is not set
 CONFIG_RTC_LIB=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_HCTOSYS=y
@@ -950,35 +1100,62 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_PCF8583 is not set
 # CONFIG_RTC_DRV_M41T80 is not set
 # CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
 
 #
 # SPI RTC drivers
 #
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
 # CONFIG_RTC_DRV_MAX6902 is not set
 # CONFIG_RTC_DRV_R9701 is not set
 # CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
 
 #
 # Platform RTC drivers
 #
+# CONFIG_RTC_DRV_DS1286 is not set
 # CONFIG_RTC_DRV_DS1511 is not set
 # CONFIG_RTC_DRV_DS1553 is not set
 # CONFIG_RTC_DRV_DS1742 is not set
 # CONFIG_RTC_DRV_STK17TA8 is not set
 # CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
 # CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
 # CONFIG_RTC_DRV_V3020 is not set
 
 #
 # on-CPU RTC drivers
 #
 CONFIG_RTC_DRV_AT32AP700X=y
+CONFIG_DMADEVICES=y
 
 #
-# Userspace I/O
+# DMA Devices
 #
+CONFIG_DW_DMAC=y
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+# CONFIG_NET_DMA is not set
+# CONFIG_ASYNC_TX_DMA is not set
+# CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
 
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
 #
 # File systems
 #
@@ -986,15 +1163,21 @@ CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_EXT2_FS_XIP is not set
 CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
 # CONFIG_EXT3_FS_XATTR is not set
-# CONFIG_EXT4DEV_FS is not set
+# CONFIG_EXT4_FS is not set
 CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
 # CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -1002,6 +1185,12 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -1025,15 +1214,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 CONFIG_PROC_FS=y
 # CONFIG_PROC_KCORE is not set
 CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
 CONFIG_SYSFS=y
 CONFIG_TMPFS=y
 # CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_CONFIGFS_FS=y
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -1059,8 +1246,10 @@ CONFIG_UBIFS_FS_LZO=y
 CONFIG_UBIFS_FS_ZLIB=y
 # CONFIG_UBIFS_FS_DEBUG is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
 # CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_ROMFS_FS is not set
@@ -1071,19 +1260,16 @@ CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
 # CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
+CONFIG_ROOT_NFS=y
 CONFIG_NFSD=m
 CONFIG_NFSD_V3=y
 # CONFIG_NFSD_V3_ACL is not set
 # CONFIG_NFSD_V4 is not set
-CONFIG_NFSD_TCP=y
-CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
 CONFIG_EXPORTFS=m
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_BIND34 is not set
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
@@ -1151,16 +1337,24 @@ CONFIG_NLS_UTF8=m
 # CONFIG_PRINTK_TIME is not set
 CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
 # CONFIG_UNUSED_SYMBOLS is not set
-# CONFIG_DEBUG_FS is not set
+CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
 CONFIG_DEBUG_KERNEL=y
 # CONFIG_DEBUG_SHIRQ is not set
 CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
 CONFIG_SCHED_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
 # CONFIG_SLUB_DEBUG_ON is not set
 # CONFIG_SLUB_STATS is not set
 # CONFIG_DEBUG_RT_MUTEXES is not set
@@ -1172,19 +1366,48 @@ CONFIG_SCHED_DEBUG=y
 # CONFIG_LOCK_STAT is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_INFO is not set
 # CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_BOOT_PRINTK_DELAY is not set
 # CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
 # CONFIG_KPROBES_SANITY_TEST is not set
 # CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
 # CONFIG_LKDTM is not set
 # CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_NOP_TRACER=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
+CONFIG_TRACING=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 
 #
@@ -1192,63 +1415,118 @@ CONFIG_FRAME_POINTER=y
 #
 # CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
 CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
 CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
 CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
 CONFIG_CRYPTO_BLKCIPHER=y
-# CONFIG_CRYPTO_SEQIV is not set
+CONFIG_CRYPTO_BLKCIPHER2=y
 CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
 CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=m
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
 CONFIG_CRYPTO_HMAC=y
 # CONFIG_CRYPTO_XCBC is not set
-# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
 # CONFIG_CRYPTO_MD4 is not set
 CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
 CONFIG_CRYPTO_SHA1=y
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
-# CONFIG_CRYPTO_WP512 is not set
 # CONFIG_CRYPTO_TGR192 is not set
-# CONFIG_CRYPTO_GF128MUL is not set
-CONFIG_CRYPTO_ECB=m
-CONFIG_CRYPTO_CBC=y
-# CONFIG_CRYPTO_PCBC is not set
-# CONFIG_CRYPTO_LRW is not set
-# CONFIG_CRYPTO_XTS is not set
-# CONFIG_CRYPTO_CTR is not set
-# CONFIG_CRYPTO_GCM is not set
-# CONFIG_CRYPTO_CCM is not set
-# CONFIG_CRYPTO_CRYPTD is not set
-CONFIG_CRYPTO_DES=y
-# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=m
 # CONFIG_CRYPTO_BLOWFISH is not set
-# CONFIG_CRYPTO_TWOFISH is not set
-# CONFIG_CRYPTO_SERPENT is not set
-# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_TEA is not set
-CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
 # CONFIG_CRYPTO_KHAZAD is not set
-# CONFIG_CRYPTO_ANUBIS is not set
-# CONFIG_CRYPTO_SEED is not set
 # CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
 CONFIG_CRYPTO_DEFLATE=y
-# CONFIG_CRYPTO_MICHAEL_MIC is not set
-# CONFIG_CRYPTO_CRC32C is not set
-# CONFIG_CRYPTO_CAMELLIA is not set
-# CONFIG_CRYPTO_TEST is not set
-CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_ZLIB is not set
 CONFIG_CRYPTO_LZO=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
 CONFIG_CRYPTO_HW=y
+CONFIG_BINARY_PRINTF=y
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=y
+# CONFIG_CRC_T10DIF is not set
 # CONFIG_CRC_ITU_T is not set
 CONFIG_CRC32=y
 # CONFIG_CRC7 is not set
@@ -1257,8 +1535,9 @@ CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
 CONFIG_LZO_COMPRESS=y
 CONFIG_LZO_DECOMPRESS=y
+CONFIG_DECOMPRESS_GZIP=y
 CONFIG_GENERIC_ALLOCATOR=y
-CONFIG_PLIST=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index a96b68ea5e83b0e8030a9f4538ae5b71a6aa900b..5ef67da343bcfa36bf37430da52ce3197e95c765 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.25.6
-# Wed Jun 18 16:09:32 2008
+# Linux kernel version: 2.6.32-rc5
+# Thu Oct 29 09:37:19 2009
 #
 CONFIG_AVR32=y
 CONFIG_GENERIC_GPIO=y
@@ -21,6 +21,7 @@ CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_GENERIC_BUG=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
 
 #
 # General setup
@@ -34,22 +35,37 @@ CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_BSD_PROCESS_ACCT_V3=y
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
 # CONFIG_IKCONFIG is not set
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_SYSFS_DEPRECATED_V2=y
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
@@ -59,43 +75,51 @@ CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 CONFIG_ELF_CORE=y
-# CONFIG_COMPAT_BRK is not set
 # CONFIG_BASE_FULL is not set
 CONFIG_FUTEX=y
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
 CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
 CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
 CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_SLUB_DEBUG=y
+# CONFIG_COMPAT_BRK is not set
 # CONFIG_SLAB is not set
 CONFIG_SLUB=y
 # CONFIG_SLOB is not set
 CONFIG_PROFILING=y
-# CONFIG_MARKERS is not set
+CONFIG_TRACEPOINTS=y
 CONFIG_OPROFILE=m
 CONFIG_HAVE_OPROFILE=y
 CONFIG_KPROBES=y
 CONFIG_HAVE_KPROBES=y
-# CONFIG_HAVE_KRETPROBES is not set
-CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_HAVE_CLK=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_SLOW_WORK=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
-# CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=1
 CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
 CONFIG_MODULE_UNLOAD=y
 CONFIG_MODULE_FORCE_UNLOAD=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
-# CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+CONFIG_LBDAF=y
 # CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
 
 #
 # IO Schedulers
@@ -109,7 +133,7 @@ CONFIG_IOSCHED_CFQ=y
 CONFIG_DEFAULT_CFQ=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="cfq"
-CONFIG_CLASSIC_RCU=y
+CONFIG_FREEZER=y
 
 #
 # System Type and features
@@ -124,13 +148,20 @@ CONFIG_PERFORMANCE_COUNTERS=y
 CONFIG_PLATFORM_AT32AP=y
 CONFIG_CPU_AT32AP700X=y
 CONFIG_CPU_AT32AP7000=y
+CONFIG_BOARD_ATNGW100_COMMON=y
 # CONFIG_BOARD_ATSTK1000 is not set
-CONFIG_BOARD_ATNGW100=y
+CONFIG_BOARD_ATNGW100_MKI=y
+# CONFIG_BOARD_ATNGW100_MKII is not set
+# CONFIG_BOARD_HAMMERHEAD is not set
+# CONFIG_BOARD_FAVR_32 is not set
+# CONFIG_BOARD_MERISC is not set
+# CONFIG_BOARD_MIMC200 is not set
+# CONFIG_BOARD_ATNGW100_ADDON_NONE is not set
 CONFIG_BOARD_ATNGW100_EVKLCD10X=y
+# CONFIG_BOARD_ATNGW100_MRMT is not set
 # CONFIG_BOARD_ATNGW100_EVKLCD10X_QVGA is not set
 CONFIG_BOARD_ATNGW100_EVKLCD10X_VGA=y
 # CONFIG_BOARD_ATNGW100_EVKLCD10X_POW_QVGA is not set
-CONFIG_BOARD_ATNGW100_I2C_GPIO=y
 CONFIG_LOADER_U_BOOT=y
 
 #
@@ -139,14 +170,14 @@ CONFIG_LOADER_U_BOOT=y
 # CONFIG_AP700X_32_BIT_SMC is not set
 CONFIG_AP700X_16_BIT_SMC=y
 # CONFIG_AP700X_8_BIT_SMC is not set
-CONFIG_GPIO_DEV=y
 CONFIG_LOAD_ADDRESS=0x10000000
 CONFIG_ENTRY_ADDRESS=0x90000000
 CONFIG_PHYS_OFFSET=0x10000000
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
-# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
+CONFIG_QUICKLIST=y
+# CONFIG_HAVE_ARCH_BOOTMEM is not set
 # CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
 # CONFIG_NEED_NODE_MEMMAP_SIZE is not set
 CONFIG_ARCH_FLATMEM_ENABLE=y
@@ -158,33 +189,36 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=0
+CONFIG_NR_QUICK=2
 CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
 # CONFIG_OWNERSHIP_TRACE is not set
 CONFIG_NMI_DEBUGGING=y
-CONFIG_DW_DMAC=y
 # CONFIG_HZ_100 is not set
 CONFIG_HZ_250=y
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
 CONFIG_HZ=250
-# CONFIG_SCHED_HRTICK is not set
+CONFIG_SCHED_HRTICK=y
 CONFIG_CMDLINE=""
 
 #
 # Power management options
 #
-CONFIG_ARCH_SUSPEND_POSSIBLE=y
 CONFIG_PM=y
-# CONFIG_PM_LEGACY is not set
 # CONFIG_PM_DEBUG is not set
 CONFIG_PM_SLEEP=y
 CONFIG_SUSPEND=y
 CONFIG_SUSPEND_FREEZER=y
+# CONFIG_PM_RUNTIME is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
 # CPU Frequency scaling
@@ -194,6 +228,7 @@ CONFIG_CPU_FREQ_TABLE=y
 # CONFIG_CPU_FREQ_DEBUG is not set
 # CONFIG_CPU_FREQ_STAT is not set
 # CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
 # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
 CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 # CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
@@ -214,11 +249,9 @@ CONFIG_CPU_FREQ_AT32AP=y
 # Executable file formats
 #
 CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
-
-#
-# Networking
-#
 CONFIG_NET=y
 
 #
@@ -232,6 +265,7 @@ CONFIG_XFRM_USER=y
 # CONFIG_XFRM_SUB_POLICY is not set
 # CONFIG_XFRM_MIGRATE is not set
 # CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=y
 CONFIG_NET_KEY=y
 # CONFIG_NET_KEY_MIGRATE is not set
 CONFIG_INET=y
@@ -269,7 +303,6 @@ CONFIG_INET_TCP_DIAG=y
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TCP_MD5SIG is not set
-# CONFIG_IP_VS is not set
 CONFIG_IPV6=y
 # CONFIG_IPV6_PRIVACY is not set
 # CONFIG_IPV6_ROUTER_PREF is not set
@@ -285,8 +318,10 @@ CONFIG_INET6_XFRM_MODE_TUNNEL=y
 CONFIG_INET6_XFRM_MODE_BEET=y
 # CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
 CONFIG_IPV6_SIT=y
+CONFIG_IPV6_NDISC_NODETYPE=y
 # CONFIG_IPV6_TUNNEL is not set
 # CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_IPV6_MROUTE is not set
 # CONFIG_NETWORK_SECMARK is not set
 CONFIG_NETFILTER=y
 # CONFIG_NETFILTER_DEBUG is not set
@@ -310,10 +345,12 @@ CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
 CONFIG_NETFILTER_XT_MATCH_MARK=m
 CONFIG_NETFILTER_XT_MATCH_POLICY=m
 CONFIG_NETFILTER_XT_MATCH_STATE=m
+# CONFIG_IP_VS is not set
 
 #
 # IP: Netfilter Configuration
 #
+CONFIG_NF_DEFRAG_IPV4=m
 CONFIG_NF_CONNTRACK_IPV4=m
 CONFIG_NF_CONNTRACK_PROC_COMPAT=y
 CONFIG_IP_NF_IPTABLES=m
@@ -339,16 +376,20 @@ CONFIG_IP_NF_MANGLE=m
 CONFIG_NF_CONNTRACK_IPV6=m
 CONFIG_IP6_NF_IPTABLES=m
 CONFIG_IP6_NF_MATCH_IPV6HEADER=m
-CONFIG_IP6_NF_FILTER=m
 CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_FILTER=m
 CONFIG_IP6_NF_TARGET_REJECT=m
 CONFIG_IP6_NF_MANGLE=m
 # CONFIG_IP_DCCP is not set
 # CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
+CONFIG_STP=m
 CONFIG_BRIDGE=m
+# CONFIG_NET_DSA is not set
 CONFIG_VLAN_8021Q=m
+# CONFIG_VLAN_8021Q_GVRP is not set
 # CONFIG_DECNET is not set
 CONFIG_LLC=m
 # CONFIG_LLC2 is not set
@@ -358,26 +399,33 @@ CONFIG_LLC=m
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_NET_TCPPROBE is not set
+# CONFIG_NET_DROP_MONITOR is not set
 # CONFIG_HAMRADIO is not set
 # CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+# CONFIG_WIRELESS_EXT is not set
+# CONFIG_LIB80211 is not set
 
 #
-# Wireless
+# CFG80211 needs to be enabled for MAC80211
 #
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -389,6 +437,7 @@ CONFIG_LLC=m
 # Generic Driver Options
 #
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
 CONFIG_STANDALONE=y
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FW_LOADER is not set
@@ -398,10 +447,12 @@ CONFIG_STANDALONE=y
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
 CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
 
 #
 # User Modules And Translation Layers
@@ -446,16 +497,17 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x80000000
-CONFIG_MTD_PHYSMAP_LEN=0x0
-CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
 CONFIG_MTD_DATAFLASH=y
+# CONFIG_MTD_DATAFLASH_WRITE_VERIFY is not set
+# CONFIG_MTD_DATAFLASH_OTP is not set
 # CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -470,6 +522,11 @@ CONFIG_MTD_DATAFLASH=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -499,10 +556,20 @@ CONFIG_MISC_DEVICES=y
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_TCB_CLKSRC=y
 CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
-# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_ICS932S401 is not set
 # CONFIG_ATMEL_SSC is not set
 # CONFIG_ENCLOSURE_SERVICES is not set
-# CONFIG_HAVE_IDE is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
 
 #
 # SCSI device support
@@ -514,7 +581,6 @@ CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
 # CONFIG_ATA is not set
 # CONFIG_MD is not set
 CONFIG_NETDEVICES=y
-# CONFIG_NETDEVICES_MULTIQUEUE is not set
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_MACVLAN is not set
@@ -536,25 +602,37 @@ CONFIG_PHYLIB=y
 # CONFIG_BROADCOM_PHY is not set
 # CONFIG_ICPLUS_PHY is not set
 # CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
 # CONFIG_FIXED_PHY is not set
 # CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
 CONFIG_MACB=y
 # CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
 # CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
 
 #
-# Wireless LAN
+# Enable WiMAX (Networking options) to see the WiMAX drivers
 #
-# CONFIG_WLAN_PRE80211 is not set
-# CONFIG_WLAN_80211 is not set
 # CONFIG_WAN is not set
 CONFIG_PPP=m
 # CONFIG_PPP_MULTILINK is not set
@@ -598,15 +676,30 @@ CONFIG_INPUT_EVDEV=m
 # CONFIG_INPUT_TABLET is not set
 CONFIG_INPUT_TOUCHSCREEN=y
 # CONFIG_TOUCHSCREEN_ADS7846 is not set
+# CONFIG_TOUCHSCREEN_AD7877 is not set
+# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
+# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
+# CONFIG_TOUCHSCREEN_AD7879 is not set
+# CONFIG_TOUCHSCREEN_EETI is not set
 # CONFIG_TOUCHSCREEN_FUJITSU is not set
 # CONFIG_TOUCHSCREEN_GUNZE is not set
 # CONFIG_TOUCHSCREEN_ELO is not set
+# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
+# CONFIG_TOUCHSCREEN_MCS5000 is not set
 # CONFIG_TOUCHSCREEN_MTOUCH is not set
+# CONFIG_TOUCHSCREEN_INEXIO is not set
 # CONFIG_TOUCHSCREEN_MK712 is not set
 # CONFIG_TOUCHSCREEN_PENMOUNT is not set
 # CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
 # CONFIG_TOUCHSCREEN_TOUCHWIN is not set
-# CONFIG_TOUCHSCREEN_UCB1400 is not set
+CONFIG_TOUCHSCREEN_WM97XX=m
+CONFIG_TOUCHSCREEN_WM9705=y
+CONFIG_TOUCHSCREEN_WM9712=y
+CONFIG_TOUCHSCREEN_WM9713=y
+# CONFIG_TOUCHSCREEN_WM97XX_ATMEL is not set
+# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
+# CONFIG_TOUCHSCREEN_TSC2007 is not set
+# CONFIG_TOUCHSCREEN_W90X900 is not set
 # CONFIG_INPUT_MISC is not set
 
 #
@@ -619,9 +712,11 @@ CONFIG_INPUT_TOUCHSCREEN=y
 # Character devices
 #
 CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
 # CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_DEVKMEM=y
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -636,9 +731,11 @@ CONFIG_SERIAL_ATMEL=y
 CONFIG_SERIAL_ATMEL_CONSOLE=y
 CONFIG_SERIAL_ATMEL_PDC=y
 # CONFIG_SERIAL_ATMEL_TTYAT is not set
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
@@ -647,45 +744,44 @@ CONFIG_UNIX98_PTYS=y
 # CONFIG_TCG_TPM is not set
 CONFIG_I2C=m
 CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
 CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
 
 #
-# I2C Algorithms
+# I2C Hardware Bus support
 #
-CONFIG_I2C_ALGOBIT=m
-# CONFIG_I2C_ALGOPCF is not set
-# CONFIG_I2C_ALGOPCA is not set
 
 #
-# I2C Hardware Bus support
+# I2C system bus drivers (mostly embedded / system-on-chip)
 #
-CONFIG_I2C_ATMELTWI=m
+# CONFIG_I2C_DESIGNWARE is not set
 CONFIG_I2C_GPIO=m
 # CONFIG_I2C_OCORES is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_PCA_PLATFORM is not set
 # CONFIG_I2C_STUB is not set
 
 #
 # Miscellaneous I2C Chip support
 #
 # CONFIG_DS1682 is not set
-# CONFIG_EEPROM_LEGACY is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_PCF8575 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_TPS65010 is not set
-# CONFIG_SENSORS_MAX6875 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
 # CONFIG_I2C_DEBUG_BUS is not set
 # CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# SPI support
-#
 CONFIG_SPI=y
 # CONFIG_SPI_DEBUG is not set
 CONFIG_SPI_MASTER=y
@@ -695,30 +791,48 @@ CONFIG_SPI_MASTER=y
 #
 CONFIG_SPI_ATMEL=y
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 CONFIG_SPI_SPIDEV=m
 # CONFIG_SPI_TLE62X0 is not set
-CONFIG_HAVE_GPIO_LIB=y
 
 #
-# GPIO Support
+# PPS support
 #
+# CONFIG_PPS is not set
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
 # CONFIG_DEBUG_GPIO is not set
+# CONFIG_GPIO_SYSFS is not set
+
+#
+# Memory mapped GPIO expanders:
+#
 
 #
 # I2C GPIO expanders:
 #
+# CONFIG_GPIO_MAX732X is not set
 # CONFIG_GPIO_PCA953X is not set
 # CONFIG_GPIO_PCF857X is not set
 
+#
+# PCI GPIO expanders:
+#
+
 #
 # SPI GPIO expanders:
 #
+# CONFIG_GPIO_MAX7301 is not set
 # CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
@@ -731,24 +845,31 @@ CONFIG_WATCHDOG=y
 #
 # CONFIG_SOFT_WATCHDOG is not set
 CONFIG_AT32AP700X_WDT=y
+CONFIG_SSB_POSSIBLE=y
 
 #
 # Sonics Silicon Backplane
 #
-CONFIG_SSB_POSSIBLE=y
 # CONFIG_SSB is not set
 
 #
 # Multifunction device drivers
 #
+# CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-# CONFIG_DAB is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_UCB1400_CORE is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
 
 #
 # Graphics support
@@ -758,6 +879,7 @@ CONFIG_SSB_POSSIBLE=y
 CONFIG_FB=y
 # CONFIG_FIRMWARE_EDID is not set
 # CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
 CONFIG_FB_CFB_FILLRECT=y
 CONFIG_FB_CFB_COPYAREA=y
 CONFIG_FB_CFB_IMAGEBLIT=y
@@ -765,8 +887,8 @@ CONFIG_FB_CFB_IMAGEBLIT=y
 # CONFIG_FB_SYS_FILLRECT is not set
 # CONFIG_FB_SYS_COPYAREA is not set
 # CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
 # CONFIG_FB_SYS_FOPS is not set
-CONFIG_FB_DEFERRED_IO=y
 # CONFIG_FB_SVGALIB is not set
 # CONFIG_FB_MACMODES is not set
 # CONFIG_FB_BACKLIGHT is not set
@@ -779,6 +901,9 @@ CONFIG_FB_DEFERRED_IO=y
 # CONFIG_FB_S1D13XXX is not set
 CONFIG_FB_ATMEL=y
 # CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
@@ -792,119 +917,124 @@ CONFIG_FB_ATMEL=y
 CONFIG_DUMMY_CONSOLE=y
 # CONFIG_FRAMEBUFFER_CONSOLE is not set
 # CONFIG_LOGO is not set
-
-#
-# Sound
-#
 CONFIG_SOUND=y
-
-#
-# Advanced Linux Sound Architecture
-#
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
 CONFIG_SND=y
-CONFIG_SND_TIMER=m
+CONFIG_SND_TIMER=y
 CONFIG_SND_PCM=m
 # CONFIG_SND_SEQUENCER is not set
 CONFIG_SND_OSSEMUL=y
 CONFIG_SND_MIXER_OSS=m
 CONFIG_SND_PCM_OSS=m
 CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_HRTIMER=y
 # CONFIG_SND_DYNAMIC_MINORS is not set
 # CONFIG_SND_SUPPORT_OLD_API is not set
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
-
-#
-# Generic devices
-#
+CONFIG_SND_VMASTER=y
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
 CONFIG_SND_AC97_CODEC=m
-# CONFIG_SND_DUMMY is not set
-# CONFIG_SND_MTPAV is not set
-# CONFIG_SND_SERIAL_U16550 is not set
-# CONFIG_SND_MPU401 is not set
+# CONFIG_SND_DRIVERS is not set
 
 #
-# AVR32 devices
-#
-CONFIG_SND_ATMEL_AC97=m
-
-#
-# SPI devices
-#
-
-#
-# System on Chip audio support
+# Atmel devices (AVR32 and AT91)
 #
+# CONFIG_SND_ATMEL_ABDAC is not set
+CONFIG_SND_ATMEL_AC97C=m
+# CONFIG_SND_SPI is not set
 # CONFIG_SND_SOC is not set
-
-#
-# SoC Audio support for SuperH
-#
-
-#
-# ALSA SoC audio for Freescale SOCs
-#
-
-#
-# Open Sound System
-#
 # CONFIG_SOUND_PRIME is not set
 CONFIG_AC97_BUS=m
 CONFIG_HID_SUPPORT=y
 CONFIG_HID=y
-# CONFIG_HID_DEBUG is not set
 # CONFIG_HIDRAW is not set
+# CONFIG_HID_PID is not set
+
+#
+# Special HID drivers
+#
 CONFIG_USB_SUPPORT=y
 # CONFIG_USB_ARCH_HAS_HCD is not set
 # CONFIG_USB_ARCH_HAS_OHCI is not set
 # CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
 
 #
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 CONFIG_USB_GADGET=y
 # CONFIG_USB_GADGET_DEBUG is not set
 # CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=350
 CONFIG_USB_GADGET_SELECTED=y
-# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_AT91 is not set
 CONFIG_USB_GADGET_ATMEL_USBA=y
 CONFIG_USB_ATMEL_USBA=y
 # CONFIG_USB_GADGET_FSL_USB2 is not set
-# CONFIG_USB_GADGET_NET2280 is not set
-# CONFIG_USB_GADGET_PXA2XX is not set
-# CONFIG_USB_GADGET_M66592 is not set
-# CONFIG_USB_GADGET_GOKU is not set
 # CONFIG_USB_GADGET_LH7A40X is not set
 # CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
 # CONFIG_USB_GADGET_S3C2410 is not set
-# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
 # CONFIG_USB_GADGET_DUMMY_HCD is not set
 CONFIG_USB_GADGET_DUALSPEED=y
 CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
 CONFIG_USB_ETH=m
 CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_ETH_EEM is not set
 CONFIG_USB_GADGETFS=m
 CONFIG_USB_FILE_STORAGE=m
 # CONFIG_USB_FILE_STORAGE_TEST is not set
 CONFIG_USB_G_SERIAL=m
 # CONFIG_USB_MIDI_GADGET is not set
 # CONFIG_USB_G_PRINTER is not set
+CONFIG_USB_CDC_COMPOSITE=m
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
 CONFIG_MMC=y
 # CONFIG_MMC_DEBUG is not set
 # CONFIG_MMC_UNSAFE_RESUME is not set
 
 #
-# MMC/SD Card Drivers
+# MMC/SD/SDIO Card Drivers
 #
 CONFIG_MMC_BLOCK=y
 CONFIG_MMC_BLOCK_BOUNCE=y
 # CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
 
 #
-# MMC/SD Host Controller Drivers
+# MMC/SD/SDIO Host Controller Drivers
 #
+# CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
 CONFIG_MMC_ATMELMCI=y
+# CONFIG_MMC_ATMELMCI_DMA is not set
 # CONFIG_MMC_SPI is not set
 # CONFIG_MEMSTICK is not set
 CONFIG_NEW_LEDS=y
@@ -913,7 +1043,13 @@ CONFIG_LEDS_CLASS=y
 #
 # LED drivers
 #
+# CONFIG_LEDS_PCA9532 is not set
 CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_GPIO_PLATFORM=y
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
 
 #
 # LED Triggers
@@ -921,6 +1057,14 @@ CONFIG_LEDS_GPIO=y
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
+# CONFIG_ACCESSIBILITY is not set
 CONFIG_RTC_LIB=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_HCTOSYS=y
@@ -950,35 +1094,62 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_PCF8583 is not set
 # CONFIG_RTC_DRV_M41T80 is not set
 # CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
 
 #
 # SPI RTC drivers
 #
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
 # CONFIG_RTC_DRV_MAX6902 is not set
 # CONFIG_RTC_DRV_R9701 is not set
 # CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
 
 #
 # Platform RTC drivers
 #
+# CONFIG_RTC_DRV_DS1286 is not set
 # CONFIG_RTC_DRV_DS1511 is not set
 # CONFIG_RTC_DRV_DS1553 is not set
 # CONFIG_RTC_DRV_DS1742 is not set
 # CONFIG_RTC_DRV_STK17TA8 is not set
 # CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
 # CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
 # CONFIG_RTC_DRV_V3020 is not set
 
 #
 # on-CPU RTC drivers
 #
 CONFIG_RTC_DRV_AT32AP700X=y
+CONFIG_DMADEVICES=y
 
 #
-# Userspace I/O
+# DMA Devices
 #
+CONFIG_DW_DMAC=y
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+# CONFIG_NET_DMA is not set
+# CONFIG_ASYNC_TX_DMA is not set
+# CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
 
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
 #
 # File systems
 #
@@ -986,15 +1157,21 @@ CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_EXT2_FS_XIP is not set
 CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
 # CONFIG_EXT3_FS_XATTR is not set
-# CONFIG_EXT4DEV_FS is not set
+# CONFIG_EXT4_FS is not set
 CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
 # CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -1002,6 +1179,12 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -1025,15 +1208,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 CONFIG_PROC_FS=y
 # CONFIG_PROC_KCORE is not set
 CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
 CONFIG_SYSFS=y
 CONFIG_TMPFS=y
 # CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_CONFIGFS_FS=y
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -1059,8 +1240,10 @@ CONFIG_UBIFS_FS_LZO=y
 CONFIG_UBIFS_FS_ZLIB=y
 # CONFIG_UBIFS_FS_DEBUG is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
 # CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
 # CONFIG_ROMFS_FS is not set
@@ -1071,19 +1254,16 @@ CONFIG_NFS_FS=y
 CONFIG_NFS_V3=y
 # CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
+CONFIG_ROOT_NFS=y
 CONFIG_NFSD=m
 CONFIG_NFSD_V3=y
 # CONFIG_NFSD_V3_ACL is not set
 # CONFIG_NFSD_V4 is not set
-CONFIG_NFSD_TCP=y
-CONFIG_ROOT_NFS=y
 CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
 CONFIG_EXPORTFS=m
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_BIND34 is not set
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
@@ -1151,16 +1331,24 @@ CONFIG_NLS_UTF8=m
 # CONFIG_PRINTK_TIME is not set
 CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
 # CONFIG_UNUSED_SYMBOLS is not set
-# CONFIG_DEBUG_FS is not set
+CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
 CONFIG_DEBUG_KERNEL=y
 # CONFIG_DEBUG_SHIRQ is not set
 CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
 CONFIG_SCHED_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
 # CONFIG_SLUB_DEBUG_ON is not set
 # CONFIG_SLUB_STATS is not set
 # CONFIG_DEBUG_RT_MUTEXES is not set
@@ -1172,19 +1360,48 @@ CONFIG_SCHED_DEBUG=y
 # CONFIG_LOCK_STAT is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_INFO is not set
 # CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_BOOT_PRINTK_DELAY is not set
 # CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
 # CONFIG_KPROBES_SANITY_TEST is not set
 # CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
 # CONFIG_LKDTM is not set
 # CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_NOP_TRACER=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
+CONFIG_TRACING=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 
 #
@@ -1192,63 +1409,118 @@ CONFIG_FRAME_POINTER=y
 #
 # CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
 CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
 CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
 CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
 CONFIG_CRYPTO_BLKCIPHER=y
-# CONFIG_CRYPTO_SEQIV is not set
+CONFIG_CRYPTO_BLKCIPHER2=y
 CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
 CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=m
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
 CONFIG_CRYPTO_HMAC=y
 # CONFIG_CRYPTO_XCBC is not set
-# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
 # CONFIG_CRYPTO_MD4 is not set
 CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
 CONFIG_CRYPTO_SHA1=y
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
-# CONFIG_CRYPTO_WP512 is not set
 # CONFIG_CRYPTO_TGR192 is not set
-# CONFIG_CRYPTO_GF128MUL is not set
-CONFIG_CRYPTO_ECB=m
-CONFIG_CRYPTO_CBC=y
-# CONFIG_CRYPTO_PCBC is not set
-# CONFIG_CRYPTO_LRW is not set
-# CONFIG_CRYPTO_XTS is not set
-# CONFIG_CRYPTO_CTR is not set
-# CONFIG_CRYPTO_GCM is not set
-# CONFIG_CRYPTO_CCM is not set
-# CONFIG_CRYPTO_CRYPTD is not set
-CONFIG_CRYPTO_DES=y
-# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=m
 # CONFIG_CRYPTO_BLOWFISH is not set
-# CONFIG_CRYPTO_TWOFISH is not set
-# CONFIG_CRYPTO_SERPENT is not set
-# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
 # CONFIG_CRYPTO_CAST5 is not set
 # CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_TEA is not set
-CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
 # CONFIG_CRYPTO_KHAZAD is not set
-# CONFIG_CRYPTO_ANUBIS is not set
-# CONFIG_CRYPTO_SEED is not set
 # CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
 CONFIG_CRYPTO_DEFLATE=y
-# CONFIG_CRYPTO_MICHAEL_MIC is not set
-# CONFIG_CRYPTO_CRC32C is not set
-# CONFIG_CRYPTO_CAMELLIA is not set
-# CONFIG_CRYPTO_TEST is not set
-CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_ZLIB is not set
 CONFIG_CRYPTO_LZO=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
 CONFIG_CRYPTO_HW=y
+CONFIG_BINARY_PRINTF=y
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=y
+# CONFIG_CRC_T10DIF is not set
 # CONFIG_CRC_ITU_T is not set
 CONFIG_CRC32=y
 # CONFIG_CRC7 is not set
@@ -1257,8 +1529,9 @@ CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
 CONFIG_LZO_COMPRESS=y
 CONFIG_LZO_DECOMPRESS=y
+CONFIG_DECOMPRESS_GZIP=y
 CONFIG_GENERIC_ALLOCATOR=y
-CONFIG_PLIST=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
diff --git a/arch/avr32/configs/atngw100mkii_defconfig b/arch/avr32/configs/atngw100mkii_defconfig
new file mode 100644 (file)
index 0000000..9b8b5b3
--- /dev/null
@@ -0,0 +1,1414 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.32-rc5
+# Thu Nov  5 15:32:26 2009
+#
+CONFIG_AVR32=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_BUG=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_RELAY is not set
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+# CONFIG_BASE_FULL is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLUB_DEBUG=y
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+CONFIG_TRACEPOINTS=y
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+CONFIG_KPROBES=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_CLK=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_SLOW_WORK=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=1
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_BLOCK=y
+CONFIG_LBDAF=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_FREEZER=y
+
+#
+# System Type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SUBARCH_AVR32B=y
+CONFIG_MMU=y
+CONFIG_PERFORMANCE_COUNTERS=y
+CONFIG_PLATFORM_AT32AP=y
+CONFIG_CPU_AT32AP700X=y
+CONFIG_CPU_AT32AP7000=y
+CONFIG_BOARD_ATNGW100_COMMON=y
+# CONFIG_BOARD_ATSTK1000 is not set
+# CONFIG_BOARD_ATNGW100_MKI is not set
+CONFIG_BOARD_ATNGW100_MKII=y
+# CONFIG_BOARD_HAMMERHEAD is not set
+# CONFIG_BOARD_FAVR_32 is not set
+# CONFIG_BOARD_MERISC is not set
+# CONFIG_BOARD_MIMC200 is not set
+# CONFIG_BOARD_ATNGW100_MKII_LCD is not set
+CONFIG_BOARD_ATNGW100_ADDON_NONE=y
+# CONFIG_BOARD_ATNGW100_EVKLCD10X is not set
+# CONFIG_BOARD_ATNGW100_MRMT is not set
+CONFIG_LOADER_U_BOOT=y
+
+#
+# Atmel AVR32 AP options
+#
+# CONFIG_AP700X_32_BIT_SMC is not set
+CONFIG_AP700X_16_BIT_SMC=y
+# CONFIG_AP700X_8_BIT_SMC is not set
+CONFIG_LOAD_ADDRESS=0x10000000
+CONFIG_ENTRY_ADDRESS=0x90000000
+CONFIG_PHYS_OFFSET=0x10000000
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_QUICKLIST=y
+# CONFIG_HAVE_ARCH_BOOTMEM is not set
+# CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
+# CONFIG_NEED_NODE_MEMMAP_SIZE is not set
+CONFIG_ARCH_FLATMEM_ENABLE=y
+# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
+# CONFIG_ARCH_SPARSEMEM_ENABLE is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_NR_QUICK=2
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+# CONFIG_OWNERSHIP_TRACE is not set
+CONFIG_NMI_DEBUGGING=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_CMDLINE=""
+
+#
+# Power management options
+#
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+# CONFIG_PM_RUNTIME is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+# CONFIG_CPU_FREQ_STAT is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_AT32AP=y
+
+#
+# Bus options
+#
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=y
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=y
+CONFIG_NET_KEY=y
+# CONFIG_NET_KEY_MIGRATE is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_MULTIPLE_TABLES is not set
+# CONFIG_IP_ROUTE_MULTIPATH is not set
+# CONFIG_IP_ROUTE_VERBOSE is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+# CONFIG_IP_PIMSM_V2 is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=y
+CONFIG_INET_ESP=y
+CONFIG_INET_IPCOMP=y
+CONFIG_INET_XFRM_TUNNEL=y
+CONFIG_INET_TUNNEL=y
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+# CONFIG_INET_LRO is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IPV6=y
+# CONFIG_IPV6_PRIVACY is not set
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=y
+CONFIG_INET6_ESP=y
+CONFIG_INET6_IPCOMP=y
+# CONFIG_IPV6_MIP6 is not set
+CONFIG_INET6_XFRM_TUNNEL=y
+CONFIG_INET6_TUNNEL=y
+CONFIG_INET6_XFRM_MODE_TRANSPORT=y
+CONFIG_INET6_XFRM_MODE_TUNNEL=y
+CONFIG_INET6_XFRM_MODE_BEET=y
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+CONFIG_IPV6_SIT=y
+CONFIG_IPV6_NDISC_NODETYPE=y
+# CONFIG_IPV6_TUNNEL is not set
+# CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETWORK_SECMARK is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+# CONFIG_NETFILTER_ADVANCED is not set
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=y
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+# CONFIG_IP_VS is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_DEFRAG_IPV4=m
+CONFIG_NF_CONNTRACK_IPV4=m
+CONFIG_NF_CONNTRACK_PROC_COMPAT=y
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+# CONFIG_IP_NF_TARGET_ULOG is not set
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+# CONFIG_NF_NAT_TFTP is not set
+# CONFIG_NF_NAT_AMANDA is not set
+# CONFIG_NF_NAT_PPTP is not set
+# CONFIG_NF_NAT_H323 is not set
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+CONFIG_STP=m
+CONFIG_BRIDGE=m
+# CONFIG_NET_DSA is not set
+CONFIG_VLAN_8021Q=m
+# CONFIG_VLAN_8021Q_GVRP is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NET_TCPPROBE is not set
+# CONFIG_NET_DROP_MONITOR is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+# CONFIG_WIRELESS_EXT is not set
+# CONFIG_LIB80211 is not set
+
+#
+# CFG80211 needs to be enabled for MAC80211
+#
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
+CONFIG_STANDALONE=y
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_DATAFLASH=y
+# CONFIG_MTD_DATAFLASH_WRITE_VERIFY is not set
+# CONFIG_MTD_DATAFLASH_OTP is not set
+# CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+CONFIG_MTD_NAND_ATMEL=y
+CONFIG_MTD_NAND_ATMEL_ECC_HW=y
+# CONFIG_MTD_NAND_ATMEL_ECC_SOFT is not set
+# CONFIG_MTD_NAND_ATMEL_ECC_NONE is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+CONFIG_MISC_DEVICES=y
+# CONFIG_ATMEL_PWM is not set
+CONFIG_ATMEL_TCLIB=y
+CONFIG_ATMEL_TCB_CLKSRC=y
+CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
+# CONFIG_ICS932S401 is not set
+# CONFIG_ATMEL_SSC is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+# CONFIG_VETH is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
+CONFIG_NET_ETHERNET=y
+# CONFIG_MII is not set
+CONFIG_MACB=y
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+# CONFIG_PPP_SYNC_TTY is not set
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+# CONFIG_PPPOL2TP is not set
+# CONFIG_SLIP is not set
+CONFIG_SLHC=m
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+# CONFIG_INPUT is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_DEVKMEM is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_ATMEL=y
+CONFIG_SERIAL_ATMEL_CONSOLE=y
+CONFIG_SERIAL_ATMEL_PDC=y
+# CONFIG_SERIAL_ATMEL_TTYAT is not set
+# CONFIG_SERIAL_MAX3100 is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_DESIGNWARE is not set
+CONFIG_I2C_GPIO=m
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_STUB is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_DS1682 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_ATMEL=y
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_SPIDEV=m
+# CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# Memory mapped GPIO expanders:
+#
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCF857X is not set
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_AT32AP700X_WDT=y
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+# CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+# CONFIG_SOUND is not set
+CONFIG_USB_SUPPORT=y
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG is not set
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+CONFIG_USB_GADGET_ATMEL_USBA=y
+CONFIG_USB_ATMEL_USBA=y
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=m
+CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_ETH_EEM is not set
+CONFIG_USB_GADGETFS=m
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+CONFIG_USB_G_SERIAL=m
+# CONFIG_USB_MIDI_GADGET is not set
+# CONFIG_USB_G_PRINTER is not set
+CONFIG_USB_CDC_COMPOSITE=m
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_SDIO_UART is not set
+CONFIG_MMC_TEST=m
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
+CONFIG_MMC_ATMELMCI=y
+# CONFIG_MMC_ATMELMCI_DMA is not set
+CONFIG_MMC_SPI=m
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_GPIO_PLATFORM=y
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+# CONFIG_RTC_DRV_DS1307 is not set
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
+
+#
+# SPI RTC drivers
+#
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
+# CONFIG_RTC_DRV_MAX6902 is not set
+# CONFIG_RTC_DRV_R9701 is not set
+# CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_RTC_DRV_AT32AP700X=y
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_DW_DMAC=y
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+# CONFIG_NET_DMA is not set
+# CONFIG_ASYNC_TX_DMA is not set
+# CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+# CONFIG_EXT3_FS_XATTR is not set
+# CONFIG_EXT4_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+# CONFIG_DNOTIFY is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=850
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+# CONFIG_PROC_KCORE is not set
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_CONFIGFS_FS=m
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_UBIFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+CONFIG_UFS_FS=y
+# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_UFS_DEBUG is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+CONFIG_ROOT_NFS=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V3_ACL is not set
+# CONFIG_NFSD_V4 is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+# CONFIG_SMB_NLS_DEFAULT is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_WEAK_PW_HASH is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_EXPERIMENTAL is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=m
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=m
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+CONFIG_NLS_CODEPAGE_850=m
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=m
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=m
+# CONFIG_DLM is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
+CONFIG_SCHED_DEBUG=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_SLUB_DEBUG_ON is not set
+# CONFIG_SLUB_STATS is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+CONFIG_FRAME_POINTER=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_KPROBES_SANITY_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_LKDTM is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_NOP_TRACER=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
+CONFIG_TRACING=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_SAMPLES is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=m
+# CONFIG_CRYPTO_LRW is not set
+CONFIG_CRYPTO_PCBC=m
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+CONFIG_CRYPTO_SHA1=y
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=m
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+CONFIG_CRYPTO_HW=y
+CONFIG_BINARY_PRINTF=y
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+CONFIG_CRC_CCITT=m
+# CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_CRC7=m
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
diff --git a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
new file mode 100644 (file)
index 0000000..01e913d
--- /dev/null
@@ -0,0 +1,1549 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.32-rc5
+# Thu Nov  5 15:33:09 2009
+#
+CONFIG_AVR32=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_BUG=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_RELAY is not set
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+# CONFIG_BASE_FULL is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLUB_DEBUG=y
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+CONFIG_TRACEPOINTS=y
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+CONFIG_KPROBES=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_CLK=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_SLOW_WORK=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=1
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_BLOCK=y
+CONFIG_LBDAF=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_FREEZER=y
+
+#
+# System Type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SUBARCH_AVR32B=y
+CONFIG_MMU=y
+CONFIG_PERFORMANCE_COUNTERS=y
+CONFIG_PLATFORM_AT32AP=y
+CONFIG_CPU_AT32AP700X=y
+CONFIG_CPU_AT32AP7000=y
+CONFIG_BOARD_ATNGW100_COMMON=y
+# CONFIG_BOARD_ATSTK1000 is not set
+# CONFIG_BOARD_ATNGW100_MKI is not set
+CONFIG_BOARD_ATNGW100_MKII=y
+# CONFIG_BOARD_HAMMERHEAD is not set
+# CONFIG_BOARD_FAVR_32 is not set
+# CONFIG_BOARD_MERISC is not set
+# CONFIG_BOARD_MIMC200 is not set
+CONFIG_BOARD_ATNGW100_MKII_LCD=y
+# CONFIG_BOARD_ATNGW100_ADDON_NONE is not set
+CONFIG_BOARD_ATNGW100_EVKLCD10X=y
+# CONFIG_BOARD_ATNGW100_MRMT is not set
+CONFIG_BOARD_ATNGW100_EVKLCD10X_QVGA=y
+# CONFIG_BOARD_ATNGW100_EVKLCD10X_VGA is not set
+# CONFIG_BOARD_ATNGW100_EVKLCD10X_POW_QVGA is not set
+CONFIG_LOADER_U_BOOT=y
+
+#
+# Atmel AVR32 AP options
+#
+# CONFIG_AP700X_32_BIT_SMC is not set
+CONFIG_AP700X_16_BIT_SMC=y
+# CONFIG_AP700X_8_BIT_SMC is not set
+CONFIG_LOAD_ADDRESS=0x10000000
+CONFIG_ENTRY_ADDRESS=0x90000000
+CONFIG_PHYS_OFFSET=0x10000000
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_QUICKLIST=y
+# CONFIG_HAVE_ARCH_BOOTMEM is not set
+# CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
+# CONFIG_NEED_NODE_MEMMAP_SIZE is not set
+CONFIG_ARCH_FLATMEM_ENABLE=y
+# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
+# CONFIG_ARCH_SPARSEMEM_ENABLE is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_NR_QUICK=2
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+# CONFIG_OWNERSHIP_TRACE is not set
+CONFIG_NMI_DEBUGGING=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_CMDLINE=""
+
+#
+# Power management options
+#
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+# CONFIG_PM_RUNTIME is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+# CONFIG_CPU_FREQ_STAT is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_AT32AP=y
+
+#
+# Bus options
+#
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=y
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=y
+CONFIG_NET_KEY=y
+# CONFIG_NET_KEY_MIGRATE is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_MULTIPLE_TABLES is not set
+# CONFIG_IP_ROUTE_MULTIPATH is not set
+# CONFIG_IP_ROUTE_VERBOSE is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+# CONFIG_IP_PIMSM_V2 is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=y
+CONFIG_INET_ESP=y
+CONFIG_INET_IPCOMP=y
+CONFIG_INET_XFRM_TUNNEL=y
+CONFIG_INET_TUNNEL=y
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+# CONFIG_INET_LRO is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IPV6=y
+# CONFIG_IPV6_PRIVACY is not set
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=y
+CONFIG_INET6_ESP=y
+CONFIG_INET6_IPCOMP=y
+# CONFIG_IPV6_MIP6 is not set
+CONFIG_INET6_XFRM_TUNNEL=y
+CONFIG_INET6_TUNNEL=y
+CONFIG_INET6_XFRM_MODE_TRANSPORT=y
+CONFIG_INET6_XFRM_MODE_TUNNEL=y
+CONFIG_INET6_XFRM_MODE_BEET=y
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+CONFIG_IPV6_SIT=y
+CONFIG_IPV6_NDISC_NODETYPE=y
+# CONFIG_IPV6_TUNNEL is not set
+# CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETWORK_SECMARK is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+# CONFIG_NETFILTER_ADVANCED is not set
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=y
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+# CONFIG_IP_VS is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_DEFRAG_IPV4=m
+CONFIG_NF_CONNTRACK_IPV4=m
+CONFIG_NF_CONNTRACK_PROC_COMPAT=y
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+# CONFIG_IP_NF_TARGET_ULOG is not set
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+# CONFIG_NF_NAT_TFTP is not set
+# CONFIG_NF_NAT_AMANDA is not set
+# CONFIG_NF_NAT_PPTP is not set
+# CONFIG_NF_NAT_H323 is not set
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+CONFIG_STP=m
+CONFIG_BRIDGE=m
+# CONFIG_NET_DSA is not set
+CONFIG_VLAN_8021Q=m
+# CONFIG_VLAN_8021Q_GVRP is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NET_TCPPROBE is not set
+# CONFIG_NET_DROP_MONITOR is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+# CONFIG_WIRELESS_EXT is not set
+# CONFIG_LIB80211 is not set
+
+#
+# CFG80211 needs to be enabled for MAC80211
+#
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
+CONFIG_STANDALONE=y
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_DATAFLASH=y
+# CONFIG_MTD_DATAFLASH_WRITE_VERIFY is not set
+# CONFIG_MTD_DATAFLASH_OTP is not set
+# CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+CONFIG_MTD_NAND_ATMEL=y
+CONFIG_MTD_NAND_ATMEL_ECC_HW=y
+# CONFIG_MTD_NAND_ATMEL_ECC_SOFT is not set
+# CONFIG_MTD_NAND_ATMEL_ECC_NONE is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+CONFIG_MISC_DEVICES=y
+# CONFIG_ATMEL_PWM is not set
+CONFIG_ATMEL_TCLIB=y
+CONFIG_ATMEL_TCB_CLKSRC=y
+CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
+# CONFIG_ICS932S401 is not set
+# CONFIG_ATMEL_SSC is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
+CONFIG_NET_ETHERNET=y
+# CONFIG_MII is not set
+CONFIG_MACB=y
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+# CONFIG_PPP_SYNC_TTY is not set
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+# CONFIG_PPPOL2TP is not set
+# CONFIG_SLIP is not set
+CONFIG_SLHC=m
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+# CONFIG_INPUT_POLLDEV is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=m
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+CONFIG_INPUT_TOUCHSCREEN=y
+# CONFIG_TOUCHSCREEN_ADS7846 is not set
+# CONFIG_TOUCHSCREEN_AD7877 is not set
+# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
+# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
+# CONFIG_TOUCHSCREEN_AD7879 is not set
+# CONFIG_TOUCHSCREEN_EETI is not set
+# CONFIG_TOUCHSCREEN_FUJITSU is not set
+# CONFIG_TOUCHSCREEN_GUNZE is not set
+# CONFIG_TOUCHSCREEN_ELO is not set
+# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
+# CONFIG_TOUCHSCREEN_MCS5000 is not set
+# CONFIG_TOUCHSCREEN_MTOUCH is not set
+# CONFIG_TOUCHSCREEN_INEXIO is not set
+# CONFIG_TOUCHSCREEN_MK712 is not set
+# CONFIG_TOUCHSCREEN_PENMOUNT is not set
+# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
+# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
+CONFIG_TOUCHSCREEN_WM97XX=m
+CONFIG_TOUCHSCREEN_WM9705=y
+CONFIG_TOUCHSCREEN_WM9712=y
+CONFIG_TOUCHSCREEN_WM9713=y
+# CONFIG_TOUCHSCREEN_WM97XX_ATMEL is not set
+# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
+# CONFIG_TOUCHSCREEN_TSC2007 is not set
+# CONFIG_TOUCHSCREEN_W90X900 is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_DEVKMEM=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_ATMEL=y
+CONFIG_SERIAL_ATMEL_CONSOLE=y
+CONFIG_SERIAL_ATMEL_PDC=y
+# CONFIG_SERIAL_ATMEL_TTYAT is not set
+# CONFIG_SERIAL_MAX3100 is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_DESIGNWARE is not set
+CONFIG_I2C_GPIO=m
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_STUB is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_DS1682 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_ATMEL=y
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_SPIDEV=m
+# CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+# CONFIG_GPIO_SYSFS is not set
+
+#
+# Memory mapped GPIO expanders:
+#
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCF857X is not set
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_AT32AP700X_WDT=y
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_UCB1400_CORE is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+# CONFIG_FB_SYS_FILLRECT is not set
+# CONFIG_FB_SYS_COPYAREA is not set
+# CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+# CONFIG_FB_SYS_FOPS is not set
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_ATMEL=y
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE is not set
+# CONFIG_LOGO is not set
+CONFIG_SOUND=y
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=m
+# CONFIG_SND_SEQUENCER is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_HRTIMER=y
+# CONFIG_SND_DYNAMIC_MINORS is not set
+# CONFIG_SND_SUPPORT_OLD_API is not set
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+CONFIG_SND_AC97_CODEC=m
+# CONFIG_SND_DRIVERS is not set
+
+#
+# Atmel devices (AVR32 and AT91)
+#
+# CONFIG_SND_ATMEL_ABDAC is not set
+CONFIG_SND_ATMEL_AC97C=m
+# CONFIG_SND_SPI is not set
+# CONFIG_SND_SOC is not set
+# CONFIG_SOUND_PRIME is not set
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+# CONFIG_HIDRAW is not set
+# CONFIG_HID_PID is not set
+
+#
+# Special HID drivers
+#
+CONFIG_USB_SUPPORT=y
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG is not set
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=350
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+CONFIG_USB_GADGET_ATMEL_USBA=y
+CONFIG_USB_ATMEL_USBA=y
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=m
+CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_ETH_EEM is not set
+CONFIG_USB_GADGETFS=m
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+CONFIG_USB_G_SERIAL=m
+# CONFIG_USB_MIDI_GADGET is not set
+# CONFIG_USB_G_PRINTER is not set
+CONFIG_USB_CDC_COMPOSITE=m
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
+CONFIG_MMC_ATMELMCI=y
+# CONFIG_MMC_ATMELMCI_DMA is not set
+# CONFIG_MMC_SPI is not set
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_PCA9532 is not set
+CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_GPIO_PLATFORM=y
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+# CONFIG_RTC_DRV_DS1307 is not set
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
+
+#
+# SPI RTC drivers
+#
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
+# CONFIG_RTC_DRV_MAX6902 is not set
+# CONFIG_RTC_DRV_R9701 is not set
+# CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_RTC_DRV_AT32AP700X=y
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_DW_DMAC=y
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+# CONFIG_NET_DMA is not set
+# CONFIG_ASYNC_TX_DMA is not set
+# CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+# CONFIG_EXT3_FS_XATTR is not set
+# CONFIG_EXT4_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+# CONFIG_DNOTIFY is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=850
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+# CONFIG_PROC_KCORE is not set
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_CONFIGFS_FS=y
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_UBIFS_FS=y
+# CONFIG_UBIFS_FS_XATTR is not set
+# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_ZLIB=y
+# CONFIG_UBIFS_FS_DEBUG is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+CONFIG_ROOT_NFS=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V3_ACL is not set
+# CONFIG_NFSD_V4 is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+# CONFIG_SMB_NLS_DEFAULT is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_WEAK_PW_HASH is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_EXPERIMENTAL is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=m
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=m
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+CONFIG_NLS_CODEPAGE_850=m
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=m
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=m
+# CONFIG_DLM is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
+CONFIG_SCHED_DEBUG=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_SLUB_DEBUG_ON is not set
+# CONFIG_SLUB_STATS is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+CONFIG_FRAME_POINTER=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_KPROBES_SANITY_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_LKDTM is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_NOP_TRACER=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
+CONFIG_TRACING=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_SAMPLES is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=m
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+CONFIG_CRYPTO_SHA1=y
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=m
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
+CONFIG_CRYPTO_LZO=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+CONFIG_CRYPTO_HW=y
+CONFIG_BINARY_PRINTF=y
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=y
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
diff --git a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
new file mode 100644 (file)
index 0000000..bbf6bc3
--- /dev/null
@@ -0,0 +1,1549 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.32-rc5
+# Thu Nov  5 15:33:32 2009
+#
+CONFIG_AVR32=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_BUG=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_RELAY is not set
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+# CONFIG_BASE_FULL is not set
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLUB_DEBUG=y
+# CONFIG_COMPAT_BRK is not set
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+CONFIG_TRACEPOINTS=y
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+CONFIG_KPROBES=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_CLK=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_SLOW_WORK=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=1
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_BLOCK=y
+CONFIG_LBDAF=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_FREEZER=y
+
+#
+# System Type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SUBARCH_AVR32B=y
+CONFIG_MMU=y
+CONFIG_PERFORMANCE_COUNTERS=y
+CONFIG_PLATFORM_AT32AP=y
+CONFIG_CPU_AT32AP700X=y
+CONFIG_CPU_AT32AP7000=y
+CONFIG_BOARD_ATNGW100_COMMON=y
+# CONFIG_BOARD_ATSTK1000 is not set
+# CONFIG_BOARD_ATNGW100_MKI is not set
+CONFIG_BOARD_ATNGW100_MKII=y
+# CONFIG_BOARD_HAMMERHEAD is not set
+# CONFIG_BOARD_FAVR_32 is not set
+# CONFIG_BOARD_MERISC is not set
+# CONFIG_BOARD_MIMC200 is not set
+CONFIG_BOARD_ATNGW100_MKII_LCD=y
+# CONFIG_BOARD_ATNGW100_ADDON_NONE is not set
+CONFIG_BOARD_ATNGW100_EVKLCD10X=y
+# CONFIG_BOARD_ATNGW100_MRMT is not set
+# CONFIG_BOARD_ATNGW100_EVKLCD10X_QVGA is not set
+CONFIG_BOARD_ATNGW100_EVKLCD10X_VGA=y
+# CONFIG_BOARD_ATNGW100_EVKLCD10X_POW_QVGA is not set
+CONFIG_LOADER_U_BOOT=y
+
+#
+# Atmel AVR32 AP options
+#
+# CONFIG_AP700X_32_BIT_SMC is not set
+CONFIG_AP700X_16_BIT_SMC=y
+# CONFIG_AP700X_8_BIT_SMC is not set
+CONFIG_LOAD_ADDRESS=0x10000000
+CONFIG_ENTRY_ADDRESS=0x90000000
+CONFIG_PHYS_OFFSET=0x10000000
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_QUICKLIST=y
+# CONFIG_HAVE_ARCH_BOOTMEM is not set
+# CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
+# CONFIG_NEED_NODE_MEMMAP_SIZE is not set
+CONFIG_ARCH_FLATMEM_ENABLE=y
+# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
+# CONFIG_ARCH_SPARSEMEM_ENABLE is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_NR_QUICK=2
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+# CONFIG_OWNERSHIP_TRACE is not set
+CONFIG_NMI_DEBUGGING=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_CMDLINE=""
+
+#
+# Power management options
+#
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+# CONFIG_PM_RUNTIME is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+# CONFIG_CPU_FREQ_STAT is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_AT32AP=y
+
+#
+# Bus options
+#
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=y
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=y
+CONFIG_NET_KEY=y
+# CONFIG_NET_KEY_MIGRATE is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_MULTIPLE_TABLES is not set
+# CONFIG_IP_ROUTE_MULTIPATH is not set
+# CONFIG_IP_ROUTE_VERBOSE is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+# CONFIG_IP_PIMSM_V2 is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=y
+CONFIG_INET_ESP=y
+CONFIG_INET_IPCOMP=y
+CONFIG_INET_XFRM_TUNNEL=y
+CONFIG_INET_TUNNEL=y
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+# CONFIG_INET_LRO is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IPV6=y
+# CONFIG_IPV6_PRIVACY is not set
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=y
+CONFIG_INET6_ESP=y
+CONFIG_INET6_IPCOMP=y
+# CONFIG_IPV6_MIP6 is not set
+CONFIG_INET6_XFRM_TUNNEL=y
+CONFIG_INET6_TUNNEL=y
+CONFIG_INET6_XFRM_MODE_TRANSPORT=y
+CONFIG_INET6_XFRM_MODE_TUNNEL=y
+CONFIG_INET6_XFRM_MODE_BEET=y
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+CONFIG_IPV6_SIT=y
+CONFIG_IPV6_NDISC_NODETYPE=y
+# CONFIG_IPV6_TUNNEL is not set
+# CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETWORK_SECMARK is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+# CONFIG_NETFILTER_ADVANCED is not set
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=y
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+# CONFIG_IP_VS is not set
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_DEFRAG_IPV4=m
+CONFIG_NF_CONNTRACK_IPV4=m
+CONFIG_NF_CONNTRACK_PROC_COMPAT=y
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+# CONFIG_IP_NF_TARGET_ULOG is not set
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+# CONFIG_NF_NAT_TFTP is not set
+# CONFIG_NF_NAT_AMANDA is not set
+# CONFIG_NF_NAT_PPTP is not set
+# CONFIG_NF_NAT_H323 is not set
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+CONFIG_STP=m
+CONFIG_BRIDGE=m
+# CONFIG_NET_DSA is not set
+CONFIG_VLAN_8021Q=m
+# CONFIG_VLAN_8021Q_GVRP is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NET_TCPPROBE is not set
+# CONFIG_NET_DROP_MONITOR is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+# CONFIG_WIRELESS_EXT is not set
+# CONFIG_LIB80211 is not set
+
+#
+# CFG80211 needs to be enabled for MAC80211
+#
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
+CONFIG_STANDALONE=y
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_UTIL=y
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_DATAFLASH=y
+# CONFIG_MTD_DATAFLASH_WRITE_VERIFY is not set
+# CONFIG_MTD_DATAFLASH_OTP is not set
+# CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SST25L is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+CONFIG_MTD_NAND_ATMEL=y
+CONFIG_MTD_NAND_ATMEL_ECC_HW=y
+# CONFIG_MTD_NAND_ATMEL_ECC_SOFT is not set
+# CONFIG_MTD_NAND_ATMEL_ECC_NONE is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+CONFIG_MISC_DEVICES=y
+# CONFIG_ATMEL_PWM is not set
+CONFIG_ATMEL_TCLIB=y
+CONFIG_ATMEL_TCB_CLKSRC=y
+CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
+# CONFIG_ICS932S401 is not set
+# CONFIG_ATMEL_SSC is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
+CONFIG_NET_ETHERNET=y
+# CONFIG_MII is not set
+CONFIG_MACB=y
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+CONFIG_PPP=m
+# CONFIG_PPP_MULTILINK is not set
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+# CONFIG_PPP_SYNC_TTY is not set
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+# CONFIG_PPPOL2TP is not set
+# CONFIG_SLIP is not set
+CONFIG_SLHC=m
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+# CONFIG_INPUT_POLLDEV is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=m
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+CONFIG_INPUT_TOUCHSCREEN=y
+# CONFIG_TOUCHSCREEN_ADS7846 is not set
+# CONFIG_TOUCHSCREEN_AD7877 is not set
+# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
+# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
+# CONFIG_TOUCHSCREEN_AD7879 is not set
+# CONFIG_TOUCHSCREEN_EETI is not set
+# CONFIG_TOUCHSCREEN_FUJITSU is not set
+# CONFIG_TOUCHSCREEN_GUNZE is not set
+# CONFIG_TOUCHSCREEN_ELO is not set
+# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
+# CONFIG_TOUCHSCREEN_MCS5000 is not set
+# CONFIG_TOUCHSCREEN_MTOUCH is not set
+# CONFIG_TOUCHSCREEN_INEXIO is not set
+# CONFIG_TOUCHSCREEN_MK712 is not set
+# CONFIG_TOUCHSCREEN_PENMOUNT is not set
+# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
+# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
+CONFIG_TOUCHSCREEN_WM97XX=m
+CONFIG_TOUCHSCREEN_WM9705=y
+CONFIG_TOUCHSCREEN_WM9712=y
+CONFIG_TOUCHSCREEN_WM9713=y
+# CONFIG_TOUCHSCREEN_WM97XX_ATMEL is not set
+# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
+# CONFIG_TOUCHSCREEN_TSC2007 is not set
+# CONFIG_TOUCHSCREEN_W90X900 is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_DEVKMEM=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_ATMEL=y
+CONFIG_SERIAL_ATMEL_CONSOLE=y
+CONFIG_SERIAL_ATMEL_PDC=y
+# CONFIG_SERIAL_ATMEL_TTYAT is not set
+# CONFIG_SERIAL_MAX3100 is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_DESIGNWARE is not set
+CONFIG_I2C_GPIO=m
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_STUB is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_DS1682 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_ATMEL=y
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_SPIDEV=m
+# CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+CONFIG_ARCH_REQUIRE_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+# CONFIG_GPIO_SYSFS is not set
+
+#
+# Memory mapped GPIO expanders:
+#
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCF857X is not set
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_AT32AP700X_WDT=y
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_UCB1400_CORE is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+# CONFIG_FB_SYS_FILLRECT is not set
+# CONFIG_FB_SYS_COPYAREA is not set
+# CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+# CONFIG_FB_SYS_FOPS is not set
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_ATMEL=y
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE is not set
+# CONFIG_LOGO is not set
+CONFIG_SOUND=y
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=m
+# CONFIG_SND_SEQUENCER is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_HRTIMER=y
+# CONFIG_SND_DYNAMIC_MINORS is not set
+# CONFIG_SND_SUPPORT_OLD_API is not set
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+CONFIG_SND_AC97_CODEC=m
+# CONFIG_SND_DRIVERS is not set
+
+#
+# Atmel devices (AVR32 and AT91)
+#
+# CONFIG_SND_ATMEL_ABDAC is not set
+CONFIG_SND_ATMEL_AC97C=m
+# CONFIG_SND_SPI is not set
+# CONFIG_SND_SOC is not set
+# CONFIG_SOUND_PRIME is not set
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+# CONFIG_HIDRAW is not set
+# CONFIG_HID_PID is not set
+
+#
+# Special HID drivers
+#
+CONFIG_USB_SUPPORT=y
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG is not set
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=350
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+CONFIG_USB_GADGET_ATMEL_USBA=y
+CONFIG_USB_ATMEL_USBA=y
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=m
+CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_ETH_EEM is not set
+CONFIG_USB_GADGETFS=m
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+CONFIG_USB_G_SERIAL=m
+# CONFIG_USB_MIDI_GADGET is not set
+# CONFIG_USB_G_PRINTER is not set
+CONFIG_USB_CDC_COMPOSITE=m
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
+CONFIG_MMC_ATMELMCI=y
+# CONFIG_MMC_ATMELMCI_DMA is not set
+# CONFIG_MMC_SPI is not set
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_PCA9532 is not set
+CONFIG_LEDS_GPIO=y
+CONFIG_LEDS_GPIO_PLATFORM=y
+# CONFIG_LEDS_LP3944 is not set
+# CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=y
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
+# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+# CONFIG_RTC_DRV_DS1307 is not set
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
+
+#
+# SPI RTC drivers
+#
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
+# CONFIG_RTC_DRV_MAX6902 is not set
+# CONFIG_RTC_DRV_R9701 is not set
+# CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_RTC_DRV_AT32AP700X=y
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_DW_DMAC=y
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+# CONFIG_NET_DMA is not set
+# CONFIG_ASYNC_TX_DMA is not set
+# CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+# CONFIG_EXT3_FS_XATTR is not set
+# CONFIG_EXT4_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+# CONFIG_DNOTIFY is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=850
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+# CONFIG_PROC_KCORE is not set
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_CONFIGFS_FS=y
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_UBIFS_FS=y
+# CONFIG_UBIFS_FS_XATTR is not set
+# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_ZLIB=y
+# CONFIG_UBIFS_FS_DEBUG is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+CONFIG_ROOT_NFS=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+# CONFIG_NFSD_V3_ACL is not set
+# CONFIG_NFSD_V4 is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+CONFIG_SMB_FS=m
+# CONFIG_SMB_NLS_DEFAULT is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_WEAK_PW_HASH is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_EXPERIMENTAL is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=m
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=m
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+CONFIG_NLS_CODEPAGE_850=m
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=m
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=m
+# CONFIG_DLM is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
+CONFIG_SCHED_DEBUG=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_SLUB_DEBUG_ON is not set
+# CONFIG_SLUB_STATS is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+CONFIG_FRAME_POINTER=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_KPROBES_SANITY_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_LKDTM is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_NOP_TRACER=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
+CONFIG_TRACING=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_SAMPLES is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=m
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+CONFIG_CRYPTO_SHA1=y
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=m
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
+CONFIG_CRYPTO_LZO=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+CONFIG_CRYPTO_HW=y
+CONFIG_BINARY_PRINTF=y
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=y
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index 0abe90adb1a41c0a9f6a2e2cb0c6da5e81219647..42dafce0238932e3cc9e962e95ef766f46c00517 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.27-rc1
-# Mon Aug  4 16:02:27 2008
+# Linux kernel version: 2.6.32-rc5
+# Thu Oct 29 13:00:55 2009
 #
 CONFIG_AVR32=y
 CONFIG_GENERIC_GPIO=y
@@ -21,6 +21,7 @@ CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_GENERIC_BUG=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
 
 #
 # General setup
@@ -34,21 +35,36 @@ CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
 # CONFIG_IKCONFIG is not set
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_SYSFS_DEPRECATED_V2=y
 CONFIG_RELAY=y
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
@@ -58,38 +74,40 @@ CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 CONFIG_ELF_CORE=y
-# CONFIG_COMPAT_BRK is not set
 # CONFIG_BASE_FULL is not set
 CONFIG_FUTEX=y
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
 CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
 CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
 CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_SLUB_DEBUG=y
+# CONFIG_COMPAT_BRK is not set
 # CONFIG_SLAB is not set
 CONFIG_SLUB=y
 # CONFIG_SLOB is not set
 CONFIG_PROFILING=y
-# CONFIG_MARKERS is not set
+CONFIG_TRACEPOINTS=y
 CONFIG_OPROFILE=m
 CONFIG_HAVE_OPROFILE=y
 CONFIG_KPROBES=y
-# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
-# CONFIG_HAVE_IOREMAP_PROT is not set
 CONFIG_HAVE_KPROBES=y
-# CONFIG_HAVE_KRETPROBES is not set
-# CONFIG_HAVE_ARCH_TRACEHOOK is not set
-# CONFIG_HAVE_DMA_ATTRS is not set
-# CONFIG_USE_GENERIC_SMP_HELPERS is not set
 CONFIG_HAVE_CLK=y
-CONFIG_PROC_PAGE_MONITOR=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+# CONFIG_SLOW_WORK is not set
 # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
-# CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=1
 CONFIG_MODULES=y
 # CONFIG_MODULE_FORCE_LOAD is not set
@@ -97,11 +115,8 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
-# CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+CONFIG_LBDAF=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_BLK_DEV_INTEGRITY is not set
 
@@ -117,7 +132,7 @@ CONFIG_IOSCHED_CFQ=y
 CONFIG_DEFAULT_CFQ=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="cfq"
-CONFIG_CLASSIC_RCU=y
+CONFIG_FREEZER=y
 
 #
 # System Type and features
@@ -133,7 +148,12 @@ CONFIG_PLATFORM_AT32AP=y
 CONFIG_CPU_AT32AP700X=y
 CONFIG_CPU_AT32AP7000=y
 CONFIG_BOARD_ATSTK1000=y
-# CONFIG_BOARD_ATNGW100 is not set
+# CONFIG_BOARD_ATNGW100_MKI is not set
+# CONFIG_BOARD_ATNGW100_MKII is not set
+# CONFIG_BOARD_HAMMERHEAD is not set
+# CONFIG_BOARD_FAVR_32 is not set
+# CONFIG_BOARD_MERISC is not set
+# CONFIG_BOARD_MIMC200 is not set
 CONFIG_BOARD_ATSTK1002=y
 # CONFIG_BOARD_ATSTK1003 is not set
 # CONFIG_BOARD_ATSTK1004 is not set
@@ -159,7 +179,7 @@ CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
 CONFIG_QUICKLIST=y
-# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
+# CONFIG_HAVE_ARCH_BOOTMEM is not set
 # CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
 # CONFIG_NEED_NODE_MEMMAP_SIZE is not set
 CONFIG_ARCH_FLATMEM_ENABLE=y
@@ -171,14 +191,16 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=0
 CONFIG_NR_QUICK=2
 CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
 # CONFIG_OWNERSHIP_TRACE is not set
 CONFIG_NMI_DEBUGGING=y
 # CONFIG_HZ_100 is not set
@@ -186,7 +208,7 @@ CONFIG_HZ_250=y
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
 CONFIG_HZ=250
-# CONFIG_SCHED_HRTICK is not set
+CONFIG_SCHED_HRTICK=y
 CONFIG_CMDLINE=""
 
 #
@@ -197,6 +219,7 @@ CONFIG_PM=y
 CONFIG_PM_SLEEP=y
 CONFIG_SUSPEND=y
 CONFIG_SUSPEND_FREEZER=y
+# CONFIG_PM_RUNTIME is not set
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
@@ -228,6 +251,8 @@ CONFIG_CPU_FREQ_AT32AP=y
 # Executable file formats
 #
 CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
 CONFIG_NET=y
 
@@ -295,10 +320,12 @@ CONFIG_IPV6_TUNNEL=m
 # CONFIG_NETFILTER is not set
 # CONFIG_IP_DCCP is not set
 # CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 CONFIG_STP=m
 CONFIG_BRIDGE=m
+# CONFIG_NET_DSA is not set
 # CONFIG_VLAN_8021Q is not set
 # CONFIG_DECNET is not set
 CONFIG_LLC=m
@@ -309,26 +336,33 @@ CONFIG_LLC=m
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_NET_TCPPROBE is not set
+# CONFIG_NET_DROP_MONITOR is not set
 # CONFIG_HAMRADIO is not set
 # CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+# CONFIG_WIRELESS_EXT is not set
+# CONFIG_LIB80211 is not set
 
 #
-# Wireless
+# CFG80211 needs to be enabled for MAC80211
 #
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -340,6 +374,7 @@ CONFIG_LLC=m
 # Generic Driver Options
 #
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
 CONFIG_STANDALONE=y
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FW_LOADER is not set
@@ -349,6 +384,7 @@ CONFIG_STANDALONE=y
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
@@ -398,17 +434,18 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x8000000
-CONFIG_MTD_PHYSMAP_LEN=0x0
-CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
 CONFIG_MTD_DATAFLASH=m
+# CONFIG_MTD_DATAFLASH_WRITE_VERIFY is not set
+# CONFIG_MTD_DATAFLASH_OTP is not set
 CONFIG_MTD_M25P80=m
 CONFIG_M25PXX_USE_FAST_READ=y
+# CONFIG_MTD_SST25L is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -423,10 +460,23 @@ CONFIG_M25PXX_USE_FAST_READ=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
-# CONFIG_MTD_UBI is not set
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
 # CONFIG_PARPORT is not set
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
@@ -444,10 +494,20 @@ CONFIG_ATMEL_PWM=m
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_TCB_CLKSRC=y
 CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
-# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_ICS932S401 is not set
 CONFIG_ATMEL_SSC=m
 # CONFIG_ENCLOSURE_SERVICES is not set
-# CONFIG_HAVE_IDE is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+CONFIG_EEPROM_AT24=m
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
 
 #
 # SCSI device support
@@ -469,10 +529,6 @@ CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
 # CONFIG_CHR_DEV_SG is not set
 # CONFIG_CHR_DEV_SCH is not set
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
 # CONFIG_SCSI_MULTI_LUN is not set
 # CONFIG_SCSI_CONSTANTS is not set
 # CONFIG_SCSI_LOGGING is not set
@@ -489,8 +545,10 @@ CONFIG_SCSI_WAIT_SCAN=m
 # CONFIG_SCSI_SRP_ATTRS is not set
 # CONFIG_SCSI_LOWLEVEL is not set
 # CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
 CONFIG_ATA=m
 # CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_VERBOSE_ERROR=y
 # CONFIG_SATA_PMP is not set
 CONFIG_ATA_SFF=y
 # CONFIG_SATA_MV is not set
@@ -519,26 +577,37 @@ CONFIG_PHYLIB=y
 # CONFIG_BROADCOM_PHY is not set
 # CONFIG_ICPLUS_PHY is not set
 # CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
 # CONFIG_FIXED_PHY is not set
 # CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
 CONFIG_MACB=y
 # CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
 # CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
 
 #
-# Wireless LAN
+# Enable WiMAX (Networking options) to see the WiMAX drivers
 #
-# CONFIG_WLAN_PRE80211 is not set
-# CONFIG_WLAN_80211 is not set
-# CONFIG_IWLWIFI_LEDS is not set
 # CONFIG_WAN is not set
 CONFIG_PPP=m
 # CONFIG_PPP_MULTILINK is not set
@@ -580,18 +649,25 @@ CONFIG_INPUT_EVDEV=m
 # Input Device Drivers
 #
 CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADP5588 is not set
 # CONFIG_KEYBOARD_ATKBD is not set
-# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_QT2160 is not set
 # CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
+CONFIG_KEYBOARD_GPIO=m
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_LM8323 is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
 # CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
 # CONFIG_KEYBOARD_STOWAWAY is not set
-CONFIG_KEYBOARD_GPIO=m
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
 CONFIG_INPUT_MOUSE=y
 # CONFIG_MOUSE_PS2 is not set
 # CONFIG_MOUSE_SERIAL is not set
 # CONFIG_MOUSE_VSXXXAA is not set
 CONFIG_MOUSE_GPIO=m
+# CONFIG_MOUSE_SYNAPTICS_I2C is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TABLET is not set
 # CONFIG_INPUT_TOUCHSCREEN is not set
@@ -622,9 +698,11 @@ CONFIG_SERIAL_ATMEL=y
 CONFIG_SERIAL_ATMEL_CONSOLE=y
 CONFIG_SERIAL_ATMEL_PDC=y
 # CONFIG_SERIAL_ATMEL_TTYAT is not set
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
@@ -633,7 +711,9 @@ CONFIG_UNIX98_PTYS=y
 # CONFIG_TCG_TPM is not set
 CONFIG_I2C=m
 CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
 CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
 CONFIG_I2C_ALGOBIT=m
 
 #
@@ -643,6 +723,7 @@ CONFIG_I2C_ALGOBIT=m
 #
 # I2C system bus drivers (mostly embedded / system-on-chip)
 #
+# CONFIG_I2C_DESIGNWARE is not set
 CONFIG_I2C_GPIO=m
 # CONFIG_I2C_OCORES is not set
 # CONFIG_I2C_SIMTEC is not set
@@ -663,14 +744,6 @@ CONFIG_I2C_GPIO=m
 # Miscellaneous I2C Chip support
 #
 # CONFIG_DS1682 is not set
-CONFIG_EEPROM_AT24=m
-# CONFIG_EEPROM_LEGACY is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_PCF8575 is not set
-# CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_TPS65010 is not set
-# CONFIG_SENSORS_MAX6875 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
@@ -685,18 +758,27 @@ CONFIG_SPI_MASTER=y
 #
 CONFIG_SPI_ATMEL=y
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 CONFIG_SPI_SPIDEV=m
 # CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
 CONFIG_ARCH_REQUIRE_GPIOLIB=y
 CONFIG_GPIOLIB=y
 # CONFIG_DEBUG_GPIO is not set
 CONFIG_GPIO_SYSFS=y
 
+#
+# Memory mapped GPIO expanders:
+#
+
 #
 # I2C GPIO expanders:
 #
@@ -713,11 +795,15 @@ CONFIG_GPIO_SYSFS=y
 #
 # CONFIG_GPIO_MAX7301 is not set
 # CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
 # CONFIG_THERMAL is not set
-# CONFIG_THERMAL_HWMON is not set
 CONFIG_WATCHDOG=y
 # CONFIG_WATCHDOG_NOWAYOUT is not set
 
@@ -726,11 +812,11 @@ CONFIG_WATCHDOG=y
 #
 # CONFIG_SOFT_WATCHDOG is not set
 CONFIG_AT32AP700X_WDT=y
+CONFIG_SSB_POSSIBLE=y
 
 #
 # Sonics Silicon Backplane
 #
-CONFIG_SSB_POSSIBLE=y
 # CONFIG_SSB is not set
 
 #
@@ -739,22 +825,17 @@ CONFIG_SSB_POSSIBLE=y
 # CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
 # CONFIG_HTC_PASIC3 is not set
-
-#
-# Multimedia devices
-#
-
-#
-# Multimedia core support
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-# CONFIG_VIDEO_MEDIA is not set
-
-#
-# Multimedia drivers
-#
-# CONFIG_DAB is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
 
 #
 # Graphics support
@@ -764,6 +845,7 @@ CONFIG_SSB_POSSIBLE=y
 CONFIG_FB=y
 # CONFIG_FIRMWARE_EDID is not set
 # CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
 CONFIG_FB_CFB_FILLRECT=y
 CONFIG_FB_CFB_COPYAREA=y
 CONFIG_FB_CFB_IMAGEBLIT=y
@@ -785,10 +867,15 @@ CONFIG_FB_CFB_IMAGEBLIT=y
 # CONFIG_FB_S1D13XXX is not set
 CONFIG_FB_ATMEL=y
 # CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_LCD_CLASS_DEVICE=y
+# CONFIG_LCD_LMS283GF05 is not set
 CONFIG_LCD_LTV350QV=y
 # CONFIG_LCD_ILI9320 is not set
+# CONFIG_LCD_TDO24M is not set
 # CONFIG_LCD_VGG2432A4 is not set
 # CONFIG_LCD_PLATFORM is not set
 # CONFIG_BACKLIGHT_CLASS_DEVICE is not set
@@ -799,6 +886,8 @@ CONFIG_LCD_LTV350QV=y
 # CONFIG_DISPLAY_SUPPORT is not set
 # CONFIG_LOGO is not set
 CONFIG_SOUND=m
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
 CONFIG_SND=m
 CONFIG_SND_TIMER=m
 CONFIG_SND_PCM=m
@@ -807,12 +896,24 @@ CONFIG_SND_OSSEMUL=y
 CONFIG_SND_MIXER_OSS=m
 CONFIG_SND_PCM_OSS=m
 CONFIG_SND_PCM_OSS_PLUGINS=y
+# CONFIG_SND_HRTIMER is not set
 # CONFIG_SND_DYNAMIC_MINORS is not set
 # CONFIG_SND_SUPPORT_OLD_API is not set
 # CONFIG_SND_VERBOSE_PROCFS is not set
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
 # CONFIG_SND_DRIVERS is not set
+
+#
+# Atmel devices (AVR32 and AT91)
+#
+# CONFIG_SND_ATMEL_ABDAC is not set
+# CONFIG_SND_ATMEL_AC97C is not set
 CONFIG_SND_SPI=y
 CONFIG_SND_AT73C213=m
 CONFIG_SND_AT73C213_TARGET_BITRATE=48000
@@ -825,33 +926,43 @@ CONFIG_USB_SUPPORT=y
 # CONFIG_USB_ARCH_HAS_EHCI is not set
 # CONFIG_USB_OTG_WHITELIST is not set
 # CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
 
 #
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 CONFIG_USB_GADGET=y
 # CONFIG_USB_GADGET_DEBUG is not set
 # CONFIG_USB_GADGET_DEBUG_FILES is not set
 # CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
 CONFIG_USB_GADGET_SELECTED=y
-# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_AT91 is not set
 CONFIG_USB_GADGET_ATMEL_USBA=y
 CONFIG_USB_ATMEL_USBA=y
 # CONFIG_USB_GADGET_FSL_USB2 is not set
-# CONFIG_USB_GADGET_NET2280 is not set
-# CONFIG_USB_GADGET_PXA25X is not set
-# CONFIG_USB_GADGET_M66592 is not set
-# CONFIG_USB_GADGET_PXA27X is not set
-# CONFIG_USB_GADGET_GOKU is not set
 # CONFIG_USB_GADGET_LH7A40X is not set
 # CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
 # CONFIG_USB_GADGET_S3C2410 is not set
-# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
 # CONFIG_USB_GADGET_DUMMY_HCD is not set
 CONFIG_USB_GADGET_DUALSPEED=y
 CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
 CONFIG_USB_ETH=m
 CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_ETH_EEM is not set
 CONFIG_USB_GADGETFS=m
 CONFIG_USB_FILE_STORAGE=m
 # CONFIG_USB_FILE_STORAGE_TEST is not set
@@ -859,12 +970,18 @@ CONFIG_USB_G_SERIAL=m
 # CONFIG_USB_MIDI_GADGET is not set
 # CONFIG_USB_G_PRINTER is not set
 CONFIG_USB_CDC_COMPOSITE=m
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
 CONFIG_MMC=y
 # CONFIG_MMC_DEBUG is not set
 # CONFIG_MMC_UNSAFE_RESUME is not set
 
 #
-# MMC/SD Card Drivers
+# MMC/SD/SDIO Card Drivers
 #
 CONFIG_MMC_BLOCK=y
 CONFIG_MMC_BLOCK_BOUNCE=y
@@ -872,10 +989,12 @@ CONFIG_MMC_BLOCK_BOUNCE=y
 # CONFIG_MMC_TEST is not set
 
 #
-# MMC/SD Host Controller Drivers
+# MMC/SD/SDIO Host Controller Drivers
 #
 # CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
 CONFIG_MMC_ATMELMCI=y
+# CONFIG_MMC_ATMELMCI_DMA is not set
 CONFIG_MMC_SPI=m
 # CONFIG_MEMSTICK is not set
 CONFIG_NEW_LEDS=y
@@ -887,7 +1006,11 @@ CONFIG_LEDS_CLASS=m
 CONFIG_LEDS_ATMEL_PWM=m
 # CONFIG_LEDS_PCA9532 is not set
 CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_GPIO_PLATFORM=y
+# CONFIG_LEDS_LP3944 is not set
 # CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
 
 #
 # LED Triggers
@@ -895,7 +1018,13 @@ CONFIG_LEDS_GPIO=m
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
 CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
 # CONFIG_ACCESSIBILITY is not set
 CONFIG_RTC_LIB=y
 CONFIG_RTC_CLASS=y
@@ -927,25 +1056,33 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_M41T80 is not set
 # CONFIG_RTC_DRV_S35390A is not set
 # CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
 
 #
 # SPI RTC drivers
 #
 # CONFIG_RTC_DRV_M41T94 is not set
 # CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
 # CONFIG_RTC_DRV_MAX6902 is not set
 # CONFIG_RTC_DRV_R9701 is not set
 # CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
 
 #
 # Platform RTC drivers
 #
+# CONFIG_RTC_DRV_DS1286 is not set
 # CONFIG_RTC_DRV_DS1511 is not set
 # CONFIG_RTC_DRV_DS1553 is not set
 # CONFIG_RTC_DRV_DS1742 is not set
 # CONFIG_RTC_DRV_STK17TA8 is not set
 # CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
 # CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
 # CONFIG_RTC_DRV_V3020 is not set
 
 #
@@ -964,9 +1101,16 @@ CONFIG_DMA_ENGINE=y
 # DMA Clients
 #
 # CONFIG_NET_DMA is not set
+# CONFIG_ASYNC_TX_DMA is not set
 # CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
 
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
 #
 # File systems
 #
@@ -974,15 +1118,28 @@ CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_EXT2_FS_XIP is not set
 CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
 # CONFIG_EXT3_FS_XATTR is not set
-# CONFIG_EXT4DEV_FS is not set
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_XATTR=y
+# CONFIG_EXT4_FS_POSIX_ACL is not set
+# CONFIG_EXT4_FS_SECURITY is not set
+# CONFIG_EXT4_DEBUG is not set
 CONFIG_JBD=y
 # CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=y
+# CONFIG_JBD2_DEBUG is not set
+CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -990,6 +1147,12 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -1013,15 +1176,13 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 CONFIG_PROC_FS=y
 CONFIG_PROC_KCORE=y
 CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
 CONFIG_SYSFS=y
 CONFIG_TMPFS=y
 # CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -1039,7 +1200,14 @@ CONFIG_JFFS2_ZLIB=y
 # CONFIG_JFFS2_LZO is not set
 CONFIG_JFFS2_RTIME=y
 # CONFIG_JFFS2_RUBIN is not set
+CONFIG_UBIFS_FS=y
+# CONFIG_UBIFS_FS_XATTR is not set
+# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_ZLIB=y
+# CONFIG_UBIFS_FS_DEBUG is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 CONFIG_MINIX_FS=m
 # CONFIG_OMFS_FS is not set
@@ -1122,6 +1290,7 @@ CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
 CONFIG_FRAME_WARN=1024
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
@@ -1130,6 +1299,9 @@ CONFIG_DEBUG_KERNEL=y
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
 CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
 CONFIG_SCHED_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_TIMER_STATS is not set
@@ -1145,6 +1317,7 @@ CONFIG_SCHED_DEBUG=y
 # CONFIG_LOCK_STAT is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_INFO is not set
@@ -1153,13 +1326,39 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_BOOT_PRINTK_DELAY is not set
 # CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
 # CONFIG_KPROBES_SANITY_TEST is not set
 # CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
 # CONFIG_LKDTM is not set
 # CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_NOP_TRACER=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
+CONFIG_TRACING=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 
 #
@@ -1167,19 +1366,30 @@ CONFIG_FRAME_POINTER=y
 #
 # CONFIG_KEYS is not set
 # CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
 CONFIG_CRYPTO=y
 
 #
 # Crypto core or helper
 #
-CONFIG_CRYPTO_ALGAPI=m
+# CONFIG_CRYPTO_FIPS is not set
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
 CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_AEAD2=y
 CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_BLKCIPHER2=y
 CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
 CONFIG_CRYPTO_MANAGER=m
+CONFIG_CRYPTO_MANAGER2=y
 # CONFIG_CRYPTO_GF128MUL is not set
 # CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
 # CONFIG_CRYPTO_CRYPTD is not set
 CONFIG_CRYPTO_AUTHENC=m
 # CONFIG_CRYPTO_TEST is not set
@@ -1207,11 +1417,13 @@ CONFIG_CRYPTO_CBC=m
 #
 CONFIG_CRYPTO_HMAC=m
 # CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
 
 #
 # Digest
 #
 # CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
 # CONFIG_CRYPTO_MD4 is not set
 CONFIG_CRYPTO_MD5=m
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
@@ -1228,7 +1440,7 @@ CONFIG_CRYPTO_SHA1=m
 #
 # Ciphers
 #
-# CONFIG_CRYPTO_AES is not set
+CONFIG_CRYPTO_AES=m
 # CONFIG_CRYPTO_ANUBIS is not set
 # CONFIG_CRYPTO_ARC4 is not set
 # CONFIG_CRYPTO_BLOWFISH is not set
@@ -1247,18 +1459,24 @@ CONFIG_CRYPTO_DES=m
 #
 # Compression
 #
-CONFIG_CRYPTO_DEFLATE=m
-# CONFIG_CRYPTO_LZO is not set
+CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
+CONFIG_CRYPTO_LZO=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
 # CONFIG_CRYPTO_HW is not set
+CONFIG_BINARY_PRINTF=y
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
-# CONFIG_GENERIC_FIND_FIRST_BIT is not set
-# CONFIG_GENERIC_FIND_NEXT_BIT is not set
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
-# CONFIG_CRC16 is not set
+CONFIG_CRC16=y
 CONFIG_CRC_T10DIF=m
 CONFIG_CRC_ITU_T=m
 CONFIG_CRC32=y
@@ -1266,8 +1484,11 @@ CONFIG_CRC7=m
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
+CONFIG_DECOMPRESS_GZIP=y
 CONFIG_GENERIC_ALLOCATOR=y
-CONFIG_PLIST=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index c1603c4860e0466738e4840f39498d4d3dadd6cd..363e2381f32a8595d357d5fa780a379b570fbee0 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.28-rc8
-# Thu Dec 18 11:22:23 2008
+# Linux kernel version: 2.6.32-rc5
+# Thu Oct 29 13:00:25 2009
 #
 CONFIG_AVR32=y
 CONFIG_GENERIC_GPIO=y
@@ -21,6 +21,7 @@ CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
 CONFIG_GENERIC_BUG=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
 
 #
 # General setup
@@ -34,21 +35,36 @@ CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 CONFIG_POSIX_MQUEUE=y
+CONFIG_POSIX_MQUEUE_SYSCTL=y
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
 # CONFIG_IKCONFIG is not set
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 CONFIG_SYSFS_DEPRECATED=y
 CONFIG_SYSFS_DEPRECATED_V2=y
 CONFIG_RELAY=y
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
@@ -58,32 +74,40 @@ CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 CONFIG_ELF_CORE=y
-# CONFIG_COMPAT_BRK is not set
 # CONFIG_BASE_FULL is not set
 CONFIG_FUTEX=y
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
 CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
 CONFIG_SHMEM=y
 CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
 CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_SLUB_DEBUG=y
+# CONFIG_COMPAT_BRK is not set
 # CONFIG_SLAB is not set
 CONFIG_SLUB=y
 # CONFIG_SLOB is not set
 CONFIG_PROFILING=y
-# CONFIG_MARKERS is not set
+CONFIG_TRACEPOINTS=y
 CONFIG_OPROFILE=m
 CONFIG_HAVE_OPROFILE=y
 CONFIG_KPROBES=y
 CONFIG_HAVE_KPROBES=y
 CONFIG_HAVE_CLK=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+# CONFIG_SLOW_WORK is not set
 # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
-# CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=1
 CONFIG_MODULES=y
 # CONFIG_MODULE_FORCE_LOAD is not set
@@ -91,11 +115,8 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
-# CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+CONFIG_LBDAF=y
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_BLK_DEV_INTEGRITY is not set
 
@@ -111,7 +132,6 @@ CONFIG_IOSCHED_CFQ=y
 CONFIG_DEFAULT_CFQ=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="cfq"
-CONFIG_CLASSIC_RCU=y
 CONFIG_FREEZER=y
 
 #
@@ -128,8 +148,11 @@ CONFIG_PLATFORM_AT32AP=y
 CONFIG_CPU_AT32AP700X=y
 CONFIG_CPU_AT32AP7000=y
 CONFIG_BOARD_ATSTK1000=y
-# CONFIG_BOARD_ATNGW100 is not set
+# CONFIG_BOARD_ATNGW100_MKI is not set
+# CONFIG_BOARD_ATNGW100_MKII is not set
+# CONFIG_BOARD_HAMMERHEAD is not set
 # CONFIG_BOARD_FAVR_32 is not set
+# CONFIG_BOARD_MERISC is not set
 # CONFIG_BOARD_MIMC200 is not set
 # CONFIG_BOARD_ATSTK1002 is not set
 # CONFIG_BOARD_ATSTK1003 is not set
@@ -156,7 +179,7 @@ CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
 CONFIG_QUICKLIST=y
-# CONFIG_HAVE_ARCH_BOOTMEM_NODE is not set
+# CONFIG_HAVE_ARCH_BOOTMEM is not set
 # CONFIG_ARCH_HAVE_MEMORY_PRESENT is not set
 # CONFIG_NEED_NODE_MEMMAP_SIZE is not set
 CONFIG_ARCH_FLATMEM_ENABLE=y
@@ -170,12 +193,14 @@ CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=0
 CONFIG_NR_QUICK=2
 CONFIG_VIRT_TO_BUS=y
-CONFIG_UNEVICTABLE_LRU=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
 # CONFIG_OWNERSHIP_TRACE is not set
 CONFIG_NMI_DEBUGGING=y
 # CONFIG_HZ_100 is not set
@@ -194,6 +219,7 @@ CONFIG_PM=y
 CONFIG_PM_SLEEP=y
 CONFIG_SUSPEND=y
 CONFIG_SUSPEND_FREEZER=y
+# CONFIG_PM_RUNTIME is not set
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
@@ -294,6 +320,7 @@ CONFIG_IPV6_TUNNEL=m
 # CONFIG_NETFILTER is not set
 # CONFIG_IP_DCCP is not set
 # CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 CONFIG_STP=m
@@ -309,20 +336,24 @@ CONFIG_LLC=m
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_NET_TCPPROBE is not set
+# CONFIG_NET_DROP_MONITOR is not set
 # CONFIG_HAMRADIO is not set
 # CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
-# CONFIG_PHONET is not set
 # CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -334,6 +365,7 @@ CONFIG_LLC=m
 # Generic Driver Options
 #
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
 CONFIG_STANDALONE=y
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FW_LOADER is not set
@@ -343,6 +375,7 @@ CONFIG_STANDALONE=y
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
@@ -393,9 +426,7 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x8000000
-CONFIG_MTD_PHYSMAP_LEN=0x0
-CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
@@ -406,6 +437,7 @@ CONFIG_MTD_DATAFLASH=m
 CONFIG_MTD_DATAFLASH_OTP=y
 CONFIG_MTD_M25P80=m
 CONFIG_M25PXX_USE_FAST_READ=y
+# CONFIG_MTD_SST25L is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -431,6 +463,11 @@ CONFIG_MTD_NAND_ATMEL_ECC_HW=y
 # CONFIG_MTD_NAND_PLATFORM is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -460,12 +497,21 @@ CONFIG_ATMEL_PWM=m
 CONFIG_ATMEL_TCLIB=y
 CONFIG_ATMEL_TCB_CLKSRC=y
 CONFIG_ATMEL_TCB_CLKSRC_BLOCK=0
-# CONFIG_EEPROM_93CX6 is not set
 # CONFIG_ICS932S401 is not set
 CONFIG_ATMEL_SSC=m
 # CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_ISL29003 is not set
 # CONFIG_C2PORT is not set
 
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+
 #
 # SCSI device support
 #
@@ -486,10 +532,6 @@ CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
 # CONFIG_CHR_DEV_SG is not set
 # CONFIG_CHR_DEV_SCH is not set
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
 # CONFIG_SCSI_MULTI_LUN is not set
 # CONFIG_SCSI_CONSTANTS is not set
 # CONFIG_SCSI_LOGGING is not set
@@ -506,8 +548,10 @@ CONFIG_SCSI_WAIT_SCAN=m
 # CONFIG_SCSI_SRP_ATTRS is not set
 # CONFIG_SCSI_LOWLEVEL is not set
 # CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
 CONFIG_ATA=m
 # CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_VERBOSE_ERROR=y
 # CONFIG_SATA_PMP is not set
 CONFIG_ATA_SFF=y
 # CONFIG_SATA_MV is not set
@@ -536,12 +580,17 @@ CONFIG_PHYLIB=y
 # CONFIG_BROADCOM_PHY is not set
 # CONFIG_ICPLUS_PHY is not set
 # CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
 # CONFIG_FIXED_PHY is not set
 # CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
 CONFIG_MACB=y
 # CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
@@ -550,15 +599,18 @@ CONFIG_MACB=y
 # CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
 # CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_KS8851_MLL is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
 
 #
-# Wireless LAN
+# Enable WiMAX (Networking options) to see the WiMAX drivers
 #
-# CONFIG_WLAN_PRE80211 is not set
-# CONFIG_WLAN_80211 is not set
-# CONFIG_IWLWIFI_LEDS is not set
 # CONFIG_WAN is not set
 CONFIG_PPP=m
 # CONFIG_PPP_MULTILINK is not set
@@ -600,18 +652,25 @@ CONFIG_INPUT_EVDEV=m
 # Input Device Drivers
 #
 CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADP5588 is not set
 # CONFIG_KEYBOARD_ATKBD is not set
-# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_QT2160 is not set
 # CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
+CONFIG_KEYBOARD_GPIO=m
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_LM8323 is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
 # CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
 # CONFIG_KEYBOARD_STOWAWAY is not set
-CONFIG_KEYBOARD_GPIO=m
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
 CONFIG_INPUT_MOUSE=y
 # CONFIG_MOUSE_PS2 is not set
 # CONFIG_MOUSE_SERIAL is not set
 # CONFIG_MOUSE_VSXXXAA is not set
 CONFIG_MOUSE_GPIO=m
+# CONFIG_MOUSE_SYNAPTICS_I2C is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TABLET is not set
 # CONFIG_INPUT_TOUCHSCREEN is not set
@@ -642,9 +701,11 @@ CONFIG_SERIAL_ATMEL=y
 CONFIG_SERIAL_ATMEL_CONSOLE=y
 CONFIG_SERIAL_ATMEL_PDC=y
 # CONFIG_SERIAL_ATMEL_TTYAT is not set
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
@@ -653,6 +714,7 @@ CONFIG_UNIX98_PTYS=y
 # CONFIG_TCG_TPM is not set
 CONFIG_I2C=m
 CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
 CONFIG_I2C_CHARDEV=m
 CONFIG_I2C_HELPER_AUTO=y
 CONFIG_I2C_ALGOBIT=m
@@ -664,6 +726,7 @@ CONFIG_I2C_ALGOBIT=m
 #
 # I2C system bus drivers (mostly embedded / system-on-chip)
 #
+# CONFIG_I2C_DESIGNWARE is not set
 CONFIG_I2C_GPIO=m
 # CONFIG_I2C_OCORES is not set
 # CONFIG_I2C_SIMTEC is not set
@@ -684,14 +747,6 @@ CONFIG_I2C_GPIO=m
 # Miscellaneous I2C Chip support
 #
 # CONFIG_DS1682 is not set
-# CONFIG_EEPROM_AT24 is not set
-# CONFIG_EEPROM_LEGACY is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_PCF8575 is not set
-# CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_TPS65010 is not set
-# CONFIG_SENSORS_MAX6875 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
@@ -706,13 +761,18 @@ CONFIG_SPI_MASTER=y
 #
 CONFIG_SPI_ATMEL=y
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 CONFIG_SPI_SPIDEV=m
 # CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
 CONFIG_ARCH_REQUIRE_GPIOLIB=y
 CONFIG_GPIOLIB=y
 # CONFIG_DEBUG_GPIO is not set
@@ -738,11 +798,15 @@ CONFIG_GPIO_SYSFS=y
 #
 # CONFIG_GPIO_MAX7301 is not set
 # CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIO_MC33880 is not set
+
+#
+# AC97 GPIO expanders:
+#
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
 # CONFIG_THERMAL is not set
-# CONFIG_THERMAL_HWMON is not set
 CONFIG_WATCHDOG=y
 # CONFIG_WATCHDOG_NOWAYOUT is not set
 
@@ -764,26 +828,17 @@ CONFIG_SSB_POSSIBLE=y
 # CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
 # CONFIG_HTC_PASIC3 is not set
+# CONFIG_TPS65010 is not set
 # CONFIG_MFD_TMIO is not set
 # CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
 # CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_MFD_MC13783 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
 # CONFIG_REGULATOR is not set
-
-#
-# Multimedia devices
-#
-
-#
-# Multimedia core support
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-# CONFIG_VIDEO_MEDIA is not set
-
-#
-# Multimedia drivers
-#
-# CONFIG_DAB is not set
+# CONFIG_MEDIA_SUPPORT is not set
 
 #
 # Graphics support
@@ -817,8 +872,10 @@ CONFIG_FB_ATMEL=y
 # CONFIG_FB_VIRTUAL is not set
 # CONFIG_FB_METRONOME is not set
 # CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_LCD_CLASS_DEVICE=y
+# CONFIG_LCD_LMS283GF05 is not set
 CONFIG_LCD_LTV350QV=y
 # CONFIG_LCD_ILI9320 is not set
 # CONFIG_LCD_TDO24M is not set
@@ -833,6 +890,7 @@ CONFIG_LCD_LTV350QV=y
 # CONFIG_LOGO is not set
 CONFIG_SOUND=m
 CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
 CONFIG_SND=m
 CONFIG_SND_TIMER=m
 CONFIG_SND_PCM=m
@@ -841,16 +899,28 @@ CONFIG_SND_OSSEMUL=y
 CONFIG_SND_MIXER_OSS=m
 CONFIG_SND_PCM_OSS=m
 CONFIG_SND_PCM_OSS_PLUGINS=y
+# CONFIG_SND_HRTIMER is not set
 # CONFIG_SND_DYNAMIC_MINORS is not set
 # CONFIG_SND_SUPPORT_OLD_API is not set
 # CONFIG_SND_VERBOSE_PROCFS is not set
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
 CONFIG_SND_DRIVERS=y
 # CONFIG_SND_DUMMY is not set
 # CONFIG_SND_MTPAV is not set
 # CONFIG_SND_SERIAL_U16550 is not set
 # CONFIG_SND_MPU401 is not set
+
+#
+# Atmel devices (AVR32 and AT91)
+#
+# CONFIG_SND_ATMEL_ABDAC is not set
+# CONFIG_SND_ATMEL_AC97C is not set
 CONFIG_SND_SPI=y
 CONFIG_SND_AT73C213=m
 CONFIG_SND_AT73C213_TARGET_BITRATE=48000
@@ -863,11 +933,10 @@ CONFIG_USB_SUPPORT=y
 # CONFIG_USB_ARCH_HAS_EHCI is not set
 # CONFIG_USB_OTG_WHITELIST is not set
 # CONFIG_USB_OTG_BLACKLIST_HUB is not set
-# CONFIG_USB_MUSB_HDRC is not set
 # CONFIG_USB_GADGET_MUSB_HDRC is not set
 
 #
-# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 CONFIG_USB_GADGET=y
 # CONFIG_USB_GADGET_DEBUG is not set
@@ -882,18 +951,25 @@ CONFIG_USB_ATMEL_USBA=y
 # CONFIG_USB_GADGET_LH7A40X is not set
 # CONFIG_USB_GADGET_OMAP is not set
 # CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_R8A66597 is not set
 # CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C_HSOTG is not set
+# CONFIG_USB_GADGET_IMX is not set
 # CONFIG_USB_GADGET_S3C2410 is not set
 # CONFIG_USB_GADGET_M66592 is not set
 # CONFIG_USB_GADGET_AMD5536UDC is not set
 # CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
 # CONFIG_USB_GADGET_NET2280 is not set
 # CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LANGWELL is not set
 # CONFIG_USB_GADGET_DUMMY_HCD is not set
 CONFIG_USB_GADGET_DUALSPEED=y
 CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
 CONFIG_USB_ETH=m
 CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_ETH_EEM is not set
 CONFIG_USB_GADGETFS=m
 CONFIG_USB_FILE_STORAGE=m
 # CONFIG_USB_FILE_STORAGE_TEST is not set
@@ -901,6 +977,12 @@ CONFIG_USB_G_SERIAL=m
 # CONFIG_USB_MIDI_GADGET is not set
 # CONFIG_USB_G_PRINTER is not set
 # CONFIG_USB_CDC_COMPOSITE is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
 CONFIG_MMC=y
 # CONFIG_MMC_DEBUG is not set
 # CONFIG_MMC_UNSAFE_RESUME is not set
@@ -917,6 +999,7 @@ CONFIG_MMC_BLOCK_BOUNCE=y
 # MMC/SD/SDIO Host Controller Drivers
 #
 # CONFIG_MMC_SDHCI is not set
+# CONFIG_MMC_AT91 is not set
 CONFIG_MMC_ATMELMCI=y
 # CONFIG_MMC_ATMELMCI_DMA is not set
 CONFIG_MMC_SPI=m
@@ -930,7 +1013,11 @@ CONFIG_LEDS_CLASS=m
 CONFIG_LEDS_ATMEL_PWM=m
 # CONFIG_LEDS_PCA9532 is not set
 CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_GPIO_PLATFORM=y
+# CONFIG_LEDS_LP3944 is not set
 # CONFIG_LEDS_PCA955X is not set
+# CONFIG_LEDS_DAC124S085 is not set
+# CONFIG_LEDS_BD2802 is not set
 
 #
 # LED Triggers
@@ -939,7 +1026,12 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
 # CONFIG_LEDS_TRIGGER_BACKLIGHT is not set
+# CONFIG_LEDS_TRIGGER_GPIO is not set
 CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+
+#
+# iptables trigger is under Netfilter config (LED target)
+#
 # CONFIG_ACCESSIBILITY is not set
 CONFIG_RTC_LIB=y
 CONFIG_RTC_CLASS=y
@@ -972,6 +1064,7 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_S35390A is not set
 # CONFIG_RTC_DRV_FM3130 is not set
 # CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
 
 #
 # SPI RTC drivers
@@ -983,6 +1076,7 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_R9701 is not set
 # CONFIG_RTC_DRV_RS5C348 is not set
 # CONFIG_RTC_DRV_DS3234 is not set
+# CONFIG_RTC_DRV_PCF2123 is not set
 
 #
 # Platform RTC drivers
@@ -1014,32 +1108,42 @@ CONFIG_DMA_ENGINE=y
 # DMA Clients
 #
 # CONFIG_NET_DMA is not set
+# CONFIG_ASYNC_TX_DMA is not set
 # CONFIG_DMATEST is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
 # CONFIG_STAGING is not set
-CONFIG_STAGING_EXCLUDE_BUILD=y
 
 #
 # File systems
 #
-CONFIG_EXT2_FS=m
+CONFIG_EXT2_FS=y
 # CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_EXT2_FS_XIP is not set
-CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
 # CONFIG_EXT3_FS_XATTR is not set
-CONFIG_EXT4_FS=m
-CONFIG_EXT4DEV_COMPAT=y
+CONFIG_EXT4_FS=y
 # CONFIG_EXT4_FS_XATTR is not set
-CONFIG_JBD=m
+# CONFIG_EXT4_DEBUG is not set
+CONFIG_JBD=y
 # CONFIG_JBD_DEBUG is not set
-CONFIG_JBD2=m
+CONFIG_JBD2=y
 # CONFIG_JBD2_DEBUG is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
-CONFIG_FILE_LOCKING=y
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -1047,6 +1151,12 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
 
 #
 # CD-ROM/DVD Filesystems
@@ -1076,10 +1186,7 @@ CONFIG_TMPFS=y
 # CONFIG_TMPFS_POSIX_ACL is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -1099,12 +1206,13 @@ CONFIG_JFFS2_ZLIB=y
 CONFIG_JFFS2_RTIME=y
 # CONFIG_JFFS2_RUBIN is not set
 CONFIG_UBIFS_FS=y
-CONFIG_UBIFS_FS_XATTR=y
+# CONFIG_UBIFS_FS_XATTR is not set
 # CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
 CONFIG_UBIFS_FS_LZO=y
 CONFIG_UBIFS_FS_ZLIB=y
 # CONFIG_UBIFS_FS_DEBUG is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 CONFIG_MINIX_FS=m
 # CONFIG_OMFS_FS is not set
@@ -1124,7 +1232,6 @@ CONFIG_LOCKD=y
 CONFIG_LOCKD_V4=y
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=y
-# CONFIG_SUNRPC_REGISTER_V4 is not set
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
 # CONFIG_SMB_FS is not set
@@ -1188,6 +1295,7 @@ CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
 CONFIG_FRAME_WARN=1024
 CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
@@ -1196,6 +1304,9 @@ CONFIG_DEBUG_KERNEL=y
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
 CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
 CONFIG_SCHED_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_TIMER_STATS is not set
@@ -1211,6 +1322,7 @@ CONFIG_SCHED_DEBUG=y
 # CONFIG_LOCK_STAT is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_INFO is not set
@@ -1219,6 +1331,8 @@ CONFIG_DEBUG_BUGVERBOSE=y
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
 CONFIG_FRAME_POINTER=y
 # CONFIG_BOOT_PRINTK_DELAY is not set
 # CONFIG_RCU_TORTURE_TEST is not set
@@ -1226,17 +1340,30 @@ CONFIG_FRAME_POINTER=y
 # CONFIG_KPROBES_SANITY_TEST is not set
 # CONFIG_BACKTRACE_SELF_TEST is not set
 # CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
 # CONFIG_LKDTM is not set
 # CONFIG_FAULT_INJECTION is not set
-
-#
-# Tracers
-#
+# CONFIG_PAGE_POISONING is not set
+CONFIG_NOP_TRACER=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
+CONFIG_TRACING=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
 # CONFIG_IRQSOFF_TRACER is not set
 # CONFIG_SCHED_TRACER is not set
-# CONFIG_CONTEXT_SWITCH_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
 # CONFIG_BOOT_TRACER is not set
-# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 
 #
@@ -1262,10 +1389,12 @@ CONFIG_CRYPTO_HASH=m
 CONFIG_CRYPTO_HASH2=y
 CONFIG_CRYPTO_RNG=m
 CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
 CONFIG_CRYPTO_MANAGER=m
 CONFIG_CRYPTO_MANAGER2=y
 # CONFIG_CRYPTO_GF128MUL is not set
 # CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
 # CONFIG_CRYPTO_CRYPTD is not set
 CONFIG_CRYPTO_AUTHENC=m
 # CONFIG_CRYPTO_TEST is not set
@@ -1293,11 +1422,13 @@ CONFIG_CRYPTO_CBC=m
 #
 CONFIG_CRYPTO_HMAC=m
 # CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
 
 #
 # Digest
 #
 # CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
 # CONFIG_CRYPTO_MD4 is not set
 CONFIG_CRYPTO_MD5=m
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
@@ -1334,6 +1465,7 @@ CONFIG_CRYPTO_DES=m
 # Compression
 #
 CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
 CONFIG_CRYPTO_LZO=y
 
 #
@@ -1341,11 +1473,13 @@ CONFIG_CRYPTO_LZO=y
 #
 CONFIG_CRYPTO_ANSI_CPRNG=m
 # CONFIG_CRYPTO_HW is not set
+CONFIG_BINARY_PRINTF=y
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=y
 CONFIG_CRC_T10DIF=m
@@ -1357,8 +1491,9 @@ CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
 CONFIG_LZO_COMPRESS=y
 CONFIG_LZO_DECOMPRESS=y
+CONFIG_DECOMPRESS_GZIP=y
 CONFIG_GENERIC_ALLOCATOR=y
-CONFIG_PLIST=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
diff --git a/arch/avr32/include/asm/asm-offsets.h b/arch/avr32/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index d5d1d41c600a81e6eea29bd07967fa2412ffce14..3b3159b710d42de528b487bc9758cf04dfb9a7fa 100644 (file)
@@ -77,7 +77,6 @@ typedef struct user_fpu_struct elf_fpregset_t;
 #endif
 #define ELF_ARCH       EM_AVR32
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      4096
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
index 015bc75ea79852cd6bd41d923ac26375ba0e7ba4..9e36e3ff77d2a721eaef286367b0322ea48c2017 100644 (file)
@@ -1,23 +1,6 @@
 #ifndef __ASM_AVR32_HARDIRQ_H
 #define __ASM_AVR32_HARDIRQ_H
-
-#include <linux/threads.h>
-#include <asm/irq.h>
-
 #ifndef __ASSEMBLY__
-
-#include <linux/cache.h>
-
-/* entry.S is sensitive to the offsets of these fields */
-typedef struct {
-       unsigned int __softirq_pending;
-} ____cacheline_aligned irq_cpustat_t;
-
-void ack_bad_irq(unsigned int irq);
-
-/* Standard mappings for irq_cpustat_t above */
-#include <linux/irq_cpustat.h>
-
+#include <asm-generic/hardirq.h>
 #endif /* __ASSEMBLY__ */
-
 #endif /* __ASM_AVR32_HARDIRQ_H */
index 9f572229d3183752e0c602ef9106b94617fd99ea..9604f7758f9a6e84f00779e036c4625073e9fd46 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/sysdev.h>
 
-/*
- * 'what should we do if we get a hw irq event on an illegal vector'.
- * each architecture has to answer this themselves.
- */
-void ack_bad_irq(unsigned int irq)
-{
-       printk("unexpected IRQ %u\n", irq);
-}
-
 /* May be overridden by platform code */
 int __weak nmi_enable(void)
 {
@@ -51,7 +42,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto unlock;
@@ -66,7 +57,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
        unlock:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        }
 
        return 0;
index c4b56654349adbb8fb52fd2f4a12602a3942391c..9cd2bd91d64a613a90b07e148c9e06bda955b9b1 100644 (file)
@@ -39,30 +39,10 @@ SECTIONS
                __tagtable_begin = .;
                        *(.taglist.init)
                __tagtable_end = .;
-                       INIT_DATA
-               . = ALIGN(16);
-               __setup_start = .;
-                       *(.init.setup)
-               __setup_end = .;
-               . = ALIGN(4);
-               __initcall_start = .;
-                       INITCALLS
-               __initcall_end = .;
-               __con_initcall_start = .;
-                       *(.con_initcall.init)
-               __con_initcall_end = .;
-               __security_initcall_start = .;
-                       *(.security_initcall.init)
-               __security_initcall_end = .;
-#ifdef CONFIG_BLK_DEV_INITRD
-               . = ALIGN(32);
-               __initramfs_start = .;
-                       *(.init.ramfs)
-               __initramfs_end = .;
-#endif
-               . = ALIGN(PAGE_SIZE);
-               __init_end = .;
        }
+       INIT_DATA_SECTION(16)
+       . = ALIGN(PAGE_SIZE);
+       __init_end = .;
 
        .text           : AT(ADDR(.text) - LOAD_OFFSET) {
                _evba = .;
@@ -78,34 +58,16 @@ SECTIONS
                _etext = .;
        } = 0xd703d703
 
-       . = ALIGN(4);
-       __ex_table      : AT(ADDR(__ex_table) - LOAD_OFFSET) {
-               __start___ex_table = .;
-               *(__ex_table)
-               __stop___ex_table = .;
-       }
-
+       EXCEPTION_TABLE(4)
        RODATA
 
-       . = ALIGN(THREAD_SIZE);
-
        .data           : AT(ADDR(.data) - LOAD_OFFSET) {
                _data = .;
                _sdata = .;
-               /*
-                * First, the init task union, aligned to an 8K boundary.
-                */
-               *(.data.init_task)
 
-               /* Then, the page-aligned data */
-               . = ALIGN(PAGE_SIZE);
-               *(.data.page_aligned)
-
-               /* Then, the cacheline aligned data */
-               . = ALIGN(L1_CACHE_BYTES);
-               *(.data.cacheline_aligned)
-
-               /* And the rest... */
+               INIT_TASK_DATA(THREAD_SIZE)
+               PAGE_ALIGNED_DATA(PAGE_SIZE);
+               CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
                *(.data.rel*)
                DATA_DATA
                CONSTRUCTORS
@@ -113,16 +75,8 @@ SECTIONS
                _edata = .;
        }
 
-
-       . = ALIGN(8);
-       .bss            : AT(ADDR(.bss) - LOAD_OFFSET) {
-               __bss_start = .;
-               *(.bss)
-               *(COMMON)
-               . = ALIGN(8);
-               __bss_stop = .;
-               _end = .;
-       }
+       BSS_SECTION(0, 8, 8)
+       _end = .;
 
        DWARF_DEBUG
 
index eb9d4dc2e86dff84df6cc0905505d1efb97cfb59..1aa1ea5e92127984428e06747289f3e2f055f1d1 100644 (file)
@@ -15,6 +15,8 @@
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/usb/atmel_usba_udc.h>
+
+#include <mach/atmel-mci.h>
 #include <linux/atmel-mci.h>
 
 #include <asm/io.h>
@@ -1181,19 +1183,32 @@ static struct resource atmel_spi1_resource[] = {
 DEFINE_DEV(atmel_spi, 1);
 DEV_CLK(spi_clk, atmel_spi1, pba, 1);
 
-static void __init
-at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b,
-                     unsigned int n, const u8 *pins)
+void __init
+at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, unsigned int n)
 {
+       /*
+        * Manage the chipselects as GPIOs, normally using the same pins
+        * the SPI controller expects; but boards can use other pins.
+        */
+       static u8 __initdata spi_pins[][4] = {
+               { GPIO_PIN_PA(3), GPIO_PIN_PA(4),
+                 GPIO_PIN_PA(5), GPIO_PIN_PA(20) },
+               { GPIO_PIN_PB(2), GPIO_PIN_PB(3),
+                 GPIO_PIN_PB(4), GPIO_PIN_PA(27) },
+       };
        unsigned int pin, mode;
 
+       /* There are only 2 SPI controllers */
+       if (bus_num > 1)
+               return;
+
        for (; n; n--, b++) {
                b->bus_num = bus_num;
                if (b->chip_select >= 4)
                        continue;
                pin = (unsigned)b->controller_data;
                if (!pin) {
-                       pin = pins[b->chip_select];
+                       pin = spi_pins[bus_num][b->chip_select];
                        b->controller_data = (void *)pin;
                }
                mode = AT32_GPIOF_OUTPUT;
@@ -1206,16 +1221,6 @@ at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b,
 struct platform_device *__init
 at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
 {
-       /*
-        * Manage the chipselects as GPIOs, normally using the same pins
-        * the SPI controller expects; but boards can use other pins.
-        */
-       static u8 __initdata spi0_pins[] =
-               { GPIO_PIN_PA(3), GPIO_PIN_PA(4),
-                 GPIO_PIN_PA(5), GPIO_PIN_PA(20), };
-       static u8 __initdata spi1_pins[] =
-               { GPIO_PIN_PB(2), GPIO_PIN_PB(3),
-                 GPIO_PIN_PB(4), GPIO_PIN_PA(27), };
        struct platform_device *pdev;
        u32 pin_mask;
 
@@ -1228,7 +1233,7 @@ at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
                select_peripheral(PIOA, (1 << 0), PERIPH_A, AT32_GPIOF_PULLUP);
                select_peripheral(PIOA, pin_mask, PERIPH_A, 0);
 
-               at32_spi_setup_slaves(0, b, n, spi0_pins);
+               at32_spi_setup_slaves(0, b, n);
                break;
 
        case 1:
@@ -1239,7 +1244,7 @@ at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n)
                select_peripheral(PIOB, (1 << 0), PERIPH_B, AT32_GPIOF_PULLUP);
                select_peripheral(PIOB, pin_mask, PERIPH_B, 0);
 
-               at32_spi_setup_slaves(1, b, n, spi1_pins);
+               at32_spi_setup_slaves(1, b, n);
                break;
 
        default:
@@ -1320,7 +1325,7 @@ struct platform_device *__init
 at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
 {
        struct platform_device          *pdev;
-       struct dw_dma_slave             *dws = &data->dma_slave;
+       struct mci_dma_slave            *slave;
        u32                             pioa_mask;
        u32                             piob_mask;
 
@@ -1339,13 +1344,17 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
                                ARRAY_SIZE(atmel_mci0_resource)))
                goto fail;
 
-       dws->dma_dev = &dw_dmac0_device.dev;
-       dws->reg_width = DW_DMA_SLAVE_WIDTH_32BIT;
-       dws->cfg_hi = (DWC_CFGH_SRC_PER(0)
+       slave = kzalloc(sizeof(struct mci_dma_slave), GFP_KERNEL);
+
+       slave->sdata.dma_dev = &dw_dmac0_device.dev;
+       slave->sdata.reg_width = DW_DMA_SLAVE_WIDTH_32BIT;
+       slave->sdata.cfg_hi = (DWC_CFGH_SRC_PER(0)
                                | DWC_CFGH_DST_PER(1));
-       dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL
+       slave->sdata.cfg_lo &= ~(DWC_CFGL_HS_DST_POL
                                | DWC_CFGL_HS_SRC_POL);
 
+       data->dma_slave = slave;
+
        if (platform_device_add_data(pdev, data,
                                sizeof(struct mci_platform_data)))
                goto fail;
@@ -1411,6 +1420,8 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
        return pdev;
 
 fail:
+       data->dma_slave = NULL;
+       kfree(slave);
        platform_device_put(pdev);
        return NULL;
 }
diff --git a/arch/avr32/mach-at32ap/include/mach/atmel-mci.h b/arch/avr32/mach-at32ap/include/mach/atmel-mci.h
new file mode 100644 (file)
index 0000000..a9b3896
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __MACH_ATMEL_MCI_H
+#define __MACH_ATMEL_MCI_H
+
+#include <linux/dw_dmac.h>
+
+/**
+ * struct mci_dma_data - DMA data for MCI interface
+ */
+struct mci_dma_data {
+       struct dw_dma_slave     sdata;
+};
+
+/* accessor macros */
+#define        slave_data_ptr(s)       (&(s)->sdata)
+#define find_slave_dev(s)      ((s)->sdata.dma_dev)
+
+#define        setup_dma_addr(s, t, r) do {            \
+       if (s) {                                \
+               (s)->sdata.tx_reg = (t);        \
+               (s)->sdata.rx_reg = (r);        \
+       }                                       \
+} while (0)
+
+#endif /* __MACH_ATMEL_MCI_H */
index ddedb471f33eb34fa3e902a1a3b98f08dd58da08..c7f25bb1d068e0de55c8d2eeeb9ea817d5232328 100644 (file)
@@ -49,6 +49,7 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data);
 struct spi_board_info;
 struct platform_device *
 at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n);
+void at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, unsigned int n);
 
 struct atmel_lcdfb_info;
 struct platform_device *
index ae6a60f101203632f514325b1cf25e8c10ac1ed7..53c1e1d45c684ee7f3d0d7ee7ada40c4be5780a4 100644 (file)
@@ -5,6 +5,10 @@
 
 mainmenu "Blackfin Kernel Configuration"
 
+config SYMBOL_PREFIX
+       string
+       default "_"
+
 config MMU
        def_bool n
 
@@ -28,6 +32,9 @@ config BLACKFIN
        select HAVE_OPROFILE
        select ARCH_WANT_OPTIONAL_GPIOLIB
 
+config GENERIC_CSUM
+       def_bool y
+
 config GENERIC_BUG
        def_bool y
        depends on BUG
@@ -173,7 +180,7 @@ config BF539
        help
          BF539 Processor Support.
 
-config BF542
+config BF542_std
        bool "BF542"
        help
          BF542 Processor Support.
@@ -183,7 +190,7 @@ config BF542M
        help
          BF542 Processor Support.
 
-config BF544
+config BF544_std
        bool "BF544"
        help
          BF544 Processor Support.
@@ -193,7 +200,7 @@ config BF544M
        help
          BF544 Processor Support.
 
-config BF547
+config BF547_std
        bool "BF547"
        help
          BF547 Processor Support.
@@ -203,7 +210,7 @@ config BF547M
        help
          BF547 Processor Support.
 
-config BF548
+config BF548_std
        bool "BF548"
        help
          BF548 Processor Support.
@@ -213,7 +220,7 @@ config BF548M
        help
          BF548 Processor Support.
 
-config BF549
+config BF549_std
        bool "BF549"
        help
          BF549 Processor Support.
@@ -307,31 +314,11 @@ config BF_REV_NONE
 
 endchoice
 
-config BF51x
-       bool
-       depends on (BF512 || BF514 || BF516 || BF518)
-       default y
-
-config BF52x
-       bool
-       depends on (BF522 || BF523 || BF524 || BF525 || BF526 || BF527)
-       default y
-
 config BF53x
        bool
        depends on (BF531 || BF532 || BF533 || BF534 || BF536 || BF537)
        default y
 
-config BF54xM
-       bool
-       depends on (BF542M || BF544M || BF547M || BF548M || BF549M)
-       default y
-
-config BF54x
-       bool
-       depends on (BF542 || BF544 || BF547 || BF548 || BF549 || BF54xM)
-       default y
-
 config MEM_GENERIC_BOARD
        bool
        depends on GENERIC_BOARD
@@ -913,6 +900,12 @@ config DMA_UNCACHED_2M
        bool "Enable 2M DMA region"
 config DMA_UNCACHED_1M
        bool "Enable 1M DMA region"
+config DMA_UNCACHED_512K
+       bool "Enable 512K DMA region"
+config DMA_UNCACHED_256K
+       bool "Enable 256K DMA region"
+config DMA_UNCACHED_128K
+       bool "Enable 128K DMA region"
 config DMA_UNCACHED_NONE
        bool "Disable DMA region"
 endchoice
@@ -1274,6 +1267,8 @@ source "net/Kconfig"
 
 source "drivers/Kconfig"
 
+source "drivers/firmware/Kconfig"
+
 source "fs/Kconfig"
 
 source "arch/blackfin/Kconfig.debug"
index f063b772934bbcf75461276d680feba35c5e1574..d4c7177e765649ec558db90bdc8a0ee1198ebf5b 100644 (file)
@@ -16,6 +16,7 @@ GZFLAGS          := -9
 KBUILD_CFLAGS           += $(call cc-option,-mno-fdpic)
 KBUILD_AFLAGS           += $(call cc-option,-mno-fdpic)
 CFLAGS_MODULE    += -mlong-calls
+LDFLAGS_MODULE   += -m elf32bfin
 KALLSYMS         += --symbol-prefix=_
 
 KBUILD_DEFCONFIG := BF537-STAMP_defconfig
@@ -137,7 +138,7 @@ archclean:
 
 INSTALL_PATH ?= /tftpboot
 boot := arch/$(ARCH)/boot
-BOOT_TARGETS = vmImage vmImage.bz2 vmImage.gz vmImage.lzma
+BOOT_TARGETS = vmImage vmImage.bin vmImage.bz2 vmImage.gz vmImage.lzma
 PHONY += $(BOOT_TARGETS) install
 KBUILD_IMAGE := $(boot)/vmImage
 
@@ -151,6 +152,7 @@ install:
 
 define archhelp
   echo  '* vmImage         - Alias to selected kernel format (vmImage.gz by default)'
+  echo  '  vmImage.bin     - Uncompressed Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.bin)'
   echo  '  vmImage.bz2     - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.bz2)'
   echo  '* vmImage.gz      - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.gz)'
   echo  '  vmImage.lzma    - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage.lzma)'
index fd9ccc5fea105eb24f554a4d3f19fe941cbd62a5..e9c48c6f8c1f5dbc633c26b03df394c7aec5560e 100644 (file)
@@ -8,7 +8,7 @@
 
 MKIMAGE := $(srctree)/scripts/mkuboot.sh
 
-targets := vmImage vmImage.bz2 vmImage.gz vmImage.lzma
+targets := vmImage vmImage.bin vmImage.bz2 vmImage.gz vmImage.lzma
 extra-y += vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma
 
 quiet_cmd_uimage = UIMAGE  $@
@@ -29,6 +29,9 @@ $(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE
 $(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE
        $(call if_changed,lzma)
 
+$(obj)/vmImage.bin: $(obj)/vmlinux.bin
+       $(call if_changed,uimage,none)
+
 $(obj)/vmImage.bz2: $(obj)/vmlinux.bin.bz2
        $(call if_changed,uimage,bzip2)
 
@@ -38,6 +41,7 @@ $(obj)/vmImage.gz: $(obj)/vmlinux.bin.gz
 $(obj)/vmImage.lzma: $(obj)/vmlinux.bin.lzma
        $(call if_changed,uimage,lzma)
 
+suffix-y                      := bin
 suffix-$(CONFIG_KERNEL_GZIP)  := gz
 suffix-$(CONFIG_KERNEL_BZIP2) := bz2
 suffix-$(CONFIG_KERNEL_LZMA)  := lzma
index 9905b26009e52514e83bcfe874fa3ae59d7067f7..e31559419817336aa219d9ecc9154953ad6954f0 100644 (file)
@@ -67,6 +67,7 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -316,6 +317,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=m
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
@@ -438,17 +440,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
-CONFIG_NET_DSA=y
-# CONFIG_NET_DSA_TAG_DSA is not set
-# CONFIG_NET_DSA_TAG_EDSA is not set
-# CONFIG_NET_DSA_TAG_TRAILER is not set
-CONFIG_NET_DSA_TAG_STPID=y
-# CONFIG_NET_DSA_MV88E6XXX is not set
-# CONFIG_NET_DSA_MV88E6060 is not set
-# CONFIG_NET_DSA_MV88E6XXX_NEED_PPU is not set
-# CONFIG_NET_DSA_MV88E6131 is not set
-# CONFIG_NET_DSA_MV88E6123_61_65 is not set
-CONFIG_NET_DSA_KSZ8893M=y
+# CONFIG_NET_DSA is not set
 # CONFIG_VLAN_8021Q is not set
 # CONFIG_DECNET is not set
 # CONFIG_LLC2 is not set
index 9dc682088023c1124eca01ef24d935b30c9f83b2..075e0fdcb3992a182bfda7c100042542fa0701e7 100644 (file)
@@ -67,6 +67,7 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -321,6 +322,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=m
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
index 77e35d4baf535405aef306cd5c46262703457a88..6d1a623fb1498dca5a4760405ae488e44a55be23 100644 (file)
@@ -67,6 +67,7 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -321,6 +322,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=y
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
index 4c044805cb5ca624fd807bdd0e02436c0eda1402..50f9a23ccdbde33d636fcccdd42cb4eeeea1482a 100644 (file)
@@ -67,6 +67,7 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -283,6 +284,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=m
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
index c99bbcd09a683f75f62ea79f5a3e57076dd0d4ca..6c60c8286318f48e24bb16ccc5e0c80a221c66e5 100644 (file)
@@ -67,6 +67,7 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -283,6 +284,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=m
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
index 092ffda80e684882249d891bd42b36a156860544..2908595b67c5ebb6abaa20cbd9f34fe7277707e0 100644 (file)
@@ -67,6 +67,7 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -290,6 +291,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=m
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
@@ -704,10 +706,7 @@ CONFIG_CONFIG_INPUT_PCF8574=m
 #
 # Hardware I/O ports
 #
-CONFIG_SERIO=y
-CONFIG_SERIO_SERPORT=y
-CONFIG_SERIO_LIBPS2=y
-# CONFIG_SERIO_RAW is not set
+# CONFIG_SERIO is not set
 # CONFIG_GAMEPORT is not set
 
 #
index fa698a89f6fefee977f1f8e15485bb141286143e..09ea2499555e1928f63aaa31c5f502f7ae8c0e39 100644 (file)
@@ -67,6 +67,7 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -301,6 +302,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=m
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
index f773ad1155d4b5e06628fa170ccb0747ecff33ed..eb3e98b6f3f076a58a60cc952bc844cb05e7ac3a 100644 (file)
@@ -1,22 +1,29 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.28.10
-# Thu May 21 05:50:01 2009
+# Linux kernel version: 2.6.31.5
+# Mon Nov  2 22:02:56 2009
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_CSUM=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
 
 #
 # General setup
@@ -26,22 +33,40 @@ CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_BZIP2 is not set
+# CONFIG_KERNEL_LZMA is not set
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 # CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SYSCTL=y
 CONFIG_ANON_INODES=y
@@ -62,17 +87,28 @@ CONFIG_EPOLL=y
 # CONFIG_TIMERFD is not set
 # CONFIG_EVENTFD is not set
 # CONFIG_AIO is not set
+
+#
+# Performance Counters
+#
 CONFIG_VM_EVENT_COUNTERS=y
+# CONFIG_STRIP_ASM_SYMS is not set
 CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+# CONFIG_SLOW_WORK is not set
 # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
-CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 # CONFIG_MODULE_FORCE_LOAD is not set
@@ -80,11 +116,8 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
-# CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+# CONFIG_LBDAF is not set
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_BLK_DEV_INTEGRITY is not set
 
@@ -94,13 +127,12 @@ CONFIG_BLOCK=y
 CONFIG_IOSCHED_NOOP=y
 CONFIG_IOSCHED_AS=y
 # CONFIG_IOSCHED_DEADLINE is not set
-CONFIG_IOSCHED_CFQ=y
+# CONFIG_IOSCHED_CFQ is not set
 CONFIG_DEFAULT_AS=y
 # CONFIG_DEFAULT_DEADLINE is not set
 # CONFIG_DEFAULT_CFQ is not set
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="anticipatory"
-CONFIG_CLASSIC_RCU=y
 # CONFIG_PREEMPT_NONE is not set
 CONFIG_PREEMPT_VOLUNTARY=y
 # CONFIG_PREEMPT is not set
@@ -137,7 +169,7 @@ CONFIG_PREEMPT_VOLUNTARY=y
 # CONFIG_BF544M is not set
 # CONFIG_BF547 is not set
 # CONFIG_BF547M is not set
-CONFIG_BF548=y
+CONFIG_BF548_std=y
 # CONFIG_BF548M is not set
 # CONFIG_BF549 is not set
 # CONFIG_BF549M is not set
@@ -195,7 +227,7 @@ CONFIG_BFIN548_EZKIT=y
 #
 # BF548 Specific Configuration
 #
-# CONFIG_DEB_DMA_URGENT is not set
+CONFIG_DEB_DMA_URGENT=y
 # CONFIG_BF548_ATAPI_ALTERNATIVE_PORT is not set
 
 #
@@ -352,10 +384,11 @@ CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=m
 # CONFIG_DMA_UNCACHED_4M is not set
 CONFIG_DMA_UNCACHED_2M=y
@@ -366,14 +399,13 @@ CONFIG_DMA_UNCACHED_2M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
+# CONFIG_BFIN_L2_ICACHEABLE is not set
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
-CONFIG_BFIN_EXTMEM_WRITEBACK=y
-# CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
-# CONFIG_BFIN_L2_ICACHEABLE is not set
+# CONFIG_BFIN_EXTMEM_WRITEBACK is not set
+CONFIG_BFIN_EXTMEM_WRITETHROUGH=y
 # CONFIG_BFIN_L2_DCACHEABLE is not set
 
 #
@@ -382,7 +414,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -441,11 +473,6 @@ CONFIG_NET=y
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-# CONFIG_XFRM_MIGRATE is not set
-# CONFIG_XFRM_STATISTICS is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -469,13 +496,11 @@ CONFIG_IP_PNP=y
 # CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
-CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TCP_MD5SIG is not set
 # CONFIG_IPV6 is not set
-# CONFIG_NETLABEL is not set
 # CONFIG_NETWORK_SECMARK is not set
 # CONFIG_NETFILTER is not set
 # CONFIG_IP_DCCP is not set
@@ -493,7 +518,10 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
@@ -548,14 +576,10 @@ CONFIG_SIR_BFIN_DMA=y
 # CONFIG_MCS_FIR is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
-# CONFIG_PHONET is not set
-CONFIG_WIRELESS=y
-# CONFIG_CFG80211 is not set
-CONFIG_WIRELESS_OLD_REGULATORY=y
+# CONFIG_WIRELESS is not set
 CONFIG_WIRELESS_EXT=y
-CONFIG_WIRELESS_EXT_SYSFS=y
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+CONFIG_LIB80211=m
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -578,6 +602,7 @@ CONFIG_EXTRA_FIRMWARE=""
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
@@ -653,7 +678,6 @@ CONFIG_MTD_NAND=y
 # CONFIG_MTD_NAND_VERIFY_WRITE is not set
 # CONFIG_MTD_NAND_ECC_SMC is not set
 # CONFIG_MTD_NAND_MUSEUM_IDS is not set
-# CONFIG_MTD_NAND_BFIN is not set
 CONFIG_MTD_NAND_IDS=y
 CONFIG_MTD_NAND_BF5XX=y
 CONFIG_MTD_NAND_BF5XX_HWECC=y
@@ -664,6 +688,11 @@ CONFIG_MTD_NAND_BF5XX_HWECC=y
 # CONFIG_MTD_ALAUDA is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -682,10 +711,20 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_ATA_OVER_ETH is not set
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_MISC_DEVICES=y
-# CONFIG_EEPROM_93CX6 is not set
 # CONFIG_ICS932S401 is not set
 # CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_AD525X_DPOT is not set
 # CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
 CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set
 
@@ -709,10 +748,6 @@ CONFIG_BLK_DEV_SR=m
 # CONFIG_BLK_DEV_SR_VENDOR is not set
 # CONFIG_CHR_DEV_SG is not set
 # CONFIG_CHR_DEV_SCH is not set
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
 # CONFIG_SCSI_MULTI_LUN is not set
 # CONFIG_SCSI_CONSTANTS is not set
 # CONFIG_SCSI_LOGGING is not set
@@ -729,6 +764,7 @@ CONFIG_SCSI_WAIT_SCAN=m
 # CONFIG_SCSI_SRP_ATTRS is not set
 # CONFIG_SCSI_LOWLEVEL is not set
 # CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
 CONFIG_ATA=y
 # CONFIG_ATA_NONSTANDARD is not set
 CONFIG_SATA_PMP=y
@@ -744,13 +780,34 @@ CONFIG_NETDEVICES=y
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 # CONFIG_VETH is not set
-# CONFIG_PHYLIB is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=y
 # CONFIG_SMC91X is not set
-CONFIG_SMSC911X=y
 # CONFIG_DM9000 is not set
 # CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+CONFIG_SMSC911X=y
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
@@ -759,6 +816,8 @@ CONFIG_SMSC911X=y
 # CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
 # CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
 
@@ -771,12 +830,15 @@ CONFIG_LIBERTAS=m
 # CONFIG_LIBERTAS_USB is not set
 CONFIG_LIBERTAS_SDIO=m
 CONFIG_POWEROF2_BLOCKSIZE_ONLY=y
+# CONFIG_LIBERTAS_SPI is not set
 # CONFIG_LIBERTAS_DEBUG is not set
 # CONFIG_USB_ZD1201 is not set
-# CONFIG_USB_NET_RNDIS_WLAN is not set
-# CONFIG_IWLWIFI_LEDS is not set
 # CONFIG_HOSTAP is not set
 
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+
 #
 # USB Network Adapters
 #
@@ -813,28 +875,31 @@ CONFIG_INPUT_EVBUG=m
 # Input Device Drivers
 #
 CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADP5588 is not set
 # CONFIG_KEYBOARD_ATKBD is not set
-# CONFIG_KEYBOARD_SUNKBD is not set
+CONFIG_KEYBOARD_BFIN=y
 # CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
-# CONFIG_KEYBOARD_NEWTON is not set
-# CONFIG_KEYBOARD_STOWAWAY is not set
 # CONFIG_KEYBOARD_GPIO is not set
-CONFIG_KEYBOARD_BFIN=y
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_NEWTON is not set
 # CONFIG_KEYBOARD_OPENCORES is not set
-# CONFIG_KEYBOARD_ADP5588 is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TABLET is not set
 CONFIG_INPUT_TOUCHSCREEN=y
+# CONFIG_TOUCHSCREEN_ADS7846 is not set
 CONFIG_TOUCHSCREEN_AD7877=m
 # CONFIG_TOUCHSCREEN_AD7879_I2C is not set
 # CONFIG_TOUCHSCREEN_AD7879_SPI is not set
 # CONFIG_TOUCHSCREEN_AD7879 is not set
-# CONFIG_TOUCHSCREEN_ADS7846 is not set
+# CONFIG_TOUCHSCREEN_EETI is not set
 # CONFIG_TOUCHSCREEN_FUJITSU is not set
 # CONFIG_TOUCHSCREEN_GUNZE is not set
 # CONFIG_TOUCHSCREEN_ELO is not set
+# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
 # CONFIG_TOUCHSCREEN_MTOUCH is not set
 # CONFIG_TOUCHSCREEN_INEXIO is not set
 # CONFIG_TOUCHSCREEN_MK712 is not set
@@ -844,6 +909,8 @@ CONFIG_TOUCHSCREEN_AD7877=m
 # CONFIG_TOUCHSCREEN_WM97XX is not set
 # CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
 # CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
+# CONFIG_TOUCHSCREEN_TSC2007 is not set
+# CONFIG_TOUCHSCREEN_W90X900 is not set
 CONFIG_INPUT_MISC=y
 # CONFIG_INPUT_ATI_REMOTE is not set
 # CONFIG_INPUT_ATI_REMOTE2 is not set
@@ -852,7 +919,11 @@ CONFIG_INPUT_MISC=y
 # CONFIG_INPUT_YEALINK is not set
 # CONFIG_INPUT_CM109 is not set
 # CONFIG_INPUT_UINPUT is not set
-# CONFIG_CONFIG_INPUT_PCF8574 is not set
+# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
+# CONFIG_INPUT_BFIN_ROTARY is not set
+# CONFIG_INPUT_AD714X is not set
+# CONFIG_INPUT_ADXL34X is not set
+# CONFIG_INPUT_PCF8574 is not set
 
 #
 # Hardware I/O ports
@@ -863,16 +934,13 @@ CONFIG_INPUT_MISC=y
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
 CONFIG_BFIN_DMA_INTERFACE=m
 # CONFIG_BFIN_PPI is not set
 # CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
 # CONFIG_BFIN_SPI_ADC is not set
 CONFIG_BFIN_SPORT=m
-# CONFIG_BFIN_TIMER_LATENCY is not set
 # CONFIG_BFIN_TWI_LCD is not set
-CONFIG_SIMPLE_GPIO=m
 CONFIG_VT=y
 CONFIG_CONSOLE_TRANSLATIONS=y
 CONFIG_VT_CONSOLE=y
@@ -890,6 +958,7 @@ CONFIG_BFIN_JTAG_COMM=m
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
 CONFIG_SERIAL_BFIN_DMA=y
@@ -903,6 +972,7 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 CONFIG_BFIN_OTP=y
 # CONFIG_BFIN_OTP_WRITE_ENABLE is not set
@@ -951,14 +1021,9 @@ CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100
 # Miscellaneous I2C Chip support
 #
 # CONFIG_DS1682 is not set
-# CONFIG_EEPROM_AT24 is not set
-# CONFIG_SENSORS_AD5252 is not set
-# CONFIG_EEPROM_LEGACY is not set
 # CONFIG_SENSORS_PCF8574 is not set
 # CONFIG_PCF8575 is not set
 # CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_SENSORS_MAX6875 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
@@ -975,13 +1040,18 @@ CONFIG_SPI_BFIN=y
 # CONFIG_SPI_BFIN_LOCK is not set
 # CONFIG_SPI_BFIN_SPORT is not set
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 # CONFIG_SPI_SPIDEV is not set
 # CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
 CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
 CONFIG_GPIOLIB=y
 # CONFIG_DEBUG_GPIO is not set
@@ -997,6 +1067,7 @@ CONFIG_GPIO_SYSFS=y
 # CONFIG_GPIO_MAX732X is not set
 # CONFIG_GPIO_PCA953X is not set
 # CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_ADP5588 is not set
 
 #
 # PCI GPIO expanders:
@@ -1038,28 +1109,19 @@ CONFIG_SSB_POSSIBLE=y
 # CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
 # CONFIG_HTC_PASIC3 is not set
+# CONFIG_UCB1400_CORE is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TWL4030_CORE is not set
 # CONFIG_MFD_TMIO is not set
 # CONFIG_PMIC_DA903X is not set
 # CONFIG_PMIC_ADP5520 is not set
 # CONFIG_MFD_WM8400 is not set
 # CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
 # CONFIG_REGULATOR is not set
-
-#
-# Multimedia devices
-#
-
-#
-# Multimedia core support
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-# CONFIG_VIDEO_MEDIA is not set
-
-#
-# Multimedia drivers
-#
-# CONFIG_DAB is not set
+# CONFIG_MEDIA_SUPPORT is not set
 
 #
 # Graphics support
@@ -1096,6 +1158,7 @@ CONFIG_FB_BF54X_LQ043=y
 # CONFIG_FB_VIRTUAL is not set
 # CONFIG_FB_METRONOME is not set
 # CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
 # CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
@@ -1132,6 +1195,7 @@ CONFIG_SOUND_OSS_CORE=y
 CONFIG_SND=y
 CONFIG_SND_TIMER=y
 CONFIG_SND_PCM=y
+CONFIG_SND_JACK=y
 # CONFIG_SND_SEQUENCER is not set
 CONFIG_SND_OSSEMUL=y
 CONFIG_SND_MIXER_OSS=y
@@ -1142,6 +1206,11 @@ CONFIG_SND_SUPPORT_OLD_API=y
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
 CONFIG_SND_DRIVERS=y
 # CONFIG_SND_DUMMY is not set
 # CONFIG_SND_MTPAV is not set
@@ -1152,7 +1221,6 @@ CONFIG_SND_SPI=y
 #
 # ALSA Blackfin devices
 #
-# CONFIG_SND_BLACKFIN_AD1836 is not set
 # CONFIG_SND_BFIN_AD73322 is not set
 CONFIG_SND_USB=y
 # CONFIG_SND_USB_AUDIO is not set
@@ -1160,15 +1228,17 @@ CONFIG_SND_USB=y
 CONFIG_SND_SOC=y
 CONFIG_SND_SOC_AC97_BUS=y
 # CONFIG_SND_BF5XX_I2S is not set
+# CONFIG_SND_BF5XX_TDM is not set
 CONFIG_SND_BF5XX_AC97=y
 CONFIG_SND_BF5XX_MMAP_SUPPORT=y
 # CONFIG_SND_BF5XX_MULTICHAN_SUPPORT is not set
+CONFIG_SND_BF5XX_HAVE_COLD_RESET=y
+CONFIG_SND_BF5XX_RESET_GPIO_NUM=19
+CONFIG_SND_BF5XX_SOC_AD1980=y
 CONFIG_SND_BF5XX_SOC_SPORT=y
 CONFIG_SND_BF5XX_SOC_AC97=y
-CONFIG_SND_BF5XX_SOC_AD1980=y
 CONFIG_SND_BF5XX_SPORT_NUM=0
-CONFIG_SND_BF5XX_HAVE_COLD_RESET=y
-CONFIG_SND_BF5XX_RESET_GPIO_NUM=19
+CONFIG_SND_SOC_I2C_AND_SPI=y
 # CONFIG_SND_SOC_ALL_CODECS is not set
 CONFIG_SND_SOC_AD1980=y
 # CONFIG_SOUND_PRIME is not set
@@ -1188,30 +1258,34 @@ CONFIG_USB_HID=y
 #
 # Special HID drivers
 #
-CONFIG_HID_COMPAT=y
 CONFIG_HID_A4TECH=y
 CONFIG_HID_APPLE=y
 CONFIG_HID_BELKIN=y
-CONFIG_HID_BRIGHT=y
 CONFIG_HID_CHERRY=y
 CONFIG_HID_CHICONY=y
 CONFIG_HID_CYPRESS=y
-CONFIG_HID_DELL=y
+# CONFIG_HID_DRAGONRISE is not set
 CONFIG_HID_EZKEY=y
+# CONFIG_HID_KYE is not set
 CONFIG_HID_GYRATION=y
+# CONFIG_HID_KENSINGTON is not set
 CONFIG_HID_LOGITECH=y
 # CONFIG_LOGITECH_FF is not set
 # CONFIG_LOGIRUMBLEPAD2_FF is not set
 CONFIG_HID_MICROSOFT=y
 CONFIG_HID_MONTEREY=y
+# CONFIG_HID_NTRIG is not set
 CONFIG_HID_PANTHERLORD=y
 # CONFIG_PANTHERLORD_FF is not set
 CONFIG_HID_PETALYNX=y
 CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
-CONFIG_THRUSTMASTER_FF=m
-CONFIG_ZEROPLUS_FF=m
+# CONFIG_HID_GREENASIA is not set
+# CONFIG_HID_SMARTJOYPLUS is not set
+# CONFIG_HID_TOPSEED is not set
+# CONFIG_HID_THRUSTMASTER is not set
+# CONFIG_HID_ZEROPLUS is not set
 CONFIG_USB_SUPPORT=y
 CONFIG_USB_ARCH_HAS_HCD=y
 # CONFIG_USB_ARCH_HAS_OHCI is not set
@@ -1237,6 +1311,7 @@ CONFIG_USB_MON=y
 # USB Host Controller Drivers
 #
 # CONFIG_USB_C67X00_HCD is not set
+# CONFIG_USB_OXU210HP_HCD is not set
 # CONFIG_USB_ISP116X_HCD is not set
 # CONFIG_USB_ISP1760_HCD is not set
 # CONFIG_USB_ISP1362_HCD is not set
@@ -1267,18 +1342,17 @@ CONFIG_USB_INVENTRA_DMA=y
 # CONFIG_USB_TMC is not set
 
 #
-# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 
 #
-# see USB_STORAGE Help for more information
+# also be needed; see USB_STORAGE Help for more info
 #
 CONFIG_USB_STORAGE=y
 # CONFIG_USB_STORAGE_DEBUG is not set
 # CONFIG_USB_STORAGE_DATAFAB is not set
 # CONFIG_USB_STORAGE_FREECOM is not set
 # CONFIG_USB_STORAGE_ISD200 is not set
-# CONFIG_USB_STORAGE_DPCM is not set
 # CONFIG_USB_STORAGE_USBAT is not set
 # CONFIG_USB_STORAGE_SDDR09 is not set
 # CONFIG_USB_STORAGE_SDDR55 is not set
@@ -1314,7 +1388,6 @@ CONFIG_USB_STORAGE=y
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYPRESS_CY7C63 is not set
 # CONFIG_USB_CYTHERM is not set
-# CONFIG_USB_PHIDGET is not set
 # CONFIG_USB_IDMOUSE is not set
 # CONFIG_USB_FTDI_ELAN is not set
 # CONFIG_USB_APPLEDISPLAY is not set
@@ -1326,6 +1399,13 @@ CONFIG_USB_STORAGE=y
 # CONFIG_USB_ISIGHTFW is not set
 # CONFIG_USB_VST is not set
 # CONFIG_USB_GADGET is not set
+
+#
+# OTG and related infrastructure
+#
+CONFIG_USB_OTG_UTILS=y
+# CONFIG_USB_GPIO_VBUS is not set
+CONFIG_NOP_USB_XCEIV=y
 CONFIG_MMC=y
 # CONFIG_MMC_DEBUG is not set
 # CONFIG_MMC_UNSAFE_RESUME is not set
@@ -1380,6 +1460,7 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_S35390A is not set
 # CONFIG_RTC_DRV_FM3130 is not set
 # CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
 
 #
 # SPI RTC drivers
@@ -1411,9 +1492,20 @@ CONFIG_RTC_INTF_DEV=y
 #
 CONFIG_RTC_DRV_BFIN=y
 # CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
 # CONFIG_STAGING is not set
 
+#
+# Firmware Drivers
+#
+# CONFIG_FIRMWARE_MEMMAP is not set
+# CONFIG_SIGMA is not set
+
 #
 # File systems
 #
@@ -1427,9 +1519,11 @@ CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
-CONFIG_FILE_LOCKING=y
 # CONFIG_XFS_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -1438,6 +1532,11 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
@@ -1467,10 +1566,7 @@ CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -1489,17 +1585,8 @@ CONFIG_JFFS2_ZLIB=y
 # CONFIG_JFFS2_LZO is not set
 CONFIG_JFFS2_RTIME=y
 # CONFIG_JFFS2_RUBIN is not set
-CONFIG_YAFFS_FS=m
-CONFIG_YAFFS_YAFFS1=y
-# CONFIG_YAFFS_9BYTE_TAGS is not set
-# CONFIG_YAFFS_DOES_ECC is not set
-CONFIG_YAFFS_YAFFS2=y
-CONFIG_YAFFS_AUTO_YAFFS2=y
-# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set
-# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set
-# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set
-CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_OMFS_FS is not set
@@ -1508,6 +1595,7 @@ CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
 # CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
+# CONFIG_NILFS2_FS is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=m
 CONFIG_NFS_V3=y
@@ -1522,7 +1610,6 @@ CONFIG_LOCKD_V4=y
 CONFIG_EXPORTFS=m
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=m
-# CONFIG_SUNRPC_REGISTER_V4 is not set
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
@@ -1596,11 +1683,15 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
 CONFIG_DEBUG_KERNEL=y
 CONFIG_DEBUG_SHIRQ=y
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
 CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
 CONFIG_SCHED_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_TIMER_STATS is not set
@@ -1608,16 +1699,21 @@ CONFIG_SCHED_DEBUG=y
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_NOMMU_REGIONS is not set
 # CONFIG_DEBUG_WRITECOUNT is not set
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
 # CONFIG_FRAME_POINTER is not set
 # CONFIG_BOOT_PRINTK_DELAY is not set
 # CONFIG_RCU_TORTURE_TEST is not set
@@ -1625,17 +1721,16 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_BACKTRACE_SELF_TEST is not set
 # CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
 # CONFIG_FAULT_INJECTION is not set
-
-#
-# Tracers
-#
-# CONFIG_SCHED_TRACER is not set
-# CONFIG_CONTEXT_SWITCH_TRACER is not set
-# CONFIG_BOOT_TRACER is not set
-# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+# CONFIG_FTRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
 # CONFIG_KGDB is not set
+# CONFIG_KMEMCHECK is not set
 # CONFIG_DEBUG_STACKOVERFLOW is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 CONFIG_DEBUG_VERBOSE=y
@@ -1657,17 +1752,15 @@ CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE=y
 CONFIG_EARLY_PRINTK=y
 CONFIG_CPLB_INFO=y
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
 #
 # CONFIG_KEYS is not set
-CONFIG_SECURITY=y
+# CONFIG_SECURITY is not set
 # CONFIG_SECURITYFS is not set
-# CONFIG_SECURITY_NETWORK is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
-# CONFIG_SECURITY_ROOTPLUG is not set
-CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
 CONFIG_CRYPTO=y
 
 #
@@ -1746,6 +1839,7 @@ CONFIG_CRYPTO=y
 # Compression
 #
 # CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
 # CONFIG_CRYPTO_LZO is not set
 
 #
@@ -1753,11 +1847,13 @@ CONFIG_CRYPTO=y
 #
 # CONFIG_CRYPTO_ANSI_CPRNG is not set
 CONFIG_CRYPTO_HW=y
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
 # CONFIG_CRC_T10DIF is not set
@@ -1767,6 +1863,8 @@ CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=m
+CONFIG_DECOMPRESS_GZIP=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
diff --git a/arch/blackfin/configs/BF561-ACVILON_defconfig b/arch/blackfin/configs/BF561-ACVILON_defconfig
new file mode 100644 (file)
index 0000000..b9b0f93
--- /dev/null
@@ -0,0 +1,1643 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.31.4
+# Sat Oct 24 12:15:32 2009
+#
+# CONFIG_MMU is not set
+# CONFIG_FPU is not set
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+CONFIG_BLACKFIN=y
+CONFIG_GENERIC_CSUM=y
+CONFIG_GENERIC_BUG=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_FORCE_MAX_ZONEORDER=14
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_BZIP2 is not set
+# CONFIG_KERNEL_LZMA is not set
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_RELAY is not set
+# CONFIG_NAMESPACES is not set
+# CONFIG_BLK_DEV_INITRD is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+CONFIG_UID16=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+# CONFIG_ELF_CORE is not set
+CONFIG_BASE_FULL=y
+# CONFIG_FUTEX is not set
+CONFIG_EPOLL=y
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_AIO is not set
+
+#
+# Performance Counters
+#
+CONFIG_VM_EVENT_COUNTERS=y
+# CONFIG_STRIP_ASM_SYMS is not set
+CONFIG_COMPAT_BRK=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_MMAP_ALLOW_UNINITIALIZED is not set
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+CONFIG_HAVE_OPROFILE=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+# CONFIG_SLOW_WORK is not set
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_BLOCK=y
+CONFIG_LBDAF=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+# CONFIG_IOSCHED_DEADLINE is not set
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+# CONFIG_FREEZER is not set
+
+#
+# Blackfin Processor Options
+#
+
+#
+# Processor and Board Settings
+#
+# CONFIG_BF512 is not set
+# CONFIG_BF514 is not set
+# CONFIG_BF516 is not set
+# CONFIG_BF518 is not set
+# CONFIG_BF522 is not set
+# CONFIG_BF523 is not set
+# CONFIG_BF524 is not set
+# CONFIG_BF525 is not set
+# CONFIG_BF526 is not set
+# CONFIG_BF527 is not set
+# CONFIG_BF531 is not set
+# CONFIG_BF532 is not set
+# CONFIG_BF533 is not set
+# CONFIG_BF534 is not set
+# CONFIG_BF536 is not set
+# CONFIG_BF537 is not set
+# CONFIG_BF538 is not set
+# CONFIG_BF539 is not set
+# CONFIG_BF542 is not set
+# CONFIG_BF542M is not set
+# CONFIG_BF544 is not set
+# CONFIG_BF544M is not set
+# CONFIG_BF547 is not set
+# CONFIG_BF547M is not set
+# CONFIG_BF548 is not set
+# CONFIG_BF548M is not set
+# CONFIG_BF549 is not set
+# CONFIG_BF549M is not set
+CONFIG_BF561=y
+# CONFIG_SMP is not set
+CONFIG_BF_REV_MIN=3
+CONFIG_BF_REV_MAX=5
+# CONFIG_BF_REV_0_0 is not set
+# CONFIG_BF_REV_0_1 is not set
+# CONFIG_BF_REV_0_2 is not set
+# CONFIG_BF_REV_0_3 is not set
+# CONFIG_BF_REV_0_4 is not set
+CONFIG_BF_REV_0_5=y
+# CONFIG_BF_REV_0_6 is not set
+# CONFIG_BF_REV_ANY is not set
+# CONFIG_BF_REV_NONE is not set
+CONFIG_IRQ_PLL_WAKEUP=7
+CONFIG_IRQ_SPORT0_ERROR=7
+CONFIG_IRQ_SPORT1_ERROR=7
+CONFIG_IRQ_TIMER0=10
+CONFIG_IRQ_TIMER1=10
+CONFIG_IRQ_TIMER2=10
+CONFIG_IRQ_TIMER3=10
+CONFIG_IRQ_TIMER4=10
+CONFIG_IRQ_TIMER5=10
+CONFIG_IRQ_TIMER6=10
+CONFIG_IRQ_TIMER7=10
+CONFIG_IRQ_SPI_ERROR=7
+# CONFIG_BFIN561_EZKIT is not set
+# CONFIG_BFIN561_TEPLA is not set
+# CONFIG_BFIN561_BLUETECHNIX_CM is not set
+CONFIG_BFIN561_ACVILON=y
+
+#
+# BF561 Specific Configuration
+#
+
+#
+# Core B Support
+#
+# CONFIG_BF561_COREB is not set
+
+#
+# Interrupt Priority Assignment
+#
+
+#
+# Priority
+#
+CONFIG_IRQ_DMA1_ERROR=7
+CONFIG_IRQ_DMA2_ERROR=7
+CONFIG_IRQ_IMDMA_ERROR=7
+CONFIG_IRQ_PPI0_ERROR=7
+CONFIG_IRQ_PPI1_ERROR=7
+CONFIG_IRQ_UART_ERROR=7
+CONFIG_IRQ_RESERVED_ERROR=7
+CONFIG_IRQ_DMA1_0=8
+CONFIG_IRQ_DMA1_1=8
+CONFIG_IRQ_DMA1_2=8
+CONFIG_IRQ_DMA1_3=8
+CONFIG_IRQ_DMA1_4=8
+CONFIG_IRQ_DMA1_5=8
+CONFIG_IRQ_DMA1_6=8
+CONFIG_IRQ_DMA1_7=8
+CONFIG_IRQ_DMA1_8=8
+CONFIG_IRQ_DMA1_9=8
+CONFIG_IRQ_DMA1_10=8
+CONFIG_IRQ_DMA1_11=8
+CONFIG_IRQ_DMA2_0=9
+CONFIG_IRQ_DMA2_1=9
+CONFIG_IRQ_DMA2_2=9
+CONFIG_IRQ_DMA2_3=9
+CONFIG_IRQ_DMA2_4=9
+CONFIG_IRQ_DMA2_5=9
+CONFIG_IRQ_DMA2_6=9
+CONFIG_IRQ_DMA2_7=9
+CONFIG_IRQ_DMA2_8=9
+CONFIG_IRQ_DMA2_9=9
+CONFIG_IRQ_DMA2_10=9
+CONFIG_IRQ_DMA2_11=9
+CONFIG_IRQ_TIMER8=10
+CONFIG_IRQ_TIMER9=10
+CONFIG_IRQ_TIMER10=10
+CONFIG_IRQ_TIMER11=10
+CONFIG_IRQ_PROG0_INTA=11
+CONFIG_IRQ_PROG0_INTB=11
+CONFIG_IRQ_PROG1_INTA=11
+CONFIG_IRQ_PROG1_INTB=11
+CONFIG_IRQ_PROG2_INTA=11
+CONFIG_IRQ_PROG2_INTB=11
+CONFIG_IRQ_DMA1_WRRD0=8
+CONFIG_IRQ_DMA1_WRRD1=8
+CONFIG_IRQ_DMA2_WRRD0=9
+CONFIG_IRQ_DMA2_WRRD1=9
+CONFIG_IRQ_IMDMA_WRRD0=12
+CONFIG_IRQ_IMDMA_WRRD1=12
+CONFIG_IRQ_WDTIMER=13
+
+#
+# Board customizations
+#
+# CONFIG_CMDLINE_BOOL is not set
+CONFIG_BOOT_LOAD=0x1000
+
+#
+# Clock/PLL Setup
+#
+CONFIG_CLKIN_HZ=12000000
+# CONFIG_BFIN_KERNEL_CLOCK is not set
+CONFIG_MAX_VCO_HZ=600000000
+CONFIG_MIN_VCO_HZ=50000000
+CONFIG_MAX_SCLK_HZ=133333333
+CONFIG_MIN_SCLK_HZ=27000000
+
+#
+# Kernel Timer/Scheduler
+#
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_TICKSOURCE_GPTMR0 is not set
+CONFIG_TICKSOURCE_CORETMR=y
+CONFIG_CYCLES_CLOCKSOURCE=y
+# CONFIG_GPTMR0_CLOCKSOURCE is not set
+CONFIG_TICK_ONESHOT=y
+# CONFIG_NO_HZ is not set
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+
+#
+# Misc
+#
+CONFIG_BFIN_SCRATCH_REG_RETN=y
+# CONFIG_BFIN_SCRATCH_REG_RETE is not set
+# CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
+
+#
+# Blackfin Kernel Optimizations
+#
+
+#
+# Memory Optimizations
+#
+CONFIG_I_ENTRY_L1=y
+CONFIG_EXCPT_IRQ_SYSC_L1=y
+CONFIG_DO_IRQ_L1=y
+CONFIG_CORE_TIMER_IRQ_L1=y
+CONFIG_IDLE_L1=y
+CONFIG_SCHEDULE_L1=y
+CONFIG_ARITHMETIC_OPS_L1=y
+CONFIG_ACCESS_OK_L1=y
+CONFIG_MEMSET_L1=y
+CONFIG_MEMCPY_L1=y
+CONFIG_SYS_BFIN_SPINLOCK_L1=y
+# CONFIG_IP_CHECKSUM_L1 is not set
+CONFIG_CACHELINE_ALIGNED_L1=y
+# CONFIG_SYSCALL_TAB_L1 is not set
+# CONFIG_CPLB_SWITCH_TAB_L1 is not set
+CONFIG_APP_STACK_L1=y
+
+#
+# Speed Optimizations
+#
+CONFIG_BFIN_INS_LOWOVERHEAD=y
+CONFIG_RAMKERNEL=y
+# CONFIG_ROMKERNEL is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_VIRT_TO_BUS=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
+CONFIG_BFIN_GPTIMERS=y
+CONFIG_DMA_UNCACHED_4M=y
+# CONFIG_DMA_UNCACHED_2M is not set
+# CONFIG_DMA_UNCACHED_1M is not set
+# CONFIG_DMA_UNCACHED_NONE is not set
+
+#
+# Cache Support
+#
+CONFIG_BFIN_ICACHE=y
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
+# CONFIG_BFIN_L2_ICACHEABLE is not set
+CONFIG_BFIN_DCACHE=y
+# CONFIG_BFIN_DCACHE_BANKA is not set
+CONFIG_BFIN_EXTMEM_DCACHEABLE=y
+CONFIG_BFIN_EXTMEM_WRITEBACK=y
+# CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
+# CONFIG_BFIN_L2_DCACHEABLE is not set
+
+#
+# Memory Protection Unit
+#
+# CONFIG_MPU is not set
+
+#
+# Asynchronous Memory Configuration
+#
+
+#
+# EBIU_AMGCTL Global Control
+#
+CONFIG_C_AMCKEN=y
+CONFIG_C_CDPRIO=y
+CONFIG_C_B0PEN=y
+CONFIG_C_B1PEN=y
+CONFIG_C_B2PEN=y
+# CONFIG_C_B3PEN is not set
+# CONFIG_C_AMBEN is not set
+# CONFIG_C_AMBEN_B0 is not set
+# CONFIG_C_AMBEN_B0_B1 is not set
+# CONFIG_C_AMBEN_B0_B1_B2 is not set
+CONFIG_C_AMBEN_ALL=y
+
+#
+# EBIU_AMBCTL Control
+#
+CONFIG_BANK_0=0x99b2
+CONFIG_BANK_1=0x3350
+CONFIG_BANK_2=0x7BB0
+CONFIG_BANK_3=0xAAC2
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF_FDPIC=y
+CONFIG_BINFMT_FLAT=y
+CONFIG_BINFMT_ZFLAT=y
+# CONFIG_BINFMT_SHARED_FLAT is not set
+# CONFIG_HAVE_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+
+#
+# Power management options
+#
+# CONFIG_PM is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+
+#
+# CPU Frequency scaling
+#
+# CONFIG_CPU_FREQ is not set
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+# CONFIG_INET_LRO is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETLABEL is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_RAM=y
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_UCLINUX is not set
+CONFIG_MTD_PLATRAM=y
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+# CONFIG_MTD_SLRAM is not set
+CONFIG_MTD_PHRAM=y
+# CONFIG_MTD_MTDRAM is not set
+CONFIG_MTD_BLOCK2MTD=y
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_VERIFY_WRITE=y
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+CONFIG_MTD_NAND_PLATFORM=y
+# CONFIG_MTD_ALAUDA is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
+#
+# UBI - Unsorted block images
+#
+# CONFIG_MTD_UBI is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=2
+CONFIG_BLK_DEV_RAM_SIZE=16384
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_BLK_DEV_HD is not set
+# CONFIG_MISC_DEVICES is not set
+CONFIG_HAVE_IDE=y
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_TGT is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_SCSI_PROC_FS is not set
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=y
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_SMC91X is not set
+# CONFIG_DM9000 is not set
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+CONFIG_SMSC911X=y
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+
+#
+# Wireless LAN
+#
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+# CONFIG_INPUT is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+# CONFIG_BFIN_DMA_INTERFACE is not set
+# CONFIG_BFIN_PPI is not set
+# CONFIG_BFIN_PPIFCD is not set
+CONFIG_BFIN_SIMPLE_TIMER=y
+# CONFIG_BFIN_SPI_ADC is not set
+# CONFIG_BFIN_SPORT is not set
+# CONFIG_BFIN_TWI_LCD is not set
+# CONFIG_VT is not set
+# CONFIG_DEVKMEM is not set
+# CONFIG_BFIN_JTAG_COMM is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_MAX3100 is not set
+CONFIG_SERIAL_BFIN=y
+CONFIG_SERIAL_BFIN_CONSOLE=y
+# CONFIG_SERIAL_BFIN_DMA is not set
+CONFIG_SERIAL_BFIN_PIO=y
+CONFIG_SERIAL_BFIN_UART0=y
+# CONFIG_BFIN_UART0_CTSRTS is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_BFIN_SPORT is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# CAN, the car bus and industrial fieldbus
+#
+# CONFIG_CAN4LINUX is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOPCA=y
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_GPIO is not set
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_TAOS_EVM is not set
+# CONFIG_I2C_TINY_USB is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+CONFIG_I2C_PCA_PLATFORM=y
+# CONFIG_I2C_STUB is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_DS1682 is not set
+# CONFIG_SENSORS_PCA9539 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BFIN=y
+# CONFIG_SPI_BFIN_LOCK is not set
+# CONFIG_SPI_BFIN_SPORT is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_SPIDEV=y
+# CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# Memory mapped GPIO expanders:
+#
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+CONFIG_GPIO_PCF857X=y
+# CONFIG_GPIO_ADP5588 is not set
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_AD7414 is not set
+# CONFIG_SENSORS_AD7418 is not set
+# CONFIG_SENSORS_ADCXX is not set
+# CONFIG_SENSORS_ADM1021 is not set
+# CONFIG_SENSORS_ADM1025 is not set
+# CONFIG_SENSORS_ADM1026 is not set
+# CONFIG_SENSORS_ADM1029 is not set
+# CONFIG_SENSORS_ADM1031 is not set
+# CONFIG_SENSORS_ADM9240 is not set
+# CONFIG_SENSORS_ADT7462 is not set
+# CONFIG_SENSORS_ADT7470 is not set
+# CONFIG_SENSORS_ADT7473 is not set
+# CONFIG_SENSORS_ADT7475 is not set
+# CONFIG_SENSORS_ATXP1 is not set
+# CONFIG_SENSORS_DS1621 is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_F71882FG is not set
+# CONFIG_SENSORS_F75375S is not set
+# CONFIG_SENSORS_G760A is not set
+# CONFIG_SENSORS_GL518SM is not set
+# CONFIG_SENSORS_GL520SM is not set
+# CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM63 is not set
+# CONFIG_SENSORS_LM70 is not set
+CONFIG_SENSORS_LM75=y
+# CONFIG_SENSORS_LM77 is not set
+# CONFIG_SENSORS_LM78 is not set
+# CONFIG_SENSORS_LM80 is not set
+# CONFIG_SENSORS_LM83 is not set
+# CONFIG_SENSORS_LM85 is not set
+# CONFIG_SENSORS_LM87 is not set
+# CONFIG_SENSORS_LM90 is not set
+# CONFIG_SENSORS_LM92 is not set
+# CONFIG_SENSORS_LM93 is not set
+# CONFIG_SENSORS_LTC4215 is not set
+# CONFIG_SENSORS_LTC4245 is not set
+# CONFIG_SENSORS_LM95241 is not set
+# CONFIG_SENSORS_MAX1111 is not set
+# CONFIG_SENSORS_MAX1619 is not set
+# CONFIG_SENSORS_MAX6650 is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_PC87427 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_SENSORS_SHT15 is not set
+# CONFIG_SENSORS_DME1737 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_SMSC47M192 is not set
+# CONFIG_SENSORS_SMSC47B397 is not set
+# CONFIG_SENSORS_ADS7828 is not set
+# CONFIG_SENSORS_THMC50 is not set
+# CONFIG_SENSORS_TMP401 is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_SENSORS_W83781D is not set
+# CONFIG_SENSORS_W83791D is not set
+# CONFIG_SENSORS_W83792D is not set
+# CONFIG_SENSORS_W83793 is not set
+# CONFIG_SENSORS_W83L785TS is not set
+# CONFIG_SENSORS_W83L786NG is not set
+# CONFIG_SENSORS_W83627HF is not set
+# CONFIG_SENSORS_W83627EHF is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
+# CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+# CONFIG_SOFT_WATCHDOG is not set
+CONFIG_BFIN_WDT=y
+
+#
+# USB-based Watchdog Cards
+#
+# CONFIG_USBPCWATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_EZX_PCAP is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+# CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+CONFIG_SOUND=y
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+# CONFIG_SND_SEQUENCER is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=y
+CONFIG_SND_PCM_OSS=y
+CONFIG_SND_PCM_OSS_PLUGINS=y
+# CONFIG_SND_HRTIMER is not set
+# CONFIG_SND_DYNAMIC_MINORS is not set
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+# CONFIG_SND_DRIVERS is not set
+CONFIG_SND_SPI=y
+
+#
+# ALSA Blackfin devices
+#
+# CONFIG_SND_BFIN_AD73322 is not set
+# CONFIG_SND_USB is not set
+CONFIG_SND_SOC=y
+CONFIG_SND_BF5XX_I2S=y
+# CONFIG_SND_BF5XX_SOC_SSM2602 is not set
+# CONFIG_SND_BF5XX_SOC_AD73311 is not set
+# CONFIG_SND_BF5XX_SOC_ADAU1371 is not set
+# CONFIG_SND_BF5XX_SOC_ADAU1761 is not set
+# CONFIG_SND_BF5XX_TDM is not set
+# CONFIG_SND_BF5XX_AC97 is not set
+CONFIG_SND_BF5XX_SOC_SPORT=y
+CONFIG_SND_BF5XX_SPORT_NUM=1
+CONFIG_SND_SOC_I2C_AND_SPI=y
+# CONFIG_SND_SOC_ALL_CODECS is not set
+# CONFIG_SOUND_PRIME is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+# CONFIG_USB_DEVICEFS is not set
+# CONFIG_USB_DEVICE_CLASS is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+CONFIG_USB_MON=y
+# CONFIG_USB_WUSB is not set
+# CONFIG_USB_WUSB_CBAF is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_C67X00_HCD is not set
+# CONFIG_USB_OXU210HP_HCD is not set
+# CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_ISP1760_HCD is not set
+# CONFIG_USB_ISP1362_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+# CONFIG_USB_R8A66597_HCD is not set
+# CONFIG_USB_HWA_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+# CONFIG_USB_WDM is not set
+# CONFIG_USB_TMC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+
+#
+# also be needed; see USB_STORAGE Help for more info
+#
+CONFIG_USB_STORAGE=y
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB port drivers
+#
+CONFIG_USB_SERIAL=y
+# CONFIG_USB_SERIAL_CONSOLE is not set
+# CONFIG_USB_EZUSB is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_AIRCABLE is not set
+# CONFIG_USB_SERIAL_ARK3116 is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_CH341 is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_CP210X is not set
+# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+CONFIG_USB_SERIAL_FTDI_SIO=y
+# CONFIG_USB_SERIAL_FUNSOFT is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_IPAQ is not set
+# CONFIG_USB_SERIAL_IR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
+# CONFIG_USB_SERIAL_GARMIN is not set
+# CONFIG_USB_SERIAL_IPW is not set
+# CONFIG_USB_SERIAL_IUU is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KLSI is not set
+# CONFIG_USB_SERIAL_KOBIL_SCT is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_MOS7720 is not set
+# CONFIG_USB_SERIAL_MOS7840 is not set
+# CONFIG_USB_SERIAL_MOTOROLA is not set
+# CONFIG_USB_SERIAL_NAVMAN is not set
+CONFIG_USB_SERIAL_PL2303=y
+# CONFIG_USB_SERIAL_OTI6858 is not set
+# CONFIG_USB_SERIAL_QUALCOMM is not set
+# CONFIG_USB_SERIAL_SPCP8X5 is not set
+# CONFIG_USB_SERIAL_HP4X is not set
+# CONFIG_USB_SERIAL_SAFE is not set
+# CONFIG_USB_SERIAL_SIEMENS_MPI is not set
+# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
+# CONFIG_USB_SERIAL_SYMBOL is not set
+# CONFIG_USB_SERIAL_TI is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_XIRCOM is not set
+# CONFIG_USB_SERIAL_OPTION is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+# CONFIG_USB_SERIAL_OPTICON is not set
+# CONFIG_USB_SERIAL_DEBUG is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_SEVSEG is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_BERRY_CHARGE is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_ISIGHTFW is not set
+# CONFIG_USB_VST is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+CONFIG_RTC_DRV_DS1307=y
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
+
+#
+# SPI RTC drivers
+#
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
+# CONFIG_RTC_DRV_MAX6902 is not set
+# CONFIG_RTC_DRV_R9701 is not set
+# CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
+#
+# Firmware Drivers
+#
+# CONFIG_FIRMWARE_MEMMAP is not set
+# CONFIG_SIGMA is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+# CONFIG_EXT3_FS is not set
+# CONFIG_EXT4_FS is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+# CONFIG_DNOTIFY is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=866
+CONFIG_FAT_DEFAULT_IOCHARSET="cp1251"
+CONFIG_NTFS_FS=y
+# CONFIG_NTFS_DEBUG is not set
+# CONFIG_NTFS_RW is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+# CONFIG_TMPFS is not set
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_CONFIGFS_FS=y
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+# CONFIG_JFFS2_ZLIB is not set
+CONFIG_JFFS2_LZO=y
+# CONFIG_JFFS2_RTIME is not set
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+# CONFIG_JFFS2_CMODE_PRIORITY is not set
+# CONFIG_JFFS2_CMODE_SIZE is not set
+CONFIG_JFFS2_CMODE_FAVOURLZO=y
+CONFIG_CRAMFS=y
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+CONFIG_MINIX_FS=y
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="cp1251"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+CONFIG_NLS_CODEPAGE_866=y
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+CONFIG_NLS_CODEPAGE_1251=y
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+CONFIG_NLS_KOI8_R=y
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=y
+# CONFIG_DLM is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_DEBUG_SHIRQ=y
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
+CONFIG_SCHED_DEBUG=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_NOMMU_REGIONS is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_KMEMCHECK is not set
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+CONFIG_DEBUG_VERBOSE=y
+CONFIG_DEBUG_MMRS=y
+# CONFIG_DEBUG_HWERR is not set
+# CONFIG_DEBUG_DOUBLEFAULT is not set
+CONFIG_DEBUG_HUNT_FOR_ZERO=y
+CONFIG_DEBUG_BFIN_HWTRACE_ON=y
+CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
+# CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_ONE is not set
+# CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_TWO is not set
+CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
+# CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
+# CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
+# CONFIG_EARLY_PRINTK is not set
+CONFIG_CPLB_INFO=y
+CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+CONFIG_SECURITY=y
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_NETWORK is not set
+# CONFIG_SECURITY_PATH is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+# CONFIG_SECURITY_ROOTPLUG is not set
+# CONFIG_SECURITY_TOMOYO is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
+# CONFIG_CRYPTO_MANAGER is not set
+# CONFIG_CRYPTO_MANAGER2 is not set
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_CRYPTD is not set
+# CONFIG_CRYPTO_AUTHENC is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+# CONFIG_CRYPTO_CBC is not set
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+# CONFIG_CRYPTO_ECB is not set
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_XCBC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_MD4 is not set
+# CONFIG_CRYPTO_MD5 is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+CONFIG_CRYPTO_HW=y
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index 0313cd1d9824d5bc2a07810fd6707b2adb624647..e3ecdcc3e76b9079eb60bce9107f5912720cd6d6 100644 (file)
@@ -1,22 +1,29 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.28.10
-# Thu May 21 05:50:01 2009
+# Linux kernel version: 2.6.31.5
+# Mon Nov  2 21:59:31 2009
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_CSUM=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
 
 #
 # General setup
@@ -26,22 +33,40 @@ CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_BZIP2 is not set
+# CONFIG_KERNEL_LZMA is not set
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 # CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SYSCTL=y
 CONFIG_ANON_INODES=y
@@ -62,17 +87,28 @@ CONFIG_EPOLL=y
 # CONFIG_TIMERFD is not set
 # CONFIG_EVENTFD is not set
 # CONFIG_AIO is not set
+
+#
+# Performance Counters
+#
 CONFIG_VM_EVENT_COUNTERS=y
+# CONFIG_STRIP_ASM_SYMS is not set
 CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+# CONFIG_SLOW_WORK is not set
 # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
-CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 # CONFIG_MODULE_FORCE_LOAD is not set
@@ -80,11 +116,8 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
-# CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+# CONFIG_LBDAF is not set
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_BLK_DEV_INTEGRITY is not set
 
@@ -94,13 +127,12 @@ CONFIG_BLOCK=y
 CONFIG_IOSCHED_NOOP=y
 CONFIG_IOSCHED_AS=y
 # CONFIG_IOSCHED_DEADLINE is not set
-CONFIG_IOSCHED_CFQ=y
+# CONFIG_IOSCHED_CFQ is not set
 CONFIG_DEFAULT_AS=y
 # CONFIG_DEFAULT_DEADLINE is not set
 # CONFIG_DEFAULT_CFQ is not set
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="anticipatory"
-CONFIG_CLASSIC_RCU=y
 # CONFIG_PREEMPT_NONE is not set
 CONFIG_PREEMPT_VOLUNTARY=y
 # CONFIG_PREEMPT is not set
@@ -170,6 +202,7 @@ CONFIG_IRQ_SPI_ERROR=7
 CONFIG_BFIN561_EZKIT=y
 # CONFIG_BFIN561_TEPLA is not set
 # CONFIG_BFIN561_BLUETECHNIX_CM is not set
+# CONFIG_BFIN561_ACVILON is not set
 
 #
 # BF561 Specific Configuration
@@ -317,10 +350,11 @@ CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=m
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
@@ -331,14 +365,13 @@ CONFIG_DMA_UNCACHED_1M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
+# CONFIG_BFIN_L2_ICACHEABLE is not set
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
 CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
-# CONFIG_BFIN_L2_ICACHEABLE is not set
 # CONFIG_BFIN_L2_DCACHEABLE is not set
 
 #
@@ -347,7 +380,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -407,11 +440,6 @@ CONFIG_NET=y
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-# CONFIG_XFRM_MIGRATE is not set
-# CONFIG_XFRM_STATISTICS is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -435,13 +463,11 @@ CONFIG_IP_PNP=y
 # CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
-CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TCP_MD5SIG is not set
 # CONFIG_IPV6 is not set
-# CONFIG_NETLABEL is not set
 # CONFIG_NETWORK_SECMARK is not set
 # CONFIG_NETFILTER is not set
 # CONFIG_IP_DCCP is not set
@@ -459,7 +485,10 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
@@ -503,13 +532,8 @@ CONFIG_IRTTY_SIR=m
 #
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
-# CONFIG_PHONET is not set
-CONFIG_WIRELESS=y
-# CONFIG_CFG80211 is not set
-CONFIG_WIRELESS_OLD_REGULATORY=y
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -530,6 +554,7 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
@@ -602,6 +627,11 @@ CONFIG_MTD_PHYSMAP=m
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -619,9 +649,14 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_ATA_OVER_ETH is not set
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_MISC_DEVICES=y
-# CONFIG_EEPROM_93CX6 is not set
 # CONFIG_ENCLOSURE_SERVICES is not set
 # CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_93CX6 is not set
 CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set
 
@@ -645,9 +680,11 @@ CONFIG_NETDEVICES=y
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=y
 CONFIG_SMC91X=y
-# CONFIG_SMSC911X is not set
 # CONFIG_DM9000 is not set
 # CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_SMSC911X is not set
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
@@ -656,6 +693,8 @@ CONFIG_SMC91X=y
 # CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
 # CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851 is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
 
@@ -664,7 +703,10 @@ CONFIG_SMC91X=y
 #
 # CONFIG_WLAN_PRE80211 is not set
 # CONFIG_WLAN_80211 is not set
-# CONFIG_IWLWIFI_LEDS is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
 # CONFIG_WAN is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
@@ -708,15 +750,12 @@ CONFIG_INPUT_EVDEV=m
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
 CONFIG_BFIN_DMA_INTERFACE=m
 # CONFIG_BFIN_PPI is not set
 # CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
 # CONFIG_BFIN_SPI_ADC is not set
 # CONFIG_BFIN_SPORT is not set
-# CONFIG_BFIN_TIMER_LATENCY is not set
-CONFIG_SIMPLE_GPIO=m
 # CONFIG_VT is not set
 # CONFIG_DEVKMEM is not set
 CONFIG_BFIN_JTAG_COMM=m
@@ -730,6 +769,7 @@ CONFIG_BFIN_JTAG_COMM=m
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
 CONFIG_SERIAL_BFIN_DMA=y
@@ -740,6 +780,7 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 
 #
@@ -763,13 +804,18 @@ CONFIG_SPI_BFIN=y
 # CONFIG_SPI_BFIN_LOCK is not set
 # CONFIG_SPI_BFIN_SPORT is not set
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 # CONFIG_SPI_SPIDEV is not set
 # CONFIG_SPI_TLE62X0 is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
 CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
 CONFIG_GPIOLIB=y
 # CONFIG_DEBUG_GPIO is not set
@@ -782,9 +828,6 @@ CONFIG_GPIO_SYSFS=y
 #
 # I2C GPIO expanders:
 #
-# CONFIG_GPIO_MAX732X is not set
-# CONFIG_GPIO_PCA953X is not set
-# CONFIG_GPIO_PCF857X is not set
 
 #
 # PCI GPIO expanders:
@@ -822,23 +865,9 @@ CONFIG_SSB_POSSIBLE=y
 # CONFIG_MFD_SM501 is not set
 # CONFIG_HTC_PASIC3 is not set
 # CONFIG_MFD_TMIO is not set
+# CONFIG_EZX_PCAP is not set
 # CONFIG_REGULATOR is not set
-
-#
-# Multimedia devices
-#
-
-#
-# Multimedia core support
-#
-# CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-# CONFIG_VIDEO_MEDIA is not set
-
-#
-# Multimedia drivers
-#
-# CONFIG_DAB is not set
+# CONFIG_MEDIA_SUPPORT is not set
 
 #
 # Graphics support
@@ -862,7 +891,6 @@ CONFIG_HID=m
 #
 # Special HID drivers
 #
-CONFIG_HID_COMPAT=y
 # CONFIG_USB_SUPPORT is not set
 # CONFIG_MMC is not set
 # CONFIG_MEMSTICK is not set
@@ -870,9 +898,19 @@ CONFIG_HID_COMPAT=y
 # CONFIG_ACCESSIBILITY is not set
 # CONFIG_RTC_CLASS is not set
 # CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
 # CONFIG_STAGING is not set
 
+#
+# Firmware Drivers
+#
+# CONFIG_FIRMWARE_MEMMAP is not set
+
 #
 # File systems
 #
@@ -882,9 +920,11 @@ CONFIG_HID_COMPAT=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
-CONFIG_FILE_LOCKING=y
 # CONFIG_XFS_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -893,6 +933,11 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
@@ -915,10 +960,7 @@ CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -937,17 +979,8 @@ CONFIG_JFFS2_ZLIB=y
 # CONFIG_JFFS2_LZO is not set
 CONFIG_JFFS2_RTIME=y
 # CONFIG_JFFS2_RUBIN is not set
-CONFIG_YAFFS_FS=m
-CONFIG_YAFFS_YAFFS1=y
-# CONFIG_YAFFS_9BYTE_TAGS is not set
-# CONFIG_YAFFS_DOES_ECC is not set
-CONFIG_YAFFS_YAFFS2=y
-CONFIG_YAFFS_AUTO_YAFFS2=y
-# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set
-# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set
-# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set
-CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_OMFS_FS is not set
@@ -956,6 +989,7 @@ CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
 # CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
+# CONFIG_NILFS2_FS is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=m
 CONFIG_NFS_V3=y
@@ -966,7 +1000,6 @@ CONFIG_LOCKD=m
 CONFIG_LOCKD_V4=y
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=m
-# CONFIG_SUNRPC_REGISTER_V4 is not set
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
@@ -1034,11 +1067,15 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
 CONFIG_DEBUG_KERNEL=y
 CONFIG_DEBUG_SHIRQ=y
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
 CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
 CONFIG_SCHED_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_TIMER_STATS is not set
@@ -1046,16 +1083,21 @@ CONFIG_SCHED_DEBUG=y
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_NOMMU_REGIONS is not set
 # CONFIG_DEBUG_WRITECOUNT is not set
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_DEBUG_LIST is not set
 # CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
 # CONFIG_FRAME_POINTER is not set
 # CONFIG_BOOT_PRINTK_DELAY is not set
 # CONFIG_RCU_TORTURE_TEST is not set
@@ -1063,17 +1105,19 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_BACKTRACE_SELF_TEST is not set
 # CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
 # CONFIG_FAULT_INJECTION is not set
-
-#
-# Tracers
-#
-# CONFIG_SCHED_TRACER is not set
-# CONFIG_CONTEXT_SWITCH_TRACER is not set
-# CONFIG_BOOT_TRACER is not set
-# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+# CONFIG_FTRACE is not set
+# CONFIG_BRANCH_PROFILE_NONE is not set
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
 # CONFIG_KGDB is not set
+# CONFIG_KMEMCHECK is not set
 # CONFIG_DEBUG_STACKOVERFLOW is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 CONFIG_DEBUG_VERBOSE=y
@@ -1095,16 +1139,15 @@ CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE=y
 CONFIG_EARLY_PRINTK=y
 CONFIG_CPLB_INFO=y
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
 #
 # CONFIG_KEYS is not set
-CONFIG_SECURITY=y
+# CONFIG_SECURITY is not set
 # CONFIG_SECURITYFS is not set
-# CONFIG_SECURITY_NETWORK is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
-CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
 CONFIG_CRYPTO=y
 
 #
@@ -1183,6 +1226,7 @@ CONFIG_CRYPTO=y
 # Compression
 #
 # CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
 # CONFIG_CRYPTO_LZO is not set
 
 #
@@ -1190,11 +1234,13 @@ CONFIG_CRYPTO=y
 #
 # CONFIG_CRYPTO_ANSI_CPRNG is not set
 CONFIG_CRYPTO_HW=y
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
 # CONFIG_CRC_T10DIF is not set
@@ -1204,6 +1250,8 @@ CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=m
+CONFIG_DECOMPRESS_GZIP=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index 5d944ffd4ab093efe68ccb36af33a2712d5416af..9e65d885ec0bc72c6b1ce6fb7cfd29dc28d3f5f7 100644 (file)
@@ -66,6 +66,7 @@ CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -275,6 +276,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_RESOURCES_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=y
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
index 648a31d01bf493c764e77d4ef33c31d930a01e82..4432150d89e375f1c37eb3f1631186e04a682869 100644 (file)
@@ -1,12 +1,13 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.28
+# Linux kernel version: 2.6.30.5
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
@@ -15,6 +16,9 @@ CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
@@ -25,55 +29,72 @@ CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+CONFIG_KERNEL_LZMA=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
-CONFIG_SYSFS_DEPRECATED=y
-CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_CGROUPS is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+CONFIG_RD_LZMA=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-# CONFIG_SYSCTL is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 CONFIG_UID16=y
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
+# CONFIG_STRIP_ASM_SYMS is not set
 CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
-CONFIG_COMPAT_BRK=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
 CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
 # CONFIG_AIO is not set
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
+# CONFIG_SLOW_WORK is not set
 # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
-CONFIG_RT_MUTEXES=y
-CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 # CONFIG_MODULE_FORCE_LOAD is not set
@@ -81,11 +102,8 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
 # CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_BLK_DEV_INTEGRITY is not set
 
@@ -101,7 +119,6 @@ CONFIG_IOSCHED_CFQ=y
 CONFIG_DEFAULT_CFQ=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="cfq"
-CONFIG_CLASSIC_RCU=y
 # CONFIG_PREEMPT_NONE is not set
 CONFIG_PREEMPT_VOLUNTARY=y
 # CONFIG_PREEMPT is not set
@@ -265,7 +282,10 @@ CONFIG_HZ=250
 # CONFIG_SCHED_HRTICK is not set
 CONFIG_GENERIC_TIME=y
 CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_TICKSOURCE_GPTMR0 is not set
+CONFIG_TICKSOURCE_CORETMR=y
 # CONFIG_CYCLES_CLOCKSOURCE is not set
+# CONFIG_GPTMR0_CLOCKSOURCE is not set
 # CONFIG_NO_HZ is not set
 # CONFIG_HIGH_RES_TIMERS is not set
 CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
@@ -315,10 +335,12 @@ CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_UNEVICTABLE_LRU=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=y
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
@@ -329,10 +351,9 @@ CONFIG_DMA_UNCACHED_1M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
 CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
@@ -343,7 +364,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -361,7 +382,7 @@ CONFIG_C_AMBEN_ALL=y
 # EBIU_AMBCTL Control
 #
 CONFIG_BANK_0=0x7BB0
-CONFIG_BANK_1=0x5554
+CONFIG_BANK_1=0x7BB0
 CONFIG_BANK_2=0x7BB0
 CONFIG_BANK_3=0xFFC0
 
@@ -386,7 +407,6 @@ CONFIG_BINFMT_ZFLAT=y
 #
 # CONFIG_PM is not set
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
-# CONFIG_PM_WAKEUP_BY_GPIO is not set
 
 #
 # CPU Frequency scaling
@@ -400,11 +420,6 @@ CONFIG_NET=y
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-# CONFIG_XFRM_MIGRATE is not set
-# CONFIG_XFRM_STATISTICS is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -428,7 +443,6 @@ CONFIG_IP_PNP=y
 # CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
-CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
@@ -452,7 +466,9 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
@@ -463,13 +479,8 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
-# CONFIG_PHONET is not set
-CONFIG_WIRELESS=y
-# CONFIG_CFG80211 is not set
-CONFIG_WIRELESS_OLD_REGULATORY=y
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -484,22 +495,21 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
-# CONFIG_DEBUG_DRIVER is not set
-# CONFIG_DEBUG_DEVRES is not set
 # CONFIG_SYS_HYPERVISOR is not set
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
 # CONFIG_MTD_AR7_PARTS is not set
 
 #
 # User Modules And Translation Layers
 #
-CONFIG_MTD_CHAR=m
+CONFIG_MTD_CHAR=y
 CONFIG_MTD_BLKDEVS=y
 CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
@@ -512,9 +522,9 @@ CONFIG_MTD_BLOCK=y
 #
 # RAM/ROM/Flash chip drivers
 #
-# CONFIG_MTD_CFI is not set
-CONFIG_MTD_JEDECPROBE=m
-CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI=y
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
 # CONFIG_MTD_CFI_ADV_OPTIONS is not set
 CONFIG_MTD_MAP_BANK_WIDTH_1=y
 CONFIG_MTD_MAP_BANK_WIDTH_2=y
@@ -526,9 +536,11 @@ CONFIG_MTD_CFI_I1=y
 CONFIG_MTD_CFI_I2=y
 # CONFIG_MTD_CFI_I4 is not set
 # CONFIG_MTD_CFI_I8 is not set
-# CONFIG_MTD_CFI_INTELEXT is not set
+CONFIG_MTD_CFI_INTELEXT=y
 # CONFIG_MTD_CFI_AMDSTD is not set
 # CONFIG_MTD_CFI_STAA is not set
+# CONFIG_MTD_PSD4256G is not set
+CONFIG_MTD_CFI_UTIL=y
 CONFIG_MTD_RAM=y
 CONFIG_MTD_ROM=m
 # CONFIG_MTD_ABSENT is not set
@@ -538,7 +550,7 @@ CONFIG_MTD_ROM=m
 #
 CONFIG_MTD_COMPLEX_MAPPINGS=y
 # CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_GPIO_ADDR is not set
+CONFIG_MTD_GPIO_ADDR=y
 # CONFIG_MTD_UCLINUX is not set
 # CONFIG_MTD_PLATRAM is not set
 
@@ -561,6 +573,11 @@ CONFIG_MTD_COMPLEX_MAPPINGS=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -586,12 +603,46 @@ CONFIG_HAVE_IDE=y
 # SCSI device support
 #
 # CONFIG_RAID_ATTRS is not set
-# CONFIG_SCSI is not set
-# CONFIG_SCSI_DMA is not set
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_TGT is not set
 # CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
 # CONFIG_ATA is not set
 # CONFIG_MD is not set
 CONFIG_NETDEVICES=y
+CONFIG_COMPAT_NET_DEV_OPS=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_MACVLAN is not set
@@ -613,6 +664,9 @@ CONFIG_PHYLIB=y
 # CONFIG_BROADCOM_PHY is not set
 # CONFIG_ICPLUS_PHY is not set
 # CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
 # CONFIG_FIXED_PHY is not set
 # CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
@@ -623,9 +677,11 @@ CONFIG_BFIN_TX_DESC_NUM=10
 CONFIG_BFIN_RX_DESC_NUM=20
 CONFIG_BFIN_MAC_RMII=y
 # CONFIG_SMC91X is not set
-# CONFIG_SMSC911X is not set
 # CONFIG_DM9000 is not set
 # CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_SMSC911X is not set
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
@@ -633,6 +689,7 @@ CONFIG_BFIN_MAC_RMII=y
 # CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
 # CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
 # CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
 
@@ -641,7 +698,10 @@ CONFIG_BFIN_MAC_RMII=y
 #
 # CONFIG_WLAN_PRE80211 is not set
 # CONFIG_WLAN_80211 is not set
-# CONFIG_IWLWIFI_LEDS is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
 
 #
 # USB Network Adapters
@@ -674,17 +734,13 @@ CONFIG_BFIN_MAC_RMII=y
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
-# CONFIG_SPI_ADC_BF533 is not set
-# CONFIG_BF5xx_PPIFCD is not set
+CONFIG_BFIN_DMA_INTERFACE=m
+# CONFIG_BFIN_PPI is not set
+# CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
-# CONFIG_BF5xx_PPI is not set
-# CONFIG_BF5xx_EPPI is not set
+# CONFIG_BFIN_SPI_ADC is not set
 # CONFIG_BFIN_SPORT is not set
-# CONFIG_BFIN_TIMER_LATENCY is not set
-# CONFIG_TWI_LCD is not set
-CONFIG_BFIN_DMA_INTERFACE=m
-CONFIG_SIMPLE_GPIO=m
+# CONFIG_BFIN_TWI_LCD is not set
 # CONFIG_VT is not set
 # CONFIG_DEVKMEM is not set
 # CONFIG_BFIN_JTAG_COMM is not set
@@ -698,6 +754,7 @@ CONFIG_SIMPLE_GPIO=m
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
 CONFIG_SERIAL_BFIN_DMA=y
@@ -710,6 +767,7 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 CONFIG_BFIN_OTP=y
 # CONFIG_BFIN_OTP_WRITE_ENABLE is not set
@@ -758,13 +816,9 @@ CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100
 # Miscellaneous I2C Chip support
 #
 # CONFIG_DS1682 is not set
-# CONFIG_AT24 is not set
-# CONFIG_SENSORS_AD5252 is not set
-# CONFIG_SENSORS_EEPROM is not set
 # CONFIG_SENSORS_PCF8574 is not set
 # CONFIG_PCF8575 is not set
 # CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
 # CONFIG_SENSORS_MAX6875 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
@@ -772,7 +826,6 @@ CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100
 # CONFIG_I2C_DEBUG_BUS is not set
 # CONFIG_I2C_DEBUG_CHIP is not set
 CONFIG_SPI=y
-# CONFIG_SPI_DEBUG is not set
 CONFIG_SPI_MASTER=y
 
 #
@@ -780,17 +833,17 @@ CONFIG_SPI_MASTER=y
 #
 CONFIG_SPI_BFIN=y
 # CONFIG_SPI_BFIN_LOCK is not set
+# CONFIG_SPI_BFIN_SPORT is not set
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_SPI_AT25 is not set
 # CONFIG_SPI_SPIDEV is not set
 # CONFIG_SPI_TLE62X0 is not set
 CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
 CONFIG_GPIOLIB=y
-# CONFIG_DEBUG_GPIO is not set
 CONFIG_GPIO_SYSFS=y
 
 #
@@ -803,6 +856,7 @@ CONFIG_GPIO_SYSFS=y
 # CONFIG_GPIO_MAX732X is not set
 # CONFIG_GPIO_PCA953X is not set
 # CONFIG_GPIO_PCF857X is not set
+# CONFIG_GPIO_ADP5588 is not set
 
 #
 # PCI GPIO expanders:
@@ -829,11 +883,13 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_ADT7462 is not set
 # CONFIG_SENSORS_ADT7470 is not set
 # CONFIG_SENSORS_ADT7473 is not set
+# CONFIG_SENSORS_ADT7475 is not set
 # CONFIG_SENSORS_ATXP1 is not set
 # CONFIG_SENSORS_DS1621 is not set
 # CONFIG_SENSORS_F71805F is not set
 # CONFIG_SENSORS_F71882FG is not set
 # CONFIG_SENSORS_F75375S is not set
+# CONFIG_SENSORS_G760A is not set
 # CONFIG_SENSORS_GL518SM is not set
 # CONFIG_SENSORS_GL520SM is not set
 # CONFIG_SENSORS_IT87 is not set
@@ -849,11 +905,16 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_LM90 is not set
 # CONFIG_SENSORS_LM92 is not set
 # CONFIG_SENSORS_LM93 is not set
+# CONFIG_SENSORS_LTC4215 is not set
+# CONFIG_SENSORS_LTC4245 is not set
+# CONFIG_SENSORS_LM95241 is not set
 # CONFIG_SENSORS_MAX1111 is not set
 # CONFIG_SENSORS_MAX1619 is not set
 # CONFIG_SENSORS_MAX6650 is not set
 # CONFIG_SENSORS_PC87360 is not set
 # CONFIG_SENSORS_PC87427 is not set
+# CONFIG_SENSORS_PCF8591 is not set
+# CONFIG_SENSORS_SHT15 is not set
 # CONFIG_SENSORS_DME1737 is not set
 # CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_SMSC47M192 is not set
@@ -885,6 +946,12 @@ CONFIG_BFIN_WDT=y
 # USB-based Watchdog Cards
 #
 # CONFIG_USBPCWATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
 
 #
 # Multifunction device drivers
@@ -892,10 +959,14 @@ CONFIG_BFIN_WDT=y
 # CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
 # CONFIG_HTC_PASIC3 is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TWL4030_CORE is not set
 # CONFIG_MFD_TMIO is not set
 # CONFIG_PMIC_DA903X is not set
+# CONFIG_PMIC_ADP5520 is not set
 # CONFIG_MFD_WM8400 is not set
 # CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
 # CONFIG_REGULATOR is not set
 
 #
@@ -931,20 +1002,20 @@ CONFIG_USB_SUPPORT=y
 CONFIG_USB_ARCH_HAS_HCD=y
 # CONFIG_USB_ARCH_HAS_OHCI is not set
 # CONFIG_USB_ARCH_HAS_EHCI is not set
-CONFIG_USB=y
+CONFIG_USB=m
 # CONFIG_USB_DEBUG is not set
-# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
 
 #
 # Miscellaneous USB options
 #
-# CONFIG_USB_DEVICEFS is not set
-CONFIG_USB_DEVICE_CLASS=y
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_OTG is not set
 # CONFIG_USB_OTG_WHITELIST is not set
 CONFIG_USB_OTG_BLACKLIST_HUB=y
-CONFIG_USB_MON=y
+CONFIG_USB_MON=m
 # CONFIG_USB_WUSB is not set
 # CONFIG_USB_WUSB_CBAF is not set
 
@@ -952,24 +1023,24 @@ CONFIG_USB_MON=y
 # USB Host Controller Drivers
 #
 # CONFIG_USB_C67X00_HCD is not set
+# CONFIG_USB_OXU210HP_HCD is not set
 # CONFIG_USB_ISP116X_HCD is not set
 # CONFIG_USB_ISP1760_HCD is not set
 # CONFIG_USB_ISP1362_HCD is not set
 # CONFIG_USB_SL811_HCD is not set
 # CONFIG_USB_R8A66597_HCD is not set
 # CONFIG_USB_HWA_HCD is not set
-CONFIG_USB_MUSB_HDRC=y
+CONFIG_USB_MUSB_HDRC=m
 CONFIG_USB_MUSB_SOC=y
 
 #
 # Blackfin high speed USB Support
 #
-CONFIG_USB_MUSB_HOST=y
-# CONFIG_USB_MUSB_PERIPHERAL is not set
+# CONFIG_USB_MUSB_HOST is not set
+CONFIG_USB_MUSB_PERIPHERAL=y
 # CONFIG_USB_MUSB_OTG is not set
-CONFIG_USB_MUSB_HDRC_HCD=y
+CONFIG_USB_GADGET_MUSB_HDRC=y
 CONFIG_MUSB_PIO_ONLY=y
-CONFIG_MUSB_DMA_POLL=y
 # CONFIG_USB_MUSB_DEBUG is not set
 
 #
@@ -981,18 +1052,31 @@ CONFIG_MUSB_DMA_POLL=y
 # CONFIG_USB_TMC is not set
 
 #
-# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 
 #
-# see USB_STORAGE Help for more information
+# also be needed; see USB_STORAGE Help for more info
 #
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
 # CONFIG_USB_LIBUSUAL is not set
 
 #
 # USB Imaging devices
 #
 # CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
 
 #
 # USB port drivers
@@ -1013,7 +1097,6 @@ CONFIG_MUSB_DMA_POLL=y
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYPRESS_CY7C63 is not set
 # CONFIG_USB_CYTHERM is not set
-# CONFIG_USB_PHIDGET is not set
 # CONFIG_USB_IDMOUSE is not set
 # CONFIG_USB_FTDI_ELAN is not set
 # CONFIG_USB_APPLEDISPLAY is not set
@@ -1021,9 +1104,50 @@ CONFIG_MUSB_DMA_POLL=y
 # CONFIG_USB_LD is not set
 # CONFIG_USB_TRANCEVIBRATOR is not set
 # CONFIG_USB_IOWARRIOR is not set
+# CONFIG_USB_TEST is not set
 # CONFIG_USB_ISIGHTFW is not set
 # CONFIG_USB_VST is not set
-# CONFIG_USB_GADGET is not set
+CONFIG_USB_GADGET=m
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_ATMEL_USBA is not set
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2272 is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=m
+CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_GADGETFS is not set
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+CONFIG_USB_G_SERIAL=m
+# CONFIG_USB_MIDI_GADGET is not set
+CONFIG_USB_G_PRINTER=m
+# CONFIG_USB_CDC_COMPOSITE is not set
+
+#
+# OTG and related infrastructure
+#
+CONFIG_USB_OTG_UTILS=y
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
 # CONFIG_MMC is not set
 # CONFIG_MEMSTICK is not set
 # CONFIG_NEW_LEDS is not set
@@ -1090,6 +1214,7 @@ CONFIG_RTC_INTF_DEV=y
 #
 CONFIG_RTC_DRV_BFIN=y
 # CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
 # CONFIG_STAGING is not set
 
@@ -1102,9 +1227,10 @@ CONFIG_RTC_DRV_BFIN=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
-CONFIG_FILE_LOCKING=y
 # CONFIG_XFS_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -1113,6 +1239,11 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
@@ -1122,8 +1253,11 @@ CONFIG_INOTIFY_USER=y
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # CONFIG_NTFS_FS is not set
 
 #
@@ -1135,10 +1269,7 @@ CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -1146,9 +1277,19 @@ CONFIG_SYSFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-# CONFIG_YAFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_OMFS_FS is not set
@@ -1157,6 +1298,7 @@ CONFIG_SYSFS=y
 # CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
+# CONFIG_NILFS2_FS is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=m
 CONFIG_NFS_V3=y
@@ -1167,7 +1309,6 @@ CONFIG_LOCKD=m
 CONFIG_LOCKD_V4=y
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=m
-# CONFIG_SUNRPC_REGISTER_V4 is not set
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
 CONFIG_SMB_FS=m
@@ -1182,9 +1323,9 @@ CONFIG_SMB_FS=m
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-CONFIG_NLS=m
+CONFIG_NLS=y
 CONFIG_NLS_DEFAULT="iso8859-1"
-# CONFIG_NLS_CODEPAGE_437 is not set
+CONFIG_NLS_CODEPAGE_437=y
 # CONFIG_NLS_CODEPAGE_737 is not set
 # CONFIG_NLS_CODEPAGE_775 is not set
 # CONFIG_NLS_CODEPAGE_850 is not set
@@ -1208,7 +1349,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
 # CONFIG_NLS_CODEPAGE_1250 is not set
 # CONFIG_NLS_CODEPAGE_1251 is not set
 # CONFIG_NLS_ASCII is not set
-# CONFIG_NLS_ISO8859_1 is not set
+CONFIG_NLS_ISO8859_1=y
 # CONFIG_NLS_ISO8859_2 is not set
 # CONFIG_NLS_ISO8859_3 is not set
 # CONFIG_NLS_ISO8859_4 is not set
@@ -1235,55 +1376,34 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
-CONFIG_DEBUG_KERNEL=y
-# CONFIG_DEBUG_SHIRQ is not set
-CONFIG_DETECT_SOFTLOCKUP=y
-# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
-CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
-# CONFIG_SCHED_DEBUG is not set
-# CONFIG_SCHEDSTATS is not set
-# CONFIG_TIMER_STATS is not set
-# CONFIG_DEBUG_OBJECTS is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_RT_MUTEXES is not set
-# CONFIG_RT_MUTEX_TESTER is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_MUTEXES is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
-# CONFIG_DEBUG_KOBJECT is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_VM is not set
-# CONFIG_DEBUG_WRITECOUNT is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
+# CONFIG_DEBUG_KERNEL is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
 # CONFIG_DEBUG_MEMORY_INIT is not set
-# CONFIG_DEBUG_LIST is not set
-# CONFIG_DEBUG_SG is not set
-# CONFIG_FRAME_POINTER is not set
-# CONFIG_BOOT_PRINTK_DELAY is not set
-# CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_RCU_CPU_STALL_DETECTOR is not set
-# CONFIG_BACKTRACE_SELF_TEST is not set
-# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
-# CONFIG_FAULT_INJECTION is not set
-# CONFIG_SYSCTL_SYSCALL_CHECK is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
 
 #
 # Tracers
 #
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
 # CONFIG_SCHED_TRACER is not set
 # CONFIG_CONTEXT_SWITCH_TRACER is not set
+# CONFIG_EVENT_TRACER is not set
 # CONFIG_BOOT_TRACER is not set
-# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
+# CONFIG_TRACE_BRANCH_PROFILING is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
-# CONFIG_KGDB is not set
-# CONFIG_DEBUG_STACKOVERFLOW is not set
-# CONFIG_DEBUG_STACK_USAGE is not set
-# CONFIG_KGDB_TESTCASE is not set
 CONFIG_DEBUG_VERBOSE=y
-CONFIG_DEBUG_MMRS=y
-# CONFIG_DEBUG_HWERR is not set
+# CONFIG_DEBUG_MMRS is not set
 # CONFIG_DEBUG_DOUBLEFAULT is not set
 CONFIG_DEBUG_HUNT_FOR_ZERO=y
 CONFIG_DEBUG_BFIN_HWTRACE_ON=y
@@ -1293,9 +1413,10 @@ CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
 # CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
 # CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
-# CONFIG_EARLY_PRINTK is not set
+CONFIG_EARLY_PRINTK=y
 # CONFIG_CPLB_INFO is not set
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
@@ -1304,9 +1425,9 @@ CONFIG_ACCESS_CHECK=y
 CONFIG_SECURITY=y
 # CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_NETWORK is not set
+# CONFIG_SECURITY_PATH is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
-# CONFIG_SECURITY_ROOTPLUG is not set
-CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
+# CONFIG_SECURITY_TOMOYO is not set
 CONFIG_CRYPTO=y
 
 #
@@ -1385,6 +1506,7 @@ CONFIG_CRYPTO=y
 # Compression
 #
 # CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
 # CONFIG_CRYPTO_LZO is not set
 
 #
@@ -1392,20 +1514,24 @@ CONFIG_CRYPTO=y
 #
 # CONFIG_CRYPTO_ANSI_CPRNG is not set
 CONFIG_CRYPTO_HW=y
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
 # CONFIG_CRC_T10DIF is not set
-# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC_ITU_T=y
 CONFIG_CRC32=y
-# CONFIG_CRC7 is not set
+CONFIG_CRC7=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
-CONFIG_PLIST=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_LZMA=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index ae665b93b87598d58ab7c2c561b8acf6d49f9581..df56639ab2f25333def32e01998ef6f2ebd6f50b 100644 (file)
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.22.16
+# Linux kernel version: 2.6.30.5
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
-CONFIG_SEMAPHORE_SLEEPERS=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
-CONFIG_GENERIC_TIME=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
-# Code maturity level options
+# General setup
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+CONFIG_KERNEL_LZMA=y
 CONFIG_SYSVIPC=y
-# CONFIG_IPC_NS is not set
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
-# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
-# CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-# CONFIG_SYSCTL is not set
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+CONFIG_RD_LZMA=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_UID16 is not set
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
-# CONFIG_HOTPLUG is not set
+# CONFIG_STRIP_ASM_SYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
+CONFIG_AIO=y
 CONFIG_VM_EVENT_COUNTERS=y
-CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
-# CONFIG_NP2 is not set
+CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
-CONFIG_RT_MUTEXES=y
-CONFIG_TINY_SHMEM=y
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_SLOW_WORK is not set
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
 CONFIG_BASE_SMALL=0
-
-#
-# Loadable module support
-#
 CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODULE_FORCE_LOAD is not set
+# CONFIG_MODULE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
-
-#
-# Block layer
-#
 CONFIG_BLOCK=y
 # CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
 
 #
 # IO Schedulers
@@ -96,7 +112,7 @@ CONFIG_BLOCK=y
 CONFIG_IOSCHED_NOOP=y
 # CONFIG_IOSCHED_AS is not set
 # CONFIG_IOSCHED_DEADLINE is not set
-CONFIG_IOSCHED_CFQ=y
+# CONFIG_IOSCHED_CFQ is not set
 # CONFIG_DEFAULT_AS is not set
 # CONFIG_DEFAULT_DEADLINE is not set
 # CONFIG_DEFAULT_CFQ is not set
@@ -105,6 +121,7 @@ CONFIG_DEFAULT_IOSCHED="noop"
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
+# CONFIG_FREEZER is not set
 
 #
 # Blackfin Processor Options
@@ -113,6 +130,10 @@ CONFIG_PREEMPT_NONE=y
 #
 # Processor and Board Settings
 #
+# CONFIG_BF512 is not set
+# CONFIG_BF514 is not set
+# CONFIG_BF516 is not set
+# CONFIG_BF518 is not set
 # CONFIG_BF522 is not set
 # CONFIG_BF523 is not set
 # CONFIG_BF524 is not set
@@ -125,28 +146,38 @@ CONFIG_BF533=y
 # CONFIG_BF534 is not set
 # CONFIG_BF536 is not set
 # CONFIG_BF537 is not set
+# CONFIG_BF538 is not set
+# CONFIG_BF539 is not set
 # CONFIG_BF542 is not set
+# CONFIG_BF542M is not set
 # CONFIG_BF544 is not set
+# CONFIG_BF544M is not set
 # CONFIG_BF547 is not set
+# CONFIG_BF547M is not set
 # CONFIG_BF548 is not set
+# CONFIG_BF548M is not set
 # CONFIG_BF549 is not set
+# CONFIG_BF549M is not set
 # CONFIG_BF561 is not set
+CONFIG_BF_REV_MIN=3
+CONFIG_BF_REV_MAX=6
 # CONFIG_BF_REV_0_0 is not set
 # CONFIG_BF_REV_0_1 is not set
 # CONFIG_BF_REV_0_2 is not set
 CONFIG_BF_REV_0_3=y
 # CONFIG_BF_REV_0_4 is not set
 # CONFIG_BF_REV_0_5 is not set
+# CONFIG_BF_REV_0_6 is not set
 # CONFIG_BF_REV_ANY is not set
 # CONFIG_BF_REV_NONE is not set
 CONFIG_BF53x=y
-CONFIG_BFIN_SINGLE_CORE=y
 CONFIG_MEM_MT48LC16M16A2TG_75=y
 # CONFIG_BFIN533_EZKIT is not set
 # CONFIG_BFIN533_STAMP is not set
+# CONFIG_BLACKSTAMP is not set
 CONFIG_BFIN533_BLUETECHNIX_CM=y
 # CONFIG_H8606_HVSISTEMAS is not set
-# CONFIG_GENERIC_BF533_BOARD is not set
+# CONFIG_BFIN532_IP0X is not set
 
 #
 # BF533/2/1 Specific Configuration
@@ -188,6 +219,7 @@ CONFIG_WDTIMER=13
 # Board customizations
 #
 # CONFIG_CMDLINE_BOOL is not set
+CONFIG_BOOT_LOAD=0x1000
 
 #
 # Clock/PLL Setup
@@ -207,13 +239,20 @@ CONFIG_HZ_250=y
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
 CONFIG_HZ=250
+# CONFIG_SCHED_HRTICK is not set
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_TICKSOURCE_GPTMR0 is not set
+CONFIG_TICKSOURCE_CORETMR=y
+# CONFIG_CYCLES_CLOCKSOURCE is not set
+# CONFIG_GPTMR0_CLOCKSOURCE is not set
+# CONFIG_NO_HZ is not set
+# CONFIG_HIGH_RES_TIMERS is not set
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
 
 #
-# Memory Setup
+# Misc
 #
-CONFIG_MAX_MEM_SIZE=32
-CONFIG_MEM_ADD_WIDTH=9
-CONFIG_BOOT_LOAD=0x1000
 CONFIG_BFIN_SCRATCH_REG_RETN=y
 # CONFIG_BFIN_SCRATCH_REG_RETE is not set
 # CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
@@ -240,6 +279,12 @@ CONFIG_IP_CHECKSUM_L1=y
 CONFIG_CACHELINE_ALIGNED_L1=y
 CONFIG_SYSCALL_TAB_L1=y
 CONFIG_CPLB_SWITCH_TAB_L1=y
+CONFIG_APP_STACK_L1=y
+
+#
+# Speed Optimizations
+#
+CONFIG_BFIN_INS_LOWOVERHEAD=y
 CONFIG_RAMKERNEL=y
 # CONFIG_ROMKERNEL is not set
 CONFIG_SELECT_MEMORY_MODEL=y
@@ -248,12 +293,16 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
-CONFIG_LARGE_ALLOCS=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_UNEVICTABLE_LRU=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 # CONFIG_BFIN_GPTIMERS is not set
+# CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
 CONFIG_DMA_UNCACHED_1M=y
 # CONFIG_DMA_UNCACHED_NONE is not set
@@ -262,10 +311,9 @@ CONFIG_DMA_UNCACHED_1M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
 CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
@@ -276,7 +324,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -301,12 +349,8 @@ CONFIG_BANK_3=0xFFC2
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ARCH_SUPPORTS_MSI is not set
-
-#
-# PCCARD (PCMCIA/CardBus) support
-#
+# CONFIG_PCCARD is not set
 
 #
 # Executable file formats
@@ -315,22 +359,19 @@ CONFIG_BINFMT_ELF_FDPIC=y
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_ZFLAT=y
 CONFIG_BINFMT_SHARED_FLAT=y
+# CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
 
 #
 # Power management options
 #
 # CONFIG_PM is not set
-# CONFIG_PM_WAKEUP_BY_GPIO is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
 # CPU Frequency scaling
 #
 # CONFIG_CPU_FREQ is not set
-
-#
-# Networking
-#
 CONFIG_NET=y
 
 #
@@ -339,45 +380,13 @@ CONFIG_NET=y
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-# CONFIG_XFRM_MIGRATE is not set
 # CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_FIB_HASH=y
-# CONFIG_IP_PNP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_XFRM_TUNNEL is not set
-# CONFIG_INET_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_DIAG is not set
-CONFIG_INET_TCP_DIAG=y
-# CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_CUBIC=y
-CONFIG_DEFAULT_TCP_CONG="cubic"
-# CONFIG_TCP_MD5SIG is not set
-# CONFIG_IPV6 is not set
-# CONFIG_INET6_XFRM_TUNNEL is not set
-# CONFIG_INET6_TUNNEL is not set
-# CONFIG_NETLABEL is not set
+# CONFIG_INET is not set
 # CONFIG_NETWORK_SECMARK is not set
 # CONFIG_NETFILTER is not set
-# CONFIG_IP_DCCP is not set
-# CONFIG_IP_SCTP is not set
-# CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
 # CONFIG_VLAN_8021Q is not set
 # CONFIG_DECNET is not set
 # CONFIG_LLC2 is not set
@@ -385,31 +394,23 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_ATALK is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
-# CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
+# CONFIG_PHONET is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
-# CONFIG_AF_RXRPC is not set
-
-#
-# Wireless
-#
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
 
 #
 # Device Drivers
@@ -418,20 +419,22 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 #
 # Generic Driver Options
 #
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
 # CONFIG_SYS_HYPERVISOR is not set
-
-#
-# Connector - unified userspace <-> kernelspace linker
-#
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
 
 #
 # User Modules And Translation Layers
@@ -444,12 +447,15 @@ CONFIG_MTD_BLOCK=y
 # CONFIG_INFTL is not set
 # CONFIG_RFD_FTL is not set
 # CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
 
 #
 # RAM/ROM/Flash chip drivers
 #
-# CONFIG_MTD_CFI is not set
+CONFIG_MTD_CFI=y
 # CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
 CONFIG_MTD_MAP_BANK_WIDTH_1=y
 CONFIG_MTD_MAP_BANK_WIDTH_2=y
 CONFIG_MTD_MAP_BANK_WIDTH_4=y
@@ -460,6 +466,11 @@ CONFIG_MTD_CFI_I1=y
 CONFIG_MTD_CFI_I2=y
 # CONFIG_MTD_CFI_I4 is not set
 # CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+# CONFIG_MTD_PSD4256G is not set
+CONFIG_MTD_CFI_UTIL=y
 CONFIG_MTD_RAM=y
 # CONFIG_MTD_ROM is not set
 # CONFIG_MTD_ABSENT is not set
@@ -468,12 +479,16 @@ CONFIG_MTD_RAM=y
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
-CONFIG_MTD_UCLINUX=y
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_UCLINUX is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -489,36 +504,25 @@ CONFIG_MTD_UCLINUX=y
 # CONFIG_MTD_ONENAND is not set
 
 #
-# UBI - Unsorted block images
+# LPDDR flash memory drivers
 #
-# CONFIG_MTD_UBI is not set
+# CONFIG_MTD_LPDDR is not set
 
 #
-# Parallel port support
+# UBI - Unsorted block images
 #
+# CONFIG_MTD_UBI is not set
 # CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNPACPI is not set
-
-#
-# Block devices
-#
+CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_COUNT=16
-CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+# CONFIG_BLK_DEV_RAM is not set
 # CONFIG_CDROM_PKTCDVD is not set
 # CONFIG_ATA_OVER_ETH is not set
-
-#
-# Misc devices
-#
+# CONFIG_BLK_DEV_HD is not set
+# CONFIG_MISC_DEVICES is not set
+CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set
 
 #
@@ -526,34 +530,19 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 #
 # CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
 # CONFIG_SCSI_NETLINK is not set
 # CONFIG_ATA is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
 # CONFIG_MD is not set
-
-#
-# Network device support
-#
 CONFIG_NETDEVICES=y
+CONFIG_COMPAT_NET_DEV_OPS=y
 # CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_PHYLIB is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-CONFIG_SMC91X=y
-# CONFIG_SMSC911X is not set
-# CONFIG_DM9000 is not set
+# CONFIG_VETH is not set
+# CONFIG_NET_ETHERNET is not set
 # CONFIG_NETDEV_1000 is not set
-# CONFIG_AX88180 is not set
 # CONFIG_NETDEV_10000 is not set
 
 #
@@ -561,22 +550,17 @@ CONFIG_SMC91X=y
 #
 # CONFIG_WLAN_PRE80211 is not set
 # CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
 # CONFIG_WAN is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
 # CONFIG_NETPOLL is not set
 # CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
 # CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
 # CONFIG_PHONE is not set
 
 #
@@ -593,16 +577,15 @@ CONFIG_SMC91X=y
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
-# CONFIG_SPI_ADC_BF533 is not set
-# CONFIG_BF5xx_PFLAGS is not set
-# CONFIG_BF5xx_PPIFCD is not set
+# CONFIG_BFIN_DMA_INTERFACE is not set
+# CONFIG_BFIN_PPI is not set
+# CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
-# CONFIG_BF5xx_PPI is not set
-CONFIG_BFIN_SPORT=y
-# CONFIG_BFIN_TIMER_LATENCY is not set
+# CONFIG_BFIN_SPI_ADC is not set
+# CONFIG_BFIN_SPORT is not set
 # CONFIG_VT is not set
 # CONFIG_DEVKMEM is not set
+# CONFIG_BFIN_JTAG_COMM is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -613,6 +596,7 @@ CONFIG_BFIN_SPORT=y
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
 CONFIG_SERIAL_BFIN_DMA=y
@@ -623,175 +607,140 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 
 #
 # CAN, the car bus and industrial fieldbus
 #
 # CONFIG_CAN4LINUX is not set
-
-#
-# IPMI
-#
 # CONFIG_IPMI_HANDLER is not set
-# CONFIG_WATCHDOG is not set
 # CONFIG_HW_RANDOM is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_R3964 is not set
 # CONFIG_RAW_DRIVER is not set
-
-#
-# TPM devices
-#
 # CONFIG_TCG_TPM is not set
 # CONFIG_I2C is not set
-
-CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
-CONFIG_GPIOLIB=y
-CONFIG_GPIO_SYSFS=y
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
 
 #
-# SPI support
+# SPI Master Controller Drivers
 #
-# CONFIG_SPI is not set
-# CONFIG_SPI_MASTER is not set
+CONFIG_SPI_BFIN=y
+# CONFIG_SPI_BFIN_LOCK is not set
+# CONFIG_SPI_BFIN_SPORT is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
-# Dallas's 1-wire bus
+# SPI Protocol Masters
 #
+# CONFIG_SPI_SPIDEV is not set
+# CONFIG_SPI_TLE62X0 is not set
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+# CONFIG_GPIOLIB is not set
 # CONFIG_W1 is not set
-CONFIG_HWMON=y
-# CONFIG_HWMON_VID is not set
-# CONFIG_SENSORS_ABITUGURU is not set
-# CONFIG_SENSORS_F71805F is not set
-# CONFIG_SENSORS_PC87427 is not set
-# CONFIG_SENSORS_SMSC47M1 is not set
-# CONFIG_SENSORS_SMSC47B397 is not set
-# CONFIG_SENSORS_VT1211 is not set
-# CONFIG_SENSORS_W83627HF is not set
-# CONFIG_HWMON_DEBUG_CHIP is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
 
 #
 # Multifunction device drivers
 #
+# CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_REGULATOR is not set
 
 #
 # Multimedia devices
 #
+
+#
+# Multimedia core support
+#
 # CONFIG_VIDEO_DEV is not set
-# CONFIG_DVB_CORE is not set
-# CONFIG_DAB is not set
+# CONFIG_VIDEO_MEDIA is not set
 
 #
-# Graphics support
+# Multimedia drivers
 #
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+# CONFIG_DAB is not set
 
 #
-# Display device support
+# Graphics support
 #
-# CONFIG_DISPLAY_SUPPORT is not set
 # CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
 # CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
-# Sound
+# Display device support
 #
+# CONFIG_DISPLAY_SUPPORT is not set
 # CONFIG_SOUND is not set
+# CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
 
 #
-# USB support
+# MMC/SD/SDIO Card Drivers
 #
-CONFIG_USB_ARCH_HAS_HCD=y
-# CONFIG_USB_ARCH_HAS_OHCI is not set
-# CONFIG_USB_ARCH_HAS_EHCI is not set
-# CONFIG_USB is not set
+CONFIG_MMC_BLOCK=y
+# CONFIG_MMC_BLOCK_BOUNCE is not set
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
 
 #
-# Enable Host or Gadget support to see Inventra options
-#
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-# CONFIG_MMC is not set
-
-#
-# LED devices
+# MMC/SD/SDIO Host Controller Drivers
 #
+# CONFIG_MMC_SDHCI is not set
+CONFIG_MMC_SPI=m
+# CONFIG_MEMSTICK is not set
 # CONFIG_NEW_LEDS is not set
-
-#
-# LED drivers
-#
-
-#
-# LED Triggers
-#
-
-#
-# InfiniBand support
-#
-
-#
-# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
-#
-
-#
-# Real Time Clock
-#
+# CONFIG_ACCESSIBILITY is not set
 # CONFIG_RTC_CLASS is not set
-
-#
-# DMA Engine support
-#
-# CONFIG_DMA_ENGINE is not set
-
-#
-# DMA Clients
-#
-
-#
-# DMA Devices
-#
-
-#
-# PBX support
-#
-# CONFIG_PBX is not set
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+# CONFIG_STAGING is not set
 
 #
 # File systems
 #
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-# CONFIG_EXT2_FS_POSIX_ACL is not set
-# CONFIG_EXT2_FS_SECURITY is not set
+# CONFIG_EXT2_FS is not set
 # CONFIG_EXT3_FS is not set
-# CONFIG_EXT4DEV_FS is not set
-CONFIG_FS_MBCACHE=y
+# CONFIG_EXT4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
-# CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_INOTIFY=y
-CONFIG_INOTIFY_USER=y
-# CONFIG_QUOTA is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
 # CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY is not set
+# CONFIG_QUOTA is not set
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
@@ -801,8 +750,11 @@ CONFIG_INOTIFY_USER=y
 #
 # DOS/FAT/NT Filesystems
 #
+CONFIG_FAT_FS=y
 # CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # CONFIG_NTFS_FS is not set
 
 #
@@ -813,12 +765,8 @@ CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -826,60 +774,106 @@ CONFIG_RAMFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-# CONFIG_YAFFS_FS is not set
 # CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
 # CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-# CONFIG_NFS_FS is not set
-# CONFIG_NFSD is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-# CONFIG_9P_FS is not set
+# CONFIG_NILFS2_FS is not set
+# CONFIG_NETWORK_FILESYSTEMS is not set
 
 #
 # Partition Types
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Distributed Lock Manager
-#
-# CONFIG_DLM is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
 
 #
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
 # CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
 # CONFIG_DEBUG_KERNEL is not set
-CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+
+#
+# Tracers
+#
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+# CONFIG_EVENT_TRACER is not set
+# CONFIG_BOOT_TRACER is not set
+# CONFIG_TRACE_BRANCH_PROFILING is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_DEBUG_VERBOSE=y
 CONFIG_DEBUG_MMRS=y
+# CONFIG_DEBUG_DOUBLEFAULT is not set
 CONFIG_DEBUG_HUNT_FOR_ZERO=y
 CONFIG_DEBUG_BFIN_HWTRACE_ON=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
@@ -888,34 +882,39 @@ CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
 # CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
 # CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
-# CONFIG_EARLY_PRINTK is not set
+CONFIG_EARLY_PRINTK=y
 CONFIG_CPLB_INFO=y
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
 #
 # CONFIG_KEYS is not set
 CONFIG_SECURITY=y
+# CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_NETWORK is not set
-CONFIG_SECURITY_CAPABILITIES=y
-
-#
-# Cryptographic options
-#
+# CONFIG_SECURITY_PATH is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+# CONFIG_SECURITY_TOMOYO is not set
 # CONFIG_CRYPTO is not set
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
-CONFIG_CRC_CCITT=m
+CONFIG_GENERIC_FIND_LAST_BIT=y
+CONFIG_CRC_CCITT=y
 # CONFIG_CRC16 is not set
-# CONFIG_CRC_ITU_T is not set
+# CONFIG_CRC_T10DIF is not set
+CONFIG_CRC_ITU_T=y
 CONFIG_CRC32=y
+CONFIG_CRC7=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
-CONFIG_PLIST=y
+CONFIG_DECOMPRESS_LZMA=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index d74b6f4db35df5ed91857da838c92ee32b34431a..22e565c51d66134f05160be52112b6fda1ce2768 100644 (file)
@@ -1,13 +1,13 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.28.10
-# Wed Jun  3 06:27:41 2009
+# Linux kernel version: 2.6.30.5
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
@@ -16,6 +16,9 @@ CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
@@ -26,21 +29,40 @@ CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+CONFIG_KERNEL_LZMA=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 # CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
-# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+CONFIG_RD_LZMA=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
 CONFIG_SYSCTL=y
 CONFIG_ANON_INODES=y
@@ -49,7 +71,8 @@ CONFIG_EMBEDDED=y
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
-# CONFIG_HOTPLUG is not set
+# CONFIG_STRIP_ASM_SYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
@@ -65,12 +88,13 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
+# CONFIG_SLOW_WORK is not set
 # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
-CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 # CONFIG_MODULE_FORCE_LOAD is not set
@@ -78,11 +102,8 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
 # CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_BLK_DEV_INTEGRITY is not set
 
@@ -98,7 +119,6 @@ CONFIG_IOSCHED_CFQ=y
 # CONFIG_DEFAULT_CFQ is not set
 CONFIG_DEFAULT_NOOP=y
 CONFIG_DEFAULT_IOSCHED="noop"
-CONFIG_CLASSIC_RCU=y
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
@@ -181,7 +201,8 @@ CONFIG_IRQ_MEM_DMA1=13
 CONFIG_IRQ_WATCH=13
 CONFIG_IRQ_SPI=10
 # CONFIG_BFIN537_STAMP is not set
-CONFIG_BFIN537_BLUETECHNIX_CM=y
+CONFIG_BFIN537_BLUETECHNIX_CM_E=y
+# CONFIG_BFIN537_BLUETECHNIX_CM_U is not set
 # CONFIG_BFIN537_BLUETECHNIX_TCM is not set
 # CONFIG_PNAV10 is not set
 # CONFIG_CAMSIG_MINOTAUR is not set
@@ -283,10 +304,12 @@ CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_UNEVICTABLE_LRU=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 # CONFIG_BFIN_GPTIMERS is not set
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
@@ -297,10 +320,9 @@ CONFIG_DMA_UNCACHED_1M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
 CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
@@ -311,7 +333,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -337,6 +359,7 @@ CONFIG_BANK_3=0xFFC2
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
 
 #
 # Executable file formats
@@ -366,11 +389,6 @@ CONFIG_NET=y
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-# CONFIG_XFRM_MIGRATE is not set
-# CONFIG_XFRM_STATISTICS is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -394,7 +412,6 @@ CONFIG_IP_PNP=y
 # CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
-CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
@@ -418,7 +435,9 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
@@ -429,8 +448,8 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
-# CONFIG_PHONET is not set
 # CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -441,16 +460,21 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 #
 # Generic Driver Options
 #
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
 # CONFIG_SYS_HYPERVISOR is not set
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
 # CONFIG_MTD_AR7_PARTS is not set
 
 #
@@ -486,22 +510,26 @@ CONFIG_MTD_CFI_I2=y
 CONFIG_MTD_CFI_INTELEXT=y
 # CONFIG_MTD_CFI_AMDSTD is not set
 # CONFIG_MTD_CFI_STAA is not set
+# CONFIG_MTD_PSD4256G is not set
 CONFIG_MTD_CFI_UTIL=y
 CONFIG_MTD_RAM=y
-# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ROM=m
 # CONFIG_MTD_ABSENT is not set
 
 #
 # Mapping drivers for chip access
 #
 CONFIG_MTD_COMPLEX_MAPPINGS=y
+# CONFIG_MTD_PHYSMAP is not set
 CONFIG_MTD_GPIO_ADDR=y
-CONFIG_MTD_UCLINUX=y
+# CONFIG_MTD_UCLINUX is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -516,6 +544,11 @@ CONFIG_MTD_UCLINUX=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -533,9 +566,14 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_ATA_OVER_ETH is not set
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_MISC_DEVICES=y
-# CONFIG_EEPROM_93CX6 is not set
 # CONFIG_ENCLOSURE_SERVICES is not set
 # CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_93CX6 is not set
 CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set
 
@@ -549,6 +587,7 @@ CONFIG_HAVE_IDE=y
 # CONFIG_ATA is not set
 # CONFIG_MD is not set
 CONFIG_NETDEVICES=y
+CONFIG_COMPAT_NET_DEV_OPS=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_MACVLAN is not set
@@ -570,6 +609,9 @@ CONFIG_PHYLIB=y
 # CONFIG_BROADCOM_PHY is not set
 # CONFIG_ICPLUS_PHY is not set
 # CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
 # CONFIG_FIXED_PHY is not set
 # CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
@@ -580,8 +622,11 @@ CONFIG_BFIN_TX_DESC_NUM=10
 CONFIG_BFIN_RX_DESC_NUM=20
 # CONFIG_BFIN_MAC_RMII is not set
 # CONFIG_SMC91X is not set
-# CONFIG_SMSC911X is not set
 # CONFIG_DM9000 is not set
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_SMSC911X is not set
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
@@ -598,7 +643,10 @@ CONFIG_BFIN_RX_DESC_NUM=20
 #
 # CONFIG_WLAN_PRE80211 is not set
 # CONFIG_WLAN_80211 is not set
-# CONFIG_IWLWIFI_LEDS is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
 # CONFIG_WAN is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
@@ -622,15 +670,12 @@ CONFIG_BFIN_RX_DESC_NUM=20
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
 CONFIG_BFIN_DMA_INTERFACE=m
 # CONFIG_BFIN_PPI is not set
 # CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
 # CONFIG_BFIN_SPI_ADC is not set
 CONFIG_BFIN_SPORT=y
-# CONFIG_BFIN_TIMER_LATENCY is not set
-# CONFIG_SIMPLE_GPIO is not set
 # CONFIG_VT is not set
 # CONFIG_DEVKMEM is not set
 # CONFIG_BFIN_JTAG_COMM is not set
@@ -644,6 +689,7 @@ CONFIG_BFIN_SPORT=y
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
 CONFIG_SERIAL_BFIN_DMA=y
@@ -656,6 +702,7 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 
 #
@@ -668,7 +715,23 @@ CONFIG_UNIX98_PTYS=y
 # CONFIG_RAW_DRIVER is not set
 # CONFIG_TCG_TPM is not set
 # CONFIG_I2C is not set
-# CONFIG_SPI is not set
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BFIN=y
+# CONFIG_SPI_BFIN_LOCK is not set
+# CONFIG_SPI_BFIN_SPORT is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
+
+#
+# SPI Protocol Masters
+#
+# CONFIG_SPI_SPIDEV is not set
+# CONFIG_SPI_TLE62X0 is not set
 CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_SYSFS=y
@@ -688,15 +751,21 @@ CONFIG_GPIO_SYSFS=y
 #
 # SPI GPIO expanders:
 #
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 CONFIG_HWMON=y
 # CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ADCXX is not set
 # CONFIG_SENSORS_F71805F is not set
 # CONFIG_SENSORS_F71882FG is not set
 # CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM70 is not set
+# CONFIG_SENSORS_MAX1111 is not set
 # CONFIG_SENSORS_PC87360 is not set
 # CONFIG_SENSORS_PC87427 is not set
+# CONFIG_SENSORS_SHT15 is not set
 # CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_SMSC47B397 is not set
 # CONFIG_SENSORS_VT1211 is not set
@@ -758,21 +827,74 @@ CONFIG_USB_ARCH_HAS_HCD=y
 # CONFIG_USB is not set
 # CONFIG_USB_OTG_WHITELIST is not set
 # CONFIG_USB_OTG_BLACKLIST_HUB is not set
-
-#
-# Enable Host or Gadget support to see Inventra options
-#
-
-#
-# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed;
-#
-# CONFIG_USB_GADGET is not set
-# CONFIG_MMC is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+CONFIG_USB_GADGET=m
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_ATMEL_USBA is not set
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+CONFIG_USB_GADGET_NET2272=y
+CONFIG_USB_NET2272=m
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=m
+CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_GADGETFS is not set
+# CONFIG_USB_FILE_STORAGE is not set
+# CONFIG_USB_G_SERIAL is not set
+# CONFIG_USB_MIDI_GADGET is not set
+# CONFIG_USB_G_PRINTER is not set
+# CONFIG_USB_CDC_COMPOSITE is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+# CONFIG_MMC_BLOCK_BOUNCE is not set
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+CONFIG_MMC_SPI=m
 # CONFIG_MEMSTICK is not set
 # CONFIG_NEW_LEDS is not set
 # CONFIG_ACCESSIBILITY is not set
 # CONFIG_RTC_CLASS is not set
 # CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
 # CONFIG_STAGING is not set
 
@@ -789,9 +911,10 @@ CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
-CONFIG_FILE_LOCKING=y
 # CONFIG_XFS_FS is not set
 # CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -800,6 +923,11 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
@@ -809,8 +937,11 @@ CONFIG_INOTIFY_USER=y
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # CONFIG_NTFS_FS is not set
 
 #
@@ -822,10 +953,7 @@ CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -833,9 +961,19 @@ CONFIG_SYSFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-# CONFIG_JFFS2_FS is not set
-# CONFIG_YAFFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_OMFS_FS is not set
@@ -844,14 +982,70 @@ CONFIG_SYSFS=y
 # CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
-# CONFIG_NETWORK_FILESYSTEMS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFSD is not set
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
 
 #
 # Partition Types
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-# CONFIG_NLS is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
 # CONFIG_DLM is not set
 
 #
@@ -867,14 +1061,28 @@ CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
 CONFIG_DEBUG_SECTION_MISMATCH=y
 # CONFIG_DEBUG_KERNEL is not set
-CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_RCU_CPU_STALL_DETECTOR is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
 
 #
 # Tracers
 #
-# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+# CONFIG_EVENT_TRACER is not set
+# CONFIG_BOOT_TRACER is not set
+# CONFIG_TRACE_BRANCH_PROFILING is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
 CONFIG_DEBUG_VERBOSE=y
@@ -888,9 +1096,10 @@ CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
 # CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
 # CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
-# CONFIG_EARLY_PRINTK is not set
+CONFIG_EARLY_PRINTK=y
 CONFIG_CPLB_INFO=y
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
@@ -899,8 +1108,9 @@ CONFIG_ACCESS_CHECK=y
 CONFIG_SECURITY=y
 # CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_NETWORK is not set
+# CONFIG_SECURITY_PATH is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
-CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
+# CONFIG_SECURITY_TOMOYO is not set
 CONFIG_CRYPTO=y
 
 #
@@ -979,6 +1189,7 @@ CONFIG_CRYPTO=y
 # Compression
 #
 # CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
 # CONFIG_CRYPTO_LZO is not set
 
 #
@@ -986,19 +1197,24 @@ CONFIG_CRYPTO=y
 #
 # CONFIG_CRYPTO_ANSI_CPRNG is not set
 CONFIG_CRYPTO_HW=y
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
 # CONFIG_CRC_T10DIF is not set
-# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC_ITU_T=y
 CONFIG_CRC32=y
-# CONFIG_CRC7 is not set
+CONFIG_CRC7=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_LZMA=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index 7fc8dfa1719f6119b66799d7da25632561e54211..efcc90d2f345d27bd828a84e45d4942d1d2c4e2e 100644 (file)
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.22.16
+# Linux kernel version: 2.6.30.5
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
-CONFIG_SEMAPHORE_SLEEPERS=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
-CONFIG_GENERIC_TIME=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
-# Code maturity level options
+# General setup
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+CONFIG_KERNEL_LZMA=y
 CONFIG_SYSVIPC=y
-# CONFIG_IPC_NS is not set
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
-# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
-# CONFIG_BLK_DEV_INITRD is not set
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+CONFIG_RD_LZMA=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-# CONFIG_SYSCTL is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_UID16 is not set
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
-# CONFIG_HOTPLUG is not set
+# CONFIG_STRIP_ASM_SYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
+CONFIG_AIO=y
 CONFIG_VM_EVENT_COUNTERS=y
-CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
-# CONFIG_NP2 is not set
+CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
-CONFIG_RT_MUTEXES=y
-CONFIG_TINY_SHMEM=y
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_SLOW_WORK is not set
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
 CONFIG_BASE_SMALL=0
-
-#
-# Loadable module support
-#
 CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
-
-#
-# Block layer
-#
 CONFIG_BLOCK=y
 # CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
 
 #
 # IO Schedulers
@@ -105,6 +122,7 @@ CONFIG_DEFAULT_IOSCHED="noop"
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
+# CONFIG_FREEZER is not set
 
 #
 # Blackfin Processor Options
@@ -113,6 +131,10 @@ CONFIG_PREEMPT_NONE=y
 #
 # Processor and Board Settings
 #
+# CONFIG_BF512 is not set
+# CONFIG_BF514 is not set
+# CONFIG_BF516 is not set
+# CONFIG_BF518 is not set
 # CONFIG_BF522 is not set
 # CONFIG_BF523 is not set
 # CONFIG_BF524 is not set
@@ -125,22 +147,31 @@ CONFIG_PREEMPT_NONE=y
 # CONFIG_BF534 is not set
 # CONFIG_BF536 is not set
 CONFIG_BF537=y
+# CONFIG_BF538 is not set
+# CONFIG_BF539 is not set
 # CONFIG_BF542 is not set
+# CONFIG_BF542M is not set
 # CONFIG_BF544 is not set
+# CONFIG_BF544M is not set
 # CONFIG_BF547 is not set
+# CONFIG_BF547M is not set
 # CONFIG_BF548 is not set
+# CONFIG_BF548M is not set
 # CONFIG_BF549 is not set
+# CONFIG_BF549M is not set
 # CONFIG_BF561 is not set
+CONFIG_BF_REV_MIN=2
+CONFIG_BF_REV_MAX=3
 # CONFIG_BF_REV_0_0 is not set
 # CONFIG_BF_REV_0_1 is not set
 CONFIG_BF_REV_0_2=y
 # CONFIG_BF_REV_0_3 is not set
 # CONFIG_BF_REV_0_4 is not set
 # CONFIG_BF_REV_0_5 is not set
+# CONFIG_BF_REV_0_6 is not set
 # CONFIG_BF_REV_ANY is not set
 # CONFIG_BF_REV_NONE is not set
 CONFIG_BF53x=y
-CONFIG_BFIN_SINGLE_CORE=y
 CONFIG_MEM_MT48LC16M16A2TG_75=y
 CONFIG_IRQ_PLL_WAKEUP=7
 CONFIG_IRQ_RTC=8
@@ -150,7 +181,6 @@ CONFIG_IRQ_SPORT0_TX=9
 CONFIG_IRQ_SPORT1_RX=9
 CONFIG_IRQ_SPORT1_TX=9
 CONFIG_IRQ_TWI=10
-CONFIG_IRQ_SPI=10
 CONFIG_IRQ_UART0_RX=10
 CONFIG_IRQ_UART0_TX=10
 CONFIG_IRQ_UART1_RX=10
@@ -169,11 +199,13 @@ CONFIG_IRQ_PORTG_INTB=12
 CONFIG_IRQ_MEM_DMA0=13
 CONFIG_IRQ_MEM_DMA1=13
 CONFIG_IRQ_WATCH=13
+CONFIG_IRQ_SPI=10
 # CONFIG_BFIN537_STAMP is not set
-CONFIG_BFIN537_BLUETECHNIX_CM=y
+# CONFIG_BFIN537_BLUETECHNIX_CM_E is not set
+CONFIG_BFIN537_BLUETECHNIX_CM_U=y
+# CONFIG_BFIN537_BLUETECHNIX_TCM is not set
 # CONFIG_PNAV10 is not set
 # CONFIG_CAMSIG_MINOTAUR is not set
-# CONFIG_GENERIC_BF537_BOARD is not set
 
 #
 # BF537 Specific Configuration
@@ -196,6 +228,7 @@ CONFIG_IRQ_PROG_INTA=12
 # Board customizations
 #
 # CONFIG_CMDLINE_BOOL is not set
+CONFIG_BOOT_LOAD=0x1000
 
 #
 # Clock/PLL Setup
@@ -215,13 +248,20 @@ CONFIG_HZ_250=y
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
 CONFIG_HZ=250
+# CONFIG_SCHED_HRTICK is not set
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_TICKSOURCE_GPTMR0 is not set
+CONFIG_TICKSOURCE_CORETMR=y
+# CONFIG_CYCLES_CLOCKSOURCE is not set
+# CONFIG_GPTMR0_CLOCKSOURCE is not set
+# CONFIG_NO_HZ is not set
+# CONFIG_HIGH_RES_TIMERS is not set
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
 
 #
-# Memory Setup
+# Misc
 #
-CONFIG_MAX_MEM_SIZE=32
-CONFIG_MEM_ADD_WIDTH=9
-CONFIG_BOOT_LOAD=0x1000
 CONFIG_BFIN_SCRATCH_REG_RETN=y
 # CONFIG_BFIN_SCRATCH_REG_RETE is not set
 # CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
@@ -248,6 +288,12 @@ CONFIG_IP_CHECKSUM_L1=y
 CONFIG_CACHELINE_ALIGNED_L1=y
 CONFIG_SYSCALL_TAB_L1=y
 CONFIG_CPLB_SWITCH_TAB_L1=y
+CONFIG_APP_STACK_L1=y
+
+#
+# Speed Optimizations
+#
+CONFIG_BFIN_INS_LOWOVERHEAD=y
 CONFIG_RAMKERNEL=y
 # CONFIG_ROMKERNEL is not set
 CONFIG_SELECT_MEMORY_MODEL=y
@@ -256,12 +302,16 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
-CONFIG_LARGE_ALLOCS=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_UNEVICTABLE_LRU=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 # CONFIG_BFIN_GPTIMERS is not set
+# CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
 CONFIG_DMA_UNCACHED_1M=y
 # CONFIG_DMA_UNCACHED_NONE is not set
@@ -270,10 +320,9 @@ CONFIG_DMA_UNCACHED_1M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
 CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
@@ -284,7 +333,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -309,12 +358,8 @@ CONFIG_BANK_3=0xFFC2
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ARCH_SUPPORTS_MSI is not set
-
-#
-# PCCARD (PCMCIA/CardBus) support
-#
+# CONFIG_PCCARD is not set
 
 #
 # Executable file formats
@@ -323,22 +368,19 @@ CONFIG_BINFMT_ELF_FDPIC=y
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_ZFLAT=y
 CONFIG_BINFMT_SHARED_FLAT=y
+# CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
 
 #
 # Power management options
 #
 # CONFIG_PM is not set
-# CONFIG_PM_WAKEUP_BY_GPIO is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
 # CPU Frequency scaling
 #
 # CONFIG_CPU_FREQ is not set
-
-#
-# Networking
-#
 CONFIG_NET=y
 
 #
@@ -347,10 +389,6 @@ CONFIG_NET=y
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-# CONFIG_XFRM_MIGRATE is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -369,15 +407,13 @@ CONFIG_IP_FIB_HASH=y
 # CONFIG_INET_XFRM_MODE_TRANSPORT is not set
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
+CONFIG_INET_LRO=y
 # CONFIG_INET_DIAG is not set
-CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TCP_MD5SIG is not set
 # CONFIG_IPV6 is not set
-# CONFIG_INET6_XFRM_TUNNEL is not set
-# CONFIG_INET6_TUNNEL is not set
 # CONFIG_NETLABEL is not set
 # CONFIG_NETWORK_SECMARK is not set
 # CONFIG_NETFILTER is not set
@@ -386,6 +422,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
 # CONFIG_VLAN_8021Q is not set
 # CONFIG_DECNET is not set
 # CONFIG_LLC2 is not set
@@ -395,29 +432,23 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
+# CONFIG_PHONET is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
-
-#
-# Wireless
-#
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
 
 #
 # Device Drivers
@@ -426,20 +457,22 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 #
 # Generic Driver Options
 #
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
 # CONFIG_SYS_HYPERVISOR is not set
-
-#
-# Connector - unified userspace <-> kernelspace linker
-#
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
 
 #
 # User Modules And Translation Layers
@@ -452,12 +485,15 @@ CONFIG_MTD_BLOCK=y
 # CONFIG_INFTL is not set
 # CONFIG_RFD_FTL is not set
 # CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
 
 #
 # RAM/ROM/Flash chip drivers
 #
-# CONFIG_MTD_CFI is not set
+CONFIG_MTD_CFI=y
 # CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
 CONFIG_MTD_MAP_BANK_WIDTH_1=y
 CONFIG_MTD_MAP_BANK_WIDTH_2=y
 CONFIG_MTD_MAP_BANK_WIDTH_4=y
@@ -468,20 +504,29 @@ CONFIG_MTD_CFI_I1=y
 CONFIG_MTD_CFI_I2=y
 # CONFIG_MTD_CFI_I4 is not set
 # CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+# CONFIG_MTD_PSD4256G is not set
+CONFIG_MTD_CFI_UTIL=y
 CONFIG_MTD_RAM=y
-# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ROM=m
 # CONFIG_MTD_ABSENT is not set
 
 #
 # Mapping drivers for chip access
 #
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-CONFIG_MTD_UCLINUX=y
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+# CONFIG_MTD_PHYSMAP is not set
+CONFIG_MTD_GPIO_ADDR=y
+# CONFIG_MTD_UCLINUX is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -497,36 +542,36 @@ CONFIG_MTD_UCLINUX=y
 # CONFIG_MTD_ONENAND is not set
 
 #
-# UBI - Unsorted block images
+# LPDDR flash memory drivers
 #
-# CONFIG_MTD_UBI is not set
+# CONFIG_MTD_LPDDR is not set
 
 #
-# Parallel port support
+# UBI - Unsorted block images
 #
+# CONFIG_MTD_UBI is not set
 # CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNPACPI is not set
-
-#
-# Block devices
-#
+CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
 # CONFIG_BLK_DEV_LOOP is not set
 # CONFIG_BLK_DEV_NBD is not set
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+# CONFIG_BLK_DEV_XIP is not set
 # CONFIG_CDROM_PKTCDVD is not set
 # CONFIG_ATA_OVER_ETH is not set
+# CONFIG_BLK_DEV_HD is not set
+CONFIG_MISC_DEVICES=y
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_C2PORT is not set
 
 #
-# Misc devices
+# EEPROM support
 #
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_93CX6 is not set
+CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set
 
 #
@@ -534,35 +579,20 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 #
 # CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
 # CONFIG_SCSI_NETLINK is not set
 # CONFIG_ATA is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
 # CONFIG_MD is not set
-
-#
-# Network device support
-#
 CONFIG_NETDEVICES=y
+CONFIG_COMPAT_NET_DEV_OPS=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
-# CONFIG_PHYLIB is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-CONFIG_SMC91X=y
-# CONFIG_BFIN_MAC is not set
-# CONFIG_SMSC911X is not set
-# CONFIG_DM9000 is not set
+# CONFIG_VETH is not set
+# CONFIG_NET_ETHERNET is not set
 # CONFIG_NETDEV_1000 is not set
-# CONFIG_AX88180 is not set
 # CONFIG_NETDEV_10000 is not set
 
 #
@@ -570,22 +600,17 @@ CONFIG_SMC91X=y
 #
 # CONFIG_WLAN_PRE80211 is not set
 # CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
 # CONFIG_WAN is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
 # CONFIG_NETPOLL is not set
 # CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
 # CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
 # CONFIG_PHONE is not set
 
 #
@@ -602,16 +627,15 @@ CONFIG_SMC91X=y
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
-# CONFIG_SPI_ADC_BF533 is not set
-# CONFIG_BF5xx_PFLAGS is not set
-# CONFIG_BF5xx_PPIFCD is not set
+CONFIG_BFIN_DMA_INTERFACE=m
+# CONFIG_BFIN_PPI is not set
+# CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
-# CONFIG_BF5xx_PPI is not set
+# CONFIG_BFIN_SPI_ADC is not set
 CONFIG_BFIN_SPORT=y
-# CONFIG_BFIN_TIMER_LATENCY is not set
 # CONFIG_VT is not set
 # CONFIG_DEVKMEM is not set
+# CONFIG_BFIN_JTAG_COMM is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -622,6 +646,7 @@ CONFIG_BFIN_SPORT=y
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
 CONFIG_SERIAL_BFIN_DMA=y
@@ -634,165 +659,201 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 
 #
 # CAN, the car bus and industrial fieldbus
 #
 # CONFIG_CAN4LINUX is not set
-
-#
-# IPMI
-#
 # CONFIG_IPMI_HANDLER is not set
-# CONFIG_WATCHDOG is not set
 # CONFIG_HW_RANDOM is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_R3964 is not set
 # CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+# CONFIG_I2C is not set
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
 
 #
-# TPM devices
+# SPI Master Controller Drivers
 #
-# CONFIG_TCG_TPM is not set
-# CONFIG_I2C is not set
+CONFIG_SPI_BFIN=y
+# CONFIG_SPI_BFIN_LOCK is not set
+# CONFIG_SPI_BFIN_SPORT is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
+#
+# SPI Protocol Masters
+#
+# CONFIG_SPI_SPIDEV is not set
+# CONFIG_SPI_TLE62X0 is not set
 CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_SYSFS=y
 
 #
-# SPI support
+# Memory mapped GPIO expanders:
+#
+
+#
+# I2C GPIO expanders:
 #
-# CONFIG_SPI is not set
-# CONFIG_SPI_MASTER is not set
 
 #
-# Dallas's 1-wire bus
+# PCI GPIO expanders:
 #
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
 # CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
 CONFIG_HWMON=y
 # CONFIG_HWMON_VID is not set
-# CONFIG_SENSORS_ABITUGURU is not set
+# CONFIG_SENSORS_ADCXX is not set
 # CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_F71882FG is not set
+# CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM70 is not set
+# CONFIG_SENSORS_MAX1111 is not set
+# CONFIG_SENSORS_PC87360 is not set
 # CONFIG_SENSORS_PC87427 is not set
+# CONFIG_SENSORS_SHT15 is not set
 # CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_SMSC47B397 is not set
 # CONFIG_SENSORS_VT1211 is not set
 # CONFIG_SENSORS_W83627HF is not set
+# CONFIG_SENSORS_W83627EHF is not set
 # CONFIG_HWMON_DEBUG_CHIP is not set
+# CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
 
 #
 # Multifunction device drivers
 #
+# CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_REGULATOR is not set
 
 #
 # Multimedia devices
 #
+
+#
+# Multimedia core support
+#
 # CONFIG_VIDEO_DEV is not set
 # CONFIG_DVB_CORE is not set
-# CONFIG_DAB is not set
+# CONFIG_VIDEO_MEDIA is not set
 
 #
-# Graphics support
+# Multimedia drivers
 #
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+# CONFIG_DAB is not set
 
 #
-# Display device support
+# Graphics support
 #
-# CONFIG_DISPLAY_SUPPORT is not set
 # CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
 # CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
-# Sound
+# Display device support
 #
+# CONFIG_DISPLAY_SUPPORT is not set
 # CONFIG_SOUND is not set
-
-#
-# USB support
-#
+CONFIG_USB_SUPPORT=y
 CONFIG_USB_ARCH_HAS_HCD=y
 # CONFIG_USB_ARCH_HAS_OHCI is not set
 # CONFIG_USB_ARCH_HAS_EHCI is not set
 # CONFIG_USB is not set
-# CONFIG_USB_MUSB_HDRC is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
 # CONFIG_USB_GADGET_MUSB_HDRC is not set
 
 #
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
-
-#
-# USB Gadget Support
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 CONFIG_USB_GADGET=y
 # CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
 CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_ATMEL_USBA is not set
 # CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
 CONFIG_USB_GADGET_NET2272=y
 CONFIG_USB_NET2272=y
 # CONFIG_USB_GADGET_NET2280 is not set
-# CONFIG_USB_GADGET_PXA2XX is not set
 # CONFIG_USB_GADGET_GOKU is not set
-# CONFIG_USB_GADGET_LH7A40X is not set
-# CONFIG_USB_GADGET_OMAP is not set
-# CONFIG_USB_GADGET_AT91 is not set
 # CONFIG_USB_GADGET_DUMMY_HCD is not set
 CONFIG_USB_GADGET_DUALSPEED=y
 # CONFIG_USB_ZERO is not set
-# CONFIG_USB_ETH is not set
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=y
+CONFIG_USB_ETH_RNDIS=y
 # CONFIG_USB_GADGETFS is not set
 # CONFIG_USB_FILE_STORAGE is not set
 # CONFIG_USB_G_SERIAL is not set
 # CONFIG_USB_MIDI_GADGET is not set
-# CONFIG_MMC is not set
-
-#
-# LED devices
-#
-# CONFIG_NEW_LEDS is not set
-
-#
-# LED drivers
-#
-
-#
-# LED Triggers
-#
+# CONFIG_USB_G_PRINTER is not set
+# CONFIG_USB_CDC_COMPOSITE is not set
 
 #
-# InfiniBand support
+# OTG and related infrastructure
 #
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
 
 #
-# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+# MMC/SD/SDIO Card Drivers
 #
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
 
 #
-# Real Time Clock
+# MMC/SD/SDIO Host Controller Drivers
 #
+# CONFIG_MMC_SDHCI is not set
+CONFIG_MMC_SPI=m
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
 # CONFIG_RTC_CLASS is not set
-
-#
-# DMA Engine support
-#
-# CONFIG_DMA_ENGINE is not set
-
-#
-# DMA Clients
-#
-
-#
-# DMA Devices
-#
-
-#
-# PBX support
-#
-# CONFIG_PBX is not set
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+# CONFIG_STAGING is not set
 
 #
 # File systems
@@ -802,24 +863,28 @@ CONFIG_EXT2_FS_XATTR=y
 # CONFIG_EXT2_FS_POSIX_ACL is not set
 # CONFIG_EXT2_FS_SECURITY is not set
 # CONFIG_EXT3_FS is not set
-# CONFIG_EXT4DEV_FS is not set
+# CONFIG_EXT4_FS is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
-# CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
+# CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
-# CONFIG_DNOTIFY is not set
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
@@ -829,8 +894,11 @@ CONFIG_INOTIFY_USER=y
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # CONFIG_NTFS_FS is not set
 
 #
@@ -841,12 +909,8 @@ CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -854,18 +918,29 @@ CONFIG_RAMFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-# CONFIG_YAFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
 # CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
+# CONFIG_NILFS2_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
 # CONFIG_NFS_FS is not set
 # CONFIG_NFSD is not set
 # CONFIG_SMB_FS is not set
@@ -873,41 +948,94 @@ CONFIG_RAMFS=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
-# CONFIG_9P_FS is not set
 
 #
 # Partition Types
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Distributed Lock Manager
-#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
 # CONFIG_DLM is not set
 
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
 #
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
 # CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
 # CONFIG_DEBUG_KERNEL is not set
-CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+
+#
+# Tracers
+#
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+# CONFIG_EVENT_TRACER is not set
+# CONFIG_BOOT_TRACER is not set
+# CONFIG_TRACE_BRANCH_PROFILING is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_DEBUG_VERBOSE=y
 CONFIG_DEBUG_MMRS=y
+# CONFIG_DEBUG_DOUBLEFAULT is not set
 CONFIG_DEBUG_HUNT_FOR_ZERO=y
 CONFIG_DEBUG_BFIN_HWTRACE_ON=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
@@ -916,34 +1044,40 @@ CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
 # CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
 # CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
-# CONFIG_EARLY_PRINTK is not set
+CONFIG_EARLY_PRINTK=y
 CONFIG_CPLB_INFO=y
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
 #
 # CONFIG_KEYS is not set
 CONFIG_SECURITY=y
+# CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_NETWORK is not set
-CONFIG_SECURITY_CAPABILITIES=y
-
-#
-# Cryptographic options
-#
+# CONFIG_SECURITY_PATH is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+# CONFIG_SECURITY_TOMOYO is not set
 # CONFIG_CRYPTO is not set
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
-# CONFIG_CRC_ITU_T is not set
+# CONFIG_CRC_T10DIF is not set
+CONFIG_CRC_ITU_T=y
 CONFIG_CRC32=y
+CONFIG_CRC7=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
-CONFIG_PLIST=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_LZMA=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index acca4e51a45a12ba1f005d5347d3c1dcb6ad04c9..7f579cf51127810791ac5c0d94477714aad7e0ed 100644 (file)
@@ -1,14 +1,14 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.24.4
+# Linux kernel version: 2.6.30.5
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
-CONFIG_SEMAPHORE_SLEEPERS=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_HARDIRQS=y
@@ -16,6 +16,9 @@ CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
@@ -26,79 +29,100 @@ CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+CONFIG_KERNEL_LZMA=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
-# CONFIG_USER_NS is not set
-# CONFIG_PID_NS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_GROUP_SCHED is not set
 # CONFIG_CGROUPS is not set
-CONFIG_FAIR_GROUP_SCHED=y
-CONFIG_FAIR_USER_SCHED=y
-# CONFIG_FAIR_CGROUP_SCHED is not set
-# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
+# CONFIG_NAMESPACES is not set
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+CONFIG_RD_LZMA=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-# CONFIG_SYSCTL is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
-CONFIG_UID16=y
+# CONFIG_UID16 is not set
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
+# CONFIG_STRIP_ASM_SYMS is not set
 CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
+CONFIG_AIO=y
 CONFIG_VM_EVENT_COUNTERS=y
-CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
-# CONFIG_NP2 is not set
+CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_SLOW_WORK is not set
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
-CONFIG_RT_MUTEXES=y
-CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
 # CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
 # CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
 
 #
 # IO Schedulers
 #
 CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
+# CONFIG_IOSCHED_AS is not set
 # CONFIG_IOSCHED_DEADLINE is not set
 CONFIG_IOSCHED_CFQ=y
-CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_AS is not set
 # CONFIG_DEFAULT_DEADLINE is not set
 # CONFIG_DEFAULT_CFQ is not set
-# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="anticipatory"
-# CONFIG_PREEMPT_NONE is not set
-CONFIG_PREEMPT_VOLUNTARY=y
+CONFIG_DEFAULT_NOOP=y
+CONFIG_DEFAULT_IOSCHED="noop"
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
+# CONFIG_FREEZER is not set
 
 #
 # Blackfin Processor Options
@@ -107,6 +131,10 @@ CONFIG_PREEMPT_VOLUNTARY=y
 #
 # Processor and Board Settings
 #
+# CONFIG_BF512 is not set
+# CONFIG_BF514 is not set
+# CONFIG_BF516 is not set
+# CONFIG_BF518 is not set
 # CONFIG_BF522 is not set
 # CONFIG_BF523 is not set
 # CONFIG_BF524 is not set
@@ -119,19 +147,29 @@ CONFIG_PREEMPT_VOLUNTARY=y
 # CONFIG_BF534 is not set
 # CONFIG_BF536 is not set
 # CONFIG_BF537 is not set
+# CONFIG_BF538 is not set
+# CONFIG_BF539 is not set
 # CONFIG_BF542 is not set
+# CONFIG_BF542M is not set
 # CONFIG_BF544 is not set
+# CONFIG_BF544M is not set
 # CONFIG_BF547 is not set
-CONFIG_BF548=y
+# CONFIG_BF547M is not set
+CONFIG_BF548_std=y
+# CONFIG_BF548M is not set
 # CONFIG_BF549 is not set
+# CONFIG_BF549M is not set
 # CONFIG_BF561 is not set
+CONFIG_BF_REV_MIN=0
+CONFIG_BF_REV_MAX=2
 # CONFIG_BF_REV_0_0 is not set
 # CONFIG_BF_REV_0_1 is not set
-CONFIG_BF_REV_0_2=y
+# CONFIG_BF_REV_0_2 is not set
 # CONFIG_BF_REV_0_3 is not set
 # CONFIG_BF_REV_0_4 is not set
 # CONFIG_BF_REV_0_5 is not set
-# CONFIG_BF_REV_ANY is not set
+# CONFIG_BF_REV_0_6 is not set
+CONFIG_BF_REV_ANY=y
 # CONFIG_BF_REV_NONE is not set
 CONFIG_BF54x=y
 CONFIG_IRQ_PLL_WAKEUP=7
@@ -140,15 +178,12 @@ CONFIG_IRQ_SPORT0_RX=9
 CONFIG_IRQ_SPORT0_TX=9
 CONFIG_IRQ_SPORT1_RX=9
 CONFIG_IRQ_SPORT1_TX=9
+CONFIG_IRQ_SPI0=10
 CONFIG_IRQ_UART0_RX=10
 CONFIG_IRQ_UART0_TX=10
 CONFIG_IRQ_UART1_RX=10
 CONFIG_IRQ_UART1_TX=10
 CONFIG_IRQ_CNT=8
-CONFIG_IRQ_USB_INT0=11
-CONFIG_IRQ_USB_INT1=11
-CONFIG_IRQ_USB_INT2=11
-CONFIG_IRQ_USB_DMA=11
 CONFIG_IRQ_TIMER0=11
 CONFIG_IRQ_TIMER1=11
 CONFIG_IRQ_TIMER2=11
@@ -157,9 +192,21 @@ CONFIG_IRQ_TIMER4=11
 CONFIG_IRQ_TIMER5=11
 CONFIG_IRQ_TIMER6=11
 CONFIG_IRQ_TIMER7=11
+CONFIG_IRQ_USB_INT0=11
+CONFIG_IRQ_USB_INT1=11
+CONFIG_IRQ_USB_INT2=11
+CONFIG_IRQ_USB_DMA=11
 CONFIG_IRQ_TIMER8=11
 CONFIG_IRQ_TIMER9=11
 CONFIG_IRQ_TIMER10=11
+CONFIG_IRQ_SPORT2_RX=9
+CONFIG_IRQ_SPORT2_TX=9
+CONFIG_IRQ_SPORT3_RX=9
+CONFIG_IRQ_SPORT3_TX=9
+CONFIG_IRQ_SPI1=10
+CONFIG_IRQ_SPI2=10
+CONFIG_IRQ_TWI0=11
+CONFIG_IRQ_TWI1=11
 # CONFIG_BFIN548_EZKIT is not set
 CONFIG_BFIN548_BLUETECHNIX_CM=y
 
@@ -167,6 +214,7 @@ CONFIG_BFIN548_BLUETECHNIX_CM=y
 # BF548 Specific Configuration
 #
 # CONFIG_DEB_DMA_URGENT is not set
+# CONFIG_BF548_ATAPI_ALTERNATIVE_PORT is not set
 
 #
 # Interrupt Priority Assignment
@@ -182,7 +230,6 @@ CONFIG_IRQ_SPORT1_ERR=7
 CONFIG_IRQ_SPI0_ERR=7
 CONFIG_IRQ_UART0_ERR=7
 CONFIG_IRQ_EPPI0=8
-CONFIG_IRQ_SPI0=10
 CONFIG_IRQ_PINT0=12
 CONFIG_IRQ_PINT1=12
 CONFIG_IRQ_MDMAS0=13
@@ -197,18 +244,10 @@ CONFIG_IRQ_SPI2_ERR=7
 CONFIG_IRQ_UART1_ERR=7
 CONFIG_IRQ_UART2_ERR=7
 CONFIG_IRQ_CAN0_ERR=7
-CONFIG_IRQ_SPORT2_RX=9
-CONFIG_IRQ_SPORT2_TX=9
-CONFIG_IRQ_SPORT3_RX=9
-CONFIG_IRQ_SPORT3_TX=9
 CONFIG_IRQ_EPPI1=9
 CONFIG_IRQ_EPPI2=9
-CONFIG_IRQ_SPI1=10
-CONFIG_IRQ_SPI2=10
 CONFIG_IRQ_ATAPI_RX=10
 CONFIG_IRQ_ATAPI_TX=10
-CONFIG_IRQ_TWI0=11
-CONFIG_IRQ_TWI1=11
 CONFIG_IRQ_CAN0_RX=11
 CONFIG_IRQ_CAN0_TX=11
 CONFIG_IRQ_MDMAS2=13
@@ -255,6 +294,7 @@ CONFIG_PINT3_ASSIGN=0x02020303
 # Board customizations
 #
 # CONFIG_CMDLINE_BOOL is not set
+CONFIG_BOOT_LOAD=0x1000
 
 #
 # Clock/PLL Setup
@@ -274,16 +314,12 @@ CONFIG_HZ_250=y
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
 CONFIG_HZ=250
+# CONFIG_SCHED_HRTICK is not set
 # CONFIG_GENERIC_TIME is not set
-# CONFIG_TICK_ONESHOT is not set
 
 #
-# Memory Setup
+# Misc
 #
-CONFIG_MAX_MEM_SIZE=64
-# CONFIG_MEM_MT46V32M16_6T is not set
-CONFIG_MEM_MT46V32M16_5B=y
-CONFIG_BOOT_LOAD=0x1000
 CONFIG_BFIN_SCRATCH_REG_RETN=y
 # CONFIG_BFIN_SCRATCH_REG_RETE is not set
 # CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
@@ -310,6 +346,12 @@ CONFIG_ACCESS_OK_L1=y
 CONFIG_CACHELINE_ALIGNED_L1=y
 # CONFIG_SYSCALL_TAB_L1 is not set
 # CONFIG_CPLB_SWITCH_TAB_L1 is not set
+CONFIG_APP_STACK_L1=y
+
+#
+# Speed Optimizations
+#
+CONFIG_BFIN_INS_LOWOVERHEAD=y
 CONFIG_RAMKERNEL=y
 # CONFIG_ROMKERNEL is not set
 CONFIG_SELECT_MEMORY_MODEL=y
@@ -318,13 +360,16 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_UNEVICTABLE_LRU=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 # CONFIG_BFIN_GPTIMERS is not set
+# CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
 CONFIG_DMA_UNCACHED_1M=y
 # CONFIG_DMA_UNCACHED_NONE is not set
@@ -333,14 +378,13 @@ CONFIG_DMA_UNCACHED_1M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
+# CONFIG_BFIN_L2_ICACHEABLE is not set
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
-CONFIG_BFIN_EXTMEM_WRITEBACK=y
-# CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
-# CONFIG_BFIN_L2_ICACHEABLE is not set
+# CONFIG_BFIN_EXTMEM_WRITEBACK
+CONFIG_BFIN_EXTMEM_WRITETHROUGH=y
 # CONFIG_BFIN_L2_DCACHEABLE is not set
 
 #
@@ -349,7 +393,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -369,7 +413,7 @@ CONFIG_C_AMBEN_ALL=y
 CONFIG_BANK_0=0x7BB0
 CONFIG_BANK_1=0x5554
 CONFIG_BANK_2=0x7BB0
-CONFIG_BANK_3=0x99B2
+CONFIG_BANK_3=0x99B3
 CONFIG_EBIU_MBSCTLVAL=0x0
 CONFIG_EBIU_MODEVAL=0x1
 CONFIG_EBIU_FCTLVAL=0x6
@@ -377,7 +421,6 @@ CONFIG_EBIU_FCTLVAL=0x6
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ARCH_SUPPORTS_MSI is not set
 # CONFIG_PCCARD is not set
 
@@ -388,23 +431,19 @@ CONFIG_BINFMT_ELF_FDPIC=y
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_ZFLAT=y
 # CONFIG_BINFMT_SHARED_FLAT is not set
+# CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
 
 #
 # Power management options
 #
 # CONFIG_PM is not set
-CONFIG_SUSPEND_UP_POSSIBLE=y
-# CONFIG_PM_WAKEUP_BY_GPIO is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
 # CPU Frequency scaling
 #
 # CONFIG_CPU_FREQ is not set
-
-#
-# Networking
-#
 CONFIG_NET=y
 
 #
@@ -417,6 +456,7 @@ CONFIG_XFRM=y
 # CONFIG_XFRM_USER is not set
 # CONFIG_XFRM_SUB_POLICY is not set
 # CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -435,19 +475,16 @@ CONFIG_IP_PNP=y
 # CONFIG_INET_IPCOMP is not set
 # CONFIG_INET_XFRM_TUNNEL is not set
 # CONFIG_INET_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
 # CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
-CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TCP_MD5SIG is not set
 # CONFIG_IPV6 is not set
-# CONFIG_INET6_XFRM_TUNNEL is not set
-# CONFIG_INET6_TUNNEL is not set
 # CONFIG_NETLABEL is not set
 # CONFIG_NETWORK_SECMARK is not set
 # CONFIG_NETFILTER is not set
@@ -456,6 +493,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
 # CONFIG_VLAN_8021Q is not set
 # CONFIG_DECNET is not set
 # CONFIG_LLC2 is not set
@@ -465,24 +503,21 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
-
-#
-# Wireless
-#
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -501,10 +536,12 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
 CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
 
 #
 # User Modules And Translation Layers
@@ -539,6 +576,7 @@ CONFIG_MTD_CFI_I2=y
 CONFIG_MTD_CFI_INTELEXT=y
 # CONFIG_MTD_CFI_AMDSTD is not set
 # CONFIG_MTD_CFI_STAA is not set
+# CONFIG_MTD_PSD4256G is not set
 CONFIG_MTD_CFI_UTIL=y
 CONFIG_MTD_RAM=y
 # CONFIG_MTD_ROM is not set
@@ -549,9 +587,8 @@ CONFIG_MTD_RAM=y
 #
 CONFIG_MTD_COMPLEX_MAPPINGS=y
 CONFIG_MTD_PHYSMAP=y
-CONFIG_MTD_PHYSMAP_START=0x20000000
-CONFIG_MTD_PHYSMAP_LEN=0
-CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_GPIO_ADDR is not set
 # CONFIG_MTD_UCLINUX is not set
 # CONFIG_MTD_PLATRAM is not set
 
@@ -574,6 +611,11 @@ CONFIG_MTD_PHYSMAP_BANKWIDTH=2
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -587,31 +629,31 @@ CONFIG_BLK_DEV=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+# CONFIG_BLK_DEV_XIP is not set
 # CONFIG_CDROM_PKTCDVD is not set
 # CONFIG_ATA_OVER_ETH is not set
-CONFIG_MISC_DEVICES=y
-# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_BLK_DEV_HD is not set
+# CONFIG_MISC_DEVICES is not set
+CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set
 
 #
 # SCSI device support
 #
 # CONFIG_RAID_ATTRS is not set
-CONFIG_SCSI=y
+CONFIG_SCSI=m
 CONFIG_SCSI_DMA=y
 # CONFIG_SCSI_TGT is not set
 # CONFIG_SCSI_NETLINK is not set
-# CONFIG_SCSI_PROC_FS is not set
+CONFIG_SCSI_PROC_FS=y
 
 #
 # SCSI support type (disk, tape, CD-ROM)
 #
-CONFIG_BLK_DEV_SD=y
+CONFIG_BLK_DEV_SD=m
 # CONFIG_CHR_DEV_ST is not set
 # CONFIG_CHR_DEV_OSST is not set
-CONFIG_BLK_DEV_SR=y
-# CONFIG_BLK_DEV_SR_VENDOR is not set
+# CONFIG_BLK_DEV_SR is not set
 # CONFIG_CHR_DEV_SG is not set
 # CONFIG_CHR_DEV_SCH is not set
 
@@ -632,29 +674,54 @@ CONFIG_SCSI_WAIT_SCAN=m
 # CONFIG_SCSI_ISCSI_ATTRS is not set
 # CONFIG_SCSI_SAS_LIBSAS is not set
 # CONFIG_SCSI_SRP_ATTRS is not set
-CONFIG_SCSI_LOWLEVEL=y
-# CONFIG_ISCSI_TCP is not set
-# CONFIG_SCSI_DEBUG is not set
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
 # CONFIG_ATA is not set
 # CONFIG_MD is not set
 CONFIG_NETDEVICES=y
-# CONFIG_NETDEVICES_MULTIQUEUE is not set
+CONFIG_COMPAT_NET_DEV_OPS=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_MACVLAN is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 # CONFIG_VETH is not set
-# CONFIG_PHYLIB is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=y
 # CONFIG_SMC91X is not set
-CONFIG_SMSC911X=y
 # CONFIG_DM9000 is not set
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+CONFIG_SMSC911X=y
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
 # CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
 # CONFIG_NETDEV_1000 is not set
 # CONFIG_NETDEV_10000 is not set
@@ -665,6 +732,10 @@ CONFIG_SMSC911X=y
 # CONFIG_WLAN_PRE80211 is not set
 # CONFIG_WLAN_80211 is not set
 
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+
 #
 # USB Network Adapters
 #
@@ -676,7 +747,6 @@ CONFIG_SMSC911X=y
 # CONFIG_WAN is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
 # CONFIG_NETPOLL is not set
 # CONFIG_NET_POLL_CONTROLLER is not set
@@ -711,6 +781,7 @@ CONFIG_INPUT_KEYBOARD=y
 # CONFIG_KEYBOARD_GPIO is not set
 # CONFIG_KEYBOARD_BFIN is not set
 # CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_ADP5588 is not set
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TABLET is not set
@@ -726,19 +797,16 @@ CONFIG_INPUT_KEYBOARD=y
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
-# CONFIG_SPI_ADC_BF533 is not set
-# CONFIG_BF5xx_PPIFCD is not set
+CONFIG_BFIN_DMA_INTERFACE=m
+# CONFIG_BFIN_PPI is not set
+# CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
-# CONFIG_BF5xx_PPI is not set
-CONFIG_BFIN_OTP=y
-# CONFIG_BFIN_OTP_WRITE_ENABLE is not set
+# CONFIG_BFIN_SPI_ADC is not set
 # CONFIG_BFIN_SPORT is not set
-# CONFIG_BFIN_TIMER_LATENCY is not set
-# CONFIG_TWI_LCD is not set
-# CONFIG_SIMPLE_GPIO is not set
+# CONFIG_BFIN_TWI_LCD is not set
 # CONFIG_VT is not set
-# CONFIG_DEVKMEM is not set
+CONFIG_DEVKMEM=y
+# CONFIG_BFIN_JTAG_COMM is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -749,10 +817,11 @@ CONFIG_BFIN_OTP=y
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
-CONFIG_SERIAL_BFIN_DMA=y
-# CONFIG_SERIAL_BFIN_PIO is not set
+# CONFIG_SERIAL_BFIN_DMA is not set
+CONFIG_SERIAL_BFIN_PIO=y
 # CONFIG_SERIAL_BFIN_UART0 is not set
 CONFIG_SERIAL_BFIN_UART1=y
 # CONFIG_BFIN_UART1_CTSRTS is not set
@@ -762,7 +831,10 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
+CONFIG_BFIN_OTP=y
+# CONFIG_BFIN_OTP_WRITE_ENABLE is not set
 
 #
 # CAN, the car bus and industrial fieldbus
@@ -770,61 +842,53 @@ CONFIG_UNIX98_PTYS=y
 # CONFIG_CAN4LINUX is not set
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_R3964 is not set
 # CONFIG_RAW_DRIVER is not set
 # CONFIG_TCG_TPM is not set
 CONFIG_I2C=y
 CONFIG_I2C_BOARDINFO=y
 CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_HELPER_AUTO=y
 
 #
-# I2C Algorithms
+# I2C Hardware Bus support
 #
-# CONFIG_I2C_ALGOBIT is not set
-# CONFIG_I2C_ALGOPCF is not set
-# CONFIG_I2C_ALGOPCA is not set
 
 #
-# I2C Hardware Bus support
+# I2C system bus drivers (mostly embedded / system-on-chip)
 #
 CONFIG_I2C_BLACKFIN_TWI=y
-CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100
+CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=50
 # CONFIG_I2C_GPIO is not set
 # CONFIG_I2C_OCORES is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_TAOS_EVM is not set
-# CONFIG_I2C_STUB is not set
 # CONFIG_I2C_TINY_USB is not set
 
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_STUB is not set
+
 #
 # Miscellaneous I2C Chip support
 #
-# CONFIG_SENSORS_DS1337 is not set
-# CONFIG_SENSORS_DS1374 is not set
 # CONFIG_DS1682 is not set
-# CONFIG_SENSORS_AD5252 is not set
-# CONFIG_EEPROM_LEGACY is not set
 # CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_SENSORS_PCF8575 is not set
-# CONFIG_SENSORS_PCA9543 is not set
+# CONFIG_PCF8575 is not set
 # CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
 # CONFIG_SENSORS_MAX6875 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
 # CONFIG_I2C_DEBUG_BUS is not set
 # CONFIG_I2C_DEBUG_CHIP is not set
-
-CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
-CONFIG_GPIOLIB=y
-CONFIG_GPIO_SYSFS=y
-
-#
-# SPI support
-#
 CONFIG_SPI=y
 CONFIG_SPI_MASTER=y
 
@@ -832,64 +896,23 @@ CONFIG_SPI_MASTER=y
 # SPI Master Controller Drivers
 #
 CONFIG_SPI_BFIN=y
+# CONFIG_SPI_BFIN_LOCK is not set
+# CONFIG_SPI_BFIN_SPORT is not set
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 # CONFIG_SPI_SPIDEV is not set
 # CONFIG_SPI_TLE62X0 is not set
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+# CONFIG_GPIOLIB is not set
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
-CONFIG_HWMON=y
-# CONFIG_HWMON_VID is not set
-# CONFIG_SENSORS_AD7418 is not set
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_ADM1025 is not set
-# CONFIG_SENSORS_ADM1026 is not set
-# CONFIG_SENSORS_ADM1029 is not set
-# CONFIG_SENSORS_ADM1031 is not set
-# CONFIG_SENSORS_ADM9240 is not set
-# CONFIG_SENSORS_ADT7470 is not set
-# CONFIG_SENSORS_ATXP1 is not set
-# CONFIG_SENSORS_DS1621 is not set
-# CONFIG_SENSORS_F71805F is not set
-# CONFIG_SENSORS_F71882FG is not set
-# CONFIG_SENSORS_F75375S is not set
-# CONFIG_SENSORS_GL518SM is not set
-# CONFIG_SENSORS_GL520SM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM63 is not set
-# CONFIG_SENSORS_LM70 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM77 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM80 is not set
-# CONFIG_SENSORS_LM83 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_LM87 is not set
-# CONFIG_SENSORS_LM90 is not set
-# CONFIG_SENSORS_LM92 is not set
-# CONFIG_SENSORS_LM93 is not set
-# CONFIG_SENSORS_MAX1619 is not set
-# CONFIG_SENSORS_MAX6650 is not set
-# CONFIG_SENSORS_PC87360 is not set
-# CONFIG_SENSORS_PC87427 is not set
-# CONFIG_SENSORS_DME1737 is not set
-# CONFIG_SENSORS_SMSC47M1 is not set
-# CONFIG_SENSORS_SMSC47M192 is not set
-# CONFIG_SENSORS_SMSC47B397 is not set
-# CONFIG_SENSORS_THMC50 is not set
-# CONFIG_SENSORS_VT1211 is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_SENSORS_W83791D is not set
-# CONFIG_SENSORS_W83792D is not set
-# CONFIG_SENSORS_W83793 is not set
-# CONFIG_SENSORS_W83L785TS is not set
-# CONFIG_SENSORS_W83627HF is not set
-# CONFIG_SENSORS_W83627EHF is not set
-# CONFIG_HWMON_DEBUG_CHIP is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
 CONFIG_WATCHDOG=y
 # CONFIG_WATCHDOG_NOWAYOUT is not set
 
@@ -903,25 +926,43 @@ CONFIG_BFIN_WDT=y
 # USB-based Watchdog Cards
 #
 # CONFIG_USBPCWATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
 
 #
 # Sonics Silicon Backplane
 #
-CONFIG_SSB_POSSIBLE=y
 # CONFIG_SSB is not set
 
 #
 # Multifunction device drivers
 #
+# CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_PMIC_ADP5520 is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_REGULATOR is not set
 
 #
 # Multimedia devices
 #
+
+#
+# Multimedia core support
+#
 # CONFIG_VIDEO_DEV is not set
 # CONFIG_DVB_CORE is not set
+# CONFIG_VIDEO_MEDIA is not set
+
+#
+# Multimedia drivers
+#
 # CONFIG_DAB is not set
-# CONFIG_USB_DABUSB is not set
 
 #
 # Graphics support
@@ -935,80 +976,75 @@ CONFIG_SSB_POSSIBLE=y
 # Display device support
 #
 # CONFIG_DISPLAY_SUPPORT is not set
-
-#
-# Sound
-#
 # CONFIG_SOUND is not set
-CONFIG_HID_SUPPORT=y
-CONFIG_HID=y
-# CONFIG_HID_DEBUG is not set
-# CONFIG_HIDRAW is not set
-
-#
-# USB Input Devices
-#
-CONFIG_USB_HID=y
-# CONFIG_USB_HIDINPUT_POWERBOOK is not set
-# CONFIG_HID_FF is not set
-# CONFIG_USB_HIDDEV is not set
+# CONFIG_HID_SUPPORT is not set
 CONFIG_USB_SUPPORT=y
 CONFIG_USB_ARCH_HAS_HCD=y
 # CONFIG_USB_ARCH_HAS_OHCI is not set
 # CONFIG_USB_ARCH_HAS_EHCI is not set
-CONFIG_USB=y
+CONFIG_USB=m
 # CONFIG_USB_DEBUG is not set
+# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
 
 #
 # Miscellaneous USB options
 #
-# CONFIG_USB_DEVICEFS is not set
-CONFIG_USB_DEVICE_CLASS=y
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
 # CONFIG_USB_OTG is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+CONFIG_USB_MON=m
+# CONFIG_USB_WUSB is not set
+# CONFIG_USB_WUSB_CBAF is not set
 
 #
 # USB Host Controller Drivers
 #
+# CONFIG_USB_C67X00_HCD is not set
+# CONFIG_USB_OXU210HP_HCD is not set
 # CONFIG_USB_ISP116X_HCD is not set
-# CONFIG_USB_ISP1362_HCD is not set
 # CONFIG_USB_ISP1760_HCD is not set
+# CONFIG_USB_ISP1362_HCD is not set
 # CONFIG_USB_SL811_HCD is not set
 # CONFIG_USB_R8A66597_HCD is not set
-CONFIG_USB_MUSB_HDRC=y
+# CONFIG_USB_HWA_HCD is not set
+CONFIG_USB_MUSB_HDRC=m
 CONFIG_USB_MUSB_SOC=y
 
 #
-# Blackfin BF54x, BF525 and BF527 high speed USB support
+# Blackfin high speed USB Support
 #
-CONFIG_USB_MUSB_HOST=y
-# CONFIG_USB_MUSB_PERIPHERAL is not set
+# CONFIG_USB_MUSB_HOST is not set
+CONFIG_USB_MUSB_PERIPHERAL=y
 # CONFIG_USB_MUSB_OTG is not set
-CONFIG_USB_MUSB_HDRC_HCD=y
+CONFIG_USB_GADGET_MUSB_HDRC=y
 # CONFIG_MUSB_PIO_ONLY is not set
-# CONFIG_USB_INVENTRA_DMA is not set
+CONFIG_USB_INVENTRA_DMA=y
 # CONFIG_USB_TI_CPPI_DMA is not set
-CONFIG_USB_MUSB_LOGLEVEL=0
+# CONFIG_USB_MUSB_DEBUG is not set
 
 #
 # USB Device Class drivers
 #
 # CONFIG_USB_ACM is not set
 # CONFIG_USB_PRINTER is not set
+# CONFIG_USB_WDM is not set
+# CONFIG_USB_TMC is not set
 
 #
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
 #
 
 #
-# may also be needed; see USB_STORAGE Help for more information
+# also be needed; see USB_STORAGE Help for more info
 #
-CONFIG_USB_STORAGE=y
+CONFIG_USB_STORAGE=m
 # CONFIG_USB_STORAGE_DEBUG is not set
 # CONFIG_USB_STORAGE_DATAFAB is not set
 # CONFIG_USB_STORAGE_FREECOM is not set
 # CONFIG_USB_STORAGE_ISD200 is not set
-# CONFIG_USB_STORAGE_DPCM is not set
 # CONFIG_USB_STORAGE_USBAT is not set
 # CONFIG_USB_STORAGE_SDDR09 is not set
 # CONFIG_USB_STORAGE_SDDR55 is not set
@@ -1016,6 +1052,7 @@ CONFIG_USB_STORAGE=y
 # CONFIG_USB_STORAGE_ALAUDA is not set
 # CONFIG_USB_STORAGE_ONETOUCH is not set
 # CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
 # CONFIG_USB_LIBUSUAL is not set
 
 #
@@ -1023,15 +1060,10 @@ CONFIG_USB_STORAGE=y
 #
 # CONFIG_USB_MDC800 is not set
 # CONFIG_USB_MICROTEK is not set
-CONFIG_USB_MON=y
 
 #
 # USB port drivers
 #
-
-#
-# USB Serial Converter support
-#
 # CONFIG_USB_SERIAL is not set
 
 #
@@ -1040,7 +1072,7 @@ CONFIG_USB_MON=y
 # CONFIG_USB_EMI62 is not set
 # CONFIG_USB_EMI26 is not set
 # CONFIG_USB_ADUTUX is not set
-# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_SEVSEG is not set
 # CONFIG_USB_RIO500 is not set
 # CONFIG_USB_LEGOTOWER is not set
 # CONFIG_USB_LCD is not set
@@ -1048,7 +1080,6 @@ CONFIG_USB_MON=y
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYPRESS_CY7C63 is not set
 # CONFIG_USB_CYTHERM is not set
-# CONFIG_USB_PHIDGET is not set
 # CONFIG_USB_IDMOUSE is not set
 # CONFIG_USB_FTDI_ELAN is not set
 # CONFIG_USB_APPLEDISPLAY is not set
@@ -1056,38 +1087,75 @@ CONFIG_USB_MON=y
 # CONFIG_USB_LD is not set
 # CONFIG_USB_TRANCEVIBRATOR is not set
 # CONFIG_USB_IOWARRIOR is not set
-
-#
-# USB DSL modem support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-CONFIG_MMC=y
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_ISIGHTFW is not set
+# CONFIG_USB_VST is not set
+CONFIG_USB_GADGET=m
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_ATMEL_USBA is not set
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+# CONFIG_USB_GADGET_NET2272 is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+CONFIG_USB_ZERO=m
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=m
+# CONFIG_USB_ETH_RNDIS is not set
+CONFIG_USB_GADGETFS=m
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+CONFIG_USB_G_SERIAL=m
+# CONFIG_USB_MIDI_GADGET is not set
+CONFIG_USB_G_PRINTER=m
+# CONFIG_USB_CDC_COMPOSITE is not set
+
+#
+# OTG and related infrastructure
+#
+CONFIG_USB_OTG_UTILS=y
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=m
 # CONFIG_MMC_DEBUG is not set
 # CONFIG_MMC_UNSAFE_RESUME is not set
 
 #
-# MMC/SD Card Drivers
+# MMC/SD/SDIO Card Drivers
 #
-CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK=m
 CONFIG_MMC_BLOCK_BOUNCE=y
 # CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
 
 #
-# MMC/SD Host Controller Drivers
+# MMC/SD/SDIO Host Controller Drivers
 #
-CONFIG_SDH_BFIN=y
+# CONFIG_MMC_SDHCI is not set
+CONFIG_SDH_BFIN=m
+# CONFIG_SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND is not set
+# CONFIG_SDH_BFIN_ENABLE_SDIO_IRQ is not set
 # CONFIG_MMC_SPI is not set
-# CONFIG_SPI_MMC is not set
+# CONFIG_MEMSTICK is not set
 # CONFIG_NEW_LEDS is not set
-CONFIG_RTC_LIB=y
-CONFIG_RTC_CLASS=y
-CONFIG_RTC_HCTOSYS=y
-CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
-# CONFIG_RTC_DEBUG is not set
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
 
 #
 # RTC interfaces
@@ -1111,66 +1179,74 @@ CONFIG_RTC_INTF_DEV=y
 # CONFIG_RTC_DRV_PCF8563 is not set
 # CONFIG_RTC_DRV_PCF8583 is not set
 # CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
 
 #
 # SPI RTC drivers
 #
-# CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_M41T94 is not set
+# CONFIG_RTC_DRV_DS1305 is not set
+# CONFIG_RTC_DRV_DS1390 is not set
 # CONFIG_RTC_DRV_MAX6902 is not set
+# CONFIG_RTC_DRV_R9701 is not set
+# CONFIG_RTC_DRV_RS5C348 is not set
+# CONFIG_RTC_DRV_DS3234 is not set
 
 #
 # Platform RTC drivers
 #
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
 # CONFIG_RTC_DRV_DS1553 is not set
-# CONFIG_RTC_DRV_STK17TA8 is not set
 # CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
 # CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
 # CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
 # CONFIG_RTC_DRV_V3020 is not set
 
 #
 # on-CPU RTC drivers
 #
-CONFIG_RTC_DRV_BFIN=y
-
-#
-# Userspace I/O
-#
+CONFIG_RTC_DRV_BFIN=m
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
-
-#
-# PBX support
-#
-# CONFIG_PBX is not set
+# CONFIG_STAGING is not set
 
 #
 # File systems
 #
-# CONFIG_EXT2_FS is not set
+CONFIG_EXT2_FS=m
+# CONFIG_EXT2_FS_XATTR is not set
 # CONFIG_EXT3_FS is not set
-# CONFIG_EXT4DEV_FS is not set
+# CONFIG_EXT4_FS is not set
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
-# CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_INOTIFY=y
-CONFIG_INOTIFY_USER=y
-# CONFIG_QUOTA is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
 # CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY is not set
+# CONFIG_QUOTA is not set
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
-CONFIG_ISO9660_FS=m
-CONFIG_JOLIET=y
-CONFIG_ZISOFS=y
+# CONFIG_ISO9660_FS is not set
 # CONFIG_UDF_FS is not set
 
 #
@@ -1194,10 +1270,7 @@ CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -1205,17 +1278,7 @@ CONFIG_SYSFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-CONFIG_YAFFS_FS=m
-CONFIG_YAFFS_YAFFS1=y
-# CONFIG_YAFFS_DOES_ECC is not set
-CONFIG_YAFFS_YAFFS2=y
-CONFIG_YAFFS_AUTO_YAFFS2=y
-# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set
-CONFIG_YAFFS_CHECKPOINT_RESERVED_BLOCKS=10
-# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set
-# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set
-CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y
-CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS=y
 CONFIG_JFFS2_FS_DEBUG=0
 CONFIG_JFFS2_FS_WRITEBUFFER=y
 # CONFIG_JFFS2_FS_WBUF_VERIFY is not set
@@ -1227,34 +1290,30 @@ CONFIG_JFFS2_ZLIB=y
 CONFIG_JFFS2_RTIME=y
 # CONFIG_JFFS2_RUBIN is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
 # CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
+# CONFIG_NILFS2_FS is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=m
 CONFIG_NFS_V3=y
 # CONFIG_NFS_V3_ACL is not set
 # CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-CONFIG_NFSD=m
-CONFIG_NFSD_V3=y
-# CONFIG_NFSD_V3_ACL is not set
-# CONFIG_NFSD_V4 is not set
-CONFIG_NFSD_TCP=y
+# CONFIG_NFSD is not set
 CONFIG_LOCKD=m
 CONFIG_LOCKD_V4=y
-CONFIG_EXPORTFS=m
 CONFIG_NFS_COMMON=y
 CONFIG_SUNRPC=m
-# CONFIG_SUNRPC_BIND34 is not set
 # CONFIG_RPCSEC_GSS_KRB5 is not set
 # CONFIG_RPCSEC_GSS_SPKM3 is not set
-CONFIG_SMB_FS=m
-CONFIG_SMB_NLS_DEFAULT=y
-CONFIG_SMB_NLS_REMOTE="cp437"
-CONFIG_CIFS=y
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
 # CONFIG_CIFS_STATS is not set
 # CONFIG_CIFS_WEAK_PW_HASH is not set
 # CONFIG_CIFS_XATTR is not set
@@ -1267,24 +1326,8 @@ CONFIG_CIFS=y
 #
 # Partition Types
 #
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
+# CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_KARMA_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-# CONFIG_SYSV68_PARTITION is not set
 CONFIG_NLS=y
 CONFIG_NLS_DEFAULT="iso8859-1"
 CONFIG_NLS_CODEPAGE_437=m
@@ -1326,9 +1369,6 @@ CONFIG_NLS_KOI8_R=m
 CONFIG_NLS_KOI8_U=m
 CONFIG_NLS_UTF8=m
 # CONFIG_DLM is not set
-CONFIG_INSTRUMENTATION=y
-# CONFIG_PROFILING is not set
-# CONFIG_MARKERS is not set
 
 #
 # Kernel hacking
@@ -1336,14 +1376,39 @@ CONFIG_INSTRUMENTATION=y
 # CONFIG_PRINTK_TIME is not set
 CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
 # CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
 # CONFIG_DEBUG_KERNEL is not set
-CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+
+#
+# Tracers
+#
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+# CONFIG_EVENT_TRACER is not set
+# CONFIG_BOOT_TRACER is not set
+# CONFIG_TRACE_BRANCH_PROFILING is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
-CONFIG_DEBUG_MMRS=y
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_DEBUG_VERBOSE=y
+# CONFIG_DEBUG_MMRS is not set
+# CONFIG_DEBUG_DOUBLEFAULT is not set
 CONFIG_DEBUG_HUNT_FOR_ZERO=y
 CONFIG_DEBUG_BFIN_HWTRACE_ON=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
@@ -1352,33 +1417,125 @@ CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
 # CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
 # CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
-# CONFIG_EARLY_PRINTK is not set
+CONFIG_EARLY_PRINTK=y
 CONFIG_CPLB_INFO=y
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
 #
 # CONFIG_KEYS is not set
 CONFIG_SECURITY=y
+# CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_NETWORK is not set
-# CONFIG_SECURITY_CAPABILITIES is not set
-# CONFIG_SECURITY_ROOTPLUG is not set
-# CONFIG_CRYPTO is not set
+# CONFIG_SECURITY_PATH is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+# CONFIG_SECURITY_TOMOYO is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
+# CONFIG_CRYPTO_MANAGER is not set
+# CONFIG_CRYPTO_MANAGER2 is not set
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_CRYPTD is not set
+# CONFIG_CRYPTO_AUTHENC is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+# CONFIG_CRYPTO_CBC is not set
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+# CONFIG_CRYPTO_ECB is not set
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_XCBC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_MD4 is not set
+# CONFIG_CRYPTO_MD5 is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+# CONFIG_CRYPTO_HW is not set
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
 # CONFIG_CRC_ITU_T is not set
 CONFIG_CRC32=y
 # CONFIG_CRC7 is not set
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=m
-CONFIG_PLIST=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_LZMA=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index bae4ee6e68bbaf1471b9e8f96857516fbbf7388e..a6df01dac98a51431e37578166dcc6f985e181bf 100644 (file)
@@ -1,15 +1,14 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.24.4
-# Tue Apr  1 10:50:11 2008
+# Linux kernel version: 2.6.30.5
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
-CONFIG_SEMAPHORE_SLEEPERS=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_HARDIRQS=y
@@ -17,6 +16,9 @@ CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
@@ -27,62 +29,83 @@ CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+CONFIG_KERNEL_LZMA=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
-# CONFIG_USER_NS is not set
-# CONFIG_PID_NS is not set
 # CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
+# CONFIG_GROUP_SCHED is not set
 # CONFIG_CGROUPS is not set
-CONFIG_FAIR_GROUP_SCHED=y
-CONFIG_FAIR_USER_SCHED=y
-# CONFIG_FAIR_CGROUP_SCHED is not set
-# CONFIG_SYSFS_DEPRECATED is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
-# CONFIG_BLK_DEV_INITRD is not set
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+CONFIG_RD_LZMA=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-# CONFIG_SYSCTL is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_UID16 is not set
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
-# CONFIG_HOTPLUG is not set
+# CONFIG_STRIP_ASM_SYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
-CONFIG_SIGNALFD=y
-CONFIG_EVENTFD=y
+# CONFIG_SIGNALFD is not set
+# CONFIG_TIMERFD is not set
+# CONFIG_EVENTFD is not set
+# CONFIG_AIO is not set
 CONFIG_VM_EVENT_COUNTERS=y
-CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
-# CONFIG_NP2 is not set
+CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_SLOW_WORK is not set
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
-CONFIG_RT_MUTEXES=y
-CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
 # CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
 # CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
 
 #
 # IO Schedulers
@@ -99,6 +122,7 @@ CONFIG_DEFAULT_IOSCHED="noop"
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
+# CONFIG_FREEZER is not set
 
 #
 # Blackfin Processor Options
@@ -107,6 +131,10 @@ CONFIG_PREEMPT_NONE=y
 #
 # Processor and Board Settings
 #
+# CONFIG_BF512 is not set
+# CONFIG_BF514 is not set
+# CONFIG_BF516 is not set
+# CONFIG_BF518 is not set
 # CONFIG_BF522 is not set
 # CONFIG_BF523 is not set
 # CONFIG_BF524 is not set
@@ -119,44 +147,56 @@ CONFIG_PREEMPT_NONE=y
 # CONFIG_BF534 is not set
 # CONFIG_BF536 is not set
 # CONFIG_BF537 is not set
+# CONFIG_BF538 is not set
+# CONFIG_BF539 is not set
 # CONFIG_BF542 is not set
+# CONFIG_BF542M is not set
 # CONFIG_BF544 is not set
+# CONFIG_BF544M is not set
 # CONFIG_BF547 is not set
+# CONFIG_BF547M is not set
 # CONFIG_BF548 is not set
+# CONFIG_BF548M is not set
 # CONFIG_BF549 is not set
+# CONFIG_BF549M is not set
 CONFIG_BF561=y
+# CONFIG_SMP is not set
+CONFIG_BF_REV_MIN=3
+CONFIG_BF_REV_MAX=5
 # CONFIG_BF_REV_0_0 is not set
 # CONFIG_BF_REV_0_1 is not set
 # CONFIG_BF_REV_0_2 is not set
 CONFIG_BF_REV_0_3=y
 # CONFIG_BF_REV_0_4 is not set
 # CONFIG_BF_REV_0_5 is not set
+# CONFIG_BF_REV_0_6 is not set
 # CONFIG_BF_REV_ANY is not set
 # CONFIG_BF_REV_NONE is not set
-CONFIG_BFIN_DUAL_CORE=y
 CONFIG_MEM_MT48LC8M32B2B5_7=y
 CONFIG_IRQ_PLL_WAKEUP=7
 CONFIG_IRQ_SPORT0_ERROR=7
 CONFIG_IRQ_SPORT1_ERROR=7
+CONFIG_IRQ_TIMER0=10
+CONFIG_IRQ_TIMER1=10
+CONFIG_IRQ_TIMER2=10
+CONFIG_IRQ_TIMER3=10
+CONFIG_IRQ_TIMER4=10
+CONFIG_IRQ_TIMER5=10
+CONFIG_IRQ_TIMER6=10
+CONFIG_IRQ_TIMER7=10
 CONFIG_IRQ_SPI_ERROR=7
 # CONFIG_BFIN561_EZKIT is not set
 # CONFIG_BFIN561_TEPLA is not set
 CONFIG_BFIN561_BLUETECHNIX_CM=y
-# CONFIG_GENERIC_BF561_BOARD is not set
 
 #
 # BF561 Specific Configuration
 #
 
-#
-# Core B Support
-#
-
 #
 # Core B Support
 #
 CONFIG_BF561_COREB=y
-# CONFIG_BF561_COREB_RESET is not set
 
 #
 # Interrupt Priority Assignment
@@ -196,14 +236,6 @@ CONFIG_IRQ_DMA2_8=9
 CONFIG_IRQ_DMA2_9=9
 CONFIG_IRQ_DMA2_10=9
 CONFIG_IRQ_DMA2_11=9
-CONFIG_IRQ_TIMER0=10
-CONFIG_IRQ_TIMER1=10
-CONFIG_IRQ_TIMER2=10
-CONFIG_IRQ_TIMER3=10
-CONFIG_IRQ_TIMER4=10
-CONFIG_IRQ_TIMER5=10
-CONFIG_IRQ_TIMER6=10
-CONFIG_IRQ_TIMER7=10
 CONFIG_IRQ_TIMER8=10
 CONFIG_IRQ_TIMER9=10
 CONFIG_IRQ_TIMER10=10
@@ -226,6 +258,7 @@ CONFIG_IRQ_WDTIMER=13
 # Board customizations
 #
 # CONFIG_CMDLINE_BOOL is not set
+CONFIG_BOOT_LOAD=0x1000
 
 #
 # Clock/PLL Setup
@@ -245,19 +278,20 @@ CONFIG_HZ_250=y
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
 CONFIG_HZ=250
+# CONFIG_SCHED_HRTICK is not set
 CONFIG_GENERIC_TIME=y
 CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_TICKSOURCE_GPTMR0 is not set
+CONFIG_TICKSOURCE_CORETMR=y
 # CONFIG_CYCLES_CLOCKSOURCE is not set
-# CONFIG_TICK_ONESHOT is not set
+# CONFIG_GPTMR0_CLOCKSOURCE is not set
 # CONFIG_NO_HZ is not set
 # CONFIG_HIGH_RES_TIMERS is not set
 CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
 
 #
-# Memory Setup
+# Misc
 #
-CONFIG_MAX_MEM_SIZE=32
-CONFIG_BOOT_LOAD=0x1000
 CONFIG_BFIN_SCRATCH_REG_RETN=y
 # CONFIG_BFIN_SCRATCH_REG_RETE is not set
 # CONFIG_BFIN_SCRATCH_REG_CYCLES is not set
@@ -284,6 +318,12 @@ CONFIG_IP_CHECKSUM_L1=y
 CONFIG_CACHELINE_ALIGNED_L1=y
 CONFIG_SYSCALL_TAB_L1=y
 CONFIG_CPLB_SWITCH_TAB_L1=y
+CONFIG_APP_STACK_L1=y
+
+#
+# Speed Optimizations
+#
+CONFIG_BFIN_INS_LOWOVERHEAD=y
 CONFIG_RAMKERNEL=y
 # CONFIG_ROMKERNEL is not set
 CONFIG_SELECT_MEMORY_MODEL=y
@@ -292,14 +332,16 @@ CONFIG_FLATMEM_MANUAL=y
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
-CONFIG_LARGE_ALLOCS=y
+CONFIG_UNEVICTABLE_LRU=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 # CONFIG_BFIN_GPTIMERS is not set
+# CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
 CONFIG_DMA_UNCACHED_1M=y
 # CONFIG_DMA_UNCACHED_NONE is not set
@@ -308,15 +350,16 @@ CONFIG_DMA_UNCACHED_1M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
+# CONFIG_BFIN_L2_ICACHEABLE is not set
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
-CONFIG_BFIN_EXTMEM_WRITEBACK=y
-# CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
-# CONFIG_BFIN_L2_ICACHEABLE is not set
+# CONFIG_BFIN_EXTMEM_WRITEBACK is not set
+CONFIG_BFIN_EXTMEM_WRITETHROUGH=y
 # CONFIG_BFIN_L2_DCACHEABLE is not set
+# CONFIG_BFIN_L2_WRITEBACK is not set
+# CONFIG_BFIN_L2_WRITETHROUGH is not set
 
 #
 # Memory Protection Unit
@@ -324,7 +367,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -353,8 +396,8 @@ CONFIG_BANK_3=0xFFC2
 #
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
-# CONFIG_PCI is not set
 # CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
 
 #
 # Executable file formats
@@ -363,18 +406,19 @@ CONFIG_BINFMT_ELF_FDPIC=y
 CONFIG_BINFMT_FLAT=y
 CONFIG_BINFMT_ZFLAT=y
 CONFIG_BINFMT_SHARED_FLAT=y
+# CONFIG_HAVE_AOUT is not set
 # CONFIG_BINFMT_MISC is not set
 
 #
 # Power management options
 #
 # CONFIG_PM is not set
-CONFIG_SUSPEND_UP_POSSIBLE=y
-# CONFIG_PM_WAKEUP_BY_GPIO is not set
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
 
 #
-# Networking
+# CPU Frequency scaling
 #
+# CONFIG_CPU_FREQ is not set
 CONFIG_NET=y
 
 #
@@ -383,10 +427,6 @@ CONFIG_NET=y
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-# CONFIG_XFRM_MIGRATE is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -407,14 +447,11 @@ CONFIG_IP_FIB_HASH=y
 # CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_INET_LRO is not set
 # CONFIG_INET_DIAG is not set
-CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
 CONFIG_TCP_CONG_CUBIC=y
 CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TCP_MD5SIG is not set
 # CONFIG_IPV6 is not set
-# CONFIG_INET6_XFRM_TUNNEL is not set
-# CONFIG_INET6_TUNNEL is not set
 # CONFIG_NETLABEL is not set
 # CONFIG_NETWORK_SECMARK is not set
 # CONFIG_NETFILTER is not set
@@ -423,6 +460,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
 # CONFIG_VLAN_8021Q is not set
 # CONFIG_DECNET is not set
 # CONFIG_LLC2 is not set
@@ -432,24 +470,21 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 # CONFIG_LAPB is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
 # CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
 
 #
 # Network testing
 #
 # CONFIG_NET_PKTGEN is not set
 # CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
 # CONFIG_IRDA is not set
 # CONFIG_BT is not set
 # CONFIG_AF_RXRPC is not set
-
-#
-# Wireless
-#
-# CONFIG_CFG80211 is not set
-# CONFIG_WIRELESS_EXT is not set
-# CONFIG_MAC80211 is not set
-# CONFIG_IEEE80211 is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 # CONFIG_NET_9P is not set
 
@@ -460,16 +495,22 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
 #
 # Generic Driver Options
 #
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
 # CONFIG_SYS_HYPERVISOR is not set
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
 
 #
 # User Modules And Translation Layers
@@ -487,8 +528,10 @@ CONFIG_MTD_BLOCK=y
 #
 # RAM/ROM/Flash chip drivers
 #
-# CONFIG_MTD_CFI is not set
+CONFIG_MTD_CFI=y
 # CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
 CONFIG_MTD_MAP_BANK_WIDTH_1=y
 CONFIG_MTD_MAP_BANK_WIDTH_2=y
 CONFIG_MTD_MAP_BANK_WIDTH_4=y
@@ -499,20 +542,29 @@ CONFIG_MTD_CFI_I1=y
 CONFIG_MTD_CFI_I2=y
 # CONFIG_MTD_CFI_I4 is not set
 # CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+# CONFIG_MTD_PSD4256G is not set
+CONFIG_MTD_CFI_UTIL=y
 CONFIG_MTD_RAM=y
-# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ROM=m
 # CONFIG_MTD_ABSENT is not set
 
 #
 # Mapping drivers for chip access
 #
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
-CONFIG_MTD_UCLINUX=y
+CONFIG_MTD_PHYSMAP=y
+# CONFIG_MTD_PHYSMAP_COMPAT is not set
+# CONFIG_MTD_UCLINUX is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
 # Self-contained MTD device drivers
 #
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -527,6 +579,11 @@ CONFIG_MTD_UCLINUX=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -539,14 +596,21 @@ CONFIG_BLK_DEV=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
+# CONFIG_BLK_DEV_XIP is not set
 # CONFIG_CDROM_PKTCDVD is not set
 # CONFIG_ATA_OVER_ETH is not set
+# CONFIG_BLK_DEV_HD is not set
 CONFIG_MISC_DEVICES=y
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT25 is not set
 # CONFIG_EEPROM_93CX6 is not set
+CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set
-# CONFIG_BFIN_IDE_ADDRESS_MAPPING_MODE0 is not set
-# CONFIG_BFIN_IDE_ADDRESS_MAPPING_MODE1 is not set
 
 #
 # SCSI device support
@@ -558,26 +622,50 @@ CONFIG_MISC_DEVICES=y
 # CONFIG_ATA is not set
 # CONFIG_MD is not set
 CONFIG_NETDEVICES=y
-# CONFIG_NETDEVICES_MULTIQUEUE is not set
+CONFIG_COMPAT_NET_DEV_OPS=y
 # CONFIG_DUMMY is not set
 # CONFIG_BONDING is not set
 # CONFIG_MACVLAN is not set
 # CONFIG_EQUALIZER is not set
 # CONFIG_TUN is not set
 # CONFIG_VETH is not set
-# CONFIG_PHYLIB is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=y
-CONFIG_SMC91X=y
-# CONFIG_SMSC911X is not set
+# CONFIG_SMC91X is not set
 # CONFIG_DM9000 is not set
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+CONFIG_SMSC911X=m
+# CONFIG_DNET is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
 # CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
 # CONFIG_B44 is not set
 # CONFIG_NETDEV_1000 is not set
-# CONFIG_AX88180 is not set
 # CONFIG_NETDEV_10000 is not set
 
 #
@@ -585,10 +673,13 @@ CONFIG_SMC91X=y
 #
 # CONFIG_WLAN_PRE80211 is not set
 # CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
 # CONFIG_WAN is not set
 # CONFIG_PPP is not set
 # CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
 # CONFIG_NETCONSOLE is not set
 # CONFIG_NETPOLL is not set
 # CONFIG_NET_POLL_CONTROLLER is not set
@@ -609,16 +700,15 @@ CONFIG_SMC91X=y
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
-# CONFIG_SPI_ADC_BF533 is not set
-# CONFIG_BF5xx_PPIFCD is not set
+CONFIG_BFIN_DMA_INTERFACE=m
+# CONFIG_BFIN_PPI is not set
+# CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
-# CONFIG_BF5xx_PPI is not set
+# CONFIG_BFIN_SPI_ADC is not set
 # CONFIG_BFIN_SPORT is not set
-# CONFIG_BFIN_TIMER_LATENCY is not set
-# CONFIG_SIMPLE_GPIO is not set
 # CONFIG_VT is not set
 # CONFIG_DEVKMEM is not set
+# CONFIG_BFIN_JTAG_COMM is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -629,6 +719,7 @@ CONFIG_SMC91X=y
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
 CONFIG_SERIAL_BFIN_DMA=y
@@ -639,6 +730,7 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 
 #
@@ -647,54 +739,100 @@ CONFIG_UNIX98_PTYS=y
 # CONFIG_CAN4LINUX is not set
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_R3964 is not set
 # CONFIG_RAW_DRIVER is not set
 # CONFIG_TCG_TPM is not set
 # CONFIG_I2C is not set
+CONFIG_SPI=y
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BFIN=y
+# CONFIG_SPI_BFIN_LOCK is not set
+# CONFIG_SPI_BFIN_SPORT is not set
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
+#
+# SPI Protocol Masters
+#
+# CONFIG_SPI_SPIDEV is not set
+# CONFIG_SPI_TLE62X0 is not set
 CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_SYSFS=y
 
 #
-# SPI support
+# Memory mapped GPIO expanders:
+#
+
+#
+# I2C GPIO expanders:
+#
+
 #
-# CONFIG_SPI is not set
-# CONFIG_SPI_MASTER is not set
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+# CONFIG_GPIO_MAX7301 is not set
+# CONFIG_GPIO_MCP23S08 is not set
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 CONFIG_HWMON=y
 # CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ADCXX is not set
 # CONFIG_SENSORS_F71805F is not set
 # CONFIG_SENSORS_F71882FG is not set
 # CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_LM70 is not set
+# CONFIG_SENSORS_MAX1111 is not set
 # CONFIG_SENSORS_PC87360 is not set
 # CONFIG_SENSORS_PC87427 is not set
+# CONFIG_SENSORS_SHT15 is not set
 # CONFIG_SENSORS_SMSC47M1 is not set
 # CONFIG_SENSORS_SMSC47B397 is not set
 # CONFIG_SENSORS_VT1211 is not set
 # CONFIG_SENSORS_W83627HF is not set
 # CONFIG_SENSORS_W83627EHF is not set
 # CONFIG_HWMON_DEBUG_CHIP is not set
+# CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
 # CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
 
 #
 # Sonics Silicon Backplane
 #
-CONFIG_SSB_POSSIBLE=y
 # CONFIG_SSB is not set
 
 #
 # Multifunction device drivers
 #
+# CONFIG_MFD_CORE is not set
 # CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_REGULATOR is not set
 
 #
 # Multimedia devices
 #
+
+#
+# Multimedia core support
+#
 # CONFIG_VIDEO_DEV is not set
 # CONFIG_DVB_CORE is not set
+# CONFIG_VIDEO_MEDIA is not set
+
+#
+# Multimedia drivers
+#
 # CONFIG_DAB is not set
 
 #
@@ -709,42 +847,85 @@ CONFIG_SSB_POSSIBLE=y
 # Display device support
 #
 # CONFIG_DISPLAY_SUPPORT is not set
-
-#
-# Sound
-#
 # CONFIG_SOUND is not set
 CONFIG_USB_SUPPORT=y
 CONFIG_USB_ARCH_HAS_HCD=y
 # CONFIG_USB_ARCH_HAS_OHCI is not set
 # CONFIG_USB_ARCH_HAS_EHCI is not set
 # CONFIG_USB is not set
-
-#
-# Enable Host or Gadget support to see Inventra options
-#
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-# CONFIG_MMC is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+CONFIG_USB_GADGET=m
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_ATMEL_USBA is not set
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+CONFIG_USB_GADGET_NET2272=y
+CONFIG_USB_NET2272=m
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=m
+CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_GADGETFS is not set
+CONFIG_USB_FILE_STORAGE=m
+# CONFIG_USB_FILE_STORAGE_TEST is not set
+CONFIG_USB_G_SERIAL=m
+# CONFIG_USB_MIDI_GADGET is not set
+CONFIG_USB_G_PRINTER=m
+# CONFIG_USB_CDC_COMPOSITE is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+CONFIG_MMC_SPI=m
+# CONFIG_MEMSTICK is not set
 # CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
 # CONFIG_RTC_CLASS is not set
-
-#
-# Userspace I/O
-#
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
-
-#
-# PBX support
-#
-# CONFIG_PBX is not set
+# CONFIG_STAGING is not set
 
 #
 # File systems
@@ -754,24 +935,28 @@ CONFIG_EXT2_FS_XATTR=y
 # CONFIG_EXT2_FS_POSIX_ACL is not set
 # CONFIG_EXT2_FS_SECURITY is not set
 # CONFIG_EXT3_FS is not set
-# CONFIG_EXT4DEV_FS is not set
+# CONFIG_EXT4_FS is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
-# CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
+# CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
-# CONFIG_DNOTIFY is not set
 # CONFIG_AUTOFS_FS is not set
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
@@ -781,8 +966,11 @@ CONFIG_INOTIFY_USER=y
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # CONFIG_NTFS_FS is not set
 
 #
@@ -794,10 +982,7 @@ CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -805,14 +990,28 @@ CONFIG_SYSFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-# CONFIG_YAFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
 # CONFIG_HPFS_FS is not set
 # CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
+# CONFIG_NILFS2_FS is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 # CONFIG_NFS_FS is not set
 # CONFIG_NFSD is not set
@@ -827,11 +1026,47 @@ CONFIG_NETWORK_FILESYSTEMS=y
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-# CONFIG_NLS is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
 # CONFIG_DLM is not set
-CONFIG_INSTRUMENTATION=y
-# CONFIG_PROFILING is not set
-# CONFIG_MARKERS is not set
 
 #
 # Kernel hacking
@@ -839,14 +1074,40 @@ CONFIG_INSTRUMENTATION=y
 # CONFIG_PRINTK_TIME is not set
 CONFIG_ENABLE_WARN_DEPRECATED=y
 CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
 # CONFIG_MAGIC_SYSRQ is not set
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
 # CONFIG_DEBUG_KERNEL is not set
-CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+
+#
+# Tracers
+#
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+# CONFIG_EVENT_TRACER is not set
+# CONFIG_BOOT_TRACER is not set
+# CONFIG_TRACE_BRANCH_PROFILING is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_DEBUG_VERBOSE=y
 CONFIG_DEBUG_MMRS=y
+# CONFIG_DEBUG_DOUBLEFAULT is not set
 CONFIG_DEBUG_HUNT_FOR_ZERO=y
 CONFIG_DEBUG_BFIN_HWTRACE_ON=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
@@ -855,33 +1116,40 @@ CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
 # CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
 # CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
-# CONFIG_EARLY_PRINTK is not set
-# CONFIG_DUAL_CORE_TEST_MODULE is not set
+CONFIG_EARLY_PRINTK=y
 CONFIG_CPLB_INFO=y
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
 #
 # CONFIG_KEYS is not set
 CONFIG_SECURITY=y
+# CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_NETWORK is not set
-CONFIG_SECURITY_CAPABILITIES=y
+# CONFIG_SECURITY_PATH is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
+# CONFIG_SECURITY_TOMOYO is not set
 # CONFIG_CRYPTO is not set
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
 CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
-# CONFIG_CRC_ITU_T is not set
+# CONFIG_CRC_T10DIF is not set
+CONFIG_CRC_ITU_T=y
 CONFIG_CRC32=y
-# CONFIG_CRC7 is not set
+CONFIG_CRC7=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
-CONFIG_PLIST=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_LZMA=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index a6a7c8ede70539c6e7ac5df4344ba0c07f05e069..bc7fae3d8b8327521ef23586bb03807ea4228e61 100644 (file)
@@ -67,6 +67,7 @@ CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 CONFIG_RT_MUTEXES=y
 CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
@@ -249,6 +250,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_RESOURCES_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_LARGE_ALLOCS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=y
 # CONFIG_DMA_UNCACHED_2M is not set
 CONFIG_DMA_UNCACHED_1M=y
index 1ec9ae2e964b816f17905cac2e70512e6a31aa4f..a7e49d63122907d7268fe2ed0d2ae773b90a12e3 100644 (file)
@@ -68,6 +68,7 @@ CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 CONFIG_RT_MUTEXES=y
 CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
@@ -261,6 +262,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_RESOURCES_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_LARGE_ALLOCS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 # CONFIG_BFIN_GPTIMERS is not set
 # CONFIG_DMA_UNCACHED_2M is not set
 CONFIG_DMA_UNCACHED_1M=y
index ff377fae061b9a6e113455a644c16493ac1ef46b..67d12768602a6760010d0f64366d2deb6140e747 100644 (file)
@@ -63,6 +63,7 @@ CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
@@ -285,6 +286,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_BFIN_GPTIMERS=y
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
index 814f9cacf407e029047fc9335976d5647253e55f..52bfa6bf18da7e85ec8cfeba308f964dd5dee0f0 100644 (file)
@@ -72,6 +72,7 @@ CONFIG_BIG_ORDER_ALLOC_NOFAIL_MAGIC=3
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 CONFIG_RT_MUTEXES=y
 CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
@@ -271,6 +272,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
 # CONFIG_RESOURCES_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_LARGE_ALLOCS=y
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 CONFIG_DMA_UNCACHED_2M=y
 # CONFIG_DMA_UNCACHED_1M is not set
 # CONFIG_DMA_UNCACHED_NONE is not set
@@ -700,7 +702,7 @@ CONFIG_INPUT_MISC=y
 # CONFIG_INPUT_YEALINK is not set
 CONFIG_INPUT_UINPUT=y
 # CONFIG_BF53X_PFBUTTONS is not set
-# CONFIG_TWI_KEYPAD is not set
+# CONFIG_INPUT_PCF8574 is not set
 
 #
 # Hardware I/O ports
index 375e75a27abc814be354aeec59a0dfa949997037..60adfad54db9b3d80102b220528929f208d9bffe 100644 (file)
@@ -1,13 +1,13 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.28-rc2
-# Tue Jan  6 09:22:17 2009
+# Linux kernel version: 2.6.30.5
 #
 # CONFIG_MMU is not set
 # CONFIG_FPU is not set
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
 CONFIG_BLACKFIN=y
+CONFIG_GENERIC_BUG=y
 CONFIG_ZONE_DMA=y
 CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
@@ -16,6 +16,9 @@ CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_GENERIC_GPIO=y
 CONFIG_FORCE_MAX_ZONEORDER=14
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
@@ -26,49 +29,72 @@ CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+CONFIG_KERNEL_LZMA=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
-# CONFIG_CGROUPS is not set
 # CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
 # CONFIG_SYSFS_DEPRECATED_V2 is not set
 # CONFIG_RELAY is not set
 # CONFIG_NAMESPACES is not set
-# CONFIG_BLK_DEV_INITRD is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+CONFIG_RD_LZMA=y
 # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
-# CONFIG_SYSCTL is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
 CONFIG_EMBEDDED=y
 # CONFIG_UID16 is not set
 # CONFIG_SYSCTL_SYSCALL is not set
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
-# CONFIG_HOTPLUG is not set
+# CONFIG_STRIP_ASM_SYMS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
-CONFIG_COMPAT_BRK=y
 CONFIG_BASE_FULL=y
 # CONFIG_FUTEX is not set
-CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SIGNALFD=y
 CONFIG_TIMERFD=y
 CONFIG_EVENTFD=y
 # CONFIG_AIO is not set
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_COMPAT_BRK=y
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
+CONFIG_MMAP_ALLOW_UNINITIALIZED=y
 # CONFIG_PROFILING is not set
 # CONFIG_MARKERS is not set
 CONFIG_HAVE_OPROFILE=y
+# CONFIG_SLOW_WORK is not set
 # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
 CONFIG_SLABINFO=y
-CONFIG_RT_MUTEXES=y
-CONFIG_TINY_SHMEM=y
 CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 # CONFIG_MODULE_FORCE_LOAD is not set
@@ -76,11 +102,8 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
 CONFIG_BLOCK=y
 # CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
 # CONFIG_BLK_DEV_BSG is not set
 # CONFIG_BLK_DEV_INTEGRITY is not set
 
@@ -96,7 +119,6 @@ CONFIG_IOSCHED_CFQ=y
 # CONFIG_DEFAULT_CFQ is not set
 CONFIG_DEFAULT_NOOP=y
 CONFIG_DEFAULT_IOSCHED="noop"
-CONFIG_CLASSIC_RCU=y
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
@@ -128,10 +150,15 @@ CONFIG_BF537=y
 # CONFIG_BF538 is not set
 # CONFIG_BF539 is not set
 # CONFIG_BF542 is not set
+# CONFIG_BF542M is not set
 # CONFIG_BF544 is not set
+# CONFIG_BF544M is not set
 # CONFIG_BF547 is not set
+# CONFIG_BF547M is not set
 # CONFIG_BF548 is not set
+# CONFIG_BF548M is not set
 # CONFIG_BF549 is not set
+# CONFIG_BF549M is not set
 # CONFIG_BF561 is not set
 CONFIG_BF_REV_MIN=2
 CONFIG_BF_REV_MAX=3
@@ -173,11 +200,11 @@ CONFIG_IRQ_MEM_DMA1=13
 CONFIG_IRQ_WATCH=13
 CONFIG_IRQ_SPI=10
 # CONFIG_BFIN537_STAMP is not set
-# CONFIG_BFIN537_BLUETECHNIX_CM is not set
+# CONFIG_BFIN537_BLUETECHNIX_CM_E is not set
+# CONFIG_BFIN537_BLUETECHNIX_CM_U is not set
 CONFIG_BFIN537_BLUETECHNIX_TCM=y
 # CONFIG_PNAV10 is not set
 # CONFIG_CAMSIG_MINOTAUR is not set
-# CONFIG_GENERIC_BF537_BOARD is not set
 
 #
 # BF537 Specific Configuration
@@ -223,7 +250,10 @@ CONFIG_HZ=250
 # CONFIG_SCHED_HRTICK is not set
 CONFIG_GENERIC_TIME=y
 CONFIG_GENERIC_CLOCKEVENTS=y
+# CONFIG_TICKSOURCE_GPTMR0 is not set
+CONFIG_TICKSOURCE_CORETMR=y
 # CONFIG_CYCLES_CLOCKSOURCE is not set
+# CONFIG_GPTMR0_CLOCKSOURCE is not set
 # CONFIG_NO_HZ is not set
 # CONFIG_HIGH_RES_TIMERS is not set
 CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
@@ -273,10 +303,12 @@ CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
 # CONFIG_PHYS_ADDR_T_64BIT is not set
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_VIRT_TO_BUS=y
+CONFIG_UNEVICTABLE_LRU=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_NOMMU_INITIAL_TRIM_EXCESS=0
 # CONFIG_BFIN_GPTIMERS is not set
 # CONFIG_DMA_UNCACHED_4M is not set
 # CONFIG_DMA_UNCACHED_2M is not set
@@ -287,10 +319,9 @@ CONFIG_DMA_UNCACHED_1M=y
 # Cache Support
 #
 CONFIG_BFIN_ICACHE=y
-# CONFIG_BFIN_ICACHE_LOCK is not set
+CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_DCACHE=y
 # CONFIG_BFIN_DCACHE_BANKA is not set
-CONFIG_BFIN_EXTMEM_ICACHEABLE=y
 CONFIG_BFIN_EXTMEM_DCACHEABLE=y
 CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_BFIN_EXTMEM_WRITETHROUGH is not set
@@ -301,7 +332,7 @@ CONFIG_BFIN_EXTMEM_WRITEBACK=y
 # CONFIG_MPU is not set
 
 #
-# Asynchonous Memory Configuration
+# Asynchronous Memory Configuration
 #
 
 #
@@ -327,6 +358,7 @@ CONFIG_BANK_3=0xFFC2
 # Bus options (PCI, PCMCIA, EISA, MCA, ISA)
 #
 # CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
 
 #
 # Executable file formats
@@ -343,13 +375,83 @@ CONFIG_BINFMT_SHARED_FLAT=y
 #
 # CONFIG_PM is not set
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
-# CONFIG_PM_WAKEUP_BY_GPIO is not set
 
 #
 # CPU Frequency scaling
 #
 # CONFIG_CPU_FREQ is not set
-# CONFIG_NET is not set
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
+CONFIG_INET_LRO=y
+# CONFIG_INET_DIAG is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
 
 #
 # Device Drivers
@@ -358,15 +460,21 @@ CONFIG_ARCH_SUSPEND_POSSIBLE=y
 #
 # Generic Driver Options
 #
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
 # CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
 CONFIG_MTD=y
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 CONFIG_MTD_PARTITIONS=y
 # CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
 # CONFIG_MTD_AR7_PARTS is not set
 
 #
@@ -402,9 +510,10 @@ CONFIG_MTD_CFI_I2=y
 CONFIG_MTD_CFI_INTELEXT=y
 # CONFIG_MTD_CFI_AMDSTD is not set
 # CONFIG_MTD_CFI_STAA is not set
+# CONFIG_MTD_PSD4256G is not set
 CONFIG_MTD_CFI_UTIL=y
 CONFIG_MTD_RAM=y
-# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ROM=m
 # CONFIG_MTD_ABSENT is not set
 
 #
@@ -413,7 +522,7 @@ CONFIG_MTD_RAM=y
 CONFIG_MTD_COMPLEX_MAPPINGS=y
 # CONFIG_MTD_PHYSMAP is not set
 CONFIG_MTD_GPIO_ADDR=y
-CONFIG_MTD_UCLINUX=y
+# CONFIG_MTD_UCLINUX is not set
 # CONFIG_MTD_PLATRAM is not set
 
 #
@@ -435,6 +544,11 @@ CONFIG_MTD_UCLINUX=y
 # CONFIG_MTD_NAND is not set
 # CONFIG_MTD_ONENAND is not set
 
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
 #
 # UBI - Unsorted block images
 #
@@ -443,15 +557,23 @@ CONFIG_MTD_UCLINUX=y
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
 # CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
 # CONFIG_BLK_DEV_XIP is not set
 # CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
 # CONFIG_BLK_DEV_HD is not set
 CONFIG_MISC_DEVICES=y
-# CONFIG_EEPROM_93CX6 is not set
 # CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT25 is not set
+# CONFIG_EEPROM_93CX6 is not set
 CONFIG_HAVE_IDE=y
 # CONFIG_IDE is not set
 
@@ -464,6 +586,74 @@ CONFIG_HAVE_IDE=y
 # CONFIG_SCSI_NETLINK is not set
 # CONFIG_ATA is not set
 # CONFIG_MD is not set
+CONFIG_NETDEVICES=y
+CONFIG_COMPAT_NET_DEV_OPS=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+# CONFIG_VITESSE_PHY is not set
+# CONFIG_SMSC_PHY is not set
+# CONFIG_BROADCOM_PHY is not set
+# CONFIG_ICPLUS_PHY is not set
+# CONFIG_REALTEK_PHY is not set
+# CONFIG_NATIONAL_PHY is not set
+# CONFIG_STE10XP is not set
+# CONFIG_LSI_ET1011C_PHY is not set
+# CONFIG_FIXED_PHY is not set
+# CONFIG_MDIO_BITBANG is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+CONFIG_BFIN_MAC=y
+CONFIG_BFIN_MAC_USE_L1=y
+CONFIG_BFIN_TX_DESC_NUM=10
+CONFIG_BFIN_RX_DESC_NUM=20
+# CONFIG_BFIN_MAC_RMII is not set
+# CONFIG_SMC91X is not set
+# CONFIG_DM9000 is not set
+# CONFIG_ENC28J60 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_SMSC911X is not set
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+
+#
+# Wireless LAN
+#
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
 # CONFIG_PHONE is not set
 
 #
@@ -480,15 +670,12 @@ CONFIG_HAVE_IDE=y
 #
 # Character devices
 #
-# CONFIG_AD9960 is not set
-# CONFIG_SPI_ADC_BF533 is not set
-# CONFIG_BF5xx_PPIFCD is not set
+CONFIG_BFIN_DMA_INTERFACE=m
+# CONFIG_BFIN_PPI is not set
+# CONFIG_BFIN_PPIFCD is not set
 # CONFIG_BFIN_SIMPLE_TIMER is not set
-# CONFIG_BF5xx_PPI is not set
+# CONFIG_BFIN_SPI_ADC is not set
 CONFIG_BFIN_SPORT=y
-# CONFIG_BFIN_TIMER_LATENCY is not set
-CONFIG_BFIN_DMA_INTERFACE=m
-# CONFIG_SIMPLE_GPIO is not set
 # CONFIG_VT is not set
 # CONFIG_DEVKMEM is not set
 # CONFIG_BFIN_JTAG_COMM is not set
@@ -502,6 +689,7 @@ CONFIG_BFIN_DMA_INTERFACE=m
 #
 # Non-8250 serial port support
 #
+# CONFIG_SERIAL_MAX3100 is not set
 CONFIG_SERIAL_BFIN=y
 CONFIG_SERIAL_BFIN_CONSOLE=y
 CONFIG_SERIAL_BFIN_DMA=y
@@ -514,6 +702,7 @@ CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
 # CONFIG_SERIAL_BFIN_SPORT is not set
 CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
 # CONFIG_LEGACY_PTYS is not set
 
 #
@@ -534,39 +723,17 @@ CONFIG_SPI_MASTER=y
 #
 CONFIG_SPI_BFIN=y
 # CONFIG_SPI_BFIN_LOCK is not set
+# CONFIG_SPI_BFIN_SPORT is not set
 # CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_GPIO is not set
 
 #
 # SPI Protocol Masters
 #
-# CONFIG_EEPROM_AT25 is not set
 # CONFIG_SPI_SPIDEV is not set
 # CONFIG_SPI_TLE62X0 is not set
 CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
-CONFIG_GPIOLIB=y
-# CONFIG_DEBUG_GPIO is not set
-CONFIG_GPIO_SYSFS=y
-
-#
-# Memory mapped GPIO expanders:
-#
-
-#
-# I2C GPIO expanders:
-#
-# CONFIG_GPIO_MAX732X is not set
-# CONFIG_GPIO_PCA953X is not set
-# CONFIG_GPIO_PCF857X is not set
-
-#
-# PCI GPIO expanders:
-#
-
-#
-# SPI GPIO expanders:
-#
-# CONFIG_GPIO_MAX7301 is not set
-# CONFIG_GPIO_MCP23S08 is not set
+# CONFIG_GPIOLIB is not set
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
@@ -580,6 +747,12 @@ CONFIG_WATCHDOG=y
 #
 # CONFIG_SOFT_WATCHDOG is not set
 CONFIG_BFIN_WDT=y
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
 
 #
 # Multifunction device drivers
@@ -588,7 +761,7 @@ CONFIG_BFIN_WDT=y
 # CONFIG_MFD_SM501 is not set
 # CONFIG_HTC_PASIC3 is not set
 # CONFIG_MFD_TMIO is not set
-# CONFIG_MFD_WM8400 is not set
+# CONFIG_REGULATOR is not set
 
 #
 # Multimedia devices
@@ -598,6 +771,7 @@ CONFIG_BFIN_WDT=y
 # Multimedia core support
 #
 # CONFIG_VIDEO_DEV is not set
+# CONFIG_DVB_CORE is not set
 # CONFIG_VIDEO_MEDIA is not set
 
 #
@@ -618,13 +792,81 @@ CONFIG_BFIN_WDT=y
 #
 # CONFIG_DISPLAY_SUPPORT is not set
 # CONFIG_SOUND is not set
-# CONFIG_USB_SUPPORT is not set
-# CONFIG_MMC is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_GADGET_MUSB_HDRC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+CONFIG_USB_GADGET=y
+# CONFIG_USB_GADGET_DEBUG_FILES is not set
+# CONFIG_USB_GADGET_DEBUG_FS is not set
+CONFIG_USB_GADGET_VBUS_DRAW=2
+CONFIG_USB_GADGET_SELECTED=y
+# CONFIG_USB_GADGET_AT91 is not set
+# CONFIG_USB_GADGET_ATMEL_USBA is not set
+# CONFIG_USB_GADGET_FSL_USB2 is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_PXA25X is not set
+# CONFIG_USB_GADGET_PXA27X is not set
+# CONFIG_USB_GADGET_S3C2410 is not set
+# CONFIG_USB_GADGET_IMX is not set
+# CONFIG_USB_GADGET_M66592 is not set
+# CONFIG_USB_GADGET_AMD5536UDC is not set
+# CONFIG_USB_GADGET_FSL_QE is not set
+# CONFIG_USB_GADGET_CI13XXX is not set
+CONFIG_USB_GADGET_NET2272=y
+CONFIG_USB_NET2272=y
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+CONFIG_USB_GADGET_DUALSPEED=y
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_AUDIO is not set
+CONFIG_USB_ETH=y
+CONFIG_USB_ETH_RNDIS=y
+# CONFIG_USB_GADGETFS is not set
+# CONFIG_USB_FILE_STORAGE is not set
+# CONFIG_USB_G_SERIAL is not set
+# CONFIG_USB_MIDI_GADGET is not set
+# CONFIG_USB_G_PRINTER is not set
+# CONFIG_USB_CDC_COMPOSITE is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_USB_GPIO_VBUS is not set
+# CONFIG_NOP_USB_XCEIV is not set
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+# CONFIG_MMC_SDHCI is not set
+CONFIG_MMC_SPI=m
 # CONFIG_MEMSTICK is not set
 # CONFIG_NEW_LEDS is not set
 # CONFIG_ACCESSIBILITY is not set
 # CONFIG_RTC_CLASS is not set
 # CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
 # CONFIG_UIO is not set
 # CONFIG_STAGING is not set
 
@@ -641,8 +883,10 @@ CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
-CONFIG_FILE_LOCKING=y
 # CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
 # CONFIG_DNOTIFY is not set
 CONFIG_INOTIFY=y
 CONFIG_INOTIFY_USER=y
@@ -651,6 +895,11 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_AUTOFS4_FS is not set
 # CONFIG_FUSE_FS is not set
 
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
 #
 # CD-ROM/DVD Filesystems
 #
@@ -660,8 +909,11 @@ CONFIG_INOTIFY_USER=y
 #
 # DOS/FAT/NT Filesystems
 #
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
 # CONFIG_NTFS_FS is not set
 
 #
@@ -673,10 +925,7 @@ CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 # CONFIG_CONFIGFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
+CONFIG_MISC_FILESYSTEMS=y
 # CONFIG_ADFS_FS is not set
 # CONFIG_AFFS_FS is not set
 # CONFIG_HFS_FS is not set
@@ -684,9 +933,19 @@ CONFIG_SYSFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-# CONFIG_YAFFS_FS is not set
-# CONFIG_JFFS2_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
 # CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_OMFS_FS is not set
@@ -695,13 +954,62 @@ CONFIG_SYSFS=y
 # CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
 
 #
 # Partition Types
 #
 # CONFIG_PARTITION_ADVANCED is not set
 CONFIG_MSDOS_PARTITION=y
-# CONFIG_NLS is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+# CONFIG_DLM is not set
 
 #
 # Kernel hacking
@@ -714,12 +1022,30 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_SECTION_MISMATCH=y
 # CONFIG_DEBUG_KERNEL is not set
-CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_BUGVERBOSE is not set
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_RCU_CPU_STALL_DETECTOR is not set
-# CONFIG_SYSCTL_SYSCALL_CHECK is not set
-# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+
+#
+# Tracers
+#
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+# CONFIG_EVENT_TRACER is not set
+# CONFIG_BOOT_TRACER is not set
+# CONFIG_TRACE_BRANCH_PROFILING is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
 CONFIG_DEBUG_VERBOSE=y
@@ -733,9 +1059,10 @@ CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION_OFF=y
 CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION=0
 # CONFIG_DEBUG_BFIN_HWTRACE_EXPAND is not set
 # CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE is not set
-# CONFIG_EARLY_PRINTK is not set
+CONFIG_EARLY_PRINTK=y
 CONFIG_CPLB_INFO=y
 CONFIG_ACCESS_CHECK=y
+# CONFIG_BFIN_ISRAM_SELF_TEST is not set
 
 #
 # Security options
@@ -744,20 +1071,110 @@ CONFIG_ACCESS_CHECK=y
 # CONFIG_SECURITY is not set
 # CONFIG_SECURITYFS is not set
 # CONFIG_SECURITY_FILE_CAPABILITIES is not set
-# CONFIG_CRYPTO is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
+# CONFIG_CRYPTO_MANAGER is not set
+# CONFIG_CRYPTO_MANAGER2 is not set
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+# CONFIG_CRYPTO_CRYPTD is not set
+# CONFIG_CRYPTO_AUTHENC is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+# CONFIG_CRYPTO_CBC is not set
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+# CONFIG_CRYPTO_ECB is not set
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_XCBC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_MD4 is not set
+# CONFIG_CRYPTO_MD5 is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+CONFIG_CRYPTO_HW=y
+# CONFIG_BINARY_PRINTF is not set
 
 #
 # Library routines
 #
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
 # CONFIG_CRC_CCITT is not set
 # CONFIG_CRC16 is not set
 # CONFIG_CRC_T10DIF is not set
-# CONFIG_CRC_ITU_T is not set
-# CONFIG_CRC32 is not set
-# CONFIG_CRC7 is not set
+CONFIG_CRC_ITU_T=y
+CONFIG_CRC32=y
+CONFIG_CRC7=y
 # CONFIG_LIBCRC32C is not set
 CONFIG_ZLIB_INFLATE=y
-CONFIG_PLIST=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_DECOMPRESS_LZMA=y
 CONFIG_HAS_IOMEM=y
 CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
diff --git a/arch/blackfin/include/asm/asm-offsets.h b/arch/blackfin/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 10064f902d201849f5f1c09b0e494b2230aee6d6..e6485c305ea6e53266412712216136ec126cac4b 100644 (file)
@@ -11,9 +11,6 @@
 
 #ifndef __ASSEMBLY__
 
-#include <asm/sections.h>
-#include <asm/ptrace.h>
-#include <asm/user.h>
 #include <linux/linkage.h>
 #include <linux/types.h>
 
 # define DMA_UNCACHED_REGION (2 * 1024 * 1024)
 #elif defined(CONFIG_DMA_UNCACHED_1M)
 # define DMA_UNCACHED_REGION (1024 * 1024)
+#elif defined(CONFIG_DMA_UNCACHED_512K)
+# define DMA_UNCACHED_REGION (512 * 1024)
+#elif defined(CONFIG_DMA_UNCACHED_256K)
+# define DMA_UNCACHED_REGION (256 * 1024)
+#elif defined(CONFIG_DMA_UNCACHED_128K)
+# define DMA_UNCACHED_REGION (128 * 1024)
 #else
 # define DMA_UNCACHED_REGION (0)
 #endif
@@ -35,6 +38,7 @@ extern unsigned long get_sclk(void);
 extern unsigned long sclk_to_usecs(unsigned long sclk);
 extern unsigned long usecs_to_sclk(unsigned long usecs);
 
+struct pt_regs;
 extern void dump_bfin_process(struct pt_regs *regs);
 extern void dump_bfin_mem(struct pt_regs *regs);
 extern void dump_bfin_trace_buffer(void);
diff --git a/arch/blackfin/include/asm/bfin-lq035q1.h b/arch/blackfin/include/asm/bfin-lq035q1.h
new file mode 100644 (file)
index 0000000..57bc21a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Blackfin LCD Framebuffer driver SHARP LQ035Q1DH02
+ *
+ * Copyright 2008-2009 Analog Devices Inc.
+ * Licensed under the GPL-2 or later.
+ */
+
+#ifndef BFIN_LQ035Q1_H
+#define BFIN_LQ035Q1_H
+
+#define LQ035_RL       (0 << 8)        /* Right -> Left Scan */
+#define LQ035_LR       (1 << 8)        /* Left -> Right Scan */
+#define LQ035_TB       (1 << 9)        /* Top -> Botton Scan */
+#define LQ035_BT       (0 << 9)        /* Botton -> Top Scan */
+#define LQ035_BGR      (1 << 11)       /* Use BGR format */
+#define LQ035_RGB      (0 << 11)       /* Use RGB format */
+#define LQ035_NORM     (1 << 13)       /* Reversal */
+#define LQ035_REV      (0 << 13)       /* Reversal */
+
+struct bfin_lq035q1fb_disp_info {
+
+       unsigned        mode;
+       /* GPIOs */
+       int             use_bl;
+       unsigned        gpio_bl;
+};
+
+#endif /* BFIN_LQ035Q1_H */
index 6f4548a1355539191e077770f090b548c3eb17ee..75f6dc336d46d4b13e04a42bf8facb44ea79a49f 100644 (file)
@@ -47,7 +47,7 @@
 #define BUG()                                                          \
        do {                                                            \
                _BUG_OR_WARN(0);                                        \
-               for (;;);                                               \
+               unreachable();                                          \
        } while (0)
 
 #define WARN_ON(condition)                                                     \
index 417eaac7fe99948a077d38707fb1cb9c22f03f10..2666ff8ea9522907b7aa80dc3ea63de161f76b98 100644 (file)
@@ -10,6 +10,7 @@
 #define _BLACKFIN_CACHEFLUSH_H
 
 #include <asm/blackfin.h>      /* for SSYNC() */
+#include <asm/sections.h>      /* for _ramend */
 
 extern void blackfin_icache_flush_range(unsigned long start_address, unsigned long end_address);
 extern void blackfin_dcache_flush_range(unsigned long start_address, unsigned long end_address);
index a23415be0de1ae96950eaee94b9423ce792c9671..623cc7fb00bc0602871c905c5e14b164b726d4e2 100644 (file)
@@ -8,64 +8,13 @@
 #ifndef _BFIN_CHECKSUM_H
 #define _BFIN_CHECKSUM_H
 
-/*
- * computes the checksum of a memory block at buff, length len,
- * and adds in "sum" (32-bit)
- *
- * returns a 32-bit number suitable for feeding into itself
- * or csum_tcpudp_magic
- *
- * this function must be called with even lengths, except
- * for the last fragment, which may be odd
- *
- * it's best to have buff aligned on a 32-bit boundary
- */
-__wsum csum_partial(const void *buff, int len, __wsum sum);
-
-/*
- * the same as csum_partial, but copies from src while it
- * checksums
- *
- * here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-
-__wsum csum_partial_copy(const void *src, void *dst,
-                              int len, __wsum sum);
-
-/*
- * the same as csum_partial_copy, but copies from user space.
- *
- * here even more important to align src and dst on a 32-bit (or even
- * better 64-bit) boundary
- */
-
-extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst,
-                                         int len, __wsum sum, int *csum_err);
-
-#define csum_partial_copy_nocheck(src, dst, len, sum)  \
-       csum_partial_copy((src), (dst), (len), (sum))
-
-__sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl);
-
-/*
- *     Fold a partial checksum
- */
-
-static inline __sum16 csum_fold(__wsum sum)
-{
-       while (sum >> 16)
-               sum = (sum & 0xffff) + (sum >> 16);
-       return ((~(sum << 16)) >> 16);
-}
-
 /*
  * computes the checksum of the TCP/UDP pseudo-header
  * returns a 16-bit checksum, already complemented
  */
 
 static inline __wsum
-csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
+__csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
                   unsigned short proto, __wsum sum)
 {
        unsigned int carry;
@@ -88,19 +37,8 @@ csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
 
        return (sum);
 }
+#define csum_tcpudp_nofold __csum_tcpudp_nofold
 
-static inline __sum16
-csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
-                 unsigned short proto, __wsum sum)
-{
-       return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
-}
-
-/*
- * this routine is used for miscellaneous IP-like checksums, mainly
- * in icmp.c
- */
-
-extern __sum16 ip_compute_csum(const void *buff, int len);
+#include <asm-generic/checksum.h>
 
-#endif                         /* _BFIN_CHECKSUM_H */
+#endif
index f80dad5ff2577feeea61d031bf4c7776f6081623..6f0b61852f5848feb69424c409eb1f1b24ab6e99 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef _BFIN_CLOCKS_H
 #define _BFIN_CLOCKS_H
 
+#include <asm/dpmc.h>
+
 #ifdef CONFIG_CCLK_DIV_1
 # define CONFIG_CCLK_ACT_DIV   CCLK_DIV1
 # define CONFIG_CCLK_DIV 1
index 7a23d824ac961693d5935ccd757fa359f2cb8438..f9172ff30e5c1e327574bd92d36eb6592c554ffc 100644 (file)
@@ -7,9 +7,9 @@
 #ifndef _BLACKFIN_DMA_MAPPING_H
 #define _BLACKFIN_DMA_MAPPING_H
 
-#include <asm/scatterlist.h>
+#include <asm/cacheflush.h>
+struct scatterlist;
 
-void dma_alloc_init(unsigned long start, unsigned long end);
 void *dma_alloc_coherent(struct device *dev, size_t size,
                         dma_addr_t *dma_handle, gfp_t gfp);
 void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
@@ -20,13 +20,51 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
  */
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
+#define dma_supported(d, m)         (1)
+#define dma_get_cache_alignment()   (32)
+#define dma_is_consistent(d, h)     (1)
 
-static inline
-int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+static inline int
+dma_set_mask(struct device *dev, u64 dma_mask)
 {
+       if (!dev->dma_mask || !dma_supported(dev, dma_mask))
+               return -EIO;
+
+       *dev->dma_mask = dma_mask;
+
        return 0;
 }
 
+static inline int
+dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+       return 0;
+}
+
+extern void
+__dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir);
+static inline void
+_dma_sync(dma_addr_t addr, size_t size, enum dma_data_direction dir)
+{
+       if (!__builtin_constant_p(dir)) {
+               __dma_sync(addr, size, dir);
+               return;
+       }
+
+       switch (dir) {
+       case DMA_NONE:
+               BUG();
+       case DMA_TO_DEVICE:             /* writeback only */
+               flush_dcache_range(addr, addr + size);
+               break;
+       case DMA_FROM_DEVICE: /* invalidate only */
+       case DMA_BIDIRECTIONAL: /* flush and invalidate */
+               /* Blackfin has no dedicated invalidate (it includes a flush) */
+               invalidate_dcache_range(addr, addr + size);
+               break;
+       }
+}
+
 /*
  * Map a single buffer of the indicated size for DMA in streaming mode.
  * The 32-bit bus address to use is returned.
@@ -34,8 +72,13 @@ int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
  * Once the device is given the dma address, the device owns this memory
  * until either pci_unmap_single or pci_dma_sync_single is performed.
  */
-extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
-                                enum dma_data_direction direction);
+static inline dma_addr_t
+dma_map_single(struct device *dev, void *ptr, size_t size,
+              enum dma_data_direction dir)
+{
+       _dma_sync((dma_addr_t)ptr, size, dir);
+       return (dma_addr_t) ptr;
+}
 
 static inline dma_addr_t
 dma_map_page(struct device *dev, struct page *page,
@@ -53,8 +96,12 @@ dma_map_page(struct device *dev, struct page *page,
  * After this call, reads by the cpu to the buffer are guarenteed to see
  * whatever the device wrote there.
  */
-extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
-                         enum dma_data_direction direction);
+static inline void
+dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
+                enum dma_data_direction dir)
+{
+       BUG_ON(!valid_dma_direction(dir));
+}
 
 static inline void
 dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
@@ -80,38 +127,66 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size,
  * the same here.
  */
 extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
-                     enum dma_data_direction direction);
+                     enum dma_data_direction dir);
 
 /*
  * Unmap a set of streaming mode DMA translations.
  * Again, cpu read rules concerning calls here are the same as for
  * pci_unmap_single() above.
  */
-extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
-                     int nhwentries, enum dma_data_direction direction);
+static inline void
+dma_unmap_sg(struct device *dev, struct scatterlist *sg,
+            int nhwentries, enum dma_data_direction dir)
+{
+       BUG_ON(!valid_dma_direction(dir));
+}
 
-static inline void dma_sync_single_for_cpu(struct device *dev,
-                                       dma_addr_t handle, size_t size,
-                                       enum dma_data_direction dir)
+static inline void
+dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t handle,
+                             unsigned long offset, size_t size,
+                             enum dma_data_direction dir)
 {
+       BUG_ON(!valid_dma_direction(dir));
 }
 
-static inline void dma_sync_single_for_device(struct device *dev,
-                                       dma_addr_t handle, size_t size,
-                                       enum dma_data_direction dir)
+static inline void
+dma_sync_single_range_for_device(struct device *dev, dma_addr_t handle,
+                                unsigned long offset, size_t size,
+                                enum dma_data_direction dir)
 {
+       _dma_sync(handle + offset, size, dir);
 }
 
-static inline void dma_sync_sg_for_cpu(struct device *dev,
-                                       struct scatterlist *sg,
-                                       int nents, enum dma_data_direction dir)
+static inline void
+dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle, size_t size,
+                       enum dma_data_direction dir)
 {
+       dma_sync_single_range_for_cpu(dev, handle, 0, size, dir);
 }
 
-static inline void dma_sync_sg_for_device(struct device *dev,
-                                       struct scatterlist *sg,
-                                       int nents, enum dma_data_direction dir)
+static inline void
+dma_sync_single_for_device(struct device *dev, dma_addr_t handle, size_t size,
+                          enum dma_data_direction dir)
+{
+       dma_sync_single_range_for_device(dev, handle, 0, size, dir);
+}
+
+static inline void
+dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nents,
+                   enum dma_data_direction dir)
+{
+       BUG_ON(!valid_dma_direction(dir));
+}
+
+extern void
+dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
+                      int nents, enum dma_data_direction dir);
+
+static inline void
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
+              enum dma_data_direction dir)
 {
+       _dma_sync((dma_addr_t)vaddr, size, dir);
 }
 
 #endif                         /* _BLACKFIN_DMA_MAPPING_H */
index c9a59622e23f65d490087c64f26921ddaf545313..bd2e62243abef01f2376eb3c7731153f9c795933 100644 (file)
 
 #include <linux/interrupt.h>
 #include <mach/dma.h>
+#include <asm/atomic.h>
 #include <asm/blackfin.h>
 #include <asm/page.h>
-
-#define MAX_DMA_ADDRESS PAGE_OFFSET
-
-/*****************************************************************************
-*        Generic DMA  Declarations
-*
-****************************************************************************/
-enum dma_chan_status {
-       DMA_CHANNEL_FREE,
-       DMA_CHANNEL_REQUESTED,
-       DMA_CHANNEL_ENABLED,
-};
+#include <asm-generic/dma.h>
+
+/* DMA_CONFIG Masks */
+#define DMAEN                  0x0001  /* DMA Channel Enable */
+#define WNR                            0x0002  /* Channel Direction (W/R*) */
+#define WDSIZE_8               0x0000  /* Transfer Word Size = 8 */
+#define WDSIZE_16              0x0004  /* Transfer Word Size = 16 */
+#define WDSIZE_32              0x0008  /* Transfer Word Size = 32 */
+#define DMA2D                  0x0010  /* DMA Mode (2D/1D*) */
+#define RESTART                        0x0020  /* DMA Buffer Clear */
+#define DI_SEL                 0x0040  /* Data Interrupt Timing Select */
+#define DI_EN                  0x0080  /* Data Interrupt Enable */
+#define NDSIZE_0               0x0000  /* Next Descriptor Size = 0 (Stop/Autobuffer) */
+#define NDSIZE_1               0x0100  /* Next Descriptor Size = 1 */
+#define NDSIZE_2               0x0200  /* Next Descriptor Size = 2 */
+#define NDSIZE_3               0x0300  /* Next Descriptor Size = 3 */
+#define NDSIZE_4               0x0400  /* Next Descriptor Size = 4 */
+#define NDSIZE_5               0x0500  /* Next Descriptor Size = 5 */
+#define NDSIZE_6               0x0600  /* Next Descriptor Size = 6 */
+#define NDSIZE_7               0x0700  /* Next Descriptor Size = 7 */
+#define NDSIZE_8               0x0800  /* Next Descriptor Size = 8 */
+#define NDSIZE_9               0x0900  /* Next Descriptor Size = 9 */
+#define NDSIZE                 0x0f00  /* Next Descriptor Size */
+#define DMAFLOW                        0x7000  /* Flow Control */
+#define DMAFLOW_STOP   0x0000  /* Stop Mode */
+#define DMAFLOW_AUTO   0x1000  /* Autobuffer Mode */
+#define DMAFLOW_ARRAY  0x4000  /* Descriptor Array Mode */
+#define DMAFLOW_SMALL  0x6000  /* Small Model Descriptor List Mode */
+#define DMAFLOW_LARGE  0x7000  /* Large Model Descriptor List Mode */
+
+/* DMA_IRQ_STATUS Masks */
+#define DMA_DONE               0x0001  /* DMA Completion Interrupt Status */
+#define DMA_ERR                        0x0002  /* DMA Error Interrupt Status */
+#define DFETCH                 0x0004  /* DMA Descriptor Fetch Indicator */
+#define DMA_RUN                        0x0008  /* DMA Channel Running Indicator */
 
 /*-------------------------
  * config reg bits value
  *-------------------------*/
-#define DATA_SIZE_8            0
-#define DATA_SIZE_16           1
-#define DATA_SIZE_32           2
+#define DATA_SIZE_8                    0
+#define DATA_SIZE_16           1
+#define DATA_SIZE_32           2
 
-#define DMA_FLOW_STOP          0
-#define DMA_FLOW_AUTO          1
-#define DMA_FLOW_ARRAY                 4
-#define DMA_FLOW_SMALL                 6
-#define DMA_FLOW_LARGE                 7
+#define DMA_FLOW_STOP          0
+#define DMA_FLOW_AUTO          1
+#define DMA_FLOW_ARRAY         4
+#define DMA_FLOW_SMALL         6
+#define DMA_FLOW_LARGE         7
 
-#define DIMENSION_LINEAR    0
-#define DIMENSION_2D           1
+#define DIMENSION_LINEAR       0
+#define DIMENSION_2D           1
 
-#define DIR_READ     0
-#define DIR_WRITE    1
+#define DIR_READ                       0
+#define DIR_WRITE                      1
 
-#define INTR_DISABLE   0
-#define INTR_ON_BUF    2
-#define INTR_ON_ROW    3
+#define INTR_DISABLE           0
+#define INTR_ON_BUF                    2
+#define INTR_ON_ROW                    3
 
 #define DMA_NOSYNC_KEEP_DMA_BUF        0
-#define DMA_SYNC_RESTART       1
+#define DMA_SYNC_RESTART               1
 
 struct dmasg {
        void *next_desc_addr;
@@ -104,11 +128,9 @@ struct dma_register {
 
 };
 
-struct mutex;
 struct dma_channel {
-       struct mutex dmalock;
        const char *device_id;
-       enum dma_chan_status chan_status;
+       atomic_t chan_status;
        volatile struct dma_register *regs;
        struct dmasg *sg;               /* large mode descriptor */
        unsigned int irq;
@@ -220,27 +242,20 @@ static inline void set_dma_sg(unsigned int channel, struct dmasg *sg, int ndsize
 
 static inline int dma_channel_active(unsigned int channel)
 {
-       if (dma_ch[channel].chan_status == DMA_CHANNEL_FREE)
-               return 0;
-       else
-               return 1;
+       return atomic_read(&dma_ch[channel].chan_status);
 }
 
 static inline void disable_dma(unsigned int channel)
 {
        dma_ch[channel].regs->cfg &= ~DMAEN;
        SSYNC();
-       dma_ch[channel].chan_status = DMA_CHANNEL_REQUESTED;
 }
 static inline void enable_dma(unsigned int channel)
 {
        dma_ch[channel].regs->curr_x_count = 0;
        dma_ch[channel].regs->curr_y_count = 0;
        dma_ch[channel].regs->cfg |= DMAEN;
-       dma_ch[channel].chan_status = DMA_CHANNEL_ENABLED;
 }
-void free_dma(unsigned int channel);
-int request_dma(unsigned int channel, const char *device_id);
 int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data);
 
 static inline void dma_disable_irq(unsigned int channel)
index 925e66cb2d49273581ec44c09b9ffe339dab19b4..1597ae5041ee4ae08ea017988f32862ffa6ac709 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Miscellaneous IOCTL commands for Dynamic Power Management Controller Driver
  *
- * Copyright (C) 2004-2008 Analog Device Inc.
+ * Copyright (C) 2004-2009 Analog Device Inc.
  *
  * Licensed under the GPL-2
  */
@@ -9,7 +9,109 @@
 #ifndef _BLACKFIN_DPMC_H_
 #define _BLACKFIN_DPMC_H_
 
-#ifdef __KERNEL__
+/* PLL_CTL Masks */
+#define DF                     0x0001  /* 0: PLL = CLKIN, 1: PLL = CLKIN/2 */
+#define PLL_OFF                        0x0002  /* PLL Not Powered */
+#define STOPCK                 0x0008  /* Core Clock Off */
+#define PDWN                   0x0020  /* Enter Deep Sleep Mode */
+#ifdef __ADSPBF539__
+# define IN_DELAY              0x0014  /* Add 200ps Delay To EBIU Input Latches */
+# define OUT_DELAY             0x00C0  /* Add 200ps Delay To EBIU Output Signals */
+#else
+# define IN_DELAY              0x0040  /* Add 200ps Delay To EBIU Input Latches */
+# define OUT_DELAY             0x0080  /* Add 200ps Delay To EBIU Output Signals */
+#endif
+#define BYPASS                 0x0100  /* Bypass the PLL */
+#define MSEL                   0x7E00  /* Multiplier Select For CCLK/VCO Factors */
+#define SPORT_HYST             0x8000  /* Enable Additional Hysteresis on SPORT Input Pins */
+#define SET_MSEL(x)            (((x)&0x3F) << 0x9)     /* Set MSEL = 0-63 --> VCO = CLKIN*MSEL */
+
+/* PLL_DIV Masks */
+#define SSEL                   0x000F  /* System Select */
+#define CSEL                   0x0030  /* Core Select */
+#define CSEL_DIV1              0x0000  /* CCLK = VCO / 1 */
+#define CSEL_DIV2              0x0010  /* CCLK = VCO / 2 */
+#define CSEL_DIV4              0x0020  /* CCLK = VCO / 4 */
+#define CSEL_DIV8              0x0030  /* CCLK = VCO / 8 */
+
+#define CCLK_DIV1 CSEL_DIV1
+#define CCLK_DIV2 CSEL_DIV2
+#define CCLK_DIV4 CSEL_DIV4
+#define CCLK_DIV8 CSEL_DIV8
+
+#define SET_SSEL(x)    ((x) & 0xF)     /* Set SSEL = 0-15 --> SCLK = VCO/SSEL */
+#define SCLK_DIV(x)    (x)             /* SCLK = VCO / x */
+
+/* PLL_STAT Masks */
+#define ACTIVE_PLLENABLED      0x0001  /* Processor In Active Mode With PLL Enabled */
+#define FULL_ON                        0x0002  /* Processor In Full On Mode */
+#define ACTIVE_PLLDISABLED     0x0004  /* Processor In Active Mode With PLL Disabled */
+#define PLL_LOCKED             0x0020  /* PLL_LOCKCNT Has Been Reached */
+
+#define RTCWS                  0x0400  /* RTC/Reset Wake-Up Status */
+#define CANWS                  0x0800  /* CAN Wake-Up Status */
+#define USBWS                  0x2000  /* USB Wake-Up Status */
+#define KPADWS                 0x4000  /* Keypad Wake-Up Status */
+#define ROTWS                  0x8000  /* Rotary Wake-Up Status */
+#define GPWS                   0x1000  /* General-Purpose Wake-Up Status */
+
+/* VR_CTL Masks */
+#if defined(__ADSPBF52x__) || defined(__ADSPBF51x__)
+#define FREQ                   0x3000  /* Switching Oscillator Frequency For Regulator */
+#define FREQ_1000              0x3000  /* Switching Frequency Is 1 MHz */
+#else
+#define FREQ                   0x0003  /* Switching Oscillator Frequency For Regulator */
+#define FREQ_333               0x0001  /* Switching Frequency Is 333 kHz */
+#define FREQ_667               0x0002  /* Switching Frequency Is 667 kHz */
+#define FREQ_1000              0x0003  /* Switching Frequency Is 1 MHz */
+#endif
+#define HIBERNATE              0x0000  /* Powerdown/Bypass On-Board Regulation */
+
+#define GAIN                   0x000C  /* Voltage Level Gain */
+#define GAIN_5                 0x0000  /* GAIN = 5 */
+#define GAIN_10                        0x0004  /* GAIN = 1 */
+#define GAIN_20                        0x0008  /* GAIN = 2 */
+#define GAIN_50                        0x000C  /* GAIN = 5 */
+
+#define VLEV                   0x00F0  /* Internal Voltage Level */
+#ifdef __ADSPBF52x__
+#define VLEV_085               0x0040  /* VLEV = 0.85 V (-5% - +10% Accuracy) */
+#define VLEV_090               0x0050  /* VLEV = 0.90 V (-5% - +10% Accuracy) */
+#define VLEV_095               0x0060  /* VLEV = 0.95 V (-5% - +10% Accuracy) */
+#define VLEV_100               0x0070  /* VLEV = 1.00 V (-5% - +10% Accuracy) */
+#define VLEV_105               0x0080  /* VLEV = 1.05 V (-5% - +10% Accuracy) */
+#define VLEV_110               0x0090  /* VLEV = 1.10 V (-5% - +10% Accuracy) */
+#define VLEV_115               0x00A0  /* VLEV = 1.15 V (-5% - +10% Accuracy) */
+#define VLEV_120               0x00B0  /* VLEV = 1.20 V (-5% - +10% Accuracy) */
+#else
+#define VLEV_085               0x0060  /* VLEV = 0.85 V (-5% - +10% Accuracy) */
+#define VLEV_090               0x0070  /* VLEV = 0.90 V (-5% - +10% Accuracy) */
+#define VLEV_095               0x0080  /* VLEV = 0.95 V (-5% - +10% Accuracy) */
+#define VLEV_100               0x0090  /* VLEV = 1.00 V (-5% - +10% Accuracy) */
+#define VLEV_105               0x00A0  /* VLEV = 1.05 V (-5% - +10% Accuracy) */
+#define VLEV_110               0x00B0  /* VLEV = 1.10 V (-5% - +10% Accuracy) */
+#define VLEV_115               0x00C0  /* VLEV = 1.15 V (-5% - +10% Accuracy) */
+#define VLEV_120               0x00D0  /* VLEV = 1.20 V (-5% - +10% Accuracy) */
+#define VLEV_125               0x00E0  /* VLEV = 1.25 V (-5% - +10% Accuracy) */
+#define VLEV_130               0x00F0  /* VLEV = 1.30 V (-5% - +10% Accuracy) */
+#endif
+
+#define WAKE                   0x0100  /* Enable RTC/Reset Wakeup From Hibernate */
+#define CANWE                  0x0200  /* Enable CAN Wakeup From Hibernate */
+#define PHYWE                  0x0400  /* Enable PHY Wakeup From Hibernate */
+#define GPWE                   0x0400  /* General-Purpose Wake-Up Enable */
+#define MXVRWE                 0x0400  /* Enable MXVR Wakeup From Hibernate */
+#define KPADWE                 0x1000  /* Keypad Wake-Up Enable */
+#define ROTWE                  0x2000  /* Rotary Wake-Up Enable */
+#define CLKBUFOE               0x4000  /* CLKIN Buffer Output Enable */
+#define SCKELOW                        0x8000  /* Do Not Drive SCKE High During Reset After Hibernate */
+
+#if defined(__ADSPBF52x__) || defined(__ADSPBF51x__)
+#define USBWE                  0x0200  /* Enable USB Wakeup From Hibernate */
+#else
+#define USBWE                  0x0800  /* Enable USB Wakeup From Hibernate */
+#endif
+
 #ifndef __ASSEMBLY__
 
 void sleep_mode(u32 sic_iwr0, u32 sic_iwr1, u32 sic_iwr2);
@@ -54,6 +156,5 @@ struct bfin_dpmc_platform_data {
        w[P0 + (x - PLL_CTL)] = R0;\
 
 #endif
-#endif /* __KERNEL__ */
 
 #endif /*_BLACKFIN_DPMC_H_*/
index 8e0764c81eaf18df6d2e0ee0167596b2fdea5e25..5b50f0ecacf8ebd77c0e4646c397fb2356034d80 100644 (file)
@@ -55,7 +55,6 @@ do {                                                                                  \
        _regs->p2       = _dynamic_addr;                                \
 } while(0)
 
-#define USE_ELF_CORE_DUMP
 #define ELF_FDPIC_CORE_EFLAGS  EF_BFIN_FDPIC
 #define ELF_EXEC_PAGESIZE      4096
 
index 5b44d05ca53e8a6f89b0e5d9c0e80cb095527309..539468a05057fad759fa88fc8ef7ea37931b0bc2 100644 (file)
@@ -159,6 +159,11 @@ struct gpio_port_t {
 };
 #endif
 
+#ifdef BFIN_SPECIAL_GPIO_BANKS
+void bfin_special_gpio_free(unsigned gpio);
+int bfin_special_gpio_request(unsigned gpio, const char *label);
+#endif
+
 #ifdef CONFIG_PM
 
 unsigned int bfin_pm_standby_setup(void);
index 89f08decb8e0fb0b6e5bf62c3d664d36e83e043e..c722acdda0d396cc3835001ebdc55c1da5435493 100644 (file)
 
 /* The actual gptimer API */
 
-void     set_gptimer_pwidth(int timer_id, uint32_t width);
-uint32_t get_gptimer_pwidth(int timer_id);
-void     set_gptimer_period(int timer_id, uint32_t period);
-uint32_t get_gptimer_period(int timer_id);
-uint32_t get_gptimer_count(int timer_id);
-int      get_gptimer_intr(int timer_id);
-void     clear_gptimer_intr(int timer_id);
-int      get_gptimer_over(int timer_id);
-void     clear_gptimer_over(int timer_id);
-void     set_gptimer_config(int timer_id, uint16_t config);
-uint16_t get_gptimer_config(int timer_id);
-int      get_gptimer_run(int timer_id);
-void     set_gptimer_pulse_hi(int timer_id);
-void     clear_gptimer_pulse_hi(int timer_id);
+void     set_gptimer_pwidth(unsigned int timer_id, uint32_t width);
+uint32_t get_gptimer_pwidth(unsigned int timer_id);
+void     set_gptimer_period(unsigned int timer_id, uint32_t period);
+uint32_t get_gptimer_period(unsigned int timer_id);
+uint32_t get_gptimer_count(unsigned int timer_id);
+int      get_gptimer_intr(unsigned int timer_id);
+void     clear_gptimer_intr(unsigned int timer_id);
+int      get_gptimer_over(unsigned int timer_id);
+void     clear_gptimer_over(unsigned int timer_id);
+void     set_gptimer_config(unsigned int timer_id, uint16_t config);
+uint16_t get_gptimer_config(unsigned int timer_id);
+int      get_gptimer_run(unsigned int timer_id);
+void     set_gptimer_pulse_hi(unsigned int timer_id);
+void     clear_gptimer_pulse_hi(unsigned int timer_id);
 void     enable_gptimers(uint16_t mask);
 void     disable_gptimers(uint16_t mask);
 void     disable_gptimers_sync(uint16_t mask);
 uint16_t get_enabled_gptimers(void);
-uint32_t get_gptimer_status(int group);
-void     set_gptimer_status(int group, uint32_t value);
+uint32_t get_gptimer_status(unsigned int group);
+void     set_gptimer_status(unsigned int group, uint32_t value);
 
 #endif
index d1f5029189a7dc194fd1a06bbe96bc52a1e3fd24..29e55b9d88bcdbe0558aea0689a00dc4e7f25c89 100644 (file)
@@ -31,12 +31,14 @@ static inline unsigned char readb(const volatile void __iomem *addr)
        unsigned int val;
        int tmp;
 
-       __asm__ __volatile__ ("cli %1;\n\t"
-                       "NOP; NOP; SSYNC;\n\t"
-                       "%0 = b [%2] (z);\n\t"
-                       "sti %1;\n\t"
-                       : "=d"(val), "=d"(tmp): "a"(addr)
-                       );
+       __asm__ __volatile__ (
+               "cli %1;"
+               "NOP; NOP; SSYNC;"
+               "%0 = b [%2] (z);"
+               "sti %1;"
+               : "=d"(val), "=d"(tmp)
+               : "a"(addr)
+       );
 
        return (unsigned char) val;
 }
@@ -46,12 +48,14 @@ static inline unsigned short readw(const volatile void __iomem *addr)
        unsigned int val;
        int tmp;
 
-       __asm__ __volatile__ ("cli %1;\n\t"
-                       "NOP; NOP; SSYNC;\n\t"
-                       "%0 = w [%2] (z);\n\t"
-                       "sti %1;\n\t"
-                       : "=d"(val), "=d"(tmp): "a"(addr)
-                       );
+       __asm__ __volatile__ (
+               "cli %1;"
+               "NOP; NOP; SSYNC;"
+               "%0 = w [%2] (z);"
+               "sti %1;"
+               : "=d"(val), "=d"(tmp)
+               : "a"(addr)
+       );
 
        return (unsigned short) val;
 }
@@ -61,20 +65,23 @@ static inline unsigned int readl(const volatile void __iomem *addr)
        unsigned int val;
        int tmp;
 
-       __asm__ __volatile__ ("cli %1;\n\t"
-                       "NOP; NOP; SSYNC;\n\t"
-                       "%0 = [%2];\n\t"
-                       "sti %1;\n\t"
-                       : "=d"(val), "=d"(tmp): "a"(addr)
-                       );
+       __asm__ __volatile__ (
+               "cli %1;"
+               "NOP; NOP; SSYNC;"
+               "%0 = [%2];"
+               "sti %1;"
+               : "=d"(val), "=d"(tmp)
+               : "a"(addr)
+       );
+
        return val;
 }
 
 #endif /*  __ASSEMBLY__ */
 
-#define writeb(b,addr) (void)((*(volatile unsigned char *) (addr)) = (b))
-#define writew(b,addr) (void)((*(volatile unsigned short *) (addr)) = (b))
-#define writel(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b))
+#define writeb(b, addr) (void)((*(volatile unsigned char *) (addr)) = (b))
+#define writew(b, addr) (void)((*(volatile unsigned short *) (addr)) = (b))
+#define writel(b, addr) (void)((*(volatile unsigned int *) (addr)) = (b))
 
 #define __raw_readb readb
 #define __raw_readw readw
@@ -82,9 +89,9 @@ static inline unsigned int readl(const volatile void __iomem *addr)
 #define __raw_writeb writeb
 #define __raw_writew writew
 #define __raw_writel writel
-#define memset_io(a,b,c)       memset((void *)(a),(b),(c))
-#define memcpy_fromio(a,b,c)   memcpy((a),(void *)(b),(c))
-#define memcpy_toio(a,b,c)     memcpy((void *)(a),(b),(c))
+#define memset_io(a, b, c)     memset((void *)(a), (b), (c))
+#define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
+#define memcpy_toio(a, b, c)   memcpy((void *)(a), (b), (c))
 
 /* Convert "I/O port addresses" to actual addresses.  i.e. ugly casts. */
 #define __io(port) ((void *)(unsigned long)(port))
@@ -92,30 +99,30 @@ static inline unsigned int readl(const volatile void __iomem *addr)
 #define inb(port)    readb(__io(port))
 #define inw(port)    readw(__io(port))
 #define inl(port)    readl(__io(port))
-#define outb(x,port) writeb(x,__io(port))
-#define outw(x,port) writew(x,__io(port))
-#define outl(x,port) writel(x,__io(port))
+#define outb(x, port) writeb(x, __io(port))
+#define outw(x, port) writew(x, __io(port))
+#define outl(x, port) writel(x, __io(port))
 
 #define inb_p(port)    inb(__io(port))
 #define inw_p(port)    inw(__io(port))
 #define inl_p(port)    inl(__io(port))
-#define outb_p(x,port) outb(x,__io(port))
-#define outw_p(x,port) outw(x,__io(port))
-#define outl_p(x,port) outl(x,__io(port))
-
-#define ioread8_rep(a,d,c)     readsb(a,d,c)
-#define ioread16_rep(a,d,c)    readsw(a,d,c)
-#define ioread32_rep(a,d,c)    readsl(a,d,c)
-#define iowrite8_rep(a,s,c)    writesb(a,s,c)
-#define iowrite16_rep(a,s,c)   writesw(a,s,c)
-#define iowrite32_rep(a,s,c)   writesl(a,s,c)
-
-#define ioread8(X)                     readb(X)
-#define ioread16(X)                    readw(X)
-#define ioread32(X)                    readl(X)
-#define iowrite8(val,X)                        writeb(val,X)
-#define iowrite16(val,X)               writew(val,X)
-#define iowrite32(val,X)               writel(val,X)
+#define outb_p(x, port) outb(x, __io(port))
+#define outw_p(x, port) outw(x, __io(port))
+#define outl_p(x, port) outl(x, __io(port))
+
+#define ioread8_rep(a, d, c)   readsb(a, d, c)
+#define ioread16_rep(a, d, c)  readsw(a, d, c)
+#define ioread32_rep(a, d, c)  readsl(a, d, c)
+#define iowrite8_rep(a, s, c)  writesb(a, s, c)
+#define iowrite16_rep(a, s, c) writesw(a, s, c)
+#define iowrite32_rep(a, s, c) writesl(a, s, c)
+
+#define ioread8(x)                     readb(x)
+#define ioread16(x)                    readw(x)
+#define ioread32(x)                    readl(x)
+#define iowrite8(val, x)               writeb(val, x)
+#define iowrite16(val, x)              writew(val, x)
+#define iowrite32(val, x)              writel(val, x)
 
 #define mmiowb() wmb()
 
index 4617ba66278ffadb2ceb1f3cb524eaaa804cbf49..d3b40449ca0e20e07efa820272748000ebd35961 100644 (file)
@@ -35,9 +35,9 @@
 #include <asm/atomic.h>
 #include <asm/traps.h>
 
-#define IPIPE_ARCH_STRING     "1.11-00"
+#define IPIPE_ARCH_STRING     "1.12-00"
 #define IPIPE_MAJOR_NUMBER    1
-#define IPIPE_MINOR_NUMBER    11
+#define IPIPE_MINOR_NUMBER    12
 #define IPIPE_PATCH_NUMBER    0
 
 #ifdef CONFIG_SMP
@@ -124,16 +124,6 @@ static inline int __ipipe_check_tickdev(const char *devname)
        return 1;
 }
 
-static inline void __ipipe_lock_root(void)
-{
-       set_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status));
-}
-
-static inline void __ipipe_unlock_root(void)
-{
-       clear_bit(IPIPE_SYNCDEFER_FLAG, &ipipe_root_cpudom_var(status));
-}
-
 void __ipipe_enable_pipeline(void);
 
 #define __ipipe_hook_critical_ipi(ipd) do { } while (0)
index 490098f532a75a4a55725f13dec848e76540be90..00409201d9edc7d69a225562caef7582e636d447 100644 (file)
 
 extern unsigned long __ipipe_root_status; /* Alias to ipipe_root_cpudom_var(status) */
 
-#define __ipipe_stall_root()                                           \
-       do {                                                            \
-               volatile unsigned long *p = &__ipipe_root_status;       \
-               set_bit(0, p);                                          \
-       } while (0)
-
-#define __ipipe_test_and_stall_root()                                  \
-       ({                                                              \
-               volatile unsigned long *p = &__ipipe_root_status;       \
-               test_and_set_bit(0, p);                                 \
-       })
-
-#define __ipipe_test_root()                                    \
-       ({                                                      \
-               const unsigned long *p = &__ipipe_root_status;  \
-               test_bit(0, p);                                 \
-       })
+void __ipipe_stall_root(void);
+
+unsigned long __ipipe_test_and_stall_root(void);
+
+unsigned long __ipipe_test_root(void);
+
+void __ipipe_lock_root(void);
+
+void __ipipe_unlock_root(void);
 
 #endif /* !__ASSEMBLY__ */
 
index 9b19a19d9ae933401cc1baf2aa0b6ce8fa7eea66..813a1af3e865e589f5cf17a822796e79297a884f 100644 (file)
@@ -33,6 +33,7 @@ static inline unsigned long bfin_cli(void)
 
 #ifdef CONFIG_IPIPE
 
+#include <linux/compiler.h>
 #include <linux/ipipe_base.h>
 #include <linux/ipipe_trace.h>
 
@@ -49,12 +50,12 @@ static inline unsigned long bfin_cli(void)
                barrier();                              \
        } while (0)
 
-static inline void raw_local_irq_enable(void)
-{
-       barrier();
-       ipipe_check_context(ipipe_root_domain);
-       __ipipe_unstall_root();
-}
+#define raw_local_irq_enable()                         \
+       do {                                            \
+               barrier();                              \
+               ipipe_check_context(ipipe_root_domain); \
+               __ipipe_unstall_root();                 \
+       } while (0)
 
 #define raw_local_save_flags_ptr(x)                                    \
        do {                                                            \
index c8b256d2ea30ec6d86fdb3a353bc2cce3a2edf78..8651afe1299027502afd3700b4394ae3dfcf0b85 100644 (file)
@@ -10,9 +10,6 @@
 
 #include <linux/ptrace.h>
 
-/* gdb locks */
-#define KGDB_MAX_NO_CPUS 8
-
 /*
  * BUFMAX defines the maximum number of characters in inbound/outbound buffers.
  * At least NUMREGBYTES*2 are needed for register packets.
index 4179e329b9c931d94521b2f2a1c457a4c59090e3..7c8fe834ff22cfa025cda6026557b81399cd48b5 100644 (file)
 #else
 #define PLL_BYPASS       0
 #endif
-
-/***************************************Currently Not Being Used *********************************/
-
-#if defined(CONFIG_FLASH_SPEED_BWAT) && \
-defined(CONFIG_FLASH_SPEED_BRAT) && \
-defined(CONFIG_FLASH_SPEED_BHT) && \
-defined(CONFIG_FLASH_SPEED_BST) && \
-defined(CONFIG_FLASH_SPEED_BTT)
-
-#define flash_EBIU_AMBCTL_WAT  ((CONFIG_FLASH_SPEED_BWAT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
-#define flash_EBIU_AMBCTL_RAT  ((CONFIG_FLASH_SPEED_BRAT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
-#define flash_EBIU_AMBCTL_HT   ((CONFIG_FLASH_SPEED_BHT  * 4) / (4000000000 / CONFIG_SCLK_HZ))
-#define flash_EBIU_AMBCTL_ST   ((CONFIG_FLASH_SPEED_BST  * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
-#define flash_EBIU_AMBCTL_TT   ((CONFIG_FLASH_SPEED_BTT  * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
-
-#if (flash_EBIU_AMBCTL_TT > 3)
-#define flash_EBIU_AMBCTL0_TT   B0TT_4
-#endif
-#if (flash_EBIU_AMBCTL_TT == 3)
-#define flash_EBIU_AMBCTL0_TT   B0TT_3
-#endif
-#if (flash_EBIU_AMBCTL_TT == 2)
-#define flash_EBIU_AMBCTL0_TT   B0TT_2
-#endif
-#if (flash_EBIU_AMBCTL_TT < 2)
-#define flash_EBIU_AMBCTL0_TT   B0TT_1
-#endif
-
-#if (flash_EBIU_AMBCTL_ST > 3)
-#define flash_EBIU_AMBCTL0_ST   B0ST_4
-#endif
-#if (flash_EBIU_AMBCTL_ST == 3)
-#define flash_EBIU_AMBCTL0_ST   B0ST_3
-#endif
-#if (flash_EBIU_AMBCTL_ST == 2)
-#define flash_EBIU_AMBCTL0_ST   B0ST_2
-#endif
-#if (flash_EBIU_AMBCTL_ST < 2)
-#define flash_EBIU_AMBCTL0_ST   B0ST_1
-#endif
-
-#if (flash_EBIU_AMBCTL_HT > 2)
-#define flash_EBIU_AMBCTL0_HT   B0HT_3
-#endif
-#if (flash_EBIU_AMBCTL_HT == 2)
-#define flash_EBIU_AMBCTL0_HT   B0HT_2
-#endif
-#if (flash_EBIU_AMBCTL_HT == 1)
-#define flash_EBIU_AMBCTL0_HT   B0HT_1
-#endif
-#if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT == 0)
-#define flash_EBIU_AMBCTL0_HT   B0HT_0
-#endif
-#if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT != 0)
-#define flash_EBIU_AMBCTL0_HT   B0HT_1
-#endif
-
-#if (flash_EBIU_AMBCTL_WAT > 14)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_15
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 14)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_14
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 13)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_13
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 12)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_12
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 11)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_11
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 10)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_10
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 9)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_9
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 8)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_8
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 7)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_7
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 6)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_6
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 5)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_5
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 4)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_4
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 3)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_3
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 2)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_2
-#endif
-#if (flash_EBIU_AMBCTL_WAT == 1)
-#define flash_EBIU_AMBCTL0_WAT  B0WAT_1
-#endif
-
-#if (flash_EBIU_AMBCTL_RAT > 14)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_15
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 14)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_14
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 13)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_13
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 12)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_12
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 11)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_11
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 10)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_10
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 9)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_9
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 8)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_8
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 7)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_7
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 6)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_6
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 5)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_5
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 4)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_4
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 3)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_3
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 2)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_2
-#endif
-#if (flash_EBIU_AMBCTL_RAT == 1)
-#define flash_EBIU_AMBCTL0_RAT  B0RAT_1
-#endif
-
-#define flash_EBIU_AMBCTL0  \
-       (flash_EBIU_AMBCTL0_WAT | flash_EBIU_AMBCTL0_RAT | flash_EBIU_AMBCTL0_HT | \
-        flash_EBIU_AMBCTL0_ST | flash_EBIU_AMBCTL0_TT | CONFIG_FLASH_SPEED_RDYEN)
-#endif
index 4a3be376ad5b906cf7c7371dda02ec37be7cdccd..ae8ef4ffd806d8078c0aec77525487ce1fbcf8df 100644 (file)
@@ -66,8 +66,8 @@ activate_l1stack(struct mm_struct *mm, unsigned long sp_base)
 
 #define activate_mm(prev, next) switch_mm(prev, next, NULL)
 
-static inline void switch_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm,
-                            struct task_struct *tsk)
+static inline void __switch_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm,
+                              struct task_struct *tsk)
 {
 #ifdef CONFIG_MPU
        unsigned int cpu = smp_processor_id();
@@ -95,7 +95,24 @@ static inline void switch_mm(struct mm_struct *prev_mm, struct mm_struct *next_m
 #endif
 }
 
+#ifdef CONFIG_IPIPE
+#define lock_mm_switch(flags)  local_irq_save_hw_cond(flags)
+#define unlock_mm_switch(flags)        local_irq_restore_hw_cond(flags)
+#else
+#define lock_mm_switch(flags)  do { (void)(flags); } while (0)
+#define unlock_mm_switch(flags)        do { (void)(flags); } while (0)
+#endif /* CONFIG_IPIPE */
+
 #ifdef CONFIG_MPU
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
+                            struct task_struct *tsk)
+{
+       unsigned long flags;
+       lock_mm_switch(flags);
+       __switch_mm(prev, next, tsk);
+       unlock_mm_switch(flags);
+}
+
 static inline void protect_page(struct mm_struct *mm, unsigned long addr,
                                unsigned long flags)
 {
@@ -128,6 +145,12 @@ static inline void update_protections(struct mm_struct *mm)
                set_mask_dcplbs(mm->context.page_rwx_mask, cpu);
        }
 }
+#else /* !CONFIG_MPU */
+static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
+                            struct task_struct *tsk)
+{
+       __switch_mm(prev, next, tsk);
+}
 #endif
 
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
@@ -173,4 +196,10 @@ static inline void destroy_context(struct mm_struct *mm)
 #endif
 }
 
+#define ipipe_mm_switch_protect(flags)         \
+       local_irq_save_hw_cond(flags)
+
+#define ipipe_mm_switch_unprotect(flags)       \
+       local_irq_restore_hw_cond(flags)
+
 #endif
index 9c1cfffddd9b2c832fedb0ebdffc6207c0e9fac8..4282b169ead9f922b33a5c625fc667ee31e37b24 100644 (file)
@@ -7,8 +7,6 @@
 #ifndef _ASM_BFIN_MODULE_H
 #define _ASM_BFIN_MODULE_H
 
-#define MODULE_SYMBOL_PREFIX "_"
-
 #define Elf_Shdr        Elf32_Shdr
 #define Elf_Sym         Elf32_Sym
 #define Elf_Ehdr        Elf32_Ehdr
index 61277358c8655b64817a37c1e22a2f77ebc0114d..99cae2e3bac702259b9dc4c469b2eeb85890f2b3 100644 (file)
 #define _ASM_BFIN_PCI_H
 
 #include <asm/scatterlist.h>
+#include <asm-generic/pci-dma-compat.h>
+#include <asm-generic/pci.h>
 
-/*
- *
- * Written by Wout Klaren.
- */
-
-/* Added by Chang Junxiao */
 #define PCIBIOS_MIN_IO 0x00001000
 #define PCIBIOS_MIN_MEM 0x10000000
 
-#define PCI_DMA_BUS_IS_PHYS       (1)
-struct pci_ops;
-
-/*
- * Structure with hardware dependent information and functions of the
- * PCI bus.
- */
-struct pci_bus_info {
-
-       /*
-        * Resources of the PCI bus.
-        */
-       struct resource mem_space;
-       struct resource io_space;
-
-       /*
-        * System dependent functions.
-        */
-       struct pci_ops *bfin_pci_ops;
-       void (*fixup) (int pci_modify);
-       void (*conf_device) (unsigned char bus, unsigned char device_fn);
-};
-
-#define pcibios_assign_all_busses()    0
 static inline void pcibios_set_master(struct pci_dev *dev)
 {
-
        /* No special bus mastering setup handling */
 }
 static inline void pcibios_penalize_isa_irq(int irq)
 {
-
        /* We don't do dynamic PCI IRQ allocation */
 }
-static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
-                                       size_t size, int direction)
-{
-       if (direction == PCI_DMA_NONE)
-               BUG();
-
-        /* return virt_to_bus(ptr); */
-       return (dma_addr_t) ptr;
-}
-
-/* Unmap a single streaming mode DMA translation.  The dma_addr and size
- * must match what was provided for in a previous pci_map_single call.  All
- * other usages are undefined.
- *
- * After this call, reads by the cpu to the buffer are guarenteed to see
- * whatever the device wrote there.
- */
-static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
-                                   size_t size, int direction)
-{
-       if (direction == PCI_DMA_NONE)
-               BUG();
-
-       /* Nothing to do */
-}
-
-/* Map a set of buffers described by scatterlist in streaming
- * mode for DMA.  This is the scather-gather version of the
- * above pci_map_single interface.  Here the scatter gather list
- * elements are each tagged with the appropriate dma address
- * and length.  They are obtained via sg_dma_{address,length}(SG).
- *
- * NOTE: An implementation may be able to use a smaller number of
- *       DMA address/length pairs than there are SG table elements.
- *       (for example via virtual mapping capabilities)
- *       The routine returns the number of addr/length pairs actually
- *       used, at most nents.
- *
- * Device ownership issues as mentioned above for pci_map_single are
- * the same here.
- */
-static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg,
-                            int nents, int direction)
-{
-       if (direction == PCI_DMA_NONE)
-               BUG();
-       return nents;
-}
-
-/* Unmap a set of streaming mode DMA translations.
- * Again, cpu read rules concerning calls here are the same as for
- * pci_unmap_single() above.
- */
-static inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
-                               int nents, int direction)
-{
-       if (direction == PCI_DMA_NONE)
-               BUG();
-
-       /* Nothing to do */
-}
-
-/* Make physical memory consistent for a single
- * streaming mode DMA translation after a transfer.
- *
- * If you perform a pci_map_single() but wish to interrogate the
- * buffer using the cpu, yet do not wish to teardown the PCI dma
- * mapping, you must call this function before doing so.  At the
- * next point you give the PCI dma address back to the card, the
- * device again owns the buffer.
- */
-static inline void pci_dma_sync_single(struct pci_dev *hwdev,
-                                      dma_addr_t dma_handle, size_t size,
-                                      int direction)
-{
-       if (direction == PCI_DMA_NONE)
-               BUG();
-
-       /* Nothing to do */
-}
-
-/* Make physical memory consistent for a set of streaming
- * mode DMA translations after a transfer.
- *
- * The same as pci_dma_sync_single but for a scatter-gather list,
- * same rules and usage.
- */
-static inline void pci_dma_sync_sg(struct pci_dev *hwdev,
-                                  struct scatterlist *sg, int nelems,
-                                  int direction)
-{
-       if (direction == PCI_DMA_NONE)
-               BUG();
-
-       /* Nothing to do */
-}
 
 #endif                         /* _ASM_BFIN_PCI_H */
index 27290c955a7ae61dd6d0eb69bf842615667c9b0d..b33a4488f49856e53c804a260c7626ac08609ee7 100644 (file)
@@ -89,9 +89,9 @@ struct pt_regs {
 #define PTRACE_GETREGS            12
 #define PTRACE_SETREGS            13   /* ptrace signal  */
 
-#define PTRACE_GETFDPIC           31
-#define PTRACE_GETFDPIC_EXEC      0
-#define PTRACE_GETFDPIC_INTERP    1
+#define PTRACE_GETFDPIC           31   /* get the ELF fdpic loadmap address */
+#define PTRACE_GETFDPIC_EXEC       0   /* [addr] request the executable loadmap */
+#define PTRACE_GETFDPIC_INTERP     1   /* [addr] request the interpreter loadmap */
 
 #define PS_S  (0x0002)
 
index 1f5381fbb4a7483897ac7006c8ead510268a959c..42f6c53c59c651301e8547f820f6dddf3aeb9d20 100644 (file)
@@ -13,10 +13,18 @@ extern unsigned long memory_mtd_start, memory_mtd_end, mtd_size;
 extern unsigned long _ramstart, _ramend, _rambase;
 extern unsigned long memory_start, memory_end, physical_mem_end;
 
-extern char _stext_l1[], _etext_l1[], _sdata_l1[], _edata_l1[], _sbss_l1[],
-       _ebss_l1[], _l1_lma_start[], _sdata_b_l1[], _sbss_b_l1[], _ebss_b_l1[],
-       _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[], _sbss_l2[],
-       _ebss_l2[], _l2_lma_start[];
+/*
+ * The weak markings on the lengths might seem weird, but this is required
+ * in order to make gcc accept the fact that these may actually have a value
+ * of 0 (since they aren't actually addresses, but sizes of sections).
+ */
+extern char _stext_l1[], _etext_l1[], _text_l1_lma[], __weak _text_l1_len[];
+extern char _sdata_l1[], _edata_l1[], _sbss_l1[], _ebss_l1[],
+       _data_l1_lma[], __weak _data_l1_len[];
+extern char _sdata_b_l1[], _edata_b_l1[], _sbss_b_l1[], _ebss_b_l1[],
+       _data_b_l1_lma[], __weak _data_b_l1_len[];
+extern char _stext_l2[], _etext_l2[], _sdata_l2[], _edata_l2[],
+       _sbss_l2[], _ebss_l2[], _l2_lma[], __weak _l2_len[];
 
 #include <asm/mem_map.h>
 
index b0c7f0ee4b03e54d3d24004d9df75e1345c4ce8a..1942ccfedbe01fc0b9dfe5681aec33e5e2258a8b 100644 (file)
@@ -17,84 +17,84 @@ asmlinkage int __raw_spin_is_locked_asm(volatile int *ptr);
 asmlinkage void __raw_spin_lock_asm(volatile int *ptr);
 asmlinkage int __raw_spin_trylock_asm(volatile int *ptr);
 asmlinkage void __raw_spin_unlock_asm(volatile int *ptr);
-asmlinkage void __raw_read_lock_asm(volatile int *ptr);
-asmlinkage int __raw_read_trylock_asm(volatile int *ptr);
-asmlinkage void __raw_read_unlock_asm(volatile int *ptr);
-asmlinkage void __raw_write_lock_asm(volatile int *ptr);
-asmlinkage int __raw_write_trylock_asm(volatile int *ptr);
-asmlinkage void __raw_write_unlock_asm(volatile int *ptr);
-
-static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
+asmlinkage void arch_read_lock_asm(volatile int *ptr);
+asmlinkage int arch_read_trylock_asm(volatile int *ptr);
+asmlinkage void arch_read_unlock_asm(volatile int *ptr);
+asmlinkage void arch_write_lock_asm(volatile int *ptr);
+asmlinkage int arch_write_trylock_asm(volatile int *ptr);
+asmlinkage void arch_write_unlock_asm(volatile int *ptr);
+
+static inline int arch_spin_is_locked(arch_spinlock_t *lock)
 {
        return __raw_spin_is_locked_asm(&lock->lock);
 }
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        __raw_spin_lock_asm(&lock->lock);
 }
 
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
+#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        return __raw_spin_trylock_asm(&lock->lock);
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        __raw_spin_unlock_asm(&lock->lock);
 }
 
-static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
+static inline void arch_spin_unlock_wait(arch_spinlock_t *lock)
 {
-       while (__raw_spin_is_locked(lock))
+       while (arch_spin_is_locked(lock))
                cpu_relax();
 }
 
-static inline int __raw_read_can_lock(raw_rwlock_t *rw)
+static inline int arch_read_can_lock(arch_rwlock_t *rw)
 {
        return __raw_uncached_fetch_asm(&rw->lock) > 0;
 }
 
-static inline int __raw_write_can_lock(raw_rwlock_t *rw)
+static inline int arch_write_can_lock(arch_rwlock_t *rw)
 {
        return __raw_uncached_fetch_asm(&rw->lock) == RW_LOCK_BIAS;
 }
 
-static inline void __raw_read_lock(raw_rwlock_t *rw)
+static inline void arch_read_lock(arch_rwlock_t *rw)
 {
-       __raw_read_lock_asm(&rw->lock);
+       arch_read_lock_asm(&rw->lock);
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t *rw)
+static inline int arch_read_trylock(arch_rwlock_t *rw)
 {
-       return __raw_read_trylock_asm(&rw->lock);
+       return arch_read_trylock_asm(&rw->lock);
 }
 
-static inline void __raw_read_unlock(raw_rwlock_t *rw)
+static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
-       __raw_read_unlock_asm(&rw->lock);
+       arch_read_unlock_asm(&rw->lock);
 }
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
-       __raw_write_lock_asm(&rw->lock);
+       arch_write_lock_asm(&rw->lock);
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *rw)
+static inline int arch_write_trylock(arch_rwlock_t *rw)
 {
-       return __raw_write_trylock_asm(&rw->lock);
+       return arch_write_trylock_asm(&rw->lock);
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t *rw)
+static inline void arch_write_unlock(arch_rwlock_t *rw)
 {
-       __raw_write_unlock_asm(&rw->lock);
+       arch_write_unlock_asm(&rw->lock);
 }
 
-#define _raw_spin_relax(lock)          cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)          cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif
 
index be75762c06100a3b2e19255a855c29dabd99c120..1a33608c958b90fa0bd43aebd019c884389afa41 100644 (file)
 
 typedef struct {
        volatile unsigned int lock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        volatile unsigned int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { RW_LOCK_BIAS }
+#define __ARCH_RW_LOCK_UNLOCKED                { RW_LOCK_BIAS }
 
 #endif
index afb3a86263806ec830efde8d057767355e0f235e..a40d9368c38a3c3e8a78b9d79b962150831abc2d 100644 (file)
@@ -103,11 +103,13 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_RESTORE_SIGMASK    5       /* restore signal mask in do_signal() */
 #define TIF_FREEZE              6       /* is freezing for suspend */
 #define TIF_IRQ_SYNC            7       /* sync pipeline stage */
+#define TIF_NOTIFY_RESUME       8       /* callback before returning to user */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE     (1<<TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING                (1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED      (1<<TIF_NEED_RESCHED)
+#define _TIF_NOTIFY_RESUME     (1<<TIF_NOTIFY_RESUME)
 #define _TIF_POLLING_NRFLAG    (1<<TIF_POLLING_NRFLAG)
 #define _TIF_RESTORE_SIGMASK   (1<<TIF_RESTORE_SIGMASK)
 #define _TIF_FREEZE             (1<<TIF_FREEZE)
index 609ad3c841891c0bb59cb9784edf113da932ed39..dc0aa55ae773420fb426733e0b437d089580a692 100644 (file)
@@ -28,6 +28,8 @@ extern unsigned long software_trace_buff[];
 
 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
 
+#define trace_buffer_init() bfin_write_TBUFCTL(BFIN_TRACE_INIT)
+
 #define trace_buffer_save(x) \
        do { \
                (x) = bfin_read_TBUFCTL(); \
index c03b8532aad398cef7bcfcee584a9765c0bf9dc2..1c0d190adaefa7a6555dfd079b7bac0da273b175 100644 (file)
@@ -17,9 +17,7 @@
 #include <linux/string.h>
 
 #include <asm/segment.h>
-#ifdef CONFIG_ACCESS_CHECK
-# include <asm/bfin-global.h>
-#endif
+#include <asm/sections.h>
 
 #define get_ds()        (KERNEL_DS)
 #define get_fs()        (current_thread_info()->addr_limit)
index 779be02a910a8d9e730586eae8ec3b5488242079..22886cbdae7aa2b7c615bd800259600bc1148bf6 100644 (file)
 #define __NR_pwritev           367
 #define __NR_rt_tgsigqueueinfo 368
 #define __NR_perf_event_open   369
+#define __NR_recvmmsg          370
 
-#define __NR_syscall           370
+#define __NR_syscall           371
 #define NR_syscalls            __NR_syscall
 
 /* Old optional stuff no one actually uses */
index 3946aff4f4148b6133f31429fbbe9facb40b35c0..924c00286bab84d87611bc8896df9ba85806fd09 100644 (file)
@@ -37,9 +37,8 @@ static int __init blackfin_dma_init(void)
        printk(KERN_INFO "Blackfin DMA Controller\n");
 
        for (i = 0; i < MAX_DMA_CHANNELS; i++) {
-               dma_ch[i].chan_status = DMA_CHANNEL_FREE;
+               atomic_set(&dma_ch[i].chan_status, 0);
                dma_ch[i].regs = dma_io_base_addr[i];
-               mutex_init(&(dma_ch[i].dmalock));
        }
        /* Mark MEMDMA Channel 0 as requested since we're using it internally */
        request_dma(CH_MEM_STREAM0_DEST, "Blackfin dma_memcpy");
@@ -60,7 +59,7 @@ static int proc_dma_show(struct seq_file *m, void *v)
        int i;
 
        for (i = 0; i < MAX_DMA_CHANNELS; ++i)
-               if (dma_ch[i].chan_status != DMA_CHANNEL_FREE)
+               if (dma_channel_active(i))
                        seq_printf(m, "%2d: %s\n", i, dma_ch[i].device_id);
 
        return 0;
@@ -107,20 +106,11 @@ int request_dma(unsigned int channel, const char *device_id)
        }
 #endif
 
-       mutex_lock(&(dma_ch[channel].dmalock));
-
-       if ((dma_ch[channel].chan_status == DMA_CHANNEL_REQUESTED)
-           || (dma_ch[channel].chan_status == DMA_CHANNEL_ENABLED)) {
-               mutex_unlock(&(dma_ch[channel].dmalock));
+       if (atomic_cmpxchg(&dma_ch[channel].chan_status, 0, 1)) {
                pr_debug("DMA CHANNEL IN USE  \n");
                return -EBUSY;
-       } else {
-               dma_ch[channel].chan_status = DMA_CHANNEL_REQUESTED;
-               pr_debug("DMA CHANNEL IS ALLOCATED  \n");
        }
 
-       mutex_unlock(&(dma_ch[channel].dmalock));
-
 #ifdef CONFIG_BF54x
        if (channel >= CH_UART2_RX && channel <= CH_UART3_TX) {
                unsigned int per_map;
@@ -148,21 +138,20 @@ EXPORT_SYMBOL(request_dma);
 
 int set_dma_callback(unsigned int channel, irq_handler_t callback, void *data)
 {
-       BUG_ON(channel >= MAX_DMA_CHANNELS ||
-                       dma_ch[channel].chan_status == DMA_CHANNEL_FREE);
+       int ret;
+       unsigned int irq;
 
-       if (callback != NULL) {
-               int ret;
-               unsigned int irq = channel2irq(channel);
+       BUG_ON(channel >= MAX_DMA_CHANNELS || !callback ||
+                       !atomic_read(&dma_ch[channel].chan_status));
 
-               ret = request_irq(irq, callback, IRQF_DISABLED,
-                       dma_ch[channel].device_id, data);
-               if (ret)
-                       return ret;
+       irq = channel2irq(channel);
+       ret = request_irq(irq, callback, 0, dma_ch[channel].device_id, data);
+       if (ret)
+               return ret;
+
+       dma_ch[channel].irq = irq;
+       dma_ch[channel].data = data;
 
-               dma_ch[channel].irq = irq;
-               dma_ch[channel].data = data;
-       }
        return 0;
 }
 EXPORT_SYMBOL(set_dma_callback);
@@ -184,7 +173,7 @@ void free_dma(unsigned int channel)
 {
        pr_debug("freedma() : BEGIN \n");
        BUG_ON(channel >= MAX_DMA_CHANNELS ||
-                       dma_ch[channel].chan_status == DMA_CHANNEL_FREE);
+                       !atomic_read(&dma_ch[channel].chan_status));
 
        /* Halt the DMA */
        disable_dma(channel);
@@ -194,9 +183,7 @@ void free_dma(unsigned int channel)
                free_irq(dma_ch[channel].irq, dma_ch[channel].data);
 
        /* Clear the DMA Variable in the Channel */
-       mutex_lock(&(dma_ch[channel].dmalock));
-       dma_ch[channel].chan_status = DMA_CHANNEL_FREE;
-       mutex_unlock(&(dma_ch[channel].dmalock));
+       atomic_set(&dma_ch[channel].chan_status, 0);
 
        pr_debug("freedma() : END \n");
 }
@@ -210,13 +197,14 @@ int blackfin_dma_suspend(void)
 {
        int i;
 
-       for (i = 0; i < MAX_DMA_SUSPEND_CHANNELS; ++i) {
-               if (dma_ch[i].chan_status == DMA_CHANNEL_ENABLED) {
+       for (i = 0; i < MAX_DMA_CHANNELS; ++i) {
+               if (dma_ch[i].regs->cfg & DMAEN) {
                        printk(KERN_ERR "DMA Channel %d failed to suspend\n", i);
                        return -EBUSY;
                }
 
-               dma_ch[i].saved_peripheral_map = dma_ch[i].regs->peripheral_map;
+               if (i < MAX_DMA_SUSPEND_CHANNELS)
+                       dma_ch[i].saved_peripheral_map = dma_ch[i].regs->peripheral_map;
        }
 
        return 0;
index 22705eeff34f5b64c4f510cc4a781a18d6afc0f8..a174596cc009b513d5221bb222b43b0246255684 100644 (file)
@@ -100,6 +100,12 @@ u8 pmux_offset[][16] = {
 };
 # endif
 
+#elif defined(BF538_FAMILY)
+static unsigned short * const port_fer[] = {
+       (unsigned short *) PORTCIO_FER,
+       (unsigned short *) PORTDIO_FER,
+       (unsigned short *) PORTEIO_FER,
+};
 #endif
 
 static unsigned short reserved_gpio_map[GPIO_BANK_NUM];
@@ -163,6 +169,27 @@ static int cmp_label(unsigned short ident, const char *label)
 
 static void port_setup(unsigned gpio, unsigned short usage)
 {
+#if defined(BF538_FAMILY)
+       /*
+        * BF538/9 Port C,D and E are special.
+        * Inverted PORT_FER polarity on CDE and no PORF_FER on F
+        * Regular PORT F GPIOs are handled here, CDE are exclusively
+        * managed by GPIOLIB
+        */
+
+       if (gpio < MAX_BLACKFIN_GPIOS || gpio >= MAX_RESOURCES)
+               return;
+
+       gpio -= MAX_BLACKFIN_GPIOS;
+
+       if (usage == GPIO_USAGE)
+               *port_fer[gpio_bank(gpio)] |= gpio_bit(gpio);
+       else
+               *port_fer[gpio_bank(gpio)] &= ~gpio_bit(gpio);
+       SSYNC();
+       return;
+#endif
+
        if (check_gpio(gpio))
                return;
 
@@ -762,6 +789,8 @@ int peripheral_request(unsigned short per, const char *label)
        if (!(per & P_DEFINED))
                return -ENODEV;
 
+       BUG_ON(ident >= MAX_RESOURCES);
+
        local_irq_save_hw(flags);
 
        /* If a pin can be muxed as either GPIO or peripheral, make
@@ -979,6 +1008,76 @@ void bfin_gpio_free(unsigned gpio)
 }
 EXPORT_SYMBOL(bfin_gpio_free);
 
+#ifdef BFIN_SPECIAL_GPIO_BANKS
+static unsigned short reserved_special_gpio_map[gpio_bank(MAX_RESOURCES)];
+
+int bfin_special_gpio_request(unsigned gpio, const char *label)
+{
+       unsigned long flags;
+
+       local_irq_save_hw(flags);
+
+       /*
+        * Allow that the identical GPIO can
+        * be requested from the same driver twice
+        * Do nothing and return -
+        */
+
+       if (cmp_label(gpio, label) == 0) {
+               local_irq_restore_hw(flags);
+               return 0;
+       }
+
+       if (unlikely(reserved_special_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
+               local_irq_restore_hw(flags);
+               printk(KERN_ERR "bfin-gpio: GPIO %d is already reserved by %s !\n",
+                      gpio, get_label(gpio));
+
+               return -EBUSY;
+       }
+       if (unlikely(reserved_peri_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
+               local_irq_restore_hw(flags);
+               printk(KERN_ERR
+                      "bfin-gpio: GPIO %d is already reserved as Peripheral by %s !\n",
+                      gpio, get_label(gpio));
+
+               return -EBUSY;
+       }
+
+       reserved_special_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio);
+       reserved_peri_map[gpio_bank(gpio)] |= gpio_bit(gpio);
+
+       set_label(gpio, label);
+       local_irq_restore_hw(flags);
+       port_setup(gpio, GPIO_USAGE);
+
+       return 0;
+}
+EXPORT_SYMBOL(bfin_special_gpio_request);
+
+void bfin_special_gpio_free(unsigned gpio)
+{
+       unsigned long flags;
+
+       might_sleep();
+
+       local_irq_save_hw(flags);
+
+       if (unlikely(!(reserved_special_gpio_map[gpio_bank(gpio)] & gpio_bit(gpio)))) {
+               gpio_error(gpio);
+               local_irq_restore_hw(flags);
+               return;
+       }
+
+       reserved_special_gpio_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
+       reserved_peri_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
+       set_label(gpio, "free");
+       local_irq_restore_hw(flags);
+}
+EXPORT_SYMBOL(bfin_special_gpio_free);
+#endif
+
+
 int bfin_gpio_irq_request(unsigned gpio, const char *label)
 {
        unsigned long flags;
index b52c1f8c4bc0e9451ab2def134dfc7e095e45185..8d42b9e50dfa16a21679674a63669762862800a3 100644 (file)
@@ -92,6 +92,6 @@ void __init generate_cplb_tables_cpu(unsigned int cpu)
                icplb_tbl[cpu][i_i++].data = 0;
 }
 
-void generate_cplb_tables_all(void)
+void __init generate_cplb_tables_all(void)
 {
 }
index 69e0e530d70ff2940c468c5bf34e62ddd0cac76b..930c01c0681348bd51f1ddc6a0d1e413cd9acad4 100644 (file)
@@ -113,11 +113,11 @@ static noinline int dcplb_miss(unsigned int cpu)
                addr = L2_START;
                d_data = L2_DMEMORY;
        } else if (addr >= physical_mem_end) {
-               if (addr >= ASYNC_BANK0_BASE && addr < ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE
-                   && (status & FAULT_USERSUPV)) {
-                       addr &= ~0x3fffff;
+               if (addr >= ASYNC_BANK0_BASE && addr < ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE) {
+                       addr &= ~(4 * 1024 * 1024 - 1);
                        d_data &= ~PAGE_SIZE_4KB;
                        d_data |= PAGE_SIZE_4MB;
+                       d_data |= CPLB_USER_RD | CPLB_USER_WR;
                } else if (addr >= BOOT_ROM_START && addr < BOOT_ROM_START + BOOT_ROM_LENGTH
                    && (status & (FAULT_RW | FAULT_USERSUPV)) == FAULT_USERSUPV) {
                        addr &= ~(1 * 1024 * 1024 - 1);
@@ -203,7 +203,12 @@ static noinline int icplb_miss(unsigned int cpu)
                addr = L2_START;
                i_data = L2_IMEMORY;
        } else if (addr >= physical_mem_end) {
-               if (addr >= BOOT_ROM_START && addr < BOOT_ROM_START + BOOT_ROM_LENGTH
+               if (addr >= ASYNC_BANK0_BASE && addr < ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE) {
+                       addr &= ~(4 * 1024 * 1024 - 1);
+                       i_data &= ~PAGE_SIZE_4KB;
+                       i_data |= PAGE_SIZE_4MB;
+                       i_data |= CPLB_USER_RD;
+               } else if (addr >= BOOT_ROM_START && addr < BOOT_ROM_START + BOOT_ROM_LENGTH
                    && (status & FAULT_USERSUPV)) {
                        addr &= ~(1 * 1024 * 1024 - 1);
                        i_data &= ~PAGE_SIZE_4KB;
index fd9a2f31e686f63ceabe2354b401df5c919bb1f6..282a7919821b0a8776dd9283bdca4e2677f893a0 100644 (file)
@@ -89,15 +89,25 @@ void __init generate_cplb_tables_cpu(unsigned int cpu)
 
 void __init generate_cplb_tables_all(void)
 {
+       unsigned long uncached_end;
        int i_d, i_i;
 
        i_d = 0;
        /* Normal RAM, including MTD FS.  */
 #ifdef CONFIG_MTD_UCLINUX
-       dcplb_bounds[i_d].eaddr = memory_mtd_start + mtd_size;
+       uncached_end = memory_mtd_start + mtd_size;
 #else
-       dcplb_bounds[i_d].eaddr = memory_end;
+       uncached_end = memory_end;
 #endif
+       /*
+        * if DMA uncached is less than 1MB, mark the 1MB chunk as uncached
+        * so that we don't have to use 4kB pages and cause CPLB thrashing
+        */
+       if ((DMA_UNCACHED_REGION >= 1 * 1024 * 1024) || !DMA_UNCACHED_REGION ||
+           ((_ramend - uncached_end) >= 1 * 1024 * 1024))
+               dcplb_bounds[i_d].eaddr = uncached_end;
+       else
+               dcplb_bounds[i_d].eaddr = uncached_end & ~(1 * 1024 * 1024);
        dcplb_bounds[i_d++].data = SDRAM_DGENERIC;
        /* DMA uncached region.  */
        if (DMA_UNCACHED_REGION) {
@@ -135,18 +145,15 @@ void __init generate_cplb_tables_all(void)
 
        i_i = 0;
        /* Normal RAM, including MTD FS.  */
-#ifdef CONFIG_MTD_UCLINUX
-       icplb_bounds[i_i].eaddr = memory_mtd_start + mtd_size;
-#else
-       icplb_bounds[i_i].eaddr = memory_end;
-#endif
+       icplb_bounds[i_i].eaddr = uncached_end;
        icplb_bounds[i_i++].data = SDRAM_IGENERIC;
-       /* DMA uncached region.  */
-       if (DMA_UNCACHED_REGION) {
-               icplb_bounds[i_i].eaddr = _ramend;
-               icplb_bounds[i_i++].data = 0;
-       }
        if (_ramend != physical_mem_end) {
+               /* DMA uncached region.  */
+               if (DMA_UNCACHED_REGION) {
+                       /* Normally this hole is caught by the async below.  */
+                       icplb_bounds[i_i].eaddr = _ramend;
+                       icplb_bounds[i_i++].data = 0;
+               }
                /* Reserved memory.  */
                icplb_bounds[i_i].eaddr = physical_mem_end;
                icplb_bounds[i_i++].data = (reserved_mem_icache_on ?
index e74e74d7733ff254ecb5cba001eeb28765be2c94..e937f323d82c6f61dd4dc4309eabcb413fc99f76 100644 (file)
@@ -7,30 +7,25 @@
  */
 
 #include <linux/types.h>
-#include <linux/mm.h>
+#include <linux/gfp.h>
 #include <linux/string.h>
-#include <linux/bootmem.h>
 #include <linux/spinlock.h>
-#include <linux/device.h>
 #include <linux/dma-mapping.h>
-#include <linux/io.h>
 #include <linux/scatterlist.h>
-#include <asm/cacheflush.h>
-#include <asm/bfin-global.h>
 
 static spinlock_t dma_page_lock;
-static unsigned int *dma_page;
+static unsigned long *dma_page;
 static unsigned int dma_pages;
 static unsigned long dma_base;
 static unsigned long dma_size;
 static unsigned int dma_initialized;
 
-void dma_alloc_init(unsigned long start, unsigned long end)
+static void dma_alloc_init(unsigned long start, unsigned long end)
 {
        spin_lock_init(&dma_page_lock);
        dma_initialized = 0;
 
-       dma_page = (unsigned int *)__get_free_page(GFP_KERNEL);
+       dma_page = (unsigned long *)__get_free_page(GFP_KERNEL);
        memset(dma_page, 0, PAGE_SIZE);
        dma_base = PAGE_ALIGN(start);
        dma_size = PAGE_ALIGN(end) - PAGE_ALIGN(start);
@@ -58,10 +53,11 @@ static unsigned long __alloc_dma_pages(unsigned int pages)
        spin_lock_irqsave(&dma_page_lock, flags);
 
        for (i = 0; i < dma_pages;) {
-               if (dma_page[i++] == 0) {
+               if (test_bit(i++, dma_page) == 0) {
                        if (++count == pages) {
                                while (count--)
-                                       dma_page[--i] = 1;
+                                       __set_bit(--i, dma_page);
+
                                ret = dma_base + (i << PAGE_SHIFT);
                                break;
                        }
@@ -84,14 +80,14 @@ static void __free_dma_pages(unsigned long addr, unsigned int pages)
        }
 
        spin_lock_irqsave(&dma_page_lock, flags);
-       for (i = page; i < page + pages; i++) {
-               dma_page[i] = 0;
-       }
+       for (i = page; i < page + pages; i++)
+               __clear_bit(i, dma_page);
+
        spin_unlock_irqrestore(&dma_page_lock, flags);
 }
 
 void *dma_alloc_coherent(struct device *dev, size_t size,
-                        dma_addr_t * dma_handle, gfp_t gfp)
+                        dma_addr_t *dma_handle, gfp_t gfp)
 {
        void *ret;
 
@@ -115,21 +111,14 @@ dma_free_coherent(struct device *dev, size_t size, void *vaddr,
 EXPORT_SYMBOL(dma_free_coherent);
 
 /*
- * Dummy functions defined for some existing drivers
+ * Streaming DMA mappings
  */
-
-dma_addr_t
-dma_map_single(struct device *dev, void *ptr, size_t size,
-              enum dma_data_direction direction)
+void __dma_sync(dma_addr_t addr, size_t size,
+               enum dma_data_direction dir)
 {
-       BUG_ON(direction == DMA_NONE);
-
-       invalidate_dcache_range((unsigned long)ptr,
-                       (unsigned long)ptr + size);
-
-       return (dma_addr_t) ptr;
+       _dma_sync(addr, size, dir);
 }
-EXPORT_SYMBOL(dma_map_single);
+EXPORT_SYMBOL(__dma_sync);
 
 int
 dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
@@ -137,30 +126,23 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
 {
        int i;
 
-       BUG_ON(direction == DMA_NONE);
-
        for (i = 0; i < nents; i++, sg++) {
                sg->dma_address = (dma_addr_t) sg_virt(sg);
-
-               invalidate_dcache_range(sg_dma_address(sg),
-                                       sg_dma_address(sg) +
-                                       sg_dma_len(sg));
+               __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction);
        }
 
        return nents;
 }
 EXPORT_SYMBOL(dma_map_sg);
 
-void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
-               enum dma_data_direction direction)
+void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
+                           int nelems, enum dma_data_direction direction)
 {
-       BUG_ON(direction == DMA_NONE);
-}
-EXPORT_SYMBOL(dma_unmap_single);
+       int i;
 
-void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
-               int nhwentries, enum dma_data_direction direction)
-{
-       BUG_ON(direction == DMA_NONE);
+       for (i = 0; i < nelems; i++, sg++) {
+               sg->dma_address = (dma_addr_t) sg_virt(sg);
+               __dma_sync(sg_dma_address(sg), sg_dma_len(sg), direction);
+       }
 }
-EXPORT_SYMBOL(dma_unmap_sg);
+EXPORT_SYMBOL(dma_sync_sg_for_device);
index 7281a91d26b5cfc2c328eef44ae327ac753bd6b4..cdbe075de1dc6841411310ef481ed26a4210c2f2 100644 (file)
@@ -137,7 +137,7 @@ static uint32_t const timil_mask[MAX_BLACKFIN_GPTIMERS] =
 #endif
 };
 
-void set_gptimer_pwidth(int timer_id, uint32_t value)
+void set_gptimer_pwidth(unsigned int timer_id, uint32_t value)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        timer_regs[timer_id]->width = value;
@@ -145,14 +145,14 @@ void set_gptimer_pwidth(int timer_id, uint32_t value)
 }
 EXPORT_SYMBOL(set_gptimer_pwidth);
 
-uint32_t get_gptimer_pwidth(int timer_id)
+uint32_t get_gptimer_pwidth(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        return timer_regs[timer_id]->width;
 }
 EXPORT_SYMBOL(get_gptimer_pwidth);
 
-void set_gptimer_period(int timer_id, uint32_t period)
+void set_gptimer_period(unsigned int timer_id, uint32_t period)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        timer_regs[timer_id]->period = period;
@@ -160,28 +160,28 @@ void set_gptimer_period(int timer_id, uint32_t period)
 }
 EXPORT_SYMBOL(set_gptimer_period);
 
-uint32_t get_gptimer_period(int timer_id)
+uint32_t get_gptimer_period(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        return timer_regs[timer_id]->period;
 }
 EXPORT_SYMBOL(get_gptimer_period);
 
-uint32_t get_gptimer_count(int timer_id)
+uint32_t get_gptimer_count(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        return timer_regs[timer_id]->counter;
 }
 EXPORT_SYMBOL(get_gptimer_count);
 
-uint32_t get_gptimer_status(int group)
+uint32_t get_gptimer_status(unsigned int group)
 {
        tassert(group < BFIN_TIMER_NUM_GROUP);
        return group_regs[group]->status;
 }
 EXPORT_SYMBOL(get_gptimer_status);
 
-void set_gptimer_status(int group, uint32_t value)
+void set_gptimer_status(unsigned int group, uint32_t value)
 {
        tassert(group < BFIN_TIMER_NUM_GROUP);
        group_regs[group]->status = value;
@@ -189,42 +189,42 @@ void set_gptimer_status(int group, uint32_t value)
 }
 EXPORT_SYMBOL(set_gptimer_status);
 
-int get_gptimer_intr(int timer_id)
+int get_gptimer_intr(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & timil_mask[timer_id]);
 }
 EXPORT_SYMBOL(get_gptimer_intr);
 
-void clear_gptimer_intr(int timer_id)
+void clear_gptimer_intr(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        group_regs[BFIN_TIMER_OCTET(timer_id)]->status = timil_mask[timer_id];
 }
 EXPORT_SYMBOL(clear_gptimer_intr);
 
-int get_gptimer_over(int timer_id)
+int get_gptimer_over(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & tovf_mask[timer_id]);
 }
 EXPORT_SYMBOL(get_gptimer_over);
 
-void clear_gptimer_over(int timer_id)
+void clear_gptimer_over(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        group_regs[BFIN_TIMER_OCTET(timer_id)]->status = tovf_mask[timer_id];
 }
 EXPORT_SYMBOL(clear_gptimer_over);
 
-int get_gptimer_run(int timer_id)
+int get_gptimer_run(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        return !!(group_regs[BFIN_TIMER_OCTET(timer_id)]->status & trun_mask[timer_id]);
 }
 EXPORT_SYMBOL(get_gptimer_run);
 
-void set_gptimer_config(int timer_id, uint16_t config)
+void set_gptimer_config(unsigned int timer_id, uint16_t config)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        timer_regs[timer_id]->config = config;
@@ -232,7 +232,7 @@ void set_gptimer_config(int timer_id, uint16_t config)
 }
 EXPORT_SYMBOL(set_gptimer_config);
 
-uint16_t get_gptimer_config(int timer_id)
+uint16_t get_gptimer_config(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        return timer_regs[timer_id]->config;
@@ -280,7 +280,7 @@ void disable_gptimers_sync(uint16_t mask)
 }
 EXPORT_SYMBOL(disable_gptimers_sync);
 
-void set_gptimer_pulse_hi(int timer_id)
+void set_gptimer_pulse_hi(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        timer_regs[timer_id]->config |= TIMER_PULSE_HI;
@@ -288,7 +288,7 @@ void set_gptimer_pulse_hi(int timer_id)
 }
 EXPORT_SYMBOL(set_gptimer_pulse_hi);
 
-void clear_gptimer_pulse_hi(int timer_id)
+void clear_gptimer_pulse_hi(unsigned int timer_id)
 {
        tassert(timer_id < MAX_BLACKFIN_GPTIMERS);
        timer_regs[timer_id]->config &= ~TIMER_PULSE_HI;
index 5d7382396dc02846d62b56506cb9088ae9ed66f6..a77307a4473b3f6ab5395ffb8f1a337982f99483 100644 (file)
@@ -335,3 +335,70 @@ void __ipipe_enable_root_irqs_hw(void)
        __clear_bit(IPIPE_STALL_FLAG, &ipipe_root_cpudom_var(status));
        bfin_sti(bfin_irq_flags);
 }
+
+/*
+ * We could use standard atomic bitops in the following root status
+ * manipulation routines, but let's prepare for SMP support in the
+ * same move, preventing CPU migration as required.
+ */
+void __ipipe_stall_root(void)
+{
+       unsigned long *p, flags;
+
+       local_irq_save_hw(flags);
+       p = &__ipipe_root_status;
+       __set_bit(IPIPE_STALL_FLAG, p);
+       local_irq_restore_hw(flags);
+}
+EXPORT_SYMBOL(__ipipe_stall_root);
+
+unsigned long __ipipe_test_and_stall_root(void)
+{
+       unsigned long *p, flags;
+       int x;
+
+       local_irq_save_hw(flags);
+       p = &__ipipe_root_status;
+       x = __test_and_set_bit(IPIPE_STALL_FLAG, p);
+       local_irq_restore_hw(flags);
+
+       return x;
+}
+EXPORT_SYMBOL(__ipipe_test_and_stall_root);
+
+unsigned long __ipipe_test_root(void)
+{
+       const unsigned long *p;
+       unsigned long flags;
+       int x;
+
+       local_irq_save_hw_smp(flags);
+       p = &__ipipe_root_status;
+       x = test_bit(IPIPE_STALL_FLAG, p);
+       local_irq_restore_hw_smp(flags);
+
+       return x;
+}
+EXPORT_SYMBOL(__ipipe_test_root);
+
+void __ipipe_lock_root(void)
+{
+       unsigned long *p, flags;
+
+       local_irq_save_hw(flags);
+       p = &__ipipe_root_status;
+       __set_bit(IPIPE_SYNCDEFER_FLAG, p);
+       local_irq_restore_hw(flags);
+}
+EXPORT_SYMBOL(__ipipe_lock_root);
+
+void __ipipe_unlock_root(void)
+{
+       unsigned long *p, flags;
+
+       local_irq_save_hw(flags);
+       p = &__ipipe_root_status;
+       __clear_bit(IPIPE_SYNCDEFER_FLAG, p);
+       local_irq_restore_hw(flags);
+}
+EXPORT_SYMBOL(__ipipe_unlock_root);
index db9f9c91f11f926730ffc42df62a4daa4b840645..64cff54a8a58c488175b4fde8f88037107bc6c68 100644 (file)
@@ -23,7 +23,7 @@ void ack_bad_irq(unsigned int irq)
 
 static struct irq_desc bad_irq_desc = {
        .handle_irq = handle_bad_irq,
-       .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
+       .lock = __RAW_SPIN_LOCK_UNLOCKED(bad_irq_desc.lock),
 };
 
 #ifdef CONFIG_CPUMASK_OFFSTACK
@@ -39,7 +39,7 @@ int show_interrupts(struct seq_file *p, void *v)
        unsigned long flags;
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -53,7 +53,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
  skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        } else if (i == NR_IRQS) {
                seq_printf(p, "NMI: ");
                for_each_online_cpu(j)
index cce79d05b90b733228a2e012376616a3810bb64c..f1036b6b92936fbfb5eba7a74f2026613c3c3d49 100644 (file)
 #include <asm/blackfin.h>
 #include <asm/dma.h>
 
-/* Put the error code here just in case the user cares.  */
-int gdb_bfin_errcode;
-/* Likewise, the vector number here (since GDB only gets the signal
-   number through the usual means, and that's not very specific).  */
-int gdb_bfin_vector = -1;
-
-#if KGDB_MAX_NO_CPUS != 8
-#error change the definition of slavecpulocks
-#endif
-
 void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
 {
        gdb_regs[BFIN_R0] = regs->r0;
@@ -369,13 +359,6 @@ void kgdb_roundup_cpu(int cpu, unsigned long flags)
 }
 #endif
 
-void kgdb_post_primary_code(struct pt_regs *regs, int eVector, int err_code)
-{
-       /* Master processor is completely in the debugger */
-       gdb_bfin_vector = eVector;
-       gdb_bfin_errcode = err_code;
-}
-
 int kgdb_arch_handle_exception(int vector, int signo,
                               int err_code, char *remcom_in_buffer,
                               char *remcom_out_buffer,
index 59fc42dc5d6a2e49f5014cbcada34fde53abed7f..9a4b07594389a6f45f390885f8e62a6365356ded 100644 (file)
@@ -17,8 +17,9 @@
 
 #include <asm/blackfin.h>
 
+/* Symbols are here for kgdb test to poke directly */
 static char cmdline[256];
-static unsigned long len;
+static size_t len;
 
 #ifndef CONFIG_SMP
 static int num1 __attribute__((l1_data));
@@ -27,11 +28,10 @@ void kgdb_l1_test(void) __attribute__((l1_text));
 
 void kgdb_l1_test(void)
 {
-       printk(KERN_ALERT "L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1);
-       printk(KERN_ALERT "L1 : code function addr = 0x%p\n", kgdb_l1_test);
-       num1 = num1 + 10 ;
-       printk(KERN_ALERT "L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1);
-       return ;
+       pr_alert("L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1);
+       pr_alert("L1 : code function addr = 0x%p\n", kgdb_l1_test);
+       num1 = num1 + 10;
+       pr_alert("L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1);
 }
 #endif
 
@@ -42,11 +42,10 @@ void kgdb_l2_test(void) __attribute__((l2));
 
 void kgdb_l2_test(void)
 {
-       printk(KERN_ALERT "L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2);
-       printk(KERN_ALERT "L2 : code function addr = 0x%p\n", kgdb_l2_test);
-       num2 = num2 + 20 ;
-       printk(KERN_ALERT "L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2);
-       return ;
+       pr_alert("L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2);
+       pr_alert("L2 : code function addr = 0x%p\n", kgdb_l2_test);
+       num2 = num2 + 20;
+       pr_alert("L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2);
 }
 
 #endif
@@ -54,12 +53,14 @@ void kgdb_l2_test(void)
 
 int kgdb_test(char *name, int len, int count, int z)
 {
-       printk(KERN_ALERT "kgdb name(%d): %s, %d, %d\n", len, name, count, z);
+       pr_alert("kgdb name(%d): %s, %d, %d\n", len, name, count, z);
        count = z;
        return count;
 }
 
-static int test_proc_output(char *buf)
+static ssize_t
+kgdb_test_proc_read(struct file *file, char __user *buf,
+                    size_t count, loff_t *ppos)
 {
        kgdb_test("hello world!", 12, 0x55, 0x10);
 #ifndef CONFIG_SMP
@@ -72,49 +73,31 @@ static int test_proc_output(char *buf)
        return 0;
 }
 
-static int test_read_proc(char *page, char **start, off_t off,
-                                int count, int *eof, void *data)
+static ssize_t
+kgdb_test_proc_write(struct file *file, const char __user *buffer,
+                     size_t count, loff_t *pos)
 {
-       int len;
-
-       len = test_proc_output(page);
-       if (len <= off+count)
-               *eof = 1;
-       *start = page + off;
-       len -= off;
-       if (len > count)
-               len = count;
-       if (len < 0)
-               len = 0;
-       return len;
-}
-
-static int test_write_proc(struct file *file, const char *buffer,
-                                unsigned long count, void *data)
-{
-       if (count >= 256)
-               len = 255;
-       else
-               len = count;
-
+       len = min_t(size_t, 255, count);
        memcpy(cmdline, buffer, count);
        cmdline[len] = 0;
 
        return len;
 }
 
+static const struct file_operations kgdb_test_proc_fops = {
+       .owner = THIS_MODULE,
+       .read  = kgdb_test_proc_read,
+       .write = kgdb_test_proc_write,
+};
+
 static int __init kgdbtest_init(void)
 {
        struct proc_dir_entry *entry;
 
-       entry = create_proc_entry("kgdbtest", 0, NULL);
+       entry = proc_create("kgdbtest", 0, NULL, &kgdb_test_proc_fops);
        if (entry == NULL)
                return -ENOMEM;
 
-       entry->read_proc = test_read_proc;
-       entry->write_proc = test_write_proc;
-       entry->data = NULL;
-
        return 0;
 }
 
index 45876427eb2dca826359b0767ace3d1523bc6c5c..b56b0e485e0bb3e8cb5e0ad79575d8e5eefad6de 100644 (file)
@@ -258,9 +258,12 @@ void finish_atomic_sections (struct pt_regs *regs)
        int __user *up0 = (int __user *)regs->p0;
 
        switch (regs->pc) {
+       default:
+               /* not in middle of an atomic step, so resume like normal */
+               return;
+
        case ATOMIC_XCHG32 + 2:
                put_user(regs->r1, up0);
-               regs->pc = ATOMIC_XCHG32 + 4;
                break;
 
        case ATOMIC_CAS32 + 2:
@@ -268,7 +271,6 @@ void finish_atomic_sections (struct pt_regs *regs)
                if (regs->r0 == regs->r1)
        case ATOMIC_CAS32 + 6:
                        put_user(regs->r2, up0);
-               regs->pc = ATOMIC_CAS32 + 8;
                break;
 
        case ATOMIC_ADD32 + 2:
@@ -276,7 +278,6 @@ void finish_atomic_sections (struct pt_regs *regs)
                /* fall through */
        case ATOMIC_ADD32 + 4:
                put_user(regs->r0, up0);
-               regs->pc = ATOMIC_ADD32 + 6;
                break;
 
        case ATOMIC_SUB32 + 2:
@@ -284,7 +285,6 @@ void finish_atomic_sections (struct pt_regs *regs)
                /* fall through */
        case ATOMIC_SUB32 + 4:
                put_user(regs->r0, up0);
-               regs->pc = ATOMIC_SUB32 + 6;
                break;
 
        case ATOMIC_IOR32 + 2:
@@ -292,7 +292,6 @@ void finish_atomic_sections (struct pt_regs *regs)
                /* fall through */
        case ATOMIC_IOR32 + 4:
                put_user(regs->r0, up0);
-               regs->pc = ATOMIC_IOR32 + 6;
                break;
 
        case ATOMIC_AND32 + 2:
@@ -300,7 +299,6 @@ void finish_atomic_sections (struct pt_regs *regs)
                /* fall through */
        case ATOMIC_AND32 + 4:
                put_user(regs->r0, up0);
-               regs->pc = ATOMIC_AND32 + 6;
                break;
 
        case ATOMIC_XOR32 + 2:
@@ -308,9 +306,15 @@ void finish_atomic_sections (struct pt_regs *regs)
                /* fall through */
        case ATOMIC_XOR32 + 4:
                put_user(regs->r0, up0);
-               regs->pc = ATOMIC_XOR32 + 6;
                break;
        }
+
+       /*
+        * We've finished the atomic section, and the only thing left for
+        * userspace is to do a RTS, so we might as well handle that too
+        * since we need to update the PC anyways.
+        */
+       regs->pc = regs->rets;
 }
 
 static inline
@@ -332,12 +336,58 @@ int in_mem_const(unsigned long addr, unsigned long size,
 {
        return in_mem_const_off(addr, size, 0, const_addr, const_size);
 }
-#define IN_ASYNC(bnum, bctlnum) \
+#define ASYNC_ENABLED(bnum, bctlnum) \
 ({ \
-       (bfin_read_EBIU_AMGCTL() & 0xe) < ((bnum + 1) << 1) ? -EFAULT : \
-       bfin_read_EBIU_AMBCTL##bctlnum() & B##bnum##RDYEN ? -EFAULT : \
-       BFIN_MEM_ACCESS_CORE; \
+       (bfin_read_EBIU_AMGCTL() & 0xe) < ((bnum + 1) << 1) ? 0 : \
+       bfin_read_EBIU_AMBCTL##bctlnum() & B##bnum##RDYEN ? 0 : \
+       1; \
 })
+/*
+ * We can't read EBIU banks that aren't enabled or we end up hanging
+ * on the access to the async space.  Make sure we validate accesses
+ * that cross async banks too.
+ *     0 - found, but unusable
+ *     1 - found & usable
+ *     2 - not found
+ */
+static
+int in_async(unsigned long addr, unsigned long size)
+{
+       if (addr >= ASYNC_BANK0_BASE && addr < ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE) {
+               if (!ASYNC_ENABLED(0, 0))
+                       return 0;
+               if (addr + size <= ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE)
+                       return 1;
+               size -= ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE - addr;
+               addr = ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE;
+       }
+       if (addr >= ASYNC_BANK1_BASE && addr < ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE) {
+               if (!ASYNC_ENABLED(1, 0))
+                       return 0;
+               if (addr + size <= ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE)
+                       return 1;
+               size -= ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE - addr;
+               addr = ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE;
+       }
+       if (addr >= ASYNC_BANK2_BASE && addr < ASYNC_BANK2_BASE + ASYNC_BANK2_SIZE) {
+               if (!ASYNC_ENABLED(2, 1))
+                       return 0;
+               if (addr + size <= ASYNC_BANK2_BASE + ASYNC_BANK2_SIZE)
+                       return 1;
+               size -= ASYNC_BANK2_BASE + ASYNC_BANK2_SIZE - addr;
+               addr = ASYNC_BANK2_BASE + ASYNC_BANK2_SIZE;
+       }
+       if (addr >= ASYNC_BANK3_BASE && addr < ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE) {
+               if (ASYNC_ENABLED(3, 1))
+                       return 0;
+               if (addr + size <= ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE)
+                       return 1;
+               return 0;
+       }
+
+       /* not within async bounds */
+       return 2;
+}
 
 int bfin_mem_access_type(unsigned long addr, unsigned long size)
 {
@@ -374,17 +424,11 @@ int bfin_mem_access_type(unsigned long addr, unsigned long size)
        if (addr >= SYSMMR_BASE)
                return BFIN_MEM_ACCESS_CORE_ONLY;
 
-       /* We can't read EBIU banks that aren't enabled or we end up hanging
-        * on the access to the async space.
-        */
-       if (in_mem_const(addr, size, ASYNC_BANK0_BASE, ASYNC_BANK0_SIZE))
-               return IN_ASYNC(0, 0);
-       if (in_mem_const(addr, size, ASYNC_BANK1_BASE, ASYNC_BANK1_SIZE))
-               return IN_ASYNC(1, 0);
-       if (in_mem_const(addr, size, ASYNC_BANK2_BASE, ASYNC_BANK2_SIZE))
-               return IN_ASYNC(2, 1);
-       if (in_mem_const(addr, size, ASYNC_BANK3_BASE, ASYNC_BANK3_SIZE))
-               return IN_ASYNC(3, 1);
+       switch (in_async(addr, size)) {
+       case 0: return -EFAULT;
+       case 1: return BFIN_MEM_ACCESS_CORE;
+       case 2: /* fall through */;
+       }
 
        if (in_mem_const(addr, size, BOOT_ROM_START, BOOT_ROM_LENGTH))
                return BFIN_MEM_ACCESS_CORE;
@@ -401,6 +445,8 @@ __attribute__((l1_text))
 /* Return 1 if access to memory range is OK, 0 otherwise */
 int _access_ok(unsigned long addr, unsigned long size)
 {
+       int aret;
+
        if (size == 0)
                return 1;
        /* Check that things do not wrap around */
@@ -450,6 +496,11 @@ int _access_ok(unsigned long addr, unsigned long size)
        if (in_mem_const(addr, size, COREB_L1_DATA_B_START, COREB_L1_DATA_B_LENGTH))
                return 1;
 #endif
+
+       aret = in_async(addr, size);
+       if (aret < 2)
+               return aret;
+
        if (in_mem_const_off(addr, size, _ebss_l2 - _stext_l2, L2_START, L2_LENGTH))
                return 1;
 
index 56b0ba12175f2d6922068c4284fa9a0487a75acd..65567dc4b9f5a0b1a10c5b5cddafab9bbbc99cc2 100644 (file)
@@ -316,19 +316,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                        case BFIN_MEM_ACCESS_CORE_ONLY:
                                copied = access_process_vm(child, addr, &data,
                                                           to_copy, 1);
-                               if (copied)
-                                       break;
-
-                               /* hrm, why didn't that work ... maybe no mapping */
-                               if (addr >= FIXED_CODE_START &&
-                                   addr + to_copy <= FIXED_CODE_END) {
-                                       copy_to_user_page(0, 0, 0, paddr, &data, to_copy);
-                                       copied = to_copy;
-                               } else if (addr >= BOOT_ROM_START) {
-                                       memcpy(paddr, &data, to_copy);
-                                       copied = to_copy;
-                               }
-
                                break;
                        case BFIN_MEM_ACCESS_DMA:
                                if (safe_dma_memcpy(paddr, &data, to_copy))
index c202a44d141696e2873edc1c9aa670396c91118b..95448ae9c43a79ff442fc67cb9a5bdf14a901316 100644 (file)
@@ -178,10 +178,10 @@ void __init bfin_cache_init(void)
 
 void __init bfin_relocate_l1_mem(void)
 {
-       unsigned long l1_code_length;
-       unsigned long l1_data_a_length;
-       unsigned long l1_data_b_length;
-       unsigned long l2_length;
+       unsigned long text_l1_len = (unsigned long)_text_l1_len;
+       unsigned long data_l1_len = (unsigned long)_data_l1_len;
+       unsigned long data_b_l1_len = (unsigned long)_data_b_l1_len;
+       unsigned long l2_len = (unsigned long)_l2_len;
 
        early_shadow_stamp();
 
@@ -201,30 +201,23 @@ void __init bfin_relocate_l1_mem(void)
 
        blackfin_dma_early_init();
 
-       /* if necessary, copy _stext_l1 to _etext_l1 to L1 instruction SRAM */
-       l1_code_length = _etext_l1 - _stext_l1;
-       if (l1_code_length)
-               early_dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length);
+       /* if necessary, copy L1 text to L1 instruction SRAM */
+       if (L1_CODE_LENGTH && text_l1_len)
+               early_dma_memcpy(_stext_l1, _text_l1_lma, text_l1_len);
 
-       /* if necessary, copy _sdata_l1 to _sbss_l1 to L1 data bank A SRAM */
-       l1_data_a_length = _sbss_l1 - _sdata_l1;
-       if (l1_data_a_length)
-               early_dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length);
+       /* if necessary, copy L1 data to L1 data bank A SRAM */
+       if (L1_DATA_A_LENGTH && data_l1_len)
+               early_dma_memcpy(_sdata_l1, _data_l1_lma, data_l1_len);
 
-       /* if necessary, copy _sdata_b_l1 to _sbss_b_l1 to L1 data bank B SRAM */
-       l1_data_b_length = _sbss_b_l1 - _sdata_b_l1;
-       if (l1_data_b_length)
-               early_dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
-                       l1_data_a_length, l1_data_b_length);
+       /* if necessary, copy L1 data B to L1 data bank B SRAM */
+       if (L1_DATA_B_LENGTH && data_b_l1_len)
+               early_dma_memcpy(_sdata_b_l1, _data_b_l1_lma, data_b_l1_len);
 
        early_dma_memcpy_done();
 
-       /* if necessary, copy _stext_l2 to _edata_l2 to L2 SRAM */
-       if (L2_LENGTH != 0) {
-               l2_length = _sbss_l2 - _stext_l2;
-               if (l2_length)
-                       memcpy(_stext_l2, _l2_lma_start, l2_length);
-       }
+       /* if necessary, copy L2 text/data to L2 SRAM */
+       if (L2_LENGTH && l2_len)
+               memcpy(_stext_l2, _l2_lma, l2_len);
 }
 
 /* add_memory_region to memmap */
@@ -608,11 +601,6 @@ static __init void memory_setup(void)
        page_mask_order = get_order(3 * page_mask_nelts * sizeof(long));
 #endif
 
-#if !defined(CONFIG_MTD_UCLINUX)
-       /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/
-       memory_end -= SIZE_4K;
-#endif
-
        init_mm.start_code = (unsigned long)_stext;
        init_mm.end_code = (unsigned long)_etext;
        init_mm.end_data = (unsigned long)_edata;
@@ -917,7 +905,7 @@ void __init setup_arch(char **cmdline_p)
 
        printk(KERN_INFO "Blackfin support (C) 2004-2009 Analog Devices, Inc.\n");
        if (bfin_compiled_revid() == 0xffff)
-               printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU);
+               printk(KERN_INFO "Compiled for ADSP-%s Rev any, running on 0.%d\n", CPU, bfin_revid());
        else if (bfin_compiled_revid() == -1)
                printk(KERN_INFO "Compiled for ADSP-%s Rev none\n", CPU);
        else
index 9d90c18fab23d1544e73659b96bb3cbd977139f6..e0fd63e9e38abdd469ece8f6203bec7b423f350c 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/binfmts.h>
 #include <linux/freezer.h>
 #include <linux/uaccess.h>
+#include <linux/tracehook.h>
 
 #include <asm/cacheflush.h>
 #include <asm/ucontext.h>
@@ -332,3 +333,20 @@ asmlinkage void do_signal(struct pt_regs *regs)
                sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
        }
 }
+
+/*
+ * notification of userspace execution resumption
+ */
+asmlinkage void do_notify_resume(struct pt_regs *regs)
+{
+       if (test_thread_flag(TIF_SIGPENDING) || test_thread_flag(TIF_RESTORE_SIGMASK))
+               do_signal(regs);
+
+       if (test_thread_flag(TIF_NOTIFY_RESUME)) {
+               clear_thread_flag(TIF_NOTIFY_RESUME);
+               tracehook_notify_resume(regs);
+               if (current->replacement_session_keyring)
+                       key_replace_session_keyring();
+       }
+}
+
index 359cfb1815ca77c00c4adcebbe1101a7e76da227..17c38c5b5b22f60edd2273c5715888cc8eb45083 100644 (file)
@@ -22,8 +22,6 @@
 #include <asm/time.h>
 #include <asm/gptimers.h>
 
-#if defined(CONFIG_CYCLES_CLOCKSOURCE)
-
 /* Accelerators for sched_clock()
  * convert from cycles(64bits) => nanoseconds (64bits)
  *  basic equation:
  *                     -johnstul@us.ibm.com "math is hard, lets go shopping!"
  */
 
-static unsigned long cyc2ns_scale;
 #define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
 
-static inline void set_cyc2ns_scale(unsigned long cpu_khz)
-{
-       cyc2ns_scale = (1000000 << CYC2NS_SCALE_FACTOR) / cpu_khz;
-}
-
-static inline unsigned long long cycles_2_ns(cycle_t cyc)
-{
-       return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
-}
+#if defined(CONFIG_CYCLES_CLOCKSOURCE)
 
-static cycle_t bfin_read_cycles(struct clocksource *cs)
+static notrace cycle_t bfin_read_cycles(struct clocksource *cs)
 {
        return __bfin_cycles_off + (get_cycles() << __bfin_cycles_mod);
 }
@@ -69,19 +58,18 @@ static struct clocksource bfin_cs_cycles = {
        .rating         = 400,
        .read           = bfin_read_cycles,
        .mask           = CLOCKSOURCE_MASK(64),
-       .shift          = 22,
+       .shift          = CYC2NS_SCALE_FACTOR,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-unsigned long long sched_clock(void)
+static inline unsigned long long bfin_cs_cycles_sched_clock(void)
 {
-       return cycles_2_ns(bfin_read_cycles(&bfin_cs_cycles));
+       return clocksource_cyc2ns(bfin_read_cycles(&bfin_cs_cycles),
+               bfin_cs_cycles.mult, bfin_cs_cycles.shift);
 }
 
 static int __init bfin_cs_cycles_init(void)
 {
-       set_cyc2ns_scale(get_cclk() / 1000);
-
        bfin_cs_cycles.mult = \
                clocksource_hz2mult(get_cclk(), bfin_cs_cycles.shift);
 
@@ -108,7 +96,7 @@ void __init setup_gptimer0(void)
        enable_gptimers(TIMER0bit);
 }
 
-static cycle_t bfin_read_gptimer0(void)
+static cycle_t bfin_read_gptimer0(struct clocksource *cs)
 {
        return bfin_read_TIMER0_COUNTER();
 }
@@ -118,10 +106,16 @@ static struct clocksource bfin_cs_gptimer0 = {
        .rating         = 350,
        .read           = bfin_read_gptimer0,
        .mask           = CLOCKSOURCE_MASK(32),
-       .shift          = 22,
+       .shift          = CYC2NS_SCALE_FACTOR,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
+static inline unsigned long long bfin_cs_gptimer0_sched_clock(void)
+{
+       return clocksource_cyc2ns(bfin_read_TIMER0_COUNTER(),
+               bfin_cs_gptimer0.mult, bfin_cs_gptimer0.shift);
+}
+
 static int __init bfin_cs_gptimer0_init(void)
 {
        setup_gptimer0();
@@ -138,6 +132,19 @@ static int __init bfin_cs_gptimer0_init(void)
 # define bfin_cs_gptimer0_init()
 #endif
 
+
+#if defined(CONFIG_GPTMR0_CLOCKSOURCE) || defined(CONFIG_CYCLES_CLOCKSOURCE)
+/* prefer to use cycles since it has higher rating */
+notrace unsigned long long sched_clock(void)
+{
+#if defined(CONFIG_CYCLES_CLOCKSOURCE)
+       return bfin_cs_cycles_sched_clock();
+#else
+       return bfin_cs_gptimer0_sched_clock();
+#endif
+}
+#endif
+
 #ifdef CONFIG_CORE_TIMER_IRQ_L1
 __attribute__((l1_text))
 #endif
index bd3b53da295ef6745bbaf365a239617e1bc9b4d9..13c1ee3e64082560a4a4e97aff6dd2abb95bb2b7 100644 (file)
@@ -184,11 +184,3 @@ void __init time_init(void)
 
        time_sched_init(timer_interrupt);
 }
-
-/*
- * Scheduler clock - returns current time in nanosec units.
- */
-unsigned long long sched_clock(void)
-{
-       return (unsigned long long)jiffies *(NSEC_PER_SEC / HZ);
-}
index 78cb3d38f899696c33eb8a1279c3c94c01e098c6..d3cbcd6bd985d6a5c517bba229e77474742d7393 100644 (file)
@@ -119,6 +119,15 @@ static void decode_address(char *buf, unsigned long address)
                return;
        }
 
+       /*
+        * Don't walk any of the vmas if we are oopsing, it has been known
+        * to cause problems - corrupt vmas (kernel crashes) cause double faults
+        */
+       if (oops_in_progress) {
+               strcat(buf, "/* kernel dynamic memory (maybe user-space) */");
+               return;
+       }
+
        /* looks like we're off in user-land, so let's walk all the
         * mappings of all our processes and see if we can't be a whee
         * bit more specific
@@ -515,6 +524,36 @@ asmlinkage notrace void trap_c(struct pt_regs *fp)
                        break;
                /* External Memory Addressing Error */
                case (SEQSTAT_HWERRCAUSE_EXTERN_ADDR):
+                       if (ANOMALY_05000310) {
+                               static unsigned long anomaly_rets;
+
+                               if ((fp->pc >= (L1_CODE_START + L1_CODE_LENGTH - 512)) &&
+                                   (fp->pc < (L1_CODE_START + L1_CODE_LENGTH))) {
+                                       /*
+                                        * A false hardware error will happen while fetching at
+                                        * the L1 instruction SRAM boundary.  Ignore it.
+                                        */
+                                       anomaly_rets = fp->rets;
+                                       goto traps_done;
+                               } else if (fp->rets == anomaly_rets) {
+                                       /*
+                                        * While boundary code returns to a function, at the ret
+                                        * point, a new false hardware error might occur too based
+                                        * on tests.  Ignore it too.
+                                        */
+                                       goto traps_done;
+                               } else if ((fp->rets >= (L1_CODE_START + L1_CODE_LENGTH - 512)) &&
+                                          (fp->rets < (L1_CODE_START + L1_CODE_LENGTH))) {
+                                       /*
+                                        * If boundary code calls a function, at the entry point,
+                                        * a new false hardware error maybe happen based on tests.
+                                        * Ignore it too.
+                                        */
+                                       goto traps_done;
+                               } else
+                                       anomaly_rets = 0;
+                       }
+
                        info.si_code = BUS_ADRERR;
                        sig = SIGBUS;
                        strerror = KERN_NOTICE HWC_x3(KERN_NOTICE);
@@ -976,12 +1015,12 @@ void dump_bfin_process(struct pt_regs *fp)
            !((unsigned long)current & 0x3) && current->pid) {
                verbose_printk(KERN_NOTICE "CURRENT PROCESS:\n");
                if (current->comm >= (char *)FIXED_CODE_START)
-                       verbose_printk(KERN_NOTICE "COMM=%s PID=%d\n",
+                       verbose_printk(KERN_NOTICE "COMM=%s PID=%d",
                                current->comm, current->pid);
                else
-                       verbose_printk(KERN_NOTICE "COMM= invalid\n");
+                       verbose_printk(KERN_NOTICE "COMM= invalid");
 
-               printk(KERN_NOTICE "CPU = %d\n", current_thread_info()->cpu);
+               printk(KERN_CONT " CPU=%d\n", current_thread_info()->cpu);
                if (!((unsigned long)current->mm & 0x3) && (unsigned long)current->mm >= FIXED_CODE_START)
                        verbose_printk(KERN_NOTICE
                                "TEXT = 0x%p-0x%p        DATA = 0x%p-0x%p\n"
@@ -1140,7 +1179,7 @@ void show_regs(struct pt_regs *fp)
        if (fp->ipend & ~0x3F) {
                for (i = 0; i < (NR_IRQS - 1); i++) {
                        if (!in_atomic)
-                               spin_lock_irqsave(&irq_desc[i].lock, flags);
+                               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
 
                        action = irq_desc[i].action;
                        if (!action)
@@ -1155,7 +1194,7 @@ void show_regs(struct pt_regs *fp)
                        verbose_printk("\n");
 unlock:
                        if (!in_atomic)
-                               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+                               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
                }
        }
 
index 10e12539000ebad641207ee49daf7e9ad5b8cad3..66799e763dc93562513b8350c737e37fad282df8 100644 (file)
@@ -4,8 +4,6 @@
  * Licensed under the GPL-2 or later
  */
 
-#define VMLINUX_SYMBOL(_sym_) _##_sym_
-
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/mem_map.h>
 #include <asm/page.h>
@@ -123,8 +121,6 @@ SECTIONS
                EXIT_DATA
        }
 
-       __l1_lma_start = .;
-
        .text_l1 L1_CODE_START : AT(LOADADDR(.exit.data) + SIZEOF(.exit.data))
        {
                . = ALIGN(4);
@@ -136,9 +132,11 @@ SECTIONS
                . = ALIGN(4);
                __etext_l1 = .;
        }
-       ASSERT (SIZEOF(.text_l1) <= L1_CODE_LENGTH, "L1 text overflow!")
+       __text_l1_lma = LOADADDR(.text_l1);
+       __text_l1_len = SIZEOF(.text_l1);
+       ASSERT (__text_l1_len <= L1_CODE_LENGTH, "L1 text overflow!")
 
-       .data_l1 L1_DATA_A_START : AT(LOADADDR(.text_l1) + SIZEOF(.text_l1))
+       .data_l1 L1_DATA_A_START : AT(__text_l1_lma + __text_l1_len)
        {
                . = ALIGN(4);
                __sdata_l1 = .;
@@ -154,9 +152,11 @@ SECTIONS
                . = ALIGN(4);
                __ebss_l1 = .;
        }
-       ASSERT (SIZEOF(.data_l1) <= L1_DATA_A_LENGTH, "L1 data A overflow!")
+       __data_l1_lma = LOADADDR(.data_l1);
+       __data_l1_len = SIZEOF(.data_l1);
+       ASSERT (__data_l1_len <= L1_DATA_A_LENGTH, "L1 data A overflow!")
 
-       .data_b_l1 L1_DATA_B_START : AT(LOADADDR(.data_l1) + SIZEOF(.data_l1))
+       .data_b_l1 L1_DATA_B_START : AT(__data_l1_lma + __data_l1_len)
        {
                . = ALIGN(4);
                __sdata_b_l1 = .;
@@ -169,11 +169,11 @@ SECTIONS
                . = ALIGN(4);
                __ebss_b_l1 = .;
        }
-       ASSERT (SIZEOF(.data_b_l1) <= L1_DATA_B_LENGTH, "L1 data B overflow!")
-
-       __l2_lma_start = LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1);
+       __data_b_l1_lma = LOADADDR(.data_b_l1);
+       __data_b_l1_len = SIZEOF(.data_b_l1);
+       ASSERT (__data_b_l1_len <= L1_DATA_B_LENGTH, "L1 data B overflow!")
 
-       .text_data_l2 L2_START : AT(LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1))
+       .text_data_l2 L2_START : AT(__data_b_l1_lma + __data_b_l1_len)
        {
                . = ALIGN(4);
                __stext_l2 = .;
@@ -195,12 +195,14 @@ SECTIONS
                . = ALIGN(4);
                __ebss_l2 = .;
        }
-       ASSERT (SIZEOF(.text_data_l2) <= L2_LENGTH, "L2 overflow!")
+       __l2_lma = LOADADDR(.text_data_l2);
+       __l2_len = SIZEOF(.text_data_l2);
+       ASSERT (__l2_len <= L2_LENGTH, "L2 overflow!")
 
        /* Force trailing alignment of our init section so that when we
         * free our init memory, we don't leave behind a partial page.
         */
-       . = LOADADDR(.text_data_l2) + SIZEOF(.text_data_l2);
+       . = __l2_lma + __l2_len;
        . = ALIGN(PAGE_SIZE);
        ___init_end = .;
 
index 635288fc5f5432c2d3d89d1226968c8bd7077c72..42c47dc9e12f965dfdcdb1becdba81b96f6d4daa 100644 (file)
@@ -5,7 +5,7 @@
 lib-y := \
        ashldi3.o ashrdi3.o lshrdi3.o \
        muldi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
-       checksum.o memcpy.o memset.o memcmp.o memchr.o memmove.o \
+       memcpy.o memset.o memcmp.o memchr.o memmove.o \
        strcmp.o strcpy.o strncmp.o strncpy.o \
        umulsi3_highpart.o smulsi3_highpart.o \
        ins.o outs.o
diff --git a/arch/blackfin/lib/checksum.c b/arch/blackfin/lib/checksum.c
deleted file mode 100644 (file)
index c62969d..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2004-2009 Analog Devices Inc.
- *
- * Licensed under the GPL-2 or later.
- *
- * An implementation of the TCP/IP protocol suite for the LINUX operating
- * system. INET is implemented using the BSD Socket interface as the
- * means of communication with the user level.
- *
- */
-
-#include <linux/module.h>
-#include <net/checksum.h>
-#include <asm/checksum.h>
-
-#ifdef CONFIG_IP_CHECKSUM_L1
-static unsigned short do_csum(const unsigned char *buff, int len)__attribute__((l1_text));
-#endif
-
-static unsigned short do_csum(const unsigned char *buff, int len)
-{
-       register unsigned long sum = 0;
-       int swappem = 0;
-
-       if (1 & (unsigned long)buff) {
-               sum = *buff << 8;
-               buff++;
-               len--;
-               ++swappem;
-       }
-
-       while (len > 1) {
-               sum += *(unsigned short *)buff;
-               buff += 2;
-               len -= 2;
-       }
-
-       if (len > 0)
-               sum += *buff;
-
-       /*  Fold 32-bit sum to 16 bits */
-       while (sum >> 16)
-               sum = (sum & 0xffff) + (sum >> 16);
-
-       if (swappem)
-               sum = ((sum & 0xff00) >> 8) + ((sum & 0x00ff) << 8);
-
-       return sum;
-
-}
-
-/*
- *     This is a version of ip_compute_csum() optimized for IP headers,
- *     which always checksum on 4 octet boundaries.
- */
-__sum16 ip_fast_csum(unsigned char *iph, unsigned int ihl)
-{
-       return (__force __sum16)~do_csum(iph, ihl * 4);
-}
-EXPORT_SYMBOL(ip_fast_csum);
-
-/*
- * computes the checksum of a memory block at buff, length len,
- * and adds in "sum" (32-bit)
- *
- * returns a 32-bit number suitable for feeding into itself
- * or csum_tcpudp_magic
- *
- * this function must be called with even lengths, except
- * for the last fragment, which may be odd
- *
- * it's best to have buff aligned on a 32-bit boundary
- */
-__wsum csum_partial(const void *buff, int len, __wsum sum)
-{
-       /*
-        * Just in case we get nasty checksum data...
-        * Like 0xffff6ec3 in the case of our IPv6 multicast header.
-        * We fold to begin with, as well as at the end.
-        */
-       sum = (sum & 0xffff) + (sum >> 16);
-
-       sum += do_csum(buff, len);
-
-       sum = (sum & 0xffff) + (sum >> 16);
-
-       return sum;
-}
-EXPORT_SYMBOL(csum_partial);
-
-/*
- * this routine is used for miscellaneous IP-like checksums, mainly
- * in icmp.c
- */
-__sum16 ip_compute_csum(const void *buff, int len)
-{
-       return (__force __sum16)~do_csum(buff, len);
-}
-EXPORT_SYMBOL(ip_compute_csum);
-
-/*
- * copy from fs while checksumming, otherwise like csum_partial
- */
-
-__wsum
-csum_partial_copy_from_user(const void __user *src, void *dst,
-                           int len, __wsum sum, int *csum_err)
-{
-       if (csum_err)
-               *csum_err = 0;
-       memcpy(dst, (__force void *)src, len);
-       return csum_partial(dst, len, sum);
-}
-EXPORT_SYMBOL(csum_partial_copy_from_user);
-
-/*
- * copy from ds while checksumming, otherwise like csum_partial
- */
-
-__wsum csum_partial_copy(const void *src, void *dst, int len, __wsum sum)
-{
-       memcpy(dst, src, len);
-       return csum_partial(dst, len, sum);
-}
-EXPORT_SYMBOL(csum_partial_copy);
index 4c76fefb7a3b68c02006358622bffe0a401d6761..4ab2d166c83257f0068a0a5ecbf6a67fdeefcb48 100644 (file)
@@ -1,3 +1,7 @@
+config BF51x
+       def_bool y
+       depends on (BF512 || BF514 || BF516 || BF518)
+
 if (BF51x)
 
 source "arch/blackfin/mach-bf518/boards/Kconfig"
index 6cfb246aebecc35a6307f913ff3b19f934587e3f..9053462be4b169068b8fdf3b3fdfc75e10e4ee74 100644 (file)
 #define OFFSET_SCR              0x1C   /* SCR Scratch Register                 */
 #define OFFSET_GCTL             0x24   /* Global Control Register              */
 
-/* PLL_DIV Masks                                                                                                       */
-#define CCLK_DIV1 CSEL_DIV1    /*          CCLK = VCO / 1                                  */
-#define CCLK_DIV2 CSEL_DIV2    /*          CCLK = VCO / 2                                  */
-#define CCLK_DIV4 CSEL_DIV4    /*          CCLK = VCO / 4                                  */
-#define CCLK_DIV8 CSEL_DIV8    /*          CCLK = VCO / 8                                  */
-
 #endif
index e1d99911025d73e555f85cda632ad43ab20734cd..108fa4bde2771f0df7e81e59f576e300c9598f4b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2008-2009 Analog Devices Inc.
  *
- * Licensed under the GPL-2 or later
+ * Licensed under the ADI BSD license or the GPL-2 (or later)
  */
 
 #ifndef _CDEF_BF514_H
 /* include all Core registers and bit definitions */
 #include "defBF514.h"
 
-/* include core specific register pointer definitions */
-#include <asm/cdef_LPBlackfin.h>
-
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF514 */
-
-/* include cdefBF51x_base.h for the set of #defines that are common to all ADSP-BF51x processors */
-#include "cdefBF51x_base.h"
-
-/* The following are the #defines needed by ADSP-BF514 that are not in the common header */
+/* BF514 is BF512 + RSI */
+#include "cdefBF512.h"
 
 /* Removable Storage Interface Registers */
 
index 6b364eda4947f5ee7637e4e23b01b5701ac010aa..2751592ef1c1741aceae8522a8d454041615921b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2008-2009 Analog Devices Inc.
  *
- * Licensed under the GPL-2 or later
+ * Licensed under the ADI BSD license or the GPL-2 (or later)
  */
 
 #ifndef _CDEF_BF516_H
 /* include all Core registers and bit definitions */
 #include "defBF516.h"
 
-/* include core specific register pointer definitions */
-#include <asm/cdef_LPBlackfin.h>
-
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF516 */
-
-/* include cdefBF51x_base.h for the set of #defines that are common to all ADSP-BF51x processors */
-#include "cdefBF51x_base.h"
-
-/* The following are the #defines needed by ADSP-BF516 that are not in the common header */
+/* BF516 is BF514 + EMAC */
+#include "cdefBF514.h"
 
 /* 10/100 Ethernet Controller  (0xFFC03000 - 0xFFC031FF) */
 
 #define bfin_read_EMAC_TXC_ABORT()             bfin_read32(EMAC_TXC_ABORT)
 #define bfin_write_EMAC_TXC_ABORT(val)         bfin_write32(EMAC_TXC_ABORT, val)
 
-/* Removable Storage Interface Registers */
-
-#define bfin_read_RSI_PWR_CTL()        bfin_read16(RSI_PWR_CONTROL)
-#define bfin_write_RSI_PWR_CTL(val)    bfin_write16(RSI_PWR_CONTROL, val)
-#define bfin_read_RSI_CLK_CTL()               bfin_read16(RSI_CLK_CONTROL)
-#define bfin_write_RSI_CLK_CTL(val)    bfin_write16(RSI_CLK_CONTROL, val)
-#define bfin_read_RSI_ARGUMENT()       bfin_read32(RSI_ARGUMENT)
-#define bfin_write_RSI_ARGUMENT(val)   bfin_write32(RSI_ARGUMENT, val)
-#define bfin_read_RSI_COMMAND()        bfin_read16(RSI_COMMAND)
-#define bfin_write_RSI_COMMAND(val)    bfin_write16(RSI_COMMAND, val)
-#define bfin_read_RSI_RESP_CMD()       bfin_read16(RSI_RESP_CMD)
-#define bfin_write_RSI_RESP_CMD(val)   bfin_write16(RSI_RESP_CMD, val)
-#define bfin_read_RSI_RESPONSE0()      bfin_read32(RSI_RESPONSE0)
-#define bfin_write_RSI_RESPONSE0(val)  bfin_write32(RSI_RESPONSE0, val)
-#define bfin_read_RSI_RESPONSE1()      bfin_read32(RSI_RESPONSE1)
-#define bfin_write_RSI_RESPONSE1(val)  bfin_write32(RSI_RESPONSE1, val)
-#define bfin_read_RSI_RESPONSE2()      bfin_read32(RSI_RESPONSE2)
-#define bfin_write_RSI_RESPONSE2(val)  bfin_write32(RSI_RESPONSE2, val)
-#define bfin_read_RSI_RESPONSE3()      bfin_read32(RSI_RESPONSE3)
-#define bfin_write_RSI_RESPONSE3(val)  bfin_write32(RSI_RESPONSE3, val)
-#define bfin_read_RSI_DATA_TIMER()     bfin_read32(RSI_DATA_TIMER)
-#define bfin_write_RSI_DATA_TIMER(val) bfin_write32(RSI_DATA_TIMER, val)
-#define bfin_read_RSI_DATA_LGTH()      bfin_read16(RSI_DATA_LGTH)
-#define bfin_write_RSI_DATA_LGTH(val)  bfin_write16(RSI_DATA_LGTH, val)
-#define bfin_read_RSI_DATA_CTL()       bfin_read16(RSI_DATA_CONTROL)
-#define bfin_write_RSI_DATA_CTL(val)   bfin_write16(RSI_DATA_CONTROL, val)
-#define bfin_read_RSI_DATA_CNT()       bfin_read16(RSI_DATA_CNT)
-#define bfin_write_RSI_DATA_CNT(val)   bfin_write16(RSI_DATA_CNT, val)
-#define bfin_read_RSI_STATUS()         bfin_read32(RSI_STATUS)
-#define bfin_write_RSI_STATUS(val)     bfin_write32(RSI_STATUS, val)
-#define bfin_read_RSI_STATUS_CLR()     bfin_read16(RSI_STATUSCL)
-#define bfin_write_RSI_STATUS_CLR(val) bfin_write16(RSI_STATUSCL, val)
-#define bfin_read_RSI_MASK0()          bfin_read32(RSI_MASK0)
-#define bfin_write_RSI_MASK0(val)      bfin_write32(RSI_MASK0, val)
-#define bfin_read_RSI_MASK1()          bfin_read32(RSI_MASK1)
-#define bfin_write_RSI_MASK1(val)      bfin_write32(RSI_MASK1, val)
-#define bfin_read_RSI_FIFO_CNT()       bfin_read16(RSI_FIFO_CNT)
-#define bfin_write_RSI_FIFO_CNT(val)   bfin_write16(RSI_FIFO_CNT, val)
-#define bfin_read_RSI_CEATA_CTL()      bfin_read16(RSI_CEATA_CONTROL)
-#define bfin_write_RSI_CEATA_CTL(val)  bfin_write16(RSI_CEATA_CONTROL, val)
-#define bfin_read_RSI_FIFO()           bfin_read32(RSI_FIFO)
-#define bfin_write_RSI_FIFO(val)       bfin_write32(RSI_FIFO, val)
-#define bfin_read_RSI_E_STATUS()       bfin_read16(RSI_ESTAT)
-#define bfin_write_RSI_E_STATUS(val)   bfin_write16(RSI_ESTAT, val)
-#define bfin_read_RSI_E_MASK()         bfin_read16(RSI_EMASK)
-#define bfin_write_RSI_E_MASK(val)     bfin_write16(RSI_EMASK, val)
-#define bfin_read_RSI_CFG()            bfin_read16(RSI_CONFIG)
-#define bfin_write_RSI_CFG(val)        bfin_write16(RSI_CONFIG, val)
-#define bfin_read_RSI_RD_WAIT_EN()     bfin_read16(RSI_RD_WAIT_EN)
-#define bfin_write_RSI_RD_WAIT_EN(val) bfin_write16(RSI_RD_WAIT_EN, val)
-#define bfin_read_RSI_PID0()           bfin_read16(RSI_PID0)
-#define bfin_write_RSI_PID0(val)       bfin_write16(RSI_PID0, val)
-#define bfin_read_RSI_PID1()           bfin_read16(RSI_PID1)
-#define bfin_write_RSI_PID1(val)       bfin_write16(RSI_PID1, val)
-#define bfin_read_RSI_PID2()           bfin_read16(RSI_PID2)
-#define bfin_write_RSI_PID2(val)       bfin_write16(RSI_PID2, val)
-#define bfin_read_RSI_PID3()           bfin_read16(RSI_PID3)
-#define bfin_write_RSI_PID3(val)       bfin_write16(RSI_PID3, val)
-#define bfin_read_RSI_PID4()           bfin_read16(RSI_PID4)
-#define bfin_write_RSI_PID4(val)       bfin_write16(RSI_PID4, val)
-#define bfin_read_RSI_PID5()           bfin_read16(RSI_PID5)
-#define bfin_write_RSI_PID5(val)       bfin_write16(RSI_PID5, val)
-#define bfin_read_RSI_PID6()           bfin_read16(RSI_PID6)
-#define bfin_write_RSI_PID6(val)       bfin_write16(RSI_PID6, val)
-#define bfin_read_RSI_PID7()           bfin_read16(RSI_PID7)
-#define bfin_write_RSI_PID7(val)       bfin_write16(RSI_PID7, val)
-
 #endif /* _CDEF_BF516_H */
index 929b90650bd430c9ce0949cf09a6aad86f533d0d..7fb7f0eab990f779a3bef87cabf004709f568836 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2008-2009 Analog Devices Inc.
  *
- * Licensed under the GPL-2 or later
+ * Licensed under the ADI BSD license or the GPL-2 (or later)
  */
 
 #ifndef _CDEF_BF518_H
 /* include all Core registers and bit definitions */
 #include "defBF518.h"
 
-/* include core specific register pointer definitions */
-#include <asm/cdef_LPBlackfin.h>
+/* BF518 is BF516 + IEEE-1588 */
+#include "cdefBF516.h"
 
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF518 */
-
-/* include cdefBF51x_base.h for the set of #defines that are common to all ADSP-BF51x processors */
-#include "cdefBF51x_base.h"
-
-/* The following are the #defines needed by ADSP-BF518 that are not in the common header */
-
-
-/* 10/100 Ethernet Controller  (0xFFC03000 - 0xFFC031FF) */
-
-#define bfin_read_EMAC_OPMODE()                        bfin_read32(EMAC_OPMODE)
-#define bfin_write_EMAC_OPMODE(val)            bfin_write32(EMAC_OPMODE, val)
-#define bfin_read_EMAC_ADDRLO()                        bfin_read32(EMAC_ADDRLO)
-#define bfin_write_EMAC_ADDRLO(val)            bfin_write32(EMAC_ADDRLO, val)
-#define bfin_read_EMAC_ADDRHI()                        bfin_read32(EMAC_ADDRHI)
-#define bfin_write_EMAC_ADDRHI(val)            bfin_write32(EMAC_ADDRHI, val)
-#define bfin_read_EMAC_HASHLO()                        bfin_read32(EMAC_HASHLO)
-#define bfin_write_EMAC_HASHLO(val)            bfin_write32(EMAC_HASHLO, val)
-#define bfin_read_EMAC_HASHHI()                        bfin_read32(EMAC_HASHHI)
-#define bfin_write_EMAC_HASHHI(val)            bfin_write32(EMAC_HASHHI, val)
-#define bfin_read_EMAC_STAADD()                        bfin_read32(EMAC_STAADD)
-#define bfin_write_EMAC_STAADD(val)            bfin_write32(EMAC_STAADD, val)
-#define bfin_read_EMAC_STADAT()                        bfin_read32(EMAC_STADAT)
-#define bfin_write_EMAC_STADAT(val)            bfin_write32(EMAC_STADAT, val)
-#define bfin_read_EMAC_FLC()                   bfin_read32(EMAC_FLC)
-#define bfin_write_EMAC_FLC(val)               bfin_write32(EMAC_FLC, val)
-#define bfin_read_EMAC_VLAN1()                 bfin_read32(EMAC_VLAN1)
-#define bfin_write_EMAC_VLAN1(val)             bfin_write32(EMAC_VLAN1, val)
-#define bfin_read_EMAC_VLAN2()                 bfin_read32(EMAC_VLAN2)
-#define bfin_write_EMAC_VLAN2(val)             bfin_write32(EMAC_VLAN2, val)
-#define bfin_read_EMAC_WKUP_CTL()              bfin_read32(EMAC_WKUP_CTL)
-#define bfin_write_EMAC_WKUP_CTL(val)          bfin_write32(EMAC_WKUP_CTL, val)
-#define bfin_read_EMAC_WKUP_FFMSK0()           bfin_read32(EMAC_WKUP_FFMSK0)
-#define bfin_write_EMAC_WKUP_FFMSK0(val)       bfin_write32(EMAC_WKUP_FFMSK0, val)
-#define bfin_read_EMAC_WKUP_FFMSK1()           bfin_read32(EMAC_WKUP_FFMSK1)
-#define bfin_write_EMAC_WKUP_FFMSK1(val)       bfin_write32(EMAC_WKUP_FFMSK1, val)
-#define bfin_read_EMAC_WKUP_FFMSK2()           bfin_read32(EMAC_WKUP_FFMSK2)
-#define bfin_write_EMAC_WKUP_FFMSK2(val)       bfin_write32(EMAC_WKUP_FFMSK2, val)
-#define bfin_read_EMAC_WKUP_FFMSK3()           bfin_read32(EMAC_WKUP_FFMSK3)
-#define bfin_write_EMAC_WKUP_FFMSK3(val)       bfin_write32(EMAC_WKUP_FFMSK3, val)
-#define bfin_read_EMAC_WKUP_FFCMD()            bfin_read32(EMAC_WKUP_FFCMD)
-#define bfin_write_EMAC_WKUP_FFCMD(val)                bfin_write32(EMAC_WKUP_FFCMD, val)
-#define bfin_read_EMAC_WKUP_FFOFF()            bfin_read32(EMAC_WKUP_FFOFF)
-#define bfin_write_EMAC_WKUP_FFOFF(val)                bfin_write32(EMAC_WKUP_FFOFF, val)
-#define bfin_read_EMAC_WKUP_FFCRC0()           bfin_read32(EMAC_WKUP_FFCRC0)
-#define bfin_write_EMAC_WKUP_FFCRC0(val)       bfin_write32(EMAC_WKUP_FFCRC0, val)
-#define bfin_read_EMAC_WKUP_FFCRC1()           bfin_read32(EMAC_WKUP_FFCRC1)
-#define bfin_write_EMAC_WKUP_FFCRC1(val)       bfin_write32(EMAC_WKUP_FFCRC1, val)
-
-#define bfin_read_EMAC_SYSCTL()                        bfin_read32(EMAC_SYSCTL)
-#define bfin_write_EMAC_SYSCTL(val)            bfin_write32(EMAC_SYSCTL, val)
-#define bfin_read_EMAC_SYSTAT()                        bfin_read32(EMAC_SYSTAT)
-#define bfin_write_EMAC_SYSTAT(val)            bfin_write32(EMAC_SYSTAT, val)
-#define bfin_read_EMAC_RX_STAT()               bfin_read32(EMAC_RX_STAT)
-#define bfin_write_EMAC_RX_STAT(val)           bfin_write32(EMAC_RX_STAT, val)
-#define bfin_read_EMAC_RX_STKY()               bfin_read32(EMAC_RX_STKY)
-#define bfin_write_EMAC_RX_STKY(val)           bfin_write32(EMAC_RX_STKY, val)
-#define bfin_read_EMAC_RX_IRQE()               bfin_read32(EMAC_RX_IRQE)
-#define bfin_write_EMAC_RX_IRQE(val)           bfin_write32(EMAC_RX_IRQE, val)
-#define bfin_read_EMAC_TX_STAT()               bfin_read32(EMAC_TX_STAT)
-#define bfin_write_EMAC_TX_STAT(val)           bfin_write32(EMAC_TX_STAT, val)
-#define bfin_read_EMAC_TX_STKY()               bfin_read32(EMAC_TX_STKY)
-#define bfin_write_EMAC_TX_STKY(val)           bfin_write32(EMAC_TX_STKY, val)
-#define bfin_read_EMAC_TX_IRQE()               bfin_read32(EMAC_TX_IRQE)
-#define bfin_write_EMAC_TX_IRQE(val)           bfin_write32(EMAC_TX_IRQE, val)
-
-#define bfin_read_EMAC_MMC_CTL()               bfin_read32(EMAC_MMC_CTL)
-#define bfin_write_EMAC_MMC_CTL(val)           bfin_write32(EMAC_MMC_CTL, val)
-#define bfin_read_EMAC_MMC_RIRQS()             bfin_read32(EMAC_MMC_RIRQS)
-#define bfin_write_EMAC_MMC_RIRQS(val)         bfin_write32(EMAC_MMC_RIRQS, val)
-#define bfin_read_EMAC_MMC_RIRQE()             bfin_read32(EMAC_MMC_RIRQE)
-#define bfin_write_EMAC_MMC_RIRQE(val)         bfin_write32(EMAC_MMC_RIRQE, val)
-#define bfin_read_EMAC_MMC_TIRQS()             bfin_read32(EMAC_MMC_TIRQS)
-#define bfin_write_EMAC_MMC_TIRQS(val)         bfin_write32(EMAC_MMC_TIRQS, val)
-#define bfin_read_EMAC_MMC_TIRQE()             bfin_read32(EMAC_MMC_TIRQE)
-#define bfin_write_EMAC_MMC_TIRQE(val)         bfin_write32(EMAC_MMC_TIRQE, val)
-
-#define bfin_read_EMAC_RXC_OK()                        bfin_read32(EMAC_RXC_OK)
-#define bfin_write_EMAC_RXC_OK(val)            bfin_write32(EMAC_RXC_OK, val)
-#define bfin_read_EMAC_RXC_FCS()               bfin_read32(EMAC_RXC_FCS)
-#define bfin_write_EMAC_RXC_FCS(val)           bfin_write32(EMAC_RXC_FCS, val)
-#define bfin_read_EMAC_RXC_ALIGN()             bfin_read32(EMAC_RXC_ALIGN)
-#define bfin_write_EMAC_RXC_ALIGN(val)         bfin_write32(EMAC_RXC_ALIGN, val)
-#define bfin_read_EMAC_RXC_OCTET()             bfin_read32(EMAC_RXC_OCTET)
-#define bfin_write_EMAC_RXC_OCTET(val)         bfin_write32(EMAC_RXC_OCTET, val)
-#define bfin_read_EMAC_RXC_DMAOVF()            bfin_read32(EMAC_RXC_DMAOVF)
-#define bfin_write_EMAC_RXC_DMAOVF(val)                bfin_write32(EMAC_RXC_DMAOVF, val)
-#define bfin_read_EMAC_RXC_UNICST()            bfin_read32(EMAC_RXC_UNICST)
-#define bfin_write_EMAC_RXC_UNICST(val)                bfin_write32(EMAC_RXC_UNICST, val)
-#define bfin_read_EMAC_RXC_MULTI()             bfin_read32(EMAC_RXC_MULTI)
-#define bfin_write_EMAC_RXC_MULTI(val)         bfin_write32(EMAC_RXC_MULTI, val)
-#define bfin_read_EMAC_RXC_BROAD()             bfin_read32(EMAC_RXC_BROAD)
-#define bfin_write_EMAC_RXC_BROAD(val)         bfin_write32(EMAC_RXC_BROAD, val)
-#define bfin_read_EMAC_RXC_LNERRI()            bfin_read32(EMAC_RXC_LNERRI)
-#define bfin_write_EMAC_RXC_LNERRI(val)                bfin_write32(EMAC_RXC_LNERRI, val)
-#define bfin_read_EMAC_RXC_LNERRO()            bfin_read32(EMAC_RXC_LNERRO)
-#define bfin_write_EMAC_RXC_LNERRO(val)                bfin_write32(EMAC_RXC_LNERRO, val)
-#define bfin_read_EMAC_RXC_LONG()              bfin_read32(EMAC_RXC_LONG)
-#define bfin_write_EMAC_RXC_LONG(val)          bfin_write32(EMAC_RXC_LONG, val)
-#define bfin_read_EMAC_RXC_MACCTL()            bfin_read32(EMAC_RXC_MACCTL)
-#define bfin_write_EMAC_RXC_MACCTL(val)                bfin_write32(EMAC_RXC_MACCTL, val)
-#define bfin_read_EMAC_RXC_OPCODE()            bfin_read32(EMAC_RXC_OPCODE)
-#define bfin_write_EMAC_RXC_OPCODE(val)                bfin_write32(EMAC_RXC_OPCODE, val)
-#define bfin_read_EMAC_RXC_PAUSE()             bfin_read32(EMAC_RXC_PAUSE)
-#define bfin_write_EMAC_RXC_PAUSE(val)         bfin_write32(EMAC_RXC_PAUSE, val)
-#define bfin_read_EMAC_RXC_ALLFRM()            bfin_read32(EMAC_RXC_ALLFRM)
-#define bfin_write_EMAC_RXC_ALLFRM(val)                bfin_write32(EMAC_RXC_ALLFRM, val)
-#define bfin_read_EMAC_RXC_ALLOCT()            bfin_read32(EMAC_RXC_ALLOCT)
-#define bfin_write_EMAC_RXC_ALLOCT(val)                bfin_write32(EMAC_RXC_ALLOCT, val)
-#define bfin_read_EMAC_RXC_TYPED()             bfin_read32(EMAC_RXC_TYPED)
-#define bfin_write_EMAC_RXC_TYPED(val)         bfin_write32(EMAC_RXC_TYPED, val)
-#define bfin_read_EMAC_RXC_SHORT()             bfin_read32(EMAC_RXC_SHORT)
-#define bfin_write_EMAC_RXC_SHORT(val)         bfin_write32(EMAC_RXC_SHORT, val)
-#define bfin_read_EMAC_RXC_EQ64()              bfin_read32(EMAC_RXC_EQ64)
-#define bfin_write_EMAC_RXC_EQ64(val)          bfin_write32(EMAC_RXC_EQ64, val)
-#define bfin_read_EMAC_RXC_LT128()             bfin_read32(EMAC_RXC_LT128)
-#define bfin_write_EMAC_RXC_LT128(val)         bfin_write32(EMAC_RXC_LT128, val)
-#define bfin_read_EMAC_RXC_LT256()             bfin_read32(EMAC_RXC_LT256)
-#define bfin_write_EMAC_RXC_LT256(val)         bfin_write32(EMAC_RXC_LT256, val)
-#define bfin_read_EMAC_RXC_LT512()             bfin_read32(EMAC_RXC_LT512)
-#define bfin_write_EMAC_RXC_LT512(val)         bfin_write32(EMAC_RXC_LT512, val)
-#define bfin_read_EMAC_RXC_LT1024()            bfin_read32(EMAC_RXC_LT1024)
-#define bfin_write_EMAC_RXC_LT1024(val)                bfin_write32(EMAC_RXC_LT1024, val)
-#define bfin_read_EMAC_RXC_GE1024()            bfin_read32(EMAC_RXC_GE1024)
-#define bfin_write_EMAC_RXC_GE1024(val)                bfin_write32(EMAC_RXC_GE1024, val)
-
-#define bfin_read_EMAC_TXC_OK()                        bfin_read32(EMAC_TXC_OK)
-#define bfin_write_EMAC_TXC_OK(val)            bfin_write32(EMAC_TXC_OK, val)
-#define bfin_read_EMAC_TXC_1COL()              bfin_read32(EMAC_TXC_1COL)
-#define bfin_write_EMAC_TXC_1COL(val)          bfin_write32(EMAC_TXC_1COL, val)
-#define bfin_read_EMAC_TXC_GT1COL()            bfin_read32(EMAC_TXC_GT1COL)
-#define bfin_write_EMAC_TXC_GT1COL(val)                bfin_write32(EMAC_TXC_GT1COL, val)
-#define bfin_read_EMAC_TXC_OCTET()             bfin_read32(EMAC_TXC_OCTET)
-#define bfin_write_EMAC_TXC_OCTET(val)         bfin_write32(EMAC_TXC_OCTET, val)
-#define bfin_read_EMAC_TXC_DEFER()             bfin_read32(EMAC_TXC_DEFER)
-#define bfin_write_EMAC_TXC_DEFER(val)         bfin_write32(EMAC_TXC_DEFER, val)
-#define bfin_read_EMAC_TXC_LATECL()            bfin_read32(EMAC_TXC_LATECL)
-#define bfin_write_EMAC_TXC_LATECL(val)                bfin_write32(EMAC_TXC_LATECL, val)
-#define bfin_read_EMAC_TXC_XS_COL()            bfin_read32(EMAC_TXC_XS_COL)
-#define bfin_write_EMAC_TXC_XS_COL(val)                bfin_write32(EMAC_TXC_XS_COL, val)
-#define bfin_read_EMAC_TXC_DMAUND()            bfin_read32(EMAC_TXC_DMAUND)
-#define bfin_write_EMAC_TXC_DMAUND(val)                bfin_write32(EMAC_TXC_DMAUND, val)
-#define bfin_read_EMAC_TXC_CRSERR()            bfin_read32(EMAC_TXC_CRSERR)
-#define bfin_write_EMAC_TXC_CRSERR(val)                bfin_write32(EMAC_TXC_CRSERR, val)
-#define bfin_read_EMAC_TXC_UNICST()            bfin_read32(EMAC_TXC_UNICST)
-#define bfin_write_EMAC_TXC_UNICST(val)                bfin_write32(EMAC_TXC_UNICST, val)
-#define bfin_read_EMAC_TXC_MULTI()             bfin_read32(EMAC_TXC_MULTI)
-#define bfin_write_EMAC_TXC_MULTI(val)         bfin_write32(EMAC_TXC_MULTI, val)
-#define bfin_read_EMAC_TXC_BROAD()             bfin_read32(EMAC_TXC_BROAD)
-#define bfin_write_EMAC_TXC_BROAD(val)         bfin_write32(EMAC_TXC_BROAD, val)
-#define bfin_read_EMAC_TXC_XS_DFR()            bfin_read32(EMAC_TXC_XS_DFR)
-#define bfin_write_EMAC_TXC_XS_DFR(val)                bfin_write32(EMAC_TXC_XS_DFR, val)
-#define bfin_read_EMAC_TXC_MACCTL()            bfin_read32(EMAC_TXC_MACCTL)
-#define bfin_write_EMAC_TXC_MACCTL(val)                bfin_write32(EMAC_TXC_MACCTL, val)
-#define bfin_read_EMAC_TXC_ALLFRM()            bfin_read32(EMAC_TXC_ALLFRM)
-#define bfin_write_EMAC_TXC_ALLFRM(val)                bfin_write32(EMAC_TXC_ALLFRM, val)
-#define bfin_read_EMAC_TXC_ALLOCT()            bfin_read32(EMAC_TXC_ALLOCT)
-#define bfin_write_EMAC_TXC_ALLOCT(val)                bfin_write32(EMAC_TXC_ALLOCT, val)
-#define bfin_read_EMAC_TXC_EQ64()              bfin_read32(EMAC_TXC_EQ64)
-#define bfin_write_EMAC_TXC_EQ64(val)          bfin_write32(EMAC_TXC_EQ64, val)
-#define bfin_read_EMAC_TXC_LT128()             bfin_read32(EMAC_TXC_LT128)
-#define bfin_write_EMAC_TXC_LT128(val)         bfin_write32(EMAC_TXC_LT128, val)
-#define bfin_read_EMAC_TXC_LT256()             bfin_read32(EMAC_TXC_LT256)
-#define bfin_write_EMAC_TXC_LT256(val)         bfin_write32(EMAC_TXC_LT256, val)
-#define bfin_read_EMAC_TXC_LT512()             bfin_read32(EMAC_TXC_LT512)
-#define bfin_write_EMAC_TXC_LT512(val)         bfin_write32(EMAC_TXC_LT512, val)
-#define bfin_read_EMAC_TXC_LT1024()            bfin_read32(EMAC_TXC_LT1024)
-#define bfin_write_EMAC_TXC_LT1024(val)                bfin_write32(EMAC_TXC_LT1024, val)
-#define bfin_read_EMAC_TXC_GE1024()            bfin_read32(EMAC_TXC_GE1024)
-#define bfin_write_EMAC_TXC_GE1024(val)                bfin_write32(EMAC_TXC_GE1024, val)
-#define bfin_read_EMAC_TXC_ABORT()             bfin_read32(EMAC_TXC_ABORT)
-#define bfin_write_EMAC_TXC_ABORT(val)         bfin_write32(EMAC_TXC_ABORT, val)
+/* PTP TSYNC Registers */
 
 #define bfin_read_EMAC_PTP_CTL()                bfin_read16(EMAC_PTP_CTL)
 #define bfin_write_EMAC_PTP_CTL(val)            bfin_write16(EMAC_PTP_CTL, val)
 #define bfin_read_EMAC_PTP_PPS_PERIOD()         bfin_read32(EMAC_PTP_PPS_PERIOD)
 #define bfin_write_EMAC_PTP_PPS_PERIOD(val)     bfin_write32(EMAC_PTP_PPS_PERIOD, val)
 
-/* Removable Storage Interface Registers */
-
-#define bfin_read_RSI_PWR_CTL()        bfin_read16(RSI_PWR_CONTROL)
-#define bfin_write_RSI_PWR_CTL(val)    bfin_write16(RSI_PWR_CONTROL, val)
-#define bfin_read_RSI_CLK_CTL()               bfin_read16(RSI_CLK_CONTROL)
-#define bfin_write_RSI_CLK_CTL(val)    bfin_write16(RSI_CLK_CONTROL, val)
-#define bfin_read_RSI_ARGUMENT()       bfin_read32(RSI_ARGUMENT)
-#define bfin_write_RSI_ARGUMENT(val)   bfin_write32(RSI_ARGUMENT, val)
-#define bfin_read_RSI_COMMAND()        bfin_read16(RSI_COMMAND)
-#define bfin_write_RSI_COMMAND(val)    bfin_write16(RSI_COMMAND, val)
-#define bfin_read_RSI_RESP_CMD()       bfin_read16(RSI_RESP_CMD)
-#define bfin_write_RSI_RESP_CMD(val)   bfin_write16(RSI_RESP_CMD, val)
-#define bfin_read_RSI_RESPONSE0()      bfin_read32(RSI_RESPONSE0)
-#define bfin_write_RSI_RESPONSE0(val)  bfin_write32(RSI_RESPONSE0, val)
-#define bfin_read_RSI_RESPONSE1()      bfin_read32(RSI_RESPONSE1)
-#define bfin_write_RSI_RESPONSE1(val)  bfin_write32(RSI_RESPONSE1, val)
-#define bfin_read_RSI_RESPONSE2()      bfin_read32(RSI_RESPONSE2)
-#define bfin_write_RSI_RESPONSE2(val)  bfin_write32(RSI_RESPONSE2, val)
-#define bfin_read_RSI_RESPONSE3()      bfin_read32(RSI_RESPONSE3)
-#define bfin_write_RSI_RESPONSE3(val)  bfin_write32(RSI_RESPONSE3, val)
-#define bfin_read_RSI_DATA_TIMER()     bfin_read32(RSI_DATA_TIMER)
-#define bfin_write_RSI_DATA_TIMER(val) bfin_write32(RSI_DATA_TIMER, val)
-#define bfin_read_RSI_DATA_LGTH()      bfin_read16(RSI_DATA_LGTH)
-#define bfin_write_RSI_DATA_LGTH(val)  bfin_write16(RSI_DATA_LGTH, val)
-#define bfin_read_RSI_DATA_CTL()       bfin_read16(RSI_DATA_CONTROL)
-#define bfin_write_RSI_DATA_CTL(val)   bfin_write16(RSI_DATA_CONTROL, val)
-#define bfin_read_RSI_DATA_CNT()       bfin_read16(RSI_DATA_CNT)
-#define bfin_write_RSI_DATA_CNT(val)   bfin_write16(RSI_DATA_CNT, val)
-#define bfin_read_RSI_STATUS()         bfin_read32(RSI_STATUS)
-#define bfin_write_RSI_STATUS(val)     bfin_write32(RSI_STATUS, val)
-#define bfin_read_RSI_STATUS_CLR()     bfin_read16(RSI_STATUSCL)
-#define bfin_write_RSI_STATUS_CLR(val) bfin_write16(RSI_STATUSCL, val)
-#define bfin_read_RSI_MASK0()          bfin_read32(RSI_MASK0)
-#define bfin_write_RSI_MASK0(val)      bfin_write32(RSI_MASK0, val)
-#define bfin_read_RSI_MASK1()          bfin_read32(RSI_MASK1)
-#define bfin_write_RSI_MASK1(val)      bfin_write32(RSI_MASK1, val)
-#define bfin_read_RSI_FIFO_CNT()       bfin_read16(RSI_FIFO_CNT)
-#define bfin_write_RSI_FIFO_CNT(val)   bfin_write16(RSI_FIFO_CNT, val)
-#define bfin_read_RSI_CEATA_CTL()      bfin_read16(RSI_CEATA_CONTROL)
-#define bfin_write_RSI_CEATA_CTL(val)  bfin_write16(RSI_CEATA_CONTROL, val)
-#define bfin_read_RSI_FIFO()           bfin_read32(RSI_FIFO)
-#define bfin_write_RSI_FIFO(val)       bfin_write32(RSI_FIFO, val)
-#define bfin_read_RSI_E_STATUS()       bfin_read16(RSI_ESTAT)
-#define bfin_write_RSI_E_STATUS(val)   bfin_write16(RSI_ESTAT, val)
-#define bfin_read_RSI_E_MASK()         bfin_read16(RSI_EMASK)
-#define bfin_write_RSI_E_MASK(val)     bfin_write16(RSI_EMASK, val)
-#define bfin_read_RSI_CFG()            bfin_read16(RSI_CONFIG)
-#define bfin_write_RSI_CFG(val)        bfin_write16(RSI_CONFIG, val)
-#define bfin_read_RSI_RD_WAIT_EN()     bfin_read16(RSI_RD_WAIT_EN)
-#define bfin_write_RSI_RD_WAIT_EN(val) bfin_write16(RSI_RD_WAIT_EN, val)
-#define bfin_read_RSI_PID0()           bfin_read16(RSI_PID0)
-#define bfin_write_RSI_PID0(val)       bfin_write16(RSI_PID0, val)
-#define bfin_read_RSI_PID1()           bfin_read16(RSI_PID1)
-#define bfin_write_RSI_PID1(val)       bfin_write16(RSI_PID1, val)
-#define bfin_read_RSI_PID2()           bfin_read16(RSI_PID2)
-#define bfin_write_RSI_PID2(val)       bfin_write16(RSI_PID2, val)
-#define bfin_read_RSI_PID3()           bfin_read16(RSI_PID3)
-#define bfin_write_RSI_PID3(val)       bfin_write16(RSI_PID3, val)
-#define bfin_read_RSI_PID4()           bfin_read16(RSI_PID4)
-#define bfin_write_RSI_PID4(val)       bfin_write16(RSI_PID4, val)
-#define bfin_read_RSI_PID5()           bfin_read16(RSI_PID5)
-#define bfin_write_RSI_PID5(val)       bfin_write16(RSI_PID5, val)
-#define bfin_read_RSI_PID6()           bfin_read16(RSI_PID6)
-#define bfin_write_RSI_PID6(val)       bfin_write16(RSI_PID6, val)
-#define bfin_read_RSI_PID7()           bfin_read16(RSI_PID7)
-#define bfin_write_RSI_PID7(val)       bfin_write16(RSI_PID7, val)
-
-
 #endif /* _CDEF_BF518_H */
index 1d970df7aee94cabd8dc46503c077a8a1b67e6c0..e548e9d1d6fac5a91b0824701c349883ec5cdac7 100644 (file)
 #define bfin_write_UART0_GCTL(val)             bfin_write16(UART0_GCTL, val)
 
 
-/* SPI Controller              (0xFFC00500 - 0xFFC005FF)                                                                       */
-#define bfin_read_SPI_CTL()                    bfin_read16(SPI_CTL)
-#define bfin_write_SPI_CTL(val)                        bfin_write16(SPI_CTL, val)
-#define bfin_read_SPI_FLG()                    bfin_read16(SPI_FLG)
-#define bfin_write_SPI_FLG(val)                        bfin_write16(SPI_FLG, val)
-#define bfin_read_SPI_STAT()                   bfin_read16(SPI_STAT)
-#define bfin_write_SPI_STAT(val)               bfin_write16(SPI_STAT, val)
-#define bfin_read_SPI_TDBR()                   bfin_read16(SPI_TDBR)
-#define bfin_write_SPI_TDBR(val)               bfin_write16(SPI_TDBR, val)
-#define bfin_read_SPI_RDBR()                   bfin_read16(SPI_RDBR)
-#define bfin_write_SPI_RDBR(val)               bfin_write16(SPI_RDBR, val)
-#define bfin_read_SPI_BAUD()                   bfin_read16(SPI_BAUD)
-#define bfin_write_SPI_BAUD(val)               bfin_write16(SPI_BAUD, val)
-#define bfin_read_SPI_SHADOW()                 bfin_read16(SPI_SHADOW)
-#define bfin_write_SPI_SHADOW(val)             bfin_write16(SPI_SHADOW, val)
-
-
 /* TIMER0-7 Registers          (0xFFC00600 - 0xFFC006FF)                                                               */
 #define bfin_read_TIMER0_CONFIG()              bfin_read16(TIMER0_CONFIG)
 #define bfin_write_TIMER0_CONFIG(val)          bfin_write16(TIMER0_CONFIG, val)
 #define bfin_write_PPI_CONTROL(val)            bfin_write16(PPI_CONTROL, val)
 #define bfin_read_PPI_STATUS()                 bfin_read16(PPI_STATUS)
 #define bfin_write_PPI_STATUS(val)             bfin_write16(PPI_STATUS, val)
+#define bfin_clear_PPI_STATUS()                        bfin_write_PPI_STATUS(0xFFFF)
 #define bfin_read_PPI_DELAY()                  bfin_read16(PPI_DELAY)
 #define bfin_write_PPI_DELAY(val)              bfin_write16(PPI_DELAY, val)
 #define bfin_read_PPI_COUNT()                  bfin_read16(PPI_COUNT)
 #define bfin_read_CNT_MIN()                    bfin_read32(CNT_MIN)
 #define bfin_write_CNT_MIN(val)                        bfin_write32(CNT_MIN, val)
 
-/* OTP/FUSE Registers */
-
-#define bfin_read_OTP_CONTROL()                        bfin_read16(OTP_CONTROL)
-#define bfin_write_OTP_CONTROL(val)            bfin_write16(OTP_CONTROL, val)
-#define bfin_read_OTP_BEN()                    bfin_read16(OTP_BEN)
-#define bfin_write_OTP_BEN(val)                        bfin_write16(OTP_BEN, val)
-#define bfin_read_OTP_STATUS()                 bfin_read16(OTP_STATUS)
-#define bfin_write_OTP_STATUS(val)             bfin_write16(OTP_STATUS, val)
-#define bfin_read_OTP_TIMING()                 bfin_read32(OTP_TIMING)
-#define bfin_write_OTP_TIMING(val)             bfin_write32(OTP_TIMING, val)
-
 /* Security Registers */
 
 #define bfin_read_SECURE_SYSSWT()              bfin_read32(SECURE_SYSSWT)
 #define bfin_read_SECURE_STATUS()              bfin_read16(SECURE_STATUS)
 #define bfin_write_SECURE_STATUS(val)          bfin_write16(SECURE_STATUS, val)
 
-/* OTP Read/Write Data Buffer Registers */
-
-#define bfin_read_OTP_DATA0()                  bfin_read32(OTP_DATA0)
-#define bfin_write_OTP_DATA0(val)              bfin_write32(OTP_DATA0, val)
-#define bfin_read_OTP_DATA1()                  bfin_read32(OTP_DATA1)
-#define bfin_write_OTP_DATA1(val)              bfin_write32(OTP_DATA1, val)
-#define bfin_read_OTP_DATA2()                  bfin_read32(OTP_DATA2)
-#define bfin_write_OTP_DATA2(val)              bfin_write32(OTP_DATA2, val)
-#define bfin_read_OTP_DATA3()                  bfin_read32(OTP_DATA3)
-#define bfin_write_OTP_DATA3(val)              bfin_write32(OTP_DATA3, val)
-
-/* NFC Registers */
-
-#define bfin_read_NFC_CTL()                    bfin_read16(NFC_CTL)
-#define bfin_write_NFC_CTL(val)                        bfin_write16(NFC_CTL, val)
-#define bfin_read_NFC_STAT()                   bfin_read16(NFC_STAT)
-#define bfin_write_NFC_STAT(val)               bfin_write16(NFC_STAT, val)
-#define bfin_read_NFC_IRQSTAT()                        bfin_read16(NFC_IRQSTAT)
-#define bfin_write_NFC_IRQSTAT(val)            bfin_write16(NFC_IRQSTAT, val)
-#define bfin_read_NFC_IRQMASK()                        bfin_read16(NFC_IRQMASK)
-#define bfin_write_NFC_IRQMASK(val)            bfin_write16(NFC_IRQMASK, val)
-#define bfin_read_NFC_ECC0()                   bfin_read16(NFC_ECC0)
-#define bfin_write_NFC_ECC0(val)               bfin_write16(NFC_ECC0, val)
-#define bfin_read_NFC_ECC1()                   bfin_read16(NFC_ECC1)
-#define bfin_write_NFC_ECC1(val)               bfin_write16(NFC_ECC1, val)
-#define bfin_read_NFC_ECC2()                   bfin_read16(NFC_ECC2)
-#define bfin_write_NFC_ECC2(val)               bfin_write16(NFC_ECC2, val)
-#define bfin_read_NFC_ECC3()                   bfin_read16(NFC_ECC3)
-#define bfin_write_NFC_ECC3(val)               bfin_write16(NFC_ECC3, val)
-#define bfin_read_NFC_COUNT()                  bfin_read16(NFC_COUNT)
-#define bfin_write_NFC_COUNT(val)              bfin_write16(NFC_COUNT, val)
-#define bfin_read_NFC_RST()                    bfin_read16(NFC_RST)
-#define bfin_write_NFC_RST(val)                        bfin_write16(NFC_RST, val)
-#define bfin_read_NFC_PGCTL()                  bfin_read16(NFC_PGCTL)
-#define bfin_write_NFC_PGCTL(val)              bfin_write16(NFC_PGCTL, val)
-#define bfin_read_NFC_READ()                   bfin_read16(NFC_READ)
-#define bfin_write_NFC_READ(val)               bfin_write16(NFC_READ, val)
-#define bfin_read_NFC_ADDR()                   bfin_read16(NFC_ADDR)
-#define bfin_write_NFC_ADDR(val)               bfin_write16(NFC_ADDR, val)
-#define bfin_read_NFC_CMD()                    bfin_read16(NFC_CMD)
-#define bfin_write_NFC_CMD(val)                        bfin_write16(NFC_CMD, val)
-#define bfin_read_NFC_DATA_WR()                        bfin_read16(NFC_DATA_WR)
-#define bfin_write_NFC_DATA_WR(val)            bfin_write16(NFC_DATA_WR, val)
-#define bfin_read_NFC_DATA_RD()                        bfin_read16(NFC_DATA_RD)
-#define bfin_write_NFC_DATA_RD(val)            bfin_write16(NFC_DATA_RD, val)
-
 /* These need to be last due to the cdef/linux inter-dependencies */
 #include <asm/irq.h>
 
index b5adca23a788081498ac838acba6d2469854b886..92e950d6e996f2bfcfae08257ab5b50b22fb650a 100644 (file)
@@ -7,49 +7,8 @@
 #ifndef _DEF_BF514_H
 #define _DEF_BF514_H
 
-/* Include all Core registers and bit definitions */
-#include <asm/def_LPBlackfin.h>
-
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF514 */
-
-/* Include defBF51x_base.h for the set of #defines that are common to all ADSP-BF51x processors */
-#include "defBF51x_base.h"
-
-/* The following are the #defines needed by ADSP-BF514 that are not in the common header */
-
-/* SDH Registers */
-
-#define SDH_PWR_CTL                    0xFFC03900 /* SDH Power Control */
-#define SDH_CLK_CTL                    0xFFC03904 /* SDH Clock Control */
-#define SDH_ARGUMENT                   0xFFC03908 /* SDH Argument */
-#define SDH_COMMAND                    0xFFC0390C /* SDH Command */
-#define SDH_RESP_CMD                   0xFFC03910 /* SDH Response Command */
-#define SDH_RESPONSE0                  0xFFC03914 /* SDH Response0 */
-#define SDH_RESPONSE1                  0xFFC03918 /* SDH Response1 */
-#define SDH_RESPONSE2                  0xFFC0391C /* SDH Response2 */
-#define SDH_RESPONSE3                  0xFFC03920 /* SDH Response3 */
-#define SDH_DATA_TIMER                 0xFFC03924 /* SDH Data Timer */
-#define SDH_DATA_LGTH                  0xFFC03928 /* SDH Data Length */
-#define SDH_DATA_CTL                   0xFFC0392C /* SDH Data Control */
-#define SDH_DATA_CNT                   0xFFC03930 /* SDH Data Counter */
-#define SDH_STATUS                     0xFFC03934 /* SDH Status */
-#define SDH_STATUS_CLR                 0xFFC03938 /* SDH Status Clear */
-#define SDH_MASK0                      0xFFC0393C /* SDH Interrupt0 Mask */
-#define SDH_MASK1                      0xFFC03940 /* SDH Interrupt1 Mask */
-#define SDH_FIFO_CNT                   0xFFC03948 /* SDH FIFO Counter */
-#define SDH_FIFO                       0xFFC03980 /* SDH Data FIFO */
-#define SDH_E_STATUS                   0xFFC039C0 /* SDH Exception Status */
-#define SDH_E_MASK                     0xFFC039C4 /* SDH Exception Mask */
-#define SDH_CFG                        0xFFC039C8 /* SDH Configuration */
-#define SDH_RD_WAIT_EN                 0xFFC039CC /* SDH Read Wait Enable */
-#define SDH_PID0                       0xFFC039D0 /* SDH Peripheral Identification0 */
-#define SDH_PID1                       0xFFC039D4 /* SDH Peripheral Identification1 */
-#define SDH_PID2                       0xFFC039D8 /* SDH Peripheral Identification2 */
-#define SDH_PID3                       0xFFC039DC /* SDH Peripheral Identification3 */
-#define SDH_PID4                       0xFFC039E0 /* SDH Peripheral Identification4 */
-#define SDH_PID5                       0xFFC039E4 /* SDH Peripheral Identification5 */
-#define SDH_PID6                       0xFFC039E8 /* SDH Peripheral Identification6 */
-#define SDH_PID7                       0xFFC039EC /* SDH Peripheral Identification7 */
+/* BF514 is BF512 + RSI */
+#include "defBF512.h"
 
 /* Removable Storage Interface Registers */
 
index 7eb18774d7279a02428548f7e7156a7502172d25..22a3aa0d2629cedabb134618f8af488858c0afd0 100644 (file)
@@ -7,13 +7,8 @@
 #ifndef _DEF_BF516_H
 #define _DEF_BF516_H
 
-/* Include all Core registers and bit definitions */
-#include <asm/def_LPBlackfin.h>
-
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF516 */
-
-/* Include defBF51x_base.h for the set of #defines that are common to all ADSP-BF51x processors */
-#include "defBF51x_base.h"
+/* BF516 is BF514 + EMAC */
+#include "defBF514.h"
 
 /* The following are the #defines needed by ADSP-BF516 that are not in the common header */
 /* 10/100 Ethernet Controller  (0xFFC03000 - 0xFFC031FF) */
 #define        TX_GE1024_CNT     0x00200000    /* 1024-Max-Byte TX Frames Sent                           */
 #define        TX_ABORT_CNT      0x00400000    /* TX Frames Aborted                                      */
 
-/* SDH Registers */
-
-#define SDH_PWR_CTL                    0xFFC03900 /* SDH Power Control */
-#define SDH_CLK_CTL                    0xFFC03904 /* SDH Clock Control */
-#define SDH_ARGUMENT                   0xFFC03908 /* SDH Argument */
-#define SDH_COMMAND                    0xFFC0390C /* SDH Command */
-#define SDH_RESP_CMD                   0xFFC03910 /* SDH Response Command */
-#define SDH_RESPONSE0                  0xFFC03914 /* SDH Response0 */
-#define SDH_RESPONSE1                  0xFFC03918 /* SDH Response1 */
-#define SDH_RESPONSE2                  0xFFC0391C /* SDH Response2 */
-#define SDH_RESPONSE3                  0xFFC03920 /* SDH Response3 */
-#define SDH_DATA_TIMER                 0xFFC03924 /* SDH Data Timer */
-#define SDH_DATA_LGTH                  0xFFC03928 /* SDH Data Length */
-#define SDH_DATA_CTL                   0xFFC0392C /* SDH Data Control */
-#define SDH_DATA_CNT                   0xFFC03930 /* SDH Data Counter */
-#define SDH_STATUS                     0xFFC03934 /* SDH Status */
-#define SDH_STATUS_CLR                 0xFFC03938 /* SDH Status Clear */
-#define SDH_MASK0                      0xFFC0393C /* SDH Interrupt0 Mask */
-#define SDH_MASK1                      0xFFC03940 /* SDH Interrupt1 Mask */
-#define SDH_FIFO_CNT                   0xFFC03948 /* SDH FIFO Counter */
-#define SDH_FIFO                       0xFFC03980 /* SDH Data FIFO */
-#define SDH_E_STATUS                   0xFFC039C0 /* SDH Exception Status */
-#define SDH_E_MASK                     0xFFC039C4 /* SDH Exception Mask */
-#define SDH_CFG                        0xFFC039C8 /* SDH Configuration */
-#define SDH_RD_WAIT_EN                 0xFFC039CC /* SDH Read Wait Enable */
-#define SDH_PID0                       0xFFC039D0 /* SDH Peripheral Identification0 */
-#define SDH_PID1                       0xFFC039D4 /* SDH Peripheral Identification1 */
-#define SDH_PID2                       0xFFC039D8 /* SDH Peripheral Identification2 */
-#define SDH_PID3                       0xFFC039DC /* SDH Peripheral Identification3 */
-#define SDH_PID4                       0xFFC039E0 /* SDH Peripheral Identification4 */
-#define SDH_PID5                       0xFFC039E4 /* SDH Peripheral Identification5 */
-#define SDH_PID6                       0xFFC039E8 /* SDH Peripheral Identification6 */
-#define SDH_PID7                       0xFFC039EC /* SDH Peripheral Identification7 */
-
-/* Removable Storage Interface Registers */
-
-#define RSI_PWR_CONTROL                0xFFC03800 /* RSI Power Control Register */
-#define RSI_CLK_CONTROL                0xFFC03804 /* RSI Clock Control Register */
-#define RSI_ARGUMENT                   0xFFC03808 /* RSI Argument Register */
-#define RSI_COMMAND                    0xFFC0380C /* RSI Command Register */
-#define RSI_RESP_CMD                   0xFFC03810 /* RSI Response Command Register */
-#define RSI_RESPONSE0                  0xFFC03814 /* RSI Response Register */
-#define RSI_RESPONSE1                  0xFFC03818 /* RSI Response Register */
-#define RSI_RESPONSE2                  0xFFC0381C /* RSI Response Register */
-#define RSI_RESPONSE3                  0xFFC03820 /* RSI Response Register */
-#define RSI_DATA_TIMER                 0xFFC03824 /* RSI Data Timer Register */
-#define RSI_DATA_LGTH                  0xFFC03828 /* RSI Data Length Register */
-#define RSI_DATA_CONTROL               0xFFC0382C /* RSI Data Control Register */
-#define RSI_DATA_CNT                   0xFFC03830 /* RSI Data Counter Register */
-#define RSI_STATUS                     0xFFC03834 /* RSI Status Register */
-#define RSI_STATUSCL                   0xFFC03838 /* RSI Status Clear Register */
-#define RSI_MASK0                      0xFFC0383C /* RSI Interrupt 0 Mask Register */
-#define RSI_MASK1                      0xFFC03840 /* RSI Interrupt 1 Mask Register */
-#define RSI_FIFO_CNT                   0xFFC03848 /* RSI FIFO Counter Register */
-#define RSI_CEATA_CONTROL              0xFFC0384C /* RSI CEATA Register */
-#define RSI_FIFO                       0xFFC03880 /* RSI Data FIFO Register */
-#define RSI_ESTAT                      0xFFC038C0 /* RSI Exception Status Register */
-#define RSI_EMASK                      0xFFC038C4 /* RSI Exception Mask Register */
-#define RSI_CONFIG                     0xFFC038C8 /* RSI Configuration Register */
-#define RSI_RD_WAIT_EN                 0xFFC038CC /* RSI Read Wait Enable Register */
-#define RSI_PID0                       0xFFC03FE0 /* RSI Peripheral ID Register 0 */
-#define RSI_PID1                       0xFFC03FE4 /* RSI Peripheral ID Register 1 */
-#define RSI_PID2                       0xFFC03FE8 /* RSI Peripheral ID Register 2 */
-#define RSI_PID3                       0xFFC03FEC /* RSI Peripheral ID Register 3 */
-#define RSI_PID4                       0xFFC03FF0 /* RSI Peripheral ID Register 4 */
-#define RSI_PID5                       0xFFC03FF4 /* RSI Peripheral ID Register 5 */
-#define RSI_PID6                       0xFFC03FF8 /* RSI Peripheral ID Register 6 */
-#define RSI_PID7                       0xFFC03FFC /* RSI Peripheral ID Register 7 */
-
-/* ********************************************************** */
-/*     SINGLE BIT MACRO PAIRS (bit mask and negated one)      */
-/*     and MULTI BIT READ MACROS                              */
-/* ********************************************************** */
-
-/* Bit masks for SDH_COMMAND */
-
-#define                   CMD_IDX  0x3f       /* Command Index */
-#define                   CMD_RSP  0x40       /* Response */
-#define                 CMD_L_RSP  0x80       /* Long Response */
-#define                 CMD_INT_E  0x100      /* Command Interrupt */
-#define                CMD_PEND_E  0x200      /* Command Pending */
-#define                     CMD_E  0x400      /* Command Enable */
-
-/* Bit masks for SDH_PWR_CTL */
-
-#define                    PWR_ON  0x3        /* Power On */
-#if 0
-#define                       TBD  0x3c       /* TBD */
-#endif
-#define                 SD_CMD_OD  0x40       /* Open Drain Output */
-#define                   ROD_CTL  0x80       /* Rod Control */
-
-/* Bit masks for SDH_CLK_CTL */
-
-#define                    CLKDIV  0xff       /* MC_CLK Divisor */
-#define                     CLK_E  0x100      /* MC_CLK Bus Clock Enable */
-#define                  PWR_SV_E  0x200      /* Power Save Enable */
-#define             CLKDIV_BYPASS  0x400      /* Bypass Divisor */
-#define                  WIDE_BUS  0x800      /* Wide Bus Mode Enable */
-
-/* Bit masks for SDH_RESP_CMD */
-
-#define                  RESP_CMD  0x3f       /* Response Command */
-
-/* Bit masks for SDH_DATA_CTL */
-
-#define                     DTX_E  0x1        /* Data Transfer Enable */
-#define                   DTX_DIR  0x2        /* Data Transfer Direction */
-#define                  DTX_MODE  0x4        /* Data Transfer Mode */
-#define                 DTX_DMA_E  0x8        /* Data Transfer DMA Enable */
-#define              DTX_BLK_LGTH  0xf0       /* Data Transfer Block Length */
-
-/* Bit masks for SDH_STATUS */
-
-#define              CMD_CRC_FAIL  0x1        /* CMD CRC Fail */
-#define              DAT_CRC_FAIL  0x2        /* Data CRC Fail */
-#define               CMD_TIME_OUT  0x4        /* CMD Time Out */
-#define               DAT_TIME_OUT  0x8        /* Data Time Out */
-#define               TX_UNDERRUN  0x10       /* Transmit Underrun */
-#define                RX_OVERRUN  0x20       /* Receive Overrun */
-#define              CMD_RESP_END  0x40       /* CMD Response End */
-#define                  CMD_SENT  0x80       /* CMD Sent */
-#define                   DAT_END  0x100      /* Data End */
-#define             START_BIT_ERR  0x200      /* Start Bit Error */
-#define               DAT_BLK_END  0x400      /* Data Block End */
-#define                   CMD_ACT  0x800      /* CMD Active */
-#define                    TX_ACT  0x1000     /* Transmit Active */
-#define                    RX_ACT  0x2000     /* Receive Active */
-#define              TX_FIFO_STAT  0x4000     /* Transmit FIFO Status */
-#define              RX_FIFO_STAT  0x8000     /* Receive FIFO Status */
-#define              TX_FIFO_FULL  0x10000    /* Transmit FIFO Full */
-#define              RX_FIFO_FULL  0x20000    /* Receive FIFO Full */
-#define              TX_FIFO_ZERO  0x40000    /* Transmit FIFO Empty */
-#define               RX_DAT_ZERO  0x80000    /* Receive FIFO Empty */
-#define                TX_DAT_RDY  0x100000   /* Transmit Data Available */
-#define               RX_FIFO_RDY  0x200000   /* Receive Data Available */
-
-/* Bit masks for SDH_STATUS_CLR */
-
-#define         CMD_CRC_FAIL_STAT  0x1        /* CMD CRC Fail Status */
-#define         DAT_CRC_FAIL_STAT  0x2        /* Data CRC Fail Status */
-#define          CMD_TIMEOUT_STAT  0x4        /* CMD Time Out Status */
-#define          DAT_TIMEOUT_STAT  0x8        /* Data Time Out status */
-#define          TX_UNDERRUN_STAT  0x10       /* Transmit Underrun Status */
-#define           RX_OVERRUN_STAT  0x20       /* Receive Overrun Status */
-#define         CMD_RESP_END_STAT  0x40       /* CMD Response End Status */
-#define             CMD_SENT_STAT  0x80       /* CMD Sent Status */
-#define              DAT_END_STAT  0x100      /* Data End Status */
-#define        START_BIT_ERR_STAT  0x200      /* Start Bit Error Status */
-#define          DAT_BLK_END_STAT  0x400      /* Data Block End Status */
-
-/* Bit masks for SDH_MASK0 */
-
-#define         CMD_CRC_FAIL_MASK  0x1        /* CMD CRC Fail Mask */
-#define         DAT_CRC_FAIL_MASK  0x2        /* Data CRC Fail Mask */
-#define          CMD_TIMEOUT_MASK  0x4        /* CMD Time Out Mask */
-#define          DAT_TIMEOUT_MASK  0x8        /* Data Time Out Mask */
-#define          TX_UNDERRUN_MASK  0x10       /* Transmit Underrun Mask */
-#define           RX_OVERRUN_MASK  0x20       /* Receive Overrun Mask */
-#define         CMD_RESP_END_MASK  0x40       /* CMD Response End Mask */
-#define             CMD_SENT_MASK  0x80       /* CMD Sent Mask */
-#define              DAT_END_MASK  0x100      /* Data End Mask */
-#define        START_BIT_ERR_MASK  0x200      /* Start Bit Error Mask */
-#define          DAT_BLK_END_MASK  0x400      /* Data Block End Mask */
-#define              CMD_ACT_MASK  0x800      /* CMD Active Mask */
-#define               TX_ACT_MASK  0x1000     /* Transmit Active Mask */
-#define               RX_ACT_MASK  0x2000     /* Receive Active Mask */
-#define         TX_FIFO_STAT_MASK  0x4000     /* Transmit FIFO Status Mask */
-#define         RX_FIFO_STAT_MASK  0x8000     /* Receive FIFO Status Mask */
-#define         TX_FIFO_FULL_MASK  0x10000    /* Transmit FIFO Full Mask */
-#define         RX_FIFO_FULL_MASK  0x20000    /* Receive FIFO Full Mask */
-#define         TX_FIFO_ZERO_MASK  0x40000    /* Transmit FIFO Empty Mask */
-#define          RX_DAT_ZERO_MASK  0x80000    /* Receive FIFO Empty Mask */
-#define           TX_DAT_RDY_MASK  0x100000   /* Transmit Data Available Mask */
-#define          RX_FIFO_RDY_MASK  0x200000   /* Receive Data Available Mask */
-
-/* Bit masks for SDH_FIFO_CNT */
-
-#define                FIFO_COUNT  0x7fff     /* FIFO Count */
-
-/* Bit masks for SDH_E_STATUS */
-
-#define              SDIO_INT_DET  0x2        /* SDIO Int Detected */
-#define               SD_CARD_DET  0x10       /* SD Card Detect */
-
-/* Bit masks for SDH_E_MASK */
-
-#define                  SDIO_MSK  0x2        /* Mask SDIO Int Detected */
-#define                   SCD_MSK  0x40       /* Mask Card Detect */
-
-/* Bit masks for SDH_CFG */
-
-#define                   CLKS_EN  0x1        /* Clocks Enable */
-#define                      SD4E  0x4        /* SDIO 4-Bit Enable */
-#define                       MWE  0x8        /* Moving Window Enable */
-#define                    SD_RST  0x10       /* SDMMC Reset */
-#define                 PUP_SDDAT  0x20       /* Pull-up SD_DAT */
-#define                PUP_SDDAT3  0x40       /* Pull-up SD_DAT3 */
-#define                 PD_SDDAT3  0x80       /* Pull-down SD_DAT3 */
-
-/* Bit masks for SDH_RD_WAIT_EN */
-
-#define                       RWR  0x1        /* Read Wait Request */
-
 #endif /* _DEF_BF516_H */
index 794cf06eb5bae608e95ee1b56af9d30699293e5d..cb18270e55c2c394b07ac3ff88ab47b063b99135 100644 (file)
@@ -7,461 +7,8 @@
 #ifndef _DEF_BF518_H
 #define _DEF_BF518_H
 
-/* Include all Core registers and bit definitions */
-#include <asm/def_LPBlackfin.h>
-
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF518 */
-
-/* Include defBF51x_base.h for the set of #defines that are common to all ADSP-BF51x processors */
-#include "defBF51x_base.h"
-
-/* The following are the #defines needed by ADSP-BF518 that are not in the common header */
-/* 10/100 Ethernet Controller  (0xFFC03000 - 0xFFC031FF) */
-
-#define EMAC_OPMODE             0xFFC03000       /* Operating Mode Register                              */
-#define EMAC_ADDRLO             0xFFC03004       /* Address Low (32 LSBs) Register                       */
-#define EMAC_ADDRHI             0xFFC03008       /* Address High (16 MSBs) Register                      */
-#define EMAC_HASHLO             0xFFC0300C       /* Multicast Hash Table Low (Bins 31-0) Register        */
-#define EMAC_HASHHI             0xFFC03010       /* Multicast Hash Table High (Bins 63-32) Register      */
-#define EMAC_STAADD             0xFFC03014       /* Station Management Address Register                  */
-#define EMAC_STADAT             0xFFC03018       /* Station Management Data Register                     */
-#define EMAC_FLC                0xFFC0301C       /* Flow Control Register                                */
-#define EMAC_VLAN1              0xFFC03020       /* VLAN1 Tag Register                                   */
-#define EMAC_VLAN2              0xFFC03024       /* VLAN2 Tag Register                                   */
-#define EMAC_WKUP_CTL           0xFFC0302C       /* Wake-Up Control/Status Register                      */
-#define EMAC_WKUP_FFMSK0        0xFFC03030       /* Wake-Up Frame Filter 0 Byte Mask Register            */
-#define EMAC_WKUP_FFMSK1        0xFFC03034       /* Wake-Up Frame Filter 1 Byte Mask Register            */
-#define EMAC_WKUP_FFMSK2        0xFFC03038       /* Wake-Up Frame Filter 2 Byte Mask Register            */
-#define EMAC_WKUP_FFMSK3        0xFFC0303C       /* Wake-Up Frame Filter 3 Byte Mask Register            */
-#define EMAC_WKUP_FFCMD         0xFFC03040       /* Wake-Up Frame Filter Commands Register               */
-#define EMAC_WKUP_FFOFF         0xFFC03044       /* Wake-Up Frame Filter Offsets Register                */
-#define EMAC_WKUP_FFCRC0        0xFFC03048       /* Wake-Up Frame Filter 0,1 CRC-16 Register             */
-#define EMAC_WKUP_FFCRC1        0xFFC0304C       /* Wake-Up Frame Filter 2,3 CRC-16 Register             */
-
-#define EMAC_SYSCTL             0xFFC03060       /* EMAC System Control Register                         */
-#define EMAC_SYSTAT             0xFFC03064       /* EMAC System Status Register                          */
-#define EMAC_RX_STAT            0xFFC03068       /* RX Current Frame Status Register                     */
-#define EMAC_RX_STKY            0xFFC0306C       /* RX Sticky Frame Status Register                      */
-#define EMAC_RX_IRQE            0xFFC03070       /* RX Frame Status Interrupt Enables Register           */
-#define EMAC_TX_STAT            0xFFC03074       /* TX Current Frame Status Register                     */
-#define EMAC_TX_STKY            0xFFC03078       /* TX Sticky Frame Status Register                      */
-#define EMAC_TX_IRQE            0xFFC0307C       /* TX Frame Status Interrupt Enables Register           */
-
-#define EMAC_MMC_CTL            0xFFC03080       /* MMC Counter Control Register                         */
-#define EMAC_MMC_RIRQS          0xFFC03084       /* MMC RX Interrupt Status Register                     */
-#define EMAC_MMC_RIRQE          0xFFC03088       /* MMC RX Interrupt Enables Register                    */
-#define EMAC_MMC_TIRQS          0xFFC0308C       /* MMC TX Interrupt Status Register                     */
-#define EMAC_MMC_TIRQE          0xFFC03090       /* MMC TX Interrupt Enables Register                    */
-
-#define EMAC_RXC_OK             0xFFC03100       /* RX Frame Successful Count                            */
-#define EMAC_RXC_FCS            0xFFC03104       /* RX Frame FCS Failure Count                           */
-#define EMAC_RXC_ALIGN          0xFFC03108       /* RX Alignment Error Count                             */
-#define EMAC_RXC_OCTET          0xFFC0310C       /* RX Octets Successfully Received Count                */
-#define EMAC_RXC_DMAOVF         0xFFC03110       /* Internal MAC Sublayer Error RX Frame Count           */
-#define EMAC_RXC_UNICST         0xFFC03114       /* Unicast RX Frame Count                               */
-#define EMAC_RXC_MULTI          0xFFC03118       /* Multicast RX Frame Count                             */
-#define EMAC_RXC_BROAD          0xFFC0311C       /* Broadcast RX Frame Count                             */
-#define EMAC_RXC_LNERRI         0xFFC03120       /* RX Frame In Range Error Count                        */
-#define EMAC_RXC_LNERRO         0xFFC03124       /* RX Frame Out Of Range Error Count                    */
-#define EMAC_RXC_LONG           0xFFC03128       /* RX Frame Too Long Count                              */
-#define EMAC_RXC_MACCTL         0xFFC0312C       /* MAC Control RX Frame Count                           */
-#define EMAC_RXC_OPCODE         0xFFC03130       /* Unsupported Op-Code RX Frame Count                   */
-#define EMAC_RXC_PAUSE          0xFFC03134       /* MAC Control Pause RX Frame Count                     */
-#define EMAC_RXC_ALLFRM         0xFFC03138       /* Overall RX Frame Count                               */
-#define EMAC_RXC_ALLOCT         0xFFC0313C       /* Overall RX Octet Count                               */
-#define EMAC_RXC_TYPED          0xFFC03140       /* Type/Length Consistent RX Frame Count                */
-#define EMAC_RXC_SHORT          0xFFC03144       /* RX Frame Fragment Count - Byte Count x < 64          */
-#define EMAC_RXC_EQ64           0xFFC03148       /* Good RX Frame Count - Byte Count x = 64              */
-#define EMAC_RXC_LT128          0xFFC0314C       /* Good RX Frame Count - Byte Count  64 < x < 128       */
-#define EMAC_RXC_LT256          0xFFC03150       /* Good RX Frame Count - Byte Count 128 <= x < 256      */
-#define EMAC_RXC_LT512          0xFFC03154       /* Good RX Frame Count - Byte Count 256 <= x < 512      */
-#define EMAC_RXC_LT1024         0xFFC03158       /* Good RX Frame Count - Byte Count 512 <= x < 1024     */
-#define EMAC_RXC_GE1024         0xFFC0315C       /* Good RX Frame Count - Byte Count x >= 1024           */
-
-#define EMAC_TXC_OK             0xFFC03180       /* TX Frame Successful Count                             */
-#define EMAC_TXC_1COL           0xFFC03184       /* TX Frames Successful After Single Collision Count     */
-#define EMAC_TXC_GT1COL         0xFFC03188       /* TX Frames Successful After Multiple Collisions Count  */
-#define EMAC_TXC_OCTET          0xFFC0318C       /* TX Octets Successfully Received Count                 */
-#define EMAC_TXC_DEFER          0xFFC03190       /* TX Frame Delayed Due To Busy Count                    */
-#define EMAC_TXC_LATECL         0xFFC03194       /* Late TX Collisions Count                              */
-#define EMAC_TXC_XS_COL         0xFFC03198       /* TX Frame Failed Due To Excessive Collisions Count     */
-#define EMAC_TXC_DMAUND         0xFFC0319C       /* Internal MAC Sublayer Error TX Frame Count            */
-#define EMAC_TXC_CRSERR         0xFFC031A0       /* Carrier Sense Deasserted During TX Frame Count        */
-#define EMAC_TXC_UNICST         0xFFC031A4       /* Unicast TX Frame Count                                */
-#define EMAC_TXC_MULTI          0xFFC031A8       /* Multicast TX Frame Count                              */
-#define EMAC_TXC_BROAD          0xFFC031AC       /* Broadcast TX Frame Count                              */
-#define EMAC_TXC_XS_DFR         0xFFC031B0       /* TX Frames With Excessive Deferral Count               */
-#define EMAC_TXC_MACCTL         0xFFC031B4       /* MAC Control TX Frame Count                            */
-#define EMAC_TXC_ALLFRM         0xFFC031B8       /* Overall TX Frame Count                                */
-#define EMAC_TXC_ALLOCT         0xFFC031BC       /* Overall TX Octet Count                                */
-#define EMAC_TXC_EQ64           0xFFC031C0       /* Good TX Frame Count - Byte Count x = 64               */
-#define EMAC_TXC_LT128          0xFFC031C4       /* Good TX Frame Count - Byte Count  64 < x < 128        */
-#define EMAC_TXC_LT256          0xFFC031C8       /* Good TX Frame Count - Byte Count 128 <= x < 256       */
-#define EMAC_TXC_LT512          0xFFC031CC       /* Good TX Frame Count - Byte Count 256 <= x < 512       */
-#define EMAC_TXC_LT1024         0xFFC031D0       /* Good TX Frame Count - Byte Count 512 <= x < 1024      */
-#define EMAC_TXC_GE1024         0xFFC031D4       /* Good TX Frame Count - Byte Count x >= 1024            */
-#define EMAC_TXC_ABORT          0xFFC031D8       /* Total TX Frames Aborted Count                         */
-
-/* Listing for IEEE-Supported Count Registers */
-
-#define FramesReceivedOK                EMAC_RXC_OK        /* RX Frame Successful Count                            */
-#define FrameCheckSequenceErrors        EMAC_RXC_FCS       /* RX Frame FCS Failure Count                           */
-#define AlignmentErrors                 EMAC_RXC_ALIGN     /* RX Alignment Error Count                             */
-#define OctetsReceivedOK                EMAC_RXC_OCTET     /* RX Octets Successfully Received Count                */
-#define FramesLostDueToIntMACRcvError   EMAC_RXC_DMAOVF    /* Internal MAC Sublayer Error RX Frame Count           */
-#define UnicastFramesReceivedOK         EMAC_RXC_UNICST    /* Unicast RX Frame Count                               */
-#define MulticastFramesReceivedOK       EMAC_RXC_MULTI     /* Multicast RX Frame Count                             */
-#define BroadcastFramesReceivedOK       EMAC_RXC_BROAD     /* Broadcast RX Frame Count                             */
-#define InRangeLengthErrors             EMAC_RXC_LNERRI    /* RX Frame In Range Error Count                        */
-#define OutOfRangeLengthField           EMAC_RXC_LNERRO    /* RX Frame Out Of Range Error Count                    */
-#define FrameTooLongErrors              EMAC_RXC_LONG      /* RX Frame Too Long Count                              */
-#define MACControlFramesReceived        EMAC_RXC_MACCTL    /* MAC Control RX Frame Count                           */
-#define UnsupportedOpcodesReceived      EMAC_RXC_OPCODE    /* Unsupported Op-Code RX Frame Count                   */
-#define PAUSEMACCtrlFramesReceived      EMAC_RXC_PAUSE     /* MAC Control Pause RX Frame Count                     */
-#define FramesReceivedAll               EMAC_RXC_ALLFRM    /* Overall RX Frame Count                               */
-#define OctetsReceivedAll               EMAC_RXC_ALLOCT    /* Overall RX Octet Count                               */
-#define TypedFramesReceived             EMAC_RXC_TYPED     /* Type/Length Consistent RX Frame Count                */
-#define FramesLenLt64Received           EMAC_RXC_SHORT     /* RX Frame Fragment Count - Byte Count x < 64          */
-#define FramesLenEq64Received           EMAC_RXC_EQ64      /* Good RX Frame Count - Byte Count x = 64              */
-#define FramesLen65_127Received         EMAC_RXC_LT128     /* Good RX Frame Count - Byte Count  64 < x < 128       */
-#define FramesLen128_255Received        EMAC_RXC_LT256     /* Good RX Frame Count - Byte Count 128 <= x < 256      */
-#define FramesLen256_511Received        EMAC_RXC_LT512     /* Good RX Frame Count - Byte Count 256 <= x < 512      */
-#define FramesLen512_1023Received       EMAC_RXC_LT1024    /* Good RX Frame Count - Byte Count 512 <= x < 1024     */
-#define FramesLen1024_MaxReceived       EMAC_RXC_GE1024    /* Good RX Frame Count - Byte Count x >= 1024           */
-
-#define FramesTransmittedOK             EMAC_TXC_OK        /* TX Frame Successful Count                            */
-#define SingleCollisionFrames           EMAC_TXC_1COL      /* TX Frames Successful After Single Collision Count    */
-#define MultipleCollisionFrames         EMAC_TXC_GT1COL    /* TX Frames Successful After Multiple Collisions Count */
-#define OctetsTransmittedOK             EMAC_TXC_OCTET     /* TX Octets Successfully Received Count                */
-#define FramesWithDeferredXmissions     EMAC_TXC_DEFER     /* TX Frame Delayed Due To Busy Count                   */
-#define LateCollisions                  EMAC_TXC_LATECL    /* Late TX Collisions Count                             */
-#define FramesAbortedDueToXSColls       EMAC_TXC_XS_COL    /* TX Frame Failed Due To Excessive Collisions Count    */
-#define FramesLostDueToIntMacXmitError  EMAC_TXC_DMAUND    /* Internal MAC Sublayer Error TX Frame Count           */
-#define CarrierSenseErrors              EMAC_TXC_CRSERR    /* Carrier Sense Deasserted During TX Frame Count       */
-#define UnicastFramesXmittedOK          EMAC_TXC_UNICST    /* Unicast TX Frame Count                               */
-#define MulticastFramesXmittedOK        EMAC_TXC_MULTI     /* Multicast TX Frame Count                             */
-#define BroadcastFramesXmittedOK        EMAC_TXC_BROAD     /* Broadcast TX Frame Count                             */
-#define FramesWithExcessiveDeferral     EMAC_TXC_XS_DFR    /* TX Frames With Excessive Deferral Count              */
-#define MACControlFramesTransmitted     EMAC_TXC_MACCTL    /* MAC Control TX Frame Count                           */
-#define FramesTransmittedAll            EMAC_TXC_ALLFRM    /* Overall TX Frame Count                               */
-#define OctetsTransmittedAll            EMAC_TXC_ALLOCT    /* Overall TX Octet Count                               */
-#define FramesLenEq64Transmitted        EMAC_TXC_EQ64      /* Good TX Frame Count - Byte Count x = 64              */
-#define FramesLen65_127Transmitted      EMAC_TXC_LT128     /* Good TX Frame Count - Byte Count  64 < x < 128       */
-#define FramesLen128_255Transmitted     EMAC_TXC_LT256     /* Good TX Frame Count - Byte Count 128 <= x < 256      */
-#define FramesLen256_511Transmitted     EMAC_TXC_LT512     /* Good TX Frame Count - Byte Count 256 <= x < 512      */
-#define FramesLen512_1023Transmitted    EMAC_TXC_LT1024    /* Good TX Frame Count - Byte Count 512 <= x < 1024     */
-#define FramesLen1024_MaxTransmitted    EMAC_TXC_GE1024    /* Good TX Frame Count - Byte Count x >= 1024           */
-#define TxAbortedFrames                 EMAC_TXC_ABORT     /* Total TX Frames Aborted Count                        */
-
-/***********************************************************************************
-** System MMR Register Bits And Macros
-**
-** Disclaimer: All macros are intended to make C and Assembly code more readable.
-**                             Use these macros carefully, as any that do left shifts for field
-**                             depositing will result in the lower order bits being destroyed.  Any
-**                             macro that shifts left to properly position the bit-field should be
-**                             used as part of an OR to initialize a register and NOT as a dynamic
-**                             modifier UNLESS the lower order bits are saved and ORed back in when
-**                             the macro is used.
-*************************************************************************************/
-
-/************************  ETHERNET 10/100 CONTROLLER MASKS  ************************/
-
-/* EMAC_OPMODE Masks */
-
-#define        RE                 0x00000001     /* Receiver Enable                                    */
-#define        ASTP               0x00000002     /* Enable Automatic Pad Stripping On RX Frames        */
-#define        HU                 0x00000010     /* Hash Filter Unicast Address                        */
-#define        HM                 0x00000020     /* Hash Filter Multicast Address                      */
-#define        PAM                0x00000040     /* Pass-All-Multicast Mode Enable                     */
-#define        PR                 0x00000080     /* Promiscuous Mode Enable                            */
-#define        IFE                0x00000100     /* Inverse Filtering Enable                           */
-#define        DBF                0x00000200     /* Disable Broadcast Frame Reception                  */
-#define        PBF                0x00000400     /* Pass Bad Frames Enable                             */
-#define        PSF                0x00000800     /* Pass Short Frames Enable                           */
-#define        RAF                0x00001000     /* Receive-All Mode                                   */
-#define        TE                 0x00010000     /* Transmitter Enable                                 */
-#define        DTXPAD             0x00020000     /* Disable Automatic TX Padding                       */
-#define        DTXCRC             0x00040000     /* Disable Automatic TX CRC Generation                */
-#define        DC                 0x00080000     /* Deferral Check                                     */
-#define        BOLMT              0x00300000     /* Back-Off Limit                                     */
-#define        BOLMT_10           0x00000000     /*            10-bit range                            */
-#define        BOLMT_8            0x00100000     /*            8-bit range                             */
-#define        BOLMT_4            0x00200000     /*            4-bit range                             */
-#define        BOLMT_1            0x00300000     /*            1-bit range                             */
-#define        DRTY               0x00400000     /* Disable TX Retry On Collision                      */
-#define        LCTRE              0x00800000     /* Enable TX Retry On Late Collision                  */
-#define        RMII               0x01000000     /* RMII/MII* Mode                                     */
-#define        RMII_10            0x02000000     /* Speed Select for RMII Port (10MBit/100MBit*)       */
-#define        FDMODE             0x04000000     /* Duplex Mode Enable (Full/Half*)                    */
-#define        LB                 0x08000000     /* Internal Loopback Enable                           */
-#define        DRO                0x10000000     /* Disable Receive Own Frames (Half-Duplex Mode)      */
-
-/* EMAC_STAADD Masks */
-
-#define        STABUSY            0x00000001     /* Initiate Station Mgt Reg Access / STA Busy Stat    */
-#define        STAOP              0x00000002     /* Station Management Operation Code (Write/Read*)    */
-#define        STADISPRE          0x00000004     /* Disable Preamble Generation                        */
-#define        STAIE              0x00000008     /* Station Mgt. Transfer Done Interrupt Enable        */
-#define        REGAD              0x000007C0     /* STA Register Address                               */
-#define        PHYAD              0x0000F800     /* PHY Device Address                                 */
-
-#define        SET_REGAD(x) (((x)&0x1F)<<  6 )   /* Set STA Register Address                           */
-#define        SET_PHYAD(x) (((x)&0x1F)<< 11 )   /* Set PHY Device Address                             */
-
-/* EMAC_STADAT Mask */
-
-#define        STADATA            0x0000FFFF     /* Station Management Data                            */
-
-/* EMAC_FLC Masks */
-
-#define        FLCBUSY            0x00000001     /* Send Flow Ctrl Frame / Flow Ctrl Busy Status       */
-#define        FLCE               0x00000002     /* Flow Control Enable                                */
-#define        PCF                0x00000004     /* Pass Control Frames                                */
-#define        BKPRSEN            0x00000008     /* Enable Backpressure                                */
-#define        FLCPAUSE           0xFFFF0000     /* Pause Time                                         */
-
-#define        SET_FLCPAUSE(x) (((x)&0xFFFF)<< 16) /* Set Pause Time                                   */
-
-/* EMAC_WKUP_CTL Masks */
-
-#define        CAPWKFRM           0x00000001    /* Capture Wake-Up Frames                              */
-#define        MPKE               0x00000002    /* Magic Packet Enable                                 */
-#define        RWKE               0x00000004    /* Remote Wake-Up Frame Enable                         */
-#define        GUWKE              0x00000008    /* Global Unicast Wake Enable                          */
-#define        MPKS               0x00000020    /* Magic Packet Received Status                        */
-#define        RWKS               0x00000F00    /* Wake-Up Frame Received Status, Filters 3:0          */
-
-/* EMAC_WKUP_FFCMD Masks */
-
-#define        WF0_E              0x00000001    /* Enable Wake-Up Filter 0                              */
-#define        WF0_T              0x00000008    /* Wake-Up Filter 0 Addr Type (Multicast/Unicast*)      */
-#define        WF1_E              0x00000100    /* Enable Wake-Up Filter 1                              */
-#define        WF1_T              0x00000800    /* Wake-Up Filter 1 Addr Type (Multicast/Unicast*)      */
-#define        WF2_E              0x00010000    /* Enable Wake-Up Filter 2                              */
-#define        WF2_T              0x00080000    /* Wake-Up Filter 2 Addr Type (Multicast/Unicast*)      */
-#define        WF3_E              0x01000000    /* Enable Wake-Up Filter 3                              */
-#define        WF3_T              0x08000000    /* Wake-Up Filter 3 Addr Type (Multicast/Unicast*)      */
-
-/* EMAC_WKUP_FFOFF Masks */
-
-#define        WF0_OFF            0x000000FF    /* Wake-Up Filter 0 Pattern Offset                      */
-#define        WF1_OFF            0x0000FF00    /* Wake-Up Filter 1 Pattern Offset                      */
-#define        WF2_OFF            0x00FF0000    /* Wake-Up Filter 2 Pattern Offset                      */
-#define        WF3_OFF            0xFF000000    /* Wake-Up Filter 3 Pattern Offset                      */
-
-#define        SET_WF0_OFF(x) (((x)&0xFF)<<  0 ) /* Set Wake-Up Filter 0 Byte Offset                    */
-#define        SET_WF1_OFF(x) (((x)&0xFF)<<  8 ) /* Set Wake-Up Filter 1 Byte Offset                    */
-#define        SET_WF2_OFF(x) (((x)&0xFF)<< 16 ) /* Set Wake-Up Filter 2 Byte Offset                    */
-#define        SET_WF3_OFF(x) (((x)&0xFF)<< 24 ) /* Set Wake-Up Filter 3 Byte Offset                    */
-/* Set ALL Offsets */
-#define        SET_WF_OFFS(x0,x1,x2,x3) (SET_WF0_OFF((x0))|SET_WF1_OFF((x1))|SET_WF2_OFF((x2))|SET_WF3_OFF((x3)))
-
-/* EMAC_WKUP_FFCRC0 Masks */
-
-#define        WF0_CRC           0x0000FFFF    /* Wake-Up Filter 0 Pattern CRC                           */
-#define        WF1_CRC           0xFFFF0000    /* Wake-Up Filter 1 Pattern CRC                           */
-
-#define        SET_WF0_CRC(x) (((x)&0xFFFF)<<   0 ) /* Set Wake-Up Filter 0 Target CRC                   */
-#define        SET_WF1_CRC(x) (((x)&0xFFFF)<<  16 ) /* Set Wake-Up Filter 1 Target CRC                   */
-
-/* EMAC_WKUP_FFCRC1 Masks */
-
-#define        WF2_CRC           0x0000FFFF    /* Wake-Up Filter 2 Pattern CRC                           */
-#define        WF3_CRC           0xFFFF0000    /* Wake-Up Filter 3 Pattern CRC                           */
-
-#define        SET_WF2_CRC(x) (((x)&0xFFFF)<<   0 ) /* Set Wake-Up Filter 2 Target CRC                   */
-#define        SET_WF3_CRC(x) (((x)&0xFFFF)<<  16 ) /* Set Wake-Up Filter 3 Target CRC                   */
-
-/* EMAC_SYSCTL Masks */
-
-#define        PHYIE             0x00000001    /* PHY_INT Interrupt Enable                               */
-#define        RXDWA             0x00000002    /* Receive Frame DMA Word Alignment (Odd/Even*)           */
-#define        RXCKS             0x00000004    /* Enable RX Frame TCP/UDP Checksum Computation           */
-#define        TXDWA             0x00000010    /* Transmit Frame DMA Word Alignment (Odd/Even*)          */
-#define        MDCDIV            0x00003F00    /* SCLK:MDC Clock Divisor [MDC=SCLK/(2*(N+1))]            */
-
-#define        SET_MDCDIV(x) (((x)&0x3F)<< 8)   /* Set MDC Clock Divisor                                 */
-
-/* EMAC_SYSTAT Masks */
-
-#define        PHYINT            0x00000001    /* PHY_INT Interrupt Status                               */
-#define        MMCINT            0x00000002    /* MMC Counter Interrupt Status                           */
-#define        RXFSINT           0x00000004    /* RX Frame-Status Interrupt Status                       */
-#define        TXFSINT           0x00000008    /* TX Frame-Status Interrupt Status                       */
-#define        WAKEDET           0x00000010    /* Wake-Up Detected Status                                */
-#define        RXDMAERR          0x00000020    /* RX DMA Direction Error Status                          */
-#define        TXDMAERR          0x00000040    /* TX DMA Direction Error Status                          */
-#define        STMDONE           0x00000080    /* Station Mgt. Transfer Done Interrupt Status            */
-
-/* EMAC_RX_STAT, EMAC_RX_STKY, and EMAC_RX_IRQE Masks */
-
-#define        RX_FRLEN          0x000007FF    /* Frame Length In Bytes                                  */
-#define        RX_COMP           0x00001000    /* RX Frame Complete                                      */
-#define        RX_OK             0x00002000    /* RX Frame Received With No Errors                       */
-#define        RX_LONG           0x00004000    /* RX Frame Too Long Error                                */
-#define        RX_ALIGN          0x00008000    /* RX Frame Alignment Error                               */
-#define        RX_CRC            0x00010000    /* RX Frame CRC Error                                     */
-#define        RX_LEN            0x00020000    /* RX Frame Length Error                                  */
-#define        RX_FRAG           0x00040000    /* RX Frame Fragment Error                                */
-#define        RX_ADDR           0x00080000    /* RX Frame Address Filter Failed Error                   */
-#define        RX_DMAO           0x00100000    /* RX Frame DMA Overrun Error                             */
-#define        RX_PHY            0x00200000    /* RX Frame PHY Error                                     */
-#define        RX_LATE           0x00400000    /* RX Frame Late Collision Error                          */
-#define        RX_RANGE          0x00800000    /* RX Frame Length Field Out of Range Error               */
-#define        RX_MULTI          0x01000000    /* RX Multicast Frame Indicator                           */
-#define        RX_BROAD          0x02000000    /* RX Broadcast Frame Indicator                           */
-#define        RX_CTL            0x04000000    /* RX Control Frame Indicator                             */
-#define        RX_UCTL           0x08000000    /* Unsupported RX Control Frame Indicator                 */
-#define        RX_TYPE           0x10000000    /* RX Typed Frame Indicator                               */
-#define        RX_VLAN1          0x20000000    /* RX VLAN1 Frame Indicator                               */
-#define        RX_VLAN2          0x40000000    /* RX VLAN2 Frame Indicator                               */
-#define        RX_ACCEPT         0x80000000    /* RX Frame Accepted Indicator                            */
-
-/*  EMAC_TX_STAT, EMAC_TX_STKY, and EMAC_TX_IRQE Masks  */
-
-#define        TX_COMP           0x00000001    /* TX Frame Complete                                      */
-#define        TX_OK             0x00000002    /* TX Frame Sent With No Errors                           */
-#define        TX_ECOLL          0x00000004    /* TX Frame Excessive Collision Error                     */
-#define        TX_LATE           0x00000008    /* TX Frame Late Collision Error                          */
-#define        TX_DMAU           0x00000010    /* TX Frame DMA Underrun Error (STAT)                     */
-#define        TX_MACE           0x00000010    /* Internal MAC Error Detected (STKY and IRQE)            */
-#define        TX_EDEFER         0x00000020    /* TX Frame Excessive Deferral Error                      */
-#define        TX_BROAD          0x00000040    /* TX Broadcast Frame Indicator                           */
-#define        TX_MULTI          0x00000080    /* TX Multicast Frame Indicator                           */
-#define        TX_CCNT           0x00000F00    /* TX Frame Collision Count                               */
-#define        TX_DEFER          0x00001000    /* TX Frame Deferred Indicator                            */
-#define        TX_CRS            0x00002000    /* TX Frame Carrier Sense Not Asserted Error              */
-#define        TX_LOSS           0x00004000    /* TX Frame Carrier Lost During TX Error                  */
-#define        TX_RETRY          0x00008000    /* TX Frame Successful After Retry                        */
-#define        TX_FRLEN          0x07FF0000    /* TX Frame Length (Bytes)                                */
-
-/* EMAC_MMC_CTL Masks */
-#define        RSTC              0x00000001    /* Reset All Counters                                     */
-#define        CROLL             0x00000002    /* Counter Roll-Over Enable                               */
-#define        CCOR              0x00000004    /* Counter Clear-On-Read Mode Enable                      */
-#define        MMCE              0x00000008    /* Enable MMC Counter Operation                           */
-
-/* EMAC_MMC_RIRQS and EMAC_MMC_RIRQE Masks */
-#define        RX_OK_CNT         0x00000001    /* RX Frames Received With No Errors                      */
-#define        RX_FCS_CNT        0x00000002    /* RX Frames W/Frame Check Sequence Errors                */
-#define        RX_ALIGN_CNT      0x00000004    /* RX Frames With Alignment Errors                        */
-#define        RX_OCTET_CNT      0x00000008    /* RX Octets Received OK                                  */
-#define        RX_LOST_CNT       0x00000010    /* RX Frames Lost Due To Internal MAC RX Error            */
-#define        RX_UNI_CNT        0x00000020    /* Unicast RX Frames Received OK                          */
-#define        RX_MULTI_CNT      0x00000040    /* Multicast RX Frames Received OK                        */
-#define        RX_BROAD_CNT      0x00000080    /* Broadcast RX Frames Received OK                        */
-#define        RX_IRL_CNT        0x00000100    /* RX Frames With In-Range Length Errors                  */
-#define        RX_ORL_CNT        0x00000200    /* RX Frames With Out-Of-Range Length Errors              */
-#define        RX_LONG_CNT       0x00000400    /* RX Frames With Frame Too Long Errors                   */
-#define        RX_MACCTL_CNT     0x00000800    /* MAC Control RX Frames Received                         */
-#define        RX_OPCODE_CTL     0x00001000    /* Unsupported Op-Code RX Frames Received                 */
-#define        RX_PAUSE_CNT      0x00002000    /* PAUSEMAC Control RX Frames Received                    */
-#define        RX_ALLF_CNT       0x00004000    /* All RX Frames Received                                 */
-#define        RX_ALLO_CNT       0x00008000    /* All RX Octets Received                                 */
-#define        RX_TYPED_CNT      0x00010000    /* Typed RX Frames Received                               */
-#define        RX_SHORT_CNT      0x00020000    /* RX Frame Fragments (< 64 Bytes) Received               */
-#define        RX_EQ64_CNT       0x00040000    /* 64-Byte RX Frames Received                             */
-#define        RX_LT128_CNT      0x00080000    /* 65-127-Byte RX Frames Received                         */
-#define        RX_LT256_CNT      0x00100000    /* 128-255-Byte RX Frames Received                        */
-#define        RX_LT512_CNT      0x00200000    /* 256-511-Byte RX Frames Received                        */
-#define        RX_LT1024_CNT     0x00400000    /* 512-1023-Byte RX Frames Received                       */
-#define        RX_GE1024_CNT     0x00800000    /* 1024-Max-Byte RX Frames Received                       */
-
-/* EMAC_MMC_TIRQS and EMAC_MMC_TIRQE Masks  */
-
-#define        TX_OK_CNT         0x00000001    /* TX Frames Sent OK                                      */
-#define        TX_SCOLL_CNT      0x00000002    /* TX Frames With Single Collisions                       */
-#define        TX_MCOLL_CNT      0x00000004    /* TX Frames With Multiple Collisions                     */
-#define        TX_OCTET_CNT      0x00000008    /* TX Octets Sent OK                                      */
-#define        TX_DEFER_CNT      0x00000010    /* TX Frames With Deferred Transmission                   */
-#define        TX_LATE_CNT       0x00000020    /* TX Frames With Late Collisions                         */
-#define        TX_ABORTC_CNT     0x00000040    /* TX Frames Aborted Due To Excess Collisions             */
-#define        TX_LOST_CNT       0x00000080    /* TX Frames Lost Due To Internal MAC TX Error            */
-#define        TX_CRS_CNT        0x00000100    /* TX Frames With Carrier Sense Errors                    */
-#define        TX_UNI_CNT        0x00000200    /* Unicast TX Frames Sent                                 */
-#define        TX_MULTI_CNT      0x00000400    /* Multicast TX Frames Sent                               */
-#define        TX_BROAD_CNT      0x00000800    /* Broadcast TX Frames Sent                               */
-#define        TX_EXDEF_CTL      0x00001000    /* TX Frames With Excessive Deferral                      */
-#define        TX_MACCTL_CNT     0x00002000    /* MAC Control TX Frames Sent                             */
-#define        TX_ALLF_CNT       0x00004000    /* All TX Frames Sent                                     */
-#define        TX_ALLO_CNT       0x00008000    /* All TX Octets Sent                                     */
-#define        TX_EQ64_CNT       0x00010000    /* 64-Byte TX Frames Sent                                 */
-#define        TX_LT128_CNT      0x00020000    /* 65-127-Byte TX Frames Sent                             */
-#define        TX_LT256_CNT      0x00040000    /* 128-255-Byte TX Frames Sent                            */
-#define        TX_LT512_CNT      0x00080000    /* 256-511-Byte TX Frames Sent                            */
-#define        TX_LT1024_CNT     0x00100000    /* 512-1023-Byte TX Frames Sent                           */
-#define        TX_GE1024_CNT     0x00200000    /* 1024-Max-Byte TX Frames Sent                           */
-#define        TX_ABORT_CNT      0x00400000    /* TX Frames Aborted                                      */
-
-/* SDH Registers */
-
-#define SDH_PWR_CTL                    0xFFC03900 /* SDH Power Control */
-#define SDH_CLK_CTL                    0xFFC03904 /* SDH Clock Control */
-#define SDH_ARGUMENT                   0xFFC03908 /* SDH Argument */
-#define SDH_COMMAND                    0xFFC0390C /* SDH Command */
-#define SDH_RESP_CMD                   0xFFC03910 /* SDH Response Command */
-#define SDH_RESPONSE0                  0xFFC03914 /* SDH Response0 */
-#define SDH_RESPONSE1                  0xFFC03918 /* SDH Response1 */
-#define SDH_RESPONSE2                  0xFFC0391C /* SDH Response2 */
-#define SDH_RESPONSE3                  0xFFC03920 /* SDH Response3 */
-#define SDH_DATA_TIMER                 0xFFC03924 /* SDH Data Timer */
-#define SDH_DATA_LGTH                  0xFFC03928 /* SDH Data Length */
-#define SDH_DATA_CTL                   0xFFC0392C /* SDH Data Control */
-#define SDH_DATA_CNT                   0xFFC03930 /* SDH Data Counter */
-#define SDH_STATUS                     0xFFC03934 /* SDH Status */
-#define SDH_STATUS_CLR                 0xFFC03938 /* SDH Status Clear */
-#define SDH_MASK0                      0xFFC0393C /* SDH Interrupt0 Mask */
-#define SDH_MASK1                      0xFFC03940 /* SDH Interrupt1 Mask */
-#define SDH_FIFO_CNT                   0xFFC03948 /* SDH FIFO Counter */
-#define SDH_FIFO                       0xFFC03980 /* SDH Data FIFO */
-#define SDH_E_STATUS                   0xFFC039C0 /* SDH Exception Status */
-#define SDH_E_MASK                     0xFFC039C4 /* SDH Exception Mask */
-#define SDH_CFG                        0xFFC039C8 /* SDH Configuration */
-#define SDH_RD_WAIT_EN                 0xFFC039CC /* SDH Read Wait Enable */
-#define SDH_PID0                       0xFFC039D0 /* SDH Peripheral Identification0 */
-#define SDH_PID1                       0xFFC039D4 /* SDH Peripheral Identification1 */
-#define SDH_PID2                       0xFFC039D8 /* SDH Peripheral Identification2 */
-#define SDH_PID3                       0xFFC039DC /* SDH Peripheral Identification3 */
-#define SDH_PID4                       0xFFC039E0 /* SDH Peripheral Identification4 */
-#define SDH_PID5                       0xFFC039E4 /* SDH Peripheral Identification5 */
-#define SDH_PID6                       0xFFC039E8 /* SDH Peripheral Identification6 */
-#define SDH_PID7                       0xFFC039EC /* SDH Peripheral Identification7 */
-
-/* Removable Storage Interface Registers */
-
-#define RSI_PWR_CONTROL                0xFFC03800 /* RSI Power Control Register */
-#define RSI_CLK_CONTROL                0xFFC03804 /* RSI Clock Control Register */
-#define RSI_ARGUMENT                   0xFFC03808 /* RSI Argument Register */
-#define RSI_COMMAND                    0xFFC0380C /* RSI Command Register */
-#define RSI_RESP_CMD                   0xFFC03810 /* RSI Response Command Register */
-#define RSI_RESPONSE0                  0xFFC03814 /* RSI Response Register */
-#define RSI_RESPONSE1                  0xFFC03818 /* RSI Response Register */
-#define RSI_RESPONSE2                  0xFFC0381C /* RSI Response Register */
-#define RSI_RESPONSE3                  0xFFC03820 /* RSI Response Register */
-#define RSI_DATA_TIMER                 0xFFC03824 /* RSI Data Timer Register */
-#define RSI_DATA_LGTH                  0xFFC03828 /* RSI Data Length Register */
-#define RSI_DATA_CONTROL               0xFFC0382C /* RSI Data Control Register */
-#define RSI_DATA_CNT                   0xFFC03830 /* RSI Data Counter Register */
-#define RSI_STATUS                     0xFFC03834 /* RSI Status Register */
-#define RSI_STATUSCL                   0xFFC03838 /* RSI Status Clear Register */
-#define RSI_MASK0                      0xFFC0383C /* RSI Interrupt 0 Mask Register */
-#define RSI_MASK1                      0xFFC03840 /* RSI Interrupt 1 Mask Register */
-#define RSI_FIFO_CNT                   0xFFC03848 /* RSI FIFO Counter Register */
-#define RSI_CEATA_CONTROL              0xFFC0384C /* RSI CEATA Register */
-#define RSI_FIFO                       0xFFC03880 /* RSI Data FIFO Register */
-#define RSI_ESTAT                      0xFFC038C0 /* RSI Exception Status Register */
-#define RSI_EMASK                      0xFFC038C4 /* RSI Exception Mask Register */
-#define RSI_CONFIG                     0xFFC038C8 /* RSI Configuration Register */
-#define RSI_RD_WAIT_EN                 0xFFC038CC /* RSI Read Wait Enable Register */
-#define RSI_PID0                       0xFFC03FE0 /* RSI Peripheral ID Register 0 */
-#define RSI_PID1                       0xFFC03FE4 /* RSI Peripheral ID Register 1 */
-#define RSI_PID2                       0xFFC03FE8 /* RSI Peripheral ID Register 2 */
-#define RSI_PID3                       0xFFC03FEC /* RSI Peripheral ID Register 3 */
-#define RSI_PID4                       0xFFC03FF0 /* RSI Peripheral ID Register 4 */
-#define RSI_PID5                       0xFFC03FF4 /* RSI Peripheral ID Register 5 */
-#define RSI_PID6                       0xFFC03FF8 /* RSI Peripheral ID Register 6 */
-#define RSI_PID7                       0xFFC03FFC /* RSI Peripheral ID Register 7 */
+/* BF518 is BF516 + IEEE-1588 */
+#include "defBF516.h"
 
 /* PTP TSYNC Registers */
 
 #define EMAC_PTP_PPS_STARTHI           0xFFC030F4 /* PPS Start Time High */
 #define EMAC_PTP_PPS_PERIOD            0xFFC030F8 /* PPS Count Register */
 
-/* ********************************************************** */
-/*     SINGLE BIT MACRO PAIRS (bit mask and negated one)      */
-/*     and MULTI BIT READ MACROS                              */
-/* ********************************************************** */
-
-/* Bit masks for SDH_COMMAND */
-
-#define                   CMD_IDX  0x3f       /* Command Index */
-#define                   CMD_RSP  0x40       /* Response */
-#define                 CMD_L_RSP  0x80       /* Long Response */
-#define                 CMD_INT_E  0x100      /* Command Interrupt */
-#define                CMD_PEND_E  0x200      /* Command Pending */
-#define                     CMD_E  0x400      /* Command Enable */
-
-/* Bit masks for SDH_PWR_CTL */
-
-#define                    PWR_ON  0x3        /* Power On */
-#if 0
-#define                       TBD  0x3c       /* TBD */
-#endif
-#define                 SD_CMD_OD  0x40       /* Open Drain Output */
-#define                   ROD_CTL  0x80       /* Rod Control */
-
-/* Bit masks for SDH_CLK_CTL */
-
-#define                    CLKDIV  0xff       /* MC_CLK Divisor */
-#define                     CLK_E  0x100      /* MC_CLK Bus Clock Enable */
-#define                  PWR_SV_E  0x200      /* Power Save Enable */
-#define             CLKDIV_BYPASS  0x400      /* Bypass Divisor */
-#define                  WIDE_BUS  0x800      /* Wide Bus Mode Enable */
-
-/* Bit masks for SDH_RESP_CMD */
-
-#define                  RESP_CMD  0x3f       /* Response Command */
-
-/* Bit masks for SDH_DATA_CTL */
-
-#define                     DTX_E  0x1        /* Data Transfer Enable */
-#define                   DTX_DIR  0x2        /* Data Transfer Direction */
-#define                  DTX_MODE  0x4        /* Data Transfer Mode */
-#define                 DTX_DMA_E  0x8        /* Data Transfer DMA Enable */
-#define              DTX_BLK_LGTH  0xf0       /* Data Transfer Block Length */
-
-/* Bit masks for SDH_STATUS */
-
-#define              CMD_CRC_FAIL  0x1        /* CMD CRC Fail */
-#define              DAT_CRC_FAIL  0x2        /* Data CRC Fail */
-#define               CMD_TIME_OUT  0x4        /* CMD Time Out */
-#define               DAT_TIME_OUT  0x8        /* Data Time Out */
-#define               TX_UNDERRUN  0x10       /* Transmit Underrun */
-#define                RX_OVERRUN  0x20       /* Receive Overrun */
-#define              CMD_RESP_END  0x40       /* CMD Response End */
-#define                  CMD_SENT  0x80       /* CMD Sent */
-#define                   DAT_END  0x100      /* Data End */
-#define             START_BIT_ERR  0x200      /* Start Bit Error */
-#define               DAT_BLK_END  0x400      /* Data Block End */
-#define                   CMD_ACT  0x800      /* CMD Active */
-#define                    TX_ACT  0x1000     /* Transmit Active */
-#define                    RX_ACT  0x2000     /* Receive Active */
-#define              TX_FIFO_STAT  0x4000     /* Transmit FIFO Status */
-#define              RX_FIFO_STAT  0x8000     /* Receive FIFO Status */
-#define              TX_FIFO_FULL  0x10000    /* Transmit FIFO Full */
-#define              RX_FIFO_FULL  0x20000    /* Receive FIFO Full */
-#define              TX_FIFO_ZERO  0x40000    /* Transmit FIFO Empty */
-#define               RX_DAT_ZERO  0x80000    /* Receive FIFO Empty */
-#define                TX_DAT_RDY  0x100000   /* Transmit Data Available */
-#define               RX_FIFO_RDY  0x200000   /* Receive Data Available */
-
-/* Bit masks for SDH_STATUS_CLR */
-
-#define         CMD_CRC_FAIL_STAT  0x1        /* CMD CRC Fail Status */
-#define         DAT_CRC_FAIL_STAT  0x2        /* Data CRC Fail Status */
-#define          CMD_TIMEOUT_STAT  0x4        /* CMD Time Out Status */
-#define          DAT_TIMEOUT_STAT  0x8        /* Data Time Out status */
-#define          TX_UNDERRUN_STAT  0x10       /* Transmit Underrun Status */
-#define           RX_OVERRUN_STAT  0x20       /* Receive Overrun Status */
-#define         CMD_RESP_END_STAT  0x40       /* CMD Response End Status */
-#define             CMD_SENT_STAT  0x80       /* CMD Sent Status */
-#define              DAT_END_STAT  0x100      /* Data End Status */
-#define        START_BIT_ERR_STAT  0x200      /* Start Bit Error Status */
-#define          DAT_BLK_END_STAT  0x400      /* Data Block End Status */
-
-/* Bit masks for SDH_MASK0 */
-
-#define         CMD_CRC_FAIL_MASK  0x1        /* CMD CRC Fail Mask */
-#define         DAT_CRC_FAIL_MASK  0x2        /* Data CRC Fail Mask */
-#define          CMD_TIMEOUT_MASK  0x4        /* CMD Time Out Mask */
-#define          DAT_TIMEOUT_MASK  0x8        /* Data Time Out Mask */
-#define          TX_UNDERRUN_MASK  0x10       /* Transmit Underrun Mask */
-#define           RX_OVERRUN_MASK  0x20       /* Receive Overrun Mask */
-#define         CMD_RESP_END_MASK  0x40       /* CMD Response End Mask */
-#define             CMD_SENT_MASK  0x80       /* CMD Sent Mask */
-#define              DAT_END_MASK  0x100      /* Data End Mask */
-#define        START_BIT_ERR_MASK  0x200      /* Start Bit Error Mask */
-#define          DAT_BLK_END_MASK  0x400      /* Data Block End Mask */
-#define              CMD_ACT_MASK  0x800      /* CMD Active Mask */
-#define               TX_ACT_MASK  0x1000     /* Transmit Active Mask */
-#define               RX_ACT_MASK  0x2000     /* Receive Active Mask */
-#define         TX_FIFO_STAT_MASK  0x4000     /* Transmit FIFO Status Mask */
-#define         RX_FIFO_STAT_MASK  0x8000     /* Receive FIFO Status Mask */
-#define         TX_FIFO_FULL_MASK  0x10000    /* Transmit FIFO Full Mask */
-#define         RX_FIFO_FULL_MASK  0x20000    /* Receive FIFO Full Mask */
-#define         TX_FIFO_ZERO_MASK  0x40000    /* Transmit FIFO Empty Mask */
-#define          RX_DAT_ZERO_MASK  0x80000    /* Receive FIFO Empty Mask */
-#define           TX_DAT_RDY_MASK  0x100000   /* Transmit Data Available Mask */
-#define          RX_FIFO_RDY_MASK  0x200000   /* Receive Data Available Mask */
-
-/* Bit masks for SDH_FIFO_CNT */
-
-#define                FIFO_COUNT  0x7fff     /* FIFO Count */
-
-/* Bit masks for SDH_E_STATUS */
-
-#define              SDIO_INT_DET  0x2        /* SDIO Int Detected */
-#define               SD_CARD_DET  0x10       /* SD Card Detect */
-
-/* Bit masks for SDH_E_MASK */
-
-#define                  SDIO_MSK  0x2        /* Mask SDIO Int Detected */
-#define                   SCD_MSK  0x40       /* Mask Card Detect */
-
-/* Bit masks for SDH_CFG */
-
-#define                   CLKS_EN  0x1        /* Clocks Enable */
-#define                      SD4E  0x4        /* SDIO 4-Bit Enable */
-#define                       MWE  0x8        /* Moving Window Enable */
-#define                    SD_RST  0x10       /* SDMMC Reset */
-#define                 PUP_SDDAT  0x20       /* Pull-up SD_DAT */
-#define                PUP_SDDAT3  0x40       /* Pull-up SD_DAT3 */
-#define                 PD_SDDAT3  0x80       /* Pull-down SD_DAT3 */
-
-/* Bit masks for SDH_RD_WAIT_EN */
-
-#define                       RWR  0x1        /* Read Wait Request */
-
 /* Bit masks for EMAC_PTP_CTL */
 
 #define                    PTP_EN  0x1        /* Enable the PTP_TSYNC module */
index f9fd2b2a295649aa80816909c407867f2c3c6a26..9241205fb9928a501c06f2d51aa7ebbaecb28f89 100644 (file)
 **                             modifier UNLESS the lower order bits are saved and ORed back in when
 **                             the macro is used.
 *************************************************************************************/
-/*
-** ********************* PLL AND RESET MASKS ****************************************/
-/* PLL_CTL Masks                                                                                                                                       */
-#define DF                             0x0001  /* 0: PLL = CLKIN, 1: PLL = CLKIN/2                                     */
-#define PLL_OFF                        0x0002  /* PLL Not Powered                                                                      */
-#define STOPCK                 0x0008  /* Core Clock Off                                                                       */
-#define PDWN                   0x0020  /* Enter Deep Sleep Mode                                                        */
-#define        IN_DELAY                0x0040  /* Add 200ps Delay To EBIU Input Latches                        */
-#define        OUT_DELAY               0x0080  /* Add 200ps Delay To EBIU Output Signals                       */
-#define BYPASS                 0x0100  /* Bypass the PLL                                                                       */
-#define        MSEL                    0x7E00  /* Multiplier Select For CCLK/VCO Factors                       */
-/* PLL_CTL Macros (Only Use With Logic OR While Setting Lower Order Bits)                      */
-#define        SET_MSEL(x)             (((x)&0x3F) << 0x9)     /* Set MSEL = 0-63 --> VCO = CLKIN*MSEL         */
-
-/* PLL_DIV Masks                                                                                                               */
-#define SSEL                   0x000F  /* System Select                                                */
-#define        CSEL                    0x0030  /* Core Select                                                  */
-#define CSEL_DIV1              0x0000  /*              CCLK = VCO / 1                                  */
-#define CSEL_DIV2              0x0010  /*              CCLK = VCO / 2                                  */
-#define        CSEL_DIV4               0x0020  /*              CCLK = VCO / 4                                  */
-#define        CSEL_DIV8               0x0030  /*              CCLK = VCO / 8                                  */
-/* PLL_DIV Macros                                                                                                              */
-#define SET_SSEL(x)            ((x)&0xF)               /* Set SSEL = 0-15 --> SCLK = VCO/SSEL  */
-
-/* VR_CTL Masks        */
-#define        FREQ                    0x3000  /* Switching Oscillator Frequency For Regulator */
-#define        HIBERNATE               0x0000  /*              Powerdown/Bypass On-Board Regulation    */
-
-#define        VLEV                    0x00F0  /* Internal Voltage Level                                       */
-#define        VLEV_085                0x0060  /*              VLEV = 0.85 V (-5% - +10% Accuracy)     */
-#define        VLEV_090                0x0070  /*              VLEV = 0.90 V (-5% - +10% Accuracy)     */
-#define        VLEV_095                0x0080  /*              VLEV = 0.95 V (-5% - +10% Accuracy)     */
-#define        VLEV_100                0x0090  /*              VLEV = 1.00 V (-5% - +10% Accuracy)     */
-#define        VLEV_105                0x00A0  /*              VLEV = 1.05 V (-5% - +10% Accuracy)     */
-#define        VLEV_110                0x00B0  /*              VLEV = 1.10 V (-5% - +10% Accuracy)     */
-#define        VLEV_115                0x00C0  /*              VLEV = 1.15 V (-5% - +10% Accuracy)     */
-#define        VLEV_120                0x00D0  /*              VLEV = 1.20 V (-5% - +10% Accuracy)     */
-#define        VLEV_125                0x00E0  /*              VLEV = 1.25 V (-5% - +10% Accuracy)     */
-#define        VLEV_130                0x00F0  /*              VLEV = 1.30 V (-5% - +10% Accuracy)     */
-
-#define        WAKE                    0x0100  /* Enable RTC/Reset Wakeup From Hibernate       */
-#define        USBWE                   0x0200  /* Enable USB Wakeup From Hibernate                     */
-#define        PHYWE                   0x0400  /* Enable PHY Wakeup From Hibernate                     */
-#define        CLKBUFOE                0x4000  /* CLKIN Buffer Output Enable */
-#define        PHYCLKOE                CLKBUFOE        /* Alternative legacy name for the above */
-#define        SCKELOW         0x8000  /* Enable Drive CKE Low During Reset            */
-
-/* PLL_STAT Masks                                                                                                                                      */
-#define ACTIVE_PLLENABLED      0x0001  /* Processor In Active Mode With PLL Enabled    */
-#define        FULL_ON                         0x0002  /* Processor In Full On Mode                                    */
-#define ACTIVE_PLLDISABLED     0x0004  /* Processor In Active Mode With PLL Disabled   */
-#define        PLL_LOCKED                      0x0020  /* PLL_LOCKCNT Has Been Reached                                 */
 
 /* CHIPID Masks */
 #define CHIPID_VERSION         0xF0000000
 #define IWR_DISABLE(x) (0xFFFFFFFF ^ (1 << ((x)&0x1F)))        /* Wakeup Disable Peripheral #x         */
 
 
-/* ********* WATCHDOG TIMER MASKS ******************** */
-
-/* Watchdog Timer WDOG_CTL Register Masks */
-
-#define WDEV(x) (((x)<<1) & 0x0006) /* event generated on roll over */
-#define WDEV_RESET 0x0000 /* generate reset event on roll over */
-#define WDEV_NMI 0x0002 /* generate NMI event on roll over */
-#define WDEV_GPI 0x0004 /* generate GP IRQ on roll over */
-#define WDEV_NONE 0x0006 /* no event on roll over */
-#define WDEN 0x0FF0 /* enable watchdog */
-#define WDDIS 0x0AD0 /* disable watchdog */
-#define WDRO 0x8000 /* watchdog rolled over latch */
-
-/* depreciated WDOG_CTL Register Masks for legacy code */
-
-
-#define ICTL WDEV
-#define ENABLE_RESET WDEV_RESET
-#define WDOG_RESET WDEV_RESET
-#define ENABLE_NMI WDEV_NMI
-#define WDOG_NMI WDEV_NMI
-#define ENABLE_GPI WDEV_GPI
-#define WDOG_GPI WDEV_GPI
-#define DISABLE_EVT WDEV_NONE
-#define WDOG_NONE WDEV_NONE
-
-#define TMR_EN WDEN
-#define TMR_DIS WDDIS
-#define TRO WDRO
-#define ICTL_P0 0x01
- #define ICTL_P1 0x02
-#define TRO_P 0x0F
-
-
-
-/* ***************  REAL TIME CLOCK MASKS  **************************/
-/* RTC_STAT and RTC_ALARM Masks                                                                                */
-#define        RTC_SEC                         0x0000003F      /* Real-Time Clock Seconds      */
-#define        RTC_MIN                         0x00000FC0      /* Real-Time Clock Minutes      */
-#define        RTC_HR                          0x0001F000      /* Real-Time Clock Hours        */
-#define        RTC_DAY                         0xFFFE0000      /* Real-Time Clock Days         */
-
-/* RTC_ALARM Macro                     z=day           y=hr    x=min   w=sec           */
-#define SET_ALARM(z,y,x,w)     ((((z)&0x7FFF)<<0x11)|(((y)&0x1F)<<0xC)|(((x)&0x3F)<<0x6)|((w)&0x3F))
-
-/* RTC_ICTL and RTC_ISTAT Masks                                                                                                                                                */
-#define        STOPWATCH                       0x0001          /* Stopwatch Interrupt Enable                                                           */
-#define        ALARM                           0x0002          /* Alarm Interrupt Enable                                                                       */
-#define        SECOND                          0x0004          /* Seconds (1 Hz) Interrupt Enable                                                      */
-#define        MINUTE                          0x0008          /* Minutes Interrupt Enable                                                                     */
-#define        HOUR                            0x0010          /* Hours Interrupt Enable                                                                       */
-#define        DAY                                     0x0020          /* 24 Hours (Days) Interrupt Enable                                                     */
-#define        DAY_ALARM                       0x0040          /* Day Alarm (Day, Hour, Minute, Second) Interrupt Enable       */
-#define        WRITE_PENDING           0x4000          /* Write Pending Status                                                                         */
-#define        WRITE_COMPLETE          0x8000          /* Write Complete Interrupt Enable                                                      */
-
-/* RTC_FAST / RTC_PREN Mask                                                                                            */
-#define PREN                           0x0001  /* Enable Prescaler, RTC Runs @1 Hz     */
-
-
 /* ************** UART CONTROLLER MASKS *************************/
 /* UARTx_LCR Masks                                                                                             */
 #define WLS(x)         (((x)-5) & 0x03)        /* Word Length Select */
 
 
 /* **************************  DMA CONTROLLER MASKS  ********************************/
-/* DMAx_CONFIG, MDMA_yy_CONFIG Masks                                                                                           */
-#define DMAEN                  0x0001          /* DMA Channel Enable                                                   */
-#define WNR                            0x0002          /* Channel Direction (W/R*)                                             */
-#define WDSIZE_8               0x0000          /* Transfer Word Size = 8                                               */
-#define WDSIZE_16              0x0004          /* Transfer Word Size = 16                                              */
-#define WDSIZE_32              0x0008          /* Transfer Word Size = 32                                              */
-#define DMA2D                  0x0010          /* DMA Mode (2D/1D*)                                                    */
-#define RESTART                        0x0020          /* DMA Buffer Clear                                                             */
-#define DI_SEL                 0x0040          /* Data Interrupt Timing Select                                 */
-#define DI_EN                  0x0080          /* Data Interrupt Enable                                                */
-#define NDSIZE_0               0x0000          /* Next Descriptor Size = 0 (Stop/Autobuffer)   */
-#define NDSIZE_1               0x0100          /* Next Descriptor Size = 1                                             */
-#define NDSIZE_2               0x0200          /* Next Descriptor Size = 2                                             */
-#define NDSIZE_3               0x0300          /* Next Descriptor Size = 3                                             */
-#define NDSIZE_4               0x0400          /* Next Descriptor Size = 4                                             */
-#define NDSIZE_5               0x0500          /* Next Descriptor Size = 5                                             */
-#define NDSIZE_6               0x0600          /* Next Descriptor Size = 6                                             */
-#define NDSIZE_7               0x0700          /* Next Descriptor Size = 7                                             */
-#define NDSIZE_8               0x0800          /* Next Descriptor Size = 8                                             */
-#define NDSIZE_9               0x0900          /* Next Descriptor Size = 9                                             */
-#define NDSIZE                 0x0900  /* Next Descriptor Size */
-#define DMAFLOW                        0x7000  /* Flow Control */
-#define DMAFLOW_STOP           0x0000          /* Stop Mode                                                                    */
-#define DMAFLOW_AUTO           0x1000          /* Autobuffer Mode                                                              */
-#define DMAFLOW_ARRAY          0x4000          /* Descriptor Array Mode                                                */
-#define DMAFLOW_SMALL          0x6000          /* Small Model Descriptor List Mode                             */
-#define DMAFLOW_LARGE          0x7000          /* Large Model Descriptor List Mode                             */
 
 /* DMAx_PERIPHERAL_MAP, MDMA_yy_PERIPHERAL_MAP Masks                                                           */
 #define CTYPE                  0x0040  /* DMA Channel Type Indicator (Memory/Peripheral*)      */
 #define        PMAP_UART1RX    0xA000  /*              UART1 Port Receive DMA                                          */
 #define        PMAP_UART1TX    0xB000  /*              UART1 Port Transmit DMA                                         */
 
-/* DMAx_IRQ_STATUS, MDMA_yy_IRQ_STATUS Masks                                           */
-#define DMA_DONE               0x0001  /* DMA Completion Interrupt Status      */
-#define DMA_ERR                        0x0002  /* DMA Error Interrupt Status           */
-#define DFETCH                 0x0004  /* DMA Descriptor Fetch Indicator       */
-#define DMA_RUN                        0x0008  /* DMA Channel Running Indicator        */
-
-
 /*  ************  PARALLEL PERIPHERAL INTERFACE (PPI) MASKS *************/
 /*  PPI_CONTROL Masks                                                                                                  */
 #define PORT_EN                        0x0001          /* PPI Port Enable                                      */
 #define BNDMODE_CAPT     0x2000  /* boundary capture mode */
 #define BNDMODE_AEXT     0x3000  /* boundary auto-extend mode */
 
-/* Bit masks for OTP_CONTROL */
-
-#define                FUSE_FADDR  0x1ff      /* OTP/Fuse Address */
-#define                      FIEN  0x800      /* OTP/Fuse Interrupt Enable */
-#define                     nFIEN  0x0
-#define                  FTESTDEC  0x1000     /* OTP/Fuse Test Decoder */
-#define                 nFTESTDEC  0x0
-#define                   FWRTEST  0x2000     /* OTP/Fuse Write Test */
-#define                  nFWRTEST  0x0
-#define                     FRDEN  0x4000     /* OTP/Fuse Read Enable */
-#define                    nFRDEN  0x0
-#define                     FWREN  0x8000     /* OTP/Fuse Write Enable */
-#define                    nFWREN  0x0
-
-/* Bit masks for OTP_BEN */
-
-#define                      FBEN  0xffff     /* OTP/Fuse Byte Enable */
-
-/* Bit masks for OTP_STATUS */
-
-#define                     FCOMP  0x1        /* OTP/Fuse Access Complete */
-#define                    nFCOMP  0x0
-#define                    FERROR  0x2        /* OTP/Fuse Access Error */
-#define                   nFERROR  0x0
-#define                  MMRGLOAD  0x10       /* Memory Mapped Register Gasket Load */
-#define                 nMMRGLOAD  0x0
-#define                  MMRGLOCK  0x20       /* Memory Mapped Register Gasket Lock */
-#define                 nMMRGLOCK  0x0
-#define                    FPGMEN  0x40       /* OTP/Fuse Program Enable */
-#define                   nFPGMEN  0x0
-
-/* Bit masks for OTP_TIMING */
-
-#define                   USECDIV  0xff       /* Micro Second Divider */
-#define                   READACC  0x7f00     /* Read Access Time */
-#define                   CPUMPRL  0x38000    /* Charge Pump Release Time */
-#define                   CPUMPSU  0xc0000    /* Charge Pump Setup Time */
-#define                   CPUMPHD  0xf00000   /* Charge Pump Hold Time */
-#define                   PGMTIME  0xff000000 /* Program Time */
-
 /* Bit masks for SECURE_SYSSWT */
 
 #define                   EMUDABL  0x1        /* Emulation Disable. */
index 848ac6f868231d42044209a71c48a46c806d96e0..1f8cbe9d6b9ad22b190b233c961f78d067c1272a 100644 (file)
@@ -1,3 +1,7 @@
+config BF52x
+       def_bool y
+       depends on (BF522 || BF523 || BF524 || BF525 || BF526 || BF527)
+
 if (BF52x)
 
 source "arch/blackfin/mach-bf527/boards/Kconfig"
index f1996b13a3daf1844b598a6b45cb8b7c3c1e8c10..7ab0800e291427ddbfae33468a703f0b9b838a61 100644 (file)
@@ -15,9 +15,6 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 #include <linux/etherdevice.h>
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-#include <linux/usb/isp1362.h>
-#endif
 #include <linux/i2c.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
@@ -65,7 +62,7 @@ static struct isp1760_platform_data isp1760_priv = {
 };
 
 static struct platform_device bfin_isp1760_device = {
-       .name           = "isp1760-hcd",
+       .name           = "isp1760",
        .id             = 0,
        .dev = {
                .platform_data = &isp1760_priv,
@@ -317,45 +314,6 @@ static struct platform_device sl811_hcd_device = {
 };
 #endif
 
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-static struct resource isp1362_hcd_resources[] = {
-       {
-               .start = 0x20360000,
-               .end = 0x20360000,
-               .flags = IORESOURCE_MEM,
-       }, {
-               .start = 0x20360004,
-               .end = 0x20360004,
-               .flags = IORESOURCE_MEM,
-       }, {
-               .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
-               .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
-               .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
-       },
-};
-
-static struct isp1362_platform_data isp1362_priv = {
-       .sel15Kres = 1,
-       .clknotstop = 0,
-       .oc_enable = 0,
-       .int_act_high = 0,
-       .int_edge_triggered = 0,
-       .remote_wakeup_connected = 0,
-       .no_power_switching = 1,
-       .power_switching_mode = 0,
-};
-
-static struct platform_device isp1362_hcd_device = {
-       .name = "isp1362-hcd",
-       .id = 0,
-       .dev = {
-               .platform_data = &isp1362_priv,
-       },
-       .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
-       .resource = isp1362_hcd_resources,
-};
-#endif
-
 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
 static struct platform_device bfin_mii_bus = {
        .name = "bfin_mii_bus",
@@ -841,10 +799,6 @@ static struct platform_device *cmbf527_devices[] __initdata = {
        &sl811_hcd_device,
 #endif
 
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-       &isp1362_hcd_device,
-#endif
-
 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
        &bfin_isp1760_device,
 #endif
index f09665f74ba03053d79b53901a9b7249ad4142f3..5294fdd207326fc716d5df787d849c8af33c7557 100644 (file)
@@ -13,9 +13,6 @@
 #include <linux/mtd/physmap.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-#include <linux/usb/isp1362.h>
-#endif
 #include <linux/i2c.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
@@ -63,7 +60,7 @@ static struct isp1760_platform_data isp1760_priv = {
 };
 
 static struct platform_device bfin_isp1760_device = {
-       .name           = "isp1760-hcd",
+       .name           = "isp1760",
        .id             = 0,
        .dev = {
                .platform_data = &isp1760_priv,
@@ -373,45 +370,6 @@ static struct platform_device sl811_hcd_device = {
 };
 #endif
 
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-static struct resource isp1362_hcd_resources[] = {
-       {
-               .start = 0x20360000,
-               .end = 0x20360000,
-               .flags = IORESOURCE_MEM,
-       }, {
-               .start = 0x20360004,
-               .end = 0x20360004,
-               .flags = IORESOURCE_MEM,
-       }, {
-               .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
-               .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
-               .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
-       },
-};
-
-static struct isp1362_platform_data isp1362_priv = {
-       .sel15Kres = 1,
-       .clknotstop = 0,
-       .oc_enable = 0,
-       .int_act_high = 0,
-       .int_edge_triggered = 0,
-       .remote_wakeup_connected = 0,
-       .no_power_switching = 1,
-       .power_switching_mode = 0,
-};
-
-static struct platform_device isp1362_hcd_device = {
-       .name = "isp1362-hcd",
-       .id = 0,
-       .dev = {
-               .platform_data = &isp1362_priv,
-       },
-       .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
-       .resource = isp1362_hcd_resources,
-};
-#endif
-
 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
 static struct platform_device bfin_mii_bus = {
        .name = "bfin_mii_bus",
@@ -688,12 +646,6 @@ static struct platform_device bfin_spi0_device = {
 };
 #endif  /* spi master and devices */
 
-#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
-static struct platform_device bfin_fb_device = {
-       .name = "bf537-lq035",
-};
-#endif
-
 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
 static struct resource bfin_uart_resources[] = {
 #ifdef CONFIG_SERIAL_BFIN_UART0
@@ -850,7 +802,7 @@ static struct platform_device bfin_device_gpiokeys = {
 };
 #endif
 
-#if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
+#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
 #include <linux/input.h>
 #include <asm/bfin_rotary.h>
 
@@ -924,10 +876,6 @@ static struct platform_device *stamp_devices[] __initdata = {
        &sl811_hcd_device,
 #endif
 
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-       &isp1362_hcd_device,
-#endif
-
 #if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
        &bfin_isp1760_device,
 #endif
@@ -957,10 +905,6 @@ static struct platform_device *stamp_devices[] __initdata = {
        &bfin_spi0_device,
 #endif
 
-#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
-       &bfin_fb_device,
-#endif
-
 #if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
        &bf52x_t350mcqb_device,
 #endif
@@ -991,7 +935,7 @@ static struct platform_device *stamp_devices[] __initdata = {
        &bfin_device_gpiokeys,
 #endif
 
-#if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
+#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
        &bfin_rotary_device,
 #endif
 
index e7d6034f268fef5f876b3fb720735e046abe5e16..f714c5de30739d4e01dfe9b23daaeb4fb8a9dc2a 100644 (file)
 #define OFFSET_SCR              0x1C   /* SCR Scratch Register                 */
 #define OFFSET_GCTL             0x24   /* Global Control Register              */
 
-/* PLL_DIV Masks                                                                                                       */
-#define CCLK_DIV1 CSEL_DIV1    /*          CCLK = VCO / 1                                  */
-#define CCLK_DIV2 CSEL_DIV2    /*          CCLK = VCO / 2                                  */
-#define CCLK_DIV4 CSEL_DIV4    /*          CCLK = VCO / 4                                  */
-#define CCLK_DIV8 CSEL_DIV8    /*          CCLK = VCO / 8                                  */
-
 #endif
index dc3119e9f6634ac55d58957008afca5c3a4e7da7..d7e2751c6bcc811f79017e7cdb35f92f87e4c1ca 100644 (file)
 /* include all Core registers and bit definitions */
 #include "defBF525.h"
 
-/* include core specific register pointer definitions */
-#include <asm/cdef_LPBlackfin.h>
-
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF525 */
-
-/* include cdefBF52x_base.h for the set of #defines that are common to all ADSP-BF52x processors */
-#include "cdefBF52x_base.h"
-
-/* The following are the #defines needed by ADSP-BF525 that are not in the common header */
+/* BF525 is BF522 + USB */
+#include "cdefBF522.h"
 
 /* USB Control Registers */
 
index d6579449ee463b182254f5c77d6d219588b18859..c7ba544d50b6ccfba3368f95f1f745811b85ad9a 100644 (file)
 /* include all Core registers and bit definitions */
 #include "defBF527.h"
 
-/* include core specific register pointer definitions */
-#include <asm/cdef_LPBlackfin.h>
-
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF527 */
-
-/* include cdefBF52x_base.h for the set of #defines that are common to all ADSP-BF52x processors */
-#include "cdefBF52x_base.h"
-
-/* The following are the #defines needed by ADSP-BF527 that are not in the common header */
+/* BF527 is BF525 + EMAC */
+#include "cdefBF525.h"
 
 /* 10/100 Ethernet Controller  (0xFFC03000 - 0xFFC031FF) */
 
 #define bfin_read_EMAC_TXC_ABORT()             bfin_read32(EMAC_TXC_ABORT)
 #define bfin_write_EMAC_TXC_ABORT(val)         bfin_write32(EMAC_TXC_ABORT, val)
 
-/* USB Control Registers */
-
-#define bfin_read_USB_FADDR()                  bfin_read16(USB_FADDR)
-#define bfin_write_USB_FADDR(val)              bfin_write16(USB_FADDR, val)
-#define bfin_read_USB_POWER()                  bfin_read16(USB_POWER)
-#define bfin_write_USB_POWER(val)              bfin_write16(USB_POWER, val)
-#define bfin_read_USB_INTRTX()                 bfin_read16(USB_INTRTX)
-#define bfin_write_USB_INTRTX(val)             bfin_write16(USB_INTRTX, val)
-#define bfin_read_USB_INTRRX()                 bfin_read16(USB_INTRRX)
-#define bfin_write_USB_INTRRX(val)             bfin_write16(USB_INTRRX, val)
-#define bfin_read_USB_INTRTXE()                        bfin_read16(USB_INTRTXE)
-#define bfin_write_USB_INTRTXE(val)            bfin_write16(USB_INTRTXE, val)
-#define bfin_read_USB_INTRRXE()                        bfin_read16(USB_INTRRXE)
-#define bfin_write_USB_INTRRXE(val)            bfin_write16(USB_INTRRXE, val)
-#define bfin_read_USB_INTRUSB()                        bfin_read16(USB_INTRUSB)
-#define bfin_write_USB_INTRUSB(val)            bfin_write16(USB_INTRUSB, val)
-#define bfin_read_USB_INTRUSBE()               bfin_read16(USB_INTRUSBE)
-#define bfin_write_USB_INTRUSBE(val)           bfin_write16(USB_INTRUSBE, val)
-#define bfin_read_USB_FRAME()                  bfin_read16(USB_FRAME)
-#define bfin_write_USB_FRAME(val)              bfin_write16(USB_FRAME, val)
-#define bfin_read_USB_INDEX()                  bfin_read16(USB_INDEX)
-#define bfin_write_USB_INDEX(val)              bfin_write16(USB_INDEX, val)
-#define bfin_read_USB_TESTMODE()               bfin_read16(USB_TESTMODE)
-#define bfin_write_USB_TESTMODE(val)           bfin_write16(USB_TESTMODE, val)
-#define bfin_read_USB_GLOBINTR()               bfin_read16(USB_GLOBINTR)
-#define bfin_write_USB_GLOBINTR(val)           bfin_write16(USB_GLOBINTR, val)
-#define bfin_read_USB_GLOBAL_CTL()             bfin_read16(USB_GLOBAL_CTL)
-#define bfin_write_USB_GLOBAL_CTL(val)         bfin_write16(USB_GLOBAL_CTL, val)
-
-/* USB Packet Control Registers */
-
-#define bfin_read_USB_TX_MAX_PACKET()          bfin_read16(USB_TX_MAX_PACKET)
-#define bfin_write_USB_TX_MAX_PACKET(val)      bfin_write16(USB_TX_MAX_PACKET, val)
-#define bfin_read_USB_CSR0()                   bfin_read16(USB_CSR0)
-#define bfin_write_USB_CSR0(val)               bfin_write16(USB_CSR0, val)
-#define bfin_read_USB_TXCSR()                  bfin_read16(USB_TXCSR)
-#define bfin_write_USB_TXCSR(val)              bfin_write16(USB_TXCSR, val)
-#define bfin_read_USB_RX_MAX_PACKET()          bfin_read16(USB_RX_MAX_PACKET)
-#define bfin_write_USB_RX_MAX_PACKET(val)      bfin_write16(USB_RX_MAX_PACKET, val)
-#define bfin_read_USB_RXCSR()                  bfin_read16(USB_RXCSR)
-#define bfin_write_USB_RXCSR(val)              bfin_write16(USB_RXCSR, val)
-#define bfin_read_USB_COUNT0()                 bfin_read16(USB_COUNT0)
-#define bfin_write_USB_COUNT0(val)             bfin_write16(USB_COUNT0, val)
-#define bfin_read_USB_RXCOUNT()                        bfin_read16(USB_RXCOUNT)
-#define bfin_write_USB_RXCOUNT(val)            bfin_write16(USB_RXCOUNT, val)
-#define bfin_read_USB_TXTYPE()                 bfin_read16(USB_TXTYPE)
-#define bfin_write_USB_TXTYPE(val)             bfin_write16(USB_TXTYPE, val)
-#define bfin_read_USB_NAKLIMIT0()              bfin_read16(USB_NAKLIMIT0)
-#define bfin_write_USB_NAKLIMIT0(val)          bfin_write16(USB_NAKLIMIT0, val)
-#define bfin_read_USB_TXINTERVAL()             bfin_read16(USB_TXINTERVAL)
-#define bfin_write_USB_TXINTERVAL(val)         bfin_write16(USB_TXINTERVAL, val)
-#define bfin_read_USB_RXTYPE()                 bfin_read16(USB_RXTYPE)
-#define bfin_write_USB_RXTYPE(val)             bfin_write16(USB_RXTYPE, val)
-#define bfin_read_USB_RXINTERVAL()             bfin_read16(USB_RXINTERVAL)
-#define bfin_write_USB_RXINTERVAL(val)         bfin_write16(USB_RXINTERVAL, val)
-#define bfin_read_USB_TXCOUNT()                        bfin_read16(USB_TXCOUNT)
-#define bfin_write_USB_TXCOUNT(val)            bfin_write16(USB_TXCOUNT, val)
-
-/* USB Endpoint FIFO Registers */
-
-#define bfin_read_USB_EP0_FIFO()               bfin_read16(USB_EP0_FIFO)
-#define bfin_write_USB_EP0_FIFO(val)           bfin_write16(USB_EP0_FIFO, val)
-#define bfin_read_USB_EP1_FIFO()               bfin_read16(USB_EP1_FIFO)
-#define bfin_write_USB_EP1_FIFO(val)           bfin_write16(USB_EP1_FIFO, val)
-#define bfin_read_USB_EP2_FIFO()               bfin_read16(USB_EP2_FIFO)
-#define bfin_write_USB_EP2_FIFO(val)           bfin_write16(USB_EP2_FIFO, val)
-#define bfin_read_USB_EP3_FIFO()               bfin_read16(USB_EP3_FIFO)
-#define bfin_write_USB_EP3_FIFO(val)           bfin_write16(USB_EP3_FIFO, val)
-#define bfin_read_USB_EP4_FIFO()               bfin_read16(USB_EP4_FIFO)
-#define bfin_write_USB_EP4_FIFO(val)           bfin_write16(USB_EP4_FIFO, val)
-#define bfin_read_USB_EP5_FIFO()               bfin_read16(USB_EP5_FIFO)
-#define bfin_write_USB_EP5_FIFO(val)           bfin_write16(USB_EP5_FIFO, val)
-#define bfin_read_USB_EP6_FIFO()               bfin_read16(USB_EP6_FIFO)
-#define bfin_write_USB_EP6_FIFO(val)           bfin_write16(USB_EP6_FIFO, val)
-#define bfin_read_USB_EP7_FIFO()               bfin_read16(USB_EP7_FIFO)
-#define bfin_write_USB_EP7_FIFO(val)           bfin_write16(USB_EP7_FIFO, val)
-
-/* USB OTG Control Registers */
-
-#define bfin_read_USB_OTG_DEV_CTL()            bfin_read16(USB_OTG_DEV_CTL)
-#define bfin_write_USB_OTG_DEV_CTL(val)                bfin_write16(USB_OTG_DEV_CTL, val)
-#define bfin_read_USB_OTG_VBUS_IRQ()           bfin_read16(USB_OTG_VBUS_IRQ)
-#define bfin_write_USB_OTG_VBUS_IRQ(val)       bfin_write16(USB_OTG_VBUS_IRQ, val)
-#define bfin_read_USB_OTG_VBUS_MASK()          bfin_read16(USB_OTG_VBUS_MASK)
-#define bfin_write_USB_OTG_VBUS_MASK(val)      bfin_write16(USB_OTG_VBUS_MASK, val)
-
-/* USB Phy Control Registers */
-
-#define bfin_read_USB_LINKINFO()               bfin_read16(USB_LINKINFO)
-#define bfin_write_USB_LINKINFO(val)           bfin_write16(USB_LINKINFO, val)
-#define bfin_read_USB_VPLEN()                  bfin_read16(USB_VPLEN)
-#define bfin_write_USB_VPLEN(val)              bfin_write16(USB_VPLEN, val)
-#define bfin_read_USB_HS_EOF1()                        bfin_read16(USB_HS_EOF1)
-#define bfin_write_USB_HS_EOF1(val)            bfin_write16(USB_HS_EOF1, val)
-#define bfin_read_USB_FS_EOF1()                        bfin_read16(USB_FS_EOF1)
-#define bfin_write_USB_FS_EOF1(val)            bfin_write16(USB_FS_EOF1, val)
-#define bfin_read_USB_LS_EOF1()                        bfin_read16(USB_LS_EOF1)
-#define bfin_write_USB_LS_EOF1(val)            bfin_write16(USB_LS_EOF1, val)
-
-/* (APHY_CNTRL is for ADI usage only) */
-
-#define bfin_read_USB_APHY_CNTRL()             bfin_read16(USB_APHY_CNTRL)
-#define bfin_write_USB_APHY_CNTRL(val)         bfin_write16(USB_APHY_CNTRL, val)
-
-/* (APHY_CALIB is for ADI usage only) */
-
-#define bfin_read_USB_APHY_CALIB()             bfin_read16(USB_APHY_CALIB)
-#define bfin_write_USB_APHY_CALIB(val)         bfin_write16(USB_APHY_CALIB, val)
-
-#define bfin_read_USB_APHY_CNTRL2()            bfin_read16(USB_APHY_CNTRL2)
-#define bfin_write_USB_APHY_CNTRL2(val)                bfin_write16(USB_APHY_CNTRL2, val)
-
-/* (PHY_TEST is for ADI usage only) */
-
-#define bfin_read_USB_PHY_TEST()               bfin_read16(USB_PHY_TEST)
-#define bfin_write_USB_PHY_TEST(val)           bfin_write16(USB_PHY_TEST, val)
-
-#define bfin_read_USB_PLLOSC_CTRL()            bfin_read16(USB_PLLOSC_CTRL)
-#define bfin_write_USB_PLLOSC_CTRL(val)                bfin_write16(USB_PLLOSC_CTRL, val)
-#define bfin_read_USB_SRP_CLKDIV()             bfin_read16(USB_SRP_CLKDIV)
-#define bfin_write_USB_SRP_CLKDIV(val)         bfin_write16(USB_SRP_CLKDIV, val)
-
-/* USB Endpoint 0 Control Registers */
-
-#define bfin_read_USB_EP_NI0_TXMAXP()          bfin_read16(USB_EP_NI0_TXMAXP)
-#define bfin_write_USB_EP_NI0_TXMAXP(val)      bfin_write16(USB_EP_NI0_TXMAXP, val)
-#define bfin_read_USB_EP_NI0_TXCSR()           bfin_read16(USB_EP_NI0_TXCSR)
-#define bfin_write_USB_EP_NI0_TXCSR(val)       bfin_write16(USB_EP_NI0_TXCSR, val)
-#define bfin_read_USB_EP_NI0_RXMAXP()          bfin_read16(USB_EP_NI0_RXMAXP)
-#define bfin_write_USB_EP_NI0_RXMAXP(val)      bfin_write16(USB_EP_NI0_RXMAXP, val)
-#define bfin_read_USB_EP_NI0_RXCSR()           bfin_read16(USB_EP_NI0_RXCSR)
-#define bfin_write_USB_EP_NI0_RXCSR(val)       bfin_write16(USB_EP_NI0_RXCSR, val)
-#define bfin_read_USB_EP_NI0_RXCOUNT()         bfin_read16(USB_EP_NI0_RXCOUNT)
-#define bfin_write_USB_EP_NI0_RXCOUNT(val)     bfin_write16(USB_EP_NI0_RXCOUNT, val)
-#define bfin_read_USB_EP_NI0_TXTYPE()          bfin_read16(USB_EP_NI0_TXTYPE)
-#define bfin_write_USB_EP_NI0_TXTYPE(val)      bfin_write16(USB_EP_NI0_TXTYPE, val)
-#define bfin_read_USB_EP_NI0_TXINTERVAL()      bfin_read16(USB_EP_NI0_TXINTERVAL)
-#define bfin_write_USB_EP_NI0_TXINTERVAL(val)  bfin_write16(USB_EP_NI0_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI0_RXTYPE()          bfin_read16(USB_EP_NI0_RXTYPE)
-#define bfin_write_USB_EP_NI0_RXTYPE(val)      bfin_write16(USB_EP_NI0_RXTYPE, val)
-#define bfin_read_USB_EP_NI0_RXINTERVAL()      bfin_read16(USB_EP_NI0_RXINTERVAL)
-#define bfin_write_USB_EP_NI0_RXINTERVAL(val)  bfin_write16(USB_EP_NI0_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI0_TXCOUNT()         bfin_read16(USB_EP_NI0_TXCOUNT)
-#define bfin_write_USB_EP_NI0_TXCOUNT(val)     bfin_write16(USB_EP_NI0_TXCOUNT, val)
-
-/* USB Endpoint 1 Control Registers */
-
-#define bfin_read_USB_EP_NI1_TXMAXP()          bfin_read16(USB_EP_NI1_TXMAXP)
-#define bfin_write_USB_EP_NI1_TXMAXP(val)      bfin_write16(USB_EP_NI1_TXMAXP, val)
-#define bfin_read_USB_EP_NI1_TXCSR()           bfin_read16(USB_EP_NI1_TXCSR)
-#define bfin_write_USB_EP_NI1_TXCSR(val)       bfin_write16(USB_EP_NI1_TXCSR, val)
-#define bfin_read_USB_EP_NI1_RXMAXP()          bfin_read16(USB_EP_NI1_RXMAXP)
-#define bfin_write_USB_EP_NI1_RXMAXP(val)      bfin_write16(USB_EP_NI1_RXMAXP, val)
-#define bfin_read_USB_EP_NI1_RXCSR()           bfin_read16(USB_EP_NI1_RXCSR)
-#define bfin_write_USB_EP_NI1_RXCSR(val)       bfin_write16(USB_EP_NI1_RXCSR, val)
-#define bfin_read_USB_EP_NI1_RXCOUNT()         bfin_read16(USB_EP_NI1_RXCOUNT)
-#define bfin_write_USB_EP_NI1_RXCOUNT(val)     bfin_write16(USB_EP_NI1_RXCOUNT, val)
-#define bfin_read_USB_EP_NI1_TXTYPE()          bfin_read16(USB_EP_NI1_TXTYPE)
-#define bfin_write_USB_EP_NI1_TXTYPE(val)      bfin_write16(USB_EP_NI1_TXTYPE, val)
-#define bfin_read_USB_EP_NI1_TXINTERVAL()      bfin_read16(USB_EP_NI1_TXINTERVAL)
-#define bfin_write_USB_EP_NI1_TXINTERVAL(val)  bfin_write16(USB_EP_NI1_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI1_RXTYPE()          bfin_read16(USB_EP_NI1_RXTYPE)
-#define bfin_write_USB_EP_NI1_RXTYPE(val)      bfin_write16(USB_EP_NI1_RXTYPE, val)
-#define bfin_read_USB_EP_NI1_RXINTERVAL()      bfin_read16(USB_EP_NI1_RXINTERVAL)
-#define bfin_write_USB_EP_NI1_RXINTERVAL(val)  bfin_write16(USB_EP_NI1_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI1_TXCOUNT()         bfin_read16(USB_EP_NI1_TXCOUNT)
-#define bfin_write_USB_EP_NI1_TXCOUNT(val)     bfin_write16(USB_EP_NI1_TXCOUNT, val)
-
-/* USB Endpoint 2 Control Registers */
-
-#define bfin_read_USB_EP_NI2_TXMAXP()          bfin_read16(USB_EP_NI2_TXMAXP)
-#define bfin_write_USB_EP_NI2_TXMAXP(val)      bfin_write16(USB_EP_NI2_TXMAXP, val)
-#define bfin_read_USB_EP_NI2_TXCSR()           bfin_read16(USB_EP_NI2_TXCSR)
-#define bfin_write_USB_EP_NI2_TXCSR(val)       bfin_write16(USB_EP_NI2_TXCSR, val)
-#define bfin_read_USB_EP_NI2_RXMAXP()          bfin_read16(USB_EP_NI2_RXMAXP)
-#define bfin_write_USB_EP_NI2_RXMAXP(val)      bfin_write16(USB_EP_NI2_RXMAXP, val)
-#define bfin_read_USB_EP_NI2_RXCSR()           bfin_read16(USB_EP_NI2_RXCSR)
-#define bfin_write_USB_EP_NI2_RXCSR(val)       bfin_write16(USB_EP_NI2_RXCSR, val)
-#define bfin_read_USB_EP_NI2_RXCOUNT()         bfin_read16(USB_EP_NI2_RXCOUNT)
-#define bfin_write_USB_EP_NI2_RXCOUNT(val)     bfin_write16(USB_EP_NI2_RXCOUNT, val)
-#define bfin_read_USB_EP_NI2_TXTYPE()          bfin_read16(USB_EP_NI2_TXTYPE)
-#define bfin_write_USB_EP_NI2_TXTYPE(val)      bfin_write16(USB_EP_NI2_TXTYPE, val)
-#define bfin_read_USB_EP_NI2_TXINTERVAL()      bfin_read16(USB_EP_NI2_TXINTERVAL)
-#define bfin_write_USB_EP_NI2_TXINTERVAL(val)  bfin_write16(USB_EP_NI2_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI2_RXTYPE()          bfin_read16(USB_EP_NI2_RXTYPE)
-#define bfin_write_USB_EP_NI2_RXTYPE(val)      bfin_write16(USB_EP_NI2_RXTYPE, val)
-#define bfin_read_USB_EP_NI2_RXINTERVAL()      bfin_read16(USB_EP_NI2_RXINTERVAL)
-#define bfin_write_USB_EP_NI2_RXINTERVAL(val)  bfin_write16(USB_EP_NI2_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI2_TXCOUNT()         bfin_read16(USB_EP_NI2_TXCOUNT)
-#define bfin_write_USB_EP_NI2_TXCOUNT(val)     bfin_write16(USB_EP_NI2_TXCOUNT, val)
-
-/* USB Endpoint 3 Control Registers */
-
-#define bfin_read_USB_EP_NI3_TXMAXP()          bfin_read16(USB_EP_NI3_TXMAXP)
-#define bfin_write_USB_EP_NI3_TXMAXP(val)      bfin_write16(USB_EP_NI3_TXMAXP, val)
-#define bfin_read_USB_EP_NI3_TXCSR()           bfin_read16(USB_EP_NI3_TXCSR)
-#define bfin_write_USB_EP_NI3_TXCSR(val)       bfin_write16(USB_EP_NI3_TXCSR, val)
-#define bfin_read_USB_EP_NI3_RXMAXP()          bfin_read16(USB_EP_NI3_RXMAXP)
-#define bfin_write_USB_EP_NI3_RXMAXP(val)      bfin_write16(USB_EP_NI3_RXMAXP, val)
-#define bfin_read_USB_EP_NI3_RXCSR()           bfin_read16(USB_EP_NI3_RXCSR)
-#define bfin_write_USB_EP_NI3_RXCSR(val)       bfin_write16(USB_EP_NI3_RXCSR, val)
-#define bfin_read_USB_EP_NI3_RXCOUNT()         bfin_read16(USB_EP_NI3_RXCOUNT)
-#define bfin_write_USB_EP_NI3_RXCOUNT(val)     bfin_write16(USB_EP_NI3_RXCOUNT, val)
-#define bfin_read_USB_EP_NI3_TXTYPE()          bfin_read16(USB_EP_NI3_TXTYPE)
-#define bfin_write_USB_EP_NI3_TXTYPE(val)      bfin_write16(USB_EP_NI3_TXTYPE, val)
-#define bfin_read_USB_EP_NI3_TXINTERVAL()      bfin_read16(USB_EP_NI3_TXINTERVAL)
-#define bfin_write_USB_EP_NI3_TXINTERVAL(val)  bfin_write16(USB_EP_NI3_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI3_RXTYPE()          bfin_read16(USB_EP_NI3_RXTYPE)
-#define bfin_write_USB_EP_NI3_RXTYPE(val)      bfin_write16(USB_EP_NI3_RXTYPE, val)
-#define bfin_read_USB_EP_NI3_RXINTERVAL()      bfin_read16(USB_EP_NI3_RXINTERVAL)
-#define bfin_write_USB_EP_NI3_RXINTERVAL(val)  bfin_write16(USB_EP_NI3_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI3_TXCOUNT()         bfin_read16(USB_EP_NI3_TXCOUNT)
-#define bfin_write_USB_EP_NI3_TXCOUNT(val)     bfin_write16(USB_EP_NI3_TXCOUNT, val)
-
-/* USB Endpoint 4 Control Registers */
-
-#define bfin_read_USB_EP_NI4_TXMAXP()          bfin_read16(USB_EP_NI4_TXMAXP)
-#define bfin_write_USB_EP_NI4_TXMAXP(val)      bfin_write16(USB_EP_NI4_TXMAXP, val)
-#define bfin_read_USB_EP_NI4_TXCSR()           bfin_read16(USB_EP_NI4_TXCSR)
-#define bfin_write_USB_EP_NI4_TXCSR(val)       bfin_write16(USB_EP_NI4_TXCSR, val)
-#define bfin_read_USB_EP_NI4_RXMAXP()          bfin_read16(USB_EP_NI4_RXMAXP)
-#define bfin_write_USB_EP_NI4_RXMAXP(val)      bfin_write16(USB_EP_NI4_RXMAXP, val)
-#define bfin_read_USB_EP_NI4_RXCSR()           bfin_read16(USB_EP_NI4_RXCSR)
-#define bfin_write_USB_EP_NI4_RXCSR(val)       bfin_write16(USB_EP_NI4_RXCSR, val)
-#define bfin_read_USB_EP_NI4_RXCOUNT()         bfin_read16(USB_EP_NI4_RXCOUNT)
-#define bfin_write_USB_EP_NI4_RXCOUNT(val)     bfin_write16(USB_EP_NI4_RXCOUNT, val)
-#define bfin_read_USB_EP_NI4_TXTYPE()          bfin_read16(USB_EP_NI4_TXTYPE)
-#define bfin_write_USB_EP_NI4_TXTYPE(val)      bfin_write16(USB_EP_NI4_TXTYPE, val)
-#define bfin_read_USB_EP_NI4_TXINTERVAL()      bfin_read16(USB_EP_NI4_TXINTERVAL)
-#define bfin_write_USB_EP_NI4_TXINTERVAL(val)  bfin_write16(USB_EP_NI4_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI4_RXTYPE()          bfin_read16(USB_EP_NI4_RXTYPE)
-#define bfin_write_USB_EP_NI4_RXTYPE(val)      bfin_write16(USB_EP_NI4_RXTYPE, val)
-#define bfin_read_USB_EP_NI4_RXINTERVAL()      bfin_read16(USB_EP_NI4_RXINTERVAL)
-#define bfin_write_USB_EP_NI4_RXINTERVAL(val)  bfin_write16(USB_EP_NI4_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI4_TXCOUNT()         bfin_read16(USB_EP_NI4_TXCOUNT)
-#define bfin_write_USB_EP_NI4_TXCOUNT(val)     bfin_write16(USB_EP_NI4_TXCOUNT, val)
-
-/* USB Endpoint 5 Control Registers */
-
-#define bfin_read_USB_EP_NI5_TXMAXP()          bfin_read16(USB_EP_NI5_TXMAXP)
-#define bfin_write_USB_EP_NI5_TXMAXP(val)      bfin_write16(USB_EP_NI5_TXMAXP, val)
-#define bfin_read_USB_EP_NI5_TXCSR()           bfin_read16(USB_EP_NI5_TXCSR)
-#define bfin_write_USB_EP_NI5_TXCSR(val)       bfin_write16(USB_EP_NI5_TXCSR, val)
-#define bfin_read_USB_EP_NI5_RXMAXP()          bfin_read16(USB_EP_NI5_RXMAXP)
-#define bfin_write_USB_EP_NI5_RXMAXP(val)      bfin_write16(USB_EP_NI5_RXMAXP, val)
-#define bfin_read_USB_EP_NI5_RXCSR()           bfin_read16(USB_EP_NI5_RXCSR)
-#define bfin_write_USB_EP_NI5_RXCSR(val)       bfin_write16(USB_EP_NI5_RXCSR, val)
-#define bfin_read_USB_EP_NI5_RXCOUNT()         bfin_read16(USB_EP_NI5_RXCOUNT)
-#define bfin_write_USB_EP_NI5_RXCOUNT(val)     bfin_write16(USB_EP_NI5_RXCOUNT, val)
-#define bfin_read_USB_EP_NI5_TXTYPE()          bfin_read16(USB_EP_NI5_TXTYPE)
-#define bfin_write_USB_EP_NI5_TXTYPE(val)      bfin_write16(USB_EP_NI5_TXTYPE, val)
-#define bfin_read_USB_EP_NI5_TXINTERVAL()      bfin_read16(USB_EP_NI5_TXINTERVAL)
-#define bfin_write_USB_EP_NI5_TXINTERVAL(val)  bfin_write16(USB_EP_NI5_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI5_RXTYPE()          bfin_read16(USB_EP_NI5_RXTYPE)
-#define bfin_write_USB_EP_NI5_RXTYPE(val)      bfin_write16(USB_EP_NI5_RXTYPE, val)
-#define bfin_read_USB_EP_NI5_RXINTERVAL()      bfin_read16(USB_EP_NI5_RXINTERVAL)
-#define bfin_write_USB_EP_NI5_RXINTERVAL(val)  bfin_write16(USB_EP_NI5_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI5_TXCOUNT()         bfin_read16(USB_EP_NI5_TXCOUNT)
-#define bfin_write_USB_EP_NI5_TXCOUNT(val)     bfin_write16(USB_EP_NI5_TXCOUNT, val)
-
-/* USB Endpoint 6 Control Registers */
-
-#define bfin_read_USB_EP_NI6_TXMAXP()          bfin_read16(USB_EP_NI6_TXMAXP)
-#define bfin_write_USB_EP_NI6_TXMAXP(val)      bfin_write16(USB_EP_NI6_TXMAXP, val)
-#define bfin_read_USB_EP_NI6_TXCSR()           bfin_read16(USB_EP_NI6_TXCSR)
-#define bfin_write_USB_EP_NI6_TXCSR(val)       bfin_write16(USB_EP_NI6_TXCSR, val)
-#define bfin_read_USB_EP_NI6_RXMAXP()          bfin_read16(USB_EP_NI6_RXMAXP)
-#define bfin_write_USB_EP_NI6_RXMAXP(val)      bfin_write16(USB_EP_NI6_RXMAXP, val)
-#define bfin_read_USB_EP_NI6_RXCSR()           bfin_read16(USB_EP_NI6_RXCSR)
-#define bfin_write_USB_EP_NI6_RXCSR(val)       bfin_write16(USB_EP_NI6_RXCSR, val)
-#define bfin_read_USB_EP_NI6_RXCOUNT()         bfin_read16(USB_EP_NI6_RXCOUNT)
-#define bfin_write_USB_EP_NI6_RXCOUNT(val)     bfin_write16(USB_EP_NI6_RXCOUNT, val)
-#define bfin_read_USB_EP_NI6_TXTYPE()          bfin_read16(USB_EP_NI6_TXTYPE)
-#define bfin_write_USB_EP_NI6_TXTYPE(val)      bfin_write16(USB_EP_NI6_TXTYPE, val)
-#define bfin_read_USB_EP_NI6_TXINTERVAL()      bfin_read16(USB_EP_NI6_TXINTERVAL)
-#define bfin_write_USB_EP_NI6_TXINTERVAL(val)  bfin_write16(USB_EP_NI6_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI6_RXTYPE()          bfin_read16(USB_EP_NI6_RXTYPE)
-#define bfin_write_USB_EP_NI6_RXTYPE(val)      bfin_write16(USB_EP_NI6_RXTYPE, val)
-#define bfin_read_USB_EP_NI6_RXINTERVAL()      bfin_read16(USB_EP_NI6_RXINTERVAL)
-#define bfin_write_USB_EP_NI6_RXINTERVAL(val)  bfin_write16(USB_EP_NI6_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI6_TXCOUNT()         bfin_read16(USB_EP_NI6_TXCOUNT)
-#define bfin_write_USB_EP_NI6_TXCOUNT(val)     bfin_write16(USB_EP_NI6_TXCOUNT, val)
-
-/* USB Endpoint 7 Control Registers */
-
-#define bfin_read_USB_EP_NI7_TXMAXP()          bfin_read16(USB_EP_NI7_TXMAXP)
-#define bfin_write_USB_EP_NI7_TXMAXP(val)      bfin_write16(USB_EP_NI7_TXMAXP, val)
-#define bfin_read_USB_EP_NI7_TXCSR()           bfin_read16(USB_EP_NI7_TXCSR)
-#define bfin_write_USB_EP_NI7_TXCSR(val)       bfin_write16(USB_EP_NI7_TXCSR, val)
-#define bfin_read_USB_EP_NI7_RXMAXP()          bfin_read16(USB_EP_NI7_RXMAXP)
-#define bfin_write_USB_EP_NI7_RXMAXP(val)      bfin_write16(USB_EP_NI7_RXMAXP, val)
-#define bfin_read_USB_EP_NI7_RXCSR()           bfin_read16(USB_EP_NI7_RXCSR)
-#define bfin_write_USB_EP_NI7_RXCSR(val)       bfin_write16(USB_EP_NI7_RXCSR, val)
-#define bfin_read_USB_EP_NI7_RXCOUNT()         bfin_read16(USB_EP_NI7_RXCOUNT)
-#define bfin_write_USB_EP_NI7_RXCOUNT(val)     bfin_write16(USB_EP_NI7_RXCOUNT, val)
-#define bfin_read_USB_EP_NI7_TXTYPE()          bfin_read16(USB_EP_NI7_TXTYPE)
-#define bfin_write_USB_EP_NI7_TXTYPE(val)      bfin_write16(USB_EP_NI7_TXTYPE, val)
-#define bfin_read_USB_EP_NI7_TXINTERVAL()      bfin_read16(USB_EP_NI7_TXINTERVAL)
-#define bfin_write_USB_EP_NI7_TXINTERVAL(val)  bfin_write16(USB_EP_NI7_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI7_RXTYPE()          bfin_read16(USB_EP_NI7_RXTYPE)
-#define bfin_write_USB_EP_NI7_RXTYPE(val)      bfin_write16(USB_EP_NI7_RXTYPE, val)
-#define bfin_read_USB_EP_NI7_RXINTERVAL()      bfin_read16(USB_EP_NI7_RXINTERVAL)
-#define bfin_write_USB_EP_NI7_RXINTERVAL(val)  bfin_write16(USB_EP_NI7_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI7_TXCOUNT()         bfin_read16(USB_EP_NI7_TXCOUNT)
-#define bfin_write_USB_EP_NI7_TXCOUNT(val)     bfin_write16(USB_EP_NI7_TXCOUNT, val)
-
-#define bfin_read_USB_DMA_INTERRUPT()          bfin_read16(USB_DMA_INTERRUPT)
-#define bfin_write_USB_DMA_INTERRUPT(val)      bfin_write16(USB_DMA_INTERRUPT, val)
-
-/* USB Channel 0 Config Registers */
-
-#define bfin_read_USB_DMA0CONTROL()            bfin_read16(USB_DMA0CONTROL)
-#define bfin_write_USB_DMA0CONTROL(val)                bfin_write16(USB_DMA0CONTROL, val)
-#define bfin_read_USB_DMA0ADDRLOW()            bfin_read16(USB_DMA0ADDRLOW)
-#define bfin_write_USB_DMA0ADDRLOW(val)                bfin_write16(USB_DMA0ADDRLOW, val)
-#define bfin_read_USB_DMA0ADDRHIGH()           bfin_read16(USB_DMA0ADDRHIGH)
-#define bfin_write_USB_DMA0ADDRHIGH(val)       bfin_write16(USB_DMA0ADDRHIGH, val)
-#define bfin_read_USB_DMA0COUNTLOW()           bfin_read16(USB_DMA0COUNTLOW)
-#define bfin_write_USB_DMA0COUNTLOW(val)       bfin_write16(USB_DMA0COUNTLOW, val)
-#define bfin_read_USB_DMA0COUNTHIGH()          bfin_read16(USB_DMA0COUNTHIGH)
-#define bfin_write_USB_DMA0COUNTHIGH(val)      bfin_write16(USB_DMA0COUNTHIGH, val)
-
-/* USB Channel 1 Config Registers */
-
-#define bfin_read_USB_DMA1CONTROL()            bfin_read16(USB_DMA1CONTROL)
-#define bfin_write_USB_DMA1CONTROL(val)                bfin_write16(USB_DMA1CONTROL, val)
-#define bfin_read_USB_DMA1ADDRLOW()            bfin_read16(USB_DMA1ADDRLOW)
-#define bfin_write_USB_DMA1ADDRLOW(val)                bfin_write16(USB_DMA1ADDRLOW, val)
-#define bfin_read_USB_DMA1ADDRHIGH()           bfin_read16(USB_DMA1ADDRHIGH)
-#define bfin_write_USB_DMA1ADDRHIGH(val)       bfin_write16(USB_DMA1ADDRHIGH, val)
-#define bfin_read_USB_DMA1COUNTLOW()           bfin_read16(USB_DMA1COUNTLOW)
-#define bfin_write_USB_DMA1COUNTLOW(val)       bfin_write16(USB_DMA1COUNTLOW, val)
-#define bfin_read_USB_DMA1COUNTHIGH()          bfin_read16(USB_DMA1COUNTHIGH)
-#define bfin_write_USB_DMA1COUNTHIGH(val)      bfin_write16(USB_DMA1COUNTHIGH, val)
-
-/* USB Channel 2 Config Registers */
-
-#define bfin_read_USB_DMA2CONTROL()            bfin_read16(USB_DMA2CONTROL)
-#define bfin_write_USB_DMA2CONTROL(val)                bfin_write16(USB_DMA2CONTROL, val)
-#define bfin_read_USB_DMA2ADDRLOW()            bfin_read16(USB_DMA2ADDRLOW)
-#define bfin_write_USB_DMA2ADDRLOW(val)                bfin_write16(USB_DMA2ADDRLOW, val)
-#define bfin_read_USB_DMA2ADDRHIGH()           bfin_read16(USB_DMA2ADDRHIGH)
-#define bfin_write_USB_DMA2ADDRHIGH(val)       bfin_write16(USB_DMA2ADDRHIGH, val)
-#define bfin_read_USB_DMA2COUNTLOW()           bfin_read16(USB_DMA2COUNTLOW)
-#define bfin_write_USB_DMA2COUNTLOW(val)       bfin_write16(USB_DMA2COUNTLOW, val)
-#define bfin_read_USB_DMA2COUNTHIGH()          bfin_read16(USB_DMA2COUNTHIGH)
-#define bfin_write_USB_DMA2COUNTHIGH(val)      bfin_write16(USB_DMA2COUNTHIGH, val)
-
-/* USB Channel 3 Config Registers */
-
-#define bfin_read_USB_DMA3CONTROL()            bfin_read16(USB_DMA3CONTROL)
-#define bfin_write_USB_DMA3CONTROL(val)                bfin_write16(USB_DMA3CONTROL, val)
-#define bfin_read_USB_DMA3ADDRLOW()            bfin_read16(USB_DMA3ADDRLOW)
-#define bfin_write_USB_DMA3ADDRLOW(val)                bfin_write16(USB_DMA3ADDRLOW, val)
-#define bfin_read_USB_DMA3ADDRHIGH()           bfin_read16(USB_DMA3ADDRHIGH)
-#define bfin_write_USB_DMA3ADDRHIGH(val)       bfin_write16(USB_DMA3ADDRHIGH, val)
-#define bfin_read_USB_DMA3COUNTLOW()           bfin_read16(USB_DMA3COUNTLOW)
-#define bfin_write_USB_DMA3COUNTLOW(val)       bfin_write16(USB_DMA3COUNTLOW, val)
-#define bfin_read_USB_DMA3COUNTHIGH()          bfin_read16(USB_DMA3COUNTHIGH)
-#define bfin_write_USB_DMA3COUNTHIGH(val)      bfin_write16(USB_DMA3COUNTHIGH, val)
-
-/* USB Channel 4 Config Registers */
-
-#define bfin_read_USB_DMA4CONTROL()            bfin_read16(USB_DMA4CONTROL)
-#define bfin_write_USB_DMA4CONTROL(val)                bfin_write16(USB_DMA4CONTROL, val)
-#define bfin_read_USB_DMA4ADDRLOW()            bfin_read16(USB_DMA4ADDRLOW)
-#define bfin_write_USB_DMA4ADDRLOW(val)                bfin_write16(USB_DMA4ADDRLOW, val)
-#define bfin_read_USB_DMA4ADDRHIGH()           bfin_read16(USB_DMA4ADDRHIGH)
-#define bfin_write_USB_DMA4ADDRHIGH(val)       bfin_write16(USB_DMA4ADDRHIGH, val)
-#define bfin_read_USB_DMA4COUNTLOW()           bfin_read16(USB_DMA4COUNTLOW)
-#define bfin_write_USB_DMA4COUNTLOW(val)       bfin_write16(USB_DMA4COUNTLOW, val)
-#define bfin_read_USB_DMA4COUNTHIGH()          bfin_read16(USB_DMA4COUNTHIGH)
-#define bfin_write_USB_DMA4COUNTHIGH(val)      bfin_write16(USB_DMA4COUNTHIGH, val)
-
-/* USB Channel 5 Config Registers */
-
-#define bfin_read_USB_DMA5CONTROL()            bfin_read16(USB_DMA5CONTROL)
-#define bfin_write_USB_DMA5CONTROL(val)                bfin_write16(USB_DMA5CONTROL, val)
-#define bfin_read_USB_DMA5ADDRLOW()            bfin_read16(USB_DMA5ADDRLOW)
-#define bfin_write_USB_DMA5ADDRLOW(val)                bfin_write16(USB_DMA5ADDRLOW, val)
-#define bfin_read_USB_DMA5ADDRHIGH()           bfin_read16(USB_DMA5ADDRHIGH)
-#define bfin_write_USB_DMA5ADDRHIGH(val)       bfin_write16(USB_DMA5ADDRHIGH, val)
-#define bfin_read_USB_DMA5COUNTLOW()           bfin_read16(USB_DMA5COUNTLOW)
-#define bfin_write_USB_DMA5COUNTLOW(val)       bfin_write16(USB_DMA5COUNTLOW, val)
-#define bfin_read_USB_DMA5COUNTHIGH()          bfin_read16(USB_DMA5COUNTHIGH)
-#define bfin_write_USB_DMA5COUNTHIGH(val)      bfin_write16(USB_DMA5COUNTHIGH, val)
-
-/* USB Channel 6 Config Registers */
-
-#define bfin_read_USB_DMA6CONTROL()            bfin_read16(USB_DMA6CONTROL)
-#define bfin_write_USB_DMA6CONTROL(val)                bfin_write16(USB_DMA6CONTROL, val)
-#define bfin_read_USB_DMA6ADDRLOW()            bfin_read16(USB_DMA6ADDRLOW)
-#define bfin_write_USB_DMA6ADDRLOW(val)                bfin_write16(USB_DMA6ADDRLOW, val)
-#define bfin_read_USB_DMA6ADDRHIGH()           bfin_read16(USB_DMA6ADDRHIGH)
-#define bfin_write_USB_DMA6ADDRHIGH(val)       bfin_write16(USB_DMA6ADDRHIGH, val)
-#define bfin_read_USB_DMA6COUNTLOW()           bfin_read16(USB_DMA6COUNTLOW)
-#define bfin_write_USB_DMA6COUNTLOW(val)       bfin_write16(USB_DMA6COUNTLOW, val)
-#define bfin_read_USB_DMA6COUNTHIGH()          bfin_read16(USB_DMA6COUNTHIGH)
-#define bfin_write_USB_DMA6COUNTHIGH(val)      bfin_write16(USB_DMA6COUNTHIGH, val)
-
-/* USB Channel 7 Config Registers */
-
-#define bfin_read_USB_DMA7CONTROL()            bfin_read16(USB_DMA7CONTROL)
-#define bfin_write_USB_DMA7CONTROL(val)                bfin_write16(USB_DMA7CONTROL, val)
-#define bfin_read_USB_DMA7ADDRLOW()            bfin_read16(USB_DMA7ADDRLOW)
-#define bfin_write_USB_DMA7ADDRLOW(val)                bfin_write16(USB_DMA7ADDRLOW, val)
-#define bfin_read_USB_DMA7ADDRHIGH()           bfin_read16(USB_DMA7ADDRHIGH)
-#define bfin_write_USB_DMA7ADDRHIGH(val)       bfin_write16(USB_DMA7ADDRHIGH, val)
-#define bfin_read_USB_DMA7COUNTLOW()           bfin_read16(USB_DMA7COUNTLOW)
-#define bfin_write_USB_DMA7COUNTLOW(val)       bfin_write16(USB_DMA7COUNTLOW, val)
-#define bfin_read_USB_DMA7COUNTHIGH()          bfin_read16(USB_DMA7COUNTHIGH)
-#define bfin_write_USB_DMA7COUNTHIGH(val)      bfin_write16(USB_DMA7COUNTHIGH, val)
-
 #endif /* _CDEF_BF527_H */
index 7014dde10dd6b2c122fd5bcfb5caf322fcadb026..12f2ad45314eb3c1bfbdaabc7ae96edc3bbb7ae4 100644 (file)
 #define bfin_write_PPI_CONTROL(val)            bfin_write16(PPI_CONTROL, val)
 #define bfin_read_PPI_STATUS()                 bfin_read16(PPI_STATUS)
 #define bfin_write_PPI_STATUS(val)             bfin_write16(PPI_STATUS, val)
+#define bfin_clear_PPI_STATUS()                        bfin_write_PPI_STATUS(0xFFFF)
 #define bfin_read_PPI_DELAY()                  bfin_read16(PPI_DELAY)
 #define bfin_write_PPI_DELAY(val)              bfin_write16(PPI_DELAY, val)
 #define bfin_read_PPI_COUNT()                  bfin_read16(PPI_COUNT)
 #define bfin_read_CNT_MIN()                    bfin_read32(CNT_MIN)
 #define bfin_write_CNT_MIN(val)                        bfin_write32(CNT_MIN, val)
 
-/* OTP/FUSE Registers */
-
-#define bfin_read_OTP_CONTROL()                        bfin_read16(OTP_CONTROL)
-#define bfin_write_OTP_CONTROL(val)            bfin_write16(OTP_CONTROL, val)
-#define bfin_read_OTP_BEN()                    bfin_read16(OTP_BEN)
-#define bfin_write_OTP_BEN(val)                        bfin_write16(OTP_BEN, val)
-#define bfin_read_OTP_STATUS()                 bfin_read16(OTP_STATUS)
-#define bfin_write_OTP_STATUS(val)             bfin_write16(OTP_STATUS, val)
-#define bfin_read_OTP_TIMING()                 bfin_read32(OTP_TIMING)
-#define bfin_write_OTP_TIMING(val)             bfin_write32(OTP_TIMING, val)
-
 /* Security Registers */
 
 #define bfin_read_SECURE_SYSSWT()              bfin_read32(SECURE_SYSSWT)
 #define bfin_read_SECURE_STATUS()              bfin_read16(SECURE_STATUS)
 #define bfin_write_SECURE_STATUS(val)          bfin_write16(SECURE_STATUS, val)
 
-/* OTP Read/Write Data Buffer Registers */
-
-#define bfin_read_OTP_DATA0()                  bfin_read32(OTP_DATA0)
-#define bfin_write_OTP_DATA0(val)              bfin_write32(OTP_DATA0, val)
-#define bfin_read_OTP_DATA1()                  bfin_read32(OTP_DATA1)
-#define bfin_write_OTP_DATA1(val)              bfin_write32(OTP_DATA1, val)
-#define bfin_read_OTP_DATA2()                  bfin_read32(OTP_DATA2)
-#define bfin_write_OTP_DATA2(val)              bfin_write32(OTP_DATA2, val)
-#define bfin_read_OTP_DATA3()                  bfin_read32(OTP_DATA3)
-#define bfin_write_OTP_DATA3(val)              bfin_write32(OTP_DATA3, val)
-
 /* NFC Registers */
 
 #define bfin_read_NFC_CTL()                    bfin_read16(NFC_CTL)
index 82abefc1ef6cfa49e85374256c36e462003e557f..c136f7032962bb74cc4c5a687769fb9a6a39acea 100644 (file)
@@ -7,15 +7,8 @@
 #ifndef _DEF_BF525_H
 #define _DEF_BF525_H
 
-/* Include all Core registers and bit definitions */
-#include <asm/def_LPBlackfin.h>
-
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF525 */
-
-/* Include defBF52x_base.h for the set of #defines that are common to all ADSP-BF52x processors */
-#include "defBF52x_base.h"
-
-/* The following are the #defines needed by ADSP-BF525 that are not in the common header */
+/* BF525 is BF522 + USB */
+#include "defBF522.h"
 
 /* USB Control Registers */
 
index 570a125df025b5916004dc7131362300a5ae2f89..4dd58fb331568af448518727af91c8004d9959b6 100644 (file)
@@ -7,15 +7,9 @@
 #ifndef _DEF_BF527_H
 #define _DEF_BF527_H
 
-/* Include all Core registers and bit definitions */
-#include <asm/def_LPBlackfin.h>
+/* BF527 is BF525 + EMAC */
+#include "defBF525.h"
 
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF527 */
-
-/* Include defBF52x_base.h for the set of #defines that are common to all ADSP-BF52x processors */
-#include "defBF52x_base.h"
-
-/* The following are the #defines needed by ADSP-BF527 that are not in the common header */
 /* 10/100 Ethernet Controller  (0xFFC03000 - 0xFFC031FF) */
 
 #define EMAC_OPMODE             0xFFC03000       /* Operating Mode Register                              */
 #define        TX_GE1024_CNT     0x00200000    /* 1024-Max-Byte TX Frames Sent                           */
 #define        TX_ABORT_CNT      0x00400000    /* TX Frames Aborted                                      */
 
-/* USB Control Registers */
-
-#define                        USB_FADDR  0xffc03800   /* Function address register */
-#define                        USB_POWER  0xffc03804   /* Power management register */
-#define                       USB_INTRTX  0xffc03808   /* Interrupt register for endpoint 0 and Tx endpoint 1 to 7 */
-#define                       USB_INTRRX  0xffc0380c   /* Interrupt register for Rx endpoints 1 to 7 */
-#define                      USB_INTRTXE  0xffc03810   /* Interrupt enable register for IntrTx */
-#define                      USB_INTRRXE  0xffc03814   /* Interrupt enable register for IntrRx */
-#define                      USB_INTRUSB  0xffc03818   /* Interrupt register for common USB interrupts */
-#define                     USB_INTRUSBE  0xffc0381c   /* Interrupt enable register for IntrUSB */
-#define                        USB_FRAME  0xffc03820   /* USB frame number */
-#define                        USB_INDEX  0xffc03824   /* Index register for selecting the indexed endpoint registers */
-#define                     USB_TESTMODE  0xffc03828   /* Enabled USB 20 test modes */
-#define                     USB_GLOBINTR  0xffc0382c   /* Global Interrupt Mask register and Wakeup Exception Interrupt */
-#define                   USB_GLOBAL_CTL  0xffc03830   /* Global Clock Control for the core */
-
-/* USB Packet Control Registers */
-
-#define                USB_TX_MAX_PACKET  0xffc03840   /* Maximum packet size for Host Tx endpoint */
-#define                         USB_CSR0  0xffc03844   /* Control Status register for endpoint 0 and Control Status register for Host Tx endpoint */
-#define                        USB_TXCSR  0xffc03844   /* Control Status register for endpoint 0 and Control Status register for Host Tx endpoint */
-#define                USB_RX_MAX_PACKET  0xffc03848   /* Maximum packet size for Host Rx endpoint */
-#define                        USB_RXCSR  0xffc0384c   /* Control Status register for Host Rx endpoint */
-#define                       USB_COUNT0  0xffc03850   /* Number of bytes received in endpoint 0 FIFO and Number of bytes received in Host Tx endpoint */
-#define                      USB_RXCOUNT  0xffc03850   /* Number of bytes received in endpoint 0 FIFO and Number of bytes received in Host Tx endpoint */
-#define                       USB_TXTYPE  0xffc03854   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint */
-#define                    USB_NAKLIMIT0  0xffc03858   /* Sets the NAK response timeout on Endpoint 0 and on Bulk transfers for Host Tx endpoint */
-#define                   USB_TXINTERVAL  0xffc03858   /* Sets the NAK response timeout on Endpoint 0 and on Bulk transfers for Host Tx endpoint */
-#define                       USB_RXTYPE  0xffc0385c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint */
-#define                   USB_RXINTERVAL  0xffc03860   /* Sets the polling interval for Interrupt and Isochronous transfers or the NAK response timeout on Bulk transfers */
-#define                      USB_TXCOUNT  0xffc03868   /* Number of bytes to be written to the selected endpoint Tx FIFO */
-
-/* USB Endpoint FIFO Registers */
-
-#define                     USB_EP0_FIFO  0xffc03880   /* Endpoint 0 FIFO */
-#define                     USB_EP1_FIFO  0xffc03888   /* Endpoint 1 FIFO */
-#define                     USB_EP2_FIFO  0xffc03890   /* Endpoint 2 FIFO */
-#define                     USB_EP3_FIFO  0xffc03898   /* Endpoint 3 FIFO */
-#define                     USB_EP4_FIFO  0xffc038a0   /* Endpoint 4 FIFO */
-#define                     USB_EP5_FIFO  0xffc038a8   /* Endpoint 5 FIFO */
-#define                     USB_EP6_FIFO  0xffc038b0   /* Endpoint 6 FIFO */
-#define                     USB_EP7_FIFO  0xffc038b8   /* Endpoint 7 FIFO */
-
-/* USB OTG Control Registers */
-
-#define                  USB_OTG_DEV_CTL  0xffc03900   /* OTG Device Control Register */
-#define                 USB_OTG_VBUS_IRQ  0xffc03904   /* OTG VBUS Control Interrupts */
-#define                USB_OTG_VBUS_MASK  0xffc03908   /* VBUS Control Interrupt Enable */
-
-/* USB Phy Control Registers */
-
-#define                     USB_LINKINFO  0xffc03948   /* Enables programming of some PHY-side delays */
-#define                        USB_VPLEN  0xffc0394c   /* Determines duration of VBUS pulse for VBUS charging */
-#define                      USB_HS_EOF1  0xffc03950   /* Time buffer for High-Speed transactions */
-#define                      USB_FS_EOF1  0xffc03954   /* Time buffer for Full-Speed transactions */
-#define                      USB_LS_EOF1  0xffc03958   /* Time buffer for Low-Speed transactions */
-
-/* (APHY_CNTRL is for ADI usage only) */
-
-#define                   USB_APHY_CNTRL  0xffc039e0   /* Register that increases visibility of Analog PHY */
-
-/* (APHY_CALIB is for ADI usage only) */
-
-#define                   USB_APHY_CALIB  0xffc039e4   /* Register used to set some calibration values */
-
-#define                  USB_APHY_CNTRL2  0xffc039e8   /* Register used to prevent re-enumeration once Moab goes into hibernate mode */
-
-/* (PHY_TEST is for ADI usage only) */
-
-#define                     USB_PHY_TEST  0xffc039ec   /* Used for reducing simulation time and simplifies FIFO testability */
-
-#define                  USB_PLLOSC_CTRL  0xffc039f0   /* Used to program different parameters for USB PLL and Oscillator */
-#define                   USB_SRP_CLKDIV  0xffc039f4   /* Used to program clock divide value for the clock fed to the SRP detection logic */
-
-/* USB Endpoint 0 Control Registers */
-
-#define                USB_EP_NI0_TXMAXP  0xffc03a00   /* Maximum packet size for Host Tx endpoint0 */
-#define                 USB_EP_NI0_TXCSR  0xffc03a04   /* Control Status register for endpoint 0 */
-#define                USB_EP_NI0_RXMAXP  0xffc03a08   /* Maximum packet size for Host Rx endpoint0 */
-#define                 USB_EP_NI0_RXCSR  0xffc03a0c   /* Control Status register for Host Rx endpoint0 */
-#define               USB_EP_NI0_RXCOUNT  0xffc03a10   /* Number of bytes received in endpoint 0 FIFO */
-#define                USB_EP_NI0_TXTYPE  0xffc03a14   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint0 */
-#define            USB_EP_NI0_TXINTERVAL  0xffc03a18   /* Sets the NAK response timeout on Endpoint 0 */
-#define                USB_EP_NI0_RXTYPE  0xffc03a1c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint0 */
-#define            USB_EP_NI0_RXINTERVAL  0xffc03a20   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint0 */
-#define               USB_EP_NI0_TXCOUNT  0xffc03a28   /* Number of bytes to be written to the endpoint0 Tx FIFO */
-
-/* USB Endpoint 1 Control Registers */
-
-#define                USB_EP_NI1_TXMAXP  0xffc03a40   /* Maximum packet size for Host Tx endpoint1 */
-#define                 USB_EP_NI1_TXCSR  0xffc03a44   /* Control Status register for endpoint1 */
-#define                USB_EP_NI1_RXMAXP  0xffc03a48   /* Maximum packet size for Host Rx endpoint1 */
-#define                 USB_EP_NI1_RXCSR  0xffc03a4c   /* Control Status register for Host Rx endpoint1 */
-#define               USB_EP_NI1_RXCOUNT  0xffc03a50   /* Number of bytes received in endpoint1 FIFO */
-#define                USB_EP_NI1_TXTYPE  0xffc03a54   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint1 */
-#define            USB_EP_NI1_TXINTERVAL  0xffc03a58   /* Sets the NAK response timeout on Endpoint1 */
-#define                USB_EP_NI1_RXTYPE  0xffc03a5c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint1 */
-#define            USB_EP_NI1_RXINTERVAL  0xffc03a60   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint1 */
-#define               USB_EP_NI1_TXCOUNT  0xffc03a68   /* Number of bytes to be written to the+H102 endpoint1 Tx FIFO */
-
-/* USB Endpoint 2 Control Registers */
-
-#define                USB_EP_NI2_TXMAXP  0xffc03a80   /* Maximum packet size for Host Tx endpoint2 */
-#define                 USB_EP_NI2_TXCSR  0xffc03a84   /* Control Status register for endpoint2 */
-#define                USB_EP_NI2_RXMAXP  0xffc03a88   /* Maximum packet size for Host Rx endpoint2 */
-#define                 USB_EP_NI2_RXCSR  0xffc03a8c   /* Control Status register for Host Rx endpoint2 */
-#define               USB_EP_NI2_RXCOUNT  0xffc03a90   /* Number of bytes received in endpoint2 FIFO */
-#define                USB_EP_NI2_TXTYPE  0xffc03a94   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint2 */
-#define            USB_EP_NI2_TXINTERVAL  0xffc03a98   /* Sets the NAK response timeout on Endpoint2 */
-#define                USB_EP_NI2_RXTYPE  0xffc03a9c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint2 */
-#define            USB_EP_NI2_RXINTERVAL  0xffc03aa0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint2 */
-#define               USB_EP_NI2_TXCOUNT  0xffc03aa8   /* Number of bytes to be written to the endpoint2 Tx FIFO */
-
-/* USB Endpoint 3 Control Registers */
-
-#define                USB_EP_NI3_TXMAXP  0xffc03ac0   /* Maximum packet size for Host Tx endpoint3 */
-#define                 USB_EP_NI3_TXCSR  0xffc03ac4   /* Control Status register for endpoint3 */
-#define                USB_EP_NI3_RXMAXP  0xffc03ac8   /* Maximum packet size for Host Rx endpoint3 */
-#define                 USB_EP_NI3_RXCSR  0xffc03acc   /* Control Status register for Host Rx endpoint3 */
-#define               USB_EP_NI3_RXCOUNT  0xffc03ad0   /* Number of bytes received in endpoint3 FIFO */
-#define                USB_EP_NI3_TXTYPE  0xffc03ad4   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint3 */
-#define            USB_EP_NI3_TXINTERVAL  0xffc03ad8   /* Sets the NAK response timeout on Endpoint3 */
-#define                USB_EP_NI3_RXTYPE  0xffc03adc   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint3 */
-#define            USB_EP_NI3_RXINTERVAL  0xffc03ae0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint3 */
-#define               USB_EP_NI3_TXCOUNT  0xffc03ae8   /* Number of bytes to be written to the H124endpoint3 Tx FIFO */
-
-/* USB Endpoint 4 Control Registers */
-
-#define                USB_EP_NI4_TXMAXP  0xffc03b00   /* Maximum packet size for Host Tx endpoint4 */
-#define                 USB_EP_NI4_TXCSR  0xffc03b04   /* Control Status register for endpoint4 */
-#define                USB_EP_NI4_RXMAXP  0xffc03b08   /* Maximum packet size for Host Rx endpoint4 */
-#define                 USB_EP_NI4_RXCSR  0xffc03b0c   /* Control Status register for Host Rx endpoint4 */
-#define               USB_EP_NI4_RXCOUNT  0xffc03b10   /* Number of bytes received in endpoint4 FIFO */
-#define                USB_EP_NI4_TXTYPE  0xffc03b14   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint4 */
-#define            USB_EP_NI4_TXINTERVAL  0xffc03b18   /* Sets the NAK response timeout on Endpoint4 */
-#define                USB_EP_NI4_RXTYPE  0xffc03b1c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint4 */
-#define            USB_EP_NI4_RXINTERVAL  0xffc03b20   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint4 */
-#define               USB_EP_NI4_TXCOUNT  0xffc03b28   /* Number of bytes to be written to the endpoint4 Tx FIFO */
-
-/* USB Endpoint 5 Control Registers */
-
-#define                USB_EP_NI5_TXMAXP  0xffc03b40   /* Maximum packet size for Host Tx endpoint5 */
-#define                 USB_EP_NI5_TXCSR  0xffc03b44   /* Control Status register for endpoint5 */
-#define                USB_EP_NI5_RXMAXP  0xffc03b48   /* Maximum packet size for Host Rx endpoint5 */
-#define                 USB_EP_NI5_RXCSR  0xffc03b4c   /* Control Status register for Host Rx endpoint5 */
-#define               USB_EP_NI5_RXCOUNT  0xffc03b50   /* Number of bytes received in endpoint5 FIFO */
-#define                USB_EP_NI5_TXTYPE  0xffc03b54   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint5 */
-#define            USB_EP_NI5_TXINTERVAL  0xffc03b58   /* Sets the NAK response timeout on Endpoint5 */
-#define                USB_EP_NI5_RXTYPE  0xffc03b5c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint5 */
-#define            USB_EP_NI5_RXINTERVAL  0xffc03b60   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint5 */
-#define               USB_EP_NI5_TXCOUNT  0xffc03b68   /* Number of bytes to be written to the endpoint5 Tx FIFO */
-
-/* USB Endpoint 6 Control Registers */
-
-#define                USB_EP_NI6_TXMAXP  0xffc03b80   /* Maximum packet size for Host Tx endpoint6 */
-#define                 USB_EP_NI6_TXCSR  0xffc03b84   /* Control Status register for endpoint6 */
-#define                USB_EP_NI6_RXMAXP  0xffc03b88   /* Maximum packet size for Host Rx endpoint6 */
-#define                 USB_EP_NI6_RXCSR  0xffc03b8c   /* Control Status register for Host Rx endpoint6 */
-#define               USB_EP_NI6_RXCOUNT  0xffc03b90   /* Number of bytes received in endpoint6 FIFO */
-#define                USB_EP_NI6_TXTYPE  0xffc03b94   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint6 */
-#define            USB_EP_NI6_TXINTERVAL  0xffc03b98   /* Sets the NAK response timeout on Endpoint6 */
-#define                USB_EP_NI6_RXTYPE  0xffc03b9c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint6 */
-#define            USB_EP_NI6_RXINTERVAL  0xffc03ba0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint6 */
-#define               USB_EP_NI6_TXCOUNT  0xffc03ba8   /* Number of bytes to be written to the endpoint6 Tx FIFO */
-
-/* USB Endpoint 7 Control Registers */
-
-#define                USB_EP_NI7_TXMAXP  0xffc03bc0   /* Maximum packet size for Host Tx endpoint7 */
-#define                 USB_EP_NI7_TXCSR  0xffc03bc4   /* Control Status register for endpoint7 */
-#define                USB_EP_NI7_RXMAXP  0xffc03bc8   /* Maximum packet size for Host Rx endpoint7 */
-#define                 USB_EP_NI7_RXCSR  0xffc03bcc   /* Control Status register for Host Rx endpoint7 */
-#define               USB_EP_NI7_RXCOUNT  0xffc03bd0   /* Number of bytes received in endpoint7 FIFO */
-#define                USB_EP_NI7_TXTYPE  0xffc03bd4   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint7 */
-#define            USB_EP_NI7_TXINTERVAL  0xffc03bd8   /* Sets the NAK response timeout on Endpoint7 */
-#define                USB_EP_NI7_RXTYPE  0xffc03bdc   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint7 */
-#define            USB_EP_NI7_RXINTERVAL  0xffc03bf0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint7 */
-#define               USB_EP_NI7_TXCOUNT  0xffc03bf8   /* Number of bytes to be written to the endpoint7 Tx FIFO */
-
-#define                USB_DMA_INTERRUPT  0xffc03c00   /* Indicates pending interrupts for the DMA channels */
-
-/* USB Channel 0 Config Registers */
-
-#define                  USB_DMA0CONTROL  0xffc03c04   /* DMA master channel 0 configuration */
-#define                  USB_DMA0ADDRLOW  0xffc03c08   /* Lower 16-bits of memory source/destination address for DMA master channel 0 */
-#define                 USB_DMA0ADDRHIGH  0xffc03c0c   /* Upper 16-bits of memory source/destination address for DMA master channel 0 */
-#define                 USB_DMA0COUNTLOW  0xffc03c10   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 0 */
-#define                USB_DMA0COUNTHIGH  0xffc03c14   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 0 */
-
-/* USB Channel 1 Config Registers */
-
-#define                  USB_DMA1CONTROL  0xffc03c24   /* DMA master channel 1 configuration */
-#define                  USB_DMA1ADDRLOW  0xffc03c28   /* Lower 16-bits of memory source/destination address for DMA master channel 1 */
-#define                 USB_DMA1ADDRHIGH  0xffc03c2c   /* Upper 16-bits of memory source/destination address for DMA master channel 1 */
-#define                 USB_DMA1COUNTLOW  0xffc03c30   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 1 */
-#define                USB_DMA1COUNTHIGH  0xffc03c34   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 1 */
-
-/* USB Channel 2 Config Registers */
-
-#define                  USB_DMA2CONTROL  0xffc03c44   /* DMA master channel 2 configuration */
-#define                  USB_DMA2ADDRLOW  0xffc03c48   /* Lower 16-bits of memory source/destination address for DMA master channel 2 */
-#define                 USB_DMA2ADDRHIGH  0xffc03c4c   /* Upper 16-bits of memory source/destination address for DMA master channel 2 */
-#define                 USB_DMA2COUNTLOW  0xffc03c50   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 2 */
-#define                USB_DMA2COUNTHIGH  0xffc03c54   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 2 */
-
-/* USB Channel 3 Config Registers */
-
-#define                  USB_DMA3CONTROL  0xffc03c64   /* DMA master channel 3 configuration */
-#define                  USB_DMA3ADDRLOW  0xffc03c68   /* Lower 16-bits of memory source/destination address for DMA master channel 3 */
-#define                 USB_DMA3ADDRHIGH  0xffc03c6c   /* Upper 16-bits of memory source/destination address for DMA master channel 3 */
-#define                 USB_DMA3COUNTLOW  0xffc03c70   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 3 */
-#define                USB_DMA3COUNTHIGH  0xffc03c74   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 3 */
-
-/* USB Channel 4 Config Registers */
-
-#define                  USB_DMA4CONTROL  0xffc03c84   /* DMA master channel 4 configuration */
-#define                  USB_DMA4ADDRLOW  0xffc03c88   /* Lower 16-bits of memory source/destination address for DMA master channel 4 */
-#define                 USB_DMA4ADDRHIGH  0xffc03c8c   /* Upper 16-bits of memory source/destination address for DMA master channel 4 */
-#define                 USB_DMA4COUNTLOW  0xffc03c90   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 4 */
-#define                USB_DMA4COUNTHIGH  0xffc03c94   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 4 */
-
-/* USB Channel 5 Config Registers */
-
-#define                  USB_DMA5CONTROL  0xffc03ca4   /* DMA master channel 5 configuration */
-#define                  USB_DMA5ADDRLOW  0xffc03ca8   /* Lower 16-bits of memory source/destination address for DMA master channel 5 */
-#define                 USB_DMA5ADDRHIGH  0xffc03cac   /* Upper 16-bits of memory source/destination address for DMA master channel 5 */
-#define                 USB_DMA5COUNTLOW  0xffc03cb0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 5 */
-#define                USB_DMA5COUNTHIGH  0xffc03cb4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 5 */
-
-/* USB Channel 6 Config Registers */
-
-#define                  USB_DMA6CONTROL  0xffc03cc4   /* DMA master channel 6 configuration */
-#define                  USB_DMA6ADDRLOW  0xffc03cc8   /* Lower 16-bits of memory source/destination address for DMA master channel 6 */
-#define                 USB_DMA6ADDRHIGH  0xffc03ccc   /* Upper 16-bits of memory source/destination address for DMA master channel 6 */
-#define                 USB_DMA6COUNTLOW  0xffc03cd0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 6 */
-#define                USB_DMA6COUNTHIGH  0xffc03cd4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 6 */
-
-/* USB Channel 7 Config Registers */
-
-#define                  USB_DMA7CONTROL  0xffc03ce4   /* DMA master channel 7 configuration */
-#define                  USB_DMA7ADDRLOW  0xffc03ce8   /* Lower 16-bits of memory source/destination address for DMA master channel 7 */
-#define                 USB_DMA7ADDRHIGH  0xffc03cec   /* Upper 16-bits of memory source/destination address for DMA master channel 7 */
-#define                 USB_DMA7COUNTLOW  0xffc03cf0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 7 */
-#define                USB_DMA7COUNTHIGH  0xffc03cf4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 7 */
-
-/* Bit masks for USB_FADDR */
-
-#define          FUNCTION_ADDRESS  0x7f       /* Function address */
-
-/* Bit masks for USB_POWER */
-
-#define           ENABLE_SUSPENDM  0x1        /* enable SuspendM output */
-#define          nENABLE_SUSPENDM  0x0       
-#define              SUSPEND_MODE  0x2        /* Suspend Mode indicator */
-#define             nSUSPEND_MODE  0x0       
-#define               RESUME_MODE  0x4        /* DMA Mode */
-#define              nRESUME_MODE  0x0       
-#define                     RESET  0x8        /* Reset indicator */
-#define                    nRESET  0x0       
-#define                   HS_MODE  0x10       /* High Speed mode indicator */
-#define                  nHS_MODE  0x0       
-#define                 HS_ENABLE  0x20       /* high Speed Enable */
-#define                nHS_ENABLE  0x0       
-#define                 SOFT_CONN  0x40       /* Soft connect */
-#define                nSOFT_CONN  0x0       
-#define                ISO_UPDATE  0x80       /* Isochronous update */
-#define               nISO_UPDATE  0x0       
-
-/* Bit masks for USB_INTRTX */
-
-#define                    EP0_TX  0x1        /* Tx Endpoint 0 interrupt */
-#define                   nEP0_TX  0x0       
-#define                    EP1_TX  0x2        /* Tx Endpoint 1 interrupt */
-#define                   nEP1_TX  0x0       
-#define                    EP2_TX  0x4        /* Tx Endpoint 2 interrupt */
-#define                   nEP2_TX  0x0       
-#define                    EP3_TX  0x8        /* Tx Endpoint 3 interrupt */
-#define                   nEP3_TX  0x0       
-#define                    EP4_TX  0x10       /* Tx Endpoint 4 interrupt */
-#define                   nEP4_TX  0x0       
-#define                    EP5_TX  0x20       /* Tx Endpoint 5 interrupt */
-#define                   nEP5_TX  0x0       
-#define                    EP6_TX  0x40       /* Tx Endpoint 6 interrupt */
-#define                   nEP6_TX  0x0       
-#define                    EP7_TX  0x80       /* Tx Endpoint 7 interrupt */
-#define                   nEP7_TX  0x0       
-
-/* Bit masks for USB_INTRRX */
-
-#define                    EP1_RX  0x2        /* Rx Endpoint 1 interrupt */
-#define                   nEP1_RX  0x0       
-#define                    EP2_RX  0x4        /* Rx Endpoint 2 interrupt */
-#define                   nEP2_RX  0x0       
-#define                    EP3_RX  0x8        /* Rx Endpoint 3 interrupt */
-#define                   nEP3_RX  0x0       
-#define                    EP4_RX  0x10       /* Rx Endpoint 4 interrupt */
-#define                   nEP4_RX  0x0       
-#define                    EP5_RX  0x20       /* Rx Endpoint 5 interrupt */
-#define                   nEP5_RX  0x0       
-#define                    EP6_RX  0x40       /* Rx Endpoint 6 interrupt */
-#define                   nEP6_RX  0x0       
-#define                    EP7_RX  0x80       /* Rx Endpoint 7 interrupt */
-#define                   nEP7_RX  0x0       
-
-/* Bit masks for USB_INTRTXE */
-
-#define                  EP0_TX_E  0x1        /* Endpoint 0 interrupt Enable */
-#define                 nEP0_TX_E  0x0       
-#define                  EP1_TX_E  0x2        /* Tx Endpoint 1 interrupt  Enable */
-#define                 nEP1_TX_E  0x0       
-#define                  EP2_TX_E  0x4        /* Tx Endpoint 2 interrupt  Enable */
-#define                 nEP2_TX_E  0x0       
-#define                  EP3_TX_E  0x8        /* Tx Endpoint 3 interrupt  Enable */
-#define                 nEP3_TX_E  0x0       
-#define                  EP4_TX_E  0x10       /* Tx Endpoint 4 interrupt  Enable */
-#define                 nEP4_TX_E  0x0       
-#define                  EP5_TX_E  0x20       /* Tx Endpoint 5 interrupt  Enable */
-#define                 nEP5_TX_E  0x0       
-#define                  EP6_TX_E  0x40       /* Tx Endpoint 6 interrupt  Enable */
-#define                 nEP6_TX_E  0x0       
-#define                  EP7_TX_E  0x80       /* Tx Endpoint 7 interrupt  Enable */
-#define                 nEP7_TX_E  0x0       
-
-/* Bit masks for USB_INTRRXE */
-
-#define                  EP1_RX_E  0x2        /* Rx Endpoint 1 interrupt  Enable */
-#define                 nEP1_RX_E  0x0       
-#define                  EP2_RX_E  0x4        /* Rx Endpoint 2 interrupt  Enable */
-#define                 nEP2_RX_E  0x0       
-#define                  EP3_RX_E  0x8        /* Rx Endpoint 3 interrupt  Enable */
-#define                 nEP3_RX_E  0x0       
-#define                  EP4_RX_E  0x10       /* Rx Endpoint 4 interrupt  Enable */
-#define                 nEP4_RX_E  0x0       
-#define                  EP5_RX_E  0x20       /* Rx Endpoint 5 interrupt  Enable */
-#define                 nEP5_RX_E  0x0       
-#define                  EP6_RX_E  0x40       /* Rx Endpoint 6 interrupt  Enable */
-#define                 nEP6_RX_E  0x0       
-#define                  EP7_RX_E  0x80       /* Rx Endpoint 7 interrupt  Enable */
-#define                 nEP7_RX_E  0x0       
-
-/* Bit masks for USB_INTRUSB */
-
-#define                 SUSPEND_B  0x1        /* Suspend indicator */
-#define                nSUSPEND_B  0x0       
-#define                  RESUME_B  0x2        /* Resume indicator */
-#define                 nRESUME_B  0x0       
-#define          RESET_OR_BABLE_B  0x4        /* Reset/babble indicator */
-#define         nRESET_OR_BABLE_B  0x0       
-#define                     SOF_B  0x8        /* Start of frame */
-#define                    nSOF_B  0x0       
-#define                    CONN_B  0x10       /* Connection indicator */
-#define                   nCONN_B  0x0       
-#define                  DISCON_B  0x20       /* Disconnect indicator */
-#define                 nDISCON_B  0x0       
-#define             SESSION_REQ_B  0x40       /* Session Request */
-#define            nSESSION_REQ_B  0x0       
-#define              VBUS_ERROR_B  0x80       /* Vbus threshold indicator */
-#define             nVBUS_ERROR_B  0x0       
-
-/* Bit masks for USB_INTRUSBE */
-
-#define                SUSPEND_BE  0x1        /* Suspend indicator int enable */
-#define               nSUSPEND_BE  0x0       
-#define                 RESUME_BE  0x2        /* Resume indicator int enable */
-#define                nRESUME_BE  0x0       
-#define         RESET_OR_BABLE_BE  0x4        /* Reset/babble indicator int enable */
-#define        nRESET_OR_BABLE_BE  0x0       
-#define                    SOF_BE  0x8        /* Start of frame int enable */
-#define                   nSOF_BE  0x0       
-#define                   CONN_BE  0x10       /* Connection indicator int enable */
-#define                  nCONN_BE  0x0       
-#define                 DISCON_BE  0x20       /* Disconnect indicator int enable */
-#define                nDISCON_BE  0x0       
-#define            SESSION_REQ_BE  0x40       /* Session Request int enable */
-#define           nSESSION_REQ_BE  0x0       
-#define             VBUS_ERROR_BE  0x80       /* Vbus threshold indicator int enable */
-#define            nVBUS_ERROR_BE  0x0       
-
-/* Bit masks for USB_FRAME */
-
-#define              FRAME_NUMBER  0x7ff      /* Frame number */
-
-/* Bit masks for USB_INDEX */
-
-#define         SELECTED_ENDPOINT  0xf        /* selected endpoint */
-
-/* Bit masks for USB_GLOBAL_CTL */
-
-#define                GLOBAL_ENA  0x1        /* enables USB module */
-#define               nGLOBAL_ENA  0x0       
-#define                EP1_TX_ENA  0x2        /* Transmit endpoint 1 enable */
-#define               nEP1_TX_ENA  0x0       
-#define                EP2_TX_ENA  0x4        /* Transmit endpoint 2 enable */
-#define               nEP2_TX_ENA  0x0       
-#define                EP3_TX_ENA  0x8        /* Transmit endpoint 3 enable */
-#define               nEP3_TX_ENA  0x0       
-#define                EP4_TX_ENA  0x10       /* Transmit endpoint 4 enable */
-#define               nEP4_TX_ENA  0x0       
-#define                EP5_TX_ENA  0x20       /* Transmit endpoint 5 enable */
-#define               nEP5_TX_ENA  0x0       
-#define                EP6_TX_ENA  0x40       /* Transmit endpoint 6 enable */
-#define               nEP6_TX_ENA  0x0       
-#define                EP7_TX_ENA  0x80       /* Transmit endpoint 7 enable */
-#define               nEP7_TX_ENA  0x0       
-#define                EP1_RX_ENA  0x100      /* Receive endpoint 1 enable */
-#define               nEP1_RX_ENA  0x0       
-#define                EP2_RX_ENA  0x200      /* Receive endpoint 2 enable */
-#define               nEP2_RX_ENA  0x0       
-#define                EP3_RX_ENA  0x400      /* Receive endpoint 3 enable */
-#define               nEP3_RX_ENA  0x0       
-#define                EP4_RX_ENA  0x800      /* Receive endpoint 4 enable */
-#define               nEP4_RX_ENA  0x0       
-#define                EP5_RX_ENA  0x1000     /* Receive endpoint 5 enable */
-#define               nEP5_RX_ENA  0x0       
-#define                EP6_RX_ENA  0x2000     /* Receive endpoint 6 enable */
-#define               nEP6_RX_ENA  0x0       
-#define                EP7_RX_ENA  0x4000     /* Receive endpoint 7 enable */
-#define               nEP7_RX_ENA  0x0       
-
-/* Bit masks for USB_OTG_DEV_CTL */
-
-#define                   SESSION  0x1        /* session indicator */
-#define                  nSESSION  0x0       
-#define                  HOST_REQ  0x2        /* Host negotiation request */
-#define                 nHOST_REQ  0x0       
-#define                 HOST_MODE  0x4        /* indicates USBDRC is a host */
-#define                nHOST_MODE  0x0       
-#define                     VBUS0  0x8        /* Vbus level indicator[0] */
-#define                    nVBUS0  0x0       
-#define                     VBUS1  0x10       /* Vbus level indicator[1] */
-#define                    nVBUS1  0x0       
-#define                     LSDEV  0x20       /* Low-speed indicator */
-#define                    nLSDEV  0x0       
-#define                     FSDEV  0x40       /* Full or High-speed indicator */
-#define                    nFSDEV  0x0       
-#define                  B_DEVICE  0x80       /* A' or 'B' device indicator */
-#define                 nB_DEVICE  0x0       
-
-/* Bit masks for USB_OTG_VBUS_IRQ */
-
-#define             DRIVE_VBUS_ON  0x1        /* indicator to drive VBUS control circuit */
-#define            nDRIVE_VBUS_ON  0x0       
-#define            DRIVE_VBUS_OFF  0x2        /* indicator to shut off charge pump */
-#define           nDRIVE_VBUS_OFF  0x0       
-#define           CHRG_VBUS_START  0x4        /* indicator for external circuit to start charging VBUS */
-#define          nCHRG_VBUS_START  0x0       
-#define             CHRG_VBUS_END  0x8        /* indicator for external circuit to end charging VBUS */
-#define            nCHRG_VBUS_END  0x0       
-#define        DISCHRG_VBUS_START  0x10       /* indicator to start discharging VBUS */
-#define       nDISCHRG_VBUS_START  0x0       
-#define          DISCHRG_VBUS_END  0x20       /* indicator to stop discharging VBUS */
-#define         nDISCHRG_VBUS_END  0x0       
-
-/* Bit masks for USB_OTG_VBUS_MASK */
-
-#define         DRIVE_VBUS_ON_ENA  0x1        /* enable DRIVE_VBUS_ON interrupt */
-#define        nDRIVE_VBUS_ON_ENA  0x0       
-#define        DRIVE_VBUS_OFF_ENA  0x2        /* enable DRIVE_VBUS_OFF interrupt */
-#define       nDRIVE_VBUS_OFF_ENA  0x0       
-#define       CHRG_VBUS_START_ENA  0x4        /* enable CHRG_VBUS_START interrupt */
-#define      nCHRG_VBUS_START_ENA  0x0       
-#define         CHRG_VBUS_END_ENA  0x8        /* enable CHRG_VBUS_END interrupt */
-#define        nCHRG_VBUS_END_ENA  0x0       
-#define    DISCHRG_VBUS_START_ENA  0x10       /* enable DISCHRG_VBUS_START interrupt */
-#define   nDISCHRG_VBUS_START_ENA  0x0       
-#define      DISCHRG_VBUS_END_ENA  0x20       /* enable DISCHRG_VBUS_END interrupt */
-#define     nDISCHRG_VBUS_END_ENA  0x0       
-
-/* Bit masks for USB_CSR0 */
-
-#define                  RXPKTRDY  0x1        /* data packet receive indicator */
-#define                 nRXPKTRDY  0x0       
-#define                  TXPKTRDY  0x2        /* data packet in FIFO indicator */
-#define                 nTXPKTRDY  0x0       
-#define                STALL_SENT  0x4        /* STALL handshake sent */
-#define               nSTALL_SENT  0x0       
-#define                   DATAEND  0x8        /* Data end indicator */
-#define                  nDATAEND  0x0       
-#define                  SETUPEND  0x10       /* Setup end */
-#define                 nSETUPEND  0x0       
-#define                 SENDSTALL  0x20       /* Send STALL handshake */
-#define                nSENDSTALL  0x0       
-#define         SERVICED_RXPKTRDY  0x40       /* used to clear the RxPktRdy bit */
-#define        nSERVICED_RXPKTRDY  0x0       
-#define         SERVICED_SETUPEND  0x80       /* used to clear the SetupEnd bit */
-#define        nSERVICED_SETUPEND  0x0       
-#define                 FLUSHFIFO  0x100      /* flush endpoint FIFO */
-#define                nFLUSHFIFO  0x0       
-#define          STALL_RECEIVED_H  0x4        /* STALL handshake received host mode */
-#define         nSTALL_RECEIVED_H  0x0       
-#define                SETUPPKT_H  0x8        /* send Setup token host mode */
-#define               nSETUPPKT_H  0x0       
-#define                   ERROR_H  0x10       /* timeout error indicator host mode */
-#define                  nERROR_H  0x0       
-#define                  REQPKT_H  0x20       /* Request an IN transaction host mode */
-#define                 nREQPKT_H  0x0       
-#define               STATUSPKT_H  0x40       /* Status stage transaction host mode */
-#define              nSTATUSPKT_H  0x0       
-#define             NAK_TIMEOUT_H  0x80       /* EP0 halted after a NAK host mode */
-#define            nNAK_TIMEOUT_H  0x0       
-
-/* Bit masks for USB_COUNT0 */
-
-#define              EP0_RX_COUNT  0x7f       /* number of received bytes in EP0 FIFO */
-
-/* Bit masks for USB_NAKLIMIT0 */
-
-#define             EP0_NAK_LIMIT  0x1f       /* number of frames/micro frames after which EP0 timeouts */
-
-/* Bit masks for USB_TX_MAX_PACKET */
-
-#define         MAX_PACKET_SIZE_T  0x7ff      /* maximum data pay load in a frame */
-
-/* Bit masks for USB_RX_MAX_PACKET */
-
-#define         MAX_PACKET_SIZE_R  0x7ff      /* maximum data pay load in a frame */
-
-/* Bit masks for USB_TXCSR */
-
-#define                TXPKTRDY_T  0x1        /* data packet in FIFO indicator */
-#define               nTXPKTRDY_T  0x0       
-#define          FIFO_NOT_EMPTY_T  0x2        /* FIFO not empty */
-#define         nFIFO_NOT_EMPTY_T  0x0       
-#define                UNDERRUN_T  0x4        /* TxPktRdy not set  for an IN token */
-#define               nUNDERRUN_T  0x0       
-#define               FLUSHFIFO_T  0x8        /* flush endpoint FIFO */
-#define              nFLUSHFIFO_T  0x0       
-#define              STALL_SEND_T  0x10       /* issue a Stall handshake */
-#define             nSTALL_SEND_T  0x0       
-#define              STALL_SENT_T  0x20       /* Stall handshake transmitted */
-#define             nSTALL_SENT_T  0x0       
-#define        CLEAR_DATATOGGLE_T  0x40       /* clear endpoint data toggle */
-#define       nCLEAR_DATATOGGLE_T  0x0       
-#define                INCOMPTX_T  0x80       /* indicates that a large packet is split */
-#define               nINCOMPTX_T  0x0       
-#define              DMAREQMODE_T  0x400      /* DMA mode (0 or 1) selection */
-#define             nDMAREQMODE_T  0x0       
-#define        FORCE_DATATOGGLE_T  0x800      /* Force data toggle */
-#define       nFORCE_DATATOGGLE_T  0x0       
-#define              DMAREQ_ENA_T  0x1000     /* Enable DMA request for Tx EP */
-#define             nDMAREQ_ENA_T  0x0       
-#define                     ISO_T  0x4000     /* enable Isochronous transfers */
-#define                    nISO_T  0x0       
-#define                 AUTOSET_T  0x8000     /* allows TxPktRdy to be set automatically */
-#define                nAUTOSET_T  0x0       
-#define                  ERROR_TH  0x4        /* error condition host mode */
-#define                 nERROR_TH  0x0       
-#define         STALL_RECEIVED_TH  0x20       /* Stall handshake received host mode */
-#define        nSTALL_RECEIVED_TH  0x0       
-#define            NAK_TIMEOUT_TH  0x80       /* NAK timeout host mode */
-#define           nNAK_TIMEOUT_TH  0x0       
-
-/* Bit masks for USB_TXCOUNT */
-
-#define                  TX_COUNT  0x1fff     /* Number of bytes to be written to the selected endpoint Tx FIFO */
-
-/* Bit masks for USB_RXCSR */
-
-#define                RXPKTRDY_R  0x1        /* data packet in FIFO indicator */
-#define               nRXPKTRDY_R  0x0       
-#define               FIFO_FULL_R  0x2        /* FIFO not empty */
-#define              nFIFO_FULL_R  0x0       
-#define                 OVERRUN_R  0x4        /* TxPktRdy not set  for an IN token */
-#define                nOVERRUN_R  0x0       
-#define               DATAERROR_R  0x8        /* Out packet cannot be loaded into Rx  FIFO */
-#define              nDATAERROR_R  0x0       
-#define               FLUSHFIFO_R  0x10       /* flush endpoint FIFO */
-#define              nFLUSHFIFO_R  0x0       
-#define              STALL_SEND_R  0x20       /* issue a Stall handshake */
-#define             nSTALL_SEND_R  0x0       
-#define              STALL_SENT_R  0x40       /* Stall handshake transmitted */
-#define             nSTALL_SENT_R  0x0       
-#define        CLEAR_DATATOGGLE_R  0x80       /* clear endpoint data toggle */
-#define       nCLEAR_DATATOGGLE_R  0x0       
-#define                INCOMPRX_R  0x100      /* indicates that a large packet is split */
-#define               nINCOMPRX_R  0x0       
-#define              DMAREQMODE_R  0x800      /* DMA mode (0 or 1) selection */
-#define             nDMAREQMODE_R  0x0       
-#define                 DISNYET_R  0x1000     /* disable Nyet handshakes */
-#define                nDISNYET_R  0x0       
-#define              DMAREQ_ENA_R  0x2000     /* Enable DMA request for Tx EP */
-#define             nDMAREQ_ENA_R  0x0       
-#define                     ISO_R  0x4000     /* enable Isochronous transfers */
-#define                    nISO_R  0x0       
-#define               AUTOCLEAR_R  0x8000     /* allows TxPktRdy to be set automatically */
-#define              nAUTOCLEAR_R  0x0       
-#define                  ERROR_RH  0x4        /* TxPktRdy not set  for an IN token host mode */
-#define                 nERROR_RH  0x0       
-#define                 REQPKT_RH  0x20       /* request an IN transaction host mode */
-#define                nREQPKT_RH  0x0       
-#define         STALL_RECEIVED_RH  0x40       /* Stall handshake received host mode */
-#define        nSTALL_RECEIVED_RH  0x0       
-#define               INCOMPRX_RH  0x100      /* indicates that a large packet is split host mode */
-#define              nINCOMPRX_RH  0x0       
-#define             DMAREQMODE_RH  0x800      /* DMA mode (0 or 1) selection host mode */
-#define            nDMAREQMODE_RH  0x0       
-#define                AUTOREQ_RH  0x4000     /* sets ReqPkt automatically host mode */
-#define               nAUTOREQ_RH  0x0       
-
-/* Bit masks for USB_RXCOUNT */
-
-#define                  RX_COUNT  0x1fff     /* Number of received bytes in the packet in the Rx FIFO */
-
-/* Bit masks for USB_TXTYPE */
-
-#define            TARGET_EP_NO_T  0xf        /* EP number */
-#define                PROTOCOL_T  0xc        /* transfer type */
-
-/* Bit masks for USB_TXINTERVAL */
-
-#define          TX_POLL_INTERVAL  0xff       /* polling interval for selected Tx EP */
-
-/* Bit masks for USB_RXTYPE */
-
-#define            TARGET_EP_NO_R  0xf        /* EP number */
-#define                PROTOCOL_R  0xc        /* transfer type */
-
-/* Bit masks for USB_RXINTERVAL */
-
-#define          RX_POLL_INTERVAL  0xff       /* polling interval for selected Rx EP */
-
-/* Bit masks for USB_DMA_INTERRUPT */
-
-#define                  DMA0_INT  0x1        /* DMA0 pending interrupt */
-#define                 nDMA0_INT  0x0       
-#define                  DMA1_INT  0x2        /* DMA1 pending interrupt */
-#define                 nDMA1_INT  0x0       
-#define                  DMA2_INT  0x4        /* DMA2 pending interrupt */
-#define                 nDMA2_INT  0x0       
-#define                  DMA3_INT  0x8        /* DMA3 pending interrupt */
-#define                 nDMA3_INT  0x0       
-#define                  DMA4_INT  0x10       /* DMA4 pending interrupt */
-#define                 nDMA4_INT  0x0       
-#define                  DMA5_INT  0x20       /* DMA5 pending interrupt */
-#define                 nDMA5_INT  0x0       
-#define                  DMA6_INT  0x40       /* DMA6 pending interrupt */
-#define                 nDMA6_INT  0x0       
-#define                  DMA7_INT  0x80       /* DMA7 pending interrupt */
-#define                 nDMA7_INT  0x0       
-
-/* Bit masks for USB_DMAxCONTROL */
-
-#define                   DMA_ENA  0x1        /* DMA enable */
-#define                  nDMA_ENA  0x0       
-#define                 DIRECTION  0x2        /* direction of DMA transfer */
-#define                nDIRECTION  0x0       
-#define                      MODE  0x4        /* DMA Bus error */
-#define                     nMODE  0x0       
-#define                   INT_ENA  0x8        /* Interrupt enable */
-#define                  nINT_ENA  0x0       
-#define                     EPNUM  0xf0       /* EP number */
-#define                  BUSERROR  0x100      /* DMA Bus error */
-#define                 nBUSERROR  0x0       
-
-/* Bit masks for USB_DMAxADDRHIGH */
-
-#define             DMA_ADDR_HIGH  0xffff     /* Upper 16-bits of memory source/destination address for the DMA master channel */
-
-/* Bit masks for USB_DMAxADDRLOW */
-
-#define              DMA_ADDR_LOW  0xffff     /* Lower 16-bits of memory source/destination address for the DMA master channel */
-
-/* Bit masks for USB_DMAxCOUNTHIGH */
-
-#define            DMA_COUNT_HIGH  0xffff     /* Upper 16-bits of byte count of DMA transfer for DMA master channel */
-
-/* Bit masks for USB_DMAxCOUNTLOW */
-
-#define             DMA_COUNT_LOW  0xffff     /* Lower 16-bits of byte count of DMA transfer for DMA master channel */
-
 #endif /* _DEF_BF527_H */
index b9dbb73d7ef0ac1faa31c145040d1cb513f661dc..8b18b535921061dc90e4b63770348c56a5f2a873 100644 (file)
 **                             modifier UNLESS the lower order bits are saved and ORed back in when
 **                             the macro is used.
 *************************************************************************************/
-/*
-** ********************* PLL AND RESET MASKS ****************************************/
-/* PLL_CTL Masks                                                                                                                                       */
-#define DF                             0x0001  /* 0: PLL = CLKIN, 1: PLL = CLKIN/2                                     */
-#define PLL_OFF                        0x0002  /* PLL Not Powered                                                                      */
-#define STOPCK                 0x0008  /* Core Clock Off                                                                       */
-#define PDWN                   0x0020  /* Enter Deep Sleep Mode                                                        */
-#define        IN_DELAY                0x0040  /* Add 200ps Delay To EBIU Input Latches                        */
-#define        OUT_DELAY               0x0080  /* Add 200ps Delay To EBIU Output Signals                       */
-#define BYPASS                 0x0100  /* Bypass the PLL                                                                       */
-#define        MSEL                    0x7E00  /* Multiplier Select For CCLK/VCO Factors                       */
-/* PLL_CTL Macros (Only Use With Logic OR While Setting Lower Order Bits)                      */
-#define        SET_MSEL(x)             (((x)&0x3F) << 0x9)     /* Set MSEL = 0-63 --> VCO = CLKIN*MSEL         */
-
-/* PLL_DIV Masks                                                                                                               */
-#define SSEL                   0x000F  /* System Select                                                */
-#define        CSEL                    0x0030  /* Core Select                                                  */
-#define CSEL_DIV1              0x0000  /*              CCLK = VCO / 1                                  */
-#define CSEL_DIV2              0x0010  /*              CCLK = VCO / 2                                  */
-#define        CSEL_DIV4               0x0020  /*              CCLK = VCO / 4                                  */
-#define        CSEL_DIV8               0x0030  /*              CCLK = VCO / 8                                  */
-/* PLL_DIV Macros                                                                                                              */
-#define SET_SSEL(x)            ((x)&0xF)               /* Set SSEL = 0-15 --> SCLK = VCO/SSEL  */
-
-/* VR_CTL Masks        */
-#define        FREQ                    0x3000  /* Switching Oscillator Frequency For Regulator */
-#define        HIBERNATE               0x0000  /*              Powerdown/Bypass On-Board Regulation    */
-
-#define        VLEV                    0x00F0  /* Internal Voltage Level                                       */
-#define        VLEV_085                0x0060  /*              VLEV = 0.85 V (-5% - +10% Accuracy)     */
-#define        VLEV_090                0x0070  /*              VLEV = 0.90 V (-5% - +10% Accuracy)     */
-#define        VLEV_095                0x0080  /*              VLEV = 0.95 V (-5% - +10% Accuracy)     */
-#define        VLEV_100                0x0090  /*              VLEV = 1.00 V (-5% - +10% Accuracy)     */
-#define        VLEV_105                0x00A0  /*              VLEV = 1.05 V (-5% - +10% Accuracy)     */
-#define        VLEV_110                0x00B0  /*              VLEV = 1.10 V (-5% - +10% Accuracy)     */
-#define        VLEV_115                0x00C0  /*              VLEV = 1.15 V (-5% - +10% Accuracy)     */
-#define        VLEV_120                0x00D0  /*              VLEV = 1.20 V (-5% - +10% Accuracy)     */
-#define        VLEV_125                0x00E0  /*              VLEV = 1.25 V (-5% - +10% Accuracy)     */
-#define        VLEV_130                0x00F0  /*              VLEV = 1.30 V (-5% - +10% Accuracy)     */
-
-#define        WAKE                    0x0100  /* Enable RTC/Reset Wakeup From Hibernate       */
-#define        USBWE                   0x0200  /* Enable USB Wakeup From Hibernate                     */
-#define        PHYWE                   0x0400  /* Enable PHY Wakeup From Hibernate                     */
-#define        CLKBUFOE                0x4000  /* CLKIN Buffer Output Enable */
-#define        PHYCLKOE                CLKBUFOE        /* Alternative legacy name for the above */
-#define        SCKELOW         0x8000  /* Enable Drive CKE Low During Reset            */
-
-/* PLL_STAT Masks                                                                                                                                      */
-#define ACTIVE_PLLENABLED      0x0001  /* Processor In Active Mode With PLL Enabled    */
-#define        FULL_ON                         0x0002  /* Processor In Full On Mode                                    */
-#define ACTIVE_PLLDISABLED     0x0004  /* Processor In Active Mode With PLL Disabled   */
-#define        PLL_LOCKED                      0x0020  /* PLL_LOCKCNT Has Been Reached                                 */
 
 /* CHIPID Masks */
 #define CHIPID_VERSION         0xF0000000
 #define IWR_DISABLE(x) (0xFFFFFFFF ^ (1 << ((x)&0x1F)))        /* Wakeup Disable Peripheral #x         */
 
 
-/* ********* WATCHDOG TIMER MASKS ******************** */
-
-/* Watchdog Timer WDOG_CTL Register Masks */
-
-#define WDEV(x) (((x)<<1) & 0x0006) /* event generated on roll over */
-#define WDEV_RESET 0x0000 /* generate reset event on roll over */
-#define WDEV_NMI 0x0002 /* generate NMI event on roll over */
-#define WDEV_GPI 0x0004 /* generate GP IRQ on roll over */
-#define WDEV_NONE 0x0006 /* no event on roll over */
-#define WDEN 0x0FF0 /* enable watchdog */
-#define WDDIS 0x0AD0 /* disable watchdog */
-#define WDRO 0x8000 /* watchdog rolled over latch */
-
-/* depreciated WDOG_CTL Register Masks for legacy code */
-
-
-#define ICTL WDEV
-#define ENABLE_RESET WDEV_RESET
-#define WDOG_RESET WDEV_RESET
-#define ENABLE_NMI WDEV_NMI
-#define WDOG_NMI WDEV_NMI
-#define ENABLE_GPI WDEV_GPI
-#define WDOG_GPI WDEV_GPI
-#define DISABLE_EVT WDEV_NONE
-#define WDOG_NONE WDEV_NONE
-
-#define TMR_EN WDEN
-#define TMR_DIS WDDIS
-#define TRO WDRO
-#define ICTL_P0 0x01
- #define ICTL_P1 0x02
-#define TRO_P 0x0F
-
-
-
-/* ***************  REAL TIME CLOCK MASKS  **************************/
-/* RTC_STAT and RTC_ALARM Masks                                                                                */
-#define        RTC_SEC                         0x0000003F      /* Real-Time Clock Seconds      */
-#define        RTC_MIN                         0x00000FC0      /* Real-Time Clock Minutes      */
-#define        RTC_HR                          0x0001F000      /* Real-Time Clock Hours        */
-#define        RTC_DAY                         0xFFFE0000      /* Real-Time Clock Days         */
-
-/* RTC_ALARM Macro                     z=day           y=hr    x=min   w=sec           */
-#define SET_ALARM(z,y,x,w)     ((((z)&0x7FFF)<<0x11)|(((y)&0x1F)<<0xC)|(((x)&0x3F)<<0x6)|((w)&0x3F))
-
-/* RTC_ICTL and RTC_ISTAT Masks                                                                                                                                                */
-#define        STOPWATCH                       0x0001          /* Stopwatch Interrupt Enable                                                           */
-#define        ALARM                           0x0002          /* Alarm Interrupt Enable                                                                       */
-#define        SECOND                          0x0004          /* Seconds (1 Hz) Interrupt Enable                                                      */
-#define        MINUTE                          0x0008          /* Minutes Interrupt Enable                                                                     */
-#define        HOUR                            0x0010          /* Hours Interrupt Enable                                                                       */
-#define        DAY                                     0x0020          /* 24 Hours (Days) Interrupt Enable                                                     */
-#define        DAY_ALARM                       0x0040          /* Day Alarm (Day, Hour, Minute, Second) Interrupt Enable       */
-#define        WRITE_PENDING           0x4000          /* Write Pending Status                                                                         */
-#define        WRITE_COMPLETE          0x8000          /* Write Complete Interrupt Enable                                                      */
-
-/* RTC_FAST / RTC_PREN Mask                                                                                            */
-#define PREN                           0x0001  /* Enable Prescaler, RTC Runs @1 Hz     */
-
-
 /* ************** UART CONTROLLER MASKS *************************/
 /* UARTx_LCR Masks                                                                                             */
 #define WLS(x)         (((x)-5) & 0x03)        /* Word Length Select */
 
 
 /* **************************  DMA CONTROLLER MASKS  ********************************/
-/* DMAx_CONFIG, MDMA_yy_CONFIG Masks                                                                                           */
-#define DMAEN                  0x0001          /* DMA Channel Enable                                                   */
-#define WNR                            0x0002          /* Channel Direction (W/R*)                                             */
-#define WDSIZE_8               0x0000          /* Transfer Word Size = 8                                               */
-#define WDSIZE_16              0x0004          /* Transfer Word Size = 16                                              */
-#define WDSIZE_32              0x0008          /* Transfer Word Size = 32                                              */
-#define DMA2D                  0x0010          /* DMA Mode (2D/1D*)                                                    */
-#define RESTART                        0x0020          /* DMA Buffer Clear                                                             */
-#define DI_SEL                 0x0040          /* Data Interrupt Timing Select                                 */
-#define DI_EN                  0x0080          /* Data Interrupt Enable                                                */
-#define NDSIZE_0               0x0000          /* Next Descriptor Size = 0 (Stop/Autobuffer)   */
-#define NDSIZE_1               0x0100          /* Next Descriptor Size = 1                                             */
-#define NDSIZE_2               0x0200          /* Next Descriptor Size = 2                                             */
-#define NDSIZE_3               0x0300          /* Next Descriptor Size = 3                                             */
-#define NDSIZE_4               0x0400          /* Next Descriptor Size = 4                                             */
-#define NDSIZE_5               0x0500          /* Next Descriptor Size = 5                                             */
-#define NDSIZE_6               0x0600          /* Next Descriptor Size = 6                                             */
-#define NDSIZE_7               0x0700          /* Next Descriptor Size = 7                                             */
-#define NDSIZE_8               0x0800          /* Next Descriptor Size = 8                                             */
-#define NDSIZE_9               0x0900          /* Next Descriptor Size = 9                                             */
-#define NDSIZE                 0x0900  /* Next Descriptor Size */
-#define DMAFLOW                        0x7000  /* Flow Control */
-#define DMAFLOW_STOP           0x0000          /* Stop Mode                                                                    */
-#define DMAFLOW_AUTO           0x1000          /* Autobuffer Mode                                                              */
-#define DMAFLOW_ARRAY          0x4000          /* Descriptor Array Mode                                                */
-#define DMAFLOW_SMALL          0x6000          /* Small Model Descriptor List Mode                             */
-#define DMAFLOW_LARGE          0x7000          /* Large Model Descriptor List Mode                             */
 
 /* DMAx_PERIPHERAL_MAP, MDMA_yy_PERIPHERAL_MAP Masks                                                           */
 #define CTYPE                  0x0040  /* DMA Channel Type Indicator (Memory/Peripheral*)      */
 #define        PMAP_UART1RX    0xA000  /*              UART1 Port Receive DMA                                          */
 #define        PMAP_UART1TX    0xB000  /*              UART1 Port Transmit DMA                                         */
 
-/* DMAx_IRQ_STATUS, MDMA_yy_IRQ_STATUS Masks                                           */
-#define DMA_DONE               0x0001  /* DMA Completion Interrupt Status      */
-#define DMA_ERR                        0x0002  /* DMA Error Interrupt Status           */
-#define DFETCH                 0x0004  /* DMA Descriptor Fetch Indicator       */
-#define DMA_RUN                        0x0008  /* DMA Channel Running Indicator        */
-
-
 /*  ************  PARALLEL PERIPHERAL INTERFACE (PPI) MASKS *************/
 /*  PPI_CONTROL Masks                                                                                                  */
 #define PORT_EN                        0x0001          /* PPI Port Enable                                      */
 #define BNDMODE_CAPT     0x2000  /* boundary capture mode */
 #define BNDMODE_AEXT     0x3000  /* boundary auto-extend mode */
 
-/* Bit masks for OTP_CONTROL */
-
-#define                FUSE_FADDR  0x1ff      /* OTP/Fuse Address */
-#define                      FIEN  0x800      /* OTP/Fuse Interrupt Enable */
-#define                     nFIEN  0x0
-#define                  FTESTDEC  0x1000     /* OTP/Fuse Test Decoder */
-#define                 nFTESTDEC  0x0
-#define                   FWRTEST  0x2000     /* OTP/Fuse Write Test */
-#define                  nFWRTEST  0x0
-#define                     FRDEN  0x4000     /* OTP/Fuse Read Enable */
-#define                    nFRDEN  0x0
-#define                     FWREN  0x8000     /* OTP/Fuse Write Enable */
-#define                    nFWREN  0x0
-
-/* Bit masks for OTP_BEN */
-
-#define                      FBEN  0xffff     /* OTP/Fuse Byte Enable */
-
-/* Bit masks for OTP_STATUS */
-
-#define                     FCOMP  0x1        /* OTP/Fuse Access Complete */
-#define                    nFCOMP  0x0
-#define                    FERROR  0x2        /* OTP/Fuse Access Error */
-#define                   nFERROR  0x0
-#define                  MMRGLOAD  0x10       /* Memory Mapped Register Gasket Load */
-#define                 nMMRGLOAD  0x0
-#define                  MMRGLOCK  0x20       /* Memory Mapped Register Gasket Lock */
-#define                 nMMRGLOCK  0x0
-#define                    FPGMEN  0x40       /* OTP/Fuse Program Enable */
-#define                   nFPGMEN  0x0
-
-/* Bit masks for OTP_TIMING */
-
-#define                   USECDIV  0xff       /* Micro Second Divider */
-#define                   READACC  0x7f00     /* Read Access Time */
-#define                   CPUMPRL  0x38000    /* Charge Pump Release Time */
-#define                   CPUMPSU  0xc0000    /* Charge Pump Setup Time */
-#define                   CPUMPHD  0xf00000   /* Charge Pump Hold Time */
-#define                   PGMTIME  0xff000000 /* Program Time */
-
 /* Bit masks for SECURE_SYSSWT */
 
 #define                   EMUDABL  0x1        /* Emulation Disable. */
index 43f43a095a996744082b35f0c24152ac0adcb0cd..4adceb0bdb6d3c0dc8f762bb9c921d20516ded04 100644 (file)
@@ -166,7 +166,6 @@ static struct bfin5xx_spi_chip spi_flash_chip_info = {
 #if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
 /* SPI ADC chip */
 static struct bfin5xx_spi_chip spi_adc_chip_info = {
-       .ctl_reg = 0x1000,
        .enable_dma = 1,         /* use dma transfer with this chip*/
        .bits_per_word = 16,
 };
@@ -174,7 +173,6 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
 
 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
-       .ctl_reg = 0x1000,
        .enable_dma = 0,
        .bits_per_word = 16,
 };
@@ -258,12 +256,6 @@ static struct platform_device bfin_spi0_device = {
 };
 #endif  /* spi master and devices */
 
-#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
-static struct platform_device bfin_fb_device = {
-       .name = "bf537-fb",
-};
-#endif
-
 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
 static struct resource bfin_uart_resources[] = {
        {
index 644be5e5ab6f4008568c69ba35dbf595fb53cc69..8ec42ba35b9e4675ca627fcf5747359b8c4d2b7e 100644 (file)
@@ -20,6 +20,7 @@
 #endif
 #include <asm/irq.h>
 #include <asm/bfin5xx_spi.h>
+#include <asm/portmux.h>
 
 /*
  * Name the Board for the /proc/cpuinfo
@@ -107,20 +108,6 @@ static struct platform_device dm9000_device2 = {
 
 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
-/*
- * CPOL (Clock Polarity)
- *  0 - Active high SCK
- *  1 - Active low SCK
- *  CPHA (Clock Phase) Selects transfer format and operation mode
- *  0 - SCLK toggles from middle of the first data bit, slave select
- *      pins controlled by hardware.
- *  1 - SCLK toggles from beginning of first data bit, slave select
- *      pins controller by user software.
- *     .ctl_reg = 0x1c00,               *  CPOL=1,CPHA=1,Sandisk 1G work
- * NO NO       .ctl_reg = 0x1800,               *  CPOL=1,CPHA=0
- * NO NO       .ctl_reg = 0x1400,               *  CPOL=0,CPHA=1
- */
-       .ctl_reg = 0x1000,              /* CPOL=0,CPHA=0,Sandisk 1G work */
        .enable_dma = 0,                /* if 1 - block!!! */
        .bits_per_word = 8,
 };
index 82f70efd66e7106a541bc8dcfaccf42d247c230e..6d68dcfa2da21ade9ddbd50856219cfeb9d7ecdb 100644 (file)
@@ -321,12 +321,6 @@ static struct platform_device bfin_spi0_device = {
 };
 #endif  /* spi master and devices */
 
-#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
-static struct platform_device bfin_fb_device = {
-       .name = "bf537-fb",
-};
-#endif
-
 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
 static struct resource bfin_uart_resources[] = {
        {
index 02b328eb0e073d0200b27387081f18bb8c3d5027..e9ff491c095380396706add9fd80ed0789c7b3d4 100644 (file)
 /* System MMR Register Bits */
 /******************************************************************************* */
 
-/* ********************* PLL AND RESET MASKS ************************ */
-
-/* PLL_CTL Masks */
-#define PLL_CLKIN                      0x0000  /* Pass CLKIN to PLL */
-#define PLL_CLKIN_DIV2                 0x0001  /* Pass CLKIN/2 to PLL */
-#define DF                             0x0001  /* 0: PLL = CLKIN, 1: PLL = CLKIN/2                                     */
-#define PLL_OFF                                0x0002  /* Shut off PLL clocks */
-#define STOPCK_OFF                     0x0008  /* Core clock off */
-#define STOPCK                         0x0008  /* Core Clock Off                                                                       */
-#define PDWN                           0x0020  /* Put the PLL in a Deep Sleep state */
-#if !defined(__ADSPBF538__)
-/* this file is included in defBF538.h but IN_DELAY/OUT_DELAY are different */
-# define IN_DELAY        0x0040  /* Add 200ps Delay To EBIU Input Latches */
-# define OUT_DELAY       0x0080  /* Add 200ps Delay To EBIU Output Signals */
-#endif
-#define BYPASS                         0x0100  /* Bypass the PLL */
-/* PLL_CTL Macros (Only Use With Logic OR While Setting Lower Order Bits)                      */
-#define        SET_MSEL(x)             (((x)&0x3F) << 0x9)     /* Set MSEL = 0-63 --> VCO = CLKIN*MSEL         */
-
-/* PLL_DIV Masks */
-#define SSEL                           0x000F  /* System Select                                                */
-#define        CSEL                            0x0030  /* Core Select                                                  */
-
-#define SCLK_DIV(x)  (x)       /* SCLK = VCO / x */
-
-#define CCLK_DIV1              0x00000000      /* CCLK = VCO / 1 */
-#define CCLK_DIV2              0x00000010      /* CCLK = VCO / 2 */
-#define CCLK_DIV4              0x00000020      /* CCLK = VCO / 4 */
-#define CCLK_DIV8              0x00000030      /* CCLK = VCO / 8 */
-/* PLL_DIV Macros                                                                                                              */
-#define SET_SSEL(x)                    ((x)&0xF)       /* Set SSEL = 0-15 --> SCLK = VCO/SSEL  */
-
-/* PLL_STAT Masks                                                                                                                                      */
-#define ACTIVE_PLLENABLED      0x0001  /* Processor In Active Mode With PLL Enabled    */
-#define        FULL_ON                         0x0002  /* Processor In Full On Mode                                    */
-#define ACTIVE_PLLDISABLED     0x0004  /* Processor In Active Mode With PLL Disabled   */
-#define        PLL_LOCKED                      0x0020  /* PLL_LOCKCNT Has Been Reached                                 */
-
-/* VR_CTL Masks                                                                                                                                        */
-#define        FREQ                    0x0003  /* Switching Oscillator Frequency For Regulator */
-#define        HIBERNATE               0x0000  /*              Powerdown/Bypass On-Board Regulation    */
-#define        FREQ_333                0x0001  /*              Switching Frequency Is 333 kHz                  */
-#define        FREQ_667                0x0002  /*              Switching Frequency Is 667 kHz                  */
-#define        FREQ_1000               0x0003  /*              Switching Frequency Is 1 MHz                    */
-
-#define GAIN                   0x000C  /* Voltage Level Gain   */
-#define        GAIN_5                  0x0000  /*              GAIN = 5                */
-#define        GAIN_10                 0x0004  /*              GAIN = 10               */
-#define        GAIN_20                 0x0008  /*              GAIN = 20               */
-#define        GAIN_50                 0x000C  /*              GAIN = 50               */
-
-#define        VLEV                    0x00F0  /* Internal Voltage Level                                       */
-#define        VLEV_085                0x0060  /*              VLEV = 0.85 V (-5% - +10% Accuracy)     */
-#define        VLEV_090                0x0070  /*              VLEV = 0.90 V (-5% - +10% Accuracy)     */
-#define        VLEV_095                0x0080  /*              VLEV = 0.95 V (-5% - +10% Accuracy)     */
-#define        VLEV_100                0x0090  /*              VLEV = 1.00 V (-5% - +10% Accuracy)     */
-#define        VLEV_105                0x00A0  /*              VLEV = 1.05 V (-5% - +10% Accuracy)     */
-#define        VLEV_110                0x00B0  /*              VLEV = 1.10 V (-5% - +10% Accuracy)     */
-#define        VLEV_115                0x00C0  /*              VLEV = 1.15 V (-5% - +10% Accuracy)     */
-#define        VLEV_120                0x00D0  /*              VLEV = 1.20 V (-5% - +10% Accuracy)     */
-#define        VLEV_125                0x00E0  /*              VLEV = 1.25 V (-5% - +10% Accuracy)     */
-#define        VLEV_130                0x00F0  /*              VLEV = 1.30 V (-5% - +10% Accuracy)     */
-
-#define        WAKE                    0x0100  /* Enable RTC/Reset Wakeup From Hibernate       */
-#define        SCKELOW                 0x8000  /* Do Not Drive SCKE High During Reset After Hibernate */
-
 /* CHIPID Masks */
 #define CHIPID_VERSION         0xF0000000
 #define CHIPID_FAMILY          0x0FFFF000
 
 /* **********  DMA CONTROLLER MASKS  *********************8 */
 
-/*DMAx_CONFIG, MDMA_yy_CONFIG Masks */
-#define DMAEN          0x00000001      /* Channel Enable */
-#define WNR            0x00000002      /* Channel Direction (W/R*) */
-#define WDSIZE_8       0x00000000      /* Word Size 8 bits */
-#define WDSIZE_16      0x00000004      /* Word Size 16 bits */
-#define WDSIZE_32      0x00000008      /* Word Size 32 bits */
-#define DMA2D          0x00000010      /* 2D/1D* Mode */
-#define RESTART         0x00000020     /* Restart */
-#define DI_SEL         0x00000040      /* Data Interrupt Select */
-#define DI_EN          0x00000080      /* Data Interrupt Enable */
-#define NDSIZE_0               0x0000  /* Next Descriptor Size = 0 (Stop/Autobuffer)   */
-#define NDSIZE_1               0x0100  /* Next Descriptor Size = 1                                             */
-#define NDSIZE_2               0x0200  /* Next Descriptor Size = 2                                             */
-#define NDSIZE_3               0x0300  /* Next Descriptor Size = 3                                             */
-#define NDSIZE_4               0x0400  /* Next Descriptor Size = 4                                             */
-#define NDSIZE_5               0x0500  /* Next Descriptor Size = 5                                             */
-#define NDSIZE_6               0x0600  /* Next Descriptor Size = 6                                             */
-#define NDSIZE_7               0x0700  /* Next Descriptor Size = 7                                             */
-#define NDSIZE_8               0x0800  /* Next Descriptor Size = 8                                             */
-#define NDSIZE_9               0x0900  /* Next Descriptor Size = 9                                             */
-#define NDSIZE         0x00000900      /* Next Descriptor Size */
-#define DMAFLOW                0x00007000      /* Flow Control */
-#define DMAFLOW_STOP           0x0000  /* Stop Mode */
-#define DMAFLOW_AUTO           0x1000  /* Autobuffer Mode */
-#define DMAFLOW_ARRAY          0x4000  /* Descriptor Array Mode */
-#define DMAFLOW_SMALL          0x6000  /* Small Model Descriptor List Mode */
-#define DMAFLOW_LARGE          0x7000  /* Large Model Descriptor List Mode */
-
-#define DMAEN_P                        0       /* Channel Enable */
-#define WNR_P                  1       /* Channel Direction (W/R*) */
-#define DMA2D_P                        4       /* 2D/1D* Mode */
-#define RESTART_P              5       /* Restart */
-#define DI_SEL_P               6       /* Data Interrupt Select */
-#define DI_EN_P                        7       /* Data Interrupt Enable */
-
-/*DMAx_IRQ_STATUS, MDMA_yy_IRQ_STATUS Masks */
-
-#define DMA_DONE               0x00000001      /* DMA Done Indicator */
-#define DMA_ERR                        0x00000002      /* DMA Error Indicator */
-#define DFETCH                 0x00000004      /* Descriptor Fetch Indicator */
-#define DMA_RUN                        0x00000008      /* DMA Running Indicator */
-
-#define DMA_DONE_P             0       /* DMA Done Indicator */
-#define DMA_ERR_P              1       /* DMA Error Indicator */
-#define DFETCH_P               2       /* Descriptor Fetch Indicator */
-#define DMA_RUN_P              3       /* DMA Running Indicator */
-
-/*DMAx_PERIPHERAL_MAP, MDMA_yy_PERIPHERAL_MAP Masks */
+/* DMAx_PERIPHERAL_MAP, MDMA_yy_PERIPHERAL_MAP Masks */
 
 #define CTYPE              0x00000040  /* DMA Channel Type Indicator */
 #define CTYPE_P             6  /* DMA Channel Type Indicator BIT POSITION */
index 9ba290466b5695775ec00ac26bfb69029b778dc1..4e0afda472ab2905557fe2d8ad1000860e0524af 100644 (file)
@@ -13,9 +13,6 @@
 #include <linux/mtd/partitions.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-#include <linux/usb/isp1362.h>
-#endif
 #include <linux/irq.h>
 #include <asm/dma.h>
 #include <asm/bfin5xx_spi.h>
@@ -147,45 +144,6 @@ static struct platform_device sl811_hcd_device = {
 };
 #endif
 
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-static struct resource isp1362_hcd_resources[] = {
-       {
-               .start = 0x20360000,
-               .end = 0x20360000,
-               .flags = IORESOURCE_MEM,
-       }, {
-               .start = 0x20360004,
-               .end = 0x20360004,
-               .flags = IORESOURCE_MEM,
-       }, {
-               .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
-               .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
-               .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
-       },
-};
-
-static struct isp1362_platform_data isp1362_priv = {
-       .sel15Kres = 1,
-       .clknotstop = 0,
-       .oc_enable = 0,
-       .int_act_high = 0,
-       .int_edge_triggered = 0,
-       .remote_wakeup_connected = 0,
-       .no_power_switching = 1,
-       .power_switching_mode = 0,
-};
-
-static struct platform_device isp1362_hcd_device = {
-       .name = "isp1362-hcd",
-       .id = 0,
-       .dev = {
-               .platform_data = &isp1362_priv,
-       },
-       .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
-       .resource = isp1362_hcd_resources,
-};
-#endif
-
 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
 static struct platform_device bfin_mii_bus = {
        .name = "bfin_mii_bus",
@@ -492,10 +450,6 @@ static struct platform_device *stamp_devices[] __initdata = {
        &sl811_hcd_device,
 #endif
 
-#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
-       &isp1362_hcd_device,
-#endif
-
 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
        &smc91x_device,
 #endif
index c46baa5e6d9b22e047165f67c1e016b5da665775..ac9b52e0087ccb831c06130c8d5b225ff82c4024 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
@@ -25,6 +26,8 @@
 #include <linux/i2c.h>
 #include <linux/usb/sl811.h>
 #include <linux/spi/mmc_spi.h>
+#include <linux/leds.h>
+#include <linux/input.h>
 #include <asm/dma.h>
 #include <asm/bfin5xx_spi.h>
 #include <asm/reboot.h>
@@ -65,7 +68,7 @@ static struct isp1760_platform_data isp1760_priv = {
 };
 
 static struct platform_device bfin_isp1760_device = {
-       .name           = "isp1760-hcd",
+       .name           = "isp1760",
        .id             = 0,
        .dev = {
                .platform_data = &isp1760_priv,
@@ -76,7 +79,6 @@ static struct platform_device bfin_isp1760_device = {
 #endif
 
 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
-#include <linux/input.h>
 #include <linux/gpio_keys.h>
 
 static struct gpio_keys_button bfin_gpio_keys_table[] = {
@@ -195,28 +197,6 @@ static struct platform_device dm9000_device = {
 };
 #endif
 
-#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
-static struct resource ax88180_resources[] = {
-       [0] = {
-               .start  = 0x20300000,
-               .end    = 0x20300000 + 0x8000,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = IRQ_PF7,
-               .end    = IRQ_PF7,
-               .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
-       },
-};
-
-static struct platform_device ax88180_device = {
-       .name           = "ax88180",
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(ax88180_resources),
-       .resource       = ax88180_resources,
-};
-#endif
-
 #if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
 static struct resource sl811_hcd_resources[] = {
        {
@@ -272,8 +252,8 @@ static struct resource isp1362_hcd_resources[] = {
                .end = 0x20360004,
                .flags = IORESOURCE_MEM,
        }, {
-               .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
-               .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
+               .start = IRQ_PF3,
+               .end = IRQ_PF3,
                .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
        },
 };
@@ -300,6 +280,44 @@ static struct platform_device isp1362_hcd_device = {
 };
 #endif
 
+#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
+unsigned short bfin_can_peripherals[] = {
+       P_CAN0_RX, P_CAN0_TX, 0
+};
+
+static struct resource bfin_can_resources[] = {
+       {
+               .start = 0xFFC02A00,
+               .end = 0xFFC02FFF,
+               .flags = IORESOURCE_MEM,
+       },
+       {
+               .start = IRQ_CAN_RX,
+               .end = IRQ_CAN_RX,
+               .flags = IORESOURCE_IRQ,
+       },
+       {
+               .start = IRQ_CAN_TX,
+               .end = IRQ_CAN_TX,
+               .flags = IORESOURCE_IRQ,
+       },
+       {
+               .start = IRQ_CAN_ERROR,
+               .end = IRQ_CAN_ERROR,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device bfin_can_device = {
+       .name = "bfin_can",
+       .num_resources = ARRAY_SIZE(bfin_can_resources),
+       .resource = bfin_can_resources,
+       .dev = {
+               .platform_data = &bfin_can_peripherals, /* Passed to driver */
+       },
+};
+#endif
+
 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
 static struct platform_device bfin_mii_bus = {
        .name = "bfin_mii_bus",
@@ -514,15 +532,14 @@ static struct bfin5xx_spi_chip ad1938_spi_chip_info = {
 };
 #endif
 
-#if defined(CONFIG_INPUT_EVAL_AD7147EBZ)
-#include <linux/input.h>
+#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE)
 #include <linux/input/ad714x.h>
 static struct bfin5xx_spi_chip ad7147_spi_chip_info = {
        .enable_dma = 0,
        .bits_per_word = 16,
 };
 
-static struct ad714x_slider_plat slider_plat[] = {
+static struct ad714x_slider_plat ad7147_spi_slider_plat[] = {
        {
                .start_stage = 0,
                .end_stage = 7,
@@ -530,7 +547,7 @@ static struct ad714x_slider_plat slider_plat[] = {
        },
 };
 
-static struct ad714x_button_plat button_plat[] = {
+static struct ad714x_button_plat ad7147_spi_button_plat[] = {
        {
                .keycode = BTN_FORWARD,
                .l_mask = 0,
@@ -557,11 +574,11 @@ static struct ad714x_button_plat button_plat[] = {
                .h_mask = 0x400,
        },
 };
-static struct ad714x_platform_data ad7147_platfrom_data = {
+static struct ad714x_platform_data ad7147_spi_platform_data = {
        .slider_num = 1,
        .button_num = 5,
-       .slider = slider_plat,
-       .button = button_plat,
+       .slider = ad7147_spi_slider_plat,
+       .button = ad7147_spi_button_plat,
        .stage_cfg_reg =  {
                {0xFBFF, 0x1FFF, 0, 0x2626, 1600, 1600, 1600, 1600},
                {0xEFFF, 0x1FFF, 0, 0x2626, 1650, 1650, 1650, 1650},
@@ -580,10 +597,9 @@ static struct ad714x_platform_data ad7147_platfrom_data = {
 };
 #endif
 
-#if defined(CONFIG_INPUT_EVAL_AD7142EB)
-#include <linux/input.h>
+#if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE)
 #include <linux/input/ad714x.h>
-static struct ad714x_button_plat button_plat[] = {
+static struct ad714x_button_plat ad7142_i2c_button_plat[] = {
        {
                .keycode = BTN_1,
                .l_mask = 0,
@@ -605,9 +621,9 @@ static struct ad714x_button_plat button_plat[] = {
                .h_mask = 0x8,
        },
 };
-static struct ad714x_platform_data ad7142_platfrom_data = {
+static struct ad714x_platform_data ad7142_i2c_platform_data = {
        .button_num = 4,
-       .button = button_plat,
+       .button = ad7142_i2c_button_plat,
        .stage_cfg_reg =  {
                /* fixme: figure out right setting for all comoponent according
                 * to hardware feature of EVAL-AD7142EB board */
@@ -696,8 +712,7 @@ static const struct ad7879_platform_data bfin_ad7879_ts_info = {
 #endif
 
 #if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE)
-#include <linux/input.h>
-#include <linux/spi/adxl34x.h>
+#include <linux/input/adxl34x.h>
 static const struct adxl34x_platform_data adxl34x_info = {
        .x_axis_offset = 0,
        .y_axis_offset = 0,
@@ -721,9 +736,7 @@ static const struct adxl34x_platform_data adxl34x_info = {
        .ev_code_y = ABS_Y,             /* EV_REL */
        .ev_code_z = ABS_Z,             /* EV_REL */
 
-       .ev_code_tap_x = BTN_TOUCH,             /* EV_KEY */
-       .ev_code_tap_y = BTN_TOUCH,             /* EV_KEY */
-       .ev_code_tap_z = BTN_TOUCH,             /* EV_KEY */
+       .ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY x,y,z */
 
 /*     .ev_code_ff = KEY_F,*/          /* EV_KEY */
 /*     .ev_code_act_inactivity = KEY_A,*/      /* EV_KEY */
@@ -761,6 +774,47 @@ static struct bfin5xx_spi_chip enc28j60_spi_chip_info = {
 };
 #endif
 
+#if defined(CONFIG_ADF702X) || defined(CONFIG_ADF702X_MODULE)
+static struct bfin5xx_spi_chip adf7021_spi_chip_info = {
+       .bits_per_word = 16,
+       .cs_gpio = GPIO_PF10,
+};
+
+#include <linux/spi/adf702x.h>
+#define TXREG 0x0160A470
+static const u32 adf7021_regs[] = {
+       0x09608FA0,
+       0x00575011,
+       0x00A7F092,
+       0x2B141563,
+       0x81F29E94,
+       0x00003155,
+       0x050A4F66,
+       0x00000007,
+       0x00000008,
+       0x000231E9,
+       0x3296354A,
+       0x891A2B3B,
+       0x00000D9C,
+       0x0000000D,
+       0x0000000E,
+       0x0000000F,
+};
+
+static struct adf702x_platform_data adf7021_platform_data = {
+       .regs_base = (void *)SPORT1_TCR1,
+       .dma_ch_rx = CH_SPORT1_RX,
+       .dma_ch_tx = CH_SPORT1_TX,
+       .irq_sport_err = IRQ_SPORT1_ERROR,
+       .gpio_int_rfs = GPIO_PF8,
+       .pin_req = {P_SPORT1_DTPRI, P_SPORT1_RFS, P_SPORT1_DRPRI,
+                       P_SPORT1_RSCLK, P_SPORT1_TSCLK, 0},
+       .adf702x_model = MODEL_ADF7021,
+       .adf702x_regs = adf7021_regs,
+       .tx_reg = TXREG,
+};
+#endif
+
 #if defined(CONFIG_MTD_DATAFLASH) \
        || defined(CONFIG_MTD_DATAFLASH_MODULE)
 
@@ -794,6 +848,13 @@ static struct bfin5xx_spi_chip data_flash_chip_info = {
 };
 #endif
 
+#if defined(CONFIG_INPUT_ADXL34X_SPI) || defined(CONFIG_INPUT_ADXL34X_SPI_MODULE)
+static struct bfin5xx_spi_chip spi_adxl34x_chip_info = {
+       .enable_dma = 0,         /* use dma transfer with this chip*/
+       .bits_per_word = 8,
+};
+#endif
+
 static struct spi_board_info bfin_spi_board_info[] __initdata = {
 #if defined(CONFIG_MTD_M25P80) \
        || defined(CONFIG_MTD_M25P80_MODULE)
@@ -855,7 +916,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
        },
 #endif
 
-#if defined(CONFIG_INPUT_EVAL_AD7147EBZ)
+#if defined(CONFIG_INPUT_AD714X_SPI) || defined(CONFIG_INPUT_AD714X_SPI_MODULE)
        {
                .modalias = "ad714x_captouch",
                .max_speed_hz = 1000000,     /* max spi clock (SCK) speed in HZ */
@@ -863,7 +924,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
                .bus_num = 0,
                .chip_select = 5,
                .mode = SPI_MODE_3,
-               .platform_data = &ad7147_platfrom_data,
+               .platform_data = &ad7147_spi_platform_data,
                .controller_data = &ad7147_spi_chip_info,
        },
 #endif
@@ -932,6 +993,30 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
                .mode = SPI_MODE_0,
        },
 #endif
+#if defined(CONFIG_INPUT_ADXL34X_SPI) || defined(CONFIG_INPUT_ADXL34X_SPI_MODULE)
+       {
+               .modalias       = "adxl34x",
+               .platform_data  = &adxl34x_info,
+               .irq            = IRQ_PF6,
+               .max_speed_hz   = 5000000,    /* max spi clock (SCK) speed in HZ */
+               .bus_num        = 0,
+               .chip_select    = 2,
+               .controller_data = &spi_adxl34x_chip_info,
+               .mode = SPI_MODE_3,
+       },
+#endif
+#if defined(CONFIG_ADF702X) || defined(CONFIG_ADF702X_MODULE)
+       {
+               .modalias = "adf702x",
+               .max_speed_hz = 16000000,     /* max spi clock (SCK) speed in HZ */
+               .bus_num = 0,
+               .chip_select = 0,       /* GPIO controlled SSEL */
+               .controller_data = &adf7021_spi_chip_info,
+               .platform_data = &adf7021_platform_data,
+               .mode = SPI_MODE_0,
+       },
+#endif
+
 };
 
 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
@@ -1175,7 +1260,6 @@ static struct platform_device i2c_bfin_twi_device = {
 #endif
 
 #if defined(CONFIG_KEYBOARD_ADP5588) || defined(CONFIG_KEYBOARD_ADP5588_MODULE)
-#include <linux/input.h>
 #include <linux/i2c/adp5588.h>
 static const unsigned short adp5588_keymap[ADP5588_KEYMAPSIZE] = {
        [0]      = KEY_GRAVE,
@@ -1268,35 +1352,33 @@ static struct adp5588_kpad_platform_data adp5588_kpad_data = {
         *  ADP5520/5501 Backlight Data
         */
 
-static struct adp5520_backlight_platfrom_data adp5520_backlight_data = {
-       .fade_in                = FADE_T_1200ms,
-       .fade_out               = FADE_T_1200ms,
-       .fade_led_law           = BL_LAW_LINEAR,
-       .en_ambl_sens           = 1,
-       .abml_filt              = BL_AMBL_FILT_640ms,
-       .l1_daylight_max        = BL_CUR_mA(15),
-       .l1_daylight_dim        = BL_CUR_mA(0),
-       .l2_office_max          = BL_CUR_mA(7),
-       .l2_office_dim          = BL_CUR_mA(0),
-       .l3_dark_max            = BL_CUR_mA(3),
-       .l3_dark_dim            = BL_CUR_mA(0),
-       .l2_trip                = L2_COMP_CURR_uA(700),
-       .l2_hyst                = L2_COMP_CURR_uA(50),
-       .l3_trip                = L3_COMP_CURR_uA(80),
-       .l3_hyst                = L3_COMP_CURR_uA(20),
+static struct adp5520_backlight_platform_data adp5520_backlight_data = {
+       .fade_in                = ADP5520_FADE_T_1200ms,
+       .fade_out               = ADP5520_FADE_T_1200ms,
+       .fade_led_law           = ADP5520_BL_LAW_LINEAR,
+       .en_ambl_sens           = 1,
+       .abml_filt              = ADP5520_BL_AMBL_FILT_640ms,
+       .l1_daylight_max        = ADP5520_BL_CUR_mA(15),
+       .l1_daylight_dim        = ADP5520_BL_CUR_mA(0),
+       .l2_office_max          = ADP5520_BL_CUR_mA(7),
+       .l2_office_dim          = ADP5520_BL_CUR_mA(0),
+       .l3_dark_max            = ADP5520_BL_CUR_mA(3),
+       .l3_dark_dim            = ADP5520_BL_CUR_mA(0),
+       .l2_trip                = ADP5520_L2_COMP_CURR_uA(700),
+       .l2_hyst                = ADP5520_L2_COMP_CURR_uA(50),
+       .l3_trip                = ADP5520_L3_COMP_CURR_uA(80),
+       .l3_hyst                = ADP5520_L3_COMP_CURR_uA(20),
 };
 
        /*
         *  ADP5520/5501 LEDs Data
         */
 
-#include <linux/leds.h>
-
 static struct led_info adp5520_leds[] = {
        {
                .name = "adp5520-led1",
                .default_trigger = "none",
-               .flags = FLAG_ID_ADP5520_LED1_ADP5501_LED0 | LED_OFFT_600ms,
+               .flags = FLAG_ID_ADP5520_LED1_ADP5501_LED0 | ADP5520_LED_OFFT_600ms,
        },
 #ifdef ADP5520_EN_ALL_LEDS
        {
@@ -1312,51 +1394,50 @@ static struct led_info adp5520_leds[] = {
 #endif
 };
 
-static struct adp5520_leds_platfrom_data adp5520_leds_data = {
+static struct adp5520_leds_platform_data adp5520_leds_data = {
        .num_leds = ARRAY_SIZE(adp5520_leds),
        .leds = adp5520_leds,
-       .fade_in = FADE_T_600ms,
-       .fade_out = FADE_T_600ms,
-       .led_on_time = LED_ONT_600ms,
+       .fade_in = ADP5520_FADE_T_600ms,
+       .fade_out = ADP5520_FADE_T_600ms,
+       .led_on_time = ADP5520_LED_ONT_600ms,
 };
 
        /*
         *  ADP5520 GPIO Data
         */
 
-static struct adp5520_gpio_platfrom_data adp5520_gpio_data = {
+static struct adp5520_gpio_platform_data adp5520_gpio_data = {
        .gpio_start = 50,
-       .gpio_en_mask = GPIO_C1 | GPIO_C2 | GPIO_R2,
-       .gpio_pullup_mask = GPIO_C1 | GPIO_C2 | GPIO_R2,
+       .gpio_en_mask = ADP5520_GPIO_C1 | ADP5520_GPIO_C2 | ADP5520_GPIO_R2,
+       .gpio_pullup_mask = ADP5520_GPIO_C1 | ADP5520_GPIO_C2 | ADP5520_GPIO_R2,
 };
 
        /*
         *  ADP5520 Keypad Data
         */
 
-#include <linux/input.h>
 static const unsigned short adp5520_keymap[ADP5520_KEYMAPSIZE] = {
-       [KEY(0, 0)]     = KEY_GRAVE,
-       [KEY(0, 1)]     = KEY_1,
-       [KEY(0, 2)]     = KEY_2,
-       [KEY(0, 3)]     = KEY_3,
-       [KEY(1, 0)]     = KEY_4,
-       [KEY(1, 1)]     = KEY_5,
-       [KEY(1, 2)]     = KEY_6,
-       [KEY(1, 3)]     = KEY_7,
-       [KEY(2, 0)]     = KEY_8,
-       [KEY(2, 1)]     = KEY_9,
-       [KEY(2, 2)]     = KEY_0,
-       [KEY(2, 3)]     = KEY_MINUS,
-       [KEY(3, 0)]     = KEY_EQUAL,
-       [KEY(3, 1)]     = KEY_BACKSLASH,
-       [KEY(3, 2)]     = KEY_BACKSPACE,
-       [KEY(3, 3)]     = KEY_ENTER,
-};
-
-static struct adp5520_keys_platfrom_data adp5520_keys_data = {
-       .rows_en_mask   = ROW_R3 | ROW_R2 | ROW_R1 | ROW_R0,
-       .cols_en_mask   = COL_C3 | COL_C2 | COL_C1 | COL_C0,
+       [ADP5520_KEY(0, 0)]     = KEY_GRAVE,
+       [ADP5520_KEY(0, 1)]     = KEY_1,
+       [ADP5520_KEY(0, 2)]     = KEY_2,
+       [ADP5520_KEY(0, 3)]     = KEY_3,
+       [ADP5520_KEY(1, 0)]     = KEY_4,
+       [ADP5520_KEY(1, 1)]     = KEY_5,
+       [ADP5520_KEY(1, 2)]     = KEY_6,
+       [ADP5520_KEY(1, 3)]     = KEY_7,
+       [ADP5520_KEY(2, 0)]     = KEY_8,
+       [ADP5520_KEY(2, 1)]     = KEY_9,
+       [ADP5520_KEY(2, 2)]     = KEY_0,
+       [ADP5520_KEY(2, 3)]     = KEY_MINUS,
+       [ADP5520_KEY(3, 0)]     = KEY_EQUAL,
+       [ADP5520_KEY(3, 1)]     = KEY_BACKSLASH,
+       [ADP5520_KEY(3, 2)]     = KEY_BACKSPACE,
+       [ADP5520_KEY(3, 3)]     = KEY_ENTER,
+};
+
+static struct adp5520_keys_platform_data adp5520_keys_data = {
+       .rows_en_mask   = ADP5520_ROW_R3 | ADP5520_ROW_R2 | ADP5520_ROW_R1 | ADP5520_ROW_R0,
+       .cols_en_mask   = ADP5520_COL_C3 | ADP5520_COL_C2 | ADP5520_COL_C1 | ADP5520_COL_C0,
        .keymap         = adp5520_keymap,
        .keymapsize     = ARRAY_SIZE(adp5520_keymap),
        .repeat         = 0,
@@ -1366,50 +1447,81 @@ static struct adp5520_keys_platfrom_data adp5520_keys_data = {
         *  ADP5520/5501 Multifuction Device Init Data
         */
 
-static struct adp5520_subdev_info adp5520_subdevs[] = {
-       {
-               .name = "adp5520-backlight",
-               .id = ID_ADP5520,
-               .platform_data = &adp5520_backlight_data,
-       },
-       {
-               .name = "adp5520-led",
-               .id = ID_ADP5520,
-               .platform_data = &adp5520_leds_data,
-       },
-       {
-               .name = "adp5520-gpio",
-               .id = ID_ADP5520,
-               .platform_data = &adp5520_gpio_data,
-       },
-       {
-               .name = "adp5520-keys",
-               .id = ID_ADP5520,
-               .platform_data = &adp5520_keys_data,
-       },
-};
-
 static struct adp5520_platform_data adp5520_pdev_data = {
-       .num_subdevs = ARRAY_SIZE(adp5520_subdevs),
-       .subdevs = adp5520_subdevs,
+       .backlight = &adp5520_backlight_data,
+       .leds = &adp5520_leds_data,
+       .gpio = &adp5520_gpio_data,
+       .keys = &adp5520_keys_data,
 };
 
 #endif
 
 #if defined(CONFIG_GPIO_ADP5588) || defined(CONFIG_GPIO_ADP5588_MODULE)
 #include <linux/i2c/adp5588.h>
-static struct adp5588_gpio_platfrom_data adp5588_gpio_data = {
+static struct adp5588_gpio_platform_data adp5588_gpio_data = {
        .gpio_start = 50,
        .pullup_dis_mask = 0,
 };
 #endif
 
+#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE)
+#include <linux/i2c/adp8870.h>
+static struct led_info adp8870_leds[] = {
+       {
+               .name = "adp8870-led7",
+               .default_trigger = "none",
+               .flags = ADP8870_LED_D7 | ADP8870_LED_OFFT_600ms,
+       },
+};
+
+
+static struct adp8870_backlight_platform_data adp8870_pdata = {
+       .bl_led_assign = ADP8870_BL_D1 | ADP8870_BL_D2 | ADP8870_BL_D3 |
+                        ADP8870_BL_D4 | ADP8870_BL_D5 | ADP8870_BL_D6, /* 1 = Backlight 0 = Individual LED */
+       .pwm_assign = 0,                                /* 1 = Enables PWM mode */
+
+       .bl_fade_in = ADP8870_FADE_T_1200ms,            /* Backlight Fade-In Timer */
+       .bl_fade_out = ADP8870_FADE_T_1200ms,           /* Backlight Fade-Out Timer */
+       .bl_fade_law = ADP8870_FADE_LAW_CUBIC1,         /* fade-on/fade-off transfer characteristic */
+
+       .en_ambl_sens = 1,                              /* 1 = enable ambient light sensor */
+       .abml_filt = ADP8870_BL_AMBL_FILT_320ms,        /* Light sensor filter time */
+
+       .l1_daylight_max = ADP8870_BL_CUR_mA(20),       /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l1_daylight_dim = ADP8870_BL_CUR_mA(0),        /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l2_bright_max = ADP8870_BL_CUR_mA(14),         /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l2_bright_dim = ADP8870_BL_CUR_mA(0),          /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l3_office_max = ADP8870_BL_CUR_mA(6),          /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l3_office_dim = ADP8870_BL_CUR_mA(0),          /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l4_indoor_max = ADP8870_BL_CUR_mA(3),          /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l4_indor_dim = ADP8870_BL_CUR_mA(0),           /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l5_dark_max = ADP8870_BL_CUR_mA(2),            /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l5_dark_dim = ADP8870_BL_CUR_mA(0),            /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
+
+       .l2_trip = ADP8870_L2_COMP_CURR_uA(710),        /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */
+       .l2_hyst = ADP8870_L2_COMP_CURR_uA(73),         /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */
+       .l3_trip = ADP8870_L3_COMP_CURR_uA(389),        /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */
+       .l3_hyst = ADP8870_L3_COMP_CURR_uA(54),         /* use L3_COMP_CURR_uA(I) 0 <= I <= 551 uA */
+       .l4_trip = ADP8870_L4_COMP_CURR_uA(167),        /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */
+       .l4_hyst = ADP8870_L4_COMP_CURR_uA(16),         /* use L4_COMP_CURR_uA(I) 0 <= I <= 275 uA */
+       .l5_trip = ADP8870_L5_COMP_CURR_uA(43),         /* use L5_COMP_CURR_uA(I) 0 <= I <= 138 uA */
+       .l5_hyst = ADP8870_L5_COMP_CURR_uA(11),         /* use L6_COMP_CURR_uA(I) 0 <= I <= 138 uA */
+
+       .leds = adp8870_leds,
+       .num_leds = ARRAY_SIZE(adp8870_leds),
+       .led_fade_law = ADP8870_FADE_LAW_SQUARE,        /* fade-on/fade-off transfer characteristic */
+       .led_fade_in = ADP8870_FADE_T_600ms,
+       .led_fade_out = ADP8870_FADE_T_600ms,
+       .led_on_time = ADP8870_LED_ONT_200ms,
+};
+#endif
+
 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
-#if defined(CONFIG_INPUT_EVAL_AD7142EB)
+#if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE)
        {
                I2C_BOARD_INFO("ad7142_captouch", 0x2C),
                .irq = IRQ_PG5,
-               .platform_data = (void *)&ad7142_platfrom_data,
+               .platform_data = (void *)&ad7142_i2c_platform_data,
        },
 #endif
 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
@@ -1462,6 +1574,32 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
                I2C_BOARD_INFO("bfin-adv7393", 0x2B),
        },
 #endif
+#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
+       {
+               I2C_BOARD_INFO("bf537-lq035-ad5280", 0x2C),
+       },
+#endif
+#if defined(CONFIG_BACKLIGHT_ADP8870) || defined(CONFIG_BACKLIGHT_ADP8870_MODULE)
+       {
+               I2C_BOARD_INFO("adp8870", 0x2B),
+               .platform_data = (void *)&adp8870_pdata,
+       },
+#endif
+#if defined(CONFIG_SND_SOC_ADAU1371) || defined(CONFIG_SND_SOC_ADAU1371_MODULE)
+       {
+               I2C_BOARD_INFO("adau1371", 0x1A),
+       },
+#endif
+#if defined(CONFIG_SND_SOC_ADAU1761) || defined(CONFIG_SND_SOC_ADAU1761_MODULE)
+       {
+               I2C_BOARD_INFO("adau1761", 0x38),
+       },
+#endif
+#if defined(CONFIG_AD525X_DPOT) || defined(CONFIG_AD525X_DPOT_MODULE)
+       {
+               I2C_BOARD_INFO("ad5258", 0x18),
+       },
+#endif
 };
 
 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
@@ -1602,8 +1740,8 @@ static struct platform_device *stamp_devices[] __initdata = {
        &dm9000_device,
 #endif
 
-#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
-       &ax88180_device,
+#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
+       &bfin_can_device,
 #endif
 
 #if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
index 17fab4474669e7ee75bea250d772117432123fbf..8b291418ca322b5d887b003a1bb4e681f22307a9 100644 (file)
@@ -9,16 +9,6 @@
 #ifndef __MACH_BF537_H__
 #define __MACH_BF537_H__
 
-/* Masks for generic ERROR IRQ demultiplexing used in int-priority-sc.c */
-
-#define SPI_ERR_MASK (TXCOL | RBSY | MODF | TXE)       /* SPI_STAT */
-#define SPORT_ERR_MASK (ROVF | RUVF | TOVF | TUVF)     /* SPORTx_STAT */
-#define PPI_ERR_MASK (0xFFFF & ~FLD)   /* PPI_STATUS */
-#define EMAC_ERR_MASK (PHYINT | MMCINT | RXFSINT | TXFSINT | WAKEDET | RXDMAERR | TXDMAERR | STMDONE)  /* EMAC_SYSTAT */
-#define UART_ERR_MASK_STAT1 (0x4)      /* UARTx_IIR */
-#define UART_ERR_MASK_STAT0 (0x2)      /* UARTx_IIR */
-#define CAN_ERR_MASK  (EWTIF | EWRIF | EPIF | BOIF | WUIF | UIAIF | AAIF | RMLIF | UCEIF | EXTIF | ADIF)       /* CAN_GIF */
-
 #define OFFSET_(x) ((x) & 0x0000FFFF)
 
 /*some misc defines*/
index eab006d260c5daf513c6d8e9def488a08da350d9..a12d4b6a221d88bb36c1d549656725429f4ce632 100644 (file)
 #define OFFSET_SCR              0x1C   /* SCR Scratch Register                 */
 #define OFFSET_GCTL             0x24   /* Global Control Register              */
 
-/* PLL_DIV Masks                                                                                                       */
-#define CCLK_DIV1 CSEL_DIV1    /*          CCLK = VCO / 1                                  */
-#define CCLK_DIV2 CSEL_DIV2    /*          CCLK = VCO / 2                                  */
-#define CCLK_DIV4 CSEL_DIV4    /*          CCLK = VCO / 4                                  */
-#define CCLK_DIV8 CSEL_DIV8    /*          CCLK = VCO / 8                                  */
-
 #endif
index a6d20ca5768342fae4bffd969539e0b081f5e55d..066d5c261f47e3a34def90192dadc06c582de7ed 100644 (file)
 **                             modifier UNLESS the lower order bits are saved and ORed back in when
 **                             the macro is used.
 *************************************************************************************/
-/*
-** ********************* PLL AND RESET MASKS ****************************************/
-/* PLL_CTL Masks                                                                                                                                       */
-#define DF                             0x0001  /* 0: PLL = CLKIN, 1: PLL = CLKIN/2                                     */
-#define PLL_OFF                        0x0002  /* PLL Not Powered                                                                      */
-#define STOPCK                 0x0008  /* Core Clock Off                                                                       */
-#define PDWN                   0x0020  /* Enter Deep Sleep Mode                                                        */
-#define        IN_DELAY                0x0040  /* Add 200ps Delay To EBIU Input Latches                        */
-#define        OUT_DELAY               0x0080  /* Add 200ps Delay To EBIU Output Signals                       */
-#define BYPASS                 0x0100  /* Bypass the PLL                                                                       */
-#define        MSEL                    0x7E00  /* Multiplier Select For CCLK/VCO Factors                       */
-/* PLL_CTL Macros (Only Use With Logic OR While Setting Lower Order Bits)                      */
-#define        SET_MSEL(x)             (((x)&0x3F) << 0x9)     /* Set MSEL = 0-63 --> VCO = CLKIN*MSEL         */
-
-/* PLL_DIV Masks                                                                                                               */
-#define SSEL                   0x000F  /* System Select                                                */
-#define        CSEL                    0x0030  /* Core Select                                                  */
-#define CSEL_DIV1              0x0000  /*              CCLK = VCO / 1                                  */
-#define CSEL_DIV2              0x0010  /*              CCLK = VCO / 2                                  */
-#define        CSEL_DIV4               0x0020  /*              CCLK = VCO / 4                                  */
-#define        CSEL_DIV8               0x0030  /*              CCLK = VCO / 8                                  */
-/* PLL_DIV Macros                                                                                                              */
-#define SET_SSEL(x)            ((x)&0xF)       /* Set SSEL = 0-15 --> SCLK = VCO/SSEL  */
-
-/* VR_CTL Masks                                                                                                                                        */
-#define        FREQ                    0x0003  /* Switching Oscillator Frequency For Regulator */
-#define        HIBERNATE               0x0000  /*              Powerdown/Bypass On-Board Regulation    */
-#define        FREQ_333                0x0001  /*              Switching Frequency Is 333 kHz                  */
-#define        FREQ_667                0x0002  /*              Switching Frequency Is 667 kHz                  */
-#define        FREQ_1000               0x0003  /*              Switching Frequency Is 1 MHz                    */
-
-#define GAIN                   0x000C  /* Voltage Level Gain   */
-#define        GAIN_5                  0x0000  /*              GAIN = 5                */
-#define        GAIN_10                 0x0004  /*              GAIN = 10               */
-#define        GAIN_20                 0x0008  /*              GAIN = 20               */
-#define        GAIN_50                 0x000C  /*              GAIN = 50               */
-
-#define        VLEV                    0x00F0  /* Internal Voltage Level                                       */
-#define        VLEV_085                0x0060  /*              VLEV = 0.85 V (-5% - +10% Accuracy)     */
-#define        VLEV_090                0x0070  /*              VLEV = 0.90 V (-5% - +10% Accuracy)     */
-#define        VLEV_095                0x0080  /*              VLEV = 0.95 V (-5% - +10% Accuracy)     */
-#define        VLEV_100                0x0090  /*              VLEV = 1.00 V (-5% - +10% Accuracy)     */
-#define        VLEV_105                0x00A0  /*              VLEV = 1.05 V (-5% - +10% Accuracy)     */
-#define        VLEV_110                0x00B0  /*              VLEV = 1.10 V (-5% - +10% Accuracy)     */
-#define        VLEV_115                0x00C0  /*              VLEV = 1.15 V (-5% - +10% Accuracy)     */
-#define        VLEV_120                0x00D0  /*              VLEV = 1.20 V (-5% - +10% Accuracy)     */
-#define        VLEV_125                0x00E0  /*              VLEV = 1.25 V (-5% - +10% Accuracy)     */
-#define        VLEV_130                0x00F0  /*              VLEV = 1.30 V (-5% - +10% Accuracy)     */
-
-#define        WAKE                    0x0100  /* Enable RTC/Reset Wakeup From Hibernate       */
-#define        CANWE                   0x0200  /* Enable CAN Wakeup From Hibernate                     */
-#define        PHYWE                   0x0400  /* Enable PHY Wakeup From Hibernate                     */
-#define        CLKBUFOE                0x4000  /* CLKIN Buffer Output Enable */
-#define        PHYCLKOE                CLKBUFOE        /* Alternative legacy name for the above */
-#define        SCKELOW         0x8000  /* Enable Drive CKE Low During Reset            */
-
-/* PLL_STAT Masks                                                                                                                                      */
-#define ACTIVE_PLLENABLED      0x0001  /* Processor In Active Mode With PLL Enabled    */
-#define        FULL_ON                         0x0002  /* Processor In Full On Mode                                    */
-#define ACTIVE_PLLDISABLED     0x0004  /* Processor In Active Mode With PLL Disabled   */
-#define        PLL_LOCKED                      0x0020  /* PLL_LOCKCNT Has Been Reached                                 */
 
 /* CHIPID Masks */
 #define CHIPID_VERSION         0xF0000000
 #define BGSTAT                 0x0020  /* Bus Grant Status                                             */
 
 /* **************************  DMA CONTROLLER MASKS  ********************************/
-/* DMAx_CONFIG, MDMA_yy_CONFIG Masks                                                                                           */
-#define DMAEN                  0x0001  /* DMA Channel Enable                                                   */
-#define WNR                            0x0002  /* Channel Direction (W/R*)                                             */
-#define WDSIZE_8               0x0000  /* Transfer Word Size = 8                                               */
-#define WDSIZE_16              0x0004  /* Transfer Word Size = 16                                              */
-#define WDSIZE_32              0x0008  /* Transfer Word Size = 32                                              */
-#define DMA2D                  0x0010  /* DMA Mode (2D/1D*)                                                    */
-#define RESTART                        0x0020  /* DMA Buffer Clear                                                             */
-#define DI_SEL                 0x0040  /* Data Interrupt Timing Select                                 */
-#define DI_EN                  0x0080  /* Data Interrupt Enable                                                */
-#define NDSIZE_0               0x0000  /* Next Descriptor Size = 0 (Stop/Autobuffer)   */
-#define NDSIZE_1               0x0100  /* Next Descriptor Size = 1                                             */
-#define NDSIZE_2               0x0200  /* Next Descriptor Size = 2                                             */
-#define NDSIZE_3               0x0300  /* Next Descriptor Size = 3                                             */
-#define NDSIZE_4               0x0400  /* Next Descriptor Size = 4                                             */
-#define NDSIZE_5               0x0500  /* Next Descriptor Size = 5                                             */
-#define NDSIZE_6               0x0600  /* Next Descriptor Size = 6                                             */
-#define NDSIZE_7               0x0700  /* Next Descriptor Size = 7                                             */
-#define NDSIZE_8               0x0800  /* Next Descriptor Size = 8                                             */
-#define NDSIZE_9               0x0900  /* Next Descriptor Size = 9                                             */
-#define NDSIZE                 0x0900  /* Next Descriptor Size */
-
-#define DMAFLOW                        0x7000  /* Flow Control */
-#define DMAFLOW_STOP           0x0000  /* Stop Mode */
-#define DMAFLOW_AUTO           0x1000  /* Autobuffer Mode */
-#define DMAFLOW_ARRAY          0x4000  /* Descriptor Array Mode */
-#define DMAFLOW_SMALL          0x6000  /* Small Model Descriptor List Mode */
-#define DMAFLOW_LARGE          0x7000  /* Large Model Descriptor List Mode */
 
 /* DMAx_PERIPHERAL_MAP, MDMA_yy_PERIPHERAL_MAP Masks                                                           */
 #define CTYPE                  0x0040  /* DMA Channel Type Indicator (Memory/Peripheral*)      */
 #define        PMAP_UART1RX    0xA000  /*              UART1 Port Receive DMA                                          */
 #define        PMAP_UART1TX    0xB000  /*              UART1 Port Transmit DMA                                         */
 
-/* DMAx_IRQ_STATUS, MDMA_yy_IRQ_STATUS Masks                                           */
-#define DMA_DONE               0x0001  /* DMA Completion Interrupt Status      */
-#define DMA_ERR                        0x0002  /* DMA Error Interrupt Status           */
-#define DFETCH                 0x0004  /* DMA Descriptor Fetch Indicator       */
-#define DMA_RUN                        0x0008  /* DMA Channel Running Indicator        */
-
 /*  ************  PARALLEL PERIPHERAL INTERFACE (PPI) MASKS *************/
 /*  PPI_CONTROL Masks                                                                                                  */
 #define PORT_EN                        0x0001  /* PPI Port Enable                                      */
index 8cd2719684db5a9b4ab02d551f8ea64ebebf1695..c0be54f2cd2bbc6e70e9efe8503509a0eb19db22 100644 (file)
@@ -3,3 +3,4 @@
 #
 
 obj-y := ints-priority.o dma.o
+obj-$(CONFIG_GPIOLIB)  += ext-gpio.o
index 14af5c2088d44192f70b383e6ea9eb3ae2ec18e6..c296bb1ed50370230b756fff443479c980de01ac 100644 (file)
@@ -151,6 +151,44 @@ static struct platform_device bfin_sir2_device = {
 #endif
 #endif
 
+#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
+unsigned short bfin_can_peripherals[] = {
+       P_CAN0_RX, P_CAN0_TX, 0
+};
+
+static struct resource bfin_can_resources[] = {
+       {
+               .start = 0xFFC02A00,
+               .end = 0xFFC02FFF,
+               .flags = IORESOURCE_MEM,
+       },
+       {
+               .start = IRQ_CAN_RX,
+               .end = IRQ_CAN_RX,
+               .flags = IORESOURCE_IRQ,
+       },
+       {
+               .start = IRQ_CAN_TX,
+               .end = IRQ_CAN_TX,
+               .flags = IORESOURCE_IRQ,
+       },
+       {
+               .start = IRQ_CAN_ERROR,
+               .end = IRQ_CAN_ERROR,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device bfin_can_device = {
+       .name = "bfin_can",
+       .num_resources = ARRAY_SIZE(bfin_can_resources),
+       .resource = bfin_can_resources,
+       .dev = {
+               .platform_data = &bfin_can_peripherals, /* Passed to driver */
+       },
+};
+#endif
+
 /*
  *  USB-LAN EzExtender board
  *  Driver needs to know address, irq and flag pin.
@@ -610,6 +648,10 @@ static struct platform_device *cm_bf538_devices[] __initdata = {
 #endif
 #endif
 
+#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
+       &bfin_can_device,
+#endif
+
 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
        &smc91x_device,
 #endif
diff --git a/arch/blackfin/mach-bf538/ext-gpio.c b/arch/blackfin/mach-bf538/ext-gpio.c
new file mode 100644 (file)
index 0000000..180b125
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * GPIOLIB interface for BF538/9 PORT C, D, and E GPIOs
+ *
+ * Copyright 2009 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <linux/module.h>
+#include <linux/err.h>
+#include <asm/blackfin.h>
+#include <asm/gpio.h>
+#include <asm/portmux.h>
+
+#define DEFINE_REG(reg, off) \
+static inline u16 read_##reg(void __iomem *port) \
+       { return bfin_read16(port + off); } \
+static inline void write_##reg(void __iomem *port, u16 v) \
+       { bfin_write16(port + off, v); }
+
+DEFINE_REG(PORTIO, 0x00)
+DEFINE_REG(PORTIO_CLEAR, 0x10)
+DEFINE_REG(PORTIO_SET, 0x20)
+DEFINE_REG(PORTIO_DIR, 0x40)
+DEFINE_REG(PORTIO_INEN, 0x50)
+
+static void __iomem *gpio_chip_to_mmr(struct gpio_chip *chip)
+{
+       switch (chip->base) {
+       default: /* not really needed, but keeps gcc happy */
+       case GPIO_PC0: return (void __iomem *)PORTCIO;
+       case GPIO_PD0: return (void __iomem *)PORTDIO;
+       case GPIO_PE0: return (void __iomem *)PORTEIO;
+       }
+}
+
+static int bf538_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
+{
+       void __iomem *port = gpio_chip_to_mmr(chip);
+       return !!(read_PORTIO(port) & (1u << gpio));
+}
+
+static void bf538_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
+{
+       void __iomem *port = gpio_chip_to_mmr(chip);
+       if (value)
+               write_PORTIO_SET(port, (1u << gpio));
+       else
+               write_PORTIO_CLEAR(port, (1u << gpio));
+}
+
+static int bf538_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
+{
+       void __iomem *port = gpio_chip_to_mmr(chip);
+       write_PORTIO_DIR(port, read_PORTIO_DIR(port) & ~(1u << gpio));
+       write_PORTIO_INEN(port, read_PORTIO_INEN(port) | (1u << gpio));
+       return 0;
+}
+
+static int bf538_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value)
+{
+       void __iomem *port = gpio_chip_to_mmr(chip);
+       write_PORTIO_INEN(port, read_PORTIO_INEN(port) & ~(1u << gpio));
+       bf538_gpio_set_value(port, gpio, value);
+       write_PORTIO_DIR(port, read_PORTIO_DIR(port) | (1u << gpio));
+       return 0;
+}
+
+static int bf538_gpio_request(struct gpio_chip *chip, unsigned gpio)
+{
+       return bfin_special_gpio_request(chip->base + gpio, chip->label);
+}
+
+static void bf538_gpio_free(struct gpio_chip *chip, unsigned gpio)
+{
+       return bfin_special_gpio_free(chip->base + gpio);
+}
+
+/* We don't set the irq fields as these banks cannot generate interrupts */
+
+static struct gpio_chip bf538_portc_chip = {
+       .label = "GPIO-PC",
+       .direction_input = bf538_gpio_direction_input,
+       .get = bf538_gpio_get_value,
+       .direction_output = bf538_gpio_direction_output,
+       .set = bf538_gpio_set_value,
+       .request = bf538_gpio_request,
+       .free = bf538_gpio_free,
+       .base = GPIO_PC0,
+       .ngpio = GPIO_PC9 - GPIO_PC0 + 1,
+};
+
+static struct gpio_chip bf538_portd_chip = {
+       .label = "GPIO-PD",
+       .direction_input = bf538_gpio_direction_input,
+       .get = bf538_gpio_get_value,
+       .direction_output = bf538_gpio_direction_output,
+       .set = bf538_gpio_set_value,
+       .request = bf538_gpio_request,
+       .free = bf538_gpio_free,
+       .base = GPIO_PD0,
+       .ngpio = GPIO_PD13 - GPIO_PD0 + 1,
+};
+
+static struct gpio_chip bf538_porte_chip = {
+       .label = "GPIO-PE",
+       .direction_input = bf538_gpio_direction_input,
+       .get = bf538_gpio_get_value,
+       .direction_output = bf538_gpio_direction_output,
+       .set = bf538_gpio_set_value,
+       .request = bf538_gpio_request,
+       .free = bf538_gpio_free,
+       .base = GPIO_PE0,
+       .ngpio = GPIO_PE15 - GPIO_PE0 + 1,
+};
+
+static int __init bf538_extgpio_setup(void)
+{
+       return gpiochip_add(&bf538_portc_chip) |
+               gpiochip_add(&bf538_portd_chip) |
+               gpiochip_add(&bf538_porte_chip);
+}
+arch_initcall(bf538_extgpio_setup);
index 278e8942eef23e4df7e6dbf90d8bc6c0980556a0..08b5eabb1ed57b1c205798c529c6cf86564af339 100644 (file)
 #define OFFSET_SCR              0x1C   /* SCR Scratch Register                 */
 #define OFFSET_GCTL             0x24   /* Global Control Register              */
 
-/* PLL_DIV Masks                                                                                                       */
-#define CCLK_DIV1 CSEL_DIV1    /*          CCLK = VCO / 1                                  */
-#define CCLK_DIV2 CSEL_DIV2    /*          CCLK = VCO / 2                                  */
-#define CCLK_DIV4 CSEL_DIV4    /*          CCLK = VCO / 4                                  */
-#define CCLK_DIV8 CSEL_DIV8    /*          CCLK = VCO / 8                                  */
-
 #endif
index 5f6c34dfd08e8faf8e1c181731280f795d5c058e..fac563e6f62f7adbe357cab7d501d1c6fc276ac9 100644 (file)
 /* General-Purpose Ports  (0xFFC01500 -        0xFFC015FF)      */
 
 /* GPIO        Port C Register Names */
-#define        GPIO_C_CNFG                     0xFFC01500      /* GPIO Pin Port C Configuration Register */
-#define        GPIO_C_D                        0xFFC01510      /* GPIO Pin Port C Data Register */
-#define        GPIO_C_C                        0xFFC01520      /* Clear GPIO Pin Port C Register */
-#define        GPIO_C_S                        0xFFC01530      /* Set GPIO Pin Port C Register */
-#define        GPIO_C_T                        0xFFC01540      /* Toggle GPIO Pin Port C Register */
-#define        GPIO_C_DIR                      0xFFC01550      /* GPIO Pin Port C Direction Register */
-#define        GPIO_C_INEN                     0xFFC01560      /* GPIO Pin Port C Input Enable Register */
+#define PORTCIO_FER                    0xFFC01500      /* GPIO Pin Port C Configuration Register */
+#define PORTCIO                                0xFFC01510      /* GPIO Pin Port C Data Register */
+#define PORTCIO_CLEAR                  0xFFC01520      /* Clear GPIO Pin Port C Register */
+#define PORTCIO_SET                    0xFFC01530      /* Set GPIO Pin Port C Register */
+#define PORTCIO_TOGGLE                 0xFFC01540      /* Toggle GPIO Pin Port C Register */
+#define PORTCIO_DIR                    0xFFC01550      /* GPIO Pin Port C Direction Register */
+#define PORTCIO_INEN                   0xFFC01560      /* GPIO Pin Port C Input Enable Register */
 
 /* GPIO        Port D Register Names */
-#define        GPIO_D_CNFG                     0xFFC01504      /* GPIO Pin Port D Configuration Register */
-#define        GPIO_D_D                        0xFFC01514      /* GPIO Pin Port D Data Register */
-#define        GPIO_D_C                        0xFFC01524      /* Clear GPIO Pin Port D Register */
-#define        GPIO_D_S                        0xFFC01534      /* Set GPIO Pin Port D Register */
-#define        GPIO_D_T                        0xFFC01544      /* Toggle GPIO Pin Port D Register */
-#define        GPIO_D_DIR                      0xFFC01554      /* GPIO Pin Port D Direction Register */
-#define        GPIO_D_INEN                     0xFFC01564      /* GPIO Pin Port D Input Enable Register */
+#define PORTDIO_FER                    0xFFC01504      /* GPIO Pin Port D Configuration Register */
+#define PORTDIO                                0xFFC01514      /* GPIO Pin Port D Data Register */
+#define PORTDIO_CLEAR                  0xFFC01524      /* Clear GPIO Pin Port D Register */
+#define PORTDIO_SET                    0xFFC01534      /* Set GPIO Pin Port D Register */
+#define PORTDIO_TOGGLE                 0xFFC01544      /* Toggle GPIO Pin Port D Register */
+#define PORTDIO_DIR                    0xFFC01554      /* GPIO Pin Port D Direction Register */
+#define PORTDIO_INEN                   0xFFC01564      /* GPIO Pin Port D Input Enable Register */
 
 /* GPIO        Port E Register Names */
-#define        GPIO_E_CNFG                     0xFFC01508      /* GPIO Pin Port E Configuration Register */
-#define        GPIO_E_D                        0xFFC01518      /* GPIO Pin Port E Data Register */
-#define        GPIO_E_C                        0xFFC01528      /* Clear GPIO Pin Port E Register */
-#define        GPIO_E_S                        0xFFC01538      /* Set GPIO Pin Port E Register */
-#define        GPIO_E_T                        0xFFC01548      /* Toggle GPIO Pin Port E Register */
-#define        GPIO_E_DIR                      0xFFC01558      /* GPIO Pin Port E Direction Register */
-#define        GPIO_E_INEN                     0xFFC01568      /* GPIO Pin Port E Input Enable Register */
+#define PORTEIO_FER                    0xFFC01508      /* GPIO Pin Port E Configuration Register */
+#define PORTEIO                                0xFFC01518      /* GPIO Pin Port E Data Register */
+#define PORTEIO_CLEAR                  0xFFC01528      /* Clear GPIO Pin Port E Register */
+#define PORTEIO_SET                    0xFFC01538      /* Set GPIO Pin Port E Register */
+#define PORTEIO_TOGGLE                 0xFFC01548      /* Toggle GPIO Pin Port E Register */
+#define PORTEIO_DIR                    0xFFC01558      /* GPIO Pin Port E Direction Register */
+#define PORTEIO_INEN                   0xFFC01568      /* GPIO Pin Port E Input Enable Register */
 
 /* DMA Controller 1 Traffic Control Registers (0xFFC01B00 - 0xFFC01BFF) */
 
 /* System MMR Register Bits and        Macros */
 /******************************************************************************* */
 
-/* ********************* PLL AND RESET MASKS ************************ */
-/* PLL_CTL Masks */
-#define        PLL_CLKIN                       0x0000  /* Pass CLKIN to PLL */
-#define        PLL_CLKIN_DIV2          0x0001  /* Pass CLKIN/2 to PLL */
-#define        DF                                      0x0001   /* 0: PLL = CLKIN, 1: PLL = CLKIN/2 */
-#define        PLL_OFF                         0x0002  /* Shut off PLL clocks */
-
-#define        STOPCK                          0x0008  /* Core Clock Off                */
-#define        PDWN                            0x0020  /* Put the PLL in a Deep Sleep state */
-#define        IN_DELAY                        0x0014  /* EBIU Input Delay Select */
-#define        OUT_DELAY                       0x00C0  /* EBIU Output Delay Select */
-#define        BYPASS                          0x0100  /* Bypass the PLL */
-#define        MSEL                    0x7E00  /* Multiplier Select For CCLK/VCO Factors */
-
-/* PLL_CTL Macros                               */
-#ifdef _MISRA_RULES
-#define        SET_MSEL(x)             (((x)&0x3Fu) << 0x9)    /* Set MSEL = 0-63 --> VCO = CLKIN*MSEL */
-#define        SET_OUT_DELAY(x)        (((x)&0x03u) << 0x6)
-#define        SET_IN_DELAY(x)         ((((x)&0x02u) << 0x3) | (((x)&0x01u) << 0x2))
-#else
-#define        SET_MSEL(x)             (((x)&0x3F) << 0x9)     /* Set MSEL = 0-63 --> VCO = CLKIN*MSEL */
-#define        SET_OUT_DELAY(x)        (((x)&0x03) << 0x6)
-#define        SET_IN_DELAY(x)         ((((x)&0x02) << 0x3) | (((x)&0x01) << 0x2))
-#endif /* _MISRA_RULES */
-
-/* PLL_DIV Masks */
-#define        SSEL                            0x000F  /* System Select */
-#define        CSEL                            0x0030  /* Core Select */
-#define        CSEL_DIV1               0x0000  /*              CCLK = VCO / 1 */
-#define        CSEL_DIV2               0x0010  /*              CCLK = VCO / 2 */
-#define        CSEL_DIV4               0x0020  /*              CCLK = VCO / 4 */
-#define        CSEL_DIV8               0x0030  /*              CCLK = VCO / 8 */
-
-#define        SCLK_DIV(x)                     (x)             /* SCLK = VCO / x */
-
-/* PLL_DIV Macros                                                       */
-#ifdef _MISRA_RULES
-#define        SET_SSEL(x)                     ((x)&0xFu)      /* Set SSEL = 0-15 --> SCLK = VCO/SSEL */
-#else
-#define        SET_SSEL(x)                     ((x)&0xF)       /* Set SSEL = 0-15 --> SCLK = VCO/SSEL */
-#endif /* _MISRA_RULES */
-
-/* PLL_STAT Masks                                                                               */
-#define        ACTIVE_PLLENABLED       0x0001  /* Processor In Active Mode With PLL Enabled */
-#define        FULL_ON                         0x0002  /* Processor In Full On Mode */
-#define        ACTIVE_PLLDISABLED      0x0004  /* Processor In Active Mode With PLL Disabled */
-#define        PLL_LOCKED                      0x0020  /* PLL_LOCKCNT Has Been Reached */
-
-/* VR_CTL Masks                                                                                 */
-#define        FREQ                    0x0003  /* Switching Oscillator Frequency For Regulator */
-#define        HIBERNATE               0x0000  /*              Powerdown/Bypass On-Board Regulation */
-#define        FREQ_333                0x0001  /*              Switching Frequency Is 333 kHz */
-#define        FREQ_667                0x0002  /*              Switching Frequency Is 667 kHz */
-#define        FREQ_1000               0x0003  /*              Switching Frequency Is 1 MHz */
-
-#define        GAIN                    0x000C  /* Voltage Level Gain */
-#define        GAIN_5                  0x0000  /*              GAIN = 5 */
-#define        GAIN_10                 0x0004  /*              GAIN = 10 */
-#define        GAIN_20                 0x0008  /*              GAIN = 20 */
-#define        GAIN_50                 0x000C  /*              GAIN = 50 */
-
-#define        VLEV                    0x00F0  /* Internal Voltage Level - Only Program Values Within Specifications */
-#define        VLEV_100                0x0090  /*      VLEV = 1.00 V (See Datasheet for Regulator Tolerance) */
-#define        VLEV_105                0x00A0  /*      VLEV = 1.05 V (See Datasheet for Regulator Tolerance) */
-#define        VLEV_110                0x00B0  /*      VLEV = 1.10 V (See Datasheet for Regulator Tolerance) */
-#define        VLEV_115                0x00C0  /*      VLEV = 1.15 V (See Datasheet for Regulator Tolerance) */
-#define        VLEV_120                0x00D0  /*      VLEV = 1.20 V (See Datasheet for Regulator Tolerance) */
-#define        VLEV_125                0x00E0  /*      VLEV = 1.25 V (See Datasheet for Regulator Tolerance) */
-#define        VLEV_130                0x00F0  /*      VLEV = 1.30 V (See Datasheet for Regulator Tolerance) */
-
-#define        WAKE                    0x0100  /* Enable RTC/Reset Wakeup From Hibernate */
-#define        CANWE                   0x0200  /* Enable CAN Wakeup From Hibernate */
-#define        MXVRWE                  0x0400  /* Enable MXVR Wakeup From Hibernate */
-#define        SCKELOW                 0x8000  /* Do Not Drive SCKE High During Reset After Hibernate */
-
 /* SWRST Mask */
 #define        SYSTEM_RESET    0x0007  /* Initiates A System Software Reset */
 #define        DOUBLE_FAULT    0x0008  /* Core Double Fault Causes Reset */
 #endif /* _MISRA_RULES */
 
 
-/* ********* WATCHDOG TIMER MASKS ******************** */
-/* Watchdog Timer WDOG_CTL Register Masks */
-#ifdef _MISRA_RULES
-#define        WDEV(x)                 (((x)<<1) & 0x0006u)    /* event generated on roll over */
-#else
-#define        WDEV(x)                 (((x)<<1) & 0x0006)     /* event generated on roll over */
-#endif /* _MISRA_RULES */
-#define        WDEV_RESET              0x0000                          /* generate reset event on roll over */
-#define        WDEV_NMI                0x0002                          /* generate NMI event on roll over */
-#define        WDEV_GPI                0x0004                          /* generate GP IRQ on roll over */
-#define        WDEV_NONE               0x0006                          /* no event on roll over */
-#define        WDEN                    0x0FF0                          /* enable watchdog */
-#define        WDDIS                   0x0AD0                          /* disable watchdog */
-#define        WDRO                    0x8000                          /* watchdog rolled over latch */
-
-/* deprecated WDOG_CTL Register        Masks for legacy code */
-#define        ICTL WDEV
-#define        ENABLE_RESET    WDEV_RESET
-#define        WDOG_RESET              WDEV_RESET
-#define        ENABLE_NMI              WDEV_NMI
-#define        WDOG_NMI                WDEV_NMI
-#define        ENABLE_GPI              WDEV_GPI
-#define        WDOG_GPI                WDEV_GPI
-#define        DISABLE_EVT     WDEV_NONE
-#define        WDOG_NONE               WDEV_NONE
-
-#define        TMR_EN                  WDEN
-#define        WDOG_DISABLE            WDDIS
-#define        TRO                     WDRO
-
-#define        ICTL_P0                 0x01
-#define        ICTL_P1                 0x02
-#define        TRO_P                   0x0F
-
-
-/* ***************  REAL TIME CLOCK MASKS  **************************/
-/* RTC_STAT and        RTC_ALARM register */
-#define        RTSEC           0x0000003F      /* Real-Time Clock Seconds */
-#define        RTMIN           0x00000FC0      /* Real-Time Clock Minutes */
-#define        RTHR            0x0001F000      /* Real-Time Clock Hours */
-#define        RTDAY           0xFFFE0000      /* Real-Time Clock Days */
-
-/* RTC_ICTL register */
-#define        SWIE            0x0001          /* Stopwatch Interrupt Enable */
-#define        AIE                     0x0002          /* Alarm Interrupt Enable */
-#define        SIE                     0x0004          /* Seconds (1 Hz) Interrupt Enable */
-#define        MIE                     0x0008          /* Minutes Interrupt Enable */
-#define        HIE                     0x0010          /* Hours Interrupt Enable */
-#define        DIE                     0x0020          /* 24 Hours (Days) Interrupt Enable */
-#define        DAIE            0x0040          /* Day Alarm (Day, Hour, Minute, Second) Interrupt Enable */
-#define        WCIE            0x8000          /* Write Complete Interrupt Enable */
-
-/* RTC_ISTAT register */
-#define        SWEF            0x0001          /* Stopwatch Event Flag */
-#define        AEF                     0x0002          /* Alarm Event Flag */
-#define        SEF                     0x0004          /* Seconds (1 Hz) Event Flag */
-#define        MEF                     0x0008          /* Minutes Event Flag */
-#define        HEF                     0x0010          /* Hours Event Flag */
-#define        DEF                     0x0020          /* 24 Hours (Days) Event Flag */
-#define        DAEF            0x0040          /* Day Alarm (Day, Hour, Minute, Second) Event Flag */
-#define        WPS                     0x4000          /* Write Pending Status (RO) */
-#define        WCOM            0x8000          /* Write Complete */
-
-/* RTC_FAST Mask (RTC_PREN Mask) */
-#define        ENABLE_PRESCALE      0x00000001  /* Enable prescaler so RTC runs at 1 Hz */
-#define        PREN                 0x00000001
-               /* ** Must be set after power-up for proper operation of RTC */
-
-/* Deprecated RTC_STAT and RTC_ALARM Masks                      */
-#define        RTC_SEC                 RTSEC   /* Real-Time Clock Seconds */
-#define        RTC_MIN                 RTMIN   /* Real-Time Clock Minutes */
-#define        RTC_HR                  RTHR    /* Real-Time Clock Hours */
-#define        RTC_DAY                 RTDAY   /* Real-Time Clock Days */
-
-/* Deprecated RTC_ICTL/RTC_ISTAT Masks                                                                                  */
-#define        STOPWATCH               SWIE            /* Stopwatch Interrupt Enable    */
-#define        ALARM                   AIE             /* Alarm Interrupt Enable                */
-#define        SECOND                  SIE             /* Seconds (1 Hz) Interrupt Enable */
-#define        MINUTE                  MIE             /* Minutes Interrupt Enable              */
-#define        HOUR                    HIE             /* Hours Interrupt Enable                */
-#define        DAY                             DIE             /* 24 Hours (Days) Interrupt Enable */
-#define        DAY_ALARM               DAIE            /* Day Alarm (Day, Hour, Minute, Second) Interrupt Enable */
-#define        WRITE_COMPLETE  WCIE            /* Write Complete Interrupt Enable */
-
-
 /* ***************************** UART CONTROLLER MASKS ********************** */
 /* UARTx_LCR Register */
 #ifdef _MISRA_RULES
 
 
 /* **********  DMA CONTROLLER MASKS  ***********************/
-/* DMAx_CONFIG,        MDMA_yy_CONFIG Masks */
-#define        DMAEN           0x0001  /* Channel Enable */
-#define        WNR                     0x0002  /* Channel Direction (W/R*) */
-#define        WDSIZE_8        0x0000  /* Word Size 8 bits */
-#define        WDSIZE_16       0x0004  /* Word Size 16 bits */
-#define        WDSIZE_32       0x0008  /* Word Size 32 bits */
-#define        DMA2D           0x0010  /* 2D/1D* Mode */
-#define        RESTART         0x0020  /* Restart */
-#define        DI_SEL          0x0040  /* Data Interrupt Select */
-#define        DI_EN           0x0080  /* Data Interrupt Enable */
-#define        NDSIZE          0x0900  /* Next Descriptor Size */
-#define        NDSIZE_0        0x0000  /* Next Descriptor Size = 0 (Stop/Autobuffer) */
-#define        NDSIZE_1        0x0100  /* Next Descriptor Size = 1 */
-#define        NDSIZE_2        0x0200  /* Next Descriptor Size = 2 */
-#define        NDSIZE_3        0x0300  /* Next Descriptor Size = 3 */
-#define        NDSIZE_4        0x0400  /* Next Descriptor Size = 4 */
-#define        NDSIZE_5        0x0500  /* Next Descriptor Size = 5 */
-#define        NDSIZE_6        0x0600  /* Next Descriptor Size = 6 */
-#define        NDSIZE_7        0x0700  /* Next Descriptor Size = 7 */
-#define        NDSIZE_8        0x0800  /* Next Descriptor Size = 8 */
-#define        NDSIZE_9        0x0900  /* Next Descriptor Size = 9 */
-
-#define DMAFLOW                        0x7000  /* Flow Control */
-#define DMAFLOW_STOP           0x0000  /* Stop Mode */
-#define DMAFLOW_AUTO           0x1000  /* Autobuffer Mode */
-#define DMAFLOW_ARRAY          0x4000  /* Descriptor Array Mode */
-#define DMAFLOW_SMALL          0x6000  /* Small Model Descriptor List Mode */
-#define DMAFLOW_LARGE          0x7000  /* Large Model Descriptor List Mode */
-
-#define        DMAEN_P         0x0             /* Channel Enable */
-#define        WNR_P           0x1             /* Channel Direction (W/R*) */
-#define        DMA2D_P         0x4             /* 2D/1D* Mode */
-#define        RESTART_P       0x5             /* Restart */
-#define        DI_SEL_P        0x6             /* Data Interrupt Select */
-#define        DI_EN_P         0x7             /* Data Interrupt Enable */
-
-/* DMAx_IRQ_STATUS, MDMA_yy_IRQ_STATUS Masks */
-#define        DMA_DONE        0x0001  /* DMA Done Indicator */
-#define        DMA_ERR         0x0002  /* DMA Error Indicator */
-#define        DFETCH          0x0004  /* Descriptor Fetch Indicator */
-#define        DMA_RUN         0x0008  /* DMA Running Indicator */
-
-#define        DMA_DONE_P      0x0             /* DMA Done Indicator */
-#define        DMA_ERR_P       0x1             /* DMA Error Indicator */
-#define        DFETCH_P        0x2             /* Descriptor Fetch Indicator */
-#define        DMA_RUN_P       0x3             /* DMA Running Indicator */
 
 /* DMAx_PERIPHERAL_MAP,        MDMA_yy_PERIPHERAL_MAP Masks */
 
 #define        RCV_FULL        0x000C          /*              Receive FIFO Full (2 Bytes To Read) */
 
 
-/********************************* MXVR        MASKS ****************************************/
-
-/* MXVR_CONFIG Masks */
-
-#define        MXVREN    0x00000001lu
-#define        MMSM      0x00000002lu
-#define        ACTIVE    0x00000004lu
-#define        SDELAY    0x00000008lu
-#define        NCMRXEN   0x00000010lu
-#define        RWRRXEN   0x00000020lu
-#define        MTXEN     0x00000040lu
-#define        MTXON     0x00000080lu /*legacy*/
-#define        MTXONB    0x00000080lu
-#define        EPARITY   0x00000100lu
-#define        MSB       0x00001E00lu
-#define        APRXEN    0x00002000lu
-#define        WAKEUP    0x00004000lu
-#define        LMECH     0x00008000lu
-
-#ifdef _MISRA_RULES
-#define        SET_MSB(x)     (((x)&0xFu) << 0x9)
-#else
-#define        SET_MSB(x)     (((x)&0xF) << 0x9)
-#endif /* _MISRA_RULES */
-
-
-/* MXVR_PLL_CTL_0 Masks */
-
-#define        MXTALCEN  0x00000001lu
-#define        MXTALFEN  0x00000002lu
-#define        MPLLMS    0x00000008lu
-#define        MXTALMUL  0x00000030lu
-#define        MPLLEN    0x00000040lu
-#define        MPLLEN0   0x00000040lu /* legacy */
-#define        MPLLEN1   0x00000080lu /* legacy */
-#define        MMCLKEN   0x00000100lu
-#define        MMCLKMUL  0x00001E00lu
-#define        MPLLRSTB  0x00002000lu
-#define        MPLLRSTB0 0x00002000lu /* legacy */
-#define        MPLLRSTB1 0x00004000lu /* legacy */
-#define        MBCLKEN   0x00010000lu
-#define        MBCLKDIV  0x001E0000lu
-#define        MPLLCDR   0x00200000lu
-#define        MPLLCDR0  0x00200000lu /* legacy */
-#define        MPLLCDR1  0x00400000lu /* legacy */
-#define        INVRX     0x00800000lu
-#define        MFSEN     0x01000000lu
-#define        MFSDIV    0x1E000000lu
-#define        MFSSEL    0x60000000lu
-#define        MFSSYNC   0x80000000lu
-
-#define        MXTALMUL_256FS   0x00000000lu /* legacy */
-#define        MXTALMUL_384FS   0x00000010lu /* legacy */
-#define        MXTALMUL_512FS   0x00000020lu /* legacy */
-#define        MXTALMUL_1024FS  0x00000030lu
-
-#define        MMCLKMUL_1024FS  0x00000000lu
-#define        MMCLKMUL_512FS   0x00000200lu
-#define        MMCLKMUL_256FS   0x00000400lu
-#define        MMCLKMUL_128FS   0x00000600lu
-#define        MMCLKMUL_64FS    0x00000800lu
-#define        MMCLKMUL_32FS    0x00000A00lu
-#define        MMCLKMUL_16FS    0x00000C00lu
-#define        MMCLKMUL_8FS     0x00000E00lu
-#define        MMCLKMUL_4FS     0x00001000lu
-#define        MMCLKMUL_2FS     0x00001200lu
-#define        MMCLKMUL_1FS     0x00001400lu
-#define        MMCLKMUL_1536FS  0x00001A00lu
-#define        MMCLKMUL_768FS   0x00001C00lu
-#define        MMCLKMUL_384FS   0x00001E00lu
-
-#define        MBCLKDIV_DIV2    0x00020000lu
-#define        MBCLKDIV_DIV4    0x00040000lu
-#define        MBCLKDIV_DIV8    0x00060000lu
-#define        MBCLKDIV_DIV16   0x00080000lu
-#define        MBCLKDIV_DIV32   0x000A0000lu
-#define        MBCLKDIV_DIV64   0x000C0000lu
-#define        MBCLKDIV_DIV128  0x000E0000lu
-#define        MBCLKDIV_DIV256  0x00100000lu
-#define        MBCLKDIV_DIV512  0x00120000lu
-#define        MBCLKDIV_DIV1024 0x00140000lu
-
-#define        MFSDIV_DIV2      0x02000000lu
-#define        MFSDIV_DIV4      0x04000000lu
-#define        MFSDIV_DIV8      0x06000000lu
-#define        MFSDIV_DIV16     0x08000000lu
-#define        MFSDIV_DIV32     0x0A000000lu
-#define        MFSDIV_DIV64     0x0C000000lu
-#define        MFSDIV_DIV128    0x0E000000lu
-#define        MFSDIV_DIV256    0x10000000lu
-#define        MFSDIV_DIV512    0x12000000lu
-#define        MFSDIV_DIV1024   0x14000000lu
-
-#define        MFSSEL_CLOCK     0x00000000lu
-#define        MFSSEL_PULSE_HI  0x20000000lu
-#define        MFSSEL_PULSE_LO  0x40000000lu
-
-
-/* MXVR_PLL_CTL_1 Masks */
-
-#define        MSTO       0x00000001lu
-#define        MSTO0      0x00000001lu /* legacy */
-#define        MHOGGD     0x00000004lu
-#define        MHOGGD0    0x00000004lu /* legacy */
-#define        MHOGGD1    0x00000008lu /* legacy */
-#define        MSHAPEREN  0x00000010lu
-#define        MSHAPEREN0 0x00000010lu /* legacy */
-#define        MSHAPEREN1 0x00000020lu /* legacy */
-#define        MPLLCNTEN  0x00008000lu
-#define        MPLLCNT    0xFFFF0000lu
-
-#ifdef _MISRA_RULES
-#define        SET_MPLLCNT(x)     (((x)&0xFFFFu) << 0x10)
-#else
-#define        SET_MPLLCNT(x)     (((x)&0xFFFF) << 0x10)
-#endif /* _MISRA_RULES */
-
-
-/* MXVR_PLL_CTL_2 Masks */
-
-#define        MSHAPERSEL 0x00000007lu
-#define        MCPSEL     0x000000E0lu
-
-/* MXVR_INT_STAT_0 Masks */
-
-#define        NI2A  0x00000001lu
-#define        NA2I  0x00000002lu
-#define        SBU2L 0x00000004lu
-#define        SBL2U 0x00000008lu
-#define        PRU   0x00000010lu
-#define        MPRU  0x00000020lu
-#define        DRU   0x00000040lu
-#define        MDRU  0x00000080lu
-#define        SBU   0x00000100lu
-#define        ATU   0x00000200lu
-#define        FCZ0  0x00000400lu
-#define        FCZ1  0x00000800lu
-#define        PERR  0x00001000lu
-#define        MH2L  0x00002000lu
-#define        ML2H  0x00004000lu
-#define        WUP   0x00008000lu
-#define        FU2L  0x00010000lu
-#define        FL2U  0x00020000lu
-#define        BU2L  0x00040000lu
-#define        BL2U  0x00080000lu
-#define        PCZ   0x00400000lu
-#define        FERR  0x00800000lu
-#define        CMR   0x01000000lu
-#define        CMROF 0x02000000lu
-#define        CMTS  0x04000000lu
-#define        CMTC  0x08000000lu
-#define        RWRC  0x10000000lu
-#define        BCZ   0x20000000lu
-#define        BMERR 0x40000000lu
-#define        DERR  0x80000000lu
-
-
-/* MXVR_INT_EN_0 Masks */
-
-#define        NI2AEN  NI2A
-#define        NA2IEN  NA2I
-#define        SBU2LEN SBU2L
-#define        SBL2UEN SBL2U
-#define        PRUEN   PRU
-#define        MPRUEN  MPRU
-#define        DRUEN   DRU
-#define        MDRUEN  MDRU
-#define        SBUEN   SBU
-#define        ATUEN   ATU
-#define        FCZ0EN  FCZ0
-#define        FCZ1EN  FCZ1
-#define        PERREN  PERR
-#define        MH2LEN  MH2L
-#define        ML2HEN  ML2H
-#define        WUPEN   WUP
-#define        FU2LEN  FU2L
-#define        FL2UEN  FL2U
-#define        BU2LEN  BU2L
-#define        BL2UEN  BL2U
-#define        PCZEN   PCZ
-#define        FERREN  FERR
-#define        CMREN   CMR
-#define        CMROFEN CMROF
-#define        CMTSEN  CMTS
-#define        CMTCEN  CMTC
-#define        RWRCEN  RWRC
-#define        BCZEN   BCZ
-#define        BMERREN BMERR
-#define        DERREN  DERR
-
-
-/* MXVR_INT_STAT_1 Masks */
-
-#define        APR   0x00000004lu
-#define        APROF 0x00000008lu
-#define        APTS  0x00000040lu
-#define        APTC  0x00000080lu
-#define        APRCE 0x00000400lu
-#define        APRPE 0x00000800lu
-
-#define        HDONE0 0x00000001lu
-#define        DONE0  0x00000002lu
-#define        HDONE1 0x00000010lu
-#define        DONE1  0x00000020lu
-#define        HDONE2 0x00000100lu
-#define        DONE2  0x00000200lu
-#define        HDONE3 0x00001000lu
-#define        DONE3  0x00002000lu
-#define        HDONE4 0x00010000lu
-#define        DONE4  0x00020000lu
-#define        HDONE5 0x00100000lu
-#define        DONE5  0x00200000lu
-#define        HDONE6 0x01000000lu
-#define        DONE6  0x02000000lu
-#define        HDONE7 0x10000000lu
-#define        DONE7  0x20000000lu
-
-#define        DONEX(x) (0x00000002 << (4 * (x)))
-#define        HDONEX(x) (0x00000001 << (4 * (x)))
-
-
-/* MXVR_INT_EN_1 Masks */
-
-#define        APREN   APR
-#define        APROFEN APROF
-#define        APTSEN  APTS
-#define        APTCEN  APTC
-#define        APRCEEN APRCE
-#define        APRPEEN APRPE
-
-#define        HDONEEN0 HDONE0
-#define        DONEEN0  DONE0
-#define        HDONEEN1 HDONE1
-#define        DONEEN1  DONE1
-#define        HDONEEN2 HDONE2
-#define        DONEEN2  DONE2
-#define        HDONEEN3 HDONE3
-#define        DONEEN3  DONE3
-#define        HDONEEN4 HDONE4
-#define        DONEEN4  DONE4
-#define        HDONEEN5 HDONE5
-#define        DONEEN5  DONE5
-#define        HDONEEN6 HDONE6
-#define        DONEEN6  DONE6
-#define        HDONEEN7 HDONE7
-#define        DONEEN7  DONE7
-
-#define        DONEENX(x) (0x00000002 << (4 * (x)))
-#define        HDONEENX(x) (0x00000001 << (4 * (x)))
-
-
-/* MXVR_STATE_0        Masks */
-
-#define        NACT     0x00000001lu
-#define        SBLOCK   0x00000002lu
-#define        PFDLOCK  0x00000004lu
-#define        PFDLOCK0 0x00000004lu /* legacy */
-#define        PDD      0x00000008lu
-#define        PDD0     0x00000008lu /* legacy */
-#define        PVCO     0x00000010lu
-#define        PVCO0    0x00000010lu /* legacy */
-#define        PFDLOCK1 0x00000020lu /* legacy */
-#define        PDD1     0x00000040lu /* legacy */
-#define        PVCO1    0x00000080lu /* legacy */
-#define        APBSY    0x00000100lu
-#define        APARB    0x00000200lu
-#define        APTX     0x00000400lu
-#define        APRX     0x00000800lu
-#define        CMBSY    0x00001000lu
-#define        CMARB    0x00002000lu
-#define        CMTX     0x00004000lu
-#define        CMRX     0x00008000lu
-#define        MRXONB   0x00010000lu
-#define        RGSIP    0x00020000lu
-#define        DALIP    0x00040000lu
-#define        ALIP     0x00080000lu
-#define        RRDIP    0x00100000lu
-#define        RWRIP    0x00200000lu
-#define        FLOCK    0x00400000lu
-#define        BLOCK    0x00800000lu
-#define        RSB      0x0F000000lu
-#define        DERRNUM  0xF0000000lu
-
-
-/* MXVR_STATE_1        Masks */
-
-#define        STXNUMB     0x0000000Flu
-#define        SRXNUMB     0x000000F0lu
-#define        APCONT      0x00000100lu
-#define        DMAACTIVEX  0x00FF0000lu
-#define        DMAACTIVE0  0x00010000lu
-#define        DMAACTIVE1  0x00020000lu
-#define        DMAACTIVE2  0x00040000lu
-#define        DMAACTIVE3  0x00080000lu
-#define        DMAACTIVE4  0x00100000lu
-#define        DMAACTIVE5  0x00200000lu
-#define        DMAACTIVE6  0x00400000lu
-#define        DMAACTIVE7  0x00800000lu
-#define        DMAPMENX    0xFF000000lu
-#define        DMAPMEN0    0x01000000lu
-#define        DMAPMEN1    0x02000000lu
-#define        DMAPMEN2    0x04000000lu
-#define        DMAPMEN3    0x08000000lu
-#define        DMAPMEN4    0x10000000lu
-#define        DMAPMEN5    0x20000000lu
-#define        DMAPMEN6    0x40000000lu
-#define        DMAPMEN7    0x80000000lu
-
-
-/* MXVR_POSITION Masks */
-
-#define        PVALID       0x8000
-#define        POSITION     0x003F
-
-
-/* MXVR_MAX_POSITION Masks */
-
-#define        MPVALID      0x8000
-#define        MPOSITION    0x003F
-
-
-/* MXVR_DELAY Masks */
-
-#define        DVALID       0x8000
-#define        DELAY        0x003F
-
-
-/* MXVR_MAX_DELAY Masks */
-
-#define        MDVALID      0x8000
-#define        MDELAY       0x003F
-
-
-/* MXVR_LADDR Masks */
-
-#define        LVALID       0x80000000lu
-#define        LADDR        0x0000FFFFlu
-
-
-/* MXVR_GADDR Masks */
-
-#define        GVALID       0x8000
-#define        GADDRL       0x00FF
-
-
-/* MXVR_AADDR Masks */
-
-#define        AVALID       0x80000000lu
-#define        AADDR        0x0000FFFFlu
-
-
-/* MXVR_ALLOC_0        Masks */
-
-#define        CIU0         0x00000080lu
-#define        CIU1         0x00008000lu
-#define        CIU2         0x00800000lu
-#define        CIU3         0x80000000lu
-
-#define        CL0          0x0000007Flu
-#define        CL1          0x00007F00lu
-#define        CL2          0x007F0000lu
-#define        CL3          0x7F000000lu
-
-
-/* MXVR_ALLOC_1        Masks */
-
-#define        CIU4         0x00000080lu
-#define        CIU5         0x00008000lu
-#define        CIU6         0x00800000lu
-#define        CIU7         0x80000000lu
-
-#define        CL4          0x0000007Flu
-#define        CL5          0x00007F00lu
-#define        CL6          0x007F0000lu
-#define        CL7          0x7F000000lu
-
-
-/* MXVR_ALLOC_2        Masks */
-
-#define        CIU8         0x00000080lu
-#define        CIU9         0x00008000lu
-#define        CIU10        0x00800000lu
-#define        CIU11        0x80000000lu
-
-#define        CL8          0x0000007Flu
-#define        CL9          0x00007F00lu
-#define        CL10         0x007F0000lu
-#define        CL11         0x7F000000lu
-
-
-/* MXVR_ALLOC_3        Masks */
-
-#define        CIU12        0x00000080lu
-#define        CIU13        0x00008000lu
-#define        CIU14        0x00800000lu
-#define        CIU15        0x80000000lu
-
-#define        CL12         0x0000007Flu
-#define        CL13         0x00007F00lu
-#define        CL14         0x007F0000lu
-#define        CL15         0x7F000000lu
-
-
-/* MXVR_ALLOC_4        Masks */
-
-#define        CIU16        0x00000080lu
-#define        CIU17        0x00008000lu
-#define        CIU18        0x00800000lu
-#define        CIU19        0x80000000lu
-
-#define        CL16         0x0000007Flu
-#define        CL17         0x00007F00lu
-#define        CL18         0x007F0000lu
-#define        CL19         0x7F000000lu
-
-
-/* MXVR_ALLOC_5        Masks */
-
-#define        CIU20        0x00000080lu
-#define        CIU21        0x00008000lu
-#define        CIU22        0x00800000lu
-#define        CIU23        0x80000000lu
-
-#define        CL20         0x0000007Flu
-#define        CL21         0x00007F00lu
-#define        CL22         0x007F0000lu
-#define        CL23         0x7F000000lu
-
-
-/* MXVR_ALLOC_6        Masks */
-
-#define        CIU24        0x00000080lu
-#define        CIU25        0x00008000lu
-#define        CIU26        0x00800000lu
-#define        CIU27        0x80000000lu
-
-#define        CL24         0x0000007Flu
-#define        CL25         0x00007F00lu
-#define        CL26         0x007F0000lu
-#define        CL27         0x7F000000lu
-
-
-/* MXVR_ALLOC_7        Masks */
-
-#define        CIU28        0x00000080lu
-#define        CIU29        0x00008000lu
-#define        CIU30        0x00800000lu
-#define        CIU31        0x80000000lu
-
-#define        CL28         0x0000007Flu
-#define        CL29         0x00007F00lu
-#define        CL30         0x007F0000lu
-#define        CL31         0x7F000000lu
-
-
-/* MXVR_ALLOC_8        Masks */
-
-#define        CIU32        0x00000080lu
-#define        CIU33        0x00008000lu
-#define        CIU34        0x00800000lu
-#define        CIU35        0x80000000lu
-
-#define        CL32         0x0000007Flu
-#define        CL33         0x00007F00lu
-#define        CL34         0x007F0000lu
-#define        CL35         0x7F000000lu
-
-
-/* MXVR_ALLOC_9        Masks */
-
-#define        CIU36        0x00000080lu
-#define        CIU37        0x00008000lu
-#define        CIU38        0x00800000lu
-#define        CIU39        0x80000000lu
-
-#define        CL36         0x0000007Flu
-#define        CL37         0x00007F00lu
-#define        CL38         0x007F0000lu
-#define        CL39         0x7F000000lu
-
-
-/* MXVR_ALLOC_10 Masks */
-
-#define        CIU40        0x00000080lu
-#define        CIU41        0x00008000lu
-#define        CIU42        0x00800000lu
-#define        CIU43        0x80000000lu
-
-#define        CL40         0x0000007Flu
-#define        CL41         0x00007F00lu
-#define        CL42         0x007F0000lu
-#define        CL43         0x7F000000lu
-
-
-/* MXVR_ALLOC_11 Masks */
-
-#define        CIU44        0x00000080lu
-#define        CIU45        0x00008000lu
-#define        CIU46        0x00800000lu
-#define        CIU47        0x80000000lu
-
-#define        CL44         0x0000007Flu
-#define        CL45         0x00007F00lu
-#define        CL46         0x007F0000lu
-#define        CL47         0x7F000000lu
-
-
-/* MXVR_ALLOC_12 Masks */
-
-#define        CIU48        0x00000080lu
-#define        CIU49        0x00008000lu
-#define        CIU50        0x00800000lu
-#define        CIU51        0x80000000lu
-
-#define        CL48         0x0000007Flu
-#define        CL49         0x00007F00lu
-#define        CL50         0x007F0000lu
-#define        CL51         0x7F000000lu
-
-
-/* MXVR_ALLOC_13 Masks */
-
-#define        CIU52        0x00000080lu
-#define        CIU53        0x00008000lu
-#define        CIU54        0x00800000lu
-#define        CIU55        0x80000000lu
-
-#define        CL52         0x0000007Flu
-#define        CL53         0x00007F00lu
-#define        CL54         0x007F0000lu
-#define        CL55         0x7F000000lu
-
-
-/* MXVR_ALLOC_14 Masks */
-
-#define        CIU56        0x00000080lu
-#define        CIU57        0x00008000lu
-#define        CIU58        0x00800000lu
-#define        CIU59        0x80000000lu
-
-#define        CL56         0x0000007Flu
-#define        CL57         0x00007F00lu
-#define        CL58         0x007F0000lu
-#define        CL59         0x7F000000lu
-
-
-/* MXVR_SYNC_LCHAN_0 Masks */
-
-#define        LCHANPC0     0x0000000Flu
-#define        LCHANPC1     0x000000F0lu
-#define        LCHANPC2     0x00000F00lu
-#define        LCHANPC3     0x0000F000lu
-#define        LCHANPC4     0x000F0000lu
-#define        LCHANPC5     0x00F00000lu
-#define        LCHANPC6     0x0F000000lu
-#define        LCHANPC7     0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_1 Masks */
-
-#define        LCHANPC8     0x0000000Flu
-#define        LCHANPC9     0x000000F0lu
-#define        LCHANPC10    0x00000F00lu
-#define        LCHANPC11    0x0000F000lu
-#define        LCHANPC12    0x000F0000lu
-#define        LCHANPC13    0x00F00000lu
-#define        LCHANPC14    0x0F000000lu
-#define        LCHANPC15    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_2 Masks */
-
-#define        LCHANPC16    0x0000000Flu
-#define        LCHANPC17    0x000000F0lu
-#define        LCHANPC18    0x00000F00lu
-#define        LCHANPC19    0x0000F000lu
-#define        LCHANPC20    0x000F0000lu
-#define        LCHANPC21    0x00F00000lu
-#define        LCHANPC22    0x0F000000lu
-#define        LCHANPC23    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_3 Masks */
-
-#define        LCHANPC24    0x0000000Flu
-#define        LCHANPC25    0x000000F0lu
-#define        LCHANPC26    0x00000F00lu
-#define        LCHANPC27    0x0000F000lu
-#define        LCHANPC28    0x000F0000lu
-#define        LCHANPC29    0x00F00000lu
-#define        LCHANPC30    0x0F000000lu
-#define        LCHANPC31    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_4 Masks */
-
-#define        LCHANPC32    0x0000000Flu
-#define        LCHANPC33    0x000000F0lu
-#define        LCHANPC34    0x00000F00lu
-#define        LCHANPC35    0x0000F000lu
-#define        LCHANPC36    0x000F0000lu
-#define        LCHANPC37    0x00F00000lu
-#define        LCHANPC38    0x0F000000lu
-#define        LCHANPC39    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_5 Masks */
-
-#define        LCHANPC40    0x0000000Flu
-#define        LCHANPC41    0x000000F0lu
-#define        LCHANPC42    0x00000F00lu
-#define        LCHANPC43    0x0000F000lu
-#define        LCHANPC44    0x000F0000lu
-#define        LCHANPC45    0x00F00000lu
-#define        LCHANPC46    0x0F000000lu
-#define        LCHANPC47    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_6 Masks */
-
-#define        LCHANPC48    0x0000000Flu
-#define        LCHANPC49    0x000000F0lu
-#define        LCHANPC50    0x00000F00lu
-#define        LCHANPC51    0x0000F000lu
-#define        LCHANPC52    0x000F0000lu
-#define        LCHANPC53    0x00F00000lu
-#define        LCHANPC54    0x0F000000lu
-#define        LCHANPC55    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_7 Masks */
-
-#define        LCHANPC56    0x0000000Flu
-#define        LCHANPC57    0x000000F0lu
-#define        LCHANPC58    0x00000F00lu
-#define        LCHANPC59    0x0000F000lu
-
-
-/* MXVR_DMAx_CONFIG Masks */
-
-#define        MDMAEN      0x00000001lu
-#define        DD          0x00000002lu
-#define        LCHAN       0x000003C0lu
-#define        BITSWAPEN   0x00000400lu
-#define        BYSWAPEN    0x00000800lu
-#define        MFLOW       0x00007000lu
-#define        FIXEDPM     0x00080000lu
-#define        STARTPAT    0x00300000lu
-#define        STOPPAT     0x00C00000lu
-#define        COUNTPOS    0x1C000000lu
-
-#define        DD_TX       0x00000000lu
-#define        DD_RX       0x00000002lu
-
-#define        LCHAN_0     0x00000000lu
-#define        LCHAN_1     0x00000040lu
-#define        LCHAN_2     0x00000080lu
-#define        LCHAN_3     0x000000C0lu
-#define        LCHAN_4     0x00000100lu
-#define        LCHAN_5     0x00000140lu
-#define        LCHAN_6     0x00000180lu
-#define        LCHAN_7     0x000001C0lu
-
-#define        MFLOW_STOP  0x00000000lu
-#define        MFLOW_AUTO  0x00001000lu
-#define        MFLOW_PVC   0x00002000lu
-#define        MFLOW_PSS   0x00003000lu
-#define        MFLOW_PFC   0x00004000lu
-
-#define        STARTPAT_0  0x00000000lu
-#define        STARTPAT_1  0x00100000lu
-
-#define        STOPPAT_0   0x00000000lu
-#define        STOPPAT_1   0x00400000lu
-
-#define        COUNTPOS_0  0x00000000lu
-#define        COUNTPOS_1  0x04000000lu
-#define        COUNTPOS_2  0x08000000lu
-#define        COUNTPOS_3  0x0C000000lu
-#define        COUNTPOS_4  0x10000000lu
-#define        COUNTPOS_5  0x14000000lu
-#define        COUNTPOS_6  0x18000000lu
-#define        COUNTPOS_7  0x1C000000lu
-
-
-/* MXVR_AP_CTL Masks */
-
-#define        STARTAP    0x00000001lu
-#define        CANCELAP   0x00000002lu
-#define        RESETAP    0x00000004lu
-#define        APRBE0     0x00004000lu
-#define        APRBE1     0x00008000lu
-#define        APRBEX     0x0000C000lu
-
-
-/* MXVR_CM_CTL Masks */
-
-#define        STARTCM    0x00000001lu
-#define        CANCELCM   0x00000002lu
-#define        CMRBEX     0xFFFF0000lu
-#define        CMRBE0     0x00010000lu
-#define        CMRBE1     0x00020000lu
-#define        CMRBE2     0x00040000lu
-#define        CMRBE3     0x00080000lu
-#define        CMRBE4     0x00100000lu
-#define        CMRBE5     0x00200000lu
-#define        CMRBE6     0x00400000lu
-#define        CMRBE7     0x00800000lu
-#define        CMRBE8     0x01000000lu
-#define        CMRBE9     0x02000000lu
-#define        CMRBE10    0x04000000lu
-#define        CMRBE11    0x08000000lu
-#define        CMRBE12    0x10000000lu
-#define        CMRBE13    0x20000000lu
-#define        CMRBE14    0x40000000lu
-#define        CMRBE15    0x80000000lu
-
-
-/* MXVR_PAT_DATA_x Masks */
-
-#define        MATCH_DATA_0 0x000000FFlu
-#define        MATCH_DATA_1 0x0000FF00lu
-#define        MATCH_DATA_2 0x00FF0000lu
-#define        MATCH_DATA_3 0xFF000000lu
-
-
-
-/* MXVR_PAT_EN_x Masks */
-
-#define        MATCH_EN_0_0 0x00000001lu
-#define        MATCH_EN_0_1 0x00000002lu
-#define        MATCH_EN_0_2 0x00000004lu
-#define        MATCH_EN_0_3 0x00000008lu
-#define        MATCH_EN_0_4 0x00000010lu
-#define        MATCH_EN_0_5 0x00000020lu
-#define        MATCH_EN_0_6 0x00000040lu
-#define        MATCH_EN_0_7 0x00000080lu
-
-#define        MATCH_EN_1_0 0x00000100lu
-#define        MATCH_EN_1_1 0x00000200lu
-#define        MATCH_EN_1_2 0x00000400lu
-#define        MATCH_EN_1_3 0x00000800lu
-#define        MATCH_EN_1_4 0x00001000lu
-#define        MATCH_EN_1_5 0x00002000lu
-#define        MATCH_EN_1_6 0x00004000lu
-#define        MATCH_EN_1_7 0x00008000lu
-
-#define        MATCH_EN_2_0 0x00010000lu
-#define        MATCH_EN_2_1 0x00020000lu
-#define        MATCH_EN_2_2 0x00040000lu
-#define        MATCH_EN_2_3 0x00080000lu
-#define        MATCH_EN_2_4 0x00100000lu
-#define        MATCH_EN_2_5 0x00200000lu
-#define        MATCH_EN_2_6 0x00400000lu
-#define        MATCH_EN_2_7 0x00800000lu
-
-#define        MATCH_EN_3_0 0x01000000lu
-#define        MATCH_EN_3_1 0x02000000lu
-#define        MATCH_EN_3_2 0x04000000lu
-#define        MATCH_EN_3_3 0x08000000lu
-#define        MATCH_EN_3_4 0x10000000lu
-#define        MATCH_EN_3_5 0x20000000lu
-#define        MATCH_EN_3_6 0x40000000lu
-#define        MATCH_EN_3_7 0x80000000lu
-
-
-/* MXVR_ROUTING_0 Masks */
-
-#define        MUTE_CH0        0x00000080lu
-#define        MUTE_CH1        0x00008000lu
-#define        MUTE_CH2        0x00800000lu
-#define        MUTE_CH3        0x80000000lu
-
-#define        TX_CH0          0x0000007Flu
-#define        TX_CH1          0x00007F00lu
-#define        TX_CH2          0x007F0000lu
-#define        TX_CH3          0x7F000000lu
-
-
-/* MXVR_ROUTING_1 Masks */
-
-#define        MUTE_CH4        0x00000080lu
-#define        MUTE_CH5        0x00008000lu
-#define        MUTE_CH6        0x00800000lu
-#define        MUTE_CH7        0x80000000lu
-
-#define        TX_CH4          0x0000007Flu
-#define        TX_CH5          0x00007F00lu
-#define        TX_CH6          0x007F0000lu
-#define        TX_CH7          0x7F000000lu
-
-
-/* MXVR_ROUTING_2 Masks */
-
-#define        MUTE_CH8        0x00000080lu
-#define        MUTE_CH9        0x00008000lu
-#define        MUTE_CH10       0x00800000lu
-#define        MUTE_CH11       0x80000000lu
-
-#define        TX_CH8          0x0000007Flu
-#define        TX_CH9          0x00007F00lu
-#define        TX_CH10         0x007F0000lu
-#define        TX_CH11         0x7F000000lu
-
-/* MXVR_ROUTING_3 Masks */
-
-#define        MUTE_CH12       0x00000080lu
-#define        MUTE_CH13       0x00008000lu
-#define        MUTE_CH14       0x00800000lu
-#define        MUTE_CH15       0x80000000lu
-
-#define        TX_CH12         0x0000007Flu
-#define        TX_CH13         0x00007F00lu
-#define        TX_CH14         0x007F0000lu
-#define        TX_CH15         0x7F000000lu
-
-
-/* MXVR_ROUTING_4 Masks */
-
-#define        MUTE_CH16       0x00000080lu
-#define        MUTE_CH17       0x00008000lu
-#define        MUTE_CH18       0x00800000lu
-#define        MUTE_CH19       0x80000000lu
-
-#define        TX_CH16         0x0000007Flu
-#define        TX_CH17         0x00007F00lu
-#define        TX_CH18         0x007F0000lu
-#define        TX_CH19         0x7F000000lu
-
-
-/* MXVR_ROUTING_5 Masks */
-
-#define        MUTE_CH20       0x00000080lu
-#define        MUTE_CH21       0x00008000lu
-#define        MUTE_CH22       0x00800000lu
-#define        MUTE_CH23       0x80000000lu
-
-#define        TX_CH20         0x0000007Flu
-#define        TX_CH21         0x00007F00lu
-#define        TX_CH22         0x007F0000lu
-#define        TX_CH23         0x7F000000lu
-
-
-/* MXVR_ROUTING_6 Masks */
-
-#define        MUTE_CH24       0x00000080lu
-#define        MUTE_CH25       0x00008000lu
-#define        MUTE_CH26       0x00800000lu
-#define        MUTE_CH27       0x80000000lu
-
-#define        TX_CH24         0x0000007Flu
-#define        TX_CH25         0x00007F00lu
-#define        TX_CH26         0x007F0000lu
-#define        TX_CH27         0x7F000000lu
-
-
-/* MXVR_ROUTING_7 Masks */
-
-#define        MUTE_CH28       0x00000080lu
-#define        MUTE_CH29       0x00008000lu
-#define        MUTE_CH30       0x00800000lu
-#define        MUTE_CH31       0x80000000lu
-
-#define        TX_CH28         0x0000007Flu
-#define        TX_CH29         0x00007F00lu
-#define        TX_CH30         0x007F0000lu
-#define        TX_CH31         0x7F000000lu
-
-
-/* MXVR_ROUTING_8 Masks */
-
-#define        MUTE_CH32       0x00000080lu
-#define        MUTE_CH33       0x00008000lu
-#define        MUTE_CH34       0x00800000lu
-#define        MUTE_CH35       0x80000000lu
-
-#define        TX_CH32         0x0000007Flu
-#define        TX_CH33         0x00007F00lu
-#define        TX_CH34         0x007F0000lu
-#define        TX_CH35         0x7F000000lu
-
-
-/* MXVR_ROUTING_9 Masks */
-
-#define        MUTE_CH36       0x00000080lu
-#define        MUTE_CH37       0x00008000lu
-#define        MUTE_CH38       0x00800000lu
-#define        MUTE_CH39       0x80000000lu
-
-#define        TX_CH36         0x0000007Flu
-#define        TX_CH37         0x00007F00lu
-#define        TX_CH38         0x007F0000lu
-#define        TX_CH39         0x7F000000lu
-
-
-/* MXVR_ROUTING_10 Masks */
-
-#define        MUTE_CH40       0x00000080lu
-#define        MUTE_CH41       0x00008000lu
-#define        MUTE_CH42       0x00800000lu
-#define        MUTE_CH43       0x80000000lu
-
-#define        TX_CH40         0x0000007Flu
-#define        TX_CH41         0x00007F00lu
-#define        TX_CH42         0x007F0000lu
-#define        TX_CH43         0x7F000000lu
-
-
-/* MXVR_ROUTING_11 Masks */
-
-#define        MUTE_CH44       0x00000080lu
-#define        MUTE_CH45       0x00008000lu
-#define        MUTE_CH46       0x00800000lu
-#define        MUTE_CH47       0x80000000lu
-
-#define        TX_CH44         0x0000007Flu
-#define        TX_CH45         0x00007F00lu
-#define        TX_CH46         0x007F0000lu
-#define        TX_CH47         0x7F000000lu
-
-
-/* MXVR_ROUTING_12 Masks */
-
-#define        MUTE_CH48       0x00000080lu
-#define        MUTE_CH49       0x00008000lu
-#define        MUTE_CH50       0x00800000lu
-#define        MUTE_CH51       0x80000000lu
-
-#define        TX_CH48         0x0000007Flu
-#define        TX_CH49         0x00007F00lu
-#define        TX_CH50         0x007F0000lu
-#define        TX_CH51         0x7F000000lu
-
-
-/* MXVR_ROUTING_13 Masks */
-
-#define        MUTE_CH52       0x00000080lu
-#define        MUTE_CH53       0x00008000lu
-#define        MUTE_CH54       0x00800000lu
-#define        MUTE_CH55       0x80000000lu
-
-#define        TX_CH52         0x0000007Flu
-#define        TX_CH53         0x00007F00lu
-#define        TX_CH54         0x007F0000lu
-#define        TX_CH55         0x7F000000lu
-
-
-/* MXVR_ROUTING_14 Masks */
-
-#define        MUTE_CH56       0x00000080lu
-#define        MUTE_CH57       0x00008000lu
-#define        MUTE_CH58       0x00800000lu
-#define        MUTE_CH59       0x80000000lu
-
-#define        TX_CH56         0x0000007Flu
-#define        TX_CH57         0x00007F00lu
-#define        TX_CH58         0x007F0000lu
-#define        TX_CH59         0x7F000000lu
-
-
-/* Control Message Receive Buffer (CMRB) Address Offsets */
-
-#define        CMRB_STRIDE       0x00000016lu
-
-#define        CMRB_DST_OFFSET   0x00000000lu
-#define        CMRB_SRC_OFFSET   0x00000002lu
-#define        CMRB_DATA_OFFSET  0x00000005lu
-
-
-/* Control Message Transmit Buffer (CMTB) Address Offsets */
-
-#define        CMTB_PRIO_OFFSET    0x00000000lu
-#define        CMTB_DST_OFFSET     0x00000002lu
-#define        CMTB_SRC_OFFSET     0x00000004lu
-#define        CMTB_TYPE_OFFSET    0x00000006lu
-#define        CMTB_DATA_OFFSET    0x00000007lu
-
-#define        CMTB_ANSWER_OFFSET  0x0000000Alu
-
-#define        CMTB_STAT_N_OFFSET  0x00000018lu
-#define        CMTB_STAT_A_OFFSET  0x00000016lu
-#define        CMTB_STAT_D_OFFSET  0x0000000Elu
-#define        CMTB_STAT_R_OFFSET  0x00000014lu
-#define        CMTB_STAT_W_OFFSET  0x00000014lu
-#define        CMTB_STAT_G_OFFSET  0x00000014lu
-
-
-/* Asynchronous        Packet Receive Buffer (APRB) Address Offsets */
-
-#define        APRB_STRIDE       0x00000400lu
-
-#define        APRB_DST_OFFSET   0x00000000lu
-#define        APRB_LEN_OFFSET   0x00000002lu
-#define        APRB_SRC_OFFSET   0x00000004lu
-#define        APRB_DATA_OFFSET  0x00000006lu
-
-
-/* Asynchronous        Packet Transmit Buffer (APTB) Address Offsets */
-
-#define        APTB_PRIO_OFFSET  0x00000000lu
-#define        APTB_DST_OFFSET   0x00000002lu
-#define        APTB_LEN_OFFSET   0x00000004lu
-#define        APTB_SRC_OFFSET   0x00000006lu
-#define        APTB_DATA_OFFSET  0x00000008lu
-
-
-/* Remote Read Buffer (RRDB) Address Offsets */
-
-#define        RRDB_WADDR_OFFSET 0x00000100lu
-#define        RRDB_WLEN_OFFSET  0x00000101lu
-
-
-
 /* ************         CONTROLLER AREA NETWORK (CAN) MASKS  ***************/
 /* CAN_CONTROL Masks                                    */
 #define        SRS                     0x0001  /* Software Reset */
index 295c78a465c2476eb91a05f7446da7c2ea5391e7..0c346fba9619a886a270c07cd058ff2088571553 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Analog Devices Inc.
+ * Copyright (C) 2008-2009 Analog Devices Inc.
  * Licensed under the GPL-2 or later.
  */
 
@@ -7,11 +7,8 @@
 #ifndef _MACH_GPIO_H_
 #define _MACH_GPIO_H_
 
-       /* FIXME:
-        * For now only support PORTF GPIOs.
-        * PORT C,D and E are for peripheral usage only
-        */
 #define MAX_BLACKFIN_GPIOS 16
+#define BFIN_SPECIAL_GPIO_BANKS 3
 
 #define        GPIO_PF0        0       /* PF */
 #define        GPIO_PF1        1
index 6121cf8b5872a63f110d7c457313c100fb1080ab..0083ba13ee9ecfb623b3a7f70213be8d99923b91 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef _MACH_PORTMUX_H_
 #define _MACH_PORTMUX_H_
 
-#define MAX_RESOURCES  MAX_BLACKFIN_GPIOS
+#define MAX_RESOURCES  64
 
 #define P_TMR2         (P_DONTCARE)
 #define P_TMR1         (P_DONTCARE)
index a09623dfd5504b063199c72b9f76d4df43ffaee7..70189a0d1a1905d95dbf6c243f0f1c4e88d6e6d8 100644 (file)
@@ -1,3 +1,27 @@
+config BF542
+       def_bool y
+       depends on BF542_std || BF542M
+config BF544
+       def_bool y
+       depends on BF544_std || BF544M
+config BF547
+       def_bool y
+       depends on BF547_std || BF547M
+config BF548
+       def_bool y
+       depends on BF548_std || BF548M
+config BF549
+       def_bool y
+       depends on BF549_std || BF549M
+
+config BF54xM
+       def_bool y
+       depends on (BF542M || BF544M || BF547M || BF548M || BF549M)
+
+config BF54x
+       def_bool y
+       depends on (BF542 || BF544 || BF547 || BF548 || BF549)
+
 if (BF54x)
 
 source "arch/blackfin/mach-bf548/boards/Kconfig"
index 1a5286bbb3fac68a4fc095fd494d0231a0a5608e..60193f72777c5d07f7bec6f46f16bfd46ce98a0c 100644 (file)
@@ -62,7 +62,7 @@ static struct isp1760_platform_data isp1760_priv = {
 };
 
 static struct platform_device bfin_isp1760_device = {
-       .name           = "isp1760-hcd",
+       .name           = "isp1760",
        .id             = 0,
        .dev = {
                .platform_data = &isp1760_priv,
@@ -154,7 +154,7 @@ static struct platform_device bf54x_kpad_device = {
 };
 #endif
 
-#if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
+#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
 #include <asm/bfin_rotary.h>
 
 static struct bfin_rotary_platform_data bfin_rotary_data = {
@@ -186,7 +186,7 @@ static struct platform_device bfin_rotary_device = {
 #endif
 
 #if defined(CONFIG_INPUT_ADXL34X) || defined(CONFIG_INPUT_ADXL34X_MODULE)
-#include <linux/spi/adxl34x.h>
+#include <linux/input/adxl34x.h>
 static const struct adxl34x_platform_data adxl34x_info = {
        .x_axis_offset = 0,
        .y_axis_offset = 0,
@@ -210,14 +210,17 @@ static const struct adxl34x_platform_data adxl34x_info = {
        .ev_code_y = ABS_Y,             /* EV_REL */
        .ev_code_z = ABS_Z,             /* EV_REL */
 
-       .ev_code_tap_x = BTN_TOUCH,             /* EV_KEY */
-       .ev_code_tap_y = BTN_TOUCH,             /* EV_KEY */
-       .ev_code_tap_z = BTN_TOUCH,             /* EV_KEY */
+       .ev_code_tap = {BTN_TOUCH, BTN_TOUCH, BTN_TOUCH}, /* EV_KEY x,y,z */
 
 /*     .ev_code_ff = KEY_F,*/          /* EV_KEY */
 /*     .ev_code_act_inactivity = KEY_A,*/      /* EV_KEY */
        .power_mode = ADXL_AUTO_SLEEP | ADXL_LINK,
        .fifo_mode = ADXL_FIFO_STREAM,
+       .orientation_enable = ADXL_EN_ORIENTATION_3D,
+       .deadzone_angle = ADXL_DEADZONE_ANGLE_10p8,
+       .divisor_length = ADXL_LP_FILTER_DIVISOR_16,
+       /* EV_KEY {+Z, +Y, +X, -X, -Y, -Z} */
+       .ev_codes_orient_3d = {BTN_Z, BTN_Y, BTN_X, BTN_A, BTN_B, BTN_C},
 };
 #endif
 
@@ -461,6 +464,44 @@ static struct platform_device musb_device = {
 };
 #endif
 
+#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
+unsigned short bfin_can_peripherals[] = {
+       P_CAN0_RX, P_CAN0_TX, 0
+};
+
+static struct resource bfin_can_resources[] = {
+       {
+               .start = 0xFFC02A00,
+               .end = 0xFFC02FFF,
+               .flags = IORESOURCE_MEM,
+       },
+       {
+               .start = IRQ_CAN0_RX,
+               .end = IRQ_CAN0_RX,
+               .flags = IORESOURCE_IRQ,
+       },
+       {
+               .start = IRQ_CAN0_TX,
+               .end = IRQ_CAN0_TX,
+               .flags = IORESOURCE_IRQ,
+       },
+       {
+               .start = IRQ_CAN0_ERROR,
+               .end = IRQ_CAN0_ERROR,
+               .flags = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device bfin_can_device = {
+       .name = "bfin_can",
+       .num_resources = ARRAY_SIZE(bfin_can_resources),
+       .resource = bfin_can_resources,
+       .dev = {
+               .platform_data = &bfin_can_peripherals, /* Passed to driver */
+       },
+};
+#endif
+
 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
 static struct resource bfin_atapi_resources[] = {
        {
@@ -953,6 +994,10 @@ static struct platform_device *ezkit_devices[] __initdata = {
        &bfin_isp1760_device,
 #endif
 
+#if defined(CONFIG_CAN_BFIN) || defined(CONFIG_CAN_BFIN_MODULE)
+       &bfin_can_device,
+#endif
+
 #if defined(CONFIG_PATA_BF54X) || defined(CONFIG_PATA_BF54X_MODULE)
        &bfin_atapi_device,
 #endif
@@ -974,7 +1019,7 @@ static struct platform_device *ezkit_devices[] __initdata = {
        &bf54x_kpad_device,
 #endif
 
-#if defined(CONFIG_JOYSTICK_BFIN_ROTARY) || defined(CONFIG_JOYSTICK_BFIN_ROTARY_MODULE)
+#if defined(CONFIG_INPUT_BFIN_ROTARY) || defined(CONFIG_INPUT_BFIN_ROTARY_MODULE)
        &bfin_rotary_device,
 #endif
 
index 7bead5ce0f3b8712b453bb5252821da86ca4d485..751e5e11ecf889c53ea8bb9b6f387ba7a2e34578 100644 (file)
 
 #define AMGCTLVAL      (V_AMBEN | V_AMCKEN)
 
-#if defined(CONFIG_BF542M)
-# define CONFIG_BF542
-#elif defined(CONFIG_BF544M)
-# define CONFIG_BF544
-#elif defined(CONFIG_BF547M)
-# define CONFIG_BF547
-#elif defined(CONFIG_BF548M)
-# define CONFIG_BF548
-#elif defined(CONFIG_BF549M)
-# define CONFIG_BF549
-#endif
-
 #if defined(CONFIG_BF542)
 # define CPU   "BF542"
 # define CPUID 0x27de
index 13302b67857a50ee4dd424480e64a5689381d75d..5684030ccc21101f3fd47e781bbcc5f25fa18b71 100644 (file)
 #define OFFSET_THR              0x28   /* Transmit Holding register            */
 #define OFFSET_RBR              0x2C   /* Receive Buffer register              */
 
-/* PLL_DIV Masks */
-#define CCLK_DIV1 CSEL_DIV1    /* CCLK = VCO / 1 */
-#define CCLK_DIV2 CSEL_DIV2    /* CCLK = VCO / 2 */
-#define CCLK_DIV4 CSEL_DIV4    /* CCLK = VCO / 4 */
-#define CCLK_DIV8 CSEL_DIV8    /* CCLK = VCO / 8 */
-
 #endif
index 42342151513426a33f8f27c370fbe24672d8f193..bc650e6ea4828bf7b116886da8b3a845bdf9a6bc 100644 (file)
@@ -4,21 +4,21 @@
  * Licensed under the GPL-2 or later.
  */
 
-#ifndef _CDEF_BF548_H
-#define _CDEF_BF548_H
+#ifndef _CDEF_BF547_H
+#define _CDEF_BF547_H
 
 /* include all Core registers and bit definitions */
-#include "defBF548.h"
+#include "defBF547.h"
 
 /* include core sbfin_read_()ecific register pointer definitions */
 #include <asm/cdef_LPBlackfin.h>
 
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF548 */
+/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF547 */
 
 /* include cdefBF54x_base.h for the set of #defines that are common to all ADSP-BF54x bfin_read_()rocessors */
 #include "cdefBF54x_base.h"
 
-/* The following are the #defines needed by ADSP-BF548 that are not in the common header */
+/* The following are the #defines needed by ADSP-BF547 that are not in the common header */
 
 /* Timer Registers */
 
 #define bfin_read_HMDMA1_BCOUNT()              bfin_read16(HMDMA1_BCOUNT)
 #define bfin_write_HMDMA1_BCOUNT(val)          bfin_write16(HMDMA1_BCOUNT, val)
 
-#endif /* _CDEF_BF548_H */
+#endif /* _CDEF_BF547_H */
index df84180410c45e2d0d47799050ca49a9e0159ed8..3523e08f7968e092f3e3a2dcd195cfdc96dfde5f 100644 (file)
 /* include cdefBF54x_base.h for the set of #defines that are common to all ADSP-BF54x bfin_read_()rocessors */
 #include "cdefBF54x_base.h"
 
-/* The following are the #defines needed by ADSP-BF548 that are not in the common header */
-
-/* Timer Registers */
-
-#define bfin_read_TIMER8_CONFIG()      bfin_read16(TIMER8_CONFIG)
-#define bfin_write_TIMER8_CONFIG(val)  bfin_write16(TIMER8_CONFIG, val)
-#define bfin_read_TIMER8_COUNTER()     bfin_read32(TIMER8_COUNTER)
-#define bfin_write_TIMER8_COUNTER(val) bfin_write32(TIMER8_COUNTER, val)
-#define bfin_read_TIMER8_PERIOD()      bfin_read32(TIMER8_PERIOD)
-#define bfin_write_TIMER8_PERIOD(val)  bfin_write32(TIMER8_PERIOD, val)
-#define bfin_read_TIMER8_WIDTH()       bfin_read32(TIMER8_WIDTH)
-#define bfin_write_TIMER8_WIDTH(val)   bfin_write32(TIMER8_WIDTH, val)
-#define bfin_read_TIMER9_CONFIG()      bfin_read16(TIMER9_CONFIG)
-#define bfin_write_TIMER9_CONFIG(val)  bfin_write16(TIMER9_CONFIG, val)
-#define bfin_read_TIMER9_COUNTER()     bfin_read32(TIMER9_COUNTER)
-#define bfin_write_TIMER9_COUNTER(val) bfin_write32(TIMER9_COUNTER, val)
-#define bfin_read_TIMER9_PERIOD()      bfin_read32(TIMER9_PERIOD)
-#define bfin_write_TIMER9_PERIOD(val)  bfin_write32(TIMER9_PERIOD, val)
-#define bfin_read_TIMER9_WIDTH()       bfin_read32(TIMER9_WIDTH)
-#define bfin_write_TIMER9_WIDTH(val)   bfin_write32(TIMER9_WIDTH, val)
-#define bfin_read_TIMER10_CONFIG()     bfin_read16(TIMER10_CONFIG)
-#define bfin_write_TIMER10_CONFIG(val) bfin_write16(TIMER10_CONFIG, val)
-#define bfin_read_TIMER10_COUNTER()    bfin_read32(TIMER10_COUNTER)
-#define bfin_write_TIMER10_COUNTER(val)        bfin_write32(TIMER10_COUNTER, val)
-#define bfin_read_TIMER10_PERIOD()     bfin_read32(TIMER10_PERIOD)
-#define bfin_write_TIMER10_PERIOD(val) bfin_write32(TIMER10_PERIOD, val)
-#define bfin_read_TIMER10_WIDTH()      bfin_read32(TIMER10_WIDTH)
-#define bfin_write_TIMER10_WIDTH(val)  bfin_write32(TIMER10_WIDTH, val)
-
-/* Timer Groubfin_read_() of 3 */
-
-#define bfin_read_TIMER_ENABLE1()      bfin_read16(TIMER_ENABLE1)
-#define bfin_write_TIMER_ENABLE1(val)  bfin_write16(TIMER_ENABLE1, val)
-#define bfin_read_TIMER_DISABLE1()     bfin_read16(TIMER_DISABLE1)
-#define bfin_write_TIMER_DISABLE1(val) bfin_write16(TIMER_DISABLE1, val)
-#define bfin_read_TIMER_STATUS1()      bfin_read32(TIMER_STATUS1)
-#define bfin_write_TIMER_STATUS1(val)  bfin_write32(TIMER_STATUS1, val)
-
-/* SPORT0 Registers */
-
-#define bfin_read_SPORT0_TCR1()                bfin_read16(SPORT0_TCR1)
-#define bfin_write_SPORT0_TCR1(val)    bfin_write16(SPORT0_TCR1, val)
-#define bfin_read_SPORT0_TCR2()                bfin_read16(SPORT0_TCR2)
-#define bfin_write_SPORT0_TCR2(val)    bfin_write16(SPORT0_TCR2, val)
-#define bfin_read_SPORT0_TCLKDIV()     bfin_read16(SPORT0_TCLKDIV)
-#define bfin_write_SPORT0_TCLKDIV(val) bfin_write16(SPORT0_TCLKDIV, val)
-#define bfin_read_SPORT0_TFSDIV()      bfin_read16(SPORT0_TFSDIV)
-#define bfin_write_SPORT0_TFSDIV(val)  bfin_write16(SPORT0_TFSDIV, val)
-#define bfin_read_SPORT0_TX()          bfin_read32(SPORT0_TX)
-#define bfin_write_SPORT0_TX(val)      bfin_write32(SPORT0_TX, val)
-#define bfin_read_SPORT0_RX()          bfin_read32(SPORT0_RX)
-#define bfin_write_SPORT0_RX(val)      bfin_write32(SPORT0_RX, val)
-#define bfin_read_SPORT0_RCR1()                bfin_read16(SPORT0_RCR1)
-#define bfin_write_SPORT0_RCR1(val)    bfin_write16(SPORT0_RCR1, val)
-#define bfin_read_SPORT0_RCR2()                bfin_read16(SPORT0_RCR2)
-#define bfin_write_SPORT0_RCR2(val)    bfin_write16(SPORT0_RCR2, val)
-#define bfin_read_SPORT0_RCLKDIV()     bfin_read16(SPORT0_RCLKDIV)
-#define bfin_write_SPORT0_RCLKDIV(val) bfin_write16(SPORT0_RCLKDIV, val)
-#define bfin_read_SPORT0_RFSDIV()      bfin_read16(SPORT0_RFSDIV)
-#define bfin_write_SPORT0_RFSDIV(val)  bfin_write16(SPORT0_RFSDIV, val)
-#define bfin_read_SPORT0_STAT()                bfin_read16(SPORT0_STAT)
-#define bfin_write_SPORT0_STAT(val)    bfin_write16(SPORT0_STAT, val)
-#define bfin_read_SPORT0_CHNL()                bfin_read16(SPORT0_CHNL)
-#define bfin_write_SPORT0_CHNL(val)    bfin_write16(SPORT0_CHNL, val)
-#define bfin_read_SPORT0_MCMC1()       bfin_read16(SPORT0_MCMC1)
-#define bfin_write_SPORT0_MCMC1(val)   bfin_write16(SPORT0_MCMC1, val)
-#define bfin_read_SPORT0_MCMC2()       bfin_read16(SPORT0_MCMC2)
-#define bfin_write_SPORT0_MCMC2(val)   bfin_write16(SPORT0_MCMC2, val)
-#define bfin_read_SPORT0_MTCS0()       bfin_read32(SPORT0_MTCS0)
-#define bfin_write_SPORT0_MTCS0(val)   bfin_write32(SPORT0_MTCS0, val)
-#define bfin_read_SPORT0_MTCS1()       bfin_read32(SPORT0_MTCS1)
-#define bfin_write_SPORT0_MTCS1(val)   bfin_write32(SPORT0_MTCS1, val)
-#define bfin_read_SPORT0_MTCS2()       bfin_read32(SPORT0_MTCS2)
-#define bfin_write_SPORT0_MTCS2(val)   bfin_write32(SPORT0_MTCS2, val)
-#define bfin_read_SPORT0_MTCS3()       bfin_read32(SPORT0_MTCS3)
-#define bfin_write_SPORT0_MTCS3(val)   bfin_write32(SPORT0_MTCS3, val)
-#define bfin_read_SPORT0_MRCS0()       bfin_read32(SPORT0_MRCS0)
-#define bfin_write_SPORT0_MRCS0(val)   bfin_write32(SPORT0_MRCS0, val)
-#define bfin_read_SPORT0_MRCS1()       bfin_read32(SPORT0_MRCS1)
-#define bfin_write_SPORT0_MRCS1(val)   bfin_write32(SPORT0_MRCS1, val)
-#define bfin_read_SPORT0_MRCS2()       bfin_read32(SPORT0_MRCS2)
-#define bfin_write_SPORT0_MRCS2(val)   bfin_write32(SPORT0_MRCS2, val)
-#define bfin_read_SPORT0_MRCS3()       bfin_read32(SPORT0_MRCS3)
-#define bfin_write_SPORT0_MRCS3(val)   bfin_write32(SPORT0_MRCS3, val)
-
-/* EPPI0 Registers */
-
-#define bfin_read_EPPI0_STATUS()       bfin_read16(EPPI0_STATUS)
-#define bfin_write_EPPI0_STATUS(val)   bfin_write16(EPPI0_STATUS, val)
-#define bfin_read_EPPI0_HCOUNT()       bfin_read16(EPPI0_HCOUNT)
-#define bfin_write_EPPI0_HCOUNT(val)   bfin_write16(EPPI0_HCOUNT, val)
-#define bfin_read_EPPI0_HDELAY()       bfin_read16(EPPI0_HDELAY)
-#define bfin_write_EPPI0_HDELAY(val)   bfin_write16(EPPI0_HDELAY, val)
-#define bfin_read_EPPI0_VCOUNT()       bfin_read16(EPPI0_VCOUNT)
-#define bfin_write_EPPI0_VCOUNT(val)   bfin_write16(EPPI0_VCOUNT, val)
-#define bfin_read_EPPI0_VDELAY()       bfin_read16(EPPI0_VDELAY)
-#define bfin_write_EPPI0_VDELAY(val)   bfin_write16(EPPI0_VDELAY, val)
-#define bfin_read_EPPI0_FRAME()                bfin_read16(EPPI0_FRAME)
-#define bfin_write_EPPI0_FRAME(val)    bfin_write16(EPPI0_FRAME, val)
-#define bfin_read_EPPI0_LINE()         bfin_read16(EPPI0_LINE)
-#define bfin_write_EPPI0_LINE(val)     bfin_write16(EPPI0_LINE, val)
-#define bfin_read_EPPI0_CLKDIV()       bfin_read16(EPPI0_CLKDIV)
-#define bfin_write_EPPI0_CLKDIV(val)   bfin_write16(EPPI0_CLKDIV, val)
-#define bfin_read_EPPI0_CONTROL()      bfin_read32(EPPI0_CONTROL)
-#define bfin_write_EPPI0_CONTROL(val)  bfin_write32(EPPI0_CONTROL, val)
-#define bfin_read_EPPI0_FS1W_HBL()     bfin_read32(EPPI0_FS1W_HBL)
-#define bfin_write_EPPI0_FS1W_HBL(val) bfin_write32(EPPI0_FS1W_HBL, val)
-#define bfin_read_EPPI0_FS1P_AVPL()    bfin_read32(EPPI0_FS1P_AVPL)
-#define bfin_write_EPPI0_FS1P_AVPL(val)        bfin_write32(EPPI0_FS1P_AVPL, val)
-#define bfin_read_EPPI0_FS2W_LVB()     bfin_read32(EPPI0_FS2W_LVB)
-#define bfin_write_EPPI0_FS2W_LVB(val) bfin_write32(EPPI0_FS2W_LVB, val)
-#define bfin_read_EPPI0_FS2P_LAVF()    bfin_read32(EPPI0_FS2P_LAVF)
-#define bfin_write_EPPI0_FS2P_LAVF(val)        bfin_write32(EPPI0_FS2P_LAVF, val)
-#define bfin_read_EPPI0_CLIP()         bfin_read32(EPPI0_CLIP)
-#define bfin_write_EPPI0_CLIP(val)     bfin_write32(EPPI0_CLIP, val)
-
-/* UART2 Registers */
-
-#define bfin_read_UART2_DLL()          bfin_read16(UART2_DLL)
-#define bfin_write_UART2_DLL(val)      bfin_write16(UART2_DLL, val)
-#define bfin_read_UART2_DLH()          bfin_read16(UART2_DLH)
-#define bfin_write_UART2_DLH(val)      bfin_write16(UART2_DLH, val)
-#define bfin_read_UART2_GCTL()         bfin_read16(UART2_GCTL)
-#define bfin_write_UART2_GCTL(val)     bfin_write16(UART2_GCTL, val)
-#define bfin_read_UART2_LCR()          bfin_read16(UART2_LCR)
-#define bfin_write_UART2_LCR(val)      bfin_write16(UART2_LCR, val)
-#define bfin_read_UART2_MCR()          bfin_read16(UART2_MCR)
-#define bfin_write_UART2_MCR(val)      bfin_write16(UART2_MCR, val)
-#define bfin_read_UART2_LSR()          bfin_read16(UART2_LSR)
-#define bfin_write_UART2_LSR(val)      bfin_write16(UART2_LSR, val)
-#define bfin_read_UART2_MSR()          bfin_read16(UART2_MSR)
-#define bfin_write_UART2_MSR(val)      bfin_write16(UART2_MSR, val)
-#define bfin_read_UART2_SCR()          bfin_read16(UART2_SCR)
-#define bfin_write_UART2_SCR(val)      bfin_write16(UART2_SCR, val)
-#define bfin_read_UART2_IER_SET()      bfin_read16(UART2_IER_SET)
-#define bfin_write_UART2_IER_SET(val)  bfin_write16(UART2_IER_SET, val)
-#define bfin_read_UART2_IER_CLEAR()    bfin_read16(UART2_IER_CLEAR)
-#define bfin_write_UART2_IER_CLEAR(val)        bfin_write16(UART2_IER_CLEAR, val)
-#define bfin_read_UART2_RBR()          bfin_read16(UART2_RBR)
-#define bfin_write_UART2_RBR(val)      bfin_write16(UART2_RBR, val)
-
-/* Two Wire Interface Registers (TWI1) */
-
-/* SPI2  Registers */
-
-#define bfin_read_SPI2_CTL()           bfin_read16(SPI2_CTL)
-#define bfin_write_SPI2_CTL(val)       bfin_write16(SPI2_CTL, val)
-#define bfin_read_SPI2_FLG()           bfin_read16(SPI2_FLG)
-#define bfin_write_SPI2_FLG(val)       bfin_write16(SPI2_FLG, val)
-#define bfin_read_SPI2_STAT()          bfin_read16(SPI2_STAT)
-#define bfin_write_SPI2_STAT(val)      bfin_write16(SPI2_STAT, val)
-#define bfin_read_SPI2_TDBR()          bfin_read16(SPI2_TDBR)
-#define bfin_write_SPI2_TDBR(val)      bfin_write16(SPI2_TDBR, val)
-#define bfin_read_SPI2_RDBR()          bfin_read16(SPI2_RDBR)
-#define bfin_write_SPI2_RDBR(val)      bfin_write16(SPI2_RDBR, val)
-#define bfin_read_SPI2_BAUD()          bfin_read16(SPI2_BAUD)
-#define bfin_write_SPI2_BAUD(val)      bfin_write16(SPI2_BAUD, val)
-#define bfin_read_SPI2_SHADOW()                bfin_read16(SPI2_SHADOW)
-#define bfin_write_SPI2_SHADOW(val)    bfin_write16(SPI2_SHADOW, val)
+/* The BF548 is like the BF547, but has additional CANs */
+#include "cdefBF547.h"
 
 /* CAN Controller 1 Config 1 Registers */
 
 #define bfin_read_CAN1_MB31_ID1()              bfin_read16(CAN1_MB31_ID1)
 #define bfin_write_CAN1_MB31_ID1(val)          bfin_write16(CAN1_MB31_ID1, val)
 
-/* ATAPI Registers */
-
-#define bfin_read_ATAPI_CONTROL()              bfin_read16(ATAPI_CONTROL)
-#define bfin_write_ATAPI_CONTROL(val)          bfin_write16(ATAPI_CONTROL, val)
-#define bfin_read_ATAPI_STATUS()               bfin_read16(ATAPI_STATUS)
-#define bfin_write_ATAPI_STATUS(val)           bfin_write16(ATAPI_STATUS, val)
-#define bfin_read_ATAPI_DEV_ADDR()             bfin_read16(ATAPI_DEV_ADDR)
-#define bfin_write_ATAPI_DEV_ADDR(val)         bfin_write16(ATAPI_DEV_ADDR, val)
-#define bfin_read_ATAPI_DEV_TXBUF()            bfin_read16(ATAPI_DEV_TXBUF)
-#define bfin_write_ATAPI_DEV_TXBUF(val)                bfin_write16(ATAPI_DEV_TXBUF, val)
-#define bfin_read_ATAPI_DEV_RXBUF()            bfin_read16(ATAPI_DEV_RXBUF)
-#define bfin_write_ATAPI_DEV_RXBUF(val)                bfin_write16(ATAPI_DEV_RXBUF, val)
-#define bfin_read_ATAPI_INT_MASK()             bfin_read16(ATAPI_INT_MASK)
-#define bfin_write_ATAPI_INT_MASK(val)         bfin_write16(ATAPI_INT_MASK, val)
-#define bfin_read_ATAPI_INT_STATUS()           bfin_read16(ATAPI_INT_STATUS)
-#define bfin_write_ATAPI_INT_STATUS(val)       bfin_write16(ATAPI_INT_STATUS, val)
-#define bfin_read_ATAPI_XFER_LEN()             bfin_read16(ATAPI_XFER_LEN)
-#define bfin_write_ATAPI_XFER_LEN(val)         bfin_write16(ATAPI_XFER_LEN, val)
-#define bfin_read_ATAPI_LINE_STATUS()          bfin_read16(ATAPI_LINE_STATUS)
-#define bfin_write_ATAPI_LINE_STATUS(val)      bfin_write16(ATAPI_LINE_STATUS, val)
-#define bfin_read_ATAPI_SM_STATE()             bfin_read16(ATAPI_SM_STATE)
-#define bfin_write_ATAPI_SM_STATE(val)         bfin_write16(ATAPI_SM_STATE, val)
-#define bfin_read_ATAPI_TERMINATE()            bfin_read16(ATAPI_TERMINATE)
-#define bfin_write_ATAPI_TERMINATE(val)                bfin_write16(ATAPI_TERMINATE, val)
-#define bfin_read_ATAPI_PIO_TFRCNT()           bfin_read16(ATAPI_PIO_TFRCNT)
-#define bfin_write_ATAPI_PIO_TFRCNT(val)       bfin_write16(ATAPI_PIO_TFRCNT, val)
-#define bfin_read_ATAPI_DMA_TFRCNT()           bfin_read16(ATAPI_DMA_TFRCNT)
-#define bfin_write_ATAPI_DMA_TFRCNT(val)       bfin_write16(ATAPI_DMA_TFRCNT, val)
-#define bfin_read_ATAPI_UMAIN_TFRCNT()         bfin_read16(ATAPI_UMAIN_TFRCNT)
-#define bfin_write_ATAPI_UMAIN_TFRCNT(val)     bfin_write16(ATAPI_UMAIN_TFRCNT, val)
-#define bfin_read_ATAPI_UDMAOUT_TFRCNT()       bfin_read16(ATAPI_UDMAOUT_TFRCNT)
-#define bfin_write_ATAPI_UDMAOUT_TFRCNT(val)   bfin_write16(ATAPI_UDMAOUT_TFRCNT, val)
-#define bfin_read_ATAPI_REG_TIM_0()            bfin_read16(ATAPI_REG_TIM_0)
-#define bfin_write_ATAPI_REG_TIM_0(val)                bfin_write16(ATAPI_REG_TIM_0, val)
-#define bfin_read_ATAPI_PIO_TIM_0()            bfin_read16(ATAPI_PIO_TIM_0)
-#define bfin_write_ATAPI_PIO_TIM_0(val)                bfin_write16(ATAPI_PIO_TIM_0, val)
-#define bfin_read_ATAPI_PIO_TIM_1()            bfin_read16(ATAPI_PIO_TIM_1)
-#define bfin_write_ATAPI_PIO_TIM_1(val)                bfin_write16(ATAPI_PIO_TIM_1, val)
-#define bfin_read_ATAPI_MULTI_TIM_0()          bfin_read16(ATAPI_MULTI_TIM_0)
-#define bfin_write_ATAPI_MULTI_TIM_0(val)      bfin_write16(ATAPI_MULTI_TIM_0, val)
-#define bfin_read_ATAPI_MULTI_TIM_1()          bfin_read16(ATAPI_MULTI_TIM_1)
-#define bfin_write_ATAPI_MULTI_TIM_1(val)      bfin_write16(ATAPI_MULTI_TIM_1, val)
-#define bfin_read_ATAPI_MULTI_TIM_2()          bfin_read16(ATAPI_MULTI_TIM_2)
-#define bfin_write_ATAPI_MULTI_TIM_2(val)      bfin_write16(ATAPI_MULTI_TIM_2, val)
-#define bfin_read_ATAPI_ULTRA_TIM_0()          bfin_read16(ATAPI_ULTRA_TIM_0)
-#define bfin_write_ATAPI_ULTRA_TIM_0(val)      bfin_write16(ATAPI_ULTRA_TIM_0, val)
-#define bfin_read_ATAPI_ULTRA_TIM_1()          bfin_read16(ATAPI_ULTRA_TIM_1)
-#define bfin_write_ATAPI_ULTRA_TIM_1(val)      bfin_write16(ATAPI_ULTRA_TIM_1, val)
-#define bfin_read_ATAPI_ULTRA_TIM_2()          bfin_read16(ATAPI_ULTRA_TIM_2)
-#define bfin_write_ATAPI_ULTRA_TIM_2(val)      bfin_write16(ATAPI_ULTRA_TIM_2, val)
-#define bfin_read_ATAPI_ULTRA_TIM_3()          bfin_read16(ATAPI_ULTRA_TIM_3)
-#define bfin_write_ATAPI_ULTRA_TIM_3(val)      bfin_write16(ATAPI_ULTRA_TIM_3, val)
-
-/* SDH Registers */
-
-#define bfin_read_SDH_PWR_CTL()                bfin_read16(SDH_PWR_CTL)
-#define bfin_write_SDH_PWR_CTL(val)    bfin_write16(SDH_PWR_CTL, val)
-#define bfin_read_SDH_CLK_CTL()                bfin_read16(SDH_CLK_CTL)
-#define bfin_write_SDH_CLK_CTL(val)    bfin_write16(SDH_CLK_CTL, val)
-#define bfin_read_SDH_ARGUMENT()       bfin_read32(SDH_ARGUMENT)
-#define bfin_write_SDH_ARGUMENT(val)   bfin_write32(SDH_ARGUMENT, val)
-#define bfin_read_SDH_COMMAND()                bfin_read16(SDH_COMMAND)
-#define bfin_write_SDH_COMMAND(val)    bfin_write16(SDH_COMMAND, val)
-#define bfin_read_SDH_RESP_CMD()       bfin_read16(SDH_RESP_CMD)
-#define bfin_write_SDH_RESP_CMD(val)   bfin_write16(SDH_RESP_CMD, val)
-#define bfin_read_SDH_RESPONSE0()      bfin_read32(SDH_RESPONSE0)
-#define bfin_write_SDH_RESPONSE0(val)  bfin_write32(SDH_RESPONSE0, val)
-#define bfin_read_SDH_RESPONSE1()      bfin_read32(SDH_RESPONSE1)
-#define bfin_write_SDH_RESPONSE1(val)  bfin_write32(SDH_RESPONSE1, val)
-#define bfin_read_SDH_RESPONSE2()      bfin_read32(SDH_RESPONSE2)
-#define bfin_write_SDH_RESPONSE2(val)  bfin_write32(SDH_RESPONSE2, val)
-#define bfin_read_SDH_RESPONSE3()      bfin_read32(SDH_RESPONSE3)
-#define bfin_write_SDH_RESPONSE3(val)  bfin_write32(SDH_RESPONSE3, val)
-#define bfin_read_SDH_DATA_TIMER()     bfin_read32(SDH_DATA_TIMER)
-#define bfin_write_SDH_DATA_TIMER(val) bfin_write32(SDH_DATA_TIMER, val)
-#define bfin_read_SDH_DATA_LGTH()      bfin_read16(SDH_DATA_LGTH)
-#define bfin_write_SDH_DATA_LGTH(val)  bfin_write16(SDH_DATA_LGTH, val)
-#define bfin_read_SDH_DATA_CTL()       bfin_read16(SDH_DATA_CTL)
-#define bfin_write_SDH_DATA_CTL(val)   bfin_write16(SDH_DATA_CTL, val)
-#define bfin_read_SDH_DATA_CNT()       bfin_read16(SDH_DATA_CNT)
-#define bfin_write_SDH_DATA_CNT(val)   bfin_write16(SDH_DATA_CNT, val)
-#define bfin_read_SDH_STATUS()         bfin_read32(SDH_STATUS)
-#define bfin_write_SDH_STATUS(val)     bfin_write32(SDH_STATUS, val)
-#define bfin_read_SDH_STATUS_CLR()     bfin_read16(SDH_STATUS_CLR)
-#define bfin_write_SDH_STATUS_CLR(val) bfin_write16(SDH_STATUS_CLR, val)
-#define bfin_read_SDH_MASK0()          bfin_read32(SDH_MASK0)
-#define bfin_write_SDH_MASK0(val)      bfin_write32(SDH_MASK0, val)
-#define bfin_read_SDH_MASK1()          bfin_read32(SDH_MASK1)
-#define bfin_write_SDH_MASK1(val)      bfin_write32(SDH_MASK1, val)
-#define bfin_read_SDH_FIFO_CNT()       bfin_read16(SDH_FIFO_CNT)
-#define bfin_write_SDH_FIFO_CNT(val)   bfin_write16(SDH_FIFO_CNT, val)
-#define bfin_read_SDH_FIFO()           bfin_read32(SDH_FIFO)
-#define bfin_write_SDH_FIFO(val)       bfin_write32(SDH_FIFO, val)
-#define bfin_read_SDH_E_STATUS()       bfin_read16(SDH_E_STATUS)
-#define bfin_write_SDH_E_STATUS(val)   bfin_write16(SDH_E_STATUS, val)
-#define bfin_read_SDH_E_MASK()         bfin_read16(SDH_E_MASK)
-#define bfin_write_SDH_E_MASK(val)     bfin_write16(SDH_E_MASK, val)
-#define bfin_read_SDH_CFG()            bfin_read16(SDH_CFG)
-#define bfin_write_SDH_CFG(val)                bfin_write16(SDH_CFG, val)
-#define bfin_read_SDH_RD_WAIT_EN()     bfin_read16(SDH_RD_WAIT_EN)
-#define bfin_write_SDH_RD_WAIT_EN(val) bfin_write16(SDH_RD_WAIT_EN, val)
-#define bfin_read_SDH_PID0()           bfin_read16(SDH_PID0)
-#define bfin_write_SDH_PID0(val)       bfin_write16(SDH_PID0, val)
-#define bfin_read_SDH_PID1()           bfin_read16(SDH_PID1)
-#define bfin_write_SDH_PID1(val)       bfin_write16(SDH_PID1, val)
-#define bfin_read_SDH_PID2()           bfin_read16(SDH_PID2)
-#define bfin_write_SDH_PID2(val)       bfin_write16(SDH_PID2, val)
-#define bfin_read_SDH_PID3()           bfin_read16(SDH_PID3)
-#define bfin_write_SDH_PID3(val)       bfin_write16(SDH_PID3, val)
-#define bfin_read_SDH_PID4()           bfin_read16(SDH_PID4)
-#define bfin_write_SDH_PID4(val)       bfin_write16(SDH_PID4, val)
-#define bfin_read_SDH_PID5()           bfin_read16(SDH_PID5)
-#define bfin_write_SDH_PID5(val)       bfin_write16(SDH_PID5, val)
-#define bfin_read_SDH_PID6()           bfin_read16(SDH_PID6)
-#define bfin_write_SDH_PID6(val)       bfin_write16(SDH_PID6, val)
-#define bfin_read_SDH_PID7()           bfin_read16(SDH_PID7)
-#define bfin_write_SDH_PID7(val)       bfin_write16(SDH_PID7, val)
-
-/* HOST Port Registers */
-
-#define bfin_read_HOST_CONTROL()       bfin_read16(HOST_CONTROL)
-#define bfin_write_HOST_CONTROL(val)   bfin_write16(HOST_CONTROL, val)
-#define bfin_read_HOST_STATUS()                bfin_read16(HOST_STATUS)
-#define bfin_write_HOST_STATUS(val)    bfin_write16(HOST_STATUS, val)
-#define bfin_read_HOST_TIMEOUT()       bfin_read16(HOST_TIMEOUT)
-#define bfin_write_HOST_TIMEOUT(val)   bfin_write16(HOST_TIMEOUT, val)
-
-/* USB Control Registers */
-
-#define bfin_read_USB_FADDR()          bfin_read16(USB_FADDR)
-#define bfin_write_USB_FADDR(val)      bfin_write16(USB_FADDR, val)
-#define bfin_read_USB_POWER()          bfin_read16(USB_POWER)
-#define bfin_write_USB_POWER(val)      bfin_write16(USB_POWER, val)
-#define bfin_read_USB_INTRTX()         bfin_read16(USB_INTRTX)
-#define bfin_write_USB_INTRTX(val)     bfin_write16(USB_INTRTX, val)
-#define bfin_read_USB_INTRRX()         bfin_read16(USB_INTRRX)
-#define bfin_write_USB_INTRRX(val)     bfin_write16(USB_INTRRX, val)
-#define bfin_read_USB_INTRTXE()                bfin_read16(USB_INTRTXE)
-#define bfin_write_USB_INTRTXE(val)    bfin_write16(USB_INTRTXE, val)
-#define bfin_read_USB_INTRRXE()                bfin_read16(USB_INTRRXE)
-#define bfin_write_USB_INTRRXE(val)    bfin_write16(USB_INTRRXE, val)
-#define bfin_read_USB_INTRUSB()                bfin_read16(USB_INTRUSB)
-#define bfin_write_USB_INTRUSB(val)    bfin_write16(USB_INTRUSB, val)
-#define bfin_read_USB_INTRUSBE()       bfin_read16(USB_INTRUSBE)
-#define bfin_write_USB_INTRUSBE(val)   bfin_write16(USB_INTRUSBE, val)
-#define bfin_read_USB_FRAME()          bfin_read16(USB_FRAME)
-#define bfin_write_USB_FRAME(val)      bfin_write16(USB_FRAME, val)
-#define bfin_read_USB_INDEX()          bfin_read16(USB_INDEX)
-#define bfin_write_USB_INDEX(val)      bfin_write16(USB_INDEX, val)
-#define bfin_read_USB_TESTMODE()       bfin_read16(USB_TESTMODE)
-#define bfin_write_USB_TESTMODE(val)   bfin_write16(USB_TESTMODE, val)
-#define bfin_read_USB_GLOBINTR()       bfin_read16(USB_GLOBINTR)
-#define bfin_write_USB_GLOBINTR(val)   bfin_write16(USB_GLOBINTR, val)
-#define bfin_read_USB_GLOBAL_CTL()     bfin_read16(USB_GLOBAL_CTL)
-#define bfin_write_USB_GLOBAL_CTL(val)         bfin_write16(USB_GLOBAL_CTL, val)
-
-/* USB Packet Control Registers */
-
-#define bfin_read_USB_TX_MAX_PACKET()          bfin_read16(USB_TX_MAX_PACKET)
-#define bfin_write_USB_TX_MAX_PACKET(val)      bfin_write16(USB_TX_MAX_PACKET, val)
-#define bfin_read_USB_CSR0()           bfin_read16(USB_CSR0)
-#define bfin_write_USB_CSR0(val)       bfin_write16(USB_CSR0, val)
-#define bfin_read_USB_TXCSR()          bfin_read16(USB_TXCSR)
-#define bfin_write_USB_TXCSR(val)      bfin_write16(USB_TXCSR, val)
-#define bfin_read_USB_RX_MAX_PACKET()          bfin_read16(USB_RX_MAX_PACKET)
-#define bfin_write_USB_RX_MAX_PACKET(val)      bfin_write16(USB_RX_MAX_PACKET, val)
-#define bfin_read_USB_RXCSR()          bfin_read16(USB_RXCSR)
-#define bfin_write_USB_RXCSR(val)      bfin_write16(USB_RXCSR, val)
-#define bfin_read_USB_COUNT0()         bfin_read16(USB_COUNT0)
-#define bfin_write_USB_COUNT0(val)     bfin_write16(USB_COUNT0, val)
-#define bfin_read_USB_RXCOUNT()                bfin_read16(USB_RXCOUNT)
-#define bfin_write_USB_RXCOUNT(val)    bfin_write16(USB_RXCOUNT, val)
-#define bfin_read_USB_TXTYPE()         bfin_read16(USB_TXTYPE)
-#define bfin_write_USB_TXTYPE(val)     bfin_write16(USB_TXTYPE, val)
-#define bfin_read_USB_NAKLIMIT0()      bfin_read16(USB_NAKLIMIT0)
-#define bfin_write_USB_NAKLIMIT0(val)  bfin_write16(USB_NAKLIMIT0, val)
-#define bfin_read_USB_TXINTERVAL()     bfin_read16(USB_TXINTERVAL)
-#define bfin_write_USB_TXINTERVAL(val) bfin_write16(USB_TXINTERVAL, val)
-#define bfin_read_USB_RXTYPE()         bfin_read16(USB_RXTYPE)
-#define bfin_write_USB_RXTYPE(val)     bfin_write16(USB_RXTYPE, val)
-#define bfin_read_USB_RXINTERVAL()     bfin_read16(USB_RXINTERVAL)
-#define bfin_write_USB_RXINTERVAL(val) bfin_write16(USB_RXINTERVAL, val)
-#define bfin_read_USB_TXCOUNT()                bfin_read16(USB_TXCOUNT)
-#define bfin_write_USB_TXCOUNT(val)    bfin_write16(USB_TXCOUNT, val)
-
-/* USB Endbfin_read_()oint FIFO Registers */
-
-#define bfin_read_USB_EP0_FIFO()       bfin_read16(USB_EP0_FIFO)
-#define bfin_write_USB_EP0_FIFO(val)   bfin_write16(USB_EP0_FIFO, val)
-#define bfin_read_USB_EP1_FIFO()       bfin_read16(USB_EP1_FIFO)
-#define bfin_write_USB_EP1_FIFO(val)   bfin_write16(USB_EP1_FIFO, val)
-#define bfin_read_USB_EP2_FIFO()       bfin_read16(USB_EP2_FIFO)
-#define bfin_write_USB_EP2_FIFO(val)   bfin_write16(USB_EP2_FIFO, val)
-#define bfin_read_USB_EP3_FIFO()       bfin_read16(USB_EP3_FIFO)
-#define bfin_write_USB_EP3_FIFO(val)   bfin_write16(USB_EP3_FIFO, val)
-#define bfin_read_USB_EP4_FIFO()       bfin_read16(USB_EP4_FIFO)
-#define bfin_write_USB_EP4_FIFO(val)   bfin_write16(USB_EP4_FIFO, val)
-#define bfin_read_USB_EP5_FIFO()       bfin_read16(USB_EP5_FIFO)
-#define bfin_write_USB_EP5_FIFO(val)   bfin_write16(USB_EP5_FIFO, val)
-#define bfin_read_USB_EP6_FIFO()       bfin_read16(USB_EP6_FIFO)
-#define bfin_write_USB_EP6_FIFO(val)   bfin_write16(USB_EP6_FIFO, val)
-#define bfin_read_USB_EP7_FIFO()       bfin_read16(USB_EP7_FIFO)
-#define bfin_write_USB_EP7_FIFO(val)   bfin_write16(USB_EP7_FIFO, val)
-
-/* USB OTG Control Registers */
-
-#define bfin_read_USB_OTG_DEV_CTL()            bfin_read16(USB_OTG_DEV_CTL)
-#define bfin_write_USB_OTG_DEV_CTL(val)                bfin_write16(USB_OTG_DEV_CTL, val)
-#define bfin_read_USB_OTG_VBUS_IRQ()           bfin_read16(USB_OTG_VBUS_IRQ)
-#define bfin_write_USB_OTG_VBUS_IRQ(val)       bfin_write16(USB_OTG_VBUS_IRQ, val)
-#define bfin_read_USB_OTG_VBUS_MASK()          bfin_read16(USB_OTG_VBUS_MASK)
-#define bfin_write_USB_OTG_VBUS_MASK(val)      bfin_write16(USB_OTG_VBUS_MASK, val)
-
-/* USB Phy Control Registers */
-
-#define bfin_read_USB_LINKINFO()       bfin_read16(USB_LINKINFO)
-#define bfin_write_USB_LINKINFO(val)   bfin_write16(USB_LINKINFO, val)
-#define bfin_read_USB_VPLEN()          bfin_read16(USB_VPLEN)
-#define bfin_write_USB_VPLEN(val)      bfin_write16(USB_VPLEN, val)
-#define bfin_read_USB_HS_EOF1()                bfin_read16(USB_HS_EOF1)
-#define bfin_write_USB_HS_EOF1(val)    bfin_write16(USB_HS_EOF1, val)
-#define bfin_read_USB_FS_EOF1()                bfin_read16(USB_FS_EOF1)
-#define bfin_write_USB_FS_EOF1(val)    bfin_write16(USB_FS_EOF1, val)
-#define bfin_read_USB_LS_EOF1()                bfin_read16(USB_LS_EOF1)
-#define bfin_write_USB_LS_EOF1(val)    bfin_write16(USB_LS_EOF1, val)
-
-/* (APHY_CNTRL is for ADI usage only) */
-
-#define bfin_read_USB_APHY_CNTRL()             bfin_read16(USB_APHY_CNTRL)
-#define bfin_write_USB_APHY_CNTRL(val)         bfin_write16(USB_APHY_CNTRL, val)
-
-/* (APHY_CALIB is for ADI usage only) */
-
-#define bfin_read_USB_APHY_CALIB()             bfin_read16(USB_APHY_CALIB)
-#define bfin_write_USB_APHY_CALIB(val)         bfin_write16(USB_APHY_CALIB, val)
-#define bfin_read_USB_APHY_CNTRL2()            bfin_read16(USB_APHY_CNTRL2)
-#define bfin_write_USB_APHY_CNTRL2(val)                bfin_write16(USB_APHY_CNTRL2, val)
-
-/* (PHY_TEST is for ADI usage only) */
-
-#define bfin_read_USB_PHY_TEST()               bfin_read16(USB_PHY_TEST)
-#define bfin_write_USB_PHY_TEST(val)           bfin_write16(USB_PHY_TEST, val)
-#define bfin_read_USB_PLLOSC_CTRL()            bfin_read16(USB_PLLOSC_CTRL)
-#define bfin_write_USB_PLLOSC_CTRL(val)                bfin_write16(USB_PLLOSC_CTRL, val)
-#define bfin_read_USB_SRP_CLKDIV()             bfin_read16(USB_SRP_CLKDIV)
-#define bfin_write_USB_SRP_CLKDIV(val)         bfin_write16(USB_SRP_CLKDIV, val)
-
-/* USB Endbfin_read_()oint 0 Control Registers */
-
-#define bfin_read_USB_EP_NI0_TXMAXP()          bfin_read16(USB_EP_NI0_TXMAXP)
-#define bfin_write_USB_EP_NI0_TXMAXP(val)      bfin_write16(USB_EP_NI0_TXMAXP, val)
-#define bfin_read_USB_EP_NI0_TXCSR()           bfin_read16(USB_EP_NI0_TXCSR)
-#define bfin_write_USB_EP_NI0_TXCSR(val)       bfin_write16(USB_EP_NI0_TXCSR, val)
-#define bfin_read_USB_EP_NI0_RXMAXP()          bfin_read16(USB_EP_NI0_RXMAXP)
-#define bfin_write_USB_EP_NI0_RXMAXP(val)      bfin_write16(USB_EP_NI0_RXMAXP, val)
-#define bfin_read_USB_EP_NI0_RXCSR()           bfin_read16(USB_EP_NI0_RXCSR)
-#define bfin_write_USB_EP_NI0_RXCSR(val)       bfin_write16(USB_EP_NI0_RXCSR, val)
-#define bfin_read_USB_EP_NI0_RXCOUNT()         bfin_read16(USB_EP_NI0_RXCOUNT)
-#define bfin_write_USB_EP_NI0_RXCOUNT(val)     bfin_write16(USB_EP_NI0_RXCOUNT, val)
-#define bfin_read_USB_EP_NI0_TXTYPE()          bfin_read16(USB_EP_NI0_TXTYPE)
-#define bfin_write_USB_EP_NI0_TXTYPE(val)      bfin_write16(USB_EP_NI0_TXTYPE, val)
-#define bfin_read_USB_EP_NI0_TXINTERVAL()      bfin_read16(USB_EP_NI0_TXINTERVAL)
-#define bfin_write_USB_EP_NI0_TXINTERVAL(val)  bfin_write16(USB_EP_NI0_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI0_RXTYPE()          bfin_read16(USB_EP_NI0_RXTYPE)
-#define bfin_write_USB_EP_NI0_RXTYPE(val)      bfin_write16(USB_EP_NI0_RXTYPE, val)
-#define bfin_read_USB_EP_NI0_RXINTERVAL()      bfin_read16(USB_EP_NI0_RXINTERVAL)
-#define bfin_write_USB_EP_NI0_RXINTERVAL(val)  bfin_write16(USB_EP_NI0_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 1 Control Registers */
-
-#define bfin_read_USB_EP_NI0_TXCOUNT()         bfin_read16(USB_EP_NI0_TXCOUNT)
-#define bfin_write_USB_EP_NI0_TXCOUNT(val)     bfin_write16(USB_EP_NI0_TXCOUNT, val)
-#define bfin_read_USB_EP_NI1_TXMAXP()          bfin_read16(USB_EP_NI1_TXMAXP)
-#define bfin_write_USB_EP_NI1_TXMAXP(val)      bfin_write16(USB_EP_NI1_TXMAXP, val)
-#define bfin_read_USB_EP_NI1_TXCSR()           bfin_read16(USB_EP_NI1_TXCSR)
-#define bfin_write_USB_EP_NI1_TXCSR(val)       bfin_write16(USB_EP_NI1_TXCSR, val)
-#define bfin_read_USB_EP_NI1_RXMAXP()          bfin_read16(USB_EP_NI1_RXMAXP)
-#define bfin_write_USB_EP_NI1_RXMAXP(val)      bfin_write16(USB_EP_NI1_RXMAXP, val)
-#define bfin_read_USB_EP_NI1_RXCSR()           bfin_read16(USB_EP_NI1_RXCSR)
-#define bfin_write_USB_EP_NI1_RXCSR(val)       bfin_write16(USB_EP_NI1_RXCSR, val)
-#define bfin_read_USB_EP_NI1_RXCOUNT()         bfin_read16(USB_EP_NI1_RXCOUNT)
-#define bfin_write_USB_EP_NI1_RXCOUNT(val)     bfin_write16(USB_EP_NI1_RXCOUNT, val)
-#define bfin_read_USB_EP_NI1_TXTYPE()          bfin_read16(USB_EP_NI1_TXTYPE)
-#define bfin_write_USB_EP_NI1_TXTYPE(val)      bfin_write16(USB_EP_NI1_TXTYPE, val)
-#define bfin_read_USB_EP_NI1_TXINTERVAL()      bfin_read16(USB_EP_NI1_TXINTERVAL)
-#define bfin_write_USB_EP_NI1_TXINTERVAL(val)  bfin_write16(USB_EP_NI1_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI1_RXTYPE()          bfin_read16(USB_EP_NI1_RXTYPE)
-#define bfin_write_USB_EP_NI1_RXTYPE(val)      bfin_write16(USB_EP_NI1_RXTYPE, val)
-#define bfin_read_USB_EP_NI1_RXINTERVAL()      bfin_read16(USB_EP_NI1_RXINTERVAL)
-#define bfin_write_USB_EP_NI1_RXINTERVAL(val)  bfin_write16(USB_EP_NI1_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 2 Control Registers */
-
-#define bfin_read_USB_EP_NI1_TXCOUNT()         bfin_read16(USB_EP_NI1_TXCOUNT)
-#define bfin_write_USB_EP_NI1_TXCOUNT(val)     bfin_write16(USB_EP_NI1_TXCOUNT, val)
-#define bfin_read_USB_EP_NI2_TXMAXP()          bfin_read16(USB_EP_NI2_TXMAXP)
-#define bfin_write_USB_EP_NI2_TXMAXP(val)      bfin_write16(USB_EP_NI2_TXMAXP, val)
-#define bfin_read_USB_EP_NI2_TXCSR()           bfin_read16(USB_EP_NI2_TXCSR)
-#define bfin_write_USB_EP_NI2_TXCSR(val)       bfin_write16(USB_EP_NI2_TXCSR, val)
-#define bfin_read_USB_EP_NI2_RXMAXP()          bfin_read16(USB_EP_NI2_RXMAXP)
-#define bfin_write_USB_EP_NI2_RXMAXP(val)      bfin_write16(USB_EP_NI2_RXMAXP, val)
-#define bfin_read_USB_EP_NI2_RXCSR()           bfin_read16(USB_EP_NI2_RXCSR)
-#define bfin_write_USB_EP_NI2_RXCSR(val)       bfin_write16(USB_EP_NI2_RXCSR, val)
-#define bfin_read_USB_EP_NI2_RXCOUNT()         bfin_read16(USB_EP_NI2_RXCOUNT)
-#define bfin_write_USB_EP_NI2_RXCOUNT(val)     bfin_write16(USB_EP_NI2_RXCOUNT, val)
-#define bfin_read_USB_EP_NI2_TXTYPE()          bfin_read16(USB_EP_NI2_TXTYPE)
-#define bfin_write_USB_EP_NI2_TXTYPE(val)      bfin_write16(USB_EP_NI2_TXTYPE, val)
-#define bfin_read_USB_EP_NI2_TXINTERVAL()      bfin_read16(USB_EP_NI2_TXINTERVAL)
-#define bfin_write_USB_EP_NI2_TXINTERVAL(val)  bfin_write16(USB_EP_NI2_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI2_RXTYPE()          bfin_read16(USB_EP_NI2_RXTYPE)
-#define bfin_write_USB_EP_NI2_RXTYPE(val)      bfin_write16(USB_EP_NI2_RXTYPE, val)
-#define bfin_read_USB_EP_NI2_RXINTERVAL()      bfin_read16(USB_EP_NI2_RXINTERVAL)
-#define bfin_write_USB_EP_NI2_RXINTERVAL(val)  bfin_write16(USB_EP_NI2_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 3 Control Registers */
-
-#define bfin_read_USB_EP_NI2_TXCOUNT()         bfin_read16(USB_EP_NI2_TXCOUNT)
-#define bfin_write_USB_EP_NI2_TXCOUNT(val)     bfin_write16(USB_EP_NI2_TXCOUNT, val)
-#define bfin_read_USB_EP_NI3_TXMAXP()          bfin_read16(USB_EP_NI3_TXMAXP)
-#define bfin_write_USB_EP_NI3_TXMAXP(val)      bfin_write16(USB_EP_NI3_TXMAXP, val)
-#define bfin_read_USB_EP_NI3_TXCSR()           bfin_read16(USB_EP_NI3_TXCSR)
-#define bfin_write_USB_EP_NI3_TXCSR(val)       bfin_write16(USB_EP_NI3_TXCSR, val)
-#define bfin_read_USB_EP_NI3_RXMAXP()          bfin_read16(USB_EP_NI3_RXMAXP)
-#define bfin_write_USB_EP_NI3_RXMAXP(val)      bfin_write16(USB_EP_NI3_RXMAXP, val)
-#define bfin_read_USB_EP_NI3_RXCSR()           bfin_read16(USB_EP_NI3_RXCSR)
-#define bfin_write_USB_EP_NI3_RXCSR(val)       bfin_write16(USB_EP_NI3_RXCSR, val)
-#define bfin_read_USB_EP_NI3_RXCOUNT()         bfin_read16(USB_EP_NI3_RXCOUNT)
-#define bfin_write_USB_EP_NI3_RXCOUNT(val)     bfin_write16(USB_EP_NI3_RXCOUNT, val)
-#define bfin_read_USB_EP_NI3_TXTYPE()          bfin_read16(USB_EP_NI3_TXTYPE)
-#define bfin_write_USB_EP_NI3_TXTYPE(val)      bfin_write16(USB_EP_NI3_TXTYPE, val)
-#define bfin_read_USB_EP_NI3_TXINTERVAL()      bfin_read16(USB_EP_NI3_TXINTERVAL)
-#define bfin_write_USB_EP_NI3_TXINTERVAL(val)  bfin_write16(USB_EP_NI3_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI3_RXTYPE()          bfin_read16(USB_EP_NI3_RXTYPE)
-#define bfin_write_USB_EP_NI3_RXTYPE(val)      bfin_write16(USB_EP_NI3_RXTYPE, val)
-#define bfin_read_USB_EP_NI3_RXINTERVAL()      bfin_read16(USB_EP_NI3_RXINTERVAL)
-#define bfin_write_USB_EP_NI3_RXINTERVAL(val)  bfin_write16(USB_EP_NI3_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 4 Control Registers */
-
-#define bfin_read_USB_EP_NI3_TXCOUNT()         bfin_read16(USB_EP_NI3_TXCOUNT)
-#define bfin_write_USB_EP_NI3_TXCOUNT(val)     bfin_write16(USB_EP_NI3_TXCOUNT, val)
-#define bfin_read_USB_EP_NI4_TXMAXP()          bfin_read16(USB_EP_NI4_TXMAXP)
-#define bfin_write_USB_EP_NI4_TXMAXP(val)      bfin_write16(USB_EP_NI4_TXMAXP, val)
-#define bfin_read_USB_EP_NI4_TXCSR()           bfin_read16(USB_EP_NI4_TXCSR)
-#define bfin_write_USB_EP_NI4_TXCSR(val)       bfin_write16(USB_EP_NI4_TXCSR, val)
-#define bfin_read_USB_EP_NI4_RXMAXP()          bfin_read16(USB_EP_NI4_RXMAXP)
-#define bfin_write_USB_EP_NI4_RXMAXP(val)      bfin_write16(USB_EP_NI4_RXMAXP, val)
-#define bfin_read_USB_EP_NI4_RXCSR()           bfin_read16(USB_EP_NI4_RXCSR)
-#define bfin_write_USB_EP_NI4_RXCSR(val)       bfin_write16(USB_EP_NI4_RXCSR, val)
-#define bfin_read_USB_EP_NI4_RXCOUNT()         bfin_read16(USB_EP_NI4_RXCOUNT)
-#define bfin_write_USB_EP_NI4_RXCOUNT(val)     bfin_write16(USB_EP_NI4_RXCOUNT, val)
-#define bfin_read_USB_EP_NI4_TXTYPE()          bfin_read16(USB_EP_NI4_TXTYPE)
-#define bfin_write_USB_EP_NI4_TXTYPE(val)      bfin_write16(USB_EP_NI4_TXTYPE, val)
-#define bfin_read_USB_EP_NI4_TXINTERVAL()      bfin_read16(USB_EP_NI4_TXINTERVAL)
-#define bfin_write_USB_EP_NI4_TXINTERVAL(val)  bfin_write16(USB_EP_NI4_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI4_RXTYPE()          bfin_read16(USB_EP_NI4_RXTYPE)
-#define bfin_write_USB_EP_NI4_RXTYPE(val)      bfin_write16(USB_EP_NI4_RXTYPE, val)
-#define bfin_read_USB_EP_NI4_RXINTERVAL()      bfin_read16(USB_EP_NI4_RXINTERVAL)
-#define bfin_write_USB_EP_NI4_RXINTERVAL(val)  bfin_write16(USB_EP_NI4_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 5 Control Registers */
-
-#define bfin_read_USB_EP_NI4_TXCOUNT()         bfin_read16(USB_EP_NI4_TXCOUNT)
-#define bfin_write_USB_EP_NI4_TXCOUNT(val)     bfin_write16(USB_EP_NI4_TXCOUNT, val)
-#define bfin_read_USB_EP_NI5_TXMAXP()          bfin_read16(USB_EP_NI5_TXMAXP)
-#define bfin_write_USB_EP_NI5_TXMAXP(val)      bfin_write16(USB_EP_NI5_TXMAXP, val)
-#define bfin_read_USB_EP_NI5_TXCSR()           bfin_read16(USB_EP_NI5_TXCSR)
-#define bfin_write_USB_EP_NI5_TXCSR(val)       bfin_write16(USB_EP_NI5_TXCSR, val)
-#define bfin_read_USB_EP_NI5_RXMAXP()          bfin_read16(USB_EP_NI5_RXMAXP)
-#define bfin_write_USB_EP_NI5_RXMAXP(val)      bfin_write16(USB_EP_NI5_RXMAXP, val)
-#define bfin_read_USB_EP_NI5_RXCSR()           bfin_read16(USB_EP_NI5_RXCSR)
-#define bfin_write_USB_EP_NI5_RXCSR(val)       bfin_write16(USB_EP_NI5_RXCSR, val)
-#define bfin_read_USB_EP_NI5_RXCOUNT()         bfin_read16(USB_EP_NI5_RXCOUNT)
-#define bfin_write_USB_EP_NI5_RXCOUNT(val)     bfin_write16(USB_EP_NI5_RXCOUNT, val)
-#define bfin_read_USB_EP_NI5_TXTYPE()          bfin_read16(USB_EP_NI5_TXTYPE)
-#define bfin_write_USB_EP_NI5_TXTYPE(val)      bfin_write16(USB_EP_NI5_TXTYPE, val)
-#define bfin_read_USB_EP_NI5_TXINTERVAL()      bfin_read16(USB_EP_NI5_TXINTERVAL)
-#define bfin_write_USB_EP_NI5_TXINTERVAL(val)  bfin_write16(USB_EP_NI5_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI5_RXTYPE()          bfin_read16(USB_EP_NI5_RXTYPE)
-#define bfin_write_USB_EP_NI5_RXTYPE(val)      bfin_write16(USB_EP_NI5_RXTYPE, val)
-#define bfin_read_USB_EP_NI5_RXINTERVAL()      bfin_read16(USB_EP_NI5_RXINTERVAL)
-#define bfin_write_USB_EP_NI5_RXINTERVAL(val)  bfin_write16(USB_EP_NI5_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 6 Control Registers */
-
-#define bfin_read_USB_EP_NI5_TXCOUNT()         bfin_read16(USB_EP_NI5_TXCOUNT)
-#define bfin_write_USB_EP_NI5_TXCOUNT(val)     bfin_write16(USB_EP_NI5_TXCOUNT, val)
-#define bfin_read_USB_EP_NI6_TXMAXP()          bfin_read16(USB_EP_NI6_TXMAXP)
-#define bfin_write_USB_EP_NI6_TXMAXP(val)      bfin_write16(USB_EP_NI6_TXMAXP, val)
-#define bfin_read_USB_EP_NI6_TXCSR()           bfin_read16(USB_EP_NI6_TXCSR)
-#define bfin_write_USB_EP_NI6_TXCSR(val)       bfin_write16(USB_EP_NI6_TXCSR, val)
-#define bfin_read_USB_EP_NI6_RXMAXP()          bfin_read16(USB_EP_NI6_RXMAXP)
-#define bfin_write_USB_EP_NI6_RXMAXP(val)      bfin_write16(USB_EP_NI6_RXMAXP, val)
-#define bfin_read_USB_EP_NI6_RXCSR()           bfin_read16(USB_EP_NI6_RXCSR)
-#define bfin_write_USB_EP_NI6_RXCSR(val)       bfin_write16(USB_EP_NI6_RXCSR, val)
-#define bfin_read_USB_EP_NI6_RXCOUNT()         bfin_read16(USB_EP_NI6_RXCOUNT)
-#define bfin_write_USB_EP_NI6_RXCOUNT(val)     bfin_write16(USB_EP_NI6_RXCOUNT, val)
-#define bfin_read_USB_EP_NI6_TXTYPE()          bfin_read16(USB_EP_NI6_TXTYPE)
-#define bfin_write_USB_EP_NI6_TXTYPE(val)      bfin_write16(USB_EP_NI6_TXTYPE, val)
-#define bfin_read_USB_EP_NI6_TXINTERVAL()      bfin_read16(USB_EP_NI6_TXINTERVAL)
-#define bfin_write_USB_EP_NI6_TXINTERVAL(val)  bfin_write16(USB_EP_NI6_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI6_RXTYPE()          bfin_read16(USB_EP_NI6_RXTYPE)
-#define bfin_write_USB_EP_NI6_RXTYPE(val)      bfin_write16(USB_EP_NI6_RXTYPE, val)
-#define bfin_read_USB_EP_NI6_RXINTERVAL()      bfin_read16(USB_EP_NI6_RXINTERVAL)
-#define bfin_write_USB_EP_NI6_RXINTERVAL(val)  bfin_write16(USB_EP_NI6_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 7 Control Registers */
-
-#define bfin_read_USB_EP_NI6_TXCOUNT()         bfin_read16(USB_EP_NI6_TXCOUNT)
-#define bfin_write_USB_EP_NI6_TXCOUNT(val)     bfin_write16(USB_EP_NI6_TXCOUNT, val)
-#define bfin_read_USB_EP_NI7_TXMAXP()          bfin_read16(USB_EP_NI7_TXMAXP)
-#define bfin_write_USB_EP_NI7_TXMAXP(val)      bfin_write16(USB_EP_NI7_TXMAXP, val)
-#define bfin_read_USB_EP_NI7_TXCSR()           bfin_read16(USB_EP_NI7_TXCSR)
-#define bfin_write_USB_EP_NI7_TXCSR(val)       bfin_write16(USB_EP_NI7_TXCSR, val)
-#define bfin_read_USB_EP_NI7_RXMAXP()          bfin_read16(USB_EP_NI7_RXMAXP)
-#define bfin_write_USB_EP_NI7_RXMAXP(val)      bfin_write16(USB_EP_NI7_RXMAXP, val)
-#define bfin_read_USB_EP_NI7_RXCSR()           bfin_read16(USB_EP_NI7_RXCSR)
-#define bfin_write_USB_EP_NI7_RXCSR(val)       bfin_write16(USB_EP_NI7_RXCSR, val)
-#define bfin_read_USB_EP_NI7_RXCOUNT()         bfin_read16(USB_EP_NI7_RXCOUNT)
-#define bfin_write_USB_EP_NI7_RXCOUNT(val)     bfin_write16(USB_EP_NI7_RXCOUNT, val)
-#define bfin_read_USB_EP_NI7_TXTYPE()          bfin_read16(USB_EP_NI7_TXTYPE)
-#define bfin_write_USB_EP_NI7_TXTYPE(val)      bfin_write16(USB_EP_NI7_TXTYPE, val)
-#define bfin_read_USB_EP_NI7_TXINTERVAL()      bfin_read16(USB_EP_NI7_TXINTERVAL)
-#define bfin_write_USB_EP_NI7_TXINTERVAL(val)  bfin_write16(USB_EP_NI7_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI7_RXTYPE()          bfin_read16(USB_EP_NI7_RXTYPE)
-#define bfin_write_USB_EP_NI7_RXTYPE(val)      bfin_write16(USB_EP_NI7_RXTYPE, val)
-#define bfin_read_USB_EP_NI7_RXINTERVAL()      bfin_read16(USB_EP_NI7_RXINTERVAL)
-#define bfin_write_USB_EP_NI7_RXINTERVAL(val)  bfin_write16(USB_EP_NI7_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI7_TXCOUNT()         bfin_read16(USB_EP_NI7_TXCOUNT)
-#define bfin_write_USB_EP_NI7_TXCOUNT(val)     bfin_write16(USB_EP_NI7_TXCOUNT, val)
-#define bfin_read_USB_DMA_INTERRUPT()          bfin_read16(USB_DMA_INTERRUPT)
-#define bfin_write_USB_DMA_INTERRUPT(val)      bfin_write16(USB_DMA_INTERRUPT, val)
-
-/* USB Channel 0 Config Registers */
-
-#define bfin_read_USB_DMA0CONTROL()            bfin_read16(USB_DMA0CONTROL)
-#define bfin_write_USB_DMA0CONTROL(val)                bfin_write16(USB_DMA0CONTROL, val)
-#define bfin_read_USB_DMA0ADDRLOW()            bfin_read16(USB_DMA0ADDRLOW)
-#define bfin_write_USB_DMA0ADDRLOW(val)                bfin_write16(USB_DMA0ADDRLOW, val)
-#define bfin_read_USB_DMA0ADDRHIGH()           bfin_read16(USB_DMA0ADDRHIGH)
-#define bfin_write_USB_DMA0ADDRHIGH(val)       bfin_write16(USB_DMA0ADDRHIGH, val)
-#define bfin_read_USB_DMA0COUNTLOW()           bfin_read16(USB_DMA0COUNTLOW)
-#define bfin_write_USB_DMA0COUNTLOW(val)       bfin_write16(USB_DMA0COUNTLOW, val)
-#define bfin_read_USB_DMA0COUNTHIGH()          bfin_read16(USB_DMA0COUNTHIGH)
-#define bfin_write_USB_DMA0COUNTHIGH(val)      bfin_write16(USB_DMA0COUNTHIGH, val)
-
-/* USB Channel 1 Config Registers */
-
-#define bfin_read_USB_DMA1CONTROL()            bfin_read16(USB_DMA1CONTROL)
-#define bfin_write_USB_DMA1CONTROL(val)                bfin_write16(USB_DMA1CONTROL, val)
-#define bfin_read_USB_DMA1ADDRLOW()            bfin_read16(USB_DMA1ADDRLOW)
-#define bfin_write_USB_DMA1ADDRLOW(val)                bfin_write16(USB_DMA1ADDRLOW, val)
-#define bfin_read_USB_DMA1ADDRHIGH()           bfin_read16(USB_DMA1ADDRHIGH)
-#define bfin_write_USB_DMA1ADDRHIGH(val)       bfin_write16(USB_DMA1ADDRHIGH, val)
-#define bfin_read_USB_DMA1COUNTLOW()           bfin_read16(USB_DMA1COUNTLOW)
-#define bfin_write_USB_DMA1COUNTLOW(val)       bfin_write16(USB_DMA1COUNTLOW, val)
-#define bfin_read_USB_DMA1COUNTHIGH()          bfin_read16(USB_DMA1COUNTHIGH)
-#define bfin_write_USB_DMA1COUNTHIGH(val)      bfin_write16(USB_DMA1COUNTHIGH, val)
-
-/* USB Channel 2 Config Registers */
-
-#define bfin_read_USB_DMA2CONTROL()            bfin_read16(USB_DMA2CONTROL)
-#define bfin_write_USB_DMA2CONTROL(val)                bfin_write16(USB_DMA2CONTROL, val)
-#define bfin_read_USB_DMA2ADDRLOW()            bfin_read16(USB_DMA2ADDRLOW)
-#define bfin_write_USB_DMA2ADDRLOW(val)                bfin_write16(USB_DMA2ADDRLOW, val)
-#define bfin_read_USB_DMA2ADDRHIGH()           bfin_read16(USB_DMA2ADDRHIGH)
-#define bfin_write_USB_DMA2ADDRHIGH(val)       bfin_write16(USB_DMA2ADDRHIGH, val)
-#define bfin_read_USB_DMA2COUNTLOW()           bfin_read16(USB_DMA2COUNTLOW)
-#define bfin_write_USB_DMA2COUNTLOW(val)       bfin_write16(USB_DMA2COUNTLOW, val)
-#define bfin_read_USB_DMA2COUNTHIGH()          bfin_read16(USB_DMA2COUNTHIGH)
-#define bfin_write_USB_DMA2COUNTHIGH(val)      bfin_write16(USB_DMA2COUNTHIGH, val)
-
-/* USB Channel 3 Config Registers */
-
-#define bfin_read_USB_DMA3CONTROL()            bfin_read16(USB_DMA3CONTROL)
-#define bfin_write_USB_DMA3CONTROL(val)                bfin_write16(USB_DMA3CONTROL, val)
-#define bfin_read_USB_DMA3ADDRLOW()            bfin_read16(USB_DMA3ADDRLOW)
-#define bfin_write_USB_DMA3ADDRLOW(val)                bfin_write16(USB_DMA3ADDRLOW, val)
-#define bfin_read_USB_DMA3ADDRHIGH()           bfin_read16(USB_DMA3ADDRHIGH)
-#define bfin_write_USB_DMA3ADDRHIGH(val)       bfin_write16(USB_DMA3ADDRHIGH, val)
-#define bfin_read_USB_DMA3COUNTLOW()           bfin_read16(USB_DMA3COUNTLOW)
-#define bfin_write_USB_DMA3COUNTLOW(val)       bfin_write16(USB_DMA3COUNTLOW, val)
-#define bfin_read_USB_DMA3COUNTHIGH()          bfin_read16(USB_DMA3COUNTHIGH)
-#define bfin_write_USB_DMA3COUNTHIGH(val)      bfin_write16(USB_DMA3COUNTHIGH, val)
-
-/* USB Channel 4 Config Registers */
-
-#define bfin_read_USB_DMA4CONTROL()            bfin_read16(USB_DMA4CONTROL)
-#define bfin_write_USB_DMA4CONTROL(val)                bfin_write16(USB_DMA4CONTROL, val)
-#define bfin_read_USB_DMA4ADDRLOW()            bfin_read16(USB_DMA4ADDRLOW)
-#define bfin_write_USB_DMA4ADDRLOW(val)                bfin_write16(USB_DMA4ADDRLOW, val)
-#define bfin_read_USB_DMA4ADDRHIGH()           bfin_read16(USB_DMA4ADDRHIGH)
-#define bfin_write_USB_DMA4ADDRHIGH(val)       bfin_write16(USB_DMA4ADDRHIGH, val)
-#define bfin_read_USB_DMA4COUNTLOW()           bfin_read16(USB_DMA4COUNTLOW)
-#define bfin_write_USB_DMA4COUNTLOW(val)       bfin_write16(USB_DMA4COUNTLOW, val)
-#define bfin_read_USB_DMA4COUNTHIGH()          bfin_read16(USB_DMA4COUNTHIGH)
-#define bfin_write_USB_DMA4COUNTHIGH(val)      bfin_write16(USB_DMA4COUNTHIGH, val)
-
-/* USB Channel 5 Config Registers */
-
-#define bfin_read_USB_DMA5CONTROL()            bfin_read16(USB_DMA5CONTROL)
-#define bfin_write_USB_DMA5CONTROL(val)                bfin_write16(USB_DMA5CONTROL, val)
-#define bfin_read_USB_DMA5ADDRLOW()            bfin_read16(USB_DMA5ADDRLOW)
-#define bfin_write_USB_DMA5ADDRLOW(val)                bfin_write16(USB_DMA5ADDRLOW, val)
-#define bfin_read_USB_DMA5ADDRHIGH()           bfin_read16(USB_DMA5ADDRHIGH)
-#define bfin_write_USB_DMA5ADDRHIGH(val)       bfin_write16(USB_DMA5ADDRHIGH, val)
-#define bfin_read_USB_DMA5COUNTLOW()           bfin_read16(USB_DMA5COUNTLOW)
-#define bfin_write_USB_DMA5COUNTLOW(val)       bfin_write16(USB_DMA5COUNTLOW, val)
-#define bfin_read_USB_DMA5COUNTHIGH()          bfin_read16(USB_DMA5COUNTHIGH)
-#define bfin_write_USB_DMA5COUNTHIGH(val)      bfin_write16(USB_DMA5COUNTHIGH, val)
-
-/* USB Channel 6 Config Registers */
-
-#define bfin_read_USB_DMA6CONTROL()            bfin_read16(USB_DMA6CONTROL)
-#define bfin_write_USB_DMA6CONTROL(val)                bfin_write16(USB_DMA6CONTROL, val)
-#define bfin_read_USB_DMA6ADDRLOW()            bfin_read16(USB_DMA6ADDRLOW)
-#define bfin_write_USB_DMA6ADDRLOW(val)                bfin_write16(USB_DMA6ADDRLOW, val)
-#define bfin_read_USB_DMA6ADDRHIGH()           bfin_read16(USB_DMA6ADDRHIGH)
-#define bfin_write_USB_DMA6ADDRHIGH(val)       bfin_write16(USB_DMA6ADDRHIGH, val)
-#define bfin_read_USB_DMA6COUNTLOW()           bfin_read16(USB_DMA6COUNTLOW)
-#define bfin_write_USB_DMA6COUNTLOW(val)       bfin_write16(USB_DMA6COUNTLOW, val)
-#define bfin_read_USB_DMA6COUNTHIGH()          bfin_read16(USB_DMA6COUNTHIGH)
-#define bfin_write_USB_DMA6COUNTHIGH(val)      bfin_write16(USB_DMA6COUNTHIGH, val)
-
-/* USB Channel 7 Config Registers */
-
-#define bfin_read_USB_DMA7CONTROL()            bfin_read16(USB_DMA7CONTROL)
-#define bfin_write_USB_DMA7CONTROL(val)                bfin_write16(USB_DMA7CONTROL, val)
-#define bfin_read_USB_DMA7ADDRLOW()            bfin_read16(USB_DMA7ADDRLOW)
-#define bfin_write_USB_DMA7ADDRLOW(val)                bfin_write16(USB_DMA7ADDRLOW, val)
-#define bfin_read_USB_DMA7ADDRHIGH()           bfin_read16(USB_DMA7ADDRHIGH)
-#define bfin_write_USB_DMA7ADDRHIGH(val)       bfin_write16(USB_DMA7ADDRHIGH, val)
-#define bfin_read_USB_DMA7COUNTLOW()           bfin_read16(USB_DMA7COUNTLOW)
-#define bfin_write_USB_DMA7COUNTLOW(val)       bfin_write16(USB_DMA7COUNTLOW, val)
-#define bfin_read_USB_DMA7COUNTHIGH()          bfin_read16(USB_DMA7COUNTHIGH)
-#define bfin_write_USB_DMA7COUNTHIGH(val)      bfin_write16(USB_DMA7COUNTHIGH, val)
-
-/* Keybfin_read_()ad Registers */
-
-#define bfin_read_KPAD_CTL()           bfin_read16(KPAD_CTL)
-#define bfin_write_KPAD_CTL(val)       bfin_write16(KPAD_CTL, val)
-#define bfin_read_KPAD_PRESCALE()      bfin_read16(KPAD_PRESCALE)
-#define bfin_write_KPAD_PRESCALE(val)  bfin_write16(KPAD_PRESCALE, val)
-#define bfin_read_KPAD_MSEL()          bfin_read16(KPAD_MSEL)
-#define bfin_write_KPAD_MSEL(val)      bfin_write16(KPAD_MSEL, val)
-#define bfin_read_KPAD_ROWCOL()                bfin_read16(KPAD_ROWCOL)
-#define bfin_write_KPAD_ROWCOL(val)    bfin_write16(KPAD_ROWCOL, val)
-#define bfin_read_KPAD_STAT()          bfin_read16(KPAD_STAT)
-#define bfin_write_KPAD_STAT(val)      bfin_write16(KPAD_STAT, val)
-#define bfin_read_KPAD_SOFTEVAL()      bfin_read16(KPAD_SOFTEVAL)
-#define bfin_write_KPAD_SOFTEVAL(val)  bfin_write16(KPAD_SOFTEVAL, val)
-
-/* Pixel Combfin_read_()ositor (PIXC) Registers */
-
-#define bfin_read_PIXC_CTL()           bfin_read16(PIXC_CTL)
-#define bfin_write_PIXC_CTL(val)       bfin_write16(PIXC_CTL, val)
-#define bfin_read_PIXC_PPL()           bfin_read16(PIXC_PPL)
-#define bfin_write_PIXC_PPL(val)       bfin_write16(PIXC_PPL, val)
-#define bfin_read_PIXC_LPF()           bfin_read16(PIXC_LPF)
-#define bfin_write_PIXC_LPF(val)       bfin_write16(PIXC_LPF, val)
-#define bfin_read_PIXC_AHSTART()       bfin_read16(PIXC_AHSTART)
-#define bfin_write_PIXC_AHSTART(val)   bfin_write16(PIXC_AHSTART, val)
-#define bfin_read_PIXC_AHEND()         bfin_read16(PIXC_AHEND)
-#define bfin_write_PIXC_AHEND(val)     bfin_write16(PIXC_AHEND, val)
-#define bfin_read_PIXC_AVSTART()       bfin_read16(PIXC_AVSTART)
-#define bfin_write_PIXC_AVSTART(val)   bfin_write16(PIXC_AVSTART, val)
-#define bfin_read_PIXC_AVEND()         bfin_read16(PIXC_AVEND)
-#define bfin_write_PIXC_AVEND(val)     bfin_write16(PIXC_AVEND, val)
-#define bfin_read_PIXC_ATRANSP()       bfin_read16(PIXC_ATRANSP)
-#define bfin_write_PIXC_ATRANSP(val)   bfin_write16(PIXC_ATRANSP, val)
-#define bfin_read_PIXC_BHSTART()       bfin_read16(PIXC_BHSTART)
-#define bfin_write_PIXC_BHSTART(val)   bfin_write16(PIXC_BHSTART, val)
-#define bfin_read_PIXC_BHEND()         bfin_read16(PIXC_BHEND)
-#define bfin_write_PIXC_BHEND(val)     bfin_write16(PIXC_BHEND, val)
-#define bfin_read_PIXC_BVSTART()       bfin_read16(PIXC_BVSTART)
-#define bfin_write_PIXC_BVSTART(val)   bfin_write16(PIXC_BVSTART, val)
-#define bfin_read_PIXC_BVEND()         bfin_read16(PIXC_BVEND)
-#define bfin_write_PIXC_BVEND(val)     bfin_write16(PIXC_BVEND, val)
-#define bfin_read_PIXC_BTRANSP()       bfin_read16(PIXC_BTRANSP)
-#define bfin_write_PIXC_BTRANSP(val)   bfin_write16(PIXC_BTRANSP, val)
-#define bfin_read_PIXC_INTRSTAT()      bfin_read16(PIXC_INTRSTAT)
-#define bfin_write_PIXC_INTRSTAT(val)  bfin_write16(PIXC_INTRSTAT, val)
-#define bfin_read_PIXC_RYCON()         bfin_read32(PIXC_RYCON)
-#define bfin_write_PIXC_RYCON(val)     bfin_write32(PIXC_RYCON, val)
-#define bfin_read_PIXC_GUCON()         bfin_read32(PIXC_GUCON)
-#define bfin_write_PIXC_GUCON(val)     bfin_write32(PIXC_GUCON, val)
-#define bfin_read_PIXC_BVCON()         bfin_read32(PIXC_BVCON)
-#define bfin_write_PIXC_BVCON(val)     bfin_write32(PIXC_BVCON, val)
-#define bfin_read_PIXC_CCBIAS()                bfin_read32(PIXC_CCBIAS)
-#define bfin_write_PIXC_CCBIAS(val)    bfin_write32(PIXC_CCBIAS, val)
-#define bfin_read_PIXC_TC()            bfin_read32(PIXC_TC)
-#define bfin_write_PIXC_TC(val)                bfin_write32(PIXC_TC, val)
-
-/* Handshake MDMA 0 Registers */
-
-#define bfin_read_HMDMA0_CONTROL()             bfin_read16(HMDMA0_CONTROL)
-#define bfin_write_HMDMA0_CONTROL(val)         bfin_write16(HMDMA0_CONTROL, val)
-#define bfin_read_HMDMA0_ECINIT()              bfin_read16(HMDMA0_ECINIT)
-#define bfin_write_HMDMA0_ECINIT(val)          bfin_write16(HMDMA0_ECINIT, val)
-#define bfin_read_HMDMA0_BCINIT()              bfin_read16(HMDMA0_BCINIT)
-#define bfin_write_HMDMA0_BCINIT(val)          bfin_write16(HMDMA0_BCINIT, val)
-#define bfin_read_HMDMA0_ECURGENT()            bfin_read16(HMDMA0_ECURGENT)
-#define bfin_write_HMDMA0_ECURGENT(val)                bfin_write16(HMDMA0_ECURGENT, val)
-#define bfin_read_HMDMA0_ECOVERFLOW()          bfin_read16(HMDMA0_ECOVERFLOW)
-#define bfin_write_HMDMA0_ECOVERFLOW(val)      bfin_write16(HMDMA0_ECOVERFLOW, val)
-#define bfin_read_HMDMA0_ECOUNT()              bfin_read16(HMDMA0_ECOUNT)
-#define bfin_write_HMDMA0_ECOUNT(val)          bfin_write16(HMDMA0_ECOUNT, val)
-#define bfin_read_HMDMA0_BCOUNT()              bfin_read16(HMDMA0_BCOUNT)
-#define bfin_write_HMDMA0_BCOUNT(val)          bfin_write16(HMDMA0_BCOUNT, val)
-
-/* Handshake MDMA 1 Registers */
-
-#define bfin_read_HMDMA1_CONTROL()             bfin_read16(HMDMA1_CONTROL)
-#define bfin_write_HMDMA1_CONTROL(val)         bfin_write16(HMDMA1_CONTROL, val)
-#define bfin_read_HMDMA1_ECINIT()              bfin_read16(HMDMA1_ECINIT)
-#define bfin_write_HMDMA1_ECINIT(val)          bfin_write16(HMDMA1_ECINIT, val)
-#define bfin_read_HMDMA1_BCINIT()              bfin_read16(HMDMA1_BCINIT)
-#define bfin_write_HMDMA1_BCINIT(val)          bfin_write16(HMDMA1_BCINIT, val)
-#define bfin_read_HMDMA1_ECURGENT()            bfin_read16(HMDMA1_ECURGENT)
-#define bfin_write_HMDMA1_ECURGENT(val)                bfin_write16(HMDMA1_ECURGENT, val)
-#define bfin_read_HMDMA1_ECOVERFLOW()          bfin_read16(HMDMA1_ECOVERFLOW)
-#define bfin_write_HMDMA1_ECOVERFLOW(val)      bfin_write16(HMDMA1_ECOVERFLOW, val)
-#define bfin_read_HMDMA1_ECOUNT()              bfin_read16(HMDMA1_ECOUNT)
-#define bfin_write_HMDMA1_ECOUNT(val)          bfin_write16(HMDMA1_ECOUNT, val)
-#define bfin_read_HMDMA1_BCOUNT()              bfin_read16(HMDMA1_BCOUNT)
-#define bfin_write_HMDMA1_BCOUNT(val)          bfin_write16(HMDMA1_BCOUNT, val)
-
 #endif /* _CDEF_BF548_H */
index 34c84c7fb256a7d28bc7b03ef4cb861710dab979..80201ed41f80bfe48b70c78df55ecab87fb60445 100644 (file)
 /* include cdefBF54x_base.h for the set of #defines that are common to all ADSP-BF54x bfin_read_()rocessors */
 #include "cdefBF54x_base.h"
 
-/* The following are the #defines needed by ADSP-BF549 that are not in the common header */
-
-/* Timer Registers */
-
-#define bfin_read_TIMER8_CONFIG()              bfin_read16(TIMER8_CONFIG)
-#define bfin_write_TIMER8_CONFIG(val)          bfin_write16(TIMER8_CONFIG, val)
-#define bfin_read_TIMER8_COUNTER()             bfin_read32(TIMER8_COUNTER)
-#define bfin_write_TIMER8_COUNTER(val)         bfin_write32(TIMER8_COUNTER, val)
-#define bfin_read_TIMER8_PERIOD()              bfin_read32(TIMER8_PERIOD)
-#define bfin_write_TIMER8_PERIOD(val)          bfin_write32(TIMER8_PERIOD, val)
-#define bfin_read_TIMER8_WIDTH()               bfin_read32(TIMER8_WIDTH)
-#define bfin_write_TIMER8_WIDTH(val)           bfin_write32(TIMER8_WIDTH, val)
-#define bfin_read_TIMER9_CONFIG()              bfin_read16(TIMER9_CONFIG)
-#define bfin_write_TIMER9_CONFIG(val)          bfin_write16(TIMER9_CONFIG, val)
-#define bfin_read_TIMER9_COUNTER()             bfin_read32(TIMER9_COUNTER)
-#define bfin_write_TIMER9_COUNTER(val)         bfin_write32(TIMER9_COUNTER, val)
-#define bfin_read_TIMER9_PERIOD()              bfin_read32(TIMER9_PERIOD)
-#define bfin_write_TIMER9_PERIOD(val)          bfin_write32(TIMER9_PERIOD, val)
-#define bfin_read_TIMER9_WIDTH()               bfin_read32(TIMER9_WIDTH)
-#define bfin_write_TIMER9_WIDTH(val)           bfin_write32(TIMER9_WIDTH, val)
-#define bfin_read_TIMER10_CONFIG()             bfin_read16(TIMER10_CONFIG)
-#define bfin_write_TIMER10_CONFIG(val)         bfin_write16(TIMER10_CONFIG, val)
-#define bfin_read_TIMER10_COUNTER()            bfin_read32(TIMER10_COUNTER)
-#define bfin_write_TIMER10_COUNTER(val)                bfin_write32(TIMER10_COUNTER, val)
-#define bfin_read_TIMER10_PERIOD()             bfin_read32(TIMER10_PERIOD)
-#define bfin_write_TIMER10_PERIOD(val)         bfin_write32(TIMER10_PERIOD, val)
-#define bfin_read_TIMER10_WIDTH()              bfin_read32(TIMER10_WIDTH)
-#define bfin_write_TIMER10_WIDTH(val)          bfin_write32(TIMER10_WIDTH, val)
-
-/* Timer Groubfin_read_() of 3 */
-
-#define bfin_read_TIMER_ENABLE1()              bfin_read16(TIMER_ENABLE1)
-#define bfin_write_TIMER_ENABLE1(val)          bfin_write16(TIMER_ENABLE1, val)
-#define bfin_read_TIMER_DISABLE1()             bfin_read16(TIMER_DISABLE1)
-#define bfin_write_TIMER_DISABLE1(val)         bfin_write16(TIMER_DISABLE1, val)
-#define bfin_read_TIMER_STATUS1()              bfin_read32(TIMER_STATUS1)
-#define bfin_write_TIMER_STATUS1(val)          bfin_write32(TIMER_STATUS1, val)
-
-/* SPORT0 Registers */
-
-#define bfin_read_SPORT0_TCR1()                        bfin_read16(SPORT0_TCR1)
-#define bfin_write_SPORT0_TCR1(val)            bfin_write16(SPORT0_TCR1, val)
-#define bfin_read_SPORT0_TCR2()                        bfin_read16(SPORT0_TCR2)
-#define bfin_write_SPORT0_TCR2(val)            bfin_write16(SPORT0_TCR2, val)
-#define bfin_read_SPORT0_TCLKDIV()             bfin_read16(SPORT0_TCLKDIV)
-#define bfin_write_SPORT0_TCLKDIV(val)         bfin_write16(SPORT0_TCLKDIV, val)
-#define bfin_read_SPORT0_TFSDIV()              bfin_read16(SPORT0_TFSDIV)
-#define bfin_write_SPORT0_TFSDIV(val)          bfin_write16(SPORT0_TFSDIV, val)
-#define bfin_read_SPORT0_TX()                  bfin_read32(SPORT0_TX)
-#define bfin_write_SPORT0_TX(val)              bfin_write32(SPORT0_TX, val)
-#define bfin_read_SPORT0_RX()                  bfin_read32(SPORT0_RX)
-#define bfin_write_SPORT0_RX(val)              bfin_write32(SPORT0_RX, val)
-#define bfin_read_SPORT0_RCR1()                        bfin_read16(SPORT0_RCR1)
-#define bfin_write_SPORT0_RCR1(val)            bfin_write16(SPORT0_RCR1, val)
-#define bfin_read_SPORT0_RCR2()                        bfin_read16(SPORT0_RCR2)
-#define bfin_write_SPORT0_RCR2(val)            bfin_write16(SPORT0_RCR2, val)
-#define bfin_read_SPORT0_RCLKDIV()             bfin_read16(SPORT0_RCLKDIV)
-#define bfin_write_SPORT0_RCLKDIV(val)         bfin_write16(SPORT0_RCLKDIV, val)
-#define bfin_read_SPORT0_RFSDIV()              bfin_read16(SPORT0_RFSDIV)
-#define bfin_write_SPORT0_RFSDIV(val)          bfin_write16(SPORT0_RFSDIV, val)
-#define bfin_read_SPORT0_STAT()                        bfin_read16(SPORT0_STAT)
-#define bfin_write_SPORT0_STAT(val)            bfin_write16(SPORT0_STAT, val)
-#define bfin_read_SPORT0_CHNL()                        bfin_read16(SPORT0_CHNL)
-#define bfin_write_SPORT0_CHNL(val)            bfin_write16(SPORT0_CHNL, val)
-#define bfin_read_SPORT0_MCMC1()               bfin_read16(SPORT0_MCMC1)
-#define bfin_write_SPORT0_MCMC1(val)           bfin_write16(SPORT0_MCMC1, val)
-#define bfin_read_SPORT0_MCMC2()               bfin_read16(SPORT0_MCMC2)
-#define bfin_write_SPORT0_MCMC2(val)           bfin_write16(SPORT0_MCMC2, val)
-#define bfin_read_SPORT0_MTCS0()               bfin_read32(SPORT0_MTCS0)
-#define bfin_write_SPORT0_MTCS0(val)           bfin_write32(SPORT0_MTCS0, val)
-#define bfin_read_SPORT0_MTCS1()               bfin_read32(SPORT0_MTCS1)
-#define bfin_write_SPORT0_MTCS1(val)           bfin_write32(SPORT0_MTCS1, val)
-#define bfin_read_SPORT0_MTCS2()               bfin_read32(SPORT0_MTCS2)
-#define bfin_write_SPORT0_MTCS2(val)           bfin_write32(SPORT0_MTCS2, val)
-#define bfin_read_SPORT0_MTCS3()               bfin_read32(SPORT0_MTCS3)
-#define bfin_write_SPORT0_MTCS3(val)           bfin_write32(SPORT0_MTCS3, val)
-#define bfin_read_SPORT0_MRCS0()               bfin_read32(SPORT0_MRCS0)
-#define bfin_write_SPORT0_MRCS0(val)           bfin_write32(SPORT0_MRCS0, val)
-#define bfin_read_SPORT0_MRCS1()               bfin_read32(SPORT0_MRCS1)
-#define bfin_write_SPORT0_MRCS1(val)           bfin_write32(SPORT0_MRCS1, val)
-#define bfin_read_SPORT0_MRCS2()               bfin_read32(SPORT0_MRCS2)
-#define bfin_write_SPORT0_MRCS2(val)           bfin_write32(SPORT0_MRCS2, val)
-#define bfin_read_SPORT0_MRCS3()               bfin_read32(SPORT0_MRCS3)
-#define bfin_write_SPORT0_MRCS3(val)           bfin_write32(SPORT0_MRCS3, val)
-
-/* EPPI0 Registers */
-
-#define bfin_read_EPPI0_STATUS()               bfin_read16(EPPI0_STATUS)
-#define bfin_write_EPPI0_STATUS(val)           bfin_write16(EPPI0_STATUS, val)
-#define bfin_read_EPPI0_HCOUNT()               bfin_read16(EPPI0_HCOUNT)
-#define bfin_write_EPPI0_HCOUNT(val)           bfin_write16(EPPI0_HCOUNT, val)
-#define bfin_read_EPPI0_HDELAY()               bfin_read16(EPPI0_HDELAY)
-#define bfin_write_EPPI0_HDELAY(val)           bfin_write16(EPPI0_HDELAY, val)
-#define bfin_read_EPPI0_VCOUNT()               bfin_read16(EPPI0_VCOUNT)
-#define bfin_write_EPPI0_VCOUNT(val)           bfin_write16(EPPI0_VCOUNT, val)
-#define bfin_read_EPPI0_VDELAY()               bfin_read16(EPPI0_VDELAY)
-#define bfin_write_EPPI0_VDELAY(val)           bfin_write16(EPPI0_VDELAY, val)
-#define bfin_read_EPPI0_FRAME()                        bfin_read16(EPPI0_FRAME)
-#define bfin_write_EPPI0_FRAME(val)            bfin_write16(EPPI0_FRAME, val)
-#define bfin_read_EPPI0_LINE()                 bfin_read16(EPPI0_LINE)
-#define bfin_write_EPPI0_LINE(val)             bfin_write16(EPPI0_LINE, val)
-#define bfin_read_EPPI0_CLKDIV()               bfin_read16(EPPI0_CLKDIV)
-#define bfin_write_EPPI0_CLKDIV(val)           bfin_write16(EPPI0_CLKDIV, val)
-#define bfin_read_EPPI0_CONTROL()              bfin_read32(EPPI0_CONTROL)
-#define bfin_write_EPPI0_CONTROL(val)          bfin_write32(EPPI0_CONTROL, val)
-#define bfin_read_EPPI0_FS1W_HBL()             bfin_read32(EPPI0_FS1W_HBL)
-#define bfin_write_EPPI0_FS1W_HBL(val)         bfin_write32(EPPI0_FS1W_HBL, val)
-#define bfin_read_EPPI0_FS1P_AVPL()            bfin_read32(EPPI0_FS1P_AVPL)
-#define bfin_write_EPPI0_FS1P_AVPL(val)                bfin_write32(EPPI0_FS1P_AVPL, val)
-#define bfin_read_EPPI0_FS2W_LVB()             bfin_read32(EPPI0_FS2W_LVB)
-#define bfin_write_EPPI0_FS2W_LVB(val)         bfin_write32(EPPI0_FS2W_LVB, val)
-#define bfin_read_EPPI0_FS2P_LAVF()            bfin_read32(EPPI0_FS2P_LAVF)
-#define bfin_write_EPPI0_FS2P_LAVF(val)                bfin_write32(EPPI0_FS2P_LAVF, val)
-#define bfin_read_EPPI0_CLIP()                 bfin_read32(EPPI0_CLIP)
-#define bfin_write_EPPI0_CLIP(val)             bfin_write32(EPPI0_CLIP, val)
-
-/* UART2 Registers */
-
-#define bfin_read_UART2_DLL()                  bfin_read16(UART2_DLL)
-#define bfin_write_UART2_DLL(val)              bfin_write16(UART2_DLL, val)
-#define bfin_read_UART2_DLH()                  bfin_read16(UART2_DLH)
-#define bfin_write_UART2_DLH(val)              bfin_write16(UART2_DLH, val)
-#define bfin_read_UART2_GCTL()                 bfin_read16(UART2_GCTL)
-#define bfin_write_UART2_GCTL(val)             bfin_write16(UART2_GCTL, val)
-#define bfin_read_UART2_LCR()                  bfin_read16(UART2_LCR)
-#define bfin_write_UART2_LCR(val)              bfin_write16(UART2_LCR, val)
-#define bfin_read_UART2_MCR()                  bfin_read16(UART2_MCR)
-#define bfin_write_UART2_MCR(val)              bfin_write16(UART2_MCR, val)
-#define bfin_read_UART2_LSR()                  bfin_read16(UART2_LSR)
-#define bfin_write_UART2_LSR(val)              bfin_write16(UART2_LSR, val)
-#define bfin_read_UART2_MSR()                  bfin_read16(UART2_MSR)
-#define bfin_write_UART2_MSR(val)              bfin_write16(UART2_MSR, val)
-#define bfin_read_UART2_SCR()                  bfin_read16(UART2_SCR)
-#define bfin_write_UART2_SCR(val)              bfin_write16(UART2_SCR, val)
-#define bfin_read_UART2_IER_SET()              bfin_read16(UART2_IER_SET)
-#define bfin_write_UART2_IER_SET(val)          bfin_write16(UART2_IER_SET, val)
-#define bfin_read_UART2_IER_CLEAR()            bfin_read16(UART2_IER_CLEAR)
-#define bfin_write_UART2_IER_CLEAR(val)                bfin_write16(UART2_IER_CLEAR, val)
-#define bfin_read_UART2_RBR()                  bfin_read16(UART2_RBR)
-#define bfin_write_UART2_RBR(val)              bfin_write16(UART2_RBR, val)
-
-/* Two Wire Interface Registers (TWI1) */
-
-/* SPI2 Registers */
-
-#define bfin_read_SPI2_CTL()           bfin_read16(SPI2_CTL)
-#define bfin_write_SPI2_CTL(val)       bfin_write16(SPI2_CTL, val)
-#define bfin_read_SPI2_FLG()           bfin_read16(SPI2_FLG)
-#define bfin_write_SPI2_FLG(val)       bfin_write16(SPI2_FLG, val)
-#define bfin_read_SPI2_STAT()          bfin_read16(SPI2_STAT)
-#define bfin_write_SPI2_STAT(val)      bfin_write16(SPI2_STAT, val)
-#define bfin_read_SPI2_TDBR()          bfin_read16(SPI2_TDBR)
-#define bfin_write_SPI2_TDBR(val)      bfin_write16(SPI2_TDBR, val)
-#define bfin_read_SPI2_RDBR()          bfin_read16(SPI2_RDBR)
-#define bfin_write_SPI2_RDBR(val)      bfin_write16(SPI2_RDBR, val)
-#define bfin_read_SPI2_BAUD()          bfin_read16(SPI2_BAUD)
-#define bfin_write_SPI2_BAUD(val)      bfin_write16(SPI2_BAUD, val)
-#define bfin_read_SPI2_SHADOW()                bfin_read16(SPI2_SHADOW)
-#define bfin_write_SPI2_SHADOW(val)    bfin_write16(SPI2_SHADOW, val)
+/* The BF549 is like the BF544, but has MXVR */
+#include "cdefBF547.h"
 
 /* MXVR Registers */
 
 #define bfin_read_MXVR_SCLK_CNT()              bfin_read16(MXVR_SCLK_CNT)
 #define bfin_write_MXVR_SCLK_CNT(val)          bfin_write16(MXVR_SCLK_CNT, val)
 
-/* CAN Controller 1 Config 1 Registers */
-
-#define bfin_read_CAN1_MC1()           bfin_read16(CAN1_MC1)
-#define bfin_write_CAN1_MC1(val)       bfin_write16(CAN1_MC1, val)
-#define bfin_read_CAN1_MD1()           bfin_read16(CAN1_MD1)
-#define bfin_write_CAN1_MD1(val)       bfin_write16(CAN1_MD1, val)
-#define bfin_read_CAN1_TRS1()          bfin_read16(CAN1_TRS1)
-#define bfin_write_CAN1_TRS1(val)      bfin_write16(CAN1_TRS1, val)
-#define bfin_read_CAN1_TRR1()          bfin_read16(CAN1_TRR1)
-#define bfin_write_CAN1_TRR1(val)      bfin_write16(CAN1_TRR1, val)
-#define bfin_read_CAN1_TA1()           bfin_read16(CAN1_TA1)
-#define bfin_write_CAN1_TA1(val)       bfin_write16(CAN1_TA1, val)
-#define bfin_read_CAN1_AA1()           bfin_read16(CAN1_AA1)
-#define bfin_write_CAN1_AA1(val)       bfin_write16(CAN1_AA1, val)
-#define bfin_read_CAN1_RMP1()          bfin_read16(CAN1_RMP1)
-#define bfin_write_CAN1_RMP1(val)      bfin_write16(CAN1_RMP1, val)
-#define bfin_read_CAN1_RML1()          bfin_read16(CAN1_RML1)
-#define bfin_write_CAN1_RML1(val)      bfin_write16(CAN1_RML1, val)
-#define bfin_read_CAN1_MBTIF1()                bfin_read16(CAN1_MBTIF1)
-#define bfin_write_CAN1_MBTIF1(val)    bfin_write16(CAN1_MBTIF1, val)
-#define bfin_read_CAN1_MBRIF1()                bfin_read16(CAN1_MBRIF1)
-#define bfin_write_CAN1_MBRIF1(val)    bfin_write16(CAN1_MBRIF1, val)
-#define bfin_read_CAN1_MBIM1()         bfin_read16(CAN1_MBIM1)
-#define bfin_write_CAN1_MBIM1(val)     bfin_write16(CAN1_MBIM1, val)
-#define bfin_read_CAN1_RFH1()          bfin_read16(CAN1_RFH1)
-#define bfin_write_CAN1_RFH1(val)      bfin_write16(CAN1_RFH1, val)
-#define bfin_read_CAN1_OPSS1()         bfin_read16(CAN1_OPSS1)
-#define bfin_write_CAN1_OPSS1(val)     bfin_write16(CAN1_OPSS1, val)
-
-/* CAN Controller 1 Config 2 Registers */
-
-#define bfin_read_CAN1_MC2()           bfin_read16(CAN1_MC2)
-#define bfin_write_CAN1_MC2(val)       bfin_write16(CAN1_MC2, val)
-#define bfin_read_CAN1_MD2()           bfin_read16(CAN1_MD2)
-#define bfin_write_CAN1_MD2(val)       bfin_write16(CAN1_MD2, val)
-#define bfin_read_CAN1_TRS2()          bfin_read16(CAN1_TRS2)
-#define bfin_write_CAN1_TRS2(val)      bfin_write16(CAN1_TRS2, val)
-#define bfin_read_CAN1_TRR2()          bfin_read16(CAN1_TRR2)
-#define bfin_write_CAN1_TRR2(val)      bfin_write16(CAN1_TRR2, val)
-#define bfin_read_CAN1_TA2()           bfin_read16(CAN1_TA2)
-#define bfin_write_CAN1_TA2(val)       bfin_write16(CAN1_TA2, val)
-#define bfin_read_CAN1_AA2()           bfin_read16(CAN1_AA2)
-#define bfin_write_CAN1_AA2(val)       bfin_write16(CAN1_AA2, val)
-#define bfin_read_CAN1_RMP2()          bfin_read16(CAN1_RMP2)
-#define bfin_write_CAN1_RMP2(val)      bfin_write16(CAN1_RMP2, val)
-#define bfin_read_CAN1_RML2()          bfin_read16(CAN1_RML2)
-#define bfin_write_CAN1_RML2(val)      bfin_write16(CAN1_RML2, val)
-#define bfin_read_CAN1_MBTIF2()                bfin_read16(CAN1_MBTIF2)
-#define bfin_write_CAN1_MBTIF2(val)    bfin_write16(CAN1_MBTIF2, val)
-#define bfin_read_CAN1_MBRIF2()                bfin_read16(CAN1_MBRIF2)
-#define bfin_write_CAN1_MBRIF2(val)    bfin_write16(CAN1_MBRIF2, val)
-#define bfin_read_CAN1_MBIM2()         bfin_read16(CAN1_MBIM2)
-#define bfin_write_CAN1_MBIM2(val)     bfin_write16(CAN1_MBIM2, val)
-#define bfin_read_CAN1_RFH2()          bfin_read16(CAN1_RFH2)
-#define bfin_write_CAN1_RFH2(val)      bfin_write16(CAN1_RFH2, val)
-#define bfin_read_CAN1_OPSS2()         bfin_read16(CAN1_OPSS2)
-#define bfin_write_CAN1_OPSS2(val)     bfin_write16(CAN1_OPSS2, val)
-
-/* CAN Controller 1 Clock/Interrubfin_read_()t/Counter Registers */
-
-#define bfin_read_CAN1_CLOCK()         bfin_read16(CAN1_CLOCK)
-#define bfin_write_CAN1_CLOCK(val)     bfin_write16(CAN1_CLOCK, val)
-#define bfin_read_CAN1_TIMING()                bfin_read16(CAN1_TIMING)
-#define bfin_write_CAN1_TIMING(val)    bfin_write16(CAN1_TIMING, val)
-#define bfin_read_CAN1_DEBUG()         bfin_read16(CAN1_DEBUG)
-#define bfin_write_CAN1_DEBUG(val)     bfin_write16(CAN1_DEBUG, val)
-#define bfin_read_CAN1_STATUS()                bfin_read16(CAN1_STATUS)
-#define bfin_write_CAN1_STATUS(val)    bfin_write16(CAN1_STATUS, val)
-#define bfin_read_CAN1_CEC()           bfin_read16(CAN1_CEC)
-#define bfin_write_CAN1_CEC(val)       bfin_write16(CAN1_CEC, val)
-#define bfin_read_CAN1_GIS()           bfin_read16(CAN1_GIS)
-#define bfin_write_CAN1_GIS(val)       bfin_write16(CAN1_GIS, val)
-#define bfin_read_CAN1_GIM()           bfin_read16(CAN1_GIM)
-#define bfin_write_CAN1_GIM(val)       bfin_write16(CAN1_GIM, val)
-#define bfin_read_CAN1_GIF()           bfin_read16(CAN1_GIF)
-#define bfin_write_CAN1_GIF(val)       bfin_write16(CAN1_GIF, val)
-#define bfin_read_CAN1_CONTROL()       bfin_read16(CAN1_CONTROL)
-#define bfin_write_CAN1_CONTROL(val)   bfin_write16(CAN1_CONTROL, val)
-#define bfin_read_CAN1_INTR()          bfin_read16(CAN1_INTR)
-#define bfin_write_CAN1_INTR(val)      bfin_write16(CAN1_INTR, val)
-#define bfin_read_CAN1_MBTD()          bfin_read16(CAN1_MBTD)
-#define bfin_write_CAN1_MBTD(val)      bfin_write16(CAN1_MBTD, val)
-#define bfin_read_CAN1_EWR()           bfin_read16(CAN1_EWR)
-#define bfin_write_CAN1_EWR(val)       bfin_write16(CAN1_EWR, val)
-#define bfin_read_CAN1_ESR()           bfin_read16(CAN1_ESR)
-#define bfin_write_CAN1_ESR(val)       bfin_write16(CAN1_ESR, val)
-#define bfin_read_CAN1_UCCNT()         bfin_read16(CAN1_UCCNT)
-#define bfin_write_CAN1_UCCNT(val)     bfin_write16(CAN1_UCCNT, val)
-#define bfin_read_CAN1_UCRC()          bfin_read16(CAN1_UCRC)
-#define bfin_write_CAN1_UCRC(val)      bfin_write16(CAN1_UCRC, val)
-#define bfin_read_CAN1_UCCNF()         bfin_read16(CAN1_UCCNF)
-#define bfin_write_CAN1_UCCNF(val)     bfin_write16(CAN1_UCCNF, val)
-
-/* CAN Controller 1 Mailbox Accebfin_read_()tance Registers */
-
-#define bfin_read_CAN1_AM00L()         bfin_read16(CAN1_AM00L)
-#define bfin_write_CAN1_AM00L(val)     bfin_write16(CAN1_AM00L, val)
-#define bfin_read_CAN1_AM00H()         bfin_read16(CAN1_AM00H)
-#define bfin_write_CAN1_AM00H(val)     bfin_write16(CAN1_AM00H, val)
-#define bfin_read_CAN1_AM01L()         bfin_read16(CAN1_AM01L)
-#define bfin_write_CAN1_AM01L(val)     bfin_write16(CAN1_AM01L, val)
-#define bfin_read_CAN1_AM01H()         bfin_read16(CAN1_AM01H)
-#define bfin_write_CAN1_AM01H(val)     bfin_write16(CAN1_AM01H, val)
-#define bfin_read_CAN1_AM02L()         bfin_read16(CAN1_AM02L)
-#define bfin_write_CAN1_AM02L(val)     bfin_write16(CAN1_AM02L, val)
-#define bfin_read_CAN1_AM02H()         bfin_read16(CAN1_AM02H)
-#define bfin_write_CAN1_AM02H(val)     bfin_write16(CAN1_AM02H, val)
-#define bfin_read_CAN1_AM03L()         bfin_read16(CAN1_AM03L)
-#define bfin_write_CAN1_AM03L(val)     bfin_write16(CAN1_AM03L, val)
-#define bfin_read_CAN1_AM03H()         bfin_read16(CAN1_AM03H)
-#define bfin_write_CAN1_AM03H(val)     bfin_write16(CAN1_AM03H, val)
-#define bfin_read_CAN1_AM04L()         bfin_read16(CAN1_AM04L)
-#define bfin_write_CAN1_AM04L(val)     bfin_write16(CAN1_AM04L, val)
-#define bfin_read_CAN1_AM04H()         bfin_read16(CAN1_AM04H)
-#define bfin_write_CAN1_AM04H(val)     bfin_write16(CAN1_AM04H, val)
-#define bfin_read_CAN1_AM05L()         bfin_read16(CAN1_AM05L)
-#define bfin_write_CAN1_AM05L(val)     bfin_write16(CAN1_AM05L, val)
-#define bfin_read_CAN1_AM05H()         bfin_read16(CAN1_AM05H)
-#define bfin_write_CAN1_AM05H(val)     bfin_write16(CAN1_AM05H, val)
-#define bfin_read_CAN1_AM06L()         bfin_read16(CAN1_AM06L)
-#define bfin_write_CAN1_AM06L(val)     bfin_write16(CAN1_AM06L, val)
-#define bfin_read_CAN1_AM06H()         bfin_read16(CAN1_AM06H)
-#define bfin_write_CAN1_AM06H(val)     bfin_write16(CAN1_AM06H, val)
-#define bfin_read_CAN1_AM07L()         bfin_read16(CAN1_AM07L)
-#define bfin_write_CAN1_AM07L(val)     bfin_write16(CAN1_AM07L, val)
-#define bfin_read_CAN1_AM07H()         bfin_read16(CAN1_AM07H)
-#define bfin_write_CAN1_AM07H(val)     bfin_write16(CAN1_AM07H, val)
-#define bfin_read_CAN1_AM08L()         bfin_read16(CAN1_AM08L)
-#define bfin_write_CAN1_AM08L(val)     bfin_write16(CAN1_AM08L, val)
-#define bfin_read_CAN1_AM08H()         bfin_read16(CAN1_AM08H)
-#define bfin_write_CAN1_AM08H(val)     bfin_write16(CAN1_AM08H, val)
-#define bfin_read_CAN1_AM09L()         bfin_read16(CAN1_AM09L)
-#define bfin_write_CAN1_AM09L(val)     bfin_write16(CAN1_AM09L, val)
-#define bfin_read_CAN1_AM09H()         bfin_read16(CAN1_AM09H)
-#define bfin_write_CAN1_AM09H(val)     bfin_write16(CAN1_AM09H, val)
-#define bfin_read_CAN1_AM10L()         bfin_read16(CAN1_AM10L)
-#define bfin_write_CAN1_AM10L(val)     bfin_write16(CAN1_AM10L, val)
-#define bfin_read_CAN1_AM10H()         bfin_read16(CAN1_AM10H)
-#define bfin_write_CAN1_AM10H(val)     bfin_write16(CAN1_AM10H, val)
-#define bfin_read_CAN1_AM11L()         bfin_read16(CAN1_AM11L)
-#define bfin_write_CAN1_AM11L(val)     bfin_write16(CAN1_AM11L, val)
-#define bfin_read_CAN1_AM11H()         bfin_read16(CAN1_AM11H)
-#define bfin_write_CAN1_AM11H(val)     bfin_write16(CAN1_AM11H, val)
-#define bfin_read_CAN1_AM12L()         bfin_read16(CAN1_AM12L)
-#define bfin_write_CAN1_AM12L(val)     bfin_write16(CAN1_AM12L, val)
-#define bfin_read_CAN1_AM12H()         bfin_read16(CAN1_AM12H)
-#define bfin_write_CAN1_AM12H(val)     bfin_write16(CAN1_AM12H, val)
-#define bfin_read_CAN1_AM13L()         bfin_read16(CAN1_AM13L)
-#define bfin_write_CAN1_AM13L(val)     bfin_write16(CAN1_AM13L, val)
-#define bfin_read_CAN1_AM13H()         bfin_read16(CAN1_AM13H)
-#define bfin_write_CAN1_AM13H(val)     bfin_write16(CAN1_AM13H, val)
-#define bfin_read_CAN1_AM14L()         bfin_read16(CAN1_AM14L)
-#define bfin_write_CAN1_AM14L(val)     bfin_write16(CAN1_AM14L, val)
-#define bfin_read_CAN1_AM14H()         bfin_read16(CAN1_AM14H)
-#define bfin_write_CAN1_AM14H(val)     bfin_write16(CAN1_AM14H, val)
-#define bfin_read_CAN1_AM15L()         bfin_read16(CAN1_AM15L)
-#define bfin_write_CAN1_AM15L(val)     bfin_write16(CAN1_AM15L, val)
-#define bfin_read_CAN1_AM15H()         bfin_read16(CAN1_AM15H)
-#define bfin_write_CAN1_AM15H(val)     bfin_write16(CAN1_AM15H, val)
-
-/* CAN Controller 1 Mailbox Accebfin_read_()tance Registers */
-
-#define bfin_read_CAN1_AM16L()         bfin_read16(CAN1_AM16L)
-#define bfin_write_CAN1_AM16L(val)     bfin_write16(CAN1_AM16L, val)
-#define bfin_read_CAN1_AM16H()         bfin_read16(CAN1_AM16H)
-#define bfin_write_CAN1_AM16H(val)     bfin_write16(CAN1_AM16H, val)
-#define bfin_read_CAN1_AM17L()         bfin_read16(CAN1_AM17L)
-#define bfin_write_CAN1_AM17L(val)     bfin_write16(CAN1_AM17L, val)
-#define bfin_read_CAN1_AM17H()         bfin_read16(CAN1_AM17H)
-#define bfin_write_CAN1_AM17H(val)     bfin_write16(CAN1_AM17H, val)
-#define bfin_read_CAN1_AM18L()         bfin_read16(CAN1_AM18L)
-#define bfin_write_CAN1_AM18L(val)     bfin_write16(CAN1_AM18L, val)
-#define bfin_read_CAN1_AM18H()         bfin_read16(CAN1_AM18H)
-#define bfin_write_CAN1_AM18H(val)     bfin_write16(CAN1_AM18H, val)
-#define bfin_read_CAN1_AM19L()         bfin_read16(CAN1_AM19L)
-#define bfin_write_CAN1_AM19L(val)     bfin_write16(CAN1_AM19L, val)
-#define bfin_read_CAN1_AM19H()         bfin_read16(CAN1_AM19H)
-#define bfin_write_CAN1_AM19H(val)     bfin_write16(CAN1_AM19H, val)
-#define bfin_read_CAN1_AM20L()         bfin_read16(CAN1_AM20L)
-#define bfin_write_CAN1_AM20L(val)     bfin_write16(CAN1_AM20L, val)
-#define bfin_read_CAN1_AM20H()         bfin_read16(CAN1_AM20H)
-#define bfin_write_CAN1_AM20H(val)     bfin_write16(CAN1_AM20H, val)
-#define bfin_read_CAN1_AM21L()         bfin_read16(CAN1_AM21L)
-#define bfin_write_CAN1_AM21L(val)     bfin_write16(CAN1_AM21L, val)
-#define bfin_read_CAN1_AM21H()         bfin_read16(CAN1_AM21H)
-#define bfin_write_CAN1_AM21H(val)     bfin_write16(CAN1_AM21H, val)
-#define bfin_read_CAN1_AM22L()         bfin_read16(CAN1_AM22L)
-#define bfin_write_CAN1_AM22L(val)     bfin_write16(CAN1_AM22L, val)
-#define bfin_read_CAN1_AM22H()         bfin_read16(CAN1_AM22H)
-#define bfin_write_CAN1_AM22H(val)     bfin_write16(CAN1_AM22H, val)
-#define bfin_read_CAN1_AM23L()         bfin_read16(CAN1_AM23L)
-#define bfin_write_CAN1_AM23L(val)     bfin_write16(CAN1_AM23L, val)
-#define bfin_read_CAN1_AM23H()         bfin_read16(CAN1_AM23H)
-#define bfin_write_CAN1_AM23H(val)     bfin_write16(CAN1_AM23H, val)
-#define bfin_read_CAN1_AM24L()         bfin_read16(CAN1_AM24L)
-#define bfin_write_CAN1_AM24L(val)     bfin_write16(CAN1_AM24L, val)
-#define bfin_read_CAN1_AM24H()         bfin_read16(CAN1_AM24H)
-#define bfin_write_CAN1_AM24H(val)     bfin_write16(CAN1_AM24H, val)
-#define bfin_read_CAN1_AM25L()         bfin_read16(CAN1_AM25L)
-#define bfin_write_CAN1_AM25L(val)     bfin_write16(CAN1_AM25L, val)
-#define bfin_read_CAN1_AM25H()         bfin_read16(CAN1_AM25H)
-#define bfin_write_CAN1_AM25H(val)     bfin_write16(CAN1_AM25H, val)
-#define bfin_read_CAN1_AM26L()         bfin_read16(CAN1_AM26L)
-#define bfin_write_CAN1_AM26L(val)     bfin_write16(CAN1_AM26L, val)
-#define bfin_read_CAN1_AM26H()         bfin_read16(CAN1_AM26H)
-#define bfin_write_CAN1_AM26H(val)     bfin_write16(CAN1_AM26H, val)
-#define bfin_read_CAN1_AM27L()         bfin_read16(CAN1_AM27L)
-#define bfin_write_CAN1_AM27L(val)     bfin_write16(CAN1_AM27L, val)
-#define bfin_read_CAN1_AM27H()         bfin_read16(CAN1_AM27H)
-#define bfin_write_CAN1_AM27H(val)     bfin_write16(CAN1_AM27H, val)
-#define bfin_read_CAN1_AM28L()         bfin_read16(CAN1_AM28L)
-#define bfin_write_CAN1_AM28L(val)     bfin_write16(CAN1_AM28L, val)
-#define bfin_read_CAN1_AM28H()         bfin_read16(CAN1_AM28H)
-#define bfin_write_CAN1_AM28H(val)     bfin_write16(CAN1_AM28H, val)
-#define bfin_read_CAN1_AM29L()         bfin_read16(CAN1_AM29L)
-#define bfin_write_CAN1_AM29L(val)     bfin_write16(CAN1_AM29L, val)
-#define bfin_read_CAN1_AM29H()         bfin_read16(CAN1_AM29H)
-#define bfin_write_CAN1_AM29H(val)     bfin_write16(CAN1_AM29H, val)
-#define bfin_read_CAN1_AM30L()         bfin_read16(CAN1_AM30L)
-#define bfin_write_CAN1_AM30L(val)     bfin_write16(CAN1_AM30L, val)
-#define bfin_read_CAN1_AM30H()         bfin_read16(CAN1_AM30H)
-#define bfin_write_CAN1_AM30H(val)     bfin_write16(CAN1_AM30H, val)
-#define bfin_read_CAN1_AM31L()         bfin_read16(CAN1_AM31L)
-#define bfin_write_CAN1_AM31L(val)     bfin_write16(CAN1_AM31L, val)
-#define bfin_read_CAN1_AM31H()         bfin_read16(CAN1_AM31H)
-#define bfin_write_CAN1_AM31H(val)     bfin_write16(CAN1_AM31H, val)
-
-/* CAN Controller 1 Mailbox Data Registers */
-
-#define bfin_read_CAN1_MB00_DATA0()            bfin_read16(CAN1_MB00_DATA0)
-#define bfin_write_CAN1_MB00_DATA0(val)                bfin_write16(CAN1_MB00_DATA0, val)
-#define bfin_read_CAN1_MB00_DATA1()            bfin_read16(CAN1_MB00_DATA1)
-#define bfin_write_CAN1_MB00_DATA1(val)                bfin_write16(CAN1_MB00_DATA1, val)
-#define bfin_read_CAN1_MB00_DATA2()            bfin_read16(CAN1_MB00_DATA2)
-#define bfin_write_CAN1_MB00_DATA2(val)                bfin_write16(CAN1_MB00_DATA2, val)
-#define bfin_read_CAN1_MB00_DATA3()            bfin_read16(CAN1_MB00_DATA3)
-#define bfin_write_CAN1_MB00_DATA3(val)                bfin_write16(CAN1_MB00_DATA3, val)
-#define bfin_read_CAN1_MB00_LENGTH()           bfin_read16(CAN1_MB00_LENGTH)
-#define bfin_write_CAN1_MB00_LENGTH(val)       bfin_write16(CAN1_MB00_LENGTH, val)
-#define bfin_read_CAN1_MB00_TIMESTAMP()                bfin_read16(CAN1_MB00_TIMESTAMP)
-#define bfin_write_CAN1_MB00_TIMESTAMP(val)    bfin_write16(CAN1_MB00_TIMESTAMP, val)
-#define bfin_read_CAN1_MB00_ID0()              bfin_read16(CAN1_MB00_ID0)
-#define bfin_write_CAN1_MB00_ID0(val)          bfin_write16(CAN1_MB00_ID0, val)
-#define bfin_read_CAN1_MB00_ID1()              bfin_read16(CAN1_MB00_ID1)
-#define bfin_write_CAN1_MB00_ID1(val)          bfin_write16(CAN1_MB00_ID1, val)
-#define bfin_read_CAN1_MB01_DATA0()            bfin_read16(CAN1_MB01_DATA0)
-#define bfin_write_CAN1_MB01_DATA0(val)                bfin_write16(CAN1_MB01_DATA0, val)
-#define bfin_read_CAN1_MB01_DATA1()            bfin_read16(CAN1_MB01_DATA1)
-#define bfin_write_CAN1_MB01_DATA1(val)                bfin_write16(CAN1_MB01_DATA1, val)
-#define bfin_read_CAN1_MB01_DATA2()            bfin_read16(CAN1_MB01_DATA2)
-#define bfin_write_CAN1_MB01_DATA2(val)                bfin_write16(CAN1_MB01_DATA2, val)
-#define bfin_read_CAN1_MB01_DATA3()            bfin_read16(CAN1_MB01_DATA3)
-#define bfin_write_CAN1_MB01_DATA3(val)                bfin_write16(CAN1_MB01_DATA3, val)
-#define bfin_read_CAN1_MB01_LENGTH()           bfin_read16(CAN1_MB01_LENGTH)
-#define bfin_write_CAN1_MB01_LENGTH(val)       bfin_write16(CAN1_MB01_LENGTH, val)
-#define bfin_read_CAN1_MB01_TIMESTAMP()                bfin_read16(CAN1_MB01_TIMESTAMP)
-#define bfin_write_CAN1_MB01_TIMESTAMP(val)    bfin_write16(CAN1_MB01_TIMESTAMP, val)
-#define bfin_read_CAN1_MB01_ID0()              bfin_read16(CAN1_MB01_ID0)
-#define bfin_write_CAN1_MB01_ID0(val)          bfin_write16(CAN1_MB01_ID0, val)
-#define bfin_read_CAN1_MB01_ID1()              bfin_read16(CAN1_MB01_ID1)
-#define bfin_write_CAN1_MB01_ID1(val)          bfin_write16(CAN1_MB01_ID1, val)
-#define bfin_read_CAN1_MB02_DATA0()            bfin_read16(CAN1_MB02_DATA0)
-#define bfin_write_CAN1_MB02_DATA0(val)                bfin_write16(CAN1_MB02_DATA0, val)
-#define bfin_read_CAN1_MB02_DATA1()            bfin_read16(CAN1_MB02_DATA1)
-#define bfin_write_CAN1_MB02_DATA1(val)                bfin_write16(CAN1_MB02_DATA1, val)
-#define bfin_read_CAN1_MB02_DATA2()            bfin_read16(CAN1_MB02_DATA2)
-#define bfin_write_CAN1_MB02_DATA2(val)                bfin_write16(CAN1_MB02_DATA2, val)
-#define bfin_read_CAN1_MB02_DATA3()            bfin_read16(CAN1_MB02_DATA3)
-#define bfin_write_CAN1_MB02_DATA3(val)                bfin_write16(CAN1_MB02_DATA3, val)
-#define bfin_read_CAN1_MB02_LENGTH()           bfin_read16(CAN1_MB02_LENGTH)
-#define bfin_write_CAN1_MB02_LENGTH(val)       bfin_write16(CAN1_MB02_LENGTH, val)
-#define bfin_read_CAN1_MB02_TIMESTAMP()                bfin_read16(CAN1_MB02_TIMESTAMP)
-#define bfin_write_CAN1_MB02_TIMESTAMP(val)    bfin_write16(CAN1_MB02_TIMESTAMP, val)
-#define bfin_read_CAN1_MB02_ID0()              bfin_read16(CAN1_MB02_ID0)
-#define bfin_write_CAN1_MB02_ID0(val)          bfin_write16(CAN1_MB02_ID0, val)
-#define bfin_read_CAN1_MB02_ID1()              bfin_read16(CAN1_MB02_ID1)
-#define bfin_write_CAN1_MB02_ID1(val)          bfin_write16(CAN1_MB02_ID1, val)
-#define bfin_read_CAN1_MB03_DATA0()            bfin_read16(CAN1_MB03_DATA0)
-#define bfin_write_CAN1_MB03_DATA0(val)                bfin_write16(CAN1_MB03_DATA0, val)
-#define bfin_read_CAN1_MB03_DATA1()            bfin_read16(CAN1_MB03_DATA1)
-#define bfin_write_CAN1_MB03_DATA1(val)                bfin_write16(CAN1_MB03_DATA1, val)
-#define bfin_read_CAN1_MB03_DATA2()            bfin_read16(CAN1_MB03_DATA2)
-#define bfin_write_CAN1_MB03_DATA2(val)                bfin_write16(CAN1_MB03_DATA2, val)
-#define bfin_read_CAN1_MB03_DATA3()            bfin_read16(CAN1_MB03_DATA3)
-#define bfin_write_CAN1_MB03_DATA3(val)                bfin_write16(CAN1_MB03_DATA3, val)
-#define bfin_read_CAN1_MB03_LENGTH()           bfin_read16(CAN1_MB03_LENGTH)
-#define bfin_write_CAN1_MB03_LENGTH(val)       bfin_write16(CAN1_MB03_LENGTH, val)
-#define bfin_read_CAN1_MB03_TIMESTAMP()                bfin_read16(CAN1_MB03_TIMESTAMP)
-#define bfin_write_CAN1_MB03_TIMESTAMP(val)    bfin_write16(CAN1_MB03_TIMESTAMP, val)
-#define bfin_read_CAN1_MB03_ID0()              bfin_read16(CAN1_MB03_ID0)
-#define bfin_write_CAN1_MB03_ID0(val)          bfin_write16(CAN1_MB03_ID0, val)
-#define bfin_read_CAN1_MB03_ID1()              bfin_read16(CAN1_MB03_ID1)
-#define bfin_write_CAN1_MB03_ID1(val)          bfin_write16(CAN1_MB03_ID1, val)
-#define bfin_read_CAN1_MB04_DATA0()            bfin_read16(CAN1_MB04_DATA0)
-#define bfin_write_CAN1_MB04_DATA0(val)                bfin_write16(CAN1_MB04_DATA0, val)
-#define bfin_read_CAN1_MB04_DATA1()            bfin_read16(CAN1_MB04_DATA1)
-#define bfin_write_CAN1_MB04_DATA1(val)                bfin_write16(CAN1_MB04_DATA1, val)
-#define bfin_read_CAN1_MB04_DATA2()            bfin_read16(CAN1_MB04_DATA2)
-#define bfin_write_CAN1_MB04_DATA2(val)                bfin_write16(CAN1_MB04_DATA2, val)
-#define bfin_read_CAN1_MB04_DATA3()            bfin_read16(CAN1_MB04_DATA3)
-#define bfin_write_CAN1_MB04_DATA3(val)                bfin_write16(CAN1_MB04_DATA3, val)
-#define bfin_read_CAN1_MB04_LENGTH()           bfin_read16(CAN1_MB04_LENGTH)
-#define bfin_write_CAN1_MB04_LENGTH(val)       bfin_write16(CAN1_MB04_LENGTH, val)
-#define bfin_read_CAN1_MB04_TIMESTAMP()                bfin_read16(CAN1_MB04_TIMESTAMP)
-#define bfin_write_CAN1_MB04_TIMESTAMP(val)    bfin_write16(CAN1_MB04_TIMESTAMP, val)
-#define bfin_read_CAN1_MB04_ID0()              bfin_read16(CAN1_MB04_ID0)
-#define bfin_write_CAN1_MB04_ID0(val)          bfin_write16(CAN1_MB04_ID0, val)
-#define bfin_read_CAN1_MB04_ID1()              bfin_read16(CAN1_MB04_ID1)
-#define bfin_write_CAN1_MB04_ID1(val)          bfin_write16(CAN1_MB04_ID1, val)
-#define bfin_read_CAN1_MB05_DATA0()            bfin_read16(CAN1_MB05_DATA0)
-#define bfin_write_CAN1_MB05_DATA0(val)                bfin_write16(CAN1_MB05_DATA0, val)
-#define bfin_read_CAN1_MB05_DATA1()            bfin_read16(CAN1_MB05_DATA1)
-#define bfin_write_CAN1_MB05_DATA1(val)                bfin_write16(CAN1_MB05_DATA1, val)
-#define bfin_read_CAN1_MB05_DATA2()            bfin_read16(CAN1_MB05_DATA2)
-#define bfin_write_CAN1_MB05_DATA2(val)                bfin_write16(CAN1_MB05_DATA2, val)
-#define bfin_read_CAN1_MB05_DATA3()            bfin_read16(CAN1_MB05_DATA3)
-#define bfin_write_CAN1_MB05_DATA3(val)                bfin_write16(CAN1_MB05_DATA3, val)
-#define bfin_read_CAN1_MB05_LENGTH()           bfin_read16(CAN1_MB05_LENGTH)
-#define bfin_write_CAN1_MB05_LENGTH(val)       bfin_write16(CAN1_MB05_LENGTH, val)
-#define bfin_read_CAN1_MB05_TIMESTAMP()                bfin_read16(CAN1_MB05_TIMESTAMP)
-#define bfin_write_CAN1_MB05_TIMESTAMP(val)    bfin_write16(CAN1_MB05_TIMESTAMP, val)
-#define bfin_read_CAN1_MB05_ID0()              bfin_read16(CAN1_MB05_ID0)
-#define bfin_write_CAN1_MB05_ID0(val)          bfin_write16(CAN1_MB05_ID0, val)
-#define bfin_read_CAN1_MB05_ID1()              bfin_read16(CAN1_MB05_ID1)
-#define bfin_write_CAN1_MB05_ID1(val)          bfin_write16(CAN1_MB05_ID1, val)
-#define bfin_read_CAN1_MB06_DATA0()            bfin_read16(CAN1_MB06_DATA0)
-#define bfin_write_CAN1_MB06_DATA0(val)                bfin_write16(CAN1_MB06_DATA0, val)
-#define bfin_read_CAN1_MB06_DATA1()            bfin_read16(CAN1_MB06_DATA1)
-#define bfin_write_CAN1_MB06_DATA1(val)                bfin_write16(CAN1_MB06_DATA1, val)
-#define bfin_read_CAN1_MB06_DATA2()            bfin_read16(CAN1_MB06_DATA2)
-#define bfin_write_CAN1_MB06_DATA2(val)                bfin_write16(CAN1_MB06_DATA2, val)
-#define bfin_read_CAN1_MB06_DATA3()            bfin_read16(CAN1_MB06_DATA3)
-#define bfin_write_CAN1_MB06_DATA3(val)                bfin_write16(CAN1_MB06_DATA3, val)
-#define bfin_read_CAN1_MB06_LENGTH()           bfin_read16(CAN1_MB06_LENGTH)
-#define bfin_write_CAN1_MB06_LENGTH(val)       bfin_write16(CAN1_MB06_LENGTH, val)
-#define bfin_read_CAN1_MB06_TIMESTAMP()                bfin_read16(CAN1_MB06_TIMESTAMP)
-#define bfin_write_CAN1_MB06_TIMESTAMP(val)    bfin_write16(CAN1_MB06_TIMESTAMP, val)
-#define bfin_read_CAN1_MB06_ID0()              bfin_read16(CAN1_MB06_ID0)
-#define bfin_write_CAN1_MB06_ID0(val)          bfin_write16(CAN1_MB06_ID0, val)
-#define bfin_read_CAN1_MB06_ID1()              bfin_read16(CAN1_MB06_ID1)
-#define bfin_write_CAN1_MB06_ID1(val)          bfin_write16(CAN1_MB06_ID1, val)
-#define bfin_read_CAN1_MB07_DATA0()            bfin_read16(CAN1_MB07_DATA0)
-#define bfin_write_CAN1_MB07_DATA0(val)                bfin_write16(CAN1_MB07_DATA0, val)
-#define bfin_read_CAN1_MB07_DATA1()            bfin_read16(CAN1_MB07_DATA1)
-#define bfin_write_CAN1_MB07_DATA1(val)                bfin_write16(CAN1_MB07_DATA1, val)
-#define bfin_read_CAN1_MB07_DATA2()            bfin_read16(CAN1_MB07_DATA2)
-#define bfin_write_CAN1_MB07_DATA2(val)                bfin_write16(CAN1_MB07_DATA2, val)
-#define bfin_read_CAN1_MB07_DATA3()            bfin_read16(CAN1_MB07_DATA3)
-#define bfin_write_CAN1_MB07_DATA3(val)                bfin_write16(CAN1_MB07_DATA3, val)
-#define bfin_read_CAN1_MB07_LENGTH()           bfin_read16(CAN1_MB07_LENGTH)
-#define bfin_write_CAN1_MB07_LENGTH(val)       bfin_write16(CAN1_MB07_LENGTH, val)
-#define bfin_read_CAN1_MB07_TIMESTAMP()                bfin_read16(CAN1_MB07_TIMESTAMP)
-#define bfin_write_CAN1_MB07_TIMESTAMP(val)    bfin_write16(CAN1_MB07_TIMESTAMP, val)
-#define bfin_read_CAN1_MB07_ID0()              bfin_read16(CAN1_MB07_ID0)
-#define bfin_write_CAN1_MB07_ID0(val)          bfin_write16(CAN1_MB07_ID0, val)
-#define bfin_read_CAN1_MB07_ID1()              bfin_read16(CAN1_MB07_ID1)
-#define bfin_write_CAN1_MB07_ID1(val)          bfin_write16(CAN1_MB07_ID1, val)
-#define bfin_read_CAN1_MB08_DATA0()            bfin_read16(CAN1_MB08_DATA0)
-#define bfin_write_CAN1_MB08_DATA0(val)                bfin_write16(CAN1_MB08_DATA0, val)
-#define bfin_read_CAN1_MB08_DATA1()            bfin_read16(CAN1_MB08_DATA1)
-#define bfin_write_CAN1_MB08_DATA1(val)                bfin_write16(CAN1_MB08_DATA1, val)
-#define bfin_read_CAN1_MB08_DATA2()            bfin_read16(CAN1_MB08_DATA2)
-#define bfin_write_CAN1_MB08_DATA2(val)                bfin_write16(CAN1_MB08_DATA2, val)
-#define bfin_read_CAN1_MB08_DATA3()            bfin_read16(CAN1_MB08_DATA3)
-#define bfin_write_CAN1_MB08_DATA3(val)                bfin_write16(CAN1_MB08_DATA3, val)
-#define bfin_read_CAN1_MB08_LENGTH()           bfin_read16(CAN1_MB08_LENGTH)
-#define bfin_write_CAN1_MB08_LENGTH(val)       bfin_write16(CAN1_MB08_LENGTH, val)
-#define bfin_read_CAN1_MB08_TIMESTAMP()                bfin_read16(CAN1_MB08_TIMESTAMP)
-#define bfin_write_CAN1_MB08_TIMESTAMP(val)    bfin_write16(CAN1_MB08_TIMESTAMP, val)
-#define bfin_read_CAN1_MB08_ID0()              bfin_read16(CAN1_MB08_ID0)
-#define bfin_write_CAN1_MB08_ID0(val)          bfin_write16(CAN1_MB08_ID0, val)
-#define bfin_read_CAN1_MB08_ID1()              bfin_read16(CAN1_MB08_ID1)
-#define bfin_write_CAN1_MB08_ID1(val)          bfin_write16(CAN1_MB08_ID1, val)
-#define bfin_read_CAN1_MB09_DATA0()            bfin_read16(CAN1_MB09_DATA0)
-#define bfin_write_CAN1_MB09_DATA0(val)                bfin_write16(CAN1_MB09_DATA0, val)
-#define bfin_read_CAN1_MB09_DATA1()            bfin_read16(CAN1_MB09_DATA1)
-#define bfin_write_CAN1_MB09_DATA1(val)                bfin_write16(CAN1_MB09_DATA1, val)
-#define bfin_read_CAN1_MB09_DATA2()            bfin_read16(CAN1_MB09_DATA2)
-#define bfin_write_CAN1_MB09_DATA2(val)                bfin_write16(CAN1_MB09_DATA2, val)
-#define bfin_read_CAN1_MB09_DATA3()            bfin_read16(CAN1_MB09_DATA3)
-#define bfin_write_CAN1_MB09_DATA3(val)                bfin_write16(CAN1_MB09_DATA3, val)
-#define bfin_read_CAN1_MB09_LENGTH()           bfin_read16(CAN1_MB09_LENGTH)
-#define bfin_write_CAN1_MB09_LENGTH(val)       bfin_write16(CAN1_MB09_LENGTH, val)
-#define bfin_read_CAN1_MB09_TIMESTAMP()                bfin_read16(CAN1_MB09_TIMESTAMP)
-#define bfin_write_CAN1_MB09_TIMESTAMP(val)    bfin_write16(CAN1_MB09_TIMESTAMP, val)
-#define bfin_read_CAN1_MB09_ID0()              bfin_read16(CAN1_MB09_ID0)
-#define bfin_write_CAN1_MB09_ID0(val)          bfin_write16(CAN1_MB09_ID0, val)
-#define bfin_read_CAN1_MB09_ID1()              bfin_read16(CAN1_MB09_ID1)
-#define bfin_write_CAN1_MB09_ID1(val)          bfin_write16(CAN1_MB09_ID1, val)
-#define bfin_read_CAN1_MB10_DATA0()            bfin_read16(CAN1_MB10_DATA0)
-#define bfin_write_CAN1_MB10_DATA0(val)                bfin_write16(CAN1_MB10_DATA0, val)
-#define bfin_read_CAN1_MB10_DATA1()            bfin_read16(CAN1_MB10_DATA1)
-#define bfin_write_CAN1_MB10_DATA1(val)                bfin_write16(CAN1_MB10_DATA1, val)
-#define bfin_read_CAN1_MB10_DATA2()            bfin_read16(CAN1_MB10_DATA2)
-#define bfin_write_CAN1_MB10_DATA2(val)                bfin_write16(CAN1_MB10_DATA2, val)
-#define bfin_read_CAN1_MB10_DATA3()            bfin_read16(CAN1_MB10_DATA3)
-#define bfin_write_CAN1_MB10_DATA3(val)                bfin_write16(CAN1_MB10_DATA3, val)
-#define bfin_read_CAN1_MB10_LENGTH()           bfin_read16(CAN1_MB10_LENGTH)
-#define bfin_write_CAN1_MB10_LENGTH(val)       bfin_write16(CAN1_MB10_LENGTH, val)
-#define bfin_read_CAN1_MB10_TIMESTAMP()                bfin_read16(CAN1_MB10_TIMESTAMP)
-#define bfin_write_CAN1_MB10_TIMESTAMP(val)    bfin_write16(CAN1_MB10_TIMESTAMP, val)
-#define bfin_read_CAN1_MB10_ID0()              bfin_read16(CAN1_MB10_ID0)
-#define bfin_write_CAN1_MB10_ID0(val)          bfin_write16(CAN1_MB10_ID0, val)
-#define bfin_read_CAN1_MB10_ID1()              bfin_read16(CAN1_MB10_ID1)
-#define bfin_write_CAN1_MB10_ID1(val)          bfin_write16(CAN1_MB10_ID1, val)
-#define bfin_read_CAN1_MB11_DATA0()            bfin_read16(CAN1_MB11_DATA0)
-#define bfin_write_CAN1_MB11_DATA0(val)                bfin_write16(CAN1_MB11_DATA0, val)
-#define bfin_read_CAN1_MB11_DATA1()            bfin_read16(CAN1_MB11_DATA1)
-#define bfin_write_CAN1_MB11_DATA1(val)                bfin_write16(CAN1_MB11_DATA1, val)
-#define bfin_read_CAN1_MB11_DATA2()            bfin_read16(CAN1_MB11_DATA2)
-#define bfin_write_CAN1_MB11_DATA2(val)                bfin_write16(CAN1_MB11_DATA2, val)
-#define bfin_read_CAN1_MB11_DATA3()            bfin_read16(CAN1_MB11_DATA3)
-#define bfin_write_CAN1_MB11_DATA3(val)                bfin_write16(CAN1_MB11_DATA3, val)
-#define bfin_read_CAN1_MB11_LENGTH()           bfin_read16(CAN1_MB11_LENGTH)
-#define bfin_write_CAN1_MB11_LENGTH(val)       bfin_write16(CAN1_MB11_LENGTH, val)
-#define bfin_read_CAN1_MB11_TIMESTAMP()                bfin_read16(CAN1_MB11_TIMESTAMP)
-#define bfin_write_CAN1_MB11_TIMESTAMP(val)    bfin_write16(CAN1_MB11_TIMESTAMP, val)
-#define bfin_read_CAN1_MB11_ID0()              bfin_read16(CAN1_MB11_ID0)
-#define bfin_write_CAN1_MB11_ID0(val)          bfin_write16(CAN1_MB11_ID0, val)
-#define bfin_read_CAN1_MB11_ID1()              bfin_read16(CAN1_MB11_ID1)
-#define bfin_write_CAN1_MB11_ID1(val)          bfin_write16(CAN1_MB11_ID1, val)
-#define bfin_read_CAN1_MB12_DATA0()            bfin_read16(CAN1_MB12_DATA0)
-#define bfin_write_CAN1_MB12_DATA0(val)                bfin_write16(CAN1_MB12_DATA0, val)
-#define bfin_read_CAN1_MB12_DATA1()            bfin_read16(CAN1_MB12_DATA1)
-#define bfin_write_CAN1_MB12_DATA1(val)                bfin_write16(CAN1_MB12_DATA1, val)
-#define bfin_read_CAN1_MB12_DATA2()            bfin_read16(CAN1_MB12_DATA2)
-#define bfin_write_CAN1_MB12_DATA2(val)                bfin_write16(CAN1_MB12_DATA2, val)
-#define bfin_read_CAN1_MB12_DATA3()            bfin_read16(CAN1_MB12_DATA3)
-#define bfin_write_CAN1_MB12_DATA3(val)                bfin_write16(CAN1_MB12_DATA3, val)
-#define bfin_read_CAN1_MB12_LENGTH()           bfin_read16(CAN1_MB12_LENGTH)
-#define bfin_write_CAN1_MB12_LENGTH(val)       bfin_write16(CAN1_MB12_LENGTH, val)
-#define bfin_read_CAN1_MB12_TIMESTAMP()                bfin_read16(CAN1_MB12_TIMESTAMP)
-#define bfin_write_CAN1_MB12_TIMESTAMP(val)    bfin_write16(CAN1_MB12_TIMESTAMP, val)
-#define bfin_read_CAN1_MB12_ID0()              bfin_read16(CAN1_MB12_ID0)
-#define bfin_write_CAN1_MB12_ID0(val)          bfin_write16(CAN1_MB12_ID0, val)
-#define bfin_read_CAN1_MB12_ID1()              bfin_read16(CAN1_MB12_ID1)
-#define bfin_write_CAN1_MB12_ID1(val)          bfin_write16(CAN1_MB12_ID1, val)
-#define bfin_read_CAN1_MB13_DATA0()            bfin_read16(CAN1_MB13_DATA0)
-#define bfin_write_CAN1_MB13_DATA0(val)                bfin_write16(CAN1_MB13_DATA0, val)
-#define bfin_read_CAN1_MB13_DATA1()            bfin_read16(CAN1_MB13_DATA1)
-#define bfin_write_CAN1_MB13_DATA1(val)                bfin_write16(CAN1_MB13_DATA1, val)
-#define bfin_read_CAN1_MB13_DATA2()            bfin_read16(CAN1_MB13_DATA2)
-#define bfin_write_CAN1_MB13_DATA2(val)                bfin_write16(CAN1_MB13_DATA2, val)
-#define bfin_read_CAN1_MB13_DATA3()            bfin_read16(CAN1_MB13_DATA3)
-#define bfin_write_CAN1_MB13_DATA3(val)                bfin_write16(CAN1_MB13_DATA3, val)
-#define bfin_read_CAN1_MB13_LENGTH()           bfin_read16(CAN1_MB13_LENGTH)
-#define bfin_write_CAN1_MB13_LENGTH(val)       bfin_write16(CAN1_MB13_LENGTH, val)
-#define bfin_read_CAN1_MB13_TIMESTAMP()                bfin_read16(CAN1_MB13_TIMESTAMP)
-#define bfin_write_CAN1_MB13_TIMESTAMP(val)    bfin_write16(CAN1_MB13_TIMESTAMP, val)
-#define bfin_read_CAN1_MB13_ID0()              bfin_read16(CAN1_MB13_ID0)
-#define bfin_write_CAN1_MB13_ID0(val)          bfin_write16(CAN1_MB13_ID0, val)
-#define bfin_read_CAN1_MB13_ID1()              bfin_read16(CAN1_MB13_ID1)
-#define bfin_write_CAN1_MB13_ID1(val)          bfin_write16(CAN1_MB13_ID1, val)
-#define bfin_read_CAN1_MB14_DATA0()            bfin_read16(CAN1_MB14_DATA0)
-#define bfin_write_CAN1_MB14_DATA0(val)                bfin_write16(CAN1_MB14_DATA0, val)
-#define bfin_read_CAN1_MB14_DATA1()            bfin_read16(CAN1_MB14_DATA1)
-#define bfin_write_CAN1_MB14_DATA1(val)                bfin_write16(CAN1_MB14_DATA1, val)
-#define bfin_read_CAN1_MB14_DATA2()            bfin_read16(CAN1_MB14_DATA2)
-#define bfin_write_CAN1_MB14_DATA2(val)                bfin_write16(CAN1_MB14_DATA2, val)
-#define bfin_read_CAN1_MB14_DATA3()            bfin_read16(CAN1_MB14_DATA3)
-#define bfin_write_CAN1_MB14_DATA3(val)                bfin_write16(CAN1_MB14_DATA3, val)
-#define bfin_read_CAN1_MB14_LENGTH()           bfin_read16(CAN1_MB14_LENGTH)
-#define bfin_write_CAN1_MB14_LENGTH(val)       bfin_write16(CAN1_MB14_LENGTH, val)
-#define bfin_read_CAN1_MB14_TIMESTAMP()                bfin_read16(CAN1_MB14_TIMESTAMP)
-#define bfin_write_CAN1_MB14_TIMESTAMP(val)    bfin_write16(CAN1_MB14_TIMESTAMP, val)
-#define bfin_read_CAN1_MB14_ID0()              bfin_read16(CAN1_MB14_ID0)
-#define bfin_write_CAN1_MB14_ID0(val)          bfin_write16(CAN1_MB14_ID0, val)
-#define bfin_read_CAN1_MB14_ID1()              bfin_read16(CAN1_MB14_ID1)
-#define bfin_write_CAN1_MB14_ID1(val)          bfin_write16(CAN1_MB14_ID1, val)
-#define bfin_read_CAN1_MB15_DATA0()            bfin_read16(CAN1_MB15_DATA0)
-#define bfin_write_CAN1_MB15_DATA0(val)                bfin_write16(CAN1_MB15_DATA0, val)
-#define bfin_read_CAN1_MB15_DATA1()            bfin_read16(CAN1_MB15_DATA1)
-#define bfin_write_CAN1_MB15_DATA1(val)                bfin_write16(CAN1_MB15_DATA1, val)
-#define bfin_read_CAN1_MB15_DATA2()            bfin_read16(CAN1_MB15_DATA2)
-#define bfin_write_CAN1_MB15_DATA2(val)                bfin_write16(CAN1_MB15_DATA2, val)
-#define bfin_read_CAN1_MB15_DATA3()            bfin_read16(CAN1_MB15_DATA3)
-#define bfin_write_CAN1_MB15_DATA3(val)                bfin_write16(CAN1_MB15_DATA3, val)
-#define bfin_read_CAN1_MB15_LENGTH()           bfin_read16(CAN1_MB15_LENGTH)
-#define bfin_write_CAN1_MB15_LENGTH(val)       bfin_write16(CAN1_MB15_LENGTH, val)
-#define bfin_read_CAN1_MB15_TIMESTAMP()                bfin_read16(CAN1_MB15_TIMESTAMP)
-#define bfin_write_CAN1_MB15_TIMESTAMP(val)    bfin_write16(CAN1_MB15_TIMESTAMP, val)
-#define bfin_read_CAN1_MB15_ID0()              bfin_read16(CAN1_MB15_ID0)
-#define bfin_write_CAN1_MB15_ID0(val)          bfin_write16(CAN1_MB15_ID0, val)
-#define bfin_read_CAN1_MB15_ID1()              bfin_read16(CAN1_MB15_ID1)
-#define bfin_write_CAN1_MB15_ID1(val)          bfin_write16(CAN1_MB15_ID1, val)
-
-/* CAN Controller 1 Mailbox Data Registers */
-
-#define bfin_read_CAN1_MB16_DATA0()            bfin_read16(CAN1_MB16_DATA0)
-#define bfin_write_CAN1_MB16_DATA0(val)                bfin_write16(CAN1_MB16_DATA0, val)
-#define bfin_read_CAN1_MB16_DATA1()            bfin_read16(CAN1_MB16_DATA1)
-#define bfin_write_CAN1_MB16_DATA1(val)                bfin_write16(CAN1_MB16_DATA1, val)
-#define bfin_read_CAN1_MB16_DATA2()            bfin_read16(CAN1_MB16_DATA2)
-#define bfin_write_CAN1_MB16_DATA2(val)                bfin_write16(CAN1_MB16_DATA2, val)
-#define bfin_read_CAN1_MB16_DATA3()            bfin_read16(CAN1_MB16_DATA3)
-#define bfin_write_CAN1_MB16_DATA3(val)                bfin_write16(CAN1_MB16_DATA3, val)
-#define bfin_read_CAN1_MB16_LENGTH()           bfin_read16(CAN1_MB16_LENGTH)
-#define bfin_write_CAN1_MB16_LENGTH(val)       bfin_write16(CAN1_MB16_LENGTH, val)
-#define bfin_read_CAN1_MB16_TIMESTAMP()                bfin_read16(CAN1_MB16_TIMESTAMP)
-#define bfin_write_CAN1_MB16_TIMESTAMP(val)    bfin_write16(CAN1_MB16_TIMESTAMP, val)
-#define bfin_read_CAN1_MB16_ID0()              bfin_read16(CAN1_MB16_ID0)
-#define bfin_write_CAN1_MB16_ID0(val)          bfin_write16(CAN1_MB16_ID0, val)
-#define bfin_read_CAN1_MB16_ID1()              bfin_read16(CAN1_MB16_ID1)
-#define bfin_write_CAN1_MB16_ID1(val)          bfin_write16(CAN1_MB16_ID1, val)
-#define bfin_read_CAN1_MB17_DATA0()            bfin_read16(CAN1_MB17_DATA0)
-#define bfin_write_CAN1_MB17_DATA0(val)                bfin_write16(CAN1_MB17_DATA0, val)
-#define bfin_read_CAN1_MB17_DATA1()            bfin_read16(CAN1_MB17_DATA1)
-#define bfin_write_CAN1_MB17_DATA1(val)                bfin_write16(CAN1_MB17_DATA1, val)
-#define bfin_read_CAN1_MB17_DATA2()            bfin_read16(CAN1_MB17_DATA2)
-#define bfin_write_CAN1_MB17_DATA2(val)                bfin_write16(CAN1_MB17_DATA2, val)
-#define bfin_read_CAN1_MB17_DATA3()            bfin_read16(CAN1_MB17_DATA3)
-#define bfin_write_CAN1_MB17_DATA3(val)                bfin_write16(CAN1_MB17_DATA3, val)
-#define bfin_read_CAN1_MB17_LENGTH()           bfin_read16(CAN1_MB17_LENGTH)
-#define bfin_write_CAN1_MB17_LENGTH(val)       bfin_write16(CAN1_MB17_LENGTH, val)
-#define bfin_read_CAN1_MB17_TIMESTAMP()                bfin_read16(CAN1_MB17_TIMESTAMP)
-#define bfin_write_CAN1_MB17_TIMESTAMP(val)    bfin_write16(CAN1_MB17_TIMESTAMP, val)
-#define bfin_read_CAN1_MB17_ID0()              bfin_read16(CAN1_MB17_ID0)
-#define bfin_write_CAN1_MB17_ID0(val)          bfin_write16(CAN1_MB17_ID0, val)
-#define bfin_read_CAN1_MB17_ID1()              bfin_read16(CAN1_MB17_ID1)
-#define bfin_write_CAN1_MB17_ID1(val)          bfin_write16(CAN1_MB17_ID1, val)
-#define bfin_read_CAN1_MB18_DATA0()            bfin_read16(CAN1_MB18_DATA0)
-#define bfin_write_CAN1_MB18_DATA0(val)                bfin_write16(CAN1_MB18_DATA0, val)
-#define bfin_read_CAN1_MB18_DATA1()            bfin_read16(CAN1_MB18_DATA1)
-#define bfin_write_CAN1_MB18_DATA1(val)                bfin_write16(CAN1_MB18_DATA1, val)
-#define bfin_read_CAN1_MB18_DATA2()            bfin_read16(CAN1_MB18_DATA2)
-#define bfin_write_CAN1_MB18_DATA2(val)                bfin_write16(CAN1_MB18_DATA2, val)
-#define bfin_read_CAN1_MB18_DATA3()            bfin_read16(CAN1_MB18_DATA3)
-#define bfin_write_CAN1_MB18_DATA3(val)                bfin_write16(CAN1_MB18_DATA3, val)
-#define bfin_read_CAN1_MB18_LENGTH()           bfin_read16(CAN1_MB18_LENGTH)
-#define bfin_write_CAN1_MB18_LENGTH(val)       bfin_write16(CAN1_MB18_LENGTH, val)
-#define bfin_read_CAN1_MB18_TIMESTAMP()                bfin_read16(CAN1_MB18_TIMESTAMP)
-#define bfin_write_CAN1_MB18_TIMESTAMP(val)    bfin_write16(CAN1_MB18_TIMESTAMP, val)
-#define bfin_read_CAN1_MB18_ID0()              bfin_read16(CAN1_MB18_ID0)
-#define bfin_write_CAN1_MB18_ID0(val)          bfin_write16(CAN1_MB18_ID0, val)
-#define bfin_read_CAN1_MB18_ID1()              bfin_read16(CAN1_MB18_ID1)
-#define bfin_write_CAN1_MB18_ID1(val)          bfin_write16(CAN1_MB18_ID1, val)
-#define bfin_read_CAN1_MB19_DATA0()            bfin_read16(CAN1_MB19_DATA0)
-#define bfin_write_CAN1_MB19_DATA0(val)                bfin_write16(CAN1_MB19_DATA0, val)
-#define bfin_read_CAN1_MB19_DATA1()            bfin_read16(CAN1_MB19_DATA1)
-#define bfin_write_CAN1_MB19_DATA1(val)                bfin_write16(CAN1_MB19_DATA1, val)
-#define bfin_read_CAN1_MB19_DATA2()            bfin_read16(CAN1_MB19_DATA2)
-#define bfin_write_CAN1_MB19_DATA2(val)                bfin_write16(CAN1_MB19_DATA2, val)
-#define bfin_read_CAN1_MB19_DATA3()            bfin_read16(CAN1_MB19_DATA3)
-#define bfin_write_CAN1_MB19_DATA3(val)                bfin_write16(CAN1_MB19_DATA3, val)
-#define bfin_read_CAN1_MB19_LENGTH()           bfin_read16(CAN1_MB19_LENGTH)
-#define bfin_write_CAN1_MB19_LENGTH(val)       bfin_write16(CAN1_MB19_LENGTH, val)
-#define bfin_read_CAN1_MB19_TIMESTAMP()                bfin_read16(CAN1_MB19_TIMESTAMP)
-#define bfin_write_CAN1_MB19_TIMESTAMP(val)    bfin_write16(CAN1_MB19_TIMESTAMP, val)
-#define bfin_read_CAN1_MB19_ID0()              bfin_read16(CAN1_MB19_ID0)
-#define bfin_write_CAN1_MB19_ID0(val)          bfin_write16(CAN1_MB19_ID0, val)
-#define bfin_read_CAN1_MB19_ID1()              bfin_read16(CAN1_MB19_ID1)
-#define bfin_write_CAN1_MB19_ID1(val)          bfin_write16(CAN1_MB19_ID1, val)
-#define bfin_read_CAN1_MB20_DATA0()            bfin_read16(CAN1_MB20_DATA0)
-#define bfin_write_CAN1_MB20_DATA0(val)                bfin_write16(CAN1_MB20_DATA0, val)
-#define bfin_read_CAN1_MB20_DATA1()            bfin_read16(CAN1_MB20_DATA1)
-#define bfin_write_CAN1_MB20_DATA1(val)                bfin_write16(CAN1_MB20_DATA1, val)
-#define bfin_read_CAN1_MB20_DATA2()            bfin_read16(CAN1_MB20_DATA2)
-#define bfin_write_CAN1_MB20_DATA2(val)                bfin_write16(CAN1_MB20_DATA2, val)
-#define bfin_read_CAN1_MB20_DATA3()            bfin_read16(CAN1_MB20_DATA3)
-#define bfin_write_CAN1_MB20_DATA3(val)                bfin_write16(CAN1_MB20_DATA3, val)
-#define bfin_read_CAN1_MB20_LENGTH()           bfin_read16(CAN1_MB20_LENGTH)
-#define bfin_write_CAN1_MB20_LENGTH(val)       bfin_write16(CAN1_MB20_LENGTH, val)
-#define bfin_read_CAN1_MB20_TIMESTAMP()                bfin_read16(CAN1_MB20_TIMESTAMP)
-#define bfin_write_CAN1_MB20_TIMESTAMP(val)    bfin_write16(CAN1_MB20_TIMESTAMP, val)
-#define bfin_read_CAN1_MB20_ID0()              bfin_read16(CAN1_MB20_ID0)
-#define bfin_write_CAN1_MB20_ID0(val)          bfin_write16(CAN1_MB20_ID0, val)
-#define bfin_read_CAN1_MB20_ID1()              bfin_read16(CAN1_MB20_ID1)
-#define bfin_write_CAN1_MB20_ID1(val)          bfin_write16(CAN1_MB20_ID1, val)
-#define bfin_read_CAN1_MB21_DATA0()            bfin_read16(CAN1_MB21_DATA0)
-#define bfin_write_CAN1_MB21_DATA0(val)                bfin_write16(CAN1_MB21_DATA0, val)
-#define bfin_read_CAN1_MB21_DATA1()            bfin_read16(CAN1_MB21_DATA1)
-#define bfin_write_CAN1_MB21_DATA1(val)                bfin_write16(CAN1_MB21_DATA1, val)
-#define bfin_read_CAN1_MB21_DATA2()            bfin_read16(CAN1_MB21_DATA2)
-#define bfin_write_CAN1_MB21_DATA2(val)                bfin_write16(CAN1_MB21_DATA2, val)
-#define bfin_read_CAN1_MB21_DATA3()            bfin_read16(CAN1_MB21_DATA3)
-#define bfin_write_CAN1_MB21_DATA3(val)                bfin_write16(CAN1_MB21_DATA3, val)
-#define bfin_read_CAN1_MB21_LENGTH()           bfin_read16(CAN1_MB21_LENGTH)
-#define bfin_write_CAN1_MB21_LENGTH(val)       bfin_write16(CAN1_MB21_LENGTH, val)
-#define bfin_read_CAN1_MB21_TIMESTAMP()                bfin_read16(CAN1_MB21_TIMESTAMP)
-#define bfin_write_CAN1_MB21_TIMESTAMP(val)    bfin_write16(CAN1_MB21_TIMESTAMP, val)
-#define bfin_read_CAN1_MB21_ID0()              bfin_read16(CAN1_MB21_ID0)
-#define bfin_write_CAN1_MB21_ID0(val)          bfin_write16(CAN1_MB21_ID0, val)
-#define bfin_read_CAN1_MB21_ID1()              bfin_read16(CAN1_MB21_ID1)
-#define bfin_write_CAN1_MB21_ID1(val)          bfin_write16(CAN1_MB21_ID1, val)
-#define bfin_read_CAN1_MB22_DATA0()            bfin_read16(CAN1_MB22_DATA0)
-#define bfin_write_CAN1_MB22_DATA0(val)                bfin_write16(CAN1_MB22_DATA0, val)
-#define bfin_read_CAN1_MB22_DATA1()            bfin_read16(CAN1_MB22_DATA1)
-#define bfin_write_CAN1_MB22_DATA1(val)                bfin_write16(CAN1_MB22_DATA1, val)
-#define bfin_read_CAN1_MB22_DATA2()            bfin_read16(CAN1_MB22_DATA2)
-#define bfin_write_CAN1_MB22_DATA2(val)                bfin_write16(CAN1_MB22_DATA2, val)
-#define bfin_read_CAN1_MB22_DATA3()            bfin_read16(CAN1_MB22_DATA3)
-#define bfin_write_CAN1_MB22_DATA3(val)                bfin_write16(CAN1_MB22_DATA3, val)
-#define bfin_read_CAN1_MB22_LENGTH()           bfin_read16(CAN1_MB22_LENGTH)
-#define bfin_write_CAN1_MB22_LENGTH(val)       bfin_write16(CAN1_MB22_LENGTH, val)
-#define bfin_read_CAN1_MB22_TIMESTAMP()                bfin_read16(CAN1_MB22_TIMESTAMP)
-#define bfin_write_CAN1_MB22_TIMESTAMP(val)    bfin_write16(CAN1_MB22_TIMESTAMP, val)
-#define bfin_read_CAN1_MB22_ID0()              bfin_read16(CAN1_MB22_ID0)
-#define bfin_write_CAN1_MB22_ID0(val)          bfin_write16(CAN1_MB22_ID0, val)
-#define bfin_read_CAN1_MB22_ID1()              bfin_read16(CAN1_MB22_ID1)
-#define bfin_write_CAN1_MB22_ID1(val)          bfin_write16(CAN1_MB22_ID1, val)
-#define bfin_read_CAN1_MB23_DATA0()            bfin_read16(CAN1_MB23_DATA0)
-#define bfin_write_CAN1_MB23_DATA0(val)                bfin_write16(CAN1_MB23_DATA0, val)
-#define bfin_read_CAN1_MB23_DATA1()            bfin_read16(CAN1_MB23_DATA1)
-#define bfin_write_CAN1_MB23_DATA1(val)                bfin_write16(CAN1_MB23_DATA1, val)
-#define bfin_read_CAN1_MB23_DATA2()            bfin_read16(CAN1_MB23_DATA2)
-#define bfin_write_CAN1_MB23_DATA2(val)                bfin_write16(CAN1_MB23_DATA2, val)
-#define bfin_read_CAN1_MB23_DATA3()            bfin_read16(CAN1_MB23_DATA3)
-#define bfin_write_CAN1_MB23_DATA3(val)                bfin_write16(CAN1_MB23_DATA3, val)
-#define bfin_read_CAN1_MB23_LENGTH()           bfin_read16(CAN1_MB23_LENGTH)
-#define bfin_write_CAN1_MB23_LENGTH(val)       bfin_write16(CAN1_MB23_LENGTH, val)
-#define bfin_read_CAN1_MB23_TIMESTAMP()                bfin_read16(CAN1_MB23_TIMESTAMP)
-#define bfin_write_CAN1_MB23_TIMESTAMP(val)    bfin_write16(CAN1_MB23_TIMESTAMP, val)
-#define bfin_read_CAN1_MB23_ID0()              bfin_read16(CAN1_MB23_ID0)
-#define bfin_write_CAN1_MB23_ID0(val)          bfin_write16(CAN1_MB23_ID0, val)
-#define bfin_read_CAN1_MB23_ID1()              bfin_read16(CAN1_MB23_ID1)
-#define bfin_write_CAN1_MB23_ID1(val)          bfin_write16(CAN1_MB23_ID1, val)
-#define bfin_read_CAN1_MB24_DATA0()            bfin_read16(CAN1_MB24_DATA0)
-#define bfin_write_CAN1_MB24_DATA0(val)                bfin_write16(CAN1_MB24_DATA0, val)
-#define bfin_read_CAN1_MB24_DATA1()            bfin_read16(CAN1_MB24_DATA1)
-#define bfin_write_CAN1_MB24_DATA1(val)                bfin_write16(CAN1_MB24_DATA1, val)
-#define bfin_read_CAN1_MB24_DATA2()            bfin_read16(CAN1_MB24_DATA2)
-#define bfin_write_CAN1_MB24_DATA2(val)                bfin_write16(CAN1_MB24_DATA2, val)
-#define bfin_read_CAN1_MB24_DATA3()            bfin_read16(CAN1_MB24_DATA3)
-#define bfin_write_CAN1_MB24_DATA3(val)                bfin_write16(CAN1_MB24_DATA3, val)
-#define bfin_read_CAN1_MB24_LENGTH()           bfin_read16(CAN1_MB24_LENGTH)
-#define bfin_write_CAN1_MB24_LENGTH(val)       bfin_write16(CAN1_MB24_LENGTH, val)
-#define bfin_read_CAN1_MB24_TIMESTAMP()                bfin_read16(CAN1_MB24_TIMESTAMP)
-#define bfin_write_CAN1_MB24_TIMESTAMP(val)    bfin_write16(CAN1_MB24_TIMESTAMP, val)
-#define bfin_read_CAN1_MB24_ID0()              bfin_read16(CAN1_MB24_ID0)
-#define bfin_write_CAN1_MB24_ID0(val)          bfin_write16(CAN1_MB24_ID0, val)
-#define bfin_read_CAN1_MB24_ID1()              bfin_read16(CAN1_MB24_ID1)
-#define bfin_write_CAN1_MB24_ID1(val)          bfin_write16(CAN1_MB24_ID1, val)
-#define bfin_read_CAN1_MB25_DATA0()            bfin_read16(CAN1_MB25_DATA0)
-#define bfin_write_CAN1_MB25_DATA0(val)                bfin_write16(CAN1_MB25_DATA0, val)
-#define bfin_read_CAN1_MB25_DATA1()            bfin_read16(CAN1_MB25_DATA1)
-#define bfin_write_CAN1_MB25_DATA1(val)                bfin_write16(CAN1_MB25_DATA1, val)
-#define bfin_read_CAN1_MB25_DATA2()            bfin_read16(CAN1_MB25_DATA2)
-#define bfin_write_CAN1_MB25_DATA2(val)                bfin_write16(CAN1_MB25_DATA2, val)
-#define bfin_read_CAN1_MB25_DATA3()            bfin_read16(CAN1_MB25_DATA3)
-#define bfin_write_CAN1_MB25_DATA3(val)                bfin_write16(CAN1_MB25_DATA3, val)
-#define bfin_read_CAN1_MB25_LENGTH()           bfin_read16(CAN1_MB25_LENGTH)
-#define bfin_write_CAN1_MB25_LENGTH(val)       bfin_write16(CAN1_MB25_LENGTH, val)
-#define bfin_read_CAN1_MB25_TIMESTAMP()                bfin_read16(CAN1_MB25_TIMESTAMP)
-#define bfin_write_CAN1_MB25_TIMESTAMP(val)    bfin_write16(CAN1_MB25_TIMESTAMP, val)
-#define bfin_read_CAN1_MB25_ID0()              bfin_read16(CAN1_MB25_ID0)
-#define bfin_write_CAN1_MB25_ID0(val)          bfin_write16(CAN1_MB25_ID0, val)
-#define bfin_read_CAN1_MB25_ID1()              bfin_read16(CAN1_MB25_ID1)
-#define bfin_write_CAN1_MB25_ID1(val)          bfin_write16(CAN1_MB25_ID1, val)
-#define bfin_read_CAN1_MB26_DATA0()            bfin_read16(CAN1_MB26_DATA0)
-#define bfin_write_CAN1_MB26_DATA0(val)                bfin_write16(CAN1_MB26_DATA0, val)
-#define bfin_read_CAN1_MB26_DATA1()            bfin_read16(CAN1_MB26_DATA1)
-#define bfin_write_CAN1_MB26_DATA1(val)                bfin_write16(CAN1_MB26_DATA1, val)
-#define bfin_read_CAN1_MB26_DATA2()            bfin_read16(CAN1_MB26_DATA2)
-#define bfin_write_CAN1_MB26_DATA2(val)                bfin_write16(CAN1_MB26_DATA2, val)
-#define bfin_read_CAN1_MB26_DATA3()            bfin_read16(CAN1_MB26_DATA3)
-#define bfin_write_CAN1_MB26_DATA3(val)                bfin_write16(CAN1_MB26_DATA3, val)
-#define bfin_read_CAN1_MB26_LENGTH()           bfin_read16(CAN1_MB26_LENGTH)
-#define bfin_write_CAN1_MB26_LENGTH(val)       bfin_write16(CAN1_MB26_LENGTH, val)
-#define bfin_read_CAN1_MB26_TIMESTAMP()                bfin_read16(CAN1_MB26_TIMESTAMP)
-#define bfin_write_CAN1_MB26_TIMESTAMP(val)    bfin_write16(CAN1_MB26_TIMESTAMP, val)
-#define bfin_read_CAN1_MB26_ID0()              bfin_read16(CAN1_MB26_ID0)
-#define bfin_write_CAN1_MB26_ID0(val)          bfin_write16(CAN1_MB26_ID0, val)
-#define bfin_read_CAN1_MB26_ID1()              bfin_read16(CAN1_MB26_ID1)
-#define bfin_write_CAN1_MB26_ID1(val)          bfin_write16(CAN1_MB26_ID1, val)
-#define bfin_read_CAN1_MB27_DATA0()            bfin_read16(CAN1_MB27_DATA0)
-#define bfin_write_CAN1_MB27_DATA0(val)                bfin_write16(CAN1_MB27_DATA0, val)
-#define bfin_read_CAN1_MB27_DATA1()            bfin_read16(CAN1_MB27_DATA1)
-#define bfin_write_CAN1_MB27_DATA1(val)                bfin_write16(CAN1_MB27_DATA1, val)
-#define bfin_read_CAN1_MB27_DATA2()            bfin_read16(CAN1_MB27_DATA2)
-#define bfin_write_CAN1_MB27_DATA2(val)                bfin_write16(CAN1_MB27_DATA2, val)
-#define bfin_read_CAN1_MB27_DATA3()            bfin_read16(CAN1_MB27_DATA3)
-#define bfin_write_CAN1_MB27_DATA3(val)                bfin_write16(CAN1_MB27_DATA3, val)
-#define bfin_read_CAN1_MB27_LENGTH()           bfin_read16(CAN1_MB27_LENGTH)
-#define bfin_write_CAN1_MB27_LENGTH(val)       bfin_write16(CAN1_MB27_LENGTH, val)
-#define bfin_read_CAN1_MB27_TIMESTAMP()                bfin_read16(CAN1_MB27_TIMESTAMP)
-#define bfin_write_CAN1_MB27_TIMESTAMP(val)    bfin_write16(CAN1_MB27_TIMESTAMP, val)
-#define bfin_read_CAN1_MB27_ID0()              bfin_read16(CAN1_MB27_ID0)
-#define bfin_write_CAN1_MB27_ID0(val)          bfin_write16(CAN1_MB27_ID0, val)
-#define bfin_read_CAN1_MB27_ID1()              bfin_read16(CAN1_MB27_ID1)
-#define bfin_write_CAN1_MB27_ID1(val)          bfin_write16(CAN1_MB27_ID1, val)
-#define bfin_read_CAN1_MB28_DATA0()            bfin_read16(CAN1_MB28_DATA0)
-#define bfin_write_CAN1_MB28_DATA0(val)                bfin_write16(CAN1_MB28_DATA0, val)
-#define bfin_read_CAN1_MB28_DATA1()            bfin_read16(CAN1_MB28_DATA1)
-#define bfin_write_CAN1_MB28_DATA1(val)                bfin_write16(CAN1_MB28_DATA1, val)
-#define bfin_read_CAN1_MB28_DATA2()            bfin_read16(CAN1_MB28_DATA2)
-#define bfin_write_CAN1_MB28_DATA2(val)                bfin_write16(CAN1_MB28_DATA2, val)
-#define bfin_read_CAN1_MB28_DATA3()            bfin_read16(CAN1_MB28_DATA3)
-#define bfin_write_CAN1_MB28_DATA3(val)                bfin_write16(CAN1_MB28_DATA3, val)
-#define bfin_read_CAN1_MB28_LENGTH()           bfin_read16(CAN1_MB28_LENGTH)
-#define bfin_write_CAN1_MB28_LENGTH(val)       bfin_write16(CAN1_MB28_LENGTH, val)
-#define bfin_read_CAN1_MB28_TIMESTAMP()                bfin_read16(CAN1_MB28_TIMESTAMP)
-#define bfin_write_CAN1_MB28_TIMESTAMP(val)    bfin_write16(CAN1_MB28_TIMESTAMP, val)
-#define bfin_read_CAN1_MB28_ID0()              bfin_read16(CAN1_MB28_ID0)
-#define bfin_write_CAN1_MB28_ID0(val)          bfin_write16(CAN1_MB28_ID0, val)
-#define bfin_read_CAN1_MB28_ID1()              bfin_read16(CAN1_MB28_ID1)
-#define bfin_write_CAN1_MB28_ID1(val)          bfin_write16(CAN1_MB28_ID1, val)
-#define bfin_read_CAN1_MB29_DATA0()            bfin_read16(CAN1_MB29_DATA0)
-#define bfin_write_CAN1_MB29_DATA0(val)                bfin_write16(CAN1_MB29_DATA0, val)
-#define bfin_read_CAN1_MB29_DATA1()            bfin_read16(CAN1_MB29_DATA1)
-#define bfin_write_CAN1_MB29_DATA1(val)                bfin_write16(CAN1_MB29_DATA1, val)
-#define bfin_read_CAN1_MB29_DATA2()            bfin_read16(CAN1_MB29_DATA2)
-#define bfin_write_CAN1_MB29_DATA2(val)                bfin_write16(CAN1_MB29_DATA2, val)
-#define bfin_read_CAN1_MB29_DATA3()            bfin_read16(CAN1_MB29_DATA3)
-#define bfin_write_CAN1_MB29_DATA3(val)                bfin_write16(CAN1_MB29_DATA3, val)
-#define bfin_read_CAN1_MB29_LENGTH()           bfin_read16(CAN1_MB29_LENGTH)
-#define bfin_write_CAN1_MB29_LENGTH(val)       bfin_write16(CAN1_MB29_LENGTH, val)
-#define bfin_read_CAN1_MB29_TIMESTAMP()                bfin_read16(CAN1_MB29_TIMESTAMP)
-#define bfin_write_CAN1_MB29_TIMESTAMP(val)    bfin_write16(CAN1_MB29_TIMESTAMP, val)
-#define bfin_read_CAN1_MB29_ID0()              bfin_read16(CAN1_MB29_ID0)
-#define bfin_write_CAN1_MB29_ID0(val)          bfin_write16(CAN1_MB29_ID0, val)
-#define bfin_read_CAN1_MB29_ID1()              bfin_read16(CAN1_MB29_ID1)
-#define bfin_write_CAN1_MB29_ID1(val)          bfin_write16(CAN1_MB29_ID1, val)
-#define bfin_read_CAN1_MB30_DATA0()            bfin_read16(CAN1_MB30_DATA0)
-#define bfin_write_CAN1_MB30_DATA0(val)                bfin_write16(CAN1_MB30_DATA0, val)
-#define bfin_read_CAN1_MB30_DATA1()            bfin_read16(CAN1_MB30_DATA1)
-#define bfin_write_CAN1_MB30_DATA1(val)                bfin_write16(CAN1_MB30_DATA1, val)
-#define bfin_read_CAN1_MB30_DATA2()            bfin_read16(CAN1_MB30_DATA2)
-#define bfin_write_CAN1_MB30_DATA2(val)                bfin_write16(CAN1_MB30_DATA2, val)
-#define bfin_read_CAN1_MB30_DATA3()            bfin_read16(CAN1_MB30_DATA3)
-#define bfin_write_CAN1_MB30_DATA3(val)                bfin_write16(CAN1_MB30_DATA3, val)
-#define bfin_read_CAN1_MB30_LENGTH()           bfin_read16(CAN1_MB30_LENGTH)
-#define bfin_write_CAN1_MB30_LENGTH(val)       bfin_write16(CAN1_MB30_LENGTH, val)
-#define bfin_read_CAN1_MB30_TIMESTAMP()                bfin_read16(CAN1_MB30_TIMESTAMP)
-#define bfin_write_CAN1_MB30_TIMESTAMP(val)    bfin_write16(CAN1_MB30_TIMESTAMP, val)
-#define bfin_read_CAN1_MB30_ID0()              bfin_read16(CAN1_MB30_ID0)
-#define bfin_write_CAN1_MB30_ID0(val)          bfin_write16(CAN1_MB30_ID0, val)
-#define bfin_read_CAN1_MB30_ID1()              bfin_read16(CAN1_MB30_ID1)
-#define bfin_write_CAN1_MB30_ID1(val)          bfin_write16(CAN1_MB30_ID1, val)
-#define bfin_read_CAN1_MB31_DATA0()            bfin_read16(CAN1_MB31_DATA0)
-#define bfin_write_CAN1_MB31_DATA0(val)                bfin_write16(CAN1_MB31_DATA0, val)
-#define bfin_read_CAN1_MB31_DATA1()            bfin_read16(CAN1_MB31_DATA1)
-#define bfin_write_CAN1_MB31_DATA1(val)                bfin_write16(CAN1_MB31_DATA1, val)
-#define bfin_read_CAN1_MB31_DATA2()            bfin_read16(CAN1_MB31_DATA2)
-#define bfin_write_CAN1_MB31_DATA2(val)                bfin_write16(CAN1_MB31_DATA2, val)
-#define bfin_read_CAN1_MB31_DATA3()            bfin_read16(CAN1_MB31_DATA3)
-#define bfin_write_CAN1_MB31_DATA3(val)                bfin_write16(CAN1_MB31_DATA3, val)
-#define bfin_read_CAN1_MB31_LENGTH()           bfin_read16(CAN1_MB31_LENGTH)
-#define bfin_write_CAN1_MB31_LENGTH(val)       bfin_write16(CAN1_MB31_LENGTH, val)
-#define bfin_read_CAN1_MB31_TIMESTAMP()                bfin_read16(CAN1_MB31_TIMESTAMP)
-#define bfin_write_CAN1_MB31_TIMESTAMP(val)    bfin_write16(CAN1_MB31_TIMESTAMP, val)
-#define bfin_read_CAN1_MB31_ID0()              bfin_read16(CAN1_MB31_ID0)
-#define bfin_write_CAN1_MB31_ID0(val)          bfin_write16(CAN1_MB31_ID0, val)
-#define bfin_read_CAN1_MB31_ID1()              bfin_read16(CAN1_MB31_ID1)
-#define bfin_write_CAN1_MB31_ID1(val)          bfin_write16(CAN1_MB31_ID1, val)
-
-/* ATAPI Registers */
-
-#define bfin_read_ATAPI_CONTROL()              bfin_read16(ATAPI_CONTROL)
-#define bfin_write_ATAPI_CONTROL(val)          bfin_write16(ATAPI_CONTROL, val)
-#define bfin_read_ATAPI_STATUS()               bfin_read16(ATAPI_STATUS)
-#define bfin_write_ATAPI_STATUS(val)           bfin_write16(ATAPI_STATUS, val)
-#define bfin_read_ATAPI_DEV_ADDR()             bfin_read16(ATAPI_DEV_ADDR)
-#define bfin_write_ATAPI_DEV_ADDR(val)         bfin_write16(ATAPI_DEV_ADDR, val)
-#define bfin_read_ATAPI_DEV_TXBUF()            bfin_read16(ATAPI_DEV_TXBUF)
-#define bfin_write_ATAPI_DEV_TXBUF(val)                bfin_write16(ATAPI_DEV_TXBUF, val)
-#define bfin_read_ATAPI_DEV_RXBUF()            bfin_read16(ATAPI_DEV_RXBUF)
-#define bfin_write_ATAPI_DEV_RXBUF(val)                bfin_write16(ATAPI_DEV_RXBUF, val)
-#define bfin_read_ATAPI_INT_MASK()             bfin_read16(ATAPI_INT_MASK)
-#define bfin_write_ATAPI_INT_MASK(val)         bfin_write16(ATAPI_INT_MASK, val)
-#define bfin_read_ATAPI_INT_STATUS()           bfin_read16(ATAPI_INT_STATUS)
-#define bfin_write_ATAPI_INT_STATUS(val)       bfin_write16(ATAPI_INT_STATUS, val)
-#define bfin_read_ATAPI_XFER_LEN()             bfin_read16(ATAPI_XFER_LEN)
-#define bfin_write_ATAPI_XFER_LEN(val)         bfin_write16(ATAPI_XFER_LEN, val)
-#define bfin_read_ATAPI_LINE_STATUS()          bfin_read16(ATAPI_LINE_STATUS)
-#define bfin_write_ATAPI_LINE_STATUS(val)      bfin_write16(ATAPI_LINE_STATUS, val)
-#define bfin_read_ATAPI_SM_STATE()             bfin_read16(ATAPI_SM_STATE)
-#define bfin_write_ATAPI_SM_STATE(val)         bfin_write16(ATAPI_SM_STATE, val)
-#define bfin_read_ATAPI_TERMINATE()            bfin_read16(ATAPI_TERMINATE)
-#define bfin_write_ATAPI_TERMINATE(val)                bfin_write16(ATAPI_TERMINATE, val)
-#define bfin_read_ATAPI_PIO_TFRCNT()           bfin_read16(ATAPI_PIO_TFRCNT)
-#define bfin_write_ATAPI_PIO_TFRCNT(val)       bfin_write16(ATAPI_PIO_TFRCNT, val)
-#define bfin_read_ATAPI_DMA_TFRCNT()           bfin_read16(ATAPI_DMA_TFRCNT)
-#define bfin_write_ATAPI_DMA_TFRCNT(val)       bfin_write16(ATAPI_DMA_TFRCNT, val)
-#define bfin_read_ATAPI_UMAIN_TFRCNT()         bfin_read16(ATAPI_UMAIN_TFRCNT)
-#define bfin_write_ATAPI_UMAIN_TFRCNT(val)     bfin_write16(ATAPI_UMAIN_TFRCNT, val)
-#define bfin_read_ATAPI_UDMAOUT_TFRCNT()       bfin_read16(ATAPI_UDMAOUT_TFRCNT)
-#define bfin_write_ATAPI_UDMAOUT_TFRCNT(val)   bfin_write16(ATAPI_UDMAOUT_TFRCNT, val)
-#define bfin_read_ATAPI_REG_TIM_0()            bfin_read16(ATAPI_REG_TIM_0)
-#define bfin_write_ATAPI_REG_TIM_0(val)                bfin_write16(ATAPI_REG_TIM_0, val)
-#define bfin_read_ATAPI_PIO_TIM_0()            bfin_read16(ATAPI_PIO_TIM_0)
-#define bfin_write_ATAPI_PIO_TIM_0(val)                bfin_write16(ATAPI_PIO_TIM_0, val)
-#define bfin_read_ATAPI_PIO_TIM_1()            bfin_read16(ATAPI_PIO_TIM_1)
-#define bfin_write_ATAPI_PIO_TIM_1(val)                bfin_write16(ATAPI_PIO_TIM_1, val)
-#define bfin_read_ATAPI_MULTI_TIM_0()          bfin_read16(ATAPI_MULTI_TIM_0)
-#define bfin_write_ATAPI_MULTI_TIM_0(val)      bfin_write16(ATAPI_MULTI_TIM_0, val)
-#define bfin_read_ATAPI_MULTI_TIM_1()          bfin_read16(ATAPI_MULTI_TIM_1)
-#define bfin_write_ATAPI_MULTI_TIM_1(val)      bfin_write16(ATAPI_MULTI_TIM_1, val)
-#define bfin_read_ATAPI_MULTI_TIM_2()          bfin_read16(ATAPI_MULTI_TIM_2)
-#define bfin_write_ATAPI_MULTI_TIM_2(val)      bfin_write16(ATAPI_MULTI_TIM_2, val)
-#define bfin_read_ATAPI_ULTRA_TIM_0()          bfin_read16(ATAPI_ULTRA_TIM_0)
-#define bfin_write_ATAPI_ULTRA_TIM_0(val)      bfin_write16(ATAPI_ULTRA_TIM_0, val)
-#define bfin_read_ATAPI_ULTRA_TIM_1()          bfin_read16(ATAPI_ULTRA_TIM_1)
-#define bfin_write_ATAPI_ULTRA_TIM_1(val)      bfin_write16(ATAPI_ULTRA_TIM_1, val)
-#define bfin_read_ATAPI_ULTRA_TIM_2()          bfin_read16(ATAPI_ULTRA_TIM_2)
-#define bfin_write_ATAPI_ULTRA_TIM_2(val)      bfin_write16(ATAPI_ULTRA_TIM_2, val)
-#define bfin_read_ATAPI_ULTRA_TIM_3()          bfin_read16(ATAPI_ULTRA_TIM_3)
-#define bfin_write_ATAPI_ULTRA_TIM_3(val)      bfin_write16(ATAPI_ULTRA_TIM_3, val)
-
-/* SDH Registers */
-
-#define bfin_read_SDH_PWR_CTL()                bfin_read16(SDH_PWR_CTL)
-#define bfin_write_SDH_PWR_CTL(val)    bfin_write16(SDH_PWR_CTL, val)
-#define bfin_read_SDH_CLK_CTL()                bfin_read16(SDH_CLK_CTL)
-#define bfin_write_SDH_CLK_CTL(val)    bfin_write16(SDH_CLK_CTL, val)
-#define bfin_read_SDH_ARGUMENT()       bfin_read32(SDH_ARGUMENT)
-#define bfin_write_SDH_ARGUMENT(val)   bfin_write32(SDH_ARGUMENT, val)
-#define bfin_read_SDH_COMMAND()                bfin_read16(SDH_COMMAND)
-#define bfin_write_SDH_COMMAND(val)    bfin_write16(SDH_COMMAND, val)
-#define bfin_read_SDH_RESP_CMD()       bfin_read16(SDH_RESP_CMD)
-#define bfin_write_SDH_RESP_CMD(val)   bfin_write16(SDH_RESP_CMD, val)
-#define bfin_read_SDH_RESPONSE0()      bfin_read32(SDH_RESPONSE0)
-#define bfin_write_SDH_RESPONSE0(val)  bfin_write32(SDH_RESPONSE0, val)
-#define bfin_read_SDH_RESPONSE1()      bfin_read32(SDH_RESPONSE1)
-#define bfin_write_SDH_RESPONSE1(val)  bfin_write32(SDH_RESPONSE1, val)
-#define bfin_read_SDH_RESPONSE2()      bfin_read32(SDH_RESPONSE2)
-#define bfin_write_SDH_RESPONSE2(val)  bfin_write32(SDH_RESPONSE2, val)
-#define bfin_read_SDH_RESPONSE3()      bfin_read32(SDH_RESPONSE3)
-#define bfin_write_SDH_RESPONSE3(val)  bfin_write32(SDH_RESPONSE3, val)
-#define bfin_read_SDH_DATA_TIMER()     bfin_read32(SDH_DATA_TIMER)
-#define bfin_write_SDH_DATA_TIMER(val) bfin_write32(SDH_DATA_TIMER, val)
-#define bfin_read_SDH_DATA_LGTH()      bfin_read16(SDH_DATA_LGTH)
-#define bfin_write_SDH_DATA_LGTH(val)  bfin_write16(SDH_DATA_LGTH, val)
-#define bfin_read_SDH_DATA_CTL()       bfin_read16(SDH_DATA_CTL)
-#define bfin_write_SDH_DATA_CTL(val)   bfin_write16(SDH_DATA_CTL, val)
-#define bfin_read_SDH_DATA_CNT()       bfin_read16(SDH_DATA_CNT)
-#define bfin_write_SDH_DATA_CNT(val)   bfin_write16(SDH_DATA_CNT, val)
-#define bfin_read_SDH_STATUS()         bfin_read32(SDH_STATUS)
-#define bfin_write_SDH_STATUS(val)     bfin_write32(SDH_STATUS, val)
-#define bfin_read_SDH_STATUS_CLR()     bfin_read16(SDH_STATUS_CLR)
-#define bfin_write_SDH_STATUS_CLR(val) bfin_write16(SDH_STATUS_CLR, val)
-#define bfin_read_SDH_MASK0()          bfin_read32(SDH_MASK0)
-#define bfin_write_SDH_MASK0(val)      bfin_write32(SDH_MASK0, val)
-#define bfin_read_SDH_MASK1()          bfin_read32(SDH_MASK1)
-#define bfin_write_SDH_MASK1(val)      bfin_write32(SDH_MASK1, val)
-#define bfin_read_SDH_FIFO_CNT()       bfin_read16(SDH_FIFO_CNT)
-#define bfin_write_SDH_FIFO_CNT(val)   bfin_write16(SDH_FIFO_CNT, val)
-#define bfin_read_SDH_FIFO()           bfin_read32(SDH_FIFO)
-#define bfin_write_SDH_FIFO(val)       bfin_write32(SDH_FIFO, val)
-#define bfin_read_SDH_E_STATUS()       bfin_read16(SDH_E_STATUS)
-#define bfin_write_SDH_E_STATUS(val)   bfin_write16(SDH_E_STATUS, val)
-#define bfin_read_SDH_E_MASK()         bfin_read16(SDH_E_MASK)
-#define bfin_write_SDH_E_MASK(val)     bfin_write16(SDH_E_MASK, val)
-#define bfin_read_SDH_CFG()            bfin_read16(SDH_CFG)
-#define bfin_write_SDH_CFG(val)                bfin_write16(SDH_CFG, val)
-#define bfin_read_SDH_RD_WAIT_EN()     bfin_read16(SDH_RD_WAIT_EN)
-#define bfin_write_SDH_RD_WAIT_EN(val) bfin_write16(SDH_RD_WAIT_EN, val)
-#define bfin_read_SDH_PID0()           bfin_read16(SDH_PID0)
-#define bfin_write_SDH_PID0(val)       bfin_write16(SDH_PID0, val)
-#define bfin_read_SDH_PID1()           bfin_read16(SDH_PID1)
-#define bfin_write_SDH_PID1(val)       bfin_write16(SDH_PID1, val)
-#define bfin_read_SDH_PID2()           bfin_read16(SDH_PID2)
-#define bfin_write_SDH_PID2(val)       bfin_write16(SDH_PID2, val)
-#define bfin_read_SDH_PID3()           bfin_read16(SDH_PID3)
-#define bfin_write_SDH_PID3(val)       bfin_write16(SDH_PID3, val)
-#define bfin_read_SDH_PID4()           bfin_read16(SDH_PID4)
-#define bfin_write_SDH_PID4(val)       bfin_write16(SDH_PID4, val)
-#define bfin_read_SDH_PID5()           bfin_read16(SDH_PID5)
-#define bfin_write_SDH_PID5(val)       bfin_write16(SDH_PID5, val)
-#define bfin_read_SDH_PID6()           bfin_read16(SDH_PID6)
-#define bfin_write_SDH_PID6(val)       bfin_write16(SDH_PID6, val)
-#define bfin_read_SDH_PID7()           bfin_read16(SDH_PID7)
-#define bfin_write_SDH_PID7(val)       bfin_write16(SDH_PID7, val)
-
-/* HOST Port Registers */
-
-#define bfin_read_HOST_CONTROL()       bfin_read16(HOST_CONTROL)
-#define bfin_write_HOST_CONTROL(val)   bfin_write16(HOST_CONTROL, val)
-#define bfin_read_HOST_STATUS()                bfin_read16(HOST_STATUS)
-#define bfin_write_HOST_STATUS(val)    bfin_write16(HOST_STATUS, val)
-#define bfin_read_HOST_TIMEOUT()       bfin_read16(HOST_TIMEOUT)
-#define bfin_write_HOST_TIMEOUT(val)   bfin_write16(HOST_TIMEOUT, val)
-
-/* USB Control Registers */
-
-#define bfin_read_USB_FADDR()          bfin_read16(USB_FADDR)
-#define bfin_write_USB_FADDR(val)      bfin_write16(USB_FADDR, val)
-#define bfin_read_USB_POWER()          bfin_read16(USB_POWER)
-#define bfin_write_USB_POWER(val)      bfin_write16(USB_POWER, val)
-#define bfin_read_USB_INTRTX()         bfin_read16(USB_INTRTX)
-#define bfin_write_USB_INTRTX(val)     bfin_write16(USB_INTRTX, val)
-#define bfin_read_USB_INTRRX()         bfin_read16(USB_INTRRX)
-#define bfin_write_USB_INTRRX(val)     bfin_write16(USB_INTRRX, val)
-#define bfin_read_USB_INTRTXE()                bfin_read16(USB_INTRTXE)
-#define bfin_write_USB_INTRTXE(val)    bfin_write16(USB_INTRTXE, val)
-#define bfin_read_USB_INTRRXE()                bfin_read16(USB_INTRRXE)
-#define bfin_write_USB_INTRRXE(val)    bfin_write16(USB_INTRRXE, val)
-#define bfin_read_USB_INTRUSB()                bfin_read16(USB_INTRUSB)
-#define bfin_write_USB_INTRUSB(val)    bfin_write16(USB_INTRUSB, val)
-#define bfin_read_USB_INTRUSBE()       bfin_read16(USB_INTRUSBE)
-#define bfin_write_USB_INTRUSBE(val)   bfin_write16(USB_INTRUSBE, val)
-#define bfin_read_USB_FRAME()          bfin_read16(USB_FRAME)
-#define bfin_write_USB_FRAME(val)      bfin_write16(USB_FRAME, val)
-#define bfin_read_USB_INDEX()          bfin_read16(USB_INDEX)
-#define bfin_write_USB_INDEX(val)      bfin_write16(USB_INDEX, val)
-#define bfin_read_USB_TESTMODE()       bfin_read16(USB_TESTMODE)
-#define bfin_write_USB_TESTMODE(val)   bfin_write16(USB_TESTMODE, val)
-#define bfin_read_USB_GLOBINTR()       bfin_read16(USB_GLOBINTR)
-#define bfin_write_USB_GLOBINTR(val)   bfin_write16(USB_GLOBINTR, val)
-#define bfin_read_USB_GLOBAL_CTL()     bfin_read16(USB_GLOBAL_CTL)
-#define bfin_write_USB_GLOBAL_CTL(val) bfin_write16(USB_GLOBAL_CTL, val)
-
-/* USB Packet Control Registers */
-
-#define bfin_read_USB_TX_MAX_PACKET()          bfin_read16(USB_TX_MAX_PACKET)
-#define bfin_write_USB_TX_MAX_PACKET(val)      bfin_write16(USB_TX_MAX_PACKET, val)
-#define bfin_read_USB_CSR0()                   bfin_read16(USB_CSR0)
-#define bfin_write_USB_CSR0(val)               bfin_write16(USB_CSR0, val)
-#define bfin_read_USB_TXCSR()                  bfin_read16(USB_TXCSR)
-#define bfin_write_USB_TXCSR(val)              bfin_write16(USB_TXCSR, val)
-#define bfin_read_USB_RX_MAX_PACKET()          bfin_read16(USB_RX_MAX_PACKET)
-#define bfin_write_USB_RX_MAX_PACKET(val)      bfin_write16(USB_RX_MAX_PACKET, val)
-#define bfin_read_USB_RXCSR()                  bfin_read16(USB_RXCSR)
-#define bfin_write_USB_RXCSR(val)              bfin_write16(USB_RXCSR, val)
-#define bfin_read_USB_COUNT0()                 bfin_read16(USB_COUNT0)
-#define bfin_write_USB_COUNT0(val)             bfin_write16(USB_COUNT0, val)
-#define bfin_read_USB_RXCOUNT()                        bfin_read16(USB_RXCOUNT)
-#define bfin_write_USB_RXCOUNT(val)            bfin_write16(USB_RXCOUNT, val)
-#define bfin_read_USB_TXTYPE()                 bfin_read16(USB_TXTYPE)
-#define bfin_write_USB_TXTYPE(val)             bfin_write16(USB_TXTYPE, val)
-#define bfin_read_USB_NAKLIMIT0()              bfin_read16(USB_NAKLIMIT0)
-#define bfin_write_USB_NAKLIMIT0(val)          bfin_write16(USB_NAKLIMIT0, val)
-#define bfin_read_USB_TXINTERVAL()             bfin_read16(USB_TXINTERVAL)
-#define bfin_write_USB_TXINTERVAL(val)         bfin_write16(USB_TXINTERVAL, val)
-#define bfin_read_USB_RXTYPE()                 bfin_read16(USB_RXTYPE)
-#define bfin_write_USB_RXTYPE(val)             bfin_write16(USB_RXTYPE, val)
-#define bfin_read_USB_RXINTERVAL()             bfin_read16(USB_RXINTERVAL)
-#define bfin_write_USB_RXINTERVAL(val)         bfin_write16(USB_RXINTERVAL, val)
-#define bfin_read_USB_TXCOUNT()                        bfin_read16(USB_TXCOUNT)
-#define bfin_write_USB_TXCOUNT(val)            bfin_write16(USB_TXCOUNT, val)
-
-/* USB Endbfin_read_()oint FIFO Registers */
-
-#define bfin_read_USB_EP0_FIFO()               bfin_read16(USB_EP0_FIFO)
-#define bfin_write_USB_EP0_FIFO(val)           bfin_write16(USB_EP0_FIFO, val)
-#define bfin_read_USB_EP1_FIFO()               bfin_read16(USB_EP1_FIFO)
-#define bfin_write_USB_EP1_FIFO(val)           bfin_write16(USB_EP1_FIFO, val)
-#define bfin_read_USB_EP2_FIFO()               bfin_read16(USB_EP2_FIFO)
-#define bfin_write_USB_EP2_FIFO(val)           bfin_write16(USB_EP2_FIFO, val)
-#define bfin_read_USB_EP3_FIFO()               bfin_read16(USB_EP3_FIFO)
-#define bfin_write_USB_EP3_FIFO(val)           bfin_write16(USB_EP3_FIFO, val)
-#define bfin_read_USB_EP4_FIFO()               bfin_read16(USB_EP4_FIFO)
-#define bfin_write_USB_EP4_FIFO(val)           bfin_write16(USB_EP4_FIFO, val)
-#define bfin_read_USB_EP5_FIFO()               bfin_read16(USB_EP5_FIFO)
-#define bfin_write_USB_EP5_FIFO(val)           bfin_write16(USB_EP5_FIFO, val)
-#define bfin_read_USB_EP6_FIFO()               bfin_read16(USB_EP6_FIFO)
-#define bfin_write_USB_EP6_FIFO(val)           bfin_write16(USB_EP6_FIFO, val)
-#define bfin_read_USB_EP7_FIFO()               bfin_read16(USB_EP7_FIFO)
-#define bfin_write_USB_EP7_FIFO(val)           bfin_write16(USB_EP7_FIFO, val)
-
-/* USB OTG Control Registers */
-
-#define bfin_read_USB_OTG_DEV_CTL()            bfin_read16(USB_OTG_DEV_CTL)
-#define bfin_write_USB_OTG_DEV_CTL(val)                bfin_write16(USB_OTG_DEV_CTL, val)
-#define bfin_read_USB_OTG_VBUS_IRQ()           bfin_read16(USB_OTG_VBUS_IRQ)
-#define bfin_write_USB_OTG_VBUS_IRQ(val)       bfin_write16(USB_OTG_VBUS_IRQ, val)
-#define bfin_read_USB_OTG_VBUS_MASK()          bfin_read16(USB_OTG_VBUS_MASK)
-#define bfin_write_USB_OTG_VBUS_MASK(val)      bfin_write16(USB_OTG_VBUS_MASK, val)
-
-/* USB Phy Control Registers */
-
-#define bfin_read_USB_LINKINFO()               bfin_read16(USB_LINKINFO)
-#define bfin_write_USB_LINKINFO(val)           bfin_write16(USB_LINKINFO, val)
-#define bfin_read_USB_VPLEN()                  bfin_read16(USB_VPLEN)
-#define bfin_write_USB_VPLEN(val)              bfin_write16(USB_VPLEN, val)
-#define bfin_read_USB_HS_EOF1()                        bfin_read16(USB_HS_EOF1)
-#define bfin_write_USB_HS_EOF1(val)            bfin_write16(USB_HS_EOF1, val)
-#define bfin_read_USB_FS_EOF1()                        bfin_read16(USB_FS_EOF1)
-#define bfin_write_USB_FS_EOF1(val)            bfin_write16(USB_FS_EOF1, val)
-#define bfin_read_USB_LS_EOF1()                        bfin_read16(USB_LS_EOF1)
-#define bfin_write_USB_LS_EOF1(val)            bfin_write16(USB_LS_EOF1, val)
-
-/* (APHY_CNTRL is for ADI usage only) */
-
-#define bfin_read_USB_APHY_CNTRL()             bfin_read16(USB_APHY_CNTRL)
-#define bfin_write_USB_APHY_CNTRL(val)         bfin_write16(USB_APHY_CNTRL, val)
-
-/* (APHY_CALIB is for ADI usage only) */
-
-#define bfin_read_USB_APHY_CALIB()             bfin_read16(USB_APHY_CALIB)
-#define bfin_write_USB_APHY_CALIB(val)         bfin_write16(USB_APHY_CALIB, val)
-#define bfin_read_USB_APHY_CNTRL2()            bfin_read16(USB_APHY_CNTRL2)
-#define bfin_write_USB_APHY_CNTRL2(val)                bfin_write16(USB_APHY_CNTRL2, val)
-
-/* (PHY_TEST is for ADI usage only) */
-
-#define bfin_read_USB_PHY_TEST()               bfin_read16(USB_PHY_TEST)
-#define bfin_write_USB_PHY_TEST(val)           bfin_write16(USB_PHY_TEST, val)
-#define bfin_read_USB_PLLOSC_CTRL()            bfin_read16(USB_PLLOSC_CTRL)
-#define bfin_write_USB_PLLOSC_CTRL(val)                bfin_write16(USB_PLLOSC_CTRL, val)
-#define bfin_read_USB_SRP_CLKDIV()             bfin_read16(USB_SRP_CLKDIV)
-#define bfin_write_USB_SRP_CLKDIV(val)         bfin_write16(USB_SRP_CLKDIV, val)
-
-/* USB Endbfin_read_()oint 0 Control Registers */
-
-#define bfin_read_USB_EP_NI0_TXMAXP()          bfin_read16(USB_EP_NI0_TXMAXP)
-#define bfin_write_USB_EP_NI0_TXMAXP(val)      bfin_write16(USB_EP_NI0_TXMAXP, val)
-#define bfin_read_USB_EP_NI0_TXCSR()           bfin_read16(USB_EP_NI0_TXCSR)
-#define bfin_write_USB_EP_NI0_TXCSR(val)       bfin_write16(USB_EP_NI0_TXCSR, val)
-#define bfin_read_USB_EP_NI0_RXMAXP()          bfin_read16(USB_EP_NI0_RXMAXP)
-#define bfin_write_USB_EP_NI0_RXMAXP(val)      bfin_write16(USB_EP_NI0_RXMAXP, val)
-#define bfin_read_USB_EP_NI0_RXCSR()           bfin_read16(USB_EP_NI0_RXCSR)
-#define bfin_write_USB_EP_NI0_RXCSR(val)       bfin_write16(USB_EP_NI0_RXCSR, val)
-#define bfin_read_USB_EP_NI0_RXCOUNT()         bfin_read16(USB_EP_NI0_RXCOUNT)
-#define bfin_write_USB_EP_NI0_RXCOUNT(val)     bfin_write16(USB_EP_NI0_RXCOUNT, val)
-#define bfin_read_USB_EP_NI0_TXTYPE()          bfin_read16(USB_EP_NI0_TXTYPE)
-#define bfin_write_USB_EP_NI0_TXTYPE(val)      bfin_write16(USB_EP_NI0_TXTYPE, val)
-#define bfin_read_USB_EP_NI0_TXINTERVAL()      bfin_read16(USB_EP_NI0_TXINTERVAL)
-#define bfin_write_USB_EP_NI0_TXINTERVAL(val)  bfin_write16(USB_EP_NI0_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI0_RXTYPE()          bfin_read16(USB_EP_NI0_RXTYPE)
-#define bfin_write_USB_EP_NI0_RXTYPE(val)      bfin_write16(USB_EP_NI0_RXTYPE, val)
-#define bfin_read_USB_EP_NI0_RXINTERVAL()      bfin_read16(USB_EP_NI0_RXINTERVAL)
-#define bfin_write_USB_EP_NI0_RXINTERVAL(val)  bfin_write16(USB_EP_NI0_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 1 Control Registers */
-
-#define bfin_read_USB_EP_NI0_TXCOUNT()         bfin_read16(USB_EP_NI0_TXCOUNT)
-#define bfin_write_USB_EP_NI0_TXCOUNT(val)     bfin_write16(USB_EP_NI0_TXCOUNT, val)
-#define bfin_read_USB_EP_NI1_TXMAXP()          bfin_read16(USB_EP_NI1_TXMAXP)
-#define bfin_write_USB_EP_NI1_TXMAXP(val)      bfin_write16(USB_EP_NI1_TXMAXP, val)
-#define bfin_read_USB_EP_NI1_TXCSR()           bfin_read16(USB_EP_NI1_TXCSR)
-#define bfin_write_USB_EP_NI1_TXCSR(val)       bfin_write16(USB_EP_NI1_TXCSR, val)
-#define bfin_read_USB_EP_NI1_RXMAXP()          bfin_read16(USB_EP_NI1_RXMAXP)
-#define bfin_write_USB_EP_NI1_RXMAXP(val)      bfin_write16(USB_EP_NI1_RXMAXP, val)
-#define bfin_read_USB_EP_NI1_RXCSR()           bfin_read16(USB_EP_NI1_RXCSR)
-#define bfin_write_USB_EP_NI1_RXCSR(val)       bfin_write16(USB_EP_NI1_RXCSR, val)
-#define bfin_read_USB_EP_NI1_RXCOUNT()         bfin_read16(USB_EP_NI1_RXCOUNT)
-#define bfin_write_USB_EP_NI1_RXCOUNT(val)     bfin_write16(USB_EP_NI1_RXCOUNT, val)
-#define bfin_read_USB_EP_NI1_TXTYPE()          bfin_read16(USB_EP_NI1_TXTYPE)
-#define bfin_write_USB_EP_NI1_TXTYPE(val)      bfin_write16(USB_EP_NI1_TXTYPE, val)
-#define bfin_read_USB_EP_NI1_TXINTERVAL()      bfin_read16(USB_EP_NI1_TXINTERVAL)
-#define bfin_write_USB_EP_NI1_TXINTERVAL(val)  bfin_write16(USB_EP_NI1_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI1_RXTYPE()          bfin_read16(USB_EP_NI1_RXTYPE)
-#define bfin_write_USB_EP_NI1_RXTYPE(val)      bfin_write16(USB_EP_NI1_RXTYPE, val)
-#define bfin_read_USB_EP_NI1_RXINTERVAL()      bfin_read16(USB_EP_NI1_RXINTERVAL)
-#define bfin_write_USB_EP_NI1_RXINTERVAL(val)  bfin_write16(USB_EP_NI1_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 2 Control Registers */
-
-#define bfin_read_USB_EP_NI1_TXCOUNT()         bfin_read16(USB_EP_NI1_TXCOUNT)
-#define bfin_write_USB_EP_NI1_TXCOUNT(val)     bfin_write16(USB_EP_NI1_TXCOUNT, val)
-#define bfin_read_USB_EP_NI2_TXMAXP()          bfin_read16(USB_EP_NI2_TXMAXP)
-#define bfin_write_USB_EP_NI2_TXMAXP(val)      bfin_write16(USB_EP_NI2_TXMAXP, val)
-#define bfin_read_USB_EP_NI2_TXCSR()           bfin_read16(USB_EP_NI2_TXCSR)
-#define bfin_write_USB_EP_NI2_TXCSR(val)       bfin_write16(USB_EP_NI2_TXCSR, val)
-#define bfin_read_USB_EP_NI2_RXMAXP()          bfin_read16(USB_EP_NI2_RXMAXP)
-#define bfin_write_USB_EP_NI2_RXMAXP(val)      bfin_write16(USB_EP_NI2_RXMAXP, val)
-#define bfin_read_USB_EP_NI2_RXCSR()           bfin_read16(USB_EP_NI2_RXCSR)
-#define bfin_write_USB_EP_NI2_RXCSR(val)       bfin_write16(USB_EP_NI2_RXCSR, val)
-#define bfin_read_USB_EP_NI2_RXCOUNT()         bfin_read16(USB_EP_NI2_RXCOUNT)
-#define bfin_write_USB_EP_NI2_RXCOUNT(val)     bfin_write16(USB_EP_NI2_RXCOUNT, val)
-#define bfin_read_USB_EP_NI2_TXTYPE()          bfin_read16(USB_EP_NI2_TXTYPE)
-#define bfin_write_USB_EP_NI2_TXTYPE(val)      bfin_write16(USB_EP_NI2_TXTYPE, val)
-#define bfin_read_USB_EP_NI2_TXINTERVAL()      bfin_read16(USB_EP_NI2_TXINTERVAL)
-#define bfin_write_USB_EP_NI2_TXINTERVAL(val)  bfin_write16(USB_EP_NI2_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI2_RXTYPE()          bfin_read16(USB_EP_NI2_RXTYPE)
-#define bfin_write_USB_EP_NI2_RXTYPE(val)      bfin_write16(USB_EP_NI2_RXTYPE, val)
-#define bfin_read_USB_EP_NI2_RXINTERVAL()      bfin_read16(USB_EP_NI2_RXINTERVAL)
-#define bfin_write_USB_EP_NI2_RXINTERVAL(val)  bfin_write16(USB_EP_NI2_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 3 Control Registers */
-
-#define bfin_read_USB_EP_NI2_TXCOUNT()         bfin_read16(USB_EP_NI2_TXCOUNT)
-#define bfin_write_USB_EP_NI2_TXCOUNT(val)     bfin_write16(USB_EP_NI2_TXCOUNT, val)
-#define bfin_read_USB_EP_NI3_TXMAXP()          bfin_read16(USB_EP_NI3_TXMAXP)
-#define bfin_write_USB_EP_NI3_TXMAXP(val)      bfin_write16(USB_EP_NI3_TXMAXP, val)
-#define bfin_read_USB_EP_NI3_TXCSR()           bfin_read16(USB_EP_NI3_TXCSR)
-#define bfin_write_USB_EP_NI3_TXCSR(val)       bfin_write16(USB_EP_NI3_TXCSR, val)
-#define bfin_read_USB_EP_NI3_RXMAXP()          bfin_read16(USB_EP_NI3_RXMAXP)
-#define bfin_write_USB_EP_NI3_RXMAXP(val)      bfin_write16(USB_EP_NI3_RXMAXP, val)
-#define bfin_read_USB_EP_NI3_RXCSR()           bfin_read16(USB_EP_NI3_RXCSR)
-#define bfin_write_USB_EP_NI3_RXCSR(val)       bfin_write16(USB_EP_NI3_RXCSR, val)
-#define bfin_read_USB_EP_NI3_RXCOUNT()         bfin_read16(USB_EP_NI3_RXCOUNT)
-#define bfin_write_USB_EP_NI3_RXCOUNT(val)     bfin_write16(USB_EP_NI3_RXCOUNT, val)
-#define bfin_read_USB_EP_NI3_TXTYPE()          bfin_read16(USB_EP_NI3_TXTYPE)
-#define bfin_write_USB_EP_NI3_TXTYPE(val)      bfin_write16(USB_EP_NI3_TXTYPE, val)
-#define bfin_read_USB_EP_NI3_TXINTERVAL()      bfin_read16(USB_EP_NI3_TXINTERVAL)
-#define bfin_write_USB_EP_NI3_TXINTERVAL(val)  bfin_write16(USB_EP_NI3_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI3_RXTYPE()          bfin_read16(USB_EP_NI3_RXTYPE)
-#define bfin_write_USB_EP_NI3_RXTYPE(val)      bfin_write16(USB_EP_NI3_RXTYPE, val)
-#define bfin_read_USB_EP_NI3_RXINTERVAL()      bfin_read16(USB_EP_NI3_RXINTERVAL)
-#define bfin_write_USB_EP_NI3_RXINTERVAL(val)  bfin_write16(USB_EP_NI3_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 4 Control Registers */
-
-#define bfin_read_USB_EP_NI3_TXCOUNT()         bfin_read16(USB_EP_NI3_TXCOUNT)
-#define bfin_write_USB_EP_NI3_TXCOUNT(val)     bfin_write16(USB_EP_NI3_TXCOUNT, val)
-#define bfin_read_USB_EP_NI4_TXMAXP()          bfin_read16(USB_EP_NI4_TXMAXP)
-#define bfin_write_USB_EP_NI4_TXMAXP(val)      bfin_write16(USB_EP_NI4_TXMAXP, val)
-#define bfin_read_USB_EP_NI4_TXCSR()           bfin_read16(USB_EP_NI4_TXCSR)
-#define bfin_write_USB_EP_NI4_TXCSR(val)       bfin_write16(USB_EP_NI4_TXCSR, val)
-#define bfin_read_USB_EP_NI4_RXMAXP()          bfin_read16(USB_EP_NI4_RXMAXP)
-#define bfin_write_USB_EP_NI4_RXMAXP(val)      bfin_write16(USB_EP_NI4_RXMAXP, val)
-#define bfin_read_USB_EP_NI4_RXCSR()           bfin_read16(USB_EP_NI4_RXCSR)
-#define bfin_write_USB_EP_NI4_RXCSR(val)       bfin_write16(USB_EP_NI4_RXCSR, val)
-#define bfin_read_USB_EP_NI4_RXCOUNT()         bfin_read16(USB_EP_NI4_RXCOUNT)
-#define bfin_write_USB_EP_NI4_RXCOUNT(val)     bfin_write16(USB_EP_NI4_RXCOUNT, val)
-#define bfin_read_USB_EP_NI4_TXTYPE()          bfin_read16(USB_EP_NI4_TXTYPE)
-#define bfin_write_USB_EP_NI4_TXTYPE(val)      bfin_write16(USB_EP_NI4_TXTYPE, val)
-#define bfin_read_USB_EP_NI4_TXINTERVAL()      bfin_read16(USB_EP_NI4_TXINTERVAL)
-#define bfin_write_USB_EP_NI4_TXINTERVAL(val)  bfin_write16(USB_EP_NI4_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI4_RXTYPE()          bfin_read16(USB_EP_NI4_RXTYPE)
-#define bfin_write_USB_EP_NI4_RXTYPE(val)      bfin_write16(USB_EP_NI4_RXTYPE, val)
-#define bfin_read_USB_EP_NI4_RXINTERVAL()      bfin_read16(USB_EP_NI4_RXINTERVAL)
-#define bfin_write_USB_EP_NI4_RXINTERVAL(val)  bfin_write16(USB_EP_NI4_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 5 Control Registers */
-
-#define bfin_read_USB_EP_NI4_TXCOUNT()         bfin_read16(USB_EP_NI4_TXCOUNT)
-#define bfin_write_USB_EP_NI4_TXCOUNT(val)     bfin_write16(USB_EP_NI4_TXCOUNT, val)
-#define bfin_read_USB_EP_NI5_TXMAXP()          bfin_read16(USB_EP_NI5_TXMAXP)
-#define bfin_write_USB_EP_NI5_TXMAXP(val)      bfin_write16(USB_EP_NI5_TXMAXP, val)
-#define bfin_read_USB_EP_NI5_TXCSR()           bfin_read16(USB_EP_NI5_TXCSR)
-#define bfin_write_USB_EP_NI5_TXCSR(val)       bfin_write16(USB_EP_NI5_TXCSR, val)
-#define bfin_read_USB_EP_NI5_RXMAXP()          bfin_read16(USB_EP_NI5_RXMAXP)
-#define bfin_write_USB_EP_NI5_RXMAXP(val)      bfin_write16(USB_EP_NI5_RXMAXP, val)
-#define bfin_read_USB_EP_NI5_RXCSR()           bfin_read16(USB_EP_NI5_RXCSR)
-#define bfin_write_USB_EP_NI5_RXCSR(val)       bfin_write16(USB_EP_NI5_RXCSR, val)
-#define bfin_read_USB_EP_NI5_RXCOUNT()         bfin_read16(USB_EP_NI5_RXCOUNT)
-#define bfin_write_USB_EP_NI5_RXCOUNT(val)     bfin_write16(USB_EP_NI5_RXCOUNT, val)
-#define bfin_read_USB_EP_NI5_TXTYPE()          bfin_read16(USB_EP_NI5_TXTYPE)
-#define bfin_write_USB_EP_NI5_TXTYPE(val)      bfin_write16(USB_EP_NI5_TXTYPE, val)
-#define bfin_read_USB_EP_NI5_TXINTERVAL()      bfin_read16(USB_EP_NI5_TXINTERVAL)
-#define bfin_write_USB_EP_NI5_TXINTERVAL(val)  bfin_write16(USB_EP_NI5_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI5_RXTYPE()          bfin_read16(USB_EP_NI5_RXTYPE)
-#define bfin_write_USB_EP_NI5_RXTYPE(val)      bfin_write16(USB_EP_NI5_RXTYPE, val)
-#define bfin_read_USB_EP_NI5_RXINTERVAL()      bfin_read16(USB_EP_NI5_RXINTERVAL)
-#define bfin_write_USB_EP_NI5_RXINTERVAL(val)  bfin_write16(USB_EP_NI5_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 6 Control Registers */
-
-#define bfin_read_USB_EP_NI5_TXCOUNT()         bfin_read16(USB_EP_NI5_TXCOUNT)
-#define bfin_write_USB_EP_NI5_TXCOUNT(val)     bfin_write16(USB_EP_NI5_TXCOUNT, val)
-#define bfin_read_USB_EP_NI6_TXMAXP()          bfin_read16(USB_EP_NI6_TXMAXP)
-#define bfin_write_USB_EP_NI6_TXMAXP(val)      bfin_write16(USB_EP_NI6_TXMAXP, val)
-#define bfin_read_USB_EP_NI6_TXCSR()           bfin_read16(USB_EP_NI6_TXCSR)
-#define bfin_write_USB_EP_NI6_TXCSR(val)       bfin_write16(USB_EP_NI6_TXCSR, val)
-#define bfin_read_USB_EP_NI6_RXMAXP()          bfin_read16(USB_EP_NI6_RXMAXP)
-#define bfin_write_USB_EP_NI6_RXMAXP(val)      bfin_write16(USB_EP_NI6_RXMAXP, val)
-#define bfin_read_USB_EP_NI6_RXCSR()           bfin_read16(USB_EP_NI6_RXCSR)
-#define bfin_write_USB_EP_NI6_RXCSR(val)       bfin_write16(USB_EP_NI6_RXCSR, val)
-#define bfin_read_USB_EP_NI6_RXCOUNT()         bfin_read16(USB_EP_NI6_RXCOUNT)
-#define bfin_write_USB_EP_NI6_RXCOUNT(val)     bfin_write16(USB_EP_NI6_RXCOUNT, val)
-#define bfin_read_USB_EP_NI6_TXTYPE()          bfin_read16(USB_EP_NI6_TXTYPE)
-#define bfin_write_USB_EP_NI6_TXTYPE(val)      bfin_write16(USB_EP_NI6_TXTYPE, val)
-#define bfin_read_USB_EP_NI6_TXINTERVAL()      bfin_read16(USB_EP_NI6_TXINTERVAL)
-#define bfin_write_USB_EP_NI6_TXINTERVAL(val)  bfin_write16(USB_EP_NI6_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI6_RXTYPE()          bfin_read16(USB_EP_NI6_RXTYPE)
-#define bfin_write_USB_EP_NI6_RXTYPE(val)      bfin_write16(USB_EP_NI6_RXTYPE, val)
-#define bfin_read_USB_EP_NI6_RXINTERVAL()      bfin_read16(USB_EP_NI6_RXINTERVAL)
-#define bfin_write_USB_EP_NI6_RXINTERVAL(val)  bfin_write16(USB_EP_NI6_RXINTERVAL, val)
-
-/* USB Endbfin_read_()oint 7 Control Registers */
-
-#define bfin_read_USB_EP_NI6_TXCOUNT()         bfin_read16(USB_EP_NI6_TXCOUNT)
-#define bfin_write_USB_EP_NI6_TXCOUNT(val)     bfin_write16(USB_EP_NI6_TXCOUNT, val)
-#define bfin_read_USB_EP_NI7_TXMAXP()          bfin_read16(USB_EP_NI7_TXMAXP)
-#define bfin_write_USB_EP_NI7_TXMAXP(val)      bfin_write16(USB_EP_NI7_TXMAXP, val)
-#define bfin_read_USB_EP_NI7_TXCSR()           bfin_read16(USB_EP_NI7_TXCSR)
-#define bfin_write_USB_EP_NI7_TXCSR(val)       bfin_write16(USB_EP_NI7_TXCSR, val)
-#define bfin_read_USB_EP_NI7_RXMAXP()          bfin_read16(USB_EP_NI7_RXMAXP)
-#define bfin_write_USB_EP_NI7_RXMAXP(val)      bfin_write16(USB_EP_NI7_RXMAXP, val)
-#define bfin_read_USB_EP_NI7_RXCSR()           bfin_read16(USB_EP_NI7_RXCSR)
-#define bfin_write_USB_EP_NI7_RXCSR(val)       bfin_write16(USB_EP_NI7_RXCSR, val)
-#define bfin_read_USB_EP_NI7_RXCOUNT()         bfin_read16(USB_EP_NI7_RXCOUNT)
-#define bfin_write_USB_EP_NI7_RXCOUNT(val)     bfin_write16(USB_EP_NI7_RXCOUNT, val)
-#define bfin_read_USB_EP_NI7_TXTYPE()          bfin_read16(USB_EP_NI7_TXTYPE)
-#define bfin_write_USB_EP_NI7_TXTYPE(val)      bfin_write16(USB_EP_NI7_TXTYPE, val)
-#define bfin_read_USB_EP_NI7_TXINTERVAL()      bfin_read16(USB_EP_NI7_TXINTERVAL)
-#define bfin_write_USB_EP_NI7_TXINTERVAL(val)  bfin_write16(USB_EP_NI7_TXINTERVAL, val)
-#define bfin_read_USB_EP_NI7_RXTYPE()          bfin_read16(USB_EP_NI7_RXTYPE)
-#define bfin_write_USB_EP_NI7_RXTYPE(val)      bfin_write16(USB_EP_NI7_RXTYPE, val)
-#define bfin_read_USB_EP_NI7_RXINTERVAL()      bfin_read16(USB_EP_NI7_RXINTERVAL)
-#define bfin_write_USB_EP_NI7_RXINTERVAL(val)  bfin_write16(USB_EP_NI7_RXINTERVAL, val)
-#define bfin_read_USB_EP_NI7_TXCOUNT()         bfin_read16(USB_EP_NI7_TXCOUNT)
-#define bfin_write_USB_EP_NI7_TXCOUNT(val)     bfin_write16(USB_EP_NI7_TXCOUNT, val)
-#define bfin_read_USB_DMA_INTERRUPT()          bfin_read16(USB_DMA_INTERRUPT)
-#define bfin_write_USB_DMA_INTERRUPT(val)      bfin_write16(USB_DMA_INTERRUPT, val)
-
-/* USB Channel 0 Config Registers */
-
-#define bfin_read_USB_DMA0CONTROL()            bfin_read16(USB_DMA0CONTROL)
-#define bfin_write_USB_DMA0CONTROL(val)                bfin_write16(USB_DMA0CONTROL, val)
-#define bfin_read_USB_DMA0ADDRLOW()            bfin_read16(USB_DMA0ADDRLOW)
-#define bfin_write_USB_DMA0ADDRLOW(val)                bfin_write16(USB_DMA0ADDRLOW, val)
-#define bfin_read_USB_DMA0ADDRHIGH()           bfin_read16(USB_DMA0ADDRHIGH)
-#define bfin_write_USB_DMA0ADDRHIGH(val)       bfin_write16(USB_DMA0ADDRHIGH, val)
-#define bfin_read_USB_DMA0COUNTLOW()           bfin_read16(USB_DMA0COUNTLOW)
-#define bfin_write_USB_DMA0COUNTLOW(val)       bfin_write16(USB_DMA0COUNTLOW, val)
-#define bfin_read_USB_DMA0COUNTHIGH()          bfin_read16(USB_DMA0COUNTHIGH)
-#define bfin_write_USB_DMA0COUNTHIGH(val)      bfin_write16(USB_DMA0COUNTHIGH, val)
-
-/* USB Channel 1 Config Registers */
-
-#define bfin_read_USB_DMA1CONTROL()            bfin_read16(USB_DMA1CONTROL)
-#define bfin_write_USB_DMA1CONTROL(val)                bfin_write16(USB_DMA1CONTROL, val)
-#define bfin_read_USB_DMA1ADDRLOW()            bfin_read16(USB_DMA1ADDRLOW)
-#define bfin_write_USB_DMA1ADDRLOW(val)                bfin_write16(USB_DMA1ADDRLOW, val)
-#define bfin_read_USB_DMA1ADDRHIGH()           bfin_read16(USB_DMA1ADDRHIGH)
-#define bfin_write_USB_DMA1ADDRHIGH(val)       bfin_write16(USB_DMA1ADDRHIGH, val)
-#define bfin_read_USB_DMA1COUNTLOW()           bfin_read16(USB_DMA1COUNTLOW)
-#define bfin_write_USB_DMA1COUNTLOW(val)       bfin_write16(USB_DMA1COUNTLOW, val)
-#define bfin_read_USB_DMA1COUNTHIGH()          bfin_read16(USB_DMA1COUNTHIGH)
-#define bfin_write_USB_DMA1COUNTHIGH(val)      bfin_write16(USB_DMA1COUNTHIGH, val)
-
-/* USB Channel 2 Config Registers */
-
-#define bfin_read_USB_DMA2CONTROL()            bfin_read16(USB_DMA2CONTROL)
-#define bfin_write_USB_DMA2CONTROL(val)                bfin_write16(USB_DMA2CONTROL, val)
-#define bfin_read_USB_DMA2ADDRLOW()            bfin_read16(USB_DMA2ADDRLOW)
-#define bfin_write_USB_DMA2ADDRLOW(val)                bfin_write16(USB_DMA2ADDRLOW, val)
-#define bfin_read_USB_DMA2ADDRHIGH()           bfin_read16(USB_DMA2ADDRHIGH)
-#define bfin_write_USB_DMA2ADDRHIGH(val)       bfin_write16(USB_DMA2ADDRHIGH, val)
-#define bfin_read_USB_DMA2COUNTLOW()           bfin_read16(USB_DMA2COUNTLOW)
-#define bfin_write_USB_DMA2COUNTLOW(val)       bfin_write16(USB_DMA2COUNTLOW, val)
-#define bfin_read_USB_DMA2COUNTHIGH()          bfin_read16(USB_DMA2COUNTHIGH)
-#define bfin_write_USB_DMA2COUNTHIGH(val)      bfin_write16(USB_DMA2COUNTHIGH, val)
-
-/* USB Channel 3 Config Registers */
-
-#define bfin_read_USB_DMA3CONTROL()            bfin_read16(USB_DMA3CONTROL)
-#define bfin_write_USB_DMA3CONTROL(val)                bfin_write16(USB_DMA3CONTROL, val)
-#define bfin_read_USB_DMA3ADDRLOW()            bfin_read16(USB_DMA3ADDRLOW)
-#define bfin_write_USB_DMA3ADDRLOW(val)                bfin_write16(USB_DMA3ADDRLOW, val)
-#define bfin_read_USB_DMA3ADDRHIGH()           bfin_read16(USB_DMA3ADDRHIGH)
-#define bfin_write_USB_DMA3ADDRHIGH(val)       bfin_write16(USB_DMA3ADDRHIGH, val)
-#define bfin_read_USB_DMA3COUNTLOW()           bfin_read16(USB_DMA3COUNTLOW)
-#define bfin_write_USB_DMA3COUNTLOW(val)       bfin_write16(USB_DMA3COUNTLOW, val)
-#define bfin_read_USB_DMA3COUNTHIGH()          bfin_read16(USB_DMA3COUNTHIGH)
-#define bfin_write_USB_DMA3COUNTHIGH(val)      bfin_write16(USB_DMA3COUNTHIGH, val)
-
-/* USB Channel 4 Config Registers */
-
-#define bfin_read_USB_DMA4CONTROL()            bfin_read16(USB_DMA4CONTROL)
-#define bfin_write_USB_DMA4CONTROL(val)                bfin_write16(USB_DMA4CONTROL, val)
-#define bfin_read_USB_DMA4ADDRLOW()            bfin_read16(USB_DMA4ADDRLOW)
-#define bfin_write_USB_DMA4ADDRLOW(val)                bfin_write16(USB_DMA4ADDRLOW, val)
-#define bfin_read_USB_DMA4ADDRHIGH()           bfin_read16(USB_DMA4ADDRHIGH)
-#define bfin_write_USB_DMA4ADDRHIGH(val)       bfin_write16(USB_DMA4ADDRHIGH, val)
-#define bfin_read_USB_DMA4COUNTLOW()           bfin_read16(USB_DMA4COUNTLOW)
-#define bfin_write_USB_DMA4COUNTLOW(val)       bfin_write16(USB_DMA4COUNTLOW, val)
-#define bfin_read_USB_DMA4COUNTHIGH()          bfin_read16(USB_DMA4COUNTHIGH)
-#define bfin_write_USB_DMA4COUNTHIGH(val)      bfin_write16(USB_DMA4COUNTHIGH, val)
-
-/* USB Channel 5 Config Registers */
-
-#define bfin_read_USB_DMA5CONTROL()            bfin_read16(USB_DMA5CONTROL)
-#define bfin_write_USB_DMA5CONTROL(val)                bfin_write16(USB_DMA5CONTROL, val)
-#define bfin_read_USB_DMA5ADDRLOW()            bfin_read16(USB_DMA5ADDRLOW)
-#define bfin_write_USB_DMA5ADDRLOW(val)                bfin_write16(USB_DMA5ADDRLOW, val)
-#define bfin_read_USB_DMA5ADDRHIGH()           bfin_read16(USB_DMA5ADDRHIGH)
-#define bfin_write_USB_DMA5ADDRHIGH(val)               bfin_write16(USB_DMA5ADDRHIGH, val)
-#define bfin_read_USB_DMA5COUNTLOW()           bfin_read16(USB_DMA5COUNTLOW)
-#define bfin_write_USB_DMA5COUNTLOW(val)       bfin_write16(USB_DMA5COUNTLOW, val)
-#define bfin_read_USB_DMA5COUNTHIGH()          bfin_read16(USB_DMA5COUNTHIGH)
-#define bfin_write_USB_DMA5COUNTHIGH(val)      bfin_write16(USB_DMA5COUNTHIGH, val)
-
-/* USB Channel 6 Config Registers */
-
-#define bfin_read_USB_DMA6CONTROL()            bfin_read16(USB_DMA6CONTROL)
-#define bfin_write_USB_DMA6CONTROL(val)                bfin_write16(USB_DMA6CONTROL, val)
-#define bfin_read_USB_DMA6ADDRLOW()            bfin_read16(USB_DMA6ADDRLOW)
-#define bfin_write_USB_DMA6ADDRLOW(val)                bfin_write16(USB_DMA6ADDRLOW, val)
-#define bfin_read_USB_DMA6ADDRHIGH()           bfin_read16(USB_DMA6ADDRHIGH)
-#define bfin_write_USB_DMA6ADDRHIGH(val)       bfin_write16(USB_DMA6ADDRHIGH, val)
-#define bfin_read_USB_DMA6COUNTLOW()           bfin_read16(USB_DMA6COUNTLOW)
-#define bfin_write_USB_DMA6COUNTLOW(val)       bfin_write16(USB_DMA6COUNTLOW, val)
-#define bfin_read_USB_DMA6COUNTHIGH()          bfin_read16(USB_DMA6COUNTHIGH)
-#define bfin_write_USB_DMA6COUNTHIGH(val)      bfin_write16(USB_DMA6COUNTHIGH, val)
-
-/* USB Channel 7 Config Registers */
-
-#define bfin_read_USB_DMA7CONTROL()            bfin_read16(USB_DMA7CONTROL)
-#define bfin_write_USB_DMA7CONTROL(val)                bfin_write16(USB_DMA7CONTROL, val)
-#define bfin_read_USB_DMA7ADDRLOW()            bfin_read16(USB_DMA7ADDRLOW)
-#define bfin_write_USB_DMA7ADDRLOW(val)                bfin_write16(USB_DMA7ADDRLOW, val)
-#define bfin_read_USB_DMA7ADDRHIGH()           bfin_read16(USB_DMA7ADDRHIGH)
-#define bfin_write_USB_DMA7ADDRHIGH(val)       bfin_write16(USB_DMA7ADDRHIGH, val)
-#define bfin_read_USB_DMA7COUNTLOW()           bfin_read16(USB_DMA7COUNTLOW)
-#define bfin_write_USB_DMA7COUNTLOW(val)       bfin_write16(USB_DMA7COUNTLOW, val)
-#define bfin_read_USB_DMA7COUNTHIGH()          bfin_read16(USB_DMA7COUNTHIGH)
-#define bfin_write_USB_DMA7COUNTHIGH(val)      bfin_write16(USB_DMA7COUNTHIGH, val)
-
-/* Keybfin_read_()ad Registers */
-
-#define bfin_read_KPAD_CTL()           bfin_read16(KPAD_CTL)
-#define bfin_write_KPAD_CTL(val)       bfin_write16(KPAD_CTL, val)
-#define bfin_read_KPAD_PRESCALE()      bfin_read16(KPAD_PRESCALE)
-#define bfin_write_KPAD_PRESCALE(val)  bfin_write16(KPAD_PRESCALE, val)
-#define bfin_read_KPAD_MSEL()          bfin_read16(KPAD_MSEL)
-#define bfin_write_KPAD_MSEL(val)      bfin_write16(KPAD_MSEL, val)
-#define bfin_read_KPAD_ROWCOL()                bfin_read16(KPAD_ROWCOL)
-#define bfin_write_KPAD_ROWCOL(val)    bfin_write16(KPAD_ROWCOL, val)
-#define bfin_read_KPAD_STAT()          bfin_read16(KPAD_STAT)
-#define bfin_write_KPAD_STAT(val)      bfin_write16(KPAD_STAT, val)
-#define bfin_read_KPAD_SOFTEVAL()      bfin_read16(KPAD_SOFTEVAL)
-#define bfin_write_KPAD_SOFTEVAL(val)  bfin_write16(KPAD_SOFTEVAL, val)
-
-/* Pixel Combfin_read_()ositor (PIXC) Registers */
-
-#define bfin_read_PIXC_CTL()           bfin_read16(PIXC_CTL)
-#define bfin_write_PIXC_CTL(val)       bfin_write16(PIXC_CTL, val)
-#define bfin_read_PIXC_PPL()           bfin_read16(PIXC_PPL)
-#define bfin_write_PIXC_PPL(val)       bfin_write16(PIXC_PPL, val)
-#define bfin_read_PIXC_LPF()           bfin_read16(PIXC_LPF)
-#define bfin_write_PIXC_LPF(val)       bfin_write16(PIXC_LPF, val)
-#define bfin_read_PIXC_AHSTART()       bfin_read16(PIXC_AHSTART)
-#define bfin_write_PIXC_AHSTART(val)   bfin_write16(PIXC_AHSTART, val)
-#define bfin_read_PIXC_AHEND()         bfin_read16(PIXC_AHEND)
-#define bfin_write_PIXC_AHEND(val)     bfin_write16(PIXC_AHEND, val)
-#define bfin_read_PIXC_AVSTART()       bfin_read16(PIXC_AVSTART)
-#define bfin_write_PIXC_AVSTART(val)   bfin_write16(PIXC_AVSTART, val)
-#define bfin_read_PIXC_AVEND()         bfin_read16(PIXC_AVEND)
-#define bfin_write_PIXC_AVEND(val)     bfin_write16(PIXC_AVEND, val)
-#define bfin_read_PIXC_ATRANSP()       bfin_read16(PIXC_ATRANSP)
-#define bfin_write_PIXC_ATRANSP(val)   bfin_write16(PIXC_ATRANSP, val)
-#define bfin_read_PIXC_BHSTART()       bfin_read16(PIXC_BHSTART)
-#define bfin_write_PIXC_BHSTART(val)   bfin_write16(PIXC_BHSTART, val)
-#define bfin_read_PIXC_BHEND()         bfin_read16(PIXC_BHEND)
-#define bfin_write_PIXC_BHEND(val)     bfin_write16(PIXC_BHEND, val)
-#define bfin_read_PIXC_BVSTART()       bfin_read16(PIXC_BVSTART)
-#define bfin_write_PIXC_BVSTART(val)   bfin_write16(PIXC_BVSTART, val)
-#define bfin_read_PIXC_BVEND()         bfin_read16(PIXC_BVEND)
-#define bfin_write_PIXC_BVEND(val)     bfin_write16(PIXC_BVEND, val)
-#define bfin_read_PIXC_BTRANSP()       bfin_read16(PIXC_BTRANSP)
-#define bfin_write_PIXC_BTRANSP(val)   bfin_write16(PIXC_BTRANSP, val)
-#define bfin_read_PIXC_INTRSTAT()      bfin_read16(PIXC_INTRSTAT)
-#define bfin_write_PIXC_INTRSTAT(val)  bfin_write16(PIXC_INTRSTAT, val)
-#define bfin_read_PIXC_RYCON()         bfin_read32(PIXC_RYCON)
-#define bfin_write_PIXC_RYCON(val)     bfin_write32(PIXC_RYCON, val)
-#define bfin_read_PIXC_GUCON()         bfin_read32(PIXC_GUCON)
-#define bfin_write_PIXC_GUCON(val)     bfin_write32(PIXC_GUCON, val)
-#define bfin_read_PIXC_BVCON()         bfin_read32(PIXC_BVCON)
-#define bfin_write_PIXC_BVCON(val)     bfin_write32(PIXC_BVCON, val)
-#define bfin_read_PIXC_CCBIAS()                bfin_read32(PIXC_CCBIAS)
-#define bfin_write_PIXC_CCBIAS(val)    bfin_write32(PIXC_CCBIAS, val)
-#define bfin_read_PIXC_TC()            bfin_read32(PIXC_TC)
-#define bfin_write_PIXC_TC(val)                bfin_write32(PIXC_TC, val)
-
-/* Handshake MDMA 0 Registers */
-
-#define bfin_read_HMDMA0_CONTROL()             bfin_read16(HMDMA0_CONTROL)
-#define bfin_write_HMDMA0_CONTROL(val)         bfin_write16(HMDMA0_CONTROL, val)
-#define bfin_read_HMDMA0_ECINIT()              bfin_read16(HMDMA0_ECINIT)
-#define bfin_write_HMDMA0_ECINIT(val)          bfin_write16(HMDMA0_ECINIT, val)
-#define bfin_read_HMDMA0_BCINIT()              bfin_read16(HMDMA0_BCINIT)
-#define bfin_write_HMDMA0_BCINIT(val)          bfin_write16(HMDMA0_BCINIT, val)
-#define bfin_read_HMDMA0_ECURGENT()            bfin_read16(HMDMA0_ECURGENT)
-#define bfin_write_HMDMA0_ECURGENT(val)                bfin_write16(HMDMA0_ECURGENT, val)
-#define bfin_read_HMDMA0_ECOVERFLOW()          bfin_read16(HMDMA0_ECOVERFLOW)
-#define bfin_write_HMDMA0_ECOVERFLOW(val)      bfin_write16(HMDMA0_ECOVERFLOW, val)
-#define bfin_read_HMDMA0_ECOUNT()              bfin_read16(HMDMA0_ECOUNT)
-#define bfin_write_HMDMA0_ECOUNT(val)          bfin_write16(HMDMA0_ECOUNT, val)
-#define bfin_read_HMDMA0_BCOUNT()              bfin_read16(HMDMA0_BCOUNT)
-#define bfin_write_HMDMA0_BCOUNT(val)          bfin_write16(HMDMA0_BCOUNT, val)
-
-/* Handshake MDMA 1 Registers */
-
-#define bfin_read_HMDMA1_CONTROL()             bfin_read16(HMDMA1_CONTROL)
-#define bfin_write_HMDMA1_CONTROL(val)         bfin_write16(HMDMA1_CONTROL, val)
-#define bfin_read_HMDMA1_ECINIT()              bfin_read16(HMDMA1_ECINIT)
-#define bfin_write_HMDMA1_ECINIT(val)          bfin_write16(HMDMA1_ECINIT, val)
-#define bfin_read_HMDMA1_BCINIT()              bfin_read16(HMDMA1_BCINIT)
-#define bfin_write_HMDMA1_BCINIT(val)          bfin_write16(HMDMA1_BCINIT, val)
-#define bfin_read_HMDMA1_ECURGENT()            bfin_read16(HMDMA1_ECURGENT)
-#define bfin_write_HMDMA1_ECURGENT(val)                bfin_write16(HMDMA1_ECURGENT, val)
-#define bfin_read_HMDMA1_ECOVERFLOW()          bfin_read16(HMDMA1_ECOVERFLOW)
-#define bfin_write_HMDMA1_ECOVERFLOW(val)      bfin_write16(HMDMA1_ECOVERFLOW, val)
-#define bfin_read_HMDMA1_ECOUNT()              bfin_read16(HMDMA1_ECOUNT)
-#define bfin_write_HMDMA1_ECOUNT(val)          bfin_write16(HMDMA1_ECOUNT, val)
-#define bfin_read_HMDMA1_BCOUNT()              bfin_read16(HMDMA1_BCOUNT)
-#define bfin_write_HMDMA1_BCOUNT(val)          bfin_write16(HMDMA1_BCOUNT, val)
-
 #endif /* _CDEF_BF549_H */
index a2e9d9849eba22ac2b119c604ca124188de05e0b..32f71e6a7c15c52c268b81ded5904f9e0a7cc22d 100644 (file)
 #define bfin_read_CNT_MIN()            bfin_read32(CNT_MIN)
 #define bfin_write_CNT_MIN(val)                bfin_write32(CNT_MIN, val)
 
-/* OTP/FUSE Registers */
-
-#define bfin_read_OTP_CONTROL()                bfin_read16(OTP_CONTROL)
-#define bfin_write_OTP_CONTROL(val)    bfin_write16(OTP_CONTROL, val)
-#define bfin_read_OTP_BEN()            bfin_read16(OTP_BEN)
-#define bfin_write_OTP_BEN(val)                bfin_write16(OTP_BEN, val)
-#define bfin_read_OTP_STATUS()         bfin_read16(OTP_STATUS)
-#define bfin_write_OTP_STATUS(val)     bfin_write16(OTP_STATUS, val)
-#define bfin_read_OTP_TIMING()         bfin_read32(OTP_TIMING)
-#define bfin_write_OTP_TIMING(val)     bfin_write32(OTP_TIMING, val)
-
 /* Security Registers */
 
 #define bfin_read_SECURE_SYSSWT()      bfin_read32(SECURE_SYSSWT)
 #define bfin_read_DMAC1_PERIMUX()      bfin_read16(DMAC1_PERIMUX)
 #define bfin_write_DMAC1_PERIMUX(val)  bfin_write16(DMAC1_PERIMUX, val)
 
-/* OTP Read/Write Data Buffer Registers */
-
-#define bfin_read_OTP_DATA0()          bfin_read32(OTP_DATA0)
-#define bfin_write_OTP_DATA0(val)      bfin_write32(OTP_DATA0, val)
-#define bfin_read_OTP_DATA1()          bfin_read32(OTP_DATA1)
-#define bfin_write_OTP_DATA1(val)      bfin_write32(OTP_DATA1, val)
-#define bfin_read_OTP_DATA2()          bfin_read32(OTP_DATA2)
-#define bfin_write_OTP_DATA2(val)      bfin_write32(OTP_DATA2, val)
-#define bfin_read_OTP_DATA3()          bfin_read32(OTP_DATA3)
-#define bfin_write_OTP_DATA3(val)      bfin_write32(OTP_DATA3, val)
-
 /* Handshake MDMA is not defined in the shared file because it is not available on the ADSP-BF542 bfin_read_()rocessor */
 
 /* legacy definitions */
index 39f588dcd382a4d6fab5785f4be38f83e9a92b2f..f916c52a148afded7f39137e474ef27a0466824c 100644 (file)
 #define                 DMA_READY  0x1        /* DMA Ready */
 #define                  FIFOFULL  0x2        /* FIFO Full */
 #define                 FIFOEMPTY  0x4        /* FIFO Empty */
-#define                  COMPLETE  0x8        /* DMA Complete */
+#define              DMA_COMPLETE  0x8        /* DMA Complete */
 #define                      HSHK  0x10       /* Host Handshake */
-#define                   TIMEOUT  0x20       /* Host Timeout */
+#define                 HSTIMEOUT  0x20       /* Host Timeout */
 #define                      HIRQ  0x40       /* Host Interrupt Request */
 #define                ALLOW_CNFG  0x80       /* Allow New Configuration */
 #define                   DMA_DIR  0x100      /* DMA Direction */
index c4dcf302d9f5ef5e3a7033e8703052a375af417f..72c343646b2a46e4c17ef4876fa92d45150dbf90 100644 (file)
@@ -4,18 +4,18 @@
  * Licensed under the ADI BSD license or the GPL-2 (or later)
  */
 
-#ifndef _DEF_BF548_H
-#define _DEF_BF548_H
+#ifndef _DEF_BF547_H
+#define _DEF_BF547_H
 
 /* Include all Core registers and bit definitions */
 #include <asm/def_LPBlackfin.h>
 
-/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF548 */
+/* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF547 */
 
 /* Include defBF54x_base.h for the set of #defines that are common to all ADSP-BF54x processors */
 #include "defBF54x_base.h"
 
-/* The following are the #defines needed by ADSP-BF548 that are not in the common header */
+/* The following are the #defines needed by ADSP-BF547 that are not in the common header */
 
 /* Timer Registers */
 
 /* ******************************************* */
 
 
-#endif /* _DEF_BF548_H */
+#endif /* _DEF_BF547_H */
index a5079980968c78f74d82da02ea0003e58f63a79e..3fb33b040ab760a94d4f24e87629e24ff2278ef0 100644 (file)
 /* Include defBF54x_base.h for the set of #defines that are common to all ADSP-BF54x processors */
 #include "defBF54x_base.h"
 
-/* The following are the #defines needed by ADSP-BF548 that are not in the common header */
-
-/* Timer Registers */
-
-#define                    TIMER8_CONFIG  0xffc00600   /* Timer 8 Configuration Register */
-#define                   TIMER8_COUNTER  0xffc00604   /* Timer 8 Counter Register */
-#define                    TIMER8_PERIOD  0xffc00608   /* Timer 8 Period Register */
-#define                     TIMER8_WIDTH  0xffc0060c   /* Timer 8 Width Register */
-#define                    TIMER9_CONFIG  0xffc00610   /* Timer 9 Configuration Register */
-#define                   TIMER9_COUNTER  0xffc00614   /* Timer 9 Counter Register */
-#define                    TIMER9_PERIOD  0xffc00618   /* Timer 9 Period Register */
-#define                     TIMER9_WIDTH  0xffc0061c   /* Timer 9 Width Register */
-#define                   TIMER10_CONFIG  0xffc00620   /* Timer 10 Configuration Register */
-#define                  TIMER10_COUNTER  0xffc00624   /* Timer 10 Counter Register */
-#define                   TIMER10_PERIOD  0xffc00628   /* Timer 10 Period Register */
-#define                    TIMER10_WIDTH  0xffc0062c   /* Timer 10 Width Register */
-
-/* Timer Group of 3 Registers */
-
-#define                    TIMER_ENABLE1  0xffc00640   /* Timer Group of 3 Enable Register */
-#define                   TIMER_DISABLE1  0xffc00644   /* Timer Group of 3 Disable Register */
-#define                    TIMER_STATUS1  0xffc00648   /* Timer Group of 3 Status Register */
-
-/* SPORT0 Registers */
-
-#define                      SPORT0_TCR1  0xffc00800   /* SPORT0 Transmit Configuration 1 Register */
-#define                      SPORT0_TCR2  0xffc00804   /* SPORT0 Transmit Configuration 2 Register */
-#define                   SPORT0_TCLKDIV  0xffc00808   /* SPORT0 Transmit Serial Clock Divider Register */
-#define                    SPORT0_TFSDIV  0xffc0080c   /* SPORT0 Transmit Frame Sync Divider Register */
-#define                        SPORT0_TX  0xffc00810   /* SPORT0 Transmit Data Register */
-#define                        SPORT0_RX  0xffc00818   /* SPORT0 Receive Data Register */
-#define                      SPORT0_RCR1  0xffc00820   /* SPORT0 Receive Configuration 1 Register */
-#define                      SPORT0_RCR2  0xffc00824   /* SPORT0 Receive Configuration 2 Register */
-#define                   SPORT0_RCLKDIV  0xffc00828   /* SPORT0 Receive Serial Clock Divider Register */
-#define                    SPORT0_RFSDIV  0xffc0082c   /* SPORT0 Receive Frame Sync Divider Register */
-#define                      SPORT0_STAT  0xffc00830   /* SPORT0 Status Register */
-#define                      SPORT0_CHNL  0xffc00834   /* SPORT0 Current Channel Register */
-#define                     SPORT0_MCMC1  0xffc00838   /* SPORT0 Multi channel Configuration Register 1 */
-#define                     SPORT0_MCMC2  0xffc0083c   /* SPORT0 Multi channel Configuration Register 2 */
-#define                     SPORT0_MTCS0  0xffc00840   /* SPORT0 Multi channel Transmit Select Register 0 */
-#define                     SPORT0_MTCS1  0xffc00844   /* SPORT0 Multi channel Transmit Select Register 1 */
-#define                     SPORT0_MTCS2  0xffc00848   /* SPORT0 Multi channel Transmit Select Register 2 */
-#define                     SPORT0_MTCS3  0xffc0084c   /* SPORT0 Multi channel Transmit Select Register 3 */
-#define                     SPORT0_MRCS0  0xffc00850   /* SPORT0 Multi channel Receive Select Register 0 */
-#define                     SPORT0_MRCS1  0xffc00854   /* SPORT0 Multi channel Receive Select Register 1 */
-#define                     SPORT0_MRCS2  0xffc00858   /* SPORT0 Multi channel Receive Select Register 2 */
-#define                     SPORT0_MRCS3  0xffc0085c   /* SPORT0 Multi channel Receive Select Register 3 */
-
-/* EPPI0 Registers */
-
-#define                     EPPI0_STATUS  0xffc01000   /* EPPI0 Status Register */
-#define                     EPPI0_HCOUNT  0xffc01004   /* EPPI0 Horizontal Transfer Count Register */
-#define                     EPPI0_HDELAY  0xffc01008   /* EPPI0 Horizontal Delay Count Register */
-#define                     EPPI0_VCOUNT  0xffc0100c   /* EPPI0 Vertical Transfer Count Register */
-#define                     EPPI0_VDELAY  0xffc01010   /* EPPI0 Vertical Delay Count Register */
-#define                      EPPI0_FRAME  0xffc01014   /* EPPI0 Lines per Frame Register */
-#define                       EPPI0_LINE  0xffc01018   /* EPPI0 Samples per Line Register */
-#define                     EPPI0_CLKDIV  0xffc0101c   /* EPPI0 Clock Divide Register */
-#define                    EPPI0_CONTROL  0xffc01020   /* EPPI0 Control Register */
-#define                   EPPI0_FS1W_HBL  0xffc01024   /* EPPI0 FS1 Width Register / EPPI0 Horizontal Blanking Samples Per Line Register */
-#define                  EPPI0_FS1P_AVPL  0xffc01028   /* EPPI0 FS1 Period Register / EPPI0 Active Video Samples Per Line Register */
-#define                   EPPI0_FS2W_LVB  0xffc0102c   /* EPPI0 FS2 Width Register / EPPI0 Lines of Vertical Blanking Register */
-#define                  EPPI0_FS2P_LAVF  0xffc01030   /* EPPI0 FS2 Period Register/ EPPI0 Lines of Active Video Per Field Register */
-#define                       EPPI0_CLIP  0xffc01034   /* EPPI0 Clipping Register */
-
-/* UART2 Registers */
-
-#define                        UART2_DLL  0xffc02100   /* Divisor Latch Low Byte */
-#define                        UART2_DLH  0xffc02104   /* Divisor Latch High Byte */
-#define                       UART2_GCTL  0xffc02108   /* Global Control Register */
-#define                        UART2_LCR  0xffc0210c   /* Line Control Register */
-#define                        UART2_MCR  0xffc02110   /* Modem Control Register */
-#define                        UART2_LSR  0xffc02114   /* Line Status Register */
-#define                        UART2_MSR  0xffc02118   /* Modem Status Register */
-#define                        UART2_SCR  0xffc0211c   /* Scratch Register */
-#define                    UART2_IER_SET  0xffc02120   /* Interrupt Enable Register Set */
-#define                  UART2_IER_CLEAR  0xffc02124   /* Interrupt Enable Register Clear */
-#define                        UART2_RBR  0xffc0212c   /* Receive Buffer Register */
-
-/* Two Wire Interface Registers (TWI1) */
-
-#define                     TWI1_REGBASE  0xffc02200
-#define                      TWI1_CLKDIV  0xffc02200   /* Clock Divider Register */
-#define                     TWI1_CONTROL  0xffc02204   /* TWI Control Register */
-#define                  TWI1_SLAVE_CTRL  0xffc02208   /* TWI Slave Mode Control Register */
-#define                  TWI1_SLAVE_STAT  0xffc0220c   /* TWI Slave Mode Status Register */
-#define                  TWI1_SLAVE_ADDR  0xffc02210   /* TWI Slave Mode Address Register */
-#define                 TWI1_MASTER_CTRL  0xffc02214   /* TWI Master Mode Control Register */
-#define                 TWI1_MASTER_STAT  0xffc02218   /* TWI Master Mode Status Register */
-#define                 TWI1_MASTER_ADDR  0xffc0221c   /* TWI Master Mode Address Register */
-#define                    TWI1_INT_STAT  0xffc02220   /* TWI Interrupt Status Register */
-#define                    TWI1_INT_MASK  0xffc02224   /* TWI Interrupt Mask Register */
-#define                   TWI1_FIFO_CTRL  0xffc02228   /* TWI FIFO Control Register */
-#define                   TWI1_FIFO_STAT  0xffc0222c   /* TWI FIFO Status Register */
-#define                   TWI1_XMT_DATA8  0xffc02280   /* TWI FIFO Transmit Data Single Byte Register */
-#define                  TWI1_XMT_DATA16  0xffc02284   /* TWI FIFO Transmit Data Double Byte Register */
-#define                   TWI1_RCV_DATA8  0xffc02288   /* TWI FIFO Receive Data Single Byte Register */
-#define                  TWI1_RCV_DATA16  0xffc0228c   /* TWI FIFO Receive Data Double Byte Register */
-
-/* SPI2  Registers */
-
-#define                     SPI2_REGBASE  0xffc02400
-#define                         SPI2_CTL  0xffc02400   /* SPI2 Control Register */
-#define                         SPI2_FLG  0xffc02404   /* SPI2 Flag Register */
-#define                        SPI2_STAT  0xffc02408   /* SPI2 Status Register */
-#define                        SPI2_TDBR  0xffc0240c   /* SPI2 Transmit Data Buffer Register */
-#define                        SPI2_RDBR  0xffc02410   /* SPI2 Receive Data Buffer Register */
-#define                        SPI2_BAUD  0xffc02414   /* SPI2 Baud Rate Register */
-#define                      SPI2_SHADOW  0xffc02418   /* SPI2 Receive Data Buffer Shadow Register */
+/* The BF548 is like the BF547, but has additional CANs */
+#include "defBF547.h"
 
 /* CAN Controller 1 Config 1 Registers */
 
 #define                    CAN1_MB31_ID0  0xffc037f8   /* CAN Controller 1 Mailbox 31 ID0 Register */
 #define                    CAN1_MB31_ID1  0xffc037fc   /* CAN Controller 1 Mailbox 31 ID1 Register */
 
-/* ATAPI Registers */
-
-#define                    ATAPI_CONTROL  0xffc03800   /* ATAPI Control Register */
-#define                     ATAPI_STATUS  0xffc03804   /* ATAPI Status Register */
-#define                   ATAPI_DEV_ADDR  0xffc03808   /* ATAPI Device Register Address */
-#define                  ATAPI_DEV_TXBUF  0xffc0380c   /* ATAPI Device Register Write Data */
-#define                  ATAPI_DEV_RXBUF  0xffc03810   /* ATAPI Device Register Read Data */
-#define                   ATAPI_INT_MASK  0xffc03814   /* ATAPI Interrupt Mask Register */
-#define                 ATAPI_INT_STATUS  0xffc03818   /* ATAPI Interrupt Status Register */
-#define                   ATAPI_XFER_LEN  0xffc0381c   /* ATAPI Length of Transfer */
-#define                ATAPI_LINE_STATUS  0xffc03820   /* ATAPI Line Status */
-#define                   ATAPI_SM_STATE  0xffc03824   /* ATAPI State Machine Status */
-#define                  ATAPI_TERMINATE  0xffc03828   /* ATAPI Host Terminate */
-#define                 ATAPI_PIO_TFRCNT  0xffc0382c   /* ATAPI PIO mode transfer count */
-#define                 ATAPI_DMA_TFRCNT  0xffc03830   /* ATAPI DMA mode transfer count */
-#define               ATAPI_UMAIN_TFRCNT  0xffc03834   /* ATAPI UDMAIN transfer count */
-#define             ATAPI_UDMAOUT_TFRCNT  0xffc03838   /* ATAPI UDMAOUT transfer count */
-#define                  ATAPI_REG_TIM_0  0xffc03840   /* ATAPI Register Transfer Timing 0 */
-#define                  ATAPI_PIO_TIM_0  0xffc03844   /* ATAPI PIO Timing 0 Register */
-#define                  ATAPI_PIO_TIM_1  0xffc03848   /* ATAPI PIO Timing 1 Register */
-#define                ATAPI_MULTI_TIM_0  0xffc03850   /* ATAPI Multi-DMA Timing 0 Register */
-#define                ATAPI_MULTI_TIM_1  0xffc03854   /* ATAPI Multi-DMA Timing 1 Register */
-#define                ATAPI_MULTI_TIM_2  0xffc03858   /* ATAPI Multi-DMA Timing 2 Register */
-#define                ATAPI_ULTRA_TIM_0  0xffc03860   /* ATAPI Ultra-DMA Timing 0 Register */
-#define                ATAPI_ULTRA_TIM_1  0xffc03864   /* ATAPI Ultra-DMA Timing 1 Register */
-#define                ATAPI_ULTRA_TIM_2  0xffc03868   /* ATAPI Ultra-DMA Timing 2 Register */
-#define                ATAPI_ULTRA_TIM_3  0xffc0386c   /* ATAPI Ultra-DMA Timing 3 Register */
-
-/* SDH Registers */
-
-#define                      SDH_PWR_CTL  0xffc03900   /* SDH Power Control */
-#define                      SDH_CLK_CTL  0xffc03904   /* SDH Clock Control */
-#define                     SDH_ARGUMENT  0xffc03908   /* SDH Argument */
-#define                      SDH_COMMAND  0xffc0390c   /* SDH Command */
-#define                     SDH_RESP_CMD  0xffc03910   /* SDH Response Command */
-#define                    SDH_RESPONSE0  0xffc03914   /* SDH Response0 */
-#define                    SDH_RESPONSE1  0xffc03918   /* SDH Response1 */
-#define                    SDH_RESPONSE2  0xffc0391c   /* SDH Response2 */
-#define                    SDH_RESPONSE3  0xffc03920   /* SDH Response3 */
-#define                   SDH_DATA_TIMER  0xffc03924   /* SDH Data Timer */
-#define                    SDH_DATA_LGTH  0xffc03928   /* SDH Data Length */
-#define                     SDH_DATA_CTL  0xffc0392c   /* SDH Data Control */
-#define                     SDH_DATA_CNT  0xffc03930   /* SDH Data Counter */
-#define                       SDH_STATUS  0xffc03934   /* SDH Status */
-#define                   SDH_STATUS_CLR  0xffc03938   /* SDH Status Clear */
-#define                        SDH_MASK0  0xffc0393c   /* SDH Interrupt0 Mask */
-#define                        SDH_MASK1  0xffc03940   /* SDH Interrupt1 Mask */
-#define                     SDH_FIFO_CNT  0xffc03948   /* SDH FIFO Counter */
-#define                         SDH_FIFO  0xffc03980   /* SDH Data FIFO */
-#define                     SDH_E_STATUS  0xffc039c0   /* SDH Exception Status */
-#define                       SDH_E_MASK  0xffc039c4   /* SDH Exception Mask */
-#define                          SDH_CFG  0xffc039c8   /* SDH Configuration */
-#define                   SDH_RD_WAIT_EN  0xffc039cc   /* SDH Read Wait Enable */
-#define                         SDH_PID0  0xffc039d0   /* SDH Peripheral Identification0 */
-#define                         SDH_PID1  0xffc039d4   /* SDH Peripheral Identification1 */
-#define                         SDH_PID2  0xffc039d8   /* SDH Peripheral Identification2 */
-#define                         SDH_PID3  0xffc039dc   /* SDH Peripheral Identification3 */
-#define                         SDH_PID4  0xffc039e0   /* SDH Peripheral Identification4 */
-#define                         SDH_PID5  0xffc039e4   /* SDH Peripheral Identification5 */
-#define                         SDH_PID6  0xffc039e8   /* SDH Peripheral Identification6 */
-#define                         SDH_PID7  0xffc039ec   /* SDH Peripheral Identification7 */
-
-/* HOST Port Registers */
-
-#define                     HOST_CONTROL  0xffc03a00   /* HOST Control Register */
-#define                      HOST_STATUS  0xffc03a04   /* HOST Status Register */
-#define                     HOST_TIMEOUT  0xffc03a08   /* HOST Acknowledge Mode Timeout Register */
-
-/* USB Control Registers */
-
-#define                        USB_FADDR  0xffc03c00   /* Function address register */
-#define                        USB_POWER  0xffc03c04   /* Power management register */
-#define                       USB_INTRTX  0xffc03c08   /* Interrupt register for endpoint 0 and Tx endpoint 1 to 7 */
-#define                       USB_INTRRX  0xffc03c0c   /* Interrupt register for Rx endpoints 1 to 7 */
-#define                      USB_INTRTXE  0xffc03c10   /* Interrupt enable register for IntrTx */
-#define                      USB_INTRRXE  0xffc03c14   /* Interrupt enable register for IntrRx */
-#define                      USB_INTRUSB  0xffc03c18   /* Interrupt register for common USB interrupts */
-#define                     USB_INTRUSBE  0xffc03c1c   /* Interrupt enable register for IntrUSB */
-#define                        USB_FRAME  0xffc03c20   /* USB frame number */
-#define                        USB_INDEX  0xffc03c24   /* Index register for selecting the indexed endpoint registers */
-#define                     USB_TESTMODE  0xffc03c28   /* Enabled USB 20 test modes */
-#define                     USB_GLOBINTR  0xffc03c2c   /* Global Interrupt Mask register and Wakeup Exception Interrupt */
-#define                   USB_GLOBAL_CTL  0xffc03c30   /* Global Clock Control for the core */
-
-/* USB Packet Control Registers */
-
-#define                USB_TX_MAX_PACKET  0xffc03c40   /* Maximum packet size for Host Tx endpoint */
-#define                         USB_CSR0  0xffc03c44   /* Control Status register for endpoint 0 and Control Status register for Host Tx endpoint */
-#define                        USB_TXCSR  0xffc03c44   /* Control Status register for endpoint 0 and Control Status register for Host Tx endpoint */
-#define                USB_RX_MAX_PACKET  0xffc03c48   /* Maximum packet size for Host Rx endpoint */
-#define                        USB_RXCSR  0xffc03c4c   /* Control Status register for Host Rx endpoint */
-#define                       USB_COUNT0  0xffc03c50   /* Number of bytes received in endpoint 0 FIFO and Number of bytes received in Host Tx endpoint */
-#define                      USB_RXCOUNT  0xffc03c50   /* Number of bytes received in endpoint 0 FIFO and Number of bytes received in Host Tx endpoint */
-#define                       USB_TXTYPE  0xffc03c54   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint */
-#define                    USB_NAKLIMIT0  0xffc03c58   /* Sets the NAK response timeout on Endpoint 0 and on Bulk transfers for Host Tx endpoint */
-#define                   USB_TXINTERVAL  0xffc03c58   /* Sets the NAK response timeout on Endpoint 0 and on Bulk transfers for Host Tx endpoint */
-#define                       USB_RXTYPE  0xffc03c5c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint */
-#define                   USB_RXINTERVAL  0xffc03c60   /* Sets the polling interval for Interrupt and Isochronous transfers or the NAK response timeout on Bulk transfers */
-#define                      USB_TXCOUNT  0xffc03c68   /* Number of bytes to be written to the selected endpoint Tx FIFO */
-
-/* USB Endpoint FIFO Registers */
-
-#define                     USB_EP0_FIFO  0xffc03c80   /* Endpoint 0 FIFO */
-#define                     USB_EP1_FIFO  0xffc03c88   /* Endpoint 1 FIFO */
-#define                     USB_EP2_FIFO  0xffc03c90   /* Endpoint 2 FIFO */
-#define                     USB_EP3_FIFO  0xffc03c98   /* Endpoint 3 FIFO */
-#define                     USB_EP4_FIFO  0xffc03ca0   /* Endpoint 4 FIFO */
-#define                     USB_EP5_FIFO  0xffc03ca8   /* Endpoint 5 FIFO */
-#define                     USB_EP6_FIFO  0xffc03cb0   /* Endpoint 6 FIFO */
-#define                     USB_EP7_FIFO  0xffc03cb8   /* Endpoint 7 FIFO */
-
-/* USB OTG Control Registers */
-
-#define                  USB_OTG_DEV_CTL  0xffc03d00   /* OTG Device Control Register */
-#define                 USB_OTG_VBUS_IRQ  0xffc03d04   /* OTG VBUS Control Interrupts */
-#define                USB_OTG_VBUS_MASK  0xffc03d08   /* VBUS Control Interrupt Enable */
-
-/* USB Phy Control Registers */
-
-#define                     USB_LINKINFO  0xffc03d48   /* Enables programming of some PHY-side delays */
-#define                        USB_VPLEN  0xffc03d4c   /* Determines duration of VBUS pulse for VBUS charging */
-#define                      USB_HS_EOF1  0xffc03d50   /* Time buffer for High-Speed transactions */
-#define                      USB_FS_EOF1  0xffc03d54   /* Time buffer for Full-Speed transactions */
-#define                      USB_LS_EOF1  0xffc03d58   /* Time buffer for Low-Speed transactions */
-
-/* (APHY_CNTRL is for ADI usage only) */
-
-#define                   USB_APHY_CNTRL  0xffc03de0   /* Register that increases visibility of Analog PHY */
-
-/* (APHY_CALIB is for ADI usage only) */
-
-#define                   USB_APHY_CALIB  0xffc03de4   /* Register used to set some calibration values */
-#define                  USB_APHY_CNTRL2  0xffc03de8   /* Register used to prevent re-enumeration once Moab goes into hibernate mode */
-
-/* (PHY_TEST is for ADI usage only) */
-
-#define                     USB_PHY_TEST  0xffc03dec   /* Used for reducing simulation time and simplifies FIFO testability */
-#define                  USB_PLLOSC_CTRL  0xffc03df0   /* Used to program different parameters for USB PLL and Oscillator */
-#define                   USB_SRP_CLKDIV  0xffc03df4   /* Used to program clock divide value for the clock fed to the SRP detection logic */
-
-/* USB Endpoint 0 Control Registers */
-
-#define                USB_EP_NI0_TXMAXP  0xffc03e00   /* Maximum packet size for Host Tx endpoint0 */
-#define                 USB_EP_NI0_TXCSR  0xffc03e04   /* Control Status register for endpoint 0 */
-#define                USB_EP_NI0_RXMAXP  0xffc03e08   /* Maximum packet size for Host Rx endpoint0 */
-#define                 USB_EP_NI0_RXCSR  0xffc03e0c   /* Control Status register for Host Rx endpoint0 */
-#define               USB_EP_NI0_RXCOUNT  0xffc03e10   /* Number of bytes received in endpoint 0 FIFO */
-#define                USB_EP_NI0_TXTYPE  0xffc03e14   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint0 */
-#define            USB_EP_NI0_TXINTERVAL  0xffc03e18   /* Sets the NAK response timeout on Endpoint 0 */
-#define                USB_EP_NI0_RXTYPE  0xffc03e1c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint0 */
-#define            USB_EP_NI0_RXINTERVAL  0xffc03e20   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint0 */
-
-/* USB Endpoint 1 Control Registers */
-
-#define               USB_EP_NI0_TXCOUNT  0xffc03e28   /* Number of bytes to be written to the endpoint0 Tx FIFO */
-#define                USB_EP_NI1_TXMAXP  0xffc03e40   /* Maximum packet size for Host Tx endpoint1 */
-#define                 USB_EP_NI1_TXCSR  0xffc03e44   /* Control Status register for endpoint1 */
-#define                USB_EP_NI1_RXMAXP  0xffc03e48   /* Maximum packet size for Host Rx endpoint1 */
-#define                 USB_EP_NI1_RXCSR  0xffc03e4c   /* Control Status register for Host Rx endpoint1 */
-#define               USB_EP_NI1_RXCOUNT  0xffc03e50   /* Number of bytes received in endpoint1 FIFO */
-#define                USB_EP_NI1_TXTYPE  0xffc03e54   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint1 */
-#define            USB_EP_NI1_TXINTERVAL  0xffc03e58   /* Sets the NAK response timeout on Endpoint1 */
-#define                USB_EP_NI1_RXTYPE  0xffc03e5c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint1 */
-#define            USB_EP_NI1_RXINTERVAL  0xffc03e60   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint1 */
-
-/* USB Endpoint 2 Control Registers */
-
-#define               USB_EP_NI1_TXCOUNT  0xffc03e68   /* Number of bytes to be written to the+H102 endpoint1 Tx FIFO */
-#define                USB_EP_NI2_TXMAXP  0xffc03e80   /* Maximum packet size for Host Tx endpoint2 */
-#define                 USB_EP_NI2_TXCSR  0xffc03e84   /* Control Status register for endpoint2 */
-#define                USB_EP_NI2_RXMAXP  0xffc03e88   /* Maximum packet size for Host Rx endpoint2 */
-#define                 USB_EP_NI2_RXCSR  0xffc03e8c   /* Control Status register for Host Rx endpoint2 */
-#define               USB_EP_NI2_RXCOUNT  0xffc03e90   /* Number of bytes received in endpoint2 FIFO */
-#define                USB_EP_NI2_TXTYPE  0xffc03e94   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint2 */
-#define            USB_EP_NI2_TXINTERVAL  0xffc03e98   /* Sets the NAK response timeout on Endpoint2 */
-#define                USB_EP_NI2_RXTYPE  0xffc03e9c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint2 */
-#define            USB_EP_NI2_RXINTERVAL  0xffc03ea0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint2 */
-
-/* USB Endpoint 3 Control Registers */
-
-#define               USB_EP_NI2_TXCOUNT  0xffc03ea8   /* Number of bytes to be written to the endpoint2 Tx FIFO */
-#define                USB_EP_NI3_TXMAXP  0xffc03ec0   /* Maximum packet size for Host Tx endpoint3 */
-#define                 USB_EP_NI3_TXCSR  0xffc03ec4   /* Control Status register for endpoint3 */
-#define                USB_EP_NI3_RXMAXP  0xffc03ec8   /* Maximum packet size for Host Rx endpoint3 */
-#define                 USB_EP_NI3_RXCSR  0xffc03ecc   /* Control Status register for Host Rx endpoint3 */
-#define               USB_EP_NI3_RXCOUNT  0xffc03ed0   /* Number of bytes received in endpoint3 FIFO */
-#define                USB_EP_NI3_TXTYPE  0xffc03ed4   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint3 */
-#define            USB_EP_NI3_TXINTERVAL  0xffc03ed8   /* Sets the NAK response timeout on Endpoint3 */
-#define                USB_EP_NI3_RXTYPE  0xffc03edc   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint3 */
-#define            USB_EP_NI3_RXINTERVAL  0xffc03ee0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint3 */
-
-/* USB Endpoint 4 Control Registers */
-
-#define               USB_EP_NI3_TXCOUNT  0xffc03ee8   /* Number of bytes to be written to the H124endpoint3 Tx FIFO */
-#define                USB_EP_NI4_TXMAXP  0xffc03f00   /* Maximum packet size for Host Tx endpoint4 */
-#define                 USB_EP_NI4_TXCSR  0xffc03f04   /* Control Status register for endpoint4 */
-#define                USB_EP_NI4_RXMAXP  0xffc03f08   /* Maximum packet size for Host Rx endpoint4 */
-#define                 USB_EP_NI4_RXCSR  0xffc03f0c   /* Control Status register for Host Rx endpoint4 */
-#define               USB_EP_NI4_RXCOUNT  0xffc03f10   /* Number of bytes received in endpoint4 FIFO */
-#define                USB_EP_NI4_TXTYPE  0xffc03f14   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint4 */
-#define            USB_EP_NI4_TXINTERVAL  0xffc03f18   /* Sets the NAK response timeout on Endpoint4 */
-#define                USB_EP_NI4_RXTYPE  0xffc03f1c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint4 */
-#define            USB_EP_NI4_RXINTERVAL  0xffc03f20   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint4 */
-
-/* USB Endpoint 5 Control Registers */
-
-#define               USB_EP_NI4_TXCOUNT  0xffc03f28   /* Number of bytes to be written to the endpoint4 Tx FIFO */
-#define                USB_EP_NI5_TXMAXP  0xffc03f40   /* Maximum packet size for Host Tx endpoint5 */
-#define                 USB_EP_NI5_TXCSR  0xffc03f44   /* Control Status register for endpoint5 */
-#define                USB_EP_NI5_RXMAXP  0xffc03f48   /* Maximum packet size for Host Rx endpoint5 */
-#define                 USB_EP_NI5_RXCSR  0xffc03f4c   /* Control Status register for Host Rx endpoint5 */
-#define               USB_EP_NI5_RXCOUNT  0xffc03f50   /* Number of bytes received in endpoint5 FIFO */
-#define                USB_EP_NI5_TXTYPE  0xffc03f54   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint5 */
-#define            USB_EP_NI5_TXINTERVAL  0xffc03f58   /* Sets the NAK response timeout on Endpoint5 */
-#define                USB_EP_NI5_RXTYPE  0xffc03f5c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint5 */
-#define            USB_EP_NI5_RXINTERVAL  0xffc03f60   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint5 */
-
-/* USB Endpoint 6 Control Registers */
-
-#define               USB_EP_NI5_TXCOUNT  0xffc03f68   /* Number of bytes to be written to the H145endpoint5 Tx FIFO */
-#define                USB_EP_NI6_TXMAXP  0xffc03f80   /* Maximum packet size for Host Tx endpoint6 */
-#define                 USB_EP_NI6_TXCSR  0xffc03f84   /* Control Status register for endpoint6 */
-#define                USB_EP_NI6_RXMAXP  0xffc03f88   /* Maximum packet size for Host Rx endpoint6 */
-#define                 USB_EP_NI6_RXCSR  0xffc03f8c   /* Control Status register for Host Rx endpoint6 */
-#define               USB_EP_NI6_RXCOUNT  0xffc03f90   /* Number of bytes received in endpoint6 FIFO */
-#define                USB_EP_NI6_TXTYPE  0xffc03f94   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint6 */
-#define            USB_EP_NI6_TXINTERVAL  0xffc03f98   /* Sets the NAK response timeout on Endpoint6 */
-#define                USB_EP_NI6_RXTYPE  0xffc03f9c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint6 */
-#define            USB_EP_NI6_RXINTERVAL  0xffc03fa0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint6 */
-
-/* USB Endpoint 7 Control Registers */
-
-#define               USB_EP_NI6_TXCOUNT  0xffc03fa8   /* Number of bytes to be written to the endpoint6 Tx FIFO */
-#define                USB_EP_NI7_TXMAXP  0xffc03fc0   /* Maximum packet size for Host Tx endpoint7 */
-#define                 USB_EP_NI7_TXCSR  0xffc03fc4   /* Control Status register for endpoint7 */
-#define                USB_EP_NI7_RXMAXP  0xffc03fc8   /* Maximum packet size for Host Rx endpoint7 */
-#define                 USB_EP_NI7_RXCSR  0xffc03fcc   /* Control Status register for Host Rx endpoint7 */
-#define               USB_EP_NI7_RXCOUNT  0xffc03fd0   /* Number of bytes received in endpoint7 FIFO */
-#define                USB_EP_NI7_TXTYPE  0xffc03fd4   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint7 */
-#define            USB_EP_NI7_TXINTERVAL  0xffc03fd8   /* Sets the NAK response timeout on Endpoint7 */
-#define                USB_EP_NI7_RXTYPE  0xffc03fdc   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint7 */
-#define            USB_EP_NI7_RXINTERVAL  0xffc03ff0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint7 */
-#define               USB_EP_NI7_TXCOUNT  0xffc03ff8   /* Number of bytes to be written to the endpoint7 Tx FIFO */
-#define                USB_DMA_INTERRUPT  0xffc04000   /* Indicates pending interrupts for the DMA channels */
-
-/* USB Channel 0 Config Registers */
-
-#define                  USB_DMA0CONTROL  0xffc04004   /* DMA master channel 0 configuration */
-#define                  USB_DMA0ADDRLOW  0xffc04008   /* Lower 16-bits of memory source/destination address for DMA master channel 0 */
-#define                 USB_DMA0ADDRHIGH  0xffc0400c   /* Upper 16-bits of memory source/destination address for DMA master channel 0 */
-#define                 USB_DMA0COUNTLOW  0xffc04010   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 0 */
-#define                USB_DMA0COUNTHIGH  0xffc04014   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 0 */
-
-/* USB Channel 1 Config Registers */
-
-#define                  USB_DMA1CONTROL  0xffc04024   /* DMA master channel 1 configuration */
-#define                  USB_DMA1ADDRLOW  0xffc04028   /* Lower 16-bits of memory source/destination address for DMA master channel 1 */
-#define                 USB_DMA1ADDRHIGH  0xffc0402c   /* Upper 16-bits of memory source/destination address for DMA master channel 1 */
-#define                 USB_DMA1COUNTLOW  0xffc04030   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 1 */
-#define                USB_DMA1COUNTHIGH  0xffc04034   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 1 */
-
-/* USB Channel 2 Config Registers */
-
-#define                  USB_DMA2CONTROL  0xffc04044   /* DMA master channel 2 configuration */
-#define                  USB_DMA2ADDRLOW  0xffc04048   /* Lower 16-bits of memory source/destination address for DMA master channel 2 */
-#define                 USB_DMA2ADDRHIGH  0xffc0404c   /* Upper 16-bits of memory source/destination address for DMA master channel 2 */
-#define                 USB_DMA2COUNTLOW  0xffc04050   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 2 */
-#define                USB_DMA2COUNTHIGH  0xffc04054   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 2 */
-
-/* USB Channel 3 Config Registers */
-
-#define                  USB_DMA3CONTROL  0xffc04064   /* DMA master channel 3 configuration */
-#define                  USB_DMA3ADDRLOW  0xffc04068   /* Lower 16-bits of memory source/destination address for DMA master channel 3 */
-#define                 USB_DMA3ADDRHIGH  0xffc0406c   /* Upper 16-bits of memory source/destination address for DMA master channel 3 */
-#define                 USB_DMA3COUNTLOW  0xffc04070   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 3 */
-#define                USB_DMA3COUNTHIGH  0xffc04074   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 3 */
-
-/* USB Channel 4 Config Registers */
-
-#define                  USB_DMA4CONTROL  0xffc04084   /* DMA master channel 4 configuration */
-#define                  USB_DMA4ADDRLOW  0xffc04088   /* Lower 16-bits of memory source/destination address for DMA master channel 4 */
-#define                 USB_DMA4ADDRHIGH  0xffc0408c   /* Upper 16-bits of memory source/destination address for DMA master channel 4 */
-#define                 USB_DMA4COUNTLOW  0xffc04090   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 4 */
-#define                USB_DMA4COUNTHIGH  0xffc04094   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 4 */
-
-/* USB Channel 5 Config Registers */
-
-#define                  USB_DMA5CONTROL  0xffc040a4   /* DMA master channel 5 configuration */
-#define                  USB_DMA5ADDRLOW  0xffc040a8   /* Lower 16-bits of memory source/destination address for DMA master channel 5 */
-#define                 USB_DMA5ADDRHIGH  0xffc040ac   /* Upper 16-bits of memory source/destination address for DMA master channel 5 */
-#define                 USB_DMA5COUNTLOW  0xffc040b0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 5 */
-#define                USB_DMA5COUNTHIGH  0xffc040b4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 5 */
-
-/* USB Channel 6 Config Registers */
-
-#define                  USB_DMA6CONTROL  0xffc040c4   /* DMA master channel 6 configuration */
-#define                  USB_DMA6ADDRLOW  0xffc040c8   /* Lower 16-bits of memory source/destination address for DMA master channel 6 */
-#define                 USB_DMA6ADDRHIGH  0xffc040cc   /* Upper 16-bits of memory source/destination address for DMA master channel 6 */
-#define                 USB_DMA6COUNTLOW  0xffc040d0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 6 */
-#define                USB_DMA6COUNTHIGH  0xffc040d4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 6 */
-
-/* USB Channel 7 Config Registers */
-
-#define                  USB_DMA7CONTROL  0xffc040e4   /* DMA master channel 7 configuration */
-#define                  USB_DMA7ADDRLOW  0xffc040e8   /* Lower 16-bits of memory source/destination address for DMA master channel 7 */
-#define                 USB_DMA7ADDRHIGH  0xffc040ec   /* Upper 16-bits of memory source/destination address for DMA master channel 7 */
-#define                 USB_DMA7COUNTLOW  0xffc040f0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 7 */
-#define                USB_DMA7COUNTHIGH  0xffc040f4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 7 */
-
-/* Keypad Registers */
-
-#define                         KPAD_CTL  0xffc04100   /* Controls keypad module enable and disable */
-#define                    KPAD_PRESCALE  0xffc04104   /* Establish a time base for programing the KPAD_MSEL register */
-#define                        KPAD_MSEL  0xffc04108   /* Selects delay parameters for keypad interface sensitivity */
-#define                      KPAD_ROWCOL  0xffc0410c   /* Captures the row and column output values of the keys pressed */
-#define                        KPAD_STAT  0xffc04110   /* Holds and clears the status of the keypad interface interrupt */
-#define                    KPAD_SOFTEVAL  0xffc04114   /* Lets software force keypad interface to check for keys being pressed */
-
-/* Pixel Compositor (PIXC) Registers */
-
-#define                         PIXC_CTL  0xffc04400   /* Overlay enable, resampling mode, I/O data format, transparency enable, watermark level, FIFO status */
-#define                         PIXC_PPL  0xffc04404   /* Holds the number of pixels per line of the display */
-#define                         PIXC_LPF  0xffc04408   /* Holds the number of lines per frame of the display */
-#define                     PIXC_AHSTART  0xffc0440c   /* Contains horizontal start pixel information of the overlay data (set A) */
-#define                       PIXC_AHEND  0xffc04410   /* Contains horizontal end pixel information of the overlay data (set A) */
-#define                     PIXC_AVSTART  0xffc04414   /* Contains vertical start pixel information of the overlay data (set A) */
-#define                       PIXC_AVEND  0xffc04418   /* Contains vertical end pixel information of the overlay data (set A) */
-#define                     PIXC_ATRANSP  0xffc0441c   /* Contains the transparency ratio (set A) */
-#define                     PIXC_BHSTART  0xffc04420   /* Contains horizontal start pixel information of the overlay data (set B) */
-#define                       PIXC_BHEND  0xffc04424   /* Contains horizontal end pixel information of the overlay data (set B) */
-#define                     PIXC_BVSTART  0xffc04428   /* Contains vertical start pixel information of the overlay data (set B) */
-#define                       PIXC_BVEND  0xffc0442c   /* Contains vertical end pixel information of the overlay data (set B) */
-#define                     PIXC_BTRANSP  0xffc04430   /* Contains the transparency ratio (set B) */
-#define                    PIXC_INTRSTAT  0xffc0443c   /* Overlay interrupt configuration/status */
-#define                       PIXC_RYCON  0xffc04440   /* Color space conversion matrix register. Contains the R/Y conversion coefficients */
-#define                       PIXC_GUCON  0xffc04444   /* Color space conversion matrix register. Contains the G/U conversion coefficients */
-#define                       PIXC_BVCON  0xffc04448   /* Color space conversion matrix register. Contains the B/V conversion coefficients */
-#define                      PIXC_CCBIAS  0xffc0444c   /* Bias values for the color space conversion matrix */
-#define                          PIXC_TC  0xffc04450   /* Holds the transparent color value */
-
-/* Handshake MDMA 0 Registers */
-
-#define                   HMDMA0_CONTROL  0xffc04500   /* Handshake MDMA0 Control Register */
-#define                    HMDMA0_ECINIT  0xffc04504   /* Handshake MDMA0 Initial Edge Count Register */
-#define                    HMDMA0_BCINIT  0xffc04508   /* Handshake MDMA0 Initial Block Count Register */
-#define                  HMDMA0_ECURGENT  0xffc0450c   /* Handshake MDMA0 Urgent Edge Count Threshold Register */
-#define                HMDMA0_ECOVERFLOW  0xffc04510   /* Handshake MDMA0 Edge Count Overflow Interrupt Register */
-#define                    HMDMA0_ECOUNT  0xffc04514   /* Handshake MDMA0 Current Edge Count Register */
-#define                    HMDMA0_BCOUNT  0xffc04518   /* Handshake MDMA0 Current Block Count Register */
-
-/* Handshake MDMA 1 Registers */
-
-#define                   HMDMA1_CONTROL  0xffc04540   /* Handshake MDMA1 Control Register */
-#define                    HMDMA1_ECINIT  0xffc04544   /* Handshake MDMA1 Initial Edge Count Register */
-#define                    HMDMA1_BCINIT  0xffc04548   /* Handshake MDMA1 Initial Block Count Register */
-#define                  HMDMA1_ECURGENT  0xffc0454c   /* Handshake MDMA1 Urgent Edge Count Threshold Register */
-#define                HMDMA1_ECOVERFLOW  0xffc04550   /* Handshake MDMA1 Edge Count Overflow Interrupt Register */
-#define                    HMDMA1_ECOUNT  0xffc04554   /* Handshake MDMA1 Current Edge Count Register */
-#define                    HMDMA1_BCOUNT  0xffc04558   /* Handshake MDMA1 Current Block Count Register */
-
-
-/* ********************************************************** */
-/*     SINGLE BIT MACRO PAIRS (bit mask and negated one)      */
-/*     and MULTI BIT READ MACROS                              */
-/* ********************************************************** */
-
-/* Bit masks for PIXC_CTL */
-
-#define                   PIXC_EN  0x1        /* Pixel Compositor Enable */
-#define                  OVR_A_EN  0x2        /* Overlay A Enable */
-#define                  OVR_B_EN  0x4        /* Overlay B Enable */
-#define                  IMG_FORM  0x8        /* Image Data Format */
-#define                  OVR_FORM  0x10       /* Overlay Data Format */
-#define                  OUT_FORM  0x20       /* Output Data Format */
-#define                   UDS_MOD  0x40       /* Resampling Mode */
-#define                     TC_EN  0x80       /* Transparent Color Enable */
-#define                  IMG_STAT  0x300      /* Image FIFO Status */
-#define                  OVR_STAT  0xc00      /* Overlay FIFO Status */
-#define                    WM_LVL  0x3000     /* FIFO Watermark Level */
-
-/* Bit masks for PIXC_AHSTART */
-
-#define                  A_HSTART  0xfff      /* Horizontal Start Coordinates */
-
-/* Bit masks for PIXC_AHEND */
-
-#define                    A_HEND  0xfff      /* Horizontal End Coordinates */
-
-/* Bit masks for PIXC_AVSTART */
-
-#define                  A_VSTART  0x3ff      /* Vertical Start Coordinates */
-
-/* Bit masks for PIXC_AVEND */
-
-#define                    A_VEND  0x3ff      /* Vertical End Coordinates */
-
-/* Bit masks for PIXC_ATRANSP */
-
-#define                  A_TRANSP  0xf        /* Transparency Value */
-
-/* Bit masks for PIXC_BHSTART */
-
-#define                  B_HSTART  0xfff      /* Horizontal Start Coordinates */
-
-/* Bit masks for PIXC_BHEND */
-
-#define                    B_HEND  0xfff      /* Horizontal End Coordinates */
-
-/* Bit masks for PIXC_BVSTART */
-
-#define                  B_VSTART  0x3ff      /* Vertical Start Coordinates */
-
-/* Bit masks for PIXC_BVEND */
-
-#define                    B_VEND  0x3ff      /* Vertical End Coordinates */
-
-/* Bit masks for PIXC_BTRANSP */
-
-#define                  B_TRANSP  0xf        /* Transparency Value */
-
-/* Bit masks for PIXC_INTRSTAT */
-
-#define                OVR_INT_EN  0x1        /* Interrupt at End of Last Valid Overlay */
-#define                FRM_INT_EN  0x2        /* Interrupt at End of Frame */
-#define              OVR_INT_STAT  0x4        /* Overlay Interrupt Status */
-#define              FRM_INT_STAT  0x8        /* Frame Interrupt Status */
-
-/* Bit masks for PIXC_RYCON */
-
-#define                       A11  0x3ff      /* A11 in the Coefficient Matrix */
-#define                       A12  0xffc00    /* A12 in the Coefficient Matrix */
-#define                       A13  0x3ff00000 /* A13 in the Coefficient Matrix */
-#define                  RY_MULT4  0x40000000 /* Multiply Row by 4 */
-
-/* Bit masks for PIXC_GUCON */
-
-#define                       A21  0x3ff      /* A21 in the Coefficient Matrix */
-#define                       A22  0xffc00    /* A22 in the Coefficient Matrix */
-#define                       A23  0x3ff00000 /* A23 in the Coefficient Matrix */
-#define                  GU_MULT4  0x40000000 /* Multiply Row by 4 */
-
-/* Bit masks for PIXC_BVCON */
-
-#define                       A31  0x3ff      /* A31 in the Coefficient Matrix */
-#define                       A32  0xffc00    /* A32 in the Coefficient Matrix */
-#define                       A33  0x3ff00000 /* A33 in the Coefficient Matrix */
-#define                  BV_MULT4  0x40000000 /* Multiply Row by 4 */
-
-/* Bit masks for PIXC_CCBIAS */
-
-#define                       A14  0x3ff      /* A14 in the Bias Vector */
-#define                       A24  0xffc00    /* A24 in the Bias Vector */
-#define                       A34  0x3ff00000 /* A34 in the Bias Vector */
-
-/* Bit masks for PIXC_TC */
-
-#define                  RY_TRANS  0xff       /* Transparent Color - R/Y Component */
-#define                  GU_TRANS  0xff00     /* Transparent Color - G/U Component */
-#define                  BV_TRANS  0xff0000   /* Transparent Color - B/V Component */
-
-/* Bit masks for HOST_CONTROL */
-
-#define                   HOST_EN  0x1        /* Host Enable */
-#define                  HOST_END  0x2        /* Host Endianess */
-#define                 DATA_SIZE  0x4        /* Data Size */
-#define                  HOST_RST  0x8        /* Host Reset */
-#define                  HRDY_OVR  0x20       /* Host Ready Override */
-#define                  INT_MODE  0x40       /* Interrupt Mode */
-#define                     BT_EN  0x80       /* Bus Timeout Enable */
-#define                       EHW  0x100      /* Enable Host Write */
-#define                       EHR  0x200      /* Enable Host Read */
-#define                       BDR  0x400      /* Burst DMA Requests */
-
-/* Bit masks for HOST_STATUS */
-
-#define                 DMA_READY  0x1        /* DMA Ready */
-#define                  FIFOFULL  0x2        /* FIFO Full */
-#define                 FIFOEMPTY  0x4        /* FIFO Empty */
-#define              DMA_COMPLETE  0x8        /* DMA Complete */
-#define                      HSHK  0x10       /* Host Handshake */
-#define                 HSTIMEOUT  0x20       /* Host Timeout */
-#define                      HIRQ  0x40       /* Host Interrupt Request */
-#define                ALLOW_CNFG  0x80       /* Allow New Configuration */
-#define                   DMA_DIR  0x100      /* DMA Direction */
-#define                       BTE  0x200      /* Bus Timeout Enabled */
-
-/* Bit masks for HOST_TIMEOUT */
-
-#define             COUNT_TIMEOUT  0x7ff      /* Host Timeout count */
-
-/* Bit masks for KPAD_CTL */
-
-#define                   KPAD_EN  0x1        /* Keypad Enable */
-#define              KPAD_IRQMODE  0x6        /* Key Press Interrupt Enable */
-#define                KPAD_ROWEN  0x1c00     /* Row Enable Width */
-#define                KPAD_COLEN  0xe000     /* Column Enable Width */
-
-/* Bit masks for KPAD_PRESCALE */
-
-#define         KPAD_PRESCALE_VAL  0x3f       /* Key Prescale Value */
-
-/* Bit masks for KPAD_MSEL */
-
-#define                DBON_SCALE  0xff       /* Debounce Scale Value */
-#define              COLDRV_SCALE  0xff00     /* Column Driver Scale Value */
-
-/* Bit masks for KPAD_ROWCOL */
-
-#define                  KPAD_ROW  0xff       /* Rows Pressed */
-#define                  KPAD_COL  0xff00     /* Columns Pressed */
-
-/* Bit masks for KPAD_STAT */
-
-#define                  KPAD_IRQ  0x1        /* Keypad Interrupt Status */
-#define              KPAD_MROWCOL  0x6        /* Multiple Row/Column Keypress Status */
-#define              KPAD_PRESSED  0x8        /* Key press current status */
-
-/* Bit masks for KPAD_SOFTEVAL */
-
-#define           KPAD_SOFTEVAL_E  0x2        /* Software Programmable Force Evaluate */
-
-/* Bit masks for SDH_COMMAND */
-
-#define                   CMD_IDX  0x3f       /* Command Index */
-#define                   CMD_RSP  0x40       /* Response */
-#define                 CMD_L_RSP  0x80       /* Long Response */
-#define                 CMD_INT_E  0x100      /* Command Interrupt */
-#define                CMD_PEND_E  0x200      /* Command Pending */
-#define                     CMD_E  0x400      /* Command Enable */
-
-/* Bit masks for SDH_PWR_CTL */
-
-#define                    PWR_ON  0x3        /* Power On */
-#if 0
-#define                       TBD  0x3c       /* TBD */
-#endif
-#define                 SD_CMD_OD  0x40       /* Open Drain Output */
-#define                   ROD_CTL  0x80       /* Rod Control */
-
-/* Bit masks for SDH_CLK_CTL */
-
-#define                    CLKDIV  0xff       /* MC_CLK Divisor */
-#define                     CLK_E  0x100      /* MC_CLK Bus Clock Enable */
-#define                  PWR_SV_E  0x200      /* Power Save Enable */
-#define             CLKDIV_BYPASS  0x400      /* Bypass Divisor */
-#define                  WIDE_BUS  0x800      /* Wide Bus Mode Enable */
-
-/* Bit masks for SDH_RESP_CMD */
-
-#define                  RESP_CMD  0x3f       /* Response Command */
-
-/* Bit masks for SDH_DATA_CTL */
-
-#define                     DTX_E  0x1        /* Data Transfer Enable */
-#define                   DTX_DIR  0x2        /* Data Transfer Direction */
-#define                  DTX_MODE  0x4        /* Data Transfer Mode */
-#define                 DTX_DMA_E  0x8        /* Data Transfer DMA Enable */
-#define              DTX_BLK_LGTH  0xf0       /* Data Transfer Block Length */
-
-/* Bit masks for SDH_STATUS */
-
-#define              CMD_CRC_FAIL  0x1        /* CMD CRC Fail */
-#define              DAT_CRC_FAIL  0x2        /* Data CRC Fail */
-#define               CMD_TIME_OUT  0x4        /* CMD Time Out */
-#define               DAT_TIME_OUT  0x8        /* Data Time Out */
-#define               TX_UNDERRUN  0x10       /* Transmit Underrun */
-#define                RX_OVERRUN  0x20       /* Receive Overrun */
-#define              CMD_RESP_END  0x40       /* CMD Response End */
-#define                  CMD_SENT  0x80       /* CMD Sent */
-#define                   DAT_END  0x100      /* Data End */
-#define             START_BIT_ERR  0x200      /* Start Bit Error */
-#define               DAT_BLK_END  0x400      /* Data Block End */
-#define                   CMD_ACT  0x800      /* CMD Active */
-#define                    TX_ACT  0x1000     /* Transmit Active */
-#define                    RX_ACT  0x2000     /* Receive Active */
-#define              TX_FIFO_STAT  0x4000     /* Transmit FIFO Status */
-#define              RX_FIFO_STAT  0x8000     /* Receive FIFO Status */
-#define              TX_FIFO_FULL  0x10000    /* Transmit FIFO Full */
-#define              RX_FIFO_FULL  0x20000    /* Receive FIFO Full */
-#define              TX_FIFO_ZERO  0x40000    /* Transmit FIFO Empty */
-#define               RX_DAT_ZERO  0x80000    /* Receive FIFO Empty */
-#define                TX_DAT_RDY  0x100000   /* Transmit Data Available */
-#define               RX_FIFO_RDY  0x200000   /* Receive Data Available */
-
-/* Bit masks for SDH_STATUS_CLR */
-
-#define         CMD_CRC_FAIL_STAT  0x1        /* CMD CRC Fail Status */
-#define         DAT_CRC_FAIL_STAT  0x2        /* Data CRC Fail Status */
-#define          CMD_TIMEOUT_STAT  0x4        /* CMD Time Out Status */
-#define          DAT_TIMEOUT_STAT  0x8        /* Data Time Out status */
-#define          TX_UNDERRUN_STAT  0x10       /* Transmit Underrun Status */
-#define           RX_OVERRUN_STAT  0x20       /* Receive Overrun Status */
-#define         CMD_RESP_END_STAT  0x40       /* CMD Response End Status */
-#define             CMD_SENT_STAT  0x80       /* CMD Sent Status */
-#define              DAT_END_STAT  0x100      /* Data End Status */
-#define        START_BIT_ERR_STAT  0x200      /* Start Bit Error Status */
-#define          DAT_BLK_END_STAT  0x400      /* Data Block End Status */
-
-/* Bit masks for SDH_MASK0 */
-
-#define         CMD_CRC_FAIL_MASK  0x1        /* CMD CRC Fail Mask */
-#define         DAT_CRC_FAIL_MASK  0x2        /* Data CRC Fail Mask */
-#define          CMD_TIMEOUT_MASK  0x4        /* CMD Time Out Mask */
-#define          DAT_TIMEOUT_MASK  0x8        /* Data Time Out Mask */
-#define          TX_UNDERRUN_MASK  0x10       /* Transmit Underrun Mask */
-#define           RX_OVERRUN_MASK  0x20       /* Receive Overrun Mask */
-#define         CMD_RESP_END_MASK  0x40       /* CMD Response End Mask */
-#define             CMD_SENT_MASK  0x80       /* CMD Sent Mask */
-#define              DAT_END_MASK  0x100      /* Data End Mask */
-#define        START_BIT_ERR_MASK  0x200      /* Start Bit Error Mask */
-#define          DAT_BLK_END_MASK  0x400      /* Data Block End Mask */
-#define              CMD_ACT_MASK  0x800      /* CMD Active Mask */
-#define               TX_ACT_MASK  0x1000     /* Transmit Active Mask */
-#define               RX_ACT_MASK  0x2000     /* Receive Active Mask */
-#define         TX_FIFO_STAT_MASK  0x4000     /* Transmit FIFO Status Mask */
-#define         RX_FIFO_STAT_MASK  0x8000     /* Receive FIFO Status Mask */
-#define         TX_FIFO_FULL_MASK  0x10000    /* Transmit FIFO Full Mask */
-#define         RX_FIFO_FULL_MASK  0x20000    /* Receive FIFO Full Mask */
-#define         TX_FIFO_ZERO_MASK  0x40000    /* Transmit FIFO Empty Mask */
-#define          RX_DAT_ZERO_MASK  0x80000    /* Receive FIFO Empty Mask */
-#define           TX_DAT_RDY_MASK  0x100000   /* Transmit Data Available Mask */
-#define          RX_FIFO_RDY_MASK  0x200000   /* Receive Data Available Mask */
-
-/* Bit masks for SDH_FIFO_CNT */
-
-#define                FIFO_COUNT  0x7fff     /* FIFO Count */
-
-/* Bit masks for SDH_E_STATUS */
-
-#define              SDIO_INT_DET  0x2        /* SDIO Int Detected */
-#define               SD_CARD_DET  0x10       /* SD Card Detect */
-
-/* Bit masks for SDH_E_MASK */
-
-#define                  SDIO_MSK  0x2        /* Mask SDIO Int Detected */
-#define                   SCD_MSK  0x40       /* Mask Card Detect */
-
-/* Bit masks for SDH_CFG */
-
-#define                   CLKS_EN  0x1        /* Clocks Enable */
-#define                      SD4E  0x4        /* SDIO 4-Bit Enable */
-#define                       MWE  0x8        /* Moving Window Enable */
-#define                    SD_RST  0x10       /* SDMMC Reset */
-#define                 PUP_SDDAT  0x20       /* Pull-up SD_DAT */
-#define                PUP_SDDAT3  0x40       /* Pull-up SD_DAT3 */
-#define                 PD_SDDAT3  0x80       /* Pull-down SD_DAT3 */
-
-/* Bit masks for SDH_RD_WAIT_EN */
-
-#define                       RWR  0x1        /* Read Wait Request */
-
-/* Bit masks for ATAPI_CONTROL */
-
-#define                 PIO_START  0x1        /* Start PIO/Reg Op */
-#define               MULTI_START  0x2        /* Start Multi-DMA Op */
-#define               ULTRA_START  0x4        /* Start Ultra-DMA Op */
-#define                  XFER_DIR  0x8        /* Transfer Direction */
-#define                  IORDY_EN  0x10       /* IORDY Enable */
-#define                FIFO_FLUSH  0x20       /* Flush FIFOs */
-#define                  SOFT_RST  0x40       /* Soft Reset */
-#define                   DEV_RST  0x80       /* Device Reset */
-#define                TFRCNT_RST  0x100      /* Trans Count Reset */
-#define               END_ON_TERM  0x200      /* End/Terminate Select */
-#define               PIO_USE_DMA  0x400      /* PIO-DMA Enable */
-#define          UDMAIN_FIFO_THRS  0xf000     /* Ultra DMA-IN FIFO Threshold */
-
-/* Bit masks for ATAPI_STATUS */
-
-#define               PIO_XFER_ON  0x1        /* PIO transfer in progress */
-#define             MULTI_XFER_ON  0x2        /* Multi-word DMA transfer in progress */
-#define             ULTRA_XFER_ON  0x4        /* Ultra DMA transfer in progress */
-#define               ULTRA_IN_FL  0xf0       /* Ultra DMA Input FIFO Level */
-
-/* Bit masks for ATAPI_DEV_ADDR */
-
-#define                  DEV_ADDR  0x1f       /* Device Address */
-
-/* Bit masks for ATAPI_INT_MASK */
-
-#define        ATAPI_DEV_INT_MASK  0x1        /* Device interrupt mask */
-#define             PIO_DONE_MASK  0x2        /* PIO transfer done interrupt mask */
-#define           MULTI_DONE_MASK  0x4        /* Multi-DMA transfer done interrupt mask */
-#define          UDMAIN_DONE_MASK  0x8        /* Ultra-DMA in transfer done interrupt mask */
-#define         UDMAOUT_DONE_MASK  0x10       /* Ultra-DMA out transfer done interrupt mask */
-#define       HOST_TERM_XFER_MASK  0x20       /* Host terminate current transfer interrupt mask */
-#define           MULTI_TERM_MASK  0x40       /* Device terminate Multi-DMA transfer interrupt mask */
-#define          UDMAIN_TERM_MASK  0x80       /* Device terminate Ultra-DMA-in transfer interrupt mask */
-#define         UDMAOUT_TERM_MASK  0x100      /* Device terminate Ultra-DMA-out transfer interrupt mask */
-
-/* Bit masks for ATAPI_INT_STATUS */
-
-#define             ATAPI_DEV_INT  0x1        /* Device interrupt status */
-#define              PIO_DONE_INT  0x2        /* PIO transfer done interrupt status */
-#define            MULTI_DONE_INT  0x4        /* Multi-DMA transfer done interrupt status */
-#define           UDMAIN_DONE_INT  0x8        /* Ultra-DMA in transfer done interrupt status */
-#define          UDMAOUT_DONE_INT  0x10       /* Ultra-DMA out transfer done interrupt status */
-#define        HOST_TERM_XFER_INT  0x20       /* Host terminate current transfer interrupt status */
-#define            MULTI_TERM_INT  0x40       /* Device terminate Multi-DMA transfer interrupt status */
-#define           UDMAIN_TERM_INT  0x80       /* Device terminate Ultra-DMA-in transfer interrupt status */
-#define          UDMAOUT_TERM_INT  0x100      /* Device terminate Ultra-DMA-out transfer interrupt status */
-
-/* Bit masks for ATAPI_LINE_STATUS */
-
-#define                ATAPI_INTR  0x1        /* Device interrupt to host line status */
-#define                ATAPI_DASP  0x2        /* Device dasp to host line status */
-#define                ATAPI_CS0N  0x4        /* ATAPI chip select 0 line status */
-#define                ATAPI_CS1N  0x8        /* ATAPI chip select 1 line status */
-#define                ATAPI_ADDR  0x70       /* ATAPI address line status */
-#define              ATAPI_DMAREQ  0x80       /* ATAPI DMA request line status */
-#define             ATAPI_DMAACKN  0x100      /* ATAPI DMA acknowledge line status */
-#define               ATAPI_DIOWN  0x200      /* ATAPI write line status */
-#define               ATAPI_DIORN  0x400      /* ATAPI read line status */
-#define               ATAPI_IORDY  0x800      /* ATAPI IORDY line status */
-
-/* Bit masks for ATAPI_SM_STATE */
-
-#define                PIO_CSTATE  0xf        /* PIO mode state machine current state */
-#define                DMA_CSTATE  0xf0       /* DMA mode state machine current state */
-#define             UDMAIN_CSTATE  0xf00      /* Ultra DMA-In mode state machine current state */
-#define            UDMAOUT_CSTATE  0xf000     /* ATAPI IORDY line status */
-
-/* Bit masks for ATAPI_TERMINATE */
-
-#define           ATAPI_HOST_TERM  0x1        /* Host terminationation */
-
-/* Bit masks for ATAPI_REG_TIM_0 */
-
-#define                    T2_REG  0xff       /* End of cycle time for register access transfers */
-#define                  TEOC_REG  0xff00     /* Selects DIOR/DIOW pulsewidth */
-
-/* Bit masks for ATAPI_PIO_TIM_0 */
-
-#define                    T1_REG  0xf        /* Time from address valid to DIOR/DIOW */
-#define                T2_REG_PIO  0xff0      /* DIOR/DIOW pulsewidth */
-#define                    T4_REG  0xf000     /* DIOW data hold */
-
-/* Bit masks for ATAPI_PIO_TIM_1 */
-
-#define              TEOC_REG_PIO  0xff       /* End of cycle time for PIO access transfers. */
-
-/* Bit masks for ATAPI_MULTI_TIM_0 */
-
-#define                        TD  0xff       /* DIOR/DIOW asserted pulsewidth */
-#define                        TM  0xff00     /* Time from address valid to DIOR/DIOW */
-
-/* Bit masks for ATAPI_MULTI_TIM_1 */
-
-#define                       TKW  0xff       /* Selects DIOW negated pulsewidth */
-#define                       TKR  0xff00     /* Selects DIOR negated pulsewidth */
-
-/* Bit masks for ATAPI_MULTI_TIM_2 */
-
-#define                        TH  0xff       /* Selects DIOW data hold */
-#define                      TEOC  0xff00     /* Selects end of cycle for DMA */
-
-/* Bit masks for ATAPI_ULTRA_TIM_0 */
-
-#define                      TACK  0xff       /* Selects setup and hold times for TACK */
-#define                      TENV  0xff00     /* Selects envelope time */
-
-/* Bit masks for ATAPI_ULTRA_TIM_1 */
-
-#define                      TDVS  0xff       /* Selects data valid setup time */
-#define                 TCYC_TDVS  0xff00     /* Selects cycle time - TDVS time */
-
-/* Bit masks for ATAPI_ULTRA_TIM_2 */
-
-#define                       TSS  0xff       /* Selects time from STROBE edge to negation of DMARQ or assertion of STOP */
-#define                      TMLI  0xff00     /* Selects interlock time */
-
-/* Bit masks for ATAPI_ULTRA_TIM_3 */
-
-#define                      TZAH  0xff       /* Selects minimum delay required for output */
-#define               READY_PAUSE  0xff00     /* Selects ready to pause */
-
-/* Bit masks for TIMER_ENABLE1 */
-
-#define                    TIMEN8  0x1        /* Timer 8 Enable */
-#define                    TIMEN9  0x2        /* Timer 9 Enable */
-#define                   TIMEN10  0x4        /* Timer 10 Enable */
-
-/* Bit masks for TIMER_DISABLE1 */
-
-#define                   TIMDIS8  0x1        /* Timer 8 Disable */
-#define                   TIMDIS9  0x2        /* Timer 9 Disable */
-#define                  TIMDIS10  0x4        /* Timer 10 Disable */
-
-/* Bit masks for TIMER_STATUS1 */
-
-#define                    TIMIL8  0x1        /* Timer 8 Interrupt */
-#define                    TIMIL9  0x2        /* Timer 9 Interrupt */
-#define                   TIMIL10  0x4        /* Timer 10 Interrupt */
-#define                 TOVF_ERR8  0x10       /* Timer 8 Counter Overflow */
-#define                 TOVF_ERR9  0x20       /* Timer 9 Counter Overflow */
-#define                TOVF_ERR10  0x40       /* Timer 10 Counter Overflow */
-#define                     TRUN8  0x1000     /* Timer 8 Slave Enable Status */
-#define                     TRUN9  0x2000     /* Timer 9 Slave Enable Status */
-#define                    TRUN10  0x4000     /* Timer 10 Slave Enable Status */
-
-/* Bit masks for EPPI0 are obtained from common base header for EPPIx (EPPI1 and EPPI2) */
-
-/* Bit masks for USB_FADDR */
-
-#define          FUNCTION_ADDRESS  0x7f       /* Function address */
-
-/* Bit masks for USB_POWER */
-
-#define           ENABLE_SUSPENDM  0x1        /* enable SuspendM output */
-#define              SUSPEND_MODE  0x2        /* Suspend Mode indicator */
-#define               RESUME_MODE  0x4        /* DMA Mode */
-#define                     RESET  0x8        /* Reset indicator */
-#define                   HS_MODE  0x10       /* High Speed mode indicator */
-#define                 HS_ENABLE  0x20       /* high Speed Enable */
-#define                 SOFT_CONN  0x40       /* Soft connect */
-#define                ISO_UPDATE  0x80       /* Isochronous update */
-
-/* Bit masks for USB_INTRTX */
-
-#define                    EP0_TX  0x1        /* Tx Endpoint 0 interrupt */
-#define                    EP1_TX  0x2        /* Tx Endpoint 1 interrupt */
-#define                    EP2_TX  0x4        /* Tx Endpoint 2 interrupt */
-#define                    EP3_TX  0x8        /* Tx Endpoint 3 interrupt */
-#define                    EP4_TX  0x10       /* Tx Endpoint 4 interrupt */
-#define                    EP5_TX  0x20       /* Tx Endpoint 5 interrupt */
-#define                    EP6_TX  0x40       /* Tx Endpoint 6 interrupt */
-#define                    EP7_TX  0x80       /* Tx Endpoint 7 interrupt */
-
-/* Bit masks for USB_INTRRX */
-
-#define                    EP1_RX  0x2        /* Rx Endpoint 1 interrupt */
-#define                    EP2_RX  0x4        /* Rx Endpoint 2 interrupt */
-#define                    EP3_RX  0x8        /* Rx Endpoint 3 interrupt */
-#define                    EP4_RX  0x10       /* Rx Endpoint 4 interrupt */
-#define                    EP5_RX  0x20       /* Rx Endpoint 5 interrupt */
-#define                    EP6_RX  0x40       /* Rx Endpoint 6 interrupt */
-#define                    EP7_RX  0x80       /* Rx Endpoint 7 interrupt */
-
-/* Bit masks for USB_INTRTXE */
-
-#define                  EP0_TX_E  0x1        /* Endpoint 0 interrupt Enable */
-#define                  EP1_TX_E  0x2        /* Tx Endpoint 1 interrupt  Enable */
-#define                  EP2_TX_E  0x4        /* Tx Endpoint 2 interrupt  Enable */
-#define                  EP3_TX_E  0x8        /* Tx Endpoint 3 interrupt  Enable */
-#define                  EP4_TX_E  0x10       /* Tx Endpoint 4 interrupt  Enable */
-#define                  EP5_TX_E  0x20       /* Tx Endpoint 5 interrupt  Enable */
-#define                  EP6_TX_E  0x40       /* Tx Endpoint 6 interrupt  Enable */
-#define                  EP7_TX_E  0x80       /* Tx Endpoint 7 interrupt  Enable */
-
-/* Bit masks for USB_INTRRXE */
-
-#define                  EP1_RX_E  0x2        /* Rx Endpoint 1 interrupt  Enable */
-#define                  EP2_RX_E  0x4        /* Rx Endpoint 2 interrupt  Enable */
-#define                  EP3_RX_E  0x8        /* Rx Endpoint 3 interrupt  Enable */
-#define                  EP4_RX_E  0x10       /* Rx Endpoint 4 interrupt  Enable */
-#define                  EP5_RX_E  0x20       /* Rx Endpoint 5 interrupt  Enable */
-#define                  EP6_RX_E  0x40       /* Rx Endpoint 6 interrupt  Enable */
-#define                  EP7_RX_E  0x80       /* Rx Endpoint 7 interrupt  Enable */
-
-/* Bit masks for USB_INTRUSB */
-
-#define                 SUSPEND_B  0x1        /* Suspend indicator */
-#define                  RESUME_B  0x2        /* Resume indicator */
-#define          RESET_OR_BABLE_B  0x4        /* Reset/babble indicator */
-#define                     SOF_B  0x8        /* Start of frame */
-#define                    CONN_B  0x10       /* Connection indicator */
-#define                  DISCON_B  0x20       /* Disconnect indicator */
-#define             SESSION_REQ_B  0x40       /* Session Request */
-#define              VBUS_ERROR_B  0x80       /* Vbus threshold indicator */
-
-/* Bit masks for USB_INTRUSBE */
-
-#define                SUSPEND_BE  0x1        /* Suspend indicator int enable */
-#define                 RESUME_BE  0x2        /* Resume indicator int enable */
-#define         RESET_OR_BABLE_BE  0x4        /* Reset/babble indicator int enable */
-#define                    SOF_BE  0x8        /* Start of frame int enable */
-#define                   CONN_BE  0x10       /* Connection indicator int enable */
-#define                 DISCON_BE  0x20       /* Disconnect indicator int enable */
-#define            SESSION_REQ_BE  0x40       /* Session Request int enable */
-#define             VBUS_ERROR_BE  0x80       /* Vbus threshold indicator int enable */
-
-/* Bit masks for USB_FRAME */
-
-#define              FRAME_NUMBER  0x7ff      /* Frame number */
-
-/* Bit masks for USB_INDEX */
-
-#define         SELECTED_ENDPOINT  0xf        /* selected endpoint */
-
-/* Bit masks for USB_GLOBAL_CTL */
-
-#define                GLOBAL_ENA  0x1        /* enables USB module */
-#define                EP1_TX_ENA  0x2        /* Transmit endpoint 1 enable */
-#define                EP2_TX_ENA  0x4        /* Transmit endpoint 2 enable */
-#define                EP3_TX_ENA  0x8        /* Transmit endpoint 3 enable */
-#define                EP4_TX_ENA  0x10       /* Transmit endpoint 4 enable */
-#define                EP5_TX_ENA  0x20       /* Transmit endpoint 5 enable */
-#define                EP6_TX_ENA  0x40       /* Transmit endpoint 6 enable */
-#define                EP7_TX_ENA  0x80       /* Transmit endpoint 7 enable */
-#define                EP1_RX_ENA  0x100      /* Receive endpoint 1 enable */
-#define                EP2_RX_ENA  0x200      /* Receive endpoint 2 enable */
-#define                EP3_RX_ENA  0x400      /* Receive endpoint 3 enable */
-#define                EP4_RX_ENA  0x800      /* Receive endpoint 4 enable */
-#define                EP5_RX_ENA  0x1000     /* Receive endpoint 5 enable */
-#define                EP6_RX_ENA  0x2000     /* Receive endpoint 6 enable */
-#define                EP7_RX_ENA  0x4000     /* Receive endpoint 7 enable */
-
-/* Bit masks for USB_OTG_DEV_CTL */
-
-#define                   SESSION  0x1        /* session indicator */
-#define                  HOST_REQ  0x2        /* Host negotiation request */
-#define                 HOST_MODE  0x4        /* indicates USBDRC is a host */
-#define                     VBUS0  0x8        /* Vbus level indicator[0] */
-#define                     VBUS1  0x10       /* Vbus level indicator[1] */
-#define                     LSDEV  0x20       /* Low-speed indicator */
-#define                     FSDEV  0x40       /* Full or High-speed indicator */
-#define                  B_DEVICE  0x80       /* A' or 'B' device indicator */
-
-/* Bit masks for USB_OTG_VBUS_IRQ */
-
-#define             DRIVE_VBUS_ON  0x1        /* indicator to drive VBUS control circuit */
-#define            DRIVE_VBUS_OFF  0x2        /* indicator to shut off charge pump */
-#define           CHRG_VBUS_START  0x4        /* indicator for external circuit to start charging VBUS */
-#define             CHRG_VBUS_END  0x8        /* indicator for external circuit to end charging VBUS */
-#define        DISCHRG_VBUS_START  0x10       /* indicator to start discharging VBUS */
-#define          DISCHRG_VBUS_END  0x20       /* indicator to stop discharging VBUS */
-
-/* Bit masks for USB_OTG_VBUS_MASK */
-
-#define         DRIVE_VBUS_ON_ENA  0x1        /* enable DRIVE_VBUS_ON interrupt */
-#define        DRIVE_VBUS_OFF_ENA  0x2        /* enable DRIVE_VBUS_OFF interrupt */
-#define       CHRG_VBUS_START_ENA  0x4        /* enable CHRG_VBUS_START interrupt */
-#define         CHRG_VBUS_END_ENA  0x8        /* enable CHRG_VBUS_END interrupt */
-#define    DISCHRG_VBUS_START_ENA  0x10       /* enable DISCHRG_VBUS_START interrupt */
-#define      DISCHRG_VBUS_END_ENA  0x20       /* enable DISCHRG_VBUS_END interrupt */
-
-/* Bit masks for USB_CSR0 */
-
-#define                  RXPKTRDY  0x1        /* data packet receive indicator */
-#define                  TXPKTRDY  0x2        /* data packet in FIFO indicator */
-#define                STALL_SENT  0x4        /* STALL handshake sent */
-#define                   DATAEND  0x8        /* Data end indicator */
-#define                  SETUPEND  0x10       /* Setup end */
-#define                 SENDSTALL  0x20       /* Send STALL handshake */
-#define         SERVICED_RXPKTRDY  0x40       /* used to clear the RxPktRdy bit */
-#define         SERVICED_SETUPEND  0x80       /* used to clear the SetupEnd bit */
-#define                 FLUSHFIFO  0x100      /* flush endpoint FIFO */
-#define          STALL_RECEIVED_H  0x4        /* STALL handshake received host mode */
-#define                SETUPPKT_H  0x8        /* send Setup token host mode */
-#define                   ERROR_H  0x10       /* timeout error indicator host mode */
-#define                  REQPKT_H  0x20       /* Request an IN transaction host mode */
-#define               STATUSPKT_H  0x40       /* Status stage transaction host mode */
-#define             NAK_TIMEOUT_H  0x80       /* EP0 halted after a NAK host mode */
-
-/* Bit masks for USB_COUNT0 */
-
-#define              EP0_RX_COUNT  0x7f       /* number of received bytes in EP0 FIFO */
-
-/* Bit masks for USB_NAKLIMIT0 */
-
-#define             EP0_NAK_LIMIT  0x1f       /* number of frames/micro frames after which EP0 timeouts */
-
-/* Bit masks for USB_TX_MAX_PACKET */
-
-#define         MAX_PACKET_SIZE_T  0x7ff      /* maximum data pay load in a frame */
-
-/* Bit masks for USB_RX_MAX_PACKET */
-
-#define         MAX_PACKET_SIZE_R  0x7ff      /* maximum data pay load in a frame */
-
-/* Bit masks for USB_TXCSR */
-
-#define                TXPKTRDY_T  0x1        /* data packet in FIFO indicator */
-#define          FIFO_NOT_EMPTY_T  0x2        /* FIFO not empty */
-#define                UNDERRUN_T  0x4        /* TxPktRdy not set  for an IN token */
-#define               FLUSHFIFO_T  0x8        /* flush endpoint FIFO */
-#define              STALL_SEND_T  0x10       /* issue a Stall handshake */
-#define              STALL_SENT_T  0x20       /* Stall handshake transmitted */
-#define        CLEAR_DATATOGGLE_T  0x40       /* clear endpoint data toggle */
-#define                INCOMPTX_T  0x80       /* indicates that a large packet is split */
-#define              DMAREQMODE_T  0x400      /* DMA mode (0 or 1) selection */
-#define        FORCE_DATATOGGLE_T  0x800      /* Force data toggle */
-#define              DMAREQ_ENA_T  0x1000     /* Enable DMA request for Tx EP */
-#define                     ISO_T  0x4000     /* enable Isochronous transfers */
-#define                 AUTOSET_T  0x8000     /* allows TxPktRdy to be set automatically */
-#define                  ERROR_TH  0x4        /* error condition host mode */
-#define         STALL_RECEIVED_TH  0x20       /* Stall handshake received host mode */
-#define            NAK_TIMEOUT_TH  0x80       /* NAK timeout host mode */
-
-/* Bit masks for USB_TXCOUNT */
-
-#define                  TX_COUNT  0x1fff     /* Number of bytes to be written to the selected endpoint Tx FIFO */
-
-/* Bit masks for USB_RXCSR */
-
-#define                RXPKTRDY_R  0x1        /* data packet in FIFO indicator */
-#define               FIFO_FULL_R  0x2        /* FIFO not empty */
-#define                 OVERRUN_R  0x4        /* TxPktRdy not set  for an IN token */
-#define               DATAERROR_R  0x8        /* Out packet cannot be loaded into Rx  FIFO */
-#define               FLUSHFIFO_R  0x10       /* flush endpoint FIFO */
-#define              STALL_SEND_R  0x20       /* issue a Stall handshake */
-#define              STALL_SENT_R  0x40       /* Stall handshake transmitted */
-#define        CLEAR_DATATOGGLE_R  0x80       /* clear endpoint data toggle */
-#define                INCOMPRX_R  0x100      /* indicates that a large packet is split */
-#define              DMAREQMODE_R  0x800      /* DMA mode (0 or 1) selection */
-#define                 DISNYET_R  0x1000     /* disable Nyet handshakes */
-#define              DMAREQ_ENA_R  0x2000     /* Enable DMA request for Tx EP */
-#define                     ISO_R  0x4000     /* enable Isochronous transfers */
-#define               AUTOCLEAR_R  0x8000     /* allows TxPktRdy to be set automatically */
-#define                  ERROR_RH  0x4        /* TxPktRdy not set  for an IN token host mode */
-#define                 REQPKT_RH  0x20       /* request an IN transaction host mode */
-#define         STALL_RECEIVED_RH  0x40       /* Stall handshake received host mode */
-#define               INCOMPRX_RH  0x100      /* indicates that a large packet is split host mode */
-#define             DMAREQMODE_RH  0x800      /* DMA mode (0 or 1) selection host mode */
-#define                AUTOREQ_RH  0x4000     /* sets ReqPkt automatically host mode */
-
-/* Bit masks for USB_RXCOUNT */
-
-#define                  RX_COUNT  0x1fff     /* Number of received bytes in the packet in the Rx FIFO */
-
-/* Bit masks for USB_TXTYPE */
-
-#define            TARGET_EP_NO_T  0xf        /* EP number */
-#define                PROTOCOL_T  0xc        /* transfer type */
-
-/* Bit masks for USB_TXINTERVAL */
-
-#define          TX_POLL_INTERVAL  0xff       /* polling interval for selected Tx EP */
-
-/* Bit masks for USB_RXTYPE */
-
-#define            TARGET_EP_NO_R  0xf        /* EP number */
-#define                PROTOCOL_R  0xc        /* transfer type */
-
-/* Bit masks for USB_RXINTERVAL */
-
-#define          RX_POLL_INTERVAL  0xff       /* polling interval for selected Rx EP */
-
-/* Bit masks for USB_DMA_INTERRUPT */
-
-#define                  DMA0_INT  0x1        /* DMA0 pending interrupt */
-#define                  DMA1_INT  0x2        /* DMA1 pending interrupt */
-#define                  DMA2_INT  0x4        /* DMA2 pending interrupt */
-#define                  DMA3_INT  0x8        /* DMA3 pending interrupt */
-#define                  DMA4_INT  0x10       /* DMA4 pending interrupt */
-#define                  DMA5_INT  0x20       /* DMA5 pending interrupt */
-#define                  DMA6_INT  0x40       /* DMA6 pending interrupt */
-#define                  DMA7_INT  0x80       /* DMA7 pending interrupt */
-
-/* Bit masks for USB_DMAxCONTROL */
-
-#define                   DMA_ENA  0x1        /* DMA enable */
-#define                 DIRECTION  0x2        /* direction of DMA transfer */
-#define                      MODE  0x4        /* DMA Bus error */
-#define                   INT_ENA  0x8        /* Interrupt enable */
-#define                     EPNUM  0xf0       /* EP number */
-#define                  BUSERROR  0x100      /* DMA Bus error */
-
-/* Bit masks for USB_DMAxADDRHIGH */
-
-#define             DMA_ADDR_HIGH  0xffff     /* Upper 16-bits of memory source/destination address for the DMA master channel */
-
-/* Bit masks for USB_DMAxADDRLOW */
-
-#define              DMA_ADDR_LOW  0xffff     /* Lower 16-bits of memory source/destination address for the DMA master channel */
-
-/* Bit masks for USB_DMAxCOUNTHIGH */
-
-#define            DMA_COUNT_HIGH  0xffff     /* Upper 16-bits of byte count of DMA transfer for DMA master channel */
-
-/* Bit masks for USB_DMAxCOUNTLOW */
-
-#define             DMA_COUNT_LOW  0xffff     /* Lower 16-bits of byte count of DMA transfer for DMA master channel */
-
-/* Bit masks for HMDMAx_CONTROL */
-
-#define                   HMDMAEN  0x1        /* Handshake MDMA Enable */
-#define                       REP  0x2        /* Handshake MDMA Request Polarity */
-#define                       UTE  0x8        /* Urgency Threshold Enable */
-#define                       OIE  0x10       /* Overflow Interrupt Enable */
-#define                      BDIE  0x20       /* Block Done Interrupt Enable */
-#define                      MBDI  0x40       /* Mask Block Done Interrupt */
-#define                       DRQ  0x300      /* Handshake MDMA Request Type */
-#define                       RBC  0x1000     /* Force Reload of BCOUNT */
-#define                        PS  0x2000     /* Pin Status */
-#define                        OI  0x4000     /* Overflow Interrupt Generated */
-#define                       BDI  0x8000     /* Block Done Interrupt Generated */
-
-/* ******************************************* */
-/*     MULTI BIT MACRO ENUMERATIONS            */
-/* ******************************************* */
-
-
 #endif /* _DEF_BF548_H */
index f7f043560c6ffd1f66a4f9b24cc30b911c6f45f6..5a04e6d4017eb0946afa06b502506e8f6493df06 100644 (file)
 /* Include all Core registers and bit definitions */
 #include <asm/def_LPBlackfin.h>
 
-
 /* SYSTEM & MMR ADDRESS DEFINITIONS FOR ADSP-BF549 */
 
 /* Include defBF54x_base.h for the set of #defines that are common to all ADSP-BF54x processors */
 #include "defBF54x_base.h"
 
-/* The following are the #defines needed by ADSP-BF549 that are not in the common header */
-
-/* Timer Registers */
-
-#define                    TIMER8_CONFIG  0xffc00600   /* Timer 8 Configuration Register */
-#define                   TIMER8_COUNTER  0xffc00604   /* Timer 8 Counter Register */
-#define                    TIMER8_PERIOD  0xffc00608   /* Timer 8 Period Register */
-#define                     TIMER8_WIDTH  0xffc0060c   /* Timer 8 Width Register */
-#define                    TIMER9_CONFIG  0xffc00610   /* Timer 9 Configuration Register */
-#define                   TIMER9_COUNTER  0xffc00614   /* Timer 9 Counter Register */
-#define                    TIMER9_PERIOD  0xffc00618   /* Timer 9 Period Register */
-#define                     TIMER9_WIDTH  0xffc0061c   /* Timer 9 Width Register */
-#define                   TIMER10_CONFIG  0xffc00620   /* Timer 10 Configuration Register */
-#define                  TIMER10_COUNTER  0xffc00624   /* Timer 10 Counter Register */
-#define                   TIMER10_PERIOD  0xffc00628   /* Timer 10 Period Register */
-#define                    TIMER10_WIDTH  0xffc0062c   /* Timer 10 Width Register */
-
-/* Timer Group of 3 Registers */
-
-#define                    TIMER_ENABLE1  0xffc00640   /* Timer Group of 3 Enable Register */
-#define                   TIMER_DISABLE1  0xffc00644   /* Timer Group of 3 Disable Register */
-#define                    TIMER_STATUS1  0xffc00648   /* Timer Group of 3 Status Register */
-
-/* SPORT0 Registers */
-
-#define                      SPORT0_TCR1  0xffc00800   /* SPORT0 Transmit Configuration 1 Register */
-#define                      SPORT0_TCR2  0xffc00804   /* SPORT0 Transmit Configuration 2 Register */
-#define                   SPORT0_TCLKDIV  0xffc00808   /* SPORT0 Transmit Serial Clock Divider Register */
-#define                    SPORT0_TFSDIV  0xffc0080c   /* SPORT0 Transmit Frame Sync Divider Register */
-#define                        SPORT0_TX  0xffc00810   /* SPORT0 Transmit Data Register */
-#define                        SPORT0_RX  0xffc00818   /* SPORT0 Receive Data Register */
-#define                      SPORT0_RCR1  0xffc00820   /* SPORT0 Receive Configuration 1 Register */
-#define                      SPORT0_RCR2  0xffc00824   /* SPORT0 Receive Configuration 2 Register */
-#define                   SPORT0_RCLKDIV  0xffc00828   /* SPORT0 Receive Serial Clock Divider Register */
-#define                    SPORT0_RFSDIV  0xffc0082c   /* SPORT0 Receive Frame Sync Divider Register */
-#define                      SPORT0_STAT  0xffc00830   /* SPORT0 Status Register */
-#define                      SPORT0_CHNL  0xffc00834   /* SPORT0 Current Channel Register */
-#define                     SPORT0_MCMC1  0xffc00838   /* SPORT0 Multi channel Configuration Register 1 */
-#define                     SPORT0_MCMC2  0xffc0083c   /* SPORT0 Multi channel Configuration Register 2 */
-#define                     SPORT0_MTCS0  0xffc00840   /* SPORT0 Multi channel Transmit Select Register 0 */
-#define                     SPORT0_MTCS1  0xffc00844   /* SPORT0 Multi channel Transmit Select Register 1 */
-#define                     SPORT0_MTCS2  0xffc00848   /* SPORT0 Multi channel Transmit Select Register 2 */
-#define                     SPORT0_MTCS3  0xffc0084c   /* SPORT0 Multi channel Transmit Select Register 3 */
-#define                     SPORT0_MRCS0  0xffc00850   /* SPORT0 Multi channel Receive Select Register 0 */
-#define                     SPORT0_MRCS1  0xffc00854   /* SPORT0 Multi channel Receive Select Register 1 */
-#define                     SPORT0_MRCS2  0xffc00858   /* SPORT0 Multi channel Receive Select Register 2 */
-#define                     SPORT0_MRCS3  0xffc0085c   /* SPORT0 Multi channel Receive Select Register 3 */
-
-/* EPPI0 Registers */
-
-#define                     EPPI0_STATUS  0xffc01000   /* EPPI0 Status Register */
-#define                     EPPI0_HCOUNT  0xffc01004   /* EPPI0 Horizontal Transfer Count Register */
-#define                     EPPI0_HDELAY  0xffc01008   /* EPPI0 Horizontal Delay Count Register */
-#define                     EPPI0_VCOUNT  0xffc0100c   /* EPPI0 Vertical Transfer Count Register */
-#define                     EPPI0_VDELAY  0xffc01010   /* EPPI0 Vertical Delay Count Register */
-#define                      EPPI0_FRAME  0xffc01014   /* EPPI0 Lines per Frame Register */
-#define                       EPPI0_LINE  0xffc01018   /* EPPI0 Samples per Line Register */
-#define                     EPPI0_CLKDIV  0xffc0101c   /* EPPI0 Clock Divide Register */
-#define                    EPPI0_CONTROL  0xffc01020   /* EPPI0 Control Register */
-#define                   EPPI0_FS1W_HBL  0xffc01024   /* EPPI0 FS1 Width Register / EPPI0 Horizontal Blanking Samples Per Line Register */
-#define                  EPPI0_FS1P_AVPL  0xffc01028   /* EPPI0 FS1 Period Register / EPPI0 Active Video Samples Per Line Register */
-#define                   EPPI0_FS2W_LVB  0xffc0102c   /* EPPI0 FS2 Width Register / EPPI0 Lines of Vertical Blanking Register */
-#define                  EPPI0_FS2P_LAVF  0xffc01030   /* EPPI0 FS2 Period Register/ EPPI0 Lines of Active Video Per Field Register */
-#define                       EPPI0_CLIP  0xffc01034   /* EPPI0 Clipping Register */
-
-/* UART2 Registers */
-
-#define                        UART2_DLL  0xffc02100   /* Divisor Latch Low Byte */
-#define                        UART2_DLH  0xffc02104   /* Divisor Latch High Byte */
-#define                       UART2_GCTL  0xffc02108   /* Global Control Register */
-#define                        UART2_LCR  0xffc0210c   /* Line Control Register */
-#define                        UART2_MCR  0xffc02110   /* Modem Control Register */
-#define                        UART2_LSR  0xffc02114   /* Line Status Register */
-#define                        UART2_MSR  0xffc02118   /* Modem Status Register */
-#define                        UART2_SCR  0xffc0211c   /* Scratch Register */
-#define                    UART2_IER_SET  0xffc02120   /* Interrupt Enable Register Set */
-#define                  UART2_IER_CLEAR  0xffc02124   /* Interrupt Enable Register Clear */
-#define                        UART2_RBR  0xffc0212c   /* Receive Buffer Register */
-
-/* Two Wire Interface Registers (TWI1) */
-
-#define                     TWI1_REGBASE  0xffc02200
-#define                      TWI1_CLKDIV  0xffc02200   /* Clock Divider Register */
-#define                     TWI1_CONTROL  0xffc02204   /* TWI Control Register */
-#define                  TWI1_SLAVE_CTRL  0xffc02208   /* TWI Slave Mode Control Register */
-#define                  TWI1_SLAVE_STAT  0xffc0220c   /* TWI Slave Mode Status Register */
-#define                  TWI1_SLAVE_ADDR  0xffc02210   /* TWI Slave Mode Address Register */
-#define                 TWI1_MASTER_CTRL  0xffc02214   /* TWI Master Mode Control Register */
-#define                 TWI1_MASTER_STAT  0xffc02218   /* TWI Master Mode Status Register */
-#define                 TWI1_MASTER_ADDR  0xffc0221c   /* TWI Master Mode Address Register */
-#define                    TWI1_INT_STAT  0xffc02220   /* TWI Interrupt Status Register */
-#define                    TWI1_INT_MASK  0xffc02224   /* TWI Interrupt Mask Register */
-#define                   TWI1_FIFO_CTRL  0xffc02228   /* TWI FIFO Control Register */
-#define                   TWI1_FIFO_STAT  0xffc0222c   /* TWI FIFO Status Register */
-#define                   TWI1_XMT_DATA8  0xffc02280   /* TWI FIFO Transmit Data Single Byte Register */
-#define                  TWI1_XMT_DATA16  0xffc02284   /* TWI FIFO Transmit Data Double Byte Register */
-#define                   TWI1_RCV_DATA8  0xffc02288   /* TWI FIFO Receive Data Single Byte Register */
-#define                  TWI1_RCV_DATA16  0xffc0228c   /* TWI FIFO Receive Data Double Byte Register */
-
-/* SPI2  Registers */
-
-#define                     SPI2_REGBASE  0xffc02400
-#define                         SPI2_CTL  0xffc02400   /* SPI2 Control Register */
-#define                         SPI2_FLG  0xffc02404   /* SPI2 Flag Register */
-#define                        SPI2_STAT  0xffc02408   /* SPI2 Status Register */
-#define                        SPI2_TDBR  0xffc0240c   /* SPI2 Transmit Data Buffer Register */
-#define                        SPI2_RDBR  0xffc02410   /* SPI2 Receive Data Buffer Register */
-#define                        SPI2_BAUD  0xffc02414   /* SPI2 Baud Rate Register */
-#define                      SPI2_SHADOW  0xffc02418   /* SPI2 Receive Data Buffer Shadow Register */
+/* The BF549 is like the BF544, but has MXVR */
+#include "defBF547.h"
 
 /* MXVR Registers */
 
 #define                     MXVR_PIN_CTL  0xffc028dc   /* MXVR Pin Control Register */
 #define                    MXVR_SCLK_CNT  0xffc028e0   /* MXVR System Clock Counter Register */
 
-/* CAN Controller 1 Config 1 Registers */
-
-#define                         CAN1_MC1  0xffc03200   /* CAN Controller 1 Mailbox Configuration Register 1 */
-#define                         CAN1_MD1  0xffc03204   /* CAN Controller 1 Mailbox Direction Register 1 */
-#define                        CAN1_TRS1  0xffc03208   /* CAN Controller 1 Transmit Request Set Register 1 */
-#define                        CAN1_TRR1  0xffc0320c   /* CAN Controller 1 Transmit Request Reset Register 1 */
-#define                         CAN1_TA1  0xffc03210   /* CAN Controller 1 Transmit Acknowledge Register 1 */
-#define                         CAN1_AA1  0xffc03214   /* CAN Controller 1 Abort Acknowledge Register 1 */
-#define                        CAN1_RMP1  0xffc03218   /* CAN Controller 1 Receive Message Pending Register 1 */
-#define                        CAN1_RML1  0xffc0321c   /* CAN Controller 1 Receive Message Lost Register 1 */
-#define                      CAN1_MBTIF1  0xffc03220   /* CAN Controller 1 Mailbox Transmit Interrupt Flag Register 1 */
-#define                      CAN1_MBRIF1  0xffc03224   /* CAN Controller 1 Mailbox Receive Interrupt Flag Register 1 */
-#define                       CAN1_MBIM1  0xffc03228   /* CAN Controller 1 Mailbox Interrupt Mask Register 1 */
-#define                        CAN1_RFH1  0xffc0322c   /* CAN Controller 1 Remote Frame Handling Enable Register 1 */
-#define                       CAN1_OPSS1  0xffc03230   /* CAN Controller 1 Overwrite Protection Single Shot Transmit Register 1 */
-
-/* CAN Controller 1 Config 2 Registers */
-
-#define                         CAN1_MC2  0xffc03240   /* CAN Controller 1 Mailbox Configuration Register 2 */
-#define                         CAN1_MD2  0xffc03244   /* CAN Controller 1 Mailbox Direction Register 2 */
-#define                        CAN1_TRS2  0xffc03248   /* CAN Controller 1 Transmit Request Set Register 2 */
-#define                        CAN1_TRR2  0xffc0324c   /* CAN Controller 1 Transmit Request Reset Register 2 */
-#define                         CAN1_TA2  0xffc03250   /* CAN Controller 1 Transmit Acknowledge Register 2 */
-#define                         CAN1_AA2  0xffc03254   /* CAN Controller 1 Abort Acknowledge Register 2 */
-#define                        CAN1_RMP2  0xffc03258   /* CAN Controller 1 Receive Message Pending Register 2 */
-#define                        CAN1_RML2  0xffc0325c   /* CAN Controller 1 Receive Message Lost Register 2 */
-#define                      CAN1_MBTIF2  0xffc03260   /* CAN Controller 1 Mailbox Transmit Interrupt Flag Register 2 */
-#define                      CAN1_MBRIF2  0xffc03264   /* CAN Controller 1 Mailbox Receive Interrupt Flag Register 2 */
-#define                       CAN1_MBIM2  0xffc03268   /* CAN Controller 1 Mailbox Interrupt Mask Register 2 */
-#define                        CAN1_RFH2  0xffc0326c   /* CAN Controller 1 Remote Frame Handling Enable Register 2 */
-#define                       CAN1_OPSS2  0xffc03270   /* CAN Controller 1 Overwrite Protection Single Shot Transmit Register 2 */
-
-/* CAN Controller 1 Clock/Interrupt/Counter Registers */
-
-#define                       CAN1_CLOCK  0xffc03280   /* CAN Controller 1 Clock Register */
-#define                      CAN1_TIMING  0xffc03284   /* CAN Controller 1 Timing Register */
-#define                       CAN1_DEBUG  0xffc03288   /* CAN Controller 1 Debug Register */
-#define                      CAN1_STATUS  0xffc0328c   /* CAN Controller 1 Global Status Register */
-#define                         CAN1_CEC  0xffc03290   /* CAN Controller 1 Error Counter Register */
-#define                         CAN1_GIS  0xffc03294   /* CAN Controller 1 Global Interrupt Status Register */
-#define                         CAN1_GIM  0xffc03298   /* CAN Controller 1 Global Interrupt Mask Register */
-#define                         CAN1_GIF  0xffc0329c   /* CAN Controller 1 Global Interrupt Flag Register */
-#define                     CAN1_CONTROL  0xffc032a0   /* CAN Controller 1 Master Control Register */
-#define                        CAN1_INTR  0xffc032a4   /* CAN Controller 1 Interrupt Pending Register */
-#define                        CAN1_MBTD  0xffc032ac   /* CAN Controller 1 Mailbox Temporary Disable Register */
-#define                         CAN1_EWR  0xffc032b0   /* CAN Controller 1 Programmable Warning Level Register */
-#define                         CAN1_ESR  0xffc032b4   /* CAN Controller 1 Error Status Register */
-#define                       CAN1_UCCNT  0xffc032c4   /* CAN Controller 1 Universal Counter Register */
-#define                        CAN1_UCRC  0xffc032c8   /* CAN Controller 1 Universal Counter Force Reload Register */
-#define                       CAN1_UCCNF  0xffc032cc   /* CAN Controller 1 Universal Counter Configuration Register */
-
-/* CAN Controller 1 Mailbox Acceptance Registers */
-
-#define                       CAN1_AM00L  0xffc03300   /* CAN Controller 1 Mailbox 0 Acceptance Mask High Register */
-#define                       CAN1_AM00H  0xffc03304   /* CAN Controller 1 Mailbox 0 Acceptance Mask Low Register */
-#define                       CAN1_AM01L  0xffc03308   /* CAN Controller 1 Mailbox 1 Acceptance Mask High Register */
-#define                       CAN1_AM01H  0xffc0330c   /* CAN Controller 1 Mailbox 1 Acceptance Mask Low Register */
-#define                       CAN1_AM02L  0xffc03310   /* CAN Controller 1 Mailbox 2 Acceptance Mask High Register */
-#define                       CAN1_AM02H  0xffc03314   /* CAN Controller 1 Mailbox 2 Acceptance Mask Low Register */
-#define                       CAN1_AM03L  0xffc03318   /* CAN Controller 1 Mailbox 3 Acceptance Mask High Register */
-#define                       CAN1_AM03H  0xffc0331c   /* CAN Controller 1 Mailbox 3 Acceptance Mask Low Register */
-#define                       CAN1_AM04L  0xffc03320   /* CAN Controller 1 Mailbox 4 Acceptance Mask High Register */
-#define                       CAN1_AM04H  0xffc03324   /* CAN Controller 1 Mailbox 4 Acceptance Mask Low Register */
-#define                       CAN1_AM05L  0xffc03328   /* CAN Controller 1 Mailbox 5 Acceptance Mask High Register */
-#define                       CAN1_AM05H  0xffc0332c   /* CAN Controller 1 Mailbox 5 Acceptance Mask Low Register */
-#define                       CAN1_AM06L  0xffc03330   /* CAN Controller 1 Mailbox 6 Acceptance Mask High Register */
-#define                       CAN1_AM06H  0xffc03334   /* CAN Controller 1 Mailbox 6 Acceptance Mask Low Register */
-#define                       CAN1_AM07L  0xffc03338   /* CAN Controller 1 Mailbox 7 Acceptance Mask High Register */
-#define                       CAN1_AM07H  0xffc0333c   /* CAN Controller 1 Mailbox 7 Acceptance Mask Low Register */
-#define                       CAN1_AM08L  0xffc03340   /* CAN Controller 1 Mailbox 8 Acceptance Mask High Register */
-#define                       CAN1_AM08H  0xffc03344   /* CAN Controller 1 Mailbox 8 Acceptance Mask Low Register */
-#define                       CAN1_AM09L  0xffc03348   /* CAN Controller 1 Mailbox 9 Acceptance Mask High Register */
-#define                       CAN1_AM09H  0xffc0334c   /* CAN Controller 1 Mailbox 9 Acceptance Mask Low Register */
-#define                       CAN1_AM10L  0xffc03350   /* CAN Controller 1 Mailbox 10 Acceptance Mask High Register */
-#define                       CAN1_AM10H  0xffc03354   /* CAN Controller 1 Mailbox 10 Acceptance Mask Low Register */
-#define                       CAN1_AM11L  0xffc03358   /* CAN Controller 1 Mailbox 11 Acceptance Mask High Register */
-#define                       CAN1_AM11H  0xffc0335c   /* CAN Controller 1 Mailbox 11 Acceptance Mask Low Register */
-#define                       CAN1_AM12L  0xffc03360   /* CAN Controller 1 Mailbox 12 Acceptance Mask High Register */
-#define                       CAN1_AM12H  0xffc03364   /* CAN Controller 1 Mailbox 12 Acceptance Mask Low Register */
-#define                       CAN1_AM13L  0xffc03368   /* CAN Controller 1 Mailbox 13 Acceptance Mask High Register */
-#define                       CAN1_AM13H  0xffc0336c   /* CAN Controller 1 Mailbox 13 Acceptance Mask Low Register */
-#define                       CAN1_AM14L  0xffc03370   /* CAN Controller 1 Mailbox 14 Acceptance Mask High Register */
-#define                       CAN1_AM14H  0xffc03374   /* CAN Controller 1 Mailbox 14 Acceptance Mask Low Register */
-#define                       CAN1_AM15L  0xffc03378   /* CAN Controller 1 Mailbox 15 Acceptance Mask High Register */
-#define                       CAN1_AM15H  0xffc0337c   /* CAN Controller 1 Mailbox 15 Acceptance Mask Low Register */
-
-/* CAN Controller 1 Mailbox Acceptance Registers */
-
-#define                       CAN1_AM16L  0xffc03380   /* CAN Controller 1 Mailbox 16 Acceptance Mask High Register */
-#define                       CAN1_AM16H  0xffc03384   /* CAN Controller 1 Mailbox 16 Acceptance Mask Low Register */
-#define                       CAN1_AM17L  0xffc03388   /* CAN Controller 1 Mailbox 17 Acceptance Mask High Register */
-#define                       CAN1_AM17H  0xffc0338c   /* CAN Controller 1 Mailbox 17 Acceptance Mask Low Register */
-#define                       CAN1_AM18L  0xffc03390   /* CAN Controller 1 Mailbox 18 Acceptance Mask High Register */
-#define                       CAN1_AM18H  0xffc03394   /* CAN Controller 1 Mailbox 18 Acceptance Mask Low Register */
-#define                       CAN1_AM19L  0xffc03398   /* CAN Controller 1 Mailbox 19 Acceptance Mask High Register */
-#define                       CAN1_AM19H  0xffc0339c   /* CAN Controller 1 Mailbox 19 Acceptance Mask Low Register */
-#define                       CAN1_AM20L  0xffc033a0   /* CAN Controller 1 Mailbox 20 Acceptance Mask High Register */
-#define                       CAN1_AM20H  0xffc033a4   /* CAN Controller 1 Mailbox 20 Acceptance Mask Low Register */
-#define                       CAN1_AM21L  0xffc033a8   /* CAN Controller 1 Mailbox 21 Acceptance Mask High Register */
-#define                       CAN1_AM21H  0xffc033ac   /* CAN Controller 1 Mailbox 21 Acceptance Mask Low Register */
-#define                       CAN1_AM22L  0xffc033b0   /* CAN Controller 1 Mailbox 22 Acceptance Mask High Register */
-#define                       CAN1_AM22H  0xffc033b4   /* CAN Controller 1 Mailbox 22 Acceptance Mask Low Register */
-#define                       CAN1_AM23L  0xffc033b8   /* CAN Controller 1 Mailbox 23 Acceptance Mask High Register */
-#define                       CAN1_AM23H  0xffc033bc   /* CAN Controller 1 Mailbox 23 Acceptance Mask Low Register */
-#define                       CAN1_AM24L  0xffc033c0   /* CAN Controller 1 Mailbox 24 Acceptance Mask High Register */
-#define                       CAN1_AM24H  0xffc033c4   /* CAN Controller 1 Mailbox 24 Acceptance Mask Low Register */
-#define                       CAN1_AM25L  0xffc033c8   /* CAN Controller 1 Mailbox 25 Acceptance Mask High Register */
-#define                       CAN1_AM25H  0xffc033cc   /* CAN Controller 1 Mailbox 25 Acceptance Mask Low Register */
-#define                       CAN1_AM26L  0xffc033d0   /* CAN Controller 1 Mailbox 26 Acceptance Mask High Register */
-#define                       CAN1_AM26H  0xffc033d4   /* CAN Controller 1 Mailbox 26 Acceptance Mask Low Register */
-#define                       CAN1_AM27L  0xffc033d8   /* CAN Controller 1 Mailbox 27 Acceptance Mask High Register */
-#define                       CAN1_AM27H  0xffc033dc   /* CAN Controller 1 Mailbox 27 Acceptance Mask Low Register */
-#define                       CAN1_AM28L  0xffc033e0   /* CAN Controller 1 Mailbox 28 Acceptance Mask High Register */
-#define                       CAN1_AM28H  0xffc033e4   /* CAN Controller 1 Mailbox 28 Acceptance Mask Low Register */
-#define                       CAN1_AM29L  0xffc033e8   /* CAN Controller 1 Mailbox 29 Acceptance Mask High Register */
-#define                       CAN1_AM29H  0xffc033ec   /* CAN Controller 1 Mailbox 29 Acceptance Mask Low Register */
-#define                       CAN1_AM30L  0xffc033f0   /* CAN Controller 1 Mailbox 30 Acceptance Mask High Register */
-#define                       CAN1_AM30H  0xffc033f4   /* CAN Controller 1 Mailbox 30 Acceptance Mask Low Register */
-#define                       CAN1_AM31L  0xffc033f8   /* CAN Controller 1 Mailbox 31 Acceptance Mask High Register */
-#define                       CAN1_AM31H  0xffc033fc   /* CAN Controller 1 Mailbox 31 Acceptance Mask Low Register */
-
-/* CAN Controller 1 Mailbox Data Registers */
-
-#define                  CAN1_MB00_DATA0  0xffc03400   /* CAN Controller 1 Mailbox 0 Data 0 Register */
-#define                  CAN1_MB00_DATA1  0xffc03404   /* CAN Controller 1 Mailbox 0 Data 1 Register */
-#define                  CAN1_MB00_DATA2  0xffc03408   /* CAN Controller 1 Mailbox 0 Data 2 Register */
-#define                  CAN1_MB00_DATA3  0xffc0340c   /* CAN Controller 1 Mailbox 0 Data 3 Register */
-#define                 CAN1_MB00_LENGTH  0xffc03410   /* CAN Controller 1 Mailbox 0 Length Register */
-#define              CAN1_MB00_TIMESTAMP  0xffc03414   /* CAN Controller 1 Mailbox 0 Timestamp Register */
-#define                    CAN1_MB00_ID0  0xffc03418   /* CAN Controller 1 Mailbox 0 ID0 Register */
-#define                    CAN1_MB00_ID1  0xffc0341c   /* CAN Controller 1 Mailbox 0 ID1 Register */
-#define                  CAN1_MB01_DATA0  0xffc03420   /* CAN Controller 1 Mailbox 1 Data 0 Register */
-#define                  CAN1_MB01_DATA1  0xffc03424   /* CAN Controller 1 Mailbox 1 Data 1 Register */
-#define                  CAN1_MB01_DATA2  0xffc03428   /* CAN Controller 1 Mailbox 1 Data 2 Register */
-#define                  CAN1_MB01_DATA3  0xffc0342c   /* CAN Controller 1 Mailbox 1 Data 3 Register */
-#define                 CAN1_MB01_LENGTH  0xffc03430   /* CAN Controller 1 Mailbox 1 Length Register */
-#define              CAN1_MB01_TIMESTAMP  0xffc03434   /* CAN Controller 1 Mailbox 1 Timestamp Register */
-#define                    CAN1_MB01_ID0  0xffc03438   /* CAN Controller 1 Mailbox 1 ID0 Register */
-#define                    CAN1_MB01_ID1  0xffc0343c   /* CAN Controller 1 Mailbox 1 ID1 Register */
-#define                  CAN1_MB02_DATA0  0xffc03440   /* CAN Controller 1 Mailbox 2 Data 0 Register */
-#define                  CAN1_MB02_DATA1  0xffc03444   /* CAN Controller 1 Mailbox 2 Data 1 Register */
-#define                  CAN1_MB02_DATA2  0xffc03448   /* CAN Controller 1 Mailbox 2 Data 2 Register */
-#define                  CAN1_MB02_DATA3  0xffc0344c   /* CAN Controller 1 Mailbox 2 Data 3 Register */
-#define                 CAN1_MB02_LENGTH  0xffc03450   /* CAN Controller 1 Mailbox 2 Length Register */
-#define              CAN1_MB02_TIMESTAMP  0xffc03454   /* CAN Controller 1 Mailbox 2 Timestamp Register */
-#define                    CAN1_MB02_ID0  0xffc03458   /* CAN Controller 1 Mailbox 2 ID0 Register */
-#define                    CAN1_MB02_ID1  0xffc0345c   /* CAN Controller 1 Mailbox 2 ID1 Register */
-#define                  CAN1_MB03_DATA0  0xffc03460   /* CAN Controller 1 Mailbox 3 Data 0 Register */
-#define                  CAN1_MB03_DATA1  0xffc03464   /* CAN Controller 1 Mailbox 3 Data 1 Register */
-#define                  CAN1_MB03_DATA2  0xffc03468   /* CAN Controller 1 Mailbox 3 Data 2 Register */
-#define                  CAN1_MB03_DATA3  0xffc0346c   /* CAN Controller 1 Mailbox 3 Data 3 Register */
-#define                 CAN1_MB03_LENGTH  0xffc03470   /* CAN Controller 1 Mailbox 3 Length Register */
-#define              CAN1_MB03_TIMESTAMP  0xffc03474   /* CAN Controller 1 Mailbox 3 Timestamp Register */
-#define                    CAN1_MB03_ID0  0xffc03478   /* CAN Controller 1 Mailbox 3 ID0 Register */
-#define                    CAN1_MB03_ID1  0xffc0347c   /* CAN Controller 1 Mailbox 3 ID1 Register */
-#define                  CAN1_MB04_DATA0  0xffc03480   /* CAN Controller 1 Mailbox 4 Data 0 Register */
-#define                  CAN1_MB04_DATA1  0xffc03484   /* CAN Controller 1 Mailbox 4 Data 1 Register */
-#define                  CAN1_MB04_DATA2  0xffc03488   /* CAN Controller 1 Mailbox 4 Data 2 Register */
-#define                  CAN1_MB04_DATA3  0xffc0348c   /* CAN Controller 1 Mailbox 4 Data 3 Register */
-#define                 CAN1_MB04_LENGTH  0xffc03490   /* CAN Controller 1 Mailbox 4 Length Register */
-#define              CAN1_MB04_TIMESTAMP  0xffc03494   /* CAN Controller 1 Mailbox 4 Timestamp Register */
-#define                    CAN1_MB04_ID0  0xffc03498   /* CAN Controller 1 Mailbox 4 ID0 Register */
-#define                    CAN1_MB04_ID1  0xffc0349c   /* CAN Controller 1 Mailbox 4 ID1 Register */
-#define                  CAN1_MB05_DATA0  0xffc034a0   /* CAN Controller 1 Mailbox 5 Data 0 Register */
-#define                  CAN1_MB05_DATA1  0xffc034a4   /* CAN Controller 1 Mailbox 5 Data 1 Register */
-#define                  CAN1_MB05_DATA2  0xffc034a8   /* CAN Controller 1 Mailbox 5 Data 2 Register */
-#define                  CAN1_MB05_DATA3  0xffc034ac   /* CAN Controller 1 Mailbox 5 Data 3 Register */
-#define                 CAN1_MB05_LENGTH  0xffc034b0   /* CAN Controller 1 Mailbox 5 Length Register */
-#define              CAN1_MB05_TIMESTAMP  0xffc034b4   /* CAN Controller 1 Mailbox 5 Timestamp Register */
-#define                    CAN1_MB05_ID0  0xffc034b8   /* CAN Controller 1 Mailbox 5 ID0 Register */
-#define                    CAN1_MB05_ID1  0xffc034bc   /* CAN Controller 1 Mailbox 5 ID1 Register */
-#define                  CAN1_MB06_DATA0  0xffc034c0   /* CAN Controller 1 Mailbox 6 Data 0 Register */
-#define                  CAN1_MB06_DATA1  0xffc034c4   /* CAN Controller 1 Mailbox 6 Data 1 Register */
-#define                  CAN1_MB06_DATA2  0xffc034c8   /* CAN Controller 1 Mailbox 6 Data 2 Register */
-#define                  CAN1_MB06_DATA3  0xffc034cc   /* CAN Controller 1 Mailbox 6 Data 3 Register */
-#define                 CAN1_MB06_LENGTH  0xffc034d0   /* CAN Controller 1 Mailbox 6 Length Register */
-#define              CAN1_MB06_TIMESTAMP  0xffc034d4   /* CAN Controller 1 Mailbox 6 Timestamp Register */
-#define                    CAN1_MB06_ID0  0xffc034d8   /* CAN Controller 1 Mailbox 6 ID0 Register */
-#define                    CAN1_MB06_ID1  0xffc034dc   /* CAN Controller 1 Mailbox 6 ID1 Register */
-#define                  CAN1_MB07_DATA0  0xffc034e0   /* CAN Controller 1 Mailbox 7 Data 0 Register */
-#define                  CAN1_MB07_DATA1  0xffc034e4   /* CAN Controller 1 Mailbox 7 Data 1 Register */
-#define                  CAN1_MB07_DATA2  0xffc034e8   /* CAN Controller 1 Mailbox 7 Data 2 Register */
-#define                  CAN1_MB07_DATA3  0xffc034ec   /* CAN Controller 1 Mailbox 7 Data 3 Register */
-#define                 CAN1_MB07_LENGTH  0xffc034f0   /* CAN Controller 1 Mailbox 7 Length Register */
-#define              CAN1_MB07_TIMESTAMP  0xffc034f4   /* CAN Controller 1 Mailbox 7 Timestamp Register */
-#define                    CAN1_MB07_ID0  0xffc034f8   /* CAN Controller 1 Mailbox 7 ID0 Register */
-#define                    CAN1_MB07_ID1  0xffc034fc   /* CAN Controller 1 Mailbox 7 ID1 Register */
-#define                  CAN1_MB08_DATA0  0xffc03500   /* CAN Controller 1 Mailbox 8 Data 0 Register */
-#define                  CAN1_MB08_DATA1  0xffc03504   /* CAN Controller 1 Mailbox 8 Data 1 Register */
-#define                  CAN1_MB08_DATA2  0xffc03508   /* CAN Controller 1 Mailbox 8 Data 2 Register */
-#define                  CAN1_MB08_DATA3  0xffc0350c   /* CAN Controller 1 Mailbox 8 Data 3 Register */
-#define                 CAN1_MB08_LENGTH  0xffc03510   /* CAN Controller 1 Mailbox 8 Length Register */
-#define              CAN1_MB08_TIMESTAMP  0xffc03514   /* CAN Controller 1 Mailbox 8 Timestamp Register */
-#define                    CAN1_MB08_ID0  0xffc03518   /* CAN Controller 1 Mailbox 8 ID0 Register */
-#define                    CAN1_MB08_ID1  0xffc0351c   /* CAN Controller 1 Mailbox 8 ID1 Register */
-#define                  CAN1_MB09_DATA0  0xffc03520   /* CAN Controller 1 Mailbox 9 Data 0 Register */
-#define                  CAN1_MB09_DATA1  0xffc03524   /* CAN Controller 1 Mailbox 9 Data 1 Register */
-#define                  CAN1_MB09_DATA2  0xffc03528   /* CAN Controller 1 Mailbox 9 Data 2 Register */
-#define                  CAN1_MB09_DATA3  0xffc0352c   /* CAN Controller 1 Mailbox 9 Data 3 Register */
-#define                 CAN1_MB09_LENGTH  0xffc03530   /* CAN Controller 1 Mailbox 9 Length Register */
-#define              CAN1_MB09_TIMESTAMP  0xffc03534   /* CAN Controller 1 Mailbox 9 Timestamp Register */
-#define                    CAN1_MB09_ID0  0xffc03538   /* CAN Controller 1 Mailbox 9 ID0 Register */
-#define                    CAN1_MB09_ID1  0xffc0353c   /* CAN Controller 1 Mailbox 9 ID1 Register */
-#define                  CAN1_MB10_DATA0  0xffc03540   /* CAN Controller 1 Mailbox 10 Data 0 Register */
-#define                  CAN1_MB10_DATA1  0xffc03544   /* CAN Controller 1 Mailbox 10 Data 1 Register */
-#define                  CAN1_MB10_DATA2  0xffc03548   /* CAN Controller 1 Mailbox 10 Data 2 Register */
-#define                  CAN1_MB10_DATA3  0xffc0354c   /* CAN Controller 1 Mailbox 10 Data 3 Register */
-#define                 CAN1_MB10_LENGTH  0xffc03550   /* CAN Controller 1 Mailbox 10 Length Register */
-#define              CAN1_MB10_TIMESTAMP  0xffc03554   /* CAN Controller 1 Mailbox 10 Timestamp Register */
-#define                    CAN1_MB10_ID0  0xffc03558   /* CAN Controller 1 Mailbox 10 ID0 Register */
-#define                    CAN1_MB10_ID1  0xffc0355c   /* CAN Controller 1 Mailbox 10 ID1 Register */
-#define                  CAN1_MB11_DATA0  0xffc03560   /* CAN Controller 1 Mailbox 11 Data 0 Register */
-#define                  CAN1_MB11_DATA1  0xffc03564   /* CAN Controller 1 Mailbox 11 Data 1 Register */
-#define                  CAN1_MB11_DATA2  0xffc03568   /* CAN Controller 1 Mailbox 11 Data 2 Register */
-#define                  CAN1_MB11_DATA3  0xffc0356c   /* CAN Controller 1 Mailbox 11 Data 3 Register */
-#define                 CAN1_MB11_LENGTH  0xffc03570   /* CAN Controller 1 Mailbox 11 Length Register */
-#define              CAN1_MB11_TIMESTAMP  0xffc03574   /* CAN Controller 1 Mailbox 11 Timestamp Register */
-#define                    CAN1_MB11_ID0  0xffc03578   /* CAN Controller 1 Mailbox 11 ID0 Register */
-#define                    CAN1_MB11_ID1  0xffc0357c   /* CAN Controller 1 Mailbox 11 ID1 Register */
-#define                  CAN1_MB12_DATA0  0xffc03580   /* CAN Controller 1 Mailbox 12 Data 0 Register */
-#define                  CAN1_MB12_DATA1  0xffc03584   /* CAN Controller 1 Mailbox 12 Data 1 Register */
-#define                  CAN1_MB12_DATA2  0xffc03588   /* CAN Controller 1 Mailbox 12 Data 2 Register */
-#define                  CAN1_MB12_DATA3  0xffc0358c   /* CAN Controller 1 Mailbox 12 Data 3 Register */
-#define                 CAN1_MB12_LENGTH  0xffc03590   /* CAN Controller 1 Mailbox 12 Length Register */
-#define              CAN1_MB12_TIMESTAMP  0xffc03594   /* CAN Controller 1 Mailbox 12 Timestamp Register */
-#define                    CAN1_MB12_ID0  0xffc03598   /* CAN Controller 1 Mailbox 12 ID0 Register */
-#define                    CAN1_MB12_ID1  0xffc0359c   /* CAN Controller 1 Mailbox 12 ID1 Register */
-#define                  CAN1_MB13_DATA0  0xffc035a0   /* CAN Controller 1 Mailbox 13 Data 0 Register */
-#define                  CAN1_MB13_DATA1  0xffc035a4   /* CAN Controller 1 Mailbox 13 Data 1 Register */
-#define                  CAN1_MB13_DATA2  0xffc035a8   /* CAN Controller 1 Mailbox 13 Data 2 Register */
-#define                  CAN1_MB13_DATA3  0xffc035ac   /* CAN Controller 1 Mailbox 13 Data 3 Register */
-#define                 CAN1_MB13_LENGTH  0xffc035b0   /* CAN Controller 1 Mailbox 13 Length Register */
-#define              CAN1_MB13_TIMESTAMP  0xffc035b4   /* CAN Controller 1 Mailbox 13 Timestamp Register */
-#define                    CAN1_MB13_ID0  0xffc035b8   /* CAN Controller 1 Mailbox 13 ID0 Register */
-#define                    CAN1_MB13_ID1  0xffc035bc   /* CAN Controller 1 Mailbox 13 ID1 Register */
-#define                  CAN1_MB14_DATA0  0xffc035c0   /* CAN Controller 1 Mailbox 14 Data 0 Register */
-#define                  CAN1_MB14_DATA1  0xffc035c4   /* CAN Controller 1 Mailbox 14 Data 1 Register */
-#define                  CAN1_MB14_DATA2  0xffc035c8   /* CAN Controller 1 Mailbox 14 Data 2 Register */
-#define                  CAN1_MB14_DATA3  0xffc035cc   /* CAN Controller 1 Mailbox 14 Data 3 Register */
-#define                 CAN1_MB14_LENGTH  0xffc035d0   /* CAN Controller 1 Mailbox 14 Length Register */
-#define              CAN1_MB14_TIMESTAMP  0xffc035d4   /* CAN Controller 1 Mailbox 14 Timestamp Register */
-#define                    CAN1_MB14_ID0  0xffc035d8   /* CAN Controller 1 Mailbox 14 ID0 Register */
-#define                    CAN1_MB14_ID1  0xffc035dc   /* CAN Controller 1 Mailbox 14 ID1 Register */
-#define                  CAN1_MB15_DATA0  0xffc035e0   /* CAN Controller 1 Mailbox 15 Data 0 Register */
-#define                  CAN1_MB15_DATA1  0xffc035e4   /* CAN Controller 1 Mailbox 15 Data 1 Register */
-#define                  CAN1_MB15_DATA2  0xffc035e8   /* CAN Controller 1 Mailbox 15 Data 2 Register */
-#define                  CAN1_MB15_DATA3  0xffc035ec   /* CAN Controller 1 Mailbox 15 Data 3 Register */
-#define                 CAN1_MB15_LENGTH  0xffc035f0   /* CAN Controller 1 Mailbox 15 Length Register */
-#define              CAN1_MB15_TIMESTAMP  0xffc035f4   /* CAN Controller 1 Mailbox 15 Timestamp Register */
-#define                    CAN1_MB15_ID0  0xffc035f8   /* CAN Controller 1 Mailbox 15 ID0 Register */
-#define                    CAN1_MB15_ID1  0xffc035fc   /* CAN Controller 1 Mailbox 15 ID1 Register */
-
-/* CAN Controller 1 Mailbox Data Registers */
-
-#define                  CAN1_MB16_DATA0  0xffc03600   /* CAN Controller 1 Mailbox 16 Data 0 Register */
-#define                  CAN1_MB16_DATA1  0xffc03604   /* CAN Controller 1 Mailbox 16 Data 1 Register */
-#define                  CAN1_MB16_DATA2  0xffc03608   /* CAN Controller 1 Mailbox 16 Data 2 Register */
-#define                  CAN1_MB16_DATA3  0xffc0360c   /* CAN Controller 1 Mailbox 16 Data 3 Register */
-#define                 CAN1_MB16_LENGTH  0xffc03610   /* CAN Controller 1 Mailbox 16 Length Register */
-#define              CAN1_MB16_TIMESTAMP  0xffc03614   /* CAN Controller 1 Mailbox 16 Timestamp Register */
-#define                    CAN1_MB16_ID0  0xffc03618   /* CAN Controller 1 Mailbox 16 ID0 Register */
-#define                    CAN1_MB16_ID1  0xffc0361c   /* CAN Controller 1 Mailbox 16 ID1 Register */
-#define                  CAN1_MB17_DATA0  0xffc03620   /* CAN Controller 1 Mailbox 17 Data 0 Register */
-#define                  CAN1_MB17_DATA1  0xffc03624   /* CAN Controller 1 Mailbox 17 Data 1 Register */
-#define                  CAN1_MB17_DATA2  0xffc03628   /* CAN Controller 1 Mailbox 17 Data 2 Register */
-#define                  CAN1_MB17_DATA3  0xffc0362c   /* CAN Controller 1 Mailbox 17 Data 3 Register */
-#define                 CAN1_MB17_LENGTH  0xffc03630   /* CAN Controller 1 Mailbox 17 Length Register */
-#define              CAN1_MB17_TIMESTAMP  0xffc03634   /* CAN Controller 1 Mailbox 17 Timestamp Register */
-#define                    CAN1_MB17_ID0  0xffc03638   /* CAN Controller 1 Mailbox 17 ID0 Register */
-#define                    CAN1_MB17_ID1  0xffc0363c   /* CAN Controller 1 Mailbox 17 ID1 Register */
-#define                  CAN1_MB18_DATA0  0xffc03640   /* CAN Controller 1 Mailbox 18 Data 0 Register */
-#define                  CAN1_MB18_DATA1  0xffc03644   /* CAN Controller 1 Mailbox 18 Data 1 Register */
-#define                  CAN1_MB18_DATA2  0xffc03648   /* CAN Controller 1 Mailbox 18 Data 2 Register */
-#define                  CAN1_MB18_DATA3  0xffc0364c   /* CAN Controller 1 Mailbox 18 Data 3 Register */
-#define                 CAN1_MB18_LENGTH  0xffc03650   /* CAN Controller 1 Mailbox 18 Length Register */
-#define              CAN1_MB18_TIMESTAMP  0xffc03654   /* CAN Controller 1 Mailbox 18 Timestamp Register */
-#define                    CAN1_MB18_ID0  0xffc03658   /* CAN Controller 1 Mailbox 18 ID0 Register */
-#define                    CAN1_MB18_ID1  0xffc0365c   /* CAN Controller 1 Mailbox 18 ID1 Register */
-#define                  CAN1_MB19_DATA0  0xffc03660   /* CAN Controller 1 Mailbox 19 Data 0 Register */
-#define                  CAN1_MB19_DATA1  0xffc03664   /* CAN Controller 1 Mailbox 19 Data 1 Register */
-#define                  CAN1_MB19_DATA2  0xffc03668   /* CAN Controller 1 Mailbox 19 Data 2 Register */
-#define                  CAN1_MB19_DATA3  0xffc0366c   /* CAN Controller 1 Mailbox 19 Data 3 Register */
-#define                 CAN1_MB19_LENGTH  0xffc03670   /* CAN Controller 1 Mailbox 19 Length Register */
-#define              CAN1_MB19_TIMESTAMP  0xffc03674   /* CAN Controller 1 Mailbox 19 Timestamp Register */
-#define                    CAN1_MB19_ID0  0xffc03678   /* CAN Controller 1 Mailbox 19 ID0 Register */
-#define                    CAN1_MB19_ID1  0xffc0367c   /* CAN Controller 1 Mailbox 19 ID1 Register */
-#define                  CAN1_MB20_DATA0  0xffc03680   /* CAN Controller 1 Mailbox 20 Data 0 Register */
-#define                  CAN1_MB20_DATA1  0xffc03684   /* CAN Controller 1 Mailbox 20 Data 1 Register */
-#define                  CAN1_MB20_DATA2  0xffc03688   /* CAN Controller 1 Mailbox 20 Data 2 Register */
-#define                  CAN1_MB20_DATA3  0xffc0368c   /* CAN Controller 1 Mailbox 20 Data 3 Register */
-#define                 CAN1_MB20_LENGTH  0xffc03690   /* CAN Controller 1 Mailbox 20 Length Register */
-#define              CAN1_MB20_TIMESTAMP  0xffc03694   /* CAN Controller 1 Mailbox 20 Timestamp Register */
-#define                    CAN1_MB20_ID0  0xffc03698   /* CAN Controller 1 Mailbox 20 ID0 Register */
-#define                    CAN1_MB20_ID1  0xffc0369c   /* CAN Controller 1 Mailbox 20 ID1 Register */
-#define                  CAN1_MB21_DATA0  0xffc036a0   /* CAN Controller 1 Mailbox 21 Data 0 Register */
-#define                  CAN1_MB21_DATA1  0xffc036a4   /* CAN Controller 1 Mailbox 21 Data 1 Register */
-#define                  CAN1_MB21_DATA2  0xffc036a8   /* CAN Controller 1 Mailbox 21 Data 2 Register */
-#define                  CAN1_MB21_DATA3  0xffc036ac   /* CAN Controller 1 Mailbox 21 Data 3 Register */
-#define                 CAN1_MB21_LENGTH  0xffc036b0   /* CAN Controller 1 Mailbox 21 Length Register */
-#define              CAN1_MB21_TIMESTAMP  0xffc036b4   /* CAN Controller 1 Mailbox 21 Timestamp Register */
-#define                    CAN1_MB21_ID0  0xffc036b8   /* CAN Controller 1 Mailbox 21 ID0 Register */
-#define                    CAN1_MB21_ID1  0xffc036bc   /* CAN Controller 1 Mailbox 21 ID1 Register */
-#define                  CAN1_MB22_DATA0  0xffc036c0   /* CAN Controller 1 Mailbox 22 Data 0 Register */
-#define                  CAN1_MB22_DATA1  0xffc036c4   /* CAN Controller 1 Mailbox 22 Data 1 Register */
-#define                  CAN1_MB22_DATA2  0xffc036c8   /* CAN Controller 1 Mailbox 22 Data 2 Register */
-#define                  CAN1_MB22_DATA3  0xffc036cc   /* CAN Controller 1 Mailbox 22 Data 3 Register */
-#define                 CAN1_MB22_LENGTH  0xffc036d0   /* CAN Controller 1 Mailbox 22 Length Register */
-#define              CAN1_MB22_TIMESTAMP  0xffc036d4   /* CAN Controller 1 Mailbox 22 Timestamp Register */
-#define                    CAN1_MB22_ID0  0xffc036d8   /* CAN Controller 1 Mailbox 22 ID0 Register */
-#define                    CAN1_MB22_ID1  0xffc036dc   /* CAN Controller 1 Mailbox 22 ID1 Register */
-#define                  CAN1_MB23_DATA0  0xffc036e0   /* CAN Controller 1 Mailbox 23 Data 0 Register */
-#define                  CAN1_MB23_DATA1  0xffc036e4   /* CAN Controller 1 Mailbox 23 Data 1 Register */
-#define                  CAN1_MB23_DATA2  0xffc036e8   /* CAN Controller 1 Mailbox 23 Data 2 Register */
-#define                  CAN1_MB23_DATA3  0xffc036ec   /* CAN Controller 1 Mailbox 23 Data 3 Register */
-#define                 CAN1_MB23_LENGTH  0xffc036f0   /* CAN Controller 1 Mailbox 23 Length Register */
-#define              CAN1_MB23_TIMESTAMP  0xffc036f4   /* CAN Controller 1 Mailbox 23 Timestamp Register */
-#define                    CAN1_MB23_ID0  0xffc036f8   /* CAN Controller 1 Mailbox 23 ID0 Register */
-#define                    CAN1_MB23_ID1  0xffc036fc   /* CAN Controller 1 Mailbox 23 ID1 Register */
-#define                  CAN1_MB24_DATA0  0xffc03700   /* CAN Controller 1 Mailbox 24 Data 0 Register */
-#define                  CAN1_MB24_DATA1  0xffc03704   /* CAN Controller 1 Mailbox 24 Data 1 Register */
-#define                  CAN1_MB24_DATA2  0xffc03708   /* CAN Controller 1 Mailbox 24 Data 2 Register */
-#define                  CAN1_MB24_DATA3  0xffc0370c   /* CAN Controller 1 Mailbox 24 Data 3 Register */
-#define                 CAN1_MB24_LENGTH  0xffc03710   /* CAN Controller 1 Mailbox 24 Length Register */
-#define              CAN1_MB24_TIMESTAMP  0xffc03714   /* CAN Controller 1 Mailbox 24 Timestamp Register */
-#define                    CAN1_MB24_ID0  0xffc03718   /* CAN Controller 1 Mailbox 24 ID0 Register */
-#define                    CAN1_MB24_ID1  0xffc0371c   /* CAN Controller 1 Mailbox 24 ID1 Register */
-#define                  CAN1_MB25_DATA0  0xffc03720   /* CAN Controller 1 Mailbox 25 Data 0 Register */
-#define                  CAN1_MB25_DATA1  0xffc03724   /* CAN Controller 1 Mailbox 25 Data 1 Register */
-#define                  CAN1_MB25_DATA2  0xffc03728   /* CAN Controller 1 Mailbox 25 Data 2 Register */
-#define                  CAN1_MB25_DATA3  0xffc0372c   /* CAN Controller 1 Mailbox 25 Data 3 Register */
-#define                 CAN1_MB25_LENGTH  0xffc03730   /* CAN Controller 1 Mailbox 25 Length Register */
-#define              CAN1_MB25_TIMESTAMP  0xffc03734   /* CAN Controller 1 Mailbox 25 Timestamp Register */
-#define                    CAN1_MB25_ID0  0xffc03738   /* CAN Controller 1 Mailbox 25 ID0 Register */
-#define                    CAN1_MB25_ID1  0xffc0373c   /* CAN Controller 1 Mailbox 25 ID1 Register */
-#define                  CAN1_MB26_DATA0  0xffc03740   /* CAN Controller 1 Mailbox 26 Data 0 Register */
-#define                  CAN1_MB26_DATA1  0xffc03744   /* CAN Controller 1 Mailbox 26 Data 1 Register */
-#define                  CAN1_MB26_DATA2  0xffc03748   /* CAN Controller 1 Mailbox 26 Data 2 Register */
-#define                  CAN1_MB26_DATA3  0xffc0374c   /* CAN Controller 1 Mailbox 26 Data 3 Register */
-#define                 CAN1_MB26_LENGTH  0xffc03750   /* CAN Controller 1 Mailbox 26 Length Register */
-#define              CAN1_MB26_TIMESTAMP  0xffc03754   /* CAN Controller 1 Mailbox 26 Timestamp Register */
-#define                    CAN1_MB26_ID0  0xffc03758   /* CAN Controller 1 Mailbox 26 ID0 Register */
-#define                    CAN1_MB26_ID1  0xffc0375c   /* CAN Controller 1 Mailbox 26 ID1 Register */
-#define                  CAN1_MB27_DATA0  0xffc03760   /* CAN Controller 1 Mailbox 27 Data 0 Register */
-#define                  CAN1_MB27_DATA1  0xffc03764   /* CAN Controller 1 Mailbox 27 Data 1 Register */
-#define                  CAN1_MB27_DATA2  0xffc03768   /* CAN Controller 1 Mailbox 27 Data 2 Register */
-#define                  CAN1_MB27_DATA3  0xffc0376c   /* CAN Controller 1 Mailbox 27 Data 3 Register */
-#define                 CAN1_MB27_LENGTH  0xffc03770   /* CAN Controller 1 Mailbox 27 Length Register */
-#define              CAN1_MB27_TIMESTAMP  0xffc03774   /* CAN Controller 1 Mailbox 27 Timestamp Register */
-#define                    CAN1_MB27_ID0  0xffc03778   /* CAN Controller 1 Mailbox 27 ID0 Register */
-#define                    CAN1_MB27_ID1  0xffc0377c   /* CAN Controller 1 Mailbox 27 ID1 Register */
-#define                  CAN1_MB28_DATA0  0xffc03780   /* CAN Controller 1 Mailbox 28 Data 0 Register */
-#define                  CAN1_MB28_DATA1  0xffc03784   /* CAN Controller 1 Mailbox 28 Data 1 Register */
-#define                  CAN1_MB28_DATA2  0xffc03788   /* CAN Controller 1 Mailbox 28 Data 2 Register */
-#define                  CAN1_MB28_DATA3  0xffc0378c   /* CAN Controller 1 Mailbox 28 Data 3 Register */
-#define                 CAN1_MB28_LENGTH  0xffc03790   /* CAN Controller 1 Mailbox 28 Length Register */
-#define              CAN1_MB28_TIMESTAMP  0xffc03794   /* CAN Controller 1 Mailbox 28 Timestamp Register */
-#define                    CAN1_MB28_ID0  0xffc03798   /* CAN Controller 1 Mailbox 28 ID0 Register */
-#define                    CAN1_MB28_ID1  0xffc0379c   /* CAN Controller 1 Mailbox 28 ID1 Register */
-#define                  CAN1_MB29_DATA0  0xffc037a0   /* CAN Controller 1 Mailbox 29 Data 0 Register */
-#define                  CAN1_MB29_DATA1  0xffc037a4   /* CAN Controller 1 Mailbox 29 Data 1 Register */
-#define                  CAN1_MB29_DATA2  0xffc037a8   /* CAN Controller 1 Mailbox 29 Data 2 Register */
-#define                  CAN1_MB29_DATA3  0xffc037ac   /* CAN Controller 1 Mailbox 29 Data 3 Register */
-#define                 CAN1_MB29_LENGTH  0xffc037b0   /* CAN Controller 1 Mailbox 29 Length Register */
-#define              CAN1_MB29_TIMESTAMP  0xffc037b4   /* CAN Controller 1 Mailbox 29 Timestamp Register */
-#define                    CAN1_MB29_ID0  0xffc037b8   /* CAN Controller 1 Mailbox 29 ID0 Register */
-#define                    CAN1_MB29_ID1  0xffc037bc   /* CAN Controller 1 Mailbox 29 ID1 Register */
-#define                  CAN1_MB30_DATA0  0xffc037c0   /* CAN Controller 1 Mailbox 30 Data 0 Register */
-#define                  CAN1_MB30_DATA1  0xffc037c4   /* CAN Controller 1 Mailbox 30 Data 1 Register */
-#define                  CAN1_MB30_DATA2  0xffc037c8   /* CAN Controller 1 Mailbox 30 Data 2 Register */
-#define                  CAN1_MB30_DATA3  0xffc037cc   /* CAN Controller 1 Mailbox 30 Data 3 Register */
-#define                 CAN1_MB30_LENGTH  0xffc037d0   /* CAN Controller 1 Mailbox 30 Length Register */
-#define              CAN1_MB30_TIMESTAMP  0xffc037d4   /* CAN Controller 1 Mailbox 30 Timestamp Register */
-#define                    CAN1_MB30_ID0  0xffc037d8   /* CAN Controller 1 Mailbox 30 ID0 Register */
-#define                    CAN1_MB30_ID1  0xffc037dc   /* CAN Controller 1 Mailbox 30 ID1 Register */
-#define                  CAN1_MB31_DATA0  0xffc037e0   /* CAN Controller 1 Mailbox 31 Data 0 Register */
-#define                  CAN1_MB31_DATA1  0xffc037e4   /* CAN Controller 1 Mailbox 31 Data 1 Register */
-#define                  CAN1_MB31_DATA2  0xffc037e8   /* CAN Controller 1 Mailbox 31 Data 2 Register */
-#define                  CAN1_MB31_DATA3  0xffc037ec   /* CAN Controller 1 Mailbox 31 Data 3 Register */
-#define                 CAN1_MB31_LENGTH  0xffc037f0   /* CAN Controller 1 Mailbox 31 Length Register */
-#define              CAN1_MB31_TIMESTAMP  0xffc037f4   /* CAN Controller 1 Mailbox 31 Timestamp Register */
-#define                    CAN1_MB31_ID0  0xffc037f8   /* CAN Controller 1 Mailbox 31 ID0 Register */
-#define                    CAN1_MB31_ID1  0xffc037fc   /* CAN Controller 1 Mailbox 31 ID1 Register */
-
-/* ATAPI Registers */
-
-#define                    ATAPI_CONTROL  0xffc03800   /* ATAPI Control Register */
-#define                     ATAPI_STATUS  0xffc03804   /* ATAPI Status Register */
-#define                   ATAPI_DEV_ADDR  0xffc03808   /* ATAPI Device Register Address */
-#define                  ATAPI_DEV_TXBUF  0xffc0380c   /* ATAPI Device Register Write Data */
-#define                  ATAPI_DEV_RXBUF  0xffc03810   /* ATAPI Device Register Read Data */
-#define                   ATAPI_INT_MASK  0xffc03814   /* ATAPI Interrupt Mask Register */
-#define                 ATAPI_INT_STATUS  0xffc03818   /* ATAPI Interrupt Status Register */
-#define                   ATAPI_XFER_LEN  0xffc0381c   /* ATAPI Length of Transfer */
-#define                ATAPI_LINE_STATUS  0xffc03820   /* ATAPI Line Status */
-#define                   ATAPI_SM_STATE  0xffc03824   /* ATAPI State Machine Status */
-#define                  ATAPI_TERMINATE  0xffc03828   /* ATAPI Host Terminate */
-#define                 ATAPI_PIO_TFRCNT  0xffc0382c   /* ATAPI PIO mode transfer count */
-#define                 ATAPI_DMA_TFRCNT  0xffc03830   /* ATAPI DMA mode transfer count */
-#define               ATAPI_UMAIN_TFRCNT  0xffc03834   /* ATAPI UDMAIN transfer count */
-#define             ATAPI_UDMAOUT_TFRCNT  0xffc03838   /* ATAPI UDMAOUT transfer count */
-#define                  ATAPI_REG_TIM_0  0xffc03840   /* ATAPI Register Transfer Timing 0 */
-#define                  ATAPI_PIO_TIM_0  0xffc03844   /* ATAPI PIO Timing 0 Register */
-#define                  ATAPI_PIO_TIM_1  0xffc03848   /* ATAPI PIO Timing 1 Register */
-#define                ATAPI_MULTI_TIM_0  0xffc03850   /* ATAPI Multi-DMA Timing 0 Register */
-#define                ATAPI_MULTI_TIM_1  0xffc03854   /* ATAPI Multi-DMA Timing 1 Register */
-#define                ATAPI_MULTI_TIM_2  0xffc03858   /* ATAPI Multi-DMA Timing 2 Register */
-#define                ATAPI_ULTRA_TIM_0  0xffc03860   /* ATAPI Ultra-DMA Timing 0 Register */
-#define                ATAPI_ULTRA_TIM_1  0xffc03864   /* ATAPI Ultra-DMA Timing 1 Register */
-#define                ATAPI_ULTRA_TIM_2  0xffc03868   /* ATAPI Ultra-DMA Timing 2 Register */
-#define                ATAPI_ULTRA_TIM_3  0xffc0386c   /* ATAPI Ultra-DMA Timing 3 Register */
-
-/* SDH Registers */
-
-#define                      SDH_PWR_CTL  0xffc03900   /* SDH Power Control */
-#define                      SDH_CLK_CTL  0xffc03904   /* SDH Clock Control */
-#define                     SDH_ARGUMENT  0xffc03908   /* SDH Argument */
-#define                      SDH_COMMAND  0xffc0390c   /* SDH Command */
-#define                     SDH_RESP_CMD  0xffc03910   /* SDH Response Command */
-#define                    SDH_RESPONSE0  0xffc03914   /* SDH Response0 */
-#define                    SDH_RESPONSE1  0xffc03918   /* SDH Response1 */
-#define                    SDH_RESPONSE2  0xffc0391c   /* SDH Response2 */
-#define                    SDH_RESPONSE3  0xffc03920   /* SDH Response3 */
-#define                   SDH_DATA_TIMER  0xffc03924   /* SDH Data Timer */
-#define                    SDH_DATA_LGTH  0xffc03928   /* SDH Data Length */
-#define                     SDH_DATA_CTL  0xffc0392c   /* SDH Data Control */
-#define                     SDH_DATA_CNT  0xffc03930   /* SDH Data Counter */
-#define                       SDH_STATUS  0xffc03934   /* SDH Status */
-#define                   SDH_STATUS_CLR  0xffc03938   /* SDH Status Clear */
-#define                        SDH_MASK0  0xffc0393c   /* SDH Interrupt0 Mask */
-#define                        SDH_MASK1  0xffc03940   /* SDH Interrupt1 Mask */
-#define                     SDH_FIFO_CNT  0xffc03948   /* SDH FIFO Counter */
-#define                         SDH_FIFO  0xffc03980   /* SDH Data FIFO */
-#define                     SDH_E_STATUS  0xffc039c0   /* SDH Exception Status */
-#define                       SDH_E_MASK  0xffc039c4   /* SDH Exception Mask */
-#define                          SDH_CFG  0xffc039c8   /* SDH Configuration */
-#define                   SDH_RD_WAIT_EN  0xffc039cc   /* SDH Read Wait Enable */
-#define                         SDH_PID0  0xffc039d0   /* SDH Peripheral Identification0 */
-#define                         SDH_PID1  0xffc039d4   /* SDH Peripheral Identification1 */
-#define                         SDH_PID2  0xffc039d8   /* SDH Peripheral Identification2 */
-#define                         SDH_PID3  0xffc039dc   /* SDH Peripheral Identification3 */
-#define                         SDH_PID4  0xffc039e0   /* SDH Peripheral Identification4 */
-#define                         SDH_PID5  0xffc039e4   /* SDH Peripheral Identification5 */
-#define                         SDH_PID6  0xffc039e8   /* SDH Peripheral Identification6 */
-#define                         SDH_PID7  0xffc039ec   /* SDH Peripheral Identification7 */
-
-/* HOST Port Registers */
-
-#define                     HOST_CONTROL  0xffc03a00   /* HOST Control Register */
-#define                      HOST_STATUS  0xffc03a04   /* HOST Status Register */
-#define                     HOST_TIMEOUT  0xffc03a08   /* HOST Acknowledge Mode Timeout Register */
-
-/* USB Control Registers */
-
-#define                        USB_FADDR  0xffc03c00   /* Function address register */
-#define                        USB_POWER  0xffc03c04   /* Power management register */
-#define                       USB_INTRTX  0xffc03c08   /* Interrupt register for endpoint 0 and Tx endpoint 1 to 7 */
-#define                       USB_INTRRX  0xffc03c0c   /* Interrupt register for Rx endpoints 1 to 7 */
-#define                      USB_INTRTXE  0xffc03c10   /* Interrupt enable register for IntrTx */
-#define                      USB_INTRRXE  0xffc03c14   /* Interrupt enable register for IntrRx */
-#define                      USB_INTRUSB  0xffc03c18   /* Interrupt register for common USB interrupts */
-#define                     USB_INTRUSBE  0xffc03c1c   /* Interrupt enable register for IntrUSB */
-#define                        USB_FRAME  0xffc03c20   /* USB frame number */
-#define                        USB_INDEX  0xffc03c24   /* Index register for selecting the indexed endpoint registers */
-#define                     USB_TESTMODE  0xffc03c28   /* Enabled USB 20 test modes */
-#define                     USB_GLOBINTR  0xffc03c2c   /* Global Interrupt Mask register and Wakeup Exception Interrupt */
-#define                   USB_GLOBAL_CTL  0xffc03c30   /* Global Clock Control for the core */
-
-/* USB Packet Control Registers */
-
-#define                USB_TX_MAX_PACKET  0xffc03c40   /* Maximum packet size for Host Tx endpoint */
-#define                         USB_CSR0  0xffc03c44   /* Control Status register for endpoint 0 and Control Status register for Host Tx endpoint */
-#define                        USB_TXCSR  0xffc03c44   /* Control Status register for endpoint 0 and Control Status register for Host Tx endpoint */
-#define                USB_RX_MAX_PACKET  0xffc03c48   /* Maximum packet size for Host Rx endpoint */
-#define                        USB_RXCSR  0xffc03c4c   /* Control Status register for Host Rx endpoint */
-#define                       USB_COUNT0  0xffc03c50   /* Number of bytes received in endpoint 0 FIFO and Number of bytes received in Host Tx endpoint */
-#define                      USB_RXCOUNT  0xffc03c50   /* Number of bytes received in endpoint 0 FIFO and Number of bytes received in Host Tx endpoint */
-#define                       USB_TXTYPE  0xffc03c54   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint */
-#define                    USB_NAKLIMIT0  0xffc03c58   /* Sets the NAK response timeout on Endpoint 0 and on Bulk transfers for Host Tx endpoint */
-#define                   USB_TXINTERVAL  0xffc03c58   /* Sets the NAK response timeout on Endpoint 0 and on Bulk transfers for Host Tx endpoint */
-#define                       USB_RXTYPE  0xffc03c5c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint */
-#define                   USB_RXINTERVAL  0xffc03c60   /* Sets the polling interval for Interrupt and Isochronous transfers or the NAK response timeout on Bulk transfers */
-#define                      USB_TXCOUNT  0xffc03c68   /* Number of bytes to be written to the selected endpoint Tx FIFO */
-
-/* USB Endpoint FIFO Registers */
-
-#define                     USB_EP0_FIFO  0xffc03c80   /* Endpoint 0 FIFO */
-#define                     USB_EP1_FIFO  0xffc03c88   /* Endpoint 1 FIFO */
-#define                     USB_EP2_FIFO  0xffc03c90   /* Endpoint 2 FIFO */
-#define                     USB_EP3_FIFO  0xffc03c98   /* Endpoint 3 FIFO */
-#define                     USB_EP4_FIFO  0xffc03ca0   /* Endpoint 4 FIFO */
-#define                     USB_EP5_FIFO  0xffc03ca8   /* Endpoint 5 FIFO */
-#define                     USB_EP6_FIFO  0xffc03cb0   /* Endpoint 6 FIFO */
-#define                     USB_EP7_FIFO  0xffc03cb8   /* Endpoint 7 FIFO */
-
-/* USB OTG Control Registers */
-
-#define                  USB_OTG_DEV_CTL  0xffc03d00   /* OTG Device Control Register */
-#define                 USB_OTG_VBUS_IRQ  0xffc03d04   /* OTG VBUS Control Interrupts */
-#define                USB_OTG_VBUS_MASK  0xffc03d08   /* VBUS Control Interrupt Enable */
-
-/* USB Phy Control Registers */
-
-#define                     USB_LINKINFO  0xffc03d48   /* Enables programming of some PHY-side delays */
-#define                        USB_VPLEN  0xffc03d4c   /* Determines duration of VBUS pulse for VBUS charging */
-#define                      USB_HS_EOF1  0xffc03d50   /* Time buffer for High-Speed transactions */
-#define                      USB_FS_EOF1  0xffc03d54   /* Time buffer for Full-Speed transactions */
-#define                      USB_LS_EOF1  0xffc03d58   /* Time buffer for Low-Speed transactions */
-
-/* (APHY_CNTRL is for ADI usage only) */
-
-#define                   USB_APHY_CNTRL  0xffc03de0   /* Register that increases visibility of Analog PHY */
-
-/* (APHY_CALIB is for ADI usage only) */
-
-#define                   USB_APHY_CALIB  0xffc03de4   /* Register used to set some calibration values */
-#define                  USB_APHY_CNTRL2  0xffc03de8   /* Register used to prevent re-enumeration once Moab goes into hibernate mode */
-
-/* (PHY_TEST is for ADI usage only) */
-
-#define                     USB_PHY_TEST  0xffc03dec   /* Used for reducing simulation time and simplifies FIFO testability */
-#define                  USB_PLLOSC_CTRL  0xffc03df0   /* Used to program different parameters for USB PLL and Oscillator */
-#define                   USB_SRP_CLKDIV  0xffc03df4   /* Used to program clock divide value for the clock fed to the SRP detection logic */
-
-/* USB Endpoint 0 Control Registers */
-
-#define                USB_EP_NI0_TXMAXP  0xffc03e00   /* Maximum packet size for Host Tx endpoint0 */
-#define                 USB_EP_NI0_TXCSR  0xffc03e04   /* Control Status register for endpoint 0 */
-#define                USB_EP_NI0_RXMAXP  0xffc03e08   /* Maximum packet size for Host Rx endpoint0 */
-#define                 USB_EP_NI0_RXCSR  0xffc03e0c   /* Control Status register for Host Rx endpoint0 */
-#define               USB_EP_NI0_RXCOUNT  0xffc03e10   /* Number of bytes received in endpoint 0 FIFO */
-#define                USB_EP_NI0_TXTYPE  0xffc03e14   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint0 */
-#define            USB_EP_NI0_TXINTERVAL  0xffc03e18   /* Sets the NAK response timeout on Endpoint 0 */
-#define                USB_EP_NI0_RXTYPE  0xffc03e1c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint0 */
-#define            USB_EP_NI0_RXINTERVAL  0xffc03e20   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint0 */
-
-/* USB Endpoint 1 Control Registers */
-
-#define               USB_EP_NI0_TXCOUNT  0xffc03e28   /* Number of bytes to be written to the endpoint0 Tx FIFO */
-#define                USB_EP_NI1_TXMAXP  0xffc03e40   /* Maximum packet size for Host Tx endpoint1 */
-#define                 USB_EP_NI1_TXCSR  0xffc03e44   /* Control Status register for endpoint1 */
-#define                USB_EP_NI1_RXMAXP  0xffc03e48   /* Maximum packet size for Host Rx endpoint1 */
-#define                 USB_EP_NI1_RXCSR  0xffc03e4c   /* Control Status register for Host Rx endpoint1 */
-#define               USB_EP_NI1_RXCOUNT  0xffc03e50   /* Number of bytes received in endpoint1 FIFO */
-#define                USB_EP_NI1_TXTYPE  0xffc03e54   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint1 */
-#define            USB_EP_NI1_TXINTERVAL  0xffc03e58   /* Sets the NAK response timeout on Endpoint1 */
-#define                USB_EP_NI1_RXTYPE  0xffc03e5c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint1 */
-#define            USB_EP_NI1_RXINTERVAL  0xffc03e60   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint1 */
-
-/* USB Endpoint 2 Control Registers */
-
-#define               USB_EP_NI1_TXCOUNT  0xffc03e68   /* Number of bytes to be written to the+H102 endpoint1 Tx FIFO */
-#define                USB_EP_NI2_TXMAXP  0xffc03e80   /* Maximum packet size for Host Tx endpoint2 */
-#define                 USB_EP_NI2_TXCSR  0xffc03e84   /* Control Status register for endpoint2 */
-#define                USB_EP_NI2_RXMAXP  0xffc03e88   /* Maximum packet size for Host Rx endpoint2 */
-#define                 USB_EP_NI2_RXCSR  0xffc03e8c   /* Control Status register for Host Rx endpoint2 */
-#define               USB_EP_NI2_RXCOUNT  0xffc03e90   /* Number of bytes received in endpoint2 FIFO */
-#define                USB_EP_NI2_TXTYPE  0xffc03e94   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint2 */
-#define            USB_EP_NI2_TXINTERVAL  0xffc03e98   /* Sets the NAK response timeout on Endpoint2 */
-#define                USB_EP_NI2_RXTYPE  0xffc03e9c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint2 */
-#define            USB_EP_NI2_RXINTERVAL  0xffc03ea0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint2 */
-
-/* USB Endpoint 3 Control Registers */
-
-#define               USB_EP_NI2_TXCOUNT  0xffc03ea8   /* Number of bytes to be written to the endpoint2 Tx FIFO */
-#define                USB_EP_NI3_TXMAXP  0xffc03ec0   /* Maximum packet size for Host Tx endpoint3 */
-#define                 USB_EP_NI3_TXCSR  0xffc03ec4   /* Control Status register for endpoint3 */
-#define                USB_EP_NI3_RXMAXP  0xffc03ec8   /* Maximum packet size for Host Rx endpoint3 */
-#define                 USB_EP_NI3_RXCSR  0xffc03ecc   /* Control Status register for Host Rx endpoint3 */
-#define               USB_EP_NI3_RXCOUNT  0xffc03ed0   /* Number of bytes received in endpoint3 FIFO */
-#define                USB_EP_NI3_TXTYPE  0xffc03ed4   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint3 */
-#define            USB_EP_NI3_TXINTERVAL  0xffc03ed8   /* Sets the NAK response timeout on Endpoint3 */
-#define                USB_EP_NI3_RXTYPE  0xffc03edc   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint3 */
-#define            USB_EP_NI3_RXINTERVAL  0xffc03ee0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint3 */
-
-/* USB Endpoint 4 Control Registers */
-
-#define               USB_EP_NI3_TXCOUNT  0xffc03ee8   /* Number of bytes to be written to the H124endpoint3 Tx FIFO */
-#define                USB_EP_NI4_TXMAXP  0xffc03f00   /* Maximum packet size for Host Tx endpoint4 */
-#define                 USB_EP_NI4_TXCSR  0xffc03f04   /* Control Status register for endpoint4 */
-#define                USB_EP_NI4_RXMAXP  0xffc03f08   /* Maximum packet size for Host Rx endpoint4 */
-#define                 USB_EP_NI4_RXCSR  0xffc03f0c   /* Control Status register for Host Rx endpoint4 */
-#define               USB_EP_NI4_RXCOUNT  0xffc03f10   /* Number of bytes received in endpoint4 FIFO */
-#define                USB_EP_NI4_TXTYPE  0xffc03f14   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint4 */
-#define            USB_EP_NI4_TXINTERVAL  0xffc03f18   /* Sets the NAK response timeout on Endpoint4 */
-#define                USB_EP_NI4_RXTYPE  0xffc03f1c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint4 */
-#define            USB_EP_NI4_RXINTERVAL  0xffc03f20   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint4 */
-
-/* USB Endpoint 5 Control Registers */
-
-#define               USB_EP_NI4_TXCOUNT  0xffc03f28   /* Number of bytes to be written to the endpoint4 Tx FIFO */
-#define                USB_EP_NI5_TXMAXP  0xffc03f40   /* Maximum packet size for Host Tx endpoint5 */
-#define                 USB_EP_NI5_TXCSR  0xffc03f44   /* Control Status register for endpoint5 */
-#define                USB_EP_NI5_RXMAXP  0xffc03f48   /* Maximum packet size for Host Rx endpoint5 */
-#define                 USB_EP_NI5_RXCSR  0xffc03f4c   /* Control Status register for Host Rx endpoint5 */
-#define               USB_EP_NI5_RXCOUNT  0xffc03f50   /* Number of bytes received in endpoint5 FIFO */
-#define                USB_EP_NI5_TXTYPE  0xffc03f54   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint5 */
-#define            USB_EP_NI5_TXINTERVAL  0xffc03f58   /* Sets the NAK response timeout on Endpoint5 */
-#define                USB_EP_NI5_RXTYPE  0xffc03f5c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint5 */
-#define            USB_EP_NI5_RXINTERVAL  0xffc03f60   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint5 */
-
-/* USB Endpoint 6 Control Registers */
-
-#define               USB_EP_NI5_TXCOUNT  0xffc03f68   /* Number of bytes to be written to the H145endpoint5 Tx FIFO */
-#define                USB_EP_NI6_TXMAXP  0xffc03f80   /* Maximum packet size for Host Tx endpoint6 */
-#define                 USB_EP_NI6_TXCSR  0xffc03f84   /* Control Status register for endpoint6 */
-#define                USB_EP_NI6_RXMAXP  0xffc03f88   /* Maximum packet size for Host Rx endpoint6 */
-#define                 USB_EP_NI6_RXCSR  0xffc03f8c   /* Control Status register for Host Rx endpoint6 */
-#define               USB_EP_NI6_RXCOUNT  0xffc03f90   /* Number of bytes received in endpoint6 FIFO */
-#define                USB_EP_NI6_TXTYPE  0xffc03f94   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint6 */
-#define            USB_EP_NI6_TXINTERVAL  0xffc03f98   /* Sets the NAK response timeout on Endpoint6 */
-#define                USB_EP_NI6_RXTYPE  0xffc03f9c   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint6 */
-#define            USB_EP_NI6_RXINTERVAL  0xffc03fa0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint6 */
-
-/* USB Endpoint 7 Control Registers */
-
-#define               USB_EP_NI6_TXCOUNT  0xffc03fa8   /* Number of bytes to be written to the endpoint6 Tx FIFO */
-#define                USB_EP_NI7_TXMAXP  0xffc03fc0   /* Maximum packet size for Host Tx endpoint7 */
-#define                 USB_EP_NI7_TXCSR  0xffc03fc4   /* Control Status register for endpoint7 */
-#define                USB_EP_NI7_RXMAXP  0xffc03fc8   /* Maximum packet size for Host Rx endpoint7 */
-#define                 USB_EP_NI7_RXCSR  0xffc03fcc   /* Control Status register for Host Rx endpoint7 */
-#define               USB_EP_NI7_RXCOUNT  0xffc03fd0   /* Number of bytes received in endpoint7 FIFO */
-#define                USB_EP_NI7_TXTYPE  0xffc03fd4   /* Sets the transaction protocol and peripheral endpoint number for the Host Tx endpoint7 */
-#define            USB_EP_NI7_TXINTERVAL  0xffc03fd8   /* Sets the NAK response timeout on Endpoint7 */
-#define                USB_EP_NI7_RXTYPE  0xffc03fdc   /* Sets the transaction protocol and peripheral endpoint number for the Host Rx endpoint7 */
-#define            USB_EP_NI7_RXINTERVAL  0xffc03ff0   /* Sets the polling interval for Interrupt/Isochronous transfers or the NAK response timeout on Bulk transfers for Host Rx endpoint7 */
-#define               USB_EP_NI7_TXCOUNT  0xffc03ff8   /* Number of bytes to be written to the endpoint7 Tx FIFO */
-#define                USB_DMA_INTERRUPT  0xffc04000   /* Indicates pending interrupts for the DMA channels */
-
-/* USB Channel 0 Config Registers */
-
-#define                  USB_DMA0CONTROL  0xffc04004   /* DMA master channel 0 configuration */
-#define                  USB_DMA0ADDRLOW  0xffc04008   /* Lower 16-bits of memory source/destination address for DMA master channel 0 */
-#define                 USB_DMA0ADDRHIGH  0xffc0400c   /* Upper 16-bits of memory source/destination address for DMA master channel 0 */
-#define                 USB_DMA0COUNTLOW  0xffc04010   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 0 */
-#define                USB_DMA0COUNTHIGH  0xffc04014   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 0 */
-
-/* USB Channel 1 Config Registers */
-
-#define                  USB_DMA1CONTROL  0xffc04024   /* DMA master channel 1 configuration */
-#define                  USB_DMA1ADDRLOW  0xffc04028   /* Lower 16-bits of memory source/destination address for DMA master channel 1 */
-#define                 USB_DMA1ADDRHIGH  0xffc0402c   /* Upper 16-bits of memory source/destination address for DMA master channel 1 */
-#define                 USB_DMA1COUNTLOW  0xffc04030   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 1 */
-#define                USB_DMA1COUNTHIGH  0xffc04034   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 1 */
-
-/* USB Channel 2 Config Registers */
-
-#define                  USB_DMA2CONTROL  0xffc04044   /* DMA master channel 2 configuration */
-#define                  USB_DMA2ADDRLOW  0xffc04048   /* Lower 16-bits of memory source/destination address for DMA master channel 2 */
-#define                 USB_DMA2ADDRHIGH  0xffc0404c   /* Upper 16-bits of memory source/destination address for DMA master channel 2 */
-#define                 USB_DMA2COUNTLOW  0xffc04050   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 2 */
-#define                USB_DMA2COUNTHIGH  0xffc04054   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 2 */
-
-/* USB Channel 3 Config Registers */
-
-#define                  USB_DMA3CONTROL  0xffc04064   /* DMA master channel 3 configuration */
-#define                  USB_DMA3ADDRLOW  0xffc04068   /* Lower 16-bits of memory source/destination address for DMA master channel 3 */
-#define                 USB_DMA3ADDRHIGH  0xffc0406c   /* Upper 16-bits of memory source/destination address for DMA master channel 3 */
-#define                 USB_DMA3COUNTLOW  0xffc04070   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 3 */
-#define                USB_DMA3COUNTHIGH  0xffc04074   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 3 */
-
-/* USB Channel 4 Config Registers */
-
-#define                  USB_DMA4CONTROL  0xffc04084   /* DMA master channel 4 configuration */
-#define                  USB_DMA4ADDRLOW  0xffc04088   /* Lower 16-bits of memory source/destination address for DMA master channel 4 */
-#define                 USB_DMA4ADDRHIGH  0xffc0408c   /* Upper 16-bits of memory source/destination address for DMA master channel 4 */
-#define                 USB_DMA4COUNTLOW  0xffc04090   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 4 */
-#define                USB_DMA4COUNTHIGH  0xffc04094   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 4 */
-
-/* USB Channel 5 Config Registers */
-
-#define                  USB_DMA5CONTROL  0xffc040a4   /* DMA master channel 5 configuration */
-#define                  USB_DMA5ADDRLOW  0xffc040a8   /* Lower 16-bits of memory source/destination address for DMA master channel 5 */
-#define                 USB_DMA5ADDRHIGH  0xffc040ac   /* Upper 16-bits of memory source/destination address for DMA master channel 5 */
-#define                 USB_DMA5COUNTLOW  0xffc040b0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 5 */
-#define                USB_DMA5COUNTHIGH  0xffc040b4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 5 */
-
-/* USB Channel 6 Config Registers */
-
-#define                  USB_DMA6CONTROL  0xffc040c4   /* DMA master channel 6 configuration */
-#define                  USB_DMA6ADDRLOW  0xffc040c8   /* Lower 16-bits of memory source/destination address for DMA master channel 6 */
-#define                 USB_DMA6ADDRHIGH  0xffc040cc   /* Upper 16-bits of memory source/destination address for DMA master channel 6 */
-#define                 USB_DMA6COUNTLOW  0xffc040d0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 6 */
-#define                USB_DMA6COUNTHIGH  0xffc040d4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 6 */
-
-/* USB Channel 7 Config Registers */
-
-#define                  USB_DMA7CONTROL  0xffc040e4   /* DMA master channel 7 configuration */
-#define                  USB_DMA7ADDRLOW  0xffc040e8   /* Lower 16-bits of memory source/destination address for DMA master channel 7 */
-#define                 USB_DMA7ADDRHIGH  0xffc040ec   /* Upper 16-bits of memory source/destination address for DMA master channel 7 */
-#define                 USB_DMA7COUNTLOW  0xffc040f0   /* Lower 16-bits of byte count of DMA transfer for DMA master channel 7 */
-#define                USB_DMA7COUNTHIGH  0xffc040f4   /* Upper 16-bits of byte count of DMA transfer for DMA master channel 7 */
-
-/* Keypad Registers */
-
-#define                         KPAD_CTL  0xffc04100   /* Controls keypad module enable and disable */
-#define                    KPAD_PRESCALE  0xffc04104   /* Establish a time base for programing the KPAD_MSEL register */
-#define                        KPAD_MSEL  0xffc04108   /* Selects delay parameters for keypad interface sensitivity */
-#define                      KPAD_ROWCOL  0xffc0410c   /* Captures the row and column output values of the keys pressed */
-#define                        KPAD_STAT  0xffc04110   /* Holds and clears the status of the keypad interface interrupt */
-#define                    KPAD_SOFTEVAL  0xffc04114   /* Lets software force keypad interface to check for keys being pressed */
-
-/* Pixel Compositor (PIXC) Registers */
-
-#define                         PIXC_CTL  0xffc04400   /* Overlay enable, resampling mode, I/O data format, transparency enable, watermark level, FIFO status */
-#define                         PIXC_PPL  0xffc04404   /* Holds the number of pixels per line of the display */
-#define                         PIXC_LPF  0xffc04408   /* Holds the number of lines per frame of the display */
-#define                     PIXC_AHSTART  0xffc0440c   /* Contains horizontal start pixel information of the overlay data (set A) */
-#define                       PIXC_AHEND  0xffc04410   /* Contains horizontal end pixel information of the overlay data (set A) */
-#define                     PIXC_AVSTART  0xffc04414   /* Contains vertical start pixel information of the overlay data (set A) */
-#define                       PIXC_AVEND  0xffc04418   /* Contains vertical end pixel information of the overlay data (set A) */
-#define                     PIXC_ATRANSP  0xffc0441c   /* Contains the transparency ratio (set A) */
-#define                     PIXC_BHSTART  0xffc04420   /* Contains horizontal start pixel information of the overlay data (set B) */
-#define                       PIXC_BHEND  0xffc04424   /* Contains horizontal end pixel information of the overlay data (set B) */
-#define                     PIXC_BVSTART  0xffc04428   /* Contains vertical start pixel information of the overlay data (set B) */
-#define                       PIXC_BVEND  0xffc0442c   /* Contains vertical end pixel information of the overlay data (set B) */
-#define                     PIXC_BTRANSP  0xffc04430   /* Contains the transparency ratio (set B) */
-#define                    PIXC_INTRSTAT  0xffc0443c   /* Overlay interrupt configuration/status */
-#define                       PIXC_RYCON  0xffc04440   /* Color space conversion matrix register. Contains the R/Y conversion coefficients */
-#define                       PIXC_GUCON  0xffc04444   /* Color space conversion matrix register. Contains the G/U conversion coefficients */
-#define                       PIXC_BVCON  0xffc04448   /* Color space conversion matrix register. Contains the B/V conversion coefficients */
-#define                      PIXC_CCBIAS  0xffc0444c   /* Bias values for the color space conversion matrix */
-#define                          PIXC_TC  0xffc04450   /* Holds the transparent color value */
-
-/* Handshake MDMA 0 Registers */
-
-#define                   HMDMA0_CONTROL  0xffc04500   /* Handshake MDMA0 Control Register */
-#define                    HMDMA0_ECINIT  0xffc04504   /* Handshake MDMA0 Initial Edge Count Register */
-#define                    HMDMA0_BCINIT  0xffc04508   /* Handshake MDMA0 Initial Block Count Register */
-#define                  HMDMA0_ECURGENT  0xffc0450c   /* Handshake MDMA0 Urgent Edge Count Threshold Register */
-#define                HMDMA0_ECOVERFLOW  0xffc04510   /* Handshake MDMA0 Edge Count Overflow Interrupt Register */
-#define                    HMDMA0_ECOUNT  0xffc04514   /* Handshake MDMA0 Current Edge Count Register */
-#define                    HMDMA0_BCOUNT  0xffc04518   /* Handshake MDMA0 Current Block Count Register */
-
-/* Handshake MDMA 1 Registers */
-
-#define                   HMDMA1_CONTROL  0xffc04540   /* Handshake MDMA1 Control Register */
-#define                    HMDMA1_ECINIT  0xffc04544   /* Handshake MDMA1 Initial Edge Count Register */
-#define                    HMDMA1_BCINIT  0xffc04548   /* Handshake MDMA1 Initial Block Count Register */
-#define                  HMDMA1_ECURGENT  0xffc0454c   /* Handshake MDMA1 Urgent Edge Count Threshold Register */
-#define                HMDMA1_ECOVERFLOW  0xffc04550   /* Handshake MDMA1 Edge Count Overflow Interrupt Register */
-#define                    HMDMA1_ECOUNT  0xffc04554   /* Handshake MDMA1 Current Edge Count Register */
-#define                    HMDMA1_BCOUNT  0xffc04558   /* Handshake MDMA1 Current Block Count Register */
-
-
-/* ********************************************************** */
-/*     SINGLE BIT MACRO PAIRS (bit mask and negated one)      */
-/*     and MULTI BIT READ MACROS                              */
-/* ********************************************************** */
-
-/* Bit masks for PIXC_CTL */
-
-#define                   PIXC_EN  0x1        /* Pixel Compositor Enable */
-#define                  OVR_A_EN  0x2        /* Overlay A Enable */
-#define                  OVR_B_EN  0x4        /* Overlay B Enable */
-#define                  IMG_FORM  0x8        /* Image Data Format */
-#define                  OVR_FORM  0x10       /* Overlay Data Format */
-#define                  OUT_FORM  0x20       /* Output Data Format */
-#define                   UDS_MOD  0x40       /* Resampling Mode */
-#define                     TC_EN  0x80       /* Transparent Color Enable */
-#define                  IMG_STAT  0x300      /* Image FIFO Status */
-#define                  OVR_STAT  0xc00      /* Overlay FIFO Status */
-#define                    WM_LVL  0x3000     /* FIFO Watermark Level */
-
-/* Bit masks for PIXC_AHSTART */
-
-#define                  A_HSTART  0xfff      /* Horizontal Start Coordinates */
-
-/* Bit masks for PIXC_AHEND */
-
-#define                    A_HEND  0xfff      /* Horizontal End Coordinates */
-
-/* Bit masks for PIXC_AVSTART */
-
-#define                  A_VSTART  0x3ff      /* Vertical Start Coordinates */
-
-/* Bit masks for PIXC_AVEND */
-
-#define                    A_VEND  0x3ff      /* Vertical End Coordinates */
-
-/* Bit masks for PIXC_ATRANSP */
-
-#define                  A_TRANSP  0xf        /* Transparency Value */
-
-/* Bit masks for PIXC_BHSTART */
-
-#define                  B_HSTART  0xfff      /* Horizontal Start Coordinates */
-
-/* Bit masks for PIXC_BHEND */
-
-#define                    B_HEND  0xfff      /* Horizontal End Coordinates */
-
-/* Bit masks for PIXC_BVSTART */
-
-#define                  B_VSTART  0x3ff      /* Vertical Start Coordinates */
-
-/* Bit masks for PIXC_BVEND */
-
-#define                    B_VEND  0x3ff      /* Vertical End Coordinates */
-
-/* Bit masks for PIXC_BTRANSP */
-
-#define                  B_TRANSP  0xf        /* Transparency Value */
-
-/* Bit masks for PIXC_INTRSTAT */
-
-#define                OVR_INT_EN  0x1        /* Interrupt at End of Last Valid Overlay */
-#define                FRM_INT_EN  0x2        /* Interrupt at End of Frame */
-#define              OVR_INT_STAT  0x4        /* Overlay Interrupt Status */
-#define              FRM_INT_STAT  0x8        /* Frame Interrupt Status */
-
-/* Bit masks for PIXC_RYCON */
-
-#define                       A11  0x3ff      /* A11 in the Coefficient Matrix */
-#define                       A12  0xffc00    /* A12 in the Coefficient Matrix */
-#define                       A13  0x3ff00000 /* A13 in the Coefficient Matrix */
-#define                  RY_MULT4  0x40000000 /* Multiply Row by 4 */
-
-/* Bit masks for PIXC_GUCON */
-
-#define                       A21  0x3ff      /* A21 in the Coefficient Matrix */
-#define                       A22  0xffc00    /* A22 in the Coefficient Matrix */
-#define                       A23  0x3ff00000 /* A23 in the Coefficient Matrix */
-#define                  GU_MULT4  0x40000000 /* Multiply Row by 4 */
-
-/* Bit masks for PIXC_BVCON */
-
-#define                       A31  0x3ff      /* A31 in the Coefficient Matrix */
-#define                       A32  0xffc00    /* A32 in the Coefficient Matrix */
-#define                       A33  0x3ff00000 /* A33 in the Coefficient Matrix */
-#define                  BV_MULT4  0x40000000 /* Multiply Row by 4 */
-
-/* Bit masks for PIXC_CCBIAS */
-
-#define                       A14  0x3ff      /* A14 in the Bias Vector */
-#define                       A24  0xffc00    /* A24 in the Bias Vector */
-#define                       A34  0x3ff00000 /* A34 in the Bias Vector */
-
-/* Bit masks for PIXC_TC */
-
-#define                  RY_TRANS  0xff       /* Transparent Color - R/Y Component */
-#define                  GU_TRANS  0xff00     /* Transparent Color - G/U Component */
-#define                  BV_TRANS  0xff0000   /* Transparent Color - B/V Component */
-
-/* Bit masks for HOST_CONTROL */
-
-#define                   HOST_EN  0x1        /* Host Enable */
-#define                  HOST_END  0x2        /* Host Endianess */
-#define                 DATA_SIZE  0x4        /* Data Size */
-#define                  HOST_RST  0x8        /* Host Reset */
-#define                  HRDY_OVR  0x20       /* Host Ready Override */
-#define                  INT_MODE  0x40       /* Interrupt Mode */
-#define                     BT_EN  0x80       /* Bus Timeout Enable */
-#define                       EHW  0x100      /* Enable Host Write */
-#define                       EHR  0x200      /* Enable Host Read */
-#define                       BDR  0x400      /* Burst DMA Requests */
-
-/* Bit masks for HOST_STATUS */
-
-#define                 DMA_READY  0x1        /* DMA Ready */
-#define                  FIFOFULL  0x2        /* FIFO Full */
-#define                 FIFOEMPTY  0x4        /* FIFO Empty */
-#define              DMA_COMPLETE  0x8        /* DMA Complete */
-#define                      HSHK  0x10       /* Host Handshake */
-#define                   TIMEOUT  0x20       /* Host Timeout */
-#define                      HIRQ  0x40       /* Host Interrupt Request */
-#define                ALLOW_CNFG  0x80       /* Allow New Configuration */
-#define                   DMA_DIR  0x100      /* DMA Direction */
-#define                       BTE  0x200      /* Bus Timeout Enabled */
-
-/* Bit masks for HOST_TIMEOUT */
-
-#define             COUNT_TIMEOUT  0x7ff      /* Host Timeout count */
-
-/* Bit masks for MXVR_CONFIG */
-
-#define                    MXVREN  0x1        /* MXVR Enable */
-#define                      MMSM  0x2        /* MXVR Master/Slave Mode Select */
-#define                    ACTIVE  0x4        /* Active Mode */
-#define                    SDELAY  0x8        /* Synchronous Data Delay */
-#define                   NCMRXEN  0x10       /* Normal Control Message Receive Enable */
-#define                   RWRRXEN  0x20       /* Remote Write Receive Enable */
-#define                     MTXEN  0x40       /* MXVR Transmit Data Enable */
-#define                    MTXONB  0x80       /* MXVR Phy Transmitter On */
-#define                   EPARITY  0x100      /* Even Parity Select */
-#define                       MSB  0x1e00     /* Master Synchronous Boundary */
-#define                    APRXEN  0x2000     /* Asynchronous Packet Receive Enable */
-#define                    WAKEUP  0x4000     /* Wake-Up */
-#define                     LMECH  0x8000     /* Lock Mechanism Select */
-
-/* Bit masks for MXVR_STATE_0 */
-
-#define                      NACT  0x1        /* Network Activity */
-#define                    SBLOCK  0x2        /* Super Block Lock */
-#define                   FMPLLST  0xc        /* Frequency Multiply PLL SM State */
-#define                  CDRPLLST  0xe0       /* Clock/Data Recovery PLL SM State */
-#define                     APBSY  0x100      /* Asynchronous Packet Transmit Buffer Busy */
-#define                     APARB  0x200      /* Asynchronous Packet Arbitrating */
-#define                      APTX  0x400      /* Asynchronous Packet Transmitting */
-#define                      APRX  0x800      /* Receiving Asynchronous Packet */
-#define                     CMBSY  0x1000     /* Control Message Transmit Buffer Busy */
-#define                     CMARB  0x2000     /* Control Message Arbitrating */
-#define                      CMTX  0x4000     /* Control Message Transmitting */
-#define                      CMRX  0x8000     /* Receiving Control Message */
-#define                    MRXONB  0x10000    /* MRXONB Pin State */
-#define                     RGSIP  0x20000    /* Remote Get Source In Progress */
-#define                     DALIP  0x40000    /* Resource Deallocate In Progress */
-#define                      ALIP  0x80000    /* Resource Allocate In Progress */
-#define                     RRDIP  0x100000   /* Remote Read In Progress */
-#define                     RWRIP  0x200000   /* Remote Write In Progress */
-#define                     FLOCK  0x400000   /* Frame Lock */
-#define                     BLOCK  0x800000   /* Block Lock */
-#define                       RSB  0xf000000  /* Received Synchronous Boundary */
-#define                   DERRNUM  0xf0000000 /* DMA Error Channel Number */
-
-/* Bit masks for MXVR_STATE_1 */
-
-#define                   SRXNUMB  0xf        /* Synchronous Receive FIFO Number of Bytes */
-#define                   STXNUMB  0xf0       /* Synchronous Transmit FIFO Number of Bytes */
-#define                    APCONT  0x100      /* Asynchronous Packet Continuation */
-#define                  OBERRNUM  0xe00      /* DMA Out of Bounds Error Channel Number */
-#define                DMAACTIVE0  0x10000    /* DMA0 Active */
-#define                DMAACTIVE1  0x20000    /* DMA1 Active */
-#define                DMAACTIVE2  0x40000    /* DMA2 Active */
-#define                DMAACTIVE3  0x80000    /* DMA3 Active */
-#define                DMAACTIVE4  0x100000   /* DMA4 Active */
-#define                DMAACTIVE5  0x200000   /* DMA5 Active */
-#define                DMAACTIVE6  0x400000   /* DMA6 Active */
-#define                DMAACTIVE7  0x800000   /* DMA7 Active */
-#define                  DMAPMEN0  0x1000000  /* DMA0 Pattern Matching Enabled */
-#define                  DMAPMEN1  0x2000000  /* DMA1 Pattern Matching Enabled */
-#define                  DMAPMEN2  0x4000000  /* DMA2 Pattern Matching Enabled */
-#define                  DMAPMEN3  0x8000000  /* DMA3 Pattern Matching Enabled */
-#define                  DMAPMEN4  0x10000000 /* DMA4 Pattern Matching Enabled */
-#define                  DMAPMEN5  0x20000000 /* DMA5 Pattern Matching Enabled */
-#define                  DMAPMEN6  0x40000000 /* DMA6 Pattern Matching Enabled */
-#define                  DMAPMEN7  0x80000000 /* DMA7 Pattern Matching Enabled */
-
-/* Bit masks for MXVR_INT_STAT_0 */
-
-#define                      NI2A  0x1        /* Network Inactive to Active */
-#define                      NA2I  0x2        /* Network Active to Inactive */
-#define                     SBU2L  0x4        /* Super Block Unlock to Lock */
-#define                     SBL2U  0x8        /* Super Block Lock to Unlock */
-#define                       PRU  0x10       /* Position Register Updated */
-#define                      MPRU  0x20       /* Maximum Position Register Updated */
-#define                       DRU  0x40       /* Delay Register Updated */
-#define                      MDRU  0x80       /* Maximum Delay Register Updated */
-#define                       SBU  0x100      /* Synchronous Boundary Updated */
-#define                       ATU  0x200      /* Allocation Table Updated */
-#define                      FCZ0  0x400      /* Frame Counter 0 Zero */
-#define                      FCZ1  0x800      /* Frame Counter 1 Zero */
-#define                      PERR  0x1000     /* Parity Error */
-#define                      MH2L  0x2000     /* MRXONB High to Low */
-#define                      ML2H  0x4000     /* MRXONB Low to High */
-#define                       WUP  0x8000     /* Wake-Up Preamble Received */
-#define                      FU2L  0x10000    /* Frame Unlock to Lock */
-#define                      FL2U  0x20000    /* Frame Lock to Unlock */
-#define                      BU2L  0x40000    /* Block Unlock to Lock */
-#define                      BL2U  0x80000    /* Block Lock to Unlock */
-#define                     OBERR  0x100000   /* DMA Out of Bounds Error */
-#define                       PFL  0x200000   /* PLL Frequency Locked */
-#define                       SCZ  0x400000   /* System Clock Counter Zero */
-#define                      FERR  0x800000   /* FIFO Error */
-#define                       CMR  0x1000000  /* Control Message Received */
-#define                     CMROF  0x2000000  /* Control Message Receive Buffer Overflow */
-#define                      CMTS  0x4000000  /* Control Message Transmit Buffer Successfully Sent */
-#define                      CMTC  0x8000000  /* Control Message Transmit Buffer Successfully Cancelled */
-#define                      RWRC  0x10000000 /* Remote Write Control Message Completed */
-#define                       BCZ  0x20000000 /* Block Counter Zero */
-#define                     BMERR  0x40000000 /* Biphase Mark Coding Error */
-#define                      DERR  0x80000000 /* DMA Error */
-
-/* Bit masks for MXVR_INT_STAT_1 */
-
-#define                    HDONE0  0x1        /* DMA0 Half Done */
-#define                     DONE0  0x2        /* DMA0 Done */
-#define                       APR  0x4        /* Asynchronous Packet Received */
-#define                     APROF  0x8        /* Asynchronous Packet Receive Buffer Overflow */
-#define                    HDONE1  0x10       /* DMA1 Half Done */
-#define                     DONE1  0x20       /* DMA1 Done */
-#define                      APTS  0x40       /* Asynchronous Packet Transmit Buffer Successfully Sent */
-#define                      APTC  0x80       /* Asynchronous Packet Transmit Buffer Successfully Cancelled */
-#define                    HDONE2  0x100      /* DMA2 Half Done */
-#define                     DONE2  0x200      /* DMA2 Done */
-#define                     APRCE  0x400      /* Asynchronous Packet Receive CRC Error */
-#define                     APRPE  0x800      /* Asynchronous Packet Receive Packet Error */
-#define                    HDONE3  0x1000     /* DMA3 Half Done */
-#define                     DONE3  0x2000     /* DMA3 Done */
-#define                    HDONE4  0x10000    /* DMA4 Half Done */
-#define                     DONE4  0x20000    /* DMA4 Done */
-#define                    HDONE5  0x100000   /* DMA5 Half Done */
-#define                     DONE5  0x200000   /* DMA5 Done */
-#define                    HDONE6  0x1000000  /* DMA6 Half Done */
-#define                     DONE6  0x2000000  /* DMA6 Done */
-#define                    HDONE7  0x10000000 /* DMA7 Half Done */
-#define                     DONE7  0x20000000 /* DMA7 Done */
-
-/* Bit masks for MXVR_INT_EN_0 */
-
-#define                    NI2AEN  0x1        /* Network Inactive to Active Interrupt Enable */
-#define                    NA2IEN  0x2        /* Network Active to Inactive Interrupt Enable */
-#define                   SBU2LEN  0x4        /* Super Block Unlock to Lock Interrupt Enable */
-#define                   SBL2UEN  0x8        /* Super Block Lock to Unlock Interrupt Enable */
-#define                     PRUEN  0x10       /* Position Register Updated Interrupt Enable */
-#define                    MPRUEN  0x20       /* Maximum Position Register Updated Interrupt Enable */
-#define                     DRUEN  0x40       /* Delay Register Updated Interrupt Enable */
-#define                    MDRUEN  0x80       /* Maximum Delay Register Updated Interrupt Enable */
-#define                     SBUEN  0x100      /* Synchronous Boundary Updated Interrupt Enable */
-#define                     ATUEN  0x200      /* Allocation Table Updated Interrupt Enable */
-#define                    FCZ0EN  0x400      /* Frame Counter 0 Zero Interrupt Enable */
-#define                    FCZ1EN  0x800      /* Frame Counter 1 Zero Interrupt Enable */
-#define                    PERREN  0x1000     /* Parity Error Interrupt Enable */
-#define                    MH2LEN  0x2000     /* MRXONB High to Low Interrupt Enable */
-#define                    ML2HEN  0x4000     /* MRXONB Low to High Interrupt Enable */
-#define                     WUPEN  0x8000     /* Wake-Up Preamble Received Interrupt Enable */
-#define                    FU2LEN  0x10000    /* Frame Unlock to Lock Interrupt Enable */
-#define                    FL2UEN  0x20000    /* Frame Lock to Unlock Interrupt Enable */
-#define                    BU2LEN  0x40000    /* Block Unlock to Lock Interrupt Enable */
-#define                    BL2UEN  0x80000    /* Block Lock to Unlock Interrupt Enable */
-#define                   OBERREN  0x100000   /* DMA Out of Bounds Error Interrupt Enable */
-#define                     PFLEN  0x200000   /* PLL Frequency Locked Interrupt Enable */
-#define                     SCZEN  0x400000   /* System Clock Counter Zero Interrupt Enable */
-#define                    FERREN  0x800000   /* FIFO Error Interrupt Enable */
-#define                     CMREN  0x1000000  /* Control Message Received Interrupt Enable */
-#define                   CMROFEN  0x2000000  /* Control Message Receive Buffer Overflow Interrupt Enable */
-#define                    CMTSEN  0x4000000  /* Control Message Transmit Buffer Successfully Sent Interrupt Enable */
-#define                    CMTCEN  0x8000000  /* Control Message Transmit Buffer Successfully Cancelled Interrupt Enable */
-#define                    RWRCEN  0x10000000 /* Remote Write Control Message Completed Interrupt Enable */
-#define                     BCZEN  0x20000000 /* Block Counter Zero Interrupt Enable */
-#define                   BMERREN  0x40000000 /* Biphase Mark Coding Error Interrupt Enable */
-#define                    DERREN  0x80000000 /* DMA Error Interrupt Enable */
-
-/* Bit masks for MXVR_INT_EN_1 */
-
-#define                  HDONEEN0  0x1        /* DMA0 Half Done Interrupt Enable */
-#define                   DONEEN0  0x2        /* DMA0 Done Interrupt Enable */
-#define                     APREN  0x4        /* Asynchronous Packet Received Interrupt Enable */
-#define                   APROFEN  0x8        /* Asynchronous Packet Receive Buffer Overflow Interrupt Enable */
-#define                  HDONEEN1  0x10       /* DMA1 Half Done Interrupt Enable */
-#define                   DONEEN1  0x20       /* DMA1 Done Interrupt Enable */
-#define                    APTSEN  0x40       /* Asynchronous Packet Transmit Buffer Successfully Sent Interrupt Enable */
-#define                    APTCEN  0x80       /* Asynchronous Packet Transmit Buffer Successfully Cancelled Interrupt Enable */
-#define                  HDONEEN2  0x100      /* DMA2 Half Done Interrupt Enable */
-#define                   DONEEN2  0x200      /* DMA2 Done Interrupt Enable */
-#define                   APRCEEN  0x400      /* Asynchronous Packet Receive CRC Error Interrupt Enable */
-#define                   APRPEEN  0x800      /* Asynchronous Packet Receive Packet Error Interrupt Enable */
-#define                  HDONEEN3  0x1000     /* DMA3 Half Done Interrupt Enable */
-#define                   DONEEN3  0x2000     /* DMA3 Done Interrupt Enable */
-#define                  HDONEEN4  0x10000    /* DMA4 Half Done Interrupt Enable */
-#define                   DONEEN4  0x20000    /* DMA4 Done Interrupt Enable */
-#define                  HDONEEN5  0x100000   /* DMA5 Half Done Interrupt Enable */
-#define                   DONEEN5  0x200000   /* DMA5 Done Interrupt Enable */
-#define                  HDONEEN6  0x1000000  /* DMA6 Half Done Interrupt Enable */
-#define                   DONEEN6  0x2000000  /* DMA6 Done Interrupt Enable */
-#define                  HDONEEN7  0x10000000 /* DMA7 Half Done Interrupt Enable */
-#define                   DONEEN7  0x20000000 /* DMA7 Done Interrupt Enable */
-
-/* Bit masks for MXVR_POSITION */
-
-#define                  POSITION  0x3f       /* Node Position */
-#define                    PVALID  0x8000     /* Node Position Valid */
-
-/* Bit masks for MXVR_MAX_POSITION */
-
-#define                 MPOSITION  0x3f       /* Maximum Node Position */
-#define                   MPVALID  0x8000     /* Maximum Node Position Valid */
-
-/* Bit masks for MXVR_DELAY */
-
-#define                     DELAY  0x3f       /* Node Frame Delay */
-#define                    DVALID  0x8000     /* Node Frame Delay Valid */
-
-/* Bit masks for MXVR_MAX_DELAY */
-
-#define                    MDELAY  0x3f       /* Maximum Node Frame Delay */
-#define                   MDVALID  0x8000     /* Maximum Node Frame Delay Valid */
-
-/* Bit masks for MXVR_LADDR */
-
-#define                     LADDR  0xffff     /* Logical Address */
-#define                    LVALID  0x80000000 /* Logical Address Valid */
-
-/* Bit masks for MXVR_GADDR */
-
-#define                    GADDRL  0xff       /* Group Address Lower Byte */
-#define                    GVALID  0x8000     /* Group Address Valid */
-
-/* Bit masks for MXVR_AADDR */
-
-#define                     AADDR  0xffff     /* Alternate Address */
-#define                    AVALID  0x80000000 /* Alternate Address Valid */
-
-/* Bit masks for MXVR_ALLOC_0 */
-
-#define                       CL0  0x7f       /* Channel 0 Connection Label */
-#define                      CIU0  0x80       /* Channel 0 In Use */
-#define                       CL1  0x7f00     /* Channel 0 Connection Label */
-#define                      CIU1  0x8000     /* Channel 0 In Use */
-#define                       CL2  0x7f0000   /* Channel 0 Connection Label */
-#define                      CIU2  0x800000   /* Channel 0 In Use */
-#define                       CL3  0x7f000000 /* Channel 0 Connection Label */
-#define                      CIU3  0x80000000 /* Channel 0 In Use */
-
-/* Bit masks for MXVR_ALLOC_1 */
-
-#define                       CL4  0x7f       /* Channel 4 Connection Label */
-#define                      CIU4  0x80       /* Channel 4 In Use */
-#define                       CL5  0x7f00     /* Channel 5 Connection Label */
-#define                      CIU5  0x8000     /* Channel 5 In Use */
-#define                       CL6  0x7f0000   /* Channel 6 Connection Label */
-#define                      CIU6  0x800000   /* Channel 6 In Use */
-#define                       CL7  0x7f000000 /* Channel 7 Connection Label */
-#define                      CIU7  0x80000000 /* Channel 7 In Use */
-
-/* Bit masks for MXVR_ALLOC_2 */
-
-#define                       CL8  0x7f       /* Channel 8 Connection Label */
-#define                      CIU8  0x80       /* Channel 8 In Use */
-#define                       CL9  0x7f00     /* Channel 9 Connection Label */
-#define                      CIU9  0x8000     /* Channel 9 In Use */
-#define                      CL10  0x7f0000   /* Channel 10 Connection Label */
-#define                     CIU10  0x800000   /* Channel 10 In Use */
-#define                      CL11  0x7f000000 /* Channel 11 Connection Label */
-#define                     CIU11  0x80000000 /* Channel 11 In Use */
-
-/* Bit masks for MXVR_ALLOC_3 */
-
-#define                      CL12  0x7f       /* Channel 12 Connection Label */
-#define                     CIU12  0x80       /* Channel 12 In Use */
-#define                      CL13  0x7f00     /* Channel 13 Connection Label */
-#define                     CIU13  0x8000     /* Channel 13 In Use */
-#define                      CL14  0x7f0000   /* Channel 14 Connection Label */
-#define                     CIU14  0x800000   /* Channel 14 In Use */
-#define                      CL15  0x7f000000 /* Channel 15 Connection Label */
-#define                     CIU15  0x80000000 /* Channel 15 In Use */
-
-/* Bit masks for MXVR_ALLOC_4 */
-
-#define                      CL16  0x7f       /* Channel 16 Connection Label */
-#define                     CIU16  0x80       /* Channel 16 In Use */
-#define                      CL17  0x7f00     /* Channel 17 Connection Label */
-#define                     CIU17  0x8000     /* Channel 17 In Use */
-#define                      CL18  0x7f0000   /* Channel 18 Connection Label */
-#define                     CIU18  0x800000   /* Channel 18 In Use */
-#define                      CL19  0x7f000000 /* Channel 19 Connection Label */
-#define                     CIU19  0x80000000 /* Channel 19 In Use */
-
-/* Bit masks for MXVR_ALLOC_5 */
-
-#define                      CL20  0x7f       /* Channel 20 Connection Label */
-#define                     CIU20  0x80       /* Channel 20 In Use */
-#define                      CL21  0x7f00     /* Channel 21 Connection Label */
-#define                     CIU21  0x8000     /* Channel 21 In Use */
-#define                      CL22  0x7f0000   /* Channel 22 Connection Label */
-#define                     CIU22  0x800000   /* Channel 22 In Use */
-#define                      CL23  0x7f000000 /* Channel 23 Connection Label */
-#define                     CIU23  0x80000000 /* Channel 23 In Use */
-
-/* Bit masks for MXVR_ALLOC_6 */
-
-#define                      CL24  0x7f       /* Channel 24 Connection Label */
-#define                     CIU24  0x80       /* Channel 24 In Use */
-#define                      CL25  0x7f00     /* Channel 25 Connection Label */
-#define                     CIU25  0x8000     /* Channel 25 In Use */
-#define                      CL26  0x7f0000   /* Channel 26 Connection Label */
-#define                     CIU26  0x800000   /* Channel 26 In Use */
-#define                      CL27  0x7f000000 /* Channel 27 Connection Label */
-#define                     CIU27  0x80000000 /* Channel 27 In Use */
-
-/* Bit masks for MXVR_ALLOC_7 */
-
-#define                      CL28  0x7f       /* Channel 28 Connection Label */
-#define                     CIU28  0x80       /* Channel 28 In Use */
-#define                      CL29  0x7f00     /* Channel 29 Connection Label */
-#define                     CIU29  0x8000     /* Channel 29 In Use */
-#define                      CL30  0x7f0000   /* Channel 30 Connection Label */
-#define                     CIU30  0x800000   /* Channel 30 In Use */
-#define                      CL31  0x7f000000 /* Channel 31 Connection Label */
-#define                     CIU31  0x80000000 /* Channel 31 In Use */
-
-/* Bit masks for MXVR_ALLOC_8 */
-
-#define                      CL32  0x7f       /* Channel 32 Connection Label */
-#define                     CIU32  0x80       /* Channel 32 In Use */
-#define                      CL33  0x7f00     /* Channel 33 Connection Label */
-#define                     CIU33  0x8000     /* Channel 33 In Use */
-#define                      CL34  0x7f0000   /* Channel 34 Connection Label */
-#define                     CIU34  0x800000   /* Channel 34 In Use */
-#define                      CL35  0x7f000000 /* Channel 35 Connection Label */
-#define                     CIU35  0x80000000 /* Channel 35 In Use */
-
-/* Bit masks for MXVR_ALLOC_9 */
-
-#define                      CL36  0x7f       /* Channel 36 Connection Label */
-#define                     CIU36  0x80       /* Channel 36 In Use */
-#define                      CL37  0x7f00     /* Channel 37 Connection Label */
-#define                     CIU37  0x8000     /* Channel 37 In Use */
-#define                      CL38  0x7f0000   /* Channel 38 Connection Label */
-#define                     CIU38  0x800000   /* Channel 38 In Use */
-#define                      CL39  0x7f000000 /* Channel 39 Connection Label */
-#define                     CIU39  0x80000000 /* Channel 39 In Use */
-
-/* Bit masks for MXVR_ALLOC_10 */
-
-#define                      CL40  0x7f       /* Channel 40 Connection Label */
-#define                     CIU40  0x80       /* Channel 40 In Use */
-#define                      CL41  0x7f00     /* Channel 41 Connection Label */
-#define                     CIU41  0x8000     /* Channel 41 In Use */
-#define                      CL42  0x7f0000   /* Channel 42 Connection Label */
-#define                     CIU42  0x800000   /* Channel 42 In Use */
-#define                      CL43  0x7f000000 /* Channel 43 Connection Label */
-#define                     CIU43  0x80000000 /* Channel 43 In Use */
-
-/* Bit masks for MXVR_ALLOC_11 */
-
-#define                      CL44  0x7f       /* Channel 44 Connection Label */
-#define                     CIU44  0x80       /* Channel 44 In Use */
-#define                      CL45  0x7f00     /* Channel 45 Connection Label */
-#define                     CIU45  0x8000     /* Channel 45 In Use */
-#define                      CL46  0x7f0000   /* Channel 46 Connection Label */
-#define                     CIU46  0x800000   /* Channel 46 In Use */
-#define                      CL47  0x7f000000 /* Channel 47 Connection Label */
-#define                     CIU47  0x80000000 /* Channel 47 In Use */
-
-/* Bit masks for MXVR_ALLOC_12 */
-
-#define                      CL48  0x7f       /* Channel 48 Connection Label */
-#define                     CIU48  0x80       /* Channel 48 In Use */
-#define                      CL49  0x7f00     /* Channel 49 Connection Label */
-#define                     CIU49  0x8000     /* Channel 49 In Use */
-#define                      CL50  0x7f0000   /* Channel 50 Connection Label */
-#define                     CIU50  0x800000   /* Channel 50 In Use */
-#define                      CL51  0x7f000000 /* Channel 51 Connection Label */
-#define                     CIU51  0x80000000 /* Channel 51 In Use */
-
-/* Bit masks for MXVR_ALLOC_13 */
-
-#define                      CL52  0x7f       /* Channel 52 Connection Label */
-#define                     CIU52  0x80       /* Channel 52 In Use */
-#define                      CL53  0x7f00     /* Channel 53 Connection Label */
-#define                     CIU53  0x8000     /* Channel 53 In Use */
-#define                      CL54  0x7f0000   /* Channel 54 Connection Label */
-#define                     CIU54  0x800000   /* Channel 54 In Use */
-#define                      CL55  0x7f000000 /* Channel 55 Connection Label */
-#define                     CIU55  0x80000000 /* Channel 55 In Use */
-
-/* Bit masks for MXVR_ALLOC_14 */
-
-#define                      CL56  0x7f       /* Channel 56 Connection Label */
-#define                     CIU56  0x80       /* Channel 56 In Use */
-#define                      CL57  0x7f00     /* Channel 57 Connection Label */
-#define                     CIU57  0x8000     /* Channel 57 In Use */
-#define                      CL58  0x7f0000   /* Channel 58 Connection Label */
-#define                     CIU58  0x800000   /* Channel 58 In Use */
-#define                      CL59  0x7f000000 /* Channel 59 Connection Label */
-#define                     CIU59  0x80000000 /* Channel 59 In Use */
-
-/* MXVR_SYNC_LCHAN_0 Masks */
-
-#define LCHANPC0     0x0000000Flu
-#define LCHANPC1     0x000000F0lu
-#define LCHANPC2     0x00000F00lu
-#define LCHANPC3     0x0000F000lu
-#define LCHANPC4     0x000F0000lu
-#define LCHANPC5     0x00F00000lu
-#define LCHANPC6     0x0F000000lu
-#define LCHANPC7     0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_1 Masks */
-
-#define LCHANPC8     0x0000000Flu
-#define LCHANPC9     0x000000F0lu
-#define LCHANPC10    0x00000F00lu
-#define LCHANPC11    0x0000F000lu
-#define LCHANPC12    0x000F0000lu
-#define LCHANPC13    0x00F00000lu
-#define LCHANPC14    0x0F000000lu
-#define LCHANPC15    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_2 Masks */
-
-#define LCHANPC16    0x0000000Flu
-#define LCHANPC17    0x000000F0lu
-#define LCHANPC18    0x00000F00lu
-#define LCHANPC19    0x0000F000lu
-#define LCHANPC20    0x000F0000lu
-#define LCHANPC21    0x00F00000lu
-#define LCHANPC22    0x0F000000lu
-#define LCHANPC23    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_3 Masks */
-
-#define LCHANPC24    0x0000000Flu
-#define LCHANPC25    0x000000F0lu
-#define LCHANPC26    0x00000F00lu
-#define LCHANPC27    0x0000F000lu
-#define LCHANPC28    0x000F0000lu
-#define LCHANPC29    0x00F00000lu
-#define LCHANPC30    0x0F000000lu
-#define LCHANPC31    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_4 Masks */
-
-#define LCHANPC32    0x0000000Flu
-#define LCHANPC33    0x000000F0lu
-#define LCHANPC34    0x00000F00lu
-#define LCHANPC35    0x0000F000lu
-#define LCHANPC36    0x000F0000lu
-#define LCHANPC37    0x00F00000lu
-#define LCHANPC38    0x0F000000lu
-#define LCHANPC39    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_5 Masks */
-
-#define LCHANPC40    0x0000000Flu
-#define LCHANPC41    0x000000F0lu
-#define LCHANPC42    0x00000F00lu
-#define LCHANPC43    0x0000F000lu
-#define LCHANPC44    0x000F0000lu
-#define LCHANPC45    0x00F00000lu
-#define LCHANPC46    0x0F000000lu
-#define LCHANPC47    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_6 Masks */
-
-#define LCHANPC48    0x0000000Flu
-#define LCHANPC49    0x000000F0lu
-#define LCHANPC50    0x00000F00lu
-#define LCHANPC51    0x0000F000lu
-#define LCHANPC52    0x000F0000lu
-#define LCHANPC53    0x00F00000lu
-#define LCHANPC54    0x0F000000lu
-#define LCHANPC55    0xF0000000lu
-
-
-/* MXVR_SYNC_LCHAN_7 Masks */
-
-#define LCHANPC56    0x0000000Flu
-#define LCHANPC57    0x000000F0lu
-#define LCHANPC58    0x00000F00lu
-#define LCHANPC59    0x0000F000lu
-
-/* Bit masks for MXVR_DMAx_CONFIG */
-
-#define                    MDMAEN  0x1        /* DMA Channel Enable */
-#define                     DMADD  0x2        /* DMA Channel Direction */
-#define                 BY4SWAPEN  0x20       /* DMA Channel Four Byte Swap Enable */
-#define                     LCHAN  0x3c0      /* DMA Channel Logical Channel */
-#define                 BITSWAPEN  0x400      /* DMA Channel Bit Swap Enable */
-#define                 BY2SWAPEN  0x800      /* DMA Channel Two Byte Swap Enable */
-#define                     MFLOW  0x7000     /* DMA Channel Operation Flow */
-#define                   FIXEDPM  0x80000    /* DMA Channel Fixed Pattern Matching Select */
-#define                  STARTPAT  0x300000   /* DMA Channel Start Pattern Select */
-#define                   STOPPAT  0xc00000   /* DMA Channel Stop Pattern Select */
-#define                  COUNTPOS  0x1c000000 /* DMA Channel Count Position */
-
-/* Bit masks for MXVR_AP_CTL */
-
-#define                   STARTAP  0x1        /* Start Asynchronous Packet Transmission */
-#define                  CANCELAP  0x2        /* Cancel Asynchronous Packet Transmission */
-#define                   RESETAP  0x4        /* Reset Asynchronous Packet Arbitration */
-#define                    APRBE0  0x4000     /* Asynchronous Packet Receive Buffer Entry 0 */
-#define                    APRBE1  0x8000     /* Asynchronous Packet Receive Buffer Entry 1 */
-
-/* Bit masks for MXVR_APRB_START_ADDR */
-
-#define      MXVR_APRB_START_ADDR_MASK  0x1fffffe  /* Asynchronous Packet Receive Buffer Start Address */
-
-/* Bit masks for MXVR_APRB_CURR_ADDR */
-
-#define       MXVR_APRB_CURR_ADDR_MASK  0xffffffff /* Asynchronous Packet Receive Buffer Current Address */
-
-/* Bit masks for MXVR_APTB_START_ADDR */
-
-#define       MXVR_APTB_START_ADDR_MASK  0x1fffffe  /* Asynchronous Packet Transmit Buffer Start Address */
-
-/* Bit masks for MXVR_APTB_CURR_ADDR */
-
-#define        MXVR_APTB_CURR_ADDR_MASK  0xffffffff /* Asynchronous Packet Transmit Buffer Current Address */
-
-/* Bit masks for MXVR_CM_CTL */
-
-#define                   STARTCM  0x1        /* Start Control Message Transmission */
-#define                  CANCELCM  0x2        /* Cancel Control Message Transmission */
-#define                    CMRBE0  0x10000    /* Control Message Receive Buffer Entry 0 */
-#define                    CMRBE1  0x20000    /* Control Message Receive Buffer Entry 1 */
-#define                    CMRBE2  0x40000    /* Control Message Receive Buffer Entry 2 */
-#define                    CMRBE3  0x80000    /* Control Message Receive Buffer Entry 3 */
-#define                    CMRBE4  0x100000   /* Control Message Receive Buffer Entry 4 */
-#define                    CMRBE5  0x200000   /* Control Message Receive Buffer Entry 5 */
-#define                    CMRBE6  0x400000   /* Control Message Receive Buffer Entry 6 */
-#define                    CMRBE7  0x800000   /* Control Message Receive Buffer Entry 7 */
-#define                    CMRBE8  0x1000000  /* Control Message Receive Buffer Entry 8 */
-#define                    CMRBE9  0x2000000  /* Control Message Receive Buffer Entry 9 */
-#define                   CMRBE10  0x4000000  /* Control Message Receive Buffer Entry 10 */
-#define                   CMRBE11  0x8000000  /* Control Message Receive Buffer Entry 11 */
-#define                   CMRBE12  0x10000000 /* Control Message Receive Buffer Entry 12 */
-#define                   CMRBE13  0x20000000 /* Control Message Receive Buffer Entry 13 */
-#define                   CMRBE14  0x40000000 /* Control Message Receive Buffer Entry 14 */
-#define                   CMRBE15  0x80000000 /* Control Message Receive Buffer Entry 15 */
-
-/* Bit masks for MXVR_CMRB_START_ADDR */
-
-#define      MXVR_CMRB_START_ADDR_MASK  0x1fffffe  /* Control Message Receive Buffer Start Address */
-
-/* Bit masks for MXVR_CMRB_CURR_ADDR */
-
-#define       MXVR_CMRB_CURR_ADDR_MASK  0xffffffff /* Control Message Receive Buffer Current Address */
-
-/* Bit masks for MXVR_CMTB_START_ADDR */
-
-#define      MXVR_CMTB_START_ADDR_MASK  0x1fffffe  /* Control Message Transmit Buffer Start Address */
-
-/* Bit masks for MXVR_CMTB_CURR_ADDR */
-
-#define       MXVR_CMTB_CURR_ADDR_MASK  0xffffffff /* Control Message Transmit Buffer Current Address */
-
-/* Bit masks for MXVR_RRDB_START_ADDR */
-
-#define      MXVR_RRDB_START_ADDR_MASK  0x1fffffe  /* Remote Read Buffer Start Address */
-
-/* Bit masks for MXVR_RRDB_CURR_ADDR */
-
-#define       MXVR_RRDB_CURR_ADDR_MASK  0xffffffff /* Remote Read Buffer Current Address */
-
-/* Bit masks for MXVR_PAT_DATAx */
-
-#define              MATCH_DATA_0  0xff       /* Pattern Match Data Byte 0 */
-#define              MATCH_DATA_1  0xff00     /* Pattern Match Data Byte 1 */
-#define              MATCH_DATA_2  0xff0000   /* Pattern Match Data Byte 2 */
-#define              MATCH_DATA_3  0xff000000 /* Pattern Match Data Byte 3 */
-
-/* Bit masks for MXVR_PAT_EN_0 */
-
-#define              MATCH_EN_0_0  0x1        /* Pattern Match Enable Byte 0 Bit 0 */
-#define              MATCH_EN_0_1  0x2        /* Pattern Match Enable Byte 0 Bit 1 */
-#define              MATCH_EN_0_2  0x4        /* Pattern Match Enable Byte 0 Bit 2 */
-#define              MATCH_EN_0_3  0x8        /* Pattern Match Enable Byte 0 Bit 3 */
-#define              MATCH_EN_0_4  0x10       /* Pattern Match Enable Byte 0 Bit 4 */
-#define              MATCH_EN_0_5  0x20       /* Pattern Match Enable Byte 0 Bit 5 */
-#define              MATCH_EN_0_6  0x40       /* Pattern Match Enable Byte 0 Bit 6 */
-#define              MATCH_EN_0_7  0x80       /* Pattern Match Enable Byte 0 Bit 7 */
-#define              MATCH_EN_1_0  0x100      /* Pattern Match Enable Byte 1 Bit 0 */
-#define              MATCH_EN_1_1  0x200      /* Pattern Match Enable Byte 1 Bit 1 */
-#define              MATCH_EN_1_2  0x400      /* Pattern Match Enable Byte 1 Bit 2 */
-#define              MATCH_EN_1_3  0x800      /* Pattern Match Enable Byte 1 Bit 3 */
-#define              MATCH_EN_1_4  0x1000     /* Pattern Match Enable Byte 1 Bit 4 */
-#define              MATCH_EN_1_5  0x2000     /* Pattern Match Enable Byte 1 Bit 5 */
-#define              MATCH_EN_1_6  0x4000     /* Pattern Match Enable Byte 1 Bit 6 */
-#define              MATCH_EN_1_7  0x8000     /* Pattern Match Enable Byte 1 Bit 7 */
-#define              MATCH_EN_2_0  0x10000    /* Pattern Match Enable Byte 2 Bit 0 */
-#define              MATCH_EN_2_1  0x20000    /* Pattern Match Enable Byte 2 Bit 1 */
-#define              MATCH_EN_2_2  0x40000    /* Pattern Match Enable Byte 2 Bit 2 */
-#define              MATCH_EN_2_3  0x80000    /* Pattern Match Enable Byte 2 Bit 3 */
-#define              MATCH_EN_2_4  0x100000   /* Pattern Match Enable Byte 2 Bit 4 */
-#define              MATCH_EN_2_5  0x200000   /* Pattern Match Enable Byte 2 Bit 5 */
-#define              MATCH_EN_2_6  0x400000   /* Pattern Match Enable Byte 2 Bit 6 */
-#define              MATCH_EN_2_7  0x800000   /* Pattern Match Enable Byte 2 Bit 7 */
-#define              MATCH_EN_3_0  0x1000000  /* Pattern Match Enable Byte 3 Bit 0 */
-#define              MATCH_EN_3_1  0x2000000  /* Pattern Match Enable Byte 3 Bit 1 */
-#define              MATCH_EN_3_2  0x4000000  /* Pattern Match Enable Byte 3 Bit 2 */
-#define              MATCH_EN_3_3  0x8000000  /* Pattern Match Enable Byte 3 Bit 3 */
-#define              MATCH_EN_3_4  0x10000000 /* Pattern Match Enable Byte 3 Bit 4 */
-#define              MATCH_EN_3_5  0x20000000 /* Pattern Match Enable Byte 3 Bit 5 */
-#define              MATCH_EN_3_6  0x40000000 /* Pattern Match Enable Byte 3 Bit 6 */
-#define              MATCH_EN_3_7  0x80000000 /* Pattern Match Enable Byte 3 Bit 7 */
-
-/* Bit masks for MXVR_PAT_EN_1 */
-
-#define              MATCH_EN_0_0  0x1        /* Pattern Match Enable Byte 0 Bit 0 */
-#define              MATCH_EN_0_1  0x2        /* Pattern Match Enable Byte 0 Bit 1 */
-#define              MATCH_EN_0_2  0x4        /* Pattern Match Enable Byte 0 Bit 2 */
-#define              MATCH_EN_0_3  0x8        /* Pattern Match Enable Byte 0 Bit 3 */
-#define              MATCH_EN_0_4  0x10       /* Pattern Match Enable Byte 0 Bit 4 */
-#define              MATCH_EN_0_5  0x20       /* Pattern Match Enable Byte 0 Bit 5 */
-#define              MATCH_EN_0_6  0x40       /* Pattern Match Enable Byte 0 Bit 6 */
-#define              MATCH_EN_0_7  0x80       /* Pattern Match Enable Byte 0 Bit 7 */
-#define              MATCH_EN_1_0  0x100      /* Pattern Match Enable Byte 1 Bit 0 */
-#define              MATCH_EN_1_1  0x200      /* Pattern Match Enable Byte 1 Bit 1 */
-#define              MATCH_EN_1_2  0x400      /* Pattern Match Enable Byte 1 Bit 2 */
-#define              MATCH_EN_1_3  0x800      /* Pattern Match Enable Byte 1 Bit 3 */
-#define              MATCH_EN_1_4  0x1000     /* Pattern Match Enable Byte 1 Bit 4 */
-#define              MATCH_EN_1_5  0x2000     /* Pattern Match Enable Byte 1 Bit 5 */
-#define              MATCH_EN_1_6  0x4000     /* Pattern Match Enable Byte 1 Bit 6 */
-#define              MATCH_EN_1_7  0x8000     /* Pattern Match Enable Byte 1 Bit 7 */
-#define              MATCH_EN_2_0  0x10000    /* Pattern Match Enable Byte 2 Bit 0 */
-#define              MATCH_EN_2_1  0x20000    /* Pattern Match Enable Byte 2 Bit 1 */
-#define              MATCH_EN_2_2  0x40000    /* Pattern Match Enable Byte 2 Bit 2 */
-#define              MATCH_EN_2_3  0x80000    /* Pattern Match Enable Byte 2 Bit 3 */
-#define              MATCH_EN_2_4  0x100000   /* Pattern Match Enable Byte 2 Bit 4 */
-#define              MATCH_EN_2_5  0x200000   /* Pattern Match Enable Byte 2 Bit 5 */
-#define              MATCH_EN_2_6  0x400000   /* Pattern Match Enable Byte 2 Bit 6 */
-#define              MATCH_EN_2_7  0x800000   /* Pattern Match Enable Byte 2 Bit 7 */
-#define              MATCH_EN_3_0  0x1000000  /* Pattern Match Enable Byte 3 Bit 0 */
-#define              MATCH_EN_3_1  0x2000000  /* Pattern Match Enable Byte 3 Bit 1 */
-#define              MATCH_EN_3_2  0x4000000  /* Pattern Match Enable Byte 3 Bit 2 */
-#define              MATCH_EN_3_3  0x8000000  /* Pattern Match Enable Byte 3 Bit 3 */
-#define              MATCH_EN_3_4  0x10000000 /* Pattern Match Enable Byte 3 Bit 4 */
-#define              MATCH_EN_3_5  0x20000000 /* Pattern Match Enable Byte 3 Bit 5 */
-#define              MATCH_EN_3_6  0x40000000 /* Pattern Match Enable Byte 3 Bit 6 */
-#define              MATCH_EN_3_7  0x80000000 /* Pattern Match Enable Byte 3 Bit 7 */
-
-/* Bit masks for MXVR_FRAME_CNT_0 */
-
-#define                      FCNT  0xffff     /* Frame Count */
-
-/* Bit masks for MXVR_FRAME_CNT_1 */
-
-#define                      FCNT  0xffff     /* Frame Count */
-
-/* Bit masks for MXVR_ROUTING_0 */
-
-#define                    TX_CH0  0x3f       /* Transmit Channel 0 */
-#define                  MUTE_CH0  0x80       /* Mute Channel 0 */
-#define                    TX_CH1  0x3f00     /* Transmit Channel 0 */
-#define                  MUTE_CH1  0x8000     /* Mute Channel 0 */
-#define                    TX_CH2  0x3f0000   /* Transmit Channel 0 */
-#define                  MUTE_CH2  0x800000   /* Mute Channel 0 */
-#define                    TX_CH3  0x3f000000 /* Transmit Channel 0 */
-#define                  MUTE_CH3  0x80000000 /* Mute Channel 0 */
-
-/* Bit masks for MXVR_ROUTING_1 */
-
-#define                    TX_CH4  0x3f       /* Transmit Channel 4 */
-#define                  MUTE_CH4  0x80       /* Mute Channel 4 */
-#define                    TX_CH5  0x3f00     /* Transmit Channel 5 */
-#define                  MUTE_CH5  0x8000     /* Mute Channel 5 */
-#define                    TX_CH6  0x3f0000   /* Transmit Channel 6 */
-#define                  MUTE_CH6  0x800000   /* Mute Channel 6 */
-#define                    TX_CH7  0x3f000000 /* Transmit Channel 7 */
-#define                  MUTE_CH7  0x80000000 /* Mute Channel 7 */
-
-/* Bit masks for MXVR_ROUTING_2 */
-
-#define                    TX_CH8  0x3f       /* Transmit Channel 8 */
-#define                  MUTE_CH8  0x80       /* Mute Channel 8 */
-#define                    TX_CH9  0x3f00     /* Transmit Channel 9 */
-#define                  MUTE_CH9  0x8000     /* Mute Channel 9 */
-#define                   TX_CH10  0x3f0000   /* Transmit Channel 10 */
-#define                 MUTE_CH10  0x800000   /* Mute Channel 10 */
-#define                   TX_CH11  0x3f000000 /* Transmit Channel 11 */
-#define                 MUTE_CH11  0x80000000 /* Mute Channel 11 */
-
-/* Bit masks for MXVR_ROUTING_3 */
-
-#define                   TX_CH12  0x3f       /* Transmit Channel 12 */
-#define                 MUTE_CH12  0x80       /* Mute Channel 12 */
-#define                   TX_CH13  0x3f00     /* Transmit Channel 13 */
-#define                 MUTE_CH13  0x8000     /* Mute Channel 13 */
-#define                   TX_CH14  0x3f0000   /* Transmit Channel 14 */
-#define                 MUTE_CH14  0x800000   /* Mute Channel 14 */
-#define                   TX_CH15  0x3f000000 /* Transmit Channel 15 */
-#define                 MUTE_CH15  0x80000000 /* Mute Channel 15 */
-
-/* Bit masks for MXVR_ROUTING_4 */
-
-#define                   TX_CH16  0x3f       /* Transmit Channel 16 */
-#define                 MUTE_CH16  0x80       /* Mute Channel 16 */
-#define                   TX_CH17  0x3f00     /* Transmit Channel 17 */
-#define                 MUTE_CH17  0x8000     /* Mute Channel 17 */
-#define                   TX_CH18  0x3f0000   /* Transmit Channel 18 */
-#define                 MUTE_CH18  0x800000   /* Mute Channel 18 */
-#define                   TX_CH19  0x3f000000 /* Transmit Channel 19 */
-#define                 MUTE_CH19  0x80000000 /* Mute Channel 19 */
-
-/* Bit masks for MXVR_ROUTING_5 */
-
-#define                   TX_CH20  0x3f       /* Transmit Channel 20 */
-#define                 MUTE_CH20  0x80       /* Mute Channel 20 */
-#define                   TX_CH21  0x3f00     /* Transmit Channel 21 */
-#define                 MUTE_CH21  0x8000     /* Mute Channel 21 */
-#define                   TX_CH22  0x3f0000   /* Transmit Channel 22 */
-#define                 MUTE_CH22  0x800000   /* Mute Channel 22 */
-#define                   TX_CH23  0x3f000000 /* Transmit Channel 23 */
-#define                 MUTE_CH23  0x80000000 /* Mute Channel 23 */
-
-/* Bit masks for MXVR_ROUTING_6 */
-
-#define                   TX_CH24  0x3f       /* Transmit Channel 24 */
-#define                 MUTE_CH24  0x80       /* Mute Channel 24 */
-#define                   TX_CH25  0x3f00     /* Transmit Channel 25 */
-#define                 MUTE_CH25  0x8000     /* Mute Channel 25 */
-#define                   TX_CH26  0x3f0000   /* Transmit Channel 26 */
-#define                 MUTE_CH26  0x800000   /* Mute Channel 26 */
-#define                   TX_CH27  0x3f000000 /* Transmit Channel 27 */
-#define                 MUTE_CH27  0x80000000 /* Mute Channel 27 */
-
-/* Bit masks for MXVR_ROUTING_7 */
-
-#define                   TX_CH28  0x3f       /* Transmit Channel 28 */
-#define                 MUTE_CH28  0x80       /* Mute Channel 28 */
-#define                   TX_CH29  0x3f00     /* Transmit Channel 29 */
-#define                 MUTE_CH29  0x8000     /* Mute Channel 29 */
-#define                   TX_CH30  0x3f0000   /* Transmit Channel 30 */
-#define                 MUTE_CH30  0x800000   /* Mute Channel 30 */
-#define                   TX_CH31  0x3f000000 /* Transmit Channel 31 */
-#define                 MUTE_CH31  0x80000000 /* Mute Channel 31 */
-
-/* Bit masks for MXVR_ROUTING_8 */
-
-#define                   TX_CH32  0x3f       /* Transmit Channel 32 */
-#define                 MUTE_CH32  0x80       /* Mute Channel 32 */
-#define                   TX_CH33  0x3f00     /* Transmit Channel 33 */
-#define                 MUTE_CH33  0x8000     /* Mute Channel 33 */
-#define                   TX_CH34  0x3f0000   /* Transmit Channel 34 */
-#define                 MUTE_CH34  0x800000   /* Mute Channel 34 */
-#define                   TX_CH35  0x3f000000 /* Transmit Channel 35 */
-#define                 MUTE_CH35  0x80000000 /* Mute Channel 35 */
-
-/* Bit masks for MXVR_ROUTING_9 */
-
-#define                   TX_CH36  0x3f       /* Transmit Channel 36 */
-#define                 MUTE_CH36  0x80       /* Mute Channel 36 */
-#define                   TX_CH37  0x3f00     /* Transmit Channel 37 */
-#define                 MUTE_CH37  0x8000     /* Mute Channel 37 */
-#define                   TX_CH38  0x3f0000   /* Transmit Channel 38 */
-#define                 MUTE_CH38  0x800000   /* Mute Channel 38 */
-#define                   TX_CH39  0x3f000000 /* Transmit Channel 39 */
-#define                 MUTE_CH39  0x80000000 /* Mute Channel 39 */
-
-/* Bit masks for MXVR_ROUTING_10 */
-
-#define                   TX_CH40  0x3f       /* Transmit Channel 40 */
-#define                 MUTE_CH40  0x80       /* Mute Channel 40 */
-#define                   TX_CH41  0x3f00     /* Transmit Channel 41 */
-#define                 MUTE_CH41  0x8000     /* Mute Channel 41 */
-#define                   TX_CH42  0x3f0000   /* Transmit Channel 42 */
-#define                 MUTE_CH42  0x800000   /* Mute Channel 42 */
-#define                   TX_CH43  0x3f000000 /* Transmit Channel 43 */
-#define                 MUTE_CH43  0x80000000 /* Mute Channel 43 */
-
-/* Bit masks for MXVR_ROUTING_11 */
-
-#define                   TX_CH44  0x3f       /* Transmit Channel 44 */
-#define                 MUTE_CH44  0x80       /* Mute Channel 44 */
-#define                   TX_CH45  0x3f00     /* Transmit Channel 45 */
-#define                 MUTE_CH45  0x8000     /* Mute Channel 45 */
-#define                   TX_CH46  0x3f0000   /* Transmit Channel 46 */
-#define                 MUTE_CH46  0x800000   /* Mute Channel 46 */
-#define                   TX_CH47  0x3f000000 /* Transmit Channel 47 */
-#define                 MUTE_CH47  0x80000000 /* Mute Channel 47 */
-
-/* Bit masks for MXVR_ROUTING_12 */
-
-#define                   TX_CH48  0x3f       /* Transmit Channel 48 */
-#define                 MUTE_CH48  0x80       /* Mute Channel 48 */
-#define                   TX_CH49  0x3f00     /* Transmit Channel 49 */
-#define                 MUTE_CH49  0x8000     /* Mute Channel 49 */
-#define                   TX_CH50  0x3f0000   /* Transmit Channel 50 */
-#define                 MUTE_CH50  0x800000   /* Mute Channel 50 */
-#define                   TX_CH51  0x3f000000 /* Transmit Channel 51 */
-#define                 MUTE_CH51  0x80000000 /* Mute Channel 51 */
-
-/* Bit masks for MXVR_ROUTING_13 */
-
-#define                   TX_CH52  0x3f       /* Transmit Channel 52 */
-#define                 MUTE_CH52  0x80       /* Mute Channel 52 */
-#define                   TX_CH53  0x3f00     /* Transmit Channel 53 */
-#define                 MUTE_CH53  0x8000     /* Mute Channel 53 */
-#define                   TX_CH54  0x3f0000   /* Transmit Channel 54 */
-#define                 MUTE_CH54  0x800000   /* Mute Channel 54 */
-#define                   TX_CH55  0x3f000000 /* Transmit Channel 55 */
-#define                 MUTE_CH55  0x80000000 /* Mute Channel 55 */
-
-/* Bit masks for MXVR_ROUTING_14 */
-
-#define                   TX_CH56  0x3f       /* Transmit Channel 56 */
-#define                 MUTE_CH56  0x80       /* Mute Channel 56 */
-#define                   TX_CH57  0x3f00     /* Transmit Channel 57 */
-#define                 MUTE_CH57  0x8000     /* Mute Channel 57 */
-#define                   TX_CH58  0x3f0000   /* Transmit Channel 58 */
-#define                 MUTE_CH58  0x800000   /* Mute Channel 58 */
-#define                   TX_CH59  0x3f000000 /* Transmit Channel 59 */
-#define                 MUTE_CH59  0x80000000 /* Mute Channel 59 */
-
-/* Bit masks for MXVR_BLOCK_CNT */
-
-#define                      BCNT  0xffff     /* Block Count */
-
-/* Bit masks for MXVR_CLK_CTL */
-
-#define                  MXTALCEN  0x1        /* MXVR Crystal Oscillator Clock Enable */
-#define                  MXTALFEN  0x2        /* MXVR Crystal Oscillator Feedback Enable */
-#define                  MXTALMUL  0x30       /* MXVR Crystal Multiplier */
-#define                  CLKX3SEL  0x80       /* Clock Generation Source Select */
-#define                   MMCLKEN  0x100      /* Master Clock Enable */
-#define                  MMCLKMUL  0x1e00     /* Master Clock Multiplication Factor */
-#define                   PLLSMPS  0xe000     /* MXVR PLL State Machine Prescaler */
-#define                   MBCLKEN  0x10000    /* Bit Clock Enable */
-#define                  MBCLKDIV  0x1e0000   /* Bit Clock Divide Factor */
-#define                     INVRX  0x800000   /* Invert Receive Data */
-#define                     MFSEN  0x1000000  /* Frame Sync Enable */
-#define                    MFSDIV  0x1e000000 /* Frame Sync Divide Factor */
-#define                    MFSSEL  0x60000000 /* Frame Sync Select */
-#define                   MFSSYNC  0x80000000 /* Frame Sync Synchronization Select */
-
-/* Bit masks for MXVR_CDRPLL_CTL */
-
-#define                   CDRSMEN  0x1        /* MXVR CDRPLL State Machine Enable */
-#define                   CDRRSTB  0x2        /* MXVR CDRPLL Reset */
-#define                   CDRSVCO  0x4        /* MXVR CDRPLL Start VCO */
-#define                   CDRMODE  0x8        /* MXVR CDRPLL CDR Mode Select */
-#define                   CDRSCNT  0x3f0      /* MXVR CDRPLL Start Counter */
-#define                   CDRLCNT  0xfc00     /* MXVR CDRPLL Lock Counter */
-#define                 CDRSHPSEL  0x3f0000   /* MXVR CDRPLL Shaper Select */
-#define                  CDRSHPEN  0x800000   /* MXVR CDRPLL Shaper Enable */
-#define                  CDRCPSEL  0xff000000 /* MXVR CDRPLL Charge Pump Current Select */
-
-/* Bit masks for MXVR_FMPLL_CTL */
-
-#define                    FMSMEN  0x1        /* MXVR FMPLL State Machine Enable */
-#define                    FMRSTB  0x2        /* MXVR FMPLL Reset */
-#define                    FMSVCO  0x4        /* MXVR FMPLL Start VCO */
-#define                    FMSCNT  0x3f0      /* MXVR FMPLL Start Counter */
-#define                    FMLCNT  0xfc00     /* MXVR FMPLL Lock Counter */
-#define                   FMCPSEL  0xff000000 /* MXVR FMPLL Charge Pump Current Select */
-
-/* Bit masks for MXVR_PIN_CTL */
-
-#define                  MTXONBOD  0x1        /* MTXONB Open Drain Select */
-#define                   MTXONBG  0x2        /* MTXONB Gates MTX Select */
-#define                     MFSOE  0x10       /* MFS Output Enable */
-#define                  MFSGPSEL  0x20       /* MFS General Purpose Output Select */
-#define                  MFSGPDAT  0x40       /* MFS General Purpose Output Data */
-
-/* Bit masks for MXVR_SCLK_CNT */
-
-#define                      SCNT  0xffff     /* System Clock Count */
-
-/* Bit masks for KPAD_CTL */
-
-#define                   KPAD_EN  0x1        /* Keypad Enable */
-#define              KPAD_IRQMODE  0x6        /* Key Press Interrupt Enable */
-#define                KPAD_ROWEN  0x1c00     /* Row Enable Width */
-#define                KPAD_COLEN  0xe000     /* Column Enable Width */
-
-/* Bit masks for KPAD_PRESCALE */
-
-#define         KPAD_PRESCALE_VAL  0x3f       /* Key Prescale Value */
-
-/* Bit masks for KPAD_MSEL */
-
-#define                DBON_SCALE  0xff       /* Debounce Scale Value */
-#define              COLDRV_SCALE  0xff00     /* Column Driver Scale Value */
-
-/* Bit masks for KPAD_ROWCOL */
-
-#define                  KPAD_ROW  0xff       /* Rows Pressed */
-#define                  KPAD_COL  0xff00     /* Columns Pressed */
-
-/* Bit masks for KPAD_STAT */
-
-#define                  KPAD_IRQ  0x1        /* Keypad Interrupt Status */
-#define              KPAD_MROWCOL  0x6        /* Multiple Row/Column Keypress Status */
-#define              KPAD_PRESSED  0x8        /* Key press current status */
-
-/* Bit masks for KPAD_SOFTEVAL */
-
-#define           KPAD_SOFTEVAL_E  0x2        /* Software Programmable Force Evaluate */
-
-/* Bit masks for SDH_COMMAND */
-
-#define                   CMD_IDX  0x3f       /* Command Index */
-#define                   CMD_RSP  0x40       /* Response */
-#define                 CMD_L_RSP  0x80       /* Long Response */
-#define                 CMD_INT_E  0x100      /* Command Interrupt */
-#define                CMD_PEND_E  0x200      /* Command Pending */
-#define                     CMD_E  0x400      /* Command Enable */
-
-/* Bit masks for SDH_PWR_CTL */
-
-#define                    PWR_ON  0x3        /* Power On */
-#if 0
-#define                       TBD  0x3c       /* TBD */
-#endif
-#define                 SD_CMD_OD  0x40       /* Open Drain Output */
-#define                   ROD_CTL  0x80       /* Rod Control */
-
-/* Bit masks for SDH_CLK_CTL */
-
-#define                    CLKDIV  0xff       /* MC_CLK Divisor */
-#define                     CLK_E  0x100      /* MC_CLK Bus Clock Enable */
-#define                  PWR_SV_E  0x200      /* Power Save Enable */
-#define             CLKDIV_BYPASS  0x400      /* Bypass Divisor */
-#define                  WIDE_BUS  0x800      /* Wide Bus Mode Enable */
-
-/* Bit masks for SDH_RESP_CMD */
-
-#define                  RESP_CMD  0x3f       /* Response Command */
-
-/* Bit masks for SDH_DATA_CTL */
-
-#define                     DTX_E  0x1        /* Data Transfer Enable */
-#define                   DTX_DIR  0x2        /* Data Transfer Direction */
-#define                  DTX_MODE  0x4        /* Data Transfer Mode */
-#define                 DTX_DMA_E  0x8        /* Data Transfer DMA Enable */
-#define              DTX_BLK_LGTH  0xf0       /* Data Transfer Block Length */
-
-/* Bit masks for SDH_STATUS */
-
-#define              CMD_CRC_FAIL  0x1        /* CMD CRC Fail */
-#define              DAT_CRC_FAIL  0x2        /* Data CRC Fail */
-#define               CMD_TIME_OUT  0x4        /* CMD Time Out */
-#define               DAT_TIME_OUT  0x8        /* Data Time Out */
-#define               TX_UNDERRUN  0x10       /* Transmit Underrun */
-#define                RX_OVERRUN  0x20       /* Receive Overrun */
-#define              CMD_RESP_END  0x40       /* CMD Response End */
-#define                  CMD_SENT  0x80       /* CMD Sent */
-#define                   DAT_END  0x100      /* Data End */
-#define             START_BIT_ERR  0x200      /* Start Bit Error */
-#define               DAT_BLK_END  0x400      /* Data Block End */
-#define                   CMD_ACT  0x800      /* CMD Active */
-#define                    TX_ACT  0x1000     /* Transmit Active */
-#define                    RX_ACT  0x2000     /* Receive Active */
-#define              TX_FIFO_STAT  0x4000     /* Transmit FIFO Status */
-#define              RX_FIFO_STAT  0x8000     /* Receive FIFO Status */
-#define              TX_FIFO_FULL  0x10000    /* Transmit FIFO Full */
-#define              RX_FIFO_FULL  0x20000    /* Receive FIFO Full */
-#define              TX_FIFO_ZERO  0x40000    /* Transmit FIFO Empty */
-#define               RX_DAT_ZERO  0x80000    /* Receive FIFO Empty */
-#define                TX_DAT_RDY  0x100000   /* Transmit Data Available */
-#define               RX_FIFO_RDY  0x200000   /* Receive Data Available */
-
-/* Bit masks for SDH_STATUS_CLR */
-
-#define         CMD_CRC_FAIL_STAT  0x1        /* CMD CRC Fail Status */
-#define         DAT_CRC_FAIL_STAT  0x2        /* Data CRC Fail Status */
-#define          CMD_TIMEOUT_STAT  0x4        /* CMD Time Out Status */
-#define          DAT_TIMEOUT_STAT  0x8        /* Data Time Out status */
-#define          TX_UNDERRUN_STAT  0x10       /* Transmit Underrun Status */
-#define           RX_OVERRUN_STAT  0x20       /* Receive Overrun Status */
-#define         CMD_RESP_END_STAT  0x40       /* CMD Response End Status */
-#define             CMD_SENT_STAT  0x80       /* CMD Sent Status */
-#define              DAT_END_STAT  0x100      /* Data End Status */
-#define        START_BIT_ERR_STAT  0x200      /* Start Bit Error Status */
-#define          DAT_BLK_END_STAT  0x400      /* Data Block End Status */
-
-/* Bit masks for SDH_MASK0 */
-
-#define         CMD_CRC_FAIL_MASK  0x1        /* CMD CRC Fail Mask */
-#define         DAT_CRC_FAIL_MASK  0x2        /* Data CRC Fail Mask */
-#define          CMD_TIMEOUT_MASK  0x4        /* CMD Time Out Mask */
-#define          DAT_TIMEOUT_MASK  0x8        /* Data Time Out Mask */
-#define          TX_UNDERRUN_MASK  0x10       /* Transmit Underrun Mask */
-#define           RX_OVERRUN_MASK  0x20       /* Receive Overrun Mask */
-#define         CMD_RESP_END_MASK  0x40       /* CMD Response End Mask */
-#define             CMD_SENT_MASK  0x80       /* CMD Sent Mask */
-#define              DAT_END_MASK  0x100      /* Data End Mask */
-#define        START_BIT_ERR_MASK  0x200      /* Start Bit Error Mask */
-#define          DAT_BLK_END_MASK  0x400      /* Data Block End Mask */
-#define              CMD_ACT_MASK  0x800      /* CMD Active Mask */
-#define               TX_ACT_MASK  0x1000     /* Transmit Active Mask */
-#define               RX_ACT_MASK  0x2000     /* Receive Active Mask */
-#define         TX_FIFO_STAT_MASK  0x4000     /* Transmit FIFO Status Mask */
-#define         RX_FIFO_STAT_MASK  0x8000     /* Receive FIFO Status Mask */
-#define         TX_FIFO_FULL_MASK  0x10000    /* Transmit FIFO Full Mask */
-#define         RX_FIFO_FULL_MASK  0x20000    /* Receive FIFO Full Mask */
-#define         TX_FIFO_ZERO_MASK  0x40000    /* Transmit FIFO Empty Mask */
-#define          RX_DAT_ZERO_MASK  0x80000    /* Receive FIFO Empty Mask */
-#define           TX_DAT_RDY_MASK  0x100000   /* Transmit Data Available Mask */
-#define          RX_FIFO_RDY_MASK  0x200000   /* Receive Data Available Mask */
-
-/* Bit masks for SDH_FIFO_CNT */
-
-#define                FIFO_COUNT  0x7fff     /* FIFO Count */
-
-/* Bit masks for SDH_E_STATUS */
-
-#define              SDIO_INT_DET  0x2        /* SDIO Int Detected */
-#define               SD_CARD_DET  0x10       /* SD Card Detect */
-
-/* Bit masks for SDH_E_MASK */
-
-#define                  SDIO_MSK  0x2        /* Mask SDIO Int Detected */
-#define                   SCD_MSK  0x40       /* Mask Card Detect */
-
-/* Bit masks for SDH_CFG */
-
-#define                   CLKS_EN  0x1        /* Clocks Enable */
-#define                      SD4E  0x4        /* SDIO 4-Bit Enable */
-#define                       MWE  0x8        /* Moving Window Enable */
-#define                    SD_RST  0x10       /* SDMMC Reset */
-#define                 PUP_SDDAT  0x20       /* Pull-up SD_DAT */
-#define                PUP_SDDAT3  0x40       /* Pull-up SD_DAT3 */
-#define                 PD_SDDAT3  0x80       /* Pull-down SD_DAT3 */
-
-/* Bit masks for SDH_RD_WAIT_EN */
-
-#define                       RWR  0x1        /* Read Wait Request */
-
-/* Bit masks for ATAPI_CONTROL */
-
-#define                 PIO_START  0x1        /* Start PIO/Reg Op */
-#define               MULTI_START  0x2        /* Start Multi-DMA Op */
-#define               ULTRA_START  0x4        /* Start Ultra-DMA Op */
-#define                  XFER_DIR  0x8        /* Transfer Direction */
-#define                  IORDY_EN  0x10       /* IORDY Enable */
-#define                FIFO_FLUSH  0x20       /* Flush FIFOs */
-#define                  SOFT_RST  0x40       /* Soft Reset */
-#define                   DEV_RST  0x80       /* Device Reset */
-#define                TFRCNT_RST  0x100      /* Trans Count Reset */
-#define               END_ON_TERM  0x200      /* End/Terminate Select */
-#define               PIO_USE_DMA  0x400      /* PIO-DMA Enable */
-#define          UDMAIN_FIFO_THRS  0xf000     /* Ultra DMA-IN FIFO Threshold */
-
-/* Bit masks for ATAPI_STATUS */
-
-#define               PIO_XFER_ON  0x1        /* PIO transfer in progress */
-#define             MULTI_XFER_ON  0x2        /* Multi-word DMA transfer in progress */
-#define             ULTRA_XFER_ON  0x4        /* Ultra DMA transfer in progress */
-#define               ULTRA_IN_FL  0xf0       /* Ultra DMA Input FIFO Level */
-
-/* Bit masks for ATAPI_DEV_ADDR */
-
-#define                  DEV_ADDR  0x1f       /* Device Address */
-
-/* Bit masks for ATAPI_INT_MASK */
-
-#define        ATAPI_DEV_INT_MASK  0x1        /* Device interrupt mask */
-#define             PIO_DONE_MASK  0x2        /* PIO transfer done interrupt mask */
-#define           MULTI_DONE_MASK  0x4        /* Multi-DMA transfer done interrupt mask */
-#define          UDMAIN_DONE_MASK  0x8        /* Ultra-DMA in transfer done interrupt mask */
-#define         UDMAOUT_DONE_MASK  0x10       /* Ultra-DMA out transfer done interrupt mask */
-#define       HOST_TERM_XFER_MASK  0x20       /* Host terminate current transfer interrupt mask */
-#define           MULTI_TERM_MASK  0x40       /* Device terminate Multi-DMA transfer interrupt mask */
-#define          UDMAIN_TERM_MASK  0x80       /* Device terminate Ultra-DMA-in transfer interrupt mask */
-#define         UDMAOUT_TERM_MASK  0x100      /* Device terminate Ultra-DMA-out transfer interrupt mask */
-
-/* Bit masks for ATAPI_INT_STATUS */
-
-#define             ATAPI_DEV_INT  0x1        /* Device interrupt status */
-#define              PIO_DONE_INT  0x2        /* PIO transfer done interrupt status */
-#define            MULTI_DONE_INT  0x4        /* Multi-DMA transfer done interrupt status */
-#define           UDMAIN_DONE_INT  0x8        /* Ultra-DMA in transfer done interrupt status */
-#define          UDMAOUT_DONE_INT  0x10       /* Ultra-DMA out transfer done interrupt status */
-#define        HOST_TERM_XFER_INT  0x20       /* Host terminate current transfer interrupt status */
-#define            MULTI_TERM_INT  0x40       /* Device terminate Multi-DMA transfer interrupt status */
-#define           UDMAIN_TERM_INT  0x80       /* Device terminate Ultra-DMA-in transfer interrupt status */
-#define          UDMAOUT_TERM_INT  0x100      /* Device terminate Ultra-DMA-out transfer interrupt status */
-
-/* Bit masks for ATAPI_LINE_STATUS */
-
-#define                ATAPI_INTR  0x1        /* Device interrupt to host line status */
-#define                ATAPI_DASP  0x2        /* Device dasp to host line status */
-#define                ATAPI_CS0N  0x4        /* ATAPI chip select 0 line status */
-#define                ATAPI_CS1N  0x8        /* ATAPI chip select 1 line status */
-#define                ATAPI_ADDR  0x70       /* ATAPI address line status */
-#define              ATAPI_DMAREQ  0x80       /* ATAPI DMA request line status */
-#define             ATAPI_DMAACKN  0x100      /* ATAPI DMA acknowledge line status */
-#define               ATAPI_DIOWN  0x200      /* ATAPI write line status */
-#define               ATAPI_DIORN  0x400      /* ATAPI read line status */
-#define               ATAPI_IORDY  0x800      /* ATAPI IORDY line status */
-
-/* Bit masks for ATAPI_SM_STATE */
-
-#define                PIO_CSTATE  0xf        /* PIO mode state machine current state */
-#define                DMA_CSTATE  0xf0       /* DMA mode state machine current state */
-#define             UDMAIN_CSTATE  0xf00      /* Ultra DMA-In mode state machine current state */
-#define            UDMAOUT_CSTATE  0xf000     /* ATAPI IORDY line status */
-
-/* Bit masks for ATAPI_TERMINATE */
-
-#define           ATAPI_HOST_TERM  0x1        /* Host terminationation */
-
-/* Bit masks for ATAPI_REG_TIM_0 */
-
-#define                    T2_REG  0xff       /* End of cycle time for register access transfers */
-#define                  TEOC_REG  0xff00     /* Selects DIOR/DIOW pulsewidth */
-
-/* Bit masks for ATAPI_PIO_TIM_0 */
-
-#define                    T1_REG  0xf        /* Time from address valid to DIOR/DIOW */
-#define                T2_REG_PIO  0xff0      /* DIOR/DIOW pulsewidth */
-#define                    T4_REG  0xf000     /* DIOW data hold */
-
-/* Bit masks for ATAPI_PIO_TIM_1 */
-
-#define              TEOC_REG_PIO  0xff       /* End of cycle time for PIO access transfers. */
-
-/* Bit masks for ATAPI_MULTI_TIM_0 */
-
-#define                        TD  0xff       /* DIOR/DIOW asserted pulsewidth */
-#define                        TM  0xff00     /* Time from address valid to DIOR/DIOW */
-
-/* Bit masks for ATAPI_MULTI_TIM_1 */
-
-#define                       TKW  0xff       /* Selects DIOW negated pulsewidth */
-#define                       TKR  0xff00     /* Selects DIOR negated pulsewidth */
-
-/* Bit masks for ATAPI_MULTI_TIM_2 */
-
-#define                        TH  0xff       /* Selects DIOW data hold */
-#define                      TEOC  0xff00     /* Selects end of cycle for DMA */
-
-/* Bit masks for ATAPI_ULTRA_TIM_0 */
-
-#define                      TACK  0xff       /* Selects setup and hold times for TACK */
-#define                      TENV  0xff00     /* Selects envelope time */
-
-/* Bit masks for ATAPI_ULTRA_TIM_1 */
-
-#define                      TDVS  0xff       /* Selects data valid setup time */
-#define                 TCYC_TDVS  0xff00     /* Selects cycle time - TDVS time */
-
-/* Bit masks for ATAPI_ULTRA_TIM_2 */
-
-#define                       TSS  0xff       /* Selects time from STROBE edge to negation of DMARQ or assertion of STOP */
-#define                      TMLI  0xff00     /* Selects interlock time */
-
-/* Bit masks for ATAPI_ULTRA_TIM_3 */
-
-#define                      TZAH  0xff       /* Selects minimum delay required for output */
-#define               READY_PAUSE  0xff00     /* Selects ready to pause */
-
-/* Bit masks for TIMER_ENABLE1 */
-
-#define                    TIMEN8  0x1        /* Timer 8 Enable */
-#define                    TIMEN9  0x2        /* Timer 9 Enable */
-#define                   TIMEN10  0x4        /* Timer 10 Enable */
-
-/* Bit masks for TIMER_DISABLE1 */
-
-#define                   TIMDIS8  0x1        /* Timer 8 Disable */
-#define                   TIMDIS9  0x2        /* Timer 9 Disable */
-#define                  TIMDIS10  0x4        /* Timer 10 Disable */
-
-/* Bit masks for TIMER_STATUS1 */
-
-#define                    TIMIL8  0x1        /* Timer 8 Interrupt */
-#define                    TIMIL9  0x2        /* Timer 9 Interrupt */
-#define                   TIMIL10  0x4        /* Timer 10 Interrupt */
-#define                 TOVF_ERR8  0x10       /* Timer 8 Counter Overflow */
-#define                 TOVF_ERR9  0x20       /* Timer 9 Counter Overflow */
-#define                TOVF_ERR10  0x40       /* Timer 10 Counter Overflow */
-#define                     TRUN8  0x1000     /* Timer 8 Slave Enable Status */
-#define                     TRUN9  0x2000     /* Timer 9 Slave Enable Status */
-#define                    TRUN10  0x4000     /* Timer 10 Slave Enable Status */
-
-/* Bit masks for EPPI0 are obtained from common base header for EPPIx (EPPI1 and EPPI2) */
-
-/* Bit masks for USB_FADDR */
-
-#define          FUNCTION_ADDRESS  0x7f       /* Function address */
-
-/* Bit masks for USB_POWER */
-
-#define           ENABLE_SUSPENDM  0x1        /* enable SuspendM output */
-#define              SUSPEND_MODE  0x2        /* Suspend Mode indicator */
-#define               RESUME_MODE  0x4        /* DMA Mode */
-#define                     RESET  0x8        /* Reset indicator */
-#define                   HS_MODE  0x10       /* High Speed mode indicator */
-#define                 HS_ENABLE  0x20       /* high Speed Enable */
-#define                 SOFT_CONN  0x40       /* Soft connect */
-#define                ISO_UPDATE  0x80       /* Isochronous update */
-
-/* Bit masks for USB_INTRTX */
-
-#define                    EP0_TX  0x1        /* Tx Endpoint 0 interrupt */
-#define                    EP1_TX  0x2        /* Tx Endpoint 1 interrupt */
-#define                    EP2_TX  0x4        /* Tx Endpoint 2 interrupt */
-#define                    EP3_TX  0x8        /* Tx Endpoint 3 interrupt */
-#define                    EP4_TX  0x10       /* Tx Endpoint 4 interrupt */
-#define                    EP5_TX  0x20       /* Tx Endpoint 5 interrupt */
-#define                    EP6_TX  0x40       /* Tx Endpoint 6 interrupt */
-#define                    EP7_TX  0x80       /* Tx Endpoint 7 interrupt */
-
-/* Bit masks for USB_INTRRX */
-
-#define                    EP1_RX  0x2        /* Rx Endpoint 1 interrupt */
-#define                    EP2_RX  0x4        /* Rx Endpoint 2 interrupt */
-#define                    EP3_RX  0x8        /* Rx Endpoint 3 interrupt */
-#define                    EP4_RX  0x10       /* Rx Endpoint 4 interrupt */
-#define                    EP5_RX  0x20       /* Rx Endpoint 5 interrupt */
-#define                    EP6_RX  0x40       /* Rx Endpoint 6 interrupt */
-#define                    EP7_RX  0x80       /* Rx Endpoint 7 interrupt */
-
-/* Bit masks for USB_INTRTXE */
-
-#define                  EP0_TX_E  0x1        /* Endpoint 0 interrupt Enable */
-#define                  EP1_TX_E  0x2        /* Tx Endpoint 1 interrupt  Enable */
-#define                  EP2_TX_E  0x4        /* Tx Endpoint 2 interrupt  Enable */
-#define                  EP3_TX_E  0x8        /* Tx Endpoint 3 interrupt  Enable */
-#define                  EP4_TX_E  0x10       /* Tx Endpoint 4 interrupt  Enable */
-#define                  EP5_TX_E  0x20       /* Tx Endpoint 5 interrupt  Enable */
-#define                  EP6_TX_E  0x40       /* Tx Endpoint 6 interrupt  Enable */
-#define                  EP7_TX_E  0x80       /* Tx Endpoint 7 interrupt  Enable */
-
-/* Bit masks for USB_INTRRXE */
-
-#define                  EP1_RX_E  0x2        /* Rx Endpoint 1 interrupt  Enable */
-#define                  EP2_RX_E  0x4        /* Rx Endpoint 2 interrupt  Enable */
-#define                  EP3_RX_E  0x8        /* Rx Endpoint 3 interrupt  Enable */
-#define                  EP4_RX_E  0x10       /* Rx Endpoint 4 interrupt  Enable */
-#define                  EP5_RX_E  0x20       /* Rx Endpoint 5 interrupt  Enable */
-#define                  EP6_RX_E  0x40       /* Rx Endpoint 6 interrupt  Enable */
-#define                  EP7_RX_E  0x80       /* Rx Endpoint 7 interrupt  Enable */
-
-/* Bit masks for USB_INTRUSB */
-
-#define                 SUSPEND_B  0x1        /* Suspend indicator */
-#define                  RESUME_B  0x2        /* Resume indicator */
-#define          RESET_OR_BABLE_B  0x4        /* Reset/babble indicator */
-#define                     SOF_B  0x8        /* Start of frame */
-#define                    CONN_B  0x10       /* Connection indicator */
-#define                  DISCON_B  0x20       /* Disconnect indicator */
-#define             SESSION_REQ_B  0x40       /* Session Request */
-#define              VBUS_ERROR_B  0x80       /* Vbus threshold indicator */
-
-/* Bit masks for USB_INTRUSBE */
-
-#define                SUSPEND_BE  0x1        /* Suspend indicator int enable */
-#define                 RESUME_BE  0x2        /* Resume indicator int enable */
-#define         RESET_OR_BABLE_BE  0x4        /* Reset/babble indicator int enable */
-#define                    SOF_BE  0x8        /* Start of frame int enable */
-#define                   CONN_BE  0x10       /* Connection indicator int enable */
-#define                 DISCON_BE  0x20       /* Disconnect indicator int enable */
-#define            SESSION_REQ_BE  0x40       /* Session Request int enable */
-#define             VBUS_ERROR_BE  0x80       /* Vbus threshold indicator int enable */
-
-/* Bit masks for USB_FRAME */
-
-#define              FRAME_NUMBER  0x7ff      /* Frame number */
-
-/* Bit masks for USB_INDEX */
-
-#define         SELECTED_ENDPOINT  0xf        /* selected endpoint */
-
-/* Bit masks for USB_GLOBAL_CTL */
-
-#define                GLOBAL_ENA  0x1        /* enables USB module */
-#define                EP1_TX_ENA  0x2        /* Transmit endpoint 1 enable */
-#define                EP2_TX_ENA  0x4        /* Transmit endpoint 2 enable */
-#define                EP3_TX_ENA  0x8        /* Transmit endpoint 3 enable */
-#define                EP4_TX_ENA  0x10       /* Transmit endpoint 4 enable */
-#define                EP5_TX_ENA  0x20       /* Transmit endpoint 5 enable */
-#define                EP6_TX_ENA  0x40       /* Transmit endpoint 6 enable */
-#define                EP7_TX_ENA  0x80       /* Transmit endpoint 7 enable */
-#define                EP1_RX_ENA  0x100      /* Receive endpoint 1 enable */
-#define                EP2_RX_ENA  0x200      /* Receive endpoint 2 enable */
-#define                EP3_RX_ENA  0x400      /* Receive endpoint 3 enable */
-#define                EP4_RX_ENA  0x800      /* Receive endpoint 4 enable */
-#define                EP5_RX_ENA  0x1000     /* Receive endpoint 5 enable */
-#define                EP6_RX_ENA  0x2000     /* Receive endpoint 6 enable */
-#define                EP7_RX_ENA  0x4000     /* Receive endpoint 7 enable */
-
-/* Bit masks for USB_OTG_DEV_CTL */
-
-#define                   SESSION  0x1        /* session indicator */
-#define                  HOST_REQ  0x2        /* Host negotiation request */
-#define                 HOST_MODE  0x4        /* indicates USBDRC is a host */
-#define                     VBUS0  0x8        /* Vbus level indicator[0] */
-#define                     VBUS1  0x10       /* Vbus level indicator[1] */
-#define                     LSDEV  0x20       /* Low-speed indicator */
-#define                     FSDEV  0x40       /* Full or High-speed indicator */
-#define                  B_DEVICE  0x80       /* A' or 'B' device indicator */
-
-/* Bit masks for USB_OTG_VBUS_IRQ */
-
-#define             DRIVE_VBUS_ON  0x1        /* indicator to drive VBUS control circuit */
-#define            DRIVE_VBUS_OFF  0x2        /* indicator to shut off charge pump */
-#define           CHRG_VBUS_START  0x4        /* indicator for external circuit to start charging VBUS */
-#define             CHRG_VBUS_END  0x8        /* indicator for external circuit to end charging VBUS */
-#define        DISCHRG_VBUS_START  0x10       /* indicator to start discharging VBUS */
-#define          DISCHRG_VBUS_END  0x20       /* indicator to stop discharging VBUS */
-
-/* Bit masks for USB_OTG_VBUS_MASK */
-
-#define         DRIVE_VBUS_ON_ENA  0x1        /* enable DRIVE_VBUS_ON interrupt */
-#define        DRIVE_VBUS_OFF_ENA  0x2        /* enable DRIVE_VBUS_OFF interrupt */
-#define       CHRG_VBUS_START_ENA  0x4        /* enable CHRG_VBUS_START interrupt */
-#define         CHRG_VBUS_END_ENA  0x8        /* enable CHRG_VBUS_END interrupt */
-#define    DISCHRG_VBUS_START_ENA  0x10       /* enable DISCHRG_VBUS_START interrupt */
-#define      DISCHRG_VBUS_END_ENA  0x20       /* enable DISCHRG_VBUS_END interrupt */
-
-/* Bit masks for USB_CSR0 */
-
-#define                  RXPKTRDY  0x1        /* data packet receive indicator */
-#define                  TXPKTRDY  0x2        /* data packet in FIFO indicator */
-#define                STALL_SENT  0x4        /* STALL handshake sent */
-#define                   DATAEND  0x8        /* Data end indicator */
-#define                  SETUPEND  0x10       /* Setup end */
-#define                 SENDSTALL  0x20       /* Send STALL handshake */
-#define         SERVICED_RXPKTRDY  0x40       /* used to clear the RxPktRdy bit */
-#define         SERVICED_SETUPEND  0x80       /* used to clear the SetupEnd bit */
-#define                 FLUSHFIFO  0x100      /* flush endpoint FIFO */
-#define          STALL_RECEIVED_H  0x4        /* STALL handshake received host mode */
-#define                SETUPPKT_H  0x8        /* send Setup token host mode */
-#define                   ERROR_H  0x10       /* timeout error indicator host mode */
-#define                  REQPKT_H  0x20       /* Request an IN transaction host mode */
-#define               STATUSPKT_H  0x40       /* Status stage transaction host mode */
-#define             NAK_TIMEOUT_H  0x80       /* EP0 halted after a NAK host mode */
-
-/* Bit masks for USB_COUNT0 */
-
-#define              EP0_RX_COUNT  0x7f       /* number of received bytes in EP0 FIFO */
-
-/* Bit masks for USB_NAKLIMIT0 */
-
-#define             EP0_NAK_LIMIT  0x1f       /* number of frames/micro frames after which EP0 timeouts */
-
-/* Bit masks for USB_TX_MAX_PACKET */
-
-#define         MAX_PACKET_SIZE_T  0x7ff      /* maximum data pay load in a frame */
-
-/* Bit masks for USB_RX_MAX_PACKET */
-
-#define         MAX_PACKET_SIZE_R  0x7ff      /* maximum data pay load in a frame */
-
-/* Bit masks for USB_TXCSR */
-
-#define                TXPKTRDY_T  0x1        /* data packet in FIFO indicator */
-#define          FIFO_NOT_EMPTY_T  0x2        /* FIFO not empty */
-#define                UNDERRUN_T  0x4        /* TxPktRdy not set  for an IN token */
-#define               FLUSHFIFO_T  0x8        /* flush endpoint FIFO */
-#define              STALL_SEND_T  0x10       /* issue a Stall handshake */
-#define              STALL_SENT_T  0x20       /* Stall handshake transmitted */
-#define        CLEAR_DATATOGGLE_T  0x40       /* clear endpoint data toggle */
-#define                INCOMPTX_T  0x80       /* indicates that a large packet is split */
-#define              DMAREQMODE_T  0x400      /* DMA mode (0 or 1) selection */
-#define        FORCE_DATATOGGLE_T  0x800      /* Force data toggle */
-#define              DMAREQ_ENA_T  0x1000     /* Enable DMA request for Tx EP */
-#define                     ISO_T  0x4000     /* enable Isochronous transfers */
-#define                 AUTOSET_T  0x8000     /* allows TxPktRdy to be set automatically */
-#define                  ERROR_TH  0x4        /* error condition host mode */
-#define         STALL_RECEIVED_TH  0x20       /* Stall handshake received host mode */
-#define            NAK_TIMEOUT_TH  0x80       /* NAK timeout host mode */
-
-/* Bit masks for USB_TXCOUNT */
-
-#define                  TX_COUNT  0x1fff     /* Number of bytes to be written to the selected endpoint Tx FIFO */
-
-/* Bit masks for USB_RXCSR */
-
-#define                RXPKTRDY_R  0x1        /* data packet in FIFO indicator */
-#define               FIFO_FULL_R  0x2        /* FIFO not empty */
-#define                 OVERRUN_R  0x4        /* TxPktRdy not set  for an IN token */
-#define               DATAERROR_R  0x8        /* Out packet cannot be loaded into Rx  FIFO */
-#define               FLUSHFIFO_R  0x10       /* flush endpoint FIFO */
-#define              STALL_SEND_R  0x20       /* issue a Stall handshake */
-#define              STALL_SENT_R  0x40       /* Stall handshake transmitted */
-#define        CLEAR_DATATOGGLE_R  0x80       /* clear endpoint data toggle */
-#define                INCOMPRX_R  0x100      /* indicates that a large packet is split */
-#define              DMAREQMODE_R  0x800      /* DMA mode (0 or 1) selection */
-#define                 DISNYET_R  0x1000     /* disable Nyet handshakes */
-#define              DMAREQ_ENA_R  0x2000     /* Enable DMA request for Tx EP */
-#define                     ISO_R  0x4000     /* enable Isochronous transfers */
-#define               AUTOCLEAR_R  0x8000     /* allows TxPktRdy to be set automatically */
-#define                  ERROR_RH  0x4        /* TxPktRdy not set  for an IN token host mode */
-#define                 REQPKT_RH  0x20       /* request an IN transaction host mode */
-#define         STALL_RECEIVED_RH  0x40       /* Stall handshake received host mode */
-#define               INCOMPRX_RH  0x100      /* indicates that a large packet is split host mode */
-#define             DMAREQMODE_RH  0x800      /* DMA mode (0 or 1) selection host mode */
-#define                AUTOREQ_RH  0x4000     /* sets ReqPkt automatically host mode */
-
-/* Bit masks for USB_RXCOUNT */
-
-#define                  RX_COUNT  0x1fff     /* Number of received bytes in the packet in the Rx FIFO */
-
-/* Bit masks for USB_TXTYPE */
-
-#define            TARGET_EP_NO_T  0xf        /* EP number */
-#define                PROTOCOL_T  0xc        /* transfer type */
-
-/* Bit masks for USB_TXINTERVAL */
-
-#define          TX_POLL_INTERVAL  0xff       /* polling interval for selected Tx EP */
-
-/* Bit masks for USB_RXTYPE */
-
-#define            TARGET_EP_NO_R  0xf        /* EP number */
-#define                PROTOCOL_R  0xc        /* transfer type */
-
-/* Bit masks for USB_RXINTERVAL */
-
-#define          RX_POLL_INTERVAL  0xff       /* polling interval for selected Rx EP */
-
-/* Bit masks for USB_DMA_INTERRUPT */
-
-#define                  DMA0_INT  0x1        /* DMA0 pending interrupt */
-#define                  DMA1_INT  0x2        /* DMA1 pending interrupt */
-#define                  DMA2_INT  0x4        /* DMA2 pending interrupt */
-#define                  DMA3_INT  0x8        /* DMA3 pending interrupt */
-#define                  DMA4_INT  0x10       /* DMA4 pending interrupt */
-#define                  DMA5_INT  0x20       /* DMA5 pending interrupt */
-#define                  DMA6_INT  0x40       /* DMA6 pending interrupt */
-#define                  DMA7_INT  0x80       /* DMA7 pending interrupt */
-
-/* Bit masks for USB_DMAxCONTROL */
-
-#define                   DMA_ENA  0x1        /* DMA enable */
-#define                 DIRECTION  0x2        /* direction of DMA transfer */
-#define                      MODE  0x4        /* DMA Bus error */
-#define                   INT_ENA  0x8        /* Interrupt enable */
-#define                     EPNUM  0xf0       /* EP number */
-#define                  BUSERROR  0x100      /* DMA Bus error */
-
-/* Bit masks for USB_DMAxADDRHIGH */
-
-#define             DMA_ADDR_HIGH  0xffff     /* Upper 16-bits of memory source/destination address for the DMA master channel */
-
-/* Bit masks for USB_DMAxADDRLOW */
-
-#define              DMA_ADDR_LOW  0xffff     /* Lower 16-bits of memory source/destination address for the DMA master channel */
-
-/* Bit masks for USB_DMAxCOUNTHIGH */
-
-#define            DMA_COUNT_HIGH  0xffff     /* Upper 16-bits of byte count of DMA transfer for DMA master channel */
-
-/* Bit masks for USB_DMAxCOUNTLOW */
-
-#define             DMA_COUNT_LOW  0xffff     /* Lower 16-bits of byte count of DMA transfer for DMA master channel */
-
-/* Bit masks for HMDMAx_CONTROL */
-
-#define                   HMDMAEN  0x1        /* Handshake MDMA Enable */
-#define                       REP  0x2        /* Handshake MDMA Request Polarity */
-#define                       UTE  0x8        /* Urgency Threshold Enable */
-#define                       OIE  0x10       /* Overflow Interrupt Enable */
-#define                      BDIE  0x20       /* Block Done Interrupt Enable */
-#define                      MBDI  0x40       /* Mask Block Done Interrupt */
-#define                       DRQ  0x300      /* Handshake MDMA Request Type */
-#define                       RBC  0x1000     /* Force Reload of BCOUNT */
-#define                        PS  0x2000     /* Pin Status */
-#define                        OI  0x4000     /* Overflow Interrupt Generated */
-#define                       BDI  0x8000     /* Block Done Interrupt Generated */
-
-/* ******************************************* */
-/*     MULTI BIT MACRO ENUMERATIONS            */
-/* ******************************************* */
-
-/* ************************ */
-/*   MXVR Address Offsets   */
-/* ************************ */
-
-/* Control Message Receive Buffer (CMRB) Address Offsets */
-
-#define CMRB_STRIDE       0x00000016lu
-
-#define CMRB_DST_OFFSET   0x00000000lu
-#define CMRB_SRC_OFFSET   0x00000002lu
-#define CMRB_DATA_OFFSET  0x00000005lu
-
-/* Control Message Transmit Buffer (CMTB) Address Offsets */
-
-#define CMTB_PRIO_OFFSET    0x00000000lu
-#define CMTB_DST_OFFSET     0x00000002lu
-#define CMTB_SRC_OFFSET     0x00000004lu
-#define CMTB_TYPE_OFFSET    0x00000006lu
-#define CMTB_DATA_OFFSET    0x00000007lu
-
-#define CMTB_ANSWER_OFFSET  0x0000000Alu
-
-#define CMTB_STAT_N_OFFSET  0x00000018lu
-#define CMTB_STAT_A_OFFSET  0x00000016lu
-#define CMTB_STAT_D_OFFSET  0x0000000Elu
-#define CMTB_STAT_R_OFFSET  0x00000014lu
-#define CMTB_STAT_W_OFFSET  0x00000014lu
-#define CMTB_STAT_G_OFFSET  0x00000014lu
-
-/* Asynchronous Packet Receive Buffer (APRB) Address Offsets */
-
-#define APRB_STRIDE       0x00000400lu
-
-#define APRB_DST_OFFSET   0x00000000lu
-#define APRB_LEN_OFFSET   0x00000002lu
-#define APRB_SRC_OFFSET   0x00000004lu
-#define APRB_DATA_OFFSET  0x00000006lu
-
-/* Asynchronous Packet Transmit Buffer (APTB) Address Offsets */
-
-#define APTB_PRIO_OFFSET  0x00000000lu
-#define APTB_DST_OFFSET   0x00000002lu
-#define APTB_LEN_OFFSET   0x00000004lu
-#define APTB_SRC_OFFSET   0x00000006lu
-#define APTB_DATA_OFFSET  0x00000008lu
-
-/* Remote Read Buffer (RRDB) Address Offsets */
-
-#define RRDB_WADDR_OFFSET 0x00000100lu
-#define RRDB_WLEN_OFFSET  0x00000101lu
-
-/* **************** */
-/*   MXVR Macros    */
-/* **************** */
-
-/* MXVR_CONFIG Macros */
-
-#define SET_MSB(x)       ( ( (x) & 0xF  ) << 9)
-
-/* MXVR_INT_STAT_1 Macros */
-
-#define DONEX(x)         (0x00000002 << (4 * (x)))
-#define HDONEX(x)        (0x00000001 << (4 * (x)))
-
-/* MXVR_INT_EN_1 Macros */
-
-#define DONEENX(x)       (0x00000002 << (4 * (x)))
-#define HDONEENX(x)      (0x00000001 << (4 * (x)))
-
-/* MXVR_CDRPLL_CTL Macros */
-
-#define SET_CDRSHPSEL(x) ( ( (x) & 0x3F ) << 16)
-
-/* MXVR_FMPLL_CTL Macros */
-
-#define SET_CDRCPSEL(x)  ( ( (x) & 0xFF ) << 24)
-#define SET_FMCPSEL(x)   ( ( (x) & 0xFF ) << 24)
-
 #endif /* _DEF_BF549_H */
index 8590c8c78336269b132df9c5b203f8921bd01a19..ab04d137fd8bc585fb86c099709c938d6e26491e 100644 (file)
 #define                 PINT2  0x40000000 /* Pin Interrupt 2 */
 #define                 PINT3  0x80000000 /* Pin Interrupt 3 */
 
-/* Bit masks for DMAx_CONFIG, MDMA_Sx_CONFIG, MDMA_Dx_CONFIG */
-
-#define                     DMAEN  0x1        /* DMA Channel Enable */
-#define                       WNR  0x2        /* DMA Direction */
-#define                  WDSIZE_8  0x0        /* Transfer Word Size = 8 */
-#define                 WDSIZE_16  0x4        /* Transfer Word Size = 16 */
-#define                 WDSIZE_32  0x8        /* Transfer Word Size = 32 */
-#define                     DMA2D  0x10       /* DMA Mode */
-#define                   RESTART  0x20       /* Work Unit Transitions */
-#define                    DI_SEL  0x40       /* Data Interrupt Timing Select */
-#define                     DI_EN  0x80       /* Data Interrupt Enable */
-
-#define                    NDSIZE  0xf00      /* Flex Descriptor Size */
-#define                  NDSIZE_0 0x0000      /* Next Descriptor Size = 0 (Stop/Autobuffer) */
-#define                  NDSIZE_1 0x0100      /* Next Descriptor Size = 1 */
-#define                  NDSIZE_2 0x0200      /* Next Descriptor Size = 2 */
-#define                  NDSIZE_3 0x0300      /* Next Descriptor Size = 3 */
-#define                  NDSIZE_4 0x0400      /* Next Descriptor Size = 4 */
-#define                  NDSIZE_5 0x0500      /* Next Descriptor Size = 5 */
-#define                  NDSIZE_6 0x0600      /* Next Descriptor Size = 6 */
-#define                  NDSIZE_7 0x0700      /* Next Descriptor Size = 7 */
-#define                  NDSIZE_8 0x0800      /* Next Descriptor Size = 8 */
-#define                  NDSIZE_9 0x0900      /* Next Descriptor Size = 9 */
-
-#define                   DMAFLOW  0xf000     /* Next Operation */
-#define              DMAFLOW_STOP  0x0000     /* Stop Mode */
-#define              DMAFLOW_AUTO  0x1000     /* Autobuffer Mode */
-#define             DMAFLOW_ARRAY  0x4000     /* Descriptor Array Mode */
-#define             DMAFLOW_SMALL  0x6000     /* Small Model Descriptor List Mode */
-#define             DMAFLOW_LARGE  0x7000     /* Large Model Descriptor List Mode */
-
-/* Bit masks for DMAx_IRQ_STATUS, MDMA_Sx_IRQ_STATUS, MDMA_Dx_IRQ_STATUS */
-
-#define                  DMA_DONE  0x1        /* DMA Completion Interrupt Status */
-#define                   DMA_ERR  0x2        /* DMA Error Interrupt Status */
-#define                    DFETCH  0x4        /* DMA Descriptor Fetch */
-#define                   DMA_RUN  0x8        /* DMA Channel Running */
-
 /* Bit masks for DMAx_PERIPHERAL_MAP, MDMA_Sx_IRQ_STATUS, MDMA_Dx_IRQ_STATUS */
 
 #define                     CTYPE  0x40       /* DMA Channel Type */
 #define               DEB3_MERROR  0x40       /* DEB3 Error (2nd) */
 #define               CORE_MERROR  0x80       /* Core Error (2nd) */
 
-/* Bit masks for EBIU_ERRADD */
-
-#define             ERROR_ADDRESS  0xffffffff /* Error Address */
-
 /* Bit masks for EBIU_RSTCTL */
 
 #define                 DDRSRESET  0x1        /* DDR soft reset */
 #define                     SRACK  0x10       /* Self-refresh acknowledge */
 #define                MDDRENABLE  0x20       /* Mobile DDR enable */
 
-/* Bit masks for EBIU_DDRBRC0 */
-
-#define                      BRC0  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBRC1 */
-
-#define                      BRC1  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBRC2 */
-
-#define                      BRC2  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBRC3 */
-
-#define                      BRC3  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBRC4 */
-
-#define                      BRC4  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBRC5 */
-
-#define                      BRC5  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBRC6 */
-
-#define                      BRC6  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBRC7 */
-
-#define                      BRC7  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBWC0 */
-
-#define                      BWC0  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBWC1 */
-
-#define                      BWC1  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBWC2 */
-
-#define                      BWC2  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBWC3 */
-
-#define                      BWC3  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBWC4 */
-
-#define                      BWC4  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBWC5 */
-
-#define                      BWC5  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBWC6 */
-
-#define                      BWC6  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRBWC7 */
-
-#define                      BWC7  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRACCT */
-
-#define                      ACCT  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRTACT */
-
-#define                      TECT  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRARCT */
-
-#define                      ARCT  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRGC0 */
-
-#define                       GC0  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRGC1 */
-
-#define                       GC1  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRGC2 */
-
-#define                       GC2  0xffffffff /* Count */
-
-/* Bit masks for EBIU_DDRGC3 */
-
-#define                       GC3  0xffffffff /* Count */
-
 /* Bit masks for EBIU_DDRMCEN */
 
 #define                B0WCENABLE  0x1        /* Bank 0 write count enable */
 #define                     TRUN6  0x40000000 /* Timer 6 Slave Enable Status */
 #define                     TRUN7  0x80000000 /* Timer 7 Slave Enable Status */
 
-/* Bit masks for WDOG_CTL */
-
-#define                      WDEV  0x6        /* Watchdog Event */
-#define                      WDEN  0xff0      /* Watchdog Enable */
-#define                      WDRO  0x8000     /* Watchdog Rolled Over */
-
 /* Bit masks for CNT_CONFIG */
 
 #define                      CNTE  0x1        /* Counter Enable */
 
 #define                 DPRESCALE  0xf        /* Load Counter Register */
 
-/* Bit masks for RTC_STAT */
-
-#define                   SECONDS  0x3f       /* Seconds */
-#define                   MINUTES  0xfc0      /* Minutes */
-#define                     HOURS  0x1f000    /* Hours */
-#define               DAY_COUNTER  0xfffe0000 /* Day Counter */
-
-/* Bit masks for RTC_ICTL */
-
-#define STOPWATCH_INTERRUPT_ENABLE  0x1        /* Stopwatch Interrupt Enable */
-#define    ALARM_INTERRUPT_ENABLE  0x2        /* Alarm Interrupt Enable */
-#define  SECONDS_INTERRUPT_ENABLE  0x4        /* Seconds Interrupt Enable */
-#define  MINUTES_INTERRUPT_ENABLE  0x8        /* Minutes Interrupt Enable */
-#define    HOURS_INTERRUPT_ENABLE  0x10       /* Hours Interrupt Enable */
-#define TWENTY_FOUR_HOURS_INTERRUPT_ENABLE  0x20       /* 24 Hours Interrupt Enable */
-#define DAY_ALARM_INTERRUPT_ENABLE  0x40       /* Day Alarm Interrupt Enable */
-#define WRITE_COMPLETE_INTERRUPT_ENABLE  0x8000     /* Write Complete Interrupt Enable */
-
-/* Bit masks for RTC_ISTAT */
-
-#define      STOPWATCH_EVENT_FLAG  0x1        /* Stopwatch Event Flag */
-#define          ALARM_EVENT_FLAG  0x2        /* Alarm Event Flag */
-#define        SECONDS_EVENT_FLAG  0x4        /* Seconds Event Flag */
-#define        MINUTES_EVENT_FLAG  0x8        /* Minutes Event Flag */
-#define          HOURS_EVENT_FLAG  0x10       /* Hours Event Flag */
-#define TWENTY_FOUR_HOURS_EVENT_FLAG  0x20       /* 24 Hours Event Flag */
-#define      DAY_ALARM_EVENT_FLAG  0x40       /* Day Alarm Event Flag */
-#define     WRITE_PENDING__STATUS  0x4000     /* Write Pending  Status */
-#define            WRITE_COMPLETE  0x8000     /* Write Complete */
-
-/* Bit masks for RTC_SWCNT */
-
-#define           STOPWATCH_COUNT  0xffff     /* Stopwatch Count */
-
-/* Bit masks for RTC_ALARM */
-
-#define                   SECONDS  0x3f       /* Seconds */
-#define                   MINUTES  0xfc0      /* Minutes */
-#define                     HOURS  0x1f000    /* Hours */
-#define                       DAY  0xfffe0000 /* Day */
-
-/* Bit masks for RTC_PREN */
-
-#define                      PREN  0x1        /* Prescaler Enable */
-
-/* Bit masks for OTP_CONTROL */
-
-#define                FUSE_FADDR  0x1ff      /* OTP/Fuse Address */
-#define                      FIEN  0x800      /* OTP/Fuse Interrupt Enable */
-#define                  FTESTDEC  0x1000     /* OTP/Fuse Test Decoder */
-#define                   FWRTEST  0x2000     /* OTP/Fuse Write Test */
-#define                     FRDEN  0x4000     /* OTP/Fuse Read Enable */
-#define                     FWREN  0x8000     /* OTP/Fuse Write Enable */
-
-/* Bit masks for OTP_BEN */
-
-#define                      FBEN  0xffff     /* OTP/Fuse Byte Enable */
-
-/* Bit masks for OTP_STATUS */
-
-#define                     FCOMP  0x1        /* OTP/Fuse Access Complete */
-#define                    FERROR  0x2        /* OTP/Fuse Access Error */
-#define                  MMRGLOAD  0x10       /* Memory Mapped Register Gasket Load */
-#define                  MMRGLOCK  0x20       /* Memory Mapped Register Gasket Lock */
-#define                    FPGMEN  0x40       /* OTP/Fuse Program Enable */
-
-/* Bit masks for OTP_TIMING */
-
-#define                   USECDIV  0xff       /* Micro Second Divider */
-#define                   READACC  0x7f00     /* Read Access Time */
-#define                   CPUMPRL  0x38000    /* Charge Pump Release Time */
-#define                   CPUMPSU  0xc0000    /* Charge Pump Setup Time */
-#define                   CPUMPHD  0xf00000   /* Charge Pump Hold Time */
-#define                   PGMTIME  0xff000000 /* Program Time */
-
 /* Bit masks for SECURE_SYSSWT */
 
 #define                   EMUDABL  0x1        /* Emulation Disable. */
 #define                    AFEXIT  0x10       /* Authentication Firmware Exit */
 #define                   SECSTAT  0xe0       /* Secure Status */
 
-/* Bit masks for PLL_DIV */
-
-#define                      CSEL  0x30       /* Core Select */
-#define                      SSEL  0xf        /* System Select */
-#define                        CSEL_DIV1       0x0000  /* CCLK = VCO / 1 */
-#define                        CSEL_DIV2       0x0010  /* CCLK = VCO / 2 */
-#define                        CSEL_DIV4       0x0020  /* CCLK = VCO / 4 */
-#define                        CSEL_DIV8       0x0030  /* CCLK = VCO / 8 */
-
-/* Bit masks for PLL_CTL */
-
-#define                      MSEL  0x7e00     /* Multiplier Select */
-#define                    BYPASS  0x100      /* PLL Bypass Enable */
-#define              OUTPUT_DELAY  0x80       /* External Memory Output Delay Enable */
-#define               INPUT_DELAY  0x40       /* External Memory Input Delay Enable */
-#define                      PDWN  0x20       /* Power Down */
-#define                    STOPCK  0x8        /* Stop Clock */
-#define                   PLL_OFF  0x2        /* Disable PLL */
-#define                        DF  0x1        /* Divide Frequency */
-
 /* SWRST Masks */
 #define              SYSTEM_RESET 0x0007       /* Initiates A System Software Reset */
 #define              DOUBLE_FAULT 0x0008       /* Core Double Fault Causes Reset */
 #define                RESET_WDOG 0x4000       /* SW Reset Generated By Watchdog Timer */
 #define            RESET_SOFTWARE 0x8000       /* SW Reset Occurred Since Last Read Of SWRST */
 
-/* Bit masks for PLL_STAT */
-
-#define                PLL_LOCKED  0x20       /* PLL Locked Status */
-#define        ACTIVE_PLLDISABLED  0x4        /* Active Mode With PLL Disabled */
-#define                   FULL_ON  0x2        /* Full-On Mode */
-#define         ACTIVE_PLLENABLED  0x1        /* Active Mode With PLL Enabled */
-#define                     RTCWS  0x400      /* RTC/Reset Wake-Up Status */
-#define                     CANWS  0x800      /* CAN Wake-Up Status */
-#define                     USBWS  0x2000     /* USB Wake-Up Status */
-#define                    KPADWS  0x4000     /* Keypad Wake-Up Status */
-#define                     ROTWS  0x8000     /* Rotary Wake-Up Status */
-#define                      GPWS  0x1000     /* General-Purpose Wake-Up Status */
-
-/* Bit masks for VR_CTL */
-
-#define                      FREQ  0x3        /* Regulator Switching Frequency */
-#define                      GAIN  0xc        /* Voltage Output Level Gain */
-#define                      VLEV  0xf0       /* Internal Voltage Level */
-#define                   SCKELOW  0x8000     /* Drive SCKE Low During Reset Enable */
-#define                      WAKE  0x100      /* RTC/Reset Wake-Up Enable */
-#define                     CANWE  0x200      /* CAN0/1 Wake-Up Enable */
-#define                      GPWE  0x400      /* General-Purpose Wake-Up Enable */
-#define                     USBWE  0x800      /* USB Wake-Up Enable */
-#define                    KPADWE  0x1000     /* Keypad Wake-Up Enable */
-#define                     ROTWE  0x2000     /* Rotary Wake-Up Enable */
-
-#define        FREQ_333                0x0001  /* Switching Frequency Is 333 kHz */
-#define        FREQ_667                0x0002  /* Switching Frequency Is 667 kHz */
-#define        FREQ_1000               0x0003  /* Switching Frequency Is 1 MHz */
-
-#define        GAIN_5                  0x0000  /* GAIN = 5*/
-#define        GAIN_10                 0x0004  /* GAIN = 1*/
-#define        GAIN_20                 0x0008  /* GAIN = 2*/
-#define        GAIN_50                 0x000C  /* GAIN = 5*/
-
-#define        VLEV_085                0x0060  /* VLEV = 0.85 V (-5% - +10% Accuracy) */
-#define        VLEV_090                0x0070  /* VLEV = 0.90 V (-5% - +10% Accuracy) */
-#define        VLEV_095                0x0080  /* VLEV = 0.95 V (-5% - +10% Accuracy) */
-#define        VLEV_100                0x0090  /* VLEV = 1.00 V (-5% - +10% Accuracy) */
-#define        VLEV_105                0x00A0  /* VLEV = 1.05 V (-5% - +10% Accuracy) */
-#define        VLEV_110                0x00B0  /* VLEV = 1.10 V (-5% - +10% Accuracy) */
-#define        VLEV_115                0x00C0  /* VLEV = 1.15 V (-5% - +10% Accuracy) */
-#define        VLEV_120                0x00D0  /* VLEV = 1.20 V (-5% - +10% Accuracy) */
-#define        VLEV_125                0x00E0  /* VLEV = 1.25 V (-5% - +10% Accuracy) */
-#define        VLEV_130                0x00F0  /* VLEV = 1.30 V (-5% - +10% Accuracy) */
-
 /* Bit masks for NFC_CTL */
 
 #define                    WR_DLY  0xf        /* Write Strobe Delay */
 #define                      UCCT  0x40       /* Universal Counter CAN Trigger */
 #define                       UCE  0x80       /* Universal Counter Enable */
 
-/* Bit masks for CAN0_UCCNT */
-
-#define                     UCCNT  0xffff     /* Universal Counter Count Value */
-
-/* Bit masks for CAN0_UCRC */
-
-#define                     UCVAL  0xffff     /* Universal Counter Reload/Capture Value */
-
 /* Bit masks for CAN0_CEC */
 
 #define                    RXECNT  0xff       /* Receive Error Counter */
index e4bc6d7c5a6a1e83ba33a287cc7feb6aabcc7d7a..1aa529b9f8bb334a2cda9d70adf8dd7222e8f0b0 100644 (file)
@@ -19,4 +19,11 @@ config BFIN561_BLUETECHNIX_CM
        help
          CM-BF561 support for EVAL- and DEV-Board.
 
+config BFIN561_ACVILON
+       bool "BF561-ACVILON"
+       help
+         BF561-ACVILON System On Module support (SO-DIMM 144).
+         For more information about Acvilon BF561 SoM
+         please go to http://www.niistt.ru/
+
 endchoice
index 3a152559e957d1ab98cac121399256be9a72bc4a..a5879f7857adc045d613e97053efea37e4be3e50 100644 (file)
@@ -2,6 +2,7 @@
 # arch/blackfin/mach-bf561/boards/Makefile
 #
 
+obj-$(CONFIG_BFIN561_ACVILON)          += acvilon.o
 obj-$(CONFIG_BFIN561_BLUETECHNIX_CM)   += cm_bf561.o
 obj-$(CONFIG_BFIN561_EZKIT)            += ezkit.o
 obj-$(CONFIG_BFIN561_TEPLA)            += tepla.o
diff --git a/arch/blackfin/mach-bf561/boards/acvilon.c b/arch/blackfin/mach-bf561/boards/acvilon.c
new file mode 100644 (file)
index 0000000..07e8dc8
--- /dev/null
@@ -0,0 +1,551 @@
+/*
+ * File:         arch/blackfin/mach-bf561/acvilon.c
+ * Based on:     arch/blackfin/mach-bf561/ezkit.c
+ * Author:
+ *
+ * Created:
+ * Description:
+ *
+ * Modified:
+ *               Copyright 2004-2006 Analog Devices Inc.
+ *               Copyright 2009 CJSC "NII STT"
+ *
+ * Bugs:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ *
+ * For more information about Acvilon BF561 SoM please
+ * go to http://www.niistt.ru/
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/plat-ram.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/i2c-pca-platform.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <asm/dma.h>
+#include <asm/bfin5xx_spi.h>
+#include <asm/portmux.h>
+#include <asm/dpmc.h>
+#include <asm/cacheflush.h>
+#include <linux/i2c.h>
+
+/*
+ * Name the Board for the /proc/cpuinfo
+ */
+const char bfin_board_name[] = "Acvilon board";
+
+#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
+#include <linux/usb/isp1760.h>
+static struct resource bfin_isp1760_resources[] = {
+       [0] = {
+              .start = 0x20000000,
+              .end = 0x20000000 + 0x000fffff,
+              .flags = IORESOURCE_MEM,
+              },
+       [1] = {
+              .start = IRQ_PF15,
+              .end = IRQ_PF15,
+              .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
+              },
+};
+
+static struct isp1760_platform_data isp1760_priv = {
+       .is_isp1761 = 0,
+       .port1_disable = 0,
+       .bus_width_16 = 1,
+       .port1_otg = 0,
+       .analog_oc = 0,
+       .dack_polarity_high = 0,
+       .dreq_polarity_high = 0,
+};
+
+static struct platform_device bfin_isp1760_device = {
+       .name = "isp1760-hcd",
+       .id = 0,
+       .dev = {
+               .platform_data = &isp1760_priv,
+               },
+       .num_resources = ARRAY_SIZE(bfin_isp1760_resources),
+       .resource = bfin_isp1760_resources,
+};
+#endif
+
+static struct resource bfin_i2c_pca_resources[] = {
+       {
+        .name = "pca9564-regs",
+        .start = 0x2C000000,
+        .end = 0x2C000000 + 16,
+        .flags = IORESOURCE_MEM | IORESOURCE_MEM_32BIT,
+        }, {
+
+            .start = IRQ_PF8,
+            .end = IRQ_PF8,
+            .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
+            },
+};
+
+struct i2c_pca9564_pf_platform_data pca9564_platform_data = {
+       .gpio = -1,
+       .i2c_clock_speed = 330000,
+       .timeout = 10000
+};
+
+/* PCA9564 I2C Bus driver */
+static struct platform_device bfin_i2c_pca_device = {
+       .name = "i2c-pca-platform",
+       .id = 0,
+       .num_resources = ARRAY_SIZE(bfin_i2c_pca_resources),
+       .resource = bfin_i2c_pca_resources,
+       .dev = {
+               .platform_data = &pca9564_platform_data,
+               }
+};
+
+/* I2C devices fitted. */
+static struct i2c_board_info acvilon_i2c_devs[] __initdata = {
+       {
+        I2C_BOARD_INFO("ds1339", 0x68),
+        },
+       {
+        I2C_BOARD_INFO("tcn75", 0x49),
+        },
+};
+
+#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
+static struct platdata_mtd_ram mtd_ram_data = {
+       .mapname = "rootfs(RAM)",
+       .bankwidth = 4,
+};
+
+static struct resource mtd_ram_resource = {
+       .start = 0x4000000,
+       .end = 0x5ffffff,
+       .flags = IORESOURCE_MEM,
+};
+
+static struct platform_device mtd_ram_device = {
+       .name = "mtd-ram",
+       .id = 0,
+       .dev = {
+               .platform_data = &mtd_ram_data,
+               },
+       .num_resources = 1,
+       .resource = &mtd_ram_resource,
+};
+#endif
+
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
+#include <linux/smsc911x.h>
+static struct resource smsc911x_resources[] = {
+       {
+        .name = "smsc911x-memory",
+        .start = 0x28000000,
+        .end = 0x28000000 + 0xFF,
+        .flags = IORESOURCE_MEM,
+        },
+       {
+        .start = IRQ_PF7,
+        .end = IRQ_PF7,
+        .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
+        },
+};
+
+static struct smsc911x_platform_config smsc911x_config = {
+       .flags = SMSC911X_USE_32BIT,
+       .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
+       .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
+       .phy_interface = PHY_INTERFACE_MODE_MII,
+};
+
+static struct platform_device smsc911x_device = {
+       .name = "smsc911x",
+       .id = 0,
+       .num_resources = ARRAY_SIZE(smsc911x_resources),
+       .resource = smsc911x_resources,
+       .dev = {
+               .platform_data = &smsc911x_config,
+               },
+};
+#endif
+
+#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
+#ifdef CONFIG_SERIAL_BFIN_UART0
+static struct resource bfin_uart0_resources[] = {
+       {
+        .start = BFIN_UART_THR,
+        .end = BFIN_UART_GCTL + 2,
+        .flags = IORESOURCE_MEM,
+        },
+       {
+        .start = IRQ_UART_RX,
+        .end = IRQ_UART_RX + 1,
+        .flags = IORESOURCE_IRQ,
+        },
+       {
+        .start = IRQ_UART_ERROR,
+        .end = IRQ_UART_ERROR,
+        .flags = IORESOURCE_IRQ,
+        },
+       {
+        .start = CH_UART_TX,
+        .end = CH_UART_TX,
+        .flags = IORESOURCE_DMA,
+        },
+       {
+        .start = CH_UART_RX,
+        .end = CH_UART_RX,
+        .flags = IORESOURCE_DMA,
+        },
+};
+
+unsigned short bfin_uart0_peripherals[] = {
+       P_UART0_TX, P_UART0_RX, 0
+};
+
+static struct platform_device bfin_uart0_device = {
+       .name = "bfin-uart",
+       .id = 0,
+       .num_resources = ARRAY_SIZE(bfin_uart0_resources),
+       .resource = bfin_uart0_resources,
+       .dev = {
+               /* Passed to driver */
+               .platform_data = &bfin_uart0_peripherals,
+               },
+};
+#endif
+#endif
+
+#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
+
+#ifdef CONFIG_MTD_PARTITIONS
+const char *part_probes[] = { "cmdlinepart", NULL };
+
+static struct mtd_partition bfin_plat_nand_partitions[] = {
+       {
+        .name = "params(nand)",
+        .size = 32 * 1024 * 1024,
+        .offset = 0,
+        }, {
+            .name = "userfs(nand)",
+            .size = MTDPART_SIZ_FULL,
+            .offset = MTDPART_OFS_APPEND,
+            },
+};
+#endif
+
+#define BFIN_NAND_PLAT_CLE 2
+#define BFIN_NAND_PLAT_ALE 3
+
+static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
+                                   unsigned int ctrl)
+{
+       struct nand_chip *this = mtd->priv;
+
+       if (cmd == NAND_CMD_NONE)
+               return;
+
+       if (ctrl & NAND_CLE)
+               writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
+       else
+               writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
+}
+
+#define BFIN_NAND_PLAT_READY GPIO_PF10
+static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
+{
+       return gpio_get_value(BFIN_NAND_PLAT_READY);
+}
+
+static struct platform_nand_data bfin_plat_nand_data = {
+       .chip = {
+                .chip_delay = 30,
+#ifdef CONFIG_MTD_PARTITIONS
+                .part_probe_types = part_probes,
+                .partitions = bfin_plat_nand_partitions,
+                .nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
+#endif
+                },
+       .ctrl = {
+                .cmd_ctrl = bfin_plat_nand_cmd_ctrl,
+                .dev_ready = bfin_plat_nand_dev_ready,
+                },
+};
+
+#define MAX(x, y) (x > y ? x : y)
+static struct resource bfin_plat_nand_resources = {
+       .start = 0x24000000,
+       .end = 0x24000000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
+       .flags = IORESOURCE_IO,
+};
+
+static struct platform_device bfin_async_nand_device = {
+       .name = "gen_nand",
+       .id = -1,
+       .num_resources = 1,
+       .resource = &bfin_plat_nand_resources,
+       .dev = {
+               .platform_data = &bfin_plat_nand_data,
+               },
+};
+
+static void bfin_plat_nand_init(void)
+{
+       gpio_request(BFIN_NAND_PLAT_READY, "bfin_nand_plat");
+}
+#else
+static void bfin_plat_nand_init(void)
+{
+}
+#endif
+
+#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE)
+static struct mtd_partition bfin_spi_dataflash_partitions[] = {
+       {
+        .name = "bootloader",
+        .size = 0x4200,
+        .offset = 0,
+        .mask_flags = MTD_CAP_ROM},
+       {
+        .name = "u-boot",
+        .size = 0x42000,
+        .offset = MTDPART_OFS_APPEND,
+        },
+       {
+        .name = "u-boot(params)",
+        .size = 0x4200,
+        .offset = MTDPART_OFS_APPEND,
+        },
+       {
+        .name = "kernel",
+        .size = 0x294000,
+        .offset = MTDPART_OFS_APPEND,
+        },
+       {
+        .name = "params",
+        .size = 0x42000,
+        .offset = MTDPART_OFS_APPEND,
+        },
+       {
+        .name = "rootfs",
+        .size = MTDPART_SIZ_FULL,
+        .offset = MTDPART_OFS_APPEND,
+        }
+};
+
+static struct flash_platform_data bfin_spi_dataflash_data = {
+       .name = "SPI Dataflash",
+       .parts = bfin_spi_dataflash_partitions,
+       .nr_parts = ARRAY_SIZE(bfin_spi_dataflash_partitions),
+};
+
+/* DataFlash chip */
+static struct bfin5xx_spi_chip data_flash_chip_info = {
+       .enable_dma = 0,        /* use dma transfer with this chip */
+       .bits_per_word = 8,
+};
+#endif
+
+#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
+static struct bfin5xx_spi_chip spidev_chip_info = {
+       .enable_dma = 0,
+       .bits_per_word = 8,
+};
+#endif
+
+#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
+/* SPI (0) */
+static struct resource bfin_spi0_resource[] = {
+       [0] = {
+              .start = SPI0_REGBASE,
+              .end = SPI0_REGBASE + 0xFF,
+              .flags = IORESOURCE_MEM,
+              },
+       [1] = {
+              .start = CH_SPI,
+              .end = CH_SPI,
+              .flags = IORESOURCE_DMA,
+              },
+       [2] = {
+              .start = IRQ_SPI,
+              .end = IRQ_SPI,
+              .flags = IORESOURCE_IRQ,
+              },
+};
+
+/* SPI controller data */
+static struct bfin5xx_spi_master bfin_spi0_info = {
+       .num_chipselect = 8,
+       .enable_dma = 1,        /* master has the ability to do dma transfer */
+       .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
+};
+
+static struct platform_device bfin_spi0_device = {
+       .name = "bfin-spi",
+       .id = 0,                /* Bus number */
+       .num_resources = ARRAY_SIZE(bfin_spi0_resource),
+       .resource = bfin_spi0_resource,
+       .dev = {
+               .platform_data = &bfin_spi0_info,       /* Passed to driver */
+               },
+};
+#endif
+
+static struct spi_board_info bfin_spi_board_info[] __initdata = {
+#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
+       {
+        .modalias = "spidev",
+        .max_speed_hz = 3125000,       /* max spi clock (SCK) speed in HZ */
+        .bus_num = 0,
+        .chip_select = 3,
+        .controller_data = &spidev_chip_info,
+        },
+#endif
+#if defined(CONFIG_MTD_DATAFLASH) || defined(CONFIG_MTD_DATAFLASH_MODULE)
+       {                       /* DataFlash chip */
+        .modalias = "mtd_dataflash",
+        .max_speed_hz = 33250000,      /* max spi clock (SCK) speed in HZ */
+        .bus_num = 0,          /* Framework bus number */
+        .chip_select = 2,      /* Framework chip select */
+        .platform_data = &bfin_spi_dataflash_data,
+        .controller_data = &data_flash_chip_info,
+        .mode = SPI_MODE_3,
+        },
+#endif
+};
+
+static struct resource bfin_gpios_resources = {
+       .start = 31,
+/*      .end   = MAX_BLACKFIN_GPIOS - 1, */
+       .end = 32,
+       .flags = IORESOURCE_IRQ,
+};
+
+static struct platform_device bfin_gpios_device = {
+       .name = "simple-gpio",
+       .id = -1,
+       .num_resources = 1,
+       .resource = &bfin_gpios_resources,
+};
+
+static const unsigned int cclk_vlev_datasheet[] = {
+       VRPAIR(VLEV_085, 250000000),
+       VRPAIR(VLEV_090, 300000000),
+       VRPAIR(VLEV_095, 313000000),
+       VRPAIR(VLEV_100, 350000000),
+       VRPAIR(VLEV_105, 400000000),
+       VRPAIR(VLEV_110, 444000000),
+       VRPAIR(VLEV_115, 450000000),
+       VRPAIR(VLEV_120, 475000000),
+       VRPAIR(VLEV_125, 500000000),
+       VRPAIR(VLEV_130, 600000000),
+};
+
+static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
+       .tuple_tab = cclk_vlev_datasheet,
+       .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
+       .vr_settling_time = 25 /* us */ ,
+};
+
+static struct platform_device bfin_dpmc = {
+       .name = "bfin dpmc",
+       .dev = {
+               .platform_data = &bfin_dmpc_vreg_data,
+               },
+};
+
+static struct platform_device *acvilon_devices[] __initdata = {
+       &bfin_dpmc,
+
+#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
+       &bfin_spi0_device,
+#endif
+
+#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
+#ifdef CONFIG_SERIAL_BFIN_UART0
+       &bfin_uart0_device,
+#endif
+#endif
+
+       &bfin_gpios_device,
+
+#if defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE)
+       &smsc911x_device,
+#endif
+
+       &bfin_i2c_pca_device,
+
+#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
+       &bfin_async_nand_device,
+#endif
+
+#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
+       &mtd_ram_device,
+#endif
+
+};
+
+static int __init acvilon_init(void)
+{
+       int ret;
+
+       printk(KERN_INFO "%s(): registering device resources\n", __func__);
+
+       bfin_plat_nand_init();
+       ret =
+           platform_add_devices(acvilon_devices, ARRAY_SIZE(acvilon_devices));
+       if (ret < 0)
+               return ret;
+
+       i2c_register_board_info(0, acvilon_i2c_devs,
+                               ARRAY_SIZE(acvilon_i2c_devs));
+
+       bfin_write_FIO0_FLAG_C(1 << 14);
+       msleep(5);
+       bfin_write_FIO0_FLAG_S(1 << 14);
+
+       spi_register_board_info(bfin_spi_board_info,
+                               ARRAY_SIZE(bfin_spi_board_info));
+       return 0;
+}
+
+arch_initcall(acvilon_init);
+
+static struct platform_device *acvilon_early_devices[] __initdata = {
+#if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
+#ifdef CONFIG_SERIAL_BFIN_UART0
+       &bfin_uart0_device,
+#endif
+#endif
+};
+
+void __init native_machine_early_platform_add_devices(void)
+{
+       printk(KERN_INFO "register early platform devices\n");
+       early_platform_add_devices(acvilon_early_devices,
+                                  ARRAY_SIZE(acvilon_early_devices));
+}
index 9e2d8cfba546c58e252742f36e8dc11a27365739..ffd3e6a80d1a7e370f9ced5ceb777bdf0752e2f0 100644 (file)
@@ -49,7 +49,7 @@ static struct isp1760_platform_data isp1760_priv = {
 };
 
 static struct platform_device bfin_isp1760_device = {
-       .name           = "isp1760-hcd",
+       .name           = "isp1760",
        .id             = 0,
        .dev = {
                .platform_data = &isp1760_priv,
@@ -159,28 +159,6 @@ static struct platform_device smc91x_device = {
 };
 #endif
 
-#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
-static struct resource ax88180_resources[] = {
-       [0] = {
-               .start  = 0x2c000000,
-               .end    = 0x2c000000 + 0x8000,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = IRQ_PF10,
-               .end    = IRQ_PF10,
-               .flags  = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
-       },
-};
-
-static struct platform_device ax88180_device = {
-       .name           = "ax88180",
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(ax88180_resources),
-       .resource       = ax88180_resources,
-};
-#endif
-
 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
 static struct resource bfin_uart_resources[] = {
        {
@@ -421,10 +399,6 @@ static struct platform_device *ezkit_devices[] __initdata = {
        &smc91x_device,
 #endif
 
-#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
-       &ax88180_device,
-#endif
-
 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
        &net2272_bfin_device,
 #endif
index 1e60a92dd6028d21ec02cccf885ee1b8841bf980..deb2271d09a327a5301cb2aeb97498673126f053 100644 (file)
@@ -22,8 +22,8 @@
 #define CMD_COREB_STOP         3
 #define CMD_COREB_RESET                4
 
-static int
-coreb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static long
+coreb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        int ret = 0;
 
@@ -49,8 +49,8 @@ coreb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned l
 }
 
 static const struct file_operations coreb_fops = {
-       .owner   = THIS_MODULE,
-       .ioctl   = coreb_ioctl,
+       .owner          = THIS_MODULE,
+       .unlocked_ioctl = coreb_ioctl,
 };
 
 static struct miscdevice coreb_dev = {
index a31e509553fbe8d7a408e901498a62351173df9e..4c8e36b7fb33752144d616fe7f406d1b968f8906 100644 (file)
 /* System MMR Register Bits */
 /******************************************************************************* */
 
-/* ********************* PLL AND RESET MASKS ************************ */
-
-/* PLL_CTL Masks */
-#define PLL_CLKIN              0x00000000      /* Pass CLKIN to PLL */
-#define PLL_CLKIN_DIV2         0x00000001      /* Pass CLKIN/2 to PLL */
-#define PLL_OFF                0x00000002      /* Shut off PLL clocks */
-#define STOPCK_OFF             0x00000008      /* Core clock off */
-#define PDWN                   0x00000020      /* Put the PLL in a Deep Sleep state */
-#define BYPASS                 0x00000100      /* Bypass the PLL */
-
 /* CHIPID Masks */
 #define CHIPID_VERSION         0xF0000000
 #define CHIPID_FAMILY          0x0FFFF000
 #define CHIPID_MANUFACTURE     0x00000FFE
 
-/* VR_CTL Masks                                                                                                                                        */
-#define        FREQ                    0x0003  /* Switching Oscillator Frequency For Regulator */
-#define        HIBERNATE               0x0000  /* Powerdown/Bypass On-Board Regulation */
-#define        FREQ_333                0x0001  /* Switching Frequency Is 333 kHz */
-#define        FREQ_667                0x0002  /* Switching Frequency Is 667 kHz */
-#define        FREQ_1000               0x0003  /* Switching Frequency Is 1 MHz */
-
-#define        GAIN                    0x000C  /* Voltage Level Gain   */
-#define        GAIN_5                  0x0000  /* GAIN = 5*/
-#define        GAIN_10                 0x0004  /* GAIN = 1*/
-#define        GAIN_20                 0x0008  /* GAIN = 2*/
-#define        GAIN_50                 0x000C  /* GAIN = 5*/
-
-#define        VLEV                    0x00F0  /* Internal Voltage Level */
-#define        VLEV_085                0x0060  /* VLEV = 0.85 V (-5% - +10% Accuracy) */
-#define        VLEV_090                0x0070  /* VLEV = 0.90 V (-5% - +10% Accuracy) */
-#define        VLEV_095                0x0080  /* VLEV = 0.95 V (-5% - +10% Accuracy) */
-#define        VLEV_100                0x0090  /* VLEV = 1.00 V (-5% - +10% Accuracy) */
-#define        VLEV_105                0x00A0  /* VLEV = 1.05 V (-5% - +10% Accuracy) */
-#define        VLEV_110                0x00B0  /* VLEV = 1.10 V (-5% - +10% Accuracy) */
-#define        VLEV_115                0x00C0  /* VLEV = 1.15 V (-5% - +10% Accuracy) */
-#define        VLEV_120                0x00D0  /* VLEV = 1.20 V (-5% - +10% Accuracy) */
-#define        VLEV_125                0x00E0  /* VLEV = 1.25 V (-5% - +10% Accuracy) */
-#define        VLEV_130                0x00F0  /* VLEV = 1.30 V (-5% - +10% Accuracy) */
-
-#define        WAKE                    0x0100  /* Enable RTC/Reset Wakeup From Hibernate */
-#define        SCKELOW                 0x8000  /* Do Not Drive SCKE High During Reset After Hibernate */
-
-/* PLL_DIV Masks */
-#define SCLK_DIV(x)  (x)       /* SCLK = VCO / x */
-
-#define CSEL                   0x30            /* Core Select */
-#define SSEL                   0xf             /* System Select */
-#define CCLK_DIV1              0x00000000      /* CCLK = VCO / 1 */
-#define CCLK_DIV2              0x00000010      /* CCLK = VCO / 2 */
-#define CCLK_DIV4              0x00000020      /* CCLK = VCO / 4 */
-#define CCLK_DIV8              0x00000030      /* CCLK = VCO / 8 */
-
-/* PLL_STAT Masks                                                                                                                                      */
-#define ACTIVE_PLLENABLED      0x0001  /* Processor In Active Mode With PLL Enabled    */
-#define        FULL_ON                         0x0002  /* Processor In Full On Mode                                    */
-#define ACTIVE_PLLDISABLED     0x0004  /* Processor In Active Mode With PLL Disabled   */
-#define        PLL_LOCKED                      0x0020  /* PLL_LOCKCNT Has Been Reached                                 */
-
 /* SICA_SYSCR Masks */
 #define COREB_SRAM_INIT                0x0020
 
 
 /* **********  DMA CONTROLLER MASKS  *********************8 */
 
-/* DMAx_CONFIG, MDMA_yy_CONFIG, IMDMA_yy_CONFIG Masks */
-#define DMAEN          0x00000001      /* Channel Enable */
-#define WNR            0x00000002      /* Channel Direction (W/R*) */
-#define WDSIZE_8       0x00000000      /* Word Size 8 bits */
-#define WDSIZE_16      0x00000004      /* Word Size 16 bits */
-#define WDSIZE_32      0x00000008      /* Word Size 32 bits */
-#define DMA2D          0x00000010      /* 2D/1D* Mode */
-#define RESTART         0x00000020     /* Restart */
-#define DI_SEL         0x00000040      /* Data Interrupt Select */
-#define DI_EN          0x00000080      /* Data Interrupt Enable */
-#define NDSIZE_0               0x0000  /* Next Descriptor Size = 0 (Stop/Autobuffer)   */
-#define NDSIZE_1               0x0100  /* Next Descriptor Size = 1                                             */
-#define NDSIZE_2               0x0200  /* Next Descriptor Size = 2                                             */
-#define NDSIZE_3               0x0300  /* Next Descriptor Size = 3                                             */
-#define NDSIZE_4               0x0400  /* Next Descriptor Size = 4                                             */
-#define NDSIZE_5               0x0500  /* Next Descriptor Size = 5                                             */
-#define NDSIZE_6               0x0600  /* Next Descriptor Size = 6                                             */
-#define NDSIZE_7               0x0700  /* Next Descriptor Size = 7                                             */
-#define NDSIZE_8               0x0800  /* Next Descriptor Size = 8                                             */
-#define NDSIZE_9               0x0900  /* Next Descriptor Size = 9                                             */
-#define NDSIZE         0x00000900      /* Next Descriptor Size */
-#define DMAFLOW                0x00007000      /* Flow Control */
-#define DMAFLOW_STOP           0x0000  /* Stop Mode */
-#define DMAFLOW_AUTO           0x1000  /* Autobuffer Mode */
-#define DMAFLOW_ARRAY          0x4000  /* Descriptor Array Mode */
-#define DMAFLOW_SMALL          0x6000  /* Small Model Descriptor List Mode */
-#define DMAFLOW_LARGE          0x7000  /* Large Model Descriptor List Mode */
-
-#define DMAEN_P                        0       /* Channel Enable */
-#define WNR_P                  1       /* Channel Direction (W/R*) */
-#define DMA2D_P                        4       /* 2D/1D* Mode */
-#define RESTART_P              5       /* Restart */
-#define DI_SEL_P               6       /* Data Interrupt Select */
-#define DI_EN_P                        7       /* Data Interrupt Enable */
-
-/* DMAx_IRQ_STATUS, MDMA_yy_IRQ_STATUS, IMDMA_yy_IRQ_STATUS Masks */
-
-#define DMA_DONE               0x00000001      /* DMA Done Indicator */
-#define DMA_ERR                        0x00000002      /* DMA Error Indicator */
-#define DFETCH                 0x00000004      /* Descriptor Fetch Indicator */
-#define DMA_RUN                        0x00000008      /* DMA Running Indicator */
-
-#define DMA_DONE_P             0       /* DMA Done Indicator */
-#define DMA_ERR_P              1       /* DMA Error Indicator */
-#define DFETCH_P               2       /* Descriptor Fetch Indicator */
-#define DMA_RUN_P              3       /* DMA Running Indicator */
-
 /* DMAx_PERIPHERAL_MAP, MDMA_yy_PERIPHERAL_MAP, IMDMA_yy_PERIPHERAL_MAP Masks */
 
 #define CTYPE              0x00000040  /* DMA Channel Type Indicator */
index 510f57641495b4bfe900679d935665b0fb227335..0192532e96a242fefe806ad168fc9bc311d35f2b 100644 (file)
@@ -52,8 +52,6 @@ int __init setup_profiling_timer(unsigned int multiplier) /* not supported */
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
-       local_irq_disable();
-
        /* Clone setup for peripheral interrupt sources from CoreA. */
        bfin_write_SICB_IMASK0(bfin_read_SICA_IMASK0());
        bfin_write_SICB_IMASK1(bfin_read_SICA_IMASK1());
@@ -70,11 +68,6 @@ void __cpuinit platform_secondary_init(unsigned int cpu)
        bfin_write_SICB_IAR7(bfin_read_SICA_IAR7());
        SSYNC();
 
-       local_irq_enable();
-
-       /* Calibrate loops per jiffy value. */
-       calibrate_delay();
-
        /* Store CPU-private information to the cpu_data array. */
        bfin_setup_cpudata(cpu);
 
@@ -108,9 +101,13 @@ int __cpuinit platform_boot_secondary(unsigned int cpu, struct task_struct *idle
                barrier();
        }
 
-       spin_unlock(&boot_lock);
-
-       return cpu_isset(cpu, cpu_callin_map) ? 0 : -ENOSYS;
+       if (cpu_isset(cpu, cpu_callin_map)) {
+               cpu_set(cpu, cpu_online_map);
+               /* release the lock and let coreb run */
+               spin_unlock(&boot_lock);
+               return 0;
+       } else
+               panic("CPU%u: processor failed to boot\n", cpu);
 }
 
 void __init platform_request_ipi(irq_handler_t handler)
index ef6870e9eea6d37c4771cfbd73906d85ffe03dec..d5cfe611b77834b9abfeaefd211d75b2a5f1c12a 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/dma.h>
 #include <asm/clocks.h>
 #include <asm/mem_init.h>
+#include <asm/dpmc.h>
 
 #define SDGCTL_WIDTH (1 << 31) /* SDRAM external data path width */
 #define PLL_CTL_VAL \
index 01506504e6d05cb464234febd43dabddf66e420e..7775828972530af124b30fee5c3b6972fe4d1c07 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/fs.h>
 #include <asm/blackfin.h>
 #include <asm/time.h>
-
+#include <asm/dpmc.h>
 
 /* this is the table of CCLK frequencies, in Hz */
 /* .index is the entry in the auxillary dpm_state_table[] */
@@ -138,7 +138,8 @@ static int __init __bfin_cpu_init(struct cpufreq_policy *policy)
                                                 dpm_state_table[index].tscale);
        }
 
-       policy->cpuinfo.transition_latency = (bfin_read_PLL_LOCKCNT() / (sclk / 1000000)) * 1000;
+       policy->cpuinfo.transition_latency = 50000; /* 50us assumed */
+
        /*Now ,only support one cpu */
        policy->cur = cclk;
        cpufreq_frequency_table_get_attr(bfin_freq_table, policy->cpu);
index 8009a512fb1186214af8998e3400b73bb40d4f67..b037168960510762d1c42dbdf40d08a37c1fab06 100644 (file)
@@ -404,6 +404,21 @@ ENTRY(_do_hibernate)
        PM_SYS_PUSH(EBIU_FCTL)
 #endif
 
+#ifdef PORTCIO_FER
+       PM_SYS_PUSH16(PORTCIO_DIR)
+       PM_SYS_PUSH16(PORTCIO_INEN)
+       PM_SYS_PUSH16(PORTCIO)
+       PM_SYS_PUSH16(PORTCIO_FER)
+       PM_SYS_PUSH16(PORTDIO_DIR)
+       PM_SYS_PUSH16(PORTDIO_INEN)
+       PM_SYS_PUSH16(PORTDIO)
+       PM_SYS_PUSH16(PORTDIO_FER)
+       PM_SYS_PUSH16(PORTEIO_DIR)
+       PM_SYS_PUSH16(PORTEIO_INEN)
+       PM_SYS_PUSH16(PORTEIO)
+       PM_SYS_PUSH16(PORTEIO_FER)
+#endif
+
        PM_SYS_PUSH16(SYSCR)
 
        /* Save Core MMRs */
@@ -716,6 +731,21 @@ ENTRY(_do_hibernate)
        P0.L = lo(PLL_CTL);
        PM_SYS_POP16(SYSCR)
 
+#ifdef PORTCIO_FER
+       PM_SYS_POP16(PORTEIO_FER)
+       PM_SYS_POP16(PORTEIO)
+       PM_SYS_POP16(PORTEIO_INEN)
+       PM_SYS_POP16(PORTEIO_DIR)
+       PM_SYS_POP16(PORTDIO_FER)
+       PM_SYS_POP16(PORTDIO)
+       PM_SYS_POP16(PORTDIO_INEN)
+       PM_SYS_POP16(PORTDIO_DIR)
+       PM_SYS_POP16(PORTCIO_FER)
+       PM_SYS_POP16(PORTCIO)
+       PM_SYS_POP16(PORTCIO_INEN)
+       PM_SYS_POP16(PORTCIO_DIR)
+#endif
+
 #ifdef EBIU_FCTL
        PM_SYS_POP(EBIU_FCTL)
        PM_SYS_POP(EBIU_MODE)
index f3f8bb46b517d8f291633c8fda13195462731fe9..b0ed0b487ff24dbd94b66565f8843afda8feea71 100644 (file)
@@ -713,6 +713,8 @@ ENTRY(_system_call)
        cc = BITTST(r7, TIF_RESTORE_SIGMASK);
        if cc jump .Lsyscall_do_signals;
        cc = BITTST(r7, TIF_SIGPENDING);
+       if cc jump .Lsyscall_do_signals;
+       cc = BITTST(r7, TIF_NOTIFY_RESUME);
        if !cc jump .Lsyscall_really_exit;
 .Lsyscall_do_signals:
        /* Reenable interrupts.  */
@@ -721,7 +723,7 @@ ENTRY(_system_call)
 
        r0 = sp;
        SP += -12;
-       call _do_signal;
+       call _do_notify_resume;
        SP += 12;
 
 .Lsyscall_really_exit:
index 660ea1bec54ca28041e6eaa69ba3a23f4d99f290..1873b2c1fede8b2d267d639dbe9c111e05091b10 100644 (file)
 #include <asm/blackfin.h>
 #include <asm/gpio.h>
 #include <asm/irq_handler.h>
+#include <asm/dpmc.h>
+#include <asm/bfin5xx_spi.h>
+#include <asm/bfin_sport.h>
 
 #define SIC_SYSIRQ(irq)        (irq - (IRQ_CORETMR + 1))
 
 #ifdef BF537_FAMILY
 # define BF537_GENERIC_ERROR_INT_DEMUX
+# define SPI_ERR_MASK   (BIT_STAT_TXCOL | BIT_STAT_RBSY | BIT_STAT_MODF | BIT_STAT_TXE)        /* SPI_STAT */
+# define SPORT_ERR_MASK (ROVF | RUVF | TOVF | TUVF)    /* SPORT_STAT */
+# define PPI_ERR_MASK   (0xFFFF & ~FLD)        /* PPI_STATUS */
+# define EMAC_ERR_MASK  (PHYINT | MMCINT | RXFSINT | TXFSINT | WAKEDET | RXDMAERR | TXDMAERR | STMDONE)        /* EMAC_SYSTAT */
+# define UART_ERR_MASK  (0x6)  /* UART_IIR */
+# define CAN_ERR_MASK   (EWTIF | EWRIF | EPIF | BOIF | WUIF | UIAIF | AAIF | RMLIF | UCEIF | EXTIF | ADIF)     /* CAN_GIF */
 #else
 # undef BF537_GENERIC_ERROR_INT_DEMUX
 #endif
@@ -324,11 +333,9 @@ static void bfin_demux_error_irq(unsigned int int_err_irq,
                irq = IRQ_CAN_ERROR;
        else if (bfin_read_SPI_STAT() & SPI_ERR_MASK)
                irq = IRQ_SPI_ERROR;
-       else if ((bfin_read_UART0_IIR() & UART_ERR_MASK_STAT1) &&
-                (bfin_read_UART0_IIR() & UART_ERR_MASK_STAT0))
+       else if ((bfin_read_UART0_IIR() & UART_ERR_MASK) == UART_ERR_MASK)
                irq = IRQ_UART0_ERROR;
-       else if ((bfin_read_UART1_IIR() & UART_ERR_MASK_STAT1) &&
-                (bfin_read_UART1_IIR() & UART_ERR_MASK_STAT0))
+       else if ((bfin_read_UART1_IIR() & UART_ERR_MASK) == UART_ERR_MASK)
                irq = IRQ_UART1_ERROR;
 
        if (irq) {
index d92b168c83281cdd89326875e80ca75afe890c80..369e687582b7da4a86a3fab7a537a6740839ad1f 100644 (file)
@@ -336,13 +336,6 @@ int __cpuinit __cpu_up(unsigned int cpu)
 
        ret = platform_boot_secondary(cpu, idle);
 
-       if (ret) {
-               cpu_clear(cpu, cpu_present_map);
-               printk(KERN_CRIT "CPU%u: processor failed to boot (%d)\n", cpu, ret);
-               free_task(idle);
-       } else
-               cpu_set(cpu, cpu_online_map);
-
        secondary_stack = NULL;
 
        return ret;
@@ -418,9 +411,16 @@ void __cpuinit secondary_start_kernel(void)
 
        setup_secondary(cpu);
 
+       platform_secondary_init(cpu);
+
        local_irq_enable();
 
-       platform_secondary_init(cpu);
+       /*
+        * Calibrate loops per jiffy value.
+        * IRQs need to be enabled here - D-cache can be invalidated
+        * in timer irq handler, so core B can read correct jiffies.
+        */
+       calibrate_delay();
 
        cpu_idle();
 }
index 3db478eb515505ca3be2ff1253871cb51a1dedcf..76266f80a5f127431955ac75e764948a9a2b829c 100644 (file)
@@ -10,7 +10,6 @@
  * The macros found in mmu_defs_asm.h uses the ## concatenation operator, so
  * -traditional must not be used when assembling this file.
  */
-#include <linux/autoconf.h>
 #include <arch/memmap.h>
 #include <hwregs/reg_rdwr.h>
 #include <hwregs/intr_vect.h>
index 367a53ea10c5714de719888a5ed12de83c97bc87..f171a6600fbcac6424376d65aeb35424d57e2b6e 100644 (file)
@@ -9,12 +9,12 @@ extern void cris_spin_unlock(void *l, int val);
 extern void cris_spin_lock(void *l);
 extern int cris_spin_trylock(void *l);
 
-static inline int __raw_spin_is_locked(raw_spinlock_t *x)
+static inline int arch_spin_is_locked(arch_spinlock_t *x)
 {
        return *(volatile signed char *)(&(x)->slock) <= 0;
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        __asm__ volatile ("move.d %1,%0" \
                          : "=m" (lock->slock) \
@@ -22,26 +22,26 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
                          : "memory");
 }
 
-static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
+static inline void arch_spin_unlock_wait(arch_spinlock_t *lock)
 {
-       while (__raw_spin_is_locked(lock))
+       while (arch_spin_is_locked(lock))
                cpu_relax();
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        return cris_spin_trylock((void *)&lock->slock);
 }
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        cris_spin_lock((void *)&lock->slock);
 }
 
 static inline void
-__raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
+arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
 {
-       __raw_spin_lock(lock);
+       arch_spin_lock(lock);
 }
 
 /*
@@ -56,76 +56,76 @@ __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
  *
  */
 
-static inline int __raw_read_can_lock(raw_rwlock_t *x)
+static inline int arch_read_can_lock(arch_rwlock_t *x)
 {
        return (int)(x)->lock > 0;
 }
 
-static inline int __raw_write_can_lock(raw_rwlock_t *x)
+static inline int arch_write_can_lock(arch_rwlock_t *x)
 {
        return (x)->lock == RW_LOCK_BIAS;
 }
 
-static  inline void __raw_read_lock(raw_rwlock_t *rw)
+static  inline void arch_read_lock(arch_rwlock_t *rw)
 {
-       __raw_spin_lock(&rw->slock);
+       arch_spin_lock(&rw->slock);
        while (rw->lock == 0);
        rw->lock--;
-       __raw_spin_unlock(&rw->slock);
+       arch_spin_unlock(&rw->slock);
 }
 
-static  inline void __raw_write_lock(raw_rwlock_t *rw)
+static  inline void arch_write_lock(arch_rwlock_t *rw)
 {
-       __raw_spin_lock(&rw->slock);
+       arch_spin_lock(&rw->slock);
        while (rw->lock != RW_LOCK_BIAS);
        rw->lock = 0;
-       __raw_spin_unlock(&rw->slock);
+       arch_spin_unlock(&rw->slock);
 }
 
-static  inline void __raw_read_unlock(raw_rwlock_t *rw)
+static  inline void arch_read_unlock(arch_rwlock_t *rw)
 {
-       __raw_spin_lock(&rw->slock);
+       arch_spin_lock(&rw->slock);
        rw->lock++;
-       __raw_spin_unlock(&rw->slock);
+       arch_spin_unlock(&rw->slock);
 }
 
-static  inline void __raw_write_unlock(raw_rwlock_t *rw)
+static  inline void arch_write_unlock(arch_rwlock_t *rw)
 {
-       __raw_spin_lock(&rw->slock);
+       arch_spin_lock(&rw->slock);
        while (rw->lock != RW_LOCK_BIAS);
        rw->lock = RW_LOCK_BIAS;
-       __raw_spin_unlock(&rw->slock);
+       arch_spin_unlock(&rw->slock);
 }
 
-static  inline int __raw_read_trylock(raw_rwlock_t *rw)
+static  inline int arch_read_trylock(arch_rwlock_t *rw)
 {
        int ret = 0;
-       __raw_spin_lock(&rw->slock);
+       arch_spin_lock(&rw->slock);
        if (rw->lock != 0) {
                rw->lock--;
                ret = 1;
        }
-       __raw_spin_unlock(&rw->slock);
+       arch_spin_unlock(&rw->slock);
        return ret;
 }
 
-static  inline int __raw_write_trylock(raw_rwlock_t *rw)
+static  inline int arch_write_trylock(arch_rwlock_t *rw)
 {
        int ret = 0;
-       __raw_spin_lock(&rw->slock);
+       arch_spin_lock(&rw->slock);
        if (rw->lock == RW_LOCK_BIAS) {
                rw->lock = 0;
                ret = 1;
        }
-       __raw_spin_unlock(&rw->slock);
+       arch_spin_unlock(&rw->slock);
        return 1;
 }
 
 #define _raw_read_lock_flags(lock, flags) _raw_read_lock(lock)
 #define _raw_write_lock_flags(lock, flags) _raw_write_lock(lock)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* __ASM_ARCH_SPINLOCK_H */
diff --git a/arch/cris/include/asm/asm-offsets.h b/arch/cris/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 0f51b10b9f4f39b397f5615377e229268a13df9e..8a3d8e2b33c1e41c384255ecb764cee17af4a3c4 100644 (file)
@@ -64,8 +64,6 @@ typedef unsigned long elf_fpregset_t;
 #define EF_CRIS_VARIANT_COMMON_V10_V32 0x00000004
 /* End of excerpt from {binutils}/include/elf/cris.h.  */
 
-#define USE_ELF_CORE_DUMP
-
 #define ELF_EXEC_PAGESIZE      8192
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
index ddd6fbbe75de61123abcae19978faaaae4ec7be6..dd7b8e983221e50104360d3ff11db0391625a77b 100644 (file)
@@ -1,6 +1,5 @@
 #include <linux/sched.h>
 #include <asm/thread_info.h>
-#include <linux/autoconf.h>
 
 /*
  * Generate definitions needed by assembly language modules.
index 0ca7d9892cc6d6c5c7bb5f249a5a5151289b980b..b5ce0724a88f6f307292f46601a564f022ddaf2c 100644 (file)
@@ -52,7 +52,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -71,7 +71,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        }
        return 0;
 }
index bbfda67d2907009c34af0d1b3f3ecd35ec03e47e..d49d17d2a14f5a36be1e4da6670897734565b4b8 100644 (file)
@@ -8,7 +8,6 @@
  * the kernel has booted.
  */
 
-#include <linux/autoconf.h>
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/page.h>
 
diff --git a/arch/frv/include/asm/asm-offsets.h b/arch/frv/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 7bbf6e47f8c8a5cb216c9b8f5e0b8be3b902c5bb..c3819804a74b104765c60a16051ffeea4063cbb1 100644 (file)
@@ -115,7 +115,6 @@ do {                                                                                        \
        __kernel_frame0_ptr->gr29       = 0;                                            \
 } while(0)
 
-#define USE_ELF_CORE_DUMP
 #define CORE_DUMP_USE_REGSET
 #define ELF_FDPIC_CORE_EFLAGS  EF_FRV_FDPIC
 #define ELF_EXEC_PAGESIZE      16384
index af3e824b91b3027afb72a0fa9f455150d3599421..62d1aba615dc707edeb0784deb4466d239e53822 100644 (file)
@@ -69,7 +69,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (action) {
                        seq_printf(p, "%3d: ", i);
@@ -85,7 +85,7 @@ int show_interrupts(struct seq_file *p, void *v)
                        seq_putc(p, '\n');
                }
 
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        } else if (i == NR_IRQS) {
                seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count));
        }
index 55e4fab7c0bc7f3929729e8a20a07a0b8be80bd5..75cf7f4b2fa81d8e0bd18cf6d0ff3ae4d64f8004 100644 (file)
@@ -10,7 +10,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
index 9420648352b8bc7783594c2177e14da2443aaf45..53cc669e6d591e94891753fcd375e47fe5e9173b 100644 (file)
@@ -10,6 +10,10 @@ config H8300
        default y
        select HAVE_IDE
 
+config SYMBOL_PREFIX
+       string
+       default "_"
+
 config MMU
        bool
        default n
diff --git a/arch/h8300/include/asm/asm-offsets.h b/arch/h8300/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 94e2284c88168fba8a42afc0008aa8cb1c53944e..c24fa250d6533cdb3a5429c102323ca19d356e0d 100644 (file)
@@ -34,7 +34,6 @@ typedef unsigned long elf_fpregset_t;
 
 #define ELF_PLAT_INIT(_r)      _r->er1 = 0
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      4096
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
index de23231f31962e0e79ac5d0d356e47156719e2a2..8e46724b7c09a92f26c36dabb3fc2285a9ee428b 100644 (file)
@@ -8,6 +8,4 @@ struct mod_arch_specific { };
 #define Elf_Sym Elf32_Sym
 #define Elf_Ehdr Elf32_Ehdr
 
-#define MODULE_SYMBOL_PREFIX "_"
-
 #endif /* _ASM_H8/300_MODULE_H */
index 5c913d472119dadf9c3fad5749223901ec3a0fd7..c25dc2c2b1da7d48ae6c4dae9d7c1a6172a88687 100644 (file)
@@ -186,7 +186,7 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_puts(p, "           CPU0");
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto unlock;
@@ -200,7 +200,7 @@ int show_interrupts(struct seq_file *p, void *v)
                        seq_printf(p, ", %s", action->name);
                seq_putc(p, '\n');
 unlock:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        }
        return 0;
 }
index b9e24907e6ea35422361d3ba119e4500c6c31ed4..03d356d96e5d30b066480ad8db2358f21dbccee5 100644 (file)
@@ -1,4 +1,3 @@
-#define VMLINUX_SYMBOL(_sym_) _##_sym_
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/page.h>
 
index e7cbaa02cd0b432fa99c43d0c8de742b2c11d485..475e2725fbde6feb6c9d64c024a52a2fd211af35 100644 (file)
@@ -103,4 +103,4 @@ archprepare: make_nr_irqs_h FORCE
 PHONY += make_nr_irqs_h FORCE
 
 make_nr_irqs_h: FORCE
-       $(Q)$(MAKE) $(build)=arch/ia64/kernel include/asm-ia64/nr-irqs.h
+       $(Q)$(MAKE) $(build)=arch/ia64/kernel include/generated/nr-irqs.h
index f332e3fe4237cfce182a45ae17e8fd5fc2a218e5..e14c492a8a9371488257d6b49758a615a034d557 100644 (file)
@@ -677,12 +677,19 @@ sba_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
                        spin_unlock_irqrestore(&ioc->saved_lock, flags);
 
                        pide = sba_search_bitmap(ioc, dev, pages_needed, 0);
-                       if (unlikely(pide >= (ioc->res_size << 3)))
-                               panic(__FILE__ ": I/O MMU @ %p is out of mapping resources\n",
-                                     ioc->ioc_hpa);
+                       if (unlikely(pide >= (ioc->res_size << 3))) {
+                               printk(KERN_WARNING "%s: I/O MMU @ %p is"
+                                      "out of mapping resources, %u %u %lx\n",
+                                      __func__, ioc->ioc_hpa, ioc->res_size,
+                                      pages_needed, dma_get_seg_boundary(dev));
+                               return -1;
+                       }
 #else
-                       panic(__FILE__ ": I/O MMU @ %p is out of mapping resources\n",
-                             ioc->ioc_hpa);
+                       printk(KERN_WARNING "%s: I/O MMU @ %p is"
+                              "out of mapping resources, %u %u %lx\n",
+                              __func__, ioc->ioc_hpa, ioc->res_size,
+                              pages_needed, dma_get_seg_boundary(dev));
+                       return -1;
 #endif
                }
        }
@@ -965,6 +972,8 @@ static dma_addr_t sba_map_page(struct device *dev, struct page *page,
 #endif
 
        pide = sba_alloc_range(ioc, dev, size);
+       if (pide < 0)
+               return 0;
 
        iovp = (dma_addr_t) pide << iovp_shift;
 
@@ -1320,6 +1329,7 @@ sba_coalesce_chunks(struct ioc *ioc, struct device *dev,
        unsigned long dma_offset, dma_len; /* start/len of DMA stream */
        int n_mappings = 0;
        unsigned int max_seg_size = dma_get_max_seg_size(dev);
+       int idx;
 
        while (nents > 0) {
                unsigned long vaddr = (unsigned long) sba_sg_address(startsg);
@@ -1418,16 +1428,22 @@ sba_coalesce_chunks(struct ioc *ioc, struct device *dev,
                vcontig_sg->dma_length = vcontig_len;
                dma_len = (dma_len + dma_offset + ~iovp_mask) & iovp_mask;
                ASSERT(dma_len <= DMA_CHUNK_SIZE);
-               dma_sg->dma_address = (dma_addr_t) (PIDE_FLAG
-                       | (sba_alloc_range(ioc, dev, dma_len) << iovp_shift)
-                       | dma_offset);
+               idx = sba_alloc_range(ioc, dev, dma_len);
+               if (idx < 0) {
+                       dma_sg->dma_length = 0;
+                       return -1;
+               }
+               dma_sg->dma_address = (dma_addr_t)(PIDE_FLAG | (idx << iovp_shift)
+                                                  | dma_offset);
                n_mappings++;
        }
 
        return n_mappings;
 }
 
-
+static void sba_unmap_sg_attrs(struct device *dev, struct scatterlist *sglist,
+                              int nents, enum dma_data_direction dir,
+                              struct dma_attrs *attrs);
 /**
  * sba_map_sg - map Scatter/Gather list
  * @dev: instance of PCI owned by the driver that's asking.
@@ -1493,6 +1509,10 @@ static int sba_map_sg_attrs(struct device *dev, struct scatterlist *sglist,
        ** Access to the virtual address is what forces a two pass algorithm.
        */
        coalesced = sba_coalesce_chunks(ioc, dev, sglist, nents);
+       if (coalesced < 0) {
+               sba_unmap_sg_attrs(dev, sglist, nents, dir, attrs);
+               return 0;
+       }
 
        /*
        ** Program the I/O Pdir
index 9a3abf58cea34580edc399f25d6d2750198214f7..6577257426176a4163db634bb7d4b4643a6203db 100644 (file)
@@ -11,8 +11,6 @@
 #include <asm/intrinsics.h>
 #include <asm/uaccess.h>
 
-#define USE_ELF_CORE_DUMP 1
-
 /* Override elfcore.h */
 #define _LINUX_ELFCORE_H 1
 typedef unsigned int elf_greg_t;
index 91df9686a0da88ac8b299ddf81c0ca697d3f075d..7ae58892ba8d87ee699925380bcd92d59eca06ff 100644 (file)
@@ -132,6 +132,12 @@ extern int __devinitdata pxm_to_nid_map[MAX_PXM_DOMAINS];
 extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
 #endif
 
+static inline bool arch_has_acpi_pdc(void) { return true; }
+static inline void arch_acpi_set_pdc_bits(u32 *buf)
+{
+       buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
+}
+
 #define acpi_unlazy_tlb(x)
 
 #ifdef CONFIG_ACPI_NUMA
diff --git a/arch/ia64/include/asm/asm-offsets.h b/arch/ia64/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 57a2787bc9fb62e6d5cadc62a2bc394e78cca707..6ebc229a1c51fe97b4055e32ef89b09b39678f39 100644 (file)
@@ -127,7 +127,7 @@ clear_bit_unlock (int nr, volatile void *addr)
  * @addr: Address to start counting from
  *
  * Similarly to clear_bit_unlock, the implementation uses a store
- * with release semantics. See also __raw_spin_unlock().
+ * with release semantics. See also arch_spin_unlock().
  */
 static __inline__ void
 __clear_bit_unlock(int nr, void *addr)
index 8d3c79cd81e7982f1ad5c3b9875bf302bd3731ab..7d09a09cdaadf5b1f26b8bf5009b71b986d61406 100644 (file)
@@ -73,7 +73,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
        if (!dev->dma_mask)
                return 0;
 
-       return addr + size <= *dev->dma_mask;
+       return addr + size - 1 <= *dev->dma_mask;
 }
 
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
index 86eddee029cb5238c00d4de2ef1c432f37e97e6d..e14108b19c091a654eb2a28cbf45ff104efa5ace 100644 (file)
@@ -25,7 +25,6 @@
 #define ELF_DATA       ELFDATA2LSB
 #define ELF_ARCH       EM_IA_64
 
-#define USE_ELF_CORE_DUMP
 #define CORE_DUMP_USE_REGSET
 
 /* Least-significant four bits of ELF header's e_flags are OS-specific.  The bits are
index 91619b31dbf5f45221cebd092d738426dfbd4da2..bf2e37493e04c6b28544779377cc72d8ce21a2e2 100644 (file)
@@ -59,7 +59,13 @@ typedef u16 ia64_vector;
 extern int ia64_first_device_vector;
 extern int ia64_last_device_vector;
 
+#if defined(CONFIG_SMP) && (defined(CONFIG_IA64_GENERIC) || defined (CONFIG_IA64_DIG))
+/* Reserve the lower priority vector than device vectors for "move IRQ" IPI */
+#define IA64_IRQ_MOVE_VECTOR           0x30    /* "move IRQ" IPI */
+#define IA64_DEF_FIRST_DEVICE_VECTOR   0x31
+#else
 #define IA64_DEF_FIRST_DEVICE_VECTOR   0x30
+#endif
 #define IA64_DEF_LAST_DEVICE_VECTOR    0xe7
 #define IA64_FIRST_DEVICE_VECTOR       ia64_first_device_vector
 #define IA64_LAST_DEVICE_VECTOR                ia64_last_device_vector
index 0d9d16e2d94906345ecef8ac22b2dfd5ed20836c..cc8335eb3110f257fb64bbd19dc202156d904a83 100644 (file)
@@ -424,6 +424,8 @@ __writeq (unsigned long val, volatile void __iomem *addr)
 extern void __iomem * ioremap(unsigned long offset, unsigned long size);
 extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size);
 extern void iounmap (volatile void __iomem *addr);
+extern void __iomem * early_ioremap (unsigned long phys_addr, unsigned long size);
+extern void early_iounmap (volatile void __iomem *addr, unsigned long size);
 
 /*
  * String version of IO memory access ops:
index 5282546cdf8201d460645ee70bad4e13f4066e21..91b920fd7d534099073c1ca44c69938cc445c9d4 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <linux/types.h>
 #include <linux/cpumask.h>
-#include <asm-ia64/nr-irqs.h>
+#include <generated/nr-irqs.h>
 
 static __inline__ int
 irq_canonicalize (int irq)
index c171cdf0a789514985b8597dff7cde5969481d82..43f96ab18fa0d2754ff5f79374c02e785ec24347 100644 (file)
@@ -106,6 +106,11 @@ struct ia64_sal_os_state {
        unsigned long           os_status;              /* OS status to SAL, enum below */
        unsigned long           context;                /* 0 if return to same context
                                                           1 if return to new context */
+
+       /* I-resources */
+       unsigned long           iip;
+       unsigned long           ipsr;
+       unsigned long           ifs;
 };
 
 enum {
index 3499ff57bf425db6544e9bf60f31a334d4aaa4a3..6a8a27cfae3e04f0f35771aa9490ff3b46e8729d 100644 (file)
@@ -22,8 +22,6 @@
 
 #include <asm/mmzone.h>
 
-#define NUMA_NO_NODE   -1
-
 extern u16 cpu_to_node_map[NR_CPUS] __cacheline_aligned;
 extern cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
 extern pg_data_t *pgdat_list[MAX_NUMNODES];
index fbee74b15782752b04754c2999d6f0d149e4fbb8..e8762688e8e3be5a17b90667130f47a041e9d669 100644 (file)
@@ -47,7 +47,7 @@ struct rw_semaphore {
 #define RWSEM_ACTIVE_WRITE_BIAS                (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
 
 #define __RWSEM_INITIALIZER(name) \
-       { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \
+       { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \
          LIST_HEAD_INIT((name).wait_list) }
 
 #define DECLARE_RWSEM(name) \
index 239ecdc9516d042e69fc5b1773cfa2fb29fcad4a..1a91c9121d17b5f032b192905370a69d7d24bee8 100644 (file)
@@ -17,7 +17,7 @@
 #include <asm/intrinsics.h>
 #include <asm/system.h>
 
-#define __raw_spin_lock_init(x)                        ((x)->lock = 0)
+#define arch_spin_lock_init(x)                 ((x)->lock = 0)
 
 /*
  * Ticket locks are conceptually two parts, one indicating the current head of
@@ -38,7 +38,7 @@
 #define TICKET_BITS    15
 #define        TICKET_MASK     ((1 << TICKET_BITS) - 1)
 
-static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
+static __always_inline void __ticket_spin_lock(arch_spinlock_t *lock)
 {
        int     *p = (int *)&lock->lock, ticket, serve;
 
@@ -58,7 +58,7 @@ static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
        }
 }
 
-static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
+static __always_inline int __ticket_spin_trylock(arch_spinlock_t *lock)
 {
        int tmp = ACCESS_ONCE(lock->lock);
 
@@ -67,7 +67,7 @@ static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
        return 0;
 }
 
-static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock)
+static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
 {
        unsigned short  *p = (unsigned short *)&lock->lock + 1, tmp;
 
@@ -75,7 +75,7 @@ static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock)
        ACCESS_ONCE(*p) = (tmp + 2) & ~1;
 }
 
-static __always_inline void __ticket_spin_unlock_wait(raw_spinlock_t *lock)
+static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
 {
        int     *p = (int *)&lock->lock, ticket;
 
@@ -89,64 +89,64 @@ static __always_inline void __ticket_spin_unlock_wait(raw_spinlock_t *lock)
        }
 }
 
-static inline int __ticket_spin_is_locked(raw_spinlock_t *lock)
+static inline int __ticket_spin_is_locked(arch_spinlock_t *lock)
 {
        long tmp = ACCESS_ONCE(lock->lock);
 
        return !!(((tmp >> TICKET_SHIFT) ^ tmp) & TICKET_MASK);
 }
 
-static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
+static inline int __ticket_spin_is_contended(arch_spinlock_t *lock)
 {
        long tmp = ACCESS_ONCE(lock->lock);
 
        return ((tmp - (tmp >> TICKET_SHIFT)) & TICKET_MASK) > 1;
 }
 
-static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
+static inline int arch_spin_is_locked(arch_spinlock_t *lock)
 {
        return __ticket_spin_is_locked(lock);
 }
 
-static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
+static inline int arch_spin_is_contended(arch_spinlock_t *lock)
 {
        return __ticket_spin_is_contended(lock);
 }
-#define __raw_spin_is_contended        __raw_spin_is_contended
+#define arch_spin_is_contended arch_spin_is_contended
 
-static __always_inline void __raw_spin_lock(raw_spinlock_t *lock)
+static __always_inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        __ticket_spin_lock(lock);
 }
 
-static __always_inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static __always_inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        return __ticket_spin_trylock(lock);
 }
 
-static __always_inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static __always_inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        __ticket_spin_unlock(lock);
 }
 
-static __always_inline void __raw_spin_lock_flags(raw_spinlock_t *lock,
+static __always_inline void arch_spin_lock_flags(arch_spinlock_t *lock,
                                                  unsigned long flags)
 {
-       __raw_spin_lock(lock);
+       arch_spin_lock(lock);
 }
 
-static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
+static inline void arch_spin_unlock_wait(arch_spinlock_t *lock)
 {
        __ticket_spin_unlock_wait(lock);
 }
 
-#define __raw_read_can_lock(rw)                (*(volatile int *)(rw) >= 0)
-#define __raw_write_can_lock(rw)       (*(volatile int *)(rw) == 0)
+#define arch_read_can_lock(rw)         (*(volatile int *)(rw) >= 0)
+#define arch_write_can_lock(rw)        (*(volatile int *)(rw) == 0)
 
 #ifdef ASM_SUPPORTED
 
 static __always_inline void
-__raw_read_lock_flags(raw_rwlock_t *lock, unsigned long flags)
+arch_read_lock_flags(arch_rwlock_t *lock, unsigned long flags)
 {
        __asm__ __volatile__ (
                "tbit.nz p6, p0 = %1,%2\n"
@@ -169,15 +169,15 @@ __raw_read_lock_flags(raw_rwlock_t *lock, unsigned long flags)
                : "p6", "p7", "r2", "memory");
 }
 
-#define __raw_read_lock(lock) __raw_read_lock_flags(lock, 0)
+#define arch_read_lock(lock) arch_read_lock_flags(lock, 0)
 
 #else /* !ASM_SUPPORTED */
 
-#define __raw_read_lock_flags(rw, flags) __raw_read_lock(rw)
+#define arch_read_lock_flags(rw, flags) arch_read_lock(rw)
 
-#define __raw_read_lock(rw)                                                            \
+#define arch_read_lock(rw)                                                             \
 do {                                                                                   \
-       raw_rwlock_t *__read_lock_ptr = (rw);                                           \
+       arch_rwlock_t *__read_lock_ptr = (rw);                                          \
                                                                                        \
        while (unlikely(ia64_fetchadd(1, (int *) __read_lock_ptr, acq) < 0)) {          \
                ia64_fetchadd(-1, (int *) __read_lock_ptr, rel);                        \
@@ -188,16 +188,16 @@ do {                                                                                      \
 
 #endif /* !ASM_SUPPORTED */
 
-#define __raw_read_unlock(rw)                                  \
+#define arch_read_unlock(rw)                                   \
 do {                                                           \
-       raw_rwlock_t *__read_lock_ptr = (rw);                   \
+       arch_rwlock_t *__read_lock_ptr = (rw);                  \
        ia64_fetchadd(-1, (int *) __read_lock_ptr, rel);        \
 } while (0)
 
 #ifdef ASM_SUPPORTED
 
 static __always_inline void
-__raw_write_lock_flags(raw_rwlock_t *lock, unsigned long flags)
+arch_write_lock_flags(arch_rwlock_t *lock, unsigned long flags)
 {
        __asm__ __volatile__ (
                "tbit.nz p6, p0 = %1, %2\n"
@@ -221,9 +221,9 @@ __raw_write_lock_flags(raw_rwlock_t *lock, unsigned long flags)
                : "ar.ccv", "p6", "p7", "r2", "r29", "memory");
 }
 
-#define __raw_write_lock(rw) __raw_write_lock_flags(rw, 0)
+#define arch_write_lock(rw) arch_write_lock_flags(rw, 0)
 
-#define __raw_write_trylock(rw)                                                        \
+#define arch_write_trylock(rw)                                                 \
 ({                                                                             \
        register long result;                                                   \
                                                                                \
@@ -235,7 +235,7 @@ __raw_write_lock_flags(raw_rwlock_t *lock, unsigned long flags)
        (result == 0);                                                          \
 })
 
-static inline void __raw_write_unlock(raw_rwlock_t *x)
+static inline void arch_write_unlock(arch_rwlock_t *x)
 {
        u8 *y = (u8 *)x;
        barrier();
@@ -244,9 +244,9 @@ static inline void __raw_write_unlock(raw_rwlock_t *x)
 
 #else /* !ASM_SUPPORTED */
 
-#define __raw_write_lock_flags(l, flags) __raw_write_lock(l)
+#define arch_write_lock_flags(l, flags) arch_write_lock(l)
 
-#define __raw_write_lock(l)                                                            \
+#define arch_write_lock(l)                                                             \
 ({                                                                                     \
        __u64 ia64_val, ia64_set_val = ia64_dep_mi(-1, 0, 31, 1);                       \
        __u32 *ia64_write_lock_ptr = (__u32 *) (l);                                     \
@@ -257,7 +257,7 @@ static inline void __raw_write_unlock(raw_rwlock_t *x)
        } while (ia64_val);                                                             \
 })
 
-#define __raw_write_trylock(rw)                                                \
+#define arch_write_trylock(rw)                                         \
 ({                                                                     \
        __u64 ia64_val;                                                 \
        __u64 ia64_set_val = ia64_dep_mi(-1, 0, 31,1);                  \
@@ -265,7 +265,7 @@ static inline void __raw_write_unlock(raw_rwlock_t *x)
        (ia64_val == 0);                                                \
 })
 
-static inline void __raw_write_unlock(raw_rwlock_t *x)
+static inline void arch_write_unlock(arch_rwlock_t *x)
 {
        barrier();
        x->write_lock = 0;
@@ -273,10 +273,10 @@ static inline void __raw_write_unlock(raw_rwlock_t *x)
 
 #endif /* !ASM_SUPPORTED */
 
-static inline int __raw_read_trylock(raw_rwlock_t *x)
+static inline int arch_read_trylock(arch_rwlock_t *x)
 {
        union {
-               raw_rwlock_t lock;
+               arch_rwlock_t lock;
                __u32 word;
        } old, new;
        old.lock = new.lock = *x;
@@ -285,8 +285,8 @@ static inline int __raw_read_trylock(raw_rwlock_t *x)
        return (u32)ia64_cmpxchg4_acq((__u32 *)(x), new.word, old.word) == old.word;
 }
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /*  _ASM_IA64_SPINLOCK_H */
index 474e46f1ab4a0a19527ecb2b2a32b05d520a1400..e2b42a52a6d3f266f00355691d43d9d67c6ab5e2 100644 (file)
@@ -7,15 +7,15 @@
 
 typedef struct {
        volatile unsigned int lock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        volatile unsigned int read_counter      : 31;
        volatile unsigned int write_lock        :  1;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { 0, 0 }
+#define __ARCH_RW_LOCK_UNLOCKED                { 0, 0 }
 
 #endif
index 6b7edcab0cb52ee24b8852b067f881b05ddf5d1e..e1236349c99fa3dd8ae7e0686425e77e9b4b0a30 100644 (file)
@@ -18,10 +18,6 @@ obj-$(CONFIG_IA64_GENERIC)   += acpi-ext.o
 obj-$(CONFIG_IA64_HP_ZX1)      += acpi-ext.o
 obj-$(CONFIG_IA64_HP_ZX1_SWIOTLB) += acpi-ext.o
 
-ifneq ($(CONFIG_ACPI_PROCESSOR),)
-obj-y                          += acpi-processor.o
-endif
-
 obj-$(CONFIG_IA64_PALINFO)     += palinfo.o
 obj-$(CONFIG_IOSAPIC)          += iosapic.o
 obj-$(CONFIG_MODULES)          += module.o
@@ -81,17 +77,14 @@ define cmd_nr_irqs
 endef
 
 # We use internal kbuild rules to avoid the "is up to date" message from make
-arch/$(SRCARCH)/kernel/nr-irqs.s: $(srctree)/arch/$(SRCARCH)/kernel/nr-irqs.c \
-                               $(wildcard $(srctree)/include/asm-ia64/*/irq.h)
+arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c
        $(Q)mkdir -p $(dir $@)
        $(call if_changed_dep,cc_s_c)
 
-include/asm-ia64/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s
+include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s
        $(Q)mkdir -p $(dir $@)
        $(call cmd,nr_irqs)
 
-clean-files += $(objtree)/include/asm-ia64/nr-irqs.h
-
 #
 # native ivt.S, entry.S and fsys.S
 #
diff --git a/arch/ia64/kernel/acpi-processor.c b/arch/ia64/kernel/acpi-processor.c
deleted file mode 100644 (file)
index dbda7bd..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * arch/ia64/kernel/acpi-processor.c
- *
- * Copyright (C) 2005 Intel Corporation
- *     Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
- *     - Added _PDC for platforms with Intel CPUs
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/acpi.h>
-
-#include <acpi/processor.h>
-#include <asm/acpi.h>
-
-static void init_intel_pdc(struct acpi_processor *pr)
-{
-       struct acpi_object_list *obj_list;
-       union acpi_object *obj;
-       u32 *buf;
-
-       /* allocate and initialize pdc. It will be used later. */
-       obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
-       if (!obj_list) {
-               printk(KERN_ERR "Memory allocation error\n");
-               return;
-       }
-
-       obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
-       if (!obj) {
-               printk(KERN_ERR "Memory allocation error\n");
-               kfree(obj_list);
-               return;
-       }
-
-       buf = kmalloc(12, GFP_KERNEL);
-       if (!buf) {
-               printk(KERN_ERR "Memory allocation error\n");
-               kfree(obj);
-               kfree(obj_list);
-               return;
-       }
-
-       buf[0] = ACPI_PDC_REVISION_ID;
-       buf[1] = 1;
-       buf[2] = ACPI_PDC_EST_CAPABILITY_SMP;
-       /*
-        * The default of PDC_SMP_T_SWCOORD bit is set for IA64 cpu so
-        * that OSPM is capable of native ACPI throttling software
-        * coordination using BIOS supplied _TSD info.
-        */
-       buf[2] |= ACPI_PDC_SMP_T_SWCOORD;
-
-       obj->type = ACPI_TYPE_BUFFER;
-       obj->buffer.length = 12;
-       obj->buffer.pointer = (u8 *) buf;
-       obj_list->count = 1;
-       obj_list->pointer = obj;
-       pr->pdc = obj_list;
-
-       return;
-}
-
-/* Initialize _PDC data based on the CPU vendor */
-void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
-{
-       pr->pdc = NULL;
-       init_intel_pdc(pr);
-       return;
-}
-
-EXPORT_SYMBOL(arch_acpi_processor_init_pdc);
-
-void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr)
-{
-       if (pr->pdc) {
-               kfree(pr->pdc->pointer->buffer.pointer);
-               kfree(pr->pdc->pointer);
-               kfree(pr->pdc);
-               pr->pdc = NULL;
-       }
-}
-
-EXPORT_SYMBOL(arch_acpi_processor_cleanup_pdc);
index dab4d393908c6323279ea61e1443f0e31961834f..95ac77aeae9b8fc2194e25e4c7f0fef05f5bc887 100644 (file)
@@ -793,12 +793,12 @@ iosapic_register_intr (unsigned int gsi,
                        goto unlock_iosapic_lock;
        }
 
-       spin_lock(&irq_desc[irq].lock);
+       raw_spin_lock(&irq_desc[irq].lock);
        dest = get_target_cpu(gsi, irq);
        dmode = choose_dmode();
        err = register_intr(gsi, irq, dmode, polarity, trigger);
        if (err < 0) {
-               spin_unlock(&irq_desc[irq].lock);
+               raw_spin_unlock(&irq_desc[irq].lock);
                irq = err;
                goto unlock_iosapic_lock;
        }
@@ -817,7 +817,7 @@ iosapic_register_intr (unsigned int gsi,
               (polarity == IOSAPIC_POL_HIGH ? "high" : "low"),
               cpu_logical_id(dest), dest, irq_to_vector(irq));
 
-       spin_unlock(&irq_desc[irq].lock);
+       raw_spin_unlock(&irq_desc[irq].lock);
  unlock_iosapic_lock:
        spin_unlock_irqrestore(&iosapic_lock, flags);
        return irq;
index 7d8951229e7c39f39fd333a518d4a7e633725a70..94ee9d067cbd31671ccc86a239a4dc653bad5c9a 100644 (file)
@@ -71,7 +71,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -91,7 +91,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        } else if (i == NR_IRQS)
                seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
        return 0;
index dd9d7b54f1a1f59f0a04a10a3ad6386d94f16472..d4093a173a3ec29e7d927f1f9b1dd080c3b89af9 100644 (file)
@@ -260,7 +260,6 @@ void __setup_vector_irq(int cpu)
 }
 
 #if defined(CONFIG_SMP) && (defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG))
-#define IA64_IRQ_MOVE_VECTOR   IA64_DEF_FIRST_DEVICE_VECTOR
 
 static enum vector_domain_type {
        VECTOR_DOMAIN_NONE,
@@ -345,7 +344,7 @@ static irqreturn_t smp_irq_move_cleanup_interrupt(int irq, void *dev_id)
 
                desc = irq_desc + irq;
                cfg = irq_cfg + irq;
-               spin_lock(&desc->lock);
+               raw_spin_lock(&desc->lock);
                if (!cfg->move_cleanup_count)
                        goto unlock;
 
@@ -358,7 +357,7 @@ static irqreturn_t smp_irq_move_cleanup_interrupt(int irq, void *dev_id)
                spin_unlock_irqrestore(&vector_lock, flags);
                cfg->move_cleanup_count--;
        unlock:
-               spin_unlock(&desc->lock);
+               raw_spin_unlock(&desc->lock);
        }
        return IRQ_HANDLED;
 }
@@ -659,11 +658,8 @@ init_IRQ (void)
        register_percpu_irq(IA64_SPURIOUS_INT_VECTOR, NULL);
 #ifdef CONFIG_SMP
 #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_DIG)
-       if (vector_domain_type != VECTOR_DOMAIN_NONE) {
-               BUG_ON(IA64_FIRST_DEVICE_VECTOR != IA64_IRQ_MOVE_VECTOR);
-               IA64_FIRST_DEVICE_VECTOR++;
+       if (vector_domain_type != VECTOR_DOMAIN_NONE)
                register_percpu_irq(IA64_IRQ_MOVE_VECTOR, &irq_move_irqaction);
-       }
 #endif
 #endif
 #ifdef CONFIG_PERFMON
index 496ac7a99488cdc5721a2bedf378e2e5d6a9c60e..32f2639e9b0af540948a85ceb9878d33efd866c8 100644 (file)
@@ -888,9 +888,10 @@ ia64_mca_modify_comm(const struct task_struct *previous_current)
 }
 
 static void
-finish_pt_regs(struct pt_regs *regs, const pal_min_state_area_t *ms,
+finish_pt_regs(struct pt_regs *regs, struct ia64_sal_os_state *sos,
                unsigned long *nat)
 {
+       const pal_min_state_area_t *ms = sos->pal_min_state;
        const u64 *bank;
 
        /* If ipsr.ic then use pmsa_{iip,ipsr,ifs}, else use
@@ -904,6 +905,10 @@ finish_pt_regs(struct pt_regs *regs, const pal_min_state_area_t *ms,
                regs->cr_iip = ms->pmsa_xip;
                regs->cr_ipsr = ms->pmsa_xpsr;
                regs->cr_ifs = ms->pmsa_xfs;
+
+               sos->iip = ms->pmsa_iip;
+               sos->ipsr = ms->pmsa_ipsr;
+               sos->ifs = ms->pmsa_ifs;
        }
        regs->pr = ms->pmsa_pr;
        regs->b0 = ms->pmsa_br0;
@@ -1079,7 +1084,7 @@ ia64_mca_modify_original_stack(struct pt_regs *regs,
        memcpy(old_regs, regs, sizeof(*regs));
        old_regs->loadrs = loadrs;
        old_unat = old_regs->ar_unat;
-       finish_pt_regs(old_regs, ms, &old_unat);
+       finish_pt_regs(old_regs, sos, &old_unat);
 
        /* Next stack a struct switch_stack.  mca_asm.S built a partial
         * switch_stack, copy it and fill in the blanks using pt_regs and
@@ -1150,7 +1155,7 @@ no_mod:
        mprintk(KERN_INFO "cpu %d, %s %s, original stack not modified\n",
                        smp_processor_id(), type, msg);
        old_unat = regs->ar_unat;
-       finish_pt_regs(regs, ms, &old_unat);
+       finish_pt_regs(regs, sos, &old_unat);
        return previous_current;
 }
 
index 599b233bef7514500a3daf8782a0f339dacce974..5246285a95fb253187c774093743df35b76239aa 100644 (file)
@@ -2200,7 +2200,7 @@ pfm_alloc_file(pfm_context_t *ctx)
 {
        struct file *file;
        struct inode *inode;
-       struct dentry *dentry;
+       struct path path;
        char name[32];
        struct qstr this;
 
@@ -2225,18 +2225,19 @@ pfm_alloc_file(pfm_context_t *ctx)
        /*
         * allocate a new dcache entry
         */
-       dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this);
-       if (!dentry) {
+       path.dentry = d_alloc(pfmfs_mnt->mnt_sb->s_root, &this);
+       if (!path.dentry) {
                iput(inode);
                return ERR_PTR(-ENOMEM);
        }
+       path.mnt = mntget(pfmfs_mnt);
 
-       dentry->d_op = &pfmfs_dentry_operations;
-       d_add(dentry, inode);
+       path.dentry->d_op = &pfmfs_dentry_operations;
+       d_add(path.dentry, inode);
 
-       file = alloc_file(pfmfs_mnt, dentry, FMODE_READ, &pfm_file_ops);
+       file = alloc_file(&path, FMODE_READ, &pfm_file_ops);
        if (!file) {
-               dput(dentry);
+               path_put(&path);
                return ERR_PTR(-ENFILE);
        }
 
index 0c3564a7a033a25b2df4996c3b7f14169dcc8064..9324c875caf534e2e9908c618188d0a863cd5e9b 100644 (file)
@@ -22,7 +22,6 @@
  *
  */
 
-#include <linux/autoconf.h>
 #include <linux/kvm_host.h>
 #include <linux/kbuild.h>
 
index 360724d3ae699d38681da70c1b750c6318f87a81..988911b4cc7abd9f0f60993ef5419b62d0ea062b 100644 (file)
@@ -388,6 +388,9 @@ static inline u64 __gpfn_is_io(u64 gpfn)
 #define _vmm_raw_spin_lock(x)   do {}while(0)
 #define _vmm_raw_spin_unlock(x) do {}while(0)
 #else
+typedef struct {
+       volatile unsigned int lock;
+} vmm_spinlock_t;
 #define _vmm_raw_spin_lock(x)                                          \
        do {                                                            \
                __u32 *ia64_spinlock_ptr = (__u32 *) (x);               \
@@ -405,12 +408,12 @@ static inline u64 __gpfn_is_io(u64 gpfn)
 
 #define _vmm_raw_spin_unlock(x)                                \
        do { barrier();                         \
-               ((spinlock_t *)x)->raw_lock.lock = 0; } \
+               ((vmm_spinlock_t *)x)->lock = 0; } \
 while (0)
 #endif
 
-void vmm_spin_lock(spinlock_t *lock);
-void vmm_spin_unlock(spinlock_t *lock);
+void vmm_spin_lock(vmm_spinlock_t *lock);
+void vmm_spin_unlock(vmm_spinlock_t *lock);
 enum {
        I_TLB = 1,
        D_TLB = 2
index f4b4c899bb6ce9d77d42d7a796931cb13e47ab03..7a62f75778c535f7421fc16ec4525407e3686e9b 100644 (file)
@@ -60,12 +60,12 @@ static void __exit kvm_vmm_exit(void)
        return ;
 }
 
-void vmm_spin_lock(spinlock_t *lock)
+void vmm_spin_lock(vmm_spinlock_t *lock)
 {
        _vmm_raw_spin_lock(lock);
 }
 
-void vmm_spin_unlock(spinlock_t *lock)
+void vmm_spin_unlock(vmm_spinlock_t *lock)
 {
        _vmm_raw_spin_unlock(lock);
 }
index 20b3852f7a6ec50d765fe3911fa0b6e6a0ef4859..4332f7ee5203f27179db08b5a95d372c6509e681 100644 (file)
@@ -182,7 +182,7 @@ void mark_pages_dirty(struct kvm_vcpu *v, u64 pte, u64 ps)
 {
        u64 i, dirty_pages = 1;
        u64 base_gfn = (pte&_PAGE_PPN_MASK) >> PAGE_SHIFT;
-       spinlock_t *lock = __kvm_va(v->arch.dirty_log_lock_pa);
+       vmm_spinlock_t *lock = __kvm_va(v->arch.dirty_log_lock_pa);
        void *dirty_bitmap = (void *)KVM_MEM_DIRTY_LOG_BASE;
 
        dirty_pages <<= ps <= PAGE_SHIFT ? 0 : ps - PAGE_SHIFT;
index 2a140627dfd6eefb06178cee86b87ef2282c11b1..3dccdd8eb275fd9c36c1e3105791a09f34e0a858 100644 (file)
@@ -21,6 +21,12 @@ __ioremap (unsigned long phys_addr)
        return (void __iomem *) (__IA64_UNCACHED_OFFSET | phys_addr);
 }
 
+void __iomem *
+early_ioremap (unsigned long phys_addr, unsigned long size)
+{
+       return __ioremap(phys_addr);
+}
+
 void __iomem *
 ioremap (unsigned long phys_addr, unsigned long size)
 {
@@ -101,6 +107,11 @@ ioremap_nocache (unsigned long phys_addr, unsigned long size)
 }
 EXPORT_SYMBOL(ioremap_nocache);
 
+void
+early_iounmap (volatile void __iomem *addr, unsigned long size)
+{
+}
+
 void
 iounmap (volatile void __iomem *addr)
 {
index 35b2a27d2e77055dd11b951fdd2b5dba149becfc..efb454534e525c2e9bbb76d4447dc2a97224332c 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/types.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/bitmap.h>
 #include <asm/sn/sn_sal.h>
 #include <asm/sn/addrs.h>
 #include <asm/sn/io.h>
@@ -369,7 +370,7 @@ tioca_dma_d48(struct pci_dev *pdev, u64 paddr)
 static dma_addr_t
 tioca_dma_mapped(struct pci_dev *pdev, unsigned long paddr, size_t req_size)
 {
-       int i, ps, ps_shift, entry, entries, mapsize, last_entry;
+       int ps, ps_shift, entry, entries, mapsize;
        u64 xio_addr, end_xio_addr;
        struct tioca_common *tioca_common;
        struct tioca_kernel *tioca_kern;
@@ -410,23 +411,13 @@ tioca_dma_mapped(struct pci_dev *pdev, unsigned long paddr, size_t req_size)
        map = tioca_kern->ca_pcigart_pagemap;
        mapsize = tioca_kern->ca_pcigart_entries;
 
-       entry = find_first_zero_bit(map, mapsize);
-       while (entry < mapsize) {
-               last_entry = find_next_bit(map, mapsize, entry);
-
-               if (last_entry - entry >= entries)
-                       break;
-
-               entry = find_next_zero_bit(map, mapsize, last_entry);
-       }
-
-       if (entry > mapsize) {
+       entry = bitmap_find_next_zero_area(map, mapsize, 0, entries, 0);
+       if (entry >= mapsize) {
                kfree(ca_dmamap);
                goto map_return;
        }
 
-       for (i = 0; i < entries; i++)
-               set_bit(entry + i, map);
+       bitmap_set(map, entry, entries);
 
        bus_addr = tioca_kern->ca_pciap_base + (entry * ps);
 
index 0cc34c94bf2bf26a087a73a11ea32302d48eebf6..2f85412ef7302a0aedaf1b5e26f63719c69dc033 100644 (file)
@@ -102,7 +102,6 @@ typedef elf_fpreg_t elf_fpregset_t;
  */
 #define ELF_PLAT_INIT(_r, load_addr)   (_r)->r0 = 0
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      PAGE_SIZE
 
 /*
index dded923883b2549c52bebb63e5ba5fe664382cb8..179a06489b1086036cae78a0fadd59801f2da8f1 100644 (file)
  * We make no fairness assumptions. They have a cost.
  */
 
-#define __raw_spin_is_locked(x)                (*(volatile int *)(&(x)->slock) <= 0)
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
-#define __raw_spin_unlock_wait(x) \
-               do { cpu_relax(); } while (__raw_spin_is_locked(x))
+#define arch_spin_is_locked(x)         (*(volatile int *)(&(x)->slock) <= 0)
+#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
+#define arch_spin_unlock_wait(x) \
+               do { cpu_relax(); } while (arch_spin_is_locked(x))
 
 /**
- * __raw_spin_trylock - Try spin lock and return a result
+ * arch_spin_trylock - Try spin lock and return a result
  * @lock: Pointer to the lock variable
  *
- * __raw_spin_trylock() tries to get the lock and returns a result.
+ * arch_spin_trylock() tries to get the lock and returns a result.
  * On the m32r, the result value is 1 (= Success) or 0 (= Failure).
  */
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        int oldval;
        unsigned long tmp1, tmp2;
@@ -50,7 +50,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
         * }
         */
        __asm__ __volatile__ (
-               "# __raw_spin_trylock           \n\t"
+               "# arch_spin_trylock            \n\t"
                "ldi    %1, #0;                 \n\t"
                "mvfc   %2, psw;                \n\t"
                "clrpsw #0x40 -> nop;           \n\t"
@@ -69,7 +69,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
        return (oldval > 0);
 }
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        unsigned long tmp0, tmp1;
 
@@ -84,7 +84,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
         * }
         */
        __asm__ __volatile__ (
-               "# __raw_spin_lock              \n\t"
+               "# arch_spin_lock               \n\t"
                ".fillinsn                      \n"
                "1:                             \n\t"
                "mvfc   %1, psw;                \n\t"
@@ -111,7 +111,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
        );
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        mb();
        lock->slock = 1;
@@ -140,15 +140,15 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
  * read_can_lock - would read_trylock() succeed?
  * @lock: the rwlock in question.
  */
-#define __raw_read_can_lock(x) ((int)(x)->lock > 0)
+#define arch_read_can_lock(x) ((int)(x)->lock > 0)
 
 /**
  * write_can_lock - would write_trylock() succeed?
  * @lock: the rwlock in question.
  */
-#define __raw_write_can_lock(x) ((x)->lock == RW_LOCK_BIAS)
+#define arch_write_can_lock(x) ((x)->lock == RW_LOCK_BIAS)
 
-static inline void __raw_read_lock(raw_rwlock_t *rw)
+static inline void arch_read_lock(arch_rwlock_t *rw)
 {
        unsigned long tmp0, tmp1;
 
@@ -199,7 +199,7 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
        );
 }
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
        unsigned long tmp0, tmp1, tmp2;
 
@@ -252,7 +252,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
        );
 }
 
-static inline void __raw_read_unlock(raw_rwlock_t *rw)
+static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
        unsigned long tmp0, tmp1;
 
@@ -274,7 +274,7 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
        );
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t *rw)
+static inline void arch_write_unlock(arch_rwlock_t *rw)
 {
        unsigned long tmp0, tmp1, tmp2;
 
@@ -298,7 +298,7 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
        );
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t *lock)
+static inline int arch_read_trylock(arch_rwlock_t *lock)
 {
        atomic_t *count = (atomic_t*)lock;
        if (atomic_dec_return(count) >= 0)
@@ -307,7 +307,7 @@ static inline int __raw_read_trylock(raw_rwlock_t *lock)
        return 0;
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *lock)
+static inline int arch_write_trylock(arch_rwlock_t *lock)
 {
        atomic_t *count = (atomic_t *)lock;
        if (atomic_sub_and_test(RW_LOCK_BIAS, count))
@@ -316,11 +316,11 @@ static inline int __raw_write_trylock(raw_rwlock_t *lock)
        return 0;
 }
 
-#define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock)
-#define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock)
+#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* _ASM_M32R_SPINLOCK_H */
index 83f52105c0e4a33f5ab282a78f9c25ce6f05a3bb..92e27672661f8c367ed1359bacdc207b7832d9f6 100644 (file)
@@ -7,17 +7,17 @@
 
 typedef struct {
        volatile int slock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 1 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 1 }
 
 typedef struct {
        volatile int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
 #define RW_LOCK_BIAS                   0x01000000
 #define RW_LOCK_BIAS_STR               "0x01000000"
 
-#define __RAW_RW_LOCK_UNLOCKED         { RW_LOCK_BIAS }
+#define __ARCH_RW_LOCK_UNLOCKED                { RW_LOCK_BIAS }
 
 #endif /* _ASM_M32R_SPINLOCK_TYPES_H */
index 8dfd31e87c4c884d2937d7259bd04f637cef0b11..3c71f776872c51842a7959a911182b3c4afa3353 100644 (file)
@@ -40,7 +40,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -59,7 +59,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        }
        return 0;
 }
diff --git a/arch/m68k/include/asm/asm-offsets.h b/arch/m68k/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 0b0f49eb876b11db0ce7eb6cd1703be2657fbd54..01c193d9141268c5f65ea1720ba1ecdd1db9d726 100644 (file)
@@ -59,7 +59,6 @@ typedef struct user_m68kfp_struct elf_fpregset_t;
    is actually used on ASV.  */
 #define ELF_PLAT_INIT(_r, load_addr)   _r->a1 = 0
 
-#define USE_ELF_CORE_DUMP
 #ifndef CONFIG_SUN3
 #define ELF_EXEC_PAGESIZE      4096
 #else
index 86edb5fbcfc354116093b4d3daf462ed53d11e6a..ef54128baa0b66cac9017df92ac9eb64f51d27de 100644 (file)
  * for them and trying to understand what they mean.
  *
  * CONFIG_xxx: These are the obvious machine configuration defines created
- * during configuration.  These are defined in include/linux/autoconf.h.
+ * during configuration.  These are defined in autoconf.h.
  *
  * CONSOLE:    There is support for head.S console in this file.  This
  * console can talk to a Mac frame buffer, but could easily be extrapolated
diff --git a/arch/microblaze/include/asm/asm-offsets.h b/arch/microblaze/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index f92fc0dda006d40b886d36b947bb3891cb83656a..7d4acf2b278e2061c9d73d9ef4b86faf09620e8a 100644 (file)
@@ -77,7 +77,6 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 #define ELF_DATA       ELFDATA2MSB
 #endif
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      4096
 
 
index 7d5ddd62d4d23e6d9673a538e6e251bad4b10feb..0f06034d1fe09754659c4069a31bd71fe33b02f5 100644 (file)
@@ -68,7 +68,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < nr_irq) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -89,7 +89,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        }
        return 0;
 }
index fd7620f025fab0ab25bcd9bca3e3dbf00b78161d..9541171f1220070d7d441718b7720489a6833cb7 100644 (file)
@@ -5,9 +5,12 @@ config MIPS
        select HAVE_IDE
        select HAVE_OPROFILE
        select HAVE_ARCH_KGDB
-       # Horrible source of confusion.  Die, die, die ...
-       select EMBEDDED
-       select RTC_LIB if !LEMOTE_FULOONG2E
+       select HAVE_FUNCTION_TRACER
+       select HAVE_FUNCTION_TRACE_MCOUNT_TEST
+       select HAVE_DYNAMIC_FTRACE
+       select HAVE_FTRACE_MCOUNT_RECORD
+       select HAVE_FUNCTION_GRAPH_TRACER
+       select RTC_LIB if !MACH_LOONGSON
 
 mainmenu "Linux/MIPS Kernel Configuration"
 
@@ -22,6 +25,7 @@ choice
 
 config MACH_ALCHEMY
        bool "Alchemy processor based machines"
+       select SYS_SUPPORTS_ZBOOT
 
 config AR7
        bool "Texas Instruments AR7"
@@ -36,6 +40,7 @@ config AR7
        select SYS_HAS_EARLY_PRINTK
        select SYS_SUPPORTS_32BIT_KERNEL
        select SYS_SUPPORTS_LITTLE_ENDIAN
+       select SYS_SUPPORTS_ZBOOT_UART16550
        select GENERIC_GPIO
        select GCD
        select VLYNQ
@@ -43,23 +48,6 @@ config AR7
          Support for the Texas Instruments AR7 System-on-a-Chip
          family: TNETD7100, 7200 and 7300.
 
-config BASLER_EXCITE
-       bool "Basler eXcite smart camera"
-       select CEVT_R4K
-       select CSRC_R4K
-       select DMA_COHERENT
-       select HW_HAS_PCI
-       select IRQ_CPU
-       select IRQ_CPU_RM7K
-       select IRQ_CPU_RM9K
-       select MIPS_RM9122
-       select SYS_HAS_CPU_RM9000
-       select SYS_SUPPORTS_32BIT_KERNEL
-       select SYS_SUPPORTS_BIG_ENDIAN
-       help
-         The eXcite is a smart camera platform manufactured by
-         Basler Vision Technologies AG.
-
 config BCM47XX
        bool "BCM47XX based boards"
        select CEVT_R4K
@@ -192,6 +180,7 @@ config LASAT
 
 config MACH_LOONGSON
        bool "Loongson family of machines"
+       select SYS_SUPPORTS_ZBOOT_UART16550
        help
          This enables the support of Loongson family of machines.
 
@@ -233,6 +222,7 @@ config MIPS_MALTA
        select SYS_SUPPORTS_MIPS_CMP
        select SYS_SUPPORTS_MULTITHREADING
        select SYS_SUPPORTS_SMARTMIPS
+       select SYS_SUPPORTS_ZBOOT
        help
          This enables support for the MIPS Technologies Malta evaluation
          board.
@@ -334,6 +324,24 @@ config PMC_YOSEMITE
          Yosemite is an evaluation board for the RM9000x2 processor
          manufactured by PMC-Sierra.
 
+config POWERTV
+       bool "Cisco PowerTV"
+       select BOOT_ELF32
+       select CEVT_R4K
+       select CPU_MIPSR2_IRQ_VI
+       select CPU_MIPSR2_IRQ_EI
+       select CSRC_POWERTV
+       select DMA_NONCOHERENT
+       select HW_HAS_PCI
+       select SYS_HAS_EARLY_PRINTK
+       select SYS_HAS_CPU_MIPS32_R2
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_BIG_ENDIAN
+       select SYS_SUPPORTS_HIGHMEM
+       select USB_OHCI_LITTLE_ENDIAN
+       help
+         This enables support for the Cisco PowerTV Platform.
+
 config SGI_IP22
        bool "SGI IP22 (Indy/Indigo2)"
        select ARC
@@ -674,11 +682,11 @@ config CAVIUM_OCTEON_REFERENCE_BOARD
 endchoice
 
 source "arch/mips/alchemy/Kconfig"
-source "arch/mips/basler/excite/Kconfig"
 source "arch/mips/bcm63xx/Kconfig"
 source "arch/mips/jazz/Kconfig"
 source "arch/mips/lasat/Kconfig"
 source "arch/mips/pmc-sierra/Kconfig"
+source "arch/mips/powertv/Kconfig"
 source "arch/mips/sgi-ip27/Kconfig"
 source "arch/mips/sibyte/Kconfig"
 source "arch/mips/txx9/Kconfig"
@@ -778,6 +786,9 @@ config CSRC_BCM1480
 config CSRC_IOASIC
        bool
 
+config CSRC_POWERTV
+       bool
+
 config CSRC_R4K_LIB
        bool
 
@@ -806,20 +817,6 @@ config DMA_NONCOHERENT
 config DMA_NEED_PCI_MAP_STATE
        bool
 
-config EARLY_PRINTK
-       bool "Early printk" if EMBEDDED && DEBUG_KERNEL
-       depends on SYS_HAS_EARLY_PRINTK
-       default y
-       help
-         This option enables special console drivers which allow the kernel
-         to print messages very early in the bootup process.
-
-         This is useful for kernel debugging when your machine crashes very
-         early before the console code is initialized. For normal operation,
-         it is not recommended because it looks ugly on some machines and
-         doesn't cooperate with an X server. You should normally say N here,
-         unless you want to debug such a crash.
-
 config SYS_HAS_EARLY_PRINTK
        bool
 
@@ -1069,6 +1066,21 @@ config CPU_LOONGSON2E
          The Loongson 2E processor implements the MIPS III instruction set
          with many extensions.
 
+         It has an internal FPGA northbridge, which is compatiable to
+         bonito64.
+
+config CPU_LOONGSON2F
+       bool "Loongson 2F"
+       depends on SYS_HAS_CPU_LOONGSON2F
+       select CPU_LOONGSON2
+       help
+         The Loongson 2F processor implements the MIPS III instruction set
+         with many extensions.
+
+         Loongson2F have built-in DDR2 and PCIX controller. The PCIX controller
+         have a similar programming interface with FPGA northbridge used in
+         Loongson2E.
+
 config CPU_MIPS32_R1
        bool "MIPS32 Release 1"
        depends on SYS_HAS_CPU_MIPS32_R1
@@ -1294,6 +1306,16 @@ config CPU_CAVIUM_OCTEON
 
 endchoice
 
+config SYS_SUPPORTS_ZBOOT
+       bool
+       select HAVE_KERNEL_GZIP
+       select HAVE_KERNEL_BZIP2
+       select HAVE_KERNEL_LZMA
+
+config SYS_SUPPORTS_ZBOOT_UART16550
+       bool
+       select SYS_SUPPORTS_ZBOOT
+
 config CPU_LOONGSON2
        bool
        select CPU_SUPPORTS_32BIT_KERNEL
@@ -1303,6 +1325,12 @@ config CPU_LOONGSON2
 config SYS_HAS_CPU_LOONGSON2E
        bool
 
+config SYS_HAS_CPU_LOONGSON2F
+       bool
+       select CPU_SUPPORTS_CPUFREQ
+       select CPU_SUPPORTS_ADDRWINCFG if 64BIT
+       select CPU_SUPPORTS_UNCACHED_ACCELERATED
+
 config SYS_HAS_CPU_MIPS32_R1
        bool
 
@@ -1411,8 +1439,17 @@ config CPU_SUPPORTS_32BIT_KERNEL
        bool
 config CPU_SUPPORTS_64BIT_KERNEL
        bool
+config CPU_SUPPORTS_CPUFREQ
+       bool
+config CPU_SUPPORTS_ADDRWINCFG
+       bool
 config CPU_SUPPORTS_HUGEPAGES
        bool
+config CPU_SUPPORTS_UNCACHED_ACCELERATED
+       bool
+config MIPS_PGD_C0_CONTEXT
+       bool
+       default y if 64BIT && CPU_MIPSR2
 
 #
 # Set to y for ptrace access to watch registers.
@@ -2024,15 +2061,6 @@ config STACKTRACE_SUPPORT
 
 source "init/Kconfig"
 
-config PROBE_INITRD_HEADER
-       bool "Probe initrd header created by addinitrd"
-       depends on BLK_DEV_INITRD
-       help
-         Probe initrd header at the last page of kernel image.
-         Say Y here if you are using arch/mips/boot/addinitrd.c to
-         add initrd or initramfs image to the kernel image.
-         Otherwise, say N.
-
 source "kernel/Kconfig.freezer"
 
 menu "Bus options (PCI, PCMCIA, EISA, ISA, TC)"
@@ -2104,6 +2132,7 @@ config MMU
 
 config I8253
        bool
+       select MIPS_EXTERNAL_TIMER
 
 config ZONE_DMA32
        bool
@@ -2180,6 +2209,8 @@ source "kernel/power/Kconfig"
 
 endmenu
 
+source "arch/mips/kernel/cpufreq/Kconfig"
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"
index 364ca89388072bdef9c9083183b329cec5828af7..d2b88a0be5199715b003668f5c528a0c6cefcafe 100644 (file)
@@ -6,15 +6,66 @@ config TRACE_IRQFLAGS_SUPPORT
 
 source "lib/Kconfig.debug"
 
+config EARLY_PRINTK
+       bool "Early printk" if EMBEDDED
+       depends on SYS_HAS_EARLY_PRINTK
+       default y
+       help
+         This option enables special console drivers which allow the kernel
+         to print messages very early in the bootup process.
+
+         This is useful for kernel debugging when your machine crashes very
+         early before the console code is initialized. For normal operation,
+         it is not recommended because it looks ugly on some machines and
+         doesn't cooperate with an X server. You should normally say N here,
+         unless you want to debug such a crash.
+
+config CMDLINE_BOOL
+       bool "Built-in kernel command line"
+       default n
+       help
+         For most systems, it is firmware or second stage bootloader that
+         by default specifies the kernel command line options.  However,
+         it might be necessary or advantageous to either override the
+         default kernel command line or add a few extra options to it.
+         For such cases, this option allows you to hardcode your own
+         command line options directly into the kernel.  For that, you
+         should choose 'Y' here, and fill in the extra boot arguments
+         in CONFIG_CMDLINE.
+
+         The built-in options will be concatenated to the default command
+         line if CMDLINE_OVERRIDE is set to 'N'. Otherwise, the default
+         command line will be ignored and replaced by the built-in string.
+
+         Most MIPS systems will normally expect 'N' here and rely upon
+         the command line from the firmware or the second-stage bootloader.
+
 config CMDLINE
        string "Default kernel command string"
+       depends on CMDLINE_BOOL
        default ""
        help
          On some platforms, there is currently no way for the boot loader to
-         pass arguments to the kernel. For these platforms, you can supply
-         some command-line options at build time by entering them here.  In
-         other cases you can specify kernel args so that you don't have
-         to set them up in board prom initialization routines.
+         pass arguments to the kernel.  For these platforms, and for the cases
+         when you want to add some extra options to the command line or ignore
+         the default command line, you can supply some command-line options at
+         build time by entering them here.  In other cases you can specify
+         kernel args so that you don't have to set them up in board prom
+         initialization routines.
+
+         For more information, see the CMDLINE_BOOL and CMDLINE_OVERRIDE
+         options.
+
+config CMDLINE_OVERRIDE
+       bool "Built-in command line overrides firware arguments"
+       default n
+       depends on CMDLINE_BOOL
+       help
+         By setting this option to 'Y' you will have your kernel ignore
+         command line arguments from firmware or second stage bootloader.
+         Instead, the built-in command line will be used exclusively.
+
+         Normally, you will choose 'N' here.
 
 config DEBUG_STACK_USAGE
        bool "Enable stack utilization instrumentation"
index 77f5021218d3e2dec0e5d30a3544cc64940a7a9c..1893efd43fcab58b72c339dbf5917aedab17756a 100644 (file)
@@ -48,7 +48,16 @@ ifneq ($(SUBARCH),$(ARCH))
   endif
 endif
 
+ifndef CONFIG_FUNCTION_TRACER
 cflags-y := -ffunction-sections
+endif
+ifdef CONFIG_FUNCTION_GRAPH_TRACER
+  ifndef KBUILD_MCOUNT_RA_ADDRESS
+    ifeq ($(call cc-option-yn,-mmcount-ra-address), y)
+      cflags-y += -mmcount-ra-address -DKBUILD_MCOUNT_RA_ADDRESS
+    endif
+  endif
+endif
 cflags-y += $(call cc-option, -mno-check-zero-division)
 
 ifdef CONFIG_32BIT
@@ -69,6 +78,7 @@ endif
 
 all-$(CONFIG_BOOT_ELF32)       := $(vmlinux-32)
 all-$(CONFIG_BOOT_ELF64)       := $(vmlinux-64)
+all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz
 
 #
 # GCC uses -G 0 -mabicalls -fpic as default.  We don't want PIC in the kernel
@@ -124,6 +134,8 @@ cflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap
 cflags-$(CONFIG_CPU_LOONGSON2) += -Wa,--trap
 cflags-$(CONFIG_CPU_LOONGSON2E) += \
        $(call cc-option,-march=loongson2e,-march=r4600)
+cflags-$(CONFIG_CPU_LOONGSON2F) += \
+       $(call cc-option,-march=loongson2f,-march=r4600)
 
 cflags-$(CONFIG_CPU_MIPS32_R1) += $(call cc-option,-march=mips32,-mips32 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \
                        -Wa,-mips32 -Wa,--trap
@@ -324,6 +336,7 @@ core-$(CONFIG_MACH_LOONGSON) +=arch/mips/loongson/
 cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-loongson \
                     -mno-branch-likely
 load-$(CONFIG_LEMOTE_FULOONG2E) +=0xffffffff80100000
+load-$(CONFIG_LEMOTE_MACH2F) +=0xffffffff80200000
 
 #
 # MIPS Malta board
@@ -331,7 +344,7 @@ load-$(CONFIG_LEMOTE_FULOONG2E) +=0xffffffff80100000
 core-$(CONFIG_MIPS_MALTA)      += arch/mips/mti-malta/
 cflags-$(CONFIG_MIPS_MALTA)    += -I$(srctree)/arch/mips/include/asm/mach-malta
 load-$(CONFIG_MIPS_MALTA)      += 0xffffffff80100000
-all-$(CONFIG_MIPS_MALTA)       := vmlinux.bin
+all-$(CONFIG_MIPS_MALTA)       := vmlinuz.bin
 
 #
 # MIPS SIM
@@ -355,13 +368,6 @@ core-$(CONFIG_PMC_YOSEMITE)        += arch/mips/pmc-sierra/yosemite/
 cflags-$(CONFIG_PMC_YOSEMITE)  += -I$(srctree)/arch/mips/include/asm/mach-yosemite
 load-$(CONFIG_PMC_YOSEMITE)    += 0xffffffff80100000
 
-#
-# Basler eXcite
-#
-core-$(CONFIG_BASLER_EXCITE)   += arch/mips/basler/excite/
-cflags-$(CONFIG_BASLER_EXCITE) += -I$(srctree)/arch/mips/include/asm/mach-excite
-load-$(CONFIG_BASLER_EXCITE)   += 0x80100000
-
 #
 # LASAT platforms
 #
@@ -440,6 +446,13 @@ cflags-$(CONFIG_SOC_EMMA2RH)       += -I$(srctree)/arch/mips/include/asm/mach-emma2rh
 core-$(CONFIG_NEC_MARKEINS)    += arch/mips/emma/markeins/
 load-$(CONFIG_NEC_MARKEINS)    += 0xffffffff88100000
 
+#
+# Cisco PowerTV Platform
+#
+core-$(CONFIG_POWERTV)         += arch/mips/powertv/
+cflags-$(CONFIG_POWERTV)        += -I$(srctree)/arch/mips/include/asm/mach-powertv
+load-$(CONFIG_POWERTV)         += 0xffffffff90800000
+
 #
 # SGI IP22 (Indy/Indigo2)
 #
@@ -581,7 +594,7 @@ load-$(CONFIG_SNI_RM)               += 0xffffffff80600000
 else
 load-$(CONFIG_SNI_RM)          += 0xffffffff80030000
 endif
-all-$(CONFIG_SNI_RM)           := vmlinux.ecoff
+all-$(CONFIG_SNI_RM)           := vmlinuz.ecoff
 
 #
 # Common TXx9
@@ -699,9 +712,23 @@ vmlinux.64: vmlinux
        $(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@
 
 makeboot =$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) $(1)
+makezboot =$(Q)$(MAKE) $(build)=arch/mips/boot/compressed \
+          VMLINUX_LOAD_ADDRESS=$(load-y) 32bit-bfd=$(32bit-bfd) $(1)
 
 all:   $(all-y)
 
+vmlinuz: vmlinux FORCE
+       +@$(call makezboot,$@)
+
+vmlinuz.bin: vmlinux
+       +@$(call makezboot,$@)
+
+vmlinuz.ecoff: vmlinux
+       +@$(call makezboot,$@)
+
+vmlinuz.srec: vmlinux
+       +@$(call makezboot,$@)
+
 vmlinux.bin: $(vmlinux-32)
        +@$(call makeboot,$@)
 
@@ -726,11 +753,13 @@ endif
 
 install:
        $(Q)install -D -m 755 vmlinux $(INSTALL_PATH)/vmlinux-$(KERNELRELEASE)
+       $(Q)install -D -m 755 vmlinuz $(INSTALL_PATH)/vmlinuz-$(KERNELRELEASE)
        $(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE)
        $(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE)
 
 archclean:
        @$(MAKE) $(clean)=arch/mips/boot
+       @$(MAKE) $(clean)=arch/mips/boot/compressed
        @$(MAKE) $(clean)=arch/mips/lasat
 
 define archhelp
@@ -738,10 +767,18 @@ define archhelp
        echo '  vmlinux.ecoff        - ECOFF boot image'
        echo '  vmlinux.bin          - Raw binary boot image'
        echo '  vmlinux.srec         - SREC boot image'
+       echo '  vmlinuz              - Compressed boot(zboot) image'
+       echo '  vmlinuz.ecoff        - ECOFF zboot image'
+       echo '  vmlinuz.bin          - Raw binary zboot image'
+       echo '  vmlinuz.srec         - SREC zboot image'
        echo
        echo '  These will be default as apropriate for a configured platform.'
 endef
 
 CLEAN_FILES += vmlinux.32 \
               vmlinux.64 \
-              vmlinux.ecoff
+              vmlinux.ecoff \
+              vmlinuz \
+              vmlinuz.ecoff \
+              vmlinuz.bin \
+              vmlinuz.srec
index 835f3f0319ca77b7b8be96e4babac9db16283c1f..85169c08d8dca73d03736a90c7d869bea72565c8 100644 (file)
@@ -505,7 +505,7 @@ static int __init ar7_register_devices(void)
        int res;
        u32 *bootcr, val;
 #ifdef CONFIG_SERIAL_8250
-       static struct uart_port uart_port[2];
+       static struct uart_port uart_port[2] __initdata;
 
        memset(uart_port, 0, sizeof(struct uart_port) * 2);
 
diff --git a/arch/mips/basler/excite/Kconfig b/arch/mips/basler/excite/Kconfig
deleted file mode 100644 (file)
index ba50607..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-config BASLER_EXCITE_PROTOTYPE
-       bool "Support for pre-release units"
-       depends on BASLER_EXCITE
-       default n
-       help
-         Pre-series (prototype) units are different from later ones in
-         some ways. Select this option if you have one of these. Please
-         note that a kernel built with this option selected will not be
-         able to run on normal units.
diff --git a/arch/mips/basler/excite/Makefile b/arch/mips/basler/excite/Makefile
deleted file mode 100644 (file)
index cff29cf..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# Makefile for Basler eXcite
-#
-
-obj-$(CONFIG_BASLER_EXCITE)    += excite_irq.o excite_prom.o excite_setup.o \
-                                  excite_device.o excite_procfs.o
-
-obj-m                          += excite_iodev.o
diff --git a/arch/mips/basler/excite/excite_device.c b/arch/mips/basler/excite/excite_device.c
deleted file mode 100644 (file)
index e00bc2d..0000000
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- *  Copyright (C) 2004 by Basler Vision Technologies AG
- *  Author: Thomas Koeller <thomas.koeller@baslerweb.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/ioport.h>
-#include <linux/err.h>
-#include <linux/jiffies.h>
-#include <linux/sched.h>
-#include <asm/types.h>
-#include <asm/rm9k-ocd.h>
-
-#include <excite.h>
-#include <rm9k_eth.h>
-#include <rm9k_wdt.h>
-#include <rm9k_xicap.h>
-#include <excite_nandflash.h>
-
-#include "excite_iodev.h"
-
-#define RM9K_GE_UNIT   0
-#define XICAP_UNIT     0
-#define NAND_UNIT      0
-
-#define DLL_TIMEOUT    3               /* seconds */
-
-
-#define RINIT(__start__, __end__, __name__, __parent__) {      \
-       .name   = __name__ "_0",                                \
-       .start  = (__start__),                                  \
-       .end    = (__end__),                                    \
-       .flags  = 0,                                            \
-       .parent = (__parent__)                                  \
-}
-
-#define RINIT_IRQ(__irq__, __name__) { \
-       .name   = __name__ "_0",        \
-       .start  = (__irq__),            \
-       .end    = (__irq__),            \
-       .flags  = IORESOURCE_IRQ,       \
-       .parent = NULL                  \
-}
-
-
-
-enum {
-       slice_xicap,
-       slice_eth
-};
-
-
-
-static struct resource
-       excite_ctr_resource __maybe_unused = {
-               .name           = "GPI counters",
-               .start          = 0,
-               .end            = 5,
-               .flags          = 0,
-               .parent         = NULL,
-               .sibling        = NULL,
-               .child          = NULL
-       },
-       excite_gpislice_resource __maybe_unused = {
-               .name           = "GPI slices",
-               .start          = 0,
-               .end            = 1,
-               .flags          = 0,
-               .parent         = NULL,
-               .sibling        = NULL,
-               .child          = NULL
-       },
-       excite_mdio_channel_resource __maybe_unused = {
-               .name           = "MDIO channels",
-               .start          = 0,
-               .end            = 1,
-               .flags          = 0,
-               .parent         = NULL,
-               .sibling        = NULL,
-               .child          = NULL
-       },
-       excite_fifomem_resource __maybe_unused = {
-               .name           = "FIFO memory",
-               .start          = 0,
-               .end            = 767,
-               .flags          = 0,
-               .parent         = NULL,
-               .sibling        = NULL,
-               .child          = NULL
-       },
-       excite_scram_resource __maybe_unused = {
-               .name           = "Scratch RAM",
-               .start          = EXCITE_PHYS_SCRAM,
-               .end            = EXCITE_PHYS_SCRAM + EXCITE_SIZE_SCRAM - 1,
-               .flags          = IORESOURCE_MEM,
-               .parent         = NULL,
-               .sibling        = NULL,
-               .child          = NULL
-       },
-       excite_fpga_resource __maybe_unused = {
-               .name           = "System FPGA",
-               .start          = EXCITE_PHYS_FPGA,
-               .end            = EXCITE_PHYS_FPGA + EXCITE_SIZE_FPGA - 1,
-               .flags          = IORESOURCE_MEM,
-               .parent         = NULL,
-               .sibling        = NULL,
-               .child          = NULL
-       },
-       excite_nand_resource __maybe_unused = {
-               .name           = "NAND flash control",
-               .start          = EXCITE_PHYS_NAND,
-               .end            = EXCITE_PHYS_NAND + EXCITE_SIZE_NAND - 1,
-               .flags          = IORESOURCE_MEM,
-               .parent         = NULL,
-               .sibling        = NULL,
-               .child          = NULL
-       },
-       excite_titan_resource __maybe_unused = {
-               .name           = "TITAN registers",
-               .start          = EXCITE_PHYS_TITAN,
-               .end            = EXCITE_PHYS_TITAN + EXCITE_SIZE_TITAN - 1,
-               .flags          = IORESOURCE_MEM,
-               .parent         = NULL,
-               .sibling        = NULL,
-               .child          = NULL
-       };
-
-
-
-static void adjust_resources(struct resource *res, unsigned int n)
-{
-       struct resource *p;
-       const unsigned long mask = IORESOURCE_IO | IORESOURCE_MEM
-                                  | IORESOURCE_IRQ | IORESOURCE_DMA;
-
-       for (p = res; p < res + n; p++) {
-               const struct resource * const parent = p->parent;
-               if (parent) {
-                       p->start += parent->start;
-                       p->end   += parent->start;
-                       p->flags =  parent->flags & mask;
-               }
-       }
-}
-
-
-
-#if defined(CONFIG_EXCITE_FCAP_GPI) || defined(CONFIG_EXCITE_FCAP_GPI_MODULE)
-static struct resource xicap_rsrc[] = {
-       RINIT(0x4840, 0x486f, XICAP_RESOURCE_FIFO_RX, &excite_titan_resource),
-       RINIT(0x4940, 0x494b, XICAP_RESOURCE_FIFO_TX, &excite_titan_resource),
-       RINIT(0x5040, 0x5127, XICAP_RESOURCE_XDMA, &excite_titan_resource),
-       RINIT(0x1000, 0x112f, XICAP_RESOURCE_PKTPROC, &excite_titan_resource),
-       RINIT(0x1100, 0x110f, XICAP_RESOURCE_PKT_STREAM, &excite_fpga_resource),
-       RINIT(0x0800, 0x0bff, XICAP_RESOURCE_DMADESC, &excite_scram_resource),
-       RINIT(slice_xicap, slice_xicap, XICAP_RESOURCE_GPI_SLICE, &excite_gpislice_resource),
-       RINIT(0x0100, 0x02ff, XICAP_RESOURCE_FIFO_BLK, &excite_fifomem_resource),
-       RINIT_IRQ(TITAN_IRQ,  XICAP_RESOURCE_IRQ)
-};
-
-static struct platform_device xicap_pdev = {
-       .name           = XICAP_NAME,
-       .id             = XICAP_UNIT,
-       .num_resources  = ARRAY_SIZE(xicap_rsrc),
-       .resource       = xicap_rsrc
-};
-
-/*
- * Create a platform device for the GPI port that receives the
- * image data from the embedded camera.
- */
-static int __init xicap_devinit(void)
-{
-       unsigned long tend;
-       u32 reg;
-       int retval;
-
-       adjust_resources(xicap_rsrc, ARRAY_SIZE(xicap_rsrc));
-
-       /* Power up the slice and configure it. */
-       reg = titan_readl(CPTC1R);
-       reg &= ~(0x11100 << slice_xicap);
-       titan_writel(reg, CPTC1R);
-
-       /* Enable slice & DLL. */
-       reg= titan_readl(CPRR);
-       reg &= ~(0x00030003 << (slice_xicap * 2));
-       titan_writel(reg, CPRR);
-
-       /* Wait for DLLs to lock */
-       tend = jiffies + DLL_TIMEOUT * HZ;
-       while (time_before(jiffies, tend)) {
-               if (!(~titan_readl(CPDSR) & (0x1 << (slice_xicap * 4))))
-                       break;
-               yield();
-       }
-
-       if (~titan_readl(CPDSR) & (0x1 << (slice_xicap * 4))) {
-               printk(KERN_ERR "%s: DLL not locked after %u seconds\n",
-                      xicap_pdev.name, DLL_TIMEOUT);
-               retval = -ETIME;
-       } else {
-               /* Register platform device */
-               retval = platform_device_register(&xicap_pdev);
-       }
-
-       return retval;
-}
-
-device_initcall(xicap_devinit);
-#endif /* defined(CONFIG_EXCITE_FCAP_GPI) || defined(CONFIG_EXCITE_FCAP_GPI_MODULE) */
-
-
-
-#if defined(CONFIG_WDT_RM9K_GPI) || defined(CONFIG_WDT_RM9K_GPI_MODULE)
-static struct resource wdt_rsrc[] = {
-       RINIT(0, 0, WDT_RESOURCE_COUNTER, &excite_ctr_resource),
-       RINIT(0x0084, 0x008f, WDT_RESOURCE_REGS, &excite_titan_resource),
-       RINIT_IRQ(TITAN_IRQ,  WDT_RESOURCE_IRQ)
-};
-
-static struct platform_device wdt_pdev = {
-       .name           = WDT_NAME,
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(wdt_rsrc),
-       .resource       = wdt_rsrc
-};
-
-/*
- * Create a platform device for the GPI port that receives the
- * image data from the embedded camera.
- */
-static int __init wdt_devinit(void)
-{
-       adjust_resources(wdt_rsrc, ARRAY_SIZE(wdt_rsrc));
-       return platform_device_register(&wdt_pdev);
-}
-
-device_initcall(wdt_devinit);
-#endif /* defined(CONFIG_WDT_RM9K_GPI) || defined(CONFIG_WDT_RM9K_GPI_MODULE) */
-
-
-
-static struct resource excite_nandflash_rsrc[] = {
-       RINIT(0x2000, 0x201f, EXCITE_NANDFLASH_RESOURCE_REGS,  &excite_nand_resource)
-};
-
-static struct platform_device excite_nandflash_pdev = {
-       .name           = "excite_nand",
-       .id             = NAND_UNIT,
-       .num_resources  = ARRAY_SIZE(excite_nandflash_rsrc),
-       .resource       = excite_nandflash_rsrc
-};
-
-/*
- * Create a platform device for the access to the nand-flash
- * port
- */
-static int __init excite_nandflash_devinit(void)
-{
-       adjust_resources(excite_nandflash_rsrc, ARRAY_SIZE(excite_nandflash_rsrc));
-
-        /* nothing to be done here */
-
-        /* Register platform device */
-       return platform_device_register(&excite_nandflash_pdev);
-}
-
-device_initcall(excite_nandflash_devinit);
-
-
-
-static struct resource iodev_rsrc[] = {
-       RINIT_IRQ(FPGA1_IRQ,  IODEV_RESOURCE_IRQ)
-};
-
-static struct platform_device io_pdev = {
-       .name           = IODEV_NAME,
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(iodev_rsrc),
-       .resource       = iodev_rsrc
-};
-
-/*
- * Create a platform device for the external I/O ports.
- */
-static int __init io_devinit(void)
-{
-       adjust_resources(iodev_rsrc, ARRAY_SIZE(iodev_rsrc));
-       return platform_device_register(&io_pdev);
-}
-
-device_initcall(io_devinit);
-
-
-
-
-#if defined(CONFIG_RM9K_GE) || defined(CONFIG_RM9K_GE_MODULE)
-static struct resource rm9k_ge_rsrc[] = {
-       RINIT(0x2200, 0x27ff, RM9K_GE_RESOURCE_MAC, &excite_titan_resource),
-       RINIT(0x1800, 0x1fff, RM9K_GE_RESOURCE_MSTAT, &excite_titan_resource),
-       RINIT(0x2000, 0x212f, RM9K_GE_RESOURCE_PKTPROC, &excite_titan_resource),
-       RINIT(0x5140, 0x5227, RM9K_GE_RESOURCE_XDMA, &excite_titan_resource),
-       RINIT(0x4870, 0x489f, RM9K_GE_RESOURCE_FIFO_RX, &excite_titan_resource),
-       RINIT(0x494c, 0x4957, RM9K_GE_RESOURCE_FIFO_TX, &excite_titan_resource),
-       RINIT(0x0000, 0x007f, RM9K_GE_RESOURCE_FIFOMEM_RX, &excite_fifomem_resource),
-       RINIT(0x0080, 0x00ff, RM9K_GE_RESOURCE_FIFOMEM_TX, &excite_fifomem_resource),
-       RINIT(0x0180, 0x019f, RM9K_GE_RESOURCE_PHY, &excite_titan_resource),
-       RINIT(0x0000, 0x03ff, RM9K_GE_RESOURCE_DMADESC_RX, &excite_scram_resource),
-       RINIT(0x0400, 0x07ff, RM9K_GE_RESOURCE_DMADESC_TX, &excite_scram_resource),
-       RINIT(slice_eth, slice_eth, RM9K_GE_RESOURCE_GPI_SLICE, &excite_gpislice_resource),
-       RINIT(0, 0, RM9K_GE_RESOURCE_MDIO_CHANNEL, &excite_mdio_channel_resource),
-       RINIT_IRQ(TITAN_IRQ,  RM9K_GE_RESOURCE_IRQ_MAIN),
-       RINIT_IRQ(PHY_IRQ, RM9K_GE_RESOURCE_IRQ_PHY)
-};
-
-static struct platform_device rm9k_ge_pdev = {
-       .name           = RM9K_GE_NAME,
-       .id             = RM9K_GE_UNIT,
-       .num_resources  = ARRAY_SIZE(rm9k_ge_rsrc),
-       .resource       = rm9k_ge_rsrc
-};
-
-
-
-/*
- * Create a platform device for the Ethernet port.
- */
-static int __init rm9k_ge_devinit(void)
-{
-       u32 reg;
-
-       adjust_resources(rm9k_ge_rsrc, ARRAY_SIZE(rm9k_ge_rsrc));
-
-       /* Power up the slice and configure it. */
-       reg = titan_readl(CPTC1R);
-       reg &= ~(0x11000 << slice_eth);
-       reg |= 0x100 << slice_eth;
-       titan_writel(reg, CPTC1R);
-
-       /* Take the MAC out of reset, reset the DLLs. */
-       reg = titan_readl(CPRR);
-       reg &= ~(0x00030000 << (slice_eth * 2));
-       reg |= 0x3 << (slice_eth * 2);
-       titan_writel(reg, CPRR);
-
-       return platform_device_register(&rm9k_ge_pdev);
-}
-
-device_initcall(rm9k_ge_devinit);
-#endif /* defined(CONFIG_RM9K_GE) || defined(CONFIG_RM9K_GE_MODULE) */
-
-
-
-static int __init excite_setup_devs(void)
-{
-       int res;
-       u32 reg;
-
-       /* Enable xdma and fifo interrupts */
-       reg = titan_readl(0x0050);
-       titan_writel(reg | 0x18000000, 0x0050);
-
-       res = request_resource(&iomem_resource, &excite_titan_resource);
-       if (res)
-               return res;
-       res = request_resource(&iomem_resource, &excite_scram_resource);
-       if (res)
-               return res;
-       res = request_resource(&iomem_resource, &excite_fpga_resource);
-       if (res)
-               return res;
-       res = request_resource(&iomem_resource, &excite_nand_resource);
-       if (res)
-               return res;
-       excite_fpga_resource.flags = excite_fpga_resource.parent->flags &
-                                  ( IORESOURCE_IO | IORESOURCE_MEM
-                                  | IORESOURCE_IRQ | IORESOURCE_DMA);
-       excite_nand_resource.flags = excite_nand_resource.parent->flags &
-                                  ( IORESOURCE_IO | IORESOURCE_MEM
-                                  | IORESOURCE_IRQ | IORESOURCE_DMA);
-
-       return 0;
-}
-
-arch_initcall(excite_setup_devs);
-
diff --git a/arch/mips/basler/excite/excite_iodev.c b/arch/mips/basler/excite/excite_iodev.c
deleted file mode 100644 (file)
index 938b1d0..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- *  Copyright (C) 2005 by Basler Vision Technologies AG
- *  Author: Thomas Koeller <thomas.koeller@baslerweb.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <linux/compiler.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/poll.h>
-#include <linux/interrupt.h>
-#include <linux/platform_device.h>
-#include <linux/miscdevice.h>
-#include <linux/smp_lock.h>
-
-#include "excite_iodev.h"
-
-
-
-static const struct resource *iodev_get_resource(struct platform_device *, const char *, unsigned int);
-static int __init iodev_probe(struct platform_device *);
-static int __exit iodev_remove(struct platform_device *);
-static int iodev_open(struct inode *, struct file *);
-static int iodev_release(struct inode *, struct file *);
-static ssize_t iodev_read(struct file *, char __user *, size_t s, loff_t *);
-static unsigned int iodev_poll(struct file *, struct poll_table_struct *);
-static irqreturn_t iodev_irqhdl(int, void *);
-
-
-
-static const char iodev_name[] = "iodev";
-static unsigned int iodev_irq;
-static DECLARE_WAIT_QUEUE_HEAD(wq);
-
-
-
-static const struct file_operations fops =
-{
-       .owner          = THIS_MODULE,
-       .open           = iodev_open,
-       .release        = iodev_release,
-       .read           = iodev_read,
-       .poll           = iodev_poll
-};
-
-static struct miscdevice miscdev =
-{
-       .minor          = MISC_DYNAMIC_MINOR,
-       .name           = iodev_name,
-       .fops           = &fops
-};
-
-static struct platform_driver iodev_driver = {
-       .driver = {
-               .name           = iodev_name,
-               .owner          = THIS_MODULE,
-       },
-       .probe          = iodev_probe,
-       .remove         = __devexit_p(iodev_remove),
-};
-
-
-
-static const struct resource *
-iodev_get_resource(struct platform_device *pdv, const char *name,
-                    unsigned int type)
-{
-       char buf[80];
-       if (snprintf(buf, sizeof buf, "%s_0", name) >= sizeof buf)
-               return NULL;
-       return platform_get_resource_byname(pdv, type, buf);
-}
-
-
-
-/* No hotplugging on the platform bus - use __init */
-static int __init iodev_probe(struct platform_device *dev)
-{
-       const struct resource * const ri =
-               iodev_get_resource(dev, IODEV_RESOURCE_IRQ, IORESOURCE_IRQ);
-
-       if (unlikely(!ri))
-               return -ENXIO;
-
-       iodev_irq = ri->start;
-       return misc_register(&miscdev);
-}
-
-
-
-static int __exit iodev_remove(struct platform_device *dev)
-{
-       return misc_deregister(&miscdev);
-}
-
-static int iodev_open(struct inode *i, struct file *f)
-{
-       int ret;
-
-       ret = request_irq(iodev_irq, iodev_irqhdl, IRQF_DISABLED,
-                          iodev_name, &miscdev);
-
-       return ret;
-}
-
-static int iodev_release(struct inode *i, struct file *f)
-{
-       free_irq(iodev_irq, &miscdev);
-       return 0;
-}
-
-
-
-
-static ssize_t
-iodev_read(struct file *f, char __user *d, size_t s, loff_t *o)
-{
-       ssize_t ret;
-       DEFINE_WAIT(w);
-
-       prepare_to_wait(&wq, &w, TASK_INTERRUPTIBLE);
-       if (!signal_pending(current))
-               schedule();
-       ret = signal_pending(current) ? -ERESTARTSYS : 0;
-       finish_wait(&wq, &w);
-       return ret;
-}
-
-
-static unsigned int iodev_poll(struct file *f, struct poll_table_struct *p)
-{
-       poll_wait(f, &wq, p);
-       return POLLOUT | POLLWRNORM;
-}
-
-static irqreturn_t iodev_irqhdl(int irq, void *ctxt)
-{
-       wake_up(&wq);
-
-       return IRQ_HANDLED;
-}
-
-static int __init iodev_init_module(void)
-{
-       return platform_driver_register(&iodev_driver);
-}
-
-
-
-static void __exit iodev_cleanup_module(void)
-{
-       platform_driver_unregister(&iodev_driver);
-}
-
-module_init(iodev_init_module);
-module_exit(iodev_cleanup_module);
-
-
-
-MODULE_AUTHOR("Thomas Koeller <thomas.koeller@baslerweb.com>");
-MODULE_DESCRIPTION("Basler eXcite i/o interrupt handler");
-MODULE_VERSION("0.0");
-MODULE_LICENSE("GPL");
diff --git a/arch/mips/basler/excite/excite_iodev.h b/arch/mips/basler/excite/excite_iodev.h
deleted file mode 100644 (file)
index cbfbb5d..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __EXCITE_IODEV_H__
-#define __EXCITE_IODEV_H__
-
-/* Device name */
-#define IODEV_NAME             "iodev"
-
-/* Resource names */
-#define IODEV_RESOURCE_IRQ     "excite_iodev_irq"
-
-#endif /* __EXCITE_IODEV_H__ */
diff --git a/arch/mips/basler/excite/excite_irq.c b/arch/mips/basler/excite/excite_irq.c
deleted file mode 100644 (file)
index 934e0a6..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- *  Copyright (C) by Basler Vision Technologies AG
- *  Author: Thomas Koeller <thomas.koeller@baslereb.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kernel_stat.h>
-#include <linux/module.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/timex.h>
-#include <linux/slab.h>
-#include <linux/random.h>
-#include <linux/bitops.h>
-#include <asm/bootinfo.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/irq_cpu.h>
-#include <asm/mipsregs.h>
-#include <asm/system.h>
-#include <asm/rm9k-ocd.h>
-
-#include <excite.h>
-
-extern asmlinkage void excite_handle_int(void);
-
-/*
- * Initialize the interrupt handler
- */
-void __init arch_init_irq(void)
-{
-       mips_cpu_irq_init();
-       rm7k_cpu_irq_init();
-       rm9k_cpu_irq_init();
-}
-
-asmlinkage void plat_irq_dispatch(void)
-{
-       const u32
-               interrupts = read_c0_cause() >> 8,
-               mask = ((read_c0_status() >> 8) & 0x000000ff) |
-                      (read_c0_intcontrol() & 0x0000ff00),
-               pending = interrupts & mask;
-       u32 msgintflags, msgintmask, msgint;
-
-       /* process timer interrupt */
-       if (pending & (1 << TIMER_IRQ)) {
-               do_IRQ(TIMER_IRQ);
-               return;
-       }
-
-       /* Process PCI interrupts */
-#if USB_IRQ < 10
-       msgintflags = ocd_readl(INTP0Status0 + (USB_MSGINT / 0x20 * 0x10));
-       msgintmask  = ocd_readl(INTP0Mask0 + (USB_MSGINT / 0x20 * 0x10));
-       msgint      = msgintflags & msgintmask & (0x1 << (USB_MSGINT % 0x20));
-       if ((pending & (1 << USB_IRQ)) && msgint) {
-#else
-       if (pending & (1 << USB_IRQ)) {
-#endif
-               do_IRQ(USB_IRQ);
-               return;
-       }
-
-       /* Process TITAN interrupts */
-       msgintflags = ocd_readl(INTP0Status0 + (TITAN_MSGINT / 0x20 * 0x10));
-       msgintmask  = ocd_readl(INTP0Mask0 + (TITAN_MSGINT / 0x20 * 0x10));
-       msgint      = msgintflags & msgintmask & (0x1 << (TITAN_MSGINT % 0x20));
-       if ((pending & (1 << TITAN_IRQ)) && msgint) {
-               ocd_writel(msgint, INTP0Clear0 + (TITAN_MSGINT / 0x20 * 0x10));
-               do_IRQ(TITAN_IRQ);
-               return;
-       }
-
-       /* Process FPGA line #0 interrupts */
-       msgintflags = ocd_readl(INTP0Status0 + (FPGA0_MSGINT / 0x20 * 0x10));
-       msgintmask  = ocd_readl(INTP0Mask0 + (FPGA0_MSGINT / 0x20 * 0x10));
-       msgint      = msgintflags & msgintmask & (0x1 << (FPGA0_MSGINT % 0x20));
-       if ((pending & (1 << FPGA0_IRQ)) && msgint) {
-               do_IRQ(FPGA0_IRQ);
-               return;
-       }
-
-       /* Process FPGA line #1 interrupts */
-       msgintflags = ocd_readl(INTP0Status0 + (FPGA1_MSGINT / 0x20 * 0x10));
-       msgintmask  = ocd_readl(INTP0Mask0 + (FPGA1_MSGINT / 0x20 * 0x10));
-       msgint      = msgintflags & msgintmask & (0x1 << (FPGA1_MSGINT % 0x20));
-       if ((pending & (1 << FPGA1_IRQ)) && msgint) {
-               do_IRQ(FPGA1_IRQ);
-               return;
-       }
-
-       /* Process PHY interrupts */
-       msgintflags = ocd_readl(INTP0Status0 + (PHY_MSGINT / 0x20 * 0x10));
-       msgintmask  = ocd_readl(INTP0Mask0 + (PHY_MSGINT / 0x20 * 0x10));
-       msgint      = msgintflags & msgintmask & (0x1 << (PHY_MSGINT % 0x20));
-       if ((pending & (1 << PHY_IRQ)) && msgint) {
-               do_IRQ(PHY_IRQ);
-               return;
-       }
-
-       /* Process spurious interrupts */
-       spurious_interrupt();
-}
diff --git a/arch/mips/basler/excite/excite_procfs.c b/arch/mips/basler/excite/excite_procfs.c
deleted file mode 100644 (file)
index 08923e6..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- *  Copyright (C) 2004, 2005 by Basler Vision Technologies AG
- *  Author: Thomas Koeller <thomas.koeller@baslerweb.com>
- *
- *  Procfs support for Basler eXcite
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include <linux/module.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <linux/stat.h>
-#include <asm/page.h>
-#include <asm/io.h>
-#include <asm/system.h>
-#include <asm/rm9k-ocd.h>
-
-#include <excite.h>
-
-static int excite_unit_id_proc_show(struct seq_file *m, void *v)
-{
-       seq_printf(m, "%06x", unit_id);
-       return 0;
-}
-
-static int excite_unit_id_proc_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, excite_unit_id_proc_show, NULL);
-}
-
-static const struct file_operations excite_unit_id_proc_fops = {
-       .owner          = THIS_MODULE,
-       .open           = excite_unit_id_proc_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static int
-excite_bootrom_read(char *page, char **start, off_t off, int count,
-                 int *eof, void *data)
-{
-       void __iomem * src;
-
-       if (off >= EXCITE_SIZE_BOOTROM) {
-               *eof = 1;
-               return 0;
-       }
-
-       if ((off + count) > EXCITE_SIZE_BOOTROM)
-               count = EXCITE_SIZE_BOOTROM - off;
-
-       src = ioremap(EXCITE_PHYS_BOOTROM + off, count);
-       if (src) {
-               memcpy_fromio(page, src, count);
-               iounmap(src);
-               *start = page;
-       } else {
-               count = -ENOMEM;
-       }
-
-       return count;
-}
-
-void excite_procfs_init(void)
-{
-       /* Create & populate /proc/excite */
-       struct proc_dir_entry * const pdir = proc_mkdir("excite", NULL);
-       if (pdir) {
-               struct proc_dir_entry * e;
-
-               e = proc_create("unit_id", S_IRUGO, pdir,
-                               &excite_unit_id_proc_fops);
-               if (e) e->size = 6;
-
-               e = create_proc_read_entry("bootrom", S_IRUGO, pdir,
-                                          excite_bootrom_read, NULL);
-               if (e) e->size = EXCITE_SIZE_BOOTROM;
-       }
-}
diff --git a/arch/mips/basler/excite/excite_prom.c b/arch/mips/basler/excite/excite_prom.c
deleted file mode 100644 (file)
index 68d8bc5..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- *  Copyright (C) 2004, 2005 by Thomas Koeller (thomas.koeller@baslerweb.com)
- *  Based on the PMC-Sierra Yosemite board support by Ralf Baechle and
- *  Manish Lachwani.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/delay.h>
-#include <linux/smp.h>
-#include <linux/module.h>
-#include <asm/io.h>
-#include <asm/pgtable.h>
-#include <asm/processor.h>
-#include <asm/reboot.h>
-#include <asm/system.h>
-#include <asm/bootinfo.h>
-#include <asm/string.h>
-
-#include <excite.h>
-
-/* This struct is used by Redboot to pass arguments to the kernel */
-typedef struct
-{
-       char *name;
-       char *val;
-} t_env_var;
-
-struct parmblock {
-       t_env_var memsize;
-       t_env_var modetty0;
-       t_env_var ethaddr;
-       t_env_var env_end;
-       char *argv[2];
-       char text[0];
-};
-
-static unsigned int prom_argc;
-static const char ** prom_argv;
-static const t_env_var * prom_env;
-
-static void prom_halt(void) __attribute__((noreturn));
-static void prom_exit(void) __attribute__((noreturn));
-
-
-
-const char *get_system_type(void)
-{
-       return "Basler eXcite";
-}
-
-/*
- * Halt the system
- */
-static void prom_halt(void)
-{
-       printk(KERN_NOTICE "\n** System halted.\n");
-       while (1)
-               asm volatile (
-                       "\t.set\tmips3\n"
-                       "\twait\n"
-                       "\t.set\tmips0\n"
-               );
-}
-
-/*
- * Reset the CPU and re-enter Redboot
- */
-static void prom_exit(void)
-{
-       unsigned int i;
-       volatile unsigned char * const flg =
-               (volatile unsigned char *) (EXCITE_ADDR_FPGA + EXCITE_FPGA_DPR);
-
-       /* Clear the watchdog reset flag, set the reboot flag */
-       *flg &= ~0x01;
-       *flg |= 0x80;
-
-       for (i = 0; i < 10; i++) {
-               *(volatile unsigned char *)  (EXCITE_ADDR_FPGA + EXCITE_FPGA_SYSCTL) = 0x02;
-               iob();
-               mdelay(1000);
-       }
-
-       printk(KERN_NOTICE "Reset failed\n");
-       prom_halt();
-}
-
-static const char __init *prom_getenv(char *name)
-{
-       const t_env_var * p;
-       for (p = prom_env; p->name != NULL; p++)
-               if(strcmp(name, p->name) == 0)
-                       break;
-       return p->val;
-}
-
-/*
- * Init routine which accepts the variables from Redboot
- */
-void __init prom_init(void)
-{
-       const struct parmblock * const pb = (struct parmblock *) fw_arg2;
-
-       prom_argc = fw_arg0;
-       prom_argv = (const char **) fw_arg1;
-       prom_env = &pb->memsize;
-
-       /* Callbacks for halt, restart */
-       _machine_restart = (void (*)(char *)) prom_exit;
-       _machine_halt = prom_halt;
-
-#ifdef CONFIG_32BIT
-       /* copy command line */
-       strcpy(arcs_cmdline, prom_argv[1]);
-       memsize = simple_strtol(prom_getenv("memsize"), NULL, 16);
-       strcpy(modetty, prom_getenv("modetty0"));
-#endif /* CONFIG_32BIT */
-
-#ifdef CONFIG_64BIT
-#      error 64 bit support not implemented
-#endif /* CONFIG_64BIT */
-}
-
-/* This is called from free_initmem(), so we need to provide it */
-void __init prom_free_prom_memory(void)
-{
-       /* Nothing to do */
-}
diff --git a/arch/mips/basler/excite/excite_setup.c b/arch/mips/basler/excite/excite_setup.c
deleted file mode 100644 (file)
index d66b3b8..0000000
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- *  Copyright (C) 2004, 2005 by Basler Vision Technologies AG
- *  Author: Thomas Koeller <thomas.koeller@baslerweb.com>
- *  Based on the PMC-Sierra Yosemite board support by Ralf Baechle and
- *  Manish Lachwani.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/tty.h>
-#include <linux/serial_core.h>
-#include <linux/serial.h>
-#include <linux/serial_8250.h>
-#include <linux/ioport.h>
-#include <linux/spinlock.h>
-#include <asm/bootinfo.h>
-#include <asm/mipsregs.h>
-#include <asm/pgtable-32.h>
-#include <asm/io.h>
-#include <asm/time.h>
-#include <asm/rm9k-ocd.h>
-
-#include <excite.h>
-
-#define TITAN_UART_CLK 25000000
-
-#if 1
-/* normal serial port assignment */
-#define REGBASE_SER0   0x0208
-#define REGBASE_SER1   0x0238
-#define MASK_SER0      0x1
-#define MASK_SER1      0x2
-#else
-/* serial ports swapped */
-#define REGBASE_SER0   0x0238
-#define REGBASE_SER1   0x0208
-#define MASK_SER0      0x2
-#define MASK_SER1      0x1
-#endif
-
-unsigned long memsize;
-char modetty[30];
-unsigned int titan_irq = TITAN_IRQ;
-static void __iomem * ctl_regs;
-u32 unit_id;
-
-volatile void __iomem * const ocd_base = (void *) (EXCITE_ADDR_OCD);
-volatile void __iomem * const titan_base = (void *) (EXCITE_ADDR_TITAN);
-
-/* Protect access to shared GPI registers */
-DEFINE_SPINLOCK(titan_lock);
-int titan_irqflags;
-
-
-/*
- * The eXcite platform uses the alternate timer interrupt
- *
- * Fixme: At the time of this writing cevt-r4k.c doesn't yet know about how
- * to handle the alternate timer interrupt of the RM9000.
- */
-void __init plat_time_init(void)
-{
-       const u32 modebit5 = ocd_readl(0x00e4);
-       unsigned int mult = ((modebit5 >> 11) & 0x1f) + 2;
-       unsigned int div = ((modebit5 >> 16) & 0x1f) + 2;
-
-       if (div == 33)
-               div = 1;
-       mips_hpt_frequency = EXCITE_CPU_EXT_CLOCK * mult / div / 2;
-}
-
-static int __init excite_init_console(void)
-{
-#if defined(CONFIG_SERIAL_8250)
-       static __initdata char serr[] =
-               KERN_ERR "Serial port #%u setup failed\n";
-       struct uart_port up;
-
-       /* Take the DUART out of reset */
-       titan_writel(0x00ff1cff, CPRR);
-
-#if (CONFIG_SERIAL_8250_NR_UARTS > 1)
-       /* Enable both ports */
-       titan_writel(MASK_SER0 | MASK_SER1, UACFG);
-#else
-       /* Enable port #0 only */
-       titan_writel(MASK_SER0, UACFG);
-#endif
-
-       /*
-        * Set up serial port #0. Do not use autodetection; the result is
-        * not what we want.
-        */
-       memset(&up, 0, sizeof(up));
-       up.membase      = (char *) titan_addr(REGBASE_SER0);
-       up.irq          = TITAN_IRQ;
-       up.uartclk      = TITAN_UART_CLK;
-       up.regshift     = 0;
-       up.iotype       = UPIO_RM9000;
-       up.type         = PORT_RM9000;
-       up.flags        = UPF_SHARE_IRQ;
-       up.line         = 0;
-       if (early_serial_setup(&up))
-               printk(serr, up.line);
-
-#if CONFIG_SERIAL_8250_NR_UARTS > 1
-       /* And now for port #1. */
-       up.membase      = (char *) titan_addr(REGBASE_SER1);
-       up.line         = 1;
-       if (early_serial_setup(&up))
-               printk(serr, up.line);
-#endif /* CONFIG_SERIAL_8250_NR_UARTS > 1 */
-#else
-       /* Leave the DUART in reset */
-       titan_writel(0x00ff3cff, CPRR);
-#endif  /* defined(CONFIG_SERIAL_8250) */
-
-       return 0;
-}
-
-static int __init excite_platform_init(void)
-{
-       unsigned int i;
-       unsigned char buf[3];
-       u8 reg;
-       void __iomem * dpr;
-
-       /* BIU buffer allocations */
-       ocd_writel(8, CPURSLMT);        /* CPU */
-       titan_writel(4, CPGRWL);        /* GPI / Ethernet */
-
-       /* Map control registers located in FPGA */
-       ctl_regs = ioremap_nocache(EXCITE_PHYS_FPGA + EXCITE_FPGA_SYSCTL, 16);
-       if (!ctl_regs)
-               panic("eXcite: failed to map platform control registers\n");
-       memcpy_fromio(buf, ctl_regs + 2, ARRAY_SIZE(buf));
-       unit_id = buf[0] | (buf[1] << 8) | (buf[2] << 16);
-
-       /* Clear the reboot flag */
-       dpr = ioremap_nocache(EXCITE_PHYS_FPGA + EXCITE_FPGA_DPR, 1);
-       reg = __raw_readb(dpr);
-       __raw_writeb(reg & 0x7f, dpr);
-       iounmap(dpr);
-
-       /* Interrupt controller setup */
-       for (i = INTP0Status0; i < INTP0Status0 + 0x80; i += 0x10) {
-               ocd_writel(0x00000000, i + 0x04);
-               ocd_writel(0xffffffff, i + 0x0c);
-       }
-       ocd_writel(0x2, NMICONFIG);
-
-       ocd_writel(0x1 << (TITAN_MSGINT % 0x20),
-                  INTP0Mask0 + (0x10 * (TITAN_MSGINT / 0x20)));
-       ocd_writel((0x1 << (FPGA0_MSGINT % 0x20))
-                  | ocd_readl(INTP0Mask0 + (0x10 * (FPGA0_MSGINT / 0x20))),
-                  INTP0Mask0 + (0x10 * (FPGA0_MSGINT / 0x20)));
-       ocd_writel((0x1 << (FPGA1_MSGINT % 0x20))
-                  | ocd_readl(INTP0Mask0 + (0x10 * (FPGA1_MSGINT / 0x20))),
-                  INTP0Mask0 + (0x10 * (FPGA1_MSGINT / 0x20)));
-       ocd_writel((0x1 << (PHY_MSGINT % 0x20))
-                  | ocd_readl(INTP0Mask0 + (0x10 * (PHY_MSGINT / 0x20))),
-                  INTP0Mask0 + (0x10 * (PHY_MSGINT / 0x20)));
-#if USB_IRQ < 10
-       ocd_writel((0x1 << (USB_MSGINT % 0x20))
-                  | ocd_readl(INTP0Mask0 + (0x10 * (USB_MSGINT / 0x20))),
-                  INTP0Mask0 + (0x10 * (USB_MSGINT / 0x20)));
-#endif
-       /* Enable the packet FIFO, XDMA and XDMA arbiter */
-       titan_writel(0x00ff18ff, CPRR);
-
-       /*
-        * Set up the PADMUX. Power down all ethernet slices,
-        * they will be powered up and configured at device startup.
-        */
-       titan_writel(0x00878206, CPTC1R);
-       titan_writel(0x00001100, CPTC0R); /* latch PADMUX, enable WCIMODE */
-
-       /* Reset and enable the FIFO block */
-       titan_writel(0x00000001, SDRXFCIE);
-       titan_writel(0x00000001, SDTXFCIE);
-       titan_writel(0x00000100, SDRXFCIE);
-       titan_writel(0x00000000, SDTXFCIE);
-
-       /*
-        * Initialize the common interrupt shared by all components of
-        * the GPI/Ethernet subsystem.
-        */
-       titan_writel((EXCITE_PHYS_OCD >> 12), CPCFG0);
-       titan_writel(TITAN_MSGINT, CPCFG1);
-
-       /*
-        * XDMA configuration.
-        * In order for the XDMA to be sharable among multiple drivers,
-        * the setup must be done here in the platform. The reason is that
-        * this setup can only be done while the XDMA is in reset. If this
-        * were done in a driver, it would interrupt all other drivers
-        * using the XDMA.
-        */
-       titan_writel(0x80021dff, GXCFG);        /* XDMA reset */
-       titan_writel(0x00000000, CPXCISRA);
-       titan_writel(0x00000000, CPXCISRB);     /* clear pending interrupts */
-#if defined(CONFIG_HIGHMEM)
-#      error change for HIGHMEM support!
-#else
-       titan_writel(0x00000000, GXDMADRPFX);   /* buffer address prefix */
-#endif
-       titan_writel(0, GXDMA_DESCADR);
-
-       for (i = 0x5040; i <= 0x5300; i += 0x0040)
-               titan_writel(0x80080000, i);    /* reset channel */
-
-       titan_writel((0x1 << 29)                        /* no sparse tx descr. */
-                    | (0x1 << 28)                      /* no sparse rx descr. */
-                    | (0x1 << 23) | (0x1 << 24)        /* descriptor coherency */
-                    | (0x1 << 21) | (0x1 << 22)        /* data coherency */
-                    | (0x1 << 17)
-                    | 0x1dff,
-                    GXCFG);
-
-#if defined(CONFIG_SMP)
-#      error No SMP support
-#else
-       /* All interrupts go to core #0 only. */
-       titan_writel(0x1f007fff, CPDST0A);
-       titan_writel(0x00000000, CPDST0B);
-       titan_writel(0x0000ff3f, CPDST1A);
-       titan_writel(0x00000000, CPDST1B);
-       titan_writel(0x00ffffff, CPXDSTA);
-       titan_writel(0x00000000, CPXDSTB);
-#endif
-
-       /* Enable DUART interrupts, disable everything else. */
-       titan_writel(0x04000000, CPGIG0ER);
-       titan_writel(0x000000c0, CPGIG1ER);
-
-       excite_procfs_init();
-       return 0;
-}
-
-void __init plat_mem_setup(void)
-{
-       volatile u32 * const boot_ocd_base = (u32 *) 0xbf7fc000;
-
-       /* Announce RAM to system */
-       add_memory_region(0x00000000, memsize, BOOT_MEM_RAM);
-
-       /* Set up the peripheral address map */
-       *(boot_ocd_base + (LKB9 / sizeof(u32))) = 0;
-       *(boot_ocd_base + (LKB10 / sizeof(u32))) = 0;
-       *(boot_ocd_base + (LKB11 / sizeof(u32))) = 0;
-       *(boot_ocd_base + (LKB12 / sizeof(u32))) = 0;
-       wmb();
-       *(boot_ocd_base + (LKB0 / sizeof(u32))) = EXCITE_PHYS_OCD >> 4;
-       wmb();
-
-       ocd_writel((EXCITE_PHYS_TITAN >> 4) | 0x1UL, LKB5);
-       ocd_writel(((EXCITE_SIZE_TITAN >> 4) & 0x7fffff00) - 0x100, LKM5);
-       ocd_writel((EXCITE_PHYS_SCRAM >> 4) | 0x1UL, LKB13);
-       ocd_writel(((EXCITE_SIZE_SCRAM >> 4) & 0xffffff00) - 0x100, LKM13);
-
-       /* Local bus slot #0 */
-       ocd_writel(0x00040510, LDP0);
-       ocd_writel((EXCITE_PHYS_BOOTROM >> 4) | 0x1UL, LKB9);
-       ocd_writel(((EXCITE_SIZE_BOOTROM >> 4) & 0x03ffff00) - 0x100, LKM9);
-
-       /* Local bus slot #2 */
-       ocd_writel(0x00000330, LDP2);
-       ocd_writel((EXCITE_PHYS_FPGA >> 4) | 0x1, LKB11);
-       ocd_writel(((EXCITE_SIZE_FPGA >> 4) - 0x100) & 0x03ffff00, LKM11);
-
-       /* Local bus slot #3 */
-       ocd_writel(0x00123413, LDP3);
-       ocd_writel((EXCITE_PHYS_NAND >> 4) | 0x1, LKB12);
-       ocd_writel(((EXCITE_SIZE_NAND >> 4) - 0x100) & 0x03ffff00, LKM12);
-}
-
-
-
-console_initcall(excite_init_console);
-arch_initcall(excite_platform_init);
-
-EXPORT_SYMBOL(titan_lock);
-EXPORT_SYMBOL(titan_irqflags);
-EXPORT_SYMBOL(titan_irq);
-EXPORT_SYMBOL(ocd_base);
-EXPORT_SYMBOL(titan_base);
index fb284c3b2cff4082626f425f54a700798b9f2da5..c51405e5792117d868b99dc2fe21c30c8f06061d 100644 (file)
@@ -100,11 +100,11 @@ static __init void prom_init_console(void)
 
 static __init void prom_init_cmdline(void)
 {
-       static char buf[CL_SIZE] __initdata;
+       static char buf[COMMAND_LINE_SIZE] __initdata;
 
        /* Get the kernel command line from CFE */
-       if (cfe_getenv("LINUX_CMDLINE", buf, CL_SIZE) >= 0) {
-               buf[CL_SIZE-1] = 0;
+       if (cfe_getenv("LINUX_CMDLINE", buf, COMMAND_LINE_SIZE) >= 0) {
+               buf[COMMAND_LINE_SIZE - 1] = 0;
                strcpy(arcs_cmdline, buf);
        }
 
@@ -112,13 +112,13 @@ static __init void prom_init_cmdline(void)
         * as CFE is not available anymore later in the boot process. */
        if ((strstr(arcs_cmdline, "console=")) == NULL) {
                /* Try to read the default serial port used by CFE */
-               if ((cfe_getenv("BOOT_CONSOLE", buf, CL_SIZE) < 0)
+               if ((cfe_getenv("BOOT_CONSOLE", buf, COMMAND_LINE_SIZE) < 0)
                    || (strncmp("uart", buf, 4)))
                        /* Default to uart0 */
                        strcpy(buf, "uart0");
 
                /* Compute the new command line */
-               snprintf(arcs_cmdline, CL_SIZE, "%s console=ttyS%c,115200",
+               snprintf(arcs_cmdline, COMMAND_LINE_SIZE, "%s console=ttyS%c,115200",
                         arcs_cmdline, buf[4]);
        }
 }
index 2a209d74f0b4fa70993075e39073649b5d1abd38..094bc84765a3e276f6585d8eb6e680f8b2d02bbf 100644 (file)
@@ -25,7 +25,7 @@ strip-flags   = $(addprefix --remove-section=,$(drop-sections))
 
 VMLINUX = vmlinux
 
-all: vmlinux.ecoff vmlinux.srec addinitrd
+all: vmlinux.ecoff vmlinux.srec
 
 vmlinux.ecoff: $(obj)/elf2ecoff $(VMLINUX)
        $(obj)/elf2ecoff $(VMLINUX) vmlinux.ecoff $(E2EFLAGS)
@@ -39,11 +39,7 @@ vmlinux.bin: $(VMLINUX)
 vmlinux.srec: $(VMLINUX)
        $(OBJCOPY) -S -O srec $(strip-flags) $(VMLINUX) $(obj)/vmlinux.srec
 
-$(obj)/addinitrd: $(obj)/addinitrd.c
-       $(HOSTCC) -o $@ $^
-
-clean-files += addinitrd \
-              elf2ecoff \
+clean-files += elf2ecoff \
               vmlinux.bin \
               vmlinux.ecoff \
               vmlinux.srec
diff --git a/arch/mips/boot/addinitrd.c b/arch/mips/boot/addinitrd.c
deleted file mode 100644 (file)
index b5b3feb..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * addinitrd - program to add a initrd image to an ecoff kernel
- *
- * (C) 1999 Thomas Bogendoerfer
- * minor modifications, cleanup: Guido Guenther <agx@sigxcpu.org>
- * further cleanup: Maciej W. Rozycki
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <netinet/in.h>
-
-#include "ecoff.h"
-
-#define MIPS_PAGE_SIZE 4096
-#define MIPS_PAGE_MASK (MIPS_PAGE_SIZE-1)
-
-#define swab16(x) \
-        ((unsigned short)( \
-                (((unsigned short)(x) & (unsigned short)0x00ffU) << 8) | \
-                (((unsigned short)(x) & (unsigned short)0xff00U) >> 8) ))
-
-#define swab32(x) \
-        ((unsigned int)( \
-                (((unsigned int)(x) & (unsigned int)0x000000ffUL) << 24) | \
-                (((unsigned int)(x) & (unsigned int)0x0000ff00UL) <<  8) | \
-                (((unsigned int)(x) & (unsigned int)0x00ff0000UL) >>  8) | \
-                (((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24) ))
-
-#define SWAB(a)        (swab ? swab32(a) : (a))
-
-void die(char *s)
-{
-       perror(s);
-       exit(1);
-}
-
-int main(int argc, char *argv[])
-{
-       int fd_vmlinux, fd_initrd, fd_outfile;
-       FILHDR efile;
-       AOUTHDR eaout;
-       SCNHDR esecs[3];
-       struct stat st;
-       char buf[1024];
-       unsigned long loadaddr;
-       unsigned long initrd_header[2];
-       int i, cnt;
-       int swab = 0;
-
-       if (argc != 4) {
-               printf("Usage: %s <vmlinux> <initrd> <outfile>\n", argv[0]);
-               exit(1);
-       }
-
-       if ((fd_vmlinux = open (argv[1], O_RDONLY)) < 0)
-                die("open vmlinux");
-       if (read (fd_vmlinux, &efile, sizeof efile) != sizeof efile)
-               die("read file header");
-       if (read (fd_vmlinux, &eaout, sizeof eaout) != sizeof eaout)
-               die("read aout header");
-       if (read (fd_vmlinux, esecs, sizeof esecs) != sizeof esecs)
-               die("read section headers");
-       /*
-        * check whether the file is good for us
-        */
-       /* TBD */
-
-       /*
-        * check, if we have to swab words
-        */
-       if (ntohs(0xaa55) == 0xaa55) {
-               if (efile.f_magic == swab16(MIPSELMAGIC))
-                       swab = 1;
-       } else {
-               if (efile.f_magic == swab16(MIPSEBMAGIC))
-                       swab = 1;
-       }
-
-       /* make sure we have an empty data segment for the initrd */
-       if (eaout.dsize || esecs[1].s_size) {
-               fprintf(stderr, "Data segment not empty. Giving up!\n");
-               exit(1);
-       }
-       if ((fd_initrd = open (argv[2], O_RDONLY)) < 0)
-               die("open initrd");
-       if (fstat (fd_initrd, &st) < 0)
-               die("fstat initrd");
-       loadaddr = ((SWAB(esecs[2].s_vaddr) + SWAB(esecs[2].s_size)
-                       + MIPS_PAGE_SIZE-1) & ~MIPS_PAGE_MASK) - 8;
-       if (loadaddr < (SWAB(esecs[2].s_vaddr) + SWAB(esecs[2].s_size)))
-               loadaddr += MIPS_PAGE_SIZE;
-       initrd_header[0] = SWAB(0x494E5244);
-       initrd_header[1] = SWAB(st.st_size);
-       eaout.dsize = esecs[1].s_size = initrd_header[1] = SWAB(st.st_size+8);
-       eaout.data_start = esecs[1].s_vaddr = esecs[1].s_paddr = SWAB(loadaddr);
-
-       if ((fd_outfile = open (argv[3], O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0)
-               die("open outfile");
-       if (write (fd_outfile, &efile, sizeof efile) != sizeof efile)
-               die("write file header");
-       if (write (fd_outfile, &eaout, sizeof eaout) != sizeof eaout)
-               die("write aout header");
-       if (write (fd_outfile, esecs, sizeof esecs) != sizeof esecs)
-               die("write section headers");
-       /* skip padding */
-       if(lseek(fd_vmlinux, SWAB(esecs[0].s_scnptr), SEEK_SET) == (off_t)-1)
-               die("lseek vmlinux");
-       if(lseek(fd_outfile, SWAB(esecs[0].s_scnptr), SEEK_SET) == (off_t)-1)
-               die("lseek outfile");
-       /* copy text segment */
-       cnt = SWAB(eaout.tsize);
-       while (cnt) {
-               if ((i = read (fd_vmlinux, buf, sizeof buf)) <= 0)
-                       die("read vmlinux");
-               if (write (fd_outfile, buf, i) != i)
-                       die("write vmlinux");
-               cnt -= i;
-       }
-       if (write (fd_outfile, initrd_header, sizeof initrd_header) != sizeof initrd_header)
-               die("write initrd header");
-       while ((i = read (fd_initrd, buf, sizeof buf)) > 0)
-               if (write (fd_outfile, buf, i) != i)
-                       die("write initrd");
-       close(fd_vmlinux);
-       close(fd_initrd);
-       return 0;
-}
diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
new file mode 100644 (file)
index 0000000..e27f40b
--- /dev/null
@@ -0,0 +1,100 @@
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License.
+#
+# Adapted for MIPS Pete Popov, Dan Malek
+#
+# Copyright (C) 1994 by Linus Torvalds
+# Adapted for PowerPC by Gary Thomas
+# modified by Cort (cort@cs.nmt.edu)
+#
+# Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University
+# Author: Wu Zhangjin <wuzj@lemote.com>
+#
+
+# compressed kernel load addr: VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE
+VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | cut -d' ' -f1)
+VMLINUX_SIZE := $(shell [ -n "$(VMLINUX_SIZE)" ] && echo $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))
+VMLINUZ_LOAD_ADDRESS := 0x$(shell [ -n "$(VMLINUX_SIZE)" ] && printf %x $$(($(VMLINUX_LOAD_ADDRESS) + $(VMLINUX_SIZE))))
+
+# set the default size of the mallocing area for decompressing
+BOOT_HEAP_SIZE := 0x400000
+
+# Disable Function Tracer
+KBUILD_CFLAGS := $(shell echo $(KBUILD_CFLAGS) | sed -e "s/-pg//")
+
+KBUILD_CFLAGS := $(LINUXINCLUDE) $(KBUILD_CFLAGS) -D__KERNEL__ \
+       -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" \
+
+KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
+       -DKERNEL_ENTRY=0x$(shell $(NM) $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | grep " kernel_entry" | cut -f1 -d \ ) \
+       -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE)
+
+obj-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o
+
+obj-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
+
+OBJCOPYFLAGS_vmlinux.bin := $(OBJCOPYFLAGS) -O binary -R .comment -S
+$(obj)/vmlinux.bin: $(KBUILD_IMAGE)
+       $(call if_changed,objcopy)
+
+suffix_$(CONFIG_KERNEL_GZIP)  = gz
+suffix_$(CONFIG_KERNEL_BZIP2) = bz2
+suffix_$(CONFIG_KERNEL_LZMA)  = lzma
+tool_$(CONFIG_KERNEL_GZIP)    = gzip
+tool_$(CONFIG_KERNEL_BZIP2)   = bzip2
+tool_$(CONFIG_KERNEL_LZMA)    = lzma
+$(obj)/vmlinux.$(suffix_y): $(obj)/vmlinux.bin
+       $(call if_changed,$(tool_y))
+
+$(obj)/piggy.o: $(obj)/vmlinux.$(suffix_y) $(obj)/dummy.o
+       $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) \
+               --add-section=.image=$< \
+               --set-section-flags=.image=contents,alloc,load,readonly,data \
+               $(obj)/dummy.o $@
+
+LDFLAGS_vmlinuz := $(LDFLAGS) -Ttext $(VMLINUZ_LOAD_ADDRESS) -T
+vmlinuz: $(src)/ld.script $(obj-y) $(obj)/piggy.o
+       $(call if_changed,ld)
+       $(Q)$(OBJCOPY) $(OBJCOPYFLAGS) -R .comment -R .stab -R .stabstr -R .initrd -R .sysmap $@
+
+#
+# Some DECstations need all possible sections of an ECOFF executable
+#
+ifdef CONFIG_MACH_DECSTATION
+  E2EFLAGS = -a
+else
+  E2EFLAGS =
+endif
+
+# elf2ecoff can only handle 32bit image
+
+ifdef CONFIG_32BIT
+       VMLINUZ = vmlinuz
+else
+       VMLINUZ = vmlinuz.32
+endif
+
+vmlinuz.32: vmlinuz
+       $(Q)$(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
+
+vmlinuz.ecoff: $(obj)/../elf2ecoff $(VMLINUZ)
+       $(Q)$(obj)/../elf2ecoff $(VMLINUZ) vmlinuz.ecoff $(E2EFLAGS)
+
+$(obj)/../elf2ecoff: $(src)/../elf2ecoff.c
+       $(Q)$(HOSTCC) -o $@ $^
+
+drop-sections  = .reginfo .mdebug .comment .note .pdr .options .MIPS.options
+strip-flags    = $(addprefix --remove-section=,$(drop-sections))
+
+OBJCOPYFLAGS_vmlinuz.bin := $(OBJCOPYFLAGS) -O binary $(strip-flags)
+vmlinuz.bin: vmlinuz
+       $(call if_changed,objcopy)
+
+OBJCOPYFLAGS_vmlinuz.srec := $(OBJCOPYFLAGS) -S -O srec $(strip-flags)
+vmlinuz.srec: vmlinuz
+       $(call if_changed,objcopy)
+
+clean:
+clean-files += *.o \
+              vmlinu*
diff --git a/arch/mips/boot/compressed/dbg.c b/arch/mips/boot/compressed/dbg.c
new file mode 100644 (file)
index 0000000..ff4dc7a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * MIPS-specific debug support for pre-boot environment
+ *
+ * NOTE: putc() is board specific, if your board have a 16550 compatible uart,
+ * please select SYS_SUPPORTS_ZBOOT_UART16550 for your machine. othewise, you
+ * need to implement your own putc().
+ */
+
+#include <linux/init.h>
+#include <linux/types.h>
+
+void __attribute__ ((weak)) putc(char c)
+{
+}
+
+void puts(const char *s)
+{
+       char c;
+       while ((c = *s++) != '\0') {
+               putc(c);
+               if (c == '\n')
+                       putc('\r');
+       }
+}
+
+void puthex(unsigned long long val)
+{
+
+       unsigned char buf[10];
+       int i;
+       for (i = 7; i >= 0; i--) {
+               buf[i] = "0123456789ABCDEF"[val & 0x0F];
+               val >>= 4;
+       }
+       buf[8] = '\0';
+       puts(buf);
+}
diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c
new file mode 100644 (file)
index 0000000..67330c2
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Misc. bootloader code for many machines.
+ *
+ * Copyright 2001 MontaVista Software Inc.
+ * Author: Matt Porter <mporter@mvista.com> Derived from
+ * arch/ppc/boot/prep/misc.c
+ *
+ * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology
+ * Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+#include <asm/addrspace.h>
+
+/* These two variables specify the free mem region
+ * that can be used for temporary malloc area
+ */
+unsigned long free_mem_ptr;
+unsigned long free_mem_end_ptr;
+char *zimage_start;
+
+/* The linker tells us where the image is. */
+extern unsigned char __image_begin, __image_end;
+extern unsigned char __ramdisk_begin, __ramdisk_end;
+unsigned long initrd_size;
+
+/* debug interfaces  */
+extern void puts(const char *s);
+extern void puthex(unsigned long long val);
+
+void error(char *x)
+{
+       puts("\n\n");
+       puts(x);
+       puts("\n\n -- System halted");
+
+       while (1)
+               ;       /* Halt */
+}
+
+/* activate the code for pre-boot environment */
+#define STATIC static
+
+#ifdef CONFIG_KERNEL_GZIP
+void *memcpy(void *dest, const void *src, size_t n)
+{
+       int i;
+       const char *s = src;
+       char *d = dest;
+
+       for (i = 0; i < n; i++)
+               d[i] = s[i];
+       return dest;
+}
+#include "../../../../lib/decompress_inflate.c"
+#endif
+
+#ifdef CONFIG_KERNEL_BZIP2
+void *memset(void *s, int c, size_t n)
+{
+       int i;
+       char *ss = s;
+
+       for (i = 0; i < n; i++)
+               ss[i] = c;
+       return s;
+}
+#include "../../../../lib/decompress_bunzip2.c"
+#endif
+
+#ifdef CONFIG_KERNEL_LZMA
+#include "../../../../lib/decompress_unlzma.c"
+#endif
+
+void decompress_kernel(unsigned long boot_heap_start)
+{
+       int zimage_size;
+
+       /*
+        * We link ourself to an arbitrary low address.  When we run, we
+        * relocate outself to that address.  __image_beign points to
+        * the part of the image where the zImage is. -- Tom
+        */
+       zimage_start = (char *)(unsigned long)(&__image_begin);
+       zimage_size = (unsigned long)(&__image_end) -
+           (unsigned long)(&__image_begin);
+
+       /*
+        * The zImage and initrd will be between start and _end, so they've
+        * already been moved once.  We're good to go now. -- Tom
+        */
+       puts("zimage at:     ");
+       puthex((unsigned long)zimage_start);
+       puts(" ");
+       puthex((unsigned long)(zimage_size + zimage_start));
+       puts("\n");
+
+       if (initrd_size) {
+               puts("initrd at:     ");
+               puthex((unsigned long)(&__ramdisk_begin));
+               puts(" ");
+               puthex((unsigned long)(&__ramdisk_end));
+               puts("\n");
+       }
+
+       /* this area are prepared for mallocing when decompressing */
+       free_mem_ptr = boot_heap_start;
+       free_mem_end_ptr = boot_heap_start + BOOT_HEAP_SIZE;
+
+       /* Display standard Linux/MIPS boot prompt for kernel args */
+       puts("Uncompressing Linux at load address ");
+       puthex(VMLINUX_LOAD_ADDRESS_ULL);
+       puts("\n");
+       /* Decompress the kernel with according algorithm */
+       decompress(zimage_start, zimage_size, 0, 0,
+                  (void *)VMLINUX_LOAD_ADDRESS_ULL, 0, error);
+       /* FIXME: is there a need to flush cache here? */
+       puts("Now, booting the kernel...\n");
+}
diff --git a/arch/mips/boot/compressed/dummy.c b/arch/mips/boot/compressed/dummy.c
new file mode 100644 (file)
index 0000000..31dbf45
--- /dev/null
@@ -0,0 +1,4 @@
+int main(void)
+{
+       return 0;
+}
diff --git a/arch/mips/boot/compressed/head.S b/arch/mips/boot/compressed/head.S
new file mode 100644 (file)
index 0000000..4e65a84
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1994, 1995 Waldorf Electronics
+ * Written by Ralf Baechle and Andreas Busse
+ * Copyright (C) 1995 - 1999 Ralf Baechle
+ * Copyright (C) 1996 Paul M. Antoine
+ * Modified for DECStation and hence R3000 support by Paul M. Antoine
+ * Further modifications by David S. Miller and Harald Koerfgen
+ * Copyright (C) 1999 Silicon Graphics, Inc.
+ */
+
+#include <asm/asm.h>
+#include <asm/regdef.h>
+
+       .set noreorder
+       .cprestore
+       LEAF(start)
+start:
+       /* Save boot rom start args */
+       move    s0, a0
+       move    s1, a1
+       move    s2, a2
+       move    s3, a3
+
+       /* Clear BSS */
+       PTR_LA  a0, _edata
+       PTR_LA  a2, _end
+1:     sw      zero, 0(a0)
+       bne     a2, a0, 1b
+        addiu  a0, a0, 4
+
+       PTR_LA  a0, (.heap)          /* heap address */
+       PTR_LA  sp, (.stack + 8192)  /* stack address */
+
+       PTR_LA  ra, 2f
+       PTR_LA  k0, decompress_kernel
+       jr      k0
+        nop
+2:
+       move    a0, s0
+       move    a1, s1
+       move    a2, s2
+       move    a3, s3
+       PTR_LI  k0, KERNEL_ENTRY
+       jr      k0
+        nop
+3:
+       b       3b
+        nop
+       END(start)
+
+       .comm .heap,BOOT_HEAP_SIZE,4
+       .comm .stack,4096*2,4
diff --git a/arch/mips/boot/compressed/ld.script b/arch/mips/boot/compressed/ld.script
new file mode 100644 (file)
index 0000000..29e9f4c
--- /dev/null
@@ -0,0 +1,150 @@
+OUTPUT_ARCH(mips)
+ENTRY(start)
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  .init          : { *(.init)          } =0
+  .text      :
+  {
+    _ftext = . ;
+    *(.text)
+    *(.rodata)
+    *(.rodata1)
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+  } =0
+  .kstrtab : { *(.kstrtab) }
+
+  . = ALIGN(16);               /* Exception table */
+  __start___ex_table = .;
+  __ex_table : { *(__ex_table) }
+  __stop___ex_table = .;
+
+  __start___dbe_table = .;     /* Exception table for data bus errors */
+  __dbe_table : { *(__dbe_table) }
+  __stop___dbe_table = .;
+
+  __start___ksymtab = .;       /* Kernel symbol table */
+  __ksymtab : { *(__ksymtab) }
+  __stop___ksymtab = .;
+
+  _etext = .;
+
+  . = ALIGN(8192);
+  .data.init_task : { *(.data.init_task) }
+
+  /* Startup code */
+  . = ALIGN(4096);
+  __init_begin = .;
+  .text.init : { *(.text.init) }
+  .data.init : { *(.data.init) }
+  . = ALIGN(16);
+  __setup_start = .;
+  .setup.init : { *(.setup.init) }
+  __setup_end = .;
+  __initcall_start = .;
+  .initcall.init : { *(.initcall.init) }
+  __initcall_end = .;
+  . = ALIGN(4096);     /* Align double page for init_task_union */
+  __init_end = .;
+
+  . = ALIGN(4096);
+  .data.page_aligned : { *(.data.idt) }
+
+  . = ALIGN(32);
+  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
+
+  .fini      : { *(.fini)    } =0
+  .reginfo : { *(.reginfo) }
+  /* Adjust the address for the data segment.  We want to adjust up to
+     the same address within the page on the next page up.  It would
+     be more correct to do this:
+       . = .;
+     The current expression does not correctly handle the case of a
+     text segment ending precisely at the end of a page; it causes the
+     data segment to skip a page.  The above expression does not have
+     this problem, but it will currently (2/95) cause BFD to allocate
+     a single segment, combining both text and data, for this case.
+     This will prevent the text segment from being shared among
+     multiple executions of the program; I think that is more
+     important than losing a page of the virtual address space (note
+     that no actual memory is lost; the page which is skipped can not
+     be referenced).  */
+  . = .;
+  .data    :
+  {
+    _fdata = . ;
+    *(.data)
+
+   /* Put the compressed image here, so bss is on the end. */
+   __image_begin = .;
+   *(.image)
+   __image_end = .;
+   /* Align the initial ramdisk image (INITRD) on page boundaries. */
+   . = ALIGN(4096);
+   __ramdisk_begin = .;
+   *(.initrd)
+   __ramdisk_end = .;
+   . = ALIGN(4096);
+
+    CONSTRUCTORS
+  }
+  .data1   : { *(.data1) }
+  _gp = . + 0x8000;
+  .lit8 : { *(.lit8) }
+  .lit4 : { *(.lit4) }
+  .ctors         : { *(.ctors)   }
+  .dtors         : { *(.dtors)   }
+  .got           : { *(.got.plt) *(.got) }
+  .dynamic       : { *(.dynamic) }
+  /* We want the small data sections together, so single-instruction offsets
+     can access them all, and initialized data all before uninitialized, so
+     we can shorten the on-disk segment size.  */
+  .sdata     : { *(.sdata) }
+  . = ALIGN(4);
+  _edata  =  .;
+  PROVIDE (edata = .);
+
+  __bss_start = .;
+  _fbss = .;
+  .sbss      : { *(.sbss) *(.scommon) }
+  .bss       :
+  {
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+   .  = ALIGN(4);
+  _end = . ;
+  PROVIDE (end = .);
+  }
+
+  /* Sections to be discarded */
+  /DISCARD/ :
+  {
+        *(.text.exit)
+        *(.data.exit)
+        *(.exitcall.exit)
+  }
+
+  /* This is the MIPS specific mdebug section.  */
+  .mdebug : { *(.mdebug) }
+  /* These are needed for ELF backends which have not yet been
+     converted to the new style linker.  */
+  .stab 0 : { *(.stab) }
+  .stabstr 0 : { *(.stabstr) }
+  /* DWARF debug sections.
+     Symbols in the .debug DWARF section are relative to the beginning of the
+     section so we begin .debug at 0.  It's not clear yet what needs to happen
+     for the others.   */
+  .debug          0 : { *(.debug) }
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+  .line           0 : { *(.line) }
+  /* These must appear regardless of  .  */
+  .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+  .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+  .comment : { *(.comment) }
+  .note : { *(.note) }
+}
diff --git a/arch/mips/boot/compressed/uart-16550.c b/arch/mips/boot/compressed/uart-16550.c
new file mode 100644 (file)
index 0000000..c9caaf4
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 16550 compatible uart based serial debug support for zboot
+ */
+
+#include <linux/types.h>
+#include <linux/serial_reg.h>
+#include <linux/init.h>
+
+#include <asm/addrspace.h>
+
+#if defined(CONFIG_MACH_LOONGSON) || defined(CONFIG_MIPS_MALTA)
+#define UART_BASE 0x1fd003f8
+#define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
+#endif
+
+#ifdef CONFIG_AR7
+#include <ar7.h>
+#define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
+#endif
+
+#ifndef PORT
+#error please define the serial port address for your own machine
+#endif
+
+static inline unsigned int serial_in(int offset)
+{
+       return *((char *)PORT(offset));
+}
+
+static inline void serial_out(int offset, int value)
+{
+       *((char *)PORT(offset)) = value;
+}
+
+void putc(char c)
+{
+       int timeout = 1024;
+
+       while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
+               ;
+
+       serial_out(UART_TX, c);
+}
index 139436280520698e5d6d8221e1bd6d9c9e405a33..3e9876317e61c2c040021a6b3e91a7e7f3b2bb2a 100644 (file)
@@ -9,7 +9,7 @@
 # Copyright (C) 2005-2009 Cavium Networks
 #
 
-obj-y := setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o
+obj-y := cpu.o setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o
 obj-y += dma-octeon.o flash_setup.o
 obj-y += octeon-memcpy.o
 
diff --git a/arch/mips/cavium-octeon/cpu.c b/arch/mips/cavium-octeon/cpu.c
new file mode 100644 (file)
index 0000000..b6df538
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2009 Wind River Systems,
+ *   written by Ralf Baechle <ralf@linux-mips.org>
+ */
+#include <linux/init.h>
+#include <linux/irqflags.h>
+#include <linux/notifier.h>
+#include <linux/prefetch.h>
+#include <linux/sched.h>
+
+#include <asm/cop2.h>
+#include <asm/current.h>
+#include <asm/mipsregs.h>
+#include <asm/page.h>
+#include <asm/octeon/octeon.h>
+
+static int cnmips_cu2_call(struct notifier_block *nfb, unsigned long action,
+       void *data)
+{
+       unsigned long flags;
+       unsigned int status;
+
+       switch (action) {
+       case CU2_EXCEPTION:
+               prefetch(&current->thread.cp2);
+               local_irq_save(flags);
+               KSTK_STATUS(current) |= ST0_CU2;
+               status = read_c0_status();
+               write_c0_status(status | ST0_CU2);
+               octeon_cop2_restore(&(current->thread.cp2));
+               write_c0_status(status & ~ST0_CU2);
+               local_irq_restore(flags);
+
+               return NOTIFY_BAD;      /* Don't call default notifier */
+       }
+
+       return NOTIFY_OK;               /* Let default notifier send signals */
+}
+
+static struct notifier_block cnmips_cu2_notifier = {
+       .notifier_call = cnmips_cu2_call,
+};
+
+static int cnmips_cu2_setup(void)
+{
+       return register_cu2_notifier(&cnmips_cu2_notifier);
+}
+early_initcall(cnmips_cu2_setup);
index be711dd2d9185542b912c3d05317dba12879cb7f..cfdb4c2ac5c3d7ad1a59f6dc6a08e2dcf37259c9 100644 (file)
@@ -159,6 +159,94 @@ out:
 }
 device_initcall(octeon_rng_device_init);
 
+/* Octeon SMI/MDIO interface.  */
+static int __init octeon_mdiobus_device_init(void)
+{
+       struct platform_device *pd;
+       int ret = 0;
+
+       if (octeon_is_simulation())
+               return 0; /* No mdio in the simulator. */
+
+       /* The bus number is the platform_device id.  */
+       pd = platform_device_alloc("mdio-octeon", 0);
+       if (!pd) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       ret = platform_device_add(pd);
+       if (ret)
+               goto fail;
+
+       return ret;
+fail:
+       platform_device_put(pd);
+
+out:
+       return ret;
+
+}
+device_initcall(octeon_mdiobus_device_init);
+
+/* Octeon mgmt port Ethernet interface.  */
+static int __init octeon_mgmt_device_init(void)
+{
+       struct platform_device *pd;
+       int ret = 0;
+       int port, num_ports;
+
+       struct resource mgmt_port_resource = {
+               .flags  = IORESOURCE_IRQ,
+               .start  = -1,
+               .end    = -1
+       };
+
+       if (!OCTEON_IS_MODEL(OCTEON_CN56XX) && !OCTEON_IS_MODEL(OCTEON_CN52XX))
+               return 0;
+
+       if (OCTEON_IS_MODEL(OCTEON_CN56XX))
+               num_ports = 1;
+       else
+               num_ports = 2;
+
+       for (port = 0; port < num_ports; port++) {
+               pd = platform_device_alloc("octeon_mgmt", port);
+               if (!pd) {
+                       ret = -ENOMEM;
+                       goto out;
+               }
+               switch (port) {
+               case 0:
+                       mgmt_port_resource.start = OCTEON_IRQ_MII0;
+                       break;
+               case 1:
+                       mgmt_port_resource.start = OCTEON_IRQ_MII1;
+                       break;
+               default:
+                       BUG();
+               }
+               mgmt_port_resource.end = mgmt_port_resource.start;
+
+               ret = platform_device_add_resources(pd, &mgmt_port_resource, 1);
+
+               if (ret)
+                       goto fail;
+
+               ret = platform_device_add(pd);
+               if (ret)
+                       goto fail;
+       }
+       return ret;
+fail:
+       platform_device_put(pd);
+
+out:
+       return ret;
+
+}
+device_initcall(octeon_mgmt_device_init);
+
 MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Platform driver for Octeon SOC");
index 35648302f7cc9f2b3a310e08f2a80d4e6c621dd7..5a5b6ba7514e0791f2fd74bc9cadd0ea1b0c280c 100644 (file)
@@ -10,7 +10,6 @@ CONFIG_MIPS=y
 #
 # CONFIG_MACH_ALCHEMY is not set
 CONFIG_AR7=y
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -265,7 +264,6 @@ CONFIG_DEFAULT_DEADLINE=y
 # CONFIG_DEFAULT_CFQ is not set
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="deadline"
-CONFIG_PROBE_INITRD_HEADER=y
 # CONFIG_FREEZER is not set
 
 #
@@ -1053,7 +1051,9 @@ CONFIG_TRACING_SUPPORT=y
 # CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="rootfstype=squashfs,jffs2"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index 94b7d57f906d8c46bc6ea420b8bbaeb5c1df3eed..267bd46120bc7e05f6c5de5b5cfd9ed2c3fb2f3c 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 CONFIG_BCM47XX=y
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -1853,7 +1852,7 @@ CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SAMPLES is not set
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index ea00c18d1f7b3089f77bb728f02c18fb5f15ae70..7fee0273c82935f7a420081ceaed30e71d4774eb 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 CONFIG_BCM63XX=y
 # CONFIG_MIPS_COBALT is not set
@@ -942,7 +941,9 @@ CONFIG_TRACING_SUPPORT=y
 # CONFIG_BLK_DEV_IO_TRACE is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,115200"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index 13d9eb4736c0af2bc152aaab8f12a91084e5681e..c2f06e38c8546770d2bacd7b93d9248b9803a2ef 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -1237,7 +1236,7 @@ CONFIG_DEBUG_MUTEXES=y
 # CONFIG_BACKTRACE_SELF_TEST is not set
 # CONFIG_FAULT_INJECTION is not set
 # CONFIG_SAMPLES is not set
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_SB1XXX_CORELIS is not set
 # CONFIG_RUNTIME_DEBUG is not set
index 185df23fd4609e4d04e21f85f676aef7773267b1..72b7e456916e2b9f8e3bde70c3338a6b9074a799 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -783,7 +782,9 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="mem=32M console=ttyVR0,38400"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index 7afaa28a3768d2d74450231675fe249f4df29f8f..c8507bc8e925b4141584080cde843a2d5a07c198 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -269,7 +268,6 @@ CONFIG_DEFAULT_CFQ=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="cfq"
 CONFIG_CLASSIC_RCU=y
-# CONFIG_PROBE_INITRD_HEADER is not set
 # CONFIG_FREEZER is not set
 
 #
@@ -822,7 +820,7 @@ CONFIG_SYSCTL_SYSCALL_CHECK=y
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
 # CONFIG_KGDB is not set
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_RUNTIME_DEBUG is not set
 
index 6c8cca8589ba2db188fe9af4c88c708a7d8ea75d..49e61312e006e252a3ce96d4972262625b4f1ccd 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 CONFIG_MIPS_COBALT=y
 # CONFIG_MACH_DECSTATION is not set
@@ -1126,7 +1125,7 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_SLUB_STATS is not set
 # CONFIG_DEBUG_MEMORY_INIT is not set
 # CONFIG_SAMPLES is not set
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index dbdf3bb1a34a1e508bf6a3892cf50874a0b425e7..68e90cd6b2d4a9f6d7fc102debd540c0dc5ac296 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MIPS_DB1000=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1090,7 +1089,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index fa681447589861130a324dc9a93620e43a3513d8..90812830e940c560ed44da60a8e457778ea46095 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MIPS_DB1100=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1090,7 +1089,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index d73f1de43b5dda4262b6e79bffb9f9a8f971fc12..dabf03032e06155d03e30f3091cc03cace3638da 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MACH_ALCHEMY=y
 # CONFIG_MIPS_DB1550 is not set
 CONFIG_MIPS_DB1200=y
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1172,7 +1171,9 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="mem=48M"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index ec3e028a5b2e0f17499f899b816b60126e362e6e..a151313731381c5be32c574eeff84641fa297da6 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MIPS_DB1500=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1390,7 +1389,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 7631dae51be99e0eb4e36b8ce70186df4929a437..6b64339c0014ada688a086d4389479df40fe603c 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MACH_ALCHEMY=y
 CONFIG_MIPS_DB1550=y
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1207,7 +1206,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 9e65e6a2dcb3f80598570a8f45560c911f949537..cbb4d86f2912d4fd1ea4abdb9659e3268ad35256 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 CONFIG_MACH_DECSTATION=y
 # CONFIG_MACH_JAZZ is not set
@@ -882,7 +881,7 @@ CONFIG_MAGIC_SYSRQ=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 1bd84d42b14fd7ef7d3a0b5af2b1f6573632dc0d..52968c46c806ad0c7420db724ece5da49ca2de73 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -561,7 +560,9 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyVR0,19200 ide0=0x1f0,0x3f6,40 mem=8M"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
diff --git a/arch/mips/configs/excite_defconfig b/arch/mips/configs/excite_defconfig
deleted file mode 100644 (file)
index 1995d43..0000000
+++ /dev/null
@@ -1,1335 +0,0 @@
-#
-# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.20
-# Tue Feb 20 21:47:31 2007
-#
-CONFIG_MIPS=y
-
-#
-# Machine selection
-#
-CONFIG_ZONE_DMA=y
-# CONFIG_MIPS_MTX1 is not set
-# CONFIG_MIPS_BOSPORUS is not set
-# CONFIG_MIPS_PB1000 is not set
-# CONFIG_MIPS_PB1100 is not set
-# CONFIG_MIPS_PB1500 is not set
-# CONFIG_MIPS_PB1550 is not set
-# CONFIG_MIPS_PB1200 is not set
-# CONFIG_MIPS_DB1000 is not set
-# CONFIG_MIPS_DB1100 is not set
-# CONFIG_MIPS_DB1500 is not set
-# CONFIG_MIPS_DB1550 is not set
-# CONFIG_MIPS_DB1200 is not set
-# CONFIG_MIPS_MIRAGE is not set
-CONFIG_BASLER_EXCITE=y
-# CONFIG_BASLER_EXCITE_PROTOTYPE is not set
-# CONFIG_MIPS_COBALT is not set
-# CONFIG_MACH_DECSTATION is not set
-# CONFIG_MACH_JAZZ is not set
-# CONFIG_MIPS_MALTA is not set
-# CONFIG_WR_PPMC is not set
-# CONFIG_MIPS_SIM is not set
-# CONFIG_MOMENCO_JAGUAR_ATX is not set
-# CONFIG_MIPS_XXS1500 is not set
-# CONFIG_PNX8550_JBS is not set
-# CONFIG_PNX8550_STB810 is not set
-# CONFIG_MACH_VR41XX is not set
-# CONFIG_PMC_YOSEMITE is not set
-# CONFIG_MARKEINS is not set
-# CONFIG_SGI_IP22 is not set
-# CONFIG_SGI_IP27 is not set
-# CONFIG_SGI_IP32 is not set
-# CONFIG_SIBYTE_BIGSUR is not set
-# CONFIG_SIBYTE_SWARM is not set
-# CONFIG_SIBYTE_SENTOSA is not set
-# CONFIG_SIBYTE_RHONE is not set
-# CONFIG_SIBYTE_CARMEL is not set
-# CONFIG_SIBYTE_LITTLESUR is not set
-# CONFIG_SIBYTE_CRHINE is not set
-# CONFIG_SIBYTE_CRHONE is not set
-# CONFIG_SNI_RM is not set
-# CONFIG_TOSHIBA_JMR3927 is not set
-# CONFIG_TOSHIBA_RBTX4927 is not set
-# CONFIG_TOSHIBA_RBTX4938 is not set
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-# CONFIG_ARCH_HAS_ILOG2_U32 is not set
-# CONFIG_ARCH_HAS_ILOG2_U64 is not set
-CONFIG_GENERIC_FIND_NEXT_BIT=y
-CONFIG_GENERIC_HWEIGHT=y
-CONFIG_GENERIC_CALIBRATE_DELAY=y
-CONFIG_GENERIC_TIME=y
-CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
-# CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ is not set
-CONFIG_DMA_COHERENT=y
-CONFIG_CPU_BIG_ENDIAN=y
-# CONFIG_CPU_LITTLE_ENDIAN is not set
-CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
-CONFIG_IRQ_CPU=y
-CONFIG_IRQ_CPU_RM7K=y
-CONFIG_IRQ_CPU_RM9K=y
-CONFIG_MIPS_RM9122=y
-CONFIG_SERIAL_RM9000=y
-CONFIG_GPI_RM9000=y
-CONFIG_WDT_RM9000=y
-CONFIG_MIPS_L1_CACHE_SHIFT=5
-
-#
-# CPU selection
-#
-# CONFIG_CPU_MIPS32_R1 is not set
-# CONFIG_CPU_MIPS32_R2 is not set
-# CONFIG_CPU_MIPS64_R1 is not set
-# CONFIG_CPU_MIPS64_R2 is not set
-# CONFIG_CPU_R3000 is not set
-# CONFIG_CPU_TX39XX is not set
-# CONFIG_CPU_VR41XX is not set
-# CONFIG_CPU_R4300 is not set
-# CONFIG_CPU_R4X00 is not set
-# CONFIG_CPU_TX49XX is not set
-# CONFIG_CPU_R5000 is not set
-# CONFIG_CPU_R5432 is not set
-# CONFIG_CPU_R6000 is not set
-# CONFIG_CPU_NEVADA is not set
-# CONFIG_CPU_R8000 is not set
-# CONFIG_CPU_R10000 is not set
-# CONFIG_CPU_RM7000 is not set
-CONFIG_CPU_RM9000=y
-# CONFIG_CPU_SB1 is not set
-CONFIG_SYS_HAS_CPU_RM9000=y
-CONFIG_WEAK_ORDERING=y
-CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
-CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
-CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
-CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
-
-#
-# Kernel type
-#
-CONFIG_32BIT=y
-# CONFIG_64BIT is not set
-CONFIG_PAGE_SIZE_4KB=y
-# CONFIG_PAGE_SIZE_8KB is not set
-# CONFIG_PAGE_SIZE_16KB is not set
-# CONFIG_PAGE_SIZE_64KB is not set
-CONFIG_CPU_HAS_PREFETCH=y
-CONFIG_MIPS_MT_DISABLED=y
-# CONFIG_MIPS_MT_SMP is not set
-# CONFIG_MIPS_MT_SMTC is not set
-# CONFIG_MIPS_VPE_LOADER is not set
-# CONFIG_64BIT_PHYS_ADDR is not set
-CONFIG_CPU_HAS_SYNC=y
-CONFIG_GENERIC_HARDIRQS=y
-CONFIG_GENERIC_IRQ_PROBE=y
-CONFIG_CPU_SUPPORTS_HIGHMEM=y
-CONFIG_ARCH_FLATMEM_ENABLE=y
-CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
-# CONFIG_DISCONTIGMEM_MANUAL is not set
-# CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
-CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-CONFIG_SPLIT_PTLOCK_CPUS=4
-# CONFIG_RESOURCES_64BIT is not set
-CONFIG_ZONE_DMA_FLAG=1
-# CONFIG_HZ_48 is not set
-# CONFIG_HZ_100 is not set
-# CONFIG_HZ_128 is not set
-# CONFIG_HZ_250 is not set
-# CONFIG_HZ_256 is not set
-CONFIG_HZ_1000=y
-# CONFIG_HZ_1024 is not set
-CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
-CONFIG_HZ=1000
-# CONFIG_PREEMPT_NONE is not set
-# CONFIG_PREEMPT_VOLUNTARY is not set
-CONFIG_PREEMPT=y
-CONFIG_PREEMPT_BKL=y
-# CONFIG_KEXEC is not set
-CONFIG_LOCKDEP_SUPPORT=y
-CONFIG_STACKTRACE_SUPPORT=y
-CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_BROKEN_ON_SMP=y
-CONFIG_LOCK_KERNEL=y
-CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
-CONFIG_LOCALVERSION=""
-# CONFIG_LOCALVERSION_AUTO is not set
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_IPC_NS is not set
-CONFIG_SYSVIPC_SYSCTL=y
-CONFIG_POSIX_MQUEUE=y
-# CONFIG_BSD_PROCESS_ACCT is not set
-# CONFIG_TASKSTATS is not set
-# CONFIG_UTS_NS is not set
-# CONFIG_AUDIT is not set
-# CONFIG_IKCONFIG is not set
-CONFIG_SYSFS_DEPRECATED=y
-# CONFIG_RELAY is not set
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_SYSCTL=y
-CONFIG_EMBEDDED=y
-CONFIG_SYSCTL_SYSCALL=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_HOTPLUG=y
-CONFIG_PRINTK=y
-CONFIG_BUG=y
-CONFIG_ELF_CORE=y
-CONFIG_BASE_FULL=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_SHMEM=y
-CONFIG_SLAB=y
-CONFIG_VM_EVENT_COUNTERS=y
-CONFIG_RT_MUTEXES=y
-# CONFIG_TINY_SHMEM is not set
-CONFIG_BASE_SMALL=0
-# CONFIG_SLOB is not set
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-# CONFIG_MODVERSIONS is not set
-# CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
-
-#
-# Block layer
-#
-CONFIG_BLOCK=y
-# CONFIG_LBD is not set
-# CONFIG_BLK_DEV_IO_TRACE is not set
-# CONFIG_LSF is not set
-
-#
-# IO Schedulers
-#
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_DEFAULT_AS=y
-# CONFIG_DEFAULT_DEADLINE is not set
-# CONFIG_DEFAULT_CFQ is not set
-# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="anticipatory"
-
-#
-# Bus options (PCI, PCMCIA, EISA, ISA, TC)
-#
-CONFIG_HW_HAS_PCI=y
-CONFIG_PCI=y
-CONFIG_MMU=y
-
-#
-# PCCARD (PCMCIA/CardBus) support
-#
-# CONFIG_PCCARD is not set
-
-#
-# PCI Hotplug Support
-#
-# CONFIG_HOTPLUG_PCI is not set
-
-#
-# Executable file formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_MISC is not set
-CONFIG_TRAD_SIGNALS=y
-
-#
-# Power management options
-#
-CONFIG_PM=y
-# CONFIG_PM_LEGACY is not set
-# CONFIG_PM_DEBUG is not set
-# CONFIG_PM_SYSFS_DEPRECATED is not set
-
-#
-# Networking
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-# CONFIG_NETDEBUG is not set
-CONFIG_PACKET=y
-CONFIG_PACKET_MMAP=y
-CONFIG_UNIX=y
-CONFIG_XFRM=y
-# CONFIG_XFRM_USER is not set
-# CONFIG_XFRM_SUB_POLICY is not set
-CONFIG_XFRM_MIGRATE=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_FIB_HASH=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_IP_PNP_BOOTP is not set
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-# CONFIG_SYN_COOKIES is not set
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_XFRM_TUNNEL is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_INET_XFRM_MODE_TRANSPORT=m
-CONFIG_INET_XFRM_MODE_TUNNEL=m
-CONFIG_INET_XFRM_MODE_BEET=m
-CONFIG_INET_DIAG=y
-CONFIG_INET_TCP_DIAG=y
-# CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_CUBIC=y
-CONFIG_DEFAULT_TCP_CONG="cubic"
-CONFIG_TCP_MD5SIG=y
-# CONFIG_IPV6 is not set
-# CONFIG_INET6_XFRM_TUNNEL is not set
-# CONFIG_INET6_TUNNEL is not set
-CONFIG_NETWORK_SECMARK=y
-# CONFIG_NETFILTER is not set
-
-#
-# DCCP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_DCCP is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-
-#
-# TIPC Configuration (EXPERIMENTAL)
-#
-# CONFIG_TIPC is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-# CONFIG_IEEE80211 is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_STANDALONE=y
-CONFIG_PREVENT_FIRMWARE_BUILD=y
-CONFIG_FW_LOADER=m
-# CONFIG_SYS_HYPERVISOR is not set
-
-#
-# Connector - unified userspace <-> kernelspace linker
-#
-# CONFIG_CONNECTOR is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_CONCAT is not set
-CONFIG_MTD_PARTITIONS=y
-# CONFIG_MTD_REDBOOT_PARTS is not set
-# CONFIG_MTD_CMDLINE_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLKDEVS=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-# CONFIG_RFD_FTL is not set
-# CONFIG_SSFDC is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-# CONFIG_MTD_CFI is not set
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_MAP_BANK_WIDTH_1=y
-CONFIG_MTD_MAP_BANK_WIDTH_2=y
-CONFIG_MTD_MAP_BANK_WIDTH_4=y
-# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
-CONFIG_MTD_CFI_I1=y
-CONFIG_MTD_CFI_I2=y
-# CONFIG_MTD_CFI_I4 is not set
-# CONFIG_MTD_CFI_I8 is not set
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_OBSOLETE_CHIPS is not set
-
-#
-# Mapping drivers for chip access
-#
-# CONFIG_MTD_COMPLEX_MAPPINGS is not set
-# CONFIG_MTD_PLATRAM is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_PHRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLOCK2MTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-CONFIG_MTD_NAND=y
-CONFIG_MTD_NAND_VERIFY_WRITE=y
-# CONFIG_MTD_NAND_ECC_SMC is not set
-CONFIG_MTD_NAND_IDS=y
-# CONFIG_MTD_NAND_DISKONCHIP is not set
-# CONFIG_MTD_NAND_BASLER_EXCITE is not set
-# CONFIG_MTD_NAND_CAFE is not set
-# CONFIG_MTD_NAND_NANDSIM is not set
-
-#
-# OneNAND Flash Device Drivers
-#
-# CONFIG_MTD_ONENAND is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-# CONFIG_PNPACPI is not set
-
-#
-# Block devices
-#
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_COW_COMMON is not set
-CONFIG_BLK_DEV_LOOP=m
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_SX8 is not set
-# CONFIG_BLK_DEV_UB is not set
-# CONFIG_BLK_DEV_RAM is not set
-# CONFIG_BLK_DEV_INITRD is not set
-# CONFIG_CDROM_PKTCDVD is not set
-# CONFIG_ATA_OVER_ETH is not set
-
-#
-# Misc devices
-#
-CONFIG_SGI_IOC4=m
-# CONFIG_TIFM_CORE is not set
-
-#
-# ATA/ATAPI/MFM/RLL support
-#
-# CONFIG_IDE is not set
-
-#
-# SCSI device support
-#
-# CONFIG_RAID_ATTRS is not set
-CONFIG_SCSI=y
-CONFIG_SCSI_TGT=m
-# CONFIG_SCSI_NETLINK is not set
-# CONFIG_SCSI_PROC_FS is not set
-
-#
-# SCSI support type (disk, tape, CD-ROM)
-#
-CONFIG_BLK_DEV_SD=y
-# CONFIG_CHR_DEV_ST is not set
-# CONFIG_CHR_DEV_OSST is not set
-# CONFIG_BLK_DEV_SR is not set
-# CONFIG_CHR_DEV_SG is not set
-# CONFIG_CHR_DEV_SCH is not set
-
-#
-# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
-#
-# CONFIG_SCSI_MULTI_LUN is not set
-# CONFIG_SCSI_CONSTANTS is not set
-# CONFIG_SCSI_LOGGING is not set
-CONFIG_SCSI_SCAN_ASYNC=y
-
-#
-# SCSI Transports
-#
-# CONFIG_SCSI_SPI_ATTRS is not set
-# CONFIG_SCSI_FC_ATTRS is not set
-# CONFIG_SCSI_ISCSI_ATTRS is not set
-CONFIG_SCSI_SAS_ATTRS=m
-CONFIG_SCSI_SAS_LIBSAS=m
-# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
-
-#
-# SCSI low-level drivers
-#
-# CONFIG_ISCSI_TCP is not set
-# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
-# CONFIG_SCSI_3W_9XXX is not set
-# CONFIG_SCSI_ACARD is not set
-# CONFIG_SCSI_AACRAID is not set
-# CONFIG_SCSI_AIC7XXX is not set
-# CONFIG_SCSI_AIC7XXX_OLD is not set
-# CONFIG_SCSI_AIC79XX is not set
-CONFIG_SCSI_AIC94XX=m
-# CONFIG_AIC94XX_DEBUG is not set
-# CONFIG_SCSI_DPT_I2O is not set
-# CONFIG_SCSI_ARCMSR is not set
-# CONFIG_MEGARAID_NEWGEN is not set
-# CONFIG_MEGARAID_LEGACY is not set
-# CONFIG_MEGARAID_SAS is not set
-# CONFIG_SCSI_HPTIOP is not set
-# CONFIG_SCSI_DMX3191D is not set
-# CONFIG_SCSI_FUTURE_DOMAIN is not set
-# CONFIG_SCSI_IPS is not set
-# CONFIG_SCSI_INITIO is not set
-# CONFIG_SCSI_INIA100 is not set
-# CONFIG_SCSI_STEX is not set
-# CONFIG_SCSI_SYM53C8XX_2 is not set
-# CONFIG_SCSI_QLOGIC_1280 is not set
-# CONFIG_SCSI_QLA_FC is not set
-# CONFIG_SCSI_QLA_ISCSI is not set
-# CONFIG_SCSI_LPFC is not set
-# CONFIG_SCSI_DC395x is not set
-# CONFIG_SCSI_DC390T is not set
-# CONFIG_SCSI_NSP32 is not set
-# CONFIG_SCSI_DEBUG is not set
-# CONFIG_SCSI_SRP is not set
-
-#
-# Serial ATA (prod) and Parallel ATA (experimental) drivers
-#
-# CONFIG_ATA is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-# CONFIG_FUSION_SPI is not set
-# CONFIG_FUSION_FC is not set
-# CONFIG_FUSION_SAS is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-# CONFIG_DUMMY is not set
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# PHY device support
-#
-
-#
-# Ethernet (10 or 100Mbit)
-#
-# CONFIG_NET_ETHERNET is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SKGE is not set
-# CONFIG_SKY2 is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_TIGON3 is not set
-# CONFIG_BNX2 is not set
-CONFIG_QLA3XXX=m
-# CONFIG_ATL1 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_CHELSIO_T1 is not set
-CONFIG_CHELSIO_T3=m
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-# CONFIG_MYRI10GE is not set
-CONFIG_NETXEN_NIC=m
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-# CONFIG_WAN is not set
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_NET_FC is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Telephony Support
-#
-# CONFIG_PHONE is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-# CONFIG_INPUT_FF_MEMLESS is not set
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=m
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-CONFIG_INPUT_EVDEV=m
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Hardware I/O ports
-#
-# CONFIG_SERIO is not set
-# CONFIG_GAMEPORT is not set
-
-#
-# Character devices
-#
-CONFIG_VT=y
-CONFIG_VT_CONSOLE=y
-CONFIG_HW_CONSOLE=y
-CONFIG_VT_HW_CONSOLE_BINDING=y
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_PCI=y
-CONFIG_SERIAL_8250_NR_UARTS=2
-CONFIG_SERIAL_8250_RUNTIME_UARTS=2
-CONFIG_SERIAL_8250_EXTENDED=y
-# CONFIG_SERIAL_8250_MANY_PORTS is not set
-CONFIG_SERIAL_8250_SHARE_IRQ=y
-# CONFIG_SERIAL_8250_DETECT_IRQ is not set
-# CONFIG_SERIAL_8250_RSA is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_JSM is not set
-CONFIG_UNIX98_PTYS=y
-# CONFIG_LEGACY_PTYS is not set
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-CONFIG_WDT_RM9K_GPI=m
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-
-#
-# USB-based Watchdog Cards
-#
-# CONFIG_USBPCWATCHDOG is not set
-# CONFIG_HW_RANDOM is not set
-# CONFIG_RTC is not set
-# CONFIG_GEN_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# TPM devices
-#
-# CONFIG_TCG_TPM is not set
-
-#
-# I2C support
-#
-# CONFIG_I2C is not set
-
-#
-# SPI support
-#
-# CONFIG_SPI is not set
-# CONFIG_SPI_MASTER is not set
-
-#
-# Dallas's 1-wire bus
-#
-# CONFIG_W1 is not set
-
-#
-# Hardware Monitoring support
-#
-# CONFIG_HWMON is not set
-# CONFIG_HWMON_VID is not set
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-# CONFIG_USB_DABUSB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FIRMWARE_EDID is not set
-CONFIG_FB=y
-# CONFIG_FB_CFB_FILLRECT is not set
-# CONFIG_FB_CFB_COPYAREA is not set
-# CONFIG_FB_CFB_IMAGEBLIT is not set
-# CONFIG_FB_SVGALIB is not set
-# CONFIG_FB_MACMODES is not set
-# CONFIG_FB_BACKLIGHT is not set
-# CONFIG_FB_MODE_HELPERS is not set
-# CONFIG_FB_TILEBLITTING is not set
-# CONFIG_FB_CIRRUS is not set
-# CONFIG_FB_PM2 is not set
-# CONFIG_FB_CYBER2000 is not set
-# CONFIG_FB_ASILIANT is not set
-# CONFIG_FB_IMSTT is not set
-# CONFIG_FB_S1D13XXX is not set
-# CONFIG_FB_NVIDIA is not set
-# CONFIG_FB_RIVA is not set
-# CONFIG_FB_MATROX is not set
-# CONFIG_FB_RADEON is not set
-# CONFIG_FB_ATY128 is not set
-# CONFIG_FB_ATY is not set
-# CONFIG_FB_S3 is not set
-# CONFIG_FB_SAVAGE is not set
-# CONFIG_FB_SIS is not set
-# CONFIG_FB_NEOMAGIC is not set
-# CONFIG_FB_KYRO is not set
-# CONFIG_FB_3DFX is not set
-# CONFIG_FB_VOODOO1 is not set
-# CONFIG_FB_SMIVGX is not set
-# CONFIG_FB_TRIDENT is not set
-# CONFIG_FB_VIRTUAL is not set
-
-#
-# Console display driver support
-#
-# CONFIG_VGA_CONSOLE is not set
-CONFIG_DUMMY_CONSOLE=y
-CONFIG_FRAMEBUFFER_CONSOLE=m
-# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
-# CONFIG_FONTS is not set
-CONFIG_FONT_8x8=y
-CONFIG_FONT_8x16=y
-
-#
-# Logo configuration
-#
-# CONFIG_LOGO is not set
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# HID Devices
-#
-CONFIG_HID=y
-# CONFIG_HID_DEBUG is not set
-
-#
-# USB support
-#
-CONFIG_USB_ARCH_HAS_HCD=y
-CONFIG_USB_ARCH_HAS_OHCI=y
-CONFIG_USB_ARCH_HAS_EHCI=y
-CONFIG_USB=y
-# CONFIG_USB_DEBUG is not set
-
-#
-# Miscellaneous USB options
-#
-CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_DYNAMIC_MINORS is not set
-# CONFIG_USB_SUSPEND is not set
-# CONFIG_USB_OTG is not set
-
-#
-# USB Host Controller Drivers
-#
-CONFIG_USB_EHCI_HCD=y
-# CONFIG_USB_EHCI_SPLIT_ISO is not set
-# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
-# CONFIG_USB_EHCI_TT_NEWSCHED is not set
-# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set
-# CONFIG_USB_ISP116X_HCD is not set
-CONFIG_USB_OHCI_HCD=y
-# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
-# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
-CONFIG_USB_OHCI_LITTLE_ENDIAN=y
-# CONFIG_USB_UHCI_HCD is not set
-# CONFIG_USB_SL811_HCD is not set
-
-#
-# USB Device Class drivers
-#
-# CONFIG_USB_ACM is not set
-# CONFIG_USB_PRINTER is not set
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
-
-#
-# may also be needed; see USB_STORAGE Help for more information
-#
-CONFIG_USB_STORAGE=y
-# CONFIG_USB_STORAGE_DEBUG is not set
-# CONFIG_USB_STORAGE_DATAFAB is not set
-# CONFIG_USB_STORAGE_FREECOM is not set
-# CONFIG_USB_STORAGE_DPCM is not set
-# CONFIG_USB_STORAGE_USBAT is not set
-# CONFIG_USB_STORAGE_SDDR09 is not set
-# CONFIG_USB_STORAGE_SDDR55 is not set
-# CONFIG_USB_STORAGE_JUMPSHOT is not set
-# CONFIG_USB_STORAGE_ALAUDA is not set
-# CONFIG_USB_STORAGE_KARMA is not set
-# CONFIG_USB_LIBUSUAL is not set
-
-#
-# USB Input Devices
-#
-CONFIG_USB_HID=m
-# CONFIG_USB_HIDINPUT_POWERBOOK is not set
-# CONFIG_HID_FF is not set
-# CONFIG_USB_HIDDEV is not set
-
-#
-# USB HID Boot Protocol drivers
-#
-# CONFIG_USB_KBD is not set
-# CONFIG_USB_MOUSE is not set
-# CONFIG_USB_AIPTEK is not set
-# CONFIG_USB_WACOM is not set
-# CONFIG_USB_ACECAD is not set
-# CONFIG_USB_KBTAB is not set
-# CONFIG_USB_POWERMATE is not set
-# CONFIG_USB_TOUCHSCREEN is not set
-# CONFIG_USB_YEALINK is not set
-# CONFIG_USB_XPAD is not set
-# CONFIG_USB_ATI_REMOTE is not set
-# CONFIG_USB_ATI_REMOTE2 is not set
-# CONFIG_USB_KEYSPAN_REMOTE is not set
-# CONFIG_USB_APPLETOUCH is not set
-# CONFIG_USB_GTCO is not set
-
-#
-# USB Imaging devices
-#
-# CONFIG_USB_MDC800 is not set
-# CONFIG_USB_MICROTEK is not set
-
-#
-# USB Network Adapters
-#
-# CONFIG_USB_CATC is not set
-# CONFIG_USB_KAWETH is not set
-# CONFIG_USB_PEGASUS is not set
-# CONFIG_USB_RTL8150 is not set
-# CONFIG_USB_USBNET_MII is not set
-# CONFIG_USB_USBNET is not set
-# CONFIG_USB_MON is not set
-
-#
-# USB port drivers
-#
-
-#
-# USB Serial Converter support
-#
-# CONFIG_USB_SERIAL is not set
-
-#
-# USB Miscellaneous drivers
-#
-# CONFIG_USB_EMI62 is not set
-# CONFIG_USB_EMI26 is not set
-# CONFIG_USB_ADUTUX is not set
-# CONFIG_USB_AUERSWALD is not set
-# CONFIG_USB_RIO500 is not set
-# CONFIG_USB_LEGOTOWER is not set
-# CONFIG_USB_LCD is not set
-# CONFIG_USB_BERRY_CHARGE is not set
-# CONFIG_USB_LED is not set
-# CONFIG_USB_CYPRESS_CY7C63 is not set
-# CONFIG_USB_CYTHERM is not set
-# CONFIG_USB_PHIDGET is not set
-# CONFIG_USB_IDMOUSE is not set
-# CONFIG_USB_FTDI_ELAN is not set
-# CONFIG_USB_APPLEDISPLAY is not set
-# CONFIG_USB_SISUSBVGA is not set
-# CONFIG_USB_LD is not set
-# CONFIG_USB_TRANCEVIBRATOR is not set
-# CONFIG_USB_TEST is not set
-
-#
-# USB DSL modem support
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# MMC/SD Card support
-#
-# CONFIG_MMC is not set
-
-#
-# LED devices
-#
-# CONFIG_NEW_LEDS is not set
-
-#
-# LED drivers
-#
-
-#
-# LED Triggers
-#
-
-#
-# InfiniBand support
-#
-# CONFIG_INFINIBAND is not set
-
-#
-# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
-#
-
-#
-# Real Time Clock
-#
-# CONFIG_RTC_CLASS is not set
-
-#
-# DMA Engine support
-#
-# CONFIG_DMA_ENGINE is not set
-
-#
-# DMA Clients
-#
-
-#
-# DMA Devices
-#
-
-#
-# Auxiliary Display support
-#
-
-#
-# Virtualization
-#
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-# CONFIG_EXT2_FS_XATTR is not set
-# CONFIG_EXT2_FS_XIP is not set
-# CONFIG_EXT3_FS is not set
-# CONFIG_EXT4DEV_FS is not set
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_GFS2_FS is not set
-# CONFIG_OCFS2_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_INOTIFY=y
-CONFIG_INOTIFY_USER=y
-# CONFIG_QUOTA is not set
-# CONFIG_DNOTIFY is not set
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_FUSE_FS is not set
-CONFIG_GENERIC_ACL=y
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-CONFIG_FAT_FS=m
-CONFIG_MSDOS_FS=m
-CONFIG_VFAT_FS=m
-CONFIG_FAT_DEFAULT_CODEPAGE=437
-CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_PROC_KCORE=y
-CONFIG_PROC_SYSCTL=y
-CONFIG_SYSFS=y
-CONFIG_TMPFS=y
-CONFIG_TMPFS_POSIX_ACL=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-CONFIG_CONFIGFS_FS=m
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-CONFIG_JFFS2_FS_WRITEBUFFER=y
-# CONFIG_JFFS2_SUMMARY is not set
-# CONFIG_JFFS2_FS_XATTR is not set
-# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
-CONFIG_JFFS2_ZLIB=y
-CONFIG_JFFS2_RTIME=y
-# CONFIG_JFFS2_RUBIN is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V3_ACL is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-CONFIG_NFS_COMMON=y
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_RPCSEC_GSS_SPKM3 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-# CONFIG_9P_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_KARMA_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-CONFIG_NLS=y
-CONFIG_NLS_DEFAULT="iso8859-1"
-CONFIG_NLS_CODEPAGE_437=m
-# CONFIG_NLS_CODEPAGE_737 is not set
-# CONFIG_NLS_CODEPAGE_775 is not set
-CONFIG_NLS_CODEPAGE_850=m
-# CONFIG_NLS_CODEPAGE_852 is not set
-# CONFIG_NLS_CODEPAGE_855 is not set
-# CONFIG_NLS_CODEPAGE_857 is not set
-# CONFIG_NLS_CODEPAGE_860 is not set
-# CONFIG_NLS_CODEPAGE_861 is not set
-# CONFIG_NLS_CODEPAGE_862 is not set
-# CONFIG_NLS_CODEPAGE_863 is not set
-# CONFIG_NLS_CODEPAGE_864 is not set
-# CONFIG_NLS_CODEPAGE_865 is not set
-# CONFIG_NLS_CODEPAGE_866 is not set
-# CONFIG_NLS_CODEPAGE_869 is not set
-# CONFIG_NLS_CODEPAGE_936 is not set
-# CONFIG_NLS_CODEPAGE_950 is not set
-# CONFIG_NLS_CODEPAGE_932 is not set
-# CONFIG_NLS_CODEPAGE_949 is not set
-# CONFIG_NLS_CODEPAGE_874 is not set
-# CONFIG_NLS_ISO8859_8 is not set
-# CONFIG_NLS_CODEPAGE_1250 is not set
-# CONFIG_NLS_CODEPAGE_1251 is not set
-# CONFIG_NLS_ASCII is not set
-CONFIG_NLS_ISO8859_1=m
-# CONFIG_NLS_ISO8859_2 is not set
-# CONFIG_NLS_ISO8859_3 is not set
-# CONFIG_NLS_ISO8859_4 is not set
-# CONFIG_NLS_ISO8859_5 is not set
-# CONFIG_NLS_ISO8859_6 is not set
-# CONFIG_NLS_ISO8859_7 is not set
-# CONFIG_NLS_ISO8859_9 is not set
-# CONFIG_NLS_ISO8859_13 is not set
-# CONFIG_NLS_ISO8859_14 is not set
-# CONFIG_NLS_ISO8859_15 is not set
-# CONFIG_NLS_KOI8_R is not set
-# CONFIG_NLS_KOI8_U is not set
-# CONFIG_NLS_UTF8 is not set
-
-#
-# Distributed Lock Manager
-#
-CONFIG_DLM=m
-CONFIG_DLM_TCP=y
-# CONFIG_DLM_SCTP is not set
-# CONFIG_DLM_DEBUG is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Kernel hacking
-#
-CONFIG_TRACE_IRQFLAGS_SUPPORT=y
-# CONFIG_PRINTK_TIME is not set
-CONFIG_ENABLE_MUST_CHECK=y
-# CONFIG_MAGIC_SYSRQ is not set
-# CONFIG_UNUSED_SYMBOLS is not set
-# CONFIG_DEBUG_FS is not set
-# CONFIG_HEADERS_CHECK is not set
-# CONFIG_DEBUG_KERNEL is not set
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
-
-#
-# Security options
-#
-# CONFIG_KEYS is not set
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-CONFIG_CRYPTO=y
-CONFIG_CRYPTO_ALGAPI=y
-CONFIG_CRYPTO_BLKCIPHER=m
-CONFIG_CRYPTO_HASH=m
-CONFIG_CRYPTO_MANAGER=m
-# CONFIG_CRYPTO_HMAC is not set
-CONFIG_CRYPTO_XCBC=m
-# CONFIG_CRYPTO_NULL is not set
-# CONFIG_CRYPTO_MD4 is not set
-CONFIG_CRYPTO_MD5=y
-# CONFIG_CRYPTO_SHA1 is not set
-# CONFIG_CRYPTO_SHA256 is not set
-# CONFIG_CRYPTO_SHA512 is not set
-# CONFIG_CRYPTO_WP512 is not set
-# CONFIG_CRYPTO_TGR192 is not set
-CONFIG_CRYPTO_GF128MUL=m
-CONFIG_CRYPTO_ECB=m
-CONFIG_CRYPTO_CBC=m
-CONFIG_CRYPTO_PCBC=m
-CONFIG_CRYPTO_LRW=m
-# CONFIG_CRYPTO_DES is not set
-CONFIG_CRYPTO_FCRYPT=m
-# CONFIG_CRYPTO_BLOWFISH is not set
-# CONFIG_CRYPTO_TWOFISH is not set
-# CONFIG_CRYPTO_SERPENT is not set
-# CONFIG_CRYPTO_AES is not set
-# CONFIG_CRYPTO_CAST5 is not set
-# CONFIG_CRYPTO_CAST6 is not set
-# CONFIG_CRYPTO_TEA is not set
-# CONFIG_CRYPTO_ARC4 is not set
-# CONFIG_CRYPTO_KHAZAD is not set
-# CONFIG_CRYPTO_ANUBIS is not set
-# CONFIG_CRYPTO_DEFLATE is not set
-# CONFIG_CRYPTO_MICHAEL_MIC is not set
-# CONFIG_CRYPTO_CRC32C is not set
-CONFIG_CRYPTO_CAMELLIA=m
-# CONFIG_CRYPTO_TEST is not set
-
-#
-# Hardware crypto devices
-#
-
-#
-# Library routines
-#
-CONFIG_BITREVERSE=y
-# CONFIG_CRC_CCITT is not set
-# CONFIG_CRC16 is not set
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
-CONFIG_PLIST=y
-CONFIG_HAS_IOMEM=y
-CONFIG_HAS_IOPORT=y
index 0197f0de6b3fd554d0c37590cab155008bbde2f0..a09dd03aa8c8be2fe2177e7f61e76d14f8c68018 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.31-rc1
-# Thu Jul  2 22:37:00 2009
+# Linux kernel version: 2.6.32-rc4
+# Fri Oct 16 13:18:01 2009
 #
 CONFIG_MIPS=y
 
@@ -10,8 +10,8 @@ CONFIG_MIPS=y
 #
 # CONFIG_MACH_ALCHEMY is not set
 # CONFIG_AR7 is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
+# CONFIG_BCM63XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -105,6 +105,8 @@ CONFIG_CPU_LOONGSON2E=y
 # CONFIG_CPU_RM9000 is not set
 # CONFIG_CPU_SB1 is not set
 # CONFIG_CPU_CAVIUM_OCTEON is not set
+CONFIG_SYS_SUPPORTS_ZBOOT=y
+CONFIG_SYS_SUPPORTS_ZBOOT_UART16550=y
 CONFIG_CPU_LOONGSON2=y
 CONFIG_SYS_HAS_CPU_LOONGSON2E=y
 CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
@@ -135,12 +137,16 @@ CONFIG_SYS_SUPPORTS_HIGHMEM=y
 CONFIG_ARCH_FLATMEM_ENABLE=y
 CONFIG_ARCH_POPULATES_NODE_MAP=y
 CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
+# CONFIG_FLATMEM_MANUAL is not set
 # CONFIG_DISCONTIGMEM_MANUAL is not set
-# CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
-CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_SPARSEMEM_MANUAL=y
+CONFIG_SPARSEMEM=y
+CONFIG_HAVE_MEMORY_PRESENT=y
 CONFIG_SPARSEMEM_STATIC=y
+
+#
+# Memory hotplug is currently incompatible with Software Suspend
+#
 CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
 CONFIG_PHYS_ADDR_T_64BIT=y
@@ -148,6 +154,7 @@ CONFIG_ZONE_DMA_FLAG=0
 CONFIG_VIRT_TO_BUS=y
 CONFIG_HAVE_MLOCK=y
 CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
 CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
 CONFIG_TICK_ONESHOT=y
 CONFIG_NO_HZ=y
@@ -180,6 +187,12 @@ CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 CONFIG_LOCALVERSION="-fuloong2e"
 # CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+CONFIG_KERNEL_GZIP=y
+# CONFIG_KERNEL_BZIP2 is not set
+# CONFIG_KERNEL_LZMA is not set
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 CONFIG_SYSVIPC_SYSCTL=y
@@ -193,11 +206,12 @@ CONFIG_BSD_PROCESS_ACCT=y
 #
 # RCU Subsystem
 #
-CONFIG_CLASSIC_RCU=y
-# CONFIG_TREE_RCU is not set
-# CONFIG_PREEMPT_RCU is not set
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=64
+# CONFIG_RCU_FANOUT_EXACT is not set
 # CONFIG_TREE_RCU_TRACE is not set
-# CONFIG_PREEMPT_RCU_TRACE is not set
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
@@ -235,18 +249,16 @@ CONFIG_SHMEM=y
 CONFIG_AIO=y
 
 #
-# Performance Counters
+# Kernel Performance Events And Counters
 #
 CONFIG_VM_EVENT_COUNTERS=y
 CONFIG_PCI_QUIRKS=y
-# CONFIG_STRIP_ASM_SYMS is not set
 # CONFIG_COMPAT_BRK is not set
 CONFIG_SLAB=y
 # CONFIG_SLUB is not set
 # CONFIG_SLOB is not set
 CONFIG_PROFILING=y
 CONFIG_TRACEPOINTS=y
-CONFIG_MARKERS=y
 CONFIG_OPROFILE=m
 CONFIG_HAVE_OPROFILE=y
 CONFIG_HAVE_SYSCALL_WRAPPERS=y
@@ -255,8 +267,8 @@ CONFIG_HAVE_SYSCALL_WRAPPERS=y
 # GCOV-based kernel profiling
 #
 # CONFIG_GCOV_KERNEL is not set
-# CONFIG_SLOW_WORK is not set
-# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLOW_WORK=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
 CONFIG_BASE_SMALL=0
@@ -283,7 +295,7 @@ CONFIG_IOSCHED_CFQ=y
 CONFIG_DEFAULT_CFQ=y
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="cfq"
-# CONFIG_FREEZER is not set
+CONFIG_FREEZER=y
 
 #
 # Bus options (PCI, PCMCIA, EISA, ISA, TC)
@@ -321,9 +333,14 @@ CONFIG_ARCH_HIBERNATION_POSSIBLE=y
 CONFIG_ARCH_SUSPEND_POSSIBLE=y
 CONFIG_PM=y
 # CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP=y
 # CONFIG_SUSPEND is not set
-# CONFIG_HIBERNATION is not set
+CONFIG_HIBERNATION_NVS=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION="/dev/hda3"
+# CONFIG_PM_RUNTIME is not set
 CONFIG_NET=y
+CONFIG_COMPAT_NETLINK_MESSAGES=y
 
 #
 # Networking options
@@ -442,6 +459,7 @@ CONFIG_IP_NF_ARPFILTER=m
 CONFIG_IP_NF_ARP_MANGLE=m
 # CONFIG_IP_DCCP is not set
 # CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
 # CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
@@ -473,6 +491,7 @@ CONFIG_NET_CLS_ROUTE=y
 # CONFIG_AF_RXRPC is not set
 CONFIG_WIRELESS=y
 # CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
 CONFIG_WIRELESS_OLD_REGULATORY=y
 CONFIG_WIRELESS_EXT=y
 CONFIG_WIRELESS_EXT_SYSFS=y
@@ -481,7 +500,6 @@ CONFIG_WIRELESS_EXT_SYSFS=y
 #
 # CFG80211 needs to be enabled for MAC80211
 #
-CONFIG_MAC80211_DEFAULT_PS_VALUE=0
 # CONFIG_WIMAX is not set
 # CONFIG_RFKILL is not set
 CONFIG_NET_9P=m
@@ -495,6 +513,7 @@ CONFIG_NET_9P=m
 # Generic Driver Options
 #
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 CONFIG_FW_LOADER=m
@@ -504,9 +523,9 @@ CONFIG_EXTRA_FIRMWARE=""
 # CONFIG_CONNECTOR is not set
 CONFIG_MTD=m
 # CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_TESTS is not set
 # CONFIG_MTD_CONCAT is not set
 # CONFIG_MTD_PARTITIONS is not set
-# CONFIG_MTD_TESTS is not set
 
 #
 # User Modules And Translation Layers
@@ -820,6 +839,7 @@ CONFIG_8139TOO=y
 # CONFIG_SUNDANCE is not set
 # CONFIG_TLAN is not set
 # CONFIG_KS8842 is not set
+# CONFIG_KS8851_MLL is not set
 # CONFIG_VIA_RHINE is not set
 # CONFIG_SC92031 is not set
 # CONFIG_ATL2 is not set
@@ -867,10 +887,7 @@ CONFIG_CHELSIO_T3_DEPENDS=y
 # CONFIG_SFC is not set
 # CONFIG_BE2NET is not set
 # CONFIG_TR is not set
-
-#
-# Wireless LAN
-#
+CONFIG_WLAN=y
 # CONFIG_WLAN_PRE80211 is not set
 # CONFIG_WLAN_80211 is not set
 
@@ -886,6 +903,7 @@ CONFIG_CHELSIO_T3_DEPENDS=y
 # CONFIG_USB_PEGASUS is not set
 # CONFIG_USB_RTL8150 is not set
 # CONFIG_USB_USBNET is not set
+# CONFIG_USB_CDC_PHONET is not set
 # CONFIG_WAN is not set
 # CONFIG_FDDI is not set
 # CONFIG_HIPPI is not set
@@ -933,12 +951,16 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
 # Input Device Drivers
 #
 CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADP5588 is not set
 CONFIG_KEYBOARD_ATKBD=y
-# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_QT2160 is not set
 # CONFIG_KEYBOARD_LKKBD is not set
-# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
 # CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
 # CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
 CONFIG_INPUT_MOUSE=y
 CONFIG_MOUSE_PS2=y
 CONFIG_MOUSE_PS2_ALPS=y
@@ -946,6 +968,7 @@ CONFIG_MOUSE_PS2_LOGIPS2PP=y
 CONFIG_MOUSE_PS2_SYNAPTICS=y
 CONFIG_MOUSE_PS2_TRACKPOINT=y
 # CONFIG_MOUSE_PS2_ELANTECH is not set
+# CONFIG_MOUSE_PS2_SENTELIC is not set
 # CONFIG_MOUSE_PS2_TOUCHKIT is not set
 CONFIG_MOUSE_SERIAL=y
 # CONFIG_MOUSE_APPLETOUCH is not set
@@ -1015,6 +1038,7 @@ CONFIG_RTC=y
 CONFIG_DEVPORT=y
 CONFIG_I2C=m
 CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
 CONFIG_I2C_CHARDEV=m
 CONFIG_I2C_HELPER_AUTO=y
 
@@ -1070,9 +1094,6 @@ CONFIG_I2C_VIAPRO=m
 # Miscellaneous I2C Chip support
 #
 # CONFIG_DS1682 is not set
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_PCF8575 is not set
-# CONFIG_SENSORS_PCA9539 is not set
 # CONFIG_SENSORS_TSL2550 is not set
 # CONFIG_I2C_DEBUG_CORE is not set
 # CONFIG_I2C_DEBUG_ALGO is not set
@@ -1088,7 +1109,6 @@ CONFIG_I2C_VIAPRO=m
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
 # CONFIG_THERMAL is not set
-# CONFIG_THERMAL_HWMON is not set
 # CONFIG_WATCHDOG is not set
 CONFIG_SSB_POSSIBLE=y
 
@@ -1105,6 +1125,7 @@ CONFIG_SSB_POSSIBLE=y
 # CONFIG_HTC_PASIC3 is not set
 # CONFIG_MFD_TMIO is not set
 # CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
 # CONFIG_MFD_WM8350_I2C is not set
 # CONFIG_MFD_PCF50633 is not set
 # CONFIG_AB3100_CORE is not set
@@ -1114,6 +1135,7 @@ CONFIG_SSB_POSSIBLE=y
 #
 # Graphics support
 #
+CONFIG_VGA_ARB=y
 # CONFIG_DRM is not set
 # CONFIG_VGASTATE is not set
 CONFIG_VIDEO_OUTPUT_CONTROL=m
@@ -1198,6 +1220,7 @@ CONFIG_FONT_8x16=y
 # CONFIG_LOGO is not set
 CONFIG_SOUND=y
 CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
 CONFIG_SND=m
 CONFIG_SND_TIMER=m
 CONFIG_SND_PCM=m
@@ -1304,7 +1327,6 @@ CONFIG_SND_USB=y
 CONFIG_AC97_BUS=m
 CONFIG_HID_SUPPORT=y
 CONFIG_HID=y
-# CONFIG_HID_DEBUG is not set
 CONFIG_HIDRAW=y
 
 #
@@ -1356,6 +1378,7 @@ CONFIG_USB_EHCI_TT_NEWSCHED=y
 # CONFIG_USB_OXU210HP_HCD is not set
 # CONFIG_USB_ISP116X_HCD is not set
 CONFIG_USB_ISP1760_HCD=m
+# CONFIG_USB_ISP1362_HCD is not set
 CONFIG_USB_OHCI_HCD=y
 # CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
 # CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
@@ -1453,6 +1476,7 @@ CONFIG_UIO_CIF=m
 # CONFIG_UIO_SMX is not set
 # CONFIG_UIO_AEC is not set
 # CONFIG_UIO_SERCOS3 is not set
+# CONFIG_UIO_PCI_GENERIC is not set
 
 #
 # TI VLYNQ
@@ -1469,10 +1493,10 @@ CONFIG_EXT3_FS=y
 # CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
 # CONFIG_EXT3_FS_XATTR is not set
 CONFIG_EXT4_FS=m
-CONFIG_EXT4DEV_COMPAT=y
 CONFIG_EXT4_FS_XATTR=y
 CONFIG_EXT4_FS_POSIX_ACL=y
 CONFIG_EXT4_FS_SECURITY=y
+# CONFIG_EXT4_DEBUG is not set
 CONFIG_FS_XIP=y
 CONFIG_JBD=y
 # CONFIG_JBD_DEBUG is not set
@@ -1489,6 +1513,7 @@ CONFIG_FS_POSIX_ACL=y
 # CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
 # CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
 CONFIG_FILE_LOCKING=y
 CONFIG_FSNOTIFY=y
 CONFIG_DNOTIFY=y
@@ -1557,7 +1582,6 @@ CONFIG_OMFS_FS=m
 # CONFIG_ROMFS_FS is not set
 # CONFIG_SYSV_FS is not set
 # CONFIG_UFS_FS is not set
-# CONFIG_NILFS2_FS is not set
 CONFIG_NETWORK_FILESYSTEMS=y
 CONFIG_NFS_FS=m
 CONFIG_NFS_V3=y
@@ -1666,6 +1690,7 @@ CONFIG_ENABLE_WARN_DEPRECATED=y
 # CONFIG_ENABLE_MUST_CHECK is not set
 CONFIG_FRAME_WARN=2048
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_STRIP_ASM_SYMS is not set
 # CONFIG_UNUSED_SYMBOLS is not set
 CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
@@ -1678,13 +1703,14 @@ CONFIG_NOP_TRACER=y
 CONFIG_RING_BUFFER=y
 CONFIG_EVENT_TRACING=y
 CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_RING_BUFFER_ALLOW_SWAP=y
 CONFIG_TRACING=y
 CONFIG_TRACING_SUPPORT=y
 # CONFIG_FTRACE is not set
 # CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
@@ -1742,11 +1768,13 @@ CONFIG_CRYPTO_XTS=m
 #
 CONFIG_CRYPTO_HMAC=y
 # CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
 
 #
 # Digest
 #
 # CONFIG_CRYPTO_CRC32C is not set
+CONFIG_CRYPTO_GHASH=m
 # CONFIG_CRYPTO_MD4 is not set
 CONFIG_CRYPTO_MD5=m
 # CONFIG_CRYPTO_MICHAEL_MIC is not set
index f14d38ba6034ea897e71764071475dc7b7a88af6..222d7eca2fe4afd7ac516c2d69bd3d182785b299 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -1188,7 +1187,7 @@ CONFIG_DEBUG_MEMORY_INIT=y
 CONFIG_DYNAMIC_PRINTK_DEBUG=y
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 1fc73aa7b509c73df1e6133899c7be4d8f5b0c47..ed84b4cb3c8dc2d0f7ac49fbbf9cfbf6967da512 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -940,7 +939,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 539dccb0345d18610d8e5407e92a4e12471f6cd7..dab2e5aaadaf5993f3680482b22299b65d42eac4 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -816,7 +815,7 @@ CONFIG_MAGIC_SYSRQ=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SAMPLES is not set
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index d934bdefb393b44efc0444f499909ffb651f1ffc..1841c88d3d242c7dca05e60d9656fb5c30d2eebe 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -1126,7 +1125,7 @@ CONFIG_SYSCTL_SYSCALL_CHECK=y
 # CONFIG_DYNAMIC_PRINTK_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index d22df61833a8efd95369f797d46b09f552b58299..14c2ab3b267400937fa6bb1f79daeb335a9b05c7 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 CONFIG_MACH_JAZZ=y
@@ -1374,7 +1373,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 5380f1f582d90e421eed8ec919e0dd37604f0bc5..4d66c44cced82f09e73911c977004ae359477c72 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -835,7 +834,7 @@ CONFIG_SYSCTL_SYSCALL_CHECK=y
 # CONFIG_DYNAMIC_PRINTK_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 044074db7e55a40255f45b2a3121869fa4316435..08d481e3d42ae582ba214d76d3bffff84fa0afef 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -798,7 +797,7 @@ CONFIG_MAGIC_SYSRQ=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
diff --git a/arch/mips/configs/lemote2f_defconfig b/arch/mips/configs/lemote2f_defconfig
new file mode 100644 (file)
index 0000000..b71a0a4
--- /dev/null
@@ -0,0 +1,1835 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.32-rc6
+# Mon Nov  9 23:42:42 2009
+#
+CONFIG_MIPS=y
+
+#
+# Machine selection
+#
+# CONFIG_MACH_ALCHEMY is not set
+# CONFIG_AR7 is not set
+# CONFIG_BCM47XX is not set
+# CONFIG_BCM63XX is not set
+# CONFIG_MIPS_COBALT is not set
+# CONFIG_MACH_DECSTATION is not set
+# CONFIG_MACH_JAZZ is not set
+# CONFIG_LASAT is not set
+CONFIG_MACH_LOONGSON=y
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_MIPS_SIM is not set
+# CONFIG_NEC_MARKEINS is not set
+# CONFIG_MACH_VR41XX is not set
+# CONFIG_NXP_STB220 is not set
+# CONFIG_NXP_STB225 is not set
+# CONFIG_PNX8550_JBS is not set
+# CONFIG_PNX8550_STB810 is not set
+# CONFIG_PMC_MSP is not set
+# CONFIG_PMC_YOSEMITE is not set
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SGI_IP27 is not set
+# CONFIG_SGI_IP28 is not set
+# CONFIG_SGI_IP32 is not set
+# CONFIG_SIBYTE_CRHINE is not set
+# CONFIG_SIBYTE_CARMEL is not set
+# CONFIG_SIBYTE_CRHONE is not set
+# CONFIG_SIBYTE_RHONE is not set
+# CONFIG_SIBYTE_SWARM is not set
+# CONFIG_SIBYTE_LITTLESUR is not set
+# CONFIG_SIBYTE_SENTOSA is not set
+# CONFIG_SIBYTE_BIGSUR is not set
+# CONFIG_SNI_RM is not set
+# CONFIG_MACH_TX39XX is not set
+# CONFIG_MACH_TX49XX is not set
+# CONFIG_MIKROTIK_RB532 is not set
+# CONFIG_WR_PPMC is not set
+# CONFIG_CAVIUM_OCTEON_SIMULATOR is not set
+# CONFIG_CAVIUM_OCTEON_REFERENCE_BOARD is not set
+# CONFIG_ALCHEMY_GPIO_INDIRECT is not set
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+# CONFIG_LEMOTE_FULOONG2E is not set
+CONFIG_LEMOTE_MACH2F=y
+CONFIG_CS5536=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_SUPPORTS_OPROFILE=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_SCHED_OMIT_FRAME_POINTER=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
+CONFIG_CEVT_R4K_LIB=y
+CONFIG_CEVT_R4K=y
+CONFIG_CSRC_R4K_LIB=y
+CONFIG_CSRC_R4K=y
+CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_SYS_HAS_EARLY_PRINTK=y
+CONFIG_I8259=y
+# CONFIG_NO_IOPORT is not set
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_ISA_DMA_SUPPORT_BROKEN=y
+# CONFIG_CPU_BIG_ENDIAN is not set
+CONFIG_CPU_LITTLE_ENDIAN=y
+CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
+CONFIG_IRQ_CPU=y
+CONFIG_BOOT_ELF32=y
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+
+#
+# CPU selection
+#
+# CONFIG_CPU_LOONGSON2E is not set
+CONFIG_CPU_LOONGSON2F=y
+# CONFIG_CPU_MIPS32_R1 is not set
+# CONFIG_CPU_MIPS32_R2 is not set
+# CONFIG_CPU_MIPS64_R1 is not set
+# CONFIG_CPU_MIPS64_R2 is not set
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_TX39XX is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_TX49XX is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_R5500 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R8000 is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_RM9000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_CAVIUM_OCTEON is not set
+CONFIG_SYS_SUPPORTS_ZBOOT=y
+CONFIG_SYS_SUPPORTS_ZBOOT_UART16550=y
+CONFIG_CPU_LOONGSON2=y
+CONFIG_SYS_HAS_CPU_LOONGSON2F=y
+CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
+CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
+
+#
+# Kernel type
+#
+# CONFIG_32BIT is not set
+CONFIG_64BIT=y
+# CONFIG_PAGE_SIZE_4KB is not set
+# CONFIG_PAGE_SIZE_8KB is not set
+CONFIG_PAGE_SIZE_16KB=y
+# CONFIG_PAGE_SIZE_32KB is not set
+# CONFIG_PAGE_SIZE_64KB is not set
+CONFIG_BOARD_SCACHE=y
+CONFIG_MIPS_MT_DISABLED=y
+# CONFIG_MIPS_MT_SMP is not set
+# CONFIG_MIPS_MT_SMTC is not set
+CONFIG_CPU_HAS_WB=y
+CONFIG_CPU_HAS_SYNC=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_CPU_SUPPORTS_HIGHMEM=y
+CONFIG_SYS_SUPPORTS_HIGHMEM=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+CONFIG_SPARSEMEM_MANUAL=y
+CONFIG_SPARSEMEM=y
+CONFIG_HAVE_MEMORY_PRESENT=y
+CONFIG_SPARSEMEM_STATIC=y
+
+#
+# Memory hotplug is currently incompatible with Software Suspend
+#
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_PHYS_ADDR_T_64BIT=y
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+# CONFIG_HZ_48 is not set
+# CONFIG_HZ_100 is not set
+# CONFIG_HZ_128 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_256 is not set
+# CONFIG_HZ_1000 is not set
+# CONFIG_HZ_1024 is not set
+CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
+CONFIG_HZ=250
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+CONFIG_PREEMPT=y
+# CONFIG_KEXEC is not set
+# CONFIG_SECCOMP is not set
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_HAVE_KERNEL_GZIP=y
+CONFIG_HAVE_KERNEL_BZIP2=y
+CONFIG_HAVE_KERNEL_LZMA=y
+# CONFIG_KERNEL_GZIP is not set
+# CONFIG_KERNEL_BZIP2 is not set
+CONFIG_KERNEL_LZMA=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+# CONFIG_TASKSTATS is not set
+CONFIG_AUDIT=y
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=64
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=15
+# CONFIG_GROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_RELAY is not set
+# CONFIG_NAMESPACES is not set
+# CONFIG_BLK_DEV_INITRD is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_PCSPKR_PLATFORM=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_PCI_QUIRKS=y
+CONFIG_SLUB_DEBUG=y
+CONFIG_COMPAT_BRK=y
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_HAVE_OPROFILE=y
+CONFIG_HAVE_SYSCALL_WRAPPERS=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_SLOW_WORK is not set
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODVERSIONS=y
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_BLOCK=y
+CONFIG_BLK_DEV_BSG=y
+CONFIG_BLK_DEV_INTEGRITY=y
+CONFIG_BLOCK_COMPAT=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_FREEZER=y
+
+#
+# Bus options (PCI, PCMCIA, EISA, ISA, TC)
+#
+CONFIG_HW_HAS_PCI=y
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+CONFIG_PCI_LEGACY=y
+# CONFIG_PCI_STUB is not set
+# CONFIG_PCI_IOV is not set
+CONFIG_ISA=y
+CONFIG_MMU=y
+# CONFIG_PCCARD is not set
+# CONFIG_HOTPLUG_PCI is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+CONFIG_MIPS32_COMPAT=y
+CONFIG_COMPAT=y
+CONFIG_SYSVIPC_COMPAT=y
+CONFIG_MIPS32_O32=y
+CONFIG_MIPS32_N32=y
+CONFIG_BINFMT_ELF32=y
+
+#
+# Power management options
+#
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATION_NVS=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION="/dev/hda3"
+# CONFIG_PM_RUNTIME is not set
+CONFIG_NET=y
+CONFIG_COMPAT_NETLINK_MESSAGES=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=y
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=y
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+# CONFIG_TCP_CONG_HSTCP is not set
+# CONFIG_TCP_CONG_HYBLA is not set
+# CONFIG_TCP_CONG_VEGAS is not set
+# CONFIG_TCP_CONG_SCALABLE is not set
+# CONFIG_TCP_CONG_LP is not set
+# CONFIG_TCP_CONG_VENO is not set
+# CONFIG_TCP_CONG_YEAH is not set
+# CONFIG_TCP_CONG_ILLINOIS is not set
+CONFIG_DEFAULT_BIC=y
+# CONFIG_DEFAULT_CUBIC is not set
+# CONFIG_DEFAULT_HTCP is not set
+# CONFIG_DEFAULT_VEGAS is not set
+# CONFIG_DEFAULT_WESTWOOD is not set
+# CONFIG_DEFAULT_RENO is not set
+CONFIG_DEFAULT_TCP_CONG="bic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+# CONFIG_INET6_AH is not set
+# CONFIG_INET6_ESP is not set
+# CONFIG_INET6_IPCOMP is not set
+# CONFIG_IPV6_MIP6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_BEET=m
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+CONFIG_IPV6_SIT=m
+CONFIG_IPV6_NDISC_NODETYPE=y
+# CONFIG_IPV6_TUNNEL is not set
+# CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_IPV6_MROUTE is not set
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+
+#
+# Core Netfilter Configuration
+#
+# CONFIG_NETFILTER_NETLINK_QUEUE is not set
+# CONFIG_NETFILTER_NETLINK_LOG is not set
+# CONFIG_NF_CONNTRACK is not set
+# CONFIG_NETFILTER_XTABLES is not set
+# CONFIG_IP_VS is not set
+
+#
+# IP: Netfilter Configuration
+#
+# CONFIG_NF_DEFRAG_IPV4 is not set
+# CONFIG_IP_NF_QUEUE is not set
+# CONFIG_IP_NF_IPTABLES is not set
+# CONFIG_IP_NF_ARPTABLES is not set
+
+#
+# IPv6: Netfilter Configuration
+#
+# CONFIG_IP6_NF_QUEUE is not set
+# CONFIG_IP6_NF_IPTABLES is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+# CONFIG_NET_SCH_CBQ is not set
+# CONFIG_NET_SCH_HTB is not set
+# CONFIG_NET_SCH_HFSC is not set
+# CONFIG_NET_SCH_PRIO is not set
+# CONFIG_NET_SCH_MULTIQ is not set
+# CONFIG_NET_SCH_RED is not set
+# CONFIG_NET_SCH_SFQ is not set
+# CONFIG_NET_SCH_TEQL is not set
+# CONFIG_NET_SCH_TBF is not set
+# CONFIG_NET_SCH_GRED is not set
+# CONFIG_NET_SCH_DSMARK is not set
+# CONFIG_NET_SCH_NETEM is not set
+# CONFIG_NET_SCH_DRR is not set
+# CONFIG_NET_SCH_INGRESS is not set
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+# CONFIG_NET_CLS_BASIC is not set
+# CONFIG_NET_CLS_TCINDEX is not set
+# CONFIG_NET_CLS_ROUTE4 is not set
+# CONFIG_NET_CLS_FW is not set
+# CONFIG_NET_CLS_U32 is not set
+# CONFIG_NET_CLS_RSVP is not set
+# CONFIG_NET_CLS_RSVP6 is not set
+# CONFIG_NET_CLS_FLOW is not set
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+# CONFIG_NET_EMATCH_CMP is not set
+# CONFIG_NET_EMATCH_NBYTE is not set
+# CONFIG_NET_EMATCH_U32 is not set
+# CONFIG_NET_EMATCH_META is not set
+# CONFIG_NET_EMATCH_TEXT is not set
+CONFIG_NET_CLS_ACT=y
+# CONFIG_NET_ACT_POLICE is not set
+# CONFIG_NET_ACT_GACT is not set
+# CONFIG_NET_ACT_MIRRED is not set
+# CONFIG_NET_ACT_NAT is not set
+# CONFIG_NET_ACT_PEDIT is not set
+# CONFIG_NET_ACT_SIMP is not set
+# CONFIG_NET_ACT_SKBEDIT is not set
+CONFIG_NET_SCH_FIFO=y
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+CONFIG_FIB_RULES=y
+CONFIG_WIRELESS=y
+# CONFIG_CFG80211 is not set
+CONFIG_CFG80211_DEFAULT_PS_VALUE=0
+# CONFIG_WIRELESS_OLD_REGULATORY is not set
+CONFIG_WIRELESS_EXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+# CONFIG_LIB80211 is not set
+
+#
+# CFG80211 needs to be enabled for MAC80211
+#
+# CONFIG_WIMAX is not set
+CONFIG_RFKILL=m
+# CONFIG_RFKILL_INPUT is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+# CONFIG_MTD is not set
+# CONFIG_PARPORT is not set
+# CONFIG_PNP is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_CRYPTOLOOP=y
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=8192
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_BLK_DEV_HD is not set
+CONFIG_MISC_DEVICES=y
+# CONFIG_PHANTOM is not set
+# CONFIG_SGI_IOC4 is not set
+# CONFIG_TIFM_CORE is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_HP_ILO is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_93CX6 is not set
+# CONFIG_CB710_CORE is not set
+CONFIG_HAVE_IDE=y
+CONFIG_IDE=y
+
+#
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
+#
+CONFIG_IDE_XFER_MODE=y
+CONFIG_IDE_TIMINGS=y
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_IDE_GD=y
+CONFIG_IDE_GD_ATA=y
+# CONFIG_IDE_GD_ATAPI is not set
+# CONFIG_BLK_DEV_IDECD is not set
+# CONFIG_BLK_DEV_IDETAPE is not set
+CONFIG_IDE_TASK_IOCTL=y
+CONFIG_IDE_PROC_FS=y
+
+#
+# IDE chipset support/bugfixes
+#
+# CONFIG_IDE_GENERIC is not set
+# CONFIG_BLK_DEV_PLATFORM is not set
+CONFIG_BLK_DEV_IDEDMA_SFF=y
+
+#
+# PCI IDE chipsets support
+#
+CONFIG_BLK_DEV_IDEPCI=y
+# CONFIG_IDEPCI_PCIBUS_ORDER is not set
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+# CONFIG_BLK_DEV_CMD64X is not set
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT366 is not set
+# CONFIG_BLK_DEV_JMICRON is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+# CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_IT8172 is not set
+# CONFIG_BLK_DEV_IT8213 is not set
+# CONFIG_BLK_DEV_IT821X is not set
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+# CONFIG_BLK_DEV_TC86C001 is not set
+
+#
+# Other IDE chipsets support
+#
+
+#
+# Note: most of these also require special kernel boot parameters
+#
+# CONFIG_BLK_DEV_4DRIVES is not set
+# CONFIG_BLK_DEV_ALI14XX is not set
+# CONFIG_BLK_DEV_DTC2278 is not set
+# CONFIG_BLK_DEV_HT6560B is not set
+# CONFIG_BLK_DEV_QD65XX is not set
+# CONFIG_BLK_DEV_UMC8672 is not set
+CONFIG_BLK_DEV_IDEDMA=y
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_TGT is not set
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+CONFIG_CHR_DEV_SG=m
+# CONFIG_CHR_DEV_SCH is not set
+CONFIG_SCSI_MULTI_LUN=y
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# You can enable one or both FireWire driver stacks.
+#
+
+#
+# See the help texts for more information.
+#
+# CONFIG_FIREWIRE is not set
+# CONFIG_IEEE1394 is not set
+# CONFIG_I2O is not set
+CONFIG_NETDEVICES=y
+# CONFIG_IFB is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+# CONFIG_ARCNET is not set
+# CONFIG_PHYLIB is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_AX88796 is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_CASSINI is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_SMC91X is not set
+# CONFIG_DM9000 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_DNET is not set
+# CONFIG_NET_TULIP is not set
+# CONFIG_AT1700 is not set
+# CONFIG_DEPCA is not set
+# CONFIG_HP100 is not set
+# CONFIG_NET_ISA is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+CONFIG_NET_PCI=y
+# CONFIG_PCNET32 is not set
+# CONFIG_AMD8111_ETH is not set
+# CONFIG_ADAPTEC_STARFIRE is not set
+# CONFIG_AC3200 is not set
+# CONFIG_APRICOT is not set
+# CONFIG_B44 is not set
+# CONFIG_FORCEDETH is not set
+# CONFIG_CS89x0 is not set
+# CONFIG_TC35815 is not set
+# CONFIG_E100 is not set
+# CONFIG_FEALNX is not set
+# CONFIG_NATSEMI is not set
+# CONFIG_NE2K_PCI is not set
+# CONFIG_8139CP is not set
+CONFIG_8139TOO=y
+# CONFIG_8139TOO_PIO is not set
+CONFIG_8139TOO_TUNE_TWISTER=y
+# CONFIG_8139TOO_8129 is not set
+# CONFIG_8139_OLD_RX_RESET is not set
+# CONFIG_R6040 is not set
+# CONFIG_SIS900 is not set
+# CONFIG_EPIC100 is not set
+# CONFIG_SMSC9420 is not set
+# CONFIG_SUNDANCE is not set
+# CONFIG_TLAN is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851_MLL is not set
+# CONFIG_VIA_RHINE is not set
+# CONFIG_SC92031 is not set
+# CONFIG_ATL2 is not set
+CONFIG_NETDEV_1000=y
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_E1000E is not set
+# CONFIG_IP1000 is not set
+# CONFIG_IGB is not set
+# CONFIG_IGBVF is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+CONFIG_R8169=y
+# CONFIG_SIS190 is not set
+# CONFIG_SKGE is not set
+# CONFIG_SKY2 is not set
+# CONFIG_VIA_VELOCITY is not set
+# CONFIG_TIGON3 is not set
+# CONFIG_BNX2 is not set
+# CONFIG_CNIC is not set
+# CONFIG_QLA3XXX is not set
+# CONFIG_ATL1 is not set
+# CONFIG_ATL1E is not set
+# CONFIG_ATL1C is not set
+# CONFIG_JME is not set
+# CONFIG_NETDEV_10000 is not set
+# CONFIG_TR is not set
+CONFIG_WLAN=y
+CONFIG_WLAN_PRE80211=y
+# CONFIG_STRIP is not set
+# CONFIG_WAVELAN is not set
+CONFIG_WLAN_80211=y
+# CONFIG_LIBERTAS is not set
+# CONFIG_ATMEL is not set
+# CONFIG_PRISM54 is not set
+# CONFIG_USB_ZD1201 is not set
+# CONFIG_HOSTAP is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
+# CONFIG_USB_HSO is not set
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+# CONFIG_INPUT_POLLDEV is not set
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+# CONFIG_MOUSE_PS2_ALPS is not set
+# CONFIG_MOUSE_PS2_LOGIPS2PP is not set
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+# CONFIG_MOUSE_PS2_TRACKPOINT is not set
+# CONFIG_MOUSE_PS2_ELANTECH is not set
+# CONFIG_MOUSE_PS2_SENTELIC is not set
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_APPLETOUCH is not set
+# CONFIG_MOUSE_BCM5974 is not set
+# CONFIG_MOUSE_INPORT is not set
+# CONFIG_MOUSE_LOGIBM is not set
+# CONFIG_MOUSE_PC110PAD is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_LIBPS2=y
+# CONFIG_SERIO_RAW is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+CONFIG_DEVKMEM=y
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+# CONFIG_ROCKETPORT is not set
+# CONFIG_CYCLADES is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_ISI is not set
+# CONFIG_SYNCLINKMP is not set
+# CONFIG_SYNCLINK_GT is not set
+# CONFIG_N_HDLC is not set
+# CONFIG_RISCOM8 is not set
+# CONFIG_SPECIALIX is not set
+# CONFIG_STALDRV is not set
+# CONFIG_NOZOMI is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+# CONFIG_SERIAL_8250_PCI is not set
+CONFIG_SERIAL_8250_NR_UARTS=16
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_FOURPORT=y
+# CONFIG_SERIAL_8250_ACCENT is not set
+# CONFIG_SERIAL_8250_BOCA is not set
+# CONFIG_SERIAL_8250_EXAR_ST16C554 is not set
+# CONFIG_SERIAL_8250_HUB6 is not set
+# CONFIG_SERIAL_8250_SHARE_IRQ is not set
+# CONFIG_SERIAL_8250_DETECT_IRQ is not set
+# CONFIG_SERIAL_8250_RSA is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_JSM is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=16
+# CONFIG_IPMI_HANDLER is not set
+CONFIG_HW_RANDOM=y
+# CONFIG_HW_RANDOM_TIMERIOMEM is not set
+CONFIG_RTC=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_DEVPORT=y
+# CONFIG_I2C is not set
+# CONFIG_SPI is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Native drivers
+#
+# CONFIG_SENSORS_I5K_AMB is not set
+# CONFIG_SENSORS_F71805F is not set
+# CONFIG_SENSORS_F71882FG is not set
+# CONFIG_SENSORS_IT87 is not set
+# CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_PC87427 is not set
+# CONFIG_SENSORS_SIS5595 is not set
+# CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_SMSC47B397 is not set
+# CONFIG_SENSORS_VIA686A is not set
+# CONFIG_SENSORS_VT1211 is not set
+# CONFIG_SENSORS_VT8231 is not set
+# CONFIG_SENSORS_W83627HF is not set
+# CONFIG_SENSORS_W83627EHF is not set
+CONFIG_THERMAL=y
+# CONFIG_THERMAL_HWMON is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_REGULATOR is not set
+CONFIG_MEDIA_SUPPORT=m
+
+#
+# Multimedia core support
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L2_COMMON=m
+CONFIG_VIDEO_ALLOW_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+# CONFIG_DVB_CORE is not set
+CONFIG_VIDEO_MEDIA=m
+
+#
+# Multimedia drivers
+#
+# CONFIG_MEDIA_ATTACH is not set
+CONFIG_VIDEO_V4L2=m
+CONFIG_VIDEO_V4L1=m
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+# CONFIG_VIDEO_VIVI is not set
+# CONFIG_VIDEO_PMS is not set
+# CONFIG_VIDEO_CPIA is not set
+# CONFIG_VIDEO_CPIA2 is not set
+# CONFIG_VIDEO_STRADIS is not set
+CONFIG_V4L_USB_DRIVERS=y
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
+CONFIG_USB_GSPCA=m
+# CONFIG_USB_M5602 is not set
+# CONFIG_USB_STV06XX is not set
+# CONFIG_USB_GL860 is not set
+# CONFIG_USB_GSPCA_CONEX is not set
+# CONFIG_USB_GSPCA_ETOMS is not set
+# CONFIG_USB_GSPCA_FINEPIX is not set
+# CONFIG_USB_GSPCA_JEILINJ is not set
+# CONFIG_USB_GSPCA_MARS is not set
+# CONFIG_USB_GSPCA_MR97310A is not set
+# CONFIG_USB_GSPCA_OV519 is not set
+# CONFIG_USB_GSPCA_OV534 is not set
+# CONFIG_USB_GSPCA_PAC207 is not set
+# CONFIG_USB_GSPCA_PAC7311 is not set
+# CONFIG_USB_GSPCA_SN9C20X is not set
+# CONFIG_USB_GSPCA_SONIXB is not set
+# CONFIG_USB_GSPCA_SONIXJ is not set
+# CONFIG_USB_GSPCA_SPCA500 is not set
+# CONFIG_USB_GSPCA_SPCA501 is not set
+# CONFIG_USB_GSPCA_SPCA505 is not set
+# CONFIG_USB_GSPCA_SPCA506 is not set
+# CONFIG_USB_GSPCA_SPCA508 is not set
+# CONFIG_USB_GSPCA_SPCA561 is not set
+# CONFIG_USB_GSPCA_SQ905 is not set
+# CONFIG_USB_GSPCA_SQ905C is not set
+# CONFIG_USB_GSPCA_STK014 is not set
+# CONFIG_USB_GSPCA_SUNPLUS is not set
+# CONFIG_USB_GSPCA_T613 is not set
+# CONFIG_USB_GSPCA_TV8532 is not set
+# CONFIG_USB_GSPCA_VC032X is not set
+# CONFIG_USB_GSPCA_ZC3XX is not set
+# CONFIG_VIDEO_HDPVR is not set
+# CONFIG_USB_VICAM is not set
+# CONFIG_USB_IBMCAM is not set
+# CONFIG_USB_KONICAWC is not set
+# CONFIG_USB_QUICKCAM_MESSENGER is not set
+# CONFIG_USB_ET61X251 is not set
+# CONFIG_USB_OV511 is not set
+# CONFIG_USB_SE401 is not set
+# CONFIG_USB_SN9C102 is not set
+# CONFIG_USB_STV680 is not set
+# CONFIG_USB_ZC0301 is not set
+# CONFIG_USB_PWC is not set
+CONFIG_USB_PWC_INPUT_EVDEV=y
+# CONFIG_USB_ZR364XX is not set
+# CONFIG_USB_STKWEBCAM is not set
+# CONFIG_USB_S2255 is not set
+# CONFIG_RADIO_ADAPTERS is not set
+# CONFIG_DAB is not set
+
+#
+# Graphics support
+#
+CONFIG_VGA_ARB=y
+# CONFIG_DRM is not set
+# CONFIG_VGASTATE is not set
+CONFIG_VIDEO_OUTPUT_CONTROL=y
+CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+# CONFIG_FB_DDC is not set
+CONFIG_FB_BOOT_VESA_SUPPORT=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+# CONFIG_FB_SYS_FILLRECT is not set
+# CONFIG_FB_SYS_COPYAREA is not set
+# CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+# CONFIG_FB_SYS_FOPS is not set
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+
+#
+# Frame buffer hardware drivers
+#
+# CONFIG_FB_CIRRUS is not set
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+# CONFIG_FB_S1D13XXX is not set
+# CONFIG_FB_NVIDIA is not set
+# CONFIG_FB_RIVA is not set
+# CONFIG_FB_MATROX is not set
+# CONFIG_FB_RADEON is not set
+# CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
+# CONFIG_FB_S3 is not set
+# CONFIG_FB_SAVAGE is not set
+CONFIG_FB_SIS=y
+CONFIG_FB_SIS_300=y
+CONFIG_FB_SIS_315=y
+# CONFIG_FB_VIA is not set
+# CONFIG_FB_NEOMAGIC is not set
+# CONFIG_FB_KYRO is not set
+# CONFIG_FB_3DFX is not set
+# CONFIG_FB_VOODOO1 is not set
+# CONFIG_FB_VT8623 is not set
+# CONFIG_FB_TRIDENT is not set
+# CONFIG_FB_ARK is not set
+# CONFIG_FB_PM3 is not set
+# CONFIG_FB_CARMINE is not set
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_GENERIC=y
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+# CONFIG_MDA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+CONFIG_FONTS=y
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+CONFIG_FONT_6x11=y
+CONFIG_FONT_7x14=y
+CONFIG_FONT_PEARL_8x8=y
+CONFIG_FONT_ACORN_8x8=y
+CONFIG_FONT_MINI_4x6=y
+CONFIG_FONT_SUN8x16=y
+CONFIG_FONT_SUN12x22=y
+CONFIG_FONT_10x18=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_SOUND=m
+# CONFIG_SOUND_OSS_CORE is not set
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+# CONFIG_SND_SEQUENCER is not set
+# CONFIG_SND_MIXER_OSS is not set
+# CONFIG_SND_PCM_OSS is not set
+# CONFIG_SND_HRTIMER is not set
+# CONFIG_SND_RTCTIMER is not set
+# CONFIG_SND_DYNAMIC_MINORS is not set
+# CONFIG_SND_SUPPORT_OLD_API is not set
+# CONFIG_SND_VERBOSE_PROCFS is not set
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+CONFIG_SND_AC97_CODEC=m
+# CONFIG_SND_DRIVERS is not set
+CONFIG_SND_PCI=y
+# CONFIG_SND_AD1889 is not set
+# CONFIG_SND_ALS300 is not set
+# CONFIG_SND_ALI5451 is not set
+# CONFIG_SND_ATIIXP is not set
+# CONFIG_SND_ATIIXP_MODEM is not set
+# CONFIG_SND_AU8810 is not set
+# CONFIG_SND_AU8820 is not set
+# CONFIG_SND_AU8830 is not set
+# CONFIG_SND_AW2 is not set
+# CONFIG_SND_AZT3328 is not set
+# CONFIG_SND_BT87X is not set
+# CONFIG_SND_CA0106 is not set
+# CONFIG_SND_CMIPCI is not set
+# CONFIG_SND_OXYGEN is not set
+# CONFIG_SND_CS4281 is not set
+# CONFIG_SND_CS46XX is not set
+CONFIG_SND_CS5535AUDIO=m
+# CONFIG_SND_CTXFI is not set
+# CONFIG_SND_DARLA20 is not set
+# CONFIG_SND_GINA20 is not set
+# CONFIG_SND_LAYLA20 is not set
+# CONFIG_SND_DARLA24 is not set
+# CONFIG_SND_GINA24 is not set
+# CONFIG_SND_LAYLA24 is not set
+# CONFIG_SND_MONA is not set
+# CONFIG_SND_MIA is not set
+# CONFIG_SND_ECHO3G is not set
+# CONFIG_SND_INDIGO is not set
+# CONFIG_SND_INDIGOIO is not set
+# CONFIG_SND_INDIGODJ is not set
+# CONFIG_SND_INDIGOIOX is not set
+# CONFIG_SND_INDIGODJX is not set
+# CONFIG_SND_EMU10K1 is not set
+# CONFIG_SND_EMU10K1X is not set
+# CONFIG_SND_ENS1370 is not set
+# CONFIG_SND_ENS1371 is not set
+# CONFIG_SND_ES1938 is not set
+# CONFIG_SND_ES1968 is not set
+# CONFIG_SND_FM801 is not set
+# CONFIG_SND_HDA_INTEL is not set
+# CONFIG_SND_HDSP is not set
+# CONFIG_SND_HDSPM is not set
+# CONFIG_SND_HIFIER is not set
+# CONFIG_SND_ICE1712 is not set
+# CONFIG_SND_ICE1724 is not set
+# CONFIG_SND_INTEL8X0 is not set
+# CONFIG_SND_INTEL8X0M is not set
+# CONFIG_SND_KORG1212 is not set
+# CONFIG_SND_LX6464ES is not set
+# CONFIG_SND_MAESTRO3 is not set
+# CONFIG_SND_MIXART is not set
+# CONFIG_SND_NM256 is not set
+# CONFIG_SND_PCXHR is not set
+# CONFIG_SND_RIPTIDE is not set
+# CONFIG_SND_RME32 is not set
+# CONFIG_SND_RME96 is not set
+# CONFIG_SND_RME9652 is not set
+# CONFIG_SND_SONICVIBES is not set
+# CONFIG_SND_TRIDENT is not set
+# CONFIG_SND_VIA82XX is not set
+# CONFIG_SND_VIA82XX_MODEM is not set
+# CONFIG_SND_VIRTUOSO is not set
+# CONFIG_SND_VX222 is not set
+# CONFIG_SND_YMFPCI is not set
+# CONFIG_SND_MIPS is not set
+# CONFIG_SND_USB is not set
+# CONFIG_SND_SOC is not set
+# CONFIG_SOUND_PRIME is not set
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+CONFIG_HIDRAW=y
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+# CONFIG_HID_PID is not set
+CONFIG_USB_HIDDEV=y
+
+#
+# Special HID drivers
+#
+# CONFIG_HID_A4TECH is not set
+# CONFIG_HID_APPLE is not set
+# CONFIG_HID_BELKIN is not set
+# CONFIG_HID_CHERRY is not set
+# CONFIG_HID_CHICONY is not set
+# CONFIG_HID_CYPRESS is not set
+# CONFIG_HID_DRAGONRISE is not set
+# CONFIG_HID_EZKEY is not set
+# CONFIG_HID_KYE is not set
+# CONFIG_HID_GYRATION is not set
+# CONFIG_HID_TWINHAN is not set
+# CONFIG_HID_KENSINGTON is not set
+# CONFIG_HID_LOGITECH is not set
+# CONFIG_HID_MICROSOFT is not set
+# CONFIG_HID_MONTEREY is not set
+# CONFIG_HID_NTRIG is not set
+# CONFIG_HID_PANTHERLORD is not set
+# CONFIG_HID_PETALYNX is not set
+# CONFIG_HID_SAMSUNG is not set
+# CONFIG_HID_SONY is not set
+# CONFIG_HID_SUNPLUS is not set
+# CONFIG_HID_GREENASIA is not set
+# CONFIG_HID_SMARTJOYPLUS is not set
+# CONFIG_HID_TOPSEED is not set
+# CONFIG_HID_THRUSTMASTER is not set
+# CONFIG_HID_ZEROPLUS is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
+CONFIG_USB_DYNAMIC_MINORS=y
+CONFIG_USB_SUSPEND=y
+# CONFIG_USB_OTG is not set
+CONFIG_USB_OTG_WHITELIST=y
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+CONFIG_USB_MON=y
+# CONFIG_USB_WUSB is not set
+# CONFIG_USB_WUSB_CBAF is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_C67X00_HCD is not set
+# CONFIG_USB_XHCI_HCD is not set
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+# CONFIG_USB_EHCI_TT_NEWSCHED is not set
+# CONFIG_USB_OXU210HP_HCD is not set
+# CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_ISP1760_HCD is not set
+# CONFIG_USB_ISP1362_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+# CONFIG_USB_SL811_HCD is not set
+# CONFIG_USB_R8A66597_HCD is not set
+# CONFIG_USB_WHCI_HCD is not set
+# CONFIG_USB_HWA_HCD is not set
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+# CONFIG_USB_PRINTER is not set
+CONFIG_USB_WDM=m
+# CONFIG_USB_TMC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+
+#
+# also be needed; see USB_STORAGE Help for more info
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=m
+CONFIG_USB_STORAGE_FREECOM=m
+CONFIG_USB_STORAGE_ISD200=m
+CONFIG_USB_STORAGE_USBAT=m
+CONFIG_USB_STORAGE_SDDR09=m
+CONFIG_USB_STORAGE_SDDR55=m
+CONFIG_USB_STORAGE_JUMPSHOT=m
+CONFIG_USB_STORAGE_ALAUDA=m
+# CONFIG_USB_STORAGE_ONETOUCH is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB port drivers
+#
+CONFIG_USB_SERIAL=m
+# CONFIG_USB_EZUSB is not set
+CONFIG_USB_SERIAL_GENERIC=y
+# CONFIG_USB_SERIAL_AIRCABLE is not set
+# CONFIG_USB_SERIAL_ARK3116 is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_CH341 is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_CP210X is not set
+# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_FUNSOFT is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_IPAQ is not set
+# CONFIG_USB_SERIAL_IR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
+# CONFIG_USB_SERIAL_GARMIN is not set
+# CONFIG_USB_SERIAL_IPW is not set
+# CONFIG_USB_SERIAL_IUU is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KLSI is not set
+# CONFIG_USB_SERIAL_KOBIL_SCT is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_MOS7720 is not set
+# CONFIG_USB_SERIAL_MOS7840 is not set
+# CONFIG_USB_SERIAL_MOTOROLA is not set
+# CONFIG_USB_SERIAL_NAVMAN is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_OTI6858 is not set
+# CONFIG_USB_SERIAL_QUALCOMM is not set
+# CONFIG_USB_SERIAL_SPCP8X5 is not set
+# CONFIG_USB_SERIAL_HP4X is not set
+# CONFIG_USB_SERIAL_SAFE is not set
+# CONFIG_USB_SERIAL_SIEMENS_MPI is not set
+# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
+# CONFIG_USB_SERIAL_SYMBOL is not set
+# CONFIG_USB_SERIAL_TI is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_XIRCOM is not set
+# CONFIG_USB_SERIAL_OPTION is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+# CONFIG_USB_SERIAL_OPTICON is not set
+# CONFIG_USB_SERIAL_DEBUG is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_SEVSEG is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_BERRY_CHARGE is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_SISUSBVGA is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_ISIGHTFW is not set
+# CONFIG_USB_VST is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_NOP_USB_XCEIV is not set
+# CONFIG_UWB is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
+# CONFIG_INFINIBAND is not set
+# CONFIG_RTC_CLASS is not set
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+CONFIG_STAGING=y
+# CONFIG_STAGING_EXCLUDE_BUILD is not set
+# CONFIG_ET131X is not set
+# CONFIG_USB_IP_COMMON is not set
+# CONFIG_PRISM2_USB is not set
+# CONFIG_ECHO is not set
+# CONFIG_COMEDI is not set
+# CONFIG_ASUS_OLED is not set
+# CONFIG_ALTERA_PCIE_CHDMA is not set
+# CONFIG_RTL8187SE is not set
+# CONFIG_RTL8192SU is not set
+# CONFIG_RTL8192E is not set
+# CONFIG_INPUT_MIMIO is not set
+# CONFIG_TRANZPORT is not set
+
+#
+# Android
+#
+
+#
+# Qualcomm MSM Camera And Video
+#
+
+#
+# Camera Sensor Selection
+#
+# CONFIG_INPUT_GPIO is not set
+# CONFIG_DST is not set
+# CONFIG_POHMELFS is not set
+# CONFIG_B3DFG is not set
+# CONFIG_PLAN9AUTH is not set
+# CONFIG_LINE6_USB is not set
+# CONFIG_USB_SERIAL_QUATECH2 is not set
+# CONFIG_USB_SERIAL_QUATECH_USB2 is not set
+# CONFIG_VT6655 is not set
+# CONFIG_VT6656 is not set
+# CONFIG_FB_UDL is not set
+# CONFIG_VME_BUS is not set
+
+#
+# RAR Register Driver
+#
+# CONFIG_RAR_REGISTER is not set
+# CONFIG_IIO is not set
+CONFIG_FB_SM7XX=y
+CONFIG_FB_SM7XX_ACCEL=y
+
+#
+# File systems
+#
+# CONFIG_EXT2_FS is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+# CONFIG_EXT4_FS is not set
+CONFIG_JBD=y
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+# CONFIG_QUOTA_NETLINK_INTERFACE is not set
+CONFIG_PRINT_QUOTA_WARNING=y
+# CONFIG_QFMT_V1 is not set
+# CONFIG_QFMT_V2 is not set
+CONFIG_QUOTACTL=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+# CONFIG_MSDOS_FS is not set
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFSD is not set
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf-8"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+# CONFIG_DLM is not set
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_PRINTK_TIME=y
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+# CONFIG_MAGIC_SYSRQ is not set
+CONFIG_STRIP_ASM_SYMS=y
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_HEADERS_CHECK is not set
+# CONFIG_DEBUG_KERNEL is not set
+# CONFIG_SLUB_DEBUG_ON is not set
+# CONFIG_SLUB_STATS is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+CONFIG_SYSCTL_SYSCALL_CHECK=y
+CONFIG_TRACING_SUPPORT=y
+# CONFIG_FTRACE is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_CMDLINE_BOOL is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+# CONFIG_CRYPTO_AUTHENC is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+# CONFIG_CRYPTO_ECB is not set
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
+# CONFIG_CRYPTO_MD4 is not set
+# CONFIG_CRYPTO_MD5 is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+CONFIG_CRYPTO_HW=y
+# CONFIG_CRYPTO_DEV_HIFN_795X is not set
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC_T10DIF=y
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+CONFIG_AUDIT_GENERIC=y
+CONFIG_ZLIB_INFLATE=m
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index 3f01870b4d655a2ac4789b19d5e4c50a2ed94814..d3c601206db2e3dee8e82ade72194f7070f8aaf0 100644 (file)
@@ -10,7 +10,6 @@ CONFIG_MIPS=y
 #
 CONFIG_ZONE_DMA=y
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -1591,7 +1590,7 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_DYNAMIC_PRINTK_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index d001f7e8741805bb756a5b8f5bdc9e1a6983d5fa..6a325c02b63c2a2f84f7c828bf88a0c55848c6ae 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1366,7 +1365,9 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,115200 mem=192m ip=bootp root=/dev/nfs rw"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index 7358454deaa66b430a5cdd14f08d9a3bf2577dae..f77a34e0f93814ab9ed02c26d90cb9b40dea421e 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -635,7 +634,9 @@ CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_FAULT_INJECTION is not set
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="nfsroot=192.168.192.169:/u1/mipsel,timeo=20 ip=dhcp"
+# CONFIG_CMDLINE_OVERRIDE is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_RUNTIME_DEBUG is not set
 
index 8c720e51795b164431b76d1070e026afcce37440..17203056b22ba06801b8b61187178daddeead0d4 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -817,7 +816,9 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="mem=32M console=ttyVR0,19200 ide0=0x170,0x376,73"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index ecbc030b7b6ce47a00d8caeb85614ba6aab93807..000d185ddf42764fd79427fa6362ac43c0ee91e6 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1412,7 +1411,7 @@ CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_FAULT_INJECTION is not set
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_RUNTIME_DEBUG is not set
 # CONFIG_MIPS_UNCACHED is not set
index 9477f040796d0ef08eafcec8593022673e2c19cc..144b94d9a6ad7b208b8e9d08853264e82d35fe97 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 CONFIG_MACH_ALCHEMY=y
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -3018,7 +3017,7 @@ CONFIG_MAGIC_SYSRQ=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index be8091ef0a79042be99441ccc02a29db602931f7..ddf67f63919495bd1639a6b732fe37ec1744ba3b 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MIPS_PB1100=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1083,7 +1082,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index e74ba794c789103f5daf3b315cbe552834ab7965..5ec60836b6451048d07f5f4e1c5ad27bfff1bb01 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MIPS_PB1500=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1200,7 +1199,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 1d896fd830dad6530aa83fb3b3b6b0ee2141c7fa..6647642b5d9713281d7047b523438619f454223d 100644 (file)
@@ -23,7 +23,6 @@ CONFIG_MIPS_PB1550=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1193,7 +1192,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index fef4d31c20550133141d1723689d58384cdf2f62..848344d588d127f7a9b08cc9c4a84954e9a46469 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -1034,7 +1033,7 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SAMPLES is not set
 # CONFIG_KERNEL_TESTS is not set
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index e10c7116c3c20c353baf373103e84536a28e400c..9d721fdccb304aeb31a0cd277e14ef301123181a 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1215,7 +1214,9 @@ CONFIG_DEBUG_MUTEXES=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS1,38400n8 root=/dev/nfs ip=bootp"
+# CONFIG_CMDLINE_OVERRIDE is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_RUNTIME_DEBUG is not set
 
index 5ed3c8dfa0a10dd383f9efefe04faab574a52d6d..ab07ec08c6fab6371a2d306978c43963da901e3a 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1205,7 +1204,9 @@ CONFIG_DEBUG_SLAB=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS1,38400n8 root=/dev/nfs ip=bootp"
+# CONFIG_CMDLINE_OVERRIDE is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_RUNTIME_DEBUG is not set
 
diff --git a/arch/mips/configs/powertv_defconfig b/arch/mips/configs/powertv_defconfig
new file mode 100644 (file)
index 0000000..7291633
--- /dev/null
@@ -0,0 +1,1550 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.31-rc5
+# Fri Aug 28 14:49:33 2009
+#
+CONFIG_MIPS=y
+
+#
+# Machine selection
+#
+# CONFIG_MACH_ALCHEMY is not set
+# CONFIG_AR7 is not set
+# CONFIG_BCM47XX is not set
+# CONFIG_MIPS_COBALT is not set
+# CONFIG_MACH_DECSTATION is not set
+# CONFIG_MACH_JAZZ is not set
+# CONFIG_LASAT is not set
+# CONFIG_LEMOTE_FULONG is not set
+# CONFIG_MIPS_MALTA is not set
+# CONFIG_MIPS_SIM is not set
+# CONFIG_NEC_MARKEINS is not set
+# CONFIG_MACH_VR41XX is not set
+# CONFIG_NXP_STB220 is not set
+# CONFIG_NXP_STB225 is not set
+# CONFIG_PNX8550_JBS is not set
+# CONFIG_PNX8550_STB810 is not set
+# CONFIG_PMC_MSP is not set
+# CONFIG_PMC_YOSEMITE is not set
+CONFIG_POWERTV=y
+# CONFIG_SGI_IP22 is not set
+# CONFIG_SGI_IP27 is not set
+# CONFIG_SGI_IP28 is not set
+# CONFIG_SGI_IP32 is not set
+# CONFIG_SIBYTE_CRHINE is not set
+# CONFIG_SIBYTE_CARMEL is not set
+# CONFIG_SIBYTE_CRHONE is not set
+# CONFIG_SIBYTE_RHONE is not set
+# CONFIG_SIBYTE_SWARM is not set
+# CONFIG_SIBYTE_LITTLESUR is not set
+# CONFIG_SIBYTE_SENTOSA is not set
+# CONFIG_SIBYTE_BIGSUR is not set
+# CONFIG_SNI_RM is not set
+# CONFIG_MACH_TX39XX is not set
+# CONFIG_MACH_TX49XX is not set
+# CONFIG_MIKROTIK_RB532 is not set
+# CONFIG_WR_PPMC is not set
+# CONFIG_CAVIUM_OCTEON_SIMULATOR is not set
+# CONFIG_CAVIUM_OCTEON_REFERENCE_BOARD is not set
+# CONFIG_ALCHEMY_GPIO_INDIRECT is not set
+# CONFIG_MIN_RUNTIME_RESOURCES is not set
+# CONFIG_BOOTLOADER_DRIVER is not set
+CONFIG_BOOTLOADER_FAMILY="R2"
+CONFIG_CSRC_POWERTV=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_SUPPORTS_OPROFILE=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_SCHED_OMIT_FRAME_POINTER=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
+CONFIG_CEVT_R4K_LIB=y
+CONFIG_CEVT_R4K=y
+CONFIG_DMA_NONCOHERENT=y
+CONFIG_DMA_NEED_PCI_MAP_STATE=y
+# CONFIG_EARLY_PRINTK is not set
+CONFIG_SYS_HAS_EARLY_PRINTK=y
+# CONFIG_NO_IOPORT is not set
+CONFIG_CPU_BIG_ENDIAN=y
+# CONFIG_CPU_LITTLE_ENDIAN is not set
+CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
+CONFIG_BOOT_ELF32=y
+CONFIG_MIPS_L1_CACHE_SHIFT=5
+
+#
+# CPU selection
+#
+# CONFIG_CPU_LOONGSON2 is not set
+# CONFIG_CPU_MIPS32_R1 is not set
+CONFIG_CPU_MIPS32_R2=y
+# CONFIG_CPU_MIPS64_R1 is not set
+# CONFIG_CPU_MIPS64_R2 is not set
+# CONFIG_CPU_R3000 is not set
+# CONFIG_CPU_TX39XX is not set
+# CONFIG_CPU_VR41XX is not set
+# CONFIG_CPU_R4300 is not set
+# CONFIG_CPU_R4X00 is not set
+# CONFIG_CPU_TX49XX is not set
+# CONFIG_CPU_R5000 is not set
+# CONFIG_CPU_R5432 is not set
+# CONFIG_CPU_R5500 is not set
+# CONFIG_CPU_R6000 is not set
+# CONFIG_CPU_NEVADA is not set
+# CONFIG_CPU_R8000 is not set
+# CONFIG_CPU_R10000 is not set
+# CONFIG_CPU_RM7000 is not set
+# CONFIG_CPU_RM9000 is not set
+# CONFIG_CPU_SB1 is not set
+# CONFIG_CPU_CAVIUM_OCTEON is not set
+CONFIG_SYS_HAS_CPU_MIPS32_R2=y
+CONFIG_CPU_MIPS32=y
+CONFIG_CPU_MIPSR2=y
+CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
+CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
+CONFIG_HARDWARE_WATCHPOINTS=y
+
+#
+# Kernel type
+#
+CONFIG_32BIT=y
+# CONFIG_64BIT is not set
+CONFIG_PAGE_SIZE_4KB=y
+# CONFIG_PAGE_SIZE_8KB is not set
+# CONFIG_PAGE_SIZE_16KB is not set
+# CONFIG_PAGE_SIZE_32KB is not set
+# CONFIG_PAGE_SIZE_64KB is not set
+CONFIG_CPU_HAS_PREFETCH=y
+CONFIG_MIPS_MT_DISABLED=y
+# CONFIG_MIPS_MT_SMP is not set
+# CONFIG_MIPS_MT_SMTC is not set
+CONFIG_CPU_HAS_LLSC=y
+CONFIG_CPU_MIPSR2_IRQ_VI=y
+CONFIG_CPU_MIPSR2_IRQ_EI=y
+CONFIG_CPU_HAS_SYNC=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+# CONFIG_HIGHMEM is not set
+CONFIG_CPU_SUPPORTS_HIGHMEM=y
+CONFIG_SYS_SUPPORTS_HIGHMEM=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=0
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+# CONFIG_HZ_48 is not set
+# CONFIG_HZ_100 is not set
+# CONFIG_HZ_128 is not set
+# CONFIG_HZ_250 is not set
+# CONFIG_HZ_256 is not set
+CONFIG_HZ_1000=y
+# CONFIG_HZ_1024 is not set
+CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
+CONFIG_HZ=1000
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+CONFIG_PREEMPT=y
+# CONFIG_KEXEC is not set
+# CONFIG_SECCOMP is not set
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_CLASSIC_RCU=y
+# CONFIG_TREE_RCU is not set
+# CONFIG_PREEMPT_RCU is not set
+# CONFIG_TREE_RCU_TRACE is not set
+# CONFIG_PREEMPT_RCU_TRACE is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=16
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_USER_SCHED=y
+# CONFIG_CGROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_RELAY=y
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+# CONFIG_SYSCTL_SYSCALL is not set
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+# CONFIG_PCSPKR_PLATFORM is not set
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+# CONFIG_EPOLL is not set
+# CONFIG_SIGNALFD is not set
+CONFIG_TIMERFD=y
+# CONFIG_EVENTFD is not set
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+
+#
+# Performance Counters
+#
+# CONFIG_VM_EVENT_COUNTERS is not set
+CONFIG_PCI_QUIRKS=y
+# CONFIG_SLUB_DEBUG is not set
+# CONFIG_STRIP_ASM_SYMS is not set
+CONFIG_COMPAT_BRK=y
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+# CONFIG_MARKERS is not set
+CONFIG_HAVE_OPROFILE=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+# CONFIG_SLOW_WORK is not set
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_BLOCK=y
+CONFIG_LBDAF=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+# CONFIG_IOSCHED_AS is not set
+# CONFIG_IOSCHED_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+CONFIG_DEFAULT_NOOP=y
+CONFIG_DEFAULT_IOSCHED="noop"
+# CONFIG_PROBE_INITRD_HEADER is not set
+# CONFIG_FREEZER is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, ISA, TC)
+#
+CONFIG_HW_HAS_PCI=y
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCI_LEGACY is not set
+# CONFIG_PCI_DEBUG is not set
+# CONFIG_PCI_STUB is not set
+# CONFIG_PCI_IOV is not set
+CONFIG_MMU=y
+# CONFIG_PCCARD is not set
+# CONFIG_HOTPLUG_PCI is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_HAVE_AOUT is not set
+# CONFIG_BINFMT_MISC is not set
+CONFIG_TRAD_SIGNALS=y
+
+#
+# Power management options
+#
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+# CONFIG_PM is not set
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+# CONFIG_IP_MULTIPLE_TABLES is not set
+# CONFIG_IP_ROUTE_MULTIPATH is not set
+# CONFIG_IP_ROUTE_VERBOSE is not set
+CONFIG_IP_PNP=y
+# CONFIG_IP_PNP_DHCP is not set
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_LRO is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IPV6=y
+CONFIG_IPV6_PRIVACY=y
+# CONFIG_IPV6_ROUTER_PREF is not set
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=y
+CONFIG_INET6_ESP=y
+CONFIG_INET6_IPCOMP=y
+# CONFIG_IPV6_MIP6 is not set
+CONFIG_INET6_XFRM_TUNNEL=y
+CONFIG_INET6_TUNNEL=y
+# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET6_XFRM_MODE_BEET is not set
+# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
+# CONFIG_IPV6_SIT is not set
+CONFIG_IPV6_TUNNEL=y
+# CONFIG_IPV6_MULTIPLE_TABLES is not set
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETWORK_SECMARK is not set
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+# CONFIG_BRIDGE_NETFILTER is not set
+
+#
+# Core Netfilter Configuration
+#
+# CONFIG_NETFILTER_NETLINK_QUEUE is not set
+# CONFIG_NETFILTER_NETLINK_LOG is not set
+# CONFIG_NF_CONNTRACK is not set
+CONFIG_NETFILTER_XTABLES=y
+# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set
+# CONFIG_NETFILTER_XT_TARGET_MARK is not set
+# CONFIG_NETFILTER_XT_TARGET_NFLOG is not set
+# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set
+# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
+# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set
+# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set
+# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
+# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
+# CONFIG_NETFILTER_XT_MATCH_ESP is not set
+# CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_HL is not set
+# CONFIG_NETFILTER_XT_MATCH_IPRANGE is not set
+# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set
+# CONFIG_NETFILTER_XT_MATCH_LIMIT is not set
+# CONFIG_NETFILTER_XT_MATCH_MAC is not set
+# CONFIG_NETFILTER_XT_MATCH_MARK is not set
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
+# CONFIG_NETFILTER_XT_MATCH_OWNER is not set
+# CONFIG_NETFILTER_XT_MATCH_POLICY is not set
+# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
+# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
+# CONFIG_NETFILTER_XT_MATCH_RATEEST is not set
+# CONFIG_NETFILTER_XT_MATCH_REALM is not set
+# CONFIG_NETFILTER_XT_MATCH_RECENT is not set
+# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
+# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
+# CONFIG_NETFILTER_XT_MATCH_STRING is not set
+# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
+# CONFIG_NETFILTER_XT_MATCH_TIME is not set
+# CONFIG_NETFILTER_XT_MATCH_U32 is not set
+# CONFIG_IP_VS is not set
+
+#
+# IP: Netfilter Configuration
+#
+# CONFIG_NF_DEFRAG_IPV4 is not set
+# CONFIG_IP_NF_QUEUE is not set
+CONFIG_IP_NF_IPTABLES=y
+# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
+# CONFIG_IP_NF_MATCH_AH is not set
+# CONFIG_IP_NF_MATCH_ECN is not set
+# CONFIG_IP_NF_MATCH_TTL is not set
+CONFIG_IP_NF_FILTER=y
+# CONFIG_IP_NF_TARGET_REJECT is not set
+# CONFIG_IP_NF_TARGET_LOG is not set
+# CONFIG_IP_NF_TARGET_ULOG is not set
+# CONFIG_IP_NF_MANGLE is not set
+# CONFIG_IP_NF_TARGET_TTL is not set
+# CONFIG_IP_NF_RAW is not set
+CONFIG_IP_NF_ARPTABLES=y
+CONFIG_IP_NF_ARPFILTER=y
+# CONFIG_IP_NF_ARP_MANGLE is not set
+
+#
+# IPv6: Netfilter Configuration
+#
+# CONFIG_IP6_NF_QUEUE is not set
+CONFIG_IP6_NF_IPTABLES=y
+# CONFIG_IP6_NF_MATCH_AH is not set
+# CONFIG_IP6_NF_MATCH_EUI64 is not set
+# CONFIG_IP6_NF_MATCH_FRAG is not set
+# CONFIG_IP6_NF_MATCH_OPTS is not set
+# CONFIG_IP6_NF_MATCH_HL is not set
+# CONFIG_IP6_NF_MATCH_IPV6HEADER is not set
+# CONFIG_IP6_NF_MATCH_MH is not set
+# CONFIG_IP6_NF_MATCH_RT is not set
+# CONFIG_IP6_NF_TARGET_HL is not set
+# CONFIG_IP6_NF_TARGET_LOG is not set
+CONFIG_IP6_NF_FILTER=y
+# CONFIG_IP6_NF_TARGET_REJECT is not set
+# CONFIG_IP6_NF_MANGLE is not set
+# CONFIG_IP6_NF_RAW is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+CONFIG_STP=y
+CONFIG_BRIDGE=y
+# CONFIG_NET_DSA is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+CONFIG_LLC=y
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+# CONFIG_NET_SCH_CBQ is not set
+# CONFIG_NET_SCH_HTB is not set
+# CONFIG_NET_SCH_HFSC is not set
+# CONFIG_NET_SCH_PRIO is not set
+# CONFIG_NET_SCH_MULTIQ is not set
+# CONFIG_NET_SCH_RED is not set
+# CONFIG_NET_SCH_SFQ is not set
+# CONFIG_NET_SCH_TEQL is not set
+CONFIG_NET_SCH_TBF=y
+# CONFIG_NET_SCH_GRED is not set
+# CONFIG_NET_SCH_DSMARK is not set
+# CONFIG_NET_SCH_NETEM is not set
+# CONFIG_NET_SCH_DRR is not set
+
+#
+# Classification
+#
+# CONFIG_NET_CLS_BASIC is not set
+# CONFIG_NET_CLS_TCINDEX is not set
+# CONFIG_NET_CLS_ROUTE4 is not set
+# CONFIG_NET_CLS_FW is not set
+# CONFIG_NET_CLS_U32 is not set
+# CONFIG_NET_CLS_RSVP is not set
+# CONFIG_NET_CLS_RSVP6 is not set
+# CONFIG_NET_CLS_FLOW is not set
+# CONFIG_NET_EMATCH is not set
+# CONFIG_NET_CLS_ACT is not set
+CONFIG_NET_SCH_FIFO=y
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_TESTS is not set
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+# CONFIG_MTD_AR7_PARTS is not set
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_INTEL_VR_NOR is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+# CONFIG_MTD_NAND_ECC_SMC is not set
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_NAND_CAFE is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
+# CONFIG_MTD_NAND_PLATFORM is not set
+# CONFIG_MTD_ALAUDA is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# LPDDR flash memory drivers
+#
+# CONFIG_MTD_LPDDR is not set
+
+#
+# UBI - Unsorted block images
+#
+# CONFIG_MTD_UBI is not set
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=32768
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_BLK_DEV_HD is not set
+# CONFIG_MISC_DEVICES is not set
+CONFIG_HAVE_IDE=y
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_TGT is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_SCSI_PROC_FS is not set
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+# CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
+CONFIG_ATA=y
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_SATA_PMP=y
+# CONFIG_SATA_AHCI is not set
+# CONFIG_SATA_SIL24 is not set
+CONFIG_ATA_SFF=y
+# CONFIG_SATA_SVW is not set
+# CONFIG_ATA_PIIX is not set
+# CONFIG_SATA_MV is not set
+# CONFIG_SATA_NV is not set
+# CONFIG_PDC_ADMA is not set
+# CONFIG_SATA_QSTOR is not set
+# CONFIG_SATA_PROMISE is not set
+# CONFIG_SATA_SX4 is not set
+# CONFIG_SATA_SIL is not set
+# CONFIG_SATA_SIS is not set
+# CONFIG_SATA_ULI is not set
+# CONFIG_SATA_VIA is not set
+# CONFIG_SATA_VITESSE is not set
+# CONFIG_SATA_INIC162X is not set
+# CONFIG_PATA_ALI is not set
+# CONFIG_PATA_AMD is not set
+# CONFIG_PATA_ARTOP is not set
+# CONFIG_PATA_ATIIXP is not set
+# CONFIG_PATA_CMD640_PCI is not set
+# CONFIG_PATA_CMD64X is not set
+# CONFIG_PATA_CS5520 is not set
+# CONFIG_PATA_CS5530 is not set
+# CONFIG_PATA_CYPRESS is not set
+# CONFIG_PATA_EFAR is not set
+# CONFIG_ATA_GENERIC is not set
+# CONFIG_PATA_HPT366 is not set
+# CONFIG_PATA_HPT37X is not set
+# CONFIG_PATA_HPT3X2N is not set
+# CONFIG_PATA_HPT3X3 is not set
+# CONFIG_PATA_IT821X is not set
+# CONFIG_PATA_IT8213 is not set
+# CONFIG_PATA_JMICRON is not set
+# CONFIG_PATA_TRIFLEX is not set
+# CONFIG_PATA_MARVELL is not set
+# CONFIG_PATA_MPIIX is not set
+# CONFIG_PATA_OLDPIIX is not set
+# CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
+# CONFIG_PATA_NS87410 is not set
+# CONFIG_PATA_NS87415 is not set
+# CONFIG_PATA_OPTI is not set
+# CONFIG_PATA_OPTIDMA is not set
+# CONFIG_PATA_PDC_OLD is not set
+# CONFIG_PATA_RADISYS is not set
+# CONFIG_PATA_RZ1000 is not set
+# CONFIG_PATA_SC1200 is not set
+# CONFIG_PATA_SERVERWORKS is not set
+# CONFIG_PATA_PDC2027X is not set
+# CONFIG_PATA_SIL680 is not set
+# CONFIG_PATA_SIS is not set
+# CONFIG_PATA_VIA is not set
+# CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_PLATFORM is not set
+# CONFIG_PATA_SCH is not set
+# CONFIG_MD is not set
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# You can enable one or both FireWire driver stacks.
+#
+
+#
+# See the help texts for more information.
+#
+# CONFIG_FIREWIRE is not set
+# CONFIG_IEEE1394 is not set
+# CONFIG_I2O is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+# CONFIG_ARCNET is not set
+# CONFIG_PHYLIB is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_AX88796 is not set
+# CONFIG_HAPPYMEAL is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_CASSINI is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_SMC91X is not set
+# CONFIG_DM9000 is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
+# CONFIG_NET_TULIP is not set
+# CONFIG_HP100 is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_NET_PCI is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_ATL2 is not set
+CONFIG_NETDEV_1000=y
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_E1000E is not set
+# CONFIG_IP1000 is not set
+# CONFIG_IGB is not set
+# CONFIG_IGBVF is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SIS190 is not set
+# CONFIG_SKGE is not set
+# CONFIG_SKY2 is not set
+# CONFIG_VIA_VELOCITY is not set
+# CONFIG_TIGON3 is not set
+# CONFIG_BNX2 is not set
+# CONFIG_CNIC is not set
+# CONFIG_QLA3XXX is not set
+# CONFIG_ATL1 is not set
+# CONFIG_ATL1E is not set
+# CONFIG_ATL1C is not set
+# CONFIG_JME is not set
+CONFIG_NETDEV_10000=y
+# CONFIG_CHELSIO_T1 is not set
+CONFIG_CHELSIO_T3_DEPENDS=y
+# CONFIG_CHELSIO_T3 is not set
+# CONFIG_ENIC is not set
+# CONFIG_IXGBE is not set
+# CONFIG_IXGB is not set
+# CONFIG_S2IO is not set
+# CONFIG_VXGE is not set
+# CONFIG_MYRI10GE is not set
+# CONFIG_NETXEN_NIC is not set
+# CONFIG_NIU is not set
+# CONFIG_MLX4_EN is not set
+# CONFIG_MLX4_CORE is not set
+# CONFIG_TEHUTI is not set
+# CONFIG_BNX2X is not set
+# CONFIG_QLGE is not set
+# CONFIG_SFC is not set
+# CONFIG_BE2NET is not set
+# CONFIG_TR is not set
+
+#
+# Wireless LAN
+#
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+CONFIG_USB_RTL8150=y
+# CONFIG_USB_USBNET is not set
+# CONFIG_WAN is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NET_FC is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
+# CONFIG_INPUT_POLLDEV is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_DEVKMEM is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+# CONFIG_NOZOMI is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_JSM is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_DEVPORT=y
+# CONFIG_I2C is not set
+# CONFIG_SPI is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_DRM is not set
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+# CONFIG_FB is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+# CONFIG_SOUND is not set
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+# CONFIG_HID_DEBUG is not set
+# CONFIG_HIDRAW is not set
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+# CONFIG_HID_PID is not set
+CONFIG_USB_HIDDEV=y
+
+#
+# Special HID drivers
+#
+# CONFIG_HID_A4TECH is not set
+# CONFIG_HID_APPLE is not set
+# CONFIG_HID_BELKIN is not set
+# CONFIG_HID_CHERRY is not set
+# CONFIG_HID_CHICONY is not set
+# CONFIG_HID_CYPRESS is not set
+# CONFIG_HID_DRAGONRISE is not set
+# CONFIG_HID_EZKEY is not set
+# CONFIG_HID_KYE is not set
+# CONFIG_HID_GYRATION is not set
+# CONFIG_HID_KENSINGTON is not set
+# CONFIG_HID_LOGITECH is not set
+# CONFIG_HID_MICROSOFT is not set
+# CONFIG_HID_MONTEREY is not set
+# CONFIG_HID_NTRIG is not set
+# CONFIG_HID_PANTHERLORD is not set
+# CONFIG_HID_PETALYNX is not set
+# CONFIG_HID_SAMSUNG is not set
+# CONFIG_HID_SONY is not set
+# CONFIG_HID_SUNPLUS is not set
+# CONFIG_HID_GREENASIA is not set
+# CONFIG_HID_SMARTJOYPLUS is not set
+# CONFIG_HID_TOPSEED is not set
+# CONFIG_HID_THRUSTMASTER is not set
+# CONFIG_HID_ZEROPLUS is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_OTG is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+# CONFIG_USB_MON is not set
+# CONFIG_USB_WUSB is not set
+# CONFIG_USB_WUSB_CBAF is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_C67X00_HCD is not set
+# CONFIG_USB_XHCI_HCD is not set
+CONFIG_USB_EHCI_HCD=y
+# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
+# CONFIG_USB_EHCI_TT_NEWSCHED is not set
+# CONFIG_USB_OXU210HP_HCD is not set
+# CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_ISP1760_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+# CONFIG_USB_UHCI_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+# CONFIG_USB_R8A66597_HCD is not set
+# CONFIG_USB_WHCI_HCD is not set
+# CONFIG_USB_HWA_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
+# CONFIG_USB_WDM is not set
+# CONFIG_USB_TMC is not set
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+
+#
+# also be needed; see USB_STORAGE Help for more info
+#
+CONFIG_USB_STORAGE=y
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_ISD200 is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_STORAGE_ONETOUCH is not set
+# CONFIG_USB_STORAGE_KARMA is not set
+# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB port drivers
+#
+CONFIG_USB_SERIAL=y
+CONFIG_USB_SERIAL_CONSOLE=y
+# CONFIG_USB_EZUSB is not set
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_AIRCABLE is not set
+# CONFIG_USB_SERIAL_ARK3116 is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_CH341 is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+CONFIG_USB_SERIAL_CP210X=y
+# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_FUNSOFT is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_IPAQ is not set
+# CONFIG_USB_SERIAL_IR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
+# CONFIG_USB_SERIAL_GARMIN is not set
+# CONFIG_USB_SERIAL_IPW is not set
+# CONFIG_USB_SERIAL_IUU is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KLSI is not set
+# CONFIG_USB_SERIAL_KOBIL_SCT is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+# CONFIG_USB_SERIAL_MOS7720 is not set
+# CONFIG_USB_SERIAL_MOS7840 is not set
+# CONFIG_USB_SERIAL_MOTOROLA is not set
+# CONFIG_USB_SERIAL_NAVMAN is not set
+# CONFIG_USB_SERIAL_PL2303 is not set
+# CONFIG_USB_SERIAL_OTI6858 is not set
+# CONFIG_USB_SERIAL_QUALCOMM is not set
+# CONFIG_USB_SERIAL_SPCP8X5 is not set
+# CONFIG_USB_SERIAL_HP4X is not set
+# CONFIG_USB_SERIAL_SAFE is not set
+# CONFIG_USB_SERIAL_SIEMENS_MPI is not set
+# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
+# CONFIG_USB_SERIAL_SYMBOL is not set
+# CONFIG_USB_SERIAL_TI is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_XIRCOM is not set
+# CONFIG_USB_SERIAL_OPTION is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+# CONFIG_USB_SERIAL_OPTICON is not set
+# CONFIG_USB_SERIAL_DEBUG is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
+# CONFIG_USB_SEVSEG is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_BERRY_CHARGE is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
+# CONFIG_USB_SISUSBVGA is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
+# CONFIG_USB_TEST is not set
+# CONFIG_USB_ISIGHTFW is not set
+# CONFIG_USB_VST is not set
+# CONFIG_USB_GADGET is not set
+
+#
+# OTG and related infrastructure
+#
+# CONFIG_NOP_USB_XCEIV is not set
+# CONFIG_UWB is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
+# CONFIG_INFINIBAND is not set
+CONFIG_RTC_LIB=y
+# CONFIG_RTC_CLASS is not set
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+# CONFIG_EXT3_FS_XATTR is not set
+# CONFIG_EXT4_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+# CONFIG_DNOTIFY is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+CONFIG_FUSE_FS=y
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+CONFIG_JFFS2_FS=y
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+# CONFIG_JFFS2_SUMMARY is not set
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_CRAMFS=y
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+# CONFIG_NLS_CODEPAGE_437 is not set
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+# CONFIG_NLS_ISO8859_1 is not set
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+# CONFIG_DLM is not set
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_PRINTK_TIME=y
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+CONFIG_DETECT_HUNG_TASK=y
+# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
+CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_PREEMPT is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_BOOT_PRINTK_DELAY is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_FAULT_INJECTION is not set
+# CONFIG_PAGE_POISONING is not set
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_PREEMPT_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_ENABLE_DEFAULT_TRACERS is not set
+# CONFIG_BOOT_TRACER is not set
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_KMEMCHECK is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="rw dhash_entries=1024 ihash_entries=1024 ip=10.0.1.3:10.0.1.1:10.0.1.1:255.255.255.0:zeus:eth0: root=/dev/nfs nfsroot=/nfsroot/cramfs,wsize=512,rsize=512,tcp nokgdb console=ttyUSB0,115200 memsize=252M"
+# CONFIG_CMDLINE_OVERRIDE is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_RUNTIME_DEBUG is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+# CONFIG_CRYPTO_FIPS is not set
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=y
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=y
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+# CONFIG_CRYPTO_ECB is not set
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+# CONFIG_CRYPTO_XCBC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_MD4 is not set
+CONFIG_CRYPTO_MD5=y
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+CONFIG_CRYPTO_SHA1=y
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+# CONFIG_CRYPTO_AES is not set
+# CONFIG_CRYPTO_ANUBIS is not set
+# CONFIG_CRYPTO_ARC4 is not set
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+CONFIG_CRYPTO_DES=y
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=y
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+# CONFIG_CRYPTO_HW is not set
+# CONFIG_BINARY_PRINTF is not set
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_NLATTR=y
index f40c3a04739d5e194716784e65c1a901eaad205c..57a50483abdf9069a080a3a6c11e564bc74a9dba 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -1204,7 +1203,7 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SAMPLES is not set
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 6c6a19aebe1fa21338df29e7d6566b3e0adaea23..21c2022d46eeb567d5a3a92a390ce80584540b6d 100644 (file)
@@ -10,7 +10,6 @@ CONFIG_MIPS=y
 #
 # CONFIG_MACH_ALCHEMY is not set
 # CONFIG_AR7 is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_BCM63XX is not set
 # CONFIG_MIPS_COBALT is not set
@@ -284,7 +283,6 @@ CONFIG_DEFAULT_AS=y
 # CONFIG_DEFAULT_CFQ is not set
 # CONFIG_DEFAULT_NOOP is not set
 CONFIG_DEFAULT_IOSCHED="anticipatory"
-# CONFIG_PROBE_INITRD_HEADER is not set
 # CONFIG_FREEZER is not set
 
 #
@@ -1063,7 +1061,7 @@ CONFIG_TRACING_SUPPORT=y
 # CONFIG_DYNAMIC_DEBUG is not set
 # CONFIG_SAMPLES is not set
 CONFIG_HAVE_ARCH_KGDB=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index e53b8d096cfce0acde91225ef5b981c11288d3cc..7903628900331473748a4bf698c33923d9466cc7 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -1694,7 +1693,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 
 #
 # Security options
index 7f38c0b956f312701428cc5e770edf423364e619..7f07bf02b838e100c67b346b75e3f8cd9e59a39d 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -961,7 +960,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SAMPLES is not set
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 # CONFIG_SB1XXX_CORELIS is not set
 
 #
index b5059881bc7e46dfe9f3e697f23b5c7f6cb1a802..c54d1128f9a398e2f9edfe40d5632a36bfbe5daf 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -892,7 +891,9 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SAMPLES is not set
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="cca=3 mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index b06a716bf23f594ba7febfda08286240b0bbc867..e7c5cd32a2bd90bfaa9c9a88285fbeb9adf82ea6 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -895,7 +894,9 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SAMPLES is not set
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="cca=3 mem=32M console=ttyVR0,115200"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index 46512cf7ce04cd060138a8845fd3f4eaa46f953f..b50032ba4d01b3cd01644d4d9f5cf6b6a9ad35e7 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_BCM47XX is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
@@ -1077,7 +1076,9 @@ CONFIG_FRAME_WARN=1024
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 # CONFIG_SAMPLES is not set
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="cca=3 mem=64M console=ttyVR0,115200 ip=any root=/dev/nfs"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index b437eb7f8672021e065d0ef550bd238b9b92680e..c02ba08b69ab7747c536be814716e990bbd71815 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_MIPS=y
 # Machine selection
 #
 # CONFIG_MACH_ALCHEMY is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -755,7 +754,9 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_HEADERS_CHECK is not set
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyVR0,19200 ide0=0x170,0x376,49 mem=16M"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index 06acc7482e4c84e73212ff1bb4268bc614323f71..a35bc41389e59392e27170c52897ee570b820ab1 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -887,7 +886,9 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_KERNEL is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_CROSSCOMPILE=y
+CONFIG_CMDLINE_BOOL=y
 CONFIG_CMDLINE="console=ttyS0,115200n8"
+# CONFIG_CMDLINE_OVERRIDE is not set
 
 #
 # Security options
index 69feaf88b5104403df21b44c071e4fe1394152bf..e3d68d651e7d9c96634c4d3a88cd1c12bbc4f66d 100644 (file)
@@ -22,7 +22,6 @@ CONFIG_ZONE_DMA=y
 # CONFIG_MIPS_DB1550 is not set
 # CONFIG_MIPS_DB1200 is not set
 # CONFIG_MIPS_MIRAGE is not set
-# CONFIG_BASLER_EXCITE is not set
 # CONFIG_MIPS_COBALT is not set
 # CONFIG_MACH_DECSTATION is not set
 # CONFIG_MACH_JAZZ is not set
@@ -824,7 +823,7 @@ CONFIG_DEBUG_MUTEXES=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
 CONFIG_CROSSCOMPILE=y
-CONFIG_CMDLINE=""
+# CONFIG_CMDLINE_BOOL is not set
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_RUNTIME_DEBUG is not set
 
index 4ca4eef934a539aa579458c37c95e4826356ab44..5c8603c85f20720ae8f3dab122aad5956119f145 100644 (file)
 
 #undef DEBUG_CMDLINE
 
-char * __init prom_getcmdline(void)
-{
-       return arcs_cmdline;
-}
-
 static char *ignored[] = {
        "ConsoleIn=",
        "ConsoleOut=",
diff --git a/arch/mips/include/asm/asm-offsets.h b/arch/mips/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index f5dfaf6a16064a0ff16785d0e18ee8107f54b60b..09eee09780f2335b0153fe656b4aafcac8d217ec 100644 (file)
@@ -67,9 +67,9 @@
 #define MACH_LEMOTE_ML2F7      3
 #define MACH_LEMOTE_YL2F89     4
 #define MACH_DEXXON_GDIUM2F10  5
-#define MACH_LOONGSON_END      6
-
-#define CL_SIZE                        COMMAND_LINE_SIZE
+#define MACH_LEMOTE_NAS        6
+#define MACH_LEMOTE_LL2F       7
+#define MACH_LOONGSON_END      8
 
 extern char *system_type;
 const char *get_system_type(void);
@@ -107,7 +107,7 @@ extern void free_init_pages(const char *what,
 /*
  * Initial kernel command line, usually setup by prom_init()
  */
-extern char arcs_cmdline[CL_SIZE];
+extern char arcs_cmdline[COMMAND_LINE_SIZE];
 
 /*
  * Registers a0, a1, a3 and a4 as passed to the kernel entry by firmware
diff --git a/arch/mips/include/asm/clock.h b/arch/mips/include/asm/clock.h
new file mode 100644 (file)
index 0000000..83894aa
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef __ASM_MIPS_CLOCK_H
+#define __ASM_MIPS_CLOCK_H
+
+#include <linux/kref.h>
+#include <linux/list.h>
+#include <linux/seq_file.h>
+#include <linux/clk.h>
+
+extern void (*cpu_wait) (void);
+
+struct clk;
+
+struct clk_ops {
+       void (*init) (struct clk *clk);
+       void (*enable) (struct clk *clk);
+       void (*disable) (struct clk *clk);
+       void (*recalc) (struct clk *clk);
+       int (*set_rate) (struct clk *clk, unsigned long rate, int algo_id);
+       long (*round_rate) (struct clk *clk, unsigned long rate);
+};
+
+struct clk {
+       struct list_head node;
+       const char *name;
+       int id;
+       struct module *owner;
+
+       struct clk *parent;
+       struct clk_ops *ops;
+
+       struct kref kref;
+
+       unsigned long rate;
+       unsigned long flags;
+};
+
+#define CLK_ALWAYS_ENABLED     (1 << 0)
+#define CLK_RATE_PROPAGATES    (1 << 1)
+
+/* Should be defined by processor-specific code */
+void arch_init_clk_ops(struct clk_ops **, int type);
+
+int clk_init(void);
+
+int __clk_enable(struct clk *);
+void __clk_disable(struct clk *);
+
+void clk_recalc_rate(struct clk *);
+
+int clk_register(struct clk *);
+void clk_unregister(struct clk *);
+
+/* the exported API, in addition to clk_set_rate */
+/**
+ * clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
+ * @clk: clock source
+ * @rate: desired clock rate in Hz
+ * @algo_id: algorithm id to be passed down to ops->set_rate
+ *
+ * Returns success (0) or negative errno.
+ */
+int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
+
+#endif                         /* __ASM_MIPS_CLOCK_H */
diff --git a/arch/mips/include/asm/cop2.h b/arch/mips/include/asm/cop2.h
new file mode 100644 (file)
index 0000000..6b04c98
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2009 Wind River Systems,
+ *   written by Ralf Baechle <ralf@linux-mips.org>
+ */
+#ifndef __ASM_COP2_H
+#define __ASM_COP2_H
+
+enum cu2_ops {
+       CU2_EXCEPTION,
+       CU2_LWC2_OP,
+       CU2_LDC2_OP,
+       CU2_SWC2_OP,
+       CU2_SDC2_OP,
+};
+
+extern int register_cu2_notifier(struct notifier_block *nb);
+extern int cu2_notifier_call_chain(unsigned long val, void *v);
+
+#endif /* __ASM_COP2_H */
index 4b96d1a36056e67fb038d06f17812236a790b6ab..cf373a95fe4ad1e7ee1391f2dceeac41dba5ad2e 100644 (file)
 #define PRID_REV_VR4181A       0x0070  /* Same as VR4122 */
 #define PRID_REV_VR4130                0x0080
 #define PRID_REV_34K_V1_0_2    0x0022
+#define PRID_REV_LOONGSON2E    0x0002
+#define PRID_REV_LOONGSON2F    0x0003
 
 /*
  * Older processors used to encode processor version and revision in two
index 7990694cda221dbd9f0da1c2b11b4f8e77688680..7a6a35dbe529c91ad71529e5d77218811be556cf 100644 (file)
@@ -326,7 +326,6 @@ extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs)                  \
        dump_task_fpu(tsk, elf_fpregs)
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      PAGE_SIZE
 
 /* This yields a mask that user programs can use to figure out what
index 7c6681aa2ab877a02f3dff8577c96bd2d9b11509..e482fe90fe8850609ed05f79d4caa9423e31031a 100644 (file)
@@ -19,7 +19,7 @@
 #define FASYNC         0x1000  /* fcntl, for BSD compatibility */
 #define O_LARGEFILE    0x2000  /* allow large file opens */
 /*
- * Before Linux 2.6.32 only O_DSYNC semantics were implemented, but using
+ * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
  * the O_SYNC flag.  We continue to use the existing numerical value
  * for O_DSYNC semantics now, but using the correct symbolic name for it.
  * This new value is used to request true Posix O_SYNC semantics.  It is
index 8a3ef247659a79daefde386445eb4c7d8b6d7442..7fcef8ef3fab717e7fdb335c2e05315892b85a86 100644 (file)
 struct sigcontext;
 struct sigcontext32;
 
-extern asmlinkage int (*save_fp_context)(struct sigcontext __user *sc);
-extern asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc);
-
-extern asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc);
-extern asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *sc);
-
 extern void fpu_emulator_init_fpu(void);
-extern int fpu_emulator_save_context(struct sigcontext __user *sc);
-extern int fpu_emulator_restore_context(struct sigcontext __user *sc);
 extern void _init_fpu(void);
 extern void _save_fp(struct task_struct *);
 extern void _restore_fp(struct task_struct *);
index e5189572956c5221c378f542d9c945a0ca103a2d..aecada6f61178e8837b7f3ed0688e7e0029a1634 100644 (file)
 
 #include <asm/break.h>
 #include <asm/inst.h>
+#include <asm/local.h>
+
+#ifdef CONFIG_DEBUG_FS
 
 struct mips_fpu_emulator_stats {
-       unsigned int emulated;
-       unsigned int loads;
-       unsigned int stores;
-       unsigned int cp1ops;
-       unsigned int cp1xops;
-       unsigned int errors;
+       local_t emulated;
+       local_t loads;
+       local_t stores;
+       local_t cp1ops;
+       local_t cp1xops;
+       local_t errors;
 };
 
-extern struct mips_fpu_emulator_stats fpuemustats;
+DECLARE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
+
+#define MIPS_FPU_EMU_INC_STATS(M)                                      \
+       cpu_local_wrap(__local_inc(&__get_cpu_var(fpuemustats).M))
+
+#else
+#define MIPS_FPU_EMU_INC_STATS(M) do { } while (0)
+#endif /* CONFIG_DEBUG_FS */
 
 extern int mips_dsemul(struct pt_regs *regs, mips_instruction ir,
        unsigned long cpc);
index 40a8c178f10d9e85a2873c83247c3f2fe553f408..3986cd8704f38367ad21e416a9eb73f9afe6cb7a 100644 (file)
@@ -1 +1,90 @@
-/* empty */
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive for
+ * more details.
+ *
+ * Copyright (C) 2009 DSLab, Lanzhou University, China
+ * Author: Wu Zhangjin <wuzj@lemote.com>
+ */
+
+#ifndef _ASM_MIPS_FTRACE_H
+#define _ASM_MIPS_FTRACE_H
+
+#ifdef CONFIG_FUNCTION_TRACER
+
+#define MCOUNT_ADDR ((unsigned long)(_mcount))
+#define MCOUNT_INSN_SIZE 4             /* sizeof mcount call */
+
+#ifndef __ASSEMBLY__
+extern void _mcount(void);
+#define mcount _mcount
+
+#define safe_load(load, src, dst, error)               \
+do {                                                   \
+       asm volatile (                                  \
+               "1: " load " %[" STR(dst) "], 0(%[" STR(src) "])\n"\
+               "   li %[" STR(error) "], 0\n"          \
+               "2:\n"                                  \
+                                                       \
+               ".section .fixup, \"ax\"\n"             \
+               "3: li %[" STR(error) "], 1\n"          \
+               "   j 2b\n"                             \
+               ".previous\n"                           \
+                                                       \
+               ".section\t__ex_table,\"a\"\n\t"        \
+               STR(PTR) "\t1b, 3b\n\t"                 \
+               ".previous\n"                           \
+                                                       \
+               : [dst] "=&r" (dst), [error] "=r" (error)\
+               : [src] "r" (src)                       \
+               : "memory"                              \
+       );                                              \
+} while (0)
+
+#define safe_store(store, src, dst, error)     \
+do {                                           \
+       asm volatile (                          \
+               "1: " store " %[" STR(src) "], 0(%[" STR(dst) "])\n"\
+               "   li %[" STR(error) "], 0\n"  \
+               "2:\n"                          \
+                                               \
+               ".section .fixup, \"ax\"\n"     \
+               "3: li %[" STR(error) "], 1\n"  \
+               "   j 2b\n"                     \
+               ".previous\n"                   \
+                                               \
+               ".section\t__ex_table,\"a\"\n\t"\
+               STR(PTR) "\t1b, 3b\n\t"         \
+               ".previous\n"                   \
+                                               \
+               : [error] "=r" (error)          \
+               : [dst] "r" (dst), [src] "r" (src)\
+               : "memory"                      \
+       );                                      \
+} while (0)
+
+#define safe_load_code(dst, src, error) \
+       safe_load(STR(lw), src, dst, error)
+#define safe_store_code(src, dst, error) \
+       safe_store(STR(sw), src, dst, error)
+
+#define safe_load_stack(dst, src, error) \
+       safe_load(STR(PTR_L), src, dst, error)
+
+#define safe_store_stack(src, dst, error) \
+       safe_store(STR(PTR_S), src, dst, error)
+
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+static inline unsigned long ftrace_call_adjust(unsigned long addr)
+{
+       return addr;
+}
+
+struct dyn_arch_ftrace {
+};
+
+#endif /*  CONFIG_DYNAMIC_FTRACE */
+#endif /* __ASSEMBLY__ */
+#endif /* CONFIG_FUNCTION_TRACER */
+#endif /* _ASM_MIPS_FTRACE_H */
index 09b08d05ff721707ea5c968fe1e369b19141014c..06960364c96b961a2a91eb5432c8e318309659b8 100644 (file)
@@ -113,36 +113,11 @@ do {                                                                      \
 
 #endif
 
-/*
- * do_IRQ handles all normal device IRQ's (the special
- * SMP cross-CPU interrupts have their own specific
- * handlers).
- *
- * Ideally there should be away to get this into kernel/irq/handle.c to
- * avoid the overhead of a call for just a tiny function ...
- */
-#define do_IRQ(irq)                                                    \
-do {                                                                   \
-       irq_enter();                                                    \
-       __DO_IRQ_SMTC_HOOK(irq);                                        \
-       generic_handle_irq(irq);                                        \
-       irq_exit();                                                     \
-} while (0)
+extern void do_IRQ(unsigned int irq);
 
 #ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
-/*
- * To avoid inefficient and in some cases pathological re-checking of
- * IRQ affinity, we have this variant that skips the affinity check.
- */
-
 
-#define do_IRQ_no_affinity(irq)                                                \
-do {                                                                   \
-       irq_enter();                                                    \
-       __NO_AFFINITY_IRQ_SMTC_HOOK(irq);                               \
-       generic_handle_irq(irq);                                        \
-       irq_exit();                                                     \
-} while (0)
+extern void do_IRQ_no_affinity(unsigned int irq);
 
 #endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
 
diff --git a/arch/mips/include/asm/mach-excite/cpu-feature-overrides.h b/arch/mips/include/asm/mach-excite/cpu-feature-overrides.h
deleted file mode 100644 (file)
index 107104c..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2004 Thomas Koeller <thomas.koeller@baslerweb.com>
- * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
- */
-#ifndef __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H
-#define __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H
-
-/*
- * Basler eXcite has an RM9122 processor.
- */
-#define cpu_has_watch          1
-#define cpu_has_mips16         0
-#define cpu_has_divec          0
-#define cpu_has_vce            0
-#define cpu_has_cache_cdex_p   0
-#define cpu_has_cache_cdex_s   0
-#define cpu_has_prefetch       1
-#define cpu_has_mcheck         0
-#define cpu_has_ejtag          0
-
-#define cpu_has_llsc           1
-#define cpu_has_vtag_icache    0
-#define cpu_has_dc_aliases     0
-#define cpu_has_ic_fills_f_dc  0
-#define cpu_has_dsp            0
-#define cpu_icache_snoops_remote_store 0
-#define cpu_has_mipsmt         0
-#define cpu_has_userlocal      0
-
-#define cpu_has_nofpuex                0
-#define cpu_has_64bits         1
-
-#define cpu_has_mips32r1       0
-#define cpu_has_mips32r2       0
-#define cpu_has_mips64r1       0
-#define cpu_has_mips64r2       0
-
-#define cpu_has_inclusive_pcaches      0
-
-#define cpu_dcache_line_size() 32
-#define cpu_icache_line_size() 32
-#define cpu_scache_line_size() 32
-
-#endif /* __ASM_MACH_EXCITE_CPU_FEATURE_OVERRIDES_H */
diff --git a/arch/mips/include/asm/mach-excite/excite.h b/arch/mips/include/asm/mach-excite/excite.h
deleted file mode 100644 (file)
index 4c29ba4..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-#ifndef __EXCITE_H__
-#define __EXCITE_H__
-
-#include <linux/init.h>
-#include <asm/addrspace.h>
-#include <asm/types.h>
-
-#define EXCITE_CPU_EXT_CLOCK 100000000
-
-#if !defined(__ASSEMBLY__)
-void __init excite_kgdb_init(void);
-void excite_procfs_init(void);
-extern unsigned long memsize;
-extern char modetty[];
-extern u32 unit_id;
-#endif
-
-/* Base name for XICAP devices */
-#define XICAP_NAME     "xicap_gpi"
-
-/* OCD register offsets */
-#define LKB0           0x0038
-#define LKB5           0x0128
-#define LKM5           0x012C
-#define LKB7           0x0138
-#define LKM7           0x013c
-#define LKB8           0x0140
-#define LKM8           0x0144
-#define LKB9           0x0148
-#define LKM9           0x014c
-#define LKB10          0x0150
-#define LKM10          0x0154
-#define LKB11          0x0158
-#define LKM11          0x015c
-#define LKB12          0x0160
-#define LKM12          0x0164
-#define LKB13          0x0168
-#define LKM13          0x016c
-#define LDP0           0x0200
-#define LDP1           0x0210
-#define LDP2           0x0220
-#define LDP3           0x0230
-#define INTPIN0                0x0A40
-#define INTPIN1                0x0A44
-#define INTPIN2                0x0A48
-#define INTPIN3                0x0A4C
-#define INTPIN4                0x0A50
-#define INTPIN5                0x0A54
-#define INTPIN6                0x0A58
-#define INTPIN7                0x0A5C
-
-
-
-
-/* TITAN register offsets */
-#define CPRR           0x0004
-#define CPDSR          0x0008
-#define CPTC0R         0x000c
-#define CPTC1R         0x0010
-#define CPCFG0         0x0020
-#define CPCFG1         0x0024
-#define CPDST0A                0x0028
-#define CPDST0B                0x002c
-#define CPDST1A                0x0030
-#define CPDST1B                0x0034
-#define CPXDSTA                0x0038
-#define CPXDSTB                0x003c
-#define CPXCISRA       0x0048
-#define CPXCISRB       0x004c
-#define CPGIG0ER       0x0050
-#define CPGIG1ER       0x0054
-#define CPGRWL         0x0068
-#define CPURSLMT       0x00f8
-#define UACFG          0x0200
-#define UAINTS         0x0204
-#define SDRXFCIE       0x4828
-#define SDTXFCIE       0x4928
-#define INTP0Status0   0x1B00
-#define INTP0Mask0     0x1B04
-#define INTP0Set0      0x1B08
-#define INTP0Clear0    0x1B0C
-#define GXCFG          0x5000
-#define GXDMADRPFX     0x5018
-#define GXDMA_DESCADR  0x501c
-#define GXCH0TDESSTRT  0x5054
-
-/* IRQ definitions */
-#define NMICONFIG              0xac0
-#define TITAN_MSGINT   0xc4
-#define TITAN_IRQ      ((TITAN_MSGINT / 0x20) + 2)
-#define FPGA0_MSGINT   0x5a
-#define FPGA0_IRQ      ((FPGA0_MSGINT / 0x20) + 2)
-#define FPGA1_MSGINT   0x7b
-#define FPGA1_IRQ      ((FPGA1_MSGINT / 0x20) + 2)
-#define PHY_MSGINT     0x9c
-#define PHY_IRQ                ((PHY_MSGINT   / 0x20) + 2)
-
-#if defined(CONFIG_BASLER_EXCITE_PROTOTYPE)
-/* Pre-release units used interrupt pin #9 */
-#define USB_IRQ                11
-#else
-/* Re-designed units use interrupt pin #1 */
-#define USB_MSGINT     0x39
-#define USB_IRQ                ((USB_MSGINT / 0x20) + 2)
-#endif
-#define TIMER_IRQ      12
-
-
-/* Device address ranges */
-#define EXCITE_OFFS_OCD                0x1fffc000
-#define        EXCITE_SIZE_OCD         (16 * 1024)
-#define EXCITE_PHYS_OCD                CPHYSADDR(EXCITE_OFFS_OCD)
-#define EXCITE_ADDR_OCD                CKSEG1ADDR(EXCITE_OFFS_OCD)
-
-#define EXCITE_OFFS_SCRAM      0x1fffa000
-#define        EXCITE_SIZE_SCRAM       (8 << 10)
-#define EXCITE_PHYS_SCRAM      CPHYSADDR(EXCITE_OFFS_SCRAM)
-#define EXCITE_ADDR_SCRAM      CKSEG1ADDR(EXCITE_OFFS_SCRAM)
-
-#define EXCITE_OFFS_PCI_IO     0x1fff8000
-#define        EXCITE_SIZE_PCI_IO      (8 << 10)
-#define EXCITE_PHYS_PCI_IO     CPHYSADDR(EXCITE_OFFS_PCI_IO)
-#define EXCITE_ADDR_PCI_IO     CKSEG1ADDR(EXCITE_OFFS_PCI_IO)
-
-#define EXCITE_OFFS_TITAN      0x1fff0000
-#define EXCITE_SIZE_TITAN      (32 << 10)
-#define EXCITE_PHYS_TITAN      CPHYSADDR(EXCITE_OFFS_TITAN)
-#define EXCITE_ADDR_TITAN      CKSEG1ADDR(EXCITE_OFFS_TITAN)
-
-#define EXCITE_OFFS_PCI_MEM    0x1ffe0000
-#define EXCITE_SIZE_PCI_MEM    (64 << 10)
-#define EXCITE_PHYS_PCI_MEM    CPHYSADDR(EXCITE_OFFS_PCI_MEM)
-#define EXCITE_ADDR_PCI_MEM    CKSEG1ADDR(EXCITE_OFFS_PCI_MEM)
-
-#define EXCITE_OFFS_FPGA       0x1ffdc000
-#define EXCITE_SIZE_FPGA       (16 << 10)
-#define EXCITE_PHYS_FPGA       CPHYSADDR(EXCITE_OFFS_FPGA)
-#define EXCITE_ADDR_FPGA       CKSEG1ADDR(EXCITE_OFFS_FPGA)
-
-#define EXCITE_OFFS_NAND       0x1ffd8000
-#define EXCITE_SIZE_NAND       (16 << 10)
-#define EXCITE_PHYS_NAND       CPHYSADDR(EXCITE_OFFS_NAND)
-#define EXCITE_ADDR_NAND       CKSEG1ADDR(EXCITE_OFFS_NAND)
-
-#define EXCITE_OFFS_BOOTROM    0x1f000000
-#define EXCITE_SIZE_BOOTROM    (8 << 20)
-#define EXCITE_PHYS_BOOTROM    CPHYSADDR(EXCITE_OFFS_BOOTROM)
-#define EXCITE_ADDR_BOOTROM    CKSEG1ADDR(EXCITE_OFFS_BOOTROM)
-
-/* FPGA address offsets */
-#define EXCITE_FPGA_DPR                0x0104  /* dual-ported ram */
-#define EXCITE_FPGA_SYSCTL     0x0200  /* system control register block */
-
-#endif /* __EXCITE_H__ */
diff --git a/arch/mips/include/asm/mach-excite/excite_fpga.h b/arch/mips/include/asm/mach-excite/excite_fpga.h
deleted file mode 100644 (file)
index 0a1ef69..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef EXCITE_FPGA_H_INCLUDED
-#define EXCITE_FPGA_H_INCLUDED
-
-
-/**
- * Address alignment of the individual FPGA bytes.
- * The address arrangement of the individual bytes of the FPGA is two
- * byte aligned at the embedded MK2 platform.
- */
-#ifdef EXCITE_CCI_FPGA_MK2
-typedef unsigned char excite_cci_fpga_align_t __attribute__ ((aligned(2)));
-#else
-typedef unsigned char excite_cci_fpga_align_t;
-#endif
-
-
-/**
- * Size of Dual Ported RAM.
- */
-#define EXCITE_DPR_SIZE 263
-
-
-/**
- * Size of Reserved Status Fields in Dual Ported RAM.
- */
-#define EXCITE_DPR_STATUS_SIZE 7
-
-
-
-/**
- * FPGA.
- * Hardware register layout of the FPGA interface. The FPGA must accessed
- * byte wise solely.
- * @see EXCITE_CCI_DPR_MK2
- */
-typedef struct excite_fpga {
-
-       /**
-        * Dual Ported RAM.
-        */
-       excite_cci_fpga_align_t dpr[EXCITE_DPR_SIZE];
-
-       /**
-        * Status.
-        */
-       excite_cci_fpga_align_t status[EXCITE_DPR_STATUS_SIZE];
-
-#ifdef EXCITE_CCI_FPGA_MK2
-       /**
-        * RM9000 Interrupt.
-        * Write access initiates interrupt at the RM9000 (MIPS) processor of the eXcite.
-        */
-       excite_cci_fpga_align_t rm9k_int;
-#else
-       /**
-        * MK2 Interrupt.
-        * Write access initiates interrupt at the ARM processor of the MK2.
-        */
-       excite_cci_fpga_align_t mk2_int;
-
-       excite_cci_fpga_align_t gap[0x1000-0x10f];
-
-       /**
-        * IRQ Source/Acknowledge.
-        */
-       excite_cci_fpga_align_t rm9k_irq_src;
-
-       /**
-        * IRQ Mask.
-        * Set bits enable the related interrupt.
-        */
-       excite_cci_fpga_align_t rm9k_irq_mask;
-#endif
-
-
-} excite_fpga;
-
-
-
-#endif /* ndef EXCITE_FPGA_H_INCLUDED */
diff --git a/arch/mips/include/asm/mach-excite/excite_nandflash.h b/arch/mips/include/asm/mach-excite/excite_nandflash.h
deleted file mode 100644 (file)
index c4cf614..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __EXCITE_NANDFLASH_H__
-#define __EXCITE_NANDFLASH_H__
-
-/* Resource names */
-#define EXCITE_NANDFLASH_RESOURCE_REGS "excite_nandflash_regs"
-
-#endif /* __EXCITE_NANDFLASH_H__ */
diff --git a/arch/mips/include/asm/mach-excite/rm9k_eth.h b/arch/mips/include/asm/mach-excite/rm9k_eth.h
deleted file mode 100644 (file)
index 94705a4..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#if !defined(__RM9K_ETH_H__)
-#define __RM9K_ETH_H__
-
-#define RM9K_GE_NAME                   "rm9k_ge"
-
-/* Resource names */
-#define RM9K_GE_RESOURCE_MAC           "rm9k_ge_mac"
-#define RM9K_GE_RESOURCE_MSTAT         "rm9k_ge_mstat"
-#define RM9K_GE_RESOURCE_PKTPROC       "rm9k_ge_pktproc"
-#define RM9K_GE_RESOURCE_XDMA          "rm9k_ge_xdma"
-#define RM9K_GE_RESOURCE_FIFO_RX       "rm9k_ge_fifo_rx"
-#define RM9K_GE_RESOURCE_FIFO_TX       "rm9k_ge_fifo_tx"
-#define RM9K_GE_RESOURCE_FIFOMEM_RX    "rm9k_ge_fifo_memory_rx"
-#define RM9K_GE_RESOURCE_FIFOMEM_TX    "rm9k_ge_fifo_memory_tx"
-#define RM9K_GE_RESOURCE_PHY           "rm9k_ge_phy"
-#define RM9K_GE_RESOURCE_DMADESC_RX    "rm9k_ge_dmadesc_rx"
-#define RM9K_GE_RESOURCE_DMADESC_TX    "rm9k_ge_dmadesc_tx"
-#define RM9K_GE_RESOURCE_IRQ_MAIN      "rm9k_ge_irq_main"
-#define RM9K_GE_RESOURCE_IRQ_PHY       "rm9k_ge_irq_phy"
-#define RM9K_GE_RESOURCE_GPI_SLICE     "rm9k_ge_gpi_slice"
-#define RM9K_GE_RESOURCE_MDIO_CHANNEL  "rm9k_ge_mdio_channel"
-
-#endif /* !defined(__RM9K_ETH_H__) */
diff --git a/arch/mips/include/asm/mach-excite/rm9k_wdt.h b/arch/mips/include/asm/mach-excite/rm9k_wdt.h
deleted file mode 100644 (file)
index 3fa3c08..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef __RM9K_WDT_H__
-#define __RM9K_WDT_H__
-
-/* Device name */
-#define WDT_NAME               "wdt_gpi"
-
-/* Resource names */
-#define WDT_RESOURCE_REGS      "excite_watchdog_regs"
-#define WDT_RESOURCE_IRQ       "excite_watchdog_irq"
-#define WDT_RESOURCE_COUNTER   "excite_watchdog_counter"
-
-#endif /* __RM9K_WDT_H__ */
diff --git a/arch/mips/include/asm/mach-excite/rm9k_xicap.h b/arch/mips/include/asm/mach-excite/rm9k_xicap.h
deleted file mode 100644 (file)
index 0095777..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __EXCITE_XICAP_H__
-#define __EXCITE_XICAP_H__
-
-
-/* Resource names */
-#define XICAP_RESOURCE_FIFO_RX         "xicap_fifo_rx"
-#define XICAP_RESOURCE_FIFO_TX         "xicap_fifo_tx"
-#define XICAP_RESOURCE_XDMA            "xicap_xdma"
-#define XICAP_RESOURCE_DMADESC         "xicap_dmadesc"
-#define XICAP_RESOURCE_PKTPROC         "xicap_pktproc"
-#define XICAP_RESOURCE_IRQ             "xicap_irq"
-#define XICAP_RESOURCE_GPI_SLICE       "xicap_gpi_slice"
-#define XICAP_RESOURCE_FIFO_BLK                "xicap_fifo_blocks"
-#define XICAP_RESOURCE_PKT_STREAM      "xicap_pkt_stream"
-
-#endif /* __EXCITE_XICAP_H__ */
diff --git a/arch/mips/include/asm/mach-loongson/cs5536/cs5536.h b/arch/mips/include/asm/mach-loongson/cs5536/cs5536.h
new file mode 100644 (file)
index 0000000..021f77c
--- /dev/null
@@ -0,0 +1,305 @@
+/*
+ * The header file of cs5536 sourth bridge.
+ *
+ * Copyright (C) 2007 Lemote, Inc.
+ * Author : jlliu <liujl@lemote.com>
+ */
+
+#ifndef        _CS5536_H
+#define        _CS5536_H
+
+#include <linux/types.h>
+
+extern void _rdmsr(u32 msr, u32 *hi, u32 *lo);
+extern void _wrmsr(u32 msr, u32 hi, u32 lo);
+
+/*
+ * MSR module base
+ */
+#define        CS5536_SB_MSR_BASE      (0x00000000)
+#define        CS5536_GLIU_MSR_BASE    (0x10000000)
+#define        CS5536_ILLEGAL_MSR_BASE (0x20000000)
+#define        CS5536_USB_MSR_BASE     (0x40000000)
+#define        CS5536_IDE_MSR_BASE     (0x60000000)
+#define        CS5536_DIVIL_MSR_BASE   (0x80000000)
+#define        CS5536_ACC_MSR_BASE     (0xa0000000)
+#define        CS5536_UNUSED_MSR_BASE  (0xc0000000)
+#define        CS5536_GLCP_MSR_BASE    (0xe0000000)
+
+#define        SB_MSR_REG(offset)      (CS5536_SB_MSR_BASE     | (offset))
+#define        GLIU_MSR_REG(offset)    (CS5536_GLIU_MSR_BASE   | (offset))
+#define        ILLEGAL_MSR_REG(offset) (CS5536_ILLEGAL_MSR_BASE | (offset))
+#define        USB_MSR_REG(offset)     (CS5536_USB_MSR_BASE    | (offset))
+#define        IDE_MSR_REG(offset)     (CS5536_IDE_MSR_BASE    | (offset))
+#define        DIVIL_MSR_REG(offset)   (CS5536_DIVIL_MSR_BASE  | (offset))
+#define        ACC_MSR_REG(offset)     (CS5536_ACC_MSR_BASE    | (offset))
+#define        UNUSED_MSR_REG(offset)  (CS5536_UNUSED_MSR_BASE | (offset))
+#define        GLCP_MSR_REG(offset)    (CS5536_GLCP_MSR_BASE   | (offset))
+
+/*
+ * BAR SPACE OF VIRTUAL PCI :
+ * range for pci probe use, length is the actual size.
+ */
+/* IO space for all DIVIL modules */
+#define        CS5536_IRQ_RANGE        0xffffffe0 /* USERD FOR PCI PROBE */
+#define        CS5536_IRQ_LENGTH       0x20    /* THE REGS ACTUAL LENGTH */
+#define        CS5536_SMB_RANGE        0xfffffff8
+#define        CS5536_SMB_LENGTH       0x08
+#define        CS5536_GPIO_RANGE       0xffffff00
+#define        CS5536_GPIO_LENGTH      0x100
+#define        CS5536_MFGPT_RANGE      0xffffffc0
+#define        CS5536_MFGPT_LENGTH     0x40
+#define        CS5536_ACPI_RANGE       0xffffffe0
+#define        CS5536_ACPI_LENGTH      0x20
+#define        CS5536_PMS_RANGE        0xffffff80
+#define        CS5536_PMS_LENGTH       0x80
+/* IO space for IDE */
+#define        CS5536_IDE_RANGE        0xfffffff0
+#define        CS5536_IDE_LENGTH       0x10
+/* IO space for ACC */
+#define        CS5536_ACC_RANGE        0xffffff80
+#define        CS5536_ACC_LENGTH       0x80
+/* MEM space for ALL USB modules */
+#define        CS5536_OHCI_RANGE       0xfffff000
+#define        CS5536_OHCI_LENGTH      0x1000
+#define        CS5536_EHCI_RANGE       0xfffff000
+#define        CS5536_EHCI_LENGTH      0x1000
+
+/*
+ * PCI MSR ACCESS
+ */
+#define        PCI_MSR_CTRL            0xF0
+#define        PCI_MSR_ADDR            0xF4
+#define        PCI_MSR_DATA_LO         0xF8
+#define        PCI_MSR_DATA_HI         0xFC
+
+/**************** MSR *****************************/
+
+/*
+ * GLIU STANDARD MSR
+ */
+#define        GLIU_CAP                0x00
+#define        GLIU_CONFIG             0x01
+#define        GLIU_SMI                0x02
+#define        GLIU_ERROR              0x03
+#define        GLIU_PM                 0x04
+#define        GLIU_DIAG               0x05
+
+/*
+ * GLIU SPEC. MSR
+ */
+#define        GLIU_P2D_BM0            0x20
+#define        GLIU_P2D_BM1            0x21
+#define        GLIU_P2D_BM2            0x22
+#define        GLIU_P2D_BMK0           0x23
+#define        GLIU_P2D_BMK1           0x24
+#define        GLIU_P2D_BM3            0x25
+#define        GLIU_P2D_BM4            0x26
+#define        GLIU_COH                0x80
+#define        GLIU_PAE                0x81
+#define        GLIU_ARB                0x82
+#define        GLIU_ASMI               0x83
+#define        GLIU_AERR               0x84
+#define        GLIU_DEBUG              0x85
+#define        GLIU_PHY_CAP            0x86
+#define        GLIU_NOUT_RESP          0x87
+#define        GLIU_NOUT_WDATA         0x88
+#define        GLIU_WHOAMI             0x8B
+#define        GLIU_SLV_DIS            0x8C
+#define        GLIU_IOD_BM0            0xE0
+#define        GLIU_IOD_BM1            0xE1
+#define        GLIU_IOD_BM2            0xE2
+#define        GLIU_IOD_BM3            0xE3
+#define        GLIU_IOD_BM4            0xE4
+#define        GLIU_IOD_BM5            0xE5
+#define        GLIU_IOD_BM6            0xE6
+#define        GLIU_IOD_BM7            0xE7
+#define        GLIU_IOD_BM8            0xE8
+#define        GLIU_IOD_BM9            0xE9
+#define        GLIU_IOD_SC0            0xEA
+#define        GLIU_IOD_SC1            0xEB
+#define        GLIU_IOD_SC2            0xEC
+#define        GLIU_IOD_SC3            0xED
+#define        GLIU_IOD_SC4            0xEE
+#define        GLIU_IOD_SC5            0xEF
+#define        GLIU_IOD_SC6            0xF0
+#define        GLIU_IOD_SC7            0xF1
+
+/*
+ * SB STANDARD
+ */
+#define        SB_CAP          0x00
+#define        SB_CONFIG       0x01
+#define        SB_SMI          0x02
+#define        SB_ERROR        0x03
+#define        SB_MAR_ERR_EN           0x00000001
+#define        SB_TAR_ERR_EN           0x00000002
+#define        SB_RSVD_BIT1            0x00000004
+#define        SB_EXCEP_ERR_EN         0x00000008
+#define        SB_SYSE_ERR_EN          0x00000010
+#define        SB_PARE_ERR_EN          0x00000020
+#define        SB_TAS_ERR_EN           0x00000040
+#define        SB_MAR_ERR_FLAG         0x00010000
+#define        SB_TAR_ERR_FLAG         0x00020000
+#define        SB_RSVD_BIT2            0x00040000
+#define        SB_EXCEP_ERR_FLAG       0x00080000
+#define        SB_SYSE_ERR_FLAG        0x00100000
+#define        SB_PARE_ERR_FLAG        0x00200000
+#define        SB_TAS_ERR_FLAG         0x00400000
+#define        SB_PM           0x04
+#define        SB_DIAG         0x05
+
+/*
+ * SB SPEC.
+ */
+#define        SB_CTRL         0x10
+#define        SB_R0           0x20
+#define        SB_R1           0x21
+#define        SB_R2           0x22
+#define        SB_R3           0x23
+#define        SB_R4           0x24
+#define        SB_R5           0x25
+#define        SB_R6           0x26
+#define        SB_R7           0x27
+#define        SB_R8           0x28
+#define        SB_R9           0x29
+#define        SB_R10          0x2A
+#define        SB_R11          0x2B
+#define        SB_R12          0x2C
+#define        SB_R13          0x2D
+#define        SB_R14          0x2E
+#define        SB_R15          0x2F
+
+/*
+ * GLCP STANDARD
+ */
+#define        GLCP_CAP                0x00
+#define        GLCP_CONFIG             0x01
+#define        GLCP_SMI                0x02
+#define        GLCP_ERROR              0x03
+#define        GLCP_PM                 0x04
+#define        GLCP_DIAG               0x05
+
+/*
+ * GLCP SPEC.
+ */
+#define        GLCP_CLK_DIS_DELAY      0x08
+#define        GLCP_PM_CLK_DISABLE     0x09
+#define        GLCP_GLB_PM             0x0B
+#define        GLCP_DBG_OUT            0x0C
+#define        GLCP_RSVD1              0x0D
+#define        GLCP_SOFT_COM           0x0E
+#define        SOFT_BAR_SMB_FLAG       0x00000001
+#define        SOFT_BAR_GPIO_FLAG      0x00000002
+#define        SOFT_BAR_MFGPT_FLAG     0x00000004
+#define        SOFT_BAR_IRQ_FLAG       0x00000008
+#define        SOFT_BAR_PMS_FLAG       0x00000010
+#define        SOFT_BAR_ACPI_FLAG      0x00000020
+#define        SOFT_BAR_IDE_FLAG       0x00000400
+#define        SOFT_BAR_ACC_FLAG       0x00000800
+#define        SOFT_BAR_OHCI_FLAG      0x00001000
+#define        SOFT_BAR_EHCI_FLAG      0x00002000
+#define        GLCP_RSVD2              0x0F
+#define        GLCP_CLK_OFF            0x10
+#define        GLCP_CLK_ACTIVE         0x11
+#define        GLCP_CLK_DISABLE        0x12
+#define        GLCP_CLK4ACK            0x13
+#define        GLCP_SYS_RST            0x14
+#define        GLCP_RSVD3              0x15
+#define        GLCP_DBG_CLK_CTRL       0x16
+#define        GLCP_CHIP_REV_ID        0x17
+
+/* PIC */
+#define        PIC_YSEL_LOW            0x20
+#define        PIC_YSEL_LOW_USB_SHIFT          8
+#define        PIC_YSEL_LOW_ACC_SHIFT          16
+#define        PIC_YSEL_LOW_FLASH_SHIFT        24
+#define        PIC_YSEL_HIGH           0x21
+#define        PIC_ZSEL_LOW            0x22
+#define        PIC_ZSEL_HIGH           0x23
+#define        PIC_IRQM_PRIM           0x24
+#define        PIC_IRQM_LPC            0x25
+#define        PIC_XIRR_STS_LOW        0x26
+#define        PIC_XIRR_STS_HIGH       0x27
+#define        PCI_SHDW                0x34
+
+/*
+ * DIVIL STANDARD
+ */
+#define        DIVIL_CAP               0x00
+#define        DIVIL_CONFIG            0x01
+#define        DIVIL_SMI               0x02
+#define        DIVIL_ERROR             0x03
+#define        DIVIL_PM                0x04
+#define        DIVIL_DIAG              0x05
+
+/*
+ * DIVIL SPEC.
+ */
+#define        DIVIL_LBAR_IRQ          0x08
+#define        DIVIL_LBAR_KEL          0x09
+#define        DIVIL_LBAR_SMB          0x0B
+#define        DIVIL_LBAR_GPIO         0x0C
+#define        DIVIL_LBAR_MFGPT        0x0D
+#define        DIVIL_LBAR_ACPI         0x0E
+#define        DIVIL_LBAR_PMS          0x0F
+#define        DIVIL_LEG_IO            0x14
+#define        DIVIL_BALL_OPTS         0x15
+#define        DIVIL_SOFT_IRQ          0x16
+#define        DIVIL_SOFT_RESET        0x17
+
+/* MFGPT */
+#define MFGPT_IRQ      0x28
+
+/*
+ * IDE STANDARD
+ */
+#define        IDE_CAP         0x00
+#define        IDE_CONFIG      0x01
+#define        IDE_SMI         0x02
+#define        IDE_ERROR       0x03
+#define        IDE_PM          0x04
+#define        IDE_DIAG        0x05
+
+/*
+ * IDE SPEC.
+ */
+#define        IDE_IO_BAR      0x08
+#define        IDE_CFG         0x10
+#define        IDE_DTC         0x12
+#define        IDE_CAST        0x13
+#define        IDE_ETC         0x14
+#define        IDE_INTERNAL_PM 0x15
+
+/*
+ * ACC STANDARD
+ */
+#define        ACC_CAP         0x00
+#define        ACC_CONFIG      0x01
+#define        ACC_SMI         0x02
+#define        ACC_ERROR       0x03
+#define        ACC_PM          0x04
+#define        ACC_DIAG        0x05
+
+/*
+ * USB STANDARD
+ */
+#define        USB_CAP         0x00
+#define        USB_CONFIG      0x01
+#define        USB_SMI         0x02
+#define        USB_ERROR       0x03
+#define        USB_PM          0x04
+#define        USB_DIAG        0x05
+
+/*
+ * USB SPEC.
+ */
+#define        USB_OHCI        0x08
+#define        USB_EHCI        0x09
+
+/****************** NATIVE ***************************/
+/* GPIO : I/O SPACE; REG : 32BITS */
+#define        GPIOL_OUT_VAL           0x00
+#define        GPIOL_OUT_EN            0x04
+
+#endif                         /* _CS5536_H */
diff --git a/arch/mips/include/asm/mach-loongson/cs5536/cs5536_mfgpt.h b/arch/mips/include/asm/mach-loongson/cs5536/cs5536_mfgpt.h
new file mode 100644 (file)
index 0000000..4b493d6
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * cs5536 mfgpt header file
+ */
+
+#ifndef _CS5536_MFGPT_H
+#define _CS5536_MFGPT_H
+
+#include <cs5536/cs5536.h>
+#include <cs5536/cs5536_pci.h>
+
+#ifdef CONFIG_CS5536_MFGPT
+extern void setup_mfgpt0_timer(void);
+extern void disable_mfgpt0_counter(void);
+extern void enable_mfgpt0_counter(void);
+#else
+static inline void __maybe_unused setup_mfgpt0_timer(void)
+{
+}
+static inline void __maybe_unused disable_mfgpt0_counter(void)
+{
+}
+static inline void __maybe_unused enable_mfgpt0_counter(void)
+{
+}
+#endif
+
+#define MFGPT_TICK_RATE 14318000
+#define COMPARE  ((MFGPT_TICK_RATE + HZ/2) / HZ)
+
+#define MFGPT_BASE     mfgpt_base
+#define MFGPT0_CMP2    (MFGPT_BASE + 2)
+#define MFGPT0_CNT     (MFGPT_BASE + 4)
+#define MFGPT0_SETUP   (MFGPT_BASE + 6)
+
+#endif /*!_CS5536_MFGPT_H */
diff --git a/arch/mips/include/asm/mach-loongson/cs5536/cs5536_pci.h b/arch/mips/include/asm/mach-loongson/cs5536/cs5536_pci.h
new file mode 100644 (file)
index 0000000..0dca9c8
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * the definition file of cs5536 Virtual Support Module(VSM).
+ * pci configuration space can be accessed through the VSM, so
+ * there is no need of the MSR read/write now, except the spec.
+ * MSR registers which are not implemented yet.
+ *
+ * Copyright (C) 2007 Lemote Inc.
+ * Author : jlliu, liujl@lemote.com
+ */
+
+#ifndef        _CS5536_PCI_H
+#define        _CS5536_PCI_H
+
+#include <linux/types.h>
+#include <linux/pci_regs.h>
+
+extern void cs5536_pci_conf_write4(int function, int reg, u32 value);
+extern u32 cs5536_pci_conf_read4(int function, int reg);
+
+#define        CS5536_ACC_INTR         9
+#define        CS5536_IDE_INTR         14
+#define        CS5536_USB_INTR         11
+#define        CS5536_MFGPT_INTR       5
+#define        CS5536_UART1_INTR       4
+#define        CS5536_UART2_INTR       3
+
+/************** PCI BUS DEVICE FUNCTION ***************/
+
+/*
+ * PCI bus device function
+ */
+#define        PCI_BUS_CS5536          0
+#define        PCI_IDSEL_CS5536        14
+
+/********** STANDARD PCI-2.2 EXPANSION ****************/
+
+/*
+ * PCI configuration space
+ * we have to virtualize the PCI configure space head, so we should
+ * define the necessary IDs and some others.
+ */
+
+/* CONFIG of PCI VENDOR ID*/
+#define CFG_PCI_VENDOR_ID(mod_dev_id, sys_vendor_id) \
+       (((mod_dev_id) << 16) | (sys_vendor_id))
+
+/* VENDOR ID */
+#define        CS5536_VENDOR_ID        0x1022
+
+/* DEVICE ID */
+#define        CS5536_ISA_DEVICE_ID            0x2090
+#define        CS5536_IDE_DEVICE_ID            0x209a
+#define        CS5536_ACC_DEVICE_ID            0x2093
+#define        CS5536_OHCI_DEVICE_ID           0x2094
+#define        CS5536_EHCI_DEVICE_ID           0x2095
+
+/* CLASS CODE : CLASS SUB-CLASS INTERFACE */
+#define        CS5536_ISA_CLASS_CODE           0x060100
+#define CS5536_IDE_CLASS_CODE          0x010180
+#define        CS5536_ACC_CLASS_CODE           0x040100
+#define        CS5536_OHCI_CLASS_CODE          0x0C0310
+#define        CS5536_EHCI_CLASS_CODE          0x0C0320
+
+/* BHLC : BIST HEADER-TYPE LATENCY-TIMER CACHE-LINE-SIZE */
+
+#define CFG_PCI_CACHE_LINE_SIZE(header_type, latency_timer)    \
+       ((PCI_NONE_BIST << 24) | ((header_type) << 16) \
+               | ((latency_timer) << 8) | PCI_NORMAL_CACHE_LINE_SIZE);
+
+#define        PCI_NONE_BIST                   0x00    /* RO not implemented yet. */
+#define        PCI_BRIDGE_HEADER_TYPE          0x80    /* RO */
+#define        PCI_NORMAL_HEADER_TYPE          0x00
+#define        PCI_NORMAL_LATENCY_TIMER        0x00
+#define        PCI_NORMAL_CACHE_LINE_SIZE      0x08    /* RW */
+
+/* BAR */
+#define        PCI_BAR0_REG                    0x10
+#define        PCI_BAR1_REG                    0x14
+#define        PCI_BAR2_REG                    0x18
+#define        PCI_BAR3_REG                    0x1c
+#define        PCI_BAR4_REG                    0x20
+#define        PCI_BAR5_REG                    0x24
+#define        PCI_BAR_COUNT                   6
+#define        PCI_BAR_RANGE_MASK              0xFFFFFFFF
+
+/* CARDBUS CIS POINTER */
+#define        PCI_CARDBUS_CIS_POINTER         0x00000000
+
+/* SUBSYSTEM VENDOR ID  */
+#define        CS5536_SUB_VENDOR_ID            CS5536_VENDOR_ID
+
+/* SUBSYSTEM ID */
+#define        CS5536_ISA_SUB_ID               CS5536_ISA_DEVICE_ID
+#define        CS5536_IDE_SUB_ID               CS5536_IDE_DEVICE_ID
+#define        CS5536_ACC_SUB_ID               CS5536_ACC_DEVICE_ID
+#define        CS5536_OHCI_SUB_ID              CS5536_OHCI_DEVICE_ID
+#define        CS5536_EHCI_SUB_ID              CS5536_EHCI_DEVICE_ID
+
+/* EXPANSION ROM BAR */
+#define        PCI_EXPANSION_ROM_BAR           0x00000000
+
+/* CAPABILITIES POINTER */
+#define        PCI_CAPLIST_POINTER             0x00000000
+#define PCI_CAPLIST_USB_POINTER                0x40
+/* INTERRUPT */
+
+#define CFG_PCI_INTERRUPT_LINE(pin, mod_intr) \
+       ((PCI_MAX_LATENCY << 24) | (PCI_MIN_GRANT << 16) | \
+               ((pin) << 8) | (mod_intr))
+
+#define        PCI_MAX_LATENCY                 0x40
+#define        PCI_MIN_GRANT                   0x00
+#define        PCI_DEFAULT_PIN                 0x01
+
+/*********** EXPANSION PCI REG ************************/
+
+/*
+ * ISA EXPANSION
+ */
+#define        PCI_UART1_INT_REG       0x50
+#define PCI_UART2_INT_REG      0x54
+#define        PCI_ISA_FIXUP_REG       0x58
+
+/*
+ * IDE EXPANSION
+ */
+#define        PCI_IDE_CFG_REG         0x40
+#define        CS5536_IDE_FLASH_SIGNATURE      0xDEADBEEF
+#define        PCI_IDE_DTC_REG         0x48
+#define        PCI_IDE_CAST_REG        0x4C
+#define        PCI_IDE_ETC_REG         0x50
+#define        PCI_IDE_PM_REG          0x54
+#define        PCI_IDE_INT_REG         0x60
+
+/*
+ * ACC EXPANSION
+ */
+#define        PCI_ACC_INT_REG         0x50
+
+/*
+ * OHCI EXPANSION : INTTERUPT IS IMPLEMENTED BY THE OHCI
+ */
+#define        PCI_OHCI_PM_REG         0x40
+#define        PCI_OHCI_INT_REG        0x50
+
+/*
+ * EHCI EXPANSION
+ */
+#define        PCI_EHCI_LEGSMIEN_REG   0x50
+#define        PCI_EHCI_LEGSMISTS_REG  0x54
+#define        PCI_EHCI_FLADJ_REG      0x60
+
+#endif                         /* _CS5536_PCI_H_ */
diff --git a/arch/mips/include/asm/mach-loongson/cs5536/cs5536_vsm.h b/arch/mips/include/asm/mach-loongson/cs5536/cs5536_vsm.h
new file mode 100644 (file)
index 0000000..6305bea
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * the read/write interfaces for Virtual Support Module(VSM)
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin <wuzj@lemote.com>
+ */
+
+#ifndef        _CS5536_VSM_H
+#define        _CS5536_VSM_H
+
+#include <linux/types.h>
+
+typedef void (*cs5536_pci_vsm_write)(int reg, u32 value);
+typedef u32 (*cs5536_pci_vsm_read)(int reg);
+
+#define DECLARE_CS5536_MODULE(name) \
+extern void pci_##name##_write_reg(int reg, u32 value); \
+extern u32 pci_##name##_read_reg(int reg);
+
+/* ide module */
+DECLARE_CS5536_MODULE(ide)
+/* acc module */
+DECLARE_CS5536_MODULE(acc)
+/* ohci module */
+DECLARE_CS5536_MODULE(ohci)
+/* isa module */
+DECLARE_CS5536_MODULE(isa)
+/* ehci module */
+DECLARE_CS5536_MODULE(ehci)
+
+#endif                         /* _CS5536_VSM_H */
index 71a6851ba833250b572e75372b41811ec4bcd6ba..981c75f91a7db42fb79c7ef8573668056ab811d5 100644 (file)
@@ -28,7 +28,11 @@ static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
 static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
        dma_addr_t dma_addr)
 {
+#if defined(CONFIG_CPU_LOONGSON2F) && defined(CONFIG_64BIT)
+       return (dma_addr > 0x8fffffff) ? dma_addr : (dma_addr & 0x0fffffff);
+#else
        return dma_addr & 0x7fffffff;
+#endif
 }
 
 static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
index da70bcf2304e63106f029422a7888fa42860bff9..ee8bc83769723ebd8282cbe814ff7ac985f6ea6e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology
+ * Copyright (C) 2009 Lemote, Inc.
  * Author: Wu Zhangjin <wuzj@lemote.com>
  *
  * This program is free software; you can redistribute  it and/or modify it
@@ -15,9 +15,6 @@
 #include <linux/io.h>
 #include <linux/init.h>
 
-/* there is an internal bonito64-compatiable northbridge in loongson2e/2f */
-#include <asm/mips-boards/bonito64.h>
-
 /* loongson internal northbridge initialization */
 extern void bonito_irq_init(void);
 
@@ -32,7 +29,19 @@ extern unsigned long memsize, highmemsize;
 /* loongson-specific command line, env and memory initialization */
 extern void __init prom_init_memory(void);
 extern void __init prom_init_cmdline(void);
+extern void __init prom_init_machtype(void);
 extern void __init prom_init_env(void);
+#ifdef CONFIG_LOONGSON_UART_BASE
+extern unsigned long _loongson_uart_base, loongson_uart_base;
+extern void prom_init_loongson_uart_base(void);
+#endif
+
+static inline void prom_init_uart_base(void)
+{
+#ifdef CONFIG_LOONGSON_UART_BASE
+       prom_init_loongson_uart_base();
+#endif
+}
 
 /* irq operation functions */
 extern void bonito_irqdispatch(void);
@@ -40,25 +49,276 @@ extern void __init bonito_irq_init(void);
 extern void __init set_irq_trigger_mode(void);
 extern void __init mach_init_irq(void);
 extern void mach_irq_dispatch(unsigned int pending);
+extern int mach_i8259_irq(void);
+
+/* We need this in some places... */
+#define delay()        ({              \
+       int x;                          \
+       for (x = 0; x < 100000; x++)    \
+               __asm__ __volatile__(""); \
+})
+
+#define LOONGSON_REG(x) \
+       (*(volatile u32 *)((char *)CKSEG1ADDR(LOONGSON_REG_BASE) + (x)))
+
+#define LOONGSON_IRQ_BASE      32
+#define LOONGSON2_PERFCNT_IRQ  (MIPS_CPU_IRQ_BASE + 6) /* cpu perf counter */
+
+#define LOONGSON_FLASH_BASE    0x1c000000
+#define LOONGSON_FLASH_SIZE    0x02000000      /* 32M */
+#define LOONGSON_FLASH_TOP     (LOONGSON_FLASH_BASE+LOONGSON_FLASH_SIZE-1)
+
+#define LOONGSON_LIO0_BASE     0x1e000000
+#define LOONGSON_LIO0_SIZE     0x01C00000      /* 28M */
+#define LOONGSON_LIO0_TOP      (LOONGSON_LIO0_BASE+LOONGSON_LIO0_SIZE-1)
+
+#define LOONGSON_BOOT_BASE     0x1fc00000
+#define LOONGSON_BOOT_SIZE     0x00100000      /* 1M */
+#define LOONGSON_BOOT_TOP      (LOONGSON_BOOT_BASE+LOONGSON_BOOT_SIZE-1)
+#define LOONGSON_REG_BASE      0x1fe00000
+#define LOONGSON_REG_SIZE      0x00100000      /* 256Bytes + 256Bytes + ??? */
+#define LOONGSON_REG_TOP       (LOONGSON_REG_BASE+LOONGSON_REG_SIZE-1)
+
+#define LOONGSON_LIO1_BASE     0x1ff00000
+#define LOONGSON_LIO1_SIZE     0x00100000      /* 1M */
+#define LOONGSON_LIO1_TOP      (LOONGSON_LIO1_BASE+LOONGSON_LIO1_SIZE-1)
+
+#define LOONGSON_PCILO0_BASE   0x10000000
+#define LOONGSON_PCILO1_BASE   0x14000000
+#define LOONGSON_PCILO2_BASE   0x18000000
+#define LOONGSON_PCILO_BASE    LOONGSON_PCILO0_BASE
+#define LOONGSON_PCILO_SIZE    0x0c000000      /* 64M * 3 */
+#define LOONGSON_PCILO_TOP     (LOONGSON_PCILO0_BASE+LOONGSON_PCILO_SIZE-1)
+
+#define LOONGSON_PCICFG_BASE   0x1fe80000
+#define LOONGSON_PCICFG_SIZE   0x00000800      /* 2K */
+#define LOONGSON_PCICFG_TOP    (LOONGSON_PCICFG_BASE+LOONGSON_PCICFG_SIZE-1)
+#define LOONGSON_PCIIO_BASE    0x1fd00000
+#define LOONGSON_PCIIO_SIZE    0x00100000      /* 1M */
+#define LOONGSON_PCIIO_TOP     (LOONGSON_PCIIO_BASE+LOONGSON_PCIIO_SIZE-1)
+
+/* Loongson Register Bases */
+
+#define LOONGSON_PCICONFIGBASE 0x00
+#define LOONGSON_REGBASE       0x100
 
 /* PCI Configuration Registers */
-#define LOONGSON_PCI_ISR4C  BONITO_PCI_REG(0x4c)
+
+#define LOONGSON_PCI_REG(x)    LOONGSON_REG(LOONGSON_PCICONFIGBASE + (x))
+#define LOONGSON_PCIDID                LOONGSON_PCI_REG(0x00)
+#define LOONGSON_PCICMD                LOONGSON_PCI_REG(0x04)
+#define LOONGSON_PCICLASS      LOONGSON_PCI_REG(0x08)
+#define LOONGSON_PCILTIMER     LOONGSON_PCI_REG(0x0c)
+#define LOONGSON_PCIBASE0      LOONGSON_PCI_REG(0x10)
+#define LOONGSON_PCIBASE1      LOONGSON_PCI_REG(0x14)
+#define LOONGSON_PCIBASE2      LOONGSON_PCI_REG(0x18)
+#define LOONGSON_PCIBASE3      LOONGSON_PCI_REG(0x1c)
+#define LOONGSON_PCIBASE4      LOONGSON_PCI_REG(0x20)
+#define LOONGSON_PCIEXPRBASE   LOONGSON_PCI_REG(0x30)
+#define LOONGSON_PCIINT                LOONGSON_PCI_REG(0x3c)
+
+#define LOONGSON_PCI_ISR4C     LOONGSON_PCI_REG(0x4c)
+
+#define LOONGSON_PCICMD_PERR_CLR       0x80000000
+#define LOONGSON_PCICMD_SERR_CLR       0x40000000
+#define LOONGSON_PCICMD_MABORT_CLR     0x20000000
+#define LOONGSON_PCICMD_MTABORT_CLR    0x10000000
+#define LOONGSON_PCICMD_TABORT_CLR     0x08000000
+#define LOONGSON_PCICMD_MPERR_CLR      0x01000000
+#define LOONGSON_PCICMD_PERRRESPEN     0x00000040
+#define LOONGSON_PCICMD_ASTEPEN                0x00000080
+#define LOONGSON_PCICMD_SERREN         0x00000100
+#define LOONGSON_PCILTIMER_BUSLATENCY  0x0000ff00
+#define LOONGSON_PCILTIMER_BUSLATENCY_SHIFT    8
+
+/* Loongson h/w Configuration */
+
+#define LOONGSON_GENCFG_OFFSET         0x4
+#define LOONGSON_GENCFG        LOONGSON_REG(LOONGSON_REGBASE + LOONGSON_GENCFG_OFFSET)
+
+#define LOONGSON_GENCFG_DEBUGMODE      0x00000001
+#define LOONGSON_GENCFG_SNOOPEN                0x00000002
+#define LOONGSON_GENCFG_CPUSELFRESET   0x00000004
+
+#define LOONGSON_GENCFG_FORCE_IRQA     0x00000008
+#define LOONGSON_GENCFG_IRQA_ISOUT     0x00000010
+#define LOONGSON_GENCFG_IRQA_FROM_INT1 0x00000020
+#define LOONGSON_GENCFG_BYTESWAP       0x00000040
+
+#define LOONGSON_GENCFG_UNCACHED       0x00000080
+#define LOONGSON_GENCFG_PREFETCHEN     0x00000100
+#define LOONGSON_GENCFG_WBEHINDEN      0x00000200
+#define LOONGSON_GENCFG_CACHEALG       0x00000c00
+#define LOONGSON_GENCFG_CACHEALG_SHIFT 10
+#define LOONGSON_GENCFG_PCIQUEUE       0x00001000
+#define LOONGSON_GENCFG_CACHESTOP      0x00002000
+#define LOONGSON_GENCFG_MSTRBYTESWAP   0x00004000
+#define LOONGSON_GENCFG_BUSERREN       0x00008000
+#define LOONGSON_GENCFG_NORETRYTIMEOUT 0x00010000
+#define LOONGSON_GENCFG_SHORTCOPYTIMEOUT       0x00020000
+
+/* PCI address map control */
+
+#define LOONGSON_PCIMAP                        LOONGSON_REG(LOONGSON_REGBASE + 0x10)
+#define LOONGSON_PCIMEMBASECFG         LOONGSON_REG(LOONGSON_REGBASE + 0x14)
+#define LOONGSON_PCIMAP_CFG            LOONGSON_REG(LOONGSON_REGBASE + 0x18)
+
+/* GPIO Regs - r/w */
+
+#define LOONGSON_GPIODATA              LOONGSON_REG(LOONGSON_REGBASE + 0x1c)
+#define LOONGSON_GPIOIE                        LOONGSON_REG(LOONGSON_REGBASE + 0x20)
+
+/* ICU Configuration Regs - r/w */
+
+#define LOONGSON_INTEDGE               LOONGSON_REG(LOONGSON_REGBASE + 0x24)
+#define LOONGSON_INTSTEER              LOONGSON_REG(LOONGSON_REGBASE + 0x28)
+#define LOONGSON_INTPOL                        LOONGSON_REG(LOONGSON_REGBASE + 0x2c)
+
+/* ICU Enable Regs - IntEn & IntISR are r/o. */
+
+#define LOONGSON_INTENSET              LOONGSON_REG(LOONGSON_REGBASE + 0x30)
+#define LOONGSON_INTENCLR              LOONGSON_REG(LOONGSON_REGBASE + 0x34)
+#define LOONGSON_INTEN                 LOONGSON_REG(LOONGSON_REGBASE + 0x38)
+#define LOONGSON_INTISR                        LOONGSON_REG(LOONGSON_REGBASE + 0x3c)
+
+/* ICU */
+#define LOONGSON_ICU_MBOXES            0x0000000f
+#define LOONGSON_ICU_MBOXES_SHIFT      0
+#define LOONGSON_ICU_DMARDY            0x00000010
+#define LOONGSON_ICU_DMAEMPTY          0x00000020
+#define LOONGSON_ICU_COPYRDY           0x00000040
+#define LOONGSON_ICU_COPYEMPTY         0x00000080
+#define LOONGSON_ICU_COPYERR           0x00000100
+#define LOONGSON_ICU_PCIIRQ            0x00000200
+#define LOONGSON_ICU_MASTERERR         0x00000400
+#define LOONGSON_ICU_SYSTEMERR         0x00000800
+#define LOONGSON_ICU_DRAMPERR          0x00001000
+#define LOONGSON_ICU_RETRYERR          0x00002000
+#define LOONGSON_ICU_GPIOS             0x01ff0000
+#define LOONGSON_ICU_GPIOS_SHIFT               16
+#define LOONGSON_ICU_GPINS             0x7e000000
+#define LOONGSON_ICU_GPINS_SHIFT               25
+#define LOONGSON_ICU_MBOX(N)           (1<<(LOONGSON_ICU_MBOXES_SHIFT+(N)))
+#define LOONGSON_ICU_GPIO(N)           (1<<(LOONGSON_ICU_GPIOS_SHIFT+(N)))
+#define LOONGSON_ICU_GPIN(N)           (1<<(LOONGSON_ICU_GPINS_SHIFT+(N)))
+
+/* PCI prefetch window base & mask */
+
+#define LOONGSON_MEM_WIN_BASE_L        LOONGSON_REG(LOONGSON_REGBASE + 0x40)
+#define LOONGSON_MEM_WIN_BASE_H        LOONGSON_REG(LOONGSON_REGBASE + 0x44)
+#define LOONGSON_MEM_WIN_MASK_L        LOONGSON_REG(LOONGSON_REGBASE + 0x48)
+#define LOONGSON_MEM_WIN_MASK_H        LOONGSON_REG(LOONGSON_REGBASE + 0x4c)
 
 /* PCI_Hit*_Sel_* */
 
-#define LOONGSON_PCI_HIT0_SEL_L     BONITO(BONITO_REGBASE + 0x50)
-#define LOONGSON_PCI_HIT0_SEL_H     BONITO(BONITO_REGBASE + 0x54)
-#define LOONGSON_PCI_HIT1_SEL_L     BONITO(BONITO_REGBASE + 0x58)
-#define LOONGSON_PCI_HIT1_SEL_H     BONITO(BONITO_REGBASE + 0x5c)
-#define LOONGSON_PCI_HIT2_SEL_L     BONITO(BONITO_REGBASE + 0x60)
-#define LOONGSON_PCI_HIT2_SEL_H     BONITO(BONITO_REGBASE + 0x64)
+#define LOONGSON_PCI_HIT0_SEL_L                LOONGSON_REG(LOONGSON_REGBASE + 0x50)
+#define LOONGSON_PCI_HIT0_SEL_H                LOONGSON_REG(LOONGSON_REGBASE + 0x54)
+#define LOONGSON_PCI_HIT1_SEL_L                LOONGSON_REG(LOONGSON_REGBASE + 0x58)
+#define LOONGSON_PCI_HIT1_SEL_H                LOONGSON_REG(LOONGSON_REGBASE + 0x5c)
+#define LOONGSON_PCI_HIT2_SEL_L                LOONGSON_REG(LOONGSON_REGBASE + 0x60)
+#define LOONGSON_PCI_HIT2_SEL_H                LOONGSON_REG(LOONGSON_REGBASE + 0x64)
 
 /* PXArb Config & Status */
 
-#define LOONGSON_PXARB_CFG      BONITO(BONITO_REGBASE + 0x68)
-#define LOONGSON_PXARB_STATUS       BONITO(BONITO_REGBASE + 0x6c)
+#define LOONGSON_PXARB_CFG             LOONGSON_REG(LOONGSON_REGBASE + 0x68)
+#define LOONGSON_PXARB_STATUS          LOONGSON_REG(LOONGSON_REGBASE + 0x6c)
+
+/* pcimap */
+
+#define LOONGSON_PCIMAP_PCIMAP_LO0     0x0000003f
+#define LOONGSON_PCIMAP_PCIMAP_LO0_SHIFT       0
+#define LOONGSON_PCIMAP_PCIMAP_LO1     0x00000fc0
+#define LOONGSON_PCIMAP_PCIMAP_LO1_SHIFT       6
+#define LOONGSON_PCIMAP_PCIMAP_LO2     0x0003f000
+#define LOONGSON_PCIMAP_PCIMAP_LO2_SHIFT       12
+#define LOONGSON_PCIMAP_PCIMAP_2       0x00040000
+#define LOONGSON_PCIMAP_WIN(WIN, ADDR) \
+       ((((ADDR)>>26) & LOONGSON_PCIMAP_PCIMAP_LO0) << ((WIN)*6))
+
+#ifdef CONFIG_CPU_SUPPORTS_CPUFREQ
+#include <linux/cpufreq.h>
+extern void loongson2_cpu_wait(void);
+extern struct cpufreq_frequency_table loongson2_clockmod_table[];
+
+/* Chip Config */
+#define LOONGSON_CHIPCFG0              LOONGSON_REG(LOONGSON_REGBASE + 0x80)
+#endif
+
+/*
+ * address windows configuration module
+ *
+ * loongson2e do not have this module
+ */
+#ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
+
+/* address window config module base address */
+#define LOONGSON_ADDRWINCFG_BASE               0x3ff00000ul
+#define LOONGSON_ADDRWINCFG_SIZE               0x180
+
+extern unsigned long _loongson_addrwincfg_base;
+#define LOONGSON_ADDRWINCFG(offset) \
+       (*(volatile u64 *)(_loongson_addrwincfg_base + (offset)))
+
+#define CPU_WIN0_BASE  LOONGSON_ADDRWINCFG(0x00)
+#define CPU_WIN1_BASE  LOONGSON_ADDRWINCFG(0x08)
+#define CPU_WIN2_BASE  LOONGSON_ADDRWINCFG(0x10)
+#define CPU_WIN3_BASE  LOONGSON_ADDRWINCFG(0x18)
+
+#define CPU_WIN0_MASK  LOONGSON_ADDRWINCFG(0x20)
+#define CPU_WIN1_MASK  LOONGSON_ADDRWINCFG(0x28)
+#define CPU_WIN2_MASK  LOONGSON_ADDRWINCFG(0x30)
+#define CPU_WIN3_MASK  LOONGSON_ADDRWINCFG(0x38)
+
+#define CPU_WIN0_MMAP  LOONGSON_ADDRWINCFG(0x40)
+#define CPU_WIN1_MMAP  LOONGSON_ADDRWINCFG(0x48)
+#define CPU_WIN2_MMAP  LOONGSON_ADDRWINCFG(0x50)
+#define CPU_WIN3_MMAP  LOONGSON_ADDRWINCFG(0x58)
+
+#define PCIDMA_WIN0_BASE       LOONGSON_ADDRWINCFG(0x60)
+#define PCIDMA_WIN1_BASE       LOONGSON_ADDRWINCFG(0x68)
+#define PCIDMA_WIN2_BASE       LOONGSON_ADDRWINCFG(0x70)
+#define PCIDMA_WIN3_BASE       LOONGSON_ADDRWINCFG(0x78)
+
+#define PCIDMA_WIN0_MASK       LOONGSON_ADDRWINCFG(0x80)
+#define PCIDMA_WIN1_MASK       LOONGSON_ADDRWINCFG(0x88)
+#define PCIDMA_WIN2_MASK       LOONGSON_ADDRWINCFG(0x90)
+#define PCIDMA_WIN3_MASK       LOONGSON_ADDRWINCFG(0x98)
+
+#define PCIDMA_WIN0_MMAP       LOONGSON_ADDRWINCFG(0xa0)
+#define PCIDMA_WIN1_MMAP       LOONGSON_ADDRWINCFG(0xa8)
+#define PCIDMA_WIN2_MMAP       LOONGSON_ADDRWINCFG(0xb0)
+#define PCIDMA_WIN3_MMAP       LOONGSON_ADDRWINCFG(0xb8)
+
+#define ADDRWIN_WIN0   0
+#define ADDRWIN_WIN1   1
+#define ADDRWIN_WIN2   2
+#define ADDRWIN_WIN3   3
+
+#define ADDRWIN_MAP_DST_DDR    0
+#define ADDRWIN_MAP_DST_PCI    1
+#define ADDRWIN_MAP_DST_LIO    1
+
+/*
+ * s: CPU, PCIDMA
+ * d: DDR, PCI, LIO
+ * win: 0, 1, 2, 3
+ * src: map source
+ * dst: map destination
+ * size: ~mask + 1
+ */
+#define LOONGSON_ADDRWIN_CFG(s, d, w, src, dst, size) do {\
+       s##_WIN##w##_BASE = (src); \
+       s##_WIN##w##_MMAP = (src) | ADDRWIN_MAP_DST_##d; \
+       s##_WIN##w##_MASK = ~(size-1); \
+} while (0)
+
+#define LOONGSON_ADDRWIN_CPUTOPCI(win, src, dst, size) \
+       LOONGSON_ADDRWIN_CFG(CPU, PCI, win, src, dst, size)
+#define LOONGSON_ADDRWIN_CPUTODDR(win, src, dst, size) \
+       LOONGSON_ADDRWIN_CFG(CPU, DDR, win, src, dst, size)
+#define LOONGSON_ADDRWIN_PCITODDR(win, src, dst, size) \
+       LOONGSON_ADDRWIN_CFG(PCIDMA, DDR, win, src, dst, size)
 
-/* loongson2-specific perf counter IRQ */
-#define LOONGSON2_PERFCNT_IRQ   (MIPS_CPU_IRQ_BASE + 6)
+#endif /* ! CONFIG_CPU_SUPPORTS_ADDRWINCFG */
 
 #endif /* __ASM_MACH_LOONGSON_LOONGSON_H */
index 206ea20679162fe3cad0e4cd1f3e59c18c154894..acf8359cb1358cfc1e063867c191e2c74ec5cd71 100644 (file)
 
 #ifdef CONFIG_LEMOTE_FULOONG2E
 
-#define LOONGSON_UART_BASE (BONITO_PCIIO_BASE + 0x3f8)
-
 #define LOONGSON_MACHTYPE MACH_LEMOTE_FL2E
 
 #endif
 
+/* use fuloong2f as the default machine of LEMOTE_MACH2F */
+#ifdef CONFIG_LEMOTE_MACH2F
+
+#define LOONGSON_MACHTYPE MACH_LEMOTE_FL2F
+
+#endif
+
 #endif /* __ASM_MACH_LOONGSON_MACHINE_H */
index bd7b3cba7e35ba404c957628c9b0548138ac89a4..e9960f341b96f0891ec2b1d389b0cf047de87469 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Lemote, Inc. & Institute of Computing Technology
+ * Copyright (C) 2009 Lemote, Inc.
  * Author: Wu Zhangjin <wuzj@lemote.com>
  *
  * This program is free software; you can redistribute  it and/or modify it
 #define __ASM_MACH_LOONGSON_MEM_H
 
 /*
- * On Lemote Loongson 2e
+ * high memory space
  *
- * the high memory space starts from 512M.
- * the peripheral registers reside between 0x1000:0000 and 0x2000:0000.
+ * in loongson2e, starts from 512M
+ * in loongson2f, starts from 2G 256M
  */
+#ifdef CONFIG_CPU_LOONGSON2E
+#define LOONGSON_HIGHMEM_START 0x20000000
+#else
+#define LOONGSON_HIGHMEM_START 0x90000000
+#endif
 
-#ifdef CONFIG_LEMOTE_FULOONG2E
-
-#define LOONGSON_HIGHMEM_START  0x20000000
+/*
+ * the peripheral registers(MMIO):
+ *
+ * On the Lemote Loongson 2e system, reside between 0x1000:0000 and 0x2000:0000.
+ * On the Lemote Loongson 2f system, reside between 0x1000:0000 and 0x8000:0000.
+ */
 
 #define LOONGSON_MMIO_MEM_START 0x10000000
-#define LOONGSON_MMIO_MEM_END   0x20000000
 
+#ifdef CONFIG_CPU_LOONGSON2E
+#define LOONGSON_MMIO_MEM_END  0x20000000
+#else
+#define LOONGSON_MMIO_MEM_END  0x80000000
 #endif
 
 #endif /* __ASM_MACH_LOONGSON_MEM_H */
index f1663ca81da05fdbd4559885110b9ef1efdf8443..a199a4f6de4e9633b584a0fa8a388a0a6a7b1d42 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2008 Zhang Le <r0bertz@gentoo.org>
+ * Copyright (c) 2009 Wu Zhangjin <wuzj@lemote.com>
  *
  * This program is free software; you can redistribute it
  * and/or modify it under the terms of the GNU General
 #ifndef __ASM_MACH_LOONGSON_PCI_H_
 #define __ASM_MACH_LOONGSON_PCI_H_
 
-extern struct pci_ops bonito64_pci_ops;
+extern struct pci_ops loongson_pci_ops;
 
-#ifdef CONFIG_LEMOTE_FULOONG2E
+/* this is an offset from mips_io_port_base */
+#define LOONGSON_PCI_IO_START  0x00004000UL
+
+#ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
+
+/*
+ * we use address window2 to map cpu address space to pci space
+ * window2: cpu [1G, 2G] -> pci [1G, 2G]
+ * why not use window 0 & 1? because they are used by cpu when booting.
+ * window0: cpu [0, 256M] -> ddr [0, 256M]
+ * window1: cpu [256M, 512M] -> pci [256M, 512M]
+ */
+
+/* the smallest LOONGSON_CPU_MEM_SRC can be 512M */
+#define LOONGSON_CPU_MEM_SRC   0x40000000ul            /* 1G */
+#define LOONGSON_PCI_MEM_DST   LOONGSON_CPU_MEM_SRC
+
+#define LOONGSON_PCI_MEM_START LOONGSON_PCI_MEM_DST
+#define LOONGSON_PCI_MEM_END   (0x80000000ul-1)        /* 2G */
+
+#define MMAP_CPUTOPCI_SIZE     (LOONGSON_PCI_MEM_END - \
+                                       LOONGSON_PCI_MEM_START + 1)
+
+#else  /* loongson2f/32bit & loongson2e */
 
 /* this pci memory space is mapped by pcimap in pci.c */
-#define LOONGSON_PCI_MEM_START BONITO_PCILO1_BASE
-#define LOONGSON_PCI_MEM_END   (BONITO_PCILO1_BASE + 0x04000000 * 2)
+#define LOONGSON_PCI_MEM_START LOONGSON_PCILO1_BASE
+#define LOONGSON_PCI_MEM_END   (LOONGSON_PCILO1_BASE + 0x04000000 * 2)
 /* this is an offset from mips_io_port_base */
 #define LOONGSON_PCI_IO_START  0x00004000UL
 
-#endif
+#endif /* !CONFIG_CPU_SUPPORTS_ADDRWINCFG */
 
 #endif /* !__ASM_MACH_LOONGSON_PCI_H_ */
diff --git a/arch/mips/include/asm/mach-powertv/asic.h b/arch/mips/include/asm/mach-powertv/asic.h
new file mode 100644 (file)
index 0000000..bcad43a
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _ASM_MACH_POWERTV_ASIC_H
+#define _ASM_MACH_POWERTV_ASIC_H
+
+#include <linux/ioport.h>
+#include <asm/mach-powertv/asic_regs.h>
+
+#define DVR_CAPABLE     (1<<0)
+#define PCIE_CAPABLE    (1<<1)
+#define FFS_CAPABLE     (1<<2)
+#define DISPLAY_CAPABLE (1<<3)
+
+/* Platform Family types
+ * For compitability, the new value must be added in the end */
+enum family_type {
+       FAMILY_8500,
+       FAMILY_8500RNG,
+       FAMILY_4500,
+       FAMILY_1500,
+       FAMILY_8600,
+       FAMILY_4600,
+       FAMILY_4600VZA,
+       FAMILY_8600VZB,
+       FAMILY_1500VZE,
+       FAMILY_1500VZF,
+       FAMILIES
+};
+
+/* Register maps for each ASIC */
+extern const struct register_map calliope_register_map;
+extern const struct register_map cronus_register_map;
+extern const struct register_map zeus_register_map;
+
+extern struct resource dvr_cronus_resources[];
+extern struct resource dvr_zeus_resources[];
+extern struct resource non_dvr_calliope_resources[];
+extern struct resource non_dvr_cronus_resources[];
+extern struct resource non_dvr_cronuslite_resources[];
+extern struct resource non_dvr_vz_calliope_resources[];
+extern struct resource non_dvr_vze_calliope_resources[];
+extern struct resource non_dvr_vzf_calliope_resources[];
+extern struct resource non_dvr_zeus_resources[];
+
+extern void powertv_platform_init(void);
+extern void platform_alloc_bootmem(void);
+extern enum asic_type platform_get_asic(void);
+extern enum family_type platform_get_family(void);
+extern int platform_supports_dvr(void);
+extern int platform_supports_ffs(void);
+extern int platform_supports_pcie(void);
+extern int platform_supports_display(void);
+extern void configure_platform(void);
+extern void platform_configure_usb_ehci(void);
+extern void platform_unconfigure_usb_ehci(void);
+extern void platform_configure_usb_ohci(void);
+extern void platform_unconfigure_usb_ohci(void);
+
+/* Platform Resources */
+#define ASIC_RESOURCE_GET_EXISTS 1
+extern struct resource *asic_resource_get(const char *name);
+extern void platform_release_memory(void *baddr, int size);
+
+/* Reboot Cause */
+extern void set_reboot_cause(char code, unsigned int data, unsigned int data2);
+extern void set_locked_reboot_cause(char code, unsigned int data,
+       unsigned int data2);
+
+enum sys_reboot_type {
+       sys_unknown_reboot = 0x00,      /* Unknown reboot cause */
+       sys_davic_change = 0x01,        /* Reboot due to change in DAVIC
+                                        * mode */
+       sys_user_reboot = 0x02,         /* Reboot initiated by user */
+       sys_system_reboot = 0x03,       /* Reboot initiated by OS */
+       sys_trap_reboot = 0x04,         /* Reboot due to a CPU trap */
+       sys_silent_reboot = 0x05,       /* Silent reboot */
+       sys_boot_ldr_reboot = 0x06,     /* Bootloader reboot */
+       sys_power_up_reboot = 0x07,     /* Power on bootup.  Older
+                                        * drivers may report as
+                                        * userReboot. */
+       sys_code_change = 0x08,         /* Reboot to take code change.
+                                        * Older drivers may report as
+                                        * userReboot. */
+       sys_hardware_reset = 0x09,      /* HW watchdog or front-panel
+                                        * reset button reset.  Older
+                                        * drivers may report as
+                                        * userReboot. */
+       sys_watchdogInterrupt = 0x0A    /* Pre-watchdog interrupt */
+};
+
+#endif /* _ASM_MACH_POWERTV_ASIC_H */
diff --git a/arch/mips/include/asm/mach-powertv/asic_regs.h b/arch/mips/include/asm/mach-powertv/asic_regs.h
new file mode 100644 (file)
index 0000000..9a65c93
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __ASM_MACH_POWERTV_ASIC_H_
+#define __ASM_MACH_POWERTV_ASIC_H_
+#include <linux/io.h>
+
+/* ASIC types */
+enum asic_type {
+       ASIC_UNKNOWN,
+       ASIC_ZEUS,
+       ASIC_CALLIOPE,
+       ASIC_CRONUS,
+       ASIC_CRONUSLITE,
+       ASICS
+};
+
+/* hardcoded values read from Chip Version registers */
+#define CRONUS_10      0x0B4C1C20
+#define CRONUS_11      0x0B4C1C21
+#define CRONUSLITE_10  0x0B4C1C40
+
+#define NAND_FLASH_BASE        0x03000000
+#define ZEUS_IO_BASE   0x09000000
+#define CALLIOPE_IO_BASE       0x08000000
+#define CRONUS_IO_BASE 0x09000000
+#define ASIC_IO_SIZE   0x01000000
+
+/* Definitions for backward compatibility */
+#define UART1_INTSTAT  uart1_intstat
+#define UART1_INTEN    uart1_inten
+#define UART1_CONFIG1  uart1_config1
+#define UART1_CONFIG2  uart1_config2
+#define UART1_DIVISORHI        uart1_divisorhi
+#define UART1_DIVISORLO        uart1_divisorlo
+#define UART1_DATA     uart1_data
+#define UART1_STATUS   uart1_status
+
+/* ASIC register enumeration */
+struct register_map {
+       u32 eic_slow0_strt_add;
+       u32 eic_cfg_bits;
+       u32 eic_ready_status;
+
+       u32 chipver3;
+       u32 chipver2;
+       u32 chipver1;
+       u32 chipver0;
+
+       u32 uart1_intstat;
+       u32 uart1_inten;
+       u32 uart1_config1;
+       u32 uart1_config2;
+       u32 uart1_divisorhi;
+       u32 uart1_divisorlo;
+       u32 uart1_data;
+       u32 uart1_status;
+
+       u32 int_stat_3;
+       u32 int_stat_2;
+       u32 int_stat_1;
+       u32 int_stat_0;
+       u32 int_config;
+       u32 int_int_scan;
+       u32 ien_int_3;
+       u32 ien_int_2;
+       u32 ien_int_1;
+       u32 ien_int_0;
+       u32 int_level_3_3;
+       u32 int_level_3_2;
+       u32 int_level_3_1;
+       u32 int_level_3_0;
+       u32 int_level_2_3;
+       u32 int_level_2_2;
+       u32 int_level_2_1;
+       u32 int_level_2_0;
+       u32 int_level_1_3;
+       u32 int_level_1_2;
+       u32 int_level_1_1;
+       u32 int_level_1_0;
+       u32 int_level_0_3;
+       u32 int_level_0_2;
+       u32 int_level_0_1;
+       u32 int_level_0_0;
+       u32 int_docsis_en;
+
+       u32 mips_pll_setup;
+       u32 usb_fs;
+       u32 test_bus;
+       u32 crt_spare;
+       u32 usb2_ohci_int_mask;
+       u32 usb2_strap;
+       u32 ehci_hcapbase;
+       u32 ohci_hc_revision;
+       u32 bcm1_bs_lmi_steer;
+       u32 usb2_control;
+       u32 usb2_stbus_obc;
+       u32 usb2_stbus_mess_size;
+       u32 usb2_stbus_chunk_size;
+
+       u32 pcie_regs;
+       u32 tim_ch;
+       u32 tim_cl;
+       u32 gpio_dout;
+       u32 gpio_din;
+       u32 gpio_dir;
+       u32 watchdog;
+       u32 front_panel;
+
+       u32 register_maps;
+};
+
+extern enum asic_type asic;
+extern const struct register_map *register_map;
+extern unsigned long asic_phy_base;    /* Physical address of ASIC */
+extern unsigned long asic_base;                /* Virtual address of ASIC */
+
+/*
+ * Macros to interface to registers through their ioremapped address
+ * asic_reg_offset     Returns the offset of a given register from the start
+ *                     of the ASIC address space
+ * asic_reg_phys_addr  Returns the physical address of the given register
+ * asic_reg_addr       Returns the iomapped virtual address of the given
+ *                     register.
+ */
+#define asic_reg_offset(x)     (register_map->x)
+#define asic_reg_phys_addr(x)  (asic_phy_base + asic_reg_offset(x))
+#define asic_reg_addr(x) \
+       ((unsigned int *) (asic_base + asic_reg_offset(x)))
+
+/*
+ * The asic_reg macro is gone. It should be replaced by either asic_read or
+ * asic_write, as appropriate.
+ */
+
+#define asic_read(x)           readl(asic_reg_addr(x))
+#define asic_write(v, x)       writel(v, asic_reg_addr(x))
+
+extern void asic_irq_init(void);
+#endif
diff --git a/arch/mips/include/asm/mach-powertv/dma-coherence.h b/arch/mips/include/asm/mach-powertv/dma-coherence.h
new file mode 100644 (file)
index 0000000..5b8d5eb
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Version from mach-generic modified to support PowerTV port
+ * Portions Copyright (C) 2009  Cisco Systems, Inc.
+ * Copyright (C) 2006  Ralf Baechle <ralf@linux-mips.org>
+ *
+ */
+
+#ifndef __ASM_MACH_POWERTV_DMA_COHERENCE_H
+#define __ASM_MACH_POWERTV_DMA_COHERENCE_H
+
+#include <linux/sched.h>
+#include <linux/version.h>
+#include <linux/device.h>
+#include <asm/mach-powertv/asic.h>
+
+static inline bool is_kseg2(void *addr)
+{
+       return (unsigned long)addr >= KSEG2;
+}
+
+static inline unsigned long virt_to_phys_from_pte(void *addr)
+{
+       pgd_t *pgd;
+       pud_t *pud;
+       pmd_t *pmd;
+       pte_t *ptep, pte;
+
+       unsigned long virt_addr = (unsigned long)addr;
+       unsigned long phys_addr = 0UL;
+
+       /* get the page global directory. */
+       pgd = pgd_offset_k(virt_addr);
+
+       if (!pgd_none(*pgd)) {
+               /* get the page upper directory */
+               pud = pud_offset(pgd, virt_addr);
+               if (!pud_none(*pud)) {
+                       /* get the page middle directory */
+                       pmd = pmd_offset(pud, virt_addr);
+                       if (!pmd_none(*pmd)) {
+                               /* get a pointer to the page table entry */
+                               ptep = pte_offset(pmd, virt_addr);
+                               pte = *ptep;
+                               /* check for a valid page */
+                               if (pte_present(pte)) {
+                                       /* get the physical address the page is
+                                        * refering to */
+                                       phys_addr = (unsigned long)
+                                               page_to_phys(pte_page(pte));
+                                       /* add the offset within the page */
+                                       phys_addr |= (virt_addr & ~PAGE_MASK);
+                               }
+                       }
+               }
+       }
+
+       return phys_addr;
+}
+
+static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
+       size_t size)
+{
+       if (is_kseg2(addr))
+               return phys_to_bus(virt_to_phys_from_pte(addr));
+       else
+               return phys_to_bus(virt_to_phys(addr));
+}
+
+static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
+       struct page *page)
+{
+       return phys_to_bus(page_to_phys(page));
+}
+
+static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
+       dma_addr_t dma_addr)
+{
+       return bus_to_phys(dma_addr);
+}
+
+static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
+       size_t size, enum dma_data_direction direction)
+{
+}
+
+static inline int plat_dma_supported(struct device *dev, u64 mask)
+{
+       /*
+        * we fall back to GFP_DMA when the mask isn't all 1s,
+        * so we can't guarantee allocations that must be
+        * within a tighter range than GFP_DMA..
+        */
+       if (mask < DMA_BIT_MASK(24))
+               return 0;
+
+       return 1;
+}
+
+static inline void plat_extra_sync_for_device(struct device *dev)
+{
+       return;
+}
+
+static inline int plat_dma_mapping_error(struct device *dev,
+                                        dma_addr_t dma_addr)
+{
+       return 0;
+}
+
+static inline int plat_device_is_coherent(struct device *dev)
+{
+       return 0;
+}
+
+#endif /* __ASM_MACH_POWERTV_DMA_COHERENCE_H */
diff --git a/arch/mips/include/asm/mach-powertv/interrupts.h b/arch/mips/include/asm/mach-powertv/interrupts.h
new file mode 100644 (file)
index 0000000..629a574
--- /dev/null
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef        _ASM_MACH_POWERTV_INTERRUPTS_H_
+#define _ASM_MACH_POWERTV_INTERRUPTS_H_
+
+/*
+ * Defines for all of the interrupt lines
+ */
+
+/* Definitions for backward compatibility */
+#define kIrq_Uart1             irq_uart1
+
+#define ibase 0
+
+/*------------- Register: int_stat_3 */
+/* 126 unused (bit 31) */
+#define irq_asc2video          (ibase+126)     /* ASC 2 Video Interrupt */
+#define irq_asc1video          (ibase+125)     /* ASC 1 Video Interrupt */
+#define irq_comms_block_wd     (ibase+124)     /* ASC 1 Video Interrupt */
+#define irq_fdma_mailbox       (ibase+123)     /* FDMA Mailbox Output */
+#define irq_fdma_gp            (ibase+122)     /* FDMA GP Output */
+#define irq_mips_pic           (ibase+121)     /* MIPS Performance Counter
+                                                * Interrupt */
+#define irq_mips_timer         (ibase+120)     /* MIPS Timer Interrupt */
+#define irq_memory_protect     (ibase+119)     /* Memory Protection Interrupt
+                                                * -- Ored by glue logic inside
+                                                *  SPARC ILC (see
+                                                *  INT_MEM_PROT_STAT, below,
+                                                *  for individual interrupts)
+                                                */
+/* 118 unused (bit 22) */
+#define irq_sbag               (ibase+117)     /* SBAG Interrupt -- Ored by
+                                                * glue logic inside SPARC ILC
+                                                * (see INT_SBAG_STAT, below,
+                                                * for individual interrupts) */
+#define irq_qam_b_fec          (ibase+116)     /* QAM  B FEC Interrupt */
+#define irq_qam_a_fec          (ibase+115)     /* QAM A FEC Interrupt */
+/* 114 unused  (bit 18) */
+#define irq_mailbox            (ibase+113)     /* Mailbox Debug Interrupt  --
+                                                * Ored by glue logic inside
+                                                * SPARC ILC (see
+                                                * INT_MAILBOX_STAT, below, for
+                                                * individual interrupts) */
+#define irq_fuse_stat1         (ibase+112)     /* Fuse Status 1 */
+#define irq_fuse_stat2         (ibase+111)     /* Fuse Status 2 */
+#define irq_fuse_stat3         (ibase+110)     /* Blitter Interrupt / Fuse
+                                                * Status 3 */
+#define irq_blitter            (ibase+110)     /* Blitter Interrupt / Fuse
+                                                * Status 3 */
+#define irq_avc1_pp0           (ibase+109)     /* AVC Decoder #1 PP0
+                                                * Interrupt */
+#define irq_avc1_pp1           (ibase+108)     /* AVC Decoder #1 PP1
+                                                * Interrupt */
+#define irq_avc1_mbe           (ibase+107)     /* AVC Decoder #1 MBE
+                                                * Interrupt */
+#define irq_avc2_pp0           (ibase+106)     /* AVC Decoder #2 PP0
+                                                * Interrupt */
+#define irq_avc2_pp1           (ibase+105)     /* AVC Decoder #2 PP1
+                                                * Interrupt */
+#define irq_avc2_mbe           (ibase+104)     /* AVC Decoder #2 MBE
+                                                * Interrupt */
+#define irq_zbug_spi           (ibase+103)     /* Zbug SPI Slave Interrupt */
+#define irq_qam_mod2           (ibase+102)     /* QAM Modulator 2 DMA
+                                                * Interrupt */
+#define irq_ir_rx              (ibase+101)     /* IR RX 2 Interrupt */
+#define irq_aud_dsp2           (ibase+100)     /* Audio DSP #2 Interrupt */
+#define irq_aud_dsp1           (ibase+99)      /* Audio DSP #1 Interrupt */
+#define irq_docsis             (ibase+98)      /* DOCSIS Debug Interrupt */
+#define irq_sd_dvp1            (ibase+97)      /* SD DVP #1 Interrupt */
+#define irq_sd_dvp2            (ibase+96)      /* SD DVP #2 Interrupt */
+/*------------- Register: int_stat_2 */
+#define irq_hd_dvp             (ibase+95)      /* HD DVP Interrupt */
+#define kIrq_Prewatchdog       (ibase+94)      /* watchdog Pre-Interrupt */
+#define irq_timer2             (ibase+93)      /* Programmable Timer
+                                                * Interrupt 2 */
+#define irq_1394               (ibase+92)      /* 1394 Firewire Interrupt */
+#define irq_usbohci            (ibase+91)      /* USB 2.0 OHCI Interrupt */
+#define irq_usbehci            (ibase+90)      /* USB 2.0 EHCI Interrupt */
+#define irq_pciexp             (ibase+89)      /* PCI Express 0 Interrupt */
+#define irq_pciexp0            (ibase+89)      /* PCI Express 0 Interrupt */
+#define irq_afe1               (ibase+88)      /* AFE 1 Interrupt */
+#define irq_sata               (ibase+87)      /* SATA 1 Interrupt */
+#define irq_sata1              (ibase+87)      /* SATA 1 Interrupt */
+#define irq_dtcp               (ibase+86)      /* DTCP Interrupt */
+#define irq_pciexp1            (ibase+85)      /* PCI Express 1 Interrupt */
+/* 84 unused   (bit 20) */
+/* 83 unused   (bit 19) */
+/* 82 unused   (bit 18) */
+#define irq_sata2              (ibase+81)      /* SATA2 Interrupt */
+#define irq_uart2              (ibase+80)      /* UART2 Interrupt */
+#define irq_legacy_usb         (ibase+79)      /* Legacy USB Host ISR (1.1
+                                                * Host module) */
+#define irq_pod                        (ibase+78)      /* POD Interrupt */
+#define irq_slave_usb          (ibase+77)      /* Slave USB */
+#define irq_denc1              (ibase+76)      /* DENC #1 VTG Interrupt */
+#define irq_vbi_vtg            (ibase+75)      /* VBI VTG Interrupt */
+#define irq_afe2               (ibase+74)      /* AFE 2 Interrupt */
+#define irq_denc2              (ibase+73)      /* DENC #2 VTG Interrupt */
+#define irq_asc2               (ibase+72)      /* ASC #2 Interrupt */
+#define irq_asc1               (ibase+71)      /* ASC #1 Interrupt */
+#define irq_mod_dma            (ibase+70)      /* Modulator DMA Interrupt */
+#define irq_byte_eng1          (ibase+69)      /* Byte Engine Interrupt [1] */
+#define irq_byte_eng0          (ibase+68)      /* Byte Engine Interrupt [0] */
+/* 67 unused   (bit 03) */
+/* 66 unused   (bit 02) */
+/* 65 unused   (bit 01) */
+/* 64 unused   (bit 00) */
+/*------------- Register: int_stat_1 */
+/* 63 unused   (bit 31) */
+/* 62 unused   (bit 30) */
+/* 61 unused   (bit 29) */
+/* 60 unused   (bit 28) */
+/* 59 unused   (bit 27) */
+/* 58 unused   (bit 26) */
+/* 57 unused   (bit 25) */
+/* 56 unused   (bit 24) */
+#define irq_buf_dma_mem2mem    (ibase+55)      /* BufDMA Memory to Memory
+                                                * Interrupt */
+#define irq_buf_dma_usbtransmit        (ibase+54)      /* BufDMA USB Transmit
+                                                * Interrupt */
+#define irq_buf_dma_qpskpodtransmit (ibase+53) /* BufDMA QPSK/POD Tramsit
+                                                * Interrupt */
+#define irq_buf_dma_transmit_error (ibase+52)  /* BufDMA Transmit Error
+                                                * Interrupt */
+#define irq_buf_dma_usbrecv    (ibase+51)      /* BufDMA USB Receive
+                                                * Interrupt */
+#define irq_buf_dma_qpskpodrecv        (ibase+50)      /* BufDMA QPSK/POD Receive
+                                                * Interrupt */
+#define irq_buf_dma_recv_error (ibase+49)      /* BufDMA Receive Error
+                                                * Interrupt */
+#define irq_qamdma_transmit_play (ibase+48)    /* QAMDMA Transmit/Play
+                                                * Interrupt */
+#define irq_qamdma_transmit_error (ibase+47)   /* QAMDMA Transmit Error
+                                                * Interrupt */
+#define irq_qamdma_recv2high   (ibase+46)      /* QAMDMA Receive 2 High
+                                                * (Chans 63-32) */
+#define irq_qamdma_recv2low    (ibase+45)      /* QAMDMA Receive 2 Low
+                                                * (Chans 31-0) */
+#define irq_qamdma_recv1high   (ibase+44)      /* QAMDMA Receive 1 High
+                                                * (Chans 63-32) */
+#define irq_qamdma_recv1low    (ibase+43)      /* QAMDMA Receive 1 Low
+                                                * (Chans 31-0) */
+#define irq_qamdma_recv_error  (ibase+42)      /* QAMDMA Receive Error
+                                                * Interrupt */
+#define irq_mpegsplice         (ibase+41)      /* MPEG Splice Interrupt */
+#define irq_deinterlace_rdy    (ibase+40)      /* Deinterlacer Frame Ready
+                                                * Interrupt */
+#define irq_ext_in0            (ibase+39)      /* External Interrupt irq_in0 */
+#define irq_gpio3              (ibase+38)      /* GP I/O IRQ 3 - From GP I/O
+                                                * Module */
+#define irq_gpio2              (ibase+37)      /* GP I/O IRQ 2 - From GP I/O
+                                                * Module (ABE_intN) */
+#define irq_pcrcmplt1          (ibase+36)      /* PCR Capture Complete  or
+                                                * Discontinuity 1 */
+#define irq_pcrcmplt2          (ibase+35)      /* PCR Capture Complete or
+                                                * Discontinuity 2 */
+#define irq_parse_peierr       (ibase+34)      /* PID Parser Error Detect
+                                                * (PEI) */
+#define irq_parse_cont_err     (ibase+33)      /* PID Parser continuity error
+                                                * detect */
+#define irq_ds1framer          (ibase+32)      /* DS1 Framer Interrupt */
+/*------------- Register: int_stat_0 */
+#define irq_gpio1              (ibase+31)      /* GP I/O IRQ 1 - From GP I/O
+                                                * Module */
+#define irq_gpio0              (ibase+30)      /* GP I/O IRQ 0 - From GP I/O
+                                                * Module */
+#define irq_qpsk_out_aloha     (ibase+29)      /* QPSK Output Slotted Aloha
+                                                * (chan 3) Transmission
+                                                * Completed OK */
+#define irq_qpsk_out_tdma      (ibase+28)      /* QPSK Output TDMA (chan 2)
+                                                * Transmission Completed OK */
+#define irq_qpsk_out_reserve   (ibase+27)      /* QPSK Output Reservation
+                                                * (chan 1) Transmission
+                                                * Completed OK */
+#define irq_qpsk_out_aloha_err (ibase+26)      /* QPSK Output Slotted Aloha
+                                                * (chan 3)Transmission
+                                                * completed with Errors. */
+#define irq_qpsk_out_tdma_err  (ibase+25)      /* QPSK Output TDMA (chan 2)
+                                                * Transmission completed with
+                                                * Errors. */
+#define irq_qpsk_out_rsrv_err  (ibase+24)      /* QPSK Output Reservation
+                                                * (chan 1) Transmission
+                                                * completed with Errors */
+#define irq_aloha_fail         (ibase+23)      /* Unsuccessful Resend of Aloha
+                                                * for N times. Aloha retry
+                                                * timeout for channel 3. */
+#define irq_timer1             (ibase+22)      /* Programmable Timer
+                                                * Interrupt */
+#define irq_keyboard           (ibase+21)      /* Keyboard Module Interrupt */
+#define irq_i2c                        (ibase+20)      /* I2C Module Interrupt */
+#define irq_spi                        (ibase+19)      /* SPI Module Interrupt */
+#define irq_irblaster          (ibase+18)      /* IR Blaster Interrupt */
+#define irq_splice_detect      (ibase+17)      /* PID Key Change Interrupt or
+                                                * Splice Detect Interrupt */
+#define irq_se_micro           (ibase+16)      /* Secure Micro I/F Module
+                                                * Interrupt */
+#define irq_uart1              (ibase+15)      /* UART Interrupt */
+#define irq_irrecv             (ibase+14)      /* IR Receiver Interrupt */
+#define irq_host_int1          (ibase+13)      /* Host-to-Host Interrupt 1 */
+#define irq_host_int0          (ibase+12)      /* Host-to-Host Interrupt 0 */
+#define irq_qpsk_hecerr                (ibase+11)      /* QPSK HEC Error Interrupt */
+#define irq_qpsk_crcerr                (ibase+10)      /* QPSK AAL-5 CRC Error
+                                                * Interrupt */
+/* 9 unused    (bit 09) */
+/* 8 unused    (bit 08) */
+#define irq_psicrcerr          (ibase+7)       /* QAM PSI CRC Error
+                                                * Interrupt */
+#define irq_psilength_err      (ibase+6)       /* QAM PSI Length Error
+                                                * Interrupt */
+#define irq_esfforward         (ibase+5)       /* ESF Interrupt Mark From
+                                                * Forward Path Reference -
+                                                * every 3ms when forward Mbits
+                                                * and forward slot control
+                                                * bytes are updated. */
+#define irq_esfreverse         (ibase+4)       /* ESF Interrupt Mark from
+                                                * Reverse Path Reference -
+                                                * delayed from forward mark by
+                                                * the ranging delay plus a
+                                                * fixed amount. When reverse
+                                                * Mbits and reverse slot
+                                                * control bytes are updated.
+                                                * Occurs every 3ms for 3.0M and
+                                                * 1.554 M upstream rates and
+                                                * every 6 ms for 256K upstream
+                                                * rate. */
+#define irq_aloha_timeout      (ibase+3)       /* Slotted-Aloha timeout on
+                                                * Channel 1. */
+#define irq_reservation                (ibase+2)       /* Partial (or Incremental)
+                                                * Reservation Message Completed
+                                                * or Slotted aloha verify for
+                                                * channel 1. */
+#define irq_aloha3             (ibase+1)       /* Slotted-Aloha Message Verify
+                                                * Interrupt or Reservation
+                                                * increment completed for
+                                                * channel 3. */
+#define irq_mpeg_d             (ibase+0)       /* MPEG Decoder Interrupt */
+#endif /* _ASM_MACH_POWERTV_INTERRUPTS_H_ */
+
diff --git a/arch/mips/include/asm/mach-powertv/ioremap.h b/arch/mips/include/asm/mach-powertv/ioremap.h
new file mode 100644 (file)
index 0000000..e6276d5
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License
+ *     as published by the Free Software Foundation; either version
+ *     2 of the License, or (at your option) any later version.
+ *
+ * Portions Copyright (C)  Cisco Systems, Inc.
+ */
+#ifndef __ASM_MACH_POWERTV_IOREMAP_H
+#define __ASM_MACH_POWERTV_IOREMAP_H
+
+#include <linux/types.h>
+
+#define LOW_MEM_BOUNDARY_PHYS  0x20000000
+#define LOW_MEM_BOUNDARY_MASK  (~(LOW_MEM_BOUNDARY_PHYS - 1))
+
+/*
+ * The bus addresses are different than the physical addresses that
+ * the processor sees by an offset. This offset varies by ASIC
+ * version. Define a variable to hold the offset and some macros to
+ * make the conversion simpler. */
+extern unsigned long phys_to_bus_offset;
+
+#ifdef CONFIG_HIGHMEM
+#define MEM_GAP_PHYS           0x60000000
+/*
+ * TODO: We will use the hard code for conversion between physical and
+ * bus until the bootloader releases their device tree to us.
+ */
+#define phys_to_bus(x) (((x) < LOW_MEM_BOUNDARY_PHYS) ? \
+       ((x) + phys_to_bus_offset) : (x))
+#define bus_to_phys(x) (((x) < MEM_GAP_PHYS_ADDR) ? \
+       ((x) - phys_to_bus_offset) : (x))
+#else
+#define phys_to_bus(x) ((x) + phys_to_bus_offset)
+#define bus_to_phys(x) ((x) - phys_to_bus_offset)
+#endif
+
+/*
+ * Determine whether the address we are given is for an ASIC device
+ * Params:  addr    Address to check
+ * Returns: Zero if the address is not for ASIC devices, non-zero
+ *      if it is.
+ */
+static inline int asic_is_device_addr(phys_t addr)
+{
+       return !((phys_t)addr & (phys_t) LOW_MEM_BOUNDARY_MASK);
+}
+
+/*
+ * Determine whether the address we are given is external RAM mappable
+ * into KSEG1.
+ * Params:  addr    Address to check
+ * Returns: Zero if the address is not for external RAM and
+ */
+static inline int asic_is_lowmem_ram_addr(phys_t addr)
+{
+       /*
+        * The RAM always starts at the following address in the processor's
+        * physical address space
+        */
+       static const phys_t phys_ram_base = 0x10000000;
+       phys_t bus_ram_base;
+
+       bus_ram_base = phys_to_bus_offset + phys_ram_base;
+
+       return addr >= bus_ram_base &&
+               addr < (bus_ram_base + (LOW_MEM_BOUNDARY_PHYS - phys_ram_base));
+}
+
+/*
+ * Allow physical addresses to be fixed up to help peripherals located
+ * outside the low 32-bit range -- generic pass-through version.
+ */
+static inline phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
+{
+       return phys_addr;
+}
+
+static inline void __iomem *plat_ioremap(phys_t offset, unsigned long size,
+       unsigned long flags)
+{
+       return NULL;
+}
+
+static inline int plat_iounmap(const volatile void __iomem *addr)
+{
+       return 0;
+}
+#endif /* __ASM_MACH_POWERTV_IOREMAP_H */
diff --git a/arch/mips/include/asm/mach-powertv/irq.h b/arch/mips/include/asm/mach-powertv/irq.h
new file mode 100644 (file)
index 0000000..4bd5d0c
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _ASM_MACH_POWERTV_IRQ_H
+#define _ASM_MACH_POWERTV_IRQ_H
+#include <asm/mach-powertv/interrupts.h>
+
+#define MIPS_CPU_IRQ_BASE      ibase
+#define NR_IRQS                        127
+#endif
diff --git a/arch/mips/include/asm/mach-powertv/powertv-clock.h b/arch/mips/include/asm/mach-powertv/powertv-clock.h
new file mode 100644 (file)
index 0000000..6f3e9a0
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+/*
+ * Local definitions for the powertv PCI code
+ */
+
+#ifndef _POWERTV_PCI_POWERTV_PCI_H_
+#define _POWERTV_PCI_POWERTV_PCI_H_
+extern int asic_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
+extern int asic_pcie_init(void);
+extern int asic_pcie_init(void);
+
+extern int log_level;
+#endif
similarity index 56%
rename from arch/mips/include/asm/mach-excite/war.h
rename to arch/mips/include/asm/mach-powertv/war.h
index 1f82180c1598448c411bd5e882c612e70719941e..7ac05ecc512be2fd0cb9dea3e7fc2c8800972733 100644 (file)
@@ -3,10 +3,13 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
+ * This version for the PowerTV platform copied from the Malta version.
+ *
  * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
+ * Portions copyright (C) 2009 Cisco Systems, Inc.
  */
-#ifndef __ASM_MIPS_MACH_EXCITE_WAR_H
-#define __ASM_MIPS_MACH_EXCITE_WAR_H
+#ifndef __ASM_MACH_POWERTV_WAR_H
+#define __ASM_MACH_POWERTV_WAR_H
 
 #define R4600_V1_INDEX_ICACHEOP_WAR    0
 #define R4600_V1_HIT_CACHEOP_WAR       0
 #define R5432_CP0_INTERRUPT_WAR                0
 #define BCM1250_M3_WAR                 0
 #define SIBYTE_1956_WAR                        0
-#define MIPS4K_ICACHE_REFILL_WAR       0
-#define MIPS_CACHE_SYNC_WAR            0
+#define MIPS4K_ICACHE_REFILL_WAR       1
+#define MIPS_CACHE_SYNC_WAR            1
 #define TX49XX_ICACHE_INDEX_INV_WAR    0
-#define RM9000_CDEX_SMP_WAR            1
-#define ICACHE_REFILLS_WORKAROUND_WAR   1
+#define RM9000_CDEX_SMP_WAR            0
+#define ICACHE_REFILLS_WORKAROUND_WAR  1
 #define R10000_LLSC_WAR                        0
-#define MIPS34K_MISSED_ITLB_WAR        0
+#define MIPS34K_MISSED_ITLB_WAR                0
 
-#endif /* __ASM_MIPS_MACH_EXCITE_WAR_H */
+#endif /* __ASM_MACH_POWERTV_WAR_H */
index a576ce044c3c7ca845dedd4975a8dfef40a3b259..d14e2adc4be5c8d26d42ec9076f690d9f4e1e0a7 100644 (file)
 /* offsets from base register */
 #define BONITO(x)      (x)
 
-#elif defined(CONFIG_LEMOTE_FULOONG2E)
-
-#define BONITO(x) (*(volatile u32 *)((char *)CKSEG1ADDR(BONITO_REG_BASE) + (x)))
-#define BONITO_IRQ_BASE   32
-
 #else
 
 /*
index 6083db586500ba14e22f94acab819f40e13a158f..145bb81ccaa5094efec3806568f7fbb1087031f1 100644 (file)
 #endif /* SMTC */
 #include <asm-generic/mm_hooks.h>
 
+#ifdef CONFIG_MIPS_PGD_C0_CONTEXT
+
+#define TLBMISS_HANDLER_SETUP_PGD(pgd)                         \
+       tlbmiss_handler_setup_pgd((unsigned long)(pgd))
+
+static inline void tlbmiss_handler_setup_pgd(unsigned long pgd)
+{
+       /* Check for swapper_pg_dir and convert to physical address. */
+       if ((pgd & CKSEG3) == CKSEG0)
+               pgd = CPHYSADDR(pgd);
+       write_c0_context(pgd << 11);
+}
+
+#define TLBMISS_HANDLER_SETUP()                                                \
+       do {                                                            \
+               TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir);              \
+               write_c0_xcontext((unsigned long) smp_processor_id() << 51); \
+       } while (0)
+
+
+static inline unsigned long get_current_pgd(void)
+{
+       return PHYS_TO_XKSEG_CACHED((read_c0_context() >> 11) & ~0xfffUL);
+}
+
+#else /* CONFIG_MIPS_PGD_C0_CONTEXT: using  pgd_current*/
+
 /*
  * For the fast tlb miss handlers, we keep a per cpu array of pointers
  * to the current pgd for each processor. Also, the proc. id is stuffed
@@ -46,7 +73,7 @@ extern unsigned long pgd_current[];
        back_to_back_c0_hazard();                                       \
        TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
 #endif
-
+#endif /* CONFIG_MIPS_PGD_C0_CONTEXT*/
 #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
 
 #define ASID_INC       0x40
diff --git a/arch/mips/include/asm/octeon/cvmx-agl-defs.h b/arch/mips/include/asm/octeon/cvmx-agl-defs.h
new file mode 100644 (file)
index 0000000..ec94b9a
--- /dev/null
@@ -0,0 +1,1194 @@
+/***********************license start***************
+ * Author: Cavium Networks
+ *
+ * Contact: support@caviumnetworks.com
+ * This file is part of the OCTEON SDK
+ *
+ * Copyright (c) 2003-2008 Cavium Networks
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
+ * NONINFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this file; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * or visit http://www.gnu.org/licenses/.
+ *
+ * This file may also be available under a different license from Cavium.
+ * Contact Cavium Networks for more information
+ ***********************license end**************************************/
+
+#ifndef __CVMX_AGL_DEFS_H__
+#define __CVMX_AGL_DEFS_H__
+
+#define CVMX_AGL_GMX_BAD_REG \
+        CVMX_ADD_IO_SEG(0x00011800E0000518ull)
+#define CVMX_AGL_GMX_BIST \
+        CVMX_ADD_IO_SEG(0x00011800E0000400ull)
+#define CVMX_AGL_GMX_DRV_CTL \
+        CVMX_ADD_IO_SEG(0x00011800E00007F0ull)
+#define CVMX_AGL_GMX_INF_MODE \
+        CVMX_ADD_IO_SEG(0x00011800E00007F8ull)
+#define CVMX_AGL_GMX_PRTX_CFG(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000010ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_ADR_CAM0(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000180ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_ADR_CAM1(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000188ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_ADR_CAM2(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000190ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_ADR_CAM3(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000198ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_ADR_CAM4(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00001A0ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_ADR_CAM5(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00001A8ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_ADR_CAM_EN(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000108ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_ADR_CTL(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000100ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_DECISION(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000040ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_FRM_CHK(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000020ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_FRM_CTL(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000018ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_FRM_MAX(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000030ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_FRM_MIN(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000028ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_IFG(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000058ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_INT_EN(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000008ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_INT_REG(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000000ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_JABBER(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000038ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_PAUSE_DROP_TIME(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000068ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_CTL(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000050ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_OCTS(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000088ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_OCTS_CTL(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000098ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_OCTS_DMAC(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00000A8ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_OCTS_DRP(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00000B8ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_PKTS(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000080ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00000C0ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_PKTS_CTL(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000090ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_PKTS_DMAC(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00000A0ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00000B0ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RXX_UDD_SKP(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000048ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_RX_BP_DROPX(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000420ull + (((offset) & 1) * 8))
+#define CVMX_AGL_GMX_RX_BP_OFFX(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000460ull + (((offset) & 1) * 8))
+#define CVMX_AGL_GMX_RX_BP_ONX(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000440ull + (((offset) & 1) * 8))
+#define CVMX_AGL_GMX_RX_PRT_INFO \
+        CVMX_ADD_IO_SEG(0x00011800E00004E8ull)
+#define CVMX_AGL_GMX_RX_TX_STATUS \
+        CVMX_ADD_IO_SEG(0x00011800E00007E8ull)
+#define CVMX_AGL_GMX_SMACX(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000230ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_STAT_BP \
+        CVMX_ADD_IO_SEG(0x00011800E0000520ull)
+#define CVMX_AGL_GMX_TXX_APPEND(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000218ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_CTL(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000270ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_MIN_PKT(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000240ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_PAUSE_PKT_INTERVAL(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000248ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_PAUSE_PKT_TIME(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000238ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_PAUSE_TOGO(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000258ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_PAUSE_ZERO(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000260ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_SOFT_PAUSE(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000250ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT0(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000280ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT1(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000288ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT2(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000290ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT3(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000298ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT4(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00002A0ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT5(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00002A8ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT6(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00002B0ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT7(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00002B8ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT8(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00002C0ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STAT9(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E00002C8ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_STATS_CTL(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000268ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TXX_THRESH(offset) \
+        CVMX_ADD_IO_SEG(0x00011800E0000210ull + (((offset) & 1) * 2048))
+#define CVMX_AGL_GMX_TX_BP \
+        CVMX_ADD_IO_SEG(0x00011800E00004D0ull)
+#define CVMX_AGL_GMX_TX_COL_ATTEMPT \
+        CVMX_ADD_IO_SEG(0x00011800E0000498ull)
+#define CVMX_AGL_GMX_TX_IFG \
+        CVMX_ADD_IO_SEG(0x00011800E0000488ull)
+#define CVMX_AGL_GMX_TX_INT_EN \
+        CVMX_ADD_IO_SEG(0x00011800E0000508ull)
+#define CVMX_AGL_GMX_TX_INT_REG \
+        CVMX_ADD_IO_SEG(0x00011800E0000500ull)
+#define CVMX_AGL_GMX_TX_JAM \
+        CVMX_ADD_IO_SEG(0x00011800E0000490ull)
+#define CVMX_AGL_GMX_TX_LFSR \
+        CVMX_ADD_IO_SEG(0x00011800E00004F8ull)
+#define CVMX_AGL_GMX_TX_OVR_BP \
+        CVMX_ADD_IO_SEG(0x00011800E00004C8ull)
+#define CVMX_AGL_GMX_TX_PAUSE_PKT_DMAC \
+        CVMX_ADD_IO_SEG(0x00011800E00004A0ull)
+#define CVMX_AGL_GMX_TX_PAUSE_PKT_TYPE \
+        CVMX_ADD_IO_SEG(0x00011800E00004A8ull)
+
+union cvmx_agl_gmx_bad_reg {
+       uint64_t u64;
+       struct cvmx_agl_gmx_bad_reg_s {
+               uint64_t reserved_38_63:26;
+               uint64_t txpsh1:1;
+               uint64_t txpop1:1;
+               uint64_t ovrflw1:1;
+               uint64_t txpsh:1;
+               uint64_t txpop:1;
+               uint64_t ovrflw:1;
+               uint64_t reserved_27_31:5;
+               uint64_t statovr:1;
+               uint64_t reserved_23_25:3;
+               uint64_t loststat:1;
+               uint64_t reserved_4_21:18;
+               uint64_t out_ovr:2;
+               uint64_t reserved_0_1:2;
+       } s;
+       struct cvmx_agl_gmx_bad_reg_s cn52xx;
+       struct cvmx_agl_gmx_bad_reg_s cn52xxp1;
+       struct cvmx_agl_gmx_bad_reg_cn56xx {
+               uint64_t reserved_35_63:29;
+               uint64_t txpsh:1;
+               uint64_t txpop:1;
+               uint64_t ovrflw:1;
+               uint64_t reserved_27_31:5;
+               uint64_t statovr:1;
+               uint64_t reserved_23_25:3;
+               uint64_t loststat:1;
+               uint64_t reserved_3_21:19;
+               uint64_t out_ovr:1;
+               uint64_t reserved_0_1:2;
+       } cn56xx;
+       struct cvmx_agl_gmx_bad_reg_cn56xx cn56xxp1;
+};
+
+union cvmx_agl_gmx_bist {
+       uint64_t u64;
+       struct cvmx_agl_gmx_bist_s {
+               uint64_t reserved_10_63:54;
+               uint64_t status:10;
+       } s;
+       struct cvmx_agl_gmx_bist_s cn52xx;
+       struct cvmx_agl_gmx_bist_s cn52xxp1;
+       struct cvmx_agl_gmx_bist_s cn56xx;
+       struct cvmx_agl_gmx_bist_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_drv_ctl {
+       uint64_t u64;
+       struct cvmx_agl_gmx_drv_ctl_s {
+               uint64_t reserved_49_63:15;
+               uint64_t byp_en1:1;
+               uint64_t reserved_45_47:3;
+               uint64_t pctl1:5;
+               uint64_t reserved_37_39:3;
+               uint64_t nctl1:5;
+               uint64_t reserved_17_31:15;
+               uint64_t byp_en:1;
+               uint64_t reserved_13_15:3;
+               uint64_t pctl:5;
+               uint64_t reserved_5_7:3;
+               uint64_t nctl:5;
+       } s;
+       struct cvmx_agl_gmx_drv_ctl_s cn52xx;
+       struct cvmx_agl_gmx_drv_ctl_s cn52xxp1;
+       struct cvmx_agl_gmx_drv_ctl_cn56xx {
+               uint64_t reserved_17_63:47;
+               uint64_t byp_en:1;
+               uint64_t reserved_13_15:3;
+               uint64_t pctl:5;
+               uint64_t reserved_5_7:3;
+               uint64_t nctl:5;
+       } cn56xx;
+       struct cvmx_agl_gmx_drv_ctl_cn56xx cn56xxp1;
+};
+
+union cvmx_agl_gmx_inf_mode {
+       uint64_t u64;
+       struct cvmx_agl_gmx_inf_mode_s {
+               uint64_t reserved_2_63:62;
+               uint64_t en:1;
+               uint64_t reserved_0_0:1;
+       } s;
+       struct cvmx_agl_gmx_inf_mode_s cn52xx;
+       struct cvmx_agl_gmx_inf_mode_s cn52xxp1;
+       struct cvmx_agl_gmx_inf_mode_s cn56xx;
+       struct cvmx_agl_gmx_inf_mode_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_prtx_cfg {
+       uint64_t u64;
+       struct cvmx_agl_gmx_prtx_cfg_s {
+               uint64_t reserved_6_63:58;
+               uint64_t tx_en:1;
+               uint64_t rx_en:1;
+               uint64_t slottime:1;
+               uint64_t duplex:1;
+               uint64_t speed:1;
+               uint64_t en:1;
+       } s;
+       struct cvmx_agl_gmx_prtx_cfg_s cn52xx;
+       struct cvmx_agl_gmx_prtx_cfg_s cn52xxp1;
+       struct cvmx_agl_gmx_prtx_cfg_s cn56xx;
+       struct cvmx_agl_gmx_prtx_cfg_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_adr_cam0 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_adr_cam0_s {
+               uint64_t adr:64;
+       } s;
+       struct cvmx_agl_gmx_rxx_adr_cam0_s cn52xx;
+       struct cvmx_agl_gmx_rxx_adr_cam0_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_adr_cam0_s cn56xx;
+       struct cvmx_agl_gmx_rxx_adr_cam0_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_adr_cam1 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_adr_cam1_s {
+               uint64_t adr:64;
+       } s;
+       struct cvmx_agl_gmx_rxx_adr_cam1_s cn52xx;
+       struct cvmx_agl_gmx_rxx_adr_cam1_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_adr_cam1_s cn56xx;
+       struct cvmx_agl_gmx_rxx_adr_cam1_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_adr_cam2 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_adr_cam2_s {
+               uint64_t adr:64;
+       } s;
+       struct cvmx_agl_gmx_rxx_adr_cam2_s cn52xx;
+       struct cvmx_agl_gmx_rxx_adr_cam2_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_adr_cam2_s cn56xx;
+       struct cvmx_agl_gmx_rxx_adr_cam2_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_adr_cam3 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_adr_cam3_s {
+               uint64_t adr:64;
+       } s;
+       struct cvmx_agl_gmx_rxx_adr_cam3_s cn52xx;
+       struct cvmx_agl_gmx_rxx_adr_cam3_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_adr_cam3_s cn56xx;
+       struct cvmx_agl_gmx_rxx_adr_cam3_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_adr_cam4 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_adr_cam4_s {
+               uint64_t adr:64;
+       } s;
+       struct cvmx_agl_gmx_rxx_adr_cam4_s cn52xx;
+       struct cvmx_agl_gmx_rxx_adr_cam4_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_adr_cam4_s cn56xx;
+       struct cvmx_agl_gmx_rxx_adr_cam4_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_adr_cam5 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_adr_cam5_s {
+               uint64_t adr:64;
+       } s;
+       struct cvmx_agl_gmx_rxx_adr_cam5_s cn52xx;
+       struct cvmx_agl_gmx_rxx_adr_cam5_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_adr_cam5_s cn56xx;
+       struct cvmx_agl_gmx_rxx_adr_cam5_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_adr_cam_en {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_adr_cam_en_s {
+               uint64_t reserved_8_63:56;
+               uint64_t en:8;
+       } s;
+       struct cvmx_agl_gmx_rxx_adr_cam_en_s cn52xx;
+       struct cvmx_agl_gmx_rxx_adr_cam_en_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_adr_cam_en_s cn56xx;
+       struct cvmx_agl_gmx_rxx_adr_cam_en_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_adr_ctl {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_adr_ctl_s {
+               uint64_t reserved_4_63:60;
+               uint64_t cam_mode:1;
+               uint64_t mcst:2;
+               uint64_t bcst:1;
+       } s;
+       struct cvmx_agl_gmx_rxx_adr_ctl_s cn52xx;
+       struct cvmx_agl_gmx_rxx_adr_ctl_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_adr_ctl_s cn56xx;
+       struct cvmx_agl_gmx_rxx_adr_ctl_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_decision {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_decision_s {
+               uint64_t reserved_5_63:59;
+               uint64_t cnt:5;
+       } s;
+       struct cvmx_agl_gmx_rxx_decision_s cn52xx;
+       struct cvmx_agl_gmx_rxx_decision_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_decision_s cn56xx;
+       struct cvmx_agl_gmx_rxx_decision_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_frm_chk {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_frm_chk_s {
+               uint64_t reserved_9_63:55;
+               uint64_t skperr:1;
+               uint64_t rcverr:1;
+               uint64_t lenerr:1;
+               uint64_t alnerr:1;
+               uint64_t fcserr:1;
+               uint64_t jabber:1;
+               uint64_t maxerr:1;
+               uint64_t reserved_1_1:1;
+               uint64_t minerr:1;
+       } s;
+       struct cvmx_agl_gmx_rxx_frm_chk_s cn52xx;
+       struct cvmx_agl_gmx_rxx_frm_chk_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_frm_chk_s cn56xx;
+       struct cvmx_agl_gmx_rxx_frm_chk_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_frm_ctl {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_frm_ctl_s {
+               uint64_t reserved_10_63:54;
+               uint64_t pre_align:1;
+               uint64_t pad_len:1;
+               uint64_t vlan_len:1;
+               uint64_t pre_free:1;
+               uint64_t ctl_smac:1;
+               uint64_t ctl_mcst:1;
+               uint64_t ctl_bck:1;
+               uint64_t ctl_drp:1;
+               uint64_t pre_strp:1;
+               uint64_t pre_chk:1;
+       } s;
+       struct cvmx_agl_gmx_rxx_frm_ctl_s cn52xx;
+       struct cvmx_agl_gmx_rxx_frm_ctl_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_frm_ctl_s cn56xx;
+       struct cvmx_agl_gmx_rxx_frm_ctl_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_frm_max {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_frm_max_s {
+               uint64_t reserved_16_63:48;
+               uint64_t len:16;
+       } s;
+       struct cvmx_agl_gmx_rxx_frm_max_s cn52xx;
+       struct cvmx_agl_gmx_rxx_frm_max_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_frm_max_s cn56xx;
+       struct cvmx_agl_gmx_rxx_frm_max_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_frm_min {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_frm_min_s {
+               uint64_t reserved_16_63:48;
+               uint64_t len:16;
+       } s;
+       struct cvmx_agl_gmx_rxx_frm_min_s cn52xx;
+       struct cvmx_agl_gmx_rxx_frm_min_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_frm_min_s cn56xx;
+       struct cvmx_agl_gmx_rxx_frm_min_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_ifg {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_ifg_s {
+               uint64_t reserved_4_63:60;
+               uint64_t ifg:4;
+       } s;
+       struct cvmx_agl_gmx_rxx_ifg_s cn52xx;
+       struct cvmx_agl_gmx_rxx_ifg_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_ifg_s cn56xx;
+       struct cvmx_agl_gmx_rxx_ifg_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_int_en {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_int_en_s {
+               uint64_t reserved_20_63:44;
+               uint64_t pause_drp:1;
+               uint64_t reserved_16_18:3;
+               uint64_t ifgerr:1;
+               uint64_t coldet:1;
+               uint64_t falerr:1;
+               uint64_t rsverr:1;
+               uint64_t pcterr:1;
+               uint64_t ovrerr:1;
+               uint64_t reserved_9_9:1;
+               uint64_t skperr:1;
+               uint64_t rcverr:1;
+               uint64_t lenerr:1;
+               uint64_t alnerr:1;
+               uint64_t fcserr:1;
+               uint64_t jabber:1;
+               uint64_t maxerr:1;
+               uint64_t reserved_1_1:1;
+               uint64_t minerr:1;
+       } s;
+       struct cvmx_agl_gmx_rxx_int_en_s cn52xx;
+       struct cvmx_agl_gmx_rxx_int_en_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_int_en_s cn56xx;
+       struct cvmx_agl_gmx_rxx_int_en_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_int_reg {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_int_reg_s {
+               uint64_t reserved_20_63:44;
+               uint64_t pause_drp:1;
+               uint64_t reserved_16_18:3;
+               uint64_t ifgerr:1;
+               uint64_t coldet:1;
+               uint64_t falerr:1;
+               uint64_t rsverr:1;
+               uint64_t pcterr:1;
+               uint64_t ovrerr:1;
+               uint64_t reserved_9_9:1;
+               uint64_t skperr:1;
+               uint64_t rcverr:1;
+               uint64_t lenerr:1;
+               uint64_t alnerr:1;
+               uint64_t fcserr:1;
+               uint64_t jabber:1;
+               uint64_t maxerr:1;
+               uint64_t reserved_1_1:1;
+               uint64_t minerr:1;
+       } s;
+       struct cvmx_agl_gmx_rxx_int_reg_s cn52xx;
+       struct cvmx_agl_gmx_rxx_int_reg_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_int_reg_s cn56xx;
+       struct cvmx_agl_gmx_rxx_int_reg_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_jabber {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_jabber_s {
+               uint64_t reserved_16_63:48;
+               uint64_t cnt:16;
+       } s;
+       struct cvmx_agl_gmx_rxx_jabber_s cn52xx;
+       struct cvmx_agl_gmx_rxx_jabber_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_jabber_s cn56xx;
+       struct cvmx_agl_gmx_rxx_jabber_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_pause_drop_time {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_pause_drop_time_s {
+               uint64_t reserved_16_63:48;
+               uint64_t status:16;
+       } s;
+       struct cvmx_agl_gmx_rxx_pause_drop_time_s cn52xx;
+       struct cvmx_agl_gmx_rxx_pause_drop_time_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_pause_drop_time_s cn56xx;
+       struct cvmx_agl_gmx_rxx_pause_drop_time_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_ctl {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_ctl_s {
+               uint64_t reserved_1_63:63;
+               uint64_t rd_clr:1;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_ctl_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_ctl_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_ctl_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_ctl_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_octs {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_octs_s {
+               uint64_t reserved_48_63:16;
+               uint64_t cnt:48;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_octs_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_octs_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_octs_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_octs_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_octs_ctl {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_octs_ctl_s {
+               uint64_t reserved_48_63:16;
+               uint64_t cnt:48;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_octs_ctl_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_octs_dmac {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_octs_dmac_s {
+               uint64_t reserved_48_63:16;
+               uint64_t cnt:48;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_octs_dmac_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_octs_drp {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_octs_drp_s {
+               uint64_t reserved_48_63:16;
+               uint64_t cnt:48;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_octs_drp_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_pkts {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_pkts_s {
+               uint64_t reserved_32_63:32;
+               uint64_t cnt:32;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_pkts_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_pkts_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_pkts_bad {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_pkts_bad_s {
+               uint64_t reserved_32_63:32;
+               uint64_t cnt:32;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_bad_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_pkts_ctl {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s {
+               uint64_t reserved_32_63:32;
+               uint64_t cnt:32;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_ctl_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_pkts_dmac {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s {
+               uint64_t reserved_32_63:32;
+               uint64_t cnt:32;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_dmac_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_stats_pkts_drp {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_stats_pkts_drp_s {
+               uint64_t reserved_32_63:32;
+               uint64_t cnt:32;
+       } s;
+       struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn52xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn56xx;
+       struct cvmx_agl_gmx_rxx_stats_pkts_drp_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rxx_udd_skp {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rxx_udd_skp_s {
+               uint64_t reserved_9_63:55;
+               uint64_t fcssel:1;
+               uint64_t reserved_7_7:1;
+               uint64_t len:7;
+       } s;
+       struct cvmx_agl_gmx_rxx_udd_skp_s cn52xx;
+       struct cvmx_agl_gmx_rxx_udd_skp_s cn52xxp1;
+       struct cvmx_agl_gmx_rxx_udd_skp_s cn56xx;
+       struct cvmx_agl_gmx_rxx_udd_skp_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rx_bp_dropx {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rx_bp_dropx_s {
+               uint64_t reserved_6_63:58;
+               uint64_t mark:6;
+       } s;
+       struct cvmx_agl_gmx_rx_bp_dropx_s cn52xx;
+       struct cvmx_agl_gmx_rx_bp_dropx_s cn52xxp1;
+       struct cvmx_agl_gmx_rx_bp_dropx_s cn56xx;
+       struct cvmx_agl_gmx_rx_bp_dropx_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rx_bp_offx {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rx_bp_offx_s {
+               uint64_t reserved_6_63:58;
+               uint64_t mark:6;
+       } s;
+       struct cvmx_agl_gmx_rx_bp_offx_s cn52xx;
+       struct cvmx_agl_gmx_rx_bp_offx_s cn52xxp1;
+       struct cvmx_agl_gmx_rx_bp_offx_s cn56xx;
+       struct cvmx_agl_gmx_rx_bp_offx_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rx_bp_onx {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rx_bp_onx_s {
+               uint64_t reserved_9_63:55;
+               uint64_t mark:9;
+       } s;
+       struct cvmx_agl_gmx_rx_bp_onx_s cn52xx;
+       struct cvmx_agl_gmx_rx_bp_onx_s cn52xxp1;
+       struct cvmx_agl_gmx_rx_bp_onx_s cn56xx;
+       struct cvmx_agl_gmx_rx_bp_onx_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_rx_prt_info {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rx_prt_info_s {
+               uint64_t reserved_18_63:46;
+               uint64_t drop:2;
+               uint64_t reserved_2_15:14;
+               uint64_t commit:2;
+       } s;
+       struct cvmx_agl_gmx_rx_prt_info_s cn52xx;
+       struct cvmx_agl_gmx_rx_prt_info_s cn52xxp1;
+       struct cvmx_agl_gmx_rx_prt_info_cn56xx {
+               uint64_t reserved_17_63:47;
+               uint64_t drop:1;
+               uint64_t reserved_1_15:15;
+               uint64_t commit:1;
+       } cn56xx;
+       struct cvmx_agl_gmx_rx_prt_info_cn56xx cn56xxp1;
+};
+
+union cvmx_agl_gmx_rx_tx_status {
+       uint64_t u64;
+       struct cvmx_agl_gmx_rx_tx_status_s {
+               uint64_t reserved_6_63:58;
+               uint64_t tx:2;
+               uint64_t reserved_2_3:2;
+               uint64_t rx:2;
+       } s;
+       struct cvmx_agl_gmx_rx_tx_status_s cn52xx;
+       struct cvmx_agl_gmx_rx_tx_status_s cn52xxp1;
+       struct cvmx_agl_gmx_rx_tx_status_cn56xx {
+               uint64_t reserved_5_63:59;
+               uint64_t tx:1;
+               uint64_t reserved_1_3:3;
+               uint64_t rx:1;
+       } cn56xx;
+       struct cvmx_agl_gmx_rx_tx_status_cn56xx cn56xxp1;
+};
+
+union cvmx_agl_gmx_smacx {
+       uint64_t u64;
+       struct cvmx_agl_gmx_smacx_s {
+               uint64_t reserved_48_63:16;
+               uint64_t smac:48;
+       } s;
+       struct cvmx_agl_gmx_smacx_s cn52xx;
+       struct cvmx_agl_gmx_smacx_s cn52xxp1;
+       struct cvmx_agl_gmx_smacx_s cn56xx;
+       struct cvmx_agl_gmx_smacx_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_stat_bp {
+       uint64_t u64;
+       struct cvmx_agl_gmx_stat_bp_s {
+               uint64_t reserved_17_63:47;
+               uint64_t bp:1;
+               uint64_t cnt:16;
+       } s;
+       struct cvmx_agl_gmx_stat_bp_s cn52xx;
+       struct cvmx_agl_gmx_stat_bp_s cn52xxp1;
+       struct cvmx_agl_gmx_stat_bp_s cn56xx;
+       struct cvmx_agl_gmx_stat_bp_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_append {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_append_s {
+               uint64_t reserved_4_63:60;
+               uint64_t force_fcs:1;
+               uint64_t fcs:1;
+               uint64_t pad:1;
+               uint64_t preamble:1;
+       } s;
+       struct cvmx_agl_gmx_txx_append_s cn52xx;
+       struct cvmx_agl_gmx_txx_append_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_append_s cn56xx;
+       struct cvmx_agl_gmx_txx_append_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_ctl {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_ctl_s {
+               uint64_t reserved_2_63:62;
+               uint64_t xsdef_en:1;
+               uint64_t xscol_en:1;
+       } s;
+       struct cvmx_agl_gmx_txx_ctl_s cn52xx;
+       struct cvmx_agl_gmx_txx_ctl_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_ctl_s cn56xx;
+       struct cvmx_agl_gmx_txx_ctl_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_min_pkt {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_min_pkt_s {
+               uint64_t reserved_8_63:56;
+               uint64_t min_size:8;
+       } s;
+       struct cvmx_agl_gmx_txx_min_pkt_s cn52xx;
+       struct cvmx_agl_gmx_txx_min_pkt_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_min_pkt_s cn56xx;
+       struct cvmx_agl_gmx_txx_min_pkt_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_pause_pkt_interval {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_pause_pkt_interval_s {
+               uint64_t reserved_16_63:48;
+               uint64_t interval:16;
+       } s;
+       struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn52xx;
+       struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn56xx;
+       struct cvmx_agl_gmx_txx_pause_pkt_interval_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_pause_pkt_time {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_pause_pkt_time_s {
+               uint64_t reserved_16_63:48;
+               uint64_t time:16;
+       } s;
+       struct cvmx_agl_gmx_txx_pause_pkt_time_s cn52xx;
+       struct cvmx_agl_gmx_txx_pause_pkt_time_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_pause_pkt_time_s cn56xx;
+       struct cvmx_agl_gmx_txx_pause_pkt_time_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_pause_togo {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_pause_togo_s {
+               uint64_t reserved_16_63:48;
+               uint64_t time:16;
+       } s;
+       struct cvmx_agl_gmx_txx_pause_togo_s cn52xx;
+       struct cvmx_agl_gmx_txx_pause_togo_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_pause_togo_s cn56xx;
+       struct cvmx_agl_gmx_txx_pause_togo_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_pause_zero {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_pause_zero_s {
+               uint64_t reserved_1_63:63;
+               uint64_t send:1;
+       } s;
+       struct cvmx_agl_gmx_txx_pause_zero_s cn52xx;
+       struct cvmx_agl_gmx_txx_pause_zero_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_pause_zero_s cn56xx;
+       struct cvmx_agl_gmx_txx_pause_zero_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_soft_pause {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_soft_pause_s {
+               uint64_t reserved_16_63:48;
+               uint64_t time:16;
+       } s;
+       struct cvmx_agl_gmx_txx_soft_pause_s cn52xx;
+       struct cvmx_agl_gmx_txx_soft_pause_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_soft_pause_s cn56xx;
+       struct cvmx_agl_gmx_txx_soft_pause_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat0 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat0_s {
+               uint64_t xsdef:32;
+               uint64_t xscol:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat0_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat0_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat0_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat0_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat1 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat1_s {
+               uint64_t scol:32;
+               uint64_t mcol:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat1_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat1_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat1_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat1_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat2 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat2_s {
+               uint64_t reserved_48_63:16;
+               uint64_t octs:48;
+       } s;
+       struct cvmx_agl_gmx_txx_stat2_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat2_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat2_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat2_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat3 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat3_s {
+               uint64_t reserved_32_63:32;
+               uint64_t pkts:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat3_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat3_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat3_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat3_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat4 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat4_s {
+               uint64_t hist1:32;
+               uint64_t hist0:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat4_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat4_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat4_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat4_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat5 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat5_s {
+               uint64_t hist3:32;
+               uint64_t hist2:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat5_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat5_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat5_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat5_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat6 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat6_s {
+               uint64_t hist5:32;
+               uint64_t hist4:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat6_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat6_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat6_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat6_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat7 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat7_s {
+               uint64_t hist7:32;
+               uint64_t hist6:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat7_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat7_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat7_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat7_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat8 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat8_s {
+               uint64_t mcst:32;
+               uint64_t bcst:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat8_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat8_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat8_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat8_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stat9 {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stat9_s {
+               uint64_t undflw:32;
+               uint64_t ctl:32;
+       } s;
+       struct cvmx_agl_gmx_txx_stat9_s cn52xx;
+       struct cvmx_agl_gmx_txx_stat9_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stat9_s cn56xx;
+       struct cvmx_agl_gmx_txx_stat9_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_stats_ctl {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_stats_ctl_s {
+               uint64_t reserved_1_63:63;
+               uint64_t rd_clr:1;
+       } s;
+       struct cvmx_agl_gmx_txx_stats_ctl_s cn52xx;
+       struct cvmx_agl_gmx_txx_stats_ctl_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_stats_ctl_s cn56xx;
+       struct cvmx_agl_gmx_txx_stats_ctl_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_txx_thresh {
+       uint64_t u64;
+       struct cvmx_agl_gmx_txx_thresh_s {
+               uint64_t reserved_6_63:58;
+               uint64_t cnt:6;
+       } s;
+       struct cvmx_agl_gmx_txx_thresh_s cn52xx;
+       struct cvmx_agl_gmx_txx_thresh_s cn52xxp1;
+       struct cvmx_agl_gmx_txx_thresh_s cn56xx;
+       struct cvmx_agl_gmx_txx_thresh_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_bp {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_bp_s {
+               uint64_t reserved_2_63:62;
+               uint64_t bp:2;
+       } s;
+       struct cvmx_agl_gmx_tx_bp_s cn52xx;
+       struct cvmx_agl_gmx_tx_bp_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_bp_cn56xx {
+               uint64_t reserved_1_63:63;
+               uint64_t bp:1;
+       } cn56xx;
+       struct cvmx_agl_gmx_tx_bp_cn56xx cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_col_attempt {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_col_attempt_s {
+               uint64_t reserved_5_63:59;
+               uint64_t limit:5;
+       } s;
+       struct cvmx_agl_gmx_tx_col_attempt_s cn52xx;
+       struct cvmx_agl_gmx_tx_col_attempt_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_col_attempt_s cn56xx;
+       struct cvmx_agl_gmx_tx_col_attempt_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_ifg {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_ifg_s {
+               uint64_t reserved_8_63:56;
+               uint64_t ifg2:4;
+               uint64_t ifg1:4;
+       } s;
+       struct cvmx_agl_gmx_tx_ifg_s cn52xx;
+       struct cvmx_agl_gmx_tx_ifg_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_ifg_s cn56xx;
+       struct cvmx_agl_gmx_tx_ifg_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_int_en {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_int_en_s {
+               uint64_t reserved_18_63:46;
+               uint64_t late_col:2;
+               uint64_t reserved_14_15:2;
+               uint64_t xsdef:2;
+               uint64_t reserved_10_11:2;
+               uint64_t xscol:2;
+               uint64_t reserved_4_7:4;
+               uint64_t undflw:2;
+               uint64_t reserved_1_1:1;
+               uint64_t pko_nxa:1;
+       } s;
+       struct cvmx_agl_gmx_tx_int_en_s cn52xx;
+       struct cvmx_agl_gmx_tx_int_en_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_int_en_cn56xx {
+               uint64_t reserved_17_63:47;
+               uint64_t late_col:1;
+               uint64_t reserved_13_15:3;
+               uint64_t xsdef:1;
+               uint64_t reserved_9_11:3;
+               uint64_t xscol:1;
+               uint64_t reserved_3_7:5;
+               uint64_t undflw:1;
+               uint64_t reserved_1_1:1;
+               uint64_t pko_nxa:1;
+       } cn56xx;
+       struct cvmx_agl_gmx_tx_int_en_cn56xx cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_int_reg {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_int_reg_s {
+               uint64_t reserved_18_63:46;
+               uint64_t late_col:2;
+               uint64_t reserved_14_15:2;
+               uint64_t xsdef:2;
+               uint64_t reserved_10_11:2;
+               uint64_t xscol:2;
+               uint64_t reserved_4_7:4;
+               uint64_t undflw:2;
+               uint64_t reserved_1_1:1;
+               uint64_t pko_nxa:1;
+       } s;
+       struct cvmx_agl_gmx_tx_int_reg_s cn52xx;
+       struct cvmx_agl_gmx_tx_int_reg_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_int_reg_cn56xx {
+               uint64_t reserved_17_63:47;
+               uint64_t late_col:1;
+               uint64_t reserved_13_15:3;
+               uint64_t xsdef:1;
+               uint64_t reserved_9_11:3;
+               uint64_t xscol:1;
+               uint64_t reserved_3_7:5;
+               uint64_t undflw:1;
+               uint64_t reserved_1_1:1;
+               uint64_t pko_nxa:1;
+       } cn56xx;
+       struct cvmx_agl_gmx_tx_int_reg_cn56xx cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_jam {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_jam_s {
+               uint64_t reserved_8_63:56;
+               uint64_t jam:8;
+       } s;
+       struct cvmx_agl_gmx_tx_jam_s cn52xx;
+       struct cvmx_agl_gmx_tx_jam_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_jam_s cn56xx;
+       struct cvmx_agl_gmx_tx_jam_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_lfsr {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_lfsr_s {
+               uint64_t reserved_16_63:48;
+               uint64_t lfsr:16;
+       } s;
+       struct cvmx_agl_gmx_tx_lfsr_s cn52xx;
+       struct cvmx_agl_gmx_tx_lfsr_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_lfsr_s cn56xx;
+       struct cvmx_agl_gmx_tx_lfsr_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_ovr_bp {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_ovr_bp_s {
+               uint64_t reserved_10_63:54;
+               uint64_t en:2;
+               uint64_t reserved_6_7:2;
+               uint64_t bp:2;
+               uint64_t reserved_2_3:2;
+               uint64_t ign_full:2;
+       } s;
+       struct cvmx_agl_gmx_tx_ovr_bp_s cn52xx;
+       struct cvmx_agl_gmx_tx_ovr_bp_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_ovr_bp_cn56xx {
+               uint64_t reserved_9_63:55;
+               uint64_t en:1;
+               uint64_t reserved_5_7:3;
+               uint64_t bp:1;
+               uint64_t reserved_1_3:3;
+               uint64_t ign_full:1;
+       } cn56xx;
+       struct cvmx_agl_gmx_tx_ovr_bp_cn56xx cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_pause_pkt_dmac {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_pause_pkt_dmac_s {
+               uint64_t reserved_48_63:16;
+               uint64_t dmac:48;
+       } s;
+       struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn52xx;
+       struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn56xx;
+       struct cvmx_agl_gmx_tx_pause_pkt_dmac_s cn56xxp1;
+};
+
+union cvmx_agl_gmx_tx_pause_pkt_type {
+       uint64_t u64;
+       struct cvmx_agl_gmx_tx_pause_pkt_type_s {
+               uint64_t reserved_16_63:48;
+               uint64_t type:16;
+       } s;
+       struct cvmx_agl_gmx_tx_pause_pkt_type_s cn52xx;
+       struct cvmx_agl_gmx_tx_pause_pkt_type_s cn52xxp1;
+       struct cvmx_agl_gmx_tx_pause_pkt_type_s cn56xx;
+       struct cvmx_agl_gmx_tx_pause_pkt_type_s cn56xxp1;
+};
+
+#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-mixx-defs.h b/arch/mips/include/asm/octeon/cvmx-mixx-defs.h
new file mode 100644 (file)
index 0000000..dab6dca
--- /dev/null
@@ -0,0 +1,248 @@
+/***********************license start***************
+ * Author: Cavium Networks
+ *
+ * Contact: support@caviumnetworks.com
+ * This file is part of the OCTEON SDK
+ *
+ * Copyright (c) 2003-2008 Cavium Networks
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
+ * NONINFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this file; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * or visit http://www.gnu.org/licenses/.
+ *
+ * This file may also be available under a different license from Cavium.
+ * Contact Cavium Networks for more information
+ ***********************license end**************************************/
+
+#ifndef __CVMX_MIXX_DEFS_H__
+#define __CVMX_MIXX_DEFS_H__
+
+#define CVMX_MIXX_BIST(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100078ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_CTL(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100020ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_INTENA(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100050ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_IRCNT(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100030ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_IRHWM(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100028ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_IRING1(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100010ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_IRING2(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100018ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_ISR(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100048ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_ORCNT(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100040ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_ORHWM(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100038ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_ORING1(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100000ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_ORING2(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100008ull + (((offset) & 1) * 2048))
+#define CVMX_MIXX_REMCNT(offset) \
+        CVMX_ADD_IO_SEG(0x0001070000100058ull + (((offset) & 1) * 2048))
+
+union cvmx_mixx_bist {
+       uint64_t u64;
+       struct cvmx_mixx_bist_s {
+               uint64_t reserved_4_63:60;
+               uint64_t mrqdat:1;
+               uint64_t ipfdat:1;
+               uint64_t irfdat:1;
+               uint64_t orfdat:1;
+       } s;
+       struct cvmx_mixx_bist_s cn52xx;
+       struct cvmx_mixx_bist_s cn52xxp1;
+       struct cvmx_mixx_bist_s cn56xx;
+       struct cvmx_mixx_bist_s cn56xxp1;
+};
+
+union cvmx_mixx_ctl {
+       uint64_t u64;
+       struct cvmx_mixx_ctl_s {
+               uint64_t reserved_8_63:56;
+               uint64_t crc_strip:1;
+               uint64_t busy:1;
+               uint64_t en:1;
+               uint64_t reset:1;
+               uint64_t lendian:1;
+               uint64_t nbtarb:1;
+               uint64_t mrq_hwm:2;
+       } s;
+       struct cvmx_mixx_ctl_s cn52xx;
+       struct cvmx_mixx_ctl_s cn52xxp1;
+       struct cvmx_mixx_ctl_s cn56xx;
+       struct cvmx_mixx_ctl_s cn56xxp1;
+};
+
+union cvmx_mixx_intena {
+       uint64_t u64;
+       struct cvmx_mixx_intena_s {
+               uint64_t reserved_7_63:57;
+               uint64_t orunena:1;
+               uint64_t irunena:1;
+               uint64_t data_drpena:1;
+               uint64_t ithena:1;
+               uint64_t othena:1;
+               uint64_t ivfena:1;
+               uint64_t ovfena:1;
+       } s;
+       struct cvmx_mixx_intena_s cn52xx;
+       struct cvmx_mixx_intena_s cn52xxp1;
+       struct cvmx_mixx_intena_s cn56xx;
+       struct cvmx_mixx_intena_s cn56xxp1;
+};
+
+union cvmx_mixx_ircnt {
+       uint64_t u64;
+       struct cvmx_mixx_ircnt_s {
+               uint64_t reserved_20_63:44;
+               uint64_t ircnt:20;
+       } s;
+       struct cvmx_mixx_ircnt_s cn52xx;
+       struct cvmx_mixx_ircnt_s cn52xxp1;
+       struct cvmx_mixx_ircnt_s cn56xx;
+       struct cvmx_mixx_ircnt_s cn56xxp1;
+};
+
+union cvmx_mixx_irhwm {
+       uint64_t u64;
+       struct cvmx_mixx_irhwm_s {
+               uint64_t reserved_40_63:24;
+               uint64_t ibplwm:20;
+               uint64_t irhwm:20;
+       } s;
+       struct cvmx_mixx_irhwm_s cn52xx;
+       struct cvmx_mixx_irhwm_s cn52xxp1;
+       struct cvmx_mixx_irhwm_s cn56xx;
+       struct cvmx_mixx_irhwm_s cn56xxp1;
+};
+
+union cvmx_mixx_iring1 {
+       uint64_t u64;
+       struct cvmx_mixx_iring1_s {
+               uint64_t reserved_60_63:4;
+               uint64_t isize:20;
+               uint64_t reserved_36_39:4;
+               uint64_t ibase:33;
+               uint64_t reserved_0_2:3;
+       } s;
+       struct cvmx_mixx_iring1_s cn52xx;
+       struct cvmx_mixx_iring1_s cn52xxp1;
+       struct cvmx_mixx_iring1_s cn56xx;
+       struct cvmx_mixx_iring1_s cn56xxp1;
+};
+
+union cvmx_mixx_iring2 {
+       uint64_t u64;
+       struct cvmx_mixx_iring2_s {
+               uint64_t reserved_52_63:12;
+               uint64_t itlptr:20;
+               uint64_t reserved_20_31:12;
+               uint64_t idbell:20;
+       } s;
+       struct cvmx_mixx_iring2_s cn52xx;
+       struct cvmx_mixx_iring2_s cn52xxp1;
+       struct cvmx_mixx_iring2_s cn56xx;
+       struct cvmx_mixx_iring2_s cn56xxp1;
+};
+
+union cvmx_mixx_isr {
+       uint64_t u64;
+       struct cvmx_mixx_isr_s {
+               uint64_t reserved_7_63:57;
+               uint64_t orun:1;
+               uint64_t irun:1;
+               uint64_t data_drp:1;
+               uint64_t irthresh:1;
+               uint64_t orthresh:1;
+               uint64_t idblovf:1;
+               uint64_t odblovf:1;
+       } s;
+       struct cvmx_mixx_isr_s cn52xx;
+       struct cvmx_mixx_isr_s cn52xxp1;
+       struct cvmx_mixx_isr_s cn56xx;
+       struct cvmx_mixx_isr_s cn56xxp1;
+};
+
+union cvmx_mixx_orcnt {
+       uint64_t u64;
+       struct cvmx_mixx_orcnt_s {
+               uint64_t reserved_20_63:44;
+               uint64_t orcnt:20;
+       } s;
+       struct cvmx_mixx_orcnt_s cn52xx;
+       struct cvmx_mixx_orcnt_s cn52xxp1;
+       struct cvmx_mixx_orcnt_s cn56xx;
+       struct cvmx_mixx_orcnt_s cn56xxp1;
+};
+
+union cvmx_mixx_orhwm {
+       uint64_t u64;
+       struct cvmx_mixx_orhwm_s {
+               uint64_t reserved_20_63:44;
+               uint64_t orhwm:20;
+       } s;
+       struct cvmx_mixx_orhwm_s cn52xx;
+       struct cvmx_mixx_orhwm_s cn52xxp1;
+       struct cvmx_mixx_orhwm_s cn56xx;
+       struct cvmx_mixx_orhwm_s cn56xxp1;
+};
+
+union cvmx_mixx_oring1 {
+       uint64_t u64;
+       struct cvmx_mixx_oring1_s {
+               uint64_t reserved_60_63:4;
+               uint64_t osize:20;
+               uint64_t reserved_36_39:4;
+               uint64_t obase:33;
+               uint64_t reserved_0_2:3;
+       } s;
+       struct cvmx_mixx_oring1_s cn52xx;
+       struct cvmx_mixx_oring1_s cn52xxp1;
+       struct cvmx_mixx_oring1_s cn56xx;
+       struct cvmx_mixx_oring1_s cn56xxp1;
+};
+
+union cvmx_mixx_oring2 {
+       uint64_t u64;
+       struct cvmx_mixx_oring2_s {
+               uint64_t reserved_52_63:12;
+               uint64_t otlptr:20;
+               uint64_t reserved_20_31:12;
+               uint64_t odbell:20;
+       } s;
+       struct cvmx_mixx_oring2_s cn52xx;
+       struct cvmx_mixx_oring2_s cn52xxp1;
+       struct cvmx_mixx_oring2_s cn56xx;
+       struct cvmx_mixx_oring2_s cn56xxp1;
+};
+
+union cvmx_mixx_remcnt {
+       uint64_t u64;
+       struct cvmx_mixx_remcnt_s {
+               uint64_t reserved_52_63:12;
+               uint64_t iremcnt:20;
+               uint64_t reserved_20_31:12;
+               uint64_t oremcnt:20;
+       } s;
+       struct cvmx_mixx_remcnt_s cn52xx;
+       struct cvmx_mixx_remcnt_s cn52xxp1;
+       struct cvmx_mixx_remcnt_s cn56xx;
+       struct cvmx_mixx_remcnt_s cn56xxp1;
+};
+
+#endif
diff --git a/arch/mips/include/asm/octeon/cvmx-smix-defs.h b/arch/mips/include/asm/octeon/cvmx-smix-defs.h
new file mode 100644 (file)
index 0000000..9ae45fc
--- /dev/null
@@ -0,0 +1,178 @@
+/***********************license start***************
+ * Author: Cavium Networks
+ *
+ * Contact: support@caviumnetworks.com
+ * This file is part of the OCTEON SDK
+ *
+ * Copyright (c) 2003-2008 Cavium Networks
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
+ * NONINFRINGEMENT.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this file; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * or visit http://www.gnu.org/licenses/.
+ *
+ * This file may also be available under a different license from Cavium.
+ * Contact Cavium Networks for more information
+ ***********************license end**************************************/
+
+#ifndef __CVMX_SMIX_DEFS_H__
+#define __CVMX_SMIX_DEFS_H__
+
+#define CVMX_SMIX_CLK(offset) \
+        CVMX_ADD_IO_SEG(0x0001180000001818ull + (((offset) & 1) * 256))
+#define CVMX_SMIX_CMD(offset) \
+        CVMX_ADD_IO_SEG(0x0001180000001800ull + (((offset) & 1) * 256))
+#define CVMX_SMIX_EN(offset) \
+        CVMX_ADD_IO_SEG(0x0001180000001820ull + (((offset) & 1) * 256))
+#define CVMX_SMIX_RD_DAT(offset) \
+        CVMX_ADD_IO_SEG(0x0001180000001810ull + (((offset) & 1) * 256))
+#define CVMX_SMIX_WR_DAT(offset) \
+        CVMX_ADD_IO_SEG(0x0001180000001808ull + (((offset) & 1) * 256))
+
+union cvmx_smix_clk {
+       uint64_t u64;
+       struct cvmx_smix_clk_s {
+               uint64_t reserved_25_63:39;
+               uint64_t mode:1;
+               uint64_t reserved_21_23:3;
+               uint64_t sample_hi:5;
+               uint64_t sample_mode:1;
+               uint64_t reserved_14_14:1;
+               uint64_t clk_idle:1;
+               uint64_t preamble:1;
+               uint64_t sample:4;
+               uint64_t phase:8;
+       } s;
+       struct cvmx_smix_clk_cn30xx {
+               uint64_t reserved_21_63:43;
+               uint64_t sample_hi:5;
+               uint64_t reserved_14_15:2;
+               uint64_t clk_idle:1;
+               uint64_t preamble:1;
+               uint64_t sample:4;
+               uint64_t phase:8;
+       } cn30xx;
+       struct cvmx_smix_clk_cn30xx cn31xx;
+       struct cvmx_smix_clk_cn30xx cn38xx;
+       struct cvmx_smix_clk_cn30xx cn38xxp2;
+       struct cvmx_smix_clk_cn50xx {
+               uint64_t reserved_25_63:39;
+               uint64_t mode:1;
+               uint64_t reserved_21_23:3;
+               uint64_t sample_hi:5;
+               uint64_t reserved_14_15:2;
+               uint64_t clk_idle:1;
+               uint64_t preamble:1;
+               uint64_t sample:4;
+               uint64_t phase:8;
+       } cn50xx;
+       struct cvmx_smix_clk_s cn52xx;
+       struct cvmx_smix_clk_cn50xx cn52xxp1;
+       struct cvmx_smix_clk_s cn56xx;
+       struct cvmx_smix_clk_cn50xx cn56xxp1;
+       struct cvmx_smix_clk_cn30xx cn58xx;
+       struct cvmx_smix_clk_cn30xx cn58xxp1;
+};
+
+union cvmx_smix_cmd {
+       uint64_t u64;
+       struct cvmx_smix_cmd_s {
+               uint64_t reserved_18_63:46;
+               uint64_t phy_op:2;
+               uint64_t reserved_13_15:3;
+               uint64_t phy_adr:5;
+               uint64_t reserved_5_7:3;
+               uint64_t reg_adr:5;
+       } s;
+       struct cvmx_smix_cmd_cn30xx {
+               uint64_t reserved_17_63:47;
+               uint64_t phy_op:1;
+               uint64_t reserved_13_15:3;
+               uint64_t phy_adr:5;
+               uint64_t reserved_5_7:3;
+               uint64_t reg_adr:5;
+       } cn30xx;
+       struct cvmx_smix_cmd_cn30xx cn31xx;
+       struct cvmx_smix_cmd_cn30xx cn38xx;
+       struct cvmx_smix_cmd_cn30xx cn38xxp2;
+       struct cvmx_smix_cmd_s cn50xx;
+       struct cvmx_smix_cmd_s cn52xx;
+       struct cvmx_smix_cmd_s cn52xxp1;
+       struct cvmx_smix_cmd_s cn56xx;
+       struct cvmx_smix_cmd_s cn56xxp1;
+       struct cvmx_smix_cmd_cn30xx cn58xx;
+       struct cvmx_smix_cmd_cn30xx cn58xxp1;
+};
+
+union cvmx_smix_en {
+       uint64_t u64;
+       struct cvmx_smix_en_s {
+               uint64_t reserved_1_63:63;
+               uint64_t en:1;
+       } s;
+       struct cvmx_smix_en_s cn30xx;
+       struct cvmx_smix_en_s cn31xx;
+       struct cvmx_smix_en_s cn38xx;
+       struct cvmx_smix_en_s cn38xxp2;
+       struct cvmx_smix_en_s cn50xx;
+       struct cvmx_smix_en_s cn52xx;
+       struct cvmx_smix_en_s cn52xxp1;
+       struct cvmx_smix_en_s cn56xx;
+       struct cvmx_smix_en_s cn56xxp1;
+       struct cvmx_smix_en_s cn58xx;
+       struct cvmx_smix_en_s cn58xxp1;
+};
+
+union cvmx_smix_rd_dat {
+       uint64_t u64;
+       struct cvmx_smix_rd_dat_s {
+               uint64_t reserved_18_63:46;
+               uint64_t pending:1;
+               uint64_t val:1;
+               uint64_t dat:16;
+       } s;
+       struct cvmx_smix_rd_dat_s cn30xx;
+       struct cvmx_smix_rd_dat_s cn31xx;
+       struct cvmx_smix_rd_dat_s cn38xx;
+       struct cvmx_smix_rd_dat_s cn38xxp2;
+       struct cvmx_smix_rd_dat_s cn50xx;
+       struct cvmx_smix_rd_dat_s cn52xx;
+       struct cvmx_smix_rd_dat_s cn52xxp1;
+       struct cvmx_smix_rd_dat_s cn56xx;
+       struct cvmx_smix_rd_dat_s cn56xxp1;
+       struct cvmx_smix_rd_dat_s cn58xx;
+       struct cvmx_smix_rd_dat_s cn58xxp1;
+};
+
+union cvmx_smix_wr_dat {
+       uint64_t u64;
+       struct cvmx_smix_wr_dat_s {
+               uint64_t reserved_18_63:46;
+               uint64_t pending:1;
+               uint64_t val:1;
+               uint64_t dat:16;
+       } s;
+       struct cvmx_smix_wr_dat_s cn30xx;
+       struct cvmx_smix_wr_dat_s cn31xx;
+       struct cvmx_smix_wr_dat_s cn38xx;
+       struct cvmx_smix_wr_dat_s cn38xxp2;
+       struct cvmx_smix_wr_dat_s cn50xx;
+       struct cvmx_smix_wr_dat_s cn52xx;
+       struct cvmx_smix_wr_dat_s cn52xxp1;
+       struct cvmx_smix_wr_dat_s cn56xx;
+       struct cvmx_smix_wr_dat_s cn56xxp1;
+       struct cvmx_smix_wr_dat_s cn58xx;
+       struct cvmx_smix_wr_dat_s cn58xxp1;
+};
+
+#endif
index cac9b1a206fce1eddc61e65e85ede845e47a883f..4d0a8c61fc3eed3a160d7ba0116341e442c28037 100644 (file)
@@ -47,6 +47,7 @@ struct octeon_cop2_state;
 extern unsigned long octeon_crypto_enable(struct octeon_cop2_state *state);
 extern void octeon_crypto_disable(struct octeon_cop2_state *state,
                                  unsigned long flags);
+extern asmlinkage void octeon_cop2_restore(struct octeon_cop2_state *task);
 
 extern void octeon_init_cvmcount(void);
 
index d6eb6134abeca4f819427937c9ad3dee380d1360..1854336e56a299d70e1b9b045edc93334f2829bf 100644 (file)
@@ -389,6 +389,19 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
 
 #include <asm-generic/pgtable.h>
 
+/*
+ * uncached accelerated TLB map for video memory access
+ */
+#ifdef CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED
+#define __HAVE_PHYS_MEM_ACCESS_PROT
+
+struct file;
+pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
+               unsigned long size, pgprot_t vma_prot);
+int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
+               unsigned long size, pgprot_t *vma_prot);
+#endif
+
 /*
  * We provide our own get_unmapped area to cope with the virtual aliasing
  * constraints placed on us by the cache architecture.
index bfce5c786f1c2772c0a5515c3e10b62b7e6d6185..63741ca1e422ebfd3970adb70fa692c52c1f35dc 100644 (file)
@@ -85,8 +85,7 @@ extern void prom_identify_arch(void);
 extern PCHAR ArcGetEnvironmentVariable(PCHAR name);
 extern LONG ArcSetEnvironmentVariable(PCHAR name, PCHAR value);
 
-/* ARCS command line acquisition and parsing. */
-extern char *prom_getcmdline(void);
+/* ARCS command line parsing. */
 extern void prom_init_cmdline(void);
 
 /* Acquiring info about the current time, etc. */
index 5b60a09a0f0894e8c8b1301683064b841a5b8e4b..21ef9efbde43f9e61cf726961e81e91c7252d6b5 100644 (file)
  * becomes equal to the the initial value of the tail.
  */
 
-static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
+static inline int arch_spin_is_locked(arch_spinlock_t *lock)
 {
        unsigned int counters = ACCESS_ONCE(lock->lock);
 
        return ((counters >> 14) ^ counters) & 0x1fff;
 }
 
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
-#define __raw_spin_unlock_wait(x) \
-       while (__raw_spin_is_locked(x)) { cpu_relax(); }
+#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
+#define arch_spin_unlock_wait(x) \
+       while (arch_spin_is_locked(x)) { cpu_relax(); }
 
-static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
+static inline int arch_spin_is_contended(arch_spinlock_t *lock)
 {
        unsigned int counters = ACCESS_ONCE(lock->lock);
 
        return (((counters >> 14) - counters) & 0x1fff) > 1;
 }
-#define __raw_spin_is_contended        __raw_spin_is_contended
+#define arch_spin_is_contended arch_spin_is_contended
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        int my_ticket;
        int tmp;
 
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__ (
-               "       .set push               # __raw_spin_lock       \n"
+               "       .set push               # arch_spin_lock        \n"
                "       .set noreorder                                  \n"
                "                                                       \n"
                "1:     ll      %[ticket], %[ticket_ptr]                \n"
@@ -94,7 +94,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
                  [my_ticket] "=&r" (my_ticket));
        } else {
                __asm__ __volatile__ (
-               "       .set push               # __raw_spin_lock       \n"
+               "       .set push               # arch_spin_lock        \n"
                "       .set noreorder                                  \n"
                "                                                       \n"
                "       ll      %[ticket], %[ticket_ptr]                \n"
@@ -134,7 +134,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
        smp_llsc_mb();
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        int tmp;
 
@@ -142,7 +142,7 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
 
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__ (
-               "                               # __raw_spin_unlock     \n"
+               "                               # arch_spin_unlock      \n"
                "1:     ll      %[ticket], %[ticket_ptr]                \n"
                "       addiu   %[ticket], %[ticket], 1                 \n"
                "       ori     %[ticket], %[ticket], 0x2000            \n"
@@ -153,7 +153,7 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
                  [ticket] "=&r" (tmp));
        } else {
                __asm__ __volatile__ (
-               "       .set push               # __raw_spin_unlock     \n"
+               "       .set push               # arch_spin_unlock      \n"
                "       .set noreorder                                  \n"
                "                                                       \n"
                "       ll      %[ticket], %[ticket_ptr]                \n"
@@ -174,13 +174,13 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
        }
 }
 
-static inline unsigned int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline unsigned int arch_spin_trylock(arch_spinlock_t *lock)
 {
        int tmp, tmp2, tmp3;
 
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__ (
-               "       .set push               # __raw_spin_trylock    \n"
+               "       .set push               # arch_spin_trylock     \n"
                "       .set noreorder                                  \n"
                "                                                       \n"
                "1:     ll      %[ticket], %[ticket_ptr]                \n"
@@ -204,7 +204,7 @@ static inline unsigned int __raw_spin_trylock(raw_spinlock_t *lock)
                  [now_serving] "=&r" (tmp3));
        } else {
                __asm__ __volatile__ (
-               "       .set push               # __raw_spin_trylock    \n"
+               "       .set push               # arch_spin_trylock     \n"
                "       .set noreorder                                  \n"
                "                                                       \n"
                "       ll      %[ticket], %[ticket_ptr]                \n"
@@ -248,21 +248,21 @@ static inline unsigned int __raw_spin_trylock(raw_spinlock_t *lock)
  * read_can_lock - would read_trylock() succeed?
  * @lock: the rwlock in question.
  */
-#define __raw_read_can_lock(rw)        ((rw)->lock >= 0)
+#define arch_read_can_lock(rw) ((rw)->lock >= 0)
 
 /*
  * write_can_lock - would write_trylock() succeed?
  * @lock: the rwlock in question.
  */
-#define __raw_write_can_lock(rw)       (!(rw)->lock)
+#define arch_write_can_lock(rw)        (!(rw)->lock)
 
-static inline void __raw_read_lock(raw_rwlock_t *rw)
+static inline void arch_read_lock(arch_rwlock_t *rw)
 {
        unsigned int tmp;
 
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_read_lock       \n"
+               "       .set    noreorder       # arch_read_lock        \n"
                "1:     ll      %1, %2                                  \n"
                "       bltz    %1, 1b                                  \n"
                "        addu   %1, 1                                   \n"
@@ -275,7 +275,7 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
                : "memory");
        } else {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_read_lock       \n"
+               "       .set    noreorder       # arch_read_lock        \n"
                "1:     ll      %1, %2                                  \n"
                "       bltz    %1, 2f                                  \n"
                "        addu   %1, 1                                   \n"
@@ -301,7 +301,7 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
 /* Note the use of sub, not subu which will make the kernel die with an
    overflow exception if we ever try to unlock an rwlock that is already
    unlocked or is being held by a writer.  */
-static inline void __raw_read_unlock(raw_rwlock_t *rw)
+static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
        unsigned int tmp;
 
@@ -309,7 +309,7 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
 
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
-               "1:     ll      %1, %2          # __raw_read_unlock     \n"
+               "1:     ll      %1, %2          # arch_read_unlock      \n"
                "       sub     %1, 1                                   \n"
                "       sc      %1, %0                                  \n"
                "       beqzl   %1, 1b                                  \n"
@@ -318,7 +318,7 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
                : "memory");
        } else {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_read_unlock     \n"
+               "       .set    noreorder       # arch_read_unlock      \n"
                "1:     ll      %1, %2                                  \n"
                "       sub     %1, 1                                   \n"
                "       sc      %1, %0                                  \n"
@@ -335,13 +335,13 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
        }
 }
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
        unsigned int tmp;
 
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_write_lock      \n"
+               "       .set    noreorder       # arch_write_lock       \n"
                "1:     ll      %1, %2                                  \n"
                "       bnez    %1, 1b                                  \n"
                "        lui    %1, 0x8000                              \n"
@@ -354,7 +354,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
                : "memory");
        } else {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_write_lock      \n"
+               "       .set    noreorder       # arch_write_lock       \n"
                "1:     ll      %1, %2                                  \n"
                "       bnez    %1, 2f                                  \n"
                "        lui    %1, 0x8000                              \n"
@@ -377,26 +377,26 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
        smp_llsc_mb();
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t *rw)
+static inline void arch_write_unlock(arch_rwlock_t *rw)
 {
        smp_mb();
 
        __asm__ __volatile__(
-       "                               # __raw_write_unlock    \n"
+       "                               # arch_write_unlock     \n"
        "       sw      $0, %0                                  \n"
        : "=m" (rw->lock)
        : "m" (rw->lock)
        : "memory");
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t *rw)
+static inline int arch_read_trylock(arch_rwlock_t *rw)
 {
        unsigned int tmp;
        int ret;
 
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_read_trylock    \n"
+               "       .set    noreorder       # arch_read_trylock     \n"
                "       li      %2, 0                                   \n"
                "1:     ll      %1, %3                                  \n"
                "       bltz    %1, 2f                                  \n"
@@ -413,7 +413,7 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw)
                : "memory");
        } else {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_read_trylock    \n"
+               "       .set    noreorder       # arch_read_trylock     \n"
                "       li      %2, 0                                   \n"
                "1:     ll      %1, %3                                  \n"
                "       bltz    %1, 2f                                  \n"
@@ -433,14 +433,14 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw)
        return ret;
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *rw)
+static inline int arch_write_trylock(arch_rwlock_t *rw)
 {
        unsigned int tmp;
        int ret;
 
        if (R10000_LLSC_WAR) {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_write_trylock   \n"
+               "       .set    noreorder       # arch_write_trylock    \n"
                "       li      %2, 0                                   \n"
                "1:     ll      %1, %3                                  \n"
                "       bnez    %1, 2f                                  \n"
@@ -457,7 +457,7 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
                : "memory");
        } else {
                __asm__ __volatile__(
-               "       .set    noreorder       # __raw_write_trylock   \n"
+               "       .set    noreorder       # arch_write_trylock    \n"
                "       li      %2, 0                                   \n"
                "1:     ll      %1, %3                                  \n"
                "       bnez    %1, 2f                                  \n"
@@ -480,11 +480,11 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
        return ret;
 }
 
-#define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock)
-#define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock)
+#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* _ASM_SPINLOCK_H */
index adeedaa116c14ef379c7b8fb8fcc1237b4c66bfd..ee197c2f9c98725985d99289dc20f6e3a5110738 100644 (file)
@@ -12,14 +12,14 @@ typedef struct {
         * bits 15..28: ticket
         */
        unsigned int lock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        volatile unsigned int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { 0 }
+#define __ARCH_RW_LOCK_UNLOCKED                { 0 }
 
 #endif
index db0fa7b5aeaf3f849d0a197f63c7a1ba8a487498..3b6da3330e321772358c9791914e3d472290d2f9 100644 (file)
@@ -51,9 +51,6 @@
                LONG_S  v1, PT_ACX(sp)
 #else
                mfhi    v1
-               LONG_S  v1, PT_HI(sp)
-               mflo    v1
-               LONG_S  v1, PT_LO(sp)
 #endif
 #ifdef CONFIG_32BIT
                LONG_S  $8, PT_R8(sp)
                LONG_S  $10, PT_R10(sp)
                LONG_S  $11, PT_R11(sp)
                LONG_S  $12, PT_R12(sp)
+#ifndef CONFIG_CPU_HAS_SMARTMIPS
+               LONG_S  v1, PT_HI(sp)
+               mflo    v1
+#endif
                LONG_S  $13, PT_R13(sp)
                LONG_S  $14, PT_R14(sp)
                LONG_S  $15, PT_R15(sp)
                LONG_S  $24, PT_R24(sp)
+#ifndef CONFIG_CPU_HAS_SMARTMIPS
+               LONG_S  v1, PT_LO(sp)
+#endif
                .endm
 
                .macro  SAVE_STATIC
 #ifdef CONFIG_SMP
 #ifdef CONFIG_MIPS_MT_SMTC
 #define PTEBASE_SHIFT  19      /* TCBIND */
+#define CPU_ID_REG CP0_TCBIND
+#define CPU_ID_MFC0 mfc0
+#elif defined(CONFIG_MIPS_PGD_C0_CONTEXT)
+#define PTEBASE_SHIFT  48      /* XCONTEXT */
+#define CPU_ID_REG CP0_XCONTEXT
+#define CPU_ID_MFC0 MFC0
 #else
 #define PTEBASE_SHIFT  23      /* CONTEXT */
+#define CPU_ID_REG CP0_CONTEXT
+#define CPU_ID_MFC0 MFC0
 #endif
                .macro  get_saved_sp    /* SMP variation */
-#ifdef CONFIG_MIPS_MT_SMTC
-               mfc0    k0, CP0_TCBIND
-#else
-               MFC0    k0, CP0_CONTEXT
-#endif
+               CPU_ID_MFC0     k0, CPU_ID_REG
 #if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
                lui     k1, %hi(kernelsp)
 #else
                .endm
 
                .macro  set_saved_sp stackp temp temp2
-#ifdef CONFIG_MIPS_MT_SMTC
-               mfc0    \temp, CP0_TCBIND
-#else
-               MFC0    \temp, CP0_CONTEXT
-#endif
+               CPU_ID_MFC0     \temp, CPU_ID_REG
                LONG_SRL        \temp, PTEBASE_SHIFT
                LONG_S  \stackp, kernelsp(\temp)
                .endm
                LONG_S  $0, PT_R0(sp)
                mfc0    v1, CP0_STATUS
                LONG_S  $2, PT_R2(sp)
-               LONG_S  v1, PT_STATUS(sp)
 #ifdef CONFIG_MIPS_MT_SMTC
                /*
                 * Ideally, these instructions would be shuffled in
                LONG_S  v1, PT_TCSTATUS(sp)
 #endif /* CONFIG_MIPS_MT_SMTC */
                LONG_S  $4, PT_R4(sp)
-               mfc0    v1, CP0_CAUSE
                LONG_S  $5, PT_R5(sp)
-               LONG_S  v1, PT_CAUSE(sp)
+               LONG_S  v1, PT_STATUS(sp)
+               mfc0    v1, CP0_CAUSE
                LONG_S  $6, PT_R6(sp)
-               MFC0    v1, CP0_EPC
                LONG_S  $7, PT_R7(sp)
+               LONG_S  v1, PT_CAUSE(sp)
+               MFC0    v1, CP0_EPC
 #ifdef CONFIG_64BIT
                LONG_S  $8, PT_R8(sp)
                LONG_S  $9, PT_R9(sp)
 #endif
-               LONG_S  v1, PT_EPC(sp)
                LONG_S  $25, PT_R25(sp)
                LONG_S  $28, PT_R28(sp)
                LONG_S  $31, PT_R31(sp)
+               LONG_S  v1, PT_EPC(sp)
                ori     $28, sp, _THREAD_MASK
                xori    $28, _THREAD_MASK
 #ifdef CONFIG_CPU_CAVIUM_OCTEON
index eecd2a9f155cf67d75f9409963caf339a1b3e1dd..9326af5186fe0f8a7a10cb8d69fabe56b7b4082b 100644 (file)
@@ -2,14 +2,17 @@
 # Makefile for the Linux/MIPS kernel.
 #
 
-CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS)
-
 extra-y                := head.o init_task.o vmlinux.lds
 
 obj-y          += cpu-probe.o branch.o entry.o genex.o irq.o process.o \
                   ptrace.o reset.o setup.o signal.o syscall.o \
                   time.o topology.o traps.o unaligned.o watch.o
 
+ifdef CONFIG_FUNCTION_TRACER
+CFLAGS_REMOVE_ftrace.o = -pg
+CFLAGS_REMOVE_early_printk.o = -pg
+endif
+
 obj-$(CONFIG_CEVT_BCM1480)     += cevt-bcm1480.o
 obj-$(CONFIG_CEVT_R4K_LIB)     += cevt-r4k.o
 obj-$(CONFIG_MIPS_MT_SMTC)     += cevt-smtc.o
@@ -19,6 +22,7 @@ obj-$(CONFIG_CEVT_SB1250)     += cevt-sb1250.o
 obj-$(CONFIG_CEVT_TXX9)                += cevt-txx9.o
 obj-$(CONFIG_CSRC_BCM1480)     += csrc-bcm1480.o
 obj-$(CONFIG_CSRC_IOASIC)      += csrc-ioasic.o
+obj-$(CONFIG_CSRC_POWERTV)     += csrc-powertv.o
 obj-$(CONFIG_CSRC_R4K_LIB)     += csrc-r4k.o
 obj-$(CONFIG_CSRC_SB1250)      += csrc-sb1250.o
 obj-$(CONFIG_SYNC_R4K)         += sync-r4k.o
@@ -26,6 +30,8 @@ obj-$(CONFIG_SYNC_R4K)                += sync-r4k.o
 obj-$(CONFIG_STACKTRACE)       += stacktrace.o
 obj-$(CONFIG_MODULES)          += mips_ksyms.o module.o
 
+obj-$(CONFIG_FUNCTION_TRACER)  += mcount.o ftrace.o
+
 obj-$(CONFIG_CPU_LOONGSON2)    += r4k_fpu.o r4k_switch.o
 obj-$(CONFIG_CPU_MIPS32)       += r4k_fpu.o r4k_switch.o
 obj-$(CONFIG_CPU_MIPS64)       += r4k_fpu.o r4k_switch.o
@@ -92,4 +98,8 @@ CFLAGS_cpu-bugs64.o   = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/n
 
 obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT)  += 8250-platform.o
 
+obj-$(CONFIG_MIPS_CPUFREQ)     += cpufreq/
+
 EXTRA_CFLAGS += -Werror
+
+CPPFLAGS_vmlinux.lds           := $(KBUILD_CFLAGS)
index 7a51866068a4796631cfd4132dc07d7918dc105f..80e202eca0562ecbbb9a0eba2db38f7ef464602a 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/ptrace.h>
 #include <linux/smp.h>
 #include <linux/stddef.h>
+#include <linux/module.h>
 
 #include <asm/bugs.h>
 #include <asm/cpu.h>
@@ -32,6 +33,7 @@
  * the CPU very much.
  */
 void (*cpu_wait)(void);
+EXPORT_SYMBOL(cpu_wait);
 
 static void r3081_wait(void)
 {
diff --git a/arch/mips/kernel/cpufreq/Kconfig b/arch/mips/kernel/cpufreq/Kconfig
new file mode 100644 (file)
index 0000000..58c601e
--- /dev/null
@@ -0,0 +1,41 @@
+#
+# CPU Frequency scaling
+#
+
+config MIPS_EXTERNAL_TIMER
+       bool
+
+config MIPS_CPUFREQ
+       bool
+       default y
+       depends on CPU_SUPPORTS_CPUFREQ && MIPS_EXTERNAL_TIMER
+
+if MIPS_CPUFREQ
+
+menu "CPU Frequency scaling"
+
+source "drivers/cpufreq/Kconfig"
+
+if CPU_FREQ
+
+comment "CPUFreq processor drivers"
+
+config LOONGSON2_CPUFREQ
+       tristate "Loongson2 CPUFreq Driver"
+       select CPU_FREQ_TABLE
+       depends on MIPS_CPUFREQ
+       help
+         This option adds a CPUFreq driver for loongson processors which
+         support software configurable cpu frequency.
+
+         Loongson2F and it's successors support this feature.
+
+         For details, take a look at <file:Documentation/cpu-freq/>.
+
+         If in doubt, say N.
+
+endif  # CPU_FREQ
+
+endmenu
+
+endif  # MIPS_CPUFREQ
diff --git a/arch/mips/kernel/cpufreq/Makefile b/arch/mips/kernel/cpufreq/Makefile
new file mode 100644 (file)
index 0000000..c3479a4
--- /dev/null
@@ -0,0 +1,5 @@
+#
+# Makefile for the Linux/MIPS cpufreq.
+#
+
+obj-$(CONFIG_LOONGSON2_CPUFREQ) += loongson2_cpufreq.o loongson2_clock.o
diff --git a/arch/mips/kernel/cpufreq/loongson2_clock.c b/arch/mips/kernel/cpufreq/loongson2_clock.c
new file mode 100644 (file)
index 0000000..d7ca256
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2006 - 2008 Lemote Inc. & Insititute of Computing Technology
+ * Author: Yanhua, yanh@lemote.com
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/cpufreq.h>
+#include <linux/platform_device.h>
+
+#include <asm/clock.h>
+
+#include <loongson.h>
+
+static LIST_HEAD(clock_list);
+static DEFINE_SPINLOCK(clock_lock);
+static DEFINE_MUTEX(clock_list_sem);
+
+/* Minimum CLK support */
+enum {
+       DC_ZERO, DC_25PT = 2, DC_37PT, DC_50PT, DC_62PT, DC_75PT,
+       DC_87PT, DC_DISABLE, DC_RESV
+};
+
+struct cpufreq_frequency_table loongson2_clockmod_table[] = {
+       {DC_RESV, CPUFREQ_ENTRY_INVALID},
+       {DC_ZERO, CPUFREQ_ENTRY_INVALID},
+       {DC_25PT, 0},
+       {DC_37PT, 0},
+       {DC_50PT, 0},
+       {DC_62PT, 0},
+       {DC_75PT, 0},
+       {DC_87PT, 0},
+       {DC_DISABLE, 0},
+       {DC_RESV, CPUFREQ_TABLE_END},
+};
+EXPORT_SYMBOL_GPL(loongson2_clockmod_table);
+
+static struct clk cpu_clk = {
+       .name = "cpu_clk",
+       .flags = CLK_ALWAYS_ENABLED | CLK_RATE_PROPAGATES,
+       .rate = 800000000,
+};
+
+struct clk *clk_get(struct device *dev, const char *id)
+{
+       return &cpu_clk;
+}
+EXPORT_SYMBOL(clk_get);
+
+static void propagate_rate(struct clk *clk)
+{
+       struct clk *clkp;
+
+       list_for_each_entry(clkp, &clock_list, node) {
+               if (likely(clkp->parent != clk))
+                       continue;
+               if (likely(clkp->ops && clkp->ops->recalc))
+                       clkp->ops->recalc(clkp);
+               if (unlikely(clkp->flags & CLK_RATE_PROPAGATES))
+                       propagate_rate(clkp);
+       }
+}
+
+int clk_enable(struct clk *clk)
+{
+       return 0;
+}
+EXPORT_SYMBOL(clk_enable);
+
+void clk_disable(struct clk *clk)
+{
+}
+EXPORT_SYMBOL(clk_disable);
+
+unsigned long clk_get_rate(struct clk *clk)
+{
+       return (unsigned long)clk->rate;
+}
+EXPORT_SYMBOL(clk_get_rate);
+
+void clk_put(struct clk *clk)
+{
+}
+EXPORT_SYMBOL(clk_put);
+
+int clk_set_rate(struct clk *clk, unsigned long rate)
+{
+       return clk_set_rate_ex(clk, rate, 0);
+}
+EXPORT_SYMBOL_GPL(clk_set_rate);
+
+int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id)
+{
+       int ret = 0;
+       int regval;
+       int i;
+
+       if (likely(clk->ops && clk->ops->set_rate)) {
+               unsigned long flags;
+
+               spin_lock_irqsave(&clock_lock, flags);
+               ret = clk->ops->set_rate(clk, rate, algo_id);
+               spin_unlock_irqrestore(&clock_lock, flags);
+       }
+
+       if (unlikely(clk->flags & CLK_RATE_PROPAGATES))
+               propagate_rate(clk);
+
+       for (i = 0; loongson2_clockmod_table[i].frequency != CPUFREQ_TABLE_END;
+            i++) {
+               if (loongson2_clockmod_table[i].frequency ==
+                   CPUFREQ_ENTRY_INVALID)
+                       continue;
+               if (rate == loongson2_clockmod_table[i].frequency)
+                       break;
+       }
+       if (rate != loongson2_clockmod_table[i].frequency)
+               return -ENOTSUPP;
+
+       clk->rate = rate;
+
+       regval = LOONGSON_CHIPCFG0;
+       regval = (regval & ~0x7) | (loongson2_clockmod_table[i].index - 1);
+       LOONGSON_CHIPCFG0 = regval;
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(clk_set_rate_ex);
+
+long clk_round_rate(struct clk *clk, unsigned long rate)
+{
+       if (likely(clk->ops && clk->ops->round_rate)) {
+               unsigned long flags, rounded;
+
+               spin_lock_irqsave(&clock_lock, flags);
+               rounded = clk->ops->round_rate(clk, rate);
+               spin_unlock_irqrestore(&clock_lock, flags);
+
+               return rounded;
+       }
+
+       return rate;
+}
+EXPORT_SYMBOL_GPL(clk_round_rate);
+
+/*
+ * This is the simple version of Loongson-2 wait, Maybe we need do this in
+ * interrupt disabled content
+ */
+
+DEFINE_SPINLOCK(loongson2_wait_lock);
+void loongson2_cpu_wait(void)
+{
+       u32 cpu_freq;
+       unsigned long flags;
+
+       spin_lock_irqsave(&loongson2_wait_lock, flags);
+       cpu_freq = LOONGSON_CHIPCFG0;
+       LOONGSON_CHIPCFG0 &= ~0x7;      /* Put CPU into wait mode */
+       LOONGSON_CHIPCFG0 = cpu_freq;   /* Restore CPU state */
+       spin_unlock_irqrestore(&loongson2_wait_lock, flags);
+}
+EXPORT_SYMBOL_GPL(loongson2_cpu_wait);
diff --git a/arch/mips/kernel/cpufreq/loongson2_cpufreq.c b/arch/mips/kernel/cpufreq/loongson2_cpufreq.c
new file mode 100644 (file)
index 0000000..2f6a0b1
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * Cpufreq driver for the loongson-2 processors
+ *
+ * The 2E revision of loongson processor not support this feature.
+ *
+ * Copyright (C) 2006 - 2008 Lemote Inc. & Insititute of Computing Technology
+ * Author: Yanhua, yanh@lemote.com
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/cpufreq.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/sched.h>       /* set_cpus_allowed() */
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+
+#include <asm/clock.h>
+
+#include <loongson.h>
+
+static uint nowait;
+
+static struct clk *cpuclk;
+
+static void (*saved_cpu_wait) (void);
+
+static int loongson2_cpu_freq_notifier(struct notifier_block *nb,
+                                       unsigned long val, void *data);
+
+static struct notifier_block loongson2_cpufreq_notifier_block = {
+       .notifier_call = loongson2_cpu_freq_notifier
+};
+
+static int loongson2_cpu_freq_notifier(struct notifier_block *nb,
+                                       unsigned long val, void *data)
+{
+       if (val == CPUFREQ_POSTCHANGE)
+               current_cpu_data.udelay_val = loops_per_jiffy;
+
+       return 0;
+}
+
+static unsigned int loongson2_cpufreq_get(unsigned int cpu)
+{
+       return clk_get_rate(cpuclk);
+}
+
+/*
+ * Here we notify other drivers of the proposed change and the final change.
+ */
+static int loongson2_cpufreq_target(struct cpufreq_policy *policy,
+                                    unsigned int target_freq,
+                                    unsigned int relation)
+{
+       unsigned int cpu = policy->cpu;
+       unsigned int newstate = 0;
+       cpumask_t cpus_allowed;
+       struct cpufreq_freqs freqs;
+       unsigned int freq;
+
+       if (!cpu_online(cpu))
+               return -ENODEV;
+
+       cpus_allowed = current->cpus_allowed;
+       set_cpus_allowed(current, cpumask_of_cpu(cpu));
+
+       if (cpufreq_frequency_table_target
+           (policy, &loongson2_clockmod_table[0], target_freq, relation,
+            &newstate))
+               return -EINVAL;
+
+       freq =
+           ((cpu_clock_freq / 1000) *
+            loongson2_clockmod_table[newstate].index) / 8;
+       if (freq < policy->min || freq > policy->max)
+               return -EINVAL;
+
+       pr_debug("cpufreq: requested frequency %u Hz\n", target_freq * 1000);
+
+       freqs.cpu = cpu;
+       freqs.old = loongson2_cpufreq_get(cpu);
+       freqs.new = freq;
+       freqs.flags = 0;
+
+       if (freqs.new == freqs.old)
+               return 0;
+
+       /* notifiers */
+       cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
+
+       set_cpus_allowed(current, cpus_allowed);
+
+       /* setting the cpu frequency */
+       clk_set_rate(cpuclk, freq);
+
+       /* notifiers */
+       cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+
+       pr_debug("cpufreq: set frequency %u kHz\n", freq);
+
+       return 0;
+}
+
+static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)
+{
+       int i;
+
+       if (!cpu_online(policy->cpu))
+               return -ENODEV;
+
+       cpuclk = clk_get(NULL, "cpu_clk");
+       if (IS_ERR(cpuclk)) {
+               printk(KERN_ERR "cpufreq: couldn't get CPU clk\n");
+               return PTR_ERR(cpuclk);
+       }
+
+       cpuclk->rate = cpu_clock_freq / 1000;
+       if (!cpuclk->rate)
+               return -EINVAL;
+
+       /* clock table init */
+       for (i = 2;
+            (loongson2_clockmod_table[i].frequency != CPUFREQ_TABLE_END);
+            i++)
+               loongson2_clockmod_table[i].frequency = (cpuclk->rate * i) / 8;
+
+       policy->cur = loongson2_cpufreq_get(policy->cpu);
+
+       cpufreq_frequency_table_get_attr(&loongson2_clockmod_table[0],
+                                        policy->cpu);
+
+       return cpufreq_frequency_table_cpuinfo(policy,
+                                           &loongson2_clockmod_table[0]);
+}
+
+static int loongson2_cpufreq_verify(struct cpufreq_policy *policy)
+{
+       return cpufreq_frequency_table_verify(policy,
+                                             &loongson2_clockmod_table[0]);
+}
+
+static int loongson2_cpufreq_exit(struct cpufreq_policy *policy)
+{
+       clk_put(cpuclk);
+       return 0;
+}
+
+static struct freq_attr *loongson2_table_attr[] = {
+       &cpufreq_freq_attr_scaling_available_freqs,
+       NULL,
+};
+
+static struct cpufreq_driver loongson2_cpufreq_driver = {
+       .owner = THIS_MODULE,
+       .name = "loongson2",
+       .init = loongson2_cpufreq_cpu_init,
+       .verify = loongson2_cpufreq_verify,
+       .target = loongson2_cpufreq_target,
+       .get = loongson2_cpufreq_get,
+       .exit = loongson2_cpufreq_exit,
+       .attr = loongson2_table_attr,
+};
+
+static struct platform_device_id platform_device_ids[] = {
+       {
+               .name = "loongson2_cpufreq",
+       },
+       {}
+};
+
+MODULE_DEVICE_TABLE(platform, platform_device_ids);
+
+static struct platform_driver platform_driver = {
+       .driver = {
+               .name = "loongson2_cpufreq",
+               .owner = THIS_MODULE,
+       },
+       .id_table = platform_device_ids,
+};
+
+static int __init cpufreq_init(void)
+{
+       int ret;
+
+       /* Register platform stuff */
+       ret = platform_driver_register(&platform_driver);
+       if (ret)
+               return ret;
+
+       pr_info("cpufreq: Loongson-2F CPU frequency driver.\n");
+
+       cpufreq_register_notifier(&loongson2_cpufreq_notifier_block,
+                                 CPUFREQ_TRANSITION_NOTIFIER);
+
+       ret = cpufreq_register_driver(&loongson2_cpufreq_driver);
+
+       if (!ret && !nowait) {
+               saved_cpu_wait = cpu_wait;
+               cpu_wait = loongson2_cpu_wait;
+       }
+
+       return ret;
+}
+
+static void __exit cpufreq_exit(void)
+{
+       if (!nowait && saved_cpu_wait)
+               cpu_wait = saved_cpu_wait;
+       cpufreq_unregister_driver(&loongson2_cpufreq_driver);
+       cpufreq_unregister_notifier(&loongson2_cpufreq_notifier_block,
+                                   CPUFREQ_TRANSITION_NOTIFIER);
+
+       platform_driver_unregister(&platform_driver);
+}
+
+module_init(cpufreq_init);
+module_exit(cpufreq_exit);
+
+module_param(nowait, uint, 0644);
+MODULE_PARM_DESC(nowait, "Disable Loongson-2F specific wait");
+
+MODULE_AUTHOR("Yanhua <yanh@lemote.com>");
+MODULE_DESCRIPTION("cpufreq driver for Loongson2F");
+MODULE_LICENSE("GPL");
diff --git a/arch/mips/kernel/csrc-powertv.c b/arch/mips/kernel/csrc-powertv.c
new file mode 100644 (file)
index 0000000..a27c16c
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2008 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+/*
+ * The file comes from kernel/csrc-r4k.c
+ */
+#include <linux/clocksource.h>
+#include <linux/init.h>
+
+#include <asm/time.h>                  /* Not included in linux/time.h */
+
+#include <asm/mach-powertv/asic_regs.h>
+#include "powertv-clock.h"
+
+/* MIPS PLL Register Definitions */
+#define PLL_GET_M(x)           (((x) >> 8) & 0x000000FF)
+#define PLL_GET_N(x)           (((x) >> 16) & 0x000000FF)
+#define PLL_GET_P(x)           (((x) >> 24) & 0x00000007)
+
+/*
+ * returns:  Clock frequency in kHz
+ */
+unsigned int __init mips_get_pll_freq(void)
+{
+       unsigned int pll_reg, m, n, p;
+       unsigned int fin = 54000; /* Base frequency in kHz */
+       unsigned int fout;
+
+       /* Read PLL register setting */
+       pll_reg = asic_read(mips_pll_setup);
+       m = PLL_GET_M(pll_reg);
+       n = PLL_GET_N(pll_reg);
+       p = PLL_GET_P(pll_reg);
+       pr_info("MIPS PLL Register:0x%x  M=%d  N=%d  P=%d\n", pll_reg, m, n, p);
+
+       /* Calculate clock frequency = (2 * N * 54MHz) / (M * (2**P)) */
+       fout = ((2 * n * fin) / (m * (0x01 << p)));
+
+       pr_info("MIPS Clock Freq=%d kHz\n", fout);
+
+       return fout;
+}
+
+static cycle_t c0_hpt_read(struct clocksource *cs)
+{
+       return read_c0_count();
+}
+
+static struct clocksource clocksource_mips = {
+       .name           = "powertv-counter",
+       .read           = c0_hpt_read,
+       .mask           = CLOCKSOURCE_MASK(32),
+       .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+static void __init powertv_c0_hpt_clocksource_init(void)
+{
+       unsigned int pll_freq = mips_get_pll_freq();
+
+       pr_info("CPU frequency %d.%02d MHz\n", pll_freq / 1000,
+               (pll_freq % 1000) * 100 / 1000);
+
+       mips_hpt_frequency = pll_freq / 2 * 1000;
+
+       clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
+
+       clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);
+
+       clocksource_register(&clocksource_mips);
+}
+
+/**
+ * struct tim_c - free running counter
+ * @hi:        High 16 bits of the counter
+ * @lo:        Low 32 bits of the counter
+ *
+ * Lays out the structure of the free running counter in memory. This counter
+ * increments at a rate of 27 MHz/8 on all platforms.
+ */
+struct tim_c {
+       unsigned int hi;
+       unsigned int lo;
+};
+
+static struct tim_c *tim_c;
+
+static cycle_t tim_c_read(struct clocksource *cs)
+{
+       unsigned int hi;
+       unsigned int next_hi;
+       unsigned int lo;
+
+       hi = readl(&tim_c->hi);
+
+       for (;;) {
+               lo = readl(&tim_c->lo);
+               next_hi = readl(&tim_c->hi);
+               if (next_hi == hi)
+                       break;
+               hi = next_hi;
+       }
+
+pr_crit("%s: read %llx\n", __func__, ((u64) hi << 32) | lo);
+       return ((u64) hi << 32) | lo;
+}
+
+#define TIM_C_SIZE             48              /* # bits in the timer */
+
+static struct clocksource clocksource_tim_c = {
+       .name           = "powertv-tim_c",
+       .read           = tim_c_read,
+       .mask           = CLOCKSOURCE_MASK(TIM_C_SIZE),
+       .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+/**
+ * powertv_tim_c_clocksource_init - set up a clock source for the TIM_C clock
+ *
+ * The hard part here is coming up with a constant k and shift s such that
+ * the 48-bit TIM_C value multiplied by k doesn't overflow and that value,
+ * when shifted right by s, yields the corresponding number of nanoseconds.
+ * We know that TIM_C counts at 27 MHz/8, so each cycle corresponds to
+ * 1 / (27,000,000/8) seconds. Multiply that by a billion and you get the
+ * number of nanoseconds. Since the TIM_C value has 48 bits and the math is
+ * done in 64 bits, avoiding an overflow means that k must be less than
+ * 64 - 48 = 16 bits.
+ */
+static void __init powertv_tim_c_clocksource_init(void)
+{
+       int                     prescale;
+       unsigned long           dividend;
+       unsigned long           k;
+       int                     s;
+       const int               max_k_bits = (64 - 48) - 1;
+       const unsigned long     billion = 1000000000;
+       const unsigned long     counts_per_second = 27000000 / 8;
+
+       prescale = BITS_PER_LONG - ilog2(billion) - 1;
+       dividend = billion << prescale;
+       k = dividend / counts_per_second;
+       s = ilog2(k) - max_k_bits;
+
+       if (s < 0)
+               s = prescale;
+
+       else {
+               k >>= s;
+               s += prescale;
+       }
+
+       clocksource_tim_c.mult = k;
+       clocksource_tim_c.shift = s;
+       clocksource_tim_c.rating = 200;
+
+       clocksource_register(&clocksource_tim_c);
+       tim_c = (struct tim_c *) asic_reg_addr(tim_ch);
+}
+
+/**
+ powertv_clocksource_init - initialize all clocksources
+ */
+void __init powertv_clocksource_init(void)
+{
+       powertv_c0_hpt_clocksource_init();
+       powertv_tim_c_clocksource_init();
+}
diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
new file mode 100644 (file)
index 0000000..68b0670
--- /dev/null
@@ -0,0 +1,275 @@
+/*
+ * Code for replacing ftrace calls with jumps.
+ *
+ * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
+ * Copyright (C) 2009 DSLab, Lanzhou University, China
+ * Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ * Thanks goes to Steven Rostedt for writing the original x86 version.
+ */
+
+#include <linux/uaccess.h>
+#include <linux/init.h>
+#include <linux/ftrace.h>
+
+#include <asm/cacheflush.h>
+#include <asm/asm.h>
+#include <asm/asm-offsets.h>
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+
+#define JAL 0x0c000000         /* jump & link: ip --> ra, jump to target */
+#define ADDR_MASK 0x03ffffff   /*  op_code|addr : 31...26|25 ....0 */
+#define jump_insn_encode(op_code, addr) \
+       ((unsigned int)((op_code) | (((addr) >> 2) & ADDR_MASK)))
+
+static unsigned int ftrace_nop = 0x00000000;
+
+static int ftrace_modify_code(unsigned long ip, unsigned int new_code)
+{
+       int faulted;
+
+       /* *(unsigned int *)ip = new_code; */
+       safe_store_code(new_code, ip, faulted);
+
+       if (unlikely(faulted))
+               return -EFAULT;
+
+       flush_icache_range(ip, ip + 8);
+
+       return 0;
+}
+
+static int lui_v1;
+static int jal_mcount;
+
+int ftrace_make_nop(struct module *mod,
+                   struct dyn_ftrace *rec, unsigned long addr)
+{
+       unsigned int new;
+       int faulted;
+       unsigned long ip = rec->ip;
+
+       /* We have compiled module with -mlong-calls, but compiled the kernel
+        * without it, we need to cope with them respectively. */
+       if (ip & 0x40000000) {
+               /* record it for ftrace_make_call */
+               if (lui_v1 == 0) {
+                       /* lui_v1 = *(unsigned int *)ip; */
+                       safe_load_code(lui_v1, ip, faulted);
+
+                       if (unlikely(faulted))
+                               return -EFAULT;
+               }
+
+               /* lui v1, hi_16bit_of_mcount        --> b 1f (0x10000004)
+                * addiu v1, v1, low_16bit_of_mcount
+                * move at, ra
+                * jalr v1
+                * nop
+                *                                   1f: (ip + 12)
+                */
+               new = 0x10000004;
+       } else {
+               /* record/calculate it for ftrace_make_call */
+               if (jal_mcount == 0) {
+                       /* We can record it directly like this:
+                        *     jal_mcount = *(unsigned int *)ip;
+                        * Herein, jump over the first two nop instructions */
+                       jal_mcount = jump_insn_encode(JAL, (MCOUNT_ADDR + 8));
+               }
+
+               /* move at, ra
+                * jalr v1              --> nop
+                */
+               new = ftrace_nop;
+       }
+       return ftrace_modify_code(ip, new);
+}
+
+static int modified;   /* initialized as 0 by default */
+
+int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
+{
+       unsigned int new;
+       unsigned long ip = rec->ip;
+
+       /* We just need to remove the "b ftrace_stub" at the fist time! */
+       if (modified == 0) {
+               modified = 1;
+               ftrace_modify_code(addr, ftrace_nop);
+       }
+       /* ip, module: 0xc0000000, kernel: 0x80000000 */
+       new = (ip & 0x40000000) ? lui_v1 : jal_mcount;
+
+       return ftrace_modify_code(ip, new);
+}
+
+#define FTRACE_CALL_IP ((unsigned long)(&ftrace_call))
+
+int ftrace_update_ftrace_func(ftrace_func_t func)
+{
+       unsigned int new;
+
+       new = jump_insn_encode(JAL, (unsigned long)func);
+
+       return ftrace_modify_code(FTRACE_CALL_IP, new);
+}
+
+int __init ftrace_dyn_arch_init(void *data)
+{
+       /* The return code is retured via data */
+       *(unsigned long *)data = 0;
+
+       return 0;
+}
+#endif                         /* CONFIG_DYNAMIC_FTRACE */
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+
+extern void ftrace_graph_call(void);
+#define JMP    0x08000000      /* jump to target directly */
+#define CALL_FTRACE_GRAPH_CALLER \
+       jump_insn_encode(JMP, (unsigned long)(&ftrace_graph_caller))
+#define FTRACE_GRAPH_CALL_IP   ((unsigned long)(&ftrace_graph_call))
+
+int ftrace_enable_ftrace_graph_caller(void)
+{
+       return ftrace_modify_code(FTRACE_GRAPH_CALL_IP,
+                                 CALL_FTRACE_GRAPH_CALLER);
+}
+
+int ftrace_disable_ftrace_graph_caller(void)
+{
+       return ftrace_modify_code(FTRACE_GRAPH_CALL_IP, ftrace_nop);
+}
+
+#endif                         /* !CONFIG_DYNAMIC_FTRACE */
+
+#ifndef KBUILD_MCOUNT_RA_ADDRESS
+#define S_RA_SP        (0xafbf << 16)  /* s{d,w} ra, offset(sp) */
+#define S_R_SP (0xafb0 << 16)  /* s{d,w} R, offset(sp) */
+#define OFFSET_MASK    0xffff  /* stack offset range: 0 ~ PT_SIZE */
+
+unsigned long ftrace_get_parent_addr(unsigned long self_addr,
+                                    unsigned long parent,
+                                    unsigned long parent_addr,
+                                    unsigned long fp)
+{
+       unsigned long sp, ip, ra;
+       unsigned int code;
+       int faulted;
+
+       /* in module or kernel? */
+       if (self_addr & 0x40000000) {
+               /* module: move to the instruction "lui v1, HI_16BIT_OF_MCOUNT" */
+               ip = self_addr - 20;
+       } else {
+               /* kernel: move to the instruction "move ra, at" */
+               ip = self_addr - 12;
+       }
+
+       /* search the text until finding the non-store instruction or "s{d,w}
+        * ra, offset(sp)" instruction */
+       do {
+               ip -= 4;
+
+               /* get the code at "ip": code = *(unsigned int *)ip; */
+               safe_load_code(code, ip, faulted);
+
+               if (unlikely(faulted))
+                       return 0;
+
+               /* If we hit the non-store instruction before finding where the
+                * ra is stored, then this is a leaf function and it does not
+                * store the ra on the stack. */
+               if ((code & S_R_SP) != S_R_SP)
+                       return parent_addr;
+
+       } while (((code & S_RA_SP) != S_RA_SP));
+
+       sp = fp + (code & OFFSET_MASK);
+
+       /* ra = *(unsigned long *)sp; */
+       safe_load_stack(ra, sp, faulted);
+       if (unlikely(faulted))
+               return 0;
+
+       if (ra == parent)
+               return sp;
+       return 0;
+}
+
+#endif
+
+/*
+ * Hook the return address and push it in the stack of return addrs
+ * in current thread info.
+ */
+void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
+                          unsigned long fp)
+{
+       unsigned long old;
+       struct ftrace_graph_ent trace;
+       unsigned long return_hooker = (unsigned long)
+           &return_to_handler;
+       int faulted;
+
+       if (unlikely(atomic_read(&current->tracing_graph_pause)))
+               return;
+
+       /* "parent" is the stack address saved the return address of the caller
+        * of _mcount.
+        *
+        * if the gcc < 4.5, a leaf function does not save the return address
+        * in the stack address, so, we "emulate" one in _mcount's stack space,
+        * and hijack it directly, but for a non-leaf function, it save the
+        * return address to the its own stack space, we can not hijack it
+        * directly, but need to find the real stack address,
+        * ftrace_get_parent_addr() does it!
+        *
+        * if gcc>= 4.5, with the new -mmcount-ra-address option, for a
+        * non-leaf function, the location of the return address will be saved
+        * to $12 for us, and for a leaf function, only put a zero into $12. we
+        * do it in ftrace_graph_caller of mcount.S.
+        */
+
+       /* old = *parent; */
+       safe_load_stack(old, parent, faulted);
+       if (unlikely(faulted))
+               goto out;
+#ifndef KBUILD_MCOUNT_RA_ADDRESS
+       parent = (unsigned long *)ftrace_get_parent_addr(self_addr, old,
+                                                        (unsigned long)parent,
+                                                        fp);
+       /* If fails when getting the stack address of the non-leaf function's
+        * ra, stop function graph tracer and return */
+       if (parent == 0)
+               goto out;
+#endif
+       /* *parent = return_hooker; */
+       safe_store_stack(return_hooker, parent, faulted);
+       if (unlikely(faulted))
+               goto out;
+
+       if (ftrace_push_return_trace(old, self_addr, &trace.depth, fp) ==
+           -EBUSY) {
+               *parent = old;
+               return;
+       }
+
+       trace.func = self_addr;
+
+       /* Only trace if the calling function expects to */
+       if (!ftrace_graph_entry(&trace)) {
+               current->curr_ret_stack--;
+               *parent = old;
+       }
+       return;
+out:
+       ftrace_graph_stop();
+       WARN_ON(1);
+}
+#endif                         /* CONFIG_FUNCTION_GRAPH_TRACER */
index 7b845ba9dff4cf565394393dbb1e24f497e5aed4..981f86c26168ca9b838fecc8e627663a04e82017 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/seq_file.h>
 #include <linux/kallsyms.h>
 #include <linux/kgdb.h>
+#include <linux/ftrace.h>
 
 #include <asm/atomic.h>
 #include <asm/system.h>
@@ -99,7 +100,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -118,7 +119,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        } else if (i == NR_IRQS) {
                seq_putc(p, '\n');
                seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
@@ -150,3 +151,32 @@ void __init init_IRQ(void)
                kgdb_early_setup = 1;
 #endif
 }
+
+/*
+ * do_IRQ handles all normal device IRQ's (the special
+ * SMP cross-CPU interrupts have their own specific
+ * handlers).
+ */
+void __irq_entry do_IRQ(unsigned int irq)
+{
+       irq_enter();
+       __DO_IRQ_SMTC_HOOK(irq);
+       generic_handle_irq(irq);
+       irq_exit();
+}
+
+#ifdef CONFIG_MIPS_MT_SMTC_IRQAFF
+/*
+ * To avoid inefficient and in some cases pathological re-checking of
+ * IRQ affinity, we have this variant that skips the affinity check.
+ */
+
+void __irq_entry do_IRQ_no_affinity(unsigned int irq)
+{
+       irq_enter();
+       __NO_AFFINITY_IRQ_SMTC_HOOK(irq);
+       generic_handle_irq(irq);
+       irq_exit();
+}
+
+#endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
new file mode 100644 (file)
index 0000000..0a9cfdb
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * MIPS specific _mcount support
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive for
+ * more details.
+ *
+ * Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China
+ * Author: Wu Zhangjin <wuzj@lemote.com>
+ */
+
+#include <asm/regdef.h>
+#include <asm/stackframe.h>
+#include <asm/ftrace.h>
+
+       .text
+       .set noreorder
+       .set noat
+
+       .macro MCOUNT_SAVE_REGS
+       PTR_SUBU        sp, PT_SIZE
+       PTR_S   ra, PT_R31(sp)
+       PTR_S   AT, PT_R1(sp)
+       PTR_S   a0, PT_R4(sp)
+       PTR_S   a1, PT_R5(sp)
+       PTR_S   a2, PT_R6(sp)
+       PTR_S   a3, PT_R7(sp)
+#ifdef CONFIG_64BIT
+       PTR_S   a4, PT_R8(sp)
+       PTR_S   a5, PT_R9(sp)
+       PTR_S   a6, PT_R10(sp)
+       PTR_S   a7, PT_R11(sp)
+#endif
+       .endm
+
+       .macro MCOUNT_RESTORE_REGS
+       PTR_L   ra, PT_R31(sp)
+       PTR_L   AT, PT_R1(sp)
+       PTR_L   a0, PT_R4(sp)
+       PTR_L   a1, PT_R5(sp)
+       PTR_L   a2, PT_R6(sp)
+       PTR_L   a3, PT_R7(sp)
+#ifdef CONFIG_64BIT
+       PTR_L   a4, PT_R8(sp)
+       PTR_L   a5, PT_R9(sp)
+       PTR_L   a6, PT_R10(sp)
+       PTR_L   a7, PT_R11(sp)
+#endif
+#ifdef CONFIG_64BIT
+       PTR_ADDIU       sp, PT_SIZE
+#else
+       PTR_ADDIU       sp, (PT_SIZE + 8)
+#endif
+.endm
+
+       .macro RETURN_BACK
+       jr ra
+        move ra, AT
+       .endm
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+
+NESTED(ftrace_caller, PT_SIZE, ra)
+       .globl _mcount
+_mcount:
+       b       ftrace_stub
+        nop
+       lw      t1, function_trace_stop
+       bnez    t1, ftrace_stub
+        nop
+
+       MCOUNT_SAVE_REGS
+#ifdef KBUILD_MCOUNT_RA_ADDRESS
+       PTR_S   t0, PT_R12(sp)  /* t0 saved the location of the return address(at) by -mmcount-ra-address */
+#endif
+
+       move    a0, ra          /* arg1: next ip, selfaddr */
+       .globl ftrace_call
+ftrace_call:
+       nop     /* a placeholder for the call to a real tracing function */
+        move   a1, AT          /* arg2: the caller's next ip, parent */
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+       .globl ftrace_graph_call
+ftrace_graph_call:
+       nop
+        nop
+#endif
+
+       MCOUNT_RESTORE_REGS
+       .globl ftrace_stub
+ftrace_stub:
+       RETURN_BACK
+       END(ftrace_caller)
+
+#else  /* ! CONFIG_DYNAMIC_FTRACE */
+
+NESTED(_mcount, PT_SIZE, ra)
+       lw      t1, function_trace_stop
+       bnez    t1, ftrace_stub
+        nop
+       PTR_LA  t1, ftrace_stub
+       PTR_L   t2, ftrace_trace_function /* Prepare t2 for (1) */
+       bne     t1, t2, static_trace
+        nop
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+       PTR_L   t3, ftrace_graph_return
+       bne     t1, t3, ftrace_graph_caller
+        nop
+       PTR_LA  t1, ftrace_graph_entry_stub
+       PTR_L   t3, ftrace_graph_entry
+       bne     t1, t3, ftrace_graph_caller
+        nop
+#endif
+       b       ftrace_stub
+        nop
+
+static_trace:
+       MCOUNT_SAVE_REGS
+
+       move    a0, ra          /* arg1: next ip, selfaddr */
+       jalr    t2              /* (1) call *ftrace_trace_function */
+        move   a1, AT          /* arg2: the caller's next ip, parent */
+
+       MCOUNT_RESTORE_REGS
+       .globl ftrace_stub
+ftrace_stub:
+       RETURN_BACK
+       END(_mcount)
+
+#endif /* ! CONFIG_DYNAMIC_FTRACE */
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+
+NESTED(ftrace_graph_caller, PT_SIZE, ra)
+#ifdef CONFIG_DYNAMIC_FTRACE
+       PTR_L   a1, PT_R31(sp)  /* load the original ra from the stack */
+#ifdef KBUILD_MCOUNT_RA_ADDRESS
+       PTR_L   t0, PT_R12(sp)  /* load the original t0 from the stack */
+#endif
+#else
+       MCOUNT_SAVE_REGS
+       move    a1, ra          /* arg2: next ip, selfaddr */
+#endif
+
+#ifdef KBUILD_MCOUNT_RA_ADDRESS
+       bnez    t0, 1f          /* non-leaf func: t0 saved the location of the return address */
+        nop
+       PTR_LA  t0, PT_R1(sp)   /* leaf func: get the location of at(old ra) from our own stack */
+1:     move    a0, t0          /* arg1: the location of the return address */
+#else
+       PTR_LA  a0, PT_R1(sp)   /* arg1: &AT -> a0 */
+#endif
+       jal     prepare_ftrace_return
+#ifdef CONFIG_FRAME_POINTER
+        move   a2, fp          /* arg3: frame pointer */
+#else
+#ifdef CONFIG_64BIT
+        PTR_LA a2, PT_SIZE(sp)
+#else
+        PTR_LA a2, (PT_SIZE+8)(sp)
+#endif
+#endif
+
+       MCOUNT_RESTORE_REGS
+       RETURN_BACK
+       END(ftrace_graph_caller)
+
+       .align  2
+       .globl  return_to_handler
+return_to_handler:
+       PTR_SUBU        sp, PT_SIZE
+       PTR_S   v0, PT_R2(sp)
+
+       jal     ftrace_return_to_handler
+        PTR_S  v1, PT_R3(sp)
+
+       /* restore the real parent address: v0 -> ra */
+       move    ra, v0
+
+       PTR_L   v0, PT_R2(sp)
+       PTR_L   v1, PT_R3(sp)
+       jr      ra
+        PTR_ADDIU      sp, PT_SIZE
+#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
+       .set at
+       .set reorder
index 225755d0c1f651479b7190562bdb2b0506f5b276..1d04807874db4b48af8f80e518e729f531e37fc2 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/checksum.h>
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
+#include <asm/ftrace.h>
 
 extern void *__bzero(void *__s, size_t __count);
 extern long __strncpy_from_user_nocheck_asm(char *__to,
@@ -51,3 +52,7 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck);
 EXPORT_SYMBOL(__csum_partial_copy_user);
 
 EXPORT_SYMBOL(invalid_pte_table);
+#ifdef CONFIG_FUNCTION_TRACER
+/* _mcount is defined in arch/mips/kernel/mcount.S */
+EXPORT_SYMBOL(_mcount);
+#endif
index 2b290d70083ebc6548deafc96b0a706d4fa445e7..f9513f9e61d3f13973b36ec7bf6611db242afc24 100644 (file)
@@ -58,8 +58,12 @@ EXPORT_SYMBOL(mips_machtype);
 
 struct boot_mem_map boot_mem_map;
 
-static char command_line[CL_SIZE];
-       char arcs_cmdline[CL_SIZE]=CONFIG_CMDLINE;
+static char __initdata command_line[COMMAND_LINE_SIZE];
+char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
+
+#ifdef CONFIG_CMDLINE_BOOL
+static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
+#endif
 
 /*
  * mips_io_port_base is the begin of the address space to which x86 style
@@ -166,26 +170,8 @@ static unsigned long __init init_initrd(void)
         * already set up initrd_start and initrd_end. In these cases
         * perfom sanity checks and use them if all looks good.
         */
-       if (!initrd_start || initrd_end <= initrd_start) {
-#ifdef CONFIG_PROBE_INITRD_HEADER
-               u32 *initrd_header;
-
-               /*
-                * See if initrd has been added to the kernel image by
-                * arch/mips/boot/addinitrd.c. In that case a header is
-                * prepended to initrd and is made up by 8 bytes. The first
-                * word is a magic number and the second one is the size of
-                * initrd.  Initrd start must be page aligned in any cases.
-                */
-               initrd_header = __va(PAGE_ALIGN(__pa_symbol(&_end) + 8)) - 8;
-               if (initrd_header[0] != 0x494E5244)
-                       goto disable;
-               initrd_start = (unsigned long)(initrd_header + 2);
-               initrd_end = initrd_start + initrd_header[1];
-#else
+       if (!initrd_start || initrd_end <= initrd_start)
                goto disable;
-#endif
-       }
 
        if (initrd_start & ~PAGE_MASK) {
                pr_err("initrd start must be page aligned\n");
@@ -476,8 +462,20 @@ static void __init arch_mem_init(char **cmdline_p)
        pr_info("Determined physical RAM map:\n");
        print_memory_map();
 
-       strlcpy(command_line, arcs_cmdline, sizeof(command_line));
-       strlcpy(boot_command_line, command_line, COMMAND_LINE_SIZE);
+#ifdef CONFIG_CMDLINE_BOOL
+#ifdef CONFIG_CMDLINE_OVERRIDE
+       strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+#else
+       if (builtin_cmdline[0]) {
+               strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
+               strlcat(arcs_cmdline, builtin_cmdline, COMMAND_LINE_SIZE);
+       }
+       strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
+#endif
+#else
+       strlcpy(boot_command_line, arcs_cmdline, COMMAND_LINE_SIZE);
+#endif
+       strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
 
        *cmdline_p = command_line;
 
index 6254041b942f9a9b56295024a0fd1320fb2da6ae..d0c68b5d717bce3fde6979d2eeee5e5ac6ea7094 100644 (file)
 
 #include "signal-common.h"
 
+static int (*save_fp_context)(struct sigcontext __user *sc);
+static int (*restore_fp_context)(struct sigcontext __user *sc);
+
+extern asmlinkage int _save_fp_context(struct sigcontext __user *sc);
+extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc);
+
+extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *sc);
+extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __user *sc);
+
 /*
  * Horribly complicated - with the bloody RM9000 workarounds enabled
  * the signal trampolines is moving to the end of the structure so we can
@@ -709,3 +718,40 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
                        key_replace_session_keyring();
        }
 }
+
+#ifdef CONFIG_SMP
+static int smp_save_fp_context(struct sigcontext __user *sc)
+{
+       return raw_cpu_has_fpu
+              ? _save_fp_context(sc)
+              : fpu_emulator_save_context(sc);
+}
+
+static int smp_restore_fp_context(struct sigcontext __user *sc)
+{
+       return raw_cpu_has_fpu
+              ? _restore_fp_context(sc)
+              : fpu_emulator_restore_context(sc);
+}
+#endif
+
+static int signal_setup(void)
+{
+#ifdef CONFIG_SMP
+       /* For now just do the cpu_has_fpu check when the functions are invoked */
+       save_fp_context = smp_save_fp_context;
+       restore_fp_context = smp_restore_fp_context;
+#else
+       if (cpu_has_fpu) {
+               save_fp_context = _save_fp_context;
+               restore_fp_context = _restore_fp_context;
+       } else {
+               save_fp_context = fpu_emulator_save_context;
+               restore_fp_context = fpu_emulator_restore_context;
+       }
+#endif
+
+       return 0;
+}
+
+arch_initcall(signal_setup);
index 2e74075ac0cadcc7c64b92fa98f3a0d7794ae479..03abaf048f09b3257ad7240378a53e6ddcc5588d 100644 (file)
 
 #include "signal-common.h"
 
+static int (*save_fp_context32)(struct sigcontext32 __user *sc);
+static int (*restore_fp_context32)(struct sigcontext32 __user *sc);
+
+extern asmlinkage int _save_fp_context32(struct sigcontext32 __user *sc);
+extern asmlinkage int _restore_fp_context32(struct sigcontext32 __user *sc);
+
+extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 __user *sc);
+extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 __user *sc);
+
 /*
  * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
  */
@@ -828,3 +837,18 @@ SYSCALL_DEFINE5(32_waitid, int, which, compat_pid_t, pid,
        info.si_code |= __SI_CHLD;
        return copy_siginfo_to_user32(uinfo, &info);
 }
+
+static int signal32_init(void)
+{
+       if (cpu_has_fpu) {
+               save_fp_context32 = _save_fp_context32;
+               restore_fp_context32 = _restore_fp_context32;
+       } else {
+               save_fp_context32 = fpu_emulator_save_context32;
+               restore_fp_context32 = fpu_emulator_restore_context32;
+       }
+
+       return 0;
+}
+
+arch_initcall(signal32_init);
index e72e6844d134759218227bee63faac5f2d9bbea8..6cdca1956b77c0f829cf507b57d19916b74cfad9 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/cpumask.h>
 #include <linux/cpu.h>
 #include <linux/err.h>
+#include <linux/ftrace.h>
 
 #include <asm/atomic.h>
 #include <asm/cpu.h>
@@ -130,7 +131,7 @@ asmlinkage __cpuinit void start_secondary(void)
 /*
  * Call into both interrupt handlers, as we share the IPI for them
  */
-void smp_call_function_interrupt(void)
+void __irq_entry smp_call_function_interrupt(void)
 {
        irq_enter();
        generic_smp_call_function_single_interrupt();
index a38e3ee95515deedddb56c9c5a5c2b8cb3275c3b..23499b5bd9c3d42f79352d5dd75243a8b49f96dd 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 #include <linux/module.h>
+#include <linux/ftrace.h>
 
 #include <asm/cpu.h>
 #include <asm/processor.h>
@@ -939,23 +940,29 @@ static void ipi_call_interrupt(void)
 
 DECLARE_PER_CPU(struct clock_event_device, mips_clockevent_device);
 
-void ipi_decode(struct smtc_ipi *pipi)
+static void __irq_entry smtc_clock_tick_interrupt(void)
 {
        unsigned int cpu = smp_processor_id();
        struct clock_event_device *cd;
+       int irq = MIPS_CPU_IRQ_BASE + 1;
+
+       irq_enter();
+       kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
+       cd = &per_cpu(mips_clockevent_device, cpu);
+       cd->event_handler(cd);
+       irq_exit();
+}
+
+void ipi_decode(struct smtc_ipi *pipi)
+{
        void *arg_copy = pipi->arg;
        int type_copy = pipi->type;
-       int irq = MIPS_CPU_IRQ_BASE + 1;
 
        smtc_ipi_nq(&freeIPIq, pipi);
 
        switch (type_copy) {
        case SMTC_CLOCK_TICK:
-               irq_enter();
-               kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
-               cd = &per_cpu(mips_clockevent_device, cpu);
-               cd->event_handler(cd);
-               irq_exit();
+               smtc_clock_tick_interrupt();
                break;
 
        case LINUX_SMP_IPI:
index 0a18b4c62afb3f2f5a849d182a0c41d022d5b607..308e434608647a2b1f1df35a8486bb9c3275f25e 100644 (file)
 #include <linux/ptrace.h>
 #include <linux/kgdb.h>
 #include <linux/kdebug.h>
+#include <linux/notifier.h>
 
 #include <asm/bootinfo.h>
 #include <asm/branch.h>
 #include <asm/break.h>
+#include <asm/cop2.h>
 #include <asm/cpu.h>
 #include <asm/dsp.h>
 #include <asm/fpu.h>
@@ -79,10 +81,6 @@ extern asmlinkage void handle_reserved(void);
 extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
        struct mips_fpu_struct *ctx, int has_fpu);
 
-#ifdef CONFIG_CPU_CAVIUM_OCTEON
-extern asmlinkage void octeon_cop2_restore(struct octeon_cop2_state *task);
-#endif
-
 void (*board_be_init)(void);
 int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
 void (*board_nmi_handler_setup)(void);
@@ -857,6 +855,44 @@ static void mt_ase_fp_affinity(void)
 #endif /* CONFIG_MIPS_MT_FPAFF */
 }
 
+/*
+ * No lock; only written during early bootup by CPU 0.
+ */
+static RAW_NOTIFIER_HEAD(cu2_chain);
+
+int __ref register_cu2_notifier(struct notifier_block *nb)
+{
+       return raw_notifier_chain_register(&cu2_chain, nb);
+}
+
+int cu2_notifier_call_chain(unsigned long val, void *v)
+{
+       return raw_notifier_call_chain(&cu2_chain, val, v);
+}
+
+static int default_cu2_call(struct notifier_block *nfb, unsigned long action,
+        void *data)
+{
+       struct pt_regs *regs = data;
+
+       switch (action) {
+       default:
+               die_if_kernel("Unhandled kernel unaligned access or invalid "
+                             "instruction", regs);
+               /* Fall through  */
+
+       case CU2_EXCEPTION:
+               force_sig(SIGILL, current);
+       }
+
+       return NOTIFY_OK;
+}
+
+static struct notifier_block default_cu2_notifier = {
+       .notifier_call  = default_cu2_call,
+       .priority       = 0x80000000,           /* Run last  */
+};
+
 asmlinkage void do_cpu(struct pt_regs *regs)
 {
        unsigned int __user *epc;
@@ -920,17 +956,9 @@ asmlinkage void do_cpu(struct pt_regs *regs)
                return;
 
        case 2:
-#ifdef CONFIG_CPU_CAVIUM_OCTEON
-               prefetch(&current->thread.cp2);
-               local_irq_save(flags);
-               KSTK_STATUS(current) |= ST0_CU2;
-               status = read_c0_status();
-               write_c0_status(status | ST0_CU2);
-               octeon_cop2_restore(&(current->thread.cp2));
-               write_c0_status(status & ~ST0_CU2);
-               local_irq_restore(flags);
-               return;
-#endif
+               raw_notifier_call_chain(&cu2_chain, CU2_EXCEPTION, regs);
+               break;
+
        case 3:
                break;
        }
@@ -1367,77 +1395,6 @@ void *set_vi_handler(int n, vi_handler_t addr)
        return set_vi_srs_handler(n, addr, 0);
 }
 
-/*
- * This is used by native signal handling
- */
-asmlinkage int (*save_fp_context)(struct sigcontext __user *sc);
-asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc);
-
-extern asmlinkage int _save_fp_context(struct sigcontext __user *sc);
-extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc);
-
-extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *sc);
-extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __user *sc);
-
-#ifdef CONFIG_SMP
-static int smp_save_fp_context(struct sigcontext __user *sc)
-{
-       return raw_cpu_has_fpu
-              ? _save_fp_context(sc)
-              : fpu_emulator_save_context(sc);
-}
-
-static int smp_restore_fp_context(struct sigcontext __user *sc)
-{
-       return raw_cpu_has_fpu
-              ? _restore_fp_context(sc)
-              : fpu_emulator_restore_context(sc);
-}
-#endif
-
-static inline void signal_init(void)
-{
-#ifdef CONFIG_SMP
-       /* For now just do the cpu_has_fpu check when the functions are invoked */
-       save_fp_context = smp_save_fp_context;
-       restore_fp_context = smp_restore_fp_context;
-#else
-       if (cpu_has_fpu) {
-               save_fp_context = _save_fp_context;
-               restore_fp_context = _restore_fp_context;
-       } else {
-               save_fp_context = fpu_emulator_save_context;
-               restore_fp_context = fpu_emulator_restore_context;
-       }
-#endif
-}
-
-#ifdef CONFIG_MIPS32_COMPAT
-
-/*
- * This is used by 32-bit signal stuff on the 64-bit kernel
- */
-asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc);
-asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *sc);
-
-extern asmlinkage int _save_fp_context32(struct sigcontext32 __user *sc);
-extern asmlinkage int _restore_fp_context32(struct sigcontext32 __user *sc);
-
-extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 __user *sc);
-extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 __user *sc);
-
-static inline void signal32_init(void)
-{
-       if (cpu_has_fpu) {
-               save_fp_context32 = _save_fp_context32;
-               restore_fp_context32 = _restore_fp_context32;
-       } else {
-               save_fp_context32 = fpu_emulator_save_context32;
-               restore_fp_context32 = fpu_emulator_restore_context32;
-       }
-}
-#endif
-
 extern void cpu_cache_init(void);
 extern void tlb_init(void);
 extern void flush_tlb_handlers(void);
@@ -1751,13 +1708,10 @@ void __init trap_init(void)
        else
                memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80);
 
-       signal_init();
-#ifdef CONFIG_MIPS32_COMPAT
-       signal32_init();
-#endif
-
        local_flush_icache_range(ebase, ebase + 0x400);
        flush_tlb_handlers();
 
        sort_extable(__start___dbe_table, __stop___dbe_table);
+
+       register_cu2_notifier(&default_cu2_notifier);
 }
index 67bd626942ab044de7b3b6b7e7261f4e1439dc21..69b039ca8d8337e60ecead9e32fbe7bd64659a64 100644 (file)
@@ -81,6 +81,7 @@
 #include <asm/asm.h>
 #include <asm/branch.h>
 #include <asm/byteorder.h>
+#include <asm/cop2.h>
 #include <asm/inst.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -451,17 +452,27 @@ static void emulate_load_store_insn(struct pt_regs *regs,
                 */
                goto sigbus;
 
+       /*
+        * COP2 is available to implementor for application specific use.
+        * It's up to applications to register a notifier chain and do
+        * whatever they have to do, including possible sending of signals.
+        */
        case lwc2_op:
+               cu2_notifier_call_chain(CU2_LWC2_OP, regs);
+               break;
+
        case ldc2_op:
+               cu2_notifier_call_chain(CU2_LDC2_OP, regs);
+               break;
+
        case swc2_op:
+               cu2_notifier_call_chain(CU2_SWC2_OP, regs);
+               break;
+
        case sdc2_op:
-               /*
-                * These are the coprocessor 2 load/stores.  The current
-                * implementations don't use cp2 and cp2 should always be
-                * disabled in c0_status.  So send SIGILL.
-                 * (No longer true: The Sony Praystation uses cp2 for
-                 * 3D matrix operations.  Dunno if that thingy has a MMU ...)
-                */
+               cu2_notifier_call_chain(CU2_SDC2_OP, regs);
+               break;
+
        default:
                /*
                 * Pheeee...  We encountered an yet unknown instruction or
index 162b29954baaa804be135b28fbbe482e56b853d3..f25df73db923a792b9debd05ba6184fca0030f41 100644 (file)
@@ -46,6 +46,7 @@ SECTIONS
                SCHED_TEXT
                LOCK_TEXT
                KPROBES_TEXT
+               IRQENTRY_TEXT
                *(.text.*)
                *(.fixup)
                *(.gnu.warning)
index 0bb6037afba3622ae0792842d3ceadae97f2c773..8e388da1926f2237c673c5dd972d5580b1b65f4e 100644 (file)
@@ -4,12 +4,14 @@
  * Brian Murphy <brian.murphy@eicon.com>
  *
  */
+#include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/interrupt.h>
 
 #include <linux/timer.h>
@@ -38,12 +40,9 @@ static void pvc_display(unsigned long data)
 
 static DECLARE_TASKLET(pvc_display_tasklet, &pvc_display, 0);
 
-static int pvc_proc_read_line(char *page, char **start,
-                            off_t off, int count,
-                            int *eof, void *data)
+static int pvc_line_proc_show(struct seq_file *m, void *v)
 {
-       char *origpage = page;
-       int lineno = *(int *)data;
+       int lineno = *(int *)m->private;
 
        if (lineno < 0 || lineno > PVC_NLINES) {
                printk(KERN_WARNING "proc_read_line: invalid lineno %d\n", lineno);
@@ -51,45 +50,66 @@ static int pvc_proc_read_line(char *page, char **start,
        }
 
        mutex_lock(&pvc_mutex);
-       page += sprintf(page, "%s\n", pvc_lines[lineno]);
+       seq_printf(m, "%s\n", pvc_lines[lineno]);
        mutex_unlock(&pvc_mutex);
 
-       return page - origpage;
+       return 0;
 }
 
-static int pvc_proc_write_line(struct file *file, const char *buffer,
-                          unsigned long count, void *data)
+static int pvc_line_proc_open(struct inode *inode, struct file *file)
 {
-       int origcount = count;
-       int lineno = *(int *)data;
+       return single_open(file, pvc_line_proc_show, PDE(inode)->data);
+}
 
-       if (lineno < 0 || lineno > PVC_NLINES) {
-               printk(KERN_WARNING "proc_write_line: invalid lineno %d\n",
-                      lineno);
-               return origcount;
-       }
+static ssize_t pvc_line_proc_write(struct file *file, const char __user *buf,
+                                  size_t count, loff_t *pos)
+{
+       int lineno = *(int *)PDE(file->f_path.dentry->d_inode)->data;
+       char kbuf[PVC_LINELEN];
+       size_t len;
+
+       BUG_ON(lineno < 0 || lineno > PVC_NLINES);
 
-       if (count > PVC_LINELEN)
-               count = PVC_LINELEN;
+       len = min(count, sizeof(kbuf) - 1);
+       if (copy_from_user(kbuf, buf, len))
+               return -EFAULT;
+       kbuf[len] = '\0';
 
-       if (buffer[count-1] == '\n')
-               count--;
+       if (len > 0 && kbuf[len - 1] == '\n')
+               len--;
 
        mutex_lock(&pvc_mutex);
-       strncpy(pvc_lines[lineno], buffer, count);
-       pvc_lines[lineno][count] = '\0';
+       strncpy(pvc_lines[lineno], kbuf, len);
+       pvc_lines[lineno][len] = '\0';
        mutex_unlock(&pvc_mutex);
 
        tasklet_schedule(&pvc_display_tasklet);
 
-       return origcount;
+       return count;
 }
 
-static int pvc_proc_write_scroll(struct file *file, const char *buffer,
-                          unsigned long count, void *data)
+static const struct file_operations pvc_line_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = pvc_line_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = pvc_line_proc_write,
+};
+
+static ssize_t pvc_scroll_proc_write(struct file *file, const char __user *buf,
+                                    size_t count, loff_t *pos)
 {
-       int origcount = count;
-       int cmd = simple_strtol(buffer, NULL, 10);
+       char kbuf[42];
+       size_t len;
+       int cmd;
+
+       len = min(count, sizeof(kbuf) - 1);
+       if (copy_from_user(kbuf, buf, len))
+               return -EFAULT;
+       kbuf[len] = '\0';
+
+       cmd = simple_strtol(kbuf, NULL, 10);
 
        mutex_lock(&pvc_mutex);
        if (scroll_interval != 0)
@@ -110,22 +130,31 @@ static int pvc_proc_write_scroll(struct file *file, const char *buffer,
        }
        mutex_unlock(&pvc_mutex);
 
-       return origcount;
+       return count;
 }
 
-static int pvc_proc_read_scroll(char *page, char **start,
-                            off_t off, int count,
-                            int *eof, void *data)
+static int pvc_scroll_proc_show(struct seq_file *m, void *v)
 {
-       char *origpage = page;
-
        mutex_lock(&pvc_mutex);
-       page += sprintf(page, "%d\n", scroll_dir * scroll_interval);
+       seq_printf(m, "%d\n", scroll_dir * scroll_interval);
        mutex_unlock(&pvc_mutex);
 
-       return page - origpage;
+       return 0;
 }
 
+static int pvc_scroll_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, pvc_scroll_proc_show, NULL);
+}
+
+static const struct file_operations pvc_scroll_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = pvc_scroll_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = pvc_scroll_proc_write,
+};
 
 void pvc_proc_timerfunc(unsigned long data)
 {
@@ -163,22 +192,16 @@ static int __init pvc_proc_init(void)
                pvc_linedata[i] = i;
        }
        for (i = 0; i < PVC_NLINES; i++) {
-               proc_entry = create_proc_entry(pvc_linename[i], 0644,
-                                              pvc_display_dir);
+               proc_entry = proc_create_data(pvc_linename[i], 0644, pvc_display_dir,
+                                       &pvc_line_proc_fops, &pvc_linedata[i]);
                if (proc_entry == NULL)
                        goto error;
-
-               proc_entry->read_proc = pvc_proc_read_line;
-               proc_entry->write_proc = pvc_proc_write_line;
-               proc_entry->data = &pvc_linedata[i];
        }
-       proc_entry = create_proc_entry("scroll", 0644, pvc_display_dir);
+       proc_entry = proc_create("scroll", 0644, pvc_display_dir,
+                                &pvc_scroll_proc_fops);
        if (proc_entry == NULL)
                goto error;
 
-       proc_entry->write_proc = pvc_proc_write_scroll;
-       proc_entry->read_proc = pvc_proc_read_scroll;
-
        init_timer(&timer);
        timer.function = pvc_proc_timerfunc;
 
index 6acc6cb85f0ae8032e19af25dc85a79cf05a3760..20fde19a5fbf83480d428fb803acacdb8fe45b07 100644 (file)
@@ -100,8 +100,8 @@ void __init prom_init(void)
 
        /* Get the command line */
        if (argc > 0) {
-               strncpy(arcs_cmdline, argv[0], CL_SIZE-1);
-               arcs_cmdline[CL_SIZE-1] = '\0';
+               strncpy(arcs_cmdline, argv[0], COMMAND_LINE_SIZE-1);
+               arcs_cmdline[COMMAND_LINE_SIZE-1] = '\0';
        }
 
        /* Set the I/O base address */
index 14b9a28a4aec84a7d0f3c846ab65625e6cd6303e..d87ffd04cb0adfc1d10c824c1dd88c90b336c159 100644 (file)
@@ -204,7 +204,7 @@ static ctl_table lasat_table[] = {
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_lasat_prid,
-.      },
+       },
 #ifdef CONFIG_INET
        {
                .procname       = "ipaddr",
index d45092505fa105817d1adab1282bcf40153248a9..3df1967dea08c4e7646c04e2eaed10d6c5d0a805 100644 (file)
@@ -1,31 +1,85 @@
 choice
-    prompt "Machine Type"
-    depends on MACH_LOONGSON
+       prompt "Machine Type"
+       depends on MACH_LOONGSON
 
 config LEMOTE_FULOONG2E
-    bool "Lemote Fuloong(2e) mini-PC"
-    select ARCH_SPARSEMEM_ENABLE
-    select CEVT_R4K
-    select CSRC_R4K
-    select SYS_HAS_CPU_LOONGSON2E
-    select DMA_NONCOHERENT
-    select BOOT_ELF32
-    select BOARD_SCACHE
-    select HW_HAS_PCI
-    select I8259
-    select ISA
-    select IRQ_CPU
-    select SYS_SUPPORTS_32BIT_KERNEL
-    select SYS_SUPPORTS_64BIT_KERNEL
-    select SYS_SUPPORTS_LITTLE_ENDIAN
-    select SYS_SUPPORTS_HIGHMEM
-    select SYS_HAS_EARLY_PRINTK
-    select GENERIC_HARDIRQS_NO__DO_IRQ
-    select GENERIC_ISA_DMA_SUPPORT_BROKEN
-    select CPU_HAS_WB
-    help
-      Lemote Fuloong(2e) mini-PC board based on the Chinese Loongson-2E CPU and
-      an FPGA northbridge
-
-      Lemote Fuloong(2e) mini PC have a VIA686B south bridge.
+       bool "Lemote Fuloong(2e) mini-PC"
+       select ARCH_SPARSEMEM_ENABLE
+       select CEVT_R4K
+       select CSRC_R4K
+       select SYS_HAS_CPU_LOONGSON2E
+       select DMA_NONCOHERENT
+       select BOOT_ELF32
+       select BOARD_SCACHE
+       select HW_HAS_PCI
+       select I8259
+       select ISA
+       select IRQ_CPU
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
+       select SYS_SUPPORTS_LITTLE_ENDIAN
+       select SYS_SUPPORTS_HIGHMEM
+       select SYS_HAS_EARLY_PRINTK
+       select GENERIC_HARDIRQS_NO__DO_IRQ
+       select GENERIC_ISA_DMA_SUPPORT_BROKEN
+       select CPU_HAS_WB
+       help
+         Lemote Fuloong(2e) mini-PC board based on the Chinese Loongson-2E CPU and
+         an FPGA northbridge
+
+         Lemote Fuloong(2e) mini PC have a VIA686B south bridge.
+
+config LEMOTE_MACH2F
+       bool "Lemote Loongson 2F family machines"
+       select ARCH_SPARSEMEM_ENABLE
+       select BOARD_SCACHE
+       select BOOT_ELF32
+       select CEVT_R4K if ! MIPS_EXTERNAL_TIMER
+       select CPU_HAS_WB
+       select CS5536
+       select CSRC_R4K if ! MIPS_EXTERNAL_TIMER
+       select DMA_NONCOHERENT
+       select GENERIC_HARDIRQS_NO__DO_IRQ
+       select GENERIC_ISA_DMA_SUPPORT_BROKEN
+       select HW_HAS_PCI
+       select I8259
+       select IRQ_CPU
+       select ISA
+       select SYS_HAS_CPU_LOONGSON2F
+       select SYS_HAS_EARLY_PRINTK
+       select SYS_SUPPORTS_32BIT_KERNEL
+       select SYS_SUPPORTS_64BIT_KERNEL
+       select SYS_SUPPORTS_HIGHMEM
+       select SYS_SUPPORTS_LITTLE_ENDIAN
+       help
+         Lemote Loongson 2F family machines utilize the 2F revision of
+         Loongson processor and the AMD CS5536 south bridge.
+
+         These family machines include fuloong2f mini PC, yeeloong2f notebook,
+         LingLoong allinone PC and so forth.
 endchoice
+
+config CS5536
+       bool
+
+config CS5536_MFGPT
+       bool "CS5536 MFGPT Timer"
+       depends on CS5536
+       select MIPS_EXTERNAL_TIMER
+       help
+         This option enables the mfgpt0 timer of AMD CS5536.
+
+         If you want to enable the Loongson2 CPUFreq Driver, Please enable
+         this option at first, otherwise, You will get wrong system time.
+
+         If unsure, say Yes.
+
+config LOONGSON_SUSPEND
+       bool
+       default y
+       depends on CPU_SUPPORTS_CPUFREQ && SUSPEND
+
+config LOONGSON_UART_BASE
+       bool
+       default y
+       depends on EARLY_PRINTK || SERIAL_8250
index 39048c455d7d58c8c4f4bd6cc16a230951498236..2b76cb0fb07da0857ab91f45cb68ecef9fdf090e 100644 (file)
@@ -9,3 +9,9 @@ obj-$(CONFIG_MACH_LOONGSON) += common/
 #
 
 obj-$(CONFIG_LEMOTE_FULOONG2E)  += fuloong-2e/
+
+#
+# Lemote loongson2f family machines
+#
+
+obj-$(CONFIG_LEMOTE_MACH2F)  += lemote-2f/
index 656b3cc0a2a6b48ff7f1c1c731fae31e198b406f..7668c4de1151b8c89b36d0e0eb126a856a4ec5ef 100644 (file)
@@ -3,9 +3,23 @@
 #
 
 obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \
-    pci.o bonito-irq.o mem.o machtype.o
+    pci.o bonito-irq.o mem.o machtype.o platform.o
 
 #
-# Early printk support
+# Serial port support
 #
 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
+obj-$(CONFIG_SERIAL_8250) += serial.o
+obj-$(CONFIG_LOONGSON_UART_BASE) += uart_base.o
+
+#
+# Enable CS5536 Virtual Support Module(VSM) to virtulize the PCI configure
+# space
+#
+obj-$(CONFIG_CS5536) += cs5536/
+
+#
+# Suspend Support
+#
+
+obj-$(CONFIG_LOONGSON_SUSPEND) += pm.o
index 3e31e7ad713e2b4eccbf580c89ecf6715f353a78..2dc2a4cc632a72817aaa64617246d5845c7465ac 100644 (file)
  *  option) any later version.
  */
 #include <linux/interrupt.h>
+#include <linux/compiler.h>
 
 #include <loongson.h>
 
 static inline void bonito_irq_enable(unsigned int irq)
 {
-       BONITO_INTENSET = (1 << (irq - BONITO_IRQ_BASE));
+       LOONGSON_INTENSET = (1 << (irq - LOONGSON_IRQ_BASE));
        mmiowb();
 }
 
 static inline void bonito_irq_disable(unsigned int irq)
 {
-       BONITO_INTENCLR = (1 << (irq - BONITO_IRQ_BASE));
+       LOONGSON_INTENCLR = (1 << (irq - LOONGSON_IRQ_BASE));
        mmiowb();
 }
 
@@ -35,7 +36,7 @@ static struct irq_chip bonito_irq_type = {
        .unmask = bonito_irq_enable,
 };
 
-static struct irqaction dma_timeout_irqaction = {
+static struct irqaction __maybe_unused dma_timeout_irqaction = {
        .handler        = no_action,
        .name           = "dma_timeout",
 };
@@ -44,8 +45,10 @@ void bonito_irq_init(void)
 {
        u32 i;
 
-       for (i = BONITO_IRQ_BASE; i < BONITO_IRQ_BASE + 32; i++)
+       for (i = LOONGSON_IRQ_BASE; i < LOONGSON_IRQ_BASE + 32; i++)
                set_irq_chip_and_handler(i, &bonito_irq_type, handle_level_irq);
 
-       setup_irq(BONITO_IRQ_BASE + 10, &dma_timeout_irqaction);
+#ifdef CONFIG_CPU_LOONGSON2E
+       setup_irq(LOONGSON_IRQ_BASE + 10, &dma_timeout_irqaction);
+#endif
 }
index 75f1b243ee4e4c6cb0aa0faf104159714effc821..7ad47f227477d6d10fdabde77b5f28d986b55784 100644 (file)
@@ -9,7 +9,7 @@
  * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
  * Author: Fuxin Zhang, zhangfx@lemote.com
  *
- * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
+ * Copyright (C) 2009 Lemote Inc.
  * Author: Wu Zhangjin, wuzj@lemote.com
  *
  * This program is free software; you can redistribute  it and/or modify it
@@ -49,4 +49,6 @@ void __init prom_init_cmdline(void)
                strcat(arcs_cmdline, " console=ttyS0,115200");
        if ((strstr(arcs_cmdline, "root=")) == NULL)
                strcat(arcs_cmdline, " root=/dev/hda1");
+
+       prom_init_machtype();
 }
diff --git a/arch/mips/loongson/common/cs5536/Makefile b/arch/mips/loongson/common/cs5536/Makefile
new file mode 100644 (file)
index 0000000..510d4cd
--- /dev/null
@@ -0,0 +1,13 @@
+#
+# Makefile for CS5536 support.
+#
+
+obj-$(CONFIG_CS5536) += cs5536_pci.o cs5536_ide.o cs5536_acc.o cs5536_ohci.o \
+                       cs5536_isa.o cs5536_ehci.o
+
+#
+# Enable cs5536 mfgpt Timer
+#
+obj-$(CONFIG_CS5536_MFGPT) += cs5536_mfgpt.o
+
+EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/loongson/common/cs5536/cs5536_acc.c b/arch/mips/loongson/common/cs5536/cs5536_acc.c
new file mode 100644 (file)
index 0000000..b49485f
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * the ACC Virtual Support Module of AMD CS5536
+ *
+ * Copyright (C) 2007 Lemote, Inc.
+ * Author : jlliu, liujl@lemote.com
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <cs5536/cs5536.h>
+#include <cs5536/cs5536_pci.h>
+
+void pci_acc_write_reg(int reg, u32 value)
+{
+       u32 hi = 0, lo = value;
+
+       switch (reg) {
+       case PCI_COMMAND:
+               _rdmsr(GLIU_MSR_REG(GLIU_PAE), &hi, &lo);
+               if (value & PCI_COMMAND_MASTER)
+                       lo |= (0x03 << 8);
+               else
+                       lo &= ~(0x03 << 8);
+               _wrmsr(GLIU_MSR_REG(GLIU_PAE), hi, lo);
+               break;
+       case PCI_STATUS:
+               if (value & PCI_STATUS_PARITY) {
+                       _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+                       if (lo & SB_PARE_ERR_FLAG) {
+                               lo = (lo & 0x0000ffff) | SB_PARE_ERR_FLAG;
+                               _wrmsr(SB_MSR_REG(SB_ERROR), hi, lo);
+                       }
+               }
+               break;
+       case PCI_BAR0_REG:
+               if (value == PCI_BAR_RANGE_MASK) {
+                       _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+                       lo |= SOFT_BAR_ACC_FLAG;
+                       _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+               } else if (value & 0x01) {
+                       value &= 0xfffffffc;
+                       hi = 0xA0000000 | ((value & 0x000ff000) >> 12);
+                       lo = 0x000fff80 | ((value & 0x00000fff) << 20);
+                       _wrmsr(GLIU_MSR_REG(GLIU_IOD_BM1), hi, lo);
+               }
+               break;
+       case PCI_ACC_INT_REG:
+               _rdmsr(DIVIL_MSR_REG(PIC_YSEL_LOW), &hi, &lo);
+               /* disable all the usb interrupt in PIC */
+               lo &= ~(0xf << PIC_YSEL_LOW_ACC_SHIFT);
+               if (value)      /* enable all the acc interrupt in PIC */
+                       lo |= (CS5536_ACC_INTR << PIC_YSEL_LOW_ACC_SHIFT);
+               _wrmsr(DIVIL_MSR_REG(PIC_YSEL_LOW), hi, lo);
+               break;
+       default:
+               break;
+       }
+}
+
+u32 pci_acc_read_reg(int reg)
+{
+       u32 hi, lo;
+       u32 conf_data = 0;
+
+       switch (reg) {
+       case PCI_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_ACC_DEVICE_ID, CS5536_VENDOR_ID);
+               break;
+       case PCI_COMMAND:
+               _rdmsr(GLIU_MSR_REG(GLIU_IOD_BM1), &hi, &lo);
+               if (((lo & 0xfff00000) || (hi & 0x000000ff))
+                   && ((hi & 0xf0000000) == 0xa0000000))
+                       conf_data |= PCI_COMMAND_IO;
+               _rdmsr(GLIU_MSR_REG(GLIU_PAE), &hi, &lo);
+               if ((lo & 0x300) == 0x300)
+                       conf_data |= PCI_COMMAND_MASTER;
+               break;
+       case PCI_STATUS:
+               conf_data |= PCI_STATUS_66MHZ;
+               conf_data |= PCI_STATUS_FAST_BACK;
+               _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+               if (lo & SB_PARE_ERR_FLAG)
+                       conf_data |= PCI_STATUS_PARITY;
+               conf_data |= PCI_STATUS_DEVSEL_MEDIUM;
+               break;
+       case PCI_CLASS_REVISION:
+               _rdmsr(ACC_MSR_REG(ACC_CAP), &hi, &lo);
+               conf_data = lo & 0x000000ff;
+               conf_data |= (CS5536_ACC_CLASS_CODE << 8);
+               break;
+       case PCI_CACHE_LINE_SIZE:
+               conf_data =
+                   CFG_PCI_CACHE_LINE_SIZE(PCI_NORMAL_HEADER_TYPE,
+                                           PCI_NORMAL_LATENCY_TIMER);
+               break;
+       case PCI_BAR0_REG:
+               _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+               if (lo & SOFT_BAR_ACC_FLAG) {
+                       conf_data = CS5536_ACC_RANGE |
+                           PCI_BASE_ADDRESS_SPACE_IO;
+                       lo &= ~SOFT_BAR_ACC_FLAG;
+                       _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+               } else {
+                       _rdmsr(GLIU_MSR_REG(GLIU_IOD_BM1), &hi, &lo);
+                       conf_data = (hi & 0x000000ff) << 12;
+                       conf_data |= (lo & 0xfff00000) >> 20;
+                       conf_data |= 0x01;
+                       conf_data &= ~0x02;
+               }
+               break;
+       case PCI_CARDBUS_CIS:
+               conf_data = PCI_CARDBUS_CIS_POINTER;
+               break;
+       case PCI_SUBSYSTEM_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_ACC_SUB_ID, CS5536_SUB_VENDOR_ID);
+               break;
+       case PCI_ROM_ADDRESS:
+               conf_data = PCI_EXPANSION_ROM_BAR;
+               break;
+       case PCI_CAPABILITY_LIST:
+               conf_data = PCI_CAPLIST_USB_POINTER;
+               break;
+       case PCI_INTERRUPT_LINE:
+               conf_data =
+                   CFG_PCI_INTERRUPT_LINE(PCI_DEFAULT_PIN, CS5536_ACC_INTR);
+               break;
+       default:
+               break;
+       }
+
+       return conf_data;
+}
diff --git a/arch/mips/loongson/common/cs5536/cs5536_ehci.c b/arch/mips/loongson/common/cs5536/cs5536_ehci.c
new file mode 100644 (file)
index 0000000..74f9c59
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * the EHCI Virtual Support Module of AMD CS5536
+ *
+ * Copyright (C) 2007 Lemote, Inc.
+ * Author : jlliu, liujl@lemote.com
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <cs5536/cs5536.h>
+#include <cs5536/cs5536_pci.h>
+
+void pci_ehci_write_reg(int reg, u32 value)
+{
+       u32 hi = 0, lo = value;
+
+       switch (reg) {
+       case PCI_COMMAND:
+               _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
+               if (value & PCI_COMMAND_MASTER)
+                       hi |= PCI_COMMAND_MASTER;
+               else
+                       hi &= ~PCI_COMMAND_MASTER;
+
+               if (value & PCI_COMMAND_MEMORY)
+                       hi |= PCI_COMMAND_MEMORY;
+               else
+                       hi &= ~PCI_COMMAND_MEMORY;
+               _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
+               break;
+       case PCI_STATUS:
+               if (value & PCI_STATUS_PARITY) {
+                       _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+                       if (lo & SB_PARE_ERR_FLAG) {
+                               lo = (lo & 0x0000ffff) | SB_PARE_ERR_FLAG;
+                               _wrmsr(SB_MSR_REG(SB_ERROR), hi, lo);
+                       }
+               }
+               break;
+       case PCI_BAR0_REG:
+               if (value == PCI_BAR_RANGE_MASK) {
+                       _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+                       lo |= SOFT_BAR_EHCI_FLAG;
+                       _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+               } else if ((value & 0x01) == 0x00) {
+                       _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
+
+                       value &= 0xfffffff0;
+                       hi = 0x40000000 | ((value & 0xff000000) >> 24);
+                       lo = 0x000fffff | ((value & 0x00fff000) << 8);
+                       _wrmsr(GLIU_MSR_REG(GLIU_P2D_BM4), hi, lo);
+               }
+               break;
+       case PCI_EHCI_LEGSMIEN_REG:
+               _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
+               hi &= 0x003f0000;
+               hi |= (value & 0x3f) << 16;
+               _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
+               break;
+       case PCI_EHCI_FLADJ_REG:
+               _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
+               hi &= ~0x00003f00;
+               hi |= value & 0x00003f00;
+               _wrmsr(USB_MSR_REG(USB_EHCI), hi, lo);
+               break;
+       default:
+               break;
+       }
+}
+
+u32 pci_ehci_read_reg(int reg)
+{
+       u32 conf_data = 0;
+       u32 hi, lo;
+
+       switch (reg) {
+       case PCI_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_EHCI_DEVICE_ID, CS5536_VENDOR_ID);
+               break;
+       case PCI_COMMAND:
+               _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
+               if (hi & PCI_COMMAND_MASTER)
+                       conf_data |= PCI_COMMAND_MASTER;
+               if (hi & PCI_COMMAND_MEMORY)
+                       conf_data |= PCI_COMMAND_MEMORY;
+               break;
+       case PCI_STATUS:
+               conf_data |= PCI_STATUS_66MHZ;
+               conf_data |= PCI_STATUS_FAST_BACK;
+               _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+               if (lo & SB_PARE_ERR_FLAG)
+                       conf_data |= PCI_STATUS_PARITY;
+               conf_data |= PCI_STATUS_DEVSEL_MEDIUM;
+               break;
+       case PCI_CLASS_REVISION:
+               _rdmsr(USB_MSR_REG(USB_CAP), &hi, &lo);
+               conf_data = lo & 0x000000ff;
+               conf_data |= (CS5536_EHCI_CLASS_CODE << 8);
+               break;
+       case PCI_CACHE_LINE_SIZE:
+               conf_data =
+                   CFG_PCI_CACHE_LINE_SIZE(PCI_NORMAL_HEADER_TYPE,
+                                           PCI_NORMAL_LATENCY_TIMER);
+               break;
+       case PCI_BAR0_REG:
+               _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+               if (lo & SOFT_BAR_EHCI_FLAG) {
+                       conf_data = CS5536_EHCI_RANGE |
+                           PCI_BASE_ADDRESS_SPACE_MEMORY;
+                       lo &= ~SOFT_BAR_EHCI_FLAG;
+                       _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+               } else {
+                       _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
+                       conf_data = lo & 0xfffff000;
+               }
+               break;
+       case PCI_CARDBUS_CIS:
+               conf_data = PCI_CARDBUS_CIS_POINTER;
+               break;
+       case PCI_SUBSYSTEM_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_EHCI_SUB_ID, CS5536_SUB_VENDOR_ID);
+               break;
+       case PCI_ROM_ADDRESS:
+               conf_data = PCI_EXPANSION_ROM_BAR;
+               break;
+       case PCI_CAPABILITY_LIST:
+               conf_data = PCI_CAPLIST_USB_POINTER;
+               break;
+       case PCI_INTERRUPT_LINE:
+               conf_data =
+                   CFG_PCI_INTERRUPT_LINE(PCI_DEFAULT_PIN, CS5536_USB_INTR);
+               break;
+       case PCI_EHCI_LEGSMIEN_REG:
+               _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
+               conf_data = (hi & 0x003f0000) >> 16;
+               break;
+       case PCI_EHCI_LEGSMISTS_REG:
+               _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
+               conf_data = (hi & 0x3f000000) >> 24;
+               break;
+       case PCI_EHCI_FLADJ_REG:
+               _rdmsr(USB_MSR_REG(USB_EHCI), &hi, &lo);
+               conf_data = hi & 0x00003f00;
+               break;
+       default:
+               break;
+       }
+
+       return conf_data;
+}
diff --git a/arch/mips/loongson/common/cs5536/cs5536_ide.c b/arch/mips/loongson/common/cs5536/cs5536_ide.c
new file mode 100644 (file)
index 0000000..3f61594
--- /dev/null
@@ -0,0 +1,179 @@
+/*
+ * the IDE Virtual Support Module of AMD CS5536
+ *
+ * Copyright (C) 2007 Lemote, Inc.
+ * Author : jlliu, liujl@lemote.com
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <cs5536/cs5536.h>
+#include <cs5536/cs5536_pci.h>
+
+void pci_ide_write_reg(int reg, u32 value)
+{
+       u32 hi = 0, lo = value;
+
+       switch (reg) {
+       case PCI_COMMAND:
+               _rdmsr(GLIU_MSR_REG(GLIU_PAE), &hi, &lo);
+               if (value & PCI_COMMAND_MASTER)
+                       lo |= (0x03 << 4);
+               else
+                       lo &= ~(0x03 << 4);
+               _wrmsr(GLIU_MSR_REG(GLIU_PAE), hi, lo);
+               break;
+       case PCI_STATUS:
+               if (value & PCI_STATUS_PARITY) {
+                       _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+                       if (lo & SB_PARE_ERR_FLAG) {
+                               lo = (lo & 0x0000ffff) | SB_PARE_ERR_FLAG;
+                               _wrmsr(SB_MSR_REG(SB_ERROR), hi, lo);
+                       }
+               }
+               break;
+       case PCI_CACHE_LINE_SIZE:
+               value &= 0x0000ff00;
+               _rdmsr(SB_MSR_REG(SB_CTRL), &hi, &lo);
+               hi &= 0xffffff00;
+               hi |= (value >> 8);
+               _wrmsr(SB_MSR_REG(SB_CTRL), hi, lo);
+               break;
+       case PCI_BAR4_REG:
+               if (value == PCI_BAR_RANGE_MASK) {
+                       _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+                       lo |= SOFT_BAR_IDE_FLAG;
+                       _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+               } else if (value & 0x01) {
+                       lo = (value & 0xfffffff0) | 0x1;
+                       _wrmsr(IDE_MSR_REG(IDE_IO_BAR), hi, lo);
+
+                       value &= 0xfffffffc;
+                       hi = 0x60000000 | ((value & 0x000ff000) >> 12);
+                       lo = 0x000ffff0 | ((value & 0x00000fff) << 20);
+                       _wrmsr(GLIU_MSR_REG(GLIU_IOD_BM2), hi, lo);
+               }
+               break;
+       case PCI_IDE_CFG_REG:
+               if (value == CS5536_IDE_FLASH_SIGNATURE) {
+                       _rdmsr(DIVIL_MSR_REG(DIVIL_BALL_OPTS), &hi, &lo);
+                       lo |= 0x01;
+                       _wrmsr(DIVIL_MSR_REG(DIVIL_BALL_OPTS), hi, lo);
+               } else
+                       _wrmsr(IDE_MSR_REG(IDE_CFG), hi, lo);
+               break;
+       case PCI_IDE_DTC_REG:
+               _wrmsr(IDE_MSR_REG(IDE_DTC), hi, lo);
+               break;
+       case PCI_IDE_CAST_REG:
+               _wrmsr(IDE_MSR_REG(IDE_CAST), hi, lo);
+               break;
+       case PCI_IDE_ETC_REG:
+               _wrmsr(IDE_MSR_REG(IDE_ETC), hi, lo);
+               break;
+       case PCI_IDE_PM_REG:
+               _wrmsr(IDE_MSR_REG(IDE_INTERNAL_PM), hi, lo);
+               break;
+       default:
+               break;
+       }
+}
+
+u32 pci_ide_read_reg(int reg)
+{
+       u32 conf_data = 0;
+       u32 hi, lo;
+
+       switch (reg) {
+       case PCI_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_IDE_DEVICE_ID, CS5536_VENDOR_ID);
+               break;
+       case PCI_COMMAND:
+               _rdmsr(IDE_MSR_REG(IDE_IO_BAR), &hi, &lo);
+               if (lo & 0xfffffff0)
+                       conf_data |= PCI_COMMAND_IO;
+               _rdmsr(GLIU_MSR_REG(GLIU_PAE), &hi, &lo);
+               if ((lo & 0x30) == 0x30)
+                       conf_data |= PCI_COMMAND_MASTER;
+               break;
+       case PCI_STATUS:
+               conf_data |= PCI_STATUS_66MHZ;
+               conf_data |= PCI_STATUS_FAST_BACK;
+               _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+               if (lo & SB_PARE_ERR_FLAG)
+                       conf_data |= PCI_STATUS_PARITY;
+               conf_data |= PCI_STATUS_DEVSEL_MEDIUM;
+               break;
+       case PCI_CLASS_REVISION:
+               _rdmsr(IDE_MSR_REG(IDE_CAP), &hi, &lo);
+               conf_data = lo & 0x000000ff;
+               conf_data |= (CS5536_IDE_CLASS_CODE << 8);
+               break;
+       case PCI_CACHE_LINE_SIZE:
+               _rdmsr(SB_MSR_REG(SB_CTRL), &hi, &lo);
+               hi &= 0x000000f8;
+               conf_data = CFG_PCI_CACHE_LINE_SIZE(PCI_NORMAL_HEADER_TYPE, hi);
+               break;
+       case PCI_BAR4_REG:
+               _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+               if (lo & SOFT_BAR_IDE_FLAG) {
+                       conf_data = CS5536_IDE_RANGE |
+                           PCI_BASE_ADDRESS_SPACE_IO;
+                       lo &= ~SOFT_BAR_IDE_FLAG;
+                       _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+               } else {
+                       _rdmsr(IDE_MSR_REG(IDE_IO_BAR), &hi, &lo);
+                       conf_data = lo & 0xfffffff0;
+                       conf_data |= 0x01;
+                       conf_data &= ~0x02;
+               }
+               break;
+       case PCI_CARDBUS_CIS:
+               conf_data = PCI_CARDBUS_CIS_POINTER;
+               break;
+       case PCI_SUBSYSTEM_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_IDE_SUB_ID, CS5536_SUB_VENDOR_ID);
+               break;
+       case PCI_ROM_ADDRESS:
+               conf_data = PCI_EXPANSION_ROM_BAR;
+               break;
+       case PCI_CAPABILITY_LIST:
+               conf_data = PCI_CAPLIST_POINTER;
+               break;
+       case PCI_INTERRUPT_LINE:
+               conf_data =
+                   CFG_PCI_INTERRUPT_LINE(PCI_DEFAULT_PIN, CS5536_IDE_INTR);
+               break;
+       case PCI_IDE_CFG_REG:
+               _rdmsr(IDE_MSR_REG(IDE_CFG), &hi, &lo);
+               conf_data = lo;
+               break;
+       case PCI_IDE_DTC_REG:
+               _rdmsr(IDE_MSR_REG(IDE_DTC), &hi, &lo);
+               conf_data = lo;
+               break;
+       case PCI_IDE_CAST_REG:
+               _rdmsr(IDE_MSR_REG(IDE_CAST), &hi, &lo);
+               conf_data = lo;
+               break;
+       case PCI_IDE_ETC_REG:
+               _rdmsr(IDE_MSR_REG(IDE_ETC), &hi, &lo);
+               conf_data = lo;
+       case PCI_IDE_PM_REG:
+               _rdmsr(IDE_MSR_REG(IDE_INTERNAL_PM), &hi, &lo);
+               conf_data = lo;
+               break;
+       default:
+               break;
+       }
+
+       return conf_data;
+}
diff --git a/arch/mips/loongson/common/cs5536/cs5536_isa.c b/arch/mips/loongson/common/cs5536/cs5536_isa.c
new file mode 100644 (file)
index 0000000..b6f17f5
--- /dev/null
@@ -0,0 +1,316 @@
+/*
+ * the ISA Virtual Support Module of AMD CS5536
+ *
+ * Copyright (C) 2007 Lemote, Inc.
+ * Author : jlliu, liujl@lemote.com
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <cs5536/cs5536.h>
+#include <cs5536/cs5536_pci.h>
+
+/* common variables for PCI_ISA_READ/WRITE_BAR */
+static const u32 divil_msr_reg[6] = {
+       DIVIL_MSR_REG(DIVIL_LBAR_SMB), DIVIL_MSR_REG(DIVIL_LBAR_GPIO),
+       DIVIL_MSR_REG(DIVIL_LBAR_MFGPT), DIVIL_MSR_REG(DIVIL_LBAR_IRQ),
+       DIVIL_MSR_REG(DIVIL_LBAR_PMS), DIVIL_MSR_REG(DIVIL_LBAR_ACPI),
+};
+
+static const u32 soft_bar_flag[6] = {
+       SOFT_BAR_SMB_FLAG, SOFT_BAR_GPIO_FLAG, SOFT_BAR_MFGPT_FLAG,
+       SOFT_BAR_IRQ_FLAG, SOFT_BAR_PMS_FLAG, SOFT_BAR_ACPI_FLAG,
+};
+
+static const u32 sb_msr_reg[6] = {
+       SB_MSR_REG(SB_R0), SB_MSR_REG(SB_R1), SB_MSR_REG(SB_R2),
+       SB_MSR_REG(SB_R3), SB_MSR_REG(SB_R4), SB_MSR_REG(SB_R5),
+};
+
+static const u32 bar_space_range[6] = {
+       CS5536_SMB_RANGE, CS5536_GPIO_RANGE, CS5536_MFGPT_RANGE,
+       CS5536_IRQ_RANGE, CS5536_PMS_RANGE, CS5536_ACPI_RANGE,
+};
+
+static const int bar_space_len[6] = {
+       CS5536_SMB_LENGTH, CS5536_GPIO_LENGTH, CS5536_MFGPT_LENGTH,
+       CS5536_IRQ_LENGTH, CS5536_PMS_LENGTH, CS5536_ACPI_LENGTH,
+};
+
+/*
+ * enable the divil module bar space.
+ *
+ * For all the DIVIL module LBAR, you should control the DIVIL LBAR reg
+ * and the RCONFx(0~5) reg to use the modules.
+ */
+static void divil_lbar_enable(void)
+{
+       u32 hi, lo;
+       int offset;
+
+       /*
+        * The DIVIL IRQ is not used yet. and make the RCONF0 reserved.
+        */
+
+       for (offset = DIVIL_LBAR_SMB; offset <= DIVIL_LBAR_PMS; offset++) {
+               _rdmsr(DIVIL_MSR_REG(offset), &hi, &lo);
+               hi |= 0x01;
+               _wrmsr(DIVIL_MSR_REG(DIVIL_LBAR_SMB), hi, lo);
+       }
+}
+
+/*
+ * disable the divil module bar space.
+ */
+static void divil_lbar_disable(void)
+{
+       u32 hi, lo;
+       int offset;
+
+       for (offset = DIVIL_LBAR_SMB; offset <= DIVIL_LBAR_PMS; offset++) {
+               _rdmsr(DIVIL_MSR_REG(offset), &hi, &lo);
+               hi &= ~0x01;
+               _wrmsr(DIVIL_MSR_REG(DIVIL_LBAR_SMB), hi, lo);
+       }
+}
+
+/*
+ * BAR write: write value to the n BAR
+ */
+
+void pci_isa_write_bar(int n, u32 value)
+{
+       u32 hi = 0, lo = value;
+
+       if (value == PCI_BAR_RANGE_MASK) {
+               _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+               lo |= soft_bar_flag[n];
+               _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+       } else if (value & 0x01) {
+               /* NATIVE reg */
+               hi = 0x0000f001;
+               lo &= bar_space_range[n];
+               _wrmsr(divil_msr_reg[n], hi, lo);
+
+               /* RCONFx is 4bytes in units for I/O space */
+               hi = ((value & 0x000ffffc) << 12) |
+                   ((bar_space_len[n] - 4) << 12) | 0x01;
+               lo = ((value & 0x000ffffc) << 12) | 0x01;
+               _wrmsr(sb_msr_reg[n], hi, lo);
+       }
+}
+
+/*
+ * BAR read: read the n BAR
+ */
+
+u32 pci_isa_read_bar(int n)
+{
+       u32 conf_data = 0;
+       u32 hi, lo;
+
+       _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+       if (lo & soft_bar_flag[n]) {
+               conf_data = bar_space_range[n] | PCI_BASE_ADDRESS_SPACE_IO;
+               lo &= ~soft_bar_flag[n];
+               _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+       } else {
+               _rdmsr(divil_msr_reg[n], &hi, &lo);
+               conf_data = lo & bar_space_range[n];
+               conf_data |= 0x01;
+               conf_data &= ~0x02;
+       }
+       return conf_data;
+}
+
+/*
+ * isa_write: ISA write transfer
+ *
+ * We assume that this is not a bus master transfer.
+ */
+void pci_isa_write_reg(int reg, u32 value)
+{
+       u32 hi = 0, lo = value;
+       u32 temp;
+
+       switch (reg) {
+       case PCI_COMMAND:
+               if (value & PCI_COMMAND_IO)
+                       divil_lbar_enable();
+               else
+                       divil_lbar_disable();
+               break;
+       case PCI_STATUS:
+               _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+               temp = lo & 0x0000ffff;
+               if ((value & PCI_STATUS_SIG_TARGET_ABORT) &&
+                   (lo & SB_TAS_ERR_EN))
+                       temp |= SB_TAS_ERR_FLAG;
+
+               if ((value & PCI_STATUS_REC_TARGET_ABORT) &&
+                   (lo & SB_TAR_ERR_EN))
+                       temp |= SB_TAR_ERR_FLAG;
+
+               if ((value & PCI_STATUS_REC_MASTER_ABORT)
+                   && (lo & SB_MAR_ERR_EN))
+                       temp |= SB_MAR_ERR_FLAG;
+
+               if ((value & PCI_STATUS_DETECTED_PARITY)
+                   && (lo & SB_PARE_ERR_EN))
+                       temp |= SB_PARE_ERR_FLAG;
+
+               lo = temp;
+               _wrmsr(SB_MSR_REG(SB_ERROR), hi, lo);
+               break;
+       case PCI_CACHE_LINE_SIZE:
+               value &= 0x0000ff00;
+               _rdmsr(SB_MSR_REG(SB_CTRL), &hi, &lo);
+               hi &= 0xffffff00;
+               hi |= (value >> 8);
+               _wrmsr(SB_MSR_REG(SB_CTRL), hi, lo);
+               break;
+       case PCI_BAR0_REG:
+               pci_isa_write_bar(0, value);
+               break;
+       case PCI_BAR1_REG:
+               pci_isa_write_bar(1, value);
+               break;
+       case PCI_BAR2_REG:
+               pci_isa_write_bar(2, value);
+               break;
+       case PCI_BAR3_REG:
+               pci_isa_write_bar(3, value);
+               break;
+       case PCI_BAR4_REG:
+               pci_isa_write_bar(4, value);
+               break;
+       case PCI_BAR5_REG:
+               pci_isa_write_bar(5, value);
+               break;
+       case PCI_UART1_INT_REG:
+               _rdmsr(DIVIL_MSR_REG(PIC_YSEL_HIGH), &hi, &lo);
+               /* disable uart1 interrupt in PIC */
+               lo &= ~(0xf << 24);
+               if (value)      /* enable uart1 interrupt in PIC */
+                       lo |= (CS5536_UART1_INTR << 24);
+               _wrmsr(DIVIL_MSR_REG(PIC_YSEL_HIGH), hi, lo);
+               break;
+       case PCI_UART2_INT_REG:
+               _rdmsr(DIVIL_MSR_REG(PIC_YSEL_HIGH), &hi, &lo);
+               /* disable uart2 interrupt in PIC */
+               lo &= ~(0xf << 28);
+               if (value)      /* enable uart2 interrupt in PIC */
+                       lo |= (CS5536_UART2_INTR << 28);
+               _wrmsr(DIVIL_MSR_REG(PIC_YSEL_HIGH), hi, lo);
+               break;
+       case PCI_ISA_FIXUP_REG:
+               if (value) {
+                       /* enable the TARGET ABORT/MASTER ABORT etc. */
+                       _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+                       lo |= 0x00000063;
+                       _wrmsr(SB_MSR_REG(SB_ERROR), hi, lo);
+               }
+
+       default:
+               /* ALL OTHER PCI CONFIG SPACE HEADER IS NOT IMPLEMENTED. */
+               break;
+       }
+}
+
+/*
+ * isa_read: ISA read transfers
+ *
+ * We assume that this is not a bus master transfer.
+ */
+u32 pci_isa_read_reg(int reg)
+{
+       u32 conf_data = 0;
+       u32 hi, lo;
+
+       switch (reg) {
+       case PCI_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_ISA_DEVICE_ID, CS5536_VENDOR_ID);
+               break;
+       case PCI_COMMAND:
+               /* we just check the first LBAR for the IO enable bit, */
+               /* maybe we should changed later. */
+               _rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_SMB), &hi, &lo);
+               if (hi & 0x01)
+                       conf_data |= PCI_COMMAND_IO;
+               break;
+       case PCI_STATUS:
+               conf_data |= PCI_STATUS_66MHZ;
+               conf_data |= PCI_STATUS_DEVSEL_MEDIUM;
+               conf_data |= PCI_STATUS_FAST_BACK;
+
+               _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+               if (lo & SB_TAS_ERR_FLAG)
+                       conf_data |= PCI_STATUS_SIG_TARGET_ABORT;
+               if (lo & SB_TAR_ERR_FLAG)
+                       conf_data |= PCI_STATUS_REC_TARGET_ABORT;
+               if (lo & SB_MAR_ERR_FLAG)
+                       conf_data |= PCI_STATUS_REC_MASTER_ABORT;
+               if (lo & SB_PARE_ERR_FLAG)
+                       conf_data |= PCI_STATUS_DETECTED_PARITY;
+               break;
+       case PCI_CLASS_REVISION:
+               _rdmsr(GLCP_MSR_REG(GLCP_CHIP_REV_ID), &hi, &lo);
+               conf_data = lo & 0x000000ff;
+               conf_data |= (CS5536_ISA_CLASS_CODE << 8);
+               break;
+       case PCI_CACHE_LINE_SIZE:
+               _rdmsr(SB_MSR_REG(SB_CTRL), &hi, &lo);
+               hi &= 0x000000f8;
+               conf_data = CFG_PCI_CACHE_LINE_SIZE(PCI_BRIDGE_HEADER_TYPE, hi);
+               break;
+               /*
+                * we only use the LBAR of DIVIL, no RCONF used.
+                * all of them are IO space.
+                */
+       case PCI_BAR0_REG:
+               return pci_isa_read_bar(0);
+               break;
+       case PCI_BAR1_REG:
+               return pci_isa_read_bar(1);
+               break;
+       case PCI_BAR2_REG:
+               return pci_isa_read_bar(2);
+               break;
+       case PCI_BAR3_REG:
+               break;
+       case PCI_BAR4_REG:
+               return pci_isa_read_bar(4);
+               break;
+       case PCI_BAR5_REG:
+               return pci_isa_read_bar(5);
+               break;
+       case PCI_CARDBUS_CIS:
+               conf_data = PCI_CARDBUS_CIS_POINTER;
+               break;
+       case PCI_SUBSYSTEM_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_ISA_SUB_ID, CS5536_SUB_VENDOR_ID);
+               break;
+       case PCI_ROM_ADDRESS:
+               conf_data = PCI_EXPANSION_ROM_BAR;
+               break;
+       case PCI_CAPABILITY_LIST:
+               conf_data = PCI_CAPLIST_POINTER;
+               break;
+       case PCI_INTERRUPT_LINE:
+               /* no interrupt used here */
+               conf_data = CFG_PCI_INTERRUPT_LINE(0x00, 0x00);
+               break;
+       default:
+               break;
+       }
+
+       return conf_data;
+}
diff --git a/arch/mips/loongson/common/cs5536/cs5536_mfgpt.c b/arch/mips/loongson/common/cs5536/cs5536_mfgpt.c
new file mode 100644 (file)
index 0000000..6cb44db
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * CS5536 General timer functions
+ *
+ * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
+ * Author: Yanhua, yanh@lemote.com
+ *
+ * Copyright (C) 2009 Lemote Inc.
+ * Author: Wu zhangjin, wuzj@lemote.com
+ *
+ * Reference: AMD Geode(TM) CS5536 Companion Device Data Book
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */
+
+#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/jiffies.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/clockchips.h>
+
+#include <asm/time.h>
+
+#include <cs5536/cs5536_mfgpt.h>
+
+DEFINE_SPINLOCK(mfgpt_lock);
+EXPORT_SYMBOL(mfgpt_lock);
+
+static u32 mfgpt_base;
+
+/*
+ * Initialize the MFGPT timer.
+ *
+ * This is also called after resume to bring the MFGPT into operation again.
+ */
+
+/* disable counter */
+void disable_mfgpt0_counter(void)
+{
+       outw(inw(MFGPT0_SETUP) & 0x7fff, MFGPT0_SETUP);
+}
+EXPORT_SYMBOL(disable_mfgpt0_counter);
+
+/* enable counter, comparator2 to event mode, 14.318MHz clock */
+void enable_mfgpt0_counter(void)
+{
+       outw(0xe310, MFGPT0_SETUP);
+}
+EXPORT_SYMBOL(enable_mfgpt0_counter);
+
+static void init_mfgpt_timer(enum clock_event_mode mode,
+                            struct clock_event_device *evt)
+{
+       spin_lock(&mfgpt_lock);
+
+       switch (mode) {
+       case CLOCK_EVT_MODE_PERIODIC:
+               outw(COMPARE, MFGPT0_CMP2);     /* set comparator2 */
+               outw(0, MFGPT0_CNT);    /* set counter to 0 */
+               enable_mfgpt0_counter();
+               break;
+
+       case CLOCK_EVT_MODE_SHUTDOWN:
+       case CLOCK_EVT_MODE_UNUSED:
+               if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
+                   evt->mode == CLOCK_EVT_MODE_ONESHOT)
+                       disable_mfgpt0_counter();
+               break;
+
+       case CLOCK_EVT_MODE_ONESHOT:
+               /* The oneshot mode have very high deviation, Not use it! */
+               break;
+
+       case CLOCK_EVT_MODE_RESUME:
+               /* Nothing to do here */
+               break;
+       }
+       spin_unlock(&mfgpt_lock);
+}
+
+static struct clock_event_device mfgpt_clockevent = {
+       .name = "mfgpt",
+       .features = CLOCK_EVT_FEAT_PERIODIC,
+       .set_mode = init_mfgpt_timer,
+       .irq = CS5536_MFGPT_INTR,
+};
+
+static irqreturn_t timer_interrupt(int irq, void *dev_id)
+{
+       u32 basehi;
+
+       /*
+        * get MFGPT base address
+        *
+        * NOTE: do not remove me, it's need for the value of mfgpt_base is
+        * variable
+        */
+       _rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_MFGPT), &basehi, &mfgpt_base);
+
+       /* ack */
+       outw(inw(MFGPT0_SETUP) | 0x4000, MFGPT0_SETUP);
+
+       mfgpt_clockevent.event_handler(&mfgpt_clockevent);
+
+       return IRQ_HANDLED;
+}
+
+static struct irqaction irq5 = {
+       .handler = timer_interrupt,
+       .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_TIMER,
+       .name = "timer"
+};
+
+/*
+ * Initialize the conversion factor and the min/max deltas of the clock event
+ * structure and register the clock event source with the framework.
+ */
+void __init setup_mfgpt0_timer(void)
+{
+       u32 basehi;
+       struct clock_event_device *cd = &mfgpt_clockevent;
+       unsigned int cpu = smp_processor_id();
+
+       cd->cpumask = cpumask_of(cpu);
+       clockevent_set_clock(cd, MFGPT_TICK_RATE);
+       cd->max_delta_ns = clockevent_delta2ns(0xffff, cd);
+       cd->min_delta_ns = clockevent_delta2ns(0xf, cd);
+
+       /* Enable MFGPT0 Comparator 2 Output to the Interrupt Mapper */
+       _wrmsr(DIVIL_MSR_REG(MFGPT_IRQ), 0, 0x100);
+
+       /* Enable Interrupt Gate 5 */
+       _wrmsr(DIVIL_MSR_REG(PIC_ZSEL_LOW), 0, 0x50000);
+
+       /* get MFGPT base address */
+       _rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_MFGPT), &basehi, &mfgpt_base);
+
+       clockevents_register_device(cd);
+
+       setup_irq(CS5536_MFGPT_INTR, &irq5);
+}
+
+/*
+ * Since the MFGPT overflows every tick, its not very useful
+ * to just read by itself. So use jiffies to emulate a free
+ * running counter:
+ */
+static cycle_t mfgpt_read(struct clocksource *cs)
+{
+       unsigned long flags;
+       int count;
+       u32 jifs;
+       static int old_count;
+       static u32 old_jifs;
+
+       spin_lock_irqsave(&mfgpt_lock, flags);
+       /*
+        * Although our caller may have the read side of xtime_lock,
+        * this is now a seqlock, and we are cheating in this routine
+        * by having side effects on state that we cannot undo if
+        * there is a collision on the seqlock and our caller has to
+        * retry.  (Namely, old_jifs and old_count.)  So we must treat
+        * jiffies as volatile despite the lock.  We read jiffies
+        * before latching the timer count to guarantee that although
+        * the jiffies value might be older than the count (that is,
+        * the counter may underflow between the last point where
+        * jiffies was incremented and the point where we latch the
+        * count), it cannot be newer.
+        */
+       jifs = jiffies;
+       /* read the count */
+       count = inw(MFGPT0_CNT);
+
+       /*
+        * It's possible for count to appear to go the wrong way for this
+        * reason:
+        *
+        *  The timer counter underflows, but we haven't handled the resulting
+        *  interrupt and incremented jiffies yet.
+        *
+        * Previous attempts to handle these cases intelligently were buggy, so
+        * we just do the simple thing now.
+        */
+       if (count < old_count && jifs == old_jifs)
+               count = old_count;
+
+       old_count = count;
+       old_jifs = jifs;
+
+       spin_unlock_irqrestore(&mfgpt_lock, flags);
+
+       return (cycle_t) (jifs * COMPARE) + count;
+}
+
+static struct clocksource clocksource_mfgpt = {
+       .name = "mfgpt",
+       .rating = 120, /* Functional for real use, but not desired */
+       .read = mfgpt_read,
+       .mask = CLOCKSOURCE_MASK(32),
+       .mult = 0,
+       .shift = 22,
+};
+
+int __init init_mfgpt_clocksource(void)
+{
+       if (num_possible_cpus() > 1)    /* MFGPT does not scale! */
+               return 0;
+
+       clocksource_mfgpt.mult = clocksource_hz2mult(MFGPT_TICK_RATE, 22);
+       return clocksource_register(&clocksource_mfgpt);
+}
+
+arch_initcall(init_mfgpt_clocksource);
diff --git a/arch/mips/loongson/common/cs5536/cs5536_ohci.c b/arch/mips/loongson/common/cs5536/cs5536_ohci.c
new file mode 100644 (file)
index 0000000..8fdb02b
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * the OHCI Virtual Support Module of AMD CS5536
+ *
+ * Copyright (C) 2007 Lemote, Inc.
+ * Author : jlliu, liujl@lemote.com
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <cs5536/cs5536.h>
+#include <cs5536/cs5536_pci.h>
+
+void pci_ohci_write_reg(int reg, u32 value)
+{
+       u32 hi = 0, lo = value;
+
+       switch (reg) {
+       case PCI_COMMAND:
+               _rdmsr(USB_MSR_REG(USB_OHCI), &hi, &lo);
+               if (value & PCI_COMMAND_MASTER)
+                       hi |= PCI_COMMAND_MASTER;
+               else
+                       hi &= ~PCI_COMMAND_MASTER;
+
+               if (value & PCI_COMMAND_MEMORY)
+                       hi |= PCI_COMMAND_MEMORY;
+               else
+                       hi &= ~PCI_COMMAND_MEMORY;
+               _wrmsr(USB_MSR_REG(USB_OHCI), hi, lo);
+               break;
+       case PCI_STATUS:
+               if (value & PCI_STATUS_PARITY) {
+                       _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+                       if (lo & SB_PARE_ERR_FLAG) {
+                               lo = (lo & 0x0000ffff) | SB_PARE_ERR_FLAG;
+                               _wrmsr(SB_MSR_REG(SB_ERROR), hi, lo);
+                       }
+               }
+               break;
+       case PCI_BAR0_REG:
+               if (value == PCI_BAR_RANGE_MASK) {
+                       _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+                       lo |= SOFT_BAR_OHCI_FLAG;
+                       _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+               } else if ((value & 0x01) == 0x00) {
+                       _wrmsr(USB_MSR_REG(USB_OHCI), hi, lo);
+
+                       value &= 0xfffffff0;
+                       hi = 0x40000000 | ((value & 0xff000000) >> 24);
+                       lo = 0x000fffff | ((value & 0x00fff000) << 8);
+                       _wrmsr(GLIU_MSR_REG(GLIU_P2D_BM3), hi, lo);
+               }
+               break;
+       case PCI_OHCI_INT_REG:
+               _rdmsr(DIVIL_MSR_REG(PIC_YSEL_LOW), &hi, &lo);
+               lo &= ~(0xf << PIC_YSEL_LOW_USB_SHIFT);
+               if (value)      /* enable all the usb interrupt in PIC */
+                       lo |= (CS5536_USB_INTR << PIC_YSEL_LOW_USB_SHIFT);
+               _wrmsr(DIVIL_MSR_REG(PIC_YSEL_LOW), hi, lo);
+               break;
+       default:
+               break;
+       }
+}
+
+u32 pci_ohci_read_reg(int reg)
+{
+       u32 conf_data = 0;
+       u32 hi, lo;
+
+       switch (reg) {
+       case PCI_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_OHCI_DEVICE_ID, CS5536_VENDOR_ID);
+               break;
+       case PCI_COMMAND:
+               _rdmsr(USB_MSR_REG(USB_OHCI), &hi, &lo);
+               if (hi & PCI_COMMAND_MASTER)
+                       conf_data |= PCI_COMMAND_MASTER;
+               if (hi & PCI_COMMAND_MEMORY)
+                       conf_data |= PCI_COMMAND_MEMORY;
+               break;
+       case PCI_STATUS:
+               conf_data |= PCI_STATUS_66MHZ;
+               conf_data |= PCI_STATUS_FAST_BACK;
+               _rdmsr(SB_MSR_REG(SB_ERROR), &hi, &lo);
+               if (lo & SB_PARE_ERR_FLAG)
+                       conf_data |= PCI_STATUS_PARITY;
+               conf_data |= PCI_STATUS_DEVSEL_MEDIUM;
+               break;
+       case PCI_CLASS_REVISION:
+               _rdmsr(USB_MSR_REG(USB_CAP), &hi, &lo);
+               conf_data = lo & 0x000000ff;
+               conf_data |= (CS5536_OHCI_CLASS_CODE << 8);
+               break;
+       case PCI_CACHE_LINE_SIZE:
+               conf_data =
+                   CFG_PCI_CACHE_LINE_SIZE(PCI_NORMAL_HEADER_TYPE,
+                                           PCI_NORMAL_LATENCY_TIMER);
+               break;
+       case PCI_BAR0_REG:
+               _rdmsr(GLCP_MSR_REG(GLCP_SOFT_COM), &hi, &lo);
+               if (lo & SOFT_BAR_OHCI_FLAG) {
+                       conf_data = CS5536_OHCI_RANGE |
+                           PCI_BASE_ADDRESS_SPACE_MEMORY;
+                       lo &= ~SOFT_BAR_OHCI_FLAG;
+                       _wrmsr(GLCP_MSR_REG(GLCP_SOFT_COM), hi, lo);
+               } else {
+                       _rdmsr(USB_MSR_REG(USB_OHCI), &hi, &lo);
+                       conf_data = lo & 0xffffff00;
+                       conf_data &= ~0x0000000f;       /* 32bit mem */
+               }
+               break;
+       case PCI_CARDBUS_CIS:
+               conf_data = PCI_CARDBUS_CIS_POINTER;
+               break;
+       case PCI_SUBSYSTEM_VENDOR_ID:
+               conf_data =
+                   CFG_PCI_VENDOR_ID(CS5536_OHCI_SUB_ID, CS5536_SUB_VENDOR_ID);
+               break;
+       case PCI_ROM_ADDRESS:
+               conf_data = PCI_EXPANSION_ROM_BAR;
+               break;
+       case PCI_CAPABILITY_LIST:
+               conf_data = PCI_CAPLIST_USB_POINTER;
+               break;
+       case PCI_INTERRUPT_LINE:
+               conf_data =
+                   CFG_PCI_INTERRUPT_LINE(PCI_DEFAULT_PIN, CS5536_USB_INTR);
+               break;
+       case PCI_OHCI_INT_REG:
+               _rdmsr(DIVIL_MSR_REG(PIC_YSEL_LOW), &hi, &lo);
+               if ((lo & 0x00000f00) == CS5536_USB_INTR)
+                       conf_data = 1;
+               break;
+       default:
+               break;
+       }
+
+       return conf_data;
+}
diff --git a/arch/mips/loongson/common/cs5536/cs5536_pci.c b/arch/mips/loongson/common/cs5536/cs5536_pci.c
new file mode 100644 (file)
index 0000000..e23f3d7
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * read/write operation to the PCI config space of CS5536
+ *
+ * Copyright (C) 2007 Lemote, Inc.
+ * Author : jlliu, liujl@lemote.com
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ *     the Virtual Support Module(VSM) for virtulizing the PCI
+ *     configure space are defined in cs5536_modulename.c respectively,
+ *
+ *     after this virtulizing, user can access the PCI configure space
+ *     directly as a normal multi-function PCI device which follows
+ *     the PCI-2.2 spec.
+ */
+
+#include <linux/types.h>
+#include <cs5536/cs5536_vsm.h>
+
+enum {
+       CS5536_FUNC_START = -1,
+       CS5536_ISA_FUNC,
+       reserved_func,
+       CS5536_IDE_FUNC,
+       CS5536_ACC_FUNC,
+       CS5536_OHCI_FUNC,
+       CS5536_EHCI_FUNC,
+       CS5536_FUNC_END,
+};
+
+static const cs5536_pci_vsm_write vsm_conf_write[] = {
+       [CS5536_ISA_FUNC]       pci_isa_write_reg,
+       [reserved_func]         NULL,
+       [CS5536_IDE_FUNC]       pci_ide_write_reg,
+       [CS5536_ACC_FUNC]       pci_acc_write_reg,
+       [CS5536_OHCI_FUNC]      pci_ohci_write_reg,
+       [CS5536_EHCI_FUNC]      pci_ehci_write_reg,
+};
+
+static const cs5536_pci_vsm_read vsm_conf_read[] = {
+       [CS5536_ISA_FUNC]       pci_isa_read_reg,
+       [reserved_func]         NULL,
+       [CS5536_IDE_FUNC]       pci_ide_read_reg,
+       [CS5536_ACC_FUNC]       pci_acc_read_reg,
+       [CS5536_OHCI_FUNC]      pci_ohci_read_reg,
+       [CS5536_EHCI_FUNC]      pci_ehci_read_reg,
+};
+
+/*
+ * write to PCI config space and transfer it to MSR write.
+ */
+void cs5536_pci_conf_write4(int function, int reg, u32 value)
+{
+       if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))
+               return;
+       if ((reg < 0) || (reg > 0x100) || ((reg & 0x03) != 0))
+               return;
+
+       if (vsm_conf_write[function] != NULL)
+               vsm_conf_write[function](reg, value);
+}
+
+/*
+ * read PCI config space and transfer it to MSR access.
+ */
+u32 cs5536_pci_conf_read4(int function, int reg)
+{
+       u32 data = 0;
+
+       if ((function <= CS5536_FUNC_START) || (function >= CS5536_FUNC_END))
+               return 0;
+       if ((reg < 0) || ((reg & 0x03) != 0))
+               return 0;
+       if (reg > 0x100)
+               return 0xffffffff;
+
+       if (vsm_conf_read[function] != NULL)
+               data = vsm_conf_read[function](reg);
+
+       return data;
+}
index bc73edc0cfd8a6532b37884141d89b5ccfc6f298..23e7a8f8897f6626b77d1511df9fcf6176b8e5e0 100644 (file)
@@ -1,7 +1,7 @@
 /*  early printk support
  *
  *  Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca>
- *  Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
+ *  Copyright (c) 2009 Lemote Inc.
  *  Author: Wu Zhangjin, wuzj@lemote.com
  *
  *  This program is free software; you can redistribute  it and/or modify it
 #include <linux/serial_reg.h>
 
 #include <loongson.h>
-#include <machine.h>
 
 #define PORT(base, offset) (u8 *)(base + offset)
 
-static inline unsigned int serial_in(phys_addr_t base, int offset)
+static inline unsigned int serial_in(unsigned char *base, int offset)
 {
        return readb(PORT(base, offset));
 }
 
-static inline void serial_out(phys_addr_t base, int offset, int value)
+static inline void serial_out(unsigned char *base, int offset, int value)
 {
        writeb(value, PORT(base, offset));
 }
 
 void prom_putchar(char c)
 {
-       phys_addr_t uart_base =
-               (phys_addr_t) ioremap_nocache(LOONGSON_UART_BASE, 8);
+       int timeout;
+       unsigned char *uart_base;
 
-       while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0)
+       uart_base = (unsigned char *)_loongson_uart_base;
+       timeout = 1024;
+
+       while (((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) &&
+                       (timeout-- > 0))
                ;
 
        serial_out(uart_base, UART_TX, c);
index b9ef50385541a42545a83e9caf62a464f9b8b81d..196d947d929afcf39362aaa1069ee83b01e17ae7 100644 (file)
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
  */
+#include <linux/module.h>
+
 #include <asm/bootinfo.h>
 
 #include <loongson.h>
 
 unsigned long bus_clock, cpu_clock_freq;
+EXPORT_SYMBOL(cpu_clock_freq);
 unsigned long memsize, highmemsize;
 
 /* pmon passes arguments in 32bit pointers */
index 3abe927422a3acfe3fea5c07030b5ed1e0c86cf8..a2abd9355737140d91c98e2c092a7d51543eee32 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
+ * Copyright (C) 2009 Lemote Inc.
  * Author: Wu Zhangjin, wuzj@lemote.com
  *
  * This program is free software; you can redistribute  it and/or modify it
 
 #include <linux/bootmem.h>
 
-#include <asm/bootinfo.h>
-
 #include <loongson.h>
 
+/* Loongson CPU address windows config space base address */
+unsigned long __maybe_unused _loongson_addrwincfg_base;
+
 void __init prom_init(void)
 {
-    /* init base address of io space */
+       /* init base address of io space */
        set_io_port_base((unsigned long)
-               ioremap(BONITO_PCIIO_BASE, BONITO_PCIIO_SIZE));
+               ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE));
+
+#ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
+       _loongson_addrwincfg_base = (unsigned long)
+               ioremap(LOONGSON_ADDRWINCFG_BASE, LOONGSON_ADDRWINCFG_SIZE);
+#endif
 
        prom_init_cmdline();
        prom_init_env();
        prom_init_memory();
+
+       /*init the uart base address */
+       prom_init_uart_base();
 }
 
 void __init prom_free_prom_memory(void)
index b32b4a3e513772b94b7376218ceeaa699631bed8..20e7328319787e3554f479890ea75736575e1117 100644 (file)
@@ -20,21 +20,21 @@ void bonito_irqdispatch(void)
        int i;
 
        /* workaround the IO dma problem: let cpu looping to allow DMA finish */
-       int_status = BONITO_INTISR;
+       int_status = LOONGSON_INTISR;
        if (int_status & (1 << 10)) {
                while (int_status & (1 << 10)) {
                        udelay(1);
-                       int_status = BONITO_INTISR;
+                       int_status = LOONGSON_INTISR;
                }
        }
 
        /* Get pending sources, masked by current enables */
-       int_status = BONITO_INTISR & BONITO_INTEN;
+       int_status = LOONGSON_INTISR & LOONGSON_INTEN;
 
        if (int_status != 0) {
                i = __ffs(int_status);
                int_status &= ~(1 << i);
-               do_IRQ(BONITO_IRQ_BASE + i);
+               do_IRQ(LOONGSON_IRQ_BASE + i);
        }
 }
 
@@ -60,13 +60,13 @@ void __init arch_init_irq(void)
        set_irq_trigger_mode();
 
        /* no steer */
-       BONITO_INTSTEER = 0;
+       LOONGSON_INTSTEER = 0;
 
        /*
         * Mask out all interrupt by writing "1" to all bit position in
         * the interrupt reset reg.
         */
-       BONITO_INTENCLR = ~0;
+       LOONGSON_INTENCLR = ~0;
 
        /* machine specific irq init */
        mach_init_irq();
index 7b348248de7d21693524423bf8e118d18bf30eab..0ed52b3f5314ccc1d9b4d6e3761c4f7467001a57 100644 (file)
@@ -15,6 +15,9 @@
 #include <loongson.h>
 #include <machine.h>
 
+/* please ensure the length of the machtype string is less than 50 */
+#define MACHTYPE_LEN 50
+
 static const char *system_types[] = {
        [MACH_LOONGSON_UNKNOWN]         "unknown loongson machine",
        [MACH_LEMOTE_FL2E]              "lemote-fuloong-2e-box",
@@ -22,29 +25,35 @@ static const char *system_types[] = {
        [MACH_LEMOTE_ML2F7]             "lemote-mengloong-2f-7inches",
        [MACH_LEMOTE_YL2F89]            "lemote-yeeloong-2f-8.9inches",
        [MACH_DEXXON_GDIUM2F10]         "dexxon-gidum-2f-10inches",
+       [MACH_LEMOTE_NAS]               "lemote-nas-2f",
+       [MACH_LEMOTE_LL2F]              "lemote-lynloong-2f",
        [MACH_LOONGSON_END]             NULL,
 };
 
 const char *get_system_type(void)
 {
-       if (mips_machtype == MACH_UNKNOWN)
-               mips_machtype = LOONGSON_MACHTYPE;
-
        return system_types[mips_machtype];
 }
 
-static __init int machtype_setup(char *str)
+void __init prom_init_machtype(void)
 {
+       char *p, str[MACHTYPE_LEN];
        int machtype = MACH_LEMOTE_FL2E;
 
-       if (!str)
-               return -EINVAL;
+       mips_machtype = LOONGSON_MACHTYPE;
+
+       p = strstr(arcs_cmdline, "machtype=");
+       if (!p)
+               return;
+       p += strlen("machtype=");
+       strncpy(str, p, MACHTYPE_LEN);
+       p = strstr(str, " ");
+       if (p)
+               *p = '\0';
 
        for (; system_types[machtype]; machtype++)
                if (strstr(system_types[machtype], str)) {
                        mips_machtype = machtype;
                        break;
                }
-       return 0;
 }
-__setup("machtype=", machtype_setup);
index e94ef158f9800630dd23a158dec374a6b861cbc0..ceacd092b4461f00679eab624c92b8412b6141db 100644 (file)
 
 #include <loongson.h>
 #include <mem.h>
+#include <pci.h>
 
 void __init prom_init_memory(void)
 {
     add_memory_region(0x0, (memsize << 20), BOOT_MEM_RAM);
+
+    add_memory_region(memsize << 20, LOONGSON_PCI_MEM_START - (memsize <<
+                           20), BOOT_MEM_RESERVED);
+#ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
+       {
+               int bit;
+
+               bit = fls(memsize + highmemsize);
+               if (bit != ffs(memsize + highmemsize))
+                       bit += 20;
+               else
+                       bit = bit + 20 - 1;
+
+               /* set cpu window3 to map CPU to DDR: 2G -> 2G */
+               LOONGSON_ADDRWIN_CPUTODDR(ADDRWIN_WIN3, 0x80000000ul,
+                                         0x80000000ul, (1 << bit));
+               mmiowb();
+       }
+#endif /* !CONFIG_CPU_SUPPORTS_ADDRWINCFG */
+
 #ifdef CONFIG_64BIT
-    if (highmemsize > 0)
-       add_memory_region(LOONGSON_HIGHMEM_START,
-               highmemsize << 20, BOOT_MEM_RAM);
-#endif /* CONFIG_64BIT */
+       if (highmemsize > 0)
+               add_memory_region(LOONGSON_HIGHMEM_START,
+                                 highmemsize << 20, BOOT_MEM_RAM);
+
+       add_memory_region(LOONGSON_PCI_MEM_END + 1, LOONGSON_HIGHMEM_START -
+                         LOONGSON_PCI_MEM_END - 1, BOOT_MEM_RESERVED);
+
+#endif /* !CONFIG_64BIT */
 }
 
 /* override of arch/mips/mm/cache.c: __uncached_access */
@@ -33,3 +58,61 @@ int __uncached_access(struct file *file, unsigned long addr)
                ((addr >= LOONGSON_MMIO_MEM_START) &&
                 (addr < LOONGSON_MMIO_MEM_END));
 }
+
+#ifdef CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED
+
+#include <linux/pci.h>
+#include <linux/sched.h>
+#include <asm/current.h>
+
+static unsigned long uca_start, uca_end;
+
+pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
+                             unsigned long size, pgprot_t vma_prot)
+{
+       unsigned long offset = pfn << PAGE_SHIFT;
+       unsigned long end = offset + size;
+
+       if (__uncached_access(file, offset)) {
+               if (((uca_start && offset) >= uca_start) &&
+                   (end <= uca_end))
+                       return __pgprot((pgprot_val(vma_prot) &
+                                        ~_CACHE_MASK) |
+                                       _CACHE_UNCACHED_ACCELERATED);
+               else
+                       return pgprot_noncached(vma_prot);
+       }
+       return vma_prot;
+}
+
+static int __init find_vga_mem_init(void)
+{
+       struct pci_dev *dev = 0;
+       struct resource *r;
+       int idx;
+
+       if (uca_start)
+               return 0;
+
+       for_each_pci_dev(dev) {
+               if ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA) {
+                       for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
+                               r = &dev->resource[idx];
+                               if (!r->start && r->end)
+                                       continue;
+                               if (r->flags & IORESOURCE_IO)
+                                       continue;
+                               if (r->flags & IORESOURCE_MEM) {
+                                       uca_start = r->start;
+                                       uca_end = r->end;
+                                       return 0;
+                               }
+                       }
+               }
+       }
+
+       return 0;
+}
+
+late_initcall(find_vga_mem_init);
+#endif /* !CONFIG_CPU_SUPPORTS_UNCACHED_ACCELERATED */
index a3a4abfb6c9ac33ba3cbccffc341a323aa189732..31d8c5ecd16cec95a42e5cf8def476634f79ca3e 100644 (file)
@@ -27,7 +27,7 @@ static struct resource loongson_pci_io_resource = {
 };
 
 static struct pci_controller  loongson_pci_controller = {
-       .pci_ops        = &bonito64_pci_ops,
+       .pci_ops        = &loongson_pci_ops,
        .io_resource    = &loongson_pci_io_resource,
        .mem_resource   = &loongson_pci_mem_resource,
        .mem_offset     = 0x00000000UL,
@@ -44,15 +44,15 @@ static void __init setup_pcimap(void)
         * pcimap: PCI_MAP2  PCI_Mem_Lo2 PCI_Mem_Lo1 PCI_Mem_Lo0
         *           [<2G]   [384M,448M] [320M,384M] [0M,64M]
         */
-       BONITO_PCIMAP = BONITO_PCIMAP_PCIMAP_2 |
-               BONITO_PCIMAP_WIN(2, BONITO_PCILO2_BASE) |
-               BONITO_PCIMAP_WIN(1, BONITO_PCILO1_BASE) |
-               BONITO_PCIMAP_WIN(0, 0);
+       LOONGSON_PCIMAP = LOONGSON_PCIMAP_PCIMAP_2 |
+               LOONGSON_PCIMAP_WIN(2, LOONGSON_PCILO2_BASE) |
+               LOONGSON_PCIMAP_WIN(1, LOONGSON_PCILO1_BASE) |
+               LOONGSON_PCIMAP_WIN(0, 0);
 
        /*
         * PCI-DMA to local mapping: [2G,2G+256M] -> [0M,256M]
         */
-       BONITO_PCIBASE0 = 0x80000000ul;   /* base: 2G -> mmap: 0M */
+       LOONGSON_PCIBASE0 = 0x80000000ul;   /* base: 2G -> mmap: 0M */
        /* size: 256M, burst transmission, pre-fetch enable, 64bit */
        LOONGSON_PCI_HIT0_SEL_L = 0xc000000cul;
        LOONGSON_PCI_HIT0_SEL_H = 0xfffffffful;
@@ -67,6 +67,14 @@ static void __init setup_pcimap(void)
        /* can not change gnt to break pci transfer when device's gnt not
        deassert for some broken device */
        LOONGSON_PXARB_CFG = 0x00fe0105ul;
+
+#ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG
+       /*
+        * set cpu addr window2 to map CPU address space to PCI address space
+        */
+       LOONGSON_ADDRWIN_CPUTOPCI(ADDRWIN_WIN2, LOONGSON_CPU_MEM_SRC,
+               LOONGSON_PCI_MEM_DST, MMAP_CPUTOPCI_SIZE);
+#endif
 }
 
 static int __init pcibios_init(void)
diff --git a/arch/mips/loongson/common/platform.c b/arch/mips/loongson/common/platform.c
new file mode 100644 (file)
index 0000000..be81777
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2009 Lemote Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/err.h>
+#include <linux/platform_device.h>
+
+static struct platform_device loongson2_cpufreq_device = {
+       .name = "loongson2_cpufreq",
+       .id = -1,
+};
+
+static int __init loongson2_cpufreq_init(void)
+{
+       struct cpuinfo_mips *c = &current_cpu_data;
+
+       /* Only 2F revision and it's successors support CPUFreq */
+       if ((c->processor_id & PRID_REV_MASK) >= PRID_REV_LOONGSON2F)
+               return platform_device_register(&loongson2_cpufreq_device);
+
+       return -ENODEV;
+}
+
+arch_initcall(loongson2_cpufreq_init);
diff --git a/arch/mips/loongson/common/pm.c b/arch/mips/loongson/common/pm.c
new file mode 100644 (file)
index 0000000..b625fec
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * loongson-specific suspend support
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include <linux/suspend.h>
+#include <linux/interrupt.h>
+#include <linux/pm.h>
+
+#include <asm/i8259.h>
+#include <asm/mipsregs.h>
+
+#include <loongson.h>
+
+static unsigned int __maybe_unused cached_master_mask; /* i8259A */
+static unsigned int __maybe_unused cached_slave_mask;
+static unsigned int __maybe_unused cached_bonito_irq_mask; /* bonito */
+
+void arch_suspend_disable_irqs(void)
+{
+       /* disable all mips events */
+       local_irq_disable();
+
+#ifdef CONFIG_I8259
+       /* disable all events of i8259A */
+       cached_slave_mask = inb(PIC_SLAVE_IMR);
+       cached_master_mask = inb(PIC_MASTER_IMR);
+
+       outb(0xff, PIC_SLAVE_IMR);
+       inb(PIC_SLAVE_IMR);
+       outb(0xff, PIC_MASTER_IMR);
+       inb(PIC_MASTER_IMR);
+#endif
+       /* disable all events of bonito */
+       cached_bonito_irq_mask = LOONGSON_INTEN;
+       LOONGSON_INTENCLR = 0xffff;
+       (void)LOONGSON_INTENCLR;
+}
+
+void arch_suspend_enable_irqs(void)
+{
+       /* enable all mips events */
+       local_irq_enable();
+#ifdef CONFIG_I8259
+       /* only enable the cached events of i8259A */
+       outb(cached_slave_mask, PIC_SLAVE_IMR);
+       outb(cached_master_mask, PIC_MASTER_IMR);
+#endif
+       /* enable all cached events of bonito */
+       LOONGSON_INTENSET = cached_bonito_irq_mask;
+       (void)LOONGSON_INTENSET;
+}
+
+/*
+ * Setup the board-specific events for waking up loongson from wait mode
+ */
+void __weak setup_wakeup_events(void)
+{
+}
+
+/*
+ * Check wakeup events
+ */
+int __weak wakeup_loongson(void)
+{
+       return 1;
+}
+
+/*
+ * If the events are really what we want to wakeup the CPU, wake it up
+ * otherwise put the CPU asleep again.
+ */
+static void wait_for_wakeup_events(void)
+{
+       while (!wakeup_loongson())
+               LOONGSON_CHIPCFG0 &= ~0x7;
+}
+
+/*
+ * Stop all perf counters
+ *
+ * $24 is the control register of Loongson perf counter
+ */
+static inline void stop_perf_counters(void)
+{
+       __write_64bit_c0_register($24, 0, 0);
+}
+
+
+static void loongson_suspend_enter(void)
+{
+       static unsigned int cached_cpu_freq;
+
+       /* setup wakeup events via enabling the IRQs */
+       setup_wakeup_events();
+
+       stop_perf_counters();
+
+       cached_cpu_freq = LOONGSON_CHIPCFG0;
+
+       /* Put CPU into wait mode */
+       LOONGSON_CHIPCFG0 &= ~0x7;
+
+       /* wait for the given events to wakeup cpu from wait mode */
+       wait_for_wakeup_events();
+
+       LOONGSON_CHIPCFG0 = cached_cpu_freq;
+       mmiowb();
+}
+
+void __weak mach_suspend(void)
+{
+}
+
+void __weak mach_resume(void)
+{
+}
+
+static int loongson_pm_enter(suspend_state_t state)
+{
+       mach_suspend();
+
+       /* processor specific suspend */
+       loongson_suspend_enter();
+
+       mach_resume();
+
+       return 0;
+}
+
+static int loongson_pm_valid_state(suspend_state_t state)
+{
+       switch (state) {
+       case PM_SUSPEND_ON:
+       case PM_SUSPEND_STANDBY:
+       case PM_SUSPEND_MEM:
+               return 1;
+
+       default:
+               return 0;
+       }
+}
+
+static struct platform_suspend_ops loongson_pm_ops = {
+       .valid  = loongson_pm_valid_state,
+       .enter  = loongson_pm_enter,
+};
+
+static int __init loongson_pm_init(void)
+{
+       suspend_set_ops(&loongson_pm_ops);
+
+       return 0;
+}
+arch_initcall(loongson_pm_init);
index 97e918251edd4b84507e8c8c6d160f2b82a55544..d57f1719da959b669dc7810b121cb95a7cf2a112 100644 (file)
@@ -22,7 +22,7 @@ static void loongson_restart(char *command)
        mach_prepare_reboot();
 
        /* reboot via jumping to boot base address */
-       ((void (*)(void))ioremap_nocache(BONITO_BOOT_BASE, 4)) ();
+       ((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) ();
 }
 
 static void loongson_halt(void)
diff --git a/arch/mips/loongson/common/serial.c b/arch/mips/loongson/common/serial.c
new file mode 100644 (file)
index 0000000..23b66a5
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Yan hua (yanhua@lemote.com)
+ * Author: Wu Zhangjin (wuzj@lemote.com)
+ */
+
+#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/serial_8250.h>
+
+#include <asm/bootinfo.h>
+
+#include <loongson.h>
+#include <machine.h>
+
+#define PORT(int)                      \
+{                                                              \
+       .irq            = int,                                  \
+       .uartclk        = 1843200,                              \
+       .iotype         = UPIO_PORT,                            \
+       .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,    \
+       .regshift       = 0,                                    \
+}
+
+#define PORT_M(int)                            \
+{                                                              \
+       .irq            = MIPS_CPU_IRQ_BASE + (int),            \
+       .uartclk        = 3686400,                              \
+       .iotype         = UPIO_MEM,                             \
+       .membase        = (void __iomem *)NULL,                 \
+       .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,    \
+       .regshift       = 0,                                    \
+}
+
+static struct plat_serial8250_port uart8250_data[][2] = {
+       [MACH_LOONGSON_UNKNOWN]         {},
+       [MACH_LEMOTE_FL2E]              {PORT(4), {} },
+       [MACH_LEMOTE_FL2F]              {PORT(3), {} },
+       [MACH_LEMOTE_ML2F7]             {PORT_M(3), {} },
+       [MACH_LEMOTE_YL2F89]            {PORT_M(3), {} },
+       [MACH_DEXXON_GDIUM2F10]         {PORT_M(3), {} },
+       [MACH_LEMOTE_NAS]               {PORT_M(3), {} },
+       [MACH_LEMOTE_LL2F]              {PORT(3), {} },
+       [MACH_LOONGSON_END]             {},
+};
+
+static struct platform_device uart8250_device = {
+       .name = "serial8250",
+       .id = PLAT8250_DEV_PLATFORM,
+};
+
+static int __init serial_init(void)
+{
+       unsigned char iotype;
+
+       iotype = uart8250_data[mips_machtype][0].iotype;
+
+       if (UPIO_MEM == iotype)
+               uart8250_data[mips_machtype][0].membase =
+                       (void __iomem *)_loongson_uart_base;
+       else if (UPIO_PORT == iotype)
+               uart8250_data[mips_machtype][0].iobase =
+                   loongson_uart_base - LOONGSON_PCIIO_BASE;
+
+       uart8250_device.dev.platform_data = uart8250_data[mips_machtype];
+
+       return platform_device_register(&uart8250_device);
+}
+
+device_initcall(serial_init);
index 6e08c8270abe945a2467d148d6cb1615f850b220..35f0b66a94f5a96dc13db103ff9e557894c9eba5 100644 (file)
 #include <asm/time.h>
 
 #include <loongson.h>
+#include <cs5536/cs5536_mfgpt.h>
 
 void __init plat_time_init(void)
 {
        /* setup mips r4k timer */
        mips_hpt_frequency = cpu_clock_freq / 2;
+
+       setup_mfgpt0_timer();
 }
 
 void read_persistent_clock(struct timespec *ts)
diff --git a/arch/mips/loongson/common/uart_base.c b/arch/mips/loongson/common/uart_base.c
new file mode 100644 (file)
index 0000000..78ff66a
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2009 Lemote Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/module.h>
+#include <asm/bootinfo.h>
+
+#include <loongson.h>
+
+/* ioremapped */
+unsigned long _loongson_uart_base;
+EXPORT_SYMBOL(_loongson_uart_base);
+/* raw */
+unsigned long loongson_uart_base;
+EXPORT_SYMBOL(loongson_uart_base);
+
+void prom_init_loongson_uart_base(void)
+{
+       switch (mips_machtype) {
+       case MACH_LEMOTE_FL2E:
+               loongson_uart_base = LOONGSON_PCIIO_BASE + 0x3f8;
+               break;
+       case MACH_LEMOTE_FL2F:
+       case MACH_LEMOTE_LL2F:
+               loongson_uart_base = LOONGSON_PCIIO_BASE + 0x2f8;
+               break;
+       case MACH_LEMOTE_ML2F7:
+       case MACH_LEMOTE_YL2F89:
+       case MACH_DEXXON_GDIUM2F10:
+       case MACH_LEMOTE_NAS:
+       default:
+               /* The CPU provided serial port */
+               loongson_uart_base = LOONGSON_LIO1_BASE + 0x3f8;
+               break;
+       }
+
+       _loongson_uart_base =
+               (unsigned long)ioremap_nocache(loongson_uart_base, 8);
+}
index 7888cf69424af197171d12941a0ab6f01d162472..320e9379bdd769e9171b5287218619ccf13de7c3 100644 (file)
@@ -47,8 +47,8 @@ static struct irqaction cascade_irqaction = {
 void __init set_irq_trigger_mode(void)
 {
        /* most bonito irq should be level triggered */
-       BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR |
-           BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES;
+       LOONGSON_INTEDGE = LOONGSON_ICU_SYSTEMERR | LOONGSON_ICU_MASTERERR |
+           LOONGSON_ICU_RETRYERR | LOONGSON_ICU_MBOXES;
 }
 
 void __init mach_init_irq(void)
index 677fe186db9500d771a6895151a4232ee9005a18..fc16c677d476ae0848af43d80f8f51daf9b14f15 100644 (file)
@@ -14,8 +14,8 @@
 
 void mach_prepare_reboot(void)
 {
-       BONITO_BONGENCFG &= ~(1 << 2);
-       BONITO_BONGENCFG |= (1 << 2);
+       LOONGSON_GENCFG &= ~(1 << 2);
+       LOONGSON_GENCFG |= (1 << 2);
 }
 
 void mach_prepare_shutdown(void)
diff --git a/arch/mips/loongson/lemote-2f/Makefile b/arch/mips/loongson/lemote-2f/Makefile
new file mode 100644 (file)
index 0000000..4d84b27
--- /dev/null
@@ -0,0 +1,11 @@
+#
+# Makefile for lemote loongson2f family machines
+#
+
+obj-y += irq.o reset.o ec_kb3310b.o
+
+#
+# Suspend Support
+#
+
+obj-$(CONFIG_LOONGSON_SUSPEND) += pm.o
diff --git a/arch/mips/loongson/lemote-2f/ec_kb3310b.c b/arch/mips/loongson/lemote-2f/ec_kb3310b.c
new file mode 100644 (file)
index 0000000..4d84111
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Basic KB3310B Embedded Controller support for the YeeLoong 2F netbook
+ *
+ *  Copyright (C) 2008 Lemote Inc.
+ *  Author: liujl <liujl@lemote.com>, 2008-04-20
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <linux/delay.h>
+
+#include "ec_kb3310b.h"
+
+static DEFINE_SPINLOCK(index_access_lock);
+static DEFINE_SPINLOCK(port_access_lock);
+
+unsigned char ec_read(unsigned short addr)
+{
+       unsigned char value;
+       unsigned long flags;
+
+       spin_lock_irqsave(&index_access_lock, flags);
+       outb((addr & 0xff00) >> 8, EC_IO_PORT_HIGH);
+       outb((addr & 0x00ff), EC_IO_PORT_LOW);
+       value = inb(EC_IO_PORT_DATA);
+       spin_unlock_irqrestore(&index_access_lock, flags);
+
+       return value;
+}
+EXPORT_SYMBOL_GPL(ec_read);
+
+void ec_write(unsigned short addr, unsigned char val)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&index_access_lock, flags);
+       outb((addr & 0xff00) >> 8, EC_IO_PORT_HIGH);
+       outb((addr & 0x00ff), EC_IO_PORT_LOW);
+       outb(val, EC_IO_PORT_DATA);
+       /*  flush the write action */
+       inb(EC_IO_PORT_DATA);
+       spin_unlock_irqrestore(&index_access_lock, flags);
+
+       return;
+}
+EXPORT_SYMBOL_GPL(ec_write);
+
+/*
+ * This function is used for EC command writes and corresponding status queries.
+ */
+int ec_query_seq(unsigned char cmd)
+{
+       int timeout;
+       unsigned char status;
+       unsigned long flags;
+       int ret = 0;
+
+       spin_lock_irqsave(&port_access_lock, flags);
+
+       /* make chip goto reset mode */
+       udelay(EC_REG_DELAY);
+       outb(cmd, EC_CMD_PORT);
+       udelay(EC_REG_DELAY);
+
+       /* check if the command is received by ec */
+       timeout = EC_CMD_TIMEOUT;
+       status = inb(EC_STS_PORT);
+       while (timeout-- && (status & (1 << 1))) {
+               status = inb(EC_STS_PORT);
+               udelay(EC_REG_DELAY);
+       }
+
+       if (timeout <= 0) {
+               printk(KERN_ERR "%s: deadable error : timeout...\n", __func__);
+               ret = -EINVAL;
+       } else
+               printk(KERN_INFO
+                          "(%x/%d)ec issued command %d status : 0x%x\n",
+                          timeout, EC_CMD_TIMEOUT - timeout, cmd, status);
+
+       spin_unlock_irqrestore(&port_access_lock, flags);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(ec_query_seq);
+
+/*
+ * Send query command to EC to get the proper event number
+ */
+int ec_query_event_num(void)
+{
+       return ec_query_seq(CMD_GET_EVENT_NUM);
+}
+EXPORT_SYMBOL(ec_query_event_num);
+
+/*
+ * Get event number from EC
+ *
+ * NOTE: This routine must follow the query_event_num function in the
+ * interrupt.
+ */
+int ec_get_event_num(void)
+{
+       int timeout = 100;
+       unsigned char value;
+       unsigned char status;
+
+       udelay(EC_REG_DELAY);
+       status = inb(EC_STS_PORT);
+       udelay(EC_REG_DELAY);
+       while (timeout-- && !(status & (1 << 0))) {
+               status = inb(EC_STS_PORT);
+               udelay(EC_REG_DELAY);
+       }
+       if (timeout <= 0) {
+               pr_info("%s: get event number timeout.\n", __func__);
+
+               return -EINVAL;
+       }
+       value = inb(EC_DAT_PORT);
+       udelay(EC_REG_DELAY);
+
+       return value;
+}
+EXPORT_SYMBOL(ec_get_event_num);
diff --git a/arch/mips/loongson/lemote-2f/ec_kb3310b.h b/arch/mips/loongson/lemote-2f/ec_kb3310b.h
new file mode 100644 (file)
index 0000000..1595a21
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * KB3310B Embedded Controller
+ *
+ *  Copyright (C) 2008 Lemote Inc.
+ *  Author: liujl <liujl@lemote.com>, 2008-03-14
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _EC_KB3310B_H
+#define _EC_KB3310B_H
+
+extern unsigned char ec_read(unsigned short addr);
+extern void ec_write(unsigned short addr, unsigned char val);
+extern int ec_query_seq(unsigned char cmd);
+extern int ec_query_event_num(void);
+extern int ec_get_event_num(void);
+
+typedef int (*sci_handler) (int status);
+extern sci_handler yeeloong_report_lid_status;
+
+#define SCI_IRQ_NUM 0x0A
+
+/*
+ * The following registers are determined by the EC index configuration.
+ * 1, fill the PORT_HIGH as EC register high part.
+ * 2, fill the PORT_LOW as EC register low part.
+ * 3, fill the PORT_DATA as EC register write data or get the data from it.
+ */
+#define        EC_IO_PORT_HIGH 0x0381
+#define        EC_IO_PORT_LOW  0x0382
+#define        EC_IO_PORT_DATA 0x0383
+
+/*
+ * EC delay time is 500us for register and status access
+ */
+#define        EC_REG_DELAY    500     /* unit : us */
+#define        EC_CMD_TIMEOUT  0x1000
+
+/*
+ * EC access port for SCI communication
+ */
+#define        EC_CMD_PORT             0x66
+#define        EC_STS_PORT             0x66
+#define        EC_DAT_PORT             0x62
+#define        CMD_INIT_IDLE_MODE      0xdd
+#define        CMD_EXIT_IDLE_MODE      0xdf
+#define        CMD_INIT_RESET_MODE     0xd8
+#define        CMD_REBOOT_SYSTEM       0x8c
+#define        CMD_GET_EVENT_NUM       0x84
+#define        CMD_PROGRAM_PIECE       0xda
+
+/* temperature & fan registers */
+#define        REG_TEMPERATURE_VALUE   0xF458
+#define        REG_FAN_AUTO_MAN_SWITCH 0xF459
+#define        BIT_FAN_AUTO            0
+#define        BIT_FAN_MANUAL          1
+#define        REG_FAN_CONTROL         0xF4D2
+#define        BIT_FAN_CONTROL_ON      (1 << 0)
+#define        BIT_FAN_CONTROL_OFF     (0 << 0)
+#define        REG_FAN_STATUS          0xF4DA
+#define        BIT_FAN_STATUS_ON       (1 << 0)
+#define        BIT_FAN_STATUS_OFF      (0 << 0)
+#define        REG_FAN_SPEED_HIGH      0xFE22
+#define        REG_FAN_SPEED_LOW       0xFE23
+#define        REG_FAN_SPEED_LEVEL     0xF4CC
+/* fan speed divider */
+#define        FAN_SPEED_DIVIDER       480000  /* (60*1000*1000/62.5/2)*/
+
+/* battery registers */
+#define        REG_BAT_DESIGN_CAP_HIGH         0xF77D
+#define        REG_BAT_DESIGN_CAP_LOW          0xF77E
+#define        REG_BAT_FULLCHG_CAP_HIGH        0xF780
+#define        REG_BAT_FULLCHG_CAP_LOW         0xF781
+#define        REG_BAT_DESIGN_VOL_HIGH         0xF782
+#define        REG_BAT_DESIGN_VOL_LOW          0xF783
+#define        REG_BAT_CURRENT_HIGH            0xF784
+#define        REG_BAT_CURRENT_LOW             0xF785
+#define        REG_BAT_VOLTAGE_HIGH            0xF786
+#define        REG_BAT_VOLTAGE_LOW             0xF787
+#define        REG_BAT_TEMPERATURE_HIGH        0xF788
+#define        REG_BAT_TEMPERATURE_LOW         0xF789
+#define        REG_BAT_RELATIVE_CAP_HIGH       0xF492
+#define        REG_BAT_RELATIVE_CAP_LOW        0xF493
+#define        REG_BAT_VENDOR                  0xF4C4
+#define        FLAG_BAT_VENDOR_SANYO           0x01
+#define        FLAG_BAT_VENDOR_SIMPLO          0x02
+#define        REG_BAT_CELL_COUNT              0xF4C6
+#define        FLAG_BAT_CELL_3S1P              0x03
+#define        FLAG_BAT_CELL_3S2P              0x06
+#define        REG_BAT_CHARGE                  0xF4A2
+#define        FLAG_BAT_CHARGE_DISCHARGE       0x01
+#define        FLAG_BAT_CHARGE_CHARGE          0x02
+#define        FLAG_BAT_CHARGE_ACPOWER         0x00
+#define        REG_BAT_STATUS                  0xF4B0
+#define        BIT_BAT_STATUS_LOW              (1 << 5)
+#define        BIT_BAT_STATUS_DESTROY          (1 << 2)
+#define        BIT_BAT_STATUS_FULL             (1 << 1)
+#define        BIT_BAT_STATUS_IN               (1 << 0)
+#define        REG_BAT_CHARGE_STATUS           0xF4B1
+#define        BIT_BAT_CHARGE_STATUS_OVERTEMP  (1 << 2)
+#define        BIT_BAT_CHARGE_STATUS_PRECHG    (1 << 1)
+#define        REG_BAT_STATE                   0xF482
+#define        BIT_BAT_STATE_CHARGING          (1 << 1)
+#define        BIT_BAT_STATE_DISCHARGING       (1 << 0)
+#define        REG_BAT_POWER                   0xF440
+#define        BIT_BAT_POWER_S3                (1 << 2)
+#define        BIT_BAT_POWER_ON                (1 << 1)
+#define        BIT_BAT_POWER_ACIN              (1 << 0)
+
+/* other registers */
+/* Audio: rd/wr */
+#define        REG_AUDIO_VOLUME        0xF46C
+#define        REG_AUDIO_MUTE          0xF4E7
+#define        REG_AUDIO_BEEP          0xF4D0
+/* USB port power or not: rd/wr */
+#define        REG_USB0_FLAG           0xF461
+#define        REG_USB1_FLAG           0xF462
+#define        REG_USB2_FLAG           0xF463
+#define        BIT_USB_FLAG_ON         1
+#define        BIT_USB_FLAG_OFF        0
+/* LID */
+#define        REG_LID_DETECT          0xF4BD
+#define        BIT_LID_DETECT_ON       1
+#define        BIT_LID_DETECT_OFF      0
+/* CRT */
+#define        REG_CRT_DETECT          0xF4AD
+#define        BIT_CRT_DETECT_PLUG     1
+#define        BIT_CRT_DETECT_UNPLUG   0
+/* LCD backlight brightness adjust: 9 levels */
+#define        REG_DISPLAY_BRIGHTNESS  0xF4F5
+/* Black screen Status */
+#define        BIT_DISPLAY_LCD_ON      1
+#define        BIT_DISPLAY_LCD_OFF     0
+/* LCD backlight control: off/restore */
+#define        REG_BACKLIGHT_CTRL      0xF7BD
+#define        BIT_BACKLIGHT_ON        1
+#define        BIT_BACKLIGHT_OFF       0
+/* Reset the machine auto-clear: rd/wr */
+#define        REG_RESET               0xF4EC
+#define        BIT_RESET_ON            1
+/* Light the led: rd/wr */
+#define        REG_LED                 0xF4C8
+#define        BIT_LED_RED_POWER       (1 << 0)
+#define        BIT_LED_ORANGE_POWER    (1 << 1)
+#define        BIT_LED_GREEN_CHARGE    (1 << 2)
+#define        BIT_LED_RED_CHARGE      (1 << 3)
+#define        BIT_LED_NUMLOCK         (1 << 4)
+/* Test led mode, all led on/off */
+#define        REG_LED_TEST            0xF4C2
+#define        BIT_LED_TEST_IN         1
+#define        BIT_LED_TEST_OUT        0
+/* Camera on/off */
+#define        REG_CAMERA_STATUS       0xF46A
+#define        BIT_CAMERA_STATUS_ON    1
+#define        BIT_CAMERA_STATUS_OFF   0
+#define        REG_CAMERA_CONTROL      0xF7B7
+#define        BIT_CAMERA_CONTROL_OFF  0
+#define        BIT_CAMERA_CONTROL_ON   1
+/* Wlan Status */
+#define        REG_WLAN                0xF4FA
+#define        BIT_WLAN_ON             1
+#define        BIT_WLAN_OFF            0
+#define        REG_DISPLAY_LCD         0xF79F
+
+/* SCI Event Number from EC */
+enum {
+       EVENT_LID = 0x23,       /*  LID open/close */
+       EVENT_DISPLAY_TOGGLE,   /*  Fn+F3 for display switch */
+       EVENT_SLEEP,            /*  Fn+F1 for entering sleep mode */
+       EVENT_OVERTEMP,         /*  Over-temperature happened */
+       EVENT_CRT_DETECT,       /*  CRT is connected */
+       EVENT_CAMERA,           /*  Camera on/off */
+       EVENT_USB_OC2,          /*  USB2 Over Current occurred */
+       EVENT_USB_OC0,          /*  USB0 Over Current occurred */
+       EVENT_BLACK_SCREEN,     /*  Turn on/off backlight */
+       EVENT_AUDIO_MUTE,       /*  Mute on/off */
+       EVENT_DISPLAY_BRIGHTNESS,/* LCD backlight brightness adjust */
+       EVENT_AC_BAT,           /*  AC & Battery relative issue */
+       EVENT_AUDIO_VOLUME,     /*  Volume adjust */
+       EVENT_WLAN,             /*  Wlan on/off */
+       EVENT_END
+};
+
+#endif /* !_EC_KB3310B_H */
diff --git a/arch/mips/loongson/lemote-2f/irq.c b/arch/mips/loongson/lemote-2f/irq.c
new file mode 100644 (file)
index 0000000..77d32f9
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2007 Lemote Inc.
+ * Author: Fuxin Zhang, zhangfx@lemote.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/module.h>
+
+#include <asm/irq_cpu.h>
+#include <asm/i8259.h>
+#include <asm/mipsregs.h>
+
+#include <loongson.h>
+#include <machine.h>
+
+#define LOONGSON_TIMER_IRQ     (MIPS_CPU_IRQ_BASE + 7) /* cpu timer */
+#define LOONGSON_PERFCNT_IRQ   (MIPS_CPU_IRQ_BASE + 6) /* cpu perf counter */
+#define LOONGSON_NORTH_BRIDGE_IRQ      (MIPS_CPU_IRQ_BASE + 6) /* bonito */
+#define LOONGSON_UART_IRQ      (MIPS_CPU_IRQ_BASE + 3) /* cpu serial port */
+#define LOONGSON_SOUTH_BRIDGE_IRQ      (MIPS_CPU_IRQ_BASE + 2) /* i8259 */
+
+#define LOONGSON_INT_BIT_INT0          (1 << 11)
+#define LOONGSON_INT_BIT_INT1          (1 << 12)
+
+/*
+ * The generic i8259_irq() make the kernel hang on booting.  Since we cannot
+ * get the irq via the IRR directly, we access the ISR instead.
+ */
+int mach_i8259_irq(void)
+{
+       int irq, isr;
+
+       irq = -1;
+
+       if ((LOONGSON_INTISR & LOONGSON_INTEN) & LOONGSON_INT_BIT_INT0) {
+               spin_lock(&i8259A_lock);
+               isr = inb(PIC_MASTER_CMD) &
+                       ~inb(PIC_MASTER_IMR) & ~(1 << PIC_CASCADE_IR);
+               if (!isr)
+                       isr = (inb(PIC_SLAVE_CMD) & ~inb(PIC_SLAVE_IMR)) << 8;
+               irq = ffs(isr) - 1;
+               if (unlikely(irq == 7)) {
+                       /*
+                        * This may be a spurious interrupt.
+                        *
+                        * Read the interrupt status register (ISR). If the most
+                        * significant bit is not set then there is no valid
+                        * interrupt.
+                        */
+                       outb(0x0B, PIC_MASTER_ISR);     /* ISR register */
+                       if (~inb(PIC_MASTER_ISR) & 0x80)
+                               irq = -1;
+               }
+               spin_unlock(&i8259A_lock);
+       }
+
+       return irq;
+}
+EXPORT_SYMBOL(mach_i8259_irq);
+
+static void i8259_irqdispatch(void)
+{
+       int irq;
+
+       irq = mach_i8259_irq();
+       if (irq >= 0)
+               do_IRQ(irq);
+       else
+               spurious_interrupt();
+}
+
+void mach_irq_dispatch(unsigned int pending)
+{
+       if (pending & CAUSEF_IP7)
+               do_IRQ(LOONGSON_TIMER_IRQ);
+       else if (pending & CAUSEF_IP6) {        /* North Bridge, Perf counter */
+#ifdef CONFIG_OPROFILE
+               do_IRQ(LOONGSON2_PERFCNT_IRQ);
+#endif
+               bonito_irqdispatch();
+       } else if (pending & CAUSEF_IP3)        /* CPU UART */
+               do_IRQ(LOONGSON_UART_IRQ);
+       else if (pending & CAUSEF_IP2)  /* South Bridge */
+               i8259_irqdispatch();
+       else
+               spurious_interrupt();
+}
+
+void __init set_irq_trigger_mode(void)
+{
+       /* setup cs5536 as high level trigger */
+       LOONGSON_INTPOL = LOONGSON_INT_BIT_INT0 | LOONGSON_INT_BIT_INT1;
+       LOONGSON_INTEDGE &= ~(LOONGSON_INT_BIT_INT0 | LOONGSON_INT_BIT_INT1);
+}
+
+static irqreturn_t ip6_action(int cpl, void *dev_id)
+{
+       return IRQ_HANDLED;
+}
+
+struct irqaction ip6_irqaction = {
+       .handler = ip6_action,
+       .name = "cascade",
+       .flags = IRQF_SHARED,
+};
+
+struct irqaction cascade_irqaction = {
+       .handler = no_action,
+       .name = "cascade",
+};
+
+void __init mach_init_irq(void)
+{
+       /* init all controller
+        *   0-15         ------> i8259 interrupt
+        *   16-23        ------> mips cpu interrupt
+        *   32-63        ------> bonito irq
+        */
+
+       /* Sets the first-level interrupt dispatcher. */
+       mips_cpu_irq_init();
+       init_i8259_irqs();
+       bonito_irq_init();
+
+       /* setup north bridge irq (bonito) */
+       setup_irq(LOONGSON_NORTH_BRIDGE_IRQ, &ip6_irqaction);
+       /* setup source bridge irq (i8259) */
+       setup_irq(LOONGSON_SOUTH_BRIDGE_IRQ, &cascade_irqaction);
+}
diff --git a/arch/mips/loongson/lemote-2f/pm.c b/arch/mips/loongson/lemote-2f/pm.c
new file mode 100644 (file)
index 0000000..d7af2e6
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ *  Lemote loongson2f family machines' specific suspend support
+ *
+ *  Copyright (C) 2009 Lemote Inc.
+ *  Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/suspend.h>
+#include <linux/interrupt.h>
+#include <linux/pm.h>
+#include <linux/i8042.h>
+#include <linux/module.h>
+
+#include <asm/i8259.h>
+#include <asm/mipsregs.h>
+#include <asm/bootinfo.h>
+
+#include <loongson.h>
+
+#include <cs5536/cs5536_mfgpt.h>
+#include "ec_kb3310b.h"
+
+#define I8042_KBD_IRQ          1
+#define I8042_CTR_KBDINT       0x01
+#define I8042_CTR_KBDDIS       0x10
+
+static unsigned char i8042_ctr;
+
+static int i8042_enable_kbd_port(void)
+{
+       if (i8042_command(&i8042_ctr, I8042_CMD_CTL_RCTR)) {
+               pr_err("i8042.c: Can't read CTR while enabling i8042 kbd port."
+                      "\n");
+               return -EIO;
+       }
+
+       i8042_ctr &= ~I8042_CTR_KBDDIS;
+       i8042_ctr |= I8042_CTR_KBDINT;
+
+       if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR)) {
+               i8042_ctr &= ~I8042_CTR_KBDINT;
+               i8042_ctr |= I8042_CTR_KBDDIS;
+               pr_err("i8042.c: Failed to enable KBD port.\n");
+
+               return -EIO;
+       }
+
+       return 0;
+}
+
+void setup_wakeup_events(void)
+{
+       int irq_mask;
+
+       switch (mips_machtype) {
+       case MACH_LEMOTE_ML2F7:
+       case MACH_LEMOTE_YL2F89:
+               /* open the keyboard irq in i8259A */
+               outb((0xff & ~(1 << I8042_KBD_IRQ)), PIC_MASTER_IMR);
+               irq_mask = inb(PIC_MASTER_IMR);
+
+               /* enable keyboard port */
+               i8042_enable_kbd_port();
+
+               /* Wakeup CPU via SCI lid open event */
+               outb(irq_mask & ~(1 << PIC_CASCADE_IR), PIC_MASTER_IMR);
+               inb(PIC_MASTER_IMR);
+               outb(0xff & ~(1 << (SCI_IRQ_NUM - 8)), PIC_SLAVE_IMR);
+               inb(PIC_SLAVE_IMR);
+
+               break;
+
+       default:
+               break;
+       }
+}
+
+static struct delayed_work lid_task;
+static int initialized;
+/* yeeloong_report_lid_status will be implemented in yeeloong_laptop.c */
+sci_handler yeeloong_report_lid_status;
+EXPORT_SYMBOL(yeeloong_report_lid_status);
+static void yeeloong_lid_update_task(struct work_struct *work)
+{
+       if (yeeloong_report_lid_status)
+               yeeloong_report_lid_status(BIT_LID_DETECT_ON);
+}
+
+int wakeup_loongson(void)
+{
+       int irq;
+
+       /* query the interrupt number */
+       irq = mach_i8259_irq();
+       if (irq < 0)
+               return 0;
+
+       printk(KERN_INFO "%s: irq = %d\n", __func__, irq);
+
+       if (irq == I8042_KBD_IRQ)
+               return 1;
+       else if (irq == SCI_IRQ_NUM) {
+               int ret, sci_event;
+               /* query the event number */
+               ret = ec_query_seq(CMD_GET_EVENT_NUM);
+               if (ret < 0)
+                       return 0;
+               sci_event = ec_get_event_num();
+               if (sci_event < 0)
+                       return 0;
+               if (sci_event == EVENT_LID) {
+                       int lid_status;
+                       /* check the LID status */
+                       lid_status = ec_read(REG_LID_DETECT);
+                       /* wakeup cpu when people open the LID */
+                       if (lid_status == BIT_LID_DETECT_ON) {
+                               /* If we call it directly here, the WARNING
+                                * will be sent out by getnstimeofday
+                                * via "WARN_ON(timekeeping_suspended);"
+                                * because we can not schedule in suspend mode.
+                                */
+                               if (initialized == 0) {
+                                       INIT_DELAYED_WORK(&lid_task,
+                                               yeeloong_lid_update_task);
+                                       initialized = 1;
+                               }
+                               schedule_delayed_work(&lid_task, 1);
+                               return 1;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+void __weak mach_suspend(void)
+{
+       disable_mfgpt0_counter();
+}
+
+void __weak mach_resume(void)
+{
+       enable_mfgpt0_counter();
+}
diff --git a/arch/mips/loongson/lemote-2f/reset.c b/arch/mips/loongson/lemote-2f/reset.c
new file mode 100644 (file)
index 0000000..51d1a60
--- /dev/null
@@ -0,0 +1,159 @@
+/* Board-specific reboot/shutdown routines
+ *
+ * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca>
+ *
+ * Copyright (C) 2009 Lemote Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/io.h>
+#include <linux/delay.h>
+#include <linux/types.h>
+
+#include <asm/bootinfo.h>
+
+#include <loongson.h>
+
+#include <cs5536/cs5536.h>
+#include "ec_kb3310b.h"
+
+static void reset_cpu(void)
+{
+       /*
+        * reset cpu to full speed, this is needed when enabling cpu frequency
+        * scalling
+        */
+       LOONGSON_CHIPCFG0 |= 0x7;
+}
+
+/* reset support for fuloong2f */
+
+static void fl2f_reboot(void)
+{
+       reset_cpu();
+
+       /* send a reset signal to south bridge.
+        *
+        * NOTE: if enable "Power Management" in kernel, rtl8169 will not reset
+        * normally with this reset operation and it will not work in PMON, but
+        * you can type halt command and then reboot, seems the hardware reset
+        * logic not work normally.
+        */
+       {
+               u32 hi, lo;
+               _rdmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET), &hi, &lo);
+               lo |= 0x00000001;
+               _wrmsr(DIVIL_MSR_REG(DIVIL_SOFT_RESET), hi, lo);
+       }
+}
+
+static void fl2f_shutdown(void)
+{
+       u32 hi, lo, val;
+       int gpio_base;
+
+       /* get gpio base */
+       _rdmsr(DIVIL_MSR_REG(DIVIL_LBAR_GPIO), &hi, &lo);
+       gpio_base = lo & 0xff00;
+
+       /* make cs5536 gpio13 output enable */
+       val = inl(gpio_base + GPIOL_OUT_EN);
+       val &= ~(1 << (16 + 13));
+       val |= (1 << 13);
+       outl(val, gpio_base + GPIOL_OUT_EN);
+       mmiowb();
+       /* make cs5536 gpio13 output low level voltage. */
+       val = inl(gpio_base + GPIOL_OUT_VAL) & ~(1 << (13));
+       val |= (1 << (16 + 13));
+       outl(val, gpio_base + GPIOL_OUT_VAL);
+       mmiowb();
+}
+
+/* reset support for yeeloong2f and mengloong2f notebook */
+
+void ml2f_reboot(void)
+{
+       reset_cpu();
+
+       /* sending an reset signal to EC(embedded controller) */
+       ec_write(REG_RESET, BIT_RESET_ON);
+}
+
+#define yl2f89_reboot ml2f_reboot
+
+/* menglong(7inches) laptop has different shutdown logic from 8.9inches */
+#define EC_SHUTDOWN_IO_PORT_HIGH 0xff2d
+#define EC_SHUTDOWN_IO_PORT_LOW         0xff2e
+#define EC_SHUTDOWN_IO_PORT_DATA 0xff2f
+#define REG_SHUTDOWN_HIGH        0xFC
+#define REG_SHUTDOWN_LOW         0x29
+#define BIT_SHUTDOWN_ON          (1 << 1)
+
+static void ml2f_shutdown(void)
+{
+       u8 val;
+       u64 i;
+
+       outb(REG_SHUTDOWN_HIGH, EC_SHUTDOWN_IO_PORT_HIGH);
+       outb(REG_SHUTDOWN_LOW, EC_SHUTDOWN_IO_PORT_LOW);
+       mmiowb();
+       val = inb(EC_SHUTDOWN_IO_PORT_DATA);
+       outb(val & (~BIT_SHUTDOWN_ON), EC_SHUTDOWN_IO_PORT_DATA);
+       mmiowb();
+       /* need enough wait here... how many microseconds needs? */
+       for (i = 0; i < 0x10000; i++)
+               delay();
+       outb(val | BIT_SHUTDOWN_ON, EC_SHUTDOWN_IO_PORT_DATA);
+       mmiowb();
+}
+
+static void yl2f89_shutdown(void)
+{
+       /* cpu-gpio0 output low */
+       LOONGSON_GPIODATA &= ~0x00000001;
+       /* cpu-gpio0 as output */
+       LOONGSON_GPIOIE &= ~0x00000001;
+}
+
+void mach_prepare_reboot(void)
+{
+       switch (mips_machtype) {
+       case MACH_LEMOTE_FL2F:
+       case MACH_LEMOTE_NAS:
+       case MACH_LEMOTE_LL2F:
+               fl2f_reboot();
+               break;
+       case MACH_LEMOTE_ML2F7:
+               ml2f_reboot();
+               break;
+       case MACH_LEMOTE_YL2F89:
+               yl2f89_reboot();
+               break;
+       default:
+               break;
+       }
+}
+
+void mach_prepare_shutdown(void)
+{
+       switch (mips_machtype) {
+       case MACH_LEMOTE_FL2F:
+       case MACH_LEMOTE_NAS:
+       case MACH_LEMOTE_LL2F:
+               fl2f_shutdown();
+               break;
+       case MACH_LEMOTE_ML2F7:
+               ml2f_shutdown();
+               break;
+       case MACH_LEMOTE_YL2F89:
+               yl2f89_shutdown();
+               break;
+       default:
+               break;
+       }
+}
index 454b53924490c58ed383f047f84f68e8be117afe..8f2f8e9d8b212ae5897c0aabee5dd35c46837680 100644 (file)
@@ -35,6 +35,7 @@
  * better performance by compiling with -msoft-float!
  */
 #include <linux/sched.h>
+#include <linux/module.h>
 #include <linux/debugfs.h>
 
 #include <asm/inst.h>
@@ -68,7 +69,9 @@ static int fpux_emu(struct pt_regs *,
 
 /* Further private data for which no space exists in mips_fpu_struct */
 
-struct mips_fpu_emulator_stats fpuemustats;
+#ifdef CONFIG_DEBUG_FS
+DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
+#endif
 
 /* Control registers */
 
@@ -209,7 +212,7 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
        unsigned int cond;
 
        if (get_user(ir, (mips_instruction __user *) xcp->cp0_epc)) {
-               fpuemustats.errors++;
+               MIPS_FPU_EMU_INC_STATS(errors);
                return SIGBUS;
        }
 
@@ -240,7 +243,7 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
                        return SIGILL;
                }
                if (get_user(ir, (mips_instruction __user *) emulpc)) {
-                       fpuemustats.errors++;
+                       MIPS_FPU_EMU_INC_STATS(errors);
                        return SIGBUS;
                }
                /* __compute_return_epc() will have updated cp0_epc */
@@ -253,16 +256,16 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
        }
 
       emul:
-       fpuemustats.emulated++;
+       MIPS_FPU_EMU_INC_STATS(emulated);
        switch (MIPSInst_OPCODE(ir)) {
        case ldc1_op:{
                u64 __user *va = (u64 __user *) (xcp->regs[MIPSInst_RS(ir)] +
                        MIPSInst_SIMM(ir));
                u64 val;
 
-               fpuemustats.loads++;
+               MIPS_FPU_EMU_INC_STATS(loads);
                if (get_user(val, va)) {
-                       fpuemustats.errors++;
+                       MIPS_FPU_EMU_INC_STATS(errors);
                        return SIGBUS;
                }
                DITOREG(val, MIPSInst_RT(ir));
@@ -274,10 +277,10 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
                        MIPSInst_SIMM(ir));
                u64 val;
 
-               fpuemustats.stores++;
+               MIPS_FPU_EMU_INC_STATS(stores);
                DIFROMREG(val, MIPSInst_RT(ir));
                if (put_user(val, va)) {
-                       fpuemustats.errors++;
+                       MIPS_FPU_EMU_INC_STATS(errors);
                        return SIGBUS;
                }
                break;
@@ -288,9 +291,9 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
                        MIPSInst_SIMM(ir));
                u32 val;
 
-               fpuemustats.loads++;
+               MIPS_FPU_EMU_INC_STATS(loads);
                if (get_user(val, va)) {
-                       fpuemustats.errors++;
+                       MIPS_FPU_EMU_INC_STATS(errors);
                        return SIGBUS;
                }
                SITOREG(val, MIPSInst_RT(ir));
@@ -302,10 +305,10 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
                        MIPSInst_SIMM(ir));
                u32 val;
 
-               fpuemustats.stores++;
+               MIPS_FPU_EMU_INC_STATS(stores);
                SIFROMREG(val, MIPSInst_RT(ir));
                if (put_user(val, va)) {
-                       fpuemustats.errors++;
+                       MIPS_FPU_EMU_INC_STATS(errors);
                        return SIGBUS;
                }
                break;
@@ -429,7 +432,7 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx)
 
                                if (get_user(ir,
                                    (mips_instruction __user *) xcp->cp0_epc)) {
-                                       fpuemustats.errors++;
+                                       MIPS_FPU_EMU_INC_STATS(errors);
                                        return SIGBUS;
                                }
 
@@ -595,7 +598,7 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
 {
        unsigned rcsr = 0;      /* resulting csr */
 
-       fpuemustats.cp1xops++;
+       MIPS_FPU_EMU_INC_STATS(cp1xops);
 
        switch (MIPSInst_FMA_FFMT(ir)) {
        case s_fmt:{            /* 0 */
@@ -610,9 +613,9 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
                        va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] +
                                xcp->regs[MIPSInst_FT(ir)]);
 
-                       fpuemustats.loads++;
+                       MIPS_FPU_EMU_INC_STATS(loads);
                        if (get_user(val, va)) {
-                               fpuemustats.errors++;
+                               MIPS_FPU_EMU_INC_STATS(errors);
                                return SIGBUS;
                        }
                        SITOREG(val, MIPSInst_FD(ir));
@@ -622,11 +625,11 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
                        va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] +
                                xcp->regs[MIPSInst_FT(ir)]);
 
-                       fpuemustats.stores++;
+                       MIPS_FPU_EMU_INC_STATS(stores);
 
                        SIFROMREG(val, MIPSInst_FS(ir));
                        if (put_user(val, va)) {
-                               fpuemustats.errors++;
+                               MIPS_FPU_EMU_INC_STATS(errors);
                                return SIGBUS;
                        }
                        break;
@@ -687,9 +690,9 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
                        va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] +
                                xcp->regs[MIPSInst_FT(ir)]);
 
-                       fpuemustats.loads++;
+                       MIPS_FPU_EMU_INC_STATS(loads);
                        if (get_user(val, va)) {
-                               fpuemustats.errors++;
+                               MIPS_FPU_EMU_INC_STATS(errors);
                                return SIGBUS;
                        }
                        DITOREG(val, MIPSInst_FD(ir));
@@ -699,10 +702,10 @@ static int fpux_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
                        va = (void __user *) (xcp->regs[MIPSInst_FR(ir)] +
                                xcp->regs[MIPSInst_FT(ir)]);
 
-                       fpuemustats.stores++;
+                       MIPS_FPU_EMU_INC_STATS(stores);
                        DIFROMREG(val, MIPSInst_FS(ir));
                        if (put_user(val, va)) {
-                               fpuemustats.errors++;
+                               MIPS_FPU_EMU_INC_STATS(errors);
                                return SIGBUS;
                        }
                        break;
@@ -769,7 +772,7 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
 #endif
        } rv;                   /* resulting value */
 
-       fpuemustats.cp1ops++;
+       MIPS_FPU_EMU_INC_STATS(cp1ops);
        switch (rfmt = (MIPSInst_FFMT(ir) & 0xf)) {
        case s_fmt:{            /* 0 */
                union {
@@ -1240,7 +1243,7 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
                prevepc = xcp->cp0_epc;
 
                if (get_user(insn, (mips_instruction __user *) xcp->cp0_epc)) {
-                       fpuemustats.errors++;
+                       MIPS_FPU_EMU_INC_STATS(errors);
                        return SIGBUS;
                }
                if (insn == 0)
@@ -1276,33 +1279,50 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
 }
 
 #ifdef CONFIG_DEBUG_FS
+
+static int fpuemu_stat_get(void *data, u64 *val)
+{
+       int cpu;
+       unsigned long sum = 0;
+       for_each_online_cpu(cpu) {
+               struct mips_fpu_emulator_stats *ps;
+               local_t *pv;
+               ps = &per_cpu(fpuemustats, cpu);
+               pv = (void *)ps + (unsigned long)data;
+               sum += local_read(pv);
+       }
+       *val = sum;
+       return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
+
 extern struct dentry *mips_debugfs_dir;
 static int __init debugfs_fpuemu(void)
 {
        struct dentry *d, *dir;
-       int i;
-       static struct {
-               const char *name;
-               unsigned int *v;
-       } vars[] __initdata = {
-               { "emulated", &fpuemustats.emulated },
-               { "loads",    &fpuemustats.loads },
-               { "stores",   &fpuemustats.stores },
-               { "cp1ops",   &fpuemustats.cp1ops },
-               { "cp1xops",  &fpuemustats.cp1xops },
-               { "errors",   &fpuemustats.errors },
-       };
 
        if (!mips_debugfs_dir)
                return -ENODEV;
        dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir);
        if (!dir)
                return -ENOMEM;
-       for (i = 0; i < ARRAY_SIZE(vars); i++) {
-               d = debugfs_create_u32(vars[i].name, S_IRUGO, dir, vars[i].v);
-               if (!d)
-                       return -ENOMEM;
-       }
+
+#define FPU_STAT_CREATE(M)                                             \
+       do {                                                            \
+               d = debugfs_create_file(#M , S_IRUGO, dir,              \
+                       (void *)offsetof(struct mips_fpu_emulator_stats, M), \
+                       &fops_fpuemu_stat);                             \
+               if (!d)                                                 \
+                       return -ENOMEM;                                 \
+       } while (0)
+
+       FPU_STAT_CREATE(emulated);
+       FPU_STAT_CREATE(loads);
+       FPU_STAT_CREATE(stores);
+       FPU_STAT_CREATE(cp1ops);
+       FPU_STAT_CREATE(cp1xops);
+       FPU_STAT_CREATE(errors);
+
        return 0;
 }
 __initcall(debugfs_fpuemu);
index df7b9d928efc83730b6d69361e3d2aef36eed3bc..36d975ae08f8d6677324c7fa7dfc4ea990cce019 100644 (file)
@@ -98,7 +98,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc)
        err |= __put_user(cpc, &fr->epc);
 
        if (unlikely(err)) {
-               fpuemustats.errors++;
+               MIPS_FPU_EMU_INC_STATS(errors);
                return SIGBUS;
        }
 
@@ -136,7 +136,7 @@ int do_dsemulret(struct pt_regs *xcp)
        err |= __get_user(cookie, &fr->cookie);
 
        if (unlikely(err || (insn != BREAK_MATH) || (cookie != BD_COOKIE))) {
-               fpuemustats.errors++;
+               MIPS_FPU_EMU_INC_STATS(errors);
                return 0;
        }
 
index 57f43c1c7882782bcabeb5143a2021d496a16205..41b96571315e76009322209e8bf28bdb9eac3a67 100644 (file)
@@ -17,8 +17,7 @@
 # 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
 #
 
-obj-y := sim_platform.o sim_setup.o sim_mem.o sim_time.o sim_int.o \
-        sim_cmdline.o
+obj-y := sim_platform.o sim_setup.o sim_mem.o sim_time.o sim_int.o
 
 obj-$(CONFIG_EARLY_PRINTK) += sim_console.o
 obj-$(CONFIG_MIPS_MT_SMTC) += sim_smtc.o
index 2877675c5f0ddc11f23e98a73bcbea8a855d8348..0824f6af47770b9a56bbec4a07358be12f4953c9 100644 (file)
@@ -61,7 +61,6 @@ void __init prom_init(void)
        set_io_port_base(0xbfd00000);
 
        pr_info("\nLINUX started...\n");
-       prom_init_cmdline();
        prom_meminit();
 
 #ifdef CONFIG_MIPS_MT_SMP
index 1bd1f18ac23c5d0fe0120555051b98bb5cb7169c..3571090ba17816e332a2843d6aee478131154932 100644 (file)
@@ -567,13 +567,10 @@ static uint32_t extract_dc(unsigned short addr, int data)
                                datalo = ((unsigned long long)datalohi << 32) | datalolo;
                                ecc = dc_ecc(datalo);
                                if (ecc != datahi) {
-                                       int bits = 0;
+                                       int bits;
                                        bad_ecc |= 1 << (3-offset);
                                        ecc ^= datahi;
-                                       while (ecc) {
-                                               if (ecc & 1) bits++;
-                                               ecc >>= 1;
-                                       }
+                                       bits = hweight8(ecc);
                                        res |= (bits == 1) ? CP0_CERRD_DATA_SBE : CP0_CERRD_DATA_DBE;
                                }
                                printk("  %02X-%016llX", datahi, datalo);
index 8d1f4f36304900fa5bb33d23a31a4cc4deaefe94..9e8d00389eef18e0c99b4e2343632d1533554a42 100644 (file)
@@ -462,7 +462,9 @@ void __init_refok free_initmem(void)
                        __pa_symbol(&__init_end));
 }
 
+#ifndef CONFIG_MIPS_PGD_C0_CONTEXT
 unsigned long pgd_current[NR_CPUS];
+#endif
 /*
  * On 64-bit we've got three-level pagetables with a slightly
  * different layout ...
index bb1719a55d227dc595467aafd88173dc9507b937..3d0baa4a842d0b4f1059e723fec21fddc2637734 100644 (file)
@@ -160,6 +160,12 @@ static u32 tlb_handler[128] __cpuinitdata;
 static struct uasm_label labels[128] __cpuinitdata;
 static struct uasm_reloc relocs[128] __cpuinitdata;
 
+#ifndef CONFIG_MIPS_PGD_C0_CONTEXT
+/*
+ * CONFIG_MIPS_PGD_C0_CONTEXT implies 64 bit and lack of pgd_current,
+ * we cannot do r3000 under these circumstances.
+ */
+
 /*
  * The R3000 TLB handler is simple.
  */
@@ -199,6 +205,7 @@ static void __cpuinit build_r3000_tlb_refill_handler(void)
 
        dump_handler((u32 *)ebase, 32);
 }
+#endif /* CONFIG_MIPS_PGD_C0_CONTEXT */
 
 /*
  * The R4000 TLB handler is much more complicated. We have two
@@ -497,8 +504,9 @@ static void __cpuinit
 build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
                 unsigned int tmp, unsigned int ptr)
 {
+#ifndef CONFIG_MIPS_PGD_C0_CONTEXT
        long pgdc = (long)pgd_current;
-
+#endif
        /*
         * The vmalloc handling is not in the hotpath.
         */
@@ -506,7 +514,15 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
        uasm_il_bltz(p, r, tmp, label_vmalloc);
        /* No uasm_i_nop needed here, since the next insn doesn't touch TMP. */
 
-#ifdef CONFIG_SMP
+#ifdef CONFIG_MIPS_PGD_C0_CONTEXT
+       /*
+        * &pgd << 11 stored in CONTEXT [23..63].
+        */
+       UASM_i_MFC0(p, ptr, C0_CONTEXT);
+       uasm_i_dins(p, ptr, 0, 0, 23); /* Clear lower 23 bits of context. */
+       uasm_i_ori(p, ptr, ptr, 0x540); /* 1 0  1 0 1  << 6  xkphys cached */
+       uasm_i_drotr(p, ptr, ptr, 11);
+#elif defined(CONFIG_SMP)
 # ifdef  CONFIG_MIPS_MT_SMTC
        /*
         * SMTC uses TCBind value as "CPU" index
@@ -520,7 +536,7 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
         */
        uasm_i_dmfc0(p, ptr, C0_CONTEXT);
        uasm_i_dsrl(p, ptr, ptr, 23);
-#endif
+# endif
        UASM_i_LA_mostly(p, tmp, pgdc);
        uasm_i_daddu(p, ptr, ptr, tmp);
        uasm_i_dmfc0(p, tmp, C0_BADVADDR);
@@ -1033,6 +1049,7 @@ build_pte_modifiable(u32 **p, struct uasm_reloc **r,
        iPTE_LW(p, pte, ptr);
 }
 
+#ifndef CONFIG_MIPS_PGD_C0_CONTEXT
 /*
  * R3000 style TLB load/store/modify handlers.
  */
@@ -1184,6 +1201,7 @@ static void __cpuinit build_r3000_tlb_modify_handler(void)
 
        dump_handler(handle_tlbm, ARRAY_SIZE(handle_tlbm));
 }
+#endif /* CONFIG_MIPS_PGD_C0_CONTEXT */
 
 /*
  * R4000 style TLB load/store/modify handlers.
@@ -1400,6 +1418,7 @@ void __cpuinit build_tlb_refill_handler(void)
        case CPU_TX3912:
        case CPU_TX3922:
        case CPU_TX3927:
+#ifndef CONFIG_MIPS_PGD_C0_CONTEXT
                build_r3000_tlb_refill_handler();
                if (!run_once) {
                        build_r3000_tlb_load_handler();
@@ -1407,6 +1426,9 @@ void __cpuinit build_tlb_refill_handler(void)
                        build_r3000_tlb_modify_handler();
                        run_once++;
                }
+#else
+               panic("No R3000 TLB refill handler");
+#endif
                break;
 
        case CPU_R6000:
index f467199676a8526c67aff9464efd98d5a7c9b68c..0a165c5179a125b737bc80e0d4ee48e05f63d0ac 100644 (file)
@@ -60,11 +60,11 @@ enum opcode {
        insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl,
        insn_bne, insn_cache, insn_daddu, insn_daddiu, insn_dmfc0,
        insn_dmtc0, insn_dsll, insn_dsll32, insn_dsra, insn_dsrl,
-       insn_dsrl32, insn_dsubu, insn_eret, insn_j, insn_jal, insn_jr,
-       insn_ld, insn_ll, insn_lld, insn_lui, insn_lw, insn_mfc0,
+       insn_dsrl32, insn_drotr, insn_dsubu, insn_eret, insn_j, insn_jal,
+       insn_jr, insn_ld, insn_ll, insn_lld, insn_lui, insn_lw, insn_mfc0,
        insn_mtc0, insn_ori, insn_pref, insn_rfe, insn_sc, insn_scd,
        insn_sd, insn_sll, insn_sra, insn_srl, insn_subu, insn_sw,
-       insn_tlbp, insn_tlbwi, insn_tlbwr, insn_xor, insn_xori
+       insn_tlbp, insn_tlbwi, insn_tlbwr, insn_xor, insn_xori, insn_dins
 };
 
 struct insn {
@@ -104,6 +104,7 @@ static struct insn insn_table[] __cpuinitdata = {
        { insn_dsra, M(spec_op, 0, 0, 0, 0, dsra_op), RT | RD | RE },
        { insn_dsrl, M(spec_op, 0, 0, 0, 0, dsrl_op), RT | RD | RE },
        { insn_dsrl32, M(spec_op, 0, 0, 0, 0, dsrl32_op), RT | RD | RE },
+       { insn_drotr, M(spec_op, 1, 0, 0, 0, dsrl_op), RT | RD | RE },
        { insn_dsubu, M(spec_op, 0, 0, 0, 0, dsubu_op), RS | RT | RD },
        { insn_eret,  M(cop0_op, cop_op, 0, 0, 0, eret_op),  0 },
        { insn_j,  M(j_op, 0, 0, 0, 0, 0),  JIMM },
@@ -132,6 +133,7 @@ static struct insn insn_table[] __cpuinitdata = {
        { insn_tlbwr,  M(cop0_op, cop_op, 0, 0, 0, tlbwr_op),  0 },
        { insn_xor,  M(spec_op, 0, 0, 0, 0, xor_op),  RS | RT | RD },
        { insn_xori,  M(xori_op, 0, 0, 0, 0, 0),  RS | RT | UIMM },
+       { insn_dins, M(spec3_op, 0, 0, 0, 0, dins_op), RS | RT | RD | RE },
        { insn_invalid, 0, 0 }
 };
 
@@ -304,6 +306,12 @@ Ip_u2u1s3(op)                                              \
        build_insn(buf, insn##op, b, a, c);             \
 }
 
+#define I_u2u1msbu3(op)                                        \
+Ip_u2u1msbu3(op)                                       \
+{                                                      \
+       build_insn(buf, insn##op, b, a, c+d-1, c);      \
+}
+
 #define I_u1u2(op)                                     \
 Ip_u1u2(op)                                            \
 {                                                      \
@@ -349,6 +357,7 @@ I_u2u1u3(_dsll32)
 I_u2u1u3(_dsra)
 I_u2u1u3(_dsrl)
 I_u2u1u3(_dsrl32)
+I_u2u1u3(_drotr)
 I_u3u1u2(_dsubu)
 I_0(_eret)
 I_u1(_j)
@@ -377,6 +386,7 @@ I_0(_tlbwi)
 I_0(_tlbwr)
 I_u3u1u2(_xor)
 I_u2u1u3(_xori)
+I_u2u1msbu3(_dins);
 
 /* Handle labels. */
 void __cpuinit uasm_build_label(struct uasm_label **lab, u32 *addr, int lid)
index c6d1e3dd82d490df1bb174da54756110c4ceb4fb..3d153edaa51ec28c95da7166fa824c7e9f45d184 100644 (file)
@@ -34,6 +34,11 @@ uasm_i##op(u32 **buf, unsigned int a, signed int b, unsigned int c)
 void __cpuinit                                                         \
 uasm_i##op(u32 **buf, unsigned int a, unsigned int b, signed int c)
 
+#define Ip_u2u1msbu3(op)                                               \
+void __cpuinit                                                         \
+uasm_i##op(u32 **buf, unsigned int a, unsigned int b, unsigned int c,  \
+          unsigned int d)
+
 #define Ip_u1u2(op)                                                    \
 void __cpuinit uasm_i##op(u32 **buf, unsigned int a, unsigned int b)
 
@@ -65,6 +70,7 @@ Ip_u2u1u3(_dsll32);
 Ip_u2u1u3(_dsra);
 Ip_u2u1u3(_dsrl);
 Ip_u2u1u3(_dsrl32);
+Ip_u2u1u3(_drotr);
 Ip_u3u1u2(_dsubu);
 Ip_0(_eret);
 Ip_u1(_j);
@@ -93,6 +99,7 @@ Ip_0(_tlbwi);
 Ip_0(_tlbwr);
 Ip_u3u1u2(_xor);
 Ip_u2u1u3(_xori);
+Ip_u2u1msbu3(_dins);
 
 /* Handle labels. */
 struct uasm_label {
index 9035c64bc5ed4e27b0661231507de7346848a07f..b27419c849199f2a815faedeffcc00816a83039d 100644 (file)
@@ -55,7 +55,7 @@ static struct prom_pmemblock * __init prom_getmdesc(void)
        char *memsize_str;
        unsigned int memsize;
        char *ptr;
-       static char cmdline[CL_SIZE] __initdata;
+       static char cmdline[COMMAND_LINE_SIZE] __initdata;
 
        /* otherwise look in the environment */
        memsize_str = prom_getenv("memsize");
index 30533ba200e211618cff8b46d28905cb28a82579..3a467c04f81122698002b979e71692ceb30ef9aa 100644 (file)
@@ -295,7 +295,7 @@ static int pnx833x_set_type_gpio_irq(unsigned int irq, unsigned int flow_type)
 }
 
 static struct irq_chip pnx833x_pic_irq_type = {
-       .typename = "PNX-PIC",
+       .name = "PNX-PIC",
        .startup = pnx833x_startup_pic_irq,
        .shutdown = pnx833x_shutdown_pic_irq,
        .enable = pnx833x_enable_pic_irq,
@@ -305,7 +305,7 @@ static struct irq_chip pnx833x_pic_irq_type = {
 };
 
 static struct irq_chip pnx833x_gpio_irq_type = {
-       .typename = "PNX-GPIO",
+       .name = "PNX-GPIO",
        .startup = pnx833x_startup_gpio_irq,
        .shutdown = pnx833x_disable_gpio_irq,
        .enable = pnx833x_enable_gpio_irq,
index 575cd14734759314f3da89e87705ea14a224fbf8..475ff46712ab7a1871b4d242d713003c39fe0515 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Loongson2 performance counter driver for oprofile
  *
- * Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
+ * Copyright (C) 2009 Lemote Inc.
  * Author: Yanhua <yanh@lemote.com>
  * Author: Wu Zhangjin <wuzj@lemote.com>
  *
@@ -125,6 +125,9 @@ static irqreturn_t loongson2_perfcount_handler(int irq, void *dev_id)
         */
 
        /* Check whether the irq belongs to me */
+       enabled = read_c0_perfcnt() & LOONGSON2_PERFCNT_INT_EN;
+       if (!enabled)
+               return IRQ_NONE;
        enabled = reg.cnt1_enabled | reg.cnt2_enabled;
        if (!enabled)
                return IRQ_NONE;
index 91bfe73a7f602b348c6e2168e880e8448699293e..c9209ca6c8e7177c6ece17d6ac12d94d6edaff6d 100644 (file)
@@ -22,13 +22,13 @@ obj-$(CONFIG_BCM63XX)               += pci-bcm63xx.o fixup-bcm63xx.o \
 #
 # These are still pretty much in the old state, watch, go blind.
 #
-obj-$(CONFIG_BASLER_EXCITE)    += ops-titan.o pci-excite.o fixup-excite.o
 obj-$(CONFIG_LASAT)            += pci-lasat.o
 obj-$(CONFIG_MIPS_COBALT)      += fixup-cobalt.o
 obj-$(CONFIG_SOC_AU1500)       += fixup-au1000.o ops-au1000.o
 obj-$(CONFIG_SOC_AU1550)       += fixup-au1000.o ops-au1000.o
 obj-$(CONFIG_SOC_PNX8550)      += fixup-pnx8550.o ops-pnx8550.o
-obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-bonito64.o
+obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-loongson2.o
+obj-$(CONFIG_LEMOTE_MACH2F)    += fixup-lemote2f.o ops-loongson2.o
 obj-$(CONFIG_MIPS_MALTA)       += fixup-malta.o
 obj-$(CONFIG_PMC_MSP7120_GW)   += fixup-pmcmsp.o ops-pmcmsp.o
 obj-$(CONFIG_PMC_MSP7120_EVAL) += fixup-pmcmsp.o ops-pmcmsp.o
diff --git a/arch/mips/pci/fixup-excite.c b/arch/mips/pci/fixup-excite.c
deleted file mode 100644 (file)
index cd64d9f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *  Copyright (C) 2004 by Basler Vision Technologies AG
- *  Author: Thomas Koeller <thomas.koeller@baslerweb.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <excite.h>
-
-int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
-{
-       if (pin == 0)
-               return -1;
-
-       return USB_IRQ;         /* USB controller is the only PCI device */
-}
-
-/* Do platform specific device initialization at pci_enable_device() time */
-int pcibios_plat_dev_init(struct pci_dev *dev)
-{
-       return 0;
-}
index 0c4c7a81213f81b01dc24ac924320174a0064fa2..4f6d8da07f93906a786b967cebdce7bfde0721d7 100644 (file)
@@ -13,7 +13,8 @@
  */
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <asm/mips-boards/bonito64.h>
+
+#include <loongson.h>
 
 /* South bridge slot number is set by the pci probe process */
 static u8 sb_slot = 5;
@@ -35,7 +36,7 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
                        break;
                }
        } else {
-               irq = BONITO_IRQ_BASE + 25 + pin;
+               irq = LOONGSON_IRQ_BASE + 25 + pin;
        }
        return irq;
 
diff --git a/arch/mips/pci/fixup-lemote2f.c b/arch/mips/pci/fixup-lemote2f.c
new file mode 100644 (file)
index 0000000..caf2ede
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2008 Lemote Technology
+ * Copyright (C) 2004 ICT CAS
+ * Author: Li xiaoyu, lixy@ict.ac.cn
+ *
+ * Copyright (C) 2007 Lemote, Inc.
+ * Author: Fuxin Zhang, zhangfx@lemote.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */
+#include <linux/init.h>
+#include <linux/pci.h>
+
+#include <loongson.h>
+#include <cs5536/cs5536.h>
+#include <cs5536/cs5536_pci.h>
+
+/* PCI interrupt pins
+ *
+ * These should not be changed, or you should consider loongson2f interrupt
+ * register and your pci card dispatch
+ */
+
+#define PCIA           4
+#define PCIB           5
+#define PCIC           6
+#define PCID           7
+
+/* all the pci device has the PCIA pin, check the datasheet. */
+static char irq_tab[][5] __initdata = {
+       /*      INTA    INTB    INTC    INTD */
+       {0, 0, 0, 0, 0},        /*  11: Unused */
+       {0, 0, 0, 0, 0},        /*  12: Unused */
+       {0, 0, 0, 0, 0},        /*  13: Unused */
+       {0, 0, 0, 0, 0},        /*  14: Unused */
+       {0, 0, 0, 0, 0},        /*  15: Unused */
+       {0, 0, 0, 0, 0},        /*  16: Unused */
+       {0, PCIA, 0, 0, 0},     /*  17: RTL8110-0 */
+       {0, PCIB, 0, 0, 0},     /*  18: RTL8110-1 */
+       {0, PCIC, 0, 0, 0},     /*  19: SiI3114 */
+       {0, PCID, 0, 0, 0},     /*  20: 3-ports nec usb */
+       {0, PCIA, PCIB, PCIC, PCID},    /*  21: PCI-SLOT */
+       {0, 0, 0, 0, 0},        /*  22: Unused */
+       {0, 0, 0, 0, 0},        /*  23: Unused */
+       {0, 0, 0, 0, 0},        /*  24: Unused */
+       {0, 0, 0, 0, 0},        /*  25: Unused */
+       {0, 0, 0, 0, 0},        /*  26: Unused */
+       {0, 0, 0, 0, 0},        /*  27: Unused */
+};
+
+int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+{
+       int virq;
+
+       if ((PCI_SLOT(dev->devfn) != PCI_IDSEL_CS5536)
+           && (PCI_SLOT(dev->devfn) < 32)) {
+               virq = irq_tab[slot][pin];
+               printk(KERN_INFO "slot: %d, pin: %d, irq: %d\n", slot, pin,
+                      virq + LOONGSON_IRQ_BASE);
+               if (virq != 0)
+                       return LOONGSON_IRQ_BASE + virq;
+               else
+                       return 0;
+       } else if (PCI_SLOT(dev->devfn) == PCI_IDSEL_CS5536) {  /*  cs5536 */
+               switch (PCI_FUNC(dev->devfn)) {
+               case 2:
+                       pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
+                                             CS5536_IDE_INTR);
+                       return CS5536_IDE_INTR; /*  for IDE */
+               case 3:
+                       pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
+                                             CS5536_ACC_INTR);
+                       return CS5536_ACC_INTR; /*  for AUDIO */
+               case 4: /*  for OHCI */
+               case 5: /*  for EHCI */
+               case 6: /*  for UDC */
+               case 7: /*  for OTG */
+                       pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
+                                             CS5536_USB_INTR);
+                       return CS5536_USB_INTR;
+               }
+               return dev->irq;
+       } else {
+               printk(KERN_INFO " strange pci slot number.\n");
+               return 0;
+       }
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+       return 0;
+}
+
+/* CS5536 SPEC. fixup */
+static void __init loongson_cs5536_isa_fixup(struct pci_dev *pdev)
+{
+       /* the uart1 and uart2 interrupt in PIC is enabled as default */
+       pci_write_config_dword(pdev, PCI_UART1_INT_REG, 1);
+       pci_write_config_dword(pdev, PCI_UART2_INT_REG, 1);
+}
+
+static void __init loongson_cs5536_ide_fixup(struct pci_dev *pdev)
+{
+       /* setting the mutex pin as IDE function */
+       pci_write_config_dword(pdev, PCI_IDE_CFG_REG,
+                              CS5536_IDE_FLASH_SIGNATURE);
+}
+
+static void __init loongson_cs5536_acc_fixup(struct pci_dev *pdev)
+{
+       /* enable the AUDIO interrupt in PIC  */
+       pci_write_config_dword(pdev, PCI_ACC_INT_REG, 1);
+
+       pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xc0);
+}
+
+static void __init loongson_cs5536_ohci_fixup(struct pci_dev *pdev)
+{
+       /* enable the OHCI interrupt in PIC */
+       /* THE OHCI, EHCI, UDC, OTG are shared with interrupt in PIC */
+       pci_write_config_dword(pdev, PCI_OHCI_INT_REG, 1);
+}
+
+static void __init loongson_cs5536_ehci_fixup(struct pci_dev *pdev)
+{
+       u32 hi, lo;
+
+       /* Serial short detect enable */
+       _rdmsr(USB_MSR_REG(USB_CONFIG), &hi, &lo);
+       _wrmsr(USB_MSR_REG(USB_CONFIG), (1 << 1) | (1 << 2) | (1 << 3), lo);
+
+       /* setting the USB2.0 micro frame length */
+       pci_write_config_dword(pdev, PCI_EHCI_FLADJ_REG, 0x2000);
+}
+
+static void __init loongson_nec_fixup(struct pci_dev *pdev)
+{
+       unsigned int val;
+
+       pci_read_config_dword(pdev, 0xe0, &val);
+       /* Only 2 port be used */
+       pci_write_config_dword(pdev, 0xe0, (val & ~3) | 0x2);
+}
+
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA,
+                        loongson_cs5536_isa_fixup);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_OHC,
+                        loongson_cs5536_ohci_fixup);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_EHC,
+                        loongson_cs5536_ehci_fixup);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_AUDIO,
+                        loongson_cs5536_acc_fixup);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE,
+                        loongson_cs5536_ide_fixup);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_USB,
+                        loongson_nec_fixup);
index 54e55e7a243128a783070aed91faa661e96940b3..1b3e03f20c5466dea11954462fbc1b8291e6ee40 100644 (file)
 #define PCI_ACCESS_READ  0
 #define PCI_ACCESS_WRITE 1
 
-#ifdef CONFIG_LEMOTE_FULOONG2E
-#define CFG_SPACE_REG(offset) (void *)CKSEG1ADDR(BONITO_PCICFG_BASE | (offset))
-#define ID_SEL_BEGIN 11
-#else
 #define CFG_SPACE_REG(offset) (void *)CKSEG1ADDR(_pcictrl_bonito_pcicfg + (offset))
 #define ID_SEL_BEGIN 10
-#endif
 #define MAX_DEV_NUM (31 - ID_SEL_BEGIN)
 
 
@@ -77,10 +72,8 @@ static int bonito64_pcibios_config_access(unsigned char access_type,
        addrp = CFG_SPACE_REG(addr & 0xffff);
        if (access_type == PCI_ACCESS_WRITE) {
                writel(cpu_to_le32(*data), addrp);
-#ifndef CONFIG_LEMOTE_FULOONG2E
                /* Wait till done */
                while (BONITO_PCIMSTAT & 0xF);
-#endif
        } else {
                *data = le32_to_cpu(readl(addrp));
        }
diff --git a/arch/mips/pci/ops-loongson2.c b/arch/mips/pci/ops-loongson2.c
new file mode 100644 (file)
index 0000000..aa5d3da
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * fuloong2e specific PCI support.
+ *
+ * Copyright (C) 1999, 2000, 2004  MIPS Technologies, Inc.
+ *     All rights reserved.
+ *     Authors: Carsten Langgaard <carstenl@mips.com>
+ *              Maciej W. Rozycki <macro@mips.com>
+ *
+ * Copyright (C) 2009 Lemote Inc.
+ * Author: Wu Zhangjin <wuzj@lemote.com>
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ */
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+
+#include <loongson.h>
+
+#ifdef CONFIG_CS5536
+#include <cs5536/cs5536_pci.h>
+#include <cs5536/cs5536.h>
+#endif
+
+#define PCI_ACCESS_READ  0
+#define PCI_ACCESS_WRITE 1
+
+#define CFG_SPACE_REG(offset) \
+       (void *)CKSEG1ADDR(LOONGSON_PCICFG_BASE | (offset))
+#define ID_SEL_BEGIN 11
+#define MAX_DEV_NUM (31 - ID_SEL_BEGIN)
+
+
+static int loongson_pcibios_config_access(unsigned char access_type,
+                                     struct pci_bus *bus,
+                                     unsigned int devfn, int where,
+                                     u32 *data)
+{
+       u32 busnum = bus->number;
+       u32 addr, type;
+       u32 dummy;
+       void *addrp;
+       int device = PCI_SLOT(devfn);
+       int function = PCI_FUNC(devfn);
+       int reg = where & ~3;
+
+       if (busnum == 0) {
+               /* board-specific part,currently,only fuloong2f,yeeloong2f
+                * use CS5536, fuloong2e use via686b, gdium has no
+                * south bridge
+                */
+#ifdef CONFIG_CS5536
+               /* cs5536_pci_conf_read4/write4() will call _rdmsr/_wrmsr() to
+                * access the regsters PCI_MSR_ADDR, PCI_MSR_DATA_LO,
+                * PCI_MSR_DATA_HI, which is bigger than PCI_MSR_CTRL, so, it
+                * will not go this branch, but the others. so, no calling dead
+                * loop here.
+                */
+               if ((PCI_IDSEL_CS5536 == device) && (reg < PCI_MSR_CTRL)) {
+                       switch (access_type) {
+                       case PCI_ACCESS_READ:
+                               *data = cs5536_pci_conf_read4(function, reg);
+                               break;
+                       case PCI_ACCESS_WRITE:
+                               cs5536_pci_conf_write4(function, reg, *data);
+                               break;
+                       }
+                       return 0;
+               }
+#endif
+               /* Type 0 configuration for onboard PCI bus */
+               if (device > MAX_DEV_NUM)
+                       return -1;
+
+               addr = (1 << (device + ID_SEL_BEGIN)) | (function << 8) | reg;
+               type = 0;
+       } else {
+               /* Type 1 configuration for offboard PCI bus */
+               addr = (busnum << 16) | (device << 11) | (function << 8) | reg;
+               type = 0x10000;
+       }
+
+       /* Clear aborts */
+       LOONGSON_PCICMD |= LOONGSON_PCICMD_MABORT_CLR | \
+                               LOONGSON_PCICMD_MTABORT_CLR;
+
+       LOONGSON_PCIMAP_CFG = (addr >> 16) | type;
+
+       /* Flush Bonito register block */
+       dummy = LOONGSON_PCIMAP_CFG;
+       mmiowb();
+
+       addrp = CFG_SPACE_REG(addr & 0xffff);
+       if (access_type == PCI_ACCESS_WRITE)
+               writel(cpu_to_le32(*data), addrp);
+       else
+               *data = le32_to_cpu(readl(addrp));
+
+       /* Detect Master/Target abort */
+       if (LOONGSON_PCICMD & (LOONGSON_PCICMD_MABORT_CLR |
+                            LOONGSON_PCICMD_MTABORT_CLR)) {
+               /* Error occurred */
+
+               /* Clear bits */
+               LOONGSON_PCICMD |= (LOONGSON_PCICMD_MABORT_CLR |
+                                 LOONGSON_PCICMD_MTABORT_CLR);
+
+               return -1;
+       }
+
+       return 0;
+
+}
+
+
+/*
+ * We can't address 8 and 16 bit words directly.  Instead we have to
+ * read/write a 32bit word and mask/modify the data we actually want.
+ */
+static int loongson_pcibios_read(struct pci_bus *bus, unsigned int devfn,
+                            int where, int size, u32 *val)
+{
+       u32 data = 0;
+
+       if ((size == 2) && (where & 1))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+       else if ((size == 4) && (where & 3))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+
+       if (loongson_pcibios_config_access(PCI_ACCESS_READ, bus, devfn, where,
+                                      &data))
+               return -1;
+
+       if (size == 1)
+               *val = (data >> ((where & 3) << 3)) & 0xff;
+       else if (size == 2)
+               *val = (data >> ((where & 3) << 3)) & 0xffff;
+       else
+               *val = data;
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static int loongson_pcibios_write(struct pci_bus *bus, unsigned int devfn,
+                             int where, int size, u32 val)
+{
+       u32 data = 0;
+
+       if ((size == 2) && (where & 1))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+       else if ((size == 4) && (where & 3))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+
+       if (size == 4)
+               data = val;
+       else {
+               if (loongson_pcibios_config_access(PCI_ACCESS_READ, bus, devfn,
+                                       where, &data))
+                       return -1;
+
+               if (size == 1)
+                       data = (data & ~(0xff << ((where & 3) << 3))) |
+                               (val << ((where & 3) << 3));
+               else if (size == 2)
+                       data = (data & ~(0xffff << ((where & 3) << 3))) |
+                               (val << ((where & 3) << 3));
+       }
+
+       if (loongson_pcibios_config_access(PCI_ACCESS_WRITE, bus, devfn, where,
+                                      &data))
+               return -1;
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+struct pci_ops loongson_pci_ops = {
+       .read = loongson_pcibios_read,
+       .write = loongson_pcibios_write
+};
+
+#ifdef CONFIG_CS5536
+void _rdmsr(u32 msr, u32 *hi, u32 *lo)
+{
+       struct pci_bus bus = {
+               .number = PCI_BUS_CS5536
+       };
+       u32 devfn = PCI_DEVFN(PCI_IDSEL_CS5536, 0);
+       loongson_pcibios_write(&bus, devfn, PCI_MSR_ADDR, 4, msr);
+       loongson_pcibios_read(&bus, devfn, PCI_MSR_DATA_LO, 4, lo);
+       loongson_pcibios_read(&bus, devfn, PCI_MSR_DATA_HI, 4, hi);
+}
+EXPORT_SYMBOL(_rdmsr);
+
+void _wrmsr(u32 msr, u32 hi, u32 lo)
+{
+       struct pci_bus bus = {
+               .number = PCI_BUS_CS5536
+       };
+       u32 devfn = PCI_DEVFN(PCI_IDSEL_CS5536, 0);
+       loongson_pcibios_write(&bus, devfn, PCI_MSR_ADDR, 4, msr);
+       loongson_pcibios_write(&bus, devfn, PCI_MSR_DATA_LO, 4, lo);
+       loongson_pcibios_write(&bus, devfn, PCI_MSR_DATA_HI, 4, hi);
+}
+EXPORT_SYMBOL(_wrmsr);
+#endif
diff --git a/arch/mips/pci/pci-excite.c b/arch/mips/pci/pci-excite.c
deleted file mode 100644 (file)
index 8a56876..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *  Copyright (C) 2004 by Basler Vision Technologies AG
- *  Author: Thomas Koeller <thomas.koeller@baslerweb.com>
- *  Based on the PMC-Sierra Yosemite board support by Ralf Baechle.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/bitops.h>
-#include <asm/rm9k-ocd.h>
-#include <excite.h>
-
-
-extern struct pci_ops titan_pci_ops;
-
-
-static struct resource
-       mem_resource =  {
-               .name   = "PCI memory",
-               .start  = EXCITE_PHYS_PCI_MEM,
-               .end    = EXCITE_PHYS_PCI_MEM + EXCITE_SIZE_PCI_MEM - 1,
-               .flags  = IORESOURCE_MEM
-       },
-       io_resource = {
-               .name   = "PCI I/O",
-               .start  = EXCITE_PHYS_PCI_IO,
-               .end    = EXCITE_PHYS_PCI_IO + EXCITE_SIZE_PCI_IO - 1,
-               .flags  = IORESOURCE_IO
-       };
-
-
-static struct pci_controller bx_controller = {
-       .pci_ops        = &titan_pci_ops,
-       .mem_resource   = &mem_resource,
-       .mem_offset     = 0x00000000UL,
-       .io_resource    = &io_resource,
-       .io_offset      = 0x00000000UL
-};
-
-
-static char
-       iopage_failed[] __initdata   = "Cannot allocate PCI I/O page",
-       modebits_no_pci[] __initdata = "PCI is not configured in mode bits";
-
-#define RM9000x2_OCD_HTSC      0x0604
-#define RM9000x2_OCD_HTBHL     0x060c
-#define RM9000x2_OCD_PCIHRST   0x078c
-
-#define RM9K_OCD_MODEBIT1      0x00d4 /* (MODEBIT1) Mode Bit 1 */
-#define RM9K_OCD_CPHDCR                0x00f4 /* CPU-PCI/HT Data Control. */
-
-#define PCISC_FB2B             0x00000200
-#define PCISC_MWICG            0x00000010
-#define PCISC_EMC              0x00000004
-#define PCISC_ERMA             0x00000002
-
-
-
-static int __init basler_excite_pci_setup(void)
-{
-       const unsigned int fullbars = memsize / (256 << 20);
-       unsigned int i;
-
-       /* Check modebits to see if PCI is really enabled. */
-       if (!((ocd_readl(RM9K_OCD_MODEBIT1) >> (47-32)) & 0x1))
-               panic(modebits_no_pci);
-
-       if (NULL == request_mem_region(EXCITE_PHYS_PCI_IO, EXCITE_SIZE_PCI_IO,
-                                      "Memory-mapped PCI I/O page"))
-               panic(iopage_failed);
-
-       /* Enable PCI 0 as master for config cycles */
-       ocd_writel(PCISC_EMC | PCISC_ERMA, RM9000x2_OCD_HTSC);
-
-
-       /* Set up latency timer */
-       ocd_writel(0x8008, RM9000x2_OCD_HTBHL);
-
-       /*  Setup host IO and Memory space */
-       ocd_writel((EXCITE_PHYS_PCI_IO >> 4) | 1, LKB7);
-       ocd_writel(((EXCITE_SIZE_PCI_IO >> 4) & 0x7fffff00) - 0x100, LKM7);
-       ocd_writel((EXCITE_PHYS_PCI_MEM >> 4) | 1, LKB8);
-       ocd_writel(((EXCITE_SIZE_PCI_MEM >> 4) & 0x7fffff00) - 0x100, LKM8);
-
-       /* Set up PCI BARs to map all installed memory */
-       for (i = 0; i < 6; i++) {
-               const unsigned int bar = 0x610 + i * 4;
-
-               if (i < fullbars) {
-                       ocd_writel(0x10000000 * i, bar);
-                       ocd_writel(0x01000000 * i, bar + 0x140);
-                       ocd_writel(0x0ffff029, bar + 0x100);
-                       continue;
-               }
-
-               if (i == fullbars) {
-                       int o;
-                       u32 mask;
-
-                       const unsigned long rem = memsize - i * 0x10000000;
-                       if (!rem) {
-                               ocd_writel(0x00000000, bar + 0x100);
-                               continue;
-                       }
-
-                       o = ffs(rem) - 1;
-                       if (rem & ~(0x1 << o))
-                               o++;
-                       mask = ((0x1 << o) & 0x0ffff000) - 0x1000;
-                       ocd_writel(0x10000000 * i, bar);
-                       ocd_writel(0x01000000 * i, bar + 0x140);
-                       ocd_writel(0x00000029 | mask, bar + 0x100);
-                       continue;
-               }
-
-               ocd_writel(0x00000000, bar + 0x100);
-       }
-
-       /* Finally, enable the PCI interrupt */
-#if USB_IRQ > 7
-       set_c0_intcontrol(1 << USB_IRQ);
-#else
-       set_c0_status(1 << (USB_IRQ + 8));
-#endif
-
-       ioport_resource.start = EXCITE_PHYS_PCI_IO;
-       ioport_resource.end = EXCITE_PHYS_PCI_IO + EXCITE_SIZE_PCI_IO - 1;
-       set_io_port_base((unsigned long) ioremap_nocache(EXCITE_PHYS_PCI_IO, EXCITE_SIZE_PCI_IO));
-       register_pci_controller(&bx_controller);
-       return 0;
-}
-
-
-arch_initcall(basler_excite_pci_setup);
diff --git a/arch/mips/powertv/Kconfig b/arch/mips/powertv/Kconfig
new file mode 100644 (file)
index 0000000..ff0e7e3
--- /dev/null
@@ -0,0 +1,21 @@
+source "arch/mips/powertv/asic/Kconfig"
+
+config BOOTLOADER_DRIVER
+       bool "PowerTV Bootloader Driver Support"
+       default n
+       depends on POWERTV
+       help
+         Use this option if you want to load bootloader driver.
+
+config BOOTLOADER_FAMILY
+       string "POWERTV Bootloader Family string"
+       default "85"
+       depends on POWERTV && !BOOTLOADER_DRIVER
+       help
+         This value should be specified when the bootloader driver is disabled
+         and must be exactly two characters long. Families supported are:
+           R1 - RNG-100  R2 - RNG-200
+           A1 - Class A  B1 - Class B
+           E1 - Class E  F1 - Class F
+           44 - 45xx     46 - 46xx
+           85 - 85xx     86 - 86xx
diff --git a/arch/mips/powertv/Makefile b/arch/mips/powertv/Makefile
new file mode 100644 (file)
index 0000000..2c51671
--- /dev/null
@@ -0,0 +1,28 @@
+#
+# Carsten Langgaard, carstenl@mips.com
+# Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
+#
+# Carsten Langgaard, carstenl@mips.com
+# Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+# Portions copyright (C)  2009 Cisco Systems, Inc.
+#
+# This program is free software; you can distribute it and/or modify it
+# under the terms of the GNU General Public License (Version 2) as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+#
+# Makefile for the Cisco PowerTV-specific kernel interface routines
+# under Linux.
+#
+
+obj-y += cmdline.o init.o memory.o reset.o time.o powertv_setup.o asic/ pci/
+
+EXTRA_CFLAGS += -Wall -Werror
diff --git a/arch/mips/powertv/asic/Kconfig b/arch/mips/powertv/asic/Kconfig
new file mode 100644 (file)
index 0000000..2016bfe
--- /dev/null
@@ -0,0 +1,28 @@
+config MIN_RUNTIME_RESOURCES
+       bool "Support for minimum runtime resources"
+       default n
+       depends on POWERTV
+       help
+         Enables support for minimizing the number of (SA asic) runtime
+         resources that are preallocated by the kernel.
+
+config MIN_RUNTIME_DOCSIS
+       bool "Support for minimum DOCSIS resource"
+       default y
+       depends on MIN_RUNTIME_RESOURCES
+       help
+         Enables support for the preallocated DOCSIS resource.
+
+config MIN_RUNTIME_PMEM
+       bool "Support for minimum PMEM resource"
+       default y
+       depends on MIN_RUNTIME_RESOURCES
+       help
+         Enables support for the preallocated Memory resource.
+
+config MIN_RUNTIME_TFTP
+       bool "Support for minimum TFTP resource"
+       default y
+       depends on MIN_RUNTIME_RESOURCES
+       help
+         Enables support for the preallocated TFTP resource.
diff --git a/arch/mips/powertv/asic/Makefile b/arch/mips/powertv/asic/Makefile
new file mode 100644 (file)
index 0000000..bebfdcf
--- /dev/null
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2009  Scientific-Atlanta, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+obj-y += asic-calliope.o asic-cronus.o asic-zeus.o asic_devices.o asic_int.o \
+        irq_asic.o prealloc-calliope.o prealloc-cronus.o \
+        prealloc-cronuslite.o prealloc-zeus.o
+
+EXTRA_CFLAGS += -Wall -Werror
diff --git a/arch/mips/powertv/asic/asic-calliope.c b/arch/mips/powertv/asic/asic-calliope.c
new file mode 100644 (file)
index 0000000..03d3884
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Locations of devices in the Calliope ASIC.
+ *
+ * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:       Ken Eppinett
+ *               David Schleef <ds@schleef.org>
+ *
+ * Description:  Defines the platform resources for the SA settop.
+ */
+
+#include <asm/mach-powertv/asic.h>
+
+const struct register_map calliope_register_map = {
+       .eic_slow0_strt_add = 0x800000,
+       .eic_cfg_bits = 0x800038,
+       .eic_ready_status = 0x80004c,
+
+       .chipver3 = 0xA00800,
+       .chipver2 = 0xA00804,
+       .chipver1 = 0xA00808,
+       .chipver0 = 0xA0080c,
+
+       /* The registers of IRBlaster */
+       .uart1_intstat = 0xA01800,
+       .uart1_inten = 0xA01804,
+       .uart1_config1 = 0xA01808,
+       .uart1_config2 = 0xA0180C,
+       .uart1_divisorhi = 0xA01810,
+       .uart1_divisorlo = 0xA01814,
+       .uart1_data = 0xA01818,
+       .uart1_status = 0xA0181C,
+
+       .int_stat_3 = 0xA02800,
+       .int_stat_2 = 0xA02804,
+       .int_stat_1 = 0xA02808,
+       .int_stat_0 = 0xA0280c,
+       .int_config = 0xA02810,
+       .int_int_scan = 0xA02818,
+       .ien_int_3 = 0xA02830,
+       .ien_int_2 = 0xA02834,
+       .ien_int_1 = 0xA02838,
+       .ien_int_0 = 0xA0283c,
+       .int_level_3_3 = 0xA02880,
+       .int_level_3_2 = 0xA02884,
+       .int_level_3_1 = 0xA02888,
+       .int_level_3_0 = 0xA0288c,
+       .int_level_2_3 = 0xA02890,
+       .int_level_2_2 = 0xA02894,
+       .int_level_2_1 = 0xA02898,
+       .int_level_2_0 = 0xA0289c,
+       .int_level_1_3 = 0xA028a0,
+       .int_level_1_2 = 0xA028a4,
+       .int_level_1_1 = 0xA028a8,
+       .int_level_1_0 = 0xA028ac,
+       .int_level_0_3 = 0xA028b0,
+       .int_level_0_2 = 0xA028b4,
+       .int_level_0_1 = 0xA028b8,
+       .int_level_0_0 = 0xA028bc,
+       .int_docsis_en = 0xA028F4,
+
+       .mips_pll_setup = 0x980000,
+       .usb_fs = 0x980030,             /* -default 72800028- */
+       .test_bus = 0x9800CC,
+       .crt_spare = 0x9800d4,
+       .usb2_ohci_int_mask = 0x9A000c,
+       .usb2_strap = 0x9A0014,
+       .ehci_hcapbase = 0x9BFE00,
+       .ohci_hc_revision = 0x9BFC00,
+       .bcm1_bs_lmi_steer = 0x9E0004,
+       .usb2_control = 0x9E0054,
+       .usb2_stbus_obc = 0x9BFF00,
+       .usb2_stbus_mess_size = 0x9BFF04,
+       .usb2_stbus_chunk_size = 0x9BFF08,
+
+       .pcie_regs = 0x000000,          /* -doesn't exist- */
+       .tim_ch = 0xA02C10,
+       .tim_cl = 0xA02C14,
+       .gpio_dout = 0xA02c20,
+       .gpio_din = 0xA02c24,
+       .gpio_dir = 0xA02c2C,
+       .watchdog = 0xA02c30,
+       .front_panel = 0x000000,        /* -not used- */
+};
diff --git a/arch/mips/powertv/asic/asic-cronus.c b/arch/mips/powertv/asic/asic-cronus.c
new file mode 100644 (file)
index 0000000..5f4589c
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Locations of devices in the Cronus ASIC
+ *
+ * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:       Ken Eppinett
+ *               David Schleef <ds@schleef.org>
+ *
+ * Description:  Defines the platform resources for the SA settop.
+ */
+
+#include <asm/mach-powertv/asic.h>
+
+const struct register_map cronus_register_map = {
+       .eic_slow0_strt_add = 0x000000,
+       .eic_cfg_bits = 0x000038,
+       .eic_ready_status = 0x00004C,
+
+       .chipver3 = 0x2A0800,
+       .chipver2 = 0x2A0804,
+       .chipver1 = 0x2A0808,
+       .chipver0 = 0x2A080C,
+
+       /* The registers of IRBlaster */
+       .uart1_intstat = 0x2A1800,
+       .uart1_inten = 0x2A1804,
+       .uart1_config1 = 0x2A1808,
+       .uart1_config2 = 0x2A180C,
+       .uart1_divisorhi = 0x2A1810,
+       .uart1_divisorlo = 0x2A1814,
+       .uart1_data = 0x2A1818,
+       .uart1_status = 0x2A181C,
+
+       .int_stat_3 = 0x2A2800,
+       .int_stat_2 = 0x2A2804,
+       .int_stat_1 = 0x2A2808,
+       .int_stat_0 = 0x2A280C,
+       .int_config = 0x2A2810,
+       .int_int_scan = 0x2A2818,
+       .ien_int_3 = 0x2A2830,
+       .ien_int_2 = 0x2A2834,
+       .ien_int_1 = 0x2A2838,
+       .ien_int_0 = 0x2A283C,
+       .int_level_3_3 = 0x2A2880,
+       .int_level_3_2 = 0x2A2884,
+       .int_level_3_1 = 0x2A2888,
+       .int_level_3_0 = 0x2A288C,
+       .int_level_2_3 = 0x2A2890,
+       .int_level_2_2 = 0x2A2894,
+       .int_level_2_1 = 0x2A2898,
+       .int_level_2_0 = 0x2A289C,
+       .int_level_1_3 = 0x2A28A0,
+       .int_level_1_2 = 0x2A28A4,
+       .int_level_1_1 = 0x2A28A8,
+       .int_level_1_0 = 0x2A28AC,
+       .int_level_0_3 = 0x2A28B0,
+       .int_level_0_2 = 0x2A28B4,
+       .int_level_0_1 = 0x2A28B8,
+       .int_level_0_0 = 0x2A28BC,
+       .int_docsis_en = 0x2A28F4,
+
+       .mips_pll_setup = 0x1C0000,
+       .usb_fs = 0x1C0018,
+       .test_bus = 0x1C00CC,
+       .crt_spare = 0x1c00d4,
+       .usb2_ohci_int_mask = 0x20000C,
+       .usb2_strap = 0x200014,
+       .ehci_hcapbase = 0x21FE00,
+       .ohci_hc_revision = 0x1E0000,
+       .bcm1_bs_lmi_steer = 0x2E0008,
+       .usb2_control = 0x2E004C,
+       .usb2_stbus_obc = 0x21FF00,
+       .usb2_stbus_mess_size = 0x21FF04,
+       .usb2_stbus_chunk_size = 0x21FF08,
+
+       .pcie_regs = 0x220000,
+       .tim_ch = 0x2A2C10,
+       .tim_cl = 0x2A2C14,
+       .gpio_dout = 0x2A2C20,
+       .gpio_din = 0x2A2C24,
+       .gpio_dir = 0x2A2C2C,
+       .watchdog = 0x2A2C30,
+       .front_panel = 0x2A3800,
+};
diff --git a/arch/mips/powertv/asic/asic-zeus.c b/arch/mips/powertv/asic/asic-zeus.c
new file mode 100644 (file)
index 0000000..1469daa
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Locations of devices in the Zeus ASIC
+ *
+ * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:       Ken Eppinett
+ *               David Schleef <ds@schleef.org>
+ *
+ * Description:  Defines the platform resources for the SA settop.
+ */
+
+#include <asm/mach-powertv/asic.h>
+
+const struct register_map zeus_register_map = {
+       .eic_slow0_strt_add = 0x000000,
+       .eic_cfg_bits = 0x000038,
+       .eic_ready_status = 0x00004c,
+
+       .chipver3 = 0x280800,
+       .chipver2 = 0x280804,
+       .chipver1 = 0x280808,
+       .chipver0 = 0x28080c,
+
+       /* The registers of IRBlaster */
+       .uart1_intstat = 0x281800,
+       .uart1_inten = 0x281804,
+       .uart1_config1 = 0x281808,
+       .uart1_config2 = 0x28180C,
+       .uart1_divisorhi = 0x281810,
+       .uart1_divisorlo = 0x281814,
+       .uart1_data = 0x281818,
+       .uart1_status = 0x28181C,
+
+       .int_stat_3 = 0x282800,
+       .int_stat_2 = 0x282804,
+       .int_stat_1 = 0x282808,
+       .int_stat_0 = 0x28280c,
+       .int_config = 0x282810,
+       .int_int_scan = 0x282818,
+       .ien_int_3 = 0x282830,
+       .ien_int_2 = 0x282834,
+       .ien_int_1 = 0x282838,
+       .ien_int_0 = 0x28283c,
+       .int_level_3_3 = 0x282880,
+       .int_level_3_2 = 0x282884,
+       .int_level_3_1 = 0x282888,
+       .int_level_3_0 = 0x28288c,
+       .int_level_2_3 = 0x282890,
+       .int_level_2_2 = 0x282894,
+       .int_level_2_1 = 0x282898,
+       .int_level_2_0 = 0x28289c,
+       .int_level_1_3 = 0x2828a0,
+       .int_level_1_2 = 0x2828a4,
+       .int_level_1_1 = 0x2828a8,
+       .int_level_1_0 = 0x2828ac,
+       .int_level_0_3 = 0x2828b0,
+       .int_level_0_2 = 0x2828b4,
+       .int_level_0_1 = 0x2828b8,
+       .int_level_0_0 = 0x2828bc,
+       .int_docsis_en = 0x2828F4,
+
+       .mips_pll_setup = 0x1a0000,
+       .usb_fs = 0x1a0018,
+       .test_bus = 0x1a0238,
+       .crt_spare = 0x1a0090,
+       .usb2_ohci_int_mask = 0x1e000c,
+       .usb2_strap = 0x1e0014,
+       .ehci_hcapbase = 0x1FFE00,
+       .ohci_hc_revision = 0x1FFC00,
+       .bcm1_bs_lmi_steer = 0x2C0008,
+       .usb2_control = 0x2c01a0,
+       .usb2_stbus_obc = 0x1FFF00,
+       .usb2_stbus_mess_size = 0x1FFF04,
+       .usb2_stbus_chunk_size = 0x1FFF08,
+
+       .pcie_regs = 0x200000,
+       .tim_ch = 0x282C10,
+       .tim_cl = 0x282C14,
+       .gpio_dout = 0x282c20,
+       .gpio_din = 0x282c24,
+       .gpio_dir = 0x282c2C,
+       .watchdog = 0x282c30,
+       .front_panel = 0x283800,
+};
diff --git a/arch/mips/powertv/asic/asic_devices.c b/arch/mips/powertv/asic/asic_devices.c
new file mode 100644 (file)
index 0000000..bae8288
--- /dev/null
@@ -0,0 +1,787 @@
+/*
+ *                   ASIC Device List Intialization
+ *
+ * Description:  Defines the platform resources for the SA settop.
+ *
+ * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:       Ken Eppinett
+ *               David Schleef <ds@schleef.org>
+ *
+ * Description:  Defines the platform resources for the SA settop.
+ *
+ * NOTE: The bootloader allocates persistent memory at an address which is
+ * 16 MiB below the end of the highest address in KSEG0. All fixed
+ * address memory reservations must avoid this region.
+ */
+
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/resource.h>
+#include <linux/serial_reg.h>
+#include <linux/io.h>
+#include <linux/bootmem.h>
+#include <linux/mm.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <asm/page.h>
+#include <linux/swap.h>
+#include <linux/highmem.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/mach-powertv/asic.h>
+#include <asm/mach-powertv/asic_regs.h>
+#include <asm/mach-powertv/interrupts.h>
+
+#ifdef CONFIG_BOOTLOADER_DRIVER
+#include <asm/mach-powertv/kbldr.h>
+#endif
+#include <asm/bootinfo.h>
+
+#define BOOTLDRFAMILY(byte1, byte0) (((byte1) << 8) | (byte0))
+
+/*
+ * Forward Prototypes
+ */
+static void pmem_setup_resource(void);
+
+/*
+ * Global Variables
+ */
+enum asic_type asic;
+
+unsigned int platform_features;
+unsigned int platform_family;
+const struct register_map  *register_map;
+EXPORT_SYMBOL(register_map);                   /* Exported for testing */
+unsigned long asic_phy_base;
+unsigned long asic_base;
+EXPORT_SYMBOL(asic_base);                      /* Exported for testing */
+struct resource *gp_resources;
+static bool usb_configured;
+
+/*
+ * Don't recommend to use it directly, it is usually used by kernel internally.
+ * Portable code should be using interfaces such as ioremp, dma_map_single, etc.
+ */
+unsigned long phys_to_bus_offset;
+EXPORT_SYMBOL(phys_to_bus_offset);
+
+/*
+ *
+ * IO Resource Definition
+ *
+ */
+
+struct resource asic_resource = {
+       .name  = "ASIC Resource",
+       .start = 0,
+       .end   = ASIC_IO_SIZE,
+       .flags = IORESOURCE_MEM,
+};
+
+/*
+ *
+ * USB Host Resource Definition
+ *
+ */
+
+static struct resource ehci_resources[] = {
+       {
+               .parent = &asic_resource,
+               .start  = 0,
+               .end    = 0xff,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = irq_usbehci,
+               .end    = irq_usbehci,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static u64 ehci_dmamask = DMA_BIT_MASK(32);
+
+static struct platform_device ehci_device = {
+       .name = "powertv-ehci",
+       .id = 0,
+       .num_resources = 2,
+       .resource = ehci_resources,
+       .dev = {
+               .dma_mask = &ehci_dmamask,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+       },
+};
+
+static struct resource ohci_resources[] = {
+       {
+               .parent = &asic_resource,
+               .start  = 0,
+               .end    = 0xff,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .start  = irq_usbohci,
+               .end    = irq_usbohci,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static u64 ohci_dmamask = DMA_BIT_MASK(32);
+
+static struct platform_device ohci_device = {
+       .name = "powertv-ohci",
+       .id = 0,
+       .num_resources = 2,
+       .resource = ohci_resources,
+       .dev = {
+               .dma_mask = &ohci_dmamask,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+       },
+};
+
+static struct platform_device *platform_devices[] = {
+       &ehci_device,
+       &ohci_device,
+};
+
+/*
+ *
+ * Platform Configuration and Device Initialization
+ *
+ */
+static void __init fs_update(int pe, int md, int sdiv, int disable_div_by_3)
+{
+       int en_prg, byp, pwr, nsb, val;
+       int sout;
+
+       sout = 1;
+       en_prg = 1;
+       byp = 0;
+       nsb = 1;
+       pwr = 1;
+
+       val = ((sdiv << 29) | (md << 24) | (pe<<8) | (sout<<3) | (byp<<2) |
+               (nsb<<1) | (disable_div_by_3<<5));
+
+       asic_write(val, usb_fs);
+       asic_write(val | (en_prg<<4), usb_fs);
+       asic_write(val | (en_prg<<4) | pwr, usb_fs);
+}
+
+/*
+ * Allow override of bootloader-specified model
+ */
+static char __initdata cmdline[COMMAND_LINE_SIZE];
+
+#define        FORCEFAMILY_PARAM       "forcefamily"
+
+static __init int check_forcefamily(unsigned char forced_family[2])
+{
+       const char *p;
+
+       forced_family[0] = '\0';
+       forced_family[1] = '\0';
+
+       /* Check the command line for a forcefamily directive */
+       strncpy(cmdline, arcs_cmdline, COMMAND_LINE_SIZE - 1);
+       p = strstr(cmdline, FORCEFAMILY_PARAM);
+       if (p && (p != cmdline) && (*(p - 1) != ' '))
+               p = strstr(p, " " FORCEFAMILY_PARAM "=");
+
+       if (p) {
+               p += strlen(FORCEFAMILY_PARAM "=");
+
+               if (*p == '\0' || *(p + 1) == '\0' ||
+                       (*(p + 2) != '\0' && *(p + 2) != ' '))
+                       pr_err(FORCEFAMILY_PARAM " must be exactly two "
+                               "characters long, ignoring value\n");
+
+               else {
+                       forced_family[0] = *p;
+                       forced_family[1] = *(p + 1);
+               }
+       }
+
+       return 0;
+}
+
+/*
+ * platform_set_family - determine major platform family type.
+ *
+ * Returns family type; -1 if none
+ * Returns the family type; -1 if none
+ *
+ */
+static __init noinline void platform_set_family(void)
+{
+#define BOOTLDRFAMILY(byte1, byte0) (((byte1) << 8) | (byte0))
+
+       unsigned char forced_family[2];
+       unsigned short bootldr_family;
+
+       check_forcefamily(forced_family);
+
+       if (forced_family[0] != '\0' && forced_family[1] != '\0')
+               bootldr_family = BOOTLDRFAMILY(forced_family[0],
+                       forced_family[1]);
+       else {
+
+#ifdef CONFIG_BOOTLOADER_DRIVER
+               bootldr_family = (unsigned short) kbldr_GetSWFamily();
+#else
+#if defined(CONFIG_BOOTLOADER_FAMILY)
+               bootldr_family = (unsigned short) BOOTLDRFAMILY(
+                       CONFIG_BOOTLOADER_FAMILY[0],
+                       CONFIG_BOOTLOADER_FAMILY[1]);
+#else
+#error "Unknown Bootloader Family"
+#endif
+#endif
+       }
+
+       pr_info("Bootloader Family = 0x%04X\n", bootldr_family);
+
+       switch (bootldr_family) {
+       case BOOTLDRFAMILY('R', '1'):
+               platform_family = FAMILY_1500;
+               break;
+       case BOOTLDRFAMILY('4', '4'):
+               platform_family = FAMILY_4500;
+               break;
+       case BOOTLDRFAMILY('4', '6'):
+               platform_family = FAMILY_4600;
+               break;
+       case BOOTLDRFAMILY('A', '1'):
+               platform_family = FAMILY_4600VZA;
+               break;
+       case BOOTLDRFAMILY('8', '5'):
+               platform_family = FAMILY_8500;
+               break;
+       case BOOTLDRFAMILY('R', '2'):
+               platform_family = FAMILY_8500RNG;
+               break;
+       case BOOTLDRFAMILY('8', '6'):
+               platform_family = FAMILY_8600;
+               break;
+       case BOOTLDRFAMILY('B', '1'):
+               platform_family = FAMILY_8600VZB;
+               break;
+       case BOOTLDRFAMILY('E', '1'):
+               platform_family = FAMILY_1500VZE;
+               break;
+       case BOOTLDRFAMILY('F', '1'):
+               platform_family = FAMILY_1500VZF;
+               break;
+       default:
+               platform_family = -1;
+       }
+}
+
+unsigned int platform_get_family(void)
+{
+       return platform_family;
+}
+EXPORT_SYMBOL(platform_get_family);
+
+/*
+ * \brief usb_eye_configure() for optimizing the USB eye on Calliope.
+ *
+ * \param     unsigned int value saved to the register.
+ *
+ * \return    none
+ *
+ */
+static void __init usb_eye_configure(unsigned int value)
+{
+       asic_write(asic_read(crt_spare) | value, crt_spare);
+}
+
+/*
+ * platform_get_asic - determine the ASIC type.
+ *
+ * \param     none
+ *
+ * \return    ASIC type; ASIC_UNKNOWN if none
+ *
+ */
+enum asic_type platform_get_asic(void)
+{
+       return asic;
+}
+EXPORT_SYMBOL(platform_get_asic);
+
+/*
+ * platform_configure_usb - usb configuration based on platform type.
+ * @bcm1_usb2_ctl:     value for the BCM1_USB2_CTL register, which is
+ *                     quirky
+ */
+static void __init platform_configure_usb(void)
+{
+       u32 bcm1_usb2_ctl;
+
+       if (usb_configured)
+               return;
+
+       switch (asic) {
+       case ASIC_ZEUS:
+               fs_update(0x0000, 0x11, 0x02, 0);
+               bcm1_usb2_ctl = 0x803;
+               break;
+
+       case ASIC_CRONUS:
+       case ASIC_CRONUSLITE:
+               fs_update(0x0000, 0x11, 0x02, 0);
+               bcm1_usb2_ctl = 0x803;
+               break;
+
+       case ASIC_CALLIOPE:
+               fs_update(0x0000, 0x11, 0x02, 1);
+
+               switch (platform_family) {
+               case FAMILY_1500VZE:
+                       break;
+
+               case FAMILY_1500VZF:
+                       usb_eye_configure(0x003c0000);
+                       break;
+
+               default:
+                       usb_eye_configure(0x00300000);
+                       break;
+               }
+
+               bcm1_usb2_ctl = 0x803;
+               break;
+
+       default:
+               pr_err("Unknown ASIC type: %d\n", asic);
+               break;
+       }
+
+       /* turn on USB power */
+       asic_write(0, usb2_strap);
+       /* Enable all OHCI interrupts */
+       asic_write(bcm1_usb2_ctl, usb2_control);
+       /* USB2_STBUS_OBC store32/load32 */
+       asic_write(3, usb2_stbus_obc);
+       /* USB2_STBUS_MESS_SIZE 2 packets */
+       asic_write(1, usb2_stbus_mess_size);
+       /* USB2_STBUS_CHUNK_SIZE 2 packets */
+       asic_write(1, usb2_stbus_chunk_size);
+
+       usb_configured = true;
+}
+
+/*
+ * Set up the USB EHCI interface
+ */
+void platform_configure_usb_ehci()
+{
+       platform_configure_usb();
+}
+
+/*
+ * Set up the USB OHCI interface
+ */
+void platform_configure_usb_ohci()
+{
+       platform_configure_usb();
+}
+
+/*
+ * Shut the USB EHCI interface down--currently a NOP
+ */
+void platform_unconfigure_usb_ehci()
+{
+}
+
+/*
+ * Shut the USB OHCI interface down--currently a NOP
+ */
+void platform_unconfigure_usb_ohci()
+{
+}
+
+/**
+ * configure_platform - configuration based on platform type.
+ */
+void __init configure_platform(void)
+{
+       platform_set_family();
+
+       switch (platform_family) {
+       case FAMILY_1500:
+       case FAMILY_1500VZE:
+       case FAMILY_1500VZF:
+               platform_features = FFS_CAPABLE;
+               asic = ASIC_CALLIOPE;
+               asic_phy_base = CALLIOPE_IO_BASE;
+               register_map = &calliope_register_map;
+               asic_base = (unsigned long)ioremap_nocache(asic_phy_base,
+                       ASIC_IO_SIZE);
+
+               if (platform_family == FAMILY_1500VZE) {
+                       gp_resources = non_dvr_vze_calliope_resources;
+                       pr_info("Platform: 1500/Vz Class E - "
+                               "CALLIOPE, NON_DVR_CAPABLE\n");
+               } else if (platform_family == FAMILY_1500VZF) {
+                       gp_resources = non_dvr_vzf_calliope_resources;
+                       pr_info("Platform: 1500/Vz Class F - "
+                               "CALLIOPE, NON_DVR_CAPABLE\n");
+               } else {
+                       gp_resources = non_dvr_calliope_resources;
+                       pr_info("Platform: 1500/RNG100 - CALLIOPE, "
+                               "NON_DVR_CAPABLE\n");
+               }
+               break;
+
+       case FAMILY_4500:
+               platform_features = FFS_CAPABLE | PCIE_CAPABLE |
+                       DISPLAY_CAPABLE;
+               asic = ASIC_ZEUS;
+               asic_phy_base = ZEUS_IO_BASE;
+               register_map = &zeus_register_map;
+               asic_base = (unsigned long)ioremap_nocache(asic_phy_base,
+                       ASIC_IO_SIZE);
+               gp_resources = non_dvr_zeus_resources;
+
+               pr_info("Platform: 4500 - ZEUS, NON_DVR_CAPABLE\n");
+               break;
+
+       case FAMILY_4600:
+       {
+               unsigned int chipversion = 0;
+
+               /* The settop has PCIE but it isn't used, so don't advertise
+                * it*/
+               platform_features = FFS_CAPABLE | DISPLAY_CAPABLE;
+               asic_phy_base = CRONUS_IO_BASE;   /* same as Cronus */
+               register_map = &cronus_register_map;   /* same as Cronus */
+               asic_base = (unsigned long)ioremap_nocache(asic_phy_base,
+                       ASIC_IO_SIZE);
+               gp_resources = non_dvr_cronuslite_resources;
+
+               /* ASIC version will determine if this is a real CronusLite or
+                * Castrati(Cronus) */
+               chipversion  = asic_read(chipver3) << 24;
+               chipversion |= asic_read(chipver2) << 16;
+               chipversion |= asic_read(chipver1) << 8;
+               chipversion |= asic_read(chipver0);
+
+               if ((chipversion == CRONUS_10) || (chipversion == CRONUS_11))
+                       asic = ASIC_CRONUS;
+               else
+                       asic = ASIC_CRONUSLITE;
+
+               pr_info("Platform: 4600 - %s, NON_DVR_CAPABLE, "
+                       "chipversion=0x%08X\n",
+                       (asic == ASIC_CRONUS) ? "CRONUS" : "CRONUS LITE",
+                       chipversion);
+               break;
+       }
+       case FAMILY_4600VZA:
+               platform_features = FFS_CAPABLE | DISPLAY_CAPABLE;
+               asic = ASIC_CRONUS;
+               asic_phy_base = CRONUS_IO_BASE;
+               register_map = &cronus_register_map;
+               asic_base = (unsigned long)ioremap_nocache(asic_phy_base,
+                       ASIC_IO_SIZE);
+               gp_resources = non_dvr_cronus_resources;
+
+               pr_info("Platform: Vz Class A - CRONUS, NON_DVR_CAPABLE\n");
+               break;
+
+       case FAMILY_8500:
+       case FAMILY_8500RNG:
+               platform_features = DVR_CAPABLE | PCIE_CAPABLE |
+                       DISPLAY_CAPABLE;
+               asic = ASIC_ZEUS;
+               asic_phy_base = ZEUS_IO_BASE;
+               register_map = &zeus_register_map;
+               asic_base = (unsigned long)ioremap_nocache(asic_phy_base,
+                       ASIC_IO_SIZE);
+               gp_resources = dvr_zeus_resources;
+
+               pr_info("Platform: 8500/RNG200 - ZEUS, DVR_CAPABLE\n");
+               break;
+
+       case FAMILY_8600:
+       case FAMILY_8600VZB:
+               platform_features = DVR_CAPABLE | PCIE_CAPABLE |
+                       DISPLAY_CAPABLE;
+               asic = ASIC_CRONUS;
+               asic_phy_base = CRONUS_IO_BASE;
+               register_map = &cronus_register_map;
+               asic_base = (unsigned long)ioremap_nocache(asic_phy_base,
+                       ASIC_IO_SIZE);
+               gp_resources = dvr_cronus_resources;
+
+               pr_info("Platform: 8600/Vz Class B - CRONUS, "
+                       "DVR_CAPABLE\n");
+               break;
+
+       default:
+               pr_crit("Platform:  UNKNOWN PLATFORM\n");
+               break;
+       }
+
+       switch (asic) {
+       case ASIC_ZEUS:
+               phys_to_bus_offset = 0x30000000;
+               break;
+       case ASIC_CALLIOPE:
+               phys_to_bus_offset = 0x10000000;
+               break;
+       case ASIC_CRONUSLITE:
+               /* Fall through */
+       case ASIC_CRONUS:
+               /*
+                * TODO: We suppose 0x10000000 aliases into 0x20000000-
+                * 0x2XXXXXXX. If 0x10000000 aliases into 0x60000000-
+                * 0x6XXXXXXX, the offset should be 0x50000000, not 0x10000000.
+                */
+               phys_to_bus_offset = 0x10000000;
+               break;
+       default:
+               phys_to_bus_offset = 0x00000000;
+               break;
+       }
+}
+
+/**
+ * platform_devices_init - sets up USB device resourse.
+ */
+static int __init platform_devices_init(void)
+{
+       pr_notice("%s: ----- Initializing USB resources -----\n", __func__);
+
+       asic_resource.start = asic_phy_base;
+       asic_resource.end += asic_resource.start;
+
+       ehci_resources[0].start = asic_reg_phys_addr(ehci_hcapbase);
+       ehci_resources[0].end += ehci_resources[0].start;
+
+       ohci_resources[0].start = asic_reg_phys_addr(ohci_hc_revision);
+       ohci_resources[0].end += ohci_resources[0].start;
+
+       set_io_port_base(0);
+
+       platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
+
+       return 0;
+}
+
+arch_initcall(platform_devices_init);
+
+/*
+ *
+ * BOOTMEM ALLOCATION
+ *
+ */
+/*
+ * Allocates/reserves the Platform memory resources early in the boot process.
+ * This ignores any resources that are designated IORESOURCE_IO
+ */
+void __init platform_alloc_bootmem(void)
+{
+       int i;
+       int total = 0;
+
+       /* Get persistent memory data from command line before allocating
+        * resources. This need to happen before normal command line parsing
+        * has been done */
+       pmem_setup_resource();
+
+       /* Loop through looking for resources that want a particular address */
+       for (i = 0; gp_resources[i].flags != 0; i++) {
+               int size = gp_resources[i].end - gp_resources[i].start + 1;
+               if ((gp_resources[i].start != 0) &&
+                       ((gp_resources[i].flags & IORESOURCE_MEM) != 0)) {
+                       reserve_bootmem(bus_to_phys(gp_resources[i].start),
+                               size, 0);
+                       total += gp_resources[i].end -
+                               gp_resources[i].start + 1;
+                       pr_info("reserve resource %s at %08x (%u bytes)\n",
+                               gp_resources[i].name, gp_resources[i].start,
+                               gp_resources[i].end -
+                                       gp_resources[i].start + 1);
+               }
+       }
+
+       /* Loop through assigning addresses for those that are left */
+       for (i = 0; gp_resources[i].flags != 0; i++) {
+               int size = gp_resources[i].end - gp_resources[i].start + 1;
+               if ((gp_resources[i].start == 0) &&
+                       ((gp_resources[i].flags & IORESOURCE_MEM) != 0)) {
+                       void *mem = alloc_bootmem_pages(size);
+
+                       if (mem == NULL)
+                               pr_err("Unable to allocate bootmem pages "
+                                       "for %s\n", gp_resources[i].name);
+
+                       else {
+                               gp_resources[i].start =
+                                       phys_to_bus(virt_to_phys(mem));
+                               gp_resources[i].end =
+                                       gp_resources[i].start + size - 1;
+                               total += size;
+                               pr_info("allocate resource %s at %08x "
+                                               "(%u bytes)\n",
+                                       gp_resources[i].name,
+                                       gp_resources[i].start, size);
+                       }
+               }
+       }
+
+       pr_info("Total Platform driver memory allocation: 0x%08x\n", total);
+
+       /* indicate resources that are platform I/O related */
+       for (i = 0; gp_resources[i].flags != 0; i++) {
+               if ((gp_resources[i].start != 0) &&
+                       ((gp_resources[i].flags & IORESOURCE_IO) != 0)) {
+                       pr_info("reserved platform resource %s at %08x\n",
+                               gp_resources[i].name, gp_resources[i].start);
+               }
+       }
+}
+
+/*
+ *
+ * PERSISTENT MEMORY (PMEM) CONFIGURATION
+ *
+ */
+static unsigned long pmemaddr __initdata;
+
+static int __init early_param_pmemaddr(char *p)
+{
+       pmemaddr = (unsigned long)simple_strtoul(p, NULL, 0);
+       return 0;
+}
+early_param("pmemaddr", early_param_pmemaddr);
+
+static long pmemlen __initdata;
+
+static int __init early_param_pmemlen(char *p)
+{
+/* TODO: we can use this code when and if the bootloader ever changes this */
+#if 0
+       pmemlen = (unsigned long)simple_strtoul(p, NULL, 0);
+#else
+       pmemlen = 0x20000;
+#endif
+       return 0;
+}
+early_param("pmemlen", early_param_pmemlen);
+
+/*
+ * Set up persistent memory. If we were given values, we patch the array of
+ * resources. Otherwise, persistent memory may be allocated anywhere at all.
+ */
+static void __init pmem_setup_resource(void)
+{
+       struct resource *resource;
+       resource = asic_resource_get("DiagPersistentMemory");
+
+       if (resource && pmemaddr && pmemlen) {
+               /* The address provided by bootloader is in kseg0. Convert to
+                * a bus address. */
+               resource->start = phys_to_bus(pmemaddr - 0x80000000);
+               resource->end = resource->start + pmemlen - 1;
+
+               pr_info("persistent memory: start=0x%x  end=0x%x\n",
+                       resource->start, resource->end);
+       }
+}
+
+/*
+ *
+ * RESOURCE ACCESS FUNCTIONS
+ *
+ */
+
+/**
+ * asic_resource_get - retrieves parameters for a platform resource.
+ * @name:      string to match resource
+ *
+ * Returns a pointer to a struct resource corresponding to the given name.
+ *
+ * CANNOT BE NAMED platform_resource_get, which would be the obvious choice,
+ * as this function name is already declared
+ */
+struct resource *asic_resource_get(const char *name)
+{
+       int i;
+
+       for (i = 0; gp_resources[i].flags != 0; i++) {
+               if (strcmp(gp_resources[i].name, name) == 0)
+                       return &gp_resources[i];
+       }
+
+       return NULL;
+}
+EXPORT_SYMBOL(asic_resource_get);
+
+/**
+ * platform_release_memory - release pre-allocated memory
+ * @ptr:       pointer to memory to release
+ * @size:      size of resource
+ *
+ * This must only be called for memory allocated or reserved via the boot
+ * memory allocator.
+ */
+void platform_release_memory(void *ptr, int size)
+{
+       unsigned long addr;
+       unsigned long end;
+
+       addr = ((unsigned long)ptr + (PAGE_SIZE - 1)) & PAGE_MASK;
+       end = ((unsigned long)ptr + size) & PAGE_MASK;
+
+       for (; addr < end; addr += PAGE_SIZE) {
+               ClearPageReserved(virt_to_page(__va(addr)));
+               init_page_count(virt_to_page(__va(addr)));
+               free_page((unsigned long)__va(addr));
+       }
+}
+EXPORT_SYMBOL(platform_release_memory);
+
+/*
+ *
+ * FEATURE AVAILABILITY FUNCTIONS
+ *
+ */
+int platform_supports_dvr(void)
+{
+       return (platform_features & DVR_CAPABLE) != 0;
+}
+
+int platform_supports_ffs(void)
+{
+       return (platform_features & FFS_CAPABLE) != 0;
+}
+
+int platform_supports_pcie(void)
+{
+       return (platform_features & PCIE_CAPABLE) != 0;
+}
+
+int platform_supports_display(void)
+{
+       return (platform_features & DISPLAY_CAPABLE) != 0;
+}
diff --git a/arch/mips/powertv/asic/asic_int.c b/arch/mips/powertv/asic/asic_int.c
new file mode 100644 (file)
index 0000000..80b2eed
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000, 2001, 2004 MIPS Technologies, Inc.
+ * Copyright (C) 2001 Ralf Baechle
+ * Portions copyright (C) 2009  Cisco Systems, Inc.
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Routines for generic manipulation of the interrupts found on the PowerTV
+ * platform.
+ *
+ * The interrupt controller is located in the South Bridge a PIIX4 device
+ * with two internal 82C95 interrupt controllers.
+ */
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/kernel_stat.h>
+#include <linux/kernel.h>
+#include <linux/random.h>
+
+#include <asm/irq_cpu.h>
+#include <linux/io.h>
+#include <asm/irq_regs.h>
+#include <asm/mips-boards/generic.h>
+
+#include <asm/mach-powertv/asic_regs.h>
+
+static DEFINE_SPINLOCK(asic_irq_lock);
+
+static inline int get_int(void)
+{
+       unsigned long flags;
+       int irq;
+
+       spin_lock_irqsave(&asic_irq_lock, flags);
+
+       irq = (asic_read(int_int_scan) >> 4) - 1;
+
+       if (irq == 0 || irq >= NR_IRQS)
+               irq = -1;
+
+       spin_unlock_irqrestore(&asic_irq_lock, flags);
+
+       return irq;
+}
+
+static void asic_irqdispatch(void)
+{
+       int irq;
+
+       irq = get_int();
+       if (irq < 0)
+               return;  /* interrupt has already been cleared */
+
+       do_IRQ(irq);
+}
+
+static inline int clz(unsigned long x)
+{
+       __asm__(
+       "       .set    push                                    \n"
+       "       .set    mips32                                  \n"
+       "       clz     %0, %1                                  \n"
+       "       .set    pop                                     \n"
+       : "=r" (x)
+       : "r" (x));
+
+       return x;
+}
+
+/*
+ * Version of ffs that only looks at bits 12..15.
+ */
+static inline unsigned int irq_ffs(unsigned int pending)
+{
+       return fls(pending) - 1 + CAUSEB_IP;
+}
+
+/*
+ * TODO: check how it works under EIC mode.
+ */
+asmlinkage void plat_irq_dispatch(void)
+{
+       unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
+       int irq;
+
+       irq = irq_ffs(pending);
+
+       if (irq == CAUSEF_IP3)
+               asic_irqdispatch();
+       else if (irq >= 0)
+               do_IRQ(irq);
+       else
+               spurious_interrupt();
+}
+
+void __init arch_init_irq(void)
+{
+       int i;
+
+       asic_irq_init();
+
+       /*
+        * Initialize interrupt exception vectors.
+        */
+       if (cpu_has_veic || cpu_has_vint) {
+               int nvec = cpu_has_veic ? 64 : 8;
+               for (i = 0; i < nvec; i++)
+                       set_vi_handler(i, asic_irqdispatch);
+       }
+}
diff --git a/arch/mips/powertv/asic/irq_asic.c b/arch/mips/powertv/asic/irq_asic.c
new file mode 100644 (file)
index 0000000..b54d244
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Portions copyright (C) 2005-2009 Scientific Atlanta
+ * Portions copyright (C) 2009 Cisco Systems, Inc.
+ *
+ * Modified from arch/mips/kernel/irq-rm7000.c:
+ * Copyright (C) 2003 Ralf Baechle
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+
+#include <asm/irq_cpu.h>
+#include <asm/mipsregs.h>
+#include <asm/system.h>
+
+#include <asm/mach-powertv/asic_regs.h>
+
+static inline void unmask_asic_irq(unsigned int irq)
+{
+       unsigned long enable_bit;
+
+       enable_bit = (1 << (irq & 0x1f));
+
+       switch (irq >> 5) {
+       case 0:
+               asic_write(asic_read(ien_int_0) | enable_bit, ien_int_0);
+               break;
+       case 1:
+               asic_write(asic_read(ien_int_1) | enable_bit, ien_int_1);
+               break;
+       case 2:
+               asic_write(asic_read(ien_int_2) | enable_bit, ien_int_2);
+               break;
+       case 3:
+               asic_write(asic_read(ien_int_3) | enable_bit, ien_int_3);
+               break;
+       default:
+               BUG();
+       }
+}
+
+static inline void mask_asic_irq(unsigned int irq)
+{
+       unsigned long disable_mask;
+
+       disable_mask = ~(1 << (irq & 0x1f));
+
+       switch (irq >> 5) {
+       case 0:
+               asic_write(asic_read(ien_int_0) & disable_mask, ien_int_0);
+               break;
+       case 1:
+               asic_write(asic_read(ien_int_1) & disable_mask, ien_int_1);
+               break;
+       case 2:
+               asic_write(asic_read(ien_int_2) & disable_mask, ien_int_2);
+               break;
+       case 3:
+               asic_write(asic_read(ien_int_3) & disable_mask, ien_int_3);
+               break;
+       default:
+               BUG();
+       }
+}
+
+static struct irq_chip asic_irq_chip = {
+       .name = "ASIC Level",
+       .ack = mask_asic_irq,
+       .mask = mask_asic_irq,
+       .mask_ack = mask_asic_irq,
+       .unmask = unmask_asic_irq,
+       .eoi = unmask_asic_irq,
+};
+
+void __init asic_irq_init(void)
+{
+       int i;
+
+       /* set priority to 0 */
+       write_c0_status(read_c0_status() & ~(0x0000fc00));
+
+       asic_write(0, ien_int_0);
+       asic_write(0, ien_int_1);
+       asic_write(0, ien_int_2);
+       asic_write(0, ien_int_3);
+
+       asic_write(0x0fffffff, int_level_3_3);
+       asic_write(0xffffffff, int_level_3_2);
+       asic_write(0xffffffff, int_level_3_1);
+       asic_write(0xffffffff, int_level_3_0);
+       asic_write(0xffffffff, int_level_2_3);
+       asic_write(0xffffffff, int_level_2_2);
+       asic_write(0xffffffff, int_level_2_1);
+       asic_write(0xffffffff, int_level_2_0);
+       asic_write(0xffffffff, int_level_1_3);
+       asic_write(0xffffffff, int_level_1_2);
+       asic_write(0xffffffff, int_level_1_1);
+       asic_write(0xffffffff, int_level_1_0);
+       asic_write(0xffffffff, int_level_0_3);
+       asic_write(0xffffffff, int_level_0_2);
+       asic_write(0xffffffff, int_level_0_1);
+       asic_write(0xffffffff, int_level_0_0);
+
+       asic_write(0xf, int_int_scan);
+
+       /*
+        * Initialize interrupt handlers.
+        */
+       for (i = 0; i < NR_IRQS; i++)
+               set_irq_chip_and_handler(i, &asic_irq_chip, handle_level_irq);
+}
diff --git a/arch/mips/powertv/asic/prealloc-calliope.c b/arch/mips/powertv/asic/prealloc-calliope.c
new file mode 100644 (file)
index 0000000..cd5b76a
--- /dev/null
@@ -0,0 +1,620 @@
+/*
+ * Memory pre-allocations for Calliope boxes.
+ *
+ * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:       Ken Eppinett
+ *               David Schleef <ds@schleef.org>
+ */
+
+#include <linux/init.h>
+#include <asm/mach-powertv/asic.h>
+
+/*
+ * NON_DVR_CAPABLE CALLIOPE RESOURCES
+ */
+struct resource non_dvr_calliope_resources[] __initdata =
+{
+       /*
+        * VIDEO / LX1
+        */
+       {
+               .name   = "ST231aImage",        /* Delta-Mu 1 image and ram */
+               .start  = 0x24000000,
+               .end    = 0x24200000 - 1,       /*2MiB */
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ST231aMonitor",   /*8KiB block ST231a monitor */
+               .start  = 0x24200000,
+               .end    = 0x24202000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x24202000,
+               .end    = 0x26700000 - 1, /*~36.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Sysaudio Driver
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * STAVEM driver/STAPI
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x00000000,
+               .end    = 0x00600000 - 1,       /* 6 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * DOCSIS Subsystem
+        */
+       {
+               .name   = "Docsis",
+               .start  = 0x22000000,
+               .end    = 0x22700000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * GHW HAL Driver
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x22700000,
+               .end    = 0x23500000 - 1,       /* 14 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * multi com buffer area
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x23700000,
+               .end    = 0x23720000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * DMA Ring buffer (don't need recording buffers)
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x000AA000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Display bins buffer for unit0
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,           /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * AVFS: player HAL memory
+        *
+        *
+        */
+       {
+               .name   = "AvfsDmaMem",
+               .start  = 0x00000000,
+               .end    = 0x002c4c00 - 1,       /* 945K * 3 for playback */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * PMEM
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Smartcard
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x00000000,
+               .end    = 0x2800 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * NAND Flash
+        */
+       {
+               .name   = "NandFlash",
+               .start  = NAND_FLASH_BASE,
+               .end    = NAND_FLASH_BASE + 0x400 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        * Synopsys GMAC Memory Region
+        */
+       {
+               .name   = "GMAC",
+               .start  = 0x00000000,
+               .end    = 0x00010000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Add other resources here
+        *
+        */
+       { },
+};
+
+struct resource non_dvr_vz_calliope_resources[] __initdata =
+{
+       /*
+        * VIDEO / LX1
+        */
+       {
+               .name   = "ST231aImage",        /* Delta-Mu 1 image and ram */
+               .start  = 0x24000000,
+               .end    = 0x24200000 - 1, /*2 Meg */
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ST231aMonitor",      /* 8k block ST231a monitor */
+               .start  = 0x24200000,
+               .end    = 0x24202000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x22202000,
+               .end    = 0x22C20B85 - 1,       /* 10.12 Meg */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Sysaudio Driver
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * STAVEM driver/STAPI
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x20300000,
+               .end    = 0x20620000-1,  /*3.125 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * GHW HAL Driver
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x20100000,
+               .end    = 0x20300000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * multi com buffer area
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x23900000,
+               .end    = 0x23920000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * DMA Ring buffer
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x000AA000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Display bins buffer for unit0
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * PMEM
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Smartcard
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x00000000,
+               .end    = 0x2800 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * NAND Flash
+        */
+       {
+               .name   = "NandFlash",
+               .start  = NAND_FLASH_BASE,
+               .end    = NAND_FLASH_BASE+0x400 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        * Synopsys GMAC Memory Region
+        */
+       {
+               .name   = "GMAC",
+               .start  = 0x00000000,
+               .end    = 0x00010000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Add other resources here
+        */
+       { },
+};
+
+struct resource non_dvr_vze_calliope_resources[] __initdata =
+{
+       /*
+        * VIDEO / LX1
+        */
+       {
+               .name   = "ST231aImage",        /* Delta-Mu 1 image and ram */
+               .start  = 0x22000000,
+               .end    = 0x22200000 - 1,       /*2  Meg */
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ST231aMonitor",      /* 8k block ST231a monitor */
+               .start  = 0x22200000,
+               .end    = 0x22202000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x22202000,
+               .end    = 0x22C20B85 - 1,       /* 10.12 Meg */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Sysaudio Driver
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * STAVEM driver/STAPI
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x20396000,
+               .end    = 0x206B6000 - 1,               /* 3.125 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * GHW HAL Driver
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x20100000,
+               .end    = 0x20396000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * multi com buffer area
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x206B6000,
+               .end    = 0x206D6000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * DMA Ring buffer
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x000AA000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Display bins buffer for unit0
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * PMEM
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Smartcard
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x00000000,
+               .end    = 0x2800 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * NAND Flash
+        */
+       {
+               .name   = "NandFlash",
+               .start  = NAND_FLASH_BASE,
+               .end    = NAND_FLASH_BASE+0x400 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Synopsys GMAC Memory Region
+        */
+       {
+               .name   = "GMAC",
+               .start  = 0x00000000,
+               .end    = 0x00010000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Add other resources here
+        */
+       { },
+};
+
+struct resource non_dvr_vzf_calliope_resources[] __initdata =
+{
+       /*
+        * VIDEO / LX1
+        */
+       {
+               .name   = "ST231aImage",        /*Delta-Mu 1 image and ram */
+               .start  = 0x24000000,
+               .end    = 0x24200000 - 1,       /*2MiB */
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ST231aMonitor",      /*8KiB block ST231a monitor */
+               .start  = 0x24200000,
+               .end    = 0x24202000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x24202000,
+               /* ~19.4 (21.5MiB - (2MiB + 8KiB)) */
+               .end    = 0x25580000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Sysaudio Driver
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * STAVEM driver/STAPI
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x00000000,
+               .end    = 0x00480000 - 1,  /* 4.5 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * GHW HAL Driver
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x22700000,
+               .end    = 0x23500000 - 1, /* 14 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * multi com buffer area
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x23700000,
+               .end    = 0x23720000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * DMA Ring buffer (don't need recording buffers)
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x000AA000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Display bins buffer for unit0
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,  /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Display bins buffer for unit1
+        */
+       {
+               .name   = "DisplayBins1",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,  /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * AVFS: player HAL memory
+        *
+        *
+        */
+       {
+               .name   = "AvfsDmaMem",
+               .start  = 0x00000000,
+               .end    = 0x002c4c00 - 1,  /* 945K * 3 for playback */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * PMEM
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Smartcard
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x00000000,
+               .end    = 0x2800 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * NAND Flash
+        */
+       {
+               .name   = "NandFlash",
+               .start  = NAND_FLASH_BASE,
+               .end    = NAND_FLASH_BASE + 0x400 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Synopsys GMAC Memory Region
+        */
+       {
+               .name   = "GMAC",
+               .start  = 0x00000000,
+               .end    = 0x00010000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Add other resources here
+        */
+       { },
+};
diff --git a/arch/mips/powertv/asic/prealloc-cronus.c b/arch/mips/powertv/asic/prealloc-cronus.c
new file mode 100644 (file)
index 0000000..45a5c3e
--- /dev/null
@@ -0,0 +1,608 @@
+/*
+ * Memory pre-allocations for Cronus boxes.
+ *
+ * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:       Ken Eppinett
+ *               David Schleef <ds@schleef.org>
+ */
+
+#include <linux/init.h>
+#include <asm/mach-powertv/asic.h>
+
+/*
+ * DVR_CAPABLE CRONUS RESOURCES
+ */
+struct resource dvr_cronus_resources[] __initdata =
+{
+       /*
+        *
+        * VIDEO1 / LX1
+        *
+        */
+       {
+               .name   = "ST231aImage",        /* Delta-Mu 1 image and ram */
+               .start  = 0x24000000,
+               .end    = 0x241FFFFF,           /* 2MiB */
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ST231aMonitor",      /* 8KiB block ST231a monitor */
+               .start  = 0x24200000,
+               .end    = 0x24201FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x24202000,
+               .end    = 0x25FFFFFF, /*~29.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * VIDEO2 / LX2
+        *
+        */
+       {
+               .name   = "ST231bImage",        /* Delta-Mu 2 image and ram */
+               .start  = 0x60000000,
+               .end    = 0x601FFFFF,           /* 2MiB */
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "ST231bMonitor",      /* 8KiB block ST231b monitor */
+               .start  = 0x60200000,
+               .end    = 0x60201FFF,
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "MediaMemory2",
+               .start  = 0x60202000,
+               .end    = 0x61FFFFFF, /*~29.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * Sysaudio Driver
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  DSP_Image_Buff - DSP code and data images (1MB)
+        *  ADSC_CPU_PCM_Buff - ADSC CPU PCM buffer (40KB)
+        *  ADSC_AUX_Buff - ADSC AUX buffer (16KB)
+        *  ADSC_Main_Buff - ADSC Main buffer (16KB)
+        *
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * STAVEM driver/STAPI
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  This memory area is used for allocating buffers for Video decoding
+        *  purposes.  Allocation/De-allocation within this buffer is managed
+        *  by the STAVMEM driver of the STAPI.  They could be Decimated
+        *  Picture Buffers, Intermediate Buffers, as deemed necessary for
+        *  video decoding purposes, for any video decoders on Zeus.
+        *
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x63580000,
+               .end    = 0x64180000 - 1,  /* 12 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * DOCSIS Subsystem
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "Docsis",
+               .start  = 0x62000000,
+               .end    = 0x62700000 - 1,       /* 7 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * GHW HAL Driver
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  GraphicsHeap - PowerTV Graphics Heap
+        *
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x62700000,
+               .end    = 0x63500000 - 1,       /* 14 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * multi com buffer area
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x26000000,
+               .end    = 0x26020000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * DMA Ring buffer
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x00280000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Display bins buffer for unit0
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Display Bins for unit0
+        *
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,           /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Display bins buffer
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Display Bins for unit1
+        *
+        */
+       {
+               .name   = "DisplayBins1",
+               .start  = 0x64AD4000,
+               .end    = 0x64AD5000 - 1,  /* 4 KB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * ITFS
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "ITFS",
+               .start  = 0x64180000,
+               /* 815,104 bytes each for 2 ITFS partitions. */
+               .end    = 0x6430DFFF,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * AVFS
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "AvfsDmaMem",
+               .start  = 0x6430E000,
+               /* (945K * 8) = (128K *3) 5 playbacks / 3 server */
+               .end    = 0x64AD0000 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "AvfsFileSys",
+               .start  = 0x64AD0000,
+               .end    = 0x64AD1000 - 1,  /* 4K */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * PMEM
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Persistent memory for diagnostics.
+        *
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Smartcard
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Read and write buffers for Internal/External cards
+        *
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x64AD1000,
+               .end    = 0x64AD3800 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * KAVNET
+        *    NP Reset Vector - must be of the form xxCxxxxx
+        *         NP Image - must be video bank 1
+        *         NP IPC - must be video bank 2
+        */
+       {
+               .name   = "NP_Reset_Vector",
+               .start  = 0x27c00000,
+               .end    = 0x27c01000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "NP_Image",
+               .start  = 0x27020000,
+               .end    = 0x27060000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "NP_IPC",
+               .start  = 0x63500000,
+               .end    = 0x63580000 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        * Add other resources here
+        */
+       { },
+};
+
+/*
+ * NON_DVR_CAPABLE CRONUS RESOURCES
+ */
+struct resource non_dvr_cronus_resources[] __initdata =
+{
+       /*
+        *
+        * VIDEO1 / LX1
+        *
+        */
+       {
+               .name   = "ST231aImage",        /* Delta-Mu 1 image and ram */
+               .start  = 0x24000000,
+               .end    = 0x241FFFFF,           /* 2MiB */
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ST231aMonitor",      /* 8KiB block ST231a monitor */
+               .start  = 0x24200000,
+               .end    = 0x24201FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x24202000,
+               .end    = 0x25FFFFFF, /*~29.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * VIDEO2 / LX2
+        *
+        */
+       {
+               .name   = "ST231bImage",        /* Delta-Mu 2 image and ram */
+               .start  = 0x60000000,
+               .end    = 0x601FFFFF,           /* 2MiB */
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "ST231bMonitor",      /* 8KiB block ST231b monitor */
+               .start  = 0x60200000,
+               .end    = 0x60201FFF,
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "MediaMemory2",
+               .start  = 0x60202000,
+               .end    = 0x61FFFFFF, /*~29.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * Sysaudio Driver
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  DSP_Image_Buff - DSP code and data images (1MB)
+        *  ADSC_CPU_PCM_Buff - ADSC CPU PCM buffer (40KB)
+        *  ADSC_AUX_Buff - ADSC AUX buffer (16KB)
+        *  ADSC_Main_Buff - ADSC Main buffer (16KB)
+        *
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * STAVEM driver/STAPI
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  This memory area is used for allocating buffers for Video decoding
+        *  purposes.  Allocation/De-allocation within this buffer is managed
+        *  by the STAVMEM driver of the STAPI.  They could be Decimated
+        *  Picture Buffers, Intermediate Buffers, as deemed necessary for
+        *  video decoding purposes, for any video decoders on Zeus.
+        *
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x63580000,
+               .end    = 0x64180000 - 1,  /* 12 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * DOCSIS Subsystem
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "Docsis",
+               .start  = 0x62000000,
+               .end    = 0x62700000 - 1,       /* 7 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * GHW HAL Driver
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  GraphicsHeap - PowerTV Graphics Heap
+        *
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x62700000,
+               .end    = 0x63500000 - 1,       /* 14 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * multi com buffer area
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x26000000,
+               .end    = 0x26020000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * DMA Ring buffer
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x000AA000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Display bins buffer for unit0
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Display Bins for unit0
+        *
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,           /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Display bins buffer
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Display Bins for unit1
+        *
+        */
+       {
+               .name   = "DisplayBins1",
+               .start  = 0x64AD4000,
+               .end    = 0x64AD5000 - 1,  /* 4 KB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * AVFS: player HAL memory
+        *
+        *
+        */
+       {
+               .name   = "AvfsDmaMem",
+               .start  = 0x6430E000,
+               .end    = 0x645D2C00 - 1,  /* 945K * 3 for playback */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * PMEM
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Persistent memory for diagnostics.
+        *
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Smartcard
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Read and write buffers for Internal/External cards
+        *
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x64AD1000,
+               .end    = 0x64AD3800 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * KAVNET
+        *    NP Reset Vector - must be of the form xxCxxxxx
+        *         NP Image - must be video bank 1
+        *         NP IPC - must be video bank 2
+        */
+       {
+               .name   = "NP_Reset_Vector",
+               .start  = 0x27c00000,
+               .end    = 0x27c01000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "NP_Image",
+               .start  = 0x27020000,
+               .end    = 0x27060000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "NP_IPC",
+               .start  = 0x63500000,
+               .end    = 0x63580000 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       { },
+};
diff --git a/arch/mips/powertv/asic/prealloc-cronuslite.c b/arch/mips/powertv/asic/prealloc-cronuslite.c
new file mode 100644 (file)
index 0000000..23a9056
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * Memory pre-allocations for Cronus Lite boxes.
+ *
+ * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:       Ken Eppinett
+ *               David Schleef <ds@schleef.org>
+ */
+
+#include <linux/init.h>
+#include <asm/mach-powertv/asic.h>
+
+/*
+ * NON_DVR_CAPABLE CRONUSLITE RESOURCES
+ */
+struct resource non_dvr_cronuslite_resources[] __initdata =
+{
+       /*
+        *
+        * VIDEO2 / LX2
+        *
+        */
+       {
+               .name   = "ST231aImage",        /* Delta-Mu 2 image and ram */
+               .start  = 0x60000000,
+               .end    = 0x601FFFFF,           /* 2MiB */
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "ST231aMonitor",      /* 8KiB block ST231b monitor */
+               .start  = 0x60200000,
+               .end    = 0x60201FFF,
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x60202000,
+               .end    = 0x61FFFFFF, /*~29.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * Sysaudio Driver
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  DSP_Image_Buff - DSP code and data images (1MB)
+        *  ADSC_CPU_PCM_Buff - ADSC CPU PCM buffer (40KB)
+        *  ADSC_AUX_Buff - ADSC AUX buffer (16KB)
+        *  ADSC_Main_Buff - ADSC Main buffer (16KB)
+        *
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * STAVEM driver/STAPI
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  This memory area is used for allocating buffers for Video decoding
+        *  purposes.  Allocation/De-allocation within this buffer is managed
+        *  by the STAVMEM driver of the STAPI.  They could be Decimated
+        *  Picture Buffers, Intermediate Buffers, as deemed necessary for
+        *  video decoding purposes, for any video decoders on Zeus.
+        *
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x63580000,
+               .end    = 0x63B80000 - 1,  /* 6 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * DOCSIS Subsystem
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "Docsis",
+               .start  = 0x62000000,
+               .end    = 0x62700000 - 1,       /* 7 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * GHW HAL Driver
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  GraphicsHeap - PowerTV Graphics Heap
+        *
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x62700000,
+               .end    = 0x63500000 - 1,       /* 14 MB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * multi com buffer area
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x26000000,
+               .end    = 0x26020000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * DMA Ring buffer
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x000AA000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Display bins buffer for unit0
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Display Bins for unit0
+        *
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,           /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Display bins buffer
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Display Bins for unit1
+        *
+        */
+       {
+               .name   = "DisplayBins1",
+               .start  = 0x63B83000,
+               .end    = 0x63B84000 - 1,  /* 4 KB total */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * AVFS: player HAL memory
+        *
+        *
+        */
+       {
+               .name   = "AvfsDmaMem",
+               .start  = 0x63B84000,
+               .end    = 0x63E48C00 - 1,  /* 945K * 3 for playback */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * PMEM
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Persistent memory for diagnostics.
+        *
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Smartcard
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Read and write buffers for Internal/External cards
+        *
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x63B80000,
+               .end    = 0x63B82800 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * KAVNET
+        *    NP Reset Vector - must be of the form xxCxxxxx
+        *         NP Image - must be video bank 1
+        *         NP IPC - must be video bank 2
+        */
+       {
+               .name   = "NP_Reset_Vector",
+               .start  = 0x27c00000,
+               .end    = 0x27c01000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "NP_Image",
+               .start  = 0x27020000,
+               .end    = 0x27060000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "NP_IPC",
+               .start  = 0x63500000,
+               .end    = 0x63580000 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        * NAND Flash
+        */
+       {
+               .name   = "NandFlash",
+               .start  = NAND_FLASH_BASE,
+               .end    = NAND_FLASH_BASE + 0x400 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        * Add other resources here
+        */
+       { },
+};
diff --git a/arch/mips/powertv/asic/prealloc-zeus.c b/arch/mips/powertv/asic/prealloc-zeus.c
new file mode 100644 (file)
index 0000000..018d451
--- /dev/null
@@ -0,0 +1,459 @@
+/*
+ * Memory pre-allocations for Zeus boxes.
+ *
+ * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:       Ken Eppinett
+ *               David Schleef <ds@schleef.org>
+ */
+
+#include <linux/init.h>
+#include <asm/mach-powertv/asic.h>
+
+/*
+ * DVR_CAPABLE RESOURCES
+ */
+struct resource dvr_zeus_resources[] __initdata =
+{
+       /*
+        *
+        * VIDEO1 / LX1
+        *
+        */
+       {
+               .name   = "ST231aImage",        /* Delta-Mu 1 image and ram */
+               .start  = 0x20000000,
+               .end    = 0x201FFFFF,           /* 2MiB */
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "ST231aMonitor",      /* 8KiB block ST231a monitor */
+               .start  = 0x20200000,
+               .end    = 0x20201FFF,
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x20202000,
+               .end    = 0x21FFFFFF, /*~29.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * VIDEO2 / LX2
+        *
+        */
+       {
+               .name   = "ST231bImage",        /* Delta-Mu 2 image and ram */
+               .start  = 0x30000000,
+               .end    = 0x301FFFFF,           /* 2MiB */
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "ST231bMonitor",      /* 8KiB block ST231b monitor */
+               .start  = 0x30200000,
+               .end    = 0x30201FFF,
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "MediaMemory2",
+               .start  = 0x30202000,
+               .end    = 0x31FFFFFF, /*~29.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        *
+        * Sysaudio Driver
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  DSP_Image_Buff - DSP code and data images (1MB)
+        *  ADSC_CPU_PCM_Buff - ADSC CPU PCM buffer (40KB)
+        *  ADSC_AUX_Buff - ADSC AUX buffer (16KB)
+        *  ADSC_Main_Buff - ADSC Main buffer (16KB)
+        *
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * STAVEM driver/STAPI
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  This memory area is used for allocating buffers for Video decoding
+        *  purposes.  Allocation/De-allocation within this buffer is managed
+        *  by the STAVMEM driver of the STAPI.  They could be Decimated
+        *  Picture Buffers, Intermediate Buffers, as deemed necessary for
+        *  video decoding purposes, for any video decoders on Zeus.
+        *
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x00000000,
+               .end    = 0x00c00000 - 1,       /* 12 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * DOCSIS Subsystem
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "Docsis",
+               .start  = 0x40100000,
+               .end    = 0x407fffff,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * GHW HAL Driver
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  GraphicsHeap - PowerTV Graphics Heap
+        *
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x46900000,
+               .end    = 0x47700000 - 1,       /* 14 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * multi com buffer area
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x47900000,
+               .end    = 0x47920000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * DMA Ring buffer
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x00280000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Display bins buffer for unit0
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Display Bins for unit0
+        *
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,   /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Display bins buffer
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Display Bins for unit1
+        *
+        */
+       {
+               .name   = "DisplayBins1",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,   /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * ITFS
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "ITFS",
+               .start  = 0x00000000,
+               /* 815,104 bytes each for 2 ITFS partitions. */
+               .end    = 0x0018DFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * AVFS
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Docsis -
+        *
+        */
+       {
+               .name   = "AvfsDmaMem",
+               .start  = 0x00000000,
+               /* (945K * 8) = (128K * 3) 5 playbacks / 3 server */
+               .end    = 0x007c2000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "AvfsFileSys",
+               .start  = 0x00000000,
+               .end    = 0x00001000 - 1,  /* 4K */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * PMEM
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Persistent memory for diagnostics.
+        *
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * Smartcard
+        *
+        * This driver requires:
+        *
+        * Arbitrary Based Buffers:
+        *  Read and write buffers for Internal/External cards
+        *
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x00000000,
+               .end    = 0x2800 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Add other resources here
+        */
+       { },
+};
+
+/*
+ * NON_DVR_CAPABLE ZEUS RESOURCES
+ */
+struct resource non_dvr_zeus_resources[] __initdata =
+{
+       /*
+        * VIDEO1 / LX1
+        */
+       {
+               .name   = "ST231aImage",        /* Delta-Mu 1 image and ram */
+               .start  = 0x20000000,
+               .end    = 0x201FFFFF,           /* 2MiB */
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "ST231aMonitor",      /* 8KiB block ST231a monitor */
+               .start  = 0x20200000,
+               .end    = 0x20201FFF,
+               .flags  = IORESOURCE_IO,
+       },
+       {
+               .name   = "MediaMemory1",
+               .start  = 0x20202000,
+               .end    = 0x21FFFFFF, /*~29.9MiB (32MiB - (2MiB + 8KiB)) */
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        * Sysaudio Driver
+        */
+       {
+               .name   = "DSP_Image_Buff",
+               .start  = 0x00000000,
+               .end    = 0x000FFFFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_CPU_PCM_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00009FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_AUX_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       {
+               .name   = "ADSC_Main_Buff",
+               .start  = 0x00000000,
+               .end    = 0x00003FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * STAVEM driver/STAPI
+        */
+       {
+               .name   = "AVMEMPartition0",
+               .start  = 0x00000000,
+               .end    = 0x00600000 - 1,       /* 6 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * DOCSIS Subsystem
+        */
+       {
+               .name   = "Docsis",
+               .start  = 0x40100000,
+               .end    = 0x407fffff,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * GHW HAL Driver
+        */
+       {
+               .name   = "GraphicsHeap",
+               .start  = 0x46900000,
+               .end    = 0x47700000 - 1,       /* 14 MB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * multi com buffer area
+        */
+       {
+               .name   = "MulticomSHM",
+               .start  = 0x47900000,
+               .end    = 0x47920000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * DMA Ring buffer
+        */
+       {
+               .name   = "BMM_Buffer",
+               .start  = 0x00000000,
+               .end    = 0x00280000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Display bins buffer for unit0
+        */
+       {
+               .name   = "DisplayBins0",
+               .start  = 0x00000000,
+               .end    = 0x00000FFF,           /* 4 KB total */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        *
+        * AVFS: player HAL memory
+        *
+        *
+        */
+       {
+               .name   = "AvfsDmaMem",
+               .start  = 0x00000000,
+               .end    = 0x002c4c00 - 1,       /* 945K * 3 for playback */
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * PMEM
+        */
+       {
+               .name   = "DiagPersistentMemory",
+               .start  = 0x00000000,
+               .end    = 0x10000 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * Smartcard
+        */
+       {
+               .name   = "SmartCardInfo",
+               .start  = 0x00000000,
+               .end    = 0x2800 - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       /*
+        * NAND Flash
+        */
+       {
+               .name   = "NandFlash",
+               .start  = NAND_FLASH_BASE,
+               .end    = NAND_FLASH_BASE + 0x400 - 1,
+               .flags  = IORESOURCE_IO,
+       },
+       /*
+        * Add other resources here
+        */
+       { },
+};
diff --git a/arch/mips/powertv/cmdline.c b/arch/mips/powertv/cmdline.c
new file mode 100644 (file)
index 0000000..98d73cb
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
+ * Portions copyright (C) 2009 Cisco Systems, Inc.
+ *
+ * This program is free software; you can distribute it and/or modify it
+ * under the terms of the GNU General Public License (Version 2) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Kernel command line creation using the prom monitor (YAMON) argc/argv.
+ */
+#include <linux/init.h>
+#include <linux/string.h>
+
+#include <asm/bootinfo.h>
+
+#include "init.h"
+
+/*
+ * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer.
+ * This macro take care of sign extension.
+ */
+#define prom_argv(index) ((char *)(long)_prom_argv[(index)])
+
+char * __init prom_getcmdline(void)
+{
+       return &(arcs_cmdline[0]);
+}
+
+void  __init prom_init_cmdline(void)
+{
+       int len;
+
+       if (prom_argc != 1)
+               return;
+
+       len = strlen(arcs_cmdline);
+
+       arcs_cmdline[len] = ' ';
+
+       strlcpy(arcs_cmdline + len + 1, (char *)_prom_argv,
+               COMMAND_LINE_SIZE - len - 1);
+}
diff --git a/arch/mips/powertv/init.c b/arch/mips/powertv/init.c
new file mode 100644 (file)
index 0000000..5f4e4c3
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 1999, 2000, 2004, 2005  MIPS Technologies, Inc.
+ *     All rights reserved.
+ *     Authors: Carsten Langgaard <carstenl@mips.com>
+ *              Maciej W. Rozycki <macro@mips.com>
+ * Portions copyright (C) 2009 Cisco Systems, Inc.
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * PROM library initialisation code.
+ */
+#include <linux/init.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+
+#include <asm/bootinfo.h>
+#include <linux/io.h>
+#include <asm/system.h>
+#include <asm/cacheflush.h>
+#include <asm/traps.h>
+
+#include <asm/mips-boards/prom.h>
+#include <asm/mips-boards/generic.h>
+#include <asm/mach-powertv/asic.h>
+
+#include "init.h"
+
+int prom_argc;
+int *_prom_argv, *_prom_envp;
+unsigned long _prom_memsize;
+
+/*
+ * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer.
+ * This macro take care of sign extension, if running in 64-bit mode.
+ */
+#define prom_envp(index) ((char *)(long)_prom_envp[(index)])
+
+char *prom_getenv(char *envname)
+{
+       char *result = NULL;
+
+       if (_prom_envp != NULL) {
+               /*
+                * Return a pointer to the given environment variable.
+                * In 64-bit mode: we're using 64-bit pointers, but all pointers
+                * in the PROM structures are only 32-bit, so we need some
+                * workarounds, if we are running in 64-bit mode.
+                */
+               int i, index = 0;
+
+               i = strlen(envname);
+
+               while (prom_envp(index)) {
+                       if (strncmp(envname, prom_envp(index), i) == 0) {
+                               result = prom_envp(index + 1);
+                               break;
+                       }
+                       index += 2;
+               }
+       }
+
+       return result;
+}
+
+/* TODO: Verify on linux-mips mailing list that the following two  */
+/* functions are correct                                           */
+/* TODO: Copy NMI and EJTAG exception vectors to memory from the   */
+/* BootROM exception vectors. Flush their cache entries. test it.  */
+
+static void __init mips_nmi_setup(void)
+{
+       void *base;
+#if defined(CONFIG_CPU_MIPS32_R1)
+       base = cpu_has_veic ?
+               (void *)(CAC_BASE + 0xa80) :
+               (void *)(CAC_BASE + 0x380);
+#elif defined(CONFIG_CPU_MIPS32_R2)
+       base = (void *)0xbfc00000;
+#else
+#error NMI exception handler address not defined
+#endif
+}
+
+static void __init mips_ejtag_setup(void)
+{
+       void *base;
+
+#if defined(CONFIG_CPU_MIPS32_R1)
+       base = cpu_has_veic ?
+               (void *)(CAC_BASE + 0xa00) :
+               (void *)(CAC_BASE + 0x300);
+#elif defined(CONFIG_CPU_MIPS32_R2)
+       base = (void *)0xbfc00480;
+#else
+#error EJTAG exception handler address not defined
+#endif
+}
+
+void __init prom_init(void)
+{
+       prom_argc = fw_arg0;
+       _prom_argv = (int *) fw_arg1;
+       _prom_envp = (int *) fw_arg2;
+       _prom_memsize = (unsigned long) fw_arg3;
+
+       board_nmi_handler_setup = mips_nmi_setup;
+       board_ejtag_handler_setup = mips_ejtag_setup;
+
+       pr_info("\nLINUX started...\n");
+       prom_init_cmdline();
+       configure_platform();
+       prom_meminit();
+
+#ifndef CONFIG_BOOTLOADER_DRIVER
+       pr_info("\nBootloader driver isn't loaded...\n");
+#endif
+}
diff --git a/arch/mips/powertv/init.h b/arch/mips/powertv/init.h
new file mode 100644 (file)
index 0000000..7af6bf2
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Definitions from powertv init.c file
+ *
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: David VomLehn
+ */
+
+#ifndef _POWERTV_INIT_H
+#define _POWERTV_INIT_H
+extern int prom_argc;
+extern int *_prom_argv;
+extern unsigned long _prom_memsize;
+#endif
diff --git a/arch/mips/powertv/memory.c b/arch/mips/powertv/memory.c
new file mode 100644 (file)
index 0000000..28d0660
--- /dev/null
@@ -0,0 +1,186 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
+ * Portions copyright (C) 2009 Cisco Systems, Inc.
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ * Apparently originally from arch/mips/malta-memory.c. Modified to work
+ * with the PowerTV bootloader.
+ */
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/bootmem.h>
+#include <linux/pfn.h>
+#include <linux/string.h>
+
+#include <asm/bootinfo.h>
+#include <asm/page.h>
+#include <asm/sections.h>
+
+#include <asm/mips-boards/prom.h>
+
+#include "init.h"
+
+/* Memory constants */
+#define KIBIBYTE(n)            ((n) * 1024)    /* Number of kibibytes */
+#define MEBIBYTE(n)            ((n) * KIBIBYTE(1024)) /* Number of mebibytes */
+#define DEFAULT_MEMSIZE                MEBIBYTE(256)   /* If no memsize provided */
+#define LOW_MEM_MAX            MEBIBYTE(252)   /* Max usable low mem */
+#define RES_BOOTLDR_MEMSIZE    MEBIBYTE(1)     /* Memory reserved for bldr */
+#define BOOT_MEM_SIZE          KIBIBYTE(256)   /* Memory reserved for bldr */
+#define PHYS_MEM_START         0x10000000      /* Start of physical memory */
+
+unsigned long ptv_memsize;
+
+char __initdata cmdline[COMMAND_LINE_SIZE];
+
+void __init prom_meminit(void)
+{
+       char *memsize_str;
+       unsigned long memsize = 0;
+       unsigned int physend;
+       char *ptr;
+       int low_mem;
+       int high_mem;
+
+       /* Check the command line first for a memsize directive */
+       strcpy(cmdline, arcs_cmdline);
+       ptr = strstr(cmdline, "memsize=");
+       if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' '))
+               ptr = strstr(ptr, " memsize=");
+
+       if (ptr) {
+               memsize = memparse(ptr + 8, &ptr);
+       } else {
+               /* otherwise look in the environment */
+               memsize_str = prom_getenv("memsize");
+
+               if (memsize_str != NULL) {
+                       pr_info("prom memsize = %s\n", memsize_str);
+                       memsize = simple_strtol(memsize_str, NULL, 0);
+               }
+
+               if (memsize == 0) {
+                       if (_prom_memsize != 0) {
+                               memsize = _prom_memsize;
+                               pr_info("_prom_memsize = 0x%lx\n", memsize);
+                               /* add in memory that the bootloader doesn't
+                                * report */
+                               memsize += BOOT_MEM_SIZE;
+                       } else {
+                               memsize = DEFAULT_MEMSIZE;
+                               pr_info("Memsize not passed by bootloader, "
+                                       "defaulting to 0x%lx\n", memsize);
+                       }
+               }
+       }
+
+       /* Store memsize for diagnostic purposes */
+       ptv_memsize = memsize;
+
+       physend = PFN_ALIGN(&_end) - 0x80000000;
+       if (memsize > LOW_MEM_MAX) {
+               low_mem = LOW_MEM_MAX;
+               high_mem = memsize - low_mem;
+       } else {
+               low_mem = memsize;
+               high_mem = 0;
+       }
+
+/*
+ * TODO: We will use the hard code for memory configuration until
+ * the bootloader releases their device tree to us.
+ */
+       /*
+        * Add the memory reserved for use by the bootloader to the
+        * memory map.
+        */
+       add_memory_region(PHYS_MEM_START, RES_BOOTLDR_MEMSIZE,
+               BOOT_MEM_RESERVED);
+#ifdef CONFIG_HIGHMEM_256_128
+       /*
+        * Add memory in low for general use by the kernel and its friends
+        * (like drivers, applications, etc).
+        */
+       add_memory_region(PHYS_MEM_START + RES_BOOTLDR_MEMSIZE,
+               LOW_MEM_MAX - RES_BOOTLDR_MEMSIZE, BOOT_MEM_RAM);
+       /*
+        * Add the memory reserved for reset vector.
+        */
+       add_memory_region(0x1fc00000, MEBIBYTE(4), BOOT_MEM_RESERVED);
+       /*
+        * Add the memory reserved.
+        */
+       add_memory_region(0x20000000, MEBIBYTE(1024 + 75), BOOT_MEM_RESERVED);
+       /*
+        * Add memory in high for general use by the kernel and its friends
+        * (like drivers, applications, etc).
+        *
+        * 75MB is reserved for devices which are using the memory in high.
+        */
+       add_memory_region(0x60000000 + MEBIBYTE(75), MEBIBYTE(128 - 75),
+               BOOT_MEM_RAM);
+#elif defined CONFIG_HIGHMEM_128_128
+       /*
+        * Add memory in low for general use by the kernel and its friends
+        * (like drivers, applications, etc).
+        */
+       add_memory_region(PHYS_MEM_START + RES_BOOTLDR_MEMSIZE,
+               MEBIBYTE(128) - RES_BOOTLDR_MEMSIZE, BOOT_MEM_RAM);
+       /*
+        * Add the memory reserved.
+        */
+       add_memory_region(PHYS_MEM_START + MEBIBYTE(128),
+               MEBIBYTE(128 + 1024 + 75), BOOT_MEM_RESERVED);
+       /*
+        * Add memory in high for general use by the kernel and its friends
+        * (like drivers, applications, etc).
+        *
+        * 75MB is reserved for devices which are using the memory in high.
+        */
+       add_memory_region(0x60000000 + MEBIBYTE(75), MEBIBYTE(128 - 75),
+               BOOT_MEM_RAM);
+#else
+       /* Add low memory regions for either:
+        *   - no-highmemory configuration case -OR-
+        *   - highmemory "HIGHMEM_LOWBANK_ONLY" case
+        */
+       /*
+        * Add memory for general use by the kernel and its friends
+        * (like drivers, applications, etc).
+        */
+       add_memory_region(PHYS_MEM_START + RES_BOOTLDR_MEMSIZE,
+               low_mem - RES_BOOTLDR_MEMSIZE, BOOT_MEM_RAM);
+       /*
+        * Add the memory reserved for reset vector.
+        */
+       add_memory_region(0x1fc00000, MEBIBYTE(4), BOOT_MEM_RESERVED);
+#endif
+}
+
+void __init prom_free_prom_memory(void)
+{
+       unsigned long addr;
+       int i;
+
+       for (i = 0; i < boot_mem_map.nr_map; i++) {
+               if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA)
+                       continue;
+
+               addr = boot_mem_map.map[i].addr;
+               free_init_pages("prom memory",
+                               addr, addr + boot_mem_map.map[i].size);
+       }
+}
diff --git a/arch/mips/powertv/pci/Makefile b/arch/mips/powertv/pci/Makefile
new file mode 100644 (file)
index 0000000..f5c6246
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2009  Scientific-Atlanta, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+obj-$(CONFIG_PCI)      += fixup-powertv.o
+
+EXTRA_CFLAGS += -Wall -Werror
diff --git a/arch/mips/powertv/pci/fixup-powertv.c b/arch/mips/powertv/pci/fixup-powertv.c
new file mode 100644 (file)
index 0000000..726bc2e
--- /dev/null
@@ -0,0 +1,36 @@
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <asm/mach-powertv/interrupts.h>
+#include "powertv-pci.h"
+
+int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+{
+       return asic_pcie_map_irq(dev, slot, pin);
+}
+
+/* Do platform specific device initialization at pci_enable_device() time */
+int pcibios_plat_dev_init(struct pci_dev *dev)
+{
+       return 0;
+}
+
+/*
+ * asic_pcie_map_irq
+ *
+ * Parameters:
+ * *dev - pointer to a pci_dev structure  (not used)
+ * slot - slot number  (not used)
+ * pin - pin number  (not used)
+ *
+ * Return Value:
+ * Returns: IRQ number (always the PCI Express IRQ number)
+ *
+ * Description:
+ * asic_pcie_map_irq will return the IRQ number of the PCI Express interrupt.
+ *
+ */
+int asic_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+{
+       return irq_pciexp;
+}
+EXPORT_SYMBOL(asic_pcie_map_irq);
diff --git a/arch/mips/powertv/pci/powertv-pci.h b/arch/mips/powertv/pci/powertv-pci.h
new file mode 100644 (file)
index 0000000..1b5886b
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *                             powertv-pci.c
+ *
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+/*
+ * Local definitions for the powertv PCI code
+ */
+
+#ifndef _POWERTV_PCI_POWERTV_PCI_H_
+#define _POWERTV_PCI_POWERTV_PCI_H_
+extern int asic_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
+extern int asic_pcie_init(void);
+extern int asic_pcie_init(void);
+
+extern int log_level;
+#endif
diff --git a/arch/mips/powertv/powertv-clock.h b/arch/mips/powertv/powertv-clock.h
new file mode 100644 (file)
index 0000000..d94c543
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: David VomLehn
+ */
+
+#ifndef _POWERTV_POWERTV_CLOCK_H
+#define _POWERTV_POWERTV_CLOCK_H
+extern int powertv_clockevent_init(void);
+extern void powertv_clocksource_init(void);
+extern unsigned int mips_get_pll_freq(void);
+#endif
diff --git a/arch/mips/powertv/powertv_setup.c b/arch/mips/powertv/powertv_setup.c
new file mode 100644 (file)
index 0000000..bd8ebf1
--- /dev/null
@@ -0,0 +1,351 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
+ * Portions copyright (C) 2009 Cisco Systems, Inc.
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+#include <linux/pci.h>
+#include <linux/screen_info.h>
+#include <linux/notifier.h>
+#include <linux/etherdevice.h>
+#include <linux/if_ether.h>
+#include <linux/ctype.h>
+
+#include <linux/cpu.h>
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/mips-boards/generic.h>
+#include <asm/mips-boards/prom.h>
+#include <asm/dma.h>
+#include <linux/time.h>
+#include <asm/traps.h>
+#include <asm/asm-offsets.h>
+#include "reset.h"
+
+#define VAL(n)         STR(n)
+
+/*
+ * Macros for loading addresses and storing registers:
+ * PTR_LA      Load the address into a register
+ * LONG_S      Store the full width of the given register.
+ * LONG_L      Load the full width of the given register
+ * PTR_ADDIU   Add a constant value to a register used as a pointer
+ * REG_SIZE    Number of 8-bit bytes in a full width register
+ */
+#ifdef CONFIG_64BIT
+#warning TODO: 64-bit code needs to be verified
+#define PTR_LA         "dla    "
+#define LONG_S         "sd     "
+#define LONG_L         "ld     "
+#define PTR_ADDIU      "daddiu "
+#define REG_SIZE       "8"             /* In bytes */
+#endif
+
+#ifdef CONFIG_32BIT
+#define PTR_LA         "la     "
+#define LONG_S         "sw     "
+#define LONG_L         "lw     "
+#define PTR_ADDIU      "addiu  "
+#define REG_SIZE       "4"             /* In bytes */
+#endif
+
+static struct pt_regs die_regs;
+static bool have_die_regs;
+
+static void register_panic_notifier(void);
+static int panic_handler(struct notifier_block *notifier_block,
+       unsigned long event, void *cause_string);
+
+const char *get_system_type(void)
+{
+       return "PowerTV";
+}
+
+void __init plat_mem_setup(void)
+{
+       panic_on_oops = 1;
+       register_panic_notifier();
+
+#if 0
+       mips_pcibios_init();
+#endif
+       mips_reboot_setup();
+}
+
+/*
+ * Install a panic notifier for platform-specific diagnostics
+ */
+static void register_panic_notifier()
+{
+       static struct notifier_block panic_notifier = {
+               .notifier_call = panic_handler,
+               .next = NULL,
+               .priority       = INT_MAX
+       };
+       atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier);
+}
+
+static int panic_handler(struct notifier_block *notifier_block,
+       unsigned long event, void *cause_string)
+{
+       struct pt_regs  my_regs;
+
+       /* Save all of the registers */
+       {
+               unsigned long   at, v0, v1; /* Must be on the stack */
+
+               /* Start by saving $at and v0 on the stack. We use $at
+                * ourselves, but it looks like the compiler may use v0 or v1
+                * to load the address of the pt_regs structure. We'll come
+                * back later to store the registers in the pt_regs
+                * structure. */
+               __asm__ __volatile__ (
+                       ".set   noat\n"
+                       LONG_S          "$at, %[at]\n"
+                       LONG_S          "$2, %[v0]\n"
+                       LONG_S          "$3, %[v1]\n"
+               :
+                       [at] "=m" (at),
+                       [v0] "=m" (v0),
+                       [v1] "=m" (v1)
+               :
+               :       "at"
+               );
+
+               __asm__ __volatile__ (
+                       ".set   noat\n"
+                       "move           $at, %[pt_regs]\n"
+
+                       /* Argument registers */
+                       LONG_S          "$4, " VAL(PT_R4) "($at)\n"
+                       LONG_S          "$5, " VAL(PT_R5) "($at)\n"
+                       LONG_S          "$6, " VAL(PT_R6) "($at)\n"
+                       LONG_S          "$7, " VAL(PT_R7) "($at)\n"
+
+                       /* Temporary regs */
+                       LONG_S          "$8, " VAL(PT_R8) "($at)\n"
+                       LONG_S          "$9, " VAL(PT_R9) "($at)\n"
+                       LONG_S          "$10, " VAL(PT_R10) "($at)\n"
+                       LONG_S          "$11, " VAL(PT_R11) "($at)\n"
+                       LONG_S          "$12, " VAL(PT_R12) "($at)\n"
+                       LONG_S          "$13, " VAL(PT_R13) "($at)\n"
+                       LONG_S          "$14, " VAL(PT_R14) "($at)\n"
+                       LONG_S          "$15, " VAL(PT_R15) "($at)\n"
+
+                       /* "Saved" registers */
+                       LONG_S          "$16, " VAL(PT_R16) "($at)\n"
+                       LONG_S          "$17, " VAL(PT_R17) "($at)\n"
+                       LONG_S          "$18, " VAL(PT_R18) "($at)\n"
+                       LONG_S          "$19, " VAL(PT_R19) "($at)\n"
+                       LONG_S          "$20, " VAL(PT_R20) "($at)\n"
+                       LONG_S          "$21, " VAL(PT_R21) "($at)\n"
+                       LONG_S          "$22, " VAL(PT_R22) "($at)\n"
+                       LONG_S          "$23, " VAL(PT_R23) "($at)\n"
+
+                       /* Add'l temp regs */
+                       LONG_S          "$24, " VAL(PT_R24) "($at)\n"
+                       LONG_S          "$25, " VAL(PT_R25) "($at)\n"
+
+                       /* Kernel temp regs */
+                       LONG_S          "$26, " VAL(PT_R26) "($at)\n"
+                       LONG_S          "$27, " VAL(PT_R27) "($at)\n"
+
+                       /* Global pointer, stack pointer, frame pointer and
+                        * return address */
+                       LONG_S          "$gp, " VAL(PT_R28) "($at)\n"
+                       LONG_S          "$sp, " VAL(PT_R29) "($at)\n"
+                       LONG_S          "$fp, " VAL(PT_R30) "($at)\n"
+                       LONG_S          "$ra, " VAL(PT_R31) "($at)\n"
+
+                       /* Now we can get the $at and v0 registers back and
+                        * store them */
+                       LONG_L          "$8, %[at]\n"
+                       LONG_S          "$8, " VAL(PT_R1) "($at)\n"
+                       LONG_L          "$8, %[v0]\n"
+                       LONG_S          "$8, " VAL(PT_R2) "($at)\n"
+                       LONG_L          "$8, %[v1]\n"
+                       LONG_S          "$8, " VAL(PT_R3) "($at)\n"
+               :
+               :
+                       [at] "m" (at),
+                       [v0] "m" (v0),
+                       [v1] "m" (v1),
+                       [pt_regs] "r" (&my_regs)
+               :       "at", "t0"
+               );
+
+               /* Set the current EPC value to be the current location in this
+                * function */
+               __asm__ __volatile__ (
+                       ".set   noat\n"
+               "1:\n"
+                       PTR_LA          "$at, 1b\n"
+                       LONG_S          "$at, %[cp0_epc]\n"
+               :
+                       [cp0_epc] "=m" (my_regs.cp0_epc)
+               :
+               :       "at"
+               );
+
+               my_regs.cp0_cause = read_c0_cause();
+               my_regs.cp0_status = read_c0_status();
+       }
+
+#ifdef CONFIG_DIAGNOSTICS
+       failure_report((char *) cause_string,
+               have_die_regs ? &die_regs : &my_regs);
+       have_die_regs = false;
+#else
+       pr_crit("I'm feeling a bit sleepy. hmmmmm... perhaps a nap would... "
+               "zzzz... \n");
+#endif
+
+       return NOTIFY_DONE;
+}
+
+/**
+ * Platform-specific handling of oops
+ * @str:       Pointer to the oops string
+ * @regs:      Pointer to the oops registers
+ * All we do here is to save the registers for subsequent printing through
+ * the panic notifier.
+ */
+void platform_die(const char *str, const struct pt_regs *regs)
+{
+       /* If we already have saved registers, don't overwrite them as they
+        * they apply to the initial fault */
+
+       if (!have_die_regs) {
+               have_die_regs = true;
+               die_regs = *regs;
+       }
+}
+
+/* Information about the RF MAC address, if one was supplied on the
+ * command line. */
+static bool have_rfmac;
+static u8 rfmac[ETH_ALEN];
+
+static int rfmac_param(char *p)
+{
+       u8      *q;
+       bool    is_high_nibble;
+       int     c;
+
+       /* Skip a leading "0x", if present */
+       if (*p == '0' && *(p+1) == 'x')
+               p += 2;
+
+       q = rfmac;
+       is_high_nibble = true;
+
+       for (c = (unsigned char) *p++;
+               isxdigit(c) && q - rfmac < ETH_ALEN;
+               c = (unsigned char) *p++) {
+               int     nibble;
+
+               nibble = (isdigit(c) ? (c - '0') :
+                       (isupper(c) ? c - 'A' + 10 : c - 'a' + 10));
+
+               if (is_high_nibble)
+                       *q = nibble << 4;
+               else
+                       *q++ |= nibble;
+
+               is_high_nibble = !is_high_nibble;
+       }
+
+       /* If we parsed all the way to the end of the parameter value and
+        * parsed all ETH_ALEN bytes, we have a usable RF MAC address */
+       have_rfmac = (c == '\0' && q - rfmac == ETH_ALEN);
+
+       return 0;
+}
+
+early_param("rfmac", rfmac_param);
+
+/*
+ * Generate an Ethernet MAC address that has a good chance of being unique.
+ * @addr:      Pointer to six-byte array containing the Ethernet address
+ * Generates an Ethernet MAC address that is highly likely to be unique for
+ * this particular system on a network with other systems of the same type.
+ *
+ * The problem we are solving is that, when random_ether_addr() is used to
+ * generate MAC addresses at startup, there isn't much entropy for the random
+ * number generator to use and the addresses it produces are fairly likely to
+ * be the same as those of other identical systems on the same local network.
+ * This is true even for relatively small numbers of systems (for the reason
+ * why, see the Wikipedia entry for "Birthday problem" at:
+ *     http://en.wikipedia.org/wiki/Birthday_problem
+ *
+ * The good news is that we already have a MAC address known to be unique, the
+ * RF MAC address. The bad news is that this address is already in use on the
+ * RF interface. Worse, the obvious trick, taking the RF MAC address and
+ * turning on the locally managed bit, has already been used for other devices.
+ * Still, this does give us something to work with.
+ *
+ * The approach we take is:
+ * 1.  If we can't get the RF MAC Address, just call random_ether_addr.
+ * 2.  Use the 24-bit NIC-specific bits of the RF MAC address as the last 24
+ *     bits of the new address. This is very likely to be unique, except for
+ *     the current box.
+ * 3.  To avoid using addresses already on the current box, we set the top
+ *     six bits of the address with a value different from any currently
+ *     registered Scientific Atlanta organizationally unique identifyer
+ *     (OUI). This avoids duplication with any addresses on the system that
+ *     were generated from valid Scientific Atlanta-registered address by
+ *     simply flipping the locally managed bit.
+ * 4.  We aren't generating a multicast address, so we leave the multicast
+ *     bit off. Since we aren't using a registered address, we have to set
+ *     the locally managed bit.
+ * 5.  We then randomly generate the remaining 16-bits. This does two
+ *     things:
+ *     a.      It allows us to call this function for more than one device
+ *             in this system
+ *     b.      It ensures that things will probably still work even if
+ *             some device on the device network has a locally managed
+ *             address that matches the top six bits from step 2.
+ */
+void platform_random_ether_addr(u8 addr[ETH_ALEN])
+{
+       const int num_random_bytes = 2;
+       const unsigned char non_sciatl_oui_bits = 0xc0u;
+       const unsigned char mac_addr_locally_managed = (1 << 1);
+
+       if (!have_rfmac) {
+               pr_warning("rfmac not available on command line; "
+                       "generating random MAC address\n");
+               random_ether_addr(addr);
+       }
+
+       else {
+               int     i;
+
+               /* Set the first byte to something that won't match a Scientific
+                * Atlanta OUI, is locally managed, and isn't a multicast
+                * address */
+               addr[0] = non_sciatl_oui_bits | mac_addr_locally_managed;
+
+               /* Get some bytes of random address information */
+               get_random_bytes(&addr[1], num_random_bytes);
+
+               /* Copy over the NIC-specific bits of the RF MAC address */
+               for (i = 1 + num_random_bytes; i < ETH_ALEN; i++)
+                       addr[i] = rfmac[i];
+       }
+}
diff --git a/arch/mips/powertv/reset.c b/arch/mips/powertv/reset.c
new file mode 100644 (file)
index 0000000..494c652
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
+ * Portions copyright (C) 2009 Cisco Systems, Inc.
+ *
+ *  This program is free software; you can distribute it and/or modify it
+ *  under the terms of the GNU General Public License (Version 2) as
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ *  for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+#include <linux/pm.h>
+
+#include <linux/io.h>
+#include <asm/reboot.h>                        /* Not included by linux/reboot.h */
+
+#ifdef CONFIG_BOOTLOADER_DRIVER
+#include <asm/mach-powertv/kbldr.h>
+#endif
+
+#include <asm/mach-powertv/asic_regs.h>
+#include "reset.h"
+
+static void mips_machine_restart(char *command);
+static void mips_machine_halt(void);
+
+static void mips_machine_restart(char *command)
+{
+#ifdef CONFIG_BOOTLOADER_DRIVER
+       /*
+        * Call the bootloader's reset function to ensure
+        * that persistent data is flushed before hard reset
+        */
+       kbldr_SetCauseAndReset();
+#else
+       writel(0x1, asic_reg_addr(watchdog));
+#endif
+}
+
+static void mips_machine_halt(void)
+{
+#ifdef CONFIG_BOOTLOADER_DRIVER
+       /*
+        * Call the bootloader's reset function to ensure
+        * that persistent data is flushed before hard reset
+        */
+       kbldr_SetCauseAndReset();
+#else
+       writel(0x1, asic_reg_addr(watchdog));
+#endif
+}
+
+void mips_reboot_setup(void)
+{
+       _machine_restart = mips_machine_restart;
+       _machine_halt = mips_machine_halt;
+       pm_power_off = mips_machine_halt;
+}
diff --git a/arch/mips/powertv/reset.h b/arch/mips/powertv/reset.h
new file mode 100644 (file)
index 0000000..888fd09
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Definitions from powertv reset.c file
+ *
+ * Copyright (C) 2009  Cisco Systems, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: David VomLehn
+ */
+
+#ifndef _POWERTV_POWERTV_RESET_H
+#define _POWERTV_POWERTV_RESET_H
+extern void mips_reboot_setup(void);
+#endif
similarity index 60%
rename from arch/mips/mipssim/sim_cmdline.c
rename to arch/mips/powertv/time.c
index 74240e1ce5a5090155a78cbf4483f13a8cff0b5f..1e0a5ef4c8c7cbfd024710a929a9716a52502bc5 100644 (file)
@@ -1,5 +1,7 @@
 /*
- * Copyright (C) 2005 MIPS Technologies, Inc.  All rights reserved.
+ * Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
+ * Portions copyright (C) 2009 Cisco Systems, Inc.
  *
  *  This program is free software; you can distribute it and/or modify it
  *  under the terms of the GNU General Public License (Version 2) as
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  *
+ * Setting up the clock on the MIPS boards.
  */
+
 #include <linux/init.h>
-#include <linux/string.h>
-#include <asm/bootinfo.h>
+#include <asm/mach-powertv/interrupts.h>
+#include <asm/time.h>
 
-extern char arcs_cmdline[];
+#include "powertv-clock.h"
 
-char * __init prom_getcmdline(void)
+unsigned int __cpuinit get_c0_compare_int(void)
 {
-       return arcs_cmdline;
+       return irq_mips_timer;
 }
 
-void  __init prom_init_cmdline(void)
+void __init plat_time_init(void)
 {
-       /* XXX: Get boot line from environment? */
+       powertv_clocksource_init();
+       r4k_clockevent_init();
 }
index ad5bd10979740673806c5e8b4620dcd6310e039d..d7c26d00cfefe3fdca84fda3fe61bddacc7e799c 100644 (file)
@@ -69,7 +69,7 @@ static inline unsigned long tag2ul(char *arg, const char *tag)
 
 void __init prom_setup_cmdline(void)
 {
-       static char cmd_line[CL_SIZE] __initdata;
+       static char cmd_line[COMMAND_LINE_SIZE] __initdata;
        char *cp, *board;
        int prom_argc;
        char **prom_argv, **prom_envp;
@@ -115,7 +115,7 @@ void __init prom_setup_cmdline(void)
                strcpy(cp, arcs_cmdline);
                cp += strlen(arcs_cmdline);
        }
-       cmd_line[CL_SIZE-1] = '\0';
+       cmd_line[COMMAND_LINE_SIZE - 1] = '\0';
 
        strcpy(arcs_cmdline, cmd_line);
 }
index 1617241d2737e79acbf4fe3684797cb751c83b02..da44ccb208299ab73e6774601c2a183e011dc4fa 100644 (file)
@@ -50,9 +50,9 @@
 
 static char __init *decode_eisa_sig(unsigned long addr)
 {
-        static char sig_str[EISA_SIG_LEN];
+       static char sig_str[EISA_SIG_LEN] __initdata;
        u8 sig[4];
-        u16 rev;
+       u16 rev;
        int i;
 
        for (i = 0; i < 4; i++) {
index 0ecd5fe9486ee183e750c014f6d2cfb3283bff9a..383f11d7f4424f99f31b20e9093283e939f390be 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
 #include <linux/interrupt.h>
+#include <linux/ftrace.h>
 
 #include <asm/irq_cpu.h>
 #include <asm/sgi/hpc3.h>
@@ -150,7 +151,7 @@ static void indy_local1_irqdispatch(void)
 
 extern void ip22_be_interrupt(int irq);
 
-static void indy_buserror_irq(void)
+static void __irq_entry indy_buserror_irq(void)
 {
        int irq = SGI_BUSERR_IRQ;
 
index b9a931358e2391801aa0e2704ecbb8f83b991be4..5deeb68b6c9cb0f3a367cfaa1049b966d70b1010 100644 (file)
@@ -67,7 +67,7 @@ void __init plat_mem_setup(void)
        cserial = ArcGetEnvironmentVariable("ConsoleOut");
 
        if ((ctype && *ctype == 'd') || (cserial && *cserial == 's')) {
-               static char options[8];
+               static char options[8] __initdata;
                char *baud = ArcGetEnvironmentVariable("dbaud");
                if (baud)
                        strcpy(options, baud);
index c8f7d2328b2425daf81a06cd07670be594e7affa..603fc91c1030539b8bc33ad88902b240ea84a203 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 #include <linux/time.h>
+#include <linux/ftrace.h>
 
 #include <asm/cpu.h>
 #include <asm/mipsregs.h>
@@ -115,7 +116,7 @@ __init void plat_time_init(void)
 }
 
 /* Generic SGI handler for (spurious) 8254 interrupts */
-void indy_8254timer_irq(void)
+void __irq_entry indy_8254timer_irq(void)
 {
        int irq = SGI_8254_0_IRQ;
        ULONG cnt;
index c5a5d4a31b4b42f1c7d3c9a2f45cbbe88e16bf01..3abd1465ec024bdb298cfc4be3cdf075e02d2a64 100644 (file)
@@ -90,7 +90,7 @@ void __init plat_mem_setup(void)
        {
                char* con = ArcGetEnvironmentVariable("console");
                if (con && *con == 'd') {
-                       static char options[8];
+                       static char options[8] __initdata;
                        char *baud = ArcGetEnvironmentVariable("dbaud");
                        if (baud)
                                strcpy(options, baud);
index eb5396cf81bb1b725c79ec2360c890dca8214cac..6343011e9902d05060851fa2b6dfa6b4a0a66766 100644 (file)
@@ -287,7 +287,7 @@ void __init prom_init(void)
         * boot console
         */
        cfe_cons_handle = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE);
-       if (cfe_getenv("LINUX_CMDLINE", arcs_cmdline, CL_SIZE) < 0) {
+       if (cfe_getenv("LINUX_CMDLINE", arcs_cmdline, COMMAND_LINE_SIZE) < 0) {
                if (argc >= 0) {
                        /* The loader should have set the command line */
                        /* too early for panic to do any good */
@@ -318,7 +318,7 @@ void __init prom_init(void)
 #endif /* CONFIG_BLK_DEV_INITRD */
 
        /* Not sure this is needed, but it's the safe way. */
-       arcs_cmdline[CL_SIZE-1] = 0;
+       arcs_cmdline[COMMAND_LINE_SIZE-1] = 0;
 
        prom_meminit();
 
index 7dd76fb3b64500b67e1554c7c229b010cce6391d..e6980892834aae7a00865172e2303c67732bc86b 100644 (file)
@@ -188,7 +188,7 @@ static void end_a20r_irq(unsigned int irq)
 }
 
 static struct irq_chip a20r_irq_type = {
-       .typename       = "A20R",
+       .name           = "A20R",
        .ack            = mask_a20r_irq,
        .mask           = mask_a20r_irq,
        .mask_ack       = mask_a20r_irq,
index 74e6c67982fb693134c023866aa80328826dbf73..51e62bbaa23bb2440fa671fc22fe57930690aea6 100644 (file)
@@ -214,7 +214,7 @@ static void end_pcimt_irq(unsigned int irq)
 }
 
 static struct irq_chip pcimt_irq_type = {
-       .typename = "PCIMT",
+       .name = "PCIMT",
        .ack = disable_pcimt_irq,
        .mask = disable_pcimt_irq,
        .mask_ack = disable_pcimt_irq,
index 071a9573ac7f65345d4d6b23589b3851d5f511a8..f4699d35858b70820f638d053dac36be73f4da5c 100644 (file)
@@ -176,7 +176,7 @@ void end_pcit_irq(unsigned int irq)
 }
 
 static struct irq_chip pcit_irq_type = {
-       .typename = "PCIT",
+       .name = "PCIT",
        .ack = disable_pcit_irq,
        .mask = disable_pcit_irq,
        .mask_ack = disable_pcit_irq,
index 5e687819cbc2aec4aec85dbada30184a345a6551..46f00691f448865888991202e529ee9334bf9044 100644 (file)
@@ -449,7 +449,7 @@ void end_rm200_irq(unsigned int irq)
 }
 
 static struct irq_chip rm200_irq_type = {
-       .typename = "RM200",
+       .name = "RM200",
        .ack = disable_rm200_irq,
        .mask = disable_rm200_irq,
        .mask_ack = disable_rm200_irq,
index a49272ce7ef510e2f61a4a3f4f1f312186da4164..d16b462154c33834f996bc0e89726ae97a83b089 100644 (file)
@@ -60,7 +60,7 @@ static void __init sni_console_setup(void)
        char *cdev;
        char *baud;
        int port;
-       static char options[8];
+       static char options[8] __initdata;
 
        cdev = prom_getenv("console_dev");
        if (strncmp(cdev, "tty", 3) == 0) {
index d66802edebb2f7ea85d5004ac2791905a93ad57c..06e801c7e258d37f507fb70433cb9767ce2d8d88 100644 (file)
@@ -160,7 +160,7 @@ static void __init prom_init_cmdline(void)
        int argc;
        int *argv32;
        int i;                  /* Always ignore the "-c" at argv[0] */
-       static char builtin[CL_SIZE] __initdata;
+       static char builtin[COMMAND_LINE_SIZE] __initdata;
 
        if (fw_arg0 >= CKSEG0 || fw_arg1 < CKSEG0) {
                /*
@@ -315,7 +315,7 @@ static inline void txx9_cache_fixup(void)
 
 static void __init preprocess_cmdline(void)
 {
-       static char cmdline[CL_SIZE] __initdata;
+       static char cmdline[COMMAND_LINE_SIZE] __initdata;
        char *s;
 
        strcpy(cmdline, arcs_cmdline);
index 6d39e222b170b1db7250cb990c7726f875127305..6153b6a05ccfd176a894e2ebfe74a8011469cc08 100644 (file)
@@ -159,9 +159,9 @@ void vr41xx_enable_piuint(uint16_t mask)
 
        if (current_cpu_type() == CPU_VR4111 ||
            current_cpu_type() == CPU_VR4121) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu1_set(MPIUINTREG, mask);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -174,9 +174,9 @@ void vr41xx_disable_piuint(uint16_t mask)
 
        if (current_cpu_type() == CPU_VR4111 ||
            current_cpu_type() == CPU_VR4121) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu1_clear(MPIUINTREG, mask);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -189,9 +189,9 @@ void vr41xx_enable_aiuint(uint16_t mask)
 
        if (current_cpu_type() == CPU_VR4111 ||
            current_cpu_type() == CPU_VR4121) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu1_set(MAIUINTREG, mask);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -204,9 +204,9 @@ void vr41xx_disable_aiuint(uint16_t mask)
 
        if (current_cpu_type() == CPU_VR4111 ||
            current_cpu_type() == CPU_VR4121) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu1_clear(MAIUINTREG, mask);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -219,9 +219,9 @@ void vr41xx_enable_kiuint(uint16_t mask)
 
        if (current_cpu_type() == CPU_VR4111 ||
            current_cpu_type() == CPU_VR4121) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu1_set(MKIUINTREG, mask);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -234,9 +234,9 @@ void vr41xx_disable_kiuint(uint16_t mask)
 
        if (current_cpu_type() == CPU_VR4111 ||
            current_cpu_type() == CPU_VR4121) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu1_clear(MKIUINTREG, mask);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -247,9 +247,9 @@ void vr41xx_enable_macint(uint16_t mask)
        struct irq_desc *desc = irq_desc + ETHERNET_IRQ;
        unsigned long flags;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        icu1_set(MMACINTREG, mask);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 EXPORT_SYMBOL(vr41xx_enable_macint);
@@ -259,9 +259,9 @@ void vr41xx_disable_macint(uint16_t mask)
        struct irq_desc *desc = irq_desc + ETHERNET_IRQ;
        unsigned long flags;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        icu1_clear(MMACINTREG, mask);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 EXPORT_SYMBOL(vr41xx_disable_macint);
@@ -271,9 +271,9 @@ void vr41xx_enable_dsiuint(uint16_t mask)
        struct irq_desc *desc = irq_desc + DSIU_IRQ;
        unsigned long flags;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        icu1_set(MDSIUINTREG, mask);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 EXPORT_SYMBOL(vr41xx_enable_dsiuint);
@@ -283,9 +283,9 @@ void vr41xx_disable_dsiuint(uint16_t mask)
        struct irq_desc *desc = irq_desc + DSIU_IRQ;
        unsigned long flags;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        icu1_clear(MDSIUINTREG, mask);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 EXPORT_SYMBOL(vr41xx_disable_dsiuint);
@@ -295,9 +295,9 @@ void vr41xx_enable_firint(uint16_t mask)
        struct irq_desc *desc = irq_desc + FIR_IRQ;
        unsigned long flags;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        icu2_set(MFIRINTREG, mask);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 EXPORT_SYMBOL(vr41xx_enable_firint);
@@ -307,9 +307,9 @@ void vr41xx_disable_firint(uint16_t mask)
        struct irq_desc *desc = irq_desc + FIR_IRQ;
        unsigned long flags;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        icu2_clear(MFIRINTREG, mask);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 EXPORT_SYMBOL(vr41xx_disable_firint);
@@ -322,9 +322,9 @@ void vr41xx_enable_pciint(void)
        if (current_cpu_type() == CPU_VR4122 ||
            current_cpu_type() == CPU_VR4131 ||
            current_cpu_type() == CPU_VR4133) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MPCIINTREG, PCIINT0);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -338,9 +338,9 @@ void vr41xx_disable_pciint(void)
        if (current_cpu_type() == CPU_VR4122 ||
            current_cpu_type() == CPU_VR4131 ||
            current_cpu_type() == CPU_VR4133) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MPCIINTREG, 0);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -354,9 +354,9 @@ void vr41xx_enable_scuint(void)
        if (current_cpu_type() == CPU_VR4122 ||
            current_cpu_type() == CPU_VR4131 ||
            current_cpu_type() == CPU_VR4133) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MSCUINTREG, SCUINT0);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -370,9 +370,9 @@ void vr41xx_disable_scuint(void)
        if (current_cpu_type() == CPU_VR4122 ||
            current_cpu_type() == CPU_VR4131 ||
            current_cpu_type() == CPU_VR4133) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MSCUINTREG, 0);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -386,9 +386,9 @@ void vr41xx_enable_csiint(uint16_t mask)
        if (current_cpu_type() == CPU_VR4122 ||
            current_cpu_type() == CPU_VR4131 ||
            current_cpu_type() == CPU_VR4133) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu2_set(MCSIINTREG, mask);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -402,9 +402,9 @@ void vr41xx_disable_csiint(uint16_t mask)
        if (current_cpu_type() == CPU_VR4122 ||
            current_cpu_type() == CPU_VR4131 ||
            current_cpu_type() == CPU_VR4133) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu2_clear(MCSIINTREG, mask);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -418,9 +418,9 @@ void vr41xx_enable_bcuint(void)
        if (current_cpu_type() == CPU_VR4122 ||
            current_cpu_type() == CPU_VR4131 ||
            current_cpu_type() == CPU_VR4133) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MBCUINTREG, BCUINTR);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -434,9 +434,9 @@ void vr41xx_disable_bcuint(void)
        if (current_cpu_type() == CPU_VR4122 ||
            current_cpu_type() == CPU_VR4131 ||
            current_cpu_type() == CPU_VR4133) {
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                icu2_write(MBCUINTREG, 0);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 
@@ -486,7 +486,7 @@ static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
 
        pin = SYSINT1_IRQ_TO_PIN(irq);
 
-       spin_lock_irq(&desc->lock);
+       raw_spin_lock_irq(&desc->lock);
 
        intassign0 = icu1_read(INTASSIGN0);
        intassign1 = icu1_read(INTASSIGN1);
@@ -525,7 +525,7 @@ static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
                intassign1 |= (uint16_t)assign << 9;
                break;
        default:
-               spin_unlock_irq(&desc->lock);
+               raw_spin_unlock_irq(&desc->lock);
                return -EINVAL;
        }
 
@@ -533,7 +533,7 @@ static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
        icu1_write(INTASSIGN0, intassign0);
        icu1_write(INTASSIGN1, intassign1);
 
-       spin_unlock_irq(&desc->lock);
+       raw_spin_unlock_irq(&desc->lock);
 
        return 0;
 }
@@ -546,7 +546,7 @@ static inline int set_sysint2_assign(unsigned int irq, unsigned char assign)
 
        pin = SYSINT2_IRQ_TO_PIN(irq);
 
-       spin_lock_irq(&desc->lock);
+       raw_spin_lock_irq(&desc->lock);
 
        intassign2 = icu1_read(INTASSIGN2);
        intassign3 = icu1_read(INTASSIGN3);
@@ -593,7 +593,7 @@ static inline int set_sysint2_assign(unsigned int irq, unsigned char assign)
                intassign3 |= (uint16_t)assign << 12;
                break;
        default:
-               spin_unlock_irq(&desc->lock);
+               raw_spin_unlock_irq(&desc->lock);
                return -EINVAL;
        }
 
@@ -601,7 +601,7 @@ static inline int set_sysint2_assign(unsigned int irq, unsigned char assign)
        icu1_write(INTASSIGN2, intassign2);
        icu1_write(INTASSIGN3, intassign3);
 
-       spin_unlock_irq(&desc->lock);
+       raw_spin_unlock_irq(&desc->lock);
 
        return 0;
 }
diff --git a/arch/mn10300/include/asm/asm-offsets.h b/arch/mn10300/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 75a70aa9fd6f0da2ca9b7630f588c9bff91b1f38..e5fa97cd9a147222c567b39f1e8bd01cec18ff4a 100644 (file)
@@ -77,7 +77,6 @@ do {                                                                  \
        _ur->a1   = 0;  _ur->a0   = 0;  _ur->d1   = 0;  _ur->d0   = 0;  \
 } while (0)
 
-#define USE_ELF_CORE_DUMP
 #define CORE_DUMP_USE_REGSET
 #define ELF_EXEC_PAGESIZE      4096
 
index 4c3c58ef5cda6fe571cbe39a649e8d4ebbfc3ae0..e2d5ed891f37b6c7471108f25c2e57dd425ba28f 100644 (file)
@@ -215,7 +215,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                /* display information rows, one per active CPU */
        case 1 ... NR_IRQS - 1:
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
 
                action = irq_desc[i].action;
                if (action) {
@@ -235,7 +235,7 @@ int show_interrupts(struct seq_file *p, void *v)
                        seq_putc(p, '\n');
                }
 
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
                break;
 
                /* polish off with NMI and error counters */
index 18072e03a019e1411b88a5e0b3fa1ee48e2b6458..92343bd35fa30c99f64d5c48ddd2aad6efb6ee19 100644 (file)
@@ -445,12 +445,7 @@ done:
 
 int hpux_pipe(int *kstack_fildes)
 {
-       int error;
-
-       lock_kernel();
-       error = do_pipe_flags(kstack_fildes, 0);
-       unlock_kernel();
-       return error;
+       return do_pipe_flags(kstack_fildes, 0);
 }
 
 /* lies - says it works, but it really didn't lock anything */
diff --git a/arch/parisc/include/asm/asm-offsets.h b/arch/parisc/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 8bc9e96699b2a690456aa75585a9f89c05cad7bf..716634d1f5466645c7e6028bda01ca1abd1aeeac 100644 (file)
 #  define ATOMIC_HASH_SIZE 4
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) (a))/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
 
-extern raw_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
+extern arch_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
 
 /* Can't use raw_spin_lock_irq because of #include problems, so
  * this is the substitute */
 #define _atomic_spin_lock_irqsave(l,f) do {    \
-       raw_spinlock_t *s = ATOMIC_HASH(l);             \
+       arch_spinlock_t *s = ATOMIC_HASH(l);            \
        local_irq_save(f);                      \
-       __raw_spin_lock(s);                     \
+       arch_spin_lock(s);                      \
 } while(0)
 
 #define _atomic_spin_unlock_irqrestore(l,f) do {       \
-       raw_spinlock_t *s = ATOMIC_HASH(l);                     \
-       __raw_spin_unlock(s);                           \
+       arch_spinlock_t *s = ATOMIC_HASH(l);                    \
+       arch_spin_unlock(s);                            \
        local_irq_restore(f);                           \
 } while(0)
 
index 8cfc553fc837267e2342cbf66f4ef27efacde143..75e46c557a16901d03f93cb83d2b3838e7793172 100644 (file)
                             "\t.popsection"                            \
                             : : "i" (__FILE__), "i" (__LINE__),        \
                             "i" (0), "i" (sizeof(struct bug_entry)) ); \
-               for(;;) ;                                               \
+               unreachable();                                          \
        } while(0)
 
 #else
 #define BUG()                                                          \
        do {                                                            \
                asm volatile(PARISC_BUG_BREAK_ASM : : );                \
-               for(;;) ;                                               \
+               unreachable();                                          \
        } while(0)
 #endif
 
index 9c802eb4be8491e95f932c9efb487f4b751ac5d4..19f6cb1a4a1c1aa06dd5abcaa4fd7c129863d5b1 100644 (file)
@@ -328,7 +328,6 @@ struct pt_regs;     /* forward declaration... */
    such function.  */
 #define ELF_PLAT_INIT(_r, load_addr)       _r->gr[23] = 0
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      4096
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
index 2fa05dd6aeeeee2c9ca56c772754b8e2dee30627..72c0fafaa039e910999f16b46c96226e991f3724 100644 (file)
@@ -20,6 +20,20 @@ struct ftrace_ret_stack {
  * Defined in entry.S
  */
 extern void return_to_handler(void);
+
+
+extern unsigned long return_address(unsigned int);
+
+#define HAVE_ARCH_CALLER_ADDR
+
+#define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
+#define CALLER_ADDR1 return_address(1)
+#define CALLER_ADDR2 return_address(2)
+#define CALLER_ADDR3 return_address(3)
+#define CALLER_ADDR4 return_address(4)
+#define CALLER_ADDR5 return_address(5)
+#define CALLER_ADDR6 return_address(6)
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_PARISC_FTRACE_H */
index fae03e136fa8619b6d1efc09d750992949ec3dc2..74036f436a3b51e9f6c6f1b55ba1f56502aa07f7 100644 (file)
@@ -5,17 +5,17 @@
 #include <asm/processor.h>
 #include <asm/spinlock_types.h>
 
-static inline int __raw_spin_is_locked(raw_spinlock_t *x)
+static inline int arch_spin_is_locked(arch_spinlock_t *x)
 {
        volatile unsigned int *a = __ldcw_align(x);
        return *a == 0;
 }
 
-#define __raw_spin_lock(lock) __raw_spin_lock_flags(lock, 0)
-#define __raw_spin_unlock_wait(x) \
-               do { cpu_relax(); } while (__raw_spin_is_locked(x))
+#define arch_spin_lock(lock) arch_spin_lock_flags(lock, 0)
+#define arch_spin_unlock_wait(x) \
+               do { cpu_relax(); } while (arch_spin_is_locked(x))
 
-static inline void __raw_spin_lock_flags(raw_spinlock_t *x,
+static inline void arch_spin_lock_flags(arch_spinlock_t *x,
                                         unsigned long flags)
 {
        volatile unsigned int *a;
@@ -33,7 +33,7 @@ static inline void __raw_spin_lock_flags(raw_spinlock_t *x,
        mb();
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *x)
+static inline void arch_spin_unlock(arch_spinlock_t *x)
 {
        volatile unsigned int *a;
        mb();
@@ -42,7 +42,7 @@ static inline void __raw_spin_unlock(raw_spinlock_t *x)
        mb();
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *x)
+static inline int arch_spin_trylock(arch_spinlock_t *x)
 {
        volatile unsigned int *a;
        int ret;
@@ -69,38 +69,38 @@ static inline int __raw_spin_trylock(raw_spinlock_t *x)
 
 /* Note that we have to ensure interrupts are disabled in case we're
  * interrupted by some other code that wants to grab the same read lock */
-static  __inline__ void __raw_read_lock(raw_rwlock_t *rw)
+static  __inline__ void arch_read_lock(arch_rwlock_t *rw)
 {
        unsigned long flags;
        local_irq_save(flags);
-       __raw_spin_lock_flags(&rw->lock, flags);
+       arch_spin_lock_flags(&rw->lock, flags);
        rw->counter++;
-       __raw_spin_unlock(&rw->lock);
+       arch_spin_unlock(&rw->lock);
        local_irq_restore(flags);
 }
 
 /* Note that we have to ensure interrupts are disabled in case we're
  * interrupted by some other code that wants to grab the same read lock */
-static  __inline__ void __raw_read_unlock(raw_rwlock_t *rw)
+static  __inline__ void arch_read_unlock(arch_rwlock_t *rw)
 {
        unsigned long flags;
        local_irq_save(flags);
-       __raw_spin_lock_flags(&rw->lock, flags);
+       arch_spin_lock_flags(&rw->lock, flags);
        rw->counter--;
-       __raw_spin_unlock(&rw->lock);
+       arch_spin_unlock(&rw->lock);
        local_irq_restore(flags);
 }
 
 /* Note that we have to ensure interrupts are disabled in case we're
  * interrupted by some other code that wants to grab the same read lock */
-static __inline__ int __raw_read_trylock(raw_rwlock_t *rw)
+static __inline__ int arch_read_trylock(arch_rwlock_t *rw)
 {
        unsigned long flags;
  retry:
        local_irq_save(flags);
-       if (__raw_spin_trylock(&rw->lock)) {
+       if (arch_spin_trylock(&rw->lock)) {
                rw->counter++;
-               __raw_spin_unlock(&rw->lock);
+               arch_spin_unlock(&rw->lock);
                local_irq_restore(flags);
                return 1;
        }
@@ -111,7 +111,7 @@ static __inline__ int __raw_read_trylock(raw_rwlock_t *rw)
                return 0;
 
        /* Wait until we have a realistic chance at the lock */
-       while (__raw_spin_is_locked(&rw->lock) && rw->counter >= 0)
+       while (arch_spin_is_locked(&rw->lock) && rw->counter >= 0)
                cpu_relax();
 
        goto retry;
@@ -119,15 +119,15 @@ static __inline__ int __raw_read_trylock(raw_rwlock_t *rw)
 
 /* Note that we have to ensure interrupts are disabled in case we're
  * interrupted by some other code that wants to read_trylock() this lock */
-static __inline__ void __raw_write_lock(raw_rwlock_t *rw)
+static __inline__ void arch_write_lock(arch_rwlock_t *rw)
 {
        unsigned long flags;
 retry:
        local_irq_save(flags);
-       __raw_spin_lock_flags(&rw->lock, flags);
+       arch_spin_lock_flags(&rw->lock, flags);
 
        if (rw->counter != 0) {
-               __raw_spin_unlock(&rw->lock);
+               arch_spin_unlock(&rw->lock);
                local_irq_restore(flags);
 
                while (rw->counter != 0)
@@ -141,27 +141,27 @@ retry:
        local_irq_restore(flags);
 }
 
-static __inline__ void __raw_write_unlock(raw_rwlock_t *rw)
+static __inline__ void arch_write_unlock(arch_rwlock_t *rw)
 {
        rw->counter = 0;
-       __raw_spin_unlock(&rw->lock);
+       arch_spin_unlock(&rw->lock);
 }
 
 /* Note that we have to ensure interrupts are disabled in case we're
  * interrupted by some other code that wants to read_trylock() this lock */
-static __inline__ int __raw_write_trylock(raw_rwlock_t *rw)
+static __inline__ int arch_write_trylock(arch_rwlock_t *rw)
 {
        unsigned long flags;
        int result = 0;
 
        local_irq_save(flags);
-       if (__raw_spin_trylock(&rw->lock)) {
+       if (arch_spin_trylock(&rw->lock)) {
                if (rw->counter == 0) {
                        rw->counter = -1;
                        result = 1;
                } else {
                        /* Read-locked.  Oh well. */
-                       __raw_spin_unlock(&rw->lock);
+                       arch_spin_unlock(&rw->lock);
                }
        }
        local_irq_restore(flags);
@@ -173,7 +173,7 @@ static __inline__ int __raw_write_trylock(raw_rwlock_t *rw)
  * read_can_lock - would read_trylock() succeed?
  * @lock: the rwlock in question.
  */
-static __inline__ int __raw_read_can_lock(raw_rwlock_t *rw)
+static __inline__ int arch_read_can_lock(arch_rwlock_t *rw)
 {
        return rw->counter >= 0;
 }
@@ -182,16 +182,16 @@ static __inline__ int __raw_read_can_lock(raw_rwlock_t *rw)
  * write_can_lock - would write_trylock() succeed?
  * @lock: the rwlock in question.
  */
-static __inline__ int __raw_write_can_lock(raw_rwlock_t *rw)
+static __inline__ int arch_write_can_lock(arch_rwlock_t *rw)
 {
        return !rw->counter;
 }
 
-#define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock)
-#define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock)
+#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* __ASM_SPINLOCK_H */
index 3f72f47cf4b20c798ac09a0b3ac520a069062046..8c373aa28a862f0a5fd559bec87ab2504008d01e 100644 (file)
@@ -4,18 +4,18 @@
 typedef struct {
 #ifdef CONFIG_PA20
        volatile unsigned int slock;
-# define __RAW_SPIN_LOCK_UNLOCKED { 1 }
+# define __ARCH_SPIN_LOCK_UNLOCKED { 1 }
 #else
        volatile unsigned int lock[4];
-# define __RAW_SPIN_LOCK_UNLOCKED      { { 1, 1, 1, 1 } }
+# define __ARCH_SPIN_LOCK_UNLOCKED     { { 1, 1, 1, 1 } }
 #endif
-} raw_spinlock_t;
+} arch_spinlock_t;
 
 typedef struct {
-       raw_spinlock_t lock;
+       arch_spinlock_t lock;
        volatile int counter;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { __RAW_SPIN_LOCK_UNLOCKED, 0 }
+#define __ARCH_RW_LOCK_UNLOCKED                { __ARCH_SPIN_LOCK_UNLOCKED, 0 }
 
 #endif
index fcd3c707bf126005c3fdb75325a65540890f9923..ec787b411e9a12ac73cf07342ffbf05ef52d7959 100644 (file)
@@ -244,9 +244,6 @@ int main(void)
        DEFINE(THREAD_SZ, sizeof(struct thread_info));
        DEFINE(THREAD_SZ_ALGN, align(sizeof(struct thread_info), 64));
        BLANK();
-       DEFINE(IRQSTAT_SIRQ_PEND, offsetof(irq_cpustat_t, __softirq_pending));
-       DEFINE(IRQSTAT_SZ, sizeof(irq_cpustat_t));
-       BLANK();
        DEFINE(ICACHE_BASE, offsetof(struct pdc_cache_info, ic_base));
        DEFINE(ICACHE_STRIDE, offsetof(struct pdc_cache_info, ic_stride));
        DEFINE(ICACHE_COUNT, offsetof(struct pdc_cache_info, ic_count));
index 2e7610cb33d5be4afa18daae6a5f9187078a2bf4..efbcee5d222095c7d8ad216bcebb6f72016b3f2b 100644 (file)
@@ -145,7 +145,7 @@ static int cpu_set_affinity_irq(unsigned int irq, const struct cpumask *dest)
 #endif
 
 static struct irq_chip cpu_interrupt_type = {
-       .typename       = "CPU",
+       .name           = "CPU",
        .startup        = cpu_startup_irq,
        .shutdown       = cpu_disable_irq,
        .enable         = cpu_enable_irq,
@@ -180,7 +180,7 @@ int show_interrupts(struct seq_file *p, void *v)
        if (i < NR_IRQS) {
                struct irqaction *action;
 
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -192,7 +192,7 @@ int show_interrupts(struct seq_file *p, void *v)
                seq_printf(p, "%10u ", kstat_irqs(i));
 #endif
 
-               seq_printf(p, " %14s", irq_desc[i].chip->typename);
+               seq_printf(p, " %14s", irq_desc[i].chip->name);
 #ifndef PARISC_IRQ_CR16_COUNTS
                seq_printf(p, "  %s", action->name);
 
@@ -224,7 +224,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
  skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        }
 
        return 0;
index e8467e4aa8d16b054aabac097bc19210ae4a409c..fb37ac52e46c72c225774241a02ef9322d625662 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/stddef.h>
 #include <linux/compat.h>
 #include <linux/elf.h>
-#include <linux/tracehook.h>
 #include <asm/ucontext.h>
 #include <asm/rt_sigframe.h>
 #include <asm/uaccess.h>
index 1fd0f0cec037f3fa19ce2630ee7311dc7cc34dbc..3f2fce8ce6b628c5af3121cecd93c231c924d781 100644 (file)
@@ -60,8 +60,6 @@ static int smp_debug_lvl = 0;
 #define smp_debug(lvl, ...)    do { } while(0)
 #endif /* DEBUG_SMP */
 
-DEFINE_SPINLOCK(smp_lock);
-
 volatile struct task_struct *smp_init_current_idle_task;
 
 /* track which CPU is booting */
@@ -69,7 +67,7 @@ static volatile int cpu_now_booting __cpuinitdata;
 
 static int parisc_max_cpus __cpuinitdata = 1;
 
-DEFINE_PER_CPU(spinlock_t, ipi_lock) = SPIN_LOCK_UNLOCKED;
+static DEFINE_PER_CPU(spinlock_t, ipi_lock);
 
 enum ipi_message_type {
        IPI_NOP=0,
@@ -438,6 +436,11 @@ void __init smp_prepare_boot_cpu(void)
 */
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
+       int cpu;
+
+       for_each_possible_cpu(cpu)
+               spin_lock_init(&per_cpu(ipi_lock, cpu));
+
        init_cpu_present(cpumask_of(0));
 
        parisc_max_cpus = max_cpus;
index 76d23ec8dfaa44aac517f1d2f3a7f288a1c437c8..9779ece2b07079189884f2f17807adb85e6e5bbe 100644 (file)
 #include <linux/shm.h>
 #include <linux/slab.h>
 #include <linux/uio.h>
-#include <linux/nfs_fs.h>
 #include <linux/ncp_fs.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfsd/xdr.h>
-#include <linux/nfsd/syscall.h>
 #include <linux/poll.h>
 #include <linux/personality.h>
 #include <linux/stat.h>
index a36799e85693d7b30d7a9acf1f2703709ad77bcb..d58eac1a8288af9c07ef776faa9b29d6b1890a2e 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/kallsyms.h>
+#include <linux/sort.h>
 
 #include <asm/uaccess.h>
 #include <asm/assembly.h>
@@ -115,24 +116,18 @@ unwind_table_init(struct unwind_table *table, const char *name,
        }
 }
 
+static int cmp_unwind_table_entry(const void *a, const void *b)
+{
+       return ((const struct unwind_table_entry *)a)->region_start
+            - ((const struct unwind_table_entry *)b)->region_start;
+}
+
 static void
 unwind_table_sort(struct unwind_table_entry *start,
                  struct unwind_table_entry *finish)
 {
-       struct unwind_table_entry el, *p, *q;
-
-       for (p = start + 1; p < finish; ++p) {
-               if (p[0].region_start < p[-1].region_start) {
-                       el = *p;
-                       q = p;
-                       do {
-                               q[0] = q[-1];
-                               --q;
-                       } while (q > start && 
-                                el.region_start < q[-1].region_start);
-                       *q = el;
-               }
-       }
+       sort(start, finish - start, sizeof(struct unwind_table_entry),
+            cmp_unwind_table_entry, NULL);
 }
 
 struct unwind_table *
@@ -417,3 +412,30 @@ int unwind_to_user(struct unwind_frame_info *info)
 
        return ret;
 }
+
+unsigned long return_address(unsigned int level)
+{
+       struct unwind_frame_info info;
+       struct pt_regs r;
+       unsigned long sp;
+
+       /* initialize unwind info */
+       asm volatile ("copy %%r30, %0" : "=r"(sp));
+       memset(&r, 0, sizeof(struct pt_regs));
+       r.iaoq[0] = (unsigned long) current_text_addr();
+       r.gr[2] = (unsigned long) __builtin_return_address(0);
+       r.gr[30] = sp;
+       unwind_frame_init(&info, current, &r);
+
+       /* unwind stack */
+       ++level;
+       do {
+               if (unwind_once(&info) < 0 || info.ip == 0)
+                       return 0;
+               if (!__kernel_text_address(info.ip)) {
+                       return 0;
+               }
+       } while (info.ip && level--);
+
+       return info.ip;
+}
index e3eb739fab19d3eb20c6d3ae2a837abb860ed7db..353963d42059aa409eb36c15a00bbfb5b49068a0 100644 (file)
@@ -12,8 +12,8 @@
 #include <asm/atomic.h>
 
 #ifdef CONFIG_SMP
-raw_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned = {
-       [0 ... (ATOMIC_HASH_SIZE-1)]  = __RAW_SPIN_LOCK_UNLOCKED
+arch_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned = {
+       [0 ... (ATOMIC_HASH_SIZE-1)]  = __ARCH_SPIN_LOCK_UNLOCKED
 };
 #endif
 
index 0df57466e7834ab9dab978c5accccbdbfb4b0b04..ba3948c700727b212aa2952e729176b7c1501442 100644 (file)
@@ -704,7 +704,7 @@ config PPC_PCI_CHOICE
 config PCI
        bool "PCI support" if PPC_PCI_CHOICE
        default y if !40x && !CPM2 && !8xx && !PPC_83xx \
-               && !PPC_85xx && !PPC_86xx
+               && !PPC_85xx && !PPC_86xx && !GAMECUBE_COMMON
        default PCI_PERMEDIA if !4xx && !CPM2 && !8xx
        default PCI_QSPAN if !4xx && !CPM2 && 8xx
        select ARCH_SUPPORTS_MSI
index bf3382f1904d04d0f0807490c1449691f540a4b7..5cdd7ed9a12e89abe0b4eec8cbe9155b7dfacd9e 100644 (file)
@@ -254,6 +254,14 @@ config PPC_EARLY_DEBUG_CPM
          using a CPM-based serial port.  This assumes that the bootwrapper
          has run, and set up the CPM in a particular way.
 
+config PPC_EARLY_DEBUG_USBGECKO
+       bool "Early debugging through the USB Gecko adapter"
+       depends on GAMECUBE_COMMON
+       select USBGECKO_UDBG
+       help
+         Select this to enable early debugging for Nintendo GameCube/Wii
+         consoles via an external USB Gecko adapter.
+
 endchoice
 
 config PPC_EARLY_DEBUG_44x_PHYSLOW
index 7bfc8ad8779876e33b2ea6522ba4651dfbcccde6..bb2465bcb32766598c663ddca9d0893399891564 100644 (file)
@@ -66,7 +66,7 @@ src-wlib := string.S crt0.S crtsavres.S stdio.c main.c \
                gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
                4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \
                cpm-serial.c stdlib.c mpc52xx-psc.c planetcore.c uartlite.c \
-               fsl-soc.c mpc8xx.c pq2.c
+               fsl-soc.c mpc8xx.c pq2.c ugecon.c
 src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c \
                cuboot-ebony.c cuboot-hotfoot.c treeboot-ebony.c prpmc2800.c \
                ps3-head.S ps3-hvcall.S ps3.c treeboot-bamboo.c cuboot-8xx.c \
@@ -76,7 +76,8 @@ src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c
                cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
                cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
                virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c \
-               cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c
+               cuboot-acadia.c cuboot-amigaone.c cuboot-kilauea.c \
+               gamecube-head.S gamecube.c wii-head.S wii.c
 src-boot := $(src-wlib) $(src-plat) empty.c
 
 src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -254,6 +255,8 @@ image-$(CONFIG_KSI8560)                     += cuImage.ksi8560
 image-$(CONFIG_STORCENTER)             += cuImage.storcenter
 image-$(CONFIG_MPC7448HPC2)            += cuImage.mpc7448hpc2
 image-$(CONFIG_PPC_C2K)                        += cuImage.c2k
+image-$(CONFIG_GAMECUBE)               += dtbImage.gamecube
+image-$(CONFIG_WII)                    += dtbImage.wii
 
 # Board port in arch/powerpc/platform/amigaone/Kconfig
 image-$(CONFIG_AMIGAONE)               += cuImage.amigaone
diff --git a/arch/powerpc/boot/dts/gamecube.dts b/arch/powerpc/boot/dts/gamecube.dts
new file mode 100644 (file)
index 0000000..ef3be0e
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * arch/powerpc/boot/dts/gamecube.dts
+ *
+ * Nintendo GameCube platform device tree source
+ * Copyright (C) 2007-2009 The GameCube Linux Team
+ * Copyright (C) 2007,2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+/dts-v1/;
+
+/ {
+       model = "nintendo,gamecube";
+       compatible = "nintendo,gamecube";
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       chosen {
+               bootargs = "root=/dev/gcnsda2 rootwait udbg-immortal";
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0x00000000 0x01800000>;
+       };
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               PowerPC,gekko@0 {
+                       device_type = "cpu";
+                       reg = <0>;
+                       clock-frequency = <486000000>; /* 486MHz */
+                       bus-frequency = <162000000>; /* 162MHz core-to-bus 3x */
+                       timebase-frequency = <40500000>; /* 162MHz / 4 */
+                       i-cache-line-size = <32>;
+                       d-cache-line-size = <32>;
+                       i-cache-size = <32768>;
+                       d-cache-size = <32768>;
+               };
+       };
+
+       /* devices contained int the flipper chipset */
+       flipper {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "nintendo,flipper";
+               ranges = <0x0c000000 0x0c000000 0x00010000>;
+               interrupt-parent = <&PIC>;
+
+               video@0c002000 {
+                       compatible = "nintendo,flipper-vi";
+                       reg = <0x0c002000 0x100>;
+                       interrupts = <8>;
+               };
+
+               processor-interface@0c003000 {
+                       compatible = "nintendo,flipper-pi";
+                       reg = <0x0c003000 0x100>;
+
+                       PIC: pic {
+                               #interrupt-cells = <1>;
+                               compatible = "nintendo,flipper-pic";
+                               interrupt-controller;
+                       };
+               };
+
+               dsp@0c005000 {
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       compatible = "nintendo,flipper-dsp";
+                       reg = <0x0c005000 0x200>;
+                       interrupts = <6>;
+
+                       memory@0 {
+                               compatible = "nintendo,flipper-aram";
+                               reg = <0 0x1000000>;    /* 16MB */
+                       };
+               };
+
+               disk@0c006000 {
+                       compatible = "nintendo,flipper-di";
+                       reg = <0x0c006000 0x40>;
+                       interrupts = <2>;
+               };
+
+               audio@0c006c00 {
+                       compatible = "nintendo,flipper-ai";
+                       reg = <0x0c006c00 0x20>;
+                       interrupts = <6>;
+               };
+
+               gamepad-controller@0c006400 {
+                       compatible = "nintendo,flipper-si";
+                       reg = <0x0c006400 0x100>;
+                       interrupts = <3>;
+               };
+
+               /* External Interface bus */
+               exi@0c006800 {
+                       compatible = "nintendo,flipper-exi";
+                       reg = <0x0c006800 0x40>;
+                       virtual-reg = <0x0c006800>;
+                       interrupts = <4>;
+               };
+        };
+};
+
index 51eb6ed5da2d1ff9b51283d410dc464eda87fc5e..8f345de960cd7407a811ca0a4891348a0b4bc782 100644 (file)
                dcr-reg = <0x00c 0x002>;
        };
 
+       MQ0: mq {
+               compatible = "ibm,mq-440spe";
+               dcr-reg = <0x040 0x020>;
+       };
+
        plb {
                compatible = "ibm,plb-440spe", "ibm,plb-440gp", "ibm,plb4";
                #address-cells = <2>;
                #size-cells = <1>;
                /*        addr-child     addr-parent    size */
-               ranges = <0x4 0xe0000000 0x4 0xe0000000 0x20000000
+               ranges = <0x4 0x00100000 0x4 0x00100000 0x00001000
+                         0x4 0x00200000 0x4 0x00200000 0x00000400
+                         0x4 0xe0000000 0x4 0xe0000000 0x20000000
                          0xc 0x00000000 0xc 0x00000000 0x20000000
                          0xd 0x00000000 0xd 0x00000000 0x80000000
                          0xd 0x80000000 0xd 0x80000000 0x80000000
                                0x0 0x0 0x0 0x3 &UIC3 0xa 0x4 /* swizzled int C */
                                0x0 0x0 0x0 0x4 &UIC3 0xb 0x4 /* swizzled int D */>;
                };
+
+               I2O: i2o@400100000 {
+                       compatible = "ibm,i2o-440spe";
+                       reg = <0x00000004 0x00100000 0x100>;
+                       dcr-reg = <0x060 0x020>;
+               };
+
+               DMA0: dma0@400100100 {
+                       compatible = "ibm,dma-440spe";
+                       cell-index = <0>;
+                       reg = <0x00000004 0x00100100 0x100>;
+                       dcr-reg = <0x060 0x020>;
+                       interrupt-parent = <&DMA0>;
+                       interrupts = <0 1>;
+                       #interrupt-cells = <1>;
+                       #address-cells = <0>;
+                       #size-cells = <0>;
+                       interrupt-map = <
+                               0 &UIC0 0x14 4
+                               1 &UIC1 0x16 4>;
+               };
+
+               DMA1: dma1@400100200 {
+                       compatible = "ibm,dma-440spe";
+                       cell-index = <1>;
+                       reg = <0x00000004 0x00100200 0x100>;
+                       dcr-reg = <0x060 0x020>;
+                       interrupt-parent = <&DMA1>;
+                       interrupts = <0 1>;
+                       #interrupt-cells = <1>;
+                       #address-cells = <0>;
+                       #size-cells = <0>;
+                       interrupt-map = <
+                               0 &UIC0 0x16 4
+                               1 &UIC1 0x16 4>;
+               };
+
+               xor-accel@400200000 {
+                       compatible = "amcc,xor-accelerator";
+                       reg = <0x00000004 0x00200000 0x400>;
+                       interrupt-parent = <&UIC1>;
+                       interrupts = <0x1f 4>;
+               };
        };
 
        chosen {
index 32e10f588c1d40e316332bad0126d0a795b0af07..8a3a4f3ef831aec92f0d308a791d8dfeb4f9ecc1 100644 (file)
                        interrupt-parent = <&ipic>;
                        tbi-handle = <&tbi0>;
                        phy-handle = < &phy0 >;
+                       fsl,magic-packet;
 
                        mdio@520 {
                                #address-cells = <1>;
                        interrupt-parent = <&ipic>;
                        tbi-handle = <&tbi1>;
                        phy-handle = < &phy1 >;
+                       fsl,magic-packet;
 
                        mdio@520 {
                                #address-cells = <1>;
                        interrupt-parent = <&ipic>;
                };
 
+               gtm1: timer@500 {
+                       compatible = "fsl,mpc8315-gtm", "fsl,gtm";
+                       reg = <0x500 0x100>;
+                       interrupts = <90 8 78 8 84 8 72 8>;
+                       interrupt-parent = <&ipic>;
+                       clock-frequency = <133333333>;
+               };
+
+               timer@600 {
+                       compatible = "fsl,mpc8315-gtm", "fsl,gtm";
+                       reg = <0x600 0x100>;
+                       interrupts = <91 8 79 8 85 8 73 8>;
+                       interrupt-parent = <&ipic>;
+                       clock-frequency = <133333333>;
+               };
+
                /* IPIC
                 * interrupts cell = <intr #, sense>
                 * sense values match linux IORESOURCE_IRQ_* defines:
                                      0x59 0x8>;
                        interrupt-parent = < &ipic >;
                };
+
+               pmc: power@b00 {
+                       compatible = "fsl,mpc8315-pmc", "fsl,mpc8313-pmc",
+                                    "fsl,mpc8349-pmc";
+                       reg = <0xb00 0x100 0xa00 0x100>;
+                       interrupts = <80 8>;
+                       interrupt-parent = <&ipic>;
+                       fsl,mpc8313-wakeup-timer = <&gtm1>;
+               };
        };
 
        pci0: pci@e0008500 {
index feeeb7f9d6091031825dfc2f477ebe785b9d1f26..b53d1df11e2d85ed791710695819aaec11eae61c 100644 (file)
                        reg = <0x200 0x100>;
                };
 
+               gpio1: gpio-controller@c00 {
+                       #gpio-cells = <2>;
+                       compatible = "fsl,mpc8349-gpio";
+                       reg = <0xc00 0x100>;
+                       interrupts = <74 0x8>;
+                       interrupt-parent = <&ipic>;
+                       gpio-controller;
+               };
+
+               gpio2: gpio-controller@d00 {
+                       #gpio-cells = <2>;
+                       compatible = "fsl,mpc8349-gpio";
+                       reg = <0xd00 0x100>;
+                       interrupts = <75 0x8>;
+                       interrupt-parent = <&ipic>;
+                       gpio-controller;
+               };
+
                i2c@3000 {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        interrupts = <14 0x8>;
                        interrupt-parent = <&ipic>;
                        dfsrr;
+
+                       eeprom: at24@50 {
+                               compatible = "st-micro,24c256";
+                               reg = <0x50>;
+                       };
+
                };
 
                i2c@3100 {
                                interrupt-parent = <&ipic>;
                        };
 
+                       pcf1: iexp@38 {
+                               #gpio-cells = <2>;
+                               compatible = "ti,pcf8574a";
+                               reg = <0x38>;
+                               gpio-controller;
+                       };
+
+                       pcf2: iexp@39 {
+                               #gpio-cells = <2>;
+                               compatible = "ti,pcf8574a";
+                               reg = <0x39>;
+                               gpio-controller;
+                       };
+
+                       spd: at24@51 {
+                               compatible = "at24,spd";
+                               reg = <0x51>;
+                       };
+
                        mcu_pio: mcu@a {
                                #gpio-cells = <2>;
                                compatible = "fsl,mc9s08qg8-mpc8349emitx",
                        reg = <0x700 0x100>;
                        device_type = "ipic";
                };
+
+               gpio-leds {
+                       compatible = "gpio-leds";
+
+                       green {
+                               label = "Green";
+                               gpios = <&pcf1 0 1>;
+                               linux,default-trigger = "heartbeat";
+                       };
+
+                       yellow {
+                               label = "Yellow";
+                               gpios = <&pcf1 1 1>;
+                               /* linux,default-trigger = "heartbeat"; */
+                               default-state = "on";
+                       };
+               };
+
        };
 
        pci0: pci@e0008500 {
                compatible = "fsl,mpc8349e-localbus",
                             "fsl,pq2pro-localbus";
                reg = <0xe0005000 0xd8>;
-               ranges = <0x3 0x0 0xf0000000 0x210>;
+               ranges = <0x0 0x0 0xfe000000 0x1000000  /* flash */
+                         0x1 0x0 0xf8000000 0x20000    /* VSC 7385 */
+                         0x2 0x0 0xf9000000 0x200000   /* exp slot */
+                         0x3 0x0 0xf0000000 0x210>;    /* CF slot */
+
+               flash@0,0 {
+                       compatible = "cfi-flash";
+                       reg = <0x0      0x0 0x800000>;
+                       bank-width = <2>;
+                       device-width = <1>;
+               };
+
+               flash@0,800000 {
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       compatible = "cfi-flash";
+                       reg = <0x0 0x800000 0x800000>;
+                       bank-width = <2>;
+                       device-width = <1>;
+               };
 
                pata@3,0 {
                        compatible = "fsl,mpc8349emitx-pata", "ata-generic";
index 31605ee4afb69444d9aa5f8c523f9eba9c5f5879..e576ee85c42f1fe6da0db81de11555fc220fc6fa 100644 (file)
 
                                fpga@2,4000 {
                                        compatible = "pika,fpga-sd";
-                                       reg = <0x00000002 0x00004000 0x00000A00>;
+                                       reg = <0x00000002 0x00004000 0x00004000>;
                                };
 
                                nor@0,0 {
diff --git a/arch/powerpc/boot/dts/wii.dts b/arch/powerpc/boot/dts/wii.dts
new file mode 100644 (file)
index 0000000..77528c9
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * arch/powerpc/boot/dts/wii.dts
+ *
+ * Nintendo Wii platform device tree source
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+/dts-v1/;
+
+/*
+ * This is commented-out for now.
+ * Until a later patch is merged, the kernel can use only the first
+ * contiguous RAM range and will BUG() if the memreserve is outside
+ * that range.
+ */
+/*/memreserve/ 0x10000000 0x0004000;*/ /* DSP RAM */
+
+/ {
+       model = "nintendo,wii";
+       compatible = "nintendo,wii";
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       chosen {
+               bootargs = "root=/dev/mmcblk0p2 rootwait udbg-immortal";
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0x00000000 0x01800000    /* MEM1 24MB 1T-SRAM */
+                      0x10000000 0x04000000>;  /* MEM2 64MB GDDR3 */
+       };
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               PowerPC,broadway@0 {
+                       device_type = "cpu";
+                       reg = <0>;
+                       clock-frequency = <729000000>; /* 729MHz */
+                       bus-frequency = <243000000>; /* 243MHz core-to-bus 3x */
+                       timebase-frequency = <60750000>; /* 243MHz / 4 */
+                       i-cache-line-size = <32>;
+                       d-cache-line-size = <32>;
+                       i-cache-size = <32768>;
+                       d-cache-size = <32768>;
+               };
+       };
+
+       /* devices contained in the hollywood chipset */
+       hollywood {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "nintendo,hollywood";
+                ranges = <0x0c000000 0x0c000000 0x01000000
+                         0x0d000000 0x0d000000 0x00800000
+                         0x0d800000 0x0d800000 0x00800000>;
+               interrupt-parent = <&PIC0>;
+
+               video@0c002000 {
+                       compatible = "nintendo,hollywood-vi",
+                                       "nintendo,flipper-vi";
+                       reg = <0x0c002000 0x100>;
+                       interrupts = <8>;
+               };
+
+               processor-interface@0c003000 {
+                       compatible = "nintendo,hollywood-pi",
+                                       "nintendo,flipper-pi";
+                       reg = <0x0c003000 0x100>;
+
+                       PIC0: pic0 {
+                               #interrupt-cells = <1>;
+                               compatible = "nintendo,flipper-pic";
+                               interrupt-controller;
+                       };
+               };
+
+               dsp@0c005000 {
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       compatible = "nintendo,hollywood-dsp",
+                                       "nintendo,flipper-dsp";
+                       reg = <0x0c005000 0x200>;
+                       interrupts = <6>;
+               };
+
+               gamepad-controller@0d006400 {
+                       compatible = "nintendo,hollywood-si",
+                                       "nintendo,flipper-si";
+                       reg = <0x0d006400 0x100>;
+                       interrupts = <3>;
+               };
+
+               audio@0c006c00 {
+                       compatible = "nintendo,hollywood-ai",
+                                       "nintendo,flipper-ai";
+                       reg = <0x0d006c00 0x20>;
+                       interrupts = <6>;
+               };
+
+               /* External Interface bus */
+               exi@0d006800 {
+                       compatible = "nintendo,hollywood-exi",
+                                       "nintendo,flipper-exi";
+                       reg = <0x0d006800 0x40>;
+                       virtual-reg = <0x0d006800>;
+                       interrupts = <4>;
+               };
+
+               usb@0d040000 {
+                       compatible = "nintendo,hollywood-usb-ehci",
+                                       "usb-ehci";
+                       reg = <0x0d040000 0x100>;
+                       interrupts = <4>;
+                       interrupt-parent = <&PIC1>;
+               };
+
+               usb@0d050000 {
+                       compatible = "nintendo,hollywood-usb-ohci",
+                                       "usb-ohci";
+                       reg = <0x0d050000 0x100>;
+                       interrupts = <5>;
+                       interrupt-parent = <&PIC1>;
+               };
+
+               usb@0d060000 {
+                       compatible = "nintendo,hollywood-usb-ohci",
+                                       "usb-ohci";
+                       reg = <0x0d060000 0x100>;
+                       interrupts = <6>;
+                       interrupt-parent = <&PIC1>;
+               };
+
+               sd@0d070000 {
+                       compatible = "nintendo,hollywood-sdhci",
+                                       "sdhci";
+                       reg = <0x0d070000 0x200>;
+                       interrupts = <7>;
+                       interrupt-parent = <&PIC1>;
+               };
+
+               sdio@0d080000 {
+                       compatible = "nintendo,hollywood-sdhci",
+                                       "sdhci";
+                       reg = <0x0d080000 0x200>;
+                       interrupts = <8>;
+                       interrupt-parent = <&PIC1>;
+               };
+
+               ipc@0d000000 {
+                       compatible = "nintendo,hollywood-ipc";
+                       reg = <0x0d000000 0x10>;
+                       interrupts = <30>;
+                       interrupt-parent = <&PIC1>;
+               };
+
+               PIC1: pic1@0d800030 {
+                       #interrupt-cells = <1>;
+                       compatible = "nintendo,hollywood-pic";
+                       reg = <0x0d800030 0x10>;
+                       interrupt-controller;
+                       interrupts = <14>;
+               };
+
+               GPIO: gpio@0d8000c0 {
+                       #gpio-cells = <2>;
+                       compatible = "nintendo,hollywood-gpio";
+                       reg = <0x0d8000c0 0x40>;
+                       gpio-controller;
+
+                       /*
+                        * This is commented out while a standard binding
+                        * for i2c over gpio is defined.
+                        */
+                       /*
+                       i2c-video {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               compatible = "i2c-gpio";
+
+                               gpios = <&GPIO 15 0
+                                        &GPIO 14 0>;
+                               clock-frequency = <250000>;
+                               no-clock-stretching;
+                               scl-is-open-drain;
+                               sda-is-open-drain;
+                               sda-enforce-dir;
+
+                               AVE: audio-video-encoder@70 {
+                                       compatible = "nintendo,wii-audio-video-encoder";
+                                       reg = <0x70>;
+                               };
+                       };
+                       */
+               };
+
+               control@0d800100 {
+                       compatible = "nintendo,hollywood-control";
+                       reg = <0x0d800100 0x300>;
+               };
+
+               disk@0d806000 {
+                       compatible = "nintendo,hollywood-di";
+                       reg = <0x0d806000 0x40>;
+                       interrupts = <2>;
+               };
+       };
+};
+
diff --git a/arch/powerpc/boot/gamecube-head.S b/arch/powerpc/boot/gamecube-head.S
new file mode 100644 (file)
index 0000000..65a9b2a
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * arch/powerpc/boot/gamecube-head.S
+ *
+ * Nintendo GameCube bootwrapper entry.
+ * Copyright (C) 2004-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#include "ppc_asm.h"
+
+/*
+ * The entry code does no assumptions regarding:
+ * - if the data and instruction caches are enabled or not
+ * - if the MMU is enabled or not
+ *
+ * We enable the caches if not already enabled, enable the MMU with an
+ * identity mapping scheme and jump to the start code.
+ */
+
+       .text
+
+       .globl _zimage_start
+_zimage_start:
+
+       /* turn the MMU off */
+       mfmsr   9
+       rlwinm  9, 9, 0, ~((1<<4)|(1<<5)) /* MSR_DR|MSR_IR */
+       bcl     20, 31, 1f
+1:
+       mflr    8
+       clrlwi  8, 8, 3         /* convert to a real address */
+       addi    8, 8, _mmu_off - 1b
+       mtsrr0  8
+       mtsrr1  9
+       rfi
+_mmu_off:
+       /* MMU disabled */
+
+       /* setup BATs */
+       isync
+       li      8, 0
+       mtspr   0x210, 8        /* IBAT0U */
+       mtspr   0x212, 8        /* IBAT1U */
+       mtspr   0x214, 8        /* IBAT2U */
+       mtspr   0x216, 8        /* IBAT3U */
+       mtspr   0x218, 8        /* DBAT0U */
+       mtspr   0x21a, 8        /* DBAT1U */
+       mtspr   0x21c, 8        /* DBAT2U */
+       mtspr   0x21e, 8        /* DBAT3U */
+
+       li      8, 0x01ff       /* first 16MiB */
+       li      9, 0x0002       /* rw */
+       mtspr   0x211, 9        /* IBAT0L */
+       mtspr   0x210, 8        /* IBAT0U */
+       mtspr   0x219, 9        /* DBAT0L */
+       mtspr   0x218, 8        /* DBAT0U */
+
+       lis     8, 0x0c00       /* I/O mem */
+       ori     8, 8, 0x3ff     /* 32MiB */
+       lis     9, 0x0c00
+       ori     9, 9, 0x002a    /* uncached, guarded, rw */
+       mtspr   0x21b, 9        /* DBAT1L */
+       mtspr   0x21a, 8        /* DBAT1U */
+
+       lis     8, 0x0100       /* next 8MiB */
+       ori     8, 8, 0x00ff    /* 8MiB */
+       lis     9, 0x0100
+       ori     9, 9, 0x0002    /* rw */
+       mtspr   0x215, 9        /* IBAT2L */
+       mtspr   0x214, 8        /* IBAT2U */
+       mtspr   0x21d, 9        /* DBAT2L */
+       mtspr   0x21c, 8        /* DBAT2U */
+
+       /* enable and invalidate the caches if not already enabled */
+       mfspr   8, 0x3f0        /* HID0 */
+       andi.   0, 8, (1<<15)           /* HID0_ICE */
+       bne     1f
+       ori     8, 8, (1<<15)|(1<<11)   /* HID0_ICE|HID0_ICFI*/
+1:
+       andi.   0, 8, (1<<14)           /* HID0_DCE */
+       bne     1f
+       ori     8, 8, (1<<14)|(1<<10)   /* HID0_DCE|HID0_DCFI*/
+1:
+       mtspr   0x3f0, 8        /* HID0 */
+       isync
+
+       /* initialize arguments */
+       li      3, 0
+       li      4, 0
+       li      5, 0
+
+       /* turn the MMU on */
+       bcl     20, 31, 1f
+1:
+       mflr    8
+       addi    8, 8, _mmu_on - 1b
+       mfmsr   9
+       ori     9, 9, (1<<4)|(1<<5) /* MSR_DR|MSR_IR */
+       mtsrr0  8
+       mtsrr1  9
+       sync
+       rfi
+_mmu_on:
+       b _zimage_start_lib
+
diff --git a/arch/powerpc/boot/gamecube.c b/arch/powerpc/boot/gamecube.c
new file mode 100644 (file)
index 0000000..28ae705
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * arch/powerpc/boot/gamecube.c
+ *
+ * Nintendo GameCube bootwrapper support
+ * Copyright (C) 2004-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#include <stddef.h>
+#include "stdio.h"
+#include "types.h"
+#include "io.h"
+#include "ops.h"
+
+#include "ugecon.h"
+
+BSS_STACK(8192);
+
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)
+{
+       u32 heapsize = 16*1024*1024 - (u32)_end;
+
+       simple_alloc_init(_end, heapsize, 32, 64);
+       fdt_init(_dtb_start);
+
+       if (ug_probe())
+               console_ops.write = ug_console_write;
+}
+
diff --git a/arch/powerpc/boot/ugecon.c b/arch/powerpc/boot/ugecon.c
new file mode 100644 (file)
index 0000000..8f2a6b3
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * arch/powerpc/boot/ugecon.c
+ *
+ * USB Gecko bootwrapper console.
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#include <stddef.h>
+#include "stdio.h"
+#include "types.h"
+#include "io.h"
+#include "ops.h"
+
+
+#define EXI_CLK_32MHZ           5
+
+#define EXI_CSR                 0x00
+#define   EXI_CSR_CLKMASK       (0x7<<4)
+#define     EXI_CSR_CLK_32MHZ   (EXI_CLK_32MHZ<<4)
+#define   EXI_CSR_CSMASK        (0x7<<7)
+#define     EXI_CSR_CS_0        (0x1<<7)  /* Chip Select 001 */
+
+#define EXI_CR                  0x0c
+#define   EXI_CR_TSTART         (1<<0)
+#define   EXI_CR_WRITE         (1<<2)
+#define   EXI_CR_READ_WRITE     (2<<2)
+#define   EXI_CR_TLEN(len)      (((len)-1)<<4)
+
+#define EXI_DATA                0x10
+
+
+/* virtual address base for input/output, retrieved from device tree */
+static void *ug_io_base;
+
+
+static u32 ug_io_transaction(u32 in)
+{
+       u32 *csr_reg = ug_io_base + EXI_CSR;
+       u32 *data_reg = ug_io_base + EXI_DATA;
+       u32 *cr_reg = ug_io_base + EXI_CR;
+       u32 csr, data, cr;
+
+       /* select */
+       csr = EXI_CSR_CLK_32MHZ | EXI_CSR_CS_0;
+       out_be32(csr_reg, csr);
+
+       /* read/write */
+       data = in;
+       out_be32(data_reg, data);
+       cr = EXI_CR_TLEN(2) | EXI_CR_READ_WRITE | EXI_CR_TSTART;
+       out_be32(cr_reg, cr);
+
+       while (in_be32(cr_reg) & EXI_CR_TSTART)
+               barrier();
+
+       /* deselect */
+       out_be32(csr_reg, 0);
+
+       data = in_be32(data_reg);
+       return data;
+}
+
+static int ug_is_txfifo_ready(void)
+{
+       return ug_io_transaction(0xc0000000) & 0x04000000;
+}
+
+static void ug_raw_putc(char ch)
+{
+       ug_io_transaction(0xb0000000 | (ch << 20));
+}
+
+static void ug_putc(char ch)
+{
+       int count = 16;
+
+       if (!ug_io_base)
+               return;
+
+       while (!ug_is_txfifo_ready() && count--)
+               barrier();
+       if (count >= 0)
+               ug_raw_putc(ch);
+}
+
+void ug_console_write(const char *buf, int len)
+{
+       char *b = (char *)buf;
+
+       while (len--) {
+               if (*b == '\n')
+                       ug_putc('\r');
+               ug_putc(*b++);
+       }
+}
+
+static int ug_is_adapter_present(void)
+{
+       if (!ug_io_base)
+               return 0;
+       return ug_io_transaction(0x90000000) == 0x04700000;
+}
+
+static void *ug_grab_exi_io_base(void)
+{
+       u32 v;
+       void *devp;
+
+       devp = find_node_by_compatible(NULL, "nintendo,flipper-exi");
+       if (devp == NULL)
+               goto err_out;
+       if (getprop(devp, "virtual-reg", &v, sizeof(v)) != sizeof(v))
+               goto err_out;
+
+       return (void *)v;
+
+err_out:
+       return NULL;
+}
+
+void *ug_probe(void)
+{
+       void *exi_io_base;
+       int i;
+
+       exi_io_base = ug_grab_exi_io_base();
+       if (!exi_io_base)
+               return NULL;
+
+       /* look for a usbgecko on memcard slots A and B */
+       for (i = 0; i < 2; i++) {
+               ug_io_base = exi_io_base + 0x14 * i;
+               if (ug_is_adapter_present())
+                       break;
+       }
+       if (i == 2)
+               ug_io_base = NULL;
+       return ug_io_base;
+}
+
diff --git a/arch/powerpc/boot/ugecon.h b/arch/powerpc/boot/ugecon.h
new file mode 100644 (file)
index 0000000..4373753
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * arch/powerpc/boot/ugecon.h
+ *
+ * USB Gecko early bootwrapper console.
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#ifndef __UGECON_H
+#define __UGECON_H
+
+extern void *ug_probe(void);
+
+extern void ug_putc(char ch);
+extern void ug_console_write(const char *buf, int len);
+
+#endif /* __UGECON_H */
+
diff --git a/arch/powerpc/boot/wii-head.S b/arch/powerpc/boot/wii-head.S
new file mode 100644 (file)
index 0000000..edd79b8
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * arch/powerpc/boot/wii-head.S
+ *
+ * Nintendo Wii bootwrapper entry.
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#include "ppc_asm.h"
+
+/*
+ * The entry code does no assumptions regarding:
+ * - if the data and instruction caches are enabled or not
+ * - if the MMU is enabled or not
+ * - if the high BATs are enabled or not
+ *
+ * We enable the high BATs, enable the caches if not already enabled,
+ * enable the MMU with an identity mapping scheme and jump to the start code.
+ */
+
+       .text
+
+       .globl _zimage_start
+_zimage_start:
+
+       /* turn the MMU off */
+       mfmsr   9
+       rlwinm  9, 9, 0, ~((1<<4)|(1<<5)) /* MSR_DR|MSR_IR */
+       bcl     20, 31, 1f
+1:
+       mflr    8
+       clrlwi  8, 8, 3         /* convert to a real address */
+       addi    8, 8, _mmu_off - 1b
+       mtsrr0  8
+       mtsrr1  9
+       rfi
+_mmu_off:
+       /* MMU disabled */
+
+       /* setup BATs */
+       isync
+       li      8, 0
+       mtspr   0x210, 8        /* IBAT0U */
+       mtspr   0x212, 8        /* IBAT1U */
+       mtspr   0x214, 8        /* IBAT2U */
+       mtspr   0x216, 8        /* IBAT3U */
+       mtspr   0x218, 8        /* DBAT0U */
+       mtspr   0x21a, 8        /* DBAT1U */
+       mtspr   0x21c, 8        /* DBAT2U */
+       mtspr   0x21e, 8        /* DBAT3U */
+
+       mtspr   0x230, 8        /* IBAT4U */
+       mtspr   0x232, 8        /* IBAT5U */
+       mtspr   0x234, 8        /* IBAT6U */
+       mtspr   0x236, 8        /* IBAT7U */
+       mtspr   0x238, 8        /* DBAT4U */
+       mtspr   0x23a, 8        /* DBAT5U */
+       mtspr   0x23c, 8        /* DBAT6U */
+       mtspr   0x23e, 8        /* DBAT7U */
+
+       li      8, 0x01ff       /* first 16MiB */
+       li      9, 0x0002       /* rw */
+       mtspr   0x211, 9        /* IBAT0L */
+       mtspr   0x210, 8        /* IBAT0U */
+       mtspr   0x219, 9        /* DBAT0L */
+       mtspr   0x218, 8        /* DBAT0U */
+
+       lis     8, 0x0c00       /* I/O mem */
+       ori     8, 8, 0x3ff     /* 32MiB */
+       lis     9, 0x0c00
+       ori     9, 9, 0x002a    /* uncached, guarded, rw */
+       mtspr   0x21b, 9        /* DBAT1L */
+       mtspr   0x21a, 8        /* DBAT1U */
+
+       lis     8, 0x0100       /* next 8MiB */
+       ori     8, 8, 0x00ff    /* 8MiB */
+       lis     9, 0x0100
+       ori     9, 9, 0x0002    /* rw */
+       mtspr   0x215, 9        /* IBAT2L */
+       mtspr   0x214, 8        /* IBAT2U */
+       mtspr   0x21d, 9        /* DBAT2L */
+       mtspr   0x21c, 8        /* DBAT2U */
+
+       lis     8, 0x1000       /* MEM2 */
+       ori     8, 8, 0x07ff    /* 64MiB */
+       lis     9, 0x1000
+       ori     9, 9, 0x0002    /* rw */
+       mtspr   0x216, 8        /* IBAT3U */
+       mtspr   0x217, 9        /* IBAT3L */
+       mtspr   0x21e, 8        /* DBAT3U */
+       mtspr   0x21f, 9        /* DBAT3L */
+
+       /* enable the high BATs */
+       mfspr   8, 0x3f3        /* HID4 */
+       oris    8, 8, 0x0200
+       mtspr   0x3f3, 8        /* HID4 */
+
+       /* enable and invalidate the caches if not already enabled */
+       mfspr   8, 0x3f0        /* HID0 */
+       andi.   0, 8, (1<<15)           /* HID0_ICE */
+       bne     1f
+       ori     8, 8, (1<<15)|(1<<11)   /* HID0_ICE|HID0_ICFI*/
+1:
+       andi.   0, 8, (1<<14)           /* HID0_DCE */
+       bne     1f
+       ori     8, 8, (1<<14)|(1<<10)   /* HID0_DCE|HID0_DCFI*/
+1:
+       mtspr   0x3f0, 8        /* HID0 */
+       isync
+
+       /* initialize arguments */
+       li      3, 0
+       li      4, 0
+       li      5, 0
+
+       /* turn the MMU on */
+       bcl     20, 31, 1f
+1:
+       mflr    8
+       addi    8, 8, _mmu_on - 1b
+       mfmsr   9
+       ori     9, 9, (1<<4)|(1<<5) /* MSR_DR|MSR_IR */
+       mtsrr0  8
+       mtsrr1  9
+       sync
+       rfi
+_mmu_on:
+       /* turn on the front blue led (aka: yay! we got here!) */
+       lis     8, 0x0d00
+       ori     8, 8, 0x00c0
+       lwz     9, 0(8)
+       ori     9, 9, 0x20
+       stw     9, 0(8)
+
+       b _zimage_start_lib
+
diff --git a/arch/powerpc/boot/wii.c b/arch/powerpc/boot/wii.c
new file mode 100644 (file)
index 0000000..2ebaec0
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+ * arch/powerpc/boot/wii.c
+ *
+ * Nintendo Wii bootwrapper support
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#include <stddef.h>
+#include "stdio.h"
+#include "types.h"
+#include "io.h"
+#include "ops.h"
+
+#include "ugecon.h"
+
+BSS_STACK(8192);
+
+#define HW_REG(x)              ((void *)(x))
+
+#define EXI_CTRL               HW_REG(0x0d800070)
+#define EXI_CTRL_ENABLE                (1<<0)
+
+#define MEM2_TOP               (0x10000000 + 64*1024*1024)
+#define FIRMWARE_DEFAULT_SIZE  (12*1024*1024)
+
+
+struct mipc_infohdr {
+       char magic[3];
+       u8 version;
+       u32 mem2_boundary;
+       u32 ipc_in;
+       size_t ipc_in_size;
+       u32 ipc_out;
+       size_t ipc_out_size;
+};
+
+static int mipc_check_address(u32 pa)
+{
+       /* only MEM2 addresses */
+       if (pa < 0x10000000 || pa > 0x14000000)
+               return -EINVAL;
+       return 0;
+}
+
+static struct mipc_infohdr *mipc_get_infohdr(void)
+{
+       struct mipc_infohdr **hdrp, *hdr;
+
+       /* 'mini' header pointer is the last word of MEM2 memory */
+       hdrp = (struct mipc_infohdr **)0x13fffffc;
+       if (mipc_check_address((u32)hdrp)) {
+               printf("mini: invalid hdrp %08X\n", (u32)hdrp);
+               hdr = NULL;
+               goto out;
+       }
+
+       hdr = *hdrp;
+       if (mipc_check_address((u32)hdr)) {
+               printf("mini: invalid hdr %08X\n", (u32)hdr);
+               hdr = NULL;
+               goto out;
+       }
+       if (memcmp(hdr->magic, "IPC", 3)) {
+               printf("mini: invalid magic\n");
+               hdr = NULL;
+               goto out;
+       }
+
+out:
+       return hdr;
+}
+
+static int mipc_get_mem2_boundary(u32 *mem2_boundary)
+{
+       struct mipc_infohdr *hdr;
+       int error;
+
+       hdr = mipc_get_infohdr();
+       if (!hdr) {
+               error = -1;
+               goto out;
+       }
+
+       if (mipc_check_address(hdr->mem2_boundary)) {
+               printf("mini: invalid mem2_boundary %08X\n",
+                      hdr->mem2_boundary);
+               error = -EINVAL;
+               goto out;
+       }
+       *mem2_boundary = hdr->mem2_boundary;
+       error = 0;
+out:
+       return error;
+
+}
+
+static void platform_fixups(void)
+{
+       void *mem;
+       u32 reg[4];
+       u32 mem2_boundary;
+       int len;
+       int error;
+
+       mem = finddevice("/memory");
+       if (!mem)
+               fatal("Can't find memory node\n");
+
+       /* two ranges of (address, size) words */
+       len = getprop(mem, "reg", reg, sizeof(reg));
+       if (len != sizeof(reg)) {
+               /* nothing to do */
+               goto out;
+       }
+
+       /* retrieve MEM2 boundary from 'mini' */
+       error = mipc_get_mem2_boundary(&mem2_boundary);
+       if (error) {
+               /* if that fails use a sane value */
+               mem2_boundary = MEM2_TOP - FIRMWARE_DEFAULT_SIZE;
+       }
+
+       if (mem2_boundary > reg[2] && mem2_boundary < reg[2] + reg[3]) {
+               reg[3] = mem2_boundary - reg[2];
+               printf("top of MEM2 @ %08X\n", reg[2] + reg[3]);
+               setprop(mem, "reg", reg, sizeof(reg));
+       }
+
+out:
+       return;
+}
+
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)
+{
+       u32 heapsize = 24*1024*1024 - (u32)_end;
+
+       simple_alloc_init(_end, heapsize, 32, 64);
+       fdt_init(_dtb_start);
+
+       /*
+        * 'mini' boots the Broadway processor with EXI disabled.
+        * We need it enabled before probing for the USB Gecko.
+        */
+       out_be32(EXI_CTRL, in_be32(EXI_CTRL) | EXI_CTRL_ENABLE);
+
+       if (ug_probe())
+               console_ops.write = ug_console_write;
+
+       platform_ops.fixups = platform_fixups;
+}
+
index ac9e9a58b2b0587bfa1a9c5aaa4a0190fbdfc326..390512ae7f86e087cf53ba765b038f17daa5e291 100755 (executable)
@@ -230,6 +230,10 @@ xpedite52*)
     link_address='0x1400000'
     platformo=$object/cuboot-85xx.o
     ;;
+gamecube|wii)
+    link_address='0x600000'
+    platformo="$object/$platform-head.o $object/$platform.o"
+    ;;
 esac
 
 vmz="$tmpdir/`basename \"$kernel\"`.$ext"
index fc905924c02299a525ed2effe5191f07c736878f..826a65d3f002ddb37d1f1f077888ab3b56839448 100644 (file)
@@ -757,7 +757,7 @@ CONFIG_SUNGEM=y
 # CONFIG_B44 is not set
 # CONFIG_ATL2 is not set
 CONFIG_NETDEV_1000=y
-CONFIG_ACENIC=y
+CONFIG_ACENIC=m
 CONFIG_ACENIC_OMIT_TIGON_I=y
 # CONFIG_DL2K is not set
 CONFIG_E1000=y
@@ -794,8 +794,8 @@ CONFIG_NETDEV_10000=y
 # CONFIG_BNX2X is not set
 # CONFIG_QLGE is not set
 # CONFIG_SFC is not set
-CONFIG_TR=y
-CONFIG_IBMOL=y
+# CONFIG_TR is not set
+# CONFIG_IBMOL is not set
 # CONFIG_3C359 is not set
 # CONFIG_TMS380TR is not set
 
diff --git a/arch/powerpc/configs/gamecube_defconfig b/arch/powerpc/configs/gamecube_defconfig
new file mode 100644 (file)
index 0000000..942e119
--- /dev/null
@@ -0,0 +1,1061 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.32-rc8
+# Sun Nov 22 21:07:30 2009
+#
+# CONFIG_PPC64 is not set
+
+#
+# Processor support
+#
+CONFIG_PPC_BOOK3S_32=y
+# CONFIG_PPC_85xx is not set
+# CONFIG_PPC_8xx is not set
+# CONFIG_40x is not set
+# CONFIG_44x is not set
+# CONFIG_E200 is not set
+CONFIG_PPC_BOOK3S=y
+CONFIG_6xx=y
+CONFIG_PPC_FPU=y
+# CONFIG_ALTIVEC is not set
+CONFIG_PPC_STD_MMU=y
+CONFIG_PPC_STD_MMU_32=y
+# CONFIG_PPC_MM_SLICES is not set
+CONFIG_PPC_HAVE_PMU_SUPPORT=y
+CONFIG_PPC_PERF_CTRS=y
+# CONFIG_SMP is not set
+CONFIG_NOT_COHERENT_CACHE=y
+CONFIG_PPC32=y
+CONFIG_WORD_SIZE=32
+# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
+CONFIG_MMU=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
+# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
+# CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK is not set
+CONFIG_IRQ_PER_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_ARCH_HAS_ILOG2_U32=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
+CONFIG_PPC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_OMIT_FRAME_POINTER=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_PPC_OF=y
+CONFIG_OF=y
+# CONFIG_PPC_UDBG_16550 is not set
+# CONFIG_GENERIC_TBSYNC is not set
+CONFIG_AUDIT_ARCH=y
+CONFIG_GENERIC_BUG=y
+CONFIG_DTC=y
+# CONFIG_DEFAULT_UIMAGE is not set
+# CONFIG_PPC_DCR_NATIVE is not set
+# CONFIG_PPC_DCR_MMIO is not set
+CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION="-gcn"
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_USER_SCHED=y
+# CONFIG_CGROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+# CONFIG_RELAY is not set
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+# CONFIG_ELF_CORE is not set
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+CONFIG_HAVE_PERF_EVENTS=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_PERF_EVENTS=y
+CONFIG_EVENT_PROFILE=y
+CONFIG_PERF_COUNTERS=y
+# CONFIG_DEBUG_PERF_USE_VMALLOC is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
+CONFIG_COMPAT_BRK=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_TRACEPOINTS=y
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_HAVE_IOREMAP_PROT=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_SLOW_WORK=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_BLOCK=y
+CONFIG_LBDAF=y
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+# CONFIG_FREEZER is not set
+
+#
+# Platform support
+#
+# CONFIG_PPC_CHRP is not set
+# CONFIG_MPC5121_ADS is not set
+# CONFIG_MPC5121_GENERIC is not set
+# CONFIG_PPC_MPC52xx is not set
+# CONFIG_PPC_PMAC is not set
+# CONFIG_PPC_CELL is not set
+# CONFIG_PPC_CELL_NATIVE is not set
+# CONFIG_PPC_82xx is not set
+# CONFIG_PQ2ADS is not set
+# CONFIG_PPC_83xx is not set
+# CONFIG_PPC_86xx is not set
+CONFIG_EMBEDDED6xx=y
+# CONFIG_LINKSTATION is not set
+# CONFIG_STORCENTER is not set
+# CONFIG_MPC7448HPC2 is not set
+# CONFIG_PPC_HOLLY is not set
+# CONFIG_PPC_PRPMC2800 is not set
+# CONFIG_PPC_C2K is not set
+CONFIG_GAMECUBE_COMMON=y
+CONFIG_USBGECKO_UDBG=y
+CONFIG_FLIPPER_PIC=y
+CONFIG_GAMECUBE=y
+# CONFIG_WII is not set
+# CONFIG_AMIGAONE is not set
+# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
+# CONFIG_IPIC is not set
+# CONFIG_MPIC is not set
+# CONFIG_MPIC_WEIRD is not set
+# CONFIG_PPC_I8259 is not set
+# CONFIG_PPC_RTAS is not set
+# CONFIG_MMIO_NVRAM is not set
+# CONFIG_PPC_MPC106 is not set
+# CONFIG_PPC_970_NAP is not set
+# CONFIG_PPC_INDIRECT_IO is not set
+# CONFIG_GENERIC_IOMAP is not set
+# CONFIG_CPU_FREQ is not set
+# CONFIG_TAU is not set
+# CONFIG_FSL_ULI1575 is not set
+# CONFIG_SIMPLE_GPIO is not set
+
+#
+# Kernel options
+#
+# CONFIG_HIGHMEM is not set
+# CONFIG_NO_HZ is not set
+# CONFIG_HIGH_RES_TIMERS is not set
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+# CONFIG_SCHED_HRTICK is not set
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+CONFIG_PREEMPT=y
+CONFIG_BINFMT_ELF=y
+# CONFIG_HAVE_AOUT is not set
+CONFIG_BINFMT_MISC=m
+# CONFIG_IOMMU_HELPER is not set
+# CONFIG_SWIOTLB is not set
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+CONFIG_ARCH_HAS_WALK_MEMORY=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
+CONFIG_KEXEC=y
+# CONFIG_CRASH_DUMP is not set
+CONFIG_MAX_ACTIVE_REGIONS=32
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_MIGRATION is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_PPC_4K_PAGES=y
+# CONFIG_PPC_16K_PAGES is not set
+# CONFIG_PPC_64K_PAGES is not set
+# CONFIG_PPC_256K_PAGES is not set
+CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_PROC_DEVICETREE=y
+# CONFIG_CMDLINE_BOOL is not set
+CONFIG_EXTRA_TARGETS=""
+# CONFIG_PM is not set
+# CONFIG_SECCOMP is not set
+CONFIG_ISA_DMA_API=y
+
+#
+# Bus options
+#
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+# CONFIG_PCI is not set
+# CONFIG_PCI_DOMAINS is not set
+# CONFIG_PCI_SYSCALL is not set
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+# CONFIG_HAS_RAPIDIO is not set
+
+#
+# Advanced setup
+#
+CONFIG_ADVANCED_OPTIONS=y
+# CONFIG_LOWMEM_SIZE_BOOL is not set
+CONFIG_LOWMEM_SIZE=0x30000000
+# CONFIG_PAGE_OFFSET_BOOL is not set
+CONFIG_PAGE_OFFSET=0xc0000000
+# CONFIG_KERNEL_START_BOOL is not set
+CONFIG_KERNEL_START=0xc0000000
+CONFIG_PHYSICAL_START=0x00000000
+# CONFIG_TASK_SIZE_BOOL is not set
+CONFIG_TASK_SIZE=0xc0000000
+# CONFIG_CONSISTENT_SIZE_BOOL is not set
+CONFIG_CONSISTENT_SIZE=0x00200000
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+CONFIG_IP_PNP_RARP=y
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_LRO is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NET_DROP_MONITOR is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_AF_RXRPC is not set
+# CONFIG_WIRELESS is not set
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+# CONFIG_MTD is not set
+CONFIG_OF_DEVICE=y
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=2
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_BLK_DEV_HD is not set
+CONFIG_MISC_DEVICES=y
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_93CX6 is not set
+CONFIG_HAVE_IDE=y
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+# CONFIG_SCSI_DMA is not set
+# CONFIG_SCSI_NETLINK is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+# CONFIG_MACINTOSH_DRIVERS is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+# CONFIG_PHYLIB is not set
+CONFIG_NET_ETHERNET=y
+# CONFIG_MII is not set
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851_MLL is not set
+# CONFIG_XILINX_EMACLITE is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+# CONFIG_WLAN is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+# CONFIG_INPUT_POLLDEV is not set
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+CONFIG_INPUT_JOYDEV=y
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_JOYSTICK=y
+# CONFIG_JOYSTICK_ANALOG is not set
+# CONFIG_JOYSTICK_A3D is not set
+# CONFIG_JOYSTICK_ADI is not set
+# CONFIG_JOYSTICK_COBRA is not set
+# CONFIG_JOYSTICK_GF2K is not set
+# CONFIG_JOYSTICK_GRIP is not set
+# CONFIG_JOYSTICK_GRIP_MP is not set
+# CONFIG_JOYSTICK_GUILLEMOT is not set
+# CONFIG_JOYSTICK_INTERACT is not set
+# CONFIG_JOYSTICK_SIDEWINDER is not set
+# CONFIG_JOYSTICK_TMDC is not set
+# CONFIG_JOYSTICK_IFORCE is not set
+# CONFIG_JOYSTICK_WARRIOR is not set
+# CONFIG_JOYSTICK_MAGELLAN is not set
+# CONFIG_JOYSTICK_SPACEORB is not set
+# CONFIG_JOYSTICK_SPACEBALL is not set
+# CONFIG_JOYSTICK_STINGER is not set
+# CONFIG_JOYSTICK_TWIDJOY is not set
+# CONFIG_JOYSTICK_ZHENHUA is not set
+# CONFIG_JOYSTICK_JOYDUMP is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_LIBPS2 is not set
+# CONFIG_SERIO_RAW is not set
+# CONFIG_SERIO_XILINX_XPS_PS2 is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+# CONFIG_DEVKMEM is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_UARTLITE is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=64
+# CONFIG_HVC_UDBG is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_NVRAM is not set
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+# CONFIG_I2C is not set
+# CONFIG_SPI is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+# CONFIG_GPIOLIB is not set
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+# CONFIG_SSB is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
+# CONFIG_FB_CFB_FILLRECT is not set
+# CONFIG_FB_CFB_COPYAREA is not set
+# CONFIG_FB_CFB_IMAGEBLIT is not set
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+# CONFIG_FB_SYS_FILLRECT is not set
+# CONFIG_FB_SYS_COPYAREA is not set
+# CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+# CONFIG_FB_SYS_FOPS is not set
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+# CONFIG_FB_OF is not set
+# CONFIG_FB_VGA16 is not set
+# CONFIG_FB_S1D13XXX is not set
+# CONFIG_FB_IBM_GXT4500 is not set
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+# CONFIG_LOGO_LINUX_CLUT224 is not set
+CONFIG_SOUND=y
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_SEQUENCER=y
+# CONFIG_SND_SEQ_DUMMY is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=y
+CONFIG_SND_PCM_OSS=y
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+# CONFIG_SND_DYNAMIC_MINORS is not set
+CONFIG_SND_SUPPORT_OLD_API=y
+# CONFIG_SND_VERBOSE_PROCFS is not set
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+CONFIG_SND_DRIVERS=y
+# CONFIG_SND_DUMMY is not set
+# CONFIG_SND_VIRMIDI is not set
+# CONFIG_SND_MTPAV is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+# CONFIG_SND_MPU401 is not set
+CONFIG_SND_PPC=y
+# CONFIG_SND_SOC is not set
+# CONFIG_SOUND_PRIME is not set
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+# CONFIG_HIDRAW is not set
+# CONFIG_HID_PID is not set
+
+#
+# Special HID drivers
+#
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
+# CONFIG_EDAC is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# SPI RTC drivers
+#
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_CMOS is not set
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_RTC_DRV_GENERIC=y
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+# CONFIG_EXT3_FS_XATTR is not set
+# CONFIG_EXT4_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+# CONFIG_ZISOFS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+# CONFIG_PROC_PAGE_MONITOR is not set
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=y
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_WEAK_PW_HASH is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_EXPERIMENTAL is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+# CONFIG_DLM is not set
+CONFIG_BINARY_PRINTF=y
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+CONFIG_CRC_CCITT=y
+# CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_HAVE_LMB=y
+CONFIG_NLATTR=y
+CONFIG_GENERIC_ATOMIC64=y
+
+#
+# Kernel hacking
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+# CONFIG_DETECT_HUNG_TASK is not set
+CONFIG_SCHED_DEBUG=y
+CONFIG_SCHEDSTATS=y
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KMEMLEAK is not set
+CONFIG_DEBUG_PREEMPT=y
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+CONFIG_DEBUG_SPINLOCK=y
+CONFIG_DEBUG_MUTEXES=y
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+CONFIG_DEBUG_SPINLOCK_SLEEP=y
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_FAULT_INJECTION is not set
+CONFIG_LATENCYTOP=y
+CONFIG_SYSCTL_SYSCALL_CHECK=y
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_NOP_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_TRACER_MAX_TRACE=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_TRACING=y
+CONFIG_GENERIC_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_PREEMPT_TRACER is not set
+CONFIG_SCHED_TRACER=y
+CONFIG_BOOT_TRACER=y
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_FTRACE_STARTUP_TEST is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+CONFIG_DMA_API_DEBUG=y
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_PPC_DISABLE_WERROR is not set
+CONFIG_PPC_WERROR=y
+CONFIG_PRINT_STACK_DEPTH=64
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_PPC_EMULATED_STATS is not set
+# CONFIG_CODE_PATCHING_SELFTEST is not set
+# CONFIG_FTR_FIXUP_SELFTEST is not set
+# CONFIG_MSI_BITMAP_SELFTEST is not set
+# CONFIG_XMON is not set
+# CONFIG_IRQSTACKS is not set
+# CONFIG_VIRQ_DEBUG is not set
+# CONFIG_BDI_SWITCH is not set
+# CONFIG_BOOTX_TEXT is not set
+CONFIG_PPC_EARLY_DEBUG=y
+# CONFIG_PPC_EARLY_DEBUG_LPAR is not set
+# CONFIG_PPC_EARLY_DEBUG_G5 is not set
+# CONFIG_PPC_EARLY_DEBUG_RTAS_PANEL is not set
+# CONFIG_PPC_EARLY_DEBUG_RTAS_CONSOLE is not set
+# CONFIG_PPC_EARLY_DEBUG_MAPLE is not set
+# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set
+# CONFIG_PPC_EARLY_DEBUG_PAS_REALMODE is not set
+# CONFIG_PPC_EARLY_DEBUG_BEAT is not set
+# CONFIG_PPC_EARLY_DEBUG_44x is not set
+# CONFIG_PPC_EARLY_DEBUG_40x is not set
+# CONFIG_PPC_EARLY_DEBUG_CPM is not set
+CONFIG_PPC_EARLY_DEBUG_USBGECKO=y
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+# CONFIG_CRYPTO is not set
+# CONFIG_PPC_CLOCK is not set
+# CONFIG_VIRTUALIZATION is not set
index f925c555508eaf412a239b9f6c788e88a61869c3..76982c51a4c793d3910ae09d5545b1f6f9114766 100644 (file)
@@ -714,8 +714,8 @@ CONFIG_NETDEV_10000=y
 # CONFIG_BNX2X is not set
 # CONFIG_QLGE is not set
 # CONFIG_SFC is not set
-CONFIG_TR=y
-CONFIG_IBMOL=y
+# CONFIG_TR is not set
+# CONFIG_IBMOL is not set
 # CONFIG_3C359 is not set
 # CONFIG_TMS380TR is not set
 
index 252401824575c0b6b8207bebd463db242c096bae..7b3804a6e363e10806b0a5fac0c72bc77c77cefc 100644 (file)
@@ -304,11 +304,11 @@ CONFIG_TICK_ONESHOT=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
-# CONFIG_HZ_100 is not set
-CONFIG_HZ_250=y
+CONFIG_HZ_100=y
+# CONFIG_HZ_250 is not set
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
-CONFIG_HZ=250
+CONFIG_HZ=100
 CONFIG_SCHED_HRTICK=y
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
@@ -980,7 +980,7 @@ CONFIG_E100=y
 # CONFIG_SC92031 is not set
 # CONFIG_ATL2 is not set
 CONFIG_NETDEV_1000=y
-CONFIG_ACENIC=y
+CONFIG_ACENIC=m
 CONFIG_ACENIC_OMIT_TIGON_I=y
 # CONFIG_DL2K is not set
 CONFIG_E1000=y
@@ -1023,8 +1023,8 @@ CONFIG_PASEMI_MAC=y
 # CONFIG_BNX2X is not set
 # CONFIG_QLGE is not set
 # CONFIG_SFC is not set
-CONFIG_TR=y
-CONFIG_IBMOL=y
+# CONFIG_TR is not set
+# CONFIG_IBMOL is not set
 # CONFIG_3C359 is not set
 # CONFIG_TMS380TR is not set
 
@@ -1863,7 +1863,7 @@ CONFIG_HFSPLUS_FS=m
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-CONFIG_CRAMFS=y
+CONFIG_CRAMFS=m
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_OMFS_FS is not set
index 18af460362580fbf4be9c4a86cbd9a38a78bbc5c..8195f1650cbfe0aaef708fd68f097316aca0e632 100644 (file)
@@ -1008,8 +1008,8 @@ CONFIG_IXGB=m
 # CONFIG_QLGE is not set
 # CONFIG_SFC is not set
 # CONFIG_BE2NET is not set
-CONFIG_TR=y
-CONFIG_IBMOL=y
+# CONFIG_TR is not set
+# CONFIG_IBMOL is not set
 # CONFIG_3C359 is not set
 # CONFIG_TMS380TR is not set
 CONFIG_WLAN=y
index c568329723b8d5371f9cb920dbd9f811af9bcb81..ca9ff9aad74a882a3de122f2ad2bffad17f4df88 100644 (file)
@@ -230,11 +230,11 @@ CONFIG_TICK_ONESHOT=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
-# CONFIG_HZ_100 is not set
-CONFIG_HZ_250=y
+CONFIG_HZ_100=y
+# CONFIG_HZ_250 is not set
 # CONFIG_HZ_300 is not set
 # CONFIG_HZ_1000 is not set
-CONFIG_HZ=250
+CONFIG_HZ=100
 CONFIG_SCHED_HRTICK=y
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
@@ -796,7 +796,7 @@ CONFIG_E100=y
 # CONFIG_NET_POCKET is not set
 # CONFIG_ATL2 is not set
 CONFIG_NETDEV_1000=y
-CONFIG_ACENIC=y
+CONFIG_ACENIC=m
 CONFIG_ACENIC_OMIT_TIGON_I=y
 # CONFIG_DL2K is not set
 CONFIG_E1000=y
@@ -834,8 +834,8 @@ CONFIG_S2IO=m
 # CONFIG_BNX2X is not set
 # CONFIG_QLGE is not set
 # CONFIG_SFC is not set
-CONFIG_TR=y
-CONFIG_IBMOL=y
+# CONFIG_TR is not set
+# CONFIG_IBMOL is not set
 # CONFIG_3C359 is not set
 # CONFIG_TMS380TR is not set
 
@@ -1494,7 +1494,7 @@ CONFIG_CONFIGFS_FS=m
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
-CONFIG_CRAMFS=y
+CONFIG_CRAMFS=m
 # CONFIG_VXFS_FS is not set
 # CONFIG_MINIX_FS is not set
 # CONFIG_OMFS_FS is not set
diff --git a/arch/powerpc/configs/wii_defconfig b/arch/powerpc/configs/wii_defconfig
new file mode 100644 (file)
index 0000000..c386828
--- /dev/null
@@ -0,0 +1,1406 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.32-rc8
+# Sun Nov 22 20:37:21 2009
+#
+# CONFIG_PPC64 is not set
+
+#
+# Processor support
+#
+CONFIG_PPC_BOOK3S_32=y
+# CONFIG_PPC_85xx is not set
+# CONFIG_PPC_8xx is not set
+# CONFIG_40x is not set
+# CONFIG_44x is not set
+# CONFIG_E200 is not set
+CONFIG_PPC_BOOK3S=y
+CONFIG_6xx=y
+CONFIG_PPC_FPU=y
+# CONFIG_ALTIVEC is not set
+CONFIG_PPC_STD_MMU=y
+CONFIG_PPC_STD_MMU_32=y
+# CONFIG_PPC_MM_SLICES is not set
+CONFIG_PPC_HAVE_PMU_SUPPORT=y
+CONFIG_PPC_PERF_CTRS=y
+# CONFIG_SMP is not set
+CONFIG_NOT_COHERENT_CACHE=y
+CONFIG_PPC32=y
+CONFIG_WORD_SIZE=32
+# CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set
+CONFIG_MMU=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
+# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
+# CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK is not set
+CONFIG_IRQ_PER_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_ARCH_HAS_ILOG2_U32=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_GPIO=y
+# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
+CONFIG_PPC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_OMIT_FRAME_POINTER=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_PPC_OF=y
+CONFIG_OF=y
+# CONFIG_PPC_UDBG_16550 is not set
+# CONFIG_GENERIC_TBSYNC is not set
+CONFIG_AUDIT_ARCH=y
+CONFIG_GENERIC_BUG=y
+CONFIG_DTC=y
+# CONFIG_DEFAULT_UIMAGE is not set
+# CONFIG_PPC_DCR_NATIVE is not set
+# CONFIG_PPC_DCR_MMIO is not set
+CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+CONFIG_CONSTRUCTORS=y
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION="-wii"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+# CONFIG_TASKSTATS is not set
+# CONFIG_AUDIT is not set
+
+#
+# RCU Subsystem
+#
+CONFIG_TREE_RCU=y
+# CONFIG_TREE_PREEMPT_RCU is not set
+# CONFIG_RCU_TRACE is not set
+CONFIG_RCU_FANOUT=32
+# CONFIG_RCU_FANOUT_EXACT is not set
+# CONFIG_TREE_RCU_TRACE is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+CONFIG_USER_SCHED=y
+# CONFIG_CGROUP_SCHED is not set
+# CONFIG_CGROUPS is not set
+CONFIG_SYSFS_DEPRECATED=y
+CONFIG_SYSFS_DEPRECATED_V2=y
+CONFIG_RELAY=y
+# CONFIG_NAMESPACES is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_RD_GZIP=y
+# CONFIG_RD_BZIP2 is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_SYSCTL=y
+CONFIG_ANON_INODES=y
+CONFIG_EMBEDDED=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+# CONFIG_ELF_CORE is not set
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_AIO=y
+CONFIG_HAVE_PERF_EVENTS=y
+
+#
+# Kernel Performance Events And Counters
+#
+CONFIG_PERF_EVENTS=y
+CONFIG_EVENT_PROFILE=y
+CONFIG_PERF_COUNTERS=y
+# CONFIG_DEBUG_PERF_USE_VMALLOC is not set
+# CONFIG_VM_EVENT_COUNTERS is not set
+CONFIG_COMPAT_BRK=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+# CONFIG_PROFILING is not set
+CONFIG_TRACEPOINTS=y
+CONFIG_HAVE_OPROFILE=y
+# CONFIG_KPROBES is not set
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_HAVE_IOREMAP_PROT=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_HAVE_DMA_API_DEBUG=y
+
+#
+# GCOV-based kernel profiling
+#
+# CONFIG_GCOV_KERNEL is not set
+CONFIG_SLOW_WORK=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+# CONFIG_MODULE_SRCVERSION_ALL is not set
+CONFIG_BLOCK=y
+CONFIG_LBDAF=y
+CONFIG_BLK_DEV_BSG=y
+# CONFIG_BLK_DEV_INTEGRITY is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+# CONFIG_FREEZER is not set
+
+#
+# Platform support
+#
+# CONFIG_PPC_CHRP is not set
+# CONFIG_MPC5121_ADS is not set
+# CONFIG_MPC5121_GENERIC is not set
+# CONFIG_PPC_MPC52xx is not set
+# CONFIG_PPC_PMAC is not set
+# CONFIG_PPC_CELL is not set
+# CONFIG_PPC_CELL_NATIVE is not set
+# CONFIG_PPC_82xx is not set
+# CONFIG_PQ2ADS is not set
+# CONFIG_PPC_83xx is not set
+# CONFIG_PPC_86xx is not set
+CONFIG_EMBEDDED6xx=y
+# CONFIG_LINKSTATION is not set
+# CONFIG_STORCENTER is not set
+# CONFIG_MPC7448HPC2 is not set
+# CONFIG_PPC_HOLLY is not set
+# CONFIG_PPC_PRPMC2800 is not set
+# CONFIG_PPC_C2K is not set
+CONFIG_GAMECUBE_COMMON=y
+CONFIG_USBGECKO_UDBG=y
+CONFIG_FLIPPER_PIC=y
+# CONFIG_GAMECUBE is not set
+CONFIG_HLWD_PIC=y
+CONFIG_STARLET_MINI=y
+CONFIG_WII=y
+# CONFIG_AMIGAONE is not set
+# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
+# CONFIG_IPIC is not set
+# CONFIG_MPIC is not set
+# CONFIG_MPIC_WEIRD is not set
+# CONFIG_PPC_I8259 is not set
+# CONFIG_PPC_RTAS is not set
+# CONFIG_MMIO_NVRAM is not set
+# CONFIG_PPC_MPC106 is not set
+# CONFIG_PPC_970_NAP is not set
+# CONFIG_PPC_INDIRECT_IO is not set
+# CONFIG_GENERIC_IOMAP is not set
+# CONFIG_CPU_FREQ is not set
+# CONFIG_TAU is not set
+# CONFIG_FSL_ULI1575 is not set
+# CONFIG_SIMPLE_GPIO is not set
+
+#
+# Kernel options
+#
+# CONFIG_HIGHMEM is not set
+# CONFIG_NO_HZ is not set
+# CONFIG_HIGH_RES_TIMERS is not set
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+# CONFIG_SCHED_HRTICK is not set
+# CONFIG_PREEMPT_NONE is not set
+# CONFIG_PREEMPT_VOLUNTARY is not set
+CONFIG_PREEMPT=y
+CONFIG_BINFMT_ELF=y
+# CONFIG_HAVE_AOUT is not set
+CONFIG_BINFMT_MISC=m
+# CONFIG_IOMMU_HELPER is not set
+# CONFIG_SWIOTLB is not set
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+CONFIG_ARCH_HAS_WALK_MEMORY=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
+CONFIG_KEXEC=y
+# CONFIG_CRASH_DUMP is not set
+CONFIG_MAX_ACTIVE_REGIONS=32
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_MIGRATION is not set
+# CONFIG_PHYS_ADDR_T_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_HAVE_MLOCK=y
+CONFIG_HAVE_MLOCKED_PAGE_BIT=y
+# CONFIG_KSM is not set
+CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
+CONFIG_PPC_4K_PAGES=y
+# CONFIG_PPC_16K_PAGES is not set
+# CONFIG_PPC_64K_PAGES is not set
+# CONFIG_PPC_256K_PAGES is not set
+CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_PROC_DEVICETREE=y
+# CONFIG_CMDLINE_BOOL is not set
+CONFIG_EXTRA_TARGETS=""
+# CONFIG_PM is not set
+# CONFIG_SECCOMP is not set
+CONFIG_ISA_DMA_API=y
+
+#
+# Bus options
+#
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+# CONFIG_PCI is not set
+# CONFIG_PCI_DOMAINS is not set
+# CONFIG_PCI_SYSCALL is not set
+# CONFIG_ARCH_SUPPORTS_MSI is not set
+# CONFIG_PCCARD is not set
+# CONFIG_HAS_RAPIDIO is not set
+
+#
+# Advanced setup
+#
+CONFIG_ADVANCED_OPTIONS=y
+# CONFIG_LOWMEM_SIZE_BOOL is not set
+CONFIG_LOWMEM_SIZE=0x30000000
+# CONFIG_PAGE_OFFSET_BOOL is not set
+CONFIG_PAGE_OFFSET=0xc0000000
+# CONFIG_KERNEL_START_BOOL is not set
+CONFIG_KERNEL_START=0xc0000000
+CONFIG_PHYSICAL_START=0x00000000
+# CONFIG_TASK_SIZE_BOOL is not set
+CONFIG_TASK_SIZE=0xc0000000
+# CONFIG_CONSISTENT_SIZE_BOOL is not set
+CONFIG_CONSISTENT_SIZE=0x00200000
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+CONFIG_IP_PNP_RARP=y
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
+# CONFIG_INET_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_LRO is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+# CONFIG_IPV6 is not set
+# CONFIG_NETWORK_SECMARK is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_IP_DCCP is not set
+# CONFIG_IP_SCTP is not set
+# CONFIG_RDS is not set
+# CONFIG_TIPC is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_NET_DSA is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_PHONET is not set
+# CONFIG_IEEE802154 is not set
+# CONFIG_NET_SCHED is not set
+# CONFIG_DCB is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NET_DROP_MONITOR is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+# CONFIG_IRDA is not set
+CONFIG_BT=y
+CONFIG_BT_L2CAP=y
+# CONFIG_BT_SCO is not set
+CONFIG_BT_RFCOMM=y
+# CONFIG_BT_RFCOMM_TTY is not set
+CONFIG_BT_BNEP=y
+CONFIG_BT_BNEP_MC_FILTER=y
+# CONFIG_BT_BNEP_PROTO_FILTER is not set
+CONFIG_BT_HIDP=y
+
+#
+# Bluetooth device drivers
+#
+# CONFIG_BT_HCIBTSDIO is not set
+# CONFIG_BT_HCIUART is not set
+# CONFIG_BT_HCIVHCI is not set
+# CONFIG_BT_MRVL is not set
+# CONFIG_AF_RXRPC is not set
+CONFIG_WIRELESS=y
+CONFIG_CFG80211=y
+# CONFIG_NL80211_TESTMODE is not set
+# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
+# CONFIG_CFG80211_REG_DEBUG is not set
+CONFIG_CFG80211_DEFAULT_PS=y
+CONFIG_CFG80211_DEFAULT_PS_VALUE=1
+# CONFIG_CFG80211_DEBUGFS is not set
+CONFIG_WIRELESS_OLD_REGULATORY=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+# CONFIG_LIB80211 is not set
+CONFIG_MAC80211=y
+# CONFIG_MAC80211_RC_PID is not set
+CONFIG_MAC80211_RC_MINSTREL=y
+# CONFIG_MAC80211_RC_DEFAULT_PID is not set
+CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
+CONFIG_MAC80211_RC_DEFAULT="minstrel"
+# CONFIG_MAC80211_MESH is not set
+# CONFIG_MAC80211_LEDS is not set
+# CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_MENU is not set
+# CONFIG_WIMAX is not set
+# CONFIG_RFKILL is not set
+# CONFIG_NET_9P is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+# CONFIG_DEVTMPFS is not set
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+# CONFIG_CONNECTOR is not set
+# CONFIG_MTD is not set
+CONFIG_OF_DEVICE=y
+CONFIG_OF_GPIO=y
+CONFIG_OF_I2C=y
+# CONFIG_PARPORT is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=2
+CONFIG_BLK_DEV_RAM_SIZE=4096
+# CONFIG_BLK_DEV_XIP is not set
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+# CONFIG_BLK_DEV_HD is not set
+CONFIG_MISC_DEVICES=y
+# CONFIG_ICS932S401 is not set
+# CONFIG_ENCLOSURE_SERVICES is not set
+# CONFIG_ISL29003 is not set
+# CONFIG_C2PORT is not set
+
+#
+# EEPROM support
+#
+# CONFIG_EEPROM_AT24 is not set
+# CONFIG_EEPROM_LEGACY is not set
+# CONFIG_EEPROM_MAX6875 is not set
+# CONFIG_EEPROM_93CX6 is not set
+CONFIG_HAVE_IDE=y
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+# CONFIG_SCSI_TGT is not set
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+CONFIG_SCSI_MULTI_LUN=y
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+# CONFIG_SCSI_SRP_ATTRS is not set
+CONFIG_SCSI_LOWLEVEL=y
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_LIBFC is not set
+# CONFIG_LIBFCOE is not set
+# CONFIG_SCSI_DEBUG is not set
+# CONFIG_SCSI_DH is not set
+# CONFIG_SCSI_OSD_INITIATOR is not set
+# CONFIG_ATA is not set
+# CONFIG_MD is not set
+# CONFIG_MACINTOSH_DRIVERS is not set
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_MACVLAN is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_VETH is not set
+# CONFIG_PHYLIB is not set
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+# CONFIG_ETHOC is not set
+# CONFIG_DNET is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
+# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
+# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
+# CONFIG_B44 is not set
+# CONFIG_KS8842 is not set
+# CONFIG_KS8851_MLL is not set
+# CONFIG_XILINX_EMACLITE is not set
+# CONFIG_NETDEV_1000 is not set
+# CONFIG_NETDEV_10000 is not set
+CONFIG_WLAN=y
+# CONFIG_WLAN_PRE80211 is not set
+CONFIG_WLAN_80211=y
+# CONFIG_LIBERTAS is not set
+# CONFIG_LIBERTAS_THINFIRM is not set
+# CONFIG_MAC80211_HWSIM is not set
+# CONFIG_P54_COMMON is not set
+# CONFIG_ATH_COMMON is not set
+# CONFIG_HOSTAP is not set
+CONFIG_B43=y
+CONFIG_B43_SDIO=y
+CONFIG_B43_PIO=y
+# CONFIG_B43_PHY_LP is not set
+CONFIG_B43_DEBUG=y
+# CONFIG_B43_FORCE_PIO is not set
+# CONFIG_B43LEGACY is not set
+# CONFIG_RT2X00 is not set
+# CONFIG_WL12XX is not set
+# CONFIG_IWM is not set
+
+#
+# Enable WiMAX (Networking options) to see the WiMAX drivers
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+# CONFIG_INPUT_POLLDEV is not set
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=640
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=480
+CONFIG_INPUT_JOYDEV=y
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+# CONFIG_KEYBOARD_ADP5588 is not set
+# CONFIG_KEYBOARD_ATKBD is not set
+# CONFIG_QT2160 is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_GPIO is not set
+# CONFIG_KEYBOARD_MATRIX is not set
+# CONFIG_KEYBOARD_MAX7359 is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_OPENCORES is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+CONFIG_INPUT_MOUSE=y
+# CONFIG_MOUSE_PS2 is not set
+# CONFIG_MOUSE_SERIAL is not set
+# CONFIG_MOUSE_VSXXXAA is not set
+# CONFIG_MOUSE_GPIO is not set
+# CONFIG_MOUSE_SYNAPTICS_I2C is not set
+CONFIG_INPUT_JOYSTICK=y
+# CONFIG_JOYSTICK_ANALOG is not set
+# CONFIG_JOYSTICK_A3D is not set
+# CONFIG_JOYSTICK_ADI is not set
+# CONFIG_JOYSTICK_COBRA is not set
+# CONFIG_JOYSTICK_GF2K is not set
+# CONFIG_JOYSTICK_GRIP is not set
+# CONFIG_JOYSTICK_GRIP_MP is not set
+# CONFIG_JOYSTICK_GUILLEMOT is not set
+# CONFIG_JOYSTICK_INTERACT is not set
+# CONFIG_JOYSTICK_SIDEWINDER is not set
+# CONFIG_JOYSTICK_TMDC is not set
+# CONFIG_JOYSTICK_IFORCE is not set
+# CONFIG_JOYSTICK_WARRIOR is not set
+# CONFIG_JOYSTICK_MAGELLAN is not set
+# CONFIG_JOYSTICK_SPACEORB is not set
+# CONFIG_JOYSTICK_SPACEBALL is not set
+# CONFIG_JOYSTICK_STINGER is not set
+# CONFIG_JOYSTICK_TWIDJOY is not set
+# CONFIG_JOYSTICK_ZHENHUA is not set
+# CONFIG_JOYSTICK_JOYDUMP is not set
+# CONFIG_INPUT_TABLET is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_UINPUT=y
+# CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+# CONFIG_SERIO_I8042 is not set
+# CONFIG_SERIO_SERPORT is not set
+# CONFIG_SERIO_LIBPS2 is not set
+# CONFIG_SERIO_RAW is not set
+# CONFIG_SERIO_XILINX_XPS_PS2 is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
+# CONFIG_DEVKMEM is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_8250 is not set
+
+#
+# Non-8250 serial port support
+#
+# CONFIG_SERIAL_UARTLITE is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=64
+# CONFIG_HVC_UDBG is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_HW_RANDOM is not set
+CONFIG_NVRAM=y
+# CONFIG_R3964 is not set
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_COMPAT=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=y
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+CONFIG_I2C_GPIO=y
+# CONFIG_I2C_MPC is not set
+# CONFIG_I2C_OCORES is not set
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+# CONFIG_I2C_PARPORT_LIGHT is not set
+# CONFIG_I2C_TAOS_EVM is not set
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_PCA_PLATFORM is not set
+# CONFIG_I2C_STUB is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_DS1682 is not set
+# CONFIG_SENSORS_TSL2550 is not set
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+# CONFIG_SPI is not set
+
+#
+# PPS support
+#
+# CONFIG_PPS is not set
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# Memory mapped GPIO expanders:
+#
+# CONFIG_GPIO_XILINX is not set
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_MAX732X is not set
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCF857X is not set
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+
+#
+# AC97 GPIO expanders:
+#
+# CONFIG_W1 is not set
+# CONFIG_POWER_SUPPLY is not set
+# CONFIG_HWMON is not set
+# CONFIG_THERMAL is not set
+# CONFIG_WATCHDOG is not set
+CONFIG_SSB_POSSIBLE=y
+
+#
+# Sonics Silicon Backplane
+#
+CONFIG_SSB=y
+CONFIG_SSB_BLOCKIO=y
+CONFIG_SSB_SDIOHOST_POSSIBLE=y
+CONFIG_SSB_SDIOHOST=y
+# CONFIG_SSB_SILENT is not set
+CONFIG_SSB_DEBUG=y
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+# CONFIG_MFD_SM501 is not set
+# CONFIG_HTC_PASIC3 is not set
+# CONFIG_TPS65010 is not set
+# CONFIG_TWL4030_CORE is not set
+# CONFIG_MFD_TMIO is not set
+# CONFIG_PMIC_DA903X is not set
+# CONFIG_MFD_WM8400 is not set
+# CONFIG_MFD_WM831X is not set
+# CONFIG_MFD_WM8350_I2C is not set
+# CONFIG_MFD_PCF50633 is not set
+# CONFIG_AB3100_CORE is not set
+# CONFIG_REGULATOR is not set
+# CONFIG_MEDIA_SUPPORT is not set
+
+#
+# Graphics support
+#
+# CONFIG_VGASTATE is not set
+# CONFIG_VIDEO_OUTPUT_CONTROL is not set
+CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB_DDC is not set
+# CONFIG_FB_BOOT_VESA_SUPPORT is not set
+# CONFIG_FB_CFB_FILLRECT is not set
+# CONFIG_FB_CFB_COPYAREA is not set
+# CONFIG_FB_CFB_IMAGEBLIT is not set
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+# CONFIG_FB_SYS_FILLRECT is not set
+# CONFIG_FB_SYS_COPYAREA is not set
+# CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+# CONFIG_FB_SYS_FOPS is not set
+# CONFIG_FB_SVGALIB is not set
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+# CONFIG_FB_MODE_HELPERS is not set
+# CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frame buffer hardware drivers
+#
+# CONFIG_FB_OF is not set
+# CONFIG_FB_VGA16 is not set
+# CONFIG_FB_S1D13XXX is not set
+# CONFIG_FB_IBM_GXT4500 is not set
+# CONFIG_FB_VIRTUAL is not set
+# CONFIG_FB_METRONOME is not set
+# CONFIG_FB_MB862XX is not set
+# CONFIG_FB_BROADSHEET is not set
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
+
+#
+# Display device support
+#
+# CONFIG_DISPLAY_SUPPORT is not set
+
+#
+# Console display driver support
+#
+# CONFIG_VGA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+# CONFIG_LOGO is not set
+CONFIG_SOUND=y
+CONFIG_SOUND_OSS_CORE=y
+CONFIG_SOUND_OSS_CORE_PRECLAIM=y
+CONFIG_SND=y
+CONFIG_SND_TIMER=y
+CONFIG_SND_PCM=y
+CONFIG_SND_SEQUENCER=y
+# CONFIG_SND_SEQ_DUMMY is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=y
+CONFIG_SND_PCM_OSS=y
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+# CONFIG_SND_DYNAMIC_MINORS is not set
+CONFIG_SND_SUPPORT_OLD_API=y
+# CONFIG_SND_VERBOSE_PROCFS is not set
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+# CONFIG_SND_RAWMIDI_SEQ is not set
+# CONFIG_SND_OPL3_LIB_SEQ is not set
+# CONFIG_SND_OPL4_LIB_SEQ is not set
+# CONFIG_SND_SBAWE_SEQ is not set
+# CONFIG_SND_EMU10K1_SEQ is not set
+CONFIG_SND_DRIVERS=y
+# CONFIG_SND_DUMMY is not set
+# CONFIG_SND_VIRMIDI is not set
+# CONFIG_SND_MTPAV is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+# CONFIG_SND_MPU401 is not set
+CONFIG_SND_PPC=y
+# CONFIG_SND_SOC is not set
+# CONFIG_SOUND_PRIME is not set
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+# CONFIG_HIDRAW is not set
+# CONFIG_HID_PID is not set
+
+#
+# Special HID drivers
+#
+CONFIG_HID_APPLE=m
+CONFIG_HID_WACOM=m
+CONFIG_USB_SUPPORT=y
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+# CONFIG_USB_ARCH_HAS_EHCI is not set
+# CONFIG_USB_OTG_WHITELIST is not set
+# CONFIG_USB_OTG_BLACKLIST_HUB is not set
+
+#
+# Enable Host or Gadget support to see Inventra options
+#
+
+#
+# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# OTG and related infrastructure
+#
+CONFIG_MMC=y
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD/SDIO Card Drivers
+#
+CONFIG_MMC_BLOCK=y
+CONFIG_MMC_BLOCK_BOUNCE=y
+# CONFIG_SDIO_UART is not set
+# CONFIG_MMC_TEST is not set
+
+#
+# MMC/SD/SDIO Host Controller Drivers
+#
+CONFIG_MMC_SDHCI=y
+# CONFIG_MMC_SDHCI_OF is not set
+# CONFIG_MMC_SDHCI_PLTFM is not set
+# CONFIG_MMC_WBSD is not set
+# CONFIG_MMC_AT91 is not set
+# CONFIG_MMC_ATMELMCI is not set
+# CONFIG_MEMSTICK is not set
+# CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
+# CONFIG_EDAC is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+# CONFIG_RTC_DRV_DS1307 is not set
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+# CONFIG_RTC_DRV_RX8581 is not set
+# CONFIG_RTC_DRV_RX8025 is not set
+
+#
+# SPI RTC drivers
+#
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_CMOS is not set
+# CONFIG_RTC_DRV_DS1286 is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T35 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_BQ4802 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_RTC_DRV_GENERIC=y
+# CONFIG_DMADEVICES is not set
+# CONFIG_AUXDISPLAY is not set
+# CONFIG_UIO is not set
+
+#
+# TI VLYNQ
+#
+# CONFIG_STAGING is not set
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
+# CONFIG_EXT3_FS_XATTR is not set
+# CONFIG_EXT4_FS is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_BTRFS_FS is not set
+# CONFIG_NILFS2_FS is not set
+CONFIG_FILE_LOCKING=y
+CONFIG_FSNOTIFY=y
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+# CONFIG_QUOTA is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+CONFIG_FUSE_FS=m
+# CONFIG_CUSE is not set
+
+#
+# Caches
+#
+# CONFIG_FSCACHE is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+# CONFIG_ZISOFS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+# CONFIG_PROC_PAGE_MONITOR is not set
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_TMPFS_POSIX_ACL is not set
+# CONFIG_HUGETLB_PAGE is not set
+# CONFIG_CONFIGFS_FS is not set
+CONFIG_MISC_FILESYSTEMS=y
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_SQUASHFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_OMFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_ROMFS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_V3_ACL is not set
+# CONFIG_NFS_V4 is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+# CONFIG_CIFS_WEAK_PW_HASH is not set
+# CONFIG_CIFS_XATTR is not set
+# CONFIG_CIFS_DEBUG2 is not set
+# CONFIG_CIFS_EXPERIMENTAL is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
+# CONFIG_DLM is not set
+CONFIG_BINARY_PRINTF=y
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_LAST_BIT=y
+CONFIG_CRC_CCITT=y
+CONFIG_CRC16=y
+# CONFIG_CRC_T10DIF is not set
+# CONFIG_CRC_ITU_T is not set
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+# CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=y
+CONFIG_DECOMPRESS_GZIP=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_HAVE_LMB=y
+CONFIG_NLATTR=y
+CONFIG_GENERIC_ATOMIC64=y
+
+#
+# Kernel hacking
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_ENABLE_WARN_DEPRECATED=y
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_STRIP_ASM_SYMS is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
+CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
+# CONFIG_DETECT_HUNG_TASK is not set
+CONFIG_SCHED_DEBUG=y
+CONFIG_SCHEDSTATS=y
+# CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_KMEMLEAK is not set
+CONFIG_DEBUG_PREEMPT=y
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+CONFIG_DEBUG_SPINLOCK=y
+CONFIG_DEBUG_MUTEXES=y
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+CONFIG_DEBUG_SPINLOCK_SLEEP=y
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+# CONFIG_DEBUG_MEMORY_INIT is not set
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_DEBUG_NOTIFIERS is not set
+# CONFIG_DEBUG_CREDENTIALS is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_RCU_CPU_STALL_DETECTOR is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
+# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
+# CONFIG_FAULT_INJECTION is not set
+CONFIG_LATENCYTOP=y
+CONFIG_SYSCTL_SYSCALL_CHECK=y
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_NOP_TRACER=y
+CONFIG_HAVE_FUNCTION_TRACER=y
+CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
+CONFIG_TRACER_MAX_TRACE=y
+CONFIG_RING_BUFFER=y
+CONFIG_EVENT_TRACING=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_TRACING=y
+CONFIG_GENERIC_TRACER=y
+CONFIG_TRACING_SUPPORT=y
+CONFIG_FTRACE=y
+# CONFIG_FUNCTION_TRACER is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_PREEMPT_TRACER is not set
+CONFIG_SCHED_TRACER=y
+CONFIG_BOOT_TRACER=y
+CONFIG_BRANCH_PROFILE_NONE=y
+# CONFIG_PROFILE_ANNOTATED_BRANCHES is not set
+# CONFIG_PROFILE_ALL_BRANCHES is not set
+# CONFIG_STACK_TRACER is not set
+# CONFIG_KMEMTRACE is not set
+# CONFIG_WORKQUEUE_TRACER is not set
+CONFIG_BLK_DEV_IO_TRACE=y
+# CONFIG_FTRACE_STARTUP_TEST is not set
+# CONFIG_RING_BUFFER_BENCHMARK is not set
+# CONFIG_DYNAMIC_DEBUG is not set
+CONFIG_DMA_API_DEBUG=y
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_PPC_DISABLE_WERROR is not set
+CONFIG_PPC_WERROR=y
+CONFIG_PRINT_STACK_DEPTH=64
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_PPC_EMULATED_STATS is not set
+# CONFIG_CODE_PATCHING_SELFTEST is not set
+# CONFIG_FTR_FIXUP_SELFTEST is not set
+# CONFIG_MSI_BITMAP_SELFTEST is not set
+# CONFIG_XMON is not set
+# CONFIG_IRQSTACKS is not set
+# CONFIG_VIRQ_DEBUG is not set
+# CONFIG_BDI_SWITCH is not set
+# CONFIG_BOOTX_TEXT is not set
+CONFIG_PPC_EARLY_DEBUG=y
+# CONFIG_PPC_EARLY_DEBUG_LPAR is not set
+# CONFIG_PPC_EARLY_DEBUG_G5 is not set
+# CONFIG_PPC_EARLY_DEBUG_RTAS_PANEL is not set
+# CONFIG_PPC_EARLY_DEBUG_RTAS_CONSOLE is not set
+# CONFIG_PPC_EARLY_DEBUG_MAPLE is not set
+# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set
+# CONFIG_PPC_EARLY_DEBUG_PAS_REALMODE is not set
+# CONFIG_PPC_EARLY_DEBUG_BEAT is not set
+# CONFIG_PPC_EARLY_DEBUG_44x is not set
+# CONFIG_PPC_EARLY_DEBUG_40x is not set
+# CONFIG_PPC_EARLY_DEBUG_CPM is not set
+CONFIG_PPC_EARLY_DEBUG_USBGECKO=y
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+# CONFIG_SECURITYFS is not set
+# CONFIG_SECURITY_FILE_CAPABILITIES is not set
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_ALGAPI2=y
+CONFIG_CRYPTO_AEAD2=y
+CONFIG_CRYPTO_BLKCIPHER=y
+CONFIG_CRYPTO_BLKCIPHER2=y
+CONFIG_CRYPTO_HASH2=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_PCOMP=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_MANAGER2=y
+# CONFIG_CRYPTO_GF128MUL is not set
+# CONFIG_CRYPTO_NULL is not set
+CONFIG_CRYPTO_WORKQUEUE=y
+# CONFIG_CRYPTO_CRYPTD is not set
+# CONFIG_CRYPTO_AUTHENC is not set
+# CONFIG_CRYPTO_TEST is not set
+
+#
+# Authenticated Encryption with Associated Data
+#
+# CONFIG_CRYPTO_CCM is not set
+# CONFIG_CRYPTO_GCM is not set
+# CONFIG_CRYPTO_SEQIV is not set
+
+#
+# Block modes
+#
+# CONFIG_CRYPTO_CBC is not set
+# CONFIG_CRYPTO_CTR is not set
+# CONFIG_CRYPTO_CTS is not set
+CONFIG_CRYPTO_ECB=y
+# CONFIG_CRYPTO_LRW is not set
+# CONFIG_CRYPTO_PCBC is not set
+# CONFIG_CRYPTO_XTS is not set
+
+#
+# Hash modes
+#
+# CONFIG_CRYPTO_HMAC is not set
+# CONFIG_CRYPTO_XCBC is not set
+# CONFIG_CRYPTO_VMAC is not set
+
+#
+# Digest
+#
+# CONFIG_CRYPTO_CRC32C is not set
+# CONFIG_CRYPTO_GHASH is not set
+# CONFIG_CRYPTO_MD4 is not set
+# CONFIG_CRYPTO_MD5 is not set
+# CONFIG_CRYPTO_MICHAEL_MIC is not set
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
+# CONFIG_CRYPTO_SHA1 is not set
+# CONFIG_CRYPTO_SHA256 is not set
+# CONFIG_CRYPTO_SHA512 is not set
+# CONFIG_CRYPTO_TGR192 is not set
+# CONFIG_CRYPTO_WP512 is not set
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=y
+# CONFIG_CRYPTO_ANUBIS is not set
+CONFIG_CRYPTO_ARC4=y
+# CONFIG_CRYPTO_BLOWFISH is not set
+# CONFIG_CRYPTO_CAMELLIA is not set
+# CONFIG_CRYPTO_CAST5 is not set
+# CONFIG_CRYPTO_CAST6 is not set
+# CONFIG_CRYPTO_DES is not set
+# CONFIG_CRYPTO_FCRYPT is not set
+# CONFIG_CRYPTO_KHAZAD is not set
+# CONFIG_CRYPTO_SALSA20 is not set
+# CONFIG_CRYPTO_SEED is not set
+# CONFIG_CRYPTO_SERPENT is not set
+# CONFIG_CRYPTO_TEA is not set
+# CONFIG_CRYPTO_TWOFISH is not set
+
+#
+# Compression
+#
+# CONFIG_CRYPTO_DEFLATE is not set
+# CONFIG_CRYPTO_ZLIB is not set
+# CONFIG_CRYPTO_LZO is not set
+
+#
+# Random Number Generation
+#
+# CONFIG_CRYPTO_ANSI_CPRNG is not set
+# CONFIG_CRYPTO_HW is not set
+# CONFIG_PPC_CLOCK is not set
+# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/powerpc/include/asm/asm-offsets.h b/arch/powerpc/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
diff --git a/arch/powerpc/include/asm/async_tx.h b/arch/powerpc/include/asm/async_tx.h
new file mode 100644 (file)
index 0000000..8b2dc55
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008-2009 DENX Software Engineering.
+ *
+ * Author: Yuri Tikhonov <yur@emcraft.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+#ifndef _ASM_POWERPC_ASYNC_TX_H_
+#define _ASM_POWERPC_ASYNC_TX_H_
+
+#if defined(CONFIG_440SPe) || defined(CONFIG_440SP)
+extern struct dma_chan *
+ppc440spe_async_tx_find_best_channel(enum dma_transaction_type cap,
+       struct page **dst_lst, int dst_cnt, struct page **src_lst,
+       int src_cnt, size_t src_sz);
+
+#define async_tx_find_channel(dep, cap, dst_lst, dst_cnt, src_lst, \
+                             src_cnt, src_sz) \
+       ppc440spe_async_tx_find_best_channel(cap, dst_lst, dst_cnt, src_lst, \
+                                            src_cnt, src_sz)
+#else
+
+#define async_tx_find_channel(dep, type, dst, dst_count, src, src_count, len) \
+       __async_tx_find_channel(dep, type)
+
+struct dma_chan *
+__async_tx_find_channel(struct async_submit_ctl *submit,
+                       enum dma_transaction_type tx_type);
+
+#endif
+
+#endif
index 64e1fdca233e065a0b3208517917a4e6103e6a21..2c15212e1700d5418802f1ccf6f85a142e2251d8 100644 (file)
@@ -68,7 +68,7 @@
                _EMIT_BUG_ENTRY                                 \
                : : "i" (__FILE__), "i" (__LINE__),             \
                    "i" (0), "i"  (sizeof(struct bug_entry)));  \
-       for(;;) ;                                               \
+       unreachable();                                          \
 } while (0)
 
 #define BUG_ON(x) do {                                         \
index 828e3aa1f2fcb007aa8ec4ace12004fffd36b74e..380274de429ff6e77c36c12a7a1931d2a604103c 100644 (file)
 #define  L2C_SNP_SSR_32G       0x0000f000
 #define  L2C_SNP_ESR           0x00000800
 
+/*
+ * DCR register offsets for 440SP/440SPe I2O/DMA controller.
+ * The base address is configured in the device tree.
+ */
+#define DCRN_I2O0_IBAL         0x006
+#define DCRN_I2O0_IBAH         0x007
+#define I2O_REG_ENABLE         0x00000001      /* Enable I2O/DMA access */
+
+/* 440SP/440SPe Software Reset DCR */
+#define DCRN_SDR0_SRST         0x0200
+#define DCRN_SDR0_SRST_I2ODMA  (0x80000000 >> 15)      /* Reset I2O/DMA */
+
+/* 440SP/440SPe Memory Queue DCR offsets */
+#define DCRN_MQ0_XORBA         0x04
+#define DCRN_MQ0_CF2H          0x06
+#define DCRN_MQ0_CFBHL         0x0f
+#define DCRN_MQ0_BAUH          0x10
+
+/* HB/LL Paths Configuration Register */
+#define MQ0_CFBHL_TPLM         28
+#define MQ0_CFBHL_HBCL         23
+#define MQ0_CFBHL_POLY         15
+
 #endif /* __DCR_REGS_H__ */
index e281daebddca317e10c1263c3d7cccf93dcb5538..80a973bb9e71397a7f65497d034d9eb7f7958a62 100644 (file)
@@ -197,7 +197,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
        if (!dev->dma_mask)
                return 0;
 
-       return addr + size <= *dev->dma_mask;
+       return addr + size - 1 <= *dev->dma_mask;
 }
 
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
index 014a624f4c8efb054bd46da4e5711713b3e76b68..17828ad411ebbecdb920a1cbdd8ee44886b669af 100644 (file)
@@ -170,7 +170,6 @@ typedef elf_fpreg_t elf_vsrreghalf_t32[ELF_NVSRHALFREG];
 #define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
 #define compat_elf_check_arch(x)       ((x)->e_machine == EM_PPC)
 
-#define USE_ELF_CORE_DUMP
 #define CORE_DUMP_USE_REGSET
 #define ELF_EXEC_PAGESIZE      PAGE_SIZE
 
index f1f4e23a84e930711c840f71128a5db0724d56d3..5c2c0233175e7837b4b2a154003fba67b2166da2 100644 (file)
@@ -44,6 +44,9 @@
  */
 enum fixed_addresses {
        FIX_HOLE,
+       /* reserve the top 128K for early debugging purposes */
+       FIX_EARLY_DEBUG_TOP = FIX_HOLE,
+       FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+((128*1024)/PAGE_SIZE)-1,
 #ifdef CONFIG_HIGHMEM
        FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
        FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
index ea04632399d8d25f8cf5e4f4720c28bd7dbbaef9..38762edb5e5804e714a81aa223b6ce8d338336ca 100644 (file)
@@ -38,12 +38,9 @@ static inline int gpio_cansleep(unsigned int gpio)
        return __gpio_cansleep(gpio);
 }
 
-/*
- * Not implemented, yet.
- */
 static inline int gpio_to_irq(unsigned int gpio)
 {
-       return -ENOSYS;
+       return __gpio_to_irq(gpio);
 }
 
 static inline int irq_to_gpio(unsigned int irq)
index 08454880a2c047258da91b4968f080f4e38fc4af..0192a4ee2bc2b65354778a6ec2392f6cab5cddba 100644 (file)
@@ -87,5 +87,10 @@ struct exception_table_entry;
 void sort_ex_table(struct exception_table_entry *start,
                   struct exception_table_entry *finish);
 
+#ifdef CONFIG_MODVERSIONS
+#define ARCH_RELOCATES_KCRCTAB
+
+extern const unsigned long reloc_start[];
+#endif
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_MODULE_H */
index 8c341490cfc5a9843719bb50a4590d3df24b024c..cbd759e3cd7879d106eec0dea779e40f1790f97b 100644 (file)
@@ -140,6 +140,8 @@ extern void user_enable_single_step(struct task_struct *);
 extern void user_enable_block_step(struct task_struct *);
 extern void user_disable_single_step(struct task_struct *);
 
+#define ARCH_HAS_USER_SINGLE_STEP_INFO
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __KERNEL__ */
index 168fce726201d3799fc3878e3a7620e1575a6dfd..20de73c36682e6cb7e75dbc2889a8304cc55afd7 100644 (file)
@@ -58,7 +58,7 @@ struct rtas_t {
        unsigned long entry;            /* physical address pointer */
        unsigned long base;             /* physical address pointer */
        unsigned long size;
-       raw_spinlock_t lock;
+       arch_spinlock_t lock;
        struct rtas_args args;
        struct device_node *dev;        /* virtual address pointer */
 };
index 198266cf9e2d2c95326d5ec9416bc6a2067d2fed..764094cff68172609db5ce6d4e05a1a2b8229598 100644 (file)
@@ -28,7 +28,7 @@
 #include <asm/asm-compat.h>
 #include <asm/synch.h>
 
-#define __raw_spin_is_locked(x)                ((x)->slock != 0)
+#define arch_spin_is_locked(x)         ((x)->slock != 0)
 
 #ifdef CONFIG_PPC64
 /* use 0x800000yy when locked, where yy == CPU number */
@@ -54,7 +54,7 @@
  * This returns the old value in the lock, so we succeeded
  * in getting the lock if the return value is 0.
  */
-static inline unsigned long arch_spin_trylock(raw_spinlock_t *lock)
+static inline unsigned long __arch_spin_trylock(arch_spinlock_t *lock)
 {
        unsigned long tmp, token;
 
@@ -73,10 +73,10 @@ static inline unsigned long arch_spin_trylock(raw_spinlock_t *lock)
        return tmp;
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        CLEAR_IO_SYNC;
-       return arch_spin_trylock(lock) == 0;
+       return __arch_spin_trylock(lock) == 0;
 }
 
 /*
@@ -96,19 +96,19 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
 #if defined(CONFIG_PPC_SPLPAR) || defined(CONFIG_PPC_ISERIES)
 /* We only yield to the hypervisor if we are in shared processor mode */
 #define SHARED_PROCESSOR (get_lppaca()->shared_proc)
-extern void __spin_yield(raw_spinlock_t *lock);
-extern void __rw_yield(raw_rwlock_t *lock);
+extern void __spin_yield(arch_spinlock_t *lock);
+extern void __rw_yield(arch_rwlock_t *lock);
 #else /* SPLPAR || ISERIES */
 #define __spin_yield(x)        barrier()
 #define __rw_yield(x)  barrier()
 #define SHARED_PROCESSOR       0
 #endif
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        CLEAR_IO_SYNC;
        while (1) {
-               if (likely(arch_spin_trylock(lock) == 0))
+               if (likely(__arch_spin_trylock(lock) == 0))
                        break;
                do {
                        HMT_low();
@@ -120,13 +120,13 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
 }
 
 static inline
-void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
+void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
 {
        unsigned long flags_dis;
 
        CLEAR_IO_SYNC;
        while (1) {
-               if (likely(arch_spin_trylock(lock) == 0))
+               if (likely(__arch_spin_trylock(lock) == 0))
                        break;
                local_save_flags(flags_dis);
                local_irq_restore(flags);
@@ -140,19 +140,19 @@ void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
        }
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        SYNC_IO;
-       __asm__ __volatile__("# __raw_spin_unlock\n\t"
+       __asm__ __volatile__("# arch_spin_unlock\n\t"
                                LWSYNC_ON_SMP: : :"memory");
        lock->slock = 0;
 }
 
 #ifdef CONFIG_PPC64
-extern void __raw_spin_unlock_wait(raw_spinlock_t *lock);
+extern void arch_spin_unlock_wait(arch_spinlock_t *lock);
 #else
-#define __raw_spin_unlock_wait(lock) \
-       do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0)
+#define arch_spin_unlock_wait(lock) \
+       do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)
 #endif
 
 /*
@@ -166,8 +166,8 @@ extern void __raw_spin_unlock_wait(raw_spinlock_t *lock);
  * read-locks.
  */
 
-#define __raw_read_can_lock(rw)                ((rw)->lock >= 0)
-#define __raw_write_can_lock(rw)       (!(rw)->lock)
+#define arch_read_can_lock(rw)         ((rw)->lock >= 0)
+#define arch_write_can_lock(rw)        (!(rw)->lock)
 
 #ifdef CONFIG_PPC64
 #define __DO_SIGN_EXTEND       "extsw  %0,%0\n"
@@ -181,7 +181,7 @@ extern void __raw_spin_unlock_wait(raw_spinlock_t *lock);
  * This returns the old value in the lock + 1,
  * so we got a read lock if the return value is > 0.
  */
-static inline long arch_read_trylock(raw_rwlock_t *rw)
+static inline long __arch_read_trylock(arch_rwlock_t *rw)
 {
        long tmp;
 
@@ -205,7 +205,7 @@ static inline long arch_read_trylock(raw_rwlock_t *rw)
  * This returns the old value in the lock,
  * so we got the write lock if the return value is 0.
  */
-static inline long arch_write_trylock(raw_rwlock_t *rw)
+static inline long __arch_write_trylock(arch_rwlock_t *rw)
 {
        long tmp, token;
 
@@ -225,10 +225,10 @@ static inline long arch_write_trylock(raw_rwlock_t *rw)
        return tmp;
 }
 
-static inline void __raw_read_lock(raw_rwlock_t *rw)
+static inline void arch_read_lock(arch_rwlock_t *rw)
 {
        while (1) {
-               if (likely(arch_read_trylock(rw) > 0))
+               if (likely(__arch_read_trylock(rw) > 0))
                        break;
                do {
                        HMT_low();
@@ -239,10 +239,10 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
        }
 }
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
        while (1) {
-               if (likely(arch_write_trylock(rw) == 0))
+               if (likely(__arch_write_trylock(rw) == 0))
                        break;
                do {
                        HMT_low();
@@ -253,17 +253,17 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
        }
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t *rw)
+static inline int arch_read_trylock(arch_rwlock_t *rw)
 {
-       return arch_read_trylock(rw) > 0;
+       return __arch_read_trylock(rw) > 0;
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *rw)
+static inline int arch_write_trylock(arch_rwlock_t *rw)
 {
-       return arch_write_trylock(rw) == 0;
+       return __arch_write_trylock(rw) == 0;
 }
 
-static inline void __raw_read_unlock(raw_rwlock_t *rw)
+static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
        long tmp;
 
@@ -280,19 +280,19 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
        : "cr0", "xer", "memory");
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t *rw)
+static inline void arch_write_unlock(arch_rwlock_t *rw)
 {
        __asm__ __volatile__("# write_unlock\n\t"
                                LWSYNC_ON_SMP: : :"memory");
        rw->lock = 0;
 }
 
-#define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock)
-#define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock)
+#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define _raw_spin_relax(lock)  __spin_yield(lock)
-#define _raw_read_relax(lock)  __rw_yield(lock)
-#define _raw_write_relax(lock) __rw_yield(lock)
+#define arch_spin_relax(lock)  __spin_yield(lock)
+#define arch_read_relax(lock)  __rw_yield(lock)
+#define arch_write_relax(lock) __rw_yield(lock)
 
 #endif /* __KERNEL__ */
 #endif /* __ASM_SPINLOCK_H */
index 74236c9f05b1ca85983ce74f504a903f2edc2fcb..2351adc4fdc4a7acb009dc63f623544c98bb2189 100644 (file)
@@ -7,14 +7,14 @@
 
 typedef struct {
        volatile unsigned int slock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        volatile signed int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { 0 }
+#define __ARCH_RW_LOCK_UNLOCKED                { 0 }
 
 #endif
index cd21e5e6b04f975e09c7ae7d4feb32a862940501..11ae699135bab14c7abb51973f6cbfefe4d5e18e 100644 (file)
@@ -51,6 +51,7 @@ extern void __init udbg_init_btext(void);
 extern void __init udbg_init_44x_as1(void);
 extern void __init udbg_init_40x_realmode(void);
 extern void __init udbg_init_cpm(void);
+extern void __init udbg_init_usbgecko(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
index 3839839f83c79ad8544ef0bbf6ded33e0d96ce13..b876e989220b02fbb3314e5ac56043717a42ffcb 100644 (file)
@@ -642,10 +642,14 @@ static int emulate_spe(struct pt_regs *regs, unsigned int reg,
  */
 static int emulate_vsx(unsigned char __user *addr, unsigned int reg,
                       unsigned int areg, struct pt_regs *regs,
-                      unsigned int flags, unsigned int length)
+                      unsigned int flags, unsigned int length,
+                      unsigned int elsize)
 {
        char *ptr;
+       unsigned long *lptr;
        int ret = 0;
+       int sw = 0;
+       int i, j;
 
        flush_vsx_to_thread(current);
 
@@ -654,19 +658,35 @@ static int emulate_vsx(unsigned char __user *addr, unsigned int reg,
        else
                ptr = (char *) &current->thread.vr[reg - 32];
 
-       if (flags & ST)
-               ret = __copy_to_user(addr, ptr, length);
-        else {
-               if (flags & SPLT){
-                       ret = __copy_from_user(ptr, addr, length);
-                       ptr += length;
+       lptr = (unsigned long *) ptr;
+
+       if (flags & SW)
+               sw = elsize-1;
+
+       for (j = 0; j < length; j += elsize) {
+               for (i = 0; i < elsize; ++i) {
+                       if (flags & ST)
+                               ret |= __put_user(ptr[i^sw], addr + i);
+                       else
+                               ret |= __get_user(ptr[i^sw], addr + i);
                }
-               ret |= __copy_from_user(ptr, addr, length);
+               ptr  += elsize;
+               addr += elsize;
        }
-       if (flags & U)
-               regs->gpr[areg] = regs->dar;
-       if (ret)
+
+       if (!ret) {
+               if (flags & U)
+                       regs->gpr[areg] = regs->dar;
+
+               /* Splat load copies the same data to top and bottom 8 bytes */
+               if (flags & SPLT)
+                       lptr[1] = lptr[0];
+               /* For 8 byte loads, zero the top 8 bytes */
+               else if (!(flags & ST) && (8 == length))
+                       lptr[1] = 0;
+       } else
                return -EFAULT;
+
        return 1;
 }
 #endif
@@ -767,16 +787,25 @@ int fix_alignment(struct pt_regs *regs)
 
 #ifdef CONFIG_VSX
        if ((instruction & 0xfc00003e) == 0x7c000018) {
-               /* Additional register addressing bit (64 VSX vs 32 FPR/GPR */
+               unsigned int elsize;
+
+               /* Additional register addressing bit (64 VSX vs 32 FPR/GPR) */
                reg |= (instruction & 0x1) << 5;
                /* Simple inline decoder instead of a table */
+               /* VSX has only 8 and 16 byte memory accesses */
+               nb = 8;
                if (instruction & 0x200)
                        nb = 16;
-               else if (instruction & 0x080)
-                       nb = 8;
-               else
-                       nb = 4;
+
+               /* Vector stores in little-endian mode swap individual
+                  elements, so process them separately */
+               elsize = 4;
+               if (instruction & 0x80)
+                       elsize = 8;
+
                flags = 0;
+               if (regs->msr & MSR_LE)
+                       flags |= SW;
                if (instruction & 0x100)
                        flags |= ST;
                if (instruction & 0x040)
@@ -787,7 +816,7 @@ int fix_alignment(struct pt_regs *regs)
                        nb = 8;
                }
                PPC_WARN_ALIGNMENT(vsx, regs);
-               return emulate_vsx(addr, reg, areg, regs, flags, nb);
+               return emulate_vsx(addr, reg, areg, regs, flags, nb, elsize);
        }
 #endif
        /* A size of 0 indicates an instruction we don't support, with
index 03c862b6a9c4a85799f59bcaa444b5db9d106149..2fc82bac3bbc73b029185d972b6f56c89e25f27e 100644 (file)
@@ -697,9 +697,9 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .machine_check          = machine_check_generic,
                .platform               = "ppc750",
        },
-       {       /* 750CL */
-               .pvr_mask               = 0xfffff0f0,
-               .pvr_value              = 0x00087010,
+       {       /* 750CL (and "Broadway") */
+               .pvr_mask               = 0xfffff0e0,
+               .pvr_value              = 0x00087000,
                .cpu_name               = "750CL",
                .cpu_features           = CPU_FTRS_750CL,
                .cpu_user_features      = COMMON_USER | PPC_FEATURE_PPC_LE,
index 829c3fe7c5a2384c6535cbc9a7da69b32ef76157..e025e89fe93e2632a2a485c1d52e4edaf12be3fe 100644 (file)
@@ -164,6 +164,9 @@ __after_mmu_off:
 #ifdef CONFIG_PPC_EARLY_DEBUG_CPM
        bl      setup_cpm_bat
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+       bl      setup_usbgecko_bat
+#endif
 
 /*
  * Call setup_cpu for CPU 0 and initialize 6xx Idle
@@ -1203,6 +1206,28 @@ setup_cpm_bat:
        blr
 #endif
 
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+setup_usbgecko_bat:
+       /* prepare a BAT for early io */
+#if defined(CONFIG_GAMECUBE)
+       lis     r8, 0x0c00
+#elif defined(CONFIG_WII)
+       lis     r8, 0x0d00
+#else
+#error Invalid platform for USB Gecko based early debugging.
+#endif
+       /*
+        * The virtual address used must match the virtual address
+        * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
+        */
+       lis     r11, 0xfffe     /* top 128K */
+       ori     r8, r8, 0x002a  /* uncached, guarded ,rw */
+       ori     r11, r11, 0x2   /* 128K, Vs=1, Vp=0 */
+       mtspr   SPRN_DBAT1L, r8
+       mtspr   SPRN_DBAT1U, r11
+       blr
+#endif
+
 #ifdef CONFIG_8260
 /* Jump into the system reset for the rom.
  * We first disable the MMU, and then jump to the ROM reset address.
index fd51578e29dda66b276061830e32da1f28dd37e1..5547ae6e6b0be605e293ae42c49dab911782f568 100644 (file)
@@ -30,7 +30,7 @@
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/dma-mapping.h>
-#include <linux/bitops.h>
+#include <linux/bitmap.h>
 #include <linux/iommu-helper.h>
 #include <linux/crash_dump.h>
 #include <asm/io.h>
@@ -251,7 +251,7 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
        }
 
        ppc_md.tce_free(tbl, entry, npages);
-       iommu_area_free(tbl->it_map, free_entry, npages);
+       bitmap_clear(tbl->it_map, free_entry, npages);
 }
 
 static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
index f6dca4f4b2955beba5e9d73221f9952569b4b51e..9040330b0530f1dae82f75c4f5b5218495e7c4f1 100644 (file)
@@ -210,7 +210,7 @@ int show_interrupts(struct seq_file *p, void *v)
        if (!desc)
                return 0;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
 
        action = desc->action;
        if (!action || !action->handler)
@@ -237,7 +237,7 @@ int show_interrupts(struct seq_file *p, void *v)
        seq_putc(p, '\n');
 
 skip:
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 
        return 0;
 }
@@ -1112,7 +1112,7 @@ static int virq_debug_show(struct seq_file *m, void *private)
                if (!desc)
                        continue;
 
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
 
                if (desc->action && desc->action->handler) {
                        seq_printf(m, "%5d  ", i);
@@ -1131,7 +1131,7 @@ static int virq_debug_show(struct seq_file *m, void *private)
                        seq_printf(m, "%s\n", p);
                }
 
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 
        return 0;
index e8dfdbd9327aec5c2fe3fc77903d4a1b9155e694..cadbed679fbbc17cc8cac85426a50c6cc631db34 100644 (file)
@@ -1107,6 +1107,12 @@ void __devinit pcibios_setup_bus_devices(struct pci_bus *bus)
        list_for_each_entry(dev, &bus->devices, bus_list) {
                struct dev_archdata *sd = &dev->dev.archdata;
 
+               /* Cardbus can call us to add new devices to a bus, so ignore
+                * those who are already fully discovered
+                */
+               if (dev->is_added)
+                       continue;
+
                /* Setup OF node pointer in archdata */
                sd->of_node = pci_device_to_OF_node(dev);
 
@@ -1147,6 +1153,13 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL(pcibios_fixup_bus);
 
+void __devinit pci_fixup_cardbus(struct pci_bus *bus)
+{
+       /* Now fixup devices on that bus */
+       pcibios_setup_bus_devices(bus);
+}
+
+
 static int skip_isa_ioresource_align(struct pci_dev *dev)
 {
        if ((ppc_pci_flags & PPC_PCI_CAN_SKIP_ISA_ALIGN) &&
index bf90361bb70f3664fb02742bc3514f145207b26d..fd0d29493fd629a41ea5623dd77beeef1ef86ff1 100644 (file)
@@ -42,7 +42,7 @@
 #include <asm/mmu.h>
 
 struct rtas_t rtas = {
-       .lock = __RAW_SPIN_LOCK_UNLOCKED
+       .lock = __ARCH_SPIN_LOCK_UNLOCKED
 };
 EXPORT_SYMBOL(rtas);
 
@@ -80,13 +80,13 @@ static unsigned long lock_rtas(void)
 
        local_irq_save(flags);
        preempt_disable();
-       __raw_spin_lock_flags(&rtas.lock, flags);
+       arch_spin_lock_flags(&rtas.lock, flags);
        return flags;
 }
 
 static void unlock_rtas(unsigned long flags)
 {
-       __raw_spin_unlock(&rtas.lock);
+       arch_spin_unlock(&rtas.lock);
        local_irq_restore(flags);
        preempt_enable();
 }
@@ -978,7 +978,7 @@ int __init early_init_dt_scan_rtas(unsigned long node,
        return 1;
 }
 
-static raw_spinlock_t timebase_lock;
+static arch_spinlock_t timebase_lock;
 static u64 timebase = 0;
 
 void __cpuinit rtas_give_timebase(void)
@@ -987,10 +987,10 @@ void __cpuinit rtas_give_timebase(void)
 
        local_irq_save(flags);
        hard_irq_disable();
-       __raw_spin_lock(&timebase_lock);
+       arch_spin_lock(&timebase_lock);
        rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
        timebase = get_tb();
-       __raw_spin_unlock(&timebase_lock);
+       arch_spin_unlock(&timebase_lock);
 
        while (timebase)
                barrier();
@@ -1002,8 +1002,8 @@ void __cpuinit rtas_take_timebase(void)
 {
        while (!timebase)
                barrier();
-       __raw_spin_lock(&timebase_lock);
+       arch_spin_lock(&timebase_lock);
        set_tb(timebase >> 32, timebase & 0xffffffff);
        timebase = 0;
-       __raw_spin_unlock(&timebase_lock);
+       arch_spin_unlock(&timebase_lock);
 }
index 804f0f30f227f692d949d49117b3c35da908fc6f..d069ff8a7e036c0022fe1e9f3a62112713033af6 100644 (file)
@@ -174,6 +174,15 @@ int die(const char *str, struct pt_regs *regs, long err)
        return 0;
 }
 
+void user_single_step_siginfo(struct task_struct *tsk,
+                               struct pt_regs *regs, siginfo_t *info)
+{
+       memset(info, 0, sizeof(*info));
+       info->si_signo = SIGTRAP;
+       info->si_code = TRAP_TRACE;
+       info->si_addr = (void __user *)regs->nip;
+}
+
 void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
 {
        siginfo_t info;
index fc9af47e21285f7a10872849c88930d0218bcb44..e39cad83c8849a69ecb710a8ac0d8bc595bdce3a 100644 (file)
@@ -60,6 +60,8 @@ void __init udbg_early_init(void)
        udbg_init_40x_realmode();
 #elif defined(CONFIG_PPC_EARLY_DEBUG_CPM)
        udbg_init_cpm();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_USBGECKO)
+       udbg_init_usbgecko();
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG
index 27735a7ac12b6709d1dd04e51a7871e1bce33232..dcd01c82e7013c8e08f797eaa40c9543d5f2fc01 100644 (file)
@@ -38,6 +38,9 @@ jiffies = jiffies_64 + 4;
 #endif
 SECTIONS
 {
+       . = 0;
+       reloc_start = .;
+
        . = KERNELBASE;
 
 /*
index 5598f88f142e6332877e7a4a84947fbba93b9dc6..e4beeb371a732fecdf3fc5fe1291ae01aa40b2a6 100644 (file)
@@ -390,6 +390,26 @@ static void kvmppc_mmu_book3s_64_mtsrin(struct kvm_vcpu *vcpu, u32 srnum,
 {
        u64 rb = 0, rs = 0;
 
+       /*
+        * According to Book3 2.01 mtsrin is implemented as:
+        *
+        * The SLB entry specified by (RB)32:35 is loaded from register
+        * RS, as follows.
+        *
+        * SLBE Bit     Source                  SLB Field
+        *
+        * 0:31         0x0000_0000             ESID-0:31
+        * 32:35        (RB)32:35               ESID-32:35
+        * 36           0b1                     V
+        * 37:61        0x00_0000|| 0b0         VSID-0:24
+        * 62:88        (RS)37:63               VSID-25:51
+        * 89:91        (RS)33:35               Ks Kp N
+        * 92           (RS)36                  L ((RS)36 must be 0b0)
+        * 93           0b0                     C
+        */
+
+       dprintk("KVM MMU: mtsrin(0x%x, 0x%lx)\n", srnum, value);
+
        /* ESID = srnum */
        rb |= (srnum & 0xf) << 28;
        /* Set the valid bit */
@@ -400,7 +420,7 @@ static void kvmppc_mmu_book3s_64_mtsrin(struct kvm_vcpu *vcpu, u32 srnum,
        /* VSID = VSID */
        rs |= (value & 0xfffffff) << 12;
        /* flags = flags */
-       rs |= ((value >> 27) & 0xf) << 9;
+       rs |= ((value >> 28) & 0x7) << 9;
 
        kvmppc_mmu_book3s_64_slbmte(vcpu, rs, rb);
 }
index 79d0fa3a470d9eaf4f0811652775e16c7f1634ec..58e14fba11b1d7472b982a9a91a992a20319c9cd 100644 (file)
@@ -25,7 +25,7 @@
 #include <asm/smp.h>
 #include <asm/firmware.h>
 
-void __spin_yield(raw_spinlock_t *lock)
+void __spin_yield(arch_spinlock_t *lock)
 {
        unsigned int lock_value, holder_cpu, yield_count;
 
@@ -55,7 +55,7 @@ void __spin_yield(raw_spinlock_t *lock)
  * This turns out to be the same for read and write locks, since
  * we only know the holder if it is write-locked.
  */
-void __rw_yield(raw_rwlock_t *rw)
+void __rw_yield(arch_rwlock_t *rw)
 {
        int lock_value;
        unsigned int holder_cpu, yield_count;
@@ -82,7 +82,7 @@ void __rw_yield(raw_rwlock_t *rw)
 }
 #endif
 
-void __raw_spin_unlock_wait(raw_spinlock_t *lock)
+void arch_spin_unlock_wait(arch_spinlock_t *lock)
 {
        while (lock->slock) {
                HMT_low();
@@ -92,4 +92,4 @@ void __raw_spin_unlock_wait(raw_spinlock_t *lock)
        HMT_medium();
 }
 
-EXPORT_SYMBOL(__raw_spin_unlock_wait);
+EXPORT_SYMBOL(arch_spin_unlock_wait);
index f5e7b9ce63ddaa46f9ee10da0636b6d070b95431..08dfa8e6d86fa6a842474074f43d0b77e7d87fe6 100644 (file)
@@ -91,7 +91,7 @@ void __init MMU_init_hw(void)
 #define LARGE_PAGE_SIZE_16M    (1<<24)
 #define LARGE_PAGE_SIZE_4M     (1<<22)
 
-unsigned long __init mmu_mapin_ram(void)
+unsigned long __init mmu_mapin_ram(unsigned long top)
 {
        unsigned long v, s, mapped;
        phys_addr_t p;
index 98052ac96580d69dc0566fb711594625f2f470b2..3986264b09930a198c1932b8a28cadb7a05b8042 100644 (file)
@@ -88,7 +88,7 @@ void __init MMU_init_hw(void)
        flush_instruction_cache();
 }
 
-unsigned long __init mmu_mapin_ram(void)
+unsigned long __init mmu_mapin_ram(unsigned long top)
 {
        unsigned long addr;
 
index fcfcb6e976c72c7a8da1b8d31aac474e08985282..c5394728bf2e1057b407e68e8f22a6b9fd9a3621 100644 (file)
@@ -207,7 +207,7 @@ unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx)
        return amount_mapped;
 }
 
-unsigned long __init mmu_mapin_ram(void)
+unsigned long __init mmu_mapin_ram(unsigned long top)
 {
        return tlbcam_addrs[tlbcam_index - 1].limit - PAGE_OFFSET + 1;
 }
index 50f867d657dfd365de1f21f6bf3f7f6d762c4ccd..3ecdcec0a39e11403c792b66740c5a87648bb765 100644 (file)
@@ -340,7 +340,7 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
                        else
                                def->tlbiel = 0;
 
-                       DBG(" %d: shift=%02x, sllp=%04x, avpnm=%08x, "
+                       DBG(" %d: shift=%02x, sllp=%04lx, avpnm=%08lx, "
                            "tlbiel=%d, penc=%d\n",
                            idx, shift, def->sllp, def->avpnm, def->tlbiel,
                            def->penc);
@@ -663,7 +663,7 @@ static void __init htab_initialize(void)
                base = (unsigned long)__va(lmb.memory.region[i].base);
                size = lmb.memory.region[i].size;
 
-               DBG("creating mapping for region: %lx..%lx (prot: %x)\n",
+               DBG("creating mapping for region: %lx..%lx (prot: %lx)\n",
                    base, size, prot);
 
 #ifdef CONFIG_U3_DART
@@ -879,7 +879,7 @@ static inline int subpage_protection(struct mm_struct *mm, unsigned long ea)
  */
 int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
 {
-       void *pgdir;
+       pgd_t *pgdir;
        unsigned long vsid;
        struct mm_struct *mm;
        pte_t *ptep;
@@ -1025,7 +1025,7 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
        else
 #endif /* CONFIG_PPC_HAS_HASH_64K */
        {
-               int spp = subpage_protection(pgdir, ea);
+               int spp = subpage_protection(mm, ea);
                if (access & spp)
                        rc = -2;
                else
@@ -1115,7 +1115,7 @@ void flush_hash_page(unsigned long va, real_pte_t pte, int psize, int ssize,
 {
        unsigned long hash, index, shift, hidx, slot;
 
-       DBG_LOW("flush_hash_page(va=%016x)\n", va);
+       DBG_LOW("flush_hash_page(va=%016lx)\n", va);
        pte_iterate_hashed_subpages(pte, psize, va, index, shift) {
                hash = hpt_hash(va, shift, ssize);
                hidx = __rpte_to_hidx(pte, index);
@@ -1123,7 +1123,7 @@ void flush_hash_page(unsigned long va, real_pte_t pte, int psize, int ssize,
                        hash = ~hash;
                slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
                slot += hidx & _PTEIDX_GROUP_IX;
-               DBG_LOW(" sub %d: hash=%x, hidx=%x\n", index, slot, hidx);
+               DBG_LOW(" sub %ld: hash=%lx, hidx=%lx\n", index, slot, hidx);
                ppc_md.hpte_invalidate(slot, va, psize, ssize, local);
        } pte_iterate_hashed_end();
 }
index 9ddcfb4dc139f058f31a8df44668221bc0e1227b..4ec900af332f0656ed4a847970b57bb8d66761ed 100644 (file)
@@ -82,6 +82,11 @@ extern struct task_struct *current_set[NR_CPUS];
 int __map_without_bats;
 int __map_without_ltlbs;
 
+/*
+ * This tells the system to allow ioremapping memory marked as reserved.
+ */
+int __allow_ioremap_reserved;
+
 /* max amount of low RAM to map in */
 unsigned long __max_low_memory = MAX_LOW_MEM;
 
@@ -131,9 +136,13 @@ void __init MMU_init(void)
        MMU_setup();
 
        if (lmb.memory.cnt > 1) {
+#ifndef CONFIG_WII
                lmb.memory.cnt = 1;
                lmb_analyze();
                printk(KERN_WARNING "Only using first contiguous memory region");
+#else
+               wii_memory_fixups();
+#endif
        }
 
        total_lowmem = total_memory = lmb_end_of_DRAM() - memstart_addr;
index be4f34c30a0b14c955377a5c6002fdb3e5b7a74e..1044a634b6d0a475d5978aecc8c37115f8c49abd 100644 (file)
@@ -353,7 +353,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
                read_lock(&tasklist_lock);
                for_each_process(p) {
                        if (p->mm)
-                               cpu_mask_clear_cpu(cpu, mm_cpumask(p->mm));
+                               cpumask_clear_cpu(cpu, mm_cpumask(p->mm));
                }
                read_unlock(&tasklist_lock);
        break;
index e27a990af42dd37ffcb3d7f198e6483aceed2d2f..d49a77503e19d1cb8c7d7649595d99c13646f973 100644 (file)
@@ -104,6 +104,7 @@ extern void setbat(int index, unsigned long virt, phys_addr_t phys,
                   unsigned int size, int flags);
 
 extern int __map_without_bats;
+extern int __allow_ioremap_reserved;
 extern unsigned long ioremap_base;
 extern unsigned int rtas_data, rtas_size;
 
@@ -125,24 +126,32 @@ extern phys_addr_t total_lowmem;
 extern phys_addr_t memstart_addr;
 extern phys_addr_t lowmem_end_addr;
 
+#ifdef CONFIG_WII
+extern unsigned long wii_hole_start;
+extern unsigned long wii_hole_size;
+
+extern unsigned long wii_mmu_mapin_mem2(unsigned long top);
+extern void wii_memory_fixups(void);
+#endif
+
 /* ...and now those things that may be slightly different between processor
  * architectures.  -- Dan
  */
 #if defined(CONFIG_8xx)
 #define MMU_init_hw()          do { } while(0)
-#define mmu_mapin_ram()                (0UL)
+#define mmu_mapin_ram(top)     (0UL)
 
 #elif defined(CONFIG_4xx)
 extern void MMU_init_hw(void);
-extern unsigned long mmu_mapin_ram(void);
+extern unsigned long mmu_mapin_ram(unsigned long top);
 
 #elif defined(CONFIG_FSL_BOOKE)
 extern void MMU_init_hw(void);
-extern unsigned long mmu_mapin_ram(void);
+extern unsigned long mmu_mapin_ram(unsigned long top);
 extern void adjust_total_lowmem(void);
 
 #elif defined(CONFIG_PPC32)
 /* anything 32-bit except 4xx or 8xx */
 extern void MMU_init_hw(void);
-extern unsigned long mmu_mapin_ram(void);
+extern unsigned long mmu_mapin_ram(unsigned long top);
 #endif
index cb96cb2e17cc0560e947550690013a342f63929c..573b3bd1c45b46500c38e65495b9f3a2ee3a47a2 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/highmem.h>
+#include <linux/lmb.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
@@ -191,7 +192,8 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags,
         * Don't allow anybody to remap normal RAM that we're using.
         * mem_init() sets high_memory so only do the check after that.
         */
-       if (mem_init_done && (p < virt_to_phys(high_memory))) {
+       if (mem_init_done && (p < virt_to_phys(high_memory)) &&
+           !(__allow_ioremap_reserved && lmb_is_region_reserved(p, size))) {
                printk("__ioremap(): phys addr 0x%llx is RAM lr %p\n",
                       (unsigned long long)p, __builtin_return_address(0));
                return NULL;
@@ -283,18 +285,18 @@ int map_page(unsigned long va, phys_addr_t pa, int flags)
 }
 
 /*
- * Map in a big chunk of physical memory starting at PAGE_OFFSET.
+ * Map in a chunk of physical memory starting at start.
  */
-void __init mapin_ram(void)
+void __init __mapin_ram_chunk(unsigned long offset, unsigned long top)
 {
        unsigned long v, s, f;
        phys_addr_t p;
        int ktext;
 
-       s = mmu_mapin_ram();
+       s = offset;
        v = PAGE_OFFSET + s;
        p = memstart_addr + s;
-       for (; s < total_lowmem; s += PAGE_SIZE) {
+       for (; s < top; s += PAGE_SIZE) {
                ktext = ((char *) v >= _stext && (char *) v < etext);
                f = ktext ? PAGE_KERNEL_TEXT : PAGE_KERNEL;
                map_page(v, p, f);
@@ -307,6 +309,30 @@ void __init mapin_ram(void)
        }
 }
 
+void __init mapin_ram(void)
+{
+       unsigned long s, top;
+
+#ifndef CONFIG_WII
+       top = total_lowmem;
+       s = mmu_mapin_ram(top);
+       __mapin_ram_chunk(s, top);
+#else
+       if (!wii_hole_size) {
+               s = mmu_mapin_ram(total_lowmem);
+               __mapin_ram_chunk(s, total_lowmem);
+       } else {
+               top = wii_hole_start;
+               s = mmu_mapin_ram(top);
+               __mapin_ram_chunk(s, top);
+
+               top = lmb_end_of_DRAM();
+               s = wii_mmu_mapin_mem2(top);
+               __mapin_ram_chunk(s, top);
+       }
+#endif
+}
+
 /* Scan the real Linux page tables and return a PTE pointer for
  * a virtual address in a context.
  * Returns true (1) if PTE was found, zero otherwise.  The pointer to
@@ -356,7 +382,7 @@ static int __change_page_attr(struct page *page, pgprot_t prot)
                return 0;
        if (!get_pteptr(&init_mm, address, &kpte, &kpmd))
                return -EINVAL;
-       set_pte_at(&init_mm, address, kpte, mk_pte(page, prot));
+       __set_pte_at(&init_mm, address, kpte, mk_pte(page, prot), 0);
        wmb();
 #ifdef CONFIG_PPC_STD_MMU
        flush_hash_pages(0, address, pmd_val(*kpmd), 1);
index 2d2a87e101549bea39f4775b61f13153cb5256a3..f11c2cdcb0fedd9a1afb89222ed4e6f6a9037116 100644 (file)
@@ -72,7 +72,7 @@ unsigned long p_mapped_by_bats(phys_addr_t pa)
        return 0;
 }
 
-unsigned long __init mmu_mapin_ram(void)
+unsigned long __init mmu_mapin_ram(unsigned long top)
 {
        unsigned long tot, bl, done;
        unsigned long max_size = (256<<20);
@@ -86,7 +86,7 @@ unsigned long __init mmu_mapin_ram(void)
 
        /* Make sure we don't map a block larger than the
           smallest alignment of the physical address. */
-       tot = total_lowmem;
+       tot = top;
        for (bl = 128<<10; bl < max_size; bl <<= 1) {
                if (bl * 2 > tot)
                        break;
index bcc69e1f77c10d800a40432522f121e80119314f..45c0cb9b67e6774958c621b6e3c8055d43e46163 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 #include <linux/init.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/pci.h>
 #include <linux/of.h>
 #include <asm/prom.h>
index cc0c854291d7397837f371d94a2922e7a7464c66..0bac3a3dbecfdf4fe189d897681ce388b584f508 100644 (file)
@@ -86,9 +86,9 @@ void media5200_irq_cascade(unsigned int virq, struct irq_desc *desc)
        u32 status, enable;
 
        /* Mask off the cascaded IRQ */
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        desc->chip->mask(virq);
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        /* Ask the FPGA for IRQ status.  If 'val' is 0, then no irqs
         * are pending.  'ffs()' is 1 based */
@@ -104,11 +104,11 @@ void media5200_irq_cascade(unsigned int virq, struct irq_desc *desc)
        }
 
        /* Processing done; can reenable the cascade now */
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        desc->chip->ack(virq);
        if (!(desc->status & IRQ_DISABLED))
                desc->chip->unmask(virq);
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 
 static int media5200_irq_map(struct irq_host *h, unsigned int virq,
index d306f07b9aa13ca6ee548ad8a56a436498f3cec0..43805348b81ee90be3577f9dfd8a08693363cb60 100644 (file)
@@ -32,6 +32,7 @@
 #define PMCCR1_NEXT_STATE       0x0C /* Next state for power management */
 #define PMCCR1_NEXT_STATE_SHIFT 2
 #define PMCCR1_CURR_STATE       0x03 /* Current state for power management*/
+#define IMMR_SYSCR_OFFSET       0x100
 #define IMMR_RCW_OFFSET         0x900
 #define RCW_PCI_HOST            0x80000000
 
@@ -78,6 +79,22 @@ struct mpc83xx_clock {
        u32 sccr;
 };
 
+struct mpc83xx_syscr {
+       __be32 sgprl;
+       __be32 sgprh;
+       __be32 spridr;
+       __be32 :32;
+       __be32 spcr;
+       __be32 sicrl;
+       __be32 sicrh;
+};
+
+struct mpc83xx_saved {
+       u32 sicrl;
+       u32 sicrh;
+       u32 sccr;
+};
+
 struct pmc_type {
        int has_deep_sleep;
 };
@@ -87,6 +104,8 @@ static int has_deep_sleep, deep_sleeping;
 static int pmc_irq;
 static struct mpc83xx_pmc __iomem *pmc_regs;
 static struct mpc83xx_clock __iomem *clock_regs;
+static struct mpc83xx_syscr __iomem *syscr_regs;
+static struct mpc83xx_saved saved_regs;
 static int is_pci_agent, wake_from_pci;
 static phys_addr_t immrbase;
 static int pci_pm_state;
@@ -137,6 +156,20 @@ static irqreturn_t pmc_irq_handler(int irq, void *dev_id)
        return ret;
 }
 
+static void mpc83xx_suspend_restore_regs(void)
+{
+       out_be32(&syscr_regs->sicrl, saved_regs.sicrl);
+       out_be32(&syscr_regs->sicrh, saved_regs.sicrh);
+       out_be32(&clock_regs->sccr, saved_regs.sccr);
+}
+
+static void mpc83xx_suspend_save_regs(void)
+{
+       saved_regs.sicrl = in_be32(&syscr_regs->sicrl);
+       saved_regs.sicrh = in_be32(&syscr_regs->sicrh);
+       saved_regs.sccr = in_be32(&clock_regs->sccr);
+}
+
 static int mpc83xx_suspend_enter(suspend_state_t state)
 {
        int ret = -EAGAIN;
@@ -166,6 +199,8 @@ static int mpc83xx_suspend_enter(suspend_state_t state)
         */
 
        if (deep_sleeping) {
+               mpc83xx_suspend_save_regs();
+
                out_be32(&pmc_regs->mask, PMCER_ALL);
 
                out_be32(&pmc_regs->config1,
@@ -179,6 +214,8 @@ static int mpc83xx_suspend_enter(suspend_state_t state)
                         in_be32(&pmc_regs->config1) & ~PMCCR1_POWER_OFF);
 
                out_be32(&pmc_regs->mask, PMCER_PMCI);
+
+               mpc83xx_suspend_restore_regs();
        } else {
                out_be32(&pmc_regs->mask, PMCER_PMCI);
 
@@ -194,7 +231,7 @@ out:
        return ret;
 }
 
-static void mpc83xx_suspend_finish(void)
+static void mpc83xx_suspend_end(void)
 {
        deep_sleeping = 0;
 }
@@ -278,7 +315,7 @@ static struct platform_suspend_ops mpc83xx_suspend_ops = {
        .valid = mpc83xx_suspend_valid,
        .begin = mpc83xx_suspend_begin,
        .enter = mpc83xx_suspend_enter,
-       .finish = mpc83xx_suspend_finish,
+       .end = mpc83xx_suspend_end,
 };
 
 static int pmc_probe(struct of_device *ofdev,
@@ -333,12 +370,23 @@ static int pmc_probe(struct of_device *ofdev,
                goto out_pmc;
        }
 
+       if (has_deep_sleep) {
+               syscr_regs = ioremap(immrbase + IMMR_SYSCR_OFFSET,
+                                    sizeof(*syscr_regs));
+               if (!syscr_regs) {
+                       ret = -ENOMEM;
+                       goto out_syscr;
+               }
+       }
+
        if (is_pci_agent)
                mpc83xx_set_agent();
 
        suspend_set_ops(&mpc83xx_suspend_ops);
        return 0;
 
+out_syscr:
+       iounmap(clock_regs);
 out_pmc:
        iounmap(pmc_regs);
 out:
index c5028a2e5a58510b9aa634c2cf09a114c096e373..21f61b8c445b8863b0c22969c205983b21b2b6b7 100644 (file)
@@ -86,7 +86,7 @@ static int mpc8568_fixup_125_clock(struct phy_device *phydev)
        scr = phy_read(phydev, MV88E1111_SCR);
 
        if (scr < 0)
-               return err;
+               return scr;
 
        err = phy_write(phydev, MV88E1111_SCR, scr | 0x0008);
 
index 2eab27a94cc9451e0ab2c9b9e726c91a8ebb6155..fa0f690d38676b1d945b11d71073240d7acba1f4 100644 (file)
@@ -311,7 +311,7 @@ config NR_CPUS
 
 config NOT_COHERENT_CACHE
        bool
-       depends on 4xx || 8xx || E200 || PPC_MPC512x
+       depends on 4xx || 8xx || E200 || PPC_MPC512x || GAMECUBE_COMMON
        default y
 
 config CHECK_CACHE_COHERENCY
index 9290a7a442d0af9d2736a81e4431ffd367df92b0..fb4eb0df054c0a701fe74df78990d40bd480e2df 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <linux/kernel.h>
 #include <linux/seq_file.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 
 #include <asm/machdep.h>
 #include <asm/cputable.h>
index 7267effc8078b53265e43898a7551f6adf2523d8..6829cf7e2bdada1284e63a0d91fcb8ae6c80f31b 100644 (file)
@@ -237,7 +237,7 @@ extern int noirqdebug;
 
 static void handle_iic_irq(unsigned int irq, struct irq_desc *desc)
 {
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
 
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
 
@@ -265,18 +265,18 @@ static void handle_iic_irq(unsigned int irq, struct irq_desc *desc)
                        goto out_eoi;
 
                desc->status &= ~IRQ_PENDING;
-               spin_unlock(&desc->lock);
+               raw_spin_unlock(&desc->lock);
                action_ret = handle_IRQ_event(irq, action);
                if (!noirqdebug)
                        note_interrupt(irq, desc, action_ret);
-               spin_lock(&desc->lock);
+               raw_spin_lock(&desc->lock);
 
        } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
 
        desc->status &= ~IRQ_INPROGRESS;
 out_eoi:
        desc->chip->eoi(irq);
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 
 static int iic_host_map(struct irq_host *h, unsigned int virq,
index b93f877ba5046bded97844766dee257534194b1b..b9d5d678aa44ccf2481cef76586c8dbb1f3c0ab3 100644 (file)
@@ -13,10 +13,8 @@ SPU_CC               := $(SPU_CROSS)gcc
 SPU_AS         := $(SPU_CROSS)gcc
 SPU_LD         := $(SPU_CROSS)ld
 SPU_OBJCOPY    := $(SPU_CROSS)objcopy
-SPU_CFLAGS     := -O2 -Wall -I$(srctree)/include \
-                  -I$(objtree)/include2 -D__KERNEL__
-SPU_AFLAGS     := -c -D__ASSEMBLY__ -I$(srctree)/include \
-                  -I$(objtree)/include2 -D__KERNEL__
+SPU_CFLAGS     := -O2 -Wall -I$(srctree)/include -D__KERNEL__
+SPU_AFLAGS     := -c -D__ASSEMBLY__ -I$(srctree)/include -D__KERNEL__
 SPU_LDFLAGS    := -N -Ttext=0x0
 
 $(obj)/switch.o: $(obj)/spu_save_dump.h $(obj)/spu_restore_dump.h
index 52f3df3b4ca0a6a196e1712e6038a303661b7aed..8f41685d8f42b5669ee2a7e2492b5755e6919986 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/reboot.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/adb.h>
 #include <linux/module.h>
 #include <linux/delay.h>
index 291ac9d8cbee09d4966fa0a46b846bebdb2c71df..524d971a1478eabfe0a24dc8a24a64252e23ad98 100644 (file)
@@ -90,3 +90,36 @@ config MPC10X_OPENPIC
 config MPC10X_STORE_GATHERING
        bool "Enable MPC10x store gathering"
        depends on MPC10X_BRIDGE
+
+config GAMECUBE_COMMON
+       bool
+
+config USBGECKO_UDBG
+       bool "USB Gecko udbg console for the Nintendo GameCube/Wii"
+       depends on GAMECUBE_COMMON
+       help
+         If you say yes to this option, support will be included for the
+         USB Gecko adapter as an udbg console.
+         The USB Gecko is a EXI to USB Serial converter that can be plugged
+         into a memcard slot in the Nintendo GameCube/Wii.
+
+         This driver bypasses the EXI layer completely.
+
+         If in doubt, say N here.
+
+config GAMECUBE
+       bool "Nintendo-GameCube"
+       depends on EMBEDDED6xx
+       select GAMECUBE_COMMON
+       help
+         Select GAMECUBE if configuring for the Nintendo GameCube.
+         More information at: <http://gc-linux.sourceforge.net/>
+
+config WII
+       bool "Nintendo-Wii"
+       depends on EMBEDDED6xx
+       select GAMECUBE_COMMON
+       help
+         Select WII if configuring for the Nintendo Wii.
+         More information at: <http://gc-linux.sourceforge.net/>
+
index 0773c08bd444994a6a450e94f8d474adcedf22b6..66c23e423f40784ae85affb14bd5d7e95f8d68c2 100644 (file)
@@ -7,3 +7,7 @@ obj-$(CONFIG_STORCENTER)        += storcenter.o
 obj-$(CONFIG_PPC_HOLLY)                += holly.o
 obj-$(CONFIG_PPC_PRPMC2800)    += prpmc2800.o
 obj-$(CONFIG_PPC_C2K)          += c2k.o
+obj-$(CONFIG_USBGECKO_UDBG)    += usbgecko_udbg.o
+obj-$(CONFIG_GAMECUBE_COMMON)  += flipper-pic.o
+obj-$(CONFIG_GAMECUBE)         += gamecube.o
+obj-$(CONFIG_WII)              += wii.o hlwd-pic.o
diff --git a/arch/powerpc/platforms/embedded6xx/flipper-pic.c b/arch/powerpc/platforms/embedded6xx/flipper-pic.c
new file mode 100644 (file)
index 0000000..c278bd3
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/flipper-pic.c
+ *
+ * Nintendo GameCube/Wii "Flipper" interrupt controller support.
+ * Copyright (C) 2004-2009 The GameCube Linux Team
+ * Copyright (C) 2007,2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+#define DRV_MODULE_NAME "flipper-pic"
+#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/of.h>
+#include <asm/io.h>
+
+#include "flipper-pic.h"
+
+#define FLIPPER_NR_IRQS                32
+
+/*
+ * Each interrupt has a corresponding bit in both
+ * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers.
+ *
+ * Enabling/disabling an interrupt line involves setting/clearing
+ * the corresponding bit in IMR.
+ * Except for the RSW interrupt, all interrupts get deasserted automatically
+ * when the source deasserts the interrupt.
+ */
+#define FLIPPER_ICR            0x00
+#define FLIPPER_ICR_RSS                (1<<16) /* reset switch state */
+
+#define FLIPPER_IMR            0x04
+
+#define FLIPPER_RESET          0x24
+
+
+/*
+ * IRQ chip hooks.
+ *
+ */
+
+static void flipper_pic_mask_and_ack(unsigned int virq)
+{
+       int irq = virq_to_hw(virq);
+       void __iomem *io_base = get_irq_chip_data(virq);
+       u32 mask = 1 << irq;
+
+       clrbits32(io_base + FLIPPER_IMR, mask);
+       /* this is at least needed for RSW */
+       out_be32(io_base + FLIPPER_ICR, mask);
+}
+
+static void flipper_pic_ack(unsigned int virq)
+{
+       int irq = virq_to_hw(virq);
+       void __iomem *io_base = get_irq_chip_data(virq);
+
+       /* this is at least needed for RSW */
+       out_be32(io_base + FLIPPER_ICR, 1 << irq);
+}
+
+static void flipper_pic_mask(unsigned int virq)
+{
+       int irq = virq_to_hw(virq);
+       void __iomem *io_base = get_irq_chip_data(virq);
+
+       clrbits32(io_base + FLIPPER_IMR, 1 << irq);
+}
+
+static void flipper_pic_unmask(unsigned int virq)
+{
+       int irq = virq_to_hw(virq);
+       void __iomem *io_base = get_irq_chip_data(virq);
+
+       setbits32(io_base + FLIPPER_IMR, 1 << irq);
+}
+
+
+static struct irq_chip flipper_pic = {
+       .name           = "flipper-pic",
+       .ack            = flipper_pic_ack,
+       .mask_ack       = flipper_pic_mask_and_ack,
+       .mask           = flipper_pic_mask,
+       .unmask         = flipper_pic_unmask,
+};
+
+/*
+ * IRQ host hooks.
+ *
+ */
+
+static struct irq_host *flipper_irq_host;
+
+static int flipper_pic_map(struct irq_host *h, unsigned int virq,
+                          irq_hw_number_t hwirq)
+{
+       set_irq_chip_data(virq, h->host_data);
+       irq_to_desc(virq)->status |= IRQ_LEVEL;
+       set_irq_chip_and_handler(virq, &flipper_pic, handle_level_irq);
+       return 0;
+}
+
+static void flipper_pic_unmap(struct irq_host *h, unsigned int irq)
+{
+       set_irq_chip_data(irq, NULL);
+       set_irq_chip(irq, NULL);
+}
+
+static int flipper_pic_match(struct irq_host *h, struct device_node *np)
+{
+       return 1;
+}
+
+
+static struct irq_host_ops flipper_irq_host_ops = {
+       .map = flipper_pic_map,
+       .unmap = flipper_pic_unmap,
+       .match = flipper_pic_match,
+};
+
+/*
+ * Platform hooks.
+ *
+ */
+
+static void __flipper_quiesce(void __iomem *io_base)
+{
+       /* mask and ack all IRQs */
+       out_be32(io_base + FLIPPER_IMR, 0x00000000);
+       out_be32(io_base + FLIPPER_ICR, 0xffffffff);
+}
+
+struct irq_host * __init flipper_pic_init(struct device_node *np)
+{
+       struct device_node *pi;
+       struct irq_host *irq_host = NULL;
+       struct resource res;
+       void __iomem *io_base;
+       int retval;
+
+       pi = of_get_parent(np);
+       if (!pi) {
+               pr_err("no parent found\n");
+               goto out;
+       }
+       if (!of_device_is_compatible(pi, "nintendo,flipper-pi")) {
+               pr_err("unexpected parent compatible\n");
+               goto out;
+       }
+
+       retval = of_address_to_resource(pi, 0, &res);
+       if (retval) {
+               pr_err("no io memory range found\n");
+               goto out;
+       }
+       io_base = ioremap(res.start, resource_size(&res));
+
+       pr_info("controller at 0x%08x mapped to 0x%p\n", res.start, io_base);
+
+       __flipper_quiesce(io_base);
+
+       irq_host = irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, FLIPPER_NR_IRQS,
+                                 &flipper_irq_host_ops, -1);
+       if (!irq_host) {
+               pr_err("failed to allocate irq_host\n");
+               return NULL;
+       }
+
+       irq_host->host_data = io_base;
+
+out:
+       return irq_host;
+}
+
+unsigned int flipper_pic_get_irq(void)
+{
+       void __iomem *io_base = flipper_irq_host->host_data;
+       int irq;
+       u32 irq_status;
+
+       irq_status = in_be32(io_base + FLIPPER_ICR) &
+                    in_be32(io_base + FLIPPER_IMR);
+       if (irq_status == 0)
+               return NO_IRQ;  /* no more IRQs pending */
+
+       irq = __ffs(irq_status);
+       return irq_linear_revmap(flipper_irq_host, irq);
+}
+
+/*
+ * Probe function.
+ *
+ */
+
+void __init flipper_pic_probe(void)
+{
+       struct device_node *np;
+
+       np = of_find_compatible_node(NULL, NULL, "nintendo,flipper-pic");
+       BUG_ON(!np);
+
+       flipper_irq_host = flipper_pic_init(np);
+       BUG_ON(!flipper_irq_host);
+
+       irq_set_default_host(flipper_irq_host);
+
+       of_node_put(np);
+}
+
+/*
+ * Misc functions related to the flipper chipset.
+ *
+ */
+
+/**
+ * flipper_quiesce() - quiesce flipper irq controller
+ *
+ * Mask and ack all interrupt sources.
+ *
+ */
+void flipper_quiesce(void)
+{
+       void __iomem *io_base = flipper_irq_host->host_data;
+
+       __flipper_quiesce(io_base);
+}
+
+/*
+ * Resets the platform.
+ */
+void flipper_platform_reset(void)
+{
+       void __iomem *io_base;
+
+       if (flipper_irq_host && flipper_irq_host->host_data) {
+               io_base = flipper_irq_host->host_data;
+               out_8(io_base + FLIPPER_RESET, 0x00);
+       }
+}
+
+/*
+ * Returns non-zero if the reset button is pressed.
+ */
+int flipper_is_reset_button_pressed(void)
+{
+       void __iomem *io_base;
+       u32 icr;
+
+       if (flipper_irq_host && flipper_irq_host->host_data) {
+               io_base = flipper_irq_host->host_data;
+               icr = in_be32(io_base + FLIPPER_ICR);
+               return !(icr & FLIPPER_ICR_RSS);
+       }
+       return 0;
+}
+
diff --git a/arch/powerpc/platforms/embedded6xx/flipper-pic.h b/arch/powerpc/platforms/embedded6xx/flipper-pic.h
new file mode 100644 (file)
index 0000000..e339186
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/flipper-pic.h
+ *
+ * Nintendo GameCube/Wii "Flipper" interrupt controller support.
+ * Copyright (C) 2004-2009 The GameCube Linux Team
+ * Copyright (C) 2007,2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#ifndef __FLIPPER_PIC_H
+#define __FLIPPER_PIC_H
+
+unsigned int flipper_pic_get_irq(void);
+void __init flipper_pic_probe(void);
+
+void flipper_quiesce(void);
+void flipper_platform_reset(void);
+int flipper_is_reset_button_pressed(void);
+
+#endif
diff --git a/arch/powerpc/platforms/embedded6xx/gamecube.c b/arch/powerpc/platforms/embedded6xx/gamecube.c
new file mode 100644 (file)
index 0000000..1106fd9
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/gamecube.c
+ *
+ * Nintendo GameCube board-specific support
+ * Copyright (C) 2004-2009 The GameCube Linux Team
+ * Copyright (C) 2007,2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/kexec.h>
+#include <linux/seq_file.h>
+#include <linux/of_platform.h>
+
+#include <asm/io.h>
+#include <asm/machdep.h>
+#include <asm/prom.h>
+#include <asm/time.h>
+#include <asm/udbg.h>
+
+#include "flipper-pic.h"
+#include "usbgecko_udbg.h"
+
+
+static void gamecube_spin(void)
+{
+       /* spin until power button pressed */
+       for (;;)
+               cpu_relax();
+}
+
+static void gamecube_restart(char *cmd)
+{
+       local_irq_disable();
+       flipper_platform_reset();
+       gamecube_spin();
+}
+
+static void gamecube_power_off(void)
+{
+       local_irq_disable();
+       gamecube_spin();
+}
+
+static void gamecube_halt(void)
+{
+       gamecube_restart(NULL);
+}
+
+static void __init gamecube_init_early(void)
+{
+       ug_udbg_init();
+}
+
+static int __init gamecube_probe(void)
+{
+       unsigned long dt_root;
+
+       dt_root = of_get_flat_dt_root();
+       if (!of_flat_dt_is_compatible(dt_root, "nintendo,gamecube"))
+               return 0;
+
+       return 1;
+}
+
+static void gamecube_shutdown(void)
+{
+       flipper_quiesce();
+}
+
+#ifdef CONFIG_KEXEC
+static int gamecube_kexec_prepare(struct kimage *image)
+{
+       return 0;
+}
+#endif /* CONFIG_KEXEC */
+
+
+define_machine(gamecube) {
+       .name                   = "gamecube",
+       .probe                  = gamecube_probe,
+       .init_early             = gamecube_init_early,
+       .restart                = gamecube_restart,
+       .power_off              = gamecube_power_off,
+       .halt                   = gamecube_halt,
+       .init_IRQ               = flipper_pic_probe,
+       .get_irq                = flipper_pic_get_irq,
+       .calibrate_decr         = generic_calibrate_decr,
+       .progress               = udbg_progress,
+       .machine_shutdown       = gamecube_shutdown,
+#ifdef CONFIG_KEXEC
+       .machine_kexec_prepare  = gamecube_kexec_prepare,
+#endif
+};
+
+
+static struct of_device_id gamecube_of_bus[] = {
+       { .compatible = "nintendo,flipper", },
+       { },
+};
+
+static int __init gamecube_device_probe(void)
+{
+       if (!machine_is(gamecube))
+               return 0;
+
+       of_platform_bus_probe(NULL, gamecube_of_bus, NULL);
+       return 0;
+}
+device_initcall(gamecube_device_probe);
+
diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
new file mode 100644 (file)
index 0000000..a771f91
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/hlwd-pic.c
+ *
+ * Nintendo Wii "Hollywood" interrupt controller support.
+ * Copyright (C) 2009 The GameCube Linux Team
+ * Copyright (C) 2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+#define DRV_MODULE_NAME "hlwd-pic"
+#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/of.h>
+#include <asm/io.h>
+
+#include "hlwd-pic.h"
+
+#define HLWD_NR_IRQS   32
+
+/*
+ * Each interrupt has a corresponding bit in both
+ * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers.
+ *
+ * Enabling/disabling an interrupt line involves asserting/clearing
+ * the corresponding bit in IMR. ACK'ing a request simply involves
+ * asserting the corresponding bit in ICR.
+ */
+#define HW_BROADWAY_ICR                0x00
+#define HW_BROADWAY_IMR                0x04
+
+
+/*
+ * IRQ chip hooks.
+ *
+ */
+
+static void hlwd_pic_mask_and_ack(unsigned int virq)
+{
+       int irq = virq_to_hw(virq);
+       void __iomem *io_base = get_irq_chip_data(virq);
+       u32 mask = 1 << irq;
+
+       clrbits32(io_base + HW_BROADWAY_IMR, mask);
+       out_be32(io_base + HW_BROADWAY_ICR, mask);
+}
+
+static void hlwd_pic_ack(unsigned int virq)
+{
+       int irq = virq_to_hw(virq);
+       void __iomem *io_base = get_irq_chip_data(virq);
+
+       out_be32(io_base + HW_BROADWAY_ICR, 1 << irq);
+}
+
+static void hlwd_pic_mask(unsigned int virq)
+{
+       int irq = virq_to_hw(virq);
+       void __iomem *io_base = get_irq_chip_data(virq);
+
+       clrbits32(io_base + HW_BROADWAY_IMR, 1 << irq);
+}
+
+static void hlwd_pic_unmask(unsigned int virq)
+{
+       int irq = virq_to_hw(virq);
+       void __iomem *io_base = get_irq_chip_data(virq);
+
+       setbits32(io_base + HW_BROADWAY_IMR, 1 << irq);
+}
+
+
+static struct irq_chip hlwd_pic = {
+       .name           = "hlwd-pic",
+       .ack            = hlwd_pic_ack,
+       .mask_ack       = hlwd_pic_mask_and_ack,
+       .mask           = hlwd_pic_mask,
+       .unmask         = hlwd_pic_unmask,
+};
+
+/*
+ * IRQ host hooks.
+ *
+ */
+
+static struct irq_host *hlwd_irq_host;
+
+static int hlwd_pic_map(struct irq_host *h, unsigned int virq,
+                          irq_hw_number_t hwirq)
+{
+       set_irq_chip_data(virq, h->host_data);
+       irq_to_desc(virq)->status |= IRQ_LEVEL;
+       set_irq_chip_and_handler(virq, &hlwd_pic, handle_level_irq);
+       return 0;
+}
+
+static void hlwd_pic_unmap(struct irq_host *h, unsigned int irq)
+{
+       set_irq_chip_data(irq, NULL);
+       set_irq_chip(irq, NULL);
+}
+
+static struct irq_host_ops hlwd_irq_host_ops = {
+       .map = hlwd_pic_map,
+       .unmap = hlwd_pic_unmap,
+};
+
+static unsigned int __hlwd_pic_get_irq(struct irq_host *h)
+{
+       void __iomem *io_base = h->host_data;
+       int irq;
+       u32 irq_status;
+
+       irq_status = in_be32(io_base + HW_BROADWAY_ICR) &
+                    in_be32(io_base + HW_BROADWAY_IMR);
+       if (irq_status == 0)
+               return NO_IRQ;  /* no more IRQs pending */
+
+       irq = __ffs(irq_status);
+       return irq_linear_revmap(h, irq);
+}
+
+static void hlwd_pic_irq_cascade(unsigned int cascade_virq,
+                                     struct irq_desc *desc)
+{
+       struct irq_host *irq_host = get_irq_data(cascade_virq);
+       unsigned int virq;
+
+       raw_spin_lock(&desc->lock);
+       desc->chip->mask(cascade_virq); /* IRQ_LEVEL */
+       raw_spin_unlock(&desc->lock);
+
+       virq = __hlwd_pic_get_irq(irq_host);
+       if (virq != NO_IRQ)
+               generic_handle_irq(virq);
+       else
+               pr_err("spurious interrupt!\n");
+
+       raw_spin_lock(&desc->lock);
+       desc->chip->ack(cascade_virq); /* IRQ_LEVEL */
+       if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask)
+               desc->chip->unmask(cascade_virq);
+       raw_spin_unlock(&desc->lock);
+}
+
+/*
+ * Platform hooks.
+ *
+ */
+
+static void __hlwd_quiesce(void __iomem *io_base)
+{
+       /* mask and ack all IRQs */
+       out_be32(io_base + HW_BROADWAY_IMR, 0);
+       out_be32(io_base + HW_BROADWAY_ICR, 0xffffffff);
+}
+
+struct irq_host *hlwd_pic_init(struct device_node *np)
+{
+       struct irq_host *irq_host;
+       struct resource res;
+       void __iomem *io_base;
+       int retval;
+
+       retval = of_address_to_resource(np, 0, &res);
+       if (retval) {
+               pr_err("no io memory range found\n");
+               return NULL;
+       }
+       io_base = ioremap(res.start, resource_size(&res));
+       if (!io_base) {
+               pr_err("ioremap failed\n");
+               return NULL;
+       }
+
+       pr_info("controller at 0x%08x mapped to 0x%p\n", res.start, io_base);
+
+       __hlwd_quiesce(io_base);
+
+       irq_host = irq_alloc_host(np, IRQ_HOST_MAP_LINEAR, HLWD_NR_IRQS,
+                                 &hlwd_irq_host_ops, -1);
+       if (!irq_host) {
+               pr_err("failed to allocate irq_host\n");
+               return NULL;
+       }
+       irq_host->host_data = io_base;
+
+       return irq_host;
+}
+
+unsigned int hlwd_pic_get_irq(void)
+{
+       return __hlwd_pic_get_irq(hlwd_irq_host);
+}
+
+/*
+ * Probe function.
+ *
+ */
+
+void hlwd_pic_probe(void)
+{
+       struct irq_host *host;
+       struct device_node *np;
+       const u32 *interrupts;
+       int cascade_virq;
+
+       for_each_compatible_node(np, NULL, "nintendo,hollywood-pic") {
+               interrupts = of_get_property(np, "interrupts", NULL);
+               if (interrupts) {
+                       host = hlwd_pic_init(np);
+                       BUG_ON(!host);
+                       cascade_virq = irq_of_parse_and_map(np, 0);
+                       set_irq_data(cascade_virq, host);
+                       set_irq_chained_handler(cascade_virq,
+                                               hlwd_pic_irq_cascade);
+                       hlwd_irq_host = host;
+                       break;
+               }
+       }
+}
+
+/**
+ * hlwd_quiesce() - quiesce hollywood irq controller
+ *
+ * Mask and ack all interrupt sources.
+ *
+ */
+void hlwd_quiesce(void)
+{
+       void __iomem *io_base = hlwd_irq_host->host_data;
+
+       __hlwd_quiesce(io_base);
+}
+
diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.h b/arch/powerpc/platforms/embedded6xx/hlwd-pic.h
new file mode 100644 (file)
index 0000000..d2e5a09
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/hlwd-pic.h
+ *
+ * Nintendo Wii "Hollywood" interrupt controller support.
+ * Copyright (C) 2009 The GameCube Linux Team
+ * Copyright (C) 2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#ifndef __HLWD_PIC_H
+#define __HLWD_PIC_H
+
+extern unsigned int hlwd_pic_get_irq(void);
+extern void hlwd_pic_probe(void);
+extern void hlwd_quiesce(void);
+
+#endif
diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
new file mode 100644 (file)
index 0000000..20a8ed9
--- /dev/null
@@ -0,0 +1,328 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
+ *
+ * udbg serial input/output routines for the USB Gecko adapter.
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#include <mm/mmu_decl.h>
+
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <asm/udbg.h>
+#include <asm/fixmap.h>
+
+#include "usbgecko_udbg.h"
+
+
+#define EXI_CLK_32MHZ           5
+
+#define EXI_CSR                 0x00
+#define   EXI_CSR_CLKMASK       (0x7<<4)
+#define     EXI_CSR_CLK_32MHZ   (EXI_CLK_32MHZ<<4)
+#define   EXI_CSR_CSMASK        (0x7<<7)
+#define     EXI_CSR_CS_0        (0x1<<7)  /* Chip Select 001 */
+
+#define EXI_CR                  0x0c
+#define   EXI_CR_TSTART         (1<<0)
+#define   EXI_CR_WRITE         (1<<2)
+#define   EXI_CR_READ_WRITE     (2<<2)
+#define   EXI_CR_TLEN(len)      (((len)-1)<<4)
+
+#define EXI_DATA                0x10
+
+#define UG_READ_ATTEMPTS       100
+#define UG_WRITE_ATTEMPTS      100
+
+
+static void __iomem *ug_io_base;
+
+/*
+ * Performs one input/output transaction between the exi host and the usbgecko.
+ */
+static u32 ug_io_transaction(u32 in)
+{
+       u32 __iomem *csr_reg = ug_io_base + EXI_CSR;
+       u32 __iomem *data_reg = ug_io_base + EXI_DATA;
+       u32 __iomem *cr_reg = ug_io_base + EXI_CR;
+       u32 csr, data, cr;
+
+       /* select */
+       csr = EXI_CSR_CLK_32MHZ | EXI_CSR_CS_0;
+       out_be32(csr_reg, csr);
+
+       /* read/write */
+       data = in;
+       out_be32(data_reg, data);
+       cr = EXI_CR_TLEN(2) | EXI_CR_READ_WRITE | EXI_CR_TSTART;
+       out_be32(cr_reg, cr);
+
+       while (in_be32(cr_reg) & EXI_CR_TSTART)
+               barrier();
+
+       /* deselect */
+       out_be32(csr_reg, 0);
+
+       /* result */
+       data = in_be32(data_reg);
+
+       return data;
+}
+
+/*
+ * Returns true if an usbgecko adapter is found.
+ */
+static int ug_is_adapter_present(void)
+{
+       if (!ug_io_base)
+               return 0;
+
+       return ug_io_transaction(0x90000000) == 0x04700000;
+}
+
+/*
+ * Returns true if the TX fifo is ready for transmission.
+ */
+static int ug_is_txfifo_ready(void)
+{
+       return ug_io_transaction(0xc0000000) & 0x04000000;
+}
+
+/*
+ * Tries to transmit a character.
+ * If the TX fifo is not ready the result is undefined.
+ */
+static void ug_raw_putc(char ch)
+{
+       ug_io_transaction(0xb0000000 | (ch << 20));
+}
+
+/*
+ * Transmits a character.
+ * It silently fails if the TX fifo is not ready after a number of retries.
+ */
+static void ug_putc(char ch)
+{
+       int count = UG_WRITE_ATTEMPTS;
+
+       if (!ug_io_base)
+               return;
+
+       if (ch == '\n')
+               ug_putc('\r');
+
+       while (!ug_is_txfifo_ready() && count--)
+               barrier();
+       if (count >= 0)
+               ug_raw_putc(ch);
+}
+
+/*
+ * Returns true if the RX fifo is ready for transmission.
+ */
+static int ug_is_rxfifo_ready(void)
+{
+       return ug_io_transaction(0xd0000000) & 0x04000000;
+}
+
+/*
+ * Tries to receive a character.
+ * If a character is unavailable the function returns -1.
+ */
+static int ug_raw_getc(void)
+{
+       u32 data = ug_io_transaction(0xa0000000);
+       if (data & 0x08000000)
+               return (data >> 16) & 0xff;
+       else
+               return -1;
+}
+
+/*
+ * Receives a character.
+ * It fails if the RX fifo is not ready after a number of retries.
+ */
+static int ug_getc(void)
+{
+       int count = UG_READ_ATTEMPTS;
+
+       if (!ug_io_base)
+               return -1;
+
+       while (!ug_is_rxfifo_ready() && count--)
+               barrier();
+       return ug_raw_getc();
+}
+
+/*
+ * udbg functions.
+ *
+ */
+
+/*
+ * Transmits a character.
+ */
+void ug_udbg_putc(char ch)
+{
+       ug_putc(ch);
+}
+
+/*
+ * Receives a character. Waits until a character is available.
+ */
+static int ug_udbg_getc(void)
+{
+       int ch;
+
+       while ((ch = ug_getc()) == -1)
+               barrier();
+       return ch;
+}
+
+/*
+ * Receives a character. If a character is not available, returns -1.
+ */
+static int ug_udbg_getc_poll(void)
+{
+       if (!ug_is_rxfifo_ready())
+               return -1;
+       return ug_getc();
+}
+
+/*
+ * Retrieves and prepares the virtual address needed to access the hardware.
+ */
+static void __iomem *ug_udbg_setup_exi_io_base(struct device_node *np)
+{
+       void __iomem *exi_io_base = NULL;
+       phys_addr_t paddr;
+       const unsigned int *reg;
+
+       reg = of_get_property(np, "reg", NULL);
+       if (reg) {
+               paddr = of_translate_address(np, reg);
+               if (paddr)
+                       exi_io_base = ioremap(paddr, reg[1]);
+       }
+       return exi_io_base;
+}
+
+/*
+ * Checks if a USB Gecko adapter is inserted in any memory card slot.
+ */
+static void __iomem *ug_udbg_probe(void __iomem *exi_io_base)
+{
+       int i;
+
+       /* look for a usbgecko on memcard slots A and B */
+       for (i = 0; i < 2; i++) {
+               ug_io_base = exi_io_base + 0x14 * i;
+               if (ug_is_adapter_present())
+                       break;
+       }
+       if (i == 2)
+               ug_io_base = NULL;
+       return ug_io_base;
+
+}
+
+/*
+ * USB Gecko udbg support initialization.
+ */
+void __init ug_udbg_init(void)
+{
+       struct device_node *np;
+       void __iomem *exi_io_base;
+
+       if (ug_io_base)
+               udbg_printf("%s: early -> final\n", __func__);
+
+       np = of_find_compatible_node(NULL, NULL, "nintendo,flipper-exi");
+       if (!np) {
+               udbg_printf("%s: EXI node not found\n", __func__);
+               goto done;
+       }
+
+       exi_io_base = ug_udbg_setup_exi_io_base(np);
+       if (!exi_io_base) {
+               udbg_printf("%s: failed to setup EXI io base\n", __func__);
+               goto done;
+       }
+
+       if (!ug_udbg_probe(exi_io_base)) {
+               udbg_printf("usbgecko_udbg: not found\n");
+               iounmap(exi_io_base);
+       } else {
+               udbg_putc = ug_udbg_putc;
+               udbg_getc = ug_udbg_getc;
+               udbg_getc_poll = ug_udbg_getc_poll;
+               udbg_printf("usbgecko_udbg: ready\n");
+       }
+
+done:
+       if (np)
+               of_node_put(np);
+       return;
+}
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+
+static phys_addr_t __init ug_early_grab_io_addr(void)
+{
+#if defined(CONFIG_GAMECUBE)
+       return 0x0c000000;
+#elif defined(CONFIG_WII)
+       return 0x0d000000;
+#else
+#error Invalid platform for USB Gecko based early debugging.
+#endif
+}
+
+/*
+ * USB Gecko early debug support initialization for udbg.
+ */
+void __init udbg_init_usbgecko(void)
+{
+       void __iomem *early_debug_area;
+       void __iomem *exi_io_base;
+
+       /*
+        * At this point we have a BAT already setup that enables I/O
+        * to the EXI hardware.
+        *
+        * The BAT uses a virtual address range reserved at the fixmap.
+        * This must match the virtual address configured in
+        * head_32.S:setup_usbgecko_bat().
+        */
+       early_debug_area = (void __iomem *)__fix_to_virt(FIX_EARLY_DEBUG_BASE);
+       exi_io_base = early_debug_area + 0x00006800;
+
+       /* try to detect a USB Gecko */
+       if (!ug_udbg_probe(exi_io_base))
+               return;
+
+       /* we found a USB Gecko, load udbg hooks */
+       udbg_putc = ug_udbg_putc;
+       udbg_getc = ug_udbg_getc;
+       udbg_getc_poll = ug_udbg_getc_poll;
+
+       /*
+        * Prepare again the same BAT for MMU_init.
+        * This allows udbg I/O to continue working after the MMU is
+        * turned on for real.
+        * It is safe to continue using the same virtual address as it is
+        * a reserved fixmap area.
+        */
+       setbat(1, (unsigned long)early_debug_area,
+              ug_early_grab_io_addr(), 128*1024, PAGE_KERNEL_NCG);
+}
+
+#endif /* CONFIG_PPC_EARLY_DEBUG_USBGECKO */
+
diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
new file mode 100644 (file)
index 0000000..bb6cde4
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
+ *
+ * udbg serial input/output routines for the USB Gecko adapter.
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+#ifndef __USBGECKO_UDBG_H
+#define __USBGECKO_UDBG_H
+
+#ifdef CONFIG_USBGECKO_UDBG
+
+extern void __init ug_udbg_init(void);
+
+#else
+
+static inline void __init ug_udbg_init(void)
+{
+}
+
+#endif /* CONFIG_USBGECKO_UDBG */
+
+void __init udbg_init_usbgecko(void);
+
+#endif /* __USBGECKO_UDBG_H */
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/powerpc/platforms/embedded6xx/wii.c
new file mode 100644 (file)
index 0000000..57e5b60
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * arch/powerpc/platforms/embedded6xx/wii.c
+ *
+ * Nintendo Wii board-specific support
+ * Copyright (C) 2008-2009 The GameCube Linux Team
+ * Copyright (C) 2008,2009 Albert Herranz
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+#define DRV_MODULE_NAME "wii"
+#define pr_fmt(fmt) DRV_MODULE_NAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/seq_file.h>
+#include <linux/kexec.h>
+#include <linux/of_platform.h>
+#include <linux/lmb.h>
+#include <mm/mmu_decl.h>
+
+#include <asm/io.h>
+#include <asm/machdep.h>
+#include <asm/prom.h>
+#include <asm/time.h>
+#include <asm/udbg.h>
+
+#include "flipper-pic.h"
+#include "hlwd-pic.h"
+#include "usbgecko_udbg.h"
+
+/* control block */
+#define HW_CTRL_COMPATIBLE     "nintendo,hollywood-control"
+
+#define HW_CTRL_RESETS         0x94
+#define HW_CTRL_RESETS_SYS     (1<<0)
+
+/* gpio */
+#define HW_GPIO_COMPATIBLE     "nintendo,hollywood-gpio"
+
+#define HW_GPIO_BASE(idx)      (idx * 0x20)
+#define HW_GPIO_OUT(idx)       (HW_GPIO_BASE(idx) + 0)
+#define HW_GPIO_DIR(idx)       (HW_GPIO_BASE(idx) + 4)
+
+#define HW_GPIO_SHUTDOWN       (1<<1)
+#define HW_GPIO_SLOT_LED       (1<<5)
+#define HW_GPIO_SENSOR_BAR     (1<<8)
+
+
+static void __iomem *hw_ctrl;
+static void __iomem *hw_gpio;
+
+unsigned long wii_hole_start;
+unsigned long wii_hole_size;
+
+
+static int __init page_aligned(unsigned long x)
+{
+       return !(x & (PAGE_SIZE-1));
+}
+
+void __init wii_memory_fixups(void)
+{
+       struct lmb_property *p = lmb.memory.region;
+
+       /*
+        * This is part of a workaround to allow the use of two
+        * discontiguous RAM ranges on the Wii, even if this is
+        * currently unsupported on 32-bit PowerPC Linux.
+        *
+        * We coealesce the two memory ranges of the Wii into a
+        * single range, then create a reservation for the "hole"
+        * between both ranges.
+        */
+
+       BUG_ON(lmb.memory.cnt != 2);
+       BUG_ON(!page_aligned(p[0].base) || !page_aligned(p[1].base));
+
+       p[0].size = _ALIGN_DOWN(p[0].size, PAGE_SIZE);
+       p[1].size = _ALIGN_DOWN(p[1].size, PAGE_SIZE);
+
+       wii_hole_start = p[0].base + p[0].size;
+       wii_hole_size = p[1].base - wii_hole_start;
+
+       pr_info("MEM1: <%08llx %08llx>\n", p[0].base, p[0].size);
+       pr_info("HOLE: <%08lx %08lx>\n", wii_hole_start, wii_hole_size);
+       pr_info("MEM2: <%08llx %08llx>\n", p[1].base, p[1].size);
+
+       p[0].size += wii_hole_size + p[1].size;
+
+       lmb.memory.cnt = 1;
+       lmb_analyze();
+
+       /* reserve the hole */
+       lmb_reserve(wii_hole_start, wii_hole_size);
+
+       /* allow ioremapping the address space in the hole */
+       __allow_ioremap_reserved = 1;
+}
+
+unsigned long __init wii_mmu_mapin_mem2(unsigned long top)
+{
+       unsigned long delta, size, bl;
+       unsigned long max_size = (256<<20);
+
+       /* MEM2 64MB@0x10000000 */
+       delta = wii_hole_start + wii_hole_size;
+       size = top - delta;
+       for (bl = 128<<10; bl < max_size; bl <<= 1) {
+               if (bl * 2 > size)
+                       break;
+       }
+       setbat(4, PAGE_OFFSET+delta, delta, bl, PAGE_KERNEL_X);
+       return delta + bl;
+}
+
+static void wii_spin(void)
+{
+       local_irq_disable();
+       for (;;)
+               cpu_relax();
+}
+
+static void __iomem *wii_ioremap_hw_regs(char *name, char *compatible)
+{
+       void __iomem *hw_regs = NULL;
+       struct device_node *np;
+       struct resource res;
+       int error = -ENODEV;
+
+       np = of_find_compatible_node(NULL, NULL, compatible);
+       if (!np) {
+               pr_err("no compatible node found for %s\n", compatible);
+               goto out;
+       }
+       error = of_address_to_resource(np, 0, &res);
+       if (error) {
+               pr_err("no valid reg found for %s\n", np->name);
+               goto out_put;
+       }
+
+       hw_regs = ioremap(res.start, resource_size(&res));
+       if (hw_regs) {
+               pr_info("%s at 0x%08x mapped to 0x%p\n", name,
+                       res.start, hw_regs);
+       }
+
+out_put:
+       of_node_put(np);
+out:
+       return hw_regs;
+}
+
+static void __init wii_setup_arch(void)
+{
+       hw_ctrl = wii_ioremap_hw_regs("hw_ctrl", HW_CTRL_COMPATIBLE);
+       hw_gpio = wii_ioremap_hw_regs("hw_gpio", HW_GPIO_COMPATIBLE);
+       if (hw_gpio) {
+               /* turn off the front blue led and IR light */
+               clrbits32(hw_gpio + HW_GPIO_OUT(0),
+                         HW_GPIO_SLOT_LED | HW_GPIO_SENSOR_BAR);
+       }
+}
+
+static void wii_restart(char *cmd)
+{
+       local_irq_disable();
+
+       if (hw_ctrl) {
+               /* clear the system reset pin to cause a reset */
+               clrbits32(hw_ctrl + HW_CTRL_RESETS, HW_CTRL_RESETS_SYS);
+       }
+       wii_spin();
+}
+
+static void wii_power_off(void)
+{
+       local_irq_disable();
+
+       if (hw_gpio) {
+               /* make sure that the poweroff GPIO is configured as output */
+               setbits32(hw_gpio + HW_GPIO_DIR(1), HW_GPIO_SHUTDOWN);
+
+               /* drive the poweroff GPIO high */
+               setbits32(hw_gpio + HW_GPIO_OUT(1), HW_GPIO_SHUTDOWN);
+       }
+       wii_spin();
+}
+
+static void wii_halt(void)
+{
+       if (ppc_md.restart)
+               ppc_md.restart(NULL);
+       wii_spin();
+}
+
+static void __init wii_init_early(void)
+{
+       ug_udbg_init();
+}
+
+static void __init wii_pic_probe(void)
+{
+       flipper_pic_probe();
+       hlwd_pic_probe();
+}
+
+static int __init wii_probe(void)
+{
+       unsigned long dt_root;
+
+       dt_root = of_get_flat_dt_root();
+       if (!of_flat_dt_is_compatible(dt_root, "nintendo,wii"))
+               return 0;
+
+       return 1;
+}
+
+static void wii_shutdown(void)
+{
+       hlwd_quiesce();
+       flipper_quiesce();
+}
+
+#ifdef CONFIG_KEXEC
+static int wii_machine_kexec_prepare(struct kimage *image)
+{
+       return 0;
+}
+#endif /* CONFIG_KEXEC */
+
+define_machine(wii) {
+       .name                   = "wii",
+       .probe                  = wii_probe,
+       .init_early             = wii_init_early,
+       .setup_arch             = wii_setup_arch,
+       .restart                = wii_restart,
+       .power_off              = wii_power_off,
+       .halt                   = wii_halt,
+       .init_IRQ               = wii_pic_probe,
+       .get_irq                = flipper_pic_get_irq,
+       .calibrate_decr         = generic_calibrate_decr,
+       .progress               = udbg_progress,
+       .machine_shutdown       = wii_shutdown,
+#ifdef CONFIG_KEXEC
+       .machine_kexec_prepare  = wii_machine_kexec_prepare,
+#endif
+};
+
+static struct of_device_id wii_of_bus[] = {
+       { .compatible = "nintendo,hollywood", },
+       { },
+};
+
+static int __init wii_device_probe(void)
+{
+       if (!machine_is(wii))
+               return 0;
+
+       of_platform_bus_probe(NULL, wii_of_bus, NULL);
+       return 0;
+}
+device_initcall(wii_device_probe);
+
index 07762259c60a864e598608eb5fb298eab7c57a8c..86c4b29eea891d949673c3a282cd415555201fbf 100644 (file)
@@ -217,9 +217,9 @@ void __init iSeries_activate_IRQs()
                struct irq_desc *desc = irq_to_desc(irq);
 
                if (desc && desc->chip && desc->chip->startup) {
-                       spin_lock_irqsave(&desc->lock, flags);
+                       raw_spin_lock_irqsave(&desc->lock, flags);
                        desc->chip->startup(irq);
-                       spin_unlock_irqrestore(&desc->lock, flags);
+                       raw_spin_unlock_irqrestore(&desc->lock, flags);
                }
        }
 }
index 0d9343df35bc7658e54cd823eef7660631aa1003..6617915bcb1ae129345936e82fc5573be0a70cca 100644 (file)
@@ -855,59 +855,58 @@ static int mf_get_boot_rtc(struct rtc_time *tm)
 }
 
 #ifdef CONFIG_PROC_FS
-
-static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
-               int count, int *eof, void *data)
+static int mf_cmdline_proc_show(struct seq_file *m, void *v)
 {
-       int len;
-       char *p;
+       char *page, *p;
        struct vsp_cmd_data vsp_cmd;
        int rc;
        dma_addr_t dma_addr;
 
        /* The HV appears to return no more than 256 bytes of command line */
-       if (off >= 256)
-               return 0;
-       if ((off + count) > 256)
-               count = 256 - off;
+       page = kmalloc(256, GFP_KERNEL);
+       if (!page)
+               return -ENOMEM;
 
-       dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE);
-       if (dma_addr == DMA_ERROR_CODE)
+       dma_addr = iseries_hv_map(page, 256, DMA_FROM_DEVICE);
+       if (dma_addr == DMA_ERROR_CODE) {
+               kfree(page);
                return -ENOMEM;
-       memset(page, 0, off + count);
+       }
+       memset(page, 0, 256);
        memset(&vsp_cmd, 0, sizeof(vsp_cmd));
        vsp_cmd.cmd = 33;
        vsp_cmd.sub_data.kern.token = dma_addr;
        vsp_cmd.sub_data.kern.address_type = HvLpDma_AddressType_TceIndex;
-       vsp_cmd.sub_data.kern.side = (u64)data;
-       vsp_cmd.sub_data.kern.length = off + count;
+       vsp_cmd.sub_data.kern.side = (u64)m->private;
+       vsp_cmd.sub_data.kern.length = 256;
        mb();
        rc = signal_vsp_instruction(&vsp_cmd);
-       iseries_hv_unmap(dma_addr, off + count, DMA_FROM_DEVICE);
-       if (rc)
+       iseries_hv_unmap(dma_addr, 256, DMA_FROM_DEVICE);
+       if (rc) {
+               kfree(page);
                return rc;
-       if (vsp_cmd.result_code != 0)
+       }
+       if (vsp_cmd.result_code != 0) {
+               kfree(page);
                return -ENOMEM;
+       }
        p = page;
-       len = 0;
-       while (len < (off + count)) {
-               if ((*p == '\0') || (*p == '\n')) {
-                       if (*p == '\0')
-                               *p = '\n';
-                       p++;
-                       len++;
-                       *eof = 1;
+       while (p - page < 256) {
+               if (*p == '\0' || *p == '\n') {
+                       *p = '\n';
                        break;
                }
                p++;
-               len++;
-       }
 
-       if (len < off) {
-               *eof = 1;
-               len = 0;
        }
-       return len;
+       seq_write(m, page, p - page);
+       kfree(page);
+       return 0;
+}
+
+static int mf_cmdline_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, mf_cmdline_proc_show, PDE(inode)->data);
 }
 
 #if 0
@@ -962,10 +961,8 @@ static int proc_mf_dump_vmlinux(char *page, char **start, off_t off,
 }
 #endif
 
-static int proc_mf_dump_side(char *page, char **start, off_t off,
-               int count, int *eof, void *data)
+static int mf_side_proc_show(struct seq_file *m, void *v)
 {
-       int len;
        char mf_current_side = ' ';
        struct vsp_cmd_data vsp_cmd;
 
@@ -989,21 +986,17 @@ static int proc_mf_dump_side(char *page, char **start, off_t off,
                }
        }
 
-       len = sprintf(page, "%c\n", mf_current_side);
+       seq_printf(m, "%c\n", mf_current_side);
+       return 0;
+}
 
-       if (len <= (off + count))
-               *eof = 1;
-       *start = page + off;
-       len -= off;
-       if (len > count)
-               len = count;
-       if (len < 0)
-               len = 0;
-       return len;
+static int mf_side_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, mf_side_proc_show, NULL);
 }
 
-static int proc_mf_change_side(struct file *file, const char __user *buffer,
-               unsigned long count, void *data)
+static ssize_t mf_side_proc_write(struct file *file, const char __user *buffer,
+                                 size_t count, loff_t *pos)
 {
        char side;
        u64 newSide;
@@ -1041,6 +1034,15 @@ static int proc_mf_change_side(struct file *file, const char __user *buffer,
        return count;
 }
 
+static const struct file_operations mf_side_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = mf_side_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = mf_side_proc_write,
+};
+
 #if 0
 static void mf_getSrcHistory(char *buffer, int size)
 {
@@ -1087,8 +1089,7 @@ static void mf_getSrcHistory(char *buffer, int size)
 }
 #endif
 
-static int proc_mf_dump_src(char *page, char **start, off_t off,
-               int count, int *eof, void *data)
+static int mf_src_proc_show(struct seq_file *m, void *v)
 {
 #if 0
        int len;
@@ -1109,8 +1110,13 @@ static int proc_mf_dump_src(char *page, char **start, off_t off,
 #endif
 }
 
-static int proc_mf_change_src(struct file *file, const char __user *buffer,
-               unsigned long count, void *data)
+static int mf_src_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, mf_src_proc_show, NULL);
+}
+
+static ssize_t mf_src_proc_write(struct file *file, const char __user *buffer,
+                                size_t count, loff_t *pos)
 {
        char stkbuf[10];
 
@@ -1135,9 +1141,19 @@ static int proc_mf_change_src(struct file *file, const char __user *buffer,
        return count;
 }
 
-static int proc_mf_change_cmdline(struct file *file, const char __user *buffer,
-               unsigned long count, void *data)
+static const struct file_operations mf_src_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = mf_src_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = mf_src_proc_write,
+};
+
+static ssize_t mf_cmdline_proc_write(struct file *file, const char __user *buffer,
+                                    size_t count, loff_t *pos)
 {
+       void *data = PDE(file->f_path.dentry->d_inode)->data;
        struct vsp_cmd_data vsp_cmd;
        dma_addr_t dma_addr;
        char *page;
@@ -1172,6 +1188,15 @@ out:
        return ret;
 }
 
+static const struct file_operations mf_cmdline_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = mf_cmdline_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = mf_cmdline_proc_write,
+};
+
 static ssize_t proc_mf_change_vmlinux(struct file *file,
                                      const char __user *buf,
                                      size_t count, loff_t *ppos)
@@ -1246,12 +1271,10 @@ static int __init mf_proc_init(void)
                if (!mf)
                        return 1;
 
-               ent = create_proc_entry("cmdline", S_IFREG|S_IRUSR|S_IWUSR, mf);
+               ent = proc_create_data("cmdline", S_IRUSR|S_IWUSR, mf,
+                                      &mf_cmdline_proc_fops, (void *)(long)i);
                if (!ent)
                        return 1;
-               ent->data = (void *)(long)i;
-               ent->read_proc = proc_mf_dump_cmdline;
-               ent->write_proc = proc_mf_change_cmdline;
 
                if (i == 3)     /* no vmlinux entry for 'D' */
                        continue;
@@ -1263,19 +1286,15 @@ static int __init mf_proc_init(void)
                        return 1;
        }
 
-       ent = create_proc_entry("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
+       ent = proc_create("side", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root,
+                         &mf_side_proc_fops);
        if (!ent)
                return 1;
-       ent->data = (void *)0;
-       ent->read_proc = proc_mf_dump_side;
-       ent->write_proc = proc_mf_change_side;
 
-       ent = create_proc_entry("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root);
+       ent = proc_create("src", S_IFREG|S_IRUSR|S_IWUSR, mf_proc_root,
+                         &mf_src_proc_fops);
        if (!ent)
                return 1;
-       ent->data = (void *)0;
-       ent->read_proc = proc_mf_dump_src;
-       ent->write_proc = proc_mf_change_src;
 
        return 0;
 }
index 49ff4dc422b7be7b0bf8565335d48cb34cc0979f..5aea94f30836c5044fe1fab08378a9535ac35f47 100644 (file)
@@ -116,7 +116,7 @@ static int proc_viopath_show(struct seq_file *m, void *v)
        u16 vlanMap;
        dma_addr_t handle;
        HvLpEvent_Rc hvrc;
-       DECLARE_COMPLETION(done);
+       DECLARE_COMPLETION_ONSTACK(done);
        struct device_node *node;
        const char *sysid;
 
index a4619347aa7e61a702e7a7f6c584080a31d5f4fb..242f8095c2dfc0991f1108c6581d5969cb3e3516 100644 (file)
@@ -71,7 +71,7 @@ static void pas_restart(char *cmd)
 }
 
 #ifdef CONFIG_SMP
-static raw_spinlock_t timebase_lock;
+static arch_spinlock_t timebase_lock;
 static unsigned long timebase;
 
 static void __devinit pas_give_timebase(void)
@@ -80,11 +80,11 @@ static void __devinit pas_give_timebase(void)
 
        local_irq_save(flags);
        hard_irq_disable();
-       __raw_spin_lock(&timebase_lock);
+       arch_spin_lock(&timebase_lock);
        mtspr(SPRN_TBCTL, TBCTL_FREEZE);
        isync();
        timebase = get_tb();
-       __raw_spin_unlock(&timebase_lock);
+       arch_spin_unlock(&timebase_lock);
 
        while (timebase)
                barrier();
@@ -97,10 +97,10 @@ static void __devinit pas_take_timebase(void)
        while (!timebase)
                smp_rmb();
 
-       __raw_spin_lock(&timebase_lock);
+       arch_spin_lock(&timebase_lock);
        set_tb(timebase >> 32, timebase & 0xffffffff);
        timebase = 0;
-       __raw_spin_unlock(&timebase_lock);
+       arch_spin_unlock(&timebase_lock);
 }
 
 struct smp_ops_t pas_smp_ops = {
index cf660916ae0b0101ac36824fd3a2db8fd3e13997..9dd789a7370d8b210d2c7907d2c3a5e97238d735 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/init.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <asm/sections.h>
 #include <asm/prom.h>
 #include <asm/page.h>
index 27554c807fd503ffea29fb966438ce2f6e229052..c667f0f02c34cc44eb75138e8eae6b140a49c3e8 100644 (file)
@@ -2,6 +2,8 @@ config PPC_PSERIES
        depends on PPC64 && PPC_BOOK3S
        bool "IBM pSeries & new (POWER5-based) iSeries"
        select MPIC
+       select PCI_MSI
+       select XICS
        select PPC_I8259
        select PPC_RTAS
        select PPC_RTAS_DAEMON
index bcdcf0ccc8d799ffde04e138e1b6fa2736d968e2..a277f2e28dbc285cb1ff285cf7ac2ec815e98d58 100644 (file)
 #include <asm/mmu.h>
 #include <asm/pgalloc.h>
 #include <asm/uaccess.h>
+#include <linux/memory.h>
 
 #include "plpar_wrappers.h"
 
 #define CMM_DRIVER_VERSION     "1.0.0"
 #define CMM_DEFAULT_DELAY      1
+#define CMM_HOTPLUG_DELAY      5
 #define CMM_DEBUG                      0
 #define CMM_DISABLE            0
 #define CMM_OOM_KB             1024
 #define CMM_MIN_MEM_MB         256
 #define KB2PAGES(_p)           ((_p)>>(PAGE_SHIFT-10))
 #define PAGES2KB(_p)           ((_p)<<(PAGE_SHIFT-10))
+/*
+ * The priority level tries to ensure that this notifier is called as
+ * late as possible to reduce thrashing in the shared memory pool.
+ */
+#define CMM_MEM_HOTPLUG_PRI    1
+#define CMM_MEM_ISOLATE_PRI    15
 
 static unsigned int delay = CMM_DEFAULT_DELAY;
+static unsigned int hotplug_delay = CMM_HOTPLUG_DELAY;
 static unsigned int oom_kb = CMM_OOM_KB;
 static unsigned int cmm_debug = CMM_DEBUG;
 static unsigned int cmm_disabled = CMM_DISABLE;
@@ -65,6 +74,10 @@ MODULE_VERSION(CMM_DRIVER_VERSION);
 module_param_named(delay, delay, uint, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(delay, "Delay (in seconds) between polls to query hypervisor paging requests. "
                 "[Default=" __stringify(CMM_DEFAULT_DELAY) "]");
+module_param_named(hotplug_delay, hotplug_delay, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(delay, "Delay (in seconds) after memory hotplug remove "
+                "before loaning resumes. "
+                "[Default=" __stringify(CMM_HOTPLUG_DELAY) "]");
 module_param_named(oom_kb, oom_kb, uint, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(oom_kb, "Amount of memory in kb to free on OOM. "
                 "[Default=" __stringify(CMM_OOM_KB) "]");
@@ -92,6 +105,9 @@ static unsigned long oom_freed_pages;
 static struct cmm_page_array *cmm_page_list;
 static DEFINE_SPINLOCK(cmm_lock);
 
+static DEFINE_MUTEX(hotplug_mutex);
+static int hotplug_occurred; /* protected by the hotplug mutex */
+
 static struct task_struct *cmm_thread_ptr;
 
 /**
@@ -110,6 +126,17 @@ static long cmm_alloc_pages(long nr)
        cmm_dbg("Begin request for %ld pages\n", nr);
 
        while (nr) {
+               /* Exit if a hotplug operation is in progress or occurred */
+               if (mutex_trylock(&hotplug_mutex)) {
+                       if (hotplug_occurred) {
+                               mutex_unlock(&hotplug_mutex);
+                               break;
+                       }
+                       mutex_unlock(&hotplug_mutex);
+               } else {
+                       break;
+               }
+
                addr = __get_free_page(GFP_NOIO | __GFP_NOWARN |
                                       __GFP_NORETRY | __GFP_NOMEMALLOC);
                if (!addr)
@@ -119,8 +146,9 @@ static long cmm_alloc_pages(long nr)
                if (!pa || pa->index >= CMM_NR_PAGES) {
                        /* Need a new page for the page list. */
                        spin_unlock(&cmm_lock);
-                       npa = (struct cmm_page_array *)__get_free_page(GFP_NOIO | __GFP_NOWARN |
-                                                                      __GFP_NORETRY | __GFP_NOMEMALLOC);
+                       npa = (struct cmm_page_array *)__get_free_page(
+                                       GFP_NOIO | __GFP_NOWARN |
+                                       __GFP_NORETRY | __GFP_NOMEMALLOC);
                        if (!npa) {
                                pr_info("%s: Can not allocate new page list\n", __func__);
                                free_page(addr);
@@ -282,9 +310,28 @@ static int cmm_thread(void *dummy)
        while (1) {
                timeleft = msleep_interruptible(delay * 1000);
 
-               if (kthread_should_stop() || timeleft) {
-                       loaned_pages_target = loaned_pages;
+               if (kthread_should_stop() || timeleft)
                        break;
+
+               if (mutex_trylock(&hotplug_mutex)) {
+                       if (hotplug_occurred) {
+                               hotplug_occurred = 0;
+                               mutex_unlock(&hotplug_mutex);
+                               cmm_dbg("Hotplug operation has occurred, "
+                                               "loaning activity suspended "
+                                               "for %d seconds.\n",
+                                               hotplug_delay);
+                               timeleft = msleep_interruptible(hotplug_delay *
+                                               1000);
+                               if (kthread_should_stop() || timeleft)
+                                       break;
+                               continue;
+                       }
+                       mutex_unlock(&hotplug_mutex);
+               } else {
+                       cmm_dbg("Hotplug operation in progress, activity "
+                                       "suspended\n");
+                       continue;
                }
 
                cmm_get_mpp();
@@ -413,6 +460,193 @@ static struct notifier_block cmm_reboot_nb = {
        .notifier_call = cmm_reboot_notifier,
 };
 
+/**
+ * cmm_count_pages - Count the number of pages loaned in a particular range.
+ *
+ * @arg: memory_isolate_notify structure with address range and count
+ *
+ * Return value:
+ *      0 on success
+ **/
+static unsigned long cmm_count_pages(void *arg)
+{
+       struct memory_isolate_notify *marg = arg;
+       struct cmm_page_array *pa;
+       unsigned long start = (unsigned long)pfn_to_kaddr(marg->start_pfn);
+       unsigned long end = start + (marg->nr_pages << PAGE_SHIFT);
+       unsigned long idx;
+
+       spin_lock(&cmm_lock);
+       pa = cmm_page_list;
+       while (pa) {
+               if ((unsigned long)pa >= start && (unsigned long)pa < end)
+                       marg->pages_found++;
+               for (idx = 0; idx < pa->index; idx++)
+                       if (pa->page[idx] >= start && pa->page[idx] < end)
+                               marg->pages_found++;
+               pa = pa->next;
+       }
+       spin_unlock(&cmm_lock);
+       return 0;
+}
+
+/**
+ * cmm_memory_isolate_cb - Handle memory isolation notifier calls
+ * @self:      notifier block struct
+ * @action:    action to take
+ * @arg:       struct memory_isolate_notify data for handler
+ *
+ * Return value:
+ *     NOTIFY_OK or notifier error based on subfunction return value
+ **/
+static int cmm_memory_isolate_cb(struct notifier_block *self,
+                                unsigned long action, void *arg)
+{
+       int ret = 0;
+
+       if (action == MEM_ISOLATE_COUNT)
+               ret = cmm_count_pages(arg);
+
+       if (ret)
+               ret = notifier_from_errno(ret);
+       else
+               ret = NOTIFY_OK;
+
+       return ret;
+}
+
+static struct notifier_block cmm_mem_isolate_nb = {
+       .notifier_call = cmm_memory_isolate_cb,
+       .priority = CMM_MEM_ISOLATE_PRI
+};
+
+/**
+ * cmm_mem_going_offline - Unloan pages where memory is to be removed
+ * @arg: memory_notify structure with page range to be offlined
+ *
+ * Return value:
+ *     0 on success
+ **/
+static int cmm_mem_going_offline(void *arg)
+{
+       struct memory_notify *marg = arg;
+       unsigned long start_page = (unsigned long)pfn_to_kaddr(marg->start_pfn);
+       unsigned long end_page = start_page + (marg->nr_pages << PAGE_SHIFT);
+       struct cmm_page_array *pa_curr, *pa_last, *npa;
+       unsigned long idx;
+       unsigned long freed = 0;
+
+       cmm_dbg("Memory going offline, searching 0x%lx (%ld pages).\n",
+                       start_page, marg->nr_pages);
+       spin_lock(&cmm_lock);
+
+       /* Search the page list for pages in the range to be offlined */
+       pa_last = pa_curr = cmm_page_list;
+       while (pa_curr) {
+               for (idx = (pa_curr->index - 1); (idx + 1) > 0; idx--) {
+                       if ((pa_curr->page[idx] < start_page) ||
+                           (pa_curr->page[idx] >= end_page))
+                               continue;
+
+                       plpar_page_set_active(__pa(pa_curr->page[idx]));
+                       free_page(pa_curr->page[idx]);
+                       freed++;
+                       loaned_pages--;
+                       totalram_pages++;
+                       pa_curr->page[idx] = pa_last->page[--pa_last->index];
+                       if (pa_last->index == 0) {
+                               if (pa_curr == pa_last)
+                                       pa_curr = pa_last->next;
+                               pa_last = pa_last->next;
+                               free_page((unsigned long)cmm_page_list);
+                               cmm_page_list = pa_last;
+                               continue;
+                       }
+               }
+               pa_curr = pa_curr->next;
+       }
+
+       /* Search for page list structures in the range to be offlined */
+       pa_last = NULL;
+       pa_curr = cmm_page_list;
+       while (pa_curr) {
+               if (((unsigned long)pa_curr >= start_page) &&
+                               ((unsigned long)pa_curr < end_page)) {
+                       npa = (struct cmm_page_array *)__get_free_page(
+                                       GFP_NOIO | __GFP_NOWARN |
+                                       __GFP_NORETRY | __GFP_NOMEMALLOC);
+                       if (!npa) {
+                               spin_unlock(&cmm_lock);
+                               cmm_dbg("Failed to allocate memory for list "
+                                               "management. Memory hotplug "
+                                               "failed.\n");
+                               return ENOMEM;
+                       }
+                       memcpy(npa, pa_curr, PAGE_SIZE);
+                       if (pa_curr == cmm_page_list)
+                               cmm_page_list = npa;
+                       if (pa_last)
+                               pa_last->next = npa;
+                       free_page((unsigned long) pa_curr);
+                       freed++;
+                       pa_curr = npa;
+               }
+
+               pa_last = pa_curr;
+               pa_curr = pa_curr->next;
+       }
+
+       spin_unlock(&cmm_lock);
+       cmm_dbg("Released %ld pages in the search range.\n", freed);
+
+       return 0;
+}
+
+/**
+ * cmm_memory_cb - Handle memory hotplug notifier calls
+ * @self:      notifier block struct
+ * @action:    action to take
+ * @arg:       struct memory_notify data for handler
+ *
+ * Return value:
+ *     NOTIFY_OK or notifier error based on subfunction return value
+ *
+ **/
+static int cmm_memory_cb(struct notifier_block *self,
+                       unsigned long action, void *arg)
+{
+       int ret = 0;
+
+       switch (action) {
+       case MEM_GOING_OFFLINE:
+               mutex_lock(&hotplug_mutex);
+               hotplug_occurred = 1;
+               ret = cmm_mem_going_offline(arg);
+               break;
+       case MEM_OFFLINE:
+       case MEM_CANCEL_OFFLINE:
+               mutex_unlock(&hotplug_mutex);
+               cmm_dbg("Memory offline operation complete.\n");
+               break;
+       case MEM_GOING_ONLINE:
+       case MEM_ONLINE:
+       case MEM_CANCEL_ONLINE:
+               break;
+       }
+
+       if (ret)
+               ret = notifier_from_errno(ret);
+       else
+               ret = NOTIFY_OK;
+
+       return ret;
+}
+
+static struct notifier_block cmm_mem_nb = {
+       .notifier_call = cmm_memory_cb,
+       .priority = CMM_MEM_HOTPLUG_PRI
+};
+
 /**
  * cmm_init - Module initialization
  *
@@ -435,18 +669,24 @@ static int cmm_init(void)
        if ((rc = cmm_sysfs_register(&cmm_sysdev)))
                goto out_reboot_notifier;
 
+       if (register_memory_notifier(&cmm_mem_nb) ||
+           register_memory_isolate_notifier(&cmm_mem_isolate_nb))
+               goto out_unregister_notifier;
+
        if (cmm_disabled)
                return rc;
 
        cmm_thread_ptr = kthread_run(cmm_thread, NULL, "cmmthread");
        if (IS_ERR(cmm_thread_ptr)) {
                rc = PTR_ERR(cmm_thread_ptr);
-               goto out_unregister_sysfs;
+               goto out_unregister_notifier;
        }
 
        return rc;
 
-out_unregister_sysfs:
+out_unregister_notifier:
+       unregister_memory_notifier(&cmm_mem_nb);
+       unregister_memory_isolate_notifier(&cmm_mem_isolate_nb);
        cmm_unregister_sysfs(&cmm_sysdev);
 out_reboot_notifier:
        unregister_reboot_notifier(&cmm_reboot_nb);
@@ -467,6 +707,8 @@ static void cmm_exit(void)
                kthread_stop(cmm_thread_ptr);
        unregister_oom_notifier(&cmm_oom_nb);
        unregister_reboot_notifier(&cmm_reboot_nb);
+       unregister_memory_notifier(&cmm_mem_nb);
+       unregister_memory_isolate_notifier(&cmm_mem_isolate_nb);
        cmm_free_pages(loaned_pages);
        cmm_unregister_sysfs(&cmm_sysdev);
 }
index 12df9e8812a9f258c864d01a255647ffe4c1b41e..67b7a10f9fce9b11079b6603a615e7dd43b36172 100644 (file)
@@ -346,12 +346,14 @@ int dlpar_release_drc(u32 drc_index)
 
 static DEFINE_MUTEX(pseries_cpu_hotplug_mutex);
 
-void cpu_hotplug_driver_lock()
+void cpu_hotplug_driver_lock(void)
+__acquires(pseries_cpu_hotplug_mutex)
 {
        mutex_lock(&pseries_cpu_hotplug_mutex);
 }
 
-void cpu_hotplug_driver_unlock()
+void cpu_hotplug_driver_unlock(void)
+__releases(pseries_cpu_hotplug_mutex)
 {
        mutex_unlock(&pseries_cpu_hotplug_mutex);
 }
index 8868c012268a45ebf348d41dcc023699ee0954e8..b4886635972c6dbf88b30bb9a69a21f569396ad8 100644 (file)
@@ -144,8 +144,8 @@ static void __devinit smp_pSeries_kick_cpu(int nr)
                hcpuid = get_hard_smp_processor_id(nr);
                rc = plpar_hcall_norets(H_PROD, hcpuid);
                if (rc != H_SUCCESS)
-                       panic("Error: Prod to wake up processor %d Ret= %ld\n",
-                               nr, rc);
+                       printk(KERN_ERR "Error: Prod to wake up processor %d\
+                                               Ret= %ld\n", nr, rc);
        }
 }
 
index 7d01b58f3989042e162ba11a534030e94574d7d5..b9b9e11609eca7db69e2b2a0711293cc49d667f2 100644 (file)
@@ -906,7 +906,7 @@ void xics_migrate_irqs_away(void)
                    || desc->chip->set_affinity == NULL)
                        continue;
 
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
 
                status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);
                if (status) {
@@ -930,7 +930,7 @@ void xics_migrate_irqs_away(void)
                cpumask_setall(irq_to_desc(virq)->affinity);
                desc->chip->set_affinity(virq, cpu_all_mask);
 unlock:
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 #endif
index 971483f0dfacd9f104246045a9300b80014ebe98..1709ac5aac7cf87407599701d488565f78541448 100644 (file)
@@ -143,13 +143,23 @@ static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type)
        struct irq_desc *desc = irq_to_desc(virq);
        unsigned int vold, vnew, edibit;
 
-       if (flow_type == IRQ_TYPE_NONE)
-               flow_type = IRQ_TYPE_LEVEL_LOW;
-
-       if (flow_type & IRQ_TYPE_EDGE_RISING) {
-               printk(KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n",
-                       flow_type);
-               return -EINVAL;
+       /* Port C interrupts are either IRQ_TYPE_EDGE_FALLING or
+        * IRQ_TYPE_EDGE_BOTH (default).  All others are IRQ_TYPE_EDGE_FALLING
+        * or IRQ_TYPE_LEVEL_LOW (default)
+        */
+       if (src >= CPM2_IRQ_PORTC15 && src <= CPM2_IRQ_PORTC0) {
+               if (flow_type == IRQ_TYPE_NONE)
+                       flow_type = IRQ_TYPE_EDGE_BOTH;
+
+               if (flow_type != IRQ_TYPE_EDGE_BOTH &&
+                   flow_type != IRQ_TYPE_EDGE_FALLING)
+                       goto err_sense;
+       } else {
+               if (flow_type == IRQ_TYPE_NONE)
+                       flow_type = IRQ_TYPE_LEVEL_LOW;
+
+               if (flow_type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH))
+                       goto err_sense;
        }
 
        desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
@@ -181,6 +191,10 @@ static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type)
        if (vold != vnew)
                out_be32(&cpm2_intctl->ic_siexr, vnew);
        return 0;
+
+err_sense:
+       pr_err("CPM2 PIC: sense type 0x%x not supported\n", flow_type);
+       return -EINVAL;
 }
 
 static struct irq_chip cpm2_pic = {
index 62e50258cdef9e9ca9a320b0dbc613c4e3fed446..c6e11b0771086fa611660385cfbec6cf30e66339 100644 (file)
@@ -173,7 +173,7 @@ static void fsl_msi_cascade(unsigned int irq, struct irq_desc *desc)
        u32 intr_index;
        u32 have_shift = 0;
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        if ((msi_data->feature &  FSL_PIC_IP_MASK) == FSL_PIC_IP_IPIC) {
                if (desc->chip->mask_ack)
                        desc->chip->mask_ack(irq);
@@ -225,7 +225,7 @@ static void fsl_msi_cascade(unsigned int irq, struct irq_desc *desc)
                break;
        }
 unlock:
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 
 static int __devinit fsl_of_msi_probe(struct of_device *dev,
index 4e3a3e345ab33cd5b8d435c3415e244e664f70c7..e1a028c1f18d0a94a415038c343f160309eb034c 100644 (file)
@@ -464,8 +464,7 @@ static void __iomem *mpc83xx_pcie_remap_cfg(struct pci_bus *bus,
 {
        struct pci_controller *hose = pci_bus_to_host(bus);
        struct mpc83xx_pcie_priv *pcie = hose->dn->data;
-       u8 bus_no = bus->number - hose->first_busno;
-       u32 dev_base = bus_no << 24 | devfn << 16;
+       u32 dev_base = bus->number << 24 | devfn << 16;
        int ret;
 
        ret = mpc83xx_pcie_exclude_device(bus, devfn);
@@ -515,12 +514,17 @@ static int mpc83xx_pcie_read_config(struct pci_bus *bus, unsigned int devfn,
 static int mpc83xx_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
                                     int offset, int len, u32 val)
 {
+       struct pci_controller *hose = pci_bus_to_host(bus);
        void __iomem *cfg_addr;
 
        cfg_addr = mpc83xx_pcie_remap_cfg(bus, devfn, offset);
        if (!cfg_addr)
                return PCIBIOS_DEVICE_NOT_FOUND;
 
+       /* PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS */
+       if (offset == PCI_PRIMARY_BUS && bus->number == hose->first_busno)
+               val &= 0xffffff00;
+
        switch (len) {
        case 1:
                out_8(cfg_addr, val);
index 103eace361946a65ed5cdb28f59b7afa6ed9e1ac..ee1c0e1cf4a7d814d99788c0c6520fb18bfcd3bf 100644 (file)
@@ -54,6 +54,22 @@ static void mpc8xxx_gpio_save_regs(struct of_mm_gpio_chip *mm)
        mpc8xxx_gc->data = in_be32(mm->regs + GPIO_DAT);
 }
 
+/* Workaround GPIO 1 errata on MPC8572/MPC8536. The status of GPIOs
+ * defined as output cannot be determined by reading GPDAT register,
+ * so we use shadow data register instead. The status of input pins
+ * is determined by reading GPDAT register.
+ */
+static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio)
+{
+       u32 val;
+       struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
+       struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
+
+       val = in_be32(mm->regs + GPIO_DAT) & ~in_be32(mm->regs + GPIO_DIR);
+
+       return (val | mpc8xxx_gc->data) & mpc8xxx_gpio2mask(gpio);
+}
+
 static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio)
 {
        struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
@@ -136,7 +152,10 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
        gc->ngpio = MPC8XXX_GPIO_PINS;
        gc->direction_input = mpc8xxx_gpio_dir_in;
        gc->direction_output = mpc8xxx_gpio_dir_out;
-       gc->get = mpc8xxx_gpio_get;
+       if (of_device_is_compatible(np, "fsl,mpc8572-gpio"))
+               gc->get = mpc8572_gpio_get;
+       else
+               gc->get = mpc8xxx_gpio_get;
        gc->set = mpc8xxx_gpio_set;
 
        ret = of_mm_gpiochip_add(np, mm_gc);
index aa9d06e5925b1ead712a073670600781ab23a2b9..470dc6c11d57e3ef7716a09d05b62559bd0ebeee 100644 (file)
@@ -567,13 +567,11 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
 #endif /* CONFIG_MPIC_U3_HT_IRQS */
 
 #ifdef CONFIG_SMP
-static int irq_choose_cpu(unsigned int virt_irq)
+static int irq_choose_cpu(const cpumask_t *mask)
 {
-       cpumask_t mask;
        int cpuid;
 
-       cpumask_copy(&mask, irq_to_desc(virt_irq)->affinity);
-       if (cpus_equal(mask, CPU_MASK_ALL)) {
+       if (cpumask_equal(mask, cpu_all_mask)) {
                static int irq_rover;
                static DEFINE_SPINLOCK(irq_rover_lock);
                unsigned long flags;
@@ -594,20 +592,15 @@ static int irq_choose_cpu(unsigned int virt_irq)
 
                spin_unlock_irqrestore(&irq_rover_lock, flags);
        } else {
-               cpumask_t tmp;
-
-               cpus_and(tmp, cpu_online_map, mask);
-
-               if (cpus_empty(tmp))
+               cpuid = cpumask_first_and(mask, cpu_online_mask);
+               if (cpuid >= nr_cpu_ids)
                        goto do_round_robin;
-
-               cpuid = first_cpu(tmp);
        }
 
        return get_hard_smp_processor_id(cpuid);
 }
 #else
-static int irq_choose_cpu(unsigned int virt_irq)
+static int irq_choose_cpu(const cpumask_t *mask)
 {
        return hard_smp_processor_id();
 }
@@ -816,7 +809,7 @@ int mpic_set_affinity(unsigned int irq, const struct cpumask *cpumask)
        unsigned int src = mpic_irq_to_hw(irq);
 
        if (mpic->flags & MPIC_SINGLE_DEST_CPU) {
-               int cpuid = irq_choose_cpu(irq);
+               int cpuid = irq_choose_cpu(cpumask);
 
                mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid);
        } else {
index 1d44eee80fa1275c5527967a4edf3a57f5f53f7f..0f67cd79d48185f0bf962da4a33884db6e17ce7c 100644 (file)
@@ -39,7 +39,12 @@ static int mpic_msi_reserve_u3_hwirqs(struct mpic *mpic)
 
        pr_debug("mpic: found U3, guessing msi allocator setup\n");
 
-       /* Reserve source numbers we know are reserved in the HW */
+       /* Reserve source numbers we know are reserved in the HW.
+        *
+        * This is a bit of a mix of U3 and U4 reserves but that's going
+        * to work fine, we have plenty enugh numbers left so let's just
+        * mark anything we don't like reserved.
+        */
        for (i = 0;   i < 8;   i++)
                msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);
 
@@ -49,6 +54,10 @@ static int mpic_msi_reserve_u3_hwirqs(struct mpic *mpic)
        for (i = 100; i < 105; i++)
                msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);
 
+       for (i = 124; i < mpic->irq_count; i++)
+               msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);
+
+
        np = NULL;
        while ((np = of_find_all_nodes(np))) {
                pr_debug("mpic: mapping hwirqs for %s\n", np->full_name);
index d3caf23e6312662b2030a52f5cb39249971e517b..bcbfe79c704bb42f6e8bcebe893eadf6aaf341da 100644 (file)
@@ -64,12 +64,12 @@ static u64 read_ht_magic_addr(struct pci_dev *pdev, unsigned int pos)
        return addr;
 }
 
-static u64 find_ht_magic_addr(struct pci_dev *pdev)
+static u64 find_ht_magic_addr(struct pci_dev *pdev, unsigned int hwirq)
 {
        struct pci_bus *bus;
        unsigned int pos;
 
-       for (bus = pdev->bus; bus; bus = bus->parent) {
+       for (bus = pdev->bus; bus && bus->self; bus = bus->parent) {
                pos = pci_find_ht_capability(bus->self, HT_CAPTYPE_MSI_MAPPING);
                if (pos)
                        return read_ht_magic_addr(bus->self, pos);
@@ -78,13 +78,41 @@ static u64 find_ht_magic_addr(struct pci_dev *pdev)
        return 0;
 }
 
+static u64 find_u4_magic_addr(struct pci_dev *pdev, unsigned int hwirq)
+{
+       struct pci_controller *hose = pci_bus_to_host(pdev->bus);
+
+       /* U4 PCIe MSIs need to write to the special register in
+        * the bridge that generates interrupts. There should be
+        * theorically a register at 0xf8005000 where you just write
+        * the MSI number and that triggers the right interrupt, but
+        * unfortunately, this is busted in HW, the bridge endian swaps
+        * the value and hits the wrong nibble in the register.
+        *
+        * So instead we use another register set which is used normally
+        * for converting HT interrupts to MPIC interrupts, which decodes
+        * the interrupt number as part of the low address bits
+        *
+        * This will not work if we ever use more than one legacy MSI in
+        * a block but we never do. For one MSI or multiple MSI-X where
+        * each interrupt address can be specified separately, it works
+        * just fine.
+        */
+       if (of_device_is_compatible(hose->dn, "u4-pcie") ||
+           of_device_is_compatible(hose->dn, "U4-pcie"))
+               return 0xf8004000 | (hwirq << 4);
+
+       return 0;
+}
+
 static int u3msi_msi_check_device(struct pci_dev *pdev, int nvec, int type)
 {
        if (type == PCI_CAP_ID_MSIX)
                pr_debug("u3msi: MSI-X untested, trying anyway.\n");
 
        /* If we can't find a magic address then MSI ain't gonna work */
-       if (find_ht_magic_addr(pdev) == 0) {
+       if (find_ht_magic_addr(pdev, 0) == 0 &&
+           find_u4_magic_addr(pdev, 0) == 0) {
                pr_debug("u3msi: no magic address found for %s\n",
                         pci_name(pdev));
                return -ENXIO;
@@ -118,10 +146,6 @@ static int u3msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
        u64 addr;
        int hwirq;
 
-       addr = find_ht_magic_addr(pdev);
-       msg.address_lo = addr & 0xFFFFFFFF;
-       msg.address_hi = addr >> 32;
-
        list_for_each_entry(entry, &pdev->msi_list, list) {
                hwirq = msi_bitmap_alloc_hwirqs(&msi_mpic->msi_bitmap, 1);
                if (hwirq < 0) {
@@ -129,6 +153,12 @@ static int u3msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
                        return hwirq;
                }
 
+               addr = find_ht_magic_addr(pdev, hwirq);
+               if (addr == 0)
+                       addr = find_u4_magic_addr(pdev, hwirq);
+               msg.address_lo = addr & 0xFFFFFFFF;
+               msg.address_hi = addr >> 32;
+
                virq = irq_create_mapping(msi_mpic->irqhost, hwirq);
                if (virq == NO_IRQ) {
                        pr_debug("u3msi: failed mapping hwirq 0x%x\n", hwirq);
@@ -143,6 +173,8 @@ static int u3msi_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
                pr_debug("u3msi: allocated virq 0x%x (hw 0x%x) addr 0x%lx\n",
                          virq, hwirq, (unsigned long)addr);
 
+               printk("u3msi: allocated virq 0x%x (hw 0x%x) addr 0x%lx\n",
+                         virq, hwirq, (unsigned long)addr);
                msg.data = hwirq;
                write_msi_msg(virq, &msg);
 
index 7d10074b3304616cc983f316c2fad491bbb90fc4..6f220a913e4293ef89a4f02252fe09a11b6b07dc 100644 (file)
@@ -225,12 +225,12 @@ void uic_irq_cascade(unsigned int virq, struct irq_desc *desc)
        int src;
        int subvirq;
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        if (desc->status & IRQ_LEVEL)
                desc->chip->mask(virq);
        else
                desc->chip->mask_ack(virq);
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        msr = mfdcr(uic->dcrbase + UIC_MSR);
        if (!msr) /* spurious interrupt */
@@ -242,12 +242,12 @@ void uic_irq_cascade(unsigned int virq, struct irq_desc *desc)
        generic_handle_irq(subvirq);
 
 uic_irq_ret:
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        if (desc->status & IRQ_LEVEL)
                desc->chip->ack(virq);
        if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask)
                desc->chip->unmask(virq);
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 
 static struct uic * __init uic_init_one(struct device_node *node)
index 495589950dc7daab650b316888dde9a58c98453f..5c91995b74e4b598e7eb5e974492ecb13087ff6a 100644 (file)
@@ -551,7 +551,7 @@ static int appldata_thaw(struct device *dev)
        return appldata_restore(dev);
 }
 
-static struct dev_pm_ops appldata_pm_ops = {
+static const struct dev_pm_ops appldata_pm_ops = {
        .freeze         = appldata_freeze,
        .thaw           = appldata_thaw,
        .restore        = appldata_restore,
index 6118890c946d89244e587cdc880726a1d7893073..6be4503201ac4b03d6943fd3c37edacb795f2779 100644 (file)
@@ -174,7 +174,7 @@ static int fallback_init_cip(struct crypto_tfm *tfm)
        if (IS_ERR(sctx->fallback.cip)) {
                pr_err("Allocating AES fallback algorithm %s failed\n",
                       name);
-               return PTR_ERR(sctx->fallback.blk);
+               return PTR_ERR(sctx->fallback.cip);
        }
 
        return 0;
index 77df726180ba8253d4d4ff896aa7556d1fbe07ef..2b92d501425f20262c0f38e5c34f4634634732db 100644 (file)
@@ -164,7 +164,7 @@ static inline void part_hdr__part_name(enum diag204_format type, void *hdr,
                       LPAR_NAME_LEN);
        EBCASC(name, LPAR_NAME_LEN);
        name[LPAR_NAME_LEN] = 0;
-       strstrip(name);
+       strim(name);
 }
 
 struct cpu_info {
@@ -523,7 +523,7 @@ static int diag224_idx2name(int index, char *name)
        memcpy(name, diag224_cpu_names + ((index + 1) * CPU_NAME_LEN),
                CPU_NAME_LEN);
        name[CPU_NAME_LEN] = 0;
-       strstrip(name);
+       strim(name);
        return 0;
 }
 
index d01fc8f799f0a58bab6e9d75c18e0e1a247b3d75..f0b0d31f0b48c1c04f8c18b347e9b1cbc7c5605f 100644 (file)
@@ -124,7 +124,7 @@ static int hpyfs_vm_create_guest(struct super_block *sb,
        /* guest dir */
        memcpy(guest_name, data->guest_name, NAME_LEN);
        EBCASC(guest_name, NAME_LEN);
-       strstrip(guest_name);
+       strim(guest_name);
        guest_dir = hypfs_mkdir(sb, systems_dir, guest_name);
        if (IS_ERR(guest_dir))
                return PTR_ERR(guest_dir);
diff --git a/arch/s390/include/asm/asm-offsets.h b/arch/s390/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index e885442c1dfe99622217a06444ed680c18b23303..354d42616c7e6dc057a4bbf1bbfbb80805f7d880 100644 (file)
@@ -155,7 +155,6 @@ extern unsigned int vdso_enabled;
        } while (0)
 
 #define CORE_DUMP_USE_REGSET
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      4096
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
index c9af0d19c7ab7b4fc726528797be910ef7d7c0f3..a587907d77f32e208cc0c8ed6e8da87f050c757e 100644 (file)
@@ -52,27 +52,27 @@ _raw_compare_and_swap(volatile unsigned int *lock,
  * (the type definitions are in asm/spinlock_types.h)
  */
 
-#define __raw_spin_is_locked(x) ((x)->owner_cpu != 0)
-#define __raw_spin_unlock_wait(lock) \
-       do { while (__raw_spin_is_locked(lock)) \
-                _raw_spin_relax(lock); } while (0)
+#define arch_spin_is_locked(x) ((x)->owner_cpu != 0)
+#define arch_spin_unlock_wait(lock) \
+       do { while (arch_spin_is_locked(lock)) \
+                arch_spin_relax(lock); } while (0)
 
-extern void _raw_spin_lock_wait(raw_spinlock_t *);
-extern void _raw_spin_lock_wait_flags(raw_spinlock_t *, unsigned long flags);
-extern int _raw_spin_trylock_retry(raw_spinlock_t *);
-extern void _raw_spin_relax(raw_spinlock_t *lock);
+extern void arch_spin_lock_wait(arch_spinlock_t *);
+extern void arch_spin_lock_wait_flags(arch_spinlock_t *, unsigned long flags);
+extern int arch_spin_trylock_retry(arch_spinlock_t *);
+extern void arch_spin_relax(arch_spinlock_t *lock);
 
-static inline void __raw_spin_lock(raw_spinlock_t *lp)
+static inline void arch_spin_lock(arch_spinlock_t *lp)
 {
        int old;
 
        old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
        if (likely(old == 0))
                return;
-       _raw_spin_lock_wait(lp);
+       arch_spin_lock_wait(lp);
 }
 
-static inline void __raw_spin_lock_flags(raw_spinlock_t *lp,
+static inline void arch_spin_lock_flags(arch_spinlock_t *lp,
                                         unsigned long flags)
 {
        int old;
@@ -80,20 +80,20 @@ static inline void __raw_spin_lock_flags(raw_spinlock_t *lp,
        old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
        if (likely(old == 0))
                return;
-       _raw_spin_lock_wait_flags(lp, flags);
+       arch_spin_lock_wait_flags(lp, flags);
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lp)
+static inline int arch_spin_trylock(arch_spinlock_t *lp)
 {
        int old;
 
        old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
        if (likely(old == 0))
                return 1;
-       return _raw_spin_trylock_retry(lp);
+       return arch_spin_trylock_retry(lp);
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lp)
+static inline void arch_spin_unlock(arch_spinlock_t *lp)
 {
        _raw_compare_and_swap(&lp->owner_cpu, lp->owner_cpu, 0);
 }
@@ -113,22 +113,22 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lp)
  * read_can_lock - would read_trylock() succeed?
  * @lock: the rwlock in question.
  */
-#define __raw_read_can_lock(x) ((int)(x)->lock >= 0)
+#define arch_read_can_lock(x) ((int)(x)->lock >= 0)
 
 /**
  * write_can_lock - would write_trylock() succeed?
  * @lock: the rwlock in question.
  */
-#define __raw_write_can_lock(x) ((x)->lock == 0)
+#define arch_write_can_lock(x) ((x)->lock == 0)
 
-extern void _raw_read_lock_wait(raw_rwlock_t *lp);
-extern void _raw_read_lock_wait_flags(raw_rwlock_t *lp, unsigned long flags);
-extern int _raw_read_trylock_retry(raw_rwlock_t *lp);
-extern void _raw_write_lock_wait(raw_rwlock_t *lp);
-extern void _raw_write_lock_wait_flags(raw_rwlock_t *lp, unsigned long flags);
-extern int _raw_write_trylock_retry(raw_rwlock_t *lp);
+extern void _raw_read_lock_wait(arch_rwlock_t *lp);
+extern void _raw_read_lock_wait_flags(arch_rwlock_t *lp, unsigned long flags);
+extern int _raw_read_trylock_retry(arch_rwlock_t *lp);
+extern void _raw_write_lock_wait(arch_rwlock_t *lp);
+extern void _raw_write_lock_wait_flags(arch_rwlock_t *lp, unsigned long flags);
+extern int _raw_write_trylock_retry(arch_rwlock_t *lp);
 
-static inline void __raw_read_lock(raw_rwlock_t *rw)
+static inline void arch_read_lock(arch_rwlock_t *rw)
 {
        unsigned int old;
        old = rw->lock & 0x7fffffffU;
@@ -136,7 +136,7 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
                _raw_read_lock_wait(rw);
 }
 
-static inline void __raw_read_lock_flags(raw_rwlock_t *rw, unsigned long flags)
+static inline void arch_read_lock_flags(arch_rwlock_t *rw, unsigned long flags)
 {
        unsigned int old;
        old = rw->lock & 0x7fffffffU;
@@ -144,7 +144,7 @@ static inline void __raw_read_lock_flags(raw_rwlock_t *rw, unsigned long flags)
                _raw_read_lock_wait_flags(rw, flags);
 }
 
-static inline void __raw_read_unlock(raw_rwlock_t *rw)
+static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
        unsigned int old, cmp;
 
@@ -155,24 +155,24 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
        } while (cmp != old);
 }
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
        if (unlikely(_raw_compare_and_swap(&rw->lock, 0, 0x80000000) != 0))
                _raw_write_lock_wait(rw);
 }
 
-static inline void __raw_write_lock_flags(raw_rwlock_t *rw, unsigned long flags)
+static inline void arch_write_lock_flags(arch_rwlock_t *rw, unsigned long flags)
 {
        if (unlikely(_raw_compare_and_swap(&rw->lock, 0, 0x80000000) != 0))
                _raw_write_lock_wait_flags(rw, flags);
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t *rw)
+static inline void arch_write_unlock(arch_rwlock_t *rw)
 {
        _raw_compare_and_swap(&rw->lock, 0x80000000, 0);
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t *rw)
+static inline int arch_read_trylock(arch_rwlock_t *rw)
 {
        unsigned int old;
        old = rw->lock & 0x7fffffffU;
@@ -181,14 +181,14 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw)
        return _raw_read_trylock_retry(rw);
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *rw)
+static inline int arch_write_trylock(arch_rwlock_t *rw)
 {
        if (likely(_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0))
                return 1;
        return _raw_write_trylock_retry(rw);
 }
 
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* __ASM_SPINLOCK_H */
index 654abc40de04a7b7729e3802b9d9b86244982da2..9c76656a0af035bf04d55680a03c589ef0e1b0f1 100644 (file)
@@ -7,14 +7,14 @@
 
 typedef struct {
        volatile unsigned int owner_cpu;
-} __attribute__ ((aligned (4))) raw_spinlock_t;
+} __attribute__ ((aligned (4))) arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        volatile unsigned int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { 0 }
+#define __ARCH_RW_LOCK_UNLOCKED                { 0 }
 
 #endif
index cb5232df151ef93d10617612c24a6c2ddd568871..192a7203a14f703d63ab7486987869ca796c4f75 100644 (file)
 #define        __NR_pwritev            329
 #define __NR_rt_tgsigqueueinfo 330
 #define __NR_perf_event_open   331
-#define NR_syscalls 332
+#define __NR_recvmmsg          332
+#define NR_syscalls 333
 
 /* 
  * There are some system calls that are not present on 64 bit, some
index 30de2d0e52bb421e41efabd67cdbc677bb7e5539..faeaccc7d7d98ddffccdfa83b41d92b341df57d5 100644 (file)
@@ -1853,3 +1853,12 @@ sys32_execve_wrapper:
        llgtr   %r3,%r3                 # compat_uptr_t *
        llgtr   %r4,%r4                 # compat_uptr_t *
        jg      sys32_execve            # branch to system call
+
+       .globl  compat_sys_recvmmsg_wrapper
+compat_sys_recvmmsg_wrapper:
+       lgfr    %r2,%r2                 # int
+       llgtr   %r3,%r3                 # struct compat_mmsghdr *
+       llgfr   %r4,%r4                 # unsigned int
+       llgfr   %r5,%r5                 # unsigned int
+       llgtr   %r6,%r6                 # struct compat_timespec *
+       jg      compat_sys_recvmmsg
index 071c81f179ef30d4d1662c20582835c60b81a71f..0168472b2fdfb66ed122e4ebaabf7a7a2d415efd 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/sysctl.h>
 #include <asm/uaccess.h>
 #include <linux/module.h>
@@ -1178,7 +1179,7 @@ debug_get_uint(char *buf)
 {
        int rc;
 
-       for(; isspace(*buf); buf++);
+       buf = skip_spaces(buf);
        rc = simple_strtoul(buf, &buf, 10);
        if(*buf){
                rc = -EINVAL;
index 4890ac6d7faa6da171b096e2e870cc291ffe4c93..4d73296fed74274f96574879e48a842be7f195ae 100644 (file)
@@ -221,7 +221,7 @@ static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj,        \
                const char *buf, size_t len)                            \
 {                                                                      \
        strncpy(_value, buf, sizeof(_value) - 1);                       \
-       strstrip(_value);                                               \
+       strim(_value);                                                  \
        return len;                                                     \
 }                                                                      \
 static struct kobj_attribute sys_##_prefix##_##_name##_attr =          \
@@ -472,7 +472,7 @@ static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj,
                return sprintf(page, "#unknown#\n");
        memcpy(loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN);
        EBCASC(loadparm, LOADPARM_LEN);
-       strstrip(loadparm);
+       strim(loadparm);
        return sprintf(page, "%s\n", loadparm);
 }
 
@@ -776,7 +776,7 @@ static void reipl_get_ascii_loadparm(char *loadparm,
        memcpy(loadparm, ibp->ipl_info.ccw.load_parm, LOADPARM_LEN);
        EBCASC(loadparm, LOADPARM_LEN);
        loadparm[LOADPARM_LEN] = 0;
-       strstrip(loadparm);
+       strim(loadparm);
 }
 
 static ssize_t reipl_generic_loadparm_show(struct ipl_parameter_block *ipb,
index 653c6a1787404480f532d7f033223540e2fcc616..13815d39f7dd2c757590c416298c71176f795f81 100644 (file)
@@ -959,7 +959,7 @@ static const struct user_regset s390_compat_regsets[] = {
                .set = s390_fpregs_set,
        },
        [REGSET_GENERAL_EXTENDED] = {
-               .core_note_type = NT_PRXSTATUS,
+               .core_note_type = NT_S390_HIGH_GPRS,
                .n = sizeof(s390_compat_regs_high) / sizeof(compat_long_t),
                .size = sizeof(compat_long_t),
                .align = sizeof(compat_long_t),
index 30eca070d4268953d209b54394c99806afced91e..4f292c936872dbed56e0f82cc57184809c3b4321 100644 (file)
@@ -340,3 +340,4 @@ SYSCALL(sys_preadv,sys_preadv,compat_sys_preadv_wrapper)
 SYSCALL(sys_pwritev,sys_pwritev,compat_sys_pwritev_wrapper)
 SYSCALL(sys_rt_tgsigqueueinfo,sys_rt_tgsigqueueinfo,compat_sys_rt_tgsigqueueinfo_wrapper) /* 330 */
 SYSCALL(sys_perf_event_open,sys_perf_event_open,sys_perf_event_open_wrapper)
+SYSCALL(sys_recvmmsg,sys_recvmmsg,compat_sys_recvmmsg_wrapper)
index c2e42cc65ce7cb7798618e35ededbe685001d825..6e7ad63854c06162af8fba1496165dfaba74d4bf 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/errno.h>
-#include <linux/ptrace.h>
+#include <linux/tracehook.h>
 #include <linux/timer.h>
 #include <linux/mm.h>
 #include <linux/smp.h>
@@ -382,7 +382,7 @@ void __kprobes do_single_step(struct pt_regs *regs)
                                        SIGTRAP) == NOTIFY_STOP){
                return;
        }
-       if ((current->ptrace & PT_PTRACED) != 0)
+       if (tracehook_consider_fatal_signal(current, SIGTRAP))
                force_sig(SIGTRAP, current);
 }
 
@@ -483,7 +483,7 @@ static void illegal_op(struct pt_regs * regs, long interruption_code)
                if (get_user(*((__u16 *) opcode), (__u16 __user *) location))
                        return;
                if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) {
-                       if (current->ptrace & PT_PTRACED)
+                       if (tracehook_consider_fatal_signal(current, SIGTRAP))
                                force_sig(SIGTRAP, current);
                        else
                                signal = SIGILL;
index f7e0d30250b707b1ed46f7878f0f6790e7295e30..10754a3756684900ea1570cc1c21b5d6bc800240 100644 (file)
@@ -39,7 +39,7 @@ static inline void _raw_yield_cpu(int cpu)
                _raw_yield();
 }
 
-void _raw_spin_lock_wait(raw_spinlock_t *lp)
+void arch_spin_lock_wait(arch_spinlock_t *lp)
 {
        int count = spin_retry;
        unsigned int cpu = ~smp_processor_id();
@@ -51,15 +51,15 @@ void _raw_spin_lock_wait(raw_spinlock_t *lp)
                                _raw_yield_cpu(~owner);
                        count = spin_retry;
                }
-               if (__raw_spin_is_locked(lp))
+               if (arch_spin_is_locked(lp))
                        continue;
                if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0)
                        return;
        }
 }
-EXPORT_SYMBOL(_raw_spin_lock_wait);
+EXPORT_SYMBOL(arch_spin_lock_wait);
 
-void _raw_spin_lock_wait_flags(raw_spinlock_t *lp, unsigned long flags)
+void arch_spin_lock_wait_flags(arch_spinlock_t *lp, unsigned long flags)
 {
        int count = spin_retry;
        unsigned int cpu = ~smp_processor_id();
@@ -72,7 +72,7 @@ void _raw_spin_lock_wait_flags(raw_spinlock_t *lp, unsigned long flags)
                                _raw_yield_cpu(~owner);
                        count = spin_retry;
                }
-               if (__raw_spin_is_locked(lp))
+               if (arch_spin_is_locked(lp))
                        continue;
                local_irq_disable();
                if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0)
@@ -80,32 +80,32 @@ void _raw_spin_lock_wait_flags(raw_spinlock_t *lp, unsigned long flags)
                local_irq_restore(flags);
        }
 }
-EXPORT_SYMBOL(_raw_spin_lock_wait_flags);
+EXPORT_SYMBOL(arch_spin_lock_wait_flags);
 
-int _raw_spin_trylock_retry(raw_spinlock_t *lp)
+int arch_spin_trylock_retry(arch_spinlock_t *lp)
 {
        unsigned int cpu = ~smp_processor_id();
        int count;
 
        for (count = spin_retry; count > 0; count--) {
-               if (__raw_spin_is_locked(lp))
+               if (arch_spin_is_locked(lp))
                        continue;
                if (_raw_compare_and_swap(&lp->owner_cpu, 0, cpu) == 0)
                        return 1;
        }
        return 0;
 }
-EXPORT_SYMBOL(_raw_spin_trylock_retry);
+EXPORT_SYMBOL(arch_spin_trylock_retry);
 
-void _raw_spin_relax(raw_spinlock_t *lock)
+void arch_spin_relax(arch_spinlock_t *lock)
 {
        unsigned int cpu = lock->owner_cpu;
        if (cpu != 0)
                _raw_yield_cpu(~cpu);
 }
-EXPORT_SYMBOL(_raw_spin_relax);
+EXPORT_SYMBOL(arch_spin_relax);
 
-void _raw_read_lock_wait(raw_rwlock_t *rw)
+void _raw_read_lock_wait(arch_rwlock_t *rw)
 {
        unsigned int old;
        int count = spin_retry;
@@ -115,7 +115,7 @@ void _raw_read_lock_wait(raw_rwlock_t *rw)
                        _raw_yield();
                        count = spin_retry;
                }
-               if (!__raw_read_can_lock(rw))
+               if (!arch_read_can_lock(rw))
                        continue;
                old = rw->lock & 0x7fffffffU;
                if (_raw_compare_and_swap(&rw->lock, old, old + 1) == old)
@@ -124,7 +124,7 @@ void _raw_read_lock_wait(raw_rwlock_t *rw)
 }
 EXPORT_SYMBOL(_raw_read_lock_wait);
 
-void _raw_read_lock_wait_flags(raw_rwlock_t *rw, unsigned long flags)
+void _raw_read_lock_wait_flags(arch_rwlock_t *rw, unsigned long flags)
 {
        unsigned int old;
        int count = spin_retry;
@@ -135,7 +135,7 @@ void _raw_read_lock_wait_flags(raw_rwlock_t *rw, unsigned long flags)
                        _raw_yield();
                        count = spin_retry;
                }
-               if (!__raw_read_can_lock(rw))
+               if (!arch_read_can_lock(rw))
                        continue;
                old = rw->lock & 0x7fffffffU;
                local_irq_disable();
@@ -145,13 +145,13 @@ void _raw_read_lock_wait_flags(raw_rwlock_t *rw, unsigned long flags)
 }
 EXPORT_SYMBOL(_raw_read_lock_wait_flags);
 
-int _raw_read_trylock_retry(raw_rwlock_t *rw)
+int _raw_read_trylock_retry(arch_rwlock_t *rw)
 {
        unsigned int old;
        int count = spin_retry;
 
        while (count-- > 0) {
-               if (!__raw_read_can_lock(rw))
+               if (!arch_read_can_lock(rw))
                        continue;
                old = rw->lock & 0x7fffffffU;
                if (_raw_compare_and_swap(&rw->lock, old, old + 1) == old)
@@ -161,7 +161,7 @@ int _raw_read_trylock_retry(raw_rwlock_t *rw)
 }
 EXPORT_SYMBOL(_raw_read_trylock_retry);
 
-void _raw_write_lock_wait(raw_rwlock_t *rw)
+void _raw_write_lock_wait(arch_rwlock_t *rw)
 {
        int count = spin_retry;
 
@@ -170,7 +170,7 @@ void _raw_write_lock_wait(raw_rwlock_t *rw)
                        _raw_yield();
                        count = spin_retry;
                }
-               if (!__raw_write_can_lock(rw))
+               if (!arch_write_can_lock(rw))
                        continue;
                if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0)
                        return;
@@ -178,7 +178,7 @@ void _raw_write_lock_wait(raw_rwlock_t *rw)
 }
 EXPORT_SYMBOL(_raw_write_lock_wait);
 
-void _raw_write_lock_wait_flags(raw_rwlock_t *rw, unsigned long flags)
+void _raw_write_lock_wait_flags(arch_rwlock_t *rw, unsigned long flags)
 {
        int count = spin_retry;
 
@@ -188,7 +188,7 @@ void _raw_write_lock_wait_flags(raw_rwlock_t *rw, unsigned long flags)
                        _raw_yield();
                        count = spin_retry;
                }
-               if (!__raw_write_can_lock(rw))
+               if (!arch_write_can_lock(rw))
                        continue;
                local_irq_disable();
                if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0)
@@ -197,12 +197,12 @@ void _raw_write_lock_wait_flags(raw_rwlock_t *rw, unsigned long flags)
 }
 EXPORT_SYMBOL(_raw_write_lock_wait_flags);
 
-int _raw_write_trylock_retry(raw_rwlock_t *rw)
+int _raw_write_trylock_retry(arch_rwlock_t *rw)
 {
        int count = spin_retry;
 
        while (count-- > 0) {
-               if (!__raw_write_can_lock(rw))
+               if (!arch_write_can_lock(rw))
                        continue;
                if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000) == 0)
                        return 1;
diff --git a/arch/score/include/asm/asm-offsets.h b/arch/score/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index caaba24036e345e4ca04a61a5444c9b30f2eb4f5..1d545d0ce206feefbc58e1693584dc9a5275ae3c 100644 (file)
@@ -14,10 +14,12 @@ extern void flush_cache_sigtramp(unsigned long addr);
 extern void flush_icache_all(void);
 extern void flush_icache_range(unsigned long start, unsigned long end);
 extern void flush_dcache_range(unsigned long start, unsigned long end);
+extern void flush_dcache_page(struct page *page);
+
+#define PG_dcache_dirty         PG_arch_1
 
 #define flush_cache_dup_mm(mm)                 do {} while (0)
 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
-#define flush_dcache_page(page)                        do {} while (0)
 #define flush_dcache_mmap_lock(mapping)                do {} while (0)
 #define flush_dcache_mmap_unlock(mapping)      do {} while (0)
 #define flush_cache_vmap(start, end)           do {} while (0)
index 6726ec199dc02afbbe1f8ea379eba4e8309ab882..529e494712a5a46aee7b3431771df8416c62107d 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef _ASM_SCORE_DELAY_H
 #define _ASM_SCORE_DELAY_H
 
+#include <asm-generic/param.h>
+
 static inline void __delay(unsigned long loops)
 {
        /* 3 cycles per loop. */
index 43526d9fda936b07bd22c031b50dc30189cb598b..f478ce94181fb349324bf836e9fe5a01abfaa13d 100644 (file)
@@ -61,7 +61,6 @@ struct task_struct;
 struct pt_regs;
 
 #define CORE_DUMP_USE_REGSET
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      PAGE_SIZE
 
 /* This yields a mask that user programs can use to figure out what
index d92a5a2d36d40c434ee833543275b6e296ef192b..1e9ade8e77e69e1dfd3c1f0d0595db5af853c90c 100644 (file)
@@ -74,7 +74,7 @@ extern unsigned long max_pfn;
 #define page_to_bus(page)      (page_to_phys(page))
 #define phys_to_page(paddr)    (pfn_to_page(phys_to_pfn(paddr)))
 
-#define pfn_valid(pfn)         ((pfn) >= min_low_pfn && (pfn) < max_mapnr)
+#define pfn_valid(pfn)         (((pfn) >= min_low_pfn) && ((pfn) < max_low_pfn))
 
 #define ARCH_PFN_OFFSET                (PAGE_OFFSET >> PAGE_SHIFT)
 
index 6a2503c75c4ef113f06421a41d09d962118d1368..6f898c0578781cf0862863d6e23a931c60b12c17 100644 (file)
@@ -49,6 +49,7 @@ static void __init bootmem_init(void)
 
        min_low_pfn = PFN_UP(MEMORY_START);
        max_low_pfn = PFN_UP(MEMORY_START + MEMORY_SIZE);
+       max_mapnr = max_low_pfn - min_low_pfn;
 
        /* Initialize the boot-time allocator with low memory only. */
        bootmap_size = init_bootmem_node(NODE_DATA(0), start_pfn,
index dbac9d9dfddd3d3e30a305f294fc9e99d39d9e34..b25e957436000a1f94f51e8d4264e9500a84469b 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/fs.h>
 
 #include <asm/mmu_context.h>
 
@@ -51,6 +52,27 @@ static void flush_data_cache_page(unsigned long addr)
        }
 }
 
+void flush_dcache_page(struct page *page)
+{
+       struct address_space *mapping = page_mapping(page);
+       unsigned long addr;
+
+       if (PageHighMem(page))
+               return;
+       if (mapping && !mapping_mapped(mapping)) {
+               set_bit(PG_dcache_dirty, &(page)->flags);
+               return;
+       }
+
+       /*
+        * We could delay the flush for the !page_mapping case too.  But that
+        * case is for exec env/arg pages and those are %99 certainly going to
+        * get faulted into the tlb (and thus flushed) anyways.
+        */
+       addr = (unsigned long) page_address(page);
+       flush_data_cache_page(addr);
+}
+
 /* called by update_mmu_cache. */
 void __update_cache(struct vm_area_struct *vma, unsigned long address,
                pte_t pte)
@@ -63,11 +85,11 @@ void __update_cache(struct vm_area_struct *vma, unsigned long address,
        if (unlikely(!pfn_valid(pfn)))
                return;
        page = pfn_to_page(pfn);
-       if (page_mapping(page) && test_bit(PG_arch_1, &page->flags)) {
+       if (page_mapping(page) && test_bit(PG_dcache_dirty, &(page)->flags)) {
                addr = (unsigned long) page_address(page);
                if (exec)
                        flush_data_cache_page(addr);
-               clear_bit(PG_arch_1, &page->flags);
+               clear_bit(PG_dcache_dirty, &(page)->flags);
        }
 }
 
index 4e3dcd0c4716d85a413972472f10f0b39aa6c86b..8c15b2c85d5a1d6afb6d7996f16b08948a21baee 100644 (file)
@@ -83,7 +83,6 @@ void __init mem_init(void)
        unsigned long codesize, reservedpages, datasize, initsize;
        unsigned long tmp, ram = 0;
 
-       max_mapnr = max_low_pfn;
        high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT);
        totalram_pages += free_all_bootmem();
        totalram_pages -= setup_zero_page();    /* Setup zeroed pages. */
@@ -101,10 +100,6 @@ void __init mem_init(void)
        datasize = (unsigned long) &_edata - (unsigned long) &_etext;
        initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
 
-       kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
-       kclist_add(&kcore_vmalloc, (void *) VMALLOC_START,
-                       VMALLOC_END - VMALLOC_START);
-
        printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
                        "%ldk reserved, %ldk data, %ldk init, %ldk highmem)\n",
                        (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
index 55907af1dc256a83acec8f58115d080636a540b1..12fec72fec5f4888fb5a6f7c72911aaa0ebccd68 100644 (file)
@@ -19,50 +19,6 @@ config SH_STANDARD_BIOS
          mask ROM and no flash (WindowsCE machines fall in this category).
          If unsure, say N.
 
-config EARLY_SCIF_CONSOLE
-       bool "Use early SCIF console"
-       help
-         This enables an early console using a fixed SCIF port. This can
-         be used by platforms that are either not running the SH
-         standard BIOS, or do not wish to use the BIOS callbacks for the
-         serial I/O.
-
-config EARLY_SCIF_CONSOLE_PORT
-       hex
-       depends on EARLY_SCIF_CONSOLE
-       default "0xa4400000" if CPU_SUBTYPE_SH7712 || CPU_SUBTYPE_SH7705
-       default "0xa4430000" if CPU_SUBTYPE_SH7720 || CPU_SUBTYPE_SH7721
-       default "0xf8420000" if CPU_SUBTYPE_SH7619
-       default "0xff804000" if CPU_SUBTYPE_MXG
-       default "0xffc30000" if CPU_SUBTYPE_SHX3
-       default "0xffe00000" if CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7763 || \
-                               CPU_SUBTYPE_SH7722 || CPU_SUBTYPE_SH7366 || \
-                               CPU_SUBTYPE_SH7343
-       default "0xfe4c0000" if CPU_SUBTYPE_SH7757
-       default "0xffeb0000" if CPU_SUBTYPE_SH7785
-       default "0xffeb0000" if CPU_SUBTYPE_SH7786
-       default "0xfffe8000" if CPU_SUBTYPE_SH7203
-       default "0xfffe9800" if CPU_SUBTYPE_SH7206 || CPU_SUBTYPE_SH7263
-       default "0xffe80000" if CPU_SH4
-       default "0xa4000150" if CPU_SH3
-       default "0x00000000"
-
-config EARLY_PRINTK
-       bool "Early printk support"
-       depends on SH_STANDARD_BIOS || EARLY_SCIF_CONSOLE
-       help
-         Say Y here to redirect kernel printk messages to the serial port
-         used by the SH-IPL bootloader, starting very early in the boot
-         process and ending when the kernel's serial console is initialised.
-         This option is only useful porting the kernel to a new machine,
-         when the kernel may crash or hang before the serial console is
-         initialised. If unsure, say N.
-
-         On devices that are running SH-IPL and want to keep the port
-         initialization consistent while not using the BIOS callbacks,
-         select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using
-         the kernel command line option to toggle back and forth.
-
 config STACK_DEBUG
        bool "Check for stack overflows"
        depends on DEBUG_KERNEL && SUPERH32
index ac17c5ac550e6d21a84a46ebc67ada146abec89f..db91925c79d1185665dafc0216c01f7df8c346af 100644 (file)
@@ -205,10 +205,7 @@ libs-$(CONFIG_SUPERH64)            := arch/sh/lib64/ $(libs-y)
 
 BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.srec uImage.bin \
               zImage vmlinux.srec romImage
-PHONY += maketools $(BOOT_TARGETS) FORCE
-
-maketools:  include/linux/version.h FORCE
-       $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
+PHONY += $(BOOT_TARGETS)
 
 all: $(KBUILD_IMAGE)
 
@@ -217,7 +214,8 @@ $(BOOT_TARGETS): vmlinux
 
 compressed: zImage
 
-archprepare: maketools
+archprepare:
+       $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h
 
 archclean:
        $(Q)$(MAKE) $(clean)=$(boot)
@@ -234,5 +232,3 @@ define archhelp
        @echo '  uImage.bz2                - Kernel-only image for U-Boot (bzip2)'
        @echo '  uImage.lzma               - Kernel-only image for U-Boot (lzma)'
 endef
-
-CLEAN_FILES += include/asm-sh/machtypes.h
index cf9dc12dfeb153d78ccd2ff2bcdcbfb8b5fe7804..1f5fa5c44f6df77d42f0166893abf815ed54c981 100644 (file)
@@ -316,20 +316,24 @@ static struct soc_camera_platform_info camera_info = {
        .format_name = "UYVY",
        .format_depth = 16,
        .format = {
-               .pixelformat = V4L2_PIX_FMT_UYVY,
+               .code = V4L2_MBUS_FMT_YUYV8_2X8_BE,
                .colorspace = V4L2_COLORSPACE_SMPTE170M,
+               .field = V4L2_FIELD_NONE,
                .width = 640,
                .height = 480,
        },
        .bus_param = SOCAM_PCLK_SAMPLE_RISING | SOCAM_HSYNC_ACTIVE_HIGH |
-       SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8,
+       SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_MASTER | SOCAM_DATAWIDTH_8 |
+       SOCAM_DATA_ACTIVE_HIGH,
        .set_capture = camera_set_capture,
-       .link = {
-               .bus_id         = 0,
-               .add_device     = ap325rxa_camera_add,
-               .del_device     = ap325rxa_camera_del,
-               .module_name    = "soc_camera_platform",
-       },
+};
+
+struct soc_camera_link camera_link = {
+       .bus_id         = 0,
+       .add_device     = ap325rxa_camera_add,
+       .del_device     = ap325rxa_camera_del,
+       .module_name    = "soc_camera_platform",
+       .priv           = &camera_info,
 };
 
 static void dummy_release(struct device *dev)
@@ -347,7 +351,7 @@ static struct platform_device camera_device = {
 static int ap325rxa_camera_add(struct soc_camera_link *icl,
                               struct device *dev)
 {
-       if (icl != &camera_info.link || camera_probe() <= 0)
+       if (icl != &camera_link || camera_probe() <= 0)
                return -ENODEV;
 
        camera_info.dev = dev;
@@ -357,7 +361,7 @@ static int ap325rxa_camera_add(struct soc_camera_link *icl,
 
 static void ap325rxa_camera_del(struct soc_camera_link *icl)
 {
-       if (icl != &camera_info.link)
+       if (icl != &camera_link)
                return;
 
        platform_device_unregister(&camera_device);
@@ -470,13 +474,15 @@ static struct ov772x_camera_info ov7725_info = {
        .buswidth       = SOCAM_DATAWIDTH_8,
        .flags          = OV772X_FLAG_VFLIP | OV772X_FLAG_HFLIP,
        .edgectrl       = OV772X_AUTO_EDGECTRL(0xf, 0),
-       .link = {
-               .bus_id         = 0,
-               .power          = ov7725_power,
-               .board_info     = &ap325rxa_i2c_camera[0],
-               .i2c_adapter_id = 0,
-               .module_name    = "ov772x",
-       },
+};
+
+static struct soc_camera_link ov7725_link = {
+       .bus_id         = 0,
+       .power          = ov7725_power,
+       .board_info     = &ap325rxa_i2c_camera[0],
+       .i2c_adapter_id = 0,
+       .module_name    = "ov772x",
+       .priv           = &ov7725_info,
 };
 
 static struct platform_device ap325rxa_camera[] = {
@@ -484,13 +490,13 @@ static struct platform_device ap325rxa_camera[] = {
                .name   = "soc-camera-pdrv",
                .id     = 0,
                .dev    = {
-                       .platform_data = &ov7725_info.link,
+                       .platform_data = &ov7725_link,
                },
        }, {
                .name   = "soc-camera-pdrv",
                .id     = 1,
                .dev    = {
-                       .platform_data = &camera_info.link,
+                       .platform_data = &camera_link,
                },
        },
 };
index 826e62326d51b563167544a19d32faf62b1c3bb2..6a8861b39f05cd169138c9dbf5c5a254ad236a8a 100644 (file)
 #include <linux/usb/r8a66597.h>
 #include <linux/i2c.h>
 #include <linux/i2c/tsc2007.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/sh_msiof.h>
+#include <linux/spi/mmc_spi.h>
+#include <linux/mmc/host.h>
 #include <linux/input.h>
 #include <linux/input/sh_keysc.h>
 #include <linux/mfd/sh_mobile_sdhi.h>
 #include <video/sh_mobile_lcdc.h>
+#include <sound/sh_fsi.h>
 #include <media/sh_mobile_ceu.h>
+#include <media/tw9910.h>
+#include <media/mt9t112.h>
 #include <asm/heartbeat.h>
 #include <asm/sh_eth.h>
 #include <asm/clock.h>
@@ -121,8 +128,6 @@ static struct platform_device nor_flash_device = {
 
 /* SH Eth */
 #define SH_ETH_ADDR    (0xA4600000)
-#define SH_ETH_MAHR    (SH_ETH_ADDR + 0x1C0)
-#define SH_ETH_MALR    (SH_ETH_ADDR + 0x1C8)
 static struct resource sh_eth_resources[] = {
        [0] = {
                .start = SH_ETH_ADDR,
@@ -338,6 +343,12 @@ static struct platform_device ceu1_device = {
 };
 
 /* I2C device */
+static struct i2c_board_info i2c0_devices[] = {
+       {
+               I2C_BOARD_INFO("da7210", 0x1a),
+       },
+};
+
 static struct i2c_board_info i2c1_devices[] = {
        {
                I2C_BOARD_INFO("r2025sd", 0x32),
@@ -421,6 +432,7 @@ static struct i2c_board_info ts_i2c_clients = {
        .irq            = IRQ0,
 };
 
+#ifdef CONFIG_MFD_SH_MOBILE_SDHI
 /* SHDI0 */
 static void sdhi0_set_pwr(struct platform_device *pdev, int state)
 {
@@ -493,6 +505,250 @@ static struct platform_device sdhi1_device = {
        },
 };
 
+#else
+
+/* MMC SPI */
+static int mmc_spi_get_ro(struct device *dev)
+{
+       return gpio_get_value(GPIO_PTY6);
+}
+
+static int mmc_spi_get_cd(struct device *dev)
+{
+       return !gpio_get_value(GPIO_PTY7);
+}
+
+static void mmc_spi_setpower(struct device *dev, unsigned int maskval)
+{
+       gpio_set_value(GPIO_PTB6, maskval ? 1 : 0);
+}
+
+static struct mmc_spi_platform_data mmc_spi_info = {
+       .get_ro = mmc_spi_get_ro,
+       .get_cd = mmc_spi_get_cd,
+       .caps = MMC_CAP_NEEDS_POLL,
+       .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */
+       .setpower = mmc_spi_setpower,
+};
+
+static struct spi_board_info spi_bus[] = {
+       {
+               .modalias       = "mmc_spi",
+               .platform_data  = &mmc_spi_info,
+               .max_speed_hz   = 5000000,
+               .mode           = SPI_MODE_0,
+               .controller_data = (void *) GPIO_PTM4,
+       },
+};
+
+/* MSIOF0 */
+static struct sh_msiof_spi_info msiof0_data = {
+       .num_chipselect = 1,
+};
+
+static struct resource msiof0_resources[] = {
+       [0] = {
+               .name   = "MSIOF0",
+               .start  = 0xa4c40000,
+               .end    = 0xa4c40063,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = 84,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device msiof0_device = {
+       .name           = "spi_sh_msiof",
+       .id             = 0, /* MSIOF0 */
+       .dev = {
+               .platform_data = &msiof0_data,
+       },
+       .num_resources  = ARRAY_SIZE(msiof0_resources),
+       .resource       = msiof0_resources,
+       .archdata = {
+               .hwblk_id = HWBLK_MSIOF0,
+       },
+};
+
+#endif
+
+/* I2C Video/Camera */
+static struct i2c_board_info i2c_camera[] = {
+       {
+               I2C_BOARD_INFO("tw9910", 0x45),
+       },
+       {
+               /* 1st camera */
+               I2C_BOARD_INFO("mt9t112", 0x3c),
+       },
+       {
+               /* 2nd camera */
+               I2C_BOARD_INFO("mt9t112", 0x3c),
+       },
+};
+
+/* tw9910 */
+static int tw9910_power(struct device *dev, int mode)
+{
+       int val = mode ? 0 : 1;
+
+       gpio_set_value(GPIO_PTU2, val);
+       if (mode)
+               mdelay(100);
+
+       return 0;
+}
+
+static struct tw9910_video_info tw9910_info = {
+       .buswidth       = SOCAM_DATAWIDTH_8,
+       .mpout          = TW9910_MPO_FIELD,
+};
+
+static struct soc_camera_link tw9910_link = {
+       .i2c_adapter_id = 0,
+       .bus_id         = 1,
+       .power          = tw9910_power,
+       .board_info     = &i2c_camera[0],
+       .module_name    = "tw9910",
+       .priv           = &tw9910_info,
+};
+
+/* mt9t112 */
+static int mt9t112_power1(struct device *dev, int mode)
+{
+       gpio_set_value(GPIO_PTA3, mode);
+       if (mode)
+               mdelay(100);
+
+       return 0;
+}
+
+static struct mt9t112_camera_info mt9t112_info1 = {
+       .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
+       .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
+};
+
+static struct soc_camera_link mt9t112_link1 = {
+       .i2c_adapter_id = 0,
+       .power          = mt9t112_power1,
+       .bus_id         = 0,
+       .board_info     = &i2c_camera[1],
+       .module_name    = "mt9t112",
+       .priv           = &mt9t112_info1,
+};
+
+static int mt9t112_power2(struct device *dev, int mode)
+{
+       gpio_set_value(GPIO_PTA4, mode);
+       if (mode)
+               mdelay(100);
+
+       return 0;
+}
+
+static struct mt9t112_camera_info mt9t112_info2 = {
+       .flags = MT9T112_FLAG_PCLK_RISING_EDGE | MT9T112_FLAG_DATAWIDTH_8,
+       .divider = { 0x49, 0x6, 0, 6, 0, 9, 9, 6, 0 }, /* for 24MHz */
+};
+
+static struct soc_camera_link mt9t112_link2 = {
+       .i2c_adapter_id = 1,
+       .power          = mt9t112_power2,
+       .bus_id         = 1,
+       .board_info     = &i2c_camera[2],
+       .module_name    = "mt9t112",
+       .priv           = &mt9t112_info2,
+};
+
+static struct platform_device camera_devices[] = {
+       {
+               .name   = "soc-camera-pdrv",
+               .id     = 0,
+               .dev    = {
+                       .platform_data = &tw9910_link,
+               },
+       },
+       {
+               .name   = "soc-camera-pdrv",
+               .id     = 1,
+               .dev    = {
+                       .platform_data = &mt9t112_link1,
+               },
+       },
+       {
+               .name   = "soc-camera-pdrv",
+               .id     = 2,
+               .dev    = {
+                       .platform_data = &mt9t112_link2,
+               },
+       },
+};
+
+/* FSI */
+/*
+ * FSI-B use external clock which came from da7210.
+ * So, we should change parent of fsi
+ */
+#define FCLKBCR                0xa415000c
+static void fsimck_init(struct clk *clk)
+{
+       u32 status = ctrl_inl(clk->enable_reg);
+
+       /* use external clock */
+       status &= ~0x000000ff;
+       status |= 0x00000080;
+
+       ctrl_outl(status, clk->enable_reg);
+}
+
+static struct clk_ops fsimck_clk_ops = {
+       .init = fsimck_init,
+};
+
+static struct clk fsimckb_clk = {
+       .name           = "fsimckb_clk",
+       .id             = -1,
+       .ops            = &fsimck_clk_ops,
+       .enable_reg     = (void __iomem *)FCLKBCR,
+       .rate           = 0, /* unknown */
+};
+
+struct sh_fsi_platform_info fsi_info = {
+       .portb_flags = SH_FSI_BRS_INV |
+                      SH_FSI_OUT_SLAVE_MODE |
+                      SH_FSI_IN_SLAVE_MODE |
+                      SH_FSI_OFMT(I2S) |
+                      SH_FSI_IFMT(I2S),
+};
+
+static struct resource fsi_resources[] = {
+       [0] = {
+               .name   = "FSI",
+               .start  = 0xFE3C0000,
+               .end    = 0xFE3C021d,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = 108,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device fsi_device = {
+       .name           = "sh_fsi",
+       .id             = 0,
+       .num_resources  = ARRAY_SIZE(fsi_resources),
+       .resource       = fsi_resources,
+       .dev    = {
+               .platform_data  = &fsi_info,
+       },
+       .archdata = {
+               .hwblk_id = HWBLK_SPU, /* FSI needs SPU hwblk */
+       },
+};
+
 static struct platform_device *ecovec_devices[] __initdata = {
        &heartbeat_device,
        &nor_flash_device,
@@ -503,8 +759,16 @@ static struct platform_device *ecovec_devices[] __initdata = {
        &ceu0_device,
        &ceu1_device,
        &keysc_device,
+#ifdef CONFIG_MFD_SH_MOBILE_SDHI
        &sdhi0_device,
        &sdhi1_device,
+#else
+       &msiof0_device,
+#endif
+       &camera_devices[0],
+       &camera_devices[1],
+       &camera_devices[2],
+       &fsi_device,
 };
 
 #define EEPROM_ADDR 0x50
@@ -560,6 +824,8 @@ extern char ecovec24_sdram_leave_end;
 
 static int __init arch_setup(void)
 {
+       struct clk *clk;
+
        /* register board specific self-refresh code */
        sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF,
                                        &ecovec24_sdram_enter_start,
@@ -773,7 +1039,8 @@ static int __init arch_setup(void)
        gpio_direction_input(GPIO_PTR5);
        gpio_direction_input(GPIO_PTR6);
 
-       /* enable SDHI0 (needs DS2.4 set to ON) */
+#ifdef CONFIG_MFD_SH_MOBILE_SDHI
+       /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */
        gpio_request(GPIO_FN_SDHI0CD,  NULL);
        gpio_request(GPIO_FN_SDHI0WP,  NULL);
        gpio_request(GPIO_FN_SDHI0CMD, NULL);
@@ -785,7 +1052,7 @@ static int __init arch_setup(void)
        gpio_request(GPIO_PTB6, NULL);
        gpio_direction_output(GPIO_PTB6, 0);
 
-       /* enable SDHI1 (needs DS2.6,7 set to ON,OFF) */
+       /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */
        gpio_request(GPIO_FN_SDHI1CD,  NULL);
        gpio_request(GPIO_FN_SDHI1WP,  NULL);
        gpio_request(GPIO_FN_SDHI1CMD, NULL);
@@ -799,8 +1066,59 @@ static int __init arch_setup(void)
 
        /* I/O buffer drive ability is high for SDHI1 */
        ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA);
+#else
+       /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */
+       gpio_request(GPIO_FN_MSIOF0_TXD, NULL);
+       gpio_request(GPIO_FN_MSIOF0_RXD, NULL);
+       gpio_request(GPIO_FN_MSIOF0_TSCK, NULL);
+       gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */
+       gpio_direction_output(GPIO_PTM4, 1); /* active low CS */
+       gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */
+       gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */
+       gpio_request(GPIO_PTY6, NULL); /* write protect */
+       gpio_direction_input(GPIO_PTY6);
+       gpio_request(GPIO_PTY7, NULL); /* card detect */
+       gpio_direction_input(GPIO_PTY7);
+
+       spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
+#endif
+
+       /* enable Video */
+       gpio_request(GPIO_PTU2, NULL);
+       gpio_direction_output(GPIO_PTU2, 1);
+
+       /* enable Camera */
+       gpio_request(GPIO_PTA3, NULL);
+       gpio_request(GPIO_PTA4, NULL);
+       gpio_direction_output(GPIO_PTA3, 0);
+       gpio_direction_output(GPIO_PTA4, 0);
+
+       /* enable FSI */
+       gpio_request(GPIO_FN_FSIMCKB,    NULL);
+       gpio_request(GPIO_FN_FSIIBSD,    NULL);
+       gpio_request(GPIO_FN_FSIOBSD,    NULL);
+       gpio_request(GPIO_FN_FSIIBBCK,   NULL);
+       gpio_request(GPIO_FN_FSIIBLRCK,  NULL);
+       gpio_request(GPIO_FN_FSIOBBCK,   NULL);
+       gpio_request(GPIO_FN_FSIOBLRCK,  NULL);
+       gpio_request(GPIO_FN_CLKAUDIOBO, NULL);
+
+       /* change parent of FSI B */
+       clk = clk_get(NULL, "fsib_clk");
+       clk_register(&fsimckb_clk);
+       clk_set_parent(clk, &fsimckb_clk);
+       clk_set_rate(clk, 11000);
+       clk_set_rate(&fsimckb_clk, 11000);
+       clk_put(clk);
+
+       gpio_request(GPIO_PTU0, NULL);
+       gpio_direction_output(GPIO_PTU0, 0);
+       mdelay(20);
 
        /* enable I2C device */
+       i2c_register_board_info(0, i2c0_devices,
+                               ARRAY_SIZE(i2c0_devices));
+
        i2c_register_board_info(1, i2c1_devices,
                                ARRAY_SIZE(i2c1_devices));
 
index 8ccb1cc8b5890fed7fe0014c6d10b50133fa306e..e9b970846c41fcb0c96a105ed277059f722a57b3 100644 (file)
@@ -273,6 +273,12 @@ int kfr2r09_lcd_setup(void *board_data, void *sohandle,
        return 0;
 }
 
+void kfr2r09_lcd_start(void *board_data, void *sohandle,
+                      struct sh_mobile_lcdc_sys_bus_ops *so)
+{
+       write_memory_start(sohandle, so);
+}
+
 #define CTRL_CKSW       0x10
 #define CTRL_C10        0x20
 #define CTRL_CPSW       0x80
index 87438d6603d63e89502d146cba841a5b7feaeba5..5d7b5d92475e46227b5b4c0e932a78f37ad0697f 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/input/sh_keysc.h>
 #include <linux/i2c.h>
 #include <linux/usb/r8a66597.h>
+#include <media/rj54n1cb0c.h>
 #include <media/soc_camera.h>
 #include <media/sh_mobile_ceu.h>
 #include <video/sh_mobile_lcdc.h>
@@ -149,6 +150,7 @@ static struct sh_mobile_lcdc_info kfr2r09_sh_lcdc_info = {
                },
                .board_cfg = {
                        .setup_sys = kfr2r09_lcd_setup,
+                       .start_transfer = kfr2r09_lcd_start,
                        .display_on = kfr2r09_lcd_on,
                        .display_off = kfr2r09_lcd_off,
                },
@@ -255,6 +257,9 @@ static struct i2c_board_info kfr2r09_i2c_camera = {
 
 static struct clk *camera_clk;
 
+/* set VIO_CKO clock to 25MHz */
+#define CEU_MCLK_FREQ 25000000
+
 #define DRVCRB 0xA405018C
 static int camera_power(struct device *dev, int mode)
 {
@@ -267,8 +272,7 @@ static int camera_power(struct device *dev, int mode)
                if (IS_ERR(camera_clk))
                        return PTR_ERR(camera_clk);
 
-               /* set VIO_CKO clock to 25MHz */
-               rate = clk_round_rate(camera_clk, 25000000);
+               rate = clk_round_rate(camera_clk, CEU_MCLK_FREQ);
                ret = clk_set_rate(camera_clk, rate);
                if (ret < 0)
                        goto eclkrate;
@@ -318,11 +322,17 @@ eclkrate:
        return ret;
 }
 
+static struct rj54n1_pdata rj54n1_priv = {
+       .mclk_freq      = CEU_MCLK_FREQ,
+       .ioctl_high     = false,
+};
+
 static struct soc_camera_link rj54n1_link = {
        .power          = camera_power,
        .board_info     = &kfr2r09_i2c_camera,
        .i2c_adapter_id = 1,
        .module_name    = "rj54n1cb0c",
+       .priv           = &rj54n1_priv,
 };
 
 static struct platform_device kfr2r09_camera = {
index 9099b6da99576112ca121ac2ad9966cc8df7575c..507c77be476d649c454f6b0b0653df1ca8ce907f 100644 (file)
@@ -432,23 +432,27 @@ static struct i2c_board_info migor_i2c_camera[] = {
 
 static struct ov772x_camera_info ov7725_info = {
        .buswidth       = SOCAM_DATAWIDTH_8,
-       .link = {
-               .power          = ov7725_power,
-               .board_info     = &migor_i2c_camera[0],
-               .i2c_adapter_id = 0,
-               .module_name    = "ov772x",
-       },
+};
+
+static struct soc_camera_link ov7725_link = {
+       .power          = ov7725_power,
+       .board_info     = &migor_i2c_camera[0],
+       .i2c_adapter_id = 0,
+       .module_name    = "ov772x",
+       .priv           = &ov7725_info,
 };
 
 static struct tw9910_video_info tw9910_info = {
        .buswidth       = SOCAM_DATAWIDTH_8,
        .mpout          = TW9910_MPO_FIELD,
-       .link = {
-               .power          = tw9910_power,
-               .board_info     = &migor_i2c_camera[1],
-               .i2c_adapter_id = 0,
-               .module_name    = "tw9910",
-       }
+};
+
+static struct soc_camera_link tw9910_link = {
+       .power          = tw9910_power,
+       .board_info     = &migor_i2c_camera[1],
+       .i2c_adapter_id = 0,
+       .module_name    = "tw9910",
+       .priv           = &tw9910_info,
 };
 
 static struct platform_device migor_camera[] = {
@@ -456,13 +460,13 @@ static struct platform_device migor_camera[] = {
                .name   = "soc-camera-pdrv",
                .id     = 0,
                .dev    = {
-                       .platform_data = &ov7725_info.link,
+                       .platform_data = &ov7725_link,
                },
        }, {
                .name   = "soc-camera-pdrv",
                .id     = 1,
                .dev    = {
-                       .platform_data = &tw9910_info.link,
+                       .platform_data = &tw9910_link,
                },
        },
 };
index 4eb31acfafef0f9647a72d5bd06b1d309f1cd9bc..b221b6842b0d9142dbaf4e01b2f524d6c20728c2 100644 (file)
@@ -57,15 +57,16 @@ static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc)
  */
 void __init init_se7722_IRQ(void)
 {
-       int i;
+       int i, irq;
 
        ctrl_outw(0, IRQ01_MASK);       /* disable all irqs */
        ctrl_outw(0x2000, 0xb03fffec);  /* mrshpc irq enable */
 
        for (i = 0; i < SE7722_FPGA_IRQ_NR; i++) {
-               se7722_fpga_irq[i] = create_irq();
-               if (se7722_fpga_irq[i] < 0)
+               irq = create_irq();
+               if (irq < 0)
                        return;
+               se7722_fpga_irq[i] = irq;
 
                set_irq_chip_and_handler_name(se7722_fpga_irq[i],
                                              &se7722_irq_chip,
index 4b0f0c0dc2b858ff1c3d9e447d8f4944e79d1c3e..5d0f70b46c97435dab2e565498ec33cf98ba34f3 100644 (file)
@@ -514,6 +514,13 @@ static struct platform_device *ms7724se_devices[] __initdata = {
        &sdhi1_cn8_device,
 };
 
+/* I2C device */
+static struct i2c_board_info i2c0_devices[] = {
+       {
+               I2C_BOARD_INFO("ak4642", 0x12),
+       },
+};
+
 #define EEPROM_OP   0xBA206000
 #define EEPROM_ADR  0xBA206004
 #define EEPROM_DATA 0xBA20600C
@@ -575,6 +582,16 @@ extern char ms7724se_sdram_enter_end;
 extern char ms7724se_sdram_leave_start;
 extern char ms7724se_sdram_leave_end;
 
+
+static int __init arch_setup(void)
+{
+       /* enable I2C device */
+       i2c_register_board_info(0, i2c0_devices,
+                               ARRAY_SIZE(i2c0_devices));
+       return 0;
+}
+arch_initcall(arch_setup);
+
 static int __init devices_setup(void)
 {
        u16 sw = ctrl_inw(SW4140); /* select camera, monitor */
index 0774924623cc287b9a9a3c23ba55243c3b61f289..46874704e4e7b18c30283bb604a7297fffdcf60f 100644 (file)
@@ -203,7 +203,7 @@ CONFIG_MMU=y
 CONFIG_PAGE_OFFSET=0x80000000
 CONFIG_FORCE_MAX_ZONEORDER=11
 CONFIG_MEMORY_START=0x08000000
-CONFIG_MEMORY_SIZE=0x08000000
+CONFIG_MEMORY_SIZE=0x10000000
 CONFIG_29BIT=y
 # CONFIG_X2TLB is not set
 CONFIG_VSYSCALL=y
index ac6469718a2c46761a0da53c7cbc8778cce4e10a..cad918437ca7a26c450041e8a42f38b373be597d 100644 (file)
@@ -204,7 +204,7 @@ CONFIG_MMU=y
 CONFIG_PAGE_OFFSET=0x80000000
 CONFIG_FORCE_MAX_ZONEORDER=11
 CONFIG_MEMORY_START=0x08000000
-CONFIG_MEMORY_SIZE=0x08000000
+CONFIG_MEMORY_SIZE=0x10000000
 CONFIG_29BIT=y
 # CONFIG_X2TLB is not set
 CONFIG_VSYSCALL=y
index f521e82cc19e17009a7d43fb043e7a52cd750a3a..6f1126b3e487b3a67a91b45c8bab7c46f1ea1a35 100644 (file)
@@ -324,7 +324,7 @@ CONFIG_ENTRY_OFFSET=0x00001000
 # CONFIG_UBC_WAKEUP is not set
 CONFIG_CMDLINE_OVERWRITE=y
 # CONFIG_CMDLINE_EXTEND is not set
-CONFIG_CMDLINE="console=tty0 console=ttySC0,115200 root=/dev/sda1 earlyprintk=serial"
+CONFIG_CMDLINE="console=tty0 console=ttySC1,115200 root=/dev/sda1"
 
 #
 # Bus options
index a156cd1e0617acfac691f39594dd3c9732274172..9215bbb13d6fbb4d96e5cef029c8a473beeecc02 100644 (file)
@@ -324,7 +324,7 @@ CONFIG_ENTRY_OFFSET=0x00001000
 # CONFIG_UBC_WAKEUP is not set
 CONFIG_CMDLINE_OVERWRITE=y
 # CONFIG_CMDLINE_EXTEND is not set
-CONFIG_CMDLINE="console=tty0 console=ttySC0,115200 root=/dev/sda1 earlyprintk=serial"
+CONFIG_CMDLINE="console=tty0 console=ttySC1,115200 root=/dev/sda1"
 
 #
 # Bus options
index 052b354236dcf02e039d539254c3a5e66e00e0de..7898f14d6641e701dc8438a53b539d4a89fa624b 100644 (file)
@@ -15,7 +15,7 @@
 #include <mach/lboxre2.h>
 #include <mach/r2d.h>
 #include "pci-sh4.h"
-#include <asm/machtypes.h>
+#include <generated/machtypes.h>
 
 #define PCIMCR_MRSET_OFF       0xBFFFFFFF
 #define PCIMCR_RFSH_OFF                0xFFFFFFFB
diff --git a/arch/sh/include/asm/.gitignore b/arch/sh/include/asm/.gitignore
deleted file mode 100644 (file)
index 378db77..0000000
+++ /dev/null
@@ -1 +0,0 @@
-machtypes.h
diff --git a/arch/sh/include/asm/asm-offsets.h b/arch/sh/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 04ad0e1e637e44d2f1d6c2349583f5cf7f889dcd..07373a074090addb2ae3e999f3ec7d7a18a408c2 100644 (file)
 #include <asm-generic/dma.h>
 
 #ifdef CONFIG_NR_DMA_CHANNELS
-#  define MAX_DMA_CHANNELS   (CONFIG_NR_DMA_CHANNELS)
+#  define MAX_DMA_CHANNELS     (CONFIG_NR_DMA_CHANNELS)
+#elif defined(CONFIG_NR_ONCHIP_DMA_CHANNELS)
+#  define MAX_DMA_CHANNELS     (CONFIG_NR_ONCHIP_DMA_CHANNELS)
 #else
-#  define MAX_DMA_CHANNELS   (CONFIG_NR_ONCHIP_DMA_CHANNELS)
+#  define MAX_DMA_CHANNELS     0
 #endif
 
 /*
index ccb1d93bb04361678b967fd80151c43427263b27..ac04255022b69548e6f71f07f0502e97664c881f 100644 (file)
@@ -114,7 +114,6 @@ typedef struct user_fpu_struct elf_fpregset_t;
  */
 #define CORE_DUMP_USE_REGSET
 
-#define USE_ELF_CORE_DUMP
 #define ELF_FDPIC_CORE_EFLAGS  EF_SH_FDPIC
 #define ELF_EXEC_PAGESIZE      PAGE_SIZE
 
index 512cd3e9d0ca1c92c6153e1cf5a1cc7e460cb644..026dd659a6400cf70f6105167cfa927e4670f978 100644 (file)
@@ -233,10 +233,16 @@ unsigned long long poke_real_address_q(unsigned long long addr,
  * doesn't exist, so everything must go through page tables.
  */
 #ifdef CONFIG_MMU
-void __iomem *__ioremap(unsigned long offset, unsigned long size,
-                       unsigned long flags);
+void __iomem *__ioremap_caller(unsigned long offset, unsigned long size,
+                              unsigned long flags, void *caller);
 void __iounmap(void __iomem *addr);
 
+static inline void __iomem *
+__ioremap(unsigned long offset, unsigned long size, unsigned long flags)
+{
+       return __ioremap_caller(offset, size, flags, __builtin_return_address(0));
+}
+
 static inline void __iomem *
 __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
 {
@@ -271,6 +277,7 @@ __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
        return __ioremap(offset, size, flags);
 }
 #else
+#define __ioremap(offset, size, flags)         ((void __iomem *)(offset))
 #define __ioremap_mode(offset, size, flags)    ((void __iomem *)(offset))
 #define __iounmap(addr)                                do { } while (0)
 #endif /* CONFIG_MMU */
index 84dd37761f563ee56aef820e97d6d1cc844f0936..9c30955630ffb8882064a53a54c76e9d810af659 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <linux/types.h>
 #include <linux/time.h>
-#include <asm/machtypes.h>
+#include <generated/machtypes.h>
 
 struct sh_machine_vector {
        void (*mv_setup)(char **cmdline_p);
index b354355162034bdfac9c0ef10a15ec9b833fbc9f..5003ee86f67bd9215ca2d40083455727d2de9784 100644 (file)
@@ -344,7 +344,8 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
 #define pte_special(pte)       ((pte).pte_low & _PAGE_SPECIAL)
 
 #ifdef CONFIG_X2TLB
-#define pte_write(pte)         ((pte).pte_high & _PAGE_EXT_USER_WRITE)
+#define pte_write(pte) \
+       ((pte).pte_high & (_PAGE_EXT_USER_WRITE | _PAGE_EXT_KERN_WRITE))
 #else
 #define pte_write(pte)         ((pte).pte_low & _PAGE_RW)
 #endif
@@ -358,7 +359,7 @@ static inline pte_t pte_##fn(pte_t pte) { pte.pte_##h op; return pte; }
  * individually toggled (and user permissions are entirely decoupled from
  * kernel permissions), we attempt to couple them a bit more sanely here.
  */
-PTE_BIT_FUNC(high, wrprotect, &= ~_PAGE_EXT_USER_WRITE);
+PTE_BIT_FUNC(high, wrprotect, &= ~(_PAGE_EXT_USER_WRITE | _PAGE_EXT_KERN_WRITE));
 PTE_BIT_FUNC(high, mkwrite, |= _PAGE_EXT_USER_WRITE | _PAGE_EXT_KERN_WRITE);
 PTE_BIT_FUNC(high, mkhuge, |= _PAGE_SZHUGE);
 #else
index a28c9f0053fd4663f52d8c9fc1fb5a78feb31f48..bdc0f3b6c56afdf23d6b628128e6171cc2552b74 100644 (file)
  * Your basic SMP spinlocks, allowing only a single CPU anywhere
  */
 
-#define __raw_spin_is_locked(x)                ((x)->lock <= 0)
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
-#define __raw_spin_unlock_wait(x) \
-       do { while (__raw_spin_is_locked(x)) cpu_relax(); } while (0)
+#define arch_spin_is_locked(x)         ((x)->lock <= 0)
+#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
+#define arch_spin_unlock_wait(x) \
+       do { while (arch_spin_is_locked(x)) cpu_relax(); } while (0)
 
 /*
  * Simple spin lock operations.  There are two variants, one clears IRQ's
  *
  * We make no fairness assumptions.  They have a cost.
  */
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        unsigned long tmp;
        unsigned long oldval;
 
        __asm__ __volatile__ (
                "1:                                             \n\t"
-               "movli.l        @%2, %0 ! __raw_spin_lock       \n\t"
+               "movli.l        @%2, %0 ! arch_spin_lock        \n\t"
                "mov            %0, %1                          \n\t"
                "mov            #0, %0                          \n\t"
                "movco.l        %0, @%2                         \n\t"
@@ -54,12 +54,12 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
        );
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        unsigned long tmp;
 
        __asm__ __volatile__ (
-               "mov            #1, %0 ! __raw_spin_unlock      \n\t"
+               "mov            #1, %0 ! arch_spin_unlock       \n\t"
                "mov.l          %0, @%1                         \n\t"
                : "=&z" (tmp)
                : "r" (&lock->lock)
@@ -67,13 +67,13 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
        );
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        unsigned long tmp, oldval;
 
        __asm__ __volatile__ (
                "1:                                             \n\t"
-               "movli.l        @%2, %0 ! __raw_spin_trylock    \n\t"
+               "movli.l        @%2, %0 ! arch_spin_trylock     \n\t"
                "mov            %0, %1                          \n\t"
                "mov            #0, %0                          \n\t"
                "movco.l        %0, @%2                         \n\t"
@@ -100,21 +100,21 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
  * read_can_lock - would read_trylock() succeed?
  * @lock: the rwlock in question.
  */
-#define __raw_read_can_lock(x) ((x)->lock > 0)
+#define arch_read_can_lock(x)  ((x)->lock > 0)
 
 /**
  * write_can_lock - would write_trylock() succeed?
  * @lock: the rwlock in question.
  */
-#define __raw_write_can_lock(x)        ((x)->lock == RW_LOCK_BIAS)
+#define arch_write_can_lock(x) ((x)->lock == RW_LOCK_BIAS)
 
-static inline void __raw_read_lock(raw_rwlock_t *rw)
+static inline void arch_read_lock(arch_rwlock_t *rw)
 {
        unsigned long tmp;
 
        __asm__ __volatile__ (
                "1:                                             \n\t"
-               "movli.l        @%1, %0 ! __raw_read_lock       \n\t"
+               "movli.l        @%1, %0 ! arch_read_lock        \n\t"
                "cmp/pl         %0                              \n\t"
                "bf             1b                              \n\t"
                "add            #-1, %0                         \n\t"
@@ -126,13 +126,13 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
        );
 }
 
-static inline void __raw_read_unlock(raw_rwlock_t *rw)
+static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
        unsigned long tmp;
 
        __asm__ __volatile__ (
                "1:                                             \n\t"
-               "movli.l        @%1, %0 ! __raw_read_unlock     \n\t"
+               "movli.l        @%1, %0 ! arch_read_unlock      \n\t"
                "add            #1, %0                          \n\t"
                "movco.l        %0, @%1                         \n\t"
                "bf             1b                              \n\t"
@@ -142,13 +142,13 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
        );
 }
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
        unsigned long tmp;
 
        __asm__ __volatile__ (
                "1:                                             \n\t"
-               "movli.l        @%1, %0 ! __raw_write_lock      \n\t"
+               "movli.l        @%1, %0 ! arch_write_lock       \n\t"
                "cmp/hs         %2, %0                          \n\t"
                "bf             1b                              \n\t"
                "sub            %2, %0                          \n\t"
@@ -160,23 +160,23 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
        );
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t *rw)
+static inline void arch_write_unlock(arch_rwlock_t *rw)
 {
        __asm__ __volatile__ (
-               "mov.l          %1, @%0 ! __raw_write_unlock    \n\t"
+               "mov.l          %1, @%0 ! arch_write_unlock     \n\t"
                :
                : "r" (&rw->lock), "r" (RW_LOCK_BIAS)
                : "t", "memory"
        );
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t *rw)
+static inline int arch_read_trylock(arch_rwlock_t *rw)
 {
        unsigned long tmp, oldval;
 
        __asm__ __volatile__ (
                "1:                                             \n\t"
-               "movli.l        @%2, %0 ! __raw_read_trylock    \n\t"
+               "movli.l        @%2, %0 ! arch_read_trylock     \n\t"
                "mov            %0, %1                          \n\t"
                "cmp/pl         %0                              \n\t"
                "bf             2f                              \n\t"
@@ -193,13 +193,13 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw)
        return (oldval > 0);
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *rw)
+static inline int arch_write_trylock(arch_rwlock_t *rw)
 {
        unsigned long tmp, oldval;
 
        __asm__ __volatile__ (
                "1:                                             \n\t"
-               "movli.l        @%2, %0 ! __raw_write_trylock   \n\t"
+               "movli.l        @%2, %0 ! arch_write_trylock    \n\t"
                "mov            %0, %1                          \n\t"
                "cmp/hs         %3, %0                          \n\t"
                "bf             2f                              \n\t"
@@ -216,11 +216,11 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
        return (oldval > (RW_LOCK_BIAS - 1));
 }
 
-#define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock)
-#define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock)
+#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* __ASM_SH_SPINLOCK_H */
index b4d244e7b60ca7532f7193e7365a9a67a293482f..9b7560db06ca9264cf1547624d3fee95fcfd97ac 100644 (file)
@@ -7,15 +7,15 @@
 
 typedef struct {
        volatile unsigned int lock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED               { 1 }
+#define __ARCH_SPIN_LOCK_UNLOCKED              { 1 }
 
 typedef struct {
        volatile unsigned int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
 #define RW_LOCK_BIAS                   0x01000000
-#define __RAW_RW_LOCK_UNLOCKED         { RW_LOCK_BIAS }
+#define __ARCH_RW_LOCK_UNLOCKED                { RW_LOCK_BIAS }
 
 #endif
index f3fd1b9eb6b1f32ae5b42446729ab3d1ef56f398..f18c4f9baf27920d4ef71621303d4c9a63a62448 100644 (file)
 #define __NR_pwritev           334
 #define __NR_rt_tgsigqueueinfo 335
 #define __NR_perf_event_open   336
+#define __NR_recvmmsg          337
 
-#define NR_syscalls 337
+#define NR_syscalls 338
 
 #ifdef __KERNEL__
 
index 343ce8f073ea674d8d3eb44ca0c625ab2101a44a..3e7645d111307e5d12db6e7172961b47f486e704 100644 (file)
 #define __NR_pwritev           362
 #define __NR_rt_tgsigqueueinfo 363
 #define __NR_perf_event_open   364
+#define __NR_recvmmsg          365
 
 #ifdef __KERNEL__
 
-#define NR_syscalls 365
+#define NR_syscalls 366
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
index f0886bc880e029d795dff5393b0f0c4d82a071cc..c4ed660c14cfaf2dec064d62df164f616e35ed9c 100644 (file)
 #elif defined(CONFIG_CPU_SUBTYPE_SH7723) || \
       defined(CONFIG_CPU_SUBTYPE_SH7724)
 #define DMTE0_IRQ      48      /* DMAC0A*/
-#define DMTE4_IRQ      40      /* DMAC0B */
-#define DMTE6_IRQ      42
-#define DMTE8_IRQ      76      /* DMAC1A */
-#define DMTE9_IRQ      77
+#define DMTE4_IRQ      76      /* DMAC0B */
+#define DMTE6_IRQ      40
+#define DMTE8_IRQ      42      /* DMAC1A */
+#define DMTE9_IRQ      43
 #define DMTE10_IRQ     72      /* DMAC1B */
 #define DMTE11_IRQ     73
 #define DMAE0_IRQ      78      /* DMA Error IRQ*/
index 174374e19547f4baf93157360a71b7f487b4202f..484ef42c2fb5b8d35084f9ef38c9693edadd5a16 100644 (file)
@@ -8,6 +8,8 @@ void kfr2r09_lcd_on(void *board_data);
 void kfr2r09_lcd_off(void *board_data);
 int kfr2r09_lcd_setup(void *board_data, void *sys_ops_handle,
                      struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
+void kfr2r09_lcd_start(void *board_data, void *sys_ops_handle,
+                      struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
 #else
 static inline void kfr2r09_lcd_on(void *board_data) {}
 static inline void kfr2r09_lcd_off(void *board_data) {}
@@ -16,6 +18,10 @@ static inline int kfr2r09_lcd_setup(void *board_data, void *sys_ops_handle,
 {
        return -ENODEV;
 }
+static inline void kfr2r09_lcd_start(void *board_data, void *sys_ops_handle,
+                                    struct sh_mobile_lcdc_sys_bus_ops *sys_ops)
+{
+}
 #endif
 
 #endif /* __ASM_SH_KFR2R09_H */
index 0471a3eb25edeba9a64a683de216852d19d54f70..0d587da1ef12bfa8ab402531ed0593d3b9bae9fa 100644 (file)
@@ -22,11 +22,10 @@ obj-y       := debugtraps.o dma-nommu.o dumpstack.o                         \
 obj-y                          += cpu/
 obj-$(CONFIG_VSYSCALL)         += vsyscall/
 obj-$(CONFIG_SMP)              += smp.o
-obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o
+obj-$(CONFIG_SH_STANDARD_BIOS) += sh_bios.o early_printk.o
 obj-$(CONFIG_KGDB)             += kgdb.o
 obj-$(CONFIG_SH_CPU_FREQ)      += cpufreq.o
 obj-$(CONFIG_MODULES)          += sh_ksyms_$(BITS).o module.o
-obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
 obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o
 obj-$(CONFIG_CRASH_DUMP)       += crash_dump.o
 obj-$(CONFIG_STACKTRACE)       += stacktrace.o
index c1508a90fc6af2049946e31de8c98a764b009863..9282d965a1b66082ef78f9c77e35150ac9778b47 100644 (file)
  * for more details.
  */
 #include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/io.h>
-#include <linux/interrupt.h>
 #include <linux/topology.h>
 
 static inline struct ipr_desc *get_ipr_desc(unsigned int irq)
 {
        struct irq_chip *chip = get_irq_chip(irq);
-       return (void *)((char *)chip - offsetof(struct ipr_desc, chip));
+       return container_of(chip, struct ipr_desc, chip);
 }
 
 static void disable_ipr_irq(unsigned int irq)
index 8555c05e86677f7cf3512b4d773ccd781e8a4cac..114c7cee718400395779f425fe536711e9f2bd7d 100644 (file)
@@ -59,32 +59,48 @@ static struct intc_prio_reg prio_registers[] __initdata = {
 static DECLARE_INTC_DESC(intc_desc, "sh7619", vectors, NULL,
                         NULL, prio_registers, NULL);
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xf8400000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 88, 88, 88, 88 },
-       }, {
-               .mapbase        = 0xf8410000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 92, 92, 92, 92 },
-       }, {
-               .mapbase        = 0xf8420000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 96, 96, 96, 96 },
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xf8400000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 88, 88, 88, 88 },
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xf8410000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 92, 92, 92, 92 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xf8420000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 96, 96, 96, 96 },
+};
+
+static struct platform_device scif2_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 2,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif2_platform_data,
        },
 };
 
@@ -176,7 +192,9 @@ static struct platform_device cmt1_device = {
 };
 
 static struct platform_device *sh7619_devices[] __initdata = {
-       &sci_device,
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
        &eth_device,
        &cmt0_device,
        &cmt1_device,
@@ -195,6 +213,9 @@ void __init plat_irq_setup(void)
 }
 
 static struct platform_device *sh7619_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
        &cmt0_device,
        &cmt1_device,
 };
index b67376445315b47045433ef7118d7460faba99e4..8f669dc9b0da49faa614c884af03c3dc93094fe6 100644 (file)
@@ -207,27 +207,23 @@ static struct platform_device mtu2_2_device = {
        .num_resources  = ARRAY_SIZE(mtu2_2_resources),
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xff804000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 220, 220, 220, 220 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xff804000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 220, 220, 220, 220 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif0_platform_data,
        },
 };
 
 static struct platform_device *mxg_devices[] __initdata = {
-       &sci_device,
+       &scif0_device,
        &mtu2_0_device,
        &mtu2_1_device,
        &mtu2_2_device,
@@ -246,6 +242,7 @@ void __init plat_irq_setup(void)
 }
 
 static struct platform_device *mxg_early_devices[] __initdata = {
+       &scif0_device,
        &mtu2_0_device,
        &mtu2_1_device,
        &mtu2_2_device,
index fbde5b75deb9152ba615c28af7c68652bc224ba8..4ccfeb59eb1a53d9e855da774786d09d557f43ab 100644 (file)
@@ -177,57 +177,123 @@ static struct intc_mask_reg mask_registers[] __initdata = {
 static DECLARE_INTC_DESC(intc_desc, "sh7201", vectors, groups,
                         mask_registers, prio_registers, NULL);
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xfffe8000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 180, 180, 180, 180 }
-       }, {
-               .mapbase        = 0xfffe8800,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 184, 184, 184, 184 }
-       }, {
-               .mapbase        = 0xfffe9000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 188, 188, 188, 188 }
-       }, {
-               .mapbase        = 0xfffe9800,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 192, 192, 192, 192 }
-       }, {
-               .mapbase        = 0xfffea000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 196, 196, 196, 196 }
-       }, {
-               .mapbase        = 0xfffea800,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 200, 200, 200, 200 }
-       }, {
-               .mapbase        = 0xfffeb000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 204, 204, 204, 204 }
-       }, {
-               .mapbase        = 0xfffeb800,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 208, 208, 208, 208 }
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xfffe8000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 180, 180, 180, 180 }
+};
+
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xfffe8800,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 184, 184, 184, 184 }
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xfffe9000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 188, 188, 188, 188 }
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xfffe9800,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 192, 192, 192, 192 }
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
+       .dev            = {
+               .platform_data  = &scif3_platform_data,
+       },
+};
+
+static struct plat_sci_port scif4_platform_data = {
+       .mapbase        = 0xfffea000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 196, 196, 196, 196 }
+};
+
+static struct platform_device scif4_device = {
+       .name           = "sh-sci",
+       .id             = 4,
+       .dev            = {
+               .platform_data  = &scif4_platform_data,
+       },
+};
+
+static struct plat_sci_port scif5_platform_data = {
+       .mapbase        = 0xfffea800,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 200, 200, 200, 200 }
+};
+
+static struct platform_device scif5_device = {
+       .name           = "sh-sci",
+       .id             = 5,
+       .dev            = {
+               .platform_data  = &scif5_platform_data,
+       },
+};
+
+static struct plat_sci_port scif6_platform_data = {
+       .mapbase        = 0xfffeb000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 204, 204, 204, 204 }
+};
+
+static struct platform_device scif6_device = {
+       .name           = "sh-sci",
+       .id             = 6,
+       .dev            = {
+               .platform_data  = &scif6_platform_data,
+       },
+};
+
+static struct plat_sci_port scif7_platform_data = {
+       .mapbase        = 0xfffeb800,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 208, 208, 208, 208 }
+};
+
+static struct platform_device scif7_device = {
+       .name           = "sh-sci",
+       .id             = 7,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif7_platform_data,
        },
 };
 
@@ -345,7 +411,14 @@ static struct platform_device mtu2_2_device = {
 };
 
 static struct platform_device *sh7201_devices[] __initdata = {
-       &sci_device,
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
+       &scif6_device,
+       &scif7_device,
        &rtc_device,
        &mtu2_0_device,
        &mtu2_1_device,
@@ -365,6 +438,14 @@ void __init plat_irq_setup(void)
 }
 
 static struct platform_device *sh7201_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
+       &scif6_device,
+       &scif7_device,
        &mtu2_0_device,
        &mtu2_1_device,
        &mtu2_2_device,
index d3fd536c9a842e08634a982c3c7b4330d749f05e..3136966cc9b3c7c87067719e91673b63fe0464cd 100644 (file)
@@ -173,37 +173,63 @@ static struct intc_mask_reg mask_registers[] __initdata = {
 static DECLARE_INTC_DESC(intc_desc, "sh7203", vectors, groups,
                         mask_registers, prio_registers, NULL);
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xfffe8000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           =  { 192, 192, 192, 192 },
-       }, {
-               .mapbase        = 0xfffe8800,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           =  { 196, 196, 196, 196 },
-       }, {
-               .mapbase        = 0xfffe9000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           =  { 200, 200, 200, 200 },
-       }, {
-               .mapbase        = 0xfffe9800,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           =  { 204, 204, 204, 204 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xfffe8000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           =  { 192, 192, 192, 192 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xfffe8800,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           =  { 196, 196, 196, 196 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xfffe9000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           =  { 200, 200, 200, 200 },
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xfffe9800,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           =  { 204, 204, 204, 204 },
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif3_platform_data,
        },
 };
 
@@ -354,7 +380,10 @@ static struct platform_device rtc_device = {
 };
 
 static struct platform_device *sh7203_devices[] __initdata = {
-       &sci_device,
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
        &cmt0_device,
        &cmt1_device,
        &mtu2_0_device,
@@ -375,6 +404,10 @@ void __init plat_irq_setup(void)
 }
 
 static struct platform_device *sh7203_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
        &cmt0_device,
        &cmt1_device,
        &mtu2_0_device,
index a9ccc5e8d9e98af493bf45ed7fdeb4430c0cc11b..064873585a8be99954837754e2607def20d0f79e 100644 (file)
@@ -133,37 +133,63 @@ static struct intc_mask_reg mask_registers[] __initdata = {
 static DECLARE_INTC_DESC(intc_desc, "sh7206", vectors, groups,
                         mask_registers, prio_registers, NULL);
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xfffe8000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 240, 240, 240, 240 },
-       }, {
-               .mapbase        = 0xfffe8800,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 244, 244, 244, 244 },
-       }, {
-               .mapbase        = 0xfffe9000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 248, 248, 248, 248 },
-       }, {
-               .mapbase        = 0xfffe9800,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 252, 252, 252, 252 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xfffe8000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 240, 240, 240, 240 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xfffe8800,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 244, 244, 244, 244 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xfffe9000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 248, 248, 248, 248 },
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xfffe9800,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 252, 252, 252, 252 },
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif3_platform_data,
        },
 };
 
@@ -325,7 +351,10 @@ static struct platform_device mtu2_2_device = {
 };
 
 static struct platform_device *sh7206_devices[] __initdata = {
-       &sci_device,
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
        &cmt0_device,
        &cmt1_device,
        &mtu2_0_device,
@@ -346,6 +375,10 @@ void __init plat_irq_setup(void)
 }
 
 static struct platform_device *sh7206_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
        &cmt0_device,
        &cmt1_device,
        &mtu2_0_device,
index c231059838780cc294d6f5f5cc7ea0a167eada0c..7b892d60e3a0e59a206b453b3c1121f688e7acf6 100644 (file)
@@ -67,27 +67,33 @@ static struct intc_prio_reg prio_registers[] __initdata = {
 static DECLARE_INTC_DESC(intc_desc, "sh7705", vectors, NULL,
                         NULL, prio_registers, NULL);
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xa4410000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 56, 56, 56 },
-       }, {
-               .mapbase        = 0xa4400000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 52, 52, 52 },
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xa4410000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 56, 56, 56 },
+};
+
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xa4400000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 52, 52, 52 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif1_platform_data,
        },
 };
 
@@ -210,10 +216,11 @@ static struct platform_device tmu2_device = {
 };
 
 static struct platform_device *sh7705_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
-       &sci_device,
        &rtc_device,
 };
 
@@ -225,6 +232,8 @@ static int __init sh7705_devices_setup(void)
 arch_initcall(sh7705_devices_setup);
 
 static struct platform_device *sh7705_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index 347ab35d0697bf6cb0899f18b87153cb69117b32..bc0c4f68c7c739f73b89f9a7029331094bac2ff3 100644 (file)
@@ -106,44 +106,55 @@ static struct platform_device rtc_device = {
        .resource       = rtc_resources,
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xfffffe80,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCI,
-               .irqs           = { 23, 23, 23, 0 },
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xfffffe80,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCI,
+       .irqs           = { 23, 23, 23, 0 },
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
        },
+};
 #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
     defined(CONFIG_CPU_SUBTYPE_SH7707) || \
     defined(CONFIG_CPU_SUBTYPE_SH7709)
-       {
-               .mapbase        = 0xa4000150,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 56, 56, 56, 56 },
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xa4000150,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 56, 56, 56, 56 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
        },
+};
 #endif
 #if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
     defined(CONFIG_CPU_SUBTYPE_SH7709)
-       {
-               .mapbase        = 0xa4000140,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_IRDA,
-               .irqs           = { 52, 52, 52, 52 },
-       },
-#endif
-       {
-               .flags = 0,
-       }
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xa4000140,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_IRDA,
+       .irqs           = { 52, 52, 52, 52 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif2_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 2,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif2_platform_data,
        },
 };
+#endif
 
 static struct sh_timer_config tmu0_platform_data = {
        .name = "TMU0",
@@ -238,10 +249,19 @@ static struct platform_device tmu2_device = {
 };
 
 static struct platform_device *sh770x_devices[] __initdata = {
+       &scif0_device,
+#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
+    defined(CONFIG_CPU_SUBTYPE_SH7707) || \
+    defined(CONFIG_CPU_SUBTYPE_SH7709)
+       &scif1_device,
+#endif
+#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
+    defined(CONFIG_CPU_SUBTYPE_SH7709)
+       &scif2_device,
+#endif
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
-       &sci_device,
        &rtc_device,
 };
 
@@ -253,6 +273,16 @@ static int __init sh770x_devices_setup(void)
 arch_initcall(sh770x_devices_setup);
 
 static struct platform_device *sh770x_early_devices[] __initdata = {
+       &scif0_device,
+#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
+    defined(CONFIG_CPU_SUBTYPE_SH7707) || \
+    defined(CONFIG_CPU_SUBTYPE_SH7709)
+       &scif1_device,
+#endif
+#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
+    defined(CONFIG_CPU_SUBTYPE_SH7709)
+       &scif2_device,
+#endif
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index 717e90ae1097a00efb701ba958013c844f6a55a4..0845a3ad006d9aa3dddc787e3b090681b62082eb 100644 (file)
@@ -96,28 +96,33 @@ static struct platform_device rtc_device = {
        },
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xa4400000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 52, 52, 52, 52 },
-       }, {
-               .mapbase        = 0xa4410000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 56, 56, 56, 56 },
-       }, {
-
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xa4400000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 52, 52, 52, 52 },
+};
+
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xa4410000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 56, 56, 56, 56 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif1_platform_data,
        },
 };
 
@@ -214,10 +219,11 @@ static struct platform_device tmu2_device = {
 };
 
 static struct platform_device *sh7710_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
-       &sci_device,
        &rtc_device,
 };
 
@@ -229,6 +235,8 @@ static int __init sh7710_devices_setup(void)
 arch_initcall(sh7710_devices_setup);
 
 static struct platform_device *sh7710_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index 74d8baaf8e9675c2f740a45e30b2cffcbd66ffc6..a718a62310912dcc70723d63dcfb46e90fe5be9c 100644 (file)
@@ -48,28 +48,33 @@ static struct platform_device rtc_device = {
        },
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xa4430000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 80, 80, 80, 80 },
-       }, {
-               .mapbase        = 0xa4438000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 81, 81, 81, 81 },
-       }, {
-
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xa4430000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 80, 80, 80, 80 },
+};
+
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xa4438000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 81, 81, 81, 81 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif1_platform_data,
        },
 };
 
@@ -369,6 +374,8 @@ static struct platform_device tmu2_device = {
 };
 
 static struct platform_device *sh7720_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &cmt0_device,
        &cmt1_device,
        &cmt2_device,
@@ -378,7 +385,6 @@ static struct platform_device *sh7720_devices[] __initdata = {
        &tmu1_device,
        &tmu2_device,
        &rtc_device,
-       &sci_device,
        &usb_ohci_device,
        &usbf_device,
 };
@@ -391,6 +397,8 @@ static int __init sh7720_devices_setup(void)
 arch_initcall(sh7720_devices_setup);
 
 static struct platform_device *sh7720_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &cmt0_device,
        &cmt1_device,
        &cmt2_device,
index de4827df19aacc41dcb589128c6d6e62f7a147e6..4b733715cdb555458a43d89a5b1b82c528f8b042 100644 (file)
 #include <linux/sh_timer.h>
 #include <linux/io.h>
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffe80000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 40, 41, 43, 42 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe80000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 40, 41, 43, 42 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif0_platform_data,
        },
 };
 
@@ -127,7 +123,7 @@ static struct platform_device tmu2_device = {
 };
 
 static struct platform_device *sh4202_devices[] __initdata = {
-       &sci_device,
+       &scif0_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
@@ -141,6 +137,7 @@ static int __init sh4202_devices_setup(void)
 arch_initcall(sh4202_devices_setup);
 
 static struct platform_device *sh4202_early_devices[] __initdata = {
+       &scif0_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index 1b8b122e8f3dd46f5898ba0710432f83c5578b2e..b2a9df1af64c187e3c3bb8b26d91bf9bbfc503e8 100644 (file)
@@ -35,29 +35,33 @@ static struct platform_device rtc_device = {
        .resource       = rtc_resources,
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-#ifndef CONFIG_SH_RTS7751R2D
-               .mapbase        = 0xffe00000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCI,
-               .irqs           = { 23, 23, 23, 0 },
-       }, {
-#endif
-               .mapbase        = 0xffe80000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 40, 40, 40, 40 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe00000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCI,
+       .irqs           = { 23, 23, 23, 0 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffe80000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 40, 40, 40, 40 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif1_platform_data,
        },
 };
 
@@ -221,8 +225,9 @@ static struct platform_device tmu4_device = {
 #endif
 
 static struct platform_device *sh7750_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &rtc_device,
-       &sci_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
@@ -242,6 +247,8 @@ static int __init sh7750_devices_setup(void)
 arch_initcall(sh7750_devices_setup);
 
 static struct platform_device *sh7750_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index 7fbb7be9284ca86950ead92da5ca337f0c0e7b99..5b74cc0b43daaa69a8962b10f9c1fe3f66109f2a 100644 (file)
@@ -126,37 +126,63 @@ static struct intc_vect vectors_irq[] __initdata = {
 static DECLARE_INTC_DESC(intc_desc_irq, "sh7760-irq", vectors_irq, groups,
                         mask_registers, prio_registers, NULL);
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xfe600000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 52, 53, 55, 54 },
-       }, {
-               .mapbase        = 0xfe610000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 72, 73, 75, 74 },
-       }, {
-               .mapbase        = 0xfe620000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 76, 77, 79, 78 },
-       }, {
-               .mapbase        = 0xfe480000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCI,
-               .irqs           = { 80, 81, 82, 0 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xfe600000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 52, 53, 55, 54 },
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xfe610000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 72, 73, 75, 74 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xfe620000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 76, 77, 79, 78 },
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xfe480000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCI,
+       .irqs           = { 80, 81, 82, 0 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif3_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 3,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif3_platform_data,
        },
 };
 
@@ -254,7 +280,10 @@ static struct platform_device tmu2_device = {
 
 
 static struct platform_device *sh7760_devices[] __initdata = {
-       &sci_device,
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
@@ -268,6 +297,10 @@ static int __init sh7760_devices_setup(void)
 arch_initcall(sh7760_devices_setup);
 
 static struct platform_device *sh7760_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index ac4d5672ec1a25ff053191fa7c60bd46dfaf5da5..45eb1bfd42c9889fb6e4d40b740aeea979a96bcd 100644 (file)
 #include <linux/sh_timer.h>
 #include <asm/clock.h>
 
+/* Serial */
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe00000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 80, 80, 80, 80 },
+       .clk            = "scif0",
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffe10000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 81, 81, 81, 81 },
+       .clk            = "scif1",
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xffe20000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 82, 82, 82, 82 },
+       .clk            = "scif2",
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xffe30000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 83, 83, 83, 83 },
+       .clk            = "scif3",
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
+       .dev            = {
+               .platform_data  = &scif3_platform_data,
+       },
+};
+
 static struct resource iic0_resources[] = {
        [0] = {
                .name   = "IIC0",
@@ -265,52 +330,17 @@ static struct platform_device tmu2_device = {
        .num_resources  = ARRAY_SIZE(tmu2_resources),
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffe00000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 80, 80, 80, 80 },
-               .clk            = "scif0",
-       }, {
-               .mapbase        = 0xffe10000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 81, 81, 81, 81 },
-               .clk            = "scif1",
-       }, {
-               .mapbase        = 0xffe20000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 82, 82, 82, 82 },
-               .clk            = "scif2",
-       }, {
-               .mapbase        = 0xffe30000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 83, 83, 83, 83 },
-               .clk            = "scif3",
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
-       .name           = "sh-sci",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = sci_platform_data,
-       },
-};
-
 static struct platform_device *sh7343_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
        &iic0_device,
        &iic1_device,
-       &sci_device,
        &vpu_device,
        &veu_device,
        &jpu_device,
@@ -328,6 +358,10 @@ static int __init sh7343_devices_setup(void)
 arch_initcall(sh7343_devices_setup);
 
 static struct platform_device *sh7343_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
index 4a9010bf4fd389e2aba11a392a9281dc3102ce22..c494c193e3b6bfce2dda56608fafabba5a4641d1 100644 (file)
 #include <linux/usb/r8a66597.h>
 #include <asm/clock.h>
 
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe00000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 80, 80, 80, 80 },
+       .clk            = "scif0",
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
 static struct resource iic_resources[] = {
        [0] = {
                .name   = "IIC",
@@ -276,33 +292,13 @@ static struct platform_device tmu2_device = {
        .num_resources  = ARRAY_SIZE(tmu2_resources),
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffe00000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 80, 80, 80, 80 },
-               .clk            = "scif0",
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
-       .name           = "sh-sci",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = sci_platform_data,
-       },
-};
-
 static struct platform_device *sh7366_devices[] __initdata = {
+       &scif0_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
        &iic_device,
-       &sci_device,
        &usb_host_device,
        &vpu_device,
        &veu0_device,
@@ -321,6 +317,7 @@ static int __init sh7366_devices_setup(void)
 arch_initcall(sh7366_devices_setup);
 
 static struct platform_device *sh7366_early_devices[] __initdata = {
+       &scif0_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
index 5491b094cf05eff5f9b506cffb47364217a149f1..b5335b5e309cd23b53e5b35d155bfcd71e6e630e 100644 (file)
 #include <asm/dma-sh.h>
 #include <cpu/sh7722.h>
 
+/* Serial */
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe00000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 80, 80, 80, 80 },
+       .clk            = "scif0",
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffe10000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 81, 81, 81, 81 },
+       .clk            = "scif1",
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xffe20000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 82, 82, 82, 82 },
+       .clk            = "scif2",
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
 static struct resource rtc_resources[] = {
        [0] = {
                .start  = 0xa465fec0,
@@ -339,41 +388,6 @@ static struct platform_device tmu2_device = {
        },
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffe00000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 80, 80, 80, 80 },
-               .clk            = "scif0",
-       },
-       {
-               .mapbase        = 0xffe10000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 81, 81, 81, 81 },
-               .clk            = "scif1",
-       },
-       {
-               .mapbase        = 0xffe20000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 82, 82, 82, 82 },
-               .clk            = "scif2",
-       },
-       {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
-       .name           = "sh-sci",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = sci_platform_data,
-       },
-};
-
 static struct sh_dmae_pdata dma_platform_data = {
        .mode = 0,
 };
@@ -387,6 +401,9 @@ static struct platform_device dma_device = {
 };
 
 static struct platform_device *sh7722_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
@@ -394,7 +411,6 @@ static struct platform_device *sh7722_devices[] __initdata = {
        &rtc_device,
        &usbf_device,
        &iic_device,
-       &sci_device,
        &vpu_device,
        &veu_device,
        &jpu_device,
@@ -413,6 +429,9 @@ static int __init sh7722_devices_setup(void)
 arch_initcall(sh7722_devices_setup);
 
 static struct platform_device *sh7722_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
index 4caa5a7ca86edf0ead7964255a2361955e507c1f..772b9265d0e475f445b30ef6a85940dd45ee2d31 100644 (file)
 #include <asm/mmzone.h>
 #include <cpu/sh7723.h>
 
+/* Serial */
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe00000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 80, 80, 80, 80 },
+       .clk            = "scif0",
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffe10000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 81, 81, 81, 81 },
+       .clk            = "scif1",
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xffe20000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 82, 82, 82, 82 },
+       .clk            = "scif2",
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xa4e30000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIFA,
+       .irqs           = { 56, 56, 56, 56 },
+       .clk            = "scif3",
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
+       .dev            = {
+               .platform_data  = &scif3_platform_data,
+       },
+};
+
+static struct plat_sci_port scif4_platform_data = {
+       .mapbase        = 0xa4e40000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIFA,
+       .irqs           = { 88, 88, 88, 88 },
+       .clk            = "scif4",
+};
+
+static struct platform_device scif4_device = {
+       .name           = "sh-sci",
+       .id             = 4,
+       .dev            = {
+               .platform_data  = &scif4_platform_data,
+       },
+};
+
+static struct plat_sci_port scif5_platform_data = {
+       .mapbase        = 0xa4e50000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIFA,
+       .irqs           = { 109, 109, 109, 109 },
+       .clk            = "scif5",
+};
+
+static struct platform_device scif5_device = {
+       .name           = "sh-sci",
+       .id             = 5,
+       .dev            = {
+               .platform_data  = &scif5_platform_data,
+       },
+};
+
 static struct uio_info vpu_platform_data = {
        .name = "VPU5",
        .version = "0",
@@ -348,56 +445,6 @@ static struct platform_device tmu5_device = {
        },
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffe00000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 80, 80, 80, 80 },
-               .clk            = "scif0",
-       },{
-               .mapbase        = 0xffe10000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 81, 81, 81, 81 },
-               .clk            = "scif1",
-       },{
-               .mapbase        = 0xffe20000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 82, 82, 82, 82 },
-               .clk            = "scif2",
-       },{
-               .mapbase        = 0xa4e30000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIFA,
-               .irqs           = { 56, 56, 56, 56 },
-               .clk            = "scif3",
-       },{
-               .mapbase        = 0xa4e40000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIFA,
-               .irqs           = { 88, 88, 88, 88 },
-               .clk            = "scif4",
-       },{
-               .mapbase        = 0xa4e50000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIFA,
-               .irqs           = { 109, 109, 109, 109 },
-               .clk            = "scif5",
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
-       .name           = "sh-sci",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = sci_platform_data,
-       },
-};
-
 static struct resource rtc_resources[] = {
        [0] = {
                .start  = 0xa465fec0,
@@ -488,6 +535,12 @@ static struct platform_device iic_device = {
 };
 
 static struct platform_device *sh7723_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
@@ -495,7 +548,6 @@ static struct platform_device *sh7723_devices[] __initdata = {
        &tmu3_device,
        &tmu4_device,
        &tmu5_device,
-       &sci_device,
        &rtc_device,
        &iic_device,
        &sh7723_usb_host_device,
@@ -516,6 +568,12 @@ static int __init sh7723_devices_setup(void)
 arch_initcall(sh7723_devices_setup);
 
 static struct platform_device *sh7723_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
index 845e89c936e79d6c9da2d31f67de0907e10c2db3..d32f96c1cc15f9ed7d911bfd4e28474f731661d7 100644 (file)
 #include <linux/notifier.h>
 #include <asm/suspend.h>
 #include <asm/clock.h>
+#include <asm/dma-sh.h>
 #include <asm/mmzone.h>
 #include <cpu/sh7724.h>
 
+/* DMA */
+static struct sh_dmae_pdata dma_platform_data = {
+       .mode = SHDMA_DMAOR1,
+};
+
+static struct platform_device dma_device = {
+       .name   = "sh-dma-engine",
+       .id             = -1,
+       .dev    = {
+               .platform_data  = &dma_platform_data,
+       },
+};
+
 /* Serial */
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffe00000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 80, 80, 80, 80 },
-               .clk            = "scif0",
-       }, {
-               .mapbase        = 0xffe10000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 81, 81, 81, 81 },
-               .clk            = "scif1",
-       }, {
-               .mapbase        = 0xffe20000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 82, 82, 82, 82 },
-               .clk            = "scif2",
-       }, {
-               .mapbase        = 0xa4e30000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIFA,
-               .irqs           = { 56, 56, 56, 56 },
-               .clk            = "scif3",
-       }, {
-               .mapbase        = 0xa4e40000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIFA,
-               .irqs           = { 88, 88, 88, 88 },
-               .clk            = "scif4",
-       }, {
-               .mapbase        = 0xa4e50000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIFA,
-               .irqs           = { 109, 109, 109, 109 },
-               .clk            = "scif5",
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe00000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 80, 80, 80, 80 },
+       .clk            = "scif0",
+};
+
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffe10000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 81, 81, 81, 81 },
+       .clk            = "scif1",
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xffe20000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 82, 82, 82, 82 },
+       .clk            = "scif2",
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xa4e30000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIFA,
+       .irqs           = { 56, 56, 56, 56 },
+       .clk            = "scif3",
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
+       .dev            = {
+               .platform_data  = &scif3_platform_data,
+       },
+};
+
+static struct plat_sci_port scif4_platform_data = {
+       .mapbase        = 0xa4e40000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIFA,
+       .irqs           = { 88, 88, 88, 88 },
+       .clk            = "scif4",
+};
+
+static struct platform_device scif4_device = {
+       .name           = "sh-sci",
+       .id             = 4,
+       .dev            = {
+               .platform_data  = &scif4_platform_data,
+       },
+};
+
+static struct plat_sci_port scif5_platform_data = {
+       .mapbase        = 0xa4e50000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIFA,
+       .irqs           = { 109, 109, 109, 109 },
+       .clk            = "scif5",
+};
+
+static struct platform_device scif5_device = {
+       .name           = "sh-sci",
+       .id             = 5,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif5_platform_data,
        },
 };
 
@@ -590,6 +650,12 @@ static struct platform_device spu1_device = {
 };
 
 static struct platform_device *sh7724_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
@@ -597,7 +663,7 @@ static struct platform_device *sh7724_devices[] __initdata = {
        &tmu3_device,
        &tmu4_device,
        &tmu5_device,
-       &sci_device,
+       &dma_device,
        &rtc_device,
        &iic0_device,
        &iic1_device,
@@ -624,6 +690,12 @@ static int __init sh7724_devices_setup(void)
 arch_initcall(sh7724_devices_setup);
 
 static struct platform_device *sh7724_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
index c470e15f2e03d05457c4f03fccb52bb0b019332e..37e32efbbaa77bad26d11ce8c62a6693c4a339f2 100644 (file)
 #include <linux/mm.h>
 #include <linux/sh_timer.h>
 
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xfe4b0000,           /* SCIF2 */
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 40, 40, 40, 40 },
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xfe4c0000,           /* SCIF3 */
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 76, 76, 76, 76 },
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
+       .dev            = {
+               .platform_data  = &scif3_platform_data,
+       },
+};
+
+static struct plat_sci_port scif4_platform_data = {
+       .mapbase        = 0xfe4d0000,           /* SCIF4 */
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 104, 104, 104, 104 },
+};
+
+static struct platform_device scif4_device = {
+       .name           = "sh-sci",
+       .id             = 4,
+       .dev            = {
+               .platform_data  = &scif4_platform_data,
+       },
+};
+
 static struct sh_timer_config tmu0_platform_data = {
        .name = "TMU0",
        .channel_offset = 0x04,
@@ -79,39 +124,12 @@ static struct platform_device tmu1_device = {
        .num_resources  = ARRAY_SIZE(tmu1_resources),
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xfe4b0000,           /* SCIF2 */
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 40, 40, 40, 40 },
-       }, {
-               .mapbase        = 0xfe4c0000,           /* SCIF3 */
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 76, 76, 76, 76 },
-       }, {
-               .mapbase        = 0xfe4d0000,           /* SCIF4 */
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 104, 104, 104, 104 },
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
-       .name           = "sh-sci",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = sci_platform_data,
-       },
-};
-
 static struct platform_device *sh7757_devices[] __initdata = {
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
        &tmu0_device,
        &tmu1_device,
-       &sci_device,
 };
 
 static int __init sh7757_devices_setup(void)
@@ -121,6 +139,20 @@ static int __init sh7757_devices_setup(void)
 }
 arch_initcall(sh7757_devices_setup);
 
+static struct platform_device *sh7757_early_devices[] __initdata = {
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &tmu0_device,
+       &tmu1_device,
+};
+
+void __init plat_early_device_setup(void)
+{
+       early_platform_add_devices(sh7757_early_devices,
+                                  ARRAY_SIZE(sh7757_early_devices));
+}
+
 enum {
        UNUSED = 0,
 
index 4659fff6b842057defff64a65b506714170d3c99..6aba26fec4163c4d6274344218ff527f638f34cb 100644 (file)
 #include <linux/io.h>
 #include <linux/serial_sci.h>
 
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe00000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 40, 40, 40, 40 },
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffe08000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 76, 76, 76, 76 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xffe10000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 104, 104, 104, 104 },
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
 static struct resource rtc_resources[] = {
        [0] = {
                .start  = 0xffe80000,
@@ -36,35 +81,6 @@ static struct platform_device rtc_device = {
        .resource       = rtc_resources,
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffe00000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 40, 40, 40, 40 },
-       }, {
-               .mapbase        = 0xffe08000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 76, 76, 76, 76 },
-       }, {
-               .mapbase        = 0xffe10000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 104, 104, 104, 104 },
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
-       .name           = "sh-sci",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = sci_platform_data,
-       },
-};
-
 static struct resource usb_ohci_resources[] = {
        [0] = {
                .start  = 0xffec8000,
@@ -297,6 +313,9 @@ static struct platform_device tmu5_device = {
 };
 
 static struct platform_device *sh7763_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
@@ -304,7 +323,6 @@ static struct platform_device *sh7763_devices[] __initdata = {
        &tmu4_device,
        &tmu5_device,
        &rtc_device,
-       &sci_device,
        &usb_ohci_device,
        &usbf_device,
 };
@@ -317,6 +335,9 @@ static int __init sh7763_devices_setup(void)
 arch_initcall(sh7763_devices_setup);
 
 static struct platform_device *sh7763_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index eead08d89d32548932e32e6840702e068a538a89..c1643bc9590d8a46581b9569bc2adf4516044ec6 100644 (file)
 #include <linux/sh_timer.h>
 #include <linux/io.h>
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xff923000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 61, 61, 61, 61 },
-       }, {
-               .mapbase        = 0xff924000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 62, 62, 62, 62 },
-       }, {
-               .mapbase        = 0xff925000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 63, 63, 63, 63 },
-       }, {
-               .mapbase        = 0xff926000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 64, 64, 64, 64 },
-       }, {
-               .mapbase        = 0xff927000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 65, 65, 65, 65 },
-       }, {
-               .mapbase        = 0xff928000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 66, 66, 66, 66 },
-       }, {
-               .mapbase        = 0xff929000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 67, 67, 67, 67 },
-       }, {
-               .mapbase        = 0xff92a000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 68, 68, 68, 68 },
-       }, {
-               .mapbase        = 0xff92b000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 69, 69, 69, 69 },
-       }, {
-               .mapbase        = 0xff92c000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 70, 70, 70, 70 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xff923000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 61, 61, 61, 61 },
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xff924000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 62, 62, 62, 62 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xff925000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 63, 63, 63, 63 },
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xff926000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 64, 64, 64, 64 },
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
+       .dev            = {
+               .platform_data  = &scif3_platform_data,
+       },
+};
+
+static struct plat_sci_port scif4_platform_data = {
+       .mapbase        = 0xff927000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 65, 65, 65, 65 },
+};
+
+static struct platform_device scif4_device = {
+       .name           = "sh-sci",
+       .id             = 4,
+       .dev            = {
+               .platform_data  = &scif4_platform_data,
+       },
+};
+
+static struct plat_sci_port scif5_platform_data = {
+       .mapbase        = 0xff928000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 66, 66, 66, 66 },
+};
+
+static struct platform_device scif5_device = {
+       .name           = "sh-sci",
+       .id             = 5,
+       .dev            = {
+               .platform_data  = &scif5_platform_data,
+       },
+};
+
+static struct plat_sci_port scif6_platform_data = {
+       .mapbase        = 0xff929000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 67, 67, 67, 67 },
+};
+
+static struct platform_device scif6_device = {
+       .name           = "sh-sci",
+       .id             = 6,
+       .dev            = {
+               .platform_data  = &scif6_platform_data,
+       },
+};
+
+static struct plat_sci_port scif7_platform_data = {
+       .mapbase        = 0xff92a000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 68, 68, 68, 68 },
+};
+
+static struct platform_device scif7_device = {
+       .name           = "sh-sci",
+       .id             = 7,
+       .dev            = {
+               .platform_data  = &scif7_platform_data,
+       },
+};
+
+static struct plat_sci_port scif8_platform_data = {
+       .mapbase        = 0xff92b000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 69, 69, 69, 69 },
+};
+
+static struct platform_device scif8_device = {
+       .name           = "sh-sci",
+       .id             = 8,
+       .dev            = {
+               .platform_data  = &scif8_platform_data,
+       },
+};
+
+static struct plat_sci_port scif9_platform_data = {
+       .mapbase        = 0xff92c000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 70, 70, 70, 70 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif9_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 9,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif9_platform_data,
        },
 };
 
@@ -351,6 +437,16 @@ static struct platform_device tmu8_device = {
 };
 
 static struct platform_device *sh7770_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
+       &scif6_device,
+       &scif7_device,
+       &scif8_device,
+       &scif9_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
@@ -360,7 +456,6 @@ static struct platform_device *sh7770_devices[] __initdata = {
        &tmu6_device,
        &tmu7_device,
        &tmu8_device,
-       &sci_device,
 };
 
 static int __init sh7770_devices_setup(void)
@@ -371,6 +466,16 @@ static int __init sh7770_devices_setup(void)
 arch_initcall(sh7770_devices_setup);
 
 static struct platform_device *sh7770_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
+       &scif6_device,
+       &scif7_device,
+       &scif8_device,
+       &scif9_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index 12ff56f19c5c2f9643140aa4d20838adac5e8844..c310558490d590a52ffa5e1cbdb7055ca3d09fae 100644 (file)
 #include <linux/sh_timer.h>
 #include <asm/dma-sh.h>
 
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffe00000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 40, 40, 40, 40 },
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffe10000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 76, 76, 76, 76 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
 static struct sh_timer_config tmu0_platform_data = {
        .name = "TMU0",
        .channel_offset = 0x04,
@@ -217,30 +247,6 @@ static struct platform_device rtc_device = {
        .resource       = rtc_resources,
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffe00000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 40, 40, 40, 40 },
-       }, {
-               .mapbase        = 0xffe10000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 76, 76, 76, 76 },
-       }, {
-               .flags = 0,
-       }
-};
-
-static struct platform_device sci_device = {
-       .name           = "sh-sci",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = sci_platform_data,
-       },
-};
-
 static struct sh_dmae_pdata dma_platform_data = {
        .mode = (SHDMA_MIX_IRQ | SHDMA_DMAOR1),
 };
@@ -254,6 +260,8 @@ static struct platform_device dma_device = {
 };
 
 static struct platform_device *sh7780_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
@@ -261,7 +269,6 @@ static struct platform_device *sh7780_devices[] __initdata = {
        &tmu4_device,
        &tmu5_device,
        &rtc_device,
-       &sci_device,
        &dma_device,
 };
 
@@ -271,8 +278,9 @@ static int __init sh7780_devices_setup(void)
                                    ARRAY_SIZE(sh7780_devices));
 }
 arch_initcall(sh7780_devices_setup);
-
 static struct platform_device *sh7780_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index 7f6c718b6c36e4de8722cf41b571f3c0700bd703..f685b9b219997afec1021bb1b03055c5e84a2ecb 100644 (file)
 #include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/sh_timer.h>
+#include <asm/dma-sh.h>
 #include <asm/mmzone.h>
 
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffea0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 40, 40, 40, 40 },
+       .clk            = "scif_fck",
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffeb0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 44, 44, 44, 44 },
+       .clk            = "scif_fck",
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xffec0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 60, 60, 60, 60 },
+       .clk            = "scif_fck",
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xffed0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 61, 61, 61, 61 },
+       .clk            = "scif_fck",
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
+       .dev            = {
+               .platform_data  = &scif3_platform_data,
+       },
+};
+
+static struct plat_sci_port scif4_platform_data = {
+       .mapbase        = 0xffee0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 62, 62, 62, 62 },
+       .clk            = "scif_fck",
+};
+
+static struct platform_device scif4_device = {
+       .name           = "sh-sci",
+       .id             = 4,
+       .dev            = {
+               .platform_data  = &scif4_platform_data,
+       },
+};
+
+static struct plat_sci_port scif5_platform_data = {
+       .mapbase        = 0xffef0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 63, 63, 63, 63 },
+       .clk            = "scif_fck",
+};
+
+static struct platform_device scif5_device = {
+       .name           = "sh-sci",
+       .id             = 5,
+       .dev            = {
+               .platform_data  = &scif5_platform_data,
+       },
+};
+
 static struct sh_timer_config tmu0_platform_data = {
        .name = "TMU0",
        .channel_offset = 0x04,
@@ -198,64 +295,32 @@ static struct platform_device tmu5_device = {
        .num_resources  = ARRAY_SIZE(tmu5_resources),
 };
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffea0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 40, 40, 40, 40 },
-               .clk            = "scif_fck",
-       }, {
-               .mapbase        = 0xffeb0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 44, 44, 44, 44 },
-               .clk            = "scif_fck",
-       }, {
-               .mapbase        = 0xffec0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 60, 60, 60, 60 },
-               .clk            = "scif_fck",
-       }, {
-               .mapbase        = 0xffed0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 61, 61, 61, 61 },
-               .clk            = "scif_fck",
-       }, {
-               .mapbase        = 0xffee0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 62, 62, 62, 62 },
-               .clk            = "scif_fck",
-       }, {
-               .mapbase        = 0xffef0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 63, 63, 63, 63 },
-               .clk            = "scif_fck",
-       }, {
-               .flags = 0,
-       }
+static struct sh_dmae_pdata dma_platform_data = {
+       .mode = (SHDMA_MIX_IRQ | SHDMA_DMAOR1),
 };
 
-static struct platform_device sci_device = {
-       .name           = "sh-sci",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = sci_platform_data,
+static struct platform_device dma_device = {
+       .name           = "sh-dma-engine",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &dma_platform_data,
        },
 };
 
 static struct platform_device *sh7785_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
        &tmu3_device,
        &tmu4_device,
        &tmu5_device,
-       &sci_device,
+       &dma_device,
 };
 
 static int __init sh7785_devices_setup(void)
@@ -266,6 +331,12 @@ static int __init sh7785_devices_setup(void)
 arch_initcall(sh7785_devices_setup);
 
 static struct platform_device *sh7785_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
index 0104a8ec53691a4ad26c6f80476d4f8c2a9ff361..71673487ace028c9889c3bd9bcaf0e5b203e8ed9 100644 (file)
 #include <linux/sh_timer.h>
 #include <asm/mmzone.h>
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffea0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 40, 41, 43, 42 },
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffea0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 40, 41, 43, 42 },
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
        },
-       /*
-        * The rest of these all have multiplexed IRQs
-        */
-       {
-               .mapbase        = 0xffeb0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 44, 44, 44, 44 },
-       }, {
-               .mapbase        = 0xffec0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 50, 50, 50, 50 },
-       }, {
-               .mapbase        = 0xffed0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 51, 51, 51, 51 },
-       }, {
-               .mapbase        = 0xffee0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 52, 52, 52, 52 },
-       }, {
-               .mapbase        = 0xffef0000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 53, 53, 53, 53 },
-       }, {
-               .flags = 0,
-       }
 };
 
-static struct platform_device sci_device = {
+/*
+ * The rest of these all have multiplexed IRQs
+ */
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffeb0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 44, 44, 44, 44 },
+};
+
+static struct platform_device scif1_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xffec0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 50, 50, 50, 50 },
+};
+
+static struct platform_device scif2_device = {
+       .name           = "sh-sci",
+       .id             = 2,
+       .dev            = {
+               .platform_data  = &scif2_platform_data,
+       },
+};
+
+static struct plat_sci_port scif3_platform_data = {
+       .mapbase        = 0xffed0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 51, 51, 51, 51 },
+};
+
+static struct platform_device scif3_device = {
+       .name           = "sh-sci",
+       .id             = 3,
+       .dev            = {
+               .platform_data  = &scif3_platform_data,
+       },
+};
+
+static struct plat_sci_port scif4_platform_data = {
+       .mapbase        = 0xffee0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 52, 52, 52, 52 },
+};
+
+static struct platform_device scif4_device = {
+       .name           = "sh-sci",
+       .id             = 4,
+       .dev            = {
+               .platform_data  = &scif4_platform_data,
+       },
+};
+
+static struct plat_sci_port scif5_platform_data = {
+       .mapbase        = 0xffef0000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 53, 53, 53, 53 },
+};
+
+static struct platform_device scif5_device = {
+       .name           = "sh-sci",
+       .id             = 5,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif5_platform_data,
        },
 };
 
@@ -459,6 +504,12 @@ static struct platform_device usb_ohci_device = {
 };
 
 static struct platform_device *sh7786_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
+       &scif3_device,
+       &scif4_device,
+       &scif5_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
@@ -474,7 +525,6 @@ static struct platform_device *sh7786_early_devices[] __initdata = {
 };
 
 static struct platform_device *sh7786_devices[] __initdata = {
-       &sci_device,
        &usb_ohci_device,
 };
 
index c7ba9166e18a3b6f27a9e1156a4c206b49a0041d..780ba17a5599328d8201ecff188b7567489d20d3 100644 (file)
  * silicon in the first place, we just refuse to deal with the port at
  * all rather than adding infrastructure to hack around it.
  */
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = 0xffc30000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 40, 41, 43, 42 },
-       }, {
-               .mapbase        = 0xffc40000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 44, 45, 47, 46 },
-       }, {
-               .mapbase        = 0xffc60000,
-               .flags          = UPF_BOOT_AUTOCONF,
-               .type           = PORT_SCIF,
-               .irqs           = { 52, 53, 55, 54 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = 0xffc30000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 40, 41, 43, 42 },
+};
+
+static struct platform_device scif0_device = {
+       .name           = "sh-sci",
+       .id             = 0,
+       .dev            = {
+               .platform_data  = &scif0_platform_data,
+       },
+};
+
+static struct plat_sci_port scif1_platform_data = {
+       .mapbase        = 0xffc40000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 44, 45, 47, 46 },
+};
+
+static struct platform_device scif1_device = {
+       .name           = "sh-sci",
+       .id             = 1,
+       .dev            = {
+               .platform_data  = &scif1_platform_data,
+       },
+};
+
+static struct plat_sci_port scif2_platform_data = {
+       .mapbase        = 0xffc60000,
+       .flags          = UPF_BOOT_AUTOCONF,
+       .type           = PORT_SCIF,
+       .irqs           = { 52, 53, 55, 54 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif2_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 2,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif2_platform_data,
        },
 };
 
@@ -236,6 +252,9 @@ static struct platform_device tmu5_device = {
 };
 
 static struct platform_device *shx3_early_devices[] __initdata = {
+       &scif0_device,
+       &scif1_device,
+       &scif2_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
@@ -244,21 +263,10 @@ static struct platform_device *shx3_early_devices[] __initdata = {
        &tmu5_device,
 };
 
-static struct platform_device *shx3_devices[] __initdata = {
-       &sci_device,
-};
-
 static int __init shx3_devices_setup(void)
 {
-       int ret;
-
-       ret = platform_add_devices(shx3_early_devices,
+       return platform_add_devices(shx3_early_devices,
                                   ARRAY_SIZE(shx3_early_devices));
-       if (unlikely(ret != 0))
-               return ret;
-
-       return platform_add_devices(shx3_devices,
-                                   ARRAY_SIZE(shx3_devices));
 }
 arch_initcall(shx3_devices_setup);
 
index dd4f51ffb50ea81f9af6f0931d27f050a55a1498..4648ccee6c4d2b5ebdf20fb58db5387022ebc2cc 100644 (file)
@@ -34,7 +34,7 @@ static union sh_fpu_union init_fpuregs = {
        }
 };
 
-void save_fpu(struct task_struct *tsk, struct pt_regs *regs)
+void save_fpu(struct task_struct *tsk)
 {
        asm volatile("fst.p     %0, (0*8), fp0\n\t"
                     "fst.p     %0, (1*8), fp2\n\t"
@@ -153,7 +153,7 @@ do_fpu_state_restore(unsigned long ex, struct pt_regs *regs)
        enable_fpu();
        if (last_task_used_math != NULL)
                /* Other processes fpu state, save away */
-               save_fpu(last_task_used_math, regs);
+               save_fpu(last_task_used_math);
 
         last_task_used_math = current;
         if (used_math()) {
index 6a0f82f700323ce02d06fe91f7eb766b48a9b349..e7a3c1e4b60492ba80c8f127d9e0067791cae0eb 100644 (file)
 #include <linux/sh_timer.h>
 #include <asm/addrspace.h>
 
-static struct plat_sci_port sci_platform_data[] = {
-       {
-               .mapbase        = PHYS_PERIPHERAL_BLOCK + 0x01030000,
-               .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
-               .type           = PORT_SCIF,
-               .irqs           = { 39, 40, 42, 0 },
-       }, {
-               .flags = 0,
-       }
+static struct plat_sci_port scif0_platform_data = {
+       .mapbase        = PHYS_PERIPHERAL_BLOCK + 0x01030000,
+       .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
+       .type           = PORT_SCIF,
+       .irqs           = { 39, 40, 42, 0 },
 };
 
-static struct platform_device sci_device = {
+static struct platform_device scif0_device = {
        .name           = "sh-sci",
-       .id             = -1,
+       .id             = 0,
        .dev            = {
-               .platform_data  = sci_platform_data,
+               .platform_data  = &scif0_platform_data,
        },
 };
 
@@ -164,13 +160,13 @@ static struct platform_device tmu2_device = {
 };
 
 static struct platform_device *sh5_early_devices[] __initdata = {
+       &scif0_device,
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
 };
 
 static struct platform_device *sh5_devices[] __initdata = {
-       &sci_device,
        &rtc_device,
 };
 
index 81a46145ffa5b01af702ff04863b19c128d3574b..f8bb50c6e0504e0d6041ff3321629d5ba9c26aeb 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/io.h>
 #include <linux/delay.h>
 
-#ifdef CONFIG_SH_STANDARD_BIOS
 #include <asm/sh_bios.h>
 
 /*
@@ -57,149 +56,8 @@ static struct console bios_console = {
        .flags          = CON_PRINTBUFFER,
        .index          = -1,
 };
-#endif
 
-#ifdef CONFIG_EARLY_SCIF_CONSOLE
-#include <linux/serial_core.h>
-#include "../../../drivers/serial/sh-sci.h"
-
-#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
-    defined(CONFIG_CPU_SUBTYPE_SH7721)
-#define EPK_SCSMR_VALUE 0x000
-#define EPK_SCBRR_VALUE 0x00C
-#define EPK_FIFO_SIZE 64
-#define EPK_FIFO_BITS (0x7f00 >> 8)
-#else
-#define EPK_FIFO_SIZE 16
-#define EPK_FIFO_BITS (0x1f00 >> 8)
-#endif
-
-static struct uart_port scif_port = {
-       .type           = PORT_SCIF,
-       .mapbase        = CONFIG_EARLY_SCIF_CONSOLE_PORT,
-       .membase        = (char __iomem *)CONFIG_EARLY_SCIF_CONSOLE_PORT,
-};
-
-static void scif_sercon_putc(int c)
-{
-       while (((sci_in(&scif_port, SCFDR) & EPK_FIFO_BITS) >= EPK_FIFO_SIZE))
-               ;
-
-       sci_in(&scif_port, SCxSR);
-       sci_out(&scif_port, SCxSR, 0xf3 & ~(0x20 | 0x40));
-       sci_out(&scif_port, SCxTDR, c);
-
-       while ((sci_in(&scif_port, SCxSR) & 0x40) == 0)
-               ;
-
-       if (c == '\n')
-               scif_sercon_putc('\r');
-}
-
-static void scif_sercon_write(struct console *con, const char *s,
-                             unsigned count)
-{
-       while (count-- > 0)
-               scif_sercon_putc(*s++);
-}
-
-static int __init scif_sercon_setup(struct console *con, char *options)
-{
-       con->cflag = CREAD | HUPCL | CLOCAL | B115200 | CS8;
-
-       return 0;
-}
-
-static struct console scif_console = {
-       .name           = "sercon",
-       .write          = scif_sercon_write,
-       .setup          = scif_sercon_setup,
-       .flags          = CON_PRINTBUFFER,
-       .index          = -1,
-};
-
-#if !defined(CONFIG_SH_STANDARD_BIOS)
-#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
-    defined(CONFIG_CPU_SUBTYPE_SH7721)
-static void scif_sercon_init(char *s)
-{
-       sci_out(&scif_port, SCSCR, 0x0000);     /* clear TE and RE */
-       sci_out(&scif_port, SCFCR, 0x4006);     /* reset */
-       sci_out(&scif_port, SCSCR, 0x0000);     /* select internal clock */
-       sci_out(&scif_port, SCSMR, EPK_SCSMR_VALUE);
-       sci_out(&scif_port, SCBRR, EPK_SCBRR_VALUE);
-
-       mdelay(1);      /* wait 1-bit time */
-
-       sci_out(&scif_port, SCFCR, 0x0030);     /* TTRG=b'11 */
-       sci_out(&scif_port, SCSCR, 0x0030);     /* TE, RE */
-}
-#elif defined(CONFIG_CPU_SH4) || defined(CONFIG_CPU_SH3)
-#define DEFAULT_BAUD 115200
-/*
- * Simple SCIF init, primarily aimed at SH7750 and other similar SH-4
- * devices that aren't using sh-ipl+g.
- */
-static void scif_sercon_init(char *s)
-{
-       struct uart_port *port = &scif_port;
-       unsigned baud = DEFAULT_BAUD;
-       unsigned int status;
-       char *e;
-
-       if (*s == ',')
-               ++s;
-
-       if (*s) {
-               /* ignore ioport/device name */
-               s += strcspn(s, ",");
-               if (*s == ',')
-                       s++;
-       }
-
-       if (*s) {
-               baud = simple_strtoul(s, &e, 0);
-               if (baud == 0 || s == e)
-                       baud = DEFAULT_BAUD;
-       }
-
-       do {
-               status = sci_in(port, SCxSR);
-       } while (!(status & SCxSR_TEND(port)));
-
-       sci_out(port, SCSCR, 0);         /* TE=0, RE=0 */
-       sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
-       sci_out(port, SCSMR, 0);
-
-       /* Set baud rate */
-       sci_out(port, SCBRR, (CONFIG_SH_PCLK_FREQ + 16 * baud) /
-               (32 * baud) - 1);
-       udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
-
-       sci_out(port, SCSPTR, 0);
-       sci_out(port, SCxSR, 0x60);
-       sci_out(port, SCLSR, 0);
-
-       sci_out(port, SCFCR, 0);
-       sci_out(port, SCSCR, 0x30);      /* TE=1, RE=1 */
-}
-#endif /* defined(CONFIG_CPU_SUBTYPE_SH7720) */
-#endif /* !defined(CONFIG_SH_STANDARD_BIOS) */
-#endif /* CONFIG_EARLY_SCIF_CONSOLE */
-
-/*
- * Setup a default console, if more than one is compiled in, rely on the
- * earlyprintk= parsing to give priority.
- */
-static struct console *early_console =
-#ifdef CONFIG_SH_STANDARD_BIOS
-       &bios_console
-#elif defined(CONFIG_EARLY_SCIF_CONSOLE)
-       &scif_console
-#else
-       NULL
-#endif
-       ;
+static struct console *early_console;
 
 static int __init setup_early_printk(char *buf)
 {
@@ -211,21 +69,8 @@ static int __init setup_early_printk(char *buf)
        if (strstr(buf, "keep"))
                keep_early = 1;
 
-#ifdef CONFIG_SH_STANDARD_BIOS
        if (!strncmp(buf, "bios", 4))
                early_console = &bios_console;
-#endif
-#if defined(CONFIG_EARLY_SCIF_CONSOLE)
-       if (!strncmp(buf, "serial", 6)) {
-               early_console = &scif_console;
-
-#if !defined(CONFIG_SH_STANDARD_BIOS)
-#if defined(CONFIG_CPU_SH4) || defined(CONFIG_CPU_SH3)
-               scif_sercon_init(buf + 6);
-#endif
-#endif
-       }
-#endif
 
        if (likely(early_console)) {
                if (keep_early)
index b6f41c109bebe2eb1ad6436d41fe859b605cdc82..a48cdedc73b5f934444b7169a6cae0f583a5f562 100644 (file)
@@ -401,82 +401,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
 
 #ifdef CONFIG_FTRACE_SYSCALLS
-
-extern unsigned long __start_syscalls_metadata[];
-extern unsigned long __stop_syscalls_metadata[];
 extern unsigned long *sys_call_table;
 
-static struct syscall_metadata **syscalls_metadata;
-
-static struct syscall_metadata *find_syscall_meta(unsigned long *syscall)
-{
-       struct syscall_metadata *start;
-       struct syscall_metadata *stop;
-       char str[KSYM_SYMBOL_LEN];
-
-
-       start = (struct syscall_metadata *)__start_syscalls_metadata;
-       stop = (struct syscall_metadata *)__stop_syscalls_metadata;
-       kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str);
-
-       for ( ; start < stop; start++) {
-               if (start->name && !strcmp(start->name, str))
-                       return start;
-       }
-
-       return NULL;
-}
-
-struct syscall_metadata *syscall_nr_to_meta(int nr)
-{
-       if (!syscalls_metadata || nr >= FTRACE_SYSCALL_MAX || nr < 0)
-               return NULL;
-
-       return syscalls_metadata[nr];
-}
-
-int syscall_name_to_nr(char *name)
-{
-       int i;
-
-       if (!syscalls_metadata)
-               return -1;
-       for (i = 0; i < NR_syscalls; i++)
-               if (syscalls_metadata[i])
-                       if (!strcmp(syscalls_metadata[i]->name, name))
-                               return i;
-       return -1;
-}
-
-void set_syscall_enter_id(int num, int id)
-{
-       syscalls_metadata[num]->enter_id = id;
-}
-
-void set_syscall_exit_id(int num, int id)
-{
-       syscalls_metadata[num]->exit_id = id;
-}
-
-static int __init arch_init_ftrace_syscalls(void)
+unsigned long __init arch_syscall_addr(int nr)
 {
-       int i;
-       struct syscall_metadata *meta;
-       unsigned long **psys_syscall_table = &sys_call_table;
-
-       syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) *
-                                       FTRACE_SYSCALL_MAX, GFP_KERNEL);
-       if (!syscalls_metadata) {
-               WARN_ON(1);
-               return -ENOMEM;
-       }
-
-       for (i = 0; i < FTRACE_SYSCALL_MAX; i++) {
-               meta = find_syscall_meta(psys_syscall_table[i]);
-               syscalls_metadata[i] = meta;
-       }
-
-       return 0;
+       return (unsigned long)sys_call_table[nr];
 }
-arch_initcall(arch_init_ftrace_syscalls);
 #endif /* CONFIG_FTRACE_SYSCALLS */
index aaff0037fcd7ad89269154f5ac70076bb8a97278..6b3d706deac10954b91bb1721639ce6e91044710 100644 (file)
@@ -62,6 +62,7 @@ void default_idle(void)
                clear_thread_flag(TIF_POLLING_NRFLAG);
                smp_mb__after_clear_bit();
 
+               set_bl_bit();
                if (!need_resched()) {
                        local_irq_enable();
                        cpu_sleep();
@@ -69,6 +70,7 @@ void default_idle(void)
                        local_irq_enable();
 
                set_thread_flag(TIF_POLLING_NRFLAG);
+               clear_bl_bit();
        } else
                poll_idle();
 }
index e1913f28f4189b17493c5492b6e3e0aeb223d15a..d2d41d046657a36330a6c30060d8da37208c600a 100644 (file)
@@ -76,7 +76,7 @@ int show_interrupts(struct seq_file *p, void *v)
        if (!desc)
                return 0;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        for_each_online_cpu(j)
                any_count |= kstat_irqs_cpu(i, j);
        action = desc->action;
@@ -97,7 +97,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
        seq_putc(p, '\n');
 out:
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        return 0;
 }
 #endif
index 359b8a2f4d2e6f72c013a4ddabf29a6cb3cca4d8..31f80c61b031ad5ada25630e17c71a543c9fc59a 100644 (file)
@@ -404,7 +404,7 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
        if (fpvalid) {
                if (current == last_task_used_math) {
                        enable_fpu();
-                       save_fpu(tsk, regs);
+                       save_fpu(tsk);
                        disable_fpu();
                        last_task_used_math = 0;
                        regs->sr |= SR_FD;
@@ -431,7 +431,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 #ifdef CONFIG_SH_FPU
        if(last_task_used_math == current) {
                enable_fpu();
-               save_fpu(current, regs);
+               save_fpu(current);
                disable_fpu();
                last_task_used_math = NULL;
                regs->sr |= SR_FD;
index 952da83903da353ed044702a65a9088214a93611..873ebdc4f98efcaed37132f524f78d35fb7c9d3a 100644 (file)
@@ -82,7 +82,7 @@ get_fpu_long(struct task_struct *task, unsigned long addr)
 
        if (last_task_used_math == task) {
                enable_fpu();
-               save_fpu(task, regs);
+               save_fpu(task);
                disable_fpu();
                last_task_used_math = 0;
                regs->sr |= SR_FD;
@@ -118,7 +118,7 @@ put_fpu_long(struct task_struct *task, unsigned long addr, unsigned long data)
                set_stopped_child_used_math(task);
        } else if (last_task_used_math == task) {
                enable_fpu();
-               save_fpu(task, regs);
+               save_fpu(task);
                disable_fpu();
                last_task_used_math = 0;
                regs->sr |= SR_FD;
index 5a947a2567e4c3e6c164578a97dd1d2ca02b2449..8b0e69792cf47faec445adc8f784d8debf4b2899 100644 (file)
@@ -423,6 +423,9 @@ void __init setup_arch(char **cmdline_p)
 
        plat_early_device_setup();
 
+       /* Let earlyprintk output early console messages */
+       early_platform_driver_probe("earlyprintk", 1, 1);
+
        sh_mv_setup();
 
        /*
index feb3dddd3192b55ba34692b27977bef484c66fbf..ce76dbdef2940fa8e920dcbc8f4bc265a0607b5f 100644 (file)
@@ -314,7 +314,7 @@ setup_sigcontext_fpu(struct pt_regs *regs, struct sigcontext __user *sc)
 
        if (current == last_task_used_math) {
                enable_fpu();
-               save_fpu(current, regs);
+               save_fpu(current);
                disable_fpu();
                last_task_used_math = NULL;
                regs->sr |= SR_FD;
index 19fd11dd9871aadf7c6667eb9d97f473a5e813dc..4bd5a1146956deafcc96afe26be07cbc5ab18b23 100644 (file)
@@ -353,3 +353,4 @@ ENTRY(sys_call_table)
        .long sys_pwritev
        .long sys_rt_tgsigqueueinfo     /* 335 */
        .long sys_perf_event_open
+       .long sys_recvmmsg
index 3da5a125d884cb9079170fb424aa5d5b3ce8adb4..86639beac3a2d1d7b32e44e4ded50e1e1329bfdb 100644 (file)
@@ -452,12 +452,18 @@ int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs,
        rm = regs->regs[index];
 
        /* shout about fixups */
-       if (!expected && printk_ratelimit())
-               printk(KERN_NOTICE "Fixing up unaligned %s access "
-                      "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
-                      user_mode(regs) ? "userspace" : "kernel",
-                      current->comm, task_pid_nr(current),
-                      (void *)regs->pc, instruction);
+       if (!expected) {
+               if (user_mode(regs) && (se_usermode & 1) && printk_ratelimit())
+                       pr_notice("Fixing up unaligned userspace access "
+                                 "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
+                                 current->comm, task_pid_nr(current),
+                                 (void *)regs->pc, instruction);
+               else if (se_kernmode_warn && printk_ratelimit())
+                       pr_notice("Fixing up unaligned kernel access "
+                                 "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
+                                 current->comm, task_pid_nr(current),
+                                 (void *)regs->pc, instruction);
+       }
 
        ret = -EFAULT;
        switch (instruction&0xF000) {
index 75c0cbe2eda0839785ad8b639a8eed9a0b52b41b..d86f5315a0c1422c54b888153a70927c32e5a6ca 100644 (file)
@@ -600,7 +600,7 @@ static int misaligned_fpu_load(struct pt_regs *regs,
                   indexed by register number. */
                if (last_task_used_math == current) {
                        enable_fpu();
-                       save_fpu(current, regs);
+                       save_fpu(current);
                        disable_fpu();
                        last_task_used_math = NULL;
                        regs->sr |= SR_FD;
@@ -673,7 +673,7 @@ static int misaligned_fpu_store(struct pt_regs *regs,
                   indexed by register number. */
                if (last_task_used_math == current) {
                        enable_fpu();
-                       save_fpu(current, regs);
+                       save_fpu(current);
                        disable_fpu();
                        last_task_used_math = NULL;
                        regs->sr |= SR_FD;
index f36a08bf3d5cd62ba42821e5b511346333206c54..560ddb6bc8a79dd6e480255bb0aefdc45d7ac7f7 100644 (file)
@@ -256,8 +256,7 @@ static void sh4_flush_cache_page(void *args)
                address = (unsigned long)vaddr;
        }
 
-       if (pages_do_alias(address, phys))
-               flush_cache_one(CACHE_OC_ADDRESS_ARRAY |
+       flush_cache_one(CACHE_OC_ADDRESS_ARRAY |
                        (address & shm_align_mask), phys);
 
        if (vma->vm_flags & VM_EXEC)
index e9415d3ea94a652ee9a59031e4aa0ce915324d7f..b8607fa7ae121a36b203a83e47617cdeed29fcad 100644 (file)
@@ -133,12 +133,8 @@ void __update_cache(struct vm_area_struct *vma,
        page = pfn_to_page(pfn);
        if (pfn_valid(pfn)) {
                int dirty = test_and_clear_bit(PG_dcache_dirty, &page->flags);
-               if (dirty) {
-                       unsigned long addr = (unsigned long)page_address(page);
-
-                       if (pages_do_alias(addr, address & PAGE_MASK))
-                               __flush_purge_region((void *)addr, PAGE_SIZE);
-               }
+               if (dirty)
+                       __flush_purge_region(page_address(page), PAGE_SIZE);
        }
 }
 
index a86eaa9d75a5a6e4d776820dbde9b6e5542de0e9..2141befb4f918c3ab98b020d8cd8e9598cccaefa 100644 (file)
  * have to convert them into an offset in a page-aligned mapping, but the
  * caller shouldn't need to know that small detail.
  */
-void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
-                       unsigned long flags)
+void __iomem *__ioremap_caller(unsigned long phys_addr, unsigned long size,
+                              unsigned long flags, void *caller)
 {
-       struct vm_struct * area;
+       struct vm_struct *area;
        unsigned long offset, last_addr, addr, orig_addr;
        pgprot_t pgprot;
 
@@ -67,7 +67,7 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
        /*
         * Ok, go for it..
         */
-       area = get_vm_area(size, VM_IOREMAP);
+       area = get_vm_area_caller(size, VM_IOREMAP, caller);
        if (!area)
                return NULL;
        area->phys_addr = phys_addr;
@@ -103,7 +103,7 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
 
        return (void __iomem *)(offset + (char *)orig_addr);
 }
-EXPORT_SYMBOL(__ioremap);
+EXPORT_SYMBOL(__ioremap_caller);
 
 void __iounmap(void __iomem *addr)
 {
index b16843d02b76f424051988266c58488d8c93951f..ef434657d4284d5de6fda890f7a75bf32d99993c 100644 (file)
@@ -258,15 +258,15 @@ static void shmedia_unmapioaddr(unsigned long vaddr)
        pte_clear(&init_mm, vaddr, ptep);
 }
 
-void __iomem *__ioremap(unsigned long offset, unsigned long size,
-                       unsigned long flags)
+void __iomem *__ioremap_caller(unsigned long offset, unsigned long size,
+                              unsigned long flags, void *caller)
 {
        char name[14];
 
        sprintf(name, "phys_%08x", (u32)offset);
        return shmedia_alloc_io(offset, size, name, flags);
 }
-EXPORT_SYMBOL(__ioremap);
+EXPORT_SYMBOL(__ioremap_caller);
 
 void __iounmap(void __iomem *virtual)
 {
index 6c524446c0f6f49952e3757bde91b126c1ac3af8..422e9272187860b24842d938a505e6585056fed9 100644 (file)
@@ -28,7 +28,7 @@ void __init setup_memory(void)
 {
        unsigned long free_pfn = PFN_UP(__pa(_end));
        u64 base = min_low_pfn << PAGE_SHIFT;
-       u64 size = (max_low_pfn << PAGE_SHIFT) - min_low_pfn;
+       u64 size = (max_low_pfn << PAGE_SHIFT) - base;
 
        lmb_add(base, size);
 
@@ -37,6 +37,15 @@ void __init setup_memory(void)
                    (PFN_PHYS(free_pfn) + PAGE_SIZE - 1) -
                    (__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET));
 
+       /*
+        * Reserve physical pages below CONFIG_ZERO_PAGE_OFFSET.
+        */
+       if (CONFIG_ZERO_PAGE_OFFSET != 0)
+               lmb_reserve(__MEMORY_START, CONFIG_ZERO_PAGE_OFFSET);
+
+       lmb_analyze();
+       lmb_dump_all();
+
        /*
         * Node 0 sets up its pgdat at the first available pfn,
         * and bumps it up before setting up the bootmem allocator.
@@ -71,7 +80,7 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
 
        /* Node-local pgdat */
        NODE_DATA(nid) = __va(lmb_alloc_base(sizeof(struct pglist_data),
-                                            SMP_CACHE_BYTES, end_pfn));
+                                            SMP_CACHE_BYTES, end));
        memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
 
        NODE_DATA(nid)->bdata = &bootmem_node_data[nid];
@@ -81,7 +90,7 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
        /* Node-local bootmap */
        bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
        bootmem_paddr = lmb_alloc_base(bootmap_pages << PAGE_SHIFT,
-                                      PAGE_SIZE, end_pfn);
+                                      PAGE_SIZE, end);
        init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT,
                          start_pfn, end_pfn);
 
index 567516b58acca40ff99ada5fd9bd1bd100b91496..558a56bcc7cff69d0e5fbd7035ed9a717ab94061 100644 (file)
@@ -10,7 +10,7 @@
 # Shamelessly cloned from ARM.
 #
 
-include/asm-sh/machtypes.h: $(src)/gen-mach-types $(src)/mach-types
+include/generated/machtypes.h: $(src)/gen-mach-types $(src)/mach-types
        @echo '  Generating $@'
-       $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi
+       $(Q)mkdir -p $(dir $@)
        $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
index 65161e368353609fe58081a4fb6034aa3168a6de..f5ff7c5d8913cd23b1dd6f178827008d11efba96 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/awk
 #
-# Awk script to generate include/asm-sh/machtypes.h
+# Awk script to generate include/generated/machtypes.h
 # Heavily based on arch/arm/tools/gen-mach-types
 #
 BEGIN  { nr = 0 }
index 33ac1a9ac881d33e50b2442a871aeee7a79106fe..108197ac0d56eda5d0effb398560629f6a276352 100644 (file)
@@ -43,6 +43,7 @@ config SPARC64
        select HAVE_SYSCALL_WRAPPERS
        select HAVE_DYNAMIC_FTRACE
        select HAVE_FTRACE_MCOUNT_RECORD
+       select HAVE_SYSCALL_TRACEPOINTS
        select USE_GENERIC_SMP_HELPERS if SMP
        select RTC_DRV_CMOS
        select RTC_DRV_BQ4802
index 90d5fe223a7458953e866aa376ebd8e5591f244b..9d3c889718ac60e954d2439d74847a3443ed825c 100644 (file)
@@ -33,4 +33,18 @@ config FRAME_POINTER
        depends on MCOUNT
        default y
 
+config DEBUG_STRICT_USER_COPY_CHECKS
+       bool "Strict copy size checks"
+       depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
+       ---help---
+         Enabling this option turns a certain set of sanity checks for user
+         copy operations into compile time failures.
+
+         The copy_from_user() etc checks are there to help test if there
+         are sufficient security checks on the length argument of
+         the copy operation, by having gcc prove that the argument is
+         within bounds.
+
+         If unsure, or if you run an older (pre 4.4) gcc, say N.
+
 endmenu
diff --git a/arch/sparc/include/asm/asm-offsets.h b/arch/sparc/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 381a1b5256d6c9f23e0cb683b90ba8307265a409..4269ca6ad18a9f2b46cb0064dcc9618e9d72dcb3 100644 (file)
@@ -104,8 +104,6 @@ typedef struct {
 #define ELF_CLASS      ELFCLASS32
 #define ELF_DATA       ELFDATA2MSB
 
-#define USE_ELF_CORE_DUMP
-
 #define ELF_EXEC_PAGESIZE      4096
 
 
index d42e393078c49c4cdda59392fdbd56dc1d6f6c6e..ff66bb88537b37539812173a7825d1da39a82810 100644 (file)
@@ -152,7 +152,6 @@ typedef struct {
                                         (x)->e_machine == EM_SPARC32PLUS)
 #define compat_start_thread            start_thread32
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      PAGE_SIZE
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
index 3b9cfb39175e7dba1122ce9d8250b28eaa994c78..38f37b333cc7f5b277ea29646e2a0f14cfcfe325 100644 (file)
@@ -19,7 +19,7 @@
 #define O_NOATIME      0x200000
 #define O_CLOEXEC      0x400000
 /*
- * Before Linux 2.6.32 only O_DSYNC semantics were implemented, but using
+ * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
  * the O_SYNC flag.  We continue to use the existing numerical value
  * for O_DSYNC semantics now, but using the correct symbolic name for it.
  * This new value is used to request true Posix O_SYNC semantics.  It is
index 857630cff6364ff7bf2caf09761224f930daf6c2..7f9b9dba38a64896705ecb85b9d897e71125096d 100644 (file)
 
 #include <asm/psr.h>
 
-#define __raw_spin_is_locked(lock) (*((volatile unsigned char *)(lock)) != 0)
+#define arch_spin_is_locked(lock) (*((volatile unsigned char *)(lock)) != 0)
 
-#define __raw_spin_unlock_wait(lock) \
-       do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0)
+#define arch_spin_unlock_wait(lock) \
+       do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0)
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        __asm__ __volatile__(
        "\n1:\n\t"
@@ -35,7 +35,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
        : "g2", "memory", "cc");
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        unsigned int result;
        __asm__ __volatile__("ldstub [%1], %0"
@@ -45,7 +45,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
        return (result == 0);
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        __asm__ __volatile__("stb %%g0, [%0]" : : "r" (lock) : "memory");
 }
@@ -65,7 +65,7 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
  * Sort of like atomic_t's on Sparc, but even more clever.
  *
  *     ------------------------------------
- *     | 24-bit counter           | wlock |  raw_rwlock_t
+ *     | 24-bit counter           | wlock |  arch_rwlock_t
  *     ------------------------------------
  *      31                       8 7     0
  *
@@ -76,9 +76,9 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
  *
  * Unfortunately this scheme limits us to ~16,000,000 cpus.
  */
-static inline void arch_read_lock(raw_rwlock_t *rw)
+static inline void __arch_read_lock(arch_rwlock_t *rw)
 {
-       register raw_rwlock_t *lp asm("g1");
+       register arch_rwlock_t *lp asm("g1");
        lp = rw;
        __asm__ __volatile__(
        "mov    %%o7, %%g4\n\t"
@@ -89,16 +89,16 @@ static inline void arch_read_lock(raw_rwlock_t *rw)
        : "g2", "g4", "memory", "cc");
 }
 
-#define __raw_read_lock(lock) \
+#define arch_read_lock(lock) \
 do {   unsigned long flags; \
        local_irq_save(flags); \
-       arch_read_lock(lock); \
+       __arch_read_lock(lock); \
        local_irq_restore(flags); \
 } while(0)
 
-static inline void arch_read_unlock(raw_rwlock_t *rw)
+static inline void __arch_read_unlock(arch_rwlock_t *rw)
 {
-       register raw_rwlock_t *lp asm("g1");
+       register arch_rwlock_t *lp asm("g1");
        lp = rw;
        __asm__ __volatile__(
        "mov    %%o7, %%g4\n\t"
@@ -109,16 +109,16 @@ static inline void arch_read_unlock(raw_rwlock_t *rw)
        : "g2", "g4", "memory", "cc");
 }
 
-#define __raw_read_unlock(lock) \
+#define arch_read_unlock(lock) \
 do {   unsigned long flags; \
        local_irq_save(flags); \
-       arch_read_unlock(lock); \
+       __arch_read_unlock(lock); \
        local_irq_restore(flags); \
 } while(0)
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
-       register raw_rwlock_t *lp asm("g1");
+       register arch_rwlock_t *lp asm("g1");
        lp = rw;
        __asm__ __volatile__(
        "mov    %%o7, %%g4\n\t"
@@ -130,7 +130,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
        *(volatile __u32 *)&lp->lock = ~0U;
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *rw)
+static inline int arch_write_trylock(arch_rwlock_t *rw)
 {
        unsigned int val;
 
@@ -150,9 +150,9 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
        return (val == 0);
 }
 
-static inline int arch_read_trylock(raw_rwlock_t *rw)
+static inline int __arch_read_trylock(arch_rwlock_t *rw)
 {
-       register raw_rwlock_t *lp asm("g1");
+       register arch_rwlock_t *lp asm("g1");
        register int res asm("o0");
        lp = rw;
        __asm__ __volatile__(
@@ -165,27 +165,27 @@ static inline int arch_read_trylock(raw_rwlock_t *rw)
        return res;
 }
 
-#define __raw_read_trylock(lock) \
+#define arch_read_trylock(lock) \
 ({     unsigned long flags; \
        int res; \
        local_irq_save(flags); \
-       res = arch_read_trylock(lock); \
+       res = __arch_read_trylock(lock); \
        local_irq_restore(flags); \
        res; \
 })
 
-#define __raw_write_unlock(rw) do { (rw)->lock = 0; } while(0)
+#define arch_write_unlock(rw)  do { (rw)->lock = 0; } while(0)
 
-#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
-#define __raw_read_lock_flags(rw, flags)   __raw_read_lock(rw)
-#define __raw_write_lock_flags(rw, flags)  __raw_write_lock(rw)
+#define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock)
+#define arch_read_lock_flags(rw, flags)   arch_read_lock(rw)
+#define arch_write_lock_flags(rw, flags)  arch_write_lock(rw)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
-#define __raw_read_can_lock(rw) (!((rw)->lock & 0xff))
-#define __raw_write_can_lock(rw) (!(rw)->lock)
+#define arch_read_can_lock(rw) (!((rw)->lock & 0xff))
+#define arch_write_can_lock(rw) (!(rw)->lock)
 
 #endif /* !(__ASSEMBLY__) */
 
index 43e514783582d4722e2aa61249e249bbde5e6fc2..073936a8b2755e1c15e637ff28c5bc607876f4dc 100644 (file)
  * the spinner sections must be pre-V9 branches.
  */
 
-#define __raw_spin_is_locked(lp)       ((lp)->lock != 0)
+#define arch_spin_is_locked(lp)        ((lp)->lock != 0)
 
-#define __raw_spin_unlock_wait(lp)     \
+#define arch_spin_unlock_wait(lp)      \
        do {    rmb();                  \
        } while((lp)->lock)
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        unsigned long tmp;
 
@@ -46,7 +46,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
        : "memory");
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        unsigned long result;
 
@@ -59,7 +59,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
        return (result == 0UL);
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        __asm__ __volatile__(
 "      stb             %%g0, [%0]"
@@ -68,7 +68,7 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
        : "memory");
 }
 
-static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
+static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
 {
        unsigned long tmp1, tmp2;
 
@@ -92,7 +92,7 @@ static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long fla
 
 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
 
-static void inline arch_read_lock(raw_rwlock_t *lock)
+static void inline arch_read_lock(arch_rwlock_t *lock)
 {
        unsigned long tmp1, tmp2;
 
@@ -115,7 +115,7 @@ static void inline arch_read_lock(raw_rwlock_t *lock)
        : "memory");
 }
 
-static int inline arch_read_trylock(raw_rwlock_t *lock)
+static int inline arch_read_trylock(arch_rwlock_t *lock)
 {
        int tmp1, tmp2;
 
@@ -136,7 +136,7 @@ static int inline arch_read_trylock(raw_rwlock_t *lock)
        return tmp1;
 }
 
-static void inline arch_read_unlock(raw_rwlock_t *lock)
+static void inline arch_read_unlock(arch_rwlock_t *lock)
 {
        unsigned long tmp1, tmp2;
 
@@ -152,7 +152,7 @@ static void inline arch_read_unlock(raw_rwlock_t *lock)
        : "memory");
 }
 
-static void inline arch_write_lock(raw_rwlock_t *lock)
+static void inline arch_write_lock(arch_rwlock_t *lock)
 {
        unsigned long mask, tmp1, tmp2;
 
@@ -177,7 +177,7 @@ static void inline arch_write_lock(raw_rwlock_t *lock)
        : "memory");
 }
 
-static void inline arch_write_unlock(raw_rwlock_t *lock)
+static void inline arch_write_unlock(arch_rwlock_t *lock)
 {
        __asm__ __volatile__(
 "      stw             %%g0, [%0]"
@@ -186,7 +186,7 @@ static void inline arch_write_unlock(raw_rwlock_t *lock)
        : "memory");
 }
 
-static int inline arch_write_trylock(raw_rwlock_t *lock)
+static int inline arch_write_trylock(arch_rwlock_t *lock)
 {
        unsigned long mask, tmp1, tmp2, result;
 
@@ -210,21 +210,21 @@ static int inline arch_write_trylock(raw_rwlock_t *lock)
        return result;
 }
 
-#define __raw_read_lock(p)     arch_read_lock(p)
-#define __raw_read_lock_flags(p, f) arch_read_lock(p)
-#define __raw_read_trylock(p)  arch_read_trylock(p)
-#define __raw_read_unlock(p)   arch_read_unlock(p)
-#define __raw_write_lock(p)    arch_write_lock(p)
-#define __raw_write_lock_flags(p, f) arch_write_lock(p)
-#define __raw_write_unlock(p)  arch_write_unlock(p)
-#define __raw_write_trylock(p) arch_write_trylock(p)
-
-#define __raw_read_can_lock(rw)                (!((rw)->lock & 0x80000000UL))
-#define __raw_write_can_lock(rw)       (!(rw)->lock)
-
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_read_lock(p)      arch_read_lock(p)
+#define arch_read_lock_flags(p, f) arch_read_lock(p)
+#define arch_read_trylock(p)   arch_read_trylock(p)
+#define arch_read_unlock(p)    arch_read_unlock(p)
+#define arch_write_lock(p)     arch_write_lock(p)
+#define arch_write_lock_flags(p, f) arch_write_lock(p)
+#define arch_write_unlock(p)   arch_write_unlock(p)
+#define arch_write_trylock(p)  arch_write_trylock(p)
+
+#define arch_read_can_lock(rw)         (!((rw)->lock & 0x80000000UL))
+#define arch_write_can_lock(rw)        (!(rw)->lock)
+
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 #endif /* !(__ASSEMBLY__) */
 
index 37cbe01c585b5c9e91bdab7c013946bf11b87e65..9c454fdeaad82a9cf0cdc63bd84ea78112fa0083 100644 (file)
@@ -7,14 +7,14 @@
 
 typedef struct {
        volatile unsigned char lock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        volatile unsigned int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { 0 }
+#define __ARCH_RW_LOCK_UNLOCKED                { 0 }
 
 #endif
index 6c5fddb7e6b5b9c1c49fe447ae6e0f09832591f3..edf196ee4ef844787e64299ce0db65db1b25fdc2 100644 (file)
@@ -16,8 +16,6 @@
 #ifdef __KERNEL__
 
 extern void __memmove(void *,const void *,__kernel_size_t);
-extern __kernel_size_t __memcpy(void *,const void *,__kernel_size_t);
-extern __kernel_size_t __memset(void *,int,__kernel_size_t);
 
 #ifndef EXPORT_SYMTAB_STROPS
 
@@ -32,82 +30,10 @@ extern __kernel_size_t __memset(void *,int,__kernel_size_t);
 })
 
 #define __HAVE_ARCH_MEMCPY
-
-static inline void *__constant_memcpy(void *to, const void *from, __kernel_size_t n)
-{
-       extern void __copy_1page(void *, const void *);
-
-       if(n <= 32) {
-               __builtin_memcpy(to, from, n);
-       } else if (((unsigned int) to & 7) != 0) {
-               /* Destination is not aligned on the double-word boundary */
-               __memcpy(to, from, n);
-       } else {
-               switch(n) {
-               case PAGE_SIZE:
-                       __copy_1page(to, from);
-                       break;
-               default:
-                       __memcpy(to, from, n);
-                       break;
-               }
-       }
-       return to;
-}
-
-static inline void *__nonconstant_memcpy(void *to, const void *from, __kernel_size_t n)
-{
-       __memcpy(to, from, n);
-       return to;
-}
-
-#undef memcpy
-#define memcpy(t, f, n) \
-(__builtin_constant_p(n) ? \
- __constant_memcpy((t),(f),(n)) : \
- __nonconstant_memcpy((t),(f),(n)))
+#define memcpy(t, f, n) __builtin_memcpy(t, f, n)
 
 #define __HAVE_ARCH_MEMSET
-
-static inline void *__constant_c_and_count_memset(void *s, char c, __kernel_size_t count)
-{
-       extern void bzero_1page(void *);
-       extern __kernel_size_t __bzero(void *, __kernel_size_t);
-
-       if(!c) {
-               if(count == PAGE_SIZE)
-                       bzero_1page(s);
-               else
-                       __bzero(s, count);
-       } else {
-               __memset(s, c, count);
-       }
-       return s;
-}
-
-static inline void *__constant_c_memset(void *s, char c, __kernel_size_t count)
-{
-       extern __kernel_size_t __bzero(void *, __kernel_size_t);
-
-       if(!c)
-               __bzero(s, count);
-       else
-               __memset(s, c, count);
-       return s;
-}
-
-static inline void *__nonconstant_memset(void *s, char c, __kernel_size_t count)
-{
-       __memset(s, c, count);
-       return s;
-}
-
-#undef memset
-#define memset(s, c, count) \
-(__builtin_constant_p(c) ? (__builtin_constant_p(count) ? \
-                            __constant_c_and_count_memset((s), (c), (count)) : \
-                            __constant_c_memset((s), (c), (count))) \
-                          : __nonconstant_memset((s), (c), (count)))
+#define memset(s, c, count) __builtin_memset(s, c, count)
 
 #define __HAVE_ARCH_MEMSCAN
 
index 43161f2d17eb7c61939290fb77606aae13034c76..9623bc2131584adec146d807c0229bfe80f7252f 100644 (file)
@@ -15,8 +15,6 @@
 
 #include <asm/asi.h>
 
-extern void *__memset(void *,int,__kernel_size_t);
-
 #ifndef EXPORT_SYMTAB_STROPS
 
 /* First the mem*() things. */
@@ -24,29 +22,10 @@ extern void *__memset(void *,int,__kernel_size_t);
 extern void *memmove(void *, const void *, __kernel_size_t);
 
 #define __HAVE_ARCH_MEMCPY
-extern void *memcpy(void *, const void *, __kernel_size_t);
+#define memcpy(t, f, n) __builtin_memcpy(t, f, n)
 
 #define __HAVE_ARCH_MEMSET
-extern void *__builtin_memset(void *,int,__kernel_size_t);
-
-static inline void *__constant_memset(void *s, int c, __kernel_size_t count)
-{
-       extern __kernel_size_t __bzero(void *, __kernel_size_t);
-
-       if (!c) {
-               __bzero(s, count);
-               return s;
-       } else
-               return __memset(s, c, count);
-}
-
-#undef memset
-#define memset(s, c, count) \
-((__builtin_constant_p(count) && (count) <= 32) ? \
- __builtin_memset((s), (c), (count)) : \
- (__builtin_constant_p(c) ? \
-  __constant_memset((s), (c), (count)) : \
-  __memset((s), (c), (count))))
+#define memset(s, c, count) __builtin_memset(s, c, count)
 
 #define __HAVE_ARCH_MEMSCAN
 
index 1b45a7bbe40751a210f748759fac6c0e3fc3b879..7257ebb8f3949818ede9fc562fc1a6ddb6d8be1f 100644 (file)
@@ -227,6 +227,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
 /* flag bit 8 is available */
 #define TIF_SECCOMP            9       /* secure computing */
 #define TIF_SYSCALL_AUDIT      10      /* syscall auditing active */
+#define TIF_SYSCALL_TRACEPOINT 11      /* syscall tracepoint instrumentation */
 /* flag bit 11 is available */
 /* NOTE: Thread flags >= 12 should be ones we have no interest
  *       in using in assembly, else we can't use the mask as
@@ -246,6 +247,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
 #define _TIF_32BIT             (1<<TIF_32BIT)
 #define _TIF_SECCOMP           (1<<TIF_SECCOMP)
 #define _TIF_SYSCALL_AUDIT     (1<<TIF_SYSCALL_AUDIT)
+#define _TIF_SYSCALL_TRACEPOINT        (1<<TIF_SYSCALL_TRACEPOINT)
 #define _TIF_ABI_PENDING       (1<<TIF_ABI_PENDING)
 #define _TIF_POLLING_NRFLAG    (1<<TIF_POLLING_NRFLAG)
 #define _TIF_FREEZE            (1<<TIF_FREEZE)
index 8303ac48103426542f6681d826c995f8b8375385..489d2ba92bcb504e3d6243e36cef99bddf08e4c3 100644 (file)
@@ -260,8 +260,23 @@ static inline unsigned long __copy_to_user(void __user *to, const void *from, un
        return __copy_user(to, (__force void __user *) from, n);
 }
 
+extern void copy_from_user_overflow(void)
+#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
+       __compiletime_error("copy_from_user() buffer size is not provably correct")
+#else
+       __compiletime_warning("copy_from_user() buffer size is not provably correct")
+#endif
+;
+
 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
 {
+       int sz = __compiletime_object_size(to);
+
+       if (unlikely(sz != -1 && sz < n)) {
+               copy_from_user_overflow();
+               return -EFAULT;
+       }
+
        if (n && __access_ok((unsigned long) from, n))
                return __copy_user((__force void __user *) to, from, n);
        else
index 9ea271e19c70a9be95c4d40f3da34faea0b6c4a9..dbc141660994915c23c059b844772ae855681bdc 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #ifdef __KERNEL__
+#include <linux/errno.h>
 #include <linux/compiler.h>
 #include <linux/string.h>
 #include <linux/thread_info.h>
@@ -204,6 +205,14 @@ __asm__ __volatile__(                                                      \
 
 extern int __get_user_bad(void);
 
+extern void copy_from_user_overflow(void)
+#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
+       __compiletime_error("copy_from_user() buffer size is not provably correct")
+#else
+       __compiletime_warning("copy_from_user() buffer size is not provably correct")
+#endif
+;
+
 extern unsigned long __must_check ___copy_from_user(void *to,
                                                    const void __user *from,
                                                    unsigned long size);
@@ -212,10 +221,16 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
 static inline unsigned long __must_check
 copy_from_user(void *to, const void __user *from, unsigned long size)
 {
-       unsigned long ret = ___copy_from_user(to, from, size);
-
-       if (unlikely(ret))
-               ret = copy_from_user_fixup(to, from, size);
+       unsigned long ret = (unsigned long) -EFAULT;
+       int sz = __compiletime_object_size(to);
+
+       if (likely(sz == -1 || sz >= size)) {
+               ret = ___copy_from_user(to, from, size);
+               if (unlikely(ret))
+                       ret = copy_from_user_fixup(to, from, size);
+       } else {
+               copy_from_user_overflow();
+       }
        return ret;
 }
 #define __copy_from_user copy_from_user
index d8d25bd9712126b5553b24614c0b3a64fbdae811..cb4b9bfd0d8770a014e0258acc95ba5f47072755 100644 (file)
 #define __NR_perf_event_open   327
 #define __NR_recvmmsg          328
 
-#define NR_SYSCALLS            329
+#define NR_syscalls            329
 
 #ifdef __32bit_syscall_numbers__
 /* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
index ec9c7bc67d2134706b3fa098a8ecbe1ccd5346b9..1504df8ddf70a5b4fa1e8b1644610514b1b09fe2 100644 (file)
@@ -1294,7 +1294,7 @@ linux_sparc_syscall:
        sethi   %hi(PSR_SYSCALL), %l4
        or      %l0, %l4, %l0
        /* Direct access to user regs, must faster. */
-       cmp     %g1, NR_SYSCALLS
+       cmp     %g1, NR_syscalls
        bgeu    linux_sparc_ni_syscall
         sll    %g1, 2, %l4
        ld      [%l7 + %l4], %l7
index d3b1a3076569890724fdc58a77fd1949ca96a684..29973daa993013f404c711b29fcf1fcc3c6ea457 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/percpu.h>
 #include <linux/init.h>
 #include <linux/list.h>
+#include <trace/syscall.h>
 
 #include <asm/ftrace.h>
 
@@ -91,3 +92,13 @@ int __init ftrace_dyn_arch_init(void *data)
 }
 #endif
 
+#ifdef CONFIG_FTRACE_SYSCALLS
+
+extern unsigned int sys_call_table[];
+
+unsigned long __init arch_syscall_addr(int nr)
+{
+       return (unsigned long)sys_call_table[nr];
+}
+
+#endif
index 7690cc219ecc87b5399f327a826dc5f3ffcca8a5..5fad94950e7680b49a453686420bc9a85e316d78 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/errno.h>
 #include <linux/iommu-helper.h>
+#include <linux/bitmap.h>
 
 #ifdef CONFIG_PCI
 #include <linux/pci.h>
@@ -169,7 +170,7 @@ void iommu_range_free(struct iommu *iommu, dma_addr_t dma_addr, unsigned long np
 
        entry = (dma_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT;
 
-       iommu_area_free(arena->map, entry, npages);
+       bitmap_clear(arena->map, entry, npages);
 }
 
 int iommu_table_init(struct iommu *iommu, int tsbsize,
index ce996f97855f3b063defb784ff80fd845e24d88c..8d6882bb480a7b9aea91eabc7aee588db563055f 100644 (file)
@@ -176,7 +176,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -195,7 +195,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        } else if (i == NR_IRQS) {
                seq_printf(p, "NMI: ");
                for_each_online_cpu(j)
@@ -785,14 +785,14 @@ void fixup_irqs(void)
        for (irq = 0; irq < NR_IRQS; irq++) {
                unsigned long flags;
 
-               spin_lock_irqsave(&irq_desc[irq].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[irq].lock, flags);
                if (irq_desc[irq].action &&
                    !(irq_desc[irq].status & IRQ_PER_CPU)) {
                        if (irq_desc[irq].chip->set_affinity)
                                irq_desc[irq].chip->set_affinity(irq,
                                        irq_desc[irq].affinity);
                }
-               spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[irq].lock, flags);
        }
 
        tick_ops->disable_irq();
index 3bc6527c95af3ec3bec6f6c3397d46437d72aee5..6716584e48ab4c052a3d7cf941a1781949f885e6 100644 (file)
@@ -46,6 +46,9 @@ struct kretprobe_blackpoint kretprobe_blacklist[] = {{NULL, NULL}};
 
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
+       if ((unsigned long) p->addr & 0x3UL)
+               return -EILSEQ;
+
        p->ainsn.insn[0] = *p->addr;
        flushi(&p->ainsn.insn[0]);
 
index cb3c72c45aab441786c6ad5274cfb9aa056f735c..df39a0f0d27af2c250a3c7da9a2b50208d240e5f 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/init.h>
+#include <linux/bitmap.h>
 
 #include <asm/hypervisor.h>
 #include <asm/iommu.h>
@@ -1242,13 +1243,13 @@ int ldc_bind(struct ldc_channel *lp, const char *name)
        snprintf(lp->tx_irq_name, LDC_IRQ_NAME_MAX, "%s TX", name);
 
        err = request_irq(lp->cfg.rx_irq, ldc_rx,
-                         IRQF_SAMPLE_RANDOM | IRQF_DISABLED | IRQF_SHARED,
+                         IRQF_SAMPLE_RANDOM | IRQF_DISABLED,
                          lp->rx_irq_name, lp);
        if (err)
                return err;
 
        err = request_irq(lp->cfg.tx_irq, ldc_tx,
-                         IRQF_SAMPLE_RANDOM | IRQF_DISABLED | IRQF_SHARED,
+                         IRQF_SAMPLE_RANDOM | IRQF_DISABLED,
                          lp->tx_irq_name, lp);
        if (err) {
                free_irq(lp->cfg.rx_irq, lp);
@@ -1875,7 +1876,7 @@ EXPORT_SYMBOL(ldc_read);
 static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages)
 {
        struct iommu_arena *arena = &iommu->arena;
-       unsigned long n, i, start, end, limit;
+       unsigned long n, start, end, limit;
        int pass;
 
        limit = arena->limit;
@@ -1883,7 +1884,7 @@ static long arena_alloc(struct ldc_iommu *iommu, unsigned long npages)
        pass = 0;
 
 again:
-       n = find_next_zero_bit(arena->map, limit, start);
+       n = bitmap_find_next_zero_area(arena->map, limit, start, npages, 0);
        end = n + npages;
        if (unlikely(end >= limit)) {
                if (likely(pass < 1)) {
@@ -1896,16 +1897,7 @@ again:
                        return -1;
                }
        }
-
-       for (i = n; i < end; i++) {
-               if (test_bit(i, arena->map)) {
-                       start = i + 1;
-                       goto again;
-               }
-       }
-
-       for (i = n; i < end; i++)
-               __set_bit(i, arena->map);
+       bitmap_set(arena->map, n, npages);
 
        arena->hint = end;
 
index 938da19dc06527d755d7ce0a9cc8171b39f654c7..cdc91d919e93c36219e19b8a58d9ea32de721e3b 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/miscdevice.h>
+#include <linux/bootmem.h>
 
 #include <asm/cpudata.h>
 #include <asm/hypervisor.h>
@@ -108,25 +109,15 @@ static struct mdesc_handle * __init mdesc_lmb_alloc(unsigned int mdesc_size)
 
 static void mdesc_lmb_free(struct mdesc_handle *hp)
 {
-       unsigned int alloc_size, handle_size = hp->handle_size;
-       unsigned long start, end;
+       unsigned int alloc_size;
+       unsigned long start;
 
        BUG_ON(atomic_read(&hp->refcnt) != 0);
        BUG_ON(!list_empty(&hp->list));
 
-       alloc_size = PAGE_ALIGN(handle_size);
-
-       start = (unsigned long) hp;
-       end = start + alloc_size;
-
-       while (start < end) {
-               struct page *p;
-
-               p = virt_to_page(start);
-               ClearPageReserved(p);
-               __free_page(p);
-               start += PAGE_SIZE;
-       }
+       alloc_size = PAGE_ALIGN(hp->handle_size);
+       start = __pa(hp);
+       free_bootmem_late(start, alloc_size);
 }
 
 static struct mdesc_mem_ops lmb_mdesc_ops = {
index 881947e59e955468cbc4ea0e09794a70c3c519e9..0a6f2d1798d11b37b5f8570b8bafb0326531d164 100644 (file)
@@ -104,9 +104,19 @@ static int of_bus_pci_map(u32 *addr, const u32 *range,
        int i;
 
        /* Check address type match */
-       if ((addr[0] ^ range[0]) & 0x03000000)
-               return -EINVAL;
+       if (!((addr[0] ^ range[0]) & 0x03000000))
+               goto type_match;
+
+       /* Special exception, we can map a 64-bit address into
+        * a 32-bit range.
+        */
+       if ((addr[0] & 0x03000000) == 0x03000000 &&
+           (range[0] & 0x03000000) == 0x02000000)
+               goto type_match;
+
+       return -EINVAL;
 
+type_match:
        if (of_out_of_range(addr + 1, range + 1, range + na + pna,
                            na - 1, ns))
                return -EINVAL;
index b85374f7cf945f3d4760dbd6fe739455ea52b33b..539e83f8e087a56bda4e0749ebb39329ea7eab93 100644 (file)
@@ -1064,7 +1064,6 @@ int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask)
 
        return (device_mask & dma_addr_mask) == dma_addr_mask;
 }
-EXPORT_SYMBOL(pci_dma_supported);
 
 void pci_resource_to_user(const struct pci_dev *pdev, int bar,
                          const struct resource *rp, resource_size_t *start,
index 4ae91dc2feb9697c3a659aa7b993ca0636aadfb7..2f6524d1a817a3906f99109edfb953217bb16c1a 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/signal.h>
 #include <linux/regset.h>
 #include <linux/tracehook.h>
+#include <trace/syscall.h>
 #include <linux/compat.h>
 #include <linux/elf.h>
 
@@ -37,6 +38,9 @@
 #include <asm/cpudata.h>
 #include <asm/cacheflush.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 #include "entry.h"
 
 /* #define ALLOW_INIT_TRACING */
@@ -1059,6 +1063,9 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
        if (test_thread_flag(TIF_SYSCALL_TRACE))
                ret = tracehook_report_syscall_entry(regs);
 
+       if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+               trace_sys_enter(regs, regs->u_regs[UREG_G1]);
+
        if (unlikely(current->audit_context) && !ret)
                audit_syscall_entry((test_thread_flag(TIF_32BIT) ?
                                     AUDIT_ARCH_SPARC :
@@ -1084,6 +1091,9 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
                audit_syscall_exit(result, regs->u_regs[UREG_I0]);
        }
 
+       if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+               trace_sys_exit(regs, regs->u_regs[UREG_G1]);
+
        if (test_thread_flag(TIF_SYSCALL_TRACE))
                tracehook_report_syscall_exit(regs, 0);
 }
index 0f26066a08d9a897cef4fb5e8a9b3c21a8461d9d..372ad59c4cba3ee65ed8f81d9d1a7ca1e41956c2 100644 (file)
@@ -38,17 +38,5 @@ EXPORT_SYMBOL(sun4v_niagara_setperf);
 EXPORT_SYMBOL(sun4v_niagara2_getperf);
 EXPORT_SYMBOL(sun4v_niagara2_setperf);
 
-#ifdef CONFIG_PCI
-/* inline functions in asm/pci_64.h */
-EXPORT_SYMBOL(pci_alloc_consistent);
-EXPORT_SYMBOL(pci_free_consistent);
-EXPORT_SYMBOL(pci_map_single);
-EXPORT_SYMBOL(pci_unmap_single);
-EXPORT_SYMBOL(pci_map_sg);
-EXPORT_SYMBOL(pci_unmap_sg);
-EXPORT_SYMBOL(pci_dma_sync_single_for_cpu);
-EXPORT_SYMBOL(pci_dma_sync_sg_for_cpu);
-#endif
-
 /* Exporting a symbol from /init/main.c */
 EXPORT_SYMBOL(saved_command_line);
index d150c2aa98d2a7569e0b3aa97ae4841ddf2d691f..dc4a458f74dcc590a9cbe391dbc14a7b8302353c 100644 (file)
@@ -62,7 +62,7 @@ sys32_rt_sigreturn:
 #endif
        .align  32
 1:     ldx     [%g6 + TI_FLAGS], %l5
-       andcc   %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
+       andcc   %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
        be,pt   %icc, rtrap
         nop
        call    syscall_trace_leave
@@ -187,7 +187,7 @@ linux_syscall_trace:
        .globl  linux_sparc_syscall32
 linux_sparc_syscall32:
        /* Direct access to user regs, much faster. */
-       cmp     %g1, NR_SYSCALLS                        ! IEU1  Group
+       cmp     %g1, NR_syscalls                        ! IEU1  Group
        bgeu,pn %xcc, linux_sparc_ni_syscall            ! CTI
         srl    %i0, 0, %o0                             ! IEU0
        sll     %g1, 2, %l4                             ! IEU0  Group
@@ -198,7 +198,7 @@ linux_sparc_syscall32:
 
        srl     %i5, 0, %o5                             ! IEU1
        srl     %i2, 0, %o2                             ! IEU0  Group
-       andcc   %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
+       andcc   %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
        bne,pn  %icc, linux_syscall_trace32             ! CTI
         mov    %i0, %l5                                ! IEU1
        call    %l7                                     ! CTI   Group brk forced
@@ -210,7 +210,7 @@ linux_sparc_syscall32:
        .globl  linux_sparc_syscall
 linux_sparc_syscall:
        /* Direct access to user regs, much faster. */
-       cmp     %g1, NR_SYSCALLS                        ! IEU1  Group
+       cmp     %g1, NR_syscalls                        ! IEU1  Group
        bgeu,pn %xcc, linux_sparc_ni_syscall            ! CTI
         mov    %i0, %o0                                ! IEU0
        sll     %g1, 2, %l4                             ! IEU0  Group
@@ -221,7 +221,7 @@ linux_sparc_syscall:
 
        mov     %i3, %o3                                ! IEU1
        mov     %i4, %o4                                ! IEU0  Group
-       andcc   %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
+       andcc   %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
        bne,pn  %icc, linux_syscall_trace               ! CTI   Group
         mov    %i0, %l5                                ! IEU0
 2:     call    %l7                                     ! CTI   Group brk forced
@@ -245,7 +245,7 @@ ret_sys_call:
 
        cmp     %o0, -ERESTART_RESTARTBLOCK
        bgeu,pn %xcc, 1f
-        andcc  %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
+        andcc  %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
 80:
        /* System call success, clear Carry condition code. */
        andn    %g3, %g2, %g3
@@ -260,7 +260,7 @@ ret_sys_call:
        /* System call failure, set Carry condition code.
         * Also, get abs(errno) to return to the process.
         */
-       andcc   %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6  
+       andcc   %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6  
        sub     %g0, %o0, %o0
        or      %g3, %g2, %g3
        stx     %o0, [%sp + PTREGS_OFF + PT_V9_I0]
index 63f73ae8a892fd89525b2465a7f964fb9b34d9ea..67e165102885c6d70729d932eb4845e314d52ffb 100644 (file)
@@ -774,26 +774,9 @@ void __devinit setup_sparc64_timer(void)
 static struct clocksource clocksource_tick = {
        .rating         = 100,
        .mask           = CLOCKSOURCE_MASK(64),
-       .shift          = 16,
        .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-static void __init setup_clockevent_multiplier(unsigned long hz)
-{
-       unsigned long mult, shift = 32;
-
-       while (1) {
-               mult = div_sc(hz, NSEC_PER_SEC, shift);
-               if (mult && (mult >> 32UL) == 0UL)
-                       break;
-
-               shift--;
-       }
-
-       sparc64_clockevent.shift = shift;
-       sparc64_clockevent.mult = mult;
-}
-
 static unsigned long tb_ticks_per_usec __read_mostly;
 
 void __delay(unsigned long loops)
@@ -828,9 +811,7 @@ void __init time_init(void)
                clocksource_hz2mult(freq, SPARC64_NSEC_PER_CYC_SHIFT);
 
        clocksource_tick.name = tick_ops->name;
-       clocksource_tick.mult =
-               clocksource_hz2mult(freq,
-                                   clocksource_tick.shift);
+       clocksource_calc_mult_shift(&clocksource_tick, freq, 4);
        clocksource_tick.read = clocksource_tick_read;
 
        printk("clocksource: mult[%x] shift[%d]\n",
@@ -839,15 +820,14 @@ void __init time_init(void)
        clocksource_register(&clocksource_tick);
 
        sparc64_clockevent.name = tick_ops->name;
-
-       setup_clockevent_multiplier(freq);
+       clockevents_calc_mult_shift(&sparc64_clockevent, freq, 4);
 
        sparc64_clockevent.max_delta_ns =
                clockevent_delta2ns(0x7fffffffffffffffUL, &sparc64_clockevent);
        sparc64_clockevent.min_delta_ns =
                clockevent_delta2ns(0xF, &sparc64_clockevent);
 
-       printk("clockevent: mult[%ux] shift[%d]\n",
+       printk("clockevent: mult[%x] shift[%d]\n",
               sparc64_clockevent.mult, sparc64_clockevent.shift);
 
        setup_sparc64_timer();
index 6b1e6cde6fff59873eae727467b5f35f70f04935..f8514e291e1559ecda6994ff5be883cc6805128c 100644 (file)
@@ -17,8 +17,7 @@
 #include <asm/uaccess.h>
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
-
-/* #define DEBUG_MNA */
+#include <linux/perf_event.h>
 
 enum direction {
        load,    /* ld, ldd, ldh, ldsh */
@@ -29,12 +28,6 @@ enum direction {
        invalid,
 };
 
-#ifdef DEBUG_MNA
-static char *dirstrings[] = {
-  "load", "store", "both", "fpload", "fpstore", "invalid"
-};
-#endif
-
 static inline enum direction decode_direction(unsigned int insn)
 {
        unsigned long tmp = (insn >> 21) & 1;
@@ -255,10 +248,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
                unsigned long addr = compute_effective_address(regs, insn);
                int err;
 
-#ifdef DEBUG_MNA
-               printk("KMNA: pc=%08lx [dir=%s addr=%08lx size=%d] retpc[%08lx]\n",
-                      regs->pc, dirstrings[dir], addr, size, regs->u_regs[UREG_RETPC]);
-#endif
+               perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);
                switch (dir) {
                case load:
                        err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
@@ -350,6 +340,7 @@ asmlinkage void user_unaligned_trap(struct pt_regs *regs, unsigned int insn)
                }
 
                addr = compute_effective_address(regs, insn);
+               perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);
                switch(dir) {
                case load:
                        err = do_int_load(fetch_reg_addr(((insn>>25)&0x1f),
index 379209982a07f41ca7454332e41b9ee303263b8c..378ca82b9cccd4532d66b92e63b57676fa8672a5 100644 (file)
 #include <asm/uaccess.h>
 #include <linux/smp.h>
 #include <linux/bitops.h>
+#include <linux/perf_event.h>
 #include <asm/fpumacro.h>
 
-/* #define DEBUG_MNA */
-
 enum direction {
        load,    /* ld, ldd, ldh, ldsh */
        store,   /* st, std, sth, stsh */
@@ -33,12 +32,6 @@ enum direction {
        invalid,
 };
 
-#ifdef DEBUG_MNA
-static char *dirstrings[] = {
-  "load", "store", "both", "fpload", "fpstore", "invalid"
-};
-#endif
-
 static inline enum direction decode_direction(unsigned int insn)
 {
        unsigned long tmp = (insn >> 21) & 1;
@@ -327,12 +320,7 @@ asmlinkage void kernel_unaligned_trap(struct pt_regs *regs, unsigned int insn)
 
                addr = compute_effective_address(regs, insn,
                                                 ((insn >> 25) & 0x1f));
-#ifdef DEBUG_MNA
-               printk("KMNA: pc=%016lx [dir=%s addr=%016lx size=%d] "
-                      "retpc[%016lx]\n",
-                      regs->tpc, dirstrings[dir], addr, size,
-                      regs->u_regs[UREG_RETPC]);
-#endif
+               perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, addr);
                switch (asi) {
                case ASI_NL:
                case ASI_AIUPL:
@@ -399,6 +387,7 @@ int handle_popc(u32 insn, struct pt_regs *regs)
        int ret, i, rd = ((insn >> 25) & 0x1f);
        int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;
                                
+       perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
        if (insn & 0x2000) {
                maybe_flush_windows(0, 0, rd, from_kernel);
                value = sign_extend_imm13(insn);
@@ -445,6 +434,8 @@ int handle_ldf_stq(u32 insn, struct pt_regs *regs)
        int asi = decode_asi(insn, regs);
        int flag = (freg < 32) ? FPRS_DL : FPRS_DU;
 
+       perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
+
        save_and_clear_fpu();
        current_thread_info()->xfsr[0] &= ~0x1c000;
        if (freg & 3) {
@@ -566,6 +557,8 @@ void handle_ld_nf(u32 insn, struct pt_regs *regs)
        int from_kernel = (regs->tstate & TSTATE_PRIV) != 0;
        unsigned long *reg;
                                
+       perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
+
        maybe_flush_windows(0, 0, rd, from_kernel);
        reg = fetch_reg_addr(rd, regs);
        if (from_kernel || rd < 16) {
@@ -596,6 +589,7 @@ void handle_lddfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr
 
        if (tstate & TSTATE_PRIV)
                die_if_kernel("lddfmna from kernel", regs);
+       perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar);
        if (test_thread_flag(TIF_32BIT))
                pc = (u32)pc;
        if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
@@ -657,6 +651,7 @@ void handle_stdfmna(struct pt_regs *regs, unsigned long sfar, unsigned long sfsr
 
        if (tstate & TSTATE_PRIV)
                die_if_kernel("stdfmna from kernel", regs);
+       perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, sfar);
        if (test_thread_flag(TIF_32BIT))
                pc = (u32)pc;
        if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
index d231cbd5c5261c4a8a8fbfb45cba268d4485269e..9dfd2ebcb157143bb69fe988dd1ced391ab8e874 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/thread_info.h>
+#include <linux/perf_event.h>
 
 #include <asm/ptrace.h>
 #include <asm/pstate.h>
@@ -801,6 +802,8 @@ int vis_emul(struct pt_regs *regs, unsigned int insn)
 
        BUG_ON(regs->tstate & TSTATE_PRIV);
 
+       perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
+
        if (test_thread_flag(TIF_32BIT))
                pc = (u32)pc;
 
index e75faf0e59aeadec986fb4ad1e22d77e72f040e7..c4b5e03af11557efa6ae42aa11f9ce0d74dfa42a 100644 (file)
@@ -44,3 +44,4 @@ obj-y                 += iomap.o
 obj-$(CONFIG_SPARC32) += atomic32.o
 obj-y                 += ksyms.o
 obj-$(CONFIG_SPARC64) += PeeCeeI.o
+obj-y                 += usercopy.o
index b6557297440f0dbb65a06a8153623be6ad8dc193..615f401edf69b57a56266cc4d2723f4a685eb549 100644 (file)
@@ -6,10 +6,6 @@
 
        .text
 
-       .globl  __memset
-       .type   __memset, #function
-__memset:              /* %o0=buf, %o1=pat, %o2=len */
-
        .globl  memset
        .type   memset, #function
 memset:                        /* %o0=buf, %o1=pat, %o2=len */
@@ -83,7 +79,6 @@ __bzero_done:
        retl
         mov            %o3, %o0
        .size           __bzero, .-__bzero
-       .size           __memset, .-__memset
        .size           memset, .-memset
 
 #define EX_ST(x,y)             \
index 77f228533d47850ddfe39e4d8d24e748d1b90d11..3632cb34e914b241ed394b99092b6a5aa63601c0 100644 (file)
@@ -560,7 +560,7 @@ __csum_partial_copy_end:
         mov    %i0, %o1
        mov     %i1, %o0
 5:
-       call    __memcpy
+       call    memcpy
         mov    %i2, %o2
        tst     %o0
        bne,a   2f
index 704b12668388c7b541509abd1ee598d0a60f0ce2..1b30bb3bfdb1fe19f522aff9e46f64f212060086 100644 (file)
@@ -30,7 +30,6 @@ EXPORT_SYMBOL(__memscan_generic);
 EXPORT_SYMBOL(memcmp);
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memset);
-EXPORT_SYMBOL(__memset);
 EXPORT_SYMBOL(memmove);
 EXPORT_SYMBOL(__bzero);
 
@@ -81,7 +80,6 @@ EXPORT_SYMBOL(__csum_partial_copy_sparc_generic);
 
 /* Special internal versions of library functions. */
 EXPORT_SYMBOL(__copy_1page);
-EXPORT_SYMBOL(__memcpy);
 EXPORT_SYMBOL(__memmove);
 EXPORT_SYMBOL(bzero_1page);
 
index 7ce9c65f3592a7f949bffc47ecf558ffbfcc3c3e..24b8b12deed20fa43ce9a28dfdd5c698b2a1d103 100644 (file)
@@ -64,8 +64,9 @@ mcount:
 2:      sethi          %hi(softirq_stack), %g3
        or              %g3, %lo(softirq_stack), %g3
        ldx             [%g3 + %g1], %g7
+       sub             %g7, STACK_BIAS, %g7
        cmp             %sp, %g7
-       bleu,pt         %xcc, 2f
+       bleu,pt         %xcc, 3f
         sethi          %hi(THREAD_SIZE), %g3
        add             %g7, %g3, %g7
        cmp             %sp, %g7
@@ -75,7 +76,7 @@ mcount:
         * again, we are already trying to output the stack overflow
         * message.
         */
-       sethi           %hi(ovstack), %g7               ! cant move to panic stack fast enough
+3:     sethi           %hi(ovstack), %g7               ! cant move to panic stack fast enough
         or             %g7, %lo(ovstack), %g7
        add             %g7, OVSTACKSIZE, %g3
        sub             %g3, STACK_BIAS + 192, %g3
index ce10bc869af9d8fda4aaf19232fa2d449bb4d848..34fe65751737dba67b9df52f55fe165e6d2202e4 100644 (file)
@@ -543,9 +543,6 @@ FUNC(memmove)
        b               3f
         add            %o0, 2, %o0
 
-#ifdef __KERNEL__
-FUNC(__memcpy)
-#endif
 FUNC(memcpy)   /* %o0=dst %o1=src %o2=len */
 
        sub             %o0, %o1, %o4
index 1c37ea892debaf853c94152a2eefbec7b5d798a2..99c017be8719609bbc6e99ada83610e2d38763a1 100644 (file)
         .globl  __bzero_begin
 __bzero_begin:
 
-       .globl  __bzero, __memset, 
+       .globl  __bzero
        .globl  memset
        .globl  __memset_start, __memset_end
 __memset_start:
-__memset:
 memset:
        and     %o1, 0xff, %g3
        sll     %g3, 8, %g2
diff --git a/arch/sparc/lib/usercopy.c b/arch/sparc/lib/usercopy.c
new file mode 100644 (file)
index 0000000..14b363f
--- /dev/null
@@ -0,0 +1,8 @@
+#include <linux/module.h>
+#include <linux/bug.h>
+
+void copy_from_user_overflow(void)
+{
+       WARN(1, "Buffer overflow detected!\n");
+}
+EXPORT_SYMBOL(copy_from_user_overflow);
index e13f65da17dfd90875e2da6e9e29c609e21ee3a3..a3fccde894ece2791cef55922928d9eea7abd239 100644 (file)
@@ -67,6 +67,7 @@
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
+#include <linux/perf_event.h>
 #include <asm/uaccess.h>
 
 #include "sfp-util_32.h"
@@ -163,6 +164,8 @@ int do_mathemu(struct pt_regs *regs, struct task_struct *fpt)
        int retcode = 0;                               /* assume all succeed */
        unsigned long insn;
 
+       perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
+
 #ifdef DEBUG_MATHEMU
        printk("In do_mathemu()... pc is %08lx\n", regs->pc);
        printk("fpqdepth is %ld\n", fpt->thread.fpqdepth);
index 6863c9bde25c918926d38dea78497f15f0ba2dbc..56d2c44747b8fcf3fd69324319b36ebd4b7ebce7 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <linux/perf_event.h>
 
 #include <asm/fpumacro.h>
 #include <asm/ptrace.h>
@@ -183,6 +184,7 @@ int do_mathemu(struct pt_regs *regs, struct fpustate *f)
 
        if (tstate & TSTATE_PRIV)
                die_if_kernel("unfinished/unimplemented FPop from kernel", regs);
+       perf_sw_event(PERF_COUNT_SW_EMULATION_FAULTS, 1, 0, regs, 0);
        if (test_thread_flag(TIF_32BIT))
                pc = (u32)pc;
        if (get_user(insn, (u32 __user *) pc) != -EFAULT) {
index 43b0da96a4fb92c4a3f5e3e1eaac67ae611832e5..6081936bf03b84579ce488b7488b8bc7c6e395ac 100644 (file)
 #include <asm/sections.h>
 #include <asm/mmu_context.h>
 
-#ifdef CONFIG_KPROBES
-static inline int notify_page_fault(struct pt_regs *regs)
+static inline __kprobes int notify_page_fault(struct pt_regs *regs)
 {
        int ret = 0;
 
        /* kprobe_running() needs smp_processor_id() */
-       if (!user_mode(regs)) {
+       if (kprobes_built_in() && !user_mode(regs)) {
                preempt_disable();
                if (kprobe_running() && kprobe_fault_handler(regs, 0))
                        ret = 1;
@@ -45,12 +44,6 @@ static inline int notify_page_fault(struct pt_regs *regs)
        }
        return ret;
 }
-#else
-static inline int notify_page_fault(struct pt_regs *regs)
-{
-       return 0;
-}
-#endif
 
 static void __kprobes unhandled_fault(unsigned long address,
                                      struct task_struct *tsk,
@@ -73,7 +66,7 @@ static void __kprobes unhandled_fault(unsigned long address,
        die_if_kernel("Oops", regs);
 }
 
-static void bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
+static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
 {
        printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
               regs->tpc);
@@ -170,8 +163,9 @@ static unsigned int get_fault_insn(struct pt_regs *regs, unsigned int insn)
        return insn;
 }
 
-static void do_kernel_fault(struct pt_regs *regs, int si_code, int fault_code,
-                           unsigned int insn, unsigned long address)
+static void __kprobes do_kernel_fault(struct pt_regs *regs, int si_code,
+                                     int fault_code, unsigned int insn,
+                                     unsigned long address)
 {
        unsigned char asi = ASI_P;
  
@@ -225,7 +219,7 @@ cannot_handle:
        unhandled_fault (address, current, regs);
 }
 
-static void noinline bogus_32bit_fault_tpc(struct pt_regs *regs)
+static void noinline __kprobes bogus_32bit_fault_tpc(struct pt_regs *regs)
 {
        static int times;
 
@@ -237,8 +231,8 @@ static void noinline bogus_32bit_fault_tpc(struct pt_regs *regs)
        show_regs(regs);
 }
 
-static void noinline bogus_32bit_fault_address(struct pt_regs *regs,
-                                              unsigned long addr)
+static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
+                                                        unsigned long addr)
 {
        static int times;
 
index 2ffacd67c42403393013bd73cd191eddbdc3b22f..a89baf0d875af3ef7a557675b87a90398ee6fbd3 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/fs.h>
 #include <linux/seq_file.h>
 #include <linux/scatterlist.h>
+#include <linux/bitmap.h>
 
 #include <asm/sections.h>
 #include <asm/page.h>
@@ -1021,20 +1022,12 @@ static char *sun4c_lockarea(char *vaddr, unsigned long size)
        npages = (((unsigned long)vaddr & ~PAGE_MASK) +
                  size + (PAGE_SIZE-1)) >> PAGE_SHIFT;
 
-       scan = 0;
        local_irq_save(flags);
-       for (;;) {
-               scan = find_next_zero_bit(sun4c_iobuffer_map,
-                                         iobuffer_map_size, scan);
-               if ((base = scan) + npages > iobuffer_map_size) goto abend;
-               for (;;) {
-                       if (scan >= base + npages) goto found;
-                       if (test_bit(scan, sun4c_iobuffer_map)) break;
-                       scan++;
-               }
-       }
+       base = bitmap_find_next_zero_area(sun4c_iobuffer_map, iobuffer_map_size,
+                                               0, npages, 0);
+       if (base >= iobuffer_map_size)
+               goto abend;
 
-found:
        high = ((base + npages) << PAGE_SHIFT) + sun4c_iobuffer_start;
        high = SUN4C_REAL_PGDIR_ALIGN(high);
        while (high > sun4c_iobuffer_high) {
index fc633dbacf84b818e1f6ac64fff887852431526d..fab8121d2b32a2059ea24ac2a70b5da3c221a888 100644 (file)
@@ -149,6 +149,6 @@ $(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
 
 $(SHARED_HEADERS)/kern_constants.h:
        $(Q)mkdir -p $(dir $@)
-       $(Q)echo '#include "../../../../include/asm/asm-offsets.h"' >$@
+       $(Q)echo '#include "../../../../include/generated/asm-offsets.h"' >$@
 
 export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH
index e14629c87de4fb48c15943f52ffcedf7fca48821..51069245b79a207274547c51ce904206f5ffb939 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/console.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/mm.h>
@@ -131,7 +132,7 @@ void mconsole_proc(struct mc_request *req)
        char *ptr = req->request.data, *buf;
 
        ptr += strlen("proc");
-       while (isspace(*ptr)) ptr++;
+       ptr = skip_spaces(ptr);
 
        proc = get_fs_type("proc");
        if (proc == NULL) {
@@ -212,8 +213,7 @@ void mconsole_proc(struct mc_request *req)
        char *ptr = req->request.data;
 
        ptr += strlen("proc");
-       while (isspace(*ptr))
-               ptr++;
+       ptr = skip_spaces(ptr);
        snprintf(path, sizeof(path), "/proc/%s", ptr);
 
        fd = sys_open(path, 0, 0);
@@ -560,8 +560,7 @@ void mconsole_config(struct mc_request *req)
        int err;
 
        ptr += strlen("config");
-       while (isspace(*ptr))
-               ptr++;
+       ptr = skip_spaces(ptr);
        dev = mconsole_find_dev(ptr);
        if (dev == NULL) {
                mconsole_reply(req, "Bad configuration option", 1, 0);
@@ -588,7 +587,7 @@ void mconsole_remove(struct mc_request *req)
        int err, start, end, n;
 
        ptr += strlen("remove");
-       while (isspace(*ptr)) ptr++;
+       ptr = skip_spaces(ptr);
        dev = mconsole_find_dev(ptr);
        if (dev == NULL) {
                mconsole_reply(req, "Bad remove option", 1, 0);
@@ -712,7 +711,7 @@ void mconsole_sysrq(struct mc_request *req)
        char *ptr = req->request.data;
 
        ptr += strlen("sysrq");
-       while (isspace(*ptr)) ptr++;
+       ptr = skip_spaces(ptr);
 
        /*
         * With 'b', the system will shut down without a chance to reply,
@@ -757,8 +756,7 @@ void mconsole_stack(struct mc_request *req)
         */
 
        ptr += strlen("stack");
-       while (isspace(*ptr))
-               ptr++;
+       ptr = skip_spaces(ptr);
 
        /*
         * Should really check for multiple pids or reject bad args here
@@ -833,8 +831,8 @@ static int __init mconsole_init(void)
 
 __initcall(mconsole_init);
 
-static int write_proc_mconsole(struct file *file, const char __user *buffer,
-                              unsigned long count, void *data)
+static ssize_t mconsole_proc_write(struct file *file,
+               const char __user *buffer, size_t count, loff_t *pos)
 {
        char *buf;
 
@@ -855,6 +853,11 @@ static int write_proc_mconsole(struct file *file, const char __user *buffer,
        return count;
 }
 
+static const struct file_operations mconsole_proc_fops = {
+       .owner          = THIS_MODULE,
+       .write          = mconsole_proc_write,
+};
+
 static int create_proc_mconsole(void)
 {
        struct proc_dir_entry *ent;
@@ -862,15 +865,12 @@ static int create_proc_mconsole(void)
        if (notify_socket == NULL)
                return 0;
 
-       ent = create_proc_entry("mconsole", S_IFREG | 0200, NULL);
+       ent = proc_create("mconsole", 0200, NULL, &mconsole_proc_fops);
        if (ent == NULL) {
                printk(KERN_INFO "create_proc_mconsole : create_proc_entry "
                       "failed\n");
                return 0;
        }
-
-       ent->read_proc = NULL;
-       ent->write_proc = write_proc_mconsole;
        return 0;
 }
 
index 635d16d90a80d4158df7769ec11df5ab6c64c38d..5ff554677f4019ad4435bb6d8277b9ec72907d97 100644 (file)
@@ -27,6 +27,7 @@
 #include "linux/init.h"
 #include "linux/cdrom.h"
 #include "linux/proc_fs.h"
+#include "linux/seq_file.h"
 #include "linux/ctype.h"
 #include "linux/capability.h"
 #include "linux/mm.h"
@@ -200,23 +201,25 @@ static void make_proc_ide(void)
        proc_ide = proc_mkdir("ide0", proc_ide_root);
 }
 
-static int proc_ide_read_media(char *page, char **start, off_t off, int count,
-                              int *eof, void *data)
+static int fake_ide_media_proc_show(struct seq_file *m, void *v)
 {
-       int len;
-
-       strcpy(page, "disk\n");
-       len = strlen("disk\n");
-       len -= off;
-       if (len < count){
-               *eof = 1;
-               if (len <= 0) return 0;
-       }
-       else len = count;
-       *start = page + off;
-       return len;
+       seq_puts(m, "disk\n");
+       return 0;
+}
+
+static int fake_ide_media_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, fake_ide_media_proc_show, NULL);
 }
 
+static const struct file_operations fake_ide_media_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = fake_ide_media_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 static void make_ide_entries(const char *dev_name)
 {
        struct proc_dir_entry *dir, *ent;
@@ -227,11 +230,8 @@ static void make_ide_entries(const char *dev_name)
        dir = proc_mkdir(dev_name, proc_ide);
        if(!dir) return;
 
-       ent = create_proc_entry("media", S_IFREG|S_IRUGO, dir);
+       ent = proc_create("media", S_IRUGO, dir, &fake_ide_media_proc_fops);
        if(!ent) return;
-       ent->data = NULL;
-       ent->read_proc = proc_ide_read_media;
-       ent->write_proc = NULL;
        snprintf(name, sizeof(name), "ide0/%s", dev_name);
        proc_symlink(dev_name, proc_ide_root, name);
 }
diff --git a/arch/um/include/asm/asm-offsets.h b/arch/um/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 6540d2c9fbb76f684db03539e26e202178cf18f5..829df49dee99c6093d5586d0e2c19e34786dfa97 100644 (file)
@@ -6,7 +6,9 @@
 #include <linux/ctype.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/types.h>
 #include <asm/uaccess.h>
 
  */
 int uml_exitcode = 0;
 
-static int read_proc_exitcode(char *page, char **start, off_t off,
-                             int count, int *eof, void *data)
+static int exitcode_proc_show(struct seq_file *m, void *v)
 {
-       int len, val;
+       int val;
 
        /*
         * Save uml_exitcode in a local so that we don't need to guarantee
         * that sprintf accesses it atomically.
         */
        val = uml_exitcode;
-       len = sprintf(page, "%d\n", val);
-       len -= off;
-       if (len <= off+count)
-               *eof = 1;
-       *start = page + off;
-       if (len > count)
-               len = count;
-       if (len < 0)
-               len = 0;
-       return len;
+       seq_printf(m, "%d\n", val);
+       return 0;
+}
+
+static int exitcode_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, exitcode_proc_show, NULL);
 }
 
-static int write_proc_exitcode(struct file *file, const char __user *buffer,
-                              unsigned long count, void *data)
+static ssize_t exitcode_proc_write(struct file *file,
+               const char __user *buffer, size_t count, loff_t *pos)
 {
        char *end, buf[sizeof("nnnnn\0")];
        int tmp;
@@ -55,20 +53,25 @@ static int write_proc_exitcode(struct file *file, const char __user *buffer,
        return count;
 }
 
+static const struct file_operations exitcode_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = exitcode_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = exitcode_proc_write,
+};
+
 static int make_proc_exitcode(void)
 {
        struct proc_dir_entry *ent;
 
-       ent = create_proc_entry("exitcode", 0600, NULL);
+       ent = proc_create("exitcode", 0600, NULL, &exitcode_proc_fops);
        if (ent == NULL) {
                printk(KERN_WARNING "make_proc_exitcode : Failed to register "
                       "/proc/exitcode\n");
                return 0;
        }
-
-       ent->read_proc = read_proc_exitcode;
-       ent->write_proc = write_proc_exitcode;
-
        return 0;
 }
 
index 039270b9b73bf91f76b079f2bf756b97c8cd27e1..89474ba0741e616cdfc2598553198ba99cf86bcb 100644 (file)
@@ -34,7 +34,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -53,7 +53,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        } else if (i == NR_IRQS)
                seq_putc(p, '\n');
 
index 4a28a1568d856c7b1605743ca33c143921caacd4..2f910a1b745452fdcccc1c167cdd3671d2275023 100644 (file)
@@ -9,11 +9,13 @@
 #include <linux/hardirq.h>
 #include <linux/gfp.h>
 #include <linux/mm.h>
+#include <linux/module.h>
 #include <linux/personality.h>
 #include <linux/proc_fs.h>
 #include <linux/ptrace.h>
 #include <linux/random.h>
 #include <linux/sched.h>
+#include <linux/seq_file.h>
 #include <linux/tick.h>
 #include <linux/threads.h>
 #include <asm/current.h>
@@ -336,16 +338,19 @@ int get_using_sysemu(void)
        return atomic_read(&using_sysemu);
 }
 
-static int proc_read_sysemu(char *buf, char **start, off_t offset, int size,int *eof, void *data)
+static int sysemu_proc_show(struct seq_file *m, void *v)
 {
-       if (snprintf(buf, size, "%d\n", get_using_sysemu()) < size)
-               /* No overflow */
-               *eof = 1;
+       seq_printf(m, "%d\n", get_using_sysemu());
+       return 0;
+}
 
-       return strlen(buf);
+static int sysemu_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, sysemu_proc_show, NULL);
 }
 
-static int proc_write_sysemu(struct file *file,const char __user *buf, unsigned long count,void *data)
+static ssize_t sysemu_proc_write(struct file *file, const char __user *buf,
+                                size_t count, loff_t *pos)
 {
        char tmp[2];
 
@@ -358,13 +363,22 @@ static int proc_write_sysemu(struct file *file,const char __user *buf, unsigned
        return count;
 }
 
+static const struct file_operations sysemu_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = sysemu_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = sysemu_proc_write,
+};
+
 int __init make_proc_sysemu(void)
 {
        struct proc_dir_entry *ent;
        if (!sysemu_supported)
                return 0;
 
-       ent = create_proc_entry("sysemu", 0600, NULL);
+       ent = proc_create("sysemu", 0600, NULL, &sysemu_proc_fops);
 
        if (ent == NULL)
        {
@@ -372,9 +386,6 @@ int __init make_proc_sysemu(void)
                return 0;
        }
 
-       ent->read_proc  = proc_read_sysemu;
-       ent->write_proc = proc_write_sysemu;
-
        return 0;
 }
 
index d0da9d7c53716fc294fd1d1c26759d03da784469..770885472ed4c850b59d5fea34ad1c0c5db1439f 100644 (file)
@@ -48,7 +48,6 @@ typedef struct user_i387_struct elf_fpregset_t;
        PT_REGS_EAX(regs) = 0; \
 } while (0)
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE 4096
 
 #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
index af9463cd8ce51f936af61c14d8ce217bf3eb5eec..8aacaf56508d408e425054e5991aeab78d8d9f9b 100644 (file)
@@ -17,8 +17,6 @@ extern long elf_aux_hwcap;
 #define ELF_CLASS ELFCLASS32
 #endif
 
-#define USE_ELF_CORE_DUMP
-
 #define R_386_NONE     0
 #define R_386_32       1
 #define R_386_PC32     2
index 04b9e87c8dadd38f5f0ebc60ae72b190e63c7920..49655c83efd2241b4d80b044b283207a3a3493ec 100644 (file)
@@ -104,7 +104,6 @@ extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu);
         clear_thread_flag(TIF_IA32);
 #endif
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE 4096
 
 #define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
index 32a1918e1b880d2ab94f7a62c044bd3d8fff64e9..55298e891571edc6d07486f235a46ffddd622729 100644 (file)
@@ -50,6 +50,8 @@ config X86
        select HAVE_KERNEL_BZIP2
        select HAVE_KERNEL_LZMA
        select HAVE_HW_BREAKPOINT
+       select PERF_EVENTS
+       select ANON_INODES
        select HAVE_ARCH_KMEMCHECK
        select HAVE_USER_RETURN_NOTIFIER
 
@@ -2012,18 +2014,9 @@ config SCx200HR_TIMER
          processor goes idle (as is done by the scheduler).  The
          other workaround is idle=poll boot option.
 
-config GEODE_MFGPT_TIMER
-       def_bool y
-       prompt "Geode Multi-Function General Purpose Timer (MFGPT) events"
-       depends on MGEODE_LX && GENERIC_TIME && GENERIC_CLOCKEVENTS
-       ---help---
-         This driver provides a clock event source based on the MFGPT
-         timer(s) in the CS5535 and CS5536 companion chip for the geode.
-         MFGPTs have a better resolution and max interval than the
-         generic PIT, and are suitable for use as high-res timers.
-
 config OLPC
        bool "One Laptop Per Child support"
+       select GPIOLIB
        default n
        ---help---
          Add support for detecting the unique features of the OLPC
index bbeb0c3fbd90e7ba875c583ab3e2e57cca216714..89bbf4e4d05d834c7923a23de080b71dd5ebab24 100644 (file)
@@ -9,6 +9,9 @@
 #include <byteswap.h>
 #define USE_BSD
 #include <endian.h>
+#include <regex.h>
+
+static void die(char *fmt, ...);
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 static Elf32_Ehdr ehdr;
@@ -30,25 +33,47 @@ static struct section *secs;
  * the address for which it has been compiled. Don't warn user about
  * absolute relocations present w.r.t these symbols.
  */
-static const char* safe_abs_relocs[] = {
-               "xen_irq_disable_direct_reloc",
-               "xen_save_fl_direct_reloc",
-};
+static const char abs_sym_regex[] =
+       "^(xen_irq_disable_direct_reloc$|"
+       "xen_save_fl_direct_reloc$|"
+       "VDSO|"
+       "__crc_)";
+static regex_t abs_sym_regex_c;
+static int is_abs_reloc(const char *sym_name)
+{
+       return !regexec(&abs_sym_regex_c, sym_name, 0, NULL, 0);
+}
 
-static int is_safe_abs_reloc(const char* sym_name)
+/*
+ * These symbols are known to be relative, even if the linker marks them
+ * as absolute (typically defined outside any section in the linker script.)
+ */
+static const char rel_sym_regex[] =
+       "^_end$";
+static regex_t rel_sym_regex_c;
+static int is_rel_reloc(const char *sym_name)
 {
-       int i;
+       return !regexec(&rel_sym_regex_c, sym_name, 0, NULL, 0);
+}
 
-       for (i = 0; i < ARRAY_SIZE(safe_abs_relocs); i++) {
-               if (!strcmp(sym_name, safe_abs_relocs[i]))
-                       /* Match found */
-                       return 1;
-       }
-       if (strncmp(sym_name, "VDSO", 4) == 0)
-               return 1;
-       if (strncmp(sym_name, "__crc_", 6) == 0)
-               return 1;
-       return 0;
+static void regex_init(void)
+{
+        char errbuf[128];
+        int err;
+       
+        err = regcomp(&abs_sym_regex_c, abs_sym_regex,
+                      REG_EXTENDED|REG_NOSUB);
+        if (err) {
+                regerror(err, &abs_sym_regex_c, errbuf, sizeof errbuf);
+                die("%s", errbuf);
+        }
+
+        err = regcomp(&rel_sym_regex_c, rel_sym_regex,
+                      REG_EXTENDED|REG_NOSUB);
+        if (err) {
+                regerror(err, &rel_sym_regex_c, errbuf, sizeof errbuf);
+                die("%s", errbuf);
+        }
 }
 
 static void die(char *fmt, ...)
@@ -131,7 +156,7 @@ static const char *rel_type(unsigned type)
 #undef REL_TYPE
        };
        const char *name = "unknown type rel type name";
-       if (type < ARRAY_SIZE(type_name)) {
+       if (type < ARRAY_SIZE(type_name) && type_name[type]) {
                name = type_name[type];
        }
        return name;
@@ -448,7 +473,7 @@ static void print_absolute_relocs(void)
                         * Before warning check if this absolute symbol
                         * relocation is harmless.
                         */
-                       if (is_safe_abs_reloc(name))
+                       if (is_abs_reloc(name) || is_rel_reloc(name))
                                continue;
 
                        if (!printed) {
@@ -501,21 +526,26 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
                        sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
                        r_type = ELF32_R_TYPE(rel->r_info);
                        /* Don't visit relocations to absolute symbols */
-                       if (sym->st_shndx == SHN_ABS) {
+                       if (sym->st_shndx == SHN_ABS &&
+                           !is_rel_reloc(sym_name(sym_strtab, sym))) {
                                continue;
                        }
-                       if (r_type == R_386_NONE || r_type == R_386_PC32) {
+                       switch (r_type) {
+                       case R_386_NONE:
+                       case R_386_PC32:
                                /*
                                 * NONE can be ignored and and PC relative
                                 * relocations don't need to be adjusted.
                                 */
-                       }
-                       else if (r_type == R_386_32) {
+                               break;
+                       case R_386_32:
                                /* Visit relocations that need to be adjusted */
                                visit(rel, sym);
-                       }
-                       else {
-                               die("Unsupported relocation type: %d\n", r_type);
+                               break;
+                       default:
+                               die("Unsupported relocation type: %s (%d)\n",
+                                   rel_type(r_type), r_type);
+                               break;
                        }
                }
        }
@@ -571,16 +601,15 @@ static void emit_relocs(int as_text)
        }
        else {
                unsigned char buf[4];
-               buf[0] = buf[1] = buf[2] = buf[3] = 0;
                /* Print a stop */
-               printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
+               fwrite("\0\0\0\0", 4, 1, stdout);
                /* Now print each relocation */
                for (i = 0; i < reloc_count; i++) {
                        buf[0] = (relocs[i] >>  0) & 0xff;
                        buf[1] = (relocs[i] >>  8) & 0xff;
                        buf[2] = (relocs[i] >> 16) & 0xff;
                        buf[3] = (relocs[i] >> 24) & 0xff;
-                       printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
+                       fwrite(buf, 4, 1, stdout);
                }
        }
 }
@@ -598,6 +627,8 @@ int main(int argc, char **argv)
        FILE *fp;
        int i;
 
+       regex_init();
+
        show_absolute_syms = 0;
        show_absolute_relocs = 0;
        as_text = 0;
index b31cc54b46410f89b4120702b1d1b018a79e204d..93e689f4bd86f78730e4feb4f1f08c4e1f4d6dae 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #include <asm/segment.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <asm/boot.h>
 #include <asm/e820.h>
 #include <asm/page_types.h>
index 2723d9b5ce432b4d229a9d3cbe47f9b8fdf08a2c..2b15aa488ffb2af8d446a20f26eab07b8e21d8d5 100644 (file)
@@ -13,8 +13,8 @@
  */
 
 #include "boot.h"
-#include <linux/utsrelease.h>
-#include <linux/compile.h>
+#include <generated/utsrelease.h>
+#include <generated/compile.h>
 
 const char kernel_version[] =
        UTS_RELEASE " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ") "
index 60d2b2db0bc55d003887913ce1442d5d73a66094..56f462cf22d2fc75cb6c8616697813ada52d53e9 100644 (file)
@@ -142,6 +142,32 @@ static inline unsigned int acpi_processor_cstate_check(unsigned int max_cstate)
                return max_cstate;
 }
 
+static inline bool arch_has_acpi_pdc(void)
+{
+       struct cpuinfo_x86 *c = &cpu_data(0);
+       return (c->x86_vendor == X86_VENDOR_INTEL ||
+               c->x86_vendor == X86_VENDOR_CENTAUR);
+}
+
+static inline void arch_acpi_set_pdc_bits(u32 *buf)
+{
+       struct cpuinfo_x86 *c = &cpu_data(0);
+
+       buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
+
+       if (cpu_has(c, X86_FEATURE_EST))
+               buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
+
+       if (cpu_has(c, X86_FEATURE_ACPI))
+               buf[2] |= ACPI_PDC_T_FFH;
+
+       /*
+        * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
+        */
+       if (!cpu_has(c, X86_FEATURE_MWAIT))
+               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
+}
+
 #else /* !CONFIG_ACPI */
 
 #define acpi_lapic 0
diff --git a/arch/x86/include/asm/asm-offsets.h b/arch/x86/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index 613700f27a4a17965a40c1224c033ffd91d5c00c..637e1ec963c397bec02f447e96992ca1dcd3a9f4 100644 (file)
 #define X86_FEATURE_SSE5       (6*32+11) /* SSE-5 */
 #define X86_FEATURE_SKINIT     (6*32+12) /* SKINIT/STGI instructions */
 #define X86_FEATURE_WDT                (6*32+13) /* Watchdog timer */
+#define X86_FEATURE_NODEID_MSR (6*32+19) /* NodeId MSR */
 
 /*
  * Auxiliary flags: Linux defined - For features scattered in various
index 0f6c02f3b7d4f26126a590e3df2408c2af6c5d8c..ac91eed21061a5299bc39669f6e333d2b61ef4b3 100644 (file)
@@ -67,7 +67,7 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
        if (!dev->dma_mask)
                return 0;
 
-       return addr + size <= *dev->dma_mask;
+       return addr + size - 1 <= *dev->dma_mask;
 }
 
 static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
index 8a024babe5e646a3b1f8282deeae9edcf70088ba..b4501ee223ad66e4e589d1340aee77b483e8da7c 100644 (file)
@@ -239,7 +239,6 @@ extern int force_personality32;
 #endif /* !CONFIG_X86_32 */
 
 #define CORE_DUMP_USE_REGSET
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      4096
 
 /* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
index ad3c2ed7548185f7c9891236e078bb98c62cb67c..7cd73552a4e8021517ddc3bca5d47ed9bfc7b811 100644 (file)
 
 #include <asm/processor.h>
 #include <linux/io.h>
-
-/* Generic southbridge functions */
-
-#define GEODE_DEV_PMS 0
-#define GEODE_DEV_ACPI 1
-#define GEODE_DEV_GPIO 2
-#define GEODE_DEV_MFGPT 3
-
-extern int geode_get_dev_base(unsigned int dev);
-
-/* Useful macros */
-#define geode_pms_base()       geode_get_dev_base(GEODE_DEV_PMS)
-#define geode_acpi_base()      geode_get_dev_base(GEODE_DEV_ACPI)
-#define geode_gpio_base()      geode_get_dev_base(GEODE_DEV_GPIO)
-#define geode_mfgpt_base()     geode_get_dev_base(GEODE_DEV_MFGPT)
-
-/* MSRS */
-
-#define MSR_GLIU_P2D_RO0       0x10000029
-
-#define MSR_LX_GLD_MSR_CONFIG  0x48002001
-#define MSR_LX_MSR_PADSEL      0x48002011      /* NOT 0x48000011; the data
-                                                * sheet has the wrong value */
-#define MSR_GLCP_SYS_RSTPLL    0x4C000014
-#define MSR_GLCP_DOTPLL                0x4C000015
-
-#define MSR_LBAR_SMB           0x5140000B
-#define MSR_LBAR_GPIO          0x5140000C
-#define MSR_LBAR_MFGPT         0x5140000D
-#define MSR_LBAR_ACPI          0x5140000E
-#define MSR_LBAR_PMS           0x5140000F
-
-#define MSR_DIVIL_SOFT_RESET   0x51400017
-
-#define MSR_PIC_YSEL_LOW       0x51400020
-#define MSR_PIC_YSEL_HIGH      0x51400021
-#define MSR_PIC_ZSEL_LOW       0x51400022
-#define MSR_PIC_ZSEL_HIGH      0x51400023
-#define MSR_PIC_IRQM_LPC       0x51400025
-
-#define MSR_MFGPT_IRQ          0x51400028
-#define MSR_MFGPT_NR           0x51400029
-#define MSR_MFGPT_SETUP                0x5140002B
-
-#define MSR_LX_SPARE_MSR       0x80000011      /* DC-specific */
-
-#define MSR_GX_GLD_MSR_CONFIG  0xC0002001
-#define MSR_GX_MSR_PADSEL      0xC0002011
-
-/* Resource Sizes */
-
-#define LBAR_GPIO_SIZE         0xFF
-#define LBAR_MFGPT_SIZE                0x40
-#define LBAR_ACPI_SIZE         0x40
-#define LBAR_PMS_SIZE          0x80
-
-/* ACPI registers (PMS block) */
-
-/*
- * PM1_EN is only valid when VSA is enabled for 16 bit reads.
- * When VSA is not enabled, *always* read both PM1_STS and PM1_EN
- * with a 32 bit read at offset 0x0
- */
-
-#define PM1_STS                        0x00
-#define PM1_EN                 0x02
-#define PM1_CNT                        0x08
-#define PM2_CNT                        0x0C
-#define PM_TMR                 0x10
-#define PM_GPE0_STS            0x18
-#define PM_GPE0_EN             0x1C
-
-/* PMC registers (PMS block) */
-
-#define PM_SSD                 0x00
-#define PM_SCXA                        0x04
-#define PM_SCYA                        0x08
-#define PM_OUT_SLPCTL          0x0C
-#define PM_SCLK                        0x10
-#define PM_SED                 0x1
-#define PM_SCXD                        0x18
-#define PM_SCYD                        0x1C
-#define PM_IN_SLPCTL           0x20
-#define PM_WKD                 0x30
-#define PM_WKXD                        0x34
-#define PM_RD                  0x38
-#define PM_WKXA                        0x3C
-#define PM_FSD                 0x40
-#define PM_TSD                 0x44
-#define PM_PSD                 0x48
-#define PM_NWKD                        0x4C
-#define PM_AWKD                        0x50
-#define PM_SSC                 0x54
-
-/* VSA2 magic values */
-
-#define VSA_VRC_INDEX          0xAC1C
-#define VSA_VRC_DATA           0xAC1E
-#define VSA_VR_UNLOCK          0xFC53  /* unlock virtual register */
-#define VSA_VR_SIGNATURE       0x0003
-#define VSA_VR_MEM_SIZE                0x0200
-#define AMD_VSA_SIG            0x4132  /* signature is ascii 'VSA2' */
-#define GSW_VSA_SIG            0x534d  /* General Software signature */
-/* GPIO */
-
-#define GPIO_OUTPUT_VAL                0x00
-#define GPIO_OUTPUT_ENABLE     0x04
-#define GPIO_OUTPUT_OPEN_DRAIN 0x08
-#define GPIO_OUTPUT_INVERT     0x0C
-#define GPIO_OUTPUT_AUX1       0x10
-#define GPIO_OUTPUT_AUX2       0x14
-#define GPIO_PULL_UP           0x18
-#define GPIO_PULL_DOWN         0x1C
-#define GPIO_INPUT_ENABLE      0x20
-#define GPIO_INPUT_INVERT      0x24
-#define GPIO_INPUT_FILTER      0x28
-#define GPIO_INPUT_EVENT_COUNT 0x2C
-#define GPIO_READ_BACK         0x30
-#define GPIO_INPUT_AUX1                0x34
-#define GPIO_EVENTS_ENABLE     0x38
-#define GPIO_LOCK_ENABLE       0x3C
-#define GPIO_POSITIVE_EDGE_EN  0x40
-#define GPIO_NEGATIVE_EDGE_EN  0x44
-#define GPIO_POSITIVE_EDGE_STS 0x48
-#define GPIO_NEGATIVE_EDGE_STS 0x4C
-
-#define GPIO_MAP_X             0xE0
-#define GPIO_MAP_Y             0xE4
-#define GPIO_MAP_Z             0xE8
-#define GPIO_MAP_W             0xEC
-
-static inline u32 geode_gpio(unsigned int nr)
-{
-       BUG_ON(nr > 28);
-       return 1 << nr;
-}
-
-extern void geode_gpio_set(u32, unsigned int);
-extern void geode_gpio_clear(u32, unsigned int);
-extern int geode_gpio_isset(u32, unsigned int);
-extern void geode_gpio_setup_event(unsigned int, int, int);
-extern void geode_gpio_set_irq(unsigned int, unsigned int);
-
-static inline void geode_gpio_event_irq(unsigned int gpio, int pair)
-{
-       geode_gpio_setup_event(gpio, pair, 0);
-}
-
-static inline void geode_gpio_event_pme(unsigned int gpio, int pair)
-{
-       geode_gpio_setup_event(gpio, pair, 1);
-}
-
-/* Specific geode tests */
+#include <linux/cs5535.h>
 
 static inline int is_geode_gx(void)
 {
@@ -186,68 +33,4 @@ static inline int is_geode(void)
        return (is_geode_gx() || is_geode_lx());
 }
 
-#ifdef CONFIG_MGEODE_LX
-extern int geode_has_vsa2(void);
-#else
-static inline int geode_has_vsa2(void)
-{
-       return 0;
-}
-#endif
-
-/* MFGPTs */
-
-#define MFGPT_MAX_TIMERS       8
-#define MFGPT_TIMER_ANY                (-1)
-
-#define MFGPT_DOMAIN_WORKING   1
-#define MFGPT_DOMAIN_STANDBY   2
-#define MFGPT_DOMAIN_ANY       (MFGPT_DOMAIN_WORKING | MFGPT_DOMAIN_STANDBY)
-
-#define MFGPT_CMP1             0
-#define MFGPT_CMP2             1
-
-#define MFGPT_EVENT_IRQ                0
-#define MFGPT_EVENT_NMI                1
-#define MFGPT_EVENT_RESET      3
-
-#define MFGPT_REG_CMP1         0
-#define MFGPT_REG_CMP2         2
-#define MFGPT_REG_COUNTER      4
-#define MFGPT_REG_SETUP                6
-
-#define MFGPT_SETUP_CNTEN      (1 << 15)
-#define MFGPT_SETUP_CMP2       (1 << 14)
-#define MFGPT_SETUP_CMP1       (1 << 13)
-#define MFGPT_SETUP_SETUP      (1 << 12)
-#define MFGPT_SETUP_STOPEN     (1 << 11)
-#define MFGPT_SETUP_EXTEN      (1 << 10)
-#define MFGPT_SETUP_REVEN      (1 << 5)
-#define MFGPT_SETUP_CLKSEL     (1 << 4)
-
-static inline void geode_mfgpt_write(int timer, u16 reg, u16 value)
-{
-       u32 base = geode_get_dev_base(GEODE_DEV_MFGPT);
-       outw(value, base + reg + (timer * 8));
-}
-
-static inline u16 geode_mfgpt_read(int timer, u16 reg)
-{
-       u32 base = geode_get_dev_base(GEODE_DEV_MFGPT);
-       return inw(base + reg + (timer * 8));
-}
-
-extern int geode_mfgpt_toggle_event(int timer, int cmp, int event, int enable);
-extern int geode_mfgpt_set_irq(int timer, int cmp, int *irq, int enable);
-extern int geode_mfgpt_alloc_timer(int timer, int domain);
-
-#define geode_mfgpt_setup_irq(t, c, i) geode_mfgpt_set_irq((t), (c), (i), 1)
-#define geode_mfgpt_release_irq(t, c, i) geode_mfgpt_set_irq((t), (c), (i), 0)
-
-#ifdef CONFIG_GEODE_MFGPT_TIMER
-extern int __init mfgpt_timer_setup(void);
-#else
-static inline int mfgpt_timer_setup(void) { return 0; }
-#endif
-
 #endif /* _ASM_X86_GEODE_H */
index 08c48a81841fd5af23bc24f354dbb82efd8681ef..eeac829a0f44e3d29972e2008f6ad48a0c8cd302 100644 (file)
@@ -103,7 +103,8 @@ extern int assign_irq_vector(int, struct irq_cfg *, const struct cpumask *);
 extern void send_cleanup_vector(struct irq_cfg *);
 
 struct irq_desc;
-extern unsigned int set_desc_affinity(struct irq_desc *, const struct cpumask *);
+extern unsigned int set_desc_affinity(struct irq_desc *, const struct cpumask *,
+                                     unsigned int *dest_id);
 extern int IO_APIC_get_PCI_irq_vector(int bus, int devfn, int pin, struct io_apic_irq_attr *irq_attr);
 extern void setup_ioapic_dest(void);
 
index 950df434763f5b2ea3fa407d3511f0020e9cb67b..f46b79f6c16c873a337013fa8a18e18f85c4ee22 100644 (file)
@@ -254,6 +254,10 @@ struct kvm_reinject_control {
        __u8 reserved[31];
 };
 
+/* When set in flags, include corresponding fields on KVM_SET_VCPU_EVENTS */
+#define KVM_VCPUEVENT_VALID_NMI_PENDING        0x00000001
+#define KVM_VCPUEVENT_VALID_SIPI_VECTOR        0x00000002
+
 /* for KVM_GET/SET_VCPU_EVENTS */
 struct kvm_vcpu_events {
        struct {
index 4ffe09b2ad7511c3e50a1f4465923c2f522dd3d6..1cd58cdbc03f2e97dee6983b5a8ea2ebef7d0061 100644 (file)
@@ -12,6 +12,7 @@
 #define MSR_FS_BASE            0xc0000100 /* 64bit FS base */
 #define MSR_GS_BASE            0xc0000101 /* 64bit GS base */
 #define MSR_KERNEL_GS_BASE     0xc0000102 /* SwapGS GS shadow */
+#define MSR_TSC_AUX            0xc0000103 /* Auxiliary TSC */
 
 /* EFER bits: */
 #define _EFER_SCE              0  /* SYSCALL/SYSRET */
 #define FAM10H_MMIO_CONF_BUSRANGE_SHIFT 2
 #define FAM10H_MMIO_CONF_BASE_MASK     0xfffffff
 #define FAM10H_MMIO_CONF_BASE_SHIFT    20
+#define MSR_FAM10H_NODE_ID             0xc001100c
 
 /* K8 MSRs */
 #define MSR_K8_TOP_MEM1                        0xc001001a
index 2d228fc9b4b7642958e963e464b2b924435bebc4..c5bc4c2d33f56399f98b55975abc23b3d694ea85 100644 (file)
@@ -27,6 +27,18 @@ struct msr {
        };
 };
 
+struct msr_info {
+       u32 msr_no;
+       struct msr reg;
+       struct msr *msrs;
+       int err;
+};
+
+struct msr_regs_info {
+       u32 *regs;
+       int err;
+};
+
 static inline unsigned long long native_read_tscp(unsigned int *aux)
 {
        unsigned long low, high;
@@ -240,9 +252,9 @@ do {                                                            \
 #define checking_wrmsrl(msr, val) wrmsr_safe((msr), (u32)(val),                \
                                             (u32)((val) >> 32))
 
-#define write_tsc(val1, val2) wrmsr(0x10, (val1), (val2))
+#define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2))
 
-#define write_rdtscp_aux(val) wrmsr(0xc0000103, (val), 0)
+#define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0)
 
 struct msr *msrs_alloc(void);
 void msrs_free(struct msr *msrs);
index 834a30295fabbb75740826a39c76e7bfbbe2fe37..3a57385d9fa7e9ade6d666e279fc146086169d7d 100644 (file)
@@ -120,7 +120,7 @@ extern int olpc_ec_mask_unset(uint8_t bits);
 
 /* GPIO assignments */
 
-#define OLPC_GPIO_MIC_AC       geode_gpio(1)
+#define OLPC_GPIO_MIC_AC       1
 #define OLPC_GPIO_DCON_IRQ     geode_gpio(7)
 #define OLPC_GPIO_THRM_ALRM    geode_gpio(10)
 #define OLPC_GPIO_SMB_CLK      geode_gpio(14)
index efb38994859c6c961c68a0cf301106098e0b86cc..dd59a85a918fcf6dfe70b1768e19d976ae80ba59 100644 (file)
@@ -731,34 +731,34 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
 
 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
 
-static inline int __raw_spin_is_locked(struct raw_spinlock *lock)
+static inline int arch_spin_is_locked(struct arch_spinlock *lock)
 {
        return PVOP_CALL1(int, pv_lock_ops.spin_is_locked, lock);
 }
 
-static inline int __raw_spin_is_contended(struct raw_spinlock *lock)
+static inline int arch_spin_is_contended(struct arch_spinlock *lock)
 {
        return PVOP_CALL1(int, pv_lock_ops.spin_is_contended, lock);
 }
-#define __raw_spin_is_contended        __raw_spin_is_contended
+#define arch_spin_is_contended arch_spin_is_contended
 
-static __always_inline void __raw_spin_lock(struct raw_spinlock *lock)
+static __always_inline void arch_spin_lock(struct arch_spinlock *lock)
 {
        PVOP_VCALL1(pv_lock_ops.spin_lock, lock);
 }
 
-static __always_inline void __raw_spin_lock_flags(struct raw_spinlock *lock,
+static __always_inline void arch_spin_lock_flags(struct arch_spinlock *lock,
                                                  unsigned long flags)
 {
        PVOP_VCALL2(pv_lock_ops.spin_lock_flags, lock, flags);
 }
 
-static __always_inline int __raw_spin_trylock(struct raw_spinlock *lock)
+static __always_inline int arch_spin_trylock(struct arch_spinlock *lock)
 {
        return PVOP_CALL1(int, pv_lock_ops.spin_trylock, lock);
 }
 
-static __always_inline void __raw_spin_unlock(struct raw_spinlock *lock)
+static __always_inline void arch_spin_unlock(struct arch_spinlock *lock)
 {
        PVOP_VCALL1(pv_lock_ops.spin_unlock, lock);
 }
index 9357473c8da06b7d37f76fa22ea610942cbc90e7..b1e70d51e40c87ba57f8a6a6e6df197a27b56f58 100644 (file)
@@ -318,14 +318,14 @@ struct pv_mmu_ops {
                           phys_addr_t phys, pgprot_t flags);
 };
 
-struct raw_spinlock;
+struct arch_spinlock;
 struct pv_lock_ops {
-       int (*spin_is_locked)(struct raw_spinlock *lock);
-       int (*spin_is_contended)(struct raw_spinlock *lock);
-       void (*spin_lock)(struct raw_spinlock *lock);
-       void (*spin_lock_flags)(struct raw_spinlock *lock, unsigned long flags);
-       int (*spin_trylock)(struct raw_spinlock *lock);
-       void (*spin_unlock)(struct raw_spinlock *lock);
+       int (*spin_is_locked)(struct arch_spinlock *lock);
+       int (*spin_is_contended)(struct arch_spinlock *lock);
+       void (*spin_lock)(struct arch_spinlock *lock);
+       void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
+       int (*spin_trylock)(struct arch_spinlock *lock);
+       void (*spin_unlock)(struct arch_spinlock *lock);
 };
 
 /* This contains all the paravirt structures: we get a convenient
index 6f8ec1c37e0a8c999f9344082465fd2c9b4570f1..fc801bab1b3b7683f39d6e38e3a6fc17003e7da1 100644 (file)
@@ -181,7 +181,7 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
                                unsigned int *ecx, unsigned int *edx)
 {
        /* ecx is often an input as well as an output. */
-       asm("cpuid"
+       asm volatile("cpuid"
            : "=a" (*eax),
              "=b" (*ebx),
              "=c" (*ecx),
index 3d11fd0f44c5f4f86c060207417710db58758094..9d369f6803216cd365358d1660c6aab999287d51 100644 (file)
@@ -292,6 +292,8 @@ extern void user_enable_block_step(struct task_struct *);
 #define arch_has_block_step()  (boot_cpu_data.x86 >= 6)
 #endif
 
+#define ARCH_HAS_USER_SINGLE_STEP_INFO
+
 struct user_desc;
 extern int do_get_thread_area(struct task_struct *p, int idx,
                              struct user_desc __user *info);
index 4e77853321dbcca412c52cf35c437bbff2442af8..3089f70c0c52059e569c8745d1dcca089daee8af 100644 (file)
@@ -58,7 +58,7 @@
 #if (NR_CPUS < 256)
 #define TICKET_SHIFT 8
 
-static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
+static __always_inline void __ticket_spin_lock(arch_spinlock_t *lock)
 {
        short inc = 0x0100;
 
@@ -77,7 +77,7 @@ static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
                : "memory", "cc");
 }
 
-static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
+static __always_inline int __ticket_spin_trylock(arch_spinlock_t *lock)
 {
        int tmp, new;
 
@@ -96,7 +96,7 @@ static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
        return tmp;
 }
 
-static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock)
+static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
 {
        asm volatile(UNLOCK_LOCK_PREFIX "incb %0"
                     : "+m" (lock->slock)
@@ -106,7 +106,7 @@ static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock)
 #else
 #define TICKET_SHIFT 16
 
-static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
+static __always_inline void __ticket_spin_lock(arch_spinlock_t *lock)
 {
        int inc = 0x00010000;
        int tmp;
@@ -127,7 +127,7 @@ static __always_inline void __ticket_spin_lock(raw_spinlock_t *lock)
                     : "memory", "cc");
 }
 
-static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
+static __always_inline int __ticket_spin_trylock(arch_spinlock_t *lock)
 {
        int tmp;
        int new;
@@ -149,7 +149,7 @@ static __always_inline int __ticket_spin_trylock(raw_spinlock_t *lock)
        return tmp;
 }
 
-static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock)
+static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
 {
        asm volatile(UNLOCK_LOCK_PREFIX "incw %0"
                     : "+m" (lock->slock)
@@ -158,14 +158,14 @@ static __always_inline void __ticket_spin_unlock(raw_spinlock_t *lock)
 }
 #endif
 
-static inline int __ticket_spin_is_locked(raw_spinlock_t *lock)
+static inline int __ticket_spin_is_locked(arch_spinlock_t *lock)
 {
        int tmp = ACCESS_ONCE(lock->slock);
 
        return !!(((tmp >> TICKET_SHIFT) ^ tmp) & ((1 << TICKET_SHIFT) - 1));
 }
 
-static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
+static inline int __ticket_spin_is_contended(arch_spinlock_t *lock)
 {
        int tmp = ACCESS_ONCE(lock->slock);
 
@@ -174,43 +174,43 @@ static inline int __ticket_spin_is_contended(raw_spinlock_t *lock)
 
 #ifndef CONFIG_PARAVIRT_SPINLOCKS
 
-static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
+static inline int arch_spin_is_locked(arch_spinlock_t *lock)
 {
        return __ticket_spin_is_locked(lock);
 }
 
-static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
+static inline int arch_spin_is_contended(arch_spinlock_t *lock)
 {
        return __ticket_spin_is_contended(lock);
 }
-#define __raw_spin_is_contended        __raw_spin_is_contended
+#define arch_spin_is_contended arch_spin_is_contended
 
-static __always_inline void __raw_spin_lock(raw_spinlock_t *lock)
+static __always_inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        __ticket_spin_lock(lock);
 }
 
-static __always_inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static __always_inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        return __ticket_spin_trylock(lock);
 }
 
-static __always_inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static __always_inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        __ticket_spin_unlock(lock);
 }
 
-static __always_inline void __raw_spin_lock_flags(raw_spinlock_t *lock,
+static __always_inline void arch_spin_lock_flags(arch_spinlock_t *lock,
                                                  unsigned long flags)
 {
-       __raw_spin_lock(lock);
+       arch_spin_lock(lock);
 }
 
 #endif /* CONFIG_PARAVIRT_SPINLOCKS */
 
-static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
+static inline void arch_spin_unlock_wait(arch_spinlock_t *lock)
 {
-       while (__raw_spin_is_locked(lock))
+       while (arch_spin_is_locked(lock))
                cpu_relax();
 }
 
@@ -232,7 +232,7 @@ static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
  * read_can_lock - would read_trylock() succeed?
  * @lock: the rwlock in question.
  */
-static inline int __raw_read_can_lock(raw_rwlock_t *lock)
+static inline int arch_read_can_lock(arch_rwlock_t *lock)
 {
        return (int)(lock)->lock > 0;
 }
@@ -241,12 +241,12 @@ static inline int __raw_read_can_lock(raw_rwlock_t *lock)
  * write_can_lock - would write_trylock() succeed?
  * @lock: the rwlock in question.
  */
-static inline int __raw_write_can_lock(raw_rwlock_t *lock)
+static inline int arch_write_can_lock(arch_rwlock_t *lock)
 {
        return (lock)->lock == RW_LOCK_BIAS;
 }
 
-static inline void __raw_read_lock(raw_rwlock_t *rw)
+static inline void arch_read_lock(arch_rwlock_t *rw)
 {
        asm volatile(LOCK_PREFIX " subl $1,(%0)\n\t"
                     "jns 1f\n"
@@ -255,7 +255,7 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
                     ::LOCK_PTR_REG (rw) : "memory");
 }
 
-static inline void __raw_write_lock(raw_rwlock_t *rw)
+static inline void arch_write_lock(arch_rwlock_t *rw)
 {
        asm volatile(LOCK_PREFIX " subl %1,(%0)\n\t"
                     "jz 1f\n"
@@ -264,7 +264,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
                     ::LOCK_PTR_REG (rw), "i" (RW_LOCK_BIAS) : "memory");
 }
 
-static inline int __raw_read_trylock(raw_rwlock_t *lock)
+static inline int arch_read_trylock(arch_rwlock_t *lock)
 {
        atomic_t *count = (atomic_t *)lock;
 
@@ -274,7 +274,7 @@ static inline int __raw_read_trylock(raw_rwlock_t *lock)
        return 0;
 }
 
-static inline int __raw_write_trylock(raw_rwlock_t *lock)
+static inline int arch_write_trylock(arch_rwlock_t *lock)
 {
        atomic_t *count = (atomic_t *)lock;
 
@@ -284,23 +284,23 @@ static inline int __raw_write_trylock(raw_rwlock_t *lock)
        return 0;
 }
 
-static inline void __raw_read_unlock(raw_rwlock_t *rw)
+static inline void arch_read_unlock(arch_rwlock_t *rw)
 {
        asm volatile(LOCK_PREFIX "incl %0" :"+m" (rw->lock) : : "memory");
 }
 
-static inline void __raw_write_unlock(raw_rwlock_t *rw)
+static inline void arch_write_unlock(arch_rwlock_t *rw)
 {
        asm volatile(LOCK_PREFIX "addl %1, %0"
                     : "+m" (rw->lock) : "i" (RW_LOCK_BIAS) : "memory");
 }
 
-#define __raw_read_lock_flags(lock, flags) __raw_read_lock(lock)
-#define __raw_write_lock_flags(lock, flags) __raw_write_lock(lock)
+#define arch_read_lock_flags(lock, flags) arch_read_lock(lock)
+#define arch_write_lock_flags(lock, flags) arch_write_lock(lock)
 
-#define _raw_spin_relax(lock)  cpu_relax()
-#define _raw_read_relax(lock)  cpu_relax()
-#define _raw_write_relax(lock) cpu_relax()
+#define arch_spin_relax(lock)  cpu_relax()
+#define arch_read_relax(lock)  cpu_relax()
+#define arch_write_relax(lock) cpu_relax()
 
 /* The {read|write|spin}_lock() on x86 are full memory barriers. */
 static inline void smp_mb__after_lock(void) { }
index 845f81c87091b6d63075faefecc1d74a93c45d85..dcb48b2edc11dd4eee1c378b47db0805ababea3f 100644 (file)
@@ -5,16 +5,16 @@
 # error "please don't include this file directly"
 #endif
 
-typedef struct raw_spinlock {
+typedef struct arch_spinlock {
        unsigned int slock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED       { 0 }
+#define __ARCH_SPIN_LOCK_UNLOCKED      { 0 }
 
 typedef struct {
        unsigned int lock;
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED         { RW_LOCK_BIAS }
+#define __ARCH_RW_LOCK_UNLOCKED                { RW_LOCK_BIAS }
 
 #endif /* _ASM_X86_SPINLOCK_TYPES_H */
index cf86a5e73815dde6fb2e0fa997b8628555584063..35e89122a42f53191bdce81156417b305fe005ac 100644 (file)
@@ -5,6 +5,29 @@ extern int kstack_depth_to_print;
 
 int x86_is_stack_id(int id, char *name);
 
+struct thread_info;
+struct stacktrace_ops;
+
+typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
+                                     unsigned long *stack,
+                                     unsigned long bp,
+                                     const struct stacktrace_ops *ops,
+                                     void *data,
+                                     unsigned long *end,
+                                     int *graph);
+
+extern unsigned long
+print_context_stack(struct thread_info *tinfo,
+                   unsigned long *stack, unsigned long bp,
+                   const struct stacktrace_ops *ops, void *data,
+                   unsigned long *end, int *graph);
+
+extern unsigned long
+print_context_stack_bp(struct thread_info *tinfo,
+                      unsigned long *stack, unsigned long bp,
+                      const struct stacktrace_ops *ops, void *data,
+                      unsigned long *end, int *graph);
+
 /* Generic stack tracer with callbacks */
 
 struct stacktrace_ops {
@@ -14,6 +37,7 @@ struct stacktrace_ops {
        void (*address)(void *data, unsigned long address, int reliable);
        /* On negative return stop dumping */
        int (*stack)(void *data, char *name);
+       walk_stack_t    walk_stack;
 };
 
 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
index 87ffcb12a1b87c91b3ad9fd6f459b97ad222aa5c..8085277e1b8b62747f8d8e57dc1ce16d91214e8c 100644 (file)
@@ -5,13 +5,17 @@
 
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
-extern int pci_swiotlb_init(void);
+extern int __init pci_swiotlb_detect(void);
+extern void __init pci_swiotlb_init(void);
 #else
 #define swiotlb 0
-static inline int pci_swiotlb_init(void)
+static inline int pci_swiotlb_detect(void)
 {
        return 0;
 }
+static inline void pci_swiotlb_init(void)
+{
+}
 #endif
 
 static inline void dma_mark_clean(void *addr, size_t size) {}
index 4a5a089e1c6273c7d7a633a5be1b3e64c7e9a6db..d5f69045c100947290cb19f3d74afd8410464f2b 100644 (file)
@@ -30,7 +30,6 @@ struct mmap_arg_struct;
 asmlinkage long sys32_mmap(struct mmap_arg_struct __user *);
 asmlinkage long sys32_mprotect(unsigned long, size_t, unsigned long);
 
-asmlinkage long sys32_pipe(int __user *);
 struct sigaction32;
 struct old_sigaction32;
 asmlinkage long sys32_rt_sigaction(int, struct sigaction32 __user *,
index 1bb6e395881c3fb43dec70cad2aac7ac7aeb3b4e..8868b9420b0ea5ca67e2174812d4dceb86e5c5f7 100644 (file)
 /* Common in X86_32 and X86_64 */
 /* kernel/ioport.c */
 asmlinkage long sys_ioperm(unsigned long, unsigned long, int);
+long sys_iopl(unsigned int, struct pt_regs *);
 
 /* kernel/process.c */
 int sys_fork(struct pt_regs *);
 int sys_vfork(struct pt_regs *);
+long sys_execve(char __user *, char __user * __user *,
+               char __user * __user *, struct pt_regs *);
+long sys_clone(unsigned long, unsigned long, void __user *,
+              void __user *, struct pt_regs *);
 
 /* kernel/ldt.c */
 asmlinkage int sys_modify_ldt(int, void __user *, unsigned long);
 
 /* kernel/signal.c */
 long sys_rt_sigreturn(struct pt_regs *);
+long sys_sigaltstack(const stack_t __user *, stack_t __user *,
+                    struct pt_regs *);
+
 
 /* kernel/tls.c */
 asmlinkage int sys_set_thread_area(struct user_desc __user *);
@@ -35,18 +43,11 @@ asmlinkage int sys_get_thread_area(struct user_desc __user *);
 
 /* X86_32 only */
 #ifdef CONFIG_X86_32
-/* kernel/ioport.c */
-long sys_iopl(struct pt_regs *);
-
-/* kernel/process_32.c */
-int sys_clone(struct pt_regs *);
-int sys_execve(struct pt_regs *);
 
 /* kernel/signal.c */
 asmlinkage int sys_sigsuspend(int, int, old_sigset_t);
 asmlinkage int sys_sigaction(int, const struct old_sigaction __user *,
                             struct old_sigaction __user *);
-int sys_sigaltstack(struct pt_regs *);
 unsigned long sys_sigreturn(struct pt_regs *);
 
 /* kernel/sys_i386_32.c */
@@ -62,28 +63,15 @@ asmlinkage int sys_uname(struct old_utsname __user *);
 asmlinkage int sys_olduname(struct oldold_utsname __user *);
 
 /* kernel/vm86_32.c */
-int sys_vm86old(struct pt_regs *);
-int sys_vm86(struct pt_regs *);
+int sys_vm86old(struct vm86_struct __user *, struct pt_regs *);
+int sys_vm86(unsigned long, unsigned long, struct pt_regs *);
 
 #else /* CONFIG_X86_32 */
 
 /* X86_64 only */
-/* kernel/ioport.c */
-asmlinkage long sys_iopl(unsigned int, struct pt_regs *);
-
 /* kernel/process_64.c */
-asmlinkage long sys_clone(unsigned long, unsigned long,
-                         void __user *, void __user *,
-                         struct pt_regs *);
-asmlinkage long sys_execve(char __user *, char __user * __user *,
-                          char __user * __user *,
-                          struct pt_regs *);
 long sys_arch_prctl(int, unsigned long);
 
-/* kernel/signal.c */
-asmlinkage long sys_sigaltstack(const stack_t __user *, stack_t __user *,
-                               struct pt_regs *);
-
 /* kernel/sys_x86_64.c */
 struct new_utsname;
 
index 40e37b10c6c031ab86ccd08c2123e235e259a8de..c5087d7965871c5d9ec8e93d96c7fc4a8c5b3469 100644 (file)
 # endif
 #endif
 
-/* Node not present */
-#define NUMA_NO_NODE   (-1)
+/*
+ * to preserve the visibility of NUMA_NO_NODE definition,
+ * moved to there from here.  May be used independent of
+ * CONFIG_NUMA.
+ */
+#include <linux/numa.h>
 
 #ifdef CONFIG_NUMA
 #include <linux/cpumask.h>
+
 #include <asm/mpspec.h>
 
 #ifdef CONFIG_X86_32
index 7ed17ff502b9edd76afb96fe682609a4df1afffe..2751f3075d8bc746ad548cefe5543960956cc3bd 100644 (file)
@@ -76,15 +76,6 @@ union partition_info_u {
        };
 };
 
-union uv_watchlist_u {
-       u64     val;
-       struct {
-               u64     blade   : 16,
-                       size    : 32,
-                       filler  : 16;
-       };
-};
-
 enum uv_memprotect {
        UV_MEMPROT_RESTRICT_ACCESS,
        UV_MEMPROT_ALLOW_AMO,
@@ -100,7 +91,7 @@ extern s64 uv_bios_call_reentrant(enum uv_bios_cmd, u64, u64, u64, u64, u64);
 
 extern s64 uv_bios_get_sn_info(int, int *, long *, long *, long *);
 extern s64 uv_bios_freq_base(u64, u64 *);
-extern int uv_bios_mq_watchlist_alloc(int, unsigned long, unsigned int,
+extern int uv_bios_mq_watchlist_alloc(unsigned long, unsigned int,
                                        unsigned long *);
 extern int uv_bios_mq_watchlist_free(int, int);
 extern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect);
index d1414af9855961ff52a1a952908995eacfb57b69..bcdb708993d249540a2d27ab6d21ab511c7f51b4 100644 (file)
@@ -172,6 +172,8 @@ DECLARE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
 #define UV_LOCAL_MMR_SIZE              (64UL * 1024 * 1024)
 #define UV_GLOBAL_MMR32_SIZE           (64UL * 1024 * 1024)
 
+#define UV_GLOBAL_GRU_MMR_BASE         0x4000000
+
 #define UV_GLOBAL_MMR32_PNODE_SHIFT    15
 #define UV_GLOBAL_MMR64_PNODE_SHIFT    26
 
@@ -232,6 +234,26 @@ static inline unsigned long uv_gpa(void *v)
        return uv_soc_phys_ram_to_gpa(__pa(v));
 }
 
+/* Top two bits indicate the requested address is in MMR space.  */
+static inline int
+uv_gpa_in_mmr_space(unsigned long gpa)
+{
+       return (gpa >> 62) == 0x3UL;
+}
+
+/* UV global physical address --> socket phys RAM */
+static inline unsigned long uv_gpa_to_soc_phys_ram(unsigned long gpa)
+{
+       unsigned long paddr = gpa & uv_hub_info->gpa_mask;
+       unsigned long remap_base = uv_hub_info->lowmem_remap_base;
+       unsigned long remap_top =  uv_hub_info->lowmem_remap_top;
+
+       if (paddr >= remap_base && paddr < remap_base + remap_top)
+               paddr -= remap_base;
+       return paddr;
+}
+
+
 /* gnode -> pnode */
 static inline unsigned long uv_gpa_to_gnode(unsigned long gpa)
 {
@@ -307,6 +329,27 @@ static inline unsigned long uv_read_global_mmr64(int pnode,
        return readq(uv_global_mmr64_address(pnode, offset));
 }
 
+/*
+ * Global MMR space addresses when referenced by the GRU. (GRU does
+ * NOT use socket addressing).
+ */
+static inline unsigned long uv_global_gru_mmr_address(int pnode, unsigned long offset)
+{
+       return UV_GLOBAL_GRU_MMR_BASE | offset | (pnode << uv_hub_info->m_val);
+}
+
+static inline void uv_write_global_mmr8(int pnode, unsigned long offset,
+                               unsigned char val)
+{
+       writeb(val, uv_global_mmr64_address(pnode, offset));
+}
+
+static inline unsigned char uv_read_global_mmr8(int pnode,
+                                                unsigned long offset)
+{
+       return readb(uv_global_mmr64_address(pnode, offset));
+}
+
 /*
  * Access hub local MMRs. Faster than using global space but only local MMRs
  * are accessible.
@@ -426,14 +469,28 @@ static inline void uv_set_scir_bits(unsigned char value)
        }
 }
 
+static inline unsigned long uv_scir_offset(int apicid)
+{
+       return SCIR_LOCAL_MMR_BASE | (apicid & 0x3f);
+}
+
 static inline void uv_set_cpu_scir_bits(int cpu, unsigned char value)
 {
        if (uv_cpu_hub_info(cpu)->scir.state != value) {
+               uv_write_global_mmr8(uv_cpu_to_pnode(cpu),
+                               uv_cpu_hub_info(cpu)->scir.offset, value);
                uv_cpu_hub_info(cpu)->scir.state = value;
-               uv_write_local_mmr8(uv_cpu_hub_info(cpu)->scir.offset, value);
        }
 }
 
+static unsigned long uv_hub_ipi_value(int apicid, int vector, int mode)
+{
+       return (1UL << UVH_IPI_INT_SEND_SHFT) |
+                       ((apicid) << UVH_IPI_INT_APIC_ID_SHFT) |
+                       (mode << UVH_IPI_INT_DELIVERY_MODE_SHFT) |
+                       (vector << UVH_IPI_INT_VECTOR_SHFT);
+}
+
 static inline void uv_hub_send_ipi(int pnode, int apicid, int vector)
 {
        unsigned long val;
@@ -442,10 +499,7 @@ static inline void uv_hub_send_ipi(int pnode, int apicid, int vector)
        if (vector == NMI_VECTOR)
                dmode = dest_NMI;
 
-       val = (1UL << UVH_IPI_INT_SEND_SHFT) |
-                       ((apicid) << UVH_IPI_INT_APIC_ID_SHFT) |
-                       (dmode << UVH_IPI_INT_DELIVERY_MODE_SHFT) |
-                       (vector << UVH_IPI_INT_VECTOR_SHFT);
+       val = uv_hub_ipi_value(apicid, vector, dmode);
        uv_write_global_mmr64(pnode, UVH_IPI_INT, val);
 }
 
index 4f2e66e29ecc5cc35e749f18e194b2ad11f398d2..d87f09bc5a524952e7ff7f920f75306b2984c608 100644 (file)
@@ -89,7 +89,6 @@ obj-$(CONFIG_EARLY_PRINTK)    += early_printk.o
 obj-$(CONFIG_HPET_TIMER)       += hpet.o
 
 obj-$(CONFIG_K8_NB)            += k8.o
-obj-$(CONFIG_MGEODE_LX)                += geode_32.o mfgpt_32.o
 obj-$(CONFIG_DEBUG_RODATA_TEST)        += test_rodata.o
 obj-$(CONFIG_DEBUG_NX_TEST)    += test_nx.o
 
index fd5ca97a2ad5e017b48be06e23175d007cc85572..6f35260bb3ef30ac4c05e1f7beda99450a753739 100644 (file)
@@ -4,7 +4,7 @@ obj-$(CONFIG_ACPI)              += boot.o
 obj-$(CONFIG_ACPI_SLEEP)       += sleep.o wakeup_rm.o wakeup_$(BITS).o
 
 ifneq ($(CONFIG_ACPI_PROCESSOR),)
-obj-y                          += cstate.o processor.o
+obj-y                          += cstate.o
 endif
 
 $(obj)/wakeup_rm.o:    $(obj)/realmode/wakeup.bin
index 59cdfa4686b2bf4ad7ceae1ab680265effe901aa..2e837f5080fe56d3ad0c87d308564cf157147624 100644 (file)
@@ -48,7 +48,7 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
         * P4, Core and beyond CPUs
         */
        if (c->x86_vendor == X86_VENDOR_INTEL &&
-           (c->x86 > 0xf || (c->x86 == 6 && c->x86_model >= 14)))
+           (c->x86 > 0xf || (c->x86 == 6 && c->x86_model >= 0x0f)))
                        flags->bm_control = 0;
 }
 EXPORT_SYMBOL(acpi_processor_power_init_bm_check);
diff --git a/arch/x86/kernel/acpi/processor.c b/arch/x86/kernel/acpi/processor.c
deleted file mode 100644 (file)
index d85d1b2..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2005 Intel Corporation
- *     Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
- *     - Added _PDC for platforms with Intel CPUs
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/acpi.h>
-
-#include <acpi/processor.h>
-#include <asm/acpi.h>
-
-static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c)
-{
-       struct acpi_object_list *obj_list;
-       union acpi_object *obj;
-       u32 *buf;
-
-       /* allocate and initialize pdc. It will be used later. */
-       obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
-       if (!obj_list) {
-               printk(KERN_ERR "Memory allocation error\n");
-               return;
-       }
-
-       obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
-       if (!obj) {
-               printk(KERN_ERR "Memory allocation error\n");
-               kfree(obj_list);
-               return;
-       }
-
-       buf = kmalloc(12, GFP_KERNEL);
-       if (!buf) {
-               printk(KERN_ERR "Memory allocation error\n");
-               kfree(obj);
-               kfree(obj_list);
-               return;
-       }
-
-       buf[0] = ACPI_PDC_REVISION_ID;
-       buf[1] = 1;
-       buf[2] = ACPI_PDC_C_CAPABILITY_SMP;
-
-       /*
-        * The default of PDC_SMP_T_SWCOORD bit is set for intel x86 cpu so
-        * that OSPM is capable of native ACPI throttling software
-        * coordination using BIOS supplied _TSD info.
-        */
-       buf[2] |= ACPI_PDC_SMP_T_SWCOORD;
-       if (cpu_has(c, X86_FEATURE_EST))
-               buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
-
-       if (cpu_has(c, X86_FEATURE_ACPI))
-               buf[2] |= ACPI_PDC_T_FFH;
-
-       /*
-        * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
-        */
-       if (!cpu_has(c, X86_FEATURE_MWAIT))
-               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
-
-       obj->type = ACPI_TYPE_BUFFER;
-       obj->buffer.length = 12;
-       obj->buffer.pointer = (u8 *) buf;
-       obj_list->count = 1;
-       obj_list->pointer = obj;
-       pr->pdc = obj_list;
-
-       return;
-}
-
-
-/* Initialize _PDC data based on the CPU vendor */
-void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
-{
-       struct cpuinfo_x86 *c = &cpu_data(pr->id);
-
-       pr->pdc = NULL;
-       if (c->x86_vendor == X86_VENDOR_INTEL ||
-           c->x86_vendor == X86_VENDOR_CENTAUR)
-               init_intel_pdc(pr, c);
-
-       return;
-}
-
-EXPORT_SYMBOL(arch_acpi_processor_init_pdc);
-
-void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr)
-{
-       if (pr->pdc) {
-               kfree(pr->pdc->pointer->buffer.pointer);
-               kfree(pr->pdc->pointer);
-               kfree(pr->pdc);
-               pr->pdc = NULL;
-       }
-}
-
-EXPORT_SYMBOL(arch_acpi_processor_cleanup_pdc);
index 82e508677b91116ec8428e434ae164a8390084bf..f9961034e55793b1619edac03f2e34ed57ef7798 100644 (file)
@@ -162,6 +162,8 @@ static int __init acpi_sleep_setup(char *str)
 #endif
                if (strncmp(str, "old_ordering", 12) == 0)
                        acpi_old_suspend_ordering();
+               if (strncmp(str, "sci_force_enable", 16) == 0)
+                       acpi_set_sci_en_on_resume();
                str = strchr(str, ',');
                if (str != NULL)
                        str += strspn(str, ", \t");
index b990b5cc95418df45f1c94f1b748cb5d59d45e1c..23824fef789cb458d909b12ffd7e9e9ffe1bc53e 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <linux/pci.h>
 #include <linux/gfp.h>
-#include <linux/bitops.h>
+#include <linux/bitmap.h>
 #include <linux/debugfs.h>
 #include <linux/scatterlist.h>
 #include <linux/dma-mapping.h>
@@ -1162,7 +1162,7 @@ static void dma_ops_free_addresses(struct dma_ops_domain *dom,
 
        address = (address % APERTURE_RANGE_SIZE) >> PAGE_SHIFT;
 
-       iommu_area_free(range->bitmap, address, pages);
+       bitmap_clear(range->bitmap, address, pages);
 
 }
 
index d0c99abc26c32a8f0df48d61485b1f36acb9b4b2..eacbd2b31d27c0b947c3949c2ece59b549c9007a 100644 (file)
@@ -306,10 +306,7 @@ physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
                if (cpumask_test_cpu(cpu, cpu_online_mask))
                        break;
        }
-       if (cpu < nr_cpu_ids)
-               return per_cpu(x86_cpu_to_apicid, cpu);
-
-       return BAD_APICID;
+       return per_cpu(x86_cpu_to_apicid, cpu);
 }
 
 struct apic apic_physflat =  {
index 38dcecfa5818e4111df1bdabb0145b5daefe869f..cb804c5091b941e8b362a5abc0f2ab44fb16c943 100644 (file)
@@ -131,10 +131,7 @@ static unsigned int bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
                if (cpumask_test_cpu(cpu, cpu_online_mask))
                        break;
        }
-       if (cpu < nr_cpu_ids)
-               return bigsmp_cpu_to_logical_apicid(cpu);
-
-       return BAD_APICID;
+       return bigsmp_cpu_to_logical_apicid(cpu);
 }
 
 static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)
index d5d498fbee4bf33db826aa21e3febd8be8d39262..de00c4619a55b85060a362a5640b141a7492d501 100644 (file)
@@ -2276,26 +2276,28 @@ static void __target_IO_APIC_irq(unsigned int irq, unsigned int dest, struct irq
 
 /*
  * Either sets desc->affinity to a valid value, and returns
- * ->cpu_mask_to_apicid of that, or returns BAD_APICID and
+ * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and
  * leaves desc->affinity untouched.
  */
 unsigned int
-set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask)
+set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask,
+                 unsigned int *dest_id)
 {
        struct irq_cfg *cfg;
        unsigned int irq;
 
        if (!cpumask_intersects(mask, cpu_online_mask))
-               return BAD_APICID;
+               return -1;
 
        irq = desc->irq;
        cfg = desc->chip_data;
        if (assign_irq_vector(irq, cfg, mask))
-               return BAD_APICID;
+               return -1;
 
        cpumask_copy(desc->affinity, mask);
 
-       return apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain);
+       *dest_id = apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain);
+       return 0;
 }
 
 static int
@@ -2311,12 +2313,11 @@ set_ioapic_affinity_irq_desc(struct irq_desc *desc, const struct cpumask *mask)
        cfg = desc->chip_data;
 
        spin_lock_irqsave(&ioapic_lock, flags);
-       dest = set_desc_affinity(desc, mask);
-       if (dest != BAD_APICID) {
+       ret = set_desc_affinity(desc, mask, &dest);
+       if (!ret) {
                /* Only the high 8 bits are valid. */
                dest = SET_APIC_LOGICAL_ID(dest);
                __target_IO_APIC_irq(irq, dest, cfg);
-               ret = 0;
        }
        spin_unlock_irqrestore(&ioapic_lock, flags);
 
@@ -2431,7 +2432,7 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void)
                        continue;
 
                cfg = irq_cfg(irq);
-               spin_lock(&desc->lock);
+               raw_spin_lock(&desc->lock);
 
                if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain))
                        goto unlock;
@@ -2450,7 +2451,7 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void)
                }
                __get_cpu_var(vector_irq)[vector] = -1;
 unlock:
-               spin_unlock(&desc->lock);
+               raw_spin_unlock(&desc->lock);
        }
 
        irq_exit();
@@ -3351,8 +3352,7 @@ static int set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask)
        struct msi_msg msg;
        unsigned int dest;
 
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
 
        cfg = desc->chip_data;
@@ -3384,8 +3384,7 @@ ir_set_msi_irq_affinity(unsigned int irq, const struct cpumask *mask)
        if (get_irte(irq, &irte))
                return -1;
 
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
 
        irte.vector = cfg->vector;
@@ -3567,8 +3566,7 @@ static int dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask)
        struct msi_msg msg;
        unsigned int dest;
 
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
 
        cfg = desc->chip_data;
@@ -3623,8 +3621,7 @@ static int hpet_msi_set_affinity(unsigned int irq, const struct cpumask *mask)
        struct msi_msg msg;
        unsigned int dest;
 
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
 
        cfg = desc->chip_data;
@@ -3730,8 +3727,7 @@ static int set_ht_irq_affinity(unsigned int irq, const struct cpumask *mask)
        struct irq_cfg *cfg;
        unsigned int dest;
 
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
 
        cfg = desc->chip_data;
index a5371ec367769a83b321c23eed6c8d2fde403797..cf69c59f491011c0856da6d298192e667ab2a418 100644 (file)
@@ -148,10 +148,7 @@ x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
                        break;
        }
 
-       if (cpu < nr_cpu_ids)
-               return per_cpu(x86_cpu_to_logical_apicid, cpu);
-
-       return BAD_APICID;
+       return per_cpu(x86_cpu_to_logical_apicid, cpu);
 }
 
 static unsigned int x2apic_cluster_phys_get_apic_id(unsigned long x)
index a8989aadc99a5906fc514bcfa863c728143dd2fb..8972f38c5ced332333ac014249f2a29ef335001b 100644 (file)
@@ -146,10 +146,7 @@ x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
                        break;
        }
 
-       if (cpu < nr_cpu_ids)
-               return per_cpu(x86_cpu_to_apicid, cpu);
-
-       return BAD_APICID;
+       return per_cpu(x86_cpu_to_apicid, cpu);
 }
 
 static unsigned int x2apic_phys_get_apic_id(unsigned long x)
index b684bb303cbffc5fa494e69661c9eab5b3467fd6..5f92494dab613b9fff4c987b270fed149e4e90f9 100644 (file)
@@ -225,10 +225,7 @@ uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
                if (cpumask_test_cpu(cpu, cpu_online_mask))
                        break;
        }
-       if (cpu < nr_cpu_ids)
-               return per_cpu(x86_cpu_to_apicid, cpu);
-
-       return BAD_APICID;
+       return per_cpu(x86_cpu_to_apicid, cpu);
 }
 
 static unsigned int x2apic_get_apic_id(unsigned long x)
@@ -632,8 +629,10 @@ void __init uv_system_init(void)
        uv_rtc_init();
 
        for_each_present_cpu(cpu) {
+               int apicid = per_cpu(x86_cpu_to_apicid, cpu);
+
                nid = cpu_to_node(cpu);
-               pnode = uv_apicid_to_pnode(per_cpu(x86_cpu_to_apicid, cpu));
+               pnode = uv_apicid_to_pnode(apicid);
                blade = boot_pnode_to_blade(pnode);
                lcpu = uv_blade_info[blade].nr_possible_cpus;
                uv_blade_info[blade].nr_possible_cpus++;
@@ -654,15 +653,13 @@ void __init uv_system_init(void)
                uv_cpu_hub_info(cpu)->gnode_extra = gnode_extra;
                uv_cpu_hub_info(cpu)->global_mmr_base = mmr_base;
                uv_cpu_hub_info(cpu)->coherency_domain_number = sn_coherency_id;
-               uv_cpu_hub_info(cpu)->scir.offset = SCIR_LOCAL_MMR_BASE + lcpu;
+               uv_cpu_hub_info(cpu)->scir.offset = uv_scir_offset(apicid);
                uv_node_to_blade[nid] = blade;
                uv_cpu_to_blade[cpu] = blade;
                max_pnode = max(pnode, max_pnode);
 
-               printk(KERN_DEBUG "UV: cpu %d, apicid 0x%x, pnode %d, nid %d, "
-                       "lcpu %d, blade %d\n",
-                       cpu, per_cpu(x86_cpu_to_apicid, cpu), pnode, nid,
-                       lcpu, blade);
+               printk(KERN_DEBUG "UV: cpu %d, apicid 0x%x, pnode %d, nid %d, lcpu %d, blade %d\n",
+                       cpu, apicid, pnode, nid, lcpu, blade);
        }
 
        /* Add blade/pnode info for nodes without cpus */
index 63a88e1f987d35b9ff94ccbd2d53d499b5c783ee..b0206a211b09db5bb050fdd56775add9bbb80e43 100644 (file)
@@ -101,21 +101,17 @@ s64 uv_bios_get_sn_info(int fc, int *uvtype, long *partid, long *coher,
 }
 
 int
-uv_bios_mq_watchlist_alloc(int blade, unsigned long addr, unsigned int mq_size,
+uv_bios_mq_watchlist_alloc(unsigned long addr, unsigned int mq_size,
                           unsigned long *intr_mmr_offset)
 {
-       union uv_watchlist_u size_blade;
        u64 watchlist;
        s64 ret;
 
-       size_blade.size = mq_size;
-       size_blade.blade = blade;
-
        /*
         * bios returns watchlist number or negative error number.
         */
        ret = (int)uv_bios_call_irqsave(UV_BIOS_WATCHLIST_ALLOC, addr,
-                       size_blade.val, (u64)intr_mmr_offset,
+                       mq_size, (u64)intr_mmr_offset,
                        (u64)&watchlist, 0);
        if (ret < BIOS_STATUS_SUCCESS)
                return ret;
index 8dc3ea145c975a3eebfbb1510f30c9ffa7b48e06..e485825130d2c8ee9b5d278717deca21ae2116f4 100644 (file)
@@ -254,59 +254,36 @@ static int __cpuinit nearby_node(int apicid)
 
 /*
  * Fixup core topology information for AMD multi-node processors.
- * Assumption 1: Number of cores in each internal node is the same.
- * Assumption 2: Mixed systems with both single-node and dual-node
- *               processors are not supported.
+ * Assumption: Number of cores in each internal node is the same.
  */
 #ifdef CONFIG_X86_HT
 static void __cpuinit amd_fixup_dcm(struct cpuinfo_x86 *c)
 {
-#ifdef CONFIG_PCI
-       u32 t, cpn;
-       u8 n, n_id;
+       unsigned long long value;
+       u32 nodes, cores_per_node;
        int cpu = smp_processor_id();
 
+       if (!cpu_has(c, X86_FEATURE_NODEID_MSR))
+               return;
+
        /* fixup topology information only once for a core */
        if (cpu_has(c, X86_FEATURE_AMD_DCM))
                return;
 
-       /* check for multi-node processor on boot cpu */
-       t = read_pci_config(0, 24, 3, 0xe8);
-       if (!(t & (1 << 29)))
+       rdmsrl(MSR_FAM10H_NODE_ID, value);
+
+       nodes = ((value >> 3) & 7) + 1;
+       if (nodes == 1)
                return;
 
        set_cpu_cap(c, X86_FEATURE_AMD_DCM);
+       cores_per_node = c->x86_max_cores / nodes;
 
-       /* cores per node: each internal node has half the number of cores */
-       cpn = c->x86_max_cores >> 1;
+       /* store NodeID, use llc_shared_map to store sibling info */
+       per_cpu(cpu_llc_id, cpu) = value & 7;
 
-       /* even-numbered NB_id of this dual-node processor */
-       n = c->phys_proc_id << 1;
-
-       /*
-        * determine internal node id and assign cores fifty-fifty to
-        * each node of the dual-node processor
-        */
-       t = read_pci_config(0, 24 + n, 3, 0xe8);
-       n = (t>>30) & 0x3;
-       if (n == 0) {
-               if (c->cpu_core_id < cpn)
-                       n_id = 0;
-               else
-                       n_id = 1;
-       } else {
-               if (c->cpu_core_id < cpn)
-                       n_id = 1;
-               else
-                       n_id = 0;
-       }
-
-       /* compute entire NodeID, use llc_shared_map to store sibling info */
-       per_cpu(cpu_llc_id, cpu) = (c->phys_proc_id << 1) + n_id;
-
-       /* fixup core id to be in range from 0 to cpn */
-       c->cpu_core_id = c->cpu_core_id % cpn;
-#endif
+       /* fixup core id to be in range from 0 to (cores_per_node - 1) */
+       c->cpu_core_id = c->cpu_core_id % cores_per_node;
 }
 #endif
 
index f28decf8dde3990626f493e5d962bfea9d48e59f..1b1920fa7c8085934cbd846e9329cc538c25be4b 100644 (file)
@@ -190,9 +190,11 @@ static void do_drv_write(void *_cmd)
 
 static void drv_read(struct drv_cmd *cmd)
 {
+       int err;
        cmd->val = 0;
 
-       smp_call_function_single(cpumask_any(cmd->mask), do_drv_read, cmd, 1);
+       err = smp_call_function_any(cmd->mask, do_drv_read, cmd, 1);
+       WARN_ON_ONCE(err);      /* smp_call_function_any() was buggy? */
 }
 
 static void drv_write(struct drv_cmd *cmd)
index a9df9441a9a240cd138b6492896cc0788a04cf1b..f125e5c551c0db827d33110dfd0d25688053e3c7 100644 (file)
@@ -1136,7 +1136,7 @@ static int powernowk8_target(struct cpufreq_policy *pol,
        if (!alloc_cpumask_var(&oldmask, GFP_KERNEL))
                return -ENOMEM;
 
-       cpumask_copy(oldmask, tsk_cpumask(current));
+       cpumask_copy(oldmask, tsk_cpus_allowed(current));
        set_cpus_allowed_ptr(current, cpumask_of(pol->cpu));
 
        if (smp_processor_id() != pol->cpu) {
index 9c31e8b09d2c2676c29f87a68442e56878d6bece..879666f4d871c99a312169bd30aad71049713572 100644 (file)
@@ -70,7 +70,6 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
        if (c->x86_power & (1 << 8)) {
                set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
                set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
-               set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE);
                sched_clock_stable = 1;
        }
 
index 472763d9209841dd247c9052bb29144b8682b097..73734baa50f2200e6925104fbc9f9c2f057ea9a1 100644 (file)
@@ -74,7 +74,7 @@ static void raise_exception(struct mce *m, struct pt_regs *pregs)
        m->finished = 0;
 }
 
-static cpumask_t mce_inject_cpumask;
+static cpumask_var_t mce_inject_cpumask;
 
 static int mce_raise_notify(struct notifier_block *self,
                            unsigned long val, void *data)
@@ -82,9 +82,9 @@ static int mce_raise_notify(struct notifier_block *self,
        struct die_args *args = (struct die_args *)data;
        int cpu = smp_processor_id();
        struct mce *m = &__get_cpu_var(injectm);
-       if (val != DIE_NMI_IPI || !cpu_isset(cpu, mce_inject_cpumask))
+       if (val != DIE_NMI_IPI || !cpumask_test_cpu(cpu, mce_inject_cpumask))
                return NOTIFY_DONE;
-       cpu_clear(cpu, mce_inject_cpumask);
+       cpumask_clear_cpu(cpu, mce_inject_cpumask);
        if (m->inject_flags & MCJ_EXCEPTION)
                raise_exception(m, args->regs);
        else if (m->status)
@@ -148,22 +148,22 @@ static void raise_mce(struct mce *m)
                unsigned long start;
                int cpu;
                get_online_cpus();
-               mce_inject_cpumask = cpu_online_map;
-               cpu_clear(get_cpu(), mce_inject_cpumask);
+               cpumask_copy(mce_inject_cpumask, cpu_online_mask);
+               cpumask_clear_cpu(get_cpu(), mce_inject_cpumask);
                for_each_online_cpu(cpu) {
                        struct mce *mcpu = &per_cpu(injectm, cpu);
                        if (!mcpu->finished ||
                            MCJ_CTX(mcpu->inject_flags) != MCJ_CTX_RANDOM)
-                               cpu_clear(cpu, mce_inject_cpumask);
+                               cpumask_clear_cpu(cpu, mce_inject_cpumask);
                }
-               if (!cpus_empty(mce_inject_cpumask))
-                       apic->send_IPI_mask(&mce_inject_cpumask, NMI_VECTOR);
+               if (!cpumask_empty(mce_inject_cpumask))
+                       apic->send_IPI_mask(mce_inject_cpumask, NMI_VECTOR);
                start = jiffies;
-               while (!cpus_empty(mce_inject_cpumask)) {
+               while (!cpumask_empty(mce_inject_cpumask)) {
                        if (!time_before(jiffies, start + 2*HZ)) {
                                printk(KERN_ERR
                                "Timeout waiting for mce inject NMI %lx\n",
-                                       *cpus_addr(mce_inject_cpumask));
+                                       *cpumask_bits(mce_inject_cpumask));
                                break;
                        }
                        cpu_relax();
@@ -210,6 +210,8 @@ static ssize_t mce_write(struct file *filp, const char __user *ubuf,
 
 static int inject_init(void)
 {
+       if (!alloc_cpumask_var(&mce_inject_cpumask, GFP_KERNEL))
+               return -ENOMEM;
        printk(KERN_INFO "Machine check injector initialized\n");
        mce_chrdev_ops.write = mce_write;
        register_die_notifier(&mce_raise_nb);
index 3c1b12d461d151303d6e2787c5aa9fddc078c1ad..e006e56f699c24d1fe193a307bf799fda3801c6d 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/proc_fs.h>
 #include <linux/module.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/init.h>
 
 #define LINE_SIZE 80
@@ -133,8 +134,7 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
                return -EINVAL;
 
        base = simple_strtoull(line + 5, &ptr, 0);
-       while (isspace(*ptr))
-               ptr++;
+       ptr = skip_spaces(ptr);
 
        if (strncmp(ptr, "size=", 5))
                return -EINVAL;
@@ -142,14 +142,11 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
        size = simple_strtoull(ptr + 5, &ptr, 0);
        if ((base & 0xfff) || (size & 0xfff))
                return -EINVAL;
-       while (isspace(*ptr))
-               ptr++;
+       ptr = skip_spaces(ptr);
 
        if (strncmp(ptr, "type=", 5))
                return -EINVAL;
-       ptr += 5;
-       while (isspace(*ptr))
-               ptr++;
+       ptr = skip_spaces(ptr + 5);
 
        for (i = 0; i < MTRR_NUM_TYPES; ++i) {
                if (strcmp(ptr, mtrr_strings[i]))
index 45506d5dd8df7e06f0e35ae8c0db18927ffc00e6..c223b7e895d9722d720790bd1452d994b7f4d9e0 100644 (file)
@@ -2336,6 +2336,7 @@ static const struct stacktrace_ops backtrace_ops = {
        .warning_symbol         = backtrace_warning_symbol,
        .stack                  = backtrace_stack,
        .address                = backtrace_address,
+       .walk_stack             = print_context_stack_bp,
 };
 
 #include "../dumpstack.h"
index 7ef24a796992b6b39ccbb7894b72301ecd80645a..cb27fd6136c9bec099b0a944ee59a8425d39d09c 100644 (file)
@@ -187,7 +187,8 @@ static int __init cpuid_init(void)
        int i, err = 0;
        i = 0;
 
-       if (register_chrdev(CPUID_MAJOR, "cpu/cpuid", &cpuid_fops)) {
+       if (__register_chrdev(CPUID_MAJOR, 0, NR_CPUS,
+                             "cpu/cpuid", &cpuid_fops)) {
                printk(KERN_ERR "cpuid: unable to get major %d for cpuid\n",
                       CPUID_MAJOR);
                err = -EBUSY;
@@ -216,7 +217,7 @@ out_class:
        }
        class_destroy(cpuid_class);
 out_chrdev:
-       unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
+       __unregister_chrdev(CPUID_MAJOR, 0, NR_CPUS, "cpu/cpuid");
 out:
        return err;
 }
index b8ce165dde5dc42f4a4b0e8c9a1cc53ade630bfa..c56bc2873030d65d35e9c97f7b50e990ad4de2f9 100644 (file)
@@ -109,6 +109,30 @@ print_context_stack(struct thread_info *tinfo,
        }
        return bp;
 }
+EXPORT_SYMBOL_GPL(print_context_stack);
+
+unsigned long
+print_context_stack_bp(struct thread_info *tinfo,
+                      unsigned long *stack, unsigned long bp,
+                      const struct stacktrace_ops *ops, void *data,
+                      unsigned long *end, int *graph)
+{
+       struct stack_frame *frame = (struct stack_frame *)bp;
+       unsigned long *ret_addr = &frame->return_address;
+
+       while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
+               unsigned long addr = *ret_addr;
+
+               if (__kernel_text_address(addr)) {
+                       ops->address(data, addr, 1);
+                       frame = frame->next_frame;
+                       ret_addr = &frame->return_address;
+                       print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
+               }
+       }
+       return (unsigned long)frame;
+}
+EXPORT_SYMBOL_GPL(print_context_stack_bp);
 
 
 static void
@@ -141,10 +165,11 @@ static void print_trace_address(void *data, unsigned long addr, int reliable)
 }
 
 static const struct stacktrace_ops print_trace_ops = {
-       .warning = print_trace_warning,
-       .warning_symbol = print_trace_warning_symbol,
-       .stack = print_trace_stack,
-       .address = print_trace_address,
+       .warning                = print_trace_warning,
+       .warning_symbol         = print_trace_warning_symbol,
+       .stack                  = print_trace_stack,
+       .address                = print_trace_address,
+       .walk_stack             = print_context_stack,
 };
 
 void
@@ -188,7 +213,7 @@ void dump_stack(void)
 }
 EXPORT_SYMBOL(dump_stack);
 
-static raw_spinlock_t die_lock = __RAW_SPIN_LOCK_UNLOCKED;
+static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
 static int die_owner = -1;
 static unsigned int die_nest_count;
 
@@ -207,11 +232,11 @@ unsigned __kprobes long oops_begin(void)
        /* racy, but better than risking deadlock. */
        raw_local_irq_save(flags);
        cpu = smp_processor_id();
-       if (!__raw_spin_trylock(&die_lock)) {
+       if (!arch_spin_trylock(&die_lock)) {
                if (cpu == die_owner)
                        /* nested oops. should stop eventually */;
                else
-                       __raw_spin_lock(&die_lock);
+                       arch_spin_lock(&die_lock);
        }
        die_nest_count++;
        die_owner = cpu;
@@ -231,7 +256,7 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
        die_nest_count--;
        if (!die_nest_count)
                /* Nest count reaches zero, release the lock. */
-               __raw_spin_unlock(&die_lock);
+               arch_spin_unlock(&die_lock);
        raw_local_irq_restore(flags);
        oops_exit();
 
index 81086c227ab7cafe28c0c608f1b3eb2bce72b1c0..4fd1420faffa4fd747d8de2844c8d7278b79587c 100644 (file)
 #define get_bp(bp) asm("movq %%rbp, %0" : "=r" (bp) :)
 #endif
 
-extern unsigned long
-print_context_stack(struct thread_info *tinfo,
-               unsigned long *stack, unsigned long bp,
-               const struct stacktrace_ops *ops, void *data,
-               unsigned long *end, int *graph);
-
 extern void
 show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
                unsigned long *stack, unsigned long bp, char *log_lvl);
index e0ed4c7abb626e13f8f87d735b40576f6b44bb8e..ae775ca47b25c463fb8688cd4e47a92efa6a1a1e 100644 (file)
@@ -58,7 +58,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
 
                context = (struct thread_info *)
                        ((unsigned long)stack & (~(THREAD_SIZE - 1)));
-               bp = print_context_stack(context, stack, bp, ops, data, NULL, &graph);
+               bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
 
                stack = (unsigned long *)context->previous_esp;
                if (!stack)
index b13af53883aabe04504b402739a280bacf087424..0ad9597073f5a53aabb5f3dbbd85ea4cae947d60 100644 (file)
@@ -188,8 +188,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
                        if (ops->stack(data, id) < 0)
                                break;
 
-                       bp = print_context_stack(tinfo, stack, bp, ops,
-                                                data, estack_end, &graph);
+                       bp = ops->walk_stack(tinfo, stack, bp, ops,
+                                            data, estack_end, &graph);
                        ops->stack(data, "<EOE>");
                        /*
                         * We link to the next stack via the
index f50447d961c0fc1b1ff3a8e7e7283663863c558f..05ed7ab2ca489578c9433930f9df0f03f7526375 100644 (file)
@@ -724,7 +724,7 @@ core_initcall(e820_mark_nvs_memory);
 /*
  * Early reserved memory areas.
  */
-#define MAX_EARLY_RES 20
+#define MAX_EARLY_RES 32
 
 struct early_res {
        u64 start, end;
index 50b9c220e1213ceacf48e10f4f302a98b65ced4f..44a8e0dc6737d9f28ba0fe258655e0d43b02226d 100644 (file)
@@ -725,22 +725,61 @@ END(syscall_badsys)
 /*
  * System calls that need a pt_regs pointer.
  */
-#define PTREGSCALL(name) \
+#define PTREGSCALL0(name) \
        ALIGN; \
 ptregs_##name: \
        leal 4(%esp),%eax; \
        jmp sys_##name;
 
-PTREGSCALL(iopl)
-PTREGSCALL(fork)
-PTREGSCALL(clone)
-PTREGSCALL(vfork)
-PTREGSCALL(execve)
-PTREGSCALL(sigaltstack)
-PTREGSCALL(sigreturn)
-PTREGSCALL(rt_sigreturn)
-PTREGSCALL(vm86)
-PTREGSCALL(vm86old)
+#define PTREGSCALL1(name) \
+       ALIGN; \
+ptregs_##name: \
+       leal 4(%esp),%edx; \
+       movl (PT_EBX+4)(%esp),%eax; \
+       jmp sys_##name;
+
+#define PTREGSCALL2(name) \
+       ALIGN; \
+ptregs_##name: \
+       leal 4(%esp),%ecx; \
+       movl (PT_ECX+4)(%esp),%edx; \
+       movl (PT_EBX+4)(%esp),%eax; \
+       jmp sys_##name;
+
+#define PTREGSCALL3(name) \
+       ALIGN; \
+ptregs_##name: \
+       leal 4(%esp),%eax; \
+       pushl %eax; \
+       movl PT_EDX(%eax),%ecx; \
+       movl PT_ECX(%eax),%edx; \
+       movl PT_EBX(%eax),%eax; \
+       call sys_##name; \
+       addl $4,%esp; \
+       ret
+
+PTREGSCALL1(iopl)
+PTREGSCALL0(fork)
+PTREGSCALL0(vfork)
+PTREGSCALL3(execve)
+PTREGSCALL2(sigaltstack)
+PTREGSCALL0(sigreturn)
+PTREGSCALL0(rt_sigreturn)
+PTREGSCALL2(vm86)
+PTREGSCALL1(vm86old)
+
+/* Clone is an oddball.  The 4th arg is in %edi */
+       ALIGN;
+ptregs_clone:
+       leal 4(%esp),%eax
+       pushl %eax
+       pushl PT_EDI(%eax)
+       movl PT_EDX(%eax),%ecx
+       movl PT_ECX(%eax),%edx
+       movl PT_EBX(%eax),%eax
+       call sys_clone
+       addl $8,%esp
+       ret
 
 .macro FIXUP_ESPFIX_STACK
 /*
@@ -1008,12 +1047,8 @@ END(spurious_interrupt_bug)
 ENTRY(kernel_thread_helper)
        pushl $0                # fake return address for unwinder
        CFI_STARTPROC
-       movl %edx,%eax
-       push %edx
-       CFI_ADJUST_CFA_OFFSET 4
-       call *%ebx
-       push %eax
-       CFI_ADJUST_CFA_OFFSET 4
+       movl %edi,%eax
+       call *%esi
        call do_exit
        ud2                     # padding for call trace
        CFI_ENDPROC
index 673f693fb45131aec07012fb71233b5459e3788f..0697ff139837644f170f032ae525d9e112c71681 100644 (file)
@@ -1166,63 +1166,20 @@ bad_gs:
        jmp  2b
        .previous
 
-/*
- * Create a kernel thread.
- *
- * C extern interface:
- *     extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
- *
- * asm input arguments:
- *     rdi: fn, rsi: arg, rdx: flags
- */
-ENTRY(kernel_thread)
-       CFI_STARTPROC
-       FAKE_STACK_FRAME $child_rip
-       SAVE_ALL
-
-       # rdi: flags, rsi: usp, rdx: will be &pt_regs
-       movq %rdx,%rdi
-       orq  kernel_thread_flags(%rip),%rdi
-       movq $-1, %rsi
-       movq %rsp, %rdx
-
-       xorl %r8d,%r8d
-       xorl %r9d,%r9d
-
-       # clone now
-       call do_fork
-       movq %rax,RAX(%rsp)
-       xorl %edi,%edi
-
-       /*
-        * It isn't worth to check for reschedule here,
-        * so internally to the x86_64 port you can rely on kernel_thread()
-        * not to reschedule the child before returning, this avoids the need
-        * of hacks for example to fork off the per-CPU idle tasks.
-        * [Hopefully no generic code relies on the reschedule -AK]
-        */
-       RESTORE_ALL
-       UNFAKE_STACK_FRAME
-       ret
-       CFI_ENDPROC
-END(kernel_thread)
-
-ENTRY(child_rip)
+ENTRY(kernel_thread_helper)
        pushq $0                # fake return address
        CFI_STARTPROC
        /*
         * Here we are in the child and the registers are set as they were
         * at kernel_thread() invocation in the parent.
         */
-       movq %rdi, %rax
-       movq %rsi, %rdi
-       call *%rax
+       call *%rsi
        # exit
        mov %eax, %edi
        call do_exit
        ud2                     # padding for call trace
        CFI_ENDPROC
-END(child_rip)
+END(kernel_thread_helper)
 
 /*
  * execve(). This function needs to use IRET, not SYSRET, to set up all state properly.
diff --git a/arch/x86/kernel/geode_32.c b/arch/x86/kernel/geode_32.c
deleted file mode 100644 (file)
index 9b08e85..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * AMD Geode southbridge support code
- * Copyright (C) 2006, Advanced Micro Devices, Inc.
- * Copyright (C) 2007, Andres Salomon <dilinger@debian.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/ioport.h>
-#include <linux/io.h>
-#include <asm/msr.h>
-#include <asm/geode.h>
-
-static struct {
-       char *name;
-       u32 msr;
-       int size;
-       u32 base;
-} lbars[] = {
-       { "geode-pms",   MSR_LBAR_PMS, LBAR_PMS_SIZE, 0 },
-       { "geode-acpi",  MSR_LBAR_ACPI, LBAR_ACPI_SIZE, 0 },
-       { "geode-gpio",  MSR_LBAR_GPIO, LBAR_GPIO_SIZE, 0 },
-       { "geode-mfgpt", MSR_LBAR_MFGPT, LBAR_MFGPT_SIZE, 0 }
-};
-
-static void __init init_lbars(void)
-{
-       u32 lo, hi;
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(lbars); i++) {
-               rdmsr(lbars[i].msr, lo, hi);
-               if (hi & 0x01)
-                       lbars[i].base = lo & 0x0000ffff;
-
-               if (lbars[i].base == 0)
-                       printk(KERN_ERR "geode:  Couldn't initialize '%s'\n",
-                                       lbars[i].name);
-       }
-}
-
-int geode_get_dev_base(unsigned int dev)
-{
-       BUG_ON(dev >= ARRAY_SIZE(lbars));
-       return lbars[dev].base;
-}
-EXPORT_SYMBOL_GPL(geode_get_dev_base);
-
-/* === GPIO API === */
-
-void geode_gpio_set(u32 gpio, unsigned int reg)
-{
-       u32 base = geode_get_dev_base(GEODE_DEV_GPIO);
-
-       if (!base)
-               return;
-
-       /* low bank register */
-       if (gpio & 0xFFFF)
-               outl(gpio & 0xFFFF, base + reg);
-       /* high bank register */
-       gpio >>= 16;
-       if (gpio)
-               outl(gpio, base + 0x80 + reg);
-}
-EXPORT_SYMBOL_GPL(geode_gpio_set);
-
-void geode_gpio_clear(u32 gpio, unsigned int reg)
-{
-       u32 base = geode_get_dev_base(GEODE_DEV_GPIO);
-
-       if (!base)
-               return;
-
-       /* low bank register */
-       if (gpio & 0xFFFF)
-               outl((gpio & 0xFFFF) << 16, base + reg);
-       /* high bank register */
-       gpio &= (0xFFFF << 16);
-       if (gpio)
-               outl(gpio, base + 0x80 + reg);
-}
-EXPORT_SYMBOL_GPL(geode_gpio_clear);
-
-int geode_gpio_isset(u32 gpio, unsigned int reg)
-{
-       u32 base = geode_get_dev_base(GEODE_DEV_GPIO);
-       u32 val;
-
-       if (!base)
-               return 0;
-
-       /* low bank register */
-       if (gpio & 0xFFFF) {
-               val = inl(base + reg) & (gpio & 0xFFFF);
-               if ((gpio & 0xFFFF) == val)
-                       return 1;
-       }
-       /* high bank register */
-       gpio >>= 16;
-       if (gpio) {
-               val = inl(base + 0x80 + reg) & gpio;
-               if (gpio == val)
-                       return 1;
-       }
-       return 0;
-}
-EXPORT_SYMBOL_GPL(geode_gpio_isset);
-
-void geode_gpio_set_irq(unsigned int group, unsigned int irq)
-{
-       u32 lo, hi;
-
-       if (group > 7 || irq > 15)
-               return;
-
-       rdmsr(MSR_PIC_ZSEL_HIGH, lo, hi);
-
-       lo &= ~(0xF << (group * 4));
-       lo |= (irq & 0xF) << (group * 4);
-
-       wrmsr(MSR_PIC_ZSEL_HIGH, lo, hi);
-}
-EXPORT_SYMBOL_GPL(geode_gpio_set_irq);
-
-void geode_gpio_setup_event(unsigned int gpio, int pair, int pme)
-{
-       u32 base = geode_get_dev_base(GEODE_DEV_GPIO);
-       u32 offset, shift, val;
-
-       if (gpio >= 24)
-               offset = GPIO_MAP_W;
-       else if (gpio >= 16)
-               offset = GPIO_MAP_Z;
-       else if (gpio >= 8)
-               offset = GPIO_MAP_Y;
-       else
-               offset = GPIO_MAP_X;
-
-       shift = (gpio % 8) * 4;
-
-       val = inl(base + offset);
-
-       /* Clear whatever was there before */
-       val &= ~(0xF << shift);
-
-       /* And set the new value */
-
-       val |= ((pair & 7) << shift);
-
-       /* Set the PME bit if this is a PME event */
-
-       if (pme)
-               val |= (1 << (shift + 3));
-
-       outl(val, base + offset);
-}
-EXPORT_SYMBOL_GPL(geode_gpio_setup_event);
-
-int geode_has_vsa2(void)
-{
-       static int has_vsa2 = -1;
-
-       if (has_vsa2 == -1) {
-               u16 val;
-
-               /*
-                * The VSA has virtual registers that we can query for a
-                * signature.
-                */
-               outw(VSA_VR_UNLOCK, VSA_VRC_INDEX);
-               outw(VSA_VR_SIGNATURE, VSA_VRC_INDEX);
-
-               val = inw(VSA_VRC_DATA);
-               has_vsa2 = (val == AMD_VSA_SIG || val == GSW_VSA_SIG);
-       }
-
-       return has_vsa2;
-}
-EXPORT_SYMBOL_GPL(geode_has_vsa2);
-
-static int __init geode_southbridge_init(void)
-{
-       if (!is_geode())
-               return -ENODEV;
-
-       init_lbars();
-       (void) mfgpt_timer_setup();
-       return 0;
-}
-
-postcore_initcall(geode_southbridge_init);
index 99c4d308f16b0db61ca0821adca78d3bec2e8b96..8eec0ec59af2a6545c074b330ca9d9565a7a3a70 100644 (file)
@@ -103,9 +103,10 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
  * on system-call entry - see also fork() and the signal handling
  * code.
  */
-static int do_iopl(unsigned int level, struct pt_regs *regs)
+long sys_iopl(unsigned int level, struct pt_regs *regs)
 {
        unsigned int old = (regs->flags >> 12) & 3;
+       struct thread_struct *t = &current->thread;
 
        if (level > 3)
                return -EINVAL;
@@ -115,29 +116,8 @@ static int do_iopl(unsigned int level, struct pt_regs *regs)
                        return -EPERM;
        }
        regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
-
-       return 0;
-}
-
-#ifdef CONFIG_X86_32
-long sys_iopl(struct pt_regs *regs)
-{
-       unsigned int level = regs->bx;
-       struct thread_struct *t = &current->thread;
-       int rc;
-
-       rc = do_iopl(level, regs);
-       if (rc < 0)
-               goto out;
-
        t->iopl = level << 12;
        set_iopl_mask(t->iopl);
-out:
-       return rc;
-}
-#else
-asmlinkage long sys_iopl(unsigned int level, struct pt_regs *regs)
-{
-       return do_iopl(level, regs);
+
+       return 0;
 }
-#endif
index 664bcb7384ac29245cdbf60751a6e09f8d1e8e82..91fd0c70a18abddc28eff75e287c70dd5d37af7d 100644 (file)
@@ -149,7 +149,7 @@ int show_interrupts(struct seq_file *p, void *v)
        if (!desc)
                return 0;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        for_each_online_cpu(j)
                any_count |= kstat_irqs_cpu(i, j);
        action = desc->action;
@@ -170,7 +170,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
        seq_putc(p, '\n');
 out:
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        return 0;
 }
 
@@ -294,12 +294,12 @@ void fixup_irqs(void)
                        continue;
 
                /* interrupt's are disabled at this point */
-               spin_lock(&desc->lock);
+               raw_spin_lock(&desc->lock);
 
                affinity = desc->affinity;
                if (!irq_has_action(irq) ||
                    cpumask_equal(affinity, cpu_online_mask)) {
-                       spin_unlock(&desc->lock);
+                       raw_spin_unlock(&desc->lock);
                        continue;
                }
 
@@ -326,7 +326,7 @@ void fixup_irqs(void)
                if (!(desc->status & IRQ_MOVE_PCNTXT) && desc->chip->unmask)
                        desc->chip->unmask(irq);
 
-               spin_unlock(&desc->lock);
+               raw_spin_unlock(&desc->lock);
 
                if (break_affinity && set_affinity)
                        printk("Broke affinity for irq %i\n", irq);
@@ -356,10 +356,10 @@ void fixup_irqs(void)
                        irq = __get_cpu_var(vector_irq)[vector];
 
                        desc = irq_to_desc(irq);
-                       spin_lock(&desc->lock);
+                       raw_spin_lock(&desc->lock);
                        if (desc->chip->retrigger)
                                desc->chip->retrigger(irq);
-                       spin_unlock(&desc->lock);
+                       raw_spin_unlock(&desc->lock);
                }
        }
 }
diff --git a/arch/x86/kernel/mfgpt_32.c b/arch/x86/kernel/mfgpt_32.c
deleted file mode 100644 (file)
index 2a62d84..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Driver/API for AMD Geode Multi-Function General Purpose Timers (MFGPT)
- *
- * Copyright (C) 2006, Advanced Micro Devices, Inc.
- * Copyright (C) 2007, Andres Salomon <dilinger@debian.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * The MFGPTs are documented in AMD Geode CS5536 Companion Device Data Book.
- */
-
-/*
- * We are using the 32.768kHz input clock - it's the only one that has the
- * ranges we find desirable.  The following table lists the suitable
- * divisors and the associated Hz, minimum interval and the maximum interval:
- *
- *  Divisor   Hz      Min Delta (s)  Max Delta (s)
- *   1        32768   .00048828125      2.000
- *   2        16384   .0009765625       4.000
- *   4         8192   .001953125        8.000
- *   8         4096   .00390625        16.000
- *   16        2048   .0078125         32.000
- *   32        1024   .015625          64.000
- *   64         512   .03125          128.000
- *  128         256   .0625           256.000
- *  256         128   .125            512.000
- */
-
-#include <linux/kernel.h>
-#include <linux/interrupt.h>
-#include <linux/module.h>
-#include <asm/geode.h>
-
-#define MFGPT_DEFAULT_IRQ      7
-
-static struct mfgpt_timer_t {
-       unsigned int avail:1;
-} mfgpt_timers[MFGPT_MAX_TIMERS];
-
-/* Selected from the table above */
-
-#define MFGPT_DIVISOR 16
-#define MFGPT_SCALE  4     /* divisor = 2^(scale) */
-#define MFGPT_HZ  (32768 / MFGPT_DIVISOR)
-#define MFGPT_PERIODIC (MFGPT_HZ / HZ)
-
-/* Allow for disabling of MFGPTs */
-static int disable;
-static int __init mfgpt_disable(char *s)
-{
-       disable = 1;
-       return 1;
-}
-__setup("nomfgpt", mfgpt_disable);
-
-/* Reset the MFGPT timers. This is required by some broken BIOSes which already
- * do the same and leave the system in an unstable state. TinyBIOS 0.98 is
- * affected at least (0.99 is OK with MFGPT workaround left to off).
- */
-static int __init mfgpt_fix(char *s)
-{
-       u32 val, dummy;
-
-       /* The following udocumented bit resets the MFGPT timers */
-       val = 0xFF; dummy = 0;
-       wrmsr(MSR_MFGPT_SETUP, val, dummy);
-       return 1;
-}
-__setup("mfgptfix", mfgpt_fix);
-
-/*
- * Check whether any MFGPTs are available for the kernel to use.  In most
- * cases, firmware that uses AMD's VSA code will claim all timers during
- * bootup; we certainly don't want to take them if they're already in use.
- * In other cases (such as with VSAless OpenFirmware), the system firmware
- * leaves timers available for us to use.
- */
-
-
-static int timers = -1;
-
-static void geode_mfgpt_detect(void)
-{
-       int i;
-       u16 val;
-
-       timers = 0;
-
-       if (disable) {
-               printk(KERN_INFO "geode-mfgpt:  MFGPT support is disabled\n");
-               goto done;
-       }
-
-       if (!geode_get_dev_base(GEODE_DEV_MFGPT)) {
-               printk(KERN_INFO "geode-mfgpt:  MFGPT LBAR is not set up\n");
-               goto done;
-       }
-
-       for (i = 0; i < MFGPT_MAX_TIMERS; i++) {
-               val = geode_mfgpt_read(i, MFGPT_REG_SETUP);
-               if (!(val & MFGPT_SETUP_SETUP)) {
-                       mfgpt_timers[i].avail = 1;
-                       timers++;
-               }
-       }
-
-done:
-       printk(KERN_INFO "geode-mfgpt:  %d MFGPT timers available.\n", timers);
-}
-
-int geode_mfgpt_toggle_event(int timer, int cmp, int event, int enable)
-{
-       u32 msr, mask, value, dummy;
-       int shift = (cmp == MFGPT_CMP1) ? 0 : 8;
-
-       if (timer < 0 || timer >= MFGPT_MAX_TIMERS)
-               return -EIO;
-
-       /*
-        * The register maps for these are described in sections 6.17.1.x of
-        * the AMD Geode CS5536 Companion Device Data Book.
-        */
-       switch (event) {
-       case MFGPT_EVENT_RESET:
-               /*
-                * XXX: According to the docs, we cannot reset timers above
-                * 6; that is, resets for 7 and 8 will be ignored.  Is this
-                * a problem?   -dilinger
-                */
-               msr = MSR_MFGPT_NR;
-               mask = 1 << (timer + 24);
-               break;
-
-       case MFGPT_EVENT_NMI:
-               msr = MSR_MFGPT_NR;
-               mask = 1 << (timer + shift);
-               break;
-
-       case MFGPT_EVENT_IRQ:
-               msr = MSR_MFGPT_IRQ;
-               mask = 1 << (timer + shift);
-               break;
-
-       default:
-               return -EIO;
-       }
-
-       rdmsr(msr, value, dummy);
-
-       if (enable)
-               value |= mask;
-       else
-               value &= ~mask;
-
-       wrmsr(msr, value, dummy);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(geode_mfgpt_toggle_event);
-
-int geode_mfgpt_set_irq(int timer, int cmp, int *irq, int enable)
-{
-       u32 zsel, lpc, dummy;
-       int shift;
-
-       if (timer < 0 || timer >= MFGPT_MAX_TIMERS)
-               return -EIO;
-
-       /*
-        * Unfortunately, MFGPTs come in pairs sharing their IRQ lines. If VSA
-        * is using the same CMP of the timer's Siamese twin, the IRQ is set to
-        * 2, and we mustn't use nor change it.
-        * XXX: Likewise, 2 Linux drivers might clash if the 2nd overwrites the
-        * IRQ of the 1st. This can only happen if forcing an IRQ, calling this
-        * with *irq==0 is safe. Currently there _are_ no 2 drivers.
-        */
-       rdmsr(MSR_PIC_ZSEL_LOW, zsel, dummy);
-       shift = ((cmp == MFGPT_CMP1 ? 0 : 4) + timer % 4) * 4;
-       if (((zsel >> shift) & 0xF) == 2)
-               return -EIO;
-
-       /* Choose IRQ: if none supplied, keep IRQ already set or use default */
-       if (!*irq)
-               *irq = (zsel >> shift) & 0xF;
-       if (!*irq)
-               *irq = MFGPT_DEFAULT_IRQ;
-
-       /* Can't use IRQ if it's 0 (=disabled), 2, or routed to LPC */
-       if (*irq < 1 || *irq == 2 || *irq > 15)
-               return -EIO;
-       rdmsr(MSR_PIC_IRQM_LPC, lpc, dummy);
-       if (lpc & (1 << *irq))
-               return -EIO;
-
-       /* All chosen and checked - go for it */
-       if (geode_mfgpt_toggle_event(timer, cmp, MFGPT_EVENT_IRQ, enable))
-               return -EIO;
-       if (enable) {
-               zsel = (zsel & ~(0xF << shift)) | (*irq << shift);
-               wrmsr(MSR_PIC_ZSEL_LOW, zsel, dummy);
-       }
-
-       return 0;
-}
-
-static int mfgpt_get(int timer)
-{
-       mfgpt_timers[timer].avail = 0;
-       printk(KERN_INFO "geode-mfgpt:  Registered timer %d\n", timer);
-       return timer;
-}
-
-int geode_mfgpt_alloc_timer(int timer, int domain)
-{
-       int i;
-
-       if (timers == -1) {
-               /* timers haven't been detected yet */
-               geode_mfgpt_detect();
-       }
-
-       if (!timers)
-               return -1;
-
-       if (timer >= MFGPT_MAX_TIMERS)
-               return -1;
-
-       if (timer < 0) {
-               /* Try to find an available timer */
-               for (i = 0; i < MFGPT_MAX_TIMERS; i++) {
-                       if (mfgpt_timers[i].avail)
-                               return mfgpt_get(i);
-
-                       if (i == 5 && domain == MFGPT_DOMAIN_WORKING)
-                               break;
-               }
-       } else {
-               /* If they requested a specific timer, try to honor that */
-               if (mfgpt_timers[timer].avail)
-                       return mfgpt_get(timer);
-       }
-
-       /* No timers available - too bad */
-       return -1;
-}
-EXPORT_SYMBOL_GPL(geode_mfgpt_alloc_timer);
-
-
-#ifdef CONFIG_GEODE_MFGPT_TIMER
-
-/*
- * The MFPGT timers on the CS5536 provide us with suitable timers to use
- * as clock event sources - not as good as a HPET or APIC, but certainly
- * better than the PIT.  This isn't a general purpose MFGPT driver, but
- * a simplified one designed specifically to act as a clock event source.
- * For full details about the MFGPT, please consult the CS5536 data sheet.
- */
-
-#include <linux/clocksource.h>
-#include <linux/clockchips.h>
-
-static unsigned int mfgpt_tick_mode = CLOCK_EVT_MODE_SHUTDOWN;
-static u16 mfgpt_event_clock;
-
-static int irq;
-static int __init mfgpt_setup(char *str)
-{
-       get_option(&str, &irq);
-       return 1;
-}
-__setup("mfgpt_irq=", mfgpt_setup);
-
-static void mfgpt_disable_timer(u16 clock)
-{
-       /* avoid races by clearing CMP1 and CMP2 unconditionally */
-       geode_mfgpt_write(clock, MFGPT_REG_SETUP, (u16) ~MFGPT_SETUP_CNTEN |
-                       MFGPT_SETUP_CMP1 | MFGPT_SETUP_CMP2);
-}
-
-static int mfgpt_next_event(unsigned long, struct clock_event_device *);
-static void mfgpt_set_mode(enum clock_event_mode, struct clock_event_device *);
-
-static struct clock_event_device mfgpt_clockevent = {
-       .name = "mfgpt-timer",
-       .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
-       .set_mode = mfgpt_set_mode,
-       .set_next_event = mfgpt_next_event,
-       .rating = 250,
-       .cpumask = cpu_all_mask,
-       .shift = 32
-};
-
-static void mfgpt_start_timer(u16 delta)
-{
-       geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_CMP2, (u16) delta);
-       geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_COUNTER, 0);
-
-       geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_SETUP,
-                         MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP2);
-}
-
-static void mfgpt_set_mode(enum clock_event_mode mode,
-                          struct clock_event_device *evt)
-{
-       mfgpt_disable_timer(mfgpt_event_clock);
-
-       if (mode == CLOCK_EVT_MODE_PERIODIC)
-               mfgpt_start_timer(MFGPT_PERIODIC);
-
-       mfgpt_tick_mode = mode;
-}
-
-static int mfgpt_next_event(unsigned long delta, struct clock_event_device *evt)
-{
-       mfgpt_start_timer(delta);
-       return 0;
-}
-
-static irqreturn_t mfgpt_tick(int irq, void *dev_id)
-{
-       u16 val = geode_mfgpt_read(mfgpt_event_clock, MFGPT_REG_SETUP);
-
-       /* See if the interrupt was for us */
-       if (!(val & (MFGPT_SETUP_SETUP  | MFGPT_SETUP_CMP2 | MFGPT_SETUP_CMP1)))
-               return IRQ_NONE;
-
-       /* Turn off the clock (and clear the event) */
-       mfgpt_disable_timer(mfgpt_event_clock);
-
-       if (mfgpt_tick_mode == CLOCK_EVT_MODE_SHUTDOWN)
-               return IRQ_HANDLED;
-
-       /* Clear the counter */
-       geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_COUNTER, 0);
-
-       /* Restart the clock in periodic mode */
-
-       if (mfgpt_tick_mode == CLOCK_EVT_MODE_PERIODIC) {
-               geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_SETUP,
-                                 MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP2);
-       }
-
-       mfgpt_clockevent.event_handler(&mfgpt_clockevent);
-       return IRQ_HANDLED;
-}
-
-static struct irqaction mfgptirq  = {
-       .handler = mfgpt_tick,
-       .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_TIMER,
-       .name = "mfgpt-timer"
-};
-
-int __init mfgpt_timer_setup(void)
-{
-       int timer, ret;
-       u16 val;
-
-       timer = geode_mfgpt_alloc_timer(MFGPT_TIMER_ANY, MFGPT_DOMAIN_WORKING);
-       if (timer < 0) {
-               printk(KERN_ERR
-                      "mfgpt-timer:  Could not allocate a MFPGT timer\n");
-               return -ENODEV;
-       }
-
-       mfgpt_event_clock = timer;
-
-       /* Set up the IRQ on the MFGPT side */
-       if (geode_mfgpt_setup_irq(mfgpt_event_clock, MFGPT_CMP2, &irq)) {
-               printk(KERN_ERR "mfgpt-timer:  Could not set up IRQ %d\n", irq);
-               return -EIO;
-       }
-
-       /* And register it with the kernel */
-       ret = setup_irq(irq, &mfgptirq);
-
-       if (ret) {
-               printk(KERN_ERR
-                      "mfgpt-timer:  Unable to set up the interrupt.\n");
-               goto err;
-       }
-
-       /* Set the clock scale and enable the event mode for CMP2 */
-       val = MFGPT_SCALE | (3 << 8);
-
-       geode_mfgpt_write(mfgpt_event_clock, MFGPT_REG_SETUP, val);
-
-       /* Set up the clock event */
-       mfgpt_clockevent.mult = div_sc(MFGPT_HZ, NSEC_PER_SEC,
-                                      mfgpt_clockevent.shift);
-       mfgpt_clockevent.min_delta_ns = clockevent_delta2ns(0xF,
-                       &mfgpt_clockevent);
-       mfgpt_clockevent.max_delta_ns = clockevent_delta2ns(0xFFFE,
-                       &mfgpt_clockevent);
-
-       printk(KERN_INFO
-              "mfgpt-timer:  Registering MFGPT timer %d as a clock event, using IRQ %d\n",
-              timer, irq);
-       clockevents_register_device(&mfgpt_clockevent);
-
-       return 0;
-
-err:
-       geode_mfgpt_release_irq(mfgpt_event_clock, MFGPT_CMP2, &irq);
-       printk(KERN_ERR
-              "mfgpt-timer:  Unable to set up the MFGPT clock source\n");
-       return -EIO;
-}
-
-#endif
index 844c02c65fcb158addce87804737e63a1bd82ae2..0c8632433090d6e90de8dff937f7fcf7719e6e0b 100644 (file)
@@ -394,7 +394,7 @@ static enum ucode_state microcode_update_cpu(int cpu)
        struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
        enum ucode_state ustate;
 
-       if (uci->valid && uci->mc)
+       if (uci->valid)
                ustate = microcode_resume_cpu(cpu);
        else
                ustate = microcode_init_cpu(cpu);
index 553449951b84b9c2d2f24afc2521fdd53adb7c8f..4bd93c9b2b2716d86367c41631ffa1a0c4625a83 100644 (file)
@@ -172,11 +172,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
 
 static int msr_open(struct inode *inode, struct file *file)
 {
-       unsigned int cpu = iminor(file->f_path.dentry->d_inode);
-       struct cpuinfo_x86 *c = &cpu_data(cpu);
+       unsigned int cpu;
+       struct cpuinfo_x86 *c;
 
        cpu = iminor(file->f_path.dentry->d_inode);
-
        if (cpu >= nr_cpu_ids || !cpu_online(cpu))
                return -ENXIO;  /* No such CPU */
 
@@ -247,7 +246,7 @@ static int __init msr_init(void)
        int i, err = 0;
        i = 0;
 
-       if (register_chrdev(MSR_MAJOR, "cpu/msr", &msr_fops)) {
+       if (__register_chrdev(MSR_MAJOR, 0, NR_CPUS, "cpu/msr", &msr_fops)) {
                printk(KERN_ERR "msr: unable to get major %d for msr\n",
                       MSR_MAJOR);
                err = -EBUSY;
@@ -275,7 +274,7 @@ out_class:
                msr_device_destroy(i);
        class_destroy(msr_class);
 out_chrdev:
-       unregister_chrdev(MSR_MAJOR, "cpu/msr");
+       __unregister_chrdev(MSR_MAJOR, 0, NR_CPUS, "cpu/msr");
 out:
        return err;
 }
index 4006c522adc780a0ce016b43b2d5a7ae93ca0f14..9d1d263f786fdd694513ba8383b635bcdcea319e 100644 (file)
@@ -212,7 +212,7 @@ static int __init olpc_init(void)
        unsigned char *romsig;
 
        /* The ioremap check is dangerous; limit what we run it on */
-       if (!is_geode() || geode_has_vsa2())
+       if (!is_geode() || cs5535_has_vsa2())
                return 0;
 
        spin_lock_init(&ec_lock);
@@ -244,7 +244,7 @@ static int __init olpc_init(void)
                        (unsigned char *) &olpc_platform_info.ecver, 1);
 
        /* check to see if the VSA exists */
-       if (geode_has_vsa2())
+       if (cs5535_has_vsa2())
                olpc_platform_info.flags |= OLPC_F_VSA;
 
        printk(KERN_INFO "OLPC board revision %s%X (EC=%x)\n",
index 3a7c5a44082eee1639fa695e70d8fa55bea4389c..676b8c77a97613f098f6e9022abdf02d2ef8a3e8 100644 (file)
@@ -8,9 +8,9 @@
 #include <asm/paravirt.h>
 
 static inline void
-default_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
+default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
 {
-       __raw_spin_lock(lock);
+       arch_spin_lock(lock);
 }
 
 struct pv_lock_ops pv_lock_ops = {
index c563e4c8ff395efe92522c80212a237968897b4a..2bbde607814334a811b91b21448c4d3ac75cfe00 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/string.h>
 #include <linux/crash_dump.h>
 #include <linux/dma-mapping.h>
-#include <linux/bitops.h>
+#include <linux/bitmap.h>
 #include <linux/pci_ids.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
@@ -212,7 +212,7 @@ static void iommu_range_reserve(struct iommu_table *tbl,
 
        spin_lock_irqsave(&tbl->it_lock, flags);
 
-       iommu_area_reserve(tbl->it_map, index, npages);
+       bitmap_set(tbl->it_map, index, npages);
 
        spin_unlock_irqrestore(&tbl->it_lock, flags);
 }
@@ -303,7 +303,7 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 
        spin_lock_irqsave(&tbl->it_lock, flags);
 
-       iommu_area_free(tbl->it_map, entry, npages);
+       bitmap_clear(tbl->it_map, entry, npages);
 
        spin_unlock_irqrestore(&tbl->it_lock, flags);
 }
index fcc2f2bfa39ca17e608fb2c395472494f45a91eb..75e14e21f61a728cb120590a475ff8e0f3e2c37d 100644 (file)
@@ -120,15 +120,12 @@ static void __init dma32_free_bootmem(void)
 
 void __init pci_iommu_alloc(void)
 {
-       int use_swiotlb;
-
-       use_swiotlb = pci_swiotlb_init();
 #ifdef CONFIG_X86_64
        /* free the range so iommu could get some range less than 4G */
        dma32_free_bootmem();
 #endif
-       if (use_swiotlb)
-               return;
+       if (pci_swiotlb_detect())
+               goto out;
 
        gart_iommu_hole_init();
 
@@ -138,6 +135,8 @@ void __init pci_iommu_alloc(void)
 
        /* needs to be called after gart_iommu_hole_init */
        amd_iommu_detect();
+out:
+       pci_swiotlb_init();
 }
 
 void *dma_generic_alloc_coherent(struct device *dev, size_t size,
index 56c0e730d3fe7bd09913d092c01f009f94f53974..34de53b46f8759ad90ec23575cca26828b07093a 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/module.h>
 #include <linux/topology.h>
 #include <linux/interrupt.h>
-#include <linux/bitops.h>
+#include <linux/bitmap.h>
 #include <linux/kdebug.h>
 #include <linux/scatterlist.h>
 #include <linux/iommu-helper.h>
@@ -126,7 +126,7 @@ static void free_iommu(unsigned long offset, int size)
        unsigned long flags;
 
        spin_lock_irqsave(&iommu_bitmap_lock, flags);
-       iommu_area_free(iommu_gart_bitmap, offset, size);
+       bitmap_clear(iommu_gart_bitmap, offset, size);
        if (offset >= next_bit)
                next_bit = offset + size;
        spin_unlock_irqrestore(&iommu_bitmap_lock, flags);
@@ -792,7 +792,7 @@ int __init gart_iommu_init(void)
         * Out of IOMMU space handling.
         * Reserve some invalid pages at the beginning of the GART.
         */
-       iommu_area_reserve(iommu_gart_bitmap, 0, EMERGENCY_PAGES);
+       bitmap_set(iommu_gart_bitmap, 0, EMERGENCY_PAGES);
 
        pr_info("PCI-DMA: Reserving %luMB of IOMMU area in the AGP aperture\n",
               iommu_size >> 20);
index e3c0a66b9e7785a1eee6637d9ddedef18fb7bf48..7d2829dde20e8cbbf538ea6fcf39384510a65426 100644 (file)
@@ -43,12 +43,12 @@ static struct dma_map_ops swiotlb_dma_ops = {
 };
 
 /*
- * pci_swiotlb_init - initialize swiotlb if necessary
+ * pci_swiotlb_detect - set swiotlb to 1 if necessary
  *
  * This returns non-zero if we are forced to use swiotlb (by the boot
  * option).
  */
-int __init pci_swiotlb_init(void)
+int __init pci_swiotlb_detect(void)
 {
        int use_swiotlb = swiotlb | swiotlb_force;
 
@@ -60,10 +60,13 @@ int __init pci_swiotlb_init(void)
        if (swiotlb_force)
                swiotlb = 1;
 
+       return use_swiotlb;
+}
+
+void __init pci_swiotlb_init(void)
+{
        if (swiotlb) {
                swiotlb_init(0);
                dma_ops = &swiotlb_dma_ops;
        }
-
-       return use_swiotlb;
 }
index 7a7bd4e3ec49b5f42056137f6c56165809303c98..98c2cdeb599e71ecf2f26f177a8bc6f64cad4cc8 100644 (file)
@@ -255,6 +255,76 @@ int sys_vfork(struct pt_regs *regs)
                       NULL, NULL);
 }
 
+long
+sys_clone(unsigned long clone_flags, unsigned long newsp,
+         void __user *parent_tid, void __user *child_tid, struct pt_regs *regs)
+{
+       if (!newsp)
+               newsp = regs->sp;
+       return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
+}
+
+/*
+ * This gets run with %si containing the
+ * function to call, and %di containing
+ * the "args".
+ */
+extern void kernel_thread_helper(void);
+
+/*
+ * Create a kernel thread
+ */
+int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
+{
+       struct pt_regs regs;
+
+       memset(&regs, 0, sizeof(regs));
+
+       regs.si = (unsigned long) fn;
+       regs.di = (unsigned long) arg;
+
+#ifdef CONFIG_X86_32
+       regs.ds = __USER_DS;
+       regs.es = __USER_DS;
+       regs.fs = __KERNEL_PERCPU;
+       regs.gs = __KERNEL_STACK_CANARY;
+#endif
+
+       regs.orig_ax = -1;
+       regs.ip = (unsigned long) kernel_thread_helper;
+       regs.cs = __KERNEL_CS | get_kernel_rpl();
+       regs.flags = X86_EFLAGS_IF | 0x2;
+
+       /* Ok, create the new process.. */
+       return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
+}
+EXPORT_SYMBOL(kernel_thread);
+
+/*
+ * sys_execve() executes a new program.
+ */
+long sys_execve(char __user *name, char __user * __user *argv,
+               char __user * __user *envp, struct pt_regs *regs)
+{
+       long error;
+       char *filename;
+
+       filename = getname(name);
+       error = PTR_ERR(filename);
+       if (IS_ERR(filename))
+               return error;
+       error = do_execve(filename, argv, envp, regs);
+
+#ifdef CONFIG_X86_32
+       if (error == 0) {
+               /* Make sure we don't return using sysenter.. */
+                set_thread_flag(TIF_IRET);
+        }
+#endif
+
+       putname(filename);
+       return error;
+}
 
 /*
  * Idle related variables and functions
index 120b88797a75af8d44bfb2b4e092b3dd055ed4a3..9c517b5858f0943065260484ff2f151846197b13 100644 (file)
@@ -180,39 +180,6 @@ void show_regs(struct pt_regs *regs)
        show_trace(NULL, regs, &regs->sp, regs->bp);
 }
 
-/*
- * This gets run with %bx containing the
- * function to call, and %dx containing
- * the "args".
- */
-extern void kernel_thread_helper(void);
-
-/*
- * Create a kernel thread
- */
-int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
-{
-       struct pt_regs regs;
-
-       memset(&regs, 0, sizeof(regs));
-
-       regs.bx = (unsigned long) fn;
-       regs.dx = (unsigned long) arg;
-
-       regs.ds = __USER_DS;
-       regs.es = __USER_DS;
-       regs.fs = __KERNEL_PERCPU;
-       regs.gs = __KERNEL_STACK_CANARY;
-       regs.orig_ax = -1;
-       regs.ip = (unsigned long) kernel_thread_helper;
-       regs.cs = __KERNEL_CS | get_kernel_rpl();
-       regs.flags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2;
-
-       /* Ok, create the new process.. */
-       return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
-}
-EXPORT_SYMBOL(kernel_thread);
-
 void release_thread(struct task_struct *dead_task)
 {
        BUG_ON(dead_task->mm);
@@ -424,46 +391,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
        return prev_p;
 }
 
-int sys_clone(struct pt_regs *regs)
-{
-       unsigned long clone_flags;
-       unsigned long newsp;
-       int __user *parent_tidptr, *child_tidptr;
-
-       clone_flags = regs->bx;
-       newsp = regs->cx;
-       parent_tidptr = (int __user *)regs->dx;
-       child_tidptr = (int __user *)regs->di;
-       if (!newsp)
-               newsp = regs->sp;
-       return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr);
-}
-
-/*
- * sys_execve() executes a new program.
- */
-int sys_execve(struct pt_regs *regs)
-{
-       int error;
-       char *filename;
-
-       filename = getname((char __user *) regs->bx);
-       error = PTR_ERR(filename);
-       if (IS_ERR(filename))
-               goto out;
-       error = do_execve(filename,
-                       (char __user * __user *) regs->cx,
-                       (char __user * __user *) regs->dx,
-                       regs);
-       if (error == 0) {
-               /* Make sure we don't return using sysenter.. */
-               set_thread_flag(TIF_IRET);
-       }
-       putname(filename);
-out:
-       return error;
-}
-
 #define top_esp                (THREAD_SIZE - sizeof(unsigned long))
 #define top_ebp                (THREAD_SIZE - 2*sizeof(unsigned long))
 
index e5ab0cd0ef36e5516207fbb96974c53e5b35e9d1..52fbd0c601987bed689e40693c14e6c38c4f687d 100644 (file)
@@ -57,8 +57,6 @@ asmlinkage extern void ret_from_fork(void);
 DEFINE_PER_CPU(unsigned long, old_rsp);
 static DEFINE_PER_CPU(unsigned char, is_idle);
 
-unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
-
 static ATOMIC_NOTIFIER_HEAD(idle_notifier);
 
 void idle_notifier_register(struct notifier_block *n)
@@ -273,8 +271,9 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
        *childregs = *regs;
 
        childregs->ax = 0;
-       childregs->sp = sp;
-       if (sp == ~0UL)
+       if (user_mode(regs))
+               childregs->sp = sp;
+       else
                childregs->sp = (unsigned long)childregs;
 
        p->thread.sp = (unsigned long) childregs;
@@ -508,25 +507,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
        return prev_p;
 }
 
-/*
- * sys_execve() executes a new program.
- */
-asmlinkage
-long sys_execve(char __user *name, char __user * __user *argv,
-               char __user * __user *envp, struct pt_regs *regs)
-{
-       long error;
-       char *filename;
-
-       filename = getname(name);
-       error = PTR_ERR(filename);
-       if (IS_ERR(filename))
-               return error;
-       error = do_execve(filename, argv, envp, regs);
-       putname(filename);
-       return error;
-}
-
 void set_personality_64bit(void)
 {
        /* inherit personality from parent */
@@ -541,15 +521,6 @@ void set_personality_64bit(void)
        current->personality &= ~READ_IMPLIES_EXEC;
 }
 
-asmlinkage long
-sys_clone(unsigned long clone_flags, unsigned long newsp,
-         void __user *parent_tid, void __user *child_tid, struct pt_regs *regs)
-{
-       if (!newsp)
-               newsp = regs->sp;
-       return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
-}
-
 unsigned long get_wchan(struct task_struct *p)
 {
        unsigned long stack;
index 7079ddaf0731e949d99940f7a036d82f3b613954..017d937639fef87694eea7cd3cbbf95efb163d37 100644 (file)
@@ -509,14 +509,14 @@ static int genregs_get(struct task_struct *target,
 {
        if (kbuf) {
                unsigned long *k = kbuf;
-               while (count > 0) {
+               while (count >= sizeof(*k)) {
                        *k++ = getreg(target, pos);
                        count -= sizeof(*k);
                        pos += sizeof(*k);
                }
        } else {
                unsigned long __user *u = ubuf;
-               while (count > 0) {
+               while (count >= sizeof(*u)) {
                        if (__put_user(getreg(target, pos), u++))
                                return -EFAULT;
                        count -= sizeof(*u);
@@ -535,14 +535,14 @@ static int genregs_set(struct task_struct *target,
        int ret = 0;
        if (kbuf) {
                const unsigned long *k = kbuf;
-               while (count > 0 && !ret) {
+               while (count >= sizeof(*k) && !ret) {
                        ret = putreg(target, pos, *k++);
                        count -= sizeof(*k);
                        pos += sizeof(*k);
                }
        } else {
                const unsigned long  __user *u = ubuf;
-               while (count > 0 && !ret) {
+               while (count >= sizeof(*u) && !ret) {
                        unsigned long word;
                        ret = __get_user(word, u++);
                        if (ret)
@@ -1458,14 +1458,14 @@ static int genregs32_get(struct task_struct *target,
 {
        if (kbuf) {
                compat_ulong_t *k = kbuf;
-               while (count > 0) {
+               while (count >= sizeof(*k)) {
                        getreg32(target, pos, k++);
                        count -= sizeof(*k);
                        pos += sizeof(*k);
                }
        } else {
                compat_ulong_t __user *u = ubuf;
-               while (count > 0) {
+               while (count >= sizeof(*u)) {
                        compat_ulong_t word;
                        getreg32(target, pos, &word);
                        if (__put_user(word, u++))
@@ -1486,14 +1486,14 @@ static int genregs32_set(struct task_struct *target,
        int ret = 0;
        if (kbuf) {
                const compat_ulong_t *k = kbuf;
-               while (count > 0 && !ret) {
+               while (count >= sizeof(*k) && !ret) {
                        ret = putreg32(target, pos, *k++);
                        count -= sizeof(*k);
                        pos += sizeof(*k);
                }
        } else {
                const compat_ulong_t __user *u = ubuf;
-               while (count > 0 && !ret) {
+               while (count >= sizeof(*u) && !ret) {
                        compat_ulong_t word;
                        ret = __get_user(word, u++);
                        if (ret)
@@ -1676,21 +1676,33 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 #endif
 }
 
-void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
-                                        int error_code, int si_code)
+static void fill_sigtrap_info(struct task_struct *tsk,
+                               struct pt_regs *regs,
+                               int error_code, int si_code,
+                               struct siginfo *info)
 {
-       struct siginfo info;
-
        tsk->thread.trap_no = 1;
        tsk->thread.error_code = error_code;
 
-       memset(&info, 0, sizeof(info));
-       info.si_signo = SIGTRAP;
-       info.si_code = si_code;
+       memset(info, 0, sizeof(*info));
+       info->si_signo = SIGTRAP;
+       info->si_code = si_code;
+       info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
+}
 
-       /* User-mode ip? */
-       info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL;
+void user_single_step_siginfo(struct task_struct *tsk,
+                               struct pt_regs *regs,
+                               struct siginfo *info)
+{
+       fill_sigtrap_info(tsk, regs, 0, TRAP_BRKPT, info);
+}
 
+void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
+                                        int error_code, int si_code)
+{
+       struct siginfo info;
+
+       fill_sigtrap_info(tsk, regs, error_code, si_code, &info);
        /* Send us the fake SIGTRAP */
        force_sig_info(SIGTRAP, &info, tsk);
 }
@@ -1755,29 +1767,22 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
 
 asmregparm void syscall_trace_leave(struct pt_regs *regs)
 {
+       bool step;
+
        if (unlikely(current->audit_context))
                audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
 
        if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
                trace_sys_exit(regs, regs->ax);
 
-       if (test_thread_flag(TIF_SYSCALL_TRACE))
-               tracehook_report_syscall_exit(regs, 0);
-
        /*
         * If TIF_SYSCALL_EMU is set, we only get here because of
         * TIF_SINGLESTEP (i.e. this is PTRACE_SYSEMU_SINGLESTEP).
         * We already reported this syscall instruction in
-        * syscall_trace_enter(), so don't do any more now.
-        */
-       if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
-               return;
-
-       /*
-        * If we are single-stepping, synthesize a trap to follow the
-        * system call instruction.
+        * syscall_trace_enter().
         */
-       if (test_thread_flag(TIF_SINGLESTEP) &&
-           tracehook_consider_fatal_signal(current, SIGTRAP))
-               send_sigtrap(current, regs, 0, TRAP_BRKPT);
+       step = unlikely(test_thread_flag(TIF_SINGLESTEP)) &&
+                       !test_thread_flag(TIF_SYSCALL_EMU);
+       if (step || test_thread_flag(TIF_SYSCALL_TRACE))
+               tracehook_report_syscall_exit(regs, step);
 }
index 201eab63b05fda18954dc111f7c15b44c0eafddf..fda313ebbb03dfc98d5d0f953a1b99846e25dc9a 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/interrupt.h>
 #include <asm/reboot_fixups.h>
 #include <asm/msr.h>
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 
 static void cs5530a_warm_reset(struct pci_dev *dev)
 {
index 74fe6d86dc5d3e07ab80a6b7c3d20e155f8e6a08..4fd173cd8e5734f451b3c2b113d58c4ee5da2a32 100644 (file)
@@ -545,22 +545,12 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
 }
 #endif /* CONFIG_X86_32 */
 
-#ifdef CONFIG_X86_32
-int sys_sigaltstack(struct pt_regs *regs)
-{
-       const stack_t __user *uss = (const stack_t __user *)regs->bx;
-       stack_t __user *uoss = (stack_t __user *)regs->cx;
-
-       return do_sigaltstack(uss, uoss, regs->sp);
-}
-#else /* !CONFIG_X86_32 */
-asmlinkage long
+long
 sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
                struct pt_regs *regs)
 {
        return do_sigaltstack(uss, uoss, regs->sp);
 }
-#endif /* CONFIG_X86_32 */
 
 /*
  * Do a signal return; undo the signal stack.
index c3eb207181feeef5be791127b61798b432935cc4..922eefbb3f6c72b7b511791b083b916040b9f95e 100644 (file)
@@ -53,17 +53,19 @@ save_stack_address_nosched(void *data, unsigned long addr, int reliable)
 }
 
 static const struct stacktrace_ops save_stack_ops = {
-       .warning = save_stack_warning,
-       .warning_symbol = save_stack_warning_symbol,
-       .stack = save_stack_stack,
-       .address = save_stack_address,
+       .warning        = save_stack_warning,
+       .warning_symbol = save_stack_warning_symbol,
+       .stack          = save_stack_stack,
+       .address        = save_stack_address,
+       .walk_stack     = print_context_stack,
 };
 
 static const struct stacktrace_ops save_stack_ops_nosched = {
-       .warning = save_stack_warning,
-       .warning_symbol = save_stack_warning_symbol,
-       .stack = save_stack_stack,
-       .address = save_stack_address_nosched,
+       .warning        = save_stack_warning,
+       .warning_symbol = save_stack_warning_symbol,
+       .stack          = save_stack_stack,
+       .address        = save_stack_address_nosched,
+       .walk_stack     = print_context_stack,
 };
 
 /*
index cd982f48e23e11c74acd08e8db823c3ef4fe5886..597683aa5ba0ba3ef800ab39179669ded4e3aa57 100644 (file)
@@ -763,6 +763,7 @@ void mark_tsc_unstable(char *reason)
 {
        if (!tsc_unstable) {
                tsc_unstable = 1;
+               sched_clock_stable = 0;
                printk(KERN_INFO "Marking TSC unstable due to %s\n", reason);
                /* Change only the rating, when not registered */
                if (clocksource_tsc.mult)
index eed156851f5d6f85df71907cfeb5e73b62730d40..0aa5fed8b9e6e02c6b45e5961ac228f527a89eb5 100644 (file)
@@ -33,7 +33,7 @@ static __cpuinitdata atomic_t stop_count;
  * we want to have the fastest, inlined, non-debug version
  * of a critical section, to be able to prove TSC time-warps:
  */
-static __cpuinitdata raw_spinlock_t sync_lock = __RAW_SPIN_LOCK_UNLOCKED;
+static __cpuinitdata arch_spinlock_t sync_lock = __ARCH_SPIN_LOCK_UNLOCKED;
 
 static __cpuinitdata cycles_t last_tsc;
 static __cpuinitdata cycles_t max_warp;
@@ -62,13 +62,13 @@ static __cpuinit void check_tsc_warp(void)
                 * previous TSC that was measured (possibly on
                 * another CPU) and update the previous TSC timestamp.
                 */
-               __raw_spin_lock(&sync_lock);
+               arch_spin_lock(&sync_lock);
                prev = last_tsc;
                rdtsc_barrier();
                now = get_cycles();
                rdtsc_barrier();
                last_tsc = now;
-               __raw_spin_unlock(&sync_lock);
+               arch_spin_unlock(&sync_lock);
 
                /*
                 * Be nice every now and then (and also check whether
@@ -87,10 +87,10 @@ static __cpuinit void check_tsc_warp(void)
                 * we saw a time-warp of the TSC going backwards:
                 */
                if (unlikely(prev > now)) {
-                       __raw_spin_lock(&sync_lock);
+                       arch_spin_lock(&sync_lock);
                        max_warp = max(max_warp, prev - now);
                        nr_warps++;
-                       __raw_spin_unlock(&sync_lock);
+                       arch_spin_unlock(&sync_lock);
                }
        }
        WARN(!(now-start),
index 61d805df4c91c6c14222730d7cc88d07c0b2dda8..ece73d8e32409feffaba8fde7d8b8e042c6771e7 100644 (file)
@@ -215,8 +215,7 @@ static int uv_set_irq_affinity(unsigned int irq, const struct cpumask *mask)
        unsigned long mmr_offset;
        unsigned mmr_pnode;
 
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
 
        mmr_value = 0;
index 9c4e625390589ac69e984edded55d13d6200a031..5ffb5622f793aee1446716c137078ee0c865be07 100644 (file)
@@ -197,9 +197,8 @@ out:
 static int do_vm86_irq_handling(int subfunction, int irqnumber);
 static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk);
 
-int sys_vm86old(struct pt_regs *regs)
+int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
 {
-       struct vm86_struct __user *v86 = (struct vm86_struct __user *)regs->bx;
        struct kernel_vm86_struct info; /* declare this _on top_,
                                         * this avoids wasting of stack space.
                                         * This remains on the stack until we
@@ -227,7 +226,7 @@ out:
 }
 
 
-int sys_vm86(struct pt_regs *regs)
+int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
 {
        struct kernel_vm86_struct info; /* declare this _on top_,
                                         * this avoids wasting of stack space.
@@ -239,12 +238,12 @@ int sys_vm86(struct pt_regs *regs)
        struct vm86plus_struct __user *v86;
 
        tsk = current;
-       switch (regs->bx) {
+       switch (cmd) {
        case VM86_REQUEST_IRQ:
        case VM86_FREE_IRQ:
        case VM86_GET_IRQ_BITS:
        case VM86_GET_AND_RESET_IRQ:
-               ret = do_vm86_irq_handling(regs->bx, (int)regs->cx);
+               ret = do_vm86_irq_handling(cmd, (int)arg);
                goto out;
        case VM86_PLUS_INSTALL_CHECK:
                /*
@@ -261,7 +260,7 @@ int sys_vm86(struct pt_regs *regs)
        ret = -EPERM;
        if (tsk->thread.saved_sp0)
                goto out;
-       v86 = (struct vm86plus_struct __user *)regs->cx;
+       v86 = (struct vm86plus_struct __user *)arg;
        tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
                                       offsetof(struct kernel_vm86_struct, regs32) -
                                       sizeof(info.regs));
index f3f2104408d932ab05172fe4edb42cba420ec7d4..f92a0da608cb3ade16374118320e4d73220e4b95 100644 (file)
@@ -319,9 +319,7 @@ SECTIONS
                __brk_limit = .;
        }
 
-       .end : AT(ADDR(.end) - LOAD_OFFSET) {
-               _end = .;
-       }
+       _end = .;
 
         STABS_DEBUG
         DWARF_DEBUG
index a1029769b6f249ae274cb9759d2ece7cba8cf261..619f7f88b8cc6aacacc1b828be517b91326dc1ca 100644 (file)
@@ -17,8 +17,6 @@
 EXPORT_SYMBOL(mcount);
 #endif
 
-EXPORT_SYMBOL(kernel_thread);
-
 EXPORT_SYMBOL(__get_user_1);
 EXPORT_SYMBOL(__get_user_2);
 EXPORT_SYMBOL(__get_user_4);
@@ -56,4 +54,6 @@ EXPORT_SYMBOL(__memcpy);
 
 EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(init_level4_pgt);
-EXPORT_SYMBOL(load_gs_index);
+#ifndef CONFIG_PARAVIRT
+EXPORT_SYMBOL(native_load_gs_index);
+#endif
index cd60c0bd1b32b158d70f43e373fcd6e477883b10..3063a0c4858b462a23dd8e2b7d6b81342a203fc1 100644 (file)
@@ -1150,6 +1150,7 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu)
        hrtimer_cancel(&apic->lapic_timer.timer);
        update_divide_count(apic);
        start_apic_timer(apic);
+       apic->irr_pending = true;
 }
 
 void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu)
index a6017132fba8e8dd9a8600fbc898e4e9e9fbb319..58a0f1e8859655154da07037604ebd5fb1872c7f 100644 (file)
@@ -455,8 +455,6 @@ out_unlock:
 static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
 {
        struct kvm_shadow_walk_iterator iterator;
-       pt_element_t gpte;
-       gpa_t pte_gpa = -1;
        int level;
        u64 *sptep;
        int need_flush = 0;
@@ -470,10 +468,6 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
                if (level == PT_PAGE_TABLE_LEVEL  ||
                    ((level == PT_DIRECTORY_LEVEL && is_large_pte(*sptep))) ||
                    ((level == PT_PDPE_LEVEL && is_large_pte(*sptep)))) {
-                       struct kvm_mmu_page *sp = page_header(__pa(sptep));
-
-                       pte_gpa = (sp->gfn << PAGE_SHIFT);
-                       pte_gpa += (sptep - sp->spt) * sizeof(pt_element_t);
 
                        if (is_shadow_present_pte(*sptep)) {
                                rmap_remove(vcpu->kvm, sptep);
@@ -492,18 +486,6 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva)
        if (need_flush)
                kvm_flush_remote_tlbs(vcpu->kvm);
        spin_unlock(&vcpu->kvm->mmu_lock);
-
-       if (pte_gpa == -1)
-               return;
-       if (kvm_read_guest_atomic(vcpu->kvm, pte_gpa, &gpte,
-                                 sizeof(pt_element_t)))
-               return;
-       if (is_present_gpte(gpte) && (gpte & PT_ACCESSED_MASK)) {
-               if (mmu_topup_memory_caches(vcpu))
-                       return;
-               kvm_mmu_pte_write(vcpu, pte_gpa, (const u8 *)&gpte,
-                                 sizeof(pt_element_t), 0);
-       }
 }
 
 static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr)
index 9d068966fb2aa491f00152e22ea047e60984f683..6651dbf58675ee7ec8d9e7f3e145dce09953e054 100644 (file)
@@ -1913,7 +1913,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
 
        events->sipi_vector = vcpu->arch.sipi_vector;
 
-       events->flags = 0;
+       events->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING
+                        | KVM_VCPUEVENT_VALID_SIPI_VECTOR);
 
        vcpu_put(vcpu);
 }
@@ -1921,7 +1922,8 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
 static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
                                              struct kvm_vcpu_events *events)
 {
-       if (events->flags)
+       if (events->flags & ~(KVM_VCPUEVENT_VALID_NMI_PENDING
+                             | KVM_VCPUEVENT_VALID_SIPI_VECTOR))
                return -EINVAL;
 
        vcpu_load(vcpu);
@@ -1938,10 +1940,12 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
                kvm_pic_clear_isr_ack(vcpu->kvm);
 
        vcpu->arch.nmi_injected = events->nmi.injected;
-       vcpu->arch.nmi_pending = events->nmi.pending;
+       if (events->flags & KVM_VCPUEVENT_VALID_NMI_PENDING)
+               vcpu->arch.nmi_pending = events->nmi.pending;
        kvm_x86_ops->set_nmi_mask(vcpu, events->nmi.masked);
 
-       vcpu->arch.sipi_vector = events->sipi_vector;
+       if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR)
+               vcpu->arch.sipi_vector = events->sipi_vector;
 
        vcpu_put(vcpu);
 
index 45b20e486c2f40e5895cb288851d0f2d3f7f59ab..cffd754f30396f447b9eb8955b8cccbad7420107 100644 (file)
@@ -14,7 +14,7 @@ $(obj)/inat.o: $(obj)/inat-tables.c
 
 clean-files := inat-tables.c
 
-obj-$(CONFIG_SMP) := msr.o
+obj-$(CONFIG_SMP) += msr-smp.o
 
 lib-y := delay.o
 lib-y += thunk_$(BITS).o
@@ -22,7 +22,7 @@ lib-y += usercopy_$(BITS).o getuser.o putuser.o
 lib-y += memcpy_$(BITS).o
 lib-$(CONFIG_KPROBES) += insn.o inat.o
 
-obj-y += msr-reg.o msr-reg-export.o
+obj-y += msr.o msr-reg.o msr-reg-export.o
 
 ifeq ($(CONFIG_X86_32),y)
         obj-y += atomic64_32.o
diff --git a/arch/x86/lib/msr-smp.c b/arch/x86/lib/msr-smp.c
new file mode 100644 (file)
index 0000000..a6b1b86
--- /dev/null
@@ -0,0 +1,204 @@
+#include <linux/module.h>
+#include <linux/preempt.h>
+#include <linux/smp.h>
+#include <asm/msr.h>
+
+static void __rdmsr_on_cpu(void *info)
+{
+       struct msr_info *rv = info;
+       struct msr *reg;
+       int this_cpu = raw_smp_processor_id();
+
+       if (rv->msrs)
+               reg = per_cpu_ptr(rv->msrs, this_cpu);
+       else
+               reg = &rv->reg;
+
+       rdmsr(rv->msr_no, reg->l, reg->h);
+}
+
+static void __wrmsr_on_cpu(void *info)
+{
+       struct msr_info *rv = info;
+       struct msr *reg;
+       int this_cpu = raw_smp_processor_id();
+
+       if (rv->msrs)
+               reg = per_cpu_ptr(rv->msrs, this_cpu);
+       else
+               reg = &rv->reg;
+
+       wrmsr(rv->msr_no, reg->l, reg->h);
+}
+
+int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
+{
+       int err;
+       struct msr_info rv;
+
+       memset(&rv, 0, sizeof(rv));
+
+       rv.msr_no = msr_no;
+       err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
+       *l = rv.reg.l;
+       *h = rv.reg.h;
+
+       return err;
+}
+EXPORT_SYMBOL(rdmsr_on_cpu);
+
+int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
+{
+       int err;
+       struct msr_info rv;
+
+       memset(&rv, 0, sizeof(rv));
+
+       rv.msr_no = msr_no;
+       rv.reg.l = l;
+       rv.reg.h = h;
+       err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
+
+       return err;
+}
+EXPORT_SYMBOL(wrmsr_on_cpu);
+
+static void __rwmsr_on_cpus(const struct cpumask *mask, u32 msr_no,
+                           struct msr *msrs,
+                           void (*msr_func) (void *info))
+{
+       struct msr_info rv;
+       int this_cpu;
+
+       memset(&rv, 0, sizeof(rv));
+
+       rv.msrs   = msrs;
+       rv.msr_no = msr_no;
+
+       this_cpu = get_cpu();
+
+       if (cpumask_test_cpu(this_cpu, mask))
+               msr_func(&rv);
+
+       smp_call_function_many(mask, msr_func, &rv, 1);
+       put_cpu();
+}
+
+/* rdmsr on a bunch of CPUs
+ *
+ * @mask:       which CPUs
+ * @msr_no:     which MSR
+ * @msrs:       array of MSR values
+ *
+ */
+void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
+{
+       __rwmsr_on_cpus(mask, msr_no, msrs, __rdmsr_on_cpu);
+}
+EXPORT_SYMBOL(rdmsr_on_cpus);
+
+/*
+ * wrmsr on a bunch of CPUs
+ *
+ * @mask:       which CPUs
+ * @msr_no:     which MSR
+ * @msrs:       array of MSR values
+ *
+ */
+void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
+{
+       __rwmsr_on_cpus(mask, msr_no, msrs, __wrmsr_on_cpu);
+}
+EXPORT_SYMBOL(wrmsr_on_cpus);
+
+/* These "safe" variants are slower and should be used when the target MSR
+   may not actually exist. */
+static void __rdmsr_safe_on_cpu(void *info)
+{
+       struct msr_info *rv = info;
+
+       rv->err = rdmsr_safe(rv->msr_no, &rv->reg.l, &rv->reg.h);
+}
+
+static void __wrmsr_safe_on_cpu(void *info)
+{
+       struct msr_info *rv = info;
+
+       rv->err = wrmsr_safe(rv->msr_no, rv->reg.l, rv->reg.h);
+}
+
+int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
+{
+       int err;
+       struct msr_info rv;
+
+       memset(&rv, 0, sizeof(rv));
+
+       rv.msr_no = msr_no;
+       err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
+       *l = rv.reg.l;
+       *h = rv.reg.h;
+
+       return err ? err : rv.err;
+}
+EXPORT_SYMBOL(rdmsr_safe_on_cpu);
+
+int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
+{
+       int err;
+       struct msr_info rv;
+
+       memset(&rv, 0, sizeof(rv));
+
+       rv.msr_no = msr_no;
+       rv.reg.l = l;
+       rv.reg.h = h;
+       err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1);
+
+       return err ? err : rv.err;
+}
+EXPORT_SYMBOL(wrmsr_safe_on_cpu);
+
+/*
+ * These variants are significantly slower, but allows control over
+ * the entire 32-bit GPR set.
+ */
+static void __rdmsr_safe_regs_on_cpu(void *info)
+{
+       struct msr_regs_info *rv = info;
+
+       rv->err = rdmsr_safe_regs(rv->regs);
+}
+
+static void __wrmsr_safe_regs_on_cpu(void *info)
+{
+       struct msr_regs_info *rv = info;
+
+       rv->err = wrmsr_safe_regs(rv->regs);
+}
+
+int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
+{
+       int err;
+       struct msr_regs_info rv;
+
+       rv.regs   = regs;
+       rv.err    = -EIO;
+       err = smp_call_function_single(cpu, __rdmsr_safe_regs_on_cpu, &rv, 1);
+
+       return err ? err : rv.err;
+}
+EXPORT_SYMBOL(rdmsr_safe_regs_on_cpu);
+
+int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
+{
+       int err;
+       struct msr_regs_info rv;
+
+       rv.regs = regs;
+       rv.err  = -EIO;
+       err = smp_call_function_single(cpu, __wrmsr_safe_regs_on_cpu, &rv, 1);
+
+       return err ? err : rv.err;
+}
+EXPORT_SYMBOL(wrmsr_safe_regs_on_cpu);
index 872834177937231b5ff9c55965e77929b0d55b98..8f8eebdca7d4cadc249405e8a0c50108e34edc3b 100644 (file)
@@ -1,123 +1,7 @@
 #include <linux/module.h>
 #include <linux/preempt.h>
-#include <linux/smp.h>
 #include <asm/msr.h>
 
-struct msr_info {
-       u32 msr_no;
-       struct msr reg;
-       struct msr *msrs;
-       int err;
-};
-
-static void __rdmsr_on_cpu(void *info)
-{
-       struct msr_info *rv = info;
-       struct msr *reg;
-       int this_cpu = raw_smp_processor_id();
-
-       if (rv->msrs)
-               reg = per_cpu_ptr(rv->msrs, this_cpu);
-       else
-               reg = &rv->reg;
-
-       rdmsr(rv->msr_no, reg->l, reg->h);
-}
-
-static void __wrmsr_on_cpu(void *info)
-{
-       struct msr_info *rv = info;
-       struct msr *reg;
-       int this_cpu = raw_smp_processor_id();
-
-       if (rv->msrs)
-               reg = per_cpu_ptr(rv->msrs, this_cpu);
-       else
-               reg = &rv->reg;
-
-       wrmsr(rv->msr_no, reg->l, reg->h);
-}
-
-int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
-{
-       int err;
-       struct msr_info rv;
-
-       memset(&rv, 0, sizeof(rv));
-
-       rv.msr_no = msr_no;
-       err = smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
-       *l = rv.reg.l;
-       *h = rv.reg.h;
-
-       return err;
-}
-EXPORT_SYMBOL(rdmsr_on_cpu);
-
-int wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
-{
-       int err;
-       struct msr_info rv;
-
-       memset(&rv, 0, sizeof(rv));
-
-       rv.msr_no = msr_no;
-       rv.reg.l = l;
-       rv.reg.h = h;
-       err = smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
-
-       return err;
-}
-EXPORT_SYMBOL(wrmsr_on_cpu);
-
-static void __rwmsr_on_cpus(const struct cpumask *mask, u32 msr_no,
-                           struct msr *msrs,
-                           void (*msr_func) (void *info))
-{
-       struct msr_info rv;
-       int this_cpu;
-
-       memset(&rv, 0, sizeof(rv));
-
-       rv.msrs   = msrs;
-       rv.msr_no = msr_no;
-
-       this_cpu = get_cpu();
-
-       if (cpumask_test_cpu(this_cpu, mask))
-               msr_func(&rv);
-
-       smp_call_function_many(mask, msr_func, &rv, 1);
-       put_cpu();
-}
-
-/* rdmsr on a bunch of CPUs
- *
- * @mask:       which CPUs
- * @msr_no:     which MSR
- * @msrs:       array of MSR values
- *
- */
-void rdmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
-{
-       __rwmsr_on_cpus(mask, msr_no, msrs, __rdmsr_on_cpu);
-}
-EXPORT_SYMBOL(rdmsr_on_cpus);
-
-/*
- * wrmsr on a bunch of CPUs
- *
- * @mask:       which CPUs
- * @msr_no:     which MSR
- * @msrs:       array of MSR values
- *
- */
-void wrmsr_on_cpus(const struct cpumask *mask, u32 msr_no, struct msr *msrs)
-{
-       __rwmsr_on_cpus(mask, msr_no, msrs, __wrmsr_on_cpu);
-}
-EXPORT_SYMBOL(wrmsr_on_cpus);
-
 struct msr *msrs_alloc(void)
 {
        struct msr *msrs = NULL;
@@ -137,100 +21,3 @@ void msrs_free(struct msr *msrs)
        free_percpu(msrs);
 }
 EXPORT_SYMBOL(msrs_free);
-
-/* These "safe" variants are slower and should be used when the target MSR
-   may not actually exist. */
-static void __rdmsr_safe_on_cpu(void *info)
-{
-       struct msr_info *rv = info;
-
-       rv->err = rdmsr_safe(rv->msr_no, &rv->reg.l, &rv->reg.h);
-}
-
-static void __wrmsr_safe_on_cpu(void *info)
-{
-       struct msr_info *rv = info;
-
-       rv->err = wrmsr_safe(rv->msr_no, rv->reg.l, rv->reg.h);
-}
-
-int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
-{
-       int err;
-       struct msr_info rv;
-
-       memset(&rv, 0, sizeof(rv));
-
-       rv.msr_no = msr_no;
-       err = smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
-       *l = rv.reg.l;
-       *h = rv.reg.h;
-
-       return err ? err : rv.err;
-}
-EXPORT_SYMBOL(rdmsr_safe_on_cpu);
-
-int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
-{
-       int err;
-       struct msr_info rv;
-
-       memset(&rv, 0, sizeof(rv));
-
-       rv.msr_no = msr_no;
-       rv.reg.l = l;
-       rv.reg.h = h;
-       err = smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1);
-
-       return err ? err : rv.err;
-}
-EXPORT_SYMBOL(wrmsr_safe_on_cpu);
-
-/*
- * These variants are significantly slower, but allows control over
- * the entire 32-bit GPR set.
- */
-struct msr_regs_info {
-       u32 *regs;
-       int err;
-};
-
-static void __rdmsr_safe_regs_on_cpu(void *info)
-{
-       struct msr_regs_info *rv = info;
-
-       rv->err = rdmsr_safe_regs(rv->regs);
-}
-
-static void __wrmsr_safe_regs_on_cpu(void *info)
-{
-       struct msr_regs_info *rv = info;
-
-       rv->err = wrmsr_safe_regs(rv->regs);
-}
-
-int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
-{
-       int err;
-       struct msr_regs_info rv;
-
-       rv.regs   = regs;
-       rv.err    = -EIO;
-       err = smp_call_function_single(cpu, __rdmsr_safe_regs_on_cpu, &rv, 1);
-
-       return err ? err : rv.err;
-}
-EXPORT_SYMBOL(rdmsr_safe_regs_on_cpu);
-
-int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
-{
-       int err;
-       struct msr_regs_info rv;
-
-       rv.regs = regs;
-       rv.err  = -EIO;
-       err = smp_call_function_single(cpu, __wrmsr_safe_regs_on_cpu, &rv, 1);
-
-       return err ? err : rv.err;
-}
-EXPORT_SYMBOL(wrmsr_safe_regs_on_cpu);
index 6f8aa33031c7486dde049c2ffc875e886598c075..9324f13492d51bf005921e23bdef80bd67f2d2f1 100644 (file)
@@ -267,6 +267,8 @@ int __init get_memcfg_from_srat(void)
                e820_register_active_regions(chunk->nid, chunk->start_pfn,
                                             min(chunk->end_pfn, max_pfn));
        }
+       /* for out of order entries in SRAT */
+       sort_node_map();
 
        for_each_online_node(nid) {
                unsigned long start = node_start_pfn[nid];
index d890754896647d003df5d687c210b7f75d880c58..a27124185fc1eca178798d63378e2935688ba656 100644 (file)
@@ -317,7 +317,7 @@ static int __init nodes_cover_memory(const struct bootnode *nodes)
                unsigned long s = nodes[i].start >> PAGE_SHIFT;
                unsigned long e = nodes[i].end >> PAGE_SHIFT;
                pxmram += e - s;
-               pxmram -= absent_pages_in_range(s, e);
+               pxmram -= __absent_pages_in_range(i, s, e);
                if ((long)pxmram < 0)
                        pxmram = 0;
        }
@@ -373,6 +373,8 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
        for_each_node_mask(i, nodes_parsed)
                e820_register_active_regions(i, nodes[i].start >> PAGE_SHIFT,
                                                nodes[i].end >> PAGE_SHIFT);
+       /* for out of order entries in SRAT */
+       sort_node_map();
        if (!nodes_cover_memory(nodes)) {
                bad_srat();
                return -1;
index 044897be021f0ed4a7bfc3eb3ee6208d2ae37dab..3855096c59b81910fe827c76151e84bbac836770 100644 (file)
@@ -41,10 +41,11 @@ static void backtrace_address(void *data, unsigned long addr, int reliable)
 }
 
 static struct stacktrace_ops backtrace_ops = {
-       .warning = backtrace_warning,
-       .warning_symbol = backtrace_warning_symbol,
-       .stack = backtrace_stack,
-       .address = backtrace_address,
+       .warning        = backtrace_warning,
+       .warning_symbol = backtrace_warning_symbol,
+       .stack          = backtrace_stack,
+       .address        = backtrace_address,
+       .walk_stack     = print_context_stack,
 };
 
 struct frame_head {
index 145df00e038759499d2b70b97babf24255fa8285..f939d603adfab4257dca888766584b378c0be5e9 100644 (file)
@@ -51,7 +51,7 @@ void x86_pci_root_bus_res_quirks(struct pci_bus *b)
        }
 }
 
-void __init update_res(struct pci_root_info *info, size_t start,
+void __devinit update_res(struct pci_root_info *info, size_t start,
                              size_t end, unsigned long flags, int merge)
 {
        int i;
index 0d13cd9fdcffd6e5cc791bb23770de06df3a46d9..5bbb5a33f22029f39578114adfef535971e4853a 100644 (file)
@@ -9,7 +9,7 @@ BEGIN {
 }
 
 /^GNU/ {
-       split($4, ver, ".");
+       split($3, ver, ".");
        if (ver[1] > od_ver ||
            (ver[1] == od_ver && ver[2] >= od_sver)) {
                exit 1;
index e34e92a28eb6692d610498e7e0e44aa701d2fb72..eaf11f52fc0bd8e74513ad8e83a65cb37c1ba3cc 100644 (file)
@@ -6,8 +6,6 @@
 
 # Awk implementation sanity check
 function check_awk_implement() {
-       if (!match("abc", "[[:lower:]]+"))
-               return "Your awk doesn't support charactor-class."
        if (sprintf("%x", 0) != "0")
                return "Your awk has a printf-format problem."
        return ""
@@ -44,12 +42,12 @@ BEGIN {
        delete gtable
        delete atable
 
-       opnd_expr = "^[[:alpha:]/]"
+       opnd_expr = "^[A-Za-z/]"
        ext_expr = "^\\("
        sep_expr = "^\\|$"
-       group_expr = "^Grp[[:alnum:]]+"
+       group_expr = "^Grp[0-9A-Za-z]+"
 
-       imm_expr = "^[IJAO][[:lower:]]"
+       imm_expr = "^[IJAO][a-z]"
        imm_flag["Ib"] = "INAT_MAKE_IMM(INAT_IMM_BYTE)"
        imm_flag["Jb"] = "INAT_MAKE_IMM(INAT_IMM_BYTE)"
        imm_flag["Iw"] = "INAT_MAKE_IMM(INAT_IMM_WORD)"
@@ -62,7 +60,7 @@ BEGIN {
        imm_flag["Ob"] = "INAT_MOFFSET"
        imm_flag["Ov"] = "INAT_MOFFSET"
 
-       modrm_expr = "^([CDEGMNPQRSUVW/][[:lower:]]+|NTA|T[012])"
+       modrm_expr = "^([CDEGMNPQRSUVW/][a-z]+|NTA|T[012])"
        force64_expr = "\\([df]64\\)"
        rex_expr = "^REX(\\.[XRWB]+)*"
        fpu_expr = "^ESC" # TODO
@@ -226,12 +224,12 @@ function add_flags(old,new) {
 }
 
 # convert operands to flags.
-function convert_operands(opnd,       i,imm,mod)
+function convert_operands(count,opnd,       i,j,imm,mod)
 {
        imm = null
        mod = null
-       for (i in opnd) {
-               i  = opnd[i]
+       for (j = 1; j <= count; j++) {
+               i = opnd[j]
                if (match(i, imm_expr) == 1) {
                        if (!imm_flag[i])
                                semantic_error("Unknown imm opnd: " i)
@@ -282,8 +280,8 @@ function convert_operands(opnd,       i,imm,mod)
                # parse one opcode
                if (match($i, opnd_expr)) {
                        opnd = $i
-                       split($(i++), opnds, ",")
-                       flags = convert_operands(opnds)
+                       count = split($(i++), opnds, ",")
+                       flags = convert_operands(count, opnds)
                }
                if (match($i, ext_expr))
                        ext = $(i++)
index 36a5141108dfac6f6ad72a0591d40cded14d23a4..24ded31b5aeceeabfadc05fc5c5ff7aa95fa2b97 100644 (file)
@@ -120,14 +120,14 @@ struct xen_spinlock {
        unsigned short spinners;        /* count of waiting cpus */
 };
 
-static int xen_spin_is_locked(struct raw_spinlock *lock)
+static int xen_spin_is_locked(struct arch_spinlock *lock)
 {
        struct xen_spinlock *xl = (struct xen_spinlock *)lock;
 
        return xl->lock != 0;
 }
 
-static int xen_spin_is_contended(struct raw_spinlock *lock)
+static int xen_spin_is_contended(struct arch_spinlock *lock)
 {
        struct xen_spinlock *xl = (struct xen_spinlock *)lock;
 
@@ -136,7 +136,7 @@ static int xen_spin_is_contended(struct raw_spinlock *lock)
        return xl->spinners != 0;
 }
 
-static int xen_spin_trylock(struct raw_spinlock *lock)
+static int xen_spin_trylock(struct arch_spinlock *lock)
 {
        struct xen_spinlock *xl = (struct xen_spinlock *)lock;
        u8 old = 1;
@@ -181,7 +181,7 @@ static inline void unspinning_lock(struct xen_spinlock *xl, struct xen_spinlock
        __get_cpu_var(lock_spinners) = prev;
 }
 
-static noinline int xen_spin_lock_slow(struct raw_spinlock *lock, bool irq_enable)
+static noinline int xen_spin_lock_slow(struct arch_spinlock *lock, bool irq_enable)
 {
        struct xen_spinlock *xl = (struct xen_spinlock *)lock;
        struct xen_spinlock *prev;
@@ -254,7 +254,7 @@ out:
        return ret;
 }
 
-static inline void __xen_spin_lock(struct raw_spinlock *lock, bool irq_enable)
+static inline void __xen_spin_lock(struct arch_spinlock *lock, bool irq_enable)
 {
        struct xen_spinlock *xl = (struct xen_spinlock *)lock;
        unsigned timeout;
@@ -291,12 +291,12 @@ static inline void __xen_spin_lock(struct raw_spinlock *lock, bool irq_enable)
        spin_time_accum_total(start_spin);
 }
 
-static void xen_spin_lock(struct raw_spinlock *lock)
+static void xen_spin_lock(struct arch_spinlock *lock)
 {
        __xen_spin_lock(lock, false);
 }
 
-static void xen_spin_lock_flags(struct raw_spinlock *lock, unsigned long flags)
+static void xen_spin_lock_flags(struct arch_spinlock *lock, unsigned long flags)
 {
        __xen_spin_lock(lock, !raw_irqs_disabled_flags(flags));
 }
@@ -317,7 +317,7 @@ static noinline void xen_spin_unlock_slow(struct xen_spinlock *xl)
        }
 }
 
-static void xen_spin_unlock(struct raw_spinlock *lock)
+static void xen_spin_unlock(struct arch_spinlock *lock)
 {
        struct xen_spinlock *xl = (struct xen_spinlock *)lock;
 
diff --git a/arch/xtensa/include/asm/asm-offsets.h b/arch/xtensa/include/asm/asm-offsets.h
new file mode 100644 (file)
index 0000000..d370ee3
--- /dev/null
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
index c3f53e755ca5c16fabff550b1c7859c6521c9e17..5eb6d695e9872563ab9cd14a2cf67b2a9ad142bc 100644 (file)
@@ -123,7 +123,6 @@ extern void xtensa_elf_core_copy_regs (xtensa_gregset_t *, struct pt_regs *);
 #define ELF_CLASS      ELFCLASS32
 #define ELF_ARCH       EM_XTENSA
 
-#define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE      PAGE_SIZE
 
 /*
index 4352dbe1186ae07d571abe2c1031f94e73df24ac..efcf33b92e4c02e77df78a78d95c112badc60716 100644 (file)
@@ -12,7 +12,6 @@ struct pt_regs;
 struct sigaction;
 asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*);
 asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*);
-asmlinkage long xtensa_pipe(int __user *);
 asmlinkage long xtensa_ptrace(long, long, long, long);
 asmlinkage long xtensa_sigreturn(struct pt_regs*);
 asmlinkage long xtensa_rt_sigreturn(struct pt_regs*);
index fbf318b3af3e3b688515e7b4e26dd5d0097ef1ff..528042c2951ea5949bcf6c27875e7977dd2a90db 100644 (file)
@@ -94,7 +94,7 @@ __SYSCALL( 35, sys_readlink, 3)
 #define __NR_mknod                              36
 __SYSCALL( 36, sys_mknod, 3)
 #define __NR_pipe                               37
-__SYSCALL( 37, xtensa_pipe, 1)
+__SYSCALL( 37, sys_pipe, 1)
 #define __NR_unlink                             38
 __SYSCALL( 38, sys_unlink, 1)
 #define __NR_rmdir                              39
index a1badb32fcdaea8b43350f3853f8efc66be928d8..8cd38484e1306ab8e12aeeb1185813960f0a8869 100644 (file)
@@ -90,7 +90,7 @@ int show_interrupts(struct seq_file *p, void *v)
        }
 
        if (i < NR_IRQS) {
-               spin_lock_irqsave(&irq_desc[i].lock, flags);
+               raw_spin_lock_irqsave(&irq_desc[i].lock, flags);
                action = irq_desc[i].action;
                if (!action)
                        goto skip;
@@ -109,7 +109,7 @@ int show_interrupts(struct seq_file *p, void *v)
 
                seq_putc(p, '\n');
 skip:
-               spin_unlock_irqrestore(&irq_desc[i].lock, flags);
+               raw_spin_unlock_irqrestore(&irq_desc[i].lock, flags);
        } else if (i == NR_IRQS) {
                seq_printf(p, "NMI: ");
                for_each_online_cpu(j)
index 1e67bab775c18fc47a79d6701c30264d20350377..816e6d0d686c6f934bae7de3786ee4fc463ac567 100644 (file)
@@ -39,24 +39,6 @@ syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= {
 #include <asm/unistd.h>
 };
 
-/*
- * xtensa_pipe() is the normal C calling standard for creating a pipe. It's not
- * the way unix traditional does this, though.
- */
-
-asmlinkage long xtensa_pipe(int __user *userfds)
-{
-       int fd[2];
-       int error;
-
-       error = do_pipe_flags(fd, 0);
-       if (!error) {
-               if (copy_to_user(userfds, fd, 2 * sizeof(int)))
-                       error = -EFAULT;
-       }
-       return error;
-}
-
 asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
 {
        unsigned long ret;
index 8873b9b439ffdb0bf695b0077f84bb28c1046a38..8618d8996fea9c9b278b7529d44ac958c24fa465 100644 (file)
@@ -402,7 +402,7 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
                 * our current implementations need.  If we'll ever need
                 * more the interface will need revisiting.
                 */
-               page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+               page = alloc_page(gfp_mask | __GFP_ZERO);
                if (!page)
                        goto out_free_bio;
                if (bio_add_pc_page(q, bio, page, sector_size, 0) < sector_size)
index dd1f1e0e196f932cfe6abab7f74f84602557d05d..d52d4adc440b29e8d428a9f05d59413d2bb421c9 100644 (file)
@@ -505,21 +505,30 @@ static unsigned int lcm(unsigned int a, unsigned int b)
 
 /**
  * blk_stack_limits - adjust queue_limits for stacked devices
- * @t: the stacking driver limits (top)
- * @b:  the underlying queue limits (bottom)
+ * @t: the stacking driver limits (top device)
+ * @b:  the underlying queue limits (bottom, component device)
  * @offset:  offset to beginning of data within component device
  *
  * Description:
- *    Merges two queue_limit structs.  Returns 0 if alignment didn't
- *    change.  Returns -1 if adding the bottom device caused
- *    misalignment.
+ *    This function is used by stacking drivers like MD and DM to ensure
+ *    that all component devices have compatible block sizes and
+ *    alignments.  The stacking driver must provide a queue_limits
+ *    struct (top) and then iteratively call the stacking function for
+ *    all component (bottom) devices.  The stacking function will
+ *    attempt to combine the values and ensure proper alignment.
+ *
+ *    Returns 0 if the top and bottom queue_limits are compatible.  The
+ *    top device's block sizes and alignment offsets may be adjusted to
+ *    ensure alignment with the bottom device. If no compatible sizes
+ *    and alignments exist, -1 is returned and the resulting top
+ *    queue_limits will have the misaligned flag set to indicate that
+ *    the alignment_offset is undefined.
  */
 int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
                     sector_t offset)
 {
-       int ret;
-
-       ret = 0;
+       sector_t alignment;
+       unsigned int top, bottom;
 
        t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
        t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
@@ -537,6 +546,22 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
        t->max_segment_size = min_not_zero(t->max_segment_size,
                                           b->max_segment_size);
 
+       alignment = queue_limit_alignment_offset(b, offset);
+
+       /* Bottom device has different alignment.  Check that it is
+        * compatible with the current top alignment.
+        */
+       if (t->alignment_offset != alignment) {
+
+               top = max(t->physical_block_size, t->io_min)
+                       + t->alignment_offset;
+               bottom = max(b->physical_block_size, b->io_min) + alignment;
+
+               /* Verify that top and bottom intervals line up */
+               if (max(top, bottom) & (min(top, bottom) - 1))
+                       t->misaligned = 1;
+       }
+
        t->logical_block_size = max(t->logical_block_size,
                                    b->logical_block_size);
 
@@ -544,47 +569,64 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
                                     b->physical_block_size);
 
        t->io_min = max(t->io_min, b->io_min);
+       t->io_opt = lcm(t->io_opt, b->io_opt);
+
        t->no_cluster |= b->no_cluster;
        t->discard_zeroes_data &= b->discard_zeroes_data;
 
-       /* Bottom device offset aligned? */
-       if (offset &&
-           (offset & (b->physical_block_size - 1)) != b->alignment_offset) {
+       /* Physical block size a multiple of the logical block size? */
+       if (t->physical_block_size & (t->logical_block_size - 1)) {
+               t->physical_block_size = t->logical_block_size;
                t->misaligned = 1;
-               ret = -1;
        }
 
-       if (offset &&
-           (offset & (b->discard_granularity - 1)) != b->discard_alignment) {
-               t->discard_misaligned = 1;
-               ret = -1;
+       /* Minimum I/O a multiple of the physical block size? */
+       if (t->io_min & (t->physical_block_size - 1)) {
+               t->io_min = t->physical_block_size;
+               t->misaligned = 1;
        }
 
-       /* If top has no alignment offset, inherit from bottom */
-       if (!t->alignment_offset)
-               t->alignment_offset =
-                       b->alignment_offset & (b->physical_block_size - 1);
-
-       if (!t->discard_alignment)
-               t->discard_alignment =
-                       b->discard_alignment & (b->discard_granularity - 1);
-
-       /* Top device aligned on logical block boundary? */
-       if (t->alignment_offset & (t->logical_block_size - 1)) {
+       /* Optimal I/O a multiple of the physical block size? */
+       if (t->io_opt & (t->physical_block_size - 1)) {
+               t->io_opt = 0;
                t->misaligned = 1;
-               ret = -1;
        }
 
-       /* Find lcm() of optimal I/O size and granularity */
-       t->io_opt = lcm(t->io_opt, b->io_opt);
-       t->discard_granularity = lcm(t->discard_granularity,
-                                    b->discard_granularity);
+       /* Find lowest common alignment_offset */
+       t->alignment_offset = lcm(t->alignment_offset, alignment)
+               & (max(t->physical_block_size, t->io_min) - 1);
+
+       /* Verify that new alignment_offset is on a logical block boundary */
+       if (t->alignment_offset & (t->logical_block_size - 1))
+               t->misaligned = 1;
 
-       /* Verify that optimal I/O size is a multiple of io_min */
-       if (t->io_min && t->io_opt % t->io_min)
-               ret = -1;
+       /* Discard alignment and granularity */
+       if (b->discard_granularity) {
+               unsigned int granularity = b->discard_granularity;
+               offset &= granularity - 1;
+
+               alignment = (granularity + b->discard_alignment - offset)
+                       & (granularity - 1);
+
+               if (t->discard_granularity != 0 &&
+                   t->discard_alignment != alignment) {
+                       top = t->discard_granularity + t->discard_alignment;
+                       bottom = b->discard_granularity + alignment;
+
+                       /* Verify that top and bottom intervals line up */
+                       if (max(top, bottom) & (min(top, bottom) - 1))
+                               t->discard_misaligned = 1;
+               }
+
+               t->max_discard_sectors = min_not_zero(t->max_discard_sectors,
+                                                     b->max_discard_sectors);
+               t->discard_granularity = max(t->discard_granularity,
+                                            b->discard_granularity);
+               t->discard_alignment = lcm(t->discard_alignment, alignment) &
+                       (t->discard_granularity - 1);
+       }
 
-       return ret;
+       return t->misaligned ? -1 : 0;
 }
 EXPORT_SYMBOL(blk_stack_limits);
 
index cfb0b2f5f63de6d75213b16373f84a248fbd6421..918c7fd9aeb1f9c662606a754ddfafa511193897 100644 (file)
@@ -208,8 +208,6 @@ struct cfq_data {
        /* Root service tree for cfq_groups */
        struct cfq_rb_root grp_service_tree;
        struct cfq_group root_group;
-       /* Number of active cfq groups on group service tree */
-       int nr_groups;
 
        /*
         * The priority currently being served
@@ -283,7 +281,7 @@ struct cfq_data {
         */
        struct cfq_queue oom_cfqq;
 
-       unsigned long last_end_sync_rq;
+       unsigned long last_delayed_sync;
 
        /* List of cfq groups being managed on this device*/
        struct hlist_head cfqg_list;
@@ -294,8 +292,7 @@ static struct cfq_group *cfq_get_next_cfqg(struct cfq_data *cfqd);
 
 static struct cfq_rb_root *service_tree_for(struct cfq_group *cfqg,
                                            enum wl_prio_t prio,
-                                           enum wl_type_t type,
-                                           struct cfq_data *cfqd)
+                                           enum wl_type_t type)
 {
        if (!cfqg)
                return NULL;
@@ -319,7 +316,6 @@ enum cfqq_state_flags {
        CFQ_CFQQ_FLAG_coop,             /* cfqq is shared */
        CFQ_CFQQ_FLAG_deep,             /* sync cfqq experienced large depth */
        CFQ_CFQQ_FLAG_wait_busy,        /* Waiting for next request */
-       CFQ_CFQQ_FLAG_wait_busy_done,   /* Got new request. Expire the queue */
 };
 
 #define CFQ_CFQQ_FNS(name)                                             \
@@ -348,7 +344,6 @@ CFQ_CFQQ_FNS(sync);
 CFQ_CFQQ_FNS(coop);
 CFQ_CFQQ_FNS(deep);
 CFQ_CFQQ_FNS(wait_busy);
-CFQ_CFQQ_FNS(wait_busy_done);
 #undef CFQ_CFQQ_FNS
 
 #ifdef CONFIG_DEBUG_CFQ_IOSCHED
@@ -844,7 +839,6 @@ cfq_group_service_tree_add(struct cfq_data *cfqd, struct cfq_group *cfqg)
 
        __cfq_group_service_tree_add(st, cfqg);
        cfqg->on_st = true;
-       cfqd->nr_groups++;
        st->total_weight += cfqg->weight;
 }
 
@@ -865,7 +859,6 @@ cfq_group_service_tree_del(struct cfq_data *cfqd, struct cfq_group *cfqg)
 
        cfq_log_cfqg(cfqd, cfqg, "del_from_rr group");
        cfqg->on_st = false;
-       cfqd->nr_groups--;
        st->total_weight -= cfqg->weight;
        if (!RB_EMPTY_NODE(&cfqg->rb_node))
                cfq_rb_erase(&cfqg->rb_node, st);
@@ -1152,7 +1145,7 @@ static void cfq_service_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq,
 #endif
 
        service_tree = service_tree_for(cfqq->cfqg, cfqq_prio(cfqq),
-                                               cfqq_type(cfqq), cfqd);
+                                               cfqq_type(cfqq));
        if (cfq_class_idle(cfqq)) {
                rb_key = CFQ_IDLE_DELAY;
                parent = rb_last(&service_tree->rb);
@@ -1515,9 +1508,6 @@ static int cfq_allow_merge(struct request_queue *q, struct request *rq,
        struct cfq_io_context *cic;
        struct cfq_queue *cfqq;
 
-       /* Deny merge if bio and rq don't belong to same cfq group */
-       if ((RQ_CFQQ(rq))->cfqg != cfq_get_cfqg(cfqd, 0))
-               return false;
        /*
         * Disallow merge of a sync bio into an async request.
         */
@@ -1574,7 +1564,6 @@ __cfq_slice_expired(struct cfq_data *cfqd, struct cfq_queue *cfqq,
 
        cfq_clear_cfqq_wait_request(cfqq);
        cfq_clear_cfqq_wait_busy(cfqq);
-       cfq_clear_cfqq_wait_busy_done(cfqq);
 
        /*
         * store what was left of this slice, if the queue idled/timed out
@@ -1619,7 +1608,7 @@ static struct cfq_queue *cfq_get_next_queue(struct cfq_data *cfqd)
 {
        struct cfq_rb_root *service_tree =
                service_tree_for(cfqd->serving_group, cfqd->serving_prio,
-                                       cfqd->serving_type, cfqd);
+                                       cfqd->serving_type);
 
        if (!cfqd->rq_queued)
                return NULL;
@@ -1678,13 +1667,17 @@ static inline sector_t cfq_dist_from_last(struct cfq_data *cfqd,
 #define CFQQ_SEEKY(cfqq)       ((cfqq)->seek_mean > CFQQ_SEEK_THR)
 
 static inline int cfq_rq_close(struct cfq_data *cfqd, struct cfq_queue *cfqq,
-                              struct request *rq)
+                              struct request *rq, bool for_preempt)
 {
        sector_t sdist = cfqq->seek_mean;
 
        if (!sample_valid(cfqq->seek_samples))
                sdist = CFQQ_SEEK_THR;
 
+       /* if seek_mean is big, using it as close criteria is meaningless */
+       if (sdist > CFQQ_SEEK_THR && !for_preempt)
+               sdist = CFQQ_SEEK_THR;
+
        return cfq_dist_from_last(cfqd, rq) <= sdist;
 }
 
@@ -1712,7 +1705,7 @@ static struct cfq_queue *cfqq_close(struct cfq_data *cfqd,
         * will contain the closest sector.
         */
        __cfqq = rb_entry(parent, struct cfq_queue, p_node);
-       if (cfq_rq_close(cfqd, cur_cfqq, __cfqq->next_rq))
+       if (cfq_rq_close(cfqd, cur_cfqq, __cfqq->next_rq, false))
                return __cfqq;
 
        if (blk_rq_pos(__cfqq->next_rq) < sector)
@@ -1723,7 +1716,7 @@ static struct cfq_queue *cfqq_close(struct cfq_data *cfqd,
                return NULL;
 
        __cfqq = rb_entry(node, struct cfq_queue, p_node);
-       if (cfq_rq_close(cfqd, cur_cfqq, __cfqq->next_rq))
+       if (cfq_rq_close(cfqd, cur_cfqq, __cfqq->next_rq, false))
                return __cfqq;
 
        return NULL;
@@ -1749,6 +1742,12 @@ static struct cfq_queue *cfq_close_cooperator(struct cfq_data *cfqd,
        if (CFQQ_SEEKY(cur_cfqq))
                return NULL;
 
+       /*
+        * Don't search priority tree if it's the only queue in the group.
+        */
+       if (cur_cfqq->cfqg->nr_cfqq == 1)
+               return NULL;
+
        /*
         * We should notice if some of the queues are cooperating, eg
         * working closely on the same area of the disk. In that case,
@@ -1960,8 +1959,7 @@ static void cfq_setup_merge(struct cfq_queue *cfqq, struct cfq_queue *new_cfqq)
 }
 
 static enum wl_type_t cfq_choose_wl(struct cfq_data *cfqd,
-                               struct cfq_group *cfqg, enum wl_prio_t prio,
-                               bool prio_changed)
+                               struct cfq_group *cfqg, enum wl_prio_t prio)
 {
        struct cfq_queue *queue;
        int i;
@@ -1969,24 +1967,9 @@ static enum wl_type_t cfq_choose_wl(struct cfq_data *cfqd,
        unsigned long lowest_key = 0;
        enum wl_type_t cur_best = SYNC_NOIDLE_WORKLOAD;
 
-       if (prio_changed) {
-               /*
-                * When priorities switched, we prefer starting
-                * from SYNC_NOIDLE (first choice), or just SYNC
-                * over ASYNC
-                */
-               if (service_tree_for(cfqg, prio, cur_best, cfqd)->count)
-                       return cur_best;
-               cur_best = SYNC_WORKLOAD;
-               if (service_tree_for(cfqg, prio, cur_best, cfqd)->count)
-                       return cur_best;
-
-               return ASYNC_WORKLOAD;
-       }
-
-       for (i = 0; i < 3; ++i) {
-               /* otherwise, select the one with lowest rb_key */
-               queue = cfq_rb_first(service_tree_for(cfqg, prio, i, cfqd));
+       for (i = 0; i <= SYNC_WORKLOAD; ++i) {
+               /* select the one with lowest rb_key */
+               queue = cfq_rb_first(service_tree_for(cfqg, prio, i));
                if (queue &&
                    (!key_valid || time_before(queue->rb_key, lowest_key))) {
                        lowest_key = queue->rb_key;
@@ -2000,8 +1983,6 @@ static enum wl_type_t cfq_choose_wl(struct cfq_data *cfqd,
 
 static void choose_service_tree(struct cfq_data *cfqd, struct cfq_group *cfqg)
 {
-       enum wl_prio_t previous_prio = cfqd->serving_prio;
-       bool prio_changed;
        unsigned slice;
        unsigned count;
        struct cfq_rb_root *st;
@@ -2029,24 +2010,19 @@ static void choose_service_tree(struct cfq_data *cfqd, struct cfq_group *cfqg)
         * (SYNC, SYNC_NOIDLE, ASYNC), and to compute a workload
         * expiration time
         */
-       prio_changed = (cfqd->serving_prio != previous_prio);
-       st = service_tree_for(cfqg, cfqd->serving_prio, cfqd->serving_type,
-                               cfqd);
+       st = service_tree_for(cfqg, cfqd->serving_prio, cfqd->serving_type);
        count = st->count;
 
        /*
-        * If priority didn't change, check workload expiration,
-        * and that we still have other queues ready
+        * check workload expiration, and that we still have other queues ready
         */
-       if (!prio_changed && count &&
-           !time_after(jiffies, cfqd->workload_expires))
+       if (count && !time_after(jiffies, cfqd->workload_expires))
                return;
 
        /* otherwise select new workload type */
        cfqd->serving_type =
-               cfq_choose_wl(cfqd, cfqg, cfqd->serving_prio, prio_changed);
-       st = service_tree_for(cfqg, cfqd->serving_prio, cfqd->serving_type,
-                               cfqd);
+               cfq_choose_wl(cfqd, cfqg, cfqd->serving_prio);
+       st = service_tree_for(cfqg, cfqd->serving_prio, cfqd->serving_type);
        count = st->count;
 
        /*
@@ -2110,7 +2086,9 @@ static void cfq_choose_cfqg(struct cfq_data *cfqd)
                cfqd->workload_expires = jiffies + cfqg->saved_workload_slice;
                cfqd->serving_type = cfqg->saved_workload;
                cfqd->serving_prio = cfqg->saved_serving_prio;
-       }
+       } else
+               cfqd->workload_expires = jiffies - 1;
+
        choose_service_tree(cfqd, cfqg);
 }
 
@@ -2128,13 +2106,34 @@ static struct cfq_queue *cfq_select_queue(struct cfq_data *cfqd)
 
        if (!cfqd->rq_queued)
                return NULL;
+
        /*
-        * The active queue has run out of time, expire it and select new.
+        * We were waiting for group to get backlogged. Expire the queue
         */
-       if ((cfq_slice_used(cfqq) || cfq_cfqq_wait_busy_done(cfqq))
-            && !cfq_cfqq_must_dispatch(cfqq))
+       if (cfq_cfqq_wait_busy(cfqq) && !RB_EMPTY_ROOT(&cfqq->sort_list))
                goto expire;
 
+       /*
+        * The active queue has run out of time, expire it and select new.
+        */
+       if (cfq_slice_used(cfqq) && !cfq_cfqq_must_dispatch(cfqq)) {
+               /*
+                * If slice had not expired at the completion of last request
+                * we might not have turned on wait_busy flag. Don't expire
+                * the queue yet. Allow the group to get backlogged.
+                *
+                * The very fact that we have used the slice, that means we
+                * have been idling all along on this queue and it should be
+                * ok to wait for this request to complete.
+                */
+               if (cfqq->cfqg->nr_cfqq == 1 && RB_EMPTY_ROOT(&cfqq->sort_list)
+                   && cfqq->dispatched && cfq_should_idle(cfqd, cfqq)) {
+                       cfqq = NULL;
+                       goto keep_queue;
+               } else
+                       goto expire;
+       }
+
        /*
         * The active queue has requests and isn't expired, allow it to
         * dispatch.
@@ -2264,7 +2263,7 @@ static bool cfq_may_dispatch(struct cfq_data *cfqd, struct cfq_queue *cfqq)
         * based on the last sync IO we serviced
         */
        if (!cfq_cfqq_sync(cfqq) && cfqd->cfq_latency) {
-               unsigned long last_sync = jiffies - cfqd->last_end_sync_rq;
+               unsigned long last_sync = jiffies - cfqd->last_delayed_sync;
                unsigned int depth;
 
                depth = last_sync / cfqd->cfq_slice[1];
@@ -3117,7 +3116,7 @@ cfq_should_preempt(struct cfq_data *cfqd, struct cfq_queue *new_cfqq,
         * if this request is as-good as one we would expect from the
         * current cfqq, let it preempt
         */
-       if (cfq_rq_close(cfqd, cfqq, rq))
+       if (cfq_rq_close(cfqd, cfqq, rq, true))
                return true;
 
        return false;
@@ -3165,10 +3164,6 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
        cfqq->last_request_pos = blk_rq_pos(rq) + blk_rq_sectors(rq);
 
        if (cfqq == cfqd->active_queue) {
-               if (cfq_cfqq_wait_busy(cfqq)) {
-                       cfq_clear_cfqq_wait_busy(cfqq);
-                       cfq_mark_cfqq_wait_busy_done(cfqq);
-               }
                /*
                 * Remember that we saw a request from this process, but
                 * don't start queuing just yet. Otherwise we risk seeing lots
@@ -3183,6 +3178,7 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
                        if (blk_rq_bytes(rq) > PAGE_CACHE_SIZE ||
                            cfqd->busy_queues > 1) {
                                del_timer(&cfqd->idle_slice_timer);
+                               cfq_clear_cfqq_wait_request(cfqq);
                                __blk_run_queue(cfqd->queue);
                        } else
                                cfq_mark_cfqq_must_dispatch(cfqq);
@@ -3251,6 +3247,35 @@ static void cfq_update_hw_tag(struct cfq_data *cfqd)
                cfqd->hw_tag = 0;
 }
 
+static bool cfq_should_wait_busy(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+{
+       struct cfq_io_context *cic = cfqd->active_cic;
+
+       /* If there are other queues in the group, don't wait */
+       if (cfqq->cfqg->nr_cfqq > 1)
+               return false;
+
+       if (cfq_slice_used(cfqq))
+               return true;
+
+       /* if slice left is less than think time, wait busy */
+       if (cic && sample_valid(cic->ttime_samples)
+           && (cfqq->slice_end - jiffies < cic->ttime_mean))
+               return true;
+
+       /*
+        * If think times is less than a jiffy than ttime_mean=0 and above
+        * will not be true. It might happen that slice has not expired yet
+        * but will expire soon (4-5 ns) during select_queue(). To cover the
+        * case where think time is less than a jiffy, mark the queue wait
+        * busy if only 1 jiffy is left in the slice.
+        */
+       if (cfqq->slice_end - jiffies == 1)
+               return true;
+
+       return false;
+}
+
 static void cfq_completed_request(struct request_queue *q, struct request *rq)
 {
        struct cfq_queue *cfqq = RQ_CFQQ(rq);
@@ -3273,7 +3298,8 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
 
        if (sync) {
                RQ_CIC(rq)->last_end_request = now;
-               cfqd->last_end_sync_rq = now;
+               if (!time_after(rq->start_time + cfqd->cfq_fifo_expire[1], now))
+                       cfqd->last_delayed_sync = now;
        }
 
        /*
@@ -3289,11 +3315,10 @@ static void cfq_completed_request(struct request_queue *q, struct request *rq)
                }
 
                /*
-                * If this queue consumed its slice and this is last queue
-                * in the group, wait for next request before we expire
-                * the queue
+                * Should we wait for next request to come in before we expire
+                * the queue.
                 */
-               if (cfq_slice_used(cfqq) && cfqq->cfqg->nr_cfqq == 1) {
+               if (cfq_should_wait_busy(cfqd, cfqq)) {
                        cfqq->slice_end = jiffies + cfqd->cfq_slice_idle;
                        cfq_mark_cfqq_wait_busy(cfqq);
                }
@@ -3711,7 +3736,11 @@ static void *cfq_init_queue(struct request_queue *q)
        cfqd->cfq_latency = 1;
        cfqd->cfq_group_isolation = 0;
        cfqd->hw_tag = -1;
-       cfqd->last_end_sync_rq = jiffies;
+       /*
+        * we optimistically start assuming sync ops weren't delayed in last
+        * second, in order to have larger depth for async operations.
+        */
+       cfqd->last_delayed_sync = jiffies - HZ;
        INIT_RCU_HEAD(&cfqd->rcu);
        return cfqd;
 }
index 3ec27c7e62eaff1d541a08b06154d8b197988620..f84f6b4301d98df03dd02c05db9d4351885bc39e 100644 (file)
@@ -214,6 +214,13 @@ static int raid6_test(void)
                err += test(4, &tests);
        if (NDISKS > 5)
                err += test(5, &tests);
+       /* the 11 and 12 disk cases are special for ioatdma (p-disabled
+        * q-continuation without extended descriptor)
+        */
+       if (NDISKS > 12) {
+               err += test(11, &tests);
+               err += test(12, &tests);
+       }
        err += test(NDISKS, &tests);
 
        pr("\n");
index 26e434ad373cef3d78f5c676844229143d24eb3d..8a07363417ed8aaa924c10f2c7ae0551968fd971 100644 (file)
@@ -96,6 +96,8 @@ source "drivers/edac/Kconfig"
 
 source "drivers/rtc/Kconfig"
 
+source "drivers/clocksource/Kconfig"
+
 source "drivers/dma/Kconfig"
 
 source "drivers/dca/Kconfig"
index d672cfe7ca5960997949ebede8bda6cd1088bbb8..cb423f5aef24b12247b1c604e021c421581cb4a9 100644 (file)
@@ -21,7 +21,6 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/autoconf.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
index c7b10b4298e991320cd45af4fcc5168118d4e4b3..66cc3f36a954f7d7b9151a390bc9b4cc6bd758c8 100644 (file)
@@ -32,6 +32,7 @@ acpi-$(CONFIG_ACPI_SLEEP)     += proc.o
 #
 acpi-y                         += bus.o glue.o
 acpi-y                         += scan.o
+acpi-y                         += processor_pdc.o
 acpi-y                         += ec.o
 acpi-$(CONFIG_ACPI_DOCK)       += dock.o
 acpi-y                         += pci_root.o pci_link.o pci_irq.o pci_bind.o
index 0d2cdb86158bec0c024436b7feba922a88a71844..97991ac6f5fcb4664881fa5b873cab061ab7fdc7 100644 (file)
@@ -100,7 +100,8 @@ static void round_robin_cpu(unsigned int tsk_index)
        struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
        cpumask_var_t tmp;
        int cpu;
-       unsigned long min_weight = -1, preferred_cpu;
+       unsigned long min_weight = -1;
+       unsigned long uninitialized_var(preferred_cpu);
 
        if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
                return;
index ab83919dda61d78b9fb42b182347111a20ae1da6..61edb156e8d088e7e320b6af4bb5a72e350aba66 100644 (file)
@@ -296,6 +296,11 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
                        acpi_status validate_status,
                        union acpi_operand_object **return_object_ptr);
 
+void
+acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
+                            u8 package_type,
+                            union acpi_operand_object *obj_desc);
+
 /*
  * nssearch - Namespace searching and entry
  */
@@ -354,9 +359,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
                         const char *internal_name,
                         u32 * converted_name_length, char **converted_name);
 
-struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle);
-
-acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node);
+struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle);
 
 void acpi_ns_terminate(void);
 
index b39d682a2140291509423ef6624e3d785d66f639..64062b1be3eee472be38220e18fa36ecab1917ad 100644 (file)
@@ -180,7 +180,11 @@ struct acpi_object_method {
        u8 sync_level;
        union acpi_operand_object *mutex;
        u8 *aml_start;
-       ACPI_INTERNAL_METHOD implementation;
+       union {
+               ACPI_INTERNAL_METHOD implementation;
+               union acpi_operand_object *handler;
+       } extra;
+
        u32 aml_length;
        u8 thread_count;
        acpi_owner_id owner_id;
index 567a4899a0186a2667295bba73a0918ecbb33b1b..e786f9fd767f3dc0a87715915573b52fd0ddd3bf 100644 (file)
@@ -414,7 +414,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
        /* Invoke an internal method if necessary */
 
        if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
-               status = obj_desc->method.implementation(next_walk_state);
+               status = obj_desc->method.extra.implementation(next_walk_state);
                if (status == AE_OK) {
                        status = AE_CTRL_TERMINATE;
                }
index 10fc785178437155f31b6c469ad1029e70dadb65..b40513dd6a6a90884c16678b4541dd8f84e867d5 100644 (file)
@@ -212,18 +212,19 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                case ACPI_TYPE_BUFFER:
 
                        /*
-                        * These types we will allow, but we will change the type. This
-                        * enables some existing code of the form:
+                        * These types we will allow, but we will change the type.
+                        * This enables some existing code of the form:
                         *
                         *  Name (DEB, 0)
                         *  Scope (DEB) { ... }
                         *
-                        * Note: silently change the type here. On the second pass, we will report
-                        * a warning
+                        * Note: silently change the type here. On the second pass,
+                        * we will report a warning
                         */
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-                                         "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
-                                         path,
+                                         "Type override - [%4.4s] had invalid type (%s) "
+                                         "for Scope operator, changed to type ANY\n",
+                                         acpi_ut_get_node_name(node),
                                          acpi_ut_get_type_name(node->type)));
 
                        node->type = ACPI_TYPE_ANY;
@@ -235,8 +236,10 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
                        /* All other types are an error */
 
                        ACPI_ERROR((AE_INFO,
-                                   "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)",
-                                   acpi_ut_get_type_name(node->type), path));
+                                   "Invalid type (%s) for target of "
+                                   "Scope operator [%4.4s] (Cannot override)",
+                                   acpi_ut_get_type_name(node->type),
+                                   acpi_ut_get_node_name(node)));
 
                        return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
                }
@@ -697,15 +700,16 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
                case ACPI_TYPE_BUFFER:
 
                        /*
-                        * These types we will allow, but we will change the type. This
-                        * enables some existing code of the form:
+                        * These types we will allow, but we will change the type.
+                        * This enables some existing code of the form:
                         *
                         *  Name (DEB, 0)
                         *  Scope (DEB) { ... }
                         */
                        ACPI_WARNING((AE_INFO,
-                                     "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",
-                                     buffer_ptr,
+                                     "Type override - [%4.4s] had invalid type (%s) "
+                                     "for Scope operator, changed to type ANY\n",
+                                     acpi_ut_get_node_name(node),
                                      acpi_ut_get_type_name(node->type)));
 
                        node->type = ACPI_TYPE_ANY;
@@ -717,9 +721,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
                        /* All other types are an error */
 
                        ACPI_ERROR((AE_INFO,
-                                   "Invalid type (%s) for target of Scope operator [%4.4s]",
+                                   "Invalid type (%s) for target of "
+                                   "Scope operator [%4.4s] (Cannot override)",
                                    acpi_ut_get_type_name(node->type),
-                                   buffer_ptr));
+                                   acpi_ut_get_node_name(node)));
 
                        return (AE_AML_OPERAND_TYPE);
                }
@@ -1047,9 +1052,22 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
                        }
 
                        /*
-                        * If we are executing a method, initialize the region
+                        * The op_region is not fully parsed at this time. The only valid
+                        * argument is the space_id. (We must save the address of the
+                        * AML of the address and length operands)
+                        *
+                        * If we have a valid region, initialize it. The namespace is
+                        * unlocked at this point.
+                        *
+                        * Need to unlock interpreter if it is locked (if we are running
+                        * a control method), in order to allow _REG methods to be run
+                        * during acpi_ev_initialize_region.
                         */
                        if (walk_state->method_node) {
+                               /*
+                                * Executing a method: initialize the region and unlock
+                                * the interpreter
+                                */
                                status =
                                    acpi_ex_create_region(op->named.data,
                                                          op->named.length,
@@ -1058,21 +1076,17 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
                                if (ACPI_FAILURE(status)) {
                                        return (status);
                                }
-                       }
 
-                       /*
-                        * The op_region is not fully parsed at this time. Only valid
-                        * argument is the space_id. (We must save the address of the
-                        * AML of the address and length operands)
-                        */
+                               acpi_ex_exit_interpreter();
+                       }
 
-                       /*
-                        * If we have a valid region, initialize it
-                        * Namespace is NOT locked at this point.
-                        */
                        status =
                            acpi_ev_initialize_region
                            (acpi_ns_get_attached_object(node), FALSE);
+                       if (walk_state->method_node) {
+                               acpi_ex_enter_interpreter();
+                       }
+
                        if (ACPI_FAILURE(status)) {
                                /*
                                 *  If AE_NOT_EXIST is returned, it is not fatal
index 0bc807c33a568b712cbb1ea27b4c37ca65ec772c..5336d911fbf07c7f6240d72a6691c766c9c1d5ad 100644 (file)
@@ -718,7 +718,7 @@ acpi_ev_install_handler(acpi_handle obj_handle,
 
        /* Convert and validate the device handle */
 
-       node = acpi_ns_map_handle_to_node(obj_handle);
+       node = acpi_ns_validate_handle(obj_handle);
        if (!node) {
                return (AE_BAD_PARAMETER);
        }
@@ -1087,7 +1087,7 @@ acpi_ev_reg_run(acpi_handle obj_handle,
 
        /* Convert and validate the device handle */
 
-       node = acpi_ns_map_handle_to_node(obj_handle);
+       node = acpi_ns_validate_handle(obj_handle);
        if (!node) {
                return (AE_BAD_PARAMETER);
        }
index cf29c4953028dbeaf2cd33a25c1a0c8dd184826b..ff168052a33261860675a4572c879bf754ab9b16 100644 (file)
@@ -575,6 +575,21 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
                                handler_obj = obj_desc->thermal_zone.handler;
                                break;
 
+                       case ACPI_TYPE_METHOD:
+                               /*
+                                * If we are executing module level code, the original
+                                * Node's object was replaced by this Method object and we
+                                * saved the handler in the method object.
+                                *
+                                * See acpi_ns_exec_module_code
+                                */
+                               if (obj_desc->method.
+                                   flags & AOPOBJ_MODULE_LEVEL) {
+                                       handler_obj =
+                                           obj_desc->method.extra.handler;
+                               }
+                               break;
+
                        default:
                                /* Ignore other objects */
                                break;
index 10b8543dd466e593b3d5f589af22cc7041843a24..2fe0809d4eb298162c99171073dcfa0162327b59 100644 (file)
@@ -259,7 +259,7 @@ acpi_install_notify_handler(acpi_handle device,
 
        /* Convert and validate the device handle */
 
-       node = acpi_ns_map_handle_to_node(device);
+       node = acpi_ns_validate_handle(device);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
@@ -425,7 +425,7 @@ acpi_remove_notify_handler(acpi_handle device,
 
        /* Convert and validate the device handle */
 
-       node = acpi_ns_map_handle_to_node(device);
+       node = acpi_ns_validate_handle(device);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
index 4721f58fe42c0653d6a6c14aee384ffbab2e708a..eed7a38d25f2cfdb2be2c5c712da9f8b4d6df5f8 100644 (file)
@@ -610,7 +610,7 @@ acpi_install_gpe_block(acpi_handle gpe_device,
                return (status);
        }
 
-       node = acpi_ns_map_handle_to_node(gpe_device);
+       node = acpi_ns_validate_handle(gpe_device);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
@@ -698,7 +698,7 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
                return (status);
        }
 
-       node = acpi_ns_map_handle_to_node(gpe_device);
+       node = acpi_ns_validate_handle(gpe_device);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
index 7c3d2d356ffba4877227cc2c340b7d3d1d62dc9c..c98aa7c2d67c6bbc492e9c842ce8270814e8b0a8 100644 (file)
@@ -89,7 +89,7 @@ acpi_install_address_space_handler(acpi_handle device,
 
        /* Convert and validate the device handle */
 
-       node = acpi_ns_map_handle_to_node(device);
+       node = acpi_ns_validate_handle(device);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
@@ -155,7 +155,7 @@ acpi_remove_address_space_handler(acpi_handle device,
 
        /* Convert and validate the device handle */
 
-       node = acpi_ns_map_handle_to_node(device);
+       node = acpi_ns_validate_handle(device);
        if (!node ||
            ((node->type != ACPI_TYPE_DEVICE) &&
             (node->type != ACPI_TYPE_PROCESSOR) &&
index 2f0114202b05dc8a86e77b31075d3e930e96718f..3c456bd575d0398224fe1ce600da19a000156c48 100644 (file)
@@ -375,6 +375,15 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
                return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
        }
 
+       /* Must have a valid thread ID */
+
+       if (!walk_state->thread) {
+               ACPI_ERROR((AE_INFO,
+                           "Cannot release Mutex [%4.4s], null thread info",
+                           acpi_ut_get_node_name(obj_desc->mutex.node)));
+               return_ACPI_STATUS(AE_AML_INTERNAL);
+       }
+
        /*
         * The Mutex is owned, but this thread must be the owner.
         * Special case for Global Lock, any thread can release
@@ -392,15 +401,6 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
                return_ACPI_STATUS(AE_AML_NOT_OWNER);
        }
 
-       /* Must have a valid thread ID */
-
-       if (!walk_state->thread) {
-               ACPI_ERROR((AE_INFO,
-                           "Cannot release Mutex [%4.4s], null thread info",
-                           acpi_ut_get_node_name(obj_desc->mutex.node)));
-               return_ACPI_STATUS(AE_AML_INTERNAL);
-       }
-
        /*
         * The sync level of the mutex must be equal to the current sync level. In
         * other words, the current level means that at least one mutex at that
index 9c3cdbe2d82a96e8b5ed8502432d057afa3e5856..d622ba770000f0e22e836c5d49f2edd6d96bd6b4 100644 (file)
@@ -165,7 +165,7 @@ acpi_status acpi_ns_root_initialize(void)
 
                                obj_desc->method.method_flags =
                                    AML_METHOD_INTERNAL_ONLY;
-                               obj_desc->method.implementation =
+                               obj_desc->method.extra.implementation =
                                    acpi_ut_osi_implementation;
 #endif
                                break;
index 2deb986861ca2d9ca9d376f92d737954200f5968..e37836e27e29eb3a2816696fbfb7c5da43b04999 100644 (file)
@@ -180,7 +180,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
                return (AE_OK);
        }
 
-       this_node = acpi_ns_map_handle_to_node(obj_handle);
+       this_node = acpi_ns_validate_handle(obj_handle);
        if (!this_node) {
                ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n",
                                  obj_handle));
index f771e978c40396cc405e5484e29344dd5176d9f8..af9fe91037340ff1e404ffdc521881da8e65bf58 100644 (file)
@@ -381,6 +381,18 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
                                    method_obj->method.next_object);
        type = acpi_ns_get_type(parent_node);
 
+       /*
+        * Get the region handler and save it in the method object. We may need
+        * this if an operation region declaration causes a _REG method to be run.
+        *
+        * We can't do this in acpi_ps_link_module_code because
+        * acpi_gbl_root_node->Object is NULL at PASS1.
+        */
+       if ((type == ACPI_TYPE_DEVICE) && parent_node->object) {
+               method_obj->method.extra.handler =
+                   parent_node->object->device.handler;
+       }
+
        /* Must clear next_object (acpi_ns_attach_object needs the field) */
 
        method_obj->method.next_object = NULL;
@@ -415,6 +427,12 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
        ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Executed module-level code at %p\n",
                          method_obj->method.aml_start));
 
+       /* Delete a possible implicit return value (in slack mode) */
+
+       if (info->return_object) {
+               acpi_ut_remove_reference(info->return_object);
+       }
+
        /* Detach the temporary method object */
 
        acpi_ns_detach_object(parent_node);
index af8e6bcee07e5544112299df765c540a7b4c0602..8f9a4875ce26708ae06b17a5f637b43a52964537 100644 (file)
@@ -232,7 +232,7 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle,
 
        ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle);
 
-       node = acpi_ns_map_handle_to_node(target_handle);
+       node = acpi_ns_validate_handle(target_handle);
        if (!node) {
                return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
index b05f42903c869e4378b515be629b37b091f11ce5..d34fa59548f737cd38f1ebc3a242f3563fe3919d 100644 (file)
@@ -216,29 +216,38 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
        data->pathname = pathname;
 
        /*
-        * Check that the type of the return object is what is expected for
-        * this predefined name
+        * Check that the type of the main return object is what is expected
+        * for this predefined name
         */
        status = acpi_ns_check_object_type(data, return_object_ptr,
                                           predefined->info.expected_btypes,
                                           ACPI_NOT_PACKAGE_ELEMENT);
        if (ACPI_FAILURE(status)) {
-               goto check_validation_status;
+               goto exit;
        }
 
-       /* For returned Package objects, check the type of all sub-objects */
-
-       if (return_object->common.type == ACPI_TYPE_PACKAGE) {
+       /*
+        * For returned Package objects, check the type of all sub-objects.
+        * Note: Package may have been newly created by call above.
+        */
+       if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) {
                status = acpi_ns_check_package(data, return_object_ptr);
+               if (ACPI_FAILURE(status)) {
+                       goto exit;
+               }
        }
 
        /*
-        * Perform additional, more complicated repairs on a per-name
-        * basis.
+        * The return object was OK, or it was successfully repaired above.
+        * Now make some additional checks such as verifying that package
+        * objects are sorted correctly (if required) or buffer objects have
+        * the correct data width (bytes vs. dwords). These repairs are
+        * performed on a per-name basis, i.e., the code is specific to
+        * particular predefined names.
         */
        status = acpi_ns_complex_repairs(data, node, status, return_object_ptr);
 
-check_validation_status:
+exit:
        /*
         * If the object validation failed or if we successfully repaired one
         * or more objects, mark the parent node to suppress further warning
@@ -427,6 +436,13 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
                          data->pathname, package->ret_info.type,
                          return_object->package.count));
 
+       /*
+        * For variable-length Packages, we can safely remove all embedded
+        * and trailing NULL package elements
+        */
+       acpi_ns_remove_null_elements(data, package->ret_info.type,
+                                    return_object);
+
        /* Extract package count and elements array */
 
        elements = return_object->package.elements;
@@ -461,11 +477,11 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
                if (count < expected_count) {
                        goto package_too_small;
                } else if (count > expected_count) {
-                       ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
-                                             data->node_flags,
-                                             "Return Package is larger than needed - "
-                                             "found %u, expected %u", count,
-                                             expected_count));
+                       ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
+                                         "%s: Return Package is larger than needed - "
+                                         "found %u, expected %u\n",
+                                         data->pathname, count,
+                                         expected_count));
                }
 
                /* Validate all elements of the returned package */
@@ -680,53 +696,18 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
        union acpi_operand_object *sub_package;
        union acpi_operand_object **sub_elements;
        acpi_status status;
-       u8 non_trailing_null = FALSE;
        u32 expected_count;
        u32 i;
        u32 j;
 
-       /* Validate each sub-Package in the parent Package */
-
+       /*
+        * Validate each sub-Package in the parent Package
+        *
+        * NOTE: assumes list of sub-packages contains no NULL elements.
+        * Any NULL elements should have been removed by earlier call
+        * to acpi_ns_remove_null_elements.
+        */
        for (i = 0; i < count; i++) {
-               /*
-                * Handling for NULL package elements. For now, we will simply allow
-                * a parent package with trailing NULL elements. This can happen if
-                * the package was defined to be longer than the initializer list.
-                * This is legal as per the ACPI specification. It is often used
-                * to allow for dynamic initialization of a Package.
-                *
-                * A future enhancement may be to simply truncate the package to
-                * remove the trailing NULL elements.
-                */
-               if (!(*elements)) {
-                       if (!non_trailing_null) {
-
-                               /* Ensure the remaining elements are all NULL */
-
-                               for (j = 1; j < (count - i + 1); j++) {
-                                       if (elements[j]) {
-                                               non_trailing_null = TRUE;
-                                       }
-                               }
-
-                               if (!non_trailing_null) {
-
-                                       /* Ignore the trailing NULL elements */
-
-                                       return (AE_OK);
-                               }
-                       }
-
-                       /* There are trailing non-null elements, issue warning */
-
-                       ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
-                                             data->node_flags,
-                                             "Found NULL element at package index %u",
-                                             i));
-                       elements++;
-                       continue;
-               }
-
                sub_package = *elements;
                sub_elements = sub_package->package.elements;
 
index d563f1a564a79ba4090e012158cda79c410b88a5..4fd1bdb056b2ffa496514b0a422c82aef36c35c7 100644 (file)
 #include "accommon.h"
 #include "acnamesp.h"
 #include "acinterp.h"
-#include "acpredef.h"
 
 #define _COMPONENT          ACPI_NAMESPACE
 ACPI_MODULE_NAME("nsrepair")
 
+/*******************************************************************************
+ *
+ * This module attempts to repair or convert objects returned by the
+ * predefined methods to an object type that is expected, as per the ACPI
+ * specification. The need for this code is dictated by the many machines that
+ * return incorrect types for the standard predefined methods. Performing these
+ * conversions here, in one place, eliminates the need for individual ACPI
+ * device drivers to do the same. Note: Most of these conversions are different
+ * than the internal object conversion routines used for implicit object
+ * conversion.
+ *
+ * The following conversions can be performed as necessary:
+ *
+ * Integer -> String
+ * Integer -> Buffer
+ * String  -> Integer
+ * String  -> Buffer
+ * Buffer  -> Integer
+ * Buffer  -> String
+ * Buffer  -> Package of Integers
+ * Package -> Package of one Package
+ *
+ ******************************************************************************/
+/* Local prototypes */
+static acpi_status
+acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
+                          union acpi_operand_object **return_object);
+
+static acpi_status
+acpi_ns_convert_to_string(union acpi_operand_object *original_object,
+                         union acpi_operand_object **return_object);
+
+static acpi_status
+acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
+                         union acpi_operand_object **return_object);
+
+static acpi_status
+acpi_ns_convert_to_package(union acpi_operand_object *original_object,
+                          union acpi_operand_object **return_object);
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ns_repair_object
@@ -68,6 +107,7 @@ ACPI_MODULE_NAME("nsrepair")
  *              not expected.
  *
  ******************************************************************************/
+
 acpi_status
 acpi_ns_repair_object(struct acpi_predefined_data *data,
                      u32 expected_btypes,
@@ -76,32 +116,206 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
 {
        union acpi_operand_object *return_object = *return_object_ptr;
        union acpi_operand_object *new_object;
-       acpi_size length;
        acpi_status status;
 
+       ACPI_FUNCTION_NAME(ns_repair_object);
+
        /*
         * At this point, we know that the type of the returned object was not
         * one of the expected types for this predefined name. Attempt to
-        * repair the object. Only a limited number of repairs are possible.
+        * repair the object by converting it to one of the expected object
+        * types for this predefined name.
         */
-       switch (return_object->common.type) {
+       if (expected_btypes & ACPI_RTYPE_INTEGER) {
+               status = acpi_ns_convert_to_integer(return_object, &new_object);
+               if (ACPI_SUCCESS(status)) {
+                       goto object_repaired;
+               }
+       }
+       if (expected_btypes & ACPI_RTYPE_STRING) {
+               status = acpi_ns_convert_to_string(return_object, &new_object);
+               if (ACPI_SUCCESS(status)) {
+                       goto object_repaired;
+               }
+       }
+       if (expected_btypes & ACPI_RTYPE_BUFFER) {
+               status = acpi_ns_convert_to_buffer(return_object, &new_object);
+               if (ACPI_SUCCESS(status)) {
+                       goto object_repaired;
+               }
+       }
+       if (expected_btypes & ACPI_RTYPE_PACKAGE) {
+               status = acpi_ns_convert_to_package(return_object, &new_object);
+               if (ACPI_SUCCESS(status)) {
+                       goto object_repaired;
+               }
+       }
+
+       /* We cannot repair this object */
+
+       return (AE_AML_OPERAND_TYPE);
+
+      object_repaired:
+
+       /* Object was successfully repaired */
+
+       /*
+        * If the original object is a package element, we need to:
+        * 1. Set the reference count of the new object to match the
+        *    reference count of the old object.
+        * 2. Decrement the reference count of the original object.
+        */
+       if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
+               new_object->common.reference_count =
+                   return_object->common.reference_count;
+
+               if (return_object->common.reference_count > 1) {
+                       return_object->common.reference_count--;
+               }
+
+               ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
+                                 "%s: Converted %s to expected %s at index %u\n",
+                                 data->pathname,
+                                 acpi_ut_get_object_type_name(return_object),
+                                 acpi_ut_get_object_type_name(new_object),
+                                 package_index));
+       } else {
+               ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
+                                 "%s: Converted %s to expected %s\n",
+                                 data->pathname,
+                                 acpi_ut_get_object_type_name(return_object),
+                                 acpi_ut_get_object_type_name(new_object)));
+       }
+
+       /* Delete old object, install the new return object */
+
+       acpi_ut_remove_reference(return_object);
+       *return_object_ptr = new_object;
+       data->flags |= ACPI_OBJECT_REPAIRED;
+       return (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_convert_to_integer
+ *
+ * PARAMETERS:  original_object     - Object to be converted
+ *              return_object       - Where the new converted object is returned
+ *
+ * RETURN:      Status. AE_OK if conversion was successful.
+ *
+ * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
+                          union acpi_operand_object **return_object)
+{
+       union acpi_operand_object *new_object;
+       acpi_status status;
+       u64 value = 0;
+       u32 i;
+
+       switch (original_object->common.type) {
+       case ACPI_TYPE_STRING:
+
+               /* String-to-Integer conversion */
+
+               status = acpi_ut_strtoul64(original_object->string.pointer,
+                                          ACPI_ANY_BASE, &value);
+               if (ACPI_FAILURE(status)) {
+                       return (status);
+               }
+               break;
+
        case ACPI_TYPE_BUFFER:
 
-               /* Does the method/object legally return a string? */
+               /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
 
-               if (!(expected_btypes & ACPI_RTYPE_STRING)) {
+               if (original_object->buffer.length > 8) {
                        return (AE_AML_OPERAND_TYPE);
                }
 
+               /* Extract each buffer byte to create the integer */
+
+               for (i = 0; i < original_object->buffer.length; i++) {
+                       value |=
+                           ((u64) original_object->buffer.
+                            pointer[i] << (i * 8));
+               }
+               break;
+
+       default:
+               return (AE_AML_OPERAND_TYPE);
+       }
+
+       new_object = acpi_ut_create_integer_object(value);
+       if (!new_object) {
+               return (AE_NO_MEMORY);
+       }
+
+       *return_object = new_object;
+       return (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_convert_to_string
+ *
+ * PARAMETERS:  original_object     - Object to be converted
+ *              return_object       - Where the new converted object is returned
+ *
+ * RETURN:      Status. AE_OK if conversion was successful.
+ *
+ * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ns_convert_to_string(union acpi_operand_object *original_object,
+                         union acpi_operand_object **return_object)
+{
+       union acpi_operand_object *new_object;
+       acpi_size length;
+       acpi_status status;
+
+       switch (original_object->common.type) {
+       case ACPI_TYPE_INTEGER:
+               /*
+                * Integer-to-String conversion. Commonly, convert
+                * an integer of value 0 to a NULL string. The last element of
+                * _BIF and _BIX packages occasionally need this fix.
+                */
+               if (original_object->integer.value == 0) {
+
+                       /* Allocate a new NULL string object */
+
+                       new_object = acpi_ut_create_string_object(0);
+                       if (!new_object) {
+                               return (AE_NO_MEMORY);
+                       }
+               } else {
+                       status =
+                           acpi_ex_convert_to_string(original_object,
+                                                     &new_object,
+                                                     ACPI_IMPLICIT_CONVERT_HEX);
+                       if (ACPI_FAILURE(status)) {
+                               return (status);
+                       }
+               }
+               break;
+
+       case ACPI_TYPE_BUFFER:
                /*
-                * Have a Buffer, expected a String, convert. Use a to_string
+                * Buffer-to-String conversion. Use a to_string
                 * conversion, no transform performed on the buffer data. The best
                 * example of this is the _BIF method, where the string data from
                 * the battery is often (incorrectly) returned as buffer object(s).
                 */
                length = 0;
-               while ((length < return_object->buffer.length) &&
-                      (return_object->buffer.pointer[length])) {
+               while ((length < original_object->buffer.length) &&
+                      (original_object->buffer.pointer[length])) {
                        length++;
                }
 
@@ -117,94 +331,176 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
                 * terminated at Length+1.
                 */
                ACPI_MEMCPY(new_object->string.pointer,
-                           return_object->buffer.pointer, length);
+                           original_object->buffer.pointer, length);
                break;
 
+       default:
+               return (AE_AML_OPERAND_TYPE);
+       }
+
+       *return_object = new_object;
+       return (AE_OK);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_convert_to_buffer
+ *
+ * PARAMETERS:  original_object     - Object to be converted
+ *              return_object       - Where the new converted object is returned
+ *
+ * RETURN:      Status. AE_OK if conversion was successful.
+ *
+ * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
+                         union acpi_operand_object **return_object)
+{
+       union acpi_operand_object *new_object;
+       acpi_status status;
+       union acpi_operand_object **elements;
+       u32 *dword_buffer;
+       u32 count;
+       u32 i;
+
+       switch (original_object->common.type) {
        case ACPI_TYPE_INTEGER:
+               /*
+                * Integer-to-Buffer conversion.
+                * Convert the Integer to a packed-byte buffer. _MAT and other
+                * objects need this sometimes, if a read has been performed on a
+                * Field object that is less than or equal to the global integer
+                * size (32 or 64 bits).
+                */
+               status =
+                   acpi_ex_convert_to_buffer(original_object, &new_object);
+               if (ACPI_FAILURE(status)) {
+                       return (status);
+               }
+               break;
 
-               /* 1) Does the method/object legally return a buffer? */
+       case ACPI_TYPE_STRING:
 
-               if (expected_btypes & ACPI_RTYPE_BUFFER) {
-                       /*
-                        * Convert the Integer to a packed-byte buffer. _MAT needs
-                        * this sometimes, if a read has been performed on a Field
-                        * object that is less than or equal to the global integer
-                        * size (32 or 64 bits).
-                        */
-                       status =
-                           acpi_ex_convert_to_buffer(return_object,
-                                                     &new_object);
-                       if (ACPI_FAILURE(status)) {
-                               return (status);
-                       }
+               /* String-to-Buffer conversion. Simple data copy */
+
+               new_object =
+                   acpi_ut_create_buffer_object(original_object->string.
+                                                length);
+               if (!new_object) {
+                       return (AE_NO_MEMORY);
                }
 
-               /* 2) Does the method/object legally return a string? */
+               ACPI_MEMCPY(new_object->buffer.pointer,
+                           original_object->string.pointer,
+                           original_object->string.length);
+               break;
+
+       case ACPI_TYPE_PACKAGE:
+               /*
+                * This case is often seen for predefined names that must return a
+                * Buffer object with multiple DWORD integers within. For example,
+                * _FDE and _GTM. The Package can be converted to a Buffer.
+                */
+
+               /* All elements of the Package must be integers */
 
-               else if (expected_btypes & ACPI_RTYPE_STRING) {
-                       /*
-                        * The only supported Integer-to-String conversion is to convert
-                        * an integer of value 0 to a NULL string. The last element of
-                        * _BIF and _BIX packages occasionally need this fix.
-                        */
-                       if (return_object->integer.value != 0) {
+               elements = original_object->package.elements;
+               count = original_object->package.count;
+
+               for (i = 0; i < count; i++) {
+                       if ((!*elements) ||
+                           ((*elements)->common.type != ACPI_TYPE_INTEGER)) {
                                return (AE_AML_OPERAND_TYPE);
                        }
+                       elements++;
+               }
 
-                       /* Allocate a new NULL string object */
+               /* Create the new buffer object to replace the Package */
 
-                       new_object = acpi_ut_create_string_object(0);
-                       if (!new_object) {
-                               return (AE_NO_MEMORY);
-                       }
-               } else {
-                       return (AE_AML_OPERAND_TYPE);
+               new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count));
+               if (!new_object) {
+                       return (AE_NO_MEMORY);
                }
-               break;
 
-       default:
+               /* Copy the package elements (integers) to the buffer as DWORDs */
 
-               /* We cannot repair this object */
+               elements = original_object->package.elements;
+               dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer);
+
+               for (i = 0; i < count; i++) {
+                       *dword_buffer = (u32) (*elements)->integer.value;
+                       dword_buffer++;
+                       elements++;
+               }
+               break;
 
+       default:
                return (AE_AML_OPERAND_TYPE);
        }
 
-       /* Object was successfully repaired */
+       *return_object = new_object;
+       return (AE_OK);
+}
 
-       /*
-        * If the original object is a package element, we need to:
-        * 1. Set the reference count of the new object to match the
-        *    reference count of the old object.
-        * 2. Decrement the reference count of the original object.
-        */
-       if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
-               new_object->common.reference_count =
-                   return_object->common.reference_count;
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_convert_to_package
+ *
+ * PARAMETERS:  original_object     - Object to be converted
+ *              return_object       - Where the new converted object is returned
+ *
+ * RETURN:      Status. AE_OK if conversion was successful.
+ *
+ * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of
+ *              the buffer is converted to a single integer package element.
+ *
+ ******************************************************************************/
 
-               if (return_object->common.reference_count > 1) {
-                       return_object->common.reference_count--;
+static acpi_status
+acpi_ns_convert_to_package(union acpi_operand_object *original_object,
+                          union acpi_operand_object **return_object)
+{
+       union acpi_operand_object *new_object;
+       union acpi_operand_object **elements;
+       u32 length;
+       u8 *buffer;
+
+       switch (original_object->common.type) {
+       case ACPI_TYPE_BUFFER:
+
+               /* Buffer-to-Package conversion */
+
+               length = original_object->buffer.length;
+               new_object = acpi_ut_create_package_object(length);
+               if (!new_object) {
+                       return (AE_NO_MEMORY);
                }
 
-               ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
-                                     "Converted %s to expected %s at index %u",
-                                     acpi_ut_get_object_type_name
-                                     (return_object),
-                                     acpi_ut_get_object_type_name(new_object),
-                                     package_index));
-       } else {
-               ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
-                                     "Converted %s to expected %s",
-                                     acpi_ut_get_object_type_name
-                                     (return_object),
-                                     acpi_ut_get_object_type_name
-                                     (new_object)));
-       }
+               /* Convert each buffer byte to an integer package element */
 
-       /* Delete old object, install the new return object */
+               elements = new_object->package.elements;
+               buffer = original_object->buffer.pointer;
 
-       acpi_ut_remove_reference(return_object);
-       *return_object_ptr = new_object;
-       data->flags |= ACPI_OBJECT_REPAIRED;
+               while (length--) {
+                       *elements =
+                           acpi_ut_create_integer_object((u64) *buffer);
+                       if (!*elements) {
+                               acpi_ut_remove_reference(new_object);
+                               return (AE_NO_MEMORY);
+                       }
+                       elements++;
+                       buffer++;
+               }
+               break;
+
+       default:
+               return (AE_AML_OPERAND_TYPE);
+       }
+
+       *return_object = new_object;
        return (AE_OK);
 }
 
@@ -238,6 +534,8 @@ acpi_ns_repair_package_list(struct acpi_predefined_data *data,
 {
        union acpi_operand_object *pkg_obj_desc;
 
+       ACPI_FUNCTION_NAME(ns_repair_package_list);
+
        /*
         * Create the new outer package and populate it. The new package will
         * have a single element, the lone subpackage.
@@ -254,8 +552,9 @@ acpi_ns_repair_package_list(struct acpi_predefined_data *data,
        *obj_desc_ptr = pkg_obj_desc;
        data->flags |= ACPI_OBJECT_REPAIRED;
 
-       ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
-                             "Repaired Incorrectly formed Package"));
+       ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
+                         "%s: Repaired incorrectly formed Package\n",
+                         data->pathname));
 
        return (AE_OK);
 }
index d07b686138181ad9693dd72d9773bfc07480bbf9..f13691c1cca54996097e3ada48b792acf70708ce 100644 (file)
@@ -45,6 +45,7 @@
 #include <acpi/acpi.h>
 #include "accommon.h"
 #include "acnamesp.h"
+#include "acpredef.h"
 
 #define _COMPONENT          ACPI_NAMESPACE
 ACPI_MODULE_NAME("nsrepair2")
@@ -73,6 +74,10 @@ static acpi_status
 acpi_ns_repair_ALR(struct acpi_predefined_data *data,
                   union acpi_operand_object **return_object_ptr);
 
+static acpi_status
+acpi_ns_repair_FDE(struct acpi_predefined_data *data,
+                  union acpi_operand_object **return_object_ptr);
+
 static acpi_status
 acpi_ns_repair_PSS(struct acpi_predefined_data *data,
                   union acpi_operand_object **return_object_ptr);
@@ -88,9 +93,6 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
                          u32 sort_index,
                          u8 sort_direction, char *sort_key_name);
 
-static acpi_status
-acpi_ns_remove_null_elements(union acpi_operand_object *package);
-
 static acpi_status
 acpi_ns_sort_list(union acpi_operand_object **elements,
                  u32 count, u32 index, u8 sort_direction);
@@ -104,17 +106,27 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
  * This table contains the names of the predefined methods for which we can
  * perform more complex repairs.
  *
- * _ALR: Sort the list ascending by ambient_illuminance if necessary
- * _PSS: Sort the list descending by Power if necessary
- * _TSS: Sort the list descending by Power if necessary
+ * As necessary:
+ *
+ * _ALR: Sort the list ascending by ambient_illuminance
+ * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs
+ * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
+ * _PSS: Sort the list descending by Power
+ * _TSS: Sort the list descending by Power
  */
 static const struct acpi_repair_info acpi_ns_repairable_names[] = {
        {"_ALR", acpi_ns_repair_ALR},
+       {"_FDE", acpi_ns_repair_FDE},
+       {"_GTM", acpi_ns_repair_FDE},   /* _GTM has same repair as _FDE */
        {"_PSS", acpi_ns_repair_PSS},
        {"_TSS", acpi_ns_repair_TSS},
        {{0, 0, 0, 0}, NULL}    /* Table terminator */
 };
 
+#define ACPI_FDE_FIELD_COUNT        5
+#define ACPI_FDE_BYTE_BUFFER_SIZE   5
+#define ACPI_FDE_DWORD_BUFFER_SIZE  (ACPI_FDE_FIELD_COUNT * sizeof (u32))
+
 /******************************************************************************
  *
  * FUNCTION:    acpi_ns_complex_repairs
@@ -213,6 +225,94 @@ acpi_ns_repair_ALR(struct acpi_predefined_data *data,
        return (status);
 }
 
+/******************************************************************************
+ *
+ * FUNCTION:    acpi_ns_repair_FDE
+ *
+ * PARAMETERS:  Data                - Pointer to validation data structure
+ *              return_object_ptr   - Pointer to the object returned from the
+ *                                    evaluation of a method or object
+ *
+ * RETURN:      Status. AE_OK if object is OK or was repaired successfully
+ *
+ * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return
+ *              value is a Buffer of 5 DWORDs. This function repairs a common
+ *              problem where the return value is a Buffer of BYTEs, not
+ *              DWORDs.
+ *
+ *****************************************************************************/
+
+static acpi_status
+acpi_ns_repair_FDE(struct acpi_predefined_data *data,
+                  union acpi_operand_object **return_object_ptr)
+{
+       union acpi_operand_object *return_object = *return_object_ptr;
+       union acpi_operand_object *buffer_object;
+       u8 *byte_buffer;
+       u32 *dword_buffer;
+       u32 i;
+
+       ACPI_FUNCTION_NAME(ns_repair_FDE);
+
+       switch (return_object->common.type) {
+       case ACPI_TYPE_BUFFER:
+
+               /* This is the expected type. Length should be (at least) 5 DWORDs */
+
+               if (return_object->buffer.length >= ACPI_FDE_DWORD_BUFFER_SIZE) {
+                       return (AE_OK);
+               }
+
+               /* We can only repair if we have exactly 5 BYTEs */
+
+               if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) {
+                       ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
+                                             data->node_flags,
+                                             "Incorrect return buffer length %u, expected %u",
+                                             return_object->buffer.length,
+                                             ACPI_FDE_DWORD_BUFFER_SIZE));
+
+                       return (AE_AML_OPERAND_TYPE);
+               }
+
+               /* Create the new (larger) buffer object */
+
+               buffer_object =
+                   acpi_ut_create_buffer_object(ACPI_FDE_DWORD_BUFFER_SIZE);
+               if (!buffer_object) {
+                       return (AE_NO_MEMORY);
+               }
+
+               /* Expand each byte to a DWORD */
+
+               byte_buffer = return_object->buffer.pointer;
+               dword_buffer =
+                   ACPI_CAST_PTR(u32, buffer_object->buffer.pointer);
+
+               for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) {
+                       *dword_buffer = (u32) *byte_buffer;
+                       dword_buffer++;
+                       byte_buffer++;
+               }
+
+               ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
+                                 "%s Expanded Byte Buffer to expected DWord Buffer\n",
+                                 data->pathname));
+               break;
+
+       default:
+               return (AE_AML_OPERAND_TYPE);
+       }
+
+       /* Delete the original return object, return the new buffer object */
+
+       acpi_ut_remove_reference(return_object);
+       *return_object_ptr = buffer_object;
+
+       data->flags |= ACPI_OBJECT_REPAIRED;
+       return (AE_OK);
+}
+
 /******************************************************************************
  *
  * FUNCTION:    acpi_ns_repair_TSS
@@ -345,6 +445,8 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
        u32 previous_value;
        acpi_status status;
 
+       ACPI_FUNCTION_NAME(ns_check_sorted_list);
+
        /* The top-level object must be a package */
 
        if (return_object->common.type != ACPI_TYPE_PACKAGE) {
@@ -352,24 +454,10 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
        }
 
        /*
-        * Detect any NULL package elements and remove them from the
-        * package.
-        *
-        * TBD: We may want to do this for all predefined names that
-        * return a variable-length package of packages.
+        * NOTE: assumes list of sub-packages contains no NULL elements.
+        * Any NULL elements should have been removed by earlier call
+        * to acpi_ns_remove_null_elements.
         */
-       status = acpi_ns_remove_null_elements(return_object);
-       if (status == AE_NULL_ENTRY) {
-               ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
-                                     "NULL elements removed from package"));
-
-               /* Exit if package is now zero length */
-
-               if (!return_object->package.count) {
-                       return (AE_NULL_ENTRY);
-               }
-       }
-
        outer_elements = return_object->package.elements;
        outer_element_count = return_object->package.count;
        if (!outer_element_count) {
@@ -422,10 +510,9 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
 
                        data->flags |= ACPI_OBJECT_REPAIRED;
 
-                       ACPI_INFO_PREDEFINED((AE_INFO, data->pathname,
-                                             data->node_flags,
-                                             "Repaired unsorted list - now sorted by %s",
-                                             sort_key_name));
+                       ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
+                                         "%s: Repaired unsorted list - now sorted by %s\n",
+                                         data->pathname, sort_key_name));
                        return (AE_OK);
                }
 
@@ -440,36 +527,63 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
  *
  * FUNCTION:    acpi_ns_remove_null_elements
  *
- * PARAMETERS:  obj_desc            - A Package object
+ * PARAMETERS:  Data                - Pointer to validation data structure
+ *              package_type        - An acpi_return_package_types value
+ *              obj_desc            - A Package object
  *
- * RETURN:      Status. AE_NULL_ENTRY means that one or more elements were
- *              removed.
+ * RETURN:      None.
  *
- * DESCRIPTION: Remove all NULL package elements and update the package count.
+ * DESCRIPTION: Remove all NULL package elements from packages that contain
+ *              a variable number of sub-packages.
  *
  *****************************************************************************/
 
-static acpi_status
-acpi_ns_remove_null_elements(union acpi_operand_object *obj_desc)
+void
+acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
+                            u8 package_type,
+                            union acpi_operand_object *obj_desc)
 {
        union acpi_operand_object **source;
        union acpi_operand_object **dest;
-       acpi_status status = AE_OK;
        u32 count;
        u32 new_count;
        u32 i;
 
+       ACPI_FUNCTION_NAME(ns_remove_null_elements);
+
+       /*
+        * PTYPE1 packages contain no subpackages.
+        * PTYPE2 packages contain a variable number of sub-packages. We can
+        * safely remove all NULL elements from the PTYPE2 packages.
+        */
+       switch (package_type) {
+       case ACPI_PTYPE1_FIXED:
+       case ACPI_PTYPE1_VAR:
+       case ACPI_PTYPE1_OPTION:
+               return;
+
+       case ACPI_PTYPE2:
+       case ACPI_PTYPE2_COUNT:
+       case ACPI_PTYPE2_PKG_COUNT:
+       case ACPI_PTYPE2_FIXED:
+       case ACPI_PTYPE2_MIN:
+       case ACPI_PTYPE2_REV_FIXED:
+               break;
+
+       default:
+               return;
+       }
+
        count = obj_desc->package.count;
        new_count = count;
 
        source = obj_desc->package.elements;
        dest = source;
 
-       /* Examine all elements of the package object */
+       /* Examine all elements of the package object, remove nulls */
 
        for (i = 0; i < count; i++) {
                if (!*source) {
-                       status = AE_NULL_ENTRY;
                        new_count--;
                } else {
                        *dest = *source;
@@ -478,15 +592,18 @@ acpi_ns_remove_null_elements(union acpi_operand_object *obj_desc)
                source++;
        }
 
-       if (status == AE_NULL_ENTRY) {
+       /* Update parent package if any null elements were removed */
+
+       if (new_count < count) {
+               ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
+                                 "%s: Found and removed %u NULL elements\n",
+                                 data->pathname, (count - new_count)));
 
                /* NULL terminate list and update the package count */
 
                *dest = NULL;
                obj_desc->package.count = new_count;
        }
-
-       return (status);
 }
 
 /******************************************************************************
index ea55ab4f984924937feca72f00cb056d02bc1993..47d91e668a1bfc25436a0993b3e04b3397aed490 100644 (file)
@@ -671,24 +671,25 @@ acpi_ns_externalize_name(u32 internal_name_length,
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_ns_map_handle_to_node
+ * FUNCTION:    acpi_ns_validate_handle
  *
- * PARAMETERS:  Handle          - Handle to be converted to an Node
+ * PARAMETERS:  Handle          - Handle to be validated and typecast to a
+ *                                namespace node.
  *
- * RETURN:      A Name table entry pointer
+ * RETURN:      A pointer to a namespace node
  *
- * DESCRIPTION: Convert a namespace handle to a real Node
+ * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
+ *              cases for the root node.
  *
- * Note: Real integer handles would allow for more verification
+ * NOTE: Real integer handles would allow for more verification
  *       and keep all pointers within this subsystem - however this introduces
- *       more (and perhaps unnecessary) overhead.
- *
- * The current implemenation is basically a placeholder until such time comes
- * that it is needed.
+ *       more overhead and has not been necessary to this point. Drivers
+ *       holding handles are typically notified before a node becomes invalid
+ *       due to a table unload.
  *
  ******************************************************************************/
 
-struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
+struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle)
 {
 
        ACPI_FUNCTION_ENTRY();
@@ -708,42 +709,6 @@ struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
        return (ACPI_CAST_PTR(struct acpi_namespace_node, handle));
 }
 
-/*******************************************************************************
- *
- * FUNCTION:    acpi_ns_convert_entry_to_handle
- *
- * PARAMETERS:  Node          - Node to be converted to a Handle
- *
- * RETURN:      A user handle
- *
- * DESCRIPTION: Convert a real Node to a namespace handle
- *
- ******************************************************************************/
-
-acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node)
-{
-
-       /*
-        * Simple implementation for now;
-        */
-       return ((acpi_handle) node);
-
-/* Example future implementation ---------------------
-
-       if (!Node)
-       {
-               return (NULL);
-       }
-
-       if (Node == acpi_gbl_root_node)
-       {
-               return (ACPI_ROOT_OBJECT);
-       }
-
-       return ((acpi_handle) Node);
-------------------------------------------------------*/
-}
-
 /*******************************************************************************
  *
  * FUNCTION:    acpi_ns_terminate
index f2bd1da770018dbab1da0b872d9b138abcdab268..f0c0892bc7e5c6babc8d46955d46d1d93f24bd82 100644 (file)
@@ -190,7 +190,7 @@ acpi_evaluate_object(acpi_handle handle,
 
        /* Convert and validate the device handle */
 
-       info->prefix_node = acpi_ns_map_handle_to_node(handle);
+       info->prefix_node = acpi_ns_validate_handle(handle);
        if (!info->prefix_node) {
                status = AE_BAD_PARAMETER;
                goto cleanup;
@@ -552,7 +552,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
                return (status);
        }
 
-       node = acpi_ns_map_handle_to_node(obj_handle);
+       node = acpi_ns_validate_handle(obj_handle);
        status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
        if (ACPI_FAILURE(status)) {
                return (status);
@@ -729,7 +729,7 @@ acpi_attach_data(acpi_handle obj_handle,
 
        /* Convert and validate the handle */
 
-       node = acpi_ns_map_handle_to_node(obj_handle);
+       node = acpi_ns_validate_handle(obj_handle);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
@@ -775,7 +775,7 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
 
        /* Convert and validate the handle */
 
-       node = acpi_ns_map_handle_to_node(obj_handle);
+       node = acpi_ns_validate_handle(obj_handle);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
@@ -822,7 +822,7 @@ acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
 
        /* Convert and validate the handle */
 
-       node = acpi_ns_map_handle_to_node(obj_handle);
+       node = acpi_ns_validate_handle(obj_handle);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
index ddc84af6336e727d5eaa1ec4799e4c38e49a9333..e611dd961b200ba6f8afd6cebe23b282efe503f7 100644 (file)
@@ -93,7 +93,7 @@ acpi_get_handle(acpi_handle parent,
        /* Convert a parent handle to a prefix node */
 
        if (parent) {
-               prefix_node = acpi_ns_map_handle_to_node(parent);
+               prefix_node = acpi_ns_validate_handle(parent);
                if (!prefix_node) {
                        return (AE_BAD_PARAMETER);
                }
@@ -114,7 +114,7 @@ acpi_get_handle(acpi_handle parent,
 
                if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) {
                        *ret_handle =
-                           acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
+                           ACPI_CAST_PTR(acpi_handle, acpi_gbl_root_node);
                        return (AE_OK);
                }
        } else if (!prefix_node) {
@@ -129,7 +129,7 @@ acpi_get_handle(acpi_handle parent,
        status =
            acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
        if (ACPI_SUCCESS(status)) {
-               *ret_handle = acpi_ns_convert_entry_to_handle(node);
+               *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
        }
 
        return (status);
@@ -186,7 +186,7 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
                return (status);
        }
 
-       node = acpi_ns_map_handle_to_node(handle);
+       node = acpi_ns_validate_handle(handle);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
@@ -291,7 +291,7 @@ acpi_get_object_info(acpi_handle handle,
                goto cleanup;
        }
 
-       node = acpi_ns_map_handle_to_node(handle);
+       node = acpi_ns_validate_handle(handle);
        if (!node) {
                (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
                return (AE_BAD_PARAMETER);
index 4071bad4458ed7d229bc04e30cb02abcb8efe26b..0cc6ba01a49543c27eb669fdf662f8db31a587d5 100644 (file)
@@ -79,7 +79,7 @@ acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id)
 
        /* Convert and validate the handle */
 
-       node = acpi_ns_map_handle_to_node(handle);
+       node = acpi_ns_validate_handle(handle);
        if (!node) {
                (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
                return (AE_BAD_PARAMETER);
@@ -132,7 +132,7 @@ acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type)
 
        /* Convert and validate the handle */
 
-       node = acpi_ns_map_handle_to_node(handle);
+       node = acpi_ns_validate_handle(handle);
        if (!node) {
                (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
                return (AE_BAD_PARAMETER);
@@ -182,7 +182,7 @@ acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
 
        /* Convert and validate the handle */
 
-       node = acpi_ns_map_handle_to_node(handle);
+       node = acpi_ns_validate_handle(handle);
        if (!node) {
                status = AE_BAD_PARAMETER;
                goto unlock_and_exit;
@@ -191,7 +191,7 @@ acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
        /* Get the parent entry */
 
        parent_node = acpi_ns_get_parent_node(node);
-       *ret_handle = acpi_ns_convert_entry_to_handle(parent_node);
+       *ret_handle = ACPI_CAST_PTR(acpi_handle, parent_node);
 
        /* Return exception if parent is null */
 
@@ -251,7 +251,7 @@ acpi_get_next_object(acpi_object_type type,
 
                /* Start search at the beginning of the specified scope */
 
-               parent_node = acpi_ns_map_handle_to_node(parent);
+               parent_node = acpi_ns_validate_handle(parent);
                if (!parent_node) {
                        status = AE_BAD_PARAMETER;
                        goto unlock_and_exit;
@@ -260,7 +260,7 @@ acpi_get_next_object(acpi_object_type type,
                /* Non-null handle, ignore the parent */
                /* Convert and validate the handle */
 
-               child_node = acpi_ns_map_handle_to_node(child);
+               child_node = acpi_ns_validate_handle(child);
                if (!child_node) {
                        status = AE_BAD_PARAMETER;
                        goto unlock_and_exit;
@@ -276,7 +276,7 @@ acpi_get_next_object(acpi_object_type type,
        }
 
        if (ret_handle) {
-               *ret_handle = acpi_ns_convert_entry_to_handle(node);
+               *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
        }
 
       unlock_and_exit:
index 12934ad6da8e3a1c2db36844d1a320f2a41ccc0d..d0c1b91eb8caa4731b81c71b94df969f17327127 100644 (file)
@@ -287,7 +287,8 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
        /* Invoke an internal method if necessary */
 
        if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
-               status = info->obj_desc->method.implementation(walk_state);
+               status =
+                   info->obj_desc->method.extra.implementation(walk_state);
                info->return_object = walk_state->return_desc;
 
                /* Cleanup states */
index 395212bcd19b470d756efa5328dfc9d21464c603..f27feb4772f6306b10a3a897f3f2759f5fa8c237 100644 (file)
@@ -104,7 +104,7 @@ acpi_rs_validate_parameters(acpi_handle device_handle,
                return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
 
-       node = acpi_ns_map_handle_to_node(device_handle);
+       node = acpi_ns_validate_handle(device_handle);
        if (!node) {
                return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
index 0f0c64bf8ac98d1cae2da0bdb073405d5f08d9e5..f857c5efb79f6d2cb2dc5d3bc9e9ae4376a51865 100644 (file)
@@ -323,11 +323,11 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type,
  * RETURN:      Status
  *
  * DESCRIPTION: This function is called to place a package object in a user
- *              buffer.  A package object by definition contains other objects.
+ *              buffer. A package object by definition contains other objects.
  *
  *              The buffer is assumed to have sufficient space for the object.
- *              The caller must have verified the buffer length needed using the
- *              acpi_ut_get_object_size function before calling this function.
+ *              The caller must have verified the buffer length needed using
+ *              the acpi_ut_get_object_size function before calling this function.
  *
  ******************************************************************************/
 
@@ -382,12 +382,12 @@ acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
  * FUNCTION:    acpi_ut_copy_iobject_to_eobject
  *
  * PARAMETERS:  internal_object     - The internal object to be converted
- *              buffer_ptr          - Where the object is returned
+ *              ret_buffer          - Where the object is returned
  *
  * RETURN:      Status
  *
- * DESCRIPTION: This function is called to build an API object to be returned to
- *              the caller.
+ * DESCRIPTION: This function is called to build an API object to be returned
+ *              to the caller.
  *
  ******************************************************************************/
 
@@ -626,7 +626,7 @@ acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
  * PARAMETERS:  external_object     - The external object to be converted
  *              internal_object     - Where the internal object is returned
  *
- * RETURN:      Status              - the status of the call
+ * RETURN:      Status
  *
  * DESCRIPTION: Converts an external object to an internal object.
  *
@@ -665,7 +665,7 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
  *
  * RETURN:      Status
  *
- * DESCRIPTION: Simple copy of one internal object to another.  Reference count
+ * DESCRIPTION: Simple copy of one internal object to another. Reference count
  *              of the destination object is preserved.
  *
  ******************************************************************************/
@@ -897,10 +897,11 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type,
  *
  * FUNCTION:    acpi_ut_copy_ipackage_to_ipackage
  *
- * PARAMETERS:  *source_obj     - Pointer to the source package object
- *              *dest_obj       - Where the internal object is returned
+ * PARAMETERS:  source_obj      - Pointer to the source package object
+ *              dest_obj        - Where the internal object is returned
+ *              walk_state      - Current Walk state descriptor
  *
- * RETURN:      Status          - the status of the call
+ * RETURN:      Status
  *
  * DESCRIPTION: This function is called to copy an internal package object
  *              into another internal package object.
@@ -953,9 +954,9 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
  *
  * FUNCTION:    acpi_ut_copy_iobject_to_iobject
  *
- * PARAMETERS:  walk_state          - Current walk state
- *              source_desc         - The internal object to be copied
+ * PARAMETERS:  source_desc         - The internal object to be copied
  *              dest_desc           - Where the copied object is returned
+ *              walk_state          - Current walk state
  *
  * RETURN:      Status
  *
index 3f4602b8f287252d74b6697d64142229f09e63be..cada73ffdfa7f9323264efe430afedb7abeb6f41 100644 (file)
@@ -831,7 +831,7 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
                                        dev_name(&device->dev), event,
                                        acpi_battery_present(battery));
 #ifdef CONFIG_ACPI_SYSFS_POWER
-       /* acpi_batter_update could remove power_supply object */
+       /* acpi_battery_update could remove power_supply object */
        if (battery->bat.dev)
                kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE);
 #endif
index 23e5a0519af552d27ddcb9f8c14aa38062b434ea..2815df66f6f7354f433a370a0819a91103bd50d4 100644 (file)
@@ -185,6 +185,12 @@ static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
        acpi_osi_setup("!Windows 2006");
        return 0;
 }
+static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
+{
+       printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
+       acpi_osi_setup("!Windows 2009");
+       return 0;
+}
 
 static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
        {
@@ -211,6 +217,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
                     DMI_MATCH(DMI_PRODUCT_NAME, "Sony VGN-SR290J"),
                },
        },
+       {
+       .callback = dmi_disable_osi_win7,
+       .ident = "ASUS K50IJ",
+       .matches = {
+                    DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
+                    DMI_MATCH(DMI_PRODUCT_NAME, "K50IJ"),
+               },
+       },
 
        /*
         * BIOS invocation of _OSI(Linux) is almost always a BIOS bug.
index 7411915243530f8e0a9bcd2bf7a78ce4cf576a61..cf761b904e4a2821d4cb09977182783c973a442f 100644 (file)
@@ -344,6 +344,162 @@ bool acpi_bus_can_wakeup(acpi_handle handle)
 
 EXPORT_SYMBOL(acpi_bus_can_wakeup);
 
+static void acpi_print_osc_error(acpi_handle handle,
+       struct acpi_osc_context *context, char *error)
+{
+       struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER};
+       int i;
+
+       if (ACPI_FAILURE(acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer)))
+               printk(KERN_DEBUG "%s\n", error);
+       else {
+               printk(KERN_DEBUG "%s:%s\n", (char *)buffer.pointer, error);
+               kfree(buffer.pointer);
+       }
+       printk(KERN_DEBUG"_OSC request data:");
+       for (i = 0; i < context->cap.length; i += sizeof(u32))
+               printk("%x ", *((u32 *)(context->cap.pointer + i)));
+       printk("\n");
+}
+
+static u8 hex_val(unsigned char c)
+{
+       return isdigit(c) ? c - '0' : toupper(c) - 'A' + 10;
+}
+
+static acpi_status acpi_str_to_uuid(char *str, u8 *uuid)
+{
+       int i;
+       static int opc_map_to_uuid[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
+               24, 26, 28, 30, 32, 34};
+
+       if (strlen(str) != 36)
+               return AE_BAD_PARAMETER;
+       for (i = 0; i < 36; i++) {
+               if (i == 8 || i == 13 || i == 18 || i == 23) {
+                       if (str[i] != '-')
+                               return AE_BAD_PARAMETER;
+               } else if (!isxdigit(str[i]))
+                       return AE_BAD_PARAMETER;
+       }
+       for (i = 0; i < 16; i++) {
+               uuid[i] = hex_val(str[opc_map_to_uuid[i]]) << 4;
+               uuid[i] |= hex_val(str[opc_map_to_uuid[i] + 1]);
+       }
+       return AE_OK;
+}
+
+acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
+{
+       acpi_status status;
+       struct acpi_object_list input;
+       union acpi_object in_params[4];
+       union acpi_object *out_obj;
+       u8 uuid[16];
+       u32 errors;
+       struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
+
+       if (!context)
+               return AE_ERROR;
+       if (ACPI_FAILURE(acpi_str_to_uuid(context->uuid_str, uuid)))
+               return AE_ERROR;
+       context->ret.length = ACPI_ALLOCATE_BUFFER;
+       context->ret.pointer = NULL;
+
+       /* Setting up input parameters */
+       input.count = 4;
+       input.pointer = in_params;
+       in_params[0].type               = ACPI_TYPE_BUFFER;
+       in_params[0].buffer.length      = 16;
+       in_params[0].buffer.pointer     = uuid;
+       in_params[1].type               = ACPI_TYPE_INTEGER;
+       in_params[1].integer.value      = context->rev;
+       in_params[2].type               = ACPI_TYPE_INTEGER;
+       in_params[2].integer.value      = context->cap.length/sizeof(u32);
+       in_params[3].type               = ACPI_TYPE_BUFFER;
+       in_params[3].buffer.length      = context->cap.length;
+       in_params[3].buffer.pointer     = context->cap.pointer;
+
+       status = acpi_evaluate_object(handle, "_OSC", &input, &output);
+       if (ACPI_FAILURE(status))
+               return status;
+
+       if (!output.length)
+               return AE_NULL_OBJECT;
+
+       out_obj = output.pointer;
+       if (out_obj->type != ACPI_TYPE_BUFFER
+               || out_obj->buffer.length != context->cap.length) {
+               acpi_print_osc_error(handle, context,
+                       "_OSC evaluation returned wrong type");
+               status = AE_TYPE;
+               goto out_kfree;
+       }
+       /* Need to ignore the bit0 in result code */
+       errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
+       if (errors) {
+               if (errors & OSC_REQUEST_ERROR)
+                       acpi_print_osc_error(handle, context,
+                               "_OSC request failed");
+               if (errors & OSC_INVALID_UUID_ERROR)
+                       acpi_print_osc_error(handle, context,
+                               "_OSC invalid UUID");
+               if (errors & OSC_INVALID_REVISION_ERROR)
+                       acpi_print_osc_error(handle, context,
+                               "_OSC invalid revision");
+               if (errors & OSC_CAPABILITIES_MASK_ERROR) {
+                       if (((u32 *)context->cap.pointer)[OSC_QUERY_TYPE]
+                           & OSC_QUERY_ENABLE)
+                               goto out_success;
+                       status = AE_SUPPORT;
+                       goto out_kfree;
+               }
+               status = AE_ERROR;
+               goto out_kfree;
+       }
+out_success:
+       context->ret.length = out_obj->buffer.length;
+       context->ret.pointer = kmalloc(context->ret.length, GFP_KERNEL);
+       if (!context->ret.pointer) {
+               status =  AE_NO_MEMORY;
+               goto out_kfree;
+       }
+       memcpy(context->ret.pointer, out_obj->buffer.pointer,
+               context->ret.length);
+       status =  AE_OK;
+
+out_kfree:
+       kfree(output.pointer);
+       if (status != AE_OK)
+               context->ret.pointer = NULL;
+       return status;
+}
+EXPORT_SYMBOL(acpi_run_osc);
+
+static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
+static void acpi_bus_osc_support(void)
+{
+       u32 capbuf[2];
+       struct acpi_osc_context context = {
+               .uuid_str = sb_uuid_str,
+               .rev = 1,
+               .cap.length = 8,
+               .cap.pointer = capbuf,
+       };
+       acpi_handle handle;
+
+       capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
+       capbuf[OSC_SUPPORT_TYPE] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */
+#ifdef CONFIG_ACPI_PROCESSOR_AGGREGATOR
+       capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PAD_SUPPORT;
+#endif
+       if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
+               return;
+       if (ACPI_SUCCESS(acpi_run_osc(handle, &context)))
+               kfree(context.ret.pointer);
+       /* do we need to check the returned cap? Sounds no */
+}
+
 /* --------------------------------------------------------------------------
                                 Event Management
    -------------------------------------------------------------------------- */
@@ -734,12 +890,16 @@ static int __init acpi_bus_init(void)
        status = acpi_ec_ecdt_probe();
        /* Ignore result. Not having an ECDT is not fatal. */
 
+       acpi_bus_osc_support();
+
        status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
        if (ACPI_FAILURE(status)) {
                printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
                goto error1;
        }
 
+       acpi_early_processor_set_pdc();
+
        /*
         * Maybe EC region is required at bus_scan/acpi_get_devices. So it
         * is necessary to enable it as early as possible.
index 0c9c6a9a002cb397867269e7bc44f56d4bd9f9bd..8a95e8329df732891b260efe67ad1c1855538be8 100644 (file)
@@ -282,6 +282,13 @@ static int acpi_lid_send_state(struct acpi_device *device)
        if (ret == NOTIFY_DONE)
                ret = blocking_notifier_call_chain(&acpi_lid_notifier, state,
                                                   device);
+       if (ret == NOTIFY_DONE || ret == NOTIFY_OK) {
+               /*
+                * It is also regarded as success if the notifier_chain
+                * returns NOTIFY_OK or NOTIFY_DONE.
+                */
+               ret = 0;
+       }
        return ret;
 }
 
index 8a690c3b8e234734df9ec63d1667c98671bc621a..cc421b7ae166c4ffe6a005c73b3f2714a36db2b9 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/moduleparam.h>
+#include <linux/debugfs.h>
 #include <asm/uaccess.h>
 #include <acpi/acpi_drivers.h>
 
@@ -195,6 +196,80 @@ static int param_get_trace_state(char *buffer, struct kernel_param *kp)
 module_param_call(trace_state, param_set_trace_state, param_get_trace_state,
                  NULL, 0644);
 
+/* --------------------------------------------------------------------------
+                               DebugFS Interface
+   -------------------------------------------------------------------------- */
+
+static ssize_t cm_write(struct file *file, const char __user *user_buf,
+                       size_t count, loff_t *ppos)
+{
+       static char *buf;
+       static int uncopied_bytes;
+       struct acpi_table_header table;
+       acpi_status status;
+
+       if (!(*ppos)) {
+               /* parse the table header to get the table length */
+               if (count <= sizeof(struct acpi_table_header))
+                       return -EINVAL;
+               if (copy_from_user(&table, user_buf,
+                       sizeof(struct acpi_table_header)))
+                       return -EFAULT;
+               uncopied_bytes = table.length;
+               buf = kzalloc(uncopied_bytes, GFP_KERNEL);
+               if (!buf)
+                       return -ENOMEM;
+       }
+
+       if (uncopied_bytes < count) {
+               kfree(buf);
+               return -EINVAL;
+       }
+
+       if (copy_from_user(buf + (*ppos), user_buf, count)) {
+               kfree(buf);
+               return -EFAULT;
+       }
+
+       uncopied_bytes -= count;
+       *ppos += count;
+
+       if (!uncopied_bytes) {
+               status = acpi_install_method(buf);
+               kfree(buf);
+               if (ACPI_FAILURE(status))
+                       return -EINVAL;
+               add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
+       }
+
+       return count;
+}
+
+static const struct file_operations cm_fops = {
+       .write = cm_write,
+};
+
+static int acpi_debugfs_init(void)
+{
+       struct dentry *acpi_dir, *cm_dentry;
+
+       acpi_dir = debugfs_create_dir("acpi", NULL);
+       if (!acpi_dir)
+               goto err;
+
+       cm_dentry = debugfs_create_file("custom_method", S_IWUGO,
+                                       acpi_dir, NULL, &cm_fops);
+       if (!cm_dentry)
+               goto err;
+
+       return 0;
+
+err:
+       if (acpi_dir)
+               debugfs_remove(acpi_dir);
+       return -EINVAL;
+}
+
 /* --------------------------------------------------------------------------
                               FS Interface (/proc)
    -------------------------------------------------------------------------- */
@@ -286,7 +361,7 @@ static const struct file_operations acpi_system_debug_proc_fops = {
 };
 #endif
 
-int __init acpi_debug_init(void)
+int __init acpi_procfs_init(void)
 {
 #ifdef CONFIG_ACPI_PROCFS
        struct proc_dir_entry *entry;
@@ -321,3 +396,10 @@ int __init acpi_debug_init(void)
        return 0;
 #endif
 }
+
+int __init acpi_debug_init(void)
+{
+       acpi_debugfs_init();
+       acpi_procfs_init();
+       return 0;
+}
index 30be3c148f7eadd29f7ab67338d3953054b9f323..bbc2c1315c473ca7c7e8ff3770506ba645f16f0f 100644 (file)
@@ -50,7 +50,6 @@ MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
        " before undocking");
 
 static struct atomic_notifier_head dock_notifier_list;
-static char dock_device_name[] = "dock";
 
 static const struct acpi_device_id dock_device_ids[] = {
        {"LNXDOCK", 0},
@@ -93,40 +92,30 @@ struct dock_dependent_device {
  *                         Dock Dependent device functions                   *
  *****************************************************************************/
 /**
- *  alloc_dock_dependent_device - allocate and init a dependent device
- *  @handle: the acpi_handle of the dependent device
+ * add_dock_dependent_device - associate a device with the dock station
+ * @ds: The dock station
+ * @handle: handle of the dependent device
  *
- *  Allocate memory for a dependent device structure for a device referenced
- *  by the acpi handle
+ * Add the dependent device to the dock's dependent device list.
  */
-static struct dock_dependent_device *
-alloc_dock_dependent_device(acpi_handle handle)
+static int
+add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
 {
        struct dock_dependent_device *dd;
 
        dd = kzalloc(sizeof(*dd), GFP_KERNEL);
-       if (dd) {
-               dd->handle = handle;
-               INIT_LIST_HEAD(&dd->list);
-               INIT_LIST_HEAD(&dd->hotplug_list);
-       }
-       return dd;
-}
+       if (!dd)
+               return -ENOMEM;
+
+       dd->handle = handle;
+       INIT_LIST_HEAD(&dd->list);
+       INIT_LIST_HEAD(&dd->hotplug_list);
 
-/**
- * add_dock_dependent_device - associate a device with the dock station
- * @ds: The dock station
- * @dd: The dependent device
- *
- * Add the dependent device to the dock's dependent device list.
- */
-static void
-add_dock_dependent_device(struct dock_station *ds,
-                         struct dock_dependent_device *dd)
-{
        spin_lock(&ds->dd_lock);
        list_add_tail(&dd->list, &ds->dependent_devices);
        spin_unlock(&ds->dd_lock);
+
+       return 0;
 }
 
 /**
@@ -249,6 +238,7 @@ static int is_battery(acpi_handle handle)
 static int is_ejectable_bay(acpi_handle handle)
 {
        acpi_handle phandle;
+
        if (!is_ejectable(handle))
                return 0;
        if (is_battery(handle) || is_ata(handle))
@@ -275,14 +265,13 @@ int is_dock_device(acpi_handle handle)
 
        if (is_dock(handle))
                return 1;
-       list_for_each_entry(dock_station, &dock_stations, sibling) {
+
+       list_for_each_entry(dock_station, &dock_stations, sibling)
                if (find_dock_dependent_device(dock_station, handle))
                        return 1;
-       }
 
        return 0;
 }
-
 EXPORT_SYMBOL_GPL(is_dock_device);
 
 /**
@@ -305,8 +294,6 @@ static int dock_present(struct dock_station *ds)
        return 0;
 }
 
-
-
 /**
  * dock_create_acpi_device - add new devices to acpi
  * @handle - handle of the device to add
@@ -320,7 +307,7 @@ static int dock_present(struct dock_station *ds)
  */
 static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
 {
-       struct acpi_device *device = NULL;
+       struct acpi_device *device;
        struct acpi_device *parent_device;
        acpi_handle parent;
        int ret;
@@ -337,8 +324,7 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
                ret = acpi_bus_add(&device, parent_device, handle,
                        ACPI_BUS_TYPE_DEVICE);
                if (ret) {
-                       pr_debug("error adding bus, %x\n",
-                               -ret);
+                       pr_debug("error adding bus, %x\n", -ret);
                        return NULL;
                }
        }
@@ -364,7 +350,6 @@ static void dock_remove_acpi_device(acpi_handle handle)
        }
 }
 
-
 /**
  * hotplug_dock_devices - insert or remove devices on the dock station
  * @ds: the dock station
@@ -384,10 +369,9 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
        /*
         * First call driver specific hotplug functions
         */
-       list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) {
+       list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list)
                if (dd->ops && dd->ops->handler)
                        dd->ops->handler(dd->handle, event, dd->context);
-       }
 
        /*
         * Now make sure that an acpi_device is created for each
@@ -426,6 +410,7 @@ static void dock_event(struct dock_station *ds, u32 event, int num)
        list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list)
                if (dd->ops && dd->ops->uevent)
                        dd->ops->uevent(dd->handle, event, dd->context);
+
        if (num != DOCK_EVENT)
                kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
 }
@@ -456,8 +441,8 @@ static void eject_dock(struct dock_station *ds)
        arg.type = ACPI_TYPE_INTEGER;
        arg.integer.value = 1;
 
-       if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0",
-                                             &arg_list, NULL)))
+       status = acpi_evaluate_object(ds->handle, "_EJ0", &arg_list, NULL);
+       if (ACPI_FAILURE(status))
                pr_debug("Failed to evaluate _EJ0!\n");
 }
 
@@ -577,7 +562,6 @@ int register_dock_notifier(struct notifier_block *nb)
 
        return atomic_notifier_chain_register(&dock_notifier_list, nb);
 }
-
 EXPORT_SYMBOL_GPL(register_dock_notifier);
 
 /**
@@ -591,7 +575,6 @@ void unregister_dock_notifier(struct notifier_block *nb)
 
        atomic_notifier_chain_unregister(&dock_notifier_list, nb);
 }
-
 EXPORT_SYMBOL_GPL(unregister_dock_notifier);
 
 /**
@@ -636,7 +619,6 @@ register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops,
 
        return ret;
 }
-
 EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
 
 /**
@@ -657,7 +639,6 @@ void unregister_hotplug_dock_device(acpi_handle handle)
                        dock_del_hotplug_device(dock_station, dd);
        }
 }
-
 EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
 
 /**
@@ -772,7 +753,7 @@ struct dock_data {
 
 static void acpi_dock_deferred_cb(void *context)
 {
-       struct dock_data *data = (struct dock_data *)context;
+       struct dock_data *data = context;
 
        dock_notify(data->handle, data->event, data->ds);
        kfree(data);
@@ -782,23 +763,22 @@ static int acpi_dock_notifier_call(struct notifier_block *this,
        unsigned long event, void *data)
 {
        struct dock_station *dock_station;
-       acpi_handle handle = (acpi_handle)data;
+       acpi_handle handle = data;
 
        if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
           && event != ACPI_NOTIFY_EJECT_REQUEST)
                return 0;
        list_for_each_entry(dock_station, &dock_stations, sibling) {
                if (dock_station->handle == handle) {
-                       struct dock_data *dock_data;
+                       struct dock_data *dd;
 
-                       dock_data = kmalloc(sizeof(*dock_data), GFP_KERNEL);
-                       if (!dock_data)
+                       dd = kmalloc(sizeof(*dd), GFP_KERNEL);
+                       if (!dd)
                                return 0;
-                       dock_data->handle = handle;
-                       dock_data->event = event;
-                       dock_data->ds = dock_station;
-                       acpi_os_hotplug_execute(acpi_dock_deferred_cb,
-                               dock_data);
+                       dd->handle = handle;
+                       dd->event = event;
+                       dd->ds = dock_station;
+                       acpi_os_hotplug_execute(acpi_dock_deferred_cb, dd);
                        return 0 ;
                }
        }
@@ -826,7 +806,6 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
        acpi_status status;
        acpi_handle tmp, parent;
        struct dock_station *ds = context;
-       struct dock_dependent_device *dd;
 
        status = acpi_bus_get_ejd(handle, &tmp);
        if (ACPI_FAILURE(status)) {
@@ -840,11 +819,9 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
                        goto fdd_out;
        }
 
-       if (tmp == ds->handle) {
-               dd = alloc_dock_dependent_device(handle);
-               if (dd)
-                       add_dock_dependent_device(ds, dd);
-       }
+       if (tmp == ds->handle)
+               add_dock_dependent_device(ds, handle);
+
 fdd_out:
        return AE_OK;
 }
@@ -857,8 +834,7 @@ static ssize_t show_docked(struct device *dev,
 {
        struct acpi_device *tmp;
 
-       struct dock_station *dock_station = *((struct dock_station **)
-               dev->platform_data);
+       struct dock_station *dock_station = dev->platform_data;
 
        if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp)))
                return snprintf(buf, PAGE_SIZE, "1\n");
@@ -872,8 +848,7 @@ static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
 static ssize_t show_flags(struct device *dev,
                          struct device_attribute *attr, char *buf)
 {
-       struct dock_station *dock_station = *((struct dock_station **)
-               dev->platform_data);
+       struct dock_station *dock_station = dev->platform_data;
        return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
 
 }
@@ -886,8 +861,7 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
                           const char *buf, size_t count)
 {
        int ret;
-       struct dock_station *dock_station = *((struct dock_station **)
-               dev->platform_data);
+       struct dock_station *dock_station = dev->platform_data;
 
        if (!count)
                return -EINVAL;
@@ -905,8 +879,7 @@ static ssize_t show_dock_uid(struct device *dev,
                             struct device_attribute *attr, char *buf)
 {
        unsigned long long lbuf;
-       struct dock_station *dock_station = *((struct dock_station **)
-               dev->platform_data);
+       struct dock_station *dock_station = dev->platform_data;
        acpi_status status = acpi_evaluate_integer(dock_station->handle,
                                        "_UID", NULL, &lbuf);
        if (ACPI_FAILURE(status))
@@ -919,8 +892,7 @@ static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
 static ssize_t show_dock_type(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct dock_station *dock_station = *((struct dock_station **)
-               dev->platform_data);
+       struct dock_station *dock_station = dev->platform_data;
        char *type;
 
        if (dock_station->flags & DOCK_IS_DOCK)
@@ -936,6 +908,19 @@ static ssize_t show_dock_type(struct device *dev,
 }
 static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
 
+static struct attribute *dock_attributes[] = {
+       &dev_attr_docked.attr,
+       &dev_attr_flags.attr,
+       &dev_attr_undock.attr,
+       &dev_attr_uid.attr,
+       &dev_attr_type.attr,
+       NULL
+};
+
+static struct attribute_group dock_attribute_group = {
+       .attrs = dock_attributes
+};
+
 /**
  * dock_add - add a new dock station
  * @handle: the dock station handle
@@ -945,39 +930,30 @@ static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
  */
 static int dock_add(acpi_handle handle)
 {
-       int ret;
-       struct dock_dependent_device *dd;
-       struct dock_station *dock_station;
-       struct platform_device *dock_device;
+       int ret, id;
+       struct dock_station ds, *dock_station;
+       struct platform_device *dd;
+
+       id = dock_station_count;
+       dd = platform_device_register_data(NULL, "dock", id, &ds, sizeof(ds));
+       if (IS_ERR(dd))
+               return PTR_ERR(dd);
+
+       dock_station = dd->dev.platform_data;
 
-       /* allocate & initialize the dock_station private data */
-       dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL);
-       if (!dock_station)
-               return -ENOMEM;
        dock_station->handle = handle;
+       dock_station->dock_device = dd;
        dock_station->last_dock_time = jiffies - HZ;
-       INIT_LIST_HEAD(&dock_station->dependent_devices);
-       INIT_LIST_HEAD(&dock_station->hotplug_devices);
-       INIT_LIST_HEAD(&dock_station->sibling);
-       spin_lock_init(&dock_station->dd_lock);
+
        mutex_init(&dock_station->hp_lock);
+       spin_lock_init(&dock_station->dd_lock);
+       INIT_LIST_HEAD(&dock_station->sibling);
+       INIT_LIST_HEAD(&dock_station->hotplug_devices);
        ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
-
-       /* initialize platform device stuff */
-       dock_station->dock_device =
-               platform_device_register_simple(dock_device_name,
-                       dock_station_count, NULL, 0);
-       dock_device = dock_station->dock_device;
-       if (IS_ERR(dock_device)) {
-               kfree(dock_station);
-               dock_station = NULL;
-               return PTR_ERR(dock_device);
-       }
-       platform_device_add_data(dock_device, &dock_station,
-               sizeof(struct dock_station *));
+       INIT_LIST_HEAD(&dock_station->dependent_devices);
 
        /* we want the dock device to send uevents */
-       dev_set_uevent_suppress(&dock_device->dev, 0);
+       dev_set_uevent_suppress(&dd->dev, 0);
 
        if (is_dock(handle))
                dock_station->flags |= DOCK_IS_DOCK;
@@ -986,47 +962,9 @@ static int dock_add(acpi_handle handle)
        if (is_battery(handle))
                dock_station->flags |= DOCK_IS_BAT;
 
-       ret = device_create_file(&dock_device->dev, &dev_attr_docked);
-       if (ret) {
-               printk(KERN_ERR "Error %d adding sysfs file\n", ret);
-               platform_device_unregister(dock_device);
-               kfree(dock_station);
-               dock_station = NULL;
-               return ret;
-       }
-       ret = device_create_file(&dock_device->dev, &dev_attr_undock);
-       if (ret) {
-               printk(KERN_ERR "Error %d adding sysfs file\n", ret);
-               device_remove_file(&dock_device->dev, &dev_attr_docked);
-               platform_device_unregister(dock_device);
-               kfree(dock_station);
-               dock_station = NULL;
-               return ret;
-       }
-       ret = device_create_file(&dock_device->dev, &dev_attr_uid);
-       if (ret) {
-               printk(KERN_ERR "Error %d adding sysfs file\n", ret);
-               device_remove_file(&dock_device->dev, &dev_attr_docked);
-               device_remove_file(&dock_device->dev, &dev_attr_undock);
-               platform_device_unregister(dock_device);
-               kfree(dock_station);
-               dock_station = NULL;
-               return ret;
-       }
-       ret = device_create_file(&dock_device->dev, &dev_attr_flags);
-       if (ret) {
-               printk(KERN_ERR "Error %d adding sysfs file\n", ret);
-               device_remove_file(&dock_device->dev, &dev_attr_docked);
-               device_remove_file(&dock_device->dev, &dev_attr_undock);
-               device_remove_file(&dock_device->dev, &dev_attr_uid);
-               platform_device_unregister(dock_device);
-               kfree(dock_station);
-               dock_station = NULL;
-               return ret;
-       }
-       ret = device_create_file(&dock_device->dev, &dev_attr_type);
+       ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
        if (ret)
-               printk(KERN_ERR"Error %d adding sysfs file\n", ret);
+               goto err_unregister;
 
        /* Find dependent devices */
        acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
@@ -1034,58 +972,43 @@ static int dock_add(acpi_handle handle)
                            dock_station, NULL);
 
        /* add the dock station as a device dependent on itself */
-       dd = alloc_dock_dependent_device(handle);
-       if (!dd) {
-               kfree(dock_station);
-               dock_station = NULL;
-               ret = -ENOMEM;
-               goto dock_add_err_unregister;
-       }
-       add_dock_dependent_device(dock_station, dd);
+       ret = add_dock_dependent_device(dock_station, handle);
+       if (ret)
+               goto err_rmgroup;
 
        dock_station_count++;
        list_add(&dock_station->sibling, &dock_stations);
        return 0;
 
-dock_add_err_unregister:
-       device_remove_file(&dock_device->dev, &dev_attr_type);
-       device_remove_file(&dock_device->dev, &dev_attr_docked);
-       device_remove_file(&dock_device->dev, &dev_attr_undock);
-       device_remove_file(&dock_device->dev, &dev_attr_uid);
-       device_remove_file(&dock_device->dev, &dev_attr_flags);
-       platform_device_unregister(dock_device);
-       kfree(dock_station);
-       dock_station = NULL;
+err_rmgroup:
+       sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
+err_unregister:
+       platform_device_unregister(dd);
+       printk(KERN_ERR "%s encountered error %d\n", __func__, ret);
        return ret;
 }
 
 /**
  * dock_remove - free up resources related to the dock station
  */
-static int dock_remove(struct dock_station *dock_station)
+static int dock_remove(struct dock_station *ds)
 {
        struct dock_dependent_device *dd, *tmp;
-       struct platform_device *dock_device = dock_station->dock_device;
+       struct platform_device *dock_device = ds->dock_device;
 
        if (!dock_station_count)
                return 0;
 
        /* remove dependent devices */
-       list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices,
-                                list)
-           kfree(dd);
+       list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, list)
+               kfree(dd);
+
+       list_del(&ds->sibling);
 
        /* cleanup sysfs */
-       device_remove_file(&dock_device->dev, &dev_attr_type);
-       device_remove_file(&dock_device->dev, &dev_attr_docked);
-       device_remove_file(&dock_device->dev, &dev_attr_undock);
-       device_remove_file(&dock_device->dev, &dev_attr_uid);
-       device_remove_file(&dock_device->dev, &dev_attr_flags);
+       sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group);
        platform_device_unregister(dock_device);
 
-       /* free dock station memory */
-       kfree(dock_station);
-       dock_station = NULL;
        return 0;
 }
 
@@ -1103,11 +1026,10 @@ find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
 {
        acpi_status status = AE_OK;
 
-       if (is_dock(handle)) {
-               if (dock_add(handle) >= 0) {
+       if (is_dock(handle))
+               if (dock_add(handle) >= 0)
                        status = AE_CTRL_TERMINATE;
-               }
-       }
+
        return status;
 }
 
@@ -1145,8 +1067,7 @@ static int __init dock_init(void)
 
 static void __exit dock_exit(void)
 {
-       struct dock_station *dock_station;
-       struct dock_station *tmp;
+       struct dock_station *tmp, *dock_station;
 
        unregister_acpi_bus_notifier(&dock_acpi_notifier);
        list_for_each_entry_safe(dock_station, tmp, &dock_stations, sibling)
index 75b147f5c8fdbcd0acc6e87a2d3b7a80bed6d3c0..fd1801bdee66de41bffe16aec7afc07f4db171d5 100644 (file)
@@ -916,6 +916,7 @@ static int ec_validate_ecdt(const struct dmi_system_id *id)
 /* MSI EC needs special treatment, enable it */
 static int ec_flag_msi(const struct dmi_system_id *id)
 {
+       printk(KERN_DEBUG PREFIX "Detected MSI hardware, enabling workarounds.\n");
        EC_FLAGS_MSI = 1;
        EC_FLAGS_VALIDATE_ECDT = 1;
        return 0;
@@ -928,8 +929,13 @@ static struct dmi_system_id __initdata ec_dmi_table[] = {
        DMI_MATCH(DMI_BOARD_NAME, "JFL92") }, NULL},
        {
        ec_flag_msi, "MSI hardware", {
-       DMI_MATCH(DMI_BIOS_VENDOR, "Micro-Star"),
-       DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-Star") }, NULL},
+       DMI_MATCH(DMI_BIOS_VENDOR, "Micro-Star")}, NULL},
+       {
+       ec_flag_msi, "MSI hardware", {
+       DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star")}, NULL},
+       {
+       ec_flag_msi, "MSI hardware", {
+       DMI_MATCH(DMI_CHASSIS_VENDOR, "MICRO-Star")}, NULL},
        {
        ec_validate_ecdt, "ASUS hardware", {
        DMI_MATCH(DMI_BIOS_VENDOR, "ASUS") }, NULL},
index f419849a0d3f04d8c0f55585e185e42a7d4fdaa5..acf2ab24984263d7990239a395e73862cf914c5c 100644 (file)
@@ -267,7 +267,7 @@ static int acpi_fan_add(struct acpi_device *device)
                goto end;
        }
 
-       dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id);
+       dev_dbg(&device->dev, "registered as cooling_device%d\n", cdev->id);
 
        device->driver_data = cdev;
        result = sysfs_create_link(&device->dev.kobj,
index 074cf8682d525d486306d800dd0283baa1c8017b..cb28e0502acc346af5233ebeaa195b723a995713 100644 (file)
@@ -43,6 +43,7 @@ int acpi_power_transition(struct acpi_device *device, int state);
 extern int acpi_power_nocheck;
 
 int acpi_wakeup_device_init(void);
+void acpi_early_processor_set_pdc(void);
 
 /* --------------------------------------------------------------------------
                                   Embedded Controller
index 2be2fb66204e53c18e63d30c9581dea4a9d71ade..7ad48dfc12dbc838ab82275517e5521463c4319b 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/acpi.h>
+#include <linux/numa.h>
 #include <acpi/acpi_bus.h>
 
 #define PREFIX "ACPI: "
@@ -40,14 +41,14 @@ static nodemask_t nodes_found_map = NODE_MASK_NONE;
 
 /* maps to convert between proximity domain and logical node ID */
 static int pxm_to_node_map[MAX_PXM_DOMAINS]
-                               = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL };
+                       = { [0 ... MAX_PXM_DOMAINS - 1] = NUMA_NO_NODE };
 static int node_to_pxm_map[MAX_NUMNODES]
-                               = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
+                       = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
 
 int pxm_to_node(int pxm)
 {
        if (pxm < 0)
-               return NID_INVAL;
+               return NUMA_NO_NODE;
        return pxm_to_node_map[pxm];
 }
 
@@ -68,9 +69,9 @@ int acpi_map_pxm_to_node(int pxm)
 {
        int node = pxm_to_node_map[pxm];
 
-       if (node < 0){
+       if (node < 0) {
                if (nodes_weight(nodes_found_map) >= MAX_NUMNODES)
-                       return NID_INVAL;
+                       return NUMA_NO_NODE;
                node = first_unset_node(nodes_found_map);
                __acpi_map_pxm_to_node(pxm, node);
                node_set(node, nodes_found_map);
@@ -79,16 +80,6 @@ int acpi_map_pxm_to_node(int pxm)
        return node;
 }
 
-#if 0
-void __cpuinit acpi_unmap_pxm_to_node(int node)
-{
-       int pxm = node_to_pxm_map[node];
-       pxm_to_node_map[pxm] = NID_INVAL;
-       node_to_pxm_map[node] = PXM_INVAL;
-       node_clear(node, nodes_found_map);
-}
-#endif  /*  0  */
-
 static void __init
 acpi_table_print_srat_entry(struct acpi_subtable_header *header)
 {
index 7c1c59ea9ec68368d2056a07fbc82b9e717557b9..02e8464e480f9e7dea0d3a25ba935ea55e27b8e1 100644 (file)
@@ -1118,7 +1118,7 @@ __setup("acpi_enforce_resources=", acpi_enforce_resources_setup);
 
 /* Check for resource conflicts between ACPI OperationRegions and native
  * drivers */
-int acpi_check_resource_conflict(struct resource *res)
+int acpi_check_resource_conflict(const struct resource *res)
 {
        struct acpi_res_list *res_list_elem;
        int ioport;
index 1af808171d4682be716b0e7613980ed0c3fe8dc8..101cce3681d1ea198d1e0575f428cdab2923d46c 100644 (file)
@@ -202,72 +202,24 @@ static void acpi_pci_bridge_scan(struct acpi_device *device)
                }
 }
 
-static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40,
-                         0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
+static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
 
 static acpi_status acpi_pci_run_osc(acpi_handle handle,
                                    const u32 *capbuf, u32 *retval)
 {
+       struct acpi_osc_context context = {
+               .uuid_str = pci_osc_uuid_str,
+               .rev = 1,
+               .cap.length = 12,
+               .cap.pointer = (void *)capbuf,
+       };
        acpi_status status;
-       struct acpi_object_list input;
-       union acpi_object in_params[4];
-       struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
-       union acpi_object *out_obj;
-       u32 errors;
-
-       /* Setting up input parameters */
-       input.count = 4;
-       input.pointer = in_params;
-       in_params[0].type               = ACPI_TYPE_BUFFER;
-       in_params[0].buffer.length      = 16;
-       in_params[0].buffer.pointer     = OSC_UUID;
-       in_params[1].type               = ACPI_TYPE_INTEGER;
-       in_params[1].integer.value      = 1;
-       in_params[2].type               = ACPI_TYPE_INTEGER;
-       in_params[2].integer.value      = 3;
-       in_params[3].type               = ACPI_TYPE_BUFFER;
-       in_params[3].buffer.length      = 12;
-       in_params[3].buffer.pointer     = (u8 *)capbuf;
-
-       status = acpi_evaluate_object(handle, "_OSC", &input, &output);
-       if (ACPI_FAILURE(status))
-               return status;
 
-       if (!output.length)
-               return AE_NULL_OBJECT;
-
-       out_obj = output.pointer;
-       if (out_obj->type != ACPI_TYPE_BUFFER) {
-               printk(KERN_DEBUG "_OSC evaluation returned wrong type\n");
-               status = AE_TYPE;
-               goto out_kfree;
-       }
-       /* Need to ignore the bit0 in result code */
-       errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
-       if (errors) {
-               if (errors & OSC_REQUEST_ERROR)
-                       printk(KERN_DEBUG "_OSC request failed\n");
-               if (errors & OSC_INVALID_UUID_ERROR)
-                       printk(KERN_DEBUG "_OSC invalid UUID\n");
-               if (errors & OSC_INVALID_REVISION_ERROR)
-                       printk(KERN_DEBUG "_OSC invalid revision\n");
-               if (errors & OSC_CAPABILITIES_MASK_ERROR) {
-                       if (capbuf[OSC_QUERY_TYPE] & OSC_QUERY_ENABLE)
-                               goto out_success;
-                       printk(KERN_DEBUG
-                              "Firmware did not grant requested _OSC control\n");
-                       status = AE_SUPPORT;
-                       goto out_kfree;
-               }
-               status = AE_ERROR;
-               goto out_kfree;
+       status = acpi_run_osc(handle, &context);
+       if (ACPI_SUCCESS(status)) {
+               *retval = *((u32 *)(context.ret.pointer + 8));
+               kfree(context.ret.pointer);
        }
-out_success:
-       *retval = *((u32 *)(out_obj->buffer.pointer + 8));
-       status = AE_OK;
-
-out_kfree:
-       kfree(output.pointer);
        return status;
 }
 
@@ -277,10 +229,10 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root, u32 flags)
        u32 support_set, result, capbuf[3];
 
        /* do _OSC query for all possible controls */
-       support_set = root->osc_support_set | (flags & OSC_SUPPORT_MASKS);
+       support_set = root->osc_support_set | (flags & OSC_PCI_SUPPORT_MASKS);
        capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
        capbuf[OSC_SUPPORT_TYPE] = support_set;
-       capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
+       capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS;
 
        status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
        if (ACPI_SUCCESS(status)) {
@@ -427,7 +379,7 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 flags)
        if (ACPI_FAILURE(status))
                return status;
 
-       control_req = (flags & OSC_CONTROL_MASKS);
+       control_req = (flags & OSC_PCI_CONTROL_MASKS);
        if (!control_req)
                return AE_TYPE;
 
index cb4283f5a79d298280537fd471de3e3114c53f42..9863c98c81baaf071dc138fd4bc2dfa125b8481b 100644 (file)
@@ -124,29 +124,6 @@ static const struct file_operations acpi_processor_info_fops = {
 
 DEFINE_PER_CPU(struct acpi_processor *, processors);
 struct acpi_processor_errata errata __read_mostly;
-static int set_no_mwait(const struct dmi_system_id *id)
-{
-       printk(KERN_NOTICE PREFIX "%s detected - "
-               "disabling mwait for CPU C-states\n", id->ident);
-       idle_nomwait = 1;
-       return 0;
-}
-
-static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
-       {
-       set_no_mwait, "IFL91 board", {
-       DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
-       DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
-       DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
-       DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
-       {
-       set_no_mwait, "Extensa 5220", {
-       DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
-       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-       DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
-       DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
-       {},
-};
 
 /* --------------------------------------------------------------------------
                                 Errata Handling
@@ -276,45 +253,6 @@ static int acpi_processor_errata(struct acpi_processor *pr)
        return result;
 }
 
-/* --------------------------------------------------------------------------
-                              Common ACPI processor functions
-   -------------------------------------------------------------------------- */
-
-/*
- * _PDC is required for a BIOS-OS handshake for most of the newer
- * ACPI processor features.
- */
-static int acpi_processor_set_pdc(struct acpi_processor *pr)
-{
-       struct acpi_object_list *pdc_in = pr->pdc;
-       acpi_status status = AE_OK;
-
-
-       if (!pdc_in)
-               return status;
-       if (idle_nomwait) {
-               /*
-                * If mwait is disabled for CPU C-states, the C2C3_FFH access
-                * mode will be disabled in the parameter of _PDC object.
-                * Of course C1_FFH access mode will also be disabled.
-                */
-               union acpi_object *obj;
-               u32 *buffer = NULL;
-
-               obj = pdc_in->pointer;
-               buffer = (u32 *)(obj->buffer.pointer);
-               buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
-
-       }
-       status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
-
-       if (ACPI_FAILURE(status))
-               ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-                   "Could not evaluate _PDC, using legacy perf. control...\n"));
-
-       return status;
-}
-
 /* --------------------------------------------------------------------------
                               FS Interface (/proc)
    -------------------------------------------------------------------------- */
@@ -353,7 +291,7 @@ static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
                           PDE(inode)->data);
 }
 
-static int acpi_processor_add_fs(struct acpi_device *device)
+static int __cpuinit acpi_processor_add_fs(struct acpi_device *device)
 {
        struct proc_dir_entry *entry = NULL;
 
@@ -722,7 +660,7 @@ static void acpi_processor_notify(struct acpi_device *device, u32 event)
        switch (event) {
        case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
                saved = pr->performance_platform_limit;
-               acpi_processor_ppc_has_changed(pr);
+               acpi_processor_ppc_has_changed(pr, 1);
                if (saved == pr->performance_platform_limit)
                        break;
                acpi_bus_generate_proc_event(device, event,
@@ -758,7 +696,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
        struct acpi_processor *pr = per_cpu(processors, cpu);
 
        if (action == CPU_ONLINE && pr) {
-               acpi_processor_ppc_has_changed(pr);
+               acpi_processor_ppc_has_changed(pr, 0);
                acpi_processor_cst_has_changed(pr);
                acpi_processor_tstate_has_changed(pr);
        }
@@ -825,12 +763,10 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
        }
 
        /* _PDC call should be done before doing anything else (if reqd.). */
-       arch_acpi_processor_init_pdc(pr);
-       acpi_processor_set_pdc(pr);
-       arch_acpi_processor_cleanup_pdc(pr);
+       acpi_processor_set_pdc(pr->handle);
 
 #ifdef CONFIG_CPU_FREQ
-       acpi_processor_ppc_has_changed(pr);
+       acpi_processor_ppc_has_changed(pr, 0);
 #endif
        acpi_processor_get_throttling_info(pr);
        acpi_processor_get_limit_info(pr);
@@ -845,7 +781,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
                goto err_power_exit;
        }
 
-       dev_info(&device->dev, "registered as cooling_device%d\n",
+       dev_dbg(&device->dev, "registered as cooling_device%d\n",
                 pr->cdev->id);
 
        result = sysfs_create_link(&device->dev.kobj,
@@ -1145,11 +1081,6 @@ static int __init acpi_processor_init(void)
        if (!acpi_processor_dir)
                return -ENOMEM;
 #endif
-       /*
-        * Check whether the system is DMI table. If yes, OSPM
-        * should not use mwait for CPU-states.
-        */
-       dmi_check_system(processor_idle_dmi_table);
        result = cpuidle_register_driver(&acpi_idle_driver);
        if (result < 0)
                goto out_proc;
index bbd066e7f854be51286760b2fed8267c62583c5f..d1676b1754d92d19a2f5b67aa6a5f29b0c2e536f 100644 (file)
@@ -164,7 +164,7 @@ static void lapic_timer_check_state(int state, struct acpi_processor *pr,
                pr->power.timer_broadcast_on_state = state;
 }
 
-static void lapic_timer_propagate_broadcast(void *arg)
+static void __lapic_timer_propagate_broadcast(void *arg)
 {
        struct acpi_processor *pr = (struct acpi_processor *) arg;
        unsigned long reason;
@@ -175,6 +175,12 @@ static void lapic_timer_propagate_broadcast(void *arg)
        clockevents_notify(reason, &pr->id);
 }
 
+static void lapic_timer_propagate_broadcast(struct acpi_processor *pr)
+{
+       smp_call_function_single(pr->id, __lapic_timer_propagate_broadcast,
+                                (void *)pr, 1);
+}
+
 /* Power(C) State timer broadcast control */
 static void lapic_timer_state_broadcast(struct acpi_processor *pr,
                                       struct acpi_processor_cx *cx,
@@ -638,8 +644,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
                working++;
        }
 
-       smp_call_function_single(pr->id, lapic_timer_propagate_broadcast,
-                                pr, 1);
+       lapic_timer_propagate_broadcast(pr);
 
        return (working);
 }
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
new file mode 100644 (file)
index 0000000..30e4dc0
--- /dev/null
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2005 Intel Corporation
+ * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
+ *
+ *     Alex Chiang <achiang@hp.com>
+ *     - Unified x86/ia64 implementations
+ *     Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
+ *     - Added _PDC for platforms with Intel CPUs
+ */
+#include <linux/dmi.h>
+
+#include <acpi/acpi_drivers.h>
+#include <acpi/processor.h>
+
+#include "internal.h"
+
+#define PREFIX                 "ACPI: "
+#define _COMPONENT             ACPI_PROCESSOR_COMPONENT
+ACPI_MODULE_NAME("processor_pdc");
+
+static int set_no_mwait(const struct dmi_system_id *id)
+{
+       printk(KERN_NOTICE PREFIX "%s detected - "
+               "disabling mwait for CPU C-states\n", id->ident);
+       idle_nomwait = 1;
+       return 0;
+}
+
+static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
+       {
+       set_no_mwait, "IFL91 board", {
+       DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
+       DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
+       DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
+       DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
+       {
+       set_no_mwait, "Extensa 5220", {
+       DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
+       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+       DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
+       DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
+       {},
+};
+
+static void acpi_set_pdc_bits(u32 *buf)
+{
+       buf[0] = ACPI_PDC_REVISION_ID;
+       buf[1] = 1;
+
+       /* Enable coordination with firmware's _TSD info */
+       buf[2] = ACPI_PDC_SMP_T_SWCOORD;
+
+       /* Twiddle arch-specific bits needed for _PDC */
+       arch_acpi_set_pdc_bits(buf);
+}
+
+static struct acpi_object_list *acpi_processor_alloc_pdc(void)
+{
+       struct acpi_object_list *obj_list;
+       union acpi_object *obj;
+       u32 *buf;
+
+       /* allocate and initialize pdc. It will be used later. */
+       obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
+       if (!obj_list) {
+               printk(KERN_ERR "Memory allocation error\n");
+               return NULL;
+       }
+
+       obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
+       if (!obj) {
+               printk(KERN_ERR "Memory allocation error\n");
+               kfree(obj_list);
+               return NULL;
+       }
+
+       buf = kmalloc(12, GFP_KERNEL);
+       if (!buf) {
+               printk(KERN_ERR "Memory allocation error\n");
+               kfree(obj);
+               kfree(obj_list);
+               return NULL;
+       }
+
+       acpi_set_pdc_bits(buf);
+
+       obj->type = ACPI_TYPE_BUFFER;
+       obj->buffer.length = 12;
+       obj->buffer.pointer = (u8 *) buf;
+       obj_list->count = 1;
+       obj_list->pointer = obj;
+
+       return obj_list;
+}
+
+/*
+ * _PDC is required for a BIOS-OS handshake for most of the newer
+ * ACPI processor features.
+ */
+static int
+acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
+{
+       acpi_status status = AE_OK;
+
+       if (idle_nomwait) {
+               /*
+                * If mwait is disabled for CPU C-states, the C2C3_FFH access
+                * mode will be disabled in the parameter of _PDC object.
+                * Of course C1_FFH access mode will also be disabled.
+                */
+               union acpi_object *obj;
+               u32 *buffer = NULL;
+
+               obj = pdc_in->pointer;
+               buffer = (u32 *)(obj->buffer.pointer);
+               buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
+
+       }
+       status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
+
+       if (ACPI_FAILURE(status))
+               ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+                   "Could not evaluate _PDC, using legacy perf. control.\n"));
+
+       return status;
+}
+
+void acpi_processor_set_pdc(acpi_handle handle)
+{
+       struct acpi_object_list *obj_list;
+
+       if (arch_has_acpi_pdc() == false)
+               return;
+
+       obj_list = acpi_processor_alloc_pdc();
+       if (!obj_list)
+               return;
+
+       acpi_processor_eval_pdc(handle, obj_list);
+
+       kfree(obj_list->pointer->buffer.pointer);
+       kfree(obj_list->pointer);
+       kfree(obj_list);
+}
+EXPORT_SYMBOL_GPL(acpi_processor_set_pdc);
+
+static acpi_status
+early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+       acpi_processor_set_pdc(handle);
+       return AE_OK;
+}
+
+void acpi_early_processor_set_pdc(void)
+{
+       /*
+        * Check whether the system is DMI table. If yes, OSPM
+        * should not use mwait for CPU-states.
+        */
+       dmi_check_system(processor_idle_dmi_table);
+
+       acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
+                           ACPI_UINT32_MAX,
+                           early_init_pdc, NULL, NULL, NULL);
+}
index 01e366d2b6fb14475e0b6074b886fd8b55877348..2cabadcc4d8c36806bc886080a6c0cae3d50dd04 100644 (file)
@@ -152,15 +152,59 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
        return 0;
 }
 
-int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
+#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE      0x80
+/*
+ * acpi_processor_ppc_ost: Notify firmware the _PPC evaluation status
+ * @handle: ACPI processor handle
+ * @status: the status code of _PPC evaluation
+ *     0: success. OSPM is now using the performance state specificed.
+ *     1: failure. OSPM has not changed the number of P-states in use
+ */
+static void acpi_processor_ppc_ost(acpi_handle handle, int status)
+{
+       union acpi_object params[2] = {
+               {.type = ACPI_TYPE_INTEGER,},
+               {.type = ACPI_TYPE_INTEGER,},
+       };
+       struct acpi_object_list arg_list = {2, params};
+       acpi_handle temp;
+
+       params[0].integer.value = ACPI_PROCESSOR_NOTIFY_PERFORMANCE;
+       params[1].integer.value =  status;
+
+       /* when there is no _OST , skip it */
+       if (ACPI_FAILURE(acpi_get_handle(handle, "_OST", &temp)))
+               return;
+
+       acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
+       return;
+}
+
+int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
 {
        int ret;
 
-       if (ignore_ppc)
+       if (ignore_ppc) {
+               /*
+                * Only when it is notification event, the _OST object
+                * will be evaluated. Otherwise it is skipped.
+                */
+               if (event_flag)
+                       acpi_processor_ppc_ost(pr->handle, 1);
                return 0;
+       }
 
        ret = acpi_processor_get_platform_limit(pr);
-
+       /*
+        * Only when it is notification event, the _OST object
+        * will be evaluated. Otherwise it is skipped.
+        */
+       if (event_flag) {
+               if (ret < 0)
+                       acpi_processor_ppc_ost(pr->handle, 1);
+               else
+                       acpi_processor_ppc_ost(pr->handle, 0);
+       }
        if (ret < 0)
                return (ret);
        else
index 5f2c379ab7bfba1903158f5c3f94cf37631a6c44..79d33d908b5a1d2dc586a6536107ffea393c467d 100644 (file)
@@ -80,6 +80,23 @@ static int acpi_sleep_prepare(u32 acpi_state)
 
 #ifdef CONFIG_ACPI_SLEEP
 static u32 acpi_target_sleep_state = ACPI_STATE_S0;
+/*
+ * According to the ACPI specification the BIOS should make sure that ACPI is
+ * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states.  Still,
+ * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
+ * on such systems during resume.  Unfortunately that doesn't help in
+ * particularly pathological cases in which SCI_EN has to be set directly on
+ * resume, although the specification states very clearly that this flag is
+ * owned by the hardware.  The set_sci_en_on_resume variable will be set in such
+ * cases.
+ */
+static bool set_sci_en_on_resume;
+
+void __init acpi_set_sci_en_on_resume(void)
+{
+       set_sci_en_on_resume = true;
+}
+
 /*
  * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
  * user to request that behavior by using the 'acpi_old_suspend_ordering'
@@ -170,18 +187,6 @@ static void acpi_pm_end(void)
 #endif /* CONFIG_ACPI_SLEEP */
 
 #ifdef CONFIG_SUSPEND
-/*
- * According to the ACPI specification the BIOS should make sure that ACPI is
- * enabled and SCI_EN bit is set on wake-up from S1 - S3 sleep states.  Still,
- * some BIOSes don't do that and therefore we use acpi_enable() to enable ACPI
- * on such systems during resume.  Unfortunately that doesn't help in
- * particularly pathological cases in which SCI_EN has to be set directly on
- * resume, although the specification states very clearly that this flag is
- * owned by the hardware.  The set_sci_en_on_resume variable will be set in such
- * cases.
- */
-static bool set_sci_en_on_resume;
-
 extern void do_suspend_lowlevel(void);
 
 static u32 acpi_suspend_states[] = {
index 65f67815902a2d18c0f1df09e48210af86002568..9073ada888354ac7cff6f0b8d38803495b5f763d 100644 (file)
@@ -1052,6 +1052,13 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
                                   acpi_device_bid(device));
                }
                seq_puts(seq, "\n");
+       } else {
+               seq_printf(seq, "passive (forced):");
+               if (tz->thermal_zone->forced_passive)
+                       seq_printf(seq, "        %i C\n",
+                                  tz->thermal_zone->forced_passive / 1000);
+               else
+                       seq_printf(seq, "<not set>\n");
        }
 
        for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
index 05dff631591c943918749aee95d86c474c781c62..72e76b4b6538f2da73ca4b9060e3cf12ce1808fc 100644 (file)
@@ -999,8 +999,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                sprintf(name, "acpi_video%d", count++);
                device->backlight = backlight_device_register(name,
                        NULL, device, &acpi_backlight_ops);
-               device->backlight->props.max_brightness = device->brightness->count-3;
                kfree(name);
+               if (IS_ERR(device->backlight))
+                       return;
+               device->backlight->props.max_brightness = device->brightness->count-3;
 
                result = sysfs_create_link(&device->backlight->dev.kobj,
                                           &device->dev->dev.kobj, "device");
@@ -1979,6 +1981,10 @@ acpi_video_switch_brightness(struct acpi_video_device *device, int event)
        unsigned long long level_current, level_next;
        int result = -EINVAL;
 
+       /* no warning message if acpi_backlight=vendor is used */
+       if (!acpi_video_backlight_support())
+               return 0;
+
        if (!device->brightness)
                goto out;
 
index 85844d053846fbed820ab8fb22a4db8b7cfc57ee..56c6374a39895702a7de1994e01422dee89d720f 100644 (file)
@@ -40,7 +40,6 @@ config ATA_VERBOSE_ERROR
 config ATA_ACPI
        bool "ATA ACPI Support"
        depends on ACPI && PCI
-       select ACPI_DOCK
        default y
        help
          This option adds support for ATA-related ACPI objects.
index 1683ebda900b788f0e0842d04da0f9576c8830ba..f4ea5a8c325bf5a618450b37ae229f603c30c8de 100644 (file)
@@ -3022,7 +3022,7 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd)
        case WRITE_16:
                return ata_scsi_rw_xlat;
 
-       case 0x93 /*WRITE_SAME_16*/:
+       case WRITE_SAME_16:
                return ata_scsi_write_same_xlat;
 
        case SYNCHRONIZE_CACHE:
index efa8773bef5a1add816a5a96a27553a005983248..741065c9da6700245a2ddb70f19908e3589f85c1 100644 (file)
@@ -2275,7 +2275,7 @@ void ata_sff_drain_fifo(struct ata_queued_cmd *qc)
        ap = qc->ap;
        /* Drain up to 64K of data before we give up this recovery method */
        for (count = 0; (ap->ops->sff_check_status(ap) & ATA_DRQ)
-                                               && count < 32768; count++)
+                                               && count < 65536; count += 2)
                ioread16(ap->ioaddr.data_addr);
 
        /* Can become DEBUG later */
index c4b47a3e5446decec4543b37c08c75b58cc378e8..02c81f12c702a7a02546a595937ae353c7a3290d 100644 (file)
@@ -1557,6 +1557,25 @@ static unsigned short atapi_io_port[] = {
        P_ATAPI_DMARQ,
        P_ATAPI_INTRQ,
        P_ATAPI_IORDY,
+       P_ATAPI_D0A,
+       P_ATAPI_D1A,
+       P_ATAPI_D2A,
+       P_ATAPI_D3A,
+       P_ATAPI_D4A,
+       P_ATAPI_D5A,
+       P_ATAPI_D6A,
+       P_ATAPI_D7A,
+       P_ATAPI_D8A,
+       P_ATAPI_D9A,
+       P_ATAPI_D10A,
+       P_ATAPI_D11A,
+       P_ATAPI_D12A,
+       P_ATAPI_D13A,
+       P_ATAPI_D14A,
+       P_ATAPI_D15A,
+       P_ATAPI_A0A,
+       P_ATAPI_A1A,
+       P_ATAPI_A2A,
        0
 };
 
index dadfc358ba1ce0912ba3883769da0bf9f63dfd2c..0efb1f58f2551f4c0d905f0298791ebb744d3425 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME "pata_cmd64x"
-#define DRV_VERSION "0.3.1"
+#define DRV_VERSION "0.2.5"
 
 /*
  * CMD64x specific registers definition.
@@ -219,7 +219,7 @@ static void cmd64x_set_dmamode(struct ata_port *ap, struct ata_device *adev)
                regU |= udma_data[adev->dma_mode - XFER_UDMA_0] << shift;
                /* Merge the control bits */
                regU |= 1 << adev->devno; /* UDMA on */
-               if (adev->dma_mode > 2) /* 15nS timing */
+               if (adev->dma_mode > XFER_UDMA_2) /* 15nS timing */
                        regU |= 4 << adev->devno;
        } else {
                regU &= ~ (1 << adev->devno);   /* UDMA off */
@@ -254,109 +254,17 @@ static void cmd648_bmdma_stop(struct ata_queued_cmd *qc)
 }
 
 /**
- *     cmd64x_bmdma_stop       -       DMA stop callback
+ *     cmd646r1_dma_stop       -       DMA stop callback
  *     @qc: Command in progress
  *
- *     Track the completion of live DMA commands and clear the
- *     host->private_data DMA tracking flag as we do.
+ *     Stub for now while investigating the r1 quirk in the old driver.
  */
 
-static void cmd64x_bmdma_stop(struct ata_queued_cmd *qc)
+static void cmd646r1_bmdma_stop(struct ata_queued_cmd *qc)
 {
-       struct ata_port *ap = qc->ap;
        ata_bmdma_stop(qc);
-       WARN_ON(ap->host->private_data != ap);
-       ap->host->private_data = NULL;
-}
-
-/**
- *     cmd64x_qc_defer         -       Defer logic for chip limits
- *     @qc: queued command
- *
- *     Decide whether we can issue the command. Called under the host lock.
- */
-
-static int cmd64x_qc_defer(struct ata_queued_cmd *qc)
-{
-       struct ata_host *host = qc->ap->host;
-       struct ata_port *alt = host->ports[1 ^ qc->ap->port_no];
-       int rc;
-       int dma = 0;
-
-       /* Apply the ATA rules first */
-       rc = ata_std_qc_defer(qc);
-       if (rc)
-               return rc;
-
-       if (qc->tf.protocol == ATAPI_PROT_DMA ||
-                       qc->tf.protocol == ATA_PROT_DMA)
-               dma = 1;
-
-       /* If the other port is not live then issue the command */
-       if (alt == NULL || !alt->qc_active) {
-               if (dma)
-                       host->private_data = qc->ap;
-               return 0;
-       }
-       /* If there is a live DMA command then wait */
-       if (host->private_data != NULL)
-               return  ATA_DEFER_PORT;
-       if (dma)
-               /* Cannot overlap our DMA command */
-               return ATA_DEFER_PORT;
-       return 0;
 }
 
-/**
- *     cmd64x_interrupt - ATA host interrupt handler
- *     @irq: irq line (unused)
- *     @dev_instance: pointer to our ata_host information structure
- *
- *     Our interrupt handler for PCI IDE devices.  Calls
- *     ata_sff_host_intr() for each port that is flagging an IRQ. We cannot
- *     use the defaults as we need to avoid touching status/altstatus during
- *     a DMA.
- *
- *     LOCKING:
- *     Obtains host lock during operation.
- *
- *     RETURNS:
- *     IRQ_NONE or IRQ_HANDLED.
- */
-irqreturn_t cmd64x_interrupt(int irq, void *dev_instance)
-{
-       struct ata_host *host = dev_instance;
-       struct pci_dev *pdev = to_pci_dev(host->dev);
-       unsigned int i;
-       unsigned int handled = 0;
-       unsigned long flags;
-       static const u8 irq_reg[2] = { CFR, ARTTIM23 };
-       static const u8 irq_mask[2] = { 1 << 2, 1 << 4 };
-
-       /* TODO: make _irqsave conditional on x86 PCI IDE legacy mode */
-       spin_lock_irqsave(&host->lock, flags);
-
-       for (i = 0; i < host->n_ports; i++) {
-               struct ata_port *ap;
-               u8 reg;
-
-               pci_read_config_byte(pdev, irq_reg[i], &reg);
-               ap = host->ports[i];
-               if (ap && (reg & irq_mask[i]) &&
-                   !(ap->flags & ATA_FLAG_DISABLED)) {
-                       struct ata_queued_cmd *qc;
-
-                       qc = ata_qc_from_tag(ap, ap->link.active_tag);
-                       if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
-                           (qc->flags & ATA_QCFLAG_ACTIVE))
-                               handled |= ata_sff_host_intr(ap, qc);
-               }
-       }
-
-       spin_unlock_irqrestore(&host->lock, flags);
-
-       return IRQ_RETVAL(handled);
-}
 static struct scsi_host_template cmd64x_sht = {
        ATA_BMDMA_SHT(DRV_NAME),
 };
@@ -365,8 +273,6 @@ static const struct ata_port_operations cmd64x_base_ops = {
        .inherits       = &ata_bmdma_port_ops,
        .set_piomode    = cmd64x_set_piomode,
        .set_dmamode    = cmd64x_set_dmamode,
-       .bmdma_stop     = cmd64x_bmdma_stop,
-       .qc_defer       = cmd64x_qc_defer,
 };
 
 static struct ata_port_operations cmd64x_port_ops = {
@@ -376,6 +282,7 @@ static struct ata_port_operations cmd64x_port_ops = {
 
 static struct ata_port_operations cmd646r1_port_ops = {
        .inherits       = &cmd64x_base_ops,
+       .bmdma_stop     = cmd646r1_bmdma_stop,
        .cable_detect   = ata_cable_40wire,
 };
 
@@ -383,7 +290,6 @@ static struct ata_port_operations cmd648_port_ops = {
        .inherits       = &cmd64x_base_ops,
        .bmdma_stop     = cmd648_bmdma_stop,
        .cable_detect   = cmd648_cable_detect,
-       .qc_defer       = ata_std_qc_defer
 };
 
 static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -432,7 +338,6 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL };
        u8 mrdmode;
        int rc;
-       struct ata_host *host;
 
        rc = pcim_enable_device(pdev);
        if (rc)
@@ -450,25 +355,20 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
                        ppi[0] = &cmd_info[3];
        }
 
-
        pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
        pci_read_config_byte(pdev, MRDMODE, &mrdmode);
        mrdmode &= ~ 0x30;      /* IRQ set up */
        mrdmode |= 0x02;        /* Memory read line enable */
        pci_write_config_byte(pdev, MRDMODE, mrdmode);
 
+       /* Force PIO 0 here.. */
+
        /* PPC specific fixup copied from old driver */
 #ifdef CONFIG_PPC
        pci_write_config_byte(pdev, UDIDETCR0, 0xF0);
 #endif
-       rc = ata_pci_sff_prepare_host(pdev, ppi, &host);
-       if (rc)
-               return rc;
-       /* We use this pointer to track the AP which has DMA running */
-       host->private_data = NULL;
 
-       pci_set_master(pdev);
-       return ata_pci_sff_activate_host(host, cmd64x_interrupt, &cmd64x_sht);
+       return ata_pci_sff_init_one(pdev, ppi, &cmd64x_sht, NULL);
 }
 
 #ifdef CONFIG_PM
index 9a09a1b11ca5575a9415317977a64f609cacc0da..dd26bc73bd9aaca7b2f7839c0f71da3d7f87078d 100644 (file)
@@ -8,7 +8,7 @@
  * Copyright (C) 1999-2003             Andre Hedrick <andre@linux-ide.org>
  * Portions Copyright (C) 2001         Sun Microsystems, Inc.
  * Portions Copyright (C) 2003         Red Hat Inc
- * Portions Copyright (C) 2005-2007    MontaVista Software, Inc.
+ * Portions Copyright (C) 2005-2009    MontaVista Software, Inc.
  *
  *
  * TODO
@@ -25,7 +25,7 @@
 #include <linux/libata.h>
 
 #define DRV_NAME       "pata_hpt3x2n"
-#define DRV_VERSION    "0.3.7"
+#define DRV_VERSION    "0.3.8"
 
 enum {
        HPT_PCI_FAST    =       (1 << 31),
@@ -264,7 +264,7 @@ static void hpt3x2n_bmdma_stop(struct ata_queued_cmd *qc)
 
 static void hpt3x2n_set_clock(struct ata_port *ap, int source)
 {
-       void __iomem *bmdma = ap->ioaddr.bmdma_addr;
+       void __iomem *bmdma = ap->ioaddr.bmdma_addr - ap->port_no * 8;
 
        /* Tristate the bus */
        iowrite8(0x80, bmdma+0x73);
@@ -274,9 +274,9 @@ static void hpt3x2n_set_clock(struct ata_port *ap, int source)
        iowrite8(source, bmdma+0x7B);
        iowrite8(0xC0, bmdma+0x79);
 
-       /* Reset state machines */
-       iowrite8(0x37, bmdma+0x70);
-       iowrite8(0x37, bmdma+0x74);
+       /* Reset state machines, avoid enabling the disabled channels */
+       iowrite8(ioread8(bmdma+0x70) | 0x32, bmdma+0x70);
+       iowrite8(ioread8(bmdma+0x74) | 0x32, bmdma+0x74);
 
        /* Complete reset */
        iowrite8(0x00, bmdma+0x79);
@@ -286,21 +286,10 @@ static void hpt3x2n_set_clock(struct ata_port *ap, int source)
        iowrite8(0x00, bmdma+0x77);
 }
 
-/* Check if our partner interface is busy */
-
-static int hpt3x2n_pair_idle(struct ata_port *ap)
-{
-       struct ata_host *host = ap->host;
-       struct ata_port *pair = host->ports[ap->port_no ^ 1];
-
-       if (pair->hsm_task_state == HSM_ST_IDLE)
-               return 1;
-       return 0;
-}
-
 static int hpt3x2n_use_dpll(struct ata_port *ap, int writing)
 {
        long flags = (long)ap->host->private_data;
+
        /* See if we should use the DPLL */
        if (writing)
                return USE_DPLL;        /* Needed for write */
@@ -309,20 +298,35 @@ static int hpt3x2n_use_dpll(struct ata_port *ap, int writing)
        return 0;
 }
 
+static int hpt3x2n_qc_defer(struct ata_queued_cmd *qc)
+{
+       struct ata_port *ap = qc->ap;
+       struct ata_port *alt = ap->host->ports[ap->port_no ^ 1];
+       int rc, flags = (long)ap->host->private_data;
+       int dpll = hpt3x2n_use_dpll(ap, qc->tf.flags & ATA_TFLAG_WRITE);
+
+       /* First apply the usual rules */
+       rc = ata_std_qc_defer(qc);
+       if (rc != 0)
+               return rc;
+
+       if ((flags & USE_DPLL) != dpll && alt->qc_active)
+               return ATA_DEFER_PORT;
+       return 0;
+}
+
 static unsigned int hpt3x2n_qc_issue(struct ata_queued_cmd *qc)
 {
-       struct ata_taskfile *tf = &qc->tf;
        struct ata_port *ap = qc->ap;
        int flags = (long)ap->host->private_data;
+       int dpll = hpt3x2n_use_dpll(ap, qc->tf.flags & ATA_TFLAG_WRITE);
 
-       if (hpt3x2n_pair_idle(ap)) {
-               int dpll = hpt3x2n_use_dpll(ap, (tf->flags & ATA_TFLAG_WRITE));
-               if ((flags & USE_DPLL) != dpll) {
-                       if (dpll == 1)
-                               hpt3x2n_set_clock(ap, 0x21);
-                       else
-                               hpt3x2n_set_clock(ap, 0x23);
-               }
+       if ((flags & USE_DPLL) != dpll) {
+               flags &= ~USE_DPLL;
+               flags |= dpll;
+               ap->host->private_data = (void *)(long)flags;
+
+               hpt3x2n_set_clock(ap, dpll ? 0x21 : 0x23);
        }
        return ata_sff_qc_issue(qc);
 }
@@ -339,6 +343,8 @@ static struct ata_port_operations hpt3x2n_port_ops = {
        .inherits       = &ata_bmdma_port_ops,
 
        .bmdma_stop     = hpt3x2n_bmdma_stop,
+
+       .qc_defer       = hpt3x2n_qc_defer,
        .qc_issue       = hpt3x2n_qc_issue,
 
        .cable_detect   = hpt3x2n_cable_detect,
@@ -454,7 +460,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
        unsigned int f_low, f_high;
        int adjust;
        unsigned long iobase = pci_resource_start(dev, 4);
-       void *hpriv = NULL;
+       void *hpriv = (void *)USE_DPLL;
        int rc;
 
        rc = pcim_enable_device(dev);
@@ -539,7 +545,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
        /* Set our private data up. We only need a few flags so we use
           it directly */
        if (pci_mhz > 60) {
-               hpriv = (void *)PCI66;
+               hpriv = (void *)(PCI66 | USE_DPLL);
                /*
                 * On  HPT371N, if ATA clock is 66 MHz we must set bit 2 in
                 * the MISC. register to stretch the UltraDMA Tss timing.
index d6f69561dc86f78bea2d3d6fc017c95a74281805..37ef416c12428e811c777b14a38248de7ab6a429 100644 (file)
@@ -853,7 +853,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
                        return -EINVAL;
 
                cs1 = devm_ioremap_nocache(&pdev->dev, res_cs1->start,
-                                          res_cs0->end - res_cs1->start + 1);
+                                          resource_size(res_cs1));
 
                if (!cs1)
                        return -ENOMEM;
index a8a7be0d06ffcf895f39b96fc966f68ae18b6bf6..df8ee325d3ca3869c1fb6609a3432d590178d8c7 100644 (file)
@@ -59,6 +59,7 @@
 #include <linux/dmapool.h>
 #include <linux/dma-mapping.h>
 #include <linux/device.h>
+#include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/ata_platform.h>
 #include <linux/mbus.h>
@@ -538,6 +539,7 @@ struct mv_port_signal {
 
 struct mv_host_priv {
        u32                     hp_flags;
+       unsigned int            board_idx;
        u32                     main_irq_mask;
        struct mv_port_signal   signal[8];
        const struct mv_hw_ops  *ops;
@@ -548,6 +550,10 @@ struct mv_host_priv {
        u32                     irq_cause_offset;
        u32                     irq_mask_offset;
        u32                     unmask_all_irqs;
+
+#if defined(CONFIG_HAVE_CLK)
+       struct clk              *clk;
+#endif
        /*
         * These consistent DMA memory pools give us guaranteed
         * alignment for hardware-accessed data structures,
@@ -2775,7 +2781,7 @@ static void mv_port_intr(struct ata_port *ap, u32 port_cause)
        struct mv_port_priv *pp;
        int edma_was_enabled;
 
-       if (!ap || (ap->flags & ATA_FLAG_DISABLED)) {
+       if (ap->flags & ATA_FLAG_DISABLED) {
                mv_unexpected_intr(ap, 0);
                return;
        }
@@ -3393,7 +3399,7 @@ static void mv_soc_reset_hc_port(struct mv_host_priv *hpriv,
        ZERO(0x024);            /* respq outp */
        ZERO(0x020);            /* respq inp */
        ZERO(0x02c);            /* test control */
-       writel(0xbc, port_mmio + EDMA_IORDY_TMOUT);
+       writel(0x800, port_mmio + EDMA_IORDY_TMOUT);
 }
 
 #undef ZERO
@@ -3854,7 +3860,6 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
 /**
  *      mv_init_host - Perform some early initialization of the host.
  *     @host: ATA host to initialize
- *      @board_idx: controller index
  *
  *      If possible, do an early global reset of the host.  Then do
  *      our port init and clear/unmask all/relevant host interrupts.
@@ -3862,13 +3867,13 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
  *      LOCKING:
  *      Inherited from caller.
  */
-static int mv_init_host(struct ata_host *host, unsigned int board_idx)
+static int mv_init_host(struct ata_host *host)
 {
        int rc = 0, n_hc, port, hc;
        struct mv_host_priv *hpriv = host->private_data;
        void __iomem *mmio = hpriv->base;
 
-       rc = mv_chip_id(host, board_idx);
+       rc = mv_chip_id(host, hpriv->board_idx);
        if (rc)
                goto done;
 
@@ -3905,14 +3910,6 @@ static int mv_init_host(struct ata_host *host, unsigned int board_idx)
                void __iomem *port_mmio = mv_port_base(mmio, port);
 
                mv_port_init(&ap->ioaddr, port_mmio);
-
-#ifdef CONFIG_PCI
-               if (!IS_SOC(hpriv)) {
-                       unsigned int offset = port_mmio - mmio;
-                       ata_port_pbar_desc(ap, MV_PRIMARY_BAR, -1, "mmio");
-                       ata_port_pbar_desc(ap, MV_PRIMARY_BAR, offset, "port");
-               }
-#endif
        }
 
        for (hc = 0; hc < n_hc; hc++) {
@@ -4035,12 +4032,21 @@ static int mv_platform_probe(struct platform_device *pdev)
                return -ENOMEM;
        host->private_data = hpriv;
        hpriv->n_ports = n_ports;
+       hpriv->board_idx = chip_soc;
 
        host->iomap = NULL;
        hpriv->base = devm_ioremap(&pdev->dev, res->start,
                                   resource_size(res));
        hpriv->base -= SATAHC0_REG_BASE;
 
+#if defined(CONFIG_HAVE_CLK)
+       hpriv->clk = clk_get(&pdev->dev, NULL);
+       if (IS_ERR(hpriv->clk))
+               dev_notice(&pdev->dev, "cannot get clkdev\n");
+       else
+               clk_enable(hpriv->clk);
+#endif
+
        /*
         * (Re-)program MBUS remapping windows if we are asked to.
         */
@@ -4049,12 +4055,12 @@ static int mv_platform_probe(struct platform_device *pdev)
 
        rc = mv_create_dma_pools(hpriv, &pdev->dev);
        if (rc)
-               return rc;
+               goto err;
 
        /* initialize adapter */
-       rc = mv_init_host(host, chip_soc);
+       rc = mv_init_host(host);
        if (rc)
-               return rc;
+               goto err;
 
        dev_printk(KERN_INFO, &pdev->dev,
                   "slots %u ports %d\n", (unsigned)MV_MAX_Q_DEPTH,
@@ -4062,6 +4068,15 @@ static int mv_platform_probe(struct platform_device *pdev)
 
        return ata_host_activate(host, platform_get_irq(pdev, 0), mv_interrupt,
                                 IRQF_SHARED, &mv6_sht);
+err:
+#if defined(CONFIG_HAVE_CLK)
+       if (!IS_ERR(hpriv->clk)) {
+               clk_disable(hpriv->clk);
+               clk_put(hpriv->clk);
+       }
+#endif
+
+       return rc;
 }
 
 /*
@@ -4076,14 +4091,66 @@ static int __devexit mv_platform_remove(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct ata_host *host = dev_get_drvdata(dev);
-
+#if defined(CONFIG_HAVE_CLK)
+       struct mv_host_priv *hpriv = host->private_data;
+#endif
        ata_host_detach(host);
+
+#if defined(CONFIG_HAVE_CLK)
+       if (!IS_ERR(hpriv->clk)) {
+               clk_disable(hpriv->clk);
+               clk_put(hpriv->clk);
+       }
+#endif
        return 0;
 }
 
+#ifdef CONFIG_PM
+static int mv_platform_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       if (host)
+               return ata_host_suspend(host, state);
+       else
+               return 0;
+}
+
+static int mv_platform_resume(struct platform_device *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       int ret;
+
+       if (host) {
+               struct mv_host_priv *hpriv = host->private_data;
+               const struct mv_sata_platform_data *mv_platform_data = \
+                       pdev->dev.platform_data;
+               /*
+                * (Re-)program MBUS remapping windows if we are asked to.
+                */
+               if (mv_platform_data->dram != NULL)
+                       mv_conf_mbus_windows(hpriv, mv_platform_data->dram);
+
+               /* initialize adapter */
+               ret = mv_init_host(host);
+               if (ret) {
+                       printk(KERN_ERR DRV_NAME ": Error during HW init\n");
+                       return ret;
+               }
+               ata_host_resume(host);
+       }
+
+       return 0;
+}
+#else
+#define mv_platform_suspend NULL
+#define mv_platform_resume NULL
+#endif
+
 static struct platform_driver mv_platform_driver = {
        .probe                  = mv_platform_probe,
        .remove                 = __devexit_p(mv_platform_remove),
+       .suspend                = mv_platform_suspend,
+       .resume                 = mv_platform_resume,
        .driver                 = {
                                   .name = DRV_NAME,
                                   .owner = THIS_MODULE,
@@ -4094,6 +4161,9 @@ static struct platform_driver mv_platform_driver = {
 #ifdef CONFIG_PCI
 static int mv_pci_init_one(struct pci_dev *pdev,
                           const struct pci_device_id *ent);
+#ifdef CONFIG_PM
+static int mv_pci_device_resume(struct pci_dev *pdev);
+#endif
 
 
 static struct pci_driver mv_pci_driver = {
@@ -4101,6 +4171,11 @@ static struct pci_driver mv_pci_driver = {
        .id_table               = mv_pci_tbl,
        .probe                  = mv_pci_init_one,
        .remove                 = ata_pci_remove_one,
+#ifdef CONFIG_PM
+       .suspend                = ata_pci_device_suspend,
+       .resume                 = mv_pci_device_resume,
+#endif
+
 };
 
 /* move to PCI layer or libata core? */
@@ -4194,7 +4269,7 @@ static int mv_pci_init_one(struct pci_dev *pdev,
        const struct ata_port_info *ppi[] = { &mv_port_info[board_idx], NULL };
        struct ata_host *host;
        struct mv_host_priv *hpriv;
-       int n_ports, rc;
+       int n_ports, port, rc;
 
        if (!printed_version++)
                dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
@@ -4208,6 +4283,7 @@ static int mv_pci_init_one(struct pci_dev *pdev,
                return -ENOMEM;
        host->private_data = hpriv;
        hpriv->n_ports = n_ports;
+       hpriv->board_idx = board_idx;
 
        /* acquire resources */
        rc = pcim_enable_device(pdev);
@@ -4230,8 +4306,17 @@ static int mv_pci_init_one(struct pci_dev *pdev,
        if (rc)
                return rc;
 
+       for (port = 0; port < host->n_ports; port++) {
+               struct ata_port *ap = host->ports[port];
+               void __iomem *port_mmio = mv_port_base(hpriv->base, port);
+               unsigned int offset = port_mmio - hpriv->base;
+
+               ata_port_pbar_desc(ap, MV_PRIMARY_BAR, -1, "mmio");
+               ata_port_pbar_desc(ap, MV_PRIMARY_BAR, offset, "port");
+       }
+
        /* initialize adapter */
-       rc = mv_init_host(host, board_idx);
+       rc = mv_init_host(host);
        if (rc)
                return rc;
 
@@ -4247,6 +4332,27 @@ static int mv_pci_init_one(struct pci_dev *pdev,
        return ata_host_activate(host, pdev->irq, mv_interrupt, IRQF_SHARED,
                                 IS_GEN_I(hpriv) ? &mv5_sht : &mv6_sht);
 }
+
+#ifdef CONFIG_PM
+static int mv_pci_device_resume(struct pci_dev *pdev)
+{
+       struct ata_host *host = dev_get_drvdata(&pdev->dev);
+       int rc;
+
+       rc = ata_pci_device_do_resume(pdev);
+       if (rc)
+               return rc;
+
+       /* initialize adapter */
+       rc = mv_init_host(host);
+       if (rc)
+               return rc;
+
+       ata_host_resume(host);
+
+       return 0;
+}
+#endif
 #endif
 
 static int mv_platform_probe(struct platform_device *pdev);
index f734b345ac71258b59ab1369b088ffe3e68cceb0..25a4c86f839b29a5436f1de6cf2829c543296435 100644 (file)
@@ -557,7 +557,7 @@ static int ia_cbr_setup (IADEV *dev, struct atm_vcc *vcc) {
           memcpy((caddr_t)&cbrVC,(caddr_t)TstSchedTbl,sizeof(cbrVC));
        } /* while */
        // Move this VCI number into this location of the CBR Sched table.
-       memcpy((caddr_t)TstSchedTbl, (caddr_t)&vcIndex,sizeof(TstSchedTbl));
+       memcpy((caddr_t)TstSchedTbl, (caddr_t)&vcIndex, sizeof(*TstSchedTbl));
        dev->CbrRemEntries--;
        toBeAssigned--;
    } /* while */ 
index 63c143e54a5783656d9f0208acd3c9c4166ec4e2..c0c5a43d9fb3e6cadbd962b7272766be472741a6 100644 (file)
@@ -703,9 +703,9 @@ int bus_add_driver(struct device_driver *drv)
        return 0;
 
 out_unregister:
+       kobject_put(&priv->kobj);
        kfree(drv->p);
        drv->p = NULL;
-       kobject_put(&priv->kobj);
 out_put_bus:
        bus_put(bus);
        return error;
index f1290cbd1350ebaa8d28e2c015cb403728374862..282025770429b08f329373c1a286637c6a210f45 100644 (file)
@@ -446,7 +446,8 @@ struct kset *devices_kset;
  * @dev: device.
  * @attr: device attribute descriptor.
  */
-int device_create_file(struct device *dev, struct device_attribute *attr)
+int device_create_file(struct device *dev,
+                      const struct device_attribute *attr)
 {
        int error = 0;
        if (dev)
@@ -459,7 +460,8 @@ int device_create_file(struct device *dev, struct device_attribute *attr)
  * @dev: device.
  * @attr: device attribute descriptor.
  */
-void device_remove_file(struct device *dev, struct device_attribute *attr)
+void device_remove_file(struct device *dev,
+                       const struct device_attribute *attr)
 {
        if (dev)
                sysfs_remove_file(&dev->kobj, &attr->attr);
@@ -470,7 +472,8 @@ void device_remove_file(struct device *dev, struct device_attribute *attr)
  * @dev: device.
  * @attr: device binary attribute descriptor.
  */
-int device_create_bin_file(struct device *dev, struct bin_attribute *attr)
+int device_create_bin_file(struct device *dev,
+                          const struct bin_attribute *attr)
 {
        int error = -EINVAL;
        if (dev)
@@ -484,7 +487,8 @@ EXPORT_SYMBOL_GPL(device_create_bin_file);
  * @dev: device.
  * @attr: device binary attribute descriptor.
  */
-void device_remove_bin_file(struct device *dev, struct bin_attribute *attr)
+void device_remove_bin_file(struct device *dev,
+                           const struct bin_attribute *attr)
 {
        if (dev)
                sysfs_remove_bin_file(&dev->kobj, attr);
@@ -905,8 +909,10 @@ int device_add(struct device *dev)
                dev->init_name = NULL;
        }
 
-       if (!dev_name(dev))
+       if (!dev_name(dev)) {
+               error = -EINVAL;
                goto name_error;
+       }
 
        pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
 
index 50375bb8e51d921582aa2685bdfe551acdc60ca2..090dd4851301a802aed5b588f9dd7b49f8755158 100644 (file)
@@ -32,7 +32,7 @@ static int dev_mount = 1;
 static int dev_mount;
 #endif
 
-static rwlock_t dirlock;
+static DEFINE_MUTEX(dirlock);
 
 static int __init mount_param(char *str)
 {
@@ -93,7 +93,7 @@ static int create_path(const char *nodepath)
 {
        int err;
 
-       read_lock(&dirlock);
+       mutex_lock(&dirlock);
        err = dev_mkdir(nodepath, 0755);
        if (err == -ENOENT) {
                char *path;
@@ -101,8 +101,10 @@ static int create_path(const char *nodepath)
 
                /* parent directories do not exist, create them */
                path = kstrdup(nodepath, GFP_KERNEL);
-               if (!path)
-                       return -ENOMEM;
+               if (!path) {
+                       err = -ENOMEM;
+                       goto out;
+               }
                s = path;
                for (;;) {
                        s = strchr(s, '/');
@@ -117,7 +119,8 @@ static int create_path(const char *nodepath)
                }
                kfree(path);
        }
-       read_unlock(&dirlock);
+out:
+       mutex_unlock(&dirlock);
        return err;
 }
 
@@ -229,7 +232,7 @@ static int delete_path(const char *nodepath)
        if (!path)
                return -ENOMEM;
 
-       write_lock(&dirlock);
+       mutex_lock(&dirlock);
        for (;;) {
                char *base;
 
@@ -241,7 +244,7 @@ static int delete_path(const char *nodepath)
                if (err)
                        break;
        }
-       write_unlock(&dirlock);
+       mutex_unlock(&dirlock);
 
        kfree(path);
        return err;
@@ -352,8 +355,6 @@ int __init devtmpfs_init(void)
        int err;
        struct vfsmount *mnt;
 
-       rwlock_init(&dirlock);
-
        err = register_filesystem(&dev_fs_type);
        if (err) {
                printk(KERN_ERR "devtmpfs: unable to register devtmpfs "
index f367885a76460cea4097372a035408560206c7d5..90c9fff09eadff6fbbd2e554e39db3653867ea9c 100644 (file)
@@ -98,7 +98,7 @@ EXPORT_SYMBOL_GPL(driver_find_device);
  * @attr: driver attribute descriptor.
  */
 int driver_create_file(struct device_driver *drv,
-                      struct driver_attribute *attr)
+                      const struct driver_attribute *attr)
 {
        int error;
        if (drv)
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(driver_create_file);
  * @attr: driver attribute descriptor.
  */
 void driver_remove_file(struct device_driver *drv,
-                       struct driver_attribute *attr)
+                       const struct driver_attribute *attr)
 {
        if (drv)
                sysfs_remove_file(&drv->p->kobj, &attr->attr);
index 989429cfed88a7395f38a4d1dd44d8d8ff8745ac..d7d77d4a402cf14ca90e1a034aada06c3351bc3b 100644 (file)
@@ -63,6 +63,20 @@ void unregister_memory_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL(unregister_memory_notifier);
 
+static ATOMIC_NOTIFIER_HEAD(memory_isolate_chain);
+
+int register_memory_isolate_notifier(struct notifier_block *nb)
+{
+       return atomic_notifier_chain_register(&memory_isolate_chain, nb);
+}
+EXPORT_SYMBOL(register_memory_isolate_notifier);
+
+void unregister_memory_isolate_notifier(struct notifier_block *nb)
+{
+       atomic_notifier_chain_unregister(&memory_isolate_chain, nb);
+}
+EXPORT_SYMBOL(unregister_memory_isolate_notifier);
+
 /*
  * register_memory - Setup a sysfs device for a memory block
  */
@@ -157,6 +171,11 @@ int memory_notify(unsigned long val, void *v)
        return blocking_notifier_call_chain(&memory_chain, val, v);
 }
 
+int memory_isolate_notify(unsigned long val, void *v)
+{
+       return atomic_notifier_call_chain(&memory_isolate_chain, val, v);
+}
+
 /*
  * MEMORY_HOTPLUG depends on SPARSEMEM in mm/Kconfig, so it is
  * OK to have direct references to sparsemem variables in here.
@@ -341,6 +360,64 @@ static inline int memory_probe_init(void)
 }
 #endif
 
+#ifdef CONFIG_MEMORY_FAILURE
+/*
+ * Support for offlining pages of memory
+ */
+
+/* Soft offline a page */
+static ssize_t
+store_soft_offline_page(struct class *class, const char *buf, size_t count)
+{
+       int ret;
+       u64 pfn;
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (strict_strtoull(buf, 0, &pfn) < 0)
+               return -EINVAL;
+       pfn >>= PAGE_SHIFT;
+       if (!pfn_valid(pfn))
+               return -ENXIO;
+       ret = soft_offline_page(pfn_to_page(pfn), 0);
+       return ret == 0 ? count : ret;
+}
+
+/* Forcibly offline a page, including killing processes. */
+static ssize_t
+store_hard_offline_page(struct class *class, const char *buf, size_t count)
+{
+       int ret;
+       u64 pfn;
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+       if (strict_strtoull(buf, 0, &pfn) < 0)
+               return -EINVAL;
+       pfn >>= PAGE_SHIFT;
+       ret = __memory_failure(pfn, 0, 0);
+       return ret ? ret : count;
+}
+
+static CLASS_ATTR(soft_offline_page, 0644, NULL, store_soft_offline_page);
+static CLASS_ATTR(hard_offline_page, 0644, NULL, store_hard_offline_page);
+
+static __init int memory_fail_init(void)
+{
+       int err;
+
+       err = sysfs_create_file(&memory_sysdev_class.kset.kobj,
+                               &class_attr_soft_offline_page.attr);
+       if (!err)
+               err = sysfs_create_file(&memory_sysdev_class.kset.kobj,
+                               &class_attr_hard_offline_page.attr);
+       return err;
+}
+#else
+static inline int memory_fail_init(void)
+{
+       return 0;
+}
+#endif
+
 /*
  * Note that phys_device is optional.  It is here to allow for
  * differentiation between which *physical* devices each
@@ -471,6 +548,9 @@ int __init memory_dev_init(void)
        }
 
        err = memory_probe_init();
+       if (!ret)
+               ret = err;
+       err = memory_fail_init();
        if (!ret)
                ret = err;
        err = block_size_init();
index 1fe5536d404f134e53b61324f9350c11080337dc..70122791683d5259ed4afbcc145aaad73aa59cd3 100644 (file)
@@ -173,6 +173,47 @@ static ssize_t node_read_distance(struct sys_device * dev,
 }
 static SYSDEV_ATTR(distance, S_IRUGO, node_read_distance, NULL);
 
+#ifdef CONFIG_HUGETLBFS
+/*
+ * hugetlbfs per node attributes registration interface:
+ * When/if hugetlb[fs] subsystem initializes [sometime after this module],
+ * it will register its per node attributes for all online nodes with
+ * memory.  It will also call register_hugetlbfs_with_node(), below, to
+ * register its attribute registration functions with this node driver.
+ * Once these hooks have been initialized, the node driver will call into
+ * the hugetlb module to [un]register attributes for hot-plugged nodes.
+ */
+static node_registration_func_t __hugetlb_register_node;
+static node_registration_func_t __hugetlb_unregister_node;
+
+static inline bool hugetlb_register_node(struct node *node)
+{
+       if (__hugetlb_register_node &&
+                       node_state(node->sysdev.id, N_HIGH_MEMORY)) {
+               __hugetlb_register_node(node);
+               return true;
+       }
+       return false;
+}
+
+static inline void hugetlb_unregister_node(struct node *node)
+{
+       if (__hugetlb_unregister_node)
+               __hugetlb_unregister_node(node);
+}
+
+void register_hugetlbfs_with_node(node_registration_func_t doregister,
+                                 node_registration_func_t unregister)
+{
+       __hugetlb_register_node   = doregister;
+       __hugetlb_unregister_node = unregister;
+}
+#else
+static inline void hugetlb_register_node(struct node *node) {}
+
+static inline void hugetlb_unregister_node(struct node *node) {}
+#endif
+
 
 /*
  * register_node - Setup a sysfs device for a node.
@@ -196,6 +237,8 @@ int register_node(struct node *node, int num, struct node *parent)
                sysdev_create_file(&node->sysdev, &attr_distance);
 
                scan_unevictable_register_node(node);
+
+               hugetlb_register_node(node);
        }
        return error;
 }
@@ -216,6 +259,7 @@ void unregister_node(struct node *node)
        sysdev_remove_file(&node->sysdev, &attr_distance);
 
        scan_unevictable_unregister_node(node);
+       hugetlb_unregister_node(node);          /* no-op, if memoryless node */
 
        sysdev_unregister(&node->sysdev);
 }
@@ -227,26 +271,43 @@ struct node node_devices[MAX_NUMNODES];
  */
 int register_cpu_under_node(unsigned int cpu, unsigned int nid)
 {
-       if (node_online(nid)) {
-               struct sys_device *obj = get_cpu_sysdev(cpu);
-               if (!obj)
-                       return 0;
-               return sysfs_create_link(&node_devices[nid].sysdev.kobj,
-                                        &obj->kobj,
-                                        kobject_name(&obj->kobj));
-        }
+       int ret;
+       struct sys_device *obj;
 
-       return 0;
+       if (!node_online(nid))
+               return 0;
+
+       obj = get_cpu_sysdev(cpu);
+       if (!obj)
+               return 0;
+
+       ret = sysfs_create_link(&node_devices[nid].sysdev.kobj,
+                               &obj->kobj,
+                               kobject_name(&obj->kobj));
+       if (ret)
+               return ret;
+
+       return sysfs_create_link(&obj->kobj,
+                                &node_devices[nid].sysdev.kobj,
+                                kobject_name(&node_devices[nid].sysdev.kobj));
 }
 
 int unregister_cpu_under_node(unsigned int cpu, unsigned int nid)
 {
-       if (node_online(nid)) {
-               struct sys_device *obj = get_cpu_sysdev(cpu);
-               if (obj)
-                       sysfs_remove_link(&node_devices[nid].sysdev.kobj,
-                                        kobject_name(&obj->kobj));
-       }
+       struct sys_device *obj;
+
+       if (!node_online(nid))
+               return 0;
+
+       obj = get_cpu_sysdev(cpu);
+       if (!obj)
+               return 0;
+
+       sysfs_remove_link(&node_devices[nid].sysdev.kobj,
+                         kobject_name(&obj->kobj));
+       sysfs_remove_link(&obj->kobj,
+                         kobject_name(&node_devices[nid].sysdev.kobj));
+
        return 0;
 }
 
@@ -268,6 +329,7 @@ static int get_nid_for_pfn(unsigned long pfn)
 /* register memory section under specified node if it spans that node */
 int register_mem_sect_under_node(struct memory_block *mem_blk, int nid)
 {
+       int ret;
        unsigned long pfn, sect_start_pfn, sect_end_pfn;
 
        if (!mem_blk)
@@ -284,9 +346,15 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, int nid)
                        continue;
                if (page_nid != nid)
                        continue;
-               return sysfs_create_link_nowarn(&node_devices[nid].sysdev.kobj,
+               ret = sysfs_create_link_nowarn(&node_devices[nid].sysdev.kobj,
                                        &mem_blk->sysdev.kobj,
                                        kobject_name(&mem_blk->sysdev.kobj));
+               if (ret)
+                       return ret;
+
+               return sysfs_create_link_nowarn(&mem_blk->sysdev.kobj,
+                               &node_devices[nid].sysdev.kobj,
+                               kobject_name(&node_devices[nid].sysdev.kobj));
        }
        /* mem section does not span the specified node */
        return 0;
@@ -295,12 +363,16 @@ int register_mem_sect_under_node(struct memory_block *mem_blk, int nid)
 /* unregister memory section under all nodes that it spans */
 int unregister_mem_sect_under_nodes(struct memory_block *mem_blk)
 {
-       nodemask_t unlinked_nodes;
+       NODEMASK_ALLOC(nodemask_t, unlinked_nodes, GFP_KERNEL);
        unsigned long pfn, sect_start_pfn, sect_end_pfn;
 
-       if (!mem_blk)
+       if (!mem_blk) {
+               NODEMASK_FREE(unlinked_nodes);
                return -EFAULT;
-       nodes_clear(unlinked_nodes);
+       }
+       if (!unlinked_nodes)
+               return -ENOMEM;
+       nodes_clear(*unlinked_nodes);
        sect_start_pfn = section_nr_to_pfn(mem_blk->phys_index);
        sect_end_pfn = sect_start_pfn + PAGES_PER_SECTION - 1;
        for (pfn = sect_start_pfn; pfn <= sect_end_pfn; pfn++) {
@@ -311,11 +383,14 @@ int unregister_mem_sect_under_nodes(struct memory_block *mem_blk)
                        continue;
                if (!node_online(nid))
                        continue;
-               if (node_test_and_set(nid, unlinked_nodes))
+               if (node_test_and_set(nid, *unlinked_nodes))
                        continue;
                sysfs_remove_link(&node_devices[nid].sysdev.kobj,
                         kobject_name(&mem_blk->sysdev.kobj));
+               sysfs_remove_link(&mem_blk->sysdev.kobj,
+                        kobject_name(&node_devices[nid].sysdev.kobj));
        }
+       NODEMASK_FREE(unlinked_nodes);
        return 0;
 }
 
@@ -345,9 +420,77 @@ static int link_mem_sections(int nid)
        }
        return err;
 }
-#else
+
+#ifdef CONFIG_HUGETLBFS
+/*
+ * Handle per node hstate attribute [un]registration on transistions
+ * to/from memoryless state.
+ */
+static void node_hugetlb_work(struct work_struct *work)
+{
+       struct node *node = container_of(work, struct node, node_work);
+
+       /*
+        * We only get here when a node transitions to/from memoryless state.
+        * We can detect which transition occurred by examining whether the
+        * node has memory now.  hugetlb_register_node() already check this
+        * so we try to register the attributes.  If that fails, then the
+        * node has transitioned to memoryless, try to unregister the
+        * attributes.
+        */
+       if (!hugetlb_register_node(node))
+               hugetlb_unregister_node(node);
+}
+
+static void init_node_hugetlb_work(int nid)
+{
+       INIT_WORK(&node_devices[nid].node_work, node_hugetlb_work);
+}
+
+static int node_memory_callback(struct notifier_block *self,
+                               unsigned long action, void *arg)
+{
+       struct memory_notify *mnb = arg;
+       int nid = mnb->status_change_nid;
+
+       switch (action) {
+       case MEM_ONLINE:
+       case MEM_OFFLINE:
+               /*
+                * offload per node hstate [un]registration to a work thread
+                * when transitioning to/from memoryless state.
+                */
+               if (nid != NUMA_NO_NODE)
+                       schedule_work(&node_devices[nid].node_work);
+               break;
+
+       case MEM_GOING_ONLINE:
+       case MEM_GOING_OFFLINE:
+       case MEM_CANCEL_ONLINE:
+       case MEM_CANCEL_OFFLINE:
+       default:
+               break;
+       }
+
+       return NOTIFY_OK;
+}
+#endif /* CONFIG_HUGETLBFS */
+#else  /* !CONFIG_MEMORY_HOTPLUG_SPARSE */
+
 static int link_mem_sections(int nid) { return 0; }
-#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
+#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
+
+#if !defined(CONFIG_MEMORY_HOTPLUG_SPARSE) || \
+    !defined(CONFIG_HUGETLBFS)
+static inline int node_memory_callback(struct notifier_block *self,
+                               unsigned long action, void *arg)
+{
+       return NOTIFY_OK;
+}
+
+static void init_node_hugetlb_work(int nid) { }
+
+#endif
 
 int register_one_node(int nid)
 {
@@ -371,6 +514,9 @@ int register_one_node(int nid)
 
                /* link memory sections under this node */
                error = link_mem_sections(nid);
+
+               /* initialize work queue for memory hot plug */
+               init_node_hugetlb_work(nid);
        }
 
        return error;
@@ -460,13 +606,17 @@ static int node_states_init(void)
        return err;
 }
 
+#define NODE_CALLBACK_PRI      2       /* lower than SLAB */
 static int __init register_node_type(void)
 {
        int ret;
 
        ret = sysdev_class_register(&node_class);
-       if (!ret)
+       if (!ret) {
                ret = node_states_init();
+               hotplug_memory_notifier(node_memory_callback,
+                                       NODE_CALLBACK_PRI);
+       }
 
        /*
         * Note:  we're not going to unregister the node class if we fail
index 9d2ee25deaf5cb13811b45e071e835bc615fa6b9..58efaf2f1259404973a2cdb335ca6378ffd85456 100644 (file)
@@ -441,6 +441,7 @@ error:
        platform_device_put(pdev);
        return ERR_PTR(retval);
 }
+EXPORT_SYMBOL_GPL(platform_device_register_data);
 
 static int platform_drv_probe(struct device *_dev)
 {
index 8aa2443182d517ddec760d594f8781029a3e9fe5..48adf80926a086111127a2d49fa370b0a7888947 100644 (file)
@@ -23,8 +23,8 @@
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/resume-trace.h>
-#include <linux/rwsem.h>
 #include <linux/interrupt.h>
+#include <linux/sched.h>
 
 #include "../base.h"
 #include "power.h"
@@ -161,6 +161,32 @@ void device_pm_move_last(struct device *dev)
        list_move_tail(&dev->power.entry, &dpm_list);
 }
 
+static ktime_t initcall_debug_start(struct device *dev)
+{
+       ktime_t calltime = ktime_set(0, 0);
+
+       if (initcall_debug) {
+               pr_info("calling  %s+ @ %i\n",
+                               dev_name(dev), task_pid_nr(current));
+               calltime = ktime_get();
+       }
+
+       return calltime;
+}
+
+static void initcall_debug_report(struct device *dev, ktime_t calltime,
+                                 int error)
+{
+       ktime_t delta, rettime;
+
+       if (initcall_debug) {
+               rettime = ktime_get();
+               delta = ktime_sub(rettime, calltime);
+               pr_info("call %s+ returned %d after %Ld usecs\n", dev_name(dev),
+                       error, (unsigned long long)ktime_to_ns(delta) >> 10);
+       }
+}
+
 /**
  * pm_op - Execute the PM operation appropriate for given PM event.
  * @dev: Device to handle.
@@ -172,6 +198,9 @@ static int pm_op(struct device *dev,
                 pm_message_t state)
 {
        int error = 0;
+       ktime_t calltime;
+
+       calltime = initcall_debug_start(dev);
 
        switch (state.event) {
 #ifdef CONFIG_SUSPEND
@@ -219,6 +248,9 @@ static int pm_op(struct device *dev,
        default:
                error = -EINVAL;
        }
+
+       initcall_debug_report(dev, calltime, error);
+
        return error;
 }
 
@@ -236,6 +268,13 @@ static int pm_noirq_op(struct device *dev,
                        pm_message_t state)
 {
        int error = 0;
+       ktime_t calltime, delta, rettime;
+
+       if (initcall_debug) {
+               pr_info("calling  %s_i+ @ %i\n",
+                               dev_name(dev), task_pid_nr(current));
+               calltime = ktime_get();
+       }
 
        switch (state.event) {
 #ifdef CONFIG_SUSPEND
@@ -283,6 +322,15 @@ static int pm_noirq_op(struct device *dev,
        default:
                error = -EINVAL;
        }
+
+       if (initcall_debug) {
+               rettime = ktime_get();
+               delta = ktime_sub(rettime, calltime);
+               printk("initcall %s_i+ returned %d after %Ld usecs\n",
+                       dev_name(dev), error,
+                       (unsigned long long)ktime_to_ns(delta) >> 10);
+       }
+
        return error;
 }
 
@@ -324,6 +372,23 @@ static void pm_dev_err(struct device *dev, pm_message_t state, char *info,
                kobject_name(&dev->kobj), pm_verb(state.event), info, error);
 }
 
+static void dpm_show_time(ktime_t starttime, pm_message_t state, char *info)
+{
+       ktime_t calltime;
+       s64 usecs64;
+       int usecs;
+
+       calltime = ktime_get();
+       usecs64 = ktime_to_ns(ktime_sub(calltime, starttime));
+       do_div(usecs64, NSEC_PER_USEC);
+       usecs = usecs64;
+       if (usecs == 0)
+               usecs = 1;
+       pr_info("PM: %s%s%s of devices complete after %ld.%03ld msecs\n",
+               info ?: "", info ? " " : "", pm_verb(state.event),
+               usecs / USEC_PER_MSEC, usecs % USEC_PER_MSEC);
+}
+
 /*------------------------- Resume routines -------------------------*/
 
 /**
@@ -341,14 +406,11 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
        TRACE_DEVICE(dev);
        TRACE_RESUME(0);
 
-       if (!dev->bus)
-               goto End;
-
-       if (dev->bus->pm) {
+       if (dev->bus && dev->bus->pm) {
                pm_dev_dbg(dev, state, "EARLY ");
                error = pm_noirq_op(dev, dev->bus->pm, state);
        }
- End:
+
        TRACE_RESUME(error);
        return error;
 }
@@ -363,6 +425,7 @@ static int device_resume_noirq(struct device *dev, pm_message_t state)
 void dpm_resume_noirq(pm_message_t state)
 {
        struct device *dev;
+       ktime_t starttime = ktime_get();
 
        mutex_lock(&dpm_list_mtx);
        transition_started = false;
@@ -376,10 +439,31 @@ void dpm_resume_noirq(pm_message_t state)
                                pm_dev_err(dev, state, " early", error);
                }
        mutex_unlock(&dpm_list_mtx);
+       dpm_show_time(starttime, state, "early");
        resume_device_irqs();
 }
 EXPORT_SYMBOL_GPL(dpm_resume_noirq);
 
+/**
+ * legacy_resume - Execute a legacy (bus or class) resume callback for device.
+ * dev: Device to resume.
+ * cb: Resume callback to execute.
+ */
+static int legacy_resume(struct device *dev, int (*cb)(struct device *dev))
+{
+       int error;
+       ktime_t calltime;
+
+       calltime = initcall_debug_start(dev);
+
+       error = cb(dev);
+       suspend_report_result(cb, error);
+
+       initcall_debug_report(dev, calltime, error);
+
+       return error;
+}
+
 /**
  * device_resume - Execute "resume" callbacks for given device.
  * @dev: Device to handle.
@@ -400,7 +484,7 @@ static int device_resume(struct device *dev, pm_message_t state)
                        error = pm_op(dev, dev->bus->pm, state);
                } else if (dev->bus->resume) {
                        pm_dev_dbg(dev, state, "legacy ");
-                       error = dev->bus->resume(dev);
+                       error = legacy_resume(dev, dev->bus->resume);
                }
                if (error)
                        goto End;
@@ -421,7 +505,7 @@ static int device_resume(struct device *dev, pm_message_t state)
                        error = pm_op(dev, dev->class->pm, state);
                } else if (dev->class->resume) {
                        pm_dev_dbg(dev, state, "legacy class ");
-                       error = dev->class->resume(dev);
+                       error = legacy_resume(dev, dev->class->resume);
                }
        }
  End:
@@ -441,6 +525,7 @@ static int device_resume(struct device *dev, pm_message_t state)
 static void dpm_resume(pm_message_t state)
 {
        struct list_head list;
+       ktime_t starttime = ktime_get();
 
        INIT_LIST_HEAD(&list);
        mutex_lock(&dpm_list_mtx);
@@ -469,6 +554,7 @@ static void dpm_resume(pm_message_t state)
        }
        list_splice(&list, &dpm_list);
        mutex_unlock(&dpm_list_mtx);
+       dpm_show_time(starttime, state, NULL);
 }
 
 /**
@@ -521,7 +607,7 @@ static void dpm_complete(pm_message_t state)
                        mutex_unlock(&dpm_list_mtx);
 
                        device_complete(dev, state);
-                       pm_runtime_put_noidle(dev);
+                       pm_runtime_put_sync(dev);
 
                        mutex_lock(&dpm_list_mtx);
                }
@@ -584,10 +670,7 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state)
 {
        int error = 0;
 
-       if (!dev->bus)
-               return 0;
-
-       if (dev->bus->pm) {
+       if (dev->bus && dev->bus->pm) {
                pm_dev_dbg(dev, state, "LATE ");
                error = pm_noirq_op(dev, dev->bus->pm, state);
        }
@@ -604,6 +687,7 @@ static int device_suspend_noirq(struct device *dev, pm_message_t state)
 int dpm_suspend_noirq(pm_message_t state)
 {
        struct device *dev;
+       ktime_t starttime = ktime_get();
        int error = 0;
 
        suspend_device_irqs();
@@ -619,10 +703,33 @@ int dpm_suspend_noirq(pm_message_t state)
        mutex_unlock(&dpm_list_mtx);
        if (error)
                dpm_resume_noirq(resume_event(state));
+       else
+               dpm_show_time(starttime, state, "late");
        return error;
 }
 EXPORT_SYMBOL_GPL(dpm_suspend_noirq);
 
+/**
+ * legacy_suspend - Execute a legacy (bus or class) suspend callback for device.
+ * dev: Device to suspend.
+ * cb: Suspend callback to execute.
+ */
+static int legacy_suspend(struct device *dev, pm_message_t state,
+                         int (*cb)(struct device *dev, pm_message_t state))
+{
+       int error;
+       ktime_t calltime;
+
+       calltime = initcall_debug_start(dev);
+
+       error = cb(dev, state);
+       suspend_report_result(cb, error);
+
+       initcall_debug_report(dev, calltime, error);
+
+       return error;
+}
+
 /**
  * device_suspend - Execute "suspend" callbacks for given device.
  * @dev: Device to handle.
@@ -640,8 +747,7 @@ static int device_suspend(struct device *dev, pm_message_t state)
                        error = pm_op(dev, dev->class->pm, state);
                } else if (dev->class->suspend) {
                        pm_dev_dbg(dev, state, "legacy class ");
-                       error = dev->class->suspend(dev, state);
-                       suspend_report_result(dev->class->suspend, error);
+                       error = legacy_suspend(dev, state, dev->class->suspend);
                }
                if (error)
                        goto End;
@@ -662,8 +768,7 @@ static int device_suspend(struct device *dev, pm_message_t state)
                        error = pm_op(dev, dev->bus->pm, state);
                } else if (dev->bus->suspend) {
                        pm_dev_dbg(dev, state, "legacy ");
-                       error = dev->bus->suspend(dev, state);
-                       suspend_report_result(dev->bus->suspend, error);
+                       error = legacy_suspend(dev, state, dev->bus->suspend);
                }
        }
  End:
@@ -679,6 +784,7 @@ static int device_suspend(struct device *dev, pm_message_t state)
 static int dpm_suspend(pm_message_t state)
 {
        struct list_head list;
+       ktime_t starttime = ktime_get();
        int error = 0;
 
        INIT_LIST_HEAD(&list);
@@ -704,6 +810,8 @@ static int dpm_suspend(pm_message_t state)
        }
        list_splice(&list, dpm_list.prev);
        mutex_unlock(&dpm_list_mtx);
+       if (!error)
+               dpm_show_time(starttime, state, NULL);
        return error;
 }
 
@@ -772,7 +880,7 @@ static int dpm_prepare(pm_message_t state)
                pm_runtime_get_noresume(dev);
                if (pm_runtime_barrier(dev) && device_may_wakeup(dev)) {
                        /* Wake-up requested during system sleep transition. */
-                       pm_runtime_put_noidle(dev);
+                       pm_runtime_put_sync(dev);
                        error = -EBUSY;
                } else {
                        error = device_prepare(dev, state);
index 5a01ecef4af3600da40b8e458bc670d1223d2fbe..f8b044e8aef7f5e8683c9af1d6ec461d86d197f5 100644 (file)
@@ -84,6 +84,19 @@ static int __pm_runtime_idle(struct device *dev)
 
                dev->bus->pm->runtime_idle(dev);
 
+               spin_lock_irq(&dev->power.lock);
+       } else if (dev->type && dev->type->pm && dev->type->pm->runtime_idle) {
+               spin_unlock_irq(&dev->power.lock);
+
+               dev->type->pm->runtime_idle(dev);
+
+               spin_lock_irq(&dev->power.lock);
+       } else if (dev->class && dev->class->pm
+           && dev->class->pm->runtime_idle) {
+               spin_unlock_irq(&dev->power.lock);
+
+               dev->class->pm->runtime_idle(dev);
+
                spin_lock_irq(&dev->power.lock);
        }
 
@@ -192,6 +205,22 @@ int __pm_runtime_suspend(struct device *dev, bool from_wq)
 
                retval = dev->bus->pm->runtime_suspend(dev);
 
+               spin_lock_irq(&dev->power.lock);
+               dev->power.runtime_error = retval;
+       } else if (dev->type && dev->type->pm
+           && dev->type->pm->runtime_suspend) {
+               spin_unlock_irq(&dev->power.lock);
+
+               retval = dev->type->pm->runtime_suspend(dev);
+
+               spin_lock_irq(&dev->power.lock);
+               dev->power.runtime_error = retval;
+       } else if (dev->class && dev->class->pm
+           && dev->class->pm->runtime_suspend) {
+               spin_unlock_irq(&dev->power.lock);
+
+               retval = dev->class->pm->runtime_suspend(dev);
+
                spin_lock_irq(&dev->power.lock);
                dev->power.runtime_error = retval;
        } else {
@@ -357,6 +386,22 @@ int __pm_runtime_resume(struct device *dev, bool from_wq)
 
                retval = dev->bus->pm->runtime_resume(dev);
 
+               spin_lock_irq(&dev->power.lock);
+               dev->power.runtime_error = retval;
+       } else if (dev->type && dev->type->pm
+           && dev->type->pm->runtime_resume) {
+               spin_unlock_irq(&dev->power.lock);
+
+               retval = dev->type->pm->runtime_resume(dev);
+
+               spin_lock_irq(&dev->power.lock);
+               dev->power.runtime_error = retval;
+       } else if (dev->class && dev->class->pm
+           && dev->class->pm->runtime_resume) {
+               spin_unlock_irq(&dev->power.lock);
+
+               retval = dev->class->pm->runtime_resume(dev);
+
                spin_lock_irq(&dev->power.lock);
                dev->power.runtime_error = retval;
        } else {
@@ -701,15 +746,15 @@ EXPORT_SYMBOL_GPL(pm_request_resume);
  * @dev: Device to handle.
  * @sync: If set and the device is suspended, resume it synchronously.
  *
- * Increment the usage count of the device and if it was zero previously,
- * resume it or submit a resume request for it, depending on the value of @sync.
+ * Increment the usage count of the device and resume it or submit a resume
+ * request for it, depending on the value of @sync.
  */
 int __pm_runtime_get(struct device *dev, bool sync)
 {
-       int retval = 1;
+       int retval;
 
-       if (atomic_add_return(1, &dev->power.usage_count) == 1)
-               retval = sync ? pm_runtime_resume(dev) : pm_request_resume(dev);
+       atomic_inc(&dev->power.usage_count);
+       retval = sync ? pm_runtime_resume(dev) : pm_request_resume(dev);
 
        return retval;
 }
index eb4fa19439444097875d8492ceb6996569e40d45..ce1fa923c414efa246aecde97b95bc7722a46879 100644 (file)
@@ -7101,7 +7101,7 @@ static struct DAC960_privdata DAC960_BA_privdata = {
 
 static struct DAC960_privdata DAC960_LP_privdata = {
        .HardwareType =         DAC960_LP_Controller,
-       .FirmwareType   =       DAC960_LP_Controller,
+       .FirmwareType   =       DAC960_V2_Controller,
        .InterruptHandler =     DAC960_LP_InterruptHandler,
        .MemoryWindowSize =     DAC960_LP_RegisterWindowSize,
 };
index 13bb69d2abb3307d8cb95c9f21e04e0c7b2e9ae8..64a223b0cc2229fb14250dd60fd572b8f8bd9c59 100644 (file)
@@ -735,21 +735,6 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector
        part_stat_unlock();
 }
 
-/*
- * Ensure we don't create aliases in VI caches
- */
-static inline void
-killalias(struct bio *bio)
-{
-       struct bio_vec *bv;
-       int i;
-
-       if (bio_data_dir(bio) == READ)
-               __bio_for_each_segment(bv, bio, i, 0) {
-                       flush_dcache_page(bv->bv_page);
-               }
-}
-
 void
 aoecmd_ata_rsp(struct sk_buff *skb)
 {
@@ -871,7 +856,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
                if (buf->flags & BUFFL_FAIL)
                        bio_endio(buf->bio, -EIO);
                else {
-                       killalias(buf->bio);
+                       bio_flush_dcache_pages(buf->bio);
                        bio_endio(buf->bio, 0);
                }
                mempool_free(buf, d->bufpool);
index 2312d782fe990df0f0db5ca83aa82de5ea1045e2..c9755876343088cb6e0c1ad74f06f8a4cac84f0f 100644 (file)
@@ -1490,7 +1490,7 @@ void drbd_bump_write_ordering(struct drbd_conf *mdev, enum write_ordering_e wo);
 
 /* drbd_proc.c */
 extern struct proc_dir_entry *drbd_proc;
-extern struct file_operations drbd_proc_fops;
+extern const struct file_operations drbd_proc_fops;
 extern const char *drbd_conn_str(enum drbd_conns s);
 extern const char *drbd_role_str(enum drbd_role s);
 
index 157d1e4343c23a957c751778cd7781cca1ee7833..9348f33f6242e9088f7094ea836d7b0d19e24f0f 100644 (file)
@@ -27,7 +27,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/version.h>
 #include <linux/drbd.h>
 #include <asm/uaccess.h>
 #include <asm/types.h>
@@ -151,7 +150,7 @@ wait_queue_head_t drbd_pp_wait;
 
 DEFINE_RATELIMIT_STATE(drbd_ratelimit_state, 5 * HZ, 5);
 
-static struct block_device_operations drbd_ops = {
+static const struct block_device_operations drbd_ops = {
        .owner =   THIS_MODULE,
        .open =    drbd_open,
        .release = drbd_release,
@@ -3623,7 +3622,7 @@ _drbd_fault_random(struct fault_random_state *rsp)
 {
        long refresh;
 
-       if (--rsp->count < 0) {
+       if (!rsp->count--) {
                get_random_bytes(&refresh, sizeof(refresh));
                rsp->state += refresh;
                rsp->count = FAULT_RANDOM_REFRESH;
index 436a090b532b4ac21850f18ece8d4d487322148e..4e0726aa53b0cc12ca1759b00f7579035121870c 100644 (file)
@@ -1271,8 +1271,7 @@ static int drbd_nl_net_conf(struct drbd_conf *mdev, struct drbd_nl_cfg_req *nlp,
                        goto fail;
                }
 
-               if (crypto_tfm_alg_type(crypto_hash_tfm(tfm))
-                                               != CRYPTO_ALG_TYPE_HASH) {
+               if (crypto_tfm_alg_type(crypto_hash_tfm(tfm)) != CRYPTO_ALG_TYPE_SHASH) {
                        retcode = ERR_AUTH_ALG_ND;
                        goto fail;
                }
index bdd0b4943b1033b931b44b74697017a9976d1178..df8ad9660d8f969adff252371ce86be9f2ab4aab 100644 (file)
@@ -38,7 +38,7 @@ static int drbd_proc_open(struct inode *inode, struct file *file);
 
 
 struct proc_dir_entry *drbd_proc;
-struct file_operations drbd_proc_fops = {
+const struct file_operations drbd_proc_fops = {
        .owner          = THIS_MODULE,
        .open           = drbd_proc_open,
        .read           = seq_read,
index c548f24f54a19a8262bce0f4200a54291b84cbca..259c1351b1528da954d446edc4b984bcea2e2a39 100644 (file)
@@ -28,7 +28,6 @@
 #include <asm/uaccess.h>
 #include <net/sock.h>
 
-#include <linux/version.h>
 #include <linux/drbd.h>
 #include <linux/fs.h>
 #include <linux/file.h>
index ed8796f1112d933004a6feea740765d3251cce65..b453c2bca3be5d3740c81be7e41d2ff953bb937d 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/version.h>
 #include <linux/drbd.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
@@ -34,7 +33,6 @@
 #include <linux/mm_inline.h>
 #include <linux/slab.h>
 #include <linux/random.h>
-#include <linux/mm.h>
 #include <linux/string.h>
 #include <linux/scatterlist.h>
 
index 5c01f747571b9fe34f54de72d5fa5f03641c17d7..3266b4f65daa37dec3110ff2220f8d4b7c1bfb42 100644 (file)
@@ -3497,6 +3497,9 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
            ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
                return -EPERM;
 
+       if (WARN_ON(size < 0 || size > sizeof(inparam)))
+               return -EINVAL;
+
        /* copyin */
        CLEARSTRUCT(&inparam);
        if (_IOC_DIR(cmd) & _IOC_WRITE)
@@ -4162,7 +4165,7 @@ static int floppy_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops floppy_pm_ops = {
+static const struct dev_pm_ops floppy_pm_ops = {
        .resume = floppy_resume,
        .restore = floppy_resume,
 };
index e0339aaa18154303316c8405d72c08af4b036ffd..02b2583df7fc225184dbf704a28aade8d24128ec 100644 (file)
@@ -860,7 +860,7 @@ static int mg_probe(struct platform_device *plat_dev)
                err = -EINVAL;
                goto probe_err_2;
        }
-       host->dev_base = ioremap(rsc->start , rsc->end + 1);
+       host->dev_base = ioremap(rsc->start, resource_size(rsc));
        if (!host->dev_base) {
                printk(KERN_ERR "%s:%d ioremap fail\n",
                                __func__, __LINE__);
index 0877d3628fdae251f48b87d87fffeb1e9d11df29..d1fd032e751494cb7f452c470383f14d45ab3ec7 100644 (file)
@@ -169,13 +169,6 @@ static int __init xd_init(void)
 
        init_timer (&xd_watchdog_int); xd_watchdog_int.function = xd_watchdog;
 
-       if (!xd_dma_buffer)
-               xd_dma_buffer = (char *)xd_dma_mem_alloc(xd_maxsectors * 0x200);
-       if (!xd_dma_buffer) {
-               printk(KERN_ERR "xd: Out of memory.\n");
-               return -ENOMEM;
-       }
-
        err = -EBUSY;
        if (register_blkdev(XT_DISK_MAJOR, "xd"))
                goto out1;
@@ -202,6 +195,19 @@ static int __init xd_init(void)
                        xd_drives,xd_drives == 1 ? "" : "s",xd_irq,xd_dma);
        }
 
+       /*
+        * With the drive detected, xd_maxsectors should now be known.
+        * If xd_maxsectors is 0, nothing was detected and we fall through
+        * to return -ENODEV
+        */
+       if (!xd_dma_buffer && xd_maxsectors) {
+               xd_dma_buffer = (char *)xd_dma_mem_alloc(xd_maxsectors * 0x200);
+               if (!xd_dma_buffer) {
+                       printk(KERN_ERR "xd: Out of memory.\n");
+                       goto out3;
+               }
+       }
+
        err = -ENODEV;
        if (!xd_drives)
                goto out3;
@@ -249,15 +255,17 @@ out4:
        for (i = 0; i < xd_drives; i++)
                put_disk(xd_gendisk[i]);
 out3:
-       release_region(xd_iobase,4);
+       if (xd_maxsectors)
+               release_region(xd_iobase,4);
+
+       if (xd_dma_buffer)
+               xd_dma_mem_free((unsigned long)xd_dma_buffer,
+                               xd_maxsectors * 0x200);
 out2:
        blk_cleanup_queue(xd_queue);
 out1a:
        unregister_blkdev(XT_DISK_MAJOR, "xd");
 out1:
-       if (xd_dma_buffer)
-               xd_dma_mem_free((unsigned long)xd_dma_buffer,
-                               xd_maxsectors * 0x200);
        return err;
 Enomem:
        err = -ENOMEM;
index 4d29059967517f2a54c02eabc55ef76f84ba1855..a699f09ddf7cac819eba8a13514688895abf0af6 100644 (file)
@@ -307,6 +307,7 @@ static void btusb_bulk_complete(struct urb *urb)
                return;
 
        usb_anchor_urb(urb, &data->bulk_anchor);
+       usb_mark_last_busy(data->udev);
 
        err = usb_submit_urb(urb, GFP_ATOMIC);
        if (err < 0) {
index 6f31c947210093c756d0b516dbf5743f1b7a0c84..31be3ac2e21b36e94f8db37660ff3c92aaa0771f 100644 (file)
@@ -502,7 +502,7 @@ config BRIQ_PANEL
 
 config BFIN_OTP
        tristate "Blackfin On-Chip OTP Memory Support"
-       depends on BLACKFIN && (BF52x || BF54x)
+       depends on BLACKFIN && (BF51x || BF52x || BF54x)
        default y
        help
          If you say Y here, you will get support for a character device
index 26a47dc88f6194ed7c0402f01fe31477a27e2af2..53c524e7b82928a78ff04e26be135ca4c1a4e428 100644 (file)
@@ -285,6 +285,7 @@ static const struct file_operations efi_rtc_fops = {
        .unlocked_ioctl = efi_rtc_ioctl,
        .open           = efi_rtc_open,
        .release        = efi_rtc_close,
+       .llseek         = no_llseek,
 };
 
 static struct miscdevice efi_rtc_dev= {
index b8a5d654d3d043e494f6bab085552ab64df24f9f..fe62bd0e17b751f55e359addc54ee4569a4f7488 100644 (file)
@@ -931,7 +931,7 @@ static struct hv_ops hvc_iucv_ops = {
 };
 
 /* Suspend / resume device operations */
-static struct dev_pm_ops hvc_iucv_pm_ops = {
+static const struct dev_pm_ops hvc_iucv_pm_ops = {
        .freeze   = hvc_iucv_pm_freeze,
        .thaw     = hvc_iucv_pm_restore_thaw,
        .restore  = hvc_iucv_pm_restore_thaw,
index e989f67bb61f14b84fd66f90f1a87008ff9117dc..3d9c61e5acbf2adb354a70e0a8ba532568ef06d0 100644 (file)
@@ -158,10 +158,11 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
                        goto out;
                }
        }
-out_unlock:
-       mutex_unlock(&rng_mutex);
 out:
        return ret ? : err;
+out_unlock:
+       mutex_unlock(&rng_mutex);
+       goto out;
 }
 
 
index 80704875794c38795505f945262448bb6f43cb25..cf82fedae09975272fd6517b1fa5346eff95a814 100644 (file)
@@ -370,7 +370,7 @@ static enum si_sm_result kcs_event(struct si_sm_data *kcs, long time)
                        return SI_SM_IDLE;
 
        case KCS_START_OP:
-               if (state != KCS_IDLE) {
+               if (state != KCS_IDLE_STATE) {
                        start_error_recovery(kcs,
                                             "State machine not idle at start");
                        break;
index d2e698096ace182698152e2366d7c2dc2cf91342..176f1751237f57807f3023d9427972dcb6614392 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/dmi.h>
 #include <linux/string.h>
 #include <linux/ctype.h>
+#include <linux/pnp.h>
 
 #ifdef CONFIG_PPC_OF
 #include <linux/of_device.h>
@@ -1919,7 +1920,7 @@ struct SPMITable {
        s8      spmi_id[1]; /* A '\0' terminated array starts here. */
 };
 
-static __devinit int try_init_acpi(struct SPMITable *spmi)
+static __devinit int try_init_spmi(struct SPMITable *spmi)
 {
        struct smi_info  *info;
        u8               addr_space;
@@ -1940,7 +1941,7 @@ static __devinit int try_init_acpi(struct SPMITable *spmi)
                return -ENOMEM;
        }
 
-       info->addr_source = "ACPI";
+       info->addr_source = "SPMI";
 
        /* Figure out the interface type. */
        switch (spmi->InterfaceType) {
@@ -2002,7 +2003,7 @@ static __devinit int try_init_acpi(struct SPMITable *spmi)
        return 0;
 }
 
-static __devinit void acpi_find_bmc(void)
+static __devinit void spmi_find_bmc(void)
 {
        acpi_status      status;
        struct SPMITable *spmi;
@@ -2020,9 +2021,106 @@ static __devinit void acpi_find_bmc(void)
                if (status != AE_OK)
                        return;
 
-               try_init_acpi(spmi);
+               try_init_spmi(spmi);
        }
 }
+
+static int __devinit ipmi_pnp_probe(struct pnp_dev *dev,
+                                   const struct pnp_device_id *dev_id)
+{
+       struct acpi_device *acpi_dev;
+       struct smi_info *info;
+       acpi_handle handle;
+       acpi_status status;
+       unsigned long long tmp;
+
+       acpi_dev = pnp_acpi_device(dev);
+       if (!acpi_dev)
+               return -ENODEV;
+
+       info = kzalloc(sizeof(*info), GFP_KERNEL);
+       if (!info)
+               return -ENOMEM;
+
+       info->addr_source = "ACPI";
+
+       handle = acpi_dev->handle;
+
+       /* _IFT tells us the interface type: KCS, BT, etc */
+       status = acpi_evaluate_integer(handle, "_IFT", NULL, &tmp);
+       if (ACPI_FAILURE(status))
+               goto err_free;
+
+       switch (tmp) {
+       case 1:
+               info->si_type = SI_KCS;
+               break;
+       case 2:
+               info->si_type = SI_SMIC;
+               break;
+       case 3:
+               info->si_type = SI_BT;
+               break;
+       default:
+               dev_info(&dev->dev, "unknown interface type %lld\n", tmp);
+               goto err_free;
+       }
+
+       if (pnp_port_valid(dev, 0)) {
+               info->io_setup = port_setup;
+               info->io.addr_type = IPMI_IO_ADDR_SPACE;
+               info->io.addr_data = pnp_port_start(dev, 0);
+       } else if (pnp_mem_valid(dev, 0)) {
+               info->io_setup = mem_setup;
+               info->io.addr_type = IPMI_MEM_ADDR_SPACE;
+               info->io.addr_data = pnp_mem_start(dev, 0);
+       } else {
+               dev_err(&dev->dev, "no I/O or memory address\n");
+               goto err_free;
+       }
+
+       info->io.regspacing = DEFAULT_REGSPACING;
+       info->io.regsize = DEFAULT_REGSPACING;
+       info->io.regshift = 0;
+
+       /* If _GPE exists, use it; otherwise use standard interrupts */
+       status = acpi_evaluate_integer(handle, "_GPE", NULL, &tmp);
+       if (ACPI_SUCCESS(status)) {
+               info->irq = tmp;
+               info->irq_setup = acpi_gpe_irq_setup;
+       } else if (pnp_irq_valid(dev, 0)) {
+               info->irq = pnp_irq(dev, 0);
+               info->irq_setup = std_irq_setup;
+       }
+
+       info->dev = &acpi_dev->dev;
+       pnp_set_drvdata(dev, info);
+
+       return try_smi_init(info);
+
+err_free:
+       kfree(info);
+       return -EINVAL;
+}
+
+static void __devexit ipmi_pnp_remove(struct pnp_dev *dev)
+{
+       struct smi_info *info = pnp_get_drvdata(dev);
+
+       cleanup_one_si(info);
+}
+
+static const struct pnp_device_id pnp_dev_table[] = {
+       {"IPI0001", 0},
+       {"", 0},
+};
+
+static struct pnp_driver ipmi_pnp_driver = {
+       .name           = DEVICE_NAME,
+       .probe          = ipmi_pnp_probe,
+       .remove         = __devexit_p(ipmi_pnp_remove),
+       .id_table       = pnp_dev_table,
+};
 #endif
 
 #ifdef CONFIG_DMI
@@ -2202,7 +2300,6 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
        int rv;
        int class_type = pdev->class & PCI_ERMC_CLASSCODE_TYPE_MASK;
        struct smi_info *info;
-       int first_reg_offset = 0;
 
        info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info)
@@ -2241,9 +2338,6 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
        info->addr_source_cleanup = ipmi_pci_cleanup;
        info->addr_source_data = pdev;
 
-       if (pdev->subsystem_vendor == PCI_HP_VENDOR_ID)
-               first_reg_offset = 1;
-
        if (pci_resource_flags(pdev, 0) & IORESOURCE_IO) {
                info->io_setup = port_setup;
                info->io.addr_type = IPMI_IO_ADDR_SPACE;
@@ -3108,7 +3202,10 @@ static __devinit int init_ipmi_si(void)
 #endif
 
 #ifdef CONFIG_ACPI
-       acpi_find_bmc();
+       spmi_find_bmc();
+#endif
+#ifdef CONFIG_ACPI
+       pnp_register_driver(&ipmi_pnp_driver);
 #endif
 
 #ifdef CONFIG_PCI
@@ -3233,6 +3330,9 @@ static __exit void cleanup_ipmi_si(void)
 #ifdef CONFIG_PCI
        pci_unregister_driver(&ipmi_pci_driver);
 #endif
+#ifdef CONFIG_ACPI
+       pnp_unregister_driver(&ipmi_pnp_driver);
+#endif
 
 #ifdef CONFIG_PPC_OF
        of_unregister_platform_driver(&ipmi_of_platform_driver);
index fba76fb55abfd302bbd87e6433ed858b8b5d2c4d..be832b6f8279919831df235a11738f7398668722 100644 (file)
 # include <linux/efi.h>
 #endif
 
+static inline unsigned long size_inside_page(unsigned long start,
+                                            unsigned long size)
+{
+       unsigned long sz;
+
+       sz = PAGE_SIZE - (start & (PAGE_SIZE - 1));
+
+       return min(sz, size);
+}
+
 /*
  * Architectures vary in how they handle caching for addresses
  * outside of main memory.
@@ -126,9 +136,7 @@ static ssize_t read_mem(struct file * file, char __user * buf,
 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
        /* we don't have page 0 mapped on sparc and m68k.. */
        if (p < PAGE_SIZE) {
-               sz = PAGE_SIZE - p;
-               if (sz > count) 
-                       sz = count; 
+               sz = size_inside_page(p, count);
                if (sz > 0) {
                        if (clear_user(buf, sz))
                                return -EFAULT;
@@ -141,15 +149,9 @@ static ssize_t read_mem(struct file * file, char __user * buf,
 #endif
 
        while (count > 0) {
-               /*
-                * Handle first page in case it's not aligned
-                */
-               if (-p & (PAGE_SIZE - 1))
-                       sz = -p & (PAGE_SIZE - 1);
-               else
-                       sz = PAGE_SIZE;
+               unsigned long remaining;
 
-               sz = min_t(unsigned long, sz, count);
+               sz = size_inside_page(p, count);
 
                if (!range_is_allowed(p >> PAGE_SHIFT, count))
                        return -EPERM;
@@ -163,12 +165,10 @@ static ssize_t read_mem(struct file * file, char __user * buf,
                if (!ptr)
                        return -EFAULT;
 
-               if (copy_to_user(buf, ptr, sz)) {
-                       unxlate_dev_mem_ptr(p, ptr);
-                       return -EFAULT;
-               }
-
+               remaining = copy_to_user(buf, ptr, sz);
                unxlate_dev_mem_ptr(p, ptr);
+               if (remaining)
+                       return -EFAULT;
 
                buf += sz;
                p += sz;
@@ -196,9 +196,7 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
        /* we don't have page 0 mapped on sparc and m68k.. */
        if (p < PAGE_SIZE) {
-               unsigned long sz = PAGE_SIZE - p;
-               if (sz > count)
-                       sz = count;
+               sz = size_inside_page(p, count);
                /* Hmm. Do something? */
                buf += sz;
                p += sz;
@@ -208,15 +206,7 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
 #endif
 
        while (count > 0) {
-               /*
-                * Handle first page in case it's not aligned
-                */
-               if (-p & (PAGE_SIZE - 1))
-                       sz = -p & (PAGE_SIZE - 1);
-               else
-                       sz = PAGE_SIZE;
-
-               sz = min_t(unsigned long, sz, count);
+               sz = size_inside_page(p, count);
 
                if (!range_is_allowed(p >> PAGE_SHIFT, sz))
                        return -EPERM;
@@ -234,16 +224,14 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
                }
 
                copied = copy_from_user(ptr, buf, sz);
+               unxlate_dev_mem_ptr(p, ptr);
                if (copied) {
                        written += sz - copied;
-                       unxlate_dev_mem_ptr(p, ptr);
                        if (written)
                                break;
                        return -EFAULT;
                }
 
-               unxlate_dev_mem_ptr(p, ptr);
-
                buf += sz;
                p += sz;
                count -= sz;
@@ -417,27 +405,18 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
                /* we don't have page 0 mapped on sparc and m68k.. */
                if (p < PAGE_SIZE && low_count > 0) {
-                       size_t tmp = PAGE_SIZE - p;
-                       if (tmp > low_count) tmp = low_count;
-                       if (clear_user(buf, tmp))
+                       sz = size_inside_page(p, low_count);
+                       if (clear_user(buf, sz))
                                return -EFAULT;
-                       buf += tmp;
-                       p += tmp;
-                       read += tmp;
-                       low_count -= tmp;
-                       count -= tmp;
+                       buf += sz;
+                       p += sz;
+                       read += sz;
+                       low_count -= sz;
+                       count -= sz;
                }
 #endif
                while (low_count > 0) {
-                       /*
-                        * Handle first page in case it's not aligned
-                        */
-                       if (-p & (PAGE_SIZE - 1))
-                               sz = -p & (PAGE_SIZE - 1);
-                       else
-                               sz = PAGE_SIZE;
-
-                       sz = min_t(unsigned long, sz, low_count);
+                       sz = size_inside_page(p, low_count);
 
                        /*
                         * On ia64 if a page has been mapped somewhere as
@@ -461,21 +440,18 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
                if (!kbuf)
                        return -ENOMEM;
                while (count > 0) {
-                       int len = count;
-
-                       if (len > PAGE_SIZE)
-                               len = PAGE_SIZE;
-                       len = vread(kbuf, (char *)p, len);
-                       if (!len)
+                       sz = size_inside_page(p, count);
+                       sz = vread(kbuf, (char *)p, sz);
+                       if (!sz)
                                break;
-                       if (copy_to_user(buf, kbuf, len)) {
+                       if (copy_to_user(buf, kbuf, sz)) {
                                free_page((unsigned long)kbuf);
                                return -EFAULT;
                        }
-                       count -= len;
-                       buf += len;
-                       read += len;
-                       p += len;
+                       count -= sz;
+                       buf += sz;
+                       read += sz;
+                       p += sz;
                }
                free_page((unsigned long)kbuf);
        }
@@ -485,7 +461,7 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
 
 
 static inline ssize_t
-do_write_kmem(void *p, unsigned long realp, const char __user * buf,
+do_write_kmem(unsigned long p, const char __user *buf,
              size_t count, loff_t *ppos)
 {
        ssize_t written, sz;
@@ -494,14 +470,11 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
        written = 0;
 #ifdef __ARCH_HAS_NO_PAGE_ZERO_MAPPED
        /* we don't have page 0 mapped on sparc and m68k.. */
-       if (realp < PAGE_SIZE) {
-               unsigned long sz = PAGE_SIZE - realp;
-               if (sz > count)
-                       sz = count;
+       if (p < PAGE_SIZE) {
+               sz = size_inside_page(p, count);
                /* Hmm. Do something? */
                buf += sz;
                p += sz;
-               realp += sz;
                count -= sz;
                written += sz;
        }
@@ -509,22 +482,15 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
 
        while (count > 0) {
                char *ptr;
-               /*
-                * Handle first page in case it's not aligned
-                */
-               if (-realp & (PAGE_SIZE - 1))
-                       sz = -realp & (PAGE_SIZE - 1);
-               else
-                       sz = PAGE_SIZE;
 
-               sz = min_t(unsigned long, sz, count);
+               sz = size_inside_page(p, count);
 
                /*
                 * On ia64 if a page has been mapped somewhere as
                 * uncached, then it must also be accessed uncached
                 * by the kernel or data corruption may occur
                 */
-               ptr = xlate_dev_kmem_ptr(p);
+               ptr = xlate_dev_kmem_ptr((char *)p);
 
                copied = copy_from_user(ptr, buf, sz);
                if (copied) {
@@ -535,7 +501,6 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
                }
                buf += sz;
                p += sz;
-               realp += sz;
                count -= sz;
                written += sz;
        }
@@ -554,19 +519,14 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
        unsigned long p = *ppos;
        ssize_t wrote = 0;
        ssize_t virtr = 0;
-       ssize_t written;
        char * kbuf; /* k-addr because vwrite() takes vmlist_lock rwlock */
 
        if (p < (unsigned long) high_memory) {
-
-               wrote = count;
-               if (count > (unsigned long) high_memory - p)
-                       wrote = (unsigned long) high_memory - p;
-
-               written = do_write_kmem((void*)p, p, buf, wrote, ppos);
-               if (written != wrote)
-                       return written;
-               wrote = written;
+               unsigned long to_write = min_t(unsigned long, count,
+                                              (unsigned long)high_memory - p);
+               wrote = do_write_kmem(p, buf, to_write, ppos);
+               if (wrote != to_write)
+                       return wrote;
                p += wrote;
                buf += wrote;
                count -= wrote;
@@ -577,24 +537,21 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
                if (!kbuf)
                        return wrote ? wrote : -ENOMEM;
                while (count > 0) {
-                       int len = count;
-
-                       if (len > PAGE_SIZE)
-                               len = PAGE_SIZE;
-                       if (len) {
-                               written = copy_from_user(kbuf, buf, len);
-                               if (written) {
-                                       if (wrote + virtr)
-                                               break;
-                                       free_page((unsigned long)kbuf);
-                                       return -EFAULT;
-                               }
+                       unsigned long sz = size_inside_page(p, count);
+                       unsigned long n;
+
+                       n = copy_from_user(kbuf, buf, sz);
+                       if (n) {
+                               if (wrote + virtr)
+                                       break;
+                               free_page((unsigned long)kbuf);
+                               return -EFAULT;
                        }
-                       len = vwrite(kbuf, (char *)p, len);
-                       count -= len;
-                       buf += len;
-                       virtr += len;
-                       p += len;
+                       sz = vwrite(kbuf, (char *)p, sz);
+                       count -= sz;
+                       buf += sz;
+                       virtr += sz;
+                       p += sz;
                }
                free_page((unsigned long)kbuf);
        }
index 96f1cd086dd245911cb9be85d93cf175c9b97c6a..94a136e96c06c69b51aea6c31162606382ff6330 100644 (file)
@@ -60,9 +60,7 @@ static DEFINE_MUTEX(misc_mtx);
  * Assigned numbers, used for dynamic minors
  */
 #define DYNAMIC_MINORS 64 /* like dynamic majors */
-static unsigned char misc_minors[DYNAMIC_MINORS / 8];
-
-extern int pmu_device_init(void);
+static DECLARE_BITMAP(misc_minors, DYNAMIC_MINORS);
 
 #ifdef CONFIG_PROC_FS
 static void *misc_seq_start(struct seq_file *seq, loff_t *pos)
@@ -198,24 +196,23 @@ int misc_register(struct miscdevice * misc)
        }
 
        if (misc->minor == MISC_DYNAMIC_MINOR) {
-               int i = DYNAMIC_MINORS;
-               while (--i >= 0)
-                       if ( (misc_minors[i>>3] & (1 << (i&7))) == 0)
-                               break;
-               if (i<0) {
+               int i = find_first_zero_bit(misc_minors, DYNAMIC_MINORS);
+               if (i >= DYNAMIC_MINORS) {
                        mutex_unlock(&misc_mtx);
                        return -EBUSY;
                }
-               misc->minor = i;
+               misc->minor = DYNAMIC_MINORS - i - 1;
+               set_bit(i, misc_minors);
        }
 
-       if (misc->minor < DYNAMIC_MINORS)
-               misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
        dev = MKDEV(MISC_MAJOR, misc->minor);
 
        misc->this_device = device_create(misc_class, misc->parent, dev,
                                          misc, "%s", misc->name);
        if (IS_ERR(misc->this_device)) {
+               int i = DYNAMIC_MINORS - misc->minor - 1;
+               if (i < DYNAMIC_MINORS && i >= 0)
+                       clear_bit(i, misc_minors);
                err = PTR_ERR(misc->this_device);
                goto out;
        }
@@ -242,7 +239,7 @@ int misc_register(struct miscdevice * misc)
 
 int misc_deregister(struct miscdevice *misc)
 {
-       int i = misc->minor;
+       int i = DYNAMIC_MINORS - misc->minor - 1;
 
        if (list_empty(&misc->list))
                return -EINVAL;
@@ -250,9 +247,8 @@ int misc_deregister(struct miscdevice *misc)
        mutex_lock(&misc_mtx);
        list_del(&misc->list);
        device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor));
-       if (i < DYNAMIC_MINORS && i>0) {
-               misc_minors[i>>3] &= ~(1 << (misc->minor & 7));
-       }
+       if (i < DYNAMIC_MINORS && i >= 0)
+               clear_bit(i, misc_minors);
        mutex_unlock(&misc_mtx);
        return 0;
 }
index d3400b20444f4f726b7de49e6ff88a5aa78cc938..7d73cd430340c4926343af47c2247d7e8dadceeb 100644 (file)
@@ -358,7 +358,7 @@ struct port {
        u8 update_flow_control;
        struct ctrl_ul ctrl_ul;
        struct ctrl_dl ctrl_dl;
-       struct kfifo *fifo_ul;
+       struct kfifo fifo_ul;
        void __iomem *dl_addr[2];
        u32 dl_size[2];
        u8 toggle_dl;
@@ -685,8 +685,6 @@ static int nozomi_read_config_table(struct nozomi *dc)
                dump_table(dc);
 
                for (i = PORT_MDM; i < MAX_PORT; i++) {
-                       dc->port[i].fifo_ul =
-                           kfifo_alloc(FIFO_BUFFER_SIZE_UL, GFP_ATOMIC, NULL);
                        memset(&dc->port[i].ctrl_dl, 0, sizeof(struct ctrl_dl));
                        memset(&dc->port[i].ctrl_ul, 0, sizeof(struct ctrl_ul));
                }
@@ -798,7 +796,7 @@ static int send_data(enum port_type index, struct nozomi *dc)
        struct tty_struct *tty = tty_port_tty_get(&port->port);
 
        /* Get data from tty and place in buf for now */
-       size = __kfifo_get(port->fifo_ul, dc->send_buf,
+       size = kfifo_out(&port->fifo_ul, dc->send_buf,
                           ul_size < SEND_BUF_MAX ? ul_size : SEND_BUF_MAX);
 
        if (size == 0) {
@@ -988,11 +986,11 @@ static int receive_flow_control(struct nozomi *dc)
 
        } else if (old_ctrl.CTS == 0 && ctrl_dl.CTS == 1) {
 
-               if (__kfifo_len(dc->port[port].fifo_ul)) {
+               if (kfifo_len(&dc->port[port].fifo_ul)) {
                        DBG1("Enable interrupt (0x%04X) on port: %d",
                                enable_ier, port);
                        DBG1("Data in buffer [%d], enable transmit! ",
-                               __kfifo_len(dc->port[port].fifo_ul));
+                               kfifo_len(&dc->port[port].fifo_ul));
                        enable_transmit_ul(port, dc);
                } else {
                        DBG1("No data in buffer...");
@@ -1433,6 +1431,16 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
                goto err_free_sbuf;
        }
 
+       for (i = PORT_MDM; i < MAX_PORT; i++) {
+               if (kfifo_alloc(&dc->port[i].fifo_ul,
+                     FIFO_BUFFER_SIZE_UL, GFP_ATOMIC)) {
+                       dev_err(&pdev->dev,
+                                       "Could not allocate kfifo buffer\n");
+                       ret = -ENOMEM;
+                       goto err_free_kfifo;
+               }
+       }
+
        spin_lock_init(&dc->spin_mutex);
 
        nozomi_setup_private_data(dc);
@@ -1445,7 +1453,7 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
                        NOZOMI_NAME, dc);
        if (unlikely(ret)) {
                dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq);
-               goto err_free_sbuf;
+               goto err_free_kfifo;
        }
 
        DBG1("base_addr: %p", dc->base_addr);
@@ -1464,13 +1472,28 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
        dc->state = NOZOMI_STATE_ENABLED;
 
        for (i = 0; i < MAX_PORT; i++) {
+               struct device *tty_dev;
+
                mutex_init(&dc->port[i].tty_sem);
                tty_port_init(&dc->port[i].port);
-               tty_register_device(ntty_driver, dc->index_start + i,
+               tty_dev = tty_register_device(ntty_driver, dc->index_start + i,
                                                        &pdev->dev);
+
+               if (IS_ERR(tty_dev)) {
+                       ret = PTR_ERR(tty_dev);
+                       dev_err(&pdev->dev, "Could not allocate tty?\n");
+                       goto err_free_tty;
+               }
        }
+
        return 0;
 
+err_free_tty:
+       for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i)
+               tty_unregister_device(ntty_driver, i);
+err_free_kfifo:
+       for (i = 0; i < MAX_PORT; i++)
+               kfifo_free(&dc->port[i].fifo_ul);
 err_free_sbuf:
        kfree(dc->send_buf);
        iounmap(dc->base_addr);
@@ -1536,8 +1559,7 @@ static void __devexit nozomi_card_exit(struct pci_dev *pdev)
        free_irq(pdev->irq, dc);
 
        for (i = 0; i < MAX_PORT; i++)
-               if (dc->port[i].fifo_ul)
-                       kfifo_free(dc->port[i].fifo_ul);
+               kfifo_free(&dc->port[i].fifo_ul);
 
        kfree(dc->send_buf);
 
@@ -1673,7 +1695,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
                goto exit;
        }
 
-       rval = __kfifo_put(port->fifo_ul, (unsigned char *)buffer, count);
+       rval = kfifo_in(&port->fifo_ul, (unsigned char *)buffer, count);
 
        /* notify card */
        if (unlikely(dc == NULL)) {
@@ -1721,7 +1743,7 @@ static int ntty_write_room(struct tty_struct *tty)
        if (!port->port.count)
                goto exit;
 
-       room = port->fifo_ul->size - __kfifo_len(port->fifo_ul);
+       room = port->fifo_ul.size - kfifo_len(&port->fifo_ul);
 
 exit:
        mutex_unlock(&port->tty_sem);
@@ -1878,7 +1900,7 @@ static s32 ntty_chars_in_buffer(struct tty_struct *tty)
                goto exit_in_buffer;
        }
 
-       rval = __kfifo_len(port->fifo_ul);
+       rval = kfifo_len(&port->fifo_ul);
 
 exit_in_buffer:
        return rval;
index 8c7df5ba088f5e05fee54e507602463b15cddbf7..f80810901db66ba21d2243a713bfa274d5d5f3ef 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/mutex.h>
+#include <linux/jiffies.h>
 
 #include <asm/hardware/dec21285.h>
 #include <asm/io.h>
index dcd08635cf1b160e57e5ee250c9a5ae87eeee3d6..8258982b49ec3ab1551416ccd8e558d2f1c5e6df 100644 (file)
@@ -1245,12 +1245,8 @@ static int proc_do_uuid(ctl_table *table, int write,
        if (uuid[8] == 0)
                generate_random_uuid(uuid);
 
-       sprintf(buf, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
-               "%02x%02x%02x%02x%02x%02x",
-               uuid[0],  uuid[1],  uuid[2],  uuid[3],
-               uuid[4],  uuid[5],  uuid[6],  uuid[7],
-               uuid[8],  uuid[9],  uuid[10], uuid[11],
-               uuid[12], uuid[13], uuid[14], uuid[15]);
+       sprintf(buf, "%pU", uuid);
+
        fake_table.data = buf;
        fake_table.maxlen = sizeof(buf);
 
@@ -1310,7 +1306,7 @@ ctl_table random_table[] = {
 
 /********************************************************************
  *
- * Random funtions for networking
+ * Random functions for networking
  *
  ********************************************************************/
 
index 8c262aaf7c26e2edd5d414e06498871762773120..0798754a607cea4dbf6414f3b3cff0792108f731 100644 (file)
@@ -487,7 +487,7 @@ static struct sonypi_device {
        int camera_power;
        int bluetooth_power;
        struct mutex lock;
-       struct kfifo *fifo;
+       struct kfifo fifo;
        spinlock_t fifo_lock;
        wait_queue_head_t fifo_proc_list;
        struct fasync_struct *fifo_async;
@@ -496,7 +496,7 @@ static struct sonypi_device {
        struct input_dev *input_jog_dev;
        struct input_dev *input_key_dev;
        struct work_struct input_work;
-       struct kfifo *input_fifo;
+       struct kfifo input_fifo;
        spinlock_t input_fifo_lock;
 } sonypi_device;
 
@@ -777,8 +777,9 @@ static void input_keyrelease(struct work_struct *work)
 {
        struct sonypi_keypress kp;
 
-       while (kfifo_get(sonypi_device.input_fifo, (unsigned char *)&kp,
-                        sizeof(kp)) == sizeof(kp)) {
+       while (kfifo_out_locked(&sonypi_device.input_fifo, (unsigned char *)&kp,
+                        sizeof(kp), &sonypi_device.input_fifo_lock)
+                       == sizeof(kp)) {
                msleep(10);
                input_report_key(kp.dev, kp.key, 0);
                input_sync(kp.dev);
@@ -827,8 +828,9 @@ static void sonypi_report_input_event(u8 event)
        if (kp.dev) {
                input_report_key(kp.dev, kp.key, 1);
                input_sync(kp.dev);
-               kfifo_put(sonypi_device.input_fifo,
-                         (unsigned char *)&kp, sizeof(kp));
+               kfifo_in_locked(&sonypi_device.input_fifo,
+                       (unsigned char *)&kp, sizeof(kp),
+                       &sonypi_device.input_fifo_lock);
                schedule_work(&sonypi_device.input_work);
        }
 }
@@ -880,7 +882,8 @@ found:
                acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event);
 #endif
 
-       kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event));
+       kfifo_in_locked(&sonypi_device.fifo, (unsigned char *)&event,
+                       sizeof(event), &sonypi_device.fifo_lock);
        kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
        wake_up_interruptible(&sonypi_device.fifo_proc_list);
 
@@ -906,7 +909,7 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
        mutex_lock(&sonypi_device.lock);
        /* Flush input queue on first open */
        if (!sonypi_device.open_count)
-               kfifo_reset(sonypi_device.fifo);
+               kfifo_reset(&sonypi_device.fifo);
        sonypi_device.open_count++;
        mutex_unlock(&sonypi_device.lock);
        unlock_kernel();
@@ -919,17 +922,18 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
        ssize_t ret;
        unsigned char c;
 
-       if ((kfifo_len(sonypi_device.fifo) == 0) &&
+       if ((kfifo_len(&sonypi_device.fifo) == 0) &&
            (file->f_flags & O_NONBLOCK))
                return -EAGAIN;
 
        ret = wait_event_interruptible(sonypi_device.fifo_proc_list,
-                                      kfifo_len(sonypi_device.fifo) != 0);
+                                      kfifo_len(&sonypi_device.fifo) != 0);
        if (ret)
                return ret;
 
        while (ret < count &&
-              (kfifo_get(sonypi_device.fifo, &c, sizeof(c)) == sizeof(c))) {
+              (kfifo_out_locked(&sonypi_device.fifo, &c, sizeof(c),
+                                &sonypi_device.fifo_lock) == sizeof(c))) {
                if (put_user(c, buf++))
                        return -EFAULT;
                ret++;
@@ -946,7 +950,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
 static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait)
 {
        poll_wait(file, &sonypi_device.fifo_proc_list, wait);
-       if (kfifo_len(sonypi_device.fifo))
+       if (kfifo_len(&sonypi_device.fifo))
                return POLLIN | POLLRDNORM;
        return 0;
 }
@@ -1313,11 +1317,10 @@ static int __devinit sonypi_probe(struct platform_device *dev)
                        "http://www.linux.it/~malattia/wiki/index.php/Sony_drivers\n");
 
        spin_lock_init(&sonypi_device.fifo_lock);
-       sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
-                                        &sonypi_device.fifo_lock);
-       if (IS_ERR(sonypi_device.fifo)) {
+       error = kfifo_alloc(&sonypi_device.fifo, SONYPI_BUF_SIZE, GFP_KERNEL);
+       if (error) {
                printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
-               return PTR_ERR(sonypi_device.fifo);
+               return error;
        }
 
        init_waitqueue_head(&sonypi_device.fifo_proc_list);
@@ -1393,12 +1396,10 @@ static int __devinit sonypi_probe(struct platform_device *dev)
                }
 
                spin_lock_init(&sonypi_device.input_fifo_lock);
-               sonypi_device.input_fifo =
-                       kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL,
-                                   &sonypi_device.input_fifo_lock);
-               if (IS_ERR(sonypi_device.input_fifo)) {
+               error = kfifo_alloc(&sonypi_device.input_fifo, SONYPI_BUF_SIZE,
+                               GFP_KERNEL);
+               if (error) {
                        printk(KERN_ERR "sonypi: kfifo_alloc failed\n");
-                       error = PTR_ERR(sonypi_device.input_fifo);
                        goto err_inpdev_unregister;
                }
 
@@ -1423,7 +1424,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
                pci_disable_device(pcidev);
  err_put_pcidev:
        pci_dev_put(pcidev);
-       kfifo_free(sonypi_device.fifo);
+       kfifo_free(&sonypi_device.fifo);
 
        return error;
 }
@@ -1438,7 +1439,7 @@ static int __devexit sonypi_remove(struct platform_device *dev)
        if (useinput) {
                input_unregister_device(sonypi_device.input_key_dev);
                input_unregister_device(sonypi_device.input_jog_dev);
-               kfifo_free(sonypi_device.input_fifo);
+               kfifo_free(&sonypi_device.input_fifo);
        }
 
        misc_deregister(&sonypi_misc_device);
@@ -1451,7 +1452,7 @@ static int __devexit sonypi_remove(struct platform_device *dev)
                pci_dev_put(sonypi_device.dev);
        }
 
-       kfifo_free(sonypi_device.fifo);
+       kfifo_free(&sonypi_device.fifo);
 
        return 0;
 }
index 44203ff599daa10420407265db91f88116473413..1ae2de7d8b4f333bed6a3bc5e2e63460cb4e1336 100644 (file)
@@ -339,7 +339,7 @@ static struct sysrq_key_op sysrq_term_op = {
 
 static void moom_callback(struct work_struct *ignored)
 {
-       out_of_memory(node_zonelist(0, GFP_KERNEL), GFP_KERNEL, 0);
+       out_of_memory(node_zonelist(0, GFP_KERNEL), GFP_KERNEL, 0, NULL);
 }
 
 static DECLARE_WORK(moom_work, moom_callback);
index 1e3d728dbf7e15a9c15664562c1057a376f33434..50faa1fb0f06f57f419e96f5e9c974d6a7d08b70 100644 (file)
@@ -164,6 +164,9 @@ module_param(default_utf8, int, S_IRUGO | S_IWUSR);
 int global_cursor_default = -1;
 module_param(global_cursor_default, int, S_IRUGO | S_IWUSR);
 
+static int cur_default = CUR_DEFAULT;
+module_param(cur_default, int, S_IRUGO | S_IWUSR);
+
 /*
  * ignore_poke: don't unblank the screen when things are typed.  This is
  * mainly for the privacy of braille terminal users.
@@ -184,12 +187,10 @@ static DECLARE_WORK(console_work, console_callback);
  * fg_console is the current virtual console,
  * last_console is the last used one,
  * want_console is the console we want to switch to,
- * kmsg_redirect is the console for kernel messages,
  */
 int fg_console;
 int last_console;
 int want_console = -1;
-int kmsg_redirect;
 
 /*
  * For each existing display, we have a pointer to console currently visible
@@ -1638,7 +1639,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear)
        /* do not do set_leds here because this causes an endless tasklet loop
           when the keyboard hasn't been initialized yet */
 
-       vc->vc_cursor_type = CUR_DEFAULT;
+       vc->vc_cursor_type = cur_default;
        vc->vc_complement_mask = vc->vc_s_complement_mask;
 
        default_attr(vc);
@@ -1840,7 +1841,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
                                if (vc->vc_par[0])
                                        vc->vc_cursor_type = vc->vc_par[0] | (vc->vc_par[1] << 8) | (vc->vc_par[2] << 16);
                                else
-                                       vc->vc_cursor_type = CUR_DEFAULT;
+                                       vc->vc_cursor_type = cur_default;
                                return;
                        }
                        break;
@@ -2434,6 +2435,37 @@ struct tty_driver *console_driver;
 
 #ifdef CONFIG_VT_CONSOLE
 
+/**
+ * vt_kmsg_redirect() - Sets/gets the kernel message console
+ * @new:       The new virtual terminal number or -1 if the console should stay
+ *             unchanged
+ *
+ * By default, the kernel messages are always printed on the current virtual
+ * console. However, the user may modify that default with the
+ * TIOCL_SETKMSGREDIRECT ioctl call.
+ *
+ * This function sets the kernel message console to be @new. It returns the old
+ * virtual console number. The virtual terminal number 0 (both as parameter and
+ * return value) means no redirection (i.e. always printed on the currently
+ * active console).
+ *
+ * The parameter -1 means that only the current console is returned, but the
+ * value is not modified. You may use the macro vt_get_kmsg_redirect() in that
+ * case to make the code more understandable.
+ *
+ * When the kernel is compiled without CONFIG_VT_CONSOLE, this function ignores
+ * the parameter and always returns 0.
+ */
+int vt_kmsg_redirect(int new)
+{
+       static int kmsg_con;
+
+       if (new != -1)
+               return xchg(&kmsg_con, new);
+       else
+               return kmsg_con;
+}
+
 /*
  *     Console on virtual terminal
  *
@@ -2448,6 +2480,7 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
        const ushort *start;
        ushort cnt = 0;
        ushort myx;
+       int kmsg_console;
 
        /* console busy or not yet initialized */
        if (!printable)
@@ -2455,8 +2488,9 @@ static void vt_console_print(struct console *co, const char *b, unsigned count)
        if (!spin_trylock(&printing_lock))
                return;
 
-       if (kmsg_redirect && vc_cons_allocated(kmsg_redirect - 1))
-               vc = vc_cons[kmsg_redirect - 1].d;
+       kmsg_console = vt_get_kmsg_redirect();
+       if (kmsg_console && vc_cons_allocated(kmsg_console - 1))
+               vc = vc_cons[kmsg_console - 1].d;
 
        /* read `x' only after setting currcons properly (otherwise
           the `x' macro will read the x of the foreground console). */
@@ -2613,7 +2647,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
                        ret = set_vesa_blanking(p);
                        break;
                case TIOCL_GETKMSGREDIRECT:
-                       data = kmsg_redirect;
+                       data = vt_get_kmsg_redirect();
                        ret = __put_user(data, p);
                        break;
                case TIOCL_SETKMSGREDIRECT:
@@ -2623,7 +2657,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
                                if (get_user(data, p+1))
                                        ret = -EFAULT;
                                else
-                                       kmsg_redirect = data;
+                                       vt_kmsg_redirect(data);
                        }
                        break;
                case TIOCL_GETFGCONSOLE:
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
new file mode 100644 (file)
index 0000000..08f726c
--- /dev/null
@@ -0,0 +1,9 @@
+config CS5535_CLOCK_EVENT_SRC
+       tristate "CS5535/CS5536 high-res timer (MFGPT) events"
+       depends on GENERIC_TIME && GENERIC_CLOCKEVENTS && CS5535_MFGPT
+       help
+         This driver provides a clock event source based on the MFGPT
+         timer(s) in the CS5535 and CS5536 companion chips.
+         MFGPTs have a better resolution and max interval than the
+         generic PIT, and are suitable for use as high-res timers.
+
index eef216f7f61d6a80ac57f435003b92f45b2b5579..be61ece6330bee0965ed3e8de273daa38946b984 100644 (file)
@@ -2,6 +2,7 @@ obj-$(CONFIG_ATMEL_TCB_CLKSRC)  += tcb_clksrc.o
 obj-$(CONFIG_X86_CYCLONE_TIMER)        += cyclone.o
 obj-$(CONFIG_X86_PM_TIMER)     += acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)   += scx200_hrt.o
+obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)   += cs5535-clockevt.o
 obj-$(CONFIG_SH_TIMER_CMT)     += sh_cmt.o
 obj-$(CONFIG_SH_TIMER_MTU2)    += sh_mtu2.o
 obj-$(CONFIG_SH_TIMER_TMU)     += sh_tmu.o
diff --git a/drivers/clocksource/cs5535-clockevt.c b/drivers/clocksource/cs5535-clockevt.c
new file mode 100644 (file)
index 0000000..27d20fa
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Clock event driver for the CS5535/CS5536
+ *
+ * Copyright (C) 2006, Advanced Micro Devices, Inc.
+ * Copyright (C) 2007  Andres Salomon <dilinger@debian.org>
+ * Copyright (C) 2009  Andres Salomon <dilinger@collabora.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * The MFGPTs are documented in AMD Geode CS5536 Companion Device Data Book.
+ */
+
+#include <linux/kernel.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/cs5535.h>
+#include <linux/clockchips.h>
+
+#define DRV_NAME "cs5535-clockevt"
+
+static int timer_irq = CONFIG_CS5535_MFGPT_DEFAULT_IRQ;
+module_param_named(irq, timer_irq, int, 0644);
+MODULE_PARM_DESC(irq, "Which IRQ to use for the clock source MFGPT ticks.");
+
+/*
+ * We are using the 32.768kHz input clock - it's the only one that has the
+ * ranges we find desirable.  The following table lists the suitable
+ * divisors and the associated Hz, minimum interval and the maximum interval:
+ *
+ *  Divisor   Hz      Min Delta (s)  Max Delta (s)
+ *   1        32768   .00048828125      2.000
+ *   2        16384   .0009765625       4.000
+ *   4         8192   .001953125        8.000
+ *   8         4096   .00390625        16.000
+ *   16        2048   .0078125         32.000
+ *   32        1024   .015625          64.000
+ *   64         512   .03125          128.000
+ *  128         256   .0625           256.000
+ *  256         128   .125            512.000
+ */
+
+static unsigned int cs5535_tick_mode = CLOCK_EVT_MODE_SHUTDOWN;
+static struct cs5535_mfgpt_timer *cs5535_event_clock;
+
+/* Selected from the table above */
+
+#define MFGPT_DIVISOR 16
+#define MFGPT_SCALE  4     /* divisor = 2^(scale) */
+#define MFGPT_HZ  (32768 / MFGPT_DIVISOR)
+#define MFGPT_PERIODIC (MFGPT_HZ / HZ)
+
+/*
+ * The MFPGT timers on the CS5536 provide us with suitable timers to use
+ * as clock event sources - not as good as a HPET or APIC, but certainly
+ * better than the PIT.  This isn't a general purpose MFGPT driver, but
+ * a simplified one designed specifically to act as a clock event source.
+ * For full details about the MFGPT, please consult the CS5536 data sheet.
+ */
+
+static void disable_timer(struct cs5535_mfgpt_timer *timer)
+{
+       /* avoid races by clearing CMP1 and CMP2 unconditionally */
+       cs5535_mfgpt_write(timer, MFGPT_REG_SETUP,
+                       (uint16_t) ~MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP1 |
+                               MFGPT_SETUP_CMP2);
+}
+
+static void start_timer(struct cs5535_mfgpt_timer *timer, uint16_t delta)
+{
+       cs5535_mfgpt_write(timer, MFGPT_REG_CMP2, delta);
+       cs5535_mfgpt_write(timer, MFGPT_REG_COUNTER, 0);
+
+       cs5535_mfgpt_write(timer, MFGPT_REG_SETUP,
+                       MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP2);
+}
+
+static void mfgpt_set_mode(enum clock_event_mode mode,
+               struct clock_event_device *evt)
+{
+       disable_timer(cs5535_event_clock);
+
+       if (mode == CLOCK_EVT_MODE_PERIODIC)
+               start_timer(cs5535_event_clock, MFGPT_PERIODIC);
+
+       cs5535_tick_mode = mode;
+}
+
+static int mfgpt_next_event(unsigned long delta, struct clock_event_device *evt)
+{
+       start_timer(cs5535_event_clock, delta);
+       return 0;
+}
+
+static struct clock_event_device cs5535_clockevent = {
+       .name = DRV_NAME,
+       .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
+       .set_mode = mfgpt_set_mode,
+       .set_next_event = mfgpt_next_event,
+       .rating = 250,
+       .cpumask = cpu_all_mask,
+       .shift = 32
+};
+
+static irqreturn_t mfgpt_tick(int irq, void *dev_id)
+{
+       uint16_t val = cs5535_mfgpt_read(cs5535_event_clock, MFGPT_REG_SETUP);
+
+       /* See if the interrupt was for us */
+       if (!(val & (MFGPT_SETUP_SETUP | MFGPT_SETUP_CMP2 | MFGPT_SETUP_CMP1)))
+               return IRQ_NONE;
+
+       /* Turn off the clock (and clear the event) */
+       disable_timer(cs5535_event_clock);
+
+       if (cs5535_tick_mode == CLOCK_EVT_MODE_SHUTDOWN)
+               return IRQ_HANDLED;
+
+       /* Clear the counter */
+       cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_COUNTER, 0);
+
+       /* Restart the clock in periodic mode */
+
+       if (cs5535_tick_mode == CLOCK_EVT_MODE_PERIODIC)
+               cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP,
+                               MFGPT_SETUP_CNTEN | MFGPT_SETUP_CMP2);
+
+       cs5535_clockevent.event_handler(&cs5535_clockevent);
+       return IRQ_HANDLED;
+}
+
+static struct irqaction mfgptirq  = {
+       .handler = mfgpt_tick,
+       .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_TIMER,
+       .name = DRV_NAME,
+};
+
+static int __init cs5535_mfgpt_init(void)
+{
+       struct cs5535_mfgpt_timer *timer;
+       int ret;
+       uint16_t val;
+
+       timer = cs5535_mfgpt_alloc_timer(MFGPT_TIMER_ANY, MFGPT_DOMAIN_WORKING);
+       if (!timer) {
+               printk(KERN_ERR DRV_NAME ": Could not allocate MFPGT timer\n");
+               return -ENODEV;
+       }
+       cs5535_event_clock = timer;
+
+       /* Set up the IRQ on the MFGPT side */
+       if (cs5535_mfgpt_setup_irq(timer, MFGPT_CMP2, &timer_irq)) {
+               printk(KERN_ERR DRV_NAME ": Could not set up IRQ %d\n",
+                               timer_irq);
+               return -EIO;
+       }
+
+       /* And register it with the kernel */
+       ret = setup_irq(timer_irq, &mfgptirq);
+       if (ret) {
+               printk(KERN_ERR DRV_NAME ": Unable to set up the interrupt.\n");
+               goto err;
+       }
+
+       /* Set the clock scale and enable the event mode for CMP2 */
+       val = MFGPT_SCALE | (3 << 8);
+
+       cs5535_mfgpt_write(cs5535_event_clock, MFGPT_REG_SETUP, val);
+
+       /* Set up the clock event */
+       cs5535_clockevent.mult = div_sc(MFGPT_HZ, NSEC_PER_SEC,
+                       cs5535_clockevent.shift);
+       cs5535_clockevent.min_delta_ns = clockevent_delta2ns(0xF,
+                       &cs5535_clockevent);
+       cs5535_clockevent.max_delta_ns = clockevent_delta2ns(0xFFFE,
+                       &cs5535_clockevent);
+
+       printk(KERN_INFO DRV_NAME
+               ": Registering MFGPT timer as a clock event, using IRQ %d\n",
+               timer_irq);
+       clockevents_register_device(&cs5535_clockevent);
+
+       return 0;
+
+err:
+       cs5535_mfgpt_release_irq(cs5535_event_clock, MFGPT_CMP2, &timer_irq);
+       printk(KERN_ERR DRV_NAME ": Unable to set up the MFGPT clock source\n");
+       return -EIO;
+}
+
+module_init(cs5535_mfgpt_init);
+
+MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>");
+MODULE_DESCRIPTION("CS5535/CS5536 MFGPT clock event driver");
+MODULE_LICENSE("GPL");
index a4bec3f919aa7cb98ddaf8f6f7121dc4d2f4781a..1c1ceb4f218f6299716b6318c3dd593d7b9f3b94 100644 (file)
@@ -69,9 +69,6 @@ static int ladder_select_state(struct cpuidle_device *dev)
        int last_residency, last_idx = ldev->last_state_idx;
        int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY);
 
-       if (unlikely(!ldev))
-               return 0;
-
        /* Special case when user has set very strict latency requirement */
        if (unlikely(latency_req == 0)) {
                ladder_do_selection(ldev, last_idx, 0);
index eb140ff38c27e5be88932c068efe032221c1f69a..e02d74b1e8922ae44a3817699937b6a08090e038 100644 (file)
@@ -111,6 +111,24 @@ config SH_DMAE
        help
          Enable support for the Renesas SuperH DMA controllers.
 
+config COH901318
+       bool "ST-Ericsson COH901318 DMA support"
+       select DMA_ENGINE
+       depends on ARCH_U300
+       help
+         Enable support for ST-Ericsson COH 901 318 DMA.
+
+config AMCC_PPC440SPE_ADMA
+       tristate "AMCC PPC440SPe ADMA support"
+       depends on 440SPe || 440SP
+       select DMA_ENGINE
+       select ARCH_HAS_ASYNC_TX_FIND_CHANNEL
+       help
+         Enable support for the AMCC PPC440SPe RAID engines.
+
+config ARCH_HAS_ASYNC_TX_FIND_CHANNEL
+       bool
+
 config DMA_ENGINE
        bool
 
index eca71ba78ae9716234b46c30788f350ded01a692..807053d48232e61e8aa56a2ea79a91a6c797f4e3 100644 (file)
@@ -10,3 +10,5 @@ obj-$(CONFIG_AT_HDMAC) += at_hdmac.o
 obj-$(CONFIG_MX3_IPU) += ipu/
 obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o
 obj-$(CONFIG_SH_DMAE) += shdma.o
+obj-$(CONFIG_COH901318) += coh901318.o coh901318_lli.o
+obj-$(CONFIG_AMCC_PPC440SPE_ADMA) += ppc4xx/
index c52ac9efd0bf04547cf7882259daa369a31bf0fb..efc1a61ca2310bec0b517d20d7675c3f800f0717 100644 (file)
@@ -815,7 +815,7 @@ atc_is_tx_complete(struct dma_chan *chan,
        dev_vdbg(chan2dev(chan), "is_tx_complete: %d (d%d, u%d)\n",
                        cookie, done ? *done : 0, used ? *used : 0);
 
-       spin_lock_bh(atchan->lock);
+       spin_lock_bh(&atchan->lock);
 
        last_complete = atchan->completed_cookie;
        last_used = chan->cookie;
@@ -830,7 +830,7 @@ atc_is_tx_complete(struct dma_chan *chan,
                ret = dma_async_is_complete(cookie, last_complete, last_used);
        }
 
-       spin_unlock_bh(atchan->lock);
+       spin_unlock_bh(&atchan->lock);
 
        if (done)
                *done = last_complete;
@@ -1188,7 +1188,7 @@ static int at_dma_resume_noirq(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops at_dma_dev_pm_ops = {
+static const struct dev_pm_ops at_dma_dev_pm_ops = {
        .suspend_noirq = at_dma_suspend_noirq,
        .resume_noirq = at_dma_resume_noirq,
 };
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
new file mode 100644 (file)
index 0000000..b5f2ee0
--- /dev/null
@@ -0,0 +1,1325 @@
+/*
+ * driver/dma/coh901318.c
+ *
+ * Copyright (C) 2007-2009 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ * DMA driver for COH 901 318
+ * Author: Per Friden <per.friden@stericsson.com>
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h> /* printk() */
+#include <linux/fs.h> /* everything... */
+#include <linux/slab.h> /* kmalloc() */
+#include <linux/dmaengine.h>
+#include <linux/platform_device.h>
+#include <linux/device.h>
+#include <linux/irqreturn.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
+#include <linux/debugfs.h>
+#include <mach/coh901318.h>
+
+#include "coh901318_lli.h"
+
+#define COHC_2_DEV(cohc) (&cohc->chan.dev->device)
+
+#ifdef VERBOSE_DEBUG
+#define COH_DBG(x) ({ if (1) x; 0; })
+#else
+#define COH_DBG(x) ({ if (0) x; 0; })
+#endif
+
+struct coh901318_desc {
+       struct dma_async_tx_descriptor desc;
+       struct list_head node;
+       struct scatterlist *sg;
+       unsigned int sg_len;
+       struct coh901318_lli *data;
+       enum dma_data_direction dir;
+       int pending_irqs;
+       unsigned long flags;
+};
+
+struct coh901318_base {
+       struct device *dev;
+       void __iomem *virtbase;
+       struct coh901318_pool pool;
+       struct powersave pm;
+       struct dma_device dma_slave;
+       struct dma_device dma_memcpy;
+       struct coh901318_chan *chans;
+       struct coh901318_platform *platform;
+};
+
+struct coh901318_chan {
+       spinlock_t lock;
+       int allocated;
+       int completed;
+       int id;
+       int stopped;
+
+       struct work_struct free_work;
+       struct dma_chan chan;
+
+       struct tasklet_struct tasklet;
+
+       struct list_head active;
+       struct list_head queue;
+       struct list_head free;
+
+       unsigned long nbr_active_done;
+       unsigned long busy;
+       int pending_irqs;
+
+       struct coh901318_base *base;
+};
+
+static void coh901318_list_print(struct coh901318_chan *cohc,
+                                struct coh901318_lli *lli)
+{
+       struct coh901318_lli *l;
+       dma_addr_t addr =  virt_to_phys(lli);
+       int i = 0;
+
+       while (addr) {
+               l = phys_to_virt(addr);
+               dev_vdbg(COHC_2_DEV(cohc), "i %d, lli %p, ctrl 0x%x, src 0x%x"
+                        ", dst 0x%x, link 0x%x link_virt 0x%p\n",
+                        i, l, l->control, l->src_addr, l->dst_addr,
+                        l->link_addr, phys_to_virt(l->link_addr));
+               i++;
+               addr = l->link_addr;
+       }
+}
+
+#ifdef CONFIG_DEBUG_FS
+
+#define COH901318_DEBUGFS_ASSIGN(x, y) (x = y)
+
+static struct coh901318_base *debugfs_dma_base;
+static struct dentry *dma_dentry;
+
+static int coh901318_debugfs_open(struct inode *inode, struct file *file)
+{
+
+       file->private_data = inode->i_private;
+       return 0;
+}
+
+static int coh901318_debugfs_read(struct file *file, char __user *buf,
+                                 size_t count, loff_t *f_pos)
+{
+       u64 started_channels = debugfs_dma_base->pm.started_channels;
+       int pool_count = debugfs_dma_base->pool.debugfs_pool_counter;
+       int i;
+       int ret = 0;
+       char *dev_buf;
+       char *tmp;
+       int dev_size;
+
+       dev_buf = kmalloc(4*1024, GFP_KERNEL);
+       if (dev_buf == NULL)
+               goto err_kmalloc;
+       tmp = dev_buf;
+
+       tmp += sprintf(tmp, "DMA -- enable dma channels\n");
+
+       for (i = 0; i < debugfs_dma_base->platform->max_channels; i++)
+               if (started_channels & (1 << i))
+                       tmp += sprintf(tmp, "channel %d\n", i);
+
+       tmp += sprintf(tmp, "Pool alloc nbr %d\n", pool_count);
+       dev_size = tmp  - dev_buf;
+
+       /* No more to read if offset != 0 */
+       if (*f_pos > dev_size)
+               goto out;
+
+       if (count > dev_size - *f_pos)
+               count = dev_size - *f_pos;
+
+       if (copy_to_user(buf, dev_buf + *f_pos, count))
+               ret = -EINVAL;
+       ret = count;
+       *f_pos += count;
+
+ out:
+       kfree(dev_buf);
+       return ret;
+
+ err_kmalloc:
+       return 0;
+}
+
+static const struct file_operations coh901318_debugfs_status_operations = {
+       .owner          = THIS_MODULE,
+       .open           = coh901318_debugfs_open,
+       .read           = coh901318_debugfs_read,
+};
+
+
+static int __init init_coh901318_debugfs(void)
+{
+
+       dma_dentry = debugfs_create_dir("dma", NULL);
+
+       (void) debugfs_create_file("status",
+                                  S_IFREG | S_IRUGO,
+                                  dma_dentry, NULL,
+                                  &coh901318_debugfs_status_operations);
+       return 0;
+}
+
+static void __exit exit_coh901318_debugfs(void)
+{
+       debugfs_remove_recursive(dma_dentry);
+}
+
+module_init(init_coh901318_debugfs);
+module_exit(exit_coh901318_debugfs);
+#else
+
+#define COH901318_DEBUGFS_ASSIGN(x, y)
+
+#endif /* CONFIG_DEBUG_FS */
+
+static inline struct coh901318_chan *to_coh901318_chan(struct dma_chan *chan)
+{
+       return container_of(chan, struct coh901318_chan, chan);
+}
+
+static inline dma_addr_t
+cohc_dev_addr(struct coh901318_chan *cohc)
+{
+       return cohc->base->platform->chan_conf[cohc->id].dev_addr;
+}
+
+static inline const struct coh901318_params *
+cohc_chan_param(struct coh901318_chan *cohc)
+{
+       return &cohc->base->platform->chan_conf[cohc->id].param;
+}
+
+static inline const struct coh_dma_channel *
+cohc_chan_conf(struct coh901318_chan *cohc)
+{
+       return &cohc->base->platform->chan_conf[cohc->id];
+}
+
+static void enable_powersave(struct coh901318_chan *cohc)
+{
+       unsigned long flags;
+       struct powersave *pm = &cohc->base->pm;
+
+       spin_lock_irqsave(&pm->lock, flags);
+
+       pm->started_channels &= ~(1ULL << cohc->id);
+
+       if (!pm->started_channels) {
+               /* DMA no longer intends to access memory */
+               cohc->base->platform->access_memory_state(cohc->base->dev,
+                                                         false);
+       }
+
+       spin_unlock_irqrestore(&pm->lock, flags);
+}
+static void disable_powersave(struct coh901318_chan *cohc)
+{
+       unsigned long flags;
+       struct powersave *pm = &cohc->base->pm;
+
+       spin_lock_irqsave(&pm->lock, flags);
+
+       if (!pm->started_channels) {
+               /* DMA intends to access memory */
+               cohc->base->platform->access_memory_state(cohc->base->dev,
+                                                         true);
+       }
+
+       pm->started_channels |= (1ULL << cohc->id);
+
+       spin_unlock_irqrestore(&pm->lock, flags);
+}
+
+static inline int coh901318_set_ctrl(struct coh901318_chan *cohc, u32 control)
+{
+       int channel = cohc->id;
+       void __iomem *virtbase = cohc->base->virtbase;
+
+       writel(control,
+              virtbase + COH901318_CX_CTRL +
+              COH901318_CX_CTRL_SPACING * channel);
+       return 0;
+}
+
+static inline int coh901318_set_conf(struct coh901318_chan *cohc, u32 conf)
+{
+       int channel = cohc->id;
+       void __iomem *virtbase = cohc->base->virtbase;
+
+       writel(conf,
+              virtbase + COH901318_CX_CFG +
+              COH901318_CX_CFG_SPACING*channel);
+       return 0;
+}
+
+
+static int coh901318_start(struct coh901318_chan *cohc)
+{
+       u32 val;
+       int channel = cohc->id;
+       void __iomem *virtbase = cohc->base->virtbase;
+
+       disable_powersave(cohc);
+
+       val = readl(virtbase + COH901318_CX_CFG +
+                   COH901318_CX_CFG_SPACING * channel);
+
+       /* Enable channel */
+       val |= COH901318_CX_CFG_CH_ENABLE;
+       writel(val, virtbase + COH901318_CX_CFG +
+              COH901318_CX_CFG_SPACING * channel);
+
+       return 0;
+}
+
+static int coh901318_prep_linked_list(struct coh901318_chan *cohc,
+                                     struct coh901318_lli *data)
+{
+       int channel = cohc->id;
+       void __iomem *virtbase = cohc->base->virtbase;
+
+       BUG_ON(readl(virtbase + COH901318_CX_STAT +
+                    COH901318_CX_STAT_SPACING*channel) &
+              COH901318_CX_STAT_ACTIVE);
+
+       writel(data->src_addr,
+              virtbase + COH901318_CX_SRC_ADDR +
+              COH901318_CX_SRC_ADDR_SPACING * channel);
+
+       writel(data->dst_addr, virtbase +
+              COH901318_CX_DST_ADDR +
+              COH901318_CX_DST_ADDR_SPACING * channel);
+
+       writel(data->link_addr, virtbase + COH901318_CX_LNK_ADDR +
+              COH901318_CX_LNK_ADDR_SPACING * channel);
+
+       writel(data->control, virtbase + COH901318_CX_CTRL +
+              COH901318_CX_CTRL_SPACING * channel);
+
+       return 0;
+}
+static dma_cookie_t
+coh901318_assign_cookie(struct coh901318_chan *cohc,
+                       struct coh901318_desc *cohd)
+{
+       dma_cookie_t cookie = cohc->chan.cookie;
+
+       if (++cookie < 0)
+               cookie = 1;
+
+       cohc->chan.cookie = cookie;
+       cohd->desc.cookie = cookie;
+
+       return cookie;
+}
+
+static struct coh901318_desc *
+coh901318_desc_get(struct coh901318_chan *cohc)
+{
+       struct coh901318_desc *desc;
+
+       if (list_empty(&cohc->free)) {
+               /* alloc new desc because we're out of used ones
+                * TODO: alloc a pile of descs instead of just one,
+                * avoid many small allocations.
+                */
+               desc = kmalloc(sizeof(struct coh901318_desc), GFP_NOWAIT);
+               if (desc == NULL)
+                       goto out;
+               INIT_LIST_HEAD(&desc->node);
+       } else {
+               /* Reuse an old desc. */
+               desc = list_first_entry(&cohc->free,
+                                       struct coh901318_desc,
+                                       node);
+               list_del(&desc->node);
+       }
+
+ out:
+       return desc;
+}
+
+static void
+coh901318_desc_free(struct coh901318_chan *cohc, struct coh901318_desc *cohd)
+{
+       list_add_tail(&cohd->node, &cohc->free);
+}
+
+/* call with irq lock held */
+static void
+coh901318_desc_submit(struct coh901318_chan *cohc, struct coh901318_desc *desc)
+{
+       list_add_tail(&desc->node, &cohc->active);
+
+       BUG_ON(cohc->pending_irqs != 0);
+
+       cohc->pending_irqs = desc->pending_irqs;
+}
+
+static struct coh901318_desc *
+coh901318_first_active_get(struct coh901318_chan *cohc)
+{
+       struct coh901318_desc *d;
+
+       if (list_empty(&cohc->active))
+               return NULL;
+
+       d = list_first_entry(&cohc->active,
+                            struct coh901318_desc,
+                            node);
+       return d;
+}
+
+static void
+coh901318_desc_remove(struct coh901318_desc *cohd)
+{
+       list_del(&cohd->node);
+}
+
+static void
+coh901318_desc_queue(struct coh901318_chan *cohc, struct coh901318_desc *desc)
+{
+       list_add_tail(&desc->node, &cohc->queue);
+}
+
+static struct coh901318_desc *
+coh901318_first_queued(struct coh901318_chan *cohc)
+{
+       struct coh901318_desc *d;
+
+       if (list_empty(&cohc->queue))
+               return NULL;
+
+       d = list_first_entry(&cohc->queue,
+                            struct coh901318_desc,
+                            node);
+       return d;
+}
+
+/*
+ * DMA start/stop controls
+ */
+u32 coh901318_get_bytes_left(struct dma_chan *chan)
+{
+       unsigned long flags;
+       u32 ret;
+       struct coh901318_chan *cohc = to_coh901318_chan(chan);
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       /* Read transfer count value */
+       ret = readl(cohc->base->virtbase +
+                   COH901318_CX_CTRL+COH901318_CX_CTRL_SPACING *
+                   cohc->id) & COH901318_CX_CTRL_TC_VALUE_MASK;
+
+       spin_unlock_irqrestore(&cohc->lock, flags);
+
+       return ret;
+}
+EXPORT_SYMBOL(coh901318_get_bytes_left);
+
+
+/* Stops a transfer without losing data. Enables power save.
+   Use this function in conjunction with coh901318_continue(..)
+*/
+void coh901318_stop(struct dma_chan *chan)
+{
+       u32 val;
+       unsigned long flags;
+       struct coh901318_chan *cohc = to_coh901318_chan(chan);
+       int channel = cohc->id;
+       void __iomem *virtbase = cohc->base->virtbase;
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       /* Disable channel in HW */
+       val = readl(virtbase + COH901318_CX_CFG +
+                   COH901318_CX_CFG_SPACING * channel);
+
+       /* Stopping infinit transfer */
+       if ((val & COH901318_CX_CTRL_TC_ENABLE) == 0 &&
+           (val & COH901318_CX_CFG_CH_ENABLE))
+               cohc->stopped = 1;
+
+
+       val &= ~COH901318_CX_CFG_CH_ENABLE;
+       /* Enable twice, HW bug work around */
+       writel(val, virtbase + COH901318_CX_CFG +
+              COH901318_CX_CFG_SPACING * channel);
+       writel(val, virtbase + COH901318_CX_CFG +
+              COH901318_CX_CFG_SPACING * channel);
+
+       /* Spin-wait for it to actually go inactive */
+       while (readl(virtbase + COH901318_CX_STAT+COH901318_CX_STAT_SPACING *
+                    channel) & COH901318_CX_STAT_ACTIVE)
+               cpu_relax();
+
+       /* Check if we stopped an active job */
+       if ((readl(virtbase + COH901318_CX_CTRL+COH901318_CX_CTRL_SPACING *
+                  channel) & COH901318_CX_CTRL_TC_VALUE_MASK) > 0)
+               cohc->stopped = 1;
+
+       enable_powersave(cohc);
+
+       spin_unlock_irqrestore(&cohc->lock, flags);
+}
+EXPORT_SYMBOL(coh901318_stop);
+
+/* Continues a transfer that has been stopped via 300_dma_stop(..).
+   Power save is handled.
+*/
+void coh901318_continue(struct dma_chan *chan)
+{
+       u32 val;
+       unsigned long flags;
+       struct coh901318_chan *cohc = to_coh901318_chan(chan);
+       int channel = cohc->id;
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       disable_powersave(cohc);
+
+       if (cohc->stopped) {
+               /* Enable channel in HW */
+               val = readl(cohc->base->virtbase + COH901318_CX_CFG +
+                           COH901318_CX_CFG_SPACING * channel);
+
+               val |= COH901318_CX_CFG_CH_ENABLE;
+
+               writel(val, cohc->base->virtbase + COH901318_CX_CFG +
+                      COH901318_CX_CFG_SPACING*channel);
+
+               cohc->stopped = 0;
+       }
+
+       spin_unlock_irqrestore(&cohc->lock, flags);
+}
+EXPORT_SYMBOL(coh901318_continue);
+
+bool coh901318_filter_id(struct dma_chan *chan, void *chan_id)
+{
+       unsigned int ch_nr = (unsigned int) chan_id;
+
+       if (ch_nr == to_coh901318_chan(chan)->id)
+               return true;
+
+       return false;
+}
+EXPORT_SYMBOL(coh901318_filter_id);
+
+/*
+ * DMA channel allocation
+ */
+static int coh901318_config(struct coh901318_chan *cohc,
+                           struct coh901318_params *param)
+{
+       unsigned long flags;
+       const struct coh901318_params *p;
+       int channel = cohc->id;
+       void __iomem *virtbase = cohc->base->virtbase;
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       if (param)
+               p = param;
+       else
+               p = &cohc->base->platform->chan_conf[channel].param;
+
+       /* Clear any pending BE or TC interrupt */
+       if (channel < 32) {
+               writel(1 << channel, virtbase + COH901318_BE_INT_CLEAR1);
+               writel(1 << channel, virtbase + COH901318_TC_INT_CLEAR1);
+       } else {
+               writel(1 << (channel - 32), virtbase +
+                      COH901318_BE_INT_CLEAR2);
+               writel(1 << (channel - 32), virtbase +
+                      COH901318_TC_INT_CLEAR2);
+       }
+
+       coh901318_set_conf(cohc, p->config);
+       coh901318_set_ctrl(cohc, p->ctrl_lli_last);
+
+       spin_unlock_irqrestore(&cohc->lock, flags);
+
+       return 0;
+}
+
+/* must lock when calling this function
+ * start queued jobs, if any
+ * TODO: start all queued jobs in one go
+ *
+ * Returns descriptor if queued job is started otherwise NULL.
+ * If the queue is empty NULL is returned.
+ */
+static struct coh901318_desc *coh901318_queue_start(struct coh901318_chan *cohc)
+{
+       struct coh901318_desc *cohd_que;
+
+       /* start queued jobs, if any
+        * TODO: transmit all queued jobs in one go
+        */
+       cohd_que = coh901318_first_queued(cohc);
+
+       if (cohd_que != NULL) {
+               /* Remove from queue */
+               coh901318_desc_remove(cohd_que);
+               /* initiate DMA job */
+               cohc->busy = 1;
+
+               coh901318_desc_submit(cohc, cohd_que);
+
+               coh901318_prep_linked_list(cohc, cohd_que->data);
+
+               /* start dma job */
+               coh901318_start(cohc);
+
+       }
+
+       return cohd_que;
+}
+
+static void dma_tasklet(unsigned long data)
+{
+       struct coh901318_chan *cohc = (struct coh901318_chan *) data;
+       struct coh901318_desc *cohd_fin;
+       unsigned long flags;
+       dma_async_tx_callback callback;
+       void *callback_param;
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       /* get first active entry from list */
+       cohd_fin = coh901318_first_active_get(cohc);
+
+       BUG_ON(cohd_fin->pending_irqs == 0);
+
+       if (cohd_fin == NULL)
+               goto err;
+
+       cohd_fin->pending_irqs--;
+       cohc->completed = cohd_fin->desc.cookie;
+
+       BUG_ON(cohc->nbr_active_done && cohd_fin == NULL);
+
+       if (cohc->nbr_active_done == 0)
+               return;
+
+       if (!cohd_fin->pending_irqs) {
+               /* release the lli allocation*/
+               coh901318_lli_free(&cohc->base->pool, &cohd_fin->data);
+       }
+
+       dev_vdbg(COHC_2_DEV(cohc), "[%s] chan_id %d pending_irqs %d"
+                " nbr_active_done %ld\n", __func__,
+                cohc->id, cohc->pending_irqs, cohc->nbr_active_done);
+
+       /* callback to client */
+       callback = cohd_fin->desc.callback;
+       callback_param = cohd_fin->desc.callback_param;
+
+       if (!cohd_fin->pending_irqs) {
+               coh901318_desc_remove(cohd_fin);
+
+               /* return desc to free-list */
+               coh901318_desc_free(cohc, cohd_fin);
+       }
+
+       if (cohc->nbr_active_done)
+               cohc->nbr_active_done--;
+
+       if (cohc->nbr_active_done) {
+               if (cohc_chan_conf(cohc)->priority_high)
+                       tasklet_hi_schedule(&cohc->tasklet);
+               else
+                       tasklet_schedule(&cohc->tasklet);
+       }
+       spin_unlock_irqrestore(&cohc->lock, flags);
+
+       if (callback)
+               callback(callback_param);
+
+       return;
+
+ err:
+       spin_unlock_irqrestore(&cohc->lock, flags);
+       dev_err(COHC_2_DEV(cohc), "[%s] No active dma desc\n", __func__);
+}
+
+
+/* called from interrupt context */
+static void dma_tc_handle(struct coh901318_chan *cohc)
+{
+       BUG_ON(!cohc->allocated && (list_empty(&cohc->active) ||
+                                   list_empty(&cohc->queue)));
+
+       if (!cohc->allocated)
+               return;
+
+       BUG_ON(cohc->pending_irqs == 0);
+
+       cohc->pending_irqs--;
+       cohc->nbr_active_done++;
+
+       if (cohc->pending_irqs == 0 && coh901318_queue_start(cohc) == NULL)
+               cohc->busy = 0;
+
+       BUG_ON(list_empty(&cohc->active));
+
+       if (cohc_chan_conf(cohc)->priority_high)
+               tasklet_hi_schedule(&cohc->tasklet);
+       else
+               tasklet_schedule(&cohc->tasklet);
+}
+
+
+static irqreturn_t dma_irq_handler(int irq, void *dev_id)
+{
+       u32 status1;
+       u32 status2;
+       int i;
+       int ch;
+       struct coh901318_base *base  = dev_id;
+       struct coh901318_chan *cohc;
+       void __iomem *virtbase = base->virtbase;
+
+       status1 = readl(virtbase + COH901318_INT_STATUS1);
+       status2 = readl(virtbase + COH901318_INT_STATUS2);
+
+       if (unlikely(status1 == 0 && status2 == 0)) {
+               dev_warn(base->dev, "spurious DMA IRQ from no channel!\n");
+               return IRQ_HANDLED;
+       }
+
+       /* TODO: consider handle IRQ in tasklet here to
+        *       minimize interrupt latency */
+
+       /* Check the first 32 DMA channels for IRQ */
+       while (status1) {
+               /* Find first bit set, return as a number. */
+               i = ffs(status1) - 1;
+               ch = i;
+
+               cohc = &base->chans[ch];
+               spin_lock(&cohc->lock);
+
+               /* Mask off this bit */
+               status1 &= ~(1 << i);
+               /* Check the individual channel bits */
+               if (test_bit(i, virtbase + COH901318_BE_INT_STATUS1)) {
+                       dev_crit(COHC_2_DEV(cohc),
+                                "DMA bus error on channel %d!\n", ch);
+                       BUG_ON(1);
+                       /* Clear BE interrupt */
+                       __set_bit(i, virtbase + COH901318_BE_INT_CLEAR1);
+               } else {
+                       /* Caused by TC, really? */
+                       if (unlikely(!test_bit(i, virtbase +
+                                              COH901318_TC_INT_STATUS1))) {
+                               dev_warn(COHC_2_DEV(cohc),
+                                        "ignoring interrupt not caused by terminal count on channel %d\n", ch);
+                               /* Clear TC interrupt */
+                               BUG_ON(1);
+                               __set_bit(i, virtbase + COH901318_TC_INT_CLEAR1);
+                       } else {
+                               /* Enable powersave if transfer has finished */
+                               if (!(readl(virtbase + COH901318_CX_STAT +
+                                           COH901318_CX_STAT_SPACING*ch) &
+                                     COH901318_CX_STAT_ENABLED)) {
+                                       enable_powersave(cohc);
+                               }
+
+                               /* Must clear TC interrupt before calling
+                                * dma_tc_handle
+                                * in case tc_handle initate a new dma job
+                                */
+                               __set_bit(i, virtbase + COH901318_TC_INT_CLEAR1);
+
+                               dma_tc_handle(cohc);
+                       }
+               }
+               spin_unlock(&cohc->lock);
+       }
+
+       /* Check the remaining 32 DMA channels for IRQ */
+       while (status2) {
+               /* Find first bit set, return as a number. */
+               i = ffs(status2) - 1;
+               ch = i + 32;
+               cohc = &base->chans[ch];
+               spin_lock(&cohc->lock);
+
+               /* Mask off this bit */
+               status2 &= ~(1 << i);
+               /* Check the individual channel bits */
+               if (test_bit(i, virtbase + COH901318_BE_INT_STATUS2)) {
+                       dev_crit(COHC_2_DEV(cohc),
+                                "DMA bus error on channel %d!\n", ch);
+                       /* Clear BE interrupt */
+                       BUG_ON(1);
+                       __set_bit(i, virtbase + COH901318_BE_INT_CLEAR2);
+               } else {
+                       /* Caused by TC, really? */
+                       if (unlikely(!test_bit(i, virtbase +
+                                              COH901318_TC_INT_STATUS2))) {
+                               dev_warn(COHC_2_DEV(cohc),
+                                        "ignoring interrupt not caused by terminal count on channel %d\n", ch);
+                               /* Clear TC interrupt */
+                               __set_bit(i, virtbase + COH901318_TC_INT_CLEAR2);
+                               BUG_ON(1);
+                       } else {
+                               /* Enable powersave if transfer has finished */
+                               if (!(readl(virtbase + COH901318_CX_STAT +
+                                           COH901318_CX_STAT_SPACING*ch) &
+                                     COH901318_CX_STAT_ENABLED)) {
+                                       enable_powersave(cohc);
+                               }
+                               /* Must clear TC interrupt before calling
+                                * dma_tc_handle
+                                * in case tc_handle initate a new dma job
+                                */
+                               __set_bit(i, virtbase + COH901318_TC_INT_CLEAR2);
+
+                               dma_tc_handle(cohc);
+                       }
+               }
+               spin_unlock(&cohc->lock);
+       }
+
+       return IRQ_HANDLED;
+}
+
+static int coh901318_alloc_chan_resources(struct dma_chan *chan)
+{
+       struct coh901318_chan   *cohc = to_coh901318_chan(chan);
+
+       dev_vdbg(COHC_2_DEV(cohc), "[%s] DMA channel %d\n",
+                __func__, cohc->id);
+
+       if (chan->client_count > 1)
+               return -EBUSY;
+
+       coh901318_config(cohc, NULL);
+
+       cohc->allocated = 1;
+       cohc->completed = chan->cookie = 1;
+
+       return 1;
+}
+
+static void
+coh901318_free_chan_resources(struct dma_chan *chan)
+{
+       struct coh901318_chan   *cohc = to_coh901318_chan(chan);
+       int channel = cohc->id;
+       unsigned long flags;
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       /* Disable HW */
+       writel(0x00000000U, cohc->base->virtbase + COH901318_CX_CFG +
+              COH901318_CX_CFG_SPACING*channel);
+       writel(0x00000000U, cohc->base->virtbase + COH901318_CX_CTRL +
+              COH901318_CX_CTRL_SPACING*channel);
+
+       cohc->allocated = 0;
+
+       spin_unlock_irqrestore(&cohc->lock, flags);
+
+       chan->device->device_terminate_all(chan);
+}
+
+
+static dma_cookie_t
+coh901318_tx_submit(struct dma_async_tx_descriptor *tx)
+{
+       struct coh901318_desc *cohd = container_of(tx, struct coh901318_desc,
+                                                  desc);
+       struct coh901318_chan *cohc = to_coh901318_chan(tx->chan);
+       unsigned long flags;
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       tx->cookie = coh901318_assign_cookie(cohc, cohd);
+
+       coh901318_desc_queue(cohc, cohd);
+
+       spin_unlock_irqrestore(&cohc->lock, flags);
+
+       return tx->cookie;
+}
+
+static struct dma_async_tx_descriptor *
+coh901318_prep_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
+                     size_t size, unsigned long flags)
+{
+       struct coh901318_lli *data;
+       struct coh901318_desc *cohd;
+       unsigned long flg;
+       struct coh901318_chan *cohc = to_coh901318_chan(chan);
+       int lli_len;
+       u32 ctrl_last = cohc_chan_param(cohc)->ctrl_lli_last;
+
+       spin_lock_irqsave(&cohc->lock, flg);
+
+       dev_vdbg(COHC_2_DEV(cohc),
+                "[%s] channel %d src 0x%x dest 0x%x size %d\n",
+                __func__, cohc->id, src, dest, size);
+
+       if (flags & DMA_PREP_INTERRUPT)
+               /* Trigger interrupt after last lli */
+               ctrl_last |= COH901318_CX_CTRL_TC_IRQ_ENABLE;
+
+       lli_len = size >> MAX_DMA_PACKET_SIZE_SHIFT;
+       if ((lli_len << MAX_DMA_PACKET_SIZE_SHIFT) < size)
+               lli_len++;
+
+       data = coh901318_lli_alloc(&cohc->base->pool, lli_len);
+
+       if (data == NULL)
+               goto err;
+
+       cohd = coh901318_desc_get(cohc);
+       cohd->sg = NULL;
+       cohd->sg_len = 0;
+       cohd->data = data;
+
+       cohd->pending_irqs =
+               coh901318_lli_fill_memcpy(
+                               &cohc->base->pool, data, src, size, dest,
+                               cohc_chan_param(cohc)->ctrl_lli_chained,
+                               ctrl_last);
+       cohd->flags = flags;
+
+       COH_DBG(coh901318_list_print(cohc, data));
+
+       dma_async_tx_descriptor_init(&cohd->desc, chan);
+
+       cohd->desc.tx_submit = coh901318_tx_submit;
+
+       spin_unlock_irqrestore(&cohc->lock, flg);
+
+       return &cohd->desc;
+ err:
+       spin_unlock_irqrestore(&cohc->lock, flg);
+       return NULL;
+}
+
+static struct dma_async_tx_descriptor *
+coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
+                       unsigned int sg_len, enum dma_data_direction direction,
+                       unsigned long flags)
+{
+       struct coh901318_chan *cohc = to_coh901318_chan(chan);
+       struct coh901318_lli *data;
+       struct coh901318_desc *cohd;
+       struct scatterlist *sg;
+       int len = 0;
+       int size;
+       int i;
+       u32 ctrl_chained = cohc_chan_param(cohc)->ctrl_lli_chained;
+       u32 ctrl = cohc_chan_param(cohc)->ctrl_lli;
+       u32 ctrl_last = cohc_chan_param(cohc)->ctrl_lli_last;
+       unsigned long flg;
+
+       if (!sgl)
+               goto out;
+       if (sgl->length == 0)
+               goto out;
+
+       spin_lock_irqsave(&cohc->lock, flg);
+
+       dev_vdbg(COHC_2_DEV(cohc), "[%s] sg_len %d dir %d\n",
+                __func__, sg_len, direction);
+
+       if (flags & DMA_PREP_INTERRUPT)
+               /* Trigger interrupt after last lli */
+               ctrl_last |= COH901318_CX_CTRL_TC_IRQ_ENABLE;
+
+       cohd = coh901318_desc_get(cohc);
+       cohd->sg = NULL;
+       cohd->sg_len = 0;
+       cohd->dir = direction;
+
+       if (direction == DMA_TO_DEVICE) {
+               u32 tx_flags = COH901318_CX_CTRL_PRDD_SOURCE |
+                       COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE;
+
+               ctrl_chained |= tx_flags;
+               ctrl_last |= tx_flags;
+               ctrl |= tx_flags;
+       } else if (direction == DMA_FROM_DEVICE) {
+               u32 rx_flags = COH901318_CX_CTRL_PRDD_DEST |
+                       COH901318_CX_CTRL_DST_ADDR_INC_ENABLE;
+
+               ctrl_chained |= rx_flags;
+               ctrl_last |= rx_flags;
+               ctrl |= rx_flags;
+       } else
+               goto err_direction;
+
+       dma_async_tx_descriptor_init(&cohd->desc, chan);
+
+       cohd->desc.tx_submit = coh901318_tx_submit;
+
+
+       /* The dma only supports transmitting packages up to
+        * MAX_DMA_PACKET_SIZE. Calculate to total number of
+        * dma elemts required to send the entire sg list
+        */
+       for_each_sg(sgl, sg, sg_len, i) {
+               unsigned int factor;
+               size = sg_dma_len(sg);
+
+               if (size <= MAX_DMA_PACKET_SIZE) {
+                       len++;
+                       continue;
+               }
+
+               factor = size >> MAX_DMA_PACKET_SIZE_SHIFT;
+               if ((factor << MAX_DMA_PACKET_SIZE_SHIFT) < size)
+                       factor++;
+
+               len += factor;
+       }
+
+       data = coh901318_lli_alloc(&cohc->base->pool, len);
+
+       if (data == NULL)
+               goto err_dma_alloc;
+
+       /* initiate allocated data list */
+       cohd->pending_irqs =
+               coh901318_lli_fill_sg(&cohc->base->pool, data, sgl, sg_len,
+                                     cohc_dev_addr(cohc),
+                                     ctrl_chained,
+                                     ctrl,
+                                     ctrl_last,
+                                     direction, COH901318_CX_CTRL_TC_IRQ_ENABLE);
+       cohd->data = data;
+
+       cohd->flags = flags;
+
+       COH_DBG(coh901318_list_print(cohc, data));
+
+       spin_unlock_irqrestore(&cohc->lock, flg);
+
+       return &cohd->desc;
+ err_dma_alloc:
+ err_direction:
+       coh901318_desc_remove(cohd);
+       coh901318_desc_free(cohc, cohd);
+       spin_unlock_irqrestore(&cohc->lock, flg);
+ out:
+       return NULL;
+}
+
+static enum dma_status
+coh901318_is_tx_complete(struct dma_chan *chan,
+                        dma_cookie_t cookie, dma_cookie_t *done,
+                        dma_cookie_t *used)
+{
+       struct coh901318_chan *cohc = to_coh901318_chan(chan);
+       dma_cookie_t last_used;
+       dma_cookie_t last_complete;
+       int ret;
+
+       last_complete = cohc->completed;
+       last_used = chan->cookie;
+
+       ret = dma_async_is_complete(cookie, last_complete, last_used);
+
+       if (done)
+               *done = last_complete;
+       if (used)
+               *used = last_used;
+
+       return ret;
+}
+
+static void
+coh901318_issue_pending(struct dma_chan *chan)
+{
+       struct coh901318_chan *cohc = to_coh901318_chan(chan);
+       unsigned long flags;
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       /* Busy means that pending jobs are already being processed */
+       if (!cohc->busy)
+               coh901318_queue_start(cohc);
+
+       spin_unlock_irqrestore(&cohc->lock, flags);
+}
+
+static void
+coh901318_terminate_all(struct dma_chan *chan)
+{
+       unsigned long flags;
+       struct coh901318_chan *cohc = to_coh901318_chan(chan);
+       struct coh901318_desc *cohd;
+       void __iomem *virtbase = cohc->base->virtbase;
+
+       coh901318_stop(chan);
+
+       spin_lock_irqsave(&cohc->lock, flags);
+
+       /* Clear any pending BE or TC interrupt */
+       if (cohc->id < 32) {
+               writel(1 << cohc->id, virtbase + COH901318_BE_INT_CLEAR1);
+               writel(1 << cohc->id, virtbase + COH901318_TC_INT_CLEAR1);
+       } else {
+               writel(1 << (cohc->id - 32), virtbase +
+                      COH901318_BE_INT_CLEAR2);
+               writel(1 << (cohc->id - 32), virtbase +
+                      COH901318_TC_INT_CLEAR2);
+       }
+
+       enable_powersave(cohc);
+
+       while ((cohd = coh901318_first_active_get(cohc))) {
+               /* release the lli allocation*/
+               coh901318_lli_free(&cohc->base->pool, &cohd->data);
+
+               coh901318_desc_remove(cohd);
+
+               /* return desc to free-list */
+               coh901318_desc_free(cohc, cohd);
+       }
+
+       while ((cohd = coh901318_first_queued(cohc))) {
+               /* release the lli allocation*/
+               coh901318_lli_free(&cohc->base->pool, &cohd->data);
+
+               coh901318_desc_remove(cohd);
+
+               /* return desc to free-list */
+               coh901318_desc_free(cohc, cohd);
+       }
+
+
+       cohc->nbr_active_done = 0;
+       cohc->busy = 0;
+       cohc->pending_irqs = 0;
+
+       spin_unlock_irqrestore(&cohc->lock, flags);
+}
+void coh901318_base_init(struct dma_device *dma, const int *pick_chans,
+                        struct coh901318_base *base)
+{
+       int chans_i;
+       int i = 0;
+       struct coh901318_chan *cohc;
+
+       INIT_LIST_HEAD(&dma->channels);
+
+       for (chans_i = 0; pick_chans[chans_i] != -1; chans_i += 2) {
+               for (i = pick_chans[chans_i]; i <= pick_chans[chans_i+1]; i++) {
+                       cohc = &base->chans[i];
+
+                       cohc->base = base;
+                       cohc->chan.device = dma;
+                       cohc->id = i;
+
+                       /* TODO: do we really need this lock if only one
+                        * client is connected to each channel?
+                        */
+
+                       spin_lock_init(&cohc->lock);
+
+                       cohc->pending_irqs = 0;
+                       cohc->nbr_active_done = 0;
+                       cohc->busy = 0;
+                       INIT_LIST_HEAD(&cohc->free);
+                       INIT_LIST_HEAD(&cohc->active);
+                       INIT_LIST_HEAD(&cohc->queue);
+
+                       tasklet_init(&cohc->tasklet, dma_tasklet,
+                                    (unsigned long) cohc);
+
+                       list_add_tail(&cohc->chan.device_node,
+                                     &dma->channels);
+               }
+       }
+}
+
+static int __init coh901318_probe(struct platform_device *pdev)
+{
+       int err = 0;
+       struct coh901318_platform *pdata;
+       struct coh901318_base *base;
+       int irq;
+       struct resource *io;
+
+       io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!io)
+               goto err_get_resource;
+
+       /* Map DMA controller registers to virtual memory */
+       if (request_mem_region(io->start,
+                              resource_size(io),
+                              pdev->dev.driver->name) == NULL) {
+               err = -EBUSY;
+               goto err_request_mem;
+       }
+
+       pdata = pdev->dev.platform_data;
+       if (!pdata)
+               goto err_no_platformdata;
+
+       base = kmalloc(ALIGN(sizeof(struct coh901318_base), 4) +
+                      pdata->max_channels *
+                      sizeof(struct coh901318_chan),
+                      GFP_KERNEL);
+       if (!base)
+               goto err_alloc_coh_dma_channels;
+
+       base->chans = ((void *)base) + ALIGN(sizeof(struct coh901318_base), 4);
+
+       base->virtbase = ioremap(io->start, resource_size(io));
+       if (!base->virtbase) {
+               err = -ENOMEM;
+               goto err_no_ioremap;
+       }
+
+       base->dev = &pdev->dev;
+       base->platform = pdata;
+       spin_lock_init(&base->pm.lock);
+       base->pm.started_channels = 0;
+
+       COH901318_DEBUGFS_ASSIGN(debugfs_dma_base, base);
+
+       platform_set_drvdata(pdev, base);
+
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0)
+               goto err_no_irq;
+
+       err = request_irq(irq, dma_irq_handler, IRQF_DISABLED,
+                         "coh901318", base);
+       if (err) {
+               dev_crit(&pdev->dev,
+                        "Cannot allocate IRQ for DMA controller!\n");
+               goto err_request_irq;
+       }
+
+       err = coh901318_pool_create(&base->pool, &pdev->dev,
+                                   sizeof(struct coh901318_lli),
+                                   32);
+       if (err)
+               goto err_pool_create;
+
+       /* init channels for device transfers */
+       coh901318_base_init(&base->dma_slave,  base->platform->chans_slave,
+                           base);
+
+       dma_cap_zero(base->dma_slave.cap_mask);
+       dma_cap_set(DMA_SLAVE, base->dma_slave.cap_mask);
+
+       base->dma_slave.device_alloc_chan_resources = coh901318_alloc_chan_resources;
+       base->dma_slave.device_free_chan_resources = coh901318_free_chan_resources;
+       base->dma_slave.device_prep_slave_sg = coh901318_prep_slave_sg;
+       base->dma_slave.device_is_tx_complete = coh901318_is_tx_complete;
+       base->dma_slave.device_issue_pending = coh901318_issue_pending;
+       base->dma_slave.device_terminate_all = coh901318_terminate_all;
+       base->dma_slave.dev = &pdev->dev;
+
+       err = dma_async_device_register(&base->dma_slave);
+
+       if (err)
+               goto err_register_slave;
+
+       /* init channels for memcpy */
+       coh901318_base_init(&base->dma_memcpy, base->platform->chans_memcpy,
+                           base);
+
+       dma_cap_zero(base->dma_memcpy.cap_mask);
+       dma_cap_set(DMA_MEMCPY, base->dma_memcpy.cap_mask);
+
+       base->dma_memcpy.device_alloc_chan_resources = coh901318_alloc_chan_resources;
+       base->dma_memcpy.device_free_chan_resources = coh901318_free_chan_resources;
+       base->dma_memcpy.device_prep_dma_memcpy = coh901318_prep_memcpy;
+       base->dma_memcpy.device_is_tx_complete = coh901318_is_tx_complete;
+       base->dma_memcpy.device_issue_pending = coh901318_issue_pending;
+       base->dma_memcpy.device_terminate_all = coh901318_terminate_all;
+       base->dma_memcpy.dev = &pdev->dev;
+       err = dma_async_device_register(&base->dma_memcpy);
+
+       if (err)
+               goto err_register_memcpy;
+
+       dev_dbg(&pdev->dev, "Initialized COH901318 DMA on virtual base 0x%08x\n",
+               (u32) base->virtbase);
+
+       return err;
+
+ err_register_memcpy:
+       dma_async_device_unregister(&base->dma_slave);
+ err_register_slave:
+       coh901318_pool_destroy(&base->pool);
+ err_pool_create:
+       free_irq(platform_get_irq(pdev, 0), base);
+ err_request_irq:
+ err_no_irq:
+       iounmap(base->virtbase);
+ err_no_ioremap:
+       kfree(base);
+ err_alloc_coh_dma_channels:
+ err_no_platformdata:
+       release_mem_region(pdev->resource->start,
+                          resource_size(pdev->resource));
+ err_request_mem:
+ err_get_resource:
+       return err;
+}
+
+static int __exit coh901318_remove(struct platform_device *pdev)
+{
+       struct coh901318_base *base = platform_get_drvdata(pdev);
+
+       dma_async_device_unregister(&base->dma_memcpy);
+       dma_async_device_unregister(&base->dma_slave);
+       coh901318_pool_destroy(&base->pool);
+       free_irq(platform_get_irq(pdev, 0), base);
+       iounmap(base->virtbase);
+       kfree(base);
+       release_mem_region(pdev->resource->start,
+                          resource_size(pdev->resource));
+       return 0;
+}
+
+
+static struct platform_driver coh901318_driver = {
+       .remove = __exit_p(coh901318_remove),
+       .driver = {
+               .name   = "coh901318",
+       },
+};
+
+int __init coh901318_init(void)
+{
+       return platform_driver_probe(&coh901318_driver, coh901318_probe);
+}
+subsys_initcall(coh901318_init);
+
+void __exit coh901318_exit(void)
+{
+       platform_driver_unregister(&coh901318_driver);
+}
+module_exit(coh901318_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Per Friden");
diff --git a/drivers/dma/coh901318_lli.c b/drivers/dma/coh901318_lli.c
new file mode 100644 (file)
index 0000000..f5120f2
--- /dev/null
@@ -0,0 +1,318 @@
+/*
+ * driver/dma/coh901318_lli.c
+ *
+ * Copyright (C) 2007-2009 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ * Support functions for handling lli for dma
+ * Author: Per Friden <per.friden@stericsson.com>
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/spinlock.h>
+#include <linux/dmapool.h>
+#include <linux/memory.h>
+#include <mach/coh901318.h>
+
+#include "coh901318_lli.h"
+
+#if (defined(CONFIG_DEBUG_FS) && defined(CONFIG_U300_DEBUG))
+#define DEBUGFS_POOL_COUNTER_RESET(pool) (pool->debugfs_pool_counter = 0)
+#define DEBUGFS_POOL_COUNTER_ADD(pool, add) (pool->debugfs_pool_counter += add)
+#else
+#define DEBUGFS_POOL_COUNTER_RESET(pool)
+#define DEBUGFS_POOL_COUNTER_ADD(pool, add)
+#endif
+
+static struct coh901318_lli *
+coh901318_lli_next(struct coh901318_lli *data)
+{
+       if (data == NULL || data->link_addr == 0)
+               return NULL;
+
+       return (struct coh901318_lli *) data->virt_link_addr;
+}
+
+int coh901318_pool_create(struct coh901318_pool *pool,
+                         struct device *dev,
+                         size_t size, size_t align)
+{
+       spin_lock_init(&pool->lock);
+       pool->dev = dev;
+       pool->dmapool = dma_pool_create("lli_pool", dev, size, align, 0);
+
+       DEBUGFS_POOL_COUNTER_RESET(pool);
+       return 0;
+}
+
+int coh901318_pool_destroy(struct coh901318_pool *pool)
+{
+
+       dma_pool_destroy(pool->dmapool);
+       return 0;
+}
+
+struct coh901318_lli *
+coh901318_lli_alloc(struct coh901318_pool *pool, unsigned int len)
+{
+       int i;
+       struct coh901318_lli *head;
+       struct coh901318_lli *lli;
+       struct coh901318_lli *lli_prev;
+       dma_addr_t phy;
+
+       if (len == 0)
+               goto err;
+
+       spin_lock(&pool->lock);
+
+       head = dma_pool_alloc(pool->dmapool, GFP_NOWAIT, &phy);
+
+       if (head == NULL)
+               goto err;
+
+       DEBUGFS_POOL_COUNTER_ADD(pool, 1);
+
+       lli = head;
+       lli->phy_this = phy;
+
+       for (i = 1; i < len; i++) {
+               lli_prev = lli;
+
+               lli = dma_pool_alloc(pool->dmapool, GFP_NOWAIT, &phy);
+
+               if (lli == NULL)
+                       goto err_clean_up;
+
+               DEBUGFS_POOL_COUNTER_ADD(pool, 1);
+               lli->phy_this = phy;
+
+               lli_prev->link_addr = phy;
+               lli_prev->virt_link_addr = lli;
+       }
+
+       lli->link_addr = 0x00000000U;
+
+       spin_unlock(&pool->lock);
+
+       return head;
+
+ err:
+       spin_unlock(&pool->lock);
+       return NULL;
+
+ err_clean_up:
+       lli_prev->link_addr = 0x00000000U;
+       spin_unlock(&pool->lock);
+       coh901318_lli_free(pool, &head);
+       return NULL;
+}
+
+void coh901318_lli_free(struct coh901318_pool *pool,
+                       struct coh901318_lli **lli)
+{
+       struct coh901318_lli *l;
+       struct coh901318_lli *next;
+
+       if (lli == NULL)
+               return;
+
+       l = *lli;
+
+       if (l == NULL)
+               return;
+
+       spin_lock(&pool->lock);
+
+       while (l->link_addr) {
+               next = l->virt_link_addr;
+               dma_pool_free(pool->dmapool, l, l->phy_this);
+               DEBUGFS_POOL_COUNTER_ADD(pool, -1);
+               l = next;
+       }
+       dma_pool_free(pool->dmapool, l, l->phy_this);
+       DEBUGFS_POOL_COUNTER_ADD(pool, -1);
+
+       spin_unlock(&pool->lock);
+       *lli = NULL;
+}
+
+int
+coh901318_lli_fill_memcpy(struct coh901318_pool *pool,
+                         struct coh901318_lli *lli,
+                         dma_addr_t source, unsigned int size,
+                         dma_addr_t destination, u32 ctrl_chained,
+                         u32 ctrl_eom)
+{
+       int s = size;
+       dma_addr_t src = source;
+       dma_addr_t dst = destination;
+
+       lli->src_addr = src;
+       lli->dst_addr = dst;
+
+       while (lli->link_addr) {
+               lli->control = ctrl_chained | MAX_DMA_PACKET_SIZE;
+               lli->src_addr = src;
+               lli->dst_addr = dst;
+
+               s -= MAX_DMA_PACKET_SIZE;
+               lli = coh901318_lli_next(lli);
+
+               src += MAX_DMA_PACKET_SIZE;
+               dst += MAX_DMA_PACKET_SIZE;
+       }
+
+       lli->control = ctrl_eom | s;
+       lli->src_addr = src;
+       lli->dst_addr = dst;
+
+       /* One irq per single transfer */
+       return 1;
+}
+
+int
+coh901318_lli_fill_single(struct coh901318_pool *pool,
+                         struct coh901318_lli *lli,
+                         dma_addr_t buf, unsigned int size,
+                         dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl_eom,
+                         enum dma_data_direction dir)
+{
+       int s = size;
+       dma_addr_t src;
+       dma_addr_t dst;
+
+
+       if (dir == DMA_TO_DEVICE) {
+               src = buf;
+               dst = dev_addr;
+
+       } else if (dir == DMA_FROM_DEVICE) {
+
+               src = dev_addr;
+               dst = buf;
+       } else {
+               return -EINVAL;
+       }
+
+       while (lli->link_addr) {
+               size_t block_size = MAX_DMA_PACKET_SIZE;
+               lli->control = ctrl_chained | MAX_DMA_PACKET_SIZE;
+
+               /* If we are on the next-to-final block and there will
+                * be less than half a DMA packet left for the last
+                * block, then we want to make this block a little
+                * smaller to balance the sizes. This is meant to
+                * avoid too small transfers if the buffer size is
+                * (MAX_DMA_PACKET_SIZE*N + 1) */
+               if (s < (MAX_DMA_PACKET_SIZE + MAX_DMA_PACKET_SIZE/2))
+                       block_size = MAX_DMA_PACKET_SIZE/2;
+
+               s -= block_size;
+               lli->src_addr = src;
+               lli->dst_addr = dst;
+
+               lli = coh901318_lli_next(lli);
+
+               if (dir == DMA_TO_DEVICE)
+                       src += block_size;
+               else if (dir == DMA_FROM_DEVICE)
+                       dst += block_size;
+       }
+
+       lli->control = ctrl_eom | s;
+       lli->src_addr = src;
+       lli->dst_addr = dst;
+
+       /* One irq per single transfer */
+       return 1;
+}
+
+int
+coh901318_lli_fill_sg(struct coh901318_pool *pool,
+                     struct coh901318_lli *lli,
+                     struct scatterlist *sgl, unsigned int nents,
+                     dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl,
+                     u32 ctrl_last,
+                     enum dma_data_direction dir, u32 ctrl_irq_mask)
+{
+       int i;
+       struct scatterlist *sg;
+       u32 ctrl_sg;
+       dma_addr_t src = 0;
+       dma_addr_t dst = 0;
+       int nbr_of_irq = 0;
+       u32 bytes_to_transfer;
+       u32 elem_size;
+
+       if (lli == NULL)
+               goto err;
+
+       spin_lock(&pool->lock);
+
+       if (dir == DMA_TO_DEVICE)
+               dst = dev_addr;
+       else if (dir == DMA_FROM_DEVICE)
+               src = dev_addr;
+       else
+               goto err;
+
+       for_each_sg(sgl, sg, nents, i) {
+               if (sg_is_chain(sg)) {
+                       /* sg continues to the next sg-element don't
+                        * send ctrl_finish until the last
+                        * sg-element in the chain
+                        */
+                       ctrl_sg = ctrl_chained;
+               } else if (i == nents - 1)
+                       ctrl_sg = ctrl_last;
+               else
+                       ctrl_sg = ctrl ? ctrl : ctrl_last;
+
+
+               if ((ctrl_sg & ctrl_irq_mask))
+                       nbr_of_irq++;
+
+               if (dir == DMA_TO_DEVICE)
+                       /* increment source address */
+                       src = sg_dma_address(sg);
+               else
+                       /* increment destination address */
+                       dst =  sg_dma_address(sg);
+
+               bytes_to_transfer = sg_dma_len(sg);
+
+               while (bytes_to_transfer) {
+                       u32 val;
+
+                       if (bytes_to_transfer > MAX_DMA_PACKET_SIZE) {
+                               elem_size = MAX_DMA_PACKET_SIZE;
+                               val = ctrl_chained;
+                       } else {
+                               elem_size = bytes_to_transfer;
+                               val = ctrl_sg;
+                       }
+
+                       lli->control = val | elem_size;
+                       lli->src_addr = src;
+                       lli->dst_addr = dst;
+
+                       if (dir == DMA_FROM_DEVICE)
+                               dst += elem_size;
+                       else
+                               src += elem_size;
+
+                       BUG_ON(lli->link_addr & 3);
+
+                       bytes_to_transfer -= elem_size;
+                       lli = coh901318_lli_next(lli);
+               }
+
+       }
+       spin_unlock(&pool->lock);
+
+       /* There can be many IRQs per sg transfer */
+       return nbr_of_irq;
+ err:
+       spin_unlock(&pool->lock);
+       return -EINVAL;
+}
diff --git a/drivers/dma/coh901318_lli.h b/drivers/dma/coh901318_lli.h
new file mode 100644 (file)
index 0000000..7bf713b
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * driver/dma/coh901318_lli.h
+ *
+ * Copyright (C) 2007-2009 ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ * Support functions for handling lli for coh901318
+ * Author: Per Friden <per.friden@stericsson.com>
+ */
+
+#ifndef COH901318_LLI_H
+#define COH901318_LLI_H
+
+#include <mach/coh901318.h>
+
+struct device;
+
+struct coh901318_pool {
+       spinlock_t lock;
+       struct dma_pool *dmapool;
+       struct device *dev;
+
+#ifdef CONFIG_DEBUG_FS
+       int debugfs_pool_counter;
+#endif
+};
+
+struct device;
+/**
+ * coh901318_pool_create() - Creates an dma pool for lli:s
+ * @pool: pool handle
+ * @dev: dma device
+ * @lli_nbr: number of lli:s in the pool
+ * @algin: adress alignemtn of lli:s
+ * returns 0 on success otherwise none zero
+ */
+int coh901318_pool_create(struct coh901318_pool *pool,
+                         struct device *dev,
+                         size_t lli_nbr, size_t align);
+
+/**
+ * coh901318_pool_destroy() - Destroys the dma pool
+ * @pool: pool handle
+ * returns 0 on success otherwise none zero
+ */
+int coh901318_pool_destroy(struct coh901318_pool *pool);
+
+/**
+ * coh901318_lli_alloc() - Allocates a linked list
+ *
+ * @pool: pool handle
+ * @len: length to list
+ * return: none NULL if success otherwise NULL
+ */
+struct coh901318_lli *
+coh901318_lli_alloc(struct coh901318_pool *pool,
+                   unsigned int len);
+
+/**
+ * coh901318_lli_free() - Returns the linked list items to the pool
+ * @pool: pool handle
+ * @lli: reference to lli pointer to be freed
+ */
+void coh901318_lli_free(struct coh901318_pool *pool,
+                       struct coh901318_lli **lli);
+
+/**
+ * coh901318_lli_fill_memcpy() - Prepares the lli:s for dma memcpy
+ * @pool: pool handle
+ * @lli: allocated lli
+ * @src: src address
+ * @size: transfer size
+ * @dst: destination address
+ * @ctrl_chained: ctrl for chained lli
+ * @ctrl_last: ctrl for the last lli
+ * returns number of CPU interrupts for the lli, negative on error.
+ */
+int
+coh901318_lli_fill_memcpy(struct coh901318_pool *pool,
+                         struct coh901318_lli *lli,
+                         dma_addr_t src, unsigned int size,
+                         dma_addr_t dst, u32 ctrl_chained, u32 ctrl_last);
+
+/**
+ * coh901318_lli_fill_single() - Prepares the lli:s for dma single transfer
+ * @pool: pool handle
+ * @lli: allocated lli
+ * @buf: transfer buffer
+ * @size: transfer size
+ * @dev_addr: address of periphal
+ * @ctrl_chained: ctrl for chained lli
+ * @ctrl_last: ctrl for the last lli
+ * @dir: direction of transfer (to or from device)
+ * returns number of CPU interrupts for the lli, negative on error.
+ */
+int
+coh901318_lli_fill_single(struct coh901318_pool *pool,
+                         struct coh901318_lli *lli,
+                         dma_addr_t buf, unsigned int size,
+                         dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl_last,
+                         enum dma_data_direction dir);
+
+/**
+ * coh901318_lli_fill_single() - Prepares the lli:s for dma scatter list transfer
+ * @pool: pool handle
+ * @lli: allocated lli
+ * @sg: scatter gather list
+ * @nents: number of entries in sg
+ * @dev_addr: address of periphal
+ * @ctrl_chained: ctrl for chained lli
+ * @ctrl: ctrl of middle lli
+ * @ctrl_last: ctrl for the last lli
+ * @dir: direction of transfer (to or from device)
+ * @ctrl_irq_mask: ctrl mask for CPU interrupt
+ * returns number of CPU interrupts for the lli, negative on error.
+ */
+int
+coh901318_lli_fill_sg(struct coh901318_pool *pool,
+                     struct coh901318_lli *lli,
+                     struct scatterlist *sg, unsigned int nents,
+                     dma_addr_t dev_addr, u32 ctrl_chained,
+                     u32 ctrl, u32 ctrl_last,
+                     enum dma_data_direction dir, u32 ctrl_irq_mask);
+
+#endif /* COH901318_LLI_H */
index a32a4cf7b1e049ab537db5c065f4f6a474dca2d2..8b905161fbf443b4d14036e7a425755a76b4ab3e 100644 (file)
@@ -298,10 +298,6 @@ static int dmatest_func(void *data)
 
                total_tests++;
 
-               len = dmatest_random() % test_buf_size + 1;
-               src_off = dmatest_random() % (test_buf_size - len + 1);
-               dst_off = dmatest_random() % (test_buf_size - len + 1);
-
                /* honor alignment restrictions */
                if (thread->type == DMA_MEMCPY)
                        align = dev->copy_align;
@@ -310,7 +306,19 @@ static int dmatest_func(void *data)
                else if (thread->type == DMA_PQ)
                        align = dev->pq_align;
 
+               if (1 << align > test_buf_size) {
+                       pr_err("%u-byte buffer too small for %d-byte alignment\n",
+                              test_buf_size, 1 << align);
+                       break;
+               }
+
+               len = dmatest_random() % test_buf_size + 1;
                len = (len >> align) << align;
+               if (!len)
+                       len = 1 << align;
+               src_off = dmatest_random() % (test_buf_size - len + 1);
+               dst_off = dmatest_random() % (test_buf_size - len + 1);
+
                src_off = (src_off >> align) << align;
                dst_off = (dst_off >> align) << align;
 
index 2eea823516a7aa9797f7908074c4ec68bd564b81..d28369f7afd2ba8a2da690b235c0318a89719a82 100644 (file)
@@ -1270,8 +1270,6 @@ static int __init dw_probe(struct platform_device *pdev)
                goto err_kfree;
        }
 
-       memset(dw, 0, sizeof *dw);
-
        dw->regs = ioremap(io->start, DW_REGLEN);
        if (!dw->regs) {
                err = -ENOMEM;
@@ -1427,7 +1425,7 @@ static int dw_resume_noirq(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops dw_dev_pm_ops = {
+static const struct dev_pm_ops dw_dev_pm_ops = {
        .suspend_noirq = dw_suspend_noirq,
        .resume_noirq = dw_resume_noirq,
 };
index c524d36d3c2e199db83e5b2a9a8a7b7bf1939a21..dcc4ab78b32b79a5d54fc3e8dab9f7af6b61ecc4 100644 (file)
@@ -1032,7 +1032,7 @@ int __devinit ioat_probe(struct ioatdma_device *device)
        dma->dev = &pdev->dev;
 
        if (!dma->chancnt) {
-               dev_err(dev, "zero channels detected\n");
+               dev_err(dev, "channel enumeration error\n");
                goto err_setup_interrupts;
        }
 
index 45edde99648070e8c9a0ca14f214ead551cbfc84..bbc3e78ef3334f60f025cbb9361d95fb46b38249 100644 (file)
@@ -60,6 +60,7 @@
  * @dca: direct cache access context
  * @intr_quirk: interrupt setup quirk (for ioat_v1 devices)
  * @enumerate_channels: hw version specific channel enumeration
+ * @reset_hw: hw version specific channel (re)initialization
  * @cleanup_tasklet: select between the v2 and v3 cleanup routines
  * @timer_fn: select between the v2 and v3 timer watchdog routines
  * @self_test: hardware version specific self test for each supported op type
@@ -78,6 +79,7 @@ struct ioatdma_device {
        struct dca_provider *dca;
        void (*intr_quirk)(struct ioatdma_device *device);
        int (*enumerate_channels)(struct ioatdma_device *device);
+       int (*reset_hw)(struct ioat_chan_common *chan);
        void (*cleanup_tasklet)(unsigned long data);
        void (*timer_fn)(unsigned long data);
        int (*self_test)(struct ioatdma_device *device);
@@ -264,6 +266,22 @@ static inline void ioat_suspend(struct ioat_chan_common *chan)
        writeb(IOAT_CHANCMD_SUSPEND, chan->reg_base + IOAT_CHANCMD_OFFSET(ver));
 }
 
+static inline void ioat_reset(struct ioat_chan_common *chan)
+{
+       u8 ver = chan->device->version;
+
+       writeb(IOAT_CHANCMD_RESET, chan->reg_base + IOAT_CHANCMD_OFFSET(ver));
+}
+
+static inline bool ioat_reset_pending(struct ioat_chan_common *chan)
+{
+       u8 ver = chan->device->version;
+       u8 cmd;
+
+       cmd = readb(chan->reg_base + IOAT_CHANCMD_OFFSET(ver));
+       return (cmd & IOAT_CHANCMD_RESET) == IOAT_CHANCMD_RESET;
+}
+
 static inline void ioat_set_chainaddr(struct ioat_dma_chan *ioat, u64 addr)
 {
        struct ioat_chan_common *chan = &ioat->base;
index 8f1f7f05deaadaac6cd428cbef09e35e161ededc..5f7a500e18d02636f1b94650202f6b2614323bb7 100644 (file)
@@ -239,20 +239,50 @@ void __ioat2_restart_chan(struct ioat2_dma_chan *ioat)
                __ioat2_start_null_desc(ioat);
 }
 
-static void ioat2_restart_channel(struct ioat2_dma_chan *ioat)
+int ioat2_quiesce(struct ioat_chan_common *chan, unsigned long tmo)
 {
-       struct ioat_chan_common *chan = &ioat->base;
-       unsigned long phys_complete;
+       unsigned long end = jiffies + tmo;
+       int err = 0;
        u32 status;
 
        status = ioat_chansts(chan);
        if (is_ioat_active(status) || is_ioat_idle(status))
                ioat_suspend(chan);
        while (is_ioat_active(status) || is_ioat_idle(status)) {
+               if (end && time_after(jiffies, end)) {
+                       err = -ETIMEDOUT;
+                       break;
+               }
                status = ioat_chansts(chan);
                cpu_relax();
        }
 
+       return err;
+}
+
+int ioat2_reset_sync(struct ioat_chan_common *chan, unsigned long tmo)
+{
+       unsigned long end = jiffies + tmo;
+       int err = 0;
+
+       ioat_reset(chan);
+       while (ioat_reset_pending(chan)) {
+               if (end && time_after(jiffies, end)) {
+                       err = -ETIMEDOUT;
+                       break;
+               }
+               cpu_relax();
+       }
+
+       return err;
+}
+
+static void ioat2_restart_channel(struct ioat2_dma_chan *ioat)
+{
+       struct ioat_chan_common *chan = &ioat->base;
+       unsigned long phys_complete;
+
+       ioat2_quiesce(chan, 0);
        if (ioat_cleanup_preamble(chan, &phys_complete))
                __cleanup(ioat, phys_complete);
 
@@ -318,6 +348,19 @@ void ioat2_timer_event(unsigned long data)
        spin_unlock_bh(&chan->cleanup_lock);
 }
 
+static int ioat2_reset_hw(struct ioat_chan_common *chan)
+{
+       /* throw away whatever the channel was doing and get it initialized */
+       u32 chanerr;
+
+       ioat2_quiesce(chan, msecs_to_jiffies(100));
+
+       chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET);
+       writel(chanerr, chan->reg_base + IOAT_CHANERR_OFFSET);
+
+       return ioat2_reset_sync(chan, msecs_to_jiffies(200));
+}
+
 /**
  * ioat2_enumerate_channels - find and initialize the device's channels
  * @device: the device to be enumerated
@@ -360,6 +403,10 @@ int ioat2_enumerate_channels(struct ioatdma_device *device)
                                  (unsigned long) ioat);
                ioat->xfercap_log = xfercap_log;
                spin_lock_init(&ioat->ring_lock);
+               if (device->reset_hw(&ioat->base)) {
+                       i = 0;
+                       break;
+               }
        }
        dma->chancnt = i;
        return i;
@@ -467,7 +514,6 @@ int ioat2_alloc_chan_resources(struct dma_chan *c)
        struct ioat2_dma_chan *ioat = to_ioat2_chan(c);
        struct ioat_chan_common *chan = &ioat->base;
        struct ioat_ring_ent **ring;
-       u32 chanerr;
        int order;
 
        /* have we already been set up? */
@@ -477,12 +523,6 @@ int ioat2_alloc_chan_resources(struct dma_chan *c)
        /* Setup register to interrupt and write completion status on error */
        writew(IOAT_CHANCTRL_RUN, chan->reg_base + IOAT_CHANCTRL_OFFSET);
 
-       chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET);
-       if (chanerr) {
-               dev_err(to_dev(chan), "CHANERR = %x, clearing\n", chanerr);
-               writel(chanerr, chan->reg_base + IOAT_CHANERR_OFFSET);
-       }
-
        /* allocate a completion writeback area */
        /* doing 2 32bit writes to mmio since 1 64b write doesn't work */
        chan->completion = pci_pool_alloc(chan->device->completion_pool,
@@ -746,13 +786,7 @@ void ioat2_free_chan_resources(struct dma_chan *c)
        tasklet_disable(&chan->cleanup_task);
        del_timer_sync(&chan->timer);
        device->cleanup_tasklet((unsigned long) ioat);
-
-       /* Delay 100ms after reset to allow internal DMA logic to quiesce
-        * before removing DMA descriptor resources.
-        */
-       writeb(IOAT_CHANCMD_RESET,
-              chan->reg_base + IOAT_CHANCMD_OFFSET(chan->device->version));
-       mdelay(100);
+       device->reset_hw(chan);
 
        spin_lock_bh(&ioat->ring_lock);
        descs = ioat2_ring_space(ioat);
@@ -839,6 +873,7 @@ int __devinit ioat2_dma_probe(struct ioatdma_device *device, int dca)
        int err;
 
        device->enumerate_channels = ioat2_enumerate_channels;
+       device->reset_hw = ioat2_reset_hw;
        device->cleanup_tasklet = ioat2_cleanup_tasklet;
        device->timer_fn = ioat2_timer_event;
        device->self_test = ioat_dma_self_test;
index 1d849ef74d5f7ff3a14bc7350ce58ce7d42be9c8..3afad8da43ccf1a71354fc2400cd7eca9beb2901 100644 (file)
@@ -185,6 +185,8 @@ bool reshape_ring(struct ioat2_dma_chan *ioat, int order);
 void __ioat2_issue_pending(struct ioat2_dma_chan *ioat);
 void ioat2_cleanup_tasklet(unsigned long data);
 void ioat2_timer_event(unsigned long data);
+int ioat2_quiesce(struct ioat_chan_common *chan, unsigned long tmo);
+int ioat2_reset_sync(struct ioat_chan_common *chan, unsigned long tmo);
 extern struct kobj_type ioat2_ktype;
 extern struct kmem_cache *ioat2_cache;
 #endif /* IOATDMA_V2_H */
index 42f6f10fb0cc249b2b07854f00e556f8335029d7..9908c9e94b2d0c9ba150eeefb507e48cb6cc0a5b 100644 (file)
@@ -650,9 +650,11 @@ __ioat3_prep_pq_lock(struct dma_chan *c, enum sum_check_flags *result,
 
        num_descs = ioat2_xferlen_to_descs(ioat, len);
        /* we need 2x the number of descriptors to cover greater than 3
-        * sources
+        * sources (we need 1 extra source in the q-only continuation
+        * case and 3 extra sources in the p+q continuation case.
         */
-       if (src_cnt > 3 || flags & DMA_PREP_CONTINUE) {
+       if (src_cnt + dmaf_p_disabled_continue(flags) > 3 ||
+           (dmaf_continue(flags) && !dmaf_p_disabled_continue(flags))) {
                with_ext = 1;
                num_descs *= 2;
        } else
@@ -1128,6 +1130,45 @@ static int __devinit ioat3_dma_self_test(struct ioatdma_device *device)
        return 0;
 }
 
+static int ioat3_reset_hw(struct ioat_chan_common *chan)
+{
+       /* throw away whatever the channel was doing and get it
+        * initialized, with ioat3 specific workarounds
+        */
+       struct ioatdma_device *device = chan->device;
+       struct pci_dev *pdev = device->pdev;
+       u32 chanerr;
+       u16 dev_id;
+       int err;
+
+       ioat2_quiesce(chan, msecs_to_jiffies(100));
+
+       chanerr = readl(chan->reg_base + IOAT_CHANERR_OFFSET);
+       writel(chanerr, chan->reg_base + IOAT_CHANERR_OFFSET);
+
+       /* -= IOAT ver.3 workarounds =- */
+       /* Write CHANERRMSK_INT with 3E07h to mask out the errors
+        * that can cause stability issues for IOAT ver.3, and clear any
+        * pending errors
+        */
+       pci_write_config_dword(pdev, IOAT_PCI_CHANERRMASK_INT_OFFSET, 0x3e07);
+       err = pci_read_config_dword(pdev, IOAT_PCI_CHANERR_INT_OFFSET, &chanerr);
+       if (err) {
+               dev_err(&pdev->dev, "channel error register unreachable\n");
+               return err;
+       }
+       pci_write_config_dword(pdev, IOAT_PCI_CHANERR_INT_OFFSET, chanerr);
+
+       /* Clear DMAUNCERRSTS Cfg-Reg Parity Error status bit
+        * (workaround for spurious config parity error after restart)
+        */
+       pci_read_config_word(pdev, IOAT_PCI_DEVICE_ID_OFFSET, &dev_id);
+       if (dev_id == PCI_DEVICE_ID_INTEL_IOAT_TBG0)
+               pci_write_config_dword(pdev, IOAT_PCI_DMAUNCERRSTS_OFFSET, 0x10);
+
+       return ioat2_reset_sync(chan, msecs_to_jiffies(200));
+}
+
 int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca)
 {
        struct pci_dev *pdev = device->pdev;
@@ -1137,10 +1178,10 @@ int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca)
        struct ioat_chan_common *chan;
        bool is_raid_device = false;
        int err;
-       u16 dev_id;
        u32 cap;
 
        device->enumerate_channels = ioat2_enumerate_channels;
+       device->reset_hw = ioat3_reset_hw;
        device->self_test = ioat3_dma_self_test;
        dma = &device->common;
        dma->device_prep_dma_memcpy = ioat2_dma_prep_memcpy_lock;
@@ -1216,19 +1257,6 @@ int __devinit ioat3_dma_probe(struct ioatdma_device *device, int dca)
        dma->device_prep_dma_xor_val = NULL;
        #endif
 
-       /* -= IOAT ver.3 workarounds =- */
-       /* Write CHANERRMSK_INT with 3E07h to mask out the errors
-        * that can cause stability issues for IOAT ver.3
-        */
-       pci_write_config_dword(pdev, IOAT_PCI_CHANERRMASK_INT_OFFSET, 0x3e07);
-
-       /* Clear DMAUNCERRSTS Cfg-Reg Parity Error status bit
-        * (workaround for spurious config parity error after restart)
-        */
-       pci_read_config_word(pdev, IOAT_PCI_DEVICE_ID_OFFSET, &dev_id);
-       if (dev_id == PCI_DEVICE_ID_INTEL_IOAT_TBG0)
-               pci_write_config_dword(pdev, IOAT_PCI_DMAUNCERRSTS_OFFSET, 0x10);
-
        err = ioat_probe(device);
        if (err)
                return err;
index f015ec1967004ed103149c5e93b8ad2d670eae80..e8ae63baf5887f6fed78f7d2fa33ffbf61a89301 100644 (file)
@@ -27,6 +27,7 @@
 
 #define IOAT_PCI_DEVICE_ID_OFFSET              0x02
 #define IOAT_PCI_DMAUNCERRSTS_OFFSET           0x148
+#define IOAT_PCI_CHANERR_INT_OFFSET            0x180
 #define IOAT_PCI_CHANERRMASK_INT_OFFSET                0x184
 
 /* MMIO Device Registers */
index 645ca8d54ec43350059bd8d7c8802f017b4a4abd..ca6e6a0cb7931e32a85b0f9d8da9bb2f5855b63a 100644 (file)
@@ -1470,7 +1470,7 @@ static int __devinit iop_adma_probe(struct platform_device *pdev)
                return -ENODEV;
 
        if (!devm_request_mem_region(&pdev->dev, res->start,
-                               res->end - res->start, pdev->name))
+                               resource_size(res), pdev->name))
                return -EBUSY;
 
        adev = kzalloc(sizeof(*adev), GFP_KERNEL);
@@ -1542,7 +1542,7 @@ static int __devinit iop_adma_probe(struct platform_device *pdev)
        iop_chan->device = adev;
 
        iop_chan->mmr_base = devm_ioremap(&pdev->dev, res->start,
-                                       res->end - res->start);
+                                       resource_size(res));
        if (!iop_chan->mmr_base) {
                ret = -ENOMEM;
                goto err_free_iop_chan;
diff --git a/drivers/dma/ppc4xx/Makefile b/drivers/dma/ppc4xx/Makefile
new file mode 100644 (file)
index 0000000..b3d259b
--- /dev/null
@@ -0,0 +1 @@
+obj-$(CONFIG_AMCC_PPC440SPE_ADMA) += adma.o
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
new file mode 100644 (file)
index 0000000..0a3478e
--- /dev/null
@@ -0,0 +1,5027 @@
+/*
+ * Copyright (C) 2006-2009 DENX Software Engineering.
+ *
+ * Author: Yuri Tikhonov <yur@emcraft.com>
+ *
+ * Further porting to arch/powerpc by
+ *     Anatolij Gustschin <agust@denx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+/*
+ * This driver supports the asynchrounous DMA copy and RAID engines available
+ * on the AMCC PPC440SPe Processors.
+ * Based on the Intel Xscale(R) family of I/O Processors (IOP 32x, 33x, 134x)
+ * ADMA driver written by D.Williams.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/async_tx.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/uaccess.h>
+#include <linux/proc_fs.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <asm/dcr.h>
+#include <asm/dcr-regs.h>
+#include "adma.h"
+
+enum ppc_adma_init_code {
+       PPC_ADMA_INIT_OK = 0,
+       PPC_ADMA_INIT_MEMRES,
+       PPC_ADMA_INIT_MEMREG,
+       PPC_ADMA_INIT_ALLOC,
+       PPC_ADMA_INIT_COHERENT,
+       PPC_ADMA_INIT_CHANNEL,
+       PPC_ADMA_INIT_IRQ1,
+       PPC_ADMA_INIT_IRQ2,
+       PPC_ADMA_INIT_REGISTER
+};
+
+static char *ppc_adma_errors[] = {
+       [PPC_ADMA_INIT_OK] = "ok",
+       [PPC_ADMA_INIT_MEMRES] = "failed to get memory resource",
+       [PPC_ADMA_INIT_MEMREG] = "failed to request memory region",
+       [PPC_ADMA_INIT_ALLOC] = "failed to allocate memory for adev "
+                               "structure",
+       [PPC_ADMA_INIT_COHERENT] = "failed to allocate coherent memory for "
+                                  "hardware descriptors",
+       [PPC_ADMA_INIT_CHANNEL] = "failed to allocate memory for channel",
+       [PPC_ADMA_INIT_IRQ1] = "failed to request first irq",
+       [PPC_ADMA_INIT_IRQ2] = "failed to request second irq",
+       [PPC_ADMA_INIT_REGISTER] = "failed to register dma async device",
+};
+
+static enum ppc_adma_init_code
+ppc440spe_adma_devices[PPC440SPE_ADMA_ENGINES_NUM];
+
+struct ppc_dma_chan_ref {
+       struct dma_chan *chan;
+       struct list_head node;
+};
+
+/* The list of channels exported by ppc440spe ADMA */
+struct list_head
+ppc440spe_adma_chan_list = LIST_HEAD_INIT(ppc440spe_adma_chan_list);
+
+/* This flag is set when want to refetch the xor chain in the interrupt
+ * handler
+ */
+static u32 do_xor_refetch;
+
+/* Pointer to DMA0, DMA1 CP/CS FIFO */
+static void *ppc440spe_dma_fifo_buf;
+
+/* Pointers to last submitted to DMA0, DMA1 CDBs */
+static struct ppc440spe_adma_desc_slot *chan_last_sub[3];
+static struct ppc440spe_adma_desc_slot *chan_first_cdb[3];
+
+/* Pointer to last linked and submitted xor CB */
+static struct ppc440spe_adma_desc_slot *xor_last_linked;
+static struct ppc440spe_adma_desc_slot *xor_last_submit;
+
+/* This array is used in data-check operations for storing a pattern */
+static char ppc440spe_qword[16];
+
+static atomic_t ppc440spe_adma_err_irq_ref;
+static dcr_host_t ppc440spe_mq_dcr_host;
+static unsigned int ppc440spe_mq_dcr_len;
+
+/* Since RXOR operations use the common register (MQ0_CF2H) for setting-up
+ * the block size in transactions, then we do not allow to activate more than
+ * only one RXOR transactions simultaneously. So use this var to store
+ * the information about is RXOR currently active (PPC440SPE_RXOR_RUN bit is
+ * set) or not (PPC440SPE_RXOR_RUN is clear).
+ */
+static unsigned long ppc440spe_rxor_state;
+
+/* These are used in enable & check routines
+ */
+static u32 ppc440spe_r6_enabled;
+static struct ppc440spe_adma_chan *ppc440spe_r6_tchan;
+static struct completion ppc440spe_r6_test_comp;
+
+static int ppc440spe_adma_dma2rxor_prep_src(
+               struct ppc440spe_adma_desc_slot *desc,
+               struct ppc440spe_rxor *cursor, int index,
+               int src_cnt, u32 addr);
+static void ppc440spe_adma_dma2rxor_set_src(
+               struct ppc440spe_adma_desc_slot *desc,
+               int index, dma_addr_t addr);
+static void ppc440spe_adma_dma2rxor_set_mult(
+               struct ppc440spe_adma_desc_slot *desc,
+               int index, u8 mult);
+
+#ifdef ADMA_LL_DEBUG
+#define ADMA_LL_DBG(x) ({ if (1) x; 0; })
+#else
+#define ADMA_LL_DBG(x) ({ if (0) x; 0; })
+#endif
+
+static void print_cb(struct ppc440spe_adma_chan *chan, void *block)
+{
+       struct dma_cdb *cdb;
+       struct xor_cb *cb;
+       int i;
+
+       switch (chan->device->id) {
+       case 0:
+       case 1:
+               cdb = block;
+
+               pr_debug("CDB at %p [%d]:\n"
+                       "\t attr 0x%02x opc 0x%02x cnt 0x%08x\n"
+                       "\t sg1u 0x%08x sg1l 0x%08x\n"
+                       "\t sg2u 0x%08x sg2l 0x%08x\n"
+                       "\t sg3u 0x%08x sg3l 0x%08x\n",
+                       cdb, chan->device->id,
+                       cdb->attr, cdb->opc, le32_to_cpu(cdb->cnt),
+                       le32_to_cpu(cdb->sg1u), le32_to_cpu(cdb->sg1l),
+                       le32_to_cpu(cdb->sg2u), le32_to_cpu(cdb->sg2l),
+                       le32_to_cpu(cdb->sg3u), le32_to_cpu(cdb->sg3l)
+               );
+               break;
+       case 2:
+               cb = block;
+
+               pr_debug("CB at %p [%d]:\n"
+                       "\t cbc 0x%08x cbbc 0x%08x cbs 0x%08x\n"
+                       "\t cbtah 0x%08x cbtal 0x%08x\n"
+                       "\t cblah 0x%08x cblal 0x%08x\n",
+                       cb, chan->device->id,
+                       cb->cbc, cb->cbbc, cb->cbs,
+                       cb->cbtah, cb->cbtal,
+                       cb->cblah, cb->cblal);
+               for (i = 0; i < 16; i++) {
+                       if (i && !cb->ops[i].h && !cb->ops[i].l)
+                               continue;
+                       pr_debug("\t ops[%2d]: h 0x%08x l 0x%08x\n",
+                               i, cb->ops[i].h, cb->ops[i].l);
+               }
+               break;
+       }
+}
+
+static void print_cb_list(struct ppc440spe_adma_chan *chan,
+                         struct ppc440spe_adma_desc_slot *iter)
+{
+       for (; iter; iter = iter->hw_next)
+               print_cb(chan, iter->hw_desc);
+}
+
+static void prep_dma_xor_dbg(int id, dma_addr_t dst, dma_addr_t *src,
+                            unsigned int src_cnt)
+{
+       int i;
+
+       pr_debug("\n%s(%d):\nsrc: ", __func__, id);
+       for (i = 0; i < src_cnt; i++)
+               pr_debug("\t0x%016llx ", src[i]);
+       pr_debug("dst:\n\t0x%016llx\n", dst);
+}
+
+static void prep_dma_pq_dbg(int id, dma_addr_t *dst, dma_addr_t *src,
+                           unsigned int src_cnt)
+{
+       int i;
+
+       pr_debug("\n%s(%d):\nsrc: ", __func__, id);
+       for (i = 0; i < src_cnt; i++)
+               pr_debug("\t0x%016llx ", src[i]);
+       pr_debug("dst: ");
+       for (i = 0; i < 2; i++)
+               pr_debug("\t0x%016llx ", dst[i]);
+}
+
+static void prep_dma_pqzero_sum_dbg(int id, dma_addr_t *src,
+                                   unsigned int src_cnt,
+                                   const unsigned char *scf)
+{
+       int i;
+
+       pr_debug("\n%s(%d):\nsrc(coef): ", __func__, id);
+       if (scf) {
+               for (i = 0; i < src_cnt; i++)
+                       pr_debug("\t0x%016llx(0x%02x) ", src[i], scf[i]);
+       } else {
+               for (i = 0; i < src_cnt; i++)
+                       pr_debug("\t0x%016llx(no) ", src[i]);
+       }
+
+       pr_debug("dst: ");
+       for (i = 0; i < 2; i++)
+               pr_debug("\t0x%016llx ", src[src_cnt + i]);
+}
+
+/******************************************************************************
+ * Command (Descriptor) Blocks low-level routines
+ ******************************************************************************/
+/**
+ * ppc440spe_desc_init_interrupt - initialize the descriptor for INTERRUPT
+ * pseudo operation
+ */
+static void ppc440spe_desc_init_interrupt(struct ppc440spe_adma_desc_slot *desc,
+                                         struct ppc440spe_adma_chan *chan)
+{
+       struct xor_cb *p;
+
+       switch (chan->device->id) {
+       case PPC440SPE_XOR_ID:
+               p = desc->hw_desc;
+               memset(desc->hw_desc, 0, sizeof(struct xor_cb));
+               /* NOP with Command Block Complete Enable */
+               p->cbc = XOR_CBCR_CBCE_BIT;
+               break;
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               memset(desc->hw_desc, 0, sizeof(struct dma_cdb));
+               /* NOP with interrupt */
+               set_bit(PPC440SPE_DESC_INT, &desc->flags);
+               break;
+       default:
+               printk(KERN_ERR "Unsupported id %d in %s\n", chan->device->id,
+                               __func__);
+               break;
+       }
+}
+
+/**
+ * ppc440spe_desc_init_null_xor - initialize the descriptor for NULL XOR
+ * pseudo operation
+ */
+static void ppc440spe_desc_init_null_xor(struct ppc440spe_adma_desc_slot *desc)
+{
+       memset(desc->hw_desc, 0, sizeof(struct xor_cb));
+       desc->hw_next = NULL;
+       desc->src_cnt = 0;
+       desc->dst_cnt = 1;
+}
+
+/**
+ * ppc440spe_desc_init_xor - initialize the descriptor for XOR operation
+ */
+static void ppc440spe_desc_init_xor(struct ppc440spe_adma_desc_slot *desc,
+                                        int src_cnt, unsigned long flags)
+{
+       struct xor_cb *hw_desc = desc->hw_desc;
+
+       memset(desc->hw_desc, 0, sizeof(struct xor_cb));
+       desc->hw_next = NULL;
+       desc->src_cnt = src_cnt;
+       desc->dst_cnt = 1;
+
+       hw_desc->cbc = XOR_CBCR_TGT_BIT | src_cnt;
+       if (flags & DMA_PREP_INTERRUPT)
+               /* Enable interrupt on completion */
+               hw_desc->cbc |= XOR_CBCR_CBCE_BIT;
+}
+
+/**
+ * ppc440spe_desc_init_dma2pq - initialize the descriptor for PQ
+ * operation in DMA2 controller
+ */
+static void ppc440spe_desc_init_dma2pq(struct ppc440spe_adma_desc_slot *desc,
+               int dst_cnt, int src_cnt, unsigned long flags)
+{
+       struct xor_cb *hw_desc = desc->hw_desc;
+
+       memset(desc->hw_desc, 0, sizeof(struct xor_cb));
+       desc->hw_next = NULL;
+       desc->src_cnt = src_cnt;
+       desc->dst_cnt = dst_cnt;
+       memset(desc->reverse_flags, 0, sizeof(desc->reverse_flags));
+       desc->descs_per_op = 0;
+
+       hw_desc->cbc = XOR_CBCR_TGT_BIT;
+       if (flags & DMA_PREP_INTERRUPT)
+               /* Enable interrupt on completion */
+               hw_desc->cbc |= XOR_CBCR_CBCE_BIT;
+}
+
+#define DMA_CTRL_FLAGS_LAST    DMA_PREP_FENCE
+#define DMA_PREP_ZERO_P                (DMA_CTRL_FLAGS_LAST << 1)
+#define DMA_PREP_ZERO_Q                (DMA_PREP_ZERO_P << 1)
+
+/**
+ * ppc440spe_desc_init_dma01pq - initialize the descriptors for PQ operation
+ * with DMA0/1
+ */
+static void ppc440spe_desc_init_dma01pq(struct ppc440spe_adma_desc_slot *desc,
+                               int dst_cnt, int src_cnt, unsigned long flags,
+                               unsigned long op)
+{
+       struct dma_cdb *hw_desc;
+       struct ppc440spe_adma_desc_slot *iter;
+       u8 dopc;
+
+       /* Common initialization of a PQ descriptors chain */
+       set_bits(op, &desc->flags);
+       desc->src_cnt = src_cnt;
+       desc->dst_cnt = dst_cnt;
+
+       /* WXOR MULTICAST if both P and Q are being computed
+        * MV_SG1_SG2 if Q only
+        */
+       dopc = (desc->dst_cnt == DMA_DEST_MAX_NUM) ?
+               DMA_CDB_OPC_MULTICAST : DMA_CDB_OPC_MV_SG1_SG2;
+
+       list_for_each_entry(iter, &desc->group_list, chain_node) {
+               hw_desc = iter->hw_desc;
+               memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+
+               if (likely(!list_is_last(&iter->chain_node,
+                               &desc->group_list))) {
+                       /* set 'next' pointer */
+                       iter->hw_next = list_entry(iter->chain_node.next,
+                               struct ppc440spe_adma_desc_slot, chain_node);
+                       clear_bit(PPC440SPE_DESC_INT, &iter->flags);
+               } else {
+                       /* this is the last descriptor.
+                        * this slot will be pasted from ADMA level
+                        * each time it wants to configure parameters
+                        * of the transaction (src, dst, ...)
+                        */
+                       iter->hw_next = NULL;
+                       if (flags & DMA_PREP_INTERRUPT)
+                               set_bit(PPC440SPE_DESC_INT, &iter->flags);
+                       else
+                               clear_bit(PPC440SPE_DESC_INT, &iter->flags);
+               }
+       }
+
+       /* Set OPS depending on WXOR/RXOR type of operation */
+       if (!test_bit(PPC440SPE_DESC_RXOR, &desc->flags)) {
+               /* This is a WXOR only chain:
+                * - first descriptors are for zeroing destinations
+                *   if PPC440SPE_ZERO_P/Q set;
+                * - descriptors remained are for GF-XOR operations.
+                */
+               iter = list_first_entry(&desc->group_list,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+
+               if (test_bit(PPC440SPE_ZERO_P, &desc->flags)) {
+                       hw_desc = iter->hw_desc;
+                       hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+                       iter = list_first_entry(&iter->chain_node,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               }
+
+               if (test_bit(PPC440SPE_ZERO_Q, &desc->flags)) {
+                       hw_desc = iter->hw_desc;
+                       hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+                       iter = list_first_entry(&iter->chain_node,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               }
+
+               list_for_each_entry_from(iter, &desc->group_list, chain_node) {
+                       hw_desc = iter->hw_desc;
+                       hw_desc->opc = dopc;
+               }
+       } else {
+               /* This is either RXOR-only or mixed RXOR/WXOR */
+
+               /* The first 1 or 2 slots in chain are always RXOR,
+                * if need to calculate P & Q, then there are two
+                * RXOR slots; if only P or only Q, then there is one
+                */
+               iter = list_first_entry(&desc->group_list,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               hw_desc = iter->hw_desc;
+               hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+
+               if (desc->dst_cnt == DMA_DEST_MAX_NUM) {
+                       iter = list_first_entry(&iter->chain_node,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+                       hw_desc = iter->hw_desc;
+                       hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+               }
+
+               /* The remaining descs (if any) are WXORs */
+               if (test_bit(PPC440SPE_DESC_WXOR, &desc->flags)) {
+                       iter = list_first_entry(&iter->chain_node,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+                       list_for_each_entry_from(iter, &desc->group_list,
+                                               chain_node) {
+                               hw_desc = iter->hw_desc;
+                               hw_desc->opc = dopc;
+                       }
+               }
+       }
+}
+
+/**
+ * ppc440spe_desc_init_dma01pqzero_sum - initialize the descriptor
+ * for PQ_ZERO_SUM operation
+ */
+static void ppc440spe_desc_init_dma01pqzero_sum(
+                               struct ppc440spe_adma_desc_slot *desc,
+                               int dst_cnt, int src_cnt)
+{
+       struct dma_cdb *hw_desc;
+       struct ppc440spe_adma_desc_slot *iter;
+       int i = 0;
+       u8 dopc = (dst_cnt == 2) ? DMA_CDB_OPC_MULTICAST :
+                                  DMA_CDB_OPC_MV_SG1_SG2;
+       /*
+        * Initialize starting from 2nd or 3rd descriptor dependent
+        * on dst_cnt. First one or two slots are for cloning P
+        * and/or Q to chan->pdest and/or chan->qdest as we have
+        * to preserve original P/Q.
+        */
+       iter = list_first_entry(&desc->group_list,
+                               struct ppc440spe_adma_desc_slot, chain_node);
+       iter = list_entry(iter->chain_node.next,
+                         struct ppc440spe_adma_desc_slot, chain_node);
+
+       if (dst_cnt > 1) {
+               iter = list_entry(iter->chain_node.next,
+                                 struct ppc440spe_adma_desc_slot, chain_node);
+       }
+       /* initialize each source descriptor in chain */
+       list_for_each_entry_from(iter, &desc->group_list, chain_node) {
+               hw_desc = iter->hw_desc;
+               memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+               iter->src_cnt = 0;
+               iter->dst_cnt = 0;
+
+               /* This is a ZERO_SUM operation:
+                * - <src_cnt> descriptors starting from 2nd or 3rd
+                *   descriptor are for GF-XOR operations;
+                * - remaining <dst_cnt> descriptors are for checking the result
+                */
+               if (i++ < src_cnt)
+                       /* MV_SG1_SG2 if only Q is being verified
+                        * MULTICAST if both P and Q are being verified
+                        */
+                       hw_desc->opc = dopc;
+               else
+                       /* DMA_CDB_OPC_DCHECK128 operation */
+                       hw_desc->opc = DMA_CDB_OPC_DCHECK128;
+
+               if (likely(!list_is_last(&iter->chain_node,
+                                        &desc->group_list))) {
+                       /* set 'next' pointer */
+                       iter->hw_next = list_entry(iter->chain_node.next,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+               } else {
+                       /* this is the last descriptor.
+                        * this slot will be pasted from ADMA level
+                        * each time it wants to configure parameters
+                        * of the transaction (src, dst, ...)
+                        */
+                       iter->hw_next = NULL;
+                       /* always enable interrupt generation since we get
+                        * the status of pqzero from the handler
+                        */
+                       set_bit(PPC440SPE_DESC_INT, &iter->flags);
+               }
+       }
+       desc->src_cnt = src_cnt;
+       desc->dst_cnt = dst_cnt;
+}
+
+/**
+ * ppc440spe_desc_init_memcpy - initialize the descriptor for MEMCPY operation
+ */
+static void ppc440spe_desc_init_memcpy(struct ppc440spe_adma_desc_slot *desc,
+                                       unsigned long flags)
+{
+       struct dma_cdb *hw_desc = desc->hw_desc;
+
+       memset(desc->hw_desc, 0, sizeof(struct dma_cdb));
+       desc->hw_next = NULL;
+       desc->src_cnt = 1;
+       desc->dst_cnt = 1;
+
+       if (flags & DMA_PREP_INTERRUPT)
+               set_bit(PPC440SPE_DESC_INT, &desc->flags);
+       else
+               clear_bit(PPC440SPE_DESC_INT, &desc->flags);
+
+       hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+}
+
+/**
+ * ppc440spe_desc_init_memset - initialize the descriptor for MEMSET operation
+ */
+static void ppc440spe_desc_init_memset(struct ppc440spe_adma_desc_slot *desc,
+                                       int value, unsigned long flags)
+{
+       struct dma_cdb *hw_desc = desc->hw_desc;
+
+       memset(desc->hw_desc, 0, sizeof(struct dma_cdb));
+       desc->hw_next = NULL;
+       desc->src_cnt = 1;
+       desc->dst_cnt = 1;
+
+       if (flags & DMA_PREP_INTERRUPT)
+               set_bit(PPC440SPE_DESC_INT, &desc->flags);
+       else
+               clear_bit(PPC440SPE_DESC_INT, &desc->flags);
+
+       hw_desc->sg1u = hw_desc->sg1l = cpu_to_le32((u32)value);
+       hw_desc->sg3u = hw_desc->sg3l = cpu_to_le32((u32)value);
+       hw_desc->opc = DMA_CDB_OPC_DFILL128;
+}
+
+/**
+ * ppc440spe_desc_set_src_addr - set source address into the descriptor
+ */
+static void ppc440spe_desc_set_src_addr(struct ppc440spe_adma_desc_slot *desc,
+                                       struct ppc440spe_adma_chan *chan,
+                                       int src_idx, dma_addr_t addrh,
+                                       dma_addr_t addrl)
+{
+       struct dma_cdb *dma_hw_desc;
+       struct xor_cb *xor_hw_desc;
+       phys_addr_t addr64, tmplow, tmphi;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               if (!addrh) {
+                       addr64 = addrl;
+                       tmphi = (addr64 >> 32);
+                       tmplow = (addr64 & 0xFFFFFFFF);
+               } else {
+                       tmphi = addrh;
+                       tmplow = addrl;
+               }
+               dma_hw_desc = desc->hw_desc;
+               dma_hw_desc->sg1l = cpu_to_le32((u32)tmplow);
+               dma_hw_desc->sg1u |= cpu_to_le32((u32)tmphi);
+               break;
+       case PPC440SPE_XOR_ID:
+               xor_hw_desc = desc->hw_desc;
+               xor_hw_desc->ops[src_idx].l = addrl;
+               xor_hw_desc->ops[src_idx].h |= addrh;
+               break;
+       }
+}
+
+/**
+ * ppc440spe_desc_set_src_mult - set source address mult into the descriptor
+ */
+static void ppc440spe_desc_set_src_mult(struct ppc440spe_adma_desc_slot *desc,
+                       struct ppc440spe_adma_chan *chan, u32 mult_index,
+                       int sg_index, unsigned char mult_value)
+{
+       struct dma_cdb *dma_hw_desc;
+       struct xor_cb *xor_hw_desc;
+       u32 *psgu;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_hw_desc = desc->hw_desc;
+
+               switch (sg_index) {
+               /* for RXOR operations set multiplier
+                * into source cued address
+                */
+               case DMA_CDB_SG_SRC:
+                       psgu = &dma_hw_desc->sg1u;
+                       break;
+               /* for WXOR operations set multiplier
+                * into destination cued address(es)
+                */
+               case DMA_CDB_SG_DST1:
+                       psgu = &dma_hw_desc->sg2u;
+                       break;
+               case DMA_CDB_SG_DST2:
+                       psgu = &dma_hw_desc->sg3u;
+                       break;
+               default:
+                       BUG();
+               }
+
+               *psgu |= cpu_to_le32(mult_value << mult_index);
+               break;
+       case PPC440SPE_XOR_ID:
+               xor_hw_desc = desc->hw_desc;
+               break;
+       default:
+               BUG();
+       }
+}
+
+/**
+ * ppc440spe_desc_set_dest_addr - set destination address into the descriptor
+ */
+static void ppc440spe_desc_set_dest_addr(struct ppc440spe_adma_desc_slot *desc,
+                               struct ppc440spe_adma_chan *chan,
+                               dma_addr_t addrh, dma_addr_t addrl,
+                               u32 dst_idx)
+{
+       struct dma_cdb *dma_hw_desc;
+       struct xor_cb *xor_hw_desc;
+       phys_addr_t addr64, tmphi, tmplow;
+       u32 *psgu, *psgl;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               if (!addrh) {
+                       addr64 = addrl;
+                       tmphi = (addr64 >> 32);
+                       tmplow = (addr64 & 0xFFFFFFFF);
+               } else {
+                       tmphi = addrh;
+                       tmplow = addrl;
+               }
+               dma_hw_desc = desc->hw_desc;
+
+               psgu = dst_idx ? &dma_hw_desc->sg3u : &dma_hw_desc->sg2u;
+               psgl = dst_idx ? &dma_hw_desc->sg3l : &dma_hw_desc->sg2l;
+
+               *psgl = cpu_to_le32((u32)tmplow);
+               *psgu |= cpu_to_le32((u32)tmphi);
+               break;
+       case PPC440SPE_XOR_ID:
+               xor_hw_desc = desc->hw_desc;
+               xor_hw_desc->cbtal = addrl;
+               xor_hw_desc->cbtah |= addrh;
+               break;
+       }
+}
+
+/**
+ * ppc440spe_desc_set_byte_count - set number of data bytes involved
+ * into the operation
+ */
+static void ppc440spe_desc_set_byte_count(struct ppc440spe_adma_desc_slot *desc,
+                               struct ppc440spe_adma_chan *chan,
+                               u32 byte_count)
+{
+       struct dma_cdb *dma_hw_desc;
+       struct xor_cb *xor_hw_desc;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_hw_desc = desc->hw_desc;
+               dma_hw_desc->cnt = cpu_to_le32(byte_count);
+               break;
+       case PPC440SPE_XOR_ID:
+               xor_hw_desc = desc->hw_desc;
+               xor_hw_desc->cbbc = byte_count;
+               break;
+       }
+}
+
+/**
+ * ppc440spe_desc_set_rxor_block_size - set RXOR block size
+ */
+static inline void ppc440spe_desc_set_rxor_block_size(u32 byte_count)
+{
+       /* assume that byte_count is aligned on the 512-boundary;
+        * thus write it directly to the register (bits 23:31 are
+        * reserved there).
+        */
+       dcr_write(ppc440spe_mq_dcr_host, DCRN_MQ0_CF2H, byte_count);
+}
+
+/**
+ * ppc440spe_desc_set_dcheck - set CHECK pattern
+ */
+static void ppc440spe_desc_set_dcheck(struct ppc440spe_adma_desc_slot *desc,
+                               struct ppc440spe_adma_chan *chan, u8 *qword)
+{
+       struct dma_cdb *dma_hw_desc;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_hw_desc = desc->hw_desc;
+               iowrite32(qword[0], &dma_hw_desc->sg3l);
+               iowrite32(qword[4], &dma_hw_desc->sg3u);
+               iowrite32(qword[8], &dma_hw_desc->sg2l);
+               iowrite32(qword[12], &dma_hw_desc->sg2u);
+               break;
+       default:
+               BUG();
+       }
+}
+
+/**
+ * ppc440spe_xor_set_link - set link address in xor CB
+ */
+static void ppc440spe_xor_set_link(struct ppc440spe_adma_desc_slot *prev_desc,
+                               struct ppc440spe_adma_desc_slot *next_desc)
+{
+       struct xor_cb *xor_hw_desc = prev_desc->hw_desc;
+
+       if (unlikely(!next_desc || !(next_desc->phys))) {
+               printk(KERN_ERR "%s: next_desc=0x%p; next_desc->phys=0x%llx\n",
+                       __func__, next_desc,
+                       next_desc ? next_desc->phys : 0);
+               BUG();
+       }
+
+       xor_hw_desc->cbs = 0;
+       xor_hw_desc->cblal = next_desc->phys;
+       xor_hw_desc->cblah = 0;
+       xor_hw_desc->cbc |= XOR_CBCR_LNK_BIT;
+}
+
+/**
+ * ppc440spe_desc_set_link - set the address of descriptor following this
+ * descriptor in chain
+ */
+static void ppc440spe_desc_set_link(struct ppc440spe_adma_chan *chan,
+                               struct ppc440spe_adma_desc_slot *prev_desc,
+                               struct ppc440spe_adma_desc_slot *next_desc)
+{
+       unsigned long flags;
+       struct ppc440spe_adma_desc_slot *tail = next_desc;
+
+       if (unlikely(!prev_desc || !next_desc ||
+               (prev_desc->hw_next && prev_desc->hw_next != next_desc))) {
+               /* If previous next is overwritten something is wrong.
+                * though we may refetch from append to initiate list
+                * processing; in this case - it's ok.
+                */
+               printk(KERN_ERR "%s: prev_desc=0x%p; next_desc=0x%p; "
+                       "prev->hw_next=0x%p\n", __func__, prev_desc,
+                       next_desc, prev_desc ? prev_desc->hw_next : 0);
+               BUG();
+       }
+
+       local_irq_save(flags);
+
+       /* do s/w chaining both for DMA and XOR descriptors */
+       prev_desc->hw_next = next_desc;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               break;
+       case PPC440SPE_XOR_ID:
+               /* bind descriptor to the chain */
+               while (tail->hw_next)
+                       tail = tail->hw_next;
+               xor_last_linked = tail;
+
+               if (prev_desc == xor_last_submit)
+                       /* do not link to the last submitted CB */
+                       break;
+               ppc440spe_xor_set_link(prev_desc, next_desc);
+               break;
+       }
+
+       local_irq_restore(flags);
+}
+
+/**
+ * ppc440spe_desc_get_src_addr - extract the source address from the descriptor
+ */
+static u32 ppc440spe_desc_get_src_addr(struct ppc440spe_adma_desc_slot *desc,
+                               struct ppc440spe_adma_chan *chan, int src_idx)
+{
+       struct dma_cdb *dma_hw_desc;
+       struct xor_cb *xor_hw_desc;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_hw_desc = desc->hw_desc;
+               /* May have 0, 1, 2, or 3 sources */
+               switch (dma_hw_desc->opc) {
+               case DMA_CDB_OPC_NO_OP:
+               case DMA_CDB_OPC_DFILL128:
+                       return 0;
+               case DMA_CDB_OPC_DCHECK128:
+                       if (unlikely(src_idx)) {
+                               printk(KERN_ERR "%s: try to get %d source for"
+                                   " DCHECK128\n", __func__, src_idx);
+                               BUG();
+                       }
+                       return le32_to_cpu(dma_hw_desc->sg1l);
+               case DMA_CDB_OPC_MULTICAST:
+               case DMA_CDB_OPC_MV_SG1_SG2:
+                       if (unlikely(src_idx > 2)) {
+                               printk(KERN_ERR "%s: try to get %d source from"
+                                   " DMA descr\n", __func__, src_idx);
+                               BUG();
+                       }
+                       if (src_idx) {
+                               if (le32_to_cpu(dma_hw_desc->sg1u) &
+                                   DMA_CUED_XOR_WIN_MSK) {
+                                       u8 region;
+
+                                       if (src_idx == 1)
+                                               return le32_to_cpu(
+                                                   dma_hw_desc->sg1l) +
+                                                       desc->unmap_len;
+
+                                       region = (le32_to_cpu(
+                                           dma_hw_desc->sg1u)) >>
+                                               DMA_CUED_REGION_OFF;
+
+                                       region &= DMA_CUED_REGION_MSK;
+                                       switch (region) {
+                                       case DMA_RXOR123:
+                                               return le32_to_cpu(
+                                                   dma_hw_desc->sg1l) +
+                                                       (desc->unmap_len << 1);
+                                       case DMA_RXOR124:
+                                               return le32_to_cpu(
+                                                   dma_hw_desc->sg1l) +
+                                                       (desc->unmap_len * 3);
+                                       case DMA_RXOR125:
+                                               return le32_to_cpu(
+                                                   dma_hw_desc->sg1l) +
+                                                       (desc->unmap_len << 2);
+                                       default:
+                                               printk(KERN_ERR
+                                                   "%s: try to"
+                                                   " get src3 for region %02x"
+                                                   "PPC440SPE_DESC_RXOR12?\n",
+                                                   __func__, region);
+                                               BUG();
+                                       }
+                               } else {
+                                       printk(KERN_ERR
+                                               "%s: try to get %d"
+                                               " source for non-cued descr\n",
+                                               __func__, src_idx);
+                                       BUG();
+                               }
+                       }
+                       return le32_to_cpu(dma_hw_desc->sg1l);
+               default:
+                       printk(KERN_ERR "%s: unknown OPC 0x%02x\n",
+                               __func__, dma_hw_desc->opc);
+                       BUG();
+               }
+               return le32_to_cpu(dma_hw_desc->sg1l);
+       case PPC440SPE_XOR_ID:
+               /* May have up to 16 sources */
+               xor_hw_desc = desc->hw_desc;
+               return xor_hw_desc->ops[src_idx].l;
+       }
+       return 0;
+}
+
+/**
+ * ppc440spe_desc_get_dest_addr - extract the destination address from the
+ * descriptor
+ */
+static u32 ppc440spe_desc_get_dest_addr(struct ppc440spe_adma_desc_slot *desc,
+                               struct ppc440spe_adma_chan *chan, int idx)
+{
+       struct dma_cdb *dma_hw_desc;
+       struct xor_cb *xor_hw_desc;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_hw_desc = desc->hw_desc;
+
+               if (likely(!idx))
+                       return le32_to_cpu(dma_hw_desc->sg2l);
+               return le32_to_cpu(dma_hw_desc->sg3l);
+       case PPC440SPE_XOR_ID:
+               xor_hw_desc = desc->hw_desc;
+               return xor_hw_desc->cbtal;
+       }
+       return 0;
+}
+
+/**
+ * ppc440spe_desc_get_src_num - extract the number of source addresses from
+ * the descriptor
+ */
+static u32 ppc440spe_desc_get_src_num(struct ppc440spe_adma_desc_slot *desc,
+                               struct ppc440spe_adma_chan *chan)
+{
+       struct dma_cdb *dma_hw_desc;
+       struct xor_cb *xor_hw_desc;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_hw_desc = desc->hw_desc;
+
+               switch (dma_hw_desc->opc) {
+               case DMA_CDB_OPC_NO_OP:
+               case DMA_CDB_OPC_DFILL128:
+                       return 0;
+               case DMA_CDB_OPC_DCHECK128:
+                       return 1;
+               case DMA_CDB_OPC_MV_SG1_SG2:
+               case DMA_CDB_OPC_MULTICAST:
+                       /*
+                        * Only for RXOR operations we have more than
+                        * one source
+                        */
+                       if (le32_to_cpu(dma_hw_desc->sg1u) &
+                           DMA_CUED_XOR_WIN_MSK) {
+                               /* RXOR op, there are 2 or 3 sources */
+                               if (((le32_to_cpu(dma_hw_desc->sg1u) >>
+                                   DMA_CUED_REGION_OFF) &
+                                     DMA_CUED_REGION_MSK) == DMA_RXOR12) {
+                                       /* RXOR 1-2 */
+                                       return 2;
+                               } else {
+                                       /* RXOR 1-2-3/1-2-4/1-2-5 */
+                                       return 3;
+                               }
+                       }
+                       return 1;
+               default:
+                       printk(KERN_ERR "%s: unknown OPC 0x%02x\n",
+                               __func__, dma_hw_desc->opc);
+                       BUG();
+               }
+       case PPC440SPE_XOR_ID:
+               /* up to 16 sources */
+               xor_hw_desc = desc->hw_desc;
+               return xor_hw_desc->cbc & XOR_CDCR_OAC_MSK;
+       default:
+               BUG();
+       }
+       return 0;
+}
+
+/**
+ * ppc440spe_desc_get_dst_num - get the number of destination addresses in
+ * this descriptor
+ */
+static u32 ppc440spe_desc_get_dst_num(struct ppc440spe_adma_desc_slot *desc,
+                               struct ppc440spe_adma_chan *chan)
+{
+       struct dma_cdb *dma_hw_desc;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               /* May be 1 or 2 destinations */
+               dma_hw_desc = desc->hw_desc;
+               switch (dma_hw_desc->opc) {
+               case DMA_CDB_OPC_NO_OP:
+               case DMA_CDB_OPC_DCHECK128:
+                       return 0;
+               case DMA_CDB_OPC_MV_SG1_SG2:
+               case DMA_CDB_OPC_DFILL128:
+                       return 1;
+               case DMA_CDB_OPC_MULTICAST:
+                       if (desc->dst_cnt == 2)
+                               return 2;
+                       else
+                               return 1;
+               default:
+                       printk(KERN_ERR "%s: unknown OPC 0x%02x\n",
+                               __func__, dma_hw_desc->opc);
+                       BUG();
+               }
+       case PPC440SPE_XOR_ID:
+               /* Always only 1 destination */
+               return 1;
+       default:
+               BUG();
+       }
+       return 0;
+}
+
+/**
+ * ppc440spe_desc_get_link - get the address of the descriptor that
+ * follows this one
+ */
+static inline u32 ppc440spe_desc_get_link(struct ppc440spe_adma_desc_slot *desc,
+                                       struct ppc440spe_adma_chan *chan)
+{
+       if (!desc->hw_next)
+               return 0;
+
+       return desc->hw_next->phys;
+}
+
+/**
+ * ppc440spe_desc_is_aligned - check alignment
+ */
+static inline int ppc440spe_desc_is_aligned(
+       struct ppc440spe_adma_desc_slot *desc, int num_slots)
+{
+       return (desc->idx & (num_slots - 1)) ? 0 : 1;
+}
+
+/**
+ * ppc440spe_chan_xor_slot_count - get the number of slots necessary for
+ * XOR operation
+ */
+static int ppc440spe_chan_xor_slot_count(size_t len, int src_cnt,
+                       int *slots_per_op)
+{
+       int slot_cnt;
+
+       /* each XOR descriptor provides up to 16 source operands */
+       slot_cnt = *slots_per_op = (src_cnt + XOR_MAX_OPS - 1)/XOR_MAX_OPS;
+
+       if (likely(len <= PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT))
+               return slot_cnt;
+
+       printk(KERN_ERR "%s: len %d > max %d !!\n",
+               __func__, len, PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT);
+       BUG();
+       return slot_cnt;
+}
+
+/**
+ * ppc440spe_dma2_pq_slot_count - get the number of slots necessary for
+ * DMA2 PQ operation
+ */
+static int ppc440spe_dma2_pq_slot_count(dma_addr_t *srcs,
+               int src_cnt, size_t len)
+{
+       signed long long order = 0;
+       int state = 0;
+       int addr_count = 0;
+       int i;
+       for (i = 1; i < src_cnt; i++) {
+               dma_addr_t cur_addr = srcs[i];
+               dma_addr_t old_addr = srcs[i-1];
+               switch (state) {
+               case 0:
+                       if (cur_addr == old_addr + len) {
+                               /* direct RXOR */
+                               order = 1;
+                               state = 1;
+                               if (i == src_cnt-1)
+                                       addr_count++;
+                       } else if (old_addr == cur_addr + len) {
+                               /* reverse RXOR */
+                               order = -1;
+                               state = 1;
+                               if (i == src_cnt-1)
+                                       addr_count++;
+                       } else {
+                               state = 3;
+                       }
+                       break;
+               case 1:
+                       if (i == src_cnt-2 || (order == -1
+                               && cur_addr != old_addr - len)) {
+                               order = 0;
+                               state = 0;
+                               addr_count++;
+                       } else if (cur_addr == old_addr + len*order) {
+                               state = 2;
+                               if (i == src_cnt-1)
+                                       addr_count++;
+                       } else if (cur_addr == old_addr + 2*len) {
+                               state = 2;
+                               if (i == src_cnt-1)
+                                       addr_count++;
+                       } else if (cur_addr == old_addr + 3*len) {
+                               state = 2;
+                               if (i == src_cnt-1)
+                                       addr_count++;
+                       } else {
+                               order = 0;
+                               state = 0;
+                               addr_count++;
+                       }
+                       break;
+               case 2:
+                       order = 0;
+                       state = 0;
+                       addr_count++;
+                               break;
+               }
+               if (state == 3)
+                       break;
+       }
+       if (src_cnt <= 1 || (state != 1 && state != 2)) {
+               pr_err("%s: src_cnt=%d, state=%d, addr_count=%d, order=%lld\n",
+                       __func__, src_cnt, state, addr_count, order);
+               for (i = 0; i < src_cnt; i++)
+                       pr_err("\t[%d] 0x%llx \n", i, srcs[i]);
+               BUG();
+       }
+
+       return (addr_count + XOR_MAX_OPS - 1) / XOR_MAX_OPS;
+}
+
+
+/******************************************************************************
+ * ADMA channel low-level routines
+ ******************************************************************************/
+
+static u32
+ppc440spe_chan_get_current_descriptor(struct ppc440spe_adma_chan *chan);
+static void ppc440spe_chan_append(struct ppc440spe_adma_chan *chan);
+
+/**
+ * ppc440spe_adma_device_clear_eot_status - interrupt ack to XOR or DMA engine
+ */
+static void ppc440spe_adma_device_clear_eot_status(
+                                       struct ppc440spe_adma_chan *chan)
+{
+       struct dma_regs *dma_reg;
+       struct xor_regs *xor_reg;
+       u8 *p = chan->device->dma_desc_pool_virt;
+       struct dma_cdb *cdb;
+       u32 rv, i;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               /* read FIFO to ack */
+               dma_reg = chan->device->dma_reg;
+               while ((rv = ioread32(&dma_reg->csfpl))) {
+                       i = rv & DMA_CDB_ADDR_MSK;
+                       cdb = (struct dma_cdb *)&p[i -
+                           (u32)chan->device->dma_desc_pool];
+
+                       /* Clear opcode to ack. This is necessary for
+                        * ZeroSum operations only
+                        */
+                       cdb->opc = 0;
+
+                       if (test_bit(PPC440SPE_RXOR_RUN,
+                           &ppc440spe_rxor_state)) {
+                               /* probably this is a completed RXOR op,
+                                * get pointer to CDB using the fact that
+                                * physical and virtual addresses of CDB
+                                * in pools have the same offsets
+                                */
+                               if (le32_to_cpu(cdb->sg1u) &
+                                   DMA_CUED_XOR_BASE) {
+                                       /* this is a RXOR */
+                                       clear_bit(PPC440SPE_RXOR_RUN,
+                                                 &ppc440spe_rxor_state);
+                               }
+                       }
+
+                       if (rv & DMA_CDB_STATUS_MSK) {
+                               /* ZeroSum check failed
+                                */
+                               struct ppc440spe_adma_desc_slot *iter;
+                               dma_addr_t phys = rv & ~DMA_CDB_MSK;
+
+                               /*
+                                * Update the status of corresponding
+                                * descriptor.
+                                */
+                               list_for_each_entry(iter, &chan->chain,
+                                   chain_node) {
+                                       if (iter->phys == phys)
+                                               break;
+                               }
+                               /*
+                                * if cannot find the corresponding
+                                * slot it's a bug
+                                */
+                               BUG_ON(&iter->chain_node == &chan->chain);
+
+                               if (iter->xor_check_result) {
+                                       if (test_bit(PPC440SPE_DESC_PCHECK,
+                                                    &iter->flags)) {
+                                               *iter->xor_check_result |=
+                                                       SUM_CHECK_P_RESULT;
+                                       } else
+                                       if (test_bit(PPC440SPE_DESC_QCHECK,
+                                                    &iter->flags)) {
+                                               *iter->xor_check_result |=
+                                                       SUM_CHECK_Q_RESULT;
+                                       } else
+                                               BUG();
+                               }
+                       }
+               }
+
+               rv = ioread32(&dma_reg->dsts);
+               if (rv) {
+                       pr_err("DMA%d err status: 0x%x\n",
+                              chan->device->id, rv);
+                       /* write back to clear */
+                       iowrite32(rv, &dma_reg->dsts);
+               }
+               break;
+       case PPC440SPE_XOR_ID:
+               /* reset status bits to ack */
+               xor_reg = chan->device->xor_reg;
+               rv = ioread32be(&xor_reg->sr);
+               iowrite32be(rv, &xor_reg->sr);
+
+               if (rv & (XOR_IE_ICBIE_BIT|XOR_IE_ICIE_BIT|XOR_IE_RPTIE_BIT)) {
+                       if (rv & XOR_IE_RPTIE_BIT) {
+                               /* Read PLB Timeout Error.
+                                * Try to resubmit the CB
+                                */
+                               u32 val = ioread32be(&xor_reg->ccbalr);
+
+                               iowrite32be(val, &xor_reg->cblalr);
+
+                               val = ioread32be(&xor_reg->crsr);
+                               iowrite32be(val | XOR_CRSR_XAE_BIT,
+                                           &xor_reg->crsr);
+                       } else
+                               pr_err("XOR ERR 0x%x status\n", rv);
+                       break;
+               }
+
+               /*  if the XORcore is idle, but there are unprocessed CBs
+                * then refetch the s/w chain here
+                */
+               if (!(ioread32be(&xor_reg->sr) & XOR_SR_XCP_BIT) &&
+                   do_xor_refetch)
+                       ppc440spe_chan_append(chan);
+               break;
+       }
+}
+
+/**
+ * ppc440spe_chan_is_busy - get the channel status
+ */
+static int ppc440spe_chan_is_busy(struct ppc440spe_adma_chan *chan)
+{
+       struct dma_regs *dma_reg;
+       struct xor_regs *xor_reg;
+       int busy = 0;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_reg = chan->device->dma_reg;
+               /*  if command FIFO's head and tail pointers are equal and
+                * status tail is the same as command, then channel is free
+                */
+               if (ioread16(&dma_reg->cpfhp) != ioread16(&dma_reg->cpftp) ||
+                   ioread16(&dma_reg->cpftp) != ioread16(&dma_reg->csftp))
+                       busy = 1;
+               break;
+       case PPC440SPE_XOR_ID:
+               /* use the special status bit for the XORcore
+                */
+               xor_reg = chan->device->xor_reg;
+               busy = (ioread32be(&xor_reg->sr) & XOR_SR_XCP_BIT) ? 1 : 0;
+               break;
+       }
+
+       return busy;
+}
+
+/**
+ * ppc440spe_chan_set_first_xor_descriptor -  init XORcore chain
+ */
+static void ppc440spe_chan_set_first_xor_descriptor(
+                               struct ppc440spe_adma_chan *chan,
+                               struct ppc440spe_adma_desc_slot *next_desc)
+{
+       struct xor_regs *xor_reg = chan->device->xor_reg;
+
+       if (ioread32be(&xor_reg->sr) & XOR_SR_XCP_BIT)
+               printk(KERN_INFO "%s: Warn: XORcore is running "
+                       "when try to set the first CDB!\n",
+                       __func__);
+
+       xor_last_submit = xor_last_linked = next_desc;
+
+       iowrite32be(XOR_CRSR_64BA_BIT, &xor_reg->crsr);
+
+       iowrite32be(next_desc->phys, &xor_reg->cblalr);
+       iowrite32be(0, &xor_reg->cblahr);
+       iowrite32be(ioread32be(&xor_reg->cbcr) | XOR_CBCR_LNK_BIT,
+                   &xor_reg->cbcr);
+
+       chan->hw_chain_inited = 1;
+}
+
+/**
+ * ppc440spe_dma_put_desc - put DMA0,1 descriptor to FIFO.
+ * called with irqs disabled
+ */
+static void ppc440spe_dma_put_desc(struct ppc440spe_adma_chan *chan,
+               struct ppc440spe_adma_desc_slot *desc)
+{
+       u32 pcdb;
+       struct dma_regs *dma_reg = chan->device->dma_reg;
+
+       pcdb = desc->phys;
+       if (!test_bit(PPC440SPE_DESC_INT, &desc->flags))
+               pcdb |= DMA_CDB_NO_INT;
+
+       chan_last_sub[chan->device->id] = desc;
+
+       ADMA_LL_DBG(print_cb(chan, desc->hw_desc));
+
+       iowrite32(pcdb, &dma_reg->cpfpl);
+}
+
+/**
+ * ppc440spe_chan_append - update the h/w chain in the channel
+ */
+static void ppc440spe_chan_append(struct ppc440spe_adma_chan *chan)
+{
+       struct xor_regs *xor_reg;
+       struct ppc440spe_adma_desc_slot *iter;
+       struct xor_cb *xcb;
+       u32 cur_desc;
+       unsigned long flags;
+
+       local_irq_save(flags);
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               cur_desc = ppc440spe_chan_get_current_descriptor(chan);
+
+               if (likely(cur_desc)) {
+                       iter = chan_last_sub[chan->device->id];
+                       BUG_ON(!iter);
+               } else {
+                       /* first peer */
+                       iter = chan_first_cdb[chan->device->id];
+                       BUG_ON(!iter);
+                       ppc440spe_dma_put_desc(chan, iter);
+                       chan->hw_chain_inited = 1;
+               }
+
+               /* is there something new to append */
+               if (!iter->hw_next)
+                       break;
+
+               /* flush descriptors from the s/w queue to fifo */
+               list_for_each_entry_continue(iter, &chan->chain, chain_node) {
+                       ppc440spe_dma_put_desc(chan, iter);
+                       if (!iter->hw_next)
+                               break;
+               }
+               break;
+       case PPC440SPE_XOR_ID:
+               /* update h/w links and refetch */
+               if (!xor_last_submit->hw_next)
+                       break;
+
+               xor_reg = chan->device->xor_reg;
+               /* the last linked CDB has to generate an interrupt
+                * that we'd be able to append the next lists to h/w
+                * regardless of the XOR engine state at the moment of
+                * appending of these next lists
+                */
+               xcb = xor_last_linked->hw_desc;
+               xcb->cbc |= XOR_CBCR_CBCE_BIT;
+
+               if (!(ioread32be(&xor_reg->sr) & XOR_SR_XCP_BIT)) {
+                       /* XORcore is idle. Refetch now */
+                       do_xor_refetch = 0;
+                       ppc440spe_xor_set_link(xor_last_submit,
+                               xor_last_submit->hw_next);
+
+                       ADMA_LL_DBG(print_cb_list(chan,
+                               xor_last_submit->hw_next));
+
+                       xor_last_submit = xor_last_linked;
+                       iowrite32be(ioread32be(&xor_reg->crsr) |
+                                   XOR_CRSR_RCBE_BIT | XOR_CRSR_64BA_BIT,
+                                   &xor_reg->crsr);
+               } else {
+                       /* XORcore is running. Refetch later in the handler */
+                       do_xor_refetch = 1;
+               }
+
+               break;
+       }
+
+       local_irq_restore(flags);
+}
+
+/**
+ * ppc440spe_chan_get_current_descriptor - get the currently executed descriptor
+ */
+static u32
+ppc440spe_chan_get_current_descriptor(struct ppc440spe_adma_chan *chan)
+{
+       struct dma_regs *dma_reg;
+       struct xor_regs *xor_reg;
+
+       if (unlikely(!chan->hw_chain_inited))
+               /* h/w descriptor chain is not initialized yet */
+               return 0;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_reg = chan->device->dma_reg;
+               return ioread32(&dma_reg->acpl) & (~DMA_CDB_MSK);
+       case PPC440SPE_XOR_ID:
+               xor_reg = chan->device->xor_reg;
+               return ioread32be(&xor_reg->ccbalr);
+       }
+       return 0;
+}
+
+/**
+ * ppc440spe_chan_run - enable the channel
+ */
+static void ppc440spe_chan_run(struct ppc440spe_adma_chan *chan)
+{
+       struct xor_regs *xor_reg;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               /* DMAs are always enabled, do nothing */
+               break;
+       case PPC440SPE_XOR_ID:
+               /* drain write buffer */
+               xor_reg = chan->device->xor_reg;
+
+               /* fetch descriptor pointed to in <link> */
+               iowrite32be(XOR_CRSR_64BA_BIT | XOR_CRSR_XAE_BIT,
+                           &xor_reg->crsr);
+               break;
+       }
+}
+
+/******************************************************************************
+ * ADMA device level
+ ******************************************************************************/
+
+static void ppc440spe_chan_start_null_xor(struct ppc440spe_adma_chan *chan);
+static int ppc440spe_adma_alloc_chan_resources(struct dma_chan *chan);
+
+static dma_cookie_t
+ppc440spe_adma_tx_submit(struct dma_async_tx_descriptor *tx);
+
+static void ppc440spe_adma_set_dest(struct ppc440spe_adma_desc_slot *tx,
+                                   dma_addr_t addr, int index);
+static void
+ppc440spe_adma_memcpy_xor_set_src(struct ppc440spe_adma_desc_slot *tx,
+                                 dma_addr_t addr, int index);
+
+static void
+ppc440spe_adma_pq_set_dest(struct ppc440spe_adma_desc_slot *tx,
+                          dma_addr_t *paddr, unsigned long flags);
+static void
+ppc440spe_adma_pq_set_src(struct ppc440spe_adma_desc_slot *tx,
+                         dma_addr_t addr, int index);
+static void
+ppc440spe_adma_pq_set_src_mult(struct ppc440spe_adma_desc_slot *tx,
+                              unsigned char mult, int index, int dst_pos);
+static void
+ppc440spe_adma_pqzero_sum_set_dest(struct ppc440spe_adma_desc_slot *tx,
+                                  dma_addr_t paddr, dma_addr_t qaddr);
+
+static struct page *ppc440spe_rxor_srcs[32];
+
+/**
+ * ppc440spe_can_rxor - check if the operands may be processed with RXOR
+ */
+static int ppc440spe_can_rxor(struct page **srcs, int src_cnt, size_t len)
+{
+       int i, order = 0, state = 0;
+       int idx = 0;
+
+       if (unlikely(!(src_cnt > 1)))
+               return 0;
+
+       BUG_ON(src_cnt > ARRAY_SIZE(ppc440spe_rxor_srcs));
+
+       /* Skip holes in the source list before checking */
+       for (i = 0; i < src_cnt; i++) {
+               if (!srcs[i])
+                       continue;
+               ppc440spe_rxor_srcs[idx++] = srcs[i];
+       }
+       src_cnt = idx;
+
+       for (i = 1; i < src_cnt; i++) {
+               char *cur_addr = page_address(ppc440spe_rxor_srcs[i]);
+               char *old_addr = page_address(ppc440spe_rxor_srcs[i - 1]);
+
+               switch (state) {
+               case 0:
+                       if (cur_addr == old_addr + len) {
+                               /* direct RXOR */
+                               order = 1;
+                               state = 1;
+                       } else if (old_addr == cur_addr + len) {
+                               /* reverse RXOR */
+                               order = -1;
+                               state = 1;
+                       } else
+                               goto out;
+                       break;
+               case 1:
+                       if ((i == src_cnt - 2) ||
+                           (order == -1 && cur_addr != old_addr - len)) {
+                               order = 0;
+                               state = 0;
+                       } else if ((cur_addr == old_addr + len * order) ||
+                                  (cur_addr == old_addr + 2 * len) ||
+                                  (cur_addr == old_addr + 3 * len)) {
+                               state = 2;
+                       } else {
+                               order = 0;
+                               state = 0;
+                       }
+                       break;
+               case 2:
+                       order = 0;
+                       state = 0;
+                       break;
+               }
+       }
+
+out:
+       if (state == 1 || state == 2)
+               return 1;
+
+       return 0;
+}
+
+/**
+ * ppc440spe_adma_device_estimate - estimate the efficiency of processing
+ *     the operation given on this channel. It's assumed that 'chan' is
+ *     capable to process 'cap' type of operation.
+ * @chan: channel to use
+ * @cap: type of transaction
+ * @dst_lst: array of destination pointers
+ * @dst_cnt: number of destination operands
+ * @src_lst: array of source pointers
+ * @src_cnt: number of source operands
+ * @src_sz: size of each source operand
+ */
+static int ppc440spe_adma_estimate(struct dma_chan *chan,
+       enum dma_transaction_type cap, struct page **dst_lst, int dst_cnt,
+       struct page **src_lst, int src_cnt, size_t src_sz)
+{
+       int ef = 1;
+
+       if (cap == DMA_PQ || cap == DMA_PQ_VAL) {
+               /* If RAID-6 capabilities were not activated don't try
+                * to use them
+                */
+               if (unlikely(!ppc440spe_r6_enabled))
+                       return -1;
+       }
+       /*  In the current implementation of ppc440spe ADMA driver it
+        * makes sense to pick out only pq case, because it may be
+        * processed:
+        * (1) either using Biskup method on DMA2;
+        * (2) or on DMA0/1.
+        *  Thus we give a favour to (1) if the sources are suitable;
+        * else let it be processed on one of the DMA0/1 engines.
+        *  In the sum_product case where destination is also the
+        * source process it on DMA0/1 only.
+        */
+       if (cap == DMA_PQ && chan->chan_id == PPC440SPE_XOR_ID) {
+
+               if (dst_cnt == 1 && src_cnt == 2 && dst_lst[0] == src_lst[1])
+                       ef = 0; /* sum_product case, process on DMA0/1 */
+               else if (ppc440spe_can_rxor(src_lst, src_cnt, src_sz))
+                       ef = 3; /* override (DMA0/1 + idle) */
+               else
+                       ef = 0; /* can't process on DMA2 if !rxor */
+       }
+
+       /* channel idleness increases the priority */
+       if (likely(ef) &&
+           !ppc440spe_chan_is_busy(to_ppc440spe_adma_chan(chan)))
+               ef++;
+
+       return ef;
+}
+
+struct dma_chan *
+ppc440spe_async_tx_find_best_channel(enum dma_transaction_type cap,
+       struct page **dst_lst, int dst_cnt, struct page **src_lst,
+       int src_cnt, size_t src_sz)
+{
+       struct dma_chan *best_chan = NULL;
+       struct ppc_dma_chan_ref *ref;
+       int best_rank = -1;
+
+       if (unlikely(!src_sz))
+               return NULL;
+       if (src_sz > PAGE_SIZE) {
+               /*
+                * should a user of the api ever pass > PAGE_SIZE requests
+                * we sort out cases where temporary page-sized buffers
+                * are used.
+                */
+               switch (cap) {
+               case DMA_PQ:
+                       if (src_cnt == 1 && dst_lst[1] == src_lst[0])
+                               return NULL;
+                       if (src_cnt == 2 && dst_lst[1] == src_lst[1])
+                               return NULL;
+                       break;
+               case DMA_PQ_VAL:
+               case DMA_XOR_VAL:
+                       return NULL;
+               default:
+                       break;
+               }
+       }
+
+       list_for_each_entry(ref, &ppc440spe_adma_chan_list, node) {
+               if (dma_has_cap(cap, ref->chan->device->cap_mask)) {
+                       int rank;
+
+                       rank = ppc440spe_adma_estimate(ref->chan, cap, dst_lst,
+                                       dst_cnt, src_lst, src_cnt, src_sz);
+                       if (rank > best_rank) {
+                               best_rank = rank;
+                               best_chan = ref->chan;
+                       }
+               }
+       }
+
+       return best_chan;
+}
+EXPORT_SYMBOL_GPL(ppc440spe_async_tx_find_best_channel);
+
+/**
+ * ppc440spe_get_group_entry - get group entry with index idx
+ * @tdesc: is the last allocated slot in the group.
+ */
+static struct ppc440spe_adma_desc_slot *
+ppc440spe_get_group_entry(struct ppc440spe_adma_desc_slot *tdesc, u32 entry_idx)
+{
+       struct ppc440spe_adma_desc_slot *iter = tdesc->group_head;
+       int i = 0;
+
+       if (entry_idx < 0 || entry_idx >= (tdesc->src_cnt + tdesc->dst_cnt)) {
+               printk("%s: entry_idx %d, src_cnt %d, dst_cnt %d\n",
+                       __func__, entry_idx, tdesc->src_cnt, tdesc->dst_cnt);
+               BUG();
+       }
+
+       list_for_each_entry(iter, &tdesc->group_list, chain_node) {
+               if (i++ == entry_idx)
+                       break;
+       }
+       return iter;
+}
+
+/**
+ * ppc440spe_adma_free_slots - flags descriptor slots for reuse
+ * @slot: Slot to free
+ * Caller must hold &ppc440spe_chan->lock while calling this function
+ */
+static void ppc440spe_adma_free_slots(struct ppc440spe_adma_desc_slot *slot,
+                                     struct ppc440spe_adma_chan *chan)
+{
+       int stride = slot->slots_per_op;
+
+       while (stride--) {
+               slot->slots_per_op = 0;
+               slot = list_entry(slot->slot_node.next,
+                               struct ppc440spe_adma_desc_slot,
+                               slot_node);
+       }
+}
+
+static void ppc440spe_adma_unmap(struct ppc440spe_adma_chan *chan,
+                                struct ppc440spe_adma_desc_slot *desc)
+{
+       u32 src_cnt, dst_cnt;
+       dma_addr_t addr;
+
+       /*
+        * get the number of sources & destination
+        * included in this descriptor and unmap
+        * them all
+        */
+       src_cnt = ppc440spe_desc_get_src_num(desc, chan);
+       dst_cnt = ppc440spe_desc_get_dst_num(desc, chan);
+
+       /* unmap destinations */
+       if (!(desc->async_tx.flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
+               while (dst_cnt--) {
+                       addr = ppc440spe_desc_get_dest_addr(
+                               desc, chan, dst_cnt);
+                       dma_unmap_page(chan->device->dev,
+                                       addr, desc->unmap_len,
+                                       DMA_FROM_DEVICE);
+               }
+       }
+
+       /* unmap sources */
+       if (!(desc->async_tx.flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
+               while (src_cnt--) {
+                       addr = ppc440spe_desc_get_src_addr(
+                               desc, chan, src_cnt);
+                       dma_unmap_page(chan->device->dev,
+                                       addr, desc->unmap_len,
+                                       DMA_TO_DEVICE);
+               }
+       }
+}
+
+/**
+ * ppc440spe_adma_run_tx_complete_actions - call functions to be called
+ * upon completion
+ */
+static dma_cookie_t ppc440spe_adma_run_tx_complete_actions(
+               struct ppc440spe_adma_desc_slot *desc,
+               struct ppc440spe_adma_chan *chan,
+               dma_cookie_t cookie)
+{
+       int i;
+
+       BUG_ON(desc->async_tx.cookie < 0);
+       if (desc->async_tx.cookie > 0) {
+               cookie = desc->async_tx.cookie;
+               desc->async_tx.cookie = 0;
+
+               /* call the callback (must not sleep or submit new
+                * operations to this channel)
+                */
+               if (desc->async_tx.callback)
+                       desc->async_tx.callback(
+                               desc->async_tx.callback_param);
+
+               /* unmap dma addresses
+                * (unmap_single vs unmap_page?)
+                *
+                * actually, ppc's dma_unmap_page() functions are empty, so
+                * the following code is just for the sake of completeness
+                */
+               if (chan && chan->needs_unmap && desc->group_head &&
+                    desc->unmap_len) {
+                       struct ppc440spe_adma_desc_slot *unmap =
+                                                       desc->group_head;
+                       /* assume 1 slot per op always */
+                       u32 slot_count = unmap->slot_cnt;
+
+                       /* Run through the group list and unmap addresses */
+                       for (i = 0; i < slot_count; i++) {
+                               BUG_ON(!unmap);
+                               ppc440spe_adma_unmap(chan, unmap);
+                               unmap = unmap->hw_next;
+                       }
+               }
+       }
+
+       /* run dependent operations */
+       dma_run_dependencies(&desc->async_tx);
+
+       return cookie;
+}
+
+/**
+ * ppc440spe_adma_clean_slot - clean up CDB slot (if ack is set)
+ */
+static int ppc440spe_adma_clean_slot(struct ppc440spe_adma_desc_slot *desc,
+               struct ppc440spe_adma_chan *chan)
+{
+       /* the client is allowed to attach dependent operations
+        * until 'ack' is set
+        */
+       if (!async_tx_test_ack(&desc->async_tx))
+               return 0;
+
+       /* leave the last descriptor in the chain
+        * so we can append to it
+        */
+       if (list_is_last(&desc->chain_node, &chan->chain) ||
+           desc->phys == ppc440spe_chan_get_current_descriptor(chan))
+               return 1;
+
+       if (chan->device->id != PPC440SPE_XOR_ID) {
+               /* our DMA interrupt handler clears opc field of
+                * each processed descriptor. For all types of
+                * operations except for ZeroSum we do not actually
+                * need ack from the interrupt handler. ZeroSum is a
+                * special case since the result of this operation
+                * is available from the handler only, so if we see
+                * such type of descriptor (which is unprocessed yet)
+                * then leave it in chain.
+                */
+               struct dma_cdb *cdb = desc->hw_desc;
+               if (cdb->opc == DMA_CDB_OPC_DCHECK128)
+                       return 1;
+       }
+
+       dev_dbg(chan->device->common.dev, "\tfree slot %llx: %d stride: %d\n",
+               desc->phys, desc->idx, desc->slots_per_op);
+
+       list_del(&desc->chain_node);
+       ppc440spe_adma_free_slots(desc, chan);
+       return 0;
+}
+
+/**
+ * __ppc440spe_adma_slot_cleanup - this is the common clean-up routine
+ *     which runs through the channel CDBs list until reach the descriptor
+ *     currently processed. When routine determines that all CDBs of group
+ *     are completed then corresponding callbacks (if any) are called and slots
+ *     are freed.
+ */
+static void __ppc440spe_adma_slot_cleanup(struct ppc440spe_adma_chan *chan)
+{
+       struct ppc440spe_adma_desc_slot *iter, *_iter, *group_start = NULL;
+       dma_cookie_t cookie = 0;
+       u32 current_desc = ppc440spe_chan_get_current_descriptor(chan);
+       int busy = ppc440spe_chan_is_busy(chan);
+       int seen_current = 0, slot_cnt = 0, slots_per_op = 0;
+
+       dev_dbg(chan->device->common.dev, "ppc440spe adma%d: %s\n",
+               chan->device->id, __func__);
+
+       if (!current_desc) {
+               /*  There were no transactions yet, so
+                * nothing to clean
+                */
+               return;
+       }
+
+       /* free completed slots from the chain starting with
+        * the oldest descriptor
+        */
+       list_for_each_entry_safe(iter, _iter, &chan->chain,
+                                       chain_node) {
+               dev_dbg(chan->device->common.dev, "\tcookie: %d slot: %d "
+                   "busy: %d this_desc: %#llx next_desc: %#x "
+                   "cur: %#x ack: %d\n",
+                   iter->async_tx.cookie, iter->idx, busy, iter->phys,
+                   ppc440spe_desc_get_link(iter, chan), current_desc,
+                   async_tx_test_ack(&iter->async_tx));
+               prefetch(_iter);
+               prefetch(&_iter->async_tx);
+
+               /* do not advance past the current descriptor loaded into the
+                * hardware channel,subsequent descriptors are either in process
+                * or have not been submitted
+                */
+               if (seen_current)
+                       break;
+
+               /* stop the search if we reach the current descriptor and the
+                * channel is busy, or if it appears that the current descriptor
+                * needs to be re-read (i.e. has been appended to)
+                */
+               if (iter->phys == current_desc) {
+                       BUG_ON(seen_current++);
+                       if (busy || ppc440spe_desc_get_link(iter, chan)) {
+                               /* not all descriptors of the group have
+                                * been completed; exit.
+                                */
+                               break;
+                       }
+               }
+
+               /* detect the start of a group transaction */
+               if (!slot_cnt && !slots_per_op) {
+                       slot_cnt = iter->slot_cnt;
+                       slots_per_op = iter->slots_per_op;
+                       if (slot_cnt <= slots_per_op) {
+                               slot_cnt = 0;
+                               slots_per_op = 0;
+                       }
+               }
+
+               if (slot_cnt) {
+                       if (!group_start)
+                               group_start = iter;
+                       slot_cnt -= slots_per_op;
+               }
+
+               /* all the members of a group are complete */
+               if (slots_per_op != 0 && slot_cnt == 0) {
+                       struct ppc440spe_adma_desc_slot *grp_iter, *_grp_iter;
+                       int end_of_chain = 0;
+
+                       /* clean up the group */
+                       slot_cnt = group_start->slot_cnt;
+                       grp_iter = group_start;
+                       list_for_each_entry_safe_from(grp_iter, _grp_iter,
+                               &chan->chain, chain_node) {
+
+                               cookie = ppc440spe_adma_run_tx_complete_actions(
+                                       grp_iter, chan, cookie);
+
+                               slot_cnt -= slots_per_op;
+                               end_of_chain = ppc440spe_adma_clean_slot(
+                                   grp_iter, chan);
+                               if (end_of_chain && slot_cnt) {
+                                       /* Should wait for ZeroSum completion */
+                                       if (cookie > 0)
+                                               chan->completed_cookie = cookie;
+                                       return;
+                               }
+
+                               if (slot_cnt == 0 || end_of_chain)
+                                       break;
+                       }
+
+                       /* the group should be complete at this point */
+                       BUG_ON(slot_cnt);
+
+                       slots_per_op = 0;
+                       group_start = NULL;
+                       if (end_of_chain)
+                               break;
+                       else
+                               continue;
+               } else if (slots_per_op) /* wait for group completion */
+                       continue;
+
+               cookie = ppc440spe_adma_run_tx_complete_actions(iter, chan,
+                   cookie);
+
+               if (ppc440spe_adma_clean_slot(iter, chan))
+                       break;
+       }
+
+       BUG_ON(!seen_current);
+
+       if (cookie > 0) {
+               chan->completed_cookie = cookie;
+               pr_debug("\tcompleted cookie %d\n", cookie);
+       }
+
+}
+
+/**
+ * ppc440spe_adma_tasklet - clean up watch-dog initiator
+ */
+static void ppc440spe_adma_tasklet(unsigned long data)
+{
+       struct ppc440spe_adma_chan *chan = (struct ppc440spe_adma_chan *) data;
+
+       spin_lock_nested(&chan->lock, SINGLE_DEPTH_NESTING);
+       __ppc440spe_adma_slot_cleanup(chan);
+       spin_unlock(&chan->lock);
+}
+
+/**
+ * ppc440spe_adma_slot_cleanup - clean up scheduled initiator
+ */
+static void ppc440spe_adma_slot_cleanup(struct ppc440spe_adma_chan *chan)
+{
+       spin_lock_bh(&chan->lock);
+       __ppc440spe_adma_slot_cleanup(chan);
+       spin_unlock_bh(&chan->lock);
+}
+
+/**
+ * ppc440spe_adma_alloc_slots - allocate free slots (if any)
+ */
+static struct ppc440spe_adma_desc_slot *ppc440spe_adma_alloc_slots(
+               struct ppc440spe_adma_chan *chan, int num_slots,
+               int slots_per_op)
+{
+       struct ppc440spe_adma_desc_slot *iter = NULL, *_iter;
+       struct ppc440spe_adma_desc_slot *alloc_start = NULL;
+       struct list_head chain = LIST_HEAD_INIT(chain);
+       int slots_found, retry = 0;
+
+
+       BUG_ON(!num_slots || !slots_per_op);
+       /* start search from the last allocated descrtiptor
+        * if a contiguous allocation can not be found start searching
+        * from the beginning of the list
+        */
+retry:
+       slots_found = 0;
+       if (retry == 0)
+               iter = chan->last_used;
+       else
+               iter = list_entry(&chan->all_slots,
+                                 struct ppc440spe_adma_desc_slot,
+                                 slot_node);
+       list_for_each_entry_safe_continue(iter, _iter, &chan->all_slots,
+           slot_node) {
+               prefetch(_iter);
+               prefetch(&_iter->async_tx);
+               if (iter->slots_per_op) {
+                       slots_found = 0;
+                       continue;
+               }
+
+               /* start the allocation if the slot is correctly aligned */
+               if (!slots_found++)
+                       alloc_start = iter;
+
+               if (slots_found == num_slots) {
+                       struct ppc440spe_adma_desc_slot *alloc_tail = NULL;
+                       struct ppc440spe_adma_desc_slot *last_used = NULL;
+
+                       iter = alloc_start;
+                       while (num_slots) {
+                               int i;
+                               /* pre-ack all but the last descriptor */
+                               if (num_slots != slots_per_op)
+                                       async_tx_ack(&iter->async_tx);
+
+                               list_add_tail(&iter->chain_node, &chain);
+                               alloc_tail = iter;
+                               iter->async_tx.cookie = 0;
+                               iter->hw_next = NULL;
+                               iter->flags = 0;
+                               iter->slot_cnt = num_slots;
+                               iter->xor_check_result = NULL;
+                               for (i = 0; i < slots_per_op; i++) {
+                                       iter->slots_per_op = slots_per_op - i;
+                                       last_used = iter;
+                                       iter = list_entry(iter->slot_node.next,
+                                               struct ppc440spe_adma_desc_slot,
+                                               slot_node);
+                               }
+                               num_slots -= slots_per_op;
+                       }
+                       alloc_tail->group_head = alloc_start;
+                       alloc_tail->async_tx.cookie = -EBUSY;
+                       list_splice(&chain, &alloc_tail->group_list);
+                       chan->last_used = last_used;
+                       return alloc_tail;
+               }
+       }
+       if (!retry++)
+               goto retry;
+
+       /* try to free some slots if the allocation fails */
+       tasklet_schedule(&chan->irq_tasklet);
+       return NULL;
+}
+
+/**
+ * ppc440spe_adma_alloc_chan_resources -  allocate pools for CDB slots
+ */
+static int ppc440spe_adma_alloc_chan_resources(struct dma_chan *chan)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       struct ppc440spe_adma_desc_slot *slot = NULL;
+       char *hw_desc;
+       int i, db_sz;
+       int init;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+       init = ppc440spe_chan->slots_allocated ? 0 : 1;
+       chan->chan_id = ppc440spe_chan->device->id;
+
+       /* Allocate descriptor slots */
+       i = ppc440spe_chan->slots_allocated;
+       if (ppc440spe_chan->device->id != PPC440SPE_XOR_ID)
+               db_sz = sizeof(struct dma_cdb);
+       else
+               db_sz = sizeof(struct xor_cb);
+
+       for (; i < (ppc440spe_chan->device->pool_size / db_sz); i++) {
+               slot = kzalloc(sizeof(struct ppc440spe_adma_desc_slot),
+                              GFP_KERNEL);
+               if (!slot) {
+                       printk(KERN_INFO "SPE ADMA Channel only initialized"
+                               " %d descriptor slots", i--);
+                       break;
+               }
+
+               hw_desc = (char *) ppc440spe_chan->device->dma_desc_pool_virt;
+               slot->hw_desc = (void *) &hw_desc[i * db_sz];
+               dma_async_tx_descriptor_init(&slot->async_tx, chan);
+               slot->async_tx.tx_submit = ppc440spe_adma_tx_submit;
+               INIT_LIST_HEAD(&slot->chain_node);
+               INIT_LIST_HEAD(&slot->slot_node);
+               INIT_LIST_HEAD(&slot->group_list);
+               slot->phys = ppc440spe_chan->device->dma_desc_pool + i * db_sz;
+               slot->idx = i;
+
+               spin_lock_bh(&ppc440spe_chan->lock);
+               ppc440spe_chan->slots_allocated++;
+               list_add_tail(&slot->slot_node, &ppc440spe_chan->all_slots);
+               spin_unlock_bh(&ppc440spe_chan->lock);
+       }
+
+       if (i && !ppc440spe_chan->last_used) {
+               ppc440spe_chan->last_used =
+                       list_entry(ppc440spe_chan->all_slots.next,
+                               struct ppc440spe_adma_desc_slot,
+                               slot_node);
+       }
+
+       dev_dbg(ppc440spe_chan->device->common.dev,
+               "ppc440spe adma%d: allocated %d descriptor slots\n",
+               ppc440spe_chan->device->id, i);
+
+       /* initialize the channel and the chain with a null operation */
+       if (init) {
+               switch (ppc440spe_chan->device->id) {
+               case PPC440SPE_DMA0_ID:
+               case PPC440SPE_DMA1_ID:
+                       ppc440spe_chan->hw_chain_inited = 0;
+                       /* Use WXOR for self-testing */
+                       if (!ppc440spe_r6_tchan)
+                               ppc440spe_r6_tchan = ppc440spe_chan;
+                       break;
+               case PPC440SPE_XOR_ID:
+                       ppc440spe_chan_start_null_xor(ppc440spe_chan);
+                       break;
+               default:
+                       BUG();
+               }
+               ppc440spe_chan->needs_unmap = 1;
+       }
+
+       return (i > 0) ? i : -ENOMEM;
+}
+
+/**
+ * ppc440spe_desc_assign_cookie - assign a cookie
+ */
+static dma_cookie_t ppc440spe_desc_assign_cookie(
+               struct ppc440spe_adma_chan *chan,
+               struct ppc440spe_adma_desc_slot *desc)
+{
+       dma_cookie_t cookie = chan->common.cookie;
+
+       cookie++;
+       if (cookie < 0)
+               cookie = 1;
+       chan->common.cookie = desc->async_tx.cookie = cookie;
+       return cookie;
+}
+
+/**
+ * ppc440spe_rxor_set_region_data -
+ */
+static void ppc440spe_rxor_set_region(struct ppc440spe_adma_desc_slot *desc,
+       u8 xor_arg_no, u32 mask)
+{
+       struct xor_cb *xcb = desc->hw_desc;
+
+       xcb->ops[xor_arg_no].h |= mask;
+}
+
+/**
+ * ppc440spe_rxor_set_src -
+ */
+static void ppc440spe_rxor_set_src(struct ppc440spe_adma_desc_slot *desc,
+       u8 xor_arg_no, dma_addr_t addr)
+{
+       struct xor_cb *xcb = desc->hw_desc;
+
+       xcb->ops[xor_arg_no].h |= DMA_CUED_XOR_BASE;
+       xcb->ops[xor_arg_no].l = addr;
+}
+
+/**
+ * ppc440spe_rxor_set_mult -
+ */
+static void ppc440spe_rxor_set_mult(struct ppc440spe_adma_desc_slot *desc,
+       u8 xor_arg_no, u8 idx, u8 mult)
+{
+       struct xor_cb *xcb = desc->hw_desc;
+
+       xcb->ops[xor_arg_no].h |= mult << (DMA_CUED_MULT1_OFF + idx * 8);
+}
+
+/**
+ * ppc440spe_adma_check_threshold - append CDBs to h/w chain if threshold
+ *     has been achieved
+ */
+static void ppc440spe_adma_check_threshold(struct ppc440spe_adma_chan *chan)
+{
+       dev_dbg(chan->device->common.dev, "ppc440spe adma%d: pending: %d\n",
+               chan->device->id, chan->pending);
+
+       if (chan->pending >= PPC440SPE_ADMA_THRESHOLD) {
+               chan->pending = 0;
+               ppc440spe_chan_append(chan);
+       }
+}
+
+/**
+ * ppc440spe_adma_tx_submit - submit new descriptor group to the channel
+ *     (it's not necessary that descriptors will be submitted to the h/w
+ *     chains too right now)
+ */
+static dma_cookie_t ppc440spe_adma_tx_submit(struct dma_async_tx_descriptor *tx)
+{
+       struct ppc440spe_adma_desc_slot *sw_desc;
+       struct ppc440spe_adma_chan *chan = to_ppc440spe_adma_chan(tx->chan);
+       struct ppc440spe_adma_desc_slot *group_start, *old_chain_tail;
+       int slot_cnt;
+       int slots_per_op;
+       dma_cookie_t cookie;
+
+       sw_desc = tx_to_ppc440spe_adma_slot(tx);
+
+       group_start = sw_desc->group_head;
+       slot_cnt = group_start->slot_cnt;
+       slots_per_op = group_start->slots_per_op;
+
+       spin_lock_bh(&chan->lock);
+
+       cookie = ppc440spe_desc_assign_cookie(chan, sw_desc);
+
+       if (unlikely(list_empty(&chan->chain))) {
+               /* first peer */
+               list_splice_init(&sw_desc->group_list, &chan->chain);
+               chan_first_cdb[chan->device->id] = group_start;
+       } else {
+               /* isn't first peer, bind CDBs to chain */
+               old_chain_tail = list_entry(chan->chain.prev,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               list_splice_init(&sw_desc->group_list,
+                   &old_chain_tail->chain_node);
+               /* fix up the hardware chain */
+               ppc440spe_desc_set_link(chan, old_chain_tail, group_start);
+       }
+
+       /* increment the pending count by the number of operations */
+       chan->pending += slot_cnt / slots_per_op;
+       ppc440spe_adma_check_threshold(chan);
+       spin_unlock_bh(&chan->lock);
+
+       dev_dbg(chan->device->common.dev,
+               "ppc440spe adma%d: %s cookie: %d slot: %d tx %p\n",
+               chan->device->id, __func__,
+               sw_desc->async_tx.cookie, sw_desc->idx, sw_desc);
+
+       return cookie;
+}
+
+/**
+ * ppc440spe_adma_prep_dma_interrupt - prepare CDB for a pseudo DMA operation
+ */
+static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_interrupt(
+               struct dma_chan *chan, unsigned long flags)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       struct ppc440spe_adma_desc_slot *sw_desc, *group_start;
+       int slot_cnt, slots_per_op;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+
+       dev_dbg(ppc440spe_chan->device->common.dev,
+               "ppc440spe adma%d: %s\n", ppc440spe_chan->device->id,
+               __func__);
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+       slot_cnt = slots_per_op = 1;
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt,
+                       slots_per_op);
+       if (sw_desc) {
+               group_start = sw_desc->group_head;
+               ppc440spe_desc_init_interrupt(group_start, ppc440spe_chan);
+               group_start->unmap_len = 0;
+               sw_desc->async_tx.flags = flags;
+       }
+       spin_unlock_bh(&ppc440spe_chan->lock);
+
+       return sw_desc ? &sw_desc->async_tx : NULL;
+}
+
+/**
+ * ppc440spe_adma_prep_dma_memcpy - prepare CDB for a MEMCPY operation
+ */
+static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_memcpy(
+               struct dma_chan *chan, dma_addr_t dma_dest,
+               dma_addr_t dma_src, size_t len, unsigned long flags)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       struct ppc440spe_adma_desc_slot *sw_desc, *group_start;
+       int slot_cnt, slots_per_op;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+
+       if (unlikely(!len))
+               return NULL;
+
+       BUG_ON(unlikely(len > PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT));
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+
+       dev_dbg(ppc440spe_chan->device->common.dev,
+               "ppc440spe adma%d: %s len: %u int_en %d\n",
+               ppc440spe_chan->device->id, __func__, len,
+               flags & DMA_PREP_INTERRUPT ? 1 : 0);
+       slot_cnt = slots_per_op = 1;
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt,
+               slots_per_op);
+       if (sw_desc) {
+               group_start = sw_desc->group_head;
+               ppc440spe_desc_init_memcpy(group_start, flags);
+               ppc440spe_adma_set_dest(group_start, dma_dest, 0);
+               ppc440spe_adma_memcpy_xor_set_src(group_start, dma_src, 0);
+               ppc440spe_desc_set_byte_count(group_start, ppc440spe_chan, len);
+               sw_desc->unmap_len = len;
+               sw_desc->async_tx.flags = flags;
+       }
+       spin_unlock_bh(&ppc440spe_chan->lock);
+
+       return sw_desc ? &sw_desc->async_tx : NULL;
+}
+
+/**
+ * ppc440spe_adma_prep_dma_memset - prepare CDB for a MEMSET operation
+ */
+static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_memset(
+               struct dma_chan *chan, dma_addr_t dma_dest, int value,
+               size_t len, unsigned long flags)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       struct ppc440spe_adma_desc_slot *sw_desc, *group_start;
+       int slot_cnt, slots_per_op;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+
+       if (unlikely(!len))
+               return NULL;
+
+       BUG_ON(unlikely(len > PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT));
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+
+       dev_dbg(ppc440spe_chan->device->common.dev,
+               "ppc440spe adma%d: %s cal: %u len: %u int_en %d\n",
+               ppc440spe_chan->device->id, __func__, value, len,
+               flags & DMA_PREP_INTERRUPT ? 1 : 0);
+
+       slot_cnt = slots_per_op = 1;
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt,
+               slots_per_op);
+       if (sw_desc) {
+               group_start = sw_desc->group_head;
+               ppc440spe_desc_init_memset(group_start, value, flags);
+               ppc440spe_adma_set_dest(group_start, dma_dest, 0);
+               ppc440spe_desc_set_byte_count(group_start, ppc440spe_chan, len);
+               sw_desc->unmap_len = len;
+               sw_desc->async_tx.flags = flags;
+       }
+       spin_unlock_bh(&ppc440spe_chan->lock);
+
+       return sw_desc ? &sw_desc->async_tx : NULL;
+}
+
+/**
+ * ppc440spe_adma_prep_dma_xor - prepare CDB for a XOR operation
+ */
+static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_xor(
+               struct dma_chan *chan, dma_addr_t dma_dest,
+               dma_addr_t *dma_src, u32 src_cnt, size_t len,
+               unsigned long flags)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       struct ppc440spe_adma_desc_slot *sw_desc, *group_start;
+       int slot_cnt, slots_per_op;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+
+       ADMA_LL_DBG(prep_dma_xor_dbg(ppc440spe_chan->device->id,
+                                    dma_dest, dma_src, src_cnt));
+       if (unlikely(!len))
+               return NULL;
+       BUG_ON(unlikely(len > PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT));
+
+       dev_dbg(ppc440spe_chan->device->common.dev,
+               "ppc440spe adma%d: %s src_cnt: %d len: %u int_en: %d\n",
+               ppc440spe_chan->device->id, __func__, src_cnt, len,
+               flags & DMA_PREP_INTERRUPT ? 1 : 0);
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+       slot_cnt = ppc440spe_chan_xor_slot_count(len, src_cnt, &slots_per_op);
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt,
+                       slots_per_op);
+       if (sw_desc) {
+               group_start = sw_desc->group_head;
+               ppc440spe_desc_init_xor(group_start, src_cnt, flags);
+               ppc440spe_adma_set_dest(group_start, dma_dest, 0);
+               while (src_cnt--)
+                       ppc440spe_adma_memcpy_xor_set_src(group_start,
+                               dma_src[src_cnt], src_cnt);
+               ppc440spe_desc_set_byte_count(group_start, ppc440spe_chan, len);
+               sw_desc->unmap_len = len;
+               sw_desc->async_tx.flags = flags;
+       }
+       spin_unlock_bh(&ppc440spe_chan->lock);
+
+       return sw_desc ? &sw_desc->async_tx : NULL;
+}
+
+static inline void
+ppc440spe_desc_set_xor_src_cnt(struct ppc440spe_adma_desc_slot *desc,
+                               int src_cnt);
+static void ppc440spe_init_rxor_cursor(struct ppc440spe_rxor *cursor);
+
+/**
+ * ppc440spe_adma_init_dma2rxor_slot -
+ */
+static void ppc440spe_adma_init_dma2rxor_slot(
+               struct ppc440spe_adma_desc_slot *desc,
+               dma_addr_t *src, int src_cnt)
+{
+       int i;
+
+       /* initialize CDB */
+       for (i = 0; i < src_cnt; i++) {
+               ppc440spe_adma_dma2rxor_prep_src(desc, &desc->rxor_cursor, i,
+                                                desc->src_cnt, (u32)src[i]);
+       }
+}
+
+/**
+ * ppc440spe_dma01_prep_mult -
+ * for Q operation where destination is also the source
+ */
+static struct ppc440spe_adma_desc_slot *ppc440spe_dma01_prep_mult(
+               struct ppc440spe_adma_chan *ppc440spe_chan,
+               dma_addr_t *dst, int dst_cnt, dma_addr_t *src, int src_cnt,
+               const unsigned char *scf, size_t len, unsigned long flags)
+{
+       struct ppc440spe_adma_desc_slot *sw_desc = NULL;
+       unsigned long op = 0;
+       int slot_cnt;
+
+       set_bit(PPC440SPE_DESC_WXOR, &op);
+       slot_cnt = 2;
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+
+       /* use WXOR, each descriptor occupies one slot */
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt, 1);
+       if (sw_desc) {
+               struct ppc440spe_adma_chan *chan;
+               struct ppc440spe_adma_desc_slot *iter;
+               struct dma_cdb *hw_desc;
+
+               chan = to_ppc440spe_adma_chan(sw_desc->async_tx.chan);
+               set_bits(op, &sw_desc->flags);
+               sw_desc->src_cnt = src_cnt;
+               sw_desc->dst_cnt = dst_cnt;
+               /* First descriptor, zero data in the destination and copy it
+                * to q page using MULTICAST transfer.
+                */
+               iter = list_first_entry(&sw_desc->group_list,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+               /* set 'next' pointer */
+               iter->hw_next = list_entry(iter->chain_node.next,
+                                          struct ppc440spe_adma_desc_slot,
+                                          chain_node);
+               clear_bit(PPC440SPE_DESC_INT, &iter->flags);
+               hw_desc = iter->hw_desc;
+               hw_desc->opc = DMA_CDB_OPC_MULTICAST;
+
+               ppc440spe_desc_set_dest_addr(iter, chan,
+                                            DMA_CUED_XOR_BASE, dst[0], 0);
+               ppc440spe_desc_set_dest_addr(iter, chan, 0, dst[1], 1);
+               ppc440spe_desc_set_src_addr(iter, chan, 0, DMA_CUED_XOR_HB,
+                                           src[0]);
+               ppc440spe_desc_set_byte_count(iter, ppc440spe_chan, len);
+               iter->unmap_len = len;
+
+               /*
+                * Second descriptor, multiply data from the q page
+                * and store the result in real destination.
+                */
+               iter = list_first_entry(&iter->chain_node,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+               iter->hw_next = NULL;
+               if (flags & DMA_PREP_INTERRUPT)
+                       set_bit(PPC440SPE_DESC_INT, &iter->flags);
+               else
+                       clear_bit(PPC440SPE_DESC_INT, &iter->flags);
+
+               hw_desc = iter->hw_desc;
+               hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+               ppc440spe_desc_set_src_addr(iter, chan, 0,
+                                           DMA_CUED_XOR_HB, dst[1]);
+               ppc440spe_desc_set_dest_addr(iter, chan,
+                                            DMA_CUED_XOR_BASE, dst[0], 0);
+
+               ppc440spe_desc_set_src_mult(iter, chan, DMA_CUED_MULT1_OFF,
+                                           DMA_CDB_SG_DST1, scf[0]);
+               ppc440spe_desc_set_byte_count(iter, ppc440spe_chan, len);
+               iter->unmap_len = len;
+               sw_desc->async_tx.flags = flags;
+       }
+
+       spin_unlock_bh(&ppc440spe_chan->lock);
+
+       return sw_desc;
+}
+
+/**
+ * ppc440spe_dma01_prep_sum_product -
+ * Dx = A*(P+Pxy) + B*(Q+Qxy) operation where destination is also
+ * the source.
+ */
+static struct ppc440spe_adma_desc_slot *ppc440spe_dma01_prep_sum_product(
+               struct ppc440spe_adma_chan *ppc440spe_chan,
+               dma_addr_t *dst, dma_addr_t *src, int src_cnt,
+               const unsigned char *scf, size_t len, unsigned long flags)
+{
+       struct ppc440spe_adma_desc_slot *sw_desc = NULL;
+       unsigned long op = 0;
+       int slot_cnt;
+
+       set_bit(PPC440SPE_DESC_WXOR, &op);
+       slot_cnt = 3;
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+
+       /* WXOR, each descriptor occupies one slot */
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt, 1);
+       if (sw_desc) {
+               struct ppc440spe_adma_chan *chan;
+               struct ppc440spe_adma_desc_slot *iter;
+               struct dma_cdb *hw_desc;
+
+               chan = to_ppc440spe_adma_chan(sw_desc->async_tx.chan);
+               set_bits(op, &sw_desc->flags);
+               sw_desc->src_cnt = src_cnt;
+               sw_desc->dst_cnt = 1;
+               /* 1st descriptor, src[1] data to q page and zero destination */
+               iter = list_first_entry(&sw_desc->group_list,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+               iter->hw_next = list_entry(iter->chain_node.next,
+                                          struct ppc440spe_adma_desc_slot,
+                                          chain_node);
+               clear_bit(PPC440SPE_DESC_INT, &iter->flags);
+               hw_desc = iter->hw_desc;
+               hw_desc->opc = DMA_CDB_OPC_MULTICAST;
+
+               ppc440spe_desc_set_dest_addr(iter, chan, DMA_CUED_XOR_BASE,
+                                            *dst, 0);
+               ppc440spe_desc_set_dest_addr(iter, chan, 0,
+                                            ppc440spe_chan->qdest, 1);
+               ppc440spe_desc_set_src_addr(iter, chan, 0, DMA_CUED_XOR_HB,
+                                           src[1]);
+               ppc440spe_desc_set_byte_count(iter, ppc440spe_chan, len);
+               iter->unmap_len = len;
+
+               /* 2nd descriptor, multiply src[1] data and store the
+                * result in destination */
+               iter = list_first_entry(&iter->chain_node,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+               /* set 'next' pointer */
+               iter->hw_next = list_entry(iter->chain_node.next,
+                                          struct ppc440spe_adma_desc_slot,
+                                          chain_node);
+               if (flags & DMA_PREP_INTERRUPT)
+                       set_bit(PPC440SPE_DESC_INT, &iter->flags);
+               else
+                       clear_bit(PPC440SPE_DESC_INT, &iter->flags);
+
+               hw_desc = iter->hw_desc;
+               hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+               ppc440spe_desc_set_src_addr(iter, chan, 0, DMA_CUED_XOR_HB,
+                                           ppc440spe_chan->qdest);
+               ppc440spe_desc_set_dest_addr(iter, chan, DMA_CUED_XOR_BASE,
+                                            *dst, 0);
+               ppc440spe_desc_set_src_mult(iter, chan, DMA_CUED_MULT1_OFF,
+                                           DMA_CDB_SG_DST1, scf[1]);
+               ppc440spe_desc_set_byte_count(iter, ppc440spe_chan, len);
+               iter->unmap_len = len;
+
+               /*
+                * 3rd descriptor, multiply src[0] data and xor it
+                * with destination
+                */
+               iter = list_first_entry(&iter->chain_node,
+                                       struct ppc440spe_adma_desc_slot,
+                                       chain_node);
+               memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+               iter->hw_next = NULL;
+               if (flags & DMA_PREP_INTERRUPT)
+                       set_bit(PPC440SPE_DESC_INT, &iter->flags);
+               else
+                       clear_bit(PPC440SPE_DESC_INT, &iter->flags);
+
+               hw_desc = iter->hw_desc;
+               hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+               ppc440spe_desc_set_src_addr(iter, chan, 0, DMA_CUED_XOR_HB,
+                                           src[0]);
+               ppc440spe_desc_set_dest_addr(iter, chan, DMA_CUED_XOR_BASE,
+                                            *dst, 0);
+               ppc440spe_desc_set_src_mult(iter, chan, DMA_CUED_MULT1_OFF,
+                                           DMA_CDB_SG_DST1, scf[0]);
+               ppc440spe_desc_set_byte_count(iter, ppc440spe_chan, len);
+               iter->unmap_len = len;
+               sw_desc->async_tx.flags = flags;
+       }
+
+       spin_unlock_bh(&ppc440spe_chan->lock);
+
+       return sw_desc;
+}
+
+static struct ppc440spe_adma_desc_slot *ppc440spe_dma01_prep_pq(
+               struct ppc440spe_adma_chan *ppc440spe_chan,
+               dma_addr_t *dst, int dst_cnt, dma_addr_t *src, int src_cnt,
+               const unsigned char *scf, size_t len, unsigned long flags)
+{
+       int slot_cnt;
+       struct ppc440spe_adma_desc_slot *sw_desc = NULL, *iter;
+       unsigned long op = 0;
+       unsigned char mult = 1;
+
+       pr_debug("%s: dst_cnt %d, src_cnt %d, len %d\n",
+                __func__, dst_cnt, src_cnt, len);
+       /*  select operations WXOR/RXOR depending on the
+        * source addresses of operators and the number
+        * of destinations (RXOR support only Q-parity calculations)
+        */
+       set_bit(PPC440SPE_DESC_WXOR, &op);
+       if (!test_and_set_bit(PPC440SPE_RXOR_RUN, &ppc440spe_rxor_state)) {
+               /* no active RXOR;
+                * do RXOR if:
+                * - there are more than 1 source,
+                * - len is aligned on 512-byte boundary,
+                * - source addresses fit to one of 4 possible regions.
+                */
+               if (src_cnt > 1 &&
+                   !(len & MQ0_CF2H_RXOR_BS_MASK) &&
+                   (src[0] + len) == src[1]) {
+                       /* may do RXOR R1 R2 */
+                       set_bit(PPC440SPE_DESC_RXOR, &op);
+                       if (src_cnt != 2) {
+                               /* may try to enhance region of RXOR */
+                               if ((src[1] + len) == src[2]) {
+                                       /* do RXOR R1 R2 R3 */
+                                       set_bit(PPC440SPE_DESC_RXOR123,
+                                               &op);
+                               } else if ((src[1] + len * 2) == src[2]) {
+                                       /* do RXOR R1 R2 R4 */
+                                       set_bit(PPC440SPE_DESC_RXOR124, &op);
+                               } else if ((src[1] + len * 3) == src[2]) {
+                                       /* do RXOR R1 R2 R5 */
+                                       set_bit(PPC440SPE_DESC_RXOR125,
+                                               &op);
+                               } else {
+                                       /* do RXOR R1 R2 */
+                                       set_bit(PPC440SPE_DESC_RXOR12,
+                                               &op);
+                               }
+                       } else {
+                               /* do RXOR R1 R2 */
+                               set_bit(PPC440SPE_DESC_RXOR12, &op);
+                       }
+               }
+
+               if (!test_bit(PPC440SPE_DESC_RXOR, &op)) {
+                       /* can not do this operation with RXOR */
+                       clear_bit(PPC440SPE_RXOR_RUN,
+                               &ppc440spe_rxor_state);
+               } else {
+                       /* can do; set block size right now */
+                       ppc440spe_desc_set_rxor_block_size(len);
+               }
+       }
+
+       /* Number of necessary slots depends on operation type selected */
+       if (!test_bit(PPC440SPE_DESC_RXOR, &op)) {
+               /*  This is a WXOR only chain. Need descriptors for each
+                * source to GF-XOR them with WXOR, and need descriptors
+                * for each destination to zero them with WXOR
+                */
+               slot_cnt = src_cnt;
+
+               if (flags & DMA_PREP_ZERO_P) {
+                       slot_cnt++;
+                       set_bit(PPC440SPE_ZERO_P, &op);
+               }
+               if (flags & DMA_PREP_ZERO_Q) {
+                       slot_cnt++;
+                       set_bit(PPC440SPE_ZERO_Q, &op);
+               }
+       } else {
+               /*  Need 1/2 descriptor for RXOR operation, and
+                * need (src_cnt - (2 or 3)) for WXOR of sources
+                * remained (if any)
+                */
+               slot_cnt = dst_cnt;
+
+               if (flags & DMA_PREP_ZERO_P)
+                       set_bit(PPC440SPE_ZERO_P, &op);
+               if (flags & DMA_PREP_ZERO_Q)
+                       set_bit(PPC440SPE_ZERO_Q, &op);
+
+               if (test_bit(PPC440SPE_DESC_RXOR12, &op))
+                       slot_cnt += src_cnt - 2;
+               else
+                       slot_cnt += src_cnt - 3;
+
+               /*  Thus we have either RXOR only chain or
+                * mixed RXOR/WXOR
+                */
+               if (slot_cnt == dst_cnt)
+                       /* RXOR only chain */
+                       clear_bit(PPC440SPE_DESC_WXOR, &op);
+       }
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+       /* for both RXOR/WXOR each descriptor occupies one slot */
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt, 1);
+       if (sw_desc) {
+               ppc440spe_desc_init_dma01pq(sw_desc, dst_cnt, src_cnt,
+                               flags, op);
+
+               /* setup dst/src/mult */
+               pr_debug("%s: set dst descriptor 0, 1: 0x%016llx, 0x%016llx\n",
+                        __func__, dst[0], dst[1]);
+               ppc440spe_adma_pq_set_dest(sw_desc, dst, flags);
+               while (src_cnt--) {
+                       ppc440spe_adma_pq_set_src(sw_desc, src[src_cnt],
+                                                 src_cnt);
+
+                       /* NOTE: "Multi = 0 is equivalent to = 1" as it
+                        * stated in 440SPSPe_RAID6_Addendum_UM_1_17.pdf
+                        * doesn't work for RXOR with DMA0/1! Instead, multi=0
+                        * leads to zeroing source data after RXOR.
+                        * So, for P case set-up mult=1 explicitly.
+                        */
+                       if (!(flags & DMA_PREP_PQ_DISABLE_Q))
+                               mult = scf[src_cnt];
+                       ppc440spe_adma_pq_set_src_mult(sw_desc,
+                               mult, src_cnt,  dst_cnt - 1);
+               }
+
+               /* Setup byte count foreach slot just allocated */
+               sw_desc->async_tx.flags = flags;
+               list_for_each_entry(iter, &sw_desc->group_list,
+                               chain_node) {
+                       ppc440spe_desc_set_byte_count(iter,
+                               ppc440spe_chan, len);
+                       iter->unmap_len = len;
+               }
+       }
+       spin_unlock_bh(&ppc440spe_chan->lock);
+
+       return sw_desc;
+}
+
+static struct ppc440spe_adma_desc_slot *ppc440spe_dma2_prep_pq(
+               struct ppc440spe_adma_chan *ppc440spe_chan,
+               dma_addr_t *dst, int dst_cnt, dma_addr_t *src, int src_cnt,
+               const unsigned char *scf, size_t len, unsigned long flags)
+{
+       int slot_cnt, descs_per_op;
+       struct ppc440spe_adma_desc_slot *sw_desc = NULL, *iter;
+       unsigned long op = 0;
+       unsigned char mult = 1;
+
+       BUG_ON(!dst_cnt);
+       /*pr_debug("%s: dst_cnt %d, src_cnt %d, len %d\n",
+                __func__, dst_cnt, src_cnt, len);*/
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+       descs_per_op = ppc440spe_dma2_pq_slot_count(src, src_cnt, len);
+       if (descs_per_op < 0) {
+               spin_unlock_bh(&ppc440spe_chan->lock);
+               return NULL;
+       }
+
+       /* depending on number of sources we have 1 or 2 RXOR chains */
+       slot_cnt = descs_per_op * dst_cnt;
+
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt, 1);
+       if (sw_desc) {
+               op = slot_cnt;
+               sw_desc->async_tx.flags = flags;
+               list_for_each_entry(iter, &sw_desc->group_list, chain_node) {
+                       ppc440spe_desc_init_dma2pq(iter, dst_cnt, src_cnt,
+                               --op ? 0 : flags);
+                       ppc440spe_desc_set_byte_count(iter, ppc440spe_chan,
+                               len);
+                       iter->unmap_len = len;
+
+                       ppc440spe_init_rxor_cursor(&(iter->rxor_cursor));
+                       iter->rxor_cursor.len = len;
+                       iter->descs_per_op = descs_per_op;
+               }
+               op = 0;
+               list_for_each_entry(iter, &sw_desc->group_list, chain_node) {
+                       op++;
+                       if (op % descs_per_op == 0)
+                               ppc440spe_adma_init_dma2rxor_slot(iter, src,
+                                                                 src_cnt);
+                       if (likely(!list_is_last(&iter->chain_node,
+                                                &sw_desc->group_list))) {
+                               /* set 'next' pointer */
+                               iter->hw_next =
+                                       list_entry(iter->chain_node.next,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+                               ppc440spe_xor_set_link(iter, iter->hw_next);
+                       } else {
+                               /* this is the last descriptor. */
+                               iter->hw_next = NULL;
+                       }
+               }
+
+               /* fixup head descriptor */
+               sw_desc->dst_cnt = dst_cnt;
+               if (flags & DMA_PREP_ZERO_P)
+                       set_bit(PPC440SPE_ZERO_P, &sw_desc->flags);
+               if (flags & DMA_PREP_ZERO_Q)
+                       set_bit(PPC440SPE_ZERO_Q, &sw_desc->flags);
+
+               /* setup dst/src/mult */
+               ppc440spe_adma_pq_set_dest(sw_desc, dst, flags);
+
+               while (src_cnt--) {
+                       /* handle descriptors (if dst_cnt == 2) inside
+                        * the ppc440spe_adma_pq_set_srcxxx() functions
+                        */
+                       ppc440spe_adma_pq_set_src(sw_desc, src[src_cnt],
+                                                 src_cnt);
+                       if (!(flags & DMA_PREP_PQ_DISABLE_Q))
+                               mult = scf[src_cnt];
+                       ppc440spe_adma_pq_set_src_mult(sw_desc,
+                                       mult, src_cnt, dst_cnt - 1);
+               }
+       }
+       spin_unlock_bh(&ppc440spe_chan->lock);
+       ppc440spe_desc_set_rxor_block_size(len);
+       return sw_desc;
+}
+
+/**
+ * ppc440spe_adma_prep_dma_pq - prepare CDB (group) for a GF-XOR operation
+ */
+static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_pq(
+               struct dma_chan *chan, dma_addr_t *dst, dma_addr_t *src,
+               unsigned int src_cnt, const unsigned char *scf,
+               size_t len, unsigned long flags)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       struct ppc440spe_adma_desc_slot *sw_desc = NULL;
+       int dst_cnt = 0;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+
+       ADMA_LL_DBG(prep_dma_pq_dbg(ppc440spe_chan->device->id,
+                                   dst, src, src_cnt));
+       BUG_ON(!len);
+       BUG_ON(unlikely(len > PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT));
+       BUG_ON(!src_cnt);
+
+       if (src_cnt == 1 && dst[1] == src[0]) {
+               dma_addr_t dest[2];
+
+               /* dst[1] is real destination (Q) */
+               dest[0] = dst[1];
+               /* this is the page to multicast source data to */
+               dest[1] = ppc440spe_chan->qdest;
+               sw_desc = ppc440spe_dma01_prep_mult(ppc440spe_chan,
+                               dest, 2, src, src_cnt, scf, len, flags);
+               return sw_desc ? &sw_desc->async_tx : NULL;
+       }
+
+       if (src_cnt == 2 && dst[1] == src[1]) {
+               sw_desc = ppc440spe_dma01_prep_sum_product(ppc440spe_chan,
+                                       &dst[1], src, 2, scf, len, flags);
+               return sw_desc ? &sw_desc->async_tx : NULL;
+       }
+
+       if (!(flags & DMA_PREP_PQ_DISABLE_P)) {
+               BUG_ON(!dst[0]);
+               dst_cnt++;
+               flags |= DMA_PREP_ZERO_P;
+       }
+
+       if (!(flags & DMA_PREP_PQ_DISABLE_Q)) {
+               BUG_ON(!dst[1]);
+               dst_cnt++;
+               flags |= DMA_PREP_ZERO_Q;
+       }
+
+       BUG_ON(!dst_cnt);
+
+       dev_dbg(ppc440spe_chan->device->common.dev,
+               "ppc440spe adma%d: %s src_cnt: %d len: %u int_en: %d\n",
+               ppc440spe_chan->device->id, __func__, src_cnt, len,
+               flags & DMA_PREP_INTERRUPT ? 1 : 0);
+
+       switch (ppc440spe_chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               sw_desc = ppc440spe_dma01_prep_pq(ppc440spe_chan,
+                               dst, dst_cnt, src, src_cnt, scf,
+                               len, flags);
+               break;
+
+       case PPC440SPE_XOR_ID:
+               sw_desc = ppc440spe_dma2_prep_pq(ppc440spe_chan,
+                               dst, dst_cnt, src, src_cnt, scf,
+                               len, flags);
+               break;
+       }
+
+       return sw_desc ? &sw_desc->async_tx : NULL;
+}
+
+/**
+ * ppc440spe_adma_prep_dma_pqzero_sum - prepare CDB group for
+ * a PQ_ZERO_SUM operation
+ */
+static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_pqzero_sum(
+               struct dma_chan *chan, dma_addr_t *pq, dma_addr_t *src,
+               unsigned int src_cnt, const unsigned char *scf, size_t len,
+               enum sum_check_flags *pqres, unsigned long flags)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       struct ppc440spe_adma_desc_slot *sw_desc, *iter;
+       dma_addr_t pdest, qdest;
+       int slot_cnt, slots_per_op, idst, dst_cnt;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+
+       if (flags & DMA_PREP_PQ_DISABLE_P)
+               pdest = 0;
+       else
+               pdest = pq[0];
+
+       if (flags & DMA_PREP_PQ_DISABLE_Q)
+               qdest = 0;
+       else
+               qdest = pq[1];
+
+       ADMA_LL_DBG(prep_dma_pqzero_sum_dbg(ppc440spe_chan->device->id,
+                                           src, src_cnt, scf));
+
+       /* Always use WXOR for P/Q calculations (two destinations).
+        * Need 1 or 2 extra slots to verify results are zero.
+        */
+       idst = dst_cnt = (pdest && qdest) ? 2 : 1;
+
+       /* One additional slot per destination to clone P/Q
+        * before calculation (we have to preserve destinations).
+        */
+       slot_cnt = src_cnt + dst_cnt * 2;
+       slots_per_op = 1;
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+       sw_desc = ppc440spe_adma_alloc_slots(ppc440spe_chan, slot_cnt,
+                                            slots_per_op);
+       if (sw_desc) {
+               ppc440spe_desc_init_dma01pqzero_sum(sw_desc, dst_cnt, src_cnt);
+
+               /* Setup byte count for each slot just allocated */
+               sw_desc->async_tx.flags = flags;
+               list_for_each_entry(iter, &sw_desc->group_list, chain_node) {
+                       ppc440spe_desc_set_byte_count(iter, ppc440spe_chan,
+                                                     len);
+                       iter->unmap_len = len;
+               }
+
+               if (pdest) {
+                       struct dma_cdb *hw_desc;
+                       struct ppc440spe_adma_chan *chan;
+
+                       iter = sw_desc->group_head;
+                       chan = to_ppc440spe_adma_chan(iter->async_tx.chan);
+                       memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+                       iter->hw_next = list_entry(iter->chain_node.next,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+                       hw_desc = iter->hw_desc;
+                       hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+                       iter->src_cnt = 0;
+                       iter->dst_cnt = 0;
+                       ppc440spe_desc_set_dest_addr(iter, chan, 0,
+                                                    ppc440spe_chan->pdest, 0);
+                       ppc440spe_desc_set_src_addr(iter, chan, 0, 0, pdest);
+                       ppc440spe_desc_set_byte_count(iter, ppc440spe_chan,
+                                                     len);
+                       iter->unmap_len = 0;
+                       /* override pdest to preserve original P */
+                       pdest = ppc440spe_chan->pdest;
+               }
+               if (qdest) {
+                       struct dma_cdb *hw_desc;
+                       struct ppc440spe_adma_chan *chan;
+
+                       iter = list_first_entry(&sw_desc->group_list,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+                       chan = to_ppc440spe_adma_chan(iter->async_tx.chan);
+
+                       if (pdest) {
+                               iter = list_entry(iter->chain_node.next,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+                       }
+
+                       memset(iter->hw_desc, 0, sizeof(struct dma_cdb));
+                       iter->hw_next = list_entry(iter->chain_node.next,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+                       hw_desc = iter->hw_desc;
+                       hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2;
+                       iter->src_cnt = 0;
+                       iter->dst_cnt = 0;
+                       ppc440spe_desc_set_dest_addr(iter, chan, 0,
+                                                    ppc440spe_chan->qdest, 0);
+                       ppc440spe_desc_set_src_addr(iter, chan, 0, 0, qdest);
+                       ppc440spe_desc_set_byte_count(iter, ppc440spe_chan,
+                                                     len);
+                       iter->unmap_len = 0;
+                       /* override qdest to preserve original Q */
+                       qdest = ppc440spe_chan->qdest;
+               }
+
+               /* Setup destinations for P/Q ops */
+               ppc440spe_adma_pqzero_sum_set_dest(sw_desc, pdest, qdest);
+
+               /* Setup zero QWORDs into DCHECK CDBs */
+               idst = dst_cnt;
+               list_for_each_entry_reverse(iter, &sw_desc->group_list,
+                                           chain_node) {
+                       /*
+                        * The last CDB corresponds to Q-parity check,
+                        * the one before last CDB corresponds
+                        * P-parity check
+                        */
+                       if (idst == DMA_DEST_MAX_NUM) {
+                               if (idst == dst_cnt) {
+                                       set_bit(PPC440SPE_DESC_QCHECK,
+                                               &iter->flags);
+                               } else {
+                                       set_bit(PPC440SPE_DESC_PCHECK,
+                                               &iter->flags);
+                               }
+                       } else {
+                               if (qdest) {
+                                       set_bit(PPC440SPE_DESC_QCHECK,
+                                               &iter->flags);
+                               } else {
+                                       set_bit(PPC440SPE_DESC_PCHECK,
+                                               &iter->flags);
+                               }
+                       }
+                       iter->xor_check_result = pqres;
+
+                       /*
+                        * set it to zero, if check fail then result will
+                        * be updated
+                        */
+                       *iter->xor_check_result = 0;
+                       ppc440spe_desc_set_dcheck(iter, ppc440spe_chan,
+                               ppc440spe_qword);
+
+                       if (!(--dst_cnt))
+                               break;
+               }
+
+               /* Setup sources and mults for P/Q ops */
+               list_for_each_entry_continue_reverse(iter, &sw_desc->group_list,
+                                                    chain_node) {
+                       struct ppc440spe_adma_chan *chan;
+                       u32 mult_dst;
+
+                       chan = to_ppc440spe_adma_chan(iter->async_tx.chan);
+                       ppc440spe_desc_set_src_addr(iter, chan, 0,
+                                                   DMA_CUED_XOR_HB,
+                                                   src[src_cnt - 1]);
+                       if (qdest) {
+                               mult_dst = (dst_cnt - 1) ? DMA_CDB_SG_DST2 :
+                                                          DMA_CDB_SG_DST1;
+                               ppc440spe_desc_set_src_mult(iter, chan,
+                                                           DMA_CUED_MULT1_OFF,
+                                                           mult_dst,
+                                                           scf[src_cnt - 1]);
+                       }
+                       if (!(--src_cnt))
+                               break;
+               }
+       }
+       spin_unlock_bh(&ppc440spe_chan->lock);
+       return sw_desc ? &sw_desc->async_tx : NULL;
+}
+
+/**
+ * ppc440spe_adma_prep_dma_xor_zero_sum - prepare CDB group for
+ * XOR ZERO_SUM operation
+ */
+static struct dma_async_tx_descriptor *ppc440spe_adma_prep_dma_xor_zero_sum(
+               struct dma_chan *chan, dma_addr_t *src, unsigned int src_cnt,
+               size_t len, enum sum_check_flags *result, unsigned long flags)
+{
+       struct dma_async_tx_descriptor *tx;
+       dma_addr_t pq[2];
+
+       /* validate P, disable Q */
+       pq[0] = src[0];
+       pq[1] = 0;
+       flags |= DMA_PREP_PQ_DISABLE_Q;
+
+       tx = ppc440spe_adma_prep_dma_pqzero_sum(chan, pq, &src[1],
+                                               src_cnt - 1, 0, len,
+                                               result, flags);
+       return tx;
+}
+
+/**
+ * ppc440spe_adma_set_dest - set destination address into descriptor
+ */
+static void ppc440spe_adma_set_dest(struct ppc440spe_adma_desc_slot *sw_desc,
+               dma_addr_t addr, int index)
+{
+       struct ppc440spe_adma_chan *chan;
+
+       BUG_ON(index >= sw_desc->dst_cnt);
+
+       chan = to_ppc440spe_adma_chan(sw_desc->async_tx.chan);
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               /* to do: support transfers lengths >
+                * PPC440SPE_ADMA_DMA/XOR_MAX_BYTE_COUNT
+                */
+               ppc440spe_desc_set_dest_addr(sw_desc->group_head,
+                       chan, 0, addr, index);
+               break;
+       case PPC440SPE_XOR_ID:
+               sw_desc = ppc440spe_get_group_entry(sw_desc, index);
+               ppc440spe_desc_set_dest_addr(sw_desc,
+                       chan, 0, addr, index);
+               break;
+       }
+}
+
+static void ppc440spe_adma_pq_zero_op(struct ppc440spe_adma_desc_slot *iter,
+               struct ppc440spe_adma_chan *chan, dma_addr_t addr)
+{
+       /*  To clear destinations update the descriptor
+        * (P or Q depending on index) as follows:
+        * addr is destination (0 corresponds to SG2):
+        */
+       ppc440spe_desc_set_dest_addr(iter, chan, DMA_CUED_XOR_BASE, addr, 0);
+
+       /* ... and the addr is source: */
+       ppc440spe_desc_set_src_addr(iter, chan, 0, DMA_CUED_XOR_HB, addr);
+
+       /* addr is always SG2 then the mult is always DST1 */
+       ppc440spe_desc_set_src_mult(iter, chan, DMA_CUED_MULT1_OFF,
+                                   DMA_CDB_SG_DST1, 1);
+}
+
+/**
+ * ppc440spe_adma_pq_set_dest - set destination address into descriptor
+ * for the PQXOR operation
+ */
+static void ppc440spe_adma_pq_set_dest(struct ppc440spe_adma_desc_slot *sw_desc,
+               dma_addr_t *addrs, unsigned long flags)
+{
+       struct ppc440spe_adma_desc_slot *iter;
+       struct ppc440spe_adma_chan *chan;
+       dma_addr_t paddr, qaddr;
+       dma_addr_t addr = 0, ppath, qpath;
+       int index = 0, i;
+
+       chan = to_ppc440spe_adma_chan(sw_desc->async_tx.chan);
+
+       if (flags & DMA_PREP_PQ_DISABLE_P)
+               paddr = 0;
+       else
+               paddr = addrs[0];
+
+       if (flags & DMA_PREP_PQ_DISABLE_Q)
+               qaddr = 0;
+       else
+               qaddr = addrs[1];
+
+       if (!paddr || !qaddr)
+               addr = paddr ? paddr : qaddr;
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               /* walk through the WXOR source list and set P/Q-destinations
+                * for each slot:
+                */
+               if (!test_bit(PPC440SPE_DESC_RXOR, &sw_desc->flags)) {
+                       /* This is WXOR-only chain; may have 1/2 zero descs */
+                       if (test_bit(PPC440SPE_ZERO_P, &sw_desc->flags))
+                               index++;
+                       if (test_bit(PPC440SPE_ZERO_Q, &sw_desc->flags))
+                               index++;
+
+                       iter = ppc440spe_get_group_entry(sw_desc, index);
+                       if (addr) {
+                               /* one destination */
+                               list_for_each_entry_from(iter,
+                                       &sw_desc->group_list, chain_node)
+                                       ppc440spe_desc_set_dest_addr(iter, chan,
+                                               DMA_CUED_XOR_BASE, addr, 0);
+                       } else {
+                               /* two destinations */
+                               list_for_each_entry_from(iter,
+                                       &sw_desc->group_list, chain_node) {
+                                       ppc440spe_desc_set_dest_addr(iter, chan,
+                                               DMA_CUED_XOR_BASE, paddr, 0);
+                                       ppc440spe_desc_set_dest_addr(iter, chan,
+                                               DMA_CUED_XOR_BASE, qaddr, 1);
+                               }
+                       }
+
+                       if (index) {
+                               /*  To clear destinations update the descriptor
+                                * (1st,2nd, or both depending on flags)
+                                */
+                               index = 0;
+                               if (test_bit(PPC440SPE_ZERO_P,
+                                               &sw_desc->flags)) {
+                                       iter = ppc440spe_get_group_entry(
+                                                       sw_desc, index++);
+                                       ppc440spe_adma_pq_zero_op(iter, chan,
+                                                       paddr);
+                               }
+
+                               if (test_bit(PPC440SPE_ZERO_Q,
+                                               &sw_desc->flags)) {
+                                       iter = ppc440spe_get_group_entry(
+                                                       sw_desc, index++);
+                                       ppc440spe_adma_pq_zero_op(iter, chan,
+                                                       qaddr);
+                               }
+
+                               return;
+                       }
+               } else {
+                       /* This is RXOR-only or RXOR/WXOR mixed chain */
+
+                       /* If we want to include destination into calculations,
+                        * then make dest addresses cued with mult=1 (XOR).
+                        */
+                       ppath = test_bit(PPC440SPE_ZERO_P, &sw_desc->flags) ?
+                                       DMA_CUED_XOR_HB :
+                                       DMA_CUED_XOR_BASE |
+                                               (1 << DMA_CUED_MULT1_OFF);
+                       qpath = test_bit(PPC440SPE_ZERO_Q, &sw_desc->flags) ?
+                                       DMA_CUED_XOR_HB :
+                                       DMA_CUED_XOR_BASE |
+                                               (1 << DMA_CUED_MULT1_OFF);
+
+                       /* Setup destination(s) in RXOR slot(s) */
+                       iter = ppc440spe_get_group_entry(sw_desc, index++);
+                       ppc440spe_desc_set_dest_addr(iter, chan,
+                                               paddr ? ppath : qpath,
+                                               paddr ? paddr : qaddr, 0);
+                       if (!addr) {
+                               /* two destinations */
+                               iter = ppc440spe_get_group_entry(sw_desc,
+                                                                index++);
+                               ppc440spe_desc_set_dest_addr(iter, chan,
+                                               qpath, qaddr, 0);
+                       }
+
+                       if (test_bit(PPC440SPE_DESC_WXOR, &sw_desc->flags)) {
+                               /* Setup destination(s) in remaining WXOR
+                                * slots
+                                */
+                               iter = ppc440spe_get_group_entry(sw_desc,
+                                                                index);
+                               if (addr) {
+                                       /* one destination */
+                                       list_for_each_entry_from(iter,
+                                           &sw_desc->group_list,
+                                           chain_node)
+                                               ppc440spe_desc_set_dest_addr(
+                                                       iter, chan,
+                                                       DMA_CUED_XOR_BASE,
+                                                       addr, 0);
+
+                               } else {
+                                       /* two destinations */
+                                       list_for_each_entry_from(iter,
+                                           &sw_desc->group_list,
+                                           chain_node) {
+                                               ppc440spe_desc_set_dest_addr(
+                                                       iter, chan,
+                                                       DMA_CUED_XOR_BASE,
+                                                       paddr, 0);
+                                               ppc440spe_desc_set_dest_addr(
+                                                       iter, chan,
+                                                       DMA_CUED_XOR_BASE,
+                                                       qaddr, 1);
+                                       }
+                               }
+                       }
+
+               }
+               break;
+
+       case PPC440SPE_XOR_ID:
+               /* DMA2 descriptors have only 1 destination, so there are
+                * two chains - one for each dest.
+                * If we want to include destination into calculations,
+                * then make dest addresses cued with mult=1 (XOR).
+                */
+               ppath = test_bit(PPC440SPE_ZERO_P, &sw_desc->flags) ?
+                               DMA_CUED_XOR_HB :
+                               DMA_CUED_XOR_BASE |
+                                       (1 << DMA_CUED_MULT1_OFF);
+
+               qpath = test_bit(PPC440SPE_ZERO_Q, &sw_desc->flags) ?
+                               DMA_CUED_XOR_HB :
+                               DMA_CUED_XOR_BASE |
+                                       (1 << DMA_CUED_MULT1_OFF);
+
+               iter = ppc440spe_get_group_entry(sw_desc, 0);
+               for (i = 0; i < sw_desc->descs_per_op; i++) {
+                       ppc440spe_desc_set_dest_addr(iter, chan,
+                               paddr ? ppath : qpath,
+                               paddr ? paddr : qaddr, 0);
+                       iter = list_entry(iter->chain_node.next,
+                                         struct ppc440spe_adma_desc_slot,
+                                         chain_node);
+               }
+
+               if (!addr) {
+                       /* Two destinations; setup Q here */
+                       iter = ppc440spe_get_group_entry(sw_desc,
+                               sw_desc->descs_per_op);
+                       for (i = 0; i < sw_desc->descs_per_op; i++) {
+                               ppc440spe_desc_set_dest_addr(iter,
+                                       chan, qpath, qaddr, 0);
+                               iter = list_entry(iter->chain_node.next,
+                                               struct ppc440spe_adma_desc_slot,
+                                               chain_node);
+                       }
+               }
+
+               break;
+       }
+}
+
+/**
+ * ppc440spe_adma_pq_zero_sum_set_dest - set destination address into descriptor
+ * for the PQ_ZERO_SUM operation
+ */
+static void ppc440spe_adma_pqzero_sum_set_dest(
+               struct ppc440spe_adma_desc_slot *sw_desc,
+               dma_addr_t paddr, dma_addr_t qaddr)
+{
+       struct ppc440spe_adma_desc_slot *iter, *end;
+       struct ppc440spe_adma_chan *chan;
+       dma_addr_t addr = 0;
+       int idx;
+
+       chan = to_ppc440spe_adma_chan(sw_desc->async_tx.chan);
+
+       /* walk through the WXOR source list and set P/Q-destinations
+        * for each slot
+        */
+       idx = (paddr && qaddr) ? 2 : 1;
+       /* set end */
+       list_for_each_entry_reverse(end, &sw_desc->group_list,
+                                   chain_node) {
+               if (!(--idx))
+                       break;
+       }
+       /* set start */
+       idx = (paddr && qaddr) ? 2 : 1;
+       iter = ppc440spe_get_group_entry(sw_desc, idx);
+
+       if (paddr && qaddr) {
+               /* two destinations */
+               list_for_each_entry_from(iter, &sw_desc->group_list,
+                                        chain_node) {
+                       if (unlikely(iter == end))
+                               break;
+                       ppc440spe_desc_set_dest_addr(iter, chan,
+                                               DMA_CUED_XOR_BASE, paddr, 0);
+                       ppc440spe_desc_set_dest_addr(iter, chan,
+                                               DMA_CUED_XOR_BASE, qaddr, 1);
+               }
+       } else {
+               /* one destination */
+               addr = paddr ? paddr : qaddr;
+               list_for_each_entry_from(iter, &sw_desc->group_list,
+                                        chain_node) {
+                       if (unlikely(iter == end))
+                               break;
+                       ppc440spe_desc_set_dest_addr(iter, chan,
+                                               DMA_CUED_XOR_BASE, addr, 0);
+               }
+       }
+
+       /*  The remaining descriptors are DATACHECK. These have no need in
+        * destination. Actually, these destinations are used there
+        * as sources for check operation. So, set addr as source.
+        */
+       ppc440spe_desc_set_src_addr(end, chan, 0, 0, addr ? addr : paddr);
+
+       if (!addr) {
+               end = list_entry(end->chain_node.next,
+                                struct ppc440spe_adma_desc_slot, chain_node);
+               ppc440spe_desc_set_src_addr(end, chan, 0, 0, qaddr);
+       }
+}
+
+/**
+ * ppc440spe_desc_set_xor_src_cnt - set source count into descriptor
+ */
+static inline void ppc440spe_desc_set_xor_src_cnt(
+                       struct ppc440spe_adma_desc_slot *desc,
+                       int src_cnt)
+{
+       struct xor_cb *hw_desc = desc->hw_desc;
+
+       hw_desc->cbc &= ~XOR_CDCR_OAC_MSK;
+       hw_desc->cbc |= src_cnt;
+}
+
+/**
+ * ppc440spe_adma_pq_set_src - set source address into descriptor
+ */
+static void ppc440spe_adma_pq_set_src(struct ppc440spe_adma_desc_slot *sw_desc,
+               dma_addr_t addr, int index)
+{
+       struct ppc440spe_adma_chan *chan;
+       dma_addr_t haddr = 0;
+       struct ppc440spe_adma_desc_slot *iter = NULL;
+
+       chan = to_ppc440spe_adma_chan(sw_desc->async_tx.chan);
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               /* DMA0,1 may do: WXOR, RXOR, RXOR+WXORs chain
+                */
+               if (test_bit(PPC440SPE_DESC_RXOR, &sw_desc->flags)) {
+                       /* RXOR-only or RXOR/WXOR operation */
+                       int iskip = test_bit(PPC440SPE_DESC_RXOR12,
+                               &sw_desc->flags) ?  2 : 3;
+
+                       if (index == 0) {
+                               /* 1st slot (RXOR) */
+                               /* setup sources region (R1-2-3, R1-2-4,
+                                * or R1-2-5)
+                                */
+                               if (test_bit(PPC440SPE_DESC_RXOR12,
+                                               &sw_desc->flags))
+                                       haddr = DMA_RXOR12 <<
+                                               DMA_CUED_REGION_OFF;
+                               else if (test_bit(PPC440SPE_DESC_RXOR123,
+                                   &sw_desc->flags))
+                                       haddr = DMA_RXOR123 <<
+                                               DMA_CUED_REGION_OFF;
+                               else if (test_bit(PPC440SPE_DESC_RXOR124,
+                                   &sw_desc->flags))
+                                       haddr = DMA_RXOR124 <<
+                                               DMA_CUED_REGION_OFF;
+                               else if (test_bit(PPC440SPE_DESC_RXOR125,
+                                   &sw_desc->flags))
+                                       haddr = DMA_RXOR125 <<
+                                               DMA_CUED_REGION_OFF;
+                               else
+                                       BUG();
+                               haddr |= DMA_CUED_XOR_BASE;
+                               iter = ppc440spe_get_group_entry(sw_desc, 0);
+                       } else if (index < iskip) {
+                               /* 1st slot (RXOR)
+                                * shall actually set source address only once
+                                * instead of first <iskip>
+                                */
+                               iter = NULL;
+                       } else {
+                               /* 2nd/3d and next slots (WXOR);
+                                * skip first slot with RXOR
+                                */
+                               haddr = DMA_CUED_XOR_HB;
+                               iter = ppc440spe_get_group_entry(sw_desc,
+                                   index - iskip + sw_desc->dst_cnt);
+                       }
+               } else {
+                       int znum = 0;
+
+                       /* WXOR-only operation; skip first slots with
+                        * zeroing destinations
+                        */
+                       if (test_bit(PPC440SPE_ZERO_P, &sw_desc->flags))
+                               znum++;
+                       if (test_bit(PPC440SPE_ZERO_Q, &sw_desc->flags))
+                               znum++;
+
+                       haddr = DMA_CUED_XOR_HB;
+                       iter = ppc440spe_get_group_entry(sw_desc,
+                                       index + znum);
+               }
+
+               if (likely(iter)) {
+                       ppc440spe_desc_set_src_addr(iter, chan, 0, haddr, addr);
+
+                       if (!index &&
+                           test_bit(PPC440SPE_DESC_RXOR, &sw_desc->flags) &&
+                           sw_desc->dst_cnt == 2) {
+                               /* if we have two destinations for RXOR, then
+                                * setup source in the second descr too
+                                */
+                               iter = ppc440spe_get_group_entry(sw_desc, 1);
+                               ppc440spe_desc_set_src_addr(iter, chan, 0,
+                                       haddr, addr);
+                       }
+               }
+               break;
+
+       case PPC440SPE_XOR_ID:
+               /* DMA2 may do Biskup */
+               iter = sw_desc->group_head;
+               if (iter->dst_cnt == 2) {
+                       /* both P & Q calculations required; set P src here */
+                       ppc440spe_adma_dma2rxor_set_src(iter, index, addr);
+
+                       /* this is for Q */
+                       iter = ppc440spe_get_group_entry(sw_desc,
+                               sw_desc->descs_per_op);
+               }
+               ppc440spe_adma_dma2rxor_set_src(iter, index, addr);
+               break;
+       }
+}
+
+/**
+ * ppc440spe_adma_memcpy_xor_set_src - set source address into descriptor
+ */
+static void ppc440spe_adma_memcpy_xor_set_src(
+               struct ppc440spe_adma_desc_slot *sw_desc,
+               dma_addr_t addr, int index)
+{
+       struct ppc440spe_adma_chan *chan;
+
+       chan = to_ppc440spe_adma_chan(sw_desc->async_tx.chan);
+       sw_desc = sw_desc->group_head;
+
+       if (likely(sw_desc))
+               ppc440spe_desc_set_src_addr(sw_desc, chan, index, 0, addr);
+}
+
+/**
+ * ppc440spe_adma_dma2rxor_inc_addr  -
+ */
+static void ppc440spe_adma_dma2rxor_inc_addr(
+               struct ppc440spe_adma_desc_slot *desc,
+               struct ppc440spe_rxor *cursor, int index, int src_cnt)
+{
+       cursor->addr_count++;
+       if (index == src_cnt - 1) {
+               ppc440spe_desc_set_xor_src_cnt(desc, cursor->addr_count);
+       } else if (cursor->addr_count == XOR_MAX_OPS) {
+               ppc440spe_desc_set_xor_src_cnt(desc, cursor->addr_count);
+               cursor->addr_count = 0;
+               cursor->desc_count++;
+       }
+}
+
+/**
+ * ppc440spe_adma_dma2rxor_prep_src - setup RXOR types in DMA2 CDB
+ */
+static int ppc440spe_adma_dma2rxor_prep_src(
+               struct ppc440spe_adma_desc_slot *hdesc,
+               struct ppc440spe_rxor *cursor, int index,
+               int src_cnt, u32 addr)
+{
+       int rval = 0;
+       u32 sign;
+       struct ppc440spe_adma_desc_slot *desc = hdesc;
+       int i;
+
+       for (i = 0; i < cursor->desc_count; i++) {
+               desc = list_entry(hdesc->chain_node.next,
+                                 struct ppc440spe_adma_desc_slot,
+                                 chain_node);
+       }
+
+       switch (cursor->state) {
+       case 0:
+               if (addr == cursor->addrl + cursor->len) {
+                       /* direct RXOR */
+                       cursor->state = 1;
+                       cursor->xor_count++;
+                       if (index == src_cnt-1) {
+                               ppc440spe_rxor_set_region(desc,
+                                       cursor->addr_count,
+                                       DMA_RXOR12 << DMA_CUED_REGION_OFF);
+                               ppc440spe_adma_dma2rxor_inc_addr(
+                                       desc, cursor, index, src_cnt);
+                       }
+               } else if (cursor->addrl == addr + cursor->len) {
+                       /* reverse RXOR */
+                       cursor->state = 1;
+                       cursor->xor_count++;
+                       set_bit(cursor->addr_count, &desc->reverse_flags[0]);
+                       if (index == src_cnt-1) {
+                               ppc440spe_rxor_set_region(desc,
+                                       cursor->addr_count,
+                                       DMA_RXOR12 << DMA_CUED_REGION_OFF);
+                               ppc440spe_adma_dma2rxor_inc_addr(
+                                       desc, cursor, index, src_cnt);
+                       }
+               } else {
+                       printk(KERN_ERR "Cannot build "
+                               "DMA2 RXOR command block.\n");
+                       BUG();
+               }
+               break;
+       case 1:
+               sign = test_bit(cursor->addr_count,
+                               desc->reverse_flags)
+                       ? -1 : 1;
+               if (index == src_cnt-2 || (sign == -1
+                       && addr != cursor->addrl - 2*cursor->len)) {
+                       cursor->state = 0;
+                       cursor->xor_count = 1;
+                       cursor->addrl = addr;
+                       ppc440spe_rxor_set_region(desc,
+                               cursor->addr_count,
+                               DMA_RXOR12 << DMA_CUED_REGION_OFF);
+                       ppc440spe_adma_dma2rxor_inc_addr(
+                               desc, cursor, index, src_cnt);
+               } else if (addr == cursor->addrl + 2*sign*cursor->len) {
+                       cursor->state = 2;
+                       cursor->xor_count = 0;
+                       ppc440spe_rxor_set_region(desc,
+                               cursor->addr_count,
+                               DMA_RXOR123 << DMA_CUED_REGION_OFF);
+                       if (index == src_cnt-1) {
+                               ppc440spe_adma_dma2rxor_inc_addr(
+                                       desc, cursor, index, src_cnt);
+                       }
+               } else if (addr == cursor->addrl + 3*cursor->len) {
+                       cursor->state = 2;
+                       cursor->xor_count = 0;
+                       ppc440spe_rxor_set_region(desc,
+                               cursor->addr_count,
+                               DMA_RXOR124 << DMA_CUED_REGION_OFF);
+                       if (index == src_cnt-1) {
+                               ppc440spe_adma_dma2rxor_inc_addr(
+                                       desc, cursor, index, src_cnt);
+                       }
+               } else if (addr == cursor->addrl + 4*cursor->len) {
+                       cursor->state = 2;
+                       cursor->xor_count = 0;
+                       ppc440spe_rxor_set_region(desc,
+                               cursor->addr_count,
+                               DMA_RXOR125 << DMA_CUED_REGION_OFF);
+                       if (index == src_cnt-1) {
+                               ppc440spe_adma_dma2rxor_inc_addr(
+                                       desc, cursor, index, src_cnt);
+                       }
+               } else {
+                       cursor->state = 0;
+                       cursor->xor_count = 1;
+                       cursor->addrl = addr;
+                       ppc440spe_rxor_set_region(desc,
+                               cursor->addr_count,
+                               DMA_RXOR12 << DMA_CUED_REGION_OFF);
+                       ppc440spe_adma_dma2rxor_inc_addr(
+                               desc, cursor, index, src_cnt);
+               }
+               break;
+       case 2:
+               cursor->state = 0;
+               cursor->addrl = addr;
+               cursor->xor_count++;
+               if (index) {
+                       ppc440spe_adma_dma2rxor_inc_addr(
+                               desc, cursor, index, src_cnt);
+               }
+               break;
+       }
+
+       return rval;
+}
+
+/**
+ * ppc440spe_adma_dma2rxor_set_src - set RXOR source address; it's assumed that
+ *     ppc440spe_adma_dma2rxor_prep_src() has already done prior this call
+ */
+static void ppc440spe_adma_dma2rxor_set_src(
+               struct ppc440spe_adma_desc_slot *desc,
+               int index, dma_addr_t addr)
+{
+       struct xor_cb *xcb = desc->hw_desc;
+       int k = 0, op = 0, lop = 0;
+
+       /* get the RXOR operand which corresponds to index addr */
+       while (op <= index) {
+               lop = op;
+               if (k == XOR_MAX_OPS) {
+                       k = 0;
+                       desc = list_entry(desc->chain_node.next,
+                               struct ppc440spe_adma_desc_slot, chain_node);
+                       xcb = desc->hw_desc;
+
+               }
+               if ((xcb->ops[k++].h & (DMA_RXOR12 << DMA_CUED_REGION_OFF)) ==
+                   (DMA_RXOR12 << DMA_CUED_REGION_OFF))
+                       op += 2;
+               else
+                       op += 3;
+       }
+
+       BUG_ON(k < 1);
+
+       if (test_bit(k-1, desc->reverse_flags)) {
+               /* reverse operand order; put last op in RXOR group */
+               if (index == op - 1)
+                       ppc440spe_rxor_set_src(desc, k - 1, addr);
+       } else {
+               /* direct operand order; put first op in RXOR group */
+               if (index == lop)
+                       ppc440spe_rxor_set_src(desc, k - 1, addr);
+       }
+}
+
+/**
+ * ppc440spe_adma_dma2rxor_set_mult - set RXOR multipliers; it's assumed that
+ *     ppc440spe_adma_dma2rxor_prep_src() has already done prior this call
+ */
+static void ppc440spe_adma_dma2rxor_set_mult(
+               struct ppc440spe_adma_desc_slot *desc,
+               int index, u8 mult)
+{
+       struct xor_cb *xcb = desc->hw_desc;
+       int k = 0, op = 0, lop = 0;
+
+       /* get the RXOR operand which corresponds to index mult */
+       while (op <= index) {
+               lop = op;
+               if (k == XOR_MAX_OPS) {
+                       k = 0;
+                       desc = list_entry(desc->chain_node.next,
+                                         struct ppc440spe_adma_desc_slot,
+                                         chain_node);
+                       xcb = desc->hw_desc;
+
+               }
+               if ((xcb->ops[k++].h & (DMA_RXOR12 << DMA_CUED_REGION_OFF)) ==
+                   (DMA_RXOR12 << DMA_CUED_REGION_OFF))
+                       op += 2;
+               else
+                       op += 3;
+       }
+
+       BUG_ON(k < 1);
+       if (test_bit(k-1, desc->reverse_flags)) {
+               /* reverse order */
+               ppc440spe_rxor_set_mult(desc, k - 1, op - index - 1, mult);
+       } else {
+               /* direct order */
+               ppc440spe_rxor_set_mult(desc, k - 1, index - lop, mult);
+       }
+}
+
+/**
+ * ppc440spe_init_rxor_cursor -
+ */
+static void ppc440spe_init_rxor_cursor(struct ppc440spe_rxor *cursor)
+{
+       memset(cursor, 0, sizeof(struct ppc440spe_rxor));
+       cursor->state = 2;
+}
+
+/**
+ * ppc440spe_adma_pq_set_src_mult - set multiplication coefficient into
+ * descriptor for the PQXOR operation
+ */
+static void ppc440spe_adma_pq_set_src_mult(
+               struct ppc440spe_adma_desc_slot *sw_desc,
+               unsigned char mult, int index, int dst_pos)
+{
+       struct ppc440spe_adma_chan *chan;
+       u32 mult_idx, mult_dst;
+       struct ppc440spe_adma_desc_slot *iter = NULL, *iter1 = NULL;
+
+       chan = to_ppc440spe_adma_chan(sw_desc->async_tx.chan);
+
+       switch (chan->device->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               if (test_bit(PPC440SPE_DESC_RXOR, &sw_desc->flags)) {
+                       int region = test_bit(PPC440SPE_DESC_RXOR12,
+                                       &sw_desc->flags) ? 2 : 3;
+
+                       if (index < region) {
+                               /* RXOR multipliers */
+                               iter = ppc440spe_get_group_entry(sw_desc,
+                                       sw_desc->dst_cnt - 1);
+                               if (sw_desc->dst_cnt == 2)
+                                       iter1 = ppc440spe_get_group_entry(
+                                                       sw_desc, 0);
+
+                               mult_idx = DMA_CUED_MULT1_OFF + (index << 3);
+                               mult_dst = DMA_CDB_SG_SRC;
+                       } else {
+                               /* WXOR multiplier */
+                               iter = ppc440spe_get_group_entry(sw_desc,
+                                                       index - region +
+                                                       sw_desc->dst_cnt);
+                               mult_idx = DMA_CUED_MULT1_OFF;
+                               mult_dst = dst_pos ? DMA_CDB_SG_DST2 :
+                                                    DMA_CDB_SG_DST1;
+                       }
+               } else {
+                       int znum = 0;
+
+                       /* WXOR-only;
+                        * skip first slots with destinations (if ZERO_DST has
+                        * place)
+                        */
+                       if (test_bit(PPC440SPE_ZERO_P, &sw_desc->flags))
+                               znum++;
+                       if (test_bit(PPC440SPE_ZERO_Q, &sw_desc->flags))
+                               znum++;
+
+                       iter = ppc440spe_get_group_entry(sw_desc, index + znum);
+                       mult_idx = DMA_CUED_MULT1_OFF;
+                       mult_dst = dst_pos ? DMA_CDB_SG_DST2 : DMA_CDB_SG_DST1;
+               }
+
+               if (likely(iter)) {
+                       ppc440spe_desc_set_src_mult(iter, chan,
+                               mult_idx, mult_dst, mult);
+
+                       if (unlikely(iter1)) {
+                               /* if we have two destinations for RXOR, then
+                                * we've just set Q mult. Set-up P now.
+                                */
+                               ppc440spe_desc_set_src_mult(iter1, chan,
+                                       mult_idx, mult_dst, 1);
+                       }
+
+               }
+               break;
+
+       case PPC440SPE_XOR_ID:
+               iter = sw_desc->group_head;
+               if (sw_desc->dst_cnt == 2) {
+                       /* both P & Q calculations required; set P mult here */
+                       ppc440spe_adma_dma2rxor_set_mult(iter, index, 1);
+
+                       /* and then set Q mult */
+                       iter = ppc440spe_get_group_entry(sw_desc,
+                              sw_desc->descs_per_op);
+               }
+               ppc440spe_adma_dma2rxor_set_mult(iter, index, mult);
+               break;
+       }
+}
+
+/**
+ * ppc440spe_adma_free_chan_resources - free the resources allocated
+ */
+static void ppc440spe_adma_free_chan_resources(struct dma_chan *chan)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       struct ppc440spe_adma_desc_slot *iter, *_iter;
+       int in_use_descs = 0;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+       ppc440spe_adma_slot_cleanup(ppc440spe_chan);
+
+       spin_lock_bh(&ppc440spe_chan->lock);
+       list_for_each_entry_safe(iter, _iter, &ppc440spe_chan->chain,
+                                       chain_node) {
+               in_use_descs++;
+               list_del(&iter->chain_node);
+       }
+       list_for_each_entry_safe_reverse(iter, _iter,
+                       &ppc440spe_chan->all_slots, slot_node) {
+               list_del(&iter->slot_node);
+               kfree(iter);
+               ppc440spe_chan->slots_allocated--;
+       }
+       ppc440spe_chan->last_used = NULL;
+
+       dev_dbg(ppc440spe_chan->device->common.dev,
+               "ppc440spe adma%d %s slots_allocated %d\n",
+               ppc440spe_chan->device->id,
+               __func__, ppc440spe_chan->slots_allocated);
+       spin_unlock_bh(&ppc440spe_chan->lock);
+
+       /* one is ok since we left it on there on purpose */
+       if (in_use_descs > 1)
+               printk(KERN_ERR "SPE: Freeing %d in use descriptors!\n",
+                       in_use_descs - 1);
+}
+
+/**
+ * ppc440spe_adma_is_complete - poll the status of an ADMA transaction
+ * @chan: ADMA channel handle
+ * @cookie: ADMA transaction identifier
+ */
+static enum dma_status ppc440spe_adma_is_complete(struct dma_chan *chan,
+       dma_cookie_t cookie, dma_cookie_t *done, dma_cookie_t *used)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+       dma_cookie_t last_used;
+       dma_cookie_t last_complete;
+       enum dma_status ret;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+       last_used = chan->cookie;
+       last_complete = ppc440spe_chan->completed_cookie;
+
+       if (done)
+               *done = last_complete;
+       if (used)
+               *used = last_used;
+
+       ret = dma_async_is_complete(cookie, last_complete, last_used);
+       if (ret == DMA_SUCCESS)
+               return ret;
+
+       ppc440spe_adma_slot_cleanup(ppc440spe_chan);
+
+       last_used = chan->cookie;
+       last_complete = ppc440spe_chan->completed_cookie;
+
+       if (done)
+               *done = last_complete;
+       if (used)
+               *used = last_used;
+
+       return dma_async_is_complete(cookie, last_complete, last_used);
+}
+
+/**
+ * ppc440spe_adma_eot_handler - end of transfer interrupt handler
+ */
+static irqreturn_t ppc440spe_adma_eot_handler(int irq, void *data)
+{
+       struct ppc440spe_adma_chan *chan = data;
+
+       dev_dbg(chan->device->common.dev,
+               "ppc440spe adma%d: %s\n", chan->device->id, __func__);
+
+       tasklet_schedule(&chan->irq_tasklet);
+       ppc440spe_adma_device_clear_eot_status(chan);
+
+       return IRQ_HANDLED;
+}
+
+/**
+ * ppc440spe_adma_err_handler - DMA error interrupt handler;
+ *     do the same things as a eot handler
+ */
+static irqreturn_t ppc440spe_adma_err_handler(int irq, void *data)
+{
+       struct ppc440spe_adma_chan *chan = data;
+
+       dev_dbg(chan->device->common.dev,
+               "ppc440spe adma%d: %s\n", chan->device->id, __func__);
+
+       tasklet_schedule(&chan->irq_tasklet);
+       ppc440spe_adma_device_clear_eot_status(chan);
+
+       return IRQ_HANDLED;
+}
+
+/**
+ * ppc440spe_test_callback - called when test operation has been done
+ */
+static void ppc440spe_test_callback(void *unused)
+{
+       complete(&ppc440spe_r6_test_comp);
+}
+
+/**
+ * ppc440spe_adma_issue_pending - flush all pending descriptors to h/w
+ */
+static void ppc440spe_adma_issue_pending(struct dma_chan *chan)
+{
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+
+       ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+       dev_dbg(ppc440spe_chan->device->common.dev,
+               "ppc440spe adma%d: %s %d \n", ppc440spe_chan->device->id,
+               __func__, ppc440spe_chan->pending);
+
+       if (ppc440spe_chan->pending) {
+               ppc440spe_chan->pending = 0;
+               ppc440spe_chan_append(ppc440spe_chan);
+       }
+}
+
+/**
+ * ppc440spe_chan_start_null_xor - initiate the first XOR operation (DMA engines
+ *     use FIFOs (as opposite to chains used in XOR) so this is a XOR
+ *     specific operation)
+ */
+static void ppc440spe_chan_start_null_xor(struct ppc440spe_adma_chan *chan)
+{
+       struct ppc440spe_adma_desc_slot *sw_desc, *group_start;
+       dma_cookie_t cookie;
+       int slot_cnt, slots_per_op;
+
+       dev_dbg(chan->device->common.dev,
+               "ppc440spe adma%d: %s\n", chan->device->id, __func__);
+
+       spin_lock_bh(&chan->lock);
+       slot_cnt = ppc440spe_chan_xor_slot_count(0, 2, &slots_per_op);
+       sw_desc = ppc440spe_adma_alloc_slots(chan, slot_cnt, slots_per_op);
+       if (sw_desc) {
+               group_start = sw_desc->group_head;
+               list_splice_init(&sw_desc->group_list, &chan->chain);
+               async_tx_ack(&sw_desc->async_tx);
+               ppc440spe_desc_init_null_xor(group_start);
+
+               cookie = chan->common.cookie;
+               cookie++;
+               if (cookie <= 1)
+                       cookie = 2;
+
+               /* initialize the completed cookie to be less than
+                * the most recently used cookie
+                */
+               chan->completed_cookie = cookie - 1;
+               chan->common.cookie = sw_desc->async_tx.cookie = cookie;
+
+               /* channel should not be busy */
+               BUG_ON(ppc440spe_chan_is_busy(chan));
+
+               /* set the descriptor address */
+               ppc440spe_chan_set_first_xor_descriptor(chan, sw_desc);
+
+               /* run the descriptor */
+               ppc440spe_chan_run(chan);
+       } else
+               printk(KERN_ERR "ppc440spe adma%d"
+                       " failed to allocate null descriptor\n",
+                       chan->device->id);
+       spin_unlock_bh(&chan->lock);
+}
+
+/**
+ * ppc440spe_test_raid6 - test are RAID-6 capabilities enabled successfully.
+ *     For this we just perform one WXOR operation with the same source
+ *     and destination addresses, the GF-multiplier is 1; so if RAID-6
+ *     capabilities are enabled then we'll get src/dst filled with zero.
+ */
+static int ppc440spe_test_raid6(struct ppc440spe_adma_chan *chan)
+{
+       struct ppc440spe_adma_desc_slot *sw_desc, *iter;
+       struct page *pg;
+       char *a;
+       dma_addr_t dma_addr, addrs[2];
+       unsigned long op = 0;
+       int rval = 0;
+
+       set_bit(PPC440SPE_DESC_WXOR, &op);
+
+       pg = alloc_page(GFP_KERNEL);
+       if (!pg)
+               return -ENOMEM;
+
+       spin_lock_bh(&chan->lock);
+       sw_desc = ppc440spe_adma_alloc_slots(chan, 1, 1);
+       if (sw_desc) {
+               /* 1 src, 1 dsr, int_ena, WXOR */
+               ppc440spe_desc_init_dma01pq(sw_desc, 1, 1, 1, op);
+               list_for_each_entry(iter, &sw_desc->group_list, chain_node) {
+                       ppc440spe_desc_set_byte_count(iter, chan, PAGE_SIZE);
+                       iter->unmap_len = PAGE_SIZE;
+               }
+       } else {
+               rval = -EFAULT;
+               spin_unlock_bh(&chan->lock);
+               goto exit;
+       }
+       spin_unlock_bh(&chan->lock);
+
+       /* Fill the test page with ones */
+       memset(page_address(pg), 0xFF, PAGE_SIZE);
+       dma_addr = dma_map_page(chan->device->dev, pg, 0,
+                               PAGE_SIZE, DMA_BIDIRECTIONAL);
+
+       /* Setup addresses */
+       ppc440spe_adma_pq_set_src(sw_desc, dma_addr, 0);
+       ppc440spe_adma_pq_set_src_mult(sw_desc, 1, 0, 0);
+       addrs[0] = dma_addr;
+       addrs[1] = 0;
+       ppc440spe_adma_pq_set_dest(sw_desc, addrs, DMA_PREP_PQ_DISABLE_Q);
+
+       async_tx_ack(&sw_desc->async_tx);
+       sw_desc->async_tx.callback = ppc440spe_test_callback;
+       sw_desc->async_tx.callback_param = NULL;
+
+       init_completion(&ppc440spe_r6_test_comp);
+
+       ppc440spe_adma_tx_submit(&sw_desc->async_tx);
+       ppc440spe_adma_issue_pending(&chan->common);
+
+       wait_for_completion(&ppc440spe_r6_test_comp);
+
+       /* Now check if the test page is zeroed */
+       a = page_address(pg);
+       if ((*(u32 *)a) == 0 && memcmp(a, a+4, PAGE_SIZE-4) == 0) {
+               /* page is zero - RAID-6 enabled */
+               rval = 0;
+       } else {
+               /* RAID-6 was not enabled */
+               rval = -EINVAL;
+       }
+exit:
+       __free_page(pg);
+       return rval;
+}
+
+static void ppc440spe_adma_init_capabilities(struct ppc440spe_adma_device *adev)
+{
+       switch (adev->id) {
+       case PPC440SPE_DMA0_ID:
+       case PPC440SPE_DMA1_ID:
+               dma_cap_set(DMA_MEMCPY, adev->common.cap_mask);
+               dma_cap_set(DMA_INTERRUPT, adev->common.cap_mask);
+               dma_cap_set(DMA_MEMSET, adev->common.cap_mask);
+               dma_cap_set(DMA_PQ, adev->common.cap_mask);
+               dma_cap_set(DMA_PQ_VAL, adev->common.cap_mask);
+               dma_cap_set(DMA_XOR_VAL, adev->common.cap_mask);
+               break;
+       case PPC440SPE_XOR_ID:
+               dma_cap_set(DMA_XOR, adev->common.cap_mask);
+               dma_cap_set(DMA_PQ, adev->common.cap_mask);
+               dma_cap_set(DMA_INTERRUPT, adev->common.cap_mask);
+               adev->common.cap_mask = adev->common.cap_mask;
+               break;
+       }
+
+       /* Set base routines */
+       adev->common.device_alloc_chan_resources =
+                               ppc440spe_adma_alloc_chan_resources;
+       adev->common.device_free_chan_resources =
+                               ppc440spe_adma_free_chan_resources;
+       adev->common.device_is_tx_complete = ppc440spe_adma_is_complete;
+       adev->common.device_issue_pending = ppc440spe_adma_issue_pending;
+
+       /* Set prep routines based on capability */
+       if (dma_has_cap(DMA_MEMCPY, adev->common.cap_mask)) {
+               adev->common.device_prep_dma_memcpy =
+                       ppc440spe_adma_prep_dma_memcpy;
+       }
+       if (dma_has_cap(DMA_MEMSET, adev->common.cap_mask)) {
+               adev->common.device_prep_dma_memset =
+                       ppc440spe_adma_prep_dma_memset;
+       }
+       if (dma_has_cap(DMA_XOR, adev->common.cap_mask)) {
+               adev->common.max_xor = XOR_MAX_OPS;
+               adev->common.device_prep_dma_xor =
+                       ppc440spe_adma_prep_dma_xor;
+       }
+       if (dma_has_cap(DMA_PQ, adev->common.cap_mask)) {
+               switch (adev->id) {
+               case PPC440SPE_DMA0_ID:
+                       dma_set_maxpq(&adev->common,
+                               DMA0_FIFO_SIZE / sizeof(struct dma_cdb), 0);
+                       break;
+               case PPC440SPE_DMA1_ID:
+                       dma_set_maxpq(&adev->common,
+                               DMA1_FIFO_SIZE / sizeof(struct dma_cdb), 0);
+                       break;
+               case PPC440SPE_XOR_ID:
+                       adev->common.max_pq = XOR_MAX_OPS * 3;
+                       break;
+               }
+               adev->common.device_prep_dma_pq =
+                       ppc440spe_adma_prep_dma_pq;
+       }
+       if (dma_has_cap(DMA_PQ_VAL, adev->common.cap_mask)) {
+               switch (adev->id) {
+               case PPC440SPE_DMA0_ID:
+                       adev->common.max_pq = DMA0_FIFO_SIZE /
+                                               sizeof(struct dma_cdb);
+                       break;
+               case PPC440SPE_DMA1_ID:
+                       adev->common.max_pq = DMA1_FIFO_SIZE /
+                                               sizeof(struct dma_cdb);
+                       break;
+               }
+               adev->common.device_prep_dma_pq_val =
+                       ppc440spe_adma_prep_dma_pqzero_sum;
+       }
+       if (dma_has_cap(DMA_XOR_VAL, adev->common.cap_mask)) {
+               switch (adev->id) {
+               case PPC440SPE_DMA0_ID:
+                       adev->common.max_xor = DMA0_FIFO_SIZE /
+                                               sizeof(struct dma_cdb);
+                       break;
+               case PPC440SPE_DMA1_ID:
+                       adev->common.max_xor = DMA1_FIFO_SIZE /
+                                               sizeof(struct dma_cdb);
+                       break;
+               }
+               adev->common.device_prep_dma_xor_val =
+                       ppc440spe_adma_prep_dma_xor_zero_sum;
+       }
+       if (dma_has_cap(DMA_INTERRUPT, adev->common.cap_mask)) {
+               adev->common.device_prep_dma_interrupt =
+                       ppc440spe_adma_prep_dma_interrupt;
+       }
+       pr_info("%s: AMCC(R) PPC440SP(E) ADMA Engine: "
+         "( %s%s%s%s%s%s%s)\n",
+         dev_name(adev->dev),
+         dma_has_cap(DMA_PQ, adev->common.cap_mask) ? "pq " : "",
+         dma_has_cap(DMA_PQ_VAL, adev->common.cap_mask) ? "pq_val " : "",
+         dma_has_cap(DMA_XOR, adev->common.cap_mask) ? "xor " : "",
+         dma_has_cap(DMA_XOR_VAL, adev->common.cap_mask) ? "xor_val " : "",
+         dma_has_cap(DMA_MEMCPY, adev->common.cap_mask) ? "memcpy " : "",
+         dma_has_cap(DMA_MEMSET, adev->common.cap_mask)  ? "memset " : "",
+         dma_has_cap(DMA_INTERRUPT, adev->common.cap_mask) ? "intr " : "");
+}
+
+static int ppc440spe_adma_setup_irqs(struct ppc440spe_adma_device *adev,
+                                    struct ppc440spe_adma_chan *chan,
+                                    int *initcode)
+{
+       struct device_node *np;
+       int ret;
+
+       np = container_of(adev->dev, struct of_device, dev)->node;
+       if (adev->id != PPC440SPE_XOR_ID) {
+               adev->err_irq = irq_of_parse_and_map(np, 1);
+               if (adev->err_irq == NO_IRQ) {
+                       dev_warn(adev->dev, "no err irq resource?\n");
+                       *initcode = PPC_ADMA_INIT_IRQ2;
+                       adev->err_irq = -ENXIO;
+               } else
+                       atomic_inc(&ppc440spe_adma_err_irq_ref);
+       } else {
+               adev->err_irq = -ENXIO;
+       }
+
+       adev->irq = irq_of_parse_and_map(np, 0);
+       if (adev->irq == NO_IRQ) {
+               dev_err(adev->dev, "no irq resource\n");
+               *initcode = PPC_ADMA_INIT_IRQ1;
+               ret = -ENXIO;
+               goto err_irq_map;
+       }
+       dev_dbg(adev->dev, "irq %d, err irq %d\n",
+               adev->irq, adev->err_irq);
+
+       ret = request_irq(adev->irq, ppc440spe_adma_eot_handler,
+                         0, dev_driver_string(adev->dev), chan);
+       if (ret) {
+               dev_err(adev->dev, "can't request irq %d\n",
+                       adev->irq);
+               *initcode = PPC_ADMA_INIT_IRQ1;
+               ret = -EIO;
+               goto err_req1;
+       }
+
+       /* only DMA engines have a separate error IRQ
+        * so it's Ok if err_irq < 0 in XOR engine case.
+        */
+       if (adev->err_irq > 0) {
+               /* both DMA engines share common error IRQ */
+               ret = request_irq(adev->err_irq,
+                                 ppc440spe_adma_err_handler,
+                                 IRQF_SHARED,
+                                 dev_driver_string(adev->dev),
+                                 chan);
+               if (ret) {
+                       dev_err(adev->dev, "can't request irq %d\n",
+                               adev->err_irq);
+                       *initcode = PPC_ADMA_INIT_IRQ2;
+                       ret = -EIO;
+                       goto err_req2;
+               }
+       }
+
+       if (adev->id == PPC440SPE_XOR_ID) {
+               /* enable XOR engine interrupts */
+               iowrite32be(XOR_IE_CBCIE_BIT | XOR_IE_ICBIE_BIT |
+                           XOR_IE_ICIE_BIT | XOR_IE_RPTIE_BIT,
+                           &adev->xor_reg->ier);
+       } else {
+               u32 mask, enable;
+
+               np = of_find_compatible_node(NULL, NULL, "ibm,i2o-440spe");
+               if (!np) {
+                       pr_err("%s: can't find I2O device tree node\n",
+                               __func__);
+                       ret = -ENODEV;
+                       goto err_req2;
+               }
+               adev->i2o_reg = of_iomap(np, 0);
+               if (!adev->i2o_reg) {
+                       pr_err("%s: failed to map I2O registers\n", __func__);
+                       of_node_put(np);
+                       ret = -EINVAL;
+                       goto err_req2;
+               }
+               of_node_put(np);
+               /* Unmask 'CS FIFO Attention' interrupts and
+                * enable generating interrupts on errors
+                */
+               enable = (adev->id == PPC440SPE_DMA0_ID) ?
+                        ~(I2O_IOPIM_P0SNE | I2O_IOPIM_P0EM) :
+                        ~(I2O_IOPIM_P1SNE | I2O_IOPIM_P1EM);
+               mask = ioread32(&adev->i2o_reg->iopim) & enable;
+               iowrite32(mask, &adev->i2o_reg->iopim);
+       }
+       return 0;
+
+err_req2:
+       free_irq(adev->irq, chan);
+err_req1:
+       irq_dispose_mapping(adev->irq);
+err_irq_map:
+       if (adev->err_irq > 0) {
+               if (atomic_dec_and_test(&ppc440spe_adma_err_irq_ref))
+                       irq_dispose_mapping(adev->err_irq);
+       }
+       return ret;
+}
+
+static void ppc440spe_adma_release_irqs(struct ppc440spe_adma_device *adev,
+                                       struct ppc440spe_adma_chan *chan)
+{
+       u32 mask, disable;
+
+       if (adev->id == PPC440SPE_XOR_ID) {
+               /* disable XOR engine interrupts */
+               mask = ioread32be(&adev->xor_reg->ier);
+               mask &= ~(XOR_IE_CBCIE_BIT | XOR_IE_ICBIE_BIT |
+                         XOR_IE_ICIE_BIT | XOR_IE_RPTIE_BIT);
+               iowrite32be(mask, &adev->xor_reg->ier);
+       } else {
+               /* disable DMAx engine interrupts */
+               disable = (adev->id == PPC440SPE_DMA0_ID) ?
+                         (I2O_IOPIM_P0SNE | I2O_IOPIM_P0EM) :
+                         (I2O_IOPIM_P1SNE | I2O_IOPIM_P1EM);
+               mask = ioread32(&adev->i2o_reg->iopim) | disable;
+               iowrite32(mask, &adev->i2o_reg->iopim);
+       }
+       free_irq(adev->irq, chan);
+       irq_dispose_mapping(adev->irq);
+       if (adev->err_irq > 0) {
+               free_irq(adev->err_irq, chan);
+               if (atomic_dec_and_test(&ppc440spe_adma_err_irq_ref)) {
+                       irq_dispose_mapping(adev->err_irq);
+                       iounmap(adev->i2o_reg);
+               }
+       }
+}
+
+/**
+ * ppc440spe_adma_probe - probe the asynch device
+ */
+static int __devinit ppc440spe_adma_probe(struct of_device *ofdev,
+                                         const struct of_device_id *match)
+{
+       struct device_node *np = ofdev->node;
+       struct resource res;
+       struct ppc440spe_adma_device *adev;
+       struct ppc440spe_adma_chan *chan;
+       struct ppc_dma_chan_ref *ref, *_ref;
+       int ret = 0, initcode = PPC_ADMA_INIT_OK;
+       const u32 *idx;
+       int len;
+       void *regs;
+       u32 id, pool_size;
+
+       if (of_device_is_compatible(np, "amcc,xor-accelerator")) {
+               id = PPC440SPE_XOR_ID;
+               /* As far as the XOR engine is concerned, it does not
+                * use FIFOs but uses linked list. So there is no dependency
+                * between pool size to allocate and the engine configuration.
+                */
+               pool_size = PAGE_SIZE << 1;
+       } else {
+               /* it is DMA0 or DMA1 */
+               idx = of_get_property(np, "cell-index", &len);
+               if (!idx || (len != sizeof(u32))) {
+                       dev_err(&ofdev->dev, "Device node %s has missing "
+                               "or invalid cell-index property\n",
+                               np->full_name);
+                       return -EINVAL;
+               }
+               id = *idx;
+               /* DMA0,1 engines use FIFO to maintain CDBs, so we
+                * should allocate the pool accordingly to size of this
+                * FIFO. Thus, the pool size depends on the FIFO depth:
+                * how much CDBs pointers the FIFO may contain then so
+                * much CDBs we should provide in the pool.
+                * That is
+                *   CDB size = 32B;
+                *   CDBs number = (DMA0_FIFO_SIZE >> 3);
+                *   Pool size = CDBs number * CDB size =
+                *      = (DMA0_FIFO_SIZE >> 3) << 5 = DMA0_FIFO_SIZE << 2.
+                */
+               pool_size = (id == PPC440SPE_DMA0_ID) ?
+                           DMA0_FIFO_SIZE : DMA1_FIFO_SIZE;
+               pool_size <<= 2;
+       }
+
+       if (of_address_to_resource(np, 0, &res)) {
+               dev_err(&ofdev->dev, "failed to get memory resource\n");
+               initcode = PPC_ADMA_INIT_MEMRES;
+               ret = -ENODEV;
+               goto out;
+       }
+
+       if (!request_mem_region(res.start, resource_size(&res),
+                               dev_driver_string(&ofdev->dev))) {
+               dev_err(&ofdev->dev, "failed to request memory region "
+                       "(0x%016llx-0x%016llx)\n",
+                       (u64)res.start, (u64)res.end);
+               initcode = PPC_ADMA_INIT_MEMREG;
+               ret = -EBUSY;
+               goto out;
+       }
+
+       /* create a device */
+       adev = kzalloc(sizeof(*adev), GFP_KERNEL);
+       if (!adev) {
+               dev_err(&ofdev->dev, "failed to allocate device\n");
+               initcode = PPC_ADMA_INIT_ALLOC;
+               ret = -ENOMEM;
+               goto err_adev_alloc;
+       }
+
+       adev->id = id;
+       adev->pool_size = pool_size;
+       /* allocate coherent memory for hardware descriptors */
+       adev->dma_desc_pool_virt = dma_alloc_coherent(&ofdev->dev,
+                                       adev->pool_size, &adev->dma_desc_pool,
+                                       GFP_KERNEL);
+       if (adev->dma_desc_pool_virt == NULL) {
+               dev_err(&ofdev->dev, "failed to allocate %d bytes of coherent "
+                       "memory for hardware descriptors\n",
+                       adev->pool_size);
+               initcode = PPC_ADMA_INIT_COHERENT;
+               ret = -ENOMEM;
+               goto err_dma_alloc;
+       }
+       dev_dbg(&ofdev->dev, "allocted descriptor pool virt 0x%p phys 0x%llx\n",
+               adev->dma_desc_pool_virt, (u64)adev->dma_desc_pool);
+
+       regs = ioremap(res.start, resource_size(&res));
+       if (!regs) {
+               dev_err(&ofdev->dev, "failed to ioremap regs!\n");
+               goto err_regs_alloc;
+       }
+
+       if (adev->id == PPC440SPE_XOR_ID) {
+               adev->xor_reg = regs;
+               /* Reset XOR */
+               iowrite32be(XOR_CRSR_XASR_BIT, &adev->xor_reg->crsr);
+               iowrite32be(XOR_CRSR_64BA_BIT, &adev->xor_reg->crrr);
+       } else {
+               size_t fifo_size = (adev->id == PPC440SPE_DMA0_ID) ?
+                                  DMA0_FIFO_SIZE : DMA1_FIFO_SIZE;
+               adev->dma_reg = regs;
+               /* DMAx_FIFO_SIZE is defined in bytes,
+                * <fsiz> - is defined in number of CDB pointers (8byte).
+                * DMA FIFO Length = CSlength + CPlength, where
+                * CSlength = CPlength = (fsiz + 1) * 8.
+                */
+               iowrite32(DMA_FIFO_ENABLE | ((fifo_size >> 3) - 2),
+                         &adev->dma_reg->fsiz);
+               /* Configure DMA engine */
+               iowrite32(DMA_CFG_DXEPR_HP | DMA_CFG_DFMPP_HP | DMA_CFG_FALGN,
+                         &adev->dma_reg->cfg);
+               /* Clear Status */
+               iowrite32(~0, &adev->dma_reg->dsts);
+       }
+
+       adev->dev = &ofdev->dev;
+       adev->common.dev = &ofdev->dev;
+       INIT_LIST_HEAD(&adev->common.channels);
+       dev_set_drvdata(&ofdev->dev, adev);
+
+       /* create a channel */
+       chan = kzalloc(sizeof(*chan), GFP_KERNEL);
+       if (!chan) {
+               dev_err(&ofdev->dev, "can't allocate channel structure\n");
+               initcode = PPC_ADMA_INIT_CHANNEL;
+               ret = -ENOMEM;
+               goto err_chan_alloc;
+       }
+
+       spin_lock_init(&chan->lock);
+       INIT_LIST_HEAD(&chan->chain);
+       INIT_LIST_HEAD(&chan->all_slots);
+       chan->device = adev;
+       chan->common.device = &adev->common;
+       list_add_tail(&chan->common.device_node, &adev->common.channels);
+       tasklet_init(&chan->irq_tasklet, ppc440spe_adma_tasklet,
+                    (unsigned long)chan);
+
+       /* allocate and map helper pages for async validation or
+        * async_mult/async_sum_product operations on DMA0/1.
+        */
+       if (adev->id != PPC440SPE_XOR_ID) {
+               chan->pdest_page = alloc_page(GFP_KERNEL);
+               chan->qdest_page = alloc_page(GFP_KERNEL);
+               if (!chan->pdest_page ||
+                   !chan->qdest_page) {
+                       if (chan->pdest_page)
+                               __free_page(chan->pdest_page);
+                       if (chan->qdest_page)
+                               __free_page(chan->qdest_page);
+                       ret = -ENOMEM;
+                       goto err_page_alloc;
+               }
+               chan->pdest = dma_map_page(&ofdev->dev, chan->pdest_page, 0,
+                                          PAGE_SIZE, DMA_BIDIRECTIONAL);
+               chan->qdest = dma_map_page(&ofdev->dev, chan->qdest_page, 0,
+                                          PAGE_SIZE, DMA_BIDIRECTIONAL);
+       }
+
+       ref = kmalloc(sizeof(*ref), GFP_KERNEL);
+       if (ref) {
+               ref->chan = &chan->common;
+               INIT_LIST_HEAD(&ref->node);
+               list_add_tail(&ref->node, &ppc440spe_adma_chan_list);
+       } else {
+               dev_err(&ofdev->dev, "failed to allocate channel reference!\n");
+               ret = -ENOMEM;
+               goto err_ref_alloc;
+       }
+
+       ret = ppc440spe_adma_setup_irqs(adev, chan, &initcode);
+       if (ret)
+               goto err_irq;
+
+       ppc440spe_adma_init_capabilities(adev);
+
+       ret = dma_async_device_register(&adev->common);
+       if (ret) {
+               initcode = PPC_ADMA_INIT_REGISTER;
+               dev_err(&ofdev->dev, "failed to register dma device\n");
+               goto err_dev_reg;
+       }
+
+       goto out;
+
+err_dev_reg:
+       ppc440spe_adma_release_irqs(adev, chan);
+err_irq:
+       list_for_each_entry_safe(ref, _ref, &ppc440spe_adma_chan_list, node) {
+               if (chan == to_ppc440spe_adma_chan(ref->chan)) {
+                       list_del(&ref->node);
+                       kfree(ref);
+               }
+       }
+err_ref_alloc:
+       if (adev->id != PPC440SPE_XOR_ID) {
+               dma_unmap_page(&ofdev->dev, chan->pdest,
+                              PAGE_SIZE, DMA_BIDIRECTIONAL);
+               dma_unmap_page(&ofdev->dev, chan->qdest,
+                              PAGE_SIZE, DMA_BIDIRECTIONAL);
+               __free_page(chan->pdest_page);
+               __free_page(chan->qdest_page);
+       }
+err_page_alloc:
+       kfree(chan);
+err_chan_alloc:
+       if (adev->id == PPC440SPE_XOR_ID)
+               iounmap(adev->xor_reg);
+       else
+               iounmap(adev->dma_reg);
+err_regs_alloc:
+       dma_free_coherent(adev->dev, adev->pool_size,
+                         adev->dma_desc_pool_virt,
+                         adev->dma_desc_pool);
+err_dma_alloc:
+       kfree(adev);
+err_adev_alloc:
+       release_mem_region(res.start, resource_size(&res));
+out:
+       if (id < PPC440SPE_ADMA_ENGINES_NUM)
+               ppc440spe_adma_devices[id] = initcode;
+
+       return ret;
+}
+
+/**
+ * ppc440spe_adma_remove - remove the asynch device
+ */
+static int __devexit ppc440spe_adma_remove(struct of_device *ofdev)
+{
+       struct ppc440spe_adma_device *adev = dev_get_drvdata(&ofdev->dev);
+       struct device_node *np = ofdev->node;
+       struct resource res;
+       struct dma_chan *chan, *_chan;
+       struct ppc_dma_chan_ref *ref, *_ref;
+       struct ppc440spe_adma_chan *ppc440spe_chan;
+
+       dev_set_drvdata(&ofdev->dev, NULL);
+       if (adev->id < PPC440SPE_ADMA_ENGINES_NUM)
+               ppc440spe_adma_devices[adev->id] = -1;
+
+       dma_async_device_unregister(&adev->common);
+
+       list_for_each_entry_safe(chan, _chan, &adev->common.channels,
+                                device_node) {
+               ppc440spe_chan = to_ppc440spe_adma_chan(chan);
+               ppc440spe_adma_release_irqs(adev, ppc440spe_chan);
+               tasklet_kill(&ppc440spe_chan->irq_tasklet);
+               if (adev->id != PPC440SPE_XOR_ID) {
+                       dma_unmap_page(&ofdev->dev, ppc440spe_chan->pdest,
+                                       PAGE_SIZE, DMA_BIDIRECTIONAL);
+                       dma_unmap_page(&ofdev->dev, ppc440spe_chan->qdest,
+                                       PAGE_SIZE, DMA_BIDIRECTIONAL);
+                       __free_page(ppc440spe_chan->pdest_page);
+                       __free_page(ppc440spe_chan->qdest_page);
+               }
+               list_for_each_entry_safe(ref, _ref, &ppc440spe_adma_chan_list,
+                                        node) {
+                       if (ppc440spe_chan ==
+                           to_ppc440spe_adma_chan(ref->chan)) {
+                               list_del(&ref->node);
+                               kfree(ref);
+                       }
+               }
+               list_del(&chan->device_node);
+               kfree(ppc440spe_chan);
+       }
+
+       dma_free_coherent(adev->dev, adev->pool_size,
+                         adev->dma_desc_pool_virt, adev->dma_desc_pool);
+       if (adev->id == PPC440SPE_XOR_ID)
+               iounmap(adev->xor_reg);
+       else
+               iounmap(adev->dma_reg);
+       of_address_to_resource(np, 0, &res);
+       release_mem_region(res.start, resource_size(&res));
+       kfree(adev);
+       return 0;
+}
+
+/*
+ * /sys driver interface to enable h/w RAID-6 capabilities
+ * Files created in e.g. /sys/devices/plb.0/400100100.dma0/driver/
+ * directory are "devices", "enable" and "poly".
+ * "devices" shows available engines.
+ * "enable" is used to enable RAID-6 capabilities or to check
+ * whether these has been activated.
+ * "poly" allows setting/checking used polynomial (for PPC440SPe only).
+ */
+
+static ssize_t show_ppc440spe_devices(struct device_driver *dev, char *buf)
+{
+       ssize_t size = 0;
+       int i;
+
+       for (i = 0; i < PPC440SPE_ADMA_ENGINES_NUM; i++) {
+               if (ppc440spe_adma_devices[i] == -1)
+                       continue;
+               size += snprintf(buf + size, PAGE_SIZE - size,
+                                "PPC440SP(E)-ADMA.%d: %s\n", i,
+                                ppc_adma_errors[ppc440spe_adma_devices[i]]);
+       }
+       return size;
+}
+
+static ssize_t show_ppc440spe_r6enable(struct device_driver *dev, char *buf)
+{
+       return snprintf(buf, PAGE_SIZE,
+                       "PPC440SP(e) RAID-6 capabilities are %sABLED.\n",
+                       ppc440spe_r6_enabled ? "EN" : "DIS");
+}
+
+static ssize_t store_ppc440spe_r6enable(struct device_driver *dev,
+                                       const char *buf, size_t count)
+{
+       unsigned long val;
+
+       if (!count || count > 11)
+               return -EINVAL;
+
+       if (!ppc440spe_r6_tchan)
+               return -EFAULT;
+
+       /* Write a key */
+       sscanf(buf, "%lx", &val);
+       dcr_write(ppc440spe_mq_dcr_host, DCRN_MQ0_XORBA, val);
+       isync();
+
+       /* Verify whether it really works now */
+       if (ppc440spe_test_raid6(ppc440spe_r6_tchan) == 0) {
+               pr_info("PPC440SP(e) RAID-6 has been activated "
+                       "successfully\n");
+               ppc440spe_r6_enabled = 1;
+       } else {
+               pr_info("PPC440SP(e) RAID-6 hasn't been activated!"
+                       " Error key ?\n");
+               ppc440spe_r6_enabled = 0;
+       }
+       return count;
+}
+
+static ssize_t show_ppc440spe_r6poly(struct device_driver *dev, char *buf)
+{
+       ssize_t size = 0;
+       u32 reg;
+
+#ifdef CONFIG_440SP
+       /* 440SP has fixed polynomial */
+       reg = 0x4d;
+#else
+       reg = dcr_read(ppc440spe_mq_dcr_host, DCRN_MQ0_CFBHL);
+       reg >>= MQ0_CFBHL_POLY;
+       reg &= 0xFF;
+#endif
+
+       size = snprintf(buf, PAGE_SIZE, "PPC440SP(e) RAID-6 driver "
+                       "uses 0x1%02x polynomial.\n", reg);
+       return size;
+}
+
+static ssize_t store_ppc440spe_r6poly(struct device_driver *dev,
+                                     const char *buf, size_t count)
+{
+       unsigned long reg, val;
+
+#ifdef CONFIG_440SP
+       /* 440SP uses default 0x14D polynomial only */
+       return -EINVAL;
+#endif
+
+       if (!count || count > 6)
+               return -EINVAL;
+
+       /* e.g., 0x14D or 0x11D */
+       sscanf(buf, "%lx", &val);
+
+       if (val & ~0x1FF)
+               return -EINVAL;
+
+       val &= 0xFF;
+       reg = dcr_read(ppc440spe_mq_dcr_host, DCRN_MQ0_CFBHL);
+       reg &= ~(0xFF << MQ0_CFBHL_POLY);
+       reg |= val << MQ0_CFBHL_POLY;
+       dcr_write(ppc440spe_mq_dcr_host, DCRN_MQ0_CFBHL, reg);
+
+       return count;
+}
+
+static DRIVER_ATTR(devices, S_IRUGO, show_ppc440spe_devices, NULL);
+static DRIVER_ATTR(enable, S_IRUGO | S_IWUSR, show_ppc440spe_r6enable,
+                  store_ppc440spe_r6enable);
+static DRIVER_ATTR(poly, S_IRUGO | S_IWUSR, show_ppc440spe_r6poly,
+                  store_ppc440spe_r6poly);
+
+/*
+ * Common initialisation for RAID engines; allocate memory for
+ * DMAx FIFOs, perform configuration common for all DMA engines.
+ * Further DMA engine specific configuration is done at probe time.
+ */
+static int ppc440spe_configure_raid_devices(void)
+{
+       struct device_node *np;
+       struct resource i2o_res;
+       struct i2o_regs __iomem *i2o_reg;
+       dcr_host_t i2o_dcr_host;
+       unsigned int dcr_base, dcr_len;
+       int i, ret;
+
+       np = of_find_compatible_node(NULL, NULL, "ibm,i2o-440spe");
+       if (!np) {
+               pr_err("%s: can't find I2O device tree node\n",
+                       __func__);
+               return -ENODEV;
+       }
+
+       if (of_address_to_resource(np, 0, &i2o_res)) {
+               of_node_put(np);
+               return -EINVAL;
+       }
+
+       i2o_reg = of_iomap(np, 0);
+       if (!i2o_reg) {
+               pr_err("%s: failed to map I2O registers\n", __func__);
+               of_node_put(np);
+               return -EINVAL;
+       }
+
+       /* Get I2O DCRs base */
+       dcr_base = dcr_resource_start(np, 0);
+       dcr_len = dcr_resource_len(np, 0);
+       if (!dcr_base && !dcr_len) {
+               pr_err("%s: can't get DCR registers base/len!\n",
+                       np->full_name);
+               of_node_put(np);
+               iounmap(i2o_reg);
+               return -ENODEV;
+       }
+
+       i2o_dcr_host = dcr_map(np, dcr_base, dcr_len);
+       if (!DCR_MAP_OK(i2o_dcr_host)) {
+               pr_err("%s: failed to map DCRs!\n", np->full_name);
+               of_node_put(np);
+               iounmap(i2o_reg);
+               return -ENODEV;
+       }
+       of_node_put(np);
+
+       /* Provide memory regions for DMA's FIFOs: I2O, DMA0 and DMA1 share
+        * the base address of FIFO memory space.
+        * Actually we need twice more physical memory than programmed in the
+        * <fsiz> register (because there are two FIFOs for each DMA: CP and CS)
+        */
+       ppc440spe_dma_fifo_buf = kmalloc((DMA0_FIFO_SIZE + DMA1_FIFO_SIZE) << 1,
+                                        GFP_KERNEL);
+       if (!ppc440spe_dma_fifo_buf) {
+               pr_err("%s: DMA FIFO buffer allocation failed.\n", __func__);
+               iounmap(i2o_reg);
+               dcr_unmap(i2o_dcr_host, dcr_len);
+               return -ENOMEM;
+       }
+
+       /*
+        * Configure h/w
+        */
+       /* Reset I2O/DMA */
+       mtdcri(SDR0, DCRN_SDR0_SRST, DCRN_SDR0_SRST_I2ODMA);
+       mtdcri(SDR0, DCRN_SDR0_SRST, 0);
+
+       /* Setup the base address of mmaped registers */
+       dcr_write(i2o_dcr_host, DCRN_I2O0_IBAH, (u32)(i2o_res.start >> 32));
+       dcr_write(i2o_dcr_host, DCRN_I2O0_IBAL, (u32)(i2o_res.start) |
+                                               I2O_REG_ENABLE);
+       dcr_unmap(i2o_dcr_host, dcr_len);
+
+       /* Setup FIFO memory space base address */
+       iowrite32(0, &i2o_reg->ifbah);
+       iowrite32(((u32)__pa(ppc440spe_dma_fifo_buf)), &i2o_reg->ifbal);
+
+       /* set zero FIFO size for I2O, so the whole
+        * ppc440spe_dma_fifo_buf is used by DMAs.
+        * DMAx_FIFOs will be configured while probe.
+        */
+       iowrite32(0, &i2o_reg->ifsiz);
+       iounmap(i2o_reg);
+
+       /* To prepare WXOR/RXOR functionality we need access to
+        * Memory Queue Module DCRs (finally it will be enabled
+        * via /sys interface of the ppc440spe ADMA driver).
+        */
+       np = of_find_compatible_node(NULL, NULL, "ibm,mq-440spe");
+       if (!np) {
+               pr_err("%s: can't find MQ device tree node\n",
+                       __func__);
+               ret = -ENODEV;
+               goto out_free;
+       }
+
+       /* Get MQ DCRs base */
+       dcr_base = dcr_resource_start(np, 0);
+       dcr_len = dcr_resource_len(np, 0);
+       if (!dcr_base && !dcr_len) {
+               pr_err("%s: can't get DCR registers base/len!\n",
+                       np->full_name);
+               ret = -ENODEV;
+               goto out_mq;
+       }
+
+       ppc440spe_mq_dcr_host = dcr_map(np, dcr_base, dcr_len);
+       if (!DCR_MAP_OK(ppc440spe_mq_dcr_host)) {
+               pr_err("%s: failed to map DCRs!\n", np->full_name);
+               ret = -ENODEV;
+               goto out_mq;
+       }
+       of_node_put(np);
+       ppc440spe_mq_dcr_len = dcr_len;
+
+       /* Set HB alias */
+       dcr_write(ppc440spe_mq_dcr_host, DCRN_MQ0_BAUH, DMA_CUED_XOR_HB);
+
+       /* Set:
+        * - LL transaction passing limit to 1;
+        * - Memory controller cycle limit to 1;
+        * - Galois Polynomial to 0x14d (default)
+        */
+       dcr_write(ppc440spe_mq_dcr_host, DCRN_MQ0_CFBHL,
+                 (1 << MQ0_CFBHL_TPLM) | (1 << MQ0_CFBHL_HBCL) |
+                 (PPC440SPE_DEFAULT_POLY << MQ0_CFBHL_POLY));
+
+       atomic_set(&ppc440spe_adma_err_irq_ref, 0);
+       for (i = 0; i < PPC440SPE_ADMA_ENGINES_NUM; i++)
+               ppc440spe_adma_devices[i] = -1;
+
+       return 0;
+
+out_mq:
+       of_node_put(np);
+out_free:
+       kfree(ppc440spe_dma_fifo_buf);
+       return ret;
+}
+
+static struct of_device_id __devinitdata ppc440spe_adma_of_match[] = {
+       { .compatible   = "ibm,dma-440spe", },
+       { .compatible   = "amcc,xor-accelerator", },
+       {},
+};
+MODULE_DEVICE_TABLE(of, ppc440spe_adma_of_match);
+
+static struct of_platform_driver ppc440spe_adma_driver = {
+       .match_table = ppc440spe_adma_of_match,
+       .probe = ppc440spe_adma_probe,
+       .remove = __devexit_p(ppc440spe_adma_remove),
+       .driver = {
+               .name = "PPC440SP(E)-ADMA",
+               .owner = THIS_MODULE,
+       },
+};
+
+static __init int ppc440spe_adma_init(void)
+{
+       int ret;
+
+       ret = ppc440spe_configure_raid_devices();
+       if (ret)
+               return ret;
+
+       ret = of_register_platform_driver(&ppc440spe_adma_driver);
+       if (ret) {
+               pr_err("%s: failed to register platform driver\n",
+                       __func__);
+               goto out_reg;
+       }
+
+       /* Initialization status */
+       ret = driver_create_file(&ppc440spe_adma_driver.driver,
+                                &driver_attr_devices);
+       if (ret)
+               goto out_dev;
+
+       /* RAID-6 h/w enable entry */
+       ret = driver_create_file(&ppc440spe_adma_driver.driver,
+                                &driver_attr_enable);
+       if (ret)
+               goto out_en;
+
+       /* GF polynomial to use */
+       ret = driver_create_file(&ppc440spe_adma_driver.driver,
+                                &driver_attr_poly);
+       if (!ret)
+               return ret;
+
+       driver_remove_file(&ppc440spe_adma_driver.driver,
+                          &driver_attr_enable);
+out_en:
+       driver_remove_file(&ppc440spe_adma_driver.driver,
+                          &driver_attr_devices);
+out_dev:
+       /* User will not be able to enable h/w RAID-6 */
+       pr_err("%s: failed to create RAID-6 driver interface\n",
+               __func__);
+       of_unregister_platform_driver(&ppc440spe_adma_driver);
+out_reg:
+       dcr_unmap(ppc440spe_mq_dcr_host, ppc440spe_mq_dcr_len);
+       kfree(ppc440spe_dma_fifo_buf);
+       return ret;
+}
+
+static void __exit ppc440spe_adma_exit(void)
+{
+       driver_remove_file(&ppc440spe_adma_driver.driver,
+                          &driver_attr_poly);
+       driver_remove_file(&ppc440spe_adma_driver.driver,
+                          &driver_attr_enable);
+       driver_remove_file(&ppc440spe_adma_driver.driver,
+                          &driver_attr_devices);
+       of_unregister_platform_driver(&ppc440spe_adma_driver);
+       dcr_unmap(ppc440spe_mq_dcr_host, ppc440spe_mq_dcr_len);
+       kfree(ppc440spe_dma_fifo_buf);
+}
+
+arch_initcall(ppc440spe_adma_init);
+module_exit(ppc440spe_adma_exit);
+
+MODULE_AUTHOR("Yuri Tikhonov <yur@emcraft.com>");
+MODULE_DESCRIPTION("PPC440SPE ADMA Engine Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/dma/ppc4xx/adma.h b/drivers/dma/ppc4xx/adma.h
new file mode 100644 (file)
index 0000000..8ada5a8
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * 2006-2009 (C) DENX Software Engineering.
+ *
+ * Author: Yuri Tikhonov <yur@emcraft.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2.  This program is licensed "as is" without any warranty of
+ * any kind, whether express or implied.
+ */
+
+#ifndef _PPC440SPE_ADMA_H
+#define _PPC440SPE_ADMA_H
+
+#include <linux/types.h>
+#include "dma.h"
+#include "xor.h"
+
+#define to_ppc440spe_adma_chan(chan) \
+               container_of(chan, struct ppc440spe_adma_chan, common)
+#define to_ppc440spe_adma_device(dev) \
+               container_of(dev, struct ppc440spe_adma_device, common)
+#define tx_to_ppc440spe_adma_slot(tx) \
+               container_of(tx, struct ppc440spe_adma_desc_slot, async_tx)
+
+/* Default polynomial (for 440SP is only available) */
+#define PPC440SPE_DEFAULT_POLY 0x4d
+
+#define PPC440SPE_ADMA_ENGINES_NUM     (XOR_ENGINES_NUM + DMA_ENGINES_NUM)
+
+#define PPC440SPE_ADMA_WATCHDOG_MSEC   3
+#define PPC440SPE_ADMA_THRESHOLD       1
+
+#define PPC440SPE_DMA0_ID      0
+#define PPC440SPE_DMA1_ID      1
+#define PPC440SPE_XOR_ID       2
+
+#define PPC440SPE_ADMA_DMA_MAX_BYTE_COUNT      0xFFFFFFUL
+/* this is the XOR_CBBCR width */
+#define PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT      (1 << 31)
+#define PPC440SPE_ADMA_ZERO_SUM_MAX_BYTE_COUNT PPC440SPE_ADMA_XOR_MAX_BYTE_COUNT
+
+#define PPC440SPE_RXOR_RUN     0
+
+#define MQ0_CF2H_RXOR_BS_MASK  0x1FF
+
+#undef ADMA_LL_DEBUG
+
+/**
+ * struct ppc440spe_adma_device - internal representation of an ADMA device
+ * @dev: device
+ * @dma_reg: base for DMAx register access
+ * @xor_reg: base for XOR register access
+ * @i2o_reg: base for I2O register access
+ * @id: HW ADMA Device selector
+ * @dma_desc_pool_virt: base of DMA descriptor region (CPU address)
+ * @dma_desc_pool: base of DMA descriptor region (DMA address)
+ * @pool_size: size of the pool
+ * @irq: DMAx or XOR irq number
+ * @err_irq: DMAx error irq number
+ * @common: embedded struct dma_device
+ */
+struct ppc440spe_adma_device {
+       struct device *dev;
+       struct dma_regs __iomem *dma_reg;
+       struct xor_regs __iomem *xor_reg;
+       struct i2o_regs __iomem *i2o_reg;
+       int id;
+       void *dma_desc_pool_virt;
+       dma_addr_t dma_desc_pool;
+       size_t pool_size;
+       int irq;
+       int err_irq;
+       struct dma_device common;
+};
+
+/**
+ * struct ppc440spe_adma_chan - internal representation of an ADMA channel
+ * @lock: serializes enqueue/dequeue operations to the slot pool
+ * @device: parent device
+ * @chain: device chain view of the descriptors
+ * @common: common dmaengine channel object members
+ * @all_slots: complete domain of slots usable by the channel
+ * @pending: allows batching of hardware operations
+ * @completed_cookie: identifier for the most recently completed operation
+ * @slots_allocated: records the actual size of the descriptor slot pool
+ * @hw_chain_inited: h/w descriptor chain initialization flag
+ * @irq_tasklet: bottom half where ppc440spe_adma_slot_cleanup runs
+ * @needs_unmap: if buffers should not be unmapped upon final processing
+ * @pdest_page: P destination page for async validate operation
+ * @qdest_page: Q destination page for async validate operation
+ * @pdest: P dma addr for async validate operation
+ * @qdest: Q dma addr for async validate operation
+ */
+struct ppc440spe_adma_chan {
+       spinlock_t lock;
+       struct ppc440spe_adma_device *device;
+       struct list_head chain;
+       struct dma_chan common;
+       struct list_head all_slots;
+       struct ppc440spe_adma_desc_slot *last_used;
+       int pending;
+       dma_cookie_t completed_cookie;
+       int slots_allocated;
+       int hw_chain_inited;
+       struct tasklet_struct irq_tasklet;
+       u8 needs_unmap;
+       struct page *pdest_page;
+       struct page *qdest_page;
+       dma_addr_t pdest;
+       dma_addr_t qdest;
+};
+
+struct ppc440spe_rxor {
+       u32 addrl;
+       u32 addrh;
+       int len;
+       int xor_count;
+       int addr_count;
+       int desc_count;
+       int state;
+};
+
+/**
+ * struct ppc440spe_adma_desc_slot - PPC440SPE-ADMA software descriptor
+ * @phys: hardware address of the hardware descriptor chain
+ * @group_head: first operation in a transaction
+ * @hw_next: pointer to the next descriptor in chain
+ * @async_tx: support for the async_tx api
+ * @slot_node: node on the iop_adma_chan.all_slots list
+ * @chain_node: node on the op_adma_chan.chain list
+ * @group_list: list of slots that make up a multi-descriptor transaction
+ *              for example transfer lengths larger than the supported hw max
+ * @unmap_len: transaction bytecount
+ * @hw_desc: virtual address of the hardware descriptor chain
+ * @stride: currently chained or not
+ * @idx: pool index
+ * @slot_cnt: total slots used in an transaction (group of operations)
+ * @src_cnt: number of sources set in this descriptor
+ * @dst_cnt: number of destinations set in the descriptor
+ * @slots_per_op: number of slots per operation
+ * @descs_per_op: number of slot per P/Q operation see comment
+ *                for ppc440spe_prep_dma_pqxor function
+ * @flags: desc state/type
+ * @reverse_flags: 1 if a corresponding rxor address uses reversed address order
+ * @xor_check_result: result of zero sum
+ * @crc32_result: result crc calculation
+ */
+struct ppc440spe_adma_desc_slot {
+       dma_addr_t phys;
+       struct ppc440spe_adma_desc_slot *group_head;
+       struct ppc440spe_adma_desc_slot *hw_next;
+       struct dma_async_tx_descriptor async_tx;
+       struct list_head slot_node;
+       struct list_head chain_node; /* node in channel ops list */
+       struct list_head group_list; /* list */
+       unsigned int unmap_len;
+       void *hw_desc;
+       u16 stride;
+       u16 idx;
+       u16 slot_cnt;
+       u8 src_cnt;
+       u8 dst_cnt;
+       u8 slots_per_op;
+       u8 descs_per_op;
+       unsigned long flags;
+       unsigned long reverse_flags[8];
+
+#define PPC440SPE_DESC_INT     0       /* generate interrupt on complete */
+#define PPC440SPE_ZERO_P       1       /* clear P destionaion */
+#define PPC440SPE_ZERO_Q       2       /* clear Q destination */
+#define PPC440SPE_COHERENT     3       /* src/dst are coherent */
+
+#define PPC440SPE_DESC_WXOR    4       /* WXORs are in chain */
+#define PPC440SPE_DESC_RXOR    5       /* RXOR is in chain */
+
+#define PPC440SPE_DESC_RXOR123 8       /* CDB for RXOR123 operation */
+#define PPC440SPE_DESC_RXOR124 9       /* CDB for RXOR124 operation */
+#define PPC440SPE_DESC_RXOR125 10      /* CDB for RXOR125 operation */
+#define PPC440SPE_DESC_RXOR12  11      /* CDB for RXOR12 operation */
+#define PPC440SPE_DESC_RXOR_REV        12      /* CDB has srcs in reversed order */
+
+#define PPC440SPE_DESC_PCHECK  13
+#define PPC440SPE_DESC_QCHECK  14
+
+#define PPC440SPE_DESC_RXOR_MSK        0x3
+
+       struct ppc440spe_rxor rxor_cursor;
+
+       union {
+               u32 *xor_check_result;
+               u32 *crc32_result;
+       };
+};
+
+#endif /* _PPC440SPE_ADMA_H */
diff --git a/drivers/dma/ppc4xx/dma.h b/drivers/dma/ppc4xx/dma.h
new file mode 100644 (file)
index 0000000..bcde2df
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * 440SPe's DMA engines support header file
+ *
+ * 2006-2009 (C) DENX Software Engineering.
+ *
+ * Author: Yuri Tikhonov <yur@emcraft.com>
+ *
+ * This file is licensed under the term of  the GNU General Public License
+ * version 2. The program licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#ifndef        _PPC440SPE_DMA_H
+#define _PPC440SPE_DMA_H
+
+#include <linux/types.h>
+
+/* Number of elements in the array with statical CDBs */
+#define        MAX_STAT_DMA_CDBS       16
+/* Number of DMA engines available on the contoller */
+#define DMA_ENGINES_NUM                2
+
+/* Maximum h/w supported number of destinations */
+#define DMA_DEST_MAX_NUM       2
+
+/* FIFO's params */
+#define DMA0_FIFO_SIZE         0x1000
+#define DMA1_FIFO_SIZE         0x1000
+#define DMA_FIFO_ENABLE                (1<<12)
+
+/* DMA Configuration Register. Data Transfer Engine PLB Priority: */
+#define DMA_CFG_DXEPR_LP       (0<<26)
+#define DMA_CFG_DXEPR_HP       (3<<26)
+#define DMA_CFG_DXEPR_HHP      (2<<26)
+#define DMA_CFG_DXEPR_HHHP     (1<<26)
+
+/* DMA Configuration Register. DMA FIFO Manager PLB Priority: */
+#define DMA_CFG_DFMPP_LP       (0<<23)
+#define DMA_CFG_DFMPP_HP       (3<<23)
+#define DMA_CFG_DFMPP_HHP      (2<<23)
+#define DMA_CFG_DFMPP_HHHP     (1<<23)
+
+/* DMA Configuration Register. Force 64-byte Alignment */
+#define DMA_CFG_FALGN          (1 << 19)
+
+/*UIC0:*/
+#define D0CPF_INT              (1<<12)
+#define D0CSF_INT              (1<<11)
+#define D1CPF_INT              (1<<10)
+#define D1CSF_INT              (1<<9)
+/*UIC1:*/
+#define DMAE_INT               (1<<9)
+
+/* I2O IOP Interrupt Mask Register */
+#define I2O_IOPIM_P0SNE                (1<<3)
+#define I2O_IOPIM_P0EM         (1<<5)
+#define I2O_IOPIM_P1SNE                (1<<6)
+#define I2O_IOPIM_P1EM         (1<<8)
+
+/* DMA CDB fields */
+#define DMA_CDB_MSK            (0xF)
+#define DMA_CDB_64B_ADDR       (1<<2)
+#define DMA_CDB_NO_INT         (1<<3)
+#define DMA_CDB_STATUS_MSK     (0x3)
+#define DMA_CDB_ADDR_MSK       (0xFFFFFFF0)
+
+/* DMA CDB OpCodes */
+#define DMA_CDB_OPC_NO_OP      (0x00)
+#define DMA_CDB_OPC_MV_SG1_SG2 (0x01)
+#define DMA_CDB_OPC_MULTICAST  (0x05)
+#define DMA_CDB_OPC_DFILL128   (0x24)
+#define DMA_CDB_OPC_DCHECK128  (0x23)
+
+#define DMA_CUED_XOR_BASE      (0x10000000)
+#define DMA_CUED_XOR_HB                (0x00000008)
+
+#ifdef CONFIG_440SP
+#define DMA_CUED_MULT1_OFF     0
+#define DMA_CUED_MULT2_OFF     8
+#define DMA_CUED_MULT3_OFF     16
+#define DMA_CUED_REGION_OFF    24
+#define DMA_CUED_XOR_WIN_MSK   (0xFC000000)
+#else
+#define DMA_CUED_MULT1_OFF     2
+#define DMA_CUED_MULT2_OFF     10
+#define DMA_CUED_MULT3_OFF     18
+#define DMA_CUED_REGION_OFF    26
+#define DMA_CUED_XOR_WIN_MSK   (0xF0000000)
+#endif
+
+#define DMA_CUED_REGION_MSK    0x3
+#define DMA_RXOR123            0x0
+#define DMA_RXOR124            0x1
+#define DMA_RXOR125            0x2
+#define DMA_RXOR12             0x3
+
+/* S/G addresses */
+#define DMA_CDB_SG_SRC         1
+#define DMA_CDB_SG_DST1                2
+#define DMA_CDB_SG_DST2                3
+
+/*
+ * DMAx engines Command Descriptor Block Type
+ */
+struct dma_cdb {
+       /*
+        * Basic CDB structure (Table 20-17, p.499, 440spe_um_1_22.pdf)
+        */
+       u8      pad0[2];        /* reserved */
+       u8      attr;           /* attributes */
+       u8      opc;            /* opcode */
+       u32     sg1u;           /* upper SG1 address */
+       u32     sg1l;           /* lower SG1 address */
+       u32     cnt;            /* SG count, 3B used */
+       u32     sg2u;           /* upper SG2 address */
+       u32     sg2l;           /* lower SG2 address */
+       u32     sg3u;           /* upper SG3 address */
+       u32     sg3l;           /* lower SG3 address */
+};
+
+/*
+ * DMAx hardware registers (p.515 in 440SPe UM 1.22)
+ */
+struct dma_regs {
+       u32     cpfpl;
+       u32     cpfph;
+       u32     csfpl;
+       u32     csfph;
+       u32     dsts;
+       u32     cfg;
+       u8      pad0[0x8];
+       u16     cpfhp;
+       u16     cpftp;
+       u16     csfhp;
+       u16     csftp;
+       u8      pad1[0x8];
+       u32     acpl;
+       u32     acph;
+       u32     s1bpl;
+       u32     s1bph;
+       u32     s2bpl;
+       u32     s2bph;
+       u32     s3bpl;
+       u32     s3bph;
+       u8      pad2[0x10];
+       u32     earl;
+       u32     earh;
+       u8      pad3[0x8];
+       u32     seat;
+       u32     sead;
+       u32     op;
+       u32     fsiz;
+};
+
+/*
+ * I2O hardware registers (p.528 in 440SPe UM 1.22)
+ */
+struct i2o_regs {
+       u32     ists;
+       u32     iseat;
+       u32     isead;
+       u8      pad0[0x14];
+       u32     idbel;
+       u8      pad1[0xc];
+       u32     ihis;
+       u32     ihim;
+       u8      pad2[0x8];
+       u32     ihiq;
+       u32     ihoq;
+       u8      pad3[0x8];
+       u32     iopis;
+       u32     iopim;
+       u32     iopiq;
+       u8      iopoq;
+       u8      pad4[3];
+       u16     iiflh;
+       u16     iiflt;
+       u16     iiplh;
+       u16     iiplt;
+       u16     ioflh;
+       u16     ioflt;
+       u16     ioplh;
+       u16     ioplt;
+       u32     iidc;
+       u32     ictl;
+       u32     ifcpp;
+       u8      pad5[0x4];
+       u16     mfac0;
+       u16     mfac1;
+       u16     mfac2;
+       u16     mfac3;
+       u16     mfac4;
+       u16     mfac5;
+       u16     mfac6;
+       u16     mfac7;
+       u16     ifcfh;
+       u16     ifcht;
+       u8      pad6[0x4];
+       u32     iifmc;
+       u32     iodb;
+       u32     iodbc;
+       u32     ifbal;
+       u32     ifbah;
+       u32     ifsiz;
+       u32     ispd0;
+       u32     ispd1;
+       u32     ispd2;
+       u32     ispd3;
+       u32     ihipl;
+       u32     ihiph;
+       u32     ihopl;
+       u32     ihoph;
+       u32     iiipl;
+       u32     iiiph;
+       u32     iiopl;
+       u32     iioph;
+       u32     ifcpl;
+       u32     ifcph;
+       u8      pad7[0x8];
+       u32     iopt;
+};
+
+#endif /* _PPC440SPE_DMA_H */
diff --git a/drivers/dma/ppc4xx/xor.h b/drivers/dma/ppc4xx/xor.h
new file mode 100644 (file)
index 0000000..daed738
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * 440SPe's XOR engines support header file
+ *
+ * 2006-2009 (C) DENX Software Engineering.
+ *
+ * Author: Yuri Tikhonov <yur@emcraft.com>
+ *
+ * This file is licensed under the term of  the GNU General Public License
+ * version 2. The program licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#ifndef _PPC440SPE_XOR_H
+#define _PPC440SPE_XOR_H
+
+#include <linux/types.h>
+
+/* Number of XOR engines available on the contoller */
+#define XOR_ENGINES_NUM                1
+
+/* Number of operands supported in the h/w */
+#define XOR_MAX_OPS            16
+
+/*
+ * XOR Command Block Control Register bits
+ */
+#define XOR_CBCR_LNK_BIT        (1<<31) /* link present */
+#define XOR_CBCR_TGT_BIT        (1<<30) /* target present */
+#define XOR_CBCR_CBCE_BIT       (1<<29) /* command block compete enable */
+#define XOR_CBCR_RNZE_BIT       (1<<28) /* result not zero enable */
+#define XOR_CBCR_XNOR_BIT       (1<<15) /* XOR/XNOR */
+#define XOR_CDCR_OAC_MSK        (0x7F)  /* operand address count */
+
+/*
+ * XORCore Status Register bits
+ */
+#define XOR_SR_XCP_BIT         (1<<31) /* core processing */
+#define XOR_SR_ICB_BIT         (1<<17) /* invalid CB */
+#define XOR_SR_IC_BIT          (1<<16) /* invalid command */
+#define XOR_SR_IPE_BIT         (1<<15) /* internal parity error */
+#define XOR_SR_RNZ_BIT         (1<<2)  /* result not Zero */
+#define XOR_SR_CBC_BIT         (1<<1)  /* CB complete */
+#define XOR_SR_CBLC_BIT                (1<<0)  /* CB list complete */
+
+/*
+ * XORCore Control Set and Reset Register bits
+ */
+#define XOR_CRSR_XASR_BIT      (1<<31) /* soft reset */
+#define XOR_CRSR_XAE_BIT       (1<<30) /* enable */
+#define XOR_CRSR_RCBE_BIT      (1<<29) /* refetch CB enable */
+#define XOR_CRSR_PAUS_BIT      (1<<28) /* pause */
+#define XOR_CRSR_64BA_BIT      (1<<27) /* 64/32 CB format */
+#define XOR_CRSR_CLP_BIT       (1<<25) /* continue list processing */
+
+/*
+ * XORCore Interrupt Enable Register
+ */
+#define XOR_IE_ICBIE_BIT       (1<<17) /* Invalid Command Block IRQ Enable */
+#define XOR_IE_ICIE_BIT                (1<<16) /* Invalid Command IRQ Enable */
+#define XOR_IE_RPTIE_BIT       (1<<14) /* Read PLB Timeout Error IRQ Enable */
+#define XOR_IE_CBCIE_BIT       (1<<1)  /* CB complete interrupt enable */
+#define XOR_IE_CBLCI_BIT       (1<<0)  /* CB list complete interrupt enable */
+
+/*
+ * XOR Accelerator engine Command Block Type
+ */
+struct xor_cb {
+       /*
+        * Basic 64-bit format XOR CB (Table 19-1, p.463, 440spe_um_1_22.pdf)
+        */
+       u32     cbc;            /* control */
+       u32     cbbc;           /* byte count */
+       u32     cbs;            /* status */
+       u8      pad0[4];        /* reserved */
+       u32     cbtah;          /* target address high */
+       u32     cbtal;          /* target address low */
+       u32     cblah;          /* link address high */
+       u32     cblal;          /* link address low */
+       struct {
+               u32 h;
+               u32 l;
+       } __attribute__ ((packed)) ops[16];
+} __attribute__ ((packed));
+
+/*
+ * XOR hardware registers Table 19-3, UM 1.22
+ */
+struct xor_regs {
+       u32     op_ar[16][2];   /* operand address[0]-high,[1]-low registers */
+       u8      pad0[352];      /* reserved */
+       u32     cbcr;           /* CB control register */
+       u32     cbbcr;          /* CB byte count register */
+       u32     cbsr;           /* CB status register */
+       u8      pad1[4];        /* reserved */
+       u32     cbtahr;         /* operand target address high register */
+       u32     cbtalr;         /* operand target address low register */
+       u32     cblahr;         /* CB link address high register */
+       u32     cblalr;         /* CB link address low register */
+       u32     crsr;           /* control set register */
+       u32     crrr;           /* control reset register */
+       u32     ccbahr;         /* current CB address high register */
+       u32     ccbalr;         /* current CB address low register */
+       u32     plbr;           /* PLB configuration register */
+       u32     ier;            /* interrupt enable register */
+       u32     pecr;           /* parity error count register */
+       u32     sr;             /* status register */
+       u32     revidr;         /* revision ID register */
+};
+
+#endif /* _PPC440SPE_XOR_H */
index 034ecf0ace03751b5fb20b282328e8a4d70005fe..d10cc899c460619b072466805c078cb989c496dd 100644 (file)
 #include <linux/dmaengine.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
-#include <linux/dmapool.h>
 #include <linux/platform_device.h>
 #include <cpu/dma.h>
 #include <asm/dma-sh.h>
 #include "shdma.h"
 
 /* DMA descriptor control */
-#define DESC_LAST      (-1)
-#define DESC_COMP      (1)
-#define DESC_NCOMP     (0)
+enum sh_dmae_desc_status {
+       DESC_IDLE,
+       DESC_PREPARED,
+       DESC_SUBMITTED,
+       DESC_COMPLETED, /* completed, have to call callback */
+       DESC_WAITING,   /* callback called, waiting for ack / re-submit */
+};
 
 #define NR_DESCS_PER_CHANNEL 32
 /*
@@ -45,6 +48,8 @@
  */
 #define RS_DEFAULT  (RS_DUAL)
 
+static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all);
+
 #define SH_DMAC_CHAN_BASE(id) (dma_base_addr[id])
 static void sh_dmae_writel(struct sh_dmae_chan *sh_dc, u32 data, u32 reg)
 {
@@ -80,17 +85,17 @@ static int sh_dmae_rst(int id)
        unsigned short dmaor;
 
        sh_dmae_ctl_stop(id);
-       dmaor = (dmaor_read_reg(id)|DMAOR_INIT);
+       dmaor = dmaor_read_reg(id) | DMAOR_INIT;
 
        dmaor_write_reg(id, dmaor);
-       if ((dmaor_read_reg(id) & (DMAOR_AE | DMAOR_NMIF))) {
+       if (dmaor_read_reg(id) & (DMAOR_AE | DMAOR_NMIF)) {
                pr_warning(KERN_ERR "dma-sh: Can't initialize DMAOR.\n");
                return -EINVAL;
        }
        return 0;
 }
 
-static int dmae_is_idle(struct sh_dmae_chan *sh_chan)
+static int dmae_is_busy(struct sh_dmae_chan *sh_chan)
 {
        u32 chcr = sh_dmae_readl(sh_chan, CHCR);
        if (chcr & CHCR_DE) {
@@ -106,19 +111,18 @@ static inline unsigned int calc_xmit_shift(struct sh_dmae_chan *sh_chan)
        return ts_shift[(chcr & CHCR_TS_MASK) >> CHCR_TS_SHIFT];
 }
 
-static void dmae_set_reg(struct sh_dmae_chan *sh_chan, struct sh_dmae_regs hw)
+static void dmae_set_reg(struct sh_dmae_chan *sh_chan, struct sh_dmae_regs *hw)
 {
-       sh_dmae_writel(sh_chan, hw.sar, SAR);
-       sh_dmae_writel(sh_chan, hw.dar, DAR);
-       sh_dmae_writel(sh_chan,
-               (hw.tcr >> calc_xmit_shift(sh_chan)), TCR);
+       sh_dmae_writel(sh_chan, hw->sar, SAR);
+       sh_dmae_writel(sh_chan, hw->dar, DAR);
+       sh_dmae_writel(sh_chan, hw->tcr >> calc_xmit_shift(sh_chan), TCR);
 }
 
 static void dmae_start(struct sh_dmae_chan *sh_chan)
 {
        u32 chcr = sh_dmae_readl(sh_chan, CHCR);
 
-       chcr |= (CHCR_DE|CHCR_IE);
+       chcr |= CHCR_DE | CHCR_IE;
        sh_dmae_writel(sh_chan, chcr, CHCR);
 }
 
@@ -132,7 +136,7 @@ static void dmae_halt(struct sh_dmae_chan *sh_chan)
 
 static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
 {
-       int ret = dmae_is_idle(sh_chan);
+       int ret = dmae_is_busy(sh_chan);
        /* When DMA was working, can not set data to CHCR */
        if (ret)
                return ret;
@@ -149,7 +153,7 @@ static int dmae_set_dmars(struct sh_dmae_chan *sh_chan, u16 val)
 {
        u32 addr;
        int shift = 0;
-       int ret = dmae_is_idle(sh_chan);
+       int ret = dmae_is_busy(sh_chan);
        if (ret)
                return ret;
 
@@ -185,8 +189,9 @@ static int dmae_set_dmars(struct sh_dmae_chan *sh_chan, u16 val)
 
 static dma_cookie_t sh_dmae_tx_submit(struct dma_async_tx_descriptor *tx)
 {
-       struct sh_desc *desc = tx_to_sh_desc(tx);
+       struct sh_desc *desc = tx_to_sh_desc(tx), *chunk, *last = desc, *c;
        struct sh_dmae_chan *sh_chan = to_sh_chan(tx->chan);
+       dma_async_tx_callback callback = tx->callback;
        dma_cookie_t cookie;
 
        spin_lock_bh(&sh_chan->desc_lock);
@@ -196,45 +201,53 @@ static dma_cookie_t sh_dmae_tx_submit(struct dma_async_tx_descriptor *tx)
        if (cookie < 0)
                cookie = 1;
 
-       /* If desc only in the case of 1 */
-       if (desc->async_tx.cookie != -EBUSY)
-               desc->async_tx.cookie = cookie;
-       sh_chan->common.cookie = desc->async_tx.cookie;
+       sh_chan->common.cookie = cookie;
+       tx->cookie = cookie;
+
+       /* Mark all chunks of this descriptor as submitted, move to the queue */
+       list_for_each_entry_safe(chunk, c, desc->node.prev, node) {
+               /*
+                * All chunks are on the global ld_free, so, we have to find
+                * the end of the chain ourselves
+                */
+               if (chunk != desc && (chunk->mark == DESC_IDLE ||
+                                     chunk->async_tx.cookie > 0 ||
+                                     chunk->async_tx.cookie == -EBUSY ||
+                                     &chunk->node == &sh_chan->ld_free))
+                       break;
+               chunk->mark = DESC_SUBMITTED;
+               /* Callback goes to the last chunk */
+               chunk->async_tx.callback = NULL;
+               chunk->cookie = cookie;
+               list_move_tail(&chunk->node, &sh_chan->ld_queue);
+               last = chunk;
+       }
+
+       last->async_tx.callback = callback;
+       last->async_tx.callback_param = tx->callback_param;
 
-       list_splice_init(&desc->tx_list, sh_chan->ld_queue.prev);
+       dev_dbg(sh_chan->dev, "submit #%d@%p on %d: %x[%d] -> %x\n",
+               tx->cookie, &last->async_tx, sh_chan->id,
+               desc->hw.sar, desc->hw.tcr, desc->hw.dar);
 
        spin_unlock_bh(&sh_chan->desc_lock);
 
        return cookie;
 }
 
+/* Called with desc_lock held */
 static struct sh_desc *sh_dmae_get_desc(struct sh_dmae_chan *sh_chan)
 {
-       struct sh_desc *desc, *_desc, *ret = NULL;
+       struct sh_desc *desc;
 
-       spin_lock_bh(&sh_chan->desc_lock);
-       list_for_each_entry_safe(desc, _desc, &sh_chan->ld_free, node) {
-               if (async_tx_test_ack(&desc->async_tx)) {
+       list_for_each_entry(desc, &sh_chan->ld_free, node)
+               if (desc->mark != DESC_PREPARED) {
+                       BUG_ON(desc->mark != DESC_IDLE);
                        list_del(&desc->node);
-                       ret = desc;
-                       break;
+                       return desc;
                }
-       }
-       spin_unlock_bh(&sh_chan->desc_lock);
-
-       return ret;
-}
-
-static void sh_dmae_put_desc(struct sh_dmae_chan *sh_chan, struct sh_desc *desc)
-{
-       if (desc) {
-               spin_lock_bh(&sh_chan->desc_lock);
-
-               list_splice_init(&desc->tx_list, &sh_chan->ld_free);
-               list_add(&desc->node, &sh_chan->ld_free);
 
-               spin_unlock_bh(&sh_chan->desc_lock);
-       }
+       return NULL;
 }
 
 static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
@@ -253,11 +266,10 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
                dma_async_tx_descriptor_init(&desc->async_tx,
                                        &sh_chan->common);
                desc->async_tx.tx_submit = sh_dmae_tx_submit;
-               desc->async_tx.flags = DMA_CTRL_ACK;
-               INIT_LIST_HEAD(&desc->tx_list);
-               sh_dmae_put_desc(sh_chan, desc);
+               desc->mark = DESC_IDLE;
 
                spin_lock_bh(&sh_chan->desc_lock);
+               list_add(&desc->node, &sh_chan->ld_free);
                sh_chan->descs_allocated++;
        }
        spin_unlock_bh(&sh_chan->desc_lock);
@@ -274,7 +286,10 @@ static void sh_dmae_free_chan_resources(struct dma_chan *chan)
        struct sh_desc *desc, *_desc;
        LIST_HEAD(list);
 
-       BUG_ON(!list_empty(&sh_chan->ld_queue));
+       /* Prepared and not submitted descriptors can still be on the queue */
+       if (!list_empty(&sh_chan->ld_queue))
+               sh_dmae_chan_ld_cleanup(sh_chan, true);
+
        spin_lock_bh(&sh_chan->desc_lock);
 
        list_splice_init(&sh_chan->ld_free, &list);
@@ -293,6 +308,8 @@ static struct dma_async_tx_descriptor *sh_dmae_prep_memcpy(
        struct sh_dmae_chan *sh_chan;
        struct sh_desc *first = NULL, *prev = NULL, *new;
        size_t copy_size;
+       LIST_HEAD(tx_list);
+       int chunks = (len + SH_DMA_TCR_MAX) / (SH_DMA_TCR_MAX + 1);
 
        if (!chan)
                return NULL;
@@ -302,108 +319,189 @@ static struct dma_async_tx_descriptor *sh_dmae_prep_memcpy(
 
        sh_chan = to_sh_chan(chan);
 
+       /* Have to lock the whole loop to protect against concurrent release */
+       spin_lock_bh(&sh_chan->desc_lock);
+
+       /*
+        * Chaining:
+        * first descriptor is what user is dealing with in all API calls, its
+        *      cookie is at first set to -EBUSY, at tx-submit to a positive
+        *      number
+        * if more than one chunk is needed further chunks have cookie = -EINVAL
+        * the last chunk, if not equal to the first, has cookie = -ENOSPC
+        * all chunks are linked onto the tx_list head with their .node heads
+        *      only during this function, then they are immediately spliced
+        *      back onto the free list in form of a chain
+        */
        do {
-               /* Allocate the link descriptor from DMA pool */
+               /* Allocate the link descriptor from the free list */
                new = sh_dmae_get_desc(sh_chan);
                if (!new) {
                        dev_err(sh_chan->dev,
-                                       "No free memory for link descriptor\n");
-                       goto err_get_desc;
+                               "No free memory for link descriptor\n");
+                       list_for_each_entry(new, &tx_list, node)
+                               new->mark = DESC_IDLE;
+                       list_splice(&tx_list, &sh_chan->ld_free);
+                       spin_unlock_bh(&sh_chan->desc_lock);
+                       return NULL;
                }
 
-               copy_size = min(len, (size_t)SH_DMA_TCR_MAX);
+               copy_size = min(len, (size_t)SH_DMA_TCR_MAX + 1);
 
                new->hw.sar = dma_src;
                new->hw.dar = dma_dest;
                new->hw.tcr = copy_size;
-               if (!first)
+               if (!first) {
+                       /* First desc */
+                       new->async_tx.cookie = -EBUSY;
                        first = new;
+               } else {
+                       /* Other desc - invisible to the user */
+                       new->async_tx.cookie = -EINVAL;
+               }
 
-               new->mark = DESC_NCOMP;
-               async_tx_ack(&new->async_tx);
+               dev_dbg(sh_chan->dev,
+                       "chaining %u of %u with %p, dst %x, cookie %d\n",
+                       copy_size, len, &new->async_tx, dma_dest,
+                       new->async_tx.cookie);
+
+               new->mark = DESC_PREPARED;
+               new->async_tx.flags = flags;
+               new->chunks = chunks--;
 
                prev = new;
                len -= copy_size;
                dma_src += copy_size;
                dma_dest += copy_size;
                /* Insert the link descriptor to the LD ring */
-               list_add_tail(&new->node, &first->tx_list);
+               list_add_tail(&new->node, &tx_list);
        } while (len);
 
-       new->async_tx.flags = flags; /* client is in control of this ack */
-       new->async_tx.cookie = -EBUSY; /* Last desc */
+       if (new != first)
+               new->async_tx.cookie = -ENOSPC;
 
-       return &first->async_tx;
+       /* Put them back on the free list, so, they don't get lost */
+       list_splice_tail(&tx_list, &sh_chan->ld_free);
 
-err_get_desc:
-       sh_dmae_put_desc(sh_chan, first);
-       return NULL;
+       spin_unlock_bh(&sh_chan->desc_lock);
 
+       return &first->async_tx;
 }
 
-/*
- * sh_chan_ld_cleanup - Clean up link descriptors
- *
- * This function clean up the ld_queue of DMA channel.
- */
-static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan)
+static dma_async_tx_callback __ld_cleanup(struct sh_dmae_chan *sh_chan, bool all)
 {
        struct sh_desc *desc, *_desc;
+       /* Is the "exposed" head of a chain acked? */
+       bool head_acked = false;
+       dma_cookie_t cookie = 0;
+       dma_async_tx_callback callback = NULL;
+       void *param = NULL;
 
        spin_lock_bh(&sh_chan->desc_lock);
        list_for_each_entry_safe(desc, _desc, &sh_chan->ld_queue, node) {
-               dma_async_tx_callback callback;
-               void *callback_param;
-
-               /* non send data */
-               if (desc->mark == DESC_NCOMP)
+               struct dma_async_tx_descriptor *tx = &desc->async_tx;
+
+               BUG_ON(tx->cookie > 0 && tx->cookie != desc->cookie);
+               BUG_ON(desc->mark != DESC_SUBMITTED &&
+                      desc->mark != DESC_COMPLETED &&
+                      desc->mark != DESC_WAITING);
+
+               /*
+                * queue is ordered, and we use this loop to (1) clean up all
+                * completed descriptors, and to (2) update descriptor flags of
+                * any chunks in a (partially) completed chain
+                */
+               if (!all && desc->mark == DESC_SUBMITTED &&
+                   desc->cookie != cookie)
                        break;
 
-               /* send data sesc */
-               callback = desc->async_tx.callback;
-               callback_param = desc->async_tx.callback_param;
+               if (tx->cookie > 0)
+                       cookie = tx->cookie;
 
-               /* Remove from ld_queue list */
-               list_splice_init(&desc->tx_list, &sh_chan->ld_free);
+               if (desc->mark == DESC_COMPLETED && desc->chunks == 1) {
+                       BUG_ON(sh_chan->completed_cookie != desc->cookie - 1);
+                       sh_chan->completed_cookie = desc->cookie;
+               }
 
-               dev_dbg(sh_chan->dev, "link descriptor %p will be recycle.\n",
-                               desc);
+               /* Call callback on the last chunk */
+               if (desc->mark == DESC_COMPLETED && tx->callback) {
+                       desc->mark = DESC_WAITING;
+                       callback = tx->callback;
+                       param = tx->callback_param;
+                       dev_dbg(sh_chan->dev, "descriptor #%d@%p on %d callback\n",
+                               tx->cookie, tx, sh_chan->id);
+                       BUG_ON(desc->chunks != 1);
+                       break;
+               }
 
-               list_move(&desc->node, &sh_chan->ld_free);
-               /* Run the link descriptor callback function */
-               if (callback) {
-                       spin_unlock_bh(&sh_chan->desc_lock);
-                       dev_dbg(sh_chan->dev, "link descriptor %p callback\n",
-                                       desc);
-                       callback(callback_param);
-                       spin_lock_bh(&sh_chan->desc_lock);
+               if (tx->cookie > 0 || tx->cookie == -EBUSY) {
+                       if (desc->mark == DESC_COMPLETED) {
+                               BUG_ON(tx->cookie < 0);
+                               desc->mark = DESC_WAITING;
+                       }
+                       head_acked = async_tx_test_ack(tx);
+               } else {
+                       switch (desc->mark) {
+                       case DESC_COMPLETED:
+                               desc->mark = DESC_WAITING;
+                               /* Fall through */
+                       case DESC_WAITING:
+                               if (head_acked)
+                                       async_tx_ack(&desc->async_tx);
+                       }
+               }
+
+               dev_dbg(sh_chan->dev, "descriptor %p #%d completed.\n",
+                       tx, tx->cookie);
+
+               if (((desc->mark == DESC_COMPLETED ||
+                     desc->mark == DESC_WAITING) &&
+                    async_tx_test_ack(&desc->async_tx)) || all) {
+                       /* Remove from ld_queue list */
+                       desc->mark = DESC_IDLE;
+                       list_move(&desc->node, &sh_chan->ld_free);
                }
        }
        spin_unlock_bh(&sh_chan->desc_lock);
+
+       if (callback)
+               callback(param);
+
+       return callback;
+}
+
+/*
+ * sh_chan_ld_cleanup - Clean up link descriptors
+ *
+ * This function cleans up the ld_queue of DMA channel.
+ */
+static void sh_dmae_chan_ld_cleanup(struct sh_dmae_chan *sh_chan, bool all)
+{
+       while (__ld_cleanup(sh_chan, all))
+               ;
 }
 
 static void sh_chan_xfer_ld_queue(struct sh_dmae_chan *sh_chan)
 {
-       struct list_head *ld_node;
-       struct sh_dmae_regs hw;
+       struct sh_desc *sd;
 
+       spin_lock_bh(&sh_chan->desc_lock);
        /* DMA work check */
-       if (dmae_is_idle(sh_chan))
+       if (dmae_is_busy(sh_chan)) {
+               spin_unlock_bh(&sh_chan->desc_lock);
                return;
+       }
 
        /* Find the first un-transfer desciptor */
-       for (ld_node = sh_chan->ld_queue.next;
-               (ld_node != &sh_chan->ld_queue)
-                       && (to_sh_desc(ld_node)->mark == DESC_COMP);
-               ld_node = ld_node->next)
-               cpu_relax();
-
-       if (ld_node != &sh_chan->ld_queue) {
-               /* Get the ld start address from ld_queue */
-               hw = to_sh_desc(ld_node)->hw;
-               dmae_set_reg(sh_chan, hw);
-               dmae_start(sh_chan);
-       }
+       list_for_each_entry(sd, &sh_chan->ld_queue, node)
+               if (sd->mark == DESC_SUBMITTED) {
+                       /* Get the ld start address from ld_queue */
+                       dmae_set_reg(sh_chan, &sd->hw);
+                       dmae_start(sh_chan);
+                       break;
+               }
+
+       spin_unlock_bh(&sh_chan->desc_lock);
 }
 
 static void sh_dmae_memcpy_issue_pending(struct dma_chan *chan)
@@ -421,12 +519,11 @@ static enum dma_status sh_dmae_is_complete(struct dma_chan *chan,
        dma_cookie_t last_used;
        dma_cookie_t last_complete;
 
-       sh_dmae_chan_ld_cleanup(sh_chan);
+       sh_dmae_chan_ld_cleanup(sh_chan, false);
 
        last_used = chan->cookie;
        last_complete = sh_chan->completed_cookie;
-       if (last_complete == -EBUSY)
-               last_complete = last_used;
+       BUG_ON(last_complete < 0);
 
        if (done)
                *done = last_complete;
@@ -481,11 +578,13 @@ static irqreturn_t sh_dmae_err(int irq, void *data)
                err = sh_dmae_rst(0);
                if (err)
                        return err;
+#ifdef SH_DMAC_BASE1
                if (shdev->pdata.mode & SHDMA_DMAOR1) {
                        err = sh_dmae_rst(1);
                        if (err)
                                return err;
                }
+#endif
                disable_irq(irq);
                return IRQ_HANDLED;
        }
@@ -495,34 +594,25 @@ static irqreturn_t sh_dmae_err(int irq, void *data)
 static void dmae_do_tasklet(unsigned long data)
 {
        struct sh_dmae_chan *sh_chan = (struct sh_dmae_chan *)data;
-       struct sh_desc *desc, *_desc, *cur_desc = NULL;
+       struct sh_desc *desc;
        u32 sar_buf = sh_dmae_readl(sh_chan, SAR);
-       list_for_each_entry_safe(desc, _desc,
-                                       &sh_chan->ld_queue, node) {
-               if ((desc->hw.sar + desc->hw.tcr) == sar_buf) {
-                       cur_desc = desc;
-                       break;
-               }
-       }
 
-       if (cur_desc) {
-               switch (cur_desc->async_tx.cookie) {
-               case 0: /* other desc data */
-                       break;
-               case -EBUSY: /* last desc */
-               sh_chan->completed_cookie =
-                               cur_desc->async_tx.cookie;
-                       break;
-               default: /* first desc ( 0 < )*/
-                       sh_chan->completed_cookie =
-                               cur_desc->async_tx.cookie - 1;
+       spin_lock(&sh_chan->desc_lock);
+       list_for_each_entry(desc, &sh_chan->ld_queue, node) {
+               if ((desc->hw.sar + desc->hw.tcr) == sar_buf &&
+                   desc->mark == DESC_SUBMITTED) {
+                       dev_dbg(sh_chan->dev, "done #%d@%p dst %u\n",
+                               desc->async_tx.cookie, &desc->async_tx,
+                               desc->hw.dar);
+                       desc->mark = DESC_COMPLETED;
                        break;
                }
-               cur_desc->mark = DESC_COMP;
        }
+       spin_unlock(&sh_chan->desc_lock);
+
        /* Next desc */
        sh_chan_xfer_ld_queue(sh_chan);
-       sh_dmae_chan_ld_cleanup(sh_chan);
+       sh_dmae_chan_ld_cleanup(sh_chan, false);
 }
 
 static unsigned int get_dmae_irq(unsigned int id)
@@ -543,8 +633,8 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id)
        /* alloc channel */
        new_sh_chan = kzalloc(sizeof(struct sh_dmae_chan), GFP_KERNEL);
        if (!new_sh_chan) {
-               dev_err(shdev->common.dev, "No free memory for allocating "
-                               "dma channels!\n");
+               dev_err(shdev->common.dev,
+                       "No free memory for allocating dma channels!\n");
                return -ENOMEM;
        }
 
@@ -586,8 +676,8 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id)
                        "sh-dmae%d", new_sh_chan->id);
 
        /* set up channel irq */
-       err = request_irq(irq, &sh_dmae_interrupt,
-               irqflags, new_sh_chan->dev_id, new_sh_chan);
+       err = request_irq(irq, &sh_dmae_interrupt, irqflags,
+                         new_sh_chan->dev_id, new_sh_chan);
        if (err) {
                dev_err(shdev->common.dev, "DMA channel %d request_irq error "
                        "with return %d\n", id, err);
@@ -676,6 +766,8 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
        shdev->common.device_is_tx_complete = sh_dmae_is_complete;
        shdev->common.device_issue_pending = sh_dmae_memcpy_issue_pending;
        shdev->common.dev = &pdev->dev;
+       /* Default transfer size of 32 bytes requires 32-byte alignment */
+       shdev->common.copy_align = 5;
 
 #if defined(CONFIG_CPU_SH4)
        /* Non Mix IRQ mode SH7722/SH7730 etc... */
@@ -688,8 +780,8 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
        }
 
        for (ecnt = 0 ; ecnt < ARRAY_SIZE(eirq); ecnt++) {
-               err = request_irq(eirq[ecnt], sh_dmae_err,
-                       irqflags, "DMAC Address Error", shdev);
+               err = request_irq(eirq[ecnt], sh_dmae_err, irqflags,
+                                 "DMAC Address Error", shdev);
                if (err) {
                        dev_err(&pdev->dev, "DMA device request_irq"
                                "error (irq %d) with return %d\n",
index 2b4bc15a2c0ab21907c9bcbc8841a04bd2aa61da..108f1cffb6f5337fc0616858efdae82ec849a0b9 100644 (file)
@@ -13,9 +13,9 @@
 #ifndef __DMA_SHDMA_H
 #define __DMA_SHDMA_H
 
-#include <linux/device.h>
-#include <linux/dmapool.h>
 #include <linux/dmaengine.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
 
 #define SH_DMA_TCR_MAX 0x00FFFFFF      /* 16MB */
 
@@ -26,24 +26,27 @@ struct sh_dmae_regs {
 };
 
 struct sh_desc {
-       struct list_head tx_list;
        struct sh_dmae_regs hw;
        struct list_head node;
        struct dma_async_tx_descriptor async_tx;
+       dma_cookie_t cookie;
+       int chunks;
        int mark;
 };
 
+struct device;
+
 struct sh_dmae_chan {
        dma_cookie_t completed_cookie;  /* The maximum cookie completed */
-       spinlock_t desc_lock;                   /* Descriptor operation lock */
-       struct list_head ld_queue;              /* Link descriptors queue */
-       struct list_head ld_free;               /* Link descriptors free */
-       struct dma_chan common;                 /* DMA common channel */
-       struct device *dev;                             /* Channel device */
+       spinlock_t desc_lock;           /* Descriptor operation lock */
+       struct list_head ld_queue;      /* Link descriptors queue */
+       struct list_head ld_free;       /* Link descriptors free */
+       struct dma_chan common;         /* DMA common channel */
+       struct device *dev;             /* Channel device */
        struct tasklet_struct tasklet;  /* Tasklet */
-       int descs_allocated;                    /* desc count */
+       int descs_allocated;            /* desc count */
        int id;                         /* Raw id of this channel */
-       char dev_id[16];        /* unique name per DMAC of channel */
+       char dev_id[16];                /* unique name per DMAC of channel */
 
        /* Set chcr */
        int (*set_chcr)(struct sh_dmae_chan *sh_chan, u32 regs);
index fb6bb64e88619a729ab9b2cd1fa4574fd29be16e..3ebc61067e548d407af798687db075ae15003385 100644 (file)
@@ -1313,7 +1313,7 @@ static int txx9dmac_resume_noirq(struct device *dev)
 
 }
 
-static struct dev_pm_ops txx9dmac_dev_pm_ops = {
+static const struct dev_pm_ops txx9dmac_dev_pm_ops = {
        .suspend_noirq = txx9dmac_suspend_noirq,
        .resume_noirq = txx9dmac_resume_noirq,
 };
index df5b68433f3464ab4a03f4ee5453864946364275..c5facd951dda965e1c0f217b824289445c9e3165 100644 (file)
@@ -1700,11 +1700,14 @@ static void f10_map_sysaddr_to_csrow(struct mem_ctl_info *mci,
  */
 static void amd64_debug_display_dimm_sizes(int ctrl, struct amd64_pvt *pvt)
 {
-       int dimm, size0, size1;
+       int dimm, size0, size1, factor = 0;
        u32 dbam;
        u32 *dcsb;
 
        if (boot_cpu_data.x86 == 0xf) {
+               if (pvt->dclr0 & F10_WIDTH_128)
+                       factor = 1;
+
                /* K8 families < revF not supported yet */
               if (pvt->ext_model < K8_REV_F)
                        return;
@@ -1732,7 +1735,8 @@ static void amd64_debug_display_dimm_sizes(int ctrl, struct amd64_pvt *pvt)
                        size1 = pvt->ops->dbam_to_cs(pvt, DBAM_DIMM(dimm, dbam));
 
                edac_printk(KERN_DEBUG, EDAC_MC, " %d: %5dMB %d: %5dMB\n",
-                           dimm * 2, size0, dimm * 2 + 1, size1);
+                           dimm * 2,     size0 << factor,
+                           dimm * 2 + 1, size1 << factor);
        }
 }
 
@@ -2345,7 +2349,7 @@ static void amd64_read_mc_registers(struct amd64_pvt *pvt)
        amd64_read_pci_cfg(pvt->dram_f2_ctl, F10_DCLR_0, &pvt->dclr0);
        amd64_read_pci_cfg(pvt->dram_f2_ctl, F10_DCHR_0, &pvt->dchr0);
 
-       if (!dct_ganging_enabled(pvt)) {
+       if (!dct_ganging_enabled(pvt) && boot_cpu_data.x86 >= 0x10) {
                amd64_read_pci_cfg(pvt->dram_f2_ctl, F10_DCLR_1, &pvt->dclr1);
                amd64_read_pci_cfg(pvt->dram_f2_ctl, F10_DCHR_1, &pvt->dchr1);
        }
@@ -2686,9 +2690,8 @@ static int amd64_check_ecc_enabled(struct amd64_pvt *pvt)
                        amd64_printk(KERN_WARNING, "%s", ecc_warning);
                        return -ENODEV;
                }
-       } else
-               /* CLEAR the override, since BIOS controlled it */
                ecc_enable_override = 0;
+       }
 
        return 0;
 }
@@ -2925,16 +2928,15 @@ static void __devexit amd64_remove_one_instance(struct pci_dev *pdev)
 
        amd64_free_mc_sibling_devices(pvt);
 
-       kfree(pvt);
-       mci->pvt_info = NULL;
-
-       mci_lookup[pvt->mc_node_id] = NULL;
-
        /* unregister from EDAC MCE */
        amd_report_gart_errors(false);
        amd_unregister_ecc_decoder(amd64_decode_bus_error);
 
        /* Free the EDAC CORE resources */
+       mci->pvt_info = NULL;
+       mci_lookup[pvt->mc_node_id] = NULL;
+
+       kfree(pvt);
        edac_mc_free(mci);
 }
 
@@ -3011,25 +3013,29 @@ static void amd64_setup_pci_device(void)
 static int __init amd64_edac_init(void)
 {
        int nb, err = -ENODEV;
+       bool load_ok = false;
 
        edac_printk(KERN_INFO, EDAC_MOD_STR, EDAC_AMD64_VERSION "\n");
 
        opstate_init();
 
        if (cache_k8_northbridges() < 0)
-               return err;
+               goto err_ret;
 
        msrs = msrs_alloc();
+       if (!msrs)
+               goto err_ret;
 
        err = pci_register_driver(&amd64_pci_driver);
        if (err)
-               return err;
+               goto err_pci;
 
        /*
         * At this point, the array 'pvt_lookup[]' contains pointers to alloc'd
         * amd64_pvt structs. These will be used in the 2nd stage init function
         * to finish initialization of the MC instances.
         */
+       err = -ENODEV;
        for (nb = 0; nb < num_k8_northbridges; nb++) {
                if (!pvt_lookup[nb])
                        continue;
@@ -3037,16 +3043,21 @@ static int __init amd64_edac_init(void)
                err = amd64_init_2nd_stage(pvt_lookup[nb]);
                if (err)
                        goto err_2nd_stage;
-       }
 
-       amd64_setup_pci_device();
+               load_ok = true;
+       }
 
-       return 0;
+       if (load_ok) {
+               amd64_setup_pci_device();
+               return 0;
+       }
 
 err_2nd_stage:
-       debugf0("2nd stage failed\n");
        pci_unregister_driver(&amd64_pci_driver);
-
+err_pci:
+       msrs_free(msrs);
+       msrs = NULL;
+err_ret:
        return err;
 }
 
index c693fcc2213c67181126df50168071f1b0210413..8fc91a019620d57fab83e04ed34fac8d826f0e32 100644 (file)
@@ -299,6 +299,12 @@ void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors)
        if (!handle_errors)
                return;
 
+       /*
+        * GART TLB error reporting is disabled by default. Bail out early.
+        */
+       if (TLB_ERROR(ec) && !report_gart_errors)
+               return;
+
        pr_emerg(" Northbridge Error, node %d", node_id);
 
        /*
@@ -310,10 +316,9 @@ void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors)
                if (regs->nbsh & K8_NBSH_ERR_CPU_VAL)
                        pr_cont(", core: %u\n", (u8)(regs->nbsh & 0xf));
        } else {
-               pr_cont(", core: %d\n", ilog2((regs->nbsh & 0xf)));
+               pr_cont(", core: %d\n", fls((regs->nbsh & 0xf) - 1));
        }
 
-
        pr_emerg("%s.\n", EXT_ERR_MSG(xec));
 
        if (BUS_ERROR(ec) && nb_bus_decoder)
@@ -333,21 +338,6 @@ static void amd_decode_fr_mce(u64 mc5_status)
 static inline void amd_decode_err_code(unsigned int ec)
 {
        if (TLB_ERROR(ec)) {
-               /*
-                * GART errors are intended to help graphics driver developers
-                * to detect bad GART PTEs. It is recommended by AMD to disable
-                * GART table walk error reporting by default[1] (currently
-                * being disabled in mce_cpu_quirks()) and according to the
-                * comment in mce_cpu_quirks(), such GART errors can be
-                * incorrectly triggered. We may see these errors anyway and
-                * unless requested by the user, they won't be reported.
-                *
-                * [1] section 13.10.1 on BIOS and Kernel Developers Guide for
-                *     AMD NPT family 0Fh processors
-                */
-               if (!report_gart_errors)
-                       return;
-
                pr_emerg(" Transaction: %s, Cache Level %s\n",
                         TT_MSG(ec), LL_MSG(ec));
        } else if (MEM_ERROR(ec)) {
index 422728cfe99493ec078bae3d8a392470be157130..fb60a877d768197d59cc0f09ce26e2ef6714023c 100644 (file)
@@ -534,8 +534,6 @@ static void edac_pci_dev_parity_clear(struct pci_dev *dev)
 {
        u8 header_type;
 
-       debugf0("%s()\n", __func__);
-
        get_pci_parity_status(dev, 0);
 
        /* read the device TYPE, looking for bridges */
index 22db05a67bfbc2beb107e6f09650f6700bbcea6f..7785d8ffa40486841e3d3f09d66f50416fb91b6e 100644 (file)
@@ -9,6 +9,11 @@
  * Intel 5100X Chipset Memory Controller Hub (MCH) - Datasheet
  *      http://download.intel.com/design/chipsets/datashts/318378.pdf
  *
+ * The intel 5100 has two independent channels. EDAC core currently
+ * can not reflect this configuration so instead the chip-select
+ * rows for each respective channel are layed out one after another,
+ * the first half belonging to channel 0, the second half belonging
+ * to channel 1.
  */
 #include <linux/module.h>
 #include <linux/init.h>
@@ -25,6 +30,8 @@
 
 /* device 16, func 1 */
 #define I5100_MC               0x40    /* Memory Control Register */
+#define        I5100_MC_SCRBEN_MASK    (1 << 7)
+#define        I5100_MC_SCRBDONE_MASK  (1 << 4)
 #define I5100_MS               0x44    /* Memory Status Register */
 #define I5100_SPDDATA          0x48    /* Serial Presence Detect Status Reg */
 #define I5100_SPDCMD           0x4c    /* Serial Presence Detect Command Reg */
 
 /* bit field accessors */
 
+static inline u32 i5100_mc_scrben(u32 mc)
+{
+       return mc >> 7 & 1;
+}
+
 static inline u32 i5100_mc_errdeten(u32 mc)
 {
        return mc >> 5 & 1;
 }
 
+static inline u32 i5100_mc_scrbdone(u32 mc)
+{
+       return mc >> 4 & 1;
+}
+
 static inline u16 i5100_spddata_rdo(u16 a)
 {
        return a >> 15 & 1;
@@ -265,42 +282,43 @@ static inline u32 i5100_recmemb_ras(u32 a)
 }
 
 /* some generic limits */
-#define I5100_MAX_RANKS_PER_CTLR       6
-#define I5100_MAX_CTLRS                        2
+#define I5100_MAX_RANKS_PER_CHAN       6
+#define I5100_CHANNELS                     2
 #define I5100_MAX_RANKS_PER_DIMM       4
 #define I5100_DIMM_ADDR_LINES          (6 - 3) /* 64 bits / 8 bits per byte */
-#define I5100_MAX_DIMM_SLOTS_PER_CTLR  4
+#define I5100_MAX_DIMM_SLOTS_PER_CHAN  4
 #define I5100_MAX_RANK_INTERLEAVE      4
 #define I5100_MAX_DMIRS                        5
+#define I5100_SCRUB_REFRESH_RATE       (5 * 60 * HZ)
 
 struct i5100_priv {
        /* ranks on each dimm -- 0 maps to not present -- obtained via SPD */
-       int dimm_numrank[I5100_MAX_CTLRS][I5100_MAX_DIMM_SLOTS_PER_CTLR];
+       int dimm_numrank[I5100_CHANNELS][I5100_MAX_DIMM_SLOTS_PER_CHAN];
 
        /*
         * mainboard chip select map -- maps i5100 chip selects to
         * DIMM slot chip selects.  In the case of only 4 ranks per
-        * controller, the mapping is fairly obvious but not unique.
-        * we map -1 -> NC and assume both controllers use the same
+        * channel, the mapping is fairly obvious but not unique.
+        * we map -1 -> NC and assume both channels use the same
         * map...
         *
         */
-       int dimm_csmap[I5100_MAX_DIMM_SLOTS_PER_CTLR][I5100_MAX_RANKS_PER_DIMM];
+       int dimm_csmap[I5100_MAX_DIMM_SLOTS_PER_CHAN][I5100_MAX_RANKS_PER_DIMM];
 
        /* memory interleave range */
        struct {
                u64      limit;
                unsigned way[2];
-       } mir[I5100_MAX_CTLRS];
+       } mir[I5100_CHANNELS];
 
        /* adjusted memory interleave range register */
-       unsigned amir[I5100_MAX_CTLRS];
+       unsigned amir[I5100_CHANNELS];
 
        /* dimm interleave range */
        struct {
                unsigned rank[I5100_MAX_RANK_INTERLEAVE];
                u64      limit;
-       } dmir[I5100_MAX_CTLRS][I5100_MAX_DMIRS];
+       } dmir[I5100_CHANNELS][I5100_MAX_DMIRS];
 
        /* memory technology registers... */
        struct {
@@ -310,30 +328,33 @@ struct i5100_priv {
                unsigned numbank;       /* 2 or 3 lines */
                unsigned numrow;        /* 13 .. 16 lines */
                unsigned numcol;        /* 11 .. 12 lines */
-       } mtr[I5100_MAX_CTLRS][I5100_MAX_RANKS_PER_CTLR];
+       } mtr[I5100_CHANNELS][I5100_MAX_RANKS_PER_CHAN];
 
        u64 tolm;               /* top of low memory in bytes */
-       unsigned ranksperctlr;  /* number of ranks per controller */
+       unsigned ranksperchan;  /* number of ranks per channel */
 
        struct pci_dev *mc;     /* device 16 func 1 */
        struct pci_dev *ch0mm;  /* device 21 func 0 */
        struct pci_dev *ch1mm;  /* device 22 func 0 */
+
+       struct delayed_work i5100_scrubbing;
+       int scrub_enable;
 };
 
-/* map a rank/ctlr to a slot number on the mainboard */
+/* map a rank/chan to a slot number on the mainboard */
 static int i5100_rank_to_slot(const struct mem_ctl_info *mci,
-                             int ctlr, int rank)
+                             int chan, int rank)
 {
        const struct i5100_priv *priv = mci->pvt_info;
        int i;
 
-       for (i = 0; i < I5100_MAX_DIMM_SLOTS_PER_CTLR; i++) {
+       for (i = 0; i < I5100_MAX_DIMM_SLOTS_PER_CHAN; i++) {
                int j;
-               const int numrank = priv->dimm_numrank[ctlr][i];
+               const int numrank = priv->dimm_numrank[chan][i];
 
                for (j = 0; j < numrank; j++)
                        if (priv->dimm_csmap[i][j] == rank)
-                               return i * 2 + ctlr;
+                               return i * 2 + chan;
        }
 
        return -1;
@@ -374,32 +395,32 @@ static const char *i5100_err_msg(unsigned err)
        return "none";
 }
 
-/* convert csrow index into a rank (per controller -- 0..5) */
+/* convert csrow index into a rank (per channel -- 0..5) */
 static int i5100_csrow_to_rank(const struct mem_ctl_info *mci, int csrow)
 {
        const struct i5100_priv *priv = mci->pvt_info;
 
-       return csrow % priv->ranksperctlr;
+       return csrow % priv->ranksperchan;
 }
 
-/* convert csrow index into a controller (0..1) */
-static int i5100_csrow_to_cntlr(const struct mem_ctl_info *mci, int csrow)
+/* convert csrow index into a channel (0..1) */
+static int i5100_csrow_to_chan(const struct mem_ctl_info *mci, int csrow)
 {
        const struct i5100_priv *priv = mci->pvt_info;
 
-       return csrow / priv->ranksperctlr;
+       return csrow / priv->ranksperchan;
 }
 
 static unsigned i5100_rank_to_csrow(const struct mem_ctl_info *mci,
-                                   int ctlr, int rank)
+                                   int chan, int rank)
 {
        const struct i5100_priv *priv = mci->pvt_info;
 
-       return ctlr * priv->ranksperctlr + rank;
+       return chan * priv->ranksperchan + rank;
 }
 
 static void i5100_handle_ce(struct mem_ctl_info *mci,
-                           int ctlr,
+                           int chan,
                            unsigned bank,
                            unsigned rank,
                            unsigned long syndrome,
@@ -407,12 +428,12 @@ static void i5100_handle_ce(struct mem_ctl_info *mci,
                            unsigned ras,
                            const char *msg)
 {
-       const int csrow = i5100_rank_to_csrow(mci, ctlr, rank);
+       const int csrow = i5100_rank_to_csrow(mci, chan, rank);
 
        printk(KERN_ERR
-               "CE ctlr %d, bank %u, rank %u, syndrome 0x%lx, "
+               "CE chan %d, bank %u, rank %u, syndrome 0x%lx, "
                "cas %u, ras %u, csrow %u, label \"%s\": %s\n",
-               ctlr, bank, rank, syndrome, cas, ras,
+               chan, bank, rank, syndrome, cas, ras,
                csrow, mci->csrows[csrow].channels[0].label, msg);
 
        mci->ce_count++;
@@ -421,7 +442,7 @@ static void i5100_handle_ce(struct mem_ctl_info *mci,
 }
 
 static void i5100_handle_ue(struct mem_ctl_info *mci,
-                           int ctlr,
+                           int chan,
                            unsigned bank,
                            unsigned rank,
                            unsigned long syndrome,
@@ -429,23 +450,23 @@ static void i5100_handle_ue(struct mem_ctl_info *mci,
                            unsigned ras,
                            const char *msg)
 {
-       const int csrow = i5100_rank_to_csrow(mci, ctlr, rank);
+       const int csrow = i5100_rank_to_csrow(mci, chan, rank);
 
        printk(KERN_ERR
-               "UE ctlr %d, bank %u, rank %u, syndrome 0x%lx, "
+               "UE chan %d, bank %u, rank %u, syndrome 0x%lx, "
                "cas %u, ras %u, csrow %u, label \"%s\": %s\n",
-               ctlr, bank, rank, syndrome, cas, ras,
+               chan, bank, rank, syndrome, cas, ras,
                csrow, mci->csrows[csrow].channels[0].label, msg);
 
        mci->ue_count++;
        mci->csrows[csrow].ue_count++;
 }
 
-static void i5100_read_log(struct mem_ctl_info *mci, int ctlr,
+static void i5100_read_log(struct mem_ctl_info *mci, int chan,
                           u32 ferr, u32 nerr)
 {
        struct i5100_priv *priv = mci->pvt_info;
-       struct pci_dev *pdev = (ctlr) ? priv->ch1mm : priv->ch0mm;
+       struct pci_dev *pdev = (chan) ? priv->ch1mm : priv->ch0mm;
        u32 dw;
        u32 dw2;
        unsigned syndrome = 0;
@@ -484,7 +505,7 @@ static void i5100_read_log(struct mem_ctl_info *mci, int ctlr,
                else
                        msg = i5100_err_msg(nerr);
 
-               i5100_handle_ce(mci, ctlr, bank, rank, syndrome, cas, ras, msg);
+               i5100_handle_ce(mci, chan, bank, rank, syndrome, cas, ras, msg);
        }
 
        if (i5100_validlog_nrecmemvalid(dw)) {
@@ -506,7 +527,7 @@ static void i5100_read_log(struct mem_ctl_info *mci, int ctlr,
                else
                        msg = i5100_err_msg(nerr);
 
-               i5100_handle_ue(mci, ctlr, bank, rank, syndrome, cas, ras, msg);
+               i5100_handle_ue(mci, chan, bank, rank, syndrome, cas, ras, msg);
        }
 
        pci_write_config_dword(pdev, I5100_VALIDLOG, dw);
@@ -534,6 +555,80 @@ static void i5100_check_error(struct mem_ctl_info *mci)
        }
 }
 
+/* The i5100 chipset will scrub the entire memory once, then
+ * set a done bit. Continuous scrubbing is achieved by enqueing
+ * delayed work to a workqueue, checking every few minutes if
+ * the scrubbing has completed and if so reinitiating it.
+ */
+
+static void i5100_refresh_scrubbing(struct work_struct *work)
+{
+       struct delayed_work *i5100_scrubbing = container_of(work,
+                                                           struct delayed_work,
+                                                           work);
+       struct i5100_priv *priv = container_of(i5100_scrubbing,
+                                              struct i5100_priv,
+                                              i5100_scrubbing);
+       u32 dw;
+
+       pci_read_config_dword(priv->mc, I5100_MC, &dw);
+
+       if (priv->scrub_enable) {
+
+               pci_read_config_dword(priv->mc, I5100_MC, &dw);
+
+               if (i5100_mc_scrbdone(dw)) {
+                       dw |= I5100_MC_SCRBEN_MASK;
+                       pci_write_config_dword(priv->mc, I5100_MC, dw);
+                       pci_read_config_dword(priv->mc, I5100_MC, &dw);
+               }
+
+               schedule_delayed_work(&(priv->i5100_scrubbing),
+                                     I5100_SCRUB_REFRESH_RATE);
+       }
+}
+/*
+ * The bandwidth is based on experimentation, feel free to refine it.
+ */
+static int i5100_set_scrub_rate(struct mem_ctl_info *mci,
+                                      u32 *bandwidth)
+{
+       struct i5100_priv *priv = mci->pvt_info;
+       u32 dw;
+
+       pci_read_config_dword(priv->mc, I5100_MC, &dw);
+       if (*bandwidth) {
+               priv->scrub_enable = 1;
+               dw |= I5100_MC_SCRBEN_MASK;
+               schedule_delayed_work(&(priv->i5100_scrubbing),
+                                     I5100_SCRUB_REFRESH_RATE);
+       } else {
+               priv->scrub_enable = 0;
+               dw &= ~I5100_MC_SCRBEN_MASK;
+               cancel_delayed_work(&(priv->i5100_scrubbing));
+       }
+       pci_write_config_dword(priv->mc, I5100_MC, dw);
+
+       pci_read_config_dword(priv->mc, I5100_MC, &dw);
+
+       *bandwidth = 5900000 * i5100_mc_scrben(dw);
+
+       return 0;
+}
+
+static int i5100_get_scrub_rate(struct mem_ctl_info *mci,
+                               u32 *bandwidth)
+{
+       struct i5100_priv *priv = mci->pvt_info;
+       u32 dw;
+
+       pci_read_config_dword(priv->mc, I5100_MC, &dw);
+
+       *bandwidth = 5900000 * i5100_mc_scrben(dw);
+
+       return 0;
+}
+
 static struct pci_dev *pci_get_device_func(unsigned vendor,
                                           unsigned device,
                                           unsigned func)
@@ -557,19 +652,19 @@ static unsigned long __devinit i5100_npages(struct mem_ctl_info *mci,
                                            int csrow)
 {
        struct i5100_priv *priv = mci->pvt_info;
-       const unsigned ctlr_rank = i5100_csrow_to_rank(mci, csrow);
-       const unsigned ctlr = i5100_csrow_to_cntlr(mci, csrow);
+       const unsigned chan_rank = i5100_csrow_to_rank(mci, csrow);
+       const unsigned chan = i5100_csrow_to_chan(mci, csrow);
        unsigned addr_lines;
 
        /* dimm present? */
-       if (!priv->mtr[ctlr][ctlr_rank].present)
+       if (!priv->mtr[chan][chan_rank].present)
                return 0ULL;
 
        addr_lines =
                I5100_DIMM_ADDR_LINES +
-               priv->mtr[ctlr][ctlr_rank].numcol +
-               priv->mtr[ctlr][ctlr_rank].numrow +
-               priv->mtr[ctlr][ctlr_rank].numbank;
+               priv->mtr[chan][chan_rank].numcol +
+               priv->mtr[chan][chan_rank].numrow +
+               priv->mtr[chan][chan_rank].numbank;
 
        return (unsigned long)
                ((unsigned long long) (1ULL << addr_lines) / PAGE_SIZE);
@@ -581,11 +676,11 @@ static void __devinit i5100_init_mtr(struct mem_ctl_info *mci)
        struct pci_dev *mms[2] = { priv->ch0mm, priv->ch1mm };
        int i;
 
-       for (i = 0; i < I5100_MAX_CTLRS; i++) {
+       for (i = 0; i < I5100_CHANNELS; i++) {
                int j;
                struct pci_dev *pdev = mms[i];
 
-               for (j = 0; j < I5100_MAX_RANKS_PER_CTLR; j++) {
+               for (j = 0; j < I5100_MAX_RANKS_PER_CHAN; j++) {
                        const unsigned addr =
                                (j < 4) ? I5100_MTR_0 + j * 2 :
                                          I5100_MTR_4 + (j - 4) * 2;
@@ -644,7 +739,6 @@ static int i5100_read_spd_byte(const struct mem_ctl_info *mci,
  * fill dimm chip select map
  *
  * FIXME:
- *   o only valid for 4 ranks per controller
  *   o not the only way to may chip selects to dimm slots
  *   o investigate if there is some way to obtain this map from the bios
  */
@@ -653,9 +747,7 @@ static void __devinit i5100_init_dimm_csmap(struct mem_ctl_info *mci)
        struct i5100_priv *priv = mci->pvt_info;
        int i;
 
-       WARN_ON(priv->ranksperctlr != 4);
-
-       for (i = 0; i < I5100_MAX_DIMM_SLOTS_PER_CTLR; i++) {
+       for (i = 0; i < I5100_MAX_DIMM_SLOTS_PER_CHAN; i++) {
                int j;
 
                for (j = 0; j < I5100_MAX_RANKS_PER_DIMM; j++)
@@ -663,12 +755,21 @@ static void __devinit i5100_init_dimm_csmap(struct mem_ctl_info *mci)
        }
 
        /* only 2 chip selects per slot... */
-       priv->dimm_csmap[0][0] = 0;
-       priv->dimm_csmap[0][1] = 3;
-       priv->dimm_csmap[1][0] = 1;
-       priv->dimm_csmap[1][1] = 2;
-       priv->dimm_csmap[2][0] = 2;
-       priv->dimm_csmap[3][0] = 3;
+       if (priv->ranksperchan == 4) {
+               priv->dimm_csmap[0][0] = 0;
+               priv->dimm_csmap[0][1] = 3;
+               priv->dimm_csmap[1][0] = 1;
+               priv->dimm_csmap[1][1] = 2;
+               priv->dimm_csmap[2][0] = 2;
+               priv->dimm_csmap[3][0] = 3;
+       } else {
+               priv->dimm_csmap[0][0] = 0;
+               priv->dimm_csmap[0][1] = 1;
+               priv->dimm_csmap[1][0] = 2;
+               priv->dimm_csmap[1][1] = 3;
+               priv->dimm_csmap[2][0] = 4;
+               priv->dimm_csmap[2][1] = 5;
+       }
 }
 
 static void __devinit i5100_init_dimm_layout(struct pci_dev *pdev,
@@ -677,10 +778,10 @@ static void __devinit i5100_init_dimm_layout(struct pci_dev *pdev,
        struct i5100_priv *priv = mci->pvt_info;
        int i;
 
-       for (i = 0; i < I5100_MAX_CTLRS; i++) {
+       for (i = 0; i < I5100_CHANNELS; i++) {
                int j;
 
-               for (j = 0; j < I5100_MAX_DIMM_SLOTS_PER_CTLR; j++) {
+               for (j = 0; j < I5100_MAX_DIMM_SLOTS_PER_CHAN; j++) {
                        u8 rank;
 
                        if (i5100_read_spd_byte(mci, i, j, 5, &rank) < 0)
@@ -720,7 +821,7 @@ static void __devinit i5100_init_interleaving(struct pci_dev *pdev,
        pci_read_config_word(pdev, I5100_AMIR_1, &w);
        priv->amir[1] = w;
 
-       for (i = 0; i < I5100_MAX_CTLRS; i++) {
+       for (i = 0; i < I5100_CHANNELS; i++) {
                int j;
 
                for (j = 0; j < 5; j++) {
@@ -747,7 +848,7 @@ static void __devinit i5100_init_csrows(struct mem_ctl_info *mci)
 
        for (i = 0; i < mci->nr_csrows; i++) {
                const unsigned long npages = i5100_npages(mci, i);
-               const unsigned cntlr = i5100_csrow_to_cntlr(mci, i);
+               const unsigned chan = i5100_csrow_to_chan(mci, i);
                const unsigned rank = i5100_csrow_to_rank(mci, i);
 
                if (!npages)
@@ -765,7 +866,7 @@ static void __devinit i5100_init_csrows(struct mem_ctl_info *mci)
                mci->csrows[i].grain = 32;
                mci->csrows[i].csrow_idx = i;
                mci->csrows[i].dtype =
-                       (priv->mtr[cntlr][rank].width == 4) ? DEV_X4 : DEV_X8;
+                       (priv->mtr[chan][rank].width == 4) ? DEV_X4 : DEV_X8;
                mci->csrows[i].ue_count = 0;
                mci->csrows[i].ce_count = 0;
                mci->csrows[i].mtype = MEM_RDDR2;
@@ -777,7 +878,7 @@ static void __devinit i5100_init_csrows(struct mem_ctl_info *mci)
                mci->csrows[i].channels[0].csrow = mci->csrows + i;
                snprintf(mci->csrows[i].channels[0].label,
                         sizeof(mci->csrows[i].channels[0].label),
-                        "DIMM%u", i5100_rank_to_slot(mci, cntlr, rank));
+                        "DIMM%u", i5100_rank_to_slot(mci, chan, rank));
 
                total_pages += npages;
        }
@@ -815,13 +916,6 @@ static int __devinit i5100_init_one(struct pci_dev *pdev,
        pci_read_config_dword(pdev, I5100_MS, &dw);
        ranksperch = !!(dw & (1 << 8)) * 2 + 4;
 
-       if (ranksperch != 4) {
-               /* FIXME: get 6 ranks / controller to work - need hw... */
-               printk(KERN_INFO "i5100_edac: unsupported configuration.\n");
-               ret = -ENODEV;
-               goto bail_pdev;
-       }
-
        /* enable error reporting... */
        pci_read_config_dword(pdev, I5100_EMASK_MEM, &dw);
        dw &= ~I5100_FERR_NF_MEM_ANY_MASK;
@@ -864,11 +958,21 @@ static int __devinit i5100_init_one(struct pci_dev *pdev,
        mci->dev = &pdev->dev;
 
        priv = mci->pvt_info;
-       priv->ranksperctlr = ranksperch;
+       priv->ranksperchan = ranksperch;
        priv->mc = pdev;
        priv->ch0mm = ch0mm;
        priv->ch1mm = ch1mm;
 
+       INIT_DELAYED_WORK(&(priv->i5100_scrubbing), i5100_refresh_scrubbing);
+
+       /* If scrubbing was already enabled by the bios, start maintaining it */
+       pci_read_config_dword(pdev, I5100_MC, &dw);
+       if (i5100_mc_scrben(dw)) {
+               priv->scrub_enable = 1;
+               schedule_delayed_work(&(priv->i5100_scrubbing),
+                                     I5100_SCRUB_REFRESH_RATE);
+       }
+
        i5100_init_dimm_layout(pdev, mci);
        i5100_init_interleaving(pdev, mci);
 
@@ -882,6 +986,8 @@ static int __devinit i5100_init_one(struct pci_dev *pdev,
        mci->ctl_page_to_phys = NULL;
 
        mci->edac_check = i5100_check_error;
+       mci->set_sdram_scrub_rate = i5100_set_scrub_rate;
+       mci->get_sdram_scrub_rate = i5100_get_scrub_rate;
 
        i5100_init_csrows(mci);
 
@@ -897,12 +1003,14 @@ static int __devinit i5100_init_one(struct pci_dev *pdev,
 
        if (edac_mc_add_mc(mci)) {
                ret = -ENODEV;
-               goto bail_mc;
+               goto bail_scrub;
        }
 
        return ret;
 
-bail_mc:
+bail_scrub:
+       priv->scrub_enable = 0;
+       cancel_delayed_work_sync(&(priv->i5100_scrubbing));
        edac_mc_free(mci);
 
 bail_disable_ch1:
@@ -935,6 +1043,10 @@ static void __devexit i5100_remove_one(struct pci_dev *pdev)
                return;
 
        priv = mci->pvt_info;
+
+       priv->scrub_enable = 0;
+       cancel_delayed_work_sync(&(priv->i5100_scrubbing));
+
        pci_disable_device(pdev);
        pci_disable_device(priv->ch0mm);
        pci_disable_device(priv->ch1mm);
index ebb9e51deb0cd86acb38ea5b0180d7c1b16a862a..1b03ba1d083497d5c1fe2597b2f84ad88399cc1d 100644 (file)
@@ -7,7 +7,7 @@ menu "Firmware Drivers"
 
 config EDD
        tristate "BIOS Enhanced Disk Drive calls determine boot disk"
-       depends on !IA64
+       depends on X86
        help
          Say Y or M here if you want to enable BIOS Enhanced Disk Drive
          Services real mode BIOS calls to determine which disk
@@ -28,7 +28,7 @@ config EDD_OFF
 
 config FIRMWARE_MEMMAP
     bool "Add firmware-provided memory map to sysfs" if EMBEDDED
-    default (X86_64 || X86_32)
+    default X86
     help
       Add the firmware-provided (unmodified) memory map to /sys/firmware/memmap.
       That memory map is used for example by kexec to set up parameter area
index 3a2ccb09e2f85d0cb6c9344dc92d8579e34df590..31b983d9462c7c9f5a01b87fa0a449076bd12aa1 100644 (file)
@@ -169,10 +169,7 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, int inde
        if (!s)
                return;
 
-       sprintf(s,
-               "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
-               d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
-               d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+       sprintf(s, "%pUB", d);
 
         dmi_ident[slot] = s;
 }
index 2ad0128c63c6995ab11fa7f3e2896bad968fe9f3..a019b49ecc9b0b06816d64d2c5d1e2fa2ddac08c 100644 (file)
@@ -174,6 +174,16 @@ config GPIO_ADP5520
 
 comment "PCI GPIO expanders:"
 
+config GPIO_CS5535
+       tristate "AMD CS5535/CS5536 GPIO support"
+       depends on PCI && !CS5535_GPIO
+       help
+         The AMD CS5535 and CS5536 southbridges support 28 GPIO pins that
+         can be used for quite a number of things.  The CS5535/6 is found on
+         AMD Geode and Lemote Yeeloong devices.
+
+         If unsure, say N.
+
 config GPIO_BT8XX
        tristate "BT8XX GPIO abuser"
        depends on PCI && VIDEO_BT848=n
@@ -196,6 +206,12 @@ config GPIO_LANGWELL
        help
          Say Y here to support Intel Moorestown platform GPIO.
 
+config GPIO_TIMBERDALE
+       bool "Support for timberdale GPIO IP"
+       depends on MFD_TIMBERDALE && GPIOLIB && HAS_IOMEM
+       ---help---
+       Add support for the GPIO IP in the timberdale FPGA.
+
 comment "SPI GPIO expanders:"
 
 config GPIO_MAX7301
index 00a532c9a1e294afcf6c6224d1b32e6bdda8068e..52fe4cf734c77498b3d66417eb2260b1bd1c3681 100644 (file)
@@ -13,9 +13,11 @@ obj-$(CONFIG_GPIO_MCP23S08)  += mcp23s08.o
 obj-$(CONFIG_GPIO_PCA953X)     += pca953x.o
 obj-$(CONFIG_GPIO_PCF857X)     += pcf857x.o
 obj-$(CONFIG_GPIO_PL061)       += pl061.o
+obj-$(CONFIG_GPIO_TIMBERDALE)  += timbgpio.o
 obj-$(CONFIG_GPIO_TWL4030)     += twl4030-gpio.o
 obj-$(CONFIG_GPIO_UCB1400)     += ucb1400_gpio.o
 obj-$(CONFIG_GPIO_XILINX)      += xilinx_gpio.o
+obj-$(CONFIG_GPIO_CS5535)      += cs5535-gpio.o
 obj-$(CONFIG_GPIO_BT8XX)       += bt8xxgpio.o
 obj-$(CONFIG_GPIO_VR41XX)      += vr41xx_giu.o
 obj-$(CONFIG_GPIO_WM831X)      += wm831x-gpio.o
diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c
new file mode 100644 (file)
index 0000000..0fdbe94
--- /dev/null
@@ -0,0 +1,355 @@
+/*
+ * AMD CS5535/CS5536 GPIO driver
+ * Copyright (C) 2006  Advanced Micro Devices, Inc.
+ * Copyright (C) 2007-2009  Andres Salomon <dilinger@collabora.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/gpio.h>
+#include <linux/io.h>
+#include <linux/cs5535.h>
+
+#define DRV_NAME "cs5535-gpio"
+#define GPIO_BAR 1
+
+/*
+ * Some GPIO pins
+ *  31-29,23 : reserved (always mask out)
+ *  28       : Power Button
+ *  26       : PME#
+ *  22-16    : LPC
+ *  14,15    : SMBus
+ *  9,8      : UART1
+ *  7        : PCI INTB
+ *  3,4      : UART2/DDC
+ *  2        : IDE_IRQ0
+ *  1        : AC_BEEP
+ *  0        : PCI INTA
+ *
+ * If a mask was not specified, allow all except
+ * reserved and Power Button
+ */
+#define GPIO_DEFAULT_MASK 0x0F7FFFFF
+
+static ulong mask = GPIO_DEFAULT_MASK;
+module_param_named(mask, mask, ulong, 0444);
+MODULE_PARM_DESC(mask, "GPIO channel mask.");
+
+static struct cs5535_gpio_chip {
+       struct gpio_chip chip;
+       resource_size_t base;
+
+       struct pci_dev *pdev;
+       spinlock_t lock;
+} cs5535_gpio_chip;
+
+/*
+ * The CS5535/CS5536 GPIOs support a number of extra features not defined
+ * by the gpio_chip API, so these are exported.  For a full list of the
+ * registers, see include/linux/cs5535.h.
+ */
+
+static void __cs5535_gpio_set(struct cs5535_gpio_chip *chip, unsigned offset,
+               unsigned int reg)
+{
+       if (offset < 16)
+               /* low bank register */
+               outl(1 << offset, chip->base + reg);
+       else
+               /* high bank register */
+               outl(1 << (offset - 16), chip->base + 0x80 + reg);
+}
+
+void cs5535_gpio_set(unsigned offset, unsigned int reg)
+{
+       struct cs5535_gpio_chip *chip = &cs5535_gpio_chip;
+       unsigned long flags;
+
+       spin_lock_irqsave(&chip->lock, flags);
+       __cs5535_gpio_set(chip, offset, reg);
+       spin_unlock_irqrestore(&chip->lock, flags);
+}
+EXPORT_SYMBOL_GPL(cs5535_gpio_set);
+
+static void __cs5535_gpio_clear(struct cs5535_gpio_chip *chip, unsigned offset,
+               unsigned int reg)
+{
+       if (offset < 16)
+               /* low bank register */
+               outl(1 << (offset + 16), chip->base + reg);
+       else
+               /* high bank register */
+               outl(1 << offset, chip->base + 0x80 + reg);
+}
+
+void cs5535_gpio_clear(unsigned offset, unsigned int reg)
+{
+       struct cs5535_gpio_chip *chip = &cs5535_gpio_chip;
+       unsigned long flags;
+
+       spin_lock_irqsave(&chip->lock, flags);
+       __cs5535_gpio_clear(chip, offset, reg);
+       spin_unlock_irqrestore(&chip->lock, flags);
+}
+EXPORT_SYMBOL_GPL(cs5535_gpio_clear);
+
+int cs5535_gpio_isset(unsigned offset, unsigned int reg)
+{
+       struct cs5535_gpio_chip *chip = &cs5535_gpio_chip;
+       unsigned long flags;
+       long val;
+
+       spin_lock_irqsave(&chip->lock, flags);
+       if (offset < 16)
+               /* low bank register */
+               val = inl(chip->base + reg);
+       else {
+               /* high bank register */
+               val = inl(chip->base + 0x80 + reg);
+               offset -= 16;
+       }
+       spin_unlock_irqrestore(&chip->lock, flags);
+
+       return (val & (1 << offset)) ? 1 : 0;
+}
+EXPORT_SYMBOL_GPL(cs5535_gpio_isset);
+
+/*
+ * Generic gpio_chip API support.
+ */
+
+static int chip_gpio_request(struct gpio_chip *c, unsigned offset)
+{
+       struct cs5535_gpio_chip *chip = (struct cs5535_gpio_chip *) c;
+       unsigned long flags;
+
+       spin_lock_irqsave(&chip->lock, flags);
+
+       /* check if this pin is available */
+       if ((mask & (1 << offset)) == 0) {
+               dev_info(&chip->pdev->dev,
+                       "pin %u is not available (check mask)\n", offset);
+               spin_unlock_irqrestore(&chip->lock, flags);
+               return -EINVAL;
+       }
+
+       /* disable output aux 1 & 2 on this pin */
+       __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_AUX1);
+       __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_AUX2);
+
+       /* disable input aux 1 on this pin */
+       __cs5535_gpio_clear(chip, offset, GPIO_INPUT_AUX1);
+
+       spin_unlock_irqrestore(&chip->lock, flags);
+
+       return 0;
+}
+
+static int chip_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+       return cs5535_gpio_isset(offset, GPIO_OUTPUT_VAL);
+}
+
+static void chip_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
+{
+       if (val)
+               cs5535_gpio_set(offset, GPIO_OUTPUT_VAL);
+       else
+               cs5535_gpio_clear(offset, GPIO_OUTPUT_VAL);
+}
+
+static int chip_direction_input(struct gpio_chip *c, unsigned offset)
+{
+       struct cs5535_gpio_chip *chip = (struct cs5535_gpio_chip *) c;
+       unsigned long flags;
+
+       spin_lock_irqsave(&chip->lock, flags);
+       __cs5535_gpio_set(chip, offset, GPIO_INPUT_ENABLE);
+       spin_unlock_irqrestore(&chip->lock, flags);
+
+       return 0;
+}
+
+static int chip_direction_output(struct gpio_chip *c, unsigned offset, int val)
+{
+       struct cs5535_gpio_chip *chip = (struct cs5535_gpio_chip *) c;
+       unsigned long flags;
+
+       spin_lock_irqsave(&chip->lock, flags);
+
+       __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_ENABLE);
+       if (val)
+               __cs5535_gpio_set(chip, offset, GPIO_OUTPUT_VAL);
+       else
+               __cs5535_gpio_clear(chip, offset, GPIO_OUTPUT_VAL);
+
+       spin_unlock_irqrestore(&chip->lock, flags);
+
+       return 0;
+}
+
+static char *cs5535_gpio_names[] = {
+       "GPIO0", "GPIO1", "GPIO2", "GPIO3",
+       "GPIO4", "GPIO5", "GPIO6", "GPIO7",
+       "GPIO8", "GPIO9", "GPIO10", "GPIO11",
+       "GPIO12", "GPIO13", "GPIO14", "GPIO15",
+       "GPIO16", "GPIO17", "GPIO18", "GPIO19",
+       "GPIO20", "GPIO21", "GPIO22", NULL,
+       "GPIO24", "GPIO25", "GPIO26", "GPIO27",
+       "GPIO28", NULL, NULL, NULL,
+};
+
+static struct cs5535_gpio_chip cs5535_gpio_chip = {
+       .chip = {
+               .owner = THIS_MODULE,
+               .label = DRV_NAME,
+
+               .base = 0,
+               .ngpio = 32,
+               .names = cs5535_gpio_names,
+               .request = chip_gpio_request,
+
+               .get = chip_gpio_get,
+               .set = chip_gpio_set,
+
+               .direction_input = chip_direction_input,
+               .direction_output = chip_direction_output,
+       },
+};
+
+static int __init cs5535_gpio_probe(struct pci_dev *pdev,
+               const struct pci_device_id *pci_id)
+{
+       int err;
+       ulong mask_orig = mask;
+
+       /* There are two ways to get the GPIO base address; one is by
+        * fetching it from MSR_LBAR_GPIO, the other is by reading the
+        * PCI BAR info.  The latter method is easier (especially across
+        * different architectures), so we'll stick with that for now.  If
+        * it turns out to be unreliable in the face of crappy BIOSes, we
+        * can always go back to using MSRs.. */
+
+       err = pci_enable_device_io(pdev);
+       if (err) {
+               dev_err(&pdev->dev, "can't enable device IO\n");
+               goto done;
+       }
+
+       err = pci_request_region(pdev, GPIO_BAR, DRV_NAME);
+       if (err) {
+               dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", GPIO_BAR);
+               goto done;
+       }
+
+       /* set up the driver-specific struct */
+       cs5535_gpio_chip.base = pci_resource_start(pdev, GPIO_BAR);
+       cs5535_gpio_chip.pdev = pdev;
+       spin_lock_init(&cs5535_gpio_chip.lock);
+
+       dev_info(&pdev->dev, "allocated PCI BAR #%d: base 0x%llx\n", GPIO_BAR,
+                       (unsigned long long) cs5535_gpio_chip.base);
+
+       /* mask out reserved pins */
+       mask &= 0x1F7FFFFF;
+
+       /* do not allow pin 28, Power Button, as there's special handling
+        * in the PMC needed. (note 12, p. 48) */
+       mask &= ~(1 << 28);
+
+       if (mask_orig != mask)
+               dev_info(&pdev->dev, "mask changed from 0x%08lX to 0x%08lX\n",
+                               mask_orig, mask);
+
+       /* finally, register with the generic GPIO API */
+       err = gpiochip_add(&cs5535_gpio_chip.chip);
+       if (err)
+               goto release_region;
+
+       dev_info(&pdev->dev, DRV_NAME ": GPIO support successfully loaded.\n");
+       return 0;
+
+release_region:
+       pci_release_region(pdev, GPIO_BAR);
+done:
+       return err;
+}
+
+static void __exit cs5535_gpio_remove(struct pci_dev *pdev)
+{
+       int err;
+
+       err = gpiochip_remove(&cs5535_gpio_chip.chip);
+       if (err) {
+               /* uhh? */
+               dev_err(&pdev->dev, "unable to remove gpio_chip?\n");
+       }
+       pci_release_region(pdev, GPIO_BAR);
+}
+
+static struct pci_device_id cs5535_gpio_pci_tbl[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) },
+       { 0, },
+};
+MODULE_DEVICE_TABLE(pci, cs5535_gpio_pci_tbl);
+
+/*
+ * We can't use the standard PCI driver registration stuff here, since
+ * that allows only one driver to bind to each PCI device (and we want
+ * multiple drivers to be able to bind to the device).  Instead, manually
+ * scan for the PCI device, request a single region, and keep track of the
+ * devices that we're using.
+ */
+
+static int __init cs5535_gpio_scan_pci(void)
+{
+       struct pci_dev *pdev;
+       int err = -ENODEV;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(cs5535_gpio_pci_tbl); i++) {
+               pdev = pci_get_device(cs5535_gpio_pci_tbl[i].vendor,
+                               cs5535_gpio_pci_tbl[i].device, NULL);
+               if (pdev) {
+                       err = cs5535_gpio_probe(pdev, &cs5535_gpio_pci_tbl[i]);
+                       if (err)
+                               pci_dev_put(pdev);
+
+                       /* we only support a single CS5535/6 southbridge */
+                       break;
+               }
+       }
+
+       return err;
+}
+
+static void __exit cs5535_gpio_free_pci(void)
+{
+       cs5535_gpio_remove(cs5535_gpio_chip.pdev);
+       pci_dev_put(cs5535_gpio_chip.pdev);
+}
+
+static int __init cs5535_gpio_init(void)
+{
+       return cs5535_gpio_scan_pci();
+}
+
+static void __exit cs5535_gpio_exit(void)
+{
+       cs5535_gpio_free_pci();
+}
+
+module_init(cs5535_gpio_init);
+module_exit(cs5535_gpio_exit);
+
+MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>");
+MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO driver");
+MODULE_LICENSE("GPL");
index 50de0f5750d8b4f5e76c853fe590f08fe52c1a22..a25ad284a272799d2b4f91634fa8d985e41a885c 100644 (file)
@@ -53,6 +53,7 @@ struct gpio_desc {
 #define FLAG_SYSFS     4       /* exported via /sys/class/gpio/control */
 #define FLAG_TRIG_FALL 5       /* trigger on falling edge */
 #define FLAG_TRIG_RISE 6       /* trigger on rising edge */
+#define FLAG_ACTIVE_LOW        7       /* sysfs value has active low */
 
 #define PDESC_ID_SHIFT 16      /* add new flags before this one */
 
@@ -210,6 +211,11 @@ static DEFINE_MUTEX(sysfs_lock);
  *      * configures behavior of poll(2) on /value
  *      * available only if pin can generate IRQs on input
  *      * is read/write as "none", "falling", "rising", or "both"
+ *   /active_low
+ *      * configures polarity of /value
+ *      * is read/write as zero/nonzero
+ *      * also affects existing and subsequent "falling" and "rising"
+ *        /edge configuration
  */
 
 static ssize_t gpio_direction_show(struct device *dev,
@@ -255,7 +261,7 @@ static ssize_t gpio_direction_store(struct device *dev,
        return status ? : size;
 }
 
-static const DEVICE_ATTR(direction, 0644,
+static /* const */ DEVICE_ATTR(direction, 0644,
                gpio_direction_show, gpio_direction_store);
 
 static ssize_t gpio_value_show(struct device *dev,
@@ -267,10 +273,17 @@ static ssize_t gpio_value_show(struct device *dev,
 
        mutex_lock(&sysfs_lock);
 
-       if (!test_bit(FLAG_EXPORT, &desc->flags))
+       if (!test_bit(FLAG_EXPORT, &desc->flags)) {
                status = -EIO;
-       else
-               status = sprintf(buf, "%d\n", !!gpio_get_value_cansleep(gpio));
+       } else {
+               int value;
+
+               value = !!gpio_get_value_cansleep(gpio);
+               if (test_bit(FLAG_ACTIVE_LOW, &desc->flags))
+                       value = !value;
+
+               status = sprintf(buf, "%d\n", value);
+       }
 
        mutex_unlock(&sysfs_lock);
        return status;
@@ -294,6 +307,8 @@ static ssize_t gpio_value_store(struct device *dev,
 
                status = strict_strtol(buf, 0, &value);
                if (status == 0) {
+                       if (test_bit(FLAG_ACTIVE_LOW, &desc->flags))
+                               value = !value;
                        gpio_set_value_cansleep(gpio, value != 0);
                        status = size;
                }
@@ -303,7 +318,7 @@ static ssize_t gpio_value_store(struct device *dev,
        return status;
 }
 
-static /*const*/ DEVICE_ATTR(value, 0644,
+static const DEVICE_ATTR(value, 0644,
                gpio_value_show, gpio_value_store);
 
 static irqreturn_t gpio_sysfs_irq(int irq, void *priv)
@@ -352,9 +367,11 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
 
        irq_flags = IRQF_SHARED;
        if (test_bit(FLAG_TRIG_FALL, &gpio_flags))
-               irq_flags |= IRQF_TRIGGER_FALLING;
+               irq_flags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ?
+                       IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
        if (test_bit(FLAG_TRIG_RISE, &gpio_flags))
-               irq_flags |= IRQF_TRIGGER_RISING;
+               irq_flags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ?
+                       IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
 
        if (!pdesc) {
                pdesc = kmalloc(sizeof(*pdesc), GFP_KERNEL);
@@ -475,9 +492,79 @@ found:
 
 static DEVICE_ATTR(edge, 0644, gpio_edge_show, gpio_edge_store);
 
+static int sysfs_set_active_low(struct gpio_desc *desc, struct device *dev,
+                               int value)
+{
+       int                     status = 0;
+
+       if (!!test_bit(FLAG_ACTIVE_LOW, &desc->flags) == !!value)
+               return 0;
+
+       if (value)
+               set_bit(FLAG_ACTIVE_LOW, &desc->flags);
+       else
+               clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
+
+       /* reconfigure poll(2) support if enabled on one edge only */
+       if (dev != NULL && (!!test_bit(FLAG_TRIG_RISE, &desc->flags) ^
+                               !!test_bit(FLAG_TRIG_FALL, &desc->flags))) {
+               unsigned long trigger_flags = desc->flags & GPIO_TRIGGER_MASK;
+
+               gpio_setup_irq(desc, dev, 0);
+               status = gpio_setup_irq(desc, dev, trigger_flags);
+       }
+
+       return status;
+}
+
+static ssize_t gpio_active_low_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       const struct gpio_desc  *desc = dev_get_drvdata(dev);
+       ssize_t                 status;
+
+       mutex_lock(&sysfs_lock);
+
+       if (!test_bit(FLAG_EXPORT, &desc->flags))
+               status = -EIO;
+       else
+               status = sprintf(buf, "%d\n",
+                               !!test_bit(FLAG_ACTIVE_LOW, &desc->flags));
+
+       mutex_unlock(&sysfs_lock);
+
+       return status;
+}
+
+static ssize_t gpio_active_low_store(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t size)
+{
+       struct gpio_desc        *desc = dev_get_drvdata(dev);
+       ssize_t                 status;
+
+       mutex_lock(&sysfs_lock);
+
+       if (!test_bit(FLAG_EXPORT, &desc->flags)) {
+               status = -EIO;
+       } else {
+               long            value;
+
+               status = strict_strtol(buf, 0, &value);
+               if (status == 0)
+                       status = sysfs_set_active_low(desc, dev, value != 0);
+       }
+
+       mutex_unlock(&sysfs_lock);
+
+       return status ? : size;
+}
+
+static const DEVICE_ATTR(active_low, 0644,
+               gpio_active_low_show, gpio_active_low_store);
+
 static const struct attribute *gpio_attrs[] = {
-       &dev_attr_direction.attr,
        &dev_attr_value.attr,
+       &dev_attr_active_low.attr,
        NULL,
 };
 
@@ -662,12 +749,12 @@ int gpio_export(unsigned gpio, bool direction_may_change)
                dev = device_create(&gpio_class, desc->chip->dev, MKDEV(0, 0),
                                desc, ioname ? ioname : "gpio%d", gpio);
                if (!IS_ERR(dev)) {
-                       if (direction_may_change)
-                               status = sysfs_create_group(&dev->kobj,
+                       status = sysfs_create_group(&dev->kobj,
                                                &gpio_attr_group);
-                       else
+
+                       if (!status && direction_may_change)
                                status = device_create_file(dev,
-                                               &dev_attr_value);
+                                               &dev_attr_direction);
 
                        if (!status && gpio_to_irq(gpio) >= 0
                                        && (direction_may_change
@@ -744,6 +831,55 @@ done:
 }
 EXPORT_SYMBOL_GPL(gpio_export_link);
 
+
+/**
+ * gpio_sysfs_set_active_low - set the polarity of gpio sysfs value
+ * @gpio: gpio to change
+ * @value: non-zero to use active low, i.e. inverted values
+ *
+ * Set the polarity of /sys/class/gpio/gpioN/value sysfs attribute.
+ * The GPIO does not have to be exported yet.  If poll(2) support has
+ * been enabled for either rising or falling edge, it will be
+ * reconfigured to follow the new polarity.
+ *
+ * Returns zero on success, else an error.
+ */
+int gpio_sysfs_set_active_low(unsigned gpio, int value)
+{
+       struct gpio_desc        *desc;
+       struct device           *dev = NULL;
+       int                     status = -EINVAL;
+
+       if (!gpio_is_valid(gpio))
+               goto done;
+
+       mutex_lock(&sysfs_lock);
+
+       desc = &gpio_desc[gpio];
+
+       if (test_bit(FLAG_EXPORT, &desc->flags)) {
+               struct device *dev;
+
+               dev = class_find_device(&gpio_class, NULL, desc, match_export);
+               if (dev == NULL) {
+                       status = -ENODEV;
+                       goto unlock;
+               }
+       }
+
+       status = sysfs_set_active_low(desc, dev, value);
+
+unlock:
+       mutex_unlock(&sysfs_lock);
+
+done:
+       if (status)
+               pr_debug("%s: gpio%d status %d\n", __func__, gpio, status);
+
+       return status;
+}
+EXPORT_SYMBOL_GPL(gpio_sysfs_set_active_low);
+
 /**
  * gpio_unexport - reverse effect of gpio_export()
  * @gpio: gpio to make unavailable
@@ -1094,6 +1230,7 @@ void gpio_free(unsigned gpio)
                }
                desc_set_label(desc, NULL);
                module_put(desc->chip->owner);
+               clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
                clear_bit(FLAG_REQUESTED, &desc->flags);
        } else
                WARN_ON(extra_checks);
index 4baf3d7d0f8e6e4f1f7887625b7f73a62dba1a83..6c0ebbdc659ee3bdba7fa17256b74462c4858ff2 100644 (file)
@@ -123,7 +123,7 @@ static int lnw_irq_type(unsigned irq, unsigned type)
        void __iomem *grer = (void __iomem *)(&lnw->reg_base->GRER[reg]);
        void __iomem *gfer = (void __iomem *)(&lnw->reg_base->GFER[reg]);
 
-       if (gpio < 0 || gpio > lnw->chip.ngpio)
+       if (gpio >= lnw->chip.ngpio)
                return -EINVAL;
        spin_lock_irqsave(&lnw->lock, flags);
        if (type & IRQ_TYPE_EDGE_RISING)
diff --git a/drivers/gpio/timbgpio.c b/drivers/gpio/timbgpio.c
new file mode 100644 (file)
index 0000000..a4d344b
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * timbgpio.c timberdale FPGA GPIO driver
+ * Copyright (c) 2009 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* Supports:
+ * Timberdale FPGA GPIO
+ */
+
+#include <linux/module.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/timb_gpio.h>
+#include <linux/interrupt.h>
+
+#define DRIVER_NAME "timb-gpio"
+
+#define TGPIOVAL       0x00
+#define TGPIODIR       0x04
+#define TGPIO_IER      0x08
+#define TGPIO_ISR      0x0c
+#define TGPIO_IPR      0x10
+#define TGPIO_ICR      0x14
+#define TGPIO_FLR      0x18
+#define TGPIO_LVR      0x1c
+
+struct timbgpio {
+       void __iomem            *membase;
+       spinlock_t              lock; /* mutual exclusion */
+       struct gpio_chip        gpio;
+       int                     irq_base;
+};
+
+static int timbgpio_update_bit(struct gpio_chip *gpio, unsigned index,
+       unsigned offset, bool enabled)
+{
+       struct timbgpio *tgpio = container_of(gpio, struct timbgpio, gpio);
+       u32 reg;
+
+       spin_lock(&tgpio->lock);
+       reg = ioread32(tgpio->membase + offset);
+
+       if (enabled)
+               reg |= (1 << index);
+       else
+               reg &= ~(1 << index);
+
+       iowrite32(reg, tgpio->membase + offset);
+       spin_unlock(&tgpio->lock);
+
+       return 0;
+}
+
+static int timbgpio_gpio_direction_input(struct gpio_chip *gpio, unsigned nr)
+{
+       return timbgpio_update_bit(gpio, nr, TGPIODIR, true);
+}
+
+static int timbgpio_gpio_get(struct gpio_chip *gpio, unsigned nr)
+{
+       struct timbgpio *tgpio = container_of(gpio, struct timbgpio, gpio);
+       u32 value;
+
+       value = ioread32(tgpio->membase + TGPIOVAL);
+       return (value & (1 << nr)) ? 1 : 0;
+}
+
+static int timbgpio_gpio_direction_output(struct gpio_chip *gpio,
+                                               unsigned nr, int val)
+{
+       return timbgpio_update_bit(gpio, nr, TGPIODIR, false);
+}
+
+static void timbgpio_gpio_set(struct gpio_chip *gpio,
+                               unsigned nr, int val)
+{
+       timbgpio_update_bit(gpio, nr, TGPIOVAL, val != 0);
+}
+
+static int timbgpio_to_irq(struct gpio_chip *gpio, unsigned offset)
+{
+       struct timbgpio *tgpio = container_of(gpio, struct timbgpio, gpio);
+
+       if (tgpio->irq_base <= 0)
+               return -EINVAL;
+
+       return tgpio->irq_base + offset;
+}
+
+/*
+ * GPIO IRQ
+ */
+static void timbgpio_irq_disable(unsigned irq)
+{
+       struct timbgpio *tgpio = get_irq_chip_data(irq);
+       int offset = irq - tgpio->irq_base;
+
+       timbgpio_update_bit(&tgpio->gpio, offset, TGPIO_IER, 0);
+}
+
+static void timbgpio_irq_enable(unsigned irq)
+{
+       struct timbgpio *tgpio = get_irq_chip_data(irq);
+       int offset = irq - tgpio->irq_base;
+
+       timbgpio_update_bit(&tgpio->gpio, offset, TGPIO_IER, 1);
+}
+
+static int timbgpio_irq_type(unsigned irq, unsigned trigger)
+{
+       struct timbgpio *tgpio = get_irq_chip_data(irq);
+       int offset = irq - tgpio->irq_base;
+       unsigned long flags;
+       u32 lvr, flr;
+
+       if (offset < 0 || offset > tgpio->gpio.ngpio)
+               return -EINVAL;
+
+       spin_lock_irqsave(&tgpio->lock, flags);
+
+       lvr = ioread32(tgpio->membase + TGPIO_LVR);
+       flr = ioread32(tgpio->membase + TGPIO_FLR);
+
+       if (trigger & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) {
+               flr &= ~(1 << offset);
+               if (trigger & IRQ_TYPE_LEVEL_HIGH)
+                       lvr |= 1 << offset;
+               else
+                       lvr &= ~(1 << offset);
+       }
+
+       if ((trigger & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH)
+               return -EINVAL;
+       else {
+               flr |= 1 << offset;
+               /* opposite compared to the datasheet, but it mirrors the
+                * reality
+                */
+               if (trigger & IRQ_TYPE_EDGE_FALLING)
+                       lvr |= 1 << offset;
+               else
+                       lvr &= ~(1 << offset);
+       }
+
+       iowrite32(lvr, tgpio->membase + TGPIO_LVR);
+       iowrite32(flr, tgpio->membase + TGPIO_FLR);
+       iowrite32(1 << offset, tgpio->membase + TGPIO_ICR);
+       spin_unlock_irqrestore(&tgpio->lock, flags);
+
+       return 0;
+}
+
+static void timbgpio_irq(unsigned int irq, struct irq_desc *desc)
+{
+       struct timbgpio *tgpio = get_irq_data(irq);
+       unsigned long ipr;
+       int offset;
+
+       desc->chip->ack(irq);
+       ipr = ioread32(tgpio->membase + TGPIO_IPR);
+       iowrite32(ipr, tgpio->membase + TGPIO_ICR);
+
+       for_each_bit(offset, &ipr, tgpio->gpio.ngpio)
+               generic_handle_irq(timbgpio_to_irq(&tgpio->gpio, offset));
+}
+
+static struct irq_chip timbgpio_irqchip = {
+       .name           = "GPIO",
+       .enable         = timbgpio_irq_enable,
+       .disable        = timbgpio_irq_disable,
+       .set_type       = timbgpio_irq_type,
+};
+
+static int __devinit timbgpio_probe(struct platform_device *pdev)
+{
+       int err, i;
+       struct gpio_chip *gc;
+       struct timbgpio *tgpio;
+       struct resource *iomem;
+       struct timbgpio_platform_data *pdata = pdev->dev.platform_data;
+       int irq = platform_get_irq(pdev, 0);
+
+       if (!pdata || pdata->nr_pins > 32) {
+               err = -EINVAL;
+               goto err_mem;
+       }
+
+       iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!iomem) {
+               err = -EINVAL;
+               goto err_mem;
+       }
+
+       tgpio = kzalloc(sizeof(*tgpio), GFP_KERNEL);
+       if (!tgpio) {
+               err = -EINVAL;
+               goto err_mem;
+       }
+       tgpio->irq_base = pdata->irq_base;
+
+       spin_lock_init(&tgpio->lock);
+
+       if (!request_mem_region(iomem->start, resource_size(iomem),
+               DRIVER_NAME)) {
+               err = -EBUSY;
+               goto err_request;
+       }
+
+       tgpio->membase = ioremap(iomem->start, resource_size(iomem));
+       if (!tgpio->membase) {
+               err = -ENOMEM;
+               goto err_ioremap;
+       }
+
+       gc = &tgpio->gpio;
+
+       gc->label = dev_name(&pdev->dev);
+       gc->owner = THIS_MODULE;
+       gc->dev = &pdev->dev;
+       gc->direction_input = timbgpio_gpio_direction_input;
+       gc->get = timbgpio_gpio_get;
+       gc->direction_output = timbgpio_gpio_direction_output;
+       gc->set = timbgpio_gpio_set;
+       gc->to_irq = (irq >= 0 && tgpio->irq_base > 0) ? timbgpio_to_irq : NULL;
+       gc->dbg_show = NULL;
+       gc->base = pdata->gpio_base;
+       gc->ngpio = pdata->nr_pins;
+       gc->can_sleep = 0;
+
+       err = gpiochip_add(gc);
+       if (err)
+               goto err_chipadd;
+
+       platform_set_drvdata(pdev, tgpio);
+
+       /* make sure to disable interrupts */
+       iowrite32(0x0, tgpio->membase + TGPIO_IER);
+
+       if (irq < 0 || tgpio->irq_base <= 0)
+               return 0;
+
+       for (i = 0; i < pdata->nr_pins; i++) {
+               set_irq_chip_and_handler_name(tgpio->irq_base + i,
+                       &timbgpio_irqchip, handle_simple_irq, "mux");
+               set_irq_chip_data(tgpio->irq_base + i, tgpio);
+#ifdef CONFIG_ARM
+               set_irq_flags(tgpio->irq_base + i, IRQF_VALID | IRQF_PROBE);
+#endif
+       }
+
+       set_irq_data(irq, tgpio);
+       set_irq_chained_handler(irq, timbgpio_irq);
+
+       return 0;
+
+err_chipadd:
+       iounmap(tgpio->membase);
+err_ioremap:
+       release_mem_region(iomem->start, resource_size(iomem));
+err_request:
+       kfree(tgpio);
+err_mem:
+       printk(KERN_ERR DRIVER_NAME": Failed to register GPIOs: %d\n", err);
+
+       return err;
+}
+
+static int __devexit timbgpio_remove(struct platform_device *pdev)
+{
+       int err;
+       struct timbgpio_platform_data *pdata = pdev->dev.platform_data;
+       struct timbgpio *tgpio = platform_get_drvdata(pdev);
+       struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       int irq = platform_get_irq(pdev, 0);
+
+       if (irq >= 0 && tgpio->irq_base > 0) {
+               int i;
+               for (i = 0; i < pdata->nr_pins; i++) {
+                       set_irq_chip(tgpio->irq_base + i, NULL);
+                       set_irq_chip_data(tgpio->irq_base + i, NULL);
+               }
+
+               set_irq_handler(irq, NULL);
+               set_irq_data(irq, NULL);
+       }
+
+       err = gpiochip_remove(&tgpio->gpio);
+       if (err)
+               printk(KERN_ERR DRIVER_NAME": failed to remove gpio_chip\n");
+
+       iounmap(tgpio->membase);
+       release_mem_region(iomem->start, resource_size(iomem));
+       kfree(tgpio);
+
+       platform_set_drvdata(pdev, NULL);
+
+       return 0;
+}
+
+static struct platform_driver timbgpio_platform_driver = {
+       .driver = {
+               .name   = DRIVER_NAME,
+               .owner  = THIS_MODULE,
+       },
+       .probe          = timbgpio_probe,
+       .remove         = timbgpio_remove,
+};
+
+/*--------------------------------------------------------------------------*/
+
+static int __init timbgpio_init(void)
+{
+       return platform_driver_register(&timbgpio_platform_driver);
+}
+
+static void __exit timbgpio_exit(void)
+{
+       platform_driver_unregister(&timbgpio_platform_driver);
+}
+
+module_init(timbgpio_init);
+module_exit(timbgpio_exit);
+
+MODULE_DESCRIPTION("Timberdale GPIO driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Mocean Laboratories");
+MODULE_ALIAS("platform:"DRIVER_NAME);
+
index 470ef6779db33d11e2bcbc60610f8671c34d10ef..39c5aa75b8f119eb6cc3263e44bc592ef25b9f30 100644 (file)
@@ -30,6 +30,7 @@ obj-$(CONFIG_DRM_I830)        += i830/
 obj-$(CONFIG_DRM_I915)  += i915/
 obj-$(CONFIG_DRM_SIS)   += sis/
 obj-$(CONFIG_DRM_SAVAGE)+= savage/
+obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
 obj-$(CONFIG_DRM_VIA)  +=via/
 obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
 obj-y                  += i2c/
index ff2f1042cb44f96c39ecc260e51f3eeff4126fea..766c46875a2047bae1001a52c6ff9cb9a90d8341 100644 (file)
@@ -434,11 +434,11 @@ static int drm_version(struct drm_device *dev, void *data,
  * Looks up the ioctl function in the ::ioctls table, checking for root
  * previleges if so required, and dispatches to the respective function.
  */
-int drm_ioctl(struct inode *inode, struct file *filp,
+long drm_ioctl(struct file *filp,
              unsigned int cmd, unsigned long arg)
 {
        struct drm_file *file_priv = filp->private_data;
-       struct drm_device *dev = file_priv->minor->dev;
+       struct drm_device *dev;
        struct drm_ioctl_desc *ioctl;
        drm_ioctl_t *func;
        unsigned int nr = DRM_IOCTL_NR(cmd);
@@ -446,6 +446,7 @@ int drm_ioctl(struct inode *inode, struct file *filp,
        char stack_kdata[128];
        char *kdata = NULL;
 
+       dev = file_priv->minor->dev;
        atomic_inc(&dev->ioctl_count);
        atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
        ++file_priv->ioctl_count;
@@ -501,7 +502,13 @@ int drm_ioctl(struct inode *inode, struct file *filp,
                                goto err_i1;
                        }
                }
-               retcode = func(dev, kdata, file_priv);
+               if (ioctl->flags & DRM_UNLOCKED)
+                       retcode = func(dev, kdata, file_priv);
+               else {
+                       lock_kernel();
+                       retcode = func(dev, kdata, file_priv);
+                       unlock_kernel();
+               }
 
                if (cmd & IOC_OUT) {
                        if (copy_to_user((void __user *)arg, kdata,
index c39b26f1abed050aed19d27407d1890035bd17d9..5c9f79877cbf0a361111d2d16cccb6aee7b4483a 100644 (file)
@@ -913,7 +913,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
        const int rates[] = { 60, 85, 75, 60, 50 };
 
        for (i = 0; i < 4; i++) {
-               int width, height;
+               int uninitialized_var(width), height;
                cvt = &(timing->data.other_data.data.cvt[i]);
 
                height = (cvt->code[0] + ((cvt->code[1] & 0xf0) << 8) + 1) * 2;
index 282d9fdf9f4efadce5ac77a59e34f1aa71d071fb..d61d185cf040499232d508d4daa66e2f85113fdf 100644 (file)
@@ -104,7 +104,7 @@ static int compat_drm_version(struct file *file, unsigned int cmd,
                          &version->desc))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
+       err = drm_ioctl(file,
                        DRM_IOCTL_VERSION, (unsigned long)version);
        if (err)
                return err;
@@ -145,8 +145,7 @@ static int compat_drm_getunique(struct file *file, unsigned int cmd,
                          &u->unique))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_GET_UNIQUE, (unsigned long)u);
+       err = drm_ioctl(file, DRM_IOCTL_GET_UNIQUE, (unsigned long)u);
        if (err)
                return err;
 
@@ -174,8 +173,7 @@ static int compat_drm_setunique(struct file *file, unsigned int cmd,
                          &u->unique))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_SET_UNIQUE, (unsigned long)u);
+       return drm_ioctl(file, DRM_IOCTL_SET_UNIQUE, (unsigned long)u);
 }
 
 typedef struct drm_map32 {
@@ -205,8 +203,7 @@ static int compat_drm_getmap(struct file *file, unsigned int cmd,
        if (__put_user(idx, &map->offset))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_GET_MAP, (unsigned long)map);
+       err = drm_ioctl(file, DRM_IOCTL_GET_MAP, (unsigned long)map);
        if (err)
                return err;
 
@@ -246,8 +243,7 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd,
            || __put_user(m32.flags, &map->flags))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_ADD_MAP, (unsigned long)map);
+       err = drm_ioctl(file, DRM_IOCTL_ADD_MAP, (unsigned long)map);
        if (err)
                return err;
 
@@ -284,8 +280,7 @@ static int compat_drm_rmmap(struct file *file, unsigned int cmd,
        if (__put_user((void *)(unsigned long)handle, &map->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RM_MAP, (unsigned long)map);
+       return drm_ioctl(file, DRM_IOCTL_RM_MAP, (unsigned long)map);
 }
 
 typedef struct drm_client32 {
@@ -314,8 +309,7 @@ static int compat_drm_getclient(struct file *file, unsigned int cmd,
        if (__put_user(idx, &client->idx))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_GET_CLIENT, (unsigned long)client);
+       err = drm_ioctl(file, DRM_IOCTL_GET_CLIENT, (unsigned long)client);
        if (err)
                return err;
 
@@ -351,8 +345,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
        if (!access_ok(VERIFY_WRITE, stats, sizeof(*stats)))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_GET_STATS, (unsigned long)stats);
+       err = drm_ioctl(file, DRM_IOCTL_GET_STATS, (unsigned long)stats);
        if (err)
                return err;
 
@@ -395,8 +388,7 @@ static int compat_drm_addbufs(struct file *file, unsigned int cmd,
            || __put_user(agp_start, &buf->agp_start))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_ADD_BUFS, (unsigned long)buf);
+       err = drm_ioctl(file, DRM_IOCTL_ADD_BUFS, (unsigned long)buf);
        if (err)
                return err;
 
@@ -427,8 +419,7 @@ static int compat_drm_markbufs(struct file *file, unsigned int cmd,
            || __put_user(b32.high_mark, &buf->high_mark))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_MARK_BUFS, (unsigned long)buf);
+       return drm_ioctl(file, DRM_IOCTL_MARK_BUFS, (unsigned long)buf);
 }
 
 typedef struct drm_buf_info32 {
@@ -469,8 +460,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
            || __put_user(list, &request->list))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_INFO_BUFS, (unsigned long)request);
+       err = drm_ioctl(file, DRM_IOCTL_INFO_BUFS, (unsigned long)request);
        if (err)
                return err;
 
@@ -531,8 +521,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
            || __put_user(list, &request->list))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_MAP_BUFS, (unsigned long)request);
+       err = drm_ioctl(file, DRM_IOCTL_MAP_BUFS, (unsigned long)request);
        if (err)
                return err;
 
@@ -578,8 +567,7 @@ static int compat_drm_freebufs(struct file *file, unsigned int cmd,
                          &request->list))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_FREE_BUFS, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_FREE_BUFS, (unsigned long)request);
 }
 
 typedef struct drm_ctx_priv_map32 {
@@ -605,8 +593,7 @@ static int compat_drm_setsareactx(struct file *file, unsigned int cmd,
                          &request->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_SET_SAREA_CTX, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_SET_SAREA_CTX, (unsigned long)request);
 }
 
 static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
@@ -628,8 +615,7 @@ static int compat_drm_getsareactx(struct file *file, unsigned int cmd,
        if (__put_user(ctx_id, &request->ctx_id))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_GET_SAREA_CTX, (unsigned long)request);
+       err = drm_ioctl(file, DRM_IOCTL_GET_SAREA_CTX, (unsigned long)request);
        if (err)
                return err;
 
@@ -664,8 +650,7 @@ static int compat_drm_resctx(struct file *file, unsigned int cmd,
                          &res->contexts))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_RES_CTX, (unsigned long)res);
+       err = drm_ioctl(file, DRM_IOCTL_RES_CTX, (unsigned long)res);
        if (err)
                return err;
 
@@ -718,8 +703,7 @@ static int compat_drm_dma(struct file *file, unsigned int cmd,
                          &d->request_sizes))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_DMA, (unsigned long)d);
+       err = drm_ioctl(file, DRM_IOCTL_DMA, (unsigned long)d);
        if (err)
                return err;
 
@@ -751,8 +735,7 @@ static int compat_drm_agp_enable(struct file *file, unsigned int cmd,
        if (put_user(m32.mode, &mode->mode))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_AGP_ENABLE, (unsigned long)mode);
+       return drm_ioctl(file, DRM_IOCTL_AGP_ENABLE, (unsigned long)mode);
 }
 
 typedef struct drm_agp_info32 {
@@ -781,8 +764,7 @@ static int compat_drm_agp_info(struct file *file, unsigned int cmd,
        if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_AGP_INFO, (unsigned long)info);
+       err = drm_ioctl(file, DRM_IOCTL_AGP_INFO, (unsigned long)info);
        if (err)
                return err;
 
@@ -827,16 +809,14 @@ static int compat_drm_agp_alloc(struct file *file, unsigned int cmd,
            || __put_user(req32.type, &request->type))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_AGP_ALLOC, (unsigned long)request);
+       err = drm_ioctl(file, DRM_IOCTL_AGP_ALLOC, (unsigned long)request);
        if (err)
                return err;
 
        if (__get_user(req32.handle, &request->handle)
            || __get_user(req32.physical, &request->physical)
            || copy_to_user(argp, &req32, sizeof(req32))) {
-               drm_ioctl(file->f_path.dentry->d_inode, file,
-                         DRM_IOCTL_AGP_FREE, (unsigned long)request);
+               drm_ioctl(file, DRM_IOCTL_AGP_FREE, (unsigned long)request);
                return -EFAULT;
        }
 
@@ -856,8 +836,7 @@ static int compat_drm_agp_free(struct file *file, unsigned int cmd,
            || __put_user(handle, &request->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_AGP_FREE, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_AGP_FREE, (unsigned long)request);
 }
 
 typedef struct drm_agp_binding32 {
@@ -881,8 +860,7 @@ static int compat_drm_agp_bind(struct file *file, unsigned int cmd,
            || __put_user(req32.offset, &request->offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_AGP_BIND, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_AGP_BIND, (unsigned long)request);
 }
 
 static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
@@ -898,8 +876,7 @@ static int compat_drm_agp_unbind(struct file *file, unsigned int cmd,
            || __put_user(handle, &request->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_AGP_UNBIND, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_AGP_UNBIND, (unsigned long)request);
 }
 #endif                         /* __OS_HAS_AGP */
 
@@ -923,8 +900,7 @@ static int compat_drm_sg_alloc(struct file *file, unsigned int cmd,
            || __put_user(x, &request->size))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_SG_ALLOC, (unsigned long)request);
+       err = drm_ioctl(file, DRM_IOCTL_SG_ALLOC, (unsigned long)request);
        if (err)
                return err;
 
@@ -950,8 +926,7 @@ static int compat_drm_sg_free(struct file *file, unsigned int cmd,
            || __put_user(x << PAGE_SHIFT, &request->handle))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_SG_FREE, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_SG_FREE, (unsigned long)request);
 }
 
 #if defined(CONFIG_X86) || defined(CONFIG_IA64)
@@ -981,8 +956,7 @@ static int compat_drm_update_draw(struct file *file, unsigned int cmd,
            __put_user(update32.data, &request->data))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_UPDATE_DRAW, (unsigned long)request);
+       err = drm_ioctl(file, DRM_IOCTL_UPDATE_DRAW, (unsigned long)request);
        return err;
 }
 #endif
@@ -1023,8 +997,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
            || __put_user(req32.request.signal, &request->request.signal))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_WAIT_VBLANK, (unsigned long)request);
+       err = drm_ioctl(file, DRM_IOCTL_WAIT_VBLANK, (unsigned long)request);
        if (err)
                return err;
 
@@ -1094,16 +1067,14 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
         * than always failing.
         */
        if (nr >= ARRAY_SIZE(drm_compat_ioctls))
-               return drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+               return drm_ioctl(filp, cmd, arg);
 
        fn = drm_compat_ioctls[nr];
 
-       lock_kernel();          /* XXX for now */
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
-       unlock_kernel();
+               ret = drm_ioctl(filp, cmd, arg);
 
        return ret;
 }
index d7d7eac3ddd264c1104027fae06f6b48c57fedfb..cdec32977129b98bf00179f01e919dc297fcf333 100644 (file)
@@ -358,7 +358,7 @@ struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
                if (entry->size >= size + wasted) {
                        if (!best_match)
                                return entry;
-                       if (size < best_size) {
+                       if (entry->size < best_size) {
                                best = entry;
                                best_size = entry->size;
                        }
@@ -408,7 +408,7 @@ struct drm_mm_node *drm_mm_search_free_in_range(const struct drm_mm *mm,
                if (entry->size >= size + wasted) {
                        if (!best_match)
                                return entry;
-                       if (size < best_size) {
+                       if (entry->size < best_size) {
                                best = entry;
                                best_size = entry->size;
                        }
index 9422a74c8b54148b881b6dac265339194ba24ece..81681a07a8060cbdb980765fca9edfc3a270d7ca 100644 (file)
@@ -408,6 +408,11 @@ static int ch7006_probe(struct i2c_client *client, const struct i2c_device_id *i
 
        ch7006_info(client, "Detected version ID: %x\n", val);
 
+       /* I don't know what this is for, but otherwise I get no
+        * signal.
+        */
+       ch7006_write(client, 0x3d, 0x0);
+
        return 0;
 
 fail:
index 87f5445092e84198d303d35b9ac7a2d956b2b149..e447dfb63890c91d948b634a27084ba0ba784293 100644 (file)
@@ -427,11 +427,6 @@ void ch7006_state_load(struct i2c_client *client,
        ch7006_load_reg(client, state, CH7006_SUBC_INC7);
        ch7006_load_reg(client, state, CH7006_PLL_CONTROL);
        ch7006_load_reg(client, state, CH7006_CALC_SUBC_INC0);
-
-       /* I don't know what this is for, but otherwise I get no
-        * signal.
-        */
-       ch7006_write(client, 0x3d, 0x0);
 }
 
 void ch7006_state_save(struct i2c_client *client,
index 7d1d88cdf2dc393a808cb3f1ee574bf99d29b6c5..de32d22a8c3974fecb41f64c32af246aa1764eb9 100644 (file)
@@ -115,7 +115,7 @@ static int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
 static const struct file_operations i810_buffer_fops = {
        .open = drm_open,
        .release = drm_release,
-       .ioctl = drm_ioctl,
+       .unlocked_ioctl = drm_ioctl,
        .mmap = i810_mmap_buffers,
        .fasync = drm_fasync,
 };
index fabb9a817966cecde6b4f0ff5e83c8e36d1b8ea9..c1e02752e023cdf13107e88d3825235e91411cdd 100644 (file)
@@ -59,7 +59,7 @@ static struct drm_driver driver = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
-                .ioctl = drm_ioctl,
+                .unlocked_ioctl = drm_ioctl,
                 .mmap = drm_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
index 877bf6cb14a4351d4a054b736b104d14afb0fe72..06bd732e6463b23e6ed9968e5500299bd37bcd9e 100644 (file)
@@ -117,7 +117,7 @@ static int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
 static const struct file_operations i830_buffer_fops = {
        .open = drm_open,
        .release = drm_release,
-       .ioctl = drm_ioctl,
+       .unlocked_ioctl = drm_ioctl,
        .mmap = i830_mmap_buffers,
        .fasync = drm_fasync,
 };
index 389597e4a623281b1c7db76766ddd9b52b15f791..44f990bed8f42347fa7404bf117fad9b3bb9a159 100644 (file)
@@ -70,7 +70,7 @@ static struct drm_driver driver = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
-                .ioctl = drm_ioctl,
+                .unlocked_ioctl = drm_ioctl,
                 .mmap = drm_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
index 2fa217862058d849fe3b5723cf578297777cbe53..24286ca168fc41f56bf4fb92ad4576812e1e50bd 100644 (file)
@@ -329,7 +329,7 @@ static struct drm_driver driver = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
-                .ioctl = drm_ioctl,
+                .unlocked_ioctl = drm_ioctl,
                 .mmap = drm_gem_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
index 1fe68a251b75fe3107115a970a919c1e3e447328..13b028994b2be7e3c2caf4eec100560ed01358fb 100644 (file)
@@ -66,8 +66,7 @@ static int compat_i915_batchbuffer(struct file *file, unsigned int cmd,
                          &batchbuffer->cliprects))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_I915_BATCHBUFFER,
+       return drm_ioctl(file, DRM_IOCTL_I915_BATCHBUFFER,
                         (unsigned long)batchbuffer);
 }
 
@@ -102,8 +101,8 @@ static int compat_i915_cmdbuffer(struct file *file, unsigned int cmd,
                          &cmdbuffer->cliprects))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_I915_CMDBUFFER, (unsigned long)cmdbuffer);
+       return drm_ioctl(file, DRM_IOCTL_I915_CMDBUFFER,
+                        (unsigned long)cmdbuffer);
 }
 
 typedef struct drm_i915_irq_emit32 {
@@ -125,8 +124,8 @@ static int compat_i915_irq_emit(struct file *file, unsigned int cmd,
                          &request->irq_seq))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_I915_IRQ_EMIT, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_I915_IRQ_EMIT,
+                        (unsigned long)request);
 }
 typedef struct drm_i915_getparam32 {
        int param;
@@ -149,8 +148,8 @@ static int compat_i915_getparam(struct file *file, unsigned int cmd,
                          &request->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_I915_GETPARAM, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_I915_GETPARAM,
+                        (unsigned long)request);
 }
 
 typedef struct drm_i915_mem_alloc32 {
@@ -178,8 +177,8 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
                          &request->region_offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_I915_ALLOC, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_I915_ALLOC,
+                        (unsigned long)request);
 }
 
 drm_ioctl_compat_t *i915_compat_ioctls[] = {
@@ -211,12 +210,10 @@ long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
                fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
 
-       lock_kernel();          /* XXX for now */
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
-       unlock_kernel();
+               ret = drm_ioctl(filp, cmd, arg);
 
        return ret;
 }
index 97ee566ef7492468ecb4c2489b5644d74f5cd5af..ddfe16197b59336e6d9c874e9e1b855a8222c430 100644 (file)
@@ -68,7 +68,7 @@ static struct drm_driver driver = {
                .owner = THIS_MODULE,
                .open = drm_open,
                .release = drm_release,
-               .ioctl = drm_ioctl,
+               .unlocked_ioctl = drm_ioctl,
                .mmap = drm_mmap,
                .poll = drm_poll,
                .fasync = drm_fasync,
index 30d00478ddee9055aad48054659223afeaef573f..c1f877b7bac15524f189e676fb76254098b471c8 100644 (file)
@@ -100,8 +100,7 @@ static int compat_mga_init(struct file *file, unsigned int cmd,
        if (err)
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_MGA_INIT, (unsigned long)init);
+       return drm_ioctl(file, DRM_IOCTL_MGA_INIT, (unsigned long)init);
 }
 
 typedef struct drm_mga_getparam32 {
@@ -125,8 +124,7 @@ static int compat_mga_getparam(struct file *file, unsigned int cmd,
                          &getparam->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_MGA_GETPARAM, (unsigned long)getparam);
+       return drm_ioctl(file, DRM_IOCTL_MGA_GETPARAM, (unsigned long)getparam);
 }
 
 typedef struct drm_mga_drm_bootstrap32 {
@@ -166,8 +164,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
            || __put_user(dma_bootstrap32.agp_size, &dma_bootstrap->agp_size))
                return -EFAULT;
 
-       err = drm_ioctl(file->f_path.dentry->d_inode, file,
-                       DRM_IOCTL_MGA_DMA_BOOTSTRAP,
+       err = drm_ioctl(file, DRM_IOCTL_MGA_DMA_BOOTSTRAP,
                        (unsigned long)dma_bootstrap);
        if (err)
                return err;
@@ -220,12 +217,10 @@ long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
                fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
 
-       lock_kernel();          /* XXX for now */
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
-       unlock_kernel();
+               ret = drm_ioctl(filp, cmd, arg);
 
        return ret;
 }
index d823e63195162fbc7cf3b750daf5da3be14baf73..b1bc1ea182b80362dea6dee9f3c098d96e9744f4 100644 (file)
@@ -30,11 +30,12 @@ config DRM_NOUVEAU_DEBUG
          via debugfs.
 
 menu "I2C encoder or helper chips"
-     depends on DRM
+     depends on DRM && I2C
 
 config DRM_I2C_CH7006
        tristate "Chrontel ch7006 TV encoder"
-       default m if DRM_NOUVEAU
+       depends on DRM_NOUVEAU
+       default m
        help
          Support for Chrontel ch7006 and similar TV encoders, found
          on some nVidia video cards.
index 1d90d4d0144f593aecc5c9194ddc65eded6b4acc..48c290b5da8c2743257cdfa9ca08db565dd7bd7b 100644 (file)
@@ -8,14 +8,15 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
              nouveau_sgdma.o nouveau_dma.o \
              nouveau_bo.o nouveau_fence.o nouveau_gem.o nouveau_ttm.o \
              nouveau_hw.o nouveau_calc.o nouveau_bios.o nouveau_i2c.o \
-            nouveau_display.o nouveau_connector.o nouveau_fbcon.o \
-            nouveau_dp.o \
+             nouveau_display.o nouveau_connector.o nouveau_fbcon.o \
+             nouveau_dp.o nouveau_grctx.o \
              nv04_timer.o \
              nv04_mc.o nv40_mc.o nv50_mc.o \
              nv04_fb.o nv10_fb.o nv40_fb.o \
              nv04_fifo.o nv10_fifo.o nv40_fifo.o nv50_fifo.o \
              nv04_graph.o nv10_graph.o nv20_graph.o \
              nv40_graph.o nv50_graph.o \
+             nv40_grctx.o \
              nv04_instmem.o nv50_instmem.o \
              nv50_crtc.o nv50_dac.o nv50_sor.o \
              nv50_cursor.o nv50_display.o nv50_fbcon.o \
index 5eec5ed69489ef3546d32e159f4dde2fb39db183..ba143972769f20329322c360763611d6971a1d62 100644 (file)
@@ -181,43 +181,42 @@ struct methods {
        const char desc[8];
        void (*loadbios)(struct drm_device *, uint8_t *);
        const bool rw;
-       int score;
 };
 
 static struct methods nv04_methods[] = {
        { "PROM", load_vbios_prom, false },
        { "PRAMIN", load_vbios_pramin, true },
        { "PCIROM", load_vbios_pci, true },
-       { }
 };
 
 static struct methods nv50_methods[] = {
        { "PRAMIN", load_vbios_pramin, true },
        { "PROM", load_vbios_prom, false },
        { "PCIROM", load_vbios_pci, true },
-       { }
 };
 
+#define METHODCNT 3
+
 static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
 {
        struct drm_nouveau_private *dev_priv = dev->dev_private;
-       struct methods *methods, *method;
+       struct methods *methods;
+       int i;
        int testscore = 3;
+       int scores[METHODCNT];
 
        if (nouveau_vbios) {
-               method = nv04_methods;
-               while (method->loadbios) {
-                       if (!strcasecmp(nouveau_vbios, method->desc))
+               methods = nv04_methods;
+               for (i = 0; i < METHODCNT; i++)
+                       if (!strcasecmp(nouveau_vbios, methods[i].desc))
                                break;
-                       method++;
-               }
 
-               if (method->loadbios) {
+               if (i < METHODCNT) {
                        NV_INFO(dev, "Attempting to use BIOS image from %s\n",
-                               method->desc);
+                               methods[i].desc);
 
-                       method->loadbios(dev, data);
-                       if (score_vbios(dev, data, method->rw))
+                       methods[i].loadbios(dev, data);
+                       if (score_vbios(dev, data, methods[i].rw))
                                return true;
                }
 
@@ -229,28 +228,24 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
        else
                methods = nv50_methods;
 
-       method = methods;
-       while (method->loadbios) {
+       for (i = 0; i < METHODCNT; i++) {
                NV_TRACE(dev, "Attempting to load BIOS image from %s\n",
-                        method->desc);
+                        methods[i].desc);
                data[0] = data[1] = 0;  /* avoid reuse of previous image */
-               method->loadbios(dev, data);
-               method->score = score_vbios(dev, data, method->rw);
-               if (method->score == testscore)
+               methods[i].loadbios(dev, data);
+               scores[i] = score_vbios(dev, data, methods[i].rw);
+               if (scores[i] == testscore)
                        return true;
-               method++;
        }
 
        while (--testscore > 0) {
-               method = methods;
-               while (method->loadbios) {
-                       if (method->score == testscore) {
+               for (i = 0; i < METHODCNT; i++) {
+                       if (scores[i] == testscore) {
                                NV_TRACE(dev, "Using BIOS image from %s\n",
-                                        method->desc);
-                               method->loadbios(dev, data);
+                                        methods[i].desc);
+                               methods[i].loadbios(dev, data);
                                return true;
                        }
-                       method++;
                }
        }
 
@@ -261,10 +256,7 @@ static bool NVShadowVBIOS(struct drm_device *dev, uint8_t *data)
 struct init_tbl_entry {
        char *name;
        uint8_t id;
-       int length;
-       int length_offset;
-       int length_multiplier;
-       bool (*handler)(struct nvbios *, uint16_t, struct init_exec *);
+       int (*handler)(struct nvbios *, uint16_t, struct init_exec *);
 };
 
 struct bit_entry {
@@ -820,7 +812,7 @@ static uint32_t get_tmds_index_reg(struct drm_device *dev, uint8_t mlv)
        }
 }
 
-static bool
+static int
 init_io_restrict_prog(struct nvbios *bios, uint16_t offset,
                      struct init_exec *iexec)
 {
@@ -852,9 +844,10 @@ init_io_restrict_prog(struct nvbios *bios, uint16_t offset,
        uint32_t reg = ROM32(bios->data[offset + 7]);
        uint8_t config;
        uint32_t configval;
+       int len = 11 + count * 4;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, "
                      "Shift: 0x%02X, Count: 0x%02X, Reg: 0x%08X\n",
@@ -865,7 +858,7 @@ init_io_restrict_prog(struct nvbios *bios, uint16_t offset,
                NV_ERROR(bios->dev,
                         "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n",
                         offset, config, count);
-               return false;
+               return 0;
        }
 
        configval = ROM32(bios->data[offset + 11 + config * 4]);
@@ -874,10 +867,10 @@ init_io_restrict_prog(struct nvbios *bios, uint16_t offset,
 
        bios_wr32(bios, reg, configval);
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -912,10 +905,10 @@ init_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 
        iexec->repeat = false;
 
-       return true;
+       return 2;
 }
 
-static bool
+static int
 init_io_restrict_pll(struct nvbios *bios, uint16_t offset,
                     struct init_exec *iexec)
 {
@@ -951,9 +944,10 @@ init_io_restrict_pll(struct nvbios *bios, uint16_t offset,
        uint32_t reg = ROM32(bios->data[offset + 8]);
        uint8_t config;
        uint16_t freq;
+       int len = 12 + count * 2;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, "
                      "Shift: 0x%02X, IO Flag Condition: 0x%02X, "
@@ -966,7 +960,7 @@ init_io_restrict_pll(struct nvbios *bios, uint16_t offset,
                NV_ERROR(bios->dev,
                         "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n",
                         offset, config, count);
-               return false;
+               return 0;
        }
 
        freq = ROM16(bios->data[offset + 12 + config * 2]);
@@ -986,10 +980,10 @@ init_io_restrict_pll(struct nvbios *bios, uint16_t offset,
 
        setPLL(bios, reg, freq * 10);
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_end_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1007,12 +1001,12 @@ init_end_repeat(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
         * we're not in repeat mode
         */
        if (iexec->repeat)
-               return false;
+               return 0;
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_copy(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1041,7 +1035,7 @@ init_copy(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t crtcdata;
 
        if (!iexec->execute)
-               return true;
+               return 11;
 
        BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Shift: 0x%02X, SrcMask: 0x%02X, "
                      "Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X\n",
@@ -1060,10 +1054,10 @@ init_copy(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        crtcdata |= (uint8_t)data;
        bios_idxprt_wr(bios, crtcport, crtcindex, crtcdata);
 
-       return true;
+       return 11;
 }
 
-static bool
+static int
 init_not(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1079,10 +1073,10 @@ init_not(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                BIOSLOG(bios, "0x%04X: ------ Executing following commands ------\n", offset);
 
        iexec->execute = !iexec->execute;
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_io_flag_condition(struct nvbios *bios, uint16_t offset,
                       struct init_exec *iexec)
 {
@@ -1100,7 +1094,7 @@ init_io_flag_condition(struct nvbios *bios, uint16_t offset,
        uint8_t cond = bios->data[offset + 1];
 
        if (!iexec->execute)
-               return true;
+               return 2;
 
        if (io_flag_condition_met(bios, offset, cond))
                BIOSLOG(bios, "0x%04X: Condition fulfilled -- continuing to execute\n", offset);
@@ -1109,10 +1103,10 @@ init_io_flag_condition(struct nvbios *bios, uint16_t offset,
                iexec->execute = false;
        }
 
-       return true;
+       return 2;
 }
 
-static bool
+static int
 init_idx_addr_latched(struct nvbios *bios, uint16_t offset,
                      struct init_exec *iexec)
 {
@@ -1140,11 +1134,12 @@ init_idx_addr_latched(struct nvbios *bios, uint16_t offset,
        uint32_t mask = ROM32(bios->data[offset + 9]);
        uint32_t data = ROM32(bios->data[offset + 13]);
        uint8_t count = bios->data[offset + 17];
+       int len = 18 + count * 2;
        uint32_t value;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: ControlReg: 0x%08X, DataReg: 0x%08X, "
                      "Mask: 0x%08X, Data: 0x%08X, Count: 0x%02X\n",
@@ -1164,10 +1159,10 @@ init_idx_addr_latched(struct nvbios *bios, uint16_t offset,
                bios_wr32(bios, controlreg, value);
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_io_restrict_pll2(struct nvbios *bios, uint16_t offset,
                      struct init_exec *iexec)
 {
@@ -1196,25 +1191,26 @@ init_io_restrict_pll2(struct nvbios *bios, uint16_t offset,
        uint8_t shift = bios->data[offset + 5];
        uint8_t count = bios->data[offset + 6];
        uint32_t reg = ROM32(bios->data[offset + 7]);
+       int len = 11 + count * 4;
        uint8_t config;
        uint32_t freq;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, "
                      "Shift: 0x%02X, Count: 0x%02X, Reg: 0x%08X\n",
                offset, crtcport, crtcindex, mask, shift, count, reg);
 
        if (!reg)
-               return true;
+               return len;
 
        config = (bios_idxprt_rd(bios, crtcport, crtcindex) & mask) >> shift;
        if (config > count) {
                NV_ERROR(bios->dev,
                         "0x%04X: Config 0x%02X exceeds maximal bound 0x%02X\n",
                         offset, config, count);
-               return false;
+               return 0;
        }
 
        freq = ROM32(bios->data[offset + 11 + config * 4]);
@@ -1224,10 +1220,10 @@ init_io_restrict_pll2(struct nvbios *bios, uint16_t offset,
 
        setPLL(bios, reg, freq);
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_pll2(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1244,16 +1240,16 @@ init_pll2(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint32_t freq = ROM32(bios->data[offset + 5]);
 
        if (!iexec->execute)
-               return true;
+               return 9;
 
        BIOSLOG(bios, "0x%04X: Reg: 0x%04X, Freq: %dkHz\n",
                offset, reg, freq);
 
        setPLL(bios, reg, freq);
-       return true;
+       return 9;
 }
 
-static bool
+static int
 init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1277,12 +1273,13 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t i2c_index = bios->data[offset + 1];
        uint8_t i2c_address = bios->data[offset + 2];
        uint8_t count = bios->data[offset + 3];
+       int len = 4 + count * 3;
        struct nouveau_i2c_chan *chan;
        struct i2c_msg msg;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, "
                      "Count: 0x%02X\n",
@@ -1290,7 +1287,7 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 
        chan = init_i2c_device_find(bios->dev, i2c_index);
        if (!chan)
-               return false;
+               return 0;
 
        for (i = 0; i < count; i++) {
                uint8_t i2c_reg = bios->data[offset + 4 + i * 3];
@@ -1303,7 +1300,7 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                msg.len = 1;
                msg.buf = &value;
                if (i2c_transfer(&chan->adapter, &msg, 1) != 1)
-                       return false;
+                       return 0;
 
                BIOSLOG(bios, "0x%04X: I2CReg: 0x%02X, Value: 0x%02X, "
                              "Mask: 0x%02X, Data: 0x%02X\n",
@@ -1317,14 +1314,14 @@ init_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                        msg.len = 1;
                        msg.buf = &value;
                        if (i2c_transfer(&chan->adapter, &msg, 1) != 1)
-                               return false;
+                               return 0;
                }
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1346,12 +1343,13 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t i2c_index = bios->data[offset + 1];
        uint8_t i2c_address = bios->data[offset + 2];
        uint8_t count = bios->data[offset + 3];
+       int len = 4 + count * 2;
        struct nouveau_i2c_chan *chan;
        struct i2c_msg msg;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, "
                      "Count: 0x%02X\n",
@@ -1359,7 +1357,7 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 
        chan = init_i2c_device_find(bios->dev, i2c_index);
        if (!chan)
-               return false;
+               return 0;
 
        for (i = 0; i < count; i++) {
                uint8_t i2c_reg = bios->data[offset + 4 + i * 2];
@@ -1374,14 +1372,14 @@ init_zm_i2c_byte(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                        msg.len = 1;
                        msg.buf = &data;
                        if (i2c_transfer(&chan->adapter, &msg, 1) != 1)
-                               return false;
+                               return 0;
                }
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1401,13 +1399,14 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t i2c_index = bios->data[offset + 1];
        uint8_t i2c_address = bios->data[offset + 2];
        uint8_t count = bios->data[offset + 3];
+       int len = 4 + count;
        struct nouveau_i2c_chan *chan;
        struct i2c_msg msg;
        uint8_t data[256];
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X, "
                      "Count: 0x%02X\n",
@@ -1415,7 +1414,7 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 
        chan = init_i2c_device_find(bios->dev, i2c_index);
        if (!chan)
-               return false;
+               return 0;
 
        for (i = 0; i < count; i++) {
                data[i] = bios->data[offset + 4 + i];
@@ -1429,13 +1428,13 @@ init_zm_i2c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                msg.len = count;
                msg.buf = data;
                if (i2c_transfer(&chan->adapter, &msg, 1) != 1)
-                       return false;
+                       return 0;
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1460,7 +1459,7 @@ init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint32_t reg, value;
 
        if (!iexec->execute)
-               return true;
+               return 5;
 
        BIOSLOG(bios, "0x%04X: MagicLookupValue: 0x%02X, TMDSAddr: 0x%02X, "
                      "Mask: 0x%02X, Data: 0x%02X\n",
@@ -1468,7 +1467,7 @@ init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 
        reg = get_tmds_index_reg(bios->dev, mlv);
        if (!reg)
-               return false;
+               return 0;
 
        bios_wr32(bios, reg,
                  tmdsaddr | NV_PRAMDAC_FP_TMDS_CONTROL_WRITE_DISABLE);
@@ -1476,10 +1475,10 @@ init_tmds(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        bios_wr32(bios, reg + 4, value);
        bios_wr32(bios, reg, tmdsaddr);
 
-       return true;
+       return 5;
 }
 
-static bool
+static int
 init_zm_tmds_group(struct nvbios *bios, uint16_t offset,
                   struct init_exec *iexec)
 {
@@ -1500,18 +1499,19 @@ init_zm_tmds_group(struct nvbios *bios, uint16_t offset,
 
        uint8_t mlv = bios->data[offset + 1];
        uint8_t count = bios->data[offset + 2];
+       int len = 3 + count * 2;
        uint32_t reg;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: MagicLookupValue: 0x%02X, Count: 0x%02X\n",
                offset, mlv, count);
 
        reg = get_tmds_index_reg(bios->dev, mlv);
        if (!reg)
-               return false;
+               return 0;
 
        for (i = 0; i < count; i++) {
                uint8_t tmdsaddr = bios->data[offset + 3 + i * 2];
@@ -1521,10 +1521,10 @@ init_zm_tmds_group(struct nvbios *bios, uint16_t offset,
                bios_wr32(bios, reg, tmdsaddr);
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_cr_idx_adr_latch(struct nvbios *bios, uint16_t offset,
                      struct init_exec *iexec)
 {
@@ -1547,11 +1547,12 @@ init_cr_idx_adr_latch(struct nvbios *bios, uint16_t offset,
        uint8_t crtcindex2 = bios->data[offset + 2];
        uint8_t baseaddr = bios->data[offset + 3];
        uint8_t count = bios->data[offset + 4];
+       int len = 5 + count;
        uint8_t oldaddr, data;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: Index1: 0x%02X, Index2: 0x%02X, "
                      "BaseAddr: 0x%02X, Count: 0x%02X\n",
@@ -1568,10 +1569,10 @@ init_cr_idx_adr_latch(struct nvbios *bios, uint16_t offset,
 
        bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex1, oldaddr);
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1592,7 +1593,7 @@ init_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t value;
 
        if (!iexec->execute)
-               return true;
+               return 4;
 
        BIOSLOG(bios, "0x%04X: Index: 0x%02X, Mask: 0x%02X, Data: 0x%02X\n",
                offset, crtcindex, mask, data);
@@ -1601,10 +1602,10 @@ init_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        value |= data;
        bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex, value);
 
-       return true;
+       return 4;
 }
 
-static bool
+static int
 init_zm_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1621,14 +1622,14 @@ init_zm_cr(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t data = bios->data[offset + 2];
 
        if (!iexec->execute)
-               return true;
+               return 3;
 
        bios_idxprt_wr(bios, NV_CIO_CRX__COLOR, crtcindex, data);
 
-       return true;
+       return 3;
 }
 
-static bool
+static int
 init_zm_cr_group(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1645,18 +1646,19 @@ init_zm_cr_group(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
         */
 
        uint8_t count = bios->data[offset + 1];
+       int len = 2 + count * 2;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        for (i = 0; i < count; i++)
                init_zm_cr(bios, offset + 2 + 2 * i - 1, iexec);
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_condition_time(struct nvbios *bios, uint16_t offset,
                    struct init_exec *iexec)
 {
@@ -1680,7 +1682,7 @@ init_condition_time(struct nvbios *bios, uint16_t offset,
        unsigned cnt;
 
        if (!iexec->execute)
-               return true;
+               return 3;
 
        if (retries > 100)
                retries = 100;
@@ -1711,10 +1713,10 @@ init_condition_time(struct nvbios *bios, uint16_t offset,
                iexec->execute = false;
        }
 
-       return true;
+       return 3;
 }
 
-static bool
+static int
 init_zm_reg_sequence(struct nvbios *bios, uint16_t offset,
                     struct init_exec *iexec)
 {
@@ -1734,10 +1736,11 @@ init_zm_reg_sequence(struct nvbios *bios, uint16_t offset,
 
        uint32_t basereg = ROM32(bios->data[offset + 1]);
        uint32_t count = bios->data[offset + 5];
+       int len = 6 + count * 4;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        BIOSLOG(bios, "0x%04X: BaseReg: 0x%08X, Count: 0x%02X\n",
                offset, basereg, count);
@@ -1749,10 +1752,10 @@ init_zm_reg_sequence(struct nvbios *bios, uint16_t offset,
                bios_wr32(bios, reg, data);
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1768,7 +1771,7 @@ init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint16_t sub_offset = ROM16(bios->data[offset + 1]);
 
        if (!iexec->execute)
-               return true;
+               return 3;
 
        BIOSLOG(bios, "0x%04X: Executing subroutine at 0x%04X\n",
                offset, sub_offset);
@@ -1777,10 +1780,10 @@ init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 
        BIOSLOG(bios, "0x%04X: End of 0x%04X subroutine\n", offset, sub_offset);
 
-       return true;
+       return 3;
 }
 
-static bool
+static int
 init_copy_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1808,7 +1811,7 @@ init_copy_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint32_t srcvalue, dstvalue;
 
        if (!iexec->execute)
-               return true;
+               return 22;
 
        BIOSLOG(bios, "0x%04X: SrcReg: 0x%08X, Shift: 0x%02X, SrcMask: 0x%08X, "
                      "Xor: 0x%08X, DstReg: 0x%08X, DstMask: 0x%08X\n",
@@ -1827,10 +1830,10 @@ init_copy_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 
        bios_wr32(bios, dstreg, dstvalue | srcvalue);
 
-       return true;
+       return 22;
 }
 
-static bool
+static int
 init_zm_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1848,14 +1851,14 @@ init_zm_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t data = bios->data[offset + 4];
 
        if (!iexec->execute)
-               return true;
+               return 5;
 
        bios_idxprt_wr(bios, crtcport, crtcindex, data);
 
-       return true;
+       return 5;
 }
 
-static bool
+static int
 init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1904,7 +1907,7 @@ init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        struct drm_nouveau_private *dev_priv = bios->dev->dev_private;
 
        if (dev_priv->card_type >= NV_50)
-               return true;
+               return 1;
 
        /*
         * On every card I've seen, this step gets done for us earlier in
@@ -1922,10 +1925,10 @@ init_compute_mem(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        /* write back the saved configuration value */
        bios_wr32(bios, NV_PFB_CFG0, bios->state.saved_nv_pfb_cfg0);
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_reset(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -1959,10 +1962,10 @@ init_reset(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        pci_nv_20 &= ~NV_PBUS_PCI_NV_20_ROM_SHADOW_ENABLED;     /* 0xfffffffe */
        bios_wr32(bios, NV_PBUS_PCI_NV_20, pci_nv_20);
 
-       return true;
+       return 13;
 }
 
-static bool
+static int
 init_configure_mem(struct nvbios *bios, uint16_t offset,
                   struct init_exec *iexec)
 {
@@ -1983,7 +1986,7 @@ init_configure_mem(struct nvbios *bios, uint16_t offset,
        uint32_t reg, data;
 
        if (bios->major_version > 2)
-               return false;
+               return 0;
 
        bios_idxprt_wr(bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX, bios_idxprt_rd(
                       bios, NV_VIO_SRX, NV_VIO_SR_CLOCK_INDEX) | 0x20);
@@ -2015,10 +2018,10 @@ init_configure_mem(struct nvbios *bios, uint16_t offset,
                bios_wr32(bios, reg, data);
        }
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_configure_clk(struct nvbios *bios, uint16_t offset,
                   struct init_exec *iexec)
 {
@@ -2038,7 +2041,7 @@ init_configure_clk(struct nvbios *bios, uint16_t offset,
        int clock;
 
        if (bios->major_version > 2)
-               return false;
+               return 0;
 
        clock = ROM16(bios->data[meminitoffs + 4]) * 10;
        setPLL(bios, NV_PRAMDAC_NVPLL_COEFF, clock);
@@ -2048,10 +2051,10 @@ init_configure_clk(struct nvbios *bios, uint16_t offset,
                clock *= 2;
        setPLL(bios, NV_PRAMDAC_MPLL_COEFF, clock);
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_configure_preinit(struct nvbios *bios, uint16_t offset,
                       struct init_exec *iexec)
 {
@@ -2071,15 +2074,15 @@ init_configure_preinit(struct nvbios *bios, uint16_t offset,
        uint8_t cr3c = ((straps << 2) & 0xf0) | (straps & (1 << 6));
 
        if (bios->major_version > 2)
-               return false;
+               return 0;
 
        bios_idxprt_wr(bios, NV_CIO_CRX__COLOR,
                             NV_CIO_CRE_SCRATCH4__INDEX, cr3c);
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2099,7 +2102,7 @@ init_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t data = bios->data[offset + 4];
 
        if (!iexec->execute)
-               return true;
+               return 5;
 
        BIOSLOG(bios, "0x%04X: Port: 0x%04X, Mask: 0x%02X, Data: 0x%02X\n",
                offset, crtcport, mask, data);
@@ -2158,15 +2161,15 @@ init_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                for (i = 0; i < 2; i++)
                        bios_wr32(bios, 0x614108 + (i*0x800), bios_rd32(
                                  bios, 0x614108 + (i*0x800)) & 0x0fffffff);
-               return true;
+               return 5;
        }
 
        bios_port_wr(bios, crtcport, (bios_port_rd(bios, crtcport) & mask) |
                                                                        data);
-       return true;
+       return 5;
 }
 
-static bool
+static int
 init_sub(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2181,7 +2184,7 @@ init_sub(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t sub = bios->data[offset + 1];
 
        if (!iexec->execute)
-               return true;
+               return 2;
 
        BIOSLOG(bios, "0x%04X: Calling script %d\n", offset, sub);
 
@@ -2191,10 +2194,10 @@ init_sub(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 
        BIOSLOG(bios, "0x%04X: End of script %d\n", offset, sub);
 
-       return true;
+       return 2;
 }
 
-static bool
+static int
 init_ram_condition(struct nvbios *bios, uint16_t offset,
                   struct init_exec *iexec)
 {
@@ -2215,7 +2218,7 @@ init_ram_condition(struct nvbios *bios, uint16_t offset,
        uint8_t data;
 
        if (!iexec->execute)
-               return true;
+               return 3;
 
        data = bios_rd32(bios, NV_PFB_BOOT_0) & mask;
 
@@ -2229,10 +2232,10 @@ init_ram_condition(struct nvbios *bios, uint16_t offset,
                iexec->execute = false;
        }
 
-       return true;
+       return 3;
 }
 
-static bool
+static int
 init_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2251,17 +2254,17 @@ init_nv_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint32_t data = ROM32(bios->data[offset + 9]);
 
        if (!iexec->execute)
-               return true;
+               return 13;
 
        BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Mask: 0x%08X, Data: 0x%08X\n",
                offset, reg, mask, data);
 
        bios_wr32(bios, reg, (bios_rd32(bios, reg) & mask) | data);
 
-       return true;
+       return 13;
 }
 
-static bool
+static int
 init_macro(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2285,7 +2288,7 @@ init_macro(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        int i;
 
        if (!iexec->execute)
-               return true;
+               return 2;
 
        BIOSLOG(bios, "0x%04X: Macro: 0x%02X, MacroTableIndex: 0x%02X, "
                      "Count: 0x%02X\n",
@@ -2300,10 +2303,10 @@ init_macro(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                bios_wr32(bios, reg, data);
        }
 
-       return true;
+       return 2;
 }
 
-static bool
+static int
 init_done(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2315,10 +2318,10 @@ init_done(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
         */
 
        /* mild retval abuse to stop parsing this table */
-       return false;
+       return 0;
 }
 
-static bool
+static int
 init_resume(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2330,15 +2333,15 @@ init_resume(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
         */
 
        if (iexec->execute)
-               return true;
+               return 1;
 
        iexec->execute = true;
        BIOSLOG(bios, "0x%04X: ---- Executing following commands ----\n", offset);
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_time(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2353,7 +2356,7 @@ init_time(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        unsigned time = ROM16(bios->data[offset + 1]);
 
        if (!iexec->execute)
-               return true;
+               return 3;
 
        BIOSLOG(bios, "0x%04X: Sleeping for 0x%04X microseconds\n",
                offset, time);
@@ -2363,10 +2366,10 @@ init_time(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        else
                msleep((time + 900) / 1000);
 
-       return true;
+       return 3;
 }
 
-static bool
+static int
 init_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2383,7 +2386,7 @@ init_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t cond = bios->data[offset + 1];
 
        if (!iexec->execute)
-               return true;
+               return 2;
 
        BIOSLOG(bios, "0x%04X: Condition: 0x%02X\n", offset, cond);
 
@@ -2394,10 +2397,10 @@ init_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                iexec->execute = false;
        }
 
-       return true;
+       return 2;
 }
 
-static bool
+static int
 init_io_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2414,7 +2417,7 @@ init_io_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t cond = bios->data[offset + 1];
 
        if (!iexec->execute)
-               return true;
+               return 2;
 
        BIOSLOG(bios, "0x%04X: IO condition: 0x%02X\n", offset, cond);
 
@@ -2425,10 +2428,10 @@ init_io_condition(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                iexec->execute = false;
        }
 
-       return true;
+       return 2;
 }
 
-static bool
+static int
 init_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2451,7 +2454,7 @@ init_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint8_t value;
 
        if (!iexec->execute)
-               return true;
+               return 6;
 
        BIOSLOG(bios, "0x%04X: Port: 0x%04X, Index: 0x%02X, Mask: 0x%02X, "
                      "Data: 0x%02X\n",
@@ -2460,10 +2463,10 @@ init_index_io(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        value = (bios_idxprt_rd(bios, crtcport, crtcindex) & mask) | data;
        bios_idxprt_wr(bios, crtcport, crtcindex, value);
 
-       return true;
+       return 6;
 }
 
-static bool
+static int
 init_pll(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2481,16 +2484,16 @@ init_pll(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint16_t freq = ROM16(bios->data[offset + 5]);
 
        if (!iexec->execute)
-               return true;
+               return 7;
 
        BIOSLOG(bios, "0x%04X: Reg: 0x%08X, Freq: %d0kHz\n", offset, reg, freq);
 
        setPLL(bios, reg, freq * 10);
 
-       return true;
+       return 7;
 }
 
-static bool
+static int
 init_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2507,17 +2510,17 @@ init_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint32_t value = ROM32(bios->data[offset + 5]);
 
        if (!iexec->execute)
-               return true;
+               return 9;
 
        if (reg == 0x000200)
                value |= 1;
 
        bios_wr32(bios, reg, value);
 
-       return true;
+       return 9;
 }
 
-static bool
+static int
 init_ram_restrict_pll(struct nvbios *bios, uint16_t offset,
                      struct init_exec *iexec)
 {
@@ -2543,14 +2546,15 @@ init_ram_restrict_pll(struct nvbios *bios, uint16_t offset,
        uint8_t type = bios->data[offset + 1];
        uint32_t freq = ROM32(bios->data[offset + 2 + (index * 4)]);
        uint8_t *pll_limits = &bios->data[bios->pll_limit_tbl_ptr], *entry;
+       int len = 2 + bios->ram_restrict_group_count * 4;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        if (!bios->pll_limit_tbl_ptr || (pll_limits[0] & 0xf0) != 0x30) {
                NV_ERROR(dev, "PLL limits table not version 3.x\n");
-               return true; /* deliberate, allow default clocks to remain */
+               return len; /* deliberate, allow default clocks to remain */
        }
 
        entry = pll_limits + pll_limits[1];
@@ -2563,15 +2567,15 @@ init_ram_restrict_pll(struct nvbios *bios, uint16_t offset,
                                offset, type, reg, freq);
 
                        setPLL(bios, reg, freq);
-                       return true;
+                       return len;
                }
        }
 
        NV_ERROR(dev, "PLL type 0x%02x not found in PLL limits table", type);
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_8c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2581,10 +2585,10 @@ init_8c(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
         *
         */
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_8d(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2594,10 +2598,10 @@ init_8d(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
         *
         */
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2615,14 +2619,17 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        const uint8_t *gpio_entry;
        int i;
 
+       if (!iexec->execute)
+               return 1;
+
        if (bios->bdcb.version != 0x40) {
                NV_ERROR(bios->dev, "DCB table not version 4.0\n");
-               return false;
+               return 0;
        }
 
        if (!bios->bdcb.gpio_table_ptr) {
                NV_WARN(bios->dev, "Invalid pointer to INIT_8E table\n");
-               return false;
+               return 0;
        }
 
        gpio_entry = gpio_table + gpio_table[1];
@@ -2660,13 +2667,10 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                bios_wr32(bios, r, v);
        }
 
-       return true;
+       return 1;
 }
 
-/* hack to avoid moving the itbl_entry array before this function */
-int init_ram_restrict_zm_reg_group_blocklen;
-
-static bool
+static int
 init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset,
                               struct init_exec *iexec)
 {
@@ -2692,21 +2696,21 @@ init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset,
        uint8_t regincrement = bios->data[offset + 5];
        uint8_t count = bios->data[offset + 6];
        uint32_t strap_ramcfg, data;
-       uint16_t blocklen;
+       /* previously set by 'M' BIT table */
+       uint16_t blocklen = bios->ram_restrict_group_count * 4;
+       int len = 7 + count * blocklen;
        uint8_t index;
        int i;
 
-       /* previously set by 'M' BIT table */
-       blocklen = init_ram_restrict_zm_reg_group_blocklen;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        if (!blocklen) {
                NV_ERROR(bios->dev,
                         "0x%04X: Zero block length - has the M table "
                         "been parsed?\n", offset);
-               return false;
+               return 0;
        }
 
        strap_ramcfg = (bios_rd32(bios, NV_PEXTDEV_BOOT_0) >> 2) & 0xf;
@@ -2724,10 +2728,10 @@ init_ram_restrict_zm_reg_group(struct nvbios *bios, uint16_t offset,
                reg += regincrement;
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_copy_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2744,14 +2748,14 @@ init_copy_zm_reg(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        uint32_t dstreg = ROM32(bios->data[offset + 5]);
 
        if (!iexec->execute)
-               return true;
+               return 9;
 
        bios_wr32(bios, dstreg, bios_rd32(bios, srcreg));
 
-       return true;
+       return 9;
 }
 
-static bool
+static int
 init_zm_reg_group_addr_latched(struct nvbios *bios, uint16_t offset,
                               struct init_exec *iexec)
 {
@@ -2769,20 +2773,21 @@ init_zm_reg_group_addr_latched(struct nvbios *bios, uint16_t offset,
 
        uint32_t reg = ROM32(bios->data[offset + 1]);
        uint8_t count = bios->data[offset + 5];
+       int len = 6 + count * 4;
        int i;
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        for (i = 0; i < count; i++) {
                uint32_t data = ROM32(bios->data[offset + 6 + 4 * i]);
                bios_wr32(bios, reg, data);
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_reserved(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2793,10 +2798,10 @@ init_reserved(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
         * Seemingly does nothing
         */
 
-       return true;
+       return 1;
 }
 
-static bool
+static int
 init_96(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2829,13 +2834,13 @@ init_96(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        val <<= bios->data[offset + 16];
 
        if (!iexec->execute)
-               return true;
+               return 17;
 
        bios_wr32(bios, reg, (bios_rd32(bios, reg) & mask) | val);
-       return true;
+       return 17;
 }
 
-static bool
+static int
 init_97(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2859,13 +2864,13 @@ init_97(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        val = (val & mask) | ((val + add) & ~mask);
 
        if (!iexec->execute)
-               return true;
+               return 13;
 
        bios_wr32(bios, reg, val);
-       return true;
+       return 13;
 }
 
-static bool
+static int
 init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2883,32 +2888,33 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        struct drm_device *dev = bios->dev;
        struct nouveau_i2c_chan *auxch;
        uint32_t addr = ROM32(bios->data[offset + 1]);
-       uint8_t len = bios->data[offset + 5];
+       uint8_t count = bios->data[offset + 5];
+       int len = 6 + count * 2;
        int ret, i;
 
        if (!bios->display.output) {
                NV_ERROR(dev, "INIT_AUXCH: no active output\n");
-               return false;
+               return 0;
        }
 
        auxch = init_i2c_device_find(dev, bios->display.output->i2c_index);
        if (!auxch) {
                NV_ERROR(dev, "INIT_AUXCH: couldn't get auxch %d\n",
                         bios->display.output->i2c_index);
-               return false;
+               return 0;
        }
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        offset += 6;
-       for (i = 0; i < len; i++, offset += 2) {
+       for (i = 0; i < count; i++, offset += 2) {
                uint8_t data;
 
                ret = nouveau_dp_auxch(auxch, 9, addr, &data, 1);
                if (ret) {
                        NV_ERROR(dev, "INIT_AUXCH: rd auxch fail %d\n", ret);
-                       return false;
+                       return 0;
                }
 
                data &= bios->data[offset + 0];
@@ -2917,14 +2923,14 @@ init_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
                ret = nouveau_dp_auxch(auxch, 8, addr, &data, 1);
                if (ret) {
                        NV_ERROR(dev, "INIT_AUXCH: wr auxch fail %d\n", ret);
-                       return false;
+                       return 0;
                }
        }
 
-       return true;
+       return len;
 }
 
-static bool
+static int
 init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
 {
        /*
@@ -2941,106 +2947,99 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
        struct drm_device *dev = bios->dev;
        struct nouveau_i2c_chan *auxch;
        uint32_t addr = ROM32(bios->data[offset + 1]);
-       uint8_t len = bios->data[offset + 5];
+       uint8_t count = bios->data[offset + 5];
+       int len = 6 + count;
        int ret, i;
 
        if (!bios->display.output) {
                NV_ERROR(dev, "INIT_ZM_AUXCH: no active output\n");
-               return false;
+               return 0;
        }
 
        auxch = init_i2c_device_find(dev, bios->display.output->i2c_index);
        if (!auxch) {
                NV_ERROR(dev, "INIT_ZM_AUXCH: couldn't get auxch %d\n",
                         bios->display.output->i2c_index);
-               return false;
+               return 0;
        }
 
        if (!iexec->execute)
-               return true;
+               return len;
 
        offset += 6;
-       for (i = 0; i < len; i++, offset++) {
+       for (i = 0; i < count; i++, offset++) {
                ret = nouveau_dp_auxch(auxch, 8, addr, &bios->data[offset], 1);
                if (ret) {
                        NV_ERROR(dev, "INIT_ZM_AUXCH: wr auxch fail %d\n", ret);
-                       return false;
+                       return 0;
                }
        }
 
-       return true;
+       return len;
 }
 
 static struct init_tbl_entry itbl_entry[] = {
        /* command name                       , id  , length  , offset  , mult    , command handler                 */
        /* INIT_PROG (0x31, 15, 10, 4) removed due to no example of use */
-       { "INIT_IO_RESTRICT_PROG"             , 0x32, 11      , 6       , 4       , init_io_restrict_prog           },
-       { "INIT_REPEAT"                       , 0x33, 2       , 0       , 0       , init_repeat                     },
-       { "INIT_IO_RESTRICT_PLL"              , 0x34, 12      , 7       , 2       , init_io_restrict_pll            },
-       { "INIT_END_REPEAT"                   , 0x36, 1       , 0       , 0       , init_end_repeat                 },
-       { "INIT_COPY"                         , 0x37, 11      , 0       , 0       , init_copy                       },
-       { "INIT_NOT"                          , 0x38, 1       , 0       , 0       , init_not                        },
-       { "INIT_IO_FLAG_CONDITION"            , 0x39, 2       , 0       , 0       , init_io_flag_condition          },
-       { "INIT_INDEX_ADDRESS_LATCHED"        , 0x49, 18      , 17      , 2       , init_idx_addr_latched           },
-       { "INIT_IO_RESTRICT_PLL2"             , 0x4A, 11      , 6       , 4       , init_io_restrict_pll2           },
-       { "INIT_PLL2"                         , 0x4B, 9       , 0       , 0       , init_pll2                       },
-       { "INIT_I2C_BYTE"                     , 0x4C, 4       , 3       , 3       , init_i2c_byte                   },
-       { "INIT_ZM_I2C_BYTE"                  , 0x4D, 4       , 3       , 2       , init_zm_i2c_byte                },
-       { "INIT_ZM_I2C"                       , 0x4E, 4       , 3       , 1       , init_zm_i2c                     },
-       { "INIT_TMDS"                         , 0x4F, 5       , 0       , 0       , init_tmds                       },
-       { "INIT_ZM_TMDS_GROUP"                , 0x50, 3       , 2       , 2       , init_zm_tmds_group              },
-       { "INIT_CR_INDEX_ADDRESS_LATCHED"     , 0x51, 5       , 4       , 1       , init_cr_idx_adr_latch           },
-       { "INIT_CR"                           , 0x52, 4       , 0       , 0       , init_cr                         },
-       { "INIT_ZM_CR"                        , 0x53, 3       , 0       , 0       , init_zm_cr                      },
-       { "INIT_ZM_CR_GROUP"                  , 0x54, 2       , 1       , 2       , init_zm_cr_group                },
-       { "INIT_CONDITION_TIME"               , 0x56, 3       , 0       , 0       , init_condition_time             },
-       { "INIT_ZM_REG_SEQUENCE"              , 0x58, 6       , 5       , 4       , init_zm_reg_sequence            },
+       { "INIT_IO_RESTRICT_PROG"             , 0x32, init_io_restrict_prog           },
+       { "INIT_REPEAT"                       , 0x33, init_repeat                     },
+       { "INIT_IO_RESTRICT_PLL"              , 0x34, init_io_restrict_pll            },
+       { "INIT_END_REPEAT"                   , 0x36, init_end_repeat                 },
+       { "INIT_COPY"                         , 0x37, init_copy                       },
+       { "INIT_NOT"                          , 0x38, init_not                        },
+       { "INIT_IO_FLAG_CONDITION"            , 0x39, init_io_flag_condition          },
+       { "INIT_INDEX_ADDRESS_LATCHED"        , 0x49, init_idx_addr_latched           },
+       { "INIT_IO_RESTRICT_PLL2"             , 0x4A, init_io_restrict_pll2           },
+       { "INIT_PLL2"                         , 0x4B, init_pll2                       },
+       { "INIT_I2C_BYTE"                     , 0x4C, init_i2c_byte                   },
+       { "INIT_ZM_I2C_BYTE"                  , 0x4D, init_zm_i2c_byte                },
+       { "INIT_ZM_I2C"                       , 0x4E, init_zm_i2c                     },
+       { "INIT_TMDS"                         , 0x4F, init_tmds                       },
+       { "INIT_ZM_TMDS_GROUP"                , 0x50, init_zm_tmds_group              },
+       { "INIT_CR_INDEX_ADDRESS_LATCHED"     , 0x51, init_cr_idx_adr_latch           },
+       { "INIT_CR"                           , 0x52, init_cr                         },
+       { "INIT_ZM_CR"                        , 0x53, init_zm_cr                      },
+       { "INIT_ZM_CR_GROUP"                  , 0x54, init_zm_cr_group                },
+       { "INIT_CONDITION_TIME"               , 0x56, init_condition_time             },
+       { "INIT_ZM_REG_SEQUENCE"              , 0x58, init_zm_reg_sequence            },
        /* INIT_INDIRECT_REG (0x5A, 7, 0, 0) removed due to no example of use */
-       { "INIT_SUB_DIRECT"                   , 0x5B, 3       , 0       , 0       , init_sub_direct                 },
-       { "INIT_COPY_NV_REG"                  , 0x5F, 22      , 0       , 0       , init_copy_nv_reg                },
-       { "INIT_ZM_INDEX_IO"                  , 0x62, 5       , 0       , 0       , init_zm_index_io                },
-       { "INIT_COMPUTE_MEM"                  , 0x63, 1       , 0       , 0       , init_compute_mem                },
-       { "INIT_RESET"                        , 0x65, 13      , 0       , 0       , init_reset                      },
-       { "INIT_CONFIGURE_MEM"                , 0x66, 1       , 0       , 0       , init_configure_mem              },
-       { "INIT_CONFIGURE_CLK"                , 0x67, 1       , 0       , 0       , init_configure_clk              },
-       { "INIT_CONFIGURE_PREINIT"            , 0x68, 1       , 0       , 0       , init_configure_preinit          },
-       { "INIT_IO"                           , 0x69, 5       , 0       , 0       , init_io                         },
-       { "INIT_SUB"                          , 0x6B, 2       , 0       , 0       , init_sub                        },
-       { "INIT_RAM_CONDITION"                , 0x6D, 3       , 0       , 0       , init_ram_condition              },
-       { "INIT_NV_REG"                       , 0x6E, 13      , 0       , 0       , init_nv_reg                     },
-       { "INIT_MACRO"                        , 0x6F, 2       , 0       , 0       , init_macro                      },
-       { "INIT_DONE"                         , 0x71, 1       , 0       , 0       , init_done                       },
-       { "INIT_RESUME"                       , 0x72, 1       , 0       , 0       , init_resume                     },
+       { "INIT_SUB_DIRECT"                   , 0x5B, init_sub_direct                 },
+       { "INIT_COPY_NV_REG"                  , 0x5F, init_copy_nv_reg                },
+       { "INIT_ZM_INDEX_IO"                  , 0x62, init_zm_index_io                },
+       { "INIT_COMPUTE_MEM"                  , 0x63, init_compute_mem                },
+       { "INIT_RESET"                        , 0x65, init_reset                      },
+       { "INIT_CONFIGURE_MEM"                , 0x66, init_configure_mem              },
+       { "INIT_CONFIGURE_CLK"                , 0x67, init_configure_clk              },
+       { "INIT_CONFIGURE_PREINIT"            , 0x68, init_configure_preinit          },
+       { "INIT_IO"                           , 0x69, init_io                         },
+       { "INIT_SUB"                          , 0x6B, init_sub                        },
+       { "INIT_RAM_CONDITION"                , 0x6D, init_ram_condition              },
+       { "INIT_NV_REG"                       , 0x6E, init_nv_reg                     },
+       { "INIT_MACRO"                        , 0x6F, init_macro                      },
+       { "INIT_DONE"                         , 0x71, init_done                       },
+       { "INIT_RESUME"                       , 0x72, init_resume                     },
        /* INIT_RAM_CONDITION2 (0x73, 9, 0, 0) removed due to no example of use */
-       { "INIT_TIME"                         , 0x74, 3       , 0       , 0       , init_time                       },
-       { "INIT_CONDITION"                    , 0x75, 2       , 0       , 0       , init_condition                  },
-       { "INIT_IO_CONDITION"                 , 0x76, 2       , 0       , 0       , init_io_condition               },
-       { "INIT_INDEX_IO"                     , 0x78, 6       , 0       , 0       , init_index_io                   },
-       { "INIT_PLL"                          , 0x79, 7       , 0       , 0       , init_pll                        },
-       { "INIT_ZM_REG"                       , 0x7A, 9       , 0       , 0       , init_zm_reg                     },
-       /* INIT_RAM_RESTRICT_PLL's length is adjusted by the BIT M table */
-       { "INIT_RAM_RESTRICT_PLL"             , 0x87, 2       , 0       , 0       , init_ram_restrict_pll           },
-       { "INIT_8C"                           , 0x8C, 1       , 0       , 0       , init_8c                         },
-       { "INIT_8D"                           , 0x8D, 1       , 0       , 0       , init_8d                         },
-       { "INIT_GPIO"                         , 0x8E, 1       , 0       , 0       , init_gpio                       },
-       /* INIT_RAM_RESTRICT_ZM_REG_GROUP's mult is loaded by M table in BIT */
-       { "INIT_RAM_RESTRICT_ZM_REG_GROUP"    , 0x8F, 7       , 6       , 0       , init_ram_restrict_zm_reg_group  },
-       { "INIT_COPY_ZM_REG"                  , 0x90, 9       , 0       , 0       , init_copy_zm_reg                },
-       { "INIT_ZM_REG_GROUP_ADDRESS_LATCHED" , 0x91, 6       , 5       , 4       , init_zm_reg_group_addr_latched  },
-       { "INIT_RESERVED"                     , 0x92, 1       , 0       , 0       , init_reserved                   },
-       { "INIT_96"                           , 0x96, 17      , 0       , 0       , init_96                         },
-       { "INIT_97"                           , 0x97, 13      , 0       , 0       , init_97                         },
-       { "INIT_AUXCH"                        , 0x98, 6       , 5       , 2       , init_auxch                      },
-       { "INIT_ZM_AUXCH"                     , 0x99, 6       , 5       , 1       , init_zm_auxch                   },
-       { NULL                                , 0   , 0       , 0       , 0       , NULL                            }
+       { "INIT_TIME"                         , 0x74, init_time                       },
+       { "INIT_CONDITION"                    , 0x75, init_condition                  },
+       { "INIT_IO_CONDITION"                 , 0x76, init_io_condition               },
+       { "INIT_INDEX_IO"                     , 0x78, init_index_io                   },
+       { "INIT_PLL"                          , 0x79, init_pll                        },
+       { "INIT_ZM_REG"                       , 0x7A, init_zm_reg                     },
+       { "INIT_RAM_RESTRICT_PLL"             , 0x87, init_ram_restrict_pll           },
+       { "INIT_8C"                           , 0x8C, init_8c                         },
+       { "INIT_8D"                           , 0x8D, init_8d                         },
+       { "INIT_GPIO"                         , 0x8E, init_gpio                       },
+       { "INIT_RAM_RESTRICT_ZM_REG_GROUP"    , 0x8F, init_ram_restrict_zm_reg_group  },
+       { "INIT_COPY_ZM_REG"                  , 0x90, init_copy_zm_reg                },
+       { "INIT_ZM_REG_GROUP_ADDRESS_LATCHED" , 0x91, init_zm_reg_group_addr_latched  },
+       { "INIT_RESERVED"                     , 0x92, init_reserved                   },
+       { "INIT_96"                           , 0x96, init_96                         },
+       { "INIT_97"                           , 0x97, init_97                         },
+       { "INIT_AUXCH"                        , 0x98, init_auxch                      },
+       { "INIT_ZM_AUXCH"                     , 0x99, init_zm_auxch                   },
+       { NULL                                , 0   , NULL                            }
 };
 
-static unsigned int get_init_table_entry_length(struct nvbios *bios, unsigned int offset, int i)
-{
-       /* Calculates the length of a given init table entry. */
-       return itbl_entry[i].length + bios->data[offset + itbl_entry[i].length_offset]*itbl_entry[i].length_multiplier;
-}
-
 #define MAX_TABLE_OPS 1000
 
 static int
@@ -3056,7 +3055,7 @@ parse_init_table(struct nvbios *bios, unsigned int offset,
         * is changed back to EXECUTE.
         */
 
-       int count = 0, i;
+       int count = 0, i, res;
        uint8_t id;
 
        /*
@@ -3076,22 +3075,21 @@ parse_init_table(struct nvbios *bios, unsigned int offset,
                                offset, itbl_entry[i].id, itbl_entry[i].name);
 
                        /* execute eventual command handler */
-                       if (itbl_entry[i].handler)
-                               if (!(*itbl_entry[i].handler)(bios, offset, iexec))
-                                       break;
+                       res = (*itbl_entry[i].handler)(bios, offset, iexec);
+                       if (!res)
+                               break;
+                       /*
+                        * Add the offset of the current command including all data
+                        * of that command. The offset will then be pointing on the
+                        * next op code.
+                        */
+                       offset += res;
                } else {
                        NV_ERROR(bios->dev,
                                 "0x%04X: Init table command not found: "
                                 "0x%02X\n", offset, id);
                        return -ENOENT;
                }
-
-               /*
-                * Add the offset of the current command including all data
-                * of that command. The offset will then be pointing on the
-                * next op code.
-                */
-               offset += get_init_table_entry_length(bios, offset, i);
        }
 
        if (offset >= bios->length)
@@ -3854,7 +3852,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent,
         * script tables is a pointer to the script to execute.
         */
 
-       NV_DEBUG(dev, "Searching for output entry for %d %d %d\n",
+       NV_DEBUG_KMS(dev, "Searching for output entry for %d %d %d\n",
                        dcbent->type, dcbent->location, dcbent->or);
        otable = bios_output_config_match(dev, dcbent, table[1] +
                                          bios->display.script_table_ptr,
@@ -3884,7 +3882,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent,
        if (pxclk == 0) {
                script = ROM16(otable[6]);
                if (!script) {
-                       NV_DEBUG(dev, "output script 0 not found\n");
+                       NV_DEBUG_KMS(dev, "output script 0 not found\n");
                        return 1;
                }
 
@@ -3894,7 +3892,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent,
        if (pxclk == -1) {
                script = ROM16(otable[8]);
                if (!script) {
-                       NV_DEBUG(dev, "output script 1 not found\n");
+                       NV_DEBUG_KMS(dev, "output script 1 not found\n");
                        return 1;
                }
 
@@ -3907,7 +3905,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent,
                else
                        script = 0;
                if (!script) {
-                       NV_DEBUG(dev, "output script 2 not found\n");
+                       NV_DEBUG_KMS(dev, "output script 2 not found\n");
                        return 1;
                }
 
@@ -3931,7 +3929,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent,
                if (script)
                        script = clkcmptable(bios, script, -pxclk);
                if (!script) {
-                       NV_DEBUG(dev, "clock script 1 not found\n");
+                       NV_DEBUG_KMS(dev, "clock script 1 not found\n");
                        return 1;
                }
 
@@ -4606,10 +4604,6 @@ parse_bit_M_tbl_entry(struct drm_device *dev, struct nvbios *bios,
         * stuff that we don't use - their use currently unknown
         */
 
-       uint16_t rr_strap_xlat;
-       uint8_t rr_group_count;
-       int i;
-
        /*
         * Older bios versions don't have a sufficiently long table for
         * what we want
@@ -4618,24 +4612,13 @@ parse_bit_M_tbl_entry(struct drm_device *dev, struct nvbios *bios,
                return 0;
 
        if (bitentry->id[1] < 2) {
-               rr_group_count = bios->data[bitentry->offset + 2];
-               rr_strap_xlat = ROM16(bios->data[bitentry->offset + 3]);
+               bios->ram_restrict_group_count = bios->data[bitentry->offset + 2];
+               bios->ram_restrict_tbl_ptr = ROM16(bios->data[bitentry->offset + 3]);
        } else {
-               rr_group_count = bios->data[bitentry->offset + 0];
-               rr_strap_xlat = ROM16(bios->data[bitentry->offset + 1]);
+               bios->ram_restrict_group_count = bios->data[bitentry->offset + 0];
+               bios->ram_restrict_tbl_ptr = ROM16(bios->data[bitentry->offset + 1]);
        }
 
-       /* adjust length of INIT_87 */
-       for (i = 0; itbl_entry[i].name && (itbl_entry[i].id != 0x87); i++);
-       itbl_entry[i].length += rr_group_count * 4;
-
-       /* set up multiplier for INIT_RAM_RESTRICT_ZM_REG_GROUP */
-       for (; itbl_entry[i].name && (itbl_entry[i].id != 0x8f); i++);
-       itbl_entry[i].length_multiplier = rr_group_count * 4;
-
-       init_ram_restrict_zm_reg_group_blocklen = itbl_entry[i].length_multiplier;
-       bios->ram_restrict_tbl_ptr = rr_strap_xlat;
-
        return 0;
 }
 
@@ -5234,7 +5217,7 @@ parse_dcb_connector_table(struct nvbios *bios)
        int i;
 
        if (!bios->bdcb.connector_table_ptr) {
-               NV_DEBUG(dev, "No DCB connector table present\n");
+               NV_DEBUG_KMS(dev, "No DCB connector table present\n");
                return;
        }
 
index 1d5f10bd78ed00d9e3dcf5124c467073fe333c30..058e98c76d8990397328a4c01b87d888aecc9e28 100644 (file)
@@ -227,6 +227,7 @@ struct nvbios {
 
        uint16_t pll_limit_tbl_ptr;
        uint16_t ram_restrict_tbl_ptr;
+       uint8_t ram_restrict_group_count;
 
        uint16_t some_script_ptr; /* BIT I + 14 */
        uint16_t init96_tbl_ptr; /* BIT I + 16 */
index 320a14bceb99e70735ebfe8cc4ea33c16689e7c8..0cad6d834eb28cc386ca82e4df36b83374371e98 100644 (file)
@@ -154,6 +154,11 @@ nouveau_bo_placement_set(struct nouveau_bo *nvbo, uint32_t memtype)
        nvbo->placement.busy_placement = nvbo->placements;
        nvbo->placement.num_placement = n;
        nvbo->placement.num_busy_placement = n;
+
+       if (nvbo->pin_refcnt) {
+               while (n--)
+                       nvbo->placements[n] |= TTM_PL_FLAG_NO_EVICT;
+       }
 }
 
 int
@@ -311,8 +316,10 @@ nouveau_bo_create_ttm_backend_entry(struct ttm_bo_device *bdev)
        struct drm_device *dev = dev_priv->dev;
 
        switch (dev_priv->gart_info.type) {
+#if __OS_HAS_AGP
        case NOUVEAU_GART_AGP:
                return ttm_agp_backend_init(bdev, dev->agp->bridge);
+#endif
        case NOUVEAU_GART_SGDMA:
                return nouveau_sgdma_init_ttm(dev);
        default:
@@ -398,10 +405,16 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
        struct nouveau_bo *nvbo = nouveau_bo(bo);
 
        switch (bo->mem.mem_type) {
+       case TTM_PL_VRAM:
+               nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_TT |
+                                        TTM_PL_FLAG_SYSTEM);
+               break;
        default:
                nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_SYSTEM);
                break;
        }
+
+       *pl = nvbo->placement;
 }
 
 
@@ -453,11 +466,8 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, int no_wait,
        int ret;
 
        chan = nvbo->channel;
-       if (!chan || nvbo->tile_flags || nvbo->no_vm) {
+       if (!chan || nvbo->tile_flags || nvbo->no_vm)
                chan = dev_priv->channel;
-               if (!chan)
-                       return -EINVAL;
-       }
 
        src_offset = old_mem->mm_node->start << PAGE_SHIFT;
        dst_offset = new_mem->mm_node->start << PAGE_SHIFT;
@@ -623,7 +633,8 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
                        return ret;
        }
 
-       if (dev_priv->init_state != NOUVEAU_CARD_INIT_DONE)
+       if (dev_priv->init_state != NOUVEAU_CARD_INIT_DONE ||
+           !dev_priv->channel)
                return ttm_bo_move_memcpy(bo, evict, no_wait, new_mem);
 
        if (old_mem->mem_type == TTM_PL_SYSTEM && !bo->ttm) {
index 032cf098fa1c7cc8b8c5e22b8429aa061c9607d0..5a10deb8bdbdebc54a14dcc4be6abe78dcccfd37 100644 (file)
@@ -86,7 +86,7 @@ nouveau_connector_destroy(struct drm_connector *drm_connector)
        struct nouveau_connector *connector = nouveau_connector(drm_connector);
        struct drm_device *dev = connector->base.dev;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        if (!connector)
                return;
@@ -420,7 +420,7 @@ nouveau_connector_native_mode(struct nouveau_connector *connector)
        /* Use preferred mode if there is one.. */
        list_for_each_entry(mode, &connector->base.probed_modes, head) {
                if (mode->type & DRM_MODE_TYPE_PREFERRED) {
-                       NV_DEBUG(dev, "native mode from preferred\n");
+                       NV_DEBUG_KMS(dev, "native mode from preferred\n");
                        return drm_mode_duplicate(dev, mode);
                }
        }
@@ -445,7 +445,7 @@ nouveau_connector_native_mode(struct nouveau_connector *connector)
                largest = mode;
        }
 
-       NV_DEBUG(dev, "native mode from largest: %dx%d@%d\n",
+       NV_DEBUG_KMS(dev, "native mode from largest: %dx%d@%d\n",
                      high_w, high_h, high_v);
        return largest ? drm_mode_duplicate(dev, largest) : NULL;
 }
@@ -725,7 +725,7 @@ nouveau_connector_create(struct drm_device *dev, int index, int type)
        struct drm_encoder *encoder;
        int ret;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        nv_connector = kzalloc(sizeof(*nv_connector), GFP_KERNEL);
        if (!nv_connector)
index de61f4640e126218f406bfec08083c7326ee9ab6..9e2926c485790f376fce5af52c50cf93922df9f1 100644 (file)
@@ -187,7 +187,7 @@ nouveau_dp_link_train_adjust(struct drm_encoder *encoder, uint8_t *config)
        if (ret)
                return false;
 
-       NV_DEBUG(dev, "\t\tadjust 0x%02x 0x%02x\n", request[0], request[1]);
+       NV_DEBUG_KMS(dev, "\t\tadjust 0x%02x 0x%02x\n", request[0], request[1]);
 
        /* Keep all lanes at the same level.. */
        for (i = 0; i < nv_encoder->dp.link_nr; i++) {
@@ -228,7 +228,7 @@ nouveau_dp_link_train_commit(struct drm_encoder *encoder, uint8_t *config)
        int or = nv_encoder->or, link = !(nv_encoder->dcb->sorconf.link & 1);
        int dpe_headerlen, ret, i;
 
-       NV_DEBUG(dev, "\t\tconfig 0x%02x 0x%02x 0x%02x 0x%02x\n",
+       NV_DEBUG_KMS(dev, "\t\tconfig 0x%02x 0x%02x 0x%02x 0x%02x\n",
                 config[0], config[1], config[2], config[3]);
 
        dpe = nouveau_bios_dp_table(dev, nv_encoder->dcb, &dpe_headerlen);
@@ -276,12 +276,12 @@ nouveau_dp_link_train(struct drm_encoder *encoder)
        bool cr_done, cr_max_vs, eq_done;
        int ret = 0, i, tries, voltage;
 
-       NV_DEBUG(dev, "link training!!\n");
+       NV_DEBUG_KMS(dev, "link training!!\n");
 train:
        cr_done = eq_done = false;
 
        /* set link configuration */
-       NV_DEBUG(dev, "\tbegin train: bw %d, lanes %d\n",
+       NV_DEBUG_KMS(dev, "\tbegin train: bw %d, lanes %d\n",
                 nv_encoder->dp.link_bw, nv_encoder->dp.link_nr);
 
        ret = nouveau_dp_link_bw_set(encoder, nv_encoder->dp.link_bw);
@@ -297,7 +297,7 @@ train:
                return false;
 
        /* clock recovery */
-       NV_DEBUG(dev, "\tbegin cr\n");
+       NV_DEBUG_KMS(dev, "\tbegin cr\n");
        ret = nouveau_dp_link_train_set(encoder, DP_TRAINING_PATTERN_1);
        if (ret)
                goto stop;
@@ -314,7 +314,7 @@ train:
                ret = auxch_rd(encoder, DP_LANE0_1_STATUS, status, 2);
                if (ret)
                        break;
-               NV_DEBUG(dev, "\t\tstatus: 0x%02x 0x%02x\n",
+               NV_DEBUG_KMS(dev, "\t\tstatus: 0x%02x 0x%02x\n",
                         status[0], status[1]);
 
                cr_done = true;
@@ -346,7 +346,7 @@ train:
                goto stop;
 
        /* channel equalisation */
-       NV_DEBUG(dev, "\tbegin eq\n");
+       NV_DEBUG_KMS(dev, "\tbegin eq\n");
        ret = nouveau_dp_link_train_set(encoder, DP_TRAINING_PATTERN_2);
        if (ret)
                goto stop;
@@ -357,7 +357,7 @@ train:
                ret = auxch_rd(encoder, DP_LANE0_1_STATUS, status, 3);
                if (ret)
                        break;
-               NV_DEBUG(dev, "\t\tstatus: 0x%02x 0x%02x\n",
+               NV_DEBUG_KMS(dev, "\t\tstatus: 0x%02x 0x%02x\n",
                         status[0], status[1]);
 
                eq_done = true;
@@ -395,9 +395,9 @@ stop:
 
        /* retry at a lower setting, if possible */
        if (!ret && !(eq_done && cr_done)) {
-               NV_DEBUG(dev, "\twe failed\n");
+               NV_DEBUG_KMS(dev, "\twe failed\n");
                if (nv_encoder->dp.link_bw != DP_LINK_BW_1_62) {
-                       NV_DEBUG(dev, "retry link training at low rate\n");
+                       NV_DEBUG_KMS(dev, "retry link training at low rate\n");
                        nv_encoder->dp.link_bw = DP_LINK_BW_1_62;
                        goto train;
                }
@@ -418,7 +418,7 @@ nouveau_dp_detect(struct drm_encoder *encoder)
        if (ret)
                return false;
 
-       NV_DEBUG(dev, "encoder: link_bw %d, link_nr %d\n"
+       NV_DEBUG_KMS(dev, "encoder: link_bw %d, link_nr %d\n"
                      "display: link_bw %d, link_nr %d version 0x%02x\n",
                 nv_encoder->dcb->dpconf.link_bw,
                 nv_encoder->dcb->dpconf.link_nr,
@@ -446,7 +446,7 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,
        uint32_t tmp, ctrl, stat = 0, data32[4] = {};
        int ret = 0, i, index = auxch->rd;
 
-       NV_DEBUG(dev, "ch %d cmd %d addr 0x%x len %d\n", index, cmd, addr, data_nr);
+       NV_DEBUG_KMS(dev, "ch %d cmd %d addr 0x%x len %d\n", index, cmd, addr, data_nr);
 
        tmp = nv_rd32(dev, NV50_AUXCH_CTRL(auxch->rd));
        nv_wr32(dev, NV50_AUXCH_CTRL(auxch->rd), tmp | 0x00100000);
@@ -472,7 +472,7 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,
        if (!(cmd & 1)) {
                memcpy(data32, data, data_nr);
                for (i = 0; i < 4; i++) {
-                       NV_DEBUG(dev, "wr %d: 0x%08x\n", i, data32[i]);
+                       NV_DEBUG_KMS(dev, "wr %d: 0x%08x\n", i, data32[i]);
                        nv_wr32(dev, NV50_AUXCH_DATA_OUT(index, i), data32[i]);
                }
        }
@@ -504,7 +504,7 @@ nouveau_dp_auxch(struct nouveau_i2c_chan *auxch, int cmd, int addr,
        if (cmd & 1) {
                for (i = 0; i < 4; i++) {
                        data32[i] = nv_rd32(dev, NV50_AUXCH_DATA_IN(index, i));
-                       NV_DEBUG(dev, "rd %d: 0x%08x\n", i, data32[i]);
+                       NV_DEBUG_KMS(dev, "rd %d: 0x%08x\n", i, data32[i]);
                }
                memcpy(data, data32, data_nr);
        }
index 35249c35118fc2ca4f9d6b6ae81d2ae64dbd1a57..06eb993e08835a247aa8ea669ee41f718f0addd5 100644 (file)
 
 #include "drm_pciids.h"
 
+MODULE_PARM_DESC(ctxfw, "Use external firmware blob for grctx init (NV40)");
+int nouveau_ctxfw = 0;
+module_param_named(ctxfw, nouveau_ctxfw, int, 0400);
+
 MODULE_PARM_DESC(noagp, "Disable AGP");
 int nouveau_noagp;
 module_param_named(noagp, nouveau_noagp, int, 0400);
@@ -273,7 +277,7 @@ nouveau_pci_resume(struct pci_dev *pdev)
 
                for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
                        chan = dev_priv->fifos[i];
-                       if (!chan)
+                       if (!chan || !chan->pushbuf_bo)
                                continue;
 
                        for (j = 0; j < NOUVEAU_DMA_SKIPS; j++)
@@ -341,7 +345,7 @@ static struct drm_driver driver = {
                .owner = THIS_MODULE,
                .open = drm_open,
                .release = drm_release,
-               .ioctl = drm_ioctl,
+               .unlocked_ioctl = drm_ioctl,
                .mmap = nouveau_ttm_mmap,
                .poll = drm_poll,
                .fasync = drm_fasync,
index 88b4c7b77e7fb0929d0323243a5099e0d9be3f1c..5f8cbb79c499169be20c6ec3c0af06efe9894b7c 100644 (file)
@@ -54,6 +54,7 @@ struct nouveau_fpriv {
 #include "nouveau_drm.h"
 #include "nouveau_reg.h"
 #include "nouveau_bios.h"
+struct nouveau_grctx;
 
 #define MAX_NUM_DCB_ENTRIES 16
 
@@ -317,6 +318,7 @@ struct nouveau_pgraph_engine {
        bool accel_blocked;
        void *ctxprog;
        void *ctxvals;
+       int grctx_size;
 
        int  (*init)(struct drm_device *);
        void (*takedown)(struct drm_device *);
@@ -647,6 +649,7 @@ extern int nouveau_fbpercrtc;
 extern char *nouveau_tv_norm;
 extern int nouveau_reg_debug;
 extern char *nouveau_vbios;
+extern int nouveau_ctxfw;
 
 /* nouveau_state.c */
 extern void nouveau_preclose(struct drm_device *dev, struct drm_file *);
@@ -959,9 +962,7 @@ extern int  nv40_graph_create_context(struct nouveau_channel *);
 extern void nv40_graph_destroy_context(struct nouveau_channel *);
 extern int  nv40_graph_load_context(struct nouveau_channel *);
 extern int  nv40_graph_unload_context(struct drm_device *);
-extern int  nv40_grctx_init(struct drm_device *);
-extern void nv40_grctx_fini(struct drm_device *);
-extern void nv40_grctx_vals_load(struct drm_device *, struct nouveau_gpuobj *);
+extern void nv40_grctx_init(struct nouveau_grctx *);
 
 /* nv50_graph.c */
 extern struct nouveau_pgraph_object_class nv50_graph_grclass[];
@@ -975,6 +976,12 @@ extern int  nv50_graph_load_context(struct nouveau_channel *);
 extern int  nv50_graph_unload_context(struct drm_device *);
 extern void nv50_graph_context_switch(struct drm_device *);
 
+/* nouveau_grctx.c */
+extern int  nouveau_grctx_prog_load(struct drm_device *);
+extern void nouveau_grctx_vals_load(struct drm_device *,
+                                   struct nouveau_gpuobj *);
+extern void nouveau_grctx_fini(struct drm_device *);
+
 /* nv04_instmem.c */
 extern int  nv04_instmem_init(struct drm_device *);
 extern void nv04_instmem_takedown(struct drm_device *);
@@ -1207,14 +1214,24 @@ static inline void nv_wo32(struct drm_device *dev, struct nouveau_gpuobj *obj,
                                        pci_name(d->pdev), ##arg)
 #ifndef NV_DEBUG_NOTRACE
 #define NV_DEBUG(d, fmt, arg...) do {                                          \
-       if (drm_debug) {                                                       \
+       if (drm_debug & DRM_UT_DRIVER) {                                       \
+               NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__,             \
+                         __LINE__, ##arg);                                    \
+       }                                                                      \
+} while (0)
+#define NV_DEBUG_KMS(d, fmt, arg...) do {                                      \
+       if (drm_debug & DRM_UT_KMS) {                                          \
                NV_PRINTK(KERN_DEBUG, d, "%s:%d - " fmt, __func__,             \
                          __LINE__, ##arg);                                    \
        }                                                                      \
 } while (0)
 #else
 #define NV_DEBUG(d, fmt, arg...) do {                                          \
-       if (drm_debug)                                                         \
+       if (drm_debug & DRM_UT_DRIVER)                                         \
+               NV_PRINTK(KERN_DEBUG, d, fmt, ##arg);                          \
+} while (0)
+#define NV_DEBUG_KMS(d, fmt, arg...) do {                                      \
+       if (drm_debug & DRM_UT_KMS)                                            \
                NV_PRINTK(KERN_DEBUG, d, fmt, ##arg);                          \
 } while (0)
 #endif
index 36e8c5e4503afac7db84f6cac4d9836ed31ee3e8..84af25c238b64314997635ce4bab9ae3a9eb5721 100644 (file)
@@ -58,7 +58,7 @@ nouveau_fbcon_sync(struct fb_info *info)
        struct nouveau_channel *chan = dev_priv->channel;
        int ret, i;
 
-       if (!chan->accel_done ||
+       if (!chan || !chan->accel_done ||
            info->state != FBINFO_STATE_RUNNING ||
            info->flags & FBINFO_HWACCEL_DISABLED)
                return 0;
@@ -318,14 +318,16 @@ nouveau_fbcon_create(struct drm_device *dev, uint32_t fb_width,
        par->nouveau_fb = nouveau_fb;
        par->dev = dev;
 
-       switch (dev_priv->card_type) {
-       case NV_50:
-               nv50_fbcon_accel_init(info);
-               break;
-       default:
-               nv04_fbcon_accel_init(info);
-               break;
-       };
+       if (dev_priv->channel) {
+               switch (dev_priv->card_type) {
+               case NV_50:
+                       nv50_fbcon_accel_init(info);
+                       break;
+               default:
+                       nv04_fbcon_accel_init(info);
+                       break;
+               };
+       }
 
        nouveau_fbcon_zfill(dev);
 
@@ -347,7 +349,7 @@ out:
 int
 nouveau_fbcon_probe(struct drm_device *dev)
 {
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        return drm_fb_helper_single_fb_probe(dev, 32, nouveau_fbcon_create);
 }
index 0cff7eb3690a494b14e24bdb882712ca83a63806..dacac9a0842a01c91b25ff091d14ae18b6ef258c 100644 (file)
@@ -205,7 +205,7 @@ nouveau_fence_wait(void *sync_obj, void *sync_arg, bool lazy, bool intr)
                        schedule_timeout(1);
 
                if (intr && signal_pending(current)) {
-                       ret = -ERESTART;
+                       ret = -ERESTARTSYS;
                        break;
                }
        }
index 11f831f0ddc5373f17eb3fb95a20fdac355baa22..18fd8ac9fca7cd4c8341eac4210f6530238b5209 100644 (file)
@@ -342,8 +342,6 @@ retry:
                        }
 
                        ret = ttm_bo_wait_cpu(&nvbo->bo, false);
-                       if (ret == -ERESTART)
-                               ret = -EAGAIN;
                        if (ret)
                                return ret;
                        goto retry;
@@ -915,8 +913,6 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
                        goto out;
 
                ret = ttm_bo_wait_cpu(&nvbo->bo, no_wait);
-               if (ret == -ERESTART)
-                       ret = -EAGAIN;
                if (ret)
                        goto out;
        }
@@ -925,9 +921,6 @@ nouveau_gem_ioctl_cpu_prep(struct drm_device *dev, void *data,
                ret = ttm_bo_wait(&nvbo->bo, false, false, no_wait);
        } else {
                ret = ttm_bo_synccpu_write_grab(&nvbo->bo, no_wait);
-               if (ret == -ERESTART)
-                       ret = -EAGAIN;
-               else
                if (ret == 0)
                        nvbo->cpu_filp = file_priv;
        }
diff --git a/drivers/gpu/drm/nouveau/nouveau_grctx.c b/drivers/gpu/drm/nouveau/nouveau_grctx.c
new file mode 100644 (file)
index 0000000..419f4c2
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2009 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs
+ */
+
+#include <linux/firmware.h>
+
+#include "drmP.h"
+#include "nouveau_drv.h"
+
+struct nouveau_ctxprog {
+       uint32_t signature;
+       uint8_t  version;
+       uint16_t length;
+       uint32_t data[];
+} __attribute__ ((packed));
+
+struct nouveau_ctxvals {
+       uint32_t signature;
+       uint8_t  version;
+       uint32_t length;
+       struct {
+               uint32_t offset;
+               uint32_t value;
+       } data[];
+} __attribute__ ((packed));
+
+int
+nouveau_grctx_prog_load(struct drm_device *dev)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
+       const int chipset = dev_priv->chipset;
+       const struct firmware *fw;
+       const struct nouveau_ctxprog *cp;
+       const struct nouveau_ctxvals *cv;
+       char name[32];
+       int ret, i;
+
+       if (pgraph->accel_blocked)
+               return -ENODEV;
+
+       if (!pgraph->ctxprog) {
+               sprintf(name, "nouveau/nv%02x.ctxprog", chipset);
+               ret = request_firmware(&fw, name, &dev->pdev->dev);
+               if (ret) {
+                       NV_ERROR(dev, "No ctxprog for NV%02x\n", chipset);
+                       return ret;
+               }
+
+               pgraph->ctxprog = kmalloc(fw->size, GFP_KERNEL);
+               if (!pgraph->ctxprog) {
+                       NV_ERROR(dev, "OOM copying ctxprog\n");
+                       release_firmware(fw);
+                       return -ENOMEM;
+               }
+               memcpy(pgraph->ctxprog, fw->data, fw->size);
+
+               cp = pgraph->ctxprog;
+               if (le32_to_cpu(cp->signature) != 0x5043564e ||
+                   cp->version != 0 ||
+                   le16_to_cpu(cp->length) != ((fw->size - 7) / 4)) {
+                       NV_ERROR(dev, "ctxprog invalid\n");
+                       release_firmware(fw);
+                       nouveau_grctx_fini(dev);
+                       return -EINVAL;
+               }
+               release_firmware(fw);
+       }
+
+       if (!pgraph->ctxvals) {
+               sprintf(name, "nouveau/nv%02x.ctxvals", chipset);
+               ret = request_firmware(&fw, name, &dev->pdev->dev);
+               if (ret) {
+                       NV_ERROR(dev, "No ctxvals for NV%02x\n", chipset);
+                       nouveau_grctx_fini(dev);
+                       return ret;
+               }
+
+               pgraph->ctxvals = kmalloc(fw->size, GFP_KERNEL);
+               if (!pgraph->ctxprog) {
+                       NV_ERROR(dev, "OOM copying ctxprog\n");
+                       release_firmware(fw);
+                       nouveau_grctx_fini(dev);
+                       return -ENOMEM;
+               }
+               memcpy(pgraph->ctxvals, fw->data, fw->size);
+
+               cv = (void *)pgraph->ctxvals;
+               if (le32_to_cpu(cv->signature) != 0x5643564e ||
+                   cv->version != 0 ||
+                   le32_to_cpu(cv->length) != ((fw->size - 9) / 8)) {
+                       NV_ERROR(dev, "ctxvals invalid\n");
+                       release_firmware(fw);
+                       nouveau_grctx_fini(dev);
+                       return -EINVAL;
+               }
+               release_firmware(fw);
+       }
+
+       cp = pgraph->ctxprog;
+
+       nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
+       for (i = 0; i < le16_to_cpu(cp->length); i++)
+               nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA,
+                       le32_to_cpu(cp->data[i]));
+
+       return 0;
+}
+
+void
+nouveau_grctx_fini(struct drm_device *dev)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
+
+       if (pgraph->ctxprog) {
+               kfree(pgraph->ctxprog);
+               pgraph->ctxprog = NULL;
+       }
+
+       if (pgraph->ctxvals) {
+               kfree(pgraph->ctxprog);
+               pgraph->ctxvals = NULL;
+       }
+}
+
+void
+nouveau_grctx_vals_load(struct drm_device *dev, struct nouveau_gpuobj *ctx)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
+       struct nouveau_ctxvals *cv = pgraph->ctxvals;
+       int i;
+
+       if (!cv)
+               return;
+
+       for (i = 0; i < le32_to_cpu(cv->length); i++)
+               nv_wo32(dev, ctx, le32_to_cpu(cv->data[i].offset),
+                       le32_to_cpu(cv->data[i].value));
+}
diff --git a/drivers/gpu/drm/nouveau/nouveau_grctx.h b/drivers/gpu/drm/nouveau/nouveau_grctx.h
new file mode 100644 (file)
index 0000000..5d39c4c
--- /dev/null
@@ -0,0 +1,133 @@
+#ifndef __NOUVEAU_GRCTX_H__
+#define __NOUVEAU_GRCTX_H__
+
+struct nouveau_grctx {
+       struct drm_device *dev;
+
+       enum {
+               NOUVEAU_GRCTX_PROG,
+               NOUVEAU_GRCTX_VALS
+       } mode;
+       void *data;
+
+       uint32_t ctxprog_max;
+       uint32_t ctxprog_len;
+       uint32_t ctxprog_reg;
+       int      ctxprog_label[32];
+       uint32_t ctxvals_pos;
+       uint32_t ctxvals_base;
+};
+
+#ifdef CP_CTX
+static inline void
+cp_out(struct nouveau_grctx *ctx, uint32_t inst)
+{
+       uint32_t *ctxprog = ctx->data;
+
+       if (ctx->mode != NOUVEAU_GRCTX_PROG)
+               return;
+
+       BUG_ON(ctx->ctxprog_len == ctx->ctxprog_max);
+       ctxprog[ctx->ctxprog_len++] = inst;
+}
+
+static inline void
+cp_lsr(struct nouveau_grctx *ctx, uint32_t val)
+{
+       cp_out(ctx, CP_LOAD_SR | val);
+}
+
+static inline void
+cp_ctx(struct nouveau_grctx *ctx, uint32_t reg, uint32_t length)
+{
+       ctx->ctxprog_reg = (reg - 0x00400000) >> 2;
+
+       ctx->ctxvals_base = ctx->ctxvals_pos;
+       ctx->ctxvals_pos = ctx->ctxvals_base + length;
+
+       if (length > (CP_CTX_COUNT >> CP_CTX_COUNT_SHIFT)) {
+               cp_lsr(ctx, length);
+               length = 0;
+       }
+
+       cp_out(ctx, CP_CTX | (length << CP_CTX_COUNT_SHIFT) | ctx->ctxprog_reg);
+}
+
+static inline void
+cp_name(struct nouveau_grctx *ctx, int name)
+{
+       uint32_t *ctxprog = ctx->data;
+       int i;
+
+       if (ctx->mode != NOUVEAU_GRCTX_PROG)
+               return;
+
+       ctx->ctxprog_label[name] = ctx->ctxprog_len;
+       for (i = 0; i < ctx->ctxprog_len; i++) {
+               if ((ctxprog[i] & 0xfff00000) != 0xff400000)
+                       continue;
+               if ((ctxprog[i] & CP_BRA_IP) != ((name) << CP_BRA_IP_SHIFT))
+                       continue;
+               ctxprog[i] = (ctxprog[i] & 0x00ff00ff) |
+                            (ctx->ctxprog_len << CP_BRA_IP_SHIFT);
+       }
+}
+
+static inline void
+_cp_bra(struct nouveau_grctx *ctx, u32 mod, int flag, int state, int name)
+{
+       int ip = 0;
+
+       if (mod != 2) {
+               ip = ctx->ctxprog_label[name] << CP_BRA_IP_SHIFT;
+               if (ip == 0)
+                       ip = 0xff000000 | (name << CP_BRA_IP_SHIFT);
+       }
+
+       cp_out(ctx, CP_BRA | (mod << 18) | ip | flag |
+                   (state ? 0 : CP_BRA_IF_CLEAR));
+}
+#define cp_bra(c,f,s,n) _cp_bra((c), 0, CP_FLAG_##f, CP_FLAG_##f##_##s, n)
+#ifdef CP_BRA_MOD
+#define cp_cal(c,f,s,n) _cp_bra((c), 1, CP_FLAG_##f, CP_FLAG_##f##_##s, n)
+#define cp_ret(c,f,s) _cp_bra((c), 2, CP_FLAG_##f, CP_FLAG_##f##_##s, 0)
+#endif
+
+static inline void
+_cp_wait(struct nouveau_grctx *ctx, int flag, int state)
+{
+       cp_out(ctx, CP_WAIT | flag | (state ? CP_WAIT_SET : 0));
+}
+#define cp_wait(c,f,s) _cp_wait((c), CP_FLAG_##f, CP_FLAG_##f##_##s)
+
+static inline void
+_cp_set(struct nouveau_grctx *ctx, int flag, int state)
+{
+       cp_out(ctx, CP_SET | flag | (state ? CP_SET_1 : 0));
+}
+#define cp_set(c,f,s) _cp_set((c), CP_FLAG_##f, CP_FLAG_##f##_##s)
+
+static inline void
+cp_pos(struct nouveau_grctx *ctx, int offset)
+{
+       ctx->ctxvals_pos = offset;
+       ctx->ctxvals_base = ctx->ctxvals_pos;
+
+       cp_lsr(ctx, ctx->ctxvals_pos);
+       cp_out(ctx, CP_SET_CONTEXT_POINTER);
+}
+
+static inline void
+gr_def(struct nouveau_grctx *ctx, uint32_t reg, uint32_t val)
+{
+       if (ctx->mode != NOUVEAU_GRCTX_VALS)
+               return;
+
+       reg = (reg - 0x00400000) / 4;
+       reg = (reg - ctx->ctxprog_reg) + ctx->ctxvals_base;
+
+       nv_wo32(ctx->dev, ctx->data, reg, val);
+}
+#endif
+
+#endif
index a2c30f4611ba52b3ad6a0856fcf5e5b83d4cf629..475ba810bba36ef32ac824903476e9304ffb01ce 100644 (file)
@@ -61,12 +61,10 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
        if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
                fn = nouveau_compat_ioctls[nr - DRM_COMMAND_BASE];
 #endif
-       lock_kernel();    /* XXX for now */
        if (fn != NULL)
                ret = (*fn)(filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
-       unlock_kernel();
+               ret = drm_ioctl(filp, cmd, arg);
 
        return ret;
 }
index 02755712ed3d3aa03641478f52c0ef65ab7b9a29..5158a12f7844782acd164797be5f170d45072c2d 100644 (file)
@@ -407,6 +407,7 @@ uint64_t nouveau_mem_fb_amount(struct drm_device *dev)
        return 0;
 }
 
+#if __OS_HAS_AGP
 static void nouveau_mem_reset_agp(struct drm_device *dev)
 {
        uint32_t saved_pci_nv_1, saved_pci_nv_19, pmc_enable;
@@ -432,10 +433,12 @@ static void nouveau_mem_reset_agp(struct drm_device *dev)
        nv_wr32(dev, NV04_PBUS_PCI_NV_19, saved_pci_nv_19);
        nv_wr32(dev, NV04_PBUS_PCI_NV_1, saved_pci_nv_1);
 }
+#endif
 
 int
 nouveau_mem_init_agp(struct drm_device *dev)
 {
+#if __OS_HAS_AGP
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        struct drm_agp_info info;
        struct drm_agp_mode mode;
@@ -471,6 +474,7 @@ nouveau_mem_init_agp(struct drm_device *dev)
        dev_priv->gart_info.type        = NOUVEAU_GART_AGP;
        dev_priv->gart_info.aper_base   = info.aperture_base;
        dev_priv->gart_info.aper_size   = info.aperture_size;
+#endif
        return 0;
 }
 
index 2ed41d339f6a6e8edcb4c474d3566cc8e515c6ed..e76ec2d207a97f9f7d90c1847bfbfffdc0c7c958 100644 (file)
@@ -299,12 +299,57 @@ nouveau_vga_set_decode(void *priv, bool state)
                return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM;
 }
 
+static int
+nouveau_card_init_channel(struct drm_device *dev)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct nouveau_gpuobj *gpuobj;
+       int ret;
+
+       ret = nouveau_channel_alloc(dev, &dev_priv->channel,
+                                   (struct drm_file *)-2,
+                                   NvDmaFB, NvDmaTT);
+       if (ret)
+               return ret;
+
+       gpuobj = NULL;
+       ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY,
+                                    0, nouveau_mem_fb_amount(dev),
+                                    NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM,
+                                    &gpuobj);
+       if (ret)
+               goto out_err;
+
+       ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaVRAM,
+                                    gpuobj, NULL);
+       if (ret)
+               goto out_err;
+
+       gpuobj = NULL;
+       ret = nouveau_gpuobj_gart_dma_new(dev_priv->channel, 0,
+                                         dev_priv->gart_info.aper_size,
+                                         NV_DMA_ACCESS_RW, &gpuobj, NULL);
+       if (ret)
+               goto out_err;
+
+       ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaGART,
+                                    gpuobj, NULL);
+       if (ret)
+               goto out_err;
+
+       return 0;
+out_err:
+       nouveau_gpuobj_del(dev, &gpuobj);
+       nouveau_channel_free(dev_priv->channel);
+       dev_priv->channel = NULL;
+       return ret;
+}
+
 int
 nouveau_card_init(struct drm_device *dev)
 {
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        struct nouveau_engine *engine;
-       struct nouveau_gpuobj *gpuobj;
        int ret;
 
        NV_DEBUG(dev, "prev state = %d\n", dev_priv->init_state);
@@ -317,7 +362,7 @@ nouveau_card_init(struct drm_device *dev)
        /* Initialise internal driver API hooks */
        ret = nouveau_init_engine_ptrs(dev);
        if (ret)
-               return ret;
+               goto out;
        engine = &dev_priv->engine;
        dev_priv->init_state = NOUVEAU_CARD_INIT_FAILED;
 
@@ -325,12 +370,12 @@ nouveau_card_init(struct drm_device *dev)
        if (drm_core_check_feature(dev, DRIVER_MODESET)) {
                ret = nouveau_bios_init(dev);
                if (ret)
-                       return ret;
+                       goto out;
        }
 
        ret = nouveau_gpuobj_early_init(dev);
        if (ret)
-               return ret;
+               goto out_bios;
 
        /* Initialise instance memory, must happen before mem_init so we
         * know exactly how much VRAM we're able to use for "normal"
@@ -338,100 +383,68 @@ nouveau_card_init(struct drm_device *dev)
         */
        ret = engine->instmem.init(dev);
        if (ret)
-               return ret;
+               goto out_gpuobj_early;
 
        /* Setup the memory manager */
        ret = nouveau_mem_init(dev);
        if (ret)
-               return ret;
+               goto out_instmem;
 
        ret = nouveau_gpuobj_init(dev);
        if (ret)
-               return ret;
+               goto out_mem;
 
        /* PMC */
        ret = engine->mc.init(dev);
        if (ret)
-               return ret;
+               goto out_gpuobj;
 
        /* PTIMER */
        ret = engine->timer.init(dev);
        if (ret)
-               return ret;
+               goto out_mc;
 
        /* PFB */
        ret = engine->fb.init(dev);
        if (ret)
-               return ret;
+               goto out_timer;
 
        /* PGRAPH */
        ret = engine->graph.init(dev);
        if (ret)
-               return ret;
+               goto out_fb;
 
        /* PFIFO */
        ret = engine->fifo.init(dev);
        if (ret)
-               return ret;
+               goto out_graph;
 
        /* this call irq_preinstall, register irq handler and
         * call irq_postinstall
         */
        ret = drm_irq_install(dev);
        if (ret)
-               return ret;
+               goto out_fifo;
 
        ret = drm_vblank_init(dev, 0);
        if (ret)
-               return ret;
+               goto out_irq;
 
        /* what about PVIDEO/PCRTC/PRAMDAC etc? */
 
-       ret = nouveau_channel_alloc(dev, &dev_priv->channel,
-                                   (struct drm_file *)-2,
-                                   NvDmaFB, NvDmaTT);
-       if (ret)
-               return ret;
-
-       gpuobj = NULL;
-       ret = nouveau_gpuobj_dma_new(dev_priv->channel, NV_CLASS_DMA_IN_MEMORY,
-                                    0, nouveau_mem_fb_amount(dev),
-                                    NV_DMA_ACCESS_RW, NV_DMA_TARGET_VIDMEM,
-                                    &gpuobj);
-       if (ret)
-               return ret;
-
-       ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaVRAM,
-                                    gpuobj, NULL);
-       if (ret) {
-               nouveau_gpuobj_del(dev, &gpuobj);
-               return ret;
-       }
-
-       gpuobj = NULL;
-       ret = nouveau_gpuobj_gart_dma_new(dev_priv->channel, 0,
-                                         dev_priv->gart_info.aper_size,
-                                         NV_DMA_ACCESS_RW, &gpuobj, NULL);
-       if (ret)
-               return ret;
-
-       ret = nouveau_gpuobj_ref_add(dev, dev_priv->channel, NvDmaGART,
-                                    gpuobj, NULL);
-       if (ret) {
-               nouveau_gpuobj_del(dev, &gpuobj);
-               return ret;
+       if (!engine->graph.accel_blocked) {
+               ret = nouveau_card_init_channel(dev);
+               if (ret)
+                       goto out_irq;
        }
 
        if (drm_core_check_feature(dev, DRIVER_MODESET)) {
-               if (dev_priv->card_type >= NV_50) {
+               if (dev_priv->card_type >= NV_50)
                        ret = nv50_display_create(dev);
-                       if (ret)
-                               return ret;
-               } else {
+               else
                        ret = nv04_display_create(dev);
-                       if (ret)
-                               return ret;
-               }
+               if (ret)
+                       goto out_irq;
        }
 
        ret = nouveau_backlight_init(dev);
@@ -444,6 +457,32 @@ nouveau_card_init(struct drm_device *dev)
                drm_helper_initial_config(dev);
 
        return 0;
+
+out_irq:
+       drm_irq_uninstall(dev);
+out_fifo:
+       engine->fifo.takedown(dev);
+out_graph:
+       engine->graph.takedown(dev);
+out_fb:
+       engine->fb.takedown(dev);
+out_timer:
+       engine->timer.takedown(dev);
+out_mc:
+       engine->mc.takedown(dev);
+out_gpuobj:
+       nouveau_gpuobj_takedown(dev);
+out_mem:
+       nouveau_mem_close(dev);
+out_instmem:
+       engine->instmem.takedown(dev);
+out_gpuobj_early:
+       nouveau_gpuobj_late_takedown(dev);
+out_bios:
+       nouveau_bios_takedown(dev);
+out:
+       vga_client_register(dev->pdev, NULL, NULL, NULL);
+       return ret;
 }
 
 static void nouveau_card_takedown(struct drm_device *dev)
index b91363606055dc0834f89ad6bab718dad44cbfd7..d2f143ed97c1000e0f3fa925eebb9cbcf3c3f29a 100644 (file)
@@ -143,10 +143,10 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod
        state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK;
 
        if (pv->NM2)
-               NV_TRACE(dev, "vpll: n1 %d n2 %d m1 %d m2 %d log2p %d\n",
+               NV_DEBUG_KMS(dev, "vpll: n1 %d n2 %d m1 %d m2 %d log2p %d\n",
                         pv->N1, pv->N2, pv->M1, pv->M2, pv->log2P);
        else
-               NV_TRACE(dev, "vpll: n %d m %d log2p %d\n",
+               NV_DEBUG_KMS(dev, "vpll: n %d m %d log2p %d\n",
                         pv->N1, pv->M1, pv->log2P);
 
        nv_crtc->cursor.set_offset(nv_crtc, nv_crtc->cursor.offset);
@@ -160,7 +160,7 @@ nv_crtc_dpms(struct drm_crtc *crtc, int mode)
        unsigned char seq1 = 0, crtc17 = 0;
        unsigned char crtc1A;
 
-       NV_TRACE(dev, "Setting dpms mode %d on CRTC %d\n", mode,
+       NV_DEBUG_KMS(dev, "Setting dpms mode %d on CRTC %d\n", mode,
                                                        nv_crtc->index);
 
        if (nv_crtc->last_dpms == mode) /* Don't do unnecesary mode changes. */
@@ -603,7 +603,7 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
        struct drm_nouveau_private *dev_priv = dev->dev_private;
 
-       NV_DEBUG(dev, "CTRC mode on CRTC %d:\n", nv_crtc->index);
+       NV_DEBUG_KMS(dev, "CTRC mode on CRTC %d:\n", nv_crtc->index);
        drm_mode_debug_printmodeline(adjusted_mode);
 
        /* unlock must come after turning off FP_TG_CONTROL in output_prepare */
@@ -703,7 +703,7 @@ static void nv_crtc_destroy(struct drm_crtc *crtc)
 {
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
 
-       NV_DEBUG(crtc->dev, "\n");
+       NV_DEBUG_KMS(crtc->dev, "\n");
 
        if (!nv_crtc)
                return;
index a5fa51714e874e8ee5e60bf200516095ebf2d950..d9f32879ba384aa491191a187981f2f62ffe2c51 100644 (file)
@@ -205,7 +205,7 @@ out:
        NVWriteVgaSeq(dev, 0, NV_VIO_SR_CLOCK_INDEX, saved_seq1);
 
        if (blue == 0x18) {
-               NV_TRACE(dev, "Load detected on head A\n");
+               NV_INFO(dev, "Load detected on head A\n");
                return connector_status_connected;
        }
 
@@ -350,14 +350,10 @@ static void nv04_dac_mode_set(struct drm_encoder *encoder,
                              struct drm_display_mode *mode,
                              struct drm_display_mode *adjusted_mode)
 {
-       struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
        struct drm_device *dev = encoder->dev;
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        int head = nouveau_crtc(encoder->crtc)->index;
 
-       NV_TRACE(dev, "%s called for encoder %d\n", __func__,
-                     nv_encoder->dcb->index);
-
        if (nv_gf4_disp_arch(dev)) {
                struct drm_encoder *rebind;
                uint32_t dac_offset = nv04_dac_output_offset(encoder);
@@ -466,7 +462,7 @@ static void nv04_dac_destroy(struct drm_encoder *encoder)
 {
        struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
 
-       NV_DEBUG(encoder->dev, "\n");
+       NV_DEBUG_KMS(encoder->dev, "\n");
 
        drm_encoder_cleanup(encoder);
        kfree(nv_encoder);
index e5b33339d595f262dd024a7d2349a48d9471b1b2..483f875bdb6a479f04b5387b9d20d0e713915c74 100644 (file)
@@ -261,7 +261,7 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder,
        struct drm_display_mode *output_mode = &nv_encoder->mode;
        uint32_t mode_ratio, panel_ratio;
 
-       NV_DEBUG(dev, "Output mode on CRTC %d:\n", nv_crtc->index);
+       NV_DEBUG_KMS(dev, "Output mode on CRTC %d:\n", nv_crtc->index);
        drm_mode_debug_printmodeline(output_mode);
 
        /* Initialize the FP registers in this CRTC. */
@@ -413,7 +413,9 @@ static void nv04_dfp_commit(struct drm_encoder *encoder)
        struct dcb_entry *dcbe = nv_encoder->dcb;
        int head = nouveau_crtc(encoder->crtc)->index;
 
-       NV_TRACE(dev, "%s called for encoder %d\n", __func__, nv_encoder->dcb->index);
+       NV_INFO(dev, "Output %s is running on CRTC %d using output %c\n",
+               drm_get_connector_name(&nouveau_encoder_connector_get(nv_encoder)->base),
+               nv_crtc->index, '@' + ffs(nv_encoder->dcb->or));
 
        if (dcbe->type == OUTPUT_TMDS)
                run_tmds_table(dev, dcbe, head, nv_encoder->mode.clock);
@@ -550,7 +552,7 @@ static void nv04_dfp_destroy(struct drm_encoder *encoder)
 {
        struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
 
-       NV_DEBUG(encoder->dev, "\n");
+       NV_DEBUG_KMS(encoder->dev, "\n");
 
        drm_encoder_cleanup(encoder);
        kfree(nv_encoder);
index b47c757ff48b3d9294de8bf6b2efd43cc90281ff..ef77215fa5b98372f780911d2e8006fce458f471 100644 (file)
@@ -99,10 +99,11 @@ nv04_display_create(struct drm_device *dev)
        uint16_t connector[16] = { 0 };
        int i, ret;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        if (nv_two_heads(dev))
                nv04_display_store_initial_head_owner(dev);
+       nouveau_hw_save_vga_fonts(dev, 1);
 
        drm_mode_config_init(dev);
        drm_mode_create_scaling_mode_property(dev);
@@ -203,8 +204,6 @@ nv04_display_create(struct drm_device *dev)
        /* Save previous state */
        NVLockVgaCrtcs(dev, false);
 
-       nouveau_hw_save_vga_fonts(dev, 1);
-
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
                crtc->funcs->save(crtc);
 
@@ -223,7 +222,7 @@ nv04_display_destroy(struct drm_device *dev)
        struct drm_encoder *encoder;
        struct drm_crtc *crtc;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        /* Turn every CRTC off. */
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
@@ -246,9 +245,9 @@ nv04_display_destroy(struct drm_device *dev)
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
                crtc->funcs->restore(crtc);
 
-       nouveau_hw_save_vga_fonts(dev, 0);
-
        drm_mode_config_cleanup(dev);
+
+       nouveau_hw_save_vga_fonts(dev, 0);
 }
 
 void
index 396ee92118f6e9605edb2d73961a626960b45e0c..d561d773c0f4e2d41a4a7473ac34b5a8408f0e40 100644 (file)
@@ -543,7 +543,7 @@ nv04_graph_mthd_set_operation(struct nouveau_channel *chan, int grclass,
 
        nv_wi32(dev, instance, tmp);
        nv_wr32(dev, NV04_PGRAPH_CTX_SWITCH1, tmp);
-       nv_wr32(dev, NV04_PGRAPH_CTX_CACHE1 + subc, tmp);
+       nv_wr32(dev, NV04_PGRAPH_CTX_CACHE1 + (subc<<2), tmp);
        return 0;
 }
 
index 6bf6804bb0efee1c5f525d833b34d711e1762ac5..6870e0ee2e7e315b85c12342f84f5c2732705fa8 100644 (file)
@@ -389,49 +389,50 @@ struct graph_state {
        int nv10[ARRAY_SIZE(nv10_graph_ctx_regs)];
        int nv17[ARRAY_SIZE(nv17_graph_ctx_regs)];
        struct pipe_state pipe_state;
+       uint32_t lma_window[4];
 };
 
+#define PIPE_SAVE(dev, state, addr)                                    \
+       do {                                                            \
+               int __i;                                                \
+               nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, addr);           \
+               for (__i = 0; __i < ARRAY_SIZE(state); __i++)           \
+                       state[__i] = nv_rd32(dev, NV10_PGRAPH_PIPE_DATA); \
+       } while (0)
+
+#define PIPE_RESTORE(dev, state, addr)                                 \
+       do {                                                            \
+               int __i;                                                \
+               nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, addr);           \
+               for (__i = 0; __i < ARRAY_SIZE(state); __i++)           \
+                       nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, state[__i]); \
+       } while (0)
+
 static void nv10_graph_save_pipe(struct nouveau_channel *chan)
 {
        struct drm_device *dev = chan->dev;
        struct graph_state *pgraph_ctx = chan->pgraph_ctx;
-       struct pipe_state *fifo_pipe_state = &pgraph_ctx->pipe_state;
-       int i;
-#define PIPE_SAVE(addr) \
-       do { \
-               nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, addr); \
-               for (i = 0; i < ARRAY_SIZE(fifo_pipe_state->pipe_##addr); i++) \
-                       fifo_pipe_state->pipe_##addr[i] = nv_rd32(dev, NV10_PGRAPH_PIPE_DATA); \
-       } while (0)
-
-       PIPE_SAVE(0x4400);
-       PIPE_SAVE(0x0200);
-       PIPE_SAVE(0x6400);
-       PIPE_SAVE(0x6800);
-       PIPE_SAVE(0x6c00);
-       PIPE_SAVE(0x7000);
-       PIPE_SAVE(0x7400);
-       PIPE_SAVE(0x7800);
-       PIPE_SAVE(0x0040);
-       PIPE_SAVE(0x0000);
-
-#undef PIPE_SAVE
+       struct pipe_state *pipe = &pgraph_ctx->pipe_state;
+
+       PIPE_SAVE(dev, pipe->pipe_0x4400, 0x4400);
+       PIPE_SAVE(dev, pipe->pipe_0x0200, 0x0200);
+       PIPE_SAVE(dev, pipe->pipe_0x6400, 0x6400);
+       PIPE_SAVE(dev, pipe->pipe_0x6800, 0x6800);
+       PIPE_SAVE(dev, pipe->pipe_0x6c00, 0x6c00);
+       PIPE_SAVE(dev, pipe->pipe_0x7000, 0x7000);
+       PIPE_SAVE(dev, pipe->pipe_0x7400, 0x7400);
+       PIPE_SAVE(dev, pipe->pipe_0x7800, 0x7800);
+       PIPE_SAVE(dev, pipe->pipe_0x0040, 0x0040);
+       PIPE_SAVE(dev, pipe->pipe_0x0000, 0x0000);
 }
 
 static void nv10_graph_load_pipe(struct nouveau_channel *chan)
 {
        struct drm_device *dev = chan->dev;
        struct graph_state *pgraph_ctx = chan->pgraph_ctx;
-       struct pipe_state *fifo_pipe_state = &pgraph_ctx->pipe_state;
-       int i;
+       struct pipe_state *pipe = &pgraph_ctx->pipe_state;
        uint32_t xfmode0, xfmode1;
-#define PIPE_RESTORE(addr) \
-       do { \
-               nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, addr); \
-               for (i = 0; i < ARRAY_SIZE(fifo_pipe_state->pipe_##addr); i++) \
-                       nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, fifo_pipe_state->pipe_##addr[i]); \
-       } while (0)
-
+       int i;
 
        nouveau_wait_for_idle(dev);
        /* XXX check haiku comments */
@@ -457,24 +458,22 @@ static void nv10_graph_load_pipe(struct nouveau_channel *chan)
        nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000008);
 
 
-       PIPE_RESTORE(0x0200);
+       PIPE_RESTORE(dev, pipe->pipe_0x0200, 0x0200);
        nouveau_wait_for_idle(dev);
 
        /* restore XFMODE */
        nv_wr32(dev, NV10_PGRAPH_XFMODE0, xfmode0);
        nv_wr32(dev, NV10_PGRAPH_XFMODE1, xfmode1);
-       PIPE_RESTORE(0x6400);
-       PIPE_RESTORE(0x6800);
-       PIPE_RESTORE(0x6c00);
-       PIPE_RESTORE(0x7000);
-       PIPE_RESTORE(0x7400);
-       PIPE_RESTORE(0x7800);
-       PIPE_RESTORE(0x4400);
-       PIPE_RESTORE(0x0000);
-       PIPE_RESTORE(0x0040);
+       PIPE_RESTORE(dev, pipe->pipe_0x6400, 0x6400);
+       PIPE_RESTORE(dev, pipe->pipe_0x6800, 0x6800);
+       PIPE_RESTORE(dev, pipe->pipe_0x6c00, 0x6c00);
+       PIPE_RESTORE(dev, pipe->pipe_0x7000, 0x7000);
+       PIPE_RESTORE(dev, pipe->pipe_0x7400, 0x7400);
+       PIPE_RESTORE(dev, pipe->pipe_0x7800, 0x7800);
+       PIPE_RESTORE(dev, pipe->pipe_0x4400, 0x4400);
+       PIPE_RESTORE(dev, pipe->pipe_0x0000, 0x0000);
+       PIPE_RESTORE(dev, pipe->pipe_0x0040, 0x0040);
        nouveau_wait_for_idle(dev);
-
-#undef PIPE_RESTORE
 }
 
 static void nv10_graph_create_pipe(struct nouveau_channel *chan)
@@ -832,6 +831,9 @@ int nv10_graph_init(struct drm_device *dev)
                                      (1<<31));
        if (dev_priv->chipset >= 0x17) {
                nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x1f000000);
+               nv_wr32(dev, 0x400a10, 0x3ff3fb6);
+               nv_wr32(dev, 0x400838, 0x2f8684);
+               nv_wr32(dev, 0x40083c, 0x115f3f);
                nv_wr32(dev, 0x004006b0, 0x40000020);
        } else
                nv_wr32(dev, NV10_PGRAPH_DEBUG_4, 0x00000000);
@@ -867,6 +869,115 @@ void nv10_graph_takedown(struct drm_device *dev)
 {
 }
 
+static int
+nv17_graph_mthd_lma_window(struct nouveau_channel *chan, int grclass,
+                          int mthd, uint32_t data)
+{
+       struct drm_device *dev = chan->dev;
+       struct graph_state *ctx = chan->pgraph_ctx;
+       struct pipe_state *pipe = &ctx->pipe_state;
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
+       uint32_t pipe_0x0040[1], pipe_0x64c0[8], pipe_0x6a80[3], pipe_0x6ab0[3];
+       uint32_t xfmode0, xfmode1;
+       int i;
+
+       ctx->lma_window[(mthd - 0x1638) / 4] = data;
+
+       if (mthd != 0x1644)
+               return 0;
+
+       nouveau_wait_for_idle(dev);
+
+       PIPE_SAVE(dev, pipe_0x0040, 0x0040);
+       PIPE_SAVE(dev, pipe->pipe_0x0200, 0x0200);
+
+       PIPE_RESTORE(dev, ctx->lma_window, 0x6790);
+
+       nouveau_wait_for_idle(dev);
+
+       xfmode0 = nv_rd32(dev, NV10_PGRAPH_XFMODE0);
+       xfmode1 = nv_rd32(dev, NV10_PGRAPH_XFMODE1);
+
+       PIPE_SAVE(dev, pipe->pipe_0x4400, 0x4400);
+       PIPE_SAVE(dev, pipe_0x64c0, 0x64c0);
+       PIPE_SAVE(dev, pipe_0x6ab0, 0x6ab0);
+       PIPE_SAVE(dev, pipe_0x6a80, 0x6a80);
+
+       nouveau_wait_for_idle(dev);
+
+       nv_wr32(dev, NV10_PGRAPH_XFMODE0, 0x10000000);
+       nv_wr32(dev, NV10_PGRAPH_XFMODE1, 0x00000000);
+       nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x000064c0);
+       for (i = 0; i < 4; i++)
+               nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
+       for (i = 0; i < 4; i++)
+               nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000000);
+
+       nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x00006ab0);
+       for (i = 0; i < 3; i++)
+               nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x3f800000);
+
+       nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x00006a80);
+       for (i = 0; i < 3; i++)
+               nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000000);
+
+       nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x00000040);
+       nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000008);
+
+       PIPE_RESTORE(dev, pipe->pipe_0x0200, 0x0200);
+
+       nouveau_wait_for_idle(dev);
+
+       PIPE_RESTORE(dev, pipe_0x0040, 0x0040);
+
+       nv_wr32(dev, NV10_PGRAPH_XFMODE0, xfmode0);
+       nv_wr32(dev, NV10_PGRAPH_XFMODE1, xfmode1);
+
+       PIPE_RESTORE(dev, pipe_0x64c0, 0x64c0);
+       PIPE_RESTORE(dev, pipe_0x6ab0, 0x6ab0);
+       PIPE_RESTORE(dev, pipe_0x6a80, 0x6a80);
+       PIPE_RESTORE(dev, pipe->pipe_0x4400, 0x4400);
+
+       nv_wr32(dev, NV10_PGRAPH_PIPE_ADDRESS, 0x000000c0);
+       nv_wr32(dev, NV10_PGRAPH_PIPE_DATA, 0x00000000);
+
+       nouveau_wait_for_idle(dev);
+
+       pgraph->fifo_access(dev, true);
+
+       return 0;
+}
+
+static int
+nv17_graph_mthd_lma_enable(struct nouveau_channel *chan, int grclass,
+                          int mthd, uint32_t data)
+{
+       struct drm_device *dev = chan->dev;
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
+
+       nouveau_wait_for_idle(dev);
+
+       nv_wr32(dev, NV10_PGRAPH_DEBUG_4,
+               nv_rd32(dev, NV10_PGRAPH_DEBUG_4) | 0x1 << 8);
+       nv_wr32(dev, 0x004006b0,
+               nv_rd32(dev, 0x004006b0) | 0x8 << 24);
+
+       pgraph->fifo_access(dev, true);
+
+       return 0;
+}
+
+static struct nouveau_pgraph_object_method nv17_graph_celsius_mthds[] = {
+       { 0x1638, nv17_graph_mthd_lma_window },
+       { 0x163c, nv17_graph_mthd_lma_window },
+       { 0x1640, nv17_graph_mthd_lma_window },
+       { 0x1644, nv17_graph_mthd_lma_window },
+       { 0x1658, nv17_graph_mthd_lma_enable },
+       {}
+};
+
 struct nouveau_pgraph_object_class nv10_graph_grclass[] = {
        { 0x0030, false, NULL }, /* null */
        { 0x0039, false, NULL }, /* m2mf */
@@ -887,6 +998,6 @@ struct nouveau_pgraph_object_class nv10_graph_grclass[] = {
        { 0x0095, false, NULL }, /* multitex_tri */
        { 0x0056, false, NULL }, /* celcius (nv10) */
        { 0x0096, false, NULL }, /* celcius (nv11) */
-       { 0x0099, false, NULL }, /* celcius (nv17) */
+       { 0x0099, false, nv17_graph_celsius_mthds }, /* celcius (nv17) */
        {}
 };
index 46cfd9c604782f507332f4d1b092842e88692893..81c01353a9f9fee67e1d6da42f0108b8cc3044c5 100644 (file)
@@ -219,7 +219,7 @@ static void  nv17_tv_dpms(struct drm_encoder *encoder, int mode)
                return;
        nouveau_encoder(encoder)->last_dpms = mode;
 
-       NV_TRACE(dev, "Setting dpms mode %d on TV encoder (output %d)\n",
+       NV_INFO(dev, "Setting dpms mode %d on TV encoder (output %d)\n",
                 mode, nouveau_encoder(encoder)->dcb->index);
 
        regs->ptv_200 &= ~1;
@@ -619,7 +619,7 @@ static void nv17_tv_destroy(struct drm_encoder *encoder)
 {
        struct nv17_tv_encoder *tv_enc = to_tv_enc(encoder);
 
-       NV_DEBUG(encoder->dev, "\n");
+       NV_DEBUG_KMS(encoder->dev, "\n");
 
        drm_encoder_cleanup(encoder);
        kfree(tv_enc);
index d3e0a2a6acf8e982d5077ce587b8c4982973e77d..2b332bb55acf75b4cce5bafb9dc5110538e47428 100644 (file)
  *
  */
 
-#include <linux/firmware.h>
-
 #include "drmP.h"
 #include "drm.h"
 #include "nouveau_drv.h"
-
-MODULE_FIRMWARE("nouveau/nv40.ctxprog");
-MODULE_FIRMWARE("nouveau/nv40.ctxvals");
-MODULE_FIRMWARE("nouveau/nv41.ctxprog");
-MODULE_FIRMWARE("nouveau/nv41.ctxvals");
-MODULE_FIRMWARE("nouveau/nv42.ctxprog");
-MODULE_FIRMWARE("nouveau/nv42.ctxvals");
-MODULE_FIRMWARE("nouveau/nv43.ctxprog");
-MODULE_FIRMWARE("nouveau/nv43.ctxvals");
-MODULE_FIRMWARE("nouveau/nv44.ctxprog");
-MODULE_FIRMWARE("nouveau/nv44.ctxvals");
-MODULE_FIRMWARE("nouveau/nv46.ctxprog");
-MODULE_FIRMWARE("nouveau/nv46.ctxvals");
-MODULE_FIRMWARE("nouveau/nv47.ctxprog");
-MODULE_FIRMWARE("nouveau/nv47.ctxvals");
-MODULE_FIRMWARE("nouveau/nv49.ctxprog");
-MODULE_FIRMWARE("nouveau/nv49.ctxvals");
-MODULE_FIRMWARE("nouveau/nv4a.ctxprog");
-MODULE_FIRMWARE("nouveau/nv4a.ctxvals");
-MODULE_FIRMWARE("nouveau/nv4b.ctxprog");
-MODULE_FIRMWARE("nouveau/nv4b.ctxvals");
-MODULE_FIRMWARE("nouveau/nv4c.ctxprog");
-MODULE_FIRMWARE("nouveau/nv4c.ctxvals");
-MODULE_FIRMWARE("nouveau/nv4e.ctxprog");
-MODULE_FIRMWARE("nouveau/nv4e.ctxvals");
+#include "nouveau_grctx.h"
 
 struct nouveau_channel *
 nv40_graph_channel(struct drm_device *dev)
@@ -83,27 +57,30 @@ nv40_graph_create_context(struct nouveau_channel *chan)
 {
        struct drm_device *dev = chan->dev;
        struct drm_nouveau_private *dev_priv = dev->dev_private;
-       struct nouveau_gpuobj *ctx;
+       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
        int ret;
 
-       /* Allocate a 175KiB block of PRAMIN to store the context.  This
-        * is massive overkill for a lot of chipsets, but it should be safe
-        * until we're able to implement this properly (will happen at more
-        * or less the same time we're able to write our own context programs.
-        */
-       ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, 175*1024, 16,
-                                         NVOBJ_FLAG_ZERO_ALLOC,
-                                         &chan->ramin_grctx);
+       ret = nouveau_gpuobj_new_ref(dev, chan, NULL, 0, pgraph->grctx_size,
+                                    16, NVOBJ_FLAG_ZERO_ALLOC,
+                                    &chan->ramin_grctx);
        if (ret)
                return ret;
-       ctx = chan->ramin_grctx->gpuobj;
 
        /* Initialise default context values */
        dev_priv->engine.instmem.prepare_access(dev, true);
-       nv40_grctx_vals_load(dev, ctx);
-       nv_wo32(dev, ctx, 0, ctx->im_pramin->start);
-       dev_priv->engine.instmem.finish_access(dev);
+       if (!pgraph->ctxprog) {
+               struct nouveau_grctx ctx = {};
 
+               ctx.dev = chan->dev;
+               ctx.mode = NOUVEAU_GRCTX_VALS;
+               ctx.data = chan->ramin_grctx->gpuobj;
+               nv40_grctx_init(&ctx);
+       } else {
+               nouveau_grctx_vals_load(dev, chan->ramin_grctx->gpuobj);
+       }
+       nv_wo32(dev, chan->ramin_grctx->gpuobj, 0,
+                    chan->ramin_grctx->gpuobj->im_pramin->start);
+       dev_priv->engine.instmem.finish_access(dev);
        return 0;
 }
 
@@ -204,135 +181,6 @@ nv40_graph_unload_context(struct drm_device *dev)
        return ret;
 }
 
-struct nouveau_ctxprog {
-       uint32_t signature;
-       uint8_t  version;
-       uint16_t length;
-       uint32_t data[];
-} __attribute__ ((packed));
-
-struct nouveau_ctxvals {
-       uint32_t signature;
-       uint8_t  version;
-       uint32_t length;
-       struct {
-               uint32_t offset;
-               uint32_t value;
-       } data[];
-} __attribute__ ((packed));
-
-int
-nv40_grctx_init(struct drm_device *dev)
-{
-       struct drm_nouveau_private *dev_priv = dev->dev_private;
-       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
-       const int chipset = dev_priv->chipset;
-       const struct firmware *fw;
-       const struct nouveau_ctxprog *cp;
-       const struct nouveau_ctxvals *cv;
-       char name[32];
-       int ret, i;
-
-       pgraph->accel_blocked = true;
-
-       if (!pgraph->ctxprog) {
-               sprintf(name, "nouveau/nv%02x.ctxprog", chipset);
-               ret = request_firmware(&fw, name, &dev->pdev->dev);
-               if (ret) {
-                       NV_ERROR(dev, "No ctxprog for NV%02x\n", chipset);
-                       return ret;
-               }
-
-               pgraph->ctxprog = kmalloc(fw->size, GFP_KERNEL);
-               if (!pgraph->ctxprog) {
-                       NV_ERROR(dev, "OOM copying ctxprog\n");
-                       release_firmware(fw);
-                       return -ENOMEM;
-               }
-               memcpy(pgraph->ctxprog, fw->data, fw->size);
-
-               cp = pgraph->ctxprog;
-               if (cp->signature != 0x5043564e || cp->version != 0 ||
-                   cp->length != ((fw->size - 7) / 4)) {
-                       NV_ERROR(dev, "ctxprog invalid\n");
-                       release_firmware(fw);
-                       nv40_grctx_fini(dev);
-                       return -EINVAL;
-               }
-               release_firmware(fw);
-       }
-
-       if (!pgraph->ctxvals) {
-               sprintf(name, "nouveau/nv%02x.ctxvals", chipset);
-               ret = request_firmware(&fw, name, &dev->pdev->dev);
-               if (ret) {
-                       NV_ERROR(dev, "No ctxvals for NV%02x\n", chipset);
-                       nv40_grctx_fini(dev);
-                       return ret;
-               }
-
-               pgraph->ctxvals = kmalloc(fw->size, GFP_KERNEL);
-               if (!pgraph->ctxprog) {
-                       NV_ERROR(dev, "OOM copying ctxprog\n");
-                       release_firmware(fw);
-                       nv40_grctx_fini(dev);
-                       return -ENOMEM;
-               }
-               memcpy(pgraph->ctxvals, fw->data, fw->size);
-
-               cv = (void *)pgraph->ctxvals;
-               if (cv->signature != 0x5643564e || cv->version != 0 ||
-                   cv->length != ((fw->size - 9) / 8)) {
-                       NV_ERROR(dev, "ctxvals invalid\n");
-                       release_firmware(fw);
-                       nv40_grctx_fini(dev);
-                       return -EINVAL;
-               }
-               release_firmware(fw);
-       }
-
-       cp = pgraph->ctxprog;
-
-       nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
-       for (i = 0; i < cp->length; i++)
-               nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp->data[i]);
-
-       pgraph->accel_blocked = false;
-       return 0;
-}
-
-void
-nv40_grctx_fini(struct drm_device *dev)
-{
-       struct drm_nouveau_private *dev_priv = dev->dev_private;
-       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
-
-       if (pgraph->ctxprog) {
-               kfree(pgraph->ctxprog);
-               pgraph->ctxprog = NULL;
-       }
-
-       if (pgraph->ctxvals) {
-               kfree(pgraph->ctxprog);
-               pgraph->ctxvals = NULL;
-       }
-}
-
-void
-nv40_grctx_vals_load(struct drm_device *dev, struct nouveau_gpuobj *ctx)
-{
-       struct drm_nouveau_private *dev_priv = dev->dev_private;
-       struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
-       struct nouveau_ctxvals *cv = pgraph->ctxvals;
-       int i;
-
-       if (!cv)
-               return;
-
-       for (i = 0; i < cv->length; i++)
-               nv_wo32(dev, ctx, cv->data[i].offset, cv->data[i].value);
-}
-
 /*
  * G70         0x47
  * G71         0x49
@@ -355,7 +203,26 @@ nv40_graph_init(struct drm_device *dev)
        nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
                         NV_PMC_ENABLE_PGRAPH);
 
-       nv40_grctx_init(dev);
+       if (nouveau_ctxfw) {
+               nouveau_grctx_prog_load(dev);
+               dev_priv->engine.graph.grctx_size = 175 * 1024;
+       }
+
+       if (!dev_priv->engine.graph.ctxprog) {
+               struct nouveau_grctx ctx = {};
+               uint32_t cp[256];
+
+               ctx.dev = dev;
+               ctx.mode = NOUVEAU_GRCTX_PROG;
+               ctx.data = cp;
+               ctx.ctxprog_max = 256;
+               nv40_grctx_init(&ctx);
+               dev_priv->engine.graph.grctx_size = ctx.ctxvals_pos * 4;
+
+               nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_INDEX, 0);
+               for (i = 0; i < ctx.ctxprog_len; i++)
+                       nv_wr32(dev, NV40_PGRAPH_CTXCTL_UCODE_DATA, cp[i]);
+       }
 
        /* No context present currently */
        nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0x00000000);
@@ -535,6 +402,7 @@ nv40_graph_init(struct drm_device *dev)
 
 void nv40_graph_takedown(struct drm_device *dev)
 {
+       nouveau_grctx_fini(dev);
 }
 
 struct nouveau_pgraph_object_class nv40_graph_grclass[] = {
diff --git a/drivers/gpu/drm/nouveau/nv40_grctx.c b/drivers/gpu/drm/nouveau/nv40_grctx.c
new file mode 100644 (file)
index 0000000..11b11c3
--- /dev/null
@@ -0,0 +1,678 @@
+/*
+ * Copyright 2009 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs
+ */
+
+/* NVIDIA context programs handle a number of other conditions which are
+ * not implemented in our versions.  It's not clear why NVIDIA context
+ * programs have this code, nor whether it's strictly necessary for
+ * correct operation.  We'll implement additional handling if/when we
+ * discover it's necessary.
+ *
+ * - On context save, NVIDIA set 0x400314 bit 0 to 1 if the "3D state"
+ *   flag is set, this gets saved into the context.
+ * - On context save, the context program for all cards load nsource
+ *   into a flag register and check for ILLEGAL_MTHD.  If it's set,
+ *   opcode 0x60000d is called before resuming normal operation.
+ * - Some context programs check more conditions than the above.  NV44
+ *   checks: ((nsource & 0x0857) || (0x400718 & 0x0100) || (intr & 0x0001))
+ *   and calls 0x60000d before resuming normal operation.
+ * - At the very beginning of NVIDIA's context programs, flag 9 is checked
+ *   and if true 0x800001 is called with count=0, pos=0, the flag is cleared
+ *   and then the ctxprog is aborted.  It looks like a complicated NOP,
+ *   its purpose is unknown.
+ * - In the section of code that loads the per-vs state, NVIDIA check
+ *   flag 10.  If it's set, they only transfer the small 0x300 byte block
+ *   of state + the state for a single vs as opposed to the state for
+ *   all vs units.  It doesn't seem likely that it'll occur in normal
+ *   operation, especially seeing as it appears NVIDIA may have screwed
+ *   up the ctxprogs for some cards and have an invalid instruction
+ *   rather than a cp_lsr(ctx, dwords_for_1_vs_unit) instruction.
+ * - There's a number of places where context offset 0 (where we place
+ *   the PRAMIN offset of the context) is loaded into either 0x408000,
+ *   0x408004 or 0x408008.  Not sure what's up there either.
+ * - The ctxprogs for some cards save 0x400a00 again during the cleanup
+ *   path for auto-loadctx.
+ */
+
+#define CP_FLAG_CLEAR                 0
+#define CP_FLAG_SET                   1
+#define CP_FLAG_SWAP_DIRECTION        ((0 * 32) + 0)
+#define CP_FLAG_SWAP_DIRECTION_LOAD   0
+#define CP_FLAG_SWAP_DIRECTION_SAVE   1
+#define CP_FLAG_USER_SAVE             ((0 * 32) + 5)
+#define CP_FLAG_USER_SAVE_NOT_PENDING 0
+#define CP_FLAG_USER_SAVE_PENDING     1
+#define CP_FLAG_USER_LOAD             ((0 * 32) + 6)
+#define CP_FLAG_USER_LOAD_NOT_PENDING 0
+#define CP_FLAG_USER_LOAD_PENDING     1
+#define CP_FLAG_STATUS                ((3 * 32) + 0)
+#define CP_FLAG_STATUS_IDLE           0
+#define CP_FLAG_STATUS_BUSY           1
+#define CP_FLAG_AUTO_SAVE             ((3 * 32) + 4)
+#define CP_FLAG_AUTO_SAVE_NOT_PENDING 0
+#define CP_FLAG_AUTO_SAVE_PENDING     1
+#define CP_FLAG_AUTO_LOAD             ((3 * 32) + 5)
+#define CP_FLAG_AUTO_LOAD_NOT_PENDING 0
+#define CP_FLAG_AUTO_LOAD_PENDING     1
+#define CP_FLAG_UNK54                 ((3 * 32) + 6)
+#define CP_FLAG_UNK54_CLEAR           0
+#define CP_FLAG_UNK54_SET             1
+#define CP_FLAG_ALWAYS                ((3 * 32) + 8)
+#define CP_FLAG_ALWAYS_FALSE          0
+#define CP_FLAG_ALWAYS_TRUE           1
+#define CP_FLAG_UNK57                 ((3 * 32) + 9)
+#define CP_FLAG_UNK57_CLEAR           0
+#define CP_FLAG_UNK57_SET             1
+
+#define CP_CTX                   0x00100000
+#define CP_CTX_COUNT             0x000fc000
+#define CP_CTX_COUNT_SHIFT               14
+#define CP_CTX_REG               0x00003fff
+#define CP_LOAD_SR               0x00200000
+#define CP_LOAD_SR_VALUE         0x000fffff
+#define CP_BRA                   0x00400000
+#define CP_BRA_IP                0x0000ff00
+#define CP_BRA_IP_SHIFT                   8
+#define CP_BRA_IF_CLEAR          0x00000080
+#define CP_BRA_FLAG              0x0000007f
+#define CP_WAIT                  0x00500000
+#define CP_WAIT_SET              0x00000080
+#define CP_WAIT_FLAG             0x0000007f
+#define CP_SET                   0x00700000
+#define CP_SET_1                 0x00000080
+#define CP_SET_FLAG              0x0000007f
+#define CP_NEXT_TO_SWAP          0x00600007
+#define CP_NEXT_TO_CURRENT       0x00600009
+#define CP_SET_CONTEXT_POINTER   0x0060000a
+#define CP_END                   0x0060000e
+#define CP_LOAD_MAGIC_UNK01      0x00800001 /* unknown */
+#define CP_LOAD_MAGIC_NV44TCL    0x00800029 /* per-vs state (0x4497) */
+#define CP_LOAD_MAGIC_NV40TCL    0x00800041 /* per-vs state (0x4097) */
+
+#include "drmP.h"
+#include "nouveau_drv.h"
+#include "nouveau_grctx.h"
+
+/* TODO:
+ *  - get vs count from 0x1540
+ *  - document unimplemented bits compared to nvidia
+ *    - nsource handling
+ *    - R0 & 0x0200 handling
+ *    - single-vs handling
+ *    - 400314 bit 0
+ */
+
+static int
+nv40_graph_4097(struct drm_device *dev)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+
+       if ((dev_priv->chipset & 0xf0) == 0x60)
+               return 0;
+
+       return !!(0x0baf & (1 << dev_priv->chipset));
+}
+
+static int
+nv40_graph_vs_count(struct drm_device *dev)
+{
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+
+       switch (dev_priv->chipset) {
+       case 0x47:
+       case 0x49:
+       case 0x4b:
+               return 8;
+       case 0x40:
+               return 6;
+       case 0x41:
+       case 0x42:
+               return 5;
+       case 0x43:
+       case 0x44:
+       case 0x46:
+       case 0x4a:
+               return 3;
+       case 0x4c:
+       case 0x4e:
+       case 0x67:
+       default:
+               return 1;
+       }
+}
+
+
+enum cp_label {
+       cp_check_load = 1,
+       cp_setup_auto_load,
+       cp_setup_load,
+       cp_setup_save,
+       cp_swap_state,
+       cp_swap_state3d_3_is_save,
+       cp_prepare_exit,
+       cp_exit,
+};
+
+static void
+nv40_graph_construct_general(struct nouveau_grctx *ctx)
+{
+       struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
+       int i;
+
+       cp_ctx(ctx, 0x4000a4, 1);
+       gr_def(ctx, 0x4000a4, 0x00000008);
+       cp_ctx(ctx, 0x400144, 58);
+       gr_def(ctx, 0x400144, 0x00000001);
+       cp_ctx(ctx, 0x400314, 1);
+       gr_def(ctx, 0x400314, 0x00000000);
+       cp_ctx(ctx, 0x400400, 10);
+       cp_ctx(ctx, 0x400480, 10);
+       cp_ctx(ctx, 0x400500, 19);
+       gr_def(ctx, 0x400514, 0x00040000);
+       gr_def(ctx, 0x400524, 0x55555555);
+       gr_def(ctx, 0x400528, 0x55555555);
+       gr_def(ctx, 0x40052c, 0x55555555);
+       gr_def(ctx, 0x400530, 0x55555555);
+       cp_ctx(ctx, 0x400560, 6);
+       gr_def(ctx, 0x400568, 0x0000ffff);
+       gr_def(ctx, 0x40056c, 0x0000ffff);
+       cp_ctx(ctx, 0x40057c, 5);
+       cp_ctx(ctx, 0x400710, 3);
+       gr_def(ctx, 0x400710, 0x20010001);
+       gr_def(ctx, 0x400714, 0x0f73ef00);
+       cp_ctx(ctx, 0x400724, 1);
+       gr_def(ctx, 0x400724, 0x02008821);
+       cp_ctx(ctx, 0x400770, 3);
+       if (dev_priv->chipset == 0x40) {
+               cp_ctx(ctx, 0x400814, 4);
+               cp_ctx(ctx, 0x400828, 5);
+               cp_ctx(ctx, 0x400840, 5);
+               gr_def(ctx, 0x400850, 0x00000040);
+               cp_ctx(ctx, 0x400858, 4);
+               gr_def(ctx, 0x400858, 0x00000040);
+               gr_def(ctx, 0x40085c, 0x00000040);
+               gr_def(ctx, 0x400864, 0x80000000);
+               cp_ctx(ctx, 0x40086c, 9);
+               gr_def(ctx, 0x40086c, 0x80000000);
+               gr_def(ctx, 0x400870, 0x80000000);
+               gr_def(ctx, 0x400874, 0x80000000);
+               gr_def(ctx, 0x400878, 0x80000000);
+               gr_def(ctx, 0x400888, 0x00000040);
+               gr_def(ctx, 0x40088c, 0x80000000);
+               cp_ctx(ctx, 0x4009c0, 8);
+               gr_def(ctx, 0x4009cc, 0x80000000);
+               gr_def(ctx, 0x4009dc, 0x80000000);
+       } else {
+               cp_ctx(ctx, 0x400840, 20);
+               if (!nv40_graph_4097(ctx->dev)) {
+                       for (i = 0; i < 8; i++)
+                               gr_def(ctx, 0x400860 + (i * 4), 0x00000001);
+               }
+               gr_def(ctx, 0x400880, 0x00000040);
+               gr_def(ctx, 0x400884, 0x00000040);
+               gr_def(ctx, 0x400888, 0x00000040);
+               cp_ctx(ctx, 0x400894, 11);
+               gr_def(ctx, 0x400894, 0x00000040);
+               if (nv40_graph_4097(ctx->dev)) {
+                       for (i = 0; i < 8; i++)
+                               gr_def(ctx, 0x4008a0 + (i * 4), 0x80000000);
+               }
+               cp_ctx(ctx, 0x4008e0, 2);
+               cp_ctx(ctx, 0x4008f8, 2);
+               if (dev_priv->chipset == 0x4c ||
+                   (dev_priv->chipset & 0xf0) == 0x60)
+                       cp_ctx(ctx, 0x4009f8, 1);
+       }
+       cp_ctx(ctx, 0x400a00, 73);
+       gr_def(ctx, 0x400b0c, 0x0b0b0b0c);
+       cp_ctx(ctx, 0x401000, 4);
+       cp_ctx(ctx, 0x405004, 1);
+       switch (dev_priv->chipset) {
+       case 0x47:
+       case 0x49:
+       case 0x4b:
+               cp_ctx(ctx, 0x403448, 1);
+               gr_def(ctx, 0x403448, 0x00001010);
+               break;
+       default:
+               cp_ctx(ctx, 0x403440, 1);
+               switch (dev_priv->chipset) {
+               case 0x40:
+                       gr_def(ctx, 0x403440, 0x00000010);
+                       break;
+               case 0x44:
+               case 0x46:
+               case 0x4a:
+                       gr_def(ctx, 0x403440, 0x00003010);
+                       break;
+               case 0x41:
+               case 0x42:
+               case 0x43:
+               case 0x4c:
+               case 0x4e:
+               case 0x67:
+               default:
+                       gr_def(ctx, 0x403440, 0x00001010);
+                       break;
+               }
+               break;
+       }
+}
+
+static void
+nv40_graph_construct_state3d(struct nouveau_grctx *ctx)
+{
+       struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
+       int i;
+
+       if (dev_priv->chipset == 0x40) {
+               cp_ctx(ctx, 0x401880, 51);
+               gr_def(ctx, 0x401940, 0x00000100);
+       } else
+       if (dev_priv->chipset == 0x46 || dev_priv->chipset == 0x47 ||
+           dev_priv->chipset == 0x49 || dev_priv->chipset == 0x4b) {
+               cp_ctx(ctx, 0x401880, 32);
+               for (i = 0; i < 16; i++)
+                       gr_def(ctx, 0x401880 + (i * 4), 0x00000111);
+               if (dev_priv->chipset == 0x46)
+                       cp_ctx(ctx, 0x401900, 16);
+               cp_ctx(ctx, 0x401940, 3);
+       }
+       cp_ctx(ctx, 0x40194c, 18);
+       gr_def(ctx, 0x401954, 0x00000111);
+       gr_def(ctx, 0x401958, 0x00080060);
+       gr_def(ctx, 0x401974, 0x00000080);
+       gr_def(ctx, 0x401978, 0xffff0000);
+       gr_def(ctx, 0x40197c, 0x00000001);
+       gr_def(ctx, 0x401990, 0x46400000);
+       if (dev_priv->chipset == 0x40) {
+               cp_ctx(ctx, 0x4019a0, 2);
+               cp_ctx(ctx, 0x4019ac, 5);
+       } else {
+               cp_ctx(ctx, 0x4019a0, 1);
+               cp_ctx(ctx, 0x4019b4, 3);
+       }
+       gr_def(ctx, 0x4019bc, 0xffff0000);
+       switch (dev_priv->chipset) {
+       case 0x46:
+       case 0x47:
+       case 0x49:
+       case 0x4b:
+               cp_ctx(ctx, 0x4019c0, 18);
+               for (i = 0; i < 16; i++)
+                       gr_def(ctx, 0x4019c0 + (i * 4), 0x88888888);
+               break;
+       }
+       cp_ctx(ctx, 0x401a08, 8);
+       gr_def(ctx, 0x401a10, 0x0fff0000);
+       gr_def(ctx, 0x401a14, 0x0fff0000);
+       gr_def(ctx, 0x401a1c, 0x00011100);
+       cp_ctx(ctx, 0x401a2c, 4);
+       cp_ctx(ctx, 0x401a44, 26);
+       for (i = 0; i < 16; i++)
+               gr_def(ctx, 0x401a44 + (i * 4), 0x07ff0000);
+       gr_def(ctx, 0x401a8c, 0x4b7fffff);
+       if (dev_priv->chipset == 0x40) {
+               cp_ctx(ctx, 0x401ab8, 3);
+       } else {
+               cp_ctx(ctx, 0x401ab8, 1);
+               cp_ctx(ctx, 0x401ac0, 1);
+       }
+       cp_ctx(ctx, 0x401ad0, 8);
+       gr_def(ctx, 0x401ad0, 0x30201000);
+       gr_def(ctx, 0x401ad4, 0x70605040);
+       gr_def(ctx, 0x401ad8, 0xb8a89888);
+       gr_def(ctx, 0x401adc, 0xf8e8d8c8);
+       cp_ctx(ctx, 0x401b10, dev_priv->chipset == 0x40 ? 2 : 1);
+       gr_def(ctx, 0x401b10, 0x40100000);
+       cp_ctx(ctx, 0x401b18, dev_priv->chipset == 0x40 ? 6 : 5);
+       gr_def(ctx, 0x401b28, dev_priv->chipset == 0x40 ?
+                             0x00000004 : 0x00000000);
+       cp_ctx(ctx, 0x401b30, 25);
+       gr_def(ctx, 0x401b34, 0x0000ffff);
+       gr_def(ctx, 0x401b68, 0x435185d6);
+       gr_def(ctx, 0x401b6c, 0x2155b699);
+       gr_def(ctx, 0x401b70, 0xfedcba98);
+       gr_def(ctx, 0x401b74, 0x00000098);
+       gr_def(ctx, 0x401b84, 0xffffffff);
+       gr_def(ctx, 0x401b88, 0x00ff7000);
+       gr_def(ctx, 0x401b8c, 0x0000ffff);
+       if (dev_priv->chipset != 0x44 && dev_priv->chipset != 0x4a &&
+           dev_priv->chipset != 0x4e)
+               cp_ctx(ctx, 0x401b94, 1);
+       cp_ctx(ctx, 0x401b98, 8);
+       gr_def(ctx, 0x401b9c, 0x00ff0000);
+       cp_ctx(ctx, 0x401bc0, 9);
+       gr_def(ctx, 0x401be0, 0x00ffff00);
+       cp_ctx(ctx, 0x401c00, 192);
+       for (i = 0; i < 16; i++) { /* fragment texture units */
+               gr_def(ctx, 0x401c40 + (i * 4), 0x00018488);
+               gr_def(ctx, 0x401c80 + (i * 4), 0x00028202);
+               gr_def(ctx, 0x401d00 + (i * 4), 0x0000aae4);
+               gr_def(ctx, 0x401d40 + (i * 4), 0x01012000);
+               gr_def(ctx, 0x401d80 + (i * 4), 0x00080008);
+               gr_def(ctx, 0x401e00 + (i * 4), 0x00100008);
+       }
+       for (i = 0; i < 4; i++) { /* vertex texture units */
+               gr_def(ctx, 0x401e90 + (i * 4), 0x0001bc80);
+               gr_def(ctx, 0x401ea0 + (i * 4), 0x00000202);
+               gr_def(ctx, 0x401ec0 + (i * 4), 0x00000008);
+               gr_def(ctx, 0x401ee0 + (i * 4), 0x00080008);
+       }
+       cp_ctx(ctx, 0x400f5c, 3);
+       gr_def(ctx, 0x400f5c, 0x00000002);
+       cp_ctx(ctx, 0x400f84, 1);
+}
+
+static void
+nv40_graph_construct_state3d_2(struct nouveau_grctx *ctx)
+{
+       struct drm_nouveau_private *dev_priv = ctx->dev->dev_private;
+       int i;
+
+       cp_ctx(ctx, 0x402000, 1);
+       cp_ctx(ctx, 0x402404, dev_priv->chipset == 0x40 ? 1 : 2);
+       switch (dev_priv->chipset) {
+       case 0x40:
+               gr_def(ctx, 0x402404, 0x00000001);
+               break;
+       case 0x4c:
+       case 0x4e:
+       case 0x67:
+               gr_def(ctx, 0x402404, 0x00000020);
+               break;
+       case 0x46:
+       case 0x49:
+       case 0x4b:
+               gr_def(ctx, 0x402404, 0x00000421);
+               break;
+       default:
+               gr_def(ctx, 0x402404, 0x00000021);
+       }
+       if (dev_priv->chipset != 0x40)
+               gr_def(ctx, 0x402408, 0x030c30c3);
+       switch (dev_priv->chipset) {
+       case 0x44:
+       case 0x46:
+       case 0x4a:
+       case 0x4c:
+       case 0x4e:
+       case 0x67:
+               cp_ctx(ctx, 0x402440, 1);
+               gr_def(ctx, 0x402440, 0x00011001);
+               break;
+       default:
+               break;
+       }
+       cp_ctx(ctx, 0x402480, dev_priv->chipset == 0x40 ? 8 : 9);
+       gr_def(ctx, 0x402488, 0x3e020200);
+       gr_def(ctx, 0x40248c, 0x00ffffff);
+       switch (dev_priv->chipset) {
+       case 0x40:
+               gr_def(ctx, 0x402490, 0x60103f00);
+               break;
+       case 0x47:
+               gr_def(ctx, 0x402490, 0x40103f00);
+               break;
+       case 0x41:
+       case 0x42:
+       case 0x49:
+       case 0x4b:
+               gr_def(ctx, 0x402490, 0x20103f00);
+               break;
+       default:
+               gr_def(ctx, 0x402490, 0x0c103f00);
+               break;
+       }
+       gr_def(ctx, 0x40249c, dev_priv->chipset <= 0x43 ?
+                             0x00020000 : 0x00040000);
+       cp_ctx(ctx, 0x402500, 31);
+       gr_def(ctx, 0x402530, 0x00008100);
+       if (dev_priv->chipset == 0x40)
+               cp_ctx(ctx, 0x40257c, 6);
+       cp_ctx(ctx, 0x402594, 16);
+       cp_ctx(ctx, 0x402800, 17);
+       gr_def(ctx, 0x402800, 0x00000001);
+       switch (dev_priv->chipset) {
+       case 0x47:
+       case 0x49:
+       case 0x4b:
+               cp_ctx(ctx, 0x402864, 1);
+               gr_def(ctx, 0x402864, 0x00001001);
+               cp_ctx(ctx, 0x402870, 3);
+               gr_def(ctx, 0x402878, 0x00000003);
+               if (dev_priv->chipset != 0x47) { /* belong at end!! */
+                       cp_ctx(ctx, 0x402900, 1);
+                       cp_ctx(ctx, 0x402940, 1);
+                       cp_ctx(ctx, 0x402980, 1);
+                       cp_ctx(ctx, 0x4029c0, 1);
+                       cp_ctx(ctx, 0x402a00, 1);
+                       cp_ctx(ctx, 0x402a40, 1);
+                       cp_ctx(ctx, 0x402a80, 1);
+                       cp_ctx(ctx, 0x402ac0, 1);
+               }
+               break;
+       case 0x40:
+               cp_ctx(ctx, 0x402844, 1);
+               gr_def(ctx, 0x402844, 0x00000001);
+               cp_ctx(ctx, 0x402850, 1);
+               break;
+       default:
+               cp_ctx(ctx, 0x402844, 1);
+               gr_def(ctx, 0x402844, 0x00001001);
+               cp_ctx(ctx, 0x402850, 2);
+               gr_def(ctx, 0x402854, 0x00000003);
+               break;
+       }
+
+       cp_ctx(ctx, 0x402c00, 4);
+       gr_def(ctx, 0x402c00, dev_priv->chipset == 0x40 ?
+                             0x80800001 : 0x00888001);
+       switch (dev_priv->chipset) {
+       case 0x47:
+       case 0x49:
+       case 0x4b:
+               cp_ctx(ctx, 0x402c20, 40);
+               for (i = 0; i < 32; i++)
+                       gr_def(ctx, 0x402c40 + (i * 4), 0xffffffff);
+               cp_ctx(ctx, 0x4030b8, 13);
+               gr_def(ctx, 0x4030dc, 0x00000005);
+               gr_def(ctx, 0x4030e8, 0x0000ffff);
+               break;
+       default:
+               cp_ctx(ctx, 0x402c10, 4);
+               if (dev_priv->chipset == 0x40)
+                       cp_ctx(ctx, 0x402c20, 36);
+               else
+               if (dev_priv->chipset <= 0x42)
+                       cp_ctx(ctx, 0x402c20, 24);
+               else
+               if (dev_priv->chipset <= 0x4a)
+                       cp_ctx(ctx, 0x402c20, 16);
+               else
+                       cp_ctx(ctx, 0x402c20, 8);
+               cp_ctx(ctx, 0x402cb0, dev_priv->chipset == 0x40 ? 12 : 13);
+               gr_def(ctx, 0x402cd4, 0x00000005);
+               if (dev_priv->chipset != 0x40)
+                       gr_def(ctx, 0x402ce0, 0x0000ffff);
+               break;
+       }
+
+       cp_ctx(ctx, 0x403400, dev_priv->chipset == 0x40 ? 4 : 3);
+       cp_ctx(ctx, 0x403410, dev_priv->chipset == 0x40 ? 4 : 3);
+       cp_ctx(ctx, 0x403420, nv40_graph_vs_count(ctx->dev));
+       for (i = 0; i < nv40_graph_vs_count(ctx->dev); i++)
+               gr_def(ctx, 0x403420 + (i * 4), 0x00005555);
+
+       if (dev_priv->chipset != 0x40) {
+               cp_ctx(ctx, 0x403600, 1);
+               gr_def(ctx, 0x403600, 0x00000001);
+       }
+       cp_ctx(ctx, 0x403800, 1);
+
+       cp_ctx(ctx, 0x403c18, 1);
+       gr_def(ctx, 0x403c18, 0x00000001);
+       switch (dev_priv->chipset) {
+       case 0x46:
+       case 0x47:
+       case 0x49:
+       case 0x4b:
+               cp_ctx(ctx, 0x405018, 1);
+               gr_def(ctx, 0x405018, 0x08e00001);
+               cp_ctx(ctx, 0x405c24, 1);
+               gr_def(ctx, 0x405c24, 0x000e3000);
+               break;
+       }
+       if (dev_priv->chipset != 0x4e)
+               cp_ctx(ctx, 0x405800, 11);
+       cp_ctx(ctx, 0x407000, 1);
+}
+
+static void
+nv40_graph_construct_state3d_3(struct nouveau_grctx *ctx)
+{
+       int len = nv40_graph_4097(ctx->dev) ? 0x0684 : 0x0084;
+
+       cp_out (ctx, 0x300000);
+       cp_lsr (ctx, len - 4);
+       cp_bra (ctx, SWAP_DIRECTION, SAVE, cp_swap_state3d_3_is_save);
+       cp_lsr (ctx, len);
+       cp_name(ctx, cp_swap_state3d_3_is_save);
+       cp_out (ctx, 0x800001);
+
+       ctx->ctxvals_pos += len;
+}
+
+static void
+nv40_graph_construct_shader(struct nouveau_grctx *ctx)
+{
+       struct drm_device *dev = ctx->dev;
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct nouveau_gpuobj *obj = ctx->data;
+       int vs, vs_nr, vs_len, vs_nr_b0, vs_nr_b1, b0_offset, b1_offset;
+       int offset, i;
+
+       vs_nr    = nv40_graph_vs_count(ctx->dev);
+       vs_nr_b0 = 363;
+       vs_nr_b1 = dev_priv->chipset == 0x40 ? 128 : 64;
+       if (dev_priv->chipset == 0x40) {
+               b0_offset = 0x2200/4; /* 33a0 */
+               b1_offset = 0x55a0/4; /* 1500 */
+               vs_len = 0x6aa0/4;
+       } else
+       if (dev_priv->chipset == 0x41 || dev_priv->chipset == 0x42) {
+               b0_offset = 0x2200/4; /* 2200 */
+               b1_offset = 0x4400/4; /* 0b00 */
+               vs_len = 0x4f00/4;
+       } else {
+               b0_offset = 0x1d40/4; /* 2200 */
+               b1_offset = 0x3f40/4; /* 0b00 : 0a40 */
+               vs_len = nv40_graph_4097(dev) ? 0x4a40/4 : 0x4980/4;
+       }
+
+       cp_lsr(ctx, vs_len * vs_nr + 0x300/4);
+       cp_out(ctx, nv40_graph_4097(dev) ? 0x800041 : 0x800029);
+
+       offset = ctx->ctxvals_pos;
+       ctx->ctxvals_pos += (0x0300/4 + (vs_nr * vs_len));
+
+       if (ctx->mode != NOUVEAU_GRCTX_VALS)
+               return;
+
+       offset += 0x0280/4;
+       for (i = 0; i < 16; i++, offset += 2)
+               nv_wo32(dev, obj, offset, 0x3f800000);
+
+       for (vs = 0; vs < vs_nr; vs++, offset += vs_len) {
+               for (i = 0; i < vs_nr_b0 * 6; i += 6)
+                       nv_wo32(dev, obj, offset + b0_offset + i, 0x00000001);
+               for (i = 0; i < vs_nr_b1 * 4; i += 4)
+                       nv_wo32(dev, obj, offset + b1_offset + i, 0x3f800000);
+       }
+}
+
+void
+nv40_grctx_init(struct nouveau_grctx *ctx)
+{
+       /* decide whether we're loading/unloading the context */
+       cp_bra (ctx, AUTO_SAVE, PENDING, cp_setup_save);
+       cp_bra (ctx, USER_SAVE, PENDING, cp_setup_save);
+
+       cp_name(ctx, cp_check_load);
+       cp_bra (ctx, AUTO_LOAD, PENDING, cp_setup_auto_load);
+       cp_bra (ctx, USER_LOAD, PENDING, cp_setup_load);
+       cp_bra (ctx, ALWAYS, TRUE, cp_exit);
+
+       /* setup for context load */
+       cp_name(ctx, cp_setup_auto_load);
+       cp_wait(ctx, STATUS, IDLE);
+       cp_out (ctx, CP_NEXT_TO_SWAP);
+       cp_name(ctx, cp_setup_load);
+       cp_wait(ctx, STATUS, IDLE);
+       cp_set (ctx, SWAP_DIRECTION, LOAD);
+       cp_out (ctx, 0x00910880); /* ?? */
+       cp_out (ctx, 0x00901ffe); /* ?? */
+       cp_out (ctx, 0x01940000); /* ?? */
+       cp_lsr (ctx, 0x20);
+       cp_out (ctx, 0x0060000b); /* ?? */
+       cp_wait(ctx, UNK57, CLEAR);
+       cp_out (ctx, 0x0060000c); /* ?? */
+       cp_bra (ctx, ALWAYS, TRUE, cp_swap_state);
+
+       /* setup for context save */
+       cp_name(ctx, cp_setup_save);
+       cp_set (ctx, SWAP_DIRECTION, SAVE);
+
+       /* general PGRAPH state */
+       cp_name(ctx, cp_swap_state);
+       cp_pos (ctx, 0x00020/4);
+       nv40_graph_construct_general(ctx);
+       cp_wait(ctx, STATUS, IDLE);
+
+       /* 3D state, block 1 */
+       cp_bra (ctx, UNK54, CLEAR, cp_prepare_exit);
+       nv40_graph_construct_state3d(ctx);
+       cp_wait(ctx, STATUS, IDLE);
+
+       /* 3D state, block 2 */
+       nv40_graph_construct_state3d_2(ctx);
+
+       /* Some other block of "random" state */
+       nv40_graph_construct_state3d_3(ctx);
+
+       /* Per-vertex shader state */
+       cp_pos (ctx, ctx->ctxvals_pos);
+       nv40_graph_construct_shader(ctx);
+
+       /* pre-exit state updates */
+       cp_name(ctx, cp_prepare_exit);
+       cp_bra (ctx, SWAP_DIRECTION, SAVE, cp_check_load);
+       cp_bra (ctx, USER_SAVE, PENDING, cp_exit);
+       cp_out (ctx, CP_NEXT_TO_CURRENT);
+
+       cp_name(ctx, cp_exit);
+       cp_set (ctx, USER_SAVE, NOT_PENDING);
+       cp_set (ctx, USER_LOAD, NOT_PENDING);
+       cp_out (ctx, CP_END);
+}
+
index f8e28a1e44e785747b1a7da74a1247bc5b92002b..118d3285fd8c9e95d74d1f8f5ffb0f52ef49a6ee 100644 (file)
@@ -45,7 +45,7 @@ nv50_crtc_lut_load(struct drm_crtc *crtc)
        void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo);
        int i;
 
-       NV_DEBUG(crtc->dev, "\n");
+       NV_DEBUG_KMS(crtc->dev, "\n");
 
        for (i = 0; i < 256; i++) {
                writew(nv_crtc->lut.r[i] >> 2, lut + 8*i + 0);
@@ -68,8 +68,8 @@ nv50_crtc_blank(struct nouveau_crtc *nv_crtc, bool blanked)
        struct nouveau_channel *evo = dev_priv->evo;
        int index = nv_crtc->index, ret;
 
-       NV_DEBUG(dev, "index %d\n", nv_crtc->index);
-       NV_DEBUG(dev, "%s\n", blanked ? "blanked" : "unblanked");
+       NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index);
+       NV_DEBUG_KMS(dev, "%s\n", blanked ? "blanked" : "unblanked");
 
        if (blanked) {
                nv_crtc->cursor.hide(nv_crtc, false);
@@ -139,7 +139,7 @@ nv50_crtc_set_dither(struct nouveau_crtc *nv_crtc, bool on, bool update)
        struct nouveau_channel *evo = dev_priv->evo;
        int ret;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        ret = RING_SPACE(evo, 2 + (update ? 2 : 0));
        if (ret) {
@@ -193,7 +193,7 @@ nv50_crtc_set_scale(struct nouveau_crtc *nv_crtc, int scaling_mode, bool update)
        uint32_t outX, outY, horiz, vert;
        int ret;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        switch (scaling_mode) {
        case DRM_MODE_SCALE_NONE:
@@ -301,7 +301,7 @@ nv50_crtc_destroy(struct drm_crtc *crtc)
        struct drm_device *dev = crtc->dev;
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        if (!crtc)
                return;
@@ -433,7 +433,7 @@ nv50_crtc_prepare(struct drm_crtc *crtc)
        struct drm_device *dev = crtc->dev;
        struct drm_encoder *encoder;
 
-       NV_DEBUG(dev, "index %d\n", nv_crtc->index);
+       NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index);
 
        /* Disconnect all unused encoders. */
        list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
@@ -458,7 +458,7 @@ nv50_crtc_commit(struct drm_crtc *crtc)
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
        int ret;
 
-       NV_DEBUG(dev, "index %d\n", nv_crtc->index);
+       NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index);
 
        nv50_crtc_blank(nv_crtc, false);
 
@@ -497,7 +497,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc, int x, int y,
        struct nouveau_framebuffer *fb = nouveau_framebuffer(drm_fb);
        int ret, format;
 
-       NV_DEBUG(dev, "index %d\n", nv_crtc->index);
+       NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index);
 
        switch (drm_fb->depth) {
        case  8:
@@ -612,7 +612,7 @@ nv50_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
 
        *nv_crtc->mode = *adjusted_mode;
 
-       NV_DEBUG(dev, "index %d\n", nv_crtc->index);
+       NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index);
 
        hsync_dur = adjusted_mode->hsync_end - adjusted_mode->hsync_start;
        vsync_dur = adjusted_mode->vsync_end - adjusted_mode->vsync_start;
@@ -706,7 +706,7 @@ nv50_crtc_create(struct drm_device *dev, int index)
        struct nouveau_crtc *nv_crtc = NULL;
        int ret, i;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL);
        if (!nv_crtc)
index e2e79a8f220d0df652d379c35191a2e90f5b0c08..753e723adb3afb9e0dc733d4ef416a4468b3aacc 100644 (file)
@@ -41,7 +41,7 @@ nv50_cursor_show(struct nouveau_crtc *nv_crtc, bool update)
        struct drm_device *dev = nv_crtc->base.dev;
        int ret;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        if (update && nv_crtc->cursor.visible)
                return;
@@ -76,7 +76,7 @@ nv50_cursor_hide(struct nouveau_crtc *nv_crtc, bool update)
        struct drm_device *dev = nv_crtc->base.dev;
        int ret;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        if (update && !nv_crtc->cursor.visible)
                return;
@@ -116,7 +116,7 @@ nv50_cursor_set_pos(struct nouveau_crtc *nv_crtc, int x, int y)
 static void
 nv50_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset)
 {
-       NV_DEBUG(nv_crtc->base.dev, "\n");
+       NV_DEBUG_KMS(nv_crtc->base.dev, "\n");
        if (offset == nv_crtc->cursor.offset)
                return;
 
@@ -143,7 +143,7 @@ nv50_cursor_fini(struct nouveau_crtc *nv_crtc)
        struct drm_device *dev = nv_crtc->base.dev;
        int idx = nv_crtc->index;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        nv_wr32(dev, NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx), 0);
        if (!nv_wait(NV50_PDISPLAY_CURSOR_CURSOR_CTRL2(idx),
index fb5838e3be24038d1db8c460ba2fdb8c8f8596e7..f08f042a8e10de23a06c14615bac5bcaad4e6af5 100644 (file)
@@ -44,7 +44,7 @@ nv50_dac_disconnect(struct nouveau_encoder *nv_encoder)
        struct nouveau_channel *evo = dev_priv->evo;
        int ret;
 
-       NV_DEBUG(dev, "Disconnecting DAC %d\n", nv_encoder->or);
+       NV_DEBUG_KMS(dev, "Disconnecting DAC %d\n", nv_encoder->or);
 
        ret = RING_SPACE(evo, 2);
        if (ret) {
@@ -81,11 +81,11 @@ nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
        /* Use bios provided value if possible. */
        if (dev_priv->vbios->dactestval) {
                load_pattern = dev_priv->vbios->dactestval;
-               NV_DEBUG(dev, "Using bios provided load_pattern of %d\n",
+               NV_DEBUG_KMS(dev, "Using bios provided load_pattern of %d\n",
                          load_pattern);
        } else {
                load_pattern = 340;
-               NV_DEBUG(dev, "Using default load_pattern of %d\n",
+               NV_DEBUG_KMS(dev, "Using default load_pattern of %d\n",
                         load_pattern);
        }
 
@@ -103,9 +103,9 @@ nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
                status = connector_status_connected;
 
        if (status == connector_status_connected)
-               NV_DEBUG(dev, "Load was detected on output with or %d\n", or);
+               NV_DEBUG_KMS(dev, "Load was detected on output with or %d\n", or);
        else
-               NV_DEBUG(dev, "Load was not detected on output with or %d\n", or);
+               NV_DEBUG_KMS(dev, "Load was not detected on output with or %d\n", or);
 
        return status;
 }
@@ -118,7 +118,7 @@ nv50_dac_dpms(struct drm_encoder *encoder, int mode)
        uint32_t val;
        int or = nv_encoder->or;
 
-       NV_DEBUG(dev, "or %d mode %d\n", or, mode);
+       NV_DEBUG_KMS(dev, "or %d mode %d\n", or, mode);
 
        /* wait for it to be done */
        if (!nv_wait(NV50_PDISPLAY_DAC_DPMS_CTRL(or),
@@ -173,7 +173,7 @@ nv50_dac_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
        struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
        struct nouveau_connector *connector;
 
-       NV_DEBUG(encoder->dev, "or %d\n", nv_encoder->or);
+       NV_DEBUG_KMS(encoder->dev, "or %d\n", nv_encoder->or);
 
        connector = nouveau_encoder_connector_get(nv_encoder);
        if (!connector) {
@@ -213,7 +213,7 @@ nv50_dac_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
        uint32_t mode_ctl = 0, mode_ctl2 = 0;
        int ret;
 
-       NV_DEBUG(dev, "or %d\n", nv_encoder->or);
+       NV_DEBUG_KMS(dev, "or %d\n", nv_encoder->or);
 
        nv50_dac_dpms(encoder, DRM_MODE_DPMS_ON);
 
@@ -264,7 +264,7 @@ nv50_dac_destroy(struct drm_encoder *encoder)
        if (!encoder)
                return;
 
-       NV_DEBUG(encoder->dev, "\n");
+       NV_DEBUG_KMS(encoder->dev, "\n");
 
        drm_encoder_cleanup(encoder);
        kfree(nv_encoder);
@@ -280,7 +280,7 @@ nv50_dac_create(struct drm_device *dev, struct dcb_entry *entry)
        struct nouveau_encoder *nv_encoder;
        struct drm_encoder *encoder;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
        NV_INFO(dev, "Detected a DAC output\n");
 
        nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
index 12c5ee63495b3a59e99c15b64a0e4d91b02640e7..a9263d92a231bf0c2c24855be13c79720fcb4f7e 100644 (file)
@@ -188,7 +188,7 @@ nv50_display_init(struct drm_device *dev)
        uint64_t start;
        int ret, i;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        nv_wr32(dev, 0x00610184, nv_rd32(dev, 0x00614004));
        /*
@@ -232,7 +232,7 @@ nv50_display_init(struct drm_device *dev)
        nv_wr32(dev, NV50_PDISPLAY_UNK_380, 0);
        /* RAM is clamped to 256 MiB. */
        ram_amount = nouveau_mem_fb_amount(dev);
-       NV_DEBUG(dev, "ram_amount %d\n", ram_amount);
+       NV_DEBUG_KMS(dev, "ram_amount %d\n", ram_amount);
        if (ram_amount > 256*1024*1024)
                ram_amount = 256*1024*1024;
        nv_wr32(dev, NV50_PDISPLAY_RAM_AMOUNT, ram_amount - 1);
@@ -398,7 +398,7 @@ static int nv50_display_disable(struct drm_device *dev)
        struct drm_crtc *drm_crtc;
        int ret, i;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        list_for_each_entry(drm_crtc, &dev->mode_config.crtc_list, head) {
                struct nouveau_crtc *crtc = nouveau_crtc(drm_crtc);
@@ -469,7 +469,7 @@ int nv50_display_create(struct drm_device *dev)
        uint32_t connector[16] = {};
        int ret, i;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        /* init basic kernel modesetting */
        drm_mode_config_init(dev);
@@ -573,7 +573,7 @@ int nv50_display_destroy(struct drm_device *dev)
 {
        struct drm_nouveau_private *dev_priv = dev->dev_private;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        drm_mode_config_cleanup(dev);
 
@@ -617,7 +617,7 @@ nv50_display_irq_head(struct drm_device *dev, int *phead,
         * CRTC separately, and submission will be blocked by the GPU
         * until we handle each in turn.
         */
-       NV_DEBUG(dev, "0x610030: 0x%08x\n", unk30);
+       NV_DEBUG_KMS(dev, "0x610030: 0x%08x\n", unk30);
        head = ffs((unk30 >> 9) & 3) - 1;
        if (head < 0)
                return -EINVAL;
@@ -661,7 +661,7 @@ nv50_display_irq_head(struct drm_device *dev, int *phead,
                or = i;
        }
 
-       NV_DEBUG(dev, "type %d, or %d\n", type, or);
+       NV_DEBUG_KMS(dev, "type %d, or %d\n", type, or);
        if (type == OUTPUT_ANY) {
                NV_ERROR(dev, "unknown encoder!!\n");
                return -1;
@@ -811,7 +811,7 @@ nv50_display_unk20_handler(struct drm_device *dev)
        pclk = nv_rd32(dev, NV50_PDISPLAY_CRTC_P(head, CLOCK)) & 0x3fffff;
        script = nv50_display_script_select(dev, dcbent, pclk);
 
-       NV_DEBUG(dev, "head %d pxclk: %dKHz\n", head, pclk);
+       NV_DEBUG_KMS(dev, "head %d pxclk: %dKHz\n", head, pclk);
 
        if (dcbent->type != OUTPUT_DP)
                nouveau_bios_run_display_table(dev, dcbent, 0, -2);
@@ -870,7 +870,7 @@ nv50_display_irq_handler_bh(struct work_struct *work)
                uint32_t intr0 = nv_rd32(dev, NV50_PDISPLAY_INTR_0);
                uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1);
 
-               NV_DEBUG(dev, "PDISPLAY_INTR_BH 0x%08x 0x%08x\n", intr0, intr1);
+               NV_DEBUG_KMS(dev, "PDISPLAY_INTR_BH 0x%08x 0x%08x\n", intr0, intr1);
 
                if (intr1 & NV50_PDISPLAY_INTR_1_CLK_UNK10)
                        nv50_display_unk10_handler(dev);
@@ -974,7 +974,7 @@ nv50_display_irq_handler(struct drm_device *dev)
                uint32_t intr1 = nv_rd32(dev, NV50_PDISPLAY_INTR_1);
                uint32_t clock;
 
-               NV_DEBUG(dev, "PDISPLAY_INTR 0x%08x 0x%08x\n", intr0, intr1);
+               NV_DEBUG_KMS(dev, "PDISPLAY_INTR 0x%08x 0x%08x\n", intr0, intr1);
 
                if (!intr0 && !(intr1 & ~delayed))
                        break;
index 77ae1aaa0bcea90babc84b8b202318f101c2e7af..b7282284f0806f4db2cb71b57eddda7606e3c055 100644 (file)
@@ -416,7 +416,7 @@ nv50_fifo_unload_context(struct drm_device *dev)
        NV_DEBUG(dev, "\n");
 
        chid = pfifo->channel_id(dev);
-       if (chid < 0 || chid >= dev_priv->engine.fifo.channels)
+       if (chid < 1 || chid >= dev_priv->engine.fifo.channels - 1)
                return 0;
 
        chan = dev_priv->fifos[chid];
index 177d8229336f1d59806411ddd02a9ca86540d6ec..ca79f32be44c13bcaba47e00f189b8e3067bbf55 100644 (file)
@@ -107,9 +107,13 @@ nv50_graph_init_regs(struct drm_device *dev)
 static int
 nv50_graph_init_ctxctl(struct drm_device *dev)
 {
+       struct drm_nouveau_private *dev_priv = dev->dev_private;
+
        NV_DEBUG(dev, "\n");
 
-       nv40_grctx_init(dev);
+       nouveau_grctx_prog_load(dev);
+       if (!dev_priv->engine.graph.ctxprog)
+               dev_priv->engine.graph.accel_blocked = true;
 
        nv_wr32(dev, 0x400320, 4);
        nv_wr32(dev, NV40_PGRAPH_CTXCTL_CUR, 0);
@@ -140,7 +144,7 @@ void
 nv50_graph_takedown(struct drm_device *dev)
 {
        NV_DEBUG(dev, "\n");
-       nv40_grctx_fini(dev);
+       nouveau_grctx_fini(dev);
 }
 
 void
@@ -207,7 +211,7 @@ nv50_graph_create_context(struct nouveau_channel *chan)
        dev_priv->engine.instmem.finish_access(dev);
 
        dev_priv->engine.instmem.prepare_access(dev, true);
-       nv40_grctx_vals_load(dev, ctx);
+       nouveau_grctx_vals_load(dev, ctx);
        nv_wo32(dev, ctx, 0x00000/4, chan->ramin->instance >> 12);
        if ((dev_priv->chipset & 0xf0) == 0xa0)
                nv_wo32(dev, ctx, 0x00004/4, 0x00000000);
index 8c280463a6648bff4cd1e093bb4ea2643339a1a2..e395c16d30f548c29fe848f380019bf8f946ba3b 100644 (file)
@@ -44,7 +44,7 @@ nv50_sor_disconnect(struct nouveau_encoder *nv_encoder)
        struct nouveau_channel *evo = dev_priv->evo;
        int ret;
 
-       NV_DEBUG(dev, "Disconnecting SOR %d\n", nv_encoder->or);
+       NV_DEBUG_KMS(dev, "Disconnecting SOR %d\n", nv_encoder->or);
 
        ret = RING_SPACE(evo, 2);
        if (ret) {
@@ -70,7 +70,7 @@ nv50_sor_dp_link_train(struct drm_encoder *encoder)
        }
 
        if (dpe->script0) {
-               NV_DEBUG(dev, "SOR-%d: running DP script 0\n", nv_encoder->or);
+               NV_DEBUG_KMS(dev, "SOR-%d: running DP script 0\n", nv_encoder->or);
                nouveau_bios_run_init_table(dev, le16_to_cpu(dpe->script0),
                                            nv_encoder->dcb);
        }
@@ -79,7 +79,7 @@ nv50_sor_dp_link_train(struct drm_encoder *encoder)
                NV_ERROR(dev, "SOR-%d: link training failed\n", nv_encoder->or);
 
        if (dpe->script1) {
-               NV_DEBUG(dev, "SOR-%d: running DP script 1\n", nv_encoder->or);
+               NV_DEBUG_KMS(dev, "SOR-%d: running DP script 1\n", nv_encoder->or);
                nouveau_bios_run_init_table(dev, le16_to_cpu(dpe->script1),
                                            nv_encoder->dcb);
        }
@@ -93,7 +93,7 @@ nv50_sor_dpms(struct drm_encoder *encoder, int mode)
        uint32_t val;
        int or = nv_encoder->or;
 
-       NV_DEBUG(dev, "or %d mode %d\n", or, mode);
+       NV_DEBUG_KMS(dev, "or %d mode %d\n", or, mode);
 
        /* wait for it to be done */
        if (!nv_wait(NV50_PDISPLAY_SOR_DPMS_CTRL(or),
@@ -142,7 +142,7 @@ nv50_sor_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
        struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
        struct nouveau_connector *connector;
 
-       NV_DEBUG(encoder->dev, "or %d\n", nv_encoder->or);
+       NV_DEBUG_KMS(encoder->dev, "or %d\n", nv_encoder->or);
 
        connector = nouveau_encoder_connector_get(nv_encoder);
        if (!connector) {
@@ -182,7 +182,7 @@ nv50_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
        uint32_t mode_ctl = 0;
        int ret;
 
-       NV_DEBUG(dev, "or %d\n", nv_encoder->or);
+       NV_DEBUG_KMS(dev, "or %d\n", nv_encoder->or);
 
        nv50_sor_dpms(encoder, DRM_MODE_DPMS_ON);
 
@@ -246,7 +246,7 @@ nv50_sor_destroy(struct drm_encoder *encoder)
        if (!encoder)
                return;
 
-       NV_DEBUG(encoder->dev, "\n");
+       NV_DEBUG_KMS(encoder->dev, "\n");
 
        drm_encoder_cleanup(encoder);
 
@@ -265,7 +265,7 @@ nv50_sor_create(struct drm_device *dev, struct dcb_entry *entry)
        bool dum;
        int type;
 
-       NV_DEBUG(dev, "\n");
+       NV_DEBUG_KMS(dev, "\n");
 
        switch (entry->type) {
        case OUTPUT_TMDS:
index 601f4c0e5da57accd3e81ea1938f72bcf1c61c2e..b806fdcc717037fcbc8352be15cf3e08fd92908e 100644 (file)
@@ -64,7 +64,7 @@ static struct drm_driver driver = {
                .owner = THIS_MODULE,
                .open = drm_open,
                .release = drm_release,
-               .ioctl = drm_ioctl,
+               .unlocked_ioctl = drm_ioctl,
                .mmap = drm_mmap,
                .poll = drm_poll,
                .fasync = drm_fasync,
index d3cb676eee84493e0af7d9df4c445f18dd1766f3..51c99fc4dd3819959fe8cd1470c6ca18192cc558 100644 (file)
@@ -95,8 +95,7 @@ static int compat_r128_init(struct file *file, unsigned int cmd,
                          &init->agp_textures_offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_R128_INIT, (unsigned long)init);
+       return drm_ioctl(file, DRM_IOCTL_R128_INIT, (unsigned long)init);
 }
 
 typedef struct drm_r128_depth32 {
@@ -129,8 +128,7 @@ static int compat_r128_depth(struct file *file, unsigned int cmd,
                          &depth->mask))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_R128_DEPTH, (unsigned long)depth);
+       return drm_ioctl(file, DRM_IOCTL_R128_DEPTH, (unsigned long)depth);
 
 }
 
@@ -153,8 +151,7 @@ static int compat_r128_stipple(struct file *file, unsigned int cmd,
                          &stipple->mask))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_R128_STIPPLE, (unsigned long)stipple);
+       return drm_ioctl(file, DRM_IOCTL_R128_STIPPLE, (unsigned long)stipple);
 }
 
 typedef struct drm_r128_getparam32 {
@@ -178,8 +175,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
                          &getparam->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
+       return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
 }
 
 drm_ioctl_compat_t *r128_compat_ioctls[] = {
@@ -210,12 +206,10 @@ long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
                fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
 
-       lock_kernel();          /* XXX for now */
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
-       unlock_kernel();
+               ret = drm_ioctl(filp, cmd, arg);
 
        return ret;
 }
index feb52eee43147a8ad0e8b6ffc87d7825cb3444e2..b5f5fe75e6af350335f5d8dc59436149647d96ea 100644 (file)
@@ -49,7 +49,7 @@ radeon-y += radeon_device.o radeon_kms.o \
        radeon_cs.o radeon_bios.o radeon_benchmark.o r100.o r300.o r420.o \
        rs400.o rs600.o rs690.o rv515.o r520.o r600.o rv770.o radeon_test.o \
        r200.o radeon_legacy_tv.o r600_cs.o r600_blit.o r600_blit_shaders.o \
-       r600_blit_kms.o radeon_pm.o atombios_dp.o
+       r600_blit_kms.o radeon_pm.o atombios_dp.o r600_audio.o r600_hdmi.o
 
 radeon-$(CONFIG_COMPAT) += radeon_ioc32.o
 
index 6578d19dff93dafa2d910eaeaebe0cf2247c197f..388140a7e651d4224abc2bf9ebfe234dd0805299 100644 (file)
@@ -58,6 +58,7 @@ typedef struct {
 } atom_exec_context;
 
 int atom_debug = 0;
+static void atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params);
 void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params);
 
 static uint32_t atom_arg_mask[8] =
@@ -573,7 +574,7 @@ static void atom_op_calltable(atom_exec_context *ctx, int *ptr, int arg)
        else
                SDEBUG("   table: %d\n", idx);
        if (U16(ctx->ctx->cmd_table + 4 + 2 * idx))
-               atom_execute_table(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
+               atom_execute_table_locked(ctx->ctx, idx, ctx->ps + ctx->ps_shift);
 }
 
 static void atom_op_clear(atom_exec_context *ctx, int *ptr, int arg)
@@ -1040,7 +1041,7 @@ static struct {
        atom_op_shr, ATOM_ARG_MC}, {
 atom_op_debug, 0},};
 
-void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
+static void atom_execute_table_locked(struct atom_context *ctx, int index, uint32_t * params)
 {
        int base = CU16(ctx->cmd_table + 4 + 2 * index);
        int len, ws, ps, ptr;
@@ -1092,6 +1093,13 @@ void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
                kfree(ectx.ws);
 }
 
+void atom_execute_table(struct atom_context *ctx, int index, uint32_t * params)
+{
+       mutex_lock(&ctx->mutex);
+       atom_execute_table_locked(ctx, index, params);
+       mutex_unlock(&ctx->mutex);
+}
+
 static int atom_iio_len[] = { 1, 2, 3, 3, 3, 3, 4, 4, 4, 3 };
 
 static void atom_index_iio(struct atom_context *ctx, int base)
index 6671848e5ea1012ff0961a72e31f689a6f83f3d7..47fd943f6d1422afa6bab7561127450a3285756c 100644 (file)
@@ -120,6 +120,7 @@ struct card_info {
 
 struct atom_context {
        struct card_info *card;
+       struct mutex mutex;
        void *bios;
        uint32_t cmd_table, data_table;
        uint16_t *iio;
index 5f48515c77a78cadd95c604403c2ddb0aa32d2cf..91ad0d1c1b17e3d6101499bf4985894a250a392e 100644 (file)
@@ -4690,6 +4690,205 @@ typedef struct _ATOM_POWERPLAY_INFO_V3 {
        ATOM_POWERMODE_INFO_V3 asPowerPlayInfo[ATOM_MAX_NUMBEROF_POWER_BLOCK];
 } ATOM_POWERPLAY_INFO_V3;
 
+/* New PPlib */
+/**************************************************************************/
+typedef struct _ATOM_PPLIB_THERMALCONTROLLER
+
+{
+    UCHAR ucType;           // one of ATOM_PP_THERMALCONTROLLER_*
+    UCHAR ucI2cLine;        // as interpreted by DAL I2C
+    UCHAR ucI2cAddress;
+    UCHAR ucFanParameters;  // Fan Control Parameters.
+    UCHAR ucFanMinRPM;      // Fan Minimum RPM (hundreds) -- for display purposes only.
+    UCHAR ucFanMaxRPM;      // Fan Maximum RPM (hundreds) -- for display purposes only.
+    UCHAR ucReserved;       // ----
+    UCHAR ucFlags;          // to be defined
+} ATOM_PPLIB_THERMALCONTROLLER;
+
+#define ATOM_PP_FANPARAMETERS_TACHOMETER_PULSES_PER_REVOLUTION_MASK 0x0f
+#define ATOM_PP_FANPARAMETERS_NOFAN                                 0x80    // No fan is connected to this controller.
+
+#define ATOM_PP_THERMALCONTROLLER_NONE      0
+#define ATOM_PP_THERMALCONTROLLER_LM63      1  // Not used by PPLib
+#define ATOM_PP_THERMALCONTROLLER_ADM1032   2  // Not used by PPLib
+#define ATOM_PP_THERMALCONTROLLER_ADM1030   3  // Not used by PPLib
+#define ATOM_PP_THERMALCONTROLLER_MUA6649   4  // Not used by PPLib
+#define ATOM_PP_THERMALCONTROLLER_LM64      5
+#define ATOM_PP_THERMALCONTROLLER_F75375    6  // Not used by PPLib
+#define ATOM_PP_THERMALCONTROLLER_RV6xx     7
+#define ATOM_PP_THERMALCONTROLLER_RV770     8
+#define ATOM_PP_THERMALCONTROLLER_ADT7473   9
+
+typedef struct _ATOM_PPLIB_STATE
+{
+    UCHAR ucNonClockStateIndex;
+    UCHAR ucClockStateIndices[1]; // variable-sized
+} ATOM_PPLIB_STATE;
+
+//// ATOM_PPLIB_POWERPLAYTABLE::ulPlatformCaps
+#define ATOM_PP_PLATFORM_CAP_BACKBIAS 1
+#define ATOM_PP_PLATFORM_CAP_POWERPLAY 2
+#define ATOM_PP_PLATFORM_CAP_SBIOSPOWERSOURCE 4
+#define ATOM_PP_PLATFORM_CAP_ASPM_L0s 8
+#define ATOM_PP_PLATFORM_CAP_ASPM_L1 16
+#define ATOM_PP_PLATFORM_CAP_HARDWAREDC 32
+#define ATOM_PP_PLATFORM_CAP_GEMINIPRIMARY 64
+#define ATOM_PP_PLATFORM_CAP_STEPVDDC 128
+#define ATOM_PP_PLATFORM_CAP_VOLTAGECONTROL 256
+#define ATOM_PP_PLATFORM_CAP_SIDEPORTCONTROL 512
+#define ATOM_PP_PLATFORM_CAP_TURNOFFPLL_ASPML1 1024
+#define ATOM_PP_PLATFORM_CAP_HTLINKCONTROL 2048
+
+typedef struct _ATOM_PPLIB_POWERPLAYTABLE
+{
+      ATOM_COMMON_TABLE_HEADER sHeader;
+
+      UCHAR ucDataRevision;
+
+      UCHAR ucNumStates;
+      UCHAR ucStateEntrySize;
+      UCHAR ucClockInfoSize;
+      UCHAR ucNonClockSize;
+
+      // offset from start of this table to array of ucNumStates ATOM_PPLIB_STATE structures
+      USHORT usStateArrayOffset;
+
+      // offset from start of this table to array of ASIC-specific structures,
+      // currently ATOM_PPLIB_CLOCK_INFO.
+      USHORT usClockInfoArrayOffset;
+
+      // offset from start of this table to array of ATOM_PPLIB_NONCLOCK_INFO
+      USHORT usNonClockInfoArrayOffset;
+
+      USHORT usBackbiasTime;    // in microseconds
+      USHORT usVoltageTime;     // in microseconds
+      USHORT usTableSize;       //the size of this structure, or the extended structure
+
+      ULONG ulPlatformCaps;            // See ATOM_PPLIB_CAPS_*
+
+      ATOM_PPLIB_THERMALCONTROLLER    sThermalController;
+
+      USHORT usBootClockInfoOffset;
+      USHORT usBootNonClockInfoOffset;
+
+} ATOM_PPLIB_POWERPLAYTABLE;
+
+//// ATOM_PPLIB_NONCLOCK_INFO::usClassification
+#define ATOM_PPLIB_CLASSIFICATION_UI_MASK          0x0007
+#define ATOM_PPLIB_CLASSIFICATION_UI_SHIFT         0
+#define ATOM_PPLIB_CLASSIFICATION_UI_NONE          0
+#define ATOM_PPLIB_CLASSIFICATION_UI_BATTERY       1
+#define ATOM_PPLIB_CLASSIFICATION_UI_BALANCED      3
+#define ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE   5
+// 2, 4, 6, 7 are reserved
+
+#define ATOM_PPLIB_CLASSIFICATION_BOOT                   0x0008
+#define ATOM_PPLIB_CLASSIFICATION_THERMAL                0x0010
+#define ATOM_PPLIB_CLASSIFICATION_LIMITEDPOWERSOURCE     0x0020
+#define ATOM_PPLIB_CLASSIFICATION_REST                   0x0040
+#define ATOM_PPLIB_CLASSIFICATION_FORCED                 0x0080
+#define ATOM_PPLIB_CLASSIFICATION_3DPERFORMANCE          0x0100
+#define ATOM_PPLIB_CLASSIFICATION_OVERDRIVETEMPLATE      0x0200
+#define ATOM_PPLIB_CLASSIFICATION_UVDSTATE               0x0400
+#define ATOM_PPLIB_CLASSIFICATION_3DLOW                  0x0800
+#define ATOM_PPLIB_CLASSIFICATION_ACPI                   0x1000
+// remaining 3 bits are reserved
+
+//// ATOM_PPLIB_NONCLOCK_INFO::ulCapsAndSettings
+#define ATOM_PPLIB_SINGLE_DISPLAY_ONLY           0x00000001
+#define ATOM_PPLIB_SUPPORTS_VIDEO_PLAYBACK         0x00000002
+
+// 0 is 2.5Gb/s, 1 is 5Gb/s
+#define ATOM_PPLIB_PCIE_LINK_SPEED_MASK            0x00000004
+#define ATOM_PPLIB_PCIE_LINK_SPEED_SHIFT           2
+
+// lanes - 1: 1, 2, 4, 8, 12, 16 permitted by PCIE spec
+#define ATOM_PPLIB_PCIE_LINK_WIDTH_MASK            0x000000F8
+#define ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT           3
+
+// lookup into reduced refresh-rate table
+#define ATOM_PPLIB_LIMITED_REFRESHRATE_VALUE_MASK  0x00000F00
+#define ATOM_PPLIB_LIMITED_REFRESHRATE_VALUE_SHIFT 8
+
+#define ATOM_PPLIB_LIMITED_REFRESHRATE_UNLIMITED    0
+#define ATOM_PPLIB_LIMITED_REFRESHRATE_50HZ         1
+// 2-15 TBD as needed.
+
+#define ATOM_PPLIB_SOFTWARE_DISABLE_LOADBALANCING        0x00001000
+#define ATOM_PPLIB_SOFTWARE_ENABLE_SLEEP_FOR_TIMESTAMPS  0x00002000
+#define ATOM_PPLIB_ENABLE_VARIBRIGHT                     0x00008000
+
+#define ATOM_PPLIB_DISALLOW_ON_DC                       0x00004000
+
+// Contained in an array starting at the offset
+// in ATOM_PPLIB_POWERPLAYTABLE::usNonClockInfoArrayOffset.
+// referenced from ATOM_PPLIB_STATE_INFO::ucNonClockStateIndex
+typedef struct _ATOM_PPLIB_NONCLOCK_INFO
+{
+      USHORT usClassification;
+      UCHAR  ucMinTemperature;
+      UCHAR  ucMaxTemperature;
+      ULONG  ulCapsAndSettings;
+      UCHAR  ucRequiredPower;
+      UCHAR  ucUnused1[3];
+} ATOM_PPLIB_NONCLOCK_INFO;
+
+// Contained in an array starting at the offset
+// in ATOM_PPLIB_POWERPLAYTABLE::usClockInfoArrayOffset.
+// referenced from ATOM_PPLIB_STATE::ucClockStateIndices
+typedef struct _ATOM_PPLIB_R600_CLOCK_INFO
+{
+      USHORT usEngineClockLow;
+      UCHAR ucEngineClockHigh;
+
+      USHORT usMemoryClockLow;
+      UCHAR ucMemoryClockHigh;
+
+      USHORT usVDDC;
+      USHORT usUnused1;
+      USHORT usUnused2;
+
+      ULONG ulFlags; // ATOM_PPLIB_R600_FLAGS_*
+
+} ATOM_PPLIB_R600_CLOCK_INFO;
+
+// ulFlags in ATOM_PPLIB_R600_CLOCK_INFO
+#define ATOM_PPLIB_R600_FLAGS_PCIEGEN2          1
+#define ATOM_PPLIB_R600_FLAGS_UVDSAFE           2
+#define ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE    4
+#define ATOM_PPLIB_R600_FLAGS_MEMORY_ODT_OFF    8
+#define ATOM_PPLIB_R600_FLAGS_MEMORY_DLL_OFF    16
+
+typedef struct _ATOM_PPLIB_RS780_CLOCK_INFO
+
+{
+      USHORT usLowEngineClockLow;         // Low Engine clock in MHz (the same way as on the R600).
+      UCHAR  ucLowEngineClockHigh;
+      USHORT usHighEngineClockLow;        // High Engine clock in MHz.
+      UCHAR  ucHighEngineClockHigh;
+      USHORT usMemoryClockLow;            // For now one of the ATOM_PPLIB_RS780_SPMCLK_XXXX constants.
+      UCHAR  ucMemoryClockHigh;           // Currentyl unused.
+      UCHAR  ucPadding;                   // For proper alignment and size.
+      USHORT usVDDC;                      // For the 780, use: None, Low, High, Variable
+      UCHAR  ucMaxHTLinkWidth;            // From SBIOS - {2, 4, 8, 16}
+      UCHAR  ucMinHTLinkWidth;            // From SBIOS - {2, 4, 8, 16}. Effective only if CDLW enabled. Minimum down stream width could be bigger as display BW requriement.
+      USHORT usHTLinkFreq;                // See definition ATOM_PPLIB_RS780_HTLINKFREQ_xxx or in MHz(>=200).
+      ULONG  ulFlags;
+} ATOM_PPLIB_RS780_CLOCK_INFO;
+
+#define ATOM_PPLIB_RS780_VOLTAGE_NONE       0
+#define ATOM_PPLIB_RS780_VOLTAGE_LOW        1
+#define ATOM_PPLIB_RS780_VOLTAGE_HIGH       2
+#define ATOM_PPLIB_RS780_VOLTAGE_VARIABLE   3
+
+#define ATOM_PPLIB_RS780_SPMCLK_NONE        0   // We cannot change the side port memory clock, leave it as it is.
+#define ATOM_PPLIB_RS780_SPMCLK_LOW         1
+#define ATOM_PPLIB_RS780_SPMCLK_HIGH        2
+
+#define ATOM_PPLIB_RS780_HTLINKFREQ_NONE       0
+#define ATOM_PPLIB_RS780_HTLINKFREQ_LOW        1
+#define ATOM_PPLIB_RS780_HTLINKFREQ_HIGH       2
+
 /**************************************************************************/
 
 /*  Following definitions are for compatiblity issue in different SW components. */
index 824cc6480a0654125aae84fc9f5286cde4f3e27b..71727460968f9d25445c9f179d55e7856729fb5e 100644 (file)
@@ -1374,7 +1374,6 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
                case RADEON_TXFORMAT_ARGB4444:
                case RADEON_TXFORMAT_VYUY422:
                case RADEON_TXFORMAT_YVYU422:
-               case RADEON_TXFORMAT_DXT1:
                case RADEON_TXFORMAT_SHADOW16:
                case RADEON_TXFORMAT_LDUDV655:
                case RADEON_TXFORMAT_DUDV88:
@@ -1382,12 +1381,19 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
                        break;
                case RADEON_TXFORMAT_ARGB8888:
                case RADEON_TXFORMAT_RGBA8888:
-               case RADEON_TXFORMAT_DXT23:
-               case RADEON_TXFORMAT_DXT45:
                case RADEON_TXFORMAT_SHADOW32:
                case RADEON_TXFORMAT_LDUDUV8888:
                        track->textures[i].cpp = 4;
                        break;
+               case RADEON_TXFORMAT_DXT1:
+                       track->textures[i].cpp = 1;
+                       track->textures[i].compress_format = R100_TRACK_COMP_DXT1;
+                       break;
+               case RADEON_TXFORMAT_DXT23:
+               case RADEON_TXFORMAT_DXT45:
+                       track->textures[i].cpp = 1;
+                       track->textures[i].compress_format = R100_TRACK_COMP_DXT35;
+                       break;
                }
                track->textures[i].cube_info[4].width = 1 << ((idx_value >> 16) & 0xf);
                track->textures[i].cube_info[4].height = 1 << ((idx_value >> 20) & 0xf);
@@ -2731,6 +2737,7 @@ static inline void r100_cs_track_texture_print(struct r100_cs_track_texture *t)
        DRM_ERROR("coordinate type            %d\n", t->tex_coord_type);
        DRM_ERROR("width round to power of 2  %d\n", t->roundup_w);
        DRM_ERROR("height round to power of 2 %d\n", t->roundup_h);
+       DRM_ERROR("compress format            %d\n", t->compress_format);
 }
 
 static int r100_cs_track_cube(struct radeon_device *rdev,
@@ -2760,6 +2767,36 @@ static int r100_cs_track_cube(struct radeon_device *rdev,
        return 0;
 }
 
+static int r100_track_compress_size(int compress_format, int w, int h)
+{
+       int block_width, block_height, block_bytes;
+       int wblocks, hblocks;
+       int min_wblocks;
+       int sz;
+
+       block_width = 4;
+       block_height = 4;
+
+       switch (compress_format) {
+       case R100_TRACK_COMP_DXT1:
+               block_bytes = 8;
+               min_wblocks = 4;
+               break;
+       default:
+       case R100_TRACK_COMP_DXT35:
+               block_bytes = 16;
+               min_wblocks = 2;
+               break;
+       }
+
+       hblocks = (h + block_height - 1) / block_height;
+       wblocks = (w + block_width - 1) / block_width;
+       if (wblocks < min_wblocks)
+               wblocks = min_wblocks;
+       sz = wblocks * hblocks * block_bytes;
+       return sz;
+}
+
 static int r100_cs_track_texture_check(struct radeon_device *rdev,
                                       struct r100_cs_track *track)
 {
@@ -2797,9 +2834,15 @@ static int r100_cs_track_texture_check(struct radeon_device *rdev,
                        h = h / (1 << i);
                        if (track->textures[u].roundup_h)
                                h = roundup_pow_of_two(h);
-                       size += w * h;
+                       if (track->textures[u].compress_format) {
+
+                               size += r100_track_compress_size(track->textures[u].compress_format, w, h);
+                               /* compressed textures are block based */
+                       } else
+                               size += w * h;
                }
                size *= track->textures[u].cpp;
+
                switch (track->textures[u].tex_coord_type) {
                case 0:
                        break;
@@ -2838,6 +2881,10 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track)
 
        for (i = 0; i < track->num_cb; i++) {
                if (track->cb[i].robj == NULL) {
+                       if (!(track->fastfill || track->color_channel_mask ||
+                             track->blend_read_enable)) {
+                               continue;
+                       }
                        DRM_ERROR("[drm] No buffer for color buffer %d !\n", i);
                        return -EINVAL;
                }
@@ -2967,6 +3014,7 @@ void r100_cs_track_clear(struct radeon_device *rdev, struct r100_cs_track *track
                track->arrays[i].esize = 0x7F;
        }
        for (i = 0; i < track->num_texture; i++) {
+               track->textures[i].compress_format = R100_TRACK_COMP_NONE;
                track->textures[i].pitch = 16536;
                track->textures[i].width = 16536;
                track->textures[i].height = 16536;
@@ -3399,6 +3447,8 @@ int r100_init(struct radeon_device *rdev)
        r100_errata(rdev);
        /* Initialize clocks */
        radeon_get_clock_info(rdev->ddev);
+       /* Initialize power management */
+       radeon_pm_init(rdev);
        /* Get vram informations */
        r100_vram_info(rdev);
        /* Initialize memory controller (also test AGP) */
index ca50903dd2bbff85d8c886f00886e36219f2f961..b27a6999d21938413cd8ef8258e5b26d85499d93 100644 (file)
@@ -28,6 +28,10 @@ struct r100_cs_cube_info {
        unsigned                height;
 };
 
+#define R100_TRACK_COMP_NONE   0
+#define R100_TRACK_COMP_DXT1   1
+#define R100_TRACK_COMP_DXT35  2
+
 struct r100_cs_track_texture {
        struct radeon_bo        *robj;
        struct r100_cs_cube_info cube_info[5]; /* info for 5 non-primary faces */
@@ -44,6 +48,7 @@ struct r100_cs_track_texture {
        bool                    enabled;
        bool                    roundup_w;
        bool                    roundup_h;
+       unsigned                compress_format;
 };
 
 struct r100_cs_track_limits {
@@ -62,13 +67,15 @@ struct r100_cs_track {
        unsigned                        immd_dwords;
        unsigned                        num_arrays;
        unsigned                        max_indx;
+       unsigned                        color_channel_mask;
        struct r100_cs_track_array      arrays[11];
        struct r100_cs_track_cb         cb[R300_MAX_CB];
        struct r100_cs_track_cb         zb;
        struct r100_cs_track_texture    textures[R300_TRACK_MAX_TEXTURE];
        bool                            z_enabled;
        bool                            separate_cube;
-
+       bool                            fastfill;
+       bool                            blend_read_enable;
 };
 
 int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track);
index eb740fc3549f82c5530c5450f4862ca8cf764fa3..20942127c46b216861d2b1d29c7a45e5c549b66c 100644 (file)
@@ -401,7 +401,6 @@ int r200_packet0_check(struct radeon_cs_parser *p,
                case R200_TXFORMAT_Y8:
                        track->textures[i].cpp = 1;
                        break;
-               case R200_TXFORMAT_DXT1:
                case R200_TXFORMAT_AI88:
                case R200_TXFORMAT_ARGB1555:
                case R200_TXFORMAT_RGB565:
@@ -418,9 +417,16 @@ int r200_packet0_check(struct radeon_cs_parser *p,
                case R200_TXFORMAT_ABGR8888:
                case R200_TXFORMAT_BGR111110:
                case R200_TXFORMAT_LDVDU8888:
+                       track->textures[i].cpp = 4;
+                       break;
+               case R200_TXFORMAT_DXT1:
+                       track->textures[i].cpp = 1;
+                       track->textures[i].compress_format = R100_TRACK_COMP_DXT1;
+                       break;
                case R200_TXFORMAT_DXT23:
                case R200_TXFORMAT_DXT45:
-                       track->textures[i].cpp = 4;
+                       track->textures[i].cpp = 1;
+                       track->textures[i].compress_format = R100_TRACK_COMP_DXT1;
                        break;
                }
                track->textures[i].cube_info[4].width = 1 << ((idx_value >> 16) & 0xf);
index 83378c39d0e3abf207aa60e80f910f34c5fc0162..3f2cc9e2e8d9a9f4a629361a2ea545c5f1b61f2c 100644 (file)
@@ -686,7 +686,15 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
                        r100_cs_dump_packet(p, pkt);
                        return r;
                }
-               ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
+
+               if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
+                       tile_flags |= R300_TXO_MACRO_TILE;
+               if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO)
+                       tile_flags |= R300_TXO_MICRO_TILE;
+
+               tmp = idx_value + ((u32)reloc->lobj.gpu_offset);
+               tmp |= tile_flags;
+               ib[idx] = tmp;
                track->textures[i].robj = reloc->robj;
                break;
        /* Tracked registers */
@@ -852,7 +860,6 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
                case R300_TX_FORMAT_Z6Y5X5:
                case R300_TX_FORMAT_W4Z4Y4X4:
                case R300_TX_FORMAT_W1Z5Y5X5:
-               case R300_TX_FORMAT_DXT1:
                case R300_TX_FORMAT_D3DMFT_CxV8U8:
                case R300_TX_FORMAT_B8G8_B8G8:
                case R300_TX_FORMAT_G8R8_G8B8:
@@ -866,8 +873,6 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
                case 0x17:
                case R300_TX_FORMAT_FL_I32:
                case 0x1e:
-               case R300_TX_FORMAT_DXT3:
-               case R300_TX_FORMAT_DXT5:
                        track->textures[i].cpp = 4;
                        break;
                case R300_TX_FORMAT_W16Z16Y16X16:
@@ -878,6 +883,23 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
                case R300_TX_FORMAT_FL_R32G32B32A32:
                        track->textures[i].cpp = 16;
                        break;
+               case R300_TX_FORMAT_DXT1:
+                       track->textures[i].cpp = 1;
+                       track->textures[i].compress_format = R100_TRACK_COMP_DXT1;
+                       break;
+               case R300_TX_FORMAT_ATI2N:
+                       if (p->rdev->family < CHIP_R420) {
+                               DRM_ERROR("Invalid texture format %u\n",
+                                         (idx_value & 0x1F));
+                               return -EINVAL;
+                       }
+                       /* The same rules apply as for DXT3/5. */
+                       /* Pass through. */
+               case R300_TX_FORMAT_DXT3:
+               case R300_TX_FORMAT_DXT5:
+                       track->textures[i].cpp = 1;
+                       track->textures[i].compress_format = R100_TRACK_COMP_DXT35;
+                       break;
                default:
                        DRM_ERROR("Invalid texture format %u\n",
                                  (idx_value & 0x1F));
@@ -937,6 +959,16 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
                        track->textures[i].width_11 = tmp;
                        tmp = ((idx_value >> 16) & 1) << 11;
                        track->textures[i].height_11 = tmp;
+
+                       /* ATI1N */
+                       if (idx_value & (1 << 14)) {
+                               /* The same rules apply as for DXT1. */
+                               track->textures[i].compress_format =
+                                       R100_TRACK_COMP_DXT1;
+                       }
+               } else if (idx_value & (1 << 14)) {
+                       DRM_ERROR("Forbidden bit TXFORMAT_MSB\n");
+                       return -EINVAL;
                }
                break;
        case 0x4480:
@@ -978,6 +1010,18 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
                }
                ib[idx] = idx_value + ((u32)reloc->lobj.gpu_offset);
                break;
+       case 0x4e0c:
+               /* RB3D_COLOR_CHANNEL_MASK */
+               track->color_channel_mask = idx_value;
+               break;
+       case 0x4d1c:
+               /* ZB_BW_CNTL */
+               track->fastfill = !!(idx_value & (1 << 2));
+               break;
+       case 0x4e04:
+               /* RB3D_BLENDCNTL */
+               track->blend_read_enable = !!(idx_value & (1 << 2));
+               break;
        case 0x4be8:
                /* valid register only on RV530 */
                if (p->rdev->family == CHIP_RV530)
@@ -1324,6 +1368,8 @@ int r300_init(struct radeon_device *rdev)
        r300_errata(rdev);
        /* Initialize clocks */
        radeon_get_clock_info(rdev->ddev);
+       /* Initialize power management */
+       radeon_pm_init(rdev);
        /* Get vram informations */
        r300_vram_info(rdev);
        /* Initialize memory controller (also test AGP) */
index cb2e470f97d4d100e073cf953b170a72ae1d6d51..34bffa0e4b73acc358598c489fd0549ec275a918 100644 (file)
@@ -990,7 +990,7 @@ static inline int r300_emit_r500fp(drm_radeon_private_t *dev_priv,
        int sz;
        int addr;
        int type;
-       int clamp;
+       int isclamp;
        int stride;
        RING_LOCALS;
 
@@ -999,10 +999,10 @@ static inline int r300_emit_r500fp(drm_radeon_private_t *dev_priv,
        addr = ((header.r500fp.adrhi_flags & 1) << 8) | header.r500fp.adrlo;
 
        type = !!(header.r500fp.adrhi_flags & R500FP_CONSTANT_TYPE);
-       clamp = !!(header.r500fp.adrhi_flags & R500FP_CONSTANT_CLAMP);
+       isclamp = !!(header.r500fp.adrhi_flags & R500FP_CONSTANT_CLAMP);
 
        addr |= (type << 16);
-       addr |= (clamp << 17);
+       addr |= (isclamp << 17);
 
        stride = type ? 4 : 6;
 
index 4b7afef35a655511a2431682bd77e24fe37838b4..1735a2b695806af1c41ed9bd649f5d4a05b4d935 100644 (file)
 #      define R300_TX_FORMAT_FL_I32                0x1B
 #      define R300_TX_FORMAT_FL_I32A32             0x1C
 #      define R300_TX_FORMAT_FL_R32G32B32A32       0x1D
+#      define R300_TX_FORMAT_ATI2N                 0x1F
        /* alpha modes, convenience mostly */
        /* if you have alpha, pick constant appropriate to the
           number of channels (1 for I8, 2 for I8A8, 4 for R8G8B8A8, etc */
index 36656bd110bfda3e00473d8830f7b373098fe49d..a0ac3c134b1bb560503b6d60418ce9563f614990 100644 (file)
@@ -1863,6 +1863,14 @@ int r600_startup(struct radeon_device *rdev)
        }
        r600_gpu_init(rdev);
 
+       if (!rdev->r600_blit.shader_obj) {
+               r = r600_blit_init(rdev);
+               if (r) {
+                       DRM_ERROR("radeon: failed blitter (%d).\n", r);
+                       return r;
+               }
+       }
+
        r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false);
        if (unlikely(r != 0))
                return r;
@@ -2038,12 +2046,6 @@ int r600_init(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = r600_blit_init(rdev);
-       if (r) {
-               DRM_ERROR("radeon: failed blitter (%d).\n", r);
-               return r;
-       }
-
        rdev->accel_working = true;
        r = r600_startup(rdev);
        if (r) {
@@ -2065,6 +2067,10 @@ int r600_init(struct radeon_device *rdev)
                        rdev->accel_working = false;
                }
        }
+
+       r = r600_audio_init(rdev);
+       if (r)
+               return r; /* TODO error handling */
        return 0;
 }
 
@@ -2073,6 +2079,7 @@ void r600_fini(struct radeon_device *rdev)
        /* Suspend operations */
        r600_suspend(rdev);
 
+       r600_audio_fini(rdev);
        r600_blit_fini(rdev);
        r600_irq_fini(rdev);
        radeon_irq_kms_fini(rdev);
diff --git a/drivers/gpu/drm/radeon/r600_audio.c b/drivers/gpu/drm/radeon/r600_audio.c
new file mode 100644 (file)
index 0000000..99e2c38
--- /dev/null
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2008 Advanced Micro Devices, Inc.
+ * Copyright 2008 Red Hat Inc.
+ * Copyright 2009 Christian König.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Christian König
+ */
+#include "drmP.h"
+#include "radeon.h"
+#include "radeon_reg.h"
+#include "atom.h"
+
+#define AUDIO_TIMER_INTERVALL 100 /* 1/10 sekund should be enough */
+
+/*
+ * check if the chipset is supported
+ */
+static int r600_audio_chipset_supported(struct radeon_device *rdev)
+{
+       return rdev->family >= CHIP_R600
+               || rdev->family == CHIP_RS600
+               || rdev->family == CHIP_RS690
+               || rdev->family == CHIP_RS740;
+}
+
+/*
+ * current number of channels
+ */
+static int r600_audio_channels(struct radeon_device *rdev)
+{
+       return (RREG32(R600_AUDIO_RATE_BPS_CHANNEL) & 0x7) + 1;
+}
+
+/*
+ * current bits per sample
+ */
+static int r600_audio_bits_per_sample(struct radeon_device *rdev)
+{
+       uint32_t value = (RREG32(R600_AUDIO_RATE_BPS_CHANNEL) & 0xF0) >> 4;
+       switch (value) {
+       case 0x0: return  8;
+       case 0x1: return 16;
+       case 0x2: return 20;
+       case 0x3: return 24;
+       case 0x4: return 32;
+       }
+
+       DRM_ERROR("Unknown bits per sample 0x%x using 16 instead.\n", (int)value);
+
+       return 16;
+}
+
+/*
+ * current sampling rate in HZ
+ */
+static int r600_audio_rate(struct radeon_device *rdev)
+{
+       uint32_t value = RREG32(R600_AUDIO_RATE_BPS_CHANNEL);
+       uint32_t result;
+
+       if (value & 0x4000)
+               result = 44100;
+       else
+               result = 48000;
+
+       result *= ((value >> 11) & 0x7) + 1;
+       result /= ((value >> 8) & 0x7) + 1;
+
+       return result;
+}
+
+/*
+ * iec 60958 status bits
+ */
+static uint8_t r600_audio_status_bits(struct radeon_device *rdev)
+{
+       return RREG32(R600_AUDIO_STATUS_BITS) & 0xff;
+}
+
+/*
+ * iec 60958 category code
+ */
+static uint8_t r600_audio_category_code(struct radeon_device *rdev)
+{
+       return (RREG32(R600_AUDIO_STATUS_BITS) >> 8) & 0xff;
+}
+
+/*
+ * update all hdmi interfaces with current audio parameters
+ */
+static void r600_audio_update_hdmi(unsigned long param)
+{
+       struct radeon_device *rdev = (struct radeon_device *)param;
+       struct drm_device *dev = rdev->ddev;
+
+       int channels = r600_audio_channels(rdev);
+       int rate = r600_audio_rate(rdev);
+       int bps = r600_audio_bits_per_sample(rdev);
+       uint8_t status_bits = r600_audio_status_bits(rdev);
+       uint8_t category_code = r600_audio_category_code(rdev);
+
+       struct drm_encoder *encoder;
+       int changes = 0;
+
+       changes |= channels != rdev->audio_channels;
+       changes |= rate != rdev->audio_rate;
+       changes |= bps != rdev->audio_bits_per_sample;
+       changes |= status_bits != rdev->audio_status_bits;
+       changes |= category_code != rdev->audio_category_code;
+
+       if (changes) {
+               rdev->audio_channels = channels;
+               rdev->audio_rate = rate;
+               rdev->audio_bits_per_sample = bps;
+               rdev->audio_status_bits = status_bits;
+               rdev->audio_category_code = category_code;
+       }
+
+       list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+               if (changes || r600_hdmi_buffer_status_changed(encoder))
+                       r600_hdmi_update_audio_settings(
+                               encoder, channels,
+                               rate, bps, status_bits,
+                               category_code);
+       }
+
+       mod_timer(&rdev->audio_timer,
+               jiffies + msecs_to_jiffies(AUDIO_TIMER_INTERVALL));
+}
+
+/*
+ * initialize the audio vars and register the update timer
+ */
+int r600_audio_init(struct radeon_device *rdev)
+{
+       if (!r600_audio_chipset_supported(rdev))
+               return 0;
+
+       DRM_INFO("%s audio support", radeon_audio ? "Enabling" : "Disabling");
+       WREG32_P(R600_AUDIO_ENABLE, radeon_audio ? 0x81000000 : 0x0, ~0x81000000);
+
+       rdev->audio_channels = -1;
+       rdev->audio_rate = -1;
+       rdev->audio_bits_per_sample = -1;
+       rdev->audio_status_bits = 0;
+       rdev->audio_category_code = 0;
+
+       setup_timer(
+               &rdev->audio_timer,
+               r600_audio_update_hdmi,
+               (unsigned long)rdev);
+
+       mod_timer(&rdev->audio_timer, jiffies + 1);
+
+       return 0;
+}
+
+/*
+ * determin how the encoders and audio interface is wired together
+ */
+int r600_audio_tmds_index(struct drm_encoder *encoder)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+       struct drm_encoder *other;
+
+       switch (radeon_encoder->encoder_id) {
+       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
+               return 0;
+
+       case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
+               /* special case check if an TMDS1 is present */
+               list_for_each_entry(other, &dev->mode_config.encoder_list, head) {
+                       if (to_radeon_encoder(other)->encoder_id ==
+                               ENCODER_OBJECT_ID_INTERNAL_TMDS1)
+                               return 1;
+               }
+               return 0;
+
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
+       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
+               return 1;
+
+       default:
+               DRM_ERROR("Unsupported encoder type 0x%02X\n",
+                         radeon_encoder->encoder_id);
+               return -1;
+       }
+}
+
+/*
+ * atach the audio codec to the clock source of the encoder
+ */
+void r600_audio_set_clock(struct drm_encoder *encoder, int clock)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+       int base_rate = 48000;
+
+       switch (radeon_encoder->encoder_id) {
+       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
+       case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
+               WREG32_P(R600_AUDIO_TIMING, 0, ~0x301);
+               break;
+
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
+       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
+               WREG32_P(R600_AUDIO_TIMING, 0x100, ~0x301);
+               break;
+
+       default:
+               DRM_ERROR("Unsupported encoder type 0x%02X\n",
+                         radeon_encoder->encoder_id);
+               return;
+       }
+
+       switch (r600_audio_tmds_index(encoder)) {
+       case 0:
+               WREG32(R600_AUDIO_PLL1_MUL, base_rate*50);
+               WREG32(R600_AUDIO_PLL1_DIV, clock*100);
+               WREG32(R600_AUDIO_CLK_SRCSEL, 0);
+               break;
+
+       case 1:
+               WREG32(R600_AUDIO_PLL2_MUL, base_rate*50);
+               WREG32(R600_AUDIO_PLL2_DIV, clock*100);
+               WREG32(R600_AUDIO_CLK_SRCSEL, 1);
+               break;
+       }
+}
+
+/*
+ * release the audio timer
+ * TODO: How to do this correctly on SMP systems?
+ */
+void r600_audio_fini(struct radeon_device *rdev)
+{
+       if (!r600_audio_chipset_supported(rdev))
+               return;
+
+       WREG32_P(R600_AUDIO_ENABLE, 0x0, ~0x81000000);
+
+       del_timer(&rdev->audio_timer);
+}
index 0d820764f34074dc47b8164895a446b1510649af..44060b92d9e6df4e464a9c91dce2f16e2245b4af 100644 (file)
@@ -170,7 +170,7 @@ static int r600_cs_packet_next_reloc_nomm(struct radeon_cs_parser *p,
                          idx, relocs_chunk->length_dw);
                return -EINVAL;
        }
-       *cs_reloc = &p->relocs[0];
+       *cs_reloc = p->relocs;
        (*cs_reloc)->lobj.gpu_offset = (u64)relocs_chunk->kdata[idx + 3] << 32;
        (*cs_reloc)->lobj.gpu_offset |= relocs_chunk->kdata[idx + 0];
        return 0;
@@ -717,7 +717,7 @@ static int r600_cs_parser_relocs_legacy(struct radeon_cs_parser *p)
        if (p->chunk_relocs_idx == -1) {
                return 0;
        }
-       p->relocs = kcalloc(1, sizeof(struct radeon_cs_reloc), GFP_KERNEL);
+       p->relocs = kzalloc(sizeof(struct radeon_cs_reloc), GFP_KERNEL);
        if (p->relocs == NULL) {
                return -ENOMEM;
        }
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
new file mode 100644 (file)
index 0000000..fcc949d
--- /dev/null
@@ -0,0 +1,506 @@
+/*
+ * Copyright 2008 Advanced Micro Devices, Inc.
+ * Copyright 2008 Red Hat Inc.
+ * Copyright 2009 Christian König.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Christian König
+ */
+#include "drmP.h"
+#include "radeon_drm.h"
+#include "radeon.h"
+#include "atom.h"
+
+/*
+ * HDMI color format
+ */
+enum r600_hdmi_color_format {
+       RGB = 0,
+       YCC_422 = 1,
+       YCC_444 = 2
+};
+
+/*
+ * IEC60958 status bits
+ */
+enum r600_hdmi_iec_status_bits {
+       AUDIO_STATUS_DIG_ENABLE   = 0x01,
+       AUDIO_STATUS_V      = 0x02,
+       AUDIO_STATUS_VCFG        = 0x04,
+       AUDIO_STATUS_EMPHASIS     = 0x08,
+       AUDIO_STATUS_COPYRIGHT    = 0x10,
+       AUDIO_STATUS_NONAUDIO     = 0x20,
+       AUDIO_STATUS_PROFESSIONAL = 0x40,
+       AUDIO_STATUS_LEVEL      = 0x80
+};
+
+struct {
+       uint32_t Clock;
+
+       int N_32kHz;
+       int CTS_32kHz;
+
+       int N_44_1kHz;
+       int CTS_44_1kHz;
+
+       int N_48kHz;
+       int CTS_48kHz;
+
+} r600_hdmi_ACR[] = {
+    /*      32kHz        44.1kHz       48kHz    */
+    /* Clock      N     CTS      N     CTS      N     CTS */
+    {  25174,  4576,  28125,  7007,  31250,  6864,  28125 }, /*  25,20/1.001 MHz */
+    {  25200,  4096,  25200,  6272,  28000,  6144,  25200 }, /*  25.20       MHz */
+    {  27000,  4096,  27000,  6272,  30000,  6144,  27000 }, /*  27.00       MHz */
+    {  27027,  4096,  27027,  6272,  30030,  6144,  27027 }, /*  27.00*1.001 MHz */
+    {  54000,  4096,  54000,  6272,  60000,  6144,  54000 }, /*  54.00       MHz */
+    {  54054,  4096,  54054,  6272,  60060,  6144,  54054 }, /*  54.00*1.001 MHz */
+    {  74175, 11648, 210937, 17836, 234375, 11648, 140625 }, /*  74.25/1.001 MHz */
+    {  74250,  4096,  74250,  6272,  82500,  6144,  74250 }, /*  74.25       MHz */
+    { 148351, 11648, 421875,  8918, 234375,  5824, 140625 }, /* 148.50/1.001 MHz */
+    { 148500,  4096, 148500,  6272, 165000,  6144, 148500 }, /* 148.50       MHz */
+    {      0,  4096,      0,  6272,      0,  6144,      0 }  /* Other */
+};
+
+/*
+ * calculate CTS value if it's not found in the table
+ */
+static void r600_hdmi_calc_CTS(uint32_t clock, int *CTS, int N, int freq)
+{
+       if (*CTS == 0)
+               *CTS = clock*N/(128*freq)*1000;
+       DRM_DEBUG("Using ACR timing N=%d CTS=%d for frequency %d\n",
+                 N, *CTS, freq);
+}
+
+/*
+ * update the N and CTS parameters for a given pixel clock rate
+ */
+static void r600_hdmi_update_ACR(struct drm_encoder *encoder, uint32_t clock)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
+       int CTS;
+       int N;
+       int i;
+
+       for (i = 0; r600_hdmi_ACR[i].Clock != clock && r600_hdmi_ACR[i].Clock != 0; i++);
+
+       CTS = r600_hdmi_ACR[i].CTS_32kHz;
+       N = r600_hdmi_ACR[i].N_32kHz;
+       r600_hdmi_calc_CTS(clock, &CTS, N, 32000);
+       WREG32(offset+R600_HDMI_32kHz_CTS, CTS << 12);
+       WREG32(offset+R600_HDMI_32kHz_N, N);
+
+       CTS = r600_hdmi_ACR[i].CTS_44_1kHz;
+       N = r600_hdmi_ACR[i].N_44_1kHz;
+       r600_hdmi_calc_CTS(clock, &CTS, N, 44100);
+       WREG32(offset+R600_HDMI_44_1kHz_CTS, CTS << 12);
+       WREG32(offset+R600_HDMI_44_1kHz_N, N);
+
+       CTS = r600_hdmi_ACR[i].CTS_48kHz;
+       N = r600_hdmi_ACR[i].N_48kHz;
+       r600_hdmi_calc_CTS(clock, &CTS, N, 48000);
+       WREG32(offset+R600_HDMI_48kHz_CTS, CTS << 12);
+       WREG32(offset+R600_HDMI_48kHz_N, N);
+}
+
+/*
+ * calculate the crc for a given info frame
+ */
+static void r600_hdmi_infoframe_checksum(uint8_t packetType,
+                                        uint8_t versionNumber,
+                                        uint8_t length,
+                                        uint8_t *frame)
+{
+    int i;
+    frame[0] = packetType + versionNumber + length;
+    for (i = 1; i <= length; i++)
+       frame[0] += frame[i];
+    frame[0] = 0x100 - frame[0];
+}
+
+/*
+ * build a HDMI Video Info Frame
+ */
+static void r600_hdmi_videoinfoframe(
+       struct drm_encoder *encoder,
+       enum r600_hdmi_color_format color_format,
+       int active_information_present,
+       uint8_t active_format_aspect_ratio,
+       uint8_t scan_information,
+       uint8_t colorimetry,
+       uint8_t ex_colorimetry,
+       uint8_t quantization,
+       int ITC,
+       uint8_t picture_aspect_ratio,
+       uint8_t video_format_identification,
+       uint8_t pixel_repetition,
+       uint8_t non_uniform_picture_scaling,
+       uint8_t bar_info_data_valid,
+       uint16_t top_bar,
+       uint16_t bottom_bar,
+       uint16_t left_bar,
+       uint16_t right_bar
+)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
+
+       uint8_t frame[14];
+
+       frame[0x0] = 0;
+       frame[0x1] =
+               (scan_information & 0x3) |
+               ((bar_info_data_valid & 0x3) << 2) |
+               ((active_information_present & 0x1) << 4) |
+               ((color_format & 0x3) << 5);
+       frame[0x2] =
+               (active_format_aspect_ratio & 0xF) |
+               ((picture_aspect_ratio & 0x3) << 4) |
+               ((colorimetry & 0x3) << 6);
+       frame[0x3] =
+               (non_uniform_picture_scaling & 0x3) |
+               ((quantization & 0x3) << 2) |
+               ((ex_colorimetry & 0x7) << 4) |
+               ((ITC & 0x1) << 7);
+       frame[0x4] = (video_format_identification & 0x7F);
+       frame[0x5] = (pixel_repetition & 0xF);
+       frame[0x6] = (top_bar & 0xFF);
+       frame[0x7] = (top_bar >> 8);
+       frame[0x8] = (bottom_bar & 0xFF);
+       frame[0x9] = (bottom_bar >> 8);
+       frame[0xA] = (left_bar & 0xFF);
+       frame[0xB] = (left_bar >> 8);
+       frame[0xC] = (right_bar & 0xFF);
+       frame[0xD] = (right_bar >> 8);
+
+       r600_hdmi_infoframe_checksum(0x82, 0x02, 0x0D, frame);
+
+       WREG32(offset+R600_HDMI_VIDEOINFOFRAME_0,
+               frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
+       WREG32(offset+R600_HDMI_VIDEOINFOFRAME_1,
+               frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x7] << 24));
+       WREG32(offset+R600_HDMI_VIDEOINFOFRAME_2,
+               frame[0x8] | (frame[0x9] << 8) | (frame[0xA] << 16) | (frame[0xB] << 24));
+       WREG32(offset+R600_HDMI_VIDEOINFOFRAME_3,
+               frame[0xC] | (frame[0xD] << 8));
+}
+
+/*
+ * build a Audio Info Frame
+ */
+static void r600_hdmi_audioinfoframe(
+       struct drm_encoder *encoder,
+       uint8_t channel_count,
+       uint8_t coding_type,
+       uint8_t sample_size,
+       uint8_t sample_frequency,
+       uint8_t format,
+       uint8_t channel_allocation,
+       uint8_t level_shift,
+       int downmix_inhibit
+)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
+
+       uint8_t frame[11];
+
+       frame[0x0] = 0;
+       frame[0x1] = (channel_count & 0x7) | ((coding_type & 0xF) << 4);
+       frame[0x2] = (sample_size & 0x3) | ((sample_frequency & 0x7) << 2);
+       frame[0x3] = format;
+       frame[0x4] = channel_allocation;
+       frame[0x5] = ((level_shift & 0xF) << 3) | ((downmix_inhibit & 0x1) << 7);
+       frame[0x6] = 0;
+       frame[0x7] = 0;
+       frame[0x8] = 0;
+       frame[0x9] = 0;
+       frame[0xA] = 0;
+
+       r600_hdmi_infoframe_checksum(0x84, 0x01, 0x0A, frame);
+
+       WREG32(offset+R600_HDMI_AUDIOINFOFRAME_0,
+               frame[0x0] | (frame[0x1] << 8) | (frame[0x2] << 16) | (frame[0x3] << 24));
+       WREG32(offset+R600_HDMI_AUDIOINFOFRAME_1,
+               frame[0x4] | (frame[0x5] << 8) | (frame[0x6] << 16) | (frame[0x8] << 24));
+}
+
+/*
+ * test if audio buffer is filled enough to start playing
+ */
+static int r600_hdmi_is_audio_buffer_filled(struct drm_encoder *encoder)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
+
+       return (RREG32(offset+R600_HDMI_STATUS) & 0x10) != 0;
+}
+
+/*
+ * have buffer status changed since last call?
+ */
+int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder)
+{
+       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+       int status, result;
+
+       if (!radeon_encoder->hdmi_offset)
+               return 0;
+
+       status = r600_hdmi_is_audio_buffer_filled(encoder);
+       result = radeon_encoder->hdmi_buffer_status != status;
+       radeon_encoder->hdmi_buffer_status = status;
+
+       return result;
+}
+
+/*
+ * write the audio workaround status to the hardware
+ */
+void r600_hdmi_audio_workaround(struct drm_encoder *encoder)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+       uint32_t offset = radeon_encoder->hdmi_offset;
+
+       if (!offset)
+               return;
+
+       if (r600_hdmi_is_audio_buffer_filled(encoder)) {
+               /* disable audio workaround and start delivering of audio frames */
+               WREG32_P(offset+R600_HDMI_CNTL, 0x00000001, ~0x00001001);
+
+       } else if (radeon_encoder->hdmi_audio_workaround) {
+               /* enable audio workaround and start delivering of audio frames */
+               WREG32_P(offset+R600_HDMI_CNTL, 0x00001001, ~0x00001001);
+
+       } else {
+               /* disable audio workaround and stop delivering of audio frames */
+               WREG32_P(offset+R600_HDMI_CNTL, 0x00000000, ~0x00001001);
+       }
+}
+
+
+/*
+ * update the info frames with the data from the current display mode
+ */
+void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
+
+       if (!offset)
+               return;
+
+       r600_audio_set_clock(encoder, mode->clock);
+
+       WREG32(offset+R600_HDMI_UNKNOWN_0, 0x1000);
+       WREG32(offset+R600_HDMI_UNKNOWN_1, 0x0);
+       WREG32(offset+R600_HDMI_UNKNOWN_2, 0x1000);
+
+       r600_hdmi_update_ACR(encoder, mode->clock);
+
+       WREG32(offset+R600_HDMI_VIDEOCNTL, 0x13);
+
+       WREG32(offset+R600_HDMI_VERSION, 0x202);
+
+       r600_hdmi_videoinfoframe(encoder, RGB, 0, 0, 0, 0,
+               0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+       /* it's unknown what these bits do excatly, but it's indeed quite usefull for debugging */
+       WREG32(offset+R600_HDMI_AUDIO_DEBUG_0, 0x00FFFFFF);
+       WREG32(offset+R600_HDMI_AUDIO_DEBUG_1, 0x007FFFFF);
+       WREG32(offset+R600_HDMI_AUDIO_DEBUG_2, 0x00000001);
+       WREG32(offset+R600_HDMI_AUDIO_DEBUG_3, 0x00000001);
+
+       r600_hdmi_audio_workaround(encoder);
+
+       /* audio packets per line, does anyone know how to calc this ? */
+       WREG32_P(offset+R600_HDMI_CNTL, 0x00040000, ~0x001F0000);
+
+       /* update? reset? don't realy know */
+       WREG32_P(offset+R600_HDMI_CNTL, 0x14000000, ~0x14000000);
+}
+
+/*
+ * update settings with current parameters from audio engine
+ */
+void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
+                                    int channels,
+                                    int rate,
+                                    int bps,
+                                    uint8_t status_bits,
+                                    uint8_t category_code)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
+
+       uint32_t iec;
+
+       if (!offset)
+               return;
+
+       DRM_DEBUG("%s with %d channels, %d Hz sampling rate, %d bits per sample,\n",
+                r600_hdmi_is_audio_buffer_filled(encoder) ? "playing" : "stopped",
+               channels, rate, bps);
+       DRM_DEBUG("0x%02X IEC60958 status bits and 0x%02X category code\n",
+                 (int)status_bits, (int)category_code);
+
+       iec = 0;
+       if (status_bits & AUDIO_STATUS_PROFESSIONAL)
+               iec |= 1 << 0;
+       if (status_bits & AUDIO_STATUS_NONAUDIO)
+               iec |= 1 << 1;
+       if (status_bits & AUDIO_STATUS_COPYRIGHT)
+               iec |= 1 << 2;
+       if (status_bits & AUDIO_STATUS_EMPHASIS)
+               iec |= 1 << 3;
+
+       iec |= category_code << 8;
+
+       switch (rate) {
+       case  32000: iec |= 0x3 << 24; break;
+       case  44100: iec |= 0x0 << 24; break;
+       case  88200: iec |= 0x8 << 24; break;
+       case 176400: iec |= 0xc << 24; break;
+       case  48000: iec |= 0x2 << 24; break;
+       case  96000: iec |= 0xa << 24; break;
+       case 192000: iec |= 0xe << 24; break;
+       }
+
+       WREG32(offset+R600_HDMI_IEC60958_1, iec);
+
+       iec = 0;
+       switch (bps) {
+       case 16: iec |= 0x2; break;
+       case 20: iec |= 0x3; break;
+       case 24: iec |= 0xb; break;
+       }
+       if (status_bits & AUDIO_STATUS_V)
+               iec |= 0x5 << 16;
+
+       WREG32_P(offset+R600_HDMI_IEC60958_2, iec, ~0x5000f);
+
+       /* 0x021 or 0x031 sets the audio frame length */
+       WREG32(offset+R600_HDMI_AUDIOCNTL, 0x31);
+       r600_hdmi_audioinfoframe(encoder, channels-1, 0, 0, 0, 0, 0, 0, 0);
+
+       r600_hdmi_audio_workaround(encoder);
+
+       /* update? reset? don't realy know */
+       WREG32_P(offset+R600_HDMI_CNTL, 0x04000000, ~0x04000000);
+}
+
+/*
+ * enable/disable the HDMI engine
+ */
+void r600_hdmi_enable(struct drm_encoder *encoder, int enable)
+{
+       struct drm_device *dev = encoder->dev;
+       struct radeon_device *rdev = dev->dev_private;
+       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+       uint32_t offset = to_radeon_encoder(encoder)->hdmi_offset;
+
+       if (!offset)
+               return;
+
+       DRM_DEBUG("%s HDMI interface @ 0x%04X\n", enable ? "Enabling" : "Disabling", offset);
+
+       /* some version of atombios ignore the enable HDMI flag
+        * so enabling/disabling HDMI was moved here for TMDS1+2 */
+       switch (radeon_encoder->encoder_id) {
+       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
+               WREG32_P(AVIVO_TMDSA_CNTL, enable ? 0x4 : 0x0, ~0x4);
+               WREG32(offset+R600_HDMI_ENABLE, enable ? 0x101 : 0x0);
+               break;
+
+       case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
+               WREG32_P(AVIVO_LVTMA_CNTL, enable ? 0x4 : 0x0, ~0x4);
+               WREG32(offset+R600_HDMI_ENABLE, enable ? 0x105 : 0x0);
+               break;
+
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
+       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
+               /* This part is doubtfull in my opinion */
+               WREG32(offset+R600_HDMI_ENABLE, enable ? 0x110 : 0x0);
+               break;
+
+       default:
+               DRM_ERROR("unknown HDMI output type\n");
+               break;
+       }
+}
+
+/*
+ * determin at which register offset the HDMI encoder is
+ */
+void r600_hdmi_init(struct drm_encoder *encoder)
+{
+       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
+
+       switch (radeon_encoder->encoder_id) {
+       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_TMDS1:
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY:
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY1:
+               radeon_encoder->hdmi_offset = R600_HDMI_TMDS1;
+               break;
+
+       case ENCODER_OBJECT_ID_INTERNAL_LVTM1:
+               switch (r600_audio_tmds_index(encoder)) {
+               case 0:
+                       radeon_encoder->hdmi_offset = R600_HDMI_TMDS1;
+                       break;
+               case 1:
+                       radeon_encoder->hdmi_offset = R600_HDMI_TMDS2;
+                       break;
+               default:
+                       radeon_encoder->hdmi_offset = 0;
+                       break;
+               }
+       case ENCODER_OBJECT_ID_INTERNAL_UNIPHY2:
+               radeon_encoder->hdmi_offset = R600_HDMI_TMDS2;
+               break;
+
+       case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
+               radeon_encoder->hdmi_offset = R600_HDMI_DIG;
+               break;
+
+       default:
+               radeon_encoder->hdmi_offset = 0;
+               break;
+       }
+
+       DRM_DEBUG("using HDMI engine at offset 0x%04X for encoder 0x%x\n",
+                 radeon_encoder->hdmi_offset, radeon_encoder->encoder_id);
+
+       /* TODO: make this configureable */
+       radeon_encoder->hdmi_audio_workaround = 0;
+}
index e2d1f5f33f7e34f946421f5d8837c3c19c65e347..d0e28ffdeda9400564ce40cea7a22e7fca2533f5 100644 (file)
 #define R600_BIOS_6_SCRATCH               0x173c
 #define R600_BIOS_7_SCRATCH               0x1740
 
+/* Audio, these regs were reverse enginered,
+ * so the chance is high that the naming is wrong
+ * R6xx+ ??? */
+
+/* Audio clocks */
+#define R600_AUDIO_PLL1_MUL               0x0514
+#define R600_AUDIO_PLL1_DIV               0x0518
+#define R600_AUDIO_PLL2_MUL               0x0524
+#define R600_AUDIO_PLL2_DIV               0x0528
+#define R600_AUDIO_CLK_SRCSEL             0x0534
+
+/* Audio general */
+#define R600_AUDIO_ENABLE                 0x7300
+#define R600_AUDIO_TIMING                 0x7344
+
+/* Audio params */
+#define R600_AUDIO_VENDOR_ID              0x7380
+#define R600_AUDIO_REVISION_ID            0x7384
+#define R600_AUDIO_ROOT_NODE_COUNT        0x7388
+#define R600_AUDIO_NID1_NODE_COUNT        0x738c
+#define R600_AUDIO_NID1_TYPE              0x7390
+#define R600_AUDIO_SUPPORTED_SIZE_RATE    0x7394
+#define R600_AUDIO_SUPPORTED_CODEC        0x7398
+#define R600_AUDIO_SUPPORTED_POWER_STATES 0x739c
+#define R600_AUDIO_NID2_CAPS              0x73a0
+#define R600_AUDIO_NID3_CAPS              0x73a4
+#define R600_AUDIO_NID3_PIN_CAPS          0x73a8
+
+/* Audio conn list */
+#define R600_AUDIO_CONN_LIST_LEN          0x73ac
+#define R600_AUDIO_CONN_LIST              0x73b0
+
+/* Audio verbs */
+#define R600_AUDIO_RATE_BPS_CHANNEL       0x73c0
+#define R600_AUDIO_PLAYING                0x73c4
+#define R600_AUDIO_IMPLEMENTATION_ID      0x73c8
+#define R600_AUDIO_CONFIG_DEFAULT         0x73cc
+#define R600_AUDIO_PIN_SENSE              0x73d0
+#define R600_AUDIO_PIN_WIDGET_CNTL        0x73d4
+#define R600_AUDIO_STATUS_BITS            0x73d8
+
+/* HDMI base register addresses */
+#define R600_HDMI_TMDS1                   0x7400
+#define R600_HDMI_TMDS2                   0x7700
+#define R600_HDMI_DIG                     0x7800
+
+/* HDMI registers */
+#define R600_HDMI_ENABLE           0x00
+#define R600_HDMI_STATUS           0x04
+#define R600_HDMI_CNTL             0x08
+#define R600_HDMI_UNKNOWN_0        0x0C
+#define R600_HDMI_AUDIOCNTL        0x10
+#define R600_HDMI_VIDEOCNTL        0x14
+#define R600_HDMI_VERSION          0x18
+#define R600_HDMI_UNKNOWN_1        0x28
+#define R600_HDMI_VIDEOINFOFRAME_0 0x54
+#define R600_HDMI_VIDEOINFOFRAME_1 0x58
+#define R600_HDMI_VIDEOINFOFRAME_2 0x5c
+#define R600_HDMI_VIDEOINFOFRAME_3 0x60
+#define R600_HDMI_32kHz_CTS        0xac
+#define R600_HDMI_32kHz_N          0xb0
+#define R600_HDMI_44_1kHz_CTS      0xb4
+#define R600_HDMI_44_1kHz_N        0xb8
+#define R600_HDMI_48kHz_CTS        0xbc
+#define R600_HDMI_48kHz_N          0xc0
+#define R600_HDMI_AUDIOINFOFRAME_0 0xcc
+#define R600_HDMI_AUDIOINFOFRAME_1 0xd0
+#define R600_HDMI_IEC60958_1       0xd4
+#define R600_HDMI_IEC60958_2       0xd8
+#define R600_HDMI_UNKNOWN_2        0xdc
+#define R600_HDMI_AUDIO_DEBUG_0    0xe0
+#define R600_HDMI_AUDIO_DEBUG_1    0xe4
+#define R600_HDMI_AUDIO_DEBUG_2    0xe8
+#define R600_HDMI_AUDIO_DEBUG_3    0xec
 
 #endif
index c938bb54123cd0a15e531ee661bd35361ad780e0..53b55608102b0df5a97fd099fca0d8063d5e13b7 100644 (file)
@@ -89,6 +89,7 @@ extern int radeon_testing;
 extern int radeon_connector_table;
 extern int radeon_tv;
 extern int radeon_new_pll;
+extern int radeon_audio;
 
 /*
  * Copy from radeon_drv.h so we don't have to include both and have conflicting
@@ -161,6 +162,7 @@ struct radeon_fence_driver {
        struct list_head                created;
        struct list_head                emited;
        struct list_head                signaled;
+       bool                            initialized;
 };
 
 struct radeon_fence {
@@ -201,8 +203,9 @@ struct radeon_surface_reg {
 struct radeon_mman {
        struct ttm_bo_global_ref        bo_global_ref;
        struct ttm_global_reference     mem_global_ref;
-       bool                            mem_global_referenced;
        struct ttm_bo_device            bdev;
+       bool                            mem_global_referenced;
+       bool                            initialized;
 };
 
 struct radeon_bo {
@@ -814,6 +817,14 @@ struct radeon_device {
        struct r600_ih ih; /* r6/700 interrupt ring */
        struct workqueue_struct *wq;
        struct work_struct hotplug_work;
+
+       /* audio stuff */
+       struct timer_list       audio_timer;
+       int                     audio_channels;
+       int                     audio_rate;
+       int                     audio_bits_per_sample;
+       uint8_t                 audio_status_bits;
+       uint8_t                 audio_category_code;
 };
 
 int radeon_device_init(struct radeon_device *rdev,
@@ -1016,6 +1027,7 @@ extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
 extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
 extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
 extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain);
+extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
 
 /* r100,rv100,rs100,rv200,rs200,r200,rv250,rs300,rv280 */
 struct r100_mc_save {
@@ -1146,6 +1158,21 @@ extern void r600_irq_fini(struct radeon_device *rdev);
 extern void r600_ih_ring_init(struct radeon_device *rdev, unsigned ring_size);
 extern int r600_irq_set(struct radeon_device *rdev);
 
+extern int r600_audio_init(struct radeon_device *rdev);
+extern int r600_audio_tmds_index(struct drm_encoder *encoder);
+extern void r600_audio_set_clock(struct drm_encoder *encoder, int clock);
+extern void r600_audio_fini(struct radeon_device *rdev);
+extern void r600_hdmi_init(struct drm_encoder *encoder);
+extern void r600_hdmi_enable(struct drm_encoder *encoder, int enable);
+extern void r600_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode *mode);
+extern int r600_hdmi_buffer_status_changed(struct drm_encoder *encoder);
+extern void r600_hdmi_update_audio_settings(struct drm_encoder *encoder,
+                                           int channels,
+                                           int rate,
+                                           int bps,
+                                           uint8_t status_bits,
+                                           uint8_t category_code);
+
 #include "radeon_object.h"
 
 #endif
index 636116bedcb49e554878c2cc8a51d496ae6b8764..eb29217bbf1d51d90f7060c1610e0342b65bb2d9 100644 (file)
@@ -33,6 +33,7 @@
  */
 uint32_t radeon_legacy_get_engine_clock(struct radeon_device *rdev);
 void radeon_legacy_set_engine_clock(struct radeon_device *rdev, uint32_t eng_clock);
+uint32_t radeon_legacy_get_memory_clock(struct radeon_device *rdev);
 void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int enable);
 
 uint32_t radeon_atom_get_engine_clock(struct radeon_device *rdev);
@@ -106,7 +107,7 @@ static struct radeon_asic r100_asic = {
        .copy = &r100_copy_blit,
        .get_engine_clock = &radeon_legacy_get_engine_clock,
        .set_engine_clock = &radeon_legacy_set_engine_clock,
-       .get_memory_clock = NULL,
+       .get_memory_clock = &radeon_legacy_get_memory_clock,
        .set_memory_clock = NULL,
        .set_pcie_lanes = NULL,
        .set_clock_gating = &radeon_legacy_set_clock_gating,
@@ -166,7 +167,7 @@ static struct radeon_asic r300_asic = {
        .copy = &r100_copy_blit,
        .get_engine_clock = &radeon_legacy_get_engine_clock,
        .set_engine_clock = &radeon_legacy_set_engine_clock,
-       .get_memory_clock = NULL,
+       .get_memory_clock = &radeon_legacy_get_memory_clock,
        .set_memory_clock = NULL,
        .set_pcie_lanes = &rv370_set_pcie_lanes,
        .set_clock_gating = &radeon_legacy_set_clock_gating,
@@ -259,7 +260,7 @@ static struct radeon_asic rs400_asic = {
        .copy = &r100_copy_blit,
        .get_engine_clock = &radeon_legacy_get_engine_clock,
        .set_engine_clock = &radeon_legacy_set_engine_clock,
-       .get_memory_clock = NULL,
+       .get_memory_clock = &radeon_legacy_get_memory_clock,
        .set_memory_clock = NULL,
        .set_pcie_lanes = NULL,
        .set_clock_gating = &radeon_legacy_set_clock_gating,
index 12a0c760e7ff1c09dd4dc07135e804a37f52d0ea..321044bef71c86e9888ee5d0e2f99451009fb818 100644 (file)
@@ -745,8 +745,7 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
                else
                        radeon_add_legacy_encoder(dev,
                                                  radeon_get_encoder_id(dev,
-                                                                       (1 <<
-                                                                        i),
+                                                                       (1 << i),
                                                                        dac),
                                                  (1 << i));
        }
@@ -758,32 +757,30 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
                                if (bios_connectors[j].valid && (i != j)) {
                                        if (bios_connectors[i].line_mux ==
                                            bios_connectors[j].line_mux) {
-                                               if (((bios_connectors[i].
-                                                     devices &
-                                                     (ATOM_DEVICE_DFP_SUPPORT))
-                                                    && (bios_connectors[j].
-                                                        devices &
-                                                        (ATOM_DEVICE_CRT_SUPPORT)))
-                                                   ||
-                                                   ((bios_connectors[j].
-                                                     devices &
-                                                     (ATOM_DEVICE_DFP_SUPPORT))
-                                                    && (bios_connectors[i].
-                                                        devices &
-                                                        (ATOM_DEVICE_CRT_SUPPORT)))) {
-                                                       bios_connectors[i].
-                                                           devices |=
-                                                           bios_connectors[j].
-                                                           devices;
-                                                       bios_connectors[i].
-                                                           connector_type =
-                                                           DRM_MODE_CONNECTOR_DVII;
-                                                       if (bios_connectors[j].devices &
-                                                           (ATOM_DEVICE_DFP_SUPPORT))
+                                               /* make sure not to combine LVDS */
+                                               if (bios_connectors[i].devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+                                                       bios_connectors[i].line_mux = 53;
+                                                       bios_connectors[i].ddc_bus.valid = false;
+                                                       continue;
+                                               }
+                                               if (bios_connectors[j].devices & (ATOM_DEVICE_LCD_SUPPORT)) {
+                                                       bios_connectors[j].line_mux = 53;
+                                                       bios_connectors[j].ddc_bus.valid = false;
+                                                       continue;
+                                               }
+                                               /* combine analog and digital for DVI-I */
+                                               if (((bios_connectors[i].devices & (ATOM_DEVICE_DFP_SUPPORT)) &&
+                                                    (bios_connectors[j].devices & (ATOM_DEVICE_CRT_SUPPORT))) ||
+                                                   ((bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT)) &&
+                                                    (bios_connectors[i].devices & (ATOM_DEVICE_CRT_SUPPORT)))) {
+                                                       bios_connectors[i].devices |=
+                                                               bios_connectors[j].devices;
+                                                       bios_connectors[i].connector_type =
+                                                               DRM_MODE_CONNECTOR_DVII;
+                                                       if (bios_connectors[j].devices & (ATOM_DEVICE_DFP_SUPPORT))
                                                                bios_connectors[i].hpd =
                                                                        bios_connectors[j].hpd;
-                                                       bios_connectors[j].
-                                                           valid = false;
+                                                       bios_connectors[j].valid = false;
                                                }
                                        }
                                }
@@ -1234,6 +1231,61 @@ bool radeon_atom_get_tv_timings(struct radeon_device *rdev, int index,
        return true;
 }
 
+enum radeon_tv_std
+radeon_atombios_get_tv_info(struct radeon_device *rdev)
+{
+       struct radeon_mode_info *mode_info = &rdev->mode_info;
+       int index = GetIndexIntoMasterTable(DATA, AnalogTV_Info);
+       uint16_t data_offset;
+       uint8_t frev, crev;
+       struct _ATOM_ANALOG_TV_INFO *tv_info;
+       enum radeon_tv_std tv_std = TV_STD_NTSC;
+
+       atom_parse_data_header(mode_info->atom_context, index, NULL, &frev, &crev, &data_offset);
+
+       tv_info = (struct _ATOM_ANALOG_TV_INFO *)(mode_info->atom_context->bios + data_offset);
+
+       switch (tv_info->ucTV_BootUpDefaultStandard) {
+       case ATOM_TV_NTSC:
+               tv_std = TV_STD_NTSC;
+               DRM_INFO("Default TV standard: NTSC\n");
+               break;
+       case ATOM_TV_NTSCJ:
+               tv_std = TV_STD_NTSC_J;
+               DRM_INFO("Default TV standard: NTSC-J\n");
+               break;
+       case ATOM_TV_PAL:
+               tv_std = TV_STD_PAL;
+               DRM_INFO("Default TV standard: PAL\n");
+               break;
+       case ATOM_TV_PALM:
+               tv_std = TV_STD_PAL_M;
+               DRM_INFO("Default TV standard: PAL-M\n");
+               break;
+       case ATOM_TV_PALN:
+               tv_std = TV_STD_PAL_N;
+               DRM_INFO("Default TV standard: PAL-N\n");
+               break;
+       case ATOM_TV_PALCN:
+               tv_std = TV_STD_PAL_CN;
+               DRM_INFO("Default TV standard: PAL-CN\n");
+               break;
+       case ATOM_TV_PAL60:
+               tv_std = TV_STD_PAL_60;
+               DRM_INFO("Default TV standard: PAL-60\n");
+               break;
+       case ATOM_TV_SECAM:
+               tv_std = TV_STD_SECAM;
+               DRM_INFO("Default TV standard: SECAM\n");
+               break;
+       default:
+               tv_std = TV_STD_NTSC;
+               DRM_INFO("Unknown TV standard; defaulting to NTSC\n");
+               break;
+       }
+       return tv_std;
+}
+
 struct radeon_encoder_tv_dac *
 radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder)
 {
@@ -1269,6 +1321,7 @@ radeon_atombios_get_tv_dac_info(struct radeon_encoder *encoder)
                dac = dac_info->ucDAC2_NTSC_DAC_Adjustment;
                tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
 
+               tv_dac->tv_std = radeon_atombios_get_tv_info(rdev);
        }
        return tv_dac;
 }
index b062109efbeea60b99b4a5b8a368df6b58d59691..812f24dbc2a8c58a0cfe566cc0fe81baaab382d8 100644 (file)
@@ -62,7 +62,7 @@ uint32_t radeon_legacy_get_engine_clock(struct radeon_device *rdev)
 }
 
 /* 10 khz */
-static uint32_t radeon_legacy_get_memory_clock(struct radeon_device *rdev)
+uint32_t radeon_legacy_get_memory_clock(struct radeon_device *rdev)
 {
        struct radeon_pll *mpll = &rdev->clock.mpll;
        uint32_t fb_div, ref_div, post_div, mclk;
index c5021a3445de0dbafb59cff662a39d19f1a256f7..fd94dbca33ac99724dd1c34cab8c0590e5943586 100644 (file)
@@ -634,11 +634,10 @@ struct radeon_encoder_primary_dac *radeon_combios_get_primary_dac_info(struct
        return p_dac;
 }
 
-static enum radeon_tv_std
-radeon_combios_get_tv_info(struct radeon_encoder *encoder)
+enum radeon_tv_std
+radeon_combios_get_tv_info(struct radeon_device *rdev)
 {
-       struct drm_device *dev = encoder->base.dev;
-       struct radeon_device *rdev = dev->dev_private;
+       struct drm_device *dev = rdev->ddev;
        uint16_t tv_info;
        enum radeon_tv_std tv_std = TV_STD_NTSC;
 
@@ -779,7 +778,7 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
                        tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
                        found = 1;
                }
-               tv_dac->tv_std = radeon_combios_get_tv_info(encoder);
+               tv_dac->tv_std = radeon_combios_get_tv_info(rdev);
        }
        if (!found) {
                /* then check CRT table */
index 5eece186e03c5ae388bed2b6c5421365c9004538..20161567dbff63ddba53379903c0c5a91d6ceb4e 100644 (file)
@@ -208,6 +208,18 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode
                drm_mode_set_name(mode);
 
                DRM_DEBUG("Adding native panel mode %s\n", mode->name);
+       } else if (native_mode->hdisplay != 0 &&
+                  native_mode->vdisplay != 0) {
+               /* mac laptops without an edid */
+               /* Note that this is not necessarily the exact panel mode,
+                * but an approximation based on the cvt formula.  For these
+                * systems we should ideally read the mode info out of the
+                * registers or add a mode table, but this works and is much
+                * simpler.
+                */
+               mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false);
+               mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
+               DRM_DEBUG("Adding cvt approximation of native panel mode %s\n", mode->name);
        }
        return mode;
 }
@@ -1171,7 +1183,7 @@ radeon_add_atom_connector(struct drm_device *dev,
                                                      1);
                        drm_connector_attach_property(&radeon_connector->base,
                                                      rdev->mode_info.tv_std_property,
-                                                     1);
+                                                     radeon_atombios_get_tv_info(rdev));
                }
                break;
        case DRM_MODE_CONNECTOR_LVDS:
@@ -1315,7 +1327,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
                                                      1);
                        drm_connector_attach_property(&radeon_connector->base,
                                                      rdev->mode_info.tv_std_property,
-                                                     1);
+                                                     radeon_combios_get_tv_info(rdev));
                }
                break;
        case DRM_MODE_CONNECTOR_LVDS:
index 02bcdb1240c0ffe73253ddf37a02dfa4546f1944..7c6848096bcdf2d345d2fd32e9cf838a9212c261 100644 (file)
@@ -391,6 +391,12 @@ int radeon_asic_init(struct radeon_device *rdev)
                /* FIXME: not supported yet */
                return -EINVAL;
        }
+
+       if (rdev->flags & RADEON_IS_IGP) {
+               rdev->asic->get_memory_clock = NULL;
+               rdev->asic->set_memory_clock = NULL;
+       }
+
        return 0;
 }
 
@@ -481,6 +487,7 @@ int radeon_atombios_init(struct radeon_device *rdev)
        atom_card_info->pll_write = cail_pll_write;
 
        rdev->mode_info.atom_context = atom_parse(atom_card_info, rdev->bios);
+       mutex_init(&rdev->mode_info.atom_context->mutex);
        radeon_atom_initialize_bios_scratch_regs(rdev->ddev);
        atom_allocate_fb_scratch(rdev->mode_info.atom_context);
        return 0;
@@ -539,9 +546,72 @@ void radeon_agp_disable(struct radeon_device *rdev)
        }
 }
 
-/*
- * Radeon device.
- */
+void radeon_check_arguments(struct radeon_device *rdev)
+{
+       /* vramlimit must be a power of two */
+       switch (radeon_vram_limit) {
+       case 0:
+       case 4:
+       case 8:
+       case 16:
+       case 32:
+       case 64:
+       case 128:
+       case 256:
+       case 512:
+       case 1024:
+       case 2048:
+       case 4096:
+               break;
+       default:
+               dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n",
+                               radeon_vram_limit);
+               radeon_vram_limit = 0;
+               break;
+       }
+       radeon_vram_limit = radeon_vram_limit << 20;
+       /* gtt size must be power of two and greater or equal to 32M */
+       switch (radeon_gart_size) {
+       case 4:
+       case 8:
+       case 16:
+               dev_warn(rdev->dev, "gart size (%d) too small forcing to 512M\n",
+                               radeon_gart_size);
+               radeon_gart_size = 512;
+               break;
+       case 32:
+       case 64:
+       case 128:
+       case 256:
+       case 512:
+       case 1024:
+       case 2048:
+       case 4096:
+               break;
+       default:
+               dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n",
+                               radeon_gart_size);
+               radeon_gart_size = 512;
+               break;
+       }
+       rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
+       /* AGP mode can only be -1, 1, 2, 4, 8 */
+       switch (radeon_agpmode) {
+       case -1:
+       case 0:
+       case 1:
+       case 2:
+       case 4:
+       case 8:
+               break;
+       default:
+               dev_warn(rdev->dev, "invalid AGP mode %d (valid mode: "
+                               "-1, 0, 1, 2, 4, 8)\n", radeon_agpmode);
+               radeon_agpmode = 0;
+               break;
+       }
+}
+
 int radeon_device_init(struct radeon_device *rdev,
                       struct drm_device *ddev,
                       struct pci_dev *pdev,
@@ -580,9 +650,9 @@ int radeon_device_init(struct radeon_device *rdev,
 
        /* Set asic functions */
        r = radeon_asic_init(rdev);
-       if (r) {
+       if (r)
                return r;
-       }
+       radeon_check_arguments(rdev);
 
        if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) {
                radeon_agp_disable(rdev);
index a133b833e45d46de500a0de9d9ccb89cbc0df8ab..91d72b70abc9956bacca10b0dffe41fa42868ccb 100644 (file)
@@ -739,7 +739,7 @@ static struct drm_prop_enum_list radeon_tv_std_enum_list[] =
        { TV_STD_SECAM, "secam" },
 };
 
-int radeon_modeset_create_props(struct radeon_device *rdev)
+static int radeon_modeset_create_props(struct radeon_device *rdev)
 {
        int i, sz;
 
index c5c45e626d7430d90b1ea06623fde8be2608f33c..8ba3de7994d4f2719313f0baf7f62d0daebdfe23 100644 (file)
@@ -87,6 +87,7 @@ int radeon_testing = 0;
 int radeon_connector_table = 0;
 int radeon_tv = 1;
 int radeon_new_pll = 1;
+int radeon_audio = 1;
 
 MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
 module_param_named(no_wb, radeon_no_wb, int, 0444);
@@ -124,6 +125,9 @@ module_param_named(tv, radeon_tv, int, 0444);
 MODULE_PARM_DESC(new_pll, "Select new PLL code for AVIVO chips");
 module_param_named(new_pll, radeon_new_pll, int, 0444);
 
+MODULE_PARM_DESC(audio, "Audio enable (0 = disable)");
+module_param_named(audio, radeon_audio, int, 0444);
+
 static int radeon_suspend(struct drm_device *dev, pm_message_t state)
 {
        drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -192,7 +196,7 @@ static struct drm_driver driver_old = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
-                .ioctl = drm_ioctl,
+                .unlocked_ioctl = drm_ioctl,
                 .mmap = drm_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
@@ -280,7 +284,7 @@ static struct drm_driver kms_driver = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
-                .ioctl = drm_ioctl,
+                .unlocked_ioctl = drm_ioctl,
                 .mmap = radeon_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
index b4f23ec932014367bac60edbac898e0d7f1ae760..ccba95f83d11c7dd911dd6a268c5e6104d54a570 100644 (file)
@@ -233,6 +233,8 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
                if (!ASIC_IS_AVIVO(rdev)) {
                        adjusted_mode->hdisplay = mode->hdisplay;
                        adjusted_mode->vdisplay = mode->vdisplay;
+                       adjusted_mode->crtc_hdisplay = mode->hdisplay;
+                       adjusted_mode->crtc_vdisplay = mode->vdisplay;
                }
                adjusted_mode->base.id = mode_id;
        }
@@ -438,6 +440,7 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
        union lvds_encoder_control args;
        int index = 0;
+       int hdmi_detected = 0;
        uint8_t frev, crev;
        struct radeon_encoder_atom_dig *dig;
        struct drm_connector *connector;
@@ -458,6 +461,9 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
        if (!radeon_connector->con_priv)
                return;
 
+       if (drm_detect_hdmi_monitor(radeon_connector->edid))
+               hdmi_detected = 1;
+
        dig_connector = radeon_connector->con_priv;
 
        memset(&args, 0, sizeof(args));
@@ -487,13 +493,13 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
                case 1:
                        args.v1.ucMisc = 0;
                        args.v1.ucAction = action;
-                       if (drm_detect_hdmi_monitor(radeon_connector->edid))
+                       if (hdmi_detected)
                                args.v1.ucMisc |= PANEL_ENCODER_MISC_HDMI_TYPE;
                        args.v1.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
                        if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
-                               if (dig->lvds_misc & (1 << 0))
+                               if (dig->lvds_misc & ATOM_PANEL_MISC_DUAL)
                                        args.v1.ucMisc |= PANEL_ENCODER_MISC_DUAL;
-                               if (dig->lvds_misc & (1 << 1))
+                               if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB)
                                        args.v1.ucMisc |= (1 << 1);
                        } else {
                                if (dig_connector->linkb)
@@ -512,7 +518,7 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
                                if (dig->coherent_mode)
                                        args.v2.ucMisc |= PANEL_ENCODER_MISC_COHERENT;
                        }
-                       if (drm_detect_hdmi_monitor(radeon_connector->edid))
+                       if (hdmi_detected)
                                args.v2.ucMisc |= PANEL_ENCODER_MISC_HDMI_TYPE;
                        args.v2.usPixelClock = cpu_to_le16(radeon_encoder->pixel_clock / 10);
                        args.v2.ucTruncate = 0;
@@ -520,18 +526,18 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
                        args.v2.ucTemporal = 0;
                        args.v2.ucFRC = 0;
                        if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
-                               if (dig->lvds_misc & (1 << 0))
+                               if (dig->lvds_misc & ATOM_PANEL_MISC_DUAL)
                                        args.v2.ucMisc |= PANEL_ENCODER_MISC_DUAL;
-                               if (dig->lvds_misc & (1 << 5)) {
+                               if (dig->lvds_misc & ATOM_PANEL_MISC_SPATIAL) {
                                        args.v2.ucSpatial = PANEL_ENCODER_SPATIAL_DITHER_EN;
-                                       if (dig->lvds_misc & (1 << 1))
+                                       if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB)
                                                args.v2.ucSpatial |= PANEL_ENCODER_SPATIAL_DITHER_DEPTH;
                                }
-                               if (dig->lvds_misc & (1 << 6)) {
+                               if (dig->lvds_misc & ATOM_PANEL_MISC_TEMPORAL) {
                                        args.v2.ucTemporal = PANEL_ENCODER_TEMPORAL_DITHER_EN;
-                                       if (dig->lvds_misc & (1 << 1))
+                                       if (dig->lvds_misc & ATOM_PANEL_MISC_888RGB)
                                                args.v2.ucTemporal |= PANEL_ENCODER_TEMPORAL_DITHER_DEPTH;
-                                       if (((dig->lvds_misc >> 2) & 0x3) == 2)
+                                       if (((dig->lvds_misc >> ATOM_PANEL_MISC_GREY_LEVEL_SHIFT) & 0x3) == 2)
                                                args.v2.ucTemporal |= PANEL_ENCODER_TEMPORAL_LEVEL_4;
                                }
                        } else {
@@ -552,7 +558,7 @@ atombios_digital_setup(struct drm_encoder *encoder, int action)
        }
 
        atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
-
+       r600_hdmi_enable(encoder, hdmi_detected);
 }
 
 int
@@ -893,7 +899,6 @@ atombios_dig_transmitter_setup(struct drm_encoder *encoder, int action, uint8_t
        }
 
        atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
-
 }
 
 static void
@@ -1162,7 +1167,6 @@ atombios_set_encoder_crtc_source(struct drm_encoder *encoder)
        }
 
        atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
-
 }
 
 static void
@@ -1265,6 +1269,8 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
                break;
        }
        atombios_apply_encoder_quirks(encoder, adjusted_mode);
+
+       r600_hdmi_setmode(encoder, adjusted_mode);
 }
 
 static bool
@@ -1510,4 +1516,6 @@ radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_id, uint32_t su
                drm_encoder_helper_add(encoder, &radeon_atom_dig_helper_funcs);
                break;
        }
+
+       r600_hdmi_init(encoder);
 }
index cb4cd97ae39fa811d9bf68912f709b47270fe0d1..4cdd8b4f75492103f330ae021054af4a74182853 100644 (file)
@@ -324,7 +324,7 @@ int radeon_fence_driver_init(struct radeon_device *rdev)
        write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
        r = radeon_scratch_get(rdev, &rdev->fence_drv.scratch_reg);
        if (r) {
-               DRM_ERROR("Fence failed to get a scratch register.");
+               dev_err(rdev->dev, "fence failed to get scratch register\n");
                write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
                return r;
        }
@@ -335,9 +335,10 @@ int radeon_fence_driver_init(struct radeon_device *rdev)
        INIT_LIST_HEAD(&rdev->fence_drv.signaled);
        rdev->fence_drv.count_timeout = 0;
        init_waitqueue_head(&rdev->fence_drv.queue);
+       rdev->fence_drv.initialized = true;
        write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
        if (radeon_debugfs_fence_init(rdev)) {
-               DRM_ERROR("Failed to register debugfs file for fence !\n");
+               dev_err(rdev->dev, "fence debugfs file creation failed\n");
        }
        return 0;
 }
@@ -346,11 +347,13 @@ void radeon_fence_driver_fini(struct radeon_device *rdev)
 {
        unsigned long irq_flags;
 
+       if (!rdev->fence_drv.initialized)
+               return;
        wake_up_all(&rdev->fence_drv.queue);
        write_lock_irqsave(&rdev->fence_drv.lock, irq_flags);
        radeon_scratch_free(rdev, rdev->fence_drv.scratch_reg);
        write_unlock_irqrestore(&rdev->fence_drv.lock, irq_flags);
-       DRM_INFO("radeon: fence finalized\n");
+       rdev->fence_drv.initialized = false;
 }
 
 
index 2944486871b04c0968a88da9e298d487c5ca9f7e..60df2d7e7e4c9dd2572bee249978286ac109a549 100644 (file)
@@ -66,8 +66,9 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size,
        }
        r = radeon_bo_create(rdev, gobj, size, kernel, initial_domain, &robj);
        if (r) {
-               DRM_ERROR("Failed to allocate GEM object (%d, %d, %u)\n",
-                         size, initial_domain, alignment);
+               if (r != -ERESTARTSYS)
+                       DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n",
+                                 size, initial_domain, alignment, r);
                mutex_lock(&rdev->ddev->struct_mutex);
                drm_gem_object_unreference(gobj);
                mutex_unlock(&rdev->ddev->struct_mutex);
@@ -350,9 +351,10 @@ int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,
        rbo = gobj->driver_private;
        r = radeon_bo_reserve(rbo, false);
        if (unlikely(r != 0))
-               return r;
+               goto out;
        radeon_bo_get_tiling_flags(rbo, &args->tiling_flags, &args->pitch);
        radeon_bo_unreserve(rbo);
+out:
        mutex_lock(&dev->struct_mutex);
        drm_gem_object_unreference(gobj);
        mutex_unlock(&dev->struct_mutex);
index a1bf11de308a1086a45c9a03c21faec839ce76e5..48b7cea31e08d73eef3a4da16156b05d528ebd0c 100644 (file)
@@ -92,8 +92,7 @@ static int compat_radeon_cp_init(struct file *file, unsigned int cmd,
                          &init->gart_textures_offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_CP_INIT, (unsigned long)init);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_CP_INIT, (unsigned long)init);
 }
 
 typedef struct drm_radeon_clear32 {
@@ -125,8 +124,7 @@ static int compat_radeon_cp_clear(struct file *file, unsigned int cmd,
                          &clr->depth_boxes))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_CLEAR, (unsigned long)clr);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_CLEAR, (unsigned long)clr);
 }
 
 typedef struct drm_radeon_stipple32 {
@@ -149,8 +147,7 @@ static int compat_radeon_cp_stipple(struct file *file, unsigned int cmd,
                          &request->mask))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_STIPPLE, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_STIPPLE, (unsigned long)request);
 }
 
 typedef struct drm_radeon_tex_image32 {
@@ -204,8 +201,7 @@ static int compat_radeon_cp_texture(struct file *file, unsigned int cmd,
                          &image->data))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_TEXTURE, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_TEXTURE, (unsigned long)request);
 }
 
 typedef struct drm_radeon_vertex2_32 {
@@ -238,8 +234,7 @@ static int compat_radeon_cp_vertex2(struct file *file, unsigned int cmd,
                          &request->prim))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_VERTEX2, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_VERTEX2, (unsigned long)request);
 }
 
 typedef struct drm_radeon_cmd_buffer32 {
@@ -268,8 +263,7 @@ static int compat_radeon_cp_cmdbuf(struct file *file, unsigned int cmd,
                          &request->boxes))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_CMDBUF, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_CMDBUF, (unsigned long)request);
 }
 
 typedef struct drm_radeon_getparam32 {
@@ -293,8 +287,7 @@ static int compat_radeon_cp_getparam(struct file *file, unsigned int cmd,
                          &request->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_GETPARAM, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_GETPARAM, (unsigned long)request);
 }
 
 typedef struct drm_radeon_mem_alloc32 {
@@ -322,8 +315,7 @@ static int compat_radeon_mem_alloc(struct file *file, unsigned int cmd,
                          &request->region_offset))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_ALLOC, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_ALLOC, (unsigned long)request);
 }
 
 typedef struct drm_radeon_irq_emit32 {
@@ -345,8 +337,7 @@ static int compat_radeon_irq_emit(struct file *file, unsigned int cmd,
                          &request->irq_seq))
                return -EFAULT;
 
-       return drm_ioctl(file->f_path.dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_IRQ_EMIT, (unsigned long)request);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_IRQ_EMIT, (unsigned long)request);
 }
 
 /* The two 64-bit arches where alignof(u64)==4 in 32-bit code */
@@ -372,8 +363,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
                          &request->value))
                return -EFAULT;
 
-       return drm_ioctl(file->f_dentry->d_inode, file,
-                        DRM_IOCTL_RADEON_SETPARAM, (unsigned long) request);
+       return drm_ioctl(file, DRM_IOCTL_RADEON_SETPARAM, (unsigned long) request);
 }
 #else
 #define compat_radeon_cp_setparam NULL
@@ -413,12 +403,10 @@ long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
                fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
 
-       lock_kernel();          /* XXX for now */
        if (fn != NULL)
                ret = (*fn) (filp, cmd, arg);
        else
-               ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
-       unlock_kernel();
+               ret = drm_ioctl(filp, cmd, arg);
 
        return ret;
 }
@@ -431,9 +419,7 @@ long radeon_kms_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long
        if (nr < DRM_COMMAND_BASE)
                return drm_compat_ioctl(filp, cmd, arg);
 
-       lock_kernel();          /* XXX for now */
-       ret = drm_ioctl(filp->f_path.dentry->d_inode, filp, cmd, arg);
-       unlock_kernel();
+       ret = drm_ioctl(filp, cmd, arg);
 
        return ret;
 }
index b82ede98e152d114b6f5fe8b015e28785b9d3092..cc27485a07ad9b681269d6ed3fe2889161338bab 100644 (file)
@@ -43,8 +43,7 @@ static void radeon_overscan_setup(struct drm_crtc *crtc,
 }
 
 static void radeon_legacy_rmx_mode_set(struct drm_crtc *crtc,
-                                      struct drm_display_mode *mode,
-                                      struct drm_display_mode *adjusted_mode)
+                                      struct drm_display_mode *mode)
 {
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
@@ -1059,7 +1058,7 @@ static int radeon_crtc_mode_set(struct drm_crtc *crtc,
        radeon_set_pll(crtc, adjusted_mode);
        radeon_overscan_setup(crtc, adjusted_mode);
        if (radeon_crtc->crtc_id == 0) {
-               radeon_legacy_rmx_mode_set(crtc, mode, adjusted_mode);
+               radeon_legacy_rmx_mode_set(crtc, adjusted_mode);
        } else {
                if (radeon_crtc->rmx_type != RMX_OFF) {
                        /* FIXME: only first crtc has rmx what should we
index df00515e81fa20870d73e9d797b5b19e681758b5..981508ff70378bb5a9dcea372f97ebdedc22d0a9 100644 (file)
@@ -207,6 +207,8 @@ static bool radeon_legacy_mode_fixup(struct drm_encoder *encoder,
                *adjusted_mode = *native_mode;
                adjusted_mode->hdisplay = mode->hdisplay;
                adjusted_mode->vdisplay = mode->vdisplay;
+               adjusted_mode->crtc_hdisplay = mode->hdisplay;
+               adjusted_mode->crtc_vdisplay = mode->vdisplay;
                adjusted_mode->base.id = mode_id;
        }
 
index 44d4b652ea12ceebffa40e206e0f4c2a10f7f4fa..402369db5ba0daa78116d59476bbee160f401ff6 100644 (file)
@@ -88,6 +88,7 @@ enum radeon_tv_std {
        TV_STD_SCART_PAL,
        TV_STD_SECAM,
        TV_STD_PAL_CN,
+       TV_STD_PAL_N,
 };
 
 /* radeon gpio-based i2c
@@ -334,6 +335,9 @@ struct radeon_encoder {
        enum radeon_rmx_type rmx_type;
        struct drm_display_mode native_mode;
        void *enc_priv;
+       int hdmi_offset;
+       int hdmi_audio_workaround;
+       int hdmi_buffer_status;
 };
 
 struct radeon_connector_atom_dig {
@@ -392,6 +396,11 @@ struct radeon_framebuffer {
        struct drm_gem_object *obj;
 };
 
+extern enum radeon_tv_std
+radeon_combios_get_tv_info(struct radeon_device *rdev);
+extern enum radeon_tv_std
+radeon_atombios_get_tv_info(struct radeon_device *rdev);
+
 extern void radeon_connector_hotplug(struct drm_connector *connector);
 extern bool radeon_dp_needs_link_train(struct radeon_connector *radeon_connector);
 extern int radeon_dp_mode_valid_helper(struct radeon_connector *radeon_connector,
index 544e18ffaf22e808b8f899874756aa3114d12040..d9ffe1f56e8fc2aca4acc845b1e470ceb9642203 100644 (file)
@@ -56,6 +56,13 @@ static void radeon_ttm_bo_destroy(struct ttm_buffer_object *tbo)
        kfree(bo);
 }
 
+bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo)
+{
+       if (bo->destroy == &radeon_ttm_bo_destroy)
+               return true;
+       return false;
+}
+
 void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
 {
        u32 c = 0;
@@ -71,6 +78,8 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
                rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
        if (domain & RADEON_GEM_DOMAIN_CPU)
                rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+       if (!c)
+               rbo->placements[c++] = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
        rbo->placement.num_placement = c;
        rbo->placement.num_busy_placement = c;
 }
@@ -481,14 +490,20 @@ int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
 }
 
 void radeon_bo_move_notify(struct ttm_buffer_object *bo,
-                               struct ttm_mem_reg *mem)
+                          struct ttm_mem_reg *mem)
 {
-       struct radeon_bo *rbo = container_of(bo, struct radeon_bo, tbo);
+       struct radeon_bo *rbo;
+       if (!radeon_ttm_bo_is_radeon_bo(bo))
+               return;
+       rbo = container_of(bo, struct radeon_bo, tbo);
        radeon_bo_check_tiling(rbo, 0, 1);
 }
 
 void radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
 {
-       struct radeon_bo *rbo = container_of(bo, struct radeon_bo, tbo);
+       struct radeon_bo *rbo;
+       if (!radeon_ttm_bo_is_radeon_bo(bo))
+               return;
+       rbo = container_of(bo, struct radeon_bo, tbo);
        radeon_bo_check_tiling(rbo, 0, 0);
 }
index f6b69c2c0d00cdec665946070405fe31b6005df4..a02f18011ad185da2146327adcd9bf32d6b564d6 100644 (file)
@@ -59,19 +59,17 @@ static inline unsigned radeon_mem_type_to_domain(u32 mem_type)
  *
  * Returns:
  * -EBUSY: buffer is busy and @no_wait is true
- * -ERESTART: A wait for the buffer to become unreserved was interrupted by
+ * -ERESTARTSYS: A wait for the buffer to become unreserved was interrupted by
  * a signal. Release all buffer reservations and return to user-space.
  */
 static inline int radeon_bo_reserve(struct radeon_bo *bo, bool no_wait)
 {
        int r;
 
-retry:
        r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0);
        if (unlikely(r != 0)) {
-               if (r == -ERESTART)
-                       goto retry;
-               dev_err(bo->rdev->dev, "%p reserve failed\n", bo);
+               if (r != -ERESTARTSYS)
+                       dev_err(bo->rdev->dev, "%p reserve failed\n", bo);
                return r;
        }
        return 0;
@@ -125,12 +123,10 @@ static inline int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type,
 {
        int r;
 
-retry:
        r = ttm_bo_reserve(&bo->tbo, true, no_wait, false, 0);
        if (unlikely(r != 0)) {
-               if (r == -ERESTART)
-                       goto retry;
-               dev_err(bo->rdev->dev, "%p reserve failed for wait\n", bo);
+               if (r != -ERESTARTSYS)
+                       dev_err(bo->rdev->dev, "%p reserve failed for wait\n", bo);
                return r;
        }
        spin_lock(&bo->tbo.lock);
@@ -140,8 +136,6 @@ retry:
                r = ttm_bo_wait(&bo->tbo, true, true, no_wait);
        spin_unlock(&bo->tbo.lock);
        ttm_bo_unreserve(&bo->tbo);
-       if (unlikely(r == -ERESTART))
-               goto retry;
        return r;
 }
 
index 34b08d307c814529251fb5e8d4694986f2ffbe86..8bce64cdc320f1028bd91231def13b45631de3e3 100644 (file)
@@ -44,8 +44,11 @@ static int radeon_debugfs_pm_info(struct seq_file *m, void *data)
        struct drm_device *dev = node->minor->dev;
        struct radeon_device *rdev = dev->dev_private;
 
-       seq_printf(m, "engine clock: %u0 kHz\n", radeon_get_engine_clock(rdev));
-       seq_printf(m, "memory clock: %u0 kHz\n", radeon_get_memory_clock(rdev));
+       seq_printf(m, "default engine clock: %u0 kHz\n", rdev->clock.default_sclk);
+       seq_printf(m, "current engine clock: %u0 kHz\n", radeon_get_engine_clock(rdev));
+       seq_printf(m, "default memory clock: %u0 kHz\n", rdev->clock.default_mclk);
+       if (rdev->asic->get_memory_clock)
+               seq_printf(m, "current memory clock: %u0 kHz\n", radeon_get_memory_clock(rdev));
 
        return 0;
 }
index 391c973ec4dbb7ef3c83bdfd3b757ff8b1ecb8b4..9f5e2f929da98e92cd8c418d010587ad7045d451 100644 (file)
@@ -42,8 +42,8 @@ void radeon_test_moves(struct radeon_device *rdev)
        /* Number of tests =
         * (Total GTT - IB pool - writeback page - ring buffer) / test size
         */
-       n = (rdev->mc.gtt_size - RADEON_IB_POOL_SIZE*64*1024 - RADEON_GPU_PAGE_SIZE -
-            rdev->cp.ring_size) / size;
+       n = ((u32)(rdev->mc.gtt_size - RADEON_IB_POOL_SIZE*64*1024 - RADEON_GPU_PAGE_SIZE -
+            rdev->cp.ring_size)) / size;
 
        gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL);
        if (!gtt_obj) {
index 5a19d529d1c0df9a52571b1423bcbc66b8847aca..3b0c07b444a2ee6f03c582f2da64556ed7876f1a 100644 (file)
@@ -200,7 +200,19 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
 static void radeon_evict_flags(struct ttm_buffer_object *bo,
                                struct ttm_placement *placement)
 {
-       struct radeon_bo *rbo = container_of(bo, struct radeon_bo, tbo);
+       struct radeon_bo *rbo;
+       static u32 placements = TTM_PL_MASK_CACHING | TTM_PL_FLAG_SYSTEM;
+
+       if (!radeon_ttm_bo_is_radeon_bo(bo)) {
+               placement->fpfn = 0;
+               placement->lpfn = 0;
+               placement->placement = &placements;
+               placement->busy_placement = &placements;
+               placement->num_placement = 1;
+               placement->num_busy_placement = 1;
+               return;
+       }
+       rbo = container_of(bo, struct radeon_bo, tbo);
        switch (bo->mem.mem_type) {
        case TTM_PL_VRAM:
                radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_GTT);
@@ -482,6 +494,7 @@ int radeon_ttm_init(struct radeon_device *rdev)
                DRM_ERROR("failed initializing buffer object driver(%d).\n", r);
                return r;
        }
+       rdev->mman.initialized = true;
        r = ttm_bo_init_mm(&rdev->mman.bdev, TTM_PL_VRAM,
                                rdev->mc.real_vram_size >> PAGE_SHIFT);
        if (r) {
@@ -529,6 +542,8 @@ void radeon_ttm_fini(struct radeon_device *rdev)
 {
        int r;
 
+       if (!rdev->mman.initialized)
+               return;
        if (rdev->stollen_vga_memory) {
                r = radeon_bo_reserve(rdev->stollen_vga_memory, false);
                if (r == 0) {
@@ -542,6 +557,7 @@ void radeon_ttm_fini(struct radeon_device *rdev)
        ttm_bo_device_release(&rdev->mman.bdev);
        radeon_gart_fini(rdev);
        radeon_ttm_global_fini(rdev);
+       rdev->mman.initialized = false;
        DRM_INFO("radeon: ttm finalized\n");
 }
 
index c1fcdddb6be68e7b4aa0ad56b5050679efb41bff..368415df5f3abe954494e58f239708c1c5a1557b 100644 (file)
@@ -497,6 +497,8 @@ int rs400_init(struct radeon_device *rdev)
 
        /* Initialize clocks */
        radeon_get_clock_info(rdev->ddev);
+       /* Initialize power management */
+       radeon_pm_init(rdev);
        /* Get vram informations */
        rs400_vram_info(rdev);
        /* Initialize memory controller (also test AGP) */
index fbb0357f1ec32e21da862b2e17fee781599da337..3bcb66e52786c3ef0018d8e2c43bf29d3825b154 100644 (file)
@@ -892,6 +892,14 @@ static int rv770_startup(struct radeon_device *rdev)
        }
        rv770_gpu_init(rdev);
 
+       if (!rdev->r600_blit.shader_obj) {
+               r = r600_blit_init(rdev);
+               if (r) {
+                       DRM_ERROR("radeon: failed blitter (%d).\n", r);
+                       return r;
+               }
+       }
+
        r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false);
        if (unlikely(r != 0))
                return r;
@@ -1051,12 +1059,6 @@ int rv770_init(struct radeon_device *rdev)
        if (r)
                return r;
 
-       r = r600_blit_init(rdev);
-       if (r) {
-               DRM_ERROR("radeon: failed blitter (%d).\n", r);
-               return r;
-       }
-
        rdev->accel_working = true;
        r = rv770_startup(rdev);
        if (r) {
index eee52aa92a7c9942fc937c377d684ea1bb799c7b..021de44c15ab75245fde74c95701c6c8a72aadaf 100644 (file)
@@ -50,7 +50,7 @@ static struct drm_driver driver = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
-                .ioctl = drm_ioctl,
+                .unlocked_ioctl = drm_ioctl,
                 .mmap = drm_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
index e725cc0b115583680ca9b344a8286154b5be1c2c..4fd1f067d380779302c59e1f6bb4c5d574b202ae 100644 (file)
@@ -80,7 +80,7 @@ static struct drm_driver driver = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
-                .ioctl = drm_ioctl,
+                .unlocked_ioctl = drm_ioctl,
                 .mmap = drm_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
index 012ff2e356b2a7574a1c15dad979884bd39bea80..ec5a43e65722ec3a3b2a7a63a4e97fd531730a34 100644 (file)
@@ -48,7 +48,7 @@ static struct drm_driver driver = {
                 .owner = THIS_MODULE,
                 .open = drm_open,
                 .release = drm_release,
-                .ioctl = drm_ioctl,
+                .unlocked_ioctl = drm_ioctl,
                 .mmap = drm_mmap,
                 .poll = drm_poll,
                 .fasync = drm_fasync,
index 1fbb2eea5e88d5d17b59ddffa40a29b0424f8069..2920f9a279e141aa9fd1ccc38cc0bfcb586c5f59 100644 (file)
@@ -71,34 +71,34 @@ static inline int ttm_mem_type_from_flags(uint32_t flags, uint32_t *mem_type)
        return -EINVAL;
 }
 
-static void ttm_mem_type_manager_debug(struct ttm_bo_global *glob,
-                                       struct ttm_mem_type_manager *man)
+static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type)
 {
+       struct ttm_mem_type_manager *man = &bdev->man[mem_type];
+
        printk(KERN_ERR TTM_PFX "    has_type: %d\n", man->has_type);
        printk(KERN_ERR TTM_PFX "    use_type: %d\n", man->use_type);
        printk(KERN_ERR TTM_PFX "    flags: 0x%08X\n", man->flags);
        printk(KERN_ERR TTM_PFX "    gpu_offset: 0x%08lX\n", man->gpu_offset);
        printk(KERN_ERR TTM_PFX "    io_offset: 0x%08lX\n", man->io_offset);
        printk(KERN_ERR TTM_PFX "    io_size: %ld\n", man->io_size);
-       printk(KERN_ERR TTM_PFX "    size: %ld\n", (unsigned long)man->size);
+       printk(KERN_ERR TTM_PFX "    size: %llu\n", man->size);
        printk(KERN_ERR TTM_PFX "    available_caching: 0x%08X\n",
                man->available_caching);
        printk(KERN_ERR TTM_PFX "    default_caching: 0x%08X\n",
                man->default_caching);
-       spin_lock(&glob->lru_lock);
-       drm_mm_debug_table(&man->manager, TTM_PFX);
-       spin_unlock(&glob->lru_lock);
+       if (mem_type != TTM_PL_SYSTEM) {
+               spin_lock(&bdev->glob->lru_lock);
+               drm_mm_debug_table(&man->manager, TTM_PFX);
+               spin_unlock(&bdev->glob->lru_lock);
+       }
 }
 
 static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
                                        struct ttm_placement *placement)
 {
-       struct ttm_bo_device *bdev = bo->bdev;
-       struct ttm_bo_global *glob = bo->glob;
-       struct ttm_mem_type_manager *man;
        int i, ret, mem_type;
 
-       printk(KERN_ERR TTM_PFX "No space for %p (%ld pages, %ldK, %ldM)\n",
+       printk(KERN_ERR TTM_PFX "No space for %p (%lu pages, %luK, %luM)\n",
                bo, bo->mem.num_pages, bo->mem.size >> 10,
                bo->mem.size >> 20);
        for (i = 0; i < placement->num_placement; i++) {
@@ -106,10 +106,9 @@ static void ttm_bo_mem_space_debug(struct ttm_buffer_object *bo,
                                                &mem_type);
                if (ret)
                        return;
-               man = &bdev->man[mem_type];
                printk(KERN_ERR TTM_PFX "  placement[%d]=0x%08X (%d)\n",
                        i, placement->placement[i], mem_type);
-               ttm_mem_type_manager_debug(glob, man);
+               ttm_mem_type_debug(bo->bdev, mem_type);
        }
 }
 
@@ -465,6 +464,8 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all)
                spin_unlock(&bo->lock);
 
                spin_lock(&glob->lru_lock);
+               put_count = ttm_bo_del_from_lru(bo);
+
                ret = ttm_bo_reserve_locked(bo, false, false, false, 0);
                BUG_ON(ret);
                if (bo->ttm)
@@ -472,20 +473,19 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all)
 
                if (!list_empty(&bo->ddestroy)) {
                        list_del_init(&bo->ddestroy);
-                       kref_put(&bo->list_kref, ttm_bo_ref_bug);
+                       ++put_count;
                }
                if (bo->mem.mm_node) {
                        bo->mem.mm_node->private = NULL;
                        drm_mm_put_block(bo->mem.mm_node);
                        bo->mem.mm_node = NULL;
                }
-               put_count = ttm_bo_del_from_lru(bo);
                spin_unlock(&glob->lru_lock);
 
                atomic_set(&bo->reserved, 0);
 
                while (put_count--)
-                       kref_put(&bo->list_kref, ttm_bo_release_list);
+                       kref_put(&bo->list_kref, ttm_bo_ref_bug);
 
                return 0;
        }
@@ -684,19 +684,45 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
        struct ttm_buffer_object *bo;
        int ret, put_count = 0;
 
+retry:
        spin_lock(&glob->lru_lock);
+       if (list_empty(&man->lru)) {
+               spin_unlock(&glob->lru_lock);
+               return -EBUSY;
+       }
+
        bo = list_first_entry(&man->lru, struct ttm_buffer_object, lru);
        kref_get(&bo->list_kref);
-       ret = ttm_bo_reserve_locked(bo, interruptible, no_wait, false, 0);
-       if (likely(ret == 0))
-               put_count = ttm_bo_del_from_lru(bo);
+
+       ret = ttm_bo_reserve_locked(bo, false, true, false, 0);
+
+       if (unlikely(ret == -EBUSY)) {
+               spin_unlock(&glob->lru_lock);
+               if (likely(!no_wait))
+                       ret = ttm_bo_wait_unreserved(bo, interruptible);
+
+               kref_put(&bo->list_kref, ttm_bo_release_list);
+
+               /**
+                * We *need* to retry after releasing the lru lock.
+                */
+
+               if (unlikely(ret != 0))
+                       return ret;
+               goto retry;
+       }
+
+       put_count = ttm_bo_del_from_lru(bo);
        spin_unlock(&glob->lru_lock);
-       if (unlikely(ret != 0))
-               return ret;
+
+       BUG_ON(ret != 0);
+
        while (put_count--)
                kref_put(&bo->list_kref, ttm_bo_ref_bug);
+
        ret = ttm_bo_evict(bo, interruptible, no_wait);
        ttm_bo_unreserve(bo);
+
        kref_put(&bo->list_kref, ttm_bo_release_list);
        return ret;
 }
@@ -849,7 +875,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
        int i, ret;
 
        mem->mm_node = NULL;
-       for (i = 0; i <= placement->num_placement; ++i) {
+       for (i = 0; i < placement->num_placement; ++i) {
                ret = ttm_mem_type_from_flags(placement->placement[i],
                                                &mem_type);
                if (ret)
@@ -900,8 +926,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
        if (!type_found)
                return -EINVAL;
 
-       for (i = 0; i <= placement->num_busy_placement; ++i) {
-               ret = ttm_mem_type_from_flags(placement->placement[i],
+       for (i = 0; i < placement->num_busy_placement; ++i) {
+               ret = ttm_mem_type_from_flags(placement->busy_placement[i],
                                                &mem_type);
                if (ret)
                        return ret;
@@ -911,7 +937,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
                if (!ttm_bo_mt_compatible(man,
                                                bo->type == ttm_bo_type_user,
                                                mem_type,
-                                               placement->placement[i],
+                                               placement->busy_placement[i],
                                                &cur_flags))
                        continue;
 
@@ -921,7 +947,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
                 * Use the access and other non-mapping-related flag bits from
                 * the memory placement flags to the current flags
                 */
-               ttm_flag_masked(&cur_flags, placement->placement[i],
+               ttm_flag_masked(&cur_flags, placement->busy_placement[i],
                                ~TTM_PL_MASK_MEMTYPE);
 
                ret = ttm_bo_mem_force_space(bo, mem_type, placement, mem,
@@ -1115,6 +1141,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
        bo->glob = bdev->glob;
        bo->type = type;
        bo->num_pages = num_pages;
+       bo->mem.size = num_pages << PAGE_SHIFT;
        bo->mem.mem_type = TTM_PL_SYSTEM;
        bo->mem.num_pages = bo->num_pages;
        bo->mem.mm_node = NULL;
index 609a85a4d855127288cc30e234333d516a58e7d2..668dbe8b8dd3c9e486ebd483942c827dcd8d40a6 100644 (file)
@@ -320,7 +320,7 @@ ssize_t ttm_bo_io(struct ttm_bo_device *bdev, struct file *filp,
                return -EFAULT;
 
        driver = bo->bdev->driver;
-       if (unlikely(driver->verify_access)) {
+       if (unlikely(!driver->verify_access)) {
                ret = -EPERM;
                goto out_unref;
        }
index bc2f518430050adb0495933e7221d6cb59c941ee..7a1b210401e080908a394368f4797c63dd745d65 100644 (file)
@@ -58,7 +58,7 @@ static struct drm_driver driver = {
                .owner = THIS_MODULE,
                .open = drm_open,
                .release = drm_release,
-               .ioctl = drm_ioctl,
+               .unlocked_ioctl = drm_ioctl,
                .mmap = drm_mmap,
                .poll = drm_poll,
                .fasync = drm_fasync,
diff --git a/drivers/gpu/drm/vmwgfx/Kconfig b/drivers/gpu/drm/vmwgfx/Kconfig
new file mode 100644 (file)
index 0000000..f20b8bc
--- /dev/null
@@ -0,0 +1,13 @@
+config DRM_VMWGFX
+       tristate "DRM driver for VMware Virtual GPU"
+       depends on DRM && PCI
+       select FB_DEFERRED_IO
+       select FB_CFB_FILLRECT
+       select FB_CFB_COPYAREA
+       select FB_CFB_IMAGEBLIT
+       select DRM_TTM
+       help
+         KMS enabled DRM driver for SVGA2 virtual hardware.
+
+         If unsure say n. The compiled module will be
+         called vmwgfx.ko
diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile
new file mode 100644 (file)
index 0000000..1a3cb68
--- /dev/null
@@ -0,0 +1,9 @@
+
+ccflags-y := -Iinclude/drm
+
+vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \
+           vmwgfx_fb.o vmwgfx_ioctl.o vmwgfx_resource.o vmwgfx_buffer.o \
+           vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \
+           vmwgfx_overlay.o
+
+obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
diff --git a/drivers/gpu/drm/vmwgfx/svga3d_reg.h b/drivers/gpu/drm/vmwgfx/svga3d_reg.h
new file mode 100644 (file)
index 0000000..77cb453
--- /dev/null
@@ -0,0 +1,1793 @@
+/**********************************************************
+ * Copyright 1998-2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/*
+ * svga3d_reg.h --
+ *
+ *       SVGA 3D hardware definitions
+ */
+
+#ifndef _SVGA3D_REG_H_
+#define _SVGA3D_REG_H_
+
+#include "svga_reg.h"
+
+
+/*
+ * 3D Hardware Version
+ *
+ *   The hardware version is stored in the SVGA_FIFO_3D_HWVERSION fifo
+ *   register.   Is set by the host and read by the guest.  This lets
+ *   us make new guest drivers which are backwards-compatible with old
+ *   SVGA hardware revisions.  It does not let us support old guest
+ *   drivers.  Good enough for now.
+ *
+ */
+
+#define SVGA3D_MAKE_HWVERSION(major, minor)      (((major) << 16) | ((minor) & 0xFF))
+#define SVGA3D_MAJOR_HWVERSION(version)          ((version) >> 16)
+#define SVGA3D_MINOR_HWVERSION(version)          ((version) & 0xFF)
+
+typedef enum {
+   SVGA3D_HWVERSION_WS5_RC1   = SVGA3D_MAKE_HWVERSION(0, 1),
+   SVGA3D_HWVERSION_WS5_RC2   = SVGA3D_MAKE_HWVERSION(0, 2),
+   SVGA3D_HWVERSION_WS51_RC1  = SVGA3D_MAKE_HWVERSION(0, 3),
+   SVGA3D_HWVERSION_WS6_B1    = SVGA3D_MAKE_HWVERSION(1, 1),
+   SVGA3D_HWVERSION_FUSION_11 = SVGA3D_MAKE_HWVERSION(1, 4),
+   SVGA3D_HWVERSION_WS65_B1   = SVGA3D_MAKE_HWVERSION(2, 0),
+   SVGA3D_HWVERSION_CURRENT   = SVGA3D_HWVERSION_WS65_B1,
+} SVGA3dHardwareVersion;
+
+/*
+ * Generic Types
+ */
+
+typedef uint32 SVGA3dBool; /* 32-bit Bool definition */
+#define SVGA3D_NUM_CLIPPLANES                   6
+#define SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS  8
+
+
+/*
+ * Surface formats.
+ *
+ * If you modify this list, be sure to keep GLUtil.c in sync. It
+ * includes the internal format definition of each surface in
+ * GLUtil_ConvertSurfaceFormat, and it contains a table of
+ * human-readable names in GLUtil_GetFormatName.
+ */
+
+typedef enum SVGA3dSurfaceFormat {
+   SVGA3D_FORMAT_INVALID = 0,
+
+   SVGA3D_X8R8G8B8       = 1,
+   SVGA3D_A8R8G8B8       = 2,
+
+   SVGA3D_R5G6B5         = 3,
+   SVGA3D_X1R5G5B5       = 4,
+   SVGA3D_A1R5G5B5       = 5,
+   SVGA3D_A4R4G4B4       = 6,
+
+   SVGA3D_Z_D32          = 7,
+   SVGA3D_Z_D16          = 8,
+   SVGA3D_Z_D24S8        = 9,
+   SVGA3D_Z_D15S1        = 10,
+
+   SVGA3D_LUMINANCE8            = 11,
+   SVGA3D_LUMINANCE4_ALPHA4     = 12,
+   SVGA3D_LUMINANCE16           = 13,
+   SVGA3D_LUMINANCE8_ALPHA8     = 14,
+
+   SVGA3D_DXT1           = 15,
+   SVGA3D_DXT2           = 16,
+   SVGA3D_DXT3           = 17,
+   SVGA3D_DXT4           = 18,
+   SVGA3D_DXT5           = 19,
+
+   SVGA3D_BUMPU8V8       = 20,
+   SVGA3D_BUMPL6V5U5     = 21,
+   SVGA3D_BUMPX8L8V8U8   = 22,
+   SVGA3D_BUMPL8V8U8     = 23,
+
+   SVGA3D_ARGB_S10E5     = 24,   /* 16-bit floating-point ARGB */
+   SVGA3D_ARGB_S23E8     = 25,   /* 32-bit floating-point ARGB */
+
+   SVGA3D_A2R10G10B10    = 26,
+
+   /* signed formats */
+   SVGA3D_V8U8           = 27,
+   SVGA3D_Q8W8V8U8       = 28,
+   SVGA3D_CxV8U8         = 29,
+
+   /* mixed formats */
+   SVGA3D_X8L8V8U8       = 30,
+   SVGA3D_A2W10V10U10    = 31,
+
+   SVGA3D_ALPHA8         = 32,
+
+   /* Single- and dual-component floating point formats */
+   SVGA3D_R_S10E5        = 33,
+   SVGA3D_R_S23E8        = 34,
+   SVGA3D_RG_S10E5       = 35,
+   SVGA3D_RG_S23E8       = 36,
+
+   /*
+    * Any surface can be used as a buffer object, but SVGA3D_BUFFER is
+    * the most efficient format to use when creating new surfaces
+    * expressly for index or vertex data.
+    */
+   SVGA3D_BUFFER         = 37,
+
+   SVGA3D_Z_D24X8        = 38,
+
+   SVGA3D_V16U16         = 39,
+
+   SVGA3D_G16R16         = 40,
+   SVGA3D_A16B16G16R16   = 41,
+
+   /* Packed Video formats */
+   SVGA3D_UYVY           = 42,
+   SVGA3D_YUY2           = 43,
+
+   SVGA3D_FORMAT_MAX
+} SVGA3dSurfaceFormat;
+
+typedef uint32 SVGA3dColor; /* a, r, g, b */
+
+/*
+ * These match the D3DFORMAT_OP definitions used by Direct3D. We need
+ * them so that we can query the host for what the supported surface
+ * operations are (when we're using the D3D backend, in particular),
+ * and so we can send those operations to the guest.
+ */
+typedef enum {
+   SVGA3DFORMAT_OP_TEXTURE                               = 0x00000001,
+   SVGA3DFORMAT_OP_VOLUMETEXTURE                         = 0x00000002,
+   SVGA3DFORMAT_OP_CUBETEXTURE                           = 0x00000004,
+   SVGA3DFORMAT_OP_OFFSCREEN_RENDERTARGET                = 0x00000008,
+   SVGA3DFORMAT_OP_SAME_FORMAT_RENDERTARGET              = 0x00000010,
+   SVGA3DFORMAT_OP_ZSTENCIL                              = 0x00000040,
+   SVGA3DFORMAT_OP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH   = 0x00000080,
+
+/*
+ * This format can be used as a render target if the current display mode
+ * is the same depth if the alpha channel is ignored. e.g. if the device
+ * can render to A8R8G8B8 when the display mode is X8R8G8B8, then the
+ * format op list entry for A8R8G8B8 should have this cap.
+ */
+   SVGA3DFORMAT_OP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET  = 0x00000100,
+
+/*
+ * This format contains DirectDraw support (including Flip).  This flag
+ * should not to be set on alpha formats.
+ */
+   SVGA3DFORMAT_OP_DISPLAYMODE                           = 0x00000400,
+
+/*
+ * The rasterizer can support some level of Direct3D support in this format
+ * and implies that the driver can create a Context in this mode (for some
+ * render target format).  When this flag is set, the SVGA3DFORMAT_OP_DISPLAYMODE
+ * flag must also be set.
+ */
+   SVGA3DFORMAT_OP_3DACCELERATION                        = 0x00000800,
+
+/*
+ * This is set for a private format when the driver has put the bpp in
+ * the structure.
+ */
+   SVGA3DFORMAT_OP_PIXELSIZE                             = 0x00001000,
+
+/*
+ * Indicates that this format can be converted to any RGB format for which
+ * SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB is specified
+ */
+   SVGA3DFORMAT_OP_CONVERT_TO_ARGB                       = 0x00002000,
+
+/*
+ * Indicates that this format can be used to create offscreen plain surfaces.
+ */
+   SVGA3DFORMAT_OP_OFFSCREENPLAIN                        = 0x00004000,
+
+/*
+ * Indicated that this format can be read as an SRGB texture (meaning that the
+ * sampler will linearize the looked up data)
+ */
+   SVGA3DFORMAT_OP_SRGBREAD                              = 0x00008000,
+
+/*
+ * Indicates that this format can be used in the bumpmap instructions
+ */
+   SVGA3DFORMAT_OP_BUMPMAP                               = 0x00010000,
+
+/*
+ * Indicates that this format can be sampled by the displacement map sampler
+ */
+   SVGA3DFORMAT_OP_DMAP                                  = 0x00020000,
+
+/*
+ * Indicates that this format cannot be used with texture filtering
+ */
+   SVGA3DFORMAT_OP_NOFILTER                              = 0x00040000,
+
+/*
+ * Indicates that format conversions are supported to this RGB format if
+ * SVGA3DFORMAT_OP_CONVERT_TO_ARGB is specified in the source format.
+ */
+   SVGA3DFORMAT_OP_MEMBEROFGROUP_ARGB                    = 0x00080000,
+
+/*
+ * Indicated that this format can be written as an SRGB target (meaning that the
+ * pixel pipe will DE-linearize data on output to format)
+ */
+   SVGA3DFORMAT_OP_SRGBWRITE                             = 0x00100000,
+
+/*
+ * Indicates that this format cannot be used with alpha blending
+ */
+   SVGA3DFORMAT_OP_NOALPHABLEND                          = 0x00200000,
+
+/*
+ * Indicates that the device can auto-generated sublevels for resources
+ * of this format
+ */
+   SVGA3DFORMAT_OP_AUTOGENMIPMAP                         = 0x00400000,
+
+/*
+ * Indicates that this format can be used by vertex texture sampler
+ */
+   SVGA3DFORMAT_OP_VERTEXTEXTURE                         = 0x00800000,
+
+/*
+ * Indicates that this format supports neither texture coordinate wrap
+ * modes, nor mipmapping
+ */
+   SVGA3DFORMAT_OP_NOTEXCOORDWRAPNORMIP                  = 0x01000000
+} SVGA3dFormatOp;
+
+/*
+ * This structure is a conversion of SVGA3DFORMAT_OP_*.
+ * Entries must be located at the same position.
+ */
+typedef union {
+   uint32 value;
+   struct {
+      uint32 texture : 1;
+      uint32 volumeTexture : 1;
+      uint32 cubeTexture : 1;
+      uint32 offscreenRenderTarget : 1;
+      uint32 sameFormatRenderTarget : 1;
+      uint32 unknown1 : 1;
+      uint32 zStencil : 1;
+      uint32 zStencilArbitraryDepth : 1;
+      uint32 sameFormatUpToAlpha : 1;
+      uint32 unknown2 : 1;
+      uint32 displayMode : 1;
+      uint32 acceleration3d : 1;
+      uint32 pixelSize : 1;
+      uint32 convertToARGB : 1;
+      uint32 offscreenPlain : 1;
+      uint32 sRGBRead : 1;
+      uint32 bumpMap : 1;
+      uint32 dmap : 1;
+      uint32 noFilter : 1;
+      uint32 memberOfGroupARGB : 1;
+      uint32 sRGBWrite : 1;
+      uint32 noAlphaBlend : 1;
+      uint32 autoGenMipMap : 1;
+      uint32 vertexTexture : 1;
+      uint32 noTexCoordWrapNorMip : 1;
+   };
+} SVGA3dSurfaceFormatCaps;
+
+/*
+ * SVGA_3D_CMD_SETRENDERSTATE Types.  All value types
+ * must fit in a uint32.
+ */
+
+typedef enum {
+   SVGA3D_RS_INVALID                   = 0,
+   SVGA3D_RS_ZENABLE                   = 1,     /* SVGA3dBool */
+   SVGA3D_RS_ZWRITEENABLE              = 2,     /* SVGA3dBool */
+   SVGA3D_RS_ALPHATESTENABLE           = 3,     /* SVGA3dBool */
+   SVGA3D_RS_DITHERENABLE              = 4,     /* SVGA3dBool */
+   SVGA3D_RS_BLENDENABLE               = 5,     /* SVGA3dBool */
+   SVGA3D_RS_FOGENABLE                 = 6,     /* SVGA3dBool */
+   SVGA3D_RS_SPECULARENABLE            = 7,     /* SVGA3dBool */
+   SVGA3D_RS_STENCILENABLE             = 8,     /* SVGA3dBool */
+   SVGA3D_RS_LIGHTINGENABLE            = 9,     /* SVGA3dBool */
+   SVGA3D_RS_NORMALIZENORMALS          = 10,    /* SVGA3dBool */
+   SVGA3D_RS_POINTSPRITEENABLE         = 11,    /* SVGA3dBool */
+   SVGA3D_RS_POINTSCALEENABLE          = 12,    /* SVGA3dBool */
+   SVGA3D_RS_STENCILREF                = 13,    /* uint32 */
+   SVGA3D_RS_STENCILMASK               = 14,    /* uint32 */
+   SVGA3D_RS_STENCILWRITEMASK          = 15,    /* uint32 */
+   SVGA3D_RS_FOGSTART                  = 16,    /* float */
+   SVGA3D_RS_FOGEND                    = 17,    /* float */
+   SVGA3D_RS_FOGDENSITY                = 18,    /* float */
+   SVGA3D_RS_POINTSIZE                 = 19,    /* float */
+   SVGA3D_RS_POINTSIZEMIN              = 20,    /* float */
+   SVGA3D_RS_POINTSIZEMAX              = 21,    /* float */
+   SVGA3D_RS_POINTSCALE_A              = 22,    /* float */
+   SVGA3D_RS_POINTSCALE_B              = 23,    /* float */
+   SVGA3D_RS_POINTSCALE_C              = 24,    /* float */
+   SVGA3D_RS_FOGCOLOR                  = 25,    /* SVGA3dColor */
+   SVGA3D_RS_AMBIENT                   = 26,    /* SVGA3dColor */
+   SVGA3D_RS_CLIPPLANEENABLE           = 27,    /* SVGA3dClipPlanes */
+   SVGA3D_RS_FOGMODE                   = 28,    /* SVGA3dFogMode */
+   SVGA3D_RS_FILLMODE                  = 29,    /* SVGA3dFillMode */
+   SVGA3D_RS_SHADEMODE                 = 30,    /* SVGA3dShadeMode */
+   SVGA3D_RS_LINEPATTERN               = 31,    /* SVGA3dLinePattern */
+   SVGA3D_RS_SRCBLEND                  = 32,    /* SVGA3dBlendOp */
+   SVGA3D_RS_DSTBLEND                  = 33,    /* SVGA3dBlendOp */
+   SVGA3D_RS_BLENDEQUATION             = 34,    /* SVGA3dBlendEquation */
+   SVGA3D_RS_CULLMODE                  = 35,    /* SVGA3dFace */
+   SVGA3D_RS_ZFUNC                     = 36,    /* SVGA3dCmpFunc */
+   SVGA3D_RS_ALPHAFUNC                 = 37,    /* SVGA3dCmpFunc */
+   SVGA3D_RS_STENCILFUNC               = 38,    /* SVGA3dCmpFunc */
+   SVGA3D_RS_STENCILFAIL               = 39,    /* SVGA3dStencilOp */
+   SVGA3D_RS_STENCILZFAIL              = 40,    /* SVGA3dStencilOp */
+   SVGA3D_RS_STENCILPASS               = 41,    /* SVGA3dStencilOp */
+   SVGA3D_RS_ALPHAREF                  = 42,    /* float (0.0 .. 1.0) */
+   SVGA3D_RS_FRONTWINDING              = 43,    /* SVGA3dFrontWinding */
+   SVGA3D_RS_COORDINATETYPE            = 44,    /* SVGA3dCoordinateType */
+   SVGA3D_RS_ZBIAS                     = 45,    /* float */
+   SVGA3D_RS_RANGEFOGENABLE            = 46,    /* SVGA3dBool */
+   SVGA3D_RS_COLORWRITEENABLE          = 47,    /* SVGA3dColorMask */
+   SVGA3D_RS_VERTEXMATERIALENABLE      = 48,    /* SVGA3dBool */
+   SVGA3D_RS_DIFFUSEMATERIALSOURCE     = 49,    /* SVGA3dVertexMaterial */
+   SVGA3D_RS_SPECULARMATERIALSOURCE    = 50,    /* SVGA3dVertexMaterial */
+   SVGA3D_RS_AMBIENTMATERIALSOURCE     = 51,    /* SVGA3dVertexMaterial */
+   SVGA3D_RS_EMISSIVEMATERIALSOURCE    = 52,    /* SVGA3dVertexMaterial */
+   SVGA3D_RS_TEXTUREFACTOR             = 53,    /* SVGA3dColor */
+   SVGA3D_RS_LOCALVIEWER               = 54,    /* SVGA3dBool */
+   SVGA3D_RS_SCISSORTESTENABLE         = 55,    /* SVGA3dBool */
+   SVGA3D_RS_BLENDCOLOR                = 56,    /* SVGA3dColor */
+   SVGA3D_RS_STENCILENABLE2SIDED       = 57,    /* SVGA3dBool */
+   SVGA3D_RS_CCWSTENCILFUNC            = 58,    /* SVGA3dCmpFunc */
+   SVGA3D_RS_CCWSTENCILFAIL            = 59,    /* SVGA3dStencilOp */
+   SVGA3D_RS_CCWSTENCILZFAIL           = 60,    /* SVGA3dStencilOp */
+   SVGA3D_RS_CCWSTENCILPASS            = 61,    /* SVGA3dStencilOp */
+   SVGA3D_RS_VERTEXBLEND               = 62,    /* SVGA3dVertexBlendFlags */
+   SVGA3D_RS_SLOPESCALEDEPTHBIAS       = 63,    /* float */
+   SVGA3D_RS_DEPTHBIAS                 = 64,    /* float */
+
+
+   /*
+    * Output Gamma Level
+    *
+    * Output gamma effects the gamma curve of colors that are output from the
+    * rendering pipeline.  A value of 1.0 specifies a linear color space. If the
+    * value is <= 0.0, gamma correction is ignored and linear color space is
+    * used.
+    */
+
+   SVGA3D_RS_OUTPUTGAMMA               = 65,    /* float */
+   SVGA3D_RS_ZVISIBLE                  = 66,    /* SVGA3dBool */
+   SVGA3D_RS_LASTPIXEL                 = 67,    /* SVGA3dBool */
+   SVGA3D_RS_CLIPPING                  = 68,    /* SVGA3dBool */
+   SVGA3D_RS_WRAP0                     = 69,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP1                     = 70,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP2                     = 71,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP3                     = 72,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP4                     = 73,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP5                     = 74,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP6                     = 75,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP7                     = 76,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP8                     = 77,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP9                     = 78,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP10                    = 79,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP11                    = 80,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP12                    = 81,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP13                    = 82,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP14                    = 83,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_WRAP15                    = 84,    /* SVGA3dWrapFlags */
+   SVGA3D_RS_MULTISAMPLEANTIALIAS      = 85,    /* SVGA3dBool */
+   SVGA3D_RS_MULTISAMPLEMASK           = 86,    /* uint32 */
+   SVGA3D_RS_INDEXEDVERTEXBLENDENABLE  = 87,    /* SVGA3dBool */
+   SVGA3D_RS_TWEENFACTOR               = 88,    /* float */
+   SVGA3D_RS_ANTIALIASEDLINEENABLE     = 89,    /* SVGA3dBool */
+   SVGA3D_RS_COLORWRITEENABLE1         = 90,    /* SVGA3dColorMask */
+   SVGA3D_RS_COLORWRITEENABLE2         = 91,    /* SVGA3dColorMask */
+   SVGA3D_RS_COLORWRITEENABLE3         = 92,    /* SVGA3dColorMask */
+   SVGA3D_RS_SEPARATEALPHABLENDENABLE  = 93,    /* SVGA3dBool */
+   SVGA3D_RS_SRCBLENDALPHA             = 94,    /* SVGA3dBlendOp */
+   SVGA3D_RS_DSTBLENDALPHA             = 95,    /* SVGA3dBlendOp */
+   SVGA3D_RS_BLENDEQUATIONALPHA        = 96,    /* SVGA3dBlendEquation */
+   SVGA3D_RS_MAX
+} SVGA3dRenderStateName;
+
+typedef enum {
+   SVGA3D_VERTEXMATERIAL_NONE     = 0,    /* Use the value in the current material */
+   SVGA3D_VERTEXMATERIAL_DIFFUSE  = 1,    /* Use the value in the diffuse component */
+   SVGA3D_VERTEXMATERIAL_SPECULAR = 2,    /* Use the value in the specular component */
+} SVGA3dVertexMaterial;
+
+typedef enum {
+   SVGA3D_FILLMODE_INVALID = 0,
+   SVGA3D_FILLMODE_POINT   = 1,
+   SVGA3D_FILLMODE_LINE    = 2,
+   SVGA3D_FILLMODE_FILL    = 3,
+   SVGA3D_FILLMODE_MAX
+} SVGA3dFillModeType;
+
+
+typedef
+union {
+   struct {
+      uint16   mode;       /* SVGA3dFillModeType */
+      uint16   face;       /* SVGA3dFace */
+   };
+   uint32 uintValue;
+} SVGA3dFillMode;
+
+typedef enum {
+   SVGA3D_SHADEMODE_INVALID = 0,
+   SVGA3D_SHADEMODE_FLAT    = 1,
+   SVGA3D_SHADEMODE_SMOOTH  = 2,
+   SVGA3D_SHADEMODE_PHONG   = 3,     /* Not supported */
+   SVGA3D_SHADEMODE_MAX
+} SVGA3dShadeMode;
+
+typedef
+union {
+   struct {
+      uint16 repeat;
+      uint16 pattern;
+   };
+   uint32 uintValue;
+} SVGA3dLinePattern;
+
+typedef enum {
+   SVGA3D_BLENDOP_INVALID            = 0,
+   SVGA3D_BLENDOP_ZERO               = 1,
+   SVGA3D_BLENDOP_ONE                = 2,
+   SVGA3D_BLENDOP_SRCCOLOR           = 3,
+   SVGA3D_BLENDOP_INVSRCCOLOR        = 4,
+   SVGA3D_BLENDOP_SRCALPHA           = 5,
+   SVGA3D_BLENDOP_INVSRCALPHA        = 6,
+   SVGA3D_BLENDOP_DESTALPHA          = 7,
+   SVGA3D_BLENDOP_INVDESTALPHA       = 8,
+   SVGA3D_BLENDOP_DESTCOLOR          = 9,
+   SVGA3D_BLENDOP_INVDESTCOLOR       = 10,
+   SVGA3D_BLENDOP_SRCALPHASAT        = 11,
+   SVGA3D_BLENDOP_BLENDFACTOR        = 12,
+   SVGA3D_BLENDOP_INVBLENDFACTOR     = 13,
+   SVGA3D_BLENDOP_MAX
+} SVGA3dBlendOp;
+
+typedef enum {
+   SVGA3D_BLENDEQ_INVALID            = 0,
+   SVGA3D_BLENDEQ_ADD                = 1,
+   SVGA3D_BLENDEQ_SUBTRACT           = 2,
+   SVGA3D_BLENDEQ_REVSUBTRACT        = 3,
+   SVGA3D_BLENDEQ_MINIMUM            = 4,
+   SVGA3D_BLENDEQ_MAXIMUM            = 5,
+   SVGA3D_BLENDEQ_MAX
+} SVGA3dBlendEquation;
+
+typedef enum {
+   SVGA3D_FRONTWINDING_INVALID = 0,
+   SVGA3D_FRONTWINDING_CW      = 1,
+   SVGA3D_FRONTWINDING_CCW     = 2,
+   SVGA3D_FRONTWINDING_MAX
+} SVGA3dFrontWinding;
+
+typedef enum {
+   SVGA3D_FACE_INVALID  = 0,
+   SVGA3D_FACE_NONE     = 1,
+   SVGA3D_FACE_FRONT    = 2,
+   SVGA3D_FACE_BACK     = 3,
+   SVGA3D_FACE_FRONT_BACK = 4,
+   SVGA3D_FACE_MAX
+} SVGA3dFace;
+
+/*
+ * The order and the values should not be changed
+ */
+
+typedef enum {
+   SVGA3D_CMP_INVALID              = 0,
+   SVGA3D_CMP_NEVER                = 1,
+   SVGA3D_CMP_LESS                 = 2,
+   SVGA3D_CMP_EQUAL                = 3,
+   SVGA3D_CMP_LESSEQUAL            = 4,
+   SVGA3D_CMP_GREATER              = 5,
+   SVGA3D_CMP_NOTEQUAL             = 6,
+   SVGA3D_CMP_GREATEREQUAL         = 7,
+   SVGA3D_CMP_ALWAYS               = 8,
+   SVGA3D_CMP_MAX
+} SVGA3dCmpFunc;
+
+/*
+ * SVGA3D_FOGFUNC_* specifies the fog equation, or PER_VERTEX which allows
+ * the fog factor to be specified in the alpha component of the specular
+ * (a.k.a. secondary) vertex color.
+ */
+typedef enum {
+   SVGA3D_FOGFUNC_INVALID          = 0,
+   SVGA3D_FOGFUNC_EXP              = 1,
+   SVGA3D_FOGFUNC_EXP2             = 2,
+   SVGA3D_FOGFUNC_LINEAR           = 3,
+   SVGA3D_FOGFUNC_PER_VERTEX       = 4
+} SVGA3dFogFunction;
+
+/*
+ * SVGA3D_FOGTYPE_* specifies if fog factors are computed on a per-vertex
+ * or per-pixel basis.
+ */
+typedef enum {
+   SVGA3D_FOGTYPE_INVALID          = 0,
+   SVGA3D_FOGTYPE_VERTEX           = 1,
+   SVGA3D_FOGTYPE_PIXEL            = 2,
+   SVGA3D_FOGTYPE_MAX              = 3
+} SVGA3dFogType;
+
+/*
+ * SVGA3D_FOGBASE_* selects depth or range-based fog. Depth-based fog is
+ * computed using the eye Z value of each pixel (or vertex), whereas range-
+ * based fog is computed using the actual distance (range) to the eye.
+ */
+typedef enum {
+   SVGA3D_FOGBASE_INVALID          = 0,
+   SVGA3D_FOGBASE_DEPTHBASED       = 1,
+   SVGA3D_FOGBASE_RANGEBASED       = 2,
+   SVGA3D_FOGBASE_MAX              = 3
+} SVGA3dFogBase;
+
+typedef enum {
+   SVGA3D_STENCILOP_INVALID        = 0,
+   SVGA3D_STENCILOP_KEEP           = 1,
+   SVGA3D_STENCILOP_ZERO           = 2,
+   SVGA3D_STENCILOP_REPLACE        = 3,
+   SVGA3D_STENCILOP_INCRSAT        = 4,
+   SVGA3D_STENCILOP_DECRSAT        = 5,
+   SVGA3D_STENCILOP_INVERT         = 6,
+   SVGA3D_STENCILOP_INCR           = 7,
+   SVGA3D_STENCILOP_DECR           = 8,
+   SVGA3D_STENCILOP_MAX
+} SVGA3dStencilOp;
+
+typedef enum {
+   SVGA3D_CLIPPLANE_0              = (1 << 0),
+   SVGA3D_CLIPPLANE_1              = (1 << 1),
+   SVGA3D_CLIPPLANE_2              = (1 << 2),
+   SVGA3D_CLIPPLANE_3              = (1 << 3),
+   SVGA3D_CLIPPLANE_4              = (1 << 4),
+   SVGA3D_CLIPPLANE_5              = (1 << 5),
+} SVGA3dClipPlanes;
+
+typedef enum {
+   SVGA3D_CLEAR_COLOR              = 0x1,
+   SVGA3D_CLEAR_DEPTH              = 0x2,
+   SVGA3D_CLEAR_STENCIL            = 0x4
+} SVGA3dClearFlag;
+
+typedef enum {
+   SVGA3D_RT_DEPTH                 = 0,
+   SVGA3D_RT_STENCIL               = 1,
+   SVGA3D_RT_COLOR0                = 2,
+   SVGA3D_RT_COLOR1                = 3,
+   SVGA3D_RT_COLOR2                = 4,
+   SVGA3D_RT_COLOR3                = 5,
+   SVGA3D_RT_COLOR4                = 6,
+   SVGA3D_RT_COLOR5                = 7,
+   SVGA3D_RT_COLOR6                = 8,
+   SVGA3D_RT_COLOR7                = 9,
+   SVGA3D_RT_MAX,
+   SVGA3D_RT_INVALID               = ((uint32)-1),
+} SVGA3dRenderTargetType;
+
+#define SVGA3D_MAX_RT_COLOR (SVGA3D_RT_COLOR7 - SVGA3D_RT_COLOR0 + 1)
+
+typedef
+union {
+   struct {
+      uint32  red   : 1;
+      uint32  green : 1;
+      uint32  blue  : 1;
+      uint32  alpha : 1;
+   };
+   uint32 uintValue;
+} SVGA3dColorMask;
+
+typedef enum {
+   SVGA3D_VBLEND_DISABLE            = 0,
+   SVGA3D_VBLEND_1WEIGHT            = 1,
+   SVGA3D_VBLEND_2WEIGHT            = 2,
+   SVGA3D_VBLEND_3WEIGHT            = 3,
+} SVGA3dVertexBlendFlags;
+
+typedef enum {
+   SVGA3D_WRAPCOORD_0   = 1 << 0,
+   SVGA3D_WRAPCOORD_1   = 1 << 1,
+   SVGA3D_WRAPCOORD_2   = 1 << 2,
+   SVGA3D_WRAPCOORD_3   = 1 << 3,
+   SVGA3D_WRAPCOORD_ALL = 0xF,
+} SVGA3dWrapFlags;
+
+/*
+ * SVGA_3D_CMD_TEXTURESTATE Types.  All value types
+ * must fit in a uint32.
+ */
+
+typedef enum {
+   SVGA3D_TS_INVALID                    = 0,
+   SVGA3D_TS_BIND_TEXTURE               = 1,    /* SVGA3dSurfaceId */
+   SVGA3D_TS_COLOROP                    = 2,    /* SVGA3dTextureCombiner */
+   SVGA3D_TS_COLORARG1                  = 3,    /* SVGA3dTextureArgData */
+   SVGA3D_TS_COLORARG2                  = 4,    /* SVGA3dTextureArgData */
+   SVGA3D_TS_ALPHAOP                    = 5,    /* SVGA3dTextureCombiner */
+   SVGA3D_TS_ALPHAARG1                  = 6,    /* SVGA3dTextureArgData */
+   SVGA3D_TS_ALPHAARG2                  = 7,    /* SVGA3dTextureArgData */
+   SVGA3D_TS_ADDRESSU                   = 8,    /* SVGA3dTextureAddress */
+   SVGA3D_TS_ADDRESSV                   = 9,    /* SVGA3dTextureAddress */
+   SVGA3D_TS_MIPFILTER                  = 10,   /* SVGA3dTextureFilter */
+   SVGA3D_TS_MAGFILTER                  = 11,   /* SVGA3dTextureFilter */
+   SVGA3D_TS_MINFILTER                  = 12,   /* SVGA3dTextureFilter */
+   SVGA3D_TS_BORDERCOLOR                = 13,   /* SVGA3dColor */
+   SVGA3D_TS_TEXCOORDINDEX              = 14,   /* uint32 */
+   SVGA3D_TS_TEXTURETRANSFORMFLAGS      = 15,   /* SVGA3dTexTransformFlags */
+   SVGA3D_TS_TEXCOORDGEN                = 16,   /* SVGA3dTextureCoordGen */
+   SVGA3D_TS_BUMPENVMAT00               = 17,   /* float */
+   SVGA3D_TS_BUMPENVMAT01               = 18,   /* float */
+   SVGA3D_TS_BUMPENVMAT10               = 19,   /* float */
+   SVGA3D_TS_BUMPENVMAT11               = 20,   /* float */
+   SVGA3D_TS_TEXTURE_MIPMAP_LEVEL       = 21,   /* uint32 */
+   SVGA3D_TS_TEXTURE_LOD_BIAS           = 22,   /* float */
+   SVGA3D_TS_TEXTURE_ANISOTROPIC_LEVEL  = 23,   /* uint32 */
+   SVGA3D_TS_ADDRESSW                   = 24,   /* SVGA3dTextureAddress */
+
+
+   /*
+    * Sampler Gamma Level
+    *
+    * Sampler gamma effects the color of samples taken from the sampler.  A
+    * value of 1.0 will produce linear samples.  If the value is <= 0.0 the
+    * gamma value is ignored and a linear space is used.
+    */
+
+   SVGA3D_TS_GAMMA                      = 25,   /* float */
+   SVGA3D_TS_BUMPENVLSCALE              = 26,   /* float */
+   SVGA3D_TS_BUMPENVLOFFSET             = 27,   /* float */
+   SVGA3D_TS_COLORARG0                  = 28,   /* SVGA3dTextureArgData */
+   SVGA3D_TS_ALPHAARG0                  = 29,   /* SVGA3dTextureArgData */
+   SVGA3D_TS_MAX
+} SVGA3dTextureStateName;
+
+typedef enum {
+   SVGA3D_TC_INVALID                   = 0,
+   SVGA3D_TC_DISABLE                   = 1,
+   SVGA3D_TC_SELECTARG1                = 2,
+   SVGA3D_TC_SELECTARG2                = 3,
+   SVGA3D_TC_MODULATE                  = 4,
+   SVGA3D_TC_ADD                       = 5,
+   SVGA3D_TC_ADDSIGNED                 = 6,
+   SVGA3D_TC_SUBTRACT                  = 7,
+   SVGA3D_TC_BLENDTEXTUREALPHA         = 8,
+   SVGA3D_TC_BLENDDIFFUSEALPHA         = 9,
+   SVGA3D_TC_BLENDCURRENTALPHA         = 10,
+   SVGA3D_TC_BLENDFACTORALPHA          = 11,
+   SVGA3D_TC_MODULATE2X                = 12,
+   SVGA3D_TC_MODULATE4X                = 13,
+   SVGA3D_TC_DSDT                      = 14,
+   SVGA3D_TC_DOTPRODUCT3               = 15,
+   SVGA3D_TC_BLENDTEXTUREALPHAPM       = 16,
+   SVGA3D_TC_ADDSIGNED2X               = 17,
+   SVGA3D_TC_ADDSMOOTH                 = 18,
+   SVGA3D_TC_PREMODULATE               = 19,
+   SVGA3D_TC_MODULATEALPHA_ADDCOLOR    = 20,
+   SVGA3D_TC_MODULATECOLOR_ADDALPHA    = 21,
+   SVGA3D_TC_MODULATEINVALPHA_ADDCOLOR = 22,
+   SVGA3D_TC_MODULATEINVCOLOR_ADDALPHA = 23,
+   SVGA3D_TC_BUMPENVMAPLUMINANCE       = 24,
+   SVGA3D_TC_MULTIPLYADD               = 25,
+   SVGA3D_TC_LERP                      = 26,
+   SVGA3D_TC_MAX
+} SVGA3dTextureCombiner;
+
+#define SVGA3D_TC_CAP_BIT(svga3d_tc_op) (svga3d_tc_op ? (1 << (svga3d_tc_op - 1)) : 0)
+
+typedef enum {
+   SVGA3D_TEX_ADDRESS_INVALID    = 0,
+   SVGA3D_TEX_ADDRESS_WRAP       = 1,
+   SVGA3D_TEX_ADDRESS_MIRROR     = 2,
+   SVGA3D_TEX_ADDRESS_CLAMP      = 3,
+   SVGA3D_TEX_ADDRESS_BORDER     = 4,
+   SVGA3D_TEX_ADDRESS_MIRRORONCE = 5,
+   SVGA3D_TEX_ADDRESS_EDGE       = 6,
+   SVGA3D_TEX_ADDRESS_MAX
+} SVGA3dTextureAddress;
+
+/*
+ * SVGA3D_TEX_FILTER_NONE as the minification filter means mipmapping is
+ * disabled, and the rasterizer should use the magnification filter instead.
+ */
+typedef enum {
+   SVGA3D_TEX_FILTER_NONE           = 0,
+   SVGA3D_TEX_FILTER_NEAREST        = 1,
+   SVGA3D_TEX_FILTER_LINEAR         = 2,
+   SVGA3D_TEX_FILTER_ANISOTROPIC    = 3,
+   SVGA3D_TEX_FILTER_FLATCUBIC      = 4, // Deprecated, not implemented
+   SVGA3D_TEX_FILTER_GAUSSIANCUBIC  = 5, // Deprecated, not implemented
+   SVGA3D_TEX_FILTER_PYRAMIDALQUAD  = 6, // Not currently implemented
+   SVGA3D_TEX_FILTER_GAUSSIANQUAD   = 7, // Not currently implemented
+   SVGA3D_TEX_FILTER_MAX
+} SVGA3dTextureFilter;
+
+typedef enum {
+   SVGA3D_TEX_TRANSFORM_OFF    = 0,
+   SVGA3D_TEX_TRANSFORM_S      = (1 << 0),
+   SVGA3D_TEX_TRANSFORM_T      = (1 << 1),
+   SVGA3D_TEX_TRANSFORM_R      = (1 << 2),
+   SVGA3D_TEX_TRANSFORM_Q      = (1 << 3),
+   SVGA3D_TEX_PROJECTED        = (1 << 15),
+} SVGA3dTexTransformFlags;
+
+typedef enum {
+   SVGA3D_TEXCOORD_GEN_OFF              = 0,
+   SVGA3D_TEXCOORD_GEN_EYE_POSITION     = 1,
+   SVGA3D_TEXCOORD_GEN_EYE_NORMAL       = 2,
+   SVGA3D_TEXCOORD_GEN_REFLECTIONVECTOR = 3,
+   SVGA3D_TEXCOORD_GEN_SPHERE           = 4,
+   SVGA3D_TEXCOORD_GEN_MAX
+} SVGA3dTextureCoordGen;
+
+/*
+ * Texture argument constants for texture combiner
+ */
+typedef enum {
+   SVGA3D_TA_INVALID    = 0,
+   SVGA3D_TA_CONSTANT   = 1,
+   SVGA3D_TA_PREVIOUS   = 2,
+   SVGA3D_TA_DIFFUSE    = 3,
+   SVGA3D_TA_TEXTURE    = 4,
+   SVGA3D_TA_SPECULAR   = 5,
+   SVGA3D_TA_MAX
+} SVGA3dTextureArgData;
+
+#define SVGA3D_TM_MASK_LEN 4
+
+/* Modifiers for texture argument constants defined above. */
+typedef enum {
+   SVGA3D_TM_NONE       = 0,
+   SVGA3D_TM_ALPHA      = (1 << SVGA3D_TM_MASK_LEN),
+   SVGA3D_TM_ONE_MINUS  = (2 << SVGA3D_TM_MASK_LEN),
+} SVGA3dTextureArgModifier;
+
+#define SVGA3D_INVALID_ID         ((uint32)-1)
+#define SVGA3D_MAX_CLIP_PLANES    6
+
+/*
+ * This is the limit to the number of fixed-function texture
+ * transforms and texture coordinates we can support. It does *not*
+ * correspond to the number of texture image units (samplers) we
+ * support!
+ */
+#define SVGA3D_MAX_TEXTURE_COORDS 8
+
+/*
+ * Vertex declarations
+ *
+ * Notes:
+ *
+ * SVGA3D_DECLUSAGE_POSITIONT is for pre-transformed vertices. If you
+ * draw with any POSITIONT vertex arrays, the programmable vertex
+ * pipeline will be implicitly disabled. Drawing will take place as if
+ * no vertex shader was bound.
+ */
+
+typedef enum {
+   SVGA3D_DECLUSAGE_POSITION     = 0,
+   SVGA3D_DECLUSAGE_BLENDWEIGHT,       //  1
+   SVGA3D_DECLUSAGE_BLENDINDICES,      //  2
+   SVGA3D_DECLUSAGE_NORMAL,            //  3
+   SVGA3D_DECLUSAGE_PSIZE,             //  4
+   SVGA3D_DECLUSAGE_TEXCOORD,          //  5
+   SVGA3D_DECLUSAGE_TANGENT,           //  6
+   SVGA3D_DECLUSAGE_BINORMAL,          //  7
+   SVGA3D_DECLUSAGE_TESSFACTOR,        //  8
+   SVGA3D_DECLUSAGE_POSITIONT,         //  9
+   SVGA3D_DECLUSAGE_COLOR,             // 10
+   SVGA3D_DECLUSAGE_FOG,               // 11
+   SVGA3D_DECLUSAGE_DEPTH,             // 12
+   SVGA3D_DECLUSAGE_SAMPLE,            // 13
+   SVGA3D_DECLUSAGE_MAX
+} SVGA3dDeclUsage;
+
+typedef enum {
+   SVGA3D_DECLMETHOD_DEFAULT     = 0,
+   SVGA3D_DECLMETHOD_PARTIALU,
+   SVGA3D_DECLMETHOD_PARTIALV,
+   SVGA3D_DECLMETHOD_CROSSUV,          // Normal
+   SVGA3D_DECLMETHOD_UV,
+   SVGA3D_DECLMETHOD_LOOKUP,           // Lookup a displacement map
+   SVGA3D_DECLMETHOD_LOOKUPPRESAMPLED, // Lookup a pre-sampled displacement map
+} SVGA3dDeclMethod;
+
+typedef enum {
+   SVGA3D_DECLTYPE_FLOAT1        =  0,
+   SVGA3D_DECLTYPE_FLOAT2        =  1,
+   SVGA3D_DECLTYPE_FLOAT3        =  2,
+   SVGA3D_DECLTYPE_FLOAT4        =  3,
+   SVGA3D_DECLTYPE_D3DCOLOR      =  4,
+   SVGA3D_DECLTYPE_UBYTE4        =  5,
+   SVGA3D_DECLTYPE_SHORT2        =  6,
+   SVGA3D_DECLTYPE_SHORT4        =  7,
+   SVGA3D_DECLTYPE_UBYTE4N       =  8,
+   SVGA3D_DECLTYPE_SHORT2N       =  9,
+   SVGA3D_DECLTYPE_SHORT4N       = 10,
+   SVGA3D_DECLTYPE_USHORT2N      = 11,
+   SVGA3D_DECLTYPE_USHORT4N      = 12,
+   SVGA3D_DECLTYPE_UDEC3         = 13,
+   SVGA3D_DECLTYPE_DEC3N         = 14,
+   SVGA3D_DECLTYPE_FLOAT16_2     = 15,
+   SVGA3D_DECLTYPE_FLOAT16_4     = 16,
+   SVGA3D_DECLTYPE_MAX,
+} SVGA3dDeclType;
+
+/*
+ * This structure is used for the divisor for geometry instancing;
+ * it's a direct translation of the Direct3D equivalent.
+ */
+typedef union {
+   struct {
+      /*
+       * For index data, this number represents the number of instances to draw.
+       * For instance data, this number represents the number of
+       * instances/vertex in this stream
+       */
+      uint32 count : 30;
+
+      /*
+       * This is 1 if this is supposed to be the data that is repeated for
+       * every instance.
+       */
+      uint32 indexedData : 1;
+
+      /*
+       * This is 1 if this is supposed to be the per-instance data.
+       */
+      uint32 instanceData : 1;
+   };
+
+   uint32 value;
+} SVGA3dVertexDivisor;
+
+typedef enum {
+   SVGA3D_PRIMITIVE_INVALID                     = 0,
+   SVGA3D_PRIMITIVE_TRIANGLELIST                = 1,
+   SVGA3D_PRIMITIVE_POINTLIST                   = 2,
+   SVGA3D_PRIMITIVE_LINELIST                    = 3,
+   SVGA3D_PRIMITIVE_LINESTRIP                   = 4,
+   SVGA3D_PRIMITIVE_TRIANGLESTRIP               = 5,
+   SVGA3D_PRIMITIVE_TRIANGLEFAN                 = 6,
+   SVGA3D_PRIMITIVE_MAX
+} SVGA3dPrimitiveType;
+
+typedef enum {
+   SVGA3D_COORDINATE_INVALID                   = 0,
+   SVGA3D_COORDINATE_LEFTHANDED                = 1,
+   SVGA3D_COORDINATE_RIGHTHANDED               = 2,
+   SVGA3D_COORDINATE_MAX
+} SVGA3dCoordinateType;
+
+typedef enum {
+   SVGA3D_TRANSFORM_INVALID                     = 0,
+   SVGA3D_TRANSFORM_WORLD                       = 1,
+   SVGA3D_TRANSFORM_VIEW                        = 2,
+   SVGA3D_TRANSFORM_PROJECTION                  = 3,
+   SVGA3D_TRANSFORM_TEXTURE0                    = 4,
+   SVGA3D_TRANSFORM_TEXTURE1                    = 5,
+   SVGA3D_TRANSFORM_TEXTURE2                    = 6,
+   SVGA3D_TRANSFORM_TEXTURE3                    = 7,
+   SVGA3D_TRANSFORM_TEXTURE4                    = 8,
+   SVGA3D_TRANSFORM_TEXTURE5                    = 9,
+   SVGA3D_TRANSFORM_TEXTURE6                    = 10,
+   SVGA3D_TRANSFORM_TEXTURE7                    = 11,
+   SVGA3D_TRANSFORM_WORLD1                      = 12,
+   SVGA3D_TRANSFORM_WORLD2                      = 13,
+   SVGA3D_TRANSFORM_WORLD3                      = 14,
+   SVGA3D_TRANSFORM_MAX
+} SVGA3dTransformType;
+
+typedef enum {
+   SVGA3D_LIGHTTYPE_INVALID                     = 0,
+   SVGA3D_LIGHTTYPE_POINT                       = 1,
+   SVGA3D_LIGHTTYPE_SPOT1                       = 2, /* 1-cone, in degrees */
+   SVGA3D_LIGHTTYPE_SPOT2                       = 3, /* 2-cone, in radians */
+   SVGA3D_LIGHTTYPE_DIRECTIONAL                 = 4,
+   SVGA3D_LIGHTTYPE_MAX
+} SVGA3dLightType;
+
+typedef enum {
+   SVGA3D_CUBEFACE_POSX                         = 0,
+   SVGA3D_CUBEFACE_NEGX                         = 1,
+   SVGA3D_CUBEFACE_POSY                         = 2,
+   SVGA3D_CUBEFACE_NEGY                         = 3,
+   SVGA3D_CUBEFACE_POSZ                         = 4,
+   SVGA3D_CUBEFACE_NEGZ                         = 5,
+} SVGA3dCubeFace;
+
+typedef enum {
+   SVGA3D_SHADERTYPE_COMPILED_DX8               = 0,
+   SVGA3D_SHADERTYPE_VS                         = 1,
+   SVGA3D_SHADERTYPE_PS                         = 2,
+   SVGA3D_SHADERTYPE_MAX
+} SVGA3dShaderType;
+
+typedef enum {
+   SVGA3D_CONST_TYPE_FLOAT                      = 0,
+   SVGA3D_CONST_TYPE_INT                        = 1,
+   SVGA3D_CONST_TYPE_BOOL                       = 2,
+} SVGA3dShaderConstType;
+
+#define SVGA3D_MAX_SURFACE_FACES                6
+
+typedef enum {
+   SVGA3D_STRETCH_BLT_POINT                     = 0,
+   SVGA3D_STRETCH_BLT_LINEAR                    = 1,
+   SVGA3D_STRETCH_BLT_MAX
+} SVGA3dStretchBltMode;
+
+typedef enum {
+   SVGA3D_QUERYTYPE_OCCLUSION                   = 0,
+   SVGA3D_QUERYTYPE_MAX
+} SVGA3dQueryType;
+
+typedef enum {
+   SVGA3D_QUERYSTATE_PENDING     = 0,      /* Waiting on the host (set by guest) */
+   SVGA3D_QUERYSTATE_SUCCEEDED   = 1,      /* Completed successfully (set by host) */
+   SVGA3D_QUERYSTATE_FAILED      = 2,      /* Completed unsuccessfully (set by host) */
+   SVGA3D_QUERYSTATE_NEW         = 3,      /* Never submitted (For guest use only) */
+} SVGA3dQueryState;
+
+typedef enum {
+   SVGA3D_WRITE_HOST_VRAM        = 1,
+   SVGA3D_READ_HOST_VRAM         = 2,
+} SVGA3dTransferType;
+
+/*
+ * The maximum number vertex arrays we're guaranteed to support in
+ * SVGA_3D_CMD_DRAWPRIMITIVES.
+ */
+#define SVGA3D_MAX_VERTEX_ARRAYS   32
+
+/*
+ * Identifiers for commands in the command FIFO.
+ *
+ * IDs between 1000 and 1039 (inclusive) were used by obsolete versions of
+ * the SVGA3D protocol and remain reserved; they should not be used in the
+ * future.
+ *
+ * IDs between 1040 and 1999 (inclusive) are available for use by the
+ * current SVGA3D protocol.
+ *
+ * FIFO clients other than SVGA3D should stay below 1000, or at 2000
+ * and up.
+ */
+
+#define SVGA_3D_CMD_LEGACY_BASE            1000
+#define SVGA_3D_CMD_BASE                   1040
+
+#define SVGA_3D_CMD_SURFACE_DEFINE         SVGA_3D_CMD_BASE + 0
+#define SVGA_3D_CMD_SURFACE_DESTROY        SVGA_3D_CMD_BASE + 1
+#define SVGA_3D_CMD_SURFACE_COPY           SVGA_3D_CMD_BASE + 2
+#define SVGA_3D_CMD_SURFACE_STRETCHBLT     SVGA_3D_CMD_BASE + 3
+#define SVGA_3D_CMD_SURFACE_DMA            SVGA_3D_CMD_BASE + 4
+#define SVGA_3D_CMD_CONTEXT_DEFINE         SVGA_3D_CMD_BASE + 5
+#define SVGA_3D_CMD_CONTEXT_DESTROY        SVGA_3D_CMD_BASE + 6
+#define SVGA_3D_CMD_SETTRANSFORM           SVGA_3D_CMD_BASE + 7
+#define SVGA_3D_CMD_SETZRANGE              SVGA_3D_CMD_BASE + 8
+#define SVGA_3D_CMD_SETRENDERSTATE         SVGA_3D_CMD_BASE + 9
+#define SVGA_3D_CMD_SETRENDERTARGET        SVGA_3D_CMD_BASE + 10
+#define SVGA_3D_CMD_SETTEXTURESTATE        SVGA_3D_CMD_BASE + 11
+#define SVGA_3D_CMD_SETMATERIAL            SVGA_3D_CMD_BASE + 12
+#define SVGA_3D_CMD_SETLIGHTDATA           SVGA_3D_CMD_BASE + 13
+#define SVGA_3D_CMD_SETLIGHTENABLED        SVGA_3D_CMD_BASE + 14
+#define SVGA_3D_CMD_SETVIEWPORT            SVGA_3D_CMD_BASE + 15
+#define SVGA_3D_CMD_SETCLIPPLANE           SVGA_3D_CMD_BASE + 16
+#define SVGA_3D_CMD_CLEAR                  SVGA_3D_CMD_BASE + 17
+#define SVGA_3D_CMD_PRESENT                SVGA_3D_CMD_BASE + 18    // Deprecated
+#define SVGA_3D_CMD_SHADER_DEFINE          SVGA_3D_CMD_BASE + 19
+#define SVGA_3D_CMD_SHADER_DESTROY         SVGA_3D_CMD_BASE + 20
+#define SVGA_3D_CMD_SET_SHADER             SVGA_3D_CMD_BASE + 21
+#define SVGA_3D_CMD_SET_SHADER_CONST       SVGA_3D_CMD_BASE + 22
+#define SVGA_3D_CMD_DRAW_PRIMITIVES        SVGA_3D_CMD_BASE + 23
+#define SVGA_3D_CMD_SETSCISSORRECT         SVGA_3D_CMD_BASE + 24
+#define SVGA_3D_CMD_BEGIN_QUERY            SVGA_3D_CMD_BASE + 25
+#define SVGA_3D_CMD_END_QUERY              SVGA_3D_CMD_BASE + 26
+#define SVGA_3D_CMD_WAIT_FOR_QUERY         SVGA_3D_CMD_BASE + 27
+#define SVGA_3D_CMD_PRESENT_READBACK       SVGA_3D_CMD_BASE + 28    // Deprecated
+#define SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN SVGA_3D_CMD_BASE + 29
+#define SVGA_3D_CMD_MAX                    SVGA_3D_CMD_BASE + 30
+
+#define SVGA_3D_CMD_FUTURE_MAX             2000
+
+/*
+ * Common substructures used in multiple FIFO commands:
+ */
+
+typedef struct {
+   union {
+      struct {
+         uint16  function;       // SVGA3dFogFunction
+         uint8   type;           // SVGA3dFogType
+         uint8   base;           // SVGA3dFogBase
+      };
+      uint32     uintValue;
+   };
+} SVGA3dFogMode;
+
+/*
+ * Uniquely identify one image (a 1D/2D/3D array) from a surface. This
+ * is a surface ID as well as face/mipmap indices.
+ */
+
+typedef
+struct SVGA3dSurfaceImageId {
+   uint32               sid;
+   uint32               face;
+   uint32               mipmap;
+} SVGA3dSurfaceImageId;
+
+typedef
+struct SVGA3dGuestImage {
+   SVGAGuestPtr         ptr;
+
+   /*
+    * A note on interpretation of pitch: This value of pitch is the
+    * number of bytes between vertically adjacent image
+    * blocks. Normally this is the number of bytes between the first
+    * pixel of two adjacent scanlines. With compressed textures,
+    * however, this may represent the number of bytes between
+    * compression blocks rather than between rows of pixels.
+    *
+    * XXX: Compressed textures currently must be tightly packed in guest memory.
+    *
+    * If the image is 1-dimensional, pitch is ignored.
+    *
+    * If 'pitch' is zero, the SVGA3D device calculates a pitch value
+    * assuming each row of blocks is tightly packed.
+    */
+   uint32 pitch;
+} SVGA3dGuestImage;
+
+
+/*
+ * FIFO command format definitions:
+ */
+
+/*
+ * The data size header following cmdNum for every 3d command
+ */
+typedef
+struct {
+   uint32               id;
+   uint32               size;
+} SVGA3dCmdHeader;
+
+/*
+ * A surface is a hierarchy of host VRAM surfaces: 1D, 2D, or 3D, with
+ * optional mipmaps and cube faces.
+ */
+
+typedef
+struct {
+   uint32               width;
+   uint32               height;
+   uint32               depth;
+} SVGA3dSize;
+
+typedef enum {
+   SVGA3D_SURFACE_CUBEMAP              = (1 << 0),
+   SVGA3D_SURFACE_HINT_STATIC          = (1 << 1),
+   SVGA3D_SURFACE_HINT_DYNAMIC         = (1 << 2),
+   SVGA3D_SURFACE_HINT_INDEXBUFFER     = (1 << 3),
+   SVGA3D_SURFACE_HINT_VERTEXBUFFER    = (1 << 4),
+   SVGA3D_SURFACE_HINT_TEXTURE         = (1 << 5),
+   SVGA3D_SURFACE_HINT_RENDERTARGET    = (1 << 6),
+   SVGA3D_SURFACE_HINT_DEPTHSTENCIL    = (1 << 7),
+   SVGA3D_SURFACE_HINT_WRITEONLY       = (1 << 8),
+} SVGA3dSurfaceFlags;
+
+typedef
+struct {
+   uint32               numMipLevels;
+} SVGA3dSurfaceFace;
+
+typedef
+struct {
+   uint32                      sid;
+   SVGA3dSurfaceFlags          surfaceFlags;
+   SVGA3dSurfaceFormat         format;
+   SVGA3dSurfaceFace           face[SVGA3D_MAX_SURFACE_FACES];
+   /*
+    * Followed by an SVGA3dSize structure for each mip level in each face.
+    *
+    * A note on surface sizes: Sizes are always specified in pixels,
+    * even if the true surface size is not a multiple of the minimum
+    * block size of the surface's format. For example, a 3x3x1 DXT1
+    * compressed texture would actually be stored as a 4x4x1 image in
+    * memory.
+    */
+} SVGA3dCmdDefineSurface;       /* SVGA_3D_CMD_SURFACE_DEFINE */
+
+typedef
+struct {
+   uint32               sid;
+} SVGA3dCmdDestroySurface;      /* SVGA_3D_CMD_SURFACE_DESTROY */
+
+typedef
+struct {
+   uint32               cid;
+} SVGA3dCmdDefineContext;       /* SVGA_3D_CMD_CONTEXT_DEFINE */
+
+typedef
+struct {
+   uint32               cid;
+} SVGA3dCmdDestroyContext;      /* SVGA_3D_CMD_CONTEXT_DESTROY */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dClearFlag      clearFlag;
+   uint32               color;
+   float                depth;
+   uint32               stencil;
+   /* Followed by variable number of SVGA3dRect structures */
+} SVGA3dCmdClear;               /* SVGA_3D_CMD_CLEAR */
+
+typedef
+struct SVGA3dCopyRect {
+   uint32               x;
+   uint32               y;
+   uint32               w;
+   uint32               h;
+   uint32               srcx;
+   uint32               srcy;
+} SVGA3dCopyRect;
+
+typedef
+struct SVGA3dCopyBox {
+   uint32               x;
+   uint32               y;
+   uint32               z;
+   uint32               w;
+   uint32               h;
+   uint32               d;
+   uint32               srcx;
+   uint32               srcy;
+   uint32               srcz;
+} SVGA3dCopyBox;
+
+typedef
+struct {
+   uint32               x;
+   uint32               y;
+   uint32               w;
+   uint32               h;
+} SVGA3dRect;
+
+typedef
+struct {
+   uint32               x;
+   uint32               y;
+   uint32               z;
+   uint32               w;
+   uint32               h;
+   uint32               d;
+} SVGA3dBox;
+
+typedef
+struct {
+   uint32               x;
+   uint32               y;
+   uint32               z;
+} SVGA3dPoint;
+
+typedef
+struct {
+   SVGA3dLightType      type;
+   SVGA3dBool           inWorldSpace;
+   float                diffuse[4];
+   float                specular[4];
+   float                ambient[4];
+   float                position[4];
+   float                direction[4];
+   float                range;
+   float                falloff;
+   float                attenuation0;
+   float                attenuation1;
+   float                attenuation2;
+   float                theta;
+   float                phi;
+} SVGA3dLightData;
+
+typedef
+struct {
+   uint32               sid;
+   /* Followed by variable number of SVGA3dCopyRect structures */
+} SVGA3dCmdPresent;             /* SVGA_3D_CMD_PRESENT */
+
+typedef
+struct {
+   SVGA3dRenderStateName   state;
+   union {
+      uint32               uintValue;
+      float                floatValue;
+   };
+} SVGA3dRenderState;
+
+typedef
+struct {
+   uint32               cid;
+   /* Followed by variable number of SVGA3dRenderState structures */
+} SVGA3dCmdSetRenderState;      /* SVGA_3D_CMD_SETRENDERSTATE */
+
+typedef
+struct {
+   uint32                 cid;
+   SVGA3dRenderTargetType type;
+   SVGA3dSurfaceImageId   target;
+} SVGA3dCmdSetRenderTarget;     /* SVGA_3D_CMD_SETRENDERTARGET */
+
+typedef
+struct {
+   SVGA3dSurfaceImageId  src;
+   SVGA3dSurfaceImageId  dest;
+   /* Followed by variable number of SVGA3dCopyBox structures */
+} SVGA3dCmdSurfaceCopy;               /* SVGA_3D_CMD_SURFACE_COPY */
+
+typedef
+struct {
+   SVGA3dSurfaceImageId  src;
+   SVGA3dSurfaceImageId  dest;
+   SVGA3dBox             boxSrc;
+   SVGA3dBox             boxDest;
+   SVGA3dStretchBltMode  mode;
+} SVGA3dCmdSurfaceStretchBlt;         /* SVGA_3D_CMD_SURFACE_STRETCHBLT */
+
+typedef
+struct {
+   /*
+    * If the discard flag is present in a surface DMA operation, the host may
+    * discard the contents of the current mipmap level and face of the target
+    * surface before applying the surface DMA contents.
+    */
+   uint32 discard : 1;
+
+   /*
+    * If the unsynchronized flag is present, the host may perform this upload
+    * without syncing to pending reads on this surface.
+    */
+   uint32 unsynchronized : 1;
+
+   /*
+    * Guests *MUST* set the reserved bits to 0 before submitting the command
+    * suffix as future flags may occupy these bits.
+    */
+   uint32 reserved : 30;
+} SVGA3dSurfaceDMAFlags;
+
+typedef
+struct {
+   SVGA3dGuestImage      guest;
+   SVGA3dSurfaceImageId  host;
+   SVGA3dTransferType    transfer;
+   /*
+    * Followed by variable number of SVGA3dCopyBox structures. For consistency
+    * in all clipping logic and coordinate translation, we define the
+    * "source" in each copyBox as the guest image and the
+    * "destination" as the host image, regardless of transfer
+    * direction.
+    *
+    * For efficiency, the SVGA3D device is free to copy more data than
+    * specified. For example, it may round copy boxes outwards such
+    * that they lie on particular alignment boundaries.
+    */
+} SVGA3dCmdSurfaceDMA;                /* SVGA_3D_CMD_SURFACE_DMA */
+
+/*
+ * SVGA3dCmdSurfaceDMASuffix --
+ *
+ *    This is a command suffix that will appear after a SurfaceDMA command in
+ *    the FIFO.  It contains some extra information that hosts may use to
+ *    optimize performance or protect the guest.  This suffix exists to preserve
+ *    backwards compatibility while also allowing for new functionality to be
+ *    implemented.
+ */
+
+typedef
+struct {
+   uint32 suffixSize;
+
+   /*
+    * The maximum offset is used to determine the maximum offset from the
+    * guestPtr base address that will be accessed or written to during this
+    * surfaceDMA.  If the suffix is supported, the host will respect this
+    * boundary while performing surface DMAs.
+    *
+    * Defaults to MAX_UINT32
+    */
+   uint32 maximumOffset;
+
+   /*
+    * A set of flags that describes optimizations that the host may perform
+    * while performing this surface DMA operation.  The guest should never rely
+    * on behaviour that is different when these flags are set for correctness.
+    *
+    * Defaults to 0
+    */
+   SVGA3dSurfaceDMAFlags flags;
+} SVGA3dCmdSurfaceDMASuffix;
+
+/*
+ * SVGA_3D_CMD_DRAW_PRIMITIVES --
+ *
+ *   This command is the SVGA3D device's generic drawing entry point.
+ *   It can draw multiple ranges of primitives, optionally using an
+ *   index buffer, using an arbitrary collection of vertex buffers.
+ *
+ *   Each SVGA3dVertexDecl defines a distinct vertex array to bind
+ *   during this draw call. The declarations specify which surface
+ *   the vertex data lives in, what that vertex data is used for,
+ *   and how to interpret it.
+ *
+ *   Each SVGA3dPrimitiveRange defines a collection of primitives
+ *   to render using the same vertex arrays. An index buffer is
+ *   optional.
+ */
+
+typedef
+struct {
+   /*
+    * A range hint is an optional specification for the range of indices
+    * in an SVGA3dArray that will be used. If 'last' is zero, it is assumed
+    * that the entire array will be used.
+    *
+    * These are only hints. The SVGA3D device may use them for
+    * performance optimization if possible, but it's also allowed to
+    * ignore these values.
+    */
+   uint32               first;
+   uint32               last;
+} SVGA3dArrayRangeHint;
+
+typedef
+struct {
+   /*
+    * Define the origin and shape of a vertex or index array. Both
+    * 'offset' and 'stride' are in bytes. The provided surface will be
+    * reinterpreted as a flat array of bytes in the same format used
+    * by surface DMA operations. To avoid unnecessary conversions, the
+    * surface should be created with the SVGA3D_BUFFER format.
+    *
+    * Index 0 in the array starts 'offset' bytes into the surface.
+    * Index 1 begins at byte 'offset + stride', etc. Array indices may
+    * not be negative.
+    */
+   uint32               surfaceId;
+   uint32               offset;
+   uint32               stride;
+} SVGA3dArray;
+
+typedef
+struct {
+   /*
+    * Describe a vertex array's data type, and define how it is to be
+    * used by the fixed function pipeline or the vertex shader. It
+    * isn't useful to have two VertexDecls with the same
+    * VertexArrayIdentity in one draw call.
+    */
+   SVGA3dDeclType       type;
+   SVGA3dDeclMethod     method;
+   SVGA3dDeclUsage      usage;
+   uint32               usageIndex;
+} SVGA3dVertexArrayIdentity;
+
+typedef
+struct {
+   SVGA3dVertexArrayIdentity  identity;
+   SVGA3dArray                array;
+   SVGA3dArrayRangeHint       rangeHint;
+} SVGA3dVertexDecl;
+
+typedef
+struct {
+   /*
+    * Define a group of primitives to render, from sequential indices.
+    *
+    * The value of 'primitiveType' and 'primitiveCount' imply the
+    * total number of vertices that will be rendered.
+    */
+   SVGA3dPrimitiveType  primType;
+   uint32               primitiveCount;
+
+   /*
+    * Optional index buffer. If indexArray.surfaceId is
+    * SVGA3D_INVALID_ID, we render without an index buffer. Rendering
+    * without an index buffer is identical to rendering with an index
+    * buffer containing the sequence [0, 1, 2, 3, ...].
+    *
+    * If an index buffer is in use, indexWidth specifies the width in
+    * bytes of each index value. It must be less than or equal to
+    * indexArray.stride.
+    *
+    * (Currently, the SVGA3D device requires index buffers to be tightly
+    * packed. In other words, indexWidth == indexArray.stride)
+    */
+   SVGA3dArray          indexArray;
+   uint32               indexWidth;
+
+   /*
+    * Optional index bias. This number is added to all indices from
+    * indexArray before they are used as vertex array indices. This
+    * can be used in multiple ways:
+    *
+    *  - When not using an indexArray, this bias can be used to
+    *    specify where in the vertex arrays to begin rendering.
+    *
+    *  - A positive number here is equivalent to increasing the
+    *    offset in each vertex array.
+    *
+    *  - A negative number can be used to render using a small
+    *    vertex array and an index buffer that contains large
+    *    values. This may be used by some applications that
+    *    crop a vertex buffer without modifying their index
+    *    buffer.
+    *
+    * Note that rendering with a negative bias value may be slower and
+    * use more memory than rendering with a positive or zero bias.
+    */
+   int32                indexBias;
+} SVGA3dPrimitiveRange;
+
+typedef
+struct {
+   uint32               cid;
+   uint32               numVertexDecls;
+   uint32               numRanges;
+
+   /*
+    * There are two variable size arrays after the
+    * SVGA3dCmdDrawPrimitives structure. In order,
+    * they are:
+    *
+    * 1. SVGA3dVertexDecl, quantity 'numVertexDecls'
+    * 2. SVGA3dPrimitiveRange, quantity 'numRanges'
+    * 3. Optionally, SVGA3dVertexDivisor, quantity 'numVertexDecls' (contains
+    *    the frequency divisor for this the corresponding vertex decl)
+    */
+} SVGA3dCmdDrawPrimitives;      /* SVGA_3D_CMD_DRAWPRIMITIVES */
+
+typedef
+struct {
+   uint32                   stage;
+   SVGA3dTextureStateName   name;
+   union {
+      uint32                value;
+      float                 floatValue;
+   };
+} SVGA3dTextureState;
+
+typedef
+struct {
+   uint32               cid;
+   /* Followed by variable number of SVGA3dTextureState structures */
+} SVGA3dCmdSetTextureState;      /* SVGA_3D_CMD_SETTEXTURESTATE */
+
+typedef
+struct {
+   uint32                   cid;
+   SVGA3dTransformType      type;
+   float                    matrix[16];
+} SVGA3dCmdSetTransform;          /* SVGA_3D_CMD_SETTRANSFORM */
+
+typedef
+struct {
+   float                min;
+   float                max;
+} SVGA3dZRange;
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dZRange         zRange;
+} SVGA3dCmdSetZRange;             /* SVGA_3D_CMD_SETZRANGE */
+
+typedef
+struct {
+   float                diffuse[4];
+   float                ambient[4];
+   float                specular[4];
+   float                emissive[4];
+   float                shininess;
+} SVGA3dMaterial;
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dFace           face;
+   SVGA3dMaterial       material;
+} SVGA3dCmdSetMaterial;           /* SVGA_3D_CMD_SETMATERIAL */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               index;
+   SVGA3dLightData      data;
+} SVGA3dCmdSetLightData;           /* SVGA_3D_CMD_SETLIGHTDATA */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               index;
+   uint32               enabled;
+} SVGA3dCmdSetLightEnabled;      /* SVGA_3D_CMD_SETLIGHTENABLED */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dRect           rect;
+} SVGA3dCmdSetViewport;           /* SVGA_3D_CMD_SETVIEWPORT */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dRect           rect;
+} SVGA3dCmdSetScissorRect;         /* SVGA_3D_CMD_SETSCISSORRECT */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               index;
+   float                plane[4];
+} SVGA3dCmdSetClipPlane;           /* SVGA_3D_CMD_SETCLIPPLANE */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               shid;
+   SVGA3dShaderType     type;
+   /* Followed by variable number of DWORDs for shader bycode */
+} SVGA3dCmdDefineShader;           /* SVGA_3D_CMD_SHADER_DEFINE */
+
+typedef
+struct {
+   uint32               cid;
+   uint32               shid;
+   SVGA3dShaderType     type;
+} SVGA3dCmdDestroyShader;         /* SVGA_3D_CMD_SHADER_DESTROY */
+
+typedef
+struct {
+   uint32                  cid;
+   uint32                  reg;     /* register number */
+   SVGA3dShaderType        type;
+   SVGA3dShaderConstType   ctype;
+   uint32                  values[4];
+} SVGA3dCmdSetShaderConst;        /* SVGA_3D_CMD_SET_SHADER_CONST */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dShaderType     type;
+   uint32               shid;
+} SVGA3dCmdSetShader;             /* SVGA_3D_CMD_SET_SHADER */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dQueryType      type;
+} SVGA3dCmdBeginQuery;           /* SVGA_3D_CMD_BEGIN_QUERY */
+
+typedef
+struct {
+   uint32               cid;
+   SVGA3dQueryType      type;
+   SVGAGuestPtr         guestResult;  /* Points to an SVGA3dQueryResult structure */
+} SVGA3dCmdEndQuery;                  /* SVGA_3D_CMD_END_QUERY */
+
+typedef
+struct {
+   uint32               cid;          /* Same parameters passed to END_QUERY */
+   SVGA3dQueryType      type;
+   SVGAGuestPtr         guestResult;
+} SVGA3dCmdWaitForQuery;              /* SVGA_3D_CMD_WAIT_FOR_QUERY */
+
+typedef
+struct {
+   uint32               totalSize;    /* Set by guest before query is ended. */
+   SVGA3dQueryState     state;        /* Set by host or guest. See SVGA3dQueryState. */
+   union {                            /* Set by host on exit from PENDING state */
+      uint32            result32;
+   };
+} SVGA3dQueryResult;
+
+/*
+ * SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN --
+ *
+ *    This is a blit from an SVGA3D surface to a Screen Object. Just
+ *    like GMR-to-screen blits, this blit may be directed at a
+ *    specific screen or to the virtual coordinate space.
+ *
+ *    The blit copies from a rectangular region of an SVGA3D surface
+ *    image to a rectangular region of a screen or screens.
+ *
+ *    This command takes an optional variable-length list of clipping
+ *    rectangles after the body of the command. If no rectangles are
+ *    specified, there is no clipping region. The entire destRect is
+ *    drawn to. If one or more rectangles are included, they describe
+ *    a clipping region. The clip rectangle coordinates are measured
+ *    relative to the top-left corner of destRect.
+ *
+ *    This clipping region serves multiple purposes:
+ *
+ *      - It can be used to perform an irregularly shaped blit more
+ *        efficiently than by issuing many separate blit commands.
+ *
+ *      - It is equivalent to allowing blits with non-integer
+ *        source coordinates. You could blit just one half-pixel
+ *        of a source, for example, by specifying a larger
+ *        destination rectangle than you need, then removing
+ *        part of it using a clip rectangle.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ *
+ * Limitations:
+ *
+ *    - Currently, no backend supports blits from a mipmap or face
+ *      other than the first one.
+ */
+
+typedef
+struct {
+   SVGA3dSurfaceImageId srcImage;
+   SVGASignedRect       srcRect;
+   uint32               destScreenId; /* Screen ID or SVGA_ID_INVALID for virt. coords */
+   SVGASignedRect       destRect;     /* Supports scaling if src/rest different size */
+   /* Clipping: zero or more SVGASignedRects follow */
+} SVGA3dCmdBlitSurfaceToScreen;         /* SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN */
+
+
+/*
+ * Capability query index.
+ *
+ * Notes:
+ *
+ *   1. SVGA3D_DEVCAP_MAX_TEXTURES reflects the maximum number of
+ *      fixed-function texture units available. Each of these units
+ *      work in both FFP and Shader modes, and they support texture
+ *      transforms and texture coordinates. The host may have additional
+ *      texture image units that are only usable with shaders.
+ *
+ *   2. The BUFFER_FORMAT capabilities are deprecated, and they always
+ *      return TRUE. Even on physical hardware that does not support
+ *      these formats natively, the SVGA3D device will provide an emulation
+ *      which should be invisible to the guest OS.
+ *
+ *      In general, the SVGA3D device should support any operation on
+ *      any surface format, it just may perform some of these
+ *      operations in software depending on the capabilities of the
+ *      available physical hardware.
+ *
+ *      XXX: In the future, we will add capabilities that describe in
+ *      detail what formats are supported in hardware for what kinds
+ *      of operations.
+ */
+
+typedef enum {
+   SVGA3D_DEVCAP_3D                                = 0,
+   SVGA3D_DEVCAP_MAX_LIGHTS                        = 1,
+   SVGA3D_DEVCAP_MAX_TEXTURES                      = 2,  /* See note (1) */
+   SVGA3D_DEVCAP_MAX_CLIP_PLANES                   = 3,
+   SVGA3D_DEVCAP_VERTEX_SHADER_VERSION             = 4,
+   SVGA3D_DEVCAP_VERTEX_SHADER                     = 5,
+   SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION           = 6,
+   SVGA3D_DEVCAP_FRAGMENT_SHADER                   = 7,
+   SVGA3D_DEVCAP_MAX_RENDER_TARGETS                = 8,
+   SVGA3D_DEVCAP_S23E8_TEXTURES                    = 9,
+   SVGA3D_DEVCAP_S10E5_TEXTURES                    = 10,
+   SVGA3D_DEVCAP_MAX_FIXED_VERTEXBLEND             = 11,
+   SVGA3D_DEVCAP_D16_BUFFER_FORMAT                 = 12, /* See note (2) */
+   SVGA3D_DEVCAP_D24S8_BUFFER_FORMAT               = 13, /* See note (2) */
+   SVGA3D_DEVCAP_D24X8_BUFFER_FORMAT               = 14, /* See note (2) */
+   SVGA3D_DEVCAP_QUERY_TYPES                       = 15,
+   SVGA3D_DEVCAP_TEXTURE_GRADIENT_SAMPLING         = 16,
+   SVGA3D_DEVCAP_MAX_POINT_SIZE                    = 17,
+   SVGA3D_DEVCAP_MAX_SHADER_TEXTURES               = 18,
+   SVGA3D_DEVCAP_MAX_TEXTURE_WIDTH                 = 19,
+   SVGA3D_DEVCAP_MAX_TEXTURE_HEIGHT                = 20,
+   SVGA3D_DEVCAP_MAX_VOLUME_EXTENT                 = 21,
+   SVGA3D_DEVCAP_MAX_TEXTURE_REPEAT                = 22,
+   SVGA3D_DEVCAP_MAX_TEXTURE_ASPECT_RATIO          = 23,
+   SVGA3D_DEVCAP_MAX_TEXTURE_ANISOTROPY            = 24,
+   SVGA3D_DEVCAP_MAX_PRIMITIVE_COUNT               = 25,
+   SVGA3D_DEVCAP_MAX_VERTEX_INDEX                  = 26,
+   SVGA3D_DEVCAP_MAX_VERTEX_SHADER_INSTRUCTIONS    = 27,
+   SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_INSTRUCTIONS  = 28,
+   SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS           = 29,
+   SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS         = 30,
+   SVGA3D_DEVCAP_TEXTURE_OPS                       = 31,
+   SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8               = 32,
+   SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8               = 33,
+   SVGA3D_DEVCAP_SURFACEFMT_A2R10G10B10            = 34,
+   SVGA3D_DEVCAP_SURFACEFMT_X1R5G5B5               = 35,
+   SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5               = 36,
+   SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4               = 37,
+   SVGA3D_DEVCAP_SURFACEFMT_R5G6B5                 = 38,
+   SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE16            = 39,
+   SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8_ALPHA8      = 40,
+   SVGA3D_DEVCAP_SURFACEFMT_ALPHA8                 = 41,
+   SVGA3D_DEVCAP_SURFACEFMT_LUMINANCE8             = 42,
+   SVGA3D_DEVCAP_SURFACEFMT_Z_D16                  = 43,
+   SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8                = 44,
+   SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8                = 45,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT1                   = 46,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT2                   = 47,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT3                   = 48,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT4                   = 49,
+   SVGA3D_DEVCAP_SURFACEFMT_DXT5                   = 50,
+   SVGA3D_DEVCAP_SURFACEFMT_BUMPX8L8V8U8           = 51,
+   SVGA3D_DEVCAP_SURFACEFMT_A2W10V10U10            = 52,
+   SVGA3D_DEVCAP_SURFACEFMT_BUMPU8V8               = 53,
+   SVGA3D_DEVCAP_SURFACEFMT_Q8W8V8U8               = 54,
+   SVGA3D_DEVCAP_SURFACEFMT_CxV8U8                 = 55,
+   SVGA3D_DEVCAP_SURFACEFMT_R_S10E5                = 56,
+   SVGA3D_DEVCAP_SURFACEFMT_R_S23E8                = 57,
+   SVGA3D_DEVCAP_SURFACEFMT_RG_S10E5               = 58,
+   SVGA3D_DEVCAP_SURFACEFMT_RG_S23E8               = 59,
+   SVGA3D_DEVCAP_SURFACEFMT_ARGB_S10E5             = 60,
+   SVGA3D_DEVCAP_SURFACEFMT_ARGB_S23E8             = 61,
+   SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEXTURES        = 63,
+
+   /*
+    * Note that MAX_SIMULTANEOUS_RENDER_TARGETS is a maximum count of color
+    * render targets.  This does no include the depth or stencil targets.
+    */
+   SVGA3D_DEVCAP_MAX_SIMULTANEOUS_RENDER_TARGETS   = 64,
+
+   SVGA3D_DEVCAP_SURFACEFMT_V16U16                 = 65,
+   SVGA3D_DEVCAP_SURFACEFMT_G16R16                 = 66,
+   SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16           = 67,
+   SVGA3D_DEVCAP_SURFACEFMT_UYVY                   = 68,
+   SVGA3D_DEVCAP_SURFACEFMT_YUY2                   = 69,
+
+   /*
+    * Don't add new caps into the previous section; the values in this
+    * enumeration must not change. You can put new values right before
+    * SVGA3D_DEVCAP_MAX.
+    */
+   SVGA3D_DEVCAP_MAX                                  /* This must be the last index. */
+} SVGA3dDevCapIndex;
+
+typedef union {
+   Bool   b;
+   uint32 u;
+   int32  i;
+   float  f;
+} SVGA3dDevCapResult;
+
+#endif /* _SVGA3D_REG_H_ */
diff --git a/drivers/gpu/drm/vmwgfx/svga_escape.h b/drivers/gpu/drm/vmwgfx/svga_escape.h
new file mode 100644 (file)
index 0000000..7b85e9b
--- /dev/null
@@ -0,0 +1,89 @@
+/**********************************************************
+ * Copyright 2007-2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/*
+ * svga_escape.h --
+ *
+ *    Definitions for our own (vendor-specific) SVGA Escape commands.
+ */
+
+#ifndef _SVGA_ESCAPE_H_
+#define _SVGA_ESCAPE_H_
+
+
+/*
+ * Namespace IDs for the escape command
+ */
+
+#define SVGA_ESCAPE_NSID_VMWARE 0x00000000
+#define SVGA_ESCAPE_NSID_DEVEL  0xFFFFFFFF
+
+
+/*
+ * Within SVGA_ESCAPE_NSID_VMWARE, we multiplex commands according to
+ * the first DWORD of escape data (after the nsID and size). As a
+ * guideline we're using the high word and low word as a major and
+ * minor command number, respectively.
+ *
+ * Major command number allocation:
+ *
+ *   0000: Reserved
+ *   0001: SVGA_ESCAPE_VMWARE_LOG (svga_binary_logger.h)
+ *   0002: SVGA_ESCAPE_VMWARE_VIDEO (svga_overlay.h)
+ *   0003: SVGA_ESCAPE_VMWARE_HINT (svga_escape.h)
+ */
+
+#define SVGA_ESCAPE_VMWARE_MAJOR_MASK  0xFFFF0000
+
+
+/*
+ * SVGA Hint commands.
+ *
+ * These escapes let the SVGA driver provide optional information to
+ * he host about the state of the guest or guest applications. The
+ * host can use these hints to make user interface or performance
+ * decisions.
+ *
+ * Notes:
+ *
+ *   - SVGA_ESCAPE_VMWARE_HINT_FULLSCREEN is deprecated for guests
+ *     that use the SVGA Screen Object extension. Instead of sending
+ *     this escape, use the SVGA_SCREEN_FULLSCREEN_HINT flag on your
+ *     Screen Object.
+ */
+
+#define SVGA_ESCAPE_VMWARE_HINT               0x00030000
+#define SVGA_ESCAPE_VMWARE_HINT_FULLSCREEN    0x00030001  // Deprecated
+
+typedef
+struct {
+   uint32 command;
+   uint32 fullscreen;
+   struct {
+      int32 x, y;
+   } monitorPosition;
+} SVGAEscapeHintFullscreen;
+
+#endif /* _SVGA_ESCAPE_H_ */
diff --git a/drivers/gpu/drm/vmwgfx/svga_overlay.h b/drivers/gpu/drm/vmwgfx/svga_overlay.h
new file mode 100644 (file)
index 0000000..f753d73
--- /dev/null
@@ -0,0 +1,201 @@
+/**********************************************************
+ * Copyright 2007-2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/*
+ * svga_overlay.h --
+ *
+ *    Definitions for video-overlay support.
+ */
+
+#ifndef _SVGA_OVERLAY_H_
+#define _SVGA_OVERLAY_H_
+
+#include "svga_reg.h"
+
+/*
+ * Video formats we support
+ */
+
+#define VMWARE_FOURCC_YV12 0x32315659 // 'Y' 'V' '1' '2'
+#define VMWARE_FOURCC_YUY2 0x32595559 // 'Y' 'U' 'Y' '2'
+#define VMWARE_FOURCC_UYVY 0x59565955 // 'U' 'Y' 'V' 'Y'
+
+typedef enum {
+   SVGA_OVERLAY_FORMAT_INVALID = 0,
+   SVGA_OVERLAY_FORMAT_YV12 = VMWARE_FOURCC_YV12,
+   SVGA_OVERLAY_FORMAT_YUY2 = VMWARE_FOURCC_YUY2,
+   SVGA_OVERLAY_FORMAT_UYVY = VMWARE_FOURCC_UYVY,
+} SVGAOverlayFormat;
+
+#define SVGA_VIDEO_COLORKEY_MASK             0x00ffffff
+
+#define SVGA_ESCAPE_VMWARE_VIDEO             0x00020000
+
+#define SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS    0x00020001
+        /* FIFO escape layout:
+         * Type, Stream Id, (Register Id, Value) pairs */
+
+#define SVGA_ESCAPE_VMWARE_VIDEO_FLUSH       0x00020002
+        /* FIFO escape layout:
+         * Type, Stream Id */
+
+typedef
+struct SVGAEscapeVideoSetRegs {
+   struct {
+      uint32 cmdType;
+      uint32 streamId;
+   } header;
+
+   // May include zero or more items.
+   struct {
+      uint32 registerId;
+      uint32 value;
+   } items[1];
+} SVGAEscapeVideoSetRegs;
+
+typedef
+struct SVGAEscapeVideoFlush {
+   uint32 cmdType;
+   uint32 streamId;
+} SVGAEscapeVideoFlush;
+
+
+/*
+ * Struct definitions for the video overlay commands built on
+ * SVGAFifoCmdEscape.
+ */
+typedef
+struct {
+   uint32 command;
+   uint32 overlay;
+} SVGAFifoEscapeCmdVideoBase;
+
+typedef
+struct {
+   SVGAFifoEscapeCmdVideoBase videoCmd;
+} SVGAFifoEscapeCmdVideoFlush;
+
+typedef
+struct {
+   SVGAFifoEscapeCmdVideoBase videoCmd;
+   struct {
+      uint32 regId;
+      uint32 value;
+   } items[1];
+} SVGAFifoEscapeCmdVideoSetRegs;
+
+typedef
+struct {
+   SVGAFifoEscapeCmdVideoBase videoCmd;
+   struct {
+      uint32 regId;
+      uint32 value;
+   } items[SVGA_VIDEO_NUM_REGS];
+} SVGAFifoEscapeCmdVideoSetAllRegs;
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * VMwareVideoGetAttributes --
+ *
+ *      Computes the size, pitches and offsets for YUV frames.
+ *
+ * Results:
+ *      TRUE on success; otherwise FALSE on failure.
+ *
+ * Side effects:
+ *      Pitches and offsets for the given YUV frame are put in 'pitches'
+ *      and 'offsets' respectively. They are both optional though.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static inline bool
+VMwareVideoGetAttributes(const SVGAOverlayFormat format,    // IN
+                         uint32 *width,                     // IN / OUT
+                         uint32 *height,                    // IN / OUT
+                         uint32 *size,                      // OUT
+                         uint32 *pitches,                   // OUT (optional)
+                         uint32 *offsets)                   // OUT (optional)
+{
+    int tmp;
+
+    *width = (*width + 1) & ~1;
+
+    if (offsets) {
+        offsets[0] = 0;
+    }
+
+    switch (format) {
+    case VMWARE_FOURCC_YV12:
+       *height = (*height + 1) & ~1;
+       *size = (*width + 3) & ~3;
+
+       if (pitches) {
+          pitches[0] = *size;
+       }
+
+       *size *= *height;
+
+       if (offsets) {
+          offsets[1] = *size;
+       }
+
+       tmp = ((*width >> 1) + 3) & ~3;
+
+       if (pitches) {
+          pitches[1] = pitches[2] = tmp;
+       }
+
+       tmp *= (*height >> 1);
+       *size += tmp;
+
+       if (offsets) {
+          offsets[2] = *size;
+       }
+
+       *size += tmp;
+       break;
+
+    case VMWARE_FOURCC_YUY2:
+    case VMWARE_FOURCC_UYVY:
+       *size = *width * 2;
+
+       if (pitches) {
+          pitches[0] = *size;
+       }
+
+       *size *= *height;
+       break;
+
+    default:
+       return false;
+    }
+
+    return true;
+}
+
+#endif // _SVGA_OVERLAY_H_
diff --git a/drivers/gpu/drm/vmwgfx/svga_reg.h b/drivers/gpu/drm/vmwgfx/svga_reg.h
new file mode 100644 (file)
index 0000000..1b96c2e
--- /dev/null
@@ -0,0 +1,1346 @@
+/**********************************************************
+ * Copyright 1998-2009 VMware, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+/*
+ * svga_reg.h --
+ *
+ *    Virtual hardware definitions for the VMware SVGA II device.
+ */
+
+#ifndef _SVGA_REG_H_
+#define _SVGA_REG_H_
+
+/*
+ * PCI device IDs.
+ */
+#define PCI_VENDOR_ID_VMWARE            0x15AD
+#define PCI_DEVICE_ID_VMWARE_SVGA2      0x0405
+
+/*
+ * Legal values for the SVGA_REG_CURSOR_ON register in old-fashioned
+ * cursor bypass mode. This is still supported, but no new guest
+ * drivers should use it.
+ */
+#define SVGA_CURSOR_ON_HIDE            0x0   /* Must be 0 to maintain backward compatibility */
+#define SVGA_CURSOR_ON_SHOW            0x1   /* Must be 1 to maintain backward compatibility */
+#define SVGA_CURSOR_ON_REMOVE_FROM_FB  0x2   /* Remove the cursor from the framebuffer because we need to see what's under it */
+#define SVGA_CURSOR_ON_RESTORE_TO_FB   0x3   /* Put the cursor back in the framebuffer so the user can see it */
+
+/*
+ * The maximum framebuffer size that can traced for e.g. guests in VESA mode.
+ * The changeMap in the monitor is proportional to this number. Therefore, we'd
+ * like to keep it as small as possible to reduce monitor overhead (using
+ * SVGA_VRAM_MAX_SIZE for this increases the size of the shared area by over
+ * 4k!).
+ *
+ * NB: For compatibility reasons, this value must be greater than 0xff0000.
+ *     See bug 335072.
+ */
+#define SVGA_FB_MAX_TRACEABLE_SIZE      0x1000000
+
+#define SVGA_MAX_PSEUDOCOLOR_DEPTH      8
+#define SVGA_MAX_PSEUDOCOLORS           (1 << SVGA_MAX_PSEUDOCOLOR_DEPTH)
+#define SVGA_NUM_PALETTE_REGS           (3 * SVGA_MAX_PSEUDOCOLORS)
+
+#define SVGA_MAGIC         0x900000UL
+#define SVGA_MAKE_ID(ver)  (SVGA_MAGIC << 8 | (ver))
+
+/* Version 2 let the address of the frame buffer be unsigned on Win32 */
+#define SVGA_VERSION_2     2
+#define SVGA_ID_2          SVGA_MAKE_ID(SVGA_VERSION_2)
+
+/* Version 1 has new registers starting with SVGA_REG_CAPABILITIES so
+   PALETTE_BASE has moved */
+#define SVGA_VERSION_1     1
+#define SVGA_ID_1          SVGA_MAKE_ID(SVGA_VERSION_1)
+
+/* Version 0 is the initial version */
+#define SVGA_VERSION_0     0
+#define SVGA_ID_0          SVGA_MAKE_ID(SVGA_VERSION_0)
+
+/* "Invalid" value for all SVGA IDs. (Version ID, screen object ID, surface ID...) */
+#define SVGA_ID_INVALID    0xFFFFFFFF
+
+/* Port offsets, relative to BAR0 */
+#define SVGA_INDEX_PORT         0x0
+#define SVGA_VALUE_PORT         0x1
+#define SVGA_BIOS_PORT          0x2
+#define SVGA_IRQSTATUS_PORT     0x8
+
+/*
+ * Interrupt source flags for IRQSTATUS_PORT and IRQMASK.
+ *
+ * Interrupts are only supported when the
+ * SVGA_CAP_IRQMASK capability is present.
+ */
+#define SVGA_IRQFLAG_ANY_FENCE            0x1    /* Any fence was passed */
+#define SVGA_IRQFLAG_FIFO_PROGRESS        0x2    /* Made forward progress in the FIFO */
+#define SVGA_IRQFLAG_FENCE_GOAL           0x4    /* SVGA_FIFO_FENCE_GOAL reached */
+
+/*
+ * Registers
+ */
+
+enum {
+   SVGA_REG_ID = 0,
+   SVGA_REG_ENABLE = 1,
+   SVGA_REG_WIDTH = 2,
+   SVGA_REG_HEIGHT = 3,
+   SVGA_REG_MAX_WIDTH = 4,
+   SVGA_REG_MAX_HEIGHT = 5,
+   SVGA_REG_DEPTH = 6,
+   SVGA_REG_BITS_PER_PIXEL = 7,       /* Current bpp in the guest */
+   SVGA_REG_PSEUDOCOLOR = 8,
+   SVGA_REG_RED_MASK = 9,
+   SVGA_REG_GREEN_MASK = 10,
+   SVGA_REG_BLUE_MASK = 11,
+   SVGA_REG_BYTES_PER_LINE = 12,
+   SVGA_REG_FB_START = 13,            /* (Deprecated) */
+   SVGA_REG_FB_OFFSET = 14,
+   SVGA_REG_VRAM_SIZE = 15,
+   SVGA_REG_FB_SIZE = 16,
+
+   /* ID 0 implementation only had the above registers, then the palette */
+
+   SVGA_REG_CAPABILITIES = 17,
+   SVGA_REG_MEM_START = 18,           /* (Deprecated) */
+   SVGA_REG_MEM_SIZE = 19,
+   SVGA_REG_CONFIG_DONE = 20,         /* Set when memory area configured */
+   SVGA_REG_SYNC = 21,                /* See "FIFO Synchronization Registers" */
+   SVGA_REG_BUSY = 22,                /* See "FIFO Synchronization Registers" */
+   SVGA_REG_GUEST_ID = 23,            /* Set guest OS identifier */
+   SVGA_REG_CURSOR_ID = 24,           /* (Deprecated) */
+   SVGA_REG_CURSOR_X = 25,            /* (Deprecated) */
+   SVGA_REG_CURSOR_Y = 26,            /* (Deprecated) */
+   SVGA_REG_CURSOR_ON = 27,           /* (Deprecated) */
+   SVGA_REG_HOST_BITS_PER_PIXEL = 28, /* (Deprecated) */
+   SVGA_REG_SCRATCH_SIZE = 29,        /* Number of scratch registers */
+   SVGA_REG_MEM_REGS = 30,            /* Number of FIFO registers */
+   SVGA_REG_NUM_DISPLAYS = 31,        /* (Deprecated) */
+   SVGA_REG_PITCHLOCK = 32,           /* Fixed pitch for all modes */
+   SVGA_REG_IRQMASK = 33,             /* Interrupt mask */
+
+   /* Legacy multi-monitor support */
+   SVGA_REG_NUM_GUEST_DISPLAYS = 34,/* Number of guest displays in X/Y direction */
+   SVGA_REG_DISPLAY_ID = 35,        /* Display ID for the following display attributes */
+   SVGA_REG_DISPLAY_IS_PRIMARY = 36,/* Whether this is a primary display */
+   SVGA_REG_DISPLAY_POSITION_X = 37,/* The display position x */
+   SVGA_REG_DISPLAY_POSITION_Y = 38,/* The display position y */
+   SVGA_REG_DISPLAY_WIDTH = 39,     /* The display's width */
+   SVGA_REG_DISPLAY_HEIGHT = 40,    /* The display's height */
+
+   /* See "Guest memory regions" below. */
+   SVGA_REG_GMR_ID = 41,
+   SVGA_REG_GMR_DESCRIPTOR = 42,
+   SVGA_REG_GMR_MAX_IDS = 43,
+   SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH = 44,
+
+   SVGA_REG_TRACES = 45,            /* Enable trace-based updates even when FIFO is on */
+   SVGA_REG_TOP = 46,               /* Must be 1 more than the last register */
+
+   SVGA_PALETTE_BASE = 1024,        /* Base of SVGA color map */
+   /* Next 768 (== 256*3) registers exist for colormap */
+
+   SVGA_SCRATCH_BASE = SVGA_PALETTE_BASE + SVGA_NUM_PALETTE_REGS
+                                    /* Base of scratch registers */
+   /* Next reg[SVGA_REG_SCRATCH_SIZE] registers exist for scratch usage:
+      First 4 are reserved for VESA BIOS Extension; any remaining are for
+      the use of the current SVGA driver. */
+};
+
+
+/*
+ * Guest memory regions (GMRs):
+ *
+ * This is a new memory mapping feature available in SVGA devices
+ * which have the SVGA_CAP_GMR bit set. Previously, there were two
+ * fixed memory regions available with which to share data between the
+ * device and the driver: the FIFO ('MEM') and the framebuffer. GMRs
+ * are our name for an extensible way of providing arbitrary DMA
+ * buffers for use between the driver and the SVGA device. They are a
+ * new alternative to framebuffer memory, usable for both 2D and 3D
+ * graphics operations.
+ *
+ * Since GMR mapping must be done synchronously with guest CPU
+ * execution, we use a new pair of SVGA registers:
+ *
+ *   SVGA_REG_GMR_ID --
+ *
+ *     Read/write.
+ *     This register holds the 32-bit ID (a small positive integer)
+ *     of a GMR to create, delete, or redefine. Writing this register
+ *     has no side-effects.
+ *
+ *   SVGA_REG_GMR_DESCRIPTOR --
+ *
+ *     Write-only.
+ *     Writing this register will create, delete, or redefine the GMR
+ *     specified by the above ID register. If this register is zero,
+ *     the GMR is deleted. Any pointers into this GMR (including those
+ *     currently being processed by FIFO commands) will be
+ *     synchronously invalidated.
+ *
+ *     If this register is nonzero, it must be the physical page
+ *     number (PPN) of a data structure which describes the physical
+ *     layout of the memory region this GMR should describe. The
+ *     descriptor structure will be read synchronously by the SVGA
+ *     device when this register is written. The descriptor need not
+ *     remain allocated for the lifetime of the GMR.
+ *
+ *     The guest driver should write SVGA_REG_GMR_ID first, then
+ *     SVGA_REG_GMR_DESCRIPTOR.
+ *
+ *   SVGA_REG_GMR_MAX_IDS --
+ *
+ *     Read-only.
+ *     The SVGA device may choose to support a maximum number of
+ *     user-defined GMR IDs. This register holds the number of supported
+ *     IDs. (The maximum supported ID plus 1)
+ *
+ *   SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH --
+ *
+ *     Read-only.
+ *     The SVGA device may choose to put a limit on the total number
+ *     of SVGAGuestMemDescriptor structures it will read when defining
+ *     a single GMR.
+ *
+ * The descriptor structure is an array of SVGAGuestMemDescriptor
+ * structures. Each structure may do one of three things:
+ *
+ *   - Terminate the GMR descriptor list.
+ *     (ppn==0, numPages==0)
+ *
+ *   - Add a PPN or range of PPNs to the GMR's virtual address space.
+ *     (ppn != 0, numPages != 0)
+ *
+ *   - Provide the PPN of the next SVGAGuestMemDescriptor, in order to
+ *     support multi-page GMR descriptor tables without forcing the
+ *     driver to allocate physically contiguous memory.
+ *     (ppn != 0, numPages == 0)
+ *
+ * Note that each physical page of SVGAGuestMemDescriptor structures
+ * can describe at least 2MB of guest memory. If the driver needs to
+ * use more than one page of descriptor structures, it must use one of
+ * its SVGAGuestMemDescriptors to point to an additional page.  The
+ * device will never automatically cross a page boundary.
+ *
+ * Once the driver has described a GMR, it is immediately available
+ * for use via any FIFO command that uses an SVGAGuestPtr structure.
+ * These pointers include a GMR identifier plus an offset into that
+ * GMR.
+ *
+ * The driver must check the SVGA_CAP_GMR bit before using the GMR
+ * registers.
+ */
+
+/*
+ * Special GMR IDs, allowing SVGAGuestPtrs to point to framebuffer
+ * memory as well.  In the future, these IDs could even be used to
+ * allow legacy memory regions to be redefined by the guest as GMRs.
+ *
+ * Using the guest framebuffer (GFB) at BAR1 for general purpose DMA
+ * is being phased out. Please try to use user-defined GMRs whenever
+ * possible.
+ */
+#define SVGA_GMR_NULL         ((uint32) -1)
+#define SVGA_GMR_FRAMEBUFFER  ((uint32) -2)  // Guest Framebuffer (GFB)
+
+typedef
+struct SVGAGuestMemDescriptor {
+   uint32 ppn;
+   uint32 numPages;
+} SVGAGuestMemDescriptor;
+
+typedef
+struct SVGAGuestPtr {
+   uint32 gmrId;
+   uint32 offset;
+} SVGAGuestPtr;
+
+
+/*
+ * SVGAGMRImageFormat --
+ *
+ *    This is a packed representation of the source 2D image format
+ *    for a GMR-to-screen blit. Currently it is defined as an encoding
+ *    of the screen's color depth and bits-per-pixel, however, 16 bits
+ *    are reserved for future use to identify other encodings (such as
+ *    RGBA or higher-precision images).
+ *
+ *    Currently supported formats:
+ *
+ *       bpp depth  Format Name
+ *       --- -----  -----------
+ *        32    24  32-bit BGRX
+ *        24    24  24-bit BGR
+ *        16    16  RGB 5-6-5
+ *        16    15  RGB 5-5-5
+ *
+ */
+
+typedef
+struct SVGAGMRImageFormat {
+   union {
+      struct {
+         uint32 bitsPerPixel : 8;
+         uint32 colorDepth   : 8;
+         uint32 reserved     : 16;  // Must be zero
+      };
+
+      uint32 value;
+   };
+} SVGAGMRImageFormat;
+
+/*
+ * SVGAColorBGRX --
+ *
+ *    A 24-bit color format (BGRX), which does not depend on the
+ *    format of the legacy guest framebuffer (GFB) or the current
+ *    GMRFB state.
+ */
+
+typedef
+struct SVGAColorBGRX {
+   union {
+      struct {
+         uint32 b : 8;
+         uint32 g : 8;
+         uint32 r : 8;
+         uint32 x : 8;  // Unused
+      };
+
+      uint32 value;
+   };
+} SVGAColorBGRX;
+
+
+/*
+ * SVGASignedRect --
+ * SVGASignedPoint --
+ *
+ *    Signed rectangle and point primitives. These are used by the new
+ *    2D primitives for drawing to Screen Objects, which can occupy a
+ *    signed virtual coordinate space.
+ *
+ *    SVGASignedRect specifies a half-open interval: the (left, top)
+ *    pixel is part of the rectangle, but the (right, bottom) pixel is
+ *    not.
+ */
+
+typedef
+struct SVGASignedRect {
+   int32  left;
+   int32  top;
+   int32  right;
+   int32  bottom;
+} SVGASignedRect;
+
+typedef
+struct SVGASignedPoint {
+   int32  x;
+   int32  y;
+} SVGASignedPoint;
+
+
+/*
+ *  Capabilities
+ *
+ *  Note the holes in the bitfield. Missing bits have been deprecated,
+ *  and must not be reused. Those capabilities will never be reported
+ *  by new versions of the SVGA device.
+ */
+
+#define SVGA_CAP_NONE               0x00000000
+#define SVGA_CAP_RECT_COPY          0x00000002
+#define SVGA_CAP_CURSOR             0x00000020
+#define SVGA_CAP_CURSOR_BYPASS      0x00000040   // Legacy (Use Cursor Bypass 3 instead)
+#define SVGA_CAP_CURSOR_BYPASS_2    0x00000080   // Legacy (Use Cursor Bypass 3 instead)
+#define SVGA_CAP_8BIT_EMULATION     0x00000100
+#define SVGA_CAP_ALPHA_CURSOR       0x00000200
+#define SVGA_CAP_3D                 0x00004000
+#define SVGA_CAP_EXTENDED_FIFO      0x00008000
+#define SVGA_CAP_MULTIMON           0x00010000   // Legacy multi-monitor support
+#define SVGA_CAP_PITCHLOCK          0x00020000
+#define SVGA_CAP_IRQMASK            0x00040000
+#define SVGA_CAP_DISPLAY_TOPOLOGY   0x00080000   // Legacy multi-monitor support
+#define SVGA_CAP_GMR                0x00100000
+#define SVGA_CAP_TRACES             0x00200000
+
+
+/*
+ * FIFO register indices.
+ *
+ * The FIFO is a chunk of device memory mapped into guest physmem.  It
+ * is always treated as 32-bit words.
+ *
+ * The guest driver gets to decide how to partition it between
+ * - FIFO registers (there are always at least 4, specifying where the
+ *   following data area is and how much data it contains; there may be
+ *   more registers following these, depending on the FIFO protocol
+ *   version in use)
+ * - FIFO data, written by the guest and slurped out by the VMX.
+ * These indices are 32-bit word offsets into the FIFO.
+ */
+
+enum {
+   /*
+    * Block 1 (basic registers): The originally defined FIFO registers.
+    * These exist and are valid for all versions of the FIFO protocol.
+    */
+
+   SVGA_FIFO_MIN = 0,
+   SVGA_FIFO_MAX,       /* The distance from MIN to MAX must be at least 10K */
+   SVGA_FIFO_NEXT_CMD,
+   SVGA_FIFO_STOP,
+
+   /*
+    * Block 2 (extended registers): Mandatory registers for the extended
+    * FIFO.  These exist if the SVGA caps register includes
+    * SVGA_CAP_EXTENDED_FIFO; some of them are valid only if their
+    * associated capability bit is enabled.
+    *
+    * Note that when originally defined, SVGA_CAP_EXTENDED_FIFO implied
+    * support only for (FIFO registers) CAPABILITIES, FLAGS, and FENCE.
+    * This means that the guest has to test individually (in most cases
+    * using FIFO caps) for the presence of registers after this; the VMX
+    * can define "extended FIFO" to mean whatever it wants, and currently
+    * won't enable it unless there's room for that set and much more.
+    */
+
+   SVGA_FIFO_CAPABILITIES = 4,
+   SVGA_FIFO_FLAGS,
+   // Valid with SVGA_FIFO_CAP_FENCE:
+   SVGA_FIFO_FENCE,
+
+   /*
+    * Block 3a (optional extended registers): Additional registers for the
+    * extended FIFO, whose presence isn't actually implied by
+    * SVGA_CAP_EXTENDED_FIFO; these exist if SVGA_FIFO_MIN is high enough to
+    * leave room for them.
+    *
+    * These in block 3a, the VMX currently considers mandatory for the
+    * extended FIFO.
+    */
+
+   // Valid if exists (i.e. if extended FIFO enabled):
+   SVGA_FIFO_3D_HWVERSION,       /* See SVGA3dHardwareVersion in svga3d_reg.h */
+   // Valid with SVGA_FIFO_CAP_PITCHLOCK:
+   SVGA_FIFO_PITCHLOCK,
+
+   // Valid with SVGA_FIFO_CAP_CURSOR_BYPASS_3:
+   SVGA_FIFO_CURSOR_ON,          /* Cursor bypass 3 show/hide register */
+   SVGA_FIFO_CURSOR_X,           /* Cursor bypass 3 x register */
+   SVGA_FIFO_CURSOR_Y,           /* Cursor bypass 3 y register */
+   SVGA_FIFO_CURSOR_COUNT,       /* Incremented when any of the other 3 change */
+   SVGA_FIFO_CURSOR_LAST_UPDATED,/* Last time the host updated the cursor */
+
+   // Valid with SVGA_FIFO_CAP_RESERVE:
+   SVGA_FIFO_RESERVED,           /* Bytes past NEXT_CMD with real contents */
+
+   /*
+    * Valid with SVGA_FIFO_CAP_SCREEN_OBJECT:
+    *
+    * By default this is SVGA_ID_INVALID, to indicate that the cursor
+    * coordinates are specified relative to the virtual root. If this
+    * is set to a specific screen ID, cursor position is reinterpreted
+    * as a signed offset relative to that screen's origin. This is the
+    * only way to place the cursor on a non-rooted screen.
+    */
+   SVGA_FIFO_CURSOR_SCREEN_ID,
+
+   /*
+    * XXX: The gap here, up until SVGA_FIFO_3D_CAPS, can be used for new
+    * registers, but this must be done carefully and with judicious use of
+    * capability bits, since comparisons based on SVGA_FIFO_MIN aren't
+    * enough to tell you whether the register exists: we've shipped drivers
+    * and products that used SVGA_FIFO_3D_CAPS but didn't know about some of
+    * the earlier ones.  The actual order of introduction was:
+    * - PITCHLOCK
+    * - 3D_CAPS
+    * - CURSOR_* (cursor bypass 3)
+    * - RESERVED
+    * So, code that wants to know whether it can use any of the
+    * aforementioned registers, or anything else added after PITCHLOCK and
+    * before 3D_CAPS, needs to reason about something other than
+    * SVGA_FIFO_MIN.
+    */
+
+   /*
+    * 3D caps block space; valid with 3D hardware version >=
+    * SVGA3D_HWVERSION_WS6_B1.
+    */
+   SVGA_FIFO_3D_CAPS      = 32,
+   SVGA_FIFO_3D_CAPS_LAST = 32 + 255,
+
+   /*
+    * End of VMX's current definition of "extended-FIFO registers".
+    * Registers before here are always enabled/disabled as a block; either
+    * the extended FIFO is enabled and includes all preceding registers, or
+    * it's disabled entirely.
+    *
+    * Block 3b (truly optional extended registers): Additional registers for
+    * the extended FIFO, which the VMX already knows how to enable and
+    * disable with correct granularity.
+    *
+    * Registers after here exist if and only if the guest SVGA driver
+    * sets SVGA_FIFO_MIN high enough to leave room for them.
+    */
+
+   // Valid if register exists:
+   SVGA_FIFO_GUEST_3D_HWVERSION, /* Guest driver's 3D version */
+   SVGA_FIFO_FENCE_GOAL,         /* Matching target for SVGA_IRQFLAG_FENCE_GOAL */
+   SVGA_FIFO_BUSY,               /* See "FIFO Synchronization Registers" */
+
+   /*
+    * Always keep this last.  This defines the maximum number of
+    * registers we know about.  At power-on, this value is placed in
+    * the SVGA_REG_MEM_REGS register, and we expect the guest driver
+    * to allocate this much space in FIFO memory for registers.
+    */
+    SVGA_FIFO_NUM_REGS
+};
+
+
+/*
+ * Definition of registers included in extended FIFO support.
+ *
+ * The guest SVGA driver gets to allocate the FIFO between registers
+ * and data.  It must always allocate at least 4 registers, but old
+ * drivers stopped there.
+ *
+ * The VMX will enable extended FIFO support if and only if the guest
+ * left enough room for all registers defined as part of the mandatory
+ * set for the extended FIFO.
+ *
+ * Note that the guest drivers typically allocate the FIFO only at
+ * initialization time, not at mode switches, so it's likely that the
+ * number of FIFO registers won't change without a reboot.
+ *
+ * All registers less than this value are guaranteed to be present if
+ * svgaUser->fifo.extended is set. Any later registers must be tested
+ * individually for compatibility at each use (in the VMX).
+ *
+ * This value is used only by the VMX, so it can change without
+ * affecting driver compatibility; keep it that way?
+ */
+#define SVGA_FIFO_EXTENDED_MANDATORY_REGS  (SVGA_FIFO_3D_CAPS_LAST + 1)
+
+
+/*
+ * FIFO Synchronization Registers
+ *
+ *  This explains the relationship between the various FIFO
+ *  sync-related registers in IOSpace and in FIFO space.
+ *
+ *  SVGA_REG_SYNC --
+ *
+ *       The SYNC register can be used in two different ways by the guest:
+ *
+ *         1. If the guest wishes to fully sync (drain) the FIFO,
+ *            it will write once to SYNC then poll on the BUSY
+ *            register. The FIFO is sync'ed once BUSY is zero.
+ *
+ *         2. If the guest wants to asynchronously wake up the host,
+ *            it will write once to SYNC without polling on BUSY.
+ *            Ideally it will do this after some new commands have
+ *            been placed in the FIFO, and after reading a zero
+ *            from SVGA_FIFO_BUSY.
+ *
+ *       (1) is the original behaviour that SYNC was designed to
+ *       support.  Originally, a write to SYNC would implicitly
+ *       trigger a read from BUSY. This causes us to synchronously
+ *       process the FIFO.
+ *
+ *       This behaviour has since been changed so that writing SYNC
+ *       will *not* implicitly cause a read from BUSY. Instead, it
+ *       makes a channel call which asynchronously wakes up the MKS
+ *       thread.
+ *
+ *       New guests can use this new behaviour to implement (2)
+ *       efficiently. This lets guests get the host's attention
+ *       without waiting for the MKS to poll, which gives us much
+ *       better CPU utilization on SMP hosts and on UP hosts while
+ *       we're blocked on the host GPU.
+ *
+ *       Old guests shouldn't notice the behaviour change. SYNC was
+ *       never guaranteed to process the entire FIFO, since it was
+ *       bounded to a particular number of CPU cycles. Old guests will
+ *       still loop on the BUSY register until the FIFO is empty.
+ *
+ *       Writing to SYNC currently has the following side-effects:
+ *
+ *         - Sets SVGA_REG_BUSY to TRUE (in the monitor)
+ *         - Asynchronously wakes up the MKS thread for FIFO processing
+ *         - The value written to SYNC is recorded as a "reason", for
+ *           stats purposes.
+ *
+ *       If SVGA_FIFO_BUSY is available, drivers are advised to only
+ *       write to SYNC if SVGA_FIFO_BUSY is FALSE. Drivers should set
+ *       SVGA_FIFO_BUSY to TRUE after writing to SYNC. The MKS will
+ *       eventually set SVGA_FIFO_BUSY on its own, but this approach
+ *       lets the driver avoid sending multiple asynchronous wakeup
+ *       messages to the MKS thread.
+ *
+ *  SVGA_REG_BUSY --
+ *
+ *       This register is set to TRUE when SVGA_REG_SYNC is written,
+ *       and it reads as FALSE when the FIFO has been completely
+ *       drained.
+ *
+ *       Every read from this register causes us to synchronously
+ *       process FIFO commands. There is no guarantee as to how many
+ *       commands each read will process.
+ *
+ *       CPU time spent processing FIFO commands will be billed to
+ *       the guest.
+ *
+ *       New drivers should avoid using this register unless they
+ *       need to guarantee that the FIFO is completely drained. It
+ *       is overkill for performing a sync-to-fence. Older drivers
+ *       will use this register for any type of synchronization.
+ *
+ *  SVGA_FIFO_BUSY --
+ *
+ *       This register is a fast way for the guest driver to check
+ *       whether the FIFO is already being processed. It reads and
+ *       writes at normal RAM speeds, with no monitor intervention.
+ *
+ *       If this register reads as TRUE, the host is guaranteeing that
+ *       any new commands written into the FIFO will be noticed before
+ *       the MKS goes back to sleep.
+ *
+ *       If this register reads as FALSE, no such guarantee can be
+ *       made.
+ *
+ *       The guest should use this register to quickly determine
+ *       whether or not it needs to wake up the host. If the guest
+ *       just wrote a command or group of commands that it would like
+ *       the host to begin processing, it should:
+ *
+ *         1. Read SVGA_FIFO_BUSY. If it reads as TRUE, no further
+ *            action is necessary.
+ *
+ *         2. Write TRUE to SVGA_FIFO_BUSY. This informs future guest
+ *            code that we've already sent a SYNC to the host and we
+ *            don't need to send a duplicate.
+ *
+ *         3. Write a reason to SVGA_REG_SYNC. This will send an
+ *            asynchronous wakeup to the MKS thread.
+ */
+
+
+/*
+ * FIFO Capabilities
+ *
+ *      Fence -- Fence register and command are supported
+ *      Accel Front -- Front buffer only commands are supported
+ *      Pitch Lock -- Pitch lock register is supported
+ *      Video -- SVGA Video overlay units are supported
+ *      Escape -- Escape command is supported
+ *
+ * XXX: Add longer descriptions for each capability, including a list
+ *      of the new features that each capability provides.
+ *
+ * SVGA_FIFO_CAP_SCREEN_OBJECT --
+ *
+ *    Provides dynamic multi-screen rendering, for improved Unity and
+ *    multi-monitor modes. With Screen Object, the guest can
+ *    dynamically create and destroy 'screens', which can represent
+ *    Unity windows or virtual monitors. Screen Object also provides
+ *    strong guarantees that DMA operations happen only when
+ *    guest-initiated. Screen Object deprecates the BAR1 guest
+ *    framebuffer (GFB) and all commands that work only with the GFB.
+ *
+ *    New registers:
+ *       FIFO_CURSOR_SCREEN_ID, VIDEO_DATA_GMRID, VIDEO_DST_SCREEN_ID
+ *
+ *    New 2D commands:
+ *       DEFINE_SCREEN, DESTROY_SCREEN, DEFINE_GMRFB, BLIT_GMRFB_TO_SCREEN,
+ *       BLIT_SCREEN_TO_GMRFB, ANNOTATION_FILL, ANNOTATION_COPY
+ *
+ *    New 3D commands:
+ *       BLIT_SURFACE_TO_SCREEN
+ *
+ *    New guarantees:
+ *
+ *       - The host will not read or write guest memory, including the GFB,
+ *         except when explicitly initiated by a DMA command.
+ *
+ *       - All DMA, including legacy DMA like UPDATE and PRESENT_READBACK,
+ *         is guaranteed to complete before any subsequent FENCEs.
+ *
+ *       - All legacy commands which affect a Screen (UPDATE, PRESENT,
+ *         PRESENT_READBACK) as well as new Screen blit commands will
+ *         all behave consistently as blits, and memory will be read
+ *         or written in FIFO order.
+ *
+ *         For example, if you PRESENT from one SVGA3D surface to multiple
+ *         places on the screen, the data copied will always be from the
+ *         SVGA3D surface at the time the PRESENT was issued in the FIFO.
+ *         This was not necessarily true on devices without Screen Object.
+ *
+ *         This means that on devices that support Screen Object, the
+ *         PRESENT_READBACK command should not be necessary unless you
+ *         actually want to read back the results of 3D rendering into
+ *         system memory. (And for that, the BLIT_SCREEN_TO_GMRFB
+ *         command provides a strict superset of functionality.)
+ *
+ *       - When a screen is resized, either using Screen Object commands or
+ *         legacy multimon registers, its contents are preserved.
+ */
+
+#define SVGA_FIFO_CAP_NONE                  0
+#define SVGA_FIFO_CAP_FENCE             (1<<0)
+#define SVGA_FIFO_CAP_ACCELFRONT        (1<<1)
+#define SVGA_FIFO_CAP_PITCHLOCK         (1<<2)
+#define SVGA_FIFO_CAP_VIDEO             (1<<3)
+#define SVGA_FIFO_CAP_CURSOR_BYPASS_3   (1<<4)
+#define SVGA_FIFO_CAP_ESCAPE            (1<<5)
+#define SVGA_FIFO_CAP_RESERVE           (1<<6)
+#define SVGA_FIFO_CAP_SCREEN_OBJECT     (1<<7)
+
+
+/*
+ * FIFO Flags
+ *
+ *      Accel Front -- Driver should use front buffer only commands
+ */
+
+#define SVGA_FIFO_FLAG_NONE                 0
+#define SVGA_FIFO_FLAG_ACCELFRONT       (1<<0)
+#define SVGA_FIFO_FLAG_RESERVED        (1<<31) // Internal use only
+
+/*
+ * FIFO reservation sentinel value
+ */
+
+#define SVGA_FIFO_RESERVED_UNKNOWN      0xffffffff
+
+
+/*
+ * Video overlay support
+ */
+
+#define SVGA_NUM_OVERLAY_UNITS 32
+
+
+/*
+ * Video capabilities that the guest is currently using
+ */
+
+#define SVGA_VIDEO_FLAG_COLORKEY        0x0001
+
+
+/*
+ * Offsets for the video overlay registers
+ */
+
+enum {
+   SVGA_VIDEO_ENABLED = 0,
+   SVGA_VIDEO_FLAGS,
+   SVGA_VIDEO_DATA_OFFSET,
+   SVGA_VIDEO_FORMAT,
+   SVGA_VIDEO_COLORKEY,
+   SVGA_VIDEO_SIZE,          // Deprecated
+   SVGA_VIDEO_WIDTH,
+   SVGA_VIDEO_HEIGHT,
+   SVGA_VIDEO_SRC_X,
+   SVGA_VIDEO_SRC_Y,
+   SVGA_VIDEO_SRC_WIDTH,
+   SVGA_VIDEO_SRC_HEIGHT,
+   SVGA_VIDEO_DST_X,         // Signed int32
+   SVGA_VIDEO_DST_Y,         // Signed int32
+   SVGA_VIDEO_DST_WIDTH,
+   SVGA_VIDEO_DST_HEIGHT,
+   SVGA_VIDEO_PITCH_1,
+   SVGA_VIDEO_PITCH_2,
+   SVGA_VIDEO_PITCH_3,
+   SVGA_VIDEO_DATA_GMRID,    // Optional, defaults to SVGA_GMR_FRAMEBUFFER
+   SVGA_VIDEO_DST_SCREEN_ID, // Optional, defaults to virtual coords (SVGA_ID_INVALID)
+   SVGA_VIDEO_NUM_REGS
+};
+
+
+/*
+ * SVGA Overlay Units
+ *
+ *      width and height relate to the entire source video frame.
+ *      srcX, srcY, srcWidth and srcHeight represent subset of the source
+ *      video frame to be displayed.
+ */
+
+typedef struct SVGAOverlayUnit {
+   uint32 enabled;
+   uint32 flags;
+   uint32 dataOffset;
+   uint32 format;
+   uint32 colorKey;
+   uint32 size;
+   uint32 width;
+   uint32 height;
+   uint32 srcX;
+   uint32 srcY;
+   uint32 srcWidth;
+   uint32 srcHeight;
+   int32  dstX;
+   int32  dstY;
+   uint32 dstWidth;
+   uint32 dstHeight;
+   uint32 pitches[3];
+   uint32 dataGMRId;
+   uint32 dstScreenId;
+} SVGAOverlayUnit;
+
+
+/*
+ * SVGAScreenObject --
+ *
+ *    This is a new way to represent a guest's multi-monitor screen or
+ *    Unity window. Screen objects are only supported if the
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT capability bit is set.
+ *
+ *    If Screen Objects are supported, they can be used to fully
+ *    replace the functionality provided by the framebuffer registers
+ *    (SVGA_REG_WIDTH, HEIGHT, etc.) and by SVGA_CAP_DISPLAY_TOPOLOGY.
+ *
+ *    The screen object is a struct with guaranteed binary
+ *    compatibility. New flags can be added, and the struct may grow,
+ *    but existing fields must retain their meaning.
+ *
+ */
+
+#define SVGA_SCREEN_HAS_ROOT    (1 << 0)  // Screen is present in the virtual coord space
+#define SVGA_SCREEN_IS_PRIMARY  (1 << 1)  // Guest considers this screen to be 'primary'
+#define SVGA_SCREEN_FULLSCREEN_HINT (1 << 2)   // Guest is running a fullscreen app here
+
+typedef
+struct SVGAScreenObject {
+   uint32 structSize;   // sizeof(SVGAScreenObject)
+   uint32 id;
+   uint32 flags;
+   struct {
+      uint32 width;
+      uint32 height;
+   } size;
+   struct {
+      int32 x;
+      int32 y;
+   } root;              // Only used if SVGA_SCREEN_HAS_ROOT is set.
+} SVGAScreenObject;
+
+
+/*
+ *  Commands in the command FIFO:
+ *
+ *  Command IDs defined below are used for the traditional 2D FIFO
+ *  communication (not all commands are available for all versions of the
+ *  SVGA FIFO protocol).
+ *
+ *  Note the holes in the command ID numbers: These commands have been
+ *  deprecated, and the old IDs must not be reused.
+ *
+ *  Command IDs from 1000 to 1999 are reserved for use by the SVGA3D
+ *  protocol.
+ *
+ *  Each command's parameters are described by the comments and
+ *  structs below.
+ */
+
+typedef enum {
+   SVGA_CMD_INVALID_CMD           = 0,
+   SVGA_CMD_UPDATE                = 1,
+   SVGA_CMD_RECT_COPY             = 3,
+   SVGA_CMD_DEFINE_CURSOR         = 19,
+   SVGA_CMD_DEFINE_ALPHA_CURSOR   = 22,
+   SVGA_CMD_UPDATE_VERBOSE        = 25,
+   SVGA_CMD_FRONT_ROP_FILL        = 29,
+   SVGA_CMD_FENCE                 = 30,
+   SVGA_CMD_ESCAPE                = 33,
+   SVGA_CMD_DEFINE_SCREEN         = 34,
+   SVGA_CMD_DESTROY_SCREEN        = 35,
+   SVGA_CMD_DEFINE_GMRFB          = 36,
+   SVGA_CMD_BLIT_GMRFB_TO_SCREEN  = 37,
+   SVGA_CMD_BLIT_SCREEN_TO_GMRFB  = 38,
+   SVGA_CMD_ANNOTATION_FILL       = 39,
+   SVGA_CMD_ANNOTATION_COPY       = 40,
+   SVGA_CMD_MAX
+} SVGAFifoCmdId;
+
+#define SVGA_CMD_MAX_ARGS           64
+
+
+/*
+ * SVGA_CMD_UPDATE --
+ *
+ *    This is a DMA transfer which copies from the Guest Framebuffer
+ *    (GFB) at BAR1 + SVGA_REG_FB_OFFSET to any screens which
+ *    intersect with the provided virtual rectangle.
+ *
+ *    This command does not support using arbitrary guest memory as a
+ *    data source- it only works with the pre-defined GFB memory.
+ *    This command also does not support signed virtual coordinates.
+ *    If you have defined screens (using SVGA_CMD_DEFINE_SCREEN) with
+ *    negative root x/y coordinates, the negative portion of those
+ *    screens will not be reachable by this command.
+ *
+ *    This command is not necessary when using framebuffer
+ *    traces. Traces are automatically enabled if the SVGA FIFO is
+ *    disabled, and you may explicitly enable/disable traces using
+ *    SVGA_REG_TRACES. With traces enabled, any write to the GFB will
+ *    automatically act as if a subsequent SVGA_CMD_UPDATE was issued.
+ *
+ *    Traces and SVGA_CMD_UPDATE are the only supported ways to render
+ *    pseudocolor screen updates. The newer Screen Object commands
+ *    only support true color formats.
+ *
+ * Availability:
+ *    Always available.
+ */
+
+typedef
+struct {
+   uint32 x;
+   uint32 y;
+   uint32 width;
+   uint32 height;
+} SVGAFifoCmdUpdate;
+
+
+/*
+ * SVGA_CMD_RECT_COPY --
+ *
+ *    Perform a rectangular DMA transfer from one area of the GFB to
+ *    another, and copy the result to any screens which intersect it.
+ *
+ * Availability:
+ *    SVGA_CAP_RECT_COPY
+ */
+
+typedef
+struct {
+   uint32 srcX;
+   uint32 srcY;
+   uint32 destX;
+   uint32 destY;
+   uint32 width;
+   uint32 height;
+} SVGAFifoCmdRectCopy;
+
+
+/*
+ * SVGA_CMD_DEFINE_CURSOR --
+ *
+ *    Provide a new cursor image, as an AND/XOR mask.
+ *
+ *    The recommended way to position the cursor overlay is by using
+ *    the SVGA_FIFO_CURSOR_* registers, supported by the
+ *    SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
+ *
+ * Availability:
+ *    SVGA_CAP_CURSOR
+ */
+
+typedef
+struct {
+   uint32 id;             // Reserved, must be zero.
+   uint32 hotspotX;
+   uint32 hotspotY;
+   uint32 width;
+   uint32 height;
+   uint32 andMaskDepth;   // Value must be 1 or equal to BITS_PER_PIXEL
+   uint32 xorMaskDepth;   // Value must be 1 or equal to BITS_PER_PIXEL
+   /*
+    * Followed by scanline data for AND mask, then XOR mask.
+    * Each scanline is padded to a 32-bit boundary.
+   */
+} SVGAFifoCmdDefineCursor;
+
+
+/*
+ * SVGA_CMD_DEFINE_ALPHA_CURSOR --
+ *
+ *    Provide a new cursor image, in 32-bit BGRA format.
+ *
+ *    The recommended way to position the cursor overlay is by using
+ *    the SVGA_FIFO_CURSOR_* registers, supported by the
+ *    SVGA_FIFO_CAP_CURSOR_BYPASS_3 capability.
+ *
+ * Availability:
+ *    SVGA_CAP_ALPHA_CURSOR
+ */
+
+typedef
+struct {
+   uint32 id;             // Reserved, must be zero.
+   uint32 hotspotX;
+   uint32 hotspotY;
+   uint32 width;
+   uint32 height;
+   /* Followed by scanline data */
+} SVGAFifoCmdDefineAlphaCursor;
+
+
+/*
+ * SVGA_CMD_UPDATE_VERBOSE --
+ *
+ *    Just like SVGA_CMD_UPDATE, but also provide a per-rectangle
+ *    'reason' value, an opaque cookie which is used by internal
+ *    debugging tools. Third party drivers should not use this
+ *    command.
+ *
+ * Availability:
+ *    SVGA_CAP_EXTENDED_FIFO
+ */
+
+typedef
+struct {
+   uint32 x;
+   uint32 y;
+   uint32 width;
+   uint32 height;
+   uint32 reason;
+} SVGAFifoCmdUpdateVerbose;
+
+
+/*
+ * SVGA_CMD_FRONT_ROP_FILL --
+ *
+ *    This is a hint which tells the SVGA device that the driver has
+ *    just filled a rectangular region of the GFB with a solid
+ *    color. Instead of reading these pixels from the GFB, the device
+ *    can assume that they all equal 'color'. This is primarily used
+ *    for remote desktop protocols.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_ACCELFRONT
+ */
+
+#define  SVGA_ROP_COPY                    0x03
+
+typedef
+struct {
+   uint32 color;     // In the same format as the GFB
+   uint32 x;
+   uint32 y;
+   uint32 width;
+   uint32 height;
+   uint32 rop;       // Must be SVGA_ROP_COPY
+} SVGAFifoCmdFrontRopFill;
+
+
+/*
+ * SVGA_CMD_FENCE --
+ *
+ *    Insert a synchronization fence.  When the SVGA device reaches
+ *    this command, it will copy the 'fence' value into the
+ *    SVGA_FIFO_FENCE register. It will also compare the fence against
+ *    SVGA_FIFO_FENCE_GOAL. If the fence matches the goal and the
+ *    SVGA_IRQFLAG_FENCE_GOAL interrupt is enabled, the device will
+ *    raise this interrupt.
+ *
+ * Availability:
+ *    SVGA_FIFO_FENCE for this command,
+ *    SVGA_CAP_IRQMASK for SVGA_FIFO_FENCE_GOAL.
+ */
+
+typedef
+struct {
+   uint32 fence;
+} SVGAFifoCmdFence;
+
+
+/*
+ * SVGA_CMD_ESCAPE --
+ *
+ *    Send an extended or vendor-specific variable length command.
+ *    This is used for video overlay, third party plugins, and
+ *    internal debugging tools. See svga_escape.h
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_ESCAPE
+ */
+
+typedef
+struct {
+   uint32 nsid;
+   uint32 size;
+   /* followed by 'size' bytes of data */
+} SVGAFifoCmdEscape;
+
+
+/*
+ * SVGA_CMD_DEFINE_SCREEN --
+ *
+ *    Define or redefine an SVGAScreenObject. See the description of
+ *    SVGAScreenObject above.  The video driver is responsible for
+ *    generating new screen IDs. They should be small positive
+ *    integers. The virtual device will have an implementation
+ *    specific upper limit on the number of screen IDs
+ *    supported. Drivers are responsible for recycling IDs. The first
+ *    valid ID is zero.
+ *
+ *    - Interaction with other registers:
+ *
+ *    For backwards compatibility, when the GFB mode registers (WIDTH,
+ *    HEIGHT, PITCHLOCK, BITS_PER_PIXEL) are modified, the SVGA device
+ *    deletes all screens other than screen #0, and redefines screen
+ *    #0 according to the specified mode. Drivers that use
+ *    SVGA_CMD_DEFINE_SCREEN should destroy or redefine screen #0.
+ *
+ *    If you use screen objects, do not use the legacy multi-mon
+ *    registers (SVGA_REG_NUM_GUEST_DISPLAYS, SVGA_REG_DISPLAY_*).
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGAScreenObject screen;   // Variable-length according to version
+} SVGAFifoCmdDefineScreen;
+
+
+/*
+ * SVGA_CMD_DESTROY_SCREEN --
+ *
+ *    Destroy an SVGAScreenObject. Its ID is immediately available for
+ *    re-use.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   uint32 screenId;
+} SVGAFifoCmdDestroyScreen;
+
+
+/*
+ * SVGA_CMD_DEFINE_GMRFB --
+ *
+ *    This command sets a piece of SVGA device state called the
+ *    Guest Memory Region Framebuffer, or GMRFB. The GMRFB is a
+ *    piece of light-weight state which identifies the location and
+ *    format of an image in guest memory or in BAR1. The GMRFB has
+ *    an arbitrary size, and it doesn't need to match the geometry
+ *    of the GFB or any screen object.
+ *
+ *    The GMRFB can be redefined as often as you like. You could
+ *    always use the same GMRFB, you could redefine it before
+ *    rendering from a different guest screen, or you could even
+ *    redefine it before every blit.
+ *
+ *    There are multiple ways to use this command. The simplest way is
+ *    to use it to move the framebuffer either to elsewhere in the GFB
+ *    (BAR1) memory region, or to a user-defined GMR. This lets a
+ *    driver use a framebuffer allocated entirely out of normal system
+ *    memory, which we encourage.
+ *
+ *    Another way to use this command is to set up a ring buffer of
+ *    updates in GFB memory. If a driver wants to ensure that no
+ *    frames are skipped by the SVGA device, it is important that the
+ *    driver not modify the source data for a blit until the device is
+ *    done processing the command. One efficient way to accomplish
+ *    this is to use a ring of small DMA buffers. Each buffer is used
+ *    for one blit, then we move on to the next buffer in the
+ *    ring. The FENCE mechanism is used to protect each buffer from
+ *    re-use until the device is finished with that buffer's
+ *    corresponding blit.
+ *
+ *    This command does not affect the meaning of SVGA_CMD_UPDATE.
+ *    UPDATEs always occur from the legacy GFB memory area. This
+ *    command has no support for pseudocolor GMRFBs. Currently only
+ *    true-color 15, 16, and 24-bit depths are supported. Future
+ *    devices may expose capabilities for additional framebuffer
+ *    formats.
+ *
+ *    The default GMRFB value is undefined. Drivers must always send
+ *    this command at least once before performing any blit from the
+ *    GMRFB.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGAGuestPtr        ptr;
+   uint32              bytesPerLine;
+   SVGAGMRImageFormat  format;
+} SVGAFifoCmdDefineGMRFB;
+
+
+/*
+ * SVGA_CMD_BLIT_GMRFB_TO_SCREEN --
+ *
+ *    This is a guest-to-host blit. It performs a DMA operation to
+ *    copy a rectangular region of pixels from the current GMRFB to
+ *    one or more Screen Objects.
+ *
+ *    The destination coordinate may be specified relative to a
+ *    screen's origin (if a screen ID is specified) or relative to the
+ *    virtual coordinate system's origin (if the screen ID is
+ *    SVGA_ID_INVALID). The actual destination may span zero or more
+ *    screens, in the case of a virtual destination rect or a rect
+ *    which extends off the edge of the specified screen.
+ *
+ *    This command writes to the screen's "base layer": the underlying
+ *    framebuffer which exists below any cursor or video overlays. No
+ *    action is necessary to explicitly hide or update any overlays
+ *    which exist on top of the updated region.
+ *
+ *    The SVGA device is guaranteed to finish reading from the GMRFB
+ *    by the time any subsequent FENCE commands are reached.
+ *
+ *    This command consumes an annotation. See the
+ *    SVGA_CMD_ANNOTATION_* commands for details.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGASignedPoint  srcOrigin;
+   SVGASignedRect   destRect;
+   uint32           destScreenId;
+} SVGAFifoCmdBlitGMRFBToScreen;
+
+
+/*
+ * SVGA_CMD_BLIT_SCREEN_TO_GMRFB --
+ *
+ *    This is a host-to-guest blit. It performs a DMA operation to
+ *    copy a rectangular region of pixels from a single Screen Object
+ *    back to the current GMRFB.
+ *
+ *    Usage note: This command should be used rarely. It will
+ *    typically be inefficient, but it is necessary for some types of
+ *    synchronization between 3D (GPU) and 2D (CPU) rendering into
+ *    overlapping areas of a screen.
+ *
+ *    The source coordinate is specified relative to a screen's
+ *    origin. The provided screen ID must be valid. If any parameters
+ *    are invalid, the resulting pixel values are undefined.
+ *
+ *    This command reads the screen's "base layer". Overlays like
+ *    video and cursor are not included, but any data which was sent
+ *    using a blit-to-screen primitive will be available, no matter
+ *    whether the data's original source was the GMRFB or the 3D
+ *    acceleration hardware.
+ *
+ *    Note that our guest-to-host blits and host-to-guest blits aren't
+ *    symmetric in their current implementation. While the parameters
+ *    are identical, host-to-guest blits are a lot less featureful.
+ *    They do not support clipping: If the source parameters don't
+ *    fully fit within a screen, the blit fails. They must originate
+ *    from exactly one screen. Virtual coordinates are not directly
+ *    supported.
+ *
+ *    Host-to-guest blits do support the same set of GMRFB formats
+ *    offered by guest-to-host blits.
+ *
+ *    The SVGA device is guaranteed to finish writing to the GMRFB by
+ *    the time any subsequent FENCE commands are reached.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGASignedPoint  destOrigin;
+   SVGASignedRect   srcRect;
+   uint32           srcScreenId;
+} SVGAFifoCmdBlitScreenToGMRFB;
+
+
+/*
+ * SVGA_CMD_ANNOTATION_FILL --
+ *
+ *    This is a blit annotation. This command stores a small piece of
+ *    device state which is consumed by the next blit-to-screen
+ *    command. The state is only cleared by commands which are
+ *    specifically documented as consuming an annotation. Other
+ *    commands (such as ESCAPEs for debugging) may intervene between
+ *    the annotation and its associated blit.
+ *
+ *    This annotation is a promise about the contents of the next
+ *    blit: The video driver is guaranteeing that all pixels in that
+ *    blit will have the same value, specified here as a color in
+ *    SVGAColorBGRX format.
+ *
+ *    The SVGA device can still render the blit correctly even if it
+ *    ignores this annotation, but the annotation may allow it to
+ *    perform the blit more efficiently, for example by ignoring the
+ *    source data and performing a fill in hardware.
+ *
+ *    This annotation is most important for performance when the
+ *    user's display is being remoted over a network connection.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGAColorBGRX  color;
+} SVGAFifoCmdAnnotationFill;
+
+
+/*
+ * SVGA_CMD_ANNOTATION_COPY --
+ *
+ *    This is a blit annotation. See SVGA_CMD_ANNOTATION_FILL for more
+ *    information about annotations.
+ *
+ *    This annotation is a promise about the contents of the next
+ *    blit: The video driver is guaranteeing that all pixels in that
+ *    blit will have the same value as those which already exist at an
+ *    identically-sized region on the same or a different screen.
+ *
+ *    Note that the source pixels for the COPY in this annotation are
+ *    sampled before applying the anqnotation's associated blit. They
+ *    are allowed to overlap with the blit's destination pixels.
+ *
+ *    The copy source rectangle is specified the same way as the blit
+ *    destination: it can be a rectangle which spans zero or more
+ *    screens, specified relative to either a screen or to the virtual
+ *    coordinate system's origin. If the source rectangle includes
+ *    pixels which are not from exactly one screen, the results are
+ *    undefined.
+ *
+ * Availability:
+ *    SVGA_FIFO_CAP_SCREEN_OBJECT
+ */
+
+typedef
+struct {
+   SVGASignedPoint  srcOrigin;
+   uint32           srcScreenId;
+} SVGAFifoCmdAnnotationCopy;
+
+#endif
diff --git a/drivers/gpu/drm/vmwgfx/svga_types.h b/drivers/gpu/drm/vmwgfx/svga_types.h
new file mode 100644 (file)
index 0000000..55836de
--- /dev/null
@@ -0,0 +1,45 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * Silly typedefs for the svga headers. Currently the headers are shared
+ * between all components that talk to svga. And as such the headers are
+ * are in a completely different style and use weird defines.
+ *
+ * This file lets all the ugly be prefixed with svga*.
+ */
+
+#ifndef _SVGA_TYPES_H_
+#define _SVGA_TYPES_H_
+
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef uint8_t uint8;
+typedef int32_t int32;
+typedef bool Bool;
+
+#endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
new file mode 100644 (file)
index 0000000..d6f2d2b
--- /dev/null
@@ -0,0 +1,229 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vmwgfx_drv.h"
+#include "ttm/ttm_bo_driver.h"
+#include "ttm/ttm_placement.h"
+
+static uint32_t vram_placement_flags = TTM_PL_FLAG_VRAM |
+       TTM_PL_FLAG_CACHED;
+
+static uint32_t vram_ne_placement_flags = TTM_PL_FLAG_VRAM |
+       TTM_PL_FLAG_CACHED |
+       TTM_PL_FLAG_NO_EVICT;
+
+static uint32_t sys_placement_flags = TTM_PL_FLAG_SYSTEM |
+       TTM_PL_FLAG_CACHED;
+
+struct ttm_placement vmw_vram_placement = {
+       .fpfn = 0,
+       .lpfn = 0,
+       .num_placement = 1,
+       .placement = &vram_placement_flags,
+       .num_busy_placement = 1,
+       .busy_placement = &vram_placement_flags
+};
+
+struct ttm_placement vmw_vram_ne_placement = {
+       .fpfn = 0,
+       .lpfn = 0,
+       .num_placement = 1,
+       .placement = &vram_ne_placement_flags,
+       .num_busy_placement = 1,
+       .busy_placement = &vram_ne_placement_flags
+};
+
+struct ttm_placement vmw_sys_placement = {
+       .fpfn = 0,
+       .lpfn = 0,
+       .num_placement = 1,
+       .placement = &sys_placement_flags,
+       .num_busy_placement = 1,
+       .busy_placement = &sys_placement_flags
+};
+
+struct vmw_ttm_backend {
+       struct ttm_backend backend;
+};
+
+static int vmw_ttm_populate(struct ttm_backend *backend,
+                           unsigned long num_pages, struct page **pages,
+                           struct page *dummy_read_page)
+{
+       return 0;
+}
+
+static int vmw_ttm_bind(struct ttm_backend *backend, struct ttm_mem_reg *bo_mem)
+{
+       return 0;
+}
+
+static int vmw_ttm_unbind(struct ttm_backend *backend)
+{
+       return 0;
+}
+
+static void vmw_ttm_clear(struct ttm_backend *backend)
+{
+}
+
+static void vmw_ttm_destroy(struct ttm_backend *backend)
+{
+       struct vmw_ttm_backend *vmw_be =
+           container_of(backend, struct vmw_ttm_backend, backend);
+
+       kfree(vmw_be);
+}
+
+static struct ttm_backend_func vmw_ttm_func = {
+       .populate = vmw_ttm_populate,
+       .clear = vmw_ttm_clear,
+       .bind = vmw_ttm_bind,
+       .unbind = vmw_ttm_unbind,
+       .destroy = vmw_ttm_destroy,
+};
+
+struct ttm_backend *vmw_ttm_backend_init(struct ttm_bo_device *bdev)
+{
+       struct vmw_ttm_backend *vmw_be;
+
+       vmw_be = kmalloc(sizeof(*vmw_be), GFP_KERNEL);
+       if (!vmw_be)
+               return NULL;
+
+       vmw_be->backend.func = &vmw_ttm_func;
+
+       return &vmw_be->backend;
+}
+
+int vmw_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags)
+{
+       return 0;
+}
+
+int vmw_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
+                     struct ttm_mem_type_manager *man)
+{
+       struct vmw_private *dev_priv =
+           container_of(bdev, struct vmw_private, bdev);
+
+       switch (type) {
+       case TTM_PL_SYSTEM:
+               /* System memory */
+
+               man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
+               man->available_caching = TTM_PL_MASK_CACHING;
+               man->default_caching = TTM_PL_FLAG_CACHED;
+               break;
+       case TTM_PL_VRAM:
+               /* "On-card" video ram */
+               man->gpu_offset = 0;
+               man->io_offset = dev_priv->vram_start;
+               man->io_size = dev_priv->vram_size;
+               man->flags = TTM_MEMTYPE_FLAG_FIXED |
+                   TTM_MEMTYPE_FLAG_NEEDS_IOREMAP | TTM_MEMTYPE_FLAG_MAPPABLE;
+               man->io_addr = NULL;
+               man->available_caching = TTM_PL_MASK_CACHING;
+               man->default_caching = TTM_PL_FLAG_WC;
+               break;
+       default:
+               DRM_ERROR("Unsupported memory type %u\n", (unsigned)type);
+               return -EINVAL;
+       }
+       return 0;
+}
+
+void vmw_evict_flags(struct ttm_buffer_object *bo,
+                    struct ttm_placement *placement)
+{
+       *placement = vmw_sys_placement;
+}
+
+/**
+ * FIXME: Proper access checks on buffers.
+ */
+
+static int vmw_verify_access(struct ttm_buffer_object *bo, struct file *filp)
+{
+       return 0;
+}
+
+/**
+ * FIXME: We're using the old vmware polling method to sync.
+ * Do this with fences instead.
+ */
+
+static void *vmw_sync_obj_ref(void *sync_obj)
+{
+       return sync_obj;
+}
+
+static void vmw_sync_obj_unref(void **sync_obj)
+{
+       *sync_obj = NULL;
+}
+
+static int vmw_sync_obj_flush(void *sync_obj, void *sync_arg)
+{
+       struct vmw_private *dev_priv = (struct vmw_private *)sync_arg;
+
+       mutex_lock(&dev_priv->hw_mutex);
+       vmw_write(dev_priv, SVGA_REG_SYNC, SVGA_SYNC_GENERIC);
+       mutex_unlock(&dev_priv->hw_mutex);
+       return 0;
+}
+
+static bool vmw_sync_obj_signaled(void *sync_obj, void *sync_arg)
+{
+       struct vmw_private *dev_priv = (struct vmw_private *)sync_arg;
+       uint32_t sequence = (unsigned long) sync_obj;
+
+       return vmw_fence_signaled(dev_priv, sequence);
+}
+
+static int vmw_sync_obj_wait(void *sync_obj, void *sync_arg,
+                            bool lazy, bool interruptible)
+{
+       struct vmw_private *dev_priv = (struct vmw_private *)sync_arg;
+       uint32_t sequence = (unsigned long) sync_obj;
+
+       return vmw_wait_fence(dev_priv, false, sequence, false, 3*HZ);
+}
+
+struct ttm_bo_driver vmw_bo_driver = {
+       .create_ttm_backend_entry = vmw_ttm_backend_init,
+       .invalidate_caches = vmw_invalidate_caches,
+       .init_mem_type = vmw_init_mem_type,
+       .evict_flags = vmw_evict_flags,
+       .move = NULL,
+       .verify_access = vmw_verify_access,
+       .sync_obj_signaled = vmw_sync_obj_signaled,
+       .sync_obj_wait = vmw_sync_obj_wait,
+       .sync_obj_flush = vmw_sync_obj_flush,
+       .sync_obj_unref = vmw_sync_obj_unref,
+       .sync_obj_ref = vmw_sync_obj_ref
+};
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
new file mode 100644 (file)
index 0000000..1db1ef3
--- /dev/null
@@ -0,0 +1,726 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "drmP.h"
+#include "vmwgfx_drv.h"
+#include "ttm/ttm_placement.h"
+#include "ttm/ttm_bo_driver.h"
+#include "ttm/ttm_object.h"
+#include "ttm/ttm_module.h"
+
+#define VMWGFX_DRIVER_NAME "vmwgfx"
+#define VMWGFX_DRIVER_DESC "Linux drm driver for VMware graphics devices"
+#define VMWGFX_CHIP_SVGAII 0
+#define VMW_FB_RESERVATION 0
+
+/**
+ * Fully encoded drm commands. Might move to vmw_drm.h
+ */
+
+#define DRM_IOCTL_VMW_GET_PARAM                                        \
+       DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_GET_PARAM,          \
+                struct drm_vmw_getparam_arg)
+#define DRM_IOCTL_VMW_ALLOC_DMABUF                             \
+       DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_ALLOC_DMABUF,       \
+               union drm_vmw_alloc_dmabuf_arg)
+#define DRM_IOCTL_VMW_UNREF_DMABUF                             \
+       DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_UNREF_DMABUF,        \
+               struct drm_vmw_unref_dmabuf_arg)
+#define DRM_IOCTL_VMW_CURSOR_BYPASS                            \
+       DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_CURSOR_BYPASS,       \
+                struct drm_vmw_cursor_bypass_arg)
+
+#define DRM_IOCTL_VMW_CONTROL_STREAM                           \
+       DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_CONTROL_STREAM,      \
+                struct drm_vmw_control_stream_arg)
+#define DRM_IOCTL_VMW_CLAIM_STREAM                             \
+       DRM_IOR(DRM_COMMAND_BASE + DRM_VMW_CLAIM_STREAM,        \
+                struct drm_vmw_stream_arg)
+#define DRM_IOCTL_VMW_UNREF_STREAM                             \
+       DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_UNREF_STREAM,        \
+                struct drm_vmw_stream_arg)
+
+#define DRM_IOCTL_VMW_CREATE_CONTEXT                           \
+       DRM_IOR(DRM_COMMAND_BASE + DRM_VMW_CREATE_CONTEXT,      \
+               struct drm_vmw_context_arg)
+#define DRM_IOCTL_VMW_UNREF_CONTEXT                            \
+       DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_UNREF_CONTEXT,       \
+               struct drm_vmw_context_arg)
+#define DRM_IOCTL_VMW_CREATE_SURFACE                           \
+       DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_CREATE_SURFACE,     \
+                union drm_vmw_surface_create_arg)
+#define DRM_IOCTL_VMW_UNREF_SURFACE                            \
+       DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_UNREF_SURFACE,       \
+                struct drm_vmw_surface_arg)
+#define DRM_IOCTL_VMW_REF_SURFACE                              \
+       DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_REF_SURFACE,        \
+                union drm_vmw_surface_reference_arg)
+#define DRM_IOCTL_VMW_EXECBUF                                  \
+       DRM_IOW(DRM_COMMAND_BASE + DRM_VMW_EXECBUF,             \
+               struct drm_vmw_execbuf_arg)
+#define DRM_IOCTL_VMW_FIFO_DEBUG                               \
+       DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_FIFO_DEBUG,         \
+                struct drm_vmw_fifo_debug_arg)
+#define DRM_IOCTL_VMW_FENCE_WAIT                               \
+       DRM_IOWR(DRM_COMMAND_BASE + DRM_VMW_FENCE_WAIT,         \
+                struct drm_vmw_fence_wait_arg)
+
+
+/**
+ * The core DRM version of this macro doesn't account for
+ * DRM_COMMAND_BASE.
+ */
+
+#define VMW_IOCTL_DEF(ioctl, func, flags) \
+       [DRM_IOCTL_NR(ioctl) - DRM_COMMAND_BASE] = {ioctl, flags, func}
+
+/**
+ * Ioctl definitions.
+ */
+
+static struct drm_ioctl_desc vmw_ioctls[] = {
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_GET_PARAM, vmw_getparam_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_ALLOC_DMABUF, vmw_dmabuf_alloc_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_UNREF_DMABUF, vmw_dmabuf_unref_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_CURSOR_BYPASS,
+                     vmw_kms_cursor_bypass_ioctl,
+                     DRM_MASTER | DRM_CONTROL_ALLOW | DRM_UNLOCKED),
+
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_CONTROL_STREAM, vmw_overlay_ioctl,
+                     DRM_MASTER | DRM_CONTROL_ALLOW | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_CLAIM_STREAM, vmw_stream_claim_ioctl,
+                     DRM_MASTER | DRM_CONTROL_ALLOW | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_UNREF_STREAM, vmw_stream_unref_ioctl,
+                     DRM_MASTER | DRM_CONTROL_ALLOW | DRM_UNLOCKED),
+
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_CREATE_CONTEXT, vmw_context_define_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_UNREF_CONTEXT, vmw_context_destroy_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_CREATE_SURFACE, vmw_surface_define_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_UNREF_SURFACE, vmw_surface_destroy_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_REF_SURFACE, vmw_surface_reference_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_EXECBUF, vmw_execbuf_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_FIFO_DEBUG, vmw_fifo_debug_ioctl,
+                     DRM_AUTH | DRM_ROOT_ONLY | DRM_MASTER | DRM_UNLOCKED),
+       VMW_IOCTL_DEF(DRM_IOCTL_VMW_FENCE_WAIT, vmw_fence_wait_ioctl,
+                     DRM_AUTH | DRM_UNLOCKED)
+};
+
+static struct pci_device_id vmw_pci_id_list[] = {
+       {0x15ad, 0x0405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VMWGFX_CHIP_SVGAII},
+       {0, 0, 0}
+};
+
+static char *vmw_devname = "vmwgfx";
+
+static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
+static void vmw_master_init(struct vmw_master *);
+
+static void vmw_print_capabilities(uint32_t capabilities)
+{
+       DRM_INFO("Capabilities:\n");
+       if (capabilities & SVGA_CAP_RECT_COPY)
+               DRM_INFO("  Rect copy.\n");
+       if (capabilities & SVGA_CAP_CURSOR)
+               DRM_INFO("  Cursor.\n");
+       if (capabilities & SVGA_CAP_CURSOR_BYPASS)
+               DRM_INFO("  Cursor bypass.\n");
+       if (capabilities & SVGA_CAP_CURSOR_BYPASS_2)
+               DRM_INFO("  Cursor bypass 2.\n");
+       if (capabilities & SVGA_CAP_8BIT_EMULATION)
+               DRM_INFO("  8bit emulation.\n");
+       if (capabilities & SVGA_CAP_ALPHA_CURSOR)
+               DRM_INFO("  Alpha cursor.\n");
+       if (capabilities & SVGA_CAP_3D)
+               DRM_INFO("  3D.\n");
+       if (capabilities & SVGA_CAP_EXTENDED_FIFO)
+               DRM_INFO("  Extended Fifo.\n");
+       if (capabilities & SVGA_CAP_MULTIMON)
+               DRM_INFO("  Multimon.\n");
+       if (capabilities & SVGA_CAP_PITCHLOCK)
+               DRM_INFO("  Pitchlock.\n");
+       if (capabilities & SVGA_CAP_IRQMASK)
+               DRM_INFO("  Irq mask.\n");
+       if (capabilities & SVGA_CAP_DISPLAY_TOPOLOGY)
+               DRM_INFO("  Display Topology.\n");
+       if (capabilities & SVGA_CAP_GMR)
+               DRM_INFO("  GMR.\n");
+       if (capabilities & SVGA_CAP_TRACES)
+               DRM_INFO("  Traces.\n");
+}
+
+static int vmw_request_device(struct vmw_private *dev_priv)
+{
+       int ret;
+
+       vmw_kms_save_vga(dev_priv);
+
+       ret = vmw_fifo_init(dev_priv, &dev_priv->fifo);
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Unable to initialize FIFO.\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static void vmw_release_device(struct vmw_private *dev_priv)
+{
+       vmw_fifo_release(dev_priv, &dev_priv->fifo);
+       vmw_kms_restore_vga(dev_priv);
+}
+
+
+static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
+{
+       struct vmw_private *dev_priv;
+       int ret;
+
+       dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
+       if (unlikely(dev_priv == NULL)) {
+               DRM_ERROR("Failed allocating a device private struct.\n");
+               return -ENOMEM;
+       }
+       memset(dev_priv, 0, sizeof(*dev_priv));
+
+       dev_priv->dev = dev;
+       dev_priv->vmw_chipset = chipset;
+       mutex_init(&dev_priv->hw_mutex);
+       mutex_init(&dev_priv->cmdbuf_mutex);
+       rwlock_init(&dev_priv->resource_lock);
+       idr_init(&dev_priv->context_idr);
+       idr_init(&dev_priv->surface_idr);
+       idr_init(&dev_priv->stream_idr);
+       ida_init(&dev_priv->gmr_ida);
+       mutex_init(&dev_priv->init_mutex);
+       init_waitqueue_head(&dev_priv->fence_queue);
+       init_waitqueue_head(&dev_priv->fifo_queue);
+       atomic_set(&dev_priv->fence_queue_waiters, 0);
+       atomic_set(&dev_priv->fifo_queue_waiters, 0);
+       INIT_LIST_HEAD(&dev_priv->gmr_lru);
+
+       dev_priv->io_start = pci_resource_start(dev->pdev, 0);
+       dev_priv->vram_start = pci_resource_start(dev->pdev, 1);
+       dev_priv->mmio_start = pci_resource_start(dev->pdev, 2);
+
+       mutex_lock(&dev_priv->hw_mutex);
+       dev_priv->capabilities = vmw_read(dev_priv, SVGA_REG_CAPABILITIES);
+
+       if (dev_priv->capabilities & SVGA_CAP_GMR) {
+               dev_priv->max_gmr_descriptors =
+                       vmw_read(dev_priv,
+                                SVGA_REG_GMR_MAX_DESCRIPTOR_LENGTH);
+               dev_priv->max_gmr_ids =
+                       vmw_read(dev_priv, SVGA_REG_GMR_MAX_IDS);
+       }
+
+       dev_priv->vram_size = vmw_read(dev_priv, SVGA_REG_VRAM_SIZE);
+       dev_priv->mmio_size = vmw_read(dev_priv, SVGA_REG_MEM_SIZE);
+       dev_priv->fb_max_width = vmw_read(dev_priv, SVGA_REG_MAX_WIDTH);
+       dev_priv->fb_max_height = vmw_read(dev_priv, SVGA_REG_MAX_HEIGHT);
+
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       vmw_print_capabilities(dev_priv->capabilities);
+
+       if (dev_priv->capabilities & SVGA_CAP_GMR) {
+               DRM_INFO("Max GMR ids is %u\n",
+                        (unsigned)dev_priv->max_gmr_ids);
+               DRM_INFO("Max GMR descriptors is %u\n",
+                        (unsigned)dev_priv->max_gmr_descriptors);
+       }
+       DRM_INFO("VRAM at 0x%08x size is %u kiB\n",
+                dev_priv->vram_start, dev_priv->vram_size / 1024);
+       DRM_INFO("MMIO at 0x%08x size is %u kiB\n",
+                dev_priv->mmio_start, dev_priv->mmio_size / 1024);
+
+       ret = vmw_ttm_global_init(dev_priv);
+       if (unlikely(ret != 0))
+               goto out_err0;
+
+
+       vmw_master_init(&dev_priv->fbdev_master);
+       ttm_lock_set_kill(&dev_priv->fbdev_master.lock, false, SIGTERM);
+       dev_priv->active_master = &dev_priv->fbdev_master;
+
+
+       ret = ttm_bo_device_init(&dev_priv->bdev,
+                                dev_priv->bo_global_ref.ref.object,
+                                &vmw_bo_driver, VMWGFX_FILE_PAGE_OFFSET,
+                                false);
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Failed initializing TTM buffer object driver.\n");
+               goto out_err1;
+       }
+
+       ret = ttm_bo_init_mm(&dev_priv->bdev, TTM_PL_VRAM,
+                            (dev_priv->vram_size >> PAGE_SHIFT));
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Failed initializing memory manager for VRAM.\n");
+               goto out_err2;
+       }
+
+       dev_priv->mmio_mtrr = drm_mtrr_add(dev_priv->mmio_start,
+                                          dev_priv->mmio_size, DRM_MTRR_WC);
+
+       dev_priv->mmio_virt = ioremap_wc(dev_priv->mmio_start,
+                                        dev_priv->mmio_size);
+
+       if (unlikely(dev_priv->mmio_virt == NULL)) {
+               ret = -ENOMEM;
+               DRM_ERROR("Failed mapping MMIO.\n");
+               goto out_err3;
+       }
+
+       dev_priv->tdev = ttm_object_device_init
+           (dev_priv->mem_global_ref.object, 12);
+
+       if (unlikely(dev_priv->tdev == NULL)) {
+               DRM_ERROR("Unable to initialize TTM object management.\n");
+               ret = -ENOMEM;
+               goto out_err4;
+       }
+
+       dev->dev_private = dev_priv;
+
+       if (!dev->devname)
+               dev->devname = vmw_devname;
+
+       if (dev_priv->capabilities & SVGA_CAP_IRQMASK) {
+               ret = drm_irq_install(dev);
+               if (unlikely(ret != 0)) {
+                       DRM_ERROR("Failed installing irq: %d\n", ret);
+                       goto out_no_irq;
+               }
+       }
+
+       ret = pci_request_regions(dev->pdev, "vmwgfx probe");
+       dev_priv->stealth = (ret != 0);
+       if (dev_priv->stealth) {
+               /**
+                * Request at least the mmio PCI resource.
+                */
+
+               DRM_INFO("It appears like vesafb is loaded. "
+                        "Ignore above error if any. Entering stealth mode.\n");
+               ret = pci_request_region(dev->pdev, 2, "vmwgfx stealth probe");
+               if (unlikely(ret != 0)) {
+                       DRM_ERROR("Failed reserving the SVGA MMIO resource.\n");
+                       goto out_no_device;
+               }
+               vmw_kms_init(dev_priv);
+               vmw_overlay_init(dev_priv);
+       } else {
+               ret = vmw_request_device(dev_priv);
+               if (unlikely(ret != 0))
+                       goto out_no_device;
+               vmw_kms_init(dev_priv);
+               vmw_overlay_init(dev_priv);
+               vmw_fb_init(dev_priv);
+       }
+
+       return 0;
+
+out_no_device:
+       if (dev_priv->capabilities & SVGA_CAP_IRQMASK)
+               drm_irq_uninstall(dev_priv->dev);
+       if (dev->devname == vmw_devname)
+               dev->devname = NULL;
+out_no_irq:
+       ttm_object_device_release(&dev_priv->tdev);
+out_err4:
+       iounmap(dev_priv->mmio_virt);
+out_err3:
+       drm_mtrr_del(dev_priv->mmio_mtrr, dev_priv->mmio_start,
+                    dev_priv->mmio_size, DRM_MTRR_WC);
+       (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
+out_err2:
+       (void)ttm_bo_device_release(&dev_priv->bdev);
+out_err1:
+       vmw_ttm_global_release(dev_priv);
+out_err0:
+       ida_destroy(&dev_priv->gmr_ida);
+       idr_destroy(&dev_priv->surface_idr);
+       idr_destroy(&dev_priv->context_idr);
+       idr_destroy(&dev_priv->stream_idr);
+       kfree(dev_priv);
+       return ret;
+}
+
+static int vmw_driver_unload(struct drm_device *dev)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+
+       DRM_INFO(VMWGFX_DRIVER_NAME " unload.\n");
+
+       if (!dev_priv->stealth) {
+               vmw_fb_close(dev_priv);
+               vmw_kms_close(dev_priv);
+               vmw_overlay_close(dev_priv);
+               vmw_release_device(dev_priv);
+               pci_release_regions(dev->pdev);
+       } else {
+               vmw_kms_close(dev_priv);
+               vmw_overlay_close(dev_priv);
+               pci_release_region(dev->pdev, 2);
+       }
+       if (dev_priv->capabilities & SVGA_CAP_IRQMASK)
+               drm_irq_uninstall(dev_priv->dev);
+       if (dev->devname == vmw_devname)
+               dev->devname = NULL;
+       ttm_object_device_release(&dev_priv->tdev);
+       iounmap(dev_priv->mmio_virt);
+       drm_mtrr_del(dev_priv->mmio_mtrr, dev_priv->mmio_start,
+                    dev_priv->mmio_size, DRM_MTRR_WC);
+       (void)ttm_bo_clean_mm(&dev_priv->bdev, TTM_PL_VRAM);
+       (void)ttm_bo_device_release(&dev_priv->bdev);
+       vmw_ttm_global_release(dev_priv);
+       ida_destroy(&dev_priv->gmr_ida);
+       idr_destroy(&dev_priv->surface_idr);
+       idr_destroy(&dev_priv->context_idr);
+       idr_destroy(&dev_priv->stream_idr);
+
+       kfree(dev_priv);
+
+       return 0;
+}
+
+static void vmw_postclose(struct drm_device *dev,
+                        struct drm_file *file_priv)
+{
+       struct vmw_fpriv *vmw_fp;
+
+       vmw_fp = vmw_fpriv(file_priv);
+       ttm_object_file_release(&vmw_fp->tfile);
+       if (vmw_fp->locked_master)
+               drm_master_put(&vmw_fp->locked_master);
+       kfree(vmw_fp);
+}
+
+static int vmw_driver_open(struct drm_device *dev, struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_fpriv *vmw_fp;
+       int ret = -ENOMEM;
+
+       vmw_fp = kzalloc(sizeof(*vmw_fp), GFP_KERNEL);
+       if (unlikely(vmw_fp == NULL))
+               return ret;
+
+       vmw_fp->tfile = ttm_object_file_init(dev_priv->tdev, 10);
+       if (unlikely(vmw_fp->tfile == NULL))
+               goto out_no_tfile;
+
+       file_priv->driver_priv = vmw_fp;
+
+       if (unlikely(dev_priv->bdev.dev_mapping == NULL))
+               dev_priv->bdev.dev_mapping =
+                       file_priv->filp->f_path.dentry->d_inode->i_mapping;
+
+       return 0;
+
+out_no_tfile:
+       kfree(vmw_fp);
+       return ret;
+}
+
+static long vmw_unlocked_ioctl(struct file *filp, unsigned int cmd,
+                              unsigned long arg)
+{
+       struct drm_file *file_priv = filp->private_data;
+       struct drm_device *dev = file_priv->minor->dev;
+       unsigned int nr = DRM_IOCTL_NR(cmd);
+
+       /*
+        * Do extra checking on driver private ioctls.
+        */
+
+       if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END)
+           && (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) {
+               struct drm_ioctl_desc *ioctl =
+                   &vmw_ioctls[nr - DRM_COMMAND_BASE];
+
+               if (unlikely(ioctl->cmd != cmd)) {
+                       DRM_ERROR("Invalid command format, ioctl %d\n",
+                                 nr - DRM_COMMAND_BASE);
+                       return -EINVAL;
+               }
+       }
+
+       return drm_ioctl(filp, cmd, arg);
+}
+
+static int vmw_firstopen(struct drm_device *dev)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       dev_priv->is_opened = true;
+
+       return 0;
+}
+
+static void vmw_lastclose(struct drm_device *dev)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct drm_crtc *crtc;
+       struct drm_mode_set set;
+       int ret;
+
+       /**
+        * Do nothing on the lastclose call from drm_unload.
+        */
+
+       if (!dev_priv->is_opened)
+               return;
+
+       dev_priv->is_opened = false;
+       set.x = 0;
+       set.y = 0;
+       set.fb = NULL;
+       set.mode = NULL;
+       set.connectors = NULL;
+       set.num_connectors = 0;
+
+       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+               set.crtc = crtc;
+               ret = crtc->funcs->set_config(&set);
+               WARN_ON(ret != 0);
+       }
+
+}
+
+static void vmw_master_init(struct vmw_master *vmaster)
+{
+       ttm_lock_init(&vmaster->lock);
+}
+
+static int vmw_master_create(struct drm_device *dev,
+                            struct drm_master *master)
+{
+       struct vmw_master *vmaster;
+
+       DRM_INFO("Master create.\n");
+       vmaster = kzalloc(sizeof(*vmaster), GFP_KERNEL);
+       if (unlikely(vmaster == NULL))
+               return -ENOMEM;
+
+       ttm_lock_init(&vmaster->lock);
+       ttm_lock_set_kill(&vmaster->lock, true, SIGTERM);
+       master->driver_priv = vmaster;
+
+       return 0;
+}
+
+static void vmw_master_destroy(struct drm_device *dev,
+                              struct drm_master *master)
+{
+       struct vmw_master *vmaster = vmw_master(master);
+
+       DRM_INFO("Master destroy.\n");
+       master->driver_priv = NULL;
+       kfree(vmaster);
+}
+
+
+static int vmw_master_set(struct drm_device *dev,
+                         struct drm_file *file_priv,
+                         bool from_open)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv);
+       struct vmw_master *active = dev_priv->active_master;
+       struct vmw_master *vmaster = vmw_master(file_priv->master);
+       int ret = 0;
+
+       DRM_INFO("Master set.\n");
+       if (dev_priv->stealth) {
+               ret = vmw_request_device(dev_priv);
+               if (unlikely(ret != 0))
+                       return ret;
+       }
+
+       if (active) {
+               BUG_ON(active != &dev_priv->fbdev_master);
+               ret = ttm_vt_lock(&active->lock, false, vmw_fp->tfile);
+               if (unlikely(ret != 0))
+                       goto out_no_active_lock;
+
+               ttm_lock_set_kill(&active->lock, true, SIGTERM);
+               ret = ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM);
+               if (unlikely(ret != 0)) {
+                       DRM_ERROR("Unable to clean VRAM on "
+                                 "master drop.\n");
+               }
+
+               dev_priv->active_master = NULL;
+       }
+
+       ttm_lock_set_kill(&vmaster->lock, false, SIGTERM);
+       if (!from_open) {
+               ttm_vt_unlock(&vmaster->lock);
+               BUG_ON(vmw_fp->locked_master != file_priv->master);
+               drm_master_put(&vmw_fp->locked_master);
+       }
+
+       dev_priv->active_master = vmaster;
+
+       return 0;
+
+out_no_active_lock:
+       vmw_release_device(dev_priv);
+       return ret;
+}
+
+static void vmw_master_drop(struct drm_device *dev,
+                           struct drm_file *file_priv,
+                           bool from_release)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv);
+       struct vmw_master *vmaster = vmw_master(file_priv->master);
+       int ret;
+
+       DRM_INFO("Master drop.\n");
+
+       /**
+        * Make sure the master doesn't disappear while we have
+        * it locked.
+        */
+
+       vmw_fp->locked_master = drm_master_get(file_priv->master);
+       ret = ttm_vt_lock(&vmaster->lock, false, vmw_fp->tfile);
+
+       if (unlikely((ret != 0))) {
+               DRM_ERROR("Unable to lock TTM at VT switch.\n");
+               drm_master_put(&vmw_fp->locked_master);
+       }
+
+       ttm_lock_set_kill(&vmaster->lock, true, SIGTERM);
+
+       if (dev_priv->stealth) {
+               ret = ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM);
+               if (unlikely(ret != 0))
+                       DRM_ERROR("Unable to clean VRAM on master drop.\n");
+               vmw_release_device(dev_priv);
+       }
+       dev_priv->active_master = &dev_priv->fbdev_master;
+       ttm_lock_set_kill(&dev_priv->fbdev_master.lock, false, SIGTERM);
+       ttm_vt_unlock(&dev_priv->fbdev_master.lock);
+
+       if (!dev_priv->stealth)
+               vmw_fb_on(dev_priv);
+}
+
+
+static void vmw_remove(struct pci_dev *pdev)
+{
+       struct drm_device *dev = pci_get_drvdata(pdev);
+
+       drm_put_dev(dev);
+}
+
+static struct drm_driver driver = {
+       .driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
+       DRIVER_MODESET,
+       .load = vmw_driver_load,
+       .unload = vmw_driver_unload,
+       .firstopen = vmw_firstopen,
+       .lastclose = vmw_lastclose,
+       .irq_preinstall = vmw_irq_preinstall,
+       .irq_postinstall = vmw_irq_postinstall,
+       .irq_uninstall = vmw_irq_uninstall,
+       .irq_handler = vmw_irq_handler,
+       .reclaim_buffers_locked = NULL,
+       .get_map_ofs = drm_core_get_map_ofs,
+       .get_reg_ofs = drm_core_get_reg_ofs,
+       .ioctls = vmw_ioctls,
+       .num_ioctls = DRM_ARRAY_SIZE(vmw_ioctls),
+       .dma_quiescent = NULL,  /*vmw_dma_quiescent, */
+       .master_create = vmw_master_create,
+       .master_destroy = vmw_master_destroy,
+       .master_set = vmw_master_set,
+       .master_drop = vmw_master_drop,
+       .open = vmw_driver_open,
+       .postclose = vmw_postclose,
+       .fops = {
+                .owner = THIS_MODULE,
+                .open = drm_open,
+                .release = drm_release,
+                .unlocked_ioctl = vmw_unlocked_ioctl,
+                .mmap = vmw_mmap,
+                .poll = drm_poll,
+                .fasync = drm_fasync,
+#if defined(CONFIG_COMPAT)
+                .compat_ioctl = drm_compat_ioctl,
+#endif
+                },
+       .pci_driver = {
+                      .name = VMWGFX_DRIVER_NAME,
+                      .id_table = vmw_pci_id_list,
+                      .probe = vmw_probe,
+                      .remove = vmw_remove
+                      },
+       .name = VMWGFX_DRIVER_NAME,
+       .desc = VMWGFX_DRIVER_DESC,
+       .date = VMWGFX_DRIVER_DATE,
+       .major = VMWGFX_DRIVER_MAJOR,
+       .minor = VMWGFX_DRIVER_MINOR,
+       .patchlevel = VMWGFX_DRIVER_PATCHLEVEL
+};
+
+static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
+{
+       return drm_get_dev(pdev, ent, &driver);
+}
+
+static int __init vmwgfx_init(void)
+{
+       int ret;
+       ret = drm_init(&driver);
+       if (ret)
+               DRM_ERROR("Failed initializing DRM.\n");
+       return ret;
+}
+
+static void __exit vmwgfx_exit(void)
+{
+       drm_exit(&driver);
+}
+
+module_init(vmwgfx_init);
+module_exit(vmwgfx_exit);
+
+MODULE_AUTHOR("VMware Inc. and others");
+MODULE_DESCRIPTION("Standalone drm driver for the VMware SVGA device");
+MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
new file mode 100644 (file)
index 0000000..e61bd85
--- /dev/null
@@ -0,0 +1,513 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _VMWGFX_DRV_H_
+#define _VMWGFX_DRV_H_
+
+#include "vmwgfx_reg.h"
+#include "drmP.h"
+#include "vmwgfx_drm.h"
+#include "drm_hashtab.h"
+#include "ttm/ttm_bo_driver.h"
+#include "ttm/ttm_object.h"
+#include "ttm/ttm_lock.h"
+#include "ttm/ttm_execbuf_util.h"
+#include "ttm/ttm_module.h"
+
+#define VMWGFX_DRIVER_DATE "20090724"
+#define VMWGFX_DRIVER_MAJOR 0
+#define VMWGFX_DRIVER_MINOR 1
+#define VMWGFX_DRIVER_PATCHLEVEL 2
+#define VMWGFX_FILE_PAGE_OFFSET 0x00100000
+#define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
+#define VMWGFX_MAX_RELOCATIONS 2048
+#define VMWGFX_MAX_GMRS 2048
+
+struct vmw_fpriv {
+       struct drm_master *locked_master;
+       struct ttm_object_file *tfile;
+};
+
+struct vmw_dma_buffer {
+       struct ttm_buffer_object base;
+       struct list_head validate_list;
+       struct list_head gmr_lru;
+       uint32_t gmr_id;
+       bool gmr_bound;
+       uint32_t cur_validate_node;
+       bool on_validate_list;
+};
+
+struct vmw_resource {
+       struct kref kref;
+       struct vmw_private *dev_priv;
+       struct idr *idr;
+       int id;
+       enum ttm_object_type res_type;
+       bool avail;
+       void (*hw_destroy) (struct vmw_resource *res);
+       void (*res_free) (struct vmw_resource *res);
+
+       /* TODO is a generic snooper needed? */
+#if 0
+       void (*snoop)(struct vmw_resource *res,
+                     struct ttm_object_file *tfile,
+                     SVGA3dCmdHeader *header);
+       void *snoop_priv;
+#endif
+};
+
+struct vmw_cursor_snooper {
+       struct drm_crtc *crtc;
+       size_t age;
+       uint32_t *image;
+};
+
+struct vmw_surface {
+       struct vmw_resource res;
+       uint32_t flags;
+       uint32_t format;
+       uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
+       struct drm_vmw_size *sizes;
+       uint32_t num_sizes;
+
+       /* TODO so far just a extra pointer */
+       struct vmw_cursor_snooper snooper;
+};
+
+struct vmw_fifo_state {
+       unsigned long reserved_size;
+       __le32 *dynamic_buffer;
+       __le32 *static_buffer;
+       __le32 *last_buffer;
+       uint32_t last_data_size;
+       uint32_t last_buffer_size;
+       bool last_buffer_add;
+       unsigned long static_buffer_size;
+       bool using_bounce_buffer;
+       uint32_t capabilities;
+       struct rw_semaphore rwsem;
+};
+
+struct vmw_relocation {
+       SVGAGuestPtr *location;
+       uint32_t index;
+};
+
+struct vmw_sw_context{
+       struct ida bo_list;
+       uint32_t last_cid;
+       bool cid_valid;
+       uint32_t last_sid;
+       uint32_t sid_translation;
+       bool sid_valid;
+       struct ttm_object_file *tfile;
+       struct list_head validate_nodes;
+       struct vmw_relocation relocs[VMWGFX_MAX_RELOCATIONS];
+       uint32_t cur_reloc;
+       struct ttm_validate_buffer val_bufs[VMWGFX_MAX_GMRS];
+       uint32_t cur_val_buf;
+};
+
+struct vmw_legacy_display;
+struct vmw_overlay;
+
+struct vmw_master {
+       struct ttm_lock lock;
+};
+
+struct vmw_private {
+       struct ttm_bo_device bdev;
+       struct ttm_bo_global_ref bo_global_ref;
+       struct ttm_global_reference mem_global_ref;
+
+       struct vmw_fifo_state fifo;
+
+       struct drm_device *dev;
+       unsigned long vmw_chipset;
+       unsigned int io_start;
+       uint32_t vram_start;
+       uint32_t vram_size;
+       uint32_t mmio_start;
+       uint32_t mmio_size;
+       uint32_t fb_max_width;
+       uint32_t fb_max_height;
+       __le32 __iomem *mmio_virt;
+       int mmio_mtrr;
+       uint32_t capabilities;
+       uint32_t max_gmr_descriptors;
+       uint32_t max_gmr_ids;
+       struct mutex hw_mutex;
+
+       /*
+        * VGA registers.
+        */
+
+       uint32_t vga_width;
+       uint32_t vga_height;
+       uint32_t vga_depth;
+       uint32_t vga_bpp;
+       uint32_t vga_pseudo;
+       uint32_t vga_red_mask;
+       uint32_t vga_blue_mask;
+       uint32_t vga_green_mask;
+
+       /*
+        * Framebuffer info.
+        */
+
+       void *fb_info;
+       struct vmw_legacy_display *ldu_priv;
+       struct vmw_overlay *overlay_priv;
+
+       /*
+        * Context and surface management.
+        */
+
+       rwlock_t resource_lock;
+       struct idr context_idr;
+       struct idr surface_idr;
+       struct idr stream_idr;
+
+       /*
+        * Block lastclose from racing with firstopen.
+        */
+
+       struct mutex init_mutex;
+
+       /*
+        * A resource manager for kernel-only surfaces and
+        * contexts.
+        */
+
+       struct ttm_object_device *tdev;
+
+       /*
+        * Fencing and IRQs.
+        */
+
+       uint32_t fence_seq;
+       wait_queue_head_t fence_queue;
+       wait_queue_head_t fifo_queue;
+       atomic_t fence_queue_waiters;
+       atomic_t fifo_queue_waiters;
+       uint32_t last_read_sequence;
+       spinlock_t irq_lock;
+
+       /*
+        * Device state
+        */
+
+       uint32_t traces_state;
+       uint32_t enable_state;
+       uint32_t config_done_state;
+
+       /**
+        * Execbuf
+        */
+       /**
+        * Protected by the cmdbuf mutex.
+        */
+
+       struct vmw_sw_context ctx;
+       uint32_t val_seq;
+       struct mutex cmdbuf_mutex;
+
+       /**
+        * GMR management. Protected by the lru spinlock.
+        */
+
+       struct ida gmr_ida;
+       struct list_head gmr_lru;
+
+
+       /**
+        * Operating mode.
+        */
+
+       bool stealth;
+       bool is_opened;
+
+       /**
+        * Master management.
+        */
+
+       struct vmw_master *active_master;
+       struct vmw_master fbdev_master;
+};
+
+static inline struct vmw_private *vmw_priv(struct drm_device *dev)
+{
+       return (struct vmw_private *)dev->dev_private;
+}
+
+static inline struct vmw_fpriv *vmw_fpriv(struct drm_file *file_priv)
+{
+       return (struct vmw_fpriv *)file_priv->driver_priv;
+}
+
+static inline struct vmw_master *vmw_master(struct drm_master *master)
+{
+       return (struct vmw_master *) master->driver_priv;
+}
+
+static inline void vmw_write(struct vmw_private *dev_priv,
+                            unsigned int offset, uint32_t value)
+{
+       outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT);
+       outl(value, dev_priv->io_start + VMWGFX_VALUE_PORT);
+}
+
+static inline uint32_t vmw_read(struct vmw_private *dev_priv,
+                               unsigned int offset)
+{
+       uint32_t val;
+
+       outl(offset, dev_priv->io_start + VMWGFX_INDEX_PORT);
+       val = inl(dev_priv->io_start + VMWGFX_VALUE_PORT);
+       return val;
+}
+
+/**
+ * GMR utilities - vmwgfx_gmr.c
+ */
+
+extern int vmw_gmr_bind(struct vmw_private *dev_priv,
+                       struct ttm_buffer_object *bo);
+extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id);
+
+/**
+ * Resource utilities - vmwgfx_resource.c
+ */
+
+extern struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv);
+extern void vmw_resource_unreference(struct vmw_resource **p_res);
+extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res);
+extern int vmw_context_destroy_ioctl(struct drm_device *dev, void *data,
+                                    struct drm_file *file_priv);
+extern int vmw_context_define_ioctl(struct drm_device *dev, void *data,
+                                   struct drm_file *file_priv);
+extern int vmw_context_check(struct vmw_private *dev_priv,
+                            struct ttm_object_file *tfile,
+                            int id);
+extern void vmw_surface_res_free(struct vmw_resource *res);
+extern int vmw_surface_init(struct vmw_private *dev_priv,
+                           struct vmw_surface *srf,
+                           void (*res_free) (struct vmw_resource *res));
+extern int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv,
+                                         struct ttm_object_file *tfile,
+                                         uint32_t handle,
+                                         struct vmw_surface **out);
+extern int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data,
+                                    struct drm_file *file_priv);
+extern int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
+                                   struct drm_file *file_priv);
+extern int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
+                                      struct drm_file *file_priv);
+extern int vmw_surface_check(struct vmw_private *dev_priv,
+                            struct ttm_object_file *tfile,
+                            uint32_t handle, int *id);
+extern void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo);
+extern int vmw_dmabuf_init(struct vmw_private *dev_priv,
+                          struct vmw_dma_buffer *vmw_bo,
+                          size_t size, struct ttm_placement *placement,
+                          bool interuptable,
+                          void (*bo_free) (struct ttm_buffer_object *bo));
+extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
+                                 struct drm_file *file_priv);
+extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data,
+                                 struct drm_file *file_priv);
+extern uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo,
+                                        uint32_t cur_validate_node);
+extern void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo);
+extern int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
+                                 uint32_t id, struct vmw_dma_buffer **out);
+extern uint32_t vmw_dmabuf_gmr(struct ttm_buffer_object *bo);
+extern void vmw_dmabuf_set_gmr(struct ttm_buffer_object *bo, uint32_t id);
+extern int vmw_gmr_id_alloc(struct vmw_private *dev_priv, uint32_t *p_id);
+extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,
+                                      struct vmw_dma_buffer *bo);
+extern int vmw_dmabuf_from_vram(struct vmw_private *vmw_priv,
+                               struct vmw_dma_buffer *bo);
+extern int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
+                                 struct drm_file *file_priv);
+extern int vmw_stream_unref_ioctl(struct drm_device *dev, void *data,
+                                 struct drm_file *file_priv);
+extern int vmw_user_stream_lookup(struct vmw_private *dev_priv,
+                                 struct ttm_object_file *tfile,
+                                 uint32_t *inout_id,
+                                 struct vmw_resource **out);
+
+
+/**
+ * Misc Ioctl functionality - vmwgfx_ioctl.c
+ */
+
+extern int vmw_getparam_ioctl(struct drm_device *dev, void *data,
+                             struct drm_file *file_priv);
+extern int vmw_fifo_debug_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *file_priv);
+
+/**
+ * Fifo utilities - vmwgfx_fifo.c
+ */
+
+extern int vmw_fifo_init(struct vmw_private *dev_priv,
+                        struct vmw_fifo_state *fifo);
+extern void vmw_fifo_release(struct vmw_private *dev_priv,
+                            struct vmw_fifo_state *fifo);
+extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes);
+extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes);
+extern int vmw_fifo_send_fence(struct vmw_private *dev_priv,
+                              uint32_t *sequence);
+extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason);
+extern int vmw_fifo_mmap(struct file *filp, struct vm_area_struct *vma);
+
+/**
+ * TTM glue - vmwgfx_ttm_glue.c
+ */
+
+extern int vmw_ttm_global_init(struct vmw_private *dev_priv);
+extern void vmw_ttm_global_release(struct vmw_private *dev_priv);
+extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma);
+
+/**
+ * TTM buffer object driver - vmwgfx_buffer.c
+ */
+
+extern struct ttm_placement vmw_vram_placement;
+extern struct ttm_placement vmw_vram_ne_placement;
+extern struct ttm_placement vmw_sys_placement;
+extern struct ttm_bo_driver vmw_bo_driver;
+extern int vmw_dma_quiescent(struct drm_device *dev);
+
+/**
+ * Command submission - vmwgfx_execbuf.c
+ */
+
+extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
+                            struct drm_file *file_priv);
+
+/**
+ * IRQs and wating - vmwgfx_irq.c
+ */
+
+extern irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS);
+extern int vmw_wait_fence(struct vmw_private *dev_priv, bool lazy,
+                         uint32_t sequence, bool interruptible,
+                         unsigned long timeout);
+extern void vmw_irq_preinstall(struct drm_device *dev);
+extern int vmw_irq_postinstall(struct drm_device *dev);
+extern void vmw_irq_uninstall(struct drm_device *dev);
+extern bool vmw_fence_signaled(struct vmw_private *dev_priv,
+                              uint32_t sequence);
+extern int vmw_fence_wait_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *file_priv);
+extern int vmw_fallback_wait(struct vmw_private *dev_priv,
+                            bool lazy,
+                            bool fifo_idle,
+                            uint32_t sequence,
+                            bool interruptible,
+                            unsigned long timeout);
+
+/**
+ * Kernel framebuffer - vmwgfx_fb.c
+ */
+
+int vmw_fb_init(struct vmw_private *vmw_priv);
+int vmw_fb_close(struct vmw_private *dev_priv);
+int vmw_fb_off(struct vmw_private *vmw_priv);
+int vmw_fb_on(struct vmw_private *vmw_priv);
+
+/**
+ * Kernel modesetting - vmwgfx_kms.c
+ */
+
+int vmw_kms_init(struct vmw_private *dev_priv);
+int vmw_kms_close(struct vmw_private *dev_priv);
+int vmw_kms_save_vga(struct vmw_private *vmw_priv);
+int vmw_kms_restore_vga(struct vmw_private *vmw_priv);
+int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *file_priv);
+void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv);
+void vmw_kms_cursor_snoop(struct vmw_surface *srf,
+                         struct ttm_object_file *tfile,
+                         struct ttm_buffer_object *bo,
+                         SVGA3dCmdHeader *header);
+
+/**
+ * Overlay control - vmwgfx_overlay.c
+ */
+
+int vmw_overlay_init(struct vmw_private *dev_priv);
+int vmw_overlay_close(struct vmw_private *dev_priv);
+int vmw_overlay_ioctl(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv);
+int vmw_overlay_stop_all(struct vmw_private *dev_priv);
+int vmw_overlay_resume_all(struct vmw_private *dev_priv);
+int vmw_overlay_pause_all(struct vmw_private *dev_priv);
+int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out);
+int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id);
+int vmw_overlay_num_overlays(struct vmw_private *dev_priv);
+int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
+
+/**
+ * Inline helper functions
+ */
+
+static inline void vmw_surface_unreference(struct vmw_surface **srf)
+{
+       struct vmw_surface *tmp_srf = *srf;
+       struct vmw_resource *res = &tmp_srf->res;
+       *srf = NULL;
+
+       vmw_resource_unreference(&res);
+}
+
+static inline struct vmw_surface *vmw_surface_reference(struct vmw_surface *srf)
+{
+       (void) vmw_resource_reference(&srf->res);
+       return srf;
+}
+
+static inline void vmw_dmabuf_unreference(struct vmw_dma_buffer **buf)
+{
+       struct vmw_dma_buffer *tmp_buf = *buf;
+       struct ttm_buffer_object *bo = &tmp_buf->base;
+       *buf = NULL;
+
+       ttm_bo_unref(&bo);
+}
+
+static inline struct vmw_dma_buffer *vmw_dmabuf_reference(struct vmw_dma_buffer *buf)
+{
+       if (ttm_bo_reference(&buf->base))
+               return buf;
+       return NULL;
+}
+
+#endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
new file mode 100644 (file)
index 0000000..2e92da5
--- /dev/null
@@ -0,0 +1,621 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vmwgfx_drv.h"
+#include "vmwgfx_reg.h"
+#include "ttm/ttm_bo_api.h"
+#include "ttm/ttm_placement.h"
+
+static int vmw_cmd_invalid(struct vmw_private *dev_priv,
+                          struct vmw_sw_context *sw_context,
+                          SVGA3dCmdHeader *header)
+{
+       return capable(CAP_SYS_ADMIN) ? : -EINVAL;
+}
+
+static int vmw_cmd_ok(struct vmw_private *dev_priv,
+                     struct vmw_sw_context *sw_context,
+                     SVGA3dCmdHeader *header)
+{
+       return 0;
+}
+
+static int vmw_cmd_cid_check(struct vmw_private *dev_priv,
+                            struct vmw_sw_context *sw_context,
+                            SVGA3dCmdHeader *header)
+{
+       struct vmw_cid_cmd {
+               SVGA3dCmdHeader header;
+               __le32 cid;
+       } *cmd;
+       int ret;
+
+       cmd = container_of(header, struct vmw_cid_cmd, header);
+       if (likely(sw_context->cid_valid && cmd->cid == sw_context->last_cid))
+               return 0;
+
+       ret = vmw_context_check(dev_priv, sw_context->tfile, cmd->cid);
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Could not find or use context %u\n",
+                         (unsigned) cmd->cid);
+               return ret;
+       }
+
+       sw_context->last_cid = cmd->cid;
+       sw_context->cid_valid = true;
+
+       return 0;
+}
+
+static int vmw_cmd_sid_check(struct vmw_private *dev_priv,
+                            struct vmw_sw_context *sw_context,
+                            uint32_t *sid)
+{
+       if (*sid == SVGA3D_INVALID_ID)
+               return 0;
+
+       if (unlikely((!sw_context->sid_valid  ||
+                     *sid != sw_context->last_sid))) {
+               int real_id;
+               int ret = vmw_surface_check(dev_priv, sw_context->tfile,
+                                           *sid, &real_id);
+
+               if (unlikely(ret != 0)) {
+                       DRM_ERROR("Could ot find or use surface 0x%08x "
+                                 "address 0x%08lx\n",
+                                 (unsigned int) *sid,
+                                 (unsigned long) sid);
+                       return ret;
+               }
+
+               sw_context->last_sid = *sid;
+               sw_context->sid_valid = true;
+               *sid = real_id;
+               sw_context->sid_translation = real_id;
+       } else
+               *sid = sw_context->sid_translation;
+
+       return 0;
+}
+
+
+static int vmw_cmd_set_render_target_check(struct vmw_private *dev_priv,
+                                          struct vmw_sw_context *sw_context,
+                                          SVGA3dCmdHeader *header)
+{
+       struct vmw_sid_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdSetRenderTarget body;
+       } *cmd;
+       int ret;
+
+       ret = vmw_cmd_cid_check(dev_priv, sw_context, header);
+       if (unlikely(ret != 0))
+               return ret;
+
+       cmd = container_of(header, struct vmw_sid_cmd, header);
+       ret = vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.target.sid);
+       return ret;
+}
+
+static int vmw_cmd_surface_copy_check(struct vmw_private *dev_priv,
+                                     struct vmw_sw_context *sw_context,
+                                     SVGA3dCmdHeader *header)
+{
+       struct vmw_sid_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdSurfaceCopy body;
+       } *cmd;
+       int ret;
+
+       cmd = container_of(header, struct vmw_sid_cmd, header);
+       ret = vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.src.sid);
+       if (unlikely(ret != 0))
+               return ret;
+       return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.dest.sid);
+}
+
+static int vmw_cmd_stretch_blt_check(struct vmw_private *dev_priv,
+                                    struct vmw_sw_context *sw_context,
+                                    SVGA3dCmdHeader *header)
+{
+       struct vmw_sid_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdSurfaceStretchBlt body;
+       } *cmd;
+       int ret;
+
+       cmd = container_of(header, struct vmw_sid_cmd, header);
+       ret = vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.src.sid);
+       if (unlikely(ret != 0))
+               return ret;
+       return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.dest.sid);
+}
+
+static int vmw_cmd_blt_surf_screen_check(struct vmw_private *dev_priv,
+                                        struct vmw_sw_context *sw_context,
+                                        SVGA3dCmdHeader *header)
+{
+       struct vmw_sid_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdBlitSurfaceToScreen body;
+       } *cmd;
+
+       cmd = container_of(header, struct vmw_sid_cmd, header);
+       return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.srcImage.sid);
+}
+
+static int vmw_cmd_present_check(struct vmw_private *dev_priv,
+                                struct vmw_sw_context *sw_context,
+                                SVGA3dCmdHeader *header)
+{
+       struct vmw_sid_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdPresent body;
+       } *cmd;
+
+       cmd = container_of(header, struct vmw_sid_cmd, header);
+       return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.sid);
+}
+
+static int vmw_cmd_dma(struct vmw_private *dev_priv,
+                      struct vmw_sw_context *sw_context,
+                      SVGA3dCmdHeader *header)
+{
+       uint32_t handle;
+       struct vmw_dma_buffer *vmw_bo = NULL;
+       struct ttm_buffer_object *bo;
+       struct vmw_surface *srf = NULL;
+       struct vmw_dma_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdSurfaceDMA dma;
+       } *cmd;
+       struct vmw_relocation *reloc;
+       int ret;
+       uint32_t cur_validate_node;
+       struct ttm_validate_buffer *val_buf;
+
+       cmd = container_of(header, struct vmw_dma_cmd, header);
+       handle = cmd->dma.guest.ptr.gmrId;
+       ret = vmw_user_dmabuf_lookup(sw_context->tfile, handle, &vmw_bo);
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Could not find or use GMR region.\n");
+               return -EINVAL;
+       }
+       bo = &vmw_bo->base;
+
+       if (unlikely(sw_context->cur_reloc >= VMWGFX_MAX_RELOCATIONS)) {
+               DRM_ERROR("Max number of DMA commands per submission"
+                         " exceeded\n");
+               ret = -EINVAL;
+               goto out_no_reloc;
+       }
+
+       reloc = &sw_context->relocs[sw_context->cur_reloc++];
+       reloc->location = &cmd->dma.guest.ptr;
+
+       cur_validate_node = vmw_dmabuf_validate_node(bo, sw_context->cur_val_buf);
+       if (unlikely(cur_validate_node >= VMWGFX_MAX_GMRS)) {
+               DRM_ERROR("Max number of DMA buffers per submission"
+                         " exceeded.\n");
+               ret = -EINVAL;
+               goto out_no_reloc;
+       }
+
+       reloc->index = cur_validate_node;
+       if (unlikely(cur_validate_node == sw_context->cur_val_buf)) {
+               val_buf = &sw_context->val_bufs[cur_validate_node];
+               val_buf->bo = ttm_bo_reference(bo);
+               val_buf->new_sync_obj_arg = (void *) dev_priv;
+               list_add_tail(&val_buf->head, &sw_context->validate_nodes);
+               ++sw_context->cur_val_buf;
+       }
+
+       ret = vmw_user_surface_lookup_handle(dev_priv, sw_context->tfile,
+                                            cmd->dma.host.sid, &srf);
+       if (ret) {
+               DRM_ERROR("could not find surface\n");
+               goto out_no_reloc;
+       }
+
+       /**
+        * Patch command stream with device SID.
+        */
+
+       cmd->dma.host.sid = srf->res.id;
+       vmw_kms_cursor_snoop(srf, sw_context->tfile, bo, header);
+       /**
+        * FIXME: May deadlock here when called from the
+        * command parsing code.
+        */
+       vmw_surface_unreference(&srf);
+
+out_no_reloc:
+       vmw_dmabuf_unreference(&vmw_bo);
+       return ret;
+}
+
+static int vmw_cmd_draw(struct vmw_private *dev_priv,
+                       struct vmw_sw_context *sw_context,
+                       SVGA3dCmdHeader *header)
+{
+       struct vmw_draw_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdDrawPrimitives body;
+       } *cmd;
+       SVGA3dVertexDecl *decl = (SVGA3dVertexDecl *)(
+               (unsigned long)header + sizeof(*cmd));
+       SVGA3dPrimitiveRange *range;
+       uint32_t i;
+       uint32_t maxnum;
+       int ret;
+
+       ret = vmw_cmd_cid_check(dev_priv, sw_context, header);
+       if (unlikely(ret != 0))
+               return ret;
+
+       cmd = container_of(header, struct vmw_draw_cmd, header);
+       maxnum = (header->size - sizeof(cmd->body)) / sizeof(*decl);
+
+       if (unlikely(cmd->body.numVertexDecls > maxnum)) {
+               DRM_ERROR("Illegal number of vertex declarations.\n");
+               return -EINVAL;
+       }
+
+       for (i = 0; i < cmd->body.numVertexDecls; ++i, ++decl) {
+               ret = vmw_cmd_sid_check(dev_priv, sw_context,
+                                       &decl->array.surfaceId);
+               if (unlikely(ret != 0))
+                       return ret;
+       }
+
+       maxnum = (header->size - sizeof(cmd->body) -
+                 cmd->body.numVertexDecls * sizeof(*decl)) / sizeof(*range);
+       if (unlikely(cmd->body.numRanges > maxnum)) {
+               DRM_ERROR("Illegal number of index ranges.\n");
+               return -EINVAL;
+       }
+
+       range = (SVGA3dPrimitiveRange *) decl;
+       for (i = 0; i < cmd->body.numRanges; ++i, ++range) {
+               ret = vmw_cmd_sid_check(dev_priv, sw_context,
+                                       &range->indexArray.surfaceId);
+               if (unlikely(ret != 0))
+                       return ret;
+       }
+       return 0;
+}
+
+
+static int vmw_cmd_tex_state(struct vmw_private *dev_priv,
+                            struct vmw_sw_context *sw_context,
+                            SVGA3dCmdHeader *header)
+{
+       struct vmw_tex_state_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdSetTextureState state;
+       };
+
+       SVGA3dTextureState *last_state = (SVGA3dTextureState *)
+         ((unsigned long) header + header->size + sizeof(header));
+       SVGA3dTextureState *cur_state = (SVGA3dTextureState *)
+               ((unsigned long) header + sizeof(struct vmw_tex_state_cmd));
+       int ret;
+
+       ret = vmw_cmd_cid_check(dev_priv, sw_context, header);
+       if (unlikely(ret != 0))
+               return ret;
+
+       for (; cur_state < last_state; ++cur_state) {
+               if (likely(cur_state->name != SVGA3D_TS_BIND_TEXTURE))
+                       continue;
+
+               ret = vmw_cmd_sid_check(dev_priv, sw_context,
+                                       &cur_state->value);
+               if (unlikely(ret != 0))
+                       return ret;
+       }
+
+       return 0;
+}
+
+
+typedef int (*vmw_cmd_func) (struct vmw_private *,
+                            struct vmw_sw_context *,
+                            SVGA3dCmdHeader *);
+
+#define VMW_CMD_DEF(cmd, func) \
+       [cmd - SVGA_3D_CMD_BASE] = func
+
+static vmw_cmd_func vmw_cmd_funcs[SVGA_3D_CMD_MAX] = {
+       VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_DEFINE, &vmw_cmd_invalid),
+       VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_DESTROY, &vmw_cmd_invalid),
+       VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_COPY, &vmw_cmd_surface_copy_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_STRETCHBLT, &vmw_cmd_stretch_blt_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SURFACE_DMA, &vmw_cmd_dma),
+       VMW_CMD_DEF(SVGA_3D_CMD_CONTEXT_DEFINE, &vmw_cmd_invalid),
+       VMW_CMD_DEF(SVGA_3D_CMD_CONTEXT_DESTROY, &vmw_cmd_invalid),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETTRANSFORM, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETZRANGE, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETRENDERSTATE, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETRENDERTARGET,
+                   &vmw_cmd_set_render_target_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETTEXTURESTATE, &vmw_cmd_tex_state),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETMATERIAL, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETLIGHTDATA, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETLIGHTENABLED, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETVIEWPORT, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETCLIPPLANE, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_CLEAR, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_PRESENT, &vmw_cmd_present_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SHADER_DEFINE, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SHADER_DESTROY, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SET_SHADER, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_SET_SHADER_CONST, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_DRAW_PRIMITIVES, &vmw_cmd_draw),
+       VMW_CMD_DEF(SVGA_3D_CMD_SETSCISSORRECT, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_BEGIN_QUERY, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_END_QUERY, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_WAIT_FOR_QUERY, &vmw_cmd_cid_check),
+       VMW_CMD_DEF(SVGA_3D_CMD_PRESENT_READBACK, &vmw_cmd_ok),
+       VMW_CMD_DEF(SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN,
+                   &vmw_cmd_blt_surf_screen_check)
+};
+
+static int vmw_cmd_check(struct vmw_private *dev_priv,
+                        struct vmw_sw_context *sw_context,
+                        void *buf, uint32_t *size)
+{
+       uint32_t cmd_id;
+       uint32_t size_remaining = *size;
+       SVGA3dCmdHeader *header = (SVGA3dCmdHeader *) buf;
+       int ret;
+
+       cmd_id = ((uint32_t *)buf)[0];
+       if (cmd_id == SVGA_CMD_UPDATE) {
+               *size = 5 << 2;
+               return 0;
+       }
+
+       cmd_id = le32_to_cpu(header->id);
+       *size = le32_to_cpu(header->size) + sizeof(SVGA3dCmdHeader);
+
+       cmd_id -= SVGA_3D_CMD_BASE;
+       if (unlikely(*size > size_remaining))
+               goto out_err;
+
+       if (unlikely(cmd_id >= SVGA_3D_CMD_MAX - SVGA_3D_CMD_BASE))
+               goto out_err;
+
+       ret = vmw_cmd_funcs[cmd_id](dev_priv, sw_context, header);
+       if (unlikely(ret != 0))
+               goto out_err;
+
+       return 0;
+out_err:
+       DRM_ERROR("Illegal / Invalid SVGA3D command: %d\n",
+                 cmd_id + SVGA_3D_CMD_BASE);
+       return -EINVAL;
+}
+
+static int vmw_cmd_check_all(struct vmw_private *dev_priv,
+                            struct vmw_sw_context *sw_context,
+                            void *buf, uint32_t size)
+{
+       int32_t cur_size = size;
+       int ret;
+
+       while (cur_size > 0) {
+               size = cur_size;
+               ret = vmw_cmd_check(dev_priv, sw_context, buf, &size);
+               if (unlikely(ret != 0))
+                       return ret;
+               buf = (void *)((unsigned long) buf + size);
+               cur_size -= size;
+       }
+
+       if (unlikely(cur_size != 0)) {
+               DRM_ERROR("Command verifier out of sync.\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static void vmw_free_relocations(struct vmw_sw_context *sw_context)
+{
+       sw_context->cur_reloc = 0;
+}
+
+static void vmw_apply_relocations(struct vmw_sw_context *sw_context)
+{
+       uint32_t i;
+       struct vmw_relocation *reloc;
+       struct ttm_validate_buffer *validate;
+       struct ttm_buffer_object *bo;
+
+       for (i = 0; i < sw_context->cur_reloc; ++i) {
+               reloc = &sw_context->relocs[i];
+               validate = &sw_context->val_bufs[reloc->index];
+               bo = validate->bo;
+               reloc->location->offset += bo->offset;
+               reloc->location->gmrId = vmw_dmabuf_gmr(bo);
+       }
+       vmw_free_relocations(sw_context);
+}
+
+static void vmw_clear_validations(struct vmw_sw_context *sw_context)
+{
+       struct ttm_validate_buffer *entry, *next;
+
+       list_for_each_entry_safe(entry, next, &sw_context->validate_nodes,
+                                head) {
+               list_del(&entry->head);
+               vmw_dmabuf_validate_clear(entry->bo);
+               ttm_bo_unref(&entry->bo);
+               sw_context->cur_val_buf--;
+       }
+       BUG_ON(sw_context->cur_val_buf != 0);
+}
+
+static int vmw_validate_single_buffer(struct vmw_private *dev_priv,
+                                     struct ttm_buffer_object *bo)
+{
+       int ret;
+
+       if (vmw_dmabuf_gmr(bo) != SVGA_GMR_NULL)
+               return 0;
+
+       ret = vmw_gmr_bind(dev_priv, bo);
+       if (likely(ret == 0 || ret == -ERESTARTSYS))
+               return ret;
+
+
+       ret = ttm_bo_validate(bo, &vmw_vram_placement, true, false);
+       return ret;
+}
+
+
+static int vmw_validate_buffers(struct vmw_private *dev_priv,
+                               struct vmw_sw_context *sw_context)
+{
+       struct ttm_validate_buffer *entry;
+       int ret;
+
+       list_for_each_entry(entry, &sw_context->validate_nodes, head) {
+               ret = vmw_validate_single_buffer(dev_priv, entry->bo);
+               if (unlikely(ret != 0))
+                       return ret;
+       }
+       return 0;
+}
+
+int vmw_execbuf_ioctl(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct drm_vmw_execbuf_arg *arg = (struct drm_vmw_execbuf_arg *)data;
+       struct drm_vmw_fence_rep fence_rep;
+       struct drm_vmw_fence_rep __user *user_fence_rep;
+       int ret;
+       void *user_cmd;
+       void *cmd;
+       uint32_t sequence;
+       struct vmw_sw_context *sw_context = &dev_priv->ctx;
+       struct vmw_master *vmaster = vmw_master(file_priv->master);
+
+       ret = ttm_read_lock(&vmaster->lock, true);
+       if (unlikely(ret != 0))
+               return ret;
+
+       ret = mutex_lock_interruptible(&dev_priv->cmdbuf_mutex);
+       if (unlikely(ret != 0)) {
+               ret = -ERESTARTSYS;
+               goto out_no_cmd_mutex;
+       }
+
+       cmd = vmw_fifo_reserve(dev_priv, arg->command_size);
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Failed reserving fifo space for commands.\n");
+               ret = -ENOMEM;
+               goto out_unlock;
+       }
+
+       user_cmd = (void __user *)(unsigned long)arg->commands;
+       ret = copy_from_user(cmd, user_cmd, arg->command_size);
+
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Failed copying commands.\n");
+               goto out_commit;
+       }
+
+       sw_context->tfile = vmw_fpriv(file_priv)->tfile;
+       sw_context->cid_valid = false;
+       sw_context->sid_valid = false;
+       sw_context->cur_reloc = 0;
+       sw_context->cur_val_buf = 0;
+
+       INIT_LIST_HEAD(&sw_context->validate_nodes);
+
+       ret = vmw_cmd_check_all(dev_priv, sw_context, cmd, arg->command_size);
+       if (unlikely(ret != 0))
+               goto out_err;
+       ret = ttm_eu_reserve_buffers(&sw_context->validate_nodes,
+                                    dev_priv->val_seq++);
+       if (unlikely(ret != 0))
+               goto out_err;
+
+       ret = vmw_validate_buffers(dev_priv, sw_context);
+       if (unlikely(ret != 0))
+               goto out_err;
+
+       vmw_apply_relocations(sw_context);
+       vmw_fifo_commit(dev_priv, arg->command_size);
+
+       ret = vmw_fifo_send_fence(dev_priv, &sequence);
+
+       ttm_eu_fence_buffer_objects(&sw_context->validate_nodes,
+                                   (void *)(unsigned long) sequence);
+       vmw_clear_validations(sw_context);
+       mutex_unlock(&dev_priv->cmdbuf_mutex);
+
+       /*
+        * This error is harmless, because if fence submission fails,
+        * vmw_fifo_send_fence will sync.
+        */
+
+       if (ret != 0)
+               DRM_ERROR("Fence submission error. Syncing.\n");
+
+       fence_rep.error = ret;
+       fence_rep.fence_seq = (uint64_t) sequence;
+
+       user_fence_rep = (struct drm_vmw_fence_rep __user *)
+           (unsigned long)arg->fence_rep;
+
+       /*
+        * copy_to_user errors will be detected by user space not
+        * seeing fence_rep::error filled in.
+        */
+
+       ret = copy_to_user(user_fence_rep, &fence_rep, sizeof(fence_rep));
+
+       vmw_kms_cursor_post_execbuf(dev_priv);
+       ttm_read_unlock(&vmaster->lock);
+       return 0;
+out_err:
+       vmw_free_relocations(sw_context);
+       ttm_eu_backoff_reservation(&sw_context->validate_nodes);
+       vmw_clear_validations(sw_context);
+out_commit:
+       vmw_fifo_commit(dev_priv, 0);
+out_unlock:
+       mutex_unlock(&dev_priv->cmdbuf_mutex);
+out_no_cmd_mutex:
+       ttm_read_unlock(&vmaster->lock);
+       return ret;
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
new file mode 100644 (file)
index 0000000..641dde7
--- /dev/null
@@ -0,0 +1,742 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2007 David Airlie
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "drmP.h"
+#include "vmwgfx_drv.h"
+
+#include "ttm/ttm_placement.h"
+
+#define VMW_DIRTY_DELAY (HZ / 30)
+
+struct vmw_fb_par {
+       struct vmw_private *vmw_priv;
+
+       void *vmalloc;
+
+       struct vmw_dma_buffer *vmw_bo;
+       struct ttm_bo_kmap_obj map;
+
+       u32 pseudo_palette[17];
+
+       unsigned depth;
+       unsigned bpp;
+
+       unsigned max_width;
+       unsigned max_height;
+
+       void *bo_ptr;
+       unsigned bo_size;
+       bool bo_iowrite;
+
+       struct {
+               spinlock_t lock;
+               bool active;
+               unsigned x1;
+               unsigned y1;
+               unsigned x2;
+               unsigned y2;
+       } dirty;
+};
+
+static int vmw_fb_setcolreg(unsigned regno, unsigned red, unsigned green,
+                           unsigned blue, unsigned transp,
+                           struct fb_info *info)
+{
+       struct vmw_fb_par *par = info->par;
+       u32 *pal = par->pseudo_palette;
+
+       if (regno > 15) {
+               DRM_ERROR("Bad regno %u.\n", regno);
+               return 1;
+       }
+
+       switch (par->depth) {
+       case 24:
+       case 32:
+               pal[regno] = ((red & 0xff00) << 8) |
+                             (green & 0xff00) |
+                            ((blue  & 0xff00) >> 8);
+               break;
+       default:
+               DRM_ERROR("Bad depth %u, bpp %u.\n", par->depth, par->bpp);
+               return 1;
+       }
+
+       return 0;
+}
+
+static int vmw_fb_check_var(struct fb_var_screeninfo *var,
+                           struct fb_info *info)
+{
+       int depth = var->bits_per_pixel;
+       struct vmw_fb_par *par = info->par;
+       struct vmw_private *vmw_priv = par->vmw_priv;
+
+       switch (var->bits_per_pixel) {
+       case 32:
+               depth = (var->transp.length > 0) ? 32 : 24;
+               break;
+       default:
+               DRM_ERROR("Bad bpp %u.\n", var->bits_per_pixel);
+               return -EINVAL;
+       }
+
+       switch (depth) {
+       case 24:
+               var->red.offset = 16;
+               var->green.offset = 8;
+               var->blue.offset = 0;
+               var->red.length = 8;
+               var->green.length = 8;
+               var->blue.length = 8;
+               var->transp.length = 0;
+               var->transp.offset = 0;
+               break;
+       case 32:
+               var->red.offset = 16;
+               var->green.offset = 8;
+               var->blue.offset = 0;
+               var->red.length = 8;
+               var->green.length = 8;
+               var->blue.length = 8;
+               var->transp.length = 8;
+               var->transp.offset = 24;
+               break;
+       default:
+               DRM_ERROR("Bad depth %u.\n", depth);
+               return -EINVAL;
+       }
+
+       /* without multimon its hard to resize */
+       if (!(vmw_priv->capabilities & SVGA_CAP_MULTIMON) &&
+           (var->xres != par->max_width ||
+            var->yres != par->max_height)) {
+               DRM_ERROR("Tried to resize, but we don't have multimon\n");
+               return -EINVAL;
+       }
+
+       if (var->xres > par->max_width ||
+           var->yres > par->max_height) {
+               DRM_ERROR("Requested geom can not fit in framebuffer\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int vmw_fb_set_par(struct fb_info *info)
+{
+       struct vmw_fb_par *par = info->par;
+       struct vmw_private *vmw_priv = par->vmw_priv;
+
+       if (vmw_priv->capabilities & SVGA_CAP_MULTIMON) {
+               vmw_write(vmw_priv, SVGA_REG_NUM_GUEST_DISPLAYS, 1);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_IS_PRIMARY, true);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_X, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_Y, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_WIDTH, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_HEIGHT, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
+
+               vmw_write(vmw_priv, SVGA_REG_ENABLE, 1);
+               vmw_write(vmw_priv, SVGA_REG_WIDTH, par->max_width);
+               vmw_write(vmw_priv, SVGA_REG_HEIGHT, par->max_height);
+               vmw_write(vmw_priv, SVGA_REG_BITS_PER_PIXEL, par->bpp);
+               vmw_write(vmw_priv, SVGA_REG_DEPTH, par->depth);
+               vmw_write(vmw_priv, SVGA_REG_RED_MASK, 0x00ff0000);
+               vmw_write(vmw_priv, SVGA_REG_GREEN_MASK, 0x0000ff00);
+               vmw_write(vmw_priv, SVGA_REG_BLUE_MASK, 0x000000ff);
+
+               /* TODO check if pitch and offset changes */
+
+               vmw_write(vmw_priv, SVGA_REG_NUM_GUEST_DISPLAYS, 1);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_IS_PRIMARY, true);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_X, info->var.xoffset);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_Y, info->var.yoffset);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_WIDTH, info->var.xres);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_HEIGHT, info->var.yres);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
+       } else {
+               vmw_write(vmw_priv, SVGA_REG_WIDTH, info->var.xres);
+               vmw_write(vmw_priv, SVGA_REG_HEIGHT, info->var.yres);
+
+               /* TODO check if pitch and offset changes */
+       }
+
+       return 0;
+}
+
+static int vmw_fb_pan_display(struct fb_var_screeninfo *var,
+                             struct fb_info *info)
+{
+       return 0;
+}
+
+static int vmw_fb_blank(int blank, struct fb_info *info)
+{
+       return 0;
+}
+
+/*
+ * Dirty code
+ */
+
+static void vmw_fb_dirty_flush(struct vmw_fb_par *par)
+{
+       struct vmw_private *vmw_priv = par->vmw_priv;
+       struct fb_info *info = vmw_priv->fb_info;
+       int stride = (info->fix.line_length / 4);
+       int *src = (int *)info->screen_base;
+       __le32 __iomem *vram_mem = par->bo_ptr;
+       unsigned long flags;
+       unsigned x, y, w, h;
+       int i, k;
+       struct {
+               uint32_t header;
+               SVGAFifoCmdUpdate body;
+       } *cmd;
+
+       spin_lock_irqsave(&par->dirty.lock, flags);
+       if (!par->dirty.active) {
+               spin_unlock_irqrestore(&par->dirty.lock, flags);
+               return;
+       }
+       x = par->dirty.x1;
+       y = par->dirty.y1;
+       w = min(par->dirty.x2, info->var.xres) - x;
+       h = min(par->dirty.y2, info->var.yres) - y;
+       par->dirty.x1 = par->dirty.x2 = 0;
+       par->dirty.y1 = par->dirty.y2 = 0;
+       spin_unlock_irqrestore(&par->dirty.lock, flags);
+
+       for (i = y * stride; i < info->fix.smem_len / 4; i += stride) {
+               for (k = i+x; k < i+x+w && k < info->fix.smem_len / 4; k++)
+                       iowrite32(src[k], vram_mem + k);
+       }
+
+#if 0
+       DRM_INFO("%s, (%u, %u) (%ux%u)\n", __func__, x, y, w, h);
+#endif
+
+       cmd = vmw_fifo_reserve(vmw_priv, sizeof(*cmd));
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Fifo reserve failed.\n");
+               return;
+       }
+
+       cmd->header = cpu_to_le32(SVGA_CMD_UPDATE);
+       cmd->body.x = cpu_to_le32(x);
+       cmd->body.y = cpu_to_le32(y);
+       cmd->body.width = cpu_to_le32(w);
+       cmd->body.height = cpu_to_le32(h);
+       vmw_fifo_commit(vmw_priv, sizeof(*cmd));
+}
+
+static void vmw_fb_dirty_mark(struct vmw_fb_par *par,
+                             unsigned x1, unsigned y1,
+                             unsigned width, unsigned height)
+{
+       struct fb_info *info = par->vmw_priv->fb_info;
+       unsigned long flags;
+       unsigned x2 = x1 + width;
+       unsigned y2 = y1 + height;
+
+       spin_lock_irqsave(&par->dirty.lock, flags);
+       if (par->dirty.x1 == par->dirty.x2) {
+               par->dirty.x1 = x1;
+               par->dirty.y1 = y1;
+               par->dirty.x2 = x2;
+               par->dirty.y2 = y2;
+               /* if we are active start the dirty work
+                * we share the work with the defio system */
+               if (par->dirty.active)
+                       schedule_delayed_work(&info->deferred_work, VMW_DIRTY_DELAY);
+       } else {
+               if (x1 < par->dirty.x1)
+                       par->dirty.x1 = x1;
+               if (y1 < par->dirty.y1)
+                       par->dirty.y1 = y1;
+               if (x2 > par->dirty.x2)
+                       par->dirty.x2 = x2;
+               if (y2 > par->dirty.y2)
+                       par->dirty.y2 = y2;
+       }
+       spin_unlock_irqrestore(&par->dirty.lock, flags);
+}
+
+static void vmw_deferred_io(struct fb_info *info,
+                           struct list_head *pagelist)
+{
+       struct vmw_fb_par *par = info->par;
+       unsigned long start, end, min, max;
+       unsigned long flags;
+       struct page *page;
+       int y1, y2;
+
+       min = ULONG_MAX;
+       max = 0;
+       list_for_each_entry(page, pagelist, lru) {
+               start = page->index << PAGE_SHIFT;
+               end = start + PAGE_SIZE - 1;
+               min = min(min, start);
+               max = max(max, end);
+       }
+
+       if (min < max) {
+               y1 = min / info->fix.line_length;
+               y2 = (max / info->fix.line_length) + 1;
+
+               spin_lock_irqsave(&par->dirty.lock, flags);
+               par->dirty.x1 = 0;
+               par->dirty.y1 = y1;
+               par->dirty.x2 = info->var.xres;
+               par->dirty.y2 = y2;
+               spin_unlock_irqrestore(&par->dirty.lock, flags);
+       }
+
+       vmw_fb_dirty_flush(par);
+};
+
+struct fb_deferred_io vmw_defio = {
+       .delay          = VMW_DIRTY_DELAY,
+       .deferred_io    = vmw_deferred_io,
+};
+
+/*
+ * Draw code
+ */
+
+static void vmw_fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
+{
+       cfb_fillrect(info, rect);
+       vmw_fb_dirty_mark(info->par, rect->dx, rect->dy,
+                         rect->width, rect->height);
+}
+
+static void vmw_fb_copyarea(struct fb_info *info, const struct fb_copyarea *region)
+{
+       cfb_copyarea(info, region);
+       vmw_fb_dirty_mark(info->par, region->dx, region->dy,
+                         region->width, region->height);
+}
+
+static void vmw_fb_imageblit(struct fb_info *info, const struct fb_image *image)
+{
+       cfb_imageblit(info, image);
+       vmw_fb_dirty_mark(info->par, image->dx, image->dy,
+                         image->width, image->height);
+}
+
+/*
+ * Bring up code
+ */
+
+static struct fb_ops vmw_fb_ops = {
+       .owner = THIS_MODULE,
+       .fb_check_var = vmw_fb_check_var,
+       .fb_set_par = vmw_fb_set_par,
+       .fb_setcolreg = vmw_fb_setcolreg,
+       .fb_fillrect = vmw_fb_fillrect,
+       .fb_copyarea = vmw_fb_copyarea,
+       .fb_imageblit = vmw_fb_imageblit,
+       .fb_pan_display = vmw_fb_pan_display,
+       .fb_blank = vmw_fb_blank,
+};
+
+static int vmw_fb_create_bo(struct vmw_private *vmw_priv,
+                           size_t size, struct vmw_dma_buffer **out)
+{
+       struct vmw_dma_buffer *vmw_bo;
+       struct ttm_placement ne_placement = vmw_vram_ne_placement;
+       int ret;
+
+       ne_placement.lpfn = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+
+       /* interuptable? */
+       ret = ttm_write_lock(&vmw_priv->fbdev_master.lock, false);
+       if (unlikely(ret != 0))
+               return ret;
+
+       vmw_bo = kmalloc(sizeof(*vmw_bo), GFP_KERNEL);
+       if (!vmw_bo)
+               goto err_unlock;
+
+       ret = vmw_dmabuf_init(vmw_priv, vmw_bo, size,
+                             &ne_placement,
+                             false,
+                             &vmw_dmabuf_bo_free);
+       if (unlikely(ret != 0))
+               goto err_unlock; /* init frees the buffer on failure */
+
+       *out = vmw_bo;
+
+       ttm_write_unlock(&vmw_priv->fbdev_master.lock);
+
+       return 0;
+
+err_unlock:
+       ttm_write_unlock(&vmw_priv->fbdev_master.lock);
+       return ret;
+}
+
+int vmw_fb_init(struct vmw_private *vmw_priv)
+{
+       struct device *device = &vmw_priv->dev->pdev->dev;
+       struct vmw_fb_par *par;
+       struct fb_info *info;
+       unsigned initial_width, initial_height;
+       unsigned fb_width, fb_height;
+       unsigned fb_bbp, fb_depth, fb_offset, fb_pitch, fb_size;
+       int ret;
+
+       initial_width = 800;
+       initial_height = 600;
+
+       fb_bbp = 32;
+       fb_depth = 24;
+
+       if (vmw_priv->capabilities & SVGA_CAP_MULTIMON) {
+               fb_width = min(vmw_priv->fb_max_width, (unsigned)2048);
+               fb_height = min(vmw_priv->fb_max_height, (unsigned)2048);
+       } else {
+               fb_width = min(vmw_priv->fb_max_width, initial_width);
+               fb_height = min(vmw_priv->fb_max_height, initial_height);
+       }
+
+       initial_width = min(fb_width, initial_width);
+       initial_height = min(fb_height, initial_height);
+
+       vmw_write(vmw_priv, SVGA_REG_WIDTH, fb_width);
+       vmw_write(vmw_priv, SVGA_REG_HEIGHT, fb_height);
+       vmw_write(vmw_priv, SVGA_REG_BITS_PER_PIXEL, fb_bbp);
+       vmw_write(vmw_priv, SVGA_REG_DEPTH, fb_depth);
+       vmw_write(vmw_priv, SVGA_REG_RED_MASK, 0x00ff0000);
+       vmw_write(vmw_priv, SVGA_REG_GREEN_MASK, 0x0000ff00);
+       vmw_write(vmw_priv, SVGA_REG_BLUE_MASK, 0x000000ff);
+
+       fb_size = vmw_read(vmw_priv, SVGA_REG_FB_SIZE);
+       fb_offset = vmw_read(vmw_priv, SVGA_REG_FB_OFFSET);
+       fb_pitch = vmw_read(vmw_priv, SVGA_REG_BYTES_PER_LINE);
+
+       DRM_DEBUG("width  %u\n", vmw_read(vmw_priv, SVGA_REG_MAX_WIDTH));
+       DRM_DEBUG("height %u\n", vmw_read(vmw_priv, SVGA_REG_MAX_HEIGHT));
+       DRM_DEBUG("width  %u\n", vmw_read(vmw_priv, SVGA_REG_WIDTH));
+       DRM_DEBUG("height %u\n", vmw_read(vmw_priv, SVGA_REG_HEIGHT));
+       DRM_DEBUG("bpp    %u\n", vmw_read(vmw_priv, SVGA_REG_BITS_PER_PIXEL));
+       DRM_DEBUG("depth  %u\n", vmw_read(vmw_priv, SVGA_REG_DEPTH));
+       DRM_DEBUG("bpl    %u\n", vmw_read(vmw_priv, SVGA_REG_BYTES_PER_LINE));
+       DRM_DEBUG("r mask %08x\n", vmw_read(vmw_priv, SVGA_REG_RED_MASK));
+       DRM_DEBUG("g mask %08x\n", vmw_read(vmw_priv, SVGA_REG_GREEN_MASK));
+       DRM_DEBUG("b mask %08x\n", vmw_read(vmw_priv, SVGA_REG_BLUE_MASK));
+       DRM_DEBUG("fb_offset 0x%08x\n", fb_offset);
+       DRM_DEBUG("fb_pitch  %u\n", fb_pitch);
+       DRM_DEBUG("fb_size   %u kiB\n", fb_size / 1024);
+
+       info = framebuffer_alloc(sizeof(*par), device);
+       if (!info)
+               return -ENOMEM;
+
+       /*
+        * Par
+        */
+       vmw_priv->fb_info = info;
+       par = info->par;
+       par->vmw_priv = vmw_priv;
+       par->depth = fb_depth;
+       par->bpp = fb_bbp;
+       par->vmalloc = NULL;
+       par->max_width = fb_width;
+       par->max_height = fb_height;
+
+       /*
+        * Create buffers and alloc memory
+        */
+       par->vmalloc = vmalloc(fb_size);
+       if (unlikely(par->vmalloc == NULL)) {
+               ret = -ENOMEM;
+               goto err_free;
+       }
+
+       ret = vmw_fb_create_bo(vmw_priv, fb_size, &par->vmw_bo);
+       if (unlikely(ret != 0))
+               goto err_free;
+
+       ret = ttm_bo_kmap(&par->vmw_bo->base,
+                         0,
+                         par->vmw_bo->base.num_pages,
+                         &par->map);
+       if (unlikely(ret != 0))
+               goto err_unref;
+       par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &par->bo_iowrite);
+       par->bo_size = fb_size;
+
+       /*
+        * Fixed and var
+        */
+       strcpy(info->fix.id, "svgadrmfb");
+       info->fix.type = FB_TYPE_PACKED_PIXELS;
+       info->fix.visual = FB_VISUAL_TRUECOLOR;
+       info->fix.type_aux = 0;
+       info->fix.xpanstep = 1; /* doing it in hw */
+       info->fix.ypanstep = 1; /* doing it in hw */
+       info->fix.ywrapstep = 0;
+       info->fix.accel = FB_ACCEL_NONE;
+       info->fix.line_length = fb_pitch;
+
+       info->fix.smem_start = 0;
+       info->fix.smem_len = fb_size;
+
+       info->fix.mmio_start = 0;
+       info->fix.mmio_len = 0;
+
+       info->pseudo_palette = par->pseudo_palette;
+       info->screen_base = par->vmalloc;
+       info->screen_size = fb_size;
+
+       info->flags = FBINFO_DEFAULT;
+       info->fbops = &vmw_fb_ops;
+
+       /* 24 depth per default */
+       info->var.red.offset = 16;
+       info->var.green.offset = 8;
+       info->var.blue.offset = 0;
+       info->var.red.length = 8;
+       info->var.green.length = 8;
+       info->var.blue.length = 8;
+       info->var.transp.offset = 0;
+       info->var.transp.length = 0;
+
+       info->var.xres_virtual = fb_width;
+       info->var.yres_virtual = fb_height;
+       info->var.bits_per_pixel = par->bpp;
+       info->var.xoffset = 0;
+       info->var.yoffset = 0;
+       info->var.activate = FB_ACTIVATE_NOW;
+       info->var.height = -1;
+       info->var.width = -1;
+
+       info->var.xres = initial_width;
+       info->var.yres = initial_height;
+
+#if 0
+       info->pixmap.size = 64*1024;
+       info->pixmap.buf_align = 8;
+       info->pixmap.access_align = 32;
+       info->pixmap.flags = FB_PIXMAP_SYSTEM;
+       info->pixmap.scan_align = 1;
+#else
+       info->pixmap.size = 0;
+       info->pixmap.buf_align = 8;
+       info->pixmap.access_align = 32;
+       info->pixmap.flags = FB_PIXMAP_SYSTEM;
+       info->pixmap.scan_align = 1;
+#endif
+
+       /*
+        * Dirty & Deferred IO
+        */
+       par->dirty.x1 = par->dirty.x2 = 0;
+       par->dirty.y1 = par->dirty.y1 = 0;
+       par->dirty.active = true;
+       spin_lock_init(&par->dirty.lock);
+       info->fbdefio = &vmw_defio;
+       fb_deferred_io_init(info);
+
+       ret = register_framebuffer(info);
+       if (unlikely(ret != 0))
+               goto err_defio;
+
+       return 0;
+
+err_defio:
+       fb_deferred_io_cleanup(info);
+       ttm_bo_kunmap(&par->map);
+err_unref:
+       ttm_bo_unref((struct ttm_buffer_object **)&par->vmw_bo);
+err_free:
+       vfree(par->vmalloc);
+       framebuffer_release(info);
+       vmw_priv->fb_info = NULL;
+
+       return ret;
+}
+
+int vmw_fb_close(struct vmw_private *vmw_priv)
+{
+       struct fb_info *info;
+       struct vmw_fb_par *par;
+       struct ttm_buffer_object *bo;
+
+       if (!vmw_priv->fb_info)
+               return 0;
+
+       info = vmw_priv->fb_info;
+       par = info->par;
+       bo = &par->vmw_bo->base;
+       par->vmw_bo = NULL;
+
+       /* ??? order */
+       fb_deferred_io_cleanup(info);
+       unregister_framebuffer(info);
+
+       ttm_bo_kunmap(&par->map);
+       ttm_bo_unref(&bo);
+
+       vfree(par->vmalloc);
+       framebuffer_release(info);
+
+       return 0;
+}
+
+int vmw_dmabuf_from_vram(struct vmw_private *vmw_priv,
+                        struct vmw_dma_buffer *vmw_bo)
+{
+       struct ttm_buffer_object *bo = &vmw_bo->base;
+       int ret = 0;
+
+       ret = ttm_bo_reserve(bo, false, false, false, 0);
+       if (unlikely(ret != 0))
+               return ret;
+
+       ret = ttm_bo_validate(bo, &vmw_sys_placement, false, false);
+       ttm_bo_unreserve(bo);
+
+       return ret;
+}
+
+int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,
+                               struct vmw_dma_buffer *vmw_bo)
+{
+       struct ttm_buffer_object *bo = &vmw_bo->base;
+       struct ttm_placement ne_placement = vmw_vram_ne_placement;
+       int ret = 0;
+
+       ne_placement.lpfn = bo->num_pages;
+
+       /* interuptable? */
+       ret = ttm_write_lock(&vmw_priv->active_master->lock, false);
+       if (unlikely(ret != 0))
+               return ret;
+
+       ret = ttm_bo_reserve(bo, false, false, false, 0);
+       if (unlikely(ret != 0))
+               goto err_unlock;
+
+       if (vmw_bo->gmr_bound) {
+               vmw_gmr_unbind(vmw_priv, vmw_bo->gmr_id);
+               spin_lock(&bo->glob->lru_lock);
+               ida_remove(&vmw_priv->gmr_ida, vmw_bo->gmr_id);
+               spin_unlock(&bo->glob->lru_lock);
+               vmw_bo->gmr_bound = NULL;
+       }
+
+       ret = ttm_bo_validate(bo, &ne_placement, false, false);
+       ttm_bo_unreserve(bo);
+err_unlock:
+       ttm_write_unlock(&vmw_priv->active_master->lock);
+
+       return ret;
+}
+
+int vmw_fb_off(struct vmw_private *vmw_priv)
+{
+       struct fb_info *info;
+       struct vmw_fb_par *par;
+       unsigned long flags;
+
+       if (!vmw_priv->fb_info)
+               return -EINVAL;
+
+       info = vmw_priv->fb_info;
+       par = info->par;
+
+       spin_lock_irqsave(&par->dirty.lock, flags);
+       par->dirty.active = false;
+       spin_unlock_irqrestore(&par->dirty.lock, flags);
+
+       flush_scheduled_work();
+
+       par->bo_ptr = NULL;
+       ttm_bo_kunmap(&par->map);
+
+       vmw_dmabuf_from_vram(vmw_priv, par->vmw_bo);
+
+       return 0;
+}
+
+int vmw_fb_on(struct vmw_private *vmw_priv)
+{
+       struct fb_info *info;
+       struct vmw_fb_par *par;
+       unsigned long flags;
+       bool dummy;
+       int ret;
+
+       if (!vmw_priv->fb_info)
+               return -EINVAL;
+
+       info = vmw_priv->fb_info;
+       par = info->par;
+
+       /* we are already active */
+       if (par->bo_ptr != NULL)
+               return 0;
+
+       /* Make sure that all overlays are stoped when we take over */
+       vmw_overlay_stop_all(vmw_priv);
+
+       ret = vmw_dmabuf_to_start_of_vram(vmw_priv, par->vmw_bo);
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("could not move buffer to start of VRAM\n");
+               goto err_no_buffer;
+       }
+
+       ret = ttm_bo_kmap(&par->vmw_bo->base,
+                         0,
+                         par->vmw_bo->base.num_pages,
+                         &par->map);
+       BUG_ON(ret != 0);
+       par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &dummy);
+
+       spin_lock_irqsave(&par->dirty.lock, flags);
+       par->dirty.active = true;
+       spin_unlock_irqrestore(&par->dirty.lock, flags);
+
+err_no_buffer:
+       vmw_fb_set_par(info);
+
+       vmw_fb_dirty_mark(par, 0, 0, info->var.xres, info->var.yres);
+
+       /* If there already was stuff dirty we wont
+        * schedule a new work, so lets do it now */
+       schedule_delayed_work(&info->deferred_work, 0);
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
new file mode 100644 (file)
index 0000000..01feb48
--- /dev/null
@@ -0,0 +1,519 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vmwgfx_drv.h"
+#include "drmP.h"
+#include "ttm/ttm_placement.h"
+
+int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
+{
+       __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+       uint32_t max;
+       uint32_t min;
+       uint32_t dummy;
+       int ret;
+
+       fifo->static_buffer_size = VMWGFX_FIFO_STATIC_SIZE;
+       fifo->static_buffer = vmalloc(fifo->static_buffer_size);
+       if (unlikely(fifo->static_buffer == NULL))
+               return -ENOMEM;
+
+       fifo->last_buffer_size = VMWGFX_FIFO_STATIC_SIZE;
+       fifo->last_data_size = 0;
+       fifo->last_buffer_add = false;
+       fifo->last_buffer = vmalloc(fifo->last_buffer_size);
+       if (unlikely(fifo->last_buffer == NULL)) {
+               ret = -ENOMEM;
+               goto out_err;
+       }
+
+       fifo->dynamic_buffer = NULL;
+       fifo->reserved_size = 0;
+       fifo->using_bounce_buffer = false;
+
+       init_rwsem(&fifo->rwsem);
+
+       /*
+        * Allow mapping the first page read-only to user-space.
+        */
+
+       DRM_INFO("width %d\n", vmw_read(dev_priv, SVGA_REG_WIDTH));
+       DRM_INFO("height %d\n", vmw_read(dev_priv, SVGA_REG_HEIGHT));
+       DRM_INFO("bpp %d\n", vmw_read(dev_priv, SVGA_REG_BITS_PER_PIXEL));
+
+       mutex_lock(&dev_priv->hw_mutex);
+       dev_priv->enable_state = vmw_read(dev_priv, SVGA_REG_ENABLE);
+       dev_priv->config_done_state = vmw_read(dev_priv, SVGA_REG_CONFIG_DONE);
+       vmw_write(dev_priv, SVGA_REG_ENABLE, 1);
+
+       min = 4;
+       if (dev_priv->capabilities & SVGA_CAP_EXTENDED_FIFO)
+               min = vmw_read(dev_priv, SVGA_REG_MEM_REGS);
+       min <<= 2;
+
+       if (min < PAGE_SIZE)
+               min = PAGE_SIZE;
+
+       iowrite32(min, fifo_mem + SVGA_FIFO_MIN);
+       iowrite32(dev_priv->mmio_size, fifo_mem + SVGA_FIFO_MAX);
+       wmb();
+       iowrite32(min,  fifo_mem + SVGA_FIFO_NEXT_CMD);
+       iowrite32(min,  fifo_mem + SVGA_FIFO_STOP);
+       iowrite32(0, fifo_mem + SVGA_FIFO_BUSY);
+       mb();
+
+       vmw_write(dev_priv, SVGA_REG_CONFIG_DONE, 1);
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       max = ioread32(fifo_mem + SVGA_FIFO_MAX);
+       min = ioread32(fifo_mem  + SVGA_FIFO_MIN);
+       fifo->capabilities = ioread32(fifo_mem + SVGA_FIFO_CAPABILITIES);
+
+       DRM_INFO("Fifo max 0x%08x min 0x%08x cap 0x%08x\n",
+                (unsigned int) max,
+                (unsigned int) min,
+                (unsigned int) fifo->capabilities);
+
+       dev_priv->fence_seq = (uint32_t) -100;
+       dev_priv->last_read_sequence = (uint32_t) -100;
+       iowrite32(dev_priv->last_read_sequence, fifo_mem + SVGA_FIFO_FENCE);
+
+       return vmw_fifo_send_fence(dev_priv, &dummy);
+out_err:
+       vfree(fifo->static_buffer);
+       fifo->static_buffer = NULL;
+       return ret;
+}
+
+void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason)
+{
+       __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+
+       mutex_lock(&dev_priv->hw_mutex);
+
+       if (unlikely(ioread32(fifo_mem + SVGA_FIFO_BUSY) == 0)) {
+               iowrite32(1, fifo_mem + SVGA_FIFO_BUSY);
+               vmw_write(dev_priv, SVGA_REG_SYNC, reason);
+       }
+
+       mutex_unlock(&dev_priv->hw_mutex);
+}
+
+void vmw_fifo_release(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
+{
+       __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+
+       mutex_lock(&dev_priv->hw_mutex);
+
+       while (vmw_read(dev_priv, SVGA_REG_BUSY) != 0)
+               vmw_write(dev_priv, SVGA_REG_SYNC, SVGA_SYNC_GENERIC);
+
+       dev_priv->last_read_sequence = ioread32(fifo_mem + SVGA_FIFO_FENCE);
+
+       vmw_write(dev_priv, SVGA_REG_CONFIG_DONE,
+                 dev_priv->config_done_state);
+       vmw_write(dev_priv, SVGA_REG_ENABLE,
+                 dev_priv->enable_state);
+
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       if (likely(fifo->last_buffer != NULL)) {
+               vfree(fifo->last_buffer);
+               fifo->last_buffer = NULL;
+       }
+
+       if (likely(fifo->static_buffer != NULL)) {
+               vfree(fifo->static_buffer);
+               fifo->static_buffer = NULL;
+       }
+
+       if (likely(fifo->dynamic_buffer != NULL)) {
+               vfree(fifo->dynamic_buffer);
+               fifo->dynamic_buffer = NULL;
+       }
+}
+
+static bool vmw_fifo_is_full(struct vmw_private *dev_priv, uint32_t bytes)
+{
+       __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+       uint32_t max = ioread32(fifo_mem + SVGA_FIFO_MAX);
+       uint32_t next_cmd = ioread32(fifo_mem + SVGA_FIFO_NEXT_CMD);
+       uint32_t min = ioread32(fifo_mem + SVGA_FIFO_MIN);
+       uint32_t stop = ioread32(fifo_mem + SVGA_FIFO_STOP);
+
+       return ((max - next_cmd) + (stop - min) <= bytes);
+}
+
+static int vmw_fifo_wait_noirq(struct vmw_private *dev_priv,
+                              uint32_t bytes, bool interruptible,
+                              unsigned long timeout)
+{
+       int ret = 0;
+       unsigned long end_jiffies = jiffies + timeout;
+       DEFINE_WAIT(__wait);
+
+       DRM_INFO("Fifo wait noirq.\n");
+
+       for (;;) {
+               prepare_to_wait(&dev_priv->fifo_queue, &__wait,
+                               (interruptible) ?
+                               TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
+               if (!vmw_fifo_is_full(dev_priv, bytes))
+                       break;
+               if (time_after_eq(jiffies, end_jiffies)) {
+                       ret = -EBUSY;
+                       DRM_ERROR("SVGA device lockup.\n");
+                       break;
+               }
+               schedule_timeout(1);
+               if (interruptible && signal_pending(current)) {
+                       ret = -ERESTARTSYS;
+                       break;
+               }
+       }
+       finish_wait(&dev_priv->fifo_queue, &__wait);
+       wake_up_all(&dev_priv->fifo_queue);
+       DRM_INFO("Fifo noirq exit.\n");
+       return ret;
+}
+
+static int vmw_fifo_wait(struct vmw_private *dev_priv,
+                        uint32_t bytes, bool interruptible,
+                        unsigned long timeout)
+{
+       long ret = 1L;
+       unsigned long irq_flags;
+
+       if (likely(!vmw_fifo_is_full(dev_priv, bytes)))
+               return 0;
+
+       vmw_fifo_ping_host(dev_priv, SVGA_SYNC_FIFOFULL);
+       if (!(dev_priv->capabilities & SVGA_CAP_IRQMASK))
+               return vmw_fifo_wait_noirq(dev_priv, bytes,
+                                          interruptible, timeout);
+
+       mutex_lock(&dev_priv->hw_mutex);
+       if (atomic_add_return(1, &dev_priv->fifo_queue_waiters) > 0) {
+               spin_lock_irqsave(&dev_priv->irq_lock, irq_flags);
+               outl(SVGA_IRQFLAG_FIFO_PROGRESS,
+                    dev_priv->io_start + VMWGFX_IRQSTATUS_PORT);
+               vmw_write(dev_priv, SVGA_REG_IRQMASK,
+                         vmw_read(dev_priv, SVGA_REG_IRQMASK) |
+                         SVGA_IRQFLAG_FIFO_PROGRESS);
+               spin_unlock_irqrestore(&dev_priv->irq_lock, irq_flags);
+       }
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       if (interruptible)
+               ret = wait_event_interruptible_timeout
+                   (dev_priv->fifo_queue,
+                    !vmw_fifo_is_full(dev_priv, bytes), timeout);
+       else
+               ret = wait_event_timeout
+                   (dev_priv->fifo_queue,
+                    !vmw_fifo_is_full(dev_priv, bytes), timeout);
+
+       if (unlikely(ret == 0))
+               ret = -EBUSY;
+       else if (likely(ret > 0))
+               ret = 0;
+
+       mutex_lock(&dev_priv->hw_mutex);
+       if (atomic_dec_and_test(&dev_priv->fifo_queue_waiters)) {
+               spin_lock_irqsave(&dev_priv->irq_lock, irq_flags);
+               vmw_write(dev_priv, SVGA_REG_IRQMASK,
+                         vmw_read(dev_priv, SVGA_REG_IRQMASK) &
+                         ~SVGA_IRQFLAG_FIFO_PROGRESS);
+               spin_unlock_irqrestore(&dev_priv->irq_lock, irq_flags);
+       }
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       return ret;
+}
+
+void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
+{
+       struct vmw_fifo_state *fifo_state = &dev_priv->fifo;
+       __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+       uint32_t max;
+       uint32_t min;
+       uint32_t next_cmd;
+       uint32_t reserveable = fifo_state->capabilities & SVGA_FIFO_CAP_RESERVE;
+       int ret;
+
+       down_write(&fifo_state->rwsem);
+       max = ioread32(fifo_mem + SVGA_FIFO_MAX);
+       min = ioread32(fifo_mem + SVGA_FIFO_MIN);
+       next_cmd = ioread32(fifo_mem + SVGA_FIFO_NEXT_CMD);
+
+       if (unlikely(bytes >= (max - min)))
+               goto out_err;
+
+       BUG_ON(fifo_state->reserved_size != 0);
+       BUG_ON(fifo_state->dynamic_buffer != NULL);
+
+       fifo_state->reserved_size = bytes;
+
+       while (1) {
+               uint32_t stop = ioread32(fifo_mem + SVGA_FIFO_STOP);
+               bool need_bounce = false;
+               bool reserve_in_place = false;
+
+               if (next_cmd >= stop) {
+                       if (likely((next_cmd + bytes < max ||
+                                   (next_cmd + bytes == max && stop > min))))
+                               reserve_in_place = true;
+
+                       else if (vmw_fifo_is_full(dev_priv, bytes)) {
+                               ret = vmw_fifo_wait(dev_priv, bytes,
+                                                   false, 3 * HZ);
+                               if (unlikely(ret != 0))
+                                       goto out_err;
+                       } else
+                               need_bounce = true;
+
+               } else {
+
+                       if (likely((next_cmd + bytes < stop)))
+                               reserve_in_place = true;
+                       else {
+                               ret = vmw_fifo_wait(dev_priv, bytes,
+                                                   false, 3 * HZ);
+                               if (unlikely(ret != 0))
+                                       goto out_err;
+                       }
+               }
+
+               if (reserve_in_place) {
+                       if (reserveable || bytes <= sizeof(uint32_t)) {
+                               fifo_state->using_bounce_buffer = false;
+
+                               if (reserveable)
+                                       iowrite32(bytes, fifo_mem +
+                                                 SVGA_FIFO_RESERVED);
+                               return fifo_mem + (next_cmd >> 2);
+                       } else {
+                               need_bounce = true;
+                       }
+               }
+
+               if (need_bounce) {
+                       fifo_state->using_bounce_buffer = true;
+                       if (bytes < fifo_state->static_buffer_size)
+                               return fifo_state->static_buffer;
+                       else {
+                               fifo_state->dynamic_buffer = vmalloc(bytes);
+                               return fifo_state->dynamic_buffer;
+                       }
+               }
+       }
+out_err:
+       fifo_state->reserved_size = 0;
+       up_write(&fifo_state->rwsem);
+       return NULL;
+}
+
+static void vmw_fifo_res_copy(struct vmw_fifo_state *fifo_state,
+                             __le32 __iomem *fifo_mem,
+                             uint32_t next_cmd,
+                             uint32_t max, uint32_t min, uint32_t bytes)
+{
+       uint32_t chunk_size = max - next_cmd;
+       uint32_t rest;
+       uint32_t *buffer = (fifo_state->dynamic_buffer != NULL) ?
+           fifo_state->dynamic_buffer : fifo_state->static_buffer;
+
+       if (bytes < chunk_size)
+               chunk_size = bytes;
+
+       iowrite32(bytes, fifo_mem + SVGA_FIFO_RESERVED);
+       mb();
+       memcpy_toio(fifo_mem + (next_cmd >> 2), buffer, chunk_size);
+       rest = bytes - chunk_size;
+       if (rest)
+               memcpy_toio(fifo_mem + (min >> 2), buffer + (chunk_size >> 2),
+                           rest);
+}
+
+static void vmw_fifo_slow_copy(struct vmw_fifo_state *fifo_state,
+                              __le32 __iomem *fifo_mem,
+                              uint32_t next_cmd,
+                              uint32_t max, uint32_t min, uint32_t bytes)
+{
+       uint32_t *buffer = (fifo_state->dynamic_buffer != NULL) ?
+           fifo_state->dynamic_buffer : fifo_state->static_buffer;
+
+       while (bytes > 0) {
+               iowrite32(*buffer++, fifo_mem + (next_cmd >> 2));
+               next_cmd += sizeof(uint32_t);
+               if (unlikely(next_cmd == max))
+                       next_cmd = min;
+               mb();
+               iowrite32(next_cmd, fifo_mem + SVGA_FIFO_NEXT_CMD);
+               mb();
+               bytes -= sizeof(uint32_t);
+       }
+}
+
+void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes)
+{
+       struct vmw_fifo_state *fifo_state = &dev_priv->fifo;
+       __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+       uint32_t next_cmd = ioread32(fifo_mem + SVGA_FIFO_NEXT_CMD);
+       uint32_t max = ioread32(fifo_mem + SVGA_FIFO_MAX);
+       uint32_t min = ioread32(fifo_mem + SVGA_FIFO_MIN);
+       bool reserveable = fifo_state->capabilities & SVGA_FIFO_CAP_RESERVE;
+
+       BUG_ON((bytes & 3) != 0);
+       BUG_ON(bytes > fifo_state->reserved_size);
+
+       fifo_state->reserved_size = 0;
+
+       if (fifo_state->using_bounce_buffer) {
+               if (reserveable)
+                       vmw_fifo_res_copy(fifo_state, fifo_mem,
+                                         next_cmd, max, min, bytes);
+               else
+                       vmw_fifo_slow_copy(fifo_state, fifo_mem,
+                                          next_cmd, max, min, bytes);
+
+               if (fifo_state->dynamic_buffer) {
+                       vfree(fifo_state->dynamic_buffer);
+                       fifo_state->dynamic_buffer = NULL;
+               }
+
+       }
+
+       if (fifo_state->using_bounce_buffer || reserveable) {
+               next_cmd += bytes;
+               if (next_cmd >= max)
+                       next_cmd -= max - min;
+               mb();
+               iowrite32(next_cmd, fifo_mem + SVGA_FIFO_NEXT_CMD);
+       }
+
+       if (reserveable)
+               iowrite32(0, fifo_mem + SVGA_FIFO_RESERVED);
+       mb();
+       vmw_fifo_ping_host(dev_priv, SVGA_SYNC_GENERIC);
+       up_write(&fifo_state->rwsem);
+}
+
+int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *sequence)
+{
+       struct vmw_fifo_state *fifo_state = &dev_priv->fifo;
+       struct svga_fifo_cmd_fence *cmd_fence;
+       void *fm;
+       int ret = 0;
+       uint32_t bytes = sizeof(__le32) + sizeof(*cmd_fence);
+
+       fm = vmw_fifo_reserve(dev_priv, bytes);
+       if (unlikely(fm == NULL)) {
+               down_write(&fifo_state->rwsem);
+               *sequence = dev_priv->fence_seq;
+               up_write(&fifo_state->rwsem);
+               ret = -ENOMEM;
+               (void)vmw_fallback_wait(dev_priv, false, true, *sequence,
+                                       false, 3*HZ);
+               goto out_err;
+       }
+
+       do {
+               *sequence = dev_priv->fence_seq++;
+       } while (*sequence == 0);
+
+       if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
+
+               /*
+                * Don't request hardware to send a fence. The
+                * waiting code in vmwgfx_irq.c will emulate this.
+                */
+
+               vmw_fifo_commit(dev_priv, 0);
+               return 0;
+       }
+
+       *(__le32 *) fm = cpu_to_le32(SVGA_CMD_FENCE);
+       cmd_fence = (struct svga_fifo_cmd_fence *)
+           ((unsigned long)fm + sizeof(__le32));
+
+       iowrite32(*sequence, &cmd_fence->fence);
+       fifo_state->last_buffer_add = true;
+       vmw_fifo_commit(dev_priv, bytes);
+       fifo_state->last_buffer_add = false;
+
+out_err:
+       return ret;
+}
+
+/**
+ * Map the first page of the FIFO read-only to user-space.
+ */
+
+static int vmw_fifo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+{
+       int ret;
+       unsigned long address = (unsigned long)vmf->virtual_address;
+
+       if (address != vma->vm_start)
+               return VM_FAULT_SIGBUS;
+
+       ret = vm_insert_pfn(vma, address, vma->vm_pgoff);
+       if (likely(ret == -EBUSY || ret == 0))
+               return VM_FAULT_NOPAGE;
+       else if (ret == -ENOMEM)
+               return VM_FAULT_OOM;
+
+       return VM_FAULT_SIGBUS;
+}
+
+static struct vm_operations_struct vmw_fifo_vm_ops = {
+       .fault = vmw_fifo_vm_fault,
+       .open = NULL,
+       .close = NULL
+};
+
+int vmw_fifo_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+       struct drm_file *file_priv;
+       struct vmw_private *dev_priv;
+
+       file_priv = (struct drm_file *)filp->private_data;
+       dev_priv = vmw_priv(file_priv->minor->dev);
+
+       if (vma->vm_pgoff != (dev_priv->mmio_start >> PAGE_SHIFT) ||
+           (vma->vm_end - vma->vm_start) != PAGE_SIZE)
+               return -EINVAL;
+
+       vma->vm_flags &= ~(VM_WRITE | VM_MAYWRITE);
+       vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_SHARED;
+       vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+       vma->vm_page_prot = ttm_io_prot(TTM_PL_FLAG_UNCACHED,
+                                       vma->vm_page_prot);
+       vma->vm_ops = &vmw_fifo_vm_ops;
+       return 0;
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c
new file mode 100644 (file)
index 0000000..5f8908a
--- /dev/null
@@ -0,0 +1,213 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vmwgfx_drv.h"
+#include "drmP.h"
+#include "ttm/ttm_bo_driver.h"
+
+/**
+ * FIXME: Adjust to the ttm lowmem / highmem storage to minimize
+ * the number of used descriptors.
+ */
+
+static int vmw_gmr_build_descriptors(struct list_head *desc_pages,
+                                    struct page *pages[],
+                                    unsigned long num_pages)
+{
+       struct page *page, *next;
+       struct svga_guest_mem_descriptor *page_virtual = NULL;
+       struct svga_guest_mem_descriptor *desc_virtual = NULL;
+       unsigned int desc_per_page;
+       unsigned long prev_pfn;
+       unsigned long pfn;
+       int ret;
+
+       desc_per_page = PAGE_SIZE /
+           sizeof(struct svga_guest_mem_descriptor) - 1;
+
+       while (likely(num_pages != 0)) {
+               page = alloc_page(__GFP_HIGHMEM);
+               if (unlikely(page == NULL)) {
+                       ret = -ENOMEM;
+                       goto out_err;
+               }
+
+               list_add_tail(&page->lru, desc_pages);
+
+               /*
+                * Point previous page terminating descriptor to this
+                * page before unmapping it.
+                */
+
+               if (likely(page_virtual != NULL)) {
+                       desc_virtual->ppn = page_to_pfn(page);
+                       kunmap_atomic(page_virtual, KM_USER0);
+               }
+
+               page_virtual = kmap_atomic(page, KM_USER0);
+               desc_virtual = page_virtual - 1;
+               prev_pfn = ~(0UL);
+
+               while (likely(num_pages != 0)) {
+                       pfn = page_to_pfn(*pages);
+
+                       if (pfn != prev_pfn + 1) {
+
+                               if (desc_virtual - page_virtual ==
+                                   desc_per_page - 1)
+                                       break;
+
+                               (++desc_virtual)->ppn = cpu_to_le32(pfn);
+                               desc_virtual->num_pages = cpu_to_le32(1);
+                       } else {
+                               uint32_t tmp =
+                                   le32_to_cpu(desc_virtual->num_pages);
+                               desc_virtual->num_pages = cpu_to_le32(tmp + 1);
+                       }
+                       prev_pfn = pfn;
+                       --num_pages;
+                       ++pages;
+               }
+
+               (++desc_virtual)->ppn = cpu_to_le32(0);
+               desc_virtual->num_pages = cpu_to_le32(0);
+       }
+
+       if (likely(page_virtual != NULL))
+               kunmap_atomic(page_virtual, KM_USER0);
+
+       return 0;
+out_err:
+       list_for_each_entry_safe(page, next, desc_pages, lru) {
+               list_del_init(&page->lru);
+               __free_page(page);
+       }
+       return ret;
+}
+
+static inline void vmw_gmr_free_descriptors(struct list_head *desc_pages)
+{
+       struct page *page, *next;
+
+       list_for_each_entry_safe(page, next, desc_pages, lru) {
+               list_del_init(&page->lru);
+               __free_page(page);
+       }
+}
+
+static void vmw_gmr_fire_descriptors(struct vmw_private *dev_priv,
+                                    int gmr_id, struct list_head *desc_pages)
+{
+       struct page *page;
+
+       if (unlikely(list_empty(desc_pages)))
+               return;
+
+       page = list_entry(desc_pages->next, struct page, lru);
+
+       mutex_lock(&dev_priv->hw_mutex);
+
+       vmw_write(dev_priv, SVGA_REG_GMR_ID, gmr_id);
+       wmb();
+       vmw_write(dev_priv, SVGA_REG_GMR_DESCRIPTOR, page_to_pfn(page));
+       mb();
+
+       mutex_unlock(&dev_priv->hw_mutex);
+
+}
+
+/**
+ * FIXME: Adjust to the ttm lowmem / highmem storage to minimize
+ * the number of used descriptors.
+ */
+
+static unsigned long vmw_gmr_count_descriptors(struct page *pages[],
+                                              unsigned long num_pages)
+{
+       unsigned long prev_pfn = ~(0UL);
+       unsigned long pfn;
+       unsigned long descriptors = 0;
+
+       while (num_pages--) {
+               pfn = page_to_pfn(*pages++);
+               if (prev_pfn + 1 != pfn)
+                       ++descriptors;
+               prev_pfn = pfn;
+       }
+
+       return descriptors;
+}
+
+int vmw_gmr_bind(struct vmw_private *dev_priv,
+                struct ttm_buffer_object *bo)
+{
+       struct ttm_tt *ttm = bo->ttm;
+       unsigned long descriptors;
+       int ret;
+       uint32_t id;
+       struct list_head desc_pages;
+
+       if (!(dev_priv->capabilities & SVGA_CAP_GMR))
+               return -EINVAL;
+
+       ret = ttm_tt_populate(ttm);
+       if (unlikely(ret != 0))
+               return ret;
+
+       descriptors = vmw_gmr_count_descriptors(ttm->pages, ttm->num_pages);
+       if (unlikely(descriptors > dev_priv->max_gmr_descriptors))
+               return -EINVAL;
+
+       INIT_LIST_HEAD(&desc_pages);
+       ret = vmw_gmr_build_descriptors(&desc_pages, ttm->pages,
+                                       ttm->num_pages);
+       if (unlikely(ret != 0))
+               return ret;
+
+       ret = vmw_gmr_id_alloc(dev_priv, &id);
+       if (unlikely(ret != 0))
+               goto out_no_id;
+
+       vmw_gmr_fire_descriptors(dev_priv, id, &desc_pages);
+       vmw_gmr_free_descriptors(&desc_pages);
+       vmw_dmabuf_set_gmr(bo, id);
+       return 0;
+
+out_no_id:
+       vmw_gmr_free_descriptors(&desc_pages);
+       return ret;
+}
+
+void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id)
+{
+       mutex_lock(&dev_priv->hw_mutex);
+       vmw_write(dev_priv, SVGA_REG_GMR_ID, gmr_id);
+       wmb();
+       vmw_write(dev_priv, SVGA_REG_GMR_DESCRIPTOR, 0);
+       mb();
+       mutex_unlock(&dev_priv->hw_mutex);
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
new file mode 100644 (file)
index 0000000..5fa6a4e
--- /dev/null
@@ -0,0 +1,81 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vmwgfx_drv.h"
+#include "vmwgfx_drm.h"
+
+int vmw_getparam_ioctl(struct drm_device *dev, void *data,
+                      struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct drm_vmw_getparam_arg *param =
+           (struct drm_vmw_getparam_arg *)data;
+
+       switch (param->param) {
+       case DRM_VMW_PARAM_NUM_STREAMS:
+               param->value = vmw_overlay_num_overlays(dev_priv);
+               break;
+       case DRM_VMW_PARAM_NUM_FREE_STREAMS:
+               param->value = vmw_overlay_num_free_overlays(dev_priv);
+               break;
+       case DRM_VMW_PARAM_3D:
+               param->value = dev_priv->capabilities & SVGA_CAP_3D ? 1 : 0;
+               break;
+       case DRM_VMW_PARAM_FIFO_OFFSET:
+               param->value = dev_priv->mmio_start;
+               break;
+       default:
+               DRM_ERROR("Illegal vmwgfx get param request: %d\n",
+                         param->param);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+int vmw_fifo_debug_ioctl(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_fifo_state *fifo_state = &dev_priv->fifo;
+       struct drm_vmw_fifo_debug_arg *arg =
+           (struct drm_vmw_fifo_debug_arg *)data;
+       __le32 __user *buffer = (__le32 __user *)
+           (unsigned long)arg->debug_buffer;
+
+       if (unlikely(fifo_state->last_buffer == NULL))
+               return -EINVAL;
+
+       if (arg->debug_buffer_size < fifo_state->last_data_size) {
+               arg->used_size = arg->debug_buffer_size;
+               arg->did_not_fit = 1;
+       } else {
+               arg->used_size = fifo_state->last_data_size;
+               arg->did_not_fit = 0;
+       }
+       return copy_to_user(buffer, fifo_state->last_buffer, arg->used_size);
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
new file mode 100644 (file)
index 0000000..d40086f
--- /dev/null
@@ -0,0 +1,293 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "drmP.h"
+#include "vmwgfx_drv.h"
+
+#define VMW_FENCE_WRAP (1 << 24)
+
+irqreturn_t vmw_irq_handler(DRM_IRQ_ARGS)
+{
+       struct drm_device *dev = (struct drm_device *)arg;
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       uint32_t status;
+
+       spin_lock(&dev_priv->irq_lock);
+       status = inl(dev_priv->io_start + VMWGFX_IRQSTATUS_PORT);
+       spin_unlock(&dev_priv->irq_lock);
+
+       if (status & SVGA_IRQFLAG_ANY_FENCE)
+               wake_up_all(&dev_priv->fence_queue);
+       if (status & SVGA_IRQFLAG_FIFO_PROGRESS)
+               wake_up_all(&dev_priv->fifo_queue);
+
+       if (likely(status)) {
+               outl(status, dev_priv->io_start + VMWGFX_IRQSTATUS_PORT);
+               return IRQ_HANDLED;
+       }
+
+       return IRQ_NONE;
+}
+
+static bool vmw_fifo_idle(struct vmw_private *dev_priv, uint32_t sequence)
+{
+       uint32_t busy;
+
+       mutex_lock(&dev_priv->hw_mutex);
+       busy = vmw_read(dev_priv, SVGA_REG_BUSY);
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       return (busy == 0);
+}
+
+
+bool vmw_fence_signaled(struct vmw_private *dev_priv,
+                       uint32_t sequence)
+{
+       __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+       struct vmw_fifo_state *fifo_state;
+       bool ret;
+
+       if (likely(dev_priv->last_read_sequence - sequence < VMW_FENCE_WRAP))
+               return true;
+
+       dev_priv->last_read_sequence = ioread32(fifo_mem + SVGA_FIFO_FENCE);
+       if (likely(dev_priv->last_read_sequence - sequence < VMW_FENCE_WRAP))
+               return true;
+
+       fifo_state = &dev_priv->fifo;
+       if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE) &&
+           vmw_fifo_idle(dev_priv, sequence))
+               return true;
+
+       /**
+        * Below is to signal stale fences that have wrapped.
+        * First, block fence submission.
+        */
+
+       down_read(&fifo_state->rwsem);
+
+       /**
+        * Then check if the sequence is higher than what we've actually
+        * emitted. Then the fence is stale and signaled.
+        */
+
+       ret = ((dev_priv->fence_seq - sequence) > VMW_FENCE_WRAP);
+       up_read(&fifo_state->rwsem);
+
+       return ret;
+}
+
+int vmw_fallback_wait(struct vmw_private *dev_priv,
+                     bool lazy,
+                     bool fifo_idle,
+                     uint32_t sequence,
+                     bool interruptible,
+                     unsigned long timeout)
+{
+       struct vmw_fifo_state *fifo_state = &dev_priv->fifo;
+
+       uint32_t count = 0;
+       uint32_t signal_seq;
+       int ret;
+       unsigned long end_jiffies = jiffies + timeout;
+       bool (*wait_condition)(struct vmw_private *, uint32_t);
+       DEFINE_WAIT(__wait);
+
+       wait_condition = (fifo_idle) ? &vmw_fifo_idle :
+               &vmw_fence_signaled;
+
+       /**
+        * Block command submission while waiting for idle.
+        */
+
+       if (fifo_idle)
+               down_read(&fifo_state->rwsem);
+       signal_seq = dev_priv->fence_seq;
+       ret = 0;
+
+       for (;;) {
+               prepare_to_wait(&dev_priv->fence_queue, &__wait,
+                               (interruptible) ?
+                               TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE);
+               if (wait_condition(dev_priv, sequence))
+                       break;
+               if (time_after_eq(jiffies, end_jiffies)) {
+                       DRM_ERROR("SVGA device lockup.\n");
+                       break;
+               }
+               if (lazy)
+                       schedule_timeout(1);
+               else if ((++count & 0x0F) == 0) {
+                       /**
+                        * FIXME: Use schedule_hr_timeout here for
+                        * newer kernels and lower CPU utilization.
+                        */
+
+                       __set_current_state(TASK_RUNNING);
+                       schedule();
+                       __set_current_state((interruptible) ?
+                                           TASK_INTERRUPTIBLE :
+                                           TASK_UNINTERRUPTIBLE);
+               }
+               if (interruptible && signal_pending(current)) {
+                       ret = -ERESTARTSYS;
+                       break;
+               }
+       }
+       finish_wait(&dev_priv->fence_queue, &__wait);
+       if (ret == 0 && fifo_idle) {
+               __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+               iowrite32(signal_seq, fifo_mem + SVGA_FIFO_FENCE);
+       }
+       wake_up_all(&dev_priv->fence_queue);
+       if (fifo_idle)
+               up_read(&fifo_state->rwsem);
+
+       return ret;
+}
+
+int vmw_wait_fence(struct vmw_private *dev_priv,
+                  bool lazy, uint32_t sequence,
+                  bool interruptible, unsigned long timeout)
+{
+       long ret;
+       unsigned long irq_flags;
+       struct vmw_fifo_state *fifo = &dev_priv->fifo;
+
+       if (likely(dev_priv->last_read_sequence - sequence < VMW_FENCE_WRAP))
+               return 0;
+
+       if (likely(vmw_fence_signaled(dev_priv, sequence)))
+               return 0;
+
+       vmw_fifo_ping_host(dev_priv, SVGA_SYNC_GENERIC);
+
+       if (!(fifo->capabilities & SVGA_FIFO_CAP_FENCE))
+               return vmw_fallback_wait(dev_priv, lazy, true, sequence,
+                                        interruptible, timeout);
+
+       if (!(dev_priv->capabilities & SVGA_CAP_IRQMASK))
+               return vmw_fallback_wait(dev_priv, lazy, false, sequence,
+                                        interruptible, timeout);
+
+       mutex_lock(&dev_priv->hw_mutex);
+       if (atomic_add_return(1, &dev_priv->fence_queue_waiters) > 0) {
+               spin_lock_irqsave(&dev_priv->irq_lock, irq_flags);
+               outl(SVGA_IRQFLAG_ANY_FENCE,
+                    dev_priv->io_start + VMWGFX_IRQSTATUS_PORT);
+               vmw_write(dev_priv, SVGA_REG_IRQMASK,
+                         vmw_read(dev_priv, SVGA_REG_IRQMASK) |
+                         SVGA_IRQFLAG_ANY_FENCE);
+               spin_unlock_irqrestore(&dev_priv->irq_lock, irq_flags);
+       }
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       if (interruptible)
+               ret = wait_event_interruptible_timeout
+                   (dev_priv->fence_queue,
+                    vmw_fence_signaled(dev_priv, sequence),
+                    timeout);
+       else
+               ret = wait_event_timeout
+                   (dev_priv->fence_queue,
+                    vmw_fence_signaled(dev_priv, sequence),
+                    timeout);
+
+       if (unlikely(ret == 0))
+               ret = -EBUSY;
+       else if (likely(ret > 0))
+               ret = 0;
+
+       mutex_lock(&dev_priv->hw_mutex);
+       if (atomic_dec_and_test(&dev_priv->fence_queue_waiters)) {
+               spin_lock_irqsave(&dev_priv->irq_lock, irq_flags);
+               vmw_write(dev_priv, SVGA_REG_IRQMASK,
+                         vmw_read(dev_priv, SVGA_REG_IRQMASK) &
+                         ~SVGA_IRQFLAG_ANY_FENCE);
+               spin_unlock_irqrestore(&dev_priv->irq_lock, irq_flags);
+       }
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       return ret;
+}
+
+void vmw_irq_preinstall(struct drm_device *dev)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       uint32_t status;
+
+       if (!(dev_priv->capabilities & SVGA_CAP_IRQMASK))
+               return;
+
+       spin_lock_init(&dev_priv->irq_lock);
+       status = inl(dev_priv->io_start + VMWGFX_IRQSTATUS_PORT);
+       outl(status, dev_priv->io_start + VMWGFX_IRQSTATUS_PORT);
+}
+
+int vmw_irq_postinstall(struct drm_device *dev)
+{
+       return 0;
+}
+
+void vmw_irq_uninstall(struct drm_device *dev)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       uint32_t status;
+
+       if (!(dev_priv->capabilities & SVGA_CAP_IRQMASK))
+               return;
+
+       mutex_lock(&dev_priv->hw_mutex);
+       vmw_write(dev_priv, SVGA_REG_IRQMASK, 0);
+       mutex_unlock(&dev_priv->hw_mutex);
+
+       status = inl(dev_priv->io_start + VMWGFX_IRQSTATUS_PORT);
+       outl(status, dev_priv->io_start + VMWGFX_IRQSTATUS_PORT);
+}
+
+#define VMW_FENCE_WAIT_TIMEOUT 3*HZ;
+
+int vmw_fence_wait_ioctl(struct drm_device *dev, void *data,
+                        struct drm_file *file_priv)
+{
+       struct drm_vmw_fence_wait_arg *arg =
+           (struct drm_vmw_fence_wait_arg *)data;
+       unsigned long timeout;
+
+       if (!arg->cookie_valid) {
+               arg->cookie_valid = 1;
+               arg->kernel_cookie = jiffies + VMW_FENCE_WAIT_TIMEOUT;
+       }
+
+       timeout = jiffies;
+       if (time_after_eq(timeout, (unsigned long)arg->kernel_cookie))
+               return -EBUSY;
+
+       timeout = (unsigned long)arg->kernel_cookie - timeout;
+       return vmw_wait_fence(vmw_priv(dev), true, arg->sequence, true, timeout);
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
new file mode 100644 (file)
index 0000000..b1af76e
--- /dev/null
@@ -0,0 +1,872 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vmwgfx_kms.h"
+
+/* Might need a hrtimer here? */
+#define VMWGFX_PRESENT_RATE ((HZ / 60 > 0) ? HZ / 60 : 1)
+
+
+void vmw_display_unit_cleanup(struct vmw_display_unit *du)
+{
+       if (du->cursor_surface)
+               vmw_surface_unreference(&du->cursor_surface);
+       if (du->cursor_dmabuf)
+               vmw_dmabuf_unreference(&du->cursor_dmabuf);
+       drm_crtc_cleanup(&du->crtc);
+       drm_encoder_cleanup(&du->encoder);
+       drm_connector_cleanup(&du->connector);
+}
+
+/*
+ * Display Unit Cursor functions
+ */
+
+int vmw_cursor_update_image(struct vmw_private *dev_priv,
+                           u32 *image, u32 width, u32 height,
+                           u32 hotspotX, u32 hotspotY)
+{
+       struct {
+               u32 cmd;
+               SVGAFifoCmdDefineAlphaCursor cursor;
+       } *cmd;
+       u32 image_size = width * height * 4;
+       u32 cmd_size = sizeof(*cmd) + image_size;
+
+       if (!image)
+               return -EINVAL;
+
+       cmd = vmw_fifo_reserve(dev_priv, cmd_size);
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Fifo reserve failed.\n");
+               return -ENOMEM;
+       }
+
+       memset(cmd, 0, sizeof(*cmd));
+
+       memcpy(&cmd[1], image, image_size);
+
+       cmd->cmd = cpu_to_le32(SVGA_CMD_DEFINE_ALPHA_CURSOR);
+       cmd->cursor.id = cpu_to_le32(0);
+       cmd->cursor.width = cpu_to_le32(width);
+       cmd->cursor.height = cpu_to_le32(height);
+       cmd->cursor.hotspotX = cpu_to_le32(hotspotX);
+       cmd->cursor.hotspotY = cpu_to_le32(hotspotY);
+
+       vmw_fifo_commit(dev_priv, cmd_size);
+
+       return 0;
+}
+
+void vmw_cursor_update_position(struct vmw_private *dev_priv,
+                               bool show, int x, int y)
+{
+       __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
+       uint32_t count;
+
+       iowrite32(show ? 1 : 0, fifo_mem + SVGA_FIFO_CURSOR_ON);
+       iowrite32(x, fifo_mem + SVGA_FIFO_CURSOR_X);
+       iowrite32(y, fifo_mem + SVGA_FIFO_CURSOR_Y);
+       count = ioread32(fifo_mem + SVGA_FIFO_CURSOR_COUNT);
+       iowrite32(++count, fifo_mem + SVGA_FIFO_CURSOR_COUNT);
+}
+
+int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
+                          uint32_t handle, uint32_t width, uint32_t height)
+{
+       struct vmw_private *dev_priv = vmw_priv(crtc->dev);
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
+       struct vmw_surface *surface = NULL;
+       struct vmw_dma_buffer *dmabuf = NULL;
+       int ret;
+
+       if (handle) {
+               ret = vmw_user_surface_lookup_handle(dev_priv, tfile,
+                                                    handle, &surface);
+               if (!ret) {
+                       if (!surface->snooper.image) {
+                               DRM_ERROR("surface not suitable for cursor\n");
+                               return -EINVAL;
+                       }
+               } else {
+                       ret = vmw_user_dmabuf_lookup(tfile,
+                                                    handle, &dmabuf);
+                       if (ret) {
+                               DRM_ERROR("failed to find surface or dmabuf: %i\n", ret);
+                               return -EINVAL;
+                       }
+               }
+       }
+
+       /* takedown old cursor */
+       if (du->cursor_surface) {
+               du->cursor_surface->snooper.crtc = NULL;
+               vmw_surface_unreference(&du->cursor_surface);
+       }
+       if (du->cursor_dmabuf)
+               vmw_dmabuf_unreference(&du->cursor_dmabuf);
+
+       /* setup new image */
+       if (surface) {
+               /* vmw_user_surface_lookup takes one reference */
+               du->cursor_surface = surface;
+
+               du->cursor_surface->snooper.crtc = crtc;
+               du->cursor_age = du->cursor_surface->snooper.age;
+               vmw_cursor_update_image(dev_priv, surface->snooper.image,
+                                       64, 64, du->hotspot_x, du->hotspot_y);
+       } else if (dmabuf) {
+               struct ttm_bo_kmap_obj map;
+               unsigned long kmap_offset;
+               unsigned long kmap_num;
+               void *virtual;
+               bool dummy;
+
+               /* vmw_user_surface_lookup takes one reference */
+               du->cursor_dmabuf = dmabuf;
+
+               kmap_offset = 0;
+               kmap_num = (64*64*4) >> PAGE_SHIFT;
+
+               ret = ttm_bo_reserve(&dmabuf->base, true, false, false, 0);
+               if (unlikely(ret != 0)) {
+                       DRM_ERROR("reserve failed\n");
+                       return -EINVAL;
+               }
+
+               ret = ttm_bo_kmap(&dmabuf->base, kmap_offset, kmap_num, &map);
+               if (unlikely(ret != 0))
+                       goto err_unreserve;
+
+               virtual = ttm_kmap_obj_virtual(&map, &dummy);
+               vmw_cursor_update_image(dev_priv, virtual, 64, 64,
+                                       du->hotspot_x, du->hotspot_y);
+
+               ttm_bo_kunmap(&map);
+err_unreserve:
+               ttm_bo_unreserve(&dmabuf->base);
+
+       } else {
+               vmw_cursor_update_position(dev_priv, false, 0, 0);
+               return 0;
+       }
+
+       vmw_cursor_update_position(dev_priv, true, du->cursor_x, du->cursor_y);
+
+       return 0;
+}
+
+int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
+{
+       struct vmw_private *dev_priv = vmw_priv(crtc->dev);
+       struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
+       bool shown = du->cursor_surface || du->cursor_dmabuf ? true : false;
+
+       du->cursor_x = x + crtc->x;
+       du->cursor_y = y + crtc->y;
+
+       vmw_cursor_update_position(dev_priv, shown,
+                                  du->cursor_x, du->cursor_y);
+
+       return 0;
+}
+
+void vmw_kms_cursor_snoop(struct vmw_surface *srf,
+                         struct ttm_object_file *tfile,
+                         struct ttm_buffer_object *bo,
+                         SVGA3dCmdHeader *header)
+{
+       struct ttm_bo_kmap_obj map;
+       unsigned long kmap_offset;
+       unsigned long kmap_num;
+       SVGA3dCopyBox *box;
+       unsigned box_count;
+       void *virtual;
+       bool dummy;
+       struct vmw_dma_cmd {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdSurfaceDMA dma;
+       } *cmd;
+       int ret;
+
+       cmd = container_of(header, struct vmw_dma_cmd, header);
+
+       /* No snooper installed */
+       if (!srf->snooper.image)
+               return;
+
+       if (cmd->dma.host.face != 0 || cmd->dma.host.mipmap != 0) {
+               DRM_ERROR("face and mipmap for cursors should never != 0\n");
+               return;
+       }
+
+       if (cmd->header.size < 64) {
+               DRM_ERROR("at least one full copy box must be given\n");
+               return;
+       }
+
+       box = (SVGA3dCopyBox *)&cmd[1];
+       box_count = (cmd->header.size - sizeof(SVGA3dCmdSurfaceDMA)) /
+                       sizeof(SVGA3dCopyBox);
+
+       if (cmd->dma.guest.pitch != (64 * 4) ||
+           cmd->dma.guest.ptr.offset % PAGE_SIZE ||
+           box->x != 0    || box->y != 0    || box->z != 0    ||
+           box->srcx != 0 || box->srcy != 0 || box->srcz != 0 ||
+           box->w != 64   || box->h != 64   || box->d != 1    ||
+           box_count != 1) {
+               /* TODO handle none page aligned offsets */
+               /* TODO handle partial uploads and pitch != 256 */
+               /* TODO handle more then one copy (size != 64) */
+               DRM_ERROR("lazy programer, cant handle wierd stuff\n");
+               return;
+       }
+
+       kmap_offset = cmd->dma.guest.ptr.offset >> PAGE_SHIFT;
+       kmap_num = (64*64*4) >> PAGE_SHIFT;
+
+       ret = ttm_bo_reserve(bo, true, false, false, 0);
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("reserve failed\n");
+               return;
+       }
+
+       ret = ttm_bo_kmap(bo, kmap_offset, kmap_num, &map);
+       if (unlikely(ret != 0))
+               goto err_unreserve;
+
+       virtual = ttm_kmap_obj_virtual(&map, &dummy);
+
+       memcpy(srf->snooper.image, virtual, 64*64*4);
+       srf->snooper.age++;
+
+       /* we can't call this function from this function since execbuf has
+        * reserved fifo space.
+        *
+        * if (srf->snooper.crtc)
+        *      vmw_ldu_crtc_cursor_update_image(dev_priv,
+        *                                       srf->snooper.image, 64, 64,
+        *                                       du->hotspot_x, du->hotspot_y);
+        */
+
+       ttm_bo_kunmap(&map);
+err_unreserve:
+       ttm_bo_unreserve(bo);
+}
+
+void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv)
+{
+       struct drm_device *dev = dev_priv->dev;
+       struct vmw_display_unit *du;
+       struct drm_crtc *crtc;
+
+       mutex_lock(&dev->mode_config.mutex);
+
+       list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+               du = vmw_crtc_to_du(crtc);
+               if (!du->cursor_surface ||
+                   du->cursor_age == du->cursor_surface->snooper.age)
+                       continue;
+
+               du->cursor_age = du->cursor_surface->snooper.age;
+               vmw_cursor_update_image(dev_priv,
+                                       du->cursor_surface->snooper.image,
+                                       64, 64, du->hotspot_x, du->hotspot_y);
+       }
+
+       mutex_unlock(&dev->mode_config.mutex);
+}
+
+/*
+ * Generic framebuffer code
+ */
+
+int vmw_framebuffer_create_handle(struct drm_framebuffer *fb,
+                                 struct drm_file *file_priv,
+                                 unsigned int *handle)
+{
+       if (handle)
+               handle = 0;
+
+       return 0;
+}
+
+/*
+ * Surface framebuffer code
+ */
+
+#define vmw_framebuffer_to_vfbs(x) \
+       container_of(x, struct vmw_framebuffer_surface, base.base)
+
+struct vmw_framebuffer_surface {
+       struct vmw_framebuffer base;
+       struct vmw_surface *surface;
+       struct delayed_work d_work;
+       struct mutex work_lock;
+       bool present_fs;
+};
+
+void vmw_framebuffer_surface_destroy(struct drm_framebuffer *framebuffer)
+{
+       struct vmw_framebuffer_surface *vfb =
+               vmw_framebuffer_to_vfbs(framebuffer);
+
+       cancel_delayed_work_sync(&vfb->d_work);
+       drm_framebuffer_cleanup(framebuffer);
+       vmw_surface_unreference(&vfb->surface);
+
+       kfree(framebuffer);
+}
+
+static void vmw_framebuffer_present_fs_callback(struct work_struct *work)
+{
+       struct delayed_work *d_work =
+               container_of(work, struct delayed_work, work);
+       struct vmw_framebuffer_surface *vfbs =
+               container_of(d_work, struct vmw_framebuffer_surface, d_work);
+       struct vmw_surface *surf = vfbs->surface;
+       struct drm_framebuffer *framebuffer = &vfbs->base.base;
+       struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
+
+       struct {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdPresent body;
+               SVGA3dCopyRect cr;
+       } *cmd;
+
+       mutex_lock(&vfbs->work_lock);
+       if (!vfbs->present_fs)
+               goto out_unlock;
+
+       cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
+       if (unlikely(cmd == NULL))
+               goto out_resched;
+
+       cmd->header.id = cpu_to_le32(SVGA_3D_CMD_PRESENT);
+       cmd->header.size = cpu_to_le32(sizeof(cmd->body) + sizeof(cmd->cr));
+       cmd->body.sid = cpu_to_le32(surf->res.id);
+       cmd->cr.x = cpu_to_le32(0);
+       cmd->cr.y = cpu_to_le32(0);
+       cmd->cr.srcx = cmd->cr.x;
+       cmd->cr.srcy = cmd->cr.y;
+       cmd->cr.w = cpu_to_le32(framebuffer->width);
+       cmd->cr.h = cpu_to_le32(framebuffer->height);
+       vfbs->present_fs = false;
+       vmw_fifo_commit(dev_priv, sizeof(*cmd));
+out_resched:
+       /**
+        * Will not re-add if already pending.
+        */
+       schedule_delayed_work(&vfbs->d_work, VMWGFX_PRESENT_RATE);
+out_unlock:
+       mutex_unlock(&vfbs->work_lock);
+}
+
+
+int vmw_framebuffer_surface_dirty(struct drm_framebuffer *framebuffer,
+                                 unsigned flags, unsigned color,
+                                 struct drm_clip_rect *clips,
+                                 unsigned num_clips)
+{
+       struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
+       struct vmw_framebuffer_surface *vfbs =
+               vmw_framebuffer_to_vfbs(framebuffer);
+       struct vmw_surface *surf = vfbs->surface;
+       struct drm_clip_rect norect;
+       SVGA3dCopyRect *cr;
+       int i, inc = 1;
+
+       struct {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdPresent body;
+               SVGA3dCopyRect cr;
+       } *cmd;
+
+       if (!num_clips ||
+           !(dev_priv->fifo.capabilities &
+             SVGA_FIFO_CAP_SCREEN_OBJECT)) {
+               int ret;
+
+               mutex_lock(&vfbs->work_lock);
+               vfbs->present_fs = true;
+               ret = schedule_delayed_work(&vfbs->d_work, VMWGFX_PRESENT_RATE);
+               mutex_unlock(&vfbs->work_lock);
+               if (ret) {
+                       /**
+                        * No work pending, Force immediate present.
+                        */
+                       vmw_framebuffer_present_fs_callback(&vfbs->d_work.work);
+               }
+               return 0;
+       }
+
+       if (!num_clips) {
+               num_clips = 1;
+               clips = &norect;
+               norect.x1 = norect.y1 = 0;
+               norect.x2 = framebuffer->width;
+               norect.y2 = framebuffer->height;
+       } else if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY) {
+               num_clips /= 2;
+               inc = 2; /* skip source rects */
+       }
+
+       cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd) + (num_clips - 1) * sizeof(cmd->cr));
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Fifo reserve failed.\n");
+               return -ENOMEM;
+       }
+
+       memset(cmd, 0, sizeof(*cmd));
+
+       cmd->header.id = cpu_to_le32(SVGA_3D_CMD_PRESENT);
+       cmd->header.size = cpu_to_le32(sizeof(cmd->body) + num_clips * sizeof(cmd->cr));
+       cmd->body.sid = cpu_to_le32(surf->res.id);
+
+       for (i = 0, cr = &cmd->cr; i < num_clips; i++, cr++, clips += inc) {
+               cr->x = cpu_to_le16(clips->x1);
+               cr->y = cpu_to_le16(clips->y1);
+               cr->srcx = cr->x;
+               cr->srcy = cr->y;
+               cr->w = cpu_to_le16(clips->x2 - clips->x1);
+               cr->h = cpu_to_le16(clips->y2 - clips->y1);
+       }
+
+       vmw_fifo_commit(dev_priv, sizeof(*cmd) + (num_clips - 1) * sizeof(cmd->cr));
+
+       return 0;
+}
+
+static struct drm_framebuffer_funcs vmw_framebuffer_surface_funcs = {
+       .destroy = vmw_framebuffer_surface_destroy,
+       .dirty = vmw_framebuffer_surface_dirty,
+       .create_handle = vmw_framebuffer_create_handle,
+};
+
+int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
+                                   struct vmw_surface *surface,
+                                   struct vmw_framebuffer **out,
+                                   unsigned width, unsigned height)
+
+{
+       struct drm_device *dev = dev_priv->dev;
+       struct vmw_framebuffer_surface *vfbs;
+       int ret;
+
+       vfbs = kzalloc(sizeof(*vfbs), GFP_KERNEL);
+       if (!vfbs) {
+               ret = -ENOMEM;
+               goto out_err1;
+       }
+
+       ret = drm_framebuffer_init(dev, &vfbs->base.base,
+                                  &vmw_framebuffer_surface_funcs);
+       if (ret)
+               goto out_err2;
+
+       if (!vmw_surface_reference(surface)) {
+               DRM_ERROR("failed to reference surface %p\n", surface);
+               goto out_err3;
+       }
+
+       /* XXX get the first 3 from the surface info */
+       vfbs->base.base.bits_per_pixel = 32;
+       vfbs->base.base.pitch = width * 32 / 4;
+       vfbs->base.base.depth = 24;
+       vfbs->base.base.width = width;
+       vfbs->base.base.height = height;
+       vfbs->base.pin = NULL;
+       vfbs->base.unpin = NULL;
+       vfbs->surface = surface;
+       mutex_init(&vfbs->work_lock);
+       INIT_DELAYED_WORK(&vfbs->d_work, &vmw_framebuffer_present_fs_callback);
+       *out = &vfbs->base;
+
+       return 0;
+
+out_err3:
+       drm_framebuffer_cleanup(&vfbs->base.base);
+out_err2:
+       kfree(vfbs);
+out_err1:
+       return ret;
+}
+
+/*
+ * Dmabuf framebuffer code
+ */
+
+#define vmw_framebuffer_to_vfbd(x) \
+       container_of(x, struct vmw_framebuffer_dmabuf, base.base)
+
+struct vmw_framebuffer_dmabuf {
+       struct vmw_framebuffer base;
+       struct vmw_dma_buffer *buffer;
+};
+
+void vmw_framebuffer_dmabuf_destroy(struct drm_framebuffer *framebuffer)
+{
+       struct vmw_framebuffer_dmabuf *vfbd =
+               vmw_framebuffer_to_vfbd(framebuffer);
+
+       drm_framebuffer_cleanup(framebuffer);
+       vmw_dmabuf_unreference(&vfbd->buffer);
+
+       kfree(vfbd);
+}
+
+int vmw_framebuffer_dmabuf_dirty(struct drm_framebuffer *framebuffer,
+                                unsigned flags, unsigned color,
+                                struct drm_clip_rect *clips,
+                                unsigned num_clips)
+{
+       struct vmw_private *dev_priv = vmw_priv(framebuffer->dev);
+       struct drm_clip_rect norect;
+       struct {
+               uint32_t header;
+               SVGAFifoCmdUpdate body;
+       } *cmd;
+       int i, increment = 1;
+
+       if (!num_clips ||
+           !(dev_priv->fifo.capabilities &
+             SVGA_FIFO_CAP_SCREEN_OBJECT)) {
+               num_clips = 1;
+               clips = &norect;
+               norect.x1 = norect.y1 = 0;
+               norect.x2 = framebuffer->width;
+               norect.y2 = framebuffer->height;
+       } else if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY) {
+               num_clips /= 2;
+               increment = 2;
+       }
+
+       cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd) * num_clips);
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Fifo reserve failed.\n");
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < num_clips; i++, clips += increment) {
+               cmd[i].header = cpu_to_le32(SVGA_CMD_UPDATE);
+               cmd[i].body.x = cpu_to_le32(clips[i].x1);
+               cmd[i].body.y = cpu_to_le32(clips[i].y1);
+               cmd[i].body.width = cpu_to_le32(clips[i].x2 - clips[i].x1);
+               cmd[i].body.height = cpu_to_le32(clips[i].y2 - clips[i].y1);
+       }
+
+       vmw_fifo_commit(dev_priv, sizeof(*cmd) * num_clips);
+
+       return 0;
+}
+
+static struct drm_framebuffer_funcs vmw_framebuffer_dmabuf_funcs = {
+       .destroy = vmw_framebuffer_dmabuf_destroy,
+       .dirty = vmw_framebuffer_dmabuf_dirty,
+       .create_handle = vmw_framebuffer_create_handle,
+};
+
+static int vmw_framebuffer_dmabuf_pin(struct vmw_framebuffer *vfb)
+{
+       struct vmw_private *dev_priv = vmw_priv(vfb->base.dev);
+       struct vmw_framebuffer_dmabuf *vfbd =
+               vmw_framebuffer_to_vfbd(&vfb->base);
+       int ret;
+
+       vmw_overlay_pause_all(dev_priv);
+
+       ret = vmw_dmabuf_to_start_of_vram(dev_priv, vfbd->buffer);
+
+       if (dev_priv->capabilities & SVGA_CAP_MULTIMON) {
+               vmw_write(dev_priv, SVGA_REG_NUM_GUEST_DISPLAYS, 1);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_IS_PRIMARY, true);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_X, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_Y, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_WIDTH, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_HEIGHT, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
+
+               vmw_write(dev_priv, SVGA_REG_ENABLE, 1);
+               vmw_write(dev_priv, SVGA_REG_WIDTH, vfb->base.width);
+               vmw_write(dev_priv, SVGA_REG_HEIGHT, vfb->base.height);
+               vmw_write(dev_priv, SVGA_REG_BITS_PER_PIXEL, vfb->base.bits_per_pixel);
+               vmw_write(dev_priv, SVGA_REG_DEPTH, vfb->base.depth);
+               vmw_write(dev_priv, SVGA_REG_RED_MASK, 0x00ff0000);
+               vmw_write(dev_priv, SVGA_REG_GREEN_MASK, 0x0000ff00);
+               vmw_write(dev_priv, SVGA_REG_BLUE_MASK, 0x000000ff);
+       } else
+               WARN_ON(true);
+
+       vmw_overlay_resume_all(dev_priv);
+
+       return 0;
+}
+
+static int vmw_framebuffer_dmabuf_unpin(struct vmw_framebuffer *vfb)
+{
+       struct vmw_private *dev_priv = vmw_priv(vfb->base.dev);
+       struct vmw_framebuffer_dmabuf *vfbd =
+               vmw_framebuffer_to_vfbd(&vfb->base);
+
+       if (!vfbd->buffer) {
+               WARN_ON(!vfbd->buffer);
+               return 0;
+       }
+
+       return vmw_dmabuf_from_vram(dev_priv, vfbd->buffer);
+}
+
+int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv,
+                                  struct vmw_dma_buffer *dmabuf,
+                                  struct vmw_framebuffer **out,
+                                  unsigned width, unsigned height)
+
+{
+       struct drm_device *dev = dev_priv->dev;
+       struct vmw_framebuffer_dmabuf *vfbd;
+       int ret;
+
+       vfbd = kzalloc(sizeof(*vfbd), GFP_KERNEL);
+       if (!vfbd) {
+               ret = -ENOMEM;
+               goto out_err1;
+       }
+
+       ret = drm_framebuffer_init(dev, &vfbd->base.base,
+                                  &vmw_framebuffer_dmabuf_funcs);
+       if (ret)
+               goto out_err2;
+
+       if (!vmw_dmabuf_reference(dmabuf)) {
+               DRM_ERROR("failed to reference dmabuf %p\n", dmabuf);
+               goto out_err3;
+       }
+
+       /* XXX get the first 3 from the surface info */
+       vfbd->base.base.bits_per_pixel = 32;
+       vfbd->base.base.pitch = width * 32 / 4;
+       vfbd->base.base.depth = 24;
+       vfbd->base.base.width = width;
+       vfbd->base.base.height = height;
+       vfbd->base.pin = vmw_framebuffer_dmabuf_pin;
+       vfbd->base.unpin = vmw_framebuffer_dmabuf_unpin;
+       vfbd->buffer = dmabuf;
+       *out = &vfbd->base;
+
+       return 0;
+
+out_err3:
+       drm_framebuffer_cleanup(&vfbd->base.base);
+out_err2:
+       kfree(vfbd);
+out_err1:
+       return ret;
+}
+
+/*
+ * Generic Kernel modesetting functions
+ */
+
+static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
+                                                struct drm_file *file_priv,
+                                                struct drm_mode_fb_cmd *mode_cmd)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       struct vmw_framebuffer *vfb = NULL;
+       struct vmw_surface *surface = NULL;
+       struct vmw_dma_buffer *bo = NULL;
+       int ret;
+
+       ret = vmw_user_surface_lookup_handle(dev_priv, tfile,
+                                            mode_cmd->handle, &surface);
+       if (ret)
+               goto try_dmabuf;
+
+       ret = vmw_kms_new_framebuffer_surface(dev_priv, surface, &vfb,
+                                             mode_cmd->width, mode_cmd->height);
+
+       /* vmw_user_surface_lookup takes one ref so does new_fb */
+       vmw_surface_unreference(&surface);
+
+       if (ret) {
+               DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret);
+               return NULL;
+       }
+       return &vfb->base;
+
+try_dmabuf:
+       DRM_INFO("%s: trying buffer\n", __func__);
+
+       ret = vmw_user_dmabuf_lookup(tfile, mode_cmd->handle, &bo);
+       if (ret) {
+               DRM_ERROR("failed to find buffer: %i\n", ret);
+               return NULL;
+       }
+
+       ret = vmw_kms_new_framebuffer_dmabuf(dev_priv, bo, &vfb,
+                                            mode_cmd->width, mode_cmd->height);
+
+       /* vmw_user_dmabuf_lookup takes one ref so does new_fb */
+       vmw_dmabuf_unreference(&bo);
+
+       if (ret) {
+               DRM_ERROR("failed to create vmw_framebuffer: %i\n", ret);
+               return NULL;
+       }
+
+       return &vfb->base;
+}
+
+static int vmw_kms_fb_changed(struct drm_device *dev)
+{
+       return 0;
+}
+
+static struct drm_mode_config_funcs vmw_kms_funcs = {
+       .fb_create = vmw_kms_fb_create,
+       .fb_changed = vmw_kms_fb_changed,
+};
+
+int vmw_kms_init(struct vmw_private *dev_priv)
+{
+       struct drm_device *dev = dev_priv->dev;
+       int ret;
+
+       drm_mode_config_init(dev);
+       dev->mode_config.funcs = &vmw_kms_funcs;
+       dev->mode_config.min_width = 640;
+       dev->mode_config.min_height = 480;
+       dev->mode_config.max_width = 2048;
+       dev->mode_config.max_height = 2048;
+
+       ret = vmw_kms_init_legacy_display_system(dev_priv);
+
+       return 0;
+}
+
+int vmw_kms_close(struct vmw_private *dev_priv)
+{
+       /*
+        * Docs says we should take the lock before calling this function
+        * but since it destroys encoders and our destructor calls
+        * drm_encoder_cleanup which takes the lock we deadlock.
+        */
+       drm_mode_config_cleanup(dev_priv->dev);
+       vmw_kms_close_legacy_display_system(dev_priv);
+       return 0;
+}
+
+int vmw_kms_cursor_bypass_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *file_priv)
+{
+       struct drm_vmw_cursor_bypass_arg *arg = data;
+       struct vmw_display_unit *du;
+       struct drm_mode_object *obj;
+       struct drm_crtc *crtc;
+       int ret = 0;
+
+
+       mutex_lock(&dev->mode_config.mutex);
+       if (arg->flags & DRM_VMW_CURSOR_BYPASS_ALL) {
+
+               list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+                       du = vmw_crtc_to_du(crtc);
+                       du->hotspot_x = arg->xhot;
+                       du->hotspot_y = arg->yhot;
+               }
+
+               mutex_unlock(&dev->mode_config.mutex);
+               return 0;
+       }
+
+       obj = drm_mode_object_find(dev, arg->crtc_id, DRM_MODE_OBJECT_CRTC);
+       if (!obj) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       crtc = obj_to_crtc(obj);
+       du = vmw_crtc_to_du(crtc);
+
+       du->hotspot_x = arg->xhot;
+       du->hotspot_y = arg->yhot;
+
+out:
+       mutex_unlock(&dev->mode_config.mutex);
+
+       return ret;
+}
+
+int vmw_kms_save_vga(struct vmw_private *vmw_priv)
+{
+       /*
+        * setup a single multimon monitor with the size
+        * of 0x0, this stops the UI from resizing when we
+        * change the framebuffer size
+        */
+       if (vmw_priv->capabilities & SVGA_CAP_MULTIMON) {
+               vmw_write(vmw_priv, SVGA_REG_NUM_GUEST_DISPLAYS, 1);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_IS_PRIMARY, true);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_X, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_Y, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_WIDTH, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_HEIGHT, 0);
+               vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
+       }
+
+       vmw_priv->vga_width = vmw_read(vmw_priv, SVGA_REG_WIDTH);
+       vmw_priv->vga_height = vmw_read(vmw_priv, SVGA_REG_HEIGHT);
+       vmw_priv->vga_bpp = vmw_read(vmw_priv, SVGA_REG_BITS_PER_PIXEL);
+       vmw_priv->vga_depth = vmw_read(vmw_priv, SVGA_REG_DEPTH);
+       vmw_priv->vga_pseudo = vmw_read(vmw_priv, SVGA_REG_PSEUDOCOLOR);
+       vmw_priv->vga_red_mask = vmw_read(vmw_priv, SVGA_REG_RED_MASK);
+       vmw_priv->vga_green_mask = vmw_read(vmw_priv, SVGA_REG_GREEN_MASK);
+       vmw_priv->vga_blue_mask = vmw_read(vmw_priv, SVGA_REG_BLUE_MASK);
+
+       return 0;
+}
+
+int vmw_kms_restore_vga(struct vmw_private *vmw_priv)
+{
+       vmw_write(vmw_priv, SVGA_REG_WIDTH, vmw_priv->vga_width);
+       vmw_write(vmw_priv, SVGA_REG_HEIGHT, vmw_priv->vga_height);
+       vmw_write(vmw_priv, SVGA_REG_BITS_PER_PIXEL, vmw_priv->vga_bpp);
+       vmw_write(vmw_priv, SVGA_REG_DEPTH, vmw_priv->vga_depth);
+       vmw_write(vmw_priv, SVGA_REG_PSEUDOCOLOR, vmw_priv->vga_pseudo);
+       vmw_write(vmw_priv, SVGA_REG_RED_MASK, vmw_priv->vga_red_mask);
+       vmw_write(vmw_priv, SVGA_REG_GREEN_MASK, vmw_priv->vga_green_mask);
+       vmw_write(vmw_priv, SVGA_REG_BLUE_MASK, vmw_priv->vga_blue_mask);
+
+       /* TODO check for multimon */
+       vmw_write(vmw_priv, SVGA_REG_NUM_GUEST_DISPLAYS, 0);
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
new file mode 100644 (file)
index 0000000..8b95249
--- /dev/null
@@ -0,0 +1,102 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef VMWGFX_KMS_H_
+#define VMWGFX_KMS_H_
+
+#include "drmP.h"
+#include "vmwgfx_drv.h"
+
+
+#define vmw_framebuffer_to_vfb(x) \
+       container_of(x, struct vmw_framebuffer, base)
+
+/**
+ * Base class for framebuffers
+ *
+ * @pin is called the when ever a crtc uses this framebuffer
+ * @unpin is called
+ */
+struct vmw_framebuffer {
+       struct drm_framebuffer base;
+       int (*pin)(struct vmw_framebuffer *fb);
+       int (*unpin)(struct vmw_framebuffer *fb);
+};
+
+
+#define vmw_crtc_to_du(x) \
+       container_of(x, struct vmw_display_unit, crtc)
+
+/*
+ * Basic cursor manipulation
+ */
+int vmw_cursor_update_image(struct vmw_private *dev_priv,
+                           u32 *image, u32 width, u32 height,
+                           u32 hotspotX, u32 hotspotY);
+void vmw_cursor_update_position(struct vmw_private *dev_priv,
+                               bool show, int x, int y);
+
+/**
+ * Base class display unit.
+ *
+ * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector
+ * so the display unit is all of them at the same time. This is true for both
+ * legacy multimon and screen objects.
+ */
+struct vmw_display_unit {
+       struct drm_crtc crtc;
+       struct drm_encoder encoder;
+       struct drm_connector connector;
+
+       struct vmw_surface *cursor_surface;
+       struct vmw_dma_buffer *cursor_dmabuf;
+       size_t cursor_age;
+
+       int cursor_x;
+       int cursor_y;
+
+       int hotspot_x;
+       int hotspot_y;
+
+       unsigned unit;
+};
+
+/*
+ * Shared display unit functions - vmwgfx_kms.c
+ */
+void vmw_display_unit_cleanup(struct vmw_display_unit *du);
+int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
+                          uint32_t handle, uint32_t width, uint32_t height);
+int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
+
+/*
+ * Legacy display unit functions - vmwgfx_ldu.h
+ */
+int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv);
+int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv);
+
+#endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
new file mode 100644 (file)
index 0000000..9089159
--- /dev/null
@@ -0,0 +1,516 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vmwgfx_kms.h"
+
+#define vmw_crtc_to_ldu(x) \
+       container_of(x, struct vmw_legacy_display_unit, base.crtc)
+#define vmw_encoder_to_ldu(x) \
+       container_of(x, struct vmw_legacy_display_unit, base.encoder)
+#define vmw_connector_to_ldu(x) \
+       container_of(x, struct vmw_legacy_display_unit, base.connector)
+
+struct vmw_legacy_display {
+       struct list_head active;
+
+       unsigned num_active;
+
+       struct vmw_framebuffer *fb;
+};
+
+/**
+ * Display unit using the legacy register interface.
+ */
+struct vmw_legacy_display_unit {
+       struct vmw_display_unit base;
+
+       struct list_head active;
+
+       unsigned unit;
+};
+
+static void vmw_ldu_destroy(struct vmw_legacy_display_unit *ldu)
+{
+       list_del_init(&ldu->active);
+       vmw_display_unit_cleanup(&ldu->base);
+       kfree(ldu);
+}
+
+
+/*
+ * Legacy Display Unit CRTC functions
+ */
+
+static void vmw_ldu_crtc_save(struct drm_crtc *crtc)
+{
+}
+
+static void vmw_ldu_crtc_restore(struct drm_crtc *crtc)
+{
+}
+
+static void vmw_ldu_crtc_gamma_set(struct drm_crtc *crtc,
+                                  u16 *r, u16 *g, u16 *b,
+                                  uint32_t size)
+{
+}
+
+static void vmw_ldu_crtc_destroy(struct drm_crtc *crtc)
+{
+       vmw_ldu_destroy(vmw_crtc_to_ldu(crtc));
+}
+
+static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
+{
+       struct vmw_legacy_display *lds = dev_priv->ldu_priv;
+       struct vmw_legacy_display_unit *entry;
+       struct drm_crtc *crtc;
+       int i = 0;
+
+       /* to stop the screen from changing size on resize */
+       vmw_write(dev_priv, SVGA_REG_NUM_GUEST_DISPLAYS, 0);
+       for (i = 0; i < lds->num_active; i++) {
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, i);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_IS_PRIMARY, !i);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_X, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_Y, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_WIDTH, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_HEIGHT, 0);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
+       }
+
+       /* Now set the mode */
+       vmw_write(dev_priv, SVGA_REG_NUM_GUEST_DISPLAYS, lds->num_active);
+       i = 0;
+       list_for_each_entry(entry, &lds->active, active) {
+               crtc = &entry->base.crtc;
+
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, i);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_IS_PRIMARY, !i);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_X, crtc->x);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_Y, crtc->y);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_WIDTH, crtc->mode.hdisplay);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_HEIGHT, crtc->mode.vdisplay);
+               vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
+
+               i++;
+       }
+
+       return 0;
+}
+
+static int vmw_ldu_del_active(struct vmw_private *vmw_priv,
+                             struct vmw_legacy_display_unit *ldu)
+{
+       struct vmw_legacy_display *ld = vmw_priv->ldu_priv;
+       if (list_empty(&ldu->active))
+               return 0;
+
+       list_del_init(&ldu->active);
+       if (--(ld->num_active) == 0) {
+               BUG_ON(!ld->fb);
+               if (ld->fb->unpin)
+                       ld->fb->unpin(ld->fb);
+               ld->fb = NULL;
+       }
+
+       return 0;
+}
+
+static int vmw_ldu_add_active(struct vmw_private *vmw_priv,
+                             struct vmw_legacy_display_unit *ldu,
+                             struct vmw_framebuffer *vfb)
+{
+       struct vmw_legacy_display *ld = vmw_priv->ldu_priv;
+       struct vmw_legacy_display_unit *entry;
+       struct list_head *at;
+
+       if (!list_empty(&ldu->active))
+               return 0;
+
+       at = &ld->active;
+       list_for_each_entry(entry, &ld->active, active) {
+               if (entry->unit > ldu->unit)
+                       break;
+
+               at = &entry->active;
+       }
+
+       list_add(&ldu->active, at);
+       if (ld->num_active++ == 0) {
+               BUG_ON(ld->fb);
+               if (vfb->pin)
+                       vfb->pin(vfb);
+               ld->fb = vfb;
+       }
+
+       return 0;
+}
+
+static int vmw_ldu_crtc_set_config(struct drm_mode_set *set)
+{
+       struct vmw_private *dev_priv;
+       struct vmw_legacy_display_unit *ldu;
+       struct drm_connector *connector;
+       struct drm_display_mode *mode;
+       struct drm_encoder *encoder;
+       struct vmw_framebuffer *vfb;
+       struct drm_framebuffer *fb;
+       struct drm_crtc *crtc;
+
+       if (!set)
+               return -EINVAL;
+
+       if (!set->crtc)
+               return -EINVAL;
+
+       /* get the ldu */
+       crtc = set->crtc;
+       ldu = vmw_crtc_to_ldu(crtc);
+       vfb = set->fb ? vmw_framebuffer_to_vfb(set->fb) : NULL;
+       dev_priv = vmw_priv(crtc->dev);
+
+       if (set->num_connectors > 1) {
+               DRM_ERROR("to many connectors\n");
+               return -EINVAL;
+       }
+
+       if (set->num_connectors == 1 &&
+           set->connectors[0] != &ldu->base.connector) {
+               DRM_ERROR("connector doesn't match %p %p\n",
+                       set->connectors[0], &ldu->base.connector);
+               return -EINVAL;
+       }
+
+       /* ldu only supports one fb active at the time */
+       if (dev_priv->ldu_priv->fb && vfb &&
+           dev_priv->ldu_priv->fb != vfb) {
+               DRM_ERROR("Multiple framebuffers not supported\n");
+               return -EINVAL;
+       }
+
+       /* since they always map one to one these are safe */
+       connector = &ldu->base.connector;
+       encoder = &ldu->base.encoder;
+
+       /* should we turn the crtc off? */
+       if (set->num_connectors == 0 || !set->mode || !set->fb) {
+
+               connector->encoder = NULL;
+               encoder->crtc = NULL;
+               crtc->fb = NULL;
+
+               vmw_ldu_del_active(dev_priv, ldu);
+
+               vmw_ldu_commit_list(dev_priv);
+
+               return 0;
+       }
+
+
+       /* we now know we want to set a mode */
+       mode = set->mode;
+       fb = set->fb;
+
+       if (set->x + mode->hdisplay > fb->width ||
+           set->y + mode->vdisplay > fb->height) {
+               DRM_ERROR("set outside of framebuffer\n");
+               return -EINVAL;
+       }
+
+       vmw_fb_off(dev_priv);
+
+       crtc->fb = fb;
+       encoder->crtc = crtc;
+       connector->encoder = encoder;
+       crtc->x = set->x;
+       crtc->y = set->y;
+       crtc->mode = *mode;
+
+       vmw_ldu_add_active(dev_priv, ldu, vfb);
+
+       vmw_ldu_commit_list(dev_priv);
+
+       return 0;
+}
+
+static struct drm_crtc_funcs vmw_legacy_crtc_funcs = {
+       .save = vmw_ldu_crtc_save,
+       .restore = vmw_ldu_crtc_restore,
+       .cursor_set = vmw_du_crtc_cursor_set,
+       .cursor_move = vmw_du_crtc_cursor_move,
+       .gamma_set = vmw_ldu_crtc_gamma_set,
+       .destroy = vmw_ldu_crtc_destroy,
+       .set_config = vmw_ldu_crtc_set_config,
+};
+
+/*
+ * Legacy Display Unit encoder functions
+ */
+
+static void vmw_ldu_encoder_destroy(struct drm_encoder *encoder)
+{
+       vmw_ldu_destroy(vmw_encoder_to_ldu(encoder));
+}
+
+static struct drm_encoder_funcs vmw_legacy_encoder_funcs = {
+       .destroy = vmw_ldu_encoder_destroy,
+};
+
+/*
+ * Legacy Display Unit connector functions
+ */
+
+static void vmw_ldu_connector_dpms(struct drm_connector *connector, int mode)
+{
+}
+
+static void vmw_ldu_connector_save(struct drm_connector *connector)
+{
+}
+
+static void vmw_ldu_connector_restore(struct drm_connector *connector)
+{
+}
+
+static enum drm_connector_status
+       vmw_ldu_connector_detect(struct drm_connector *connector)
+{
+       /* XXX vmwctrl should control connection status */
+       if (vmw_connector_to_ldu(connector)->base.unit == 0)
+               return connector_status_connected;
+       return connector_status_disconnected;
+}
+
+static struct drm_display_mode vmw_ldu_connector_builtin[] = {
+       /* 640x480@60Hz */
+       { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
+                  752, 800, 0, 480, 489, 492, 525, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
+       /* 800x600@60Hz */
+       { DRM_MODE("800x600",
+                  DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+                  40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628,
+                  0, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1024x768@60Hz */
+       { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048,
+                  1184, 1344, 0, 768, 771, 777, 806, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
+       /* 1152x864@75Hz */
+       { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216,
+                  1344, 1600, 0, 864, 865, 868, 900, 0,
+                  DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1280x768@60Hz */
+       { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 79500, 1280, 1344,
+                  1472, 1664, 0, 768, 771, 778, 798, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1280x800@60Hz */
+       { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 83500, 1280, 1352,
+                  1480, 1680, 0, 800, 803, 809, 831, 0,
+                  DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
+       /* 1280x960@60Hz */
+       { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1376,
+                  1488, 1800, 0, 960, 961, 964, 1000, 0,
+                  DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1280x1024@60Hz */
+       { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1328,
+                  1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
+                  DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1360x768@60Hz */
+       { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 85500, 1360, 1424,
+                  1536, 1792, 0, 768, 771, 777, 795, 0,
+                  DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1440x1050@60Hz */
+       { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 121750, 1400, 1488,
+                  1632, 1864, 0, 1050, 1053, 1057, 1089, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1440x900@60Hz */
+       { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 106500, 1440, 1520,
+                  1672, 1904, 0, 900, 903, 909, 934, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1600x1200@60Hz */
+       { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 1664,
+                  1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
+                  DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1680x1050@60Hz */
+       { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 146250, 1680, 1784,
+                  1960, 2240, 0, 1050, 1053, 1059, 1089, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1792x1344@60Hz */
+       { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 204750, 1792, 1920,
+                  2120, 2448, 0, 1344, 1345, 1348, 1394, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1853x1392@60Hz */
+       { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 218250, 1856, 1952,
+                  2176, 2528, 0, 1392, 1393, 1396, 1439, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1920x1200@60Hz */
+       { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 193250, 1920, 2056,
+                  2256, 2592, 0, 1200, 1203, 1209, 1245, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 1920x1440@60Hz */
+       { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 234000, 1920, 2048,
+                  2256, 2600, 0, 1440, 1441, 1444, 1500, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* 2560x1600@60Hz */
+       { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752,
+                  3032, 3504, 0, 1600, 1603, 1609, 1658, 0,
+                  DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
+       /* Terminate */
+       { DRM_MODE("", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) },
+};
+
+static int vmw_ldu_connector_fill_modes(struct drm_connector *connector,
+                                       uint32_t max_width, uint32_t max_height)
+{
+       struct drm_device *dev = connector->dev;
+       struct drm_display_mode *mode = NULL;
+       int i;
+
+       for (i = 0; vmw_ldu_connector_builtin[i].type != 0; i++) {
+               if (vmw_ldu_connector_builtin[i].hdisplay > max_width ||
+                   vmw_ldu_connector_builtin[i].vdisplay > max_height)
+                       continue;
+
+               mode = drm_mode_duplicate(dev, &vmw_ldu_connector_builtin[i]);
+               if (!mode)
+                       return 0;
+               mode->vrefresh = drm_mode_vrefresh(mode);
+
+               drm_mode_probed_add(connector, mode);
+       }
+
+       drm_mode_connector_list_update(connector);
+
+       return 1;
+}
+
+static int vmw_ldu_connector_set_property(struct drm_connector *connector,
+                                         struct drm_property *property,
+                                         uint64_t val)
+{
+       return 0;
+}
+
+static void vmw_ldu_connector_destroy(struct drm_connector *connector)
+{
+       vmw_ldu_destroy(vmw_connector_to_ldu(connector));
+}
+
+static struct drm_connector_funcs vmw_legacy_connector_funcs = {
+       .dpms = vmw_ldu_connector_dpms,
+       .save = vmw_ldu_connector_save,
+       .restore = vmw_ldu_connector_restore,
+       .detect = vmw_ldu_connector_detect,
+       .fill_modes = vmw_ldu_connector_fill_modes,
+       .set_property = vmw_ldu_connector_set_property,
+       .destroy = vmw_ldu_connector_destroy,
+};
+
+static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
+{
+       struct vmw_legacy_display_unit *ldu;
+       struct drm_device *dev = dev_priv->dev;
+       struct drm_connector *connector;
+       struct drm_encoder *encoder;
+       struct drm_crtc *crtc;
+
+       ldu = kzalloc(sizeof(*ldu), GFP_KERNEL);
+       if (!ldu)
+               return -ENOMEM;
+
+       ldu->unit = unit;
+       crtc = &ldu->base.crtc;
+       encoder = &ldu->base.encoder;
+       connector = &ldu->base.connector;
+
+       drm_connector_init(dev, connector, &vmw_legacy_connector_funcs,
+                          DRM_MODE_CONNECTOR_LVDS);
+       /* Initial status */
+       if (unit == 0)
+               connector->status = connector_status_connected;
+       else
+               connector->status = connector_status_disconnected;
+
+       drm_encoder_init(dev, encoder, &vmw_legacy_encoder_funcs,
+                        DRM_MODE_ENCODER_LVDS);
+       drm_mode_connector_attach_encoder(connector, encoder);
+       encoder->possible_crtcs = (1 << unit);
+       encoder->possible_clones = 0;
+
+       INIT_LIST_HEAD(&ldu->active);
+
+       drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs);
+
+       drm_connector_attach_property(connector,
+                                     dev->mode_config.dirty_info_property,
+                                     1);
+
+       return 0;
+}
+
+int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv)
+{
+       if (dev_priv->ldu_priv) {
+               DRM_INFO("ldu system already on\n");
+               return -EINVAL;
+       }
+
+       dev_priv->ldu_priv = kmalloc(GFP_KERNEL, sizeof(*dev_priv->ldu_priv));
+
+       if (!dev_priv->ldu_priv)
+               return -ENOMEM;
+
+       INIT_LIST_HEAD(&dev_priv->ldu_priv->active);
+       dev_priv->ldu_priv->num_active = 0;
+       dev_priv->ldu_priv->fb = NULL;
+
+       drm_mode_create_dirty_info_property(dev_priv->dev);
+
+       vmw_ldu_init(dev_priv, 0);
+       vmw_ldu_init(dev_priv, 1);
+       vmw_ldu_init(dev_priv, 2);
+       vmw_ldu_init(dev_priv, 3);
+       vmw_ldu_init(dev_priv, 4);
+       vmw_ldu_init(dev_priv, 5);
+       vmw_ldu_init(dev_priv, 6);
+       vmw_ldu_init(dev_priv, 7);
+
+       return 0;
+}
+
+int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv)
+{
+       if (!dev_priv->ldu_priv)
+               return -ENOSYS;
+
+       BUG_ON(!list_empty(&dev_priv->ldu_priv->active));
+
+       kfree(dev_priv->ldu_priv);
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
new file mode 100644 (file)
index 0000000..bb6e6a0
--- /dev/null
@@ -0,0 +1,634 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "drmP.h"
+#include "vmwgfx_drv.h"
+
+#include "ttm/ttm_placement.h"
+
+#include "svga_overlay.h"
+#include "svga_escape.h"
+
+#define VMW_MAX_NUM_STREAMS 1
+
+struct vmw_stream {
+       struct vmw_dma_buffer *buf;
+       bool claimed;
+       bool paused;
+       struct drm_vmw_control_stream_arg saved;
+};
+
+/**
+ * Overlay control
+ */
+struct vmw_overlay {
+       /*
+        * Each stream is a single overlay. In Xv these are called ports.
+        */
+       struct mutex mutex;
+       struct vmw_stream stream[VMW_MAX_NUM_STREAMS];
+};
+
+static inline struct vmw_overlay *vmw_overlay(struct drm_device *dev)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       return dev_priv ? dev_priv->overlay_priv : NULL;
+}
+
+struct vmw_escape_header {
+       uint32_t cmd;
+       SVGAFifoCmdEscape body;
+};
+
+struct vmw_escape_video_flush {
+       struct vmw_escape_header escape;
+       SVGAEscapeVideoFlush flush;
+};
+
+static inline void fill_escape(struct vmw_escape_header *header,
+                              uint32_t size)
+{
+       header->cmd = SVGA_CMD_ESCAPE;
+       header->body.nsid = SVGA_ESCAPE_NSID_VMWARE;
+       header->body.size = size;
+}
+
+static inline void fill_flush(struct vmw_escape_video_flush *cmd,
+                             uint32_t stream_id)
+{
+       fill_escape(&cmd->escape, sizeof(cmd->flush));
+       cmd->flush.cmdType = SVGA_ESCAPE_VMWARE_VIDEO_FLUSH;
+       cmd->flush.streamId = stream_id;
+}
+
+/**
+ * Pin or unpin a buffer in vram.
+ *
+ * @dev_priv:  Driver private.
+ * @buf:  DMA buffer to pin or unpin.
+ * @pin:  Pin buffer in vram if true.
+ * @interruptible:  Use interruptible wait.
+ *
+ * Takes the current masters ttm lock in read.
+ *
+ * Returns
+ * -ERESTARTSYS if interrupted by a signal.
+ */
+static int vmw_dmabuf_pin_in_vram(struct vmw_private *dev_priv,
+                                 struct vmw_dma_buffer *buf,
+                                 bool pin, bool interruptible)
+{
+       struct ttm_buffer_object *bo = &buf->base;
+       struct ttm_bo_global *glob = bo->glob;
+       struct ttm_placement *overlay_placement = &vmw_vram_placement;
+       int ret;
+
+       ret = ttm_read_lock(&dev_priv->active_master->lock, interruptible);
+       if (unlikely(ret != 0))
+               return ret;
+
+       ret = ttm_bo_reserve(bo, interruptible, false, false, 0);
+       if (unlikely(ret != 0))
+               goto err;
+
+       if (buf->gmr_bound) {
+               vmw_gmr_unbind(dev_priv, buf->gmr_id);
+               spin_lock(&glob->lru_lock);
+               ida_remove(&dev_priv->gmr_ida, buf->gmr_id);
+               spin_unlock(&glob->lru_lock);
+               buf->gmr_bound = NULL;
+       }
+
+       if (pin)
+               overlay_placement = &vmw_vram_ne_placement;
+
+       ret = ttm_bo_validate(bo, overlay_placement, interruptible, false);
+
+       ttm_bo_unreserve(bo);
+
+err:
+       ttm_read_unlock(&dev_priv->active_master->lock);
+
+       return ret;
+}
+
+/**
+ * Send put command to hw.
+ *
+ * Returns
+ * -ERESTARTSYS if interrupted by a signal.
+ */
+static int vmw_overlay_send_put(struct vmw_private *dev_priv,
+                               struct vmw_dma_buffer *buf,
+                               struct drm_vmw_control_stream_arg *arg,
+                               bool interruptible)
+{
+       struct {
+               struct vmw_escape_header escape;
+               struct {
+                       struct {
+                               uint32_t cmdType;
+                               uint32_t streamId;
+                       } header;
+                       struct {
+                               uint32_t registerId;
+                               uint32_t value;
+                       } items[SVGA_VIDEO_PITCH_3 + 1];
+               } body;
+               struct vmw_escape_video_flush flush;
+       } *cmds;
+       uint32_t offset;
+       int i, ret;
+
+       for (;;) {
+               cmds = vmw_fifo_reserve(dev_priv, sizeof(*cmds));
+               if (cmds)
+                       break;
+
+               ret = vmw_fallback_wait(dev_priv, false, true, 0,
+                                       interruptible, 3*HZ);
+               if (interruptible && ret == -ERESTARTSYS)
+                       return ret;
+               else
+                       BUG_ON(ret != 0);
+       }
+
+       fill_escape(&cmds->escape, sizeof(cmds->body));
+       cmds->body.header.cmdType = SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS;
+       cmds->body.header.streamId = arg->stream_id;
+
+       for (i = 0; i <= SVGA_VIDEO_PITCH_3; i++)
+               cmds->body.items[i].registerId = i;
+
+       offset = buf->base.offset + arg->offset;
+
+       cmds->body.items[SVGA_VIDEO_ENABLED].value     = true;
+       cmds->body.items[SVGA_VIDEO_FLAGS].value       = arg->flags;
+       cmds->body.items[SVGA_VIDEO_DATA_OFFSET].value = offset;
+       cmds->body.items[SVGA_VIDEO_FORMAT].value      = arg->format;
+       cmds->body.items[SVGA_VIDEO_COLORKEY].value    = arg->color_key;
+       cmds->body.items[SVGA_VIDEO_SIZE].value        = arg->size;
+       cmds->body.items[SVGA_VIDEO_WIDTH].value       = arg->width;
+       cmds->body.items[SVGA_VIDEO_HEIGHT].value      = arg->height;
+       cmds->body.items[SVGA_VIDEO_SRC_X].value       = arg->src.x;
+       cmds->body.items[SVGA_VIDEO_SRC_Y].value       = arg->src.y;
+       cmds->body.items[SVGA_VIDEO_SRC_WIDTH].value   = arg->src.w;
+       cmds->body.items[SVGA_VIDEO_SRC_HEIGHT].value  = arg->src.h;
+       cmds->body.items[SVGA_VIDEO_DST_X].value       = arg->dst.x;
+       cmds->body.items[SVGA_VIDEO_DST_Y].value       = arg->dst.y;
+       cmds->body.items[SVGA_VIDEO_DST_WIDTH].value   = arg->dst.w;
+       cmds->body.items[SVGA_VIDEO_DST_HEIGHT].value  = arg->dst.h;
+       cmds->body.items[SVGA_VIDEO_PITCH_1].value     = arg->pitch[0];
+       cmds->body.items[SVGA_VIDEO_PITCH_2].value     = arg->pitch[1];
+       cmds->body.items[SVGA_VIDEO_PITCH_3].value     = arg->pitch[2];
+
+       fill_flush(&cmds->flush, arg->stream_id);
+
+       vmw_fifo_commit(dev_priv, sizeof(*cmds));
+
+       return 0;
+}
+
+/**
+ * Send stop command to hw.
+ *
+ * Returns
+ * -ERESTARTSYS if interrupted by a signal.
+ */
+static int vmw_overlay_send_stop(struct vmw_private *dev_priv,
+                                uint32_t stream_id,
+                                bool interruptible)
+{
+       struct {
+               struct vmw_escape_header escape;
+               SVGAEscapeVideoSetRegs body;
+               struct vmw_escape_video_flush flush;
+       } *cmds;
+       int ret;
+
+       for (;;) {
+               cmds = vmw_fifo_reserve(dev_priv, sizeof(*cmds));
+               if (cmds)
+                       break;
+
+               ret = vmw_fallback_wait(dev_priv, false, true, 0,
+                                       interruptible, 3*HZ);
+               if (interruptible && ret == -ERESTARTSYS)
+                       return ret;
+               else
+                       BUG_ON(ret != 0);
+       }
+
+       fill_escape(&cmds->escape, sizeof(cmds->body));
+       cmds->body.header.cmdType = SVGA_ESCAPE_VMWARE_VIDEO_SET_REGS;
+       cmds->body.header.streamId = stream_id;
+       cmds->body.items[0].registerId = SVGA_VIDEO_ENABLED;
+       cmds->body.items[0].value = false;
+       fill_flush(&cmds->flush, stream_id);
+
+       vmw_fifo_commit(dev_priv, sizeof(*cmds));
+
+       return 0;
+}
+
+/**
+ * Stop or pause a stream.
+ *
+ * If the stream is paused the no evict flag is removed from the buffer
+ * but left in vram. This allows for instance mode_set to evict it
+ * should it need to.
+ *
+ * The caller must hold the overlay lock.
+ *
+ * @stream_id which stream to stop/pause.
+ * @pause true to pause, false to stop completely.
+ */
+static int vmw_overlay_stop(struct vmw_private *dev_priv,
+                           uint32_t stream_id, bool pause,
+                           bool interruptible)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       struct vmw_stream *stream = &overlay->stream[stream_id];
+       int ret;
+
+       /* no buffer attached the stream is completely stopped */
+       if (!stream->buf)
+               return 0;
+
+       /* If the stream is paused this is already done */
+       if (!stream->paused) {
+               ret = vmw_overlay_send_stop(dev_priv, stream_id,
+                                           interruptible);
+               if (ret)
+                       return ret;
+
+               /* We just remove the NO_EVICT flag so no -ENOMEM */
+               ret = vmw_dmabuf_pin_in_vram(dev_priv, stream->buf, false,
+                                            interruptible);
+               if (interruptible && ret == -ERESTARTSYS)
+                       return ret;
+               else
+                       BUG_ON(ret != 0);
+       }
+
+       if (!pause) {
+               vmw_dmabuf_unreference(&stream->buf);
+               stream->paused = false;
+       } else {
+               stream->paused = true;
+       }
+
+       return 0;
+}
+
+/**
+ * Update a stream and send any put or stop fifo commands needed.
+ *
+ * The caller must hold the overlay lock.
+ *
+ * Returns
+ * -ENOMEM if buffer doesn't fit in vram.
+ * -ERESTARTSYS if interrupted.
+ */
+static int vmw_overlay_update_stream(struct vmw_private *dev_priv,
+                                    struct vmw_dma_buffer *buf,
+                                    struct drm_vmw_control_stream_arg *arg,
+                                    bool interruptible)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       struct vmw_stream *stream = &overlay->stream[arg->stream_id];
+       int ret = 0;
+
+       if (!buf)
+               return -EINVAL;
+
+       DRM_DEBUG("   %s: old %p, new %p, %spaused\n", __func__,
+                 stream->buf, buf, stream->paused ? "" : "not ");
+
+       if (stream->buf != buf) {
+               ret = vmw_overlay_stop(dev_priv, arg->stream_id,
+                                      false, interruptible);
+               if (ret)
+                       return ret;
+       } else if (!stream->paused) {
+               /* If the buffers match and not paused then just send
+                * the put command, no need to do anything else.
+                */
+               ret = vmw_overlay_send_put(dev_priv, buf, arg, interruptible);
+               if (ret == 0)
+                       stream->saved = *arg;
+               else
+                       BUG_ON(!interruptible);
+
+               return ret;
+       }
+
+       /* We don't start the old stream if we are interrupted.
+        * Might return -ENOMEM if it can't fit the buffer in vram.
+        */
+       ret = vmw_dmabuf_pin_in_vram(dev_priv, buf, true, interruptible);
+       if (ret)
+               return ret;
+
+       ret = vmw_overlay_send_put(dev_priv, buf, arg, interruptible);
+       if (ret) {
+               /* This one needs to happen no matter what. We only remove
+                * the NO_EVICT flag so this is safe from -ENOMEM.
+                */
+               BUG_ON(vmw_dmabuf_pin_in_vram(dev_priv, buf, false, false) != 0);
+               return ret;
+       }
+
+       if (stream->buf != buf)
+               stream->buf = vmw_dmabuf_reference(buf);
+       stream->saved = *arg;
+
+       return 0;
+}
+
+/**
+ * Stop all streams.
+ *
+ * Used by the fb code when starting.
+ *
+ * Takes the overlay lock.
+ */
+int vmw_overlay_stop_all(struct vmw_private *dev_priv)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       int i, ret;
+
+       if (!overlay)
+               return 0;
+
+       mutex_lock(&overlay->mutex);
+
+       for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) {
+               struct vmw_stream *stream = &overlay->stream[i];
+               if (!stream->buf)
+                       continue;
+
+               ret = vmw_overlay_stop(dev_priv, i, false, false);
+               WARN_ON(ret != 0);
+       }
+
+       mutex_unlock(&overlay->mutex);
+
+       return 0;
+}
+
+/**
+ * Try to resume all paused streams.
+ *
+ * Used by the kms code after moving a new scanout buffer to vram.
+ *
+ * Takes the overlay lock.
+ */
+int vmw_overlay_resume_all(struct vmw_private *dev_priv)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       int i, ret;
+
+       if (!overlay)
+               return 0;
+
+       mutex_lock(&overlay->mutex);
+
+       for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) {
+               struct vmw_stream *stream = &overlay->stream[i];
+               if (!stream->paused)
+                       continue;
+
+               ret = vmw_overlay_update_stream(dev_priv, stream->buf,
+                                               &stream->saved, false);
+               if (ret != 0)
+                       DRM_INFO("%s: *warning* failed to resume stream %i\n",
+                                __func__, i);
+       }
+
+       mutex_unlock(&overlay->mutex);
+
+       return 0;
+}
+
+/**
+ * Pauses all active streams.
+ *
+ * Used by the kms code when moving a new scanout buffer to vram.
+ *
+ * Takes the overlay lock.
+ */
+int vmw_overlay_pause_all(struct vmw_private *dev_priv)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       int i, ret;
+
+       if (!overlay)
+               return 0;
+
+       mutex_lock(&overlay->mutex);
+
+       for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) {
+               if (overlay->stream[i].paused)
+                       DRM_INFO("%s: *warning* stream %i already paused\n",
+                                __func__, i);
+               ret = vmw_overlay_stop(dev_priv, i, true, false);
+               WARN_ON(ret != 0);
+       }
+
+       mutex_unlock(&overlay->mutex);
+
+       return 0;
+}
+
+int vmw_overlay_ioctl(struct drm_device *dev, void *data,
+                     struct drm_file *file_priv)
+{
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       struct drm_vmw_control_stream_arg *arg =
+           (struct drm_vmw_control_stream_arg *)data;
+       struct vmw_dma_buffer *buf;
+       struct vmw_resource *res;
+       int ret;
+
+       if (!overlay)
+               return -ENOSYS;
+
+       ret = vmw_user_stream_lookup(dev_priv, tfile, &arg->stream_id, &res);
+       if (ret)
+               return ret;
+
+       mutex_lock(&overlay->mutex);
+
+       if (!arg->enabled) {
+               ret = vmw_overlay_stop(dev_priv, arg->stream_id, false, true);
+               goto out_unlock;
+       }
+
+       ret = vmw_user_dmabuf_lookup(tfile, arg->handle, &buf);
+       if (ret)
+               goto out_unlock;
+
+       ret = vmw_overlay_update_stream(dev_priv, buf, arg, true);
+
+       vmw_dmabuf_unreference(&buf);
+
+out_unlock:
+       mutex_unlock(&overlay->mutex);
+       vmw_resource_unreference(&res);
+
+       return ret;
+}
+
+int vmw_overlay_num_overlays(struct vmw_private *dev_priv)
+{
+       if (!dev_priv->overlay_priv)
+               return 0;
+
+       return VMW_MAX_NUM_STREAMS;
+}
+
+int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       int i, k;
+
+       if (!overlay)
+               return 0;
+
+       mutex_lock(&overlay->mutex);
+
+       for (i = 0, k = 0; i < VMW_MAX_NUM_STREAMS; i++)
+               if (!overlay->stream[i].claimed)
+                       k++;
+
+       mutex_unlock(&overlay->mutex);
+
+       return k;
+}
+
+int vmw_overlay_claim(struct vmw_private *dev_priv, uint32_t *out)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       int i;
+
+       if (!overlay)
+               return -ENOSYS;
+
+       mutex_lock(&overlay->mutex);
+
+       for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) {
+
+               if (overlay->stream[i].claimed)
+                       continue;
+
+               overlay->stream[i].claimed = true;
+               *out = i;
+               mutex_unlock(&overlay->mutex);
+               return 0;
+       }
+
+       mutex_unlock(&overlay->mutex);
+       return -ESRCH;
+}
+
+int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+
+       BUG_ON(stream_id >= VMW_MAX_NUM_STREAMS);
+
+       if (!overlay)
+               return -ENOSYS;
+
+       mutex_lock(&overlay->mutex);
+
+       WARN_ON(!overlay->stream[stream_id].claimed);
+       vmw_overlay_stop(dev_priv, stream_id, false, false);
+       overlay->stream[stream_id].claimed = false;
+
+       mutex_unlock(&overlay->mutex);
+       return 0;
+}
+
+int vmw_overlay_init(struct vmw_private *dev_priv)
+{
+       struct vmw_overlay *overlay;
+       int i;
+
+       if (dev_priv->overlay_priv)
+               return -EINVAL;
+
+       if (!(dev_priv->fifo.capabilities & SVGA_FIFO_CAP_VIDEO) &&
+            (dev_priv->fifo.capabilities & SVGA_FIFO_CAP_ESCAPE)) {
+               DRM_INFO("hardware doesn't support overlays\n");
+               return -ENOSYS;
+       }
+
+       overlay = kmalloc(GFP_KERNEL, sizeof(*overlay));
+       if (!overlay)
+               return -ENOMEM;
+
+       memset(overlay, 0, sizeof(*overlay));
+       mutex_init(&overlay->mutex);
+       for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) {
+               overlay->stream[i].buf = NULL;
+               overlay->stream[i].paused = false;
+               overlay->stream[i].claimed = false;
+       }
+
+       dev_priv->overlay_priv = overlay;
+
+       return 0;
+}
+
+int vmw_overlay_close(struct vmw_private *dev_priv)
+{
+       struct vmw_overlay *overlay = dev_priv->overlay_priv;
+       bool forgotten_buffer = false;
+       int i;
+
+       if (!overlay)
+               return -ENOSYS;
+
+       for (i = 0; i < VMW_MAX_NUM_STREAMS; i++) {
+               if (overlay->stream[i].buf) {
+                       forgotten_buffer = true;
+                       vmw_overlay_stop(dev_priv, i, false, false);
+               }
+       }
+
+       WARN_ON(forgotten_buffer);
+
+       dev_priv->overlay_priv = NULL;
+       kfree(overlay);
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_reg.h b/drivers/gpu/drm/vmwgfx/vmwgfx_reg.h
new file mode 100644 (file)
index 0000000..9d0dd3a
--- /dev/null
@@ -0,0 +1,57 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+/**
+ * This file contains virtual hardware defines for kernel space.
+ */
+
+#ifndef _VMWGFX_REG_H_
+#define _VMWGFX_REG_H_
+
+#include <linux/types.h>
+
+#define VMWGFX_INDEX_PORT     0x0
+#define VMWGFX_VALUE_PORT     0x1
+#define VMWGFX_IRQSTATUS_PORT 0x8
+
+struct svga_guest_mem_descriptor {
+       __le32 ppn;
+       __le32 num_pages;
+};
+
+struct svga_fifo_cmd_fence {
+       __le32 fence;
+};
+
+#define SVGA_SYNC_GENERIC         1
+#define SVGA_SYNC_FIFOFULL        2
+
+#include "svga_types.h"
+
+#include "svga3d_reg.h"
+
+#endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
new file mode 100644 (file)
index 0000000..c012d59
--- /dev/null
@@ -0,0 +1,1183 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vmwgfx_drv.h"
+#include "vmwgfx_drm.h"
+#include "ttm/ttm_object.h"
+#include "ttm/ttm_placement.h"
+#include "drmP.h"
+
+#define VMW_RES_CONTEXT ttm_driver_type0
+#define VMW_RES_SURFACE ttm_driver_type1
+#define VMW_RES_STREAM ttm_driver_type2
+
+struct vmw_user_context {
+       struct ttm_base_object base;
+       struct vmw_resource res;
+};
+
+struct vmw_user_surface {
+       struct ttm_base_object base;
+       struct vmw_surface srf;
+};
+
+struct vmw_user_dma_buffer {
+       struct ttm_base_object base;
+       struct vmw_dma_buffer dma;
+};
+
+struct vmw_bo_user_rep {
+       uint32_t handle;
+       uint64_t map_handle;
+};
+
+struct vmw_stream {
+       struct vmw_resource res;
+       uint32_t stream_id;
+};
+
+struct vmw_user_stream {
+       struct ttm_base_object base;
+       struct vmw_stream stream;
+};
+
+static inline struct vmw_dma_buffer *
+vmw_dma_buffer(struct ttm_buffer_object *bo)
+{
+       return container_of(bo, struct vmw_dma_buffer, base);
+}
+
+static inline struct vmw_user_dma_buffer *
+vmw_user_dma_buffer(struct ttm_buffer_object *bo)
+{
+       struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
+       return container_of(vmw_bo, struct vmw_user_dma_buffer, dma);
+}
+
+struct vmw_resource *vmw_resource_reference(struct vmw_resource *res)
+{
+       kref_get(&res->kref);
+       return res;
+}
+
+static void vmw_resource_release(struct kref *kref)
+{
+       struct vmw_resource *res =
+           container_of(kref, struct vmw_resource, kref);
+       struct vmw_private *dev_priv = res->dev_priv;
+
+       idr_remove(res->idr, res->id);
+       write_unlock(&dev_priv->resource_lock);
+
+       if (likely(res->hw_destroy != NULL))
+               res->hw_destroy(res);
+
+       if (res->res_free != NULL)
+               res->res_free(res);
+       else
+               kfree(res);
+
+       write_lock(&dev_priv->resource_lock);
+}
+
+void vmw_resource_unreference(struct vmw_resource **p_res)
+{
+       struct vmw_resource *res = *p_res;
+       struct vmw_private *dev_priv = res->dev_priv;
+
+       *p_res = NULL;
+       write_lock(&dev_priv->resource_lock);
+       kref_put(&res->kref, vmw_resource_release);
+       write_unlock(&dev_priv->resource_lock);
+}
+
+static int vmw_resource_init(struct vmw_private *dev_priv,
+                            struct vmw_resource *res,
+                            struct idr *idr,
+                            enum ttm_object_type obj_type,
+                            void (*res_free) (struct vmw_resource *res))
+{
+       int ret;
+
+       kref_init(&res->kref);
+       res->hw_destroy = NULL;
+       res->res_free = res_free;
+       res->res_type = obj_type;
+       res->idr = idr;
+       res->avail = false;
+       res->dev_priv = dev_priv;
+
+       do {
+               if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
+                       return -ENOMEM;
+
+               write_lock(&dev_priv->resource_lock);
+               ret = idr_get_new_above(idr, res, 1, &res->id);
+               write_unlock(&dev_priv->resource_lock);
+
+       } while (ret == -EAGAIN);
+
+       return ret;
+}
+
+/**
+ * vmw_resource_activate
+ *
+ * @res:        Pointer to the newly created resource
+ * @hw_destroy: Destroy function. NULL if none.
+ *
+ * Activate a resource after the hardware has been made aware of it.
+ * Set tye destroy function to @destroy. Typically this frees the
+ * resource and destroys the hardware resources associated with it.
+ * Activate basically means that the function vmw_resource_lookup will
+ * find it.
+ */
+
+static void vmw_resource_activate(struct vmw_resource *res,
+                                 void (*hw_destroy) (struct vmw_resource *))
+{
+       struct vmw_private *dev_priv = res->dev_priv;
+
+       write_lock(&dev_priv->resource_lock);
+       res->avail = true;
+       res->hw_destroy = hw_destroy;
+       write_unlock(&dev_priv->resource_lock);
+}
+
+struct vmw_resource *vmw_resource_lookup(struct vmw_private *dev_priv,
+                                        struct idr *idr, int id)
+{
+       struct vmw_resource *res;
+
+       read_lock(&dev_priv->resource_lock);
+       res = idr_find(idr, id);
+       if (res && res->avail)
+               kref_get(&res->kref);
+       else
+               res = NULL;
+       read_unlock(&dev_priv->resource_lock);
+
+       if (unlikely(res == NULL))
+               return NULL;
+
+       return res;
+}
+
+/**
+ * Context management:
+ */
+
+static void vmw_hw_context_destroy(struct vmw_resource *res)
+{
+
+       struct vmw_private *dev_priv = res->dev_priv;
+       struct {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdDestroyContext body;
+       } *cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
+
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Failed reserving FIFO space for surface "
+                         "destruction.\n");
+               return;
+       }
+
+       cmd->header.id = cpu_to_le32(SVGA_3D_CMD_CONTEXT_DESTROY);
+       cmd->header.size = cpu_to_le32(sizeof(cmd->body));
+       cmd->body.cid = cpu_to_le32(res->id);
+
+       vmw_fifo_commit(dev_priv, sizeof(*cmd));
+}
+
+static int vmw_context_init(struct vmw_private *dev_priv,
+                           struct vmw_resource *res,
+                           void (*res_free) (struct vmw_resource *res))
+{
+       int ret;
+
+       struct {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdDefineContext body;
+       } *cmd;
+
+       ret = vmw_resource_init(dev_priv, res, &dev_priv->context_idr,
+                               VMW_RES_CONTEXT, res_free);
+
+       if (unlikely(ret != 0)) {
+               if (res_free == NULL)
+                       kfree(res);
+               else
+                       res_free(res);
+               return ret;
+       }
+
+       cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Fifo reserve failed.\n");
+               vmw_resource_unreference(&res);
+               return -ENOMEM;
+       }
+
+       cmd->header.id = cpu_to_le32(SVGA_3D_CMD_CONTEXT_DEFINE);
+       cmd->header.size = cpu_to_le32(sizeof(cmd->body));
+       cmd->body.cid = cpu_to_le32(res->id);
+
+       vmw_fifo_commit(dev_priv, sizeof(*cmd));
+       vmw_resource_activate(res, vmw_hw_context_destroy);
+       return 0;
+}
+
+struct vmw_resource *vmw_context_alloc(struct vmw_private *dev_priv)
+{
+       struct vmw_resource *res = kmalloc(sizeof(*res), GFP_KERNEL);
+       int ret;
+
+       if (unlikely(res == NULL))
+               return NULL;
+
+       ret = vmw_context_init(dev_priv, res, NULL);
+       return (ret == 0) ? res : NULL;
+}
+
+/**
+ * User-space context management:
+ */
+
+static void vmw_user_context_free(struct vmw_resource *res)
+{
+       struct vmw_user_context *ctx =
+           container_of(res, struct vmw_user_context, res);
+
+       kfree(ctx);
+}
+
+/**
+ * This function is called when user space has no more references on the
+ * base object. It releases the base-object's reference on the resource object.
+ */
+
+static void vmw_user_context_base_release(struct ttm_base_object **p_base)
+{
+       struct ttm_base_object *base = *p_base;
+       struct vmw_user_context *ctx =
+           container_of(base, struct vmw_user_context, base);
+       struct vmw_resource *res = &ctx->res;
+
+       *p_base = NULL;
+       vmw_resource_unreference(&res);
+}
+
+int vmw_context_destroy_ioctl(struct drm_device *dev, void *data,
+                             struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_resource *res;
+       struct vmw_user_context *ctx;
+       struct drm_vmw_context_arg *arg = (struct drm_vmw_context_arg *)data;
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       int ret = 0;
+
+       res = vmw_resource_lookup(dev_priv, &dev_priv->context_idr, arg->cid);
+       if (unlikely(res == NULL))
+               return -EINVAL;
+
+       if (res->res_free != &vmw_user_context_free) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       ctx = container_of(res, struct vmw_user_context, res);
+       if (ctx->base.tfile != tfile && !ctx->base.shareable) {
+               ret = -EPERM;
+               goto out;
+       }
+
+       ttm_ref_object_base_unref(tfile, ctx->base.hash.key, TTM_REF_USAGE);
+out:
+       vmw_resource_unreference(&res);
+       return ret;
+}
+
+int vmw_context_define_ioctl(struct drm_device *dev, void *data,
+                            struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_user_context *ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
+       struct vmw_resource *res;
+       struct vmw_resource *tmp;
+       struct drm_vmw_context_arg *arg = (struct drm_vmw_context_arg *)data;
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       int ret;
+
+       if (unlikely(ctx == NULL))
+               return -ENOMEM;
+
+       res = &ctx->res;
+       ctx->base.shareable = false;
+       ctx->base.tfile = NULL;
+
+       ret = vmw_context_init(dev_priv, res, vmw_user_context_free);
+       if (unlikely(ret != 0))
+               return ret;
+
+       tmp = vmw_resource_reference(&ctx->res);
+       ret = ttm_base_object_init(tfile, &ctx->base, false, VMW_RES_CONTEXT,
+                                  &vmw_user_context_base_release, NULL);
+
+       if (unlikely(ret != 0)) {
+               vmw_resource_unreference(&tmp);
+               goto out_err;
+       }
+
+       arg->cid = res->id;
+out_err:
+       vmw_resource_unreference(&res);
+       return ret;
+
+}
+
+int vmw_context_check(struct vmw_private *dev_priv,
+                     struct ttm_object_file *tfile,
+                     int id)
+{
+       struct vmw_resource *res;
+       int ret = 0;
+
+       read_lock(&dev_priv->resource_lock);
+       res = idr_find(&dev_priv->context_idr, id);
+       if (res && res->avail) {
+               struct vmw_user_context *ctx =
+                       container_of(res, struct vmw_user_context, res);
+               if (ctx->base.tfile != tfile && !ctx->base.shareable)
+                       ret = -EPERM;
+       } else
+               ret = -EINVAL;
+       read_unlock(&dev_priv->resource_lock);
+
+       return ret;
+}
+
+
+/**
+ * Surface management.
+ */
+
+static void vmw_hw_surface_destroy(struct vmw_resource *res)
+{
+
+       struct vmw_private *dev_priv = res->dev_priv;
+       struct {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdDestroySurface body;
+       } *cmd = vmw_fifo_reserve(dev_priv, sizeof(*cmd));
+
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Failed reserving FIFO space for surface "
+                         "destruction.\n");
+               return;
+       }
+
+       cmd->header.id = cpu_to_le32(SVGA_3D_CMD_SURFACE_DESTROY);
+       cmd->header.size = cpu_to_le32(sizeof(cmd->body));
+       cmd->body.sid = cpu_to_le32(res->id);
+
+       vmw_fifo_commit(dev_priv, sizeof(*cmd));
+}
+
+void vmw_surface_res_free(struct vmw_resource *res)
+{
+       struct vmw_surface *srf = container_of(res, struct vmw_surface, res);
+
+       kfree(srf->sizes);
+       kfree(srf->snooper.image);
+       kfree(srf);
+}
+
+int vmw_surface_init(struct vmw_private *dev_priv,
+                    struct vmw_surface *srf,
+                    void (*res_free) (struct vmw_resource *res))
+{
+       int ret;
+       struct {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdDefineSurface body;
+       } *cmd;
+       SVGA3dSize *cmd_size;
+       struct vmw_resource *res = &srf->res;
+       struct drm_vmw_size *src_size;
+       size_t submit_size;
+       uint32_t cmd_len;
+       int i;
+
+       BUG_ON(res_free == NULL);
+       ret = vmw_resource_init(dev_priv, res, &dev_priv->surface_idr,
+                               VMW_RES_SURFACE, res_free);
+
+       if (unlikely(ret != 0)) {
+               res_free(res);
+               return ret;
+       }
+
+       submit_size = sizeof(*cmd) + srf->num_sizes * sizeof(SVGA3dSize);
+       cmd_len = sizeof(cmd->body) + srf->num_sizes * sizeof(SVGA3dSize);
+
+       cmd = vmw_fifo_reserve(dev_priv, submit_size);
+       if (unlikely(cmd == NULL)) {
+               DRM_ERROR("Fifo reserve failed for create surface.\n");
+               vmw_resource_unreference(&res);
+               return -ENOMEM;
+       }
+
+       cmd->header.id = cpu_to_le32(SVGA_3D_CMD_SURFACE_DEFINE);
+       cmd->header.size = cpu_to_le32(cmd_len);
+       cmd->body.sid = cpu_to_le32(res->id);
+       cmd->body.surfaceFlags = cpu_to_le32(srf->flags);
+       cmd->body.format = cpu_to_le32(srf->format);
+       for (i = 0; i < DRM_VMW_MAX_SURFACE_FACES; ++i) {
+               cmd->body.face[i].numMipLevels =
+                   cpu_to_le32(srf->mip_levels[i]);
+       }
+
+       cmd += 1;
+       cmd_size = (SVGA3dSize *) cmd;
+       src_size = srf->sizes;
+
+       for (i = 0; i < srf->num_sizes; ++i, cmd_size++, src_size++) {
+               cmd_size->width = cpu_to_le32(src_size->width);
+               cmd_size->height = cpu_to_le32(src_size->height);
+               cmd_size->depth = cpu_to_le32(src_size->depth);
+       }
+
+       vmw_fifo_commit(dev_priv, submit_size);
+       vmw_resource_activate(res, vmw_hw_surface_destroy);
+       return 0;
+}
+
+static void vmw_user_surface_free(struct vmw_resource *res)
+{
+       struct vmw_surface *srf = container_of(res, struct vmw_surface, res);
+       struct vmw_user_surface *user_srf =
+           container_of(srf, struct vmw_user_surface, srf);
+
+       kfree(srf->sizes);
+       kfree(srf->snooper.image);
+       kfree(user_srf);
+}
+
+int vmw_user_surface_lookup_handle(struct vmw_private *dev_priv,
+                                  struct ttm_object_file *tfile,
+                                  uint32_t handle, struct vmw_surface **out)
+{
+       struct vmw_resource *res;
+       struct vmw_surface *srf;
+       struct vmw_user_surface *user_srf;
+       struct ttm_base_object *base;
+       int ret = -EINVAL;
+
+       base = ttm_base_object_lookup(tfile, handle);
+       if (unlikely(base == NULL))
+               return -EINVAL;
+
+       if (unlikely(base->object_type != VMW_RES_SURFACE))
+               goto out_bad_resource;
+
+       user_srf = container_of(base, struct vmw_user_surface, base);
+       srf = &user_srf->srf;
+       res = &srf->res;
+
+       read_lock(&dev_priv->resource_lock);
+
+       if (!res->avail || res->res_free != &vmw_user_surface_free) {
+               read_unlock(&dev_priv->resource_lock);
+               goto out_bad_resource;
+       }
+
+       kref_get(&res->kref);
+       read_unlock(&dev_priv->resource_lock);
+
+       *out = srf;
+       ret = 0;
+
+out_bad_resource:
+       ttm_base_object_unref(&base);
+
+       return ret;
+}
+
+static void vmw_user_surface_base_release(struct ttm_base_object **p_base)
+{
+       struct ttm_base_object *base = *p_base;
+       struct vmw_user_surface *user_srf =
+           container_of(base, struct vmw_user_surface, base);
+       struct vmw_resource *res = &user_srf->srf.res;
+
+       *p_base = NULL;
+       vmw_resource_unreference(&res);
+}
+
+int vmw_surface_destroy_ioctl(struct drm_device *dev, void *data,
+                             struct drm_file *file_priv)
+{
+       struct drm_vmw_surface_arg *arg = (struct drm_vmw_surface_arg *)data;
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+
+       return ttm_ref_object_base_unref(tfile, arg->sid, TTM_REF_USAGE);
+}
+
+int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
+                            struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_user_surface *user_srf =
+           kmalloc(sizeof(*user_srf), GFP_KERNEL);
+       struct vmw_surface *srf;
+       struct vmw_resource *res;
+       struct vmw_resource *tmp;
+       union drm_vmw_surface_create_arg *arg =
+           (union drm_vmw_surface_create_arg *)data;
+       struct drm_vmw_surface_create_req *req = &arg->req;
+       struct drm_vmw_surface_arg *rep = &arg->rep;
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       struct drm_vmw_size __user *user_sizes;
+       int ret;
+       int i;
+
+       if (unlikely(user_srf == NULL))
+               return -ENOMEM;
+
+       srf = &user_srf->srf;
+       res = &srf->res;
+
+       srf->flags = req->flags;
+       srf->format = req->format;
+       memcpy(srf->mip_levels, req->mip_levels, sizeof(srf->mip_levels));
+       srf->num_sizes = 0;
+       for (i = 0; i < DRM_VMW_MAX_SURFACE_FACES; ++i)
+               srf->num_sizes += srf->mip_levels[i];
+
+       if (srf->num_sizes > DRM_VMW_MAX_SURFACE_FACES *
+           DRM_VMW_MAX_MIP_LEVELS) {
+               ret = -EINVAL;
+               goto out_err0;
+       }
+
+       srf->sizes = kmalloc(srf->num_sizes * sizeof(*srf->sizes), GFP_KERNEL);
+       if (unlikely(srf->sizes == NULL)) {
+               ret = -ENOMEM;
+               goto out_err0;
+       }
+
+       user_sizes = (struct drm_vmw_size __user *)(unsigned long)
+           req->size_addr;
+
+       ret = copy_from_user(srf->sizes, user_sizes,
+                            srf->num_sizes * sizeof(*srf->sizes));
+       if (unlikely(ret != 0))
+               goto out_err1;
+
+       user_srf->base.shareable = false;
+       user_srf->base.tfile = NULL;
+
+       /**
+        * From this point, the generic resource management functions
+        * destroy the object on failure.
+        */
+
+       ret = vmw_surface_init(dev_priv, srf, vmw_user_surface_free);
+       if (unlikely(ret != 0))
+               return ret;
+
+       tmp = vmw_resource_reference(&srf->res);
+       ret = ttm_base_object_init(tfile, &user_srf->base,
+                                  req->shareable, VMW_RES_SURFACE,
+                                  &vmw_user_surface_base_release, NULL);
+
+       if (unlikely(ret != 0)) {
+               vmw_resource_unreference(&tmp);
+               vmw_resource_unreference(&res);
+               return ret;
+       }
+
+       if (srf->flags & (1 << 9) &&
+           srf->num_sizes == 1 &&
+           srf->sizes[0].width == 64 &&
+           srf->sizes[0].height == 64 &&
+           srf->format == SVGA3D_A8R8G8B8) {
+
+               srf->snooper.image = kmalloc(64 * 64 * 4, GFP_KERNEL);
+               /* clear the image */
+               if (srf->snooper.image)
+                       memset(srf->snooper.image, 0x00, 64 * 64 * 4);
+               else
+                       DRM_ERROR("Failed to allocate cursor_image\n");
+
+       } else {
+               srf->snooper.image = NULL;
+       }
+       srf->snooper.crtc = NULL;
+
+       rep->sid = user_srf->base.hash.key;
+       if (rep->sid == SVGA3D_INVALID_ID)
+               DRM_ERROR("Created bad Surface ID.\n");
+
+       vmw_resource_unreference(&res);
+       return 0;
+out_err1:
+       kfree(srf->sizes);
+out_err0:
+       kfree(user_srf);
+       return ret;
+}
+
+int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
+                               struct drm_file *file_priv)
+{
+       union drm_vmw_surface_reference_arg *arg =
+           (union drm_vmw_surface_reference_arg *)data;
+       struct drm_vmw_surface_arg *req = &arg->req;
+       struct drm_vmw_surface_create_req *rep = &arg->rep;
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       struct vmw_surface *srf;
+       struct vmw_user_surface *user_srf;
+       struct drm_vmw_size __user *user_sizes;
+       struct ttm_base_object *base;
+       int ret = -EINVAL;
+
+       base = ttm_base_object_lookup(tfile, req->sid);
+       if (unlikely(base == NULL)) {
+               DRM_ERROR("Could not find surface to reference.\n");
+               return -EINVAL;
+       }
+
+       if (unlikely(base->object_type != VMW_RES_SURFACE))
+               goto out_bad_resource;
+
+       user_srf = container_of(base, struct vmw_user_surface, base);
+       srf = &user_srf->srf;
+
+       ret = ttm_ref_object_add(tfile, &user_srf->base, TTM_REF_USAGE, NULL);
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Could not add a reference to a surface.\n");
+               goto out_no_reference;
+       }
+
+       rep->flags = srf->flags;
+       rep->format = srf->format;
+       memcpy(rep->mip_levels, srf->mip_levels, sizeof(srf->mip_levels));
+       user_sizes = (struct drm_vmw_size __user *)(unsigned long)
+           rep->size_addr;
+
+       if (user_sizes)
+               ret = copy_to_user(user_sizes, srf->sizes,
+                                  srf->num_sizes * sizeof(*srf->sizes));
+       if (unlikely(ret != 0))
+               DRM_ERROR("copy_to_user failed %p %u\n",
+                         user_sizes, srf->num_sizes);
+out_bad_resource:
+out_no_reference:
+       ttm_base_object_unref(&base);
+
+       return ret;
+}
+
+int vmw_surface_check(struct vmw_private *dev_priv,
+                     struct ttm_object_file *tfile,
+                     uint32_t handle, int *id)
+{
+       struct ttm_base_object *base;
+       struct vmw_user_surface *user_srf;
+
+       int ret = -EPERM;
+
+       base = ttm_base_object_lookup(tfile, handle);
+       if (unlikely(base == NULL))
+               return -EINVAL;
+
+       if (unlikely(base->object_type != VMW_RES_SURFACE))
+               goto out_bad_surface;
+
+       user_srf = container_of(base, struct vmw_user_surface, base);
+       *id = user_srf->srf.res.id;
+       ret = 0;
+
+out_bad_surface:
+       /**
+        * FIXME: May deadlock here when called from the
+        * command parsing code.
+        */
+
+       ttm_base_object_unref(&base);
+       return ret;
+}
+
+/**
+ * Buffer management.
+ */
+
+static size_t vmw_dmabuf_acc_size(struct ttm_bo_global *glob,
+                                 unsigned long num_pages)
+{
+       static size_t bo_user_size = ~0;
+
+       size_t page_array_size =
+           (num_pages * sizeof(void *) + PAGE_SIZE - 1) & PAGE_MASK;
+
+       if (unlikely(bo_user_size == ~0)) {
+               bo_user_size = glob->ttm_bo_extra_size +
+                   ttm_round_pot(sizeof(struct vmw_dma_buffer));
+       }
+
+       return bo_user_size + page_array_size;
+}
+
+void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo)
+{
+       struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
+       struct ttm_bo_global *glob = bo->glob;
+       struct vmw_private *dev_priv =
+               container_of(bo->bdev, struct vmw_private, bdev);
+
+       ttm_mem_global_free(glob->mem_glob, bo->acc_size);
+       if (vmw_bo->gmr_bound) {
+               vmw_gmr_unbind(dev_priv, vmw_bo->gmr_id);
+               spin_lock(&glob->lru_lock);
+               ida_remove(&dev_priv->gmr_ida, vmw_bo->gmr_id);
+               spin_unlock(&glob->lru_lock);
+       }
+       kfree(vmw_bo);
+}
+
+int vmw_dmabuf_init(struct vmw_private *dev_priv,
+                   struct vmw_dma_buffer *vmw_bo,
+                   size_t size, struct ttm_placement *placement,
+                   bool interruptible,
+                   void (*bo_free) (struct ttm_buffer_object *bo))
+{
+       struct ttm_bo_device *bdev = &dev_priv->bdev;
+       struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
+       size_t acc_size;
+       int ret;
+
+       BUG_ON(!bo_free);
+
+       acc_size =
+           vmw_dmabuf_acc_size(bdev->glob,
+                               (size + PAGE_SIZE - 1) >> PAGE_SHIFT);
+
+       ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
+       if (unlikely(ret != 0)) {
+               /* we must free the bo here as
+                * ttm_buffer_object_init does so as well */
+               bo_free(&vmw_bo->base);
+               return ret;
+       }
+
+       memset(vmw_bo, 0, sizeof(*vmw_bo));
+
+       INIT_LIST_HEAD(&vmw_bo->gmr_lru);
+       INIT_LIST_HEAD(&vmw_bo->validate_list);
+       vmw_bo->gmr_id = 0;
+       vmw_bo->gmr_bound = false;
+
+       ret = ttm_bo_init(bdev, &vmw_bo->base, size,
+                         ttm_bo_type_device, placement,
+                         0, 0, interruptible,
+                         NULL, acc_size, bo_free);
+       return ret;
+}
+
+static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo)
+{
+       struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo);
+       struct vmw_dma_buffer *vmw_bo = &vmw_user_bo->dma;
+       struct ttm_bo_global *glob = bo->glob;
+       struct vmw_private *dev_priv =
+               container_of(bo->bdev, struct vmw_private, bdev);
+
+       ttm_mem_global_free(glob->mem_glob, bo->acc_size);
+       if (vmw_bo->gmr_bound) {
+               vmw_gmr_unbind(dev_priv, vmw_bo->gmr_id);
+               spin_lock(&glob->lru_lock);
+               ida_remove(&dev_priv->gmr_ida, vmw_bo->gmr_id);
+               spin_unlock(&glob->lru_lock);
+       }
+       kfree(vmw_user_bo);
+}
+
+static void vmw_user_dmabuf_release(struct ttm_base_object **p_base)
+{
+       struct vmw_user_dma_buffer *vmw_user_bo;
+       struct ttm_base_object *base = *p_base;
+       struct ttm_buffer_object *bo;
+
+       *p_base = NULL;
+
+       if (unlikely(base == NULL))
+               return;
+
+       vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, base);
+       bo = &vmw_user_bo->dma.base;
+       ttm_bo_unref(&bo);
+}
+
+int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data,
+                          struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       union drm_vmw_alloc_dmabuf_arg *arg =
+           (union drm_vmw_alloc_dmabuf_arg *)data;
+       struct drm_vmw_alloc_dmabuf_req *req = &arg->req;
+       struct drm_vmw_dmabuf_rep *rep = &arg->rep;
+       struct vmw_user_dma_buffer *vmw_user_bo;
+       struct ttm_buffer_object *tmp;
+       struct vmw_master *vmaster = vmw_master(file_priv->master);
+       int ret;
+
+       vmw_user_bo = kzalloc(sizeof(*vmw_user_bo), GFP_KERNEL);
+       if (unlikely(vmw_user_bo == NULL))
+               return -ENOMEM;
+
+       ret = ttm_read_lock(&vmaster->lock, true);
+       if (unlikely(ret != 0)) {
+               kfree(vmw_user_bo);
+               return ret;
+       }
+
+       ret = vmw_dmabuf_init(dev_priv, &vmw_user_bo->dma, req->size,
+                             &vmw_vram_placement, true,
+                             &vmw_user_dmabuf_destroy);
+       if (unlikely(ret != 0))
+               return ret;
+
+       tmp = ttm_bo_reference(&vmw_user_bo->dma.base);
+       ret = ttm_base_object_init(vmw_fpriv(file_priv)->tfile,
+                                  &vmw_user_bo->base,
+                                  false,
+                                  ttm_buffer_type,
+                                  &vmw_user_dmabuf_release, NULL);
+       if (unlikely(ret != 0)) {
+               ttm_bo_unref(&tmp);
+       } else {
+               rep->handle = vmw_user_bo->base.hash.key;
+               rep->map_handle = vmw_user_bo->dma.base.addr_space_offset;
+               rep->cur_gmr_id = vmw_user_bo->base.hash.key;
+               rep->cur_gmr_offset = 0;
+       }
+       ttm_bo_unref(&tmp);
+
+       ttm_read_unlock(&vmaster->lock);
+
+       return 0;
+}
+
+int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data,
+                          struct drm_file *file_priv)
+{
+       struct drm_vmw_unref_dmabuf_arg *arg =
+           (struct drm_vmw_unref_dmabuf_arg *)data;
+
+       return ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile,
+                                        arg->handle,
+                                        TTM_REF_USAGE);
+}
+
+uint32_t vmw_dmabuf_validate_node(struct ttm_buffer_object *bo,
+                                 uint32_t cur_validate_node)
+{
+       struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
+
+       if (likely(vmw_bo->on_validate_list))
+               return vmw_bo->cur_validate_node;
+
+       vmw_bo->cur_validate_node = cur_validate_node;
+       vmw_bo->on_validate_list = true;
+
+       return cur_validate_node;
+}
+
+void vmw_dmabuf_validate_clear(struct ttm_buffer_object *bo)
+{
+       struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
+
+       vmw_bo->on_validate_list = false;
+}
+
+uint32_t vmw_dmabuf_gmr(struct ttm_buffer_object *bo)
+{
+       struct vmw_dma_buffer *vmw_bo;
+
+       if (bo->mem.mem_type == TTM_PL_VRAM)
+               return SVGA_GMR_FRAMEBUFFER;
+
+       vmw_bo = vmw_dma_buffer(bo);
+
+       return (vmw_bo->gmr_bound) ? vmw_bo->gmr_id : SVGA_GMR_NULL;
+}
+
+void vmw_dmabuf_set_gmr(struct ttm_buffer_object *bo, uint32_t id)
+{
+       struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
+       vmw_bo->gmr_bound = true;
+       vmw_bo->gmr_id = id;
+}
+
+int vmw_user_dmabuf_lookup(struct ttm_object_file *tfile,
+                          uint32_t handle, struct vmw_dma_buffer **out)
+{
+       struct vmw_user_dma_buffer *vmw_user_bo;
+       struct ttm_base_object *base;
+
+       base = ttm_base_object_lookup(tfile, handle);
+       if (unlikely(base == NULL)) {
+               printk(KERN_ERR "Invalid buffer object handle 0x%08lx.\n",
+                      (unsigned long)handle);
+               return -ESRCH;
+       }
+
+       if (unlikely(base->object_type != ttm_buffer_type)) {
+               ttm_base_object_unref(&base);
+               printk(KERN_ERR "Invalid buffer object handle 0x%08lx.\n",
+                      (unsigned long)handle);
+               return -EINVAL;
+       }
+
+       vmw_user_bo = container_of(base, struct vmw_user_dma_buffer, base);
+       (void)ttm_bo_reference(&vmw_user_bo->dma.base);
+       ttm_base_object_unref(&base);
+       *out = &vmw_user_bo->dma;
+
+       return 0;
+}
+
+/**
+ * TODO: Implement a gmr id eviction mechanism. Currently we just fail
+ * when we're out of ids, causing GMR space to be allocated
+ * out of VRAM.
+ */
+
+int vmw_gmr_id_alloc(struct vmw_private *dev_priv, uint32_t *p_id)
+{
+       struct ttm_bo_global *glob = dev_priv->bdev.glob;
+       int id;
+       int ret;
+
+       do {
+               if (unlikely(ida_pre_get(&dev_priv->gmr_ida, GFP_KERNEL) == 0))
+                       return -ENOMEM;
+
+               spin_lock(&glob->lru_lock);
+               ret = ida_get_new(&dev_priv->gmr_ida, &id);
+               spin_unlock(&glob->lru_lock);
+       } while (ret == -EAGAIN);
+
+       if (unlikely(ret != 0))
+               return ret;
+
+       if (unlikely(id >= dev_priv->max_gmr_ids)) {
+               spin_lock(&glob->lru_lock);
+               ida_remove(&dev_priv->gmr_ida, id);
+               spin_unlock(&glob->lru_lock);
+               return -EBUSY;
+       }
+
+       *p_id = (uint32_t) id;
+       return 0;
+}
+
+/*
+ * Stream managment
+ */
+
+static void vmw_stream_destroy(struct vmw_resource *res)
+{
+       struct vmw_private *dev_priv = res->dev_priv;
+       struct vmw_stream *stream;
+       int ret;
+
+       DRM_INFO("%s: unref\n", __func__);
+       stream = container_of(res, struct vmw_stream, res);
+
+       ret = vmw_overlay_unref(dev_priv, stream->stream_id);
+       WARN_ON(ret != 0);
+}
+
+static int vmw_stream_init(struct vmw_private *dev_priv,
+                          struct vmw_stream *stream,
+                          void (*res_free) (struct vmw_resource *res))
+{
+       struct vmw_resource *res = &stream->res;
+       int ret;
+
+       ret = vmw_resource_init(dev_priv, res, &dev_priv->stream_idr,
+                               VMW_RES_STREAM, res_free);
+
+       if (unlikely(ret != 0)) {
+               if (res_free == NULL)
+                       kfree(stream);
+               else
+                       res_free(&stream->res);
+               return ret;
+       }
+
+       ret = vmw_overlay_claim(dev_priv, &stream->stream_id);
+       if (ret) {
+               vmw_resource_unreference(&res);
+               return ret;
+       }
+
+       DRM_INFO("%s: claimed\n", __func__);
+
+       vmw_resource_activate(&stream->res, vmw_stream_destroy);
+       return 0;
+}
+
+/**
+ * User-space context management:
+ */
+
+static void vmw_user_stream_free(struct vmw_resource *res)
+{
+       struct vmw_user_stream *stream =
+           container_of(res, struct vmw_user_stream, stream.res);
+
+       kfree(stream);
+}
+
+/**
+ * This function is called when user space has no more references on the
+ * base object. It releases the base-object's reference on the resource object.
+ */
+
+static void vmw_user_stream_base_release(struct ttm_base_object **p_base)
+{
+       struct ttm_base_object *base = *p_base;
+       struct vmw_user_stream *stream =
+           container_of(base, struct vmw_user_stream, base);
+       struct vmw_resource *res = &stream->stream.res;
+
+       *p_base = NULL;
+       vmw_resource_unreference(&res);
+}
+
+int vmw_stream_unref_ioctl(struct drm_device *dev, void *data,
+                          struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_resource *res;
+       struct vmw_user_stream *stream;
+       struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data;
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       int ret = 0;
+
+       res = vmw_resource_lookup(dev_priv, &dev_priv->stream_idr, arg->stream_id);
+       if (unlikely(res == NULL))
+               return -EINVAL;
+
+       if (res->res_free != &vmw_user_stream_free) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       stream = container_of(res, struct vmw_user_stream, stream.res);
+       if (stream->base.tfile != tfile) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       ttm_ref_object_base_unref(tfile, stream->base.hash.key, TTM_REF_USAGE);
+out:
+       vmw_resource_unreference(&res);
+       return ret;
+}
+
+int vmw_stream_claim_ioctl(struct drm_device *dev, void *data,
+                          struct drm_file *file_priv)
+{
+       struct vmw_private *dev_priv = vmw_priv(dev);
+       struct vmw_user_stream *stream = kmalloc(sizeof(*stream), GFP_KERNEL);
+       struct vmw_resource *res;
+       struct vmw_resource *tmp;
+       struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data;
+       struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
+       int ret;
+
+       if (unlikely(stream == NULL))
+               return -ENOMEM;
+
+       res = &stream->stream.res;
+       stream->base.shareable = false;
+       stream->base.tfile = NULL;
+
+       ret = vmw_stream_init(dev_priv, &stream->stream, vmw_user_stream_free);
+       if (unlikely(ret != 0))
+               return ret;
+
+       tmp = vmw_resource_reference(res);
+       ret = ttm_base_object_init(tfile, &stream->base, false, VMW_RES_STREAM,
+                                  &vmw_user_stream_base_release, NULL);
+
+       if (unlikely(ret != 0)) {
+               vmw_resource_unreference(&tmp);
+               goto out_err;
+       }
+
+       arg->stream_id = res->id;
+out_err:
+       vmw_resource_unreference(&res);
+       return ret;
+}
+
+int vmw_user_stream_lookup(struct vmw_private *dev_priv,
+                          struct ttm_object_file *tfile,
+                          uint32_t *inout_id, struct vmw_resource **out)
+{
+       struct vmw_user_stream *stream;
+       struct vmw_resource *res;
+       int ret;
+
+       res = vmw_resource_lookup(dev_priv, &dev_priv->stream_idr, *inout_id);
+       if (unlikely(res == NULL))
+               return -EINVAL;
+
+       if (res->res_free != &vmw_user_stream_free) {
+               ret = -EINVAL;
+               goto err_ref;
+       }
+
+       stream = container_of(res, struct vmw_user_stream, stream.res);
+       if (stream->base.tfile != tfile) {
+               ret = -EPERM;
+               goto err_ref;
+       }
+
+       *inout_id = stream->stream.stream_id;
+       *out = res;
+       return 0;
+err_ref:
+       vmw_resource_unreference(&res);
+       return ret;
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c
new file mode 100644 (file)
index 0000000..e3df4ad
--- /dev/null
@@ -0,0 +1,99 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "drmP.h"
+#include "vmwgfx_drv.h"
+
+int vmw_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+       struct drm_file *file_priv;
+       struct vmw_private *dev_priv;
+
+       if (unlikely(vma->vm_pgoff < VMWGFX_FILE_PAGE_OFFSET)) {
+               if (vmw_fifo_mmap(filp, vma) == 0)
+                       return 0;
+               return drm_mmap(filp, vma);
+       }
+
+       file_priv = (struct drm_file *)filp->private_data;
+       dev_priv = vmw_priv(file_priv->minor->dev);
+       return ttm_bo_mmap(filp, vma, &dev_priv->bdev);
+}
+
+static int vmw_ttm_mem_global_init(struct ttm_global_reference *ref)
+{
+       DRM_INFO("global init.\n");
+       return ttm_mem_global_init(ref->object);
+}
+
+static void vmw_ttm_mem_global_release(struct ttm_global_reference *ref)
+{
+       ttm_mem_global_release(ref->object);
+}
+
+int vmw_ttm_global_init(struct vmw_private *dev_priv)
+{
+       struct ttm_global_reference *global_ref;
+       int ret;
+
+       global_ref = &dev_priv->mem_global_ref;
+       global_ref->global_type = TTM_GLOBAL_TTM_MEM;
+       global_ref->size = sizeof(struct ttm_mem_global);
+       global_ref->init = &vmw_ttm_mem_global_init;
+       global_ref->release = &vmw_ttm_mem_global_release;
+
+       ret = ttm_global_item_ref(global_ref);
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Failed setting up TTM memory accounting.\n");
+               return ret;
+       }
+
+       dev_priv->bo_global_ref.mem_glob =
+               dev_priv->mem_global_ref.object;
+       global_ref = &dev_priv->bo_global_ref.ref;
+       global_ref->global_type = TTM_GLOBAL_TTM_BO;
+       global_ref->size = sizeof(struct ttm_bo_global);
+       global_ref->init = &ttm_bo_global_init;
+       global_ref->release = &ttm_bo_global_release;
+               ret = ttm_global_item_ref(global_ref);
+
+       if (unlikely(ret != 0)) {
+               DRM_ERROR("Failed setting up TTM buffer objects.\n");
+               goto out_no_bo;
+       }
+
+       return 0;
+out_no_bo:
+       ttm_global_item_unref(&dev_priv->mem_global_ref);
+       return ret;
+}
+
+void vmw_ttm_global_release(struct vmw_private *dev_priv)
+{
+       ttm_global_item_unref(&dev_priv->bo_global_ref.ref);
+       ttm_global_item_unref(&dev_priv->mem_global_ref);
+}
index 27ae750ca878436ec156dfedec7c0d26ce366adf..bf31592eaf79dc32757296f47191e6e66f1d2477 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef __HID_LG_H
 #define __HID_LG_H
 
-#include <linux/autoconf.h>
-
 #ifdef CONFIG_LOGITECH_FF
 int lgff_init(struct hid_device *hdev);
 #else
index 9e640c62ebd9d267c1efcc2800ae07c36854caf8..46c3c566307ea3feedc9a2e439dd741f49fa7167 100644 (file)
@@ -228,6 +228,18 @@ config SENSORS_K8TEMP
          This driver can also be built as a module.  If so, the module
          will be called k8temp.
 
+config SENSORS_K10TEMP
+       tristate "AMD Phenom/Sempron/Turion/Opteron temperature sensor"
+       depends on X86 && PCI
+       help
+         If you say yes here you get support for the temperature
+         sensor(s) inside your CPU. Supported are later revisions of
+         the AMD Family 10h and all revisions of the AMD Family 11h
+         microarchitectures.
+
+         This driver can also be built as a module.  If so, the module
+         will be called k10temp.
+
 config SENSORS_AMS
        tristate "Apple Motion Sensor driver"
        depends on PPC_PMAC && !PPC64 && INPUT && ((ADB_PMU && I2C = y) || (ADB_PMU && !I2C) || I2C) && EXPERIMENTAL
@@ -810,6 +822,14 @@ config SENSORS_TMP421
          This driver can also be built as a module.  If so, the module
          will be called tmp421.
 
+config SENSORS_VIA_CPUTEMP
+       tristate "VIA CPU temperature sensor"
+       depends on X86
+       help
+         If you say yes here you get support for the temperature
+         sensor inside your CPU. Supported are all known variants of
+         the VIA C7 and Nano.
+
 config SENSORS_VIA686A
        tristate "VIA686A"
        depends on PCI
@@ -998,6 +1018,23 @@ config SENSORS_LIS3_SPI
          will be called lis3lv02d and a specific module for the SPI transport
          is called lis3lv02d_spi.
 
+config SENSORS_LIS3_I2C
+       tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer (I2C)"
+       depends on I2C && INPUT
+       select INPUT_POLLDEV
+       default n
+       help
+         This driver provides support for the LIS3LV02Dx accelerometer connected
+         via I2C. The accelerometer data is readable via
+         /sys/devices/platform/lis3lv02d.
+
+         This driver also provides an absolute input class device, allowing
+         the device to act as a pinball machine-esque joystick.
+
+         This driver can also be built as modules.  If so, the core module
+         will be called lis3lv02d and a specific module for the I2C transport
+         is called lis3lv02d_i2c.
+
 config SENSORS_APPLESMC
        tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
        depends on INPUT && X86
@@ -1046,25 +1083,27 @@ config SENSORS_ATK0110
          will be called asus_atk0110.
 
 config SENSORS_LIS3LV02D
-       tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer"
+       tristate "STMicroeletronics LIS3* three-axis digital accelerometer"
        depends on INPUT
        select INPUT_POLLDEV
        select NEW_LEDS
        select LEDS_CLASS
        default n
        help
-         This driver provides support for the LIS3LV02Dx accelerometer. In
-         particular, it can be found in a number of HP laptops, which have the
-         "Mobile Data Protection System 3D" or "3D DriveGuard" feature. On such
-         systems the driver should load automatically (via ACPI). The
-         accelerometer might also be found in other systems, connected via SPI
-         or I2C.  The accelerometer data is readable via
-         /sys/devices/platform/lis3lv02d.
+         This driver provides support for the LIS3* accelerometers, such as the
+         LIS3LV02DL or the LIS331DL. In particular, it can be found in a number
+         of HP laptops, which have the "Mobile Data Protection System 3D" or
+         "3D DriveGuard" feature. On such systems the driver should load
+         automatically (via ACPI alias). The accelerometer might also be found
+         in other systems, connected via SPI or I2C. The accelerometer data is
+         readable via /sys/devices/platform/lis3lv02d.
 
          This driver also provides an absolute input class device, allowing
-         the laptop to act as a pinball machine-esque joystick. On HP laptops,
+         a laptop to act as a pinball machine-esque joystick. It provides also
+         a misc device which can be used to detect free-fall. On HP laptops,
          if the led infrastructure is activated, support for a led indicating
-         disk protection will be provided as hp:red:hddprotection.
+         disk protection will be provided as hp::hddprotect. For more
+         information on the feature, refer to Documentation/hwmon/lis3lv02d.
 
          This driver can also be built as modules.  If so, the core module
          will be called lis3lv02d and a specific module for HP laptops will be
index 33c2ee105284124ee1247823fc391c4611577771..450c8e89427794558fe34feed87004cc3c8605e0 100644 (file)
@@ -53,8 +53,10 @@ obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o
 obj-$(CONFIG_SENSORS_IBMPEX)   += ibmpex.o
 obj-$(CONFIG_SENSORS_IT87)     += it87.o
 obj-$(CONFIG_SENSORS_K8TEMP)   += k8temp.o
+obj-$(CONFIG_SENSORS_K10TEMP)  += k10temp.o
 obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o
 obj-$(CONFIG_SENSORS_LIS3_SPI) += lis3lv02d.o lis3lv02d_spi.o
+obj-$(CONFIG_SENSORS_LIS3_I2C) += lis3lv02d.o lis3lv02d_i2c.o
 obj-$(CONFIG_SENSORS_LM63)     += lm63.o
 obj-$(CONFIG_SENSORS_LM70)     += lm70.o
 obj-$(CONFIG_SENSORS_LM73)     += lm73.o
@@ -87,6 +89,7 @@ obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
 obj-$(CONFIG_SENSORS_THMC50)   += thmc50.o
 obj-$(CONFIG_SENSORS_TMP401)   += tmp401.o
 obj-$(CONFIG_SENSORS_TMP421)   += tmp421.o
+obj-$(CONFIG_SENSORS_VIA_CPUTEMP)+= via-cputemp.o
 obj-$(CONFIG_SENSORS_VIA686A)  += via686a.o
 obj-$(CONFIG_SENSORS_VT1211)   += vt1211.o
 obj-$(CONFIG_SENSORS_VT8231)   += vt8231.o
index 33acf29531afa30598e684ed82f2a56295d8a835..1ad0a885c5a5795034759dfc93c9c13015d211d5 100644 (file)
@@ -34,9 +34,8 @@
 static const unsigned short normal_i2c[] = {
        0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm,
-                       mc1066);
+enum chips {
+       adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1066 };
 
 /* adm1021 constants specified below */
 
@@ -97,7 +96,7 @@ struct adm1021_data {
 
 static int adm1021_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adm1021_detect(struct i2c_client *client, int kind,
+static int adm1021_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static void adm1021_init_client(struct i2c_client *client);
 static int adm1021_remove(struct i2c_client *client);
@@ -130,7 +129,7 @@ static struct i2c_driver adm1021_driver = {
        .remove         = adm1021_remove,
        .id_table       = adm1021_id,
        .detect         = adm1021_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static ssize_t show_temp(struct device *dev,
@@ -284,7 +283,7 @@ static const struct attribute_group adm1021_group = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adm1021_detect(struct i2c_client *client, int kind,
+static int adm1021_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index db6ac2b04f6f867ba2803b279539059faf4735db..251b63165e2a8ac96fa8314a2f629430561e6c4c 100644 (file)
 
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_2(adm1025, ne1619);
+enum chips { adm1025, ne1619 };
 
 /*
  * The ADM1025 registers
@@ -111,7 +107,7 @@ static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 };
 
 static int adm1025_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adm1025_detect(struct i2c_client *client, int kind,
+static int adm1025_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static void adm1025_init_client(struct i2c_client *client);
 static int adm1025_remove(struct i2c_client *client);
@@ -137,7 +133,7 @@ static struct i2c_driver adm1025_driver = {
        .remove         = adm1025_remove,
        .id_table       = adm1025_id,
        .detect         = adm1025_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -409,7 +405,7 @@ static const struct attribute_group adm1025_group_in4 = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adm1025_detect(struct i2c_client *client, int kind,
+static int adm1025_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index fb5363985e212d73bbef2132f6ce18e324855709..65335b268fa99860e50a0ad84d794c9640ea7913 100644 (file)
@@ -37,9 +37,6 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(adm1026);
-
 static int gpio_input[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
                                -1, -1, -1, -1, -1, -1, -1, -1 };
 static int gpio_output[17] = { -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -293,7 +290,7 @@ struct adm1026_data {
 
 static int adm1026_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adm1026_detect(struct i2c_client *client, int kind,
+static int adm1026_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int adm1026_remove(struct i2c_client *client);
 static int adm1026_read_value(struct i2c_client *client, u8 reg);
@@ -305,7 +302,7 @@ static void adm1026_init_client(struct i2c_client *client);
 
 
 static const struct i2c_device_id adm1026_id[] = {
-       { "adm1026", adm1026 },
+       { "adm1026", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, adm1026_id);
@@ -319,7 +316,7 @@ static struct i2c_driver adm1026_driver = {
        .remove         = adm1026_remove,
        .id_table       = adm1026_id,
        .detect         = adm1026_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static int adm1026_read_value(struct i2c_client *client, u8 reg)
@@ -1650,7 +1647,7 @@ static const struct attribute_group adm1026_group_in8_9 = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adm1026_detect(struct i2c_client *client, int kind,
+static int adm1026_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index ef91e2a4a5673b9045c636a24adda1ae0734d187..0b8a3b145bd24b3577c827383f50144c4d7c0ce7 100644 (file)
@@ -43,12 +43,6 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
                                                0x2e, 0x2f, I2C_CLIENT_END
 };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_1(adm1029);
-
 /*
  * The ADM1029 registers
  * Manufacturer ID is 0x41 for Analog Devices
@@ -117,7 +111,7 @@ static const u8 ADM1029_REG_FAN_DIV[] = {
 
 static int adm1029_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adm1029_detect(struct i2c_client *client, int kind,
+static int adm1029_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int adm1029_remove(struct i2c_client *client);
 static struct adm1029_data *adm1029_update_device(struct device *dev);
@@ -128,7 +122,7 @@ static int adm1029_init_client(struct i2c_client *client);
  */
 
 static const struct i2c_device_id adm1029_id[] = {
-       { "adm1029", adm1029 },
+       { "adm1029", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, adm1029_id);
@@ -142,7 +136,7 @@ static struct i2c_driver adm1029_driver = {
        .remove         = adm1029_remove,
        .id_table       = adm1029_id,
        .detect         = adm1029_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -297,7 +291,7 @@ static const struct attribute_group adm1029_group = {
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adm1029_detect(struct i2c_client *client, int kind,
+static int adm1029_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 0e722175aae0640f8b1922caa56d33c972c8b232..1644b92e7cc47ae8f8507d777cd1ecbe64612484 100644 (file)
@@ -64,8 +64,7 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_2(adm1030, adm1031);
+enum chips { adm1030, adm1031 };
 
 typedef u8 auto_chan_table_t[8][2];
 
@@ -102,7 +101,7 @@ struct adm1031_data {
 
 static int adm1031_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adm1031_detect(struct i2c_client *client, int kind,
+static int adm1031_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static void adm1031_init_client(struct i2c_client *client);
 static int adm1031_remove(struct i2c_client *client);
@@ -125,7 +124,7 @@ static struct i2c_driver adm1031_driver = {
        .remove         = adm1031_remove,
        .id_table       = adm1031_id,
        .detect         = adm1031_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static inline u8 adm1031_read_value(struct i2c_client *client, u8 reg)
@@ -813,7 +812,7 @@ static const struct attribute_group adm1031_group_opt = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adm1031_detect(struct i2c_client *client, int kind,
+static int adm1031_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 20e0481cc20611aca78cc4fa5f49f68bebcea16e..0727ad250793c866c56a091784d6f4073f28e755 100644 (file)
@@ -55,8 +55,7 @@
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
                                        I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_3(adm9240, ds1780, lm81);
+enum chips { adm9240, ds1780, lm81 };
 
 /* ADM9240 registers */
 #define ADM9240_REG_MAN_ID             0x3e
@@ -132,7 +131,7 @@ static inline unsigned int AOUT_FROM_REG(u8 reg)
 
 static int adm9240_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adm9240_detect(struct i2c_client *client, int kind,
+static int adm9240_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static void adm9240_init_client(struct i2c_client *client);
 static int adm9240_remove(struct i2c_client *client);
@@ -156,7 +155,7 @@ static struct i2c_driver adm9240_driver = {
        .remove         = adm9240_remove,
        .id_table       = adm9240_id,
        .detect         = adm9240_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /* per client data */
@@ -545,7 +544,7 @@ static const struct attribute_group adm9240_group = {
 /*** sensor chip detect and driver install ***/
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adm9240_detect(struct i2c_client *new_client, int kind,
+static int adm9240_detect(struct i2c_client *new_client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
index 451977bca7d6e02767f887951c58e8dd5c3b5cdf..aac85f3aed50e6cdd2c08fe065e464643303f4ca 100644 (file)
 static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
        I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(ads7828);
-
-/* Other module parameters */
+/* Module parameters */
 static int se_input = 1; /* Default is SE, 0 == diff */
 static int int_vref = 1; /* Default is internal ref ON */
 static int vref_mv = ADS7828_INT_VREF_MV; /* set if vref != 2.5V */
@@ -72,7 +69,7 @@ struct ads7828_data {
 };
 
 /* Function declaration - necessary due to function dependencies */
-static int ads7828_detect(struct i2c_client *client, int kind,
+static int ads7828_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int ads7828_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
@@ -168,7 +165,7 @@ static int ads7828_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id ads7828_id[] = {
-       { "ads7828", ads7828 },
+       { "ads7828", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, ads7828_id);
@@ -183,11 +180,11 @@ static struct i2c_driver ads7828_driver = {
        .remove = ads7828_remove,
        .id_table = ads7828_id,
        .detect = ads7828_detect,
-       .address_data = &addr_data,
+       .address_list = normal_i2c,
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int ads7828_detect(struct i2c_client *client, int kind,
+static int ads7828_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index f9c9562b6a94f0e6f136528c9831922f5119b4ae..a1a7ef14b519f68f80ae5c91f4169c2b5ff110fc 100644 (file)
@@ -32,9 +32,6 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(adt7462);
-
 /* ADT7462 registers */
 #define ADT7462_REG_DEVICE                     0x3D
 #define ADT7462_REG_VENDOR                     0x3E
@@ -237,12 +234,12 @@ struct adt7462_data {
 
 static int adt7462_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adt7462_detect(struct i2c_client *client, int kind,
+static int adt7462_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int adt7462_remove(struct i2c_client *client);
 
 static const struct i2c_device_id adt7462_id[] = {
-       { "adt7462", adt7462 },
+       { "adt7462", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, adt7462_id);
@@ -256,7 +253,7 @@ static struct i2c_driver adt7462_driver = {
        .remove         = adt7462_remove,
        .id_table       = adt7462_id,
        .detect         = adt7462_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -1902,7 +1899,7 @@ static struct attribute *adt7462_attr[] =
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adt7462_detect(struct i2c_client *client, int kind,
+static int adt7462_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 32b1750a6890bb41e95bca0df47027637a3e6d65..3445ce1cba81e730d2bc6c4a664587be6e644517 100644 (file)
@@ -33,9 +33,6 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(adt7470);
-
 /* ADT7470 registers */
 #define ADT7470_REG_BASE_ADDR                  0x20
 #define ADT7470_REG_TEMP_BASE_ADDR             0x20
@@ -177,12 +174,12 @@ struct adt7470_data {
 
 static int adt7470_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adt7470_detect(struct i2c_client *client, int kind,
+static int adt7470_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int adt7470_remove(struct i2c_client *client);
 
 static const struct i2c_device_id adt7470_id[] = {
-       { "adt7470", adt7470 },
+       { "adt7470", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, adt7470_id);
@@ -196,7 +193,7 @@ static struct i2c_driver adt7470_driver = {
        .remove         = adt7470_remove,
        .id_table       = adt7470_id,
        .detect         = adt7470_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -1225,7 +1222,7 @@ static struct attribute *adt7470_attr[] =
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adt7470_detect(struct i2c_client *client, int kind,
+static int adt7470_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index aea244db974e1acfdf63a552f649ddc1fea063b9..434576f61c84b7572575ceb26f698b23f1fece40 100644 (file)
@@ -32,9 +32,6 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2C, 0x2D, 0x2E, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(adt7473);
-
 /* ADT7473 registers */
 #define ADT7473_REG_BASE_ADDR                  0x20
 
@@ -166,12 +163,12 @@ struct adt7473_data {
 
 static int adt7473_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int adt7473_detect(struct i2c_client *client, int kind,
+static int adt7473_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int adt7473_remove(struct i2c_client *client);
 
 static const struct i2c_device_id adt7473_id[] = {
-       { "adt7473", adt7473 },
+       { "adt7473", 0 },
        { }
 };
 
@@ -184,7 +181,7 @@ static struct i2c_driver adt7473_driver = {
        .remove         = adt7473_remove,
        .id_table       = adt7473_id,
        .detect         = adt7473_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -1085,7 +1082,7 @@ static struct attribute *adt7473_attr[] =
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int adt7473_detect(struct i2c_client *client, int kind,
+static int adt7473_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 99abfddedbc3b842be2c017c0eb2e071693917e5..a0c385145686c3d068a9453ce80f8023ecf9cc7c 100644 (file)
 
 static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
-I2C_CLIENT_INSMOD_4(adt7473, adt7475, adt7476, adt7490);
+enum chips { adt7473, adt7475, adt7476, adt7490 };
 
 static const struct i2c_device_id adt7475_id[] = {
        { "adt7473", adt7473 },
@@ -1172,7 +1172,7 @@ static struct attribute_group in4_attr_group = { .attrs = in4_attrs };
 static struct attribute_group in5_attr_group = { .attrs = in5_attrs };
 static struct attribute_group vid_attr_group = { .attrs = vid_attrs };
 
-static int adt7475_detect(struct i2c_client *client, int kind,
+static int adt7475_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
@@ -1412,7 +1412,7 @@ static struct i2c_driver adt7475_driver = {
        .remove         = adt7475_remove,
        .id_table       = adt7475_id,
        .detect         = adt7475_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static void adt7475_read_hystersis(struct i2c_client *client)
index 7ea6a8f66056827970f31f13a3a3cedd135db1fd..c1605b528e8fcccfe26241efc96c138505f67839 100644 (file)
@@ -518,7 +518,7 @@ static int applesmc_pm_restore(struct device *dev)
        return applesmc_pm_resume(dev);
 }
 
-static struct dev_pm_ops applesmc_pm_ops = {
+static const struct dev_pm_ops applesmc_pm_ops = {
        .resume = applesmc_pm_resume,
        .restore = applesmc_pm_restore,
 };
index 480f80ea1fa00c1082ee7d89d381c8ba84a002ae..7dada559b3a19a85815002ce1ff76727306d4a23 100644 (file)
@@ -51,9 +51,6 @@
 /* I2C addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(asb100);
-
 static unsigned short force_subclients[4];
 module_param_array(force_subclients, short, NULL, 0);
 MODULE_PARM_DESC(force_subclients, "List of subclient addresses: "
@@ -209,14 +206,14 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 val);
 
 static int asb100_probe(struct i2c_client *client,
                        const struct i2c_device_id *id);
-static int asb100_detect(struct i2c_client *client, int kind,
+static int asb100_detect(struct i2c_client *client,
                         struct i2c_board_info *info);
 static int asb100_remove(struct i2c_client *client);
 static struct asb100_data *asb100_update_device(struct device *dev);
 static void asb100_init_client(struct i2c_client *client);
 
 static const struct i2c_device_id asb100_id[] = {
-       { "asb100", asb100 },
+       { "asb100", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, asb100_id);
@@ -230,7 +227,7 @@ static struct i2c_driver asb100_driver = {
        .remove         = asb100_remove,
        .id_table       = asb100_id,
        .detect         = asb100_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /* 7 Voltages */
@@ -697,7 +694,7 @@ ERROR_SC_2:
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int asb100_detect(struct i2c_client *client, int kind,
+static int asb100_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index d6b490d3e36f029660e079f6f42802329cd4bf4b..94cadc19f0c54d36885f80a21530905b99ab5bca 100644 (file)
@@ -44,17 +44,14 @@ MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");
 
 static const unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
 
-I2C_CLIENT_INSMOD_1(atxp1);
-
 static int atxp1_probe(struct i2c_client *client,
                       const struct i2c_device_id *id);
 static int atxp1_remove(struct i2c_client *client);
 static struct atxp1_data * atxp1_update_device(struct device *dev);
-static int atxp1_detect(struct i2c_client *client, int kind,
-                       struct i2c_board_info *info);
+static int atxp1_detect(struct i2c_client *client, struct i2c_board_info *info);
 
 static const struct i2c_device_id atxp1_id[] = {
-       { "atxp1", atxp1 },
+       { "atxp1", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, atxp1_id);
@@ -68,7 +65,7 @@ static struct i2c_driver atxp1_driver = {
        .remove         = atxp1_remove,
        .id_table       = atxp1_id,
        .detect         = atxp1_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 struct atxp1_data {
@@ -275,7 +272,7 @@ static const struct attribute_group atxp1_group = {
 
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int atxp1_detect(struct i2c_client *new_client, int kind,
+static int atxp1_detect(struct i2c_client *new_client,
                        struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
index 4377bb0cc5269d755e1b20095a095feedfb1e592..823dd28a902cf8c33e7d8de2d8a21b9a56f85db1 100644 (file)
@@ -57,11 +57,7 @@ MODULE_PARM_DESC(probe_all_addr, "Include probing of non-standard LPC "
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END};
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_2(dme1737, sch5027);
-
-/* ISA chip types */
-enum isa_chips { sch311x = sch5027 + 1 };
+enum chips { dme1737, sch5027, sch311x };
 
 /* ---------------------------------------------------------------------
  * Registers
@@ -2208,7 +2204,7 @@ exit:
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int dme1737_i2c_detect(struct i2c_client *client, int kind,
+static int dme1737_i2c_detect(struct i2c_client *client,
                              struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
@@ -2318,7 +2314,7 @@ static struct i2c_driver dme1737_i2c_driver = {
        .remove = dme1737_i2c_remove,
        .id_table = dme1737_id,
        .detect = dme1737_i2c_detect,
-       .address_data = &addr_data,
+       .address_list = normal_i2c,
 };
 
 /* ---------------------------------------------------------------------
index 2a4c6a05b14f594b5760f3d62c98b07d7dbc0bcc..e11363467a8d45cbd32207dde7f157254be76a10 100644 (file)
@@ -38,7 +38,6 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                                        0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_1(ds1621);
 static int polarity = -1;
 module_param(polarity, int, 0);
 MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low");
@@ -224,7 +223,7 @@ static const struct attribute_group ds1621_group = {
 
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int ds1621_detect(struct i2c_client *client, int kind,
+static int ds1621_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
@@ -305,8 +304,8 @@ static int ds1621_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id ds1621_id[] = {
-       { "ds1621", ds1621 },
-       { "ds1625", ds1621 },
+       { "ds1621", 0 },
+       { "ds1625", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, ds1621_id);
@@ -321,7 +320,7 @@ static struct i2c_driver ds1621_driver = {
        .remove         = ds1621_remove,
        .id_table       = ds1621_id,
        .detect         = ds1621_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static int __init ds1621_init(void)
index 40dfbcd3f3f2f704240a9ab957355208dfb39308..277398f9c93826dddb5233d7d4765c0f515011cc 100644 (file)
@@ -39,8 +39,7 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_2(f75373, f75375);
+enum chips { f75373, f75375 };
 
 /* Fintek F75375 registers  */
 #define F75375_REG_CONFIG0             0x0
@@ -113,7 +112,7 @@ struct f75375_data {
        s8 temp_max_hyst[2];
 };
 
-static int f75375_detect(struct i2c_client *client, int kind,
+static int f75375_detect(struct i2c_client *client,
                         struct i2c_board_info *info);
 static int f75375_probe(struct i2c_client *client,
                        const struct i2c_device_id *id);
@@ -135,7 +134,7 @@ static struct i2c_driver f75375_driver = {
        .remove = f75375_remove,
        .id_table = f75375_id,
        .detect = f75375_detect,
-       .address_data = &addr_data,
+       .address_list = normal_i2c,
 };
 
 static inline int f75375_read8(struct i2c_client *client, u8 reg)
@@ -677,7 +676,7 @@ static int f75375_remove(struct i2c_client *client)
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int f75375_detect(struct i2c_client *client, int kind,
+static int f75375_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 281829cd1533824b62b12d66d7c7e78c7c5b7623..bd0fc67e804b37cc12b690f902312c7c9ee7f639 100644 (file)
@@ -56,7 +56,8 @@ static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
        __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
-I2C_CLIENT_INSMOD_7(fscpos, fscher, fscscy, fschrc, fschmd, fschds, fscsyl);
+
+enum chips { fscpos, fscher, fscscy, fschrc, fschmd, fschds, fscsyl };
 
 /*
  * The FSCHMD registers and other defines
@@ -221,7 +222,7 @@ static const int FSCHMD_NO_TEMP_SENSORS[7] = { 3, 3, 4, 3, 5, 5, 11 };
 
 static int fschmd_probe(struct i2c_client *client,
                        const struct i2c_device_id *id);
-static int fschmd_detect(struct i2c_client *client, int kind,
+static int fschmd_detect(struct i2c_client *client,
                         struct i2c_board_info *info);
 static int fschmd_remove(struct i2c_client *client);
 static struct fschmd_data *fschmd_update_device(struct device *dev);
@@ -251,7 +252,7 @@ static struct i2c_driver fschmd_driver = {
        .remove         = fschmd_remove,
        .id_table       = fschmd_id,
        .detect         = fschmd_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -1000,7 +1001,7 @@ static void fschmd_dmi_decode(const struct dmi_header *header, void *dummy)
        }
 }
 
-static int fschmd_detect(struct i2c_client *client, int _kind,
+static int fschmd_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        enum chips kind;
index 1d69458aa0b641cab7da8c51f9b7f1825dd0a6a8..e7ae5743e1817c382c6ab8e56c415d3dea5ab19a 100644 (file)
@@ -46,8 +46,7 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_2(gl518sm_r00, gl518sm_r80);
+enum chips { gl518sm_r00, gl518sm_r80 };
 
 /* Many GL518 constants specified below */
 
@@ -139,8 +138,7 @@ struct gl518_data {
 
 static int gl518_probe(struct i2c_client *client,
                       const struct i2c_device_id *id);
-static int gl518_detect(struct i2c_client *client, int kind,
-                       struct i2c_board_info *info);
+static int gl518_detect(struct i2c_client *client, struct i2c_board_info *info);
 static void gl518_init_client(struct i2c_client *client);
 static int gl518_remove(struct i2c_client *client);
 static int gl518_read_value(struct i2c_client *client, u8 reg);
@@ -163,7 +161,7 @@ static struct i2c_driver gl518_driver = {
        .remove         = gl518_remove,
        .id_table       = gl518_id,
        .detect         = gl518_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -484,8 +482,7 @@ static const struct attribute_group gl518_group_r80 = {
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int gl518_detect(struct i2c_client *client, int kind,
-                       struct i2c_board_info *info)
+static int gl518_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
        int rev;
index 92b5720ceaffd57bdece90ce14bcfd37dfdf7888..ec588026f0a9c46c2ffd37347b5ac69da6f7b721 100644 (file)
@@ -41,9 +41,6 @@ MODULE_PARM_DESC(extra_sensor_type, "Type of extra sensor (0=autodetect, 1=tempe
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(gl520sm);
-
 /* Many GL520 constants specified below
 One of the inputs can be configured as either temp or voltage.
 That's why _TEMP2 and _IN4 access the same register
@@ -81,8 +78,7 @@ static const u8 GL520_REG_TEMP_MAX_HYST[]     = { 0x06, 0x18 };
 
 static int gl520_probe(struct i2c_client *client,
                       const struct i2c_device_id *id);
-static int gl520_detect(struct i2c_client *client, int kind,
-                       struct i2c_board_info *info);
+static int gl520_detect(struct i2c_client *client, struct i2c_board_info *info);
 static void gl520_init_client(struct i2c_client *client);
 static int gl520_remove(struct i2c_client *client);
 static int gl520_read_value(struct i2c_client *client, u8 reg);
@@ -91,7 +87,7 @@ static struct gl520_data *gl520_update_device(struct device *dev);
 
 /* Driver data */
 static const struct i2c_device_id gl520_id[] = {
-       { "gl520sm", gl520sm },
+       { "gl520sm", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, gl520_id);
@@ -105,7 +101,7 @@ static struct i2c_driver gl520_driver = {
        .remove         = gl520_remove,
        .id_table       = gl520_id,
        .detect         = gl520_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /* Client data */
@@ -681,8 +677,7 @@ static const struct attribute_group gl520_group_opt = {
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int gl520_detect(struct i2c_client *client, int kind,
-                       struct i2c_board_info *info)
+static int gl520_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
 
diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
new file mode 100644 (file)
index 0000000..d8a26d1
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * k10temp.c - AMD Family 10h/11h processor hardware monitoring
+ *
+ * Copyright (c) 2009 Clemens Ladisch <clemens@ladisch.de>
+ *
+ *
+ * This driver is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This driver is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this driver; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/err.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <asm/processor.h>
+
+MODULE_DESCRIPTION("AMD Family 10h/11h CPU core temperature monitor");
+MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
+MODULE_LICENSE("GPL");
+
+static bool force;
+module_param(force, bool, 0444);
+MODULE_PARM_DESC(force, "force loading on processors with erratum 319");
+
+#define REG_HARDWARE_THERMAL_CONTROL   0x64
+#define  HTC_ENABLE                    0x00000001
+
+#define REG_REPORTED_TEMPERATURE       0xa4
+
+#define REG_NORTHBRIDGE_CAPABILITIES   0xe8
+#define  NB_CAP_HTC                    0x00000400
+
+static ssize_t show_temp(struct device *dev,
+                        struct device_attribute *attr, char *buf)
+{
+       u32 regval;
+
+       pci_read_config_dword(to_pci_dev(dev),
+                             REG_REPORTED_TEMPERATURE, &regval);
+       return sprintf(buf, "%u\n", (regval >> 21) * 125);
+}
+
+static ssize_t show_temp_max(struct device *dev,
+                            struct device_attribute *attr, char *buf)
+{
+       return sprintf(buf, "%d\n", 70 * 1000);
+}
+
+static ssize_t show_temp_crit(struct device *dev,
+                             struct device_attribute *devattr, char *buf)
+{
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       int show_hyst = attr->index;
+       u32 regval;
+       int value;
+
+       pci_read_config_dword(to_pci_dev(dev),
+                             REG_HARDWARE_THERMAL_CONTROL, &regval);
+       value = ((regval >> 16) & 0x7f) * 500 + 52000;
+       if (show_hyst)
+               value -= ((regval >> 24) & 0xf) * 500;
+       return sprintf(buf, "%d\n", value);
+}
+
+static ssize_t show_name(struct device *dev,
+                        struct device_attribute *attr, char *buf)
+{
+       return sprintf(buf, "k10temp\n");
+}
+
+static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL);
+static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_max, NULL);
+static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL, 0);
+static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, show_temp_crit, NULL, 1);
+static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+
+static bool __devinit has_erratum_319(void)
+{
+       /*
+        * Erratum 319: The thermal sensor of older Family 10h processors
+        *              (B steppings) may be unreliable.
+        */
+       return boot_cpu_data.x86 == 0x10 && boot_cpu_data.x86_model <= 2;
+}
+
+static int __devinit k10temp_probe(struct pci_dev *pdev,
+                                  const struct pci_device_id *id)
+{
+       struct device *hwmon_dev;
+       u32 reg_caps, reg_htc;
+       int err;
+
+       if (has_erratum_319() && !force) {
+               dev_err(&pdev->dev,
+                       "unreliable CPU thermal sensor; monitoring disabled\n");
+               err = -ENODEV;
+               goto exit;
+       }
+
+       err = device_create_file(&pdev->dev, &dev_attr_temp1_input);
+       if (err)
+               goto exit;
+       err = device_create_file(&pdev->dev, &dev_attr_temp1_max);
+       if (err)
+               goto exit_remove;
+
+       pci_read_config_dword(pdev, REG_NORTHBRIDGE_CAPABILITIES, &reg_caps);
+       pci_read_config_dword(pdev, REG_HARDWARE_THERMAL_CONTROL, &reg_htc);
+       if ((reg_caps & NB_CAP_HTC) && (reg_htc & HTC_ENABLE)) {
+               err = device_create_file(&pdev->dev,
+                               &sensor_dev_attr_temp1_crit.dev_attr);
+               if (err)
+                       goto exit_remove;
+               err = device_create_file(&pdev->dev,
+                               &sensor_dev_attr_temp1_crit_hyst.dev_attr);
+               if (err)
+                       goto exit_remove;
+       }
+
+       err = device_create_file(&pdev->dev, &dev_attr_name);
+       if (err)
+               goto exit_remove;
+
+       hwmon_dev = hwmon_device_register(&pdev->dev);
+       if (IS_ERR(hwmon_dev)) {
+               err = PTR_ERR(hwmon_dev);
+               goto exit_remove;
+       }
+       dev_set_drvdata(&pdev->dev, hwmon_dev);
+
+       if (has_erratum_319() && force)
+               dev_warn(&pdev->dev,
+                        "unreliable CPU thermal sensor; check erratum 319\n");
+       return 0;
+
+exit_remove:
+       device_remove_file(&pdev->dev, &dev_attr_name);
+       device_remove_file(&pdev->dev, &dev_attr_temp1_input);
+       device_remove_file(&pdev->dev, &dev_attr_temp1_max);
+       device_remove_file(&pdev->dev,
+                          &sensor_dev_attr_temp1_crit.dev_attr);
+       device_remove_file(&pdev->dev,
+                          &sensor_dev_attr_temp1_crit_hyst.dev_attr);
+exit:
+       return err;
+}
+
+static void __devexit k10temp_remove(struct pci_dev *pdev)
+{
+       hwmon_device_unregister(dev_get_drvdata(&pdev->dev));
+       device_remove_file(&pdev->dev, &dev_attr_name);
+       device_remove_file(&pdev->dev, &dev_attr_temp1_input);
+       device_remove_file(&pdev->dev, &dev_attr_temp1_max);
+       device_remove_file(&pdev->dev,
+                          &sensor_dev_attr_temp1_crit.dev_attr);
+       device_remove_file(&pdev->dev,
+                          &sensor_dev_attr_temp1_crit_hyst.dev_attr);
+       dev_set_drvdata(&pdev->dev, NULL);
+}
+
+static struct pci_device_id k10temp_id_table[] = {
+       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC) },
+       { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_11H_NB_MISC) },
+       {}
+};
+MODULE_DEVICE_TABLE(pci, k10temp_id_table);
+
+static struct pci_driver k10temp_driver = {
+       .name = "k10temp",
+       .id_table = k10temp_id_table,
+       .probe = k10temp_probe,
+       .remove = __devexit_p(k10temp_remove),
+};
+
+static int __init k10temp_init(void)
+{
+       return pci_register_driver(&k10temp_driver);
+}
+
+static void __exit k10temp_exit(void)
+{
+       pci_unregister_driver(&k10temp_driver);
+}
+
+module_init(k10temp_init)
+module_exit(k10temp_exit)
index cf5afb9a10abbd9af3432dce36249a23edfcab0d..b2f2277cad3c01c714bc36634e6c23d4f56fc317 100644 (file)
 #define MDPS_POLL_INTERVAL 50
 /*
  * The sensor can also generate interrupts (DRDY) but it's pretty pointless
- * because their are generated even if the data do not change. So it's better
+ * because they are generated even if the data do not change. So it's better
  * to keep the interrupt for the free-fall event. The values are updated at
  * 40Hz (at the lowest frequency), but as it can be pretty time consuming on
  * some low processor, we poll the sensor only at 20Hz... enough for the
  * joystick.
  */
 
+#define LIS3_PWRON_DELAY_WAI_12B       (5000)
+#define LIS3_PWRON_DELAY_WAI_8B                (3000)
+
+/*
+ * LIS3LV02D spec says 1024 LSBs corresponds 1 G -> 1LSB is 1000/1024 mG
+ * LIS302D spec says: 18 mG / digit
+ * LIS3_ACCURACY is used to increase accuracy of the intermediate
+ * calculation results.
+ */
+#define LIS3_ACCURACY                  1024
+/* Sensitivity values for -2G +2G scale */
+#define LIS3_SENSITIVITY_12B           ((LIS3_ACCURACY * 1000) / 1024)
+#define LIS3_SENSITIVITY_8B            (18 * LIS3_ACCURACY)
+
+#define LIS3_DEFAULT_FUZZ              3
+#define LIS3_DEFAULT_FLAT              3
+
 struct lis3lv02d lis3_dev = {
        .misc_wait   = __WAIT_QUEUE_HEAD_INITIALIZER(lis3_dev.misc_wait),
 };
@@ -65,7 +82,7 @@ static s16 lis3lv02d_read_8(struct lis3lv02d *lis3, int reg)
        return lo;
 }
 
-static s16 lis3lv02d_read_16(struct lis3lv02d *lis3, int reg)
+static s16 lis3lv02d_read_12(struct lis3lv02d *lis3, int reg)
 {
        u8 lo, hi;
 
@@ -102,16 +119,106 @@ static inline int lis3lv02d_get_axis(s8 axis, int hw_values[3])
 static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z)
 {
        int position[3];
+       int i;
 
+       mutex_lock(&lis3->mutex);
        position[0] = lis3->read_data(lis3, OUTX);
        position[1] = lis3->read_data(lis3, OUTY);
        position[2] = lis3->read_data(lis3, OUTZ);
+       mutex_unlock(&lis3->mutex);
+
+       for (i = 0; i < 3; i++)
+               position[i] = (position[i] * lis3->scale) / LIS3_ACCURACY;
 
        *x = lis3lv02d_get_axis(lis3->ac.x, position);
        *y = lis3lv02d_get_axis(lis3->ac.y, position);
        *z = lis3lv02d_get_axis(lis3->ac.z, position);
 }
 
+/* conversion btw sampling rate and the register values */
+static int lis3_12_rates[4] = {40, 160, 640, 2560};
+static int lis3_8_rates[2] = {100, 400};
+
+/* ODR is Output Data Rate */
+static int lis3lv02d_get_odr(void)
+{
+       u8 ctrl;
+       int shift;
+
+       lis3_dev.read(&lis3_dev, CTRL_REG1, &ctrl);
+       ctrl &= lis3_dev.odr_mask;
+       shift = ffs(lis3_dev.odr_mask) - 1;
+       return lis3_dev.odrs[(ctrl >> shift)];
+}
+
+static int lis3lv02d_set_odr(int rate)
+{
+       u8 ctrl;
+       int i, len, shift;
+
+       lis3_dev.read(&lis3_dev, CTRL_REG1, &ctrl);
+       ctrl &= ~lis3_dev.odr_mask;
+       len = 1 << hweight_long(lis3_dev.odr_mask); /* # of possible values */
+       shift = ffs(lis3_dev.odr_mask) - 1;
+
+       for (i = 0; i < len; i++)
+               if (lis3_dev.odrs[i] == rate) {
+                       lis3_dev.write(&lis3_dev, CTRL_REG1,
+                                       ctrl | (i << shift));
+                       return 0;
+               }
+       return -EINVAL;
+}
+
+static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
+{
+       u8 reg;
+       s16 x, y, z;
+       u8 selftest;
+       int ret;
+
+       mutex_lock(&lis3->mutex);
+       if (lis3_dev.whoami == WAI_12B)
+               selftest = CTRL1_ST;
+       else
+               selftest = CTRL1_STP;
+
+       lis3->read(lis3, CTRL_REG1, &reg);
+       lis3->write(lis3, CTRL_REG1, (reg | selftest));
+       msleep(lis3->pwron_delay / lis3lv02d_get_odr());
+
+       /* Read directly to avoid axis remap */
+       x = lis3->read_data(lis3, OUTX);
+       y = lis3->read_data(lis3, OUTY);
+       z = lis3->read_data(lis3, OUTZ);
+
+       /* back to normal settings */
+       lis3->write(lis3, CTRL_REG1, reg);
+       msleep(lis3->pwron_delay / lis3lv02d_get_odr());
+
+       results[0] = x - lis3->read_data(lis3, OUTX);
+       results[1] = y - lis3->read_data(lis3, OUTY);
+       results[2] = z - lis3->read_data(lis3, OUTZ);
+
+       ret = 0;
+       if (lis3->pdata) {
+               int i;
+               for (i = 0; i < 3; i++) {
+                       /* Check against selftest acceptance limits */
+                       if ((results[i] < lis3->pdata->st_min_limits[i]) ||
+                           (results[i] > lis3->pdata->st_max_limits[i])) {
+                               ret = -EIO;
+                               goto fail;
+                       }
+               }
+       }
+
+       /* test passed */
+fail:
+       mutex_unlock(&lis3->mutex);
+       return ret;
+}
+
 void lis3lv02d_poweroff(struct lis3lv02d *lis3)
 {
        /* disable X,Y,Z axis and power down */
@@ -125,14 +232,19 @@ void lis3lv02d_poweron(struct lis3lv02d *lis3)
 
        lis3->init(lis3);
 
+       /* LIS3 power on delay is quite long */
+       msleep(lis3->pwron_delay / lis3lv02d_get_odr());
+
        /*
         * Common configuration
-        * BDU: LSB and MSB values are not updated until both have been read.
-        *      So the value read will always be correct.
+        * BDU: (12 bits sensors only) LSB and MSB values are not updated until
+        *      both have been read. So the value read will always be correct.
         */
-       lis3->read(lis3, CTRL_REG2, &reg);
-       reg |= CTRL2_BDU;
-       lis3->write(lis3, CTRL_REG2, reg);
+       if (lis3->whoami ==  WAI_12B) {
+               lis3->read(lis3, CTRL_REG2, &reg);
+               reg |= CTRL2_BDU;
+               lis3->write(lis3, CTRL_REG2, reg);
+       }
 }
 EXPORT_SYMBOL_GPL(lis3lv02d_poweron);
 
@@ -273,22 +385,17 @@ static void lis3lv02d_joystick_poll(struct input_polled_dev *pidev)
        int x, y, z;
 
        lis3lv02d_get_xyz(&lis3_dev, &x, &y, &z);
-       input_report_abs(pidev->input, ABS_X, x - lis3_dev.xcalib);
-       input_report_abs(pidev->input, ABS_Y, y - lis3_dev.ycalib);
-       input_report_abs(pidev->input, ABS_Z, z - lis3_dev.zcalib);
-}
-
-
-static inline void lis3lv02d_calibrate_joystick(void)
-{
-       lis3lv02d_get_xyz(&lis3_dev,
-               &lis3_dev.xcalib, &lis3_dev.ycalib, &lis3_dev.zcalib);
+       input_report_abs(pidev->input, ABS_X, x);
+       input_report_abs(pidev->input, ABS_Y, y);
+       input_report_abs(pidev->input, ABS_Z, z);
+       input_sync(pidev->input);
 }
 
 int lis3lv02d_joystick_enable(void)
 {
        struct input_dev *input_dev;
        int err;
+       int max_val, fuzz, flat;
 
        if (lis3_dev.idev)
                return -EINVAL;
@@ -301,8 +408,6 @@ int lis3lv02d_joystick_enable(void)
        lis3_dev.idev->poll_interval = MDPS_POLL_INTERVAL;
        input_dev = lis3_dev.idev->input;
 
-       lis3lv02d_calibrate_joystick();
-
        input_dev->name       = "ST LIS3LV02DL Accelerometer";
        input_dev->phys       = DRIVER_NAME "/input0";
        input_dev->id.bustype = BUS_HOST;
@@ -310,9 +415,12 @@ int lis3lv02d_joystick_enable(void)
        input_dev->dev.parent = &lis3_dev.pdev->dev;
 
        set_bit(EV_ABS, input_dev->evbit);
-       input_set_abs_params(input_dev, ABS_X, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3);
-       input_set_abs_params(input_dev, ABS_Y, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3);
-       input_set_abs_params(input_dev, ABS_Z, -lis3_dev.mdps_max_val, lis3_dev.mdps_max_val, 3, 3);
+       max_val = (lis3_dev.mdps_max_val * lis3_dev.scale) / LIS3_ACCURACY;
+       fuzz = (LIS3_DEFAULT_FUZZ * lis3_dev.scale) / LIS3_ACCURACY;
+       flat = (LIS3_DEFAULT_FLAT * lis3_dev.scale) / LIS3_ACCURACY;
+       input_set_abs_params(input_dev, ABS_X, -max_val, max_val, fuzz, flat);
+       input_set_abs_params(input_dev, ABS_Y, -max_val, max_val, fuzz, flat);
+       input_set_abs_params(input_dev, ABS_Z, -max_val, max_val, fuzz, flat);
 
        err = input_register_polled_device(lis3_dev.idev);
        if (err) {
@@ -332,11 +440,23 @@ void lis3lv02d_joystick_disable(void)
        if (lis3_dev.irq)
                misc_deregister(&lis3lv02d_misc_device);
        input_unregister_polled_device(lis3_dev.idev);
+       input_free_polled_device(lis3_dev.idev);
        lis3_dev.idev = NULL;
 }
 EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable);
 
 /* Sysfs stuff */
+static ssize_t lis3lv02d_selftest_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+       int result;
+       s16 values[3];
+
+       result = lis3lv02d_selftest(&lis3_dev, values);
+       return sprintf(buf, "%s %d %d %d\n", result == 0 ? "OK" : "FAIL",
+               values[0], values[1], values[2]);
+}
+
 static ssize_t lis3lv02d_position_show(struct device *dev,
                                struct device_attribute *attr, char *buf)
 {
@@ -346,41 +466,35 @@ static ssize_t lis3lv02d_position_show(struct device *dev,
        return sprintf(buf, "(%d,%d,%d)\n", x, y, z);
 }
 
-static ssize_t lis3lv02d_calibrate_show(struct device *dev,
-                               struct device_attribute *attr, char *buf)
+static ssize_t lis3lv02d_rate_show(struct device *dev,
+                       struct device_attribute *attr, char *buf)
 {
-       return sprintf(buf, "(%d,%d,%d)\n", lis3_dev.xcalib, lis3_dev.ycalib, lis3_dev.zcalib);
+       return sprintf(buf, "%d\n", lis3lv02d_get_odr());
 }
 
-static ssize_t lis3lv02d_calibrate_store(struct device *dev,
-                               struct device_attribute *attr,
-                               const char *buf, size_t count)
+static ssize_t lis3lv02d_rate_set(struct device *dev,
+                               struct device_attribute *attr, const char *buf,
+                               size_t count)
 {
-       lis3lv02d_calibrate_joystick();
-       return count;
-}
+       unsigned long rate;
 
-/* conversion btw sampling rate and the register values */
-static int lis3lv02dl_df_val[4] = {40, 160, 640, 2560};
-static ssize_t lis3lv02d_rate_show(struct device *dev,
-                       struct device_attribute *attr, char *buf)
-{
-       u8 ctrl;
-       int val;
+       if (strict_strtoul(buf, 0, &rate))
+               return -EINVAL;
 
-       lis3_dev.read(&lis3_dev, CTRL_REG1, &ctrl);
-       val = (ctrl & (CTRL1_DF0 | CTRL1_DF1)) >> 4;
-       return sprintf(buf, "%d\n", lis3lv02dl_df_val[val]);
+       if (lis3lv02d_set_odr(rate))
+               return -EINVAL;
+
+       return count;
 }
 
+static DEVICE_ATTR(selftest, S_IRUSR, lis3lv02d_selftest_show, NULL);
 static DEVICE_ATTR(position, S_IRUGO, lis3lv02d_position_show, NULL);
-static DEVICE_ATTR(calibrate, S_IRUGO|S_IWUSR, lis3lv02d_calibrate_show,
-       lis3lv02d_calibrate_store);
-static DEVICE_ATTR(rate, S_IRUGO, lis3lv02d_rate_show, NULL);
+static DEVICE_ATTR(rate, S_IRUGO | S_IWUSR, lis3lv02d_rate_show,
+                                           lis3lv02d_rate_set);
 
 static struct attribute *lis3lv02d_attributes[] = {
+       &dev_attr_selftest.attr,
        &dev_attr_position.attr,
-       &dev_attr_calibrate.attr,
        &dev_attr_rate.attr,
        NULL
 };
@@ -409,22 +523,30 @@ EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs);
 
 /*
  * Initialise the accelerometer and the various subsystems.
- * Should be rather independant of the bus system.
+ * Should be rather independent of the bus system.
  */
 int lis3lv02d_init_device(struct lis3lv02d *dev)
 {
        dev->whoami = lis3lv02d_read_8(dev, WHO_AM_I);
 
        switch (dev->whoami) {
-       case LIS_DOUBLE_ID:
-               printk(KERN_INFO DRIVER_NAME ": 2-byte sensor found\n");
-               dev->read_data = lis3lv02d_read_16;
+       case WAI_12B:
+               printk(KERN_INFO DRIVER_NAME ": 12 bits sensor found\n");
+               dev->read_data = lis3lv02d_read_12;
                dev->mdps_max_val = 2048;
+               dev->pwron_delay = LIS3_PWRON_DELAY_WAI_12B;
+               dev->odrs = lis3_12_rates;
+               dev->odr_mask = CTRL1_DF0 | CTRL1_DF1;
+               dev->scale = LIS3_SENSITIVITY_12B;
                break;
-       case LIS_SINGLE_ID:
-               printk(KERN_INFO DRIVER_NAME ": 1-byte sensor found\n");
+       case WAI_8B:
+               printk(KERN_INFO DRIVER_NAME ": 8 bits sensor found\n");
                dev->read_data = lis3lv02d_read_8;
                dev->mdps_max_val = 128;
+               dev->pwron_delay = LIS3_PWRON_DELAY_WAI_8B;
+               dev->odrs = lis3_8_rates;
+               dev->odr_mask = CTRL1_DR;
+               dev->scale = LIS3_SENSITIVITY_8B;
                break;
        default:
                printk(KERN_ERR DRIVER_NAME
@@ -432,6 +554,8 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
                return -EINVAL;
        }
 
+       mutex_init(&dev->mutex);
+
        lis3lv02d_add_fs(dev);
        lis3lv02d_poweron(dev);
 
@@ -443,7 +567,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
        if (dev->pdata) {
                struct lis3lv02d_platform_data *p = dev->pdata;
 
-               if (p->click_flags && (dev->whoami == LIS_SINGLE_ID)) {
+               if (p->click_flags && (dev->whoami == WAI_8B)) {
                        dev->write(dev, CLICK_CFG, p->click_flags);
                        dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit);
                        dev->write(dev, CLICK_LATENCY, p->click_latency);
@@ -454,7 +578,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
                                        (p->click_thresh_y << 4));
                }
 
-               if (p->wakeup_flags && (dev->whoami == LIS_SINGLE_ID)) {
+               if (p->wakeup_flags && (dev->whoami == WAI_8B)) {
                        dev->write(dev, FF_WU_CFG_1, p->wakeup_flags);
                        dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f);
                        /* default to 2.5ms for now */
@@ -484,4 +608,3 @@ EXPORT_SYMBOL_GPL(lis3lv02d_init_device);
 MODULE_DESCRIPTION("ST LIS3LV02Dx three-axis digital accelerometer driver");
 MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek");
 MODULE_LICENSE("GPL");
-
index 3e1ff46f72d3ac2cdfde3f3bf1b83637513c42b8..e6a01f44709b9de41a3821e9cfacd07bb42a9691 100644 (file)
@@ -2,7 +2,7 @@
  *  lis3lv02d.h - ST LIS3LV02DL accelerometer driver
  *
  *  Copyright (C) 2007-2008 Yan Burman
- *  Copyright (C) 2008 Eric Piel
+ *  Copyright (C) 2008-2009 Eric Piel
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
 #include <linux/input-polldev.h>
 
 /*
- * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to
- * be connected via SPI. There exists also several similar chips (such as LIS302DL or
- * LIS3L02DQ) and they have slightly different registers, but we can provide a
- * common interface for all of them.
- * They can also be connected via I²C.
+ * This driver tries to support the "digital" accelerometer chips from
+ * STMicroelectronics such as LIS3LV02DL, LIS302DL, LIS3L02DQ, LIS331DL,
+ * LIS35DE, or LIS202DL. They are very similar in terms of programming, with
+ * almost the same registers. In addition to differing on physical properties,
+ * they differ on the number of axes (2/3), precision (8/12 bits), and special
+ * features (freefall detection, click...). Unfortunately, not all the
+ * differences can be probed via a register.
+ * They can be connected either via I²C or SPI.
  */
 
 #include <linux/lis3lv02d.h>
 
-/* 2-byte registers */
-#define LIS_DOUBLE_ID  0x3A /* LIS3LV02D[LQ] */
-/* 1-byte registers */
-#define LIS_SINGLE_ID  0x3B /* LIS[32]02DL and others */
-
 enum lis3_reg {
        WHO_AM_I        = 0x0F,
        OFFSET_X        = 0x16,
@@ -94,7 +92,13 @@ enum lis3lv02d_reg {
        DD_THSE_H       = 0x3F,
 };
 
-enum lis3lv02d_ctrl1 {
+enum lis3_who_am_i {
+       WAI_12B         = 0x3A, /* 12 bits: LIS3LV02D[LQ]... */
+       WAI_8B          = 0x3B, /* 8 bits: LIS[23]02D[LQ]... */
+       WAI_6B          = 0x52, /* 6 bits: LIS331DLF - not supported */
+};
+
+enum lis3lv02d_ctrl1_12b {
        CTRL1_Xen       = 0x01,
        CTRL1_Yen       = 0x02,
        CTRL1_Zen       = 0x04,
@@ -104,6 +108,16 @@ enum lis3lv02d_ctrl1 {
        CTRL1_PD0       = 0x40,
        CTRL1_PD1       = 0x80,
 };
+
+/* Delta to ctrl1_12b version */
+enum lis3lv02d_ctrl1_8b {
+       CTRL1_STM       = 0x08,
+       CTRL1_STP       = 0x10,
+       CTRL1_FS        = 0x20,
+       CTRL1_PD        = 0x40,
+       CTRL1_DR        = 0x80,
+};
+
 enum lis3lv02d_ctrl2 {
        CTRL2_DAS       = 0x01,
        CTRL2_SIM       = 0x02,
@@ -194,16 +208,20 @@ struct lis3lv02d {
        int (*write) (struct lis3lv02d *lis3, int reg, u8 val);
        int (*read) (struct lis3lv02d *lis3, int reg, u8 *ret);
 
-       u8                      whoami;    /* 3Ah: 2-byte registries, 3Bh: 1-byte registries */
+       int                     *odrs;     /* Supported output data rates */
+       u8                      odr_mask;  /* ODR bit mask */
+       u8                      whoami;    /* indicates measurement precision */
        s16 (*read_data) (struct lis3lv02d *lis3, int reg);
        int                     mdps_max_val;
+       int                     pwron_delay;
+       int                     scale; /*
+                                       * relationship between 1 LBS and mG
+                                       * (1/1000th of earth gravity)
+                                       */
 
        struct input_polled_dev *idev;     /* input device */
        struct platform_device  *pdev;     /* platform device */
        atomic_t                count;     /* interrupt count after last read */
-       int                     xcalib;    /* calibrated null value for x */
-       int                     ycalib;    /* calibrated null value for y */
-       int                     zcalib;    /* calibrated null value for z */
        struct axis_conversion  ac;        /* hw -> logical axis */
 
        u32                     irq;       /* IRQ number */
@@ -212,6 +230,7 @@ struct lis3lv02d {
        unsigned long           misc_opened; /* bit0: whether the device is open */
 
        struct lis3lv02d_platform_data *pdata;  /* for passing board config */
+       struct mutex            mutex;     /* Serialize poll and selftest */
 };
 
 int lis3lv02d_init_device(struct lis3lv02d *lis3);
diff --git a/drivers/hwmon/lis3lv02d_i2c.c b/drivers/hwmon/lis3lv02d_i2c.c
new file mode 100644 (file)
index 0000000..dc1f540
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * drivers/hwmon/lis3lv02d_i2c.c
+ *
+ * Implements I2C interface for lis3lv02d (STMicroelectronics) accelerometer.
+ * Driver is based on corresponding SPI driver written by Daniel Mack
+ * (lis3lv02d_spi.c (C) 2009 Daniel Mack <daniel@caiaq.de> ).
+ *
+ * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: Samu Onkalo <samu.p.onkalo@nokia.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include "lis3lv02d.h"
+
+#define DRV_NAME       "lis3lv02d_i2c"
+
+static inline s32 lis3_i2c_write(struct lis3lv02d *lis3, int reg, u8 value)
+{
+       struct i2c_client *c = lis3->bus_priv;
+       return i2c_smbus_write_byte_data(c, reg, value);
+}
+
+static inline s32 lis3_i2c_read(struct lis3lv02d *lis3, int reg, u8 *v)
+{
+       struct i2c_client *c = lis3->bus_priv;
+       *v = i2c_smbus_read_byte_data(c, reg);
+       return 0;
+}
+
+static int lis3_i2c_init(struct lis3lv02d *lis3)
+{
+       u8 reg;
+       int ret;
+
+       /* power up the device */
+       ret = lis3->read(lis3, CTRL_REG1, &reg);
+       if (ret < 0)
+               return ret;
+
+       reg |= CTRL1_PD0;
+       return lis3->write(lis3, CTRL_REG1, reg);
+}
+
+/* Default axis mapping but it can be overwritten by platform data */
+static struct axis_conversion lis3lv02d_axis_map = { LIS3_DEV_X,
+                                                    LIS3_DEV_Y,
+                                                    LIS3_DEV_Z };
+
+static int __devinit lis3lv02d_i2c_probe(struct i2c_client *client,
+                                       const struct i2c_device_id *id)
+{
+       int ret = 0;
+       struct lis3lv02d_platform_data *pdata = client->dev.platform_data;
+
+       if (pdata) {
+               if (pdata->axis_x)
+                       lis3lv02d_axis_map.x = pdata->axis_x;
+
+               if (pdata->axis_y)
+                       lis3lv02d_axis_map.y = pdata->axis_y;
+
+               if (pdata->axis_z)
+                       lis3lv02d_axis_map.z = pdata->axis_z;
+
+               if (pdata->setup_resources)
+                       ret = pdata->setup_resources();
+
+               if (ret)
+                       goto fail;
+       }
+
+       lis3_dev.pdata    = pdata;
+       lis3_dev.bus_priv = client;
+       lis3_dev.init     = lis3_i2c_init;
+       lis3_dev.read     = lis3_i2c_read;
+       lis3_dev.write    = lis3_i2c_write;
+       lis3_dev.irq      = client->irq;
+       lis3_dev.ac       = lis3lv02d_axis_map;
+
+       i2c_set_clientdata(client, &lis3_dev);
+       ret = lis3lv02d_init_device(&lis3_dev);
+fail:
+       return ret;
+}
+
+static int __devexit lis3lv02d_i2c_remove(struct i2c_client *client)
+{
+       struct lis3lv02d *lis3 = i2c_get_clientdata(client);
+       struct lis3lv02d_platform_data *pdata = client->dev.platform_data;
+
+       if (pdata && pdata->release_resources)
+               pdata->release_resources();
+
+       lis3lv02d_joystick_disable();
+       lis3lv02d_poweroff(lis3);
+
+       return lis3lv02d_remove_fs(&lis3_dev);
+}
+
+#ifdef CONFIG_PM
+static int lis3lv02d_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+       struct lis3lv02d *lis3 = i2c_get_clientdata(client);
+
+       if (!lis3->pdata->wakeup_flags)
+               lis3lv02d_poweroff(lis3);
+       return 0;
+}
+
+static int lis3lv02d_i2c_resume(struct i2c_client *client)
+{
+       struct lis3lv02d *lis3 = i2c_get_clientdata(client);
+
+       if (!lis3->pdata->wakeup_flags)
+               lis3lv02d_poweron(lis3);
+       return 0;
+}
+
+static void lis3lv02d_i2c_shutdown(struct i2c_client *client)
+{
+       lis3lv02d_i2c_suspend(client, PMSG_SUSPEND);
+}
+#else
+#define lis3lv02d_i2c_suspend  NULL
+#define lis3lv02d_i2c_resume   NULL
+#define lis3lv02d_i2c_shutdown NULL
+#endif
+
+static const struct i2c_device_id lis3lv02d_id[] = {
+       {"lis3lv02d", 0 },
+       {}
+};
+
+MODULE_DEVICE_TABLE(i2c, lis3lv02d_id);
+
+static struct i2c_driver lis3lv02d_i2c_driver = {
+       .driver  = {
+               .name   = DRV_NAME,
+               .owner  = THIS_MODULE,
+       },
+       .suspend = lis3lv02d_i2c_suspend,
+       .shutdown = lis3lv02d_i2c_shutdown,
+       .resume = lis3lv02d_i2c_resume,
+       .probe  = lis3lv02d_i2c_probe,
+       .remove = __devexit_p(lis3lv02d_i2c_remove),
+       .id_table = lis3lv02d_id,
+};
+
+static int __init lis3lv02d_init(void)
+{
+       return i2c_add_driver(&lis3lv02d_i2c_driver);
+}
+
+static void __exit lis3lv02d_exit(void)
+{
+       i2c_del_driver(&lis3lv02d_i2c_driver);
+}
+
+MODULE_AUTHOR("Nokia Corporation");
+MODULE_DESCRIPTION("lis3lv02d I2C interface");
+MODULE_LICENSE("GPL");
+
+module_init(lis3lv02d_init);
+module_exit(lis3lv02d_exit);
index 5da66ab04f74d6e5abb05fa2468b25859d55b6c9..bf81aff7051dd44b009a062b9f3f5ba7799429c2 100644 (file)
 
 static const unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_1(lm63);
-
 /*
  * The LM63 registers
  */
@@ -134,8 +128,7 @@ static int lm63_remove(struct i2c_client *client);
 
 static struct lm63_data *lm63_update_device(struct device *dev);
 
-static int lm63_detect(struct i2c_client *client, int kind,
-                      struct i2c_board_info *info);
+static int lm63_detect(struct i2c_client *client, struct i2c_board_info *info);
 static void lm63_init_client(struct i2c_client *client);
 
 /*
@@ -143,7 +136,7 @@ static void lm63_init_client(struct i2c_client *client);
  */
 
 static const struct i2c_device_id lm63_id[] = {
-       { "lm63", lm63 },
+       { "lm63", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, lm63_id);
@@ -157,7 +150,7 @@ static struct i2c_driver lm63_driver = {
        .remove         = lm63_remove,
        .id_table       = lm63_id,
        .detect         = lm63_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -423,7 +416,7 @@ static const struct attribute_group lm63_group_fan1 = {
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm63_detect(struct i2c_client *new_client, int kind,
+static int lm63_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
index 0bf8b2a8e9f0957723f6ee59b75bcf5cf08a5084..c5f39ba103c0341d5a0207ec805d0b38c9f689e5 100644 (file)
@@ -27,9 +27,6 @@
 static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c,
                                        0x4d, 0x4e, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(lm73);
-
 /* LM73 registers */
 #define LM73_REG_INPUT         0x00
 #define LM73_REG_CONF          0x01
@@ -145,13 +142,13 @@ static int lm73_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id lm73_ids[] = {
-       { "lm73", lm73 },
+       { "lm73", 0 },
        { /* LIST END */ }
 };
 MODULE_DEVICE_TABLE(i2c, lm73_ids);
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm73_detect(struct i2c_client *new_client, int kind,
+static int lm73_detect(struct i2c_client *new_client,
                        struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
@@ -182,7 +179,7 @@ static struct i2c_driver lm73_driver = {
        .remove         = lm73_remove,
        .id_table       = lm73_ids,
        .detect         = lm73_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /* module glue */
index e392548cccb8c8c399ab44b511c9b40c197fef53..8ae2cfe2d827257a0e1eedbd61d1dc0e9fc8d572 100644 (file)
 
 /*
  * This driver handles the LM75 and compatible digital temperature sensors.
- * Only types which are _not_ listed in I2C_CLIENT_INSMOD_*() need to be
- * listed here.  We start at 9 since I2C_CLIENT_INSMOD_*() currently allow
- * definition of up to 8 chip types (plus zero).
  */
 
 enum lm75_type {               /* keep sorted in alphabetical order */
-       ds1775 = 9,
+       ds1775,
        ds75,
-       /* lm75 -- in I2C_CLIENT_INSMOD_1() */
+       lm75,
        lm75a,
        max6625,
        max6626,
@@ -58,9 +55,6 @@ enum lm75_type {              /* keep sorted in alphabetical order */
 static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                                        0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(lm75);
-
 
 /* The LM75 registers */
 #define LM75_REG_CONF          0x01
@@ -234,7 +228,7 @@ static const struct i2c_device_id lm75_ids[] = {
 MODULE_DEVICE_TABLE(i2c, lm75_ids);
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm75_detect(struct i2c_client *new_client, int kind,
+static int lm75_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
@@ -295,7 +289,7 @@ static struct i2c_driver lm75_driver = {
        .remove         = lm75_remove,
        .id_table       = lm75_ids,
        .detect         = lm75_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*-----------------------------------------------------------------------*/
index ac067fd1948212a42d3972696dbccc771238da05..b28a297be50c68267366139f2e0310bc87fdb54a 100644 (file)
@@ -39,9 +39,6 @@
 static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
                                                I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(lm77);
-
 /* The LM77 registers */
 #define LM77_REG_TEMP          0x00
 #define LM77_REG_CONF          0x01
@@ -66,8 +63,7 @@ struct lm77_data {
 
 static int lm77_probe(struct i2c_client *client,
                      const struct i2c_device_id *id);
-static int lm77_detect(struct i2c_client *client, int kind,
-                      struct i2c_board_info *info);
+static int lm77_detect(struct i2c_client *client, struct i2c_board_info *info);
 static void lm77_init_client(struct i2c_client *client);
 static int lm77_remove(struct i2c_client *client);
 static u16 lm77_read_value(struct i2c_client *client, u8 reg);
@@ -77,7 +73,7 @@ static struct lm77_data *lm77_update_device(struct device *dev);
 
 
 static const struct i2c_device_id lm77_id[] = {
-       { "lm77", lm77 },
+       { "lm77", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, lm77_id);
@@ -92,7 +88,7 @@ static struct i2c_driver lm77_driver = {
        .remove         = lm77_remove,
        .id_table       = lm77_id,
        .detect         = lm77_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /* straight from the datasheet */
@@ -245,7 +241,7 @@ static const struct attribute_group lm77_group = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm77_detect(struct i2c_client *new_client, int kind,
+static int lm77_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
index 5978291cebb370f63965e510947d48d0fa480e65..cadcbd90ff3bc4f0c89db6cdd9c9da82becc46f1 100644 (file)
@@ -41,8 +41,7 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
                                                0x2e, 0x2f, I2C_CLIENT_END };
 static unsigned short isa_address = 0x290;
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_2(lm78, lm79);
+enum chips { lm78, lm79 };
 
 /* Many LM78 constants specified below */
 
@@ -142,7 +141,7 @@ struct lm78_data {
 };
 
 
-static int lm78_i2c_detect(struct i2c_client *client, int kind,
+static int lm78_i2c_detect(struct i2c_client *client,
                           struct i2c_board_info *info);
 static int lm78_i2c_probe(struct i2c_client *client,
                          const struct i2c_device_id *id);
@@ -173,7 +172,7 @@ static struct i2c_driver lm78_driver = {
        .remove         = lm78_i2c_remove,
        .id_table       = lm78_i2c_id,
        .detect         = lm78_i2c_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static struct platform_driver lm78_isa_driver = {
@@ -558,7 +557,7 @@ static int lm78_alias_detect(struct i2c_client *client, u8 chipid)
        return 1;
 }
 
-static int lm78_i2c_detect(struct i2c_client *client, int kind,
+static int lm78_i2c_detect(struct i2c_client *client,
                           struct i2c_board_info *info)
 {
        int i;
index bcffc189940317186dadbf68798139723fba3fd0..18a0e6c5fe88dac243ede53f817a72d8202daaf4 100644 (file)
@@ -35,9 +35,6 @@
 static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
                                                0x2e, 0x2f, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(lm80);
-
 /* Many LM80 constants specified below */
 
 /* The LM80 registers */
@@ -133,8 +130,7 @@ struct lm80_data {
 
 static int lm80_probe(struct i2c_client *client,
                      const struct i2c_device_id *id);
-static int lm80_detect(struct i2c_client *client, int kind,
-                      struct i2c_board_info *info);
+static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info);
 static void lm80_init_client(struct i2c_client *client);
 static int lm80_remove(struct i2c_client *client);
 static struct lm80_data *lm80_update_device(struct device *dev);
@@ -146,7 +142,7 @@ static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value);
  */
 
 static const struct i2c_device_id lm80_id[] = {
-       { "lm80", lm80 },
+       { "lm80", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, lm80_id);
@@ -160,7 +156,7 @@ static struct i2c_driver lm80_driver = {
        .remove         = lm80_remove,
        .id_table       = lm80_id,
        .detect         = lm80_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -447,8 +443,7 @@ static const struct attribute_group lm80_group = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm80_detect(struct i2c_client *client, int kind,
-                      struct i2c_board_info *info)
+static int lm80_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
        int i, cur;
index 08b03e6ed0b7adf3a21aab5ac42c4062982fa767..8290476aee4ab981d6f918fb92d6b2940d4e4a65 100644 (file)
 static const unsigned short normal_i2c[] = {
        0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_2(lm83, lm82);
+enum chips { lm83, lm82 };
 
 /*
  * The LM83 registers
@@ -118,7 +114,7 @@ static const u8 LM83_REG_W_HIGH[] = {
  * Functions declaration
  */
 
-static int lm83_detect(struct i2c_client *new_client, int kind,
+static int lm83_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info);
 static int lm83_probe(struct i2c_client *client,
                      const struct i2c_device_id *id);
@@ -145,7 +141,7 @@ static struct i2c_driver lm83_driver = {
        .remove         = lm83_remove,
        .id_table       = lm83_id,
        .detect         = lm83_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -291,7 +287,7 @@ static const struct attribute_group lm83_group_opt = {
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm83_detect(struct i2c_client *new_client, int kind,
+static int lm83_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
index d56da2e747080b210b907f0291795f93755bd135..b3841a615595658cc3ddd0675d827becaf53fc45 100644 (file)
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_7(lm85b, lm85c, adm1027, adt7463, adt7468, emc6d100,
-                   emc6d102);
+enum chips {
+       any_chip, lm85b, lm85c,
+       adm1027, adt7463, adt7468,
+       emc6d100, emc6d102
+};
 
 /* The LM85 registers */
 
@@ -323,8 +325,7 @@ struct lm85_data {
        struct lm85_zone zone[3];
 };
 
-static int lm85_detect(struct i2c_client *client, int kind,
-                      struct i2c_board_info *info);
+static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info);
 static int lm85_probe(struct i2c_client *client,
                      const struct i2c_device_id *id);
 static int lm85_remove(struct i2c_client *client);
@@ -357,7 +358,7 @@ static struct i2c_driver lm85_driver = {
        .remove         = lm85_remove,
        .id_table       = lm85_id,
        .detect         = lm85_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 
@@ -1156,8 +1157,7 @@ static int lm85_is_fake(struct i2c_client *client)
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm85_detect(struct i2c_client *client, int kind,
-                      struct i2c_board_info *info)
+static int lm85_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
        int address = client->addr;
index 4929b1815eee47ee1a4c30b89d111b6eb0c468f8..f1e6e7512ffa2e8f308b3de9483b943507d19913 100644 (file)
 
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_2(lm87, adm1024);
+enum chips { lm87, adm1024 };
 
 /*
  * The LM87 registers
@@ -158,7 +154,7 @@ static u8 LM87_REG_TEMP_LOW[3] = { 0x3A, 0x38, 0x2C };
 
 static int lm87_probe(struct i2c_client *client,
                      const struct i2c_device_id *id);
-static int lm87_detect(struct i2c_client *new_client, int kind,
+static int lm87_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info);
 static void lm87_init_client(struct i2c_client *client);
 static int lm87_remove(struct i2c_client *client);
@@ -184,7 +180,7 @@ static struct i2c_driver lm87_driver = {
        .remove         = lm87_remove,
        .id_table       = lm87_id,
        .detect         = lm87_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -662,7 +658,7 @@ static const struct attribute_group lm87_group_opt = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm87_detect(struct i2c_client *new_client, int kind,
+static int lm87_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
index b7c905f50ed437da556ebd37007b3b8440cb23b8..7c9bdc16742653e0dd2bcb812542f7c1f61a233d 100644 (file)
 static const unsigned short normal_i2c[] = {
        0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_8(lm90, adm1032, lm99, lm86, max6657, adt7461, max6680,
-                   max6646);
+enum chips { lm90, adm1032, lm99, lm86, max6657, adt7461, max6680, max6646 };
 
 /*
  * The LM90 registers
@@ -152,8 +147,7 @@ I2C_CLIENT_INSMOD_8(lm90, adm1032, lm99, lm86, max6657, adt7461, max6680,
  * Functions declaration
  */
 
-static int lm90_detect(struct i2c_client *client, int kind,
-                      struct i2c_board_info *info);
+static int lm90_detect(struct i2c_client *client, struct i2c_board_info *info);
 static int lm90_probe(struct i2c_client *client,
                      const struct i2c_device_id *id);
 static void lm90_init_client(struct i2c_client *client);
@@ -192,7 +186,7 @@ static struct i2c_driver lm90_driver = {
        .remove         = lm90_remove,
        .id_table       = lm90_id,
        .detect         = lm90_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -656,7 +650,7 @@ static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value)
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm90_detect(struct i2c_client *new_client, int kind,
+static int lm90_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
index 47ac698709dc2e73650820f8305b6e095de74bef..7c31e6205f8513da02a0b8dc7012a3c3ca4ffbf8 100644 (file)
@@ -54,9 +54,6 @@
 static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b,
                                                I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(lm92);
-
 /* The LM92 registers */
 #define LM92_REG_CONFIG                        0x01 /* 8-bit, RW */
 #define LM92_REG_TEMP                  0x00 /* 16-bit, RO */
@@ -319,7 +316,7 @@ static const struct attribute_group lm92_group = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm92_detect(struct i2c_client *new_client, int kind,
+static int lm92_detect(struct i2c_client *new_client,
                       struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
@@ -401,7 +398,7 @@ static int lm92_remove(struct i2c_client *client)
  */
 
 static const struct i2c_device_id lm92_id[] = {
-       { "lm92", lm92 },
+       { "lm92", 0 },
        /* max6635 could be added here */
        { }
 };
@@ -416,7 +413,7 @@ static struct i2c_driver lm92_driver = {
        .remove         = lm92_remove,
        .id_table       = lm92_id,
        .detect         = lm92_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static int __init sensors_lm92_init(void)
index 124dd7cea54cb72c2d94a0ecd9203fdc6047ce72..6669255aadcfcefc783c01f0c345a72b411f70c9 100644 (file)
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_1(lm93);
 
 static int disable_block;
 module_param(disable_block, bool, 0);
@@ -2501,8 +2500,7 @@ static void lm93_init_client(struct i2c_client *client)
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm93_detect(struct i2c_client *client, int kind,
-                      struct i2c_board_info *info)
+static int lm93_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
        int mfr, ver;
@@ -2603,7 +2601,7 @@ static int lm93_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id lm93_id[] = {
-       { "lm93", lm93 },
+       { "lm93", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, lm93_id);
@@ -2617,7 +2615,7 @@ static struct i2c_driver lm93_driver = {
        .remove         = lm93_remove,
        .id_table       = lm93_id,
        .detect         = lm93_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static int __init lm93_init(void)
index 906b896cf1d0fa6616ce5a8750f54f8e1937bf75..8fc8eb8cba47400fd23614a392b135949aab8c76 100644 (file)
@@ -39,9 +39,6 @@
 static const unsigned short normal_i2c[] = {
        0x19, 0x2a, 0x2b, I2C_CLIENT_END};
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(lm95241);
-
 /* LM95241 registers */
 #define LM95241_REG_R_MAN_ID           0xFE
 #define LM95241_REG_R_CHIP_ID          0xFF
@@ -310,7 +307,7 @@ static const struct attribute_group lm95241_group = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int lm95241_detect(struct i2c_client *new_client, int kind,
+static int lm95241_detect(struct i2c_client *new_client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = new_client->adapter;
@@ -446,7 +443,7 @@ static struct lm95241_data *lm95241_update_device(struct device *dev)
 
 /* Driver data (common to all clients) */
 static const struct i2c_device_id lm95241_id[] = {
-       { "lm95241", lm95241 },
+       { "lm95241", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, lm95241_id);
@@ -460,7 +457,7 @@ static struct i2c_driver lm95241_driver = {
        .remove         = lm95241_remove,
        .id_table       = lm95241_id,
        .detect         = lm95241_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static int __init sensors_lm95241_init(void)
index 7fcf5ff89e7f903b7fee1dc4cfa10ac8769613be..022ded098100edbdb7fe69210f8576a9db66b535 100644 (file)
 static const unsigned short normal_i2c[] = {
        0x18, 0x19, 0x1a, 0x29, 0x2a, 0x2b, 0x4c, 0x4d, 0x4e, I2C_CLIENT_END };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_1(max1619);
-
 /*
  * The MAX1619 registers
  */
@@ -88,7 +82,7 @@ static int temp_to_reg(int val)
 
 static int max1619_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int max1619_detect(struct i2c_client *client, int kind,
+static int max1619_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static void max1619_init_client(struct i2c_client *client);
 static int max1619_remove(struct i2c_client *client);
@@ -99,7 +93,7 @@ static struct max1619_data *max1619_update_device(struct device *dev);
  */
 
 static const struct i2c_device_id max1619_id[] = {
-       { "max1619", max1619 },
+       { "max1619", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, max1619_id);
@@ -113,7 +107,7 @@ static struct i2c_driver max1619_driver = {
        .remove         = max1619_remove,
        .id_table       = max1619_id,
        .detect         = max1619_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -226,7 +220,7 @@ static const struct attribute_group max1619_group = {
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int max1619_detect(struct i2c_client *client, int kind,
+static int max1619_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 1da561e0cb37dbd6e8e8db112a94b4bdd5893a0b..a0160ee5caeffcefc6d7da22a7513a13b32fcf43 100644 (file)
@@ -62,8 +62,6 @@ module_param(fan_voltage, int, S_IRUGO);
 module_param(prescaler, int, S_IRUGO);
 module_param(clock, int, S_IRUGO);
 
-I2C_CLIENT_INSMOD_1(max6650);
-
 /*
  * MAX 6650/6651 registers
  */
@@ -116,7 +114,7 @@ I2C_CLIENT_INSMOD_1(max6650);
 
 static int max6650_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int max6650_detect(struct i2c_client *client, int kind,
+static int max6650_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int max6650_init_client(struct i2c_client *client);
 static int max6650_remove(struct i2c_client *client);
@@ -127,7 +125,7 @@ static struct max6650_data *max6650_update_device(struct device *dev);
  */
 
 static const struct i2c_device_id max6650_id[] = {
-       { "max6650", max6650 },
+       { "max6650", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, max6650_id);
@@ -141,7 +139,7 @@ static struct i2c_driver max6650_driver = {
        .remove         = max6650_remove,
        .id_table       = max6650_id,
        .detect         = max6650_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -528,7 +526,7 @@ static struct attribute_group max6650_attr_grp = {
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int max6650_detect(struct i2c_client *client, int kind,
+static int max6650_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 1d7ffebd679d0cce6f25c9e1946d7e9739c1b4b5..d447879498516d9f385bf37070f8ff0f3fc10f23 100644 (file)
@@ -29,7 +29,6 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
                                        0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_1(pcf8591);
 
 static int input_mode;
 module_param(input_mode, int, 0);
@@ -169,7 +168,7 @@ static const struct attribute_group pcf8591_attr_group_opt = {
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int pcf8591_detect(struct i2c_client *client, int kind,
+static int pcf8591_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
@@ -299,7 +298,7 @@ static struct i2c_driver pcf8591_driver = {
 
        .class          = I2C_CLASS_HWMON,      /* Nearest choice */
        .detect         = pcf8591_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static int __init pcf8591_init(void)
index ebe38b680ee38494520c5cf162e50a027ab21799..864a371f6eb98443f0565b1d1263cb66a370e152 100644 (file)
@@ -305,7 +305,7 @@ static inline int sht15_calc_temp(struct sht15_data *data)
        int d1 = 0;
        int i;
 
-       for (i = 1; i < ARRAY_SIZE(temppoints) - 1; i++)
+       for (i = 1; i < ARRAY_SIZE(temppoints); i++)
                /* Find pointer to interpolate */
                if (data->supply_uV > temppoints[i - 1].vdd) {
                        d1 = (data->supply_uV/1000 - temppoints[i - 1].vdd)
@@ -332,12 +332,12 @@ static inline int sht15_calc_humid(struct sht15_data *data)
 
        const int c1 = -4;
        const int c2 = 40500; /* x 10 ^ -6 */
-       const int c3 = 2800; /* x10 ^ -9 */
+       const int c3 = -2800; /* x10 ^ -9 */
 
        RHlinear = c1*1000
                + c2 * data->val_humid/1000
                + (data->val_humid * data->val_humid * c3)/1000000;
-       return (temp - 25000) * (10000 + 800 * data->val_humid)
+       return (temp - 25000) * (10000 + 80 * data->val_humid)
                / 1000000 + RHlinear;
 }
 
index 8ad50fdba00dbb4744227de6c5d2949b3090c143..9ca97818bd4b57148d9c0ad8c42a231832967377 100644 (file)
@@ -136,11 +136,11 @@ struct smsc47m1_data {
 
 struct smsc47m1_sio_data {
        enum chips type;
+       u8 activate;            /* Remember initial device state */
 };
 
 
-static int smsc47m1_probe(struct platform_device *pdev);
-static int __devexit smsc47m1_remove(struct platform_device *pdev);
+static int __exit smsc47m1_remove(struct platform_device *pdev);
 static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
                int init);
 
@@ -160,8 +160,7 @@ static struct platform_driver smsc47m1_driver = {
                .owner  = THIS_MODULE,
                .name   = DRVNAME,
        },
-       .probe          = smsc47m1_probe,
-       .remove         = __devexit_p(smsc47m1_remove),
+       .remove         = __exit_p(smsc47m1_remove),
 };
 
 static ssize_t get_fan(struct device *dev, struct device_attribute
@@ -470,24 +469,126 @@ static int __init smsc47m1_find(unsigned short *addr,
        superio_select();
        *addr = (superio_inb(SUPERIO_REG_BASE) << 8)
              |  superio_inb(SUPERIO_REG_BASE + 1);
-       val = superio_inb(SUPERIO_REG_ACT);
-       if (*addr == 0 || (val & 0x01) == 0) {
-               pr_info(DRVNAME ": Device is disabled, will not use\n");
+       if (*addr == 0) {
+               pr_info(DRVNAME ": Device address not set, will not use\n");
                superio_exit();
                return -ENODEV;
        }
 
+       /* Enable only if address is set (needed at least on the
+        * Compaq Presario S4000NX) */
+       sio_data->activate = superio_inb(SUPERIO_REG_ACT);
+       if ((sio_data->activate & 0x01) == 0) {
+               pr_info(DRVNAME ": Enabling device\n");
+               superio_outb(SUPERIO_REG_ACT, sio_data->activate | 0x01);
+       }
+
        superio_exit();
        return 0;
 }
 
-static int __devinit smsc47m1_probe(struct platform_device *pdev)
+/* Restore device to its initial state */
+static void __init smsc47m1_restore(const struct smsc47m1_sio_data *sio_data)
+{
+       if ((sio_data->activate & 0x01) == 0) {
+               superio_enter();
+               superio_select();
+
+               pr_info(DRVNAME ": Disabling device\n");
+               superio_outb(SUPERIO_REG_ACT, sio_data->activate);
+
+               superio_exit();
+       }
+}
+
+#define CHECK          1
+#define REQUEST                2
+#define RELEASE                3
+
+/*
+ * This function can be used to:
+ *  - test for resource conflicts with ACPI
+ *  - request the resources
+ *  - release the resources
+ * We only allocate the I/O ports we really need, to minimize the risk of
+ * conflicts with ACPI or with other drivers.
+ */
+static int smsc47m1_handle_resources(unsigned short address, enum chips type,
+                                    int action, struct device *dev)
+{
+       static const u8 ports_m1[] = {
+               /* register, region length */
+               0x04, 1,
+               0x33, 4,
+               0x56, 7,
+       };
+
+       static const u8 ports_m2[] = {
+               /* register, region length */
+               0x04, 1,
+               0x09, 1,
+               0x2c, 2,
+               0x35, 4,
+               0x56, 7,
+               0x69, 4,
+       };
+
+       int i, ports_size, err;
+       const u8 *ports;
+
+       switch (type) {
+       case smsc47m1:
+       default:
+               ports = ports_m1;
+               ports_size = ARRAY_SIZE(ports_m1);
+               break;
+       case smsc47m2:
+               ports = ports_m2;
+               ports_size = ARRAY_SIZE(ports_m2);
+               break;
+       }
+
+       for (i = 0; i + 1 < ports_size; i += 2) {
+               unsigned short start = address + ports[i];
+               unsigned short len = ports[i + 1];
+
+               switch (action) {
+               case CHECK:
+                       /* Only check for conflicts */
+                       err = acpi_check_region(start, len, DRVNAME);
+                       if (err)
+                               return err;
+                       break;
+               case REQUEST:
+                       /* Request the resources */
+                       if (!request_region(start, len, DRVNAME)) {
+                               dev_err(dev, "Region 0x%hx-0x%hx already in "
+                                       "use!\n", start, start + len);
+
+                               /* Undo all requests */
+                               for (i -= 2; i >= 0; i -= 2)
+                                       release_region(address + ports[i],
+                                                      ports[i + 1]);
+                               return -EBUSY;
+                       }
+                       break;
+               case RELEASE:
+                       /* Release the resources */
+                       release_region(start, len);
+                       break;
+               }
+       }
+
+       return 0;
+}
+
+static int __init smsc47m1_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct smsc47m1_sio_data *sio_data = dev->platform_data;
        struct smsc47m1_data *data;
        struct resource *res;
-       int err = 0;
+       int err;
        int fan1, fan2, fan3, pwm1, pwm2, pwm3;
 
        static const char *names[] = {
@@ -496,12 +597,10 @@ static int __devinit smsc47m1_probe(struct platform_device *pdev)
        };
 
        res = platform_get_resource(pdev, IORESOURCE_IO, 0);
-       if (!request_region(res->start, SMSC_EXTENT, DRVNAME)) {
-               dev_err(dev, "Region 0x%lx-0x%lx already in use!\n",
-                       (unsigned long)res->start,
-                       (unsigned long)res->end);
-               return -EBUSY;
-       }
+       err = smsc47m1_handle_resources(res->start, sio_data->type,
+                                       REQUEST, dev);
+       if (err < 0)
+               return err;
 
        if (!(data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) {
                err = -ENOMEM;
@@ -637,11 +736,11 @@ error_free:
        platform_set_drvdata(pdev, NULL);
        kfree(data);
 error_release:
-       release_region(res->start, SMSC_EXTENT);
+       smsc47m1_handle_resources(res->start, sio_data->type, RELEASE, dev);
        return err;
 }
 
-static int __devexit smsc47m1_remove(struct platform_device *pdev)
+static int __exit smsc47m1_remove(struct platform_device *pdev)
 {
        struct smsc47m1_data *data = platform_get_drvdata(pdev);
        struct resource *res;
@@ -650,7 +749,7 @@ static int __devexit smsc47m1_remove(struct platform_device *pdev)
        sysfs_remove_group(&pdev->dev.kobj, &smsc47m1_group);
 
        res = platform_get_resource(pdev, IORESOURCE_IO, 0);
-       release_region(res->start, SMSC_EXTENT);
+       smsc47m1_handle_resources(res->start, data->type, RELEASE, &pdev->dev);
        platform_set_drvdata(pdev, NULL);
        kfree(data);
 
@@ -717,7 +816,7 @@ static int __init smsc47m1_device_add(unsigned short address,
        };
        int err;
 
-       err = acpi_check_resource_conflict(&res);
+       err = smsc47m1_handle_resources(address, sio_data->type, CHECK, NULL);
        if (err)
                goto exit;
 
@@ -766,27 +865,29 @@ static int __init sm_smsc47m1_init(void)
        if (smsc47m1_find(&address, &sio_data))
                return -ENODEV;
 
-       err = platform_driver_register(&smsc47m1_driver);
+       /* Sets global pdev as a side effect */
+       err = smsc47m1_device_add(address, &sio_data);
        if (err)
                goto exit;
 
-       /* Sets global pdev as a side effect */
-       err = smsc47m1_device_add(address, &sio_data);
+       err = platform_driver_probe(&smsc47m1_driver, smsc47m1_probe);
        if (err)
-               goto exit_driver;
+               goto exit_device;
 
        return 0;
 
-exit_driver:
-       platform_driver_unregister(&smsc47m1_driver);
+exit_device:
+       platform_device_unregister(pdev);
+       smsc47m1_restore(&sio_data);
 exit:
        return err;
 }
 
 static void __exit sm_smsc47m1_exit(void)
 {
-       platform_device_unregister(pdev);
        platform_driver_unregister(&smsc47m1_driver);
+       smsc47m1_restore(pdev->dev.platform_data);
+       platform_device_unregister(pdev);
 }
 
 MODULE_AUTHOR("Mark D. Studebaker <mdsxyz123@yahoo.com>");
index 4d88c045781c6cbac9ebebb83037bc9364318adc..40b26673d87f3563946dd34a8cac909b31ddfdaa 100644 (file)
@@ -36,9 +36,6 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(smsc47m192);
-
 /* SMSC47M192 registers */
 #define SMSC47M192_REG_IN(nr)          ((nr)<6 ? (0x20 + (nr)) : \
                                        (0x50 + (nr) - 6))
@@ -115,13 +112,13 @@ struct smsc47m192_data {
 
 static int smsc47m192_probe(struct i2c_client *client,
                            const struct i2c_device_id *id);
-static int smsc47m192_detect(struct i2c_client *client, int kind,
+static int smsc47m192_detect(struct i2c_client *client,
                             struct i2c_board_info *info);
 static int smsc47m192_remove(struct i2c_client *client);
 static struct smsc47m192_data *smsc47m192_update_device(struct device *dev);
 
 static const struct i2c_device_id smsc47m192_id[] = {
-       { "smsc47m192", smsc47m192 },
+       { "smsc47m192", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, smsc47m192_id);
@@ -135,7 +132,7 @@ static struct i2c_driver smsc47m192_driver = {
        .remove         = smsc47m192_remove,
        .id_table       = smsc47m192_id,
        .detect         = smsc47m192_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /* Voltages */
@@ -481,7 +478,7 @@ static void smsc47m192_init_client(struct i2c_client *client)
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int smsc47m192_detect(struct i2c_client *client, int kind,
+static int smsc47m192_detect(struct i2c_client *client,
                             struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 4b793849c73818eb3fd6d5c8cd2aca986d17d514..7dfb4dec4c5f6ca3fb60d91e398446b1456d3423 100644 (file)
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL");
 static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_2(thmc50, adm1022);
+enum chips { thmc50, adm1022 };
 
 static unsigned short adm1022_temp3[16];
 static unsigned int adm1022_temp3_num;
@@ -84,7 +84,7 @@ struct thmc50_data {
        u8 alarms;
 };
 
-static int thmc50_detect(struct i2c_client *client, int kind,
+static int thmc50_detect(struct i2c_client *client,
                         struct i2c_board_info *info);
 static int thmc50_probe(struct i2c_client *client,
                        const struct i2c_device_id *id);
@@ -108,7 +108,7 @@ static struct i2c_driver thmc50_driver = {
        .remove = thmc50_remove,
        .id_table = thmc50_id,
        .detect = thmc50_detect,
-       .address_data = &addr_data,
+       .address_list = normal_i2c,
 };
 
 static ssize_t show_analog_out(struct device *dev,
@@ -286,7 +286,7 @@ static const struct attribute_group temp3_group = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int thmc50_detect(struct i2c_client *client, int kind,
+static int thmc50_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        unsigned company;
index ee9673467c4a7289ac8b0b6313d2ed3a4222a733..a13b30e8d8d8f982f71ff5e22f42f1347e7f55ad 100644 (file)
@@ -42,8 +42,7 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x4c, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_2(tmp401, tmp411);
+enum chips { tmp401, tmp411 };
 
 /*
  * The TMP401 registers, note some registers have different addresses for
@@ -98,7 +97,7 @@ static const u8 TMP411_TEMP_HIGHEST_LSB[2]            = { 0x33, 0x37 };
 
 static int tmp401_probe(struct i2c_client *client,
                        const struct i2c_device_id *id);
-static int tmp401_detect(struct i2c_client *client, int kind,
+static int tmp401_detect(struct i2c_client *client,
                         struct i2c_board_info *info);
 static int tmp401_remove(struct i2c_client *client);
 static struct tmp401_data *tmp401_update_device(struct device *dev);
@@ -123,7 +122,7 @@ static struct i2c_driver tmp401_driver = {
        .remove         = tmp401_remove,
        .id_table       = tmp401_id,
        .detect         = tmp401_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -488,7 +487,7 @@ static void tmp401_init_client(struct i2c_client *client)
                i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config);
 }
 
-static int tmp401_detect(struct i2c_client *client, int _kind,
+static int tmp401_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        enum chips kind;
index bb5464a289cac8e9b8d3cd5d9a39a98656276ad4..4f7c051e2d7b0425308489fcbbc6c04eda68947d 100644 (file)
@@ -39,8 +39,7 @@
 static unsigned short normal_i2c[] = { 0x2a, 0x4c, 0x4d, 0x4e, 0x4f,
                                       I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_3(tmp421, tmp422, tmp423);
+enum chips { tmp421, tmp422, tmp423 };
 
 /* The TMP421 registers */
 #define TMP421_CONFIG_REG_1                    0x09
@@ -223,7 +222,7 @@ static int tmp421_init_client(struct i2c_client *client)
        return 0;
 }
 
-static int tmp421_detect(struct i2c_client *client, int _kind,
+static int tmp421_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        enum chips kind;
@@ -322,7 +321,7 @@ static struct i2c_driver tmp421_driver = {
        .remove = tmp421_remove,
        .id_table = tmp421_id,
        .detect = tmp421_detect,
-       .address_data = &addr_data,
+       .address_list = normal_i2c,
 };
 
 static int __init tmp421_init(void)
diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
new file mode 100644 (file)
index 0000000..7442cf7
--- /dev/null
@@ -0,0 +1,356 @@
+/*
+ * via-cputemp.c - Driver for VIA CPU core temperature monitoring
+ * Copyright (C) 2009 VIA Technologies, Inc.
+ *
+ * based on existing coretemp.c, which is
+ *
+ * Copyright (C) 2007 Rudolf Marek <r.marek@assembler.cz>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/hwmon.h>
+#include <linux/sysfs.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/list.h>
+#include <linux/platform_device.h>
+#include <linux/cpu.h>
+#include <asm/msr.h>
+#include <asm/processor.h>
+
+#define DRVNAME        "via_cputemp"
+
+enum { SHOW_TEMP, SHOW_LABEL, SHOW_NAME } SHOW;
+
+/*
+ * Functions declaration
+ */
+
+struct via_cputemp_data {
+       struct device *hwmon_dev;
+       const char *name;
+       u32 id;
+       u32 msr;
+};
+
+/*
+ * Sysfs stuff
+ */
+
+static ssize_t show_name(struct device *dev, struct device_attribute
+                         *devattr, char *buf)
+{
+       int ret;
+       struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+       struct via_cputemp_data *data = dev_get_drvdata(dev);
+
+       if (attr->index == SHOW_NAME)
+               ret = sprintf(buf, "%s\n", data->name);
+       else    /* show label */
+               ret = sprintf(buf, "Core %d\n", data->id);
+       return ret;
+}
+
+static ssize_t show_temp(struct device *dev,
+                        struct device_attribute *devattr, char *buf)
+{
+       struct via_cputemp_data *data = dev_get_drvdata(dev);
+       u32 eax, edx;
+       int err;
+
+       err = rdmsr_safe_on_cpu(data->id, data->msr, &eax, &edx);
+       if (err)
+               return -EAGAIN;
+
+       return sprintf(buf, "%lu\n", ((unsigned long)eax & 0xffffff) * 1000);
+}
+
+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL,
+                         SHOW_TEMP);
+static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_name, NULL, SHOW_LABEL);
+static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, SHOW_NAME);
+
+static struct attribute *via_cputemp_attributes[] = {
+       &sensor_dev_attr_name.dev_attr.attr,
+       &sensor_dev_attr_temp1_label.dev_attr.attr,
+       &sensor_dev_attr_temp1_input.dev_attr.attr,
+       NULL
+};
+
+static const struct attribute_group via_cputemp_group = {
+       .attrs = via_cputemp_attributes,
+};
+
+static int __devinit via_cputemp_probe(struct platform_device *pdev)
+{
+       struct via_cputemp_data *data;
+       struct cpuinfo_x86 *c = &cpu_data(pdev->id);
+       int err;
+       u32 eax, edx;
+
+       data = kzalloc(sizeof(struct via_cputemp_data), GFP_KERNEL);
+       if (!data) {
+               err = -ENOMEM;
+               dev_err(&pdev->dev, "Out of memory\n");
+               goto exit;
+       }
+
+       data->id = pdev->id;
+       data->name = "via_cputemp";
+
+       switch (c->x86_model) {
+       case 0xA:
+               /* C7 A */
+       case 0xD:
+               /* C7 D */
+               data->msr = 0x1169;
+               break;
+       case 0xF:
+               /* Nano */
+               data->msr = 0x1423;
+               break;
+       default:
+               err = -ENODEV;
+               goto exit_free;
+       }
+
+       /* test if we can access the TEMPERATURE MSR */
+       err = rdmsr_safe_on_cpu(data->id, data->msr, &eax, &edx);
+       if (err) {
+               dev_err(&pdev->dev,
+                       "Unable to access TEMPERATURE MSR, giving up\n");
+               goto exit_free;
+       }
+
+       platform_set_drvdata(pdev, data);
+
+       err = sysfs_create_group(&pdev->dev.kobj, &via_cputemp_group);
+       if (err)
+               goto exit_free;
+
+       data->hwmon_dev = hwmon_device_register(&pdev->dev);
+       if (IS_ERR(data->hwmon_dev)) {
+               err = PTR_ERR(data->hwmon_dev);
+               dev_err(&pdev->dev, "Class registration failed (%d)\n",
+                       err);
+               goto exit_remove;
+       }
+
+       return 0;
+
+exit_remove:
+       sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group);
+exit_free:
+       platform_set_drvdata(pdev, NULL);
+       kfree(data);
+exit:
+       return err;
+}
+
+static int __devexit via_cputemp_remove(struct platform_device *pdev)
+{
+       struct via_cputemp_data *data = platform_get_drvdata(pdev);
+
+       hwmon_device_unregister(data->hwmon_dev);
+       sysfs_remove_group(&pdev->dev.kobj, &via_cputemp_group);
+       platform_set_drvdata(pdev, NULL);
+       kfree(data);
+       return 0;
+}
+
+static struct platform_driver via_cputemp_driver = {
+       .driver = {
+               .owner = THIS_MODULE,
+               .name = DRVNAME,
+       },
+       .probe = via_cputemp_probe,
+       .remove = __devexit_p(via_cputemp_remove),
+};
+
+struct pdev_entry {
+       struct list_head list;
+       struct platform_device *pdev;
+       unsigned int cpu;
+};
+
+static LIST_HEAD(pdev_list);
+static DEFINE_MUTEX(pdev_list_mutex);
+
+static int __cpuinit via_cputemp_device_add(unsigned int cpu)
+{
+       int err;
+       struct platform_device *pdev;
+       struct pdev_entry *pdev_entry;
+
+       pdev = platform_device_alloc(DRVNAME, cpu);
+       if (!pdev) {
+               err = -ENOMEM;
+               printk(KERN_ERR DRVNAME ": Device allocation failed\n");
+               goto exit;
+       }
+
+       pdev_entry = kzalloc(sizeof(struct pdev_entry), GFP_KERNEL);
+       if (!pdev_entry) {
+               err = -ENOMEM;
+               goto exit_device_put;
+       }
+
+       err = platform_device_add(pdev);
+       if (err) {
+               printk(KERN_ERR DRVNAME ": Device addition failed (%d)\n",
+                      err);
+               goto exit_device_free;
+       }
+
+       pdev_entry->pdev = pdev;
+       pdev_entry->cpu = cpu;
+       mutex_lock(&pdev_list_mutex);
+       list_add_tail(&pdev_entry->list, &pdev_list);
+       mutex_unlock(&pdev_list_mutex);
+
+       return 0;
+
+exit_device_free:
+       kfree(pdev_entry);
+exit_device_put:
+       platform_device_put(pdev);
+exit:
+       return err;
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+static void via_cputemp_device_remove(unsigned int cpu)
+{
+       struct pdev_entry *p, *n;
+       mutex_lock(&pdev_list_mutex);
+       list_for_each_entry_safe(p, n, &pdev_list, list) {
+               if (p->cpu == cpu) {
+                       platform_device_unregister(p->pdev);
+                       list_del(&p->list);
+                       kfree(p);
+               }
+       }
+       mutex_unlock(&pdev_list_mutex);
+}
+
+static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
+                                unsigned long action, void *hcpu)
+{
+       unsigned int cpu = (unsigned long) hcpu;
+
+       switch (action) {
+       case CPU_ONLINE:
+       case CPU_DOWN_FAILED:
+               via_cputemp_device_add(cpu);
+               break;
+       case CPU_DOWN_PREPARE:
+               via_cputemp_device_remove(cpu);
+               break;
+       }
+       return NOTIFY_OK;
+}
+
+static struct notifier_block via_cputemp_cpu_notifier __refdata = {
+       .notifier_call = via_cputemp_cpu_callback,
+};
+#endif                         /* !CONFIG_HOTPLUG_CPU */
+
+static int __init via_cputemp_init(void)
+{
+       int i, err;
+       struct pdev_entry *p, *n;
+
+       if (cpu_data(0).x86_vendor != X86_VENDOR_CENTAUR) {
+               printk(KERN_DEBUG DRVNAME ": Not a VIA CPU\n");
+               err = -ENODEV;
+               goto exit;
+       }
+
+       err = platform_driver_register(&via_cputemp_driver);
+       if (err)
+               goto exit;
+
+       for_each_online_cpu(i) {
+               struct cpuinfo_x86 *c = &cpu_data(i);
+
+               if (c->x86 != 6)
+                       continue;
+
+               if (c->x86_model < 0x0a)
+                       continue;
+
+               if (c->x86_model > 0x0f) {
+                       printk(KERN_WARNING DRVNAME ": Unknown CPU "
+                               "model 0x%x\n", c->x86_model);
+                       continue;
+               }
+
+               err = via_cputemp_device_add(i);
+               if (err)
+                       goto exit_devices_unreg;
+       }
+       if (list_empty(&pdev_list)) {
+               err = -ENODEV;
+               goto exit_driver_unreg;
+       }
+
+#ifdef CONFIG_HOTPLUG_CPU
+       register_hotcpu_notifier(&via_cputemp_cpu_notifier);
+#endif
+       return 0;
+
+exit_devices_unreg:
+       mutex_lock(&pdev_list_mutex);
+       list_for_each_entry_safe(p, n, &pdev_list, list) {
+               platform_device_unregister(p->pdev);
+               list_del(&p->list);
+               kfree(p);
+       }
+       mutex_unlock(&pdev_list_mutex);
+exit_driver_unreg:
+       platform_driver_unregister(&via_cputemp_driver);
+exit:
+       return err;
+}
+
+static void __exit via_cputemp_exit(void)
+{
+       struct pdev_entry *p, *n;
+#ifdef CONFIG_HOTPLUG_CPU
+       unregister_hotcpu_notifier(&via_cputemp_cpu_notifier);
+#endif
+       mutex_lock(&pdev_list_mutex);
+       list_for_each_entry_safe(p, n, &pdev_list, list) {
+               platform_device_unregister(p->pdev);
+               list_del(&p->list);
+               kfree(p);
+       }
+       mutex_unlock(&pdev_list_mutex);
+       platform_driver_unregister(&via_cputemp_driver);
+}
+
+MODULE_AUTHOR("Harald Welte <HaraldWelte@viatech.com>");
+MODULE_DESCRIPTION("VIA CPU temperature monitor");
+MODULE_LICENSE("GPL");
+
+module_init(via_cputemp_init)
+module_exit(via_cputemp_exit)
index bb5e78748783b71c465bdcc14c478cdcc06cf9c9..0dcaba9b7189c26cd242a2acfb72804e083a7f70 100644 (file)
@@ -5,6 +5,7 @@
     Copyright (C) 2006  Yuan Mu (Winbond),
                         Rudolf Marek <r.marek@assembler.cz>
                         David Hubbard <david.c.hubbard@gmail.com>
+                       Daniel J Blueman <daniel.blueman@gmail.com>
 
     Shamelessly ripped from the w83627hf driver
     Copyright (C) 2003  Mark Studebaker
@@ -177,12 +178,15 @@ static const u16 W83627EHF_REG_TEMP_CONFIG[] = { 0x152, 0x252 };
 #define W83627EHF_REG_ALARM3           0x45B
 
 /* SmartFan registers */
+#define W83627EHF_REG_FAN_STEPUP_TIME 0x0f
+#define W83627EHF_REG_FAN_STEPDOWN_TIME 0x0e
+
 /* DC or PWM output fan configuration */
 static const u8 W83627EHF_REG_PWM_ENABLE[] = {
        0x04,                   /* SYS FAN0 output mode and PWM mode */
        0x04,                   /* CPU FAN0 output mode and PWM mode */
        0x12,                   /* AUX FAN mode */
-       0x62,                   /* CPU fan1 mode */
+       0x62,                   /* CPU FAN1 mode */
 };
 
 static const u8 W83627EHF_PWM_MODE_SHIFT[] = { 0, 1, 0, 6 };
@@ -193,10 +197,12 @@ static const u8 W83627EHF_REG_PWM[] = { 0x01, 0x03, 0x11, 0x61 };
 static const u8 W83627EHF_REG_TARGET[] = { 0x05, 0x06, 0x13, 0x63 };
 static const u8 W83627EHF_REG_TOLERANCE[] = { 0x07, 0x07, 0x14, 0x62 };
 
-
 /* Advanced Fan control, some values are common for all fans */
-static const u8 W83627EHF_REG_FAN_MIN_OUTPUT[] = { 0x08, 0x09, 0x15, 0x64 };
-static const u8 W83627EHF_REG_FAN_STOP_TIME[] = { 0x0C, 0x0D, 0x17, 0x66 };
+static const u8 W83627EHF_REG_FAN_START_OUTPUT[] = { 0x0a, 0x0b, 0x16, 0x65 };
+static const u8 W83627EHF_REG_FAN_STOP_OUTPUT[] = { 0x08, 0x09, 0x15, 0x64 };
+static const u8 W83627EHF_REG_FAN_STOP_TIME[] = { 0x0c, 0x0d, 0x17, 0x66 };
+static const u8 W83627EHF_REG_FAN_MAX_OUTPUT[] = { 0xff, 0x67, 0xff, 0x69 };
+static const u8 W83627EHF_REG_FAN_STEP_OUTPUT[] = { 0xff, 0x68, 0xff, 0x6a };
 
 /*
  * Conversions
@@ -295,14 +301,19 @@ struct w83627ehf_data {
 
        u8 pwm_mode[4]; /* 0->DC variable voltage, 1->PWM variable duty cycle */
        u8 pwm_enable[4]; /* 1->manual
-                            2->thermal cruise (also called SmartFan I) */
+                            2->thermal cruise mode (also called SmartFan I)
+                            3->fan speed cruise mode
+                            4->variable thermal cruise (also called SmartFan III) */
        u8 pwm_num;             /* number of pwm */
        u8 pwm[4];
        u8 target_temp[4];
        u8 tolerance[4];
 
-       u8 fan_min_output[4]; /* minimum fan speed */
-       u8 fan_stop_time[4];
+       u8 fan_start_output[4]; /* minimum fan speed when spinning up */
+       u8 fan_stop_output[4]; /* minimum fan speed when spinning down */
+       u8 fan_stop_time[4]; /* time at minimum before disabling fan */
+       u8 fan_max_output[4]; /* maximum fan speed */
+       u8 fan_step_output[4]; /* rate of change output value */
 
        u8 vid;
        u8 vrm;
@@ -529,8 +540,10 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
                                                & 3) + 1;
                        data->pwm[i] = w83627ehf_read_value(data,
                                                W83627EHF_REG_PWM[i]);
-                       data->fan_min_output[i] = w83627ehf_read_value(data,
-                                               W83627EHF_REG_FAN_MIN_OUTPUT[i]);
+                       data->fan_start_output[i] = w83627ehf_read_value(data,
+                                               W83627EHF_REG_FAN_START_OUTPUT[i]);
+                       data->fan_stop_output[i] = w83627ehf_read_value(data,
+                                               W83627EHF_REG_FAN_STOP_OUTPUT[i]);
                        data->fan_stop_time[i] = w83627ehf_read_value(data,
                                                W83627EHF_REG_FAN_STOP_TIME[i]);
                        data->target_temp[i] =
@@ -976,7 +989,7 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr,
        u32 val = simple_strtoul(buf, NULL, 10);
        u16 reg;
 
-       if (!val || (val > 2))  /* only modes 1 and 2 are supported */
+       if (!val || (val > 4))
                return -EINVAL;
        mutex_lock(&data->update_lock);
        reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]);
@@ -1118,7 +1131,10 @@ store_##reg(struct device *dev, struct device_attribute *attr, \
        return count; \
 }
 
-fan_functions(fan_min_output, FAN_MIN_OUTPUT)
+fan_functions(fan_start_output, FAN_START_OUTPUT)
+fan_functions(fan_stop_output, FAN_STOP_OUTPUT)
+fan_functions(fan_max_output, FAN_MAX_OUTPUT)
+fan_functions(fan_step_output, FAN_STEP_OUTPUT)
 
 #define fan_time_functions(reg, REG) \
 static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
@@ -1161,8 +1177,14 @@ static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
 static struct sensor_device_attribute sda_sf3_arrays_fan4[] = {
        SENSOR_ATTR(pwm4_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time,
                    store_fan_stop_time, 3),
-       SENSOR_ATTR(pwm4_min_output, S_IWUSR | S_IRUGO, show_fan_min_output,
-                   store_fan_min_output, 3),
+       SENSOR_ATTR(pwm4_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
+                   store_fan_start_output, 3),
+       SENSOR_ATTR(pwm4_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
+                   store_fan_stop_output, 3),
+       SENSOR_ATTR(pwm4_max_output, S_IWUSR | S_IRUGO, show_fan_max_output,
+                   store_fan_max_output, 3),
+       SENSOR_ATTR(pwm4_step_output, S_IWUSR | S_IRUGO, show_fan_step_output,
+                   store_fan_step_output, 3),
 };
 
 static struct sensor_device_attribute sda_sf3_arrays[] = {
@@ -1172,12 +1194,24 @@ static struct sensor_device_attribute sda_sf3_arrays[] = {
                    store_fan_stop_time, 1),
        SENSOR_ATTR(pwm3_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time,
                    store_fan_stop_time, 2),
-       SENSOR_ATTR(pwm1_min_output, S_IWUSR | S_IRUGO, show_fan_min_output,
-                   store_fan_min_output, 0),
-       SENSOR_ATTR(pwm2_min_output, S_IWUSR | S_IRUGO, show_fan_min_output,
-                   store_fan_min_output, 1),
-       SENSOR_ATTR(pwm3_min_output, S_IWUSR | S_IRUGO, show_fan_min_output,
-                   store_fan_min_output, 2),
+       SENSOR_ATTR(pwm1_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
+                   store_fan_start_output, 0),
+       SENSOR_ATTR(pwm2_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
+                   store_fan_start_output, 1),
+       SENSOR_ATTR(pwm3_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
+                   store_fan_start_output, 2),
+       SENSOR_ATTR(pwm1_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
+                   store_fan_stop_output, 0),
+       SENSOR_ATTR(pwm2_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
+                   store_fan_stop_output, 1),
+       SENSOR_ATTR(pwm3_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
+                   store_fan_stop_output, 2),
+
+       /* pwm1 and pwm3 don't support max and step settings */
+       SENSOR_ATTR(pwm2_max_output, S_IWUSR | S_IRUGO, show_fan_max_output,
+                   store_fan_max_output, 1),
+       SENSOR_ATTR(pwm2_step_output, S_IWUSR | S_IRUGO, show_fan_step_output,
+                   store_fan_step_output, 1),
 };
 
 static ssize_t
index b257c7223733c3fa1f9719bf0721bdd79425204c..38e2805230711f0b1b02e243b34dc62e4792c282 100644 (file)
@@ -1135,6 +1135,7 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr,
                "W83687THF",
        };
 
+       sio_data->sioaddr = sioaddr;
        superio_enter(sio_data);
        val = force_id ? force_id : superio_inb(sio_data, DEVID);
        switch (val) {
@@ -1177,7 +1178,6 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr,
        }
 
        err = 0;
-       sio_data->sioaddr = sioaddr;
        pr_info(DRVNAME ": Found %s chip at %#x\n",
                names[sio_data->type], *addr);
 
index 7ab7967da0a0359fe1dca5f90518c927752aedf5..05f9225b6f944dd7007c752eb9c15786f41c6740 100644 (file)
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
                                                0x2e, 0x2f, I2C_CLIENT_END };
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_4(w83781d, w83782d, w83783s, as99127f);
 
+enum chips { w83781d, w83782d, w83783s, as99127f };
+
+/* Insmod parameters */
 static unsigned short force_subclients[4];
 module_param_array(force_subclients, short, NULL, 0);
 MODULE_PARM_DESC(force_subclients, "List of subclient addresses: "
@@ -1051,8 +1052,7 @@ w83781d_create_files(struct device *dev, int kind, int is_isa)
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
 static int
-w83781d_detect(struct i2c_client *client, int kind,
-              struct i2c_board_info *info)
+w83781d_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        int val1, val2;
        struct w83781d_data *isa = w83781d_data_if_isa();
@@ -1537,7 +1537,7 @@ static struct i2c_driver w83781d_driver = {
        .remove         = w83781d_remove,
        .id_table       = w83781d_ids,
        .detect         = w83781d_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
index 0410bf12c5211cbb9bb27116d3dd343726adba8c..400a88bde278dc2d6778993e27c2849c629c799c 100644 (file)
@@ -52,7 +52,6 @@ static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
                                                I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_1(w83791d);
 
 static unsigned short force_subclients[4];
 module_param_array(force_subclients, short, NULL, 0);
@@ -326,7 +325,7 @@ struct w83791d_data {
 
 static int w83791d_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int w83791d_detect(struct i2c_client *client, int kind,
+static int w83791d_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int w83791d_remove(struct i2c_client *client);
 
@@ -341,7 +340,7 @@ static void w83791d_print_debug(struct w83791d_data *data, struct device *dev);
 static void w83791d_init_client(struct i2c_client *client);
 
 static const struct i2c_device_id w83791d_id[] = {
-       { "w83791d", w83791d },
+       { "w83791d", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, w83791d_id);
@@ -355,7 +354,7 @@ static struct i2c_driver w83791d_driver = {
        .remove         = w83791d_remove,
        .id_table       = w83791d_id,
        .detect         = w83791d_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /* following are the sysfs callback functions */
@@ -1259,7 +1258,7 @@ error_sc_0:
 
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int w83791d_detect(struct i2c_client *client, int kind,
+static int w83791d_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 38978851333f6361cbb62d76d4210c6edf5e4662..679718e6b0173a0e0fec17b755465e1476c04cd1 100644 (file)
@@ -50,7 +50,6 @@ static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
                                                I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_1(w83792d);
 
 static unsigned short force_subclients[4];
 module_param_array(force_subclients, short, NULL, 0);
@@ -302,7 +301,7 @@ struct w83792d_data {
 
 static int w83792d_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int w83792d_detect(struct i2c_client *client, int kind,
+static int w83792d_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int w83792d_remove(struct i2c_client *client);
 static struct w83792d_data *w83792d_update_device(struct device *dev);
@@ -314,7 +313,7 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev);
 static void w83792d_init_client(struct i2c_client *client);
 
 static const struct i2c_device_id w83792d_id[] = {
-       { "w83792d", w83792d },
+       { "w83792d", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, w83792d_id);
@@ -328,7 +327,7 @@ static struct i2c_driver w83792d_driver = {
        .remove         = w83792d_remove,
        .id_table       = w83792d_id,
        .detect         = w83792d_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static inline long in_count_from_reg(int nr, struct w83792d_data *data)
@@ -1263,7 +1262,7 @@ static const struct attribute_group w83792d_group = {
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
 static int
-w83792d_detect(struct i2c_client *client, int kind, struct i2c_board_info *info)
+w83792d_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
        int val1, val2;
index 80a2191bf1274d0b54581113972e669d6be0822d..9a2022b67495d9d2daa019173dae42f66c5b24ce 100644 (file)
@@ -41,7 +41,6 @@ static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
                                                I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_1(w83793);
 
 static unsigned short force_subclients[4];
 module_param_array(force_subclients, short, NULL, 0);
@@ -230,7 +229,7 @@ static u8 w83793_read_value(struct i2c_client *client, u16 reg);
 static int w83793_write_value(struct i2c_client *client, u16 reg, u8 value);
 static int w83793_probe(struct i2c_client *client,
                        const struct i2c_device_id *id);
-static int w83793_detect(struct i2c_client *client, int kind,
+static int w83793_detect(struct i2c_client *client,
                         struct i2c_board_info *info);
 static int w83793_remove(struct i2c_client *client);
 static void w83793_init_client(struct i2c_client *client);
@@ -238,7 +237,7 @@ static void w83793_update_nonvolatile(struct device *dev);
 static struct w83793_data *w83793_update_device(struct device *dev);
 
 static const struct i2c_device_id w83793_id[] = {
-       { "w83793", w83793 },
+       { "w83793", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, w83793_id);
@@ -252,7 +251,7 @@ static struct i2c_driver w83793_driver = {
        .remove         = w83793_remove,
        .id_table       = w83793_id,
        .detect         = w83793_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static ssize_t
@@ -1161,7 +1160,7 @@ ERROR_SC_0:
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int w83793_detect(struct i2c_client *client, int kind,
+static int w83793_detect(struct i2c_client *client,
                         struct i2c_board_info *info)
 {
        u8 tmp, bank, chip_id;
index 9b6c4c10fba75feaca0f8ca872619ad17fb6be7c..20781def65edaa280cb3ed2124adfb17c0fe4b57 100644 (file)
 
 static const unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
 
-/*
- * Insmod parameters
- */
-
-I2C_CLIENT_INSMOD_1(w83l785ts);
-
 /*
  * The W83L785TS-S registers
  * Manufacturer ID is 0x5CA3 for Winbond.
@@ -83,7 +77,7 @@ I2C_CLIENT_INSMOD_1(w83l785ts);
 
 static int w83l785ts_probe(struct i2c_client *client,
                           const struct i2c_device_id *id);
-static int w83l785ts_detect(struct i2c_client *client, int kind,
+static int w83l785ts_detect(struct i2c_client *client,
                            struct i2c_board_info *info);
 static int w83l785ts_remove(struct i2c_client *client);
 static u8 w83l785ts_read_value(struct i2c_client *client, u8 reg, u8 defval);
@@ -94,7 +88,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev);
  */
  
 static const struct i2c_device_id w83l785ts_id[] = {
-       { "w83l785ts", w83l785ts },
+       { "w83l785ts", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, w83l785ts_id);
@@ -108,7 +102,7 @@ static struct i2c_driver w83l785ts_driver = {
        .remove         = w83l785ts_remove,
        .id_table       = w83l785ts_id,
        .detect         = w83l785ts_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 /*
@@ -146,7 +140,7 @@ static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 1);
  */
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int w83l785ts_detect(struct i2c_client *client, int kind,
+static int w83l785ts_detect(struct i2c_client *client,
                            struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 27da7d2b15fb6fb82bbd0b60d63637d2dfb55367..0254e181893d9f2e9bd0d010d37f6544559ad3e5 100644 (file)
@@ -38,7 +38,6 @@
 static const unsigned short normal_i2c[] = { 0x2e, 0x2f, I2C_CLIENT_END };
 
 /* Insmod parameters */
-I2C_CLIENT_INSMOD_1(w83l786ng);
 
 static int reset;
 module_param(reset, bool, 0);
@@ -147,14 +146,14 @@ struct w83l786ng_data {
 
 static int w83l786ng_probe(struct i2c_client *client,
                           const struct i2c_device_id *id);
-static int w83l786ng_detect(struct i2c_client *client, int kind,
+static int w83l786ng_detect(struct i2c_client *client,
                            struct i2c_board_info *info);
 static int w83l786ng_remove(struct i2c_client *client);
 static void w83l786ng_init_client(struct i2c_client *client);
 static struct w83l786ng_data *w83l786ng_update_device(struct device *dev);
 
 static const struct i2c_device_id w83l786ng_id[] = {
-       { "w83l786ng", w83l786ng },
+       { "w83l786ng", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, w83l786ng_id);
@@ -168,7 +167,7 @@ static struct i2c_driver w83l786ng_driver = {
        .remove         = w83l786ng_remove,
        .id_table       = w83l786ng_id,
        .detect         = w83l786ng_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static u8
@@ -586,8 +585,7 @@ static const struct attribute_group w83l786ng_group = {
 };
 
 static int
-w83l786ng_detect(struct i2c_client *client, int kind,
-                struct i2c_board_info *info)
+w83l786ng_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
        u16 man_id;
index b309ac2c3d5cad084785f99ea3ea650713f59acf..fe3fb567317d08939345fa10ec960cc43fa53335 100644 (file)
@@ -693,13 +693,13 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
        }
 
        /* Set TWI internal clock as 10MHz */
-       write_CONTROL(iface, ((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F);
+       write_CONTROL(iface, ((get_sclk() / 1000 / 1000 + 5) / 10) & 0x7F);
 
        /*
         * We will not end up with a CLKDIV=0 because no one will specify
-        * 20kHz SCL or less in Kconfig now. (5 * 1024 / 20 = 0x100)
+        * 20kHz SCL or less in Kconfig now. (5 * 1000 / 20 = 250)
         */
-       clkhilow = 5 * 1024 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ;
+       clkhilow = ((10 * 1000 / CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ) + 1) / 2;
 
        /* Set Twi interface clock as specified */
        write_CLKDIV(iface, (clkhilow << 8) | clkhilow);
index 75bf3ad180993a2315a9af4dfd3b30f5bd1067f2..0037e31076bad86502442a95ed9d95206bdbde0e 100644 (file)
@@ -247,7 +247,13 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev)
                omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
        }
        dev->idle = 0;
-       omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
+
+       /*
+        * Don't write to this register if the IE state is 0 as it can
+        * cause deadlock.
+        */
+       if (dev->iestate)
+               omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
 }
 
 static void omap_i2c_idle(struct omap_i2c_dev *dev)
@@ -280,6 +286,11 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
        unsigned long internal_clk = 0;
 
        if (dev->rev >= OMAP_I2C_REV_2) {
+               /* Disable I2C controller before soft reset */
+               omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
+                       omap_i2c_read_reg(dev, OMAP_I2C_CON_REG) &
+                               ~(OMAP_I2C_CON_EN));
+
                omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK);
                /* For some reason we need to set the EN bit before the
                 * reset done bit gets set. */
index 049555777f67da5549cca3d689977809bbef0153..7647a20523a02dc01ccd58b5ed777448f00e57f6 100644 (file)
@@ -1155,7 +1155,7 @@ static int i2c_pxa_resume_noirq(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops i2c_pxa_dev_pm_ops = {
+static const struct dev_pm_ops i2c_pxa_dev_pm_ops = {
        .suspend_noirq = i2c_pxa_suspend_noirq,
        .resume_noirq = i2c_pxa_resume_noirq,
 };
index 96aafb91b69a78e482eab02d3df45dbd70a7bfc3..1d8c98613fa057c88f75b4a7bd793348c60b8da8 100644 (file)
@@ -967,7 +967,7 @@ static int s3c24xx_i2c_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
+static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
        .suspend_noirq = s3c24xx_i2c_suspend_noirq,
        .resume = s3c24xx_i2c_resume,
 };
index 86a9d4e8147288dac1866b98588f013d4c02268b..ccc46418ef7f16b2409c28cdf7f7f8ebdb6796d4 100644 (file)
@@ -647,7 +647,7 @@ static int sh_mobile_i2c_runtime_nop(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = {
+static const struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = {
        .runtime_suspend = sh_mobile_i2c_runtime_nop,
        .runtime_resume = sh_mobile_i2c_runtime_nop,
 };
index 4f34823e86b103ffbac7b9f51bb753ddcacf52ba..0ac2f90ab840c8f1863013ba9551a3266247f738 100644 (file)
@@ -155,6 +155,35 @@ static void i2c_device_shutdown(struct device *dev)
                driver->shutdown(client);
 }
 
+#ifdef CONFIG_SUSPEND
+static int i2c_device_pm_suspend(struct device *dev)
+{
+       const struct dev_pm_ops *pm;
+
+       if (!dev->driver)
+               return 0;
+       pm = dev->driver->pm;
+       if (!pm || !pm->suspend)
+               return 0;
+       return pm->suspend(dev);
+}
+
+static int i2c_device_pm_resume(struct device *dev)
+{
+       const struct dev_pm_ops *pm;
+
+       if (!dev->driver)
+               return 0;
+       pm = dev->driver->pm;
+       if (!pm || !pm->resume)
+               return 0;
+       return pm->resume(dev);
+}
+#else
+#define i2c_device_pm_suspend  NULL
+#define i2c_device_pm_resume   NULL
+#endif
+
 static int i2c_device_suspend(struct device *dev, pm_message_t mesg)
 {
        struct i2c_client *client = i2c_verify_client(dev);
@@ -219,6 +248,11 @@ static const struct attribute_group *i2c_dev_attr_groups[] = {
        NULL
 };
 
+const static struct dev_pm_ops i2c_device_pm_ops = {
+       .suspend = i2c_device_pm_suspend,
+       .resume = i2c_device_pm_resume,
+};
+
 struct bus_type i2c_bus_type = {
        .name           = "i2c",
        .match          = i2c_device_match,
@@ -227,6 +261,7 @@ struct bus_type i2c_bus_type = {
        .shutdown       = i2c_device_shutdown,
        .suspend        = i2c_device_suspend,
        .resume         = i2c_device_resume,
+       .pm             = &i2c_device_pm_ops,
 };
 EXPORT_SYMBOL_GPL(i2c_bus_type);
 
@@ -1184,7 +1219,7 @@ static int i2c_detect_address(struct i2c_client *temp_client,
        /* Finally call the custom detection function */
        memset(&info, 0, sizeof(struct i2c_board_info));
        info.addr = addr;
-       err = driver->detect(temp_client, -1, &info);
+       err = driver->detect(temp_client, &info);
        if (err) {
                /* -ENODEV is returned if the detection fails. We catch it
                   here as this isn't an error. */
@@ -1214,13 +1249,13 @@ static int i2c_detect_address(struct i2c_client *temp_client,
 
 static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
 {
-       const struct i2c_client_address_data *address_data;
+       const unsigned short *address_list;
        struct i2c_client *temp_client;
        int i, err = 0;
        int adap_id = i2c_adapter_id(adapter);
 
-       address_data = driver->address_data;
-       if (!driver->detect || !address_data)
+       address_list = driver->address_list;
+       if (!driver->detect || !address_list)
                return 0;
 
        /* Set up a temporary client to help detect callback */
@@ -1235,7 +1270,7 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
 
        /* Stop here if we can't use SMBUS_QUICK */
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) {
-               if (address_data->normal_i2c[0] == I2C_CLIENT_END)
+               if (address_list[0] == I2C_CLIENT_END)
                        goto exit_free;
 
                dev_warn(&adapter->dev, "SMBus Quick command not supported, "
@@ -1244,11 +1279,10 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
                goto exit_free;
        }
 
-       for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) {
+       for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) {
                dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
-                       "addr 0x%02x\n", adap_id,
-                       address_data->normal_i2c[i]);
-               temp_client->addr = address_data->normal_i2c[i];
+                       "addr 0x%02x\n", adap_id, address_list[i]);
+               temp_client->addr = address_list[i];
                err = i2c_detect_address(temp_client, driver);
                if (err)
                        goto exit_free;
index 1f20a042a4f508197ff45ebec146a9ff2daeeccd..dd253002cd50c973bd8e1ffcc5041415cf0abe1b 100644 (file)
@@ -81,7 +81,7 @@ static u8 i7300_idle_thrtctl_saved;
 static u8 i7300_idle_thrtlow_saved;
 static u32 i7300_idle_mc_saved;
 
-static cpumask_t idle_cpumask;
+static cpumask_var_t idle_cpumask;
 static ktime_t start_ktime;
 static unsigned long avg_idle_us;
 
@@ -459,9 +459,9 @@ static int i7300_idle_notifier(struct notifier_block *nb, unsigned long val,
        spin_lock_irqsave(&i7300_idle_lock, flags);
        if (val == IDLE_START) {
 
-               cpu_set(smp_processor_id(), idle_cpumask);
+               cpumask_set_cpu(smp_processor_id(), idle_cpumask);
 
-               if (cpus_weight(idle_cpumask) != num_online_cpus())
+               if (cpumask_weight(idle_cpumask) != num_online_cpus())
                        goto end;
 
                now_ktime = ktime_get();
@@ -478,8 +478,8 @@ static int i7300_idle_notifier(struct notifier_block *nb, unsigned long val,
                i7300_idle_ioat_start();
 
        } else if (val == IDLE_END) {
-               cpu_clear(smp_processor_id(), idle_cpumask);
-               if (cpus_weight(idle_cpumask) == (num_online_cpus() - 1)) {
+               cpumask_clear_cpu(smp_processor_id(), idle_cpumask);
+               if (cpumask_weight(idle_cpumask) == (num_online_cpus() - 1)) {
                        /* First CPU coming out of idle */
                        u64 idle_duration_us;
 
@@ -553,7 +553,6 @@ struct debugfs_file_info {
 static int __init i7300_idle_init(void)
 {
        spin_lock_init(&i7300_idle_lock);
-       cpus_clear(idle_cpumask);
        total_us = 0;
 
        if (i7300_idle_platform_probe(&fbd_dev, &ioat_dev, forceload))
@@ -565,6 +564,9 @@ static int __init i7300_idle_init(void)
        if (i7300_idle_ioat_init())
                return -ENODEV;
 
+       if (!zalloc_cpumask_var(&idle_cpumask, GFP_KERNEL))
+               return -ENOMEM;
+
        debugfs_dir = debugfs_create_dir("i7300_idle", NULL);
        if (debugfs_dir) {
                int i = 0;
@@ -589,6 +591,7 @@ static int __init i7300_idle_init(void)
 static void __exit i7300_idle_exit(void)
 {
        idle_notifier_unregister(&i7300_idle_nb);
+       free_cpumask_var(idle_cpumask);
 
        if (debugfs_dir) {
                int i = 0;
index bd07803e91838355b77f0d6f133cfbfe12a8e985..abbb06996f9e008c0a5c5957a18b46d10ef032d7 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/mutex.h>
 #include <linux/inetdevice.h>
 #include <linux/workqueue.h>
-#include <linux/if_arp.h>
 #include <net/arp.h>
 #include <net/neighbour.h>
 #include <net/route.h>
@@ -92,22 +91,12 @@ EXPORT_SYMBOL(rdma_addr_unregister_client);
 int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
                     const unsigned char *dst_dev_addr)
 {
-       switch (dev->type) {
-       case ARPHRD_INFINIBAND:
-               dev_addr->dev_type = RDMA_NODE_IB_CA;
-               break;
-       case ARPHRD_ETHER:
-               dev_addr->dev_type = RDMA_NODE_RNIC;
-               break;
-       default:
-               return -EADDRNOTAVAIL;
-       }
-
+       dev_addr->dev_type = dev->type;
        memcpy(dev_addr->src_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
        memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN);
        if (dst_dev_addr)
                memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
-       dev_addr->src_dev = dev;
+       dev_addr->bound_dev_if = dev->ifindex;
        return 0;
 }
 EXPORT_SYMBOL(rdma_copy_addr);
@@ -117,6 +106,15 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
        struct net_device *dev;
        int ret = -EADDRNOTAVAIL;
 
+       if (dev_addr->bound_dev_if) {
+               dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
+               if (!dev)
+                       return -ENODEV;
+               ret = rdma_copy_addr(dev_addr, dev, NULL);
+               dev_put(dev);
+               return ret;
+       }
+
        switch (addr->sa_family) {
        case AF_INET:
                dev = ip_dev_find(&init_net,
@@ -131,6 +129,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
        case AF_INET6:
+               read_lock(&dev_base_lock);
                for_each_netdev(&init_net, dev) {
                        if (ipv6_chk_addr(&init_net,
                                          &((struct sockaddr_in6 *) addr)->sin6_addr,
@@ -139,6 +138,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
                                break;
                        }
                }
+               read_unlock(&dev_base_lock);
                break;
 #endif
        }
@@ -176,48 +176,9 @@ static void queue_req(struct addr_req *req)
        mutex_unlock(&lock);
 }
 
-static void addr_send_arp(struct sockaddr *dst_in)
-{
-       struct rtable *rt;
-       struct flowi fl;
-
-       memset(&fl, 0, sizeof fl);
-
-       switch (dst_in->sa_family) {
-       case AF_INET:
-               fl.nl_u.ip4_u.daddr =
-                       ((struct sockaddr_in *) dst_in)->sin_addr.s_addr;
-
-               if (ip_route_output_key(&init_net, &rt, &fl))
-                       return;
-
-               neigh_event_send(rt->u.dst.neighbour, NULL);
-               ip_rt_put(rt);
-               break;
-
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
-       case AF_INET6:
-       {
-               struct dst_entry *dst;
-
-               fl.nl_u.ip6_u.daddr =
-                       ((struct sockaddr_in6 *) dst_in)->sin6_addr;
-
-               dst = ip6_route_output(&init_net, NULL, &fl);
-               if (!dst)
-                       return;
-
-               neigh_event_send(dst->neighbour, NULL);
-               dst_release(dst);
-               break;
-       }
-#endif
-       }
-}
-
-static int addr4_resolve_remote(struct sockaddr_in *src_in,
-                              struct sockaddr_in *dst_in,
-                              struct rdma_dev_addr *addr)
+static int addr4_resolve(struct sockaddr_in *src_in,
+                        struct sockaddr_in *dst_in,
+                        struct rdma_dev_addr *addr)
 {
        __be32 src_ip = src_in->sin_addr.s_addr;
        __be32 dst_ip = dst_in->sin_addr.s_addr;
@@ -229,10 +190,22 @@ static int addr4_resolve_remote(struct sockaddr_in *src_in,
        memset(&fl, 0, sizeof fl);
        fl.nl_u.ip4_u.daddr = dst_ip;
        fl.nl_u.ip4_u.saddr = src_ip;
+       fl.oif = addr->bound_dev_if;
+
        ret = ip_route_output_key(&init_net, &rt, &fl);
        if (ret)
                goto out;
 
+       src_in->sin_family = AF_INET;
+       src_in->sin_addr.s_addr = rt->rt_src;
+
+       if (rt->idev->dev->flags & IFF_LOOPBACK) {
+               ret = rdma_translate_ip((struct sockaddr *) dst_in, addr);
+               if (!ret)
+                       memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN);
+               goto put;
+       }
+
        /* If the device does ARP internally, return 'done' */
        if (rt->idev->dev->flags & IFF_NOARP) {
                rdma_copy_addr(addr, rt->idev->dev, NULL);
@@ -240,21 +213,14 @@ static int addr4_resolve_remote(struct sockaddr_in *src_in,
        }
 
        neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->idev->dev);
-       if (!neigh) {
+       if (!neigh || !(neigh->nud_state & NUD_VALID)) {
+               neigh_event_send(rt->u.dst.neighbour, NULL);
                ret = -ENODATA;
+               if (neigh)
+                       goto release;
                goto put;
        }
 
-       if (!(neigh->nud_state & NUD_VALID)) {
-               ret = -ENODATA;
-               goto release;
-       }
-
-       if (!src_ip) {
-               src_in->sin_family = dst_in->sin_family;
-               src_in->sin_addr.s_addr = rt->rt_src;
-       }
-
        ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
 release:
        neigh_release(neigh);
@@ -265,52 +231,77 @@ out:
 }
 
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
-static int addr6_resolve_remote(struct sockaddr_in6 *src_in,
-                              struct sockaddr_in6 *dst_in,
-                              struct rdma_dev_addr *addr)
+static int addr6_resolve(struct sockaddr_in6 *src_in,
+                        struct sockaddr_in6 *dst_in,
+                        struct rdma_dev_addr *addr)
 {
        struct flowi fl;
        struct neighbour *neigh;
        struct dst_entry *dst;
-       int ret = -ENODATA;
+       int ret;
 
        memset(&fl, 0, sizeof fl);
-       fl.nl_u.ip6_u.daddr = dst_in->sin6_addr;
-       fl.nl_u.ip6_u.saddr = src_in->sin6_addr;
+       ipv6_addr_copy(&fl.fl6_dst, &dst_in->sin6_addr);
+       ipv6_addr_copy(&fl.fl6_src, &src_in->sin6_addr);
+       fl.oif = addr->bound_dev_if;
 
        dst = ip6_route_output(&init_net, NULL, &fl);
-       if (!dst)
-               return ret;
+       if ((ret = dst->error))
+               goto put;
+
+       if (ipv6_addr_any(&fl.fl6_src)) {
+               ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
+                                        &fl.fl6_dst, 0, &fl.fl6_src);
+               if (ret)
+                       goto put;
+
+               src_in->sin6_family = AF_INET6;
+               ipv6_addr_copy(&src_in->sin6_addr, &fl.fl6_src);
+       }
+
+       if (dst->dev->flags & IFF_LOOPBACK) {
+               ret = rdma_translate_ip((struct sockaddr *) dst_in, addr);
+               if (!ret)
+                       memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN);
+               goto put;
+       }
 
+       /* If the device does ARP internally, return 'done' */
        if (dst->dev->flags & IFF_NOARP) {
                ret = rdma_copy_addr(addr, dst->dev, NULL);
-       } else {
-               neigh = dst->neighbour;
-               if (neigh && (neigh->nud_state & NUD_VALID))
-                       ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
+               goto put;
+       }
+
+       neigh = dst->neighbour;
+       if (!neigh || !(neigh->nud_state & NUD_VALID)) {
+               neigh_event_send(dst->neighbour, NULL);
+               ret = -ENODATA;
+               goto put;
        }
 
+       ret = rdma_copy_addr(addr, dst->dev, neigh->ha);
+put:
        dst_release(dst);
        return ret;
 }
 #else
-static int addr6_resolve_remote(struct sockaddr_in6 *src_in,
-                              struct sockaddr_in6 *dst_in,
-                              struct rdma_dev_addr *addr)
+static int addr6_resolve(struct sockaddr_in6 *src_in,
+                        struct sockaddr_in6 *dst_in,
+                        struct rdma_dev_addr *addr)
 {
        return -EADDRNOTAVAIL;
 }
 #endif
 
-static int addr_resolve_remote(struct sockaddr *src_in,
-                               struct sockaddr *dst_in,
-                               struct rdma_dev_addr *addr)
+static int addr_resolve(struct sockaddr *src_in,
+                       struct sockaddr *dst_in,
+                       struct rdma_dev_addr *addr)
 {
        if (src_in->sa_family == AF_INET) {
-               return addr4_resolve_remote((struct sockaddr_in *) src_in,
+               return addr4_resolve((struct sockaddr_in *) src_in,
                        (struct sockaddr_in *) dst_in, addr);
        } else
-               return addr6_resolve_remote((struct sockaddr_in6 *) src_in,
+               return addr6_resolve((struct sockaddr_in6 *) src_in,
                        (struct sockaddr_in6 *) dst_in, addr);
 }
 
@@ -327,8 +318,7 @@ static void process_req(struct work_struct *work)
                if (req->status == -ENODATA) {
                        src_in = (struct sockaddr *) &req->src_addr;
                        dst_in = (struct sockaddr *) &req->dst_addr;
-                       req->status = addr_resolve_remote(src_in, dst_in,
-                                                         req->addr);
+                       req->status = addr_resolve(src_in, dst_in, req->addr);
                        if (req->status && time_after_eq(jiffies, req->timeout))
                                req->status = -ETIMEDOUT;
                        else if (req->status == -ENODATA)
@@ -352,82 +342,6 @@ static void process_req(struct work_struct *work)
        }
 }
 
-static int addr_resolve_local(struct sockaddr *src_in,
-                             struct sockaddr *dst_in,
-                             struct rdma_dev_addr *addr)
-{
-       struct net_device *dev;
-       int ret;
-
-       switch (dst_in->sa_family) {
-       case AF_INET:
-       {
-               __be32 src_ip = ((struct sockaddr_in *) src_in)->sin_addr.s_addr;
-               __be32 dst_ip = ((struct sockaddr_in *) dst_in)->sin_addr.s_addr;
-
-               dev = ip_dev_find(&init_net, dst_ip);
-               if (!dev)
-                       return -EADDRNOTAVAIL;
-
-               if (ipv4_is_zeronet(src_ip)) {
-                       src_in->sa_family = dst_in->sa_family;
-                       ((struct sockaddr_in *) src_in)->sin_addr.s_addr = dst_ip;
-                       ret = rdma_copy_addr(addr, dev, dev->dev_addr);
-               } else if (ipv4_is_loopback(src_ip)) {
-                       ret = rdma_translate_ip(dst_in, addr);
-                       if (!ret)
-                               memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
-               } else {
-                       ret = rdma_translate_ip(src_in, addr);
-                       if (!ret)
-                               memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
-               }
-               dev_put(dev);
-               break;
-       }
-
-#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
-       case AF_INET6:
-       {
-               struct in6_addr *a;
-
-               for_each_netdev(&init_net, dev)
-                       if (ipv6_chk_addr(&init_net,
-                                         &((struct sockaddr_in6 *) dst_in)->sin6_addr,
-                                         dev, 1))
-                               break;
-
-               if (!dev)
-                       return -EADDRNOTAVAIL;
-
-               a = &((struct sockaddr_in6 *) src_in)->sin6_addr;
-
-               if (ipv6_addr_any(a)) {
-                       src_in->sa_family = dst_in->sa_family;
-                       ((struct sockaddr_in6 *) src_in)->sin6_addr =
-                               ((struct sockaddr_in6 *) dst_in)->sin6_addr;
-                       ret = rdma_copy_addr(addr, dev, dev->dev_addr);
-               } else if (ipv6_addr_loopback(a)) {
-                       ret = rdma_translate_ip(dst_in, addr);
-                       if (!ret)
-                               memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
-               } else  {
-                       ret = rdma_translate_ip(src_in, addr);
-                       if (!ret)
-                               memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
-               }
-               break;
-       }
-#endif
-
-       default:
-               ret = -EADDRNOTAVAIL;
-               break;
-       }
-
-       return ret;
-}
-
 int rdma_resolve_ip(struct rdma_addr_client *client,
                    struct sockaddr *src_addr, struct sockaddr *dst_addr,
                    struct rdma_dev_addr *addr, int timeout_ms,
@@ -443,22 +357,28 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
        if (!req)
                return -ENOMEM;
 
-       if (src_addr)
-               memcpy(&req->src_addr, src_addr, ip_addr_size(src_addr));
-       memcpy(&req->dst_addr, dst_addr, ip_addr_size(dst_addr));
+       src_in = (struct sockaddr *) &req->src_addr;
+       dst_in = (struct sockaddr *) &req->dst_addr;
+
+       if (src_addr) {
+               if (src_addr->sa_family != dst_addr->sa_family) {
+                       ret = -EINVAL;
+                       goto err;
+               }
+
+               memcpy(src_in, src_addr, ip_addr_size(src_addr));
+       } else {
+               src_in->sa_family = dst_addr->sa_family;
+       }
+
+       memcpy(dst_in, dst_addr, ip_addr_size(dst_addr));
        req->addr = addr;
        req->callback = callback;
        req->context = context;
        req->client = client;
        atomic_inc(&client->refcount);
 
-       src_in = (struct sockaddr *) &req->src_addr;
-       dst_in = (struct sockaddr *) &req->dst_addr;
-
-       req->status = addr_resolve_local(src_in, dst_in, addr);
-       if (req->status == -EADDRNOTAVAIL)
-               req->status = addr_resolve_remote(src_in, dst_in, addr);
-
+       req->status = addr_resolve(src_in, dst_in, addr);
        switch (req->status) {
        case 0:
                req->timeout = jiffies;
@@ -467,15 +387,16 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
        case -ENODATA:
                req->timeout = msecs_to_jiffies(timeout_ms) + jiffies;
                queue_req(req);
-               addr_send_arp(dst_in);
                break;
        default:
                ret = req->status;
                atomic_dec(&client->refcount);
-               kfree(req);
-               break;
+               goto err;
        }
        return ret;
+err:
+       kfree(req);
+       return ret;
 }
 EXPORT_SYMBOL(rdma_resolve_ip);
 
index 075317884b5309f31ee3b8f7fac4821ea5622040..fbdd73106000b69143fc2a7f8f8a43df4fae53b6 100644 (file)
@@ -330,17 +330,7 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv)
        union ib_gid gid;
        int ret = -ENODEV;
 
-       switch (rdma_node_get_transport(dev_addr->dev_type)) {
-       case RDMA_TRANSPORT_IB:
-               ib_addr_get_sgid(dev_addr, &gid);
-               break;
-       case RDMA_TRANSPORT_IWARP:
-               iw_addr_get_sgid(dev_addr, &gid);
-               break;
-       default:
-               return -ENODEV;
-       }
-
+       rdma_addr_get_sgid(dev_addr, &gid);
        list_for_each_entry(cma_dev, &dev_list, list) {
                ret = ib_find_cached_gid(cma_dev->device, &gid,
                                         &id_priv->id.port_num, NULL);
@@ -1032,11 +1022,17 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
        if (rt->num_paths == 2)
                rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path;
 
-       ib_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
-       ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr,
-                               &id->route.addr.dev_addr);
-       if (ret)
-               goto destroy_id;
+       if (cma_any_addr((struct sockaddr *) &rt->addr.src_addr)) {
+               rt->addr.dev_addr.dev_type = ARPHRD_INFINIBAND;
+               rdma_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
+               ib_addr_set_pkey(&rt->addr.dev_addr, rt->path_rec[0].pkey);
+       } else {
+               ret = rdma_translate_ip((struct sockaddr *) &rt->addr.src_addr,
+                                       &rt->addr.dev_addr);
+               if (ret)
+                       goto destroy_id;
+       }
+       rdma_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
 
        id_priv = container_of(id, struct rdma_id_private, id);
        id_priv->state = CMA_CONNECT;
@@ -1071,10 +1067,12 @@ static struct rdma_id_private *cma_new_udp_id(struct rdma_cm_id *listen_id,
        cma_save_net_info(&id->route.addr, &listen_id->route.addr,
                          ip_ver, port, src, dst);
 
-       ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr,
-                               &id->route.addr.dev_addr);
-       if (ret)
-               goto err;
+       if (!cma_any_addr((struct sockaddr *) &id->route.addr.src_addr)) {
+               ret = rdma_translate_ip((struct sockaddr *) &id->route.addr.src_addr,
+                                       &id->route.addr.dev_addr);
+               if (ret)
+                       goto err;
+       }
 
        id_priv = container_of(id, struct rdma_id_private, id);
        id_priv->state = CMA_CONNECT;
@@ -1474,15 +1472,6 @@ static void cma_listen_on_all(struct rdma_id_private *id_priv)
        mutex_unlock(&lock);
 }
 
-static int cma_bind_any(struct rdma_cm_id *id, sa_family_t af)
-{
-       struct sockaddr_storage addr_in;
-
-       memset(&addr_in, 0, sizeof addr_in);
-       addr_in.ss_family = af;
-       return rdma_bind_addr(id, (struct sockaddr *) &addr_in);
-}
-
 int rdma_listen(struct rdma_cm_id *id, int backlog)
 {
        struct rdma_id_private *id_priv;
@@ -1490,7 +1479,8 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
 
        id_priv = container_of(id, struct rdma_id_private, id);
        if (id_priv->state == CMA_IDLE) {
-               ret = cma_bind_any(id, AF_INET);
+               ((struct sockaddr *) &id->route.addr.src_addr)->sa_family = AF_INET;
+               ret = rdma_bind_addr(id, (struct sockaddr *) &id->route.addr.src_addr);
                if (ret)
                        return ret;
        }
@@ -1565,8 +1555,8 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
        struct sockaddr_in6 *sin6;
 
        memset(&path_rec, 0, sizeof path_rec);
-       ib_addr_get_sgid(&addr->dev_addr, &path_rec.sgid);
-       ib_addr_get_dgid(&addr->dev_addr, &path_rec.dgid);
+       rdma_addr_get_sgid(&addr->dev_addr, &path_rec.sgid);
+       rdma_addr_get_dgid(&addr->dev_addr, &path_rec.dgid);
        path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(&addr->dev_addr));
        path_rec.numb_path = 1;
        path_rec.reversible = 1;
@@ -1781,7 +1771,11 @@ port_found:
        if (ret)
                goto out;
 
-       ib_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
+       id_priv->id.route.addr.dev_addr.dev_type =
+               (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB) ?
+               ARPHRD_INFINIBAND : ARPHRD_ETHER;
+
+       rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
        ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey);
        id_priv->id.port_num = p;
        cma_attach_to_dev(id_priv, cma_dev);
@@ -1839,7 +1833,7 @@ out:
 static int cma_resolve_loopback(struct rdma_id_private *id_priv)
 {
        struct cma_work *work;
-       struct sockaddr_in *src_in, *dst_in;
+       struct sockaddr *src, *dst;
        union ib_gid gid;
        int ret;
 
@@ -1853,14 +1847,19 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
                        goto err;
        }
 
-       ib_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid);
-       ib_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid);
+       rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid);
+       rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid);
 
-       if (cma_zero_addr((struct sockaddr *) &id_priv->id.route.addr.src_addr)) {
-               src_in = (struct sockaddr_in *)&id_priv->id.route.addr.src_addr;
-               dst_in = (struct sockaddr_in *)&id_priv->id.route.addr.dst_addr;
-               src_in->sin_family = dst_in->sin_family;
-               src_in->sin_addr.s_addr = dst_in->sin_addr.s_addr;
+       src = (struct sockaddr *) &id_priv->id.route.addr.src_addr;
+       if (cma_zero_addr(src)) {
+               dst = (struct sockaddr *) &id_priv->id.route.addr.dst_addr;
+               if ((src->sa_family = dst->sa_family) == AF_INET) {
+                       ((struct sockaddr_in *) src)->sin_addr.s_addr =
+                               ((struct sockaddr_in *) dst)->sin_addr.s_addr;
+               } else {
+                       ipv6_addr_copy(&((struct sockaddr_in6 *) src)->sin6_addr,
+                                      &((struct sockaddr_in6 *) dst)->sin6_addr);
+               }
        }
 
        work->id = id_priv;
@@ -1878,10 +1877,14 @@ err:
 static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
                         struct sockaddr *dst_addr)
 {
-       if (src_addr && src_addr->sa_family)
-               return rdma_bind_addr(id, src_addr);
-       else
-               return cma_bind_any(id, dst_addr->sa_family);
+       if (!src_addr || !src_addr->sa_family) {
+               src_addr = (struct sockaddr *) &id->route.addr.src_addr;
+               if ((src_addr->sa_family = dst_addr->sa_family) == AF_INET6) {
+                       ((struct sockaddr_in6 *) src_addr)->sin6_scope_id =
+                               ((struct sockaddr_in6 *) dst_addr)->sin6_scope_id;
+               }
+       }
+       return rdma_bind_addr(id, src_addr);
 }
 
 int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
@@ -2077,6 +2080,25 @@ static int cma_get_port(struct rdma_id_private *id_priv)
        return ret;
 }
 
+static int cma_check_linklocal(struct rdma_dev_addr *dev_addr,
+                              struct sockaddr *addr)
+{
+#if defined(CONFIG_IPv6) || defined(CONFIG_IPV6_MODULE)
+       struct sockaddr_in6 *sin6;
+
+       if (addr->sa_family != AF_INET6)
+               return 0;
+
+       sin6 = (struct sockaddr_in6 *) addr;
+       if ((ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) &&
+           !sin6->sin6_scope_id)
+                       return -EINVAL;
+
+       dev_addr->bound_dev_if = sin6->sin6_scope_id;
+#endif
+       return 0;
+}
+
 int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
 {
        struct rdma_id_private *id_priv;
@@ -2089,7 +2111,13 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
        if (!cma_comp_exch(id_priv, CMA_IDLE, CMA_ADDR_BOUND))
                return -EINVAL;
 
-       if (!cma_any_addr(addr)) {
+       ret = cma_check_linklocal(&id->route.addr.dev_addr, addr);
+       if (ret)
+               goto err1;
+
+       if (cma_loopback_addr(addr)) {
+               ret = cma_bind_loopback(id_priv);
+       } else if (!cma_zero_addr(addr)) {
                ret = rdma_translate_ip(addr, &id->route.addr.dev_addr);
                if (ret)
                        goto err1;
@@ -2108,7 +2136,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr)
 
        return 0;
 err2:
-       if (!cma_any_addr(addr)) {
+       if (id_priv->cma_dev) {
                mutex_lock(&lock);
                cma_detach_from_dev(id_priv);
                mutex_unlock(&lock);
@@ -2687,10 +2715,15 @@ static void cma_set_mgid(struct rdma_id_private *id_priv,
        if (cma_any_addr(addr)) {
                memset(mgid, 0, sizeof *mgid);
        } else if ((addr->sa_family == AF_INET6) &&
-                  ((be32_to_cpu(sin6->sin6_addr.s6_addr32[0]) & 0xFF10A01B) ==
+                  ((be32_to_cpu(sin6->sin6_addr.s6_addr32[0]) & 0xFFF0FFFF) ==
                                                                 0xFF10A01B)) {
                /* IPv6 address is an SA assigned MGID. */
                memcpy(mgid, &sin6->sin6_addr, sizeof *mgid);
+       } else if ((addr->sa_family == AF_INET6)) {
+               ipv6_ib_mc_map(&sin6->sin6_addr, dev_addr->broadcast, mc_map);
+               if (id_priv->id.ps == RDMA_PS_UDP)
+                       mc_map[7] = 0x01;       /* Use RDMA CM signature */
+               *mgid = *(union ib_gid *) (mc_map + 4);
        } else {
                ip_ib_mc_map(sin->sin_addr.s_addr, dev_addr->broadcast, mc_map);
                if (id_priv->id.ps == RDMA_PS_UDP)
@@ -2716,7 +2749,7 @@ static int cma_join_ib_multicast(struct rdma_id_private *id_priv,
        cma_set_mgid(id_priv, (struct sockaddr *) &mc->addr, &rec.mgid);
        if (id_priv->id.ps == RDMA_PS_UDP)
                rec.qkey = cpu_to_be32(RDMA_UDP_QKEY);
-       ib_addr_get_sgid(dev_addr, &rec.port_gid);
+       rdma_addr_get_sgid(dev_addr, &rec.port_gid);
        rec.pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
        rec.join_state = 1;
 
@@ -2815,7 +2848,7 @@ static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id
 
        dev_addr = &id_priv->id.route.addr.dev_addr;
 
-       if ((dev_addr->src_dev == ndev) &&
+       if ((dev_addr->bound_dev_if == ndev->ifindex) &&
            memcmp(dev_addr->src_dev_addr, ndev->dev_addr, ndev->addr_len)) {
                printk(KERN_INFO "RDMA CM addr change for ndev %s used by id %p\n",
                       ndev->name, &id_priv->id);
index 82543716d59ef74ce57029e03fd1e09aef6032a3..7e1ffd8ccd5c07084317fecbae15cd3574938991 100644 (file)
@@ -604,6 +604,12 @@ retry:
        return ret ? ret : id;
 }
 
+void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec)
+{
+       ib_unpack(path_rec_table, ARRAY_SIZE(path_rec_table), attribute, rec);
+}
+EXPORT_SYMBOL(ib_sa_unpack_path);
+
 static void ib_sa_path_rec_callback(struct ib_sa_query *sa_query,
                                    int status,
                                    struct ib_sa_mad *mad)
index bb96d3c4b0f4e06d3b8eeb6b8c685cddc4418eba..b2e16c332d5b038703e083057339da6cd0434749 100644 (file)
@@ -43,6 +43,7 @@
 #include <rdma/rdma_user_cm.h>
 #include <rdma/ib_marshall.h>
 #include <rdma/rdma_cm.h>
+#include <rdma/rdma_cm_ib.h>
 
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("RDMA Userspace Connection Manager Access");
@@ -562,10 +563,10 @@ static void ucma_copy_ib_route(struct rdma_ucm_query_route_resp *resp,
        switch (route->num_paths) {
        case 0:
                dev_addr = &route->addr.dev_addr;
-               ib_addr_get_dgid(dev_addr,
-                                (union ib_gid *) &resp->ib_route[0].dgid);
-               ib_addr_get_sgid(dev_addr,
-                                (union ib_gid *) &resp->ib_route[0].sgid);
+               rdma_addr_get_dgid(dev_addr,
+                                  (union ib_gid *) &resp->ib_route[0].dgid);
+               rdma_addr_get_sgid(dev_addr,
+                                  (union ib_gid *) &resp->ib_route[0].sgid);
                resp->ib_route[0].pkey = cpu_to_be16(ib_addr_get_pkey(dev_addr));
                break;
        case 2:
@@ -812,6 +813,51 @@ static int ucma_set_option_id(struct ucma_context *ctx, int optname,
        return ret;
 }
 
+static int ucma_set_ib_path(struct ucma_context *ctx,
+                           struct ib_path_rec_data *path_data, size_t optlen)
+{
+       struct ib_sa_path_rec sa_path;
+       struct rdma_cm_event event;
+       int ret;
+
+       if (optlen % sizeof(*path_data))
+               return -EINVAL;
+
+       for (; optlen; optlen -= sizeof(*path_data), path_data++) {
+               if (path_data->flags == (IB_PATH_GMP | IB_PATH_PRIMARY |
+                                        IB_PATH_BIDIRECTIONAL))
+                       break;
+       }
+
+       if (!optlen)
+               return -EINVAL;
+
+       ib_sa_unpack_path(path_data->path_rec, &sa_path);
+       ret = rdma_set_ib_paths(ctx->cm_id, &sa_path, 1);
+       if (ret)
+               return ret;
+
+       memset(&event, 0, sizeof event);
+       event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
+       return ucma_event_handler(ctx->cm_id, &event);
+}
+
+static int ucma_set_option_ib(struct ucma_context *ctx, int optname,
+                             void *optval, size_t optlen)
+{
+       int ret;
+
+       switch (optname) {
+       case RDMA_OPTION_IB_PATH:
+               ret = ucma_set_ib_path(ctx, optval, optlen);
+               break;
+       default:
+               ret = -ENOSYS;
+       }
+
+       return ret;
+}
+
 static int ucma_set_option_level(struct ucma_context *ctx, int level,
                                 int optname, void *optval, size_t optlen)
 {
@@ -821,6 +867,9 @@ static int ucma_set_option_level(struct ucma_context *ctx, int level,
        case RDMA_OPTION_ID:
                ret = ucma_set_option_id(ctx, optname, optval, optlen);
                break;
+       case RDMA_OPTION_IB:
+               ret = ucma_set_option_ib(ctx, optname, optval, optlen);
+               break;
        default:
                ret = -ENOSYS;
        }
index 56feab6c251edd8e688647ee0cbf6617522b6e1c..112d3970222a08c3ea43af3aeeb4c9977c5546ff 100644 (file)
@@ -285,7 +285,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
 
        ucontext = ibdev->alloc_ucontext(ibdev, &udata);
        if (IS_ERR(ucontext)) {
-               ret = PTR_ERR(file->ucontext);
+               ret = PTR_ERR(ucontext);
                goto err;
        }
 
index aec0fbdfe7f016bba4126bbf89d64060783501b9..5f284ffd430e8b72dcdc493f91a1bd5430070973 100644 (file)
@@ -492,6 +492,7 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
                                        int is_async, int *fd)
 {
        struct ib_uverbs_event_file *ev_file;
+       struct path path;
        struct file *filp;
        int ret;
 
@@ -519,8 +520,10 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
         * system call on a uverbs file, which will already have a
         * module reference.
         */
-       filp = alloc_file(uverbs_event_mnt, dget(uverbs_event_mnt->mnt_root),
-                         FMODE_READ, fops_get(&uverbs_event_fops));
+       path.mnt = uverbs_event_mnt;
+       path.dentry = uverbs_event_mnt->mnt_root;
+       path_get(&path);
+       filp = alloc_file(&path, FMODE_READ, fops_get(&uverbs_event_fops));
        if (!filp) {
                ret = -ENFILE;
                goto err_fd;
@@ -531,6 +534,8 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
        return filp;
 
 err_fd:
+       fops_put(&uverbs_event_fops);
+       path_put(&path);
        put_unused_fd(*fd);
 
 err:
index a6d89440ad2c737d480508ee2e1010ff2dfbc1b8..ad518868df77642608281fd11d4c093c11c02711 100644 (file)
@@ -798,8 +798,10 @@ int c2_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
        u8 actual_sge_count;
        u32 msg_size;
 
-       if (qp->state > IB_QPS_RTS)
-               return -EINVAL;
+       if (qp->state > IB_QPS_RTS) {
+               err = -EINVAL;
+               goto out;
+       }
 
        while (ib_wr) {
 
@@ -930,6 +932,7 @@ int c2_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
                ib_wr = ib_wr->next;
        }
 
+out:
        if (err)
                *bad_wr = ib_wr;
        return err;
@@ -944,8 +947,10 @@ int c2_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *ib_wr,
        unsigned long lock_flags;
        int err = 0;
 
-       if (qp->state > IB_QPS_RTS)
-               return -EINVAL;
+       if (qp->state > IB_QPS_RTS) {
+               err = -EINVAL;
+               goto out;
+       }
 
        /*
         * Try and post each work request
@@ -998,6 +1003,7 @@ int c2_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *ib_wr,
                ib_wr = ib_wr->next;
        }
 
+out:
        if (err)
                *bad_wr = ib_wr;
        return err;
index bfd03bf8be546d4dd05198687187305c9502df43..f3d440cc68f21e96278bbb0c8b5be2af3a29bf68 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <linux/list.h>
 #include <linux/mutex.h>
+#include <linux/kfifo.h>
 
 #include "t3_cpl.h"
 #include "t3cdev.h"
@@ -75,13 +76,13 @@ struct cxio_hal_ctrl_qp {
 };
 
 struct cxio_hal_resource {
-       struct kfifo *tpt_fifo;
+       struct kfifo tpt_fifo;
        spinlock_t tpt_fifo_lock;
-       struct kfifo *qpid_fifo;
+       struct kfifo qpid_fifo;
        spinlock_t qpid_fifo_lock;
-       struct kfifo *cqid_fifo;
+       struct kfifo cqid_fifo;
        spinlock_t cqid_fifo_lock;
-       struct kfifo *pdid_fifo;
+       struct kfifo pdid_fifo;
        spinlock_t pdid_fifo_lock;
 };
 
index bd233c087653de5fed49dfbbf95f4d53cb43b7d0..31f9201b29809512ae5a4140456e0b457fa5e9cc 100644 (file)
 #include "cxio_resource.h"
 #include "cxio_hal.h"
 
-static struct kfifo *rhdl_fifo;
+static struct kfifo rhdl_fifo;
 static spinlock_t rhdl_fifo_lock;
 
 #define RANDOM_SIZE 16
 
-static int __cxio_init_resource_fifo(struct kfifo **fifo,
+static int __cxio_init_resource_fifo(struct kfifo *fifo,
                                   spinlock_t *fifo_lock,
                                   u32 nr, u32 skip_low,
                                   u32 skip_high,
@@ -55,12 +55,11 @@ static int __cxio_init_resource_fifo(struct kfifo **fifo,
        u32 rarray[16];
        spin_lock_init(fifo_lock);
 
-       *fifo = kfifo_alloc(nr * sizeof(u32), GFP_KERNEL, fifo_lock);
-       if (IS_ERR(*fifo))
+       if (kfifo_alloc(fifo, nr * sizeof(u32), GFP_KERNEL))
                return -ENOMEM;
 
        for (i = 0; i < skip_low + skip_high; i++)
-               __kfifo_put(*fifo, (unsigned char *) &entry, sizeof(u32));
+               kfifo_in(fifo, (unsigned char *) &entry, sizeof(u32));
        if (random) {
                j = 0;
                random_bytes = random32();
@@ -72,33 +71,35 @@ static int __cxio_init_resource_fifo(struct kfifo **fifo,
                                random_bytes = random32();
                        }
                        idx = (random_bytes >> (j * 2)) & 0xF;
-                       __kfifo_put(*fifo,
+                       kfifo_in(fifo,
                                (unsigned char *) &rarray[idx],
                                sizeof(u32));
                        rarray[idx] = i;
                        j++;
                }
                for (i = 0; i < RANDOM_SIZE; i++)
-                       __kfifo_put(*fifo,
+                       kfifo_in(fifo,
                                (unsigned char *) &rarray[i],
                                sizeof(u32));
        } else
                for (i = skip_low; i < nr - skip_high; i++)
-                       __kfifo_put(*fifo, (unsigned char *) &i, sizeof(u32));
+                       kfifo_in(fifo, (unsigned char *) &i, sizeof(u32));
 
        for (i = 0; i < skip_low + skip_high; i++)
-               kfifo_get(*fifo, (unsigned char *) &entry, sizeof(u32));
+               if (kfifo_out_locked(fifo, (unsigned char *) &entry,
+                               sizeof(u32), fifo_lock) != sizeof(u32))
+                                       break;
        return 0;
 }
 
-static int cxio_init_resource_fifo(struct kfifo **fifo, spinlock_t * fifo_lock,
+static int cxio_init_resource_fifo(struct kfifo *fifo, spinlock_t * fifo_lock,
                                   u32 nr, u32 skip_low, u32 skip_high)
 {
        return (__cxio_init_resource_fifo(fifo, fifo_lock, nr, skip_low,
                                          skip_high, 0));
 }
 
-static int cxio_init_resource_fifo_random(struct kfifo **fifo,
+static int cxio_init_resource_fifo_random(struct kfifo *fifo,
                                   spinlock_t * fifo_lock,
                                   u32 nr, u32 skip_low, u32 skip_high)
 {
@@ -113,15 +114,13 @@ static int cxio_init_qpid_fifo(struct cxio_rdev *rdev_p)
 
        spin_lock_init(&rdev_p->rscp->qpid_fifo_lock);
 
-       rdev_p->rscp->qpid_fifo = kfifo_alloc(T3_MAX_NUM_QP * sizeof(u32),
-                                             GFP_KERNEL,
-                                             &rdev_p->rscp->qpid_fifo_lock);
-       if (IS_ERR(rdev_p->rscp->qpid_fifo))
+       if (kfifo_alloc(&rdev_p->rscp->qpid_fifo, T3_MAX_NUM_QP * sizeof(u32),
+                                             GFP_KERNEL))
                return -ENOMEM;
 
        for (i = 16; i < T3_MAX_NUM_QP; i++)
                if (!(i & rdev_p->qpmask))
-                       __kfifo_put(rdev_p->rscp->qpid_fifo,
+                       kfifo_in(&rdev_p->rscp->qpid_fifo,
                                    (unsigned char *) &i, sizeof(u32));
        return 0;
 }
@@ -134,7 +133,7 @@ int cxio_hal_init_rhdl_resource(u32 nr_rhdl)
 
 void cxio_hal_destroy_rhdl_resource(void)
 {
-       kfifo_free(rhdl_fifo);
+       kfifo_free(&rhdl_fifo);
 }
 
 /* nr_* must be power of 2 */
@@ -167,11 +166,11 @@ int cxio_hal_init_resource(struct cxio_rdev *rdev_p,
                goto pdid_err;
        return 0;
 pdid_err:
-       kfifo_free(rscp->cqid_fifo);
+       kfifo_free(&rscp->cqid_fifo);
 cqid_err:
-       kfifo_free(rscp->qpid_fifo);
+       kfifo_free(&rscp->qpid_fifo);
 qpid_err:
-       kfifo_free(rscp->tpt_fifo);
+       kfifo_free(&rscp->tpt_fifo);
 tpt_err:
        return -ENOMEM;
 }
@@ -179,33 +178,37 @@ tpt_err:
 /*
  * returns 0 if no resource available
  */
-static u32 cxio_hal_get_resource(struct kfifo *fifo)
+static u32 cxio_hal_get_resource(struct kfifo *fifo, spinlock_t * lock)
 {
        u32 entry;
-       if (kfifo_get(fifo, (unsigned char *) &entry, sizeof(u32)))
+       if (kfifo_out_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock))
                return entry;
        else
                return 0;       /* fifo emptry */
 }
 
-static void cxio_hal_put_resource(struct kfifo *fifo, u32 entry)
+static void cxio_hal_put_resource(struct kfifo *fifo, spinlock_t * lock,
+               u32 entry)
 {
-       BUG_ON(kfifo_put(fifo, (unsigned char *) &entry, sizeof(u32)) == 0);
+       BUG_ON(
+       kfifo_in_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock)
+       == 0);
 }
 
 u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp)
 {
-       return cxio_hal_get_resource(rscp->tpt_fifo);
+       return cxio_hal_get_resource(&rscp->tpt_fifo, &rscp->tpt_fifo_lock);
 }
 
 void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag)
 {
-       cxio_hal_put_resource(rscp->tpt_fifo, stag);
+       cxio_hal_put_resource(&rscp->tpt_fifo, &rscp->tpt_fifo_lock, stag);
 }
 
 u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp)
 {
-       u32 qpid = cxio_hal_get_resource(rscp->qpid_fifo);
+       u32 qpid = cxio_hal_get_resource(&rscp->qpid_fifo,
+                       &rscp->qpid_fifo_lock);
        PDBG("%s qpid 0x%x\n", __func__, qpid);
        return qpid;
 }
@@ -213,35 +216,35 @@ u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp)
 void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid)
 {
        PDBG("%s qpid 0x%x\n", __func__, qpid);
-       cxio_hal_put_resource(rscp->qpid_fifo, qpid);
+       cxio_hal_put_resource(&rscp->qpid_fifo, &rscp->qpid_fifo_lock, qpid);
 }
 
 u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp)
 {
-       return cxio_hal_get_resource(rscp->cqid_fifo);
+       return cxio_hal_get_resource(&rscp->cqid_fifo, &rscp->cqid_fifo_lock);
 }
 
 void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid)
 {
-       cxio_hal_put_resource(rscp->cqid_fifo, cqid);
+       cxio_hal_put_resource(&rscp->cqid_fifo, &rscp->cqid_fifo_lock, cqid);
 }
 
 u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp)
 {
-       return cxio_hal_get_resource(rscp->pdid_fifo);
+       return cxio_hal_get_resource(&rscp->pdid_fifo, &rscp->pdid_fifo_lock);
 }
 
 void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid)
 {
-       cxio_hal_put_resource(rscp->pdid_fifo, pdid);
+       cxio_hal_put_resource(&rscp->pdid_fifo, &rscp->pdid_fifo_lock, pdid);
 }
 
 void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp)
 {
-       kfifo_free(rscp->tpt_fifo);
-       kfifo_free(rscp->cqid_fifo);
-       kfifo_free(rscp->qpid_fifo);
-       kfifo_free(rscp->pdid_fifo);
+       kfifo_free(&rscp->tpt_fifo);
+       kfifo_free(&rscp->cqid_fifo);
+       kfifo_free(&rscp->qpid_fifo);
+       kfifo_free(&rscp->pdid_fifo);
        kfree(rscp);
 }
 
index 1cecf98829ac93293e608238a316ce7f9ef0662f..3eb8cecf81d7ceb55287c9d0593b322be71087c1 100644 (file)
@@ -365,18 +365,19 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
        spin_lock_irqsave(&qhp->lock, flag);
        if (qhp->attr.state > IWCH_QP_STATE_RTS) {
                spin_unlock_irqrestore(&qhp->lock, flag);
-               return -EINVAL;
+               err = -EINVAL;
+               goto out;
        }
        num_wrs = Q_FREECNT(qhp->wq.sq_rptr, qhp->wq.sq_wptr,
                  qhp->wq.sq_size_log2);
        if (num_wrs <= 0) {
                spin_unlock_irqrestore(&qhp->lock, flag);
-               return -ENOMEM;
+               err = -ENOMEM;
+               goto out;
        }
        while (wr) {
                if (num_wrs == 0) {
                        err = -ENOMEM;
-                       *bad_wr = wr;
                        break;
                }
                idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2);
@@ -428,10 +429,8 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
                             wr->opcode);
                        err = -EINVAL;
                }
-               if (err) {
-                       *bad_wr = wr;
+               if (err)
                        break;
-               }
                wqe->send.wrid.id0.hi = qhp->wq.sq_wptr;
                sqp->wr_id = wr->wr_id;
                sqp->opcode = wr2opcode(t3_wr_opcode);
@@ -454,6 +453,10 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
        }
        spin_unlock_irqrestore(&qhp->lock, flag);
        ring_doorbell(qhp->wq.doorbell, qhp->wq.qpid);
+
+out:
+       if (err)
+               *bad_wr = wr;
        return err;
 }
 
@@ -471,18 +474,19 @@ int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
        spin_lock_irqsave(&qhp->lock, flag);
        if (qhp->attr.state > IWCH_QP_STATE_RTS) {
                spin_unlock_irqrestore(&qhp->lock, flag);
-               return -EINVAL;
+               err = -EINVAL;
+               goto out;
        }
        num_wrs = Q_FREECNT(qhp->wq.rq_rptr, qhp->wq.rq_wptr,
                            qhp->wq.rq_size_log2) - 1;
        if (!wr) {
                spin_unlock_irqrestore(&qhp->lock, flag);
-               return -EINVAL;
+               err = -ENOMEM;
+               goto out;
        }
        while (wr) {
                if (wr->num_sge > T3_MAX_SGE) {
                        err = -EINVAL;
-                       *bad_wr = wr;
                        break;
                }
                idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2);
@@ -494,10 +498,10 @@ int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
                                err = build_zero_stag_recv(qhp, wqe, wr);
                else
                        err = -ENOMEM;
-               if (err) {
-                       *bad_wr = wr;
+
+               if (err)
                        break;
-               }
+
                build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG,
                               Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2),
                               0, sizeof(struct t3_receive_wr) >> 3, T3_SOPEOP);
@@ -511,6 +515,10 @@ int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
        }
        spin_unlock_irqrestore(&qhp->lock, flag);
        ring_doorbell(qhp->wq.doorbell, qhp->wq.qpid);
+
+out:
+       if (err)
+               *bad_wr = wr;
        return err;
 }
 
index c825142a2fb752c7514e3af7d95d13c6d2d60f8b..0136abd50dd4cc5ff9ca5034589b6ab3cd923d55 100644 (file)
@@ -375,6 +375,7 @@ extern rwlock_t ehca_qp_idr_lock;
 extern rwlock_t ehca_cq_idr_lock;
 extern struct idr ehca_qp_idr;
 extern struct idr ehca_cq_idr;
+extern spinlock_t shca_list_lock;
 
 extern int ehca_static_rate;
 extern int ehca_port_act_time;
index 523e733c630e560acf6585ed1f35e772378e9649..3b87589b8ea0362c1a71e5b15cfdf9247b43f071 100644 (file)
@@ -169,12 +169,15 @@ int ehca_destroy_eq(struct ehca_shca *shca, struct ehca_eq *eq)
        unsigned long flags;
        u64 h_ret;
 
-       spin_lock_irqsave(&eq->spinlock, flags);
        ibmebus_free_irq(eq->ist, (void *)shca);
 
-       h_ret = hipz_h_destroy_eq(shca->ipz_hca_handle, eq);
+       spin_lock_irqsave(&shca_list_lock, flags);
+       eq->is_initialized = 0;
+       spin_unlock_irqrestore(&shca_list_lock, flags);
 
-       spin_unlock_irqrestore(&eq->spinlock, flags);
+       tasklet_kill(&eq->interrupt_task);
+
+       h_ret = hipz_h_destroy_eq(shca->ipz_hca_handle, eq);
 
        if (h_ret != H_SUCCESS) {
                ehca_err(&shca->ib_device, "Can't free EQ resources.");
index fb2d83c5bf010f955fd0ee7cb440724a5a5336bd..129a6bebd6e37bc20f6b3f36e77b0fb7653865e5 100644 (file)
@@ -123,7 +123,7 @@ DEFINE_IDR(ehca_qp_idr);
 DEFINE_IDR(ehca_cq_idr);
 
 static LIST_HEAD(shca_list); /* list of all registered ehcas */
-static DEFINE_SPINLOCK(shca_list_lock);
+DEFINE_SPINLOCK(shca_list_lock);
 
 static struct timer_list poll_eqs_timer;
 
index 8fd88cd828fd657ab11ef33e551e0f1060669f80..e3ec7fdd67bd7b07a66c95829de8dfd661011029 100644 (file)
@@ -400,7 +400,6 @@ static inline void map_ib_wc_status(u32 cqe_status,
 
 static inline int post_one_send(struct ehca_qp *my_qp,
                         struct ib_send_wr *cur_send_wr,
-                        struct ib_send_wr **bad_send_wr,
                         int hidden)
 {
        struct ehca_wqe *wqe_p;
@@ -412,8 +411,6 @@ static inline int post_one_send(struct ehca_qp *my_qp,
        wqe_p = ipz_qeit_get_inc(&my_qp->ipz_squeue);
        if (unlikely(!wqe_p)) {
                /* too many posted work requests: queue overflow */
-               if (bad_send_wr)
-                       *bad_send_wr = cur_send_wr;
                ehca_err(my_qp->ib_qp.device, "Too many posted WQEs "
                         "qp_num=%x", my_qp->ib_qp.qp_num);
                return -ENOMEM;
@@ -433,8 +430,6 @@ static inline int post_one_send(struct ehca_qp *my_qp,
         */
        if (unlikely(ret)) {
                my_qp->ipz_squeue.current_q_offset = start_offset;
-               if (bad_send_wr)
-                       *bad_send_wr = cur_send_wr;
                ehca_err(my_qp->ib_qp.device, "Could not write WQE "
                         "qp_num=%x", my_qp->ib_qp.qp_num);
                return -EINVAL;
@@ -448,7 +443,6 @@ int ehca_post_send(struct ib_qp *qp,
                   struct ib_send_wr **bad_send_wr)
 {
        struct ehca_qp *my_qp = container_of(qp, struct ehca_qp, ib_qp);
-       struct ib_send_wr *cur_send_wr;
        int wqe_cnt = 0;
        int ret = 0;
        unsigned long flags;
@@ -457,7 +451,8 @@ int ehca_post_send(struct ib_qp *qp,
        if (unlikely(my_qp->state < IB_QPS_RTS)) {
                ehca_err(qp->device, "Invalid QP state  qp_state=%d qpn=%x",
                         my_qp->state, qp->qp_num);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto out;
        }
 
        /* LOCK the QUEUE */
@@ -476,24 +471,21 @@ int ehca_post_send(struct ib_qp *qp,
                struct ib_send_wr circ_wr;
                memset(&circ_wr, 0, sizeof(circ_wr));
                circ_wr.opcode = IB_WR_RDMA_READ;
-               post_one_send(my_qp, &circ_wr, NULL, 1); /* ignore retcode */
+               post_one_send(my_qp, &circ_wr, 1); /* ignore retcode */
                wqe_cnt++;
                ehca_dbg(qp->device, "posted circ wr  qp_num=%x", qp->qp_num);
                my_qp->message_count = my_qp->packet_count = 0;
        }
 
        /* loop processes list of send reqs */
-       for (cur_send_wr = send_wr; cur_send_wr != NULL;
-            cur_send_wr = cur_send_wr->next) {
-               ret = post_one_send(my_qp, cur_send_wr, bad_send_wr, 0);
+       while (send_wr) {
+               ret = post_one_send(my_qp, send_wr, 0);
                if (unlikely(ret)) {
-                       /* if one or more WQEs were successful, don't fail */
-                       if (wqe_cnt)
-                               ret = 0;
                        goto post_send_exit0;
                }
                wqe_cnt++;
-       } /* eof for cur_send_wr */
+               send_wr = send_wr->next;
+       }
 
 post_send_exit0:
        iosync(); /* serialize GAL register access */
@@ -503,6 +495,10 @@ post_send_exit0:
                         my_qp, qp->qp_num, wqe_cnt, ret);
        my_qp->message_count += wqe_cnt;
        spin_unlock_irqrestore(&my_qp->spinlock_s, flags);
+
+out:
+       if (ret)
+               *bad_send_wr = send_wr;
        return ret;
 }
 
@@ -511,7 +507,6 @@ static int internal_post_recv(struct ehca_qp *my_qp,
                              struct ib_recv_wr *recv_wr,
                              struct ib_recv_wr **bad_recv_wr)
 {
-       struct ib_recv_wr *cur_recv_wr;
        struct ehca_wqe *wqe_p;
        int wqe_cnt = 0;
        int ret = 0;
@@ -522,27 +517,23 @@ static int internal_post_recv(struct ehca_qp *my_qp,
        if (unlikely(!HAS_RQ(my_qp))) {
                ehca_err(dev, "QP has no RQ  ehca_qp=%p qp_num=%x ext_type=%d",
                         my_qp, my_qp->real_qp_num, my_qp->ext_type);
-               return -ENODEV;
+               ret = -ENODEV;
+               goto out;
        }
 
        /* LOCK the QUEUE */
        spin_lock_irqsave(&my_qp->spinlock_r, flags);
 
-       /* loop processes list of send reqs */
-       for (cur_recv_wr = recv_wr; cur_recv_wr != NULL;
-            cur_recv_wr = cur_recv_wr->next) {
+       /* loop processes list of recv reqs */
+       while (recv_wr) {
                u64 start_offset = my_qp->ipz_rqueue.current_q_offset;
                /* get pointer next to free WQE */
                wqe_p = ipz_qeit_get_inc(&my_qp->ipz_rqueue);
                if (unlikely(!wqe_p)) {
                        /* too many posted work requests: queue overflow */
-                       if (bad_recv_wr)
-                               *bad_recv_wr = cur_recv_wr;
-                       if (wqe_cnt == 0) {
-                               ret = -ENOMEM;
-                               ehca_err(dev, "Too many posted WQEs "
-                                        "qp_num=%x", my_qp->real_qp_num);
-                       }
+                       ret = -ENOMEM;
+                       ehca_err(dev, "Too many posted WQEs "
+                               "qp_num=%x", my_qp->real_qp_num);
                        goto post_recv_exit0;
                }
                /*
@@ -552,7 +543,7 @@ static int internal_post_recv(struct ehca_qp *my_qp,
                rq_map_idx = start_offset / my_qp->ipz_rqueue.qe_size;
 
                /* write a RECV WQE into the QUEUE */
-               ret = ehca_write_rwqe(&my_qp->ipz_rqueue, wqe_p, cur_recv_wr,
+               ret = ehca_write_rwqe(&my_qp->ipz_rqueue, wqe_p, recv_wr,
                                rq_map_idx);
                /*
                 * if something failed,
@@ -560,22 +551,20 @@ static int internal_post_recv(struct ehca_qp *my_qp,
                 */
                if (unlikely(ret)) {
                        my_qp->ipz_rqueue.current_q_offset = start_offset;
-                       *bad_recv_wr = cur_recv_wr;
-                       if (wqe_cnt == 0) {
-                               ret = -EINVAL;
-                               ehca_err(dev, "Could not write WQE "
-                                        "qp_num=%x", my_qp->real_qp_num);
-                       }
+                       ret = -EINVAL;
+                       ehca_err(dev, "Could not write WQE "
+                               "qp_num=%x", my_qp->real_qp_num);
                        goto post_recv_exit0;
                }
 
                qmap_entry = &my_qp->rq_map.map[rq_map_idx];
-               qmap_entry->app_wr_id = get_app_wr_id(cur_recv_wr->wr_id);
+               qmap_entry->app_wr_id = get_app_wr_id(recv_wr->wr_id);
                qmap_entry->reported = 0;
                qmap_entry->cqe_req = 1;
 
                wqe_cnt++;
-       } /* eof for cur_recv_wr */
+               recv_wr = recv_wr->next;
+       } /* eof for recv_wr */
 
 post_recv_exit0:
        iosync(); /* serialize GAL register access */
@@ -584,6 +573,11 @@ post_recv_exit0:
            ehca_dbg(dev, "ehca_qp=%p qp_num=%x wqe_cnt=%d ret=%i",
                     my_qp, my_qp->real_qp_num, wqe_cnt, ret);
        spin_unlock_irqrestore(&my_qp->spinlock_r, flags);
+
+out:
+       if (ret)
+               *bad_recv_wr = recv_wr;
+
        return ret;
 }
 
@@ -597,6 +591,7 @@ int ehca_post_recv(struct ib_qp *qp,
        if (unlikely(my_qp->state == IB_QPS_RESET)) {
                ehca_err(qp->device, "Invalid QP state  qp_state=%d qpn=%x",
                         my_qp->state, qp->qp_num);
+               *bad_recv_wr = recv_wr;
                return -EINVAL;
        }
 
index 013d1380e77c7bae05ab5b776c9cd0c331b06dd5..d2787fe80304e65facbd6fb90e6df953c009445a 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/delay.h>
 #include <linux/netdevice.h>
 #include <linux/vmalloc.h>
+#include <linux/bitmap.h>
 
 #include "ipath_kernel.h"
 #include "ipath_verbs.h"
@@ -1697,7 +1698,7 @@ void ipath_chg_pioavailkernel(struct ipath_devdata *dd, unsigned start,
                              unsigned len, int avail)
 {
        unsigned long flags;
-       unsigned end, cnt = 0, next;
+       unsigned end, cnt = 0;
 
        /* There are two bits per send buffer (busy and generation) */
        start *= 2;
@@ -1748,12 +1749,7 @@ void ipath_chg_pioavailkernel(struct ipath_devdata *dd, unsigned start,
 
        if (dd->ipath_pioupd_thresh) {
                end = 2 * (dd->ipath_piobcnt2k + dd->ipath_piobcnt4k);
-               next = find_first_bit(dd->ipath_pioavailkernel, end);
-               while (next < end) {
-                       cnt++;
-                       next = find_next_bit(dd->ipath_pioavailkernel, end,
-                                       next + 1);
-               }
+               cnt = bitmap_weight(dd->ipath_pioavailkernel, end);
        }
        spin_unlock_irqrestore(&ipath_pioavail_lock, flags);
 
index 3cb3f47a10b85753cded5f80f019517bf81e3635..e596537ff3533cd53b607eeb5d2e5795cca49c90 100644 (file)
@@ -103,7 +103,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
                props->device_cap_flags |= IB_DEVICE_UD_AV_PORT_ENFORCE;
        if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_IPOIB_CSUM)
                props->device_cap_flags |= IB_DEVICE_UD_IP_CSUM;
-       if (dev->dev->caps.max_gso_sz)
+       if (dev->dev->caps.max_gso_sz && dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BLH)
                props->device_cap_flags |= IB_DEVICE_UD_TSO;
        if (dev->dev->caps.bmme_flags & MLX4_BMME_FLAG_RESERVED_LKEY)
                props->device_cap_flags |= IB_DEVICE_LOCAL_DMA_LKEY;
index 256a00c6aeea4b5531db17e4ff1f5d718f1d9673..989555cee8834dcf670e7d2d83c820d3cf3ef070 100644 (file)
@@ -54,7 +54,8 @@ enum {
        /*
         * Largest possible UD header: send with GRH and immediate data.
         */
-       MLX4_IB_UD_HEADER_SIZE          = 72
+       MLX4_IB_UD_HEADER_SIZE          = 72,
+       MLX4_IB_LSO_HEADER_SPARE        = 128,
 };
 
 struct mlx4_ib_sqp {
@@ -67,7 +68,8 @@ struct mlx4_ib_sqp {
 };
 
 enum {
-       MLX4_IB_MIN_SQ_STRIDE = 6
+       MLX4_IB_MIN_SQ_STRIDE   = 6,
+       MLX4_IB_CACHE_LINE_SIZE = 64,
 };
 
 static const __be32 mlx4_ib_opcode[] = {
@@ -261,7 +263,7 @@ static int send_wqe_overhead(enum ib_qp_type type, u32 flags)
        case IB_QPT_UD:
                return sizeof (struct mlx4_wqe_ctrl_seg) +
                        sizeof (struct mlx4_wqe_datagram_seg) +
-                       ((flags & MLX4_IB_QP_LSO) ? 64 : 0);
+                       ((flags & MLX4_IB_QP_LSO) ? MLX4_IB_LSO_HEADER_SPARE : 0);
        case IB_QPT_UC:
                return sizeof (struct mlx4_wqe_ctrl_seg) +
                        sizeof (struct mlx4_wqe_raddr_seg);
@@ -897,7 +899,6 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
 
        context->flags = cpu_to_be32((to_mlx4_state(new_state) << 28) |
                                     (to_mlx4_st(ibqp->qp_type) << 16));
-       context->flags     |= cpu_to_be32(1 << 8); /* DE? */
 
        if (!(attr_mask & IB_QP_PATH_MIG_STATE))
                context->flags |= cpu_to_be32(MLX4_QP_PM_MIGRATED << 11);
@@ -1467,16 +1468,12 @@ static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ib_sge *sg)
 
 static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_send_wr *wr,
                         struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
-                        __be32 *lso_hdr_sz)
+                        __be32 *lso_hdr_sz, __be32 *blh)
 {
        unsigned halign = ALIGN(sizeof *wqe + wr->wr.ud.hlen, 16);
 
-       /*
-        * This is a temporary limitation and will be removed in
-        * a forthcoming FW release:
-        */
-       if (unlikely(halign > 64))
-               return -EINVAL;
+       if (unlikely(halign > MLX4_IB_CACHE_LINE_SIZE))
+               *blh = cpu_to_be32(1 << 6);
 
        if (unlikely(!(qp->flags & MLX4_IB_QP_LSO) &&
                     wr->num_sge > qp->sq.max_gs - (halign >> 4)))
@@ -1522,6 +1519,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
        __be32 dummy;
        __be32 *lso_wqe;
        __be32 uninitialized_var(lso_hdr_sz);
+       __be32 blh;
        int i;
 
        spin_lock_irqsave(&qp->sq.lock, flags);
@@ -1530,6 +1528,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
 
        for (nreq = 0; wr; ++nreq, wr = wr->next) {
                lso_wqe = &dummy;
+               blh = 0;
 
                if (mlx4_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
                        err = -ENOMEM;
@@ -1616,7 +1615,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
                        size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
 
                        if (wr->opcode == IB_WR_LSO) {
-                               err = build_lso_seg(wqe, wr, qp, &seglen, &lso_hdr_sz);
+                               err = build_lso_seg(wqe, wr, qp, &seglen, &lso_hdr_sz, &blh);
                                if (unlikely(err)) {
                                        *bad_wr = wr;
                                        goto out;
@@ -1687,7 +1686,7 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
                }
 
                ctrl->owner_opcode = mlx4_ib_opcode[wr->opcode] |
-                       (ind & qp->sq.wqe_cnt ? cpu_to_be32(1 << 31) : 0);
+                       (ind & qp->sq.wqe_cnt ? cpu_to_be32(1 << 31) : 0) | blh;
 
                stamp = ind + qp->sq_spare_wqes;
                ind += DIV_ROUND_UP(size * 16, 1U << qp->sq.wqe_shift);
index d449eb6ec78e7d439a78cc824c260be16b32f93f..846dc97cf260658c5edb3edd95b9ccfd0b089edb 100644 (file)
@@ -4,14 +4,13 @@ config INFINIBAND_NES
        select LIBCRC32C
        select INET_LRO
        ---help---
-         This is a low-level driver for NetEffect RDMA enabled
-         Network Interface Cards (RNIC).
+         This is the RDMA Network Interface Card (RNIC) driver for
+         NetEffect Ethernet Cluster Server Adapters.
 
 config INFINIBAND_NES_DEBUG
        bool "Verbose debugging output"
        depends on INFINIBAND_NES
        default n
        ---help---
-         This option causes the NetEffect RNIC driver to produce debug
-         messages.  Select this if you are developing the driver
-         or trying to diagnose a problem.
+         This option enables debug messages from the NetEffect RNIC
+         driver.  Select this if you are diagnosing a problem.
index cbde0cfe27e0a7e3eeb784003317b90e262df6ae..b9d09bafd6c132d6e052fb585e8329145bfa44ae 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -521,7 +521,8 @@ static int __devinit nes_probe(struct pci_dev *pcidev, const struct pci_device_i
        spin_lock_init(&nesdev->indexed_regs_lock);
 
        /* Remap the PCI registers in adapter BAR0 to kernel VA space */
-       mmio_regs = ioremap_nocache(pci_resource_start(pcidev, BAR_0), sizeof(mmio_regs));
+       mmio_regs = ioremap_nocache(pci_resource_start(pcidev, BAR_0),
+                                   pci_resource_len(pcidev, BAR_0));
        if (mmio_regs == NULL) {
                printk(KERN_ERR PFX "Unable to remap BAR0\n");
                ret = -EIO;
index bcc6abc4faffafb9fba5b3076644b568434ecc98..98840564bb2f04870831e22b908a276219b128b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
index 73473db1986361f2a390a30b09c942f74e62ca96..39468c277036d5fde84b01c07d3080867ff79dc6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -52,6 +52,7 @@
 #include <linux/random.h>
 #include <linux/list.h>
 #include <linux/threads.h>
+#include <linux/highmem.h>
 #include <net/arp.h>
 #include <net/neighbour.h>
 #include <net/route.h>
@@ -251,6 +252,33 @@ static int parse_mpa(struct nes_cm_node *cm_node, u8 *buffer, u32 *type,
 
        mpa_frame = (struct ietf_mpa_frame *)buffer;
        cm_node->mpa_frame_size = ntohs(mpa_frame->priv_data_len);
+       /* make sure mpa private data len is less than 512 bytes */
+       if (cm_node->mpa_frame_size > IETF_MAX_PRIV_DATA_LEN) {
+               nes_debug(NES_DBG_CM, "The received Length of Private"
+                       " Data field exceeds 512 octets\n");
+               return -EINVAL;
+       }
+       /*
+        * make sure MPA receiver interoperate with the
+        * received MPA version and MPA key information
+        *
+        */
+       if (mpa_frame->rev != mpa_version) {
+               nes_debug(NES_DBG_CM, "The received mpa version"
+                               " can not be interoperated\n");
+               return -EINVAL;
+       }
+       if (cm_node->state != NES_CM_STATE_MPAREQ_SENT) {
+               if (memcmp(mpa_frame->key, IEFT_MPA_KEY_REQ, IETF_MPA_KEY_SIZE)) {
+                       nes_debug(NES_DBG_CM, "Unexpected MPA Key received \n");
+                       return -EINVAL;
+               }
+       } else {
+               if (memcmp(mpa_frame->key, IEFT_MPA_KEY_REP, IETF_MPA_KEY_SIZE)) {
+                       nes_debug(NES_DBG_CM, "Unexpected MPA Key received \n");
+                       return -EINVAL;
+               }
+       }
 
        if (cm_node->mpa_frame_size + sizeof(struct ietf_mpa_frame) != len) {
                nes_debug(NES_DBG_CM, "The received ietf buffer was not right"
@@ -486,6 +514,8 @@ static void nes_retrans_expired(struct nes_cm_node *cm_node)
                send_reset(cm_node, NULL);
                break;
        default:
+               add_ref_cm_node(cm_node);
+               send_reset(cm_node, NULL);
                create_event(cm_node, NES_CM_EVENT_ABORTED);
        }
 }
@@ -949,6 +979,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
                                reset_entry);
                {
                        struct nes_cm_node *loopback = cm_node->loopbackpartner;
+                       enum nes_cm_node_state old_state;
                        if (NES_CM_STATE_FIN_WAIT1 <= cm_node->state) {
                                rem_ref_cm_node(cm_node->cm_core, cm_node);
                        } else {
@@ -960,11 +991,12 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
                                                         NES_CM_STATE_CLOSED;
                                                WARN_ON(1);
                                        } else {
-                                               cm_node->state =
-                                                       NES_CM_STATE_CLOSED;
-                                               rem_ref_cm_node(
-                                                       cm_node->cm_core,
-                                                       cm_node);
+                                               old_state = cm_node->state;
+                                               cm_node->state = NES_CM_STATE_LISTENER_DESTROYED;
+                                               if (old_state != NES_CM_STATE_MPAREQ_RCVD)
+                                                       rem_ref_cm_node(
+                                                               cm_node->cm_core,
+                                                               cm_node);
                                        }
                                } else {
                                        struct nes_cm_event event;
@@ -980,20 +1012,9 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
                                                         loopback->loc_port;
                                        event.cm_info.cm_id = loopback->cm_id;
                                        cm_event_connect_error(&event);
+                                       cm_node->state = NES_CM_STATE_LISTENER_DESTROYED;
                                        loopback->state = NES_CM_STATE_CLOSED;
 
-                                       event.cm_node = cm_node;
-                                       event.cm_info.rem_addr =
-                                                        cm_node->rem_addr;
-                                       event.cm_info.loc_addr =
-                                                        cm_node->loc_addr;
-                                       event.cm_info.rem_port =
-                                                        cm_node->rem_port;
-                                       event.cm_info.loc_port =
-                                                        cm_node->loc_port;
-                                       event.cm_info.cm_id = cm_node->cm_id;
-                                       cm_event_reset(&event);
-
                                        rem_ref_cm_node(cm_node->cm_core,
                                                         cm_node);
 
@@ -1077,12 +1098,13 @@ static inline int mini_cm_accelerated(struct nes_cm_core *cm_core,
 /**
  * nes_addr_resolve_neigh
  */
-static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip)
+static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpindex)
 {
        struct rtable *rt;
        struct flowi fl;
        struct neighbour *neigh;
-       int rc = -1;
+       int rc = arpindex;
+       struct nes_adapter *nesadapter = nesvnic->nesdev->nesadapter;
 
        memset(&fl, 0, sizeof fl);
        fl.nl_u.ip4_u.daddr = htonl(dst_ip);
@@ -1098,6 +1120,21 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip)
                        nes_debug(NES_DBG_CM, "Neighbor MAC address for 0x%08X"
                                  " is %pM, Gateway is 0x%08X \n", dst_ip,
                                  neigh->ha, ntohl(rt->rt_gateway));
+
+                       if (arpindex >= 0) {
+                               if (!memcmp(nesadapter->arp_table[arpindex].mac_addr,
+                                                       neigh->ha, ETH_ALEN)){
+                                       /* Mac address same as in nes_arp_table */
+                                       neigh_release(neigh);
+                                       ip_rt_put(rt);
+                                       return rc;
+                               }
+
+                               nes_manage_arp_cache(nesvnic->netdev,
+                                               nesadapter->arp_table[arpindex].mac_addr,
+                                               dst_ip, NES_ARP_DELETE);
+                       }
+
                        nes_manage_arp_cache(nesvnic->netdev, neigh->ha,
                                             dst_ip, NES_ARP_ADD);
                        rc = nes_arp_table(nesvnic->nesdev, dst_ip, NULL,
@@ -1113,7 +1150,6 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip)
        return rc;
 }
 
-
 /**
  * make_cm_node - create a new instance of a cm node
  */
@@ -1123,6 +1159,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
 {
        struct nes_cm_node *cm_node;
        struct timespec ts;
+       int oldarpindex = 0;
        int arpindex = 0;
        struct nes_device *nesdev;
        struct nes_adapter *nesadapter;
@@ -1176,17 +1213,18 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
        nesadapter = nesdev->nesadapter;
 
        cm_node->loopbackpartner = NULL;
+
        /* get the mac addr for the remote node */
        if (ipv4_is_loopback(htonl(cm_node->rem_addr)))
                arpindex = nes_arp_table(nesdev, ntohl(nesvnic->local_ipaddr), NULL, NES_ARP_RESOLVE);
-       else
-               arpindex = nes_arp_table(nesdev, cm_node->rem_addr, NULL, NES_ARP_RESOLVE);
+       else {
+               oldarpindex = nes_arp_table(nesdev, cm_node->rem_addr, NULL, NES_ARP_RESOLVE);
+               arpindex = nes_addr_resolve_neigh(nesvnic, cm_info->rem_addr, oldarpindex);
+
+       }
        if (arpindex < 0) {
-               arpindex = nes_addr_resolve_neigh(nesvnic, cm_info->rem_addr);
-               if (arpindex < 0) {
-                       kfree(cm_node);
-                       return NULL;
-               }
+               kfree(cm_node);
+               return NULL;
        }
 
        /* copy the mac addr to node context */
@@ -1333,13 +1371,20 @@ static void handle_fin_pkt(struct nes_cm_node *cm_node)
        case NES_CM_STATE_SYN_RCVD:
        case NES_CM_STATE_SYN_SENT:
        case NES_CM_STATE_ESTABLISHED:
-       case NES_CM_STATE_MPAREQ_SENT:
        case NES_CM_STATE_MPAREJ_RCVD:
                cm_node->tcp_cntxt.rcv_nxt++;
                cleanup_retrans_entry(cm_node);
                cm_node->state = NES_CM_STATE_LAST_ACK;
                send_fin(cm_node, NULL);
                break;
+       case NES_CM_STATE_MPAREQ_SENT:
+               create_event(cm_node, NES_CM_EVENT_ABORTED);
+               cm_node->tcp_cntxt.rcv_nxt++;
+               cleanup_retrans_entry(cm_node);
+               cm_node->state = NES_CM_STATE_CLOSED;
+               add_ref_cm_node(cm_node);
+               send_reset(cm_node, NULL);
+               break;
        case NES_CM_STATE_FIN_WAIT1:
                cm_node->tcp_cntxt.rcv_nxt++;
                cleanup_retrans_entry(cm_node);
@@ -1590,6 +1635,7 @@ static void handle_syn_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
                break;
        case NES_CM_STATE_CLOSED:
                cleanup_retrans_entry(cm_node);
+               add_ref_cm_node(cm_node);
                send_reset(cm_node, skb);
                break;
        case NES_CM_STATE_TSA:
@@ -1641,9 +1687,15 @@ static void handle_synack_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
                passive_open_err(cm_node, skb, 1);
                break;
        case NES_CM_STATE_LISTENING:
+               cm_node->tcp_cntxt.loc_seq_num = ntohl(tcph->ack_seq);
+               cleanup_retrans_entry(cm_node);
+               cm_node->state = NES_CM_STATE_CLOSED;
+               send_reset(cm_node, skb);
+               break;
        case NES_CM_STATE_CLOSED:
                cm_node->tcp_cntxt.loc_seq_num = ntohl(tcph->ack_seq);
                cleanup_retrans_entry(cm_node);
+               add_ref_cm_node(cm_node);
                send_reset(cm_node, skb);
                break;
        case NES_CM_STATE_ESTABLISHED:
@@ -1712,8 +1764,13 @@ static int handle_ack_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
                        dev_kfree_skb_any(skb);
                break;
        case NES_CM_STATE_LISTENING:
+               cleanup_retrans_entry(cm_node);
+               cm_node->state = NES_CM_STATE_CLOSED;
+               send_reset(cm_node, skb);
+               break;
        case NES_CM_STATE_CLOSED:
                cleanup_retrans_entry(cm_node);
+               add_ref_cm_node(cm_node);
                send_reset(cm_node, skb);
                break;
        case NES_CM_STATE_LAST_ACK:
@@ -1974,7 +2031,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
        if (!cm_node)
                return NULL;
        mpa_frame = &cm_node->mpa_frame;
-       strcpy(mpa_frame->key, IEFT_MPA_KEY_REQ);
+       memcpy(mpa_frame->key, IEFT_MPA_KEY_REQ, IETF_MPA_KEY_SIZE);
        mpa_frame->flags = IETF_MPA_FLAGS_CRC;
        mpa_frame->rev =  IETF_MPA_VERSION;
        mpa_frame->priv_data_len = htons(private_data_len);
@@ -2102,30 +2159,39 @@ static int mini_cm_reject(struct nes_cm_core *cm_core,
                        cm_node->state = NES_CM_STATE_CLOSED;
                        rem_ref_cm_node(cm_core, cm_node);
                } else {
-                       ret = send_mpa_reject(cm_node);
-                       if (ret) {
-                               cm_node->state = NES_CM_STATE_CLOSED;
-                               err = send_reset(cm_node, NULL);
-                               if (err)
-                                       WARN_ON(1);
-                       } else
-                               cm_id->add_ref(cm_id);
+                       if (cm_node->state == NES_CM_STATE_LISTENER_DESTROYED) {
+                               rem_ref_cm_node(cm_core, cm_node);
+                       } else {
+                               ret = send_mpa_reject(cm_node);
+                               if (ret) {
+                                       cm_node->state = NES_CM_STATE_CLOSED;
+                                       err = send_reset(cm_node, NULL);
+                                       if (err)
+                                               WARN_ON(1);
+                               } else
+                                       cm_id->add_ref(cm_id);
+                       }
                }
        } else {
                cm_node->cm_id = NULL;
-               event.cm_node = loopback;
-               event.cm_info.rem_addr = loopback->rem_addr;
-               event.cm_info.loc_addr = loopback->loc_addr;
-               event.cm_info.rem_port = loopback->rem_port;
-               event.cm_info.loc_port = loopback->loc_port;
-               event.cm_info.cm_id = loopback->cm_id;
-               cm_event_mpa_reject(&event);
-               rem_ref_cm_node(cm_core, cm_node);
-               loopback->state = NES_CM_STATE_CLOSING;
+               if (cm_node->state == NES_CM_STATE_LISTENER_DESTROYED) {
+                       rem_ref_cm_node(cm_core, cm_node);
+                       rem_ref_cm_node(cm_core, loopback);
+               } else {
+                       event.cm_node = loopback;
+                       event.cm_info.rem_addr = loopback->rem_addr;
+                       event.cm_info.loc_addr = loopback->loc_addr;
+                       event.cm_info.rem_port = loopback->rem_port;
+                       event.cm_info.loc_port = loopback->loc_port;
+                       event.cm_info.cm_id = loopback->cm_id;
+                       cm_event_mpa_reject(&event);
+                       rem_ref_cm_node(cm_core, cm_node);
+                       loopback->state = NES_CM_STATE_CLOSING;
 
-               cm_id = loopback->cm_id;
-               rem_ref_cm_node(cm_core, loopback);
-               cm_id->rem_ref(cm_id);
+                       cm_id = loopback->cm_id;
+                       rem_ref_cm_node(cm_core, loopback);
+                       cm_id->rem_ref(cm_id);
+               }
        }
 
        return ret;
@@ -2164,11 +2230,15 @@ static int mini_cm_close(struct nes_cm_core *cm_core, struct nes_cm_node *cm_nod
        case NES_CM_STATE_CLOSING:
                ret = -1;
                break;
-       case NES_CM_STATE_MPAREJ_RCVD:
        case NES_CM_STATE_LISTENING:
+               cleanup_retrans_entry(cm_node);
+               send_reset(cm_node, NULL);
+               break;
+       case NES_CM_STATE_MPAREJ_RCVD:
        case NES_CM_STATE_UNKNOWN:
        case NES_CM_STATE_INITED:
        case NES_CM_STATE_CLOSED:
+       case NES_CM_STATE_LISTENER_DESTROYED:
                ret = rem_ref_cm_node(cm_core, cm_node);
                break;
        case NES_CM_STATE_TSA:
@@ -2687,8 +2757,6 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
        struct nes_pd *nespd;
        u64 tagged_offset;
 
-
-
        ibqp = nes_get_qp(cm_id->device, conn_param->qpn);
        if (!ibqp)
                return -EINVAL;
@@ -2704,6 +2772,13 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
                "%s\n", cm_node, nesvnic, nesvnic->netdev,
                nesvnic->netdev->name);
 
+       if (NES_CM_STATE_LISTENER_DESTROYED == cm_node->state) {
+               if (cm_node->loopbackpartner)
+                       rem_ref_cm_node(cm_node->cm_core, cm_node->loopbackpartner);
+               rem_ref_cm_node(cm_node->cm_core, cm_node);
+               return -EINVAL;
+       }
+
        /* associate the node with the QP */
        nesqp->cm_node = (void *)cm_node;
        cm_node->nesqp = nesqp;
@@ -2786,6 +2861,10 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
                        cpu_to_le32(conn_param->private_data_len +
                        sizeof(struct ietf_mpa_frame));
                wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = ibmr->lkey;
+               if (nesqp->sq_kmapped) {
+                       nesqp->sq_kmapped = 0;
+                       kunmap(nesqp->page);
+               }
 
                nesqp->nesqp_context->ird_ord_sizes |=
                        cpu_to_le32(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT |
@@ -2929,7 +3008,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
        if (cm_node->mpa_frame_size > MAX_CM_BUFFER)
                return -EINVAL;
 
-       strcpy(&cm_node->mpa_frame.key[0], IEFT_MPA_KEY_REP);
+       memcpy(&cm_node->mpa_frame.key[0], IEFT_MPA_KEY_REP, IETF_MPA_KEY_SIZE);
        if (loopback) {
                memcpy(&loopback->mpa_frame.priv_data, pdata, pdata_len);
                loopback->mpa_frame.priv_data_len = pdata_len;
@@ -2974,6 +3053,9 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
        if (!nesdev)
                return -EINVAL;
 
+       if (!(cm_id->local_addr.sin_port) || !(cm_id->remote_addr.sin_port))
+               return -EINVAL;
+
        nes_debug(NES_DBG_CM, "QP%u, current IP = 0x%08X, Destination IP = "
                "0x%08X:0x%04X, local = 0x%08X:0x%04X.\n", nesqp->hwqp.qp_id,
                ntohl(nesvnic->local_ipaddr),
@@ -3251,6 +3333,11 @@ static void cm_event_connected(struct nes_cm_event *event)
                wqe->wqe_words[NES_IWARP_SQ_WQE_LENGTH0_IDX] = 0;
                wqe->wqe_words[NES_IWARP_SQ_WQE_STAG0_IDX] = 0;
 
+               if (nesqp->sq_kmapped) {
+                       nesqp->sq_kmapped = 0;
+                       kunmap(nesqp->page);
+               }
+
                /* use the reserved spot on the WQ for the extra first WQE */
                nesqp->nesqp_context->ird_ord_sizes &=
                        cpu_to_le32(~(NES_QPCONTEXT_ORDIRD_LSMM_PRESENT |
@@ -3346,7 +3433,7 @@ static void cm_event_connect_error(struct nes_cm_event *event)
        nesqp->cm_id = NULL;
        cm_id->provider_data = NULL;
        cm_event.event = IW_CM_EVENT_CONNECT_REPLY;
-       cm_event.status = IW_CM_EVENT_STATUS_REJECTED;
+       cm_event.status = -ECONNRESET;
        cm_event.provider_data = cm_id->provider_data;
        cm_event.local_addr = cm_id->local_addr;
        cm_event.remote_addr = cm_id->remote_addr;
@@ -3390,6 +3477,8 @@ static void cm_event_reset(struct nes_cm_event *event)
 
        nes_debug(NES_DBG_CM, "%p - cm_id = %p\n", event->cm_node, cm_id);
        nesqp = cm_id->provider_data;
+       if (!nesqp)
+               return;
 
        nesqp->cm_id = NULL;
        /* cm_id->provider_data = NULL; */
@@ -3401,8 +3490,8 @@ static void cm_event_reset(struct nes_cm_event *event)
        cm_event.private_data = NULL;
        cm_event.private_data_len = 0;
 
-       ret = cm_id->event_handler(cm_id, &cm_event);
        cm_id->add_ref(cm_id);
+       ret = cm_id->event_handler(cm_id, &cm_event);
        atomic_inc(&cm_closes);
        cm_event.event = IW_CM_EVENT_CLOSE;
        cm_event.status = IW_CM_EVENT_STATUS_OK;
index 90e8e4d8a5cef8522039c252f300530da6a15957..d9825fda70a1359226c2fe2f1a766d15bb92bf72 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -47,6 +47,8 @@
 #define IEFT_MPA_KEY_REP  "MPA ID Rep Frame"
 #define IETF_MPA_KEY_SIZE 16
 #define IETF_MPA_VERSION  1
+#define IETF_MAX_PRIV_DATA_LEN 512
+#define IETF_MPA_FRAME_SIZE     20
 
 enum ietf_mpa_flags {
        IETF_MPA_FLAGS_MARKERS = 0x80,  /* receive Markers */
@@ -169,7 +171,7 @@ struct nes_timer_entry {
 
 #define NES_CM_DEF_SEQ2      0x18ed5740
 #define NES_CM_DEF_LOCAL_ID2 0xb807
-#define        MAX_CM_BUFFER   512
+#define        MAX_CM_BUFFER   (IETF_MPA_FRAME_SIZE + IETF_MAX_PRIV_DATA_LEN)
 
 
 typedef u32 nes_addr_t;
@@ -198,6 +200,7 @@ enum nes_cm_node_state {
        NES_CM_STATE_TIME_WAIT,
        NES_CM_STATE_LAST_ACK,
        NES_CM_STATE_CLOSING,
+       NES_CM_STATE_LISTENER_DESTROYED,
        NES_CM_STATE_CLOSED
 };
 
index 0fb8d81d9a621a7050285a28e74f4fb16ddc8bc3..b4393a16099dc69df36fa5f9f2f19d42e2b33d4f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
index 3512d6de3019806cca3b189e32734d3e039f2cfb..b1c2cbb88f0964a8c4b9fd0f613306b8d9c9d576 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -424,8 +424,9 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) {
 
        nesadapter->base_pd = 1;
 
-       nesadapter->device_cap_flags =
-               IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW;
+       nesadapter->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY |
+                                      IB_DEVICE_MEM_WINDOW |
+                                      IB_DEVICE_MEM_MGT_EXTENSIONS;
 
        nesadapter->allocated_qps = (unsigned long *)&(((unsigned char *)nesadapter)
                        [(sizeof(struct nes_adapter)+(sizeof(unsigned long)-1))&(~(sizeof(unsigned long)-1))]);
@@ -436,11 +437,12 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) {
        nesadapter->qp_table = (struct nes_qp **)(&nesadapter->allocated_arps[BITS_TO_LONGS(arp_table_size)]);
 
 
-       /* mark the usual suspect QPs and CQs as in use */
+       /* mark the usual suspect QPs, MR and CQs as in use */
        for (u32temp = 0; u32temp < NES_FIRST_QPN; u32temp++) {
                set_bit(u32temp, nesadapter->allocated_qps);
                set_bit(u32temp, nesadapter->allocated_cqs);
        }
+       set_bit(0, nesadapter->allocated_mrs);
 
        for (u32temp = 0; u32temp < 20; u32temp++)
                set_bit(u32temp, nesadapter->allocated_pds);
@@ -481,7 +483,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) {
        nesadapter->max_irrq_wr = (u32temp >> 16) & 3;
 
        nesadapter->max_sge = 4;
-       nesadapter->max_cqe = 32767;
+       nesadapter->max_cqe = 32766;
 
        if (nes_read_eeprom_values(nesdev, nesadapter)) {
                printk(KERN_ERR PFX "Unable to read EEPROM data.\n");
@@ -1355,6 +1357,8 @@ int nes_init_phy(struct nes_device *nesdev)
        }
        if ((phy_type == NES_PHY_TYPE_ARGUS) ||
            (phy_type == NES_PHY_TYPE_SFP_D)) {
+               u32 first_time = 1;
+
                /* Check firmware heartbeat */
                nes_read_10G_phy_reg(nesdev, phy_index, 0x3, 0xd7ee);
                temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
@@ -1362,8 +1366,13 @@ int nes_init_phy(struct nes_device *nesdev)
                nes_read_10G_phy_reg(nesdev, phy_index, 0x3, 0xd7ee);
                temp_phy_data2 = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
 
-               if (temp_phy_data != temp_phy_data2)
-                       return 0;
+               if (temp_phy_data != temp_phy_data2) {
+                       nes_read_10G_phy_reg(nesdev, phy_index, 0x3, 0xd7fd);
+                       temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
+                       if ((temp_phy_data & 0xff) > 0x20)
+                               return 0;
+                       printk(PFX "Reinitializing PHY\n");
+               }
 
                /* no heartbeat, configure the PHY */
                nes_write_10G_phy_reg(nesdev, phy_index, 0x1, 0x0000, 0x8000);
@@ -1399,7 +1408,7 @@ int nes_init_phy(struct nes_device *nesdev)
                temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
                do {
                        if (counter++ > 150) {
-                               nes_debug(NES_DBG_PHY, "No PHY heartbeat\n");
+                               printk(PFX "No PHY heartbeat\n");
                                break;
                        }
                        mdelay(1);
@@ -1413,11 +1422,20 @@ int nes_init_phy(struct nes_device *nesdev)
                        nes_read_10G_phy_reg(nesdev, phy_index, 0x3, 0xd7fd);
                        temp_phy_data = (u16)nes_read_indexed(nesdev, NES_IDX_MAC_MDIO_CONTROL);
                        if (counter++ > 300) {
-                               nes_debug(NES_DBG_PHY, "PHY did not track\n");
-                               break;
+                               if (((temp_phy_data & 0xff) == 0x0) && first_time) {
+                                       first_time = 0;
+                                       counter = 0;
+                                       /* reset AMCC PHY and try again */
+                                       nes_write_10G_phy_reg(nesdev, phy_index, 0x3, 0xe854, 0x00c0);
+                                       nes_write_10G_phy_reg(nesdev, phy_index, 0x3, 0xe854, 0x0040);
+                                       continue;
+                               } else {
+                                       printk(PFX "PHY did not track\n");
+                                       break;
+                               }
                        }
                        mdelay(10);
-               } while (((temp_phy_data & 0xff) != 0x50) && ((temp_phy_data & 0xff) != 0x70));
+               } while ((temp_phy_data & 0xff) < 0x30);
 
                /* setup signal integrity */
                nes_write_10G_phy_reg(nesdev, phy_index, 0x1, 0xd003, 0x0000);
index f28a41ba9fa14378bf9f68c147e74976e0c1c3f4..084be0ee689bd61ccd4f6f0c0cbc2b29b333a842 100644 (file)
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+* Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
@@ -546,11 +546,23 @@ enum nes_iwarp_sq_fmr_wqe_word_idx {
        NES_IWARP_SQ_FMR_WQE_PBL_LENGTH_IDX = 14,
 };
 
+enum nes_iwarp_sq_fmr_opcodes {
+       NES_IWARP_SQ_FMR_WQE_ZERO_BASED                 = (1<<6),
+       NES_IWARP_SQ_FMR_WQE_PAGE_SIZE_4K               = (0<<7),
+       NES_IWARP_SQ_FMR_WQE_PAGE_SIZE_2M               = (1<<7),
+       NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_LOCAL_READ   = (1<<16),
+       NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_LOCAL_WRITE  = (1<<17),
+       NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_REMOTE_READ  = (1<<18),
+       NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_REMOTE_WRITE = (1<<19),
+       NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_WINDOW_BIND  = (1<<20),
+};
+
+#define NES_IWARP_SQ_FMR_WQE_MR_LENGTH_HIGH_MASK       0xFF;
+
 enum nes_iwarp_sq_locinv_wqe_word_idx {
        NES_IWARP_SQ_LOCINV_WQE_INV_STAG_IDX = 6,
 };
 
-
 enum nes_iwarp_rq_wqe_word_idx {
        NES_IWARP_RQ_WQE_TOTAL_PAYLOAD_IDX = 1,
        NES_IWARP_RQ_WQE_COMP_CTX_LOW_IDX = 2,
@@ -1153,6 +1165,19 @@ struct nes_pbl {
        /* TODO: need to add list for two level tables */
 };
 
+#define NES_4K_PBL_CHUNK_SIZE  4096
+
+struct nes_fast_mr_wqe_pbl {
+       u64             *kva;
+       dma_addr_t      paddr;
+};
+
+struct nes_ib_fast_reg_page_list {
+       struct ib_fast_reg_page_list    ibfrpl;
+       struct nes_fast_mr_wqe_pbl      nes_wqe_pbl;
+       u64                             pbl;
+};
+
 struct nes_listener {
        struct work_struct      work;
        struct workqueue_struct *wq;
index de18fdfdadf2d0280a20f4b3af0b864768c3b275..ab11027801862c59359f4d6129cfb54ac98bb768 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
index cc90c14b49ebe7417612d6181ad69510a2cf7109..71e133ab209b3c30522681eb10ba163d112f0190 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Cisco Systems.  All rights reserved.
  * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
@@ -86,6 +86,7 @@ enum iwnes_memreg_type {
        IWNES_MEMREG_TYPE_CQ = 0x0002,
        IWNES_MEMREG_TYPE_MW = 0x0003,
        IWNES_MEMREG_TYPE_FMR = 0x0004,
+       IWNES_MEMREG_TYPE_FMEM = 0x0005,
 };
 
 struct nes_mem_reg_req {
index 9687c397ce1ac7480e36692a022d358258ae3c51..729d525c5b70514eca4e6d3b0f1dd88f1e46b953 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
index a680c42d6e8cb3b72a33c5a6c707d15cc294b202..64d3136e3747aa9fd81afe2e044c69dab2e1f34f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -275,342 +275,236 @@ static int nes_bind_mw(struct ib_qp *ibqp, struct ib_mw *ibmw,
 }
 
 
-/**
- * nes_alloc_fmr
+/*
+ * nes_alloc_fast_mr
  */
-static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd,
-               int ibmr_access_flags,
-               struct ib_fmr_attr *ibfmr_attr)
+static int alloc_fast_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
+                            u32 stag, u32 page_count)
 {
-       unsigned long flags;
-       struct nes_pd *nespd = to_nespd(ibpd);
-       struct nes_vnic *nesvnic = to_nesvnic(ibpd->device);
-       struct nes_device *nesdev = nesvnic->nesdev;
-       struct nes_adapter *nesadapter = nesdev->nesadapter;
-       struct nes_fmr *nesfmr;
-       struct nes_cqp_request *cqp_request;
        struct nes_hw_cqp_wqe *cqp_wqe;
+       struct nes_cqp_request *cqp_request;
+       unsigned long flags;
        int ret;
-       u32 stag;
-       u32 stag_index = 0;
-       u32 next_stag_index = 0;
-       u32 driver_key = 0;
+       struct nes_adapter *nesadapter = nesdev->nesadapter;
        u32 opcode = 0;
-       u8 stag_key = 0;
-       int i=0;
-       struct nes_vpbl vpbl;
-
-       get_random_bytes(&next_stag_index, sizeof(next_stag_index));
-       stag_key = (u8)next_stag_index;
-
-       driver_key = 0;
-
-       next_stag_index >>= 8;
-       next_stag_index %= nesadapter->max_mr;
-
-       ret = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs,
-                       nesadapter->max_mr, &stag_index, &next_stag_index);
-       if (ret) {
-               goto failed_resource_alloc;
-       }
-
-       nesfmr = kzalloc(sizeof(*nesfmr), GFP_KERNEL);
-       if (!nesfmr) {
-               ret = -ENOMEM;
-               goto failed_fmr_alloc;
-       }
-
-       nesfmr->nesmr.mode = IWNES_MEMREG_TYPE_FMR;
-       if (ibfmr_attr->max_pages == 1) {
-               /* use zero length PBL */
-               nesfmr->nesmr.pbl_4k = 0;
-               nesfmr->nesmr.pbls_used = 0;
-       } else if (ibfmr_attr->max_pages <= 32) {
-               /* use PBL 256 */
-               nesfmr->nesmr.pbl_4k = 0;
-               nesfmr->nesmr.pbls_used = 1;
-       } else if (ibfmr_attr->max_pages <= 512) {
-               /* use 4K PBLs */
-               nesfmr->nesmr.pbl_4k = 1;
-               nesfmr->nesmr.pbls_used = 1;
-       } else {
-               /* use two level 4K PBLs */
-               /* add support for two level 256B PBLs */
-               nesfmr->nesmr.pbl_4k = 1;
-               nesfmr->nesmr.pbls_used = 1 + (ibfmr_attr->max_pages >> 9) +
-                               ((ibfmr_attr->max_pages & 511) ? 1 : 0);
-       }
-       /* Register the region with the adapter */
-       spin_lock_irqsave(&nesadapter->pbl_lock, flags);
-
-       /* track PBL resources */
-       if (nesfmr->nesmr.pbls_used != 0) {
-               if (nesfmr->nesmr.pbl_4k) {
-                       if (nesfmr->nesmr.pbls_used > nesadapter->free_4kpbl) {
-                               spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
-                               ret = -ENOMEM;
-                               goto failed_vpbl_avail;
-                       } else {
-                               nesadapter->free_4kpbl -= nesfmr->nesmr.pbls_used;
-                       }
-               } else {
-                       if (nesfmr->nesmr.pbls_used > nesadapter->free_256pbl) {
-                               spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
-                               ret = -ENOMEM;
-                               goto failed_vpbl_avail;
-                       } else {
-                               nesadapter->free_256pbl -= nesfmr->nesmr.pbls_used;
-                       }
-               }
-       }
-
-       /* one level pbl */
-       if (nesfmr->nesmr.pbls_used == 0) {
-               nesfmr->root_vpbl.pbl_vbase = NULL;
-               nes_debug(NES_DBG_MR,  "zero level pbl \n");
-       } else if (nesfmr->nesmr.pbls_used == 1) {
-               /* can change it to kmalloc & dma_map_single */
-               nesfmr->root_vpbl.pbl_vbase = pci_alloc_consistent(nesdev->pcidev, 4096,
-                               &nesfmr->root_vpbl.pbl_pbase);
-               if (!nesfmr->root_vpbl.pbl_vbase) {
-                       spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
-                       ret = -ENOMEM;
-                       goto failed_vpbl_alloc;
-               }
-               nesfmr->leaf_pbl_cnt = 0;
-               nes_debug(NES_DBG_MR, "one level pbl, root_vpbl.pbl_vbase=%p \n",
-                               nesfmr->root_vpbl.pbl_vbase);
-       }
-       /* two level pbl */
-       else {
-               nesfmr->root_vpbl.pbl_vbase = pci_alloc_consistent(nesdev->pcidev, 8192,
-                               &nesfmr->root_vpbl.pbl_pbase);
-               if (!nesfmr->root_vpbl.pbl_vbase) {
-                       spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
-                       ret = -ENOMEM;
-                       goto failed_vpbl_alloc;
-               }
-
-               nesfmr->leaf_pbl_cnt = nesfmr->nesmr.pbls_used-1;
-               nesfmr->root_vpbl.leaf_vpbl = kzalloc(sizeof(*nesfmr->root_vpbl.leaf_vpbl)*1024, GFP_ATOMIC);
-               if (!nesfmr->root_vpbl.leaf_vpbl) {
-                       spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
-                       ret = -ENOMEM;
-                       goto failed_leaf_vpbl_alloc;
-               }
-
-               nes_debug(NES_DBG_MR, "two level pbl, root_vpbl.pbl_vbase=%p"
-                               " leaf_pbl_cnt=%d root_vpbl.leaf_vpbl=%p\n",
-                               nesfmr->root_vpbl.pbl_vbase, nesfmr->leaf_pbl_cnt, nesfmr->root_vpbl.leaf_vpbl);
-
-               for (i=0; i<nesfmr->leaf_pbl_cnt; i++)
-                       nesfmr->root_vpbl.leaf_vpbl[i].pbl_vbase = NULL;
-
-               for (i=0; i<nesfmr->leaf_pbl_cnt; i++) {
-                       vpbl.pbl_vbase = pci_alloc_consistent(nesdev->pcidev, 4096,
-                                       &vpbl.pbl_pbase);
-
-                       if (!vpbl.pbl_vbase) {
-                               ret = -ENOMEM;
-                               spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
-                               goto failed_leaf_vpbl_pages_alloc;
-                       }
-
-                       nesfmr->root_vpbl.pbl_vbase[i].pa_low = cpu_to_le32((u32)vpbl.pbl_pbase);
-                       nesfmr->root_vpbl.pbl_vbase[i].pa_high = cpu_to_le32((u32)((((u64)vpbl.pbl_pbase)>>32)));
-                       nesfmr->root_vpbl.leaf_vpbl[i] = vpbl;
-
-                       nes_debug(NES_DBG_MR, "pbase_low=0x%x, pbase_high=0x%x, vpbl=%p\n",
-                                       nesfmr->root_vpbl.pbl_vbase[i].pa_low,
-                                       nesfmr->root_vpbl.pbl_vbase[i].pa_high,
-                                       &nesfmr->root_vpbl.leaf_vpbl[i]);
-               }
-       }
-       nesfmr->ib_qp = NULL;
-       nesfmr->access_rights =0;
+       u16 major_code;
+       u64 region_length = page_count * PAGE_SIZE;
 
-       stag = stag_index << 8;
-       stag |= driver_key;
-       stag += (u32)stag_key;
 
-       spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
        cqp_request = nes_get_cqp_request(nesdev);
        if (cqp_request == NULL) {
                nes_debug(NES_DBG_MR, "Failed to get a cqp_request.\n");
-               ret = -ENOMEM;
-               goto failed_leaf_vpbl_pages_alloc;
+               return -ENOMEM;
        }
+       nes_debug(NES_DBG_MR, "alloc_fast_reg_mr: page_count = %d, "
+                             "region_length = %llu\n",
+                             page_count, region_length);
        cqp_request->waiting = 1;
        cqp_wqe = &cqp_request->cqp_wqe;
 
-       nes_debug(NES_DBG_MR, "Registering STag 0x%08X, index = 0x%08X\n",
-                       stag, stag_index);
-
-       opcode = NES_CQP_ALLOCATE_STAG | NES_CQP_STAG_VA_TO | NES_CQP_STAG_MR;
-
-       if (nesfmr->nesmr.pbl_4k == 1)
-               opcode |= NES_CQP_STAG_PBL_BLK_SIZE;
-
-       if (ibmr_access_flags & IB_ACCESS_REMOTE_WRITE) {
-               opcode |= NES_CQP_STAG_RIGHTS_REMOTE_WRITE |
-                               NES_CQP_STAG_RIGHTS_LOCAL_WRITE | NES_CQP_STAG_REM_ACC_EN;
-               nesfmr->access_rights |=
-                               NES_CQP_STAG_RIGHTS_REMOTE_WRITE | NES_CQP_STAG_RIGHTS_LOCAL_WRITE |
-                               NES_CQP_STAG_REM_ACC_EN;
+       spin_lock_irqsave(&nesadapter->pbl_lock, flags);
+       if (nesadapter->free_4kpbl > 0) {
+               nesadapter->free_4kpbl--;
+               spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
+       } else {
+               /* No 4kpbl's available: */
+               spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
+               nes_debug(NES_DBG_MR, "Out of Pbls\n");
+               nes_free_cqp_request(nesdev, cqp_request);
+               return -ENOMEM;
        }
 
-       if (ibmr_access_flags & IB_ACCESS_REMOTE_READ) {
-               opcode |= NES_CQP_STAG_RIGHTS_REMOTE_READ |
-                               NES_CQP_STAG_RIGHTS_LOCAL_READ | NES_CQP_STAG_REM_ACC_EN;
-               nesfmr->access_rights |=
-                               NES_CQP_STAG_RIGHTS_REMOTE_READ | NES_CQP_STAG_RIGHTS_LOCAL_READ |
-                               NES_CQP_STAG_REM_ACC_EN;
-       }
+       opcode = NES_CQP_ALLOCATE_STAG | NES_CQP_STAG_MR |
+                NES_CQP_STAG_PBL_BLK_SIZE | NES_CQP_STAG_VA_TO |
+                NES_CQP_STAG_REM_ACC_EN;
+       /*
+        * The current OFED API does not support the zero based TO option.
+        * If added then need to changed the NES_CQP_STAG_VA* option.  Also,
+        * the API does not support that ability to have the MR set for local
+        * access only when created and not allow the SQ op to override. Given
+        * this the remote enable must be set here.
+        */
 
        nes_fill_init_cqp_wqe(cqp_wqe, nesdev);
        set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_OPCODE_IDX, opcode);
-       set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_LEN_HIGH_PD_IDX, (nespd->pd_id & 0x00007fff));
-       set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, stag);
+       set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PBL_BLK_COUNT_IDX, 1);
 
-       cqp_wqe->wqe_words[NES_CQP_STAG_WQE_PBL_BLK_COUNT_IDX] =
-                       cpu_to_le32((nesfmr->nesmr.pbls_used>1) ?
-                       (nesfmr->nesmr.pbls_used-1) : nesfmr->nesmr.pbls_used);
+       cqp_wqe->wqe_words[NES_CQP_STAG_WQE_LEN_HIGH_PD_IDX] =
+                       cpu_to_le32((u32)(region_length >> 8) & 0xff000000);
+       cqp_wqe->wqe_words[NES_CQP_STAG_WQE_LEN_HIGH_PD_IDX] |=
+                       cpu_to_le32(nespd->pd_id & 0x00007fff);
+
+       set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, stag);
+       set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_VA_LOW_IDX, 0);
+       set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_LEN_LOW_IDX, 0);
+       set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PA_LOW_IDX, 0);
+       set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PBL_LEN_IDX, (page_count * 8));
+       cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX] |= cpu_to_le32(NES_CQP_STAG_PBL_BLK_SIZE);
+       barrier();
 
        atomic_set(&cqp_request->refcount, 2);
        nes_post_cqp_request(nesdev, cqp_request);
 
        /* Wait for CQP */
-       ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0),
-                       NES_EVENT_TIMEOUT);
-       nes_debug(NES_DBG_MR, "Register STag 0x%08X completed, wait_event_timeout ret = %u,"
-                       " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
-                       stag, ret, cqp_request->major_code, cqp_request->minor_code);
-
-       if ((!ret) || (cqp_request->major_code)) {
-               nes_put_cqp_request(nesdev, cqp_request);
-               ret = (!ret) ? -ETIME : -EIO;
-               goto failed_leaf_vpbl_pages_alloc;
-       }
+       ret = wait_event_timeout(cqp_request->waitq,
+                                (0 != cqp_request->request_done),
+                                NES_EVENT_TIMEOUT);
+
+       nes_debug(NES_DBG_MR, "Allocate STag 0x%08X completed, "
+                 "wait_event_timeout ret = %u, CQP Major:Minor codes = "
+                 "0x%04X:0x%04X.\n", stag, ret, cqp_request->major_code,
+                 cqp_request->minor_code);
+       major_code = cqp_request->major_code;
        nes_put_cqp_request(nesdev, cqp_request);
-       nesfmr->nesmr.ibfmr.lkey = stag;
-       nesfmr->nesmr.ibfmr.rkey = stag;
-       nesfmr->attr = *ibfmr_attr;
-
-       return &nesfmr->nesmr.ibfmr;
-
-       failed_leaf_vpbl_pages_alloc:
-       /* unroll all allocated pages */
-       for (i=0; i<nesfmr->leaf_pbl_cnt; i++) {
-               if (nesfmr->root_vpbl.leaf_vpbl[i].pbl_vbase) {
-                       pci_free_consistent(nesdev->pcidev, 4096, nesfmr->root_vpbl.leaf_vpbl[i].pbl_vbase,
-                                       nesfmr->root_vpbl.leaf_vpbl[i].pbl_pbase);
-               }
-       }
-       if (nesfmr->root_vpbl.leaf_vpbl)
-               kfree(nesfmr->root_vpbl.leaf_vpbl);
 
-       failed_leaf_vpbl_alloc:
-       if (nesfmr->leaf_pbl_cnt == 0) {
-               if (nesfmr->root_vpbl.pbl_vbase)
-                       pci_free_consistent(nesdev->pcidev, 4096, nesfmr->root_vpbl.pbl_vbase,
-                                       nesfmr->root_vpbl.pbl_pbase);
-       } else
-               pci_free_consistent(nesdev->pcidev, 8192, nesfmr->root_vpbl.pbl_vbase,
-                               nesfmr->root_vpbl.pbl_pbase);
-
-       failed_vpbl_alloc:
-       if (nesfmr->nesmr.pbls_used != 0) {
+       if (!ret || major_code) {
                spin_lock_irqsave(&nesadapter->pbl_lock, flags);
-               if (nesfmr->nesmr.pbl_4k)
-                       nesadapter->free_4kpbl += nesfmr->nesmr.pbls_used;
-               else
-                       nesadapter->free_256pbl += nesfmr->nesmr.pbls_used;
+               nesadapter->free_4kpbl++;
                spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
        }
 
-failed_vpbl_avail:
-       kfree(nesfmr);
-
-       failed_fmr_alloc:
-       nes_free_resource(nesadapter, nesadapter->allocated_mrs, stag_index);
-
-       failed_resource_alloc:
-       return ERR_PTR(ret);
+       if (!ret)
+               return -ETIME;
+       else if (major_code)
+               return -EIO;
+       return 0;
 }
 
-
-/**
- * nes_dealloc_fmr
+/*
+ * nes_alloc_fast_reg_mr
  */
-static int nes_dealloc_fmr(struct ib_fmr *ibfmr)
+struct ib_mr *nes_alloc_fast_reg_mr(struct ib_pd *ibpd, int max_page_list_len)
 {
-       unsigned long flags;
-       struct nes_mr *nesmr = to_nesmr_from_ibfmr(ibfmr);
-       struct nes_fmr *nesfmr = to_nesfmr(nesmr);
-       struct nes_vnic *nesvnic = to_nesvnic(ibfmr->device);
+       struct nes_pd *nespd = to_nespd(ibpd);
+       struct nes_vnic *nesvnic = to_nesvnic(ibpd->device);
        struct nes_device *nesdev = nesvnic->nesdev;
        struct nes_adapter *nesadapter = nesdev->nesadapter;
-       int i = 0;
-       int rc;
 
-       /* free the resources */
-       if (nesfmr->leaf_pbl_cnt == 0) {
-               /* single PBL case */
-               if (nesfmr->root_vpbl.pbl_vbase)
-                       pci_free_consistent(nesdev->pcidev, 4096, nesfmr->root_vpbl.pbl_vbase,
-                                       nesfmr->root_vpbl.pbl_pbase);
-       } else {
-               for (i = 0; i < nesfmr->leaf_pbl_cnt; i++) {
-                       pci_free_consistent(nesdev->pcidev, 4096, nesfmr->root_vpbl.leaf_vpbl[i].pbl_vbase,
-                                       nesfmr->root_vpbl.leaf_vpbl[i].pbl_pbase);
-               }
-               kfree(nesfmr->root_vpbl.leaf_vpbl);
-               pci_free_consistent(nesdev->pcidev, 8192, nesfmr->root_vpbl.pbl_vbase,
-                               nesfmr->root_vpbl.pbl_pbase);
-       }
-       nesmr->ibmw.device = ibfmr->device;
-       nesmr->ibmw.pd = ibfmr->pd;
-       nesmr->ibmw.rkey = ibfmr->rkey;
-       nesmr->ibmw.uobject = NULL;
+       u32 next_stag_index;
+       u8 stag_key = 0;
+       u32 driver_key = 0;
+       int err = 0;
+       u32 stag_index = 0;
+       struct nes_mr *nesmr;
+       u32 stag;
+       int ret;
+       struct ib_mr *ibmr;
+/*
+ * Note:  Set to always use a fixed length single page entry PBL.  This is to allow
+ *      for the fast_reg_mr operation to always know the size of the PBL.
+ */
+       if (max_page_list_len > (NES_4K_PBL_CHUNK_SIZE / sizeof(u64)))
+               return ERR_PTR(-E2BIG);
 
-       rc = nes_dealloc_mw(&nesmr->ibmw);
+       get_random_bytes(&next_stag_index, sizeof(next_stag_index));
+       stag_key = (u8)next_stag_index;
+       next_stag_index >>= 8;
+       next_stag_index %= nesadapter->max_mr;
 
-       if ((rc == 0) && (nesfmr->nesmr.pbls_used != 0)) {
-               spin_lock_irqsave(&nesadapter->pbl_lock, flags);
-               if (nesfmr->nesmr.pbl_4k) {
-                       nesadapter->free_4kpbl += nesfmr->nesmr.pbls_used;
-                       WARN_ON(nesadapter->free_4kpbl > nesadapter->max_4kpbl);
-               } else {
-                       nesadapter->free_256pbl += nesfmr->nesmr.pbls_used;
-                       WARN_ON(nesadapter->free_256pbl > nesadapter->max_256pbl);
-               }
-               spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
+       err = nes_alloc_resource(nesadapter, nesadapter->allocated_mrs,
+                                nesadapter->max_mr, &stag_index,
+                                &next_stag_index);
+       if (err)
+               return ERR_PTR(err);
+
+       nesmr = kzalloc(sizeof(*nesmr), GFP_KERNEL);
+       if (!nesmr) {
+               nes_free_resource(nesadapter, nesadapter->allocated_mrs, stag_index);
+               return ERR_PTR(-ENOMEM);
        }
 
-       return rc;
-}
+       stag = stag_index << 8;
+       stag |= driver_key;
+       stag += (u32)stag_key;
 
+       nes_debug(NES_DBG_MR, "Allocating STag 0x%08X index = 0x%08X\n",
+                 stag, stag_index);
 
-/**
- * nes_map_phys_fmr
+       ret = alloc_fast_reg_mr(nesdev, nespd, stag, max_page_list_len);
+
+       if (ret == 0) {
+               nesmr->ibmr.rkey = stag;
+               nesmr->ibmr.lkey = stag;
+               nesmr->mode = IWNES_MEMREG_TYPE_FMEM;
+               ibmr = &nesmr->ibmr;
+       } else {
+               kfree(nesmr);
+               nes_free_resource(nesadapter, nesadapter->allocated_mrs, stag_index);
+               ibmr = ERR_PTR(-ENOMEM);
+       }
+       return ibmr;
+}
+
+/*
+ * nes_alloc_fast_reg_page_list
  */
-static int nes_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
-               int list_len, u64 iova)
+static struct ib_fast_reg_page_list *nes_alloc_fast_reg_page_list(
+                                                       struct ib_device *ibdev,
+                                                       int page_list_len)
 {
-       return 0;
-}
+       struct nes_vnic *nesvnic = to_nesvnic(ibdev);
+       struct nes_device *nesdev = nesvnic->nesdev;
+       struct ib_fast_reg_page_list *pifrpl;
+       struct nes_ib_fast_reg_page_list *pnesfrpl;
 
+       if (page_list_len > (NES_4K_PBL_CHUNK_SIZE / sizeof(u64)))
+               return ERR_PTR(-E2BIG);
+       /*
+        * Allocate the ib_fast_reg_page_list structure, the
+        * nes_fast_bpl structure, and the PLB table.
+        */
+       pnesfrpl = kmalloc(sizeof(struct nes_ib_fast_reg_page_list) +
+                          page_list_len * sizeof(u64), GFP_KERNEL);
+
+       if (!pnesfrpl)
+               return ERR_PTR(-ENOMEM);
 
-/**
- * nes_unmap_frm
+       pifrpl = &pnesfrpl->ibfrpl;
+       pifrpl->page_list = &pnesfrpl->pbl;
+       pifrpl->max_page_list_len = page_list_len;
+       /*
+        * Allocate the WQE PBL
+        */
+       pnesfrpl->nes_wqe_pbl.kva = pci_alloc_consistent(nesdev->pcidev,
+                                                        page_list_len * sizeof(u64),
+                                                        &pnesfrpl->nes_wqe_pbl.paddr);
+
+       if (!pnesfrpl->nes_wqe_pbl.kva) {
+               kfree(pnesfrpl);
+               return ERR_PTR(-ENOMEM);
+       }
+       nes_debug(NES_DBG_MR, "nes_alloc_fast_reg_pbl: nes_frpl = %p, "
+                 "ibfrpl = %p, ibfrpl.page_list = %p, pbl.kva = %p, "
+                 "pbl.paddr= %p\n", pnesfrpl, &pnesfrpl->ibfrpl,
+                 pnesfrpl->ibfrpl.page_list, pnesfrpl->nes_wqe_pbl.kva,
+                 (void *)pnesfrpl->nes_wqe_pbl.paddr);
+
+       return pifrpl;
+}
+
+/*
+ * nes_free_fast_reg_page_list
  */
-static int nes_unmap_fmr(struct list_head *ibfmr_list)
+static void nes_free_fast_reg_page_list(struct ib_fast_reg_page_list *pifrpl)
 {
-       return 0;
+       struct nes_vnic *nesvnic = to_nesvnic(pifrpl->device);
+       struct nes_device *nesdev = nesvnic->nesdev;
+       struct nes_ib_fast_reg_page_list *pnesfrpl;
+
+       pnesfrpl = container_of(pifrpl, struct nes_ib_fast_reg_page_list, ibfrpl);
+       /*
+        * Free the WQE PBL.
+        */
+       pci_free_consistent(nesdev->pcidev,
+                           pifrpl->max_page_list_len * sizeof(u64),
+                           pnesfrpl->nes_wqe_pbl.kva,
+                           pnesfrpl->nes_wqe_pbl.paddr);
+       /*
+        * Free the PBL structure
+        */
+       kfree(pnesfrpl);
 }
 
-
-
 /**
  * nes_query_device
  */
@@ -633,23 +527,23 @@ static int nes_query_device(struct ib_device *ibdev, struct ib_device_attr *prop
        props->max_qp_wr = nesdev->nesadapter->max_qp_wr - 2;
        props->max_sge = nesdev->nesadapter->max_sge;
        props->max_cq = nesibdev->max_cq;
-       props->max_cqe = nesdev->nesadapter->max_cqe - 1;
+       props->max_cqe = nesdev->nesadapter->max_cqe;
        props->max_mr = nesibdev->max_mr;
        props->max_mw = nesibdev->max_mr;
        props->max_pd = nesibdev->max_pd;
        props->max_sge_rd = 1;
        switch (nesdev->nesadapter->max_irrq_wr) {
                case 0:
-                       props->max_qp_rd_atom = 1;
+                       props->max_qp_rd_atom = 2;
                        break;
                case 1:
-                       props->max_qp_rd_atom = 4;
+                       props->max_qp_rd_atom = 8;
                        break;
                case 2:
-                       props->max_qp_rd_atom = 16;
+                       props->max_qp_rd_atom = 32;
                        break;
                case 3:
-                       props->max_qp_rd_atom = 32;
+                       props->max_qp_rd_atom = 64;
                        break;
                default:
                        props->max_qp_rd_atom = 0;
@@ -1121,6 +1015,7 @@ static int nes_setup_virt_qp(struct nes_qp *nesqp, struct nes_pbl *nespbl,
                kunmap(nesqp->page);
                return -ENOMEM;
        }
+       nesqp->sq_kmapped = 1;
        nesqp->hwqp.q2_vbase = mem;
        mem += 256;
        memset(nesqp->hwqp.q2_vbase, 0, 256);
@@ -1198,7 +1093,10 @@ static inline void nes_free_qp_mem(struct nes_device *nesdev,
                pci_free_consistent(nesdev->pcidev, nesqp->qp_mem_size, nesqp->hwqp.q2_vbase, nesqp->hwqp.q2_pbase);
                pci_free_consistent(nesdev->pcidev, 256, nesqp->pbl_vbase, nesqp->pbl_pbase );
                nesqp->pbl_vbase = NULL;
-               kunmap(nesqp->page);
+               if (nesqp->sq_kmapped) {
+                       nesqp->sq_kmapped = 0;
+                       kunmap(nesqp->page);
+               }
        }
 }
 
@@ -1504,8 +1402,6 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
                        nes_debug(NES_DBG_QP, "QP%u structure located @%p.Size = %u.\n",
                                        nesqp->hwqp.qp_id, nesqp, (u32)sizeof(*nesqp));
                        spin_lock_init(&nesqp->lock);
-                       init_waitqueue_head(&nesqp->state_waitq);
-                       init_waitqueue_head(&nesqp->kick_waitq);
                        nes_add_ref(&nesqp->ibqp);
                        break;
                default:
@@ -1513,6 +1409,8 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
                        return ERR_PTR(-EINVAL);
        }
 
+       nesqp->sig_all = (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR);
+
        /* update the QP table */
        nesdev->nesadapter->qp_table[nesqp->hwqp.qp_id-NES_FIRST_QPN] = nesqp;
        nes_debug(NES_DBG_QP, "netdev refcnt=%u\n",
@@ -1607,8 +1505,10 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
                                nes_ucontext->first_free_wq = nesqp->mmap_sq_db_index;
                        }
                }
-               if (nesqp->pbl_pbase)
+               if (nesqp->pbl_pbase && nesqp->sq_kmapped) {
+                       nesqp->sq_kmapped = 0;
                        kunmap(nesqp->page);
+               }
        } else {
                /* Clean any pending completions from the cq(s) */
                if (nesqp->nesscq)
@@ -1649,6 +1549,9 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
        unsigned long flags;
        int ret;
 
+       if (entries > nesadapter->max_cqe)
+               return ERR_PTR(-EINVAL);
+
        err = nes_alloc_resource(nesadapter, nesadapter->allocated_cqs,
                        nesadapter->max_cq, &cq_num, &nesadapter->next_cq);
        if (err) {
@@ -2606,9 +2509,6 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
                        stag = stag_index << 8;
                        stag |= driver_key;
                        stag += (u32)stag_key;
-                       if (stag == 0) {
-                               stag = 1;
-                       }
 
                        iova_start = virt;
                        /* Make the leaf PBL the root if only one PBL */
@@ -3109,7 +3009,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
                                                                " already done based on hw state.\n",
                                                                nesqp->hwqp.qp_id);
                                                issue_modify_qp = 0;
-                                               nesqp->in_disconnect = 0;
                                        }
                                        switch (nesqp->hw_iwarp_state) {
                                                case NES_AEQE_IWARP_STATE_CLOSING:
@@ -3122,7 +3021,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
                                                        break;
                                                default:
                                                        next_iwarp_state = NES_CQP_QP_IWARP_STATE_CLOSING;
-                                                       nesqp->in_disconnect = 1;
                                                        nesqp->hw_iwarp_state = NES_AEQE_IWARP_STATE_CLOSING;
                                                        break;
                                        }
@@ -3139,7 +3037,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
                                next_iwarp_state = NES_CQP_QP_IWARP_STATE_TERMINATE;
                                nesqp->hw_iwarp_state = NES_AEQE_IWARP_STATE_TERMINATE;
                                issue_modify_qp = 1;
-                               nesqp->in_disconnect = 1;
                                break;
                        case IB_QPS_ERR:
                        case IB_QPS_RESET:
@@ -3162,7 +3059,6 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
                                if ((nesqp->hw_tcp_state > NES_AEQE_TCP_STATE_CLOSED) &&
                                                (nesqp->hw_tcp_state != NES_AEQE_TCP_STATE_TIME_WAIT)) {
                                        next_iwarp_state |= NES_CQP_QP_RESET;
-                                       nesqp->in_disconnect = 1;
                                } else {
                                        nes_debug(NES_DBG_MOD_QP, "QP%u NOT setting NES_CQP_QP_RESET since TCP state = %u\n",
                                                        nesqp->hwqp.qp_id, nesqp->hw_tcp_state);
@@ -3373,21 +3269,17 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
        struct nes_device *nesdev = nesvnic->nesdev;
        struct nes_qp *nesqp = to_nesqp(ibqp);
        struct nes_hw_qp_wqe *wqe;
-       int err;
+       int err = 0;
        u32 qsize = nesqp->hwqp.sq_size;
        u32 head;
-       u32 wqe_misc;
-       u32 wqe_count;
+       u32 wqe_misc = 0;
+       u32 wqe_count = 0;
        u32 counter;
-       u32 total_payload_length;
-
-       err = 0;
-       wqe_misc = 0;
-       wqe_count = 0;
-       total_payload_length = 0;
 
-       if (nesqp->ibqp_state > IB_QPS_RTS)
-               return -EINVAL;
+       if (nesqp->ibqp_state > IB_QPS_RTS) {
+               err = -EINVAL;
+               goto out;
+       }
 
        spin_lock_irqsave(&nesqp->lock, flags);
 
@@ -3413,94 +3305,208 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
                u64temp = (u64)(ib_wr->wr_id);
                set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_COMP_SCRATCH_LOW_IDX,
                                        u64temp);
-                       switch (ib_wr->opcode) {
-                               case IB_WR_SEND:
-                                       if (ib_wr->send_flags & IB_SEND_SOLICITED) {
-                                               wqe_misc = NES_IWARP_SQ_OP_SENDSE;
-                                       } else {
-                                               wqe_misc = NES_IWARP_SQ_OP_SEND;
-                                       }
-                                       if (ib_wr->num_sge > nesdev->nesadapter->max_sge) {
-                                               err = -EINVAL;
-                                               break;
-                                       }
-                                       if (ib_wr->send_flags & IB_SEND_FENCE) {
-                                               wqe_misc |= NES_IWARP_SQ_WQE_LOCAL_FENCE;
-                                       }
-                                       if ((ib_wr->send_flags & IB_SEND_INLINE) &&
-                                                       ((nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) == 0) &&
-                                                       (ib_wr->sg_list[0].length <= 64)) {
-                                               memcpy(&wqe->wqe_words[NES_IWARP_SQ_WQE_IMM_DATA_START_IDX],
-                                                              (void *)(unsigned long)ib_wr->sg_list[0].addr, ib_wr->sg_list[0].length);
-                                               set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX,
-                                                               ib_wr->sg_list[0].length);
-                                               wqe_misc |= NES_IWARP_SQ_WQE_IMM_DATA;
-                                       } else {
-                                               fill_wqe_sg_send(wqe, ib_wr, 1);
-                                       }
+               switch (ib_wr->opcode) {
+               case IB_WR_SEND:
+               case IB_WR_SEND_WITH_INV:
+                       if (IB_WR_SEND == ib_wr->opcode) {
+                               if (ib_wr->send_flags & IB_SEND_SOLICITED)
+                                       wqe_misc = NES_IWARP_SQ_OP_SENDSE;
+                               else
+                                       wqe_misc = NES_IWARP_SQ_OP_SEND;
+                       } else {
+                               if (ib_wr->send_flags & IB_SEND_SOLICITED)
+                                       wqe_misc = NES_IWARP_SQ_OP_SENDSEINV;
+                               else
+                                       wqe_misc = NES_IWARP_SQ_OP_SENDINV;
 
-                                       break;
-                               case IB_WR_RDMA_WRITE:
-                                       wqe_misc = NES_IWARP_SQ_OP_RDMAW;
-                                       if (ib_wr->num_sge > nesdev->nesadapter->max_sge) {
-                                               nes_debug(NES_DBG_IW_TX, "Exceeded max sge, ib_wr=%u, max=%u\n",
-                                                               ib_wr->num_sge,
-                                                               nesdev->nesadapter->max_sge);
-                                               err = -EINVAL;
-                                               break;
-                                       }
-                                       if (ib_wr->send_flags & IB_SEND_FENCE) {
-                                               wqe_misc |= NES_IWARP_SQ_WQE_LOCAL_FENCE;
-                                       }
+                               set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_INV_STAG_LOW_IDX,
+                                                   ib_wr->ex.invalidate_rkey);
+                       }
 
-                                       set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_STAG_IDX,
-                                                       ib_wr->wr.rdma.rkey);
-                                       set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_TO_LOW_IDX,
-                                                       ib_wr->wr.rdma.remote_addr);
-
-                                       if ((ib_wr->send_flags & IB_SEND_INLINE) &&
-                                                       ((nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) == 0) &&
-                                                       (ib_wr->sg_list[0].length <= 64)) {
-                                               memcpy(&wqe->wqe_words[NES_IWARP_SQ_WQE_IMM_DATA_START_IDX],
-                                                              (void *)(unsigned long)ib_wr->sg_list[0].addr, ib_wr->sg_list[0].length);
-                                               set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX,
-                                                               ib_wr->sg_list[0].length);
-                                               wqe_misc |= NES_IWARP_SQ_WQE_IMM_DATA;
-                                       } else {
-                                               fill_wqe_sg_send(wqe, ib_wr, 1);
-                                       }
-                                       wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX] =
-                                                       wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX];
-                                       break;
-                               case IB_WR_RDMA_READ:
-                                       /* iWARP only supports 1 sge for RDMA reads */
-                                       if (ib_wr->num_sge > 1) {
-                                               nes_debug(NES_DBG_IW_TX, "Exceeded max sge, ib_wr=%u, max=1\n",
-                                                               ib_wr->num_sge);
-                                               err = -EINVAL;
-                                               break;
-                                       }
-                                       wqe_misc = NES_IWARP_SQ_OP_RDMAR;
-                                       set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_TO_LOW_IDX,
-                                                       ib_wr->wr.rdma.remote_addr);
-                                       set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_STAG_IDX,
-                                                       ib_wr->wr.rdma.rkey);
-                                       set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX,
-                                                       ib_wr->sg_list->length);
-                                       set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_FRAG0_LOW_IDX,
-                                                       ib_wr->sg_list->addr);
-                                       set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_STAG0_IDX,
-                                                       ib_wr->sg_list->lkey);
-                                       break;
-                               default:
-                                       /* error */
-                                       err = -EINVAL;
-                                       break;
+                       if (ib_wr->num_sge > nesdev->nesadapter->max_sge) {
+                               err = -EINVAL;
+                               break;
                        }
 
-               if (ib_wr->send_flags & IB_SEND_SIGNALED) {
-                       wqe_misc |= NES_IWARP_SQ_WQE_SIGNALED_COMPL;
+                       if (ib_wr->send_flags & IB_SEND_FENCE)
+                               wqe_misc |= NES_IWARP_SQ_WQE_LOCAL_FENCE;
+
+                       if ((ib_wr->send_flags & IB_SEND_INLINE) &&
+                           ((nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) == 0) &&
+                            (ib_wr->sg_list[0].length <= 64)) {
+                               memcpy(&wqe->wqe_words[NES_IWARP_SQ_WQE_IMM_DATA_START_IDX],
+                                      (void *)(unsigned long)ib_wr->sg_list[0].addr, ib_wr->sg_list[0].length);
+                               set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX,
+                                                   ib_wr->sg_list[0].length);
+                               wqe_misc |= NES_IWARP_SQ_WQE_IMM_DATA;
+                       } else {
+                               fill_wqe_sg_send(wqe, ib_wr, 1);
+                       }
+
+                       break;
+               case IB_WR_RDMA_WRITE:
+                       wqe_misc = NES_IWARP_SQ_OP_RDMAW;
+                       if (ib_wr->num_sge > nesdev->nesadapter->max_sge) {
+                               nes_debug(NES_DBG_IW_TX, "Exceeded max sge, ib_wr=%u, max=%u\n",
+                                         ib_wr->num_sge, nesdev->nesadapter->max_sge);
+                               err = -EINVAL;
+                               break;
+                       }
+
+                       if (ib_wr->send_flags & IB_SEND_FENCE)
+                               wqe_misc |= NES_IWARP_SQ_WQE_LOCAL_FENCE;
+
+                       set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_STAG_IDX,
+                                           ib_wr->wr.rdma.rkey);
+                       set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_TO_LOW_IDX,
+                                           ib_wr->wr.rdma.remote_addr);
+
+                       if ((ib_wr->send_flags & IB_SEND_INLINE) &&
+                           ((nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) == 0) &&
+                            (ib_wr->sg_list[0].length <= 64)) {
+                               memcpy(&wqe->wqe_words[NES_IWARP_SQ_WQE_IMM_DATA_START_IDX],
+                                      (void *)(unsigned long)ib_wr->sg_list[0].addr, ib_wr->sg_list[0].length);
+                               set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX,
+                                                   ib_wr->sg_list[0].length);
+                               wqe_misc |= NES_IWARP_SQ_WQE_IMM_DATA;
+                       } else {
+                               fill_wqe_sg_send(wqe, ib_wr, 1);
+                       }
+
+                       wqe->wqe_words[NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX] =
+                               wqe->wqe_words[NES_IWARP_SQ_WQE_TOTAL_PAYLOAD_IDX];
+                       break;
+               case IB_WR_RDMA_READ:
+               case IB_WR_RDMA_READ_WITH_INV:
+                       /* iWARP only supports 1 sge for RDMA reads */
+                       if (ib_wr->num_sge > 1) {
+                               nes_debug(NES_DBG_IW_TX, "Exceeded max sge, ib_wr=%u, max=1\n",
+                                         ib_wr->num_sge);
+                               err = -EINVAL;
+                               break;
+                       }
+                       if (ib_wr->opcode == IB_WR_RDMA_READ) {
+                               wqe_misc = NES_IWARP_SQ_OP_RDMAR;
+                       } else {
+                               wqe_misc = NES_IWARP_SQ_OP_RDMAR_LOCINV;
+                               set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_INV_STAG_LOW_IDX,
+                                                   ib_wr->ex.invalidate_rkey);
+                       }
+
+                       set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_TO_LOW_IDX,
+                                           ib_wr->wr.rdma.remote_addr);
+                       set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_STAG_IDX,
+                                           ib_wr->wr.rdma.rkey);
+                       set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_RDMA_LENGTH_IDX,
+                                           ib_wr->sg_list->length);
+                       set_wqe_64bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_FRAG0_LOW_IDX,
+                                           ib_wr->sg_list->addr);
+                       set_wqe_32bit_value(wqe->wqe_words, NES_IWARP_SQ_WQE_STAG0_IDX,
+                                           ib_wr->sg_list->lkey);
+                       break;
+               case IB_WR_LOCAL_INV:
+                       wqe_misc = NES_IWARP_SQ_OP_LOCINV;
+                       set_wqe_32bit_value(wqe->wqe_words,
+                                           NES_IWARP_SQ_LOCINV_WQE_INV_STAG_IDX,
+                                           ib_wr->ex.invalidate_rkey);
+                       break;
+               case IB_WR_FAST_REG_MR:
+               {
+                       int i;
+                       int flags = ib_wr->wr.fast_reg.access_flags;
+                       struct nes_ib_fast_reg_page_list *pnesfrpl =
+                               container_of(ib_wr->wr.fast_reg.page_list,
+                                            struct nes_ib_fast_reg_page_list,
+                                            ibfrpl);
+                       u64 *src_page_list = pnesfrpl->ibfrpl.page_list;
+                       u64 *dst_page_list = pnesfrpl->nes_wqe_pbl.kva;
+
+                       if (ib_wr->wr.fast_reg.page_list_len >
+                           (NES_4K_PBL_CHUNK_SIZE / sizeof(u64))) {
+                               nes_debug(NES_DBG_IW_TX, "SQ_FMR: bad page_list_len\n");
+                               err = -EINVAL;
+                               break;
+                       }
+                       wqe_misc = NES_IWARP_SQ_OP_FAST_REG;
+                       set_wqe_64bit_value(wqe->wqe_words,
+                                           NES_IWARP_SQ_FMR_WQE_VA_FBO_LOW_IDX,
+                                           ib_wr->wr.fast_reg.iova_start);
+                       set_wqe_32bit_value(wqe->wqe_words,
+                                           NES_IWARP_SQ_FMR_WQE_LENGTH_LOW_IDX,
+                                           ib_wr->wr.fast_reg.length);
+                       set_wqe_32bit_value(wqe->wqe_words,
+                                           NES_IWARP_SQ_FMR_WQE_MR_STAG_IDX,
+                                           ib_wr->wr.fast_reg.rkey);
+                       /* Set page size: */
+                       if (ib_wr->wr.fast_reg.page_shift == 12) {
+                               wqe_misc |= NES_IWARP_SQ_FMR_WQE_PAGE_SIZE_4K;
+                       } else if (ib_wr->wr.fast_reg.page_shift == 21) {
+                               wqe_misc |= NES_IWARP_SQ_FMR_WQE_PAGE_SIZE_2M;
+                       } else {
+                               nes_debug(NES_DBG_IW_TX, "Invalid page shift,"
+                                         " ib_wr=%u, max=1\n", ib_wr->num_sge);
+                               err = -EINVAL;
+                               break;
+                       }
+                       /* Set access_flags */
+                       wqe_misc |= NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_LOCAL_READ;
+                       if (flags & IB_ACCESS_LOCAL_WRITE)
+                               wqe_misc |= NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_LOCAL_WRITE;
+
+                       if (flags & IB_ACCESS_REMOTE_WRITE)
+                               wqe_misc |= NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_REMOTE_WRITE;
+
+                       if (flags & IB_ACCESS_REMOTE_READ)
+                               wqe_misc |= NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_REMOTE_READ;
+
+                       if (flags & IB_ACCESS_MW_BIND)
+                               wqe_misc |= NES_IWARP_SQ_FMR_WQE_RIGHTS_ENABLE_WINDOW_BIND;
+
+                       /* Fill in PBL info: */
+                       if (ib_wr->wr.fast_reg.page_list_len >
+                           pnesfrpl->ibfrpl.max_page_list_len) {
+                               nes_debug(NES_DBG_IW_TX, "Invalid page list length,"
+                                         " ib_wr=%p, value=%u, max=%u\n",
+                                         ib_wr, ib_wr->wr.fast_reg.page_list_len,
+                                         pnesfrpl->ibfrpl.max_page_list_len);
+                               err = -EINVAL;
+                               break;
+                       }
+
+                       set_wqe_64bit_value(wqe->wqe_words,
+                                           NES_IWARP_SQ_FMR_WQE_PBL_ADDR_LOW_IDX,
+                                           pnesfrpl->nes_wqe_pbl.paddr);
+
+                       set_wqe_32bit_value(wqe->wqe_words,
+                                           NES_IWARP_SQ_FMR_WQE_PBL_LENGTH_IDX,
+                                           ib_wr->wr.fast_reg.page_list_len * 8);
+
+                       for (i = 0; i < ib_wr->wr.fast_reg.page_list_len; i++)
+                               dst_page_list[i] = cpu_to_le64(src_page_list[i]);
+
+                       nes_debug(NES_DBG_IW_TX, "SQ_FMR: iova_start: %p, "
+                                 "length: %d, rkey: %0x, pgl_paddr: %p, "
+                                 "page_list_len: %u, wqe_misc: %x\n",
+                                 (void *)ib_wr->wr.fast_reg.iova_start,
+                                 ib_wr->wr.fast_reg.length,
+                                 ib_wr->wr.fast_reg.rkey,
+                                 (void *)pnesfrpl->nes_wqe_pbl.paddr,
+                                 ib_wr->wr.fast_reg.page_list_len,
+                                 wqe_misc);
+                       break;
+               }
+               default:
+                       /* error */
+                       err = -EINVAL;
+                       break;
                }
+
+               if (err)
+                       break;
+
+               if ((ib_wr->send_flags & IB_SEND_SIGNALED) || nesqp->sig_all)
+                       wqe_misc |= NES_IWARP_SQ_WQE_SIGNALED_COMPL;
+
                wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] = cpu_to_le32(wqe_misc);
 
                ib_wr = ib_wr->next;
@@ -3522,6 +3528,7 @@ static int nes_post_send(struct ib_qp *ibqp, struct ib_send_wr *ib_wr,
 
        spin_unlock_irqrestore(&nesqp->lock, flags);
 
+out:
        if (err)
                *bad_wr = ib_wr;
        return err;
@@ -3548,8 +3555,10 @@ static int nes_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *ib_wr,
        u32 counter;
        u32 total_payload_length;
 
-       if (nesqp->ibqp_state > IB_QPS_RTS)
-               return -EINVAL;
+       if (nesqp->ibqp_state > IB_QPS_RTS) {
+               err = -EINVAL;
+               goto out;
+       }
 
        spin_lock_irqsave(&nesqp->lock, flags);
 
@@ -3612,6 +3621,7 @@ static int nes_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *ib_wr,
 
        spin_unlock_irqrestore(&nesqp->lock, flags);
 
+out:
        if (err)
                *bad_wr = ib_wr;
        return err;
@@ -3720,6 +3730,12 @@ static int nes_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry)
                                                nes_debug(NES_DBG_CQ, "Operation = Send.\n");
                                                entry->opcode = IB_WC_SEND;
                                                break;
+                                       case NES_IWARP_SQ_OP_LOCINV:
+                                               entry->opcode = IB_WR_LOCAL_INV;
+                                               break;
+                                       case NES_IWARP_SQ_OP_FAST_REG:
+                                               entry->opcode = IB_WC_FAST_REG_MR;
+                                               break;
                                }
 
                                nesqp->hwqp.sq_tail = (wqe_index+1)&(nesqp->hwqp.sq_size - 1);
@@ -3890,10 +3906,9 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
        nesibdev->ibdev.dealloc_mw = nes_dealloc_mw;
        nesibdev->ibdev.bind_mw = nes_bind_mw;
 
-       nesibdev->ibdev.alloc_fmr = nes_alloc_fmr;
-       nesibdev->ibdev.unmap_fmr = nes_unmap_fmr;
-       nesibdev->ibdev.dealloc_fmr = nes_dealloc_fmr;
-       nesibdev->ibdev.map_phys_fmr = nes_map_phys_fmr;
+       nesibdev->ibdev.alloc_fast_reg_mr = nes_alloc_fast_reg_mr;
+       nesibdev->ibdev.alloc_fast_reg_page_list = nes_alloc_fast_reg_page_list;
+       nesibdev->ibdev.free_fast_reg_page_list = nes_free_fast_reg_page_list;
 
        nesibdev->ibdev.attach_mcast = nes_multicast_attach;
        nesibdev->ibdev.detach_mcast = nes_multicast_detach;
index 89822d75f82ec581375bd87c9336f600eed6c7d1..2df9993e0cac513da2d216cfdf801f06cc73f879 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006 - 2009 Intel-NE, Inc.  All rights reserved.
+ * Copyright (c) 2006 - 2009 Intel Corporation.  All rights reserved.
  * Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -135,19 +135,15 @@ struct nes_qp {
        struct ib_qp          ibqp;
        void                  *allocated_buffer;
        struct iw_cm_id       *cm_id;
-       struct workqueue_struct *wq;
        struct nes_cq         *nesscq;
        struct nes_cq         *nesrcq;
        struct nes_pd         *nespd;
        void *cm_node; /* handle of the node this QP is associated with */
        struct ietf_mpa_frame *ietf_frame;
        dma_addr_t            ietf_frame_pbase;
-       wait_queue_head_t     state_waitq;
        struct ib_mr          *lsmm_mr;
-       unsigned long         socket;
        struct nes_hw_qp      hwqp;
        struct work_struct    work;
-       struct work_struct    ae_work;
        enum ib_qp_state      ibqp_state;
        u32                   iwarp_state;
        u32                   hte_index;
@@ -165,19 +161,20 @@ struct nes_qp {
        struct page           *page;
        struct timer_list     terminate_timer;
        enum ib_event_type    terminate_eventtype;
-       wait_queue_head_t     kick_waitq;
-       u16                   in_disconnect;
+       u16                   active_conn:1;
+       u16                   skip_lsmm:1;
+       u16                   user_mode:1;
+       u16                   hte_added:1;
+       u16                   flush_issued:1;
+       u16                   destroyed:1;
+       u16                   sig_all:1;
+       u16                   rsvd:9;
        u16                   private_data_len;
        u16                   term_sq_flush_code;
        u16                   term_rq_flush_code;
-       u8                    active_conn;
-       u8                    skip_lsmm;
-       u8                    user_mode;
-       u8                    hte_added;
        u8                    hw_iwarp_state;
-       u8                    flush_issued;
        u8                    hw_tcp_state;
        u8                    term_flags;
-       u8                    destroyed;
+       u8                    sq_kmapped;
 };
 #endif                 /* NES_VERBS_H */
index 2bf5116deec41d7109b1b6b3b6ccc141ae3ac052..df3eb8c9fd96adf7e0b9cc8496bfce760ad6952d 100644 (file)
@@ -884,6 +884,7 @@ struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour,
 
        neigh->neighbour = neighbour;
        neigh->dev = dev;
+       memset(&neigh->dgid.raw, 0, sizeof (union ib_gid));
        *to_ipoib_neigh(neighbour) = neigh;
        skb_queue_head_init(&neigh->queue);
        ipoib_cm_set(neigh, NULL);
index b9453d068e9d81922568daa82f733649c5b623f2..274c883ef3eaf30afd478408bd1f10c001baf0f8 100644 (file)
@@ -209,6 +209,8 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_task *iser_task,
        mem_copy->copy_buf = NULL;
 }
 
+#define IS_4K_ALIGNED(addr)    ((((unsigned long)addr) & ~MASK_4K) == 0)
+
 /**
  * iser_sg_to_page_vec - Translates scatterlist entries to physical addresses
  * and returns the length of resulting physical address array (may be less than
@@ -221,62 +223,52 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_task *iser_task,
  * where --few fragments of the same page-- are present in the SG as
  * consecutive elements. Also, it handles one entry SG.
  */
+
 static int iser_sg_to_page_vec(struct iser_data_buf *data,
                               struct iser_page_vec *page_vec,
                               struct ib_device *ibdev)
 {
-       struct scatterlist *sgl = (struct scatterlist *)data->buf;
-       struct scatterlist *sg;
-       u64 first_addr, last_addr, page;
-       int end_aligned;
-       unsigned int cur_page = 0;
+       struct scatterlist *sg, *sgl = (struct scatterlist *)data->buf;
+       u64 start_addr, end_addr, page, chunk_start = 0;
        unsigned long total_sz = 0;
-       int i;
+       unsigned int dma_len;
+       int i, new_chunk, cur_page, last_ent = data->dma_nents - 1;
 
        /* compute the offset of first element */
        page_vec->offset = (u64) sgl[0].offset & ~MASK_4K;
 
+       new_chunk = 1;
+       cur_page  = 0;
        for_each_sg(sgl, sg, data->dma_nents, i) {
-               unsigned int dma_len = ib_sg_dma_len(ibdev, sg);
-
+               start_addr = ib_sg_dma_address(ibdev, sg);
+               if (new_chunk)
+                       chunk_start = start_addr;
+               dma_len = ib_sg_dma_len(ibdev, sg);
+               end_addr = start_addr + dma_len;
                total_sz += dma_len;
 
-               first_addr = ib_sg_dma_address(ibdev, sg);
-               last_addr  = first_addr + dma_len;
-
-               end_aligned   = !(last_addr  & ~MASK_4K);
-
-               /* continue to collect page fragments till aligned or SG ends */
-               while (!end_aligned && (i + 1 < data->dma_nents)) {
-                       sg = sg_next(sg);
-                       i++;
-                       dma_len = ib_sg_dma_len(ibdev, sg);
-                       total_sz += dma_len;
-                       last_addr = ib_sg_dma_address(ibdev, sg) + dma_len;
-                       end_aligned = !(last_addr  & ~MASK_4K);
+               /* collect page fragments until aligned or end of SG list */
+               if (!IS_4K_ALIGNED(end_addr) && i < last_ent) {
+                       new_chunk = 0;
+                       continue;
                }
-
-               /* handle the 1st page in the 1st DMA element */
-               if (cur_page == 0) {
-                       page = first_addr & MASK_4K;
-                       page_vec->pages[cur_page] = page;
-                       cur_page++;
+               new_chunk = 1;
+
+               /* address of the first page in the contiguous chunk;
+                  masking relevant for the very first SG entry,
+                  which might be unaligned */
+               page = chunk_start & MASK_4K;
+               do {
+                       page_vec->pages[cur_page++] = page;
                        page += SIZE_4K;
-               } else
-                       page = first_addr;
-
-               for (; page < last_addr; page += SIZE_4K) {
-                       page_vec->pages[cur_page] = page;
-                       cur_page++;
-               }
-
+               } while (page < end_addr);
        }
+
        page_vec->data_size = total_sz;
        iser_dbg("page_vec->data_size:%d cur_page %d\n", page_vec->data_size,cur_page);
        return cur_page;
 }
 
-#define IS_4K_ALIGNED(addr)    ((((unsigned long)addr) & ~MASK_4K) == 0)
 
 /**
  * iser_data_buf_aligned_len - Tries to determine the maximal correctly aligned
@@ -284,42 +276,40 @@ static int iser_sg_to_page_vec(struct iser_data_buf *data,
  * the number of entries which are aligned correctly. Supports the case where
  * consecutive SG elements are actually fragments of the same physcial page.
  */
-static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data,
-                                             struct ib_device *ibdev)
+static int iser_data_buf_aligned_len(struct iser_data_buf *data,
+                                     struct ib_device *ibdev)
 {
-       struct scatterlist *sgl, *sg;
-       u64 end_addr, next_addr;
-       int i, cnt;
-       unsigned int ret_len = 0;
+       struct scatterlist *sgl, *sg, *next_sg = NULL;
+       u64 start_addr, end_addr;
+       int i, ret_len, start_check = 0;
+
+       if (data->dma_nents == 1)
+               return 1;
 
        sgl = (struct scatterlist *)data->buf;
+       start_addr  = ib_sg_dma_address(ibdev, sgl);
 
-       cnt = 0;
        for_each_sg(sgl, sg, data->dma_nents, i) {
-               /* iser_dbg("Checking sg iobuf [%d]: phys=0x%08lX "
-                  "offset: %ld sz: %ld\n", i,
-                  (unsigned long)sg_phys(sg),
-                  (unsigned long)sg->offset,
-                  (unsigned long)sg->length); */
-               end_addr = ib_sg_dma_address(ibdev, sg) +
-                          ib_sg_dma_len(ibdev, sg);
-               /* iser_dbg("Checking sg iobuf end address "
-                      "0x%08lX\n", end_addr); */
-               if (i + 1 < data->dma_nents) {
-                       next_addr = ib_sg_dma_address(ibdev, sg_next(sg));
-                       /* are i, i+1 fragments of the same page? */
-                       if (end_addr == next_addr) {
-                               cnt++;
-                               continue;
-                       } else if (!IS_4K_ALIGNED(end_addr)) {
-                               ret_len = cnt + 1;
-                               break;
-                       }
-               }
-               cnt++;
+               if (start_check && !IS_4K_ALIGNED(start_addr))
+                       break;
+
+               next_sg = sg_next(sg);
+               if (!next_sg)
+                       break;
+
+               end_addr    = start_addr + ib_sg_dma_len(ibdev, sg);
+               start_addr  = ib_sg_dma_address(ibdev, next_sg);
+
+               if (end_addr == start_addr) {
+                       start_check = 0;
+                       continue;
+               } else
+                       start_check = 1;
+
+               if (!IS_4K_ALIGNED(end_addr))
+                       break;
        }
-       if (i == data->dma_nents)
-               ret_len = cnt;  /* loop ended */
+       ret_len = (next_sg) ? i : i+1;
        iser_dbg("Found %d aligned entries out of %d in sg:0x%p\n",
                 ret_len, data->dma_nents, data);
        return ret_len;
index d48c808d59281b415505842ae5d1fb0ff55a51ac..1edb596d927bd885dea073593a3183fc63b45a54 100644 (file)
@@ -319,7 +319,7 @@ static int adp5588_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops adp5588_dev_pm_ops = {
+static const struct dev_pm_ops adp5588_dev_pm_ops = {
        .suspend = adp5588_suspend,
        .resume  = adp5588_resume,
 };
index 076111fc72d227e3216f94e975ea1f9eaf675dcf..8e9380bfed4097fcdc283cfc7c3532ed0e911318 100644 (file)
@@ -295,7 +295,7 @@ static int sh_keysc_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops sh_keysc_dev_pm_ops = {
+static const struct dev_pm_ops sh_keysc_dev_pm_ops = {
        .suspend = sh_keysc_suspend,
        .resume = sh_keysc_resume,
 };
index 690f3fafa03b9dd66ac4fa42d9d433addaa0b03a..61d10177fa83750b0162468956742564466e9e25 100644 (file)
@@ -247,7 +247,7 @@ static int bfin_rotary_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops bfin_rotary_pm_ops = {
+static const struct dev_pm_ops bfin_rotary_pm_ops = {
        .suspend        = bfin_rotary_suspend,
        .resume         = bfin_rotary_resume,
 };
index 21cb755a54fb925deda36db17933a0991bb0969c..ea4e1fd126516c05a67a0aa58ed27421f1f8de78 100644 (file)
@@ -127,7 +127,7 @@ static void pcspkr_shutdown(struct platform_device *dev)
        pcspkr_event(NULL, EV_SND, SND_BELL, 0);
 }
 
-static struct dev_pm_ops pcspkr_pm_ops = {
+static const struct dev_pm_ops pcspkr_pm_ops = {
        .suspend = pcspkr_suspend,
 };
 
index 67fcd33595def87293469b0caf625dccdaf8d83c..b79097e3028a10e381f1c259c78ce0259985f2f1 100644 (file)
@@ -233,7 +233,7 @@ static int pcap_ts_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops pcap_ts_pm_ops = {
+static const struct dev_pm_ops pcap_ts_pm_ops = {
        .suspend        = pcap_ts_suspend,
        .resume         = pcap_ts_resume,
 };
index 7e5f30dbc0a0043e8b96ff8b230042e0b76d969c..f1e8af54dff01e7934bb0f49932e825e01f44f65 100644 (file)
@@ -661,7 +661,7 @@ l1oip_socket_thread(void *data)
        size_t recvbuf_size = 1500;
        int recvlen;
        struct socket *socket = NULL;
-       DECLARE_COMPLETION(wait);
+       DECLARE_COMPLETION_ONSTACK(wait);
 
        /* allocate buffer memory */
        recvbuf = kmalloc(recvbuf_size, GFP_KERNEL);
index e4f599f20e38f5804da67013cc5936834de3e2e1..8a0e1ec95e4aaf03bf3d8a91fd6a6ef32db07ec7 100644 (file)
@@ -229,6 +229,12 @@ config LEDS_PWM
        help
          This option enables support for pwm driven LEDs
 
+config LEDS_REGULATOR
+       tristate "REGULATOR driven LED support"
+       depends on LEDS_CLASS && REGULATOR
+       help
+         This option enables support for regulator driven LEDs.
+
 config LEDS_BD2802
        tristate "LED driver for BD2802 RGB LED"
        depends on LEDS_CLASS && I2C
@@ -236,6 +242,33 @@ config LEDS_BD2802
          This option enables support for BD2802GU RGB LED driver chips
          accessed via the I2C bus.
 
+config LEDS_INTEL_SS4200
+       tristate "LED driver for Intel NAS SS4200 series"
+       depends on LEDS_CLASS && PCI && DMI
+       help
+         This option enables support for the Intel SS4200 series of
+         Network Attached Storage servers.  You may control the hard
+         drive or power LEDs on the front panel.  Using this driver
+         can stop the front LED from blinking after startup.
+
+config LEDS_LT3593
+       tristate "LED driver for LT3593 controllers"
+       depends on LEDS_CLASS && GENERIC_GPIO
+       help
+         This option enables support for LEDs driven by a Linear Technology
+         LT3593 controller. This controller uses a special one-wire pulse
+         coding protocol to set the brightness.
+
+config LEDS_ADP5520
+       tristate "LED Support for ADP5520/ADP5501 PMIC"
+       depends on LEDS_CLASS && PMIC_ADP5520
+       help
+         This option enables support for on-chip LED drivers found
+         on Analog Devices ADP5520/ADP5501 PMICs.
+
+         To compile this driver as a module, choose M here: the module will
+         be called leds-adp5520.
+
 comment "LED Triggers"
 
 config LEDS_TRIGGERS
index 46d72704d60651c43031a220f7dc416043b63774..9e63869d7c0d1bfd2e211d890f5b57371c4e1f65 100644 (file)
@@ -29,6 +29,10 @@ obj-$(CONFIG_LEDS_DA903X)            += leds-da903x.o
 obj-$(CONFIG_LEDS_WM831X_STATUS)       += leds-wm831x-status.o
 obj-$(CONFIG_LEDS_WM8350)              += leds-wm8350.o
 obj-$(CONFIG_LEDS_PWM)                 += leds-pwm.o
+obj-$(CONFIG_LEDS_REGULATOR)           += leds-regulator.o
+obj-$(CONFIG_LEDS_INTEL_SS4200)                += leds-ss4200.o
+obj-$(CONFIG_LEDS_LT3593)              += leds-lt3593.o
+obj-$(CONFIG_LEDS_ADP5520)             += leds-adp5520.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_DAC124S085)          += leds-dac124s085.o
index f2cc13d76810f457c752d6f92f53759980f465ea..782f95822eab0867f8db83666c5ba08d3a77a23e 100644 (file)
@@ -50,7 +50,7 @@ static ssize_t led_brightness_store(struct device *dev,
        unsigned long state = simple_strtoul(buf, &after, 10);
        size_t count = after - buf;
 
-       if (*after && isspace(*after))
+       if (isspace(*after))
                count++;
 
        if (count == size) {
diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c
new file mode 100644 (file)
index 0000000..a8f3159
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * LEDs driver for Analog Devices ADP5520/ADP5501 MFD PMICs
+ *
+ * Copyright 2009 Analog Devices Inc.
+ *
+ * Loosely derived from leds-da903x:
+ * Copyright (C) 2008 Compulab, Ltd.
+ *     Mike Rapoport <mike@compulab.co.il>
+ *
+ * Copyright (C) 2006-2008 Marvell International Ltd.
+ *     Eric Miao <eric.miao@marvell.com>
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/workqueue.h>
+#include <linux/mfd/adp5520.h>
+
+struct adp5520_led {
+       struct led_classdev     cdev;
+       struct work_struct      work;
+       struct device           *master;
+       enum led_brightness     new_brightness;
+       int                     id;
+       int                     flags;
+};
+
+static void adp5520_led_work(struct work_struct *work)
+{
+       struct adp5520_led *led = container_of(work, struct adp5520_led, work);
+       adp5520_write(led->master, ADP5520_LED1_CURRENT + led->id - 1,
+                        led->new_brightness >> 2);
+}
+
+static void adp5520_led_set(struct led_classdev *led_cdev,
+                          enum led_brightness value)
+{
+       struct adp5520_led *led;
+
+       led = container_of(led_cdev, struct adp5520_led, cdev);
+       led->new_brightness = value;
+       schedule_work(&led->work);
+}
+
+static int adp5520_led_setup(struct adp5520_led *led)
+{
+       struct device *dev = led->master;
+       int flags = led->flags;
+       int ret = 0;
+
+       switch (led->id) {
+       case FLAG_ID_ADP5520_LED1_ADP5501_LED0:
+               ret |= adp5520_set_bits(dev, ADP5520_LED_TIME,
+                                       (flags >> ADP5520_FLAG_OFFT_SHIFT) &
+                                       ADP5520_FLAG_OFFT_MASK);
+               ret |= adp5520_set_bits(dev, ADP5520_LED_CONTROL,
+                                       ADP5520_LED1_EN);
+               break;
+       case FLAG_ID_ADP5520_LED2_ADP5501_LED1:
+               ret |= adp5520_set_bits(dev,  ADP5520_LED_TIME,
+                                       ((flags >> ADP5520_FLAG_OFFT_SHIFT) &
+                                       ADP5520_FLAG_OFFT_MASK) << 2);
+               ret |= adp5520_clr_bits(dev, ADP5520_LED_CONTROL,
+                                        ADP5520_R3_MODE);
+               ret |= adp5520_set_bits(dev, ADP5520_LED_CONTROL,
+                                       ADP5520_LED2_EN);
+               break;
+       case FLAG_ID_ADP5520_LED3_ADP5501_LED2:
+               ret |= adp5520_set_bits(dev,  ADP5520_LED_TIME,
+                                       ((flags >> ADP5520_FLAG_OFFT_SHIFT) &
+                                       ADP5520_FLAG_OFFT_MASK) << 4);
+               ret |= adp5520_clr_bits(dev, ADP5520_LED_CONTROL,
+                                       ADP5520_C3_MODE);
+               ret |= adp5520_set_bits(dev, ADP5520_LED_CONTROL,
+                                       ADP5520_LED3_EN);
+               break;
+       }
+
+       return ret;
+}
+
+static int __devinit adp5520_led_prepare(struct platform_device *pdev)
+{
+       struct adp5520_leds_platform_data *pdata = pdev->dev.platform_data;
+       struct device *dev = pdev->dev.parent;
+       int ret = 0;
+
+       ret |= adp5520_write(dev, ADP5520_LED1_CURRENT, 0);
+       ret |= adp5520_write(dev, ADP5520_LED2_CURRENT, 0);
+       ret |= adp5520_write(dev, ADP5520_LED3_CURRENT, 0);
+       ret |= adp5520_write(dev, ADP5520_LED_TIME, pdata->led_on_time << 6);
+       ret |= adp5520_write(dev, ADP5520_LED_FADE, FADE_VAL(pdata->fade_in,
+                pdata->fade_out));
+
+       return ret;
+}
+
+static int __devinit adp5520_led_probe(struct platform_device *pdev)
+{
+       struct adp5520_leds_platform_data *pdata = pdev->dev.platform_data;
+       struct adp5520_led *led, *led_dat;
+       struct led_info *cur_led;
+       int ret, i;
+
+       if (pdata == NULL) {
+               dev_err(&pdev->dev, "missing platform data\n");
+               return -ENODEV;
+       }
+
+       if (pdata->num_leds > ADP5520_01_MAXLEDS) {
+               dev_err(&pdev->dev, "can't handle more than %d LEDS\n",
+                                ADP5520_01_MAXLEDS);
+               return -EFAULT;
+       }
+
+       led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL);
+       if (led == NULL) {
+               dev_err(&pdev->dev, "failed to alloc memory\n");
+               return -ENOMEM;
+       }
+
+       ret = adp5520_led_prepare(pdev);
+
+       if (ret) {
+               dev_err(&pdev->dev, "failed to write\n");
+               goto err_free;
+       }
+
+       for (i = 0; i < pdata->num_leds; ++i) {
+               cur_led = &pdata->leds[i];
+               led_dat = &led[i];
+
+               led_dat->cdev.name = cur_led->name;
+               led_dat->cdev.default_trigger = cur_led->default_trigger;
+               led_dat->cdev.brightness_set = adp5520_led_set;
+               led_dat->cdev.brightness = LED_OFF;
+
+               if (cur_led->flags & ADP5520_FLAG_LED_MASK)
+                       led_dat->flags = cur_led->flags;
+               else
+                       led_dat->flags = i + 1;
+
+               led_dat->id = led_dat->flags & ADP5520_FLAG_LED_MASK;
+
+               led_dat->master = pdev->dev.parent;
+               led_dat->new_brightness = LED_OFF;
+
+               INIT_WORK(&led_dat->work, adp5520_led_work);
+
+               ret = led_classdev_register(led_dat->master, &led_dat->cdev);
+               if (ret) {
+                       dev_err(&pdev->dev, "failed to register LED %d\n",
+                               led_dat->id);
+                       goto err;
+               }
+
+               ret = adp5520_led_setup(led_dat);
+               if (ret) {
+                       dev_err(&pdev->dev, "failed to write\n");
+                       i++;
+                       goto err;
+               }
+       }
+
+       platform_set_drvdata(pdev, led);
+       return 0;
+
+err:
+       if (i > 0) {
+               for (i = i - 1; i >= 0; i--) {
+                       led_classdev_unregister(&led[i].cdev);
+                       cancel_work_sync(&led[i].work);
+               }
+       }
+
+err_free:
+       kfree(led);
+       return ret;
+}
+
+static int __devexit adp5520_led_remove(struct platform_device *pdev)
+{
+       struct adp5520_leds_platform_data *pdata = pdev->dev.platform_data;
+       struct adp5520_led *led;
+       int i;
+
+       led = platform_get_drvdata(pdev);
+
+       adp5520_clr_bits(led->master, ADP5520_LED_CONTROL,
+                ADP5520_LED1_EN | ADP5520_LED2_EN | ADP5520_LED3_EN);
+
+       for (i = 0; i < pdata->num_leds; i++) {
+               led_classdev_unregister(&led[i].cdev);
+               cancel_work_sync(&led[i].work);
+       }
+
+       kfree(led);
+       return 0;
+}
+
+static struct platform_driver adp5520_led_driver = {
+       .driver = {
+               .name   = "adp5520-led",
+               .owner  = THIS_MODULE,
+       },
+       .probe          = adp5520_led_probe,
+       .remove         = __devexit_p(adp5520_led_remove),
+};
+
+static int __init adp5520_led_init(void)
+{
+       return platform_driver_register(&adp5520_led_driver);
+}
+module_init(adp5520_led_init);
+
+static void __exit adp5520_led_exit(void)
+{
+       platform_driver_unregister(&adp5520_led_driver);
+}
+module_exit(adp5520_led_exit);
+
+MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
+MODULE_DESCRIPTION("LEDS ADP5520(01) Driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:adp5520-led");
index 731d4eef342590dca6566f229d60d7f8add6b872..f59ffadf51253991451adbbc7b51eb25142ad937 100644 (file)
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
+#include <linux/pci.h>
 
 static int force = 0;
 module_param(force, bool, 0444);
 MODULE_PARM_DESC(force, "Assume system has ALIX.2/ALIX.3 style LEDs");
 
+#define MSR_LBAR_GPIO          0x5140000C
+#define CS5535_GPIO_SIZE       256
+
+static u32 gpio_base;
+
+static struct pci_device_id divil_pci[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_NS,  PCI_DEVICE_ID_NS_CS5535_ISA) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) },
+       { } /* NULL entry */
+};
+MODULE_DEVICE_TABLE(pci, divil_pci);
+
 struct alix_led {
        struct led_classdev cdev;
        unsigned short port;
@@ -30,9 +43,9 @@ static void alix_led_set(struct led_classdev *led_cdev,
                container_of(led_cdev, struct alix_led, cdev);
 
        if (brightness)
-               outl(led_dev->on_value, led_dev->port);
+               outl(led_dev->on_value, gpio_base + led_dev->port);
        else
-               outl(led_dev->off_value, led_dev->port);
+               outl(led_dev->off_value, gpio_base + led_dev->port);
 }
 
 static struct alix_led alix_leds[] = {
@@ -41,7 +54,7 @@ static struct alix_led alix_leds[] = {
                        .name = "alix:1",
                        .brightness_set = alix_led_set,
                },
-               .port = 0x6100,
+               .port = 0x00,
                .on_value = 1 << 22,
                .off_value = 1 << 6,
        },
@@ -50,7 +63,7 @@ static struct alix_led alix_leds[] = {
                        .name = "alix:2",
                        .brightness_set = alix_led_set,
                },
-               .port = 0x6180,
+               .port = 0x80,
                .on_value = 1 << 25,
                .off_value = 1 << 9,
        },
@@ -59,7 +72,7 @@ static struct alix_led alix_leds[] = {
                        .name = "alix:3",
                        .brightness_set = alix_led_set,
                },
-               .port = 0x6180,
+               .port = 0x80,
                .on_value = 1 << 27,
                .off_value = 1 << 11,
        },
@@ -101,64 +114,104 @@ static struct platform_driver alix_led_driver = {
        },
 };
 
-static int __init alix_present(void)
+static int __init alix_present(unsigned long bios_phys,
+                               const char *alix_sig,
+                               size_t alix_sig_len)
 {
-       const unsigned long bios_phys = 0x000f0000;
        const size_t bios_len = 0x00010000;
-       const char alix_sig[] = "PC Engines ALIX.";
-       const size_t alix_sig_len = sizeof(alix_sig) - 1;
-
        const char *bios_virt;
        const char *scan_end;
        const char *p;
-       int ret = 0;
+       char name[64];
 
        if (force) {
                printk(KERN_NOTICE "%s: forced to skip BIOS test, "
                       "assume system has ALIX.2 style LEDs\n",
                       KBUILD_MODNAME);
-               ret = 1;
-               goto out;
+               return 1;
        }
 
        bios_virt = phys_to_virt(bios_phys);
        scan_end = bios_virt + bios_len - (alix_sig_len + 2);
        for (p = bios_virt; p < scan_end; p++) {
                const char *tail;
+               char *a;
 
-               if (memcmp(p, alix_sig, alix_sig_len) != 0) {
+               if (memcmp(p, alix_sig, alix_sig_len) != 0)
                        continue;
-               }
+
+               memcpy(name, p, sizeof(name));
+
+               /* remove the first \0 character from string */
+               a = strchr(name, '\0');
+               if (a)
+                       *a = ' ';
+
+               /* cut the string at a newline */
+               a = strchr(name, '\r');
+               if (a)
+                       *a = '\0';
 
                tail = p + alix_sig_len;
-               if ((tail[0] == '2' || tail[0] == '3') && tail[1] == '\0') {
+               if ((tail[0] == '2' || tail[0] == '3')) {
                        printk(KERN_INFO
                               "%s: system is recognized as \"%s\"\n",
-                              KBUILD_MODNAME, p);
-                       ret = 1;
-                       break;
+                              KBUILD_MODNAME, name);
+                       return 1;
                }
        }
 
-out:
-       return ret;
+       return 0;
 }
 
 static struct platform_device *pdev;
 
-static int __init alix_led_init(void)
+static int __init alix_pci_led_init(void)
 {
-       int ret;
+       u32 low, hi;
 
-       if (!alix_present()) {
-               ret = -ENODEV;
-               goto out;
+       if (pci_dev_present(divil_pci) == 0) {
+               printk(KERN_WARNING KBUILD_MODNAME": DIVIL not found\n");
+               return -ENODEV;
        }
 
-       /* enable output on GPIO for LED 1,2,3 */
-       outl(1 << 6, 0x6104);
-       outl(1 << 9, 0x6184);
-       outl(1 << 11, 0x6184);
+       /* Grab the GPIO I/O range */
+       rdmsr(MSR_LBAR_GPIO, low, hi);
+
+       /* Check the mask and whether GPIO is enabled (sanity check) */
+       if (hi != 0x0000f001) {
+               printk(KERN_WARNING KBUILD_MODNAME": GPIO not enabled\n");
+               return -ENODEV;
+       }
+
+       /* Mask off the IO base address */
+       gpio_base = low & 0x0000ff00;
+
+       if (!request_region(gpio_base, CS5535_GPIO_SIZE, KBUILD_MODNAME)) {
+               printk(KERN_ERR KBUILD_MODNAME": can't allocate I/O for GPIO\n");
+               return -ENODEV;
+       }
+
+       /* Set GPIO function to output */
+       outl(1 << 6, gpio_base + 0x04);
+       outl(1 << 9, gpio_base + 0x84);
+       outl(1 << 11, gpio_base + 0x84);
+
+       return 0;
+}
+
+static int __init alix_led_init(void)
+{
+       int ret = -ENODEV;
+       const char tinybios_sig[] = "PC Engines ALIX.";
+       const char coreboot_sig[] = "PC Engines\0ALIX.";
+
+       if (alix_present(0xf0000, tinybios_sig, sizeof(tinybios_sig) - 1) ||
+           alix_present(0x500, coreboot_sig, sizeof(coreboot_sig) - 1))
+               ret = alix_pci_led_init();
+
+       if (ret < 0)
+               return ret;
 
        pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
        if (!IS_ERR(pdev)) {
@@ -168,7 +221,6 @@ static int __init alix_led_init(void)
        } else
                ret = PTR_ERR(pdev);
 
-out:
        return ret;
 }
 
@@ -176,6 +228,7 @@ static void __exit alix_led_exit(void)
 {
        platform_device_unregister(pdev);
        platform_driver_unregister(&alix_led_driver);
+       release_region(gpio_base, CS5535_GPIO_SIZE);
 }
 
 module_init(alix_led_init);
index 8816806accd24a380c3877785f3bd71e5ddbbbf7..da5fb016b1a550fabfee5114bb11727a22c01749 100644 (file)
@@ -31,7 +31,7 @@ static struct led_classdev qube_front_led = {
        .name                   = "qube::front",
        .brightness             = LED_FULL,
        .brightness_set         = qube_front_led_set,
-       .default_trigger        = "ide-disk",
+       .default_trigger        = "default-on",
 };
 
 static int __devinit cobalt_qube_led_probe(struct platform_device *pdev)
@@ -43,7 +43,7 @@ static int __devinit cobalt_qube_led_probe(struct platform_device *pdev)
        if (!res)
                return -EBUSY;
 
-       led_port = ioremap(res->start, res->end - res->start + 1);
+       led_port = ioremap(res->start, resource_size(res));
        if (!led_port)
                return -ENOMEM;
 
index defc212105f3e4b12c216fadebbd82d1b9ab31ec..438d48384636f2d188e06a1ee648c41c190ce00c 100644 (file)
@@ -84,7 +84,7 @@ static int __devinit cobalt_raq_led_probe(struct platform_device *pdev)
        if (!res)
                return -EBUSY;
 
-       led_port = ioremap(res->start, res->end - res->start + 1);
+       led_port = ioremap(res->start, resource_size(res));
        if (!led_port)
                return -ENOMEM;
 
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c
new file mode 100644 (file)
index 0000000..fee40a8
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * LEDs driver for LT3593 controllers
+ *
+ * See the datasheet at http://cds.linear.com/docs/Datasheet/3593f.pdf
+ *
+ * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
+ *
+ * Based on leds-gpio.c,
+ *
+ *   Copyright (C) 2007 8D Technologies inc.
+ *   Raphael Assenat <raph@8d.com>
+ *   Copyright (C) 2008 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/workqueue.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+
+struct lt3593_led_data {
+       struct led_classdev cdev;
+       unsigned gpio;
+       struct work_struct work;
+       u8 new_level;
+};
+
+static void lt3593_led_work(struct work_struct *work)
+{
+       int pulses;
+       struct lt3593_led_data *led_dat =
+               container_of(work, struct lt3593_led_data, work);
+
+       /*
+        * The LT3593 resets its internal current level register to the maximum
+        * level on the first falling edge on the control pin. Each following
+        * falling edge decreases the current level by 625uA. Up to 32 pulses
+        * can be sent, so the maximum power reduction is 20mA.
+        * After a timeout of 128us, the value is taken from the register and
+        * applied is to the output driver.
+        */
+
+       if (led_dat->new_level == 0) {
+               gpio_set_value_cansleep(led_dat->gpio, 0);
+               return;
+       }
+
+       pulses = 32 - (led_dat->new_level * 32) / 255;
+
+       if (pulses == 0) {
+               gpio_set_value_cansleep(led_dat->gpio, 0);
+               mdelay(1);
+               gpio_set_value_cansleep(led_dat->gpio, 1);
+               return;
+       }
+
+       gpio_set_value_cansleep(led_dat->gpio, 1);
+
+       while (pulses--) {
+               gpio_set_value_cansleep(led_dat->gpio, 0);
+               udelay(1);
+               gpio_set_value_cansleep(led_dat->gpio, 1);
+               udelay(1);
+       }
+}
+
+static void lt3593_led_set(struct led_classdev *led_cdev,
+       enum led_brightness value)
+{
+       struct lt3593_led_data *led_dat =
+               container_of(led_cdev, struct lt3593_led_data, cdev);
+
+       led_dat->new_level = value;
+       schedule_work(&led_dat->work);
+}
+
+static int __devinit create_lt3593_led(const struct gpio_led *template,
+       struct lt3593_led_data *led_dat, struct device *parent)
+{
+       int ret, state;
+
+       /* skip leds on GPIOs that aren't available */
+       if (!gpio_is_valid(template->gpio)) {
+               printk(KERN_INFO "%s: skipping unavailable LT3593 LED at gpio %d (%s)\n",
+                               KBUILD_MODNAME, template->gpio, template->name);
+               return 0;
+       }
+
+       ret = gpio_request(template->gpio, template->name);
+       if (ret < 0)
+               return ret;
+
+       led_dat->cdev.name = template->name;
+       led_dat->cdev.default_trigger = template->default_trigger;
+       led_dat->gpio = template->gpio;
+
+       led_dat->cdev.brightness_set = lt3593_led_set;
+
+       state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
+       led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
+
+       if (!template->retain_state_suspended)
+               led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
+
+       ret = gpio_direction_output(led_dat->gpio, state);
+       if (ret < 0)
+               goto err;
+
+       INIT_WORK(&led_dat->work, lt3593_led_work);
+
+       ret = led_classdev_register(parent, &led_dat->cdev);
+       if (ret < 0)
+               goto err;
+
+       printk(KERN_INFO "%s: registered LT3593 LED '%s' at GPIO %d\n",
+               KBUILD_MODNAME, template->name, template->gpio);
+
+       return 0;
+
+err:
+       gpio_free(led_dat->gpio);
+       return ret;
+}
+
+static void delete_lt3593_led(struct lt3593_led_data *led)
+{
+       if (!gpio_is_valid(led->gpio))
+               return;
+
+       led_classdev_unregister(&led->cdev);
+       cancel_work_sync(&led->work);
+       gpio_free(led->gpio);
+}
+
+static int __devinit lt3593_led_probe(struct platform_device *pdev)
+{
+       struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
+       struct lt3593_led_data *leds_data;
+       int i, ret = 0;
+
+       if (!pdata)
+               return -EBUSY;
+
+       leds_data = kzalloc(sizeof(struct lt3593_led_data) * pdata->num_leds,
+                               GFP_KERNEL);
+       if (!leds_data)
+               return -ENOMEM;
+
+       for (i = 0; i < pdata->num_leds; i++) {
+               ret = create_lt3593_led(&pdata->leds[i], &leds_data[i],
+                                     &pdev->dev);
+               if (ret < 0)
+                       goto err;
+       }
+
+       platform_set_drvdata(pdev, leds_data);
+
+       return 0;
+
+err:
+       for (i = i - 1; i >= 0; i--)
+               delete_lt3593_led(&leds_data[i]);
+
+       kfree(leds_data);
+
+       return ret;
+}
+
+static int __devexit lt3593_led_remove(struct platform_device *pdev)
+{
+       int i;
+       struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
+       struct lt3593_led_data *leds_data;
+
+       leds_data = platform_get_drvdata(pdev);
+
+       for (i = 0; i < pdata->num_leds; i++)
+               delete_lt3593_led(&leds_data[i]);
+
+       kfree(leds_data);
+
+       return 0;
+}
+
+static struct platform_driver lt3593_led_driver = {
+       .probe          = lt3593_led_probe,
+       .remove         = __devexit_p(lt3593_led_remove),
+       .driver         = {
+               .name   = "leds-lt3593",
+               .owner  = THIS_MODULE,
+       },
+};
+
+MODULE_ALIAS("platform:leds-lt3593");
+
+static int __init lt3593_led_init(void)
+{
+       return platform_driver_register(&lt3593_led_driver);
+}
+
+static void __exit lt3593_led_exit(void)
+{
+       platform_driver_unregister(&lt3593_led_driver);
+}
+
+module_init(lt3593_led_init);
+module_exit(lt3593_led_exit);
+
+MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
+MODULE_DESCRIPTION("LED driver for LT3593 controllers");
+MODULE_LICENSE("GPL");
index cdfdc8714e1056962506519ee56d63d043410f3f..88b1dd091cfb9f3887ec052f75a3f4e0620d69ad 100644 (file)
@@ -27,7 +27,6 @@ struct led_pwm_data {
        struct pwm_device       *pwm;
        unsigned int            active_low;
        unsigned int            period;
-       unsigned int            max_brightness;
 };
 
 static void led_pwm_set(struct led_classdev *led_cdev,
@@ -35,7 +34,7 @@ static void led_pwm_set(struct led_classdev *led_cdev,
 {
        struct led_pwm_data *led_dat =
                container_of(led_cdev, struct led_pwm_data, cdev);
-       unsigned int max = led_dat->max_brightness;
+       unsigned int max = led_dat->cdev.max_brightness;
        unsigned int period =  led_dat->period;
 
        if (brightness == 0) {
@@ -77,10 +76,10 @@ static int led_pwm_probe(struct platform_device *pdev)
                led_dat->cdev.name = cur_led->name;
                led_dat->cdev.default_trigger = cur_led->default_trigger;
                led_dat->active_low = cur_led->active_low;
-               led_dat->max_brightness = cur_led->max_brightness;
                led_dat->period = cur_led->pwm_period_ns;
                led_dat->cdev.brightness_set = led_pwm_set;
                led_dat->cdev.brightness = LED_OFF;
+               led_dat->cdev.max_brightness = cur_led->max_brightness;
                led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
 
                ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
diff --git a/drivers/leds/leds-regulator.c b/drivers/leds/leds-regulator.c
new file mode 100644 (file)
index 0000000..7f00de3
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * leds-regulator.c - LED class driver for regulator driven LEDs.
+ *
+ * Copyright (C) 2009 Antonio Ospite <ospite@studenti.unina.it>
+ *
+ * Inspired by leds-wm8350 driver.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/workqueue.h>
+#include <linux/leds.h>
+#include <linux/leds-regulator.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+
+#define to_regulator_led(led_cdev) \
+       container_of(led_cdev, struct regulator_led, cdev)
+
+struct regulator_led {
+       struct led_classdev cdev;
+       enum led_brightness value;
+       int enabled;
+       struct mutex mutex;
+       struct work_struct work;
+
+       struct regulator *vcc;
+};
+
+static inline int led_regulator_get_max_brightness(struct regulator *supply)
+{
+       int ret;
+       int voltage = regulator_list_voltage(supply, 0);
+
+       if (voltage <= 0)
+               return 1;
+
+       /* even if regulator can't change voltages,
+        * we still assume it can change status
+        * and the LED can be turned on and off.
+        */
+       ret = regulator_set_voltage(supply, voltage, voltage);
+       if (ret < 0)
+               return 1;
+
+       return regulator_count_voltages(supply);
+}
+
+static int led_regulator_get_voltage(struct regulator *supply,
+               enum led_brightness brightness)
+{
+       if (brightness == 0)
+               return -EINVAL;
+
+       return regulator_list_voltage(supply, brightness - 1);
+}
+
+
+static void regulator_led_enable(struct regulator_led *led)
+{
+       int ret;
+
+       if (led->enabled)
+               return;
+
+       ret = regulator_enable(led->vcc);
+       if (ret != 0) {
+               dev_err(led->cdev.dev, "Failed to enable vcc: %d\n", ret);
+               return;
+       }
+
+       led->enabled = 1;
+}
+
+static void regulator_led_disable(struct regulator_led *led)
+{
+       int ret;
+
+       if (!led->enabled)
+               return;
+
+       ret = regulator_disable(led->vcc);
+       if (ret != 0) {
+               dev_err(led->cdev.dev, "Failed to disable vcc: %d\n", ret);
+               return;
+       }
+
+       led->enabled = 0;
+}
+
+static void regulator_led_set_value(struct regulator_led *led)
+{
+       int voltage;
+       int ret;
+
+       mutex_lock(&led->mutex);
+
+       if (led->value == LED_OFF) {
+               regulator_led_disable(led);
+               goto out;
+       }
+
+       if (led->cdev.max_brightness > 1) {
+               voltage = led_regulator_get_voltage(led->vcc, led->value);
+               dev_dbg(led->cdev.dev, "brightness: %d voltage: %d\n",
+                               led->value, voltage);
+
+               ret = regulator_set_voltage(led->vcc, voltage, voltage);
+               if (ret != 0)
+                       dev_err(led->cdev.dev, "Failed to set voltage %d: %d\n",
+                               voltage, ret);
+       }
+
+       regulator_led_enable(led);
+
+out:
+       mutex_unlock(&led->mutex);
+}
+
+static void led_work(struct work_struct *work)
+{
+       struct regulator_led *led;
+
+       led = container_of(work, struct regulator_led, work);
+       regulator_led_set_value(led);
+}
+
+static void regulator_led_brightness_set(struct led_classdev *led_cdev,
+                          enum led_brightness value)
+{
+       struct regulator_led *led = to_regulator_led(led_cdev);
+
+       led->value = value;
+       schedule_work(&led->work);
+}
+
+static int __devinit regulator_led_probe(struct platform_device *pdev)
+{
+       struct led_regulator_platform_data *pdata = pdev->dev.platform_data;
+       struct regulator_led *led;
+       struct regulator *vcc;
+       int ret = 0;
+
+       if (pdata == NULL) {
+               dev_err(&pdev->dev, "no platform data\n");
+               return -ENODEV;
+       }
+
+       vcc = regulator_get_exclusive(&pdev->dev, "vled");
+       if (IS_ERR(vcc)) {
+               dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name);
+               return PTR_ERR(vcc);
+       }
+
+       led = kzalloc(sizeof(*led), GFP_KERNEL);
+       if (led == NULL) {
+               ret = -ENOMEM;
+               goto err_vcc;
+       }
+
+       led->cdev.max_brightness = led_regulator_get_max_brightness(vcc);
+       if (pdata->brightness > led->cdev.max_brightness) {
+               dev_err(&pdev->dev, "Invalid default brightness %d\n",
+                               pdata->brightness);
+               ret = -EINVAL;
+               goto err_led;
+       }
+       led->value = pdata->brightness;
+
+       led->cdev.brightness_set = regulator_led_brightness_set;
+       led->cdev.name = pdata->name;
+       led->cdev.flags |= LED_CORE_SUSPENDRESUME;
+       led->vcc = vcc;
+
+       mutex_init(&led->mutex);
+       INIT_WORK(&led->work, led_work);
+
+       platform_set_drvdata(pdev, led);
+
+       ret = led_classdev_register(&pdev->dev, &led->cdev);
+       if (ret < 0) {
+               cancel_work_sync(&led->work);
+               goto err_led;
+       }
+
+       /* to expose the default value to userspace */
+       led->cdev.brightness = led->value;
+
+       /* Set the default led status */
+       regulator_led_set_value(led);
+
+       return 0;
+
+err_led:
+       kfree(led);
+err_vcc:
+       regulator_put(vcc);
+       return ret;
+}
+
+static int __devexit regulator_led_remove(struct platform_device *pdev)
+{
+       struct regulator_led *led = platform_get_drvdata(pdev);
+
+       led_classdev_unregister(&led->cdev);
+       cancel_work_sync(&led->work);
+       regulator_led_disable(led);
+       regulator_put(led->vcc);
+       kfree(led);
+       return 0;
+}
+
+static struct platform_driver regulator_led_driver = {
+       .driver = {
+                  .name  = "leds-regulator",
+                  .owner = THIS_MODULE,
+                  },
+       .probe  = regulator_led_probe,
+       .remove = __devexit_p(regulator_led_remove),
+};
+
+static int __init regulator_led_init(void)
+{
+       return platform_driver_register(&regulator_led_driver);
+}
+module_init(regulator_led_init);
+
+static void __exit regulator_led_exit(void)
+{
+       platform_driver_unregister(&regulator_led_driver);
+}
+module_exit(regulator_led_exit);
+
+MODULE_AUTHOR("Antonio Ospite <ospite@studenti.unina.it>");
+MODULE_DESCRIPTION("Regulator driven LED driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:leds-regulator");
diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
new file mode 100644 (file)
index 0000000..97f0498
--- /dev/null
@@ -0,0 +1,556 @@
+/*
+ * SS4200-E Hardware API
+ * Copyright (c) 2009, Intel Corporation.
+ * Copyright IBM Corporation, 2009
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Author: Dave Hansen <dave@sr71.net>
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/dmi.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/kernel.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/types.h>
+#include <linux/uaccess.h>
+
+MODULE_AUTHOR("Rodney Girod <rgirod@confocus.com>, Dave Hansen <dave@sr71.net>");
+MODULE_DESCRIPTION("Intel NAS/Home Server ICH7 GPIO Driver");
+MODULE_LICENSE("GPL");
+
+/*
+ * ICH7 LPC/GPIO PCI Config register offsets
+ */
+#define PMBASE         0x040
+#define GPIO_BASE      0x048
+#define GPIO_CTRL      0x04c
+#define GPIO_EN                0x010
+
+/*
+ * The ICH7 GPIO register block is 64 bytes in size.
+ */
+#define ICH7_GPIO_SIZE 64
+
+/*
+ * Define register offsets within the ICH7 register block.
+ */
+#define GPIO_USE_SEL   0x000
+#define GP_IO_SEL      0x004
+#define GP_LVL         0x00c
+#define GPO_BLINK      0x018
+#define GPI_INV                0x030
+#define GPIO_USE_SEL2  0x034
+#define GP_IO_SEL2     0x038
+#define GP_LVL2                0x03c
+
+/*
+ * PCI ID of the Intel ICH7 LPC Device within which the GPIO block lives.
+ */
+static struct pci_device_id ich7_lpc_pci_id[] =
+{
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0) },
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1) },
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_30) },
+       { } /* NULL entry */
+};
+
+MODULE_DEVICE_TABLE(pci, ich7_lpc_pci_id);
+
+static int __init ss4200_led_dmi_callback(const struct dmi_system_id *id)
+{
+       pr_info("detected '%s'\n", id->ident);
+       return 1;
+}
+
+static unsigned int __initdata nodetect;
+module_param_named(nodetect, nodetect, bool, 0);
+MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
+
+/*
+ * struct nas_led_whitelist - List of known good models
+ *
+ * Contains the known good models this driver is compatible with.
+ * When adding a new model try to be as strict as possible. This
+ * makes it possible to keep the false positives (the model is
+ * detected as working, but in reality it is not) as low as
+ * possible.
+ */
+static struct dmi_system_id __initdata nas_led_whitelist[] = {
+       {
+               .callback = ss4200_led_dmi_callback,
+               .ident = "Intel SS4200-E",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "SS4200-E"),
+                       DMI_MATCH(DMI_PRODUCT_VERSION, "1.00.00")
+               }
+       },
+};
+
+/*
+ * Base I/O address assigned to the Power Management register block
+ */
+static u32 g_pm_io_base;
+
+/*
+ * Base I/O address assigned to the ICH7 GPIO register block
+ */
+static u32 nas_gpio_io_base;
+
+/*
+ * When we successfully register a region, we are returned a resource.
+ * We use these to identify which regions we need to release on our way
+ * back out.
+ */
+static struct resource *gp_gpio_resource;
+
+struct nasgpio_led {
+       char *name;
+       u32 gpio_bit;
+       struct led_classdev led_cdev;
+};
+
+/*
+ * gpio_bit(s) are the ICH7 GPIO bit assignments
+ */
+static struct nasgpio_led nasgpio_leds[] = {
+       { .name = "hdd1:blue:sata",     .gpio_bit = 0 },
+       { .name = "hdd1:amber:sata",    .gpio_bit = 1 },
+       { .name = "hdd2:blue:sata",     .gpio_bit = 2 },
+       { .name = "hdd2:amber:sata",    .gpio_bit = 3 },
+       { .name = "hdd3:blue:sata",     .gpio_bit = 4 },
+       { .name = "hdd3:amber:sata",    .gpio_bit = 5 },
+       { .name = "hdd4:blue:sata",     .gpio_bit = 6 },
+       { .name = "hdd4:amber:sata",    .gpio_bit = 7 },
+       { .name = "power:blue:power",   .gpio_bit = 27},
+       { .name = "power:amber:power",  .gpio_bit = 28},
+};
+
+#define NAS_RECOVERY   0x00000400      /* GPIO10 */
+
+static struct nasgpio_led *
+led_classdev_to_nasgpio_led(struct led_classdev *led_cdev)
+{
+       return container_of(led_cdev, struct nasgpio_led, led_cdev);
+}
+
+static struct nasgpio_led *get_led_named(char *name)
+{
+       int i;
+       for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++) {
+               if (strcmp(nasgpio_leds[i].name, name))
+                       continue;
+               return &nasgpio_leds[i];
+       }
+       return NULL;
+}
+
+/*
+ * This protects access to the gpio ports.
+ */
+static DEFINE_SPINLOCK(nasgpio_gpio_lock);
+
+/*
+ * There are two gpio ports, one for blinking and the other
+ * for power.  @port tells us if we're doing blinking or
+ * power control.
+ *
+ * Caller must hold nasgpio_gpio_lock
+ */
+static void __nasgpio_led_set_attr(struct led_classdev *led_cdev,
+                                  u32 port, u32 value)
+{
+       struct nasgpio_led *led = led_classdev_to_nasgpio_led(led_cdev);
+       u32 gpio_out;
+
+       gpio_out = inl(nas_gpio_io_base + port);
+       if (value)
+               gpio_out |= (1<<led->gpio_bit);
+       else
+               gpio_out &= ~(1<<led->gpio_bit);
+
+       outl(gpio_out, nas_gpio_io_base + port);
+}
+
+static void nasgpio_led_set_attr(struct led_classdev *led_cdev,
+                                u32 port, u32 value)
+{
+       spin_lock(&nasgpio_gpio_lock);
+       __nasgpio_led_set_attr(led_cdev, port, value);
+       spin_unlock(&nasgpio_gpio_lock);
+}
+
+u32 nasgpio_led_get_attr(struct led_classdev *led_cdev, u32 port)
+{
+       struct nasgpio_led *led = led_classdev_to_nasgpio_led(led_cdev);
+       u32 gpio_in;
+
+       spin_lock(&nasgpio_gpio_lock);
+       gpio_in = inl(nas_gpio_io_base + port);
+       spin_unlock(&nasgpio_gpio_lock);
+       if (gpio_in & (1<<led->gpio_bit))
+               return 1;
+       return 0;
+}
+
+/*
+ * There is actual brightness control in the hardware,
+ * but it is via smbus commands and not implemented
+ * in this driver.
+ */
+static void nasgpio_led_set_brightness(struct led_classdev *led_cdev,
+                                      enum led_brightness brightness)
+{
+       u32 setting = 0;
+       if (brightness >= LED_HALF)
+               setting = 1;
+       /*
+        * Hold the lock across both operations.  This ensures
+        * consistency so that both the "turn off blinking"
+        * and "turn light off" operations complete as a set.
+        */
+       spin_lock(&nasgpio_gpio_lock);
+       /*
+        * LED class documentation asks that past blink state
+        * be disabled when brightness is turned to zero.
+        */
+       if (brightness == 0)
+               __nasgpio_led_set_attr(led_cdev, GPO_BLINK, 0);
+       __nasgpio_led_set_attr(led_cdev, GP_LVL, setting);
+       spin_unlock(&nasgpio_gpio_lock);
+}
+
+static int nasgpio_led_set_blink(struct led_classdev *led_cdev,
+                                unsigned long *delay_on,
+                                unsigned long *delay_off)
+{
+       u32 setting = 1;
+       if (!(*delay_on == 0 && *delay_off == 0) &&
+           !(*delay_on == 500 && *delay_off == 500))
+               return -EINVAL;
+       /*
+        * These are very approximate.
+        */
+       *delay_on = 500;
+       *delay_off = 500;
+
+       nasgpio_led_set_attr(led_cdev, GPO_BLINK, setting);
+
+       return 0;
+}
+
+
+/*
+ * Initialize the ICH7 GPIO registers for NAS usage.  The BIOS should have
+ * already taken care of this, but we will do so in a non destructive manner
+ * so that we have what we need whether the BIOS did it or not.
+ */
+static int __devinit ich7_gpio_init(struct device *dev)
+{
+       int i;
+       u32 config_data = 0;
+       u32 all_nas_led = 0;
+
+       for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++)
+               all_nas_led |= (1<<nasgpio_leds[i].gpio_bit);
+
+       spin_lock(&nasgpio_gpio_lock);
+       /*
+        * We need to enable all of the GPIO lines used by the NAS box,
+        * so we will read the current Use Selection and add our usage
+        * to it.  This should be benign with regard to the original
+        * BIOS configuration.
+        */
+       config_data = inl(nas_gpio_io_base + GPIO_USE_SEL);
+       dev_dbg(dev, ": Data read from GPIO_USE_SEL = 0x%08x\n", config_data);
+       config_data |= all_nas_led + NAS_RECOVERY;
+       outl(config_data, nas_gpio_io_base + GPIO_USE_SEL);
+       config_data = inl(nas_gpio_io_base + GPIO_USE_SEL);
+       dev_dbg(dev, ": GPIO_USE_SEL = 0x%08x\n\n", config_data);
+
+       /*
+        * The LED GPIO outputs need to be configured for output, so we
+        * will ensure that all LED lines are cleared for output and the
+        * RECOVERY line ready for input.  This too should be benign with
+        * regard to BIOS configuration.
+        */
+       config_data = inl(nas_gpio_io_base + GP_IO_SEL);
+       dev_dbg(dev, ": Data read from GP_IO_SEL = 0x%08x\n",
+                                       config_data);
+       config_data &= ~all_nas_led;
+       config_data |= NAS_RECOVERY;
+       outl(config_data, nas_gpio_io_base + GP_IO_SEL);
+       config_data = inl(nas_gpio_io_base + GP_IO_SEL);
+       dev_dbg(dev, ": GP_IO_SEL = 0x%08x\n", config_data);
+
+       /*
+        * In our final system, the BIOS will initialize the state of all
+        * of the LEDs.  For now, we turn them all off (or Low).
+        */
+       config_data = inl(nas_gpio_io_base + GP_LVL);
+       dev_dbg(dev, ": Data read from GP_LVL = 0x%08x\n", config_data);
+       /*
+        * In our final system, the BIOS will initialize the blink state of all
+        * of the LEDs.  For now, we turn blink off for all of them.
+        */
+       config_data = inl(nas_gpio_io_base + GPO_BLINK);
+       dev_dbg(dev, ": Data read from GPO_BLINK = 0x%08x\n", config_data);
+
+       /*
+        * At this moment, I am unsure if anything needs to happen with GPI_INV
+        */
+       config_data = inl(nas_gpio_io_base + GPI_INV);
+       dev_dbg(dev, ": Data read from GPI_INV = 0x%08x\n", config_data);
+
+       spin_unlock(&nasgpio_gpio_lock);
+       return 0;
+}
+
+static void ich7_lpc_cleanup(struct device *dev)
+{
+       /*
+        * If we were given exclusive use of the GPIO
+        * I/O Address range, we must return it.
+        */
+       if (gp_gpio_resource) {
+               dev_dbg(dev, ": Releasing GPIO I/O addresses\n");
+               release_region(nas_gpio_io_base, ICH7_GPIO_SIZE);
+               gp_gpio_resource = NULL;
+       }
+}
+
+/*
+ * The OS has determined that the LPC of the Intel ICH7 Southbridge is present
+ * so we can retrive the required operational information and prepare the GPIO.
+ */
+static struct pci_dev *nas_gpio_pci_dev;
+static int __devinit ich7_lpc_probe(struct pci_dev *dev,
+                                   const struct pci_device_id *id)
+{
+       int status;
+       u32 gc = 0;
+
+       status = pci_enable_device(dev);
+       if (status) {
+               dev_err(&dev->dev, "pci_enable_device failed\n");
+               return -EIO;
+       }
+
+       nas_gpio_pci_dev = dev;
+       status = pci_read_config_dword(dev, PMBASE, &g_pm_io_base);
+       if (status)
+               goto out;
+       g_pm_io_base &= 0x00000ff80;
+
+       status = pci_read_config_dword(dev, GPIO_CTRL, &gc);
+       if (!(GPIO_EN & gc)) {
+               status = -EEXIST;
+               dev_info(&dev->dev,
+                          "ERROR: The LPC GPIO Block has not been enabled.\n");
+               goto out;
+       }
+
+       status = pci_read_config_dword(dev, GPIO_BASE, &nas_gpio_io_base);
+       if (0 > status) {
+               dev_info(&dev->dev, "Unable to read GPIOBASE.\n");
+               goto out;
+       }
+       dev_dbg(&dev->dev, ": GPIOBASE = 0x%08x\n", nas_gpio_io_base);
+       nas_gpio_io_base &= 0x00000ffc0;
+
+       /*
+        * Insure that we have exclusive access to the GPIO I/O address range.
+        */
+       gp_gpio_resource = request_region(nas_gpio_io_base, ICH7_GPIO_SIZE,
+                                         KBUILD_MODNAME);
+       if (NULL == gp_gpio_resource) {
+               dev_info(&dev->dev,
+                        "ERROR Unable to register GPIO I/O addresses.\n");
+               status = -1;
+               goto out;
+       }
+
+       /*
+        * Initialize the GPIO for NAS/Home Server Use
+        */
+       ich7_gpio_init(&dev->dev);
+
+out:
+       if (status) {
+               ich7_lpc_cleanup(&dev->dev);
+               pci_disable_device(dev);
+       }
+       return status;
+}
+
+static void ich7_lpc_remove(struct pci_dev *dev)
+{
+       ich7_lpc_cleanup(&dev->dev);
+       pci_disable_device(dev);
+}
+
+/*
+ * pci_driver structure passed to the PCI modules
+ */
+static struct pci_driver nas_gpio_pci_driver = {
+       .name = KBUILD_MODNAME,
+       .id_table = ich7_lpc_pci_id,
+       .probe = ich7_lpc_probe,
+       .remove = ich7_lpc_remove,
+};
+
+static struct led_classdev *get_classdev_for_led_nr(int nr)
+{
+       struct nasgpio_led *nas_led = &nasgpio_leds[nr];
+       struct led_classdev *led = &nas_led->led_cdev;
+       return led;
+}
+
+
+static void set_power_light_amber_noblink(void)
+{
+       struct nasgpio_led *amber = get_led_named("power:amber:power");
+       struct nasgpio_led *blue = get_led_named("power:blue:power");
+
+       if (!amber || !blue)
+               return;
+       /*
+        * LED_OFF implies disabling future blinking
+        */
+       pr_debug("setting blue off and amber on\n");
+
+       nasgpio_led_set_brightness(&blue->led_cdev, LED_OFF);
+       nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL);
+}
+
+static ssize_t nas_led_blink_show(struct device *dev,
+                                 struct device_attribute *attr, char *buf)
+{
+       struct led_classdev *led = dev_get_drvdata(dev);
+       int blinking = 0;
+       if (nasgpio_led_get_attr(led, GPO_BLINK))
+               blinking = 1;
+       return sprintf(buf, "%u\n", blinking);
+}
+
+static ssize_t nas_led_blink_store(struct device *dev,
+                                  struct device_attribute *attr,
+                                  const char *buf, size_t size)
+{
+       int ret;
+       struct led_classdev *led = dev_get_drvdata(dev);
+       unsigned long blink_state;
+
+       ret = strict_strtoul(buf, 10, &blink_state);
+       if (ret)
+               return ret;
+
+       nasgpio_led_set_attr(led, GPO_BLINK, blink_state);
+
+       return size;
+}
+
+static DEVICE_ATTR(blink, 0644, nas_led_blink_show, nas_led_blink_store);
+
+static int register_nasgpio_led(int led_nr)
+{
+       int ret;
+       struct nasgpio_led *nas_led = &nasgpio_leds[led_nr];
+       struct led_classdev *led = get_classdev_for_led_nr(led_nr);
+
+       led->name = nas_led->name;
+       led->brightness = LED_OFF;
+       if (nasgpio_led_get_attr(led, GP_LVL))
+               led->brightness = LED_FULL;
+       led->brightness_set = nasgpio_led_set_brightness;
+       led->blink_set = nasgpio_led_set_blink;
+       ret = led_classdev_register(&nas_gpio_pci_dev->dev, led);
+       if (ret)
+               return ret;
+       ret = device_create_file(led->dev, &dev_attr_blink);
+       if (ret)
+               led_classdev_unregister(led);
+       return ret;
+}
+
+static void unregister_nasgpio_led(int led_nr)
+{
+       struct led_classdev *led = get_classdev_for_led_nr(led_nr);
+       led_classdev_unregister(led);
+       device_remove_file(led->dev, &dev_attr_blink);
+}
+/*
+ * module load/initialization
+ */
+static int __init nas_gpio_init(void)
+{
+       int i;
+       int ret = 0;
+       int nr_devices = 0;
+
+       nr_devices = dmi_check_system(nas_led_whitelist);
+       if (nodetect) {
+               pr_info("skipping hardware autodetection\n");
+               pr_info("Please send 'dmidecode' output to dave@sr71.net\n");
+               nr_devices++;
+       }
+
+       if (nr_devices <= 0) {
+               pr_info("no LED devices found\n");
+               return -ENODEV;
+       }
+
+       pr_info("registering PCI driver\n");
+       ret = pci_register_driver(&nas_gpio_pci_driver);
+       if (ret)
+               return ret;
+       for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++) {
+               ret = register_nasgpio_led(i);
+               if (ret)
+                       goto out_err;
+       }
+       /*
+        * When the system powers on, the BIOS leaves the power
+        * light blue and blinking.  This will turn it solid
+        * amber once the driver is loaded.
+        */
+       set_power_light_amber_noblink();
+       return 0;
+out_err:
+       for (; i >= 0; i--)
+               unregister_nasgpio_led(i);
+       pci_unregister_driver(&nas_gpio_pci_driver);
+       return ret;
+}
+
+/*
+ * module unload
+ */
+static void __exit nas_gpio_exit(void)
+{
+       int i;
+       pr_info("Unregistering driver\n");
+       for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++)
+               unregister_nasgpio_led(i);
+       pci_unregister_driver(&nas_gpio_pci_driver);
+}
+
+module_init(nas_gpio_init);
+module_exit(nas_gpio_exit);
index 3b83406de7520b8052b73906992f2fa34e1b3891..38b3378be442b3d6501b8ffb9aa67e8eaba21ef4 100644 (file)
@@ -83,7 +83,7 @@ static ssize_t led_delay_on_store(struct device *dev,
        unsigned long state = simple_strtoul(buf, &after, 10);
        size_t count = after - buf;
 
-       if (*after && isspace(*after))
+       if (isspace(*after))
                count++;
 
        if (count == size) {
@@ -127,7 +127,7 @@ static ssize_t led_delay_off_store(struct device *dev,
        unsigned long state = simple_strtoul(buf, &after, 10);
        size_t count = after - buf;
 
-       if (*after && isspace(*after))
+       if (isspace(*after))
                count++;
 
        if (count == size) {
index e412980763bded7f0de5f05c01e9a896e254ef7e..a93637223c8d287f6ff41ecf1de0e1095dbecb29 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2003 Christophe Saout <christophe@saout.de>
  * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
- * Copyright (C) 2006-2008 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2006-2009 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the GPL.
  */
@@ -71,10 +71,21 @@ struct crypt_iv_operations {
        int (*ctr)(struct crypt_config *cc, struct dm_target *ti,
                   const char *opts);
        void (*dtr)(struct crypt_config *cc);
-       const char *(*status)(struct crypt_config *cc);
+       int (*init)(struct crypt_config *cc);
+       int (*wipe)(struct crypt_config *cc);
        int (*generator)(struct crypt_config *cc, u8 *iv, sector_t sector);
 };
 
+struct iv_essiv_private {
+       struct crypto_cipher *tfm;
+       struct crypto_hash *hash_tfm;
+       u8 *salt;
+};
+
+struct iv_benbi_private {
+       int shift;
+};
+
 /*
  * Crypt: maps a linear range of a block device
  * and encrypts / decrypts at the same time.
@@ -102,8 +113,8 @@ struct crypt_config {
        struct crypt_iv_operations *iv_gen_ops;
        char *iv_mode;
        union {
-               struct crypto_cipher *essiv_tfm;
-               int benbi_shift;
+               struct iv_essiv_private essiv;
+               struct iv_benbi_private benbi;
        } iv_gen_private;
        sector_t iv_offset;
        unsigned int iv_size;
@@ -147,6 +158,9 @@ static void kcryptd_queue_crypt(struct dm_crypt_io *io);
  * plain: the initial vector is the 32-bit little-endian version of the sector
  *        number, padded with zeros if necessary.
  *
+ * plain64: the initial vector is the 64-bit little-endian version of the sector
+ *        number, padded with zeros if necessary.
+ *
  * essiv: "encrypted sector|salt initial vector", the sector number is
  *        encrypted with the bulk cipher using a salt as key. The salt
  *        should be derived from the bulk cipher's key via hashing.
@@ -169,88 +183,123 @@ static int crypt_iv_plain_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
        return 0;
 }
 
-static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
-                             const char *opts)
+static int crypt_iv_plain64_gen(struct crypt_config *cc, u8 *iv,
+                               sector_t sector)
 {
-       struct crypto_cipher *essiv_tfm;
-       struct crypto_hash *hash_tfm;
+       memset(iv, 0, cc->iv_size);
+       *(u64 *)iv = cpu_to_le64(sector);
+
+       return 0;
+}
+
+/* Initialise ESSIV - compute salt but no local memory allocations */
+static int crypt_iv_essiv_init(struct crypt_config *cc)
+{
+       struct iv_essiv_private *essiv = &cc->iv_gen_private.essiv;
        struct hash_desc desc;
        struct scatterlist sg;
-       unsigned int saltsize;
-       u8 *salt;
        int err;
 
-       if (opts == NULL) {
+       sg_init_one(&sg, cc->key, cc->key_size);
+       desc.tfm = essiv->hash_tfm;
+       desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
+
+       err = crypto_hash_digest(&desc, &sg, cc->key_size, essiv->salt);
+       if (err)
+               return err;
+
+       return crypto_cipher_setkey(essiv->tfm, essiv->salt,
+                                   crypto_hash_digestsize(essiv->hash_tfm));
+}
+
+/* Wipe salt and reset key derived from volume key */
+static int crypt_iv_essiv_wipe(struct crypt_config *cc)
+{
+       struct iv_essiv_private *essiv = &cc->iv_gen_private.essiv;
+       unsigned salt_size = crypto_hash_digestsize(essiv->hash_tfm);
+
+       memset(essiv->salt, 0, salt_size);
+
+       return crypto_cipher_setkey(essiv->tfm, essiv->salt, salt_size);
+}
+
+static void crypt_iv_essiv_dtr(struct crypt_config *cc)
+{
+       struct iv_essiv_private *essiv = &cc->iv_gen_private.essiv;
+
+       crypto_free_cipher(essiv->tfm);
+       essiv->tfm = NULL;
+
+       crypto_free_hash(essiv->hash_tfm);
+       essiv->hash_tfm = NULL;
+
+       kzfree(essiv->salt);
+       essiv->salt = NULL;
+}
+
+static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
+                             const char *opts)
+{
+       struct crypto_cipher *essiv_tfm = NULL;
+       struct crypto_hash *hash_tfm = NULL;
+       u8 *salt = NULL;
+       int err;
+
+       if (!opts) {
                ti->error = "Digest algorithm missing for ESSIV mode";
                return -EINVAL;
        }
 
-       /* Hash the cipher key with the given hash algorithm */
+       /* Allocate hash algorithm */
        hash_tfm = crypto_alloc_hash(opts, 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(hash_tfm)) {
                ti->error = "Error initializing ESSIV hash";
-               return PTR_ERR(hash_tfm);
+               err = PTR_ERR(hash_tfm);
+               goto bad;
        }
 
-       saltsize = crypto_hash_digestsize(hash_tfm);
-       salt = kmalloc(saltsize, GFP_KERNEL);
-       if (salt == NULL) {
+       salt = kzalloc(crypto_hash_digestsize(hash_tfm), GFP_KERNEL);
+       if (!salt) {
                ti->error = "Error kmallocing salt storage in ESSIV";
-               crypto_free_hash(hash_tfm);
-               return -ENOMEM;
+               err = -ENOMEM;
+               goto bad;
        }
 
-       sg_init_one(&sg, cc->key, cc->key_size);
-       desc.tfm = hash_tfm;
-       desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
-       err = crypto_hash_digest(&desc, &sg, cc->key_size, salt);
-       crypto_free_hash(hash_tfm);
-
-       if (err) {
-               ti->error = "Error calculating hash in ESSIV";
-               kfree(salt);
-               return err;
-       }
-
-       /* Setup the essiv_tfm with the given salt */
+       /* Allocate essiv_tfm */
        essiv_tfm = crypto_alloc_cipher(cc->cipher, 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(essiv_tfm)) {
                ti->error = "Error allocating crypto tfm for ESSIV";
-               kfree(salt);
-               return PTR_ERR(essiv_tfm);
+               err = PTR_ERR(essiv_tfm);
+               goto bad;
        }
        if (crypto_cipher_blocksize(essiv_tfm) !=
            crypto_ablkcipher_ivsize(cc->tfm)) {
                ti->error = "Block size of ESSIV cipher does "
                            "not match IV size of block cipher";
-               crypto_free_cipher(essiv_tfm);
-               kfree(salt);
-               return -EINVAL;
+               err = -EINVAL;
+               goto bad;
        }
-       err = crypto_cipher_setkey(essiv_tfm, salt, saltsize);
-       if (err) {
-               ti->error = "Failed to set key for ESSIV cipher";
-               crypto_free_cipher(essiv_tfm);
-               kfree(salt);
-               return err;
-       }
-       kfree(salt);
 
-       cc->iv_gen_private.essiv_tfm = essiv_tfm;
+       cc->iv_gen_private.essiv.salt = salt;
+       cc->iv_gen_private.essiv.tfm = essiv_tfm;
+       cc->iv_gen_private.essiv.hash_tfm = hash_tfm;
+
        return 0;
-}
 
-static void crypt_iv_essiv_dtr(struct crypt_config *cc)
-{
-       crypto_free_cipher(cc->iv_gen_private.essiv_tfm);
-       cc->iv_gen_private.essiv_tfm = NULL;
+bad:
+       if (essiv_tfm && !IS_ERR(essiv_tfm))
+               crypto_free_cipher(essiv_tfm);
+       if (hash_tfm && !IS_ERR(hash_tfm))
+               crypto_free_hash(hash_tfm);
+       kfree(salt);
+       return err;
 }
 
 static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
 {
        memset(iv, 0, cc->iv_size);
        *(u64 *)iv = cpu_to_le64(sector);
-       crypto_cipher_encrypt_one(cc->iv_gen_private.essiv_tfm, iv, iv);
+       crypto_cipher_encrypt_one(cc->iv_gen_private.essiv.tfm, iv, iv);
        return 0;
 }
 
@@ -273,7 +322,7 @@ static int crypt_iv_benbi_ctr(struct crypt_config *cc, struct dm_target *ti,
                return -EINVAL;
        }
 
-       cc->iv_gen_private.benbi_shift = 9 - log;
+       cc->iv_gen_private.benbi.shift = 9 - log;
 
        return 0;
 }
@@ -288,7 +337,7 @@ static int crypt_iv_benbi_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
 
        memset(iv, 0, cc->iv_size - sizeof(u64)); /* rest is cleared below */
 
-       val = cpu_to_be64(((u64)sector << cc->iv_gen_private.benbi_shift) + 1);
+       val = cpu_to_be64(((u64)sector << cc->iv_gen_private.benbi.shift) + 1);
        put_unaligned(val, (__be64 *)(iv + cc->iv_size - sizeof(u64)));
 
        return 0;
@@ -305,9 +354,15 @@ static struct crypt_iv_operations crypt_iv_plain_ops = {
        .generator = crypt_iv_plain_gen
 };
 
+static struct crypt_iv_operations crypt_iv_plain64_ops = {
+       .generator = crypt_iv_plain64_gen
+};
+
 static struct crypt_iv_operations crypt_iv_essiv_ops = {
        .ctr       = crypt_iv_essiv_ctr,
        .dtr       = crypt_iv_essiv_dtr,
+       .init      = crypt_iv_essiv_init,
+       .wipe      = crypt_iv_essiv_wipe,
        .generator = crypt_iv_essiv_gen
 };
 
@@ -934,14 +989,14 @@ static int crypt_set_key(struct crypt_config *cc, char *key)
 
        set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
 
-       return 0;
+       return crypto_ablkcipher_setkey(cc->tfm, cc->key, cc->key_size);
 }
 
 static int crypt_wipe_key(struct crypt_config *cc)
 {
        clear_bit(DM_CRYPT_KEY_VALID, &cc->flags);
        memset(&cc->key, 0, cc->key_size * sizeof(u8));
-       return 0;
+       return crypto_ablkcipher_setkey(cc->tfm, cc->key, cc->key_size);
 }
 
 /*
@@ -983,11 +1038,6 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                return -ENOMEM;
        }
 
-       if (crypt_set_key(cc, argv[1])) {
-               ti->error = "Error decoding key";
-               goto bad_cipher;
-       }
-
        /* Compatibility mode for old dm-crypt cipher strings */
        if (!chainmode || (strcmp(chainmode, "plain") == 0 && !ivmode)) {
                chainmode = "cbc";
@@ -1015,6 +1065,11 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        strcpy(cc->chainmode, chainmode);
        cc->tfm = tfm;
 
+       if (crypt_set_key(cc, argv[1]) < 0) {
+               ti->error = "Error decoding and setting key";
+               goto bad_ivmode;
+       }
+
        /*
         * Choose ivmode. Valid modes: "plain", "essiv:<esshash>", "benbi".
         * See comments at iv code
@@ -1024,6 +1079,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                cc->iv_gen_ops = NULL;
        else if (strcmp(ivmode, "plain") == 0)
                cc->iv_gen_ops = &crypt_iv_plain_ops;
+       else if (strcmp(ivmode, "plain64") == 0)
+               cc->iv_gen_ops = &crypt_iv_plain64_ops;
        else if (strcmp(ivmode, "essiv") == 0)
                cc->iv_gen_ops = &crypt_iv_essiv_ops;
        else if (strcmp(ivmode, "benbi") == 0)
@@ -1039,6 +1096,12 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
            cc->iv_gen_ops->ctr(cc, ti, ivopts) < 0)
                goto bad_ivmode;
 
+       if (cc->iv_gen_ops && cc->iv_gen_ops->init &&
+           cc->iv_gen_ops->init(cc) < 0) {
+               ti->error = "Error initialising IV";
+               goto bad_slab_pool;
+       }
+
        cc->iv_size = crypto_ablkcipher_ivsize(tfm);
        if (cc->iv_size)
                /* at least a 64 bit sector number should fit in our buffer */
@@ -1085,11 +1148,6 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
                goto bad_bs;
        }
 
-       if (crypto_ablkcipher_setkey(tfm, cc->key, key_size) < 0) {
-               ti->error = "Error setting key";
-               goto bad_device;
-       }
-
        if (sscanf(argv[2], "%llu", &tmpll) != 1) {
                ti->error = "Invalid iv_offset sector";
                goto bad_device;
@@ -1278,6 +1336,7 @@ static void crypt_resume(struct dm_target *ti)
 static int crypt_message(struct dm_target *ti, unsigned argc, char **argv)
 {
        struct crypt_config *cc = ti->private;
+       int ret = -EINVAL;
 
        if (argc < 2)
                goto error;
@@ -1287,10 +1346,22 @@ static int crypt_message(struct dm_target *ti, unsigned argc, char **argv)
                        DMWARN("not suspended during key manipulation.");
                        return -EINVAL;
                }
-               if (argc == 3 && !strnicmp(argv[1], MESG_STR("set")))
-                       return crypt_set_key(cc, argv[2]);
-               if (argc == 2 && !strnicmp(argv[1], MESG_STR("wipe")))
+               if (argc == 3 && !strnicmp(argv[1], MESG_STR("set"))) {
+                       ret = crypt_set_key(cc, argv[2]);
+                       if (ret)
+                               return ret;
+                       if (cc->iv_gen_ops && cc->iv_gen_ops->init)
+                               ret = cc->iv_gen_ops->init(cc);
+                       return ret;
+               }
+               if (argc == 2 && !strnicmp(argv[1], MESG_STR("wipe"))) {
+                       if (cc->iv_gen_ops && cc->iv_gen_ops->wipe) {
+                               ret = cc->iv_gen_ops->wipe(cc);
+                               if (ret)
+                                       return ret;
+                       }
                        return crypt_wipe_key(cc);
+               }
        }
 
 error:
index 7dbe652efb5aabe8b42bbae0847ab9d062197495..2b7907b6dd094611c8cc9f31fbead6d7b553e1d7 100644 (file)
@@ -172,7 +172,8 @@ int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
        }
 
        /* Validate the chunk size against the device block size */
-       if (chunk_size % (bdev_logical_block_size(store->cow->bdev) >> 9)) {
+       if (chunk_size %
+           (bdev_logical_block_size(dm_snap_cow(store->snap)->bdev) >> 9)) {
                *error = "Chunk size is not a multiple of device blocksize";
                return -EINVAL;
        }
@@ -190,6 +191,7 @@ int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
 }
 
 int dm_exception_store_create(struct dm_target *ti, int argc, char **argv,
+                             struct dm_snapshot *snap,
                              unsigned *args_used,
                              struct dm_exception_store **store)
 {
@@ -198,7 +200,7 @@ int dm_exception_store_create(struct dm_target *ti, int argc, char **argv,
        struct dm_exception_store *tmp_store;
        char persistent;
 
-       if (argc < 3) {
+       if (argc < 2) {
                ti->error = "Insufficient exception store arguments";
                return -EINVAL;
        }
@@ -209,14 +211,15 @@ int dm_exception_store_create(struct dm_target *ti, int argc, char **argv,
                return -ENOMEM;
        }
 
-       persistent = toupper(*argv[1]);
+       persistent = toupper(*argv[0]);
        if (persistent == 'P')
                type = get_type("P");
        else if (persistent == 'N')
                type = get_type("N");
        else {
                ti->error = "Persistent flag is not P or N";
-               return -EINVAL;
+               r = -EINVAL;
+               goto bad_type;
        }
 
        if (!type) {
@@ -226,32 +229,23 @@ int dm_exception_store_create(struct dm_target *ti, int argc, char **argv,
        }
 
        tmp_store->type = type;
-       tmp_store->ti = ti;
-
-       r = dm_get_device(ti, argv[0], 0, 0,
-                         FMODE_READ | FMODE_WRITE, &tmp_store->cow);
-       if (r) {
-               ti->error = "Cannot get COW device";
-               goto bad_cow;
-       }
+       tmp_store->snap = snap;
 
-       r = set_chunk_size(tmp_store, argv[2], &ti->error);
+       r = set_chunk_size(tmp_store, argv[1], &ti->error);
        if (r)
-               goto bad_ctr;
+               goto bad;
 
        r = type->ctr(tmp_store, 0, NULL);
        if (r) {
                ti->error = "Exception store type constructor failed";
-               goto bad_ctr;
+               goto bad;
        }
 
-       *args_used = 3;
+       *args_used = 2;
        *store = tmp_store;
        return 0;
 
-bad_ctr:
-       dm_put_device(ti, tmp_store->cow);
-bad_cow:
+bad:
        put_type(type);
 bad_type:
        kfree(tmp_store);
@@ -262,7 +256,6 @@ EXPORT_SYMBOL(dm_exception_store_create);
 void dm_exception_store_destroy(struct dm_exception_store *store)
 {
        store->type->dtr(store);
-       dm_put_device(store->ti, store->cow);
        put_type(store->type);
        kfree(store);
 }
index 8a223a48802c0c867f79818045399937e650bf5e..e8dfa06af3ba531b6cca02842effd91cc083eb1c 100644 (file)
@@ -26,7 +26,7 @@ typedef sector_t chunk_t;
  * of chunks that follow contiguously.  Remaining bits hold the number of the
  * chunk within the device.
  */
-struct dm_snap_exception {
+struct dm_exception {
        struct list_head hash_list;
 
        chunk_t old_chunk;
@@ -64,16 +64,33 @@ struct dm_exception_store_type {
         * Find somewhere to store the next exception.
         */
        int (*prepare_exception) (struct dm_exception_store *store,
-                                 struct dm_snap_exception *e);
+                                 struct dm_exception *e);
 
        /*
         * Update the metadata with this exception.
         */
        void (*commit_exception) (struct dm_exception_store *store,
-                                 struct dm_snap_exception *e,
+                                 struct dm_exception *e,
                                  void (*callback) (void *, int success),
                                  void *callback_context);
 
+       /*
+        * Returns 0 if the exception store is empty.
+        *
+        * If there are exceptions still to be merged, sets
+        * *last_old_chunk and *last_new_chunk to the most recent
+        * still-to-be-merged chunk and returns the number of
+        * consecutive previous ones.
+        */
+       int (*prepare_merge) (struct dm_exception_store *store,
+                             chunk_t *last_old_chunk, chunk_t *last_new_chunk);
+
+       /*
+        * Clear the last n exceptions.
+        * nr_merged must be <= the value returned by prepare_merge.
+        */
+       int (*commit_merge) (struct dm_exception_store *store, int nr_merged);
+
        /*
         * The snapshot is invalid, note this in the metadata.
         */
@@ -86,19 +103,19 @@ struct dm_exception_store_type {
        /*
         * Return how full the snapshot is.
         */
-       void (*fraction_full) (struct dm_exception_store *store,
-                              sector_t *numerator,
-                              sector_t *denominator);
+       void (*usage) (struct dm_exception_store *store,
+                      sector_t *total_sectors, sector_t *sectors_allocated,
+                      sector_t *metadata_sectors);
 
        /* For internal device-mapper use only. */
        struct list_head list;
 };
 
+struct dm_snapshot;
+
 struct dm_exception_store {
        struct dm_exception_store_type *type;
-       struct dm_target *ti;
-
-       struct dm_dev *cow;
+       struct dm_snapshot *snap;
 
        /* Size of data blocks saved - must be a power of 2 */
        unsigned chunk_size;
@@ -108,6 +125,11 @@ struct dm_exception_store {
        void *context;
 };
 
+/*
+ * Obtain the cow device used by a given snapshot.
+ */
+struct dm_dev *dm_snap_cow(struct dm_snapshot *snap);
+
 /*
  * Funtions to manipulate consecutive chunks
  */
@@ -120,18 +142,25 @@ static inline chunk_t dm_chunk_number(chunk_t chunk)
        return chunk & (chunk_t)((1ULL << DM_CHUNK_NUMBER_BITS) - 1ULL);
 }
 
-static inline unsigned dm_consecutive_chunk_count(struct dm_snap_exception *e)
+static inline unsigned dm_consecutive_chunk_count(struct dm_exception *e)
 {
        return e->new_chunk >> DM_CHUNK_NUMBER_BITS;
 }
 
-static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
+static inline void dm_consecutive_chunk_count_inc(struct dm_exception *e)
 {
        e->new_chunk += (1ULL << DM_CHUNK_NUMBER_BITS);
 
        BUG_ON(!dm_consecutive_chunk_count(e));
 }
 
+static inline void dm_consecutive_chunk_count_dec(struct dm_exception *e)
+{
+       BUG_ON(!dm_consecutive_chunk_count(e));
+
+       e->new_chunk -= (1ULL << DM_CHUNK_NUMBER_BITS);
+}
+
 #  else
 #    define DM_CHUNK_CONSECUTIVE_BITS 0
 
@@ -140,12 +169,16 @@ static inline chunk_t dm_chunk_number(chunk_t chunk)
        return chunk;
 }
 
-static inline unsigned dm_consecutive_chunk_count(struct dm_snap_exception *e)
+static inline unsigned dm_consecutive_chunk_count(struct dm_exception *e)
 {
        return 0;
 }
 
-static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
+static inline void dm_consecutive_chunk_count_inc(struct dm_exception *e)
+{
+}
+
+static inline void dm_consecutive_chunk_count_dec(struct dm_exception *e)
 {
 }
 
@@ -162,7 +195,7 @@ static inline sector_t get_dev_size(struct block_device *bdev)
 static inline chunk_t sector_to_chunk(struct dm_exception_store *store,
                                      sector_t sector)
 {
-       return (sector & ~store->chunk_mask) >> store->chunk_shift;
+       return sector >> store->chunk_shift;
 }
 
 int dm_exception_store_type_register(struct dm_exception_store_type *type);
@@ -173,6 +206,7 @@ int dm_exception_store_set_chunk_size(struct dm_exception_store *store,
                                      char **error);
 
 int dm_exception_store_create(struct dm_target *ti, int argc, char **argv,
+                             struct dm_snapshot *snap,
                              unsigned *args_used,
                              struct dm_exception_store **store);
 void dm_exception_store_destroy(struct dm_exception_store *store);
index 3a2e6a2f8bdd336f863807108c9ca3ebbfbba917..10f457ca6af2568ab9073f8a7ab7477a0f946a94 100644 (file)
@@ -5,6 +5,8 @@
  * This file is released under the GPL.
  */
 
+#include "dm.h"
+
 #include <linux/device-mapper.h>
 
 #include <linux/bio.h>
 #include <linux/slab.h>
 #include <linux/dm-io.h>
 
+#define DM_MSG_PREFIX "io"
+
+#define DM_IO_MAX_REGIONS      BITS_PER_LONG
+
 struct dm_io_client {
        mempool_t *pool;
        struct bio_set *bios;
 };
 
-/* FIXME: can we shrink this ? */
+/*
+ * Aligning 'struct io' reduces the number of bits required to store
+ * its address.  Refer to store_io_and_region_in_bio() below.
+ */
 struct io {
        unsigned long error_bits;
        unsigned long eopnotsupp_bits;
@@ -28,7 +37,9 @@ struct io {
        struct dm_io_client *client;
        io_notify_fn callback;
        void *context;
-};
+} __attribute__((aligned(DM_IO_MAX_REGIONS)));
+
+static struct kmem_cache *_dm_io_cache;
 
 /*
  * io contexts are only dynamically allocated for asynchronous
@@ -53,7 +64,7 @@ struct dm_io_client *dm_io_client_create(unsigned num_pages)
        if (!client)
                return ERR_PTR(-ENOMEM);
 
-       client->pool = mempool_create_kmalloc_pool(ios, sizeof(struct io));
+       client->pool = mempool_create_slab_pool(ios, _dm_io_cache);
        if (!client->pool)
                goto bad;
 
@@ -88,18 +99,29 @@ EXPORT_SYMBOL(dm_io_client_destroy);
 
 /*-----------------------------------------------------------------
  * We need to keep track of which region a bio is doing io for.
- * In order to save a memory allocation we store this the last
- * bvec which we know is unused (blech).
- * XXX This is ugly and can OOPS with some configs... find another way.
+ * To avoid a memory allocation to store just 5 or 6 bits, we
+ * ensure the 'struct io' pointer is aligned so enough low bits are
+ * always zero and then combine it with the region number directly in
+ * bi_private.
  *---------------------------------------------------------------*/
-static inline void bio_set_region(struct bio *bio, unsigned region)
+static void store_io_and_region_in_bio(struct bio *bio, struct io *io,
+                                      unsigned region)
 {
-       bio->bi_io_vec[bio->bi_max_vecs].bv_len = region;
+       if (unlikely(!IS_ALIGNED((unsigned long)io, DM_IO_MAX_REGIONS))) {
+               DMCRIT("Unaligned struct io pointer %p", io);
+               BUG();
+       }
+
+       bio->bi_private = (void *)((unsigned long)io | region);
 }
 
-static inline unsigned bio_get_region(struct bio *bio)
+static void retrieve_io_and_region_from_bio(struct bio *bio, struct io **io,
+                                      unsigned *region)
 {
-       return bio->bi_io_vec[bio->bi_max_vecs].bv_len;
+       unsigned long val = (unsigned long)bio->bi_private;
+
+       *io = (void *)(val & -(unsigned long)DM_IO_MAX_REGIONS);
+       *region = val & (DM_IO_MAX_REGIONS - 1);
 }
 
 /*-----------------------------------------------------------------
@@ -140,10 +162,8 @@ static void endio(struct bio *bio, int error)
        /*
         * The bio destructor in bio_put() may use the io object.
         */
-       io = bio->bi_private;
-       region = bio_get_region(bio);
+       retrieve_io_and_region_from_bio(bio, &io, &region);
 
-       bio->bi_max_vecs++;
        bio_put(bio);
 
        dec_count(io, region, error);
@@ -243,7 +263,10 @@ static void vm_dp_init(struct dpages *dp, void *data)
 
 static void dm_bio_destructor(struct bio *bio)
 {
-       struct io *io = bio->bi_private;
+       unsigned region;
+       struct io *io;
+
+       retrieve_io_and_region_from_bio(bio, &io, &region);
 
        bio_free(bio, io->client->bios);
 }
@@ -286,26 +309,23 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
        unsigned num_bvecs;
        sector_t remaining = where->count;
 
-       while (remaining) {
+       /*
+        * where->count may be zero if rw holds a write barrier and we
+        * need to send a zero-sized barrier.
+        */
+       do {
                /*
-                * Allocate a suitably sized-bio: we add an extra
-                * bvec for bio_get/set_region() and decrement bi_max_vecs
-                * to hide it from bio_add_page().
+                * Allocate a suitably sized-bio.
                 */
                num_bvecs = dm_sector_div_up(remaining,
                                             (PAGE_SIZE >> SECTOR_SHIFT));
-               num_bvecs = 1 + min_t(int, bio_get_nr_vecs(where->bdev),
-                                     num_bvecs);
-               if (unlikely(num_bvecs > BIO_MAX_PAGES))
-                       num_bvecs = BIO_MAX_PAGES;
+               num_bvecs = min_t(int, bio_get_nr_vecs(where->bdev), num_bvecs);
                bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios);
                bio->bi_sector = where->sector + (where->count - remaining);
                bio->bi_bdev = where->bdev;
                bio->bi_end_io = endio;
-               bio->bi_private = io;
                bio->bi_destructor = dm_bio_destructor;
-               bio->bi_max_vecs--;
-               bio_set_region(bio, region);
+               store_io_and_region_in_bio(bio, io, region);
 
                /*
                 * Try and add as many pages as possible.
@@ -323,7 +343,7 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
 
                atomic_inc(&io->count);
                submit_bio(rw, bio);
-       }
+       } while (remaining);
 }
 
 static void dispatch_io(int rw, unsigned int num_regions,
@@ -333,6 +353,8 @@ static void dispatch_io(int rw, unsigned int num_regions,
        int i;
        struct dpages old_pages = *dp;
 
+       BUG_ON(num_regions > DM_IO_MAX_REGIONS);
+
        if (sync)
                rw |= (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_UNPLUG);
 
@@ -342,7 +364,7 @@ static void dispatch_io(int rw, unsigned int num_regions,
         */
        for (i = 0; i < num_regions; i++) {
                *dp = old_pages;
-               if (where[i].count)
+               if (where[i].count || (rw & (1 << BIO_RW_BARRIER)))
                        do_region(rw, i, where + i, dp, io);
        }
 
@@ -357,7 +379,14 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
                   struct dm_io_region *where, int rw, struct dpages *dp,
                   unsigned long *error_bits)
 {
-       struct io io;
+       /*
+        * gcc <= 4.3 can't do the alignment for stack variables, so we must
+        * align it on our own.
+        * volatile prevents the optimizer from removing or reusing
+        * "io_" field from the stack frame (allowed in ANSI C).
+        */
+       volatile char io_[sizeof(struct io) + __alignof__(struct io) - 1];
+       struct io *io = (struct io *)PTR_ALIGN(&io_, __alignof__(struct io));
 
        if (num_regions > 1 && (rw & RW_MASK) != WRITE) {
                WARN_ON(1);
@@ -365,33 +394,33 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions,
        }
 
 retry:
-       io.error_bits = 0;
-       io.eopnotsupp_bits = 0;
-       atomic_set(&io.count, 1); /* see dispatch_io() */
-       io.sleeper = current;
-       io.client = client;
+       io->error_bits = 0;
+       io->eopnotsupp_bits = 0;
+       atomic_set(&io->count, 1); /* see dispatch_io() */
+       io->sleeper = current;
+       io->client = client;
 
-       dispatch_io(rw, num_regions, where, dp, &io, 1);
+       dispatch_io(rw, num_regions, where, dp, io, 1);
 
        while (1) {
                set_current_state(TASK_UNINTERRUPTIBLE);
 
-               if (!atomic_read(&io.count))
+               if (!atomic_read(&io->count))
                        break;
 
                io_schedule();
        }
        set_current_state(TASK_RUNNING);
 
-       if (io.eopnotsupp_bits && (rw & (1 << BIO_RW_BARRIER))) {
+       if (io->eopnotsupp_bits && (rw & (1 << BIO_RW_BARRIER))) {
                rw &= ~(1 << BIO_RW_BARRIER);
                goto retry;
        }
 
        if (error_bits)
-               *error_bits = io.error_bits;
+               *error_bits = io->error_bits;
 
-       return io.error_bits ? -EIO : 0;
+       return io->error_bits ? -EIO : 0;
 }
 
 static int async_io(struct dm_io_client *client, unsigned int num_regions,
@@ -472,3 +501,18 @@ int dm_io(struct dm_io_request *io_req, unsigned num_regions,
                        &dp, io_req->notify.fn, io_req->notify.context);
 }
 EXPORT_SYMBOL(dm_io);
+
+int __init dm_io_init(void)
+{
+       _dm_io_cache = KMEM_CACHE(io, 0);
+       if (!_dm_io_cache)
+               return -ENOMEM;
+
+       return 0;
+}
+
+void dm_io_exit(void)
+{
+       kmem_cache_destroy(_dm_io_cache);
+       _dm_io_cache = NULL;
+}
index a679429315828eef8e4cbe896b8cdfba00f5eda2..1d669322b27c7fef59d6e92ba32b2b1d79aedc50 100644 (file)
@@ -56,6 +56,11 @@ static void dm_hash_remove_all(int keep_open_devices);
  */
 static DECLARE_RWSEM(_hash_lock);
 
+/*
+ * Protects use of mdptr to obtain hash cell name and uuid from mapped device.
+ */
+static DEFINE_MUTEX(dm_hash_cells_mutex);
+
 static void init_buckets(struct list_head *buckets)
 {
        unsigned int i;
@@ -206,7 +211,9 @@ static int dm_hash_insert(const char *name, const char *uuid, struct mapped_devi
                list_add(&cell->uuid_list, _uuid_buckets + hash_str(uuid));
        }
        dm_get(md);
+       mutex_lock(&dm_hash_cells_mutex);
        dm_set_mdptr(md, cell);
+       mutex_unlock(&dm_hash_cells_mutex);
        up_write(&_hash_lock);
 
        return 0;
@@ -224,9 +231,11 @@ static void __hash_remove(struct hash_cell *hc)
        /* remove from the dev hash */
        list_del(&hc->uuid_list);
        list_del(&hc->name_list);
+       mutex_lock(&dm_hash_cells_mutex);
        dm_set_mdptr(hc->md, NULL);
+       mutex_unlock(&dm_hash_cells_mutex);
 
-       table = dm_get_table(hc->md);
+       table = dm_get_live_table(hc->md);
        if (table) {
                dm_table_event(table);
                dm_table_put(table);
@@ -321,13 +330,15 @@ static int dm_hash_rename(uint32_t cookie, const char *old, const char *new)
         */
        list_del(&hc->name_list);
        old_name = hc->name;
+       mutex_lock(&dm_hash_cells_mutex);
        hc->name = new_name;
+       mutex_unlock(&dm_hash_cells_mutex);
        list_add(&hc->name_list, _name_buckets + hash_str(new_name));
 
        /*
         * Wake up any dm event waiters.
         */
-       table = dm_get_table(hc->md);
+       table = dm_get_live_table(hc->md);
        if (table) {
                dm_table_event(table);
                dm_table_put(table);
@@ -512,8 +523,6 @@ static int list_versions(struct dm_ioctl *param, size_t param_size)
        return 0;
 }
 
-
-
 static int check_name(const char *name)
 {
        if (strchr(name, '/')) {
@@ -524,6 +533,40 @@ static int check_name(const char *name)
        return 0;
 }
 
+/*
+ * On successful return, the caller must not attempt to acquire
+ * _hash_lock without first calling dm_table_put, because dm_table_destroy
+ * waits for this dm_table_put and could be called under this lock.
+ */
+static struct dm_table *dm_get_inactive_table(struct mapped_device *md)
+{
+       struct hash_cell *hc;
+       struct dm_table *table = NULL;
+
+       down_read(&_hash_lock);
+       hc = dm_get_mdptr(md);
+       if (!hc || hc->md != md) {
+               DMWARN("device has been removed from the dev hash table.");
+               goto out;
+       }
+
+       table = hc->new_map;
+       if (table)
+               dm_table_get(table);
+
+out:
+       up_read(&_hash_lock);
+
+       return table;
+}
+
+static struct dm_table *dm_get_live_or_inactive_table(struct mapped_device *md,
+                                                     struct dm_ioctl *param)
+{
+       return (param->flags & DM_QUERY_INACTIVE_TABLE_FLAG) ?
+               dm_get_inactive_table(md) : dm_get_live_table(md);
+}
+
 /*
  * Fills in a dm_ioctl structure, ready for sending back to
  * userland.
@@ -536,7 +579,7 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param)
        param->flags &= ~(DM_SUSPEND_FLAG | DM_READONLY_FLAG |
                          DM_ACTIVE_PRESENT_FLAG);
 
-       if (dm_suspended(md))
+       if (dm_suspended_md(md))
                param->flags |= DM_SUSPEND_FLAG;
 
        param->dev = huge_encode_dev(disk_devt(disk));
@@ -548,18 +591,30 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param)
         */
        param->open_count = dm_open_count(md);
 
-       if (get_disk_ro(disk))
-               param->flags |= DM_READONLY_FLAG;
-
        param->event_nr = dm_get_event_nr(md);
+       param->target_count = 0;
 
-       table = dm_get_table(md);
+       table = dm_get_live_table(md);
        if (table) {
-               param->flags |= DM_ACTIVE_PRESENT_FLAG;
-               param->target_count = dm_table_get_num_targets(table);
+               if (!(param->flags & DM_QUERY_INACTIVE_TABLE_FLAG)) {
+                       if (get_disk_ro(disk))
+                               param->flags |= DM_READONLY_FLAG;
+                       param->target_count = dm_table_get_num_targets(table);
+               }
                dm_table_put(table);
-       } else
-               param->target_count = 0;
+
+               param->flags |= DM_ACTIVE_PRESENT_FLAG;
+       }
+
+       if (param->flags & DM_QUERY_INACTIVE_TABLE_FLAG) {
+               table = dm_get_inactive_table(md);
+               if (table) {
+                       if (!(dm_table_get_mode(table) & FMODE_WRITE))
+                               param->flags |= DM_READONLY_FLAG;
+                       param->target_count = dm_table_get_num_targets(table);
+                       dm_table_put(table);
+               }
+       }
 
        return 0;
 }
@@ -634,9 +689,9 @@ static struct mapped_device *find_device(struct dm_ioctl *param)
                 * Sneakily write in both the name and the uuid
                 * while we have the cell.
                 */
-               strncpy(param->name, hc->name, sizeof(param->name));
+               strlcpy(param->name, hc->name, sizeof(param->name));
                if (hc->uuid)
-                       strncpy(param->uuid, hc->uuid, sizeof(param->uuid)-1);
+                       strlcpy(param->uuid, hc->uuid, sizeof(param->uuid));
                else
                        param->uuid[0] = '\0';
 
@@ -784,7 +839,7 @@ static int do_suspend(struct dm_ioctl *param)
        if (param->flags & DM_NOFLUSH_FLAG)
                suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
 
-       if (!dm_suspended(md))
+       if (!dm_suspended_md(md))
                r = dm_suspend(md, suspend_flags);
 
        if (!r)
@@ -800,7 +855,7 @@ static int do_resume(struct dm_ioctl *param)
        unsigned suspend_flags = DM_SUSPEND_LOCKFS_FLAG;
        struct hash_cell *hc;
        struct mapped_device *md;
-       struct dm_table *new_map;
+       struct dm_table *new_map, *old_map = NULL;
 
        down_write(&_hash_lock);
 
@@ -826,14 +881,14 @@ static int do_resume(struct dm_ioctl *param)
                        suspend_flags &= ~DM_SUSPEND_LOCKFS_FLAG;
                if (param->flags & DM_NOFLUSH_FLAG)
                        suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
-               if (!dm_suspended(md))
+               if (!dm_suspended_md(md))
                        dm_suspend(md, suspend_flags);
 
-               r = dm_swap_table(md, new_map);
-               if (r) {
+               old_map = dm_swap_table(md, new_map);
+               if (IS_ERR(old_map)) {
                        dm_table_destroy(new_map);
                        dm_put(md);
-                       return r;
+                       return PTR_ERR(old_map);
                }
 
                if (dm_table_get_mode(new_map) & FMODE_WRITE)
@@ -842,9 +897,11 @@ static int do_resume(struct dm_ioctl *param)
                        set_disk_ro(dm_disk(md), 1);
        }
 
-       if (dm_suspended(md))
+       if (dm_suspended_md(md))
                r = dm_resume(md);
 
+       if (old_map)
+               dm_table_destroy(old_map);
 
        if (!r) {
                dm_kobject_uevent(md, KOBJ_CHANGE, param->event_nr);
@@ -982,7 +1039,7 @@ static int dev_wait(struct dm_ioctl *param, size_t param_size)
        if (r)
                goto out;
 
-       table = dm_get_table(md);
+       table = dm_get_live_or_inactive_table(md, param);
        if (table) {
                retrieve_status(table, param, param_size);
                dm_table_put(table);
@@ -1215,7 +1272,7 @@ static int table_deps(struct dm_ioctl *param, size_t param_size)
        if (r)
                goto out;
 
-       table = dm_get_table(md);
+       table = dm_get_live_or_inactive_table(md, param);
        if (table) {
                retrieve_deps(table, param, param_size);
                dm_table_put(table);
@@ -1244,13 +1301,13 @@ static int table_status(struct dm_ioctl *param, size_t param_size)
        if (r)
                goto out;
 
-       table = dm_get_table(md);
+       table = dm_get_live_or_inactive_table(md, param);
        if (table) {
                retrieve_status(table, param, param_size);
                dm_table_put(table);
        }
 
- out:
+out:
        dm_put(md);
        return r;
 }
@@ -1288,10 +1345,15 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
                goto out;
        }
 
-       table = dm_get_table(md);
+       table = dm_get_live_table(md);
        if (!table)
                goto out_argv;
 
+       if (dm_deleting_md(md)) {
+               r = -ENXIO;
+               goto out_table;
+       }
+
        ti = dm_table_find_target(table, tmsg->sector);
        if (!dm_target_is_valid(ti)) {
                DMWARN("Target message sector outside device.");
@@ -1303,6 +1365,7 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
                r = -EINVAL;
        }
 
+ out_table:
        dm_table_put(table);
  out_argv:
        kfree(argv);
@@ -1582,8 +1645,7 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
        if (!md)
                return -ENXIO;
 
-       dm_get(md);
-       down_read(&_hash_lock);
+       mutex_lock(&dm_hash_cells_mutex);
        hc = dm_get_mdptr(md);
        if (!hc || hc->md != md) {
                r = -ENXIO;
@@ -1596,8 +1658,7 @@ int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid)
                strcpy(uuid, hc->uuid ? : "");
 
 out:
-       up_read(&_hash_lock);
-       dm_put(md);
+       mutex_unlock(&dm_hash_cells_mutex);
 
        return r;
 }
index 3e3fc06cb861cc456f6b3184e4cc9150d4772198..addf83475040d326145d67bad45f535d40c41407 100644 (file)
@@ -450,7 +450,10 @@ static void dispatch_job(struct kcopyd_job *job)
 {
        struct dm_kcopyd_client *kc = job->kc;
        atomic_inc(&kc->nr_jobs);
-       push(&kc->pages_jobs, job);
+       if (unlikely(!job->source.count))
+               push(&kc->complete_jobs, job);
+       else
+               push(&kc->pages_jobs, job);
        wake(kc);
 }
 
index 9443896ede070152020046d15979bb9f1dc55b29..7035582786fbd93de70855febce53aac1d283e09 100644 (file)
@@ -145,8 +145,9 @@ int dm_dirty_log_type_unregister(struct dm_dirty_log_type *type)
 EXPORT_SYMBOL(dm_dirty_log_type_unregister);
 
 struct dm_dirty_log *dm_dirty_log_create(const char *type_name,
-                                        struct dm_target *ti,
-                                        unsigned int argc, char **argv)
+                       struct dm_target *ti,
+                       int (*flush_callback_fn)(struct dm_target *ti),
+                       unsigned int argc, char **argv)
 {
        struct dm_dirty_log_type *type;
        struct dm_dirty_log *log;
@@ -161,6 +162,7 @@ struct dm_dirty_log *dm_dirty_log_create(const char *type_name,
                return NULL;
        }
 
+       log->flush_callback_fn = flush_callback_fn;
        log->type = type;
        if (type->ctr(log, ti, argc, argv)) {
                kfree(log);
@@ -208,7 +210,9 @@ struct log_header {
 
 struct log_c {
        struct dm_target *ti;
-       int touched;
+       int touched_dirtied;
+       int touched_cleaned;
+       int flush_failed;
        uint32_t region_size;
        unsigned int region_count;
        region_t sync_count;
@@ -233,6 +237,7 @@ struct log_c {
         * Disk log fields
         */
        int log_dev_failed;
+       int log_dev_flush_failed;
        struct dm_dev *log_dev;
        struct log_header header;
 
@@ -253,14 +258,14 @@ static inline void log_set_bit(struct log_c *l,
                               uint32_t *bs, unsigned bit)
 {
        ext2_set_bit(bit, (unsigned long *) bs);
-       l->touched = 1;
+       l->touched_cleaned = 1;
 }
 
 static inline void log_clear_bit(struct log_c *l,
                                 uint32_t *bs, unsigned bit)
 {
        ext2_clear_bit(bit, (unsigned long *) bs);
-       l->touched = 1;
+       l->touched_dirtied = 1;
 }
 
 /*----------------------------------------------------------------
@@ -287,6 +292,19 @@ static int rw_header(struct log_c *lc, int rw)
        return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
 }
 
+static int flush_header(struct log_c *lc)
+{
+       struct dm_io_region null_location = {
+               .bdev = lc->header_location.bdev,
+               .sector = 0,
+               .count = 0,
+       };
+
+       lc->io_req.bi_rw = WRITE_BARRIER;
+
+       return dm_io(&lc->io_req, 1, &null_location, NULL);
+}
+
 static int read_header(struct log_c *log)
 {
        int r;
@@ -378,7 +396,9 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
        }
 
        lc->ti = ti;
-       lc->touched = 0;
+       lc->touched_dirtied = 0;
+       lc->touched_cleaned = 0;
+       lc->flush_failed = 0;
        lc->region_size = region_size;
        lc->region_count = region_count;
        lc->sync = sync;
@@ -406,6 +426,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
        } else {
                lc->log_dev = dev;
                lc->log_dev_failed = 0;
+               lc->log_dev_flush_failed = 0;
                lc->header_location.bdev = lc->log_dev->bdev;
                lc->header_location.sector = 0;
 
@@ -614,6 +635,11 @@ static int disk_resume(struct dm_dirty_log *log)
 
        /* write the new header */
        r = rw_header(lc, WRITE);
+       if (!r) {
+               r = flush_header(lc);
+               if (r)
+                       lc->log_dev_flush_failed = 1;
+       }
        if (r) {
                DMWARN("%s: Failed to write header on dirty region log device",
                       lc->log_dev->name);
@@ -656,18 +682,40 @@ static int core_flush(struct dm_dirty_log *log)
 
 static int disk_flush(struct dm_dirty_log *log)
 {
-       int r;
-       struct log_c *lc = (struct log_c *) log->context;
+       int r, i;
+       struct log_c *lc = log->context;
 
        /* only write if the log has changed */
-       if (!lc->touched)
+       if (!lc->touched_cleaned && !lc->touched_dirtied)
                return 0;
 
+       if (lc->touched_cleaned && log->flush_callback_fn &&
+           log->flush_callback_fn(lc->ti)) {
+               /*
+                * At this point it is impossible to determine which
+                * regions are clean and which are dirty (without
+                * re-reading the log off disk). So mark all of them
+                * dirty.
+                */
+               lc->flush_failed = 1;
+               for (i = 0; i < lc->region_count; i++)
+                       log_clear_bit(lc, lc->clean_bits, i);
+       }
+
        r = rw_header(lc, WRITE);
        if (r)
                fail_log_device(lc);
-       else
-               lc->touched = 0;
+       else {
+               if (lc->touched_dirtied) {
+                       r = flush_header(lc);
+                       if (r) {
+                               lc->log_dev_flush_failed = 1;
+                               fail_log_device(lc);
+                       } else
+                               lc->touched_dirtied = 0;
+               }
+               lc->touched_cleaned = 0;
+       }
 
        return r;
 }
@@ -681,7 +729,8 @@ static void core_mark_region(struct dm_dirty_log *log, region_t region)
 static void core_clear_region(struct dm_dirty_log *log, region_t region)
 {
        struct log_c *lc = (struct log_c *) log->context;
-       log_set_bit(lc, lc->clean_bits, region);
+       if (likely(!lc->flush_failed))
+               log_set_bit(lc, lc->clean_bits, region);
 }
 
 static int core_get_resync_work(struct dm_dirty_log *log, region_t *region)
@@ -762,7 +811,9 @@ static int disk_status(struct dm_dirty_log *log, status_type_t status,
        switch(status) {
        case STATUSTYPE_INFO:
                DMEMIT("3 %s %s %c", log->type->name, lc->log_dev->name,
-                      lc->log_dev_failed ? 'D' : 'A');
+                      lc->log_dev_flush_failed ? 'F' :
+                      lc->log_dev_failed ? 'D' :
+                      'A');
                break;
 
        case STATUSTYPE_TABLE:
index dce971dbdfa3a4f034d5934c5950de8501e57b29..e81345a1d08fa2f1fec21437c420ccacbbdcd360 100644 (file)
@@ -93,6 +93,10 @@ struct multipath {
         * can resubmit bios on error.
         */
        mempool_t *mpio_pool;
+
+       struct mutex work_mutex;
+
+       unsigned suspended;     /* Don't create new I/O internally when set. */
 };
 
 /*
@@ -198,6 +202,7 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
                m->queue_io = 1;
                INIT_WORK(&m->process_queued_ios, process_queued_ios);
                INIT_WORK(&m->trigger_event, trigger_event);
+               mutex_init(&m->work_mutex);
                m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache);
                if (!m->mpio_pool) {
                        kfree(m);
@@ -885,13 +890,18 @@ static int multipath_ctr(struct dm_target *ti, unsigned int argc,
        return r;
 }
 
-static void multipath_dtr(struct dm_target *ti)
+static void flush_multipath_work(void)
 {
-       struct multipath *m = (struct multipath *) ti->private;
-
        flush_workqueue(kmpath_handlerd);
        flush_workqueue(kmultipathd);
        flush_scheduled_work();
+}
+
+static void multipath_dtr(struct dm_target *ti)
+{
+       struct multipath *m = ti->private;
+
+       flush_multipath_work();
        free_multipath(m);
 }
 
@@ -1261,6 +1271,16 @@ static void multipath_presuspend(struct dm_target *ti)
        queue_if_no_path(m, 0, 1);
 }
 
+static void multipath_postsuspend(struct dm_target *ti)
+{
+       struct multipath *m = ti->private;
+
+       mutex_lock(&m->work_mutex);
+       m->suspended = 1;
+       flush_multipath_work();
+       mutex_unlock(&m->work_mutex);
+}
+
 /*
  * Restore the queue_if_no_path setting.
  */
@@ -1269,6 +1289,10 @@ static void multipath_resume(struct dm_target *ti)
        struct multipath *m = (struct multipath *) ti->private;
        unsigned long flags;
 
+       mutex_lock(&m->work_mutex);
+       m->suspended = 0;
+       mutex_unlock(&m->work_mutex);
+
        spin_lock_irqsave(&m->lock, flags);
        m->queue_if_no_path = m->saved_queue_if_no_path;
        spin_unlock_irqrestore(&m->lock, flags);
@@ -1397,51 +1421,71 @@ static int multipath_status(struct dm_target *ti, status_type_t type,
 
 static int multipath_message(struct dm_target *ti, unsigned argc, char **argv)
 {
-       int r;
+       int r = -EINVAL;
        struct dm_dev *dev;
        struct multipath *m = (struct multipath *) ti->private;
        action_fn action;
 
+       mutex_lock(&m->work_mutex);
+
+       if (m->suspended) {
+               r = -EBUSY;
+               goto out;
+       }
+
+       if (dm_suspended(ti)) {
+               r = -EBUSY;
+               goto out;
+       }
+
        if (argc == 1) {
-               if (!strnicmp(argv[0], MESG_STR("queue_if_no_path")))
-                       return queue_if_no_path(m, 1, 0);
-               else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path")))
-                       return queue_if_no_path(m, 0, 0);
+               if (!strnicmp(argv[0], MESG_STR("queue_if_no_path"))) {
+                       r = queue_if_no_path(m, 1, 0);
+                       goto out;
+               } else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path"))) {
+                       r = queue_if_no_path(m, 0, 0);
+                       goto out;
+               }
        }
 
-       if (argc != 2)
-               goto error;
+       if (argc != 2) {
+               DMWARN("Unrecognised multipath message received.");
+               goto out;
+       }
 
-       if (!strnicmp(argv[0], MESG_STR("disable_group")))
-               return bypass_pg_num(m, argv[1], 1);
-       else if (!strnicmp(argv[0], MESG_STR("enable_group")))
-               return bypass_pg_num(m, argv[1], 0);
-       else if (!strnicmp(argv[0], MESG_STR("switch_group")))
-               return switch_pg_num(m, argv[1]);
-       else if (!strnicmp(argv[0], MESG_STR("reinstate_path")))
+       if (!strnicmp(argv[0], MESG_STR("disable_group"))) {
+               r = bypass_pg_num(m, argv[1], 1);
+               goto out;
+       } else if (!strnicmp(argv[0], MESG_STR("enable_group"))) {
+               r = bypass_pg_num(m, argv[1], 0);
+               goto out;
+       } else if (!strnicmp(argv[0], MESG_STR("switch_group"))) {
+               r = switch_pg_num(m, argv[1]);
+               goto out;
+       } else if (!strnicmp(argv[0], MESG_STR("reinstate_path")))
                action = reinstate_path;
        else if (!strnicmp(argv[0], MESG_STR("fail_path")))
                action = fail_path;
-       else
-               goto error;
+       else {
+               DMWARN("Unrecognised multipath message received.");
+               goto out;
+       }
 
        r = dm_get_device(ti, argv[1], ti->begin, ti->len,
                          dm_table_get_mode(ti->table), &dev);
        if (r) {
                DMWARN("message: error getting device %s",
                       argv[1]);
-               return -EINVAL;
+               goto out;
        }
 
        r = action_dev(m, dev, action);
 
        dm_put_device(ti, dev);
 
+out:
+       mutex_unlock(&m->work_mutex);
        return r;
-
-error:
-       DMWARN("Unrecognised multipath message received.");
-       return -EINVAL;
 }
 
 static int multipath_ioctl(struct dm_target *ti, unsigned int cmd,
@@ -1567,13 +1611,14 @@ out:
  *---------------------------------------------------------------*/
 static struct target_type multipath_target = {
        .name = "multipath",
-       .version = {1, 1, 0},
+       .version = {1, 1, 1},
        .module = THIS_MODULE,
        .ctr = multipath_ctr,
        .dtr = multipath_dtr,
        .map_rq = multipath_map,
        .rq_end_io = multipath_end_io,
        .presuspend = multipath_presuspend,
+       .postsuspend = multipath_postsuspend,
        .resume = multipath_resume,
        .status = multipath_status,
        .message = multipath_message,
index cc9dc79b0784ad4fb0970e1db4defd0126b63e5a..ad779bd13aec43ac6aba859be57a8e94d01a5001 100644 (file)
@@ -35,6 +35,7 @@ static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped);
  *---------------------------------------------------------------*/
 enum dm_raid1_error {
        DM_RAID1_WRITE_ERROR,
+       DM_RAID1_FLUSH_ERROR,
        DM_RAID1_SYNC_ERROR,
        DM_RAID1_READ_ERROR
 };
@@ -57,6 +58,7 @@ struct mirror_set {
        struct bio_list reads;
        struct bio_list writes;
        struct bio_list failures;
+       struct bio_list holds;  /* bios are waiting until suspend */
 
        struct dm_region_hash *rh;
        struct dm_kcopyd_client *kcopyd_client;
@@ -67,6 +69,7 @@ struct mirror_set {
        region_t nr_regions;
        int in_sync;
        int log_failure;
+       int leg_failure;
        atomic_t suspend;
 
        atomic_t default_mirror;        /* Default mirror */
@@ -179,6 +182,17 @@ static void set_default_mirror(struct mirror *m)
        atomic_set(&ms->default_mirror, m - m0);
 }
 
+static struct mirror *get_valid_mirror(struct mirror_set *ms)
+{
+       struct mirror *m;
+
+       for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
+               if (!atomic_read(&m->error_count))
+                       return m;
+
+       return NULL;
+}
+
 /* fail_mirror
  * @m: mirror device to fail
  * @error_type: one of the enum's, DM_RAID1_*_ERROR
@@ -198,6 +212,8 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
        struct mirror_set *ms = m->ms;
        struct mirror *new;
 
+       ms->leg_failure = 1;
+
        /*
         * error_count is used for nothing more than a
         * simple way to tell if a device has encountered
@@ -224,19 +240,50 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
                goto out;
        }
 
-       for (new = ms->mirror; new < ms->mirror + ms->nr_mirrors; new++)
-               if (!atomic_read(&new->error_count)) {
-                       set_default_mirror(new);
-                       break;
-               }
-
-       if (unlikely(new == ms->mirror + ms->nr_mirrors))
+       new = get_valid_mirror(ms);
+       if (new)
+               set_default_mirror(new);
+       else
                DMWARN("All sides of mirror have failed.");
 
 out:
        schedule_work(&ms->trigger_event);
 }
 
+static int mirror_flush(struct dm_target *ti)
+{
+       struct mirror_set *ms = ti->private;
+       unsigned long error_bits;
+
+       unsigned int i;
+       struct dm_io_region io[ms->nr_mirrors];
+       struct mirror *m;
+       struct dm_io_request io_req = {
+               .bi_rw = WRITE_BARRIER,
+               .mem.type = DM_IO_KMEM,
+               .mem.ptr.bvec = NULL,
+               .client = ms->io_client,
+       };
+
+       for (i = 0, m = ms->mirror; i < ms->nr_mirrors; i++, m++) {
+               io[i].bdev = m->dev->bdev;
+               io[i].sector = 0;
+               io[i].count = 0;
+       }
+
+       error_bits = -1;
+       dm_io(&io_req, ms->nr_mirrors, io, &error_bits);
+       if (unlikely(error_bits != 0)) {
+               for (i = 0; i < ms->nr_mirrors; i++)
+                       if (test_bit(i, &error_bits))
+                               fail_mirror(ms->mirror + i,
+                                           DM_RAID1_FLUSH_ERROR);
+               return -EIO;
+       }
+
+       return 0;
+}
+
 /*-----------------------------------------------------------------
  * Recovery.
  *
@@ -396,6 +443,8 @@ static int mirror_available(struct mirror_set *ms, struct bio *bio)
  */
 static sector_t map_sector(struct mirror *m, struct bio *bio)
 {
+       if (unlikely(!bio->bi_size))
+               return 0;
        return m->offset + (bio->bi_sector - m->ms->ti->begin);
 }
 
@@ -413,6 +462,27 @@ static void map_region(struct dm_io_region *io, struct mirror *m,
        io->count = bio->bi_size >> 9;
 }
 
+static void hold_bio(struct mirror_set *ms, struct bio *bio)
+{
+       /*
+        * If device is suspended, complete the bio.
+        */
+       if (atomic_read(&ms->suspend)) {
+               if (dm_noflush_suspending(ms->ti))
+                       bio_endio(bio, DM_ENDIO_REQUEUE);
+               else
+                       bio_endio(bio, -EIO);
+               return;
+       }
+
+       /*
+        * Hold bio until the suspend is complete.
+        */
+       spin_lock_irq(&ms->lock);
+       bio_list_add(&ms->holds, bio);
+       spin_unlock_irq(&ms->lock);
+}
+
 /*-----------------------------------------------------------------
  * Reads
  *---------------------------------------------------------------*/
@@ -511,7 +581,6 @@ static void write_callback(unsigned long error, void *context)
        unsigned i, ret = 0;
        struct bio *bio = (struct bio *) context;
        struct mirror_set *ms;
-       int uptodate = 0;
        int should_wake = 0;
        unsigned long flags;
 
@@ -524,36 +593,27 @@ static void write_callback(unsigned long error, void *context)
         * This way we handle both writes to SYNC and NOSYNC
         * regions with the same code.
         */
-       if (likely(!error))
-               goto out;
+       if (likely(!error)) {
+               bio_endio(bio, ret);
+               return;
+       }
 
        for (i = 0; i < ms->nr_mirrors; i++)
                if (test_bit(i, &error))
                        fail_mirror(ms->mirror + i, DM_RAID1_WRITE_ERROR);
-               else
-                       uptodate = 1;
 
-       if (unlikely(!uptodate)) {
-               DMERR("All replicated volumes dead, failing I/O");
-               /* None of the writes succeeded, fail the I/O. */
-               ret = -EIO;
-       } else if (errors_handled(ms)) {
-               /*
-                * Need to raise event.  Since raising
-                * events can block, we need to do it in
-                * the main thread.
-                */
-               spin_lock_irqsave(&ms->lock, flags);
-               if (!ms->failures.head)
-                       should_wake = 1;
-               bio_list_add(&ms->failures, bio);
-               spin_unlock_irqrestore(&ms->lock, flags);
-               if (should_wake)
-                       wakeup_mirrord(ms);
-               return;
-       }
-out:
-       bio_endio(bio, ret);
+       /*
+        * Need to raise event.  Since raising
+        * events can block, we need to do it in
+        * the main thread.
+        */
+       spin_lock_irqsave(&ms->lock, flags);
+       if (!ms->failures.head)
+               should_wake = 1;
+       bio_list_add(&ms->failures, bio);
+       spin_unlock_irqrestore(&ms->lock, flags);
+       if (should_wake)
+               wakeup_mirrord(ms);
 }
 
 static void do_write(struct mirror_set *ms, struct bio *bio)
@@ -562,7 +622,7 @@ static void do_write(struct mirror_set *ms, struct bio *bio)
        struct dm_io_region io[ms->nr_mirrors], *dest = io;
        struct mirror *m;
        struct dm_io_request io_req = {
-               .bi_rw = WRITE,
+               .bi_rw = WRITE | (bio->bi_rw & WRITE_BARRIER),
                .mem.type = DM_IO_BVEC,
                .mem.ptr.bvec = bio->bi_io_vec + bio->bi_idx,
                .notify.fn = write_callback,
@@ -603,6 +663,11 @@ static void do_writes(struct mirror_set *ms, struct bio_list *writes)
        bio_list_init(&requeue);
 
        while ((bio = bio_list_pop(writes))) {
+               if (unlikely(bio_empty_barrier(bio))) {
+                       bio_list_add(&sync, bio);
+                       continue;
+               }
+
                region = dm_rh_bio_to_region(ms->rh, bio);
 
                if (log->type->is_remote_recovering &&
@@ -672,8 +737,12 @@ static void do_writes(struct mirror_set *ms, struct bio_list *writes)
                dm_rh_delay(ms->rh, bio);
 
        while ((bio = bio_list_pop(&nosync))) {
-               map_bio(get_default_mirror(ms), bio);
-               generic_make_request(bio);
+               if (unlikely(ms->leg_failure) && errors_handled(ms))
+                       hold_bio(ms, bio);
+               else {
+                       map_bio(get_default_mirror(ms), bio);
+                       generic_make_request(bio);
+               }
        }
 }
 
@@ -681,20 +750,12 @@ static void do_failures(struct mirror_set *ms, struct bio_list *failures)
 {
        struct bio *bio;
 
-       if (!failures->head)
-               return;
-
-       if (!ms->log_failure) {
-               while ((bio = bio_list_pop(failures))) {
-                       ms->in_sync = 0;
-                       dm_rh_mark_nosync(ms->rh, bio, bio->bi_size, 0);
-               }
+       if (likely(!failures->head))
                return;
-       }
 
        /*
         * If the log has failed, unattempted writes are being
-        * put on the failures list.  We can't issue those writes
+        * put on the holds list.  We can't issue those writes
         * until a log has been marked, so we must store them.
         *
         * If a 'noflush' suspend is in progress, we can requeue
@@ -709,23 +770,27 @@ static void do_failures(struct mirror_set *ms, struct bio_list *failures)
         * for us to treat them the same and requeue them
         * as well.
         */
-       if (dm_noflush_suspending(ms->ti)) {
-               while ((bio = bio_list_pop(failures)))
-                       bio_endio(bio, DM_ENDIO_REQUEUE);
-               return;
-       }
+       while ((bio = bio_list_pop(failures))) {
+               if (!ms->log_failure) {
+                       ms->in_sync = 0;
+                       dm_rh_mark_nosync(ms->rh, bio);
+               }
 
-       if (atomic_read(&ms->suspend)) {
-               while ((bio = bio_list_pop(failures)))
+               /*
+                * If all the legs are dead, fail the I/O.
+                * If we have been told to handle errors, hold the bio
+                * and wait for userspace to deal with the problem.
+                * Otherwise pretend that the I/O succeeded. (This would
+                * be wrong if the failed leg returned after reboot and
+                * got replicated back to the good legs.)
+                */
+               if (!get_valid_mirror(ms))
                        bio_endio(bio, -EIO);
-               return;
+               else if (errors_handled(ms))
+                       hold_bio(ms, bio);
+               else
+                       bio_endio(bio, 0);
        }
-
-       spin_lock_irq(&ms->lock);
-       bio_list_merge(&ms->failures, failures);
-       spin_unlock_irq(&ms->lock);
-
-       delayed_wake(ms);
 }
 
 static void trigger_event(struct work_struct *work)
@@ -784,12 +849,17 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
        }
 
        spin_lock_init(&ms->lock);
+       bio_list_init(&ms->reads);
+       bio_list_init(&ms->writes);
+       bio_list_init(&ms->failures);
+       bio_list_init(&ms->holds);
 
        ms->ti = ti;
        ms->nr_mirrors = nr_mirrors;
        ms->nr_regions = dm_sector_div_up(ti->len, region_size);
        ms->in_sync = 0;
        ms->log_failure = 0;
+       ms->leg_failure = 0;
        atomic_set(&ms->suspend, 0);
        atomic_set(&ms->default_mirror, DEFAULT_MIRROR);
 
@@ -889,7 +959,8 @@ static struct dm_dirty_log *create_dirty_log(struct dm_target *ti,
                return NULL;
        }
 
-       dl = dm_dirty_log_create(argv[0], ti, param_count, argv + 2);
+       dl = dm_dirty_log_create(argv[0], ti, mirror_flush, param_count,
+                                argv + 2);
        if (!dl) {
                ti->error = "Error creating mirror dirty log";
                return NULL;
@@ -995,6 +1066,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 
        ti->private = ms;
        ti->split_io = dm_rh_get_region_size(ms->rh);
+       ti->num_flush_requests = 1;
 
        ms->kmirrord_wq = create_singlethread_workqueue("kmirrord");
        if (!ms->kmirrord_wq) {
@@ -1122,7 +1194,8 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio,
         * We need to dec pending if this was a write.
         */
        if (rw == WRITE) {
-               dm_rh_dec(ms->rh, map_context->ll);
+               if (likely(!bio_empty_barrier(bio)))
+                       dm_rh_dec(ms->rh, map_context->ll);
                return error;
        }
 
@@ -1180,6 +1253,9 @@ static void mirror_presuspend(struct dm_target *ti)
        struct mirror_set *ms = (struct mirror_set *) ti->private;
        struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh);
 
+       struct bio_list holds;
+       struct bio *bio;
+
        atomic_set(&ms->suspend, 1);
 
        /*
@@ -1202,6 +1278,22 @@ static void mirror_presuspend(struct dm_target *ti)
         * we know that all of our I/O has been pushed.
         */
        flush_workqueue(ms->kmirrord_wq);
+
+       /*
+        * Now set ms->suspend is set and the workqueue flushed, no more
+        * entries can be added to ms->hold list, so process it.
+        *
+        * Bios can still arrive concurrently with or after this
+        * presuspend function, but they cannot join the hold list
+        * because ms->suspend is set.
+        */
+       spin_lock_irq(&ms->lock);
+       holds = ms->holds;
+       bio_list_init(&ms->holds);
+       spin_unlock_irq(&ms->lock);
+
+       while ((bio = bio_list_pop(&holds)))
+               hold_bio(ms, bio);
 }
 
 static void mirror_postsuspend(struct dm_target *ti)
@@ -1244,7 +1336,8 @@ static char device_status_char(struct mirror *m)
        if (!atomic_read(&(m->error_count)))
                return 'A';
 
-       return (test_bit(DM_RAID1_WRITE_ERROR, &(m->error_type))) ? 'D' :
+       return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
+               (test_bit(DM_RAID1_WRITE_ERROR, &(m->error_type))) ? 'D' :
                (test_bit(DM_RAID1_SYNC_ERROR, &(m->error_type))) ? 'S' :
                (test_bit(DM_RAID1_READ_ERROR, &(m->error_type))) ? 'R' : 'U';
 }
index 36dbe29f2fd60e775b05a0c0562e4741a42a8d08..5f19ceb6fe91f6c214c9103cc4b5b4037de84a9f 100644 (file)
@@ -79,6 +79,11 @@ struct dm_region_hash {
        struct list_head recovered_regions;
        struct list_head failed_recovered_regions;
 
+       /*
+        * If there was a barrier failure no regions can be marked clean.
+        */
+       int barrier_failure;
+
        void *context;
        sector_t target_begin;
 
@@ -211,6 +216,7 @@ struct dm_region_hash *dm_region_hash_create(
        INIT_LIST_HEAD(&rh->quiesced_regions);
        INIT_LIST_HEAD(&rh->recovered_regions);
        INIT_LIST_HEAD(&rh->failed_recovered_regions);
+       rh->barrier_failure = 0;
 
        rh->region_pool = mempool_create_kmalloc_pool(MIN_REGIONS,
                                                      sizeof(struct dm_region));
@@ -377,8 +383,6 @@ static void complete_resync_work(struct dm_region *reg, int success)
 /* dm_rh_mark_nosync
  * @ms
  * @bio
- * @done
- * @error
  *
  * The bio was written on some mirror(s) but failed on other mirror(s).
  * We can successfully endio the bio but should avoid the region being
@@ -386,8 +390,7 @@ static void complete_resync_work(struct dm_region *reg, int success)
  *
  * This function is _not_ safe in interrupt context!
  */
-void dm_rh_mark_nosync(struct dm_region_hash *rh,
-                      struct bio *bio, unsigned done, int error)
+void dm_rh_mark_nosync(struct dm_region_hash *rh, struct bio *bio)
 {
        unsigned long flags;
        struct dm_dirty_log *log = rh->log;
@@ -395,6 +398,11 @@ void dm_rh_mark_nosync(struct dm_region_hash *rh,
        region_t region = dm_rh_bio_to_region(rh, bio);
        int recovering = 0;
 
+       if (bio_empty_barrier(bio)) {
+               rh->barrier_failure = 1;
+               return;
+       }
+
        /* We must inform the log that the sync count has changed. */
        log->type->set_region_sync(log, region, 0);
 
@@ -419,7 +427,6 @@ void dm_rh_mark_nosync(struct dm_region_hash *rh,
        BUG_ON(!list_empty(&reg->list));
        spin_unlock_irqrestore(&rh->region_lock, flags);
 
-       bio_endio(bio, error);
        if (recovering)
                complete_resync_work(reg, 0);
 }
@@ -515,8 +522,11 @@ void dm_rh_inc_pending(struct dm_region_hash *rh, struct bio_list *bios)
 {
        struct bio *bio;
 
-       for (bio = bios->head; bio; bio = bio->bi_next)
+       for (bio = bios->head; bio; bio = bio->bi_next) {
+               if (bio_empty_barrier(bio))
+                       continue;
                rh_inc(rh, dm_rh_bio_to_region(rh, bio));
+       }
 }
 EXPORT_SYMBOL_GPL(dm_rh_inc_pending);
 
@@ -544,7 +554,14 @@ void dm_rh_dec(struct dm_region_hash *rh, region_t region)
                 */
 
                /* do nothing for DM_RH_NOSYNC */
-               if (reg->state == DM_RH_RECOVERING) {
+               if (unlikely(rh->barrier_failure)) {
+                       /*
+                        * If a write barrier failed some time ago, we
+                        * don't know whether or not this write made it
+                        * to the disk, so we must resync the device.
+                        */
+                       reg->state = DM_RH_NOSYNC;
+               } else if (reg->state == DM_RH_RECOVERING) {
                        list_add_tail(&reg->list, &rh->quiesced_regions);
                } else if (reg->state == DM_RH_DIRTY) {
                        reg->state = DM_RH_CLEAN;
index 0c746420c00810f9c2e57ad346f3bd2589250821..7d08879689acc27b6e91f038e53fb1be4deb1b89 100644 (file)
@@ -55,6 +55,8 @@
  */
 #define SNAPSHOT_DISK_VERSION 1
 
+#define NUM_SNAPSHOT_HDR_CHUNKS 1
+
 struct disk_header {
        uint32_t magic;
 
@@ -120,7 +122,22 @@ struct pstore {
 
        /*
         * The next free chunk for an exception.
+        *
+        * When creating exceptions, all the chunks here and above are
+        * free.  It holds the next chunk to be allocated.  On rare
+        * occasions (e.g. after a system crash) holes can be left in
+        * the exception store because chunks can be committed out of
+        * order.
+        *
+        * When merging exceptions, it does not necessarily mean all the
+        * chunks here and above are free.  It holds the value it would
+        * have held if all chunks had been committed in order of
+        * allocation.  Consequently the value may occasionally be
+        * slightly too low, but since it's only used for 'status' and
+        * it can never reach its minimum value too early this doesn't
+        * matter.
         */
+
        chunk_t next_free;
 
        /*
@@ -214,7 +231,7 @@ static int chunk_io(struct pstore *ps, void *area, chunk_t chunk, int rw,
                    int metadata)
 {
        struct dm_io_region where = {
-               .bdev = ps->store->cow->bdev,
+               .bdev = dm_snap_cow(ps->store->snap)->bdev,
                .sector = ps->store->chunk_size * chunk,
                .count = ps->store->chunk_size,
        };
@@ -294,7 +311,8 @@ static int read_header(struct pstore *ps, int *new_snapshot)
         */
        if (!ps->store->chunk_size) {
                ps->store->chunk_size = max(DM_CHUNK_SIZE_DEFAULT_SECTORS,
-                   bdev_logical_block_size(ps->store->cow->bdev) >> 9);
+                   bdev_logical_block_size(dm_snap_cow(ps->store->snap)->
+                                           bdev) >> 9);
                ps->store->chunk_mask = ps->store->chunk_size - 1;
                ps->store->chunk_shift = ffs(ps->store->chunk_size) - 1;
                chunk_size_supplied = 0;
@@ -408,6 +426,15 @@ static void write_exception(struct pstore *ps,
        e->new_chunk = cpu_to_le64(de->new_chunk);
 }
 
+static void clear_exception(struct pstore *ps, uint32_t index)
+{
+       struct disk_exception *e = get_exception(ps, index);
+
+       /* clear it */
+       e->old_chunk = 0;
+       e->new_chunk = 0;
+}
+
 /*
  * Registers the exceptions that are present in the current area.
  * 'full' is filled in to indicate if the area has been
@@ -489,11 +516,23 @@ static struct pstore *get_info(struct dm_exception_store *store)
        return (struct pstore *) store->context;
 }
 
-static void persistent_fraction_full(struct dm_exception_store *store,
-                                    sector_t *numerator, sector_t *denominator)
+static void persistent_usage(struct dm_exception_store *store,
+                            sector_t *total_sectors,
+                            sector_t *sectors_allocated,
+                            sector_t *metadata_sectors)
 {
-       *numerator = get_info(store)->next_free * store->chunk_size;
-       *denominator = get_dev_size(store->cow->bdev);
+       struct pstore *ps = get_info(store);
+
+       *sectors_allocated = ps->next_free * store->chunk_size;
+       *total_sectors = get_dev_size(dm_snap_cow(store->snap)->bdev);
+
+       /*
+        * First chunk is the fixed header.
+        * Then there are (ps->current_area + 1) metadata chunks, each one
+        * separated from the next by ps->exceptions_per_area data chunks.
+        */
+       *metadata_sectors = (ps->current_area + 1 + NUM_SNAPSHOT_HDR_CHUNKS) *
+                           store->chunk_size;
 }
 
 static void persistent_dtr(struct dm_exception_store *store)
@@ -552,44 +591,40 @@ static int persistent_read_metadata(struct dm_exception_store *store,
                ps->current_area = 0;
                zero_memory_area(ps);
                r = zero_disk_area(ps, 0);
-               if (r) {
+               if (r)
                        DMWARN("zero_disk_area(0) failed");
-                       return r;
-               }
-       } else {
-               /*
-                * Sanity checks.
-                */
-               if (ps->version != SNAPSHOT_DISK_VERSION) {
-                       DMWARN("unable to handle snapshot disk version %d",
-                              ps->version);
-                       return -EINVAL;
-               }
+               return r;
+       }
+       /*
+        * Sanity checks.
+        */
+       if (ps->version != SNAPSHOT_DISK_VERSION) {
+               DMWARN("unable to handle snapshot disk version %d",
+                      ps->version);
+               return -EINVAL;
+       }
 
-               /*
-                * Metadata are valid, but snapshot is invalidated
-                */
-               if (!ps->valid)
-                       return 1;
+       /*
+        * Metadata are valid, but snapshot is invalidated
+        */
+       if (!ps->valid)
+               return 1;
 
-               /*
-                * Read the metadata.
-                */
-               r = read_exceptions(ps, callback, callback_context);
-               if (r)
-                       return r;
-       }
+       /*
+        * Read the metadata.
+        */
+       r = read_exceptions(ps, callback, callback_context);
 
-       return 0;
+       return r;
 }
 
 static int persistent_prepare_exception(struct dm_exception_store *store,
-                                       struct dm_snap_exception *e)
+                                       struct dm_exception *e)
 {
        struct pstore *ps = get_info(store);
        uint32_t stride;
        chunk_t next_free;
-       sector_t size = get_dev_size(store->cow->bdev);
+       sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev);
 
        /* Is there enough room ? */
        if (size < ((ps->next_free + 1) * store->chunk_size))
@@ -611,7 +646,7 @@ static int persistent_prepare_exception(struct dm_exception_store *store,
 }
 
 static void persistent_commit_exception(struct dm_exception_store *store,
-                                       struct dm_snap_exception *e,
+                                       struct dm_exception *e,
                                        void (*callback) (void *, int success),
                                        void *callback_context)
 {
@@ -672,6 +707,85 @@ static void persistent_commit_exception(struct dm_exception_store *store,
        ps->callback_count = 0;
 }
 
+static int persistent_prepare_merge(struct dm_exception_store *store,
+                                   chunk_t *last_old_chunk,
+                                   chunk_t *last_new_chunk)
+{
+       struct pstore *ps = get_info(store);
+       struct disk_exception de;
+       int nr_consecutive;
+       int r;
+
+       /*
+        * When current area is empty, move back to preceding area.
+        */
+       if (!ps->current_committed) {
+               /*
+                * Have we finished?
+                */
+               if (!ps->current_area)
+                       return 0;
+
+               ps->current_area--;
+               r = area_io(ps, READ);
+               if (r < 0)
+                       return r;
+               ps->current_committed = ps->exceptions_per_area;
+       }
+
+       read_exception(ps, ps->current_committed - 1, &de);
+       *last_old_chunk = de.old_chunk;
+       *last_new_chunk = de.new_chunk;
+
+       /*
+        * Find number of consecutive chunks within the current area,
+        * working backwards.
+        */
+       for (nr_consecutive = 1; nr_consecutive < ps->current_committed;
+            nr_consecutive++) {
+               read_exception(ps, ps->current_committed - 1 - nr_consecutive,
+                              &de);
+               if (de.old_chunk != *last_old_chunk - nr_consecutive ||
+                   de.new_chunk != *last_new_chunk - nr_consecutive)
+                       break;
+       }
+
+       return nr_consecutive;
+}
+
+static int persistent_commit_merge(struct dm_exception_store *store,
+                                  int nr_merged)
+{
+       int r, i;
+       struct pstore *ps = get_info(store);
+
+       BUG_ON(nr_merged > ps->current_committed);
+
+       for (i = 0; i < nr_merged; i++)
+               clear_exception(ps, ps->current_committed - 1 - i);
+
+       r = area_io(ps, WRITE);
+       if (r < 0)
+               return r;
+
+       ps->current_committed -= nr_merged;
+
+       /*
+        * At this stage, only persistent_usage() uses ps->next_free, so
+        * we make no attempt to keep ps->next_free strictly accurate
+        * as exceptions may have been committed out-of-order originally.
+        * Once a snapshot has become merging, we set it to the value it
+        * would have held had all the exceptions been committed in order.
+        *
+        * ps->current_area does not get reduced by prepare_merge() until
+        * after commit_merge() has removed the nr_merged previous exceptions.
+        */
+       ps->next_free = (area_location(ps, ps->current_area) - 1) +
+                       (ps->current_committed + 1) + NUM_SNAPSHOT_HDR_CHUNKS;
+
+       return 0;
+}
+
 static void persistent_drop_snapshot(struct dm_exception_store *store)
 {
        struct pstore *ps = get_info(store);
@@ -697,7 +811,7 @@ static int persistent_ctr(struct dm_exception_store *store,
        ps->area = NULL;
        ps->zero_area = NULL;
        ps->header_area = NULL;
-       ps->next_free = 2;      /* skipping the header and first area */
+       ps->next_free = NUM_SNAPSHOT_HDR_CHUNKS + 1; /* header and 1st area */
        ps->current_committed = 0;
 
        ps->callback_count = 0;
@@ -726,8 +840,7 @@ static unsigned persistent_status(struct dm_exception_store *store,
        case STATUSTYPE_INFO:
                break;
        case STATUSTYPE_TABLE:
-               DMEMIT(" %s P %llu", store->cow->name,
-                      (unsigned long long)store->chunk_size);
+               DMEMIT(" P %llu", (unsigned long long)store->chunk_size);
        }
 
        return sz;
@@ -741,8 +854,10 @@ static struct dm_exception_store_type _persistent_type = {
        .read_metadata = persistent_read_metadata,
        .prepare_exception = persistent_prepare_exception,
        .commit_exception = persistent_commit_exception,
+       .prepare_merge = persistent_prepare_merge,
+       .commit_merge = persistent_commit_merge,
        .drop_snapshot = persistent_drop_snapshot,
-       .fraction_full = persistent_fraction_full,
+       .usage = persistent_usage,
        .status = persistent_status,
 };
 
@@ -754,8 +869,10 @@ static struct dm_exception_store_type _persistent_compat_type = {
        .read_metadata = persistent_read_metadata,
        .prepare_exception = persistent_prepare_exception,
        .commit_exception = persistent_commit_exception,
+       .prepare_merge = persistent_prepare_merge,
+       .commit_merge = persistent_commit_merge,
        .drop_snapshot = persistent_drop_snapshot,
-       .fraction_full = persistent_fraction_full,
+       .usage = persistent_usage,
        .status = persistent_status,
 };
 
index cde5aa558e6d77b7d1130777762f8aec84c86ab1..a0898a66a2f848f581ae770a93de74011a9249c8 100644 (file)
@@ -36,10 +36,10 @@ static int transient_read_metadata(struct dm_exception_store *store,
 }
 
 static int transient_prepare_exception(struct dm_exception_store *store,
-                                      struct dm_snap_exception *e)
+                                      struct dm_exception *e)
 {
        struct transient_c *tc = store->context;
-       sector_t size = get_dev_size(store->cow->bdev);
+       sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev);
 
        if (size < (tc->next_free + store->chunk_size))
                return -1;
@@ -51,7 +51,7 @@ static int transient_prepare_exception(struct dm_exception_store *store,
 }
 
 static void transient_commit_exception(struct dm_exception_store *store,
-                                      struct dm_snap_exception *e,
+                                      struct dm_exception *e,
                                       void (*callback) (void *, int success),
                                       void *callback_context)
 {
@@ -59,11 +59,14 @@ static void transient_commit_exception(struct dm_exception_store *store,
        callback(callback_context, 1);
 }
 
-static void transient_fraction_full(struct dm_exception_store *store,
-                                   sector_t *numerator, sector_t *denominator)
+static void transient_usage(struct dm_exception_store *store,
+                           sector_t *total_sectors,
+                           sector_t *sectors_allocated,
+                           sector_t *metadata_sectors)
 {
-       *numerator = ((struct transient_c *) store->context)->next_free;
-       *denominator = get_dev_size(store->cow->bdev);
+       *sectors_allocated = ((struct transient_c *) store->context)->next_free;
+       *total_sectors = get_dev_size(dm_snap_cow(store->snap)->bdev);
+       *metadata_sectors = 0;
 }
 
 static int transient_ctr(struct dm_exception_store *store,
@@ -91,8 +94,7 @@ static unsigned transient_status(struct dm_exception_store *store,
        case STATUSTYPE_INFO:
                break;
        case STATUSTYPE_TABLE:
-               DMEMIT(" %s N %llu", store->cow->name,
-                      (unsigned long long)store->chunk_size);
+               DMEMIT(" N %llu", (unsigned long long)store->chunk_size);
        }
 
        return sz;
@@ -106,7 +108,7 @@ static struct dm_exception_store_type _transient_type = {
        .read_metadata = transient_read_metadata,
        .prepare_exception = transient_prepare_exception,
        .commit_exception = transient_commit_exception,
-       .fraction_full = transient_fraction_full,
+       .usage = transient_usage,
        .status = transient_status,
 };
 
@@ -118,7 +120,7 @@ static struct dm_exception_store_type _transient_compat_type = {
        .read_metadata = transient_read_metadata,
        .prepare_exception = transient_prepare_exception,
        .commit_exception = transient_commit_exception,
-       .fraction_full = transient_fraction_full,
+       .usage = transient_usage,
        .status = transient_status,
 };
 
index 3a3ba46e6d4b68fc9f70b87b7ad322a8ca2c9846..ee8eb283650d6ccbe3a5a6e3d6a39ba347d6c35c 100644 (file)
 
 #define DM_MSG_PREFIX "snapshots"
 
+static const char dm_snapshot_merge_target_name[] = "snapshot-merge";
+
+#define dm_target_is_snapshot_merge(ti) \
+       ((ti)->type->name == dm_snapshot_merge_target_name)
+
 /*
  * The percentage increment we will wake up users at
  */
@@ -49,7 +54,7 @@
 #define DM_TRACKED_CHUNK_HASH(x)       ((unsigned long)(x) & \
                                         (DM_TRACKED_CHUNK_HASH_SIZE - 1))
 
-struct exception_table {
+struct dm_exception_table {
        uint32_t hash_mask;
        unsigned hash_shift;
        struct list_head *table;
@@ -59,22 +64,31 @@ struct dm_snapshot {
        struct rw_semaphore lock;
 
        struct dm_dev *origin;
+       struct dm_dev *cow;
+
+       struct dm_target *ti;
 
        /* List of snapshots per Origin */
        struct list_head list;
 
-       /* You can't use a snapshot if this is 0 (e.g. if full) */
+       /*
+        * You can't use a snapshot if this is 0 (e.g. if full).
+        * A snapshot-merge target never clears this.
+        */
        int valid;
 
        /* Origin writes don't trigger exceptions until this is set */
        int active;
 
+       /* Whether or not owning mapped_device is suspended */
+       int suspended;
+
        mempool_t *pending_pool;
 
        atomic_t pending_exceptions_count;
 
-       struct exception_table pending;
-       struct exception_table complete;
+       struct dm_exception_table pending;
+       struct dm_exception_table complete;
 
        /*
         * pe_lock protects all pending_exception operations and access
@@ -95,8 +109,51 @@ struct dm_snapshot {
        mempool_t *tracked_chunk_pool;
        spinlock_t tracked_chunk_lock;
        struct hlist_head tracked_chunk_hash[DM_TRACKED_CHUNK_HASH_SIZE];
+
+       /*
+        * The merge operation failed if this flag is set.
+        * Failure modes are handled as follows:
+        * - I/O error reading the header
+        *      => don't load the target; abort.
+        * - Header does not have "valid" flag set
+        *      => use the origin; forget about the snapshot.
+        * - I/O error when reading exceptions
+        *      => don't load the target; abort.
+        *         (We can't use the intermediate origin state.)
+        * - I/O error while merging
+        *      => stop merging; set merge_failed; process I/O normally.
+        */
+       int merge_failed;
+
+       /* Wait for events based on state_bits */
+       unsigned long state_bits;
+
+       /* Range of chunks currently being merged. */
+       chunk_t first_merging_chunk;
+       int num_merging_chunks;
+
+       /*
+        * Incoming bios that overlap with chunks being merged must wait
+        * for them to be committed.
+        */
+       struct bio_list bios_queued_during_merge;
 };
 
+/*
+ * state_bits:
+ *   RUNNING_MERGE  - Merge operation is in progress.
+ *   SHUTDOWN_MERGE - Set to signal that merge needs to be stopped;
+ *                    cleared afterwards.
+ */
+#define RUNNING_MERGE          0
+#define SHUTDOWN_MERGE         1
+
+struct dm_dev *dm_snap_cow(struct dm_snapshot *s)
+{
+       return s->cow;
+}
+EXPORT_SYMBOL(dm_snap_cow);
+
 static struct workqueue_struct *ksnapd;
 static void flush_queued_bios(struct work_struct *work);
 
@@ -116,7 +173,7 @@ static int bdev_equal(struct block_device *lhs, struct block_device *rhs)
 }
 
 struct dm_snap_pending_exception {
-       struct dm_snap_exception e;
+       struct dm_exception e;
 
        /*
         * Origin buffers waiting for this to complete are held
@@ -125,28 +182,6 @@ struct dm_snap_pending_exception {
        struct bio_list origin_bios;
        struct bio_list snapshot_bios;
 
-       /*
-        * Short-term queue of pending exceptions prior to submission.
-        */
-       struct list_head list;
-
-       /*
-        * The primary pending_exception is the one that holds
-        * the ref_count and the list of origin_bios for a
-        * group of pending_exceptions.  It is always last to get freed.
-        * These fields get set up when writing to the origin.
-        */
-       struct dm_snap_pending_exception *primary_pe;
-
-       /*
-        * Number of pending_exceptions processing this chunk.
-        * When this drops to zero we must complete the origin bios.
-        * If incrementing or decrementing this, hold pe->snap->lock for
-        * the sibling concerned and not pe->primary_pe->snap->lock unless
-        * they are the same.
-        */
-       atomic_t ref_count;
-
        /* Pointer back to snapshot context */
        struct dm_snapshot *snap;
 
@@ -221,6 +256,16 @@ static int __chunk_is_tracked(struct dm_snapshot *s, chunk_t chunk)
        return found;
 }
 
+/*
+ * This conflicting I/O is extremely improbable in the caller,
+ * so msleep(1) is sufficient and there is no need for a wait queue.
+ */
+static void __check_for_conflicting_io(struct dm_snapshot *s, chunk_t chunk)
+{
+       while (__chunk_is_tracked(s, chunk))
+               msleep(1);
+}
+
 /*
  * One of these per registered origin, held in the snapshot_origins hash
  */
@@ -243,6 +288,10 @@ struct origin {
 static struct list_head *_origins;
 static struct rw_semaphore _origins_lock;
 
+static DECLARE_WAIT_QUEUE_HEAD(_pending_exceptions_done);
+static DEFINE_SPINLOCK(_pending_exceptions_done_spinlock);
+static uint64_t _pending_exceptions_done_count;
+
 static int init_origin_hash(void)
 {
        int i;
@@ -290,23 +339,145 @@ static void __insert_origin(struct origin *o)
        list_add_tail(&o->hash_list, sl);
 }
 
+/*
+ * _origins_lock must be held when calling this function.
+ * Returns number of snapshots registered using the supplied cow device, plus:
+ * snap_src - a snapshot suitable for use as a source of exception handover
+ * snap_dest - a snapshot capable of receiving exception handover.
+ * snap_merge - an existing snapshot-merge target linked to the same origin.
+ *   There can be at most one snapshot-merge target. The parameter is optional.
+ *
+ * Possible return values and states of snap_src and snap_dest.
+ *   0: NULL, NULL  - first new snapshot
+ *   1: snap_src, NULL - normal snapshot
+ *   2: snap_src, snap_dest  - waiting for handover
+ *   2: snap_src, NULL - handed over, waiting for old to be deleted
+ *   1: NULL, snap_dest - source got destroyed without handover
+ */
+static int __find_snapshots_sharing_cow(struct dm_snapshot *snap,
+                                       struct dm_snapshot **snap_src,
+                                       struct dm_snapshot **snap_dest,
+                                       struct dm_snapshot **snap_merge)
+{
+       struct dm_snapshot *s;
+       struct origin *o;
+       int count = 0;
+       int active;
+
+       o = __lookup_origin(snap->origin->bdev);
+       if (!o)
+               goto out;
+
+       list_for_each_entry(s, &o->snapshots, list) {
+               if (dm_target_is_snapshot_merge(s->ti) && snap_merge)
+                       *snap_merge = s;
+               if (!bdev_equal(s->cow->bdev, snap->cow->bdev))
+                       continue;
+
+               down_read(&s->lock);
+               active = s->active;
+               up_read(&s->lock);
+
+               if (active) {
+                       if (snap_src)
+                               *snap_src = s;
+               } else if (snap_dest)
+                       *snap_dest = s;
+
+               count++;
+       }
+
+out:
+       return count;
+}
+
+/*
+ * On success, returns 1 if this snapshot is a handover destination,
+ * otherwise returns 0.
+ */
+static int __validate_exception_handover(struct dm_snapshot *snap)
+{
+       struct dm_snapshot *snap_src = NULL, *snap_dest = NULL;
+       struct dm_snapshot *snap_merge = NULL;
+
+       /* Does snapshot need exceptions handed over to it? */
+       if ((__find_snapshots_sharing_cow(snap, &snap_src, &snap_dest,
+                                         &snap_merge) == 2) ||
+           snap_dest) {
+               snap->ti->error = "Snapshot cow pairing for exception "
+                                 "table handover failed";
+               return -EINVAL;
+       }
+
+       /*
+        * If no snap_src was found, snap cannot become a handover
+        * destination.
+        */
+       if (!snap_src)
+               return 0;
+
+       /*
+        * Non-snapshot-merge handover?
+        */
+       if (!dm_target_is_snapshot_merge(snap->ti))
+               return 1;
+
+       /*
+        * Do not allow more than one merging snapshot.
+        */
+       if (snap_merge) {
+               snap->ti->error = "A snapshot is already merging.";
+               return -EINVAL;
+       }
+
+       if (!snap_src->store->type->prepare_merge ||
+           !snap_src->store->type->commit_merge) {
+               snap->ti->error = "Snapshot exception store does not "
+                                 "support snapshot-merge.";
+               return -EINVAL;
+       }
+
+       return 1;
+}
+
+static void __insert_snapshot(struct origin *o, struct dm_snapshot *s)
+{
+       struct dm_snapshot *l;
+
+       /* Sort the list according to chunk size, largest-first smallest-last */
+       list_for_each_entry(l, &o->snapshots, list)
+               if (l->store->chunk_size < s->store->chunk_size)
+                       break;
+       list_add_tail(&s->list, &l->list);
+}
+
 /*
  * Make a note of the snapshot and its origin so we can look it
  * up when the origin has a write on it.
+ *
+ * Also validate snapshot exception store handovers.
+ * On success, returns 1 if this registration is a handover destination,
+ * otherwise returns 0.
  */
 static int register_snapshot(struct dm_snapshot *snap)
 {
-       struct dm_snapshot *l;
-       struct origin *o, *new_o;
+       struct origin *o, *new_o = NULL;
        struct block_device *bdev = snap->origin->bdev;
+       int r = 0;
 
        new_o = kmalloc(sizeof(*new_o), GFP_KERNEL);
        if (!new_o)
                return -ENOMEM;
 
        down_write(&_origins_lock);
-       o = __lookup_origin(bdev);
 
+       r = __validate_exception_handover(snap);
+       if (r < 0) {
+               kfree(new_o);
+               goto out;
+       }
+
+       o = __lookup_origin(bdev);
        if (o)
                kfree(new_o);
        else {
@@ -320,14 +491,27 @@ static int register_snapshot(struct dm_snapshot *snap)
                __insert_origin(o);
        }
 
-       /* Sort the list according to chunk size, largest-first smallest-last */
-       list_for_each_entry(l, &o->snapshots, list)
-               if (l->store->chunk_size < snap->store->chunk_size)
-                       break;
-       list_add_tail(&snap->list, &l->list);
+       __insert_snapshot(o, snap);
+
+out:
+       up_write(&_origins_lock);
+
+       return r;
+}
+
+/*
+ * Move snapshot to correct place in list according to chunk size.
+ */
+static void reregister_snapshot(struct dm_snapshot *s)
+{
+       struct block_device *bdev = s->origin->bdev;
+
+       down_write(&_origins_lock);
+
+       list_del(&s->list);
+       __insert_snapshot(__lookup_origin(bdev), s);
 
        up_write(&_origins_lock);
-       return 0;
 }
 
 static void unregister_snapshot(struct dm_snapshot *s)
@@ -338,7 +522,7 @@ static void unregister_snapshot(struct dm_snapshot *s)
        o = __lookup_origin(s->origin->bdev);
 
        list_del(&s->list);
-       if (list_empty(&o->snapshots)) {
+       if (o && list_empty(&o->snapshots)) {
                list_del(&o->hash_list);
                kfree(o);
        }
@@ -351,8 +535,8 @@ static void unregister_snapshot(struct dm_snapshot *s)
  * The lowest hash_shift bits of the chunk number are ignored, allowing
  * some consecutive chunks to be grouped together.
  */
-static int init_exception_table(struct exception_table *et, uint32_t size,
-                               unsigned hash_shift)
+static int dm_exception_table_init(struct dm_exception_table *et,
+                                  uint32_t size, unsigned hash_shift)
 {
        unsigned int i;
 
@@ -368,10 +552,11 @@ static int init_exception_table(struct exception_table *et, uint32_t size,
        return 0;
 }
 
-static void exit_exception_table(struct exception_table *et, struct kmem_cache *mem)
+static void dm_exception_table_exit(struct dm_exception_table *et,
+                                   struct kmem_cache *mem)
 {
        struct list_head *slot;
-       struct dm_snap_exception *ex, *next;
+       struct dm_exception *ex, *next;
        int i, size;
 
        size = et->hash_mask + 1;
@@ -385,19 +570,12 @@ static void exit_exception_table(struct exception_table *et, struct kmem_cache *
        vfree(et->table);
 }
 
-static uint32_t exception_hash(struct exception_table *et, chunk_t chunk)
+static uint32_t exception_hash(struct dm_exception_table *et, chunk_t chunk)
 {
        return (chunk >> et->hash_shift) & et->hash_mask;
 }
 
-static void insert_exception(struct exception_table *eh,
-                            struct dm_snap_exception *e)
-{
-       struct list_head *l = &eh->table[exception_hash(eh, e->old_chunk)];
-       list_add(&e->hash_list, l);
-}
-
-static void remove_exception(struct dm_snap_exception *e)
+static void dm_remove_exception(struct dm_exception *e)
 {
        list_del(&e->hash_list);
 }
@@ -406,11 +584,11 @@ static void remove_exception(struct dm_snap_exception *e)
  * Return the exception data for a sector, or NULL if not
  * remapped.
  */
-static struct dm_snap_exception *lookup_exception(struct exception_table *et,
-                                                 chunk_t chunk)
+static struct dm_exception *dm_lookup_exception(struct dm_exception_table *et,
+                                               chunk_t chunk)
 {
        struct list_head *slot;
-       struct dm_snap_exception *e;
+       struct dm_exception *e;
 
        slot = &et->table[exception_hash(et, chunk)];
        list_for_each_entry (e, slot, hash_list)
@@ -421,9 +599,9 @@ static struct dm_snap_exception *lookup_exception(struct exception_table *et,
        return NULL;
 }
 
-static struct dm_snap_exception *alloc_exception(void)
+static struct dm_exception *alloc_completed_exception(void)
 {
-       struct dm_snap_exception *e;
+       struct dm_exception *e;
 
        e = kmem_cache_alloc(exception_cache, GFP_NOIO);
        if (!e)
@@ -432,7 +610,7 @@ static struct dm_snap_exception *alloc_exception(void)
        return e;
 }
 
-static void free_exception(struct dm_snap_exception *e)
+static void free_completed_exception(struct dm_exception *e)
 {
        kmem_cache_free(exception_cache, e);
 }
@@ -457,12 +635,11 @@ static void free_pending_exception(struct dm_snap_pending_exception *pe)
        atomic_dec(&s->pending_exceptions_count);
 }
 
-static void insert_completed_exception(struct dm_snapshot *s,
-                                      struct dm_snap_exception *new_e)
+static void dm_insert_exception(struct dm_exception_table *eh,
+                               struct dm_exception *new_e)
 {
-       struct exception_table *eh = &s->complete;
        struct list_head *l;
-       struct dm_snap_exception *e = NULL;
+       struct dm_exception *e = NULL;
 
        l = &eh->table[exception_hash(eh, new_e->old_chunk)];
 
@@ -478,7 +655,7 @@ static void insert_completed_exception(struct dm_snapshot *s,
                    new_e->new_chunk == (dm_chunk_number(e->new_chunk) +
                                         dm_consecutive_chunk_count(e) + 1)) {
                        dm_consecutive_chunk_count_inc(e);
-                       free_exception(new_e);
+                       free_completed_exception(new_e);
                        return;
                }
 
@@ -488,7 +665,7 @@ static void insert_completed_exception(struct dm_snapshot *s,
                        dm_consecutive_chunk_count_inc(e);
                        e->old_chunk--;
                        e->new_chunk--;
-                       free_exception(new_e);
+                       free_completed_exception(new_e);
                        return;
                }
 
@@ -507,9 +684,9 @@ out:
 static int dm_add_exception(void *context, chunk_t old, chunk_t new)
 {
        struct dm_snapshot *s = context;
-       struct dm_snap_exception *e;
+       struct dm_exception *e;
 
-       e = alloc_exception();
+       e = alloc_completed_exception();
        if (!e)
                return -ENOMEM;
 
@@ -518,11 +695,30 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new)
        /* Consecutive_count is implicitly initialised to zero */
        e->new_chunk = new;
 
-       insert_completed_exception(s, e);
+       dm_insert_exception(&s->complete, e);
 
        return 0;
 }
 
+#define min_not_zero(l, r) (((l) == 0) ? (r) : (((r) == 0) ? (l) : min(l, r)))
+
+/*
+ * Return a minimum chunk size of all snapshots that have the specified origin.
+ * Return zero if the origin has no snapshots.
+ */
+static sector_t __minimum_chunk_size(struct origin *o)
+{
+       struct dm_snapshot *snap;
+       unsigned chunk_size = 0;
+
+       if (o)
+               list_for_each_entry(snap, &o->snapshots, list)
+                       chunk_size = min_not_zero(chunk_size,
+                                                 snap->store->chunk_size);
+
+       return chunk_size;
+}
+
 /*
  * Hard coded magic.
  */
@@ -546,16 +742,18 @@ static int init_hash_tables(struct dm_snapshot *s)
         * Calculate based on the size of the original volume or
         * the COW volume...
         */
-       cow_dev_size = get_dev_size(s->store->cow->bdev);
+       cow_dev_size = get_dev_size(s->cow->bdev);
        origin_dev_size = get_dev_size(s->origin->bdev);
        max_buckets = calc_max_buckets();
 
        hash_size = min(origin_dev_size, cow_dev_size) >> s->store->chunk_shift;
        hash_size = min(hash_size, max_buckets);
 
+       if (hash_size < 64)
+               hash_size = 64;
        hash_size = rounddown_pow_of_two(hash_size);
-       if (init_exception_table(&s->complete, hash_size,
-                                DM_CHUNK_CONSECUTIVE_BITS))
+       if (dm_exception_table_init(&s->complete, hash_size,
+                                   DM_CHUNK_CONSECUTIVE_BITS))
                return -ENOMEM;
 
        /*
@@ -566,14 +764,284 @@ static int init_hash_tables(struct dm_snapshot *s)
        if (hash_size < 64)
                hash_size = 64;
 
-       if (init_exception_table(&s->pending, hash_size, 0)) {
-               exit_exception_table(&s->complete, exception_cache);
+       if (dm_exception_table_init(&s->pending, hash_size, 0)) {
+               dm_exception_table_exit(&s->complete, exception_cache);
                return -ENOMEM;
        }
 
        return 0;
 }
 
+static void merge_shutdown(struct dm_snapshot *s)
+{
+       clear_bit_unlock(RUNNING_MERGE, &s->state_bits);
+       smp_mb__after_clear_bit();
+       wake_up_bit(&s->state_bits, RUNNING_MERGE);
+}
+
+static struct bio *__release_queued_bios_after_merge(struct dm_snapshot *s)
+{
+       s->first_merging_chunk = 0;
+       s->num_merging_chunks = 0;
+
+       return bio_list_get(&s->bios_queued_during_merge);
+}
+
+/*
+ * Remove one chunk from the index of completed exceptions.
+ */
+static int __remove_single_exception_chunk(struct dm_snapshot *s,
+                                          chunk_t old_chunk)
+{
+       struct dm_exception *e;
+
+       e = dm_lookup_exception(&s->complete, old_chunk);
+       if (!e) {
+               DMERR("Corruption detected: exception for block %llu is "
+                     "on disk but not in memory",
+                     (unsigned long long)old_chunk);
+               return -EINVAL;
+       }
+
+       /*
+        * If this is the only chunk using this exception, remove exception.
+        */
+       if (!dm_consecutive_chunk_count(e)) {
+               dm_remove_exception(e);
+               free_completed_exception(e);
+               return 0;
+       }
+
+       /*
+        * The chunk may be either at the beginning or the end of a
+        * group of consecutive chunks - never in the middle.  We are
+        * removing chunks in the opposite order to that in which they
+        * were added, so this should always be true.
+        * Decrement the consecutive chunk counter and adjust the
+        * starting point if necessary.
+        */
+       if (old_chunk == e->old_chunk) {
+               e->old_chunk++;
+               e->new_chunk++;
+       } else if (old_chunk != e->old_chunk +
+                  dm_consecutive_chunk_count(e)) {
+               DMERR("Attempt to merge block %llu from the "
+                     "middle of a chunk range [%llu - %llu]",
+                     (unsigned long long)old_chunk,
+                     (unsigned long long)e->old_chunk,
+                     (unsigned long long)
+                     e->old_chunk + dm_consecutive_chunk_count(e));
+               return -EINVAL;
+       }
+
+       dm_consecutive_chunk_count_dec(e);
+
+       return 0;
+}
+
+static void flush_bios(struct bio *bio);
+
+static int remove_single_exception_chunk(struct dm_snapshot *s)
+{
+       struct bio *b = NULL;
+       int r;
+       chunk_t old_chunk = s->first_merging_chunk + s->num_merging_chunks - 1;
+
+       down_write(&s->lock);
+
+       /*
+        * Process chunks (and associated exceptions) in reverse order
+        * so that dm_consecutive_chunk_count_dec() accounting works.
+        */
+       do {
+               r = __remove_single_exception_chunk(s, old_chunk);
+               if (r)
+                       goto out;
+       } while (old_chunk-- > s->first_merging_chunk);
+
+       b = __release_queued_bios_after_merge(s);
+
+out:
+       up_write(&s->lock);
+       if (b)
+               flush_bios(b);
+
+       return r;
+}
+
+static int origin_write_extent(struct dm_snapshot *merging_snap,
+                              sector_t sector, unsigned chunk_size);
+
+static void merge_callback(int read_err, unsigned long write_err,
+                          void *context);
+
+static uint64_t read_pending_exceptions_done_count(void)
+{
+       uint64_t pending_exceptions_done;
+
+       spin_lock(&_pending_exceptions_done_spinlock);
+       pending_exceptions_done = _pending_exceptions_done_count;
+       spin_unlock(&_pending_exceptions_done_spinlock);
+
+       return pending_exceptions_done;
+}
+
+static void increment_pending_exceptions_done_count(void)
+{
+       spin_lock(&_pending_exceptions_done_spinlock);
+       _pending_exceptions_done_count++;
+       spin_unlock(&_pending_exceptions_done_spinlock);
+
+       wake_up_all(&_pending_exceptions_done);
+}
+
+static void snapshot_merge_next_chunks(struct dm_snapshot *s)
+{
+       int i, linear_chunks;
+       chunk_t old_chunk, new_chunk;
+       struct dm_io_region src, dest;
+       sector_t io_size;
+       uint64_t previous_count;
+
+       BUG_ON(!test_bit(RUNNING_MERGE, &s->state_bits));
+       if (unlikely(test_bit(SHUTDOWN_MERGE, &s->state_bits)))
+               goto shut;
+
+       /*
+        * valid flag never changes during merge, so no lock required.
+        */
+       if (!s->valid) {
+               DMERR("Snapshot is invalid: can't merge");
+               goto shut;
+       }
+
+       linear_chunks = s->store->type->prepare_merge(s->store, &old_chunk,
+                                                     &new_chunk);
+       if (linear_chunks <= 0) {
+               if (linear_chunks < 0) {
+                       DMERR("Read error in exception store: "
+                             "shutting down merge");
+                       down_write(&s->lock);
+                       s->merge_failed = 1;
+                       up_write(&s->lock);
+               }
+               goto shut;
+       }
+
+       /* Adjust old_chunk and new_chunk to reflect start of linear region */
+       old_chunk = old_chunk + 1 - linear_chunks;
+       new_chunk = new_chunk + 1 - linear_chunks;
+
+       /*
+        * Use one (potentially large) I/O to copy all 'linear_chunks'
+        * from the exception store to the origin
+        */
+       io_size = linear_chunks * s->store->chunk_size;
+
+       dest.bdev = s->origin->bdev;
+       dest.sector = chunk_to_sector(s->store, old_chunk);
+       dest.count = min(io_size, get_dev_size(dest.bdev) - dest.sector);
+
+       src.bdev = s->cow->bdev;
+       src.sector = chunk_to_sector(s->store, new_chunk);
+       src.count = dest.count;
+
+       /*
+        * Reallocate any exceptions needed in other snapshots then
+        * wait for the pending exceptions to complete.
+        * Each time any pending exception (globally on the system)
+        * completes we are woken and repeat the process to find out
+        * if we can proceed.  While this may not seem a particularly
+        * efficient algorithm, it is not expected to have any
+        * significant impact on performance.
+        */
+       previous_count = read_pending_exceptions_done_count();
+       while (origin_write_extent(s, dest.sector, io_size)) {
+               wait_event(_pending_exceptions_done,
+                          (read_pending_exceptions_done_count() !=
+                           previous_count));
+               /* Retry after the wait, until all exceptions are done. */
+               previous_count = read_pending_exceptions_done_count();
+       }
+
+       down_write(&s->lock);
+       s->first_merging_chunk = old_chunk;
+       s->num_merging_chunks = linear_chunks;
+       up_write(&s->lock);
+
+       /* Wait until writes to all 'linear_chunks' drain */
+       for (i = 0; i < linear_chunks; i++)
+               __check_for_conflicting_io(s, old_chunk + i);
+
+       dm_kcopyd_copy(s->kcopyd_client, &src, 1, &dest, 0, merge_callback, s);
+       return;
+
+shut:
+       merge_shutdown(s);
+}
+
+static void error_bios(struct bio *bio);
+
+static void merge_callback(int read_err, unsigned long write_err, void *context)
+{
+       struct dm_snapshot *s = context;
+       struct bio *b = NULL;
+
+       if (read_err || write_err) {
+               if (read_err)
+                       DMERR("Read error: shutting down merge.");
+               else
+                       DMERR("Write error: shutting down merge.");
+               goto shut;
+       }
+
+       if (s->store->type->commit_merge(s->store,
+                                        s->num_merging_chunks) < 0) {
+               DMERR("Write error in exception store: shutting down merge");
+               goto shut;
+       }
+
+       if (remove_single_exception_chunk(s) < 0)
+               goto shut;
+
+       snapshot_merge_next_chunks(s);
+
+       return;
+
+shut:
+       down_write(&s->lock);
+       s->merge_failed = 1;
+       b = __release_queued_bios_after_merge(s);
+       up_write(&s->lock);
+       error_bios(b);
+
+       merge_shutdown(s);
+}
+
+static void start_merge(struct dm_snapshot *s)
+{
+       if (!test_and_set_bit(RUNNING_MERGE, &s->state_bits))
+               snapshot_merge_next_chunks(s);
+}
+
+static int wait_schedule(void *ptr)
+{
+       schedule();
+
+       return 0;
+}
+
+/*
+ * Stop the merging process and wait until it finishes.
+ */
+static void stop_merge(struct dm_snapshot *s)
+{
+       set_bit(SHUTDOWN_MERGE, &s->state_bits);
+       wait_on_bit(&s->state_bits, RUNNING_MERGE, wait_schedule,
+                   TASK_UNINTERRUPTIBLE);
+       clear_bit(SHUTDOWN_MERGE, &s->state_bits);
+}
+
 /*
  * Construct a snapshot mapping: <origin_dev> <COW-dev> <p/n> <chunk-size>
  */
@@ -582,50 +1050,73 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
        struct dm_snapshot *s;
        int i;
        int r = -EINVAL;
-       char *origin_path;
-       struct dm_exception_store *store;
-       unsigned args_used;
+       char *origin_path, *cow_path;
+       unsigned args_used, num_flush_requests = 1;
+       fmode_t origin_mode = FMODE_READ;
 
        if (argc != 4) {
                ti->error = "requires exactly 4 arguments";
                r = -EINVAL;
-               goto bad_args;
+               goto bad;
+       }
+
+       if (dm_target_is_snapshot_merge(ti)) {
+               num_flush_requests = 2;
+               origin_mode = FMODE_WRITE;
        }
 
        origin_path = argv[0];
        argv++;
        argc--;
 
-       r = dm_exception_store_create(ti, argc, argv, &args_used, &store);
+       s = kmalloc(sizeof(*s), GFP_KERNEL);
+       if (!s) {
+               ti->error = "Cannot allocate snapshot context private "
+                   "structure";
+               r = -ENOMEM;
+               goto bad;
+       }
+
+       cow_path = argv[0];
+       argv++;
+       argc--;
+
+       r = dm_get_device(ti, cow_path, 0, 0,
+                         FMODE_READ | FMODE_WRITE, &s->cow);
+       if (r) {
+               ti->error = "Cannot get COW device";
+               goto bad_cow;
+       }
+
+       r = dm_exception_store_create(ti, argc, argv, s, &args_used, &s->store);
        if (r) {
                ti->error = "Couldn't create exception store";
                r = -EINVAL;
-               goto bad_args;
+               goto bad_store;
        }
 
        argv += args_used;
        argc -= args_used;
 
-       s = kmalloc(sizeof(*s), GFP_KERNEL);
-       if (!s) {
-               ti->error = "Cannot allocate snapshot context private "
-                   "structure";
-               r = -ENOMEM;
-               goto bad_snap;
-       }
-
-       r = dm_get_device(ti, origin_path, 0, ti->len, FMODE_READ, &s->origin);
+       r = dm_get_device(ti, origin_path, 0, ti->len, origin_mode, &s->origin);
        if (r) {
                ti->error = "Cannot get origin device";
                goto bad_origin;
        }
 
-       s->store = store;
+       s->ti = ti;
        s->valid = 1;
        s->active = 0;
+       s->suspended = 0;
        atomic_set(&s->pending_exceptions_count, 0);
        init_rwsem(&s->lock);
+       INIT_LIST_HEAD(&s->list);
        spin_lock_init(&s->pe_lock);
+       s->state_bits = 0;
+       s->merge_failed = 0;
+       s->first_merging_chunk = 0;
+       s->num_merging_chunks = 0;
+       bio_list_init(&s->bios_queued_during_merge);
 
        /* Allocate hash table for COW data */
        if (init_hash_tables(s)) {
@@ -659,39 +1150,55 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 
        spin_lock_init(&s->tracked_chunk_lock);
 
-       /* Metadata must only be loaded into one table at once */
+       bio_list_init(&s->queued_bios);
+       INIT_WORK(&s->queued_bios_work, flush_queued_bios);
+
+       ti->private = s;
+       ti->num_flush_requests = num_flush_requests;
+
+       /* Add snapshot to the list of snapshots for this origin */
+       /* Exceptions aren't triggered till snapshot_resume() is called */
+       r = register_snapshot(s);
+       if (r == -ENOMEM) {
+               ti->error = "Snapshot origin struct allocation failed";
+               goto bad_load_and_register;
+       } else if (r < 0) {
+               /* invalid handover, register_snapshot has set ti->error */
+               goto bad_load_and_register;
+       }
+
+       /*
+        * Metadata must only be loaded into one table at once, so skip this
+        * if metadata will be handed over during resume.
+        * Chunk size will be set during the handover - set it to zero to
+        * ensure it's ignored.
+        */
+       if (r > 0) {
+               s->store->chunk_size = 0;
+               return 0;
+       }
+
        r = s->store->type->read_metadata(s->store, dm_add_exception,
                                          (void *)s);
        if (r < 0) {
                ti->error = "Failed to read snapshot metadata";
-               goto bad_load_and_register;
+               goto bad_read_metadata;
        } else if (r > 0) {
                s->valid = 0;
                DMWARN("Snapshot is marked invalid.");
        }
 
-       bio_list_init(&s->queued_bios);
-       INIT_WORK(&s->queued_bios_work, flush_queued_bios);
-
        if (!s->store->chunk_size) {
                ti->error = "Chunk size not set";
-               goto bad_load_and_register;
-       }
-
-       /* Add snapshot to the list of snapshots for this origin */
-       /* Exceptions aren't triggered till snapshot_resume() is called */
-       if (register_snapshot(s)) {
-               r = -EINVAL;
-               ti->error = "Cannot register snapshot origin";
-               goto bad_load_and_register;
+               goto bad_read_metadata;
        }
-
-       ti->private = s;
        ti->split_io = s->store->chunk_size;
-       ti->num_flush_requests = 1;
 
        return 0;
 
+bad_read_metadata:
+       unregister_snapshot(s);
+
 bad_load_and_register:
        mempool_destroy(s->tracked_chunk_pool);
 
@@ -702,19 +1209,22 @@ bad_pending_pool:
        dm_kcopyd_client_destroy(s->kcopyd_client);
 
 bad_kcopyd:
-       exit_exception_table(&s->pending, pending_cache);
-       exit_exception_table(&s->complete, exception_cache);
+       dm_exception_table_exit(&s->pending, pending_cache);
+       dm_exception_table_exit(&s->complete, exception_cache);
 
 bad_hash_tables:
        dm_put_device(ti, s->origin);
 
 bad_origin:
-       kfree(s);
+       dm_exception_store_destroy(s->store);
 
-bad_snap:
-       dm_exception_store_destroy(store);
+bad_store:
+       dm_put_device(ti, s->cow);
+
+bad_cow:
+       kfree(s);
 
-bad_args:
+bad:
        return r;
 }
 
@@ -723,8 +1233,39 @@ static void __free_exceptions(struct dm_snapshot *s)
        dm_kcopyd_client_destroy(s->kcopyd_client);
        s->kcopyd_client = NULL;
 
-       exit_exception_table(&s->pending, pending_cache);
-       exit_exception_table(&s->complete, exception_cache);
+       dm_exception_table_exit(&s->pending, pending_cache);
+       dm_exception_table_exit(&s->complete, exception_cache);
+}
+
+static void __handover_exceptions(struct dm_snapshot *snap_src,
+                                 struct dm_snapshot *snap_dest)
+{
+       union {
+               struct dm_exception_table table_swap;
+               struct dm_exception_store *store_swap;
+       } u;
+
+       /*
+        * Swap all snapshot context information between the two instances.
+        */
+       u.table_swap = snap_dest->complete;
+       snap_dest->complete = snap_src->complete;
+       snap_src->complete = u.table_swap;
+
+       u.store_swap = snap_dest->store;
+       snap_dest->store = snap_src->store;
+       snap_src->store = u.store_swap;
+
+       snap_dest->store->snap = snap_dest;
+       snap_src->store->snap = snap_src;
+
+       snap_dest->ti->split_io = snap_dest->store->chunk_size;
+       snap_dest->valid = snap_src->valid;
+
+       /*
+        * Set source invalid to ensure it receives no further I/O.
+        */
+       snap_src->valid = 0;
 }
 
 static void snapshot_dtr(struct dm_target *ti)
@@ -733,9 +1274,24 @@ static void snapshot_dtr(struct dm_target *ti)
        int i;
 #endif
        struct dm_snapshot *s = ti->private;
+       struct dm_snapshot *snap_src = NULL, *snap_dest = NULL;
 
        flush_workqueue(ksnapd);
 
+       down_read(&_origins_lock);
+       /* Check whether exception handover must be cancelled */
+       (void) __find_snapshots_sharing_cow(s, &snap_src, &snap_dest, NULL);
+       if (snap_src && snap_dest && (s == snap_src)) {
+               down_write(&snap_dest->lock);
+               snap_dest->valid = 0;
+               up_write(&snap_dest->lock);
+               DMERR("Cancelling snapshot handover.");
+       }
+       up_read(&_origins_lock);
+
+       if (dm_target_is_snapshot_merge(ti))
+               stop_merge(s);
+
        /* Prevent further origin writes from using this snapshot. */
        /* After this returns there can be no new kcopyd jobs. */
        unregister_snapshot(s);
@@ -763,6 +1319,8 @@ static void snapshot_dtr(struct dm_target *ti)
 
        dm_exception_store_destroy(s->store);
 
+       dm_put_device(ti, s->cow);
+
        kfree(s);
 }
 
@@ -795,6 +1353,26 @@ static void flush_queued_bios(struct work_struct *work)
        flush_bios(queued_bios);
 }
 
+static int do_origin(struct dm_dev *origin, struct bio *bio);
+
+/*
+ * Flush a list of buffers.
+ */
+static void retry_origin_bios(struct dm_snapshot *s, struct bio *bio)
+{
+       struct bio *n;
+       int r;
+
+       while (bio) {
+               n = bio->bi_next;
+               bio->bi_next = NULL;
+               r = do_origin(s->origin, bio);
+               if (r == DM_MAPIO_REMAPPED)
+                       generic_make_request(bio);
+               bio = n;
+       }
+}
+
 /*
  * Error a list of buffers.
  */
@@ -825,45 +1403,12 @@ static void __invalidate_snapshot(struct dm_snapshot *s, int err)
 
        s->valid = 0;
 
-       dm_table_event(s->store->ti->table);
-}
-
-static void get_pending_exception(struct dm_snap_pending_exception *pe)
-{
-       atomic_inc(&pe->ref_count);
-}
-
-static struct bio *put_pending_exception(struct dm_snap_pending_exception *pe)
-{
-       struct dm_snap_pending_exception *primary_pe;
-       struct bio *origin_bios = NULL;
-
-       primary_pe = pe->primary_pe;
-
-       /*
-        * If this pe is involved in a write to the origin and
-        * it is the last sibling to complete then release
-        * the bios for the original write to the origin.
-        */
-       if (primary_pe &&
-           atomic_dec_and_test(&primary_pe->ref_count)) {
-               origin_bios = bio_list_get(&primary_pe->origin_bios);
-               free_pending_exception(primary_pe);
-       }
-
-       /*
-        * Free the pe if it's not linked to an origin write or if
-        * it's not itself a primary pe.
-        */
-       if (!primary_pe || primary_pe != pe)
-               free_pending_exception(pe);
-
-       return origin_bios;
+       dm_table_event(s->ti->table);
 }
 
 static void pending_complete(struct dm_snap_pending_exception *pe, int success)
 {
-       struct dm_snap_exception *e;
+       struct dm_exception *e;
        struct dm_snapshot *s = pe->snap;
        struct bio *origin_bios = NULL;
        struct bio *snapshot_bios = NULL;
@@ -877,7 +1422,7 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
                goto out;
        }
 
-       e = alloc_exception();
+       e = alloc_completed_exception();
        if (!e) {
                down_write(&s->lock);
                __invalidate_snapshot(s, -ENOMEM);
@@ -888,28 +1433,27 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
 
        down_write(&s->lock);
        if (!s->valid) {
-               free_exception(e);
+               free_completed_exception(e);
                error = 1;
                goto out;
        }
 
-       /*
-        * Check for conflicting reads. This is extremely improbable,
-        * so msleep(1) is sufficient and there is no need for a wait queue.
-        */
-       while (__chunk_is_tracked(s, pe->e.old_chunk))
-               msleep(1);
+       /* Check for conflicting reads */
+       __check_for_conflicting_io(s, pe->e.old_chunk);
 
        /*
         * Add a proper exception, and remove the
         * in-flight exception from the list.
         */
-       insert_completed_exception(s, e);
+       dm_insert_exception(&s->complete, e);
 
  out:
-       remove_exception(&pe->e);
+       dm_remove_exception(&pe->e);
        snapshot_bios = bio_list_get(&pe->snapshot_bios);
-       origin_bios = put_pending_exception(pe);
+       origin_bios = bio_list_get(&pe->origin_bios);
+       free_pending_exception(pe);
+
+       increment_pending_exceptions_done_count();
 
        up_write(&s->lock);
 
@@ -919,7 +1463,7 @@ static void pending_complete(struct dm_snap_pending_exception *pe, int success)
        else
                flush_bios(snapshot_bios);
 
-       flush_bios(origin_bios);
+       retry_origin_bios(s, origin_bios);
 }
 
 static void commit_callback(void *context, int success)
@@ -963,7 +1507,7 @@ static void start_copy(struct dm_snap_pending_exception *pe)
        src.sector = chunk_to_sector(s->store, pe->e.old_chunk);
        src.count = min((sector_t)s->store->chunk_size, dev_size - src.sector);
 
-       dest.bdev = s->store->cow->bdev;
+       dest.bdev = s->cow->bdev;
        dest.sector = chunk_to_sector(s->store, pe->e.new_chunk);
        dest.count = src.count;
 
@@ -975,7 +1519,7 @@ static void start_copy(struct dm_snap_pending_exception *pe)
 static struct dm_snap_pending_exception *
 __lookup_pending_exception(struct dm_snapshot *s, chunk_t chunk)
 {
-       struct dm_snap_exception *e = lookup_exception(&s->pending, chunk);
+       struct dm_exception *e = dm_lookup_exception(&s->pending, chunk);
 
        if (!e)
                return NULL;
@@ -1006,8 +1550,6 @@ __find_pending_exception(struct dm_snapshot *s,
        pe->e.old_chunk = chunk;
        bio_list_init(&pe->origin_bios);
        bio_list_init(&pe->snapshot_bios);
-       pe->primary_pe = NULL;
-       atomic_set(&pe->ref_count, 0);
        pe->started = 0;
 
        if (s->store->type->prepare_exception(s->store, &pe->e)) {
@@ -1015,16 +1557,15 @@ __find_pending_exception(struct dm_snapshot *s,
                return NULL;
        }
 
-       get_pending_exception(pe);
-       insert_exception(&s->pending, &pe->e);
+       dm_insert_exception(&s->pending, &pe->e);
 
        return pe;
 }
 
-static void remap_exception(struct dm_snapshot *s, struct dm_snap_exception *e,
+static void remap_exception(struct dm_snapshot *s, struct dm_exception *e,
                            struct bio *bio, chunk_t chunk)
 {
-       bio->bi_bdev = s->store->cow->bdev;
+       bio->bi_bdev = s->cow->bdev;
        bio->bi_sector = chunk_to_sector(s->store,
                                         dm_chunk_number(e->new_chunk) +
                                         (chunk - e->old_chunk)) +
@@ -1035,14 +1576,14 @@ static void remap_exception(struct dm_snapshot *s, struct dm_snap_exception *e,
 static int snapshot_map(struct dm_target *ti, struct bio *bio,
                        union map_info *map_context)
 {
-       struct dm_snap_exception *e;
+       struct dm_exception *e;
        struct dm_snapshot *s = ti->private;
        int r = DM_MAPIO_REMAPPED;
        chunk_t chunk;
        struct dm_snap_pending_exception *pe = NULL;
 
        if (unlikely(bio_empty_barrier(bio))) {
-               bio->bi_bdev = s->store->cow->bdev;
+               bio->bi_bdev = s->cow->bdev;
                return DM_MAPIO_REMAPPED;
        }
 
@@ -1063,7 +1604,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
        }
 
        /* If the block is already remapped - use that, else remap it */
-       e = lookup_exception(&s->complete, chunk);
+       e = dm_lookup_exception(&s->complete, chunk);
        if (e) {
                remap_exception(s, e, bio, chunk);
                goto out_unlock;
@@ -1087,7 +1628,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
                                goto out_unlock;
                        }
 
-                       e = lookup_exception(&s->complete, chunk);
+                       e = dm_lookup_exception(&s->complete, chunk);
                        if (e) {
                                free_pending_exception(pe);
                                remap_exception(s, e, bio, chunk);
@@ -1125,6 +1666,78 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
        return r;
 }
 
+/*
+ * A snapshot-merge target behaves like a combination of a snapshot
+ * target and a snapshot-origin target.  It only generates new
+ * exceptions in other snapshots and not in the one that is being
+ * merged.
+ *
+ * For each chunk, if there is an existing exception, it is used to
+ * redirect I/O to the cow device.  Otherwise I/O is sent to the origin,
+ * which in turn might generate exceptions in other snapshots.
+ * If merging is currently taking place on the chunk in question, the
+ * I/O is deferred by adding it to s->bios_queued_during_merge.
+ */
+static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
+                             union map_info *map_context)
+{
+       struct dm_exception *e;
+       struct dm_snapshot *s = ti->private;
+       int r = DM_MAPIO_REMAPPED;
+       chunk_t chunk;
+
+       if (unlikely(bio_empty_barrier(bio))) {
+               if (!map_context->flush_request)
+                       bio->bi_bdev = s->origin->bdev;
+               else
+                       bio->bi_bdev = s->cow->bdev;
+               map_context->ptr = NULL;
+               return DM_MAPIO_REMAPPED;
+       }
+
+       chunk = sector_to_chunk(s->store, bio->bi_sector);
+
+       down_write(&s->lock);
+
+       /* Full merging snapshots are redirected to the origin */
+       if (!s->valid)
+               goto redirect_to_origin;
+
+       /* If the block is already remapped - use that */
+       e = dm_lookup_exception(&s->complete, chunk);
+       if (e) {
+               /* Queue writes overlapping with chunks being merged */
+               if (bio_rw(bio) == WRITE &&
+                   chunk >= s->first_merging_chunk &&
+                   chunk < (s->first_merging_chunk +
+                            s->num_merging_chunks)) {
+                       bio->bi_bdev = s->origin->bdev;
+                       bio_list_add(&s->bios_queued_during_merge, bio);
+                       r = DM_MAPIO_SUBMITTED;
+                       goto out_unlock;
+               }
+
+               remap_exception(s, e, bio, chunk);
+
+               if (bio_rw(bio) == WRITE)
+                       map_context->ptr = track_chunk(s, chunk);
+               goto out_unlock;
+       }
+
+redirect_to_origin:
+       bio->bi_bdev = s->origin->bdev;
+
+       if (bio_rw(bio) == WRITE) {
+               up_write(&s->lock);
+               return do_origin(s->origin, bio);
+       }
+
+out_unlock:
+       up_write(&s->lock);
+
+       return r;
+}
+
 static int snapshot_end_io(struct dm_target *ti, struct bio *bio,
                           int error, union map_info *map_context)
 {
@@ -1137,40 +1750,135 @@ static int snapshot_end_io(struct dm_target *ti, struct bio *bio,
        return 0;
 }
 
+static void snapshot_merge_presuspend(struct dm_target *ti)
+{
+       struct dm_snapshot *s = ti->private;
+
+       stop_merge(s);
+}
+
+static void snapshot_postsuspend(struct dm_target *ti)
+{
+       struct dm_snapshot *s = ti->private;
+
+       down_write(&s->lock);
+       s->suspended = 1;
+       up_write(&s->lock);
+}
+
+static int snapshot_preresume(struct dm_target *ti)
+{
+       int r = 0;
+       struct dm_snapshot *s = ti->private;
+       struct dm_snapshot *snap_src = NULL, *snap_dest = NULL;
+
+       down_read(&_origins_lock);
+       (void) __find_snapshots_sharing_cow(s, &snap_src, &snap_dest, NULL);
+       if (snap_src && snap_dest) {
+               down_read(&snap_src->lock);
+               if (s == snap_src) {
+                       DMERR("Unable to resume snapshot source until "
+                             "handover completes.");
+                       r = -EINVAL;
+               } else if (!snap_src->suspended) {
+                       DMERR("Unable to perform snapshot handover until "
+                             "source is suspended.");
+                       r = -EINVAL;
+               }
+               up_read(&snap_src->lock);
+       }
+       up_read(&_origins_lock);
+
+       return r;
+}
+
 static void snapshot_resume(struct dm_target *ti)
 {
        struct dm_snapshot *s = ti->private;
+       struct dm_snapshot *snap_src = NULL, *snap_dest = NULL;
+
+       down_read(&_origins_lock);
+       (void) __find_snapshots_sharing_cow(s, &snap_src, &snap_dest, NULL);
+       if (snap_src && snap_dest) {
+               down_write(&snap_src->lock);
+               down_write_nested(&snap_dest->lock, SINGLE_DEPTH_NESTING);
+               __handover_exceptions(snap_src, snap_dest);
+               up_write(&snap_dest->lock);
+               up_write(&snap_src->lock);
+       }
+       up_read(&_origins_lock);
+
+       /* Now we have correct chunk size, reregister */
+       reregister_snapshot(s);
 
        down_write(&s->lock);
        s->active = 1;
+       s->suspended = 0;
        up_write(&s->lock);
 }
 
+static sector_t get_origin_minimum_chunksize(struct block_device *bdev)
+{
+       sector_t min_chunksize;
+
+       down_read(&_origins_lock);
+       min_chunksize = __minimum_chunk_size(__lookup_origin(bdev));
+       up_read(&_origins_lock);
+
+       return min_chunksize;
+}
+
+static void snapshot_merge_resume(struct dm_target *ti)
+{
+       struct dm_snapshot *s = ti->private;
+
+       /*
+        * Handover exceptions from existing snapshot.
+        */
+       snapshot_resume(ti);
+
+       /*
+        * snapshot-merge acts as an origin, so set ti->split_io
+        */
+       ti->split_io = get_origin_minimum_chunksize(s->origin->bdev);
+
+       start_merge(s);
+}
+
 static int snapshot_status(struct dm_target *ti, status_type_t type,
                           char *result, unsigned int maxlen)
 {
        unsigned sz = 0;
        struct dm_snapshot *snap = ti->private;
 
-       down_write(&snap->lock);
-
        switch (type) {
        case STATUSTYPE_INFO:
+
+               down_write(&snap->lock);
+
                if (!snap->valid)
                        DMEMIT("Invalid");
+               else if (snap->merge_failed)
+                       DMEMIT("Merge failed");
                else {
-                       if (snap->store->type->fraction_full) {
-                               sector_t numerator, denominator;
-                               snap->store->type->fraction_full(snap->store,
-                                                                &numerator,
-                                                                &denominator);
-                               DMEMIT("%llu/%llu",
-                                      (unsigned long long)numerator,
-                                      (unsigned long long)denominator);
+                       if (snap->store->type->usage) {
+                               sector_t total_sectors, sectors_allocated,
+                                        metadata_sectors;
+                               snap->store->type->usage(snap->store,
+                                                        &total_sectors,
+                                                        &sectors_allocated,
+                                                        &metadata_sectors);
+                               DMEMIT("%llu/%llu %llu",
+                                      (unsigned long long)sectors_allocated,
+                                      (unsigned long long)total_sectors,
+                                      (unsigned long long)metadata_sectors);
                        }
                        else
                                DMEMIT("Unknown");
                }
+
+               up_write(&snap->lock);
+
                break;
 
        case STATUSTYPE_TABLE:
@@ -1179,14 +1887,12 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
                 * to make private copies if the output is to
                 * make sense.
                 */
-               DMEMIT("%s", snap->origin->name);
+               DMEMIT("%s %s", snap->origin->name, snap->cow->name);
                snap->store->type->status(snap->store, type, result + sz,
                                          maxlen - sz);
                break;
        }
 
-       up_write(&snap->lock);
-
        return 0;
 }
 
@@ -1202,17 +1908,36 @@ static int snapshot_iterate_devices(struct dm_target *ti,
 /*-----------------------------------------------------------------
  * Origin methods
  *---------------------------------------------------------------*/
-static int __origin_write(struct list_head *snapshots, struct bio *bio)
+
+/*
+ * If no exceptions need creating, DM_MAPIO_REMAPPED is returned and any
+ * supplied bio was ignored.  The caller may submit it immediately.
+ * (No remapping actually occurs as the origin is always a direct linear
+ * map.)
+ *
+ * If further exceptions are required, DM_MAPIO_SUBMITTED is returned
+ * and any supplied bio is added to a list to be submitted once all
+ * the necessary exceptions exist.
+ */
+static int __origin_write(struct list_head *snapshots, sector_t sector,
+                         struct bio *bio)
 {
-       int r = DM_MAPIO_REMAPPED, first = 0;
+       int r = DM_MAPIO_REMAPPED;
        struct dm_snapshot *snap;
-       struct dm_snap_exception *e;
-       struct dm_snap_pending_exception *pe, *next_pe, *primary_pe = NULL;
+       struct dm_exception *e;
+       struct dm_snap_pending_exception *pe;
+       struct dm_snap_pending_exception *pe_to_start_now = NULL;
+       struct dm_snap_pending_exception *pe_to_start_last = NULL;
        chunk_t chunk;
-       LIST_HEAD(pe_queue);
 
        /* Do all the snapshots on this origin */
        list_for_each_entry (snap, snapshots, list) {
+               /*
+                * Don't make new exceptions in a merging snapshot
+                * because it has effectively been deleted
+                */
+               if (dm_target_is_snapshot_merge(snap->ti))
+                       continue;
 
                down_write(&snap->lock);
 
@@ -1221,24 +1946,21 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
                        goto next_snapshot;
 
                /* Nothing to do if writing beyond end of snapshot */
-               if (bio->bi_sector >= dm_table_get_size(snap->store->ti->table))
+               if (sector >= dm_table_get_size(snap->ti->table))
                        goto next_snapshot;
 
                /*
                 * Remember, different snapshots can have
                 * different chunk sizes.
                 */
-               chunk = sector_to_chunk(snap->store, bio->bi_sector);
+               chunk = sector_to_chunk(snap->store, sector);
 
                /*
                 * Check exception table to see if block
                 * is already remapped in this snapshot
                 * and trigger an exception if not.
-                *
-                * ref_count is initialised to 1 so pending_complete()
-                * won't destroy the primary_pe while we're inside this loop.
                 */
-               e = lookup_exception(&snap->complete, chunk);
+               e = dm_lookup_exception(&snap->complete, chunk);
                if (e)
                        goto next_snapshot;
 
@@ -1253,7 +1975,7 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
                                goto next_snapshot;
                        }
 
-                       e = lookup_exception(&snap->complete, chunk);
+                       e = dm_lookup_exception(&snap->complete, chunk);
                        if (e) {
                                free_pending_exception(pe);
                                goto next_snapshot;
@@ -1266,59 +1988,43 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
                        }
                }
 
-               if (!primary_pe) {
-                       /*
-                        * Either every pe here has same
-                        * primary_pe or none has one yet.
-                        */
-                       if (pe->primary_pe)
-                               primary_pe = pe->primary_pe;
-                       else {
-                               primary_pe = pe;
-                               first = 1;
-                       }
-
-                       bio_list_add(&primary_pe->origin_bios, bio);
+               r = DM_MAPIO_SUBMITTED;
 
-                       r = DM_MAPIO_SUBMITTED;
-               }
+               /*
+                * If an origin bio was supplied, queue it to wait for the
+                * completion of this exception, and start this one last,
+                * at the end of the function.
+                */
+               if (bio) {
+                       bio_list_add(&pe->origin_bios, bio);
+                       bio = NULL;
 
-               if (!pe->primary_pe) {
-                       pe->primary_pe = primary_pe;
-                       get_pending_exception(primary_pe);
+                       if (!pe->started) {
+                               pe->started = 1;
+                               pe_to_start_last = pe;
+                       }
                }
 
                if (!pe->started) {
                        pe->started = 1;
-                       list_add_tail(&pe->list, &pe_queue);
+                       pe_to_start_now = pe;
                }
 
  next_snapshot:
                up_write(&snap->lock);
-       }
 
-       if (!primary_pe)
-               return r;
-
-       /*
-        * If this is the first time we're processing this chunk and
-        * ref_count is now 1 it means all the pending exceptions
-        * got completed while we were in the loop above, so it falls to
-        * us here to remove the primary_pe and submit any origin_bios.
-        */
-
-       if (first && atomic_dec_and_test(&primary_pe->ref_count)) {
-               flush_bios(bio_list_get(&primary_pe->origin_bios));
-               free_pending_exception(primary_pe);
-               /* If we got here, pe_queue is necessarily empty. */
-               return r;
+               if (pe_to_start_now) {
+                       start_copy(pe_to_start_now);
+                       pe_to_start_now = NULL;
+               }
        }
 
        /*
-        * Now that we have a complete pe list we can start the copying.
+        * Submit the exception against which the bio is queued last,
+        * to give the other exceptions a head start.
         */
-       list_for_each_entry_safe(pe, next_pe, &pe_queue, list)
-               start_copy(pe);
+       if (pe_to_start_last)
+               start_copy(pe_to_start_last);
 
        return r;
 }
@@ -1334,12 +2040,47 @@ static int do_origin(struct dm_dev *origin, struct bio *bio)
        down_read(&_origins_lock);
        o = __lookup_origin(origin->bdev);
        if (o)
-               r = __origin_write(&o->snapshots, bio);
+               r = __origin_write(&o->snapshots, bio->bi_sector, bio);
        up_read(&_origins_lock);
 
        return r;
 }
 
+/*
+ * Trigger exceptions in all non-merging snapshots.
+ *
+ * The chunk size of the merging snapshot may be larger than the chunk
+ * size of some other snapshot so we may need to reallocate multiple
+ * chunks in other snapshots.
+ *
+ * We scan all the overlapping exceptions in the other snapshots.
+ * Returns 1 if anything was reallocated and must be waited for,
+ * otherwise returns 0.
+ *
+ * size must be a multiple of merging_snap's chunk_size.
+ */
+static int origin_write_extent(struct dm_snapshot *merging_snap,
+                              sector_t sector, unsigned size)
+{
+       int must_wait = 0;
+       sector_t n;
+       struct origin *o;
+
+       /*
+        * The origin's __minimum_chunk_size() got stored in split_io
+        * by snapshot_merge_resume().
+        */
+       down_read(&_origins_lock);
+       o = __lookup_origin(merging_snap->origin->bdev);
+       for (n = 0; n < size; n += merging_snap->ti->split_io)
+               if (__origin_write(&o->snapshots, sector + n, NULL) ==
+                   DM_MAPIO_SUBMITTED)
+                       must_wait = 1;
+       up_read(&_origins_lock);
+
+       return must_wait;
+}
+
 /*
  * Origin: maps a linear range of a device, with hooks for snapshotting.
  */
@@ -1391,8 +2132,6 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
        return (bio_rw(bio) == WRITE) ? do_origin(dev, bio) : DM_MAPIO_REMAPPED;
 }
 
-#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
-
 /*
  * Set the target "split_io" field to the minimum of all the snapshots'
  * chunk sizes.
@@ -1400,19 +2139,8 @@ static int origin_map(struct dm_target *ti, struct bio *bio,
 static void origin_resume(struct dm_target *ti)
 {
        struct dm_dev *dev = ti->private;
-       struct dm_snapshot *snap;
-       struct origin *o;
-       unsigned chunk_size = 0;
-
-       down_read(&_origins_lock);
-       o = __lookup_origin(dev->bdev);
-       if (o)
-               list_for_each_entry (snap, &o->snapshots, list)
-                       chunk_size = min_not_zero(chunk_size,
-                                                 snap->store->chunk_size);
-       up_read(&_origins_lock);
 
-       ti->split_io = chunk_size;
+       ti->split_io = get_origin_minimum_chunksize(dev->bdev);
 }
 
 static int origin_status(struct dm_target *ti, status_type_t type, char *result,
@@ -1455,17 +2183,35 @@ static struct target_type origin_target = {
 
 static struct target_type snapshot_target = {
        .name    = "snapshot",
-       .version = {1, 7, 0},
+       .version = {1, 9, 0},
        .module  = THIS_MODULE,
        .ctr     = snapshot_ctr,
        .dtr     = snapshot_dtr,
        .map     = snapshot_map,
        .end_io  = snapshot_end_io,
+       .postsuspend = snapshot_postsuspend,
+       .preresume  = snapshot_preresume,
        .resume  = snapshot_resume,
        .status  = snapshot_status,
        .iterate_devices = snapshot_iterate_devices,
 };
 
+static struct target_type merge_target = {
+       .name    = dm_snapshot_merge_target_name,
+       .version = {1, 0, 0},
+       .module  = THIS_MODULE,
+       .ctr     = snapshot_ctr,
+       .dtr     = snapshot_dtr,
+       .map     = snapshot_merge_map,
+       .end_io  = snapshot_end_io,
+       .presuspend = snapshot_merge_presuspend,
+       .postsuspend = snapshot_postsuspend,
+       .preresume  = snapshot_preresume,
+       .resume  = snapshot_merge_resume,
+       .status  = snapshot_status,
+       .iterate_devices = snapshot_iterate_devices,
+};
+
 static int __init dm_snapshot_init(void)
 {
        int r;
@@ -1477,7 +2223,7 @@ static int __init dm_snapshot_init(void)
        }
 
        r = dm_register_target(&snapshot_target);
-       if (r) {
+       if (r < 0) {
                DMERR("snapshot target register failed %d", r);
                goto bad_register_snapshot_target;
        }
@@ -1485,34 +2231,40 @@ static int __init dm_snapshot_init(void)
        r = dm_register_target(&origin_target);
        if (r < 0) {
                DMERR("Origin target register failed %d", r);
-               goto bad1;
+               goto bad_register_origin_target;
+       }
+
+       r = dm_register_target(&merge_target);
+       if (r < 0) {
+               DMERR("Merge target register failed %d", r);
+               goto bad_register_merge_target;
        }
 
        r = init_origin_hash();
        if (r) {
                DMERR("init_origin_hash failed.");
-               goto bad2;
+               goto bad_origin_hash;
        }
 
-       exception_cache = KMEM_CACHE(dm_snap_exception, 0);
+       exception_cache = KMEM_CACHE(dm_exception, 0);
        if (!exception_cache) {
                DMERR("Couldn't create exception cache.");
                r = -ENOMEM;
-               goto bad3;
+               goto bad_exception_cache;
        }
 
        pending_cache = KMEM_CACHE(dm_snap_pending_exception, 0);
        if (!pending_cache) {
                DMERR("Couldn't create pending cache.");
                r = -ENOMEM;
-               goto bad4;
+               goto bad_pending_cache;
        }
 
        tracked_chunk_cache = KMEM_CACHE(dm_snap_tracked_chunk, 0);
        if (!tracked_chunk_cache) {
                DMERR("Couldn't create cache to track chunks in use.");
                r = -ENOMEM;
-               goto bad5;
+               goto bad_tracked_chunk_cache;
        }
 
        ksnapd = create_singlethread_workqueue("ksnapd");
@@ -1526,19 +2278,21 @@ static int __init dm_snapshot_init(void)
 
 bad_pending_pool:
        kmem_cache_destroy(tracked_chunk_cache);
-bad5:
+bad_tracked_chunk_cache:
        kmem_cache_destroy(pending_cache);
-bad4:
+bad_pending_cache:
        kmem_cache_destroy(exception_cache);
-bad3:
+bad_exception_cache:
        exit_origin_hash();
-bad2:
+bad_origin_hash:
+       dm_unregister_target(&merge_target);
+bad_register_merge_target:
        dm_unregister_target(&origin_target);
-bad1:
+bad_register_origin_target:
        dm_unregister_target(&snapshot_target);
-
 bad_register_snapshot_target:
        dm_exception_store_exit();
+
        return r;
 }
 
@@ -1548,6 +2302,7 @@ static void __exit dm_snapshot_exit(void)
 
        dm_unregister_target(&snapshot_target);
        dm_unregister_target(&origin_target);
+       dm_unregister_target(&merge_target);
 
        exit_origin_hash();
        kmem_cache_destroy(pending_cache);
index 4b045903a4e21e6ce6e0c06593c7ed7e867a13b1..f53392df7b97984438e8ec823abccb59d4386ee9 100644 (file)
@@ -59,7 +59,7 @@ static ssize_t dm_attr_uuid_show(struct mapped_device *md, char *buf)
 
 static ssize_t dm_attr_suspended_show(struct mapped_device *md, char *buf)
 {
-       sprintf(buf, "%d\n", dm_suspended(md));
+       sprintf(buf, "%d\n", dm_suspended_md(md));
 
        return strlen(buf);
 }
@@ -79,6 +79,13 @@ static struct sysfs_ops dm_sysfs_ops = {
        .show   = dm_attr_show,
 };
 
+/*
+ * The sysfs structure is embedded in md struct, nothing to do here
+ */
+static void dm_sysfs_release(struct kobject *kobj)
+{
+}
+
 /*
  * dm kobject is embedded in mapped_device structure
  * no need to define release function here
@@ -86,6 +93,7 @@ static struct sysfs_ops dm_sysfs_ops = {
 static struct kobj_type dm_ktype = {
        .sysfs_ops      = &dm_sysfs_ops,
        .default_attrs  = dm_attrs,
+       .release        = dm_sysfs_release
 };
 
 /*
index 1a6cb3c7822ed96c6c0b2eaa764522c5f0e7ae89..be625475cf6df41faa48c9a3b91e841655afb3b2 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/blkdev.h>
 #include <linux/namei.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
@@ -237,6 +238,9 @@ void dm_table_destroy(struct dm_table *t)
 {
        unsigned int i;
 
+       if (!t)
+               return;
+
        while (atomic_read(&t->holders))
                msleep(1);
        smp_mb();
@@ -600,11 +604,8 @@ int dm_split_args(int *argc, char ***argvp, char *input)
                return -ENOMEM;
 
        while (1) {
-               start = end;
-
                /* Skip whitespace */
-               while (*start && isspace(*start))
-                       start++;
+               start = skip_spaces(end);
 
                if (!*start)
                        break;  /* success, we hit the end */
index 6f65883aef124828c20a6ba1b29a26c541a941c8..c7c555a8c7b2ef619ab4671f023a6eb1b8953f33 100644 (file)
@@ -139,14 +139,13 @@ void dm_send_uevents(struct list_head *events, struct kobject *kobj)
                list_del_init(&event->elist);
 
                /*
-                * Need to call dm_copy_name_and_uuid from here for now.
-                * Context of previous var adds and locking used for
-                * hash_cell not compatable.
+                * When a device is being removed this copy fails and we
+                * discard these unsent events.
                 */
                if (dm_copy_name_and_uuid(event->md, event->name,
                                          event->uuid)) {
-                       DMERR("%s: dm_copy_name_and_uuid() failed",
-                             __func__);
+                       DMINFO("%s: skipping sending uevent for lost device",
+                              __func__);
                        goto uevent_free;
                }
 
index 724efc63904dd5459b5e675a5ead3f5aba0394f6..3167480b532cd92e64c12831bb3ac4d424f37270 100644 (file)
@@ -142,10 +142,20 @@ struct mapped_device {
         */
        int barrier_error;
 
+       /*
+        * Protect barrier_error from concurrent endio processing
+        * in request-based dm.
+        */
+       spinlock_t barrier_error_lock;
+
        /*
         * Processing queue (flush/barriers)
         */
        struct workqueue_struct *wq;
+       struct work_struct barrier_work;
+
+       /* A pointer to the currently processing pre/post flush request */
+       struct request *flush_request;
 
        /*
         * The current mapping.
@@ -178,9 +188,6 @@ struct mapped_device {
        /* forced geometry settings */
        struct hd_geometry geometry;
 
-       /* marker of flush suspend for request-based dm */
-       struct request suspend_rq;
-
        /* For saving the address of __make_request for request based dm */
        make_request_fn *saved_make_request_fn;
 
@@ -275,6 +282,7 @@ static int (*_inits[])(void) __initdata = {
        dm_target_init,
        dm_linear_init,
        dm_stripe_init,
+       dm_io_init,
        dm_kcopyd_init,
        dm_interface_init,
 };
@@ -284,6 +292,7 @@ static void (*_exits[])(void) = {
        dm_target_exit,
        dm_linear_exit,
        dm_stripe_exit,
+       dm_io_exit,
        dm_kcopyd_exit,
        dm_interface_exit,
 };
@@ -320,6 +329,11 @@ static void __exit dm_exit(void)
 /*
  * Block device functions
  */
+int dm_deleting_md(struct mapped_device *md)
+{
+       return test_bit(DMF_DELETING, &md->flags);
+}
+
 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
 {
        struct mapped_device *md;
@@ -331,7 +345,7 @@ static int dm_blk_open(struct block_device *bdev, fmode_t mode)
                goto out;
 
        if (test_bit(DMF_FREEING, &md->flags) ||
-           test_bit(DMF_DELETING, &md->flags)) {
+           dm_deleting_md(md)) {
                md = NULL;
                goto out;
        }
@@ -388,7 +402,7 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode,
                        unsigned int cmd, unsigned long arg)
 {
        struct mapped_device *md = bdev->bd_disk->private_data;
-       struct dm_table *map = dm_get_table(md);
+       struct dm_table *map = dm_get_live_table(md);
        struct dm_target *tgt;
        int r = -ENOTTY;
 
@@ -401,7 +415,7 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode,
 
        tgt = dm_table_get_target(map, 0);
 
-       if (dm_suspended(md)) {
+       if (dm_suspended_md(md)) {
                r = -EAGAIN;
                goto out;
        }
@@ -430,9 +444,10 @@ static void free_tio(struct mapped_device *md, struct dm_target_io *tio)
        mempool_free(tio, md->tio_pool);
 }
 
-static struct dm_rq_target_io *alloc_rq_tio(struct mapped_device *md)
+static struct dm_rq_target_io *alloc_rq_tio(struct mapped_device *md,
+                                           gfp_t gfp_mask)
 {
-       return mempool_alloc(md->tio_pool, GFP_ATOMIC);
+       return mempool_alloc(md->tio_pool, gfp_mask);
 }
 
 static void free_rq_tio(struct dm_rq_target_io *tio)
@@ -450,6 +465,12 @@ static void free_bio_info(struct dm_rq_clone_bio_info *info)
        mempool_free(info, info->tio->md->io_pool);
 }
 
+static int md_in_flight(struct mapped_device *md)
+{
+       return atomic_read(&md->pending[READ]) +
+              atomic_read(&md->pending[WRITE]);
+}
+
 static void start_io_acct(struct dm_io *io)
 {
        struct mapped_device *md = io->md;
@@ -512,7 +533,7 @@ static void queue_io(struct mapped_device *md, struct bio *bio)
  * function to access the md->map field, and make sure they call
  * dm_table_put() when finished.
  */
-struct dm_table *dm_get_table(struct mapped_device *md)
+struct dm_table *dm_get_live_table(struct mapped_device *md)
 {
        struct dm_table *t;
        unsigned long flags;
@@ -716,28 +737,38 @@ static void end_clone_bio(struct bio *clone, int error)
        blk_update_request(tio->orig, 0, nr_bytes);
 }
 
+static void store_barrier_error(struct mapped_device *md, int error)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&md->barrier_error_lock, flags);
+       /*
+        * Basically, the first error is taken, but:
+        *   -EOPNOTSUPP supersedes any I/O error.
+        *   Requeue request supersedes any I/O error but -EOPNOTSUPP.
+        */
+       if (!md->barrier_error || error == -EOPNOTSUPP ||
+           (md->barrier_error != -EOPNOTSUPP &&
+            error == DM_ENDIO_REQUEUE))
+               md->barrier_error = error;
+       spin_unlock_irqrestore(&md->barrier_error_lock, flags);
+}
+
 /*
  * Don't touch any member of the md after calling this function because
  * the md may be freed in dm_put() at the end of this function.
  * Or do dm_get() before calling this function and dm_put() later.
  */
-static void rq_completed(struct mapped_device *md, int run_queue)
+static void rq_completed(struct mapped_device *md, int rw, int run_queue)
 {
-       int wakeup_waiters = 0;
-       struct request_queue *q = md->queue;
-       unsigned long flags;
-
-       spin_lock_irqsave(q->queue_lock, flags);
-       if (!queue_in_flight(q))
-               wakeup_waiters = 1;
-       spin_unlock_irqrestore(q->queue_lock, flags);
+       atomic_dec(&md->pending[rw]);
 
        /* nudge anyone waiting on suspend queue */
-       if (wakeup_waiters)
+       if (!md_in_flight(md))
                wake_up(&md->wait);
 
        if (run_queue)
-               blk_run_queue(q);
+               blk_run_queue(md->queue);
 
        /*
         * dm_put() must be at the end of this function. See the comment above
@@ -753,6 +784,44 @@ static void free_rq_clone(struct request *clone)
        free_rq_tio(tio);
 }
 
+/*
+ * Complete the clone and the original request.
+ * Must be called without queue lock.
+ */
+static void dm_end_request(struct request *clone, int error)
+{
+       int rw = rq_data_dir(clone);
+       int run_queue = 1;
+       bool is_barrier = blk_barrier_rq(clone);
+       struct dm_rq_target_io *tio = clone->end_io_data;
+       struct mapped_device *md = tio->md;
+       struct request *rq = tio->orig;
+
+       if (blk_pc_request(rq) && !is_barrier) {
+               rq->errors = clone->errors;
+               rq->resid_len = clone->resid_len;
+
+               if (rq->sense)
+                       /*
+                        * We are using the sense buffer of the original
+                        * request.
+                        * So setting the length of the sense data is enough.
+                        */
+                       rq->sense_len = clone->sense_len;
+       }
+
+       free_rq_clone(clone);
+
+       if (unlikely(is_barrier)) {
+               if (unlikely(error))
+                       store_barrier_error(md, error);
+               run_queue = 0;
+       } else
+               blk_end_request_all(rq, error);
+
+       rq_completed(md, rw, run_queue);
+}
+
 static void dm_unprep_request(struct request *rq)
 {
        struct request *clone = rq->special;
@@ -768,12 +837,23 @@ static void dm_unprep_request(struct request *rq)
  */
 void dm_requeue_unmapped_request(struct request *clone)
 {
+       int rw = rq_data_dir(clone);
        struct dm_rq_target_io *tio = clone->end_io_data;
        struct mapped_device *md = tio->md;
        struct request *rq = tio->orig;
        struct request_queue *q = rq->q;
        unsigned long flags;
 
+       if (unlikely(blk_barrier_rq(clone))) {
+               /*
+                * Barrier clones share an original request.
+                * Leave it to dm_end_request(), which handles this special
+                * case.
+                */
+               dm_end_request(clone, DM_ENDIO_REQUEUE);
+               return;
+       }
+
        dm_unprep_request(rq);
 
        spin_lock_irqsave(q->queue_lock, flags);
@@ -782,7 +862,7 @@ void dm_requeue_unmapped_request(struct request *clone)
        blk_requeue_request(q, rq);
        spin_unlock_irqrestore(q->queue_lock, flags);
 
-       rq_completed(md, 0);
+       rq_completed(md, rw, 0);
 }
 EXPORT_SYMBOL_GPL(dm_requeue_unmapped_request);
 
@@ -815,34 +895,28 @@ static void start_queue(struct request_queue *q)
        spin_unlock_irqrestore(q->queue_lock, flags);
 }
 
-/*
- * Complete the clone and the original request.
- * Must be called without queue lock.
- */
-static void dm_end_request(struct request *clone, int error)
+static void dm_done(struct request *clone, int error, bool mapped)
 {
+       int r = error;
        struct dm_rq_target_io *tio = clone->end_io_data;
-       struct mapped_device *md = tio->md;
-       struct request *rq = tio->orig;
+       dm_request_endio_fn rq_end_io = tio->ti->type->rq_end_io;
 
-       if (blk_pc_request(rq)) {
-               rq->errors = clone->errors;
-               rq->resid_len = clone->resid_len;
+       if (mapped && rq_end_io)
+               r = rq_end_io(tio->ti, clone, error, &tio->info);
 
-               if (rq->sense)
-                       /*
-                        * We are using the sense buffer of the original
-                        * request.
-                        * So setting the length of the sense data is enough.
-                        */
-                       rq->sense_len = clone->sense_len;
+       if (r <= 0)
+               /* The target wants to complete the I/O */
+               dm_end_request(clone, r);
+       else if (r == DM_ENDIO_INCOMPLETE)
+               /* The target will handle the I/O */
+               return;
+       else if (r == DM_ENDIO_REQUEUE)
+               /* The target wants to requeue the I/O */
+               dm_requeue_unmapped_request(clone);
+       else {
+               DMWARN("unimplemented target endio return value: %d", r);
+               BUG();
        }
-
-       free_rq_clone(clone);
-
-       blk_end_request_all(rq, error);
-
-       rq_completed(md, 1);
 }
 
 /*
@@ -850,27 +924,14 @@ static void dm_end_request(struct request *clone, int error)
  */
 static void dm_softirq_done(struct request *rq)
 {
+       bool mapped = true;
        struct request *clone = rq->completion_data;
        struct dm_rq_target_io *tio = clone->end_io_data;
-       dm_request_endio_fn rq_end_io = tio->ti->type->rq_end_io;
-       int error = tio->error;
 
-       if (!(rq->cmd_flags & REQ_FAILED) && rq_end_io)
-               error = rq_end_io(tio->ti, clone, error, &tio->info);
+       if (rq->cmd_flags & REQ_FAILED)
+               mapped = false;
 
-       if (error <= 0)
-               /* The target wants to complete the I/O */
-               dm_end_request(clone, error);
-       else if (error == DM_ENDIO_INCOMPLETE)
-               /* The target will handle the I/O */
-               return;
-       else if (error == DM_ENDIO_REQUEUE)
-               /* The target wants to requeue the I/O */
-               dm_requeue_unmapped_request(clone);
-       else {
-               DMWARN("unimplemented target endio return value: %d", error);
-               BUG();
-       }
+       dm_done(clone, tio->error, mapped);
 }
 
 /*
@@ -882,6 +943,19 @@ static void dm_complete_request(struct request *clone, int error)
        struct dm_rq_target_io *tio = clone->end_io_data;
        struct request *rq = tio->orig;
 
+       if (unlikely(blk_barrier_rq(clone))) {
+               /*
+                * Barrier clones share an original request.  So can't use
+                * softirq_done with the original.
+                * Pass the clone to dm_done() directly in this special case.
+                * It is safe (even if clone->q->queue_lock is held here)
+                * because there is no I/O dispatching during the completion
+                * of barrier clone.
+                */
+               dm_done(clone, error, true);
+               return;
+       }
+
        tio->error = error;
        rq->completion_data = clone;
        blk_complete_request(rq);
@@ -898,6 +972,17 @@ void dm_kill_unmapped_request(struct request *clone, int error)
        struct dm_rq_target_io *tio = clone->end_io_data;
        struct request *rq = tio->orig;
 
+       if (unlikely(blk_barrier_rq(clone))) {
+               /*
+                * Barrier clones share an original request.
+                * Leave it to dm_end_request(), which handles this special
+                * case.
+                */
+               BUG_ON(error > 0);
+               dm_end_request(clone, error);
+               return;
+       }
+
        rq->cmd_flags |= REQ_FAILED;
        dm_complete_request(clone, error);
 }
@@ -1214,7 +1299,7 @@ static void __split_and_process_bio(struct mapped_device *md, struct bio *bio)
        struct clone_info ci;
        int error = 0;
 
-       ci.map = dm_get_table(md);
+       ci.map = dm_get_live_table(md);
        if (unlikely(!ci.map)) {
                if (!bio_rw_flagged(bio, BIO_RW_BARRIER))
                        bio_io_error(bio);
@@ -1255,7 +1340,7 @@ static int dm_merge_bvec(struct request_queue *q,
                         struct bio_vec *biovec)
 {
        struct mapped_device *md = q->queuedata;
-       struct dm_table *map = dm_get_table(md);
+       struct dm_table *map = dm_get_live_table(md);
        struct dm_target *ti;
        sector_t max_sectors;
        int max_size = 0;
@@ -1352,11 +1437,6 @@ static int dm_make_request(struct request_queue *q, struct bio *bio)
 {
        struct mapped_device *md = q->queuedata;
 
-       if (unlikely(bio_rw_flagged(bio, BIO_RW_BARRIER))) {
-               bio_endio(bio, -EOPNOTSUPP);
-               return 0;
-       }
-
        return md->saved_make_request_fn(q, bio); /* call __make_request() */
 }
 
@@ -1375,6 +1455,25 @@ static int dm_request(struct request_queue *q, struct bio *bio)
        return _dm_request(q, bio);
 }
 
+/*
+ * Mark this request as flush request, so that dm_request_fn() can
+ * recognize.
+ */
+static void dm_rq_prepare_flush(struct request_queue *q, struct request *rq)
+{
+       rq->cmd_type = REQ_TYPE_LINUX_BLOCK;
+       rq->cmd[0] = REQ_LB_OP_FLUSH;
+}
+
+static bool dm_rq_is_flush_request(struct request *rq)
+{
+       if (rq->cmd_type == REQ_TYPE_LINUX_BLOCK &&
+           rq->cmd[0] == REQ_LB_OP_FLUSH)
+               return true;
+       else
+               return false;
+}
+
 void dm_dispatch_request(struct request *rq)
 {
        int r;
@@ -1420,25 +1519,54 @@ static int dm_rq_bio_constructor(struct bio *bio, struct bio *bio_orig,
 static int setup_clone(struct request *clone, struct request *rq,
                       struct dm_rq_target_io *tio)
 {
-       int r = blk_rq_prep_clone(clone, rq, tio->md->bs, GFP_ATOMIC,
-                                 dm_rq_bio_constructor, tio);
+       int r;
 
-       if (r)
-               return r;
+       if (dm_rq_is_flush_request(rq)) {
+               blk_rq_init(NULL, clone);
+               clone->cmd_type = REQ_TYPE_FS;
+               clone->cmd_flags |= (REQ_HARDBARRIER | WRITE);
+       } else {
+               r = blk_rq_prep_clone(clone, rq, tio->md->bs, GFP_ATOMIC,
+                                     dm_rq_bio_constructor, tio);
+               if (r)
+                       return r;
+
+               clone->cmd = rq->cmd;
+               clone->cmd_len = rq->cmd_len;
+               clone->sense = rq->sense;
+               clone->buffer = rq->buffer;
+       }
 
-       clone->cmd = rq->cmd;
-       clone->cmd_len = rq->cmd_len;
-       clone->sense = rq->sense;
-       clone->buffer = rq->buffer;
        clone->end_io = end_clone_request;
        clone->end_io_data = tio;
 
        return 0;
 }
 
-static int dm_rq_flush_suspending(struct mapped_device *md)
+static struct request *clone_rq(struct request *rq, struct mapped_device *md,
+                               gfp_t gfp_mask)
 {
-       return !md->suspend_rq.special;
+       struct request *clone;
+       struct dm_rq_target_io *tio;
+
+       tio = alloc_rq_tio(md, gfp_mask);
+       if (!tio)
+               return NULL;
+
+       tio->md = md;
+       tio->ti = NULL;
+       tio->orig = rq;
+       tio->error = 0;
+       memset(&tio->info, 0, sizeof(tio->info));
+
+       clone = &tio->clone;
+       if (setup_clone(clone, rq, tio)) {
+               /* -ENOMEM */
+               free_rq_tio(tio);
+               return NULL;
+       }
+
+       return clone;
 }
 
 /*
@@ -1447,39 +1575,19 @@ static int dm_rq_flush_suspending(struct mapped_device *md)
 static int dm_prep_fn(struct request_queue *q, struct request *rq)
 {
        struct mapped_device *md = q->queuedata;
-       struct dm_rq_target_io *tio;
        struct request *clone;
 
-       if (unlikely(rq == &md->suspend_rq)) {
-               if (dm_rq_flush_suspending(md))
-                       return BLKPREP_OK;
-               else
-                       /* The flush suspend was interrupted */
-                       return BLKPREP_KILL;
-       }
+       if (unlikely(dm_rq_is_flush_request(rq)))
+               return BLKPREP_OK;
 
        if (unlikely(rq->special)) {
                DMWARN("Already has something in rq->special.");
                return BLKPREP_KILL;
        }
 
-       tio = alloc_rq_tio(md); /* Only one for each original request */
-       if (!tio)
-               /* -ENOMEM */
-               return BLKPREP_DEFER;
-
-       tio->md = md;
-       tio->ti = NULL;
-       tio->orig = rq;
-       tio->error = 0;
-       memset(&tio->info, 0, sizeof(tio->info));
-
-       clone = &tio->clone;
-       if (setup_clone(clone, rq, tio)) {
-               /* -ENOMEM */
-               free_rq_tio(tio);
+       clone = clone_rq(rq, md, GFP_ATOMIC);
+       if (!clone)
                return BLKPREP_DEFER;
-       }
 
        rq->special = clone;
        rq->cmd_flags |= REQ_DONTPREP;
@@ -1487,11 +1595,10 @@ static int dm_prep_fn(struct request_queue *q, struct request *rq)
        return BLKPREP_OK;
 }
 
-static void map_request(struct dm_target *ti, struct request *rq,
+static void map_request(struct dm_target *ti, struct request *clone,
                        struct mapped_device *md)
 {
        int r;
-       struct request *clone = rq->special;
        struct dm_rq_target_io *tio = clone->end_io_data;
 
        /*
@@ -1511,6 +1618,8 @@ static void map_request(struct dm_target *ti, struct request *rq,
                break;
        case DM_MAPIO_REMAPPED:
                /* The target has remapped the I/O so dispatch it */
+               trace_block_rq_remap(clone->q, clone, disk_devt(dm_disk(md)),
+                                    blk_rq_pos(tio->orig));
                dm_dispatch_request(clone);
                break;
        case DM_MAPIO_REQUEUE:
@@ -1536,29 +1645,26 @@ static void map_request(struct dm_target *ti, struct request *rq,
 static void dm_request_fn(struct request_queue *q)
 {
        struct mapped_device *md = q->queuedata;
-       struct dm_table *map = dm_get_table(md);
+       struct dm_table *map = dm_get_live_table(md);
        struct dm_target *ti;
-       struct request *rq;
+       struct request *rq, *clone;
 
        /*
-        * For noflush suspend, check blk_queue_stopped() to immediately
-        * quit I/O dispatching.
+        * For suspend, check blk_queue_stopped() and increment
+        * ->pending within a single queue_lock not to increment the
+        * number of in-flight I/Os after the queue is stopped in
+        * dm_suspend().
         */
        while (!blk_queue_plugged(q) && !blk_queue_stopped(q)) {
                rq = blk_peek_request(q);
                if (!rq)
                        goto plug_and_out;
 
-               if (unlikely(rq == &md->suspend_rq)) { /* Flush suspend maker */
-                       if (queue_in_flight(q))
-                               /* Not quiet yet.  Wait more */
-                               goto plug_and_out;
-
-                       /* This device should be quiet now */
-                       __stop_queue(q);
+               if (unlikely(dm_rq_is_flush_request(rq))) {
+                       BUG_ON(md->flush_request);
+                       md->flush_request = rq;
                        blk_start_request(rq);
-                       __blk_end_request_all(rq, 0);
-                       wake_up(&md->wait);
+                       queue_work(md->wq, &md->barrier_work);
                        goto out;
                }
 
@@ -1567,8 +1673,11 @@ static void dm_request_fn(struct request_queue *q)
                        goto plug_and_out;
 
                blk_start_request(rq);
+               clone = rq->special;
+               atomic_inc(&md->pending[rq_data_dir(clone)]);
+
                spin_unlock(q->queue_lock);
-               map_request(ti, rq, md);
+               map_request(ti, clone, md);
                spin_lock_irq(q->queue_lock);
        }
 
@@ -1595,7 +1704,7 @@ static int dm_lld_busy(struct request_queue *q)
 {
        int r;
        struct mapped_device *md = q->queuedata;
-       struct dm_table *map = dm_get_table(md);
+       struct dm_table *map = dm_get_live_table(md);
 
        if (!map || test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags))
                r = 1;
@@ -1610,7 +1719,7 @@ static int dm_lld_busy(struct request_queue *q)
 static void dm_unplug_all(struct request_queue *q)
 {
        struct mapped_device *md = q->queuedata;
-       struct dm_table *map = dm_get_table(md);
+       struct dm_table *map = dm_get_live_table(md);
 
        if (map) {
                if (dm_request_based(md))
@@ -1628,7 +1737,7 @@ static int dm_any_congested(void *congested_data, int bdi_bits)
        struct dm_table *map;
 
        if (!test_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags)) {
-               map = dm_get_table(md);
+               map = dm_get_live_table(md);
                if (map) {
                        /*
                         * Request-based dm cares about only own queue for
@@ -1725,6 +1834,7 @@ out:
 static const struct block_device_operations dm_blk_dops;
 
 static void dm_wq_work(struct work_struct *work);
+static void dm_rq_barrier_work(struct work_struct *work);
 
 /*
  * Allocate and initialise a blank device with a given minor.
@@ -1754,6 +1864,7 @@ static struct mapped_device *alloc_dev(int minor)
        init_rwsem(&md->io_lock);
        mutex_init(&md->suspend_lock);
        spin_lock_init(&md->deferred_lock);
+       spin_lock_init(&md->barrier_error_lock);
        rwlock_init(&md->map_lock);
        atomic_set(&md->holders, 1);
        atomic_set(&md->open_count, 0);
@@ -1788,6 +1899,8 @@ static struct mapped_device *alloc_dev(int minor)
        blk_queue_softirq_done(md->queue, dm_softirq_done);
        blk_queue_prep_rq(md->queue, dm_prep_fn);
        blk_queue_lld_busy(md->queue, dm_lld_busy);
+       blk_queue_ordered(md->queue, QUEUE_ORDERED_DRAIN_FLUSH,
+                         dm_rq_prepare_flush);
 
        md->disk = alloc_disk(1);
        if (!md->disk)
@@ -1797,6 +1910,7 @@ static struct mapped_device *alloc_dev(int minor)
        atomic_set(&md->pending[1], 0);
        init_waitqueue_head(&md->wait);
        INIT_WORK(&md->work, dm_wq_work);
+       INIT_WORK(&md->barrier_work, dm_rq_barrier_work);
        init_waitqueue_head(&md->eventq);
 
        md->disk->major = _major;
@@ -1921,9 +2035,13 @@ static void __set_size(struct mapped_device *md, sector_t size)
        mutex_unlock(&md->bdev->bd_inode->i_mutex);
 }
 
-static int __bind(struct mapped_device *md, struct dm_table *t,
-                 struct queue_limits *limits)
+/*
+ * Returns old map, which caller must destroy.
+ */
+static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t,
+                              struct queue_limits *limits)
 {
+       struct dm_table *old_map;
        struct request_queue *q = md->queue;
        sector_t size;
        unsigned long flags;
@@ -1938,11 +2056,6 @@ static int __bind(struct mapped_device *md, struct dm_table *t,
 
        __set_size(md, size);
 
-       if (!size) {
-               dm_table_destroy(t);
-               return 0;
-       }
-
        dm_table_event_callback(t, event_callback, md);
 
        /*
@@ -1958,26 +2071,31 @@ static int __bind(struct mapped_device *md, struct dm_table *t,
        __bind_mempools(md, t);
 
        write_lock_irqsave(&md->map_lock, flags);
+       old_map = md->map;
        md->map = t;
        dm_table_set_restrictions(t, q, limits);
        write_unlock_irqrestore(&md->map_lock, flags);
 
-       return 0;
+       return old_map;
 }
 
-static void __unbind(struct mapped_device *md)
+/*
+ * Returns unbound table for the caller to free.
+ */
+static struct dm_table *__unbind(struct mapped_device *md)
 {
        struct dm_table *map = md->map;
        unsigned long flags;
 
        if (!map)
-               return;
+               return NULL;
 
        dm_table_event_callback(map, NULL, NULL);
        write_lock_irqsave(&md->map_lock, flags);
        md->map = NULL;
        write_unlock_irqrestore(&md->map_lock, flags);
-       dm_table_destroy(map);
+
+       return map;
 }
 
 /*
@@ -2059,18 +2177,18 @@ void dm_put(struct mapped_device *md)
        BUG_ON(test_bit(DMF_FREEING, &md->flags));
 
        if (atomic_dec_and_lock(&md->holders, &_minor_lock)) {
-               map = dm_get_table(md);
+               map = dm_get_live_table(md);
                idr_replace(&_minor_idr, MINOR_ALLOCED,
                            MINOR(disk_devt(dm_disk(md))));
                set_bit(DMF_FREEING, &md->flags);
                spin_unlock(&_minor_lock);
-               if (!dm_suspended(md)) {
+               if (!dm_suspended_md(md)) {
                        dm_table_presuspend_targets(map);
                        dm_table_postsuspend_targets(map);
                }
                dm_sysfs_exit(md);
                dm_table_put(map);
-               __unbind(md);
+               dm_table_destroy(__unbind(md));
                free_dev(md);
        }
 }
@@ -2080,8 +2198,6 @@ static int dm_wait_for_completion(struct mapped_device *md, int interruptible)
 {
        int r = 0;
        DECLARE_WAITQUEUE(wait, current);
-       struct request_queue *q = md->queue;
-       unsigned long flags;
 
        dm_unplug_all(md->queue);
 
@@ -2091,15 +2207,7 @@ static int dm_wait_for_completion(struct mapped_device *md, int interruptible)
                set_current_state(interruptible);
 
                smp_mb();
-               if (dm_request_based(md)) {
-                       spin_lock_irqsave(q->queue_lock, flags);
-                       if (!queue_in_flight(q) && blk_queue_stopped(q)) {
-                               spin_unlock_irqrestore(q->queue_lock, flags);
-                               break;
-                       }
-                       spin_unlock_irqrestore(q->queue_lock, flags);
-               } else if (!atomic_read(&md->pending[0]) &&
-                                       !atomic_read(&md->pending[1]))
+               if (!md_in_flight(md))
                        break;
 
                if (interruptible == TASK_INTERRUPTIBLE &&
@@ -2194,98 +2302,106 @@ static void dm_queue_flush(struct mapped_device *md)
        queue_work(md->wq, &md->work);
 }
 
-/*
- * Swap in a new table (destroying old one).
- */
-int dm_swap_table(struct mapped_device *md, struct dm_table *table)
+static void dm_rq_set_flush_nr(struct request *clone, unsigned flush_nr)
 {
-       struct queue_limits limits;
-       int r = -EINVAL;
+       struct dm_rq_target_io *tio = clone->end_io_data;
 
-       mutex_lock(&md->suspend_lock);
+       tio->info.flush_request = flush_nr;
+}
 
-       /* device must be suspended */
-       if (!dm_suspended(md))
-               goto out;
+/* Issue barrier requests to targets and wait for their completion. */
+static int dm_rq_barrier(struct mapped_device *md)
+{
+       int i, j;
+       struct dm_table *map = dm_get_live_table(md);
+       unsigned num_targets = dm_table_get_num_targets(map);
+       struct dm_target *ti;
+       struct request *clone;
 
-       r = dm_calculate_queue_limits(table, &limits);
-       if (r)
-               goto out;
+       md->barrier_error = 0;
 
-       /* cannot change the device type, once a table is bound */
-       if (md->map &&
-           (dm_table_get_type(md->map) != dm_table_get_type(table))) {
-               DMWARN("can't change the device type after a table is bound");
-               goto out;
+       for (i = 0; i < num_targets; i++) {
+               ti = dm_table_get_target(map, i);
+               for (j = 0; j < ti->num_flush_requests; j++) {
+                       clone = clone_rq(md->flush_request, md, GFP_NOIO);
+                       dm_rq_set_flush_nr(clone, j);
+                       atomic_inc(&md->pending[rq_data_dir(clone)]);
+                       map_request(ti, clone, md);
+               }
        }
 
-       __unbind(md);
-       r = __bind(md, table, &limits);
-
-out:
-       mutex_unlock(&md->suspend_lock);
-       return r;
-}
+       dm_wait_for_completion(md, TASK_UNINTERRUPTIBLE);
+       dm_table_put(map);
 
-static void dm_rq_invalidate_suspend_marker(struct mapped_device *md)
-{
-       md->suspend_rq.special = (void *)0x1;
+       return md->barrier_error;
 }
 
-static void dm_rq_abort_suspend(struct mapped_device *md, int noflush)
+static void dm_rq_barrier_work(struct work_struct *work)
 {
+       int error;
+       struct mapped_device *md = container_of(work, struct mapped_device,
+                                               barrier_work);
        struct request_queue *q = md->queue;
+       struct request *rq;
        unsigned long flags;
 
-       spin_lock_irqsave(q->queue_lock, flags);
-       if (!noflush)
-               dm_rq_invalidate_suspend_marker(md);
-       __start_queue(q);
-       spin_unlock_irqrestore(q->queue_lock, flags);
-}
+       /*
+        * Hold the md reference here and leave it at the last part so that
+        * the md can't be deleted by device opener when the barrier request
+        * completes.
+        */
+       dm_get(md);
 
-static void dm_rq_start_suspend(struct mapped_device *md, int noflush)
-{
-       struct request *rq = &md->suspend_rq;
-       struct request_queue *q = md->queue;
+       error = dm_rq_barrier(md);
 
-       if (noflush)
-               stop_queue(q);
-       else {
-               blk_rq_init(q, rq);
-               blk_insert_request(q, rq, 0, NULL);
-       }
+       rq = md->flush_request;
+       md->flush_request = NULL;
+
+       if (error == DM_ENDIO_REQUEUE) {
+               spin_lock_irqsave(q->queue_lock, flags);
+               blk_requeue_request(q, rq);
+               spin_unlock_irqrestore(q->queue_lock, flags);
+       } else
+               blk_end_request_all(rq, error);
+
+       blk_run_queue(q);
+
+       dm_put(md);
 }
 
-static int dm_rq_suspend_available(struct mapped_device *md, int noflush)
+/*
+ * Swap in a new table, returning the old one for the caller to destroy.
+ */
+struct dm_table *dm_swap_table(struct mapped_device *md, struct dm_table *table)
 {
-       int r = 1;
-       struct request *rq = &md->suspend_rq;
-       struct request_queue *q = md->queue;
-       unsigned long flags;
+       struct dm_table *map = ERR_PTR(-EINVAL);
+       struct queue_limits limits;
+       int r;
 
-       if (noflush)
-               return r;
+       mutex_lock(&md->suspend_lock);
 
-       /* The marker must be protected by queue lock if it is in use */
-       spin_lock_irqsave(q->queue_lock, flags);
-       if (unlikely(rq->ref_count)) {
-               /*
-                * This can happen, when the previous flush suspend was
-                * interrupted, the marker is still in the queue and
-                * this flush suspend has been invoked, because we don't
-                * remove the marker at the time of suspend interruption.
-                * We have only one marker per mapped_device, so we can't
-                * start another flush suspend while it is in use.
-                */
-               BUG_ON(!rq->special); /* The marker should be invalidated */
-               DMWARN("Invalidating the previous flush suspend is still in"
-                      " progress.  Please retry later.");
-               r = 0;
+       /* device must be suspended */
+       if (!dm_suspended_md(md))
+               goto out;
+
+       r = dm_calculate_queue_limits(table, &limits);
+       if (r) {
+               map = ERR_PTR(r);
+               goto out;
        }
-       spin_unlock_irqrestore(q->queue_lock, flags);
 
-       return r;
+       /* cannot change the device type, once a table is bound */
+       if (md->map &&
+           (dm_table_get_type(md->map) != dm_table_get_type(table))) {
+               DMWARN("can't change the device type after a table is bound");
+               goto out;
+       }
+
+       map = __bind(md, table, &limits);
+
+out:
+       mutex_unlock(&md->suspend_lock);
+       return map;
 }
 
 /*
@@ -2330,49 +2446,11 @@ static void unlock_fs(struct mapped_device *md)
 /*
  * Suspend mechanism in request-based dm.
  *
- * After the suspend starts, further incoming requests are kept in
- * the request_queue and deferred.
- * Remaining requests in the request_queue at the start of suspend are flushed
- * if it is flush suspend.
- * The suspend completes when the following conditions have been satisfied,
- * so wait for it:
- *    1. q->in_flight is 0 (which means no in_flight request)
- *    2. queue has been stopped (which means no request dispatching)
- *
+ * 1. Flush all I/Os by lock_fs() if needed.
+ * 2. Stop dispatching any I/O by stopping the request_queue.
+ * 3. Wait for all in-flight I/Os to be completed or requeued.
  *
- * Noflush suspend
- * ---------------
- * Noflush suspend doesn't need to dispatch remaining requests.
- * So stop the queue immediately.  Then, wait for all in_flight requests
- * to be completed or requeued.
- *
- * To abort noflush suspend, start the queue.
- *
- *
- * Flush suspend
- * -------------
- * Flush suspend needs to dispatch remaining requests.  So stop the queue
- * after the remaining requests are completed. (Requeued request must be also
- * re-dispatched and completed.  Until then, we can't stop the queue.)
- *
- * During flushing the remaining requests, further incoming requests are also
- * inserted to the same queue.  To distinguish which requests are to be
- * flushed, we insert a marker request to the queue at the time of starting
- * flush suspend, like a barrier.
- * The dispatching is blocked when the marker is found on the top of the queue.
- * And the queue is stopped when all in_flight requests are completed, since
- * that means the remaining requests are completely flushed.
- * Then, the marker is removed from the queue.
- *
- * To abort flush suspend, we also need to take care of the marker, not only
- * starting the queue.
- * We don't remove the marker forcibly from the queue since it's against
- * the block-layer manner.  Instead, we put a invalidated mark on the marker.
- * When the invalidated marker is found on the top of the queue, it is
- * immediately removed from the queue, so it doesn't block dispatching.
- * Because we have only one marker per mapped_device, we can't start another
- * flush suspend until the invalidated marker is removed from the queue.
- * So fail and return with -EBUSY in such a case.
+ * To abort suspend, start the request_queue.
  */
 int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
 {
@@ -2383,17 +2461,12 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
 
        mutex_lock(&md->suspend_lock);
 
-       if (dm_suspended(md)) {
+       if (dm_suspended_md(md)) {
                r = -EINVAL;
                goto out_unlock;
        }
 
-       if (dm_request_based(md) && !dm_rq_suspend_available(md, noflush)) {
-               r = -EBUSY;
-               goto out_unlock;
-       }
-
-       map = dm_get_table(md);
+       map = dm_get_live_table(md);
 
        /*
         * DMF_NOFLUSH_SUSPENDING must be set before presuspend.
@@ -2406,8 +2479,10 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
        dm_table_presuspend_targets(map);
 
        /*
-        * Flush I/O to the device. noflush supersedes do_lockfs,
-        * because lock_fs() needs to flush I/Os.
+        * Flush I/O to the device.
+        * Any I/O submitted after lock_fs() may not be flushed.
+        * noflush takes precedence over do_lockfs.
+        * (lock_fs() flushes I/Os and waits for them to complete.)
         */
        if (!noflush && do_lockfs) {
                r = lock_fs(md);
@@ -2436,10 +2511,15 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
        set_bit(DMF_QUEUE_IO_TO_THREAD, &md->flags);
        up_write(&md->io_lock);
 
-       flush_workqueue(md->wq);
-
+       /*
+        * Request-based dm uses md->wq for barrier (dm_rq_barrier_work) which
+        * can be kicked until md->queue is stopped.  So stop md->queue before
+        * flushing md->wq.
+        */
        if (dm_request_based(md))
-               dm_rq_start_suspend(md, noflush);
+               stop_queue(md->queue);
+
+       flush_workqueue(md->wq);
 
        /*
         * At this point no more requests are entering target request routines.
@@ -2458,7 +2538,7 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
                dm_queue_flush(md);
 
                if (dm_request_based(md))
-                       dm_rq_abort_suspend(md, noflush);
+                       start_queue(md->queue);
 
                unlock_fs(md);
                goto out; /* pushback list is already flushed, so skip flush */
@@ -2470,10 +2550,10 @@ int dm_suspend(struct mapped_device *md, unsigned suspend_flags)
         * requests are being added to md->deferred list.
         */
 
-       dm_table_postsuspend_targets(map);
-
        set_bit(DMF_SUSPENDED, &md->flags);
 
+       dm_table_postsuspend_targets(map);
+
 out:
        dm_table_put(map);
 
@@ -2488,10 +2568,10 @@ int dm_resume(struct mapped_device *md)
        struct dm_table *map = NULL;
 
        mutex_lock(&md->suspend_lock);
-       if (!dm_suspended(md))
+       if (!dm_suspended_md(md))
                goto out;
 
-       map = dm_get_table(md);
+       map = dm_get_live_table(md);
        if (!map || !dm_table_get_size(map))
                goto out;
 
@@ -2592,18 +2672,29 @@ struct mapped_device *dm_get_from_kobject(struct kobject *kobj)
                return NULL;
 
        if (test_bit(DMF_FREEING, &md->flags) ||
-           test_bit(DMF_DELETING, &md->flags))
+           dm_deleting_md(md))
                return NULL;
 
        dm_get(md);
        return md;
 }
 
-int dm_suspended(struct mapped_device *md)
+int dm_suspended_md(struct mapped_device *md)
 {
        return test_bit(DMF_SUSPENDED, &md->flags);
 }
 
+int dm_suspended(struct dm_target *ti)
+{
+       struct mapped_device *md = dm_table_get_md(ti->table);
+       int r = dm_suspended_md(md);
+
+       dm_put(md);
+
+       return r;
+}
+EXPORT_SYMBOL_GPL(dm_suspended);
+
 int dm_noflush_suspending(struct dm_target *ti)
 {
        struct mapped_device *md = dm_table_get_md(ti->table);
index a7663eba17e2920ba84d5a7f41fe5fa015964590..8dadaa5bc39648e58c38d0c31da2872cf0d5f012 100644 (file)
@@ -88,6 +88,16 @@ int dm_target_iterate(void (*iter_func)(struct target_type *tt,
 
 int dm_split_args(int *argc, char ***argvp, char *input);
 
+/*
+ * Is this mapped_device being deleted?
+ */
+int dm_deleting_md(struct mapped_device *md);
+
+/*
+ * Is this mapped_device suspended?
+ */
+int dm_suspended_md(struct mapped_device *md);
+
 /*
  * The device-mapper can be driven through one of two interfaces;
  * ioctl or filesystem, depending which patch you have applied.
@@ -118,6 +128,9 @@ int dm_lock_for_deletion(struct mapped_device *md);
 void dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
                       unsigned cookie);
 
+int dm_io_init(void);
+void dm_io_exit(void);
+
 int dm_kcopyd_init(void);
 void dm_kcopyd_exit(void);
 
index e1f3c1715cca2ae459f0a70d7229128685ee2d70..dd3dfe42d5a9d081c590018f1ac6325cfecdaf12 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/buffer_head.h> /* for invalidate_bdev */
 #include <linux/poll.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/hdreg.h>
 #include <linux/proc_fs.h>
 #include <linux/random.h>
@@ -385,7 +386,9 @@ static void mddev_put(mddev_t *mddev)
        if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
                return;
        if (!mddev->raid_disks && list_empty(&mddev->disks) &&
-           !mddev->hold_active) {
+           mddev->ctime == 0 && !mddev->hold_active) {
+               /* Array is not configured at all, and not held active,
+                * so destroy it */
                list_del(&mddev->all_mddevs);
                if (mddev->gendisk) {
                        /* we did a probe so need to clean up.
@@ -1935,15 +1938,11 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
 
        uuid = sb->set_uuid;
        printk(KERN_INFO
-              "md:  SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x"
-              ":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n"
+              "md:  SB: (V:%u) (F:0x%08x) Array-ID:<%pU>\n"
               "md:    Name: \"%s\" CT:%llu\n",
                le32_to_cpu(sb->major_version),
                le32_to_cpu(sb->feature_map),
-               uuid[0], uuid[1], uuid[2], uuid[3],
-               uuid[4], uuid[5], uuid[6], uuid[7],
-               uuid[8], uuid[9], uuid[10], uuid[11],
-               uuid[12], uuid[13], uuid[14], uuid[15],
+               uuid,
                sb->set_name,
                (unsigned long long)le64_to_cpu(sb->ctime)
                       & MD_SUPERBLOCK_1_TIME_SEC_MASK);
@@ -1952,8 +1951,7 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
        printk(KERN_INFO
               "md:       L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu"
                        " RO:%llu\n"
-              "md:     Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x"
-                       ":%02x%02x%02x%02x%02x%02x\n"
+              "md:     Dev:%08x UUID: %pU\n"
               "md:       (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n"
               "md:         (MaxDev:%u) \n",
                le32_to_cpu(sb->level),
@@ -1966,10 +1964,7 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
                (unsigned long long)le64_to_cpu(sb->super_offset),
                (unsigned long long)le64_to_cpu(sb->recovery_offset),
                le32_to_cpu(sb->dev_number),
-               uuid[0], uuid[1], uuid[2], uuid[3],
-               uuid[4], uuid[5], uuid[6], uuid[7],
-               uuid[8], uuid[9], uuid[10], uuid[11],
-               uuid[12], uuid[13], uuid[14], uuid[15],
+               uuid,
                sb->devflags,
                (unsigned long long)le64_to_cpu(sb->utime) & MD_SUPERBLOCK_1_TIME_SEC_MASK,
                (unsigned long long)le64_to_cpu(sb->events),
@@ -3439,8 +3434,7 @@ bitmap_store(mddev_t *mddev, const char *buf, size_t len)
                }
                if (*end && !isspace(*end)) break;
                bitmap_dirty_bits(mddev->bitmap, chunk, end_chunk);
-               buf = end;
-               while (isspace(*buf)) buf++;
+               buf = skip_spaces(end);
        }
        bitmap_unplug(mddev->bitmap); /* flush the bits to disk */
 out:
@@ -4363,7 +4357,7 @@ static int do_md_run(mddev_t * mddev)
        mddev->barriers_work = 1;
        mddev->ok_start_degraded = start_dirty_degraded;
 
-       if (start_readonly)
+       if (start_readonly && mddev->ro == 0)
                mddev->ro = 2; /* read-only, but switch on first write */
 
        err = mddev->pers->run(mddev);
@@ -4427,33 +4421,6 @@ static int do_md_run(mddev_t * mddev)
 
        set_capacity(disk, mddev->array_sectors);
 
-       /* If there is a partially-recovered drive we need to
-        * start recovery here.  If we leave it to md_check_recovery,
-        * it will remove the drives and not do the right thing
-        */
-       if (mddev->degraded && !mddev->sync_thread) {
-               int spares = 0;
-               list_for_each_entry(rdev, &mddev->disks, same_set)
-                       if (rdev->raid_disk >= 0 &&
-                           !test_bit(In_sync, &rdev->flags) &&
-                           !test_bit(Faulty, &rdev->flags))
-                               /* complete an interrupted recovery */
-                               spares++;
-               if (spares && mddev->pers->sync_request) {
-                       mddev->recovery = 0;
-                       set_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
-                       mddev->sync_thread = md_register_thread(md_do_sync,
-                                                               mddev,
-                                                               "resync");
-                       if (!mddev->sync_thread) {
-                               printk(KERN_ERR "%s: could not start resync"
-                                      " thread...\n",
-                                      mdname(mddev));
-                               /* leave the spares where they are, it shouldn't hurt */
-                               mddev->recovery = 0;
-                       }
-               }
-       }
        md_wakeup_thread(mddev->thread);
        md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
 
@@ -5270,6 +5237,10 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
                mddev->minor_version = info->minor_version;
                mddev->patch_version = info->patch_version;
                mddev->persistent = !info->not_persistent;
+               /* ensure mddev_put doesn't delete this now that there
+                * is some minimal configuration.
+                */
+               mddev->ctime         = get_seconds();
                return 0;
        }
        mddev->major_version = MD_MAJOR_VERSION;
@@ -6502,10 +6473,11 @@ void md_do_sync(mddev_t *mddev)
                mddev->curr_resync = 2;
 
        try_again:
-               if (kthread_should_stop()) {
+               if (kthread_should_stop())
                        set_bit(MD_RECOVERY_INTR, &mddev->recovery);
+
+               if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
                        goto skip;
-               }
                for_each_mddev(mddev2, tmp) {
                        if (mddev2 == mddev)
                                continue;
diff --git a/drivers/media/IR/Kconfig b/drivers/media/IR/Kconfig
new file mode 100644 (file)
index 0000000..4dde7d1
--- /dev/null
@@ -0,0 +1,9 @@
+config IR_CORE
+       tristate
+       depends on INPUT
+       default INPUT
+
+config VIDEO_IR
+       tristate
+       depends on IR_CORE
+       default IR_CORE
diff --git a/drivers/media/IR/Makefile b/drivers/media/IR/Makefile
new file mode 100644 (file)
index 0000000..df5ddb4
--- /dev/null
@@ -0,0 +1,5 @@
+ir-common-objs  := ir-functions.o ir-keymaps.o
+ir-core-objs   := ir-keytable.o
+
+obj-$(CONFIG_IR_CORE) += ir-core.o
+obj-$(CONFIG_VIDEO_IR) += ir-common.o
similarity index 92%
rename from drivers/media/common/ir-functions.c
rename to drivers/media/IR/ir-functions.c
index e616f624ceaac7a0fe1518875d5b712cc1f74304..776a136616d6ee7c8c8f878c649291aee339b282 100644 (file)
@@ -34,9 +34,6 @@ static int repeat = 1;
 module_param(repeat, int, 0444);
 MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)");
 
-int media_ir_debug;    /* media_ir_debug level (0,1,2) */
-module_param_named(debug, media_ir_debug, int, 0644);
-
 /* -------------------------------------------------------------------------- */
 
 static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
@@ -55,25 +52,10 @@ static void ir_input_key_event(struct input_dev *dev, struct ir_input_state *ir)
 /* -------------------------------------------------------------------------- */
 
 int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
-                  int ir_type, struct ir_scancode_table *ir_codes)
+                  int ir_type)
 {
        ir->ir_type = ir_type;
 
-       ir->keytable.size = ir_roundup_tablesize(ir_codes->size);
-       ir->keytable.scan = kzalloc(ir->keytable.size *
-                                   sizeof(struct ir_scancode), GFP_KERNEL);
-       if (!ir->keytable.scan)
-               return -ENOMEM;
-
-       IR_dprintk(1, "Allocated space for %d keycode entries (%zd bytes)\n",
-               ir->keytable.size,
-               ir->keytable.size * sizeof(ir->keytable.scan));
-
-       ir_copy_table(&ir->keytable, ir_codes);
-       ir_set_keycode_table(dev, &ir->keytable);
-
-       clear_bit(0, dev->keybit);
-       set_bit(EV_KEY, dev->evbit);
        if (repeat)
                set_bit(EV_REP, dev->evbit);
 
similarity index 97%
rename from drivers/media/common/ir-keymaps.c
rename to drivers/media/IR/ir-keymaps.c
index 328c973a083833536ee016fc80ebb4d1bc128eb7..9bbe6b1e9871f48816f598d6318165964fb97592 100644 (file)
@@ -1847,76 +1847,6 @@ struct ir_scancode_table ir_codes_hauppauge_new_table = {
 };
 EXPORT_SYMBOL_GPL(ir_codes_hauppauge_new_table);
 
-/*
- * Hauppauge:the newer, gray remotes (seems there are multiple
- * slightly different versions), shipped with cx88+ivtv cards.
- *
- * This table contains the complete RC5 code, instead of just the data part
- */
-static struct ir_scancode ir_codes_rc5_hauppauge_new[] = {
-       /* Keys 0 to 9 */
-       { 0x1e00, KEY_0 },
-       { 0x1e01, KEY_1 },
-       { 0x1e02, KEY_2 },
-       { 0x1e03, KEY_3 },
-       { 0x1e04, KEY_4 },
-       { 0x1e05, KEY_5 },
-       { 0x1e06, KEY_6 },
-       { 0x1e07, KEY_7 },
-       { 0x1e08, KEY_8 },
-       { 0x1e09, KEY_9 },
-
-       { 0x1e0a, KEY_TEXT },           /* keypad asterisk as well */
-       { 0x1e0b, KEY_RED },            /* red button */
-       { 0x1e0c, KEY_RADIO },
-       { 0x1e0d, KEY_MENU },
-       { 0x1e0e, KEY_SUBTITLE },               /* also the # key */
-       { 0x1e0f, KEY_MUTE },
-       { 0x1e10, KEY_VOLUMEUP },
-       { 0x1e11, KEY_VOLUMEDOWN },
-       { 0x1e12, KEY_PREVIOUS },               /* previous channel */
-       { 0x1e14, KEY_UP },
-       { 0x1e15, KEY_DOWN },
-       { 0x1e16, KEY_LEFT },
-       { 0x1e17, KEY_RIGHT },
-       { 0x1e18, KEY_VIDEO },          /* Videos */
-       { 0x1e19, KEY_AUDIO },          /* Music */
-       /* 0x1e1a: Pictures - presume this means
-          "Multimedia Home Platform" -
-          no "PICTURES" key in input.h
-        */
-       { 0x1e1a, KEY_MHP },
-
-       { 0x1e1b, KEY_EPG },            /* Guide */
-       { 0x1e1c, KEY_TV },
-       { 0x1e1e, KEY_NEXTSONG },               /* skip >| */
-       { 0x1e1f, KEY_EXIT },           /* back/exit */
-       { 0x1e20, KEY_CHANNELUP },      /* channel / program + */
-       { 0x1e21, KEY_CHANNELDOWN },    /* channel / program - */
-       { 0x1e22, KEY_CHANNEL },                /* source (old black remote) */
-       { 0x1e24, KEY_PREVIOUSSONG },   /* replay |< */
-       { 0x1e25, KEY_ENTER },          /* OK */
-       { 0x1e26, KEY_SLEEP },          /* minimize (old black remote) */
-       { 0x1e29, KEY_BLUE },           /* blue key */
-       { 0x1e2e, KEY_GREEN },          /* green button */
-       { 0x1e30, KEY_PAUSE },          /* pause */
-       { 0x1e32, KEY_REWIND },         /* backward << */
-       { 0x1e34, KEY_FASTFORWARD },    /* forward >> */
-       { 0x1e35, KEY_PLAY },
-       { 0x1e36, KEY_STOP },
-       { 0x1e37, KEY_RECORD },         /* recording */
-       { 0x1e38, KEY_YELLOW },         /* yellow key */
-       { 0x1e3b, KEY_SELECT },         /* top right button */
-       { 0x1e3c, KEY_ZOOM },           /* full */
-       { 0x1e3d, KEY_POWER },          /* system power (green button) */
-};
-
-struct ir_scancode_table ir_codes_rc5_hauppauge_new_table = {
-       .scan = ir_codes_rc5_hauppauge_new,
-       .size = ARRAY_SIZE(ir_codes_rc5_hauppauge_new),
-};
-EXPORT_SYMBOL_GPL(ir_codes_rc5_hauppauge_new_table);
-
 static struct ir_scancode ir_codes_npgtech[] = {
        { 0x1d, KEY_SWITCHVIDEOMODE },  /* switch inputs */
        { 0x2a, KEY_FRONT },
@@ -3314,3 +3244,152 @@ struct ir_scancode_table ir_codes_gadmei_rm008z_table = {
 };
 EXPORT_SYMBOL_GPL(ir_codes_gadmei_rm008z_table);
 
+/*************************************************************
+ *             COMPLETE SCANCODE TABLES
+ * Instead of just a partial scancode, the tables bellow
+ * contains the complete scancode and the receiver protocol
+ *************************************************************/
+
+/*
+ * Hauppauge:the newer, gray remotes (seems there are multiple
+ * slightly different versions), shipped with cx88+ivtv cards.
+ *
+ * This table contains the complete RC5 code, instead of just the data part
+ */
+static struct ir_scancode ir_codes_rc5_hauppauge_new[] = {
+       /* Keys 0 to 9 */
+       { 0x1e00, KEY_0 },
+       { 0x1e01, KEY_1 },
+       { 0x1e02, KEY_2 },
+       { 0x1e03, KEY_3 },
+       { 0x1e04, KEY_4 },
+       { 0x1e05, KEY_5 },
+       { 0x1e06, KEY_6 },
+       { 0x1e07, KEY_7 },
+       { 0x1e08, KEY_8 },
+       { 0x1e09, KEY_9 },
+
+       { 0x1e0a, KEY_TEXT },           /* keypad asterisk as well */
+       { 0x1e0b, KEY_RED },            /* red button */
+       { 0x1e0c, KEY_RADIO },
+       { 0x1e0d, KEY_MENU },
+       { 0x1e0e, KEY_SUBTITLE },               /* also the # key */
+       { 0x1e0f, KEY_MUTE },
+       { 0x1e10, KEY_VOLUMEUP },
+       { 0x1e11, KEY_VOLUMEDOWN },
+       { 0x1e12, KEY_PREVIOUS },               /* previous channel */
+       { 0x1e14, KEY_UP },
+       { 0x1e15, KEY_DOWN },
+       { 0x1e16, KEY_LEFT },
+       { 0x1e17, KEY_RIGHT },
+       { 0x1e18, KEY_VIDEO },          /* Videos */
+       { 0x1e19, KEY_AUDIO },          /* Music */
+       /* 0x1e1a: Pictures - presume this means
+          "Multimedia Home Platform" -
+          no "PICTURES" key in input.h
+        */
+       { 0x1e1a, KEY_MHP },
+
+       { 0x1e1b, KEY_EPG },            /* Guide */
+       { 0x1e1c, KEY_TV },
+       { 0x1e1e, KEY_NEXTSONG },               /* skip >| */
+       { 0x1e1f, KEY_EXIT },           /* back/exit */
+       { 0x1e20, KEY_CHANNELUP },      /* channel / program + */
+       { 0x1e21, KEY_CHANNELDOWN },    /* channel / program - */
+       { 0x1e22, KEY_CHANNEL },                /* source (old black remote) */
+       { 0x1e24, KEY_PREVIOUSSONG },   /* replay |< */
+       { 0x1e25, KEY_ENTER },          /* OK */
+       { 0x1e26, KEY_SLEEP },          /* minimize (old black remote) */
+       { 0x1e29, KEY_BLUE },           /* blue key */
+       { 0x1e2e, KEY_GREEN },          /* green button */
+       { 0x1e30, KEY_PAUSE },          /* pause */
+       { 0x1e32, KEY_REWIND },         /* backward << */
+       { 0x1e34, KEY_FASTFORWARD },    /* forward >> */
+       { 0x1e35, KEY_PLAY },
+       { 0x1e36, KEY_STOP },
+       { 0x1e37, KEY_RECORD },         /* recording */
+       { 0x1e38, KEY_YELLOW },         /* yellow key */
+       { 0x1e3b, KEY_SELECT },         /* top right button */
+       { 0x1e3c, KEY_ZOOM },           /* full */
+       { 0x1e3d, KEY_POWER },          /* system power (green button) */
+};
+
+struct ir_scancode_table ir_codes_rc5_hauppauge_new_table = {
+       .scan = ir_codes_rc5_hauppauge_new,
+       .size = ARRAY_SIZE(ir_codes_rc5_hauppauge_new),
+       .ir_type = IR_TYPE_RC5,
+};
+EXPORT_SYMBOL_GPL(ir_codes_rc5_hauppauge_new_table);
+
+/* Terratec Cinergy Hybrid T USB XS FM
+   Mauro Carvalho Chehab <mchehab@redhat.com>
+ */
+static struct ir_scancode ir_codes_nec_terratec_cinergy_xs[] = {
+       { 0x1441, KEY_HOME},
+       { 0x1401, KEY_POWER2},
+
+       { 0x1442, KEY_MENU},            /* DVD menu */
+       { 0x1443, KEY_SUBTITLE},
+       { 0x1444, KEY_TEXT},            /* Teletext */
+       { 0x1445, KEY_DELETE},
+
+       { 0x1402, KEY_1},
+       { 0x1403, KEY_2},
+       { 0x1404, KEY_3},
+       { 0x1405, KEY_4},
+       { 0x1406, KEY_5},
+       { 0x1407, KEY_6},
+       { 0x1408, KEY_7},
+       { 0x1409, KEY_8},
+       { 0x140a, KEY_9},
+       { 0x140c, KEY_0},
+
+       { 0x140b, KEY_TUNER},           /* AV */
+       { 0x140d, KEY_MODE},            /* A.B */
+
+       { 0x1446, KEY_TV},
+       { 0x1447, KEY_DVD},
+       { 0x1449, KEY_VIDEO},
+       { 0x144a, KEY_RADIO},           /* Music */
+       { 0x144b, KEY_CAMERA},          /* PIC */
+
+       { 0x1410, KEY_UP},
+       { 0x1411, KEY_LEFT},
+       { 0x1412, KEY_OK},
+       { 0x1413, KEY_RIGHT},
+       { 0x1414, KEY_DOWN},
+
+       { 0x140f, KEY_EPG},
+       { 0x1416, KEY_INFO},
+       { 0x144d, KEY_BACKSPACE},
+
+       { 0x141c, KEY_VOLUMEUP},
+       { 0x141e, KEY_VOLUMEDOWN},
+
+       { 0x144c, KEY_PLAY},
+       { 0x141d, KEY_MUTE},
+
+       { 0x141b, KEY_CHANNELUP},
+       { 0x141f, KEY_CHANNELDOWN},
+
+       { 0x1417, KEY_RED},
+       { 0x1418, KEY_GREEN},
+       { 0x1419, KEY_YELLOW},
+       { 0x141a, KEY_BLUE},
+
+       { 0x1458, KEY_RECORD},
+       { 0x1448, KEY_STOP},
+       { 0x1440, KEY_PAUSE},
+
+       { 0x1454, KEY_LAST},
+       { 0x144e, KEY_REWIND},
+       { 0x144f, KEY_FASTFORWARD},
+       { 0x145c, KEY_NEXT},
+};
+struct ir_scancode_table ir_codes_nec_terratec_cinergy_xs_table = {
+       .scan = ir_codes_nec_terratec_cinergy_xs,
+       .size = ARRAY_SIZE(ir_codes_nec_terratec_cinergy_xs),
+       .ir_type = IR_TYPE_NEC,
+};
+EXPORT_SYMBOL_GPL(ir_codes_nec_terratec_cinergy_xs_table);
+
similarity index 81%
rename from drivers/media/common/ir-keytable.c
rename to drivers/media/IR/ir-keytable.c
index 26ce5bc2fdd545de4bf3088e655e1ec7e9a0507a..bff7a5356037bc6172cd21e95605572a92ed34b0 100644 (file)
@@ -1,10 +1,19 @@
 /* ir-register.c - handle IR scancode->keycode tables
  *
  * Copyright (C) 2009 by Mauro Carvalho Chehab <mchehab@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
  */
 
-#include <linux/usb/input.h>
 
+#include <linux/usb/input.h>
 #include <media/ir-common.h>
 
 #define IR_TAB_MIN_SIZE        32
@@ -72,6 +81,7 @@ int ir_roundup_tablesize(int n_elems)
 
        return n_elems;
 }
+EXPORT_SYMBOL_GPL(ir_roundup_tablesize);
 
 /**
  * ir_copy_table() - copies a keytable, discarding the unused entries
@@ -100,6 +110,7 @@ int ir_copy_table(struct ir_scancode_table *destin,
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(ir_copy_table);
 
 /**
  * ir_getkeycode() - get a keycode at the evdev scancode ->keycode table
@@ -114,7 +125,8 @@ static int ir_getkeycode(struct input_dev *dev,
                         int scancode, int *keycode)
 {
        int elem;
-       struct ir_scancode_table *rc_tab = input_get_drvdata(dev);
+       struct ir_input_dev *ir_dev = input_get_drvdata(dev);
+       struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
 
        elem = ir_seek_table(rc_tab, scancode);
        if (elem >= 0) {
@@ -136,7 +148,6 @@ static int ir_getkeycode(struct input_dev *dev,
        return 0;
 }
 
-
 /**
  * ir_is_resize_needed() - Check if the table needs rezise
  * @table:             keycode table that may need to resize
@@ -286,7 +297,8 @@ static int ir_setkeycode(struct input_dev *dev,
                         int scancode, int keycode)
 {
        int rc = 0;
-       struct ir_scancode_table *rc_tab = input_get_drvdata(dev);
+       struct ir_input_dev *ir_dev = input_get_drvdata(dev);
+       struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
        struct ir_scancode *keymap = rc_tab->scan;
        unsigned long flags;
 
@@ -360,7 +372,8 @@ static int ir_setkeycode(struct input_dev *dev,
  */
 u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
 {
-       struct ir_scancode_table *rc_tab = input_get_drvdata(dev);
+       struct ir_input_dev *ir_dev = input_get_drvdata(dev);
+       struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
        struct ir_scancode *keymap = rc_tab->scan;
        int elem;
 
@@ -378,9 +391,10 @@ u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
        /* Reports userspace that an unknown keycode were got */
        return KEY_RESERVED;
 }
+EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
 
 /**
- * ir_set_keycode_table() - sets the IR keycode table and add the handlers
+ * ir_input_register() - sets the IR keycode table and add the handlers
  *                         for keymap table get/set
  * @input_dev: the struct input_dev descriptor of the device
  * @rc_tab:    the struct ir_scancode_table table of scancode/keymap
@@ -389,17 +403,34 @@ u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
  * an IR.
  * It should be called before registering the IR device.
  */
-int ir_set_keycode_table(struct input_dev *input_dev,
-                        struct ir_scancode_table *rc_tab)
+int ir_input_register(struct input_dev *input_dev,
+                     struct ir_scancode_table *rc_tab)
 {
-       struct ir_scancode *keymap = rc_tab->scan;
-       int i;
-
-       spin_lock_init(&rc_tab->lock);
+       struct ir_input_dev *ir_dev;
+       struct ir_scancode  *keymap    = rc_tab->scan;
+       int i, rc;
 
        if (rc_tab->scan == NULL || !rc_tab->size)
                return -EINVAL;
 
+       ir_dev = kzalloc(sizeof(*ir_dev), GFP_KERNEL);
+       if (!ir_dev)
+               return -ENOMEM;
+
+       spin_lock_init(&rc_tab->lock);
+
+       ir_dev->rc_tab.size = ir_roundup_tablesize(rc_tab->size);
+       ir_dev->rc_tab.scan = kzalloc(ir_dev->rc_tab.size *
+                                   sizeof(struct ir_scancode), GFP_KERNEL);
+       if (!ir_dev->rc_tab.scan)
+               return -ENOMEM;
+
+       IR_dprintk(1, "Allocated space for %d keycode entries (%zd bytes)\n",
+               ir_dev->rc_tab.size,
+               ir_dev->rc_tab.size * sizeof(ir_dev->rc_tab.scan));
+
+       ir_copy_table(&ir_dev->rc_tab, rc_tab);
+
        /* set the bits for the keys */
        IR_dprintk(1, "key map size: %d\n", rc_tab->size);
        for (i = 0; i < rc_tab->size; i++) {
@@ -407,23 +438,48 @@ int ir_set_keycode_table(struct input_dev *input_dev,
                        i, keymap[i].keycode);
                set_bit(keymap[i].keycode, input_dev->keybit);
        }
+       clear_bit(0, input_dev->keybit);
+
+       set_bit(EV_KEY, input_dev->evbit);
 
        input_dev->getkeycode = ir_getkeycode;
        input_dev->setkeycode = ir_setkeycode;
-       input_set_drvdata(input_dev, rc_tab);
+       input_set_drvdata(input_dev, ir_dev);
 
-       return 0;
+       rc = input_register_device(input_dev);
+       if (rc < 0) {
+               kfree(rc_tab->scan);
+               kfree(ir_dev);
+               input_set_drvdata(input_dev, NULL);
+       }
+
+       return rc;
 }
+EXPORT_SYMBOL_GPL(ir_input_register);
 
-void ir_input_free(struct input_dev *dev)
+void ir_input_unregister(struct input_dev *dev)
 {
-       struct ir_scancode_table *rc_tab = input_get_drvdata(dev);
+       struct ir_input_dev *ir_dev = input_get_drvdata(dev);
+       struct ir_scancode_table *rc_tab;
+
+       if (!ir_dev)
+               return;
 
        IR_dprintk(1, "Freed keycode table\n");
 
+       rc_tab = &ir_dev->rc_tab;
        rc_tab->size = 0;
        kfree(rc_tab->scan);
        rc_tab->scan = NULL;
+
+       kfree(ir_dev);
+       input_unregister_device(dev);
 }
-EXPORT_SYMBOL_GPL(ir_input_free);
+EXPORT_SYMBOL_GPL(ir_input_unregister);
+
+int ir_core_debug;    /* ir_debug level (0,1,2) */
+EXPORT_SYMBOL_GPL(ir_core_debug);
+module_param_named(debug, ir_core_debug, int, 0644);
 
+MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
+MODULE_LICENSE("GPL");
index ba69beeb0e21a850aab9d1a49b11c409b332f44e..a28541b2b1a219e5a2804f20201191f1ff98c953 100644 (file)
@@ -99,6 +99,7 @@ config VIDEO_MEDIA
 comment "Multimedia drivers"
 
 source "drivers/media/common/Kconfig"
+source "drivers/media/IR/Kconfig"
 
 #
 # Tuner drivers for DVB and V4L
index 09a829d8a7e71a4b7b0b5de035f7034d1748e82d..499b0810d01984f465b23ac1d490abcb30258156 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the kernel multimedia device drivers.
 #
 
-obj-y += common/ video/
+obj-y += common/ IR/ video/
 
 obj-$(CONFIG_VIDEO_DEV) += radio/
 obj-$(CONFIG_DVB_CORE)  += dvb/
index 169b337b7c9df6c16083995129ec7ce20683aa0c..e3ec9639321b750ab10d953899e843687adc0cc3 100644 (file)
@@ -1,8 +1,6 @@
 saa7146-objs    := saa7146_i2c.o saa7146_core.o
 saa7146_vv-objs := saa7146_fops.o saa7146_video.o saa7146_hlp.o saa7146_vbi.o
-ir-common-objs  := ir-functions.o ir-keymaps.o ir-keytable.o
 
 obj-y += tuners/
 obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o
 obj-$(CONFIG_VIDEO_SAA7146_VV) += saa7146_vv.o
-obj-$(CONFIG_VIDEO_IR) += ir-common.o
index 620f655fa9c5b1e2602755fff2dadf9f7689000b..7364b9642d005c0579838c4efdf7c61888767f98 100644 (file)
@@ -1,7 +1,5 @@
 #include <media/saa7146_vv.h>
 
-#define BOARD_CAN_DO_VBI(dev)   (dev->revision != 0 && dev->vv_data->vbi_minor != -1)
-
 /****************************************************************************/
 /* resource management functions, shamelessly stolen from saa7134 driver */
 
@@ -194,43 +192,24 @@ void saa7146_buffer_timeout(unsigned long data)
 
 static int fops_open(struct file *file)
 {
-       unsigned int minor = video_devdata(file)->minor;
-       struct saa7146_dev *h = NULL, *dev = NULL;
-       struct list_head *list;
+       struct video_device *vdev = video_devdata(file);
+       struct saa7146_dev *dev = video_drvdata(file);
        struct saa7146_fh *fh = NULL;
        int result = 0;
 
-       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       enum v4l2_buf_type type;
 
-       DEB_EE(("file:%p, minor:%d\n", file, minor));
+       DEB_EE(("file:%p, dev:%s\n", file, video_device_node_name(vdev)));
 
        if (mutex_lock_interruptible(&saa7146_devices_lock))
                return -ERESTARTSYS;
 
-       list_for_each(list,&saa7146_devices) {
-               h = list_entry(list, struct saa7146_dev, item);
-               if( NULL == h->vv_data ) {
-                       DEB_D(("device %p has not registered video devices.\n",h));
-                       continue;
-               }
-               DEB_D(("trying: %p @ major %d,%d\n",h,h->vv_data->video_minor,h->vv_data->vbi_minor));
-
-               if (h->vv_data->video_minor == minor) {
-                       dev = h;
-               }
-               if (h->vv_data->vbi_minor == minor) {
-                       type = V4L2_BUF_TYPE_VBI_CAPTURE;
-                       dev = h;
-               }
-       }
-       if (NULL == dev) {
-               DEB_S(("no such video device.\n"));
-               result = -ENODEV;
-               goto out;
-       }
-
        DEB_D(("using: %p\n",dev));
 
+       type = vdev->vfl_type == VFL_TYPE_GRABBER
+            ? V4L2_BUF_TYPE_VIDEO_CAPTURE
+            : V4L2_BUF_TYPE_VBI_CAPTURE;
+
        /* check if an extension is registered */
        if( NULL == dev->ext ) {
                DEB_S(("no extension registered for this device.\n"));
@@ -474,9 +453,6 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
           configuration data) */
        dev->ext_vv_data = ext_vv;
 
-       vv->video_minor = -1;
-       vv->vbi_minor = -1;
-
        vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle);
        if( NULL == vv->d_clipping.cpu_addr ) {
                ERR(("out of memory. aborting.\n"));
@@ -515,7 +491,6 @@ EXPORT_SYMBOL_GPL(saa7146_vv_release);
 int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
                            char *name, int type)
 {
-       struct saa7146_vv *vv = dev->vv_data;
        struct video_device *vfd;
        int err;
        int i;
@@ -543,15 +518,8 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
                return err;
        }
 
-       if( VFL_TYPE_GRABBER == type ) {
-               vv->video_minor = vfd->minor;
-               INFO(("%s: registered device video%d [v4l2]\n",
-                       dev->name, vfd->num));
-       } else {
-               vv->vbi_minor = vfd->minor;
-               INFO(("%s: registered device vbi%d [v4l2]\n",
-                       dev->name, vfd->num));
-       }
+       INFO(("%s: registered device %s [v4l2]\n",
+               dev->name, video_device_node_name(vfd)));
 
        *vid = vfd;
        return 0;
@@ -560,16 +528,8 @@ EXPORT_SYMBOL_GPL(saa7146_register_device);
 
 int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev)
 {
-       struct saa7146_vv *vv = dev->vv_data;
-
        DEB_EE(("dev:%p\n",dev));
 
-       if ((*vid)->vfl_type == VFL_TYPE_GRABBER) {
-               vv->video_minor = -1;
-       } else {
-               vv->vbi_minor = -1;
-       }
-
        video_unregister_device(*vid);
        *vid = NULL;
 
index 53e3f2a7d31aa0f9ed8c4a50f98451920033784f..f0f483ac8b891760d822f7081eae139f0f45bad4 100644 (file)
@@ -589,7 +589,7 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
        snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
                "pci-%s/ir0", pci_name(dm1105->pdev));
 
-       err = ir_input_init(input_dev, &dm1105->ir.ir, ir_type, ir_codes);
+       err = ir_input_init(input_dev, &dm1105->ir.ir, ir_type);
        if (err < 0) {
                input_free_device(input_dev);
                return err;
@@ -611,20 +611,14 @@ int __devinit dm1105_ir_init(struct dm1105dvb *dm1105)
 
        INIT_WORK(&dm1105->ir.work, dm1105_emit_key);
 
-       err = input_register_device(input_dev);
-       if (err) {
-               ir_input_free(input_dev);
-               input_free_device(input_dev);
-               return err;
-       }
+       err = ir_input_register(input_dev, ir_codes);
 
-       return 0;
+       return err;
 }
 
 void __devexit dm1105_ir_exit(struct dm1105dvb *dm1105)
 {
-       ir_input_free(dm1105->ir.input_dev);
-       input_unregister_device(dm1105->ir.input_dev);
+       ir_input_unregister(dm1105->ir.input_dev);
 }
 
 static int __devinit dm1105dvb_hw_init(struct dm1105dvb *dm1105dvb)
index 2dee1bf73577feea70525e96efff84b24c8f8246..1b249897c9fbecf6c82fa9017e562d94b5909e46 100644 (file)
@@ -265,9 +265,13 @@ config DVB_USB_DW2102
        select DVB_TDA10021 if !DVB_FE_CUSTOMISE
        select DVB_MT312 if !DVB_FE_CUSTOMISE
        select DVB_ZL10039 if !DVB_FE_CUSTOMISE
+       select DVB_DS3000 if !DVB_FE_CUSTOMISE
+       select DVB_STB6100 if !DVB_FE_CUSTOMISE
+       select DVB_STV6110 if !DVB_FE_CUSTOMISE
+       select DVB_STV0900 if !DVB_FE_CUSTOMISE
        help
-         Say Y here to support the DvbWorld DVB-S/S2 USB2.0 receivers
-         and the TeVii S650, S630.
+         Say Y here to support the DvbWorld, TeVii, Prof DVB-S/S2 USB2.0
+         receivers.
 
 config DVB_USB_CINERGY_T2
        tristate "Terratec CinergyT2/qanu USB 2.0 DVB-T receiver"
index 8b544fe79b0de11842f883c48dc041f9889a968b..495a90577c5f7f1f9d0524b5edf55d141bb77846 100644 (file)
@@ -20,20 +20,22 @@ extern int dvb_usb_dib0700_debug;
 #define deb_fwdata(args...) dprintk(dvb_usb_dib0700_debug,0x04,args)
 #define deb_data(args...)   dprintk(dvb_usb_dib0700_debug,0x08,args)
 
-#define REQUEST_I2C_READ     0x2
-#define REQUEST_I2C_WRITE    0x3
-#define REQUEST_POLL_RC      0x4 /* deprecated in firmware v1.20 */
-#define REQUEST_JUMPRAM      0x8
-#define REQUEST_SET_CLOCK    0xB
-#define REQUEST_SET_GPIO     0xC
-#define REQUEST_ENABLE_VIDEO 0xF
+#define REQUEST_SET_USB_XFER_LEN    0x0 /* valid only for firmware version */
+                                       /* higher than 1.21 */
+#define REQUEST_I2C_READ            0x2
+#define REQUEST_I2C_WRITE           0x3
+#define REQUEST_POLL_RC             0x4 /* deprecated in firmware v1.20 */
+#define REQUEST_JUMPRAM             0x8
+#define REQUEST_SET_CLOCK           0xB
+#define REQUEST_SET_GPIO            0xC
+#define REQUEST_ENABLE_VIDEO        0xF
        // 1 Byte: 4MSB(1 = enable streaming, 0 = disable streaming) 4LSB(Video Mode: 0 = MPEG2 188Bytes, 1 = Analog)
        // 2 Byte: MPEG2 mode:  4MSB(1 = Master Mode, 0 = Slave Mode) 4LSB(Channel 1 = bit0, Channel 2 = bit1)
        // 2 Byte: Analog mode: 4MSB(0 = 625 lines, 1 = 525 lines)    4LSB(     "                "           )
-#define REQUEST_SET_RC       0x11
-#define REQUEST_NEW_I2C_READ 0x12
-#define REQUEST_NEW_I2C_WRITE 0x13
-#define REQUEST_GET_VERSION  0x15
+#define REQUEST_SET_RC              0x11
+#define REQUEST_NEW_I2C_READ        0x12
+#define REQUEST_NEW_I2C_WRITE       0x13
+#define REQUEST_GET_VERSION         0x15
 
 struct dib0700_state {
        u8 channel_state;
@@ -44,6 +46,8 @@ struct dib0700_state {
        u8 is_dib7000pc;
        u8 fw_use_new_i2c_api;
        u8 disable_streaming_master_mode;
+    u32 fw_version;
+    u32 nb_packet_buffer_size;
 };
 
 extern int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
index db7f7f79a66ce5796998629fe63ab2e812f34124..0d3c9a9a33be4bd1bf74d7a51042592099b315de 100644 (file)
@@ -17,6 +17,14 @@ int dvb_usb_dib0700_ir_proto = 1;
 module_param(dvb_usb_dib0700_ir_proto, int, 0644);
 MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (default), 2=RC6).");
 
+static int nb_packet_buffer_size = 21;
+module_param(nb_packet_buffer_size, int, 0644);
+MODULE_PARM_DESC(nb_packet_buffer_size,
+       "Set the dib0700 driver data buffer size. This parameter "
+       "corresponds to the number of TS packets. The actual size of "
+       "the data buffer corresponds to this parameter "
+       "multiplied by 188 (default: 21)");
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 
@@ -28,10 +36,14 @@ int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
                                  REQUEST_GET_VERSION,
                                  USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
                                  b, sizeof(b), USB_CTRL_GET_TIMEOUT);
-       *hwversion  = (b[0] << 24)  | (b[1] << 16)  | (b[2] << 8)  | b[3];
-       *romversion = (b[4] << 24)  | (b[5] << 16)  | (b[6] << 8)  | b[7];
-       *ramversion = (b[8] << 24)  | (b[9] << 16)  | (b[10] << 8) | b[11];
-       *fwtype     = (b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15];
+       if (hwversion != NULL)
+               *hwversion  = (b[0] << 24)  | (b[1] << 16)  | (b[2] << 8)  | b[3];
+       if (romversion != NULL)
+               *romversion = (b[4] << 24)  | (b[5] << 16)  | (b[6] << 8)  | b[7];
+       if (ramversion != NULL)
+               *ramversion = (b[8] << 24)  | (b[9] << 16)  | (b[10] << 8) | b[11];
+       if (fwtype != NULL)
+               *fwtype     = (b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15];
        return ret;
 }
 
@@ -97,6 +109,27 @@ int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_
        return dib0700_ctrl_wr(d,buf,3);
 }
 
+static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
+{
+    struct dib0700_state *st = d->priv;
+    u8 b[3];
+    int ret;
+
+    if (st->fw_version >= 0x10201) {
+       b[0] = REQUEST_SET_USB_XFER_LEN;
+       b[1] = (nb_ts_packets >> 8)&0xff;
+       b[2] = nb_ts_packets & 0xff;
+
+       deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
+
+       ret = dib0700_ctrl_wr(d, b, 3);
+    } else {
+       deb_info("this firmware does not allow to change the USB xfer len\n");
+       ret = -EIO;
+    }
+    return ret;
+}
+
 /*
  * I2C master xfer function (supported in 1.20 firmware)
  */
@@ -328,7 +361,9 @@ static int dib0700_jumpram(struct usb_device *udev, u32 address)
 int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw)
 {
        struct hexline hx;
-       int pos = 0, ret, act_len;
+       int pos = 0, ret, act_len, i, adap_num;
+       u8 b[16];
+       u32 fw_version;
 
        u8 buf[260];
 
@@ -364,6 +399,34 @@ int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw
        } else
                ret = -EIO;
 
+       /* the number of ts packet has to be at least 1 */
+       if (nb_packet_buffer_size < 1)
+               nb_packet_buffer_size = 1;
+
+       /* get the fimware version */
+       usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
+                                 REQUEST_GET_VERSION,
+                                 USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
+                                 b, sizeof(b), USB_CTRL_GET_TIMEOUT);
+       fw_version = (b[8] << 24)  | (b[9] << 16)  | (b[10] << 8) | b[11];
+
+       /* set the buffer size - DVB-USB is allocating URB buffers
+        * only after the firwmare download was successful */
+       for (i = 0; i < dib0700_device_count; i++) {
+               for (adap_num = 0; adap_num < dib0700_devices[i].num_adapters;
+                               adap_num++) {
+                       if (fw_version >= 0x10201)
+                               dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 188*nb_packet_buffer_size;
+                       else {
+                               /* for fw version older than 1.20.1,
+                                * the buffersize has to be n times 512 */
+                               dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = ((188*nb_packet_buffer_size+188/2)/512)*512;
+                               if (dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize < 512)
+                                       dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 512;
+                       }
+               }
+       }
+
        return ret;
 }
 
@@ -371,6 +434,18 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
 {
        struct dib0700_state *st = adap->dev->priv;
        u8 b[4];
+       int ret;
+
+       if ((onoff != 0) && (st->fw_version >= 0x10201)) {
+               /* for firmware later than 1.20.1,
+                * the USB xfer length can be set  */
+               ret = dib0700_set_usb_xfer_len(adap->dev,
+                       st->nb_packet_buffer_size);
+               if (ret < 0) {
+                       deb_info("can not set the USB xfer len\n");
+                       return ret;
+               }
+       }
 
        b[0] = REQUEST_ENABLE_VIDEO;
        b[1] = (onoff << 4) | 0x00; /* this bit gives a kind of command, rather than enabling something or not */
@@ -415,9 +490,21 @@ static int dib0700_probe(struct usb_interface *intf,
 
        for (i = 0; i < dib0700_device_count; i++)
                if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE,
-                                       &dev, adapter_nr) == 0)
-               {
+                   &dev, adapter_nr) == 0) {
+                       struct dib0700_state *st = dev->priv;
+                       u32 hwversion, romversion, fw_version, fwtype;
+
+                       dib0700_get_version(dev, &hwversion, &romversion,
+                               &fw_version, &fwtype);
+
+                       deb_info("Firmware version: %x, %d, 0x%x, %d\n",
+                               hwversion, romversion, fw_version, fwtype);
+
+                       st->fw_version = fw_version;
+                       st->nb_packet_buffer_size = (u32)nb_packet_buffer_size;
+
                        dib0700_rc_setup(dev);
+
                        return 0;
                }
 
index 684146f98eb753fb53376fbcfc010c29180df7c4..44972d01bbd02fddc22b66e84b78dcad712cb21a 100644 (file)
@@ -18,6 +18,7 @@
 #include "xc5000.h"
 #include "s5h1411.h"
 #include "dib0070.h"
+#include "dib0090.h"
 #include "lgdt3305.h"
 #include "mxl5007t.h"
 
@@ -130,93 +131,95 @@ static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
 /* MT226x */
 static struct dibx000_agc_config stk7700d_7000p_mt2266_agc_config[2] = {
        {
-               BAND_UHF, // band_caps
+               BAND_UHF,
 
                /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
                * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
-               (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
-
-               1130,  // inv_gain
-               21,  // time_stabiliz
-
-               0,  // alpha_level
-               118,  // thlock
-
-               0,     // wbd_inv
-               3530,  // wbd_ref
-               1,     // wbd_sel
-               0,     // wbd_alpha
-
-               65535,  // agc1_max
-               33770,  // agc1_min
-               65535,  // agc2_max
-               23592,  // agc2_min
-
-               0,    // agc1_pt1
-               62,   // agc1_pt2
-               255,  // agc1_pt3
-               64,   // agc1_slope1
-               64,   // agc1_slope2
-               132,  // agc2_pt1
-               192,  // agc2_pt2
-               80,   // agc2_slope1
-               80,   // agc2_slope2
-
-               17,  // alpha_mant
-               27,  // alpha_exp
-               23,  // beta_mant
-               51,  // beta_exp
-
-               1,  // perform_agc_softsplit
+               (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
+           | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
+
+               1130,
+               21,
+
+               0,
+               118,
+
+               0,
+               3530,
+               1,
+               0,
+
+               65535,
+               33770,
+               65535,
+               23592,
+
+               0,
+               62,
+               255,
+               64,
+               64,
+               132,
+               192,
+               80,
+               80,
+
+               17,
+               27,
+               23,
+               51,
+
+               1,
        }, {
-               BAND_VHF | BAND_LBAND, // band_caps
+               BAND_VHF | BAND_LBAND,
 
                /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1, P_agc_inv_pwm1=1, P_agc_inv_pwm2=1,
                * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
-               (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
-
-               2372, // inv_gain
-               21,   // time_stabiliz
-
-               0,    // alpha_level
-               118,  // thlock
-
-               0,    // wbd_inv
-               3530, // wbd_ref
-               1,     // wbd_sel
-               0,    // wbd_alpha
-
-               65535, // agc1_max
-               0,     // agc1_min
-               65535, // agc2_max
-               23592, // agc2_min
-
-               0,    // agc1_pt1
-               128,  // agc1_pt2
-               128,  // agc1_pt3
-               128,  // agc1_slope1
-               0,    // agc1_slope2
-               128,  // agc2_pt1
-               253,  // agc2_pt2
-               81,   // agc2_slope1
-               0,    // agc2_slope2
-
-               17,  // alpha_mant
-               27,  // alpha_exp
-               23,  // beta_mant
-               51,  // beta_exp
-
-               1,  // perform_agc_softsplit
+               (0 << 15) | (0 << 14) | (1 << 11) | (1 << 10) | (1 << 9) | (0 << 8)
+           | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
+
+               2372,
+               21,
+
+               0,
+               118,
+
+               0,
+               3530,
+               1,
+               0,
+
+               65535,
+               0,
+               65535,
+               23592,
+
+               0,
+               128,
+               128,
+               128,
+               0,
+               128,
+               253,
+               81,
+               0,
+
+               17,
+               27,
+               23,
+               51,
+
+               1,
        }
 };
 
 static struct dibx000_bandwidth_config stk7700d_mt2266_pll_config = {
-       60000, 30000, // internal, sampling
-       1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
-       0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
-       (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
-       0, // ifreq
-       20452225, // timf
+       60000, 30000,
+       1, 8, 3, 1, 0,
+       0, 0, 1, 1, 2,
+       (3 << 14) | (1 << 12) | (524 << 0),
+       0,
+       20452225,
 };
 
 static struct dib7000p_config stk7700d_dib7000p_mt2266_config[] = {
@@ -605,17 +608,17 @@ static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
                }
                break;
        default:
-               if (actlen != sizeof(buf)) {
-                       /* We didn't get back the 6 byte message we expected */
-                       err("Unexpected RC response size [%d]", actlen);
-                       return -1;
-               }
+       if (actlen != sizeof(buf)) {
+               /* We didn't get back the 6 byte message we expected */
+               err("Unexpected RC response size [%d]", actlen);
+               return -1;
+       }
 
-               poll_reply.report_id  = buf[0];
-               poll_reply.data_state = buf[1];
+       poll_reply.report_id  = buf[0];
+       poll_reply.data_state = buf[1];
                poll_reply.system     = (buf[2] << 8) | buf[3];
-               poll_reply.data       = buf[4];
-               poll_reply.not_data   = buf[5];
+       poll_reply.data       = buf[4];
+       poll_reply.not_data   = buf[5];
 
                break;
        }
@@ -632,7 +635,7 @@ static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
        /* Find the key in the map */
        for (i = 0; i < d->props.rc_key_map_size; i++) {
                if (rc5_custom(&keymap[i]) == (poll_reply.system & 0xff) &&
-                   rc5_data(&keymap[i]) == poll_reply.data) {
+                       rc5_data(&keymap[i]) == poll_reply.data) {
                        *event = keymap[i].event;
                        found = 1;
                        break;
@@ -641,8 +644,8 @@ static int dib0700_rc_query_v1_20(struct dvb_usb_device *d, u32 *event,
 
        if (found == 0) {
                err("Unknown remote controller key: %04x %02x %02x",
-                   poll_reply.system,
-                   poll_reply.data, poll_reply.not_data);
+                       poll_reply.system,
+                       poll_reply.data, poll_reply.not_data);
                d->last_event = 0;
                return 0;
        }
@@ -933,47 +936,48 @@ static struct dvb_usb_rc_key dib0700_rc_keys[] = {
 
 /* STK7700P: Hauppauge Nova-T Stick, AVerMedia Volar */
 static struct dibx000_agc_config stk7700p_7000m_mt2060_agc_config = {
-       BAND_UHF | BAND_VHF,       // band_caps
+       BAND_UHF | BAND_VHF,
 
        /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
         * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
-       (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
-
-       712,  // inv_gain
-       41,  // time_stabiliz
-
-       0,  // alpha_level
-       118,  // thlock
-
-       0,     // wbd_inv
-       4095,  // wbd_ref
-       0,     // wbd_sel
-       0,     // wbd_alpha
-
-       42598,  // agc1_max
-       17694,  // agc1_min
-       45875,  // agc2_max
-       2621,  // agc2_min
-       0,  // agc1_pt1
-       76,  // agc1_pt2
-       139,  // agc1_pt3
-       52,  // agc1_slope1
-       59,  // agc1_slope2
-       107,  // agc2_pt1
-       172,  // agc2_pt2
-       57,  // agc2_slope1
-       70,  // agc2_slope2
-
-       21,  // alpha_mant
-       25,  // alpha_exp
-       28,  // beta_mant
-       48,  // beta_exp
-
-       1,  // perform_agc_softsplit
-       {  0,     // split_min
-          107,   // split_max
-          51800, // global_split_min
-          24700  // global_split_max
+       (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
+       | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
+
+       712,
+       41,
+
+       0,
+       118,
+
+       0,
+       4095,
+       0,
+       0,
+
+       42598,
+       17694,
+       45875,
+       2621,
+       0,
+       76,
+       139,
+       52,
+       59,
+       107,
+       172,
+       57,
+       70,
+
+       21,
+       25,
+       28,
+       48,
+
+       1,
+       {  0,
+          107,
+          51800,
+          24700
        },
 };
 
@@ -982,54 +986,55 @@ static struct dibx000_agc_config stk7700p_7000p_mt2060_agc_config = {
 
        /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
         * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */
-       (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), // setup
+       (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
+       | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0),
 
-       712, // inv_gain
-       41,  // time_stabiliz
+       712,
+       41,
 
-       0,   // alpha_level
-       118, // thlock
+       0,
+       118,
 
-       0,    // wbd_inv
-       4095, // wbd_ref
-       0,    // wbd_sel
-       0,    // wbd_alpha
+       0,
+       4095,
+       0,
+       0,
 
-       42598, // agc1_max
-       16384, // agc1_min
-       42598, // agc2_max
-           0, // agc2_min
+       42598,
+       16384,
+       42598,
+           0,
 
-         0,   // agc1_pt1
-       137,   // agc1_pt2
-       255,   // agc1_pt3
+         0,
+       137,
+       255,
 
-         0,   // agc1_slope1
-       255,   // agc1_slope2
+         0,
+       255,
 
-       0,     // agc2_pt1
-       0,     // agc2_pt2
+       0,
+       0,
 
-        0,    // agc2_slope1
-       41,    // agc2_slope2
+        0,
+       41,
 
-       15, // alpha_mant
-       25, // alpha_exp
+       15,
+       25,
 
-       28, // beta_mant
-       48, // beta_exp
+       28,
+       48,
 
-       0, // perform_agc_softsplit
+       0,
 };
 
 static struct dibx000_bandwidth_config stk7700p_pll_config = {
-       60000, 30000, // internal, sampling
-       1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
-       0, 0, 1, 1, 0, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
-       (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
-       60258167, // ifreq
-       20452225, // timf
-       30000000, // xtal
+       60000, 30000,
+       1, 8, 3, 1, 0,
+       0, 0, 1, 1, 0,
+       (3 << 14) | (1 << 12) | (524 << 0),
+       60258167,
+       20452225,
+       30000000,
 };
 
 static struct dib7000m_config stk7700p_dib7000m_config = {
@@ -1115,41 +1120,42 @@ static struct dibx000_agc_config dib7070_agc_config = {
        BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
        /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5, P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
         * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
-       (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0), // setup
-
-       600, // inv_gain
-       10,  // time_stabiliz
-
-       0,  // alpha_level
-       118,  // thlock
-
-       0,     // wbd_inv
-       3530,  // wbd_ref
-       1,     // wbd_sel
-       5,     // wbd_alpha
-
-       65535,  // agc1_max
-               0,  // agc1_min
-
-       65535,  // agc2_max
-       0,      // agc2_min
-
-       0,      // agc1_pt1
-       40,     // agc1_pt2
-       183,    // agc1_pt3
-       206,    // agc1_slope1
-       255,    // agc1_slope2
-       72,     // agc2_pt1
-       152,    // agc2_pt2
-       88,     // agc2_slope1
-       90,     // agc2_slope2
-
-       17,  // alpha_mant
-       27,  // alpha_exp
-       23,  // beta_mant
-       51,  // beta_exp
-
-       0,  // perform_agc_softsplit
+       (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
+       | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
+
+       600,
+       10,
+
+       0,
+       118,
+
+       0,
+       3530,
+       1,
+       5,
+
+       65535,
+               0,
+
+       65535,
+       0,
+
+       0,
+       40,
+       183,
+       206,
+       255,
+       72,
+       152,
+       88,
+       90,
+
+       17,
+       27,
+       23,
+       51,
+
+       0,
 };
 
 static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
@@ -1276,13 +1282,13 @@ static int stk70x0p_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
 }
 
 static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
-       60000, 15000, // internal, sampling
-       1, 20, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass
-       0, 0, 1, 1, 2, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo
-       (3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k
-       (0 << 25) | 0, // ifreq = 0.000000 MHz
-       20452225, // timf
-       12000000, // xtal_hz
+       60000, 15000,
+       1, 20, 3, 1, 0,
+       0, 0, 1, 1, 2,
+       (3 << 14) | (1 << 12) | (524 << 0),
+       (0 << 25) | 0,
+       20452225,
+       12000000,
 };
 
 static struct dib7000p_config dib7070p_dib7000p_config = {
@@ -1476,12 +1482,12 @@ static struct dib8000_config dib807x_dib8000_config[2] = {
        }
 };
 
-static int dib807x_tuner_reset(struct dvb_frontend *fe, int onoff)
+static int dib80xx_tuner_reset(struct dvb_frontend *fe, int onoff)
 {
        return dib8000_set_gpio(fe, 5, 0, !onoff);
 }
 
-static int dib807x_tuner_sleep(struct dvb_frontend *fe, int onoff)
+static int dib80xx_tuner_sleep(struct dvb_frontend *fe, int onoff)
 {
        return dib8000_set_gpio(fe, 0, 0, onoff);
 }
@@ -1494,8 +1500,8 @@ static const struct dib0070_wbd_gain_cfg dib8070_wbd_gain_cfg[] = {
 static struct dib0070_config dib807x_dib0070_config[2] = {
        {
                .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
-               .reset = dib807x_tuner_reset,
-               .sleep = dib807x_tuner_sleep,
+               .reset = dib80xx_tuner_reset,
+               .sleep = dib80xx_tuner_sleep,
                .clock_khz = 12000,
                .clock_pad_drive = 4,
                .vga_filter = 1,
@@ -1508,8 +1514,8 @@ static struct dib0070_config dib807x_dib0070_config[2] = {
                .freq_offset_khz_vhf = -100,
        }, {
                .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
-               .reset = dib807x_tuner_reset,
-               .sleep = dib807x_tuner_sleep,
+               .reset = dib80xx_tuner_reset,
+               .sleep = dib80xx_tuner_sleep,
                .clock_khz = 12000,
                .clock_pad_drive = 2,
                .vga_filter = 1,
@@ -1566,12 +1572,14 @@ static int dib807x_tuner_attach(struct dvb_usb_adapter *adap)
        return 0;
 }
 
-static int stk807x_pid_filter(struct dvb_usb_adapter *adapter, int index, u16 pid, int onoff)
+static int stk80xx_pid_filter(struct dvb_usb_adapter *adapter, int index,
+       u16 pid, int onoff)
 {
     return dib8000_pid_filter(adapter->fe, index, pid, onoff);
 }
 
-static int stk807x_pid_filter_ctrl(struct dvb_usb_adapter *adapter, int onoff)
+static int stk80xx_pid_filter_ctrl(struct dvb_usb_adapter *adapter,
+       int onoff)
 {
     return dib8000_pid_filter_ctrl(adapter->fe, onoff);
 }
@@ -1624,7 +1632,7 @@ static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
        dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
 
        /* initialize IC 0 */
-       dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x80);
+       dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x80);
 
        adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80,
                              &dib807x_dib8000_config[0]);
@@ -1635,7 +1643,7 @@ static int stk807xpvr_frontend_attach0(struct dvb_usb_adapter *adap)
 static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
 {
        /* initialize IC 1 */
-       dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x22, 0x82);
+       dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 0x12, 0x82);
 
        adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x82,
                              &dib807x_dib8000_config[1]);
@@ -1643,6 +1651,245 @@ static int stk807xpvr_frontend_attach1(struct dvb_usb_adapter *adap)
        return adap->fe == NULL ? -ENODEV : 0;
 }
 
+/* STK8096GP */
+struct dibx000_agc_config dib8090_agc_config[2] = {
+    {
+       BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
+       /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
+     * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
+     * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
+       (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
+       | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
+
+       787,
+       10,
+
+       0,
+       118,
+
+       0,
+       3530,
+       1,
+       5,
+
+       65535,
+       0,
+
+       65535,
+       0,
+
+       0,
+       32,
+       114,
+       143,
+       144,
+       114,
+       227,
+       116,
+       117,
+
+       28,
+       26,
+       31,
+       51,
+
+       0,
+    },
+    {
+       BAND_CBAND,
+       /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=1,
+     * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
+     * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0 */
+       (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) | (0 << 8)
+       | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
+
+       787,
+       10,
+
+       0,
+       118,
+
+       0,
+       3530,
+       1,
+       5,
+
+       0,
+       0,
+
+       65535,
+       0,
+
+       0,
+       32,
+       114,
+       143,
+       144,
+       114,
+       227,
+       116,
+       117,
+
+       28,
+       26,
+       31,
+       51,
+
+       0,
+    }
+};
+
+static struct dibx000_bandwidth_config dib8090_pll_config_12mhz = {
+    54000, 13500,
+    1, 18, 3, 1, 0,
+    0, 0, 1, 1, 2,
+    (3 << 14) | (1 << 12) | (599 << 0),
+    (0 << 25) | 0,
+    20199727,
+    12000000,
+};
+
+static int dib8090_get_adc_power(struct dvb_frontend *fe)
+{
+    return dib8000_get_adc_power(fe, 1);
+}
+
+static struct dib8000_config dib809x_dib8000_config = {
+    .output_mpeg2_in_188_bytes = 1,
+
+    .agc_config_count = 2,
+    .agc = dib8090_agc_config,
+    .agc_control = dib0090_dcc_freq,
+    .pll = &dib8090_pll_config_12mhz,
+    .tuner_is_baseband = 1,
+
+    .gpio_dir = DIB8000_GPIO_DEFAULT_DIRECTIONS,
+    .gpio_val = DIB8000_GPIO_DEFAULT_VALUES,
+    .gpio_pwm_pos = DIB8000_GPIO_DEFAULT_PWM_POS,
+
+    .hostbus_diversity = 1,
+    .div_cfg = 0x31,
+    .output_mode = OUTMODE_MPEG2_FIFO,
+    .drives = 0x2d98,
+    .diversity_delay = 144,
+    .refclksel = 3,
+};
+
+static struct dib0090_config dib809x_dib0090_config = {
+    .io.pll_bypass = 1,
+    .io.pll_range = 1,
+    .io.pll_prediv = 1,
+    .io.pll_loopdiv = 20,
+    .io.adc_clock_ratio = 8,
+    .io.pll_int_loop_filt = 0,
+    .io.clock_khz = 12000,
+    .reset = dib80xx_tuner_reset,
+    .sleep = dib80xx_tuner_sleep,
+    .clkouttobamse = 1,
+    .analog_output = 1,
+    .i2c_address = DEFAULT_DIB0090_I2C_ADDRESS,
+    .wbd_vhf_offset = 100,
+    .wbd_cband_offset = 450,
+    .use_pwm_agc = 1,
+    .clkoutdrive = 1,
+    .get_adc_power = dib8090_get_adc_power,
+       .freq_offset_khz_uhf = 0,
+       .freq_offset_khz_vhf = -143,
+};
+
+static int dib8096_set_param_override(struct dvb_frontend *fe,
+               struct dvb_frontend_parameters *fep)
+{
+    struct dvb_usb_adapter *adap = fe->dvb->priv;
+    struct dib0700_adapter_state *state = adap->priv;
+    u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
+    u16 offset;
+    int ret = 0;
+    enum frontend_tune_state tune_state = CT_SHUTDOWN;
+    u16 ltgain, rf_gain_limit;
+
+    ret = state->set_param_save(fe, fep);
+    if (ret < 0)
+       return ret;
+
+    switch (band) {
+    case BAND_VHF:
+           offset = 100;
+           break;
+    case BAND_UHF:
+           offset = 550;
+           break;
+    default:
+           offset = 0;
+           break;
+    }
+    offset += (dib0090_get_wbd_offset(fe) * 8 * 18 / 33 + 1) / 2;
+    dib8000_set_wbd_ref(fe, offset);
+
+
+    if (band == BAND_CBAND) {
+       deb_info("tuning in CBAND - soft-AGC startup\n");
+       /* TODO specific wbd target for dib0090 - needed for startup ? */
+       dib0090_set_tune_state(fe, CT_AGC_START);
+       do {
+               ret = dib0090_gain_control(fe);
+               msleep(ret);
+               tune_state = dib0090_get_tune_state(fe);
+               if (tune_state == CT_AGC_STEP_0)
+                       dib8000_set_gpio(fe, 6, 0, 1);
+               else if (tune_state == CT_AGC_STEP_1) {
+                       dib0090_get_current_gain(fe, NULL, NULL, &rf_gain_limit, &ltgain);
+                       if (rf_gain_limit == 0)
+                               dib8000_set_gpio(fe, 6, 0, 0);
+               }
+       } while (tune_state < CT_AGC_STOP);
+       dib0090_pwm_gain_reset(fe);
+       dib8000_pwm_agc_reset(fe);
+       dib8000_set_tune_state(fe, CT_DEMOD_START);
+    } else {
+       deb_info("not tuning in CBAND - standard AGC startup\n");
+       dib0090_pwm_gain_reset(fe);
+    }
+
+    return 0;
+}
+
+static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
+{
+    struct dib0700_adapter_state *st = adap->priv;
+    struct i2c_adapter *tun_i2c = dib8000_get_i2c_master(adap->fe, DIBX000_I2C_INTERFACE_TUNER, 1);
+
+    if (dvb_attach(dib0090_register, adap->fe, tun_i2c, &dib809x_dib0090_config) == NULL)
+       return -ENODEV;
+
+    st->set_param_save = adap->fe->ops.tuner_ops.set_params;
+    adap->fe->ops.tuner_ops.set_params = dib8096_set_param_override;
+    return 0;
+}
+
+static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
+{
+       dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
+       msleep(10);
+       dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
+       dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
+       dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1);
+
+       dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0);
+
+       dib0700_ctrl_clock(adap->dev, 72, 1);
+
+       msleep(10);
+       dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1);
+       msleep(10);
+       dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1);
+
+       dib8000_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, 0x80);
+
+       adap->fe = dvb_attach(dib8000_attach, &adap->dev->i2c_adap, 0x80, &dib809x_dib8000_config);
+
+       return adap->fe == NULL ?  -ENODEV : 0;
+}
 
 /* STK7070PD */
 static struct dib7000p_config stk7070pd_dib7000p_config[2] = {
@@ -1929,14 +2176,17 @@ struct usb_device_id dib0700_usb_id_table[] = {
        { USB_DEVICE(USB_VID_YUAN,      USB_PID_YUAN_STK7700D) },
 /* 55 */{ USB_DEVICE(USB_VID_YUAN,     USB_PID_YUAN_STK7700D_2) },
        { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV73A) },
-       { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV73ESE) },
-       { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV282E) },
+       { USB_DEVICE(USB_VID_PCTV,      USB_PID_PINNACLE_PCTV73ESE) },
+       { USB_DEVICE(USB_VID_PCTV,      USB_PID_PINNACLE_PCTV282E) },
        { USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK7770P) },
 /* 60 */{ USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS_2) },
        { USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK807XPVR) },
        { USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK807XP) },
        { USB_DEVICE(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD) },
        { USB_DEVICE(USB_VID_EVOLUTEPC, USB_PID_TVWAY_PLUS) },
+/* 65 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73ESE) },
+       { USB_DEVICE(USB_VID_PINNACLE,  USB_PID_PINNACLE_PCTV282E) },
+       { USB_DEVICE(USB_VID_DIBCOM,    USB_PID_DIBCOM_STK8096GP) },
        { 0 }           /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -2238,11 +2488,11 @@ struct dvb_usb_device_properties dib0700_devices[] = {
                                { NULL },
                        },
                        {   "Pinnacle PCTV 73e SE",
-                               { &dib0700_usb_id_table[57], NULL },
+                               { &dib0700_usb_id_table[57], &dib0700_usb_id_table[65], NULL },
                                { NULL },
                        },
                        {   "Pinnacle PCTV 282e",
-                               { &dib0700_usb_id_table[58], NULL },
+                               { &dib0700_usb_id_table[58], &dib0700_usb_id_table[66], NULL },
                                { NULL },
                        },
                },
@@ -2471,8 +2721,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
                        {
                                .caps  = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
                                .pid_filter_count = 32,
-                               .pid_filter = stk807x_pid_filter,
-                               .pid_filter_ctrl = stk807x_pid_filter_ctrl,
+                               .pid_filter = stk80xx_pid_filter,
+                               .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
                                .frontend_attach  = stk807x_frontend_attach,
                                .tuner_attach     = dib807x_tuner_attach,
 
@@ -2510,8 +2760,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
                        {
                                .caps  = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
                                .pid_filter_count = 32,
-                               .pid_filter = stk807x_pid_filter,
-                               .pid_filter_ctrl = stk807x_pid_filter_ctrl,
+                               .pid_filter = stk80xx_pid_filter,
+                               .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
                                .frontend_attach  = stk807xpvr_frontend_attach0,
                                .tuner_attach     = dib807x_tuner_attach,
 
@@ -2523,8 +2773,8 @@ struct dvb_usb_device_properties dib0700_devices[] = {
                        {
                                .caps  = DVB_USB_ADAP_HAS_PID_FILTER | DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
                                .pid_filter_count = 32,
-                               .pid_filter = stk807x_pid_filter,
-                               .pid_filter_ctrl = stk807x_pid_filter_ctrl,
+                               .pid_filter = stk80xx_pid_filter,
+                               .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
                                .frontend_attach  = stk807xpvr_frontend_attach1,
                                .tuner_attach     = dib807x_tuner_attach,
 
@@ -2543,6 +2793,37 @@ struct dvb_usb_device_properties dib0700_devices[] = {
                        },
                },
 
+               .rc_interval      = DEFAULT_RC_INTERVAL,
+               .rc_key_map       = dib0700_rc_keys,
+               .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
+               .rc_query         = dib0700_rc_query
+       }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+               .num_adapters = 1,
+               .adapter = {
+                       {
+                               .caps  = DVB_USB_ADAP_HAS_PID_FILTER |
+                                       DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
+                               .pid_filter_count = 32,
+                               .pid_filter = stk80xx_pid_filter,
+                               .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
+                               .frontend_attach  = stk809x_frontend_attach,
+                               .tuner_attach     = dib809x_tuner_attach,
+
+                               DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
+
+                               .size_of_priv =
+                                       sizeof(struct dib0700_adapter_state),
+                       },
+               },
+
+               .num_device_descs = 1,
+               .devices = {
+                       {   "DiBcom STK8096GP reference design",
+                               { &dib0700_usb_id_table[67], NULL },
+                               { NULL },
+                       },
+               },
+
                .rc_interval      = DEFAULT_RC_INTERVAL,
                .rc_key_map       = dib0700_rc_keys,
                .rc_key_map_size  = ARRAY_SIZE(dib0700_rc_keys),
index da34979b5337732d62084e3d3acb3eae041969e3..9143b5631e88b9e2bcbe3b02851fcf09b3055171 100644 (file)
@@ -142,8 +142,13 @@ static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num
                } else if ((msg[i].flags & I2C_M_RD) == 0) {
                        if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,NULL,0) < 0)
                                break;
-               } else
-                       break;
+               } else if (msg[i].addr != 0x50) {
+                       /* 0x50 is the address of the eeprom - we need to protect it
+                        * from dibusb's bad i2c implementation: reads without
+                        * writing the offset before are forbidden */
+                       if (dibusb_i2c_msg(d, msg[i].addr, NULL, 0, msg[i].buf, msg[i].len) < 0)
+                               break;
+               }
        }
 
        mutex_unlock(&d->i2c_mutex);
@@ -243,6 +248,12 @@ static struct dib3000mc_config mod3000p_dib3000p_config = {
 
 int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap)
 {
+       if (adap->dev->udev->descriptor.idVendor  == USB_VID_LITEON &&
+                       adap->dev->udev->descriptor.idProduct ==
+                       USB_PID_LITEON_DVB_T_WARM) {
+               msleep(1000);
+       }
+
        if ((adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap, DEFAULT_DIB3000P_I2C_ADDRESS,  &mod3000p_dib3000p_config)) != NULL ||
                (adap->fe = dvb_attach(dib3000mc_attach, &adap->dev->i2c_adap, DEFAULT_DIB3000MC_I2C_ADDRESS, &mod3000p_dib3000p_config)) != NULL) {
                if (adap->priv != NULL) {
index f1602d4ace6db599b4d31709302d2240582bf36c..bc3581d58cedb8be3afe98555d8d5e1544ea8406 100644 (file)
@@ -47,6 +47,7 @@
 #define USB_VID_MSI_2                          0x1462
 #define USB_VID_OPERA1                         0x695c
 #define USB_VID_PINNACLE                       0x2304
+#define USB_VID_PCTV                           0x2013
 #define USB_VID_PIXELVIEW                      0x1554
 #define USB_VID_TECHNOTREND                    0x0b48
 #define USB_VID_TERRATEC                       0x0ccd
 #define USB_PID_DIBCOM_STK7070PD                       0x1ebe
 #define USB_PID_DIBCOM_STK807XP                                0x1f90
 #define USB_PID_DIBCOM_STK807XPVR                      0x1f98
+#define USB_PID_DIBCOM_STK8096GP                        0x1fa0
 #define USB_PID_DIBCOM_ANCHOR_2135_COLD                        0x2131
 #define USB_PID_DIBCOM_STK7770P                                0x1e80
 #define USB_PID_DPOSH_M9206_COLD                       0x9206
 #define USB_PID_PINNACLE_PCTV801E_SE                   0x023b
 #define USB_PID_PINNACLE_PCTV73A                       0x0243
 #define USB_PID_PINNACLE_PCTV73ESE                     0x0245
+#define USB_PID_PINNACLE_PCTV74E                       0x0246
 #define USB_PID_PINNACLE_PCTV282E                      0x0248
 #define USB_PID_PIXELVIEW_SBTVD                                0x5010
 #define USB_PID_PCTV_200E                              0x020e
index 5bb9479d154ed8bffa673e0af51f4fa316293b77..64132c0cf80d1f0fdb2b9ab004502c2b4a97be5d 100644 (file)
 #include "tda1002x.h"
 #include "mt312.h"
 #include "zl10039.h"
+#include "ds3000.h"
+#include "stv0900.h"
+#include "stv6110.h"
+#include "stb6100.h"
+#include "stb6100_proc.h"
 
 #ifndef USB_PID_DW2102
 #define USB_PID_DW2102 0x2102
 #define USB_PID_CINERGY_S 0x0064
 #endif
 
+#ifndef USB_PID_TEVII_S630
+#define USB_PID_TEVII_S630 0xd630
+#endif
+
 #ifndef USB_PID_TEVII_S650
 #define USB_PID_TEVII_S650 0xd650
 #endif
 
-#ifndef USB_PID_TEVII_S630
-#define USB_PID_TEVII_S630 0xd630
+#ifndef USB_PID_TEVII_S660
+#define USB_PID_TEVII_S660 0xd660
+#endif
+
+#ifndef USB_PID_PROF_1100
+#define USB_PID_PROF_1100 0xb012
 #endif
 
 #define DW210X_READ_MSG 0
 #define DW2102_VOLTAGE_CTRL (0x1800)
 #define DW2102_RC_QUERY (0x1a00)
 
+#define        err_str "did not find the firmware file. (%s) " \
+               "Please see linux/Documentation/dvb/ for more details " \
+               "on firmware-problems."
+
 struct dvb_usb_rc_keys_table {
        struct dvb_usb_rc_key *rc_keys;
        int rc_keys_size;
@@ -71,6 +88,12 @@ static int ir_keymap;
 module_param_named(keymap, ir_keymap, int, 0644);
 MODULE_PARM_DESC(keymap, "set keymap 0=default 1=dvbworld 2=tevii 3=tbs  ...");
 
+/* demod probe */
+static int demod_probe = 1;
+module_param_named(demod, demod_probe, int, 0644);
+MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 "
+                       "4=stv0903+stb6100(or-able)).");
+
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
@@ -183,7 +206,7 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
        switch (num) {
        case 2:
                /* read si2109 register by number */
-               buf6[0] = 0xd0;
+               buf6[0] = msg[0].addr << 1;
                buf6[1] = msg[0].len;
                buf6[2] = msg[0].buf[0];
                ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
@@ -198,7 +221,7 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
                switch (msg[0].addr) {
                case 0x68:
                        /* write to si2109 register */
-                       buf6[0] = 0xd0;
+                       buf6[0] = msg[0].addr << 1;
                        buf6[1] = msg[0].len;
                        memcpy(buf6 + 2, msg[0].buf, msg[0].len);
                        ret = dw210x_op_rw(d->udev, 0xc2, 0, 0, buf6,
@@ -239,7 +262,7 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
                /* read */
                /* first write first register number */
                u8 ibuf[msg[1].len + 2], obuf[3];
-               obuf[0] = 0xd0;
+               obuf[0] = msg[0].addr << 1;
                obuf[1] = msg[0].len;
                obuf[2] = msg[0].buf[0];
                ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
@@ -256,7 +279,7 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
                case 0x68: {
                        /* write to register */
                        u8 obuf[msg[0].len + 2];
-                       obuf[0] = 0xd0;
+                       obuf[0] = msg[0].addr << 1;
                        obuf[1] = msg[0].len;
                        memcpy(obuf + 2, msg[0].buf, msg[0].len);
                        ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
@@ -266,7 +289,7 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
                case 0x61: {
                        /* write to tuner */
                        u8 obuf[msg[0].len + 2];
-                       obuf[0] = 0xc2;
+                       obuf[0] = msg[0].addr << 1;
                        obuf[1] = msg[0].len;
                        memcpy(obuf + 2, msg[0].buf, msg[0].len);
                        ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
@@ -301,78 +324,78 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
        int ret = 0;
-       int len, i;
+       int len, i, j;
 
        if (!d)
                return -ENODEV;
        if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
                return -EAGAIN;
 
-       switch (num) {
-       case 2: {
-               /* read */
-               /* first write first register number */
-               u8 ibuf[msg[1].len + 2], obuf[3];
-               obuf[0] = 0xaa;
-               obuf[1] = msg[0].len;
-               obuf[2] = msg[0].buf[0];
-               ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
-                               obuf, msg[0].len + 2, DW210X_WRITE_MSG);
-               /* second read registers */
-               ret = dw210x_op_rw(d->udev, 0xc3, 0xab , 0,
-                               ibuf, msg[1].len + 2, DW210X_READ_MSG);
-               memcpy(msg[1].buf, ibuf + 2, msg[1].len);
-
-               break;
-       }
-       case 1:
-               switch (msg[0].addr) {
-               case 0x55: {
-                       if (msg[0].buf[0] == 0xf7) {
-                               /* firmware */
-                               /* Write in small blocks */
-                               u8 obuf[19];
-                               obuf[0] = 0xaa;
-                               obuf[1] = 0x11;
-                               obuf[2] = 0xf7;
-                               len = msg[0].len - 1;
-                               i = 1;
-                               do {
-                                       memcpy(obuf + 3, msg[0].buf + i, (len > 16 ? 16 : len));
-                                       ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
-                                               obuf, (len > 16 ? 16 : len) + 3, DW210X_WRITE_MSG);
-                                       i += 16;
-                                       len -= 16;
-                               } while (len > 0);
-                       } else {
-                               /* write to register */
-                               u8 obuf[msg[0].len + 2];
-                               obuf[0] = 0xaa;
-                               obuf[1] = msg[0].len;
-                               memcpy(obuf + 2, msg[0].buf, msg[0].len);
-                               ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
-                                               obuf, msg[0].len + 2, DW210X_WRITE_MSG);
-                       }
-                       break;
-               }
+       for (j = 0; j < num; j++) {
+               switch (msg[j].addr) {
                case(DW2102_RC_QUERY): {
                        u8 ibuf[2];
                        ret  = dw210x_op_rw(d->udev, 0xb8, 0, 0,
                                        ibuf, 2, DW210X_READ_MSG);
-                       memcpy(msg[0].buf, ibuf , 2);
+                       memcpy(msg[j].buf, ibuf , 2);
                        break;
                }
                case(DW2102_VOLTAGE_CTRL): {
                        u8 obuf[2];
                        obuf[0] = 0x30;
-                       obuf[1] = msg[0].buf[0];
+                       obuf[1] = msg[j].buf[0];
                        ret = dw210x_op_rw(d->udev, 0xb2, 0, 0,
                                        obuf, 2, DW210X_WRITE_MSG);
                        break;
                }
+               /*case 0x55: cx24116
+               case 0x6a: stv0903
+               case 0x68: ds3000, stv0903
+               case 0x60: ts2020, stv6110, stb6100 */
+               default: {
+                       if (msg[j].flags == I2C_M_RD) {
+                               /* read registers */
+                               u8  ibuf[msg[j].len + 2];
+                               ret = dw210x_op_rw(d->udev, 0xc3,
+                                               (msg[j].addr << 1) + 1, 0,
+                                               ibuf, msg[j].len + 2,
+                                               DW210X_READ_MSG);
+                               memcpy(msg[j].buf, ibuf + 2, msg[j].len);
+                       mdelay(10);
+                       } else if (((msg[j].buf[0] == 0xb0) &&
+                                               (msg[j].addr == 0x68)) ||
+                                               ((msg[j].buf[0] == 0xf7) &&
+                                               (msg[j].addr == 0x55))) {
+                               /* write firmware */
+                               u8 obuf[19];
+                               obuf[0] = msg[j].addr << 1;
+                               obuf[1] = (msg[j].len > 15 ? 17 : msg[j].len);
+                               obuf[2] = msg[j].buf[0];
+                               len = msg[j].len - 1;
+                               i = 1;
+                               do {
+                                       memcpy(obuf + 3, msg[j].buf + i,
+                                                       (len > 16 ? 16 : len));
+                                       ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
+                                               obuf, (len > 16 ? 16 : len) + 3,
+                                               DW210X_WRITE_MSG);
+                                       i += 16;
+                                       len -= 16;
+                               } while (len > 0);
+                       } else {
+                               /* write registers */
+                               u8 obuf[msg[j].len + 2];
+                               obuf[0] = msg[j].addr << 1;
+                               obuf[1] = msg[j].len;
+                               memcpy(obuf + 2, msg[j].buf, msg[j].len);
+                               ret = dw210x_op_rw(d->udev, 0xc2, 0, 0,
+                                               obuf, msg[j].len + 2,
+                                               DW210X_WRITE_MSG);
+                       }
+                       break;
+               }
                }
 
-               break;
        }
 
        mutex_unlock(&d->i2c_mutex);
@@ -442,63 +465,85 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
        return num;
 }
 
-static int s630_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                                                int num)
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
        int ret = 0;
+       int len, i, j;
 
        if (!d)
                return -ENODEV;
        if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
                return -EAGAIN;
 
-       switch (num) {
-       case 2: { /* read */
-               u8 ibuf[msg[1].len], obuf[3];
-               obuf[0] = msg[1].len;
-               obuf[1] = (msg[0].addr << 1);
-               obuf[2] = msg[0].buf[0];
-
-               ret = dw210x_op_rw(d->udev, 0x90, 0, 0,
-                                       obuf, 3, DW210X_WRITE_MSG);
-               msleep(5);
-               ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
-                                       ibuf, msg[1].len, DW210X_READ_MSG);
-               memcpy(msg[1].buf, ibuf, msg[1].len);
-               break;
-       }
-       case 1:
-               switch (msg[0].addr) {
-               case 0x60:
-               case 0x0e: {
-                       /* write to zl10313, zl10039 register, */
-                       u8 obuf[msg[0].len + 2];
-                       obuf[0] = msg[0].len + 1;
-                       obuf[1] = (msg[0].addr << 1);
-                       memcpy(obuf + 2, msg[0].buf, msg[0].len);
-                       ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
-                                       obuf, msg[0].len + 2, DW210X_WRITE_MSG);
-                       break;
-               }
+       for (j = 0; j < num; j++) {
+               switch (msg[j].addr) {
                case (DW2102_RC_QUERY): {
                        u8 ibuf[4];
                        ret  = dw210x_op_rw(d->udev, 0xb8, 0, 0,
                                        ibuf, 4, DW210X_READ_MSG);
-                       msg[0].buf[0] = ibuf[3];
+                       memcpy(msg[j].buf, ibuf + 1, 2);
                        break;
                }
                case (DW2102_VOLTAGE_CTRL): {
                        u8 obuf[2];
-                       obuf[0] = 0x03;
-                       obuf[1] = msg[0].buf[0];
+                       obuf[0] = 3;
+                       obuf[1] = msg[j].buf[0];
                        ret = dw210x_op_rw(d->udev, 0x8a, 0, 0,
                                        obuf, 2, DW210X_WRITE_MSG);
                        break;
                }
+               /*case 0x55: cx24116
+               case 0x6a: stv0903
+               case 0x68: ds3000, stv0903
+               case 0x60: ts2020, stv6110, stb6100
+               case 0xa0: eeprom */
+               default: {
+                       if (msg[j].flags == I2C_M_RD) {
+                               /* read registers */
+                               u8 ibuf[msg[j].len];
+                               ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
+                                               ibuf, msg[j].len,
+                                               DW210X_READ_MSG);
+                               memcpy(msg[j].buf, ibuf, msg[j].len);
+                               break;
+                       } else if ((msg[j].buf[0] == 0xb0) &&
+                                               (msg[j].addr == 0x68)) {
+                               /* write firmware */
+                               u8 obuf[19];
+                               obuf[0] = (msg[j].len > 16 ?
+                                               18 : msg[j].len + 1);
+                               obuf[1] = msg[j].addr << 1;
+                               obuf[2] = msg[j].buf[0];
+                               len = msg[j].len - 1;
+                               i = 1;
+                               do {
+                                       memcpy(obuf + 3, msg[j].buf + i,
+                                                       (len > 16 ? 16 : len));
+                                       ret = dw210x_op_rw(d->udev, 0x80, 0, 0,
+                                               obuf, (len > 16 ? 16 : len) + 3,
+                                               DW210X_WRITE_MSG);
+                                       i += 16;
+                                       len -= 16;
+                               } while (len > 0);
+                       } else {
+                               /* write registers */
+                               u8 obuf[msg[j].len + 2];
+                               obuf[0] = msg[j].len + 1;
+                               obuf[1] = (msg[j].addr << 1);
+                               memcpy(obuf + 2, msg[j].buf, msg[j].len);
+                               ret = dw210x_op_rw(d->udev,
+                                               (num > 1 ? 0x90 : 0x80), 0, 0,
+                                               obuf, msg[j].len + 2,
+                                               DW210X_WRITE_MSG);
+                               break;
+                       }
+                       break;
+               }
                }
 
-               break;
+               msleep(3);
        }
 
        mutex_unlock(&d->i2c_mutex);
@@ -535,8 +580,8 @@ static struct i2c_algorithm dw3101_i2c_algo = {
        .functionality = dw210x_i2c_func,
 };
 
-static struct i2c_algorithm s630_i2c_algo = {
-       .master_xfer = s630_i2c_transfer,
+static struct i2c_algorithm s6x0_i2c_algo = {
+       .master_xfer = s6x0_i2c_transfer,
        .functionality = dw210x_i2c_func,
 };
 
@@ -564,25 +609,34 @@ static int dw210x_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
        return 0;
 };
 
-static int s630_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
+static int s6x0_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
 {
        int i, ret;
-       u8 buf[3], eeprom[256], eepromline[16];
+       u8 ibuf[] = { 0 }, obuf[] = { 0 };
+       u8 eeprom[256], eepromline[16];
+       struct i2c_msg msg[] = {
+               {
+                       .addr = 0xa0 >> 1,
+                       .flags = 0,
+                       .buf = obuf,
+                       .len = 1,
+               }, {
+                       .addr = 0xa0 >> 1,
+                       .flags = I2C_M_RD,
+                       .buf = ibuf,
+                       .len = 1,
+               }
+       };
 
        for (i = 0; i < 256; i++) {
-               buf[0] = 1;
-               buf[1] = 0xa0;
-               buf[2] = i;
-               ret = dw210x_op_rw(d->udev, 0x90, 0, 0,
-                                       buf, 3, DW210X_WRITE_MSG);
-               ret = dw210x_op_rw(d->udev, 0x91, 0, 0,
-                                       buf, 1, DW210X_READ_MSG);
-               if (ret < 0) {
+               obuf[0] = i;
+               ret = s6x0_i2c_transfer(&d->i2c_adap, msg, 2);
+               if (ret != 2) {
                        err("read eeprom failed.");
                        return -1;
                } else {
-                       eepromline[i % 16] = buf[0];
-                       eeprom[i] = buf[0];
+                       eepromline[i % 16] = ibuf[0];
+                       eeprom[i] = ibuf[0];
                }
 
                if ((i % 16) == 15) {
@@ -644,19 +698,104 @@ static struct mt312_config zl313_config = {
        .demod_address = 0x0e,
 };
 
+static struct ds3000_config dw2104_ds3000_config = {
+       .demod_address = 0x68,
+};
+
+static struct stv0900_config dw2104a_stv0900_config = {
+       .demod_address = 0x6a,
+       .demod_mode = 0,
+       .xtal = 27000000,
+       .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
+       .diseqc_mode = 2,/* 2/3 PWM */
+       .tun1_maddress = 0,/* 0x60 */
+       .tun1_adc = 0,/* 2 Vpp */
+       .path1_mode = 3,
+};
+
+static struct stb6100_config dw2104a_stb6100_config = {
+       .tuner_address = 0x60,
+       .refclock = 27000000,
+};
+
+static struct stv0900_config dw2104_stv0900_config = {
+       .demod_address = 0x68,
+       .demod_mode = 0,
+       .xtal = 8000000,
+       .clkmode = 3,
+       .diseqc_mode = 2,
+       .tun1_maddress = 0,
+       .tun1_adc = 1,/* 1 Vpp */
+       .path1_mode = 3,
+};
+
+static struct stv6110_config dw2104_stv6110_config = {
+       .i2c_address = 0x60,
+       .mclk = 16000000,
+       .clk_div = 1,
+};
+
 static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
 {
-       if ((d->fe = dvb_attach(cx24116_attach, &dw2104_config,
-                       &d->dev->i2c_adap)) != NULL) {
+       struct dvb_tuner_ops *tuner_ops = NULL;
+
+       if (demod_probe & 4) {
+               d->fe = dvb_attach(stv0900_attach, &dw2104a_stv0900_config,
+                               &d->dev->i2c_adap, 0);
+               if (d->fe != NULL) {
+                       if (dvb_attach(stb6100_attach, d->fe,
+                                       &dw2104a_stb6100_config,
+                                       &d->dev->i2c_adap)) {
+                               tuner_ops = &d->fe->ops.tuner_ops;
+                               tuner_ops->set_frequency = stb6100_set_freq;
+                               tuner_ops->get_frequency = stb6100_get_freq;
+                               tuner_ops->set_bandwidth = stb6100_set_bandw;
+                               tuner_ops->get_bandwidth = stb6100_get_bandw;
+                               d->fe->ops.set_voltage = dw210x_set_voltage;
+                               info("Attached STV0900+STB6100!\n");
+                               return 0;
+                       }
+               }
+       }
+
+       if (demod_probe & 2) {
+               d->fe = dvb_attach(stv0900_attach, &dw2104_stv0900_config,
+                               &d->dev->i2c_adap, 0);
+               if (d->fe != NULL) {
+                       if (dvb_attach(stv6110_attach, d->fe,
+                                       &dw2104_stv6110_config,
+                                       &d->dev->i2c_adap)) {
+                               d->fe->ops.set_voltage = dw210x_set_voltage;
+                               info("Attached STV0900+STV6110A!\n");
+                               return 0;
+                       }
+               }
+       }
+
+       if (demod_probe & 1) {
+               d->fe = dvb_attach(cx24116_attach, &dw2104_config,
+                               &d->dev->i2c_adap);
+               if (d->fe != NULL) {
+                       d->fe->ops.set_voltage = dw210x_set_voltage;
+                       info("Attached cx24116!\n");
+                       return 0;
+               }
+       }
+
+       d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
+                       &d->dev->i2c_adap);
+       if (d->fe != NULL) {
                d->fe->ops.set_voltage = dw210x_set_voltage;
-               info("Attached cx24116!\n");
+               info("Attached DS3000!\n");
                return 0;
        }
+
        return -EIO;
 }
 
 static struct dvb_usb_device_properties dw2102_properties;
 static struct dvb_usb_device_properties dw2104_properties;
+static struct dvb_usb_device_properties s6x0_properties;
 
 static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
 {
@@ -670,14 +809,17 @@ static int dw2102_frontend_attach(struct dvb_usb_adapter *d)
                        return 0;
                }
        }
+
        if (dw2102_properties.i2c_algo == &dw2102_earda_i2c_algo) {
-               /*dw2102_properties.adapter->tuner_attach = dw2102_tuner_attach;*/
                d->fe = dvb_attach(stv0288_attach, &earda_config,
                                        &d->dev->i2c_adap);
                if (d->fe != NULL) {
-                       d->fe->ops.set_voltage = dw210x_set_voltage;
-                       info("Attached stv0288!\n");
-                       return 0;
+                       if (dvb_attach(stb6000_attach, d->fe, 0x61,
+                                       &d->dev->i2c_adap)) {
+                               d->fe->ops.set_voltage = dw210x_set_voltage;
+                               info("Attached stv0288!\n");
+                               return 0;
+                       }
                }
        }
 
@@ -705,15 +847,38 @@ static int dw3101_frontend_attach(struct dvb_usb_adapter *d)
        return -EIO;
 }
 
-static int s630_frontend_attach(struct dvb_usb_adapter *d)
+static int s6x0_frontend_attach(struct dvb_usb_adapter *d)
 {
        d->fe = dvb_attach(mt312_attach, &zl313_config,
-                               &d->dev->i2c_adap);
+                       &d->dev->i2c_adap);
+       if (d->fe != NULL) {
+               if (dvb_attach(zl10039_attach, d->fe, 0x60,
+                               &d->dev->i2c_adap)) {
+                       d->fe->ops.set_voltage = dw210x_set_voltage;
+                       info("Attached zl100313+zl10039!\n");
+                       return 0;
+               }
+       }
+
+       d->fe = dvb_attach(stv0288_attach, &earda_config,
+                       &d->dev->i2c_adap);
+       if (d->fe != NULL) {
+               if (dvb_attach(stb6000_attach, d->fe, 0x61,
+                               &d->dev->i2c_adap)) {
+                       d->fe->ops.set_voltage = dw210x_set_voltage;
+                       info("Attached stv0288+stb6000!\n");
+                       return 0;
+               }
+       }
+
+       d->fe = dvb_attach(ds3000_attach, &dw2104_ds3000_config,
+                       &d->dev->i2c_adap);
        if (d->fe != NULL) {
                d->fe->ops.set_voltage = dw210x_set_voltage;
-               info("Attached zl10313!\n");
+               info("Attached ds3000+ds2020!\n");
                return 0;
        }
+
        return -EIO;
 }
 
@@ -724,14 +889,6 @@ static int dw2102_tuner_attach(struct dvb_usb_adapter *adap)
        return 0;
 }
 
-static int dw2102_earda_tuner_attach(struct dvb_usb_adapter *adap)
-{
-       dvb_attach(stb6000_attach, adap->fe, 0x61,
-               &adap->dev->i2c_adap);
-
-       return 0;
-}
-
 static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
 {
        dvb_attach(dvb_pll_attach, adap->fe, 0x60,
@@ -740,14 +897,6 @@ static int dw3101_tuner_attach(struct dvb_usb_adapter *adap)
        return 0;
 }
 
-static int s630_zl10039_tuner_attach(struct dvb_usb_adapter *adap)
-{
-       dvb_attach(zl10039_attach, adap->fe, 0x60,
-               &adap->dev->i2c_adap);
-
-       return 0;
-}
-
 static struct dvb_usb_rc_key dw210x_rc_keys[] = {
        { 0xf80a, KEY_Q },              /*power*/
        { 0xf80c, KEY_M },              /*mute*/
@@ -922,6 +1071,8 @@ static struct usb_device_id dw2102_table[] = {
        {USB_DEVICE(USB_VID_TERRATEC, USB_PID_CINERGY_S)},
        {USB_DEVICE(USB_VID_CYPRESS, USB_PID_DW3101)},
        {USB_DEVICE(0x9022, USB_PID_TEVII_S630)},
+       {USB_DEVICE(0x3011, USB_PID_PROF_1100)},
+       {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
        { }
 };
 
@@ -935,15 +1086,13 @@ static int dw2102_load_firmware(struct usb_device *dev,
        u8 reset;
        u8 reset16[] = {0, 0, 0, 0, 0, 0, 0};
        const struct firmware *fw;
-       const char *filename = "dvb-usb-dw2101.fw";
+       const char *fw_2101 = "dvb-usb-dw2101.fw";
 
        switch (dev->descriptor.idProduct) {
        case 0x2101:
-               ret = request_firmware(&fw, filename, &dev->dev);
+               ret = request_firmware(&fw, fw_2101, &dev->dev);
                if (ret != 0) {
-                       err("did not find the firmware file. (%s) "
-                       "Please see linux/Documentation/dvb/ for more details "
-                       "on firmware-problems.", filename);
+                       err(err_str, fw_2101);
                        return ret;
                }
                break;
@@ -983,6 +1132,11 @@ static int dw2102_load_firmware(struct usb_device *dev,
                }
                /* init registers */
                switch (dev->descriptor.idProduct) {
+               case USB_PID_PROF_1100:
+                       s6x0_properties.rc_key_map = tbs_rc_keys;
+                       s6x0_properties.rc_key_map_size =
+                                       ARRAY_SIZE(tbs_rc_keys);
+                       break;
                case USB_PID_TEVII_S650:
                        dw2104_properties.rc_key_map = tevii_rc_keys;
                        dw2104_properties.rc_key_map_size =
@@ -1021,7 +1175,6 @@ static int dw2102_load_firmware(struct usb_device *dev,
                                                DW210X_READ_MSG);
                                if (reset16[2] == 0x11) {
                                        dw2102_properties.i2c_algo = &dw2102_earda_i2c_algo;
-                                       dw2102_properties.adapter->tuner_attach = &dw2102_earda_tuner_attach;
                                        break;
                                }
                        }
@@ -1184,13 +1337,13 @@ static struct dvb_usb_device_properties dw3101_properties = {
        }
 };
 
-static struct dvb_usb_device_properties s630_properties = {
+static struct dvb_usb_device_properties s6x0_properties = {
        .caps = DVB_USB_IS_AN_I2C_ADAPTER,
        .usb_ctrl = DEVICE_SPECIFIC,
        .firmware = "dvb-usb-s630.fw",
        .no_reconnect = 1,
 
-       .i2c_algo = &s630_i2c_algo,
+       .i2c_algo = &s6x0_i2c_algo,
        .rc_key_map = tevii_rc_keys,
        .rc_key_map_size = ARRAY_SIZE(tevii_rc_keys),
        .rc_interval = 150,
@@ -1199,12 +1352,12 @@ static struct dvb_usb_device_properties s630_properties = {
        .generic_bulk_ctrl_endpoint = 0x81,
        .num_adapters = 1,
        .download_firmware = dw2102_load_firmware,
-       .read_mac_address = s630_read_mac_address,
+       .read_mac_address = s6x0_read_mac_address,
        .adapter = {
                {
-                       .frontend_attach = s630_frontend_attach,
+                       .frontend_attach = s6x0_frontend_attach,
                        .streaming_ctrl = NULL,
-                       .tuner_attach = s630_zl10039_tuner_attach,
+                       .tuner_attach = NULL,
                        .stream = {
                                .type = USB_BULK,
                                .count = 8,
@@ -1217,12 +1370,20 @@ static struct dvb_usb_device_properties s630_properties = {
                        },
                }
        },
-       .num_device_descs = 1,
+       .num_device_descs = 3,
        .devices = {
                {"TeVii S630 USB",
                        {&dw2102_table[6], NULL},
                        {NULL},
                },
+               {"Prof 1100 USB ",
+                       {&dw2102_table[7], NULL},
+                       {NULL},
+               },
+               {"TeVii S660 USB",
+                       {&dw2102_table[8], NULL},
+                       {NULL},
+               },
        }
 };
 
@@ -1235,10 +1396,10 @@ static int dw2102_probe(struct usb_interface *intf,
                        THIS_MODULE, NULL, adapter_nr) ||
            0 == dvb_usb_device_init(intf, &dw3101_properties,
                        THIS_MODULE, NULL, adapter_nr) ||
-           0 == dvb_usb_device_init(intf, &s630_properties,
-                       THIS_MODULE, NULL, adapter_nr)) {
+           0 == dvb_usb_device_init(intf, &s6x0_properties,
+                       THIS_MODULE, NULL, adapter_nr))
                return 0;
-       }
+
        return -ENODEV;
 }
 
@@ -1269,6 +1430,7 @@ module_exit(dw2102_module_exit);
 MODULE_AUTHOR("Igor M. Liplianin (c) liplianin@me.by");
 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104,"
                                " DVB-C 3101 USB2.0,"
-                               " TeVii S600, S630, S650 USB2.0 devices");
+                               " TeVii S600, S630, S650, S660 USB2.0,"
+                               " Prof 1100 USB2.0 devices");
 MODULE_VERSION("0.1");
 MODULE_LICENSE("GPL");
index 9cbbe42ca44be982ef46d8e6c1d6fe660edd77aa..ebb7b9fd115b3e1880afd34bbb7782883e681dff 100644 (file)
@@ -134,11 +134,13 @@ static int jdvbt90502_pll_set_freq(struct jdvbt90502_state *state, u32 freq)
        deb_fe("%s: freq=%d, step=%d\n", __func__, freq,
               state->frontend.ops.info.frequency_stepsize);
        /* freq -> oscilator frequency conversion. */
-       /* freq: 473,000,000 + n*6,000,000 (no 1/7MHz shift to center freq) */
-       /* add 400[1/7 MHZ] = 57.142857MHz.   57MHz for the IF,  */
-       /*                                   1/7MHz for center freq shift */
+       /* freq: 473,000,000 + n*6,000,000 [+ 142857 (center freq. shift)] */
        f = freq / state->frontend.ops.info.frequency_stepsize;
-       f += 400;
+       /* add 399[1/7 MHZ] = 57MHz for the IF  */
+       f += 399;
+       /* add center frequency shift if necessary */
+       if (f % 7 == 0)
+               f++;
        pll_freq_cmd[DEMOD_REDIRECT_REG] = JDVBT90502_2ND_I2C_REG; /* 0xFE */
        pll_freq_cmd[ADDRESS_BYTE] = state->config.pll_address << 1;
        pll_freq_cmd[DIVIDER_BYTE1] = (f >> 8) & 0x7F;
index 20eadf9318e08eca422c11f68ab96d4b2557a0c6..7a7f1b2b681ccaa38fbc9161aa8b0d726f14952b 100644 (file)
@@ -146,8 +146,8 @@ static int gp8psk_fe_set_frontend(struct dvb_frontend* fe,
 
        switch (c->delivery_system) {
        case SYS_DVBS:
-               /* Only QPSK is supported for DVB-S */
-               if (c->modulation != QPSK) {
+               /* Allow QPSK and 8PSK (even for DVB-S) */
+               if (c->modulation != QPSK && c->modulation != PSK_8) {
                        deb_fe("%s: unsupported modulation selected (%d)\n",
                                __func__, c->modulation);
                        return -EOPNOTSUPP;
index 58aac018f109003aaea23322ac22804d8b52020c..a3b8b697349b130f161daf1dc747d40c89ffcdb7 100644 (file)
@@ -526,6 +526,15 @@ config DVB_TUNER_DIB0070
          This device is only used inside a SiP called together with a
          demodulator for now.
 
+config DVB_TUNER_DIB0090
+       tristate "DiBcom DiB0090 silicon base-band tuner"
+       depends on I2C
+       default m if DVB_FE_CUSTOMISE
+       help
+         A driver for the silicon baseband tuner DiB0090 from DiBcom.
+         This device is only used inside a SiP called together with a
+         demodulator for now.
+
 comment "SEC control devices for DVB-S"
        depends on DVB_CORE
 
index 823482535d110000b2d9a9c61508b3e1da813ec6..47575cc7b699cea3a431b6d1c29093847402a5e8 100644 (file)
@@ -55,6 +55,7 @@ obj-$(CONFIG_DVB_TDA10086) += tda10086.o
 obj-$(CONFIG_DVB_TDA826X) += tda826x.o
 obj-$(CONFIG_DVB_TDA8261) += tda8261.o
 obj-$(CONFIG_DVB_TUNER_DIB0070) += dib0070.o
+obj-$(CONFIG_DVB_TUNER_DIB0090) += dib0090.o
 obj-$(CONFIG_DVB_TUA6100) += tua6100.o
 obj-$(CONFIG_DVB_S5H1409) += s5h1409.o
 obj-$(CONFIG_DVB_TUNER_ITD1000) += itd1000.o
index 2dc2723b724a15010009710758dfe3a12931865f..24268ef2753d7b33ed1069d7bfa9d81bf8d59cc7 100644 (file)
@@ -62,7 +62,7 @@ struct au8522_register_config {
    The values are as follows from left to right
    0="ATV RF" 1="ATV RF13" 2="CVBS" 3="S-Video" 4="PAL" 5=CVBS13" 6="SVideo13"
 */
-struct au8522_register_config filter_coef[] = {
+static const struct au8522_register_config filter_coef[] = {
        {AU8522_FILTER_COEF_R410, {0x25, 0x00, 0x25, 0x25, 0x00, 0x00, 0x00} },
        {AU8522_FILTER_COEF_R411, {0x20, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00} },
        {AU8522_FILTER_COEF_R412, {0x03, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00} },
@@ -104,7 +104,7 @@ struct au8522_register_config filter_coef[] = {
    0="SIF" 1="ATVRF/ATVRF13"
    Note: the "ATVRF/ATVRF13" mode has never been tested
 */
-struct au8522_register_config lpfilter_coef[] = {
+static const struct au8522_register_config lpfilter_coef[] = {
        {0x060b, {0x21, 0x0b} },
        {0x060c, {0xad, 0xad} },
        {0x060d, {0x70, 0xf0} },
index 2be17b93e0bd7dcf2419b263316971304f30072f..0d12763603b47d7bdcb2f4f008fb1eff875f97ae 100644 (file)
@@ -49,21 +49,6 @@ MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
 #define DIB0070_P1G  0x03
 #define DIB0070S_P1A 0x02
 
-enum frontend_tune_state {
-       CT_TUNER_START = 10,
-       CT_TUNER_STEP_0,
-       CT_TUNER_STEP_1,
-       CT_TUNER_STEP_2,
-       CT_TUNER_STEP_3,
-       CT_TUNER_STEP_4,
-       CT_TUNER_STEP_5,
-       CT_TUNER_STEP_6,
-       CT_TUNER_STEP_7,
-       CT_TUNER_STOP,
-};
-
-#define FE_CALLBACK_TIME_NEVER 0xffffffff
-
 struct dib0070_state {
        struct i2c_adapter *i2c;
        struct dvb_frontend *fe;
@@ -71,10 +56,10 @@ struct dib0070_state {
        u16 wbd_ff_offset;
        u8 revision;
 
-       enum frontend_tune_state tune_state;
-       u32 current_rf;
+    enum frontend_tune_state tune_state;
+    u32 current_rf;
 
-       /* for the captrim binary search */
+    /* for the captrim binary search */
        s8 step;
        u16 adc_diff;
 
@@ -85,7 +70,7 @@ struct dib0070_state {
        const struct dib0070_tuning *current_tune_table_index;
        const struct dib0070_lna_match *lna_match;
 
-       u8 wbd_gain_current;
+    u8  wbd_gain_current;
        u16 wbd_offset_3_3[2];
 };
 
@@ -93,8 +78,8 @@ static uint16_t dib0070_read_reg(struct dib0070_state *state, u8 reg)
 {
        u8 b[2];
        struct i2c_msg msg[2] = {
-               {.addr = state->cfg->i2c_address,.flags = 0,.buf = &reg,.len = 1},
-               {.addr = state->cfg->i2c_address,.flags = I2C_M_RD,.buf = b,.len = 2},
+               { .addr = state->cfg->i2c_address, .flags = 0,        .buf = &reg, .len = 1 },
+               { .addr = state->cfg->i2c_address, .flags = I2C_M_RD, .buf = b,  .len = 2 },
        };
        if (i2c_transfer(state->i2c, msg, 2) != 2) {
                printk(KERN_WARNING "DiB0070 I2C read failed\n");
@@ -106,7 +91,7 @@ static uint16_t dib0070_read_reg(struct dib0070_state *state, u8 reg)
 static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
 {
        u8 b[3] = { reg, val >> 8, val & 0xff };
-       struct i2c_msg msg = {.addr = state->cfg->i2c_address,.flags = 0,.buf = b,.len = 3 };
+       struct i2c_msg msg = { .addr = state->cfg->i2c_address, .flags = 0, .buf = b, .len = 3 };
        if (i2c_transfer(state->i2c, &msg, 1) != 1) {
                printk(KERN_WARNING "DiB0070 I2C write failed\n");
                return -EREMOTEIO;
@@ -124,30 +109,30 @@ static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
 
 static int dib0070_set_bandwidth(struct dvb_frontend *fe, struct dvb_frontend_parameters *ch)
 {
-       struct dib0070_state *state = fe->tuner_priv;
-       u16 tmp = dib0070_read_reg(state, 0x02) & 0x3fff;
-
-       if (state->fe->dtv_property_cache.bandwidth_hz / 1000 > 7000)
-               tmp |= (0 << 14);
-       else if (state->fe->dtv_property_cache.bandwidth_hz / 1000 > 6000)
-               tmp |= (1 << 14);
-       else if (state->fe->dtv_property_cache.bandwidth_hz / 1000 > 5000)
-               tmp |= (2 << 14);
-       else
-               tmp |= (3 << 14);
-
-       dib0070_write_reg(state, 0x02, tmp);
-
-       /* sharpen the BB filter in ISDB-T to have higher immunity to adjacent channels */
-       if (state->fe->dtv_property_cache.delivery_system == SYS_ISDBT) {
-               u16 value = dib0070_read_reg(state, 0x17);
-
-               dib0070_write_reg(state, 0x17, value & 0xfffc);
-               tmp = dib0070_read_reg(state, 0x01) & 0x01ff;
-               dib0070_write_reg(state, 0x01, tmp | (60 << 9));
-
-               dib0070_write_reg(state, 0x17, value);
-       }
+    struct dib0070_state *state = fe->tuner_priv;
+    u16 tmp = dib0070_read_reg(state, 0x02) & 0x3fff;
+
+    if (state->fe->dtv_property_cache.bandwidth_hz/1000 > 7000)
+       tmp |= (0 << 14);
+    else if (state->fe->dtv_property_cache.bandwidth_hz/1000 > 6000)
+       tmp |= (1 << 14);
+    else if (state->fe->dtv_property_cache.bandwidth_hz/1000 > 5000)
+       tmp |= (2 << 14);
+    else
+       tmp |= (3 << 14);
+
+    dib0070_write_reg(state, 0x02, tmp);
+
+    /* sharpen the BB filter in ISDB-T to have higher immunity to adjacent channels */
+    if (state->fe->dtv_property_cache.delivery_system == SYS_ISDBT) {
+       u16 value = dib0070_read_reg(state, 0x17);
+
+       dib0070_write_reg(state, 0x17, value & 0xfffc);
+       tmp = dib0070_read_reg(state, 0x01) & 0x01ff;
+       dib0070_write_reg(state, 0x01, tmp | (60 << 9));
+
+       dib0070_write_reg(state, 0x17, value);
+    }
        return 0;
 }
 
@@ -160,14 +145,14 @@ static int dib0070_captrim(struct dib0070_state *state, enum frontend_tune_state
        if (*tune_state == CT_TUNER_STEP_0) {
 
                dib0070_write_reg(state, 0x0f, 0xed10);
-               dib0070_write_reg(state, 0x17, 0x0034);
+               dib0070_write_reg(state, 0x17,    0x0034);
 
                dib0070_write_reg(state, 0x18, 0x0032);
                state->step = state->captrim = state->fcaptrim = 64;
                state->adc_diff = 3000;
                ret = 20;
 
-               *tune_state = CT_TUNER_STEP_1;
+       *tune_state = CT_TUNER_STEP_1;
        } else if (*tune_state == CT_TUNER_STEP_1) {
                state->step /= 2;
                dib0070_write_reg(state, 0x14, state->lo4 | state->captrim);
@@ -178,7 +163,7 @@ static int dib0070_captrim(struct dib0070_state *state, enum frontend_tune_state
 
                adc = dib0070_read_reg(state, 0x19);
 
-               dprintk("CAPTRIM=%hd; ADC = %hd (ADC) & %dmV", state->captrim, adc, (u32) adc * (u32) 1800 / (u32) 1024);
+               dprintk("CAPTRIM=%hd; ADC = %hd (ADC) & %dmV", state->captrim, adc, (u32) adc*(u32)1800/(u32)1024);
 
                if (adc >= 400) {
                        adc -= 400;
@@ -193,6 +178,8 @@ static int dib0070_captrim(struct dib0070_state *state, enum frontend_tune_state
                        state->adc_diff = adc;
                        state->fcaptrim = state->captrim;
 
+
+
                }
                state->captrim += (step_sign * state->step);
 
@@ -213,7 +200,7 @@ static int dib0070_captrim(struct dib0070_state *state, enum frontend_tune_state
 static int dib0070_set_ctrl_lo5(struct dvb_frontend *fe, u8 vco_bias_trim, u8 hf_div_trim, u8 cp_current, u8 third_order_filt)
 {
        struct dib0070_state *state = fe->tuner_priv;
-       u16 lo5 = (third_order_filt << 14) | (0 << 13) | (1 << 12) | (3 << 9) | (cp_current << 6) | (hf_div_trim << 3) | (vco_bias_trim << 0);
+    u16 lo5 = (third_order_filt << 14) | (0 << 13) | (1 << 12) | (3 << 9) | (cp_current << 6) | (hf_div_trim << 3) | (vco_bias_trim << 0);
        dprintk("CTRL_LO5: 0x%x", lo5);
        return dib0070_write_reg(state, 0x15, lo5);
 }
@@ -227,99 +214,99 @@ void dib0070_ctrl_agc_filter(struct dvb_frontend *fe, u8 open)
                dib0070_write_reg(state, 0x1a, 0x0000);
        } else {
                dib0070_write_reg(state, 0x1b, 0x4112);
-               if (state->cfg->vga_filter != 0) {
-                       dib0070_write_reg(state, 0x1a, state->cfg->vga_filter);
-                       dprintk("vga filter register is set to %x", state->cfg->vga_filter);
-               } else
-                       dib0070_write_reg(state, 0x1a, 0x0009);
+       if (state->cfg->vga_filter != 0) {
+               dib0070_write_reg(state, 0x1a, state->cfg->vga_filter);
+               dprintk("vga filter register is set to %x", state->cfg->vga_filter);
+       } else
+               dib0070_write_reg(state, 0x1a, 0x0009);
        }
 }
 
 EXPORT_SYMBOL(dib0070_ctrl_agc_filter);
 struct dib0070_tuning {
-       u32 max_freq;           /* for every frequency less than or equal to that field: this information is correct */
-       u8 switch_trim;
-       u8 vco_band;
-       u8 hfdiv;
-       u8 vco_multi;
-       u8 presc;
-       u8 wbdmux;
-       u16 tuner_enable;
+    u32 max_freq; /* for every frequency less than or equal to that field: this information is correct */
+    u8 switch_trim;
+    u8 vco_band;
+    u8 hfdiv;
+    u8 vco_multi;
+    u8 presc;
+    u8 wbdmux;
+    u16 tuner_enable;
 };
 
 struct dib0070_lna_match {
-       u32 max_freq;           /* for every frequency less than or equal to that field: this information is correct */
-       u8 lna_band;
+    u32 max_freq; /* for every frequency less than or equal to that field: this information is correct */
+    u8 lna_band;
 };
 
 static const struct dib0070_tuning dib0070s_tuning_table[] = {
-       {570000, 2, 1, 3, 6, 6, 2, 0x4000 | 0x0800},    /* UHF */
-       {700000, 2, 0, 2, 4, 2, 2, 0x4000 | 0x0800},
-       {863999, 2, 1, 2, 4, 2, 2, 0x4000 | 0x0800},
-       {1500000, 0, 1, 1, 2, 2, 4, 0x2000 | 0x0400},   /* LBAND */
-       {1600000, 0, 1, 1, 2, 2, 4, 0x2000 | 0x0400},
-       {2000000, 0, 1, 1, 2, 2, 4, 0x2000 | 0x0400},
-       {0xffffffff, 0, 0, 8, 1, 2, 1, 0x8000 | 0x1000},        /* SBAND */
+    {     570000, 2, 1, 3, 6, 6, 2, 0x4000 | 0x0800 }, /* UHF */
+    {     700000, 2, 0, 2, 4, 2, 2, 0x4000 | 0x0800 },
+    {     863999, 2, 1, 2, 4, 2, 2, 0x4000 | 0x0800 },
+    {    1500000, 0, 1, 1, 2, 2, 4, 0x2000 | 0x0400 }, /* LBAND */
+    {    1600000, 0, 1, 1, 2, 2, 4, 0x2000 | 0x0400 },
+    {    2000000, 0, 1, 1, 2, 2, 4, 0x2000 | 0x0400 },
+    { 0xffffffff, 0, 0, 8, 1, 2, 1, 0x8000 | 0x1000 }, /* SBAND */
 };
 
 static const struct dib0070_tuning dib0070_tuning_table[] = {
-       {115000, 1, 0, 7, 24, 2, 1, 0x8000 | 0x1000},   /* FM below 92MHz cannot be tuned */
-       {179500, 1, 0, 3, 16, 2, 1, 0x8000 | 0x1000},   /* VHF */
-       {189999, 1, 1, 3, 16, 2, 1, 0x8000 | 0x1000},
-       {250000, 1, 0, 6, 12, 2, 1, 0x8000 | 0x1000},
-       {569999, 2, 1, 5, 6, 2, 2, 0x4000 | 0x0800},    /* UHF */
-       {699999, 2, 0, 1, 4, 2, 2, 0x4000 | 0x0800},
-       {863999, 2, 1, 1, 4, 2, 2, 0x4000 | 0x0800},
-       {0xffffffff, 0, 1, 0, 2, 2, 4, 0x2000 | 0x0400},        /* LBAND or everything higher than UHF */
+    {     115000, 1, 0, 7, 24, 2, 1, 0x8000 | 0x1000 }, /* FM below 92MHz cannot be tuned */
+    {     179500, 1, 0, 3, 16, 2, 1, 0x8000 | 0x1000 }, /* VHF */
+    {     189999, 1, 1, 3, 16, 2, 1, 0x8000 | 0x1000 },
+    {     250000, 1, 0, 6, 12, 2, 1, 0x8000 | 0x1000 },
+    {     569999, 2, 1, 5,  6, 2, 2, 0x4000 | 0x0800 }, /* UHF */
+    {     699999, 2, 0, 1,  4, 2, 2, 0x4000 | 0x0800 },
+    {     863999, 2, 1, 1,  4, 2, 2, 0x4000 | 0x0800 },
+    { 0xffffffff, 0, 1, 0,  2, 2, 4, 0x2000 | 0x0400 }, /* LBAND or everything higher than UHF */
 };
 
 static const struct dib0070_lna_match dib0070_lna_flip_chip[] = {
-       {180000, 0},            /* VHF */
-       {188000, 1},
-       {196400, 2},
-       {250000, 3},
-       {550000, 0},            /* UHF */
-       {590000, 1},
-       {666000, 3},
-       {864000, 5},
-       {1500000, 0},           /* LBAND or everything higher than UHF */
-       {1600000, 1},
-       {2000000, 3},
-       {0xffffffff, 7},
+    {     180000, 0 }, /* VHF */
+    {     188000, 1 },
+    {     196400, 2 },
+    {     250000, 3 },
+    {     550000, 0 }, /* UHF */
+    {     590000, 1 },
+    {     666000, 3 },
+    {     864000, 5 },
+    {    1500000, 0 }, /* LBAND or everything higher than UHF */
+    {    1600000, 1 },
+    {    2000000, 3 },
+    { 0xffffffff, 7 },
 };
 
 static const struct dib0070_lna_match dib0070_lna[] = {
-       {180000, 0},            /* VHF */
-       {188000, 1},
-       {196400, 2},
-       {250000, 3},
-       {550000, 2},            /* UHF */
-       {650000, 3},
-       {750000, 5},
-       {850000, 6},
-       {864000, 7},
-       {1500000, 0},           /* LBAND or everything higher than UHF */
-       {1600000, 1},
-       {2000000, 3},
-       {0xffffffff, 7},
+    {     180000, 0 }, /* VHF */
+    {     188000, 1 },
+    {     196400, 2 },
+    {     250000, 3 },
+    {     550000, 2 }, /* UHF */
+    {     650000, 3 },
+    {     750000, 5 },
+    {     850000, 6 },
+    {     864000, 7 },
+    {    1500000, 0 }, /* LBAND or everything higher than UHF */
+    {    1600000, 1 },
+    {    2000000, 3 },
+    { 0xffffffff, 7 },
 };
 
-#define LPF    100             // define for the loop filter 100kHz by default 16-07-06
+#define LPF    100
 static int dib0070_tune_digital(struct dvb_frontend *fe, struct dvb_frontend_parameters *ch)
 {
-       struct dib0070_state *state = fe->tuner_priv;
+    struct dib0070_state *state = fe->tuner_priv;
 
-       const struct dib0070_tuning *tune;
-       const struct dib0070_lna_match *lna_match;
+    const struct dib0070_tuning *tune;
+    const struct dib0070_lna_match *lna_match;
 
-       enum frontend_tune_state *tune_state = &state->tune_state;
-       int ret = 10;           /* 1ms is the default delay most of the time */
+    enum frontend_tune_state *tune_state = &state->tune_state;
+    int ret = 10; /* 1ms is the default delay most of the time */
 
-       u8 band = (u8) BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
-       u32 freq = fe->dtv_property_cache.frequency / 1000 + (band == BAND_VHF ? state->cfg->freq_offset_khz_vhf : state->cfg->freq_offset_khz_uhf);
+    u8  band = (u8)BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency/1000);
+    u32 freq = fe->dtv_property_cache.frequency/1000 + (band == BAND_VHF ? state->cfg->freq_offset_khz_vhf : state->cfg->freq_offset_khz_uhf);
 
 #ifdef CONFIG_SYS_ISDBT
-       if (state->fe->dtv_property_cache.delivery_system == SYS_ISDBT && state->fe->dtv_property_cache.isdbt_sb_mode == 1)
+    if (state->fe->dtv_property_cache.delivery_system == SYS_ISDBT && state->fe->dtv_property_cache.isdbt_sb_mode == 1)
                if (((state->fe->dtv_property_cache.isdbt_sb_segment_count % 2)
                     && (state->fe->dtv_property_cache.isdbt_sb_segment_idx == ((state->fe->dtv_property_cache.isdbt_sb_segment_count / 2) + 1)))
                    || (((state->fe->dtv_property_cache.isdbt_sb_segment_count % 2) == 0)
@@ -328,172 +315,180 @@ static int dib0070_tune_digital(struct dvb_frontend *fe, struct dvb_frontend_par
                        && (state->fe->dtv_property_cache.isdbt_sb_segment_idx == ((state->fe->dtv_property_cache.isdbt_sb_segment_count / 2) + 1))))
                        freq += 850;
 #endif
+    if (state->current_rf != freq) {
+
+       switch (state->revision) {
+       case DIB0070S_P1A:
+           tune = dib0070s_tuning_table;
+           lna_match = dib0070_lna;
+           break;
+       default:
+           tune = dib0070_tuning_table;
+           if (state->cfg->flip_chip)
+               lna_match = dib0070_lna_flip_chip;
+           else
+               lna_match = dib0070_lna;
+           break;
+       }
+       while (freq > tune->max_freq) /* find the right one */
+           tune++;
+       while (freq > lna_match->max_freq) /* find the right one */
+           lna_match++;
+
+       state->current_tune_table_index = tune;
+       state->lna_match = lna_match;
+    }
+
+    if (*tune_state == CT_TUNER_START) {
+       dprintk("Tuning for Band: %hd (%d kHz)", band, freq);
        if (state->current_rf != freq) {
+               u8 REFDIV;
+               u32 FBDiv, Rest, FREF, VCOF_kHz;
+               u8 Den;
+
+               state->current_rf = freq;
+               state->lo4 = (state->current_tune_table_index->vco_band << 11) | (state->current_tune_table_index->hfdiv << 7);
+
+
+               dib0070_write_reg(state, 0x17, 0x30);
+
+
+               VCOF_kHz = state->current_tune_table_index->vco_multi * freq * 2;
+
+               switch (band) {
+               case BAND_VHF:
+                       REFDIV = (u8) ((state->cfg->clock_khz + 9999) / 10000);
+                       break;
+               case BAND_FM:
+                       REFDIV = (u8) ((state->cfg->clock_khz) / 1000);
+                       break;
+               default:
+                       REFDIV = (u8) (state->cfg->clock_khz  / 10000);
+                       break;
+               }
+               FREF = state->cfg->clock_khz / REFDIV;
+
+
 
                switch (state->revision) {
                case DIB0070S_P1A:
-                       tune = dib0070s_tuning_table;
-                       lna_match = dib0070_lna;
+                       FBDiv = (VCOF_kHz / state->current_tune_table_index->presc / FREF);
+                       Rest  = (VCOF_kHz / state->current_tune_table_index->presc) - FBDiv * FREF;
                        break;
+
+               case DIB0070_P1G:
+               case DIB0070_P1F:
                default:
-                       tune = dib0070_tuning_table;
-                       if (state->cfg->flip_chip)
-                               lna_match = dib0070_lna_flip_chip;
-                       else
-                               lna_match = dib0070_lna;
+                       FBDiv = (freq / (FREF / 2));
+                       Rest  = 2 * freq - FBDiv * FREF;
                        break;
                }
-               while (freq > tune->max_freq)   /* find the right one */
-                       tune++;
-               while (freq > lna_match->max_freq)      /* find the right one */
-                       lna_match++;
 
-               state->current_tune_table_index = tune;
-               state->lna_match = lna_match;
-       }
+               if (Rest < LPF)
+                       Rest = 0;
+               else if (Rest < 2 * LPF)
+                       Rest = 2 * LPF;
+               else if (Rest > (FREF - LPF)) {
+                       Rest = 0;
+                       FBDiv += 1;
+               } else if (Rest > (FREF - 2 * LPF))
+                       Rest = FREF - 2 * LPF;
+               Rest = (Rest * 6528) / (FREF / 10);
+
+               Den = 1;
+               if (Rest > 0) {
+                       state->lo4 |= (1 << 14) | (1 << 12);
+                       Den = 255;
+               }
+
 
-       if (*tune_state == CT_TUNER_START) {
-               dprintk("Tuning for Band: %hd (%d kHz)", band, freq);
-               if (state->current_rf != freq) {
-                       u8 REFDIV;
-                       u32 FBDiv, Rest, FREF, VCOF_kHz;
-                       u8 Den;
-
-                       state->current_rf = freq;
-                       state->lo4 = (state->current_tune_table_index->vco_band << 11) | (state->current_tune_table_index->hfdiv << 7);
-
-                       dib0070_write_reg(state, 0x17, 0x30);
-
-                       VCOF_kHz = state->current_tune_table_index->vco_multi * freq * 2;
-
-                       switch (band) {
-                       case BAND_VHF:
-                               REFDIV = (u8) ((state->cfg->clock_khz + 9999) / 10000);
-                               break;
-                       case BAND_FM:
-                               REFDIV = (u8) ((state->cfg->clock_khz) / 1000);
-                               break;
-                       default:
-                               REFDIV = (u8) (state->cfg->clock_khz / 10000);
-                               break;
-                       }
-                       FREF = state->cfg->clock_khz / REFDIV;
-
-                       switch (state->revision) {
-                       case DIB0070S_P1A:
-                               FBDiv = (VCOF_kHz / state->current_tune_table_index->presc / FREF);
-                               Rest = (VCOF_kHz / state->current_tune_table_index->presc) - FBDiv * FREF;
-                               break;
-
-                       case DIB0070_P1G:
-                       case DIB0070_P1F:
-                       default:
-                               FBDiv = (freq / (FREF / 2));
-                               Rest = 2 * freq - FBDiv * FREF;
-                               break;
-                       }
-
-                       if (Rest < LPF)
-                               Rest = 0;
-                       else if (Rest < 2 * LPF)
-                               Rest = 2 * LPF;
-                       else if (Rest > (FREF - LPF)) {
-                               Rest = 0;
-                               FBDiv += 1;
-                       } else if (Rest > (FREF - 2 * LPF))
-                               Rest = FREF - 2 * LPF;
-                       Rest = (Rest * 6528) / (FREF / 10);
-
-                       Den = 1;
-                       if (Rest > 0) {
-                               state->lo4 |= (1 << 14) | (1 << 12);
-                               Den = 255;
-                       }
-
-                       dib0070_write_reg(state, 0x11, (u16) FBDiv);
-                       dib0070_write_reg(state, 0x12, (Den << 8) | REFDIV);
-                       dib0070_write_reg(state, 0x13, (u16) Rest);
-
-                       if (state->revision == DIB0070S_P1A) {
-
-                               if (band == BAND_SBAND) {
-                                       dib0070_set_ctrl_lo5(fe, 2, 4, 3, 0);
-                                       dib0070_write_reg(state, 0x1d, 0xFFFF);
-                               } else
-                                       dib0070_set_ctrl_lo5(fe, 5, 4, 3, 1);
-                       }
-
-                       dib0070_write_reg(state, 0x20,
-                                         0x0040 | 0x0020 | 0x0010 | 0x0008 | 0x0002 | 0x0001 | state->current_tune_table_index->tuner_enable);
-
-                       dprintk("REFDIV: %hd, FREF: %d", REFDIV, FREF);
-                       dprintk("FBDIV: %d, Rest: %d", FBDiv, Rest);
-                       dprintk("Num: %hd, Den: %hd, SD: %hd", (u16) Rest, Den, (state->lo4 >> 12) & 0x1);
-                       dprintk("HFDIV code: %hd", state->current_tune_table_index->hfdiv);
-                       dprintk("VCO = %hd", state->current_tune_table_index->vco_band);
-                       dprintk("VCOF: ((%hd*%d) << 1))", state->current_tune_table_index->vco_multi, freq);
-
-                       *tune_state = CT_TUNER_STEP_0;
-               } else {        /* we are already tuned to this frequency - the configuration is correct  */
-                       ret = 50;       /* wakeup time */
-                       *tune_state = CT_TUNER_STEP_5;
+               dib0070_write_reg(state, 0x11, (u16)FBDiv);
+               dib0070_write_reg(state, 0x12, (Den << 8) | REFDIV);
+               dib0070_write_reg(state, 0x13, (u16) Rest);
+
+               if (state->revision == DIB0070S_P1A) {
+
+                       if (band == BAND_SBAND) {
+                               dib0070_set_ctrl_lo5(fe, 2, 4, 3, 0);
+                               dib0070_write_reg(state, 0x1d, 0xFFFF);
+                       } else
+                               dib0070_set_ctrl_lo5(fe, 5, 4, 3, 1);
                }
-       } else if ((*tune_state > CT_TUNER_START) && (*tune_state < CT_TUNER_STEP_4)) {
 
-               ret = dib0070_captrim(state, tune_state);
+               dib0070_write_reg(state, 0x20,
+                       0x0040 | 0x0020 | 0x0010 | 0x0008 | 0x0002 | 0x0001 | state->current_tune_table_index->tuner_enable);
 
-       } else if (*tune_state == CT_TUNER_STEP_4) {
-               const struct dib0070_wbd_gain_cfg *tmp = state->cfg->wbd_gain;
-               if (tmp != NULL) {
-                       while (freq / 1000 > tmp->freq) /* find the right one */
-                               tmp++;
-                       dib0070_write_reg(state, 0x0f,
-                                         (0 << 15) | (1 << 14) | (3 << 12) | (tmp->wbd_gain_val << 9) | (0 << 8) | (1 << 7) | (state->
-                                                                                                                               current_tune_table_index->
-                                                                                                                               wbdmux << 0));
-                       state->wbd_gain_current = tmp->wbd_gain_val;
-               } else {
+               dprintk("REFDIV: %hd, FREF: %d", REFDIV, FREF);
+               dprintk("FBDIV: %d, Rest: %d", FBDiv, Rest);
+               dprintk("Num: %hd, Den: %hd, SD: %hd", (u16) Rest, Den, (state->lo4 >> 12) & 0x1);
+               dprintk("HFDIV code: %hd", state->current_tune_table_index->hfdiv);
+               dprintk("VCO = %hd", state->current_tune_table_index->vco_band);
+               dprintk("VCOF: ((%hd*%d) << 1))", state->current_tune_table_index->vco_multi, freq);
+
+               *tune_state = CT_TUNER_STEP_0;
+       } else { /* we are already tuned to this frequency - the configuration is correct  */
+               ret = 50; /* wakeup time */
+               *tune_state = CT_TUNER_STEP_5;
+       }
+    } else if ((*tune_state > CT_TUNER_START) && (*tune_state < CT_TUNER_STEP_4)) {
+
+       ret = dib0070_captrim(state, tune_state);
+
+    } else if (*tune_state == CT_TUNER_STEP_4) {
+       const struct dib0070_wbd_gain_cfg *tmp = state->cfg->wbd_gain;
+       if (tmp != NULL) {
+               while (freq/1000 > tmp->freq) /* find the right one */
+                       tmp++;
+               dib0070_write_reg(state, 0x0f,
+                       (0 << 15) | (1 << 14) | (3 << 12)
+                       | (tmp->wbd_gain_val << 9) | (0 << 8) | (1 << 7)
+                       | (state->current_tune_table_index->wbdmux << 0));
+               state->wbd_gain_current = tmp->wbd_gain_val;
+       } else {
                        dib0070_write_reg(state, 0x0f,
                                          (0 << 15) | (1 << 14) | (3 << 12) | (6 << 9) | (0 << 8) | (1 << 7) | (state->current_tune_table_index->
                                                                                                                wbdmux << 0));
-                       state->wbd_gain_current = 6;
-               }
+           state->wbd_gain_current = 6;
+       }
 
-               dib0070_write_reg(state, 0x06, 0x3fff);
+       dib0070_write_reg(state, 0x06, 0x3fff);
                dib0070_write_reg(state, 0x07,
                                  (state->current_tune_table_index->switch_trim << 11) | (7 << 8) | (state->lna_match->lna_band << 3) | (3 << 0));
-               dib0070_write_reg(state, 0x08, (state->lna_match->lna_band << 10) | (3 << 7) | (127));
-               dib0070_write_reg(state, 0x0d, 0x0d80);
+       dib0070_write_reg(state, 0x08, (state->lna_match->lna_band << 10) | (3 << 7) | (127));
+       dib0070_write_reg(state, 0x0d, 0x0d80);
 
-               dib0070_write_reg(state, 0x18, 0x07ff);
-               dib0070_write_reg(state, 0x17, 0x0033);
 
-               *tune_state = CT_TUNER_STEP_5;
-       } else if (*tune_state == CT_TUNER_STEP_5) {
-               dib0070_set_bandwidth(fe, ch);
-               *tune_state = CT_TUNER_STOP;
-       } else {
-               ret = FE_CALLBACK_TIME_NEVER;   /* tuner finished, time to call again infinite */
-       }
-       return ret;
+       dib0070_write_reg(state, 0x18,   0x07ff);
+       dib0070_write_reg(state, 0x17, 0x0033);
+
+
+       *tune_state = CT_TUNER_STEP_5;
+    } else if (*tune_state == CT_TUNER_STEP_5) {
+       dib0070_set_bandwidth(fe, ch);
+       *tune_state = CT_TUNER_STOP;
+    } else {
+       ret = FE_CALLBACK_TIME_NEVER; /* tuner finished, time to call again infinite */
+    }
+    return ret;
 }
 
+
 static int dib0070_tune(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
 {
-       struct dib0070_state *state = fe->tuner_priv;
-       uint32_t ret;
+    struct dib0070_state *state = fe->tuner_priv;
+    uint32_t ret;
 
-       state->tune_state = CT_TUNER_START;
+    state->tune_state = CT_TUNER_START;
 
-       do {
-               ret = dib0070_tune_digital(fe, p);
-               if (ret != FE_CALLBACK_TIME_NEVER)
-                       msleep(ret / 10);
-               else
-                       break;
-       } while (state->tune_state != CT_TUNER_STOP);
+    do {
+       ret = dib0070_tune_digital(fe, p);
+       if (ret != FE_CALLBACK_TIME_NEVER)
+               msleep(ret/10);
+       else
+           break;
+    } while (state->tune_state != CT_TUNER_STOP);
 
-       return 0;
+    return 0;
 }
 
 static int dib0070_wakeup(struct dvb_frontend *fe)
@@ -512,92 +507,113 @@ static int dib0070_sleep(struct dvb_frontend *fe)
        return 0;
 }
 
-static const u16 dib0070_p1f_defaults[] = {
+u8 dib0070_get_rf_output(struct dvb_frontend *fe)
+{
+       struct dib0070_state *state = fe->tuner_priv;
+       return (dib0070_read_reg(state, 0x07) >> 11) & 0x3;
+}
+EXPORT_SYMBOL(dib0070_get_rf_output);
+
+int dib0070_set_rf_output(struct dvb_frontend *fe, u8 no)
+{
+       struct dib0070_state *state = fe->tuner_priv;
+       u16 rxrf2 = dib0070_read_reg(state, 0x07) & 0xfe7ff;
+       if (no > 3)
+               no = 3;
+       if (no < 1)
+               no = 1;
+       return dib0070_write_reg(state, 0x07, rxrf2 | (no << 11));
+}
+EXPORT_SYMBOL(dib0070_set_rf_output);
+
+static const u16 dib0070_p1f_defaults[] =
+
+{
        7, 0x02,
-       0x0008,
-       0x0000,
-       0x0000,
-       0x0000,
-       0x0000,
-       0x0002,
-       0x0100,
+               0x0008,
+               0x0000,
+               0x0000,
+               0x0000,
+               0x0000,
+               0x0002,
+               0x0100,
 
        3, 0x0d,
-       0x0d80,
-       0x0001,
-       0x0000,
+               0x0d80,
+               0x0001,
+               0x0000,
 
        4, 0x11,
-       0x0000,
-       0x0103,
-       0x0000,
-       0x0000,
+               0x0000,
+               0x0103,
+               0x0000,
+               0x0000,
 
        3, 0x16,
-       0x0004 | 0x0040,
-       0x0030,
-       0x07ff,
+               0x0004 | 0x0040,
+               0x0030,
+               0x07ff,
 
        6, 0x1b,
-       0x4112,
-       0xff00,
-       0xc07f,
-       0x0000,
-       0x0180,
-       0x4000 | 0x0800 | 0x0040 | 0x0020 | 0x0010 | 0x0008 | 0x0002 | 0x0001,
+               0x4112,
+               0xff00,
+               0xc07f,
+               0x0000,
+               0x0180,
+               0x4000 | 0x0800 | 0x0040 | 0x0020 | 0x0010 | 0x0008 | 0x0002 | 0x0001,
 
        0,
 };
 
 static u16 dib0070_read_wbd_offset(struct dib0070_state *state, u8 gain)
 {
-       u16 tuner_en = dib0070_read_reg(state, 0x20);
-       u16 offset;
-
-       dib0070_write_reg(state, 0x18, 0x07ff);
-       dib0070_write_reg(state, 0x20, 0x0800 | 0x4000 | 0x0040 | 0x0020 | 0x0010 | 0x0008 | 0x0002 | 0x0001);
-       dib0070_write_reg(state, 0x0f, (1 << 14) | (2 << 12) | (gain << 9) | (1 << 8) | (1 << 7) | (0 << 0));
-       msleep(9);
-       offset = dib0070_read_reg(state, 0x19);
-       dib0070_write_reg(state, 0x20, tuner_en);
-       return offset;
+    u16 tuner_en = dib0070_read_reg(state, 0x20);
+    u16 offset;
+
+    dib0070_write_reg(state, 0x18, 0x07ff);
+    dib0070_write_reg(state, 0x20, 0x0800 | 0x4000 | 0x0040 | 0x0020 | 0x0010 | 0x0008 | 0x0002 | 0x0001);
+    dib0070_write_reg(state, 0x0f, (1 << 14) | (2 << 12) | (gain << 9) | (1 << 8) | (1 << 7) | (0 << 0));
+    msleep(9);
+    offset = dib0070_read_reg(state, 0x19);
+    dib0070_write_reg(state, 0x20, tuner_en);
+    return offset;
 }
 
 static void dib0070_wbd_offset_calibration(struct dib0070_state *state)
 {
-       u8 gain;
-       for (gain = 6; gain < 8; gain++) {
-               state->wbd_offset_3_3[gain - 6] = ((dib0070_read_wbd_offset(state, gain) * 8 * 18 / 33 + 1) / 2);
-               dprintk("Gain: %d, WBDOffset (3.3V) = %hd", gain, state->wbd_offset_3_3[gain - 6]);
-       }
+    u8 gain;
+    for (gain = 6; gain < 8; gain++) {
+       state->wbd_offset_3_3[gain - 6] = ((dib0070_read_wbd_offset(state, gain) * 8 * 18 / 33 + 1) / 2);
+       dprintk("Gain: %d, WBDOffset (3.3V) = %hd", gain, state->wbd_offset_3_3[gain-6]);
+    }
 }
 
 u16 dib0070_wbd_offset(struct dvb_frontend *fe)
 {
-       struct dib0070_state *state = fe->tuner_priv;
-       const struct dib0070_wbd_gain_cfg *tmp = state->cfg->wbd_gain;
-       u32 freq = fe->dtv_property_cache.frequency / 1000;
-
-       if (tmp != NULL) {
-               while (freq / 1000 > tmp->freq) /* find the right one */
-                       tmp++;
-               state->wbd_gain_current = tmp->wbd_gain_val;
+    struct dib0070_state *state = fe->tuner_priv;
+    const struct dib0070_wbd_gain_cfg *tmp = state->cfg->wbd_gain;
+    u32 freq = fe->dtv_property_cache.frequency/1000;
+
+    if (tmp != NULL) {
+       while (freq/1000 > tmp->freq) /* find the right one */
+           tmp++;
+       state->wbd_gain_current = tmp->wbd_gain_val;
        } else
-               state->wbd_gain_current = 6;
+       state->wbd_gain_current = 6;
 
-       return state->wbd_offset_3_3[state->wbd_gain_current - 6];
+    return state->wbd_offset_3_3[state->wbd_gain_current - 6];
 }
-
 EXPORT_SYMBOL(dib0070_wbd_offset);
 
 #define pgm_read_word(w) (*w)
 static int dib0070_reset(struct dvb_frontend *fe)
 {
-       struct dib0070_state *state = fe->tuner_priv;
+    struct dib0070_state *state = fe->tuner_priv;
        u16 l, r, *n;
 
        HARD_RESET(state);
 
+
 #ifndef FORCE_SBAND_TUNER
        if ((dib0070_read_reg(state, 0x22) >> 9) & 0x1)
                state->revision = (dib0070_read_reg(state, 0x1f) >> 8) & 0xff;
@@ -605,7 +621,7 @@ static int dib0070_reset(struct dvb_frontend *fe)
 #else
 #warning forcing SBAND
 #endif
-       state->revision = DIB0070S_P1A;
+               state->revision = DIB0070S_P1A;
 
        /* P1F or not */
        dprintk("Revision: %x", state->revision);
@@ -620,7 +636,7 @@ static int dib0070_reset(struct dvb_frontend *fe)
        while (l) {
                r = pgm_read_word(n++);
                do {
-                       dib0070_write_reg(state, (u8) r, pgm_read_word(n++));
+                       dib0070_write_reg(state, (u8)r, pgm_read_word(n++));
                        r++;
                } while (--l);
                l = pgm_read_word(n++);
@@ -633,6 +649,7 @@ static int dib0070_reset(struct dvb_frontend *fe)
        else
                r = 2;
 
+
        r |= state->cfg->osc_buffer_state << 3;
 
        dib0070_write_reg(state, 0x10, r);
@@ -643,16 +660,24 @@ static int dib0070_reset(struct dvb_frontend *fe)
                dib0070_write_reg(state, 0x02, r | (1 << 5));
        }
 
-       if (state->revision == DIB0070S_P1A)
-               dib0070_set_ctrl_lo5(fe, 2, 4, 3, 0);
-       else
+    if (state->revision == DIB0070S_P1A)
+       dib0070_set_ctrl_lo5(fe, 2, 4, 3, 0);
+    else
                dib0070_set_ctrl_lo5(fe, 5, 4, state->cfg->charge_pump, state->cfg->enable_third_order_filter);
 
        dib0070_write_reg(state, 0x01, (54 << 9) | 0xc8);
 
-       dib0070_wbd_offset_calibration(state);
+    dib0070_wbd_offset_calibration(state);
 
-       return 0;
+    return 0;
+}
+
+static int dib0070_get_frequency(struct dvb_frontend *fe, u32 *frequency)
+{
+    struct dib0070_state *state = fe->tuner_priv;
+
+    *frequency = 1000 * state->current_rf;
+    return 0;
 }
 
 static int dib0070_release(struct dvb_frontend *fe)
@@ -664,18 +689,18 @@ static int dib0070_release(struct dvb_frontend *fe)
 
 static const struct dvb_tuner_ops dib0070_ops = {
        .info = {
-                .name = "DiBcom DiB0070",
-                .frequency_min = 45000000,
-                .frequency_max = 860000000,
-                .frequency_step = 1000,
-                },
-       .release = dib0070_release,
-
-       .init = dib0070_wakeup,
-       .sleep = dib0070_sleep,
-       .set_params = dib0070_tune,
-
-//      .get_frequency = dib0070_get_frequency,
+               .name           = "DiBcom DiB0070",
+               .frequency_min  =  45000000,
+               .frequency_max  = 860000000,
+               .frequency_step =      1000,
+       },
+       .release       = dib0070_release,
+
+       .init          = dib0070_wakeup,
+       .sleep         = dib0070_sleep,
+       .set_params    = dib0070_tune,
+
+       .get_frequency = dib0070_get_frequency,
 //      .get_bandwidth = dib0070_get_bandwidth
 };
 
@@ -687,7 +712,7 @@ struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe, struct i2c_adapter
 
        state->cfg = cfg;
        state->i2c = i2c;
-       state->fe = fe;
+       state->fe  = fe;
        fe->tuner_priv = state;
 
        if (dib0070_reset(fe) != 0)
@@ -699,12 +724,11 @@ struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe, struct i2c_adapter
        fe->tuner_priv = state;
        return fe;
 
- free_mem:
+free_mem:
        kfree(state);
        fe->tuner_priv = NULL;
        return NULL;
 }
-
 EXPORT_SYMBOL(dib0070_attach);
 
 MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
index eec9e52ffa753d0454044ca2705697e53b0ca39f..45c31fae3967118c5f6a55ffe6718de54aee2b8a 100644 (file)
@@ -52,6 +52,8 @@ struct dib0070_config {
 extern struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dib0070_config *cfg);
 extern u16 dib0070_wbd_offset(struct dvb_frontend *);
 extern void dib0070_ctrl_agc_filter(struct dvb_frontend *, u8 open);
+extern u8 dib0070_get_rf_output(struct dvb_frontend *fe);
+extern int dib0070_set_rf_output(struct dvb_frontend *fe, u8 no);
 #else
 static inline struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dib0070_config *cfg)
 {
@@ -62,7 +64,7 @@ static inline struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe, struc
 static inline u16 dib0070_wbd_offset(struct dvb_frontend *fe)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
-       return -ENODEV;
+       return 0;
 }
 
 static inline void dib0070_ctrl_agc_filter(struct dvb_frontend *fe, u8 open)
diff --git a/drivers/media/dvb/frontends/dib0090.c b/drivers/media/dvb/frontends/dib0090.c
new file mode 100644 (file)
index 0000000..6145527
--- /dev/null
@@ -0,0 +1,1522 @@
+/*
+ * Linux-DVB Driver for DiBcom's DiB0090 base-band RF Tuner.
+ *
+ * Copyright (C) 2005-9 DiBcom (http://www.dibcom.fr/)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * This code is more or less generated from another driver, please
+ * excuse some codingstyle oddities.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/i2c.h>
+
+#include "dvb_frontend.h"
+
+#include "dib0090.h"
+#include "dibx000_common.h"
+
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
+
+#define dprintk(args...) do { \
+       if (debug) { \
+               printk(KERN_DEBUG "DiB0090: "); \
+               printk(args); \
+               printk("\n"); \
+       } \
+} while (0)
+
+#define CONFIG_SYS_ISDBT
+#define CONFIG_BAND_CBAND
+#define CONFIG_BAND_VHF
+#define CONFIG_BAND_UHF
+#define CONFIG_DIB0090_USE_PWM_AGC
+
+#define EN_LNA0      0x8000
+#define EN_LNA1      0x4000
+#define EN_LNA2      0x2000
+#define EN_LNA3      0x1000
+#define EN_MIX0      0x0800
+#define EN_MIX1      0x0400
+#define EN_MIX2      0x0200
+#define EN_MIX3      0x0100
+#define EN_IQADC     0x0040
+#define EN_PLL       0x0020
+#define EN_TX        0x0010
+#define EN_BB        0x0008
+#define EN_LO        0x0004
+#define EN_BIAS      0x0001
+
+#define EN_IQANA     0x0002
+#define EN_DIGCLK    0x0080    /* not in the 0x24 reg, only in 0x1b */
+#define EN_CRYSTAL   0x0002
+
+#define EN_UHF          0x22E9
+#define EN_VHF          0x44E9
+#define EN_LBD          0x11E9
+#define EN_SBD          0x44E9
+#define EN_CAB          0x88E9
+
+#define pgm_read_word(w) (*w)
+
+struct dc_calibration;
+
+struct dib0090_tuning {
+       u32 max_freq;           /* for every frequency less than or equal to that field: this information is correct */
+       u8 switch_trim;
+       u8 lna_tune;
+       u8 lna_bias;
+       u16 v2i;
+       u16 mix;
+       u16 load;
+       u16 tuner_enable;
+};
+
+struct dib0090_pll {
+       u32 max_freq;           /* for every frequency less than or equal to that field: this information is correct */
+       u8 vco_band;
+       u8 hfdiv_code;
+       u8 hfdiv;
+       u8 topresc;
+};
+
+struct dib0090_state {
+       struct i2c_adapter *i2c;
+       struct dvb_frontend *fe;
+       const struct dib0090_config *config;
+
+       u8 current_band;
+       u16 revision;
+       enum frontend_tune_state tune_state;
+       u32 current_rf;
+
+       u16 wbd_offset;
+       s16 wbd_target;         /* in dB */
+
+       s16 rf_gain_limit;      /* take-over-point: where to split between bb and rf gain */
+       s16 current_gain;       /* keeps the currently programmed gain */
+       u8 agc_step;            /* new binary search */
+
+       u16 gain[2];            /* for channel monitoring */
+
+       const u16 *rf_ramp;
+       const u16 *bb_ramp;
+
+       /* for the software AGC ramps */
+       u16 bb_1_def;
+       u16 rf_lt_def;
+       u16 gain_reg[4];
+
+       /* for the captrim/dc-offset search */
+       s8 step;
+       s16 adc_diff;
+       s16 min_adc_diff;
+
+       s8 captrim;
+       s8 fcaptrim;
+
+       const struct dc_calibration *dc;
+       u16 bb6, bb7;
+
+       const struct dib0090_tuning *current_tune_table_index;
+       const struct dib0090_pll *current_pll_table_index;
+
+       u8 tuner_is_tuned;
+       u8 agc_freeze;
+
+       u8 reset;
+};
+
+static u16 dib0090_read_reg(struct dib0090_state *state, u8 reg)
+{
+       u8 b[2];
+       struct i2c_msg msg[2] = {
+               {.addr = state->config->i2c_address, .flags = 0, .buf = &reg, .len = 1},
+               {.addr = state->config->i2c_address, .flags = I2C_M_RD, .buf = b, .len = 2},
+       };
+       if (i2c_transfer(state->i2c, msg, 2) != 2) {
+               printk(KERN_WARNING "DiB0090 I2C read failed\n");
+               return 0;
+       }
+       return (b[0] << 8) | b[1];
+}
+
+static int dib0090_write_reg(struct dib0090_state *state, u32 reg, u16 val)
+{
+       u8 b[3] = { reg & 0xff, val >> 8, val & 0xff };
+       struct i2c_msg msg = {.addr = state->config->i2c_address, .flags = 0, .buf = b, .len = 3 };
+       if (i2c_transfer(state->i2c, &msg, 1) != 1) {
+               printk(KERN_WARNING "DiB0090 I2C write failed\n");
+               return -EREMOTEIO;
+       }
+       return 0;
+}
+
+#define HARD_RESET(state) do {  if (cfg->reset) {  if (cfg->sleep) cfg->sleep(fe, 0); msleep(10);  cfg->reset(fe, 1); msleep(10);  cfg->reset(fe, 0); msleep(10);  }  } while (0)
+#define ADC_TARGET -220
+#define GAIN_ALPHA 5
+#define WBD_ALPHA 6
+#define LPF    100
+static void dib0090_write_regs(struct dib0090_state *state, u8 r, const u16 * b, u8 c)
+{
+       do {
+               dib0090_write_reg(state, r++, *b++);
+       } while (--c);
+}
+
+static u16 dib0090_identify(struct dvb_frontend *fe)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       u16 v;
+
+       v = dib0090_read_reg(state, 0x1a);
+
+#ifdef FIRMWARE_FIREFLY
+       /* pll is not locked locked */
+       if (!(v & 0x800))
+               dprintk("FE%d : Identification : pll is not yet locked", fe->id);
+#endif
+
+       /* without PLL lock info */
+       v &= 0x3ff;
+       dprintk("P/V: %04x:", v);
+
+       if ((v >> 8) & 0xf)
+               dprintk("FE%d : Product ID = 0x%x : KROSUS", fe->id, (v >> 8) & 0xf);
+       else
+               return 0xff;
+
+       v &= 0xff;
+       if (((v >> 5) & 0x7) == 0x1)
+               dprintk("FE%d : MP001 : 9090/8096", fe->id);
+       else if (((v >> 5) & 0x7) == 0x4)
+               dprintk("FE%d : MP005 : Single Sband", fe->id);
+       else if (((v >> 5) & 0x7) == 0x6)
+               dprintk("FE%d : MP008 : diversity VHF-UHF-LBAND", fe->id);
+       else if (((v >> 5) & 0x7) == 0x7)
+               dprintk("FE%d : MP009 : diversity 29098 CBAND-UHF-LBAND-SBAND", fe->id);
+       else
+               return 0xff;
+
+       /* revision only */
+       if ((v & 0x1f) == 0x3)
+               dprintk("FE%d : P1-D/E/F detected", fe->id);
+       else if ((v & 0x1f) == 0x1)
+               dprintk("FE%d : P1C detected", fe->id);
+       else if ((v & 0x1f) == 0x0) {
+#ifdef CONFIG_TUNER_DIB0090_P1B_SUPPORT
+               dprintk("FE%d : P1-A/B detected: using previous driver - support will be removed soon", fe->id);
+               dib0090_p1b_register(fe);
+#else
+               dprintk("FE%d : P1-A/B detected: driver is deactivated - not available", fe->id);
+               return 0xff;
+#endif
+       }
+
+       return v;
+}
+
+static void dib0090_reset_digital(struct dvb_frontend *fe, const struct dib0090_config *cfg)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+
+       HARD_RESET(state);
+
+       dib0090_write_reg(state, 0x24, EN_PLL);
+       dib0090_write_reg(state, 0x1b, EN_DIGCLK | EN_PLL | EN_CRYSTAL);        /* PLL, DIG_CLK and CRYSTAL remain */
+
+       /* adcClkOutRatio=8->7, release reset */
+       dib0090_write_reg(state, 0x20, ((cfg->io.adc_clock_ratio - 1) << 11) | (0 << 10) | (1 << 9) | (1 << 8) | (0 << 4) | 0);
+       if (cfg->clkoutdrive != 0)
+               dib0090_write_reg(state, 0x23,
+                                 (0 << 15) | ((!cfg->analog_output) << 14) | (1 << 10) | (1 << 9) | (0 << 8) | (cfg->clkoutdrive << 5) | (cfg->
+                                                                                                                                          clkouttobamse
+                                                                                                                                          << 4) | (0
+                                                                                                                                                   <<
+                                                                                                                                                   2)
+                                 | (0));
+       else
+               dib0090_write_reg(state, 0x23,
+                                 (0 << 15) | ((!cfg->analog_output) << 14) | (1 << 10) | (1 << 9) | (0 << 8) | (7 << 5) | (cfg->
+                                                                                                                           clkouttobamse << 4) | (0
+                                                                                                                                                  <<
+                                                                                                                                                  2)
+                                 | (0));
+
+       /* enable pll, de-activate reset, ratio: 2/1 = 60MHz */
+       dib0090_write_reg(state, 0x21,
+                         (cfg->io.pll_bypass << 15) | (1 << 13) | (cfg->io.pll_range << 12) | (cfg->io.pll_loopdiv << 6) | (cfg->io.pll_prediv));
+
+}
+
+static int dib0090_wakeup(struct dvb_frontend *fe)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       if (state->config->sleep)
+               state->config->sleep(fe, 0);
+       return 0;
+}
+
+static int dib0090_sleep(struct dvb_frontend *fe)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       if (state->config->sleep)
+               state->config->sleep(fe, 1);
+       return 0;
+}
+
+extern void dib0090_dcc_freq(struct dvb_frontend *fe, u8 fast)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       if (fast)
+               dib0090_write_reg(state, 0x04, 0);
+       else
+               dib0090_write_reg(state, 0x04, 1);
+}
+EXPORT_SYMBOL(dib0090_dcc_freq);
+
+static const u16 rf_ramp_pwm_cband[] = {
+       0,                      /* max RF gain in 10th of dB */
+       0,                      /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> 0x2b */
+       0,                      /* ramp_max = maximum X used on the ramp */
+       (0 << 10) | 0,          /* 0x2c, LNA 1 = 0dB */
+       (0 << 10) | 0,          /* 0x2d, LNA 1 */
+       (0 << 10) | 0,          /* 0x2e, LNA 2 = 0dB */
+       (0 << 10) | 0,          /* 0x2f, LNA 2 */
+       (0 << 10) | 0,          /* 0x30, LNA 3 = 0dB */
+       (0 << 10) | 0,          /* 0x31, LNA 3 */
+       (0 << 10) | 0,          /* GAIN_4_1, LNA 4 = 0dB */
+       (0 << 10) | 0,          /* GAIN_4_2, LNA 4 */
+};
+
+static const u16 rf_ramp_vhf[] = {
+       412,                    /* max RF gain in 10th of dB */
+       132, 307, 127,          /* LNA1,  13.2dB */
+       105, 412, 255,          /* LNA2,  10.5dB */
+       50, 50, 127,            /* LNA3,  5dB */
+       125, 175, 127,          /* LNA4,  12.5dB */
+       0, 0, 127,              /* CBAND, 0dB */
+};
+
+static const u16 rf_ramp_uhf[] = {
+       412,                    /* max RF gain in 10th of dB */
+       132, 307, 127,          /* LNA1  : total gain = 13.2dB, point on the ramp where this amp is full gain, value to write to get full gain */
+       105, 412, 255,          /* LNA2  : 10.5 dB */
+       50, 50, 127,            /* LNA3  :  5.0 dB */
+       125, 175, 127,          /* LNA4  : 12.5 dB */
+       0, 0, 127,              /* CBAND :  0.0 dB */
+};
+
+static const u16 rf_ramp_cband[] = {
+       332,                    /* max RF gain in 10th of dB */
+       132, 252, 127,          /* LNA1,  dB */
+       80, 332, 255,           /* LNA2,  dB */
+       0, 0, 127,              /* LNA3,  dB */
+       0, 0, 127,              /* LNA4,  dB */
+       120, 120, 127,          /* LT1 CBAND */
+};
+
+static const u16 rf_ramp_pwm_vhf[] = {
+       404,                    /* max RF gain in 10th of dB */
+       25,                     /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> 0x2b */
+       1011,                   /* ramp_max = maximum X used on the ramp */
+       (6 << 10) | 417,        /* 0x2c, LNA 1 = 13.2dB */
+       (0 << 10) | 756,        /* 0x2d, LNA 1 */
+       (16 << 10) | 756,       /* 0x2e, LNA 2 = 10.5dB */
+       (0 << 10) | 1011,       /* 0x2f, LNA 2 */
+       (16 << 10) | 290,       /* 0x30, LNA 3 = 5dB */
+       (0 << 10) | 417,        /* 0x31, LNA 3 */
+       (7 << 10) | 0,          /* GAIN_4_1, LNA 4 = 12.5dB */
+       (0 << 10) | 290,        /* GAIN_4_2, LNA 4 */
+};
+
+static const u16 rf_ramp_pwm_uhf[] = {
+       404,                    /* max RF gain in 10th of dB */
+       25,                     /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> 0x2b */
+       1011,                   /* ramp_max = maximum X used on the ramp */
+       (6 << 10) | 417,        /* 0x2c, LNA 1 = 13.2dB */
+       (0 << 10) | 756,        /* 0x2d, LNA 1 */
+       (16 << 10) | 756,       /* 0x2e, LNA 2 = 10.5dB */
+       (0 << 10) | 1011,       /* 0x2f, LNA 2 */
+       (16 << 10) | 0,         /* 0x30, LNA 3 = 5dB */
+       (0 << 10) | 127,        /* 0x31, LNA 3 */
+       (7 << 10) | 127,        /* GAIN_4_1, LNA 4 = 12.5dB */
+       (0 << 10) | 417,        /* GAIN_4_2, LNA 4 */
+};
+
+static const u16 bb_ramp_boost[] = {
+       550,                    /* max BB gain in 10th of dB */
+       260, 260, 26,           /* BB1, 26dB */
+       290, 550, 29,           /* BB2, 29dB */
+};
+
+static const u16 bb_ramp_pwm_normal[] = {
+       500,                    /* max RF gain in 10th of dB */
+       8,                      /* ramp_slope = 1dB of gain -> clock_ticks_per_db = clk_khz / ramp_slope -> 0x34 */
+       400,
+       (2 << 9) | 0,           /* 0x35 = 21dB */
+       (0 << 9) | 168,         /* 0x36 */
+       (2 << 9) | 168,         /* 0x37 = 29dB */
+       (0 << 9) | 400,         /* 0x38 */
+};
+
+struct slope {
+       int16_t range;
+       int16_t slope;
+};
+static u16 slopes_to_scale(const struct slope *slopes, u8 num, s16 val)
+{
+       u8 i;
+       u16 rest;
+       u16 ret = 0;
+       for (i = 0; i < num; i++) {
+               if (val > slopes[i].range)
+                       rest = slopes[i].range;
+               else
+                       rest = val;
+               ret += (rest * slopes[i].slope) / slopes[i].range;
+               val -= rest;
+       }
+       return ret;
+}
+
+static const struct slope dib0090_wbd_slopes[3] = {
+       {66, 120},              /* -64,-52: offset -   65 */
+       {600, 170},             /* -52,-35: 65     -  665 */
+       {170, 250},             /* -45,-10: 665    - 835 */
+};
+
+static s16 dib0090_wbd_to_db(struct dib0090_state *state, u16 wbd)
+{
+       wbd &= 0x3ff;
+       if (wbd < state->wbd_offset)
+               wbd = 0;
+       else
+               wbd -= state->wbd_offset;
+       /* -64dB is the floor */
+       return -640 + (s16) slopes_to_scale(dib0090_wbd_slopes, ARRAY_SIZE(dib0090_wbd_slopes), wbd);
+}
+
+static void dib0090_wbd_target(struct dib0090_state *state, u32 rf)
+{
+       u16 offset = 250;
+
+       /* TODO : DAB digital N+/-1 interferer perfs : offset = 10 */
+
+       if (state->current_band == BAND_VHF)
+               offset = 650;
+#ifndef FIRMWARE_FIREFLY
+       if (state->current_band == BAND_VHF)
+               offset = state->config->wbd_vhf_offset;
+       if (state->current_band == BAND_CBAND)
+               offset = state->config->wbd_cband_offset;
+#endif
+
+       state->wbd_target = dib0090_wbd_to_db(state, state->wbd_offset + offset);
+       dprintk("wbd-target: %d dB", (u32) state->wbd_target);
+}
+
+static const int gain_reg_addr[4] = {
+       0x08, 0x0a, 0x0f, 0x01
+};
+
+static void dib0090_gain_apply(struct dib0090_state *state, s16 gain_delta, s16 top_delta, u8 force)
+{
+       u16 rf, bb, ref;
+       u16 i, v, gain_reg[4] = { 0 }, gain;
+       const u16 *g;
+
+       if (top_delta < -511)
+               top_delta = -511;
+       if (top_delta > 511)
+               top_delta = 511;
+
+       if (force) {
+               top_delta *= (1 << WBD_ALPHA);
+               gain_delta *= (1 << GAIN_ALPHA);
+       }
+
+       if (top_delta >= ((s16) (state->rf_ramp[0] << WBD_ALPHA) - state->rf_gain_limit))       /* overflow */
+               state->rf_gain_limit = state->rf_ramp[0] << WBD_ALPHA;
+       else
+               state->rf_gain_limit += top_delta;
+
+       if (state->rf_gain_limit < 0)   /*underflow */
+               state->rf_gain_limit = 0;
+
+       /* use gain as a temporary variable and correct current_gain */
+       gain = ((state->rf_gain_limit >> WBD_ALPHA) + state->bb_ramp[0]) << GAIN_ALPHA;
+       if (gain_delta >= ((s16) gain - state->current_gain))   /* overflow */
+               state->current_gain = gain;
+       else
+               state->current_gain += gain_delta;
+       /* cannot be less than 0 (only if gain_delta is less than 0 we can have current_gain < 0) */
+       if (state->current_gain < 0)
+               state->current_gain = 0;
+
+       /* now split total gain to rf and bb gain */
+       gain = state->current_gain >> GAIN_ALPHA;
+
+       /* requested gain is bigger than rf gain limit - ACI/WBD adjustment */
+       if (gain > (state->rf_gain_limit >> WBD_ALPHA)) {
+               rf = state->rf_gain_limit >> WBD_ALPHA;
+               bb = gain - rf;
+               if (bb > state->bb_ramp[0])
+                       bb = state->bb_ramp[0];
+       } else {                /* high signal level -> all gains put on RF */
+               rf = gain;
+               bb = 0;
+       }
+
+       state->gain[0] = rf;
+       state->gain[1] = bb;
+
+       /* software ramp */
+       /* Start with RF gains */
+       g = state->rf_ramp + 1; /* point on RF LNA1 max gain */
+       ref = rf;
+       for (i = 0; i < 7; i++) {       /* Go over all amplifiers => 5RF amps + 2 BB amps = 7 amps */
+               if (g[0] == 0 || ref < (g[1] - g[0]))   /* if total gain of the current amp is null or this amp is not concerned because it starts to work from an higher gain value */
+                       v = 0;  /* force the gain to write for the current amp to be null */
+               else if (ref >= g[1])   /* Gain to set is higher than the high working point of this amp */
+                       v = g[2];       /* force this amp to be full gain */
+               else            /* compute the value to set to this amp because we are somewhere in his range */
+                       v = ((ref - (g[1] - g[0])) * g[2]) / g[0];
+
+               if (i == 0)     /* LNA 1 reg mapping */
+                       gain_reg[0] = v;
+               else if (i == 1)        /* LNA 2 reg mapping */
+                       gain_reg[0] |= v << 7;
+               else if (i == 2)        /* LNA 3 reg mapping */
+                       gain_reg[1] = v;
+               else if (i == 3)        /* LNA 4 reg mapping */
+                       gain_reg[1] |= v << 7;
+               else if (i == 4)        /* CBAND LNA reg mapping */
+                       gain_reg[2] = v | state->rf_lt_def;
+               else if (i == 5)        /* BB gain 1 reg mapping */
+                       gain_reg[3] = v << 3;
+               else if (i == 6)        /* BB gain 2 reg mapping */
+                       gain_reg[3] |= v << 8;
+
+               g += 3;         /* go to next gain bloc */
+
+               /* When RF is finished, start with BB */
+               if (i == 4) {
+                       g = state->bb_ramp + 1; /* point on BB gain 1 max gain */
+                       ref = bb;
+               }
+       }
+       gain_reg[3] |= state->bb_1_def;
+       gain_reg[3] |= ((bb % 10) * 100) / 125;
+
+#ifdef DEBUG_AGC
+       dprintk("GA CALC: DB: %3d(rf) + %3d(bb) = %3d gain_reg[0]=%04x gain_reg[1]=%04x gain_reg[2]=%04x gain_reg[0]=%04x", rf, bb, rf + bb,
+               gain_reg[0], gain_reg[1], gain_reg[2], gain_reg[3]);
+#endif
+
+       /* Write the amplifier regs */
+       for (i = 0; i < 4; i++) {
+               v = gain_reg[i];
+               if (force || state->gain_reg[i] != v) {
+                       state->gain_reg[i] = v;
+                       dib0090_write_reg(state, gain_reg_addr[i], v);
+               }
+       }
+}
+
+static void dib0090_set_boost(struct dib0090_state *state, int onoff)
+{
+       state->bb_1_def &= 0xdfff;
+       state->bb_1_def |= onoff << 13;
+}
+
+static void dib0090_set_rframp(struct dib0090_state *state, const u16 * cfg)
+{
+       state->rf_ramp = cfg;
+}
+
+static void dib0090_set_rframp_pwm(struct dib0090_state *state, const u16 * cfg)
+{
+       state->rf_ramp = cfg;
+
+       dib0090_write_reg(state, 0x2a, 0xffff);
+
+       dprintk("total RF gain: %ddB, step: %d", (u32) cfg[0], dib0090_read_reg(state, 0x2a));
+
+       dib0090_write_regs(state, 0x2c, cfg + 3, 6);
+       dib0090_write_regs(state, 0x3e, cfg + 9, 2);
+}
+
+static void dib0090_set_bbramp(struct dib0090_state *state, const u16 * cfg)
+{
+       state->bb_ramp = cfg;
+       dib0090_set_boost(state, cfg[0] > 500); /* we want the boost if the gain is higher that 50dB */
+}
+
+static void dib0090_set_bbramp_pwm(struct dib0090_state *state, const u16 * cfg)
+{
+       state->bb_ramp = cfg;
+
+       dib0090_set_boost(state, cfg[0] > 500); /* we want the boost if the gain is higher that 50dB */
+
+       dib0090_write_reg(state, 0x33, 0xffff);
+       dprintk("total BB gain: %ddB, step: %d", (u32) cfg[0], dib0090_read_reg(state, 0x33));
+       dib0090_write_regs(state, 0x35, cfg + 3, 4);
+}
+
+void dib0090_pwm_gain_reset(struct dvb_frontend *fe)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       /* reset the AGC */
+
+       if (state->config->use_pwm_agc) {
+#ifdef CONFIG_BAND_SBAND
+               if (state->current_band == BAND_SBAND) {
+                       dib0090_set_rframp_pwm(state, rf_ramp_pwm_sband);
+                       dib0090_set_bbramp_pwm(state, bb_ramp_pwm_boost);
+               } else
+#endif
+#ifdef CONFIG_BAND_CBAND
+               if (state->current_band == BAND_CBAND) {
+                       dib0090_set_rframp_pwm(state, rf_ramp_pwm_cband);
+                       dib0090_set_bbramp_pwm(state, bb_ramp_pwm_normal);
+               } else
+#endif
+#ifdef CONFIG_BAND_VHF
+               if (state->current_band == BAND_VHF) {
+                       dib0090_set_rframp_pwm(state, rf_ramp_pwm_vhf);
+                       dib0090_set_bbramp_pwm(state, bb_ramp_pwm_normal);
+               } else
+#endif
+               {
+                       dib0090_set_rframp_pwm(state, rf_ramp_pwm_uhf);
+                       dib0090_set_bbramp_pwm(state, bb_ramp_pwm_normal);
+               }
+
+               if (state->rf_ramp[0] != 0)
+                       dib0090_write_reg(state, 0x32, (3 << 11));
+               else
+                       dib0090_write_reg(state, 0x32, (0 << 11));
+
+               dib0090_write_reg(state, 0x39, (1 << 10));
+       }
+}
+EXPORT_SYMBOL(dib0090_pwm_gain_reset);
+
+int dib0090_gain_control(struct dvb_frontend *fe)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       enum frontend_tune_state *tune_state = &state->tune_state;
+       int ret = 10;
+
+       u16 wbd_val = 0;
+       u8 apply_gain_immediatly = 1;
+       s16 wbd_error = 0, adc_error = 0;
+
+       if (*tune_state == CT_AGC_START) {
+               state->agc_freeze = 0;
+               dib0090_write_reg(state, 0x04, 0x0);
+
+#ifdef CONFIG_BAND_SBAND
+               if (state->current_band == BAND_SBAND) {
+                       dib0090_set_rframp(state, rf_ramp_sband);
+                       dib0090_set_bbramp(state, bb_ramp_boost);
+               } else
+#endif
+#ifdef CONFIG_BAND_VHF
+               if (state->current_band == BAND_VHF) {
+                       dib0090_set_rframp(state, rf_ramp_vhf);
+                       dib0090_set_bbramp(state, bb_ramp_boost);
+               } else
+#endif
+#ifdef CONFIG_BAND_CBAND
+               if (state->current_band == BAND_CBAND) {
+                       dib0090_set_rframp(state, rf_ramp_cband);
+                       dib0090_set_bbramp(state, bb_ramp_boost);
+               } else
+#endif
+               {
+                       dib0090_set_rframp(state, rf_ramp_uhf);
+                       dib0090_set_bbramp(state, bb_ramp_boost);
+               }
+
+               dib0090_write_reg(state, 0x32, 0);
+               dib0090_write_reg(state, 0x39, 0);
+
+               dib0090_wbd_target(state, state->current_rf);
+
+               state->rf_gain_limit = state->rf_ramp[0] << WBD_ALPHA;
+               state->current_gain = ((state->rf_ramp[0] + state->bb_ramp[0]) / 2) << GAIN_ALPHA;
+
+               *tune_state = CT_AGC_STEP_0;
+       } else if (!state->agc_freeze) {
+               s16 wbd;
+
+               int adc;
+               wbd_val = dib0090_read_reg(state, 0x1d);
+
+               /* read and calc the wbd power */
+               wbd = dib0090_wbd_to_db(state, wbd_val);
+               wbd_error = state->wbd_target - wbd;
+
+               if (*tune_state == CT_AGC_STEP_0) {
+                       if (wbd_error < 0 && state->rf_gain_limit > 0) {
+#ifdef CONFIG_BAND_CBAND
+                               /* in case of CBAND tune reduce first the lt_gain2 before adjusting the RF gain */
+                               u8 ltg2 = (state->rf_lt_def >> 10) & 0x7;
+                               if (state->current_band == BAND_CBAND && ltg2) {
+                                       ltg2 >>= 1;
+                                       state->rf_lt_def &= ltg2 << 10; /* reduce in 3 steps from 7 to 0 */
+                               }
+#endif
+                       } else {
+                               state->agc_step = 0;
+                               *tune_state = CT_AGC_STEP_1;
+                       }
+               } else {
+                       /* calc the adc power */
+                       adc = state->config->get_adc_power(fe);
+                       adc = (adc * ((s32) 355774) + (((s32) 1) << 20)) >> 21; /* included in [0:-700] */
+
+                       adc_error = (s16) (((s32) ADC_TARGET) - adc);
+#ifdef CONFIG_STANDARD_DAB
+                       if (state->fe->dtv_property_cache.delivery_system == STANDARD_DAB)
+                               adc_error += 130;
+#endif
+#ifdef CONFIG_STANDARD_DVBT
+                       if (state->fe->dtv_property_cache.delivery_system == STANDARD_DVBT &&
+                           (state->fe->dtv_property_cache.modulation == QAM_64 || state->fe->dtv_property_cache.modulation == QAM_16))
+                               adc_error += 60;
+#endif
+#ifdef CONFIG_SYS_ISDBT
+                       if ((state->fe->dtv_property_cache.delivery_system == SYS_ISDBT) && (((state->fe->dtv_property_cache.layer[0].segment_count >
+                                                                                              0)
+                                                                                             &&
+                                                                                             ((state->fe->dtv_property_cache.layer[0].modulation ==
+                                                                                               QAM_64)
+                                                                                              || (state->fe->dtv_property_cache.layer[0].
+                                                                                                  modulation == QAM_16)))
+                                                                                            ||
+                                                                                            ((state->fe->dtv_property_cache.layer[1].segment_count >
+                                                                                              0)
+                                                                                             &&
+                                                                                             ((state->fe->dtv_property_cache.layer[1].modulation ==
+                                                                                               QAM_64)
+                                                                                              || (state->fe->dtv_property_cache.layer[1].
+                                                                                                  modulation == QAM_16)))
+                                                                                            ||
+                                                                                            ((state->fe->dtv_property_cache.layer[2].segment_count >
+                                                                                              0)
+                                                                                             &&
+                                                                                             ((state->fe->dtv_property_cache.layer[2].modulation ==
+                                                                                               QAM_64)
+                                                                                              || (state->fe->dtv_property_cache.layer[2].
+                                                                                                  modulation == QAM_16)))
+                           )
+                           )
+                               adc_error += 60;
+#endif
+
+                       if (*tune_state == CT_AGC_STEP_1) {     /* quickly go to the correct range of the ADC power */
+                               if (ABS(adc_error) < 50 || state->agc_step++ > 5) {
+
+#ifdef CONFIG_STANDARD_DAB
+                                       if (state->fe->dtv_property_cache.delivery_system == STANDARD_DAB) {
+                                               dib0090_write_reg(state, 0x02, (1 << 15) | (15 << 11) | (31 << 6) | (63));      /* cap value = 63 : narrow BB filter : Fc = 1.8MHz */
+                                               dib0090_write_reg(state, 0x04, 0x0);
+                                       } else
+#endif
+                                       {
+                                               dib0090_write_reg(state, 0x02, (1 << 15) | (3 << 11) | (6 << 6) | (32));
+                                               dib0090_write_reg(state, 0x04, 0x01);   /*0 = 1KHz ; 1 = 150Hz ; 2 = 50Hz ; 3 = 50KHz ; 4 = servo fast */
+                                       }
+
+                                       *tune_state = CT_AGC_STOP;
+                               }
+                       } else {
+                               /* everything higher than or equal to CT_AGC_STOP means tracking */
+                               ret = 100;      /* 10ms interval */
+                               apply_gain_immediatly = 0;
+                       }
+               }
+#ifdef DEBUG_AGC
+               dprintk
+                   ("FE: %d, tune state %d, ADC = %3ddB (ADC err %3d) WBD %3ddB (WBD err %3d, WBD val SADC: %4d), RFGainLimit (TOP): %3d, signal: %3ddBm",
+                    (u32) fe->id, (u32) *tune_state, (u32) adc, (u32) adc_error, (u32) wbd, (u32) wbd_error, (u32) wbd_val,
+                    (u32) state->rf_gain_limit >> WBD_ALPHA, (s32) 200 + adc - (state->current_gain >> GAIN_ALPHA));
+#endif
+       }
+
+       /* apply gain */
+       if (!state->agc_freeze)
+               dib0090_gain_apply(state, adc_error, wbd_error, apply_gain_immediatly);
+       return ret;
+}
+EXPORT_SYMBOL(dib0090_gain_control);
+
+void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u16 * bb, u16 * rf_gain_limit, u16 * rflt)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       if (rf)
+               *rf = state->gain[0];
+       if (bb)
+               *bb = state->gain[1];
+       if (rf_gain_limit)
+               *rf_gain_limit = state->rf_gain_limit;
+       if (rflt)
+               *rflt = (state->rf_lt_def >> 10) & 0x7;
+}
+EXPORT_SYMBOL(dib0090_get_current_gain);
+
+u16 dib0090_get_wbd_offset(struct dvb_frontend *tuner)
+{
+       struct dib0090_state *st = tuner->tuner_priv;
+       return st->wbd_offset;
+}
+EXPORT_SYMBOL(dib0090_get_wbd_offset);
+
+static const u16 dib0090_defaults[] = {
+
+       25, 0x01,
+       0x0000,
+       0x99a0,
+       0x6008,
+       0x0000,
+       0x8acb,
+       0x0000,
+       0x0405,
+       0x0000,
+       0x0000,
+       0x0000,
+       0xb802,
+       0x0300,
+       0x2d12,
+       0xbac0,
+       0x7c00,
+       0xdbb9,
+       0x0954,
+       0x0743,
+       0x8000,
+       0x0001,
+       0x0040,
+       0x0100,
+       0x0000,
+       0xe910,
+       0x149e,
+
+       1, 0x1c,
+       0xff2d,
+
+       1, 0x39,
+       0x0000,
+
+       1, 0x1b,
+       EN_IQADC | EN_BB | EN_BIAS | EN_DIGCLK | EN_PLL | EN_CRYSTAL,
+       2, 0x1e,
+       0x07FF,
+       0x0007,
+
+       1, 0x24,
+       EN_UHF | EN_CRYSTAL,
+
+       2, 0x3c,
+       0x3ff,
+       0x111,
+       0
+};
+
+static int dib0090_reset(struct dvb_frontend *fe)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       u16 l, r, *n;
+
+       dib0090_reset_digital(fe, state->config);
+       state->revision = dib0090_identify(fe);
+
+       /* Revision definition */
+       if (state->revision == 0xff)
+               return -EINVAL;
+#ifdef EFUSE
+       else if ((state->revision & 0x1f) >= 3) /* Update the efuse : Only available for KROSUS > P1C */
+               dib0090_set_EFUSE(state);
+#endif
+
+#ifdef CONFIG_TUNER_DIB0090_P1B_SUPPORT
+       if (!(state->revision & 0x1))   /* it is P1B - reset is already done */
+               return 0;
+#endif
+
+       /* Upload the default values */
+       n = (u16 *) dib0090_defaults;
+       l = pgm_read_word(n++);
+       while (l) {
+               r = pgm_read_word(n++);
+               do {
+                       /* DEBUG_TUNER */
+                       /* dprintk("%d, %d, %d", l, r, pgm_read_word(n)); */
+                       dib0090_write_reg(state, r, pgm_read_word(n++));
+                       r++;
+               } while (--l);
+               l = pgm_read_word(n++);
+       }
+
+       /* Congigure in function of the crystal */
+       if (state->config->io.clock_khz >= 24000)
+               l = 1;
+       else
+               l = 2;
+       dib0090_write_reg(state, 0x14, l);
+       dprintk("Pll lock : %d", (dib0090_read_reg(state, 0x1a) >> 11) & 0x1);
+
+       state->reset = 3;       /* enable iq-offset-calibration and wbd-calibration when tuning next time */
+
+       return 0;
+}
+
+#define steps(u) (((u) > 15) ? ((u)-16) : (u))
+#define INTERN_WAIT 10
+static int dib0090_get_offset(struct dib0090_state *state, enum frontend_tune_state *tune_state)
+{
+       int ret = INTERN_WAIT * 10;
+
+       switch (*tune_state) {
+       case CT_TUNER_STEP_2:
+               /* Turns to positive */
+               dib0090_write_reg(state, 0x1f, 0x7);
+               *tune_state = CT_TUNER_STEP_3;
+               break;
+
+       case CT_TUNER_STEP_3:
+               state->adc_diff = dib0090_read_reg(state, 0x1d);
+
+               /* Turns to negative */
+               dib0090_write_reg(state, 0x1f, 0x4);
+               *tune_state = CT_TUNER_STEP_4;
+               break;
+
+       case CT_TUNER_STEP_4:
+               state->adc_diff -= dib0090_read_reg(state, 0x1d);
+               *tune_state = CT_TUNER_STEP_5;
+               ret = 0;
+               break;
+
+       default:
+               break;
+       }
+
+       return ret;
+}
+
+struct dc_calibration {
+       uint8_t addr;
+       uint8_t offset;
+       uint8_t pga:1;
+       uint16_t bb1;
+       uint8_t i:1;
+};
+
+static const struct dc_calibration dc_table[] = {
+       /* Step1 BB gain1= 26 with boost 1, gain 2 = 0 */
+       {0x06, 5, 1, (1 << 13) | (0 << 8) | (26 << 3), 1},
+       {0x07, 11, 1, (1 << 13) | (0 << 8) | (26 << 3), 0},
+       /* Step 2 BB gain 1 = 26 with boost = 1 & gain 2 = 29 */
+       {0x06, 0, 0, (1 << 13) | (29 << 8) | (26 << 3), 1},
+       {0x06, 10, 0, (1 << 13) | (29 << 8) | (26 << 3), 0},
+       {0},
+};
+
+static void dib0090_set_trim(struct dib0090_state *state)
+{
+       u16 *val;
+
+       if (state->dc->addr == 0x07)
+               val = &state->bb7;
+       else
+               val = &state->bb6;
+
+       *val &= ~(0x1f << state->dc->offset);
+       *val |= state->step << state->dc->offset;
+
+       dib0090_write_reg(state, state->dc->addr, *val);
+}
+
+static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum frontend_tune_state *tune_state)
+{
+       int ret = 0;
+
+       switch (*tune_state) {
+
+       case CT_TUNER_START:
+               /* init */
+               dprintk("Internal DC calibration");
+
+               /* the LNA is off */
+               dib0090_write_reg(state, 0x24, 0x02ed);
+
+               /* force vcm2 = 0.8V */
+               state->bb6 = 0;
+               state->bb7 = 0x040d;
+
+               state->dc = dc_table;
+
+               *tune_state = CT_TUNER_STEP_0;
+
+               /* fall through */
+
+       case CT_TUNER_STEP_0:
+               dib0090_write_reg(state, 0x01, state->dc->bb1);
+               dib0090_write_reg(state, 0x07, state->bb7 | (state->dc->i << 7));
+
+               state->step = 0;
+
+               state->min_adc_diff = 1023;
+
+               *tune_state = CT_TUNER_STEP_1;
+               ret = 50;
+               break;
+
+       case CT_TUNER_STEP_1:
+               dib0090_set_trim(state);
+
+               *tune_state = CT_TUNER_STEP_2;
+               break;
+
+       case CT_TUNER_STEP_2:
+       case CT_TUNER_STEP_3:
+       case CT_TUNER_STEP_4:
+               ret = dib0090_get_offset(state, tune_state);
+               break;
+
+       case CT_TUNER_STEP_5:   /* found an offset */
+               dprintk("FE%d: IQC read=%d, current=%x", state->fe->id, (u32) state->adc_diff, state->step);
+
+               /* first turn for this frequency */
+               if (state->step == 0) {
+                       if (state->dc->pga && state->adc_diff < 0)
+                               state->step = 0x10;
+                       if (state->dc->pga == 0 && state->adc_diff > 0)
+                               state->step = 0x10;
+               }
+
+               state->adc_diff = ABS(state->adc_diff);
+
+               if (state->adc_diff < state->min_adc_diff && steps(state->step) < 15) { /* stop search when the delta to 0 is increasing */
+                       state->step++;
+                       state->min_adc_diff = state->adc_diff;
+                       *tune_state = CT_TUNER_STEP_1;
+               } else {
+
+                       /* the minimum was what we have seen in the step before */
+                       state->step--;
+                       dib0090_set_trim(state);
+
+                       dprintk("FE%d: BB Offset Cal, BBreg=%hd,Offset=%hd,Value Set=%hd", state->fe->id, state->dc->addr, state->adc_diff,
+                               state->step);
+
+                       state->dc++;
+                       if (state->dc->addr == 0)       /* done */
+                               *tune_state = CT_TUNER_STEP_6;
+                       else
+                               *tune_state = CT_TUNER_STEP_0;
+
+               }
+               break;
+
+       case CT_TUNER_STEP_6:
+               dib0090_write_reg(state, 0x07, state->bb7 & ~0x0008);
+               dib0090_write_reg(state, 0x1f, 0x7);
+               *tune_state = CT_TUNER_START;   /* reset done -> real tuning can now begin */
+               state->reset &= ~0x1;
+       default:
+               break;
+       }
+       return ret;
+}
+
+static int dib0090_wbd_calibration(struct dib0090_state *state, enum frontend_tune_state *tune_state)
+{
+       switch (*tune_state) {
+       case CT_TUNER_START:
+               /* WBD-mode=log, Bias=2, Gain=6, Testmode=1, en=1, WBDMUX=1 */
+               dib0090_write_reg(state, 0x10, 0xdb09 | (1 << 10));
+               dib0090_write_reg(state, 0x24, EN_UHF & 0x0fff);
+
+               *tune_state = CT_TUNER_STEP_0;
+               return 90;      /* wait for the WBDMUX to switch and for the ADC to sample */
+       case CT_TUNER_STEP_0:
+               state->wbd_offset = dib0090_read_reg(state, 0x1d);
+               dprintk("WBD calibration offset = %d", state->wbd_offset);
+
+               *tune_state = CT_TUNER_START;   /* reset done -> real tuning can now begin */
+               state->reset &= ~0x2;
+               break;
+       default:
+               break;
+       }
+       return 0;
+}
+
+static void dib0090_set_bandwidth(struct dib0090_state *state)
+{
+       u16 tmp;
+
+       if (state->fe->dtv_property_cache.bandwidth_hz / 1000 <= 5000)
+               tmp = (3 << 14);
+       else if (state->fe->dtv_property_cache.bandwidth_hz / 1000 <= 6000)
+               tmp = (2 << 14);
+       else if (state->fe->dtv_property_cache.bandwidth_hz / 1000 <= 7000)
+               tmp = (1 << 14);
+       else
+               tmp = (0 << 14);
+
+       state->bb_1_def &= 0x3fff;
+       state->bb_1_def |= tmp;
+
+       dib0090_write_reg(state, 0x01, state->bb_1_def);        /* be sure that we have the right bb-filter */
+}
+
+static const struct dib0090_pll dib0090_pll_table[] = {
+#ifdef CONFIG_BAND_CBAND
+       {56000, 0, 9, 48, 6},
+       {70000, 1, 9, 48, 6},
+       {87000, 0, 8, 32, 4},
+       {105000, 1, 8, 32, 4},
+       {115000, 0, 7, 24, 6},
+       {140000, 1, 7, 24, 6},
+       {170000, 0, 6, 16, 4},
+#endif
+#ifdef CONFIG_BAND_VHF
+       {200000, 1, 6, 16, 4},
+       {230000, 0, 5, 12, 6},
+       {280000, 1, 5, 12, 6},
+       {340000, 0, 4, 8, 4},
+       {380000, 1, 4, 8, 4},
+       {450000, 0, 3, 6, 6},
+#endif
+#ifdef CONFIG_BAND_UHF
+       {580000, 1, 3, 6, 6},
+       {700000, 0, 2, 4, 4},
+       {860000, 1, 2, 4, 4},
+#endif
+#ifdef CONFIG_BAND_LBAND
+       {1800000, 1, 0, 2, 4},
+#endif
+#ifdef CONFIG_BAND_SBAND
+       {2900000, 0, 14, 1, 4},
+#endif
+};
+
+static const struct dib0090_tuning dib0090_tuning_table_fm_vhf_on_cband[] = {
+
+#ifdef CONFIG_BAND_CBAND
+       {184000, 4, 1, 15, 0x280, 0x2912, 0xb94e, EN_CAB},
+       {227000, 4, 3, 15, 0x280, 0x2912, 0xb94e, EN_CAB},
+       {380000, 4, 7, 15, 0x280, 0x2912, 0xb94e, EN_CAB},
+#endif
+#ifdef CONFIG_BAND_UHF
+       {520000, 2, 0, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {550000, 2, 2, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {650000, 2, 3, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {750000, 2, 5, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {850000, 2, 6, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {900000, 2, 7, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+#endif
+#ifdef CONFIG_BAND_LBAND
+       {1500000, 4, 0, 20, 0x300, 0x1912, 0x82c9, EN_LBD},
+       {1600000, 4, 1, 20, 0x300, 0x1912, 0x82c9, EN_LBD},
+       {1800000, 4, 3, 20, 0x300, 0x1912, 0x82c9, EN_LBD},
+#endif
+#ifdef CONFIG_BAND_SBAND
+       {2300000, 1, 4, 20, 0x300, 0x2d2A, 0x82c7, EN_SBD},
+       {2900000, 1, 7, 20, 0x280, 0x2deb, 0x8347, EN_SBD},
+#endif
+};
+
+static const struct dib0090_tuning dib0090_tuning_table[] = {
+
+#ifdef CONFIG_BAND_CBAND
+       {170000, 4, 1, 15, 0x280, 0x2912, 0xb94e, EN_CAB},
+#endif
+#ifdef CONFIG_BAND_VHF
+       {184000, 1, 1, 15, 0x300, 0x4d12, 0xb94e, EN_VHF},
+       {227000, 1, 3, 15, 0x300, 0x4d12, 0xb94e, EN_VHF},
+       {380000, 1, 7, 15, 0x300, 0x4d12, 0xb94e, EN_VHF},
+#endif
+#ifdef CONFIG_BAND_UHF
+       {520000, 2, 0, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {550000, 2, 2, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {650000, 2, 3, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {750000, 2, 5, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {850000, 2, 6, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+       {900000, 2, 7, 15, 0x300, 0x1d12, 0xb9ce, EN_UHF},
+#endif
+#ifdef CONFIG_BAND_LBAND
+       {1500000, 4, 0, 20, 0x300, 0x1912, 0x82c9, EN_LBD},
+       {1600000, 4, 1, 20, 0x300, 0x1912, 0x82c9, EN_LBD},
+       {1800000, 4, 3, 20, 0x300, 0x1912, 0x82c9, EN_LBD},
+#endif
+#ifdef CONFIG_BAND_SBAND
+       {2300000, 1, 4, 20, 0x300, 0x2d2A, 0x82c7, EN_SBD},
+       {2900000, 1, 7, 20, 0x280, 0x2deb, 0x8347, EN_SBD},
+#endif
+};
+
+#define WBD     0x781          /* 1 1 1 1 0000 0 0 1 */
+static int dib0090_tune(struct dvb_frontend *fe)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       const struct dib0090_tuning *tune = state->current_tune_table_index;
+       const struct dib0090_pll *pll = state->current_pll_table_index;
+       enum frontend_tune_state *tune_state = &state->tune_state;
+
+       u32 rf;
+       u16 lo4 = 0xe900, lo5, lo6, Den;
+       u32 FBDiv, Rest, FREF, VCOF_kHz = 0;
+       u16 tmp, adc;
+       int8_t step_sign;
+       int ret = 10;           /* 1ms is the default delay most of the time */
+       u8 c, i;
+
+       state->current_band = (u8) BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000);
+       rf = fe->dtv_property_cache.frequency / 1000 + (state->current_band ==
+                                                       BAND_UHF ? state->config->freq_offset_khz_uhf : state->config->freq_offset_khz_vhf);
+       /* in any case we first need to do a reset if needed */
+       if (state->reset & 0x1)
+               return dib0090_dc_offset_calibration(state, tune_state);
+       else if (state->reset & 0x2)
+               return dib0090_wbd_calibration(state, tune_state);
+
+    /************************* VCO ***************************/
+       /* Default values for FG                                 */
+       /* from these are needed :                               */
+       /* Cp,HFdiv,VCOband,SD,Num,Den,FB and REFDiv             */
+
+#ifdef CONFIG_SYS_ISDBT
+       if (state->fe->dtv_property_cache.delivery_system == SYS_ISDBT && state->fe->dtv_property_cache.isdbt_sb_mode == 1)
+               rf += 850;
+#endif
+
+       if (state->current_rf != rf) {
+               state->tuner_is_tuned = 0;
+
+               tune = dib0090_tuning_table;
+
+               tmp = (state->revision >> 5) & 0x7;
+               if (tmp == 0x4 || tmp == 0x7) {
+                       /* CBAND tuner version for VHF */
+                       if (state->current_band == BAND_FM || state->current_band == BAND_VHF) {
+                               /* Force CBAND */
+                               state->current_band = BAND_CBAND;
+                               tune = dib0090_tuning_table_fm_vhf_on_cband;
+                       }
+               }
+
+               pll = dib0090_pll_table;
+               /* Look for the interval */
+               while (rf > tune->max_freq)
+                       tune++;
+               while (rf > pll->max_freq)
+                       pll++;
+               state->current_tune_table_index = tune;
+               state->current_pll_table_index = pll;
+       }
+
+       if (*tune_state == CT_TUNER_START) {
+
+               if (state->tuner_is_tuned == 0)
+                       state->current_rf = 0;
+
+               if (state->current_rf != rf) {
+
+                       dib0090_write_reg(state, 0x0b, 0xb800 | (tune->switch_trim));
+
+                       /* external loop filter, otherwise:
+                        * lo5 = (0 << 15) | (0 << 12) | (0 << 11) | (3 << 9) | (4 << 6) | (3 << 4) | 4;
+                        * lo6 = 0x0e34 */
+                       if (pll->vco_band)
+                               lo5 = 0x049e;
+                       else if (state->config->analog_output)
+                               lo5 = 0x041d;
+                       else
+                               lo5 = 0x041c;
+
+                       lo5 |= (pll->hfdiv_code << 11) | (pll->vco_band << 7);  /* bit 15 is the split to the slave, we do not do it here */
+
+                       if (!state->config->io.pll_int_loop_filt)
+                               lo6 = 0xff28;
+                       else
+                               lo6 = (state->config->io.pll_int_loop_filt << 3);
+
+                       VCOF_kHz = (pll->hfdiv * rf) * 2;
+
+                       FREF = state->config->io.clock_khz;
+
+                       FBDiv = (VCOF_kHz / pll->topresc / FREF);
+                       Rest = (VCOF_kHz / pll->topresc) - FBDiv * FREF;
+
+                       if (Rest < LPF)
+                               Rest = 0;
+                       else if (Rest < 2 * LPF)
+                               Rest = 2 * LPF;
+                       else if (Rest > (FREF - LPF)) {
+                               Rest = 0;
+                               FBDiv += 1;
+                       } else if (Rest > (FREF - 2 * LPF))
+                               Rest = FREF - 2 * LPF;
+                       Rest = (Rest * 6528) / (FREF / 10);
+
+                       Den = 1;
+
+                       dprintk(" *****  ******* Rest value = %d", Rest);
+
+                       if (Rest > 0) {
+                               if (state->config->analog_output)
+                                       lo6 |= (1 << 2) | 2;
+                               else
+                                       lo6 |= (1 << 2) | 1;
+                               Den = 255;
+                       }
+#ifdef CONFIG_BAND_SBAND
+                       if (state->current_band == BAND_SBAND)
+                               lo6 &= 0xfffb;
+#endif
+
+                       dib0090_write_reg(state, 0x15, (u16) FBDiv);
+
+                       dib0090_write_reg(state, 0x16, (Den << 8) | 1);
+
+                       dib0090_write_reg(state, 0x17, (u16) Rest);
+
+                       dib0090_write_reg(state, 0x19, lo5);
+
+                       dib0090_write_reg(state, 0x1c, lo6);
+
+                       lo6 = tune->tuner_enable;
+                       if (state->config->analog_output)
+                               lo6 = (lo6 & 0xff9f) | 0x2;
+
+                       dib0090_write_reg(state, 0x24, lo6 | EN_LO
+#ifdef CONFIG_DIB0090_USE_PWM_AGC
+                                         | state->config->use_pwm_agc * EN_CRYSTAL
+#endif
+                           );
+
+                       state->current_rf = rf;
+
+                       /* prepare a complete captrim */
+                       state->step = state->captrim = state->fcaptrim = 64;
+
+               } else {        /* we are already tuned to this frequency - the configuration is correct  */
+
+                       /* do a minimal captrim even if the frequency has not changed */
+                       state->step = 4;
+                       state->captrim = state->fcaptrim = dib0090_read_reg(state, 0x18) & 0x7f;
+               }
+               state->adc_diff = 3000;
+
+               dib0090_write_reg(state, 0x10, 0x2B1);
+
+               dib0090_write_reg(state, 0x1e, 0x0032);
+
+               ret = 20;
+               *tune_state = CT_TUNER_STEP_1;
+       } else if (*tune_state == CT_TUNER_STEP_0) {
+               /* nothing */
+       } else if (*tune_state == CT_TUNER_STEP_1) {
+               state->step /= 2;
+               dib0090_write_reg(state, 0x18, lo4 | state->captrim);
+               *tune_state = CT_TUNER_STEP_2;
+       } else if (*tune_state == CT_TUNER_STEP_2) {
+
+               adc = dib0090_read_reg(state, 0x1d);
+               dprintk("FE %d CAPTRIM=%d; ADC = %d (ADC) & %dmV", (u32) fe->id, (u32) state->captrim, (u32) adc,
+                       (u32) (adc) * (u32) 1800 / (u32) 1024);
+
+               if (adc >= 400) {
+                       adc -= 400;
+                       step_sign = -1;
+               } else {
+                       adc = 400 - adc;
+                       step_sign = 1;
+               }
+
+               if (adc < state->adc_diff) {
+                       dprintk("FE %d CAPTRIM=%d is closer to target (%d/%d)", (u32) fe->id, (u32) state->captrim, (u32) adc, (u32) state->adc_diff);
+                       state->adc_diff = adc;
+                       state->fcaptrim = state->captrim;
+
+               }
+
+               state->captrim += step_sign * state->step;
+               if (state->step >= 1)
+                       *tune_state = CT_TUNER_STEP_1;
+               else
+                       *tune_state = CT_TUNER_STEP_3;
+
+               ret = 15;
+       } else if (*tune_state == CT_TUNER_STEP_3) {
+               /*write the final cptrim config */
+               dib0090_write_reg(state, 0x18, lo4 | state->fcaptrim);
+
+#ifdef CONFIG_TUNER_DIB0090_CAPTRIM_MEMORY
+               state->memory[state->memory_index].cap = state->fcaptrim;
+#endif
+
+               *tune_state = CT_TUNER_STEP_4;
+       } else if (*tune_state == CT_TUNER_STEP_4) {
+               dib0090_write_reg(state, 0x1e, 0x07ff);
+
+               dprintk("FE %d Final Captrim: %d", (u32) fe->id, (u32) state->fcaptrim);
+               dprintk("FE %d HFDIV code: %d", (u32) fe->id, (u32) pll->hfdiv_code);
+               dprintk("FE %d VCO = %d", (u32) fe->id, (u32) pll->vco_band);
+               dprintk("FE %d VCOF in kHz: %d ((%d*%d) << 1))", (u32) fe->id, (u32) ((pll->hfdiv * rf) * 2), (u32) pll->hfdiv, (u32) rf);
+               dprintk("FE %d REFDIV: %d, FREF: %d", (u32) fe->id, (u32) 1, (u32) state->config->io.clock_khz);
+               dprintk("FE %d FBDIV: %d, Rest: %d", (u32) fe->id, (u32) dib0090_read_reg(state, 0x15), (u32) dib0090_read_reg(state, 0x17));
+               dprintk("FE %d Num: %d, Den: %d, SD: %d", (u32) fe->id, (u32) dib0090_read_reg(state, 0x17),
+                       (u32) (dib0090_read_reg(state, 0x16) >> 8), (u32) dib0090_read_reg(state, 0x1c) & 0x3);
+
+               c = 4;
+               i = 3;
+#if defined(CONFIG_BAND_LBAND) || defined(CONFIG_BAND_SBAND)
+               if ((state->current_band == BAND_LBAND) || (state->current_band == BAND_SBAND)) {
+                       c = 2;
+                       i = 2;
+               }
+#endif
+               dib0090_write_reg(state, 0x10, (c << 13) | (i << 11) | (WBD
+#ifdef CONFIG_DIB0090_USE_PWM_AGC
+                                                                       | (state->config->use_pwm_agc << 1)
+#endif
+                                 ));
+               dib0090_write_reg(state, 0x09, (tune->lna_tune << 5) | (tune->lna_bias << 0));
+               dib0090_write_reg(state, 0x0c, tune->v2i);
+               dib0090_write_reg(state, 0x0d, tune->mix);
+               dib0090_write_reg(state, 0x0e, tune->load);
+
+               *tune_state = CT_TUNER_STEP_5;
+       } else if (*tune_state == CT_TUNER_STEP_5) {
+
+               /* initialize the lt gain register */
+               state->rf_lt_def = 0x7c00;
+               dib0090_write_reg(state, 0x0f, state->rf_lt_def);
+
+               dib0090_set_bandwidth(state);
+               state->tuner_is_tuned = 1;
+               *tune_state = CT_TUNER_STOP;
+       } else
+               ret = FE_CALLBACK_TIME_NEVER;
+       return ret;
+}
+
+static int dib0090_release(struct dvb_frontend *fe)
+{
+       kfree(fe->tuner_priv);
+       fe->tuner_priv = NULL;
+       return 0;
+}
+
+enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+
+       return state->tune_state;
+}
+EXPORT_SYMBOL(dib0090_get_tune_state);
+
+int dib0090_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+
+       state->tune_state = tune_state;
+       return 0;
+}
+EXPORT_SYMBOL(dib0090_set_tune_state);
+
+static int dib0090_get_frequency(struct dvb_frontend *fe, u32 * frequency)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+
+       *frequency = 1000 * state->current_rf;
+       return 0;
+}
+
+static int dib0090_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
+{
+       struct dib0090_state *state = fe->tuner_priv;
+       uint32_t ret;
+
+       state->tune_state = CT_TUNER_START;
+
+       do {
+               ret = dib0090_tune(fe);
+               if (ret != FE_CALLBACK_TIME_NEVER)
+                       msleep(ret / 10);
+               else
+                       break;
+       } while (state->tune_state != CT_TUNER_STOP);
+
+       return 0;
+}
+
+static const struct dvb_tuner_ops dib0090_ops = {
+       .info = {
+                .name = "DiBcom DiB0090",
+                .frequency_min = 45000000,
+                .frequency_max = 860000000,
+                .frequency_step = 1000,
+                },
+       .release = dib0090_release,
+
+       .init = dib0090_wakeup,
+       .sleep = dib0090_sleep,
+       .set_params = dib0090_set_params,
+       .get_frequency = dib0090_get_frequency,
+};
+
+struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct dib0090_config *config)
+{
+       struct dib0090_state *st = kzalloc(sizeof(struct dib0090_state), GFP_KERNEL);
+       if (st == NULL)
+               return NULL;
+
+       st->config = config;
+       st->i2c = i2c;
+       st->fe = fe;
+       fe->tuner_priv = st;
+
+       if (dib0090_reset(fe) != 0)
+               goto free_mem;
+
+       printk(KERN_INFO "DiB0090: successfully identified\n");
+       memcpy(&fe->ops.tuner_ops, &dib0090_ops, sizeof(struct dvb_tuner_ops));
+
+       return fe;
+ free_mem:
+       kfree(st);
+       fe->tuner_priv = NULL;
+       return NULL;
+}
+EXPORT_SYMBOL(dib0090_register);
+
+MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
+MODULE_AUTHOR("Olivier Grenie <olivier.grenie@dibcom.fr>");
+MODULE_DESCRIPTION("Driver for the DiBcom 0090 base-band RF Tuner");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/dib0090.h b/drivers/media/dvb/frontends/dib0090.h
new file mode 100644 (file)
index 0000000..aa7711e
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Linux-DVB Driver for DiBcom's DiB0090 base-band RF Tuner.
+ *
+ * Copyright (C) 2005-7 DiBcom (http://www.dibcom.fr/)
+ *
+ * This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation, version 2.
+ */
+#ifndef DIB0090_H
+#define DIB0090_H
+
+struct dvb_frontend;
+struct i2c_adapter;
+
+#define DEFAULT_DIB0090_I2C_ADDRESS 0x60
+
+struct dib0090_io_config {
+       u32 clock_khz;
+
+       u8 pll_bypass:1;
+       u8 pll_range:1;
+       u8 pll_prediv:6;
+       u8 pll_loopdiv:6;
+
+       u8 adc_clock_ratio;     /* valid is 8, 7 ,6 */
+       u16 pll_int_loop_filt;
+};
+
+struct dib0090_config {
+       struct dib0090_io_config io;
+       int (*reset) (struct dvb_frontend *, int);
+       int (*sleep) (struct dvb_frontend *, int);
+
+       /*  offset in kHz */
+       int freq_offset_khz_uhf;
+       int freq_offset_khz_vhf;
+
+       int (*get_adc_power) (struct dvb_frontend *);
+
+       u8 clkouttobamse:1;     /* activate or deactivate clock output */
+       u8 analog_output;
+
+       u8 i2c_address;
+       /* add drives and other things if necessary */
+       u16 wbd_vhf_offset;
+       u16 wbd_cband_offset;
+       u8 use_pwm_agc;
+       u8 clkoutdrive;
+};
+
+#if defined(CONFIG_DVB_TUNER_DIB0090) || (defined(CONFIG_DVB_TUNER_DIB0090_MODULE) && defined(MODULE))
+extern struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, const struct dib0090_config *config);
+extern void dib0090_dcc_freq(struct dvb_frontend *fe, u8 fast);
+extern void dib0090_pwm_gain_reset(struct dvb_frontend *fe);
+extern u16 dib0090_get_wbd_offset(struct dvb_frontend *tuner);
+extern int dib0090_gain_control(struct dvb_frontend *fe);
+extern enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe);
+extern int dib0090_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state);
+extern void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u16 * bb, u16 * rf_gain_limit, u16 * rflt);
+#else
+static inline struct dvb_frontend *dib0090_register(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dib0090_config *config)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+       return NULL;
+}
+
+static inline void dib0090_dcc_freq(struct dvb_frontend *fe, u8 fast)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+}
+
+static inline void dib0090_pwm_gain_reset(struct dvb_frontend *fe)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+}
+
+static inline u16 dib0090_get_wbd_offset(struct dvb_frontend *tuner)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+       return 0;
+}
+
+static inline int dib0090_gain_control(struct dvb_frontend *fe)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+       return -ENODEV;
+}
+
+static inline enum frontend_tune_state dib0090_get_tune_state(struct dvb_frontend *fe)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+       return CT_DONE;
+}
+
+static inline int dib0090_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+       return -ENODEV;
+}
+
+static inline void dib0090_get_current_gain(struct dvb_frontend *fe, u16 * rf, u16 * bb, u16 * rf_gain_limit, u16 * rflt)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+}
+#endif
+
+#endif
index 898400d331a308da8965c6d0a983ae9b4417c6de..6f6fa29d9ea4310877301a520858fe354a13cd8a 100644 (file)
@@ -28,18 +28,6 @@ MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
 
 #define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiB8000: "); printk(args); printk("\n"); } } while (0)
 
-enum frontend_tune_state {
-       CT_AGC_START = 20,
-       CT_AGC_STEP_0,
-       CT_AGC_STEP_1,
-       CT_AGC_STEP_2,
-       CT_AGC_STEP_3,
-       CT_AGC_STEP_4,
-       CT_AGC_STOP,
-
-       CT_DEMOD_START = 30,
-};
-
 #define FE_STATUS_TUNE_FAILED 0
 
 struct i2c_device {
@@ -133,104 +121,104 @@ static int dib8000_write_word(struct dib8000_state *state, u16 reg, u16 val)
        return dib8000_i2c_write16(&state->i2c, reg, val);
 }
 
-const int16_t coeff_2k_sb_1seg_dqpsk[8] = {
+static const int16_t coeff_2k_sb_1seg_dqpsk[8] = {
        (769 << 5) | 0x0a, (745 << 5) | 0x03, (595 << 5) | 0x0d, (769 << 5) | 0x0a, (920 << 5) | 0x09, (784 << 5) | 0x02, (519 << 5) | 0x0c,
            (920 << 5) | 0x09
 };
 
-const int16_t coeff_2k_sb_1seg[8] = {
+static const int16_t coeff_2k_sb_1seg[8] = {
        (692 << 5) | 0x0b, (683 << 5) | 0x01, (519 << 5) | 0x09, (692 << 5) | 0x0b, 0 | 0x1f, 0 | 0x1f, 0 | 0x1f, 0 | 0x1f
 };
 
-const int16_t coeff_2k_sb_3seg_0dqpsk_1dqpsk[8] = {
+static const int16_t coeff_2k_sb_3seg_0dqpsk_1dqpsk[8] = {
        (832 << 5) | 0x10, (912 << 5) | 0x05, (900 << 5) | 0x12, (832 << 5) | 0x10, (-931 << 5) | 0x0f, (912 << 5) | 0x04, (807 << 5) | 0x11,
            (-931 << 5) | 0x0f
 };
 
-const int16_t coeff_2k_sb_3seg_0dqpsk[8] = {
+static const int16_t coeff_2k_sb_3seg_0dqpsk[8] = {
        (622 << 5) | 0x0c, (941 << 5) | 0x04, (796 << 5) | 0x10, (622 << 5) | 0x0c, (982 << 5) | 0x0c, (519 << 5) | 0x02, (572 << 5) | 0x0e,
            (982 << 5) | 0x0c
 };
 
-const int16_t coeff_2k_sb_3seg_1dqpsk[8] = {
+static const int16_t coeff_2k_sb_3seg_1dqpsk[8] = {
        (699 << 5) | 0x14, (607 << 5) | 0x04, (944 << 5) | 0x13, (699 << 5) | 0x14, (-720 << 5) | 0x0d, (640 << 5) | 0x03, (866 << 5) | 0x12,
            (-720 << 5) | 0x0d
 };
 
-const int16_t coeff_2k_sb_3seg[8] = {
+static const int16_t coeff_2k_sb_3seg[8] = {
        (664 << 5) | 0x0c, (925 << 5) | 0x03, (937 << 5) | 0x10, (664 << 5) | 0x0c, (-610 << 5) | 0x0a, (697 << 5) | 0x01, (836 << 5) | 0x0e,
            (-610 << 5) | 0x0a
 };
 
-const int16_t coeff_4k_sb_1seg_dqpsk[8] = {
+static const int16_t coeff_4k_sb_1seg_dqpsk[8] = {
        (-955 << 5) | 0x0e, (687 << 5) | 0x04, (818 << 5) | 0x10, (-955 << 5) | 0x0e, (-922 << 5) | 0x0d, (750 << 5) | 0x03, (665 << 5) | 0x0f,
            (-922 << 5) | 0x0d
 };
 
-const int16_t coeff_4k_sb_1seg[8] = {
+static const int16_t coeff_4k_sb_1seg[8] = {
        (638 << 5) | 0x0d, (683 << 5) | 0x02, (638 << 5) | 0x0d, (638 << 5) | 0x0d, (-655 << 5) | 0x0a, (517 << 5) | 0x00, (698 << 5) | 0x0d,
            (-655 << 5) | 0x0a
 };
 
-const int16_t coeff_4k_sb_3seg_0dqpsk_1dqpsk[8] = {
+static const int16_t coeff_4k_sb_3seg_0dqpsk_1dqpsk[8] = {
        (-707 << 5) | 0x14, (910 << 5) | 0x06, (889 << 5) | 0x16, (-707 << 5) | 0x14, (-958 << 5) | 0x13, (993 << 5) | 0x05, (523 << 5) | 0x14,
            (-958 << 5) | 0x13
 };
 
-const int16_t coeff_4k_sb_3seg_0dqpsk[8] = {
+static const int16_t coeff_4k_sb_3seg_0dqpsk[8] = {
        (-723 << 5) | 0x13, (910 << 5) | 0x05, (777 << 5) | 0x14, (-723 << 5) | 0x13, (-568 << 5) | 0x0f, (547 << 5) | 0x03, (696 << 5) | 0x12,
            (-568 << 5) | 0x0f
 };
 
-const int16_t coeff_4k_sb_3seg_1dqpsk[8] = {
+static const int16_t coeff_4k_sb_3seg_1dqpsk[8] = {
        (-940 << 5) | 0x15, (607 << 5) | 0x05, (915 << 5) | 0x16, (-940 << 5) | 0x15, (-848 << 5) | 0x13, (683 << 5) | 0x04, (543 << 5) | 0x14,
            (-848 << 5) | 0x13
 };
 
-const int16_t coeff_4k_sb_3seg[8] = {
+static const int16_t coeff_4k_sb_3seg[8] = {
        (612 << 5) | 0x12, (910 << 5) | 0x04, (864 << 5) | 0x14, (612 << 5) | 0x12, (-869 << 5) | 0x13, (683 << 5) | 0x02, (869 << 5) | 0x12,
            (-869 << 5) | 0x13
 };
 
-const int16_t coeff_8k_sb_1seg_dqpsk[8] = {
+static const int16_t coeff_8k_sb_1seg_dqpsk[8] = {
        (-835 << 5) | 0x12, (684 << 5) | 0x05, (735 << 5) | 0x14, (-835 << 5) | 0x12, (-598 << 5) | 0x10, (781 << 5) | 0x04, (739 << 5) | 0x13,
            (-598 << 5) | 0x10
 };
 
-const int16_t coeff_8k_sb_1seg[8] = {
+static const int16_t coeff_8k_sb_1seg[8] = {
        (673 << 5) | 0x0f, (683 << 5) | 0x03, (808 << 5) | 0x12, (673 << 5) | 0x0f, (585 << 5) | 0x0f, (512 << 5) | 0x01, (780 << 5) | 0x0f,
            (585 << 5) | 0x0f
 };
 
-const int16_t coeff_8k_sb_3seg_0dqpsk_1dqpsk[8] = {
+static const int16_t coeff_8k_sb_3seg_0dqpsk_1dqpsk[8] = {
        (863 << 5) | 0x17, (930 << 5) | 0x07, (878 << 5) | 0x19, (863 << 5) | 0x17, (0 << 5) | 0x14, (521 << 5) | 0x05, (980 << 5) | 0x18,
            (0 << 5) | 0x14
 };
 
-const int16_t coeff_8k_sb_3seg_0dqpsk[8] = {
+static const int16_t coeff_8k_sb_3seg_0dqpsk[8] = {
        (-924 << 5) | 0x17, (910 << 5) | 0x06, (774 << 5) | 0x17, (-924 << 5) | 0x17, (-877 << 5) | 0x15, (565 << 5) | 0x04, (553 << 5) | 0x15,
            (-877 << 5) | 0x15
 };
 
-const int16_t coeff_8k_sb_3seg_1dqpsk[8] = {
+static const int16_t coeff_8k_sb_3seg_1dqpsk[8] = {
        (-921 << 5) | 0x19, (607 << 5) | 0x06, (881 << 5) | 0x19, (-921 << 5) | 0x19, (-921 << 5) | 0x14, (713 << 5) | 0x05, (1018 << 5) | 0x18,
            (-921 << 5) | 0x14
 };
 
-const int16_t coeff_8k_sb_3seg[8] = {
+static const int16_t coeff_8k_sb_3seg[8] = {
        (514 << 5) | 0x14, (910 << 5) | 0x05, (861 << 5) | 0x17, (514 << 5) | 0x14, (690 << 5) | 0x14, (683 << 5) | 0x03, (662 << 5) | 0x15,
            (690 << 5) | 0x14
 };
 
-const int16_t ana_fe_coeff_3seg[24] = {
+static const int16_t ana_fe_coeff_3seg[24] = {
        81, 80, 78, 74, 68, 61, 54, 45, 37, 28, 19, 11, 4, 1022, 1017, 1013, 1010, 1008, 1008, 1008, 1008, 1010, 1014, 1017
 };
 
-const int16_t ana_fe_coeff_1seg[24] = {
+static const int16_t ana_fe_coeff_1seg[24] = {
        249, 226, 164, 82, 5, 981, 970, 988, 1018, 20, 31, 26, 8, 1012, 1000, 1018, 1012, 8, 15, 14, 9, 3, 1017, 1003
 };
 
-const int16_t ana_fe_coeff_13seg[24] = {
+static const int16_t ana_fe_coeff_13seg[24] = {
        396, 305, 105, -51, -77, -12, 41, 31, -11, -30, -11, 14, 15, -2, -13, -7, 5, 8, 1, -6, -7, -3, 0, 1
 };
 
@@ -852,6 +840,14 @@ static int dib8000_set_agc_config(struct dib8000_state *state, u8 band)
        return 0;
 }
 
+void dib8000_pwm_agc_reset(struct dvb_frontend *fe)
+{
+       struct dib8000_state *state = fe->demodulator_priv;
+       dib8000_set_adc_state(state, DIBX000_ADC_ON);
+       dib8000_set_agc_config(state, (unsigned char)(BAND_OF_FREQUENCY(fe->dtv_property_cache.frequency / 1000)));
+}
+EXPORT_SYMBOL(dib8000_pwm_agc_reset);
+
 static int dib8000_agc_soft_split(struct dib8000_state *state)
 {
        u16 agc, split_offset;
@@ -939,6 +935,32 @@ static int dib8000_agc_startup(struct dvb_frontend *fe)
 
 }
 
+static const int32_t lut_1000ln_mant[] =
+{
+       908, 7003, 7090, 7170, 7244, 7313, 7377, 7438, 7495, 7549, 7600
+};
+
+int32_t dib8000_get_adc_power(struct dvb_frontend *fe, uint8_t mode)
+{
+    struct dib8000_state *state = fe->demodulator_priv;
+    uint32_t ix = 0, tmp_val = 0, exp = 0, mant = 0;
+    int32_t val;
+
+    val = dib8000_read32(state, 384);
+    /* mode = 1 : ln_agcpower calc using mant-exp conversion and mantis look up table */
+    if (mode) {
+       tmp_val = val;
+       while (tmp_val >>= 1)
+               exp++;
+       mant = (val * 1000 / (1<<exp));
+       ix = (uint8_t)((mant-1000)/100); /* index of the LUT */
+       val = (lut_1000ln_mant[ix] + 693*(exp-20) - 6908); /* 1000 * ln(adcpower_real) ; 693 = 1000ln(2) ; 6908 = 1000*ln(1000) ; 20 comes from adc_real = adc_pow_int / 2**20 */
+       val = (val*256)/1000;
+    }
+    return val;
+}
+EXPORT_SYMBOL(dib8000_get_adc_power);
+
 static void dib8000_update_timf(struct dib8000_state *state)
 {
        u32 timf = state->timf = dib8000_read32(state, 435);
@@ -1401,10 +1423,9 @@ static void dib8000_set_channel(struct dib8000_state *state, u8 seq, u8 autosear
                        }
                        break;
                }
-       }
-       if (state->fe.dtv_property_cache.isdbt_sb_mode == 1)
                for (i = 0; i < 8; i++)
                        dib8000_write_word(state, 343 + i, ncoeff[i]);
+       }
 
        // P_small_coef_ext_enable=ISDB-Tsb, P_small_narrow_band=ISDB-Tsb, P_small_last_seg=13, P_small_offset_num_car=5
        dib8000_write_word(state, 351,
@@ -1854,6 +1875,24 @@ static int dib8000_sleep(struct dvb_frontend *fe)
        }
 }
 
+enum frontend_tune_state dib8000_get_tune_state(struct dvb_frontend *fe)
+{
+       struct dib8000_state *state = fe->demodulator_priv;
+       return state->tune_state;
+}
+EXPORT_SYMBOL(dib8000_get_tune_state);
+
+int dib8000_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state)
+{
+       struct dib8000_state *state = fe->demodulator_priv;
+       state->tune_state = tune_state;
+       return 0;
+}
+EXPORT_SYMBOL(dib8000_set_tune_state);
+
+
+
+
 static int dib8000_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
 {
        struct dib8000_state *state = fe->demodulator_priv;
@@ -2043,29 +2082,31 @@ static int dib8000_read_status(struct dvb_frontend *fe, fe_status_t * stat)
 
        *stat = 0;
 
-       if ((lock >> 14) & 1)   // AGC
+       if ((lock >> 13) & 1)
                *stat |= FE_HAS_SIGNAL;
 
-       if ((lock >> 8) & 1)    // Equal
+       if ((lock >> 8) & 1) /* Equal */
                *stat |= FE_HAS_CARRIER;
 
-       if ((lock >> 3) & 1)    // TMCC_SYNC
+       if (((lock >> 1) & 0xf) == 0xf) /* TMCC_SYNC */
                *stat |= FE_HAS_SYNC;
 
-       if ((lock >> 5) & 7)    // FEC MPEG
+       if (((lock >> 12) & 1) && ((lock >> 5) & 7)) /* FEC MPEG */
                *stat |= FE_HAS_LOCK;
 
-       lock = dib8000_read_word(state, 554);   // Viterbi Layer A
-       if (lock & 0x01)
-               *stat |= FE_HAS_VITERBI;
+       if ((lock >> 12) & 1) {
+               lock = dib8000_read_word(state, 554); /* Viterbi Layer A */
+               if (lock & 0x01)
+                       *stat |= FE_HAS_VITERBI;
 
-       lock = dib8000_read_word(state, 555);   // Viterbi Layer B
-       if (lock & 0x01)
-               *stat |= FE_HAS_VITERBI;
+               lock = dib8000_read_word(state, 555); /* Viterbi Layer B */
+               if (lock & 0x01)
+                       *stat |= FE_HAS_VITERBI;
 
-       lock = dib8000_read_word(state, 556);   // Viterbi Layer C
-       if (lock & 0x01)
-               *stat |= FE_HAS_VITERBI;
+               lock = dib8000_read_word(state, 556); /* Viterbi Layer C */
+               if (lock & 0x01)
+                       *stat |= FE_HAS_VITERBI;
+       }
 
        return 0;
 }
index 8c89482b738aab665a0e81c062693d8300c0e49a..d99619ae983ce4ea9528ba273381c950b5a6e5ff 100644 (file)
@@ -46,6 +46,10 @@ extern int dib8000_set_gpio(struct dvb_frontend *, u8 num, u8 dir, u8 val);
 extern int dib8000_set_wbd_ref(struct dvb_frontend *, u16 value);
 extern int dib8000_pid_filter_ctrl(struct dvb_frontend *, u8 onoff);
 extern int dib8000_pid_filter(struct dvb_frontend *, u8 id, u16 pid, u8 onoff);
+extern int dib8000_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state);
+extern enum frontend_tune_state dib8000_get_tune_state(struct dvb_frontend *fe);
+extern void dib8000_pwm_agc_reset(struct dvb_frontend *fe);
+extern s32 dib8000_get_adc_power(struct dvb_frontend *fe, u8 mode);
 #else
 static inline struct dvb_frontend *dib8000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg)
 {
@@ -59,35 +63,53 @@ static inline struct i2c_adapter *dib8000_get_i2c_master(struct dvb_frontend *fe
        return NULL;
 }
 
-int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, u8 default_addr, u8 first_addr)
+static inline int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, u8 default_addr, u8 first_addr)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
        return -ENODEV;
 }
 
-int dib8000_set_gpio(struct dvb_frontend *fe, u8 num, u8 dir, u8 val)
+static inline int dib8000_set_gpio(struct dvb_frontend *fe, u8 num, u8 dir, u8 val)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
        return -ENODEV;
 }
 
-int dib8000_set_wbd_ref(struct dvb_frontend *fe, u16 value)
+static inline int dib8000_set_wbd_ref(struct dvb_frontend *fe, u16 value)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
        return -ENODEV;
 }
 
-int dib8000_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
+static inline int dib8000_pid_filter_ctrl(struct dvb_frontend *fe, u8 onoff)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
        return -ENODEV;
 }
 
-int dib8000_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
+static inline int dib8000_pid_filter(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
        return -ENODEV;
 }
+static inline int dib8000_set_tune_state(struct dvb_frontend *fe, enum frontend_tune_state tune_state)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+       return -ENODEV;
+}
+static inline enum frontend_tune_state dib8000_get_tune_state(struct dvb_frontend *fe)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+    return CT_SHUTDOWN,
+}
+static inline void dib8000_pwm_agc_reset(struct dvb_frontend *fe)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+}
+static inline s32 dib8000_get_adc_power(struct dvb_frontend *fe, u8 mode)
+{
+       printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
+}
 #endif
 
 #endif
index 4efca30d2127cbf40b1618274755413a8a210429..e6f3d73db9d33e6cac8fbf34aa969cbf24de530e 100644 (file)
@@ -6,7 +6,7 @@ static int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "turn on debugging (default: 0)");
 
-#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiBX000: "); printk(args); } } while (0)
+#define dprintk(args...) do { if (debug) { printk(KERN_DEBUG "DiBX000: "); printk(args); printk("\n"); } } while (0)
 
 static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
 {
@@ -25,7 +25,7 @@ static int dibx000_i2c_select_interface(struct dibx000_i2c_master *mst,
                                        enum dibx000_i2c_interface intf)
 {
        if (mst->device_rev > DIB3000MC && mst->selected_interface != intf) {
-               dprintk("selecting interface: %d\n", intf);
+               dprintk("selecting interface: %d", intf);
                mst->selected_interface = intf;
                return dibx000_write_word(mst, mst->base_reg + 4, intf);
        }
@@ -171,9 +171,18 @@ void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst)
 {
        i2c_del_adapter(&mst->gated_tuner_i2c_adap);
 }
-
 EXPORT_SYMBOL(dibx000_exit_i2c_master);
 
+
+u32 systime()
+{
+    struct timespec t;
+
+    t = current_kernel_time();
+    return (t.tv_sec * 10000) + (t.tv_nsec / 100000);
+}
+EXPORT_SYMBOL(systime);
+
 MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
 MODULE_DESCRIPTION("Common function the DiBcom demodulator family");
 MODULE_LICENSE("GPL");
index 5be10eca07c025ee37e18c59cd7d30c277d7fb74..4f5d141a308dc45945a762db1a4433fd93086c8a 100644 (file)
@@ -36,13 +36,17 @@ extern struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master
 extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
 extern void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst);
 
+extern u32 systime(void);
+
 #define BAND_LBAND 0x01
 #define BAND_UHF   0x02
 #define BAND_VHF   0x04
 #define BAND_SBAND 0x08
-#define BAND_FM           0x10
+#define BAND_FM    0x10
+#define BAND_CBAND 0x20
 
-#define BAND_OF_FREQUENCY(freq_kHz) ( (freq_kHz) <= 115000 ? BAND_FM : \
+#define BAND_OF_FREQUENCY(freq_kHz) ((freq_kHz) <= 170000 ? BAND_CBAND : \
+                                                                       (freq_kHz) <= 115000 ? BAND_FM : \
                                                                        (freq_kHz) <= 250000 ? BAND_VHF : \
                                                                        (freq_kHz) <= 863000 ? BAND_UHF : \
                                                                        (freq_kHz) <= 2000000 ? BAND_LBAND : BAND_SBAND )
@@ -149,4 +153,67 @@ enum dibx000_adc_states {
 #define OUTMODE_MPEG2_FIFO          5
 #define OUTMODE_ANALOG_ADC          6
 
+enum frontend_tune_state {
+    CT_TUNER_START = 10,
+    CT_TUNER_STEP_0,
+    CT_TUNER_STEP_1,
+    CT_TUNER_STEP_2,
+    CT_TUNER_STEP_3,
+    CT_TUNER_STEP_4,
+    CT_TUNER_STEP_5,
+    CT_TUNER_STEP_6,
+    CT_TUNER_STEP_7,
+    CT_TUNER_STOP,
+
+    CT_AGC_START = 20,
+    CT_AGC_STEP_0,
+    CT_AGC_STEP_1,
+    CT_AGC_STEP_2,
+    CT_AGC_STEP_3,
+    CT_AGC_STEP_4,
+    CT_AGC_STOP,
+
+       CT_DEMOD_START = 30,
+    CT_DEMOD_STEP_1,
+    CT_DEMOD_STEP_2,
+    CT_DEMOD_STEP_3,
+    CT_DEMOD_STEP_4,
+    CT_DEMOD_STEP_5,
+    CT_DEMOD_STEP_6,
+    CT_DEMOD_STEP_7,
+    CT_DEMOD_STEP_8,
+    CT_DEMOD_STEP_9,
+    CT_DEMOD_STEP_10,
+    CT_DEMOD_SEARCH_NEXT = 41,
+    CT_DEMOD_STEP_LOCKED,
+    CT_DEMOD_STOP,
+
+    CT_DONE = 100,
+    CT_SHUTDOWN,
+
+};
+
+struct dvb_frontend_parametersContext {
+#define CHANNEL_STATUS_PARAMETERS_UNKNOWN   0x01
+#define CHANNEL_STATUS_PARAMETERS_SET       0x02
+    u8 status;
+    u32 tune_time_estimation[2];
+    s32 tps_available;
+    u16 tps[9];
+};
+
+#define FE_STATUS_TUNE_FAILED          0
+#define FE_STATUS_TUNE_TIMED_OUT      -1
+#define FE_STATUS_TUNE_TIME_TOO_SHORT -2
+#define FE_STATUS_TUNE_PENDING        -3
+#define FE_STATUS_STD_SUCCESS         -4
+#define FE_STATUS_FFT_SUCCESS         -5
+#define FE_STATUS_DEMOD_SUCCESS       -6
+#define FE_STATUS_LOCKED              -7
+#define FE_STATUS_DATA_LOCKED         -8
+
+#define FE_CALLBACK_TIME_NEVER 0xffffffff
+
+#define ABS(x) ((x < 0) ? (-x) : (x))
+
 #endif
index eabcadc425d5297a772a772c5f19a6d9983d4dff..dee53960e7e8f79966763c0f64107db55313f5ba 100644 (file)
@@ -199,7 +199,7 @@ static int lgs8gxx_set_if_freq(struct lgs8gxx_state *priv, u32 freq /*in kHz*/)
 
        val = freq;
        if (freq != 0) {
-               val *= (u64)1 << 32;
+               val <<= 32;
                if (if_clk != 0)
                        do_div(val, if_clk);
                v32 = val & 0xFFFFFFFF;
@@ -246,7 +246,7 @@ static int lgs8gxx_get_afc_phase(struct lgs8gxx_state *priv)
 
        val = v32;
        val *= priv->config->if_clk_freq;
-       val /= (u64)1 << 32;
+       val >>= 32;
        dprintk("AFC = %u kHz\n", (u32)val);
        return 0;
 }
index 71f607fe8fc7ca87326ad21e3fbf8fd7eeba9983..b181bf023adab96444fca28092c72a23a2abac41 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * lnbp21.c - driver for lnb supply and control ic lnbp21
  *
- * Copyright (C) 2006 Oliver Endriss
+ * Copyright (C) 2006, 2009 Oliver Endriss <o.endriss@gmx.de>
  * Copyright (C) 2009 Igor M. Liplianin <liplianin@netup.ru>
  *
  * This program is free software; you can redistribute it and/or
@@ -91,6 +91,31 @@ static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
        return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO;
 }
 
+static int lnbp21_set_tone(struct dvb_frontend *fe,
+                               fe_sec_tone_mode_t tone)
+{
+       struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->sec_priv;
+       struct i2c_msg msg = {  .addr = lnbp21->i2c_addr, .flags = 0,
+                               .buf = &lnbp21->config,
+                               .len = sizeof(lnbp21->config) };
+
+       switch (tone) {
+       case SEC_TONE_OFF:
+               lnbp21->config &= ~LNBP21_TEN;
+               break;
+       case SEC_TONE_ON:
+               lnbp21->config |= LNBP21_TEN;
+               break;
+       default:
+               return -EINVAL;
+       };
+
+       lnbp21->config |= lnbp21->override_or;
+       lnbp21->config &= lnbp21->override_and;
+
+       return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO;
+}
+
 static void lnbp21_release(struct dvb_frontend *fe)
 {
        /* LNBP power off */
@@ -133,6 +158,7 @@ static struct dvb_frontend *lnbx2x_attach(struct dvb_frontend *fe,
        /* override frontend ops */
        fe->ops.set_voltage = lnbp21_set_voltage;
        fe->ops.enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
+       fe->ops.set_tone = lnbp21_set_tone;
        printk(KERN_INFO "LNBx2x attached on addr=%x\n", lnbp21->i2c_addr);
 
        return fe;
index df49ea0983bc099513a828ed77039cf979500db7..8762c86044a5a4fb310d4b5d2e845aaeb0aa3218 100644 (file)
@@ -1451,6 +1451,8 @@ static int stv0900_status(struct stv0900_internal *intp,
 {
        enum fe_stv0900_search_state demod_state;
        int locked = FALSE;
+       u8 tsbitrate0_val, tsbitrate1_val;
+       s32 bitrate;
 
        demod_state = stv0900_get_bits(intp, HEADER_MODE);
        switch (demod_state) {
@@ -1473,6 +1475,17 @@ static int stv0900_status(struct stv0900_internal *intp,
 
        dprintk("%s: locked = %d\n", __func__, locked);
 
+       if (stvdebug) {
+               /* Print TS bitrate */
+               tsbitrate0_val = stv0900_read_reg(intp, TSBITRATE0);
+               tsbitrate1_val = stv0900_read_reg(intp, TSBITRATE1);
+               /* Formula Bit rate = Mclk * px_tsfifo_bitrate / 16384 */
+               bitrate = (stv0900_get_mclk_freq(intp, intp->quartz)/1000000)
+                       * (tsbitrate1_val << 8 | tsbitrate0_val);
+               bitrate /= 16384;
+               dprintk("TS bitrate = %d Mbit/sec \n", bitrate);
+       };
+
        return locked;
 }
 
index 48edd542242eab878e5bec361067ec59f738d67e..1573466a5c740aa544b4a68e863722f1791f1892 100644 (file)
@@ -3597,7 +3597,8 @@ static int stv090x_send_diseqc_msg(struct dvb_frontend *fe, struct dvb_diseqc_ma
 
        reg = STV090x_READ_DEMOD(state, DISTXCTL);
 
-       STV090x_SETFIELD_Px(reg, DISTX_MODE_FIELD, 2);
+       STV090x_SETFIELD_Px(reg, DISTX_MODE_FIELD,
+               (state->config->diseqc_envelope_mode) ? 4 : 2);
        STV090x_SETFIELD_Px(reg, DISEQC_RESET_FIELD, 1);
        if (STV090x_WRITE_DEMOD(state, DISTXCTL, reg) < 0)
                goto err;
@@ -3649,10 +3650,10 @@ static int stv090x_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t
        reg = STV090x_READ_DEMOD(state, DISTXCTL);
 
        if (burst == SEC_MINI_A) {
-               mode = 3;
+               mode = (state->config->diseqc_envelope_mode) ? 5 : 3;
                value = 0x00;
        } else {
-               mode = 2;
+               mode = (state->config->diseqc_envelope_mode) ? 4 : 2;
                value = 0xFF;
        }
 
index e968c98bb70f62d606ffcf3d8954e37c944a6f37..b133807663eabd28114c85c730a2c8a3a12a2f5f 100644 (file)
@@ -75,6 +75,8 @@ struct stv090x_config {
 
        enum stv090x_i2crpt     repeater_level;
 
+       bool diseqc_envelope_mode;
+
        int (*tuner_init) (struct dvb_frontend *fe);
        int (*tuner_set_mode) (struct dvb_frontend *fe, enum tuner_mode mode);
        int (*tuner_set_frequency) (struct dvb_frontend *fe, u32 frequency);
index 266033ae2784ebd5568ab33e6e7a4318add7e234..68bf9fbd8fed91094cd641c245ebaf2d467761ce 100644 (file)
@@ -662,7 +662,7 @@ adapter_error:
        return rc;
 }
 
-int smsdvb_module_init(void)
+static int __init smsdvb_module_init(void)
 {
        int rc;
 
@@ -676,7 +676,7 @@ int smsdvb_module_init(void)
        return rc;
 }
 
-void smsdvb_module_exit(void)
+static void __exit smsdvb_module_exit(void)
 {
        smscore_unregister_hotplug(smsdvb_hotplug);
 
index 24206cbda2646b0aff55a62206a92faba9913196..195244a3e69b35400df3dd83a9856c76417cef9b 100644 (file)
@@ -48,7 +48,7 @@
 #define SMSSDIO_INT            0x04
 #define SMSSDIO_BLOCK_SIZE     128
 
-static const struct sdio_device_id smssdio_ids[] = {
+static const struct sdio_device_id smssdio_ids[] __devinitconst = {
        {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_STELLAR),
         .driver_data = SMS1XXX_BOARD_SIANO_STELLAR},
        {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_NOVA_A0),
@@ -222,7 +222,7 @@ static void smssdio_interrupt(struct sdio_func *func)
        smscore_onresponse(smsdev->coredev, cb);
 }
 
-static int smssdio_probe(struct sdio_func *func,
+static int __devinit smssdio_probe(struct sdio_func *func,
                         const struct sdio_device_id *id)
 {
        int ret;
@@ -338,7 +338,7 @@ static struct sdio_driver smssdio_driver = {
 /* Module functions                                                */
 /*******************************************************************/
 
-int smssdio_module_init(void)
+static int __init smssdio_module_init(void)
 {
        int ret = 0;
 
@@ -350,7 +350,7 @@ int smssdio_module_init(void)
        return ret;
 }
 
-void smssdio_module_exit(void)
+static void __exit smssdio_module_exit(void)
 {
        sdio_unregister_driver(&smssdio_driver);
 }
index 8f88a586b0ddabb9ee50feef7ad28c6a56dff5bb..5eac27287d9ceff598d346348581106466440069 100644 (file)
@@ -390,7 +390,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
        return rc;
 }
 
-static int smsusb_probe(struct usb_interface *intf,
+static int __devinit smsusb_probe(struct usb_interface *intf,
                        const struct usb_device_id *id)
 {
        struct usb_device *udev = interface_to_usbdev(intf);
@@ -484,7 +484,7 @@ static int smsusb_resume(struct usb_interface *intf)
        return 0;
 }
 
-struct usb_device_id smsusb_id_table[] = {
+static const struct usb_device_id smsusb_id_table[] __devinitconst = {
        { USB_DEVICE(0x187f, 0x0010),
                .driver_info = SMS1XXX_BOARD_SIANO_STELLAR },
        { USB_DEVICE(0x187f, 0x0100),
@@ -533,8 +533,18 @@ struct usb_device_id smsusb_id_table[] = {
                .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
        { USB_DEVICE(0x2040, 0xb910),
                .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
+       { USB_DEVICE(0x2040, 0xb980),
+               .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
+       { USB_DEVICE(0x2040, 0xb990),
+               .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
        { USB_DEVICE(0x2040, 0xc000),
                .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
+       { USB_DEVICE(0x2040, 0xc010),
+               .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
+       { USB_DEVICE(0x2040, 0xc080),
+               .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
+       { USB_DEVICE(0x2040, 0xc090),
+               .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
        { } /* Terminating entry */
        };
 
@@ -550,7 +560,7 @@ static struct usb_driver smsusb_driver = {
        .resume                 = smsusb_resume,
 };
 
-int smsusb_module_init(void)
+static int __init smsusb_module_init(void)
 {
        int rc = usb_register(&smsusb_driver);
        if (rc)
@@ -561,7 +571,7 @@ int smsusb_module_init(void)
        return rc;
 }
 
-void smsusb_module_exit(void)
+static void __exit smsusb_module_exit(void)
 {
        /* Regular USB Cleanup */
        usb_deregister(&smsusb_driver);
index 7d193ebc0aea30baaf82896b7ed8b4f3444c0a47..9782e05937338fca46d65c1be4a54a95f9a3428c 100644 (file)
@@ -190,12 +190,13 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
        struct saa7146_dev *saa = budget_ci->budget.dev;
        struct input_dev *input_dev = budget_ci->ir.dev;
        int error;
+       struct ir_scancode_table *ir_codes;
+
 
        budget_ci->ir.dev = input_dev = input_allocate_device();
        if (!input_dev) {
                printk(KERN_ERR "budget_ci: IR interface initialisation failed\n");
-               error = -ENOMEM;
-               goto out1;
+               return -ENOMEM;
        }
 
        snprintf(budget_ci->ir.name, sizeof(budget_ci->ir.name),
@@ -217,6 +218,11 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
        }
        input_dev->dev.parent = &saa->pci->dev;
 
+       if (rc5_device < 0)
+               budget_ci->ir.rc5_device = IR_DEVICE_ANY;
+       else
+               budget_ci->ir.rc5_device = rc5_device;
+
        /* Select keymap and address */
        switch (budget_ci->budget.dev->pci->subsystem_device) {
        case 0x100c:
@@ -224,53 +230,34 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
        case 0x1011:
        case 0x1012:
                /* The hauppauge keymap is a superset of these remotes */
-               error = ir_input_init(input_dev, &budget_ci->ir.state,
-                             IR_TYPE_RC5, &ir_codes_hauppauge_new_table);
-               if (error < 0)
-                       goto out2;
+               ir_codes = &ir_codes_hauppauge_new_table;
 
                if (rc5_device < 0)
                        budget_ci->ir.rc5_device = 0x1f;
-               else
-                       budget_ci->ir.rc5_device = rc5_device;
                break;
        case 0x1010:
        case 0x1017:
        case 0x101a:
                /* for the Technotrend 1500 bundled remote */
-               error = ir_input_init(input_dev, &budget_ci->ir.state,
-                             IR_TYPE_RC5, &ir_codes_tt_1500_table);
-               if (error < 0)
-                       goto out2;
-
-               if (rc5_device < 0)
-                       budget_ci->ir.rc5_device = IR_DEVICE_ANY;
-               else
-                       budget_ci->ir.rc5_device = rc5_device;
+               ir_codes = &ir_codes_tt_1500_table;
                break;
        default:
                /* unknown remote */
-               error = ir_input_init(input_dev, &budget_ci->ir.state,
-                             IR_TYPE_RC5, &ir_codes_budget_ci_old_table);
-               if (error < 0)
-                       goto out2;
-
-               if (rc5_device < 0)
-                       budget_ci->ir.rc5_device = IR_DEVICE_ANY;
-               else
-                       budget_ci->ir.rc5_device = rc5_device;
+               ir_codes = &ir_codes_budget_ci_old_table;
                break;
        }
 
+       ir_input_init(input_dev, &budget_ci->ir.state, IR_TYPE_RC5);
+
        /* initialise the key-up timeout handler */
        init_timer(&budget_ci->ir.timer_keyup);
        budget_ci->ir.timer_keyup.function = msp430_ir_keyup;
        budget_ci->ir.timer_keyup.data = (unsigned long) &budget_ci->ir;
        budget_ci->ir.last_raw = 0xffff; /* An impossible value */
-       error = input_register_device(input_dev);
+       error = ir_input_register(input_dev, ir_codes);
        if (error) {
                printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
-               goto out2;
+               return error;
        }
 
        /* note: these must be after input_register_device */
@@ -284,12 +271,6 @@ static int msp430_ir_init(struct budget_ci *budget_ci)
        saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI);
 
        return 0;
-
-out2:
-       ir_input_free(input_dev);
-       input_free_device(input_dev);
-out1:
-       return error;
 }
 
 static void msp430_ir_deinit(struct budget_ci *budget_ci)
@@ -304,8 +285,7 @@ static void msp430_ir_deinit(struct budget_ci *budget_ci)
        del_timer_sync(&dev->timer);
        ir_input_nokey(dev, &budget_ci->ir.state);
 
-       ir_input_free(dev);
-       input_unregister_device(dev);
+       ir_input_unregister(dev);
 }
 
 static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
index 4c2b8a246772c968f8747d37b14f9c1a0bc81291..3f40f375981bfa38946ebb8de1201dc6158cfdea 100644 (file)
@@ -215,13 +215,10 @@ config RADIO_MIROPCM20
          module will be called radio-miropcm20.
 
 config RADIO_SF16FMI
-       tristate "SF16FMI Radio"
+       tristate "SF16-FMI/SF16-FMP Radio"
        depends on ISA && VIDEO_V4L2
        ---help---
-         Choose Y here if you have one of these FM radio cards.  If you
-         compile the driver into the kernel and your card is not PnP one, you
-         have to add "sf16fm=<io>" to the kernel command line (I/O address is
-         0x284 or 0x384).
+         Choose Y here if you have one of these FM radio cards.
 
          In order to control your radio card, you will need to use programs
          that are compatible with the Video For Linux API.  Information on
index 35edee009ba8b859378fcdf9e11a1f8fab1835b2..5bf4985daede6a49e9b35adcb3b3256b51a14924 100644 (file)
@@ -268,6 +268,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct rtrack *rt = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        rt_setfreq(rt, f->frequency);
        return 0;
 }
@@ -277,6 +279,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct rtrack *rt = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = rt->curfreq;
        return 0;
index 8daf809eb01aa8c8fa218e177460fd190defc1ce..c22311393624d26ebfbe0d4db8776a7c536b3a70 100644 (file)
@@ -254,6 +254,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct aztech *az = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        az_setfreq(az, f->frequency);
        return 0;
 }
@@ -263,6 +265,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct aztech *az = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = az->curfreq;
        return 0;
index c6cf1166186824b1c062350617c14c7edef0ed01..000f4d34087ce2352fbd9c4ae8b47846f49aaa82 100644 (file)
@@ -240,6 +240,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct gemtek_pci *card = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        if (f->frequency < GEMTEK_PCI_RANGE_LOW ||
            f->frequency > GEMTEK_PCI_RANGE_HIGH)
                return -EINVAL;
@@ -253,6 +255,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct gemtek_pci *card = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = card->current_frequency;
        return 0;
index 64d737c35acf18de14d9cc625ba7982ae3f3d641..f8213b7c8ddc2a6c97ac94e8c52846fe9606711a 100644 (file)
@@ -200,6 +200,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct maestro *dev = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        if (f->frequency < FREQ_LO || f->frequency > FREQ_HI)
                return -EINVAL;
        mutex_lock(&dev->lock);
@@ -213,6 +215,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct maestro *dev = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        mutex_lock(&dev->lock);
        f->frequency = BITS2FREQ(radio_bits_get(dev));
index 3da51fe8fb937c46ab349a345ecea6a8cddcbfc7..44b4dbedb322a57108483494f4785b7b02252076 100644 (file)
@@ -262,6 +262,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct maxiradio *dev = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) {
                dprintk(dev, 1, "radio freq (%d.%02d MHz) out of range (%d-%d)\n",
                                        f->frequency / 16000,
@@ -285,6 +287,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct maxiradio *dev = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = dev->freq;
 
index 949f60513d9e08862ff05f6cc925cf46c7092306..02a9cefc9a00d6b6e12dc595b0aa5d8c1baee17e 100644 (file)
@@ -374,6 +374,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct amradio_device *radio = file->private_data;
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        return amradio_setfreq(radio, f->frequency);
 }
 
@@ -383,6 +385,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct amradio_device *radio = file->private_data;
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = radio->curfreq;
 
index 9cb193fa6e335c367920e2079b67716e17378b6c..a79296aac9a9636e408a27a7da9a42cf9c4e21e3 100644 (file)
@@ -167,6 +167,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct rtrack2 *rt = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        rt_setfreq(rt, f->frequency);
        return 0;
 }
@@ -176,6 +178,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct rtrack2 *rt = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = rt->curfreq;
        return 0;
index 49c4aab95daba17a6298a007af3ac502bb7a0282..985359d18aa58fd8e350d0e06b05b66020534bc5 100644 (file)
@@ -1,4 +1,4 @@
-/* SF16FMI radio driver for Linux radio support
+/* SF16-FMI and SF16-FMP radio driver for Linux radio support
  * heavily based on rtrack driver...
  * (c) 1997 M. Kirkwood
  * (c) 1998 Petr Vandrovec, vandrove@vc.cvut.cz
@@ -11,7 +11,7 @@
  *
  *  Frequency control is done digitally -- ie out(port,encodefreq(95.8));
  *  No volume control - only mute/unmute - you have to use line volume
- *  control on SB-part of SF16FMI
+ *  control on SB-part of SF16-FMI/SF16-FMP
  *
  * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org>
  */
 #include <media/v4l2-ioctl.h>
 
 MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood");
-MODULE_DESCRIPTION("A driver for the SF16MI radio.");
+MODULE_DESCRIPTION("A driver for the SF16-FMI and SF16-FMP radio.");
 MODULE_LICENSE("GPL");
 
 static int io = -1;
 static int radio_nr = -1;
 
 module_param(io, int, 0);
-MODULE_PARM_DESC(io, "I/O address of the SF16MI card (0x284 or 0x384)");
+MODULE_PARM_DESC(io, "I/O address of the SF16-FMI or SF16-FMP card (0x284 or 0x384)");
 module_param(radio_nr, int, 0);
 
 #define RADIO_VERSION KERNEL_VERSION(0, 0, 2)
@@ -47,13 +47,14 @@ struct fmi
        struct v4l2_device v4l2_dev;
        struct video_device vdev;
        int io;
-       int curvol; /* 1 or 0 */
+       bool mute;
        unsigned long curfreq; /* freq in kHz */
        struct mutex lock;
 };
 
 static struct fmi fmi_card;
 static struct pnp_dev *dev;
+bool pnp_attached;
 
 /* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */
 /* It is only useful to give freq in interval of 800 (=0.05Mhz),
@@ -105,7 +106,7 @@ static inline int fmi_setfreq(struct fmi *fmi, unsigned long freq)
        outbits(8, 0xC0, fmi->io);
        msleep(143);            /* was schedule_timeout(HZ/7) */
        mutex_unlock(&fmi->lock);
-       if (fmi->curvol)
+       if (!fmi->mute)
                fmi_unmute(fmi);
        return 0;
 }
@@ -116,7 +117,7 @@ static inline int fmi_getsigstr(struct fmi *fmi)
        int res;
 
        mutex_lock(&fmi->lock);
-       val = fmi->curvol ? 0x08 : 0x00;        /* unmute/mute */
+       val = fmi->mute ? 0x00 : 0x08;  /* mute/unmute */
        outb(val, fmi->io);
        outb(val | 0x10, fmi->io);
        msleep(143);            /* was schedule_timeout(HZ/7) */
@@ -168,6 +169,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct fmi *fmi = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        if (f->frequency < RSF16_MINFREQ ||
                        f->frequency > RSF16_MAXFREQ)
                return -EINVAL;
@@ -182,6 +185,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct fmi *fmi = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = fmi->curfreq;
        return 0;
@@ -204,7 +209,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
 
        switch (ctrl->id) {
        case V4L2_CID_AUDIO_MUTE:
-               ctrl->value = fmi->curvol;
+               ctrl->value = fmi->mute;
                return 0;
        }
        return -EINVAL;
@@ -221,7 +226,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
                        fmi_mute(fmi);
                else
                        fmi_unmute(fmi);
-               fmi->curvol = ctrl->value;
+               fmi->mute = ctrl->value;
                return 0;
        }
        return -EINVAL;
@@ -316,26 +321,54 @@ static int __init fmi_init(void)
 {
        struct fmi *fmi = &fmi_card;
        struct v4l2_device *v4l2_dev = &fmi->v4l2_dev;
-       int res;
+       int res, i;
+       int probe_ports[] = { 0, 0x284, 0x384 };
+
+       if (io < 0) {
+               for (i = 0; i < ARRAY_SIZE(probe_ports); i++) {
+                       io = probe_ports[i];
+                       if (io == 0) {
+                               io = isapnp_fmi_probe();
+                               if (io < 0)
+                                       continue;
+                               pnp_attached = 1;
+                       }
+                       if (!request_region(io, 2, "radio-sf16fmi")) {
+                               if (pnp_attached)
+                                       pnp_device_detach(dev);
+                               io = -1;
+                               continue;
+                       }
+                       if (pnp_attached ||
+                           ((inb(io) & 0xf9) == 0xf9 && (inb(io) & 0x4) == 0))
+                               break;
+                       release_region(io, 2);
+                       io = -1;
+               }
+       } else {
+               if (!request_region(io, 2, "radio-sf16fmi")) {
+                       printk(KERN_ERR "radio-sf16fmi: port %#x already in use\n", io);
+                       return -EBUSY;
+               }
+               if (inb(io) == 0xff) {
+                       printk(KERN_ERR "radio-sf16fmi: card not present at %#x\n", io);
+                       release_region(io, 2);
+                       return -ENODEV;
+               }
+       }
+       if (io < 0) {
+               printk(KERN_ERR "radio-sf16fmi: no cards found\n");
+               return -ENODEV;
+       }
 
-       if (io < 0)
-               io = isapnp_fmi_probe();
        strlcpy(v4l2_dev->name, "sf16fmi", sizeof(v4l2_dev->name));
        fmi->io = io;
-       if (fmi->io < 0) {
-               v4l2_err(v4l2_dev, "No PnP card found.\n");
-               return fmi->io;
-       }
-       if (!request_region(io, 2, "radio-sf16fmi")) {
-               v4l2_err(v4l2_dev, "port 0x%x already in use\n", fmi->io);
-               pnp_device_detach(dev);
-               return -EBUSY;
-       }
 
        res = v4l2_device_register(NULL, v4l2_dev);
        if (res < 0) {
                release_region(fmi->io, 2);
-               pnp_device_detach(dev);
+               if (pnp_attached)
+                       pnp_device_detach(dev);
                v4l2_err(v4l2_dev, "Could not register v4l2_device\n");
                return res;
        }
@@ -352,7 +385,8 @@ static int __init fmi_init(void)
        if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
                v4l2_device_unregister(v4l2_dev);
                release_region(fmi->io, 2);
-               pnp_device_detach(dev);
+               if (pnp_attached)
+                       pnp_device_detach(dev);
                return -EINVAL;
        }
 
@@ -369,7 +403,7 @@ static void __exit fmi_exit(void)
        video_unregister_device(&fmi->vdev);
        v4l2_device_unregister(&fmi->v4l2_dev);
        release_region(fmi->io, 2);
-       if (dev)
+       if (dev && pnp_attached)
                pnp_device_detach(dev);
 }
 
index a11414f648d4f9279431b98d103450d4c8926bfd..52c7bbb32b8b7ea10312ff58716c47f1ed472bd2 100644 (file)
@@ -251,6 +251,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct fmr2 *fmr2 = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        if (f->frequency < RSF16_MINFREQ ||
                        f->frequency > RSF16_MAXFREQ)
                return -EINVAL;
@@ -272,6 +274,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct fmr2 *fmr2 = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = fmr2->curfreq;
        return 0;
index 3cd76dddb6aad7ca6fb0eaff71a66385850165f6..8e718bfcdad3200041b3bf458bf893f26cbedf2e 100644 (file)
@@ -314,7 +314,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
        if (v->index > 0)
                return -EINVAL;
 
-       memset(v, 0, sizeof(v));
+       memset(v, 0, sizeof(*v));
        strcpy(v->name, "FM");
        v->type = V4L2_TUNER_RADIO;
        tea5764_i2c_read(radio);
@@ -349,7 +349,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct tea5764_device *radio = video_drvdata(file);
 
-       if (f->tuner != 0)
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
                return -EINVAL;
        if (f->frequency == 0) {
                /* We special case this as a power down control. */
@@ -370,8 +370,10 @@ static int vidioc_g_frequency(struct file *file, void *priv,
        struct tea5764_device *radio = video_drvdata(file);
        struct tea5764_regs *r = &radio->regs;
 
+       if (f->tuner != 0)
+               return -EINVAL;
        tea5764_i2c_read(radio);
-       memset(f, 0, sizeof(f));
+       memset(f, 0, sizeof(*f));
        f->type = V4L2_TUNER_RADIO;
        if (r->tnctrl & TEA5764_TNCTRL_PUPD0)
                f->frequency = (tea5764_get_freq(radio) * 2) / 125;
@@ -458,12 +460,8 @@ static int vidioc_s_audio(struct file *file, void *priv,
 static int tea5764_open(struct file *file)
 {
        /* Currently we support only one device */
-       int minor = video_devdata(file)->minor;
        struct tea5764_device *radio = video_drvdata(file);
 
-       if (radio->videodev->minor != minor)
-               return -ENODEV;
-
        mutex_lock(&radio->mutex);
        /* Only exclusive access */
        if (radio->users) {
index 699db9acaaf79e18df99e0baa9afc708caef9e84..fc1c860fd43844c188d4e42cc845a5f40b4ae957 100644 (file)
@@ -240,6 +240,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct terratec *tt = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        tt_setfreq(tt, f->frequency);
        return 0;
 }
@@ -249,6 +251,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct terratec *tt = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = tt->curfreq;
        return 0;
index 6f9ecc359356c1cc20f93210d5558f072ca66c76..9d6dcf8af5b01de328436a0955ae190fe651aa72 100644 (file)
@@ -239,6 +239,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct trust *tr = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        tr_setfreq(tr, f->frequency);
        return 0;
 }
@@ -248,6 +250,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct trust *tr = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = tr->curfreq;
        return 0;
index 3a98f139949565e23c84ce6ba7cd715b79d36e39..03439282dfce1f18d98d8e6dd12ac8fe8e65adb9 100644 (file)
@@ -207,6 +207,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct typhoon *dev = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = dev->curfreq;
        return 0;
@@ -217,6 +219,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct typhoon *dev = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        dev->curfreq = f->frequency;
        typhoon_setfreq(dev, dev->curfreq);
        return 0;
index 80e98b6422fe76d4d48847f23e0a73199a4472dc..f31eab99c943ba9cdc722e7b3163ed91f079d8a1 100644 (file)
@@ -266,6 +266,8 @@ static int vidioc_s_frequency(struct file *file, void *priv,
 {
        struct zoltrix *zol = video_drvdata(file);
 
+       if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO)
+               return -EINVAL;
        if (zol_setfreq(zol, f->frequency) != 0)
                return -EINVAL;
        return 0;
@@ -276,6 +278,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
 {
        struct zoltrix *zol = video_drvdata(file);
 
+       if (f->tuner != 0)
+               return -EINVAL;
        f->type = V4L2_TUNER_RADIO;
        f->frequency = zol->curfreq;
        return 0;
index f33315f2c5435d253b0563db9667b7e83f73cd44..4da0f150c6e28288cf7ab130f8ffcb4ce669984e 100644 (file)
@@ -425,6 +425,104 @@ int si470x_rds_on(struct si470x_device *radio)
 
 
 
+/**************************************************************************
+ * File Operations Interface
+ **************************************************************************/
+
+/*
+ * si470x_fops_read - read RDS data
+ */
+static ssize_t si470x_fops_read(struct file *file, char __user *buf,
+               size_t count, loff_t *ppos)
+{
+       struct si470x_device *radio = video_drvdata(file);
+       int retval = 0;
+       unsigned int block_count = 0;
+
+       /* switch on rds reception */
+       if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
+               si470x_rds_on(radio);
+
+       /* block if no new data available */
+       while (radio->wr_index == radio->rd_index) {
+               if (file->f_flags & O_NONBLOCK) {
+                       retval = -EWOULDBLOCK;
+                       goto done;
+               }
+               if (wait_event_interruptible(radio->read_queue,
+                       radio->wr_index != radio->rd_index) < 0) {
+                       retval = -EINTR;
+                       goto done;
+               }
+       }
+
+       /* calculate block count from byte count */
+       count /= 3;
+
+       /* copy RDS block out of internal buffer and to user buffer */
+       mutex_lock(&radio->lock);
+       while (block_count < count) {
+               if (radio->rd_index == radio->wr_index)
+                       break;
+
+               /* always transfer rds complete blocks */
+               if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3))
+                       /* retval = -EFAULT; */
+                       break;
+
+               /* increment and wrap read pointer */
+               radio->rd_index += 3;
+               if (radio->rd_index >= radio->buf_size)
+                       radio->rd_index = 0;
+
+               /* increment counters */
+               block_count++;
+               buf += 3;
+               retval += 3;
+       }
+       mutex_unlock(&radio->lock);
+
+done:
+       return retval;
+}
+
+
+/*
+ * si470x_fops_poll - poll RDS data
+ */
+static unsigned int si470x_fops_poll(struct file *file,
+               struct poll_table_struct *pts)
+{
+       struct si470x_device *radio = video_drvdata(file);
+       int retval = 0;
+
+       /* switch on rds reception */
+       if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
+               si470x_rds_on(radio);
+
+       poll_wait(file, &radio->read_queue, pts);
+
+       if (radio->rd_index != radio->wr_index)
+               retval = POLLIN | POLLRDNORM;
+
+       return retval;
+}
+
+
+/*
+ * si470x_fops - file operations interface
+ */
+static const struct v4l2_file_operations si470x_fops = {
+       .owner                  = THIS_MODULE,
+       .read                   = si470x_fops_read,
+       .poll                   = si470x_fops_poll,
+       .ioctl                  = video_ioctl2,
+       .open                   = si470x_fops_open,
+       .release                = si470x_fops_release,
+};
+
+
+
 /**************************************************************************
  * Video4Linux Interface
  **************************************************************************/
index 2d53b6a9409b52a7d70001a38c1b6d73af16d599..5466015346a10be27b191659ff285d20b7d195bc 100644 (file)
  */
 
 
-/*
- * ToDo:
- * - RDS support
- */
-
-
 /* driver definitions */
 #define DRIVER_AUTHOR "Joonyoung Shim <jy0922.shim@samsung.com>";
-#define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 0)
+#define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 1)
 #define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
 #define DRIVER_DESC "I2C radio driver for Si470x FM Radio Receivers"
-#define DRIVER_VERSION "1.0.0"
+#define DRIVER_VERSION "1.0.1"
 
 /* kernel includes */
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <linux/interrupt.h>
 
 #include "radio-si470x.h"
 
@@ -62,6 +57,20 @@ static int radio_nr = -1;
 module_param(radio_nr, int, 0444);
 MODULE_PARM_DESC(radio_nr, "Radio Nr");
 
+/* RDS buffer blocks */
+static unsigned int rds_buf = 100;
+module_param(rds_buf, uint, 0444);
+MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*");
+
+/* RDS maximum block errors */
+static unsigned short max_rds_errors = 1;
+/* 0 means   0  errors requiring correction */
+/* 1 means 1-2  errors requiring correction (used by original USBRadio.exe) */
+/* 2 means 3-5  errors requiring correction */
+/* 3 means   6+ errors or errors in checkword, correction not possible */
+module_param(max_rds_errors, ushort, 0644);
+MODULE_PARM_DESC(max_rds_errors, "RDS maximum block errors: *1*");
+
 
 
 /**************************************************************************
@@ -173,7 +182,7 @@ int si470x_disconnect_check(struct si470x_device *radio)
 /*
  * si470x_fops_open - file open
  */
-static int si470x_fops_open(struct file *file)
+int si470x_fops_open(struct file *file)
 {
        struct si470x_device *radio = video_drvdata(file);
        int retval = 0;
@@ -181,12 +190,21 @@ static int si470x_fops_open(struct file *file)
        mutex_lock(&radio->lock);
        radio->users++;
 
-       if (radio->users == 1)
+       if (radio->users == 1) {
                /* start radio */
                retval = si470x_start(radio);
+               if (retval < 0)
+                       goto done;
+
+               /* enable RDS interrupt */
+               radio->registers[SYSCONFIG1] |= SYSCONFIG1_RDSIEN;
+               radio->registers[SYSCONFIG1] &= ~SYSCONFIG1_GPIO2;
+               radio->registers[SYSCONFIG1] |= 0x1 << 2;
+               retval = si470x_set_register(radio, SYSCONFIG1);
+       }
 
+done:
        mutex_unlock(&radio->lock);
-
        return retval;
 }
 
@@ -194,7 +212,7 @@ static int si470x_fops_open(struct file *file)
 /*
  * si470x_fops_release - file release
  */
-static int si470x_fops_release(struct file *file)
+int si470x_fops_release(struct file *file)
 {
        struct si470x_device *radio = video_drvdata(file);
        int retval = 0;
@@ -215,17 +233,6 @@ static int si470x_fops_release(struct file *file)
 }
 
 
-/*
- * si470x_fops - file operations interface
- */
-const struct v4l2_file_operations si470x_fops = {
-       .owner          = THIS_MODULE,
-       .ioctl          = video_ioctl2,
-       .open           = si470x_fops_open,
-       .release        = si470x_fops_release,
-};
-
-
 
 /**************************************************************************
  * Video4Linux Interface
@@ -252,6 +259,105 @@ int si470x_vidioc_querycap(struct file *file, void *priv,
  * I2C Interface
  **************************************************************************/
 
+/*
+ * si470x_i2c_interrupt_work - rds processing function
+ */
+static void si470x_i2c_interrupt_work(struct work_struct *work)
+{
+       struct si470x_device *radio = container_of(work,
+                       struct si470x_device, radio_work);
+       unsigned char regnr;
+       unsigned char blocknum;
+       unsigned short bler; /* rds block errors */
+       unsigned short rds;
+       unsigned char tmpbuf[3];
+       int retval = 0;
+
+       /* safety checks */
+       if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
+               return;
+
+       /* Update RDS registers */
+       for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++) {
+               retval = si470x_get_register(radio, STATUSRSSI + regnr);
+               if (retval < 0)
+                       return;
+       }
+
+       /* get rds blocks */
+       if ((radio->registers[STATUSRSSI] & STATUSRSSI_RDSR) == 0)
+               /* No RDS group ready, better luck next time */
+               return;
+
+       for (blocknum = 0; blocknum < 4; blocknum++) {
+               switch (blocknum) {
+               default:
+                       bler = (radio->registers[STATUSRSSI] &
+                                       STATUSRSSI_BLERA) >> 9;
+                       rds = radio->registers[RDSA];
+                       break;
+               case 1:
+                       bler = (radio->registers[READCHAN] &
+                                       READCHAN_BLERB) >> 14;
+                       rds = radio->registers[RDSB];
+                       break;
+               case 2:
+                       bler = (radio->registers[READCHAN] &
+                                       READCHAN_BLERC) >> 12;
+                       rds = radio->registers[RDSC];
+                       break;
+               case 3:
+                       bler = (radio->registers[READCHAN] &
+                                       READCHAN_BLERD) >> 10;
+                       rds = radio->registers[RDSD];
+                       break;
+               };
+
+               /* Fill the V4L2 RDS buffer */
+               put_unaligned_le16(rds, &tmpbuf);
+               tmpbuf[2] = blocknum;           /* offset name */
+               tmpbuf[2] |= blocknum << 3;     /* received offset */
+               if (bler > max_rds_errors)
+                       tmpbuf[2] |= 0x80;      /* uncorrectable errors */
+               else if (bler > 0)
+                       tmpbuf[2] |= 0x40;      /* corrected error(s) */
+
+               /* copy RDS block to internal buffer */
+               memcpy(&radio->buffer[radio->wr_index], &tmpbuf, 3);
+               radio->wr_index += 3;
+
+               /* wrap write pointer */
+               if (radio->wr_index >= radio->buf_size)
+                       radio->wr_index = 0;
+
+               /* check for overflow */
+               if (radio->wr_index == radio->rd_index) {
+                       /* increment and wrap read pointer */
+                       radio->rd_index += 3;
+                       if (radio->rd_index >= radio->buf_size)
+                               radio->rd_index = 0;
+               }
+       }
+
+       if (radio->wr_index != radio->rd_index)
+               wake_up_interruptible(&radio->read_queue);
+}
+
+
+/*
+ * si470x_i2c_interrupt - interrupt handler
+ */
+static irqreturn_t si470x_i2c_interrupt(int irq, void *dev_id)
+{
+       struct si470x_device *radio = dev_id;
+
+       if (!work_pending(&radio->radio_work))
+               schedule_work(&radio->radio_work);
+
+       return IRQ_HANDLED;
+}
+
+
 /*
  * si470x_i2c_probe - probe for the device
  */
@@ -268,6 +374,8 @@ static int __devinit si470x_i2c_probe(struct i2c_client *client,
                retval = -ENOMEM;
                goto err_initial;
        }
+
+       INIT_WORK(&radio->radio_work, si470x_i2c_interrupt_work);
        radio->users = 0;
        radio->client = client;
        mutex_init(&radio->lock);
@@ -319,6 +427,26 @@ static int __devinit si470x_i2c_probe(struct i2c_client *client,
        /* set initial frequency */
        si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
 
+       /* rds buffer allocation */
+       radio->buf_size = rds_buf * 3;
+       radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL);
+       if (!radio->buffer) {
+               retval = -EIO;
+               goto err_video;
+       }
+
+       /* rds buffer configuration */
+       radio->wr_index = 0;
+       radio->rd_index = 0;
+       init_waitqueue_head(&radio->read_queue);
+
+       retval = request_irq(client->irq, si470x_i2c_interrupt,
+                       IRQF_TRIGGER_FALLING, DRIVER_NAME, radio);
+       if (retval) {
+               dev_err(&client->dev, "Failed to register interrupt\n");
+               goto err_rds;
+       }
+
        /* register video device */
        retval = video_register_device(radio->videodev, VFL_TYPE_RADIO,
                        radio_nr);
@@ -330,6 +458,9 @@ static int __devinit si470x_i2c_probe(struct i2c_client *client,
 
        return 0;
 err_all:
+       free_irq(client->irq, radio);
+err_rds:
+       kfree(radio->buffer);
 err_video:
        video_device_release(radio->videodev);
 err_radio:
@@ -346,6 +477,8 @@ static __devexit int si470x_i2c_remove(struct i2c_client *client)
 {
        struct si470x_device *radio = i2c_get_clientdata(client);
 
+       free_irq(client->irq, radio);
+       cancel_work_sync(&radio->radio_work);
        video_unregister_device(radio->videodev);
        kfree(radio);
        i2c_set_clientdata(client, NULL);
@@ -354,6 +487,44 @@ static __devexit int si470x_i2c_remove(struct i2c_client *client)
 }
 
 
+#ifdef CONFIG_PM
+/*
+ * si470x_i2c_suspend - suspend the device
+ */
+static int si470x_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+       struct si470x_device *radio = i2c_get_clientdata(client);
+
+       /* power down */
+       radio->registers[POWERCFG] |= POWERCFG_DISABLE;
+       if (si470x_set_register(radio, POWERCFG) < 0)
+               return -EIO;
+
+       return 0;
+}
+
+
+/*
+ * si470x_i2c_resume - resume the device
+ */
+static int si470x_i2c_resume(struct i2c_client *client)
+{
+       struct si470x_device *radio = i2c_get_clientdata(client);
+
+       /* power up : need 110ms */
+       radio->registers[POWERCFG] |= POWERCFG_ENABLE;
+       if (si470x_set_register(radio, POWERCFG) < 0)
+               return -EIO;
+       msleep(110);
+
+       return 0;
+}
+#else
+#define si470x_i2c_suspend     NULL
+#define si470x_i2c_resume      NULL
+#endif
+
+
 /*
  * si470x_i2c_driver - i2c driver interface
  */
@@ -364,6 +535,8 @@ static struct i2c_driver si470x_i2c_driver = {
        },
        .probe                  = si470x_i2c_probe,
        .remove                 = __devexit_p(si470x_i2c_remove),
+       .suspend                = si470x_i2c_suspend,
+       .resume                 = si470x_i2c_resume,
        .id_table               = si470x_i2c_id,
 };
 
index f2d0e1ddb3016bab7394e1923d63450645342f33..a96e1b9dd646485431a3ed278b46080a9c3b8bb7 100644 (file)
@@ -508,90 +508,10 @@ resubmit:
  * File Operations Interface
  **************************************************************************/
 
-/*
- * si470x_fops_read - read RDS data
- */
-static ssize_t si470x_fops_read(struct file *file, char __user *buf,
-               size_t count, loff_t *ppos)
-{
-       struct si470x_device *radio = video_drvdata(file);
-       int retval = 0;
-       unsigned int block_count = 0;
-
-       /* switch on rds reception */
-       if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
-               si470x_rds_on(radio);
-
-       /* block if no new data available */
-       while (radio->wr_index == radio->rd_index) {
-               if (file->f_flags & O_NONBLOCK) {
-                       retval = -EWOULDBLOCK;
-                       goto done;
-               }
-               if (wait_event_interruptible(radio->read_queue,
-                       radio->wr_index != radio->rd_index) < 0) {
-                       retval = -EINTR;
-                       goto done;
-               }
-       }
-
-       /* calculate block count from byte count */
-       count /= 3;
-
-       /* copy RDS block out of internal buffer and to user buffer */
-       mutex_lock(&radio->lock);
-       while (block_count < count) {
-               if (radio->rd_index == radio->wr_index)
-                       break;
-
-               /* always transfer rds complete blocks */
-               if (copy_to_user(buf, &radio->buffer[radio->rd_index], 3))
-                       /* retval = -EFAULT; */
-                       break;
-
-               /* increment and wrap read pointer */
-               radio->rd_index += 3;
-               if (radio->rd_index >= radio->buf_size)
-                       radio->rd_index = 0;
-
-               /* increment counters */
-               block_count++;
-               buf += 3;
-               retval += 3;
-       }
-       mutex_unlock(&radio->lock);
-
-done:
-       return retval;
-}
-
-
-/*
- * si470x_fops_poll - poll RDS data
- */
-static unsigned int si470x_fops_poll(struct file *file,
-               struct poll_table_struct *pts)
-{
-       struct si470x_device *radio = video_drvdata(file);
-       int retval = 0;
-
-       /* switch on rds reception */
-       if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0)
-               si470x_rds_on(radio);
-
-       poll_wait(file, &radio->read_queue, pts);
-
-       if (radio->rd_index != radio->wr_index)
-               retval = POLLIN | POLLRDNORM;
-
-       return retval;
-}
-
-
 /*
  * si470x_fops_open - file open
  */
-static int si470x_fops_open(struct file *file)
+int si470x_fops_open(struct file *file)
 {
        struct si470x_device *radio = video_drvdata(file);
        int retval;
@@ -645,7 +565,7 @@ done:
 /*
  * si470x_fops_release - file release
  */
-static int si470x_fops_release(struct file *file)
+int si470x_fops_release(struct file *file)
 {
        struct si470x_device *radio = video_drvdata(file);
        int retval = 0;
@@ -688,19 +608,6 @@ done:
 }
 
 
-/*
- * si470x_fops - file operations interface
- */
-const struct v4l2_file_operations si470x_fops = {
-       .owner          = THIS_MODULE,
-       .read           = si470x_fops_read,
-       .poll           = si470x_fops_poll,
-       .ioctl          = video_ioctl2,
-       .open           = si470x_fops_open,
-       .release        = si470x_fops_release,
-};
-
-
 
 /**************************************************************************
  * Video4Linux Interface
index d0af194d194c9e07e4a5fa6ff698f4b8b8f20bbf..3cd0a29cd6e79bf6a3ecc13dd642fc163577633d 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
 #include <linux/input.h>
@@ -181,6 +182,7 @@ struct si470x_device {
 
 #if defined(CONFIG_I2C_SI470X) || defined(CONFIG_I2C_SI470X_MODULE)
        struct i2c_client *client;
+       struct work_struct radio_work;
 #endif
 };
 
@@ -212,7 +214,6 @@ struct si470x_device {
 /**************************************************************************
  * Common Functions
  **************************************************************************/
-extern const struct v4l2_file_operations si470x_fops;
 extern struct video_device si470x_viddev_template;
 int si470x_get_register(struct si470x_device *radio, int regnr);
 int si470x_set_register(struct si470x_device *radio, int regnr);
@@ -221,5 +222,7 @@ int si470x_set_freq(struct si470x_device *radio, unsigned int freq);
 int si470x_start(struct si470x_device *radio);
 int si470x_stop(struct si470x_device *radio);
 int si470x_rds_on(struct si470x_device *radio);
+int si470x_fops_open(struct file *file);
+int si470x_fops_release(struct file *file);
 int si470x_vidioc_querycap(struct file *file, void *priv,
                struct v4l2_capability *capability);
index 9dc74c93bf245e29657b16852ed59169bb3f6695..2f83be766d9f5d5e44b7821274571d256796669b 100644 (file)
@@ -37,10 +37,6 @@ config VIDEO_BTCX
        depends on PCI
        tristate
 
-config VIDEO_IR
-       tristate
-       depends on INPUT
-
 config VIDEO_TVEEPROM
        tristate
        depends on I2C
@@ -840,6 +836,12 @@ config SOC_CAMERA_MT9T031
        help
          This driver supports MT9T031 cameras from Micron.
 
+config SOC_CAMERA_MT9T112
+       tristate "mt9t112 support"
+       depends on SOC_CAMERA && I2C
+       help
+         This driver supports MT9T112 cameras from Aptina.
+
 config SOC_CAMERA_MT9V022
        tristate "mt9v022 support"
        depends on SOC_CAMERA && I2C
index 7a2dcc34111c4437fac00dfd46e5c3a4e079d21e..2af68ee841225813409c233af39bc46f4d315d76 100644 (file)
@@ -75,6 +75,7 @@ obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o
 obj-$(CONFIG_SOC_CAMERA_MT9M001)       += mt9m001.o
 obj-$(CONFIG_SOC_CAMERA_MT9M111)       += mt9m111.o
 obj-$(CONFIG_SOC_CAMERA_MT9T031)       += mt9t031.o
+obj-$(CONFIG_SOC_CAMERA_MT9T112)       += mt9t112.o
 obj-$(CONFIG_SOC_CAMERA_MT9V022)       += mt9v022.o
 obj-$(CONFIG_SOC_CAMERA_OV772X)                += ov772x.o
 obj-$(CONFIG_SOC_CAMERA_OV9640)                += ov9640.o
@@ -149,7 +150,7 @@ obj-$(CONFIG_VIDEO_VIVI) += vivi.o
 obj-$(CONFIG_VIDEO_CX23885) += cx23885/
 
 obj-$(CONFIG_VIDEO_OMAP2)              += omap2cam.o
-obj-$(CONFIG_SOC_CAMERA)               += soc_camera.o
+obj-$(CONFIG_SOC_CAMERA)               += soc_camera.o soc_mediabus.o
 obj-$(CONFIG_SOC_CAMERA_PLATFORM)      += soc_camera_platform.o
 # soc-camera host drivers have to be linked after camera drivers
 obj-$(CONFIG_VIDEO_MX1)                        += mx1_camera.o
index d137bac84511eb9c3dfdb7c61aef5140a163ec5a..a356d6bd3131c0ba2c57f518e1cd680d56868167 100644 (file)
@@ -767,7 +767,6 @@ static struct video_device ar_template = {
        .name           = "Colour AR VGA",
        .fops           = &ar_fops,
        .release        = ar_release,
-       .minor          = -1,
 };
 
 #define ALIGN4(x)      ((((int)(x)) & 0x3) == 0)
@@ -860,8 +859,8 @@ static int __init ar_init(void)
                goto out_dev;
        }
 
-       printk("video%d: Found M64278 VGA (IRQ %d, Freq %dMHz).\n",
-               ar->vdev->num, M32R_IRQ_INT3, freq);
+       printk("%s: Found M64278 VGA (IRQ %d, Freq %dMHz).\n",
+               video_device_node_name(ar->vdev), M32R_IRQ_INT3, freq);
 
        return 0;
 
index 1485aee18d582c708c0c60b0579581bdbed2d3b1..dc67bc40f36fb60e4d21973f966a2fab39b64522 100644 (file)
@@ -40,7 +40,6 @@
 #include "au0828.h"
 #include "au0828-reg.h"
 
-static LIST_HEAD(au0828_devlist);
 static DEFINE_MUTEX(au0828_sysfs_lock);
 
 #define AU0828_VERSION_CODE KERNEL_VERSION(0, 0, 1)
@@ -693,10 +692,8 @@ void au0828_analog_unregister(struct au0828_dev *dev)
        dprintk(1, "au0828_release_resources called\n");
        mutex_lock(&au0828_sysfs_lock);
 
-       if (dev->vdev) {
-               list_del(&dev->au0828list);
+       if (dev->vdev)
                video_unregister_device(dev->vdev);
-       }
        if (dev->vbi_dev)
                video_unregister_device(dev->vbi_dev);
 
@@ -737,29 +734,15 @@ static void res_free(struct au0828_fh *fh)
 
 static int au0828_v4l2_open(struct file *filp)
 {
-       int minor = video_devdata(filp)->minor;
        int ret = 0;
-       struct au0828_dev *h, *dev = NULL;
+       struct au0828_dev *dev = video_drvdata(filp);
        struct au0828_fh *fh;
-       int type = 0;
-       struct list_head *list;
-
-       list_for_each(list, &au0828_devlist) {
-               h = list_entry(list, struct au0828_dev, au0828list);
-               if (h->vdev->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
+       int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
 #ifdef VBI_IS_WORKING
-               if (h->vbi_dev->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VBI_CAPTURE;
-               }
+       if (video_devdata(filp)->vfl_type == VFL_TYPE_GRABBER)
+               type = V4L2_BUF_TYPE_VBI_CAPTURE;
 #endif
-       }
-
-       if (NULL == dev)
-               return -ENODEV;
 
        fh = kzalloc(sizeof(struct au0828_fh), GFP_KERNEL);
        if (NULL == fh) {
@@ -1587,7 +1570,6 @@ static const struct video_device au0828_video_template = {
        .fops                       = &au0828_v4l_fops,
        .release                    = video_device_release,
        .ioctl_ops                  = &video_ioctl_ops,
-       .minor                      = -1,
        .tvnorms                    = V4L2_STD_NTSC_M,
        .current_norm               = V4L2_STD_NTSC_M,
 };
@@ -1676,25 +1658,23 @@ int au0828_analog_register(struct au0828_dev *dev,
        strcpy(dev->vbi_dev->name, "au0828a vbi");
 #endif
 
-       list_add_tail(&dev->au0828list, &au0828_devlist);
-
        /* Register the v4l2 device */
+       video_set_drvdata(dev->vdev, dev);
        retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1);
        if (retval != 0) {
                dprintk(1, "unable to register video device (error = %d).\n",
                        retval);
-               list_del(&dev->au0828list);
                video_device_release(dev->vdev);
                return -ENODEV;
        }
 
 #ifdef VBI_IS_WORKING
        /* Register the vbi device */
+       video_set_drvdata(dev->vbi_dev, dev);
        retval = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, -1);
        if (retval != 0) {
                dprintk(1, "unable to register vbi device (error = %d).\n",
                        retval);
-               list_del(&dev->au0828list);
                video_device_release(dev->vbi_dev);
                video_device_release(dev->vdev);
                return -ENODEV;
index b977915efbd0a0eaa52636c7e8cfb1c2a79d8a55..207f32dec6a6b38a3a3d578896d2e18026349b3d 100644 (file)
@@ -192,7 +192,6 @@ struct au0828_dev {
        struct au0828_dvb               dvb;
 
        /* Analog */
-       struct list_head au0828list;
        struct v4l2_device v4l2_dev;
        int users;
        unsigned int stream_on:1;       /* Locks streams */
index a6724019c66f5d9d121edd285a89e73772e7e350..3182a406bdd1ad11ae7f3ba41bd44fa543dd764a 100644 (file)
@@ -3206,24 +3206,24 @@ err:
 
 static int bttv_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
+       struct video_device *vdev = video_devdata(file);
        struct bttv *btv = video_drvdata(file);
        struct bttv_fh *fh;
        enum v4l2_buf_type type = 0;
 
-       dprintk(KERN_DEBUG "bttv: open minor=%d\n",minor);
+       dprintk(KERN_DEBUG "bttv: open dev=%s\n", video_device_node_name(vdev));
 
-       lock_kernel();
-       if (btv->video_dev->minor == minor) {
+       if (vdev->vfl_type == VFL_TYPE_GRABBER) {
                type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       } else if (btv->vbi_dev->minor == minor) {
+       } else if (vdev->vfl_type == VFL_TYPE_VBI) {
                type = V4L2_BUF_TYPE_VBI_CAPTURE;
        } else {
                WARN_ON(1);
-               unlock_kernel();
                return -ENODEV;
        }
 
+       lock_kernel();
+
        dprintk(KERN_DEBUG "bttv%d: open called (type=%s)\n",
                btv->c.nr,v4l2_type_names[type]);
 
@@ -3397,7 +3397,6 @@ static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
 
 static struct video_device bttv_video_template = {
        .fops         = &bttv_fops,
-       .minor        = -1,
        .ioctl_ops    = &bttv_ioctl_ops,
        .tvnorms      = BTTV_NORMS,
        .current_norm = V4L2_STD_PAL,
@@ -3408,18 +3407,13 @@ static struct video_device bttv_video_template = {
 
 static int radio_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
+       struct video_device *vdev = video_devdata(file);
        struct bttv *btv = video_drvdata(file);
        struct bttv_fh *fh;
 
-       dprintk("bttv: open minor=%d\n",minor);
+       dprintk("bttv: open dev=%s\n", video_device_node_name(vdev));
 
        lock_kernel();
-       WARN_ON(btv->radio_dev && btv->radio_dev->minor != minor);
-       if (!btv->radio_dev || btv->radio_dev->minor != minor) {
-               unlock_kernel();
-               return -ENODEV;
-       }
 
        dprintk("bttv%d: open called (radio)\n",btv->c.nr);
 
@@ -3640,7 +3634,6 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
 
 static struct video_device radio_template = {
        .fops      = &radio_fops,
-       .minor     = -1,
        .ioctl_ops = &radio_ioctl_ops,
 };
 
@@ -4208,21 +4201,21 @@ static struct video_device *vdev_init(struct bttv *btv,
 static void bttv_unregister_video(struct bttv *btv)
 {
        if (btv->video_dev) {
-               if (-1 != btv->video_dev->minor)
+               if (video_is_registered(btv->video_dev))
                        video_unregister_device(btv->video_dev);
                else
                        video_device_release(btv->video_dev);
                btv->video_dev = NULL;
        }
        if (btv->vbi_dev) {
-               if (-1 != btv->vbi_dev->minor)
+               if (video_is_registered(btv->vbi_dev))
                        video_unregister_device(btv->vbi_dev);
                else
                        video_device_release(btv->vbi_dev);
                btv->vbi_dev = NULL;
        }
        if (btv->radio_dev) {
-               if (-1 != btv->radio_dev->minor)
+               if (video_is_registered(btv->radio_dev))
                        video_unregister_device(btv->radio_dev);
                else
                        video_device_release(btv->radio_dev);
@@ -4244,8 +4237,8 @@ static int __devinit bttv_register_video(struct bttv *btv)
        if (video_register_device(btv->video_dev, VFL_TYPE_GRABBER,
                                  video_nr[btv->c.nr]) < 0)
                goto err;
-       printk(KERN_INFO "bttv%d: registered device video%d\n",
-              btv->c.nr, btv->video_dev->num);
+       printk(KERN_INFO "bttv%d: registered device %s\n",
+              btv->c.nr, video_device_node_name(btv->video_dev));
        if (device_create_file(&btv->video_dev->dev,
                                     &dev_attr_card)<0) {
                printk(KERN_ERR "bttv%d: device_create_file 'card' "
@@ -4261,8 +4254,8 @@ static int __devinit bttv_register_video(struct bttv *btv)
        if (video_register_device(btv->vbi_dev, VFL_TYPE_VBI,
                                  vbi_nr[btv->c.nr]) < 0)
                goto err;
-       printk(KERN_INFO "bttv%d: registered device vbi%d\n",
-              btv->c.nr, btv->vbi_dev->num);
+       printk(KERN_INFO "bttv%d: registered device %s\n",
+              btv->c.nr, video_device_node_name(btv->vbi_dev));
 
        if (!btv->has_radio)
                return 0;
@@ -4273,8 +4266,8 @@ static int __devinit bttv_register_video(struct bttv *btv)
        if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO,
                                  radio_nr[btv->c.nr]) < 0)
                goto err;
-       printk(KERN_INFO "bttv%d: registered device radio%d\n",
-              btv->c.nr, btv->radio_dev->num);
+       printk(KERN_INFO "bttv%d: registered device %s\n",
+              btv->c.nr, video_device_node_name(btv->radio_dev));
 
        /* all done */
        return 0;
index beda363418b0e6f28c5bc1ed1342ef16a9676817..63aa31a041e848846998515f1b1dc825ebc62c5a 100644 (file)
@@ -40,7 +40,7 @@ static int i2c_debug;
 static int i2c_hw;
 static int i2c_scan;
 module_param(i2c_debug, int, 0644);
-MODULE_PARM_DESC(i2c_hw,"configure i2c debug level");
+MODULE_PARM_DESC(i2c_debug, "configure i2c debug level");
 module_param(i2c_hw,    int, 0444);
 MODULE_PARM_DESC(i2c_hw,"force use of hardware i2c support, "
                        "instead of software bitbang");
@@ -400,7 +400,7 @@ int __devinit init_bttv_i2c(struct bttv *btv)
                   That's why we probe 0x1a (~0x34) first. CB
                */
                const unsigned short addr_list[] = {
-                       0x1a, 0x18, 0x4b, 0x64, 0x30,
+                       0x1a, 0x18, 0x4b, 0x64, 0x30, 0x71,
                        I2C_CLIENT_END
                };
 
index 84a957e52c4b4600adcd89b47a12abfde4703080..277a092e1214df0b4b80fc9ddf4ff0655ed32367 100644 (file)
@@ -368,7 +368,7 @@ int bttv_input_init(struct bttv *btv)
        snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
                 pci_name(btv->c.pci));
 
-       err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
+       err = ir_input_init(input_dev, &ir->ir, ir_type);
        if (err < 0)
                goto err_out_free;
 
@@ -389,7 +389,7 @@ int bttv_input_init(struct bttv *btv)
        bttv_ir_start(btv, ir);
 
        /* all done */
-       err = input_register_device(btv->remote->dev);
+       err = ir_input_register(btv->remote->dev, ir_codes);
        if (err)
                goto err_out_stop;
 
@@ -403,8 +403,6 @@ int bttv_input_init(struct bttv *btv)
        bttv_ir_stop(btv);
        btv->remote = NULL;
  err_out_free:
-       ir_input_free(input_dev);
-       input_free_device(input_dev);
        kfree(ir);
        return err;
 }
@@ -415,8 +413,7 @@ void bttv_input_fini(struct bttv *btv)
                return;
 
        bttv_ir_stop(btv);
-       ir_input_free(btv->remote->dev);
-       input_unregister_device(btv->remote->dev);
+       ir_input_unregister(btv->remote->dev);
        kfree(btv->remote);
        btv->remote = NULL;
 }
index 85cf1778827adee718ba6ad930bfec12d37be25d..e2cbebab959bdffffb51a8347cfaf86db14d45f5 100644 (file)
@@ -809,8 +809,8 @@ static int init_cqcam(struct parport *port)
                return -ENODEV;
        }
 
-       printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
-              qcam->vdev.num, qcam->pport->name);
+       printk(KERN_INFO "%s: Colour QuickCam found on %s\n",
+              video_device_node_name(&qcam->vdev), qcam->pport->name);
 
        qcams[num_cams++] = qcam;
 
index 10230cb3d210ffd18927fcd023df5f1b58478114..7bb9c1ec7819fc7b6d83076b98fb8eae41ede5f8 100644 (file)
@@ -1723,7 +1723,6 @@ static const struct v4l2_ioctl_ops cafe_v4l_ioctl_ops = {
 
 static struct video_device cafe_v4l_template = {
        .name = "cafe",
-       .minor = -1, /* Get one dynamically */
        .tvnorms = V4L2_STD_NTSC_M,
        .current_norm = V4L2_STD_NTSC_M,  /* make mplayer happy */
 
index 2377313c041a8c33976db18f0c1ef7a698c94bd6..551ddf216a4bb21d51b9c6425a992946594d0e0f 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/fs.h>
 #include <linux/vmalloc.h>
 #include <linux/sched.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/ctype.h>
@@ -244,72 +245,67 @@ static void rvfree(void *mem, unsigned long size)
 #ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *cpia_proc_root=NULL;
 
-static int cpia_read_proc(char *page, char **start, off_t off,
-                         int count, int *eof, void *data)
+static int cpia_proc_show(struct seq_file *m, void *v)
 {
-       char *out = page;
-       int len, tmp;
-       struct cam_data *cam = data;
+       struct cam_data *cam = m->private;
+       int tmp;
        char tmpstr[29];
 
-       /* IMPORTANT: This output MUST be kept under PAGE_SIZE
-        *            or we need to get more sophisticated. */
-
-       out += sprintf(out, "read-only\n-----------------------\n");
-       out += sprintf(out, "V4L Driver version:       %d.%d.%d\n",
+       seq_printf(m, "read-only\n-----------------------\n");
+       seq_printf(m, "V4L Driver version:       %d.%d.%d\n",
                       CPIA_MAJ_VER, CPIA_MIN_VER, CPIA_PATCH_VER);
-       out += sprintf(out, "CPIA Version:             %d.%02d (%d.%d)\n",
+       seq_printf(m, "CPIA Version:             %d.%02d (%d.%d)\n",
                       cam->params.version.firmwareVersion,
                       cam->params.version.firmwareRevision,
                       cam->params.version.vcVersion,
                       cam->params.version.vcRevision);
-       out += sprintf(out, "CPIA PnP-ID:              %04x:%04x:%04x\n",
+       seq_printf(m, "CPIA PnP-ID:              %04x:%04x:%04x\n",
                       cam->params.pnpID.vendor, cam->params.pnpID.product,
                       cam->params.pnpID.deviceRevision);
-       out += sprintf(out, "VP-Version:               %d.%d %04x\n",
+       seq_printf(m, "VP-Version:               %d.%d %04x\n",
                       cam->params.vpVersion.vpVersion,
                       cam->params.vpVersion.vpRevision,
                       cam->params.vpVersion.cameraHeadID);
 
-       out += sprintf(out, "system_state:             %#04x\n",
+       seq_printf(m, "system_state:             %#04x\n",
                       cam->params.status.systemState);
-       out += sprintf(out, "grab_state:               %#04x\n",
+       seq_printf(m, "grab_state:               %#04x\n",
                       cam->params.status.grabState);
-       out += sprintf(out, "stream_state:             %#04x\n",
+       seq_printf(m, "stream_state:             %#04x\n",
                       cam->params.status.streamState);
-       out += sprintf(out, "fatal_error:              %#04x\n",
+       seq_printf(m, "fatal_error:              %#04x\n",
                       cam->params.status.fatalError);
-       out += sprintf(out, "cmd_error:                %#04x\n",
+       seq_printf(m, "cmd_error:                %#04x\n",
                       cam->params.status.cmdError);
-       out += sprintf(out, "debug_flags:              %#04x\n",
+       seq_printf(m, "debug_flags:              %#04x\n",
                       cam->params.status.debugFlags);
-       out += sprintf(out, "vp_status:                %#04x\n",
+       seq_printf(m, "vp_status:                %#04x\n",
                       cam->params.status.vpStatus);
-       out += sprintf(out, "error_code:               %#04x\n",
+       seq_printf(m, "error_code:               %#04x\n",
                       cam->params.status.errorCode);
        /* QX3 specific entries */
        if (cam->params.qx3.qx3_detected) {
-               out += sprintf(out, "button:                   %4d\n",
+               seq_printf(m, "button:                   %4d\n",
                               cam->params.qx3.button);
-               out += sprintf(out, "cradled:                  %4d\n",
+               seq_printf(m, "cradled:                  %4d\n",
                               cam->params.qx3.cradled);
        }
-       out += sprintf(out, "video_size:               %s\n",
+       seq_printf(m, "video_size:               %s\n",
                       cam->params.format.videoSize == VIDEOSIZE_CIF ?
                       "CIF " : "QCIF");
-       out += sprintf(out, "roi:                      (%3d, %3d) to (%3d, %3d)\n",
+       seq_printf(m, "roi:                      (%3d, %3d) to (%3d, %3d)\n",
                       cam->params.roi.colStart*8,
                       cam->params.roi.rowStart*4,
                       cam->params.roi.colEnd*8,
                       cam->params.roi.rowEnd*4);
-       out += sprintf(out, "actual_fps:               %3d\n", cam->fps);
-       out += sprintf(out, "transfer_rate:            %4dkB/s\n",
+       seq_printf(m, "actual_fps:               %3d\n", cam->fps);
+       seq_printf(m, "transfer_rate:            %4dkB/s\n",
                       cam->transfer_rate);
 
-       out += sprintf(out, "\nread-write\n");
-       out += sprintf(out, "-----------------------  current       min"
+       seq_printf(m, "\nread-write\n");
+       seq_printf(m, "-----------------------  current       min"
                       "       max   default  comment\n");
-       out += sprintf(out, "brightness:             %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "brightness:             %8d  %8d  %8d  %8d\n",
                       cam->params.colourParams.brightness, 0, 100, 50);
        if (cam->params.version.firmwareVersion == 1 &&
           cam->params.version.firmwareRevision == 2)
@@ -318,26 +314,26 @@ static int cpia_read_proc(char *page, char **start, off_t off,
        else
                tmp = 96;
 
-       out += sprintf(out, "contrast:               %8d  %8d  %8d  %8d"
+       seq_printf(m, "contrast:               %8d  %8d  %8d  %8d"
                       "  steps of 8\n",
                       cam->params.colourParams.contrast, 0, tmp, 48);
-       out += sprintf(out, "saturation:             %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "saturation:             %8d  %8d  %8d  %8d\n",
                       cam->params.colourParams.saturation, 0, 100, 50);
        tmp = (25000+5000*cam->params.sensorFps.baserate)/
              (1<<cam->params.sensorFps.divisor);
-       out += sprintf(out, "sensor_fps:             %4d.%03d  %8d  %8d  %8d\n",
+       seq_printf(m, "sensor_fps:             %4d.%03d  %8d  %8d  %8d\n",
                       tmp/1000, tmp%1000, 3, 30, 15);
-       out += sprintf(out, "stream_start_line:      %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "stream_start_line:      %8d  %8d  %8d  %8d\n",
                       2*cam->params.streamStartLine, 0,
                       cam->params.format.videoSize == VIDEOSIZE_CIF ? 288:144,
                       cam->params.format.videoSize == VIDEOSIZE_CIF ? 240:120);
-       out += sprintf(out, "sub_sample:             %8s  %8s  %8s  %8s\n",
+       seq_printf(m, "sub_sample:             %8s  %8s  %8s  %8s\n",
                       cam->params.format.subSample == SUBSAMPLE_420 ?
                       "420" : "422", "420", "422", "422");
-       out += sprintf(out, "yuv_order:              %8s  %8s  %8s  %8s\n",
+       seq_printf(m, "yuv_order:              %8s  %8s  %8s  %8s\n",
                       cam->params.format.yuvOrder == YUVORDER_YUYV ?
                       "YUYV" : "UYVY", "YUYV" , "UYVY", "YUYV");
-       out += sprintf(out, "ecp_timing:             %8s  %8s  %8s  %8s\n",
+       seq_printf(m, "ecp_timing:             %8s  %8s  %8s  %8s\n",
                       cam->params.ecpTiming ? "slow" : "normal", "slow",
                       "normal", "normal");
 
@@ -346,13 +342,13 @@ static int cpia_read_proc(char *page, char **start, off_t off,
        } else {
                sprintf(tmpstr, "manual");
        }
-       out += sprintf(out, "color_balance_mode:     %8s  %8s  %8s"
+       seq_printf(m, "color_balance_mode:     %8s  %8s  %8s"
                       "  %8s\n",  tmpstr, "manual", "auto", "auto");
-       out += sprintf(out, "red_gain:               %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "red_gain:               %8d  %8d  %8d  %8d\n",
                       cam->params.colourBalance.redGain, 0, 212, 32);
-       out += sprintf(out, "green_gain:             %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "green_gain:             %8d  %8d  %8d  %8d\n",
                       cam->params.colourBalance.greenGain, 0, 212, 6);
-       out += sprintf(out, "blue_gain:              %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "blue_gain:              %8d  %8d  %8d  %8d\n",
                       cam->params.colourBalance.blueGain, 0, 212, 92);
 
        if (cam->params.version.firmwareVersion == 1 &&
@@ -363,10 +359,10 @@ static int cpia_read_proc(char *page, char **start, off_t off,
                sprintf(tmpstr, "%8d  %8d  %8d", 1, 8, 2);
 
        if (cam->params.exposure.gainMode == 0)
-               out += sprintf(out, "max_gain:                unknown  %28s"
+               seq_printf(m, "max_gain:                unknown  %28s"
                               "  powers of 2\n", tmpstr);
        else
-               out += sprintf(out, "max_gain:               %8d  %28s"
+               seq_printf(m, "max_gain:               %8d  %28s"
                               "  1,2,4 or 8 \n",
                               1<<(cam->params.exposure.gainMode-1), tmpstr);
 
@@ -382,12 +378,12 @@ static int cpia_read_proc(char *page, char **start, off_t off,
                sprintf(tmpstr, "unknown");
                break;
        }
-       out += sprintf(out, "exposure_mode:          %8s  %8s  %8s"
+       seq_printf(m, "exposure_mode:          %8s  %8s  %8s"
                       "  %8s\n",  tmpstr, "manual", "auto", "auto");
-       out += sprintf(out, "centre_weight:          %8s  %8s  %8s  %8s\n",
+       seq_printf(m, "centre_weight:          %8s  %8s  %8s  %8s\n",
                       (2-cam->params.exposure.centreWeight) ? "on" : "off",
                       "off", "on", "on");
-       out += sprintf(out, "gain:                   %8d  %8d  max_gain  %8d  1,2,4,8 possible\n",
+       seq_printf(m, "gain:                   %8d  %8d  max_gain  %8d  1,2,4,8 possible\n",
                       1<<cam->params.exposure.gain, 1, 1);
        if (cam->params.version.firmwareVersion == 1 &&
           cam->params.version.firmwareRevision == 2)
@@ -396,7 +392,7 @@ static int cpia_read_proc(char *page, char **start, off_t off,
        else
                tmp = 510;
 
-       out += sprintf(out, "fine_exp:               %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "fine_exp:               %8d  %8d  %8d  %8d\n",
                       cam->params.exposure.fineExp*2, 0, tmp, 0);
        if (cam->params.version.firmwareVersion == 1 &&
           cam->params.version.firmwareRevision == 2)
@@ -405,127 +401,122 @@ static int cpia_read_proc(char *page, char **start, off_t off,
        else
                tmp = MAX_EXP;
 
-       out += sprintf(out, "coarse_exp:             %8d  %8d  %8d"
+       seq_printf(m, "coarse_exp:             %8d  %8d  %8d"
                       "  %8d\n", cam->params.exposure.coarseExpLo+
                       256*cam->params.exposure.coarseExpHi, 0, tmp, 185);
-       out += sprintf(out, "red_comp:               %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "red_comp:               %8d  %8d  %8d  %8d\n",
                       cam->params.exposure.redComp, COMP_RED, 255, COMP_RED);
-       out += sprintf(out, "green1_comp:            %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "green1_comp:            %8d  %8d  %8d  %8d\n",
                       cam->params.exposure.green1Comp, COMP_GREEN1, 255,
                       COMP_GREEN1);
-       out += sprintf(out, "green2_comp:            %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "green2_comp:            %8d  %8d  %8d  %8d\n",
                       cam->params.exposure.green2Comp, COMP_GREEN2, 255,
                       COMP_GREEN2);
-       out += sprintf(out, "blue_comp:              %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "blue_comp:              %8d  %8d  %8d  %8d\n",
                       cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE);
 
-       out += sprintf(out, "apcor_gain1:            %#8x  %#8x  %#8x  %#8x\n",
+       seq_printf(m, "apcor_gain1:            %#8x  %#8x  %#8x  %#8x\n",
                       cam->params.apcor.gain1, 0, 0xff, 0x1c);
-       out += sprintf(out, "apcor_gain2:            %#8x  %#8x  %#8x  %#8x\n",
+       seq_printf(m, "apcor_gain2:            %#8x  %#8x  %#8x  %#8x\n",
                       cam->params.apcor.gain2, 0, 0xff, 0x1a);
-       out += sprintf(out, "apcor_gain4:            %#8x  %#8x  %#8x  %#8x\n",
+       seq_printf(m, "apcor_gain4:            %#8x  %#8x  %#8x  %#8x\n",
                       cam->params.apcor.gain4, 0, 0xff, 0x2d);
-       out += sprintf(out, "apcor_gain8:            %#8x  %#8x  %#8x  %#8x\n",
+       seq_printf(m, "apcor_gain8:            %#8x  %#8x  %#8x  %#8x\n",
                       cam->params.apcor.gain8, 0, 0xff, 0x2a);
-       out += sprintf(out, "vl_offset_gain1:        %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "vl_offset_gain1:        %8d  %8d  %8d  %8d\n",
                       cam->params.vlOffset.gain1, 0, 255, 24);
-       out += sprintf(out, "vl_offset_gain2:        %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "vl_offset_gain2:        %8d  %8d  %8d  %8d\n",
                       cam->params.vlOffset.gain2, 0, 255, 28);
-       out += sprintf(out, "vl_offset_gain4:        %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "vl_offset_gain4:        %8d  %8d  %8d  %8d\n",
                       cam->params.vlOffset.gain4, 0, 255, 30);
-       out += sprintf(out, "vl_offset_gain8:        %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "vl_offset_gain8:        %8d  %8d  %8d  %8d\n",
                       cam->params.vlOffset.gain8, 0, 255, 30);
-       out += sprintf(out, "flicker_control:        %8s  %8s  %8s  %8s\n",
+       seq_printf(m, "flicker_control:        %8s  %8s  %8s  %8s\n",
                       cam->params.flickerControl.flickerMode ? "on" : "off",
                       "off", "on", "off");
-       out += sprintf(out, "mains_frequency:        %8d  %8d  %8d  %8d"
+       seq_printf(m, "mains_frequency:        %8d  %8d  %8d  %8d"
                       " only 50/60\n",
                       cam->mainsFreq ? 60 : 50, 50, 60, 50);
        if(cam->params.flickerControl.allowableOverExposure < 0)
-               out += sprintf(out, "allowable_overexposure: %4dauto      auto  %8d      auto\n",
+               seq_printf(m, "allowable_overexposure: %4dauto      auto  %8d      auto\n",
                               -cam->params.flickerControl.allowableOverExposure,
                               255);
        else
-               out += sprintf(out, "allowable_overexposure: %8d      auto  %8d      auto\n",
+               seq_printf(m, "allowable_overexposure: %8d      auto  %8d      auto\n",
                               cam->params.flickerControl.allowableOverExposure,
                               255);
-       out += sprintf(out, "compression_mode:       ");
+       seq_printf(m, "compression_mode:       ");
        switch(cam->params.compression.mode) {
        case CPIA_COMPRESSION_NONE:
-               out += sprintf(out, "%8s", "none");
+               seq_printf(m, "%8s", "none");
                break;
        case CPIA_COMPRESSION_AUTO:
-               out += sprintf(out, "%8s", "auto");
+               seq_printf(m, "%8s", "auto");
                break;
        case CPIA_COMPRESSION_MANUAL:
-               out += sprintf(out, "%8s", "manual");
+               seq_printf(m, "%8s", "manual");
                break;
        default:
-               out += sprintf(out, "%8s", "unknown");
+               seq_printf(m, "%8s", "unknown");
                break;
        }
-       out += sprintf(out, "    none,auto,manual      auto\n");
-       out += sprintf(out, "decimation_enable:      %8s  %8s  %8s  %8s\n",
+       seq_printf(m, "    none,auto,manual      auto\n");
+       seq_printf(m, "decimation_enable:      %8s  %8s  %8s  %8s\n",
                       cam->params.compression.decimation ==
                       DECIMATION_ENAB ? "on":"off", "off", "on",
                       "off");
-       out += sprintf(out, "compression_target:    %9s %9s %9s %9s\n",
+       seq_printf(m, "compression_target:    %9s %9s %9s %9s\n",
                       cam->params.compressionTarget.frTargeting  ==
                       CPIA_COMPRESSION_TARGET_FRAMERATE ?
                       "framerate":"quality",
                       "framerate", "quality", "quality");
-       out += sprintf(out, "target_framerate:       %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "target_framerate:       %8d  %8d  %8d  %8d\n",
                       cam->params.compressionTarget.targetFR, 1, 30, 15);
-       out += sprintf(out, "target_quality:         %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "target_quality:         %8d  %8d  %8d  %8d\n",
                       cam->params.compressionTarget.targetQ, 1, 64, 5);
-       out += sprintf(out, "y_threshold:            %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "y_threshold:            %8d  %8d  %8d  %8d\n",
                       cam->params.yuvThreshold.yThreshold, 0, 31, 6);
-       out += sprintf(out, "uv_threshold:           %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "uv_threshold:           %8d  %8d  %8d  %8d\n",
                       cam->params.yuvThreshold.uvThreshold, 0, 31, 6);
-       out += sprintf(out, "hysteresis:             %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "hysteresis:             %8d  %8d  %8d  %8d\n",
                       cam->params.compressionParams.hysteresis, 0, 255, 3);
-       out += sprintf(out, "threshold_max:          %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "threshold_max:          %8d  %8d  %8d  %8d\n",
                       cam->params.compressionParams.threshMax, 0, 255, 11);
-       out += sprintf(out, "small_step:             %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "small_step:             %8d  %8d  %8d  %8d\n",
                       cam->params.compressionParams.smallStep, 0, 255, 1);
-       out += sprintf(out, "large_step:             %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "large_step:             %8d  %8d  %8d  %8d\n",
                       cam->params.compressionParams.largeStep, 0, 255, 3);
-       out += sprintf(out, "decimation_hysteresis:  %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "decimation_hysteresis:  %8d  %8d  %8d  %8d\n",
                       cam->params.compressionParams.decimationHysteresis,
                       0, 255, 2);
-       out += sprintf(out, "fr_diff_step_thresh:    %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "fr_diff_step_thresh:    %8d  %8d  %8d  %8d\n",
                       cam->params.compressionParams.frDiffStepThresh,
                       0, 255, 5);
-       out += sprintf(out, "q_diff_step_thresh:     %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "q_diff_step_thresh:     %8d  %8d  %8d  %8d\n",
                       cam->params.compressionParams.qDiffStepThresh,
                       0, 255, 3);
-       out += sprintf(out, "decimation_thresh_mod:  %8d  %8d  %8d  %8d\n",
+       seq_printf(m, "decimation_thresh_mod:  %8d  %8d  %8d  %8d\n",
                       cam->params.compressionParams.decimationThreshMod,
                       0, 255, 2);
        /* QX3 specific entries */
        if (cam->params.qx3.qx3_detected) {
-               out += sprintf(out, "toplight:               %8s  %8s  %8s  %8s\n",
+               seq_printf(m, "toplight:               %8s  %8s  %8s  %8s\n",
                               cam->params.qx3.toplight ? "on" : "off",
                               "off", "on", "off");
-               out += sprintf(out, "bottomlight:            %8s  %8s  %8s  %8s\n",
+               seq_printf(m, "bottomlight:            %8s  %8s  %8s  %8s\n",
                               cam->params.qx3.bottomlight ? "on" : "off",
                               "off", "on", "off");
        }
 
-       len = out - page;
-       len -= off;
-       if (len < count) {
-               *eof = 1;
-               if (len <= 0) return 0;
-       } else
-               len = count;
-
-       *start = page + off;
-       return len;
+       return 0;
 }
 
+static int cpia_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, cpia_proc_show, PDE(inode)->data);
+}
 
-static int match(char *checkstr, char **buffer, unsigned long *count,
+static int match(char *checkstr, char **buffer, size_t *count,
                 int *find_colon, int *err)
 {
        int ret, colon_found = 1;
@@ -551,7 +542,7 @@ static int match(char *checkstr, char **buffer, unsigned long *count,
        return ret;
 }
 
-static unsigned long int value(char **buffer, unsigned long *count, int *err)
+static unsigned long int value(char **buffer, size_t *count, int *err)
 {
        char *p;
        unsigned long int ret;
@@ -565,10 +556,10 @@ static unsigned long int value(char **buffer, unsigned long *count, int *err)
        return ret;
 }
 
-static int cpia_write_proc(struct file *file, const char __user *buf,
-                          unsigned long count, void *data)
+static ssize_t cpia_proc_write(struct file *file, const char __user *buf,
+                              size_t count, loff_t *pos)
 {
-       struct cam_data *cam = data;
+       struct cam_data *cam = PDE(file->f_path.dentry->d_inode)->data;
        struct cam_params new_params;
        char *page, *buffer;
        int retval, find_colon;
@@ -582,7 +573,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
         * from the comx driver
         */
        if (count > PAGE_SIZE) {
-               printk(KERN_ERR "count is %lu > %d!!!\n", count, (int)PAGE_SIZE);
+               printk(KERN_ERR "count is %zu > %d!!!\n", count, (int)PAGE_SIZE);
                return -ENOSPC;
        }
 
@@ -1340,23 +1331,28 @@ out:
        return retval;
 }
 
+static const struct file_operations cpia_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = cpia_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = cpia_proc_write,
+};
+
 static void create_proc_cpia_cam(struct cam_data *cam)
 {
-       char name[5 + 1 + 10 + 1];
        struct proc_dir_entry *ent;
 
        if (!cpia_proc_root || !cam)
                return;
 
-       snprintf(name, sizeof(name), "video%d", cam->vdev.num);
-
-       ent = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root);
+       ent = proc_create_data(video_device_node_name(&cam->vdev),
+                              S_IRUGO|S_IWUSR, cpia_proc_root,
+                              &cpia_proc_fops, cam);
        if (!ent)
                return;
 
-       ent->data = cam;
-       ent->read_proc = cpia_read_proc;
-       ent->write_proc = cpia_write_proc;
        /*
           size of the proc entry is 3736 bytes for the standard webcam;
           the extra features of the QX3 microscope add 189 bytes.
@@ -1368,13 +1364,10 @@ static void create_proc_cpia_cam(struct cam_data *cam)
 
 static void destroy_proc_cpia_cam(struct cam_data *cam)
 {
-       char name[5 + 1 + 10 + 1];
-
        if (!cam || !cam->proc_entry)
                return;
 
-       snprintf(name, sizeof(name), "video%d", cam->vdev.num);
-       remove_proc_entry(name, cpia_proc_root);
+       remove_proc_entry(video_device_node_name(&cam->vdev), cpia_proc_root);
        cam->proc_entry = NULL;
 }
 
@@ -3999,7 +3992,7 @@ void cpia_unregister_camera(struct cam_data *cam)
        }
 
 #ifdef CONFIG_PROC_FS
-       DBG("destroying /proc/cpia/video%d\n", cam->vdev.num);
+       DBG("destroying /proc/cpia/%s\n", video_device_node_name(&cam->vdev));
        destroy_proc_cpia_cam(cam);
 #endif
        if (!cam->open_count) {
index 0b4a8f309cfab14c65727e378cc6d352b3bea881..6f91415eb7b4c8afcf9a641549e064033ef304cb 100644 (file)
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/videodev.h>
+#include <linux/stringify.h>
 #include <media/v4l2-ioctl.h>
 
 #include "cpia2.h"
 #include "cpia2dev.h"
 
-
-//#define _CPIA2_DEBUG_
-
-#define MAKE_STRING_1(x)       #x
-#define MAKE_STRING(x) MAKE_STRING_1(x)
-
 static int video_nr = -1;
 module_param(video_nr, int, 0);
 MODULE_PARM_DESC(video_nr,"video device to register (0=/dev/video0, etc)");
@@ -60,26 +55,26 @@ MODULE_PARM_DESC(buffer_size, "Size for each frame buffer in bytes (default 68k)
 static int num_buffers = 3;
 module_param(num_buffers, int, 0);
 MODULE_PARM_DESC(num_buffers, "Number of frame buffers (1-"
-                MAKE_STRING(VIDEO_MAX_FRAME) ", default 3)");
+                __stringify(VIDEO_MAX_FRAME) ", default 3)");
 
 static int alternate = DEFAULT_ALT;
 module_param(alternate, int, 0);
-MODULE_PARM_DESC(alternate, "USB Alternate (" MAKE_STRING(USBIF_ISO_1) "-"
-                MAKE_STRING(USBIF_ISO_6) ", default "
-                MAKE_STRING(DEFAULT_ALT) ")");
+MODULE_PARM_DESC(alternate, "USB Alternate (" __stringify(USBIF_ISO_1) "-"
+                __stringify(USBIF_ISO_6) ", default "
+                __stringify(DEFAULT_ALT) ")");
 
 static int flicker_freq = 60;
 module_param(flicker_freq, int, 0);
-MODULE_PARM_DESC(flicker_freq, "Flicker frequency (" MAKE_STRING(50) "or"
-                MAKE_STRING(60) ", default "
-                MAKE_STRING(60) ")");
+MODULE_PARM_DESC(flicker_freq, "Flicker frequency (" __stringify(50) "or"
+                __stringify(60) ", default "
+                __stringify(60) ")");
 
 static int flicker_mode = NEVER_FLICKER;
 module_param(flicker_mode, int, 0);
 MODULE_PARM_DESC(flicker_mode,
-                "Flicker supression (" MAKE_STRING(NEVER_FLICKER) "or"
-                MAKE_STRING(ANTI_FLICKER_ON) ", default "
-                MAKE_STRING(NEVER_FLICKER) ")");
+                "Flicker supression (" __stringify(NEVER_FLICKER) "or"
+                __stringify(ANTI_FLICKER_ON) ", default "
+                __stringify(NEVER_FLICKER) ")");
 
 MODULE_AUTHOR("Steve Miller (STMicroelectronics) <steve.miller@st.com>");
 MODULE_DESCRIPTION("V4L-driver for STMicroelectronics CPiA2 based cameras");
@@ -1926,7 +1921,6 @@ static const struct v4l2_file_operations fops_template = {
 static struct video_device cpia2_template = {
        /* I could not find any place for the old .initialize initializer?? */
        .name=          "CPiA2 Camera",
-       .minor=         -1,
        .fops=          &fops_template,
        .release=       video_device_release,
 };
@@ -1967,9 +1961,9 @@ void cpia2_unregister_camera(struct camera_data *cam)
        if (!cam->open_count) {
                video_unregister_device(cam->vdev);
        } else {
-               LOG("/dev/video%d removed while open, "
-                   "deferring video_unregister_device\n",
-                   cam->vdev->num);
+               LOG("%s removed while open, deferring "
+                   "video_unregister_device\n",
+                   video_device_node_name(cam->vdev));
        }
 }
 
index 4e278db31cc9a56679fb614868fa62fef2ee65bd..c0885c69fd89d12250c8dff19e8e3157114bc6b1 100644 (file)
@@ -758,8 +758,8 @@ int cx18_v4l2_open(struct file *filp)
 
        mutex_lock(&cx->serialize_lock);
        if (cx18_init_on_first_open(cx)) {
-               CX18_ERR("Failed to initialize on minor %d\n",
-                        video_dev->minor);
+               CX18_ERR("Failed to initialize on %s\n",
+                        video_device_node_name(video_dev));
                mutex_unlock(&cx->serialize_lock);
                return -ENXIO;
        }
index c398651dd74c861a9254bf9d6a60f4c4f4f680ec..987a9308d938523dab6914ddc647bd3ee4364b3b 100644 (file)
@@ -219,6 +219,7 @@ static int cx18_reg_dev(struct cx18 *cx, int type)
 {
        struct cx18_stream *s = &cx->streams[type];
        int vfl_type = cx18_stream_info[type].vfl_type;
+       const char *name;
        int num, ret;
 
        /* TODO: Shouldn't this be a VFL_TYPE_TRANSPORT or something?
@@ -258,31 +259,30 @@ static int cx18_reg_dev(struct cx18 *cx, int type)
                s->video_dev = NULL;
                return ret;
        }
-       num = s->video_dev->num;
+
+       name = video_device_node_name(s->video_dev);
 
        switch (vfl_type) {
        case VFL_TYPE_GRABBER:
-               CX18_INFO("Registered device video%d for %s "
-                         "(%d x %d.%02d kB)\n",
-                         num, s->name, cx->stream_buffers[type],
+               CX18_INFO("Registered device %s for %s (%d x %d.%02d kB)\n",
+                         name, s->name, cx->stream_buffers[type],
                          cx->stream_buf_size[type] / 1024,
                          (cx->stream_buf_size[type] * 100 / 1024) % 100);
                break;
 
        case VFL_TYPE_RADIO:
-               CX18_INFO("Registered device radio%d for %s\n",
-                       num, s->name);
+               CX18_INFO("Registered device %s for %s\n", name, s->name);
                break;
 
        case VFL_TYPE_VBI:
                if (cx->stream_buffers[type])
-                       CX18_INFO("Registered device vbi%d for %s "
+                       CX18_INFO("Registered device %s for %s "
                                  "(%d x %d bytes)\n",
-                                 num, s->name, cx->stream_buffers[type],
+                                 name, s->name, cx->stream_buffers[type],
                                  cx->stream_buf_size[type]);
                else
-                       CX18_INFO("Registered device vbi%d for %s\n",
-                               num, s->name);
+                       CX18_INFO("Registered device %s for %s\n",
+                               name, s->name);
                break;
        }
 
index 319c459459e0c5a0fb0f3323d0780b59a8ec65c6..a549082350095311121ba0694045eb55cfdeeb70 100644 (file)
@@ -68,19 +68,19 @@ struct cx231xx_board cx231xx_boards[] = {
                                .type = CX231XX_VMUX_TELEVISION,
                                .vmux = CX231XX_VIN_3_1,
                                .amux = CX231XX_AMUX_VIDEO,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }, {
                                .type = CX231XX_VMUX_COMPOSITE1,
                                .vmux = CX231XX_VIN_2_1,
                                .amux = CX231XX_AMUX_LINE_IN,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }, {
                                .type = CX231XX_VMUX_SVIDEO,
                                .vmux = CX231XX_VIN_1_1 |
                                        (CX231XX_VIN_1_2 << 8) |
                                        CX25840_SVIDEO_ON,
                                .amux = CX231XX_AMUX_LINE_IN,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }
                },
        },
@@ -107,19 +107,19 @@ struct cx231xx_board cx231xx_boards[] = {
                                .type = CX231XX_VMUX_TELEVISION,
                                .vmux = CX231XX_VIN_3_1,
                                .amux = CX231XX_AMUX_VIDEO,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }, {
                                .type = CX231XX_VMUX_COMPOSITE1,
                                .vmux = CX231XX_VIN_2_1,
                                .amux = CX231XX_AMUX_LINE_IN,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }, {
                                .type = CX231XX_VMUX_SVIDEO,
                                .vmux = CX231XX_VIN_1_1 |
                                        (CX231XX_VIN_1_2 << 8) |
                                        CX25840_SVIDEO_ON,
                                .amux = CX231XX_AMUX_LINE_IN,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }
                },
        },
@@ -147,19 +147,19 @@ struct cx231xx_board cx231xx_boards[] = {
                                .type = CX231XX_VMUX_TELEVISION,
                                .vmux = CX231XX_VIN_3_1,
                                .amux = CX231XX_AMUX_VIDEO,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }, {
                                .type = CX231XX_VMUX_COMPOSITE1,
                                .vmux = CX231XX_VIN_2_1,
                                .amux = CX231XX_AMUX_LINE_IN,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }, {
                                .type = CX231XX_VMUX_SVIDEO,
                                .vmux = CX231XX_VIN_1_1 |
                                        (CX231XX_VIN_1_2 << 8) |
                                        CX25840_SVIDEO_ON,
                                .amux = CX231XX_AMUX_LINE_IN,
-                               .gpio = 0,
+                               .gpio = NULL,
                        }
                },
        },
@@ -856,8 +856,9 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface)
 
        if (dev->users) {
                cx231xx_warn
-                   ("device /dev/video%d is open! Deregistration and memory "
-                    "deallocation are deferred on close.\n", dev->vdev->num);
+                   ("device %s is open! Deregistration and memory "
+                    "deallocation are deferred on close.\n",
+                    video_device_node_name(dev->vdev));
 
                dev->state |= DEV_MISCONFIGURED;
                cx231xx_uninit_isoc(dev);
index 0d333e679f7050fdce663d98e4f08148145c1fbc..4a60dfbc347deaf06f3e1f0ec707cda91690340b 100644 (file)
@@ -66,32 +66,6 @@ MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint");
 static LIST_HEAD(cx231xx_devlist);
 static DEFINE_MUTEX(cx231xx_devlist_mutex);
 
-struct cx231xx *cx231xx_get_device(int minor,
-                                  enum v4l2_buf_type *fh_type, int *has_radio)
-{
-       struct cx231xx *h, *dev = NULL;
-
-       *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       *has_radio = 0;
-
-       mutex_lock(&cx231xx_devlist_mutex);
-       list_for_each_entry(h, &cx231xx_devlist, devlist) {
-               if (h->vdev->minor == minor)
-                       dev = h;
-               if (h->vbi_dev->minor == minor) {
-                       dev = h;
-                       *fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
-               }
-               if (h->radio_dev && h->radio_dev->minor == minor) {
-                       dev = h;
-                       *has_radio = 1;
-               }
-       }
-       mutex_unlock(&cx231xx_devlist_mutex);
-
-       return dev;
-}
-
 /*
  * cx231xx_realease_resources()
  * unregisters the v4l2,i2c and usb devices
index cd135f01b9c1865eaa7bdc1817e4d08aed6e5fdf..15826f98b68826818ff401921853dad33356c6a8 100644 (file)
@@ -197,8 +197,7 @@ int cx231xx_ir_init(struct cx231xx *dev)
        usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
        strlcat(ir->phys, "/input0", sizeof(ir->phys));
 
-       err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER,
-                           dev->board.ir_codes);
+       err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER);
        if (err < 0)
                goto err_out_free;
 
@@ -217,7 +216,7 @@ int cx231xx_ir_init(struct cx231xx *dev)
        cx231xx_ir_start(ir);
 
        /* all done */
-       err = input_register_device(ir->input);
+       err = ir_input_register(ir->input, dev->board.ir_codes);
        if (err)
                goto err_out_stop;
 
@@ -226,8 +225,6 @@ err_out_stop:
        cx231xx_ir_stop(ir);
        dev->ir = NULL;
 err_out_free:
-       ir_input_free(input_dev);
-       input_free_device(input_dev);
        kfree(ir);
        return err;
 }
@@ -241,8 +238,7 @@ int cx231xx_ir_fini(struct cx231xx *dev)
                return 0;
 
        cx231xx_ir_stop(ir);
-       ir_input_free(ir->input);
-       input_unregister_device(ir->input);
+       ir_input_unregister(ir->input);
        kfree(ir);
 
        /* done */
index d095aa0d6d19f517cbeb3c4716d8b40438544d3a..d4f546f11d7490a833628a4017fa843f6e972b00 100644 (file)
@@ -1916,20 +1916,29 @@ static int radio_queryctrl(struct file *file, void *priv,
  */
 static int cx231xx_v4l2_open(struct file *filp)
 {
-       int minor = video_devdata(filp)->minor;
        int errCode = 0, radio = 0;
-       struct cx231xx *dev = NULL;
+       struct video_device *vdev = video_devdata(filp);
+       struct cx231xx *dev = video_drvdata(filp);
        struct cx231xx_fh *fh;
        enum v4l2_buf_type fh_type = 0;
 
-       dev = cx231xx_get_device(minor, &fh_type, &radio);
-       if (NULL == dev)
-               return -ENODEV;
+       switch (vdev->vfl_type) {
+       case VFL_TYPE_GRABBER:
+               fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+               break;
+       case VFL_TYPE_VBI:
+               fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
+               break;
+       case VFL_TYPE_RADIO:
+               radio = 1;
+               break;
+       }
 
        mutex_lock(&dev->lock);
 
-       cx231xx_videodbg("open minor=%d type=%s users=%d\n",
-                        minor, v4l2_type_names[fh_type], dev->users);
+       cx231xx_videodbg("open dev=%s type=%s users=%d\n",
+                        video_device_node_name(vdev), v4l2_type_names[fh_type],
+                        dev->users);
 
 #if 0
        errCode = cx231xx_set_mode(dev, CX231XX_ANALOG_MODE);
@@ -2020,25 +2029,25 @@ void cx231xx_release_analog_resources(struct cx231xx *dev)
        /*FIXME: I2C IR should be disconnected */
 
        if (dev->radio_dev) {
-               if (-1 != dev->radio_dev->minor)
+               if (video_is_registered(dev->radio_dev))
                        video_unregister_device(dev->radio_dev);
                else
                        video_device_release(dev->radio_dev);
                dev->radio_dev = NULL;
        }
        if (dev->vbi_dev) {
-               cx231xx_info("V4L2 device /dev/vbi%d deregistered\n",
-                            dev->vbi_dev->num);
-               if (-1 != dev->vbi_dev->minor)
+               cx231xx_info("V4L2 device %s deregistered\n",
+                            video_device_node_name(dev->vbi_dev));
+               if (video_is_registered(dev->vbi_dev))
                        video_unregister_device(dev->vbi_dev);
                else
                        video_device_release(dev->vbi_dev);
                dev->vbi_dev = NULL;
        }
        if (dev->vdev) {
-               cx231xx_info("V4L2 device /dev/video%d deregistered\n",
-                            dev->vdev->num);
-               if (-1 != dev->vdev->minor)
+               cx231xx_info("V4L2 device %s deregistered\n",
+                            video_device_node_name(dev->vdev));
+               if (video_is_registered(dev->vdev))
                        video_unregister_device(dev->vdev);
                else
                        video_device_release(dev->vdev);
@@ -2268,7 +2277,6 @@ static const struct video_device cx231xx_video_template = {
        .fops         = &cx231xx_v4l_fops,
        .release      = video_device_release,
        .ioctl_ops    = &video_ioctl_ops,
-       .minor        = -1,
        .tvnorms      = V4L2_STD_ALL,
        .current_norm = V4L2_STD_PAL,
 };
@@ -2303,7 +2311,6 @@ static struct video_device cx231xx_radio_template = {
        .name      = "cx231xx-radio",
        .fops      = &radio_fops,
        .ioctl_ops = &radio_ioctl_ops,
-       .minor     = -1,
 };
 
 /******************************** usb interface ******************************/
@@ -2319,13 +2326,13 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,
                return NULL;
 
        *vfd = *template;
-       vfd->minor = -1;
        vfd->v4l2_dev = &dev->v4l2_dev;
        vfd->release = video_device_release;
        vfd->debug = video_debug;
 
        snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);
 
+       video_set_drvdata(vfd, dev);
        return vfd;
 }
 
@@ -2374,8 +2381,8 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
                return ret;
        }
 
-       cx231xx_info("%s/0: registered device video%d [v4l2]\n",
-                    dev->name, dev->vdev->num);
+       cx231xx_info("%s/0: registered device %s [v4l2]\n",
+                    dev->name, video_device_node_name(dev->vdev));
 
        /* Initialize VBI template */
        memcpy(&cx231xx_vbi_template, &cx231xx_video_template,
@@ -2393,8 +2400,8 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
                return ret;
        }
 
-       cx231xx_info("%s/0: registered device vbi%d\n",
-                    dev->name, dev->vbi_dev->num);
+       cx231xx_info("%s/0: registered device %s\n",
+                    dev->name, video_device_node_name(dev->vbi_dev));
 
        if (cx231xx_boards[dev->model].radio.type == CX231XX_RADIO) {
                dev->radio_dev = cx231xx_vdev_init(dev, &cx231xx_radio_template,
@@ -2409,12 +2416,13 @@ int cx231xx_register_analog_devices(struct cx231xx *dev)
                        cx231xx_errdev("can't register radio device\n");
                        return ret;
                }
-               cx231xx_info("Registered radio device as /dev/radio%d\n",
-                            dev->radio_dev->num);
+               cx231xx_info("Registered radio device as %s\n",
+                            video_device_node_name(dev->radio_dev));
        }
 
-       cx231xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n",
-                    dev->vdev->num, dev->vbi_dev->num);
+       cx231xx_info("V4L2 device registered as %s and %s\n",
+                    video_device_node_name(dev->vdev),
+                    video_device_node_name(dev->vbi_dev));
 
        return 0;
 }
index 64e2ddd3c4018358e073da2ce5e0af094dd337ff..17d4d1a800ce010732ffa641cee0101afe7a0f36 100644 (file)
@@ -689,8 +689,6 @@ void cx231xx_release_analog_resources(struct cx231xx *dev);
 int cx231xx_register_analog_devices(struct cx231xx *dev);
 void cx231xx_remove_from_devlist(struct cx231xx *dev);
 void cx231xx_add_into_devlist(struct cx231xx *dev);
-struct cx231xx *cx231xx_get_device(int minor,
-                                  enum v4l2_buf_type *fh_type, int *has_radio);
 void cx231xx_init_extension(struct cx231xx *dev);
 void cx231xx_close_extension(struct cx231xx *dev);
 
index c04222ffb286b0ae0da344af96555dbeea29a2eb..d4a9d2c5947c196f6d4596c3c0f9e063ee1cc7d7 100644 (file)
@@ -53,6 +53,8 @@
 #define NETUP_CI_CTL           0x04
 #define NETUP_CI_RD            1
 
+#define NETUP_IRQ_DETAM        0x1
+#define NETUP_IRQ_IRQAM                0x4
 
 static unsigned int ci_dbg;
 module_param(ci_dbg, int, 0644);
@@ -73,6 +75,9 @@ struct netup_ci_state {
        int status;
        struct work_struct work;
        void *priv;
+       u8 current_irq_mode;
+       int current_ci_flag;
+       unsigned long next_status_checked_time;
 };
 
 
@@ -169,24 +174,26 @@ int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot,
        if (0 != slot)
                return -EINVAL;
 
-       ret = netup_read_i2c(state->i2c_adap, state->ci_i2c_addr,
-                                                       0, &store, 1);
-       if (ret != 0)
-               return ret;
+       if (state->current_ci_flag != flag) {
+               ret = netup_read_i2c(state->i2c_adap, state->ci_i2c_addr,
+                               0, &store, 1);
+               if (ret != 0)
+                       return ret;
 
-       store &= ~0x0c;
-       store |= flag;
+               store &= ~0x0c;
+               store |= flag;
 
-       ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr,
-                                                       0, &store, 1);
-       if (ret != 0)
-               return ret;
+               ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr,
+                               0, &store, 1);
+               if (ret != 0)
+                       return ret;
+       };
+       state->current_ci_flag = flag;
 
        mutex_lock(&dev->gpio_lock);
 
        /* write addr */
        cx_write(MC417_OEN, NETUP_EN_ALL);
-       msleep(2);
        cx_write(MC417_RWD, NETUP_CTRL_OFF |
                                NETUP_ADLO | (0xff & addr));
        cx_clear(MC417_RWD, NETUP_ADLO);
@@ -196,7 +203,6 @@ int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot,
 
        if (read) { /* data in */
                cx_write(MC417_OEN, NETUP_EN_ALL | NETUP_DATA);
-               msleep(2);
        } else /* data out */
                cx_write(MC417_RWD, NETUP_CTRL_OFF | data);
 
@@ -213,8 +219,8 @@ int netup_ci_op_cam(struct dvb_ca_en50221 *en50221, int slot,
                if (mem < 0)
                        return -EREMOTEIO;
 
-       ci_dbg_print("%s: %s: addr=[0x%02x], %s=%x\n", __func__,
-                       (read) ? "read" : "write", addr,
+       ci_dbg_print("%s: %s: chipaddr=[0x%x] addr=[0x%02x], %s=%x\n", __func__,
+                       (read) ? "read" : "write", state->ci_i2c_addr, addr,
                        (flag == NETUP_CI_CTL) ? "ctl" : "mem",
                        (read) ? mem : data);
 
@@ -283,14 +289,39 @@ int netup_ci_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot)
        return 0;
 }
 
+int netup_ci_set_irq(struct dvb_ca_en50221 *en50221, u8 irq_mode)
+{
+       struct netup_ci_state *state = en50221->data;
+       int ret;
+
+       if (irq_mode == state->current_irq_mode)
+               return 0;
+
+       ci_dbg_print("%s: chipaddr=[0x%x] setting ci IRQ to [0x%x] \n",
+                       __func__, state->ci_i2c_addr, irq_mode);
+       ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr,
+                                                       0x1b, &irq_mode, 1);
+
+       if (ret != 0)
+               return ret;
+
+       state->current_irq_mode = irq_mode;
+
+       return 0;
+}
+
 int netup_ci_slot_ts_ctl(struct dvb_ca_en50221 *en50221, int slot)
 {
        struct netup_ci_state *state = en50221->data;
-       u8 buf = 0x60;
+       u8 buf;
 
        if (0 != slot)
                return -EINVAL;
 
+       netup_read_i2c(state->i2c_adap, state->ci_i2c_addr,
+                       0, &buf, 1);
+       buf |= 0x60;
+
        return netup_write_i2c(state->i2c_adap, state->ci_i2c_addr,
                                                        0, &buf, 1);
 }
@@ -303,21 +334,35 @@ static void netup_read_ci_status(struct work_struct *work)
        u8 buf[33];
        int ret;
 
-       ret = netup_read_i2c(state->i2c_adap, state->ci_i2c_addr,
-                                                       0, &buf[0], 33);
+       /* CAM module IRQ processing. fast operation */
+       dvb_ca_en50221_frda_irq(&state->ca, 0);
 
-       if (ret != 0)
-               return;
+       /* CAM module INSERT/REMOVE processing. slow operation because of i2c
+        * transfers */
+       if (time_after(jiffies, state->next_status_checked_time)
+                       || !state->status) {
+               ret = netup_read_i2c(state->i2c_adap, state->ci_i2c_addr,
+                               0, &buf[0], 33);
+
+               state->next_status_checked_time = jiffies
+                       + msecs_to_jiffies(1000);
+
+               if (ret != 0)
+                       return;
 
-       ci_dbg_print("%s: Slot Status Addr=[0x%04x], Reg=[0x%02x], data=%02x, "
-               "TS config = %02x\n", __func__, state->ci_i2c_addr, 0, buf[0],
-               buf[32]);
+               ci_dbg_print("%s: Slot Status Addr=[0x%04x], "
+                               "Reg=[0x%02x], data=%02x, "
+                               "TS config = %02x\n", __func__,
+                               state->ci_i2c_addr, 0, buf[0],
+                               buf[0]);
 
-       if (buf[0] & 1)
-               state->status = DVB_CA_EN50221_POLL_CAM_PRESENT |
-                       DVB_CA_EN50221_POLL_CAM_READY;
-       else
-               state->status = 0;
+
+               if (buf[0] & 1)
+                       state->status = DVB_CA_EN50221_POLL_CAM_PRESENT |
+                               DVB_CA_EN50221_POLL_CAM_READY;
+               else
+                       state->status = 0;
+       };
 }
 
 /* CI irq handler */
@@ -347,6 +392,9 @@ int netup_poll_ci_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open
        if (0 != slot)
                return -EINVAL;
 
+       netup_ci_set_irq(en50221, open ? (NETUP_IRQ_DETAM | NETUP_IRQ_IRQAM)
+                       : NETUP_IRQ_DETAM);
+
        return state->status;
 }
 
@@ -381,8 +429,8 @@ int netup_ci_init(struct cx23885_tsport *port)
                0x01, /* power on (use it like store place) */
                0x00, /* RFU */
                0x00, /* int status read only */
-               0x01, /* all int unmasked */
-               0x04, /* int config */
+               NETUP_IRQ_IRQAM | NETUP_IRQ_DETAM, /* DETAM, IRQAM unmasked */
+               0x05, /* EXTINT=active-high, INT=push-pull */
                0x00, /* USCG1 */
                0x04, /* ack active low */
                0x00, /* LOCK = 0 */
@@ -422,6 +470,7 @@ int netup_ci_init(struct cx23885_tsport *port)
        state->ca.poll_slot_status = netup_poll_ci_slot_status;
        state->ca.data = state;
        state->priv = port;
+       state->current_irq_mode = NETUP_IRQ_IRQAM | NETUP_IRQ_DETAM;
 
        ret = netup_write_i2c(state->i2c_adap, state->ci_i2c_addr,
                                                0, &cimax_init[0], 34);
index 0eed852c61e9c9324b861796d76fcc2ad5ffa78c..88c0d2481118f4364ee575cc7d57b1bf577b76e9 100644 (file)
@@ -1568,28 +1568,11 @@ static int vidioc_queryctrl(struct file *file, void *priv,
 
 static int mpeg_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx23885_dev *h, *dev = NULL;
-       struct list_head *list;
+       struct cx23885_dev *dev = video_drvdata(file);
        struct cx23885_fh *fh;
 
        dprintk(2, "%s()\n", __func__);
 
-       lock_kernel();
-       list_for_each(list, &cx23885_devlist) {
-               h = list_entry(list, struct cx23885_dev, devlist);
-               if (h->v4l_device &&
-                   h->v4l_device->minor == minor) {
-                       dev = h;
-                       break;
-               }
-       }
-
-       if (dev == NULL) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
        if (NULL == fh) {
@@ -1597,6 +1580,8 @@ static int mpeg_open(struct file *file)
                return -ENOMEM;
        }
 
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev      = dev;
 
@@ -1736,7 +1721,6 @@ static struct video_device cx23885_mpeg_template = {
        .name          = "cx23885",
        .fops          = &mpeg_fops,
        .ioctl_ops     = &mpeg_ioctl_ops,
-       .minor         = -1,
        .tvnorms       = CX23885_NORMS,
        .current_norm  = V4L2_STD_NTSC_M,
 };
@@ -1746,7 +1730,7 @@ void cx23885_417_unregister(struct cx23885_dev *dev)
        dprintk(1, "%s()\n", __func__);
 
        if (dev->v4l_device) {
-               if (-1 != dev->v4l_device->minor)
+               if (video_is_registered(dev->v4l_device))
                        video_unregister_device(dev->v4l_device);
                else
                        video_device_release(dev->v4l_device);
@@ -1803,6 +1787,7 @@ int cx23885_417_register(struct cx23885_dev *dev)
        /* Allocate and initialize V4L video device */
        dev->v4l_device = cx23885_video_dev_alloc(tsport,
                dev->pci, &cx23885_mpeg_template, "mpeg");
+       video_set_drvdata(dev->v4l_device, dev);
        err = video_register_device(dev->v4l_device,
                VFL_TYPE_GRABBER, -1);
        if (err < 0) {
@@ -1810,8 +1795,8 @@ int cx23885_417_register(struct cx23885_dev *dev)
                return err;
        }
 
-       printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
-              dev->name, dev->v4l_device->num);
+       printk(KERN_INFO "%s: registered device %s [mpeg]\n",
+              dev->name, video_device_node_name(dev->v4l_device));
 
        return 0;
 }
index 04b12d27bc139318efc1e4e4b0786ee79af28716..0dde57e96d30ac99c5adb9f8eab94f838c1b83d8 100644 (file)
@@ -55,9 +55,6 @@ MODULE_PARM_DESC(card, "card type");
 
 static unsigned int cx23885_devcount;
 
-static DEFINE_MUTEX(devlist);
-LIST_HEAD(cx23885_devlist);
-
 #define NO_SYNC_LINE (-1U)
 
 /* FIXME, these allocations will change when
@@ -785,10 +782,6 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
        dev->nr = cx23885_devcount++;
        sprintf(dev->name, "cx23885[%d]", dev->nr);
 
-       mutex_lock(&devlist);
-       list_add_tail(&dev->devlist, &cx23885_devlist);
-       mutex_unlock(&devlist);
-
        /* Configure the internal memory */
        if (dev->pci->device == 0x8880) {
                /* Could be 887 or 888, assume a default */
@@ -2008,10 +2001,6 @@ static void __devexit cx23885_finidev(struct pci_dev *pci_dev)
        /* unregister stuff */
        free_irq(pci_dev->irq, dev);
 
-       mutex_lock(&devlist);
-       list_del(&dev->devlist);
-       mutex_unlock(&devlist);
-
        cx23885_dev_unregister(dev);
        v4l2_device_unregister(v4l2_dev);
        kfree(dev);
index 469e083dd5f8973dd0919c8932d0e6da4813005f..768eec92ccf9685fc9e1e835819348bde61cabe0 100644 (file)
@@ -377,7 +377,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
                 cx23885_boards[dev->board].name);
        snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(dev->pci));
 
-       ret = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
+       ret = ir_input_init(input_dev, &ir->ir, ir_type);
        if (ret < 0)
                goto err_out_free;
 
@@ -397,7 +397,7 @@ int cx23885_input_init(struct cx23885_dev *dev)
        dev->ir_input = ir;
        cx23885_input_ir_start(dev);
 
-       ret = input_register_device(ir->dev);
+       ret = ir_input_register(ir->dev, ir_codes);
        if (ret)
                goto err_out_stop;
 
@@ -407,8 +407,6 @@ err_out_stop:
        cx23885_input_ir_stop(dev);
        dev->ir_input = NULL;
 err_out_free:
-       ir_input_free(input_dev);
-       input_free_device(input_dev);
        kfree(ir);
        return ret;
 }
@@ -420,8 +418,7 @@ void cx23885_input_fini(struct cx23885_dev *dev)
 
        if (dev->ir_input == NULL)
                return;
-       ir_input_free(dev->ir_input->dev);
-       input_unregister_device(dev->ir_input->dev);
+       ir_input_unregister(dev->ir_input->dev);
        kfree(dev->ir_input);
        dev->ir_input = NULL;
 }
index 8b372b4f0de251fc8cb8244eced68833cae26dac..8934d61cf66038f2deb8e4d3022f2dfe313c9268 100644 (file)
@@ -318,11 +318,11 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev,
        if (NULL == vfd)
                return NULL;
        *vfd = *template;
-       vfd->minor = -1;
        vfd->v4l2_dev = &dev->v4l2_dev;
        vfd->release = video_device_release;
        snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
                 dev->name, type, cx23885_boards[dev->board].name);
+       video_set_drvdata(vfd, dev);
        return vfd;
 }
 
@@ -716,46 +716,34 @@ static int get_resource(struct cx23885_fh *fh)
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx23885_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx23885_dev *dev = video_drvdata(file);
        struct cx23885_fh *fh;
-       struct list_head *list;
        enum v4l2_buf_type type = 0;
        int radio = 0;
 
-       lock_kernel();
-       list_for_each(list, &cx23885_devlist) {
-               h = list_entry(list, struct cx23885_dev, devlist);
-               if (h->video_dev &&
-                   h->video_dev->minor == minor) {
-                       dev  = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-               if (h->vbi_dev &&
-                   h->vbi_dev->minor == minor) {
-                       dev  = h;
-                       type = V4L2_BUF_TYPE_VBI_CAPTURE;
-               }
-               if (h->radio_dev &&
-                   h->radio_dev->minor == minor) {
-                       radio = 1;
-                       dev   = h;
-               }
-       }
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
+       switch (vdev->vfl_type) {
+       case VFL_TYPE_GRABBER:
+               type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+               break;
+       case VFL_TYPE_VBI:
+               type = V4L2_BUF_TYPE_VBI_CAPTURE;
+               break;
+       case VFL_TYPE_RADIO:
+               radio = 1;
+               break;
        }
 
-       dprintk(1, "open minor=%d radio=%d type=%s\n",
-               minor, radio, v4l2_type_names[type]);
+       dprintk(1, "open dev=%s radio=%d type=%s\n",
+               video_device_node_name(vdev), radio, v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev      = dev;
        fh->radio    = radio;
@@ -1441,7 +1429,6 @@ static struct video_device cx23885_vbi_template;
 static struct video_device cx23885_video_template = {
        .name                 = "cx23885-video",
        .fops                 = &video_fops,
-       .minor                = -1,
        .ioctl_ops            = &video_ioctl_ops,
        .tvnorms              = CX23885_NORMS,
        .current_norm         = V4L2_STD_NTSC_M,
@@ -1461,7 +1448,7 @@ void cx23885_video_unregister(struct cx23885_dev *dev)
        cx_clear(PCI_INT_MSK, 1);
 
        if (dev->video_dev) {
-               if (-1 != dev->video_dev->minor)
+               if (video_is_registered(dev->video_dev))
                        video_unregister_device(dev->video_dev);
                else
                        video_device_release(dev->video_dev);
@@ -1532,8 +1519,8 @@ int cx23885_video_register(struct cx23885_dev *dev)
                        dev->name);
                goto fail_unreg;
        }
-       printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n",
-              dev->name, dev->video_dev->num);
+       printk(KERN_INFO "%s/0: registered device %s [v4l2]\n",
+              dev->name, video_device_node_name(dev->video_dev));
        /* initial device configuration */
        mutex_lock(&dev->lock);
        cx23885_set_tvnorm(dev, dev->tvnorm);
index fa744764dc8bdf6f2dcea485220b67485c4d0739..08b3f6b136a08c70a593f710fdef53374beecd74 100644 (file)
@@ -303,7 +303,6 @@ struct cx23885_tsport {
 };
 
 struct cx23885_dev {
-       struct list_head           devlist;
        atomic_t                   refcount;
        struct v4l2_device         v4l2_dev;
 
@@ -399,8 +398,6 @@ static inline struct cx23885_dev *to_cx23885(struct v4l2_device *v4l2_dev)
 
 extern struct v4l2_subdev *cx23885_find_hw(struct cx23885_dev *dev, u32 hw);
 
-extern struct list_head cx23885_devlist;
-
 #define SRAM_CH01  0 /* Video A */
 #define SRAM_CH02  1 /* VBI A */
 #define SRAM_CH03  2 /* Video B */
index 3ccc8afeccf32f2d90c8549e454cd01d8195b4b8..2bf57a4527d3484167e42ddde0c4bfb7b41d61de 100644 (file)
@@ -124,15 +124,12 @@ struct cx23888_ir_state {
        atomic_t rxclk_divider;
        atomic_t rx_invert;
 
-       struct kfifo *rx_kfifo;
+       struct kfifo rx_kfifo;
        spinlock_t rx_kfifo_lock;
 
        struct v4l2_subdev_ir_parameters tx_params;
        struct mutex tx_params_lock;
        atomic_t txclk_divider;
-
-       struct kfifo *tx_kfifo;
-       spinlock_t tx_kfifo_lock;
 };
 
 static inline struct cx23888_ir_state *to_state(struct v4l2_subdev *sd)
@@ -522,6 +519,7 @@ static int cx23888_ir_irq_handler(struct v4l2_subdev *sd, u32 status,
 {
        struct cx23888_ir_state *state = to_state(sd);
        struct cx23885_dev *dev = state->dev;
+       unsigned long flags;
 
        u32 cntrl = cx23888_ir_read4(dev, CX23888_IR_CNTRL_REG);
        u32 irqen = cx23888_ir_read4(dev, CX23888_IR_IRQEN_REG);
@@ -594,8 +592,9 @@ static int cx23888_ir_irq_handler(struct v4l2_subdev *sd, u32 status,
                        if (i == 0)
                                break;
                        j = i * sizeof(u32);
-                       k = kfifo_put(state->rx_kfifo,
-                                     (unsigned char *) rx_data, j);
+                       k = kfifo_in_locked(&state->rx_kfifo,
+                                     (unsigned char *) rx_data, j,
+                                     &state->rx_kfifo_lock);
                        if (k != j)
                                kror++; /* rx_kfifo over run */
                }
@@ -631,8 +630,11 @@ static int cx23888_ir_irq_handler(struct v4l2_subdev *sd, u32 status,
                cx23888_ir_write4(dev, CX23888_IR_CNTRL_REG, cntrl);
                *handled = true;
        }
-       if (kfifo_len(state->rx_kfifo) >= CX23888_IR_RX_KFIFO_SIZE / 2)
+
+       spin_lock_irqsave(&state->rx_kfifo_lock, flags);
+       if (kfifo_len(&state->rx_kfifo) >= CX23888_IR_RX_KFIFO_SIZE / 2)
                events |= V4L2_SUBDEV_IR_RX_FIFO_SERVICE_REQ;
+       spin_unlock_irqrestore(&state->rx_kfifo_lock, flags);
 
        if (events)
                v4l2_subdev_notify(sd, V4L2_SUBDEV_IR_RX_NOTIFY, &events);
@@ -657,7 +659,7 @@ static int cx23888_ir_rx_read(struct v4l2_subdev *sd, u8 *buf, size_t count,
                return 0;
        }
 
-       n = kfifo_get(state->rx_kfifo, buf, n);
+       n = kfifo_out_locked(&state->rx_kfifo, buf, n, &state->rx_kfifo_lock);
 
        n /= sizeof(u32);
        *num = n * sizeof(u32);
@@ -785,7 +787,12 @@ static int cx23888_ir_rx_s_parameters(struct v4l2_subdev *sd,
        o->interrupt_enable = p->interrupt_enable;
        o->enable = p->enable;
        if (p->enable) {
-               kfifo_reset(state->rx_kfifo);
+               unsigned long flags;
+
+               spin_lock_irqsave(&state->rx_kfifo_lock, flags);
+               kfifo_reset(&state->rx_kfifo);
+               /* reset tx_fifo too if there is one... */
+               spin_unlock_irqrestore(&state->rx_kfifo_lock, flags);
                if (p->interrupt_enable)
                        irqenable_rx(dev, IRQEN_RSE | IRQEN_RTE | IRQEN_ROE);
                control_rx_enable(dev, p->enable);
@@ -892,7 +899,6 @@ static int cx23888_ir_tx_s_parameters(struct v4l2_subdev *sd,
        o->interrupt_enable = p->interrupt_enable;
        o->enable = p->enable;
        if (p->enable) {
-               kfifo_reset(state->tx_kfifo);
                if (p->interrupt_enable)
                        irqenable_tx(dev, IRQEN_TSE);
                control_tx_enable(dev, p->enable);
@@ -1168,18 +1174,8 @@ int cx23888_ir_probe(struct cx23885_dev *dev)
                return -ENOMEM;
 
        spin_lock_init(&state->rx_kfifo_lock);
-       state->rx_kfifo = kfifo_alloc(CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL,
-                                     &state->rx_kfifo_lock);
-       if (state->rx_kfifo == NULL)
-               return -ENOMEM;
-
-       spin_lock_init(&state->tx_kfifo_lock);
-       state->tx_kfifo = kfifo_alloc(CX23888_IR_TX_KFIFO_SIZE, GFP_KERNEL,
-                                     &state->tx_kfifo_lock);
-       if (state->tx_kfifo == NULL) {
-               kfifo_free(state->rx_kfifo);
+       if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL))
                return -ENOMEM;
-       }
 
        state->dev = dev;
        state->id = V4L2_IDENT_CX23888_IR;
@@ -1211,8 +1207,7 @@ int cx23888_ir_probe(struct cx23885_dev *dev)
                       sizeof(struct v4l2_subdev_ir_parameters));
                v4l2_subdev_call(sd, ir, tx_s_parameters, &default_params);
        } else {
-               kfifo_free(state->rx_kfifo);
-               kfifo_free(state->tx_kfifo);
+               kfifo_free(&state->rx_kfifo);
        }
        return ret;
 }
@@ -1231,8 +1226,7 @@ int cx23888_ir_remove(struct cx23885_dev *dev)
 
        state = to_state(sd);
        v4l2_device_unregister_subdev(sd);
-       kfifo_free(state->rx_kfifo);
-       kfifo_free(state->tx_kfifo);
+       kfifo_free(&state->rx_kfifo);
        kfree(state);
        /* Nothing more to free() as state held the actual v4l2_subdev object */
        return 0;
index fbdc1cde56a6b1597cbac7f37d5f44b9677529b0..6fe30e6c426221283c8df5c0984083f7daf6fbcb 100644 (file)
@@ -1048,21 +1048,15 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
 
 static int mpeg_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx8802_dev *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx8802_dev *dev = video_drvdata(file);
        struct cx8802_fh *fh;
        struct cx8802_driver *drv = NULL;
        int err;
 
-       lock_kernel();
-       dev = cx8802_get_device(minor);
-
        dprintk( 1, "%s\n", __func__);
 
-       if (dev == NULL) {
-               unlock_kernel();
-               return -ENODEV;
-       }
+       lock_kernel();
 
        /* Make sure we can acquire the hardware */
        drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
@@ -1081,7 +1075,7 @@ static int mpeg_open(struct file *file)
                unlock_kernel();
                return -EINVAL;
        }
-       dprintk(1,"open minor=%d\n",minor);
+       dprintk(1, "open dev=%s\n", video_device_node_name(vdev));
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh),GFP_KERNEL);
@@ -1129,10 +1123,6 @@ static int mpeg_release(struct file *file)
        kfree(fh);
 
        /* Make sure we release the hardware */
-       dev = cx8802_get_device(video_devdata(file)->minor);
-       if (dev == NULL)
-               return -ENODEV;
-
        drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD);
        if (drv)
                drv->request_release(drv);
@@ -1220,7 +1210,6 @@ static struct video_device cx8802_mpeg_template = {
        .name                 = "cx8802",
        .fops                 = &mpeg_fops,
        .ioctl_ops            = &mpeg_ioctl_ops,
-       .minor                = -1,
        .tvnorms              = CX88_NORMS,
        .current_norm         = V4L2_STD_NTSC_M,
 };
@@ -1276,7 +1265,7 @@ static int cx8802_blackbird_advise_release(struct cx8802_driver *drv)
 static void blackbird_unregister_video(struct cx8802_dev *dev)
 {
        if (dev->mpeg_dev) {
-               if (-1 != dev->mpeg_dev->minor)
+               if (video_is_registered(dev->mpeg_dev))
                        video_unregister_device(dev->mpeg_dev);
                else
                        video_device_release(dev->mpeg_dev);
@@ -1290,14 +1279,15 @@ static int blackbird_register_video(struct cx8802_dev *dev)
 
        dev->mpeg_dev = cx88_vdev_init(dev->core,dev->pci,
                                       &cx8802_mpeg_template,"mpeg");
+       video_set_drvdata(dev->mpeg_dev, dev);
        err = video_register_device(dev->mpeg_dev,VFL_TYPE_GRABBER, -1);
        if (err < 0) {
                printk(KERN_INFO "%s/2: can't register mpeg device\n",
                       dev->core->name);
                return err;
        }
-       printk(KERN_INFO "%s/2: registered device video%d [mpeg]\n",
-              dev->core->name, dev->mpeg_dev->num);
+       printk(KERN_INFO "%s/2: registered device %s [mpeg]\n",
+              dev->core->name, video_device_node_name(dev->mpeg_dev));
        return 0;
 }
 
index 92b8cdf9fb815296ee102cffe98666416bafe192..f9fda18b410c6b21a89f043ea7b6712016396e4d 100644 (file)
@@ -360,7 +360,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
        snprintf(ir->name, sizeof(ir->name), "cx88 IR (%s)", core->board.name);
        snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", pci_name(pci));
 
-       err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
+       err = ir_input_init(input_dev, &ir->ir, ir_type);
        if (err < 0)
                goto err_out_free;
 
@@ -383,7 +383,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
        cx88_ir_start(core, ir);
 
        /* all done */
-       err = input_register_device(ir->input);
+       err = ir_input_register(ir->input, ir_codes);
        if (err)
                goto err_out_stop;
 
@@ -393,8 +393,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
        cx88_ir_stop(core, ir);
        core->ir = NULL;
  err_out_free:
-       ir_input_free(input_dev);
-       input_free_device(input_dev);
        kfree(ir);
        return err;
 }
@@ -408,8 +406,7 @@ int cx88_ir_fini(struct cx88_core *core)
                return 0;
 
        cx88_ir_stop(core, ir);
-       ir_input_free(ir->input);
-       input_unregister_device(ir->input);
+       ir_input_unregister(ir->input);
        kfree(ir);
 
        /* done */
index de9ff0fc741f06611e11bd5220d0c78331b912c5..bb51048934119c7d32a456b5ae035b8697463ef5 100644 (file)
@@ -580,21 +580,6 @@ static int cx8802_resume_common(struct pci_dev *pci_dev)
        return 0;
 }
 
-#if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \
-    defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE)
-struct cx8802_dev *cx8802_get_device(int minor)
-{
-       struct cx8802_dev *dev;
-
-       list_for_each_entry(dev, &cx8802_devlist, devlist)
-               if (dev->mpeg_dev && dev->mpeg_dev->minor == minor)
-                       return dev;
-
-       return NULL;
-}
-EXPORT_SYMBOL(cx8802_get_device);
-#endif
-
 struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype)
 {
        struct cx8802_driver *d;
index d7e8fcee559c04c4ff5d36a7840e6236924dd045..48c450f4a85a2ad6b7e7ff9cd08c0dde8dae01e4 100644 (file)
@@ -75,10 +75,6 @@ MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
 #define dprintk(level,fmt, arg...)     if (video_debug >= level) \
        printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
 
-/* ------------------------------------------------------------------ */
-
-static LIST_HEAD(cx8800_devlist);
-
 /* ------------------------------------------------------------------- */
 /* static data                                                         */
 
@@ -753,38 +749,31 @@ static int get_ressource(struct cx8800_fh *fh)
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx8800_dev *h,*dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx8800_dev *dev = video_drvdata(file);
        struct cx88_core *core;
        struct cx8800_fh *fh;
        enum v4l2_buf_type type = 0;
        int radio = 0;
 
-       lock_kernel();
-       list_for_each_entry(h, &cx8800_devlist, devlist) {
-               if (h->video_dev->minor == minor) {
-                       dev  = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-               if (h->vbi_dev->minor == minor) {
-                       dev  = h;
-                       type = V4L2_BUF_TYPE_VBI_CAPTURE;
-               }
-               if (h->radio_dev &&
-                   h->radio_dev->minor == minor) {
-                       radio = 1;
-                       dev   = h;
-               }
-       }
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
+       switch (vdev->vfl_type) {
+       case VFL_TYPE_GRABBER:
+               type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+               break;
+       case VFL_TYPE_VBI:
+               type = V4L2_BUF_TYPE_VBI_CAPTURE;
+               break;
+       case VFL_TYPE_RADIO:
+               radio = 1;
+               break;
        }
 
+       lock_kernel();
+
        core = dev->core;
 
-       dprintk(1,"open minor=%d radio=%d type=%s\n",
-               minor,radio,v4l2_type_names[type]);
+       dprintk(1, "open dev=%s radio=%d type=%s\n",
+               video_device_node_name(vdev), radio, v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh),GFP_KERNEL);
@@ -1733,7 +1722,6 @@ static struct video_device cx8800_vbi_template;
 static struct video_device cx8800_video_template = {
        .name                 = "cx8800-video",
        .fops                 = &video_fops,
-       .minor                = -1,
        .ioctl_ops            = &video_ioctl_ops,
        .tvnorms              = CX88_NORMS,
        .current_norm         = V4L2_STD_NTSC_M,
@@ -1769,7 +1757,6 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
 static struct video_device cx8800_radio_template = {
        .name                 = "cx8800-radio",
        .fops                 = &radio_fops,
-       .minor                = -1,
        .ioctl_ops            = &radio_ioctl_ops,
 };
 
@@ -1778,21 +1765,21 @@ static struct video_device cx8800_radio_template = {
 static void cx8800_unregister_video(struct cx8800_dev *dev)
 {
        if (dev->radio_dev) {
-               if (-1 != dev->radio_dev->minor)
+               if (video_is_registered(dev->radio_dev))
                        video_unregister_device(dev->radio_dev);
                else
                        video_device_release(dev->radio_dev);
                dev->radio_dev = NULL;
        }
        if (dev->vbi_dev) {
-               if (-1 != dev->vbi_dev->minor)
+               if (video_is_registered(dev->vbi_dev))
                        video_unregister_device(dev->vbi_dev);
                else
                        video_device_release(dev->vbi_dev);
                dev->vbi_dev = NULL;
        }
        if (dev->video_dev) {
-               if (-1 != dev->video_dev->minor)
+               if (video_is_registered(dev->video_dev))
                        video_unregister_device(dev->video_dev);
                else
                        video_device_release(dev->video_dev);
@@ -1909,6 +1896,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
        /* register v4l devices */
        dev->video_dev = cx88_vdev_init(core,dev->pci,
                                        &cx8800_video_template,"video");
+       video_set_drvdata(dev->video_dev, dev);
        err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
                                    video_nr[core->nr]);
        if (err < 0) {
@@ -1916,10 +1904,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
                       core->name);
                goto fail_unreg;
        }
-       printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n",
-              core->name, dev->video_dev->num);
+       printk(KERN_INFO "%s/0: registered device %s [v4l2]\n",
+              core->name, video_device_node_name(dev->video_dev));
 
        dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi");
+       video_set_drvdata(dev->vbi_dev, dev);
        err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
                                    vbi_nr[core->nr]);
        if (err < 0) {
@@ -1927,12 +1916,13 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
                       core->name);
                goto fail_unreg;
        }
-       printk(KERN_INFO "%s/0: registered device vbi%d\n",
-              core->name, dev->vbi_dev->num);
+       printk(KERN_INFO "%s/0: registered device %s\n",
+              core->name, video_device_node_name(dev->vbi_dev));
 
        if (core->board.radio.type == CX88_RADIO) {
                dev->radio_dev = cx88_vdev_init(core,dev->pci,
                                                &cx8800_radio_template,"radio");
+               video_set_drvdata(dev->radio_dev, dev);
                err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
                                            radio_nr[core->nr]);
                if (err < 0) {
@@ -1940,12 +1930,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
                               core->name);
                        goto fail_unreg;
                }
-               printk(KERN_INFO "%s/0: registered device radio%d\n",
-                      core->name, dev->radio_dev->num);
+               printk(KERN_INFO "%s/0: registered device %s\n",
+                      core->name, video_device_node_name(dev->radio_dev));
        }
 
        /* everything worked */
-       list_add_tail(&dev->devlist,&cx8800_devlist);
        pci_set_drvdata(pci_dev,dev);
 
        /* initial device configuration */
@@ -2001,7 +1990,6 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev)
 
        /* free memory */
        btcx_riscmem_free(dev->pci,&dev->vidq.stopper);
-       list_del(&dev->devlist);
        cx88_core_put(core,dev->pci);
        kfree(dev);
 }
index e1c521710103140d51c5960096a0634e5355a3cb..b1499bf604eafff2fbfa8a102959fd94e0206fa9 100644 (file)
@@ -423,7 +423,6 @@ struct cx8800_suspend_state {
 
 struct cx8800_dev {
        struct cx88_core           *core;
-       struct list_head           devlist;
        spinlock_t                 slock;
 
        /* various device info */
@@ -670,7 +669,6 @@ int cx88_audio_thread(void *data);
 
 int cx8802_register_driver(struct cx8802_driver *drv);
 int cx8802_unregister_driver(struct cx8802_driver *drv);
-struct cx8802_dev *cx8802_get_device(int minor);
 struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype);
 
 /* ----------------------------------------------------------- */
index 12a1b3d7132de212c49a992abce536ebea7250ed..de22bc9faf21274e8c6aacbf942ce41376181fa9 100644 (file)
@@ -70,7 +70,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
-#include <linux/version.h>
 #include <media/v4l2-common.h>
 #include <linux/io.h>
 #include <media/davinci/vpfe_capture.h>
@@ -1967,7 +1966,6 @@ static __init int vpfe_probe(struct platform_device *pdev)
        vfd->release            = video_device_release;
        vfd->fops               = &vpfe_fops;
        vfd->ioctl_ops          = &vpfe_ioctl_ops;
-       vfd->minor              = -1;
        vfd->tvnorms            = 0;
        vfd->current_norm       = V4L2_STD_PAL;
        vfd->v4l2_dev           = &vpfe_dev->v4l2_dev;
@@ -2071,7 +2069,7 @@ probe_out_video_unregister:
 probe_out_v4l2_unregister:
        v4l2_device_unregister(&vpfe_dev->v4l2_dev);
 probe_out_video_release:
-       if (vpfe_dev->video_dev->minor == -1)
+       if (!video_is_registered(vpfe_dev->video_dev))
                video_device_release(vpfe_dev->video_dev);
 probe_out_release_irq:
        free_irq(vpfe_dev->ccdc_irq0, vpfe_dev);
@@ -2091,7 +2089,7 @@ probe_free_dev_mem:
 /*
  * vpfe_remove : It un-register device from V4L2 driver
  */
-static int vpfe_remove(struct platform_device *pdev)
+static int __devexit vpfe_remove(struct platform_device *pdev)
 {
        struct vpfe_device *vpfe_dev = platform_get_drvdata(pdev);
        struct resource *res;
@@ -2127,7 +2125,7 @@ vpfe_resume(struct device *dev)
        return -1;
 }
 
-static struct dev_pm_ops vpfe_dev_pm_ops = {
+static const struct dev_pm_ops vpfe_dev_pm_ops = {
        .suspend = vpfe_suspend,
        .resume = vpfe_resume,
 };
index 3b8eac31ecae7c923c976f4e715456baac4d8b77..1f532e31cd49b28b3c8f998ce73ed0cce3da2120 100644 (file)
@@ -266,7 +266,7 @@ fail:
        return status;
 }
 
-static int vpif_remove(struct platform_device *pdev)
+static int __devexit vpif_remove(struct platform_device *pdev)
 {
        iounmap(vpif_base);
        release_mem_region(res->start, res_len);
index d947ee5e4eb4b9b02d0f71ea7b2b7553a6b4fc11..78130721f578fc9bd310a92ac4b6c63771737b3d 100644 (file)
@@ -2107,7 +2107,7 @@ vpif_resume(struct device *dev)
        return -1;
 }
 
-static struct dev_pm_ops vpif_dev_pm_ops = {
+static const struct dev_pm_ops vpif_dev_pm_ops = {
        .suspend = vpif_suspend,
        .resume = vpif_resume,
 };
index d14cfb200ed0f83674ee106f1e9c3200cbf81697..dfddef7228dd2c08d40f1b2ec462cec93085a303 100644 (file)
@@ -1347,7 +1347,6 @@ static const struct v4l2_file_operations vpif_fops = {
 static struct video_device vpif_video_template = {
        .name           = "vpif",
        .fops           = &vpif_fops,
-       .minor          = -1,
        .ioctl_ops      = &vpif_ioctl_ops,
        .tvnorms        = DM646X_V4L2_STD,
        .current_norm   = V4L2_STD_625_50,
index 453236bd7559b9a8613bd7d62578430c6baf4e1e..7ee72ecd3d81baea218dec5b41ab963f9978b3c4 100644 (file)
@@ -268,7 +268,7 @@ fail1:
        return status;
 }
 
-static int vpss_remove(struct platform_device *pdev)
+static int __devexit vpss_remove(struct platform_device *pdev)
 {
        iounmap(oper_cfg.vpss_bl_regs_base);
        release_mem_region(oper_cfg.r1->start, oper_cfg.len1);
index 82da205047befb219b7c6f945a6c44af222d93ed..25100001ffff838b090794b59cc9df22eb04d7ec 100644 (file)
@@ -2285,7 +2285,7 @@ void em28xx_register_i2c_ir(struct em28xx *dev)
                dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)";
                break;
        case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
-               dev->init_data.ir_codes = &ir_codes_hauppauge_new_table;
+               dev->init_data.ir_codes = &ir_codes_rc5_hauppauge_new_table;
                dev->init_data.get_key = em28xx_get_key_em_haup;
                dev->init_data.name = "i2c IR (EM2840 Hauppauge)";
                break;
@@ -2653,7 +2653,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
        INIT_LIST_HEAD(&dev->vbiq.active);
        INIT_LIST_HEAD(&dev->vbiq.queued);
 
-
        if (dev->board.has_msp34xx) {
                /* Send a reset to other chips via gpio */
                errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7);
@@ -2923,9 +2922,9 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
 
        if (dev->users) {
                em28xx_warn
-                   ("device /dev/video%d is open! Deregistration and memory "
+                   ("device %s is open! Deregistration and memory "
                     "deallocation are deferred on close.\n",
-                               dev->vdev->num);
+                    video_device_node_name(dev->vdev));
 
                dev->state |= DEV_MISCONFIGURED;
                em28xx_uninit_isoc(dev);
index 3f86d36dff2b0e490dcad8dd5ca93dbd6fd3ab2f..b311d4514bdf0e78b270d45d014aeec55c071aca 100644 (file)
@@ -216,7 +216,7 @@ int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val)
  * sets only some bits (specified by bitmask) of a register, by first reading
  * the actual value
  */
-static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
+int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
                                 u8 bitmask)
 {
        int oldval;
@@ -1136,34 +1136,6 @@ void em28xx_wake_i2c(struct em28xx *dev)
 static LIST_HEAD(em28xx_devlist);
 static DEFINE_MUTEX(em28xx_devlist_mutex);
 
-struct em28xx *em28xx_get_device(int minor,
-                                enum v4l2_buf_type *fh_type,
-                                int *has_radio)
-{
-       struct em28xx *h, *dev = NULL;
-
-       *fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-       *has_radio = 0;
-
-       mutex_lock(&em28xx_devlist_mutex);
-       list_for_each_entry(h, &em28xx_devlist, devlist) {
-               if (h->vdev->minor == minor)
-                       dev = h;
-               if (h->vbi_dev && h->vbi_dev->minor == minor) {
-                       dev = h;
-                       *fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
-               }
-               if (h->radio_dev &&
-                   h->radio_dev->minor == minor) {
-                       dev = h;
-                       *has_radio = 1;
-               }
-       }
-       mutex_unlock(&em28xx_devlist_mutex);
-
-       return dev;
-}
-
 /*
  * em28xx_realease_resources()
  * unregisters the v4l2,i2c and usb devices
index d96ec7c09dcaab1580cbfd9bf3e1435dd151615e..af0d935c29be2c52b98397a58501a4dc19feb169 100644 (file)
@@ -112,10 +112,13 @@ int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
 int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
 {
        unsigned char buf[2];
-       unsigned char code;
+       u16 code;
+       int size;
 
        /* poll IR chip */
-       if (2 != i2c_master_recv(ir->c, buf, 2))
+       size = i2c_master_recv(ir->c, buf, sizeof(buf));
+
+       if (size != 2)
                return -EIO;
 
        /* Does eliminate repeated parity code */
@@ -124,16 +127,30 @@ int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
 
        ir->old = buf[1];
 
-       /* Rearranges bits to the right order */
-       code =   ((buf[0]&0x01)<<5) | /* 0010 0000 */
-                ((buf[0]&0x02)<<3) | /* 0001 0000 */
-                ((buf[0]&0x04)<<1) | /* 0000 1000 */
-                ((buf[0]&0x08)>>1) | /* 0000 0100 */
-                ((buf[0]&0x10)>>3) | /* 0000 0010 */
-                ((buf[0]&0x20)>>5);  /* 0000 0001 */
-
-       i2cdprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n",
-                       code, buf[0]);
+       /*
+        * Rearranges bits to the right order.
+        * The bit order were determined experimentally by using
+        * The original Hauppauge Grey IR and another RC5 that uses addr=0x08
+        * The RC5 code has 14 bits, but we've experimentally determined
+        * the meaning for only 11 bits.
+        * So, the code translation is not complete. Yet, it is enough to
+        * work with the provided RC5 IR.
+        */
+       code =
+                ((buf[0] & 0x01) ? 0x0020 : 0) | /*            0010 0000 */
+                ((buf[0] & 0x02) ? 0x0010 : 0) | /*            0001 0000 */
+                ((buf[0] & 0x04) ? 0x0008 : 0) | /*            0000 1000 */
+                ((buf[0] & 0x08) ? 0x0004 : 0) | /*            0000 0100 */
+                ((buf[0] & 0x10) ? 0x0002 : 0) | /*            0000 0010 */
+                ((buf[0] & 0x20) ? 0x0001 : 0) | /*            0000 0001 */
+                ((buf[1] & 0x08) ? 0x1000 : 0) | /* 0001 0000            */
+                ((buf[1] & 0x10) ? 0x0800 : 0) | /* 0000 1000            */
+                ((buf[1] & 0x20) ? 0x0400 : 0) | /* 0000 0100            */
+                ((buf[1] & 0x40) ? 0x0200 : 0) | /* 0000 0010            */
+                ((buf[1] & 0x80) ? 0x0100 : 0);  /* 0000 0001            */
+
+       i2cdprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x%02x)\n",
+                       code, buf[1], buf[0]);
 
        /* return key */
        *ir_key = code;
@@ -337,19 +354,28 @@ int em28xx_ir_init(struct em28xx *dev)
                goto err_out_free;
 
        ir->input = input_dev;
+       ir_config = EM2874_IR_RC5;
+
+       /* Adjust xclk based o IR table for RC5/NEC tables */
+       if (dev->board.ir_codes->ir_type == IR_TYPE_RC5) {
+               dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE;
+               ir->full_code = 1;
+       } else  if (dev->board.ir_codes->ir_type == IR_TYPE_NEC) {
+               dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE;
+               ir_config = EM2874_IR_NEC;
+               ir->full_code = 1;
+       }
+       em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk,
+                             EM28XX_XCLK_IR_RC5_MODE);
 
        /* Setup the proper handler based on the chip */
        switch (dev->chip_id) {
        case CHIP_ID_EM2860:
        case CHIP_ID_EM2883:
-               if (dev->model == EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950)
-                       ir->full_code = 1;
                ir->get_key = default_polling_getkey;
                break;
        case CHIP_ID_EM2874:
                ir->get_key = em2874_polling_getkey;
-               /* For now we only support RC5, so enable it */
-               ir_config = EM2874_IR_RC5;
                em28xx_write_regs(dev, EM2874_R50_IR_CONFIG, &ir_config, 1);
                break;
        default:
@@ -367,8 +393,7 @@ int em28xx_ir_init(struct em28xx *dev)
        usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
        strlcat(ir->phys, "/input0", sizeof(ir->phys));
 
-       err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER,
-                            dev->board.ir_codes);
+       err = ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER);
        if (err < 0)
                goto err_out_free;
 
@@ -387,7 +412,7 @@ int em28xx_ir_init(struct em28xx *dev)
        em28xx_ir_start(ir);
 
        /* all done */
-       err = input_register_device(ir->input);
+       err = ir_input_register(ir->input, dev->board.ir_codes);
        if (err)
                goto err_out_stop;
 
@@ -396,8 +421,6 @@ int em28xx_ir_init(struct em28xx *dev)
        em28xx_ir_stop(ir);
        dev->ir = NULL;
  err_out_free:
-       ir_input_free(input_dev);
-       input_free_device(input_dev);
        kfree(ir);
        return err;
 }
@@ -411,8 +434,7 @@ int em28xx_ir_fini(struct em28xx *dev)
                return 0;
 
        em28xx_ir_stop(ir);
-       ir_input_free(ir->input);
-       input_unregister_device(ir->input);
+       ir_input_unregister(ir->input);
        kfree(ir);
 
        /* done */
index 7ad65370f274a24a8cfb2028af2c41d449794f27..849b18c94037d69974ae59f6368f137440f3faa1 100644 (file)
@@ -2081,22 +2081,30 @@ static int radio_queryctrl(struct file *file, void *priv,
  */
 static int em28xx_v4l2_open(struct file *filp)
 {
-       int minor = video_devdata(filp)->minor;
-       int errCode = 0, radio;
-       struct em28xx *dev;
-       enum v4l2_buf_type fh_type;
+       int errCode = 0, radio = 0;
+       struct video_device *vdev = video_devdata(filp);
+       struct em28xx *dev = video_drvdata(filp);
+       enum v4l2_buf_type fh_type = 0;
        struct em28xx_fh *fh;
        enum v4l2_field field;
 
-       dev = em28xx_get_device(minor, &fh_type, &radio);
-
-       if (NULL == dev)
-               return -ENODEV;
+       switch (vdev->vfl_type) {
+       case VFL_TYPE_GRABBER:
+               fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+               break;
+       case VFL_TYPE_VBI:
+               fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
+               break;
+       case VFL_TYPE_RADIO:
+               radio = 1;
+               break;
+       }
 
        mutex_lock(&dev->lock);
 
-       em28xx_videodbg("open minor=%d type=%s users=%d\n",
-                               minor, v4l2_type_names[fh_type], dev->users);
+       em28xx_videodbg("open dev=%s type=%s users=%d\n",
+                       video_device_node_name(vdev), v4l2_type_names[fh_type],
+                       dev->users);
 
 
        fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL);
@@ -2160,25 +2168,25 @@ void em28xx_release_analog_resources(struct em28xx *dev)
        /*FIXME: I2C IR should be disconnected */
 
        if (dev->radio_dev) {
-               if (-1 != dev->radio_dev->minor)
+               if (video_is_registered(dev->radio_dev))
                        video_unregister_device(dev->radio_dev);
                else
                        video_device_release(dev->radio_dev);
                dev->radio_dev = NULL;
        }
        if (dev->vbi_dev) {
-               em28xx_info("V4L2 device /dev/vbi%d deregistered\n",
-                           dev->vbi_dev->num);
-               if (-1 != dev->vbi_dev->minor)
+               em28xx_info("V4L2 device %s deregistered\n",
+                           video_device_node_name(dev->vbi_dev));
+               if (video_is_registered(dev->vbi_dev))
                        video_unregister_device(dev->vbi_dev);
                else
                        video_device_release(dev->vbi_dev);
                dev->vbi_dev = NULL;
        }
        if (dev->vdev) {
-               em28xx_info("V4L2 device /dev/video%d deregistered\n",
-                           dev->vdev->num);
-               if (-1 != dev->vdev->minor)
+               em28xx_info("V4L2 device %s deregistered\n",
+                           video_device_node_name(dev->vdev));
+               if (video_is_registered(dev->vdev))
                        video_unregister_device(dev->vdev);
                else
                        video_device_release(dev->vdev);
@@ -2397,8 +2405,6 @@ static const struct video_device em28xx_video_template = {
        .release                    = video_device_release,
        .ioctl_ops                  = &video_ioctl_ops,
 
-       .minor                      = -1,
-
        .tvnorms                    = V4L2_STD_ALL,
        .current_norm               = V4L2_STD_PAL,
 };
@@ -2433,7 +2439,6 @@ static struct video_device em28xx_radio_template = {
        .name                 = "em28xx-radio",
        .fops                 = &radio_fops,
        .ioctl_ops            = &radio_ioctl_ops,
-       .minor                = -1,
 };
 
 /******************************** usb interface ******************************/
@@ -2451,7 +2456,6 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
                return NULL;
 
        *vfd            = *template;
-       vfd->minor      = -1;
        vfd->v4l2_dev   = &dev->v4l2_dev;
        vfd->release    = video_device_release;
        vfd->debug      = video_debug;
@@ -2459,6 +2463,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
        snprintf(vfd->name, sizeof(vfd->name), "%s %s",
                 dev->name, type_name);
 
+       video_set_drvdata(vfd, dev);
        return vfd;
 }
 
@@ -2540,16 +2545,16 @@ int em28xx_register_analog_devices(struct em28xx *dev)
                        em28xx_errdev("can't register radio device\n");
                        return ret;
                }
-               em28xx_info("Registered radio device as /dev/radio%d\n",
-                           dev->radio_dev->num);
+               em28xx_info("Registered radio device as %s\n",
+                           video_device_node_name(dev->radio_dev));
        }
 
-       em28xx_info("V4L2 video device registered as /dev/video%d\n",
-                               dev->vdev->num);
+       em28xx_info("V4L2 video device registered as %s\n",
+                   video_device_node_name(dev->vdev));
 
        if (dev->vbi_dev)
-               em28xx_info("V4L2 VBI device registered as /dev/vbi%d\n",
-                           dev->vbi_dev->num);
+               em28xx_info("V4L2 VBI device registered as %s\n",
+                           video_device_node_name(dev->vbi_dev));
 
        return 0;
 }
index 441df644ddbe329146329e17854d82de9842d808..80d9b4fa1b971adad8ad63233c65355e3c7ba05b 100644 (file)
@@ -643,6 +643,8 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
                          int len);
 int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
 int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val);
+int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
+                                u8 bitmask);
 
 int em28xx_read_ac97(struct em28xx *dev, u8 reg);
 int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val);
@@ -666,9 +668,6 @@ int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio);
 void em28xx_wake_i2c(struct em28xx *dev);
 void em28xx_remove_from_devlist(struct em28xx *dev);
 void em28xx_add_into_devlist(struct em28xx *dev);
-struct em28xx *em28xx_get_device(int minor,
-                                enum v4l2_buf_type *fh_type,
-                                int *has_radio);
 int em28xx_register_extension(struct em28xx_ops *dev);
 void em28xx_unregister_extension(struct em28xx_ops *dev);
 void em28xx_init_extension(struct em28xx *dev);
index 88987a57cf7b655e820517a32fd35f67fe83c1d1..e6c23d5098620215041cb652ee049b7bdd0323df 100644 (file)
@@ -587,8 +587,8 @@ static int et61x251_stream_interrupt(struct et61x251_device* cam)
        else if (cam->stream != STREAM_OFF) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "URB timeout reached. The camera is misconfigured. To "
-                      "use it, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use it, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -1195,7 +1195,8 @@ static void et61x251_release_resources(struct kref *kref)
 
        cam = container_of(kref, struct et61x251_device, kref);
 
-       DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->num);
+       DBG(2, "V4L2 device %s deregistered",
+           video_device_node_name(cam->v4ldev));
        video_set_drvdata(cam->v4ldev, NULL);
        video_unregister_device(cam->v4ldev);
        usb_put_dev(cam->usbdev);
@@ -1236,8 +1237,8 @@ static int et61x251_open(struct file *filp)
        }
 
        if (cam->users) {
-               DBG(2, "Device /dev/video%d is already in use",
-                      cam->v4ldev->num);
+               DBG(2, "Device %s is already in use",
+                      video_device_node_name(cam->v4ldev));
                DBG(3, "Simultaneous opens are not supported");
                if ((filp->f_flags & O_NONBLOCK) ||
                    (filp->f_flags & O_NDELAY)) {
@@ -1280,7 +1281,8 @@ static int et61x251_open(struct file *filp)
        cam->frame_count = 0;
        et61x251_empty_framequeues(cam);
 
-       DBG(3, "Video device /dev/video%d is open", cam->v4ldev->num);
+       DBG(3, "Video device %s is open",
+           video_device_node_name(cam->v4ldev));
 
 out:
        mutex_unlock(&cam->open_mutex);
@@ -1304,7 +1306,8 @@ static int et61x251_release(struct file *filp)
        cam->users--;
        wake_up_interruptible_nr(&cam->wait_open, 1);
 
-       DBG(3, "Video device /dev/video%d closed", cam->v4ldev->num);
+       DBG(3, "Video device %s closed",
+           video_device_node_name(cam->v4ldev));
 
        kref_put(&cam->kref, et61x251_release_resources);
 
@@ -1846,8 +1849,8 @@ et61x251_vidioc_s_crop(struct et61x251_device* cam, void __user * arg)
        if (err) { /* atomic, no rollback in ioctl() */
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -1859,8 +1862,8 @@ et61x251_vidioc_s_crop(struct et61x251_device* cam, void __user * arg)
            nbuffers != et61x251_request_buffers(cam, nbuffers, cam->io)) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -ENOMEM;
        }
 
@@ -2069,8 +2072,8 @@ et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
        if (err) { /* atomic, no rollback in ioctl() */
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -2081,8 +2084,8 @@ et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
            nbuffers != et61x251_request_buffers(cam, nbuffers, cam->io)) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -ENOMEM;
        }
 
@@ -2130,7 +2133,7 @@ et61x251_vidioc_s_jpegcomp(struct et61x251_device* cam, void __user * arg)
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
                       "problems. To use the camera, close and open "
-                      "/dev/video%d again.", cam->v4ldev->num);
+                      "%s again.", video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -2584,7 +2587,6 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
 
        strcpy(cam->v4ldev->name, "ET61X[12]51 PC Camera");
        cam->v4ldev->fops = &et61x251_fops;
-       cam->v4ldev->minor = video_nr[dev_nr];
        cam->v4ldev->release = video_device_release;
        cam->v4ldev->parent = &udev->dev;
        video_set_drvdata(cam->v4ldev, cam);
@@ -2603,7 +2605,8 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
                goto fail;
        }
 
-       DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->num);
+       DBG(2, "V4L2 device registered as %s",
+           video_device_node_name(cam->v4ldev));
 
        cam->module_param.force_munmap = force_munmap[dev_nr];
        cam->module_param.frame_timeout = frame_timeout[dev_nr];
@@ -2654,9 +2657,9 @@ static void et61x251_usb_disconnect(struct usb_interface* intf)
        DBG(2, "Disconnecting %s...", cam->v4ldev->name);
 
        if (cam->users) {
-               DBG(2, "Device /dev/video%d is open! Deregistration and "
-                      "memory deallocation are deferred.",
-                   cam->v4ldev->num);
+               DBG(2, "Device %s is open! Deregistration and memory "
+                      "deallocation are deferred.",
+                   video_device_node_name(cam->v4ldev));
                cam->state |= DEV_MISCONFIGURED;
                et61x251_stop_transfer(cam);
                cam->state |= DEV_DISCONNECTED;
index 2f0b8d621e0031c7539a980bf3681d1d72d8acfd..c98b5d69c43809e8f04f9f7161be0f445aa26efd 100644 (file)
@@ -1046,14 +1046,14 @@ static struct sd_desc sd_desc = {
 };
 
 /* -- module initialisation -- */
-static __devinitdata struct usb_device_id device_table[] = {
+static const struct usb_device_id device_table[] __devinitconst = {
        {USB_DEVICE(0x0572, 0x0041)},
        {}
 };
 MODULE_DEVICE_TABLE(usb, device_table);
 
 /* -- device connect -- */
-static int sd_probe(struct usb_interface *intf,
+static int __devinit sd_probe(struct usb_interface *intf,
                        const struct usb_device_id *id)
 {
        return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
index 9de86419ae1edcf7f50f540a929cdeaf6cf6b68a..fdf4c0ec5e7af6c93adf25cf684fd59efe478320 100644 (file)
@@ -864,7 +864,7 @@ static struct sd_desc sd_desc = {
 };
 
 /* -- module initialisation -- */
-static __devinitdata struct usb_device_id device_table[] = {
+static const struct usb_device_id device_table[] __devinitconst = {
        {USB_DEVICE(0x102c, 0x6151), .driver_info = SENSOR_PAS106},
 #if !defined CONFIG_USB_ET61X251 && !defined CONFIG_USB_ET61X251_MODULE
        {USB_DEVICE(0x102c, 0x6251), .driver_info = SENSOR_TAS5130CXX},
@@ -875,7 +875,7 @@ static __devinitdata struct usb_device_id device_table[] = {
 MODULE_DEVICE_TABLE(usb, device_table);
 
 /* -- device connect -- */
-static int sd_probe(struct usb_interface *intf,
+static int __devinit sd_probe(struct usb_interface *intf,
                    const struct usb_device_id *id)
 {
        return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
index 1355e526ee8457a13f930f680a02d73b76a3a88c..c276a7debdec9fdde3f0b3fa6d421b7c3864b7bf 100644 (file)
@@ -345,7 +345,7 @@ static int mi1320_configure_alt(struct gspca_dev *gspca_dev)
        return 0;
 }
 
-int mi1320_camera_settings(struct gspca_dev *gspca_dev)
+static int mi1320_camera_settings(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
 
index 80cb3f1b36f7bb8be6b01d0756cc4c08d1182f43..7c31b4f2abea94eaaacc5145fe96dd59c5766cc3 100644 (file)
@@ -769,7 +769,7 @@ static int mi2020_configure_alt(struct gspca_dev *gspca_dev)
        return 0;
 }
 
-int mi2020_camera_settings(struct gspca_dev *gspca_dev)
+static int mi2020_camera_settings(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
 
index a695e0ae13c2c40e44b8b4f8e181d2cc07d1c680..4878c8f66543dc26ac88d7179f642dcabc7d3453 100644 (file)
@@ -40,7 +40,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
 static void sd_callback(struct gspca_dev *gspca_dev);
 
 static int gl860_guess_sensor(struct gspca_dev *gspca_dev,
-                               s32 vendor_id, s32 product_id);
+                               u16 vendor_id, u16 product_id);
 
 /*============================ driver options ==============================*/
 
@@ -326,11 +326,11 @@ static int sd_config(struct gspca_dev *gspca_dev,
 {
        struct sd *sd = (struct sd *) gspca_dev;
        struct cam *cam;
-       s32 vendor_id, product_id;
+       u16 vendor_id, product_id;
 
        /* Get USB VendorID and ProductID */
-       vendor_id  = le16_to_cpu(id->idVendor);
-       product_id = le16_to_cpu(id->idProduct);
+       vendor_id  = id->idVendor;
+       product_id = id->idProduct;
 
        sd->nbRightUp = 1;
        sd->nbIm = -1;
@@ -534,8 +534,8 @@ static int sd_probe(struct usb_interface *intf,
                gspca_dev = usb_get_intfdata(intf);
 
                PDEBUG(D_PROBE,
-                       "Camera is now controlling video device /dev/video%d",
-                       gspca_dev->vdev.minor);
+                       "Camera is now controlling video device %s",
+                       video_device_node_name(&gspca_dev->vdev));
        }
 
        return ret;
@@ -673,7 +673,7 @@ void fetch_idxdata(struct gspca_dev *gspca_dev, struct idxdata *tbl, int len)
 }
 
 static int gl860_guess_sensor(struct gspca_dev *gspca_dev,
-                               s32 vendor_id, s32 product_id)
+                               u16 vendor_id, u16 product_id)
 {
        struct sd *sd = (struct sd *) gspca_dev;
        u8 probe, nb26, nb96, nOV, ntry;
index 4076f8e5a6fc44b5cd556b9cc519ae2dd07edde5..e930a67d526b2f2a04e94da7c46ac5c3624c78a2 100644 (file)
@@ -304,7 +304,6 @@ void gspca_frame_add(struct gspca_dev *gspca_dev,
                j = gspca_dev->fr_queue[i];
                gspca_dev->cur_frame = &gspca_dev->frame[j];
        }
-       return;
 }
 EXPORT_SYMBOL(gspca_frame_add);
 
@@ -321,7 +320,7 @@ static int gspca_is_compressed(__u32 format)
        return 0;
 }
 
-static void *rvmalloc(unsigned long size)
+static void *rvmalloc(long size)
 {
        void *mem;
        unsigned long adr;
@@ -329,7 +328,7 @@ static void *rvmalloc(unsigned long size)
        mem = vmalloc_32(size);
        if (mem != NULL) {
                adr = (unsigned long) mem;
-               while ((long) size > 0) {
+               while (size > 0) {
                        SetPageReserved(vmalloc_to_page((void *) adr));
                        adr += PAGE_SIZE;
                        size -= PAGE_SIZE;
@@ -768,6 +767,7 @@ static int vidioc_g_register(struct file *file, void *priv,
 
        if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                return -ERESTARTSYS;
+       gspca_dev->usb_err = 0;
        if (gspca_dev->present)
                ret = gspca_dev->sd_desc->get_register(gspca_dev, reg);
        else
@@ -791,6 +791,7 @@ static int vidioc_s_register(struct file *file, void *priv,
 
        if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                return -ERESTARTSYS;
+       gspca_dev->usb_err = 0;
        if (gspca_dev->present)
                ret = gspca_dev->sd_desc->set_register(gspca_dev, reg);
        else
@@ -812,6 +813,7 @@ static int vidioc_g_chip_ident(struct file *file, void *priv,
 
        if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                return -ERESTARTSYS;
+       gspca_dev->usb_err = 0;
        if (gspca_dev->present)
                ret = gspca_dev->sd_desc->get_chip_ident(gspca_dev, chip);
        else
@@ -983,11 +985,40 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
        return -EINVAL;
 }
 
+static int vidioc_enum_frameintervals(struct file *filp, void *priv,
+                                     struct v4l2_frmivalenum *fival)
+{
+       struct gspca_dev *gspca_dev = priv;
+       int mode = wxh_to_mode(gspca_dev, fival->width, fival->height);
+       __u32 i;
+
+       if (gspca_dev->cam.mode_framerates == NULL ||
+                       gspca_dev->cam.mode_framerates[mode].nrates == 0)
+               return -EINVAL;
+
+       if (fival->pixel_format !=
+                       gspca_dev->cam.cam_mode[mode].pixelformat)
+               return -EINVAL;
+
+       for (i = 0; i < gspca_dev->cam.mode_framerates[mode].nrates; i++) {
+               if (fival->index == i) {
+                       fival->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+                       fival->discrete.numerator = 1;
+                       fival->discrete.denominator =
+                               gspca_dev->cam.mode_framerates[mode].rates[i];
+                       return 0;
+               }
+       }
+
+       return -EINVAL;
+}
+
 static void gspca_release(struct video_device *vfd)
 {
        struct gspca_dev *gspca_dev = container_of(vfd, struct gspca_dev, vdev);
 
-       PDEBUG(D_PROBE, "/dev/video%d released", gspca_dev->vdev.num);
+       PDEBUG(D_PROBE, "%s released",
+               video_device_node_name(&gspca_dev->vdev));
 
        kfree(gspca_dev->usb_buf);
        kfree(gspca_dev);
@@ -1053,6 +1084,7 @@ static int dev_close(struct file *file)
        if (gspca_dev->capt_file == file) {
                if (gspca_dev->streaming) {
                        mutex_lock(&gspca_dev->usb_lock);
+                       gspca_dev->usb_err = 0;
                        gspca_stream_off(gspca_dev);
                        mutex_unlock(&gspca_dev->usb_lock);
                }
@@ -1143,12 +1175,14 @@ static int vidioc_queryctrl(struct file *file, void *priv,
                                continue;
                        ctrls = &gspca_dev->sd_desc->ctrls[i];
                }
+               if (ctrls == NULL)
+                       return -EINVAL;
        } else {
                ctrls = get_ctrl(gspca_dev, id);
+               if (ctrls == NULL)
+                       return -EINVAL;
                i = ctrls - gspca_dev->sd_desc->ctrls;
        }
-       if (ctrls == NULL)
-               return -EINVAL;
        memcpy(q_ctrl, ctrls, sizeof *q_ctrl);
        if (gspca_dev->ctrl_inac & (1 << i))
                q_ctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
@@ -1172,6 +1206,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
        PDEBUG(D_CONF, "set ctrl [%08x] = %d", ctrl->id, ctrl->value);
        if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                return -ERESTARTSYS;
+       gspca_dev->usb_err = 0;
        if (gspca_dev->present)
                ret = ctrls->set(gspca_dev, ctrl->value);
        else
@@ -1193,6 +1228,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
 
        if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                return -ERESTARTSYS;
+       gspca_dev->usb_err = 0;
        if (gspca_dev->present)
                ret = ctrls->get(gspca_dev, &ctrl->value);
        else
@@ -1307,6 +1343,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
        /* stop streaming */
        if (gspca_dev->streaming) {
                mutex_lock(&gspca_dev->usb_lock);
+               gspca_dev->usb_err = 0;
                gspca_stream_off(gspca_dev);
                mutex_unlock(&gspca_dev->usb_lock);
        }
@@ -1398,6 +1435,7 @@ static int vidioc_streamoff(struct file *file, void *priv,
                ret = -ERESTARTSYS;
                goto out;
        }
+       gspca_dev->usb_err = 0;
        gspca_stream_off(gspca_dev);
        mutex_unlock(&gspca_dev->usb_lock);
 
@@ -1423,6 +1461,7 @@ static int vidioc_g_jpegcomp(struct file *file, void *priv,
                return -EINVAL;
        if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                return -ERESTARTSYS;
+       gspca_dev->usb_err = 0;
        if (gspca_dev->present)
                ret = gspca_dev->sd_desc->get_jcomp(gspca_dev, jpegcomp);
        else
@@ -1441,6 +1480,7 @@ static int vidioc_s_jpegcomp(struct file *file, void *priv,
                return -EINVAL;
        if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                return -ERESTARTSYS;
+       gspca_dev->usb_err = 0;
        if (gspca_dev->present)
                ret = gspca_dev->sd_desc->set_jcomp(gspca_dev, jpegcomp);
        else
@@ -1461,6 +1501,7 @@ static int vidioc_g_parm(struct file *filp, void *priv,
 
                if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                        return -ERESTARTSYS;
+               gspca_dev->usb_err = 0;
                if (gspca_dev->present)
                        ret = gspca_dev->sd_desc->get_streamparm(gspca_dev,
                                                                 parm);
@@ -1490,6 +1531,7 @@ static int vidioc_s_parm(struct file *filp, void *priv,
 
                if (mutex_lock_interruptible(&gspca_dev->usb_lock))
                        return -ERESTARTSYS;
+               gspca_dev->usb_err = 0;
                if (gspca_dev->present)
                        ret = gspca_dev->sd_desc->set_streamparm(gspca_dev,
                                                                 parm);
@@ -1613,7 +1655,7 @@ static int dev_mmap(struct file *file, struct vm_area_struct *vma)
                size -= PAGE_SIZE;
        }
 
-       vma->vm_ops = (struct vm_operations_struct *) &gspca_vm_ops;
+       vma->vm_ops = &gspca_vm_ops;
        vma->vm_private_data = frame;
        gspca_vm_open(vma);
        ret = 0;
@@ -1661,6 +1703,7 @@ static int frame_wait(struct gspca_dev *gspca_dev,
 
        if (gspca_dev->sd_desc->dq_callback) {
                mutex_lock(&gspca_dev->usb_lock);
+               gspca_dev->usb_err = 0;
                if (gspca_dev->present)
                        gspca_dev->sd_desc->dq_callback(gspca_dev);
                mutex_unlock(&gspca_dev->usb_lock);
@@ -1973,6 +2016,7 @@ static const struct v4l2_ioctl_ops dev_ioctl_ops = {
        .vidioc_g_parm          = vidioc_g_parm,
        .vidioc_s_parm          = vidioc_s_parm,
        .vidioc_enum_framesizes = vidioc_enum_framesizes,
+       .vidioc_enum_frameintervals = vidioc_enum_frameintervals,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
        .vidioc_g_register      = vidioc_g_register,
        .vidioc_s_register      = vidioc_s_register,
@@ -1988,7 +2032,6 @@ static struct video_device gspca_template = {
        .fops = &dev_fops,
        .ioctl_ops = &dev_ioctl_ops,
        .release = gspca_release,
-       .minor = -1,
 };
 
 /*
@@ -2047,9 +2090,6 @@ int gspca_dev_probe(struct usb_interface *intf,
        if (ret < 0)
                goto out;
        ret = sd_desc->init(gspca_dev);
-       if (ret < 0)
-               goto out;
-       ret = gspca_set_alt0(gspca_dev);
        if (ret < 0)
                goto out;
        gspca_set_default_mode(gspca_dev);
@@ -2073,7 +2113,7 @@ int gspca_dev_probe(struct usb_interface *intf,
        }
 
        usb_set_intfdata(intf, gspca_dev);
-       PDEBUG(D_PROBE, "/dev/video%d created", gspca_dev->vdev.num);
+       PDEBUG(D_PROBE, "%s created", video_device_node_name(&gspca_dev->vdev));
        return 0;
 out:
        kfree(gspca_dev->usb_buf);
@@ -2092,7 +2132,8 @@ void gspca_disconnect(struct usb_interface *intf)
 {
        struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
 
-       PDEBUG(D_PROBE, "/dev/video%d disconnect", gspca_dev->vdev.num);
+       PDEBUG(D_PROBE, "%s disconnect",
+               video_device_node_name(&gspca_dev->vdev));
        mutex_lock(&gspca_dev->usb_lock);
        gspca_dev->present = 0;
 
index 181617355ec302c410a1de9fd04c92c3a055d1aa..59c7941da99977a0980b81419ad23185cb632c62 100644 (file)
@@ -45,11 +45,20 @@ extern int gspca_debug;
 /* image transfers */
 #define MAX_NURBS 4            /* max number of URBs */
 
+
+/* used to list framerates supported by a camera mode (resolution) */
+struct framerates {
+       int *rates;
+       int nrates;
+};
+
 /* device information - set at probe time */
 struct cam {
        int bulk_size;          /* buffer size when image transfer by bulk */
        const struct v4l2_pix_format *cam_mode; /* size nmodes */
        char nmodes;
+       const struct framerates *mode_framerates; /* must have size nmode,
+                                                  * just like cam_mode */
        __u8 bulk_nurbs;        /* number of URBs in bulk mode
                                 * - cannot be > MAX_NURBS
                                 * - when 0 and bulk_size != 0 means
@@ -171,6 +180,7 @@ struct gspca_dev {
        struct mutex usb_lock;          /* usb exchange protection */
        struct mutex read_lock;         /* read protection */
        struct mutex queue_lock;        /* ISOC queue protection */
+       int usb_err;                    /* USB error - protected by usb_lock */
 #ifdef CONFIG_PM
        char frozen;                    /* suspend - resume */
 #endif
index 844fc1d886d199cad16dd0115750c2062b1477f8..4294c75e3b11d3f23ae361290be87b7d674d9105 100644 (file)
@@ -81,7 +81,7 @@ int m5602_write_bridge(struct sd *sd, const u8 address, const u8 i2c_data)
        return (err < 0) ? err : 0;
 }
 
-int m5602_wait_for_i2c(struct sd *sd)
+static int m5602_wait_for_i2c(struct sd *sd)
 {
        int err;
        u8 data;
@@ -388,7 +388,7 @@ static int m5602_probe(struct usb_interface *intf,
                               THIS_MODULE);
 }
 
-void m5602_disconnect(struct usb_interface *intf)
+static void m5602_disconnect(struct usb_interface *intf)
 {
        struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
        struct sd *sd = (struct sd *) gspca_dev;
index c2739d6605a14612cd3db4a20124bd6d8be6b411..923cdd5f7a6b227d0cad2acbdc3b584acb53c328 100644 (file)
@@ -439,7 +439,7 @@ int ov9650_start(struct sd *sd)
                        err = m5602_write_bridge(sd, res_init_ov9650[i][1],
                                res_init_ov9650[i][2]);
                else if (res_init_ov9650[i][0] == SENSOR) {
-                       u8 data = res_init_ov9650[i][2];
+                       data = res_init_ov9650[i][2];
                        err = m5602_write_sensor(sd,
                                res_init_ov9650[i][1], &data, 1);
                }
index a27afeb6f39be4ffb85608f22c428018939932a5..aa2f3c7e2cb5467c3cb68879c4b4d7006427b804 100644 (file)
@@ -525,7 +525,10 @@ static int s5k4aa_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
        err = m5602_read_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
        if (err < 0)
                return err;
-       data = (data & 0xfe) | !val;
+       if (val)
+               data &= 0xfe;
+       else
+               data |= 0x01;
        err = m5602_write_sensor(sd, S5K4AA_ROWSTART_LO, &data, 1);
        return err;
 }
@@ -570,7 +573,10 @@ static int s5k4aa_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
        err = m5602_read_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
        if (err < 0)
                return err;
-       data = (data & 0xfe) | !val;
+       if (val)
+               data &= 0xfe;
+       else
+               data |= 0x01;
        err = m5602_write_sensor(sd, S5K4AA_COLSTART_LO, &data, 1);
        return err;
 }
index 126d968dd9e00c71d79767effda20a1b9e13ea54..9154870e07d29569b045c1813411fa6177ca8134 100644 (file)
@@ -67,7 +67,7 @@ MODULE_DESCRIPTION("GSPCA/Mars-Semi MR97310A USB Camera Driver");
 MODULE_LICENSE("GPL");
 
 /* global parameters */
-int force_sensor_type = -1;
+static int force_sensor_type = -1;
 module_param(force_sensor_type, int, 0644);
 MODULE_PARM_DESC(force_sensor_type, "Force sensor type (-1 (auto), 0 or 1)");
 
index ad9ec339981d5f787e77194c32e30b1ebd044cbc..b4f965731244ed65ba2a8038a18b0b870290debc 100644 (file)
@@ -1982,7 +1982,7 @@ static int ov518_reg_w32(struct sd *sd, __u16 index, u32 value, int n)
 {
        int ret;
 
-       *((u32 *)sd->gspca_dev.usb_buf) = __cpu_to_le32(value);
+       *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value);
 
        ret = usb_control_msg(sd->gspca_dev.dev,
                        usb_sndctrlpipe(sd->gspca_dev.dev, 0),
@@ -2021,9 +2021,9 @@ static int ov511_i2c_w(struct sd *sd, __u8 reg, __u8 value)
                if (rc < 0)
                        return rc;
 
-               do
+               do {
                        rc = reg_r(sd, R511_I2C_CTL);
-               while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */
+               while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */
 
                if (rc < 0)
                        return rc;
@@ -2055,9 +2055,9 @@ static int ov511_i2c_r(struct sd *sd, __u8 reg)
                if (rc < 0)
                        return rc;
 
-               do
+               do {
                        rc = reg_r(sd, R511_I2C_CTL);
-               while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */
+               while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */
 
                if (rc < 0)
                        return rc;
@@ -2081,9 +2081,9 @@ static int ov511_i2c_r(struct sd *sd, __u8 reg)
                if (rc < 0)
                        return rc;
 
-               do
+               do {
                        rc = reg_r(sd, R511_I2C_CTL);
-               while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */
+               while (rc > 0 && ((rc & 1) == 0)); /* Retry until idle */
 
                if (rc < 0)
                        return rc;
index 74acceea8094ea4cc06c3846997a48d09ffa3c73..de0b66c4b56e708f8e4059007b201466bd5fa529 100644 (file)
@@ -90,6 +90,9 @@ struct sd {
        unsigned char autogain;
        __u8 hflip;
        __u8 vflip;
+       u8 flags;
+#define FL_HFLIP 0x01          /* mirrored by default */
+#define FL_VFLIP 0x02          /* vertical flipped by default */
 
        u8 sof_read;
        u8 autogain_ignore_frames;
@@ -552,6 +555,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
        sd->autogain = AUTOGAIN_DEF;
        sd->hflip = HFLIP_DEF;
        sd->vflip = VFLIP_DEF;
+       sd->flags = id->driver_info;
        return 0;
 }
 
@@ -708,10 +712,17 @@ static int sethvflip(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
        int ret;
-       __u8 data;
+       u8 data, hflip, vflip;
+
+       hflip = sd->hflip;
+       if (sd->flags & FL_HFLIP)
+               hflip = !hflip;
+       vflip = sd->vflip;
+       if (sd->flags & FL_VFLIP)
+               vflip = !vflip;
 
        ret = reg_w(gspca_dev, 0xff, 0x03);             /* page 3 */
-       data = (sd->hflip ? 0x08 : 0x00) | (sd->vflip ? 0x04 : 0x00);
+       data = (hflip ? 0x08 : 0x00) | (vflip ? 0x04 : 0x00);
        if (0 <= ret)
                ret = reg_w(gspca_dev, 0x21, data);
        /* load registers to sensor (Bit 0, auto clear) */
@@ -1218,15 +1229,15 @@ static struct sd_desc sd_desc = {
 };
 
 /* -- module initialisation -- */
-static __devinitdata struct usb_device_id device_table[] = {
+static const struct usb_device_id device_table[] __devinitconst = {
        {USB_DEVICE(0x06f8, 0x3009)},
        {USB_DEVICE(0x093a, 0x2620)},
        {USB_DEVICE(0x093a, 0x2621)},
-       {USB_DEVICE(0x093a, 0x2622)},
-       {USB_DEVICE(0x093a, 0x2624)},
+       {USB_DEVICE(0x093a, 0x2622), .driver_info = FL_VFLIP},
+       {USB_DEVICE(0x093a, 0x2624), .driver_info = FL_VFLIP},
        {USB_DEVICE(0x093a, 0x2626)},
        {USB_DEVICE(0x093a, 0x2628)},
-       {USB_DEVICE(0x093a, 0x2629)},
+       {USB_DEVICE(0x093a, 0x2629), .driver_info = FL_VFLIP},
        {USB_DEVICE(0x093a, 0x262a)},
        {USB_DEVICE(0x093a, 0x262c)},
        {}
@@ -1234,7 +1245,7 @@ static __devinitdata struct usb_device_id device_table[] = {
 MODULE_DEVICE_TABLE(usb, device_table);
 
 /* -- device connect -- */
-static int sd_probe(struct usb_interface *intf,
+static int __devinit sd_probe(struct usb_interface *intf,
                        const struct usb_device_id *id)
 {
        return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
index e5697a6345e8f24b9f9a7738465b90fc903b84f9..42cfcdfd8f4f114649d1e15be5582b52a082a15d 100644 (file)
@@ -863,7 +863,7 @@ static struct sd_desc sd_desc = {
 };
 
 /* -- module initialisation -- */
-static __devinitdata struct usb_device_id device_table[] = {
+static const struct usb_device_id device_table[] __devinitconst = {
        {USB_DEVICE(0x093a, 0x2600)},
        {USB_DEVICE(0x093a, 0x2601)},
        {USB_DEVICE(0x093a, 0x2603)},
@@ -875,7 +875,7 @@ static __devinitdata struct usb_device_id device_table[] = {
 MODULE_DEVICE_TABLE(usb, device_table);
 
 /* -- device connect -- */
-static int sd_probe(struct usb_interface *intf,
+static int __devinit sd_probe(struct usb_interface *intf,
                        const struct usb_device_id *id)
 {
        return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
index b1944a7cbb0f31f3629628df27f2bf2bac6dc698..4cff8035614f881445a0770e92310cdaed21bc78 100644 (file)
@@ -1158,7 +1158,7 @@ static int i2c_w2(struct gspca_dev *gspca_dev, u8 reg, u16 val)
        return i2c_w(gspca_dev, row);
 }
 
-int i2c_r1(struct gspca_dev *gspca_dev, u8 reg, u8 *val)
+static int i2c_r1(struct gspca_dev *gspca_dev, u8 reg, u8 *val)
 {
        struct sd *sd = (struct sd *) gspca_dev;
        u8 row[8];
@@ -1183,7 +1183,7 @@ int i2c_r1(struct gspca_dev *gspca_dev, u8 reg, u8 *val)
        return 0;
 }
 
-int i2c_r2(struct gspca_dev *gspca_dev, u8 reg, u16 *val)
+static int i2c_r2(struct gspca_dev *gspca_dev, u8 reg, u16 *val)
 {
        struct sd *sd = (struct sd *) gspca_dev;
        u8 row[8];
@@ -1476,8 +1476,9 @@ static int sn9c20x_input_init(struct gspca_dev *gspca_dev)
        if (input_register_device(sd->input_dev))
                return -EINVAL;
 
-       sd->input_task = kthread_run(input_kthread, gspca_dev, "sn9c20x/%d",
-                                    gspca_dev->vdev.minor);
+       sd->input_task = kthread_run(input_kthread, gspca_dev, "sn9c20x/%s-%s",
+                                    gspca_dev->dev->bus->bus_name,
+                                    gspca_dev->dev->devpath);
 
        if (IS_ERR(sd->input_task))
                return -EINVAL;
@@ -2174,8 +2175,7 @@ static void configure_sensor_output(struct gspca_dev *gspca_dev, int mode)
 }
 
 #define HW_WIN(mode, hstart, vstart) \
-((const u8 []){hstart & 0xff, hstart >> 8, \
-vstart & 0xff, vstart >> 8, \
+((const u8 []){hstart, 0, vstart, 0, \
 (mode & MODE_SXGA ? 1280 >> 4 : 640 >> 4), \
 (mode & MODE_SXGA ? 1024 >> 3 : 480 >> 3)})
 
index 5be95bc65138b107481b0fc983a1e760cdc78237..ddff2b5ee5c2534462ce390ccbf18ad4ffe80c8e 100644 (file)
@@ -1226,7 +1226,7 @@ static const struct sd_desc sd_desc = {
        .driver_info = (SENSOR_ ## sensor << 8) | BRIDGE_ ## bridge
 
 
-static __devinitdata struct usb_device_id device_table[] = {
+static const struct usb_device_id device_table[] __devinitconst = {
        {USB_DEVICE(0x0c45, 0x6001), SB(TAS5110, 102)}, /* TAS5110C1B */
        {USB_DEVICE(0x0c45, 0x6005), SB(TAS5110, 101)}, /* TAS5110C1B */
 #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE
@@ -1257,7 +1257,7 @@ static __devinitdata struct usb_device_id device_table[] = {
 MODULE_DEVICE_TABLE(usb, device_table);
 
 /* -- device connect -- */
-static int sd_probe(struct usb_interface *intf,
+static int __devinit sd_probe(struct usb_interface *intf,
                        const struct usb_device_id *id)
 {
        return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
index ab28cc23e4158707a18636d55d89689468e7449e..39257e4e074ffa14131c0518cbef09736477e29d 100644 (file)
@@ -685,7 +685,7 @@ static struct sd_desc sd_desc = {
 };
 
 /* -- module initialisation -- */
-static __devinitdata struct usb_device_id device_table[] = {
+static const struct usb_device_id device_table[] __devinitconst = {
        {USB_DEVICE(0x06e1, 0xa190)},
 /*fixme: may be IntelPCCameraPro BRIDGE_SPCA505
        {USB_DEVICE(0x0733, 0x0430)}, */
@@ -696,7 +696,7 @@ static __devinitdata struct usb_device_id device_table[] = {
 MODULE_DEVICE_TABLE(usb, device_table);
 
 /* -- device connect -- */
-static int sd_probe(struct usb_interface *intf,
+static int __devinit sd_probe(struct usb_interface *intf,
                        const struct usb_device_id *id)
 {
        return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
index 8e23320d7ab7c35326f8c0879f720e8e9ed1d17b..2e2935532d99bb3b072caf954f757cdfe47c2e2e 100644 (file)
@@ -126,12 +126,14 @@ static const struct v4l2_pix_format vga_mode[] = {
 };
 
 /* -- read a register -- */
-static int reg_r(struct gspca_dev *gspca_dev,
+static u8 reg_r(struct gspca_dev *gspca_dev,
                        __u16 index)
 {
        struct usb_device *dev = gspca_dev->dev;
        int ret;
 
+       if (gspca_dev->usb_err < 0)
+               return 0;
        ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
                        0x00,
                        USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
@@ -141,18 +143,21 @@ static int reg_r(struct gspca_dev *gspca_dev,
                        500);
        if (ret < 0) {
                PDEBUG(D_ERR, "reg_r err %d", ret);
-               return ret;
+               gspca_dev->usb_err = ret;
+               return 0;
        }
        return gspca_dev->usb_buf[0];
 }
 
 /* -- write a register -- */
-static int reg_w(struct gspca_dev *gspca_dev,
+static void reg_w(struct gspca_dev *gspca_dev,
                        __u16 index, __u16 value)
 {
        struct usb_device *dev = gspca_dev->dev;
        int ret;
 
+       if (gspca_dev->usb_err < 0)
+               return;
        ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
                        0x01,
                        USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
@@ -161,13 +166,14 @@ static int reg_w(struct gspca_dev *gspca_dev,
                        NULL,
                        0,
                        500);
-       if (ret < 0)
+       if (ret < 0) {
                PDEBUG(D_ERR, "reg_w err %d", ret);
-       return ret;
+               gspca_dev->usb_err = ret;
+       }
 }
 
 /* -- get a bulk value (4 bytes) -- */
-static int rcv_val(struct gspca_dev *gspca_dev,
+static void rcv_val(struct gspca_dev *gspca_dev,
                        int ads)
 {
        struct usb_device *dev = gspca_dev->dev;
@@ -182,17 +188,22 @@ static int rcv_val(struct gspca_dev *gspca_dev,
        reg_w(gspca_dev, 0x63a, 0);
        reg_w(gspca_dev, 0x63b, 0);
        reg_w(gspca_dev, 0x630, 5);
+       if (gspca_dev->usb_err < 0)
+               return;
        ret = usb_bulk_msg(dev,
                        usb_rcvbulkpipe(dev, 0x05),
                        gspca_dev->usb_buf,
                        4,              /* length */
                        &alen,
                        500);           /* timeout in milliseconds */
-       return ret;
+       if (ret < 0) {
+               PDEBUG(D_ERR, "rcv_val err %d", ret);
+               gspca_dev->usb_err = ret;
+       }
 }
 
 /* -- send a bulk value -- */
-static int snd_val(struct gspca_dev *gspca_dev,
+static void snd_val(struct gspca_dev *gspca_dev,
                        int ads,
                        unsigned int val)
 {
@@ -201,16 +212,9 @@ static int snd_val(struct gspca_dev *gspca_dev,
        __u8 seq = 0;
 
        if (ads == 0x003f08) {
-               ret = reg_r(gspca_dev, 0x0704);
-               if (ret < 0)
-                       goto ko;
-               ret = reg_r(gspca_dev, 0x0705);
-               if (ret < 0)
-                       goto ko;
-               seq = ret;              /* keep the sequence number */
-               ret = reg_r(gspca_dev, 0x0650);
-               if (ret < 0)
-                       goto ko;
+               reg_r(gspca_dev, 0x0704);
+               seq = reg_r(gspca_dev, 0x0705);
+               reg_r(gspca_dev, 0x0650);
                reg_w(gspca_dev, 0x654, seq);
        } else {
                reg_w(gspca_dev, 0x654, (ads >> 16) & 0xff);
@@ -223,6 +227,8 @@ static int snd_val(struct gspca_dev *gspca_dev,
        reg_w(gspca_dev, 0x65a, 0);
        reg_w(gspca_dev, 0x65b, 0);
        reg_w(gspca_dev, 0x650, 5);
+       if (gspca_dev->usb_err < 0)
+               return;
        gspca_dev->usb_buf[0] = val >> 24;
        gspca_dev->usb_buf[1] = val >> 16;
        gspca_dev->usb_buf[2] = val >> 8;
@@ -233,24 +239,23 @@ static int snd_val(struct gspca_dev *gspca_dev,
                        4,
                        &alen,
                        500);   /* timeout in milliseconds */
-       if (ret < 0)
-               goto ko;
-       if (ads == 0x003f08) {
-               seq += 4;
-               seq &= 0x3f;
-               reg_w(gspca_dev, 0x705, seq);
+       if (ret < 0) {
+               PDEBUG(D_ERR, "snd_val err %d", ret);
+               gspca_dev->usb_err = ret;
+       } else {
+               if (ads == 0x003f08) {
+                       seq += 4;
+                       seq &= 0x3f;
+                       reg_w(gspca_dev, 0x705, seq);
+               }
        }
-       return ret;
-ko:
-       PDEBUG(D_ERR, "snd_val err %d", ret);
-       return ret;
 }
 
 /* set a camera parameter */
-static int set_par(struct gspca_dev *gspca_dev,
+static void set_par(struct gspca_dev *gspca_dev,
                   int parval)
 {
-       return snd_val(gspca_dev, 0x003f08, parval);
+       snd_val(gspca_dev, 0x003f08, parval);
 }
 
 static void setbrightness(struct gspca_dev *gspca_dev)
@@ -311,18 +316,18 @@ static int sd_config(struct gspca_dev *gspca_dev,
 /* this function is called at probe and resume time */
 static int sd_init(struct gspca_dev *gspca_dev)
 {
-       int ret;
+       u8 ret;
 
        /* check if the device responds */
        usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1);
        ret = reg_r(gspca_dev, 0x0740);
-       if (ret < 0)
-               return ret;
-       if (ret != 0xff) {
-               PDEBUG(D_ERR|D_STREAM, "init reg: 0x%02x", ret);
-               return -1;
+       if (gspca_dev->usb_err >= 0) {
+               if (ret != 0xff) {
+                       PDEBUG(D_ERR|D_STREAM, "init reg: 0x%02x", ret);
+                       gspca_dev->usb_err = -EIO;
+               }
        }
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 /* -- start the camera -- */
@@ -357,15 +362,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
        if (ret < 0) {
                PDEBUG(D_ERR|D_STREAM, "set intf %d %d failed",
                        gspca_dev->iface, gspca_dev->alt);
+               gspca_dev->usb_err = ret;
                goto out;
        }
-       ret = reg_r(gspca_dev, 0x0630);
-       if (ret < 0)
-               goto out;
+        reg_r(gspca_dev, 0x0630);
        rcv_val(gspca_dev, 0x000020);   /* << (value ff ff ff ff) */
-       ret = reg_r(gspca_dev, 0x0650);
-       if (ret < 0)
-               goto out;
+       reg_r(gspca_dev, 0x0650);
        snd_val(gspca_dev, 0x000020, 0xffffffff);
        reg_w(gspca_dev, 0x0620, 0);
        reg_w(gspca_dev, 0x0630, 0);
@@ -384,11 +386,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
        /* start the video flow */
        set_par(gspca_dev, 0x01000000);
        set_par(gspca_dev, 0x01000000);
-       PDEBUG(D_STREAM, "camera started alt: 0x%02x", gspca_dev->alt);
-       return 0;
+       if (gspca_dev->usb_err >= 0)
+               PDEBUG(D_STREAM, "camera started alt: 0x%02x",
+                               gspca_dev->alt);
 out:
-       PDEBUG(D_ERR|D_STREAM, "camera start err %d", ret);
-       return ret;
+       return gspca_dev->usb_err;
 }
 
 static void sd_stopN(struct gspca_dev *gspca_dev)
@@ -456,7 +458,7 @@ static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
        sd->brightness = val;
        if (gspca_dev->streaming)
                setbrightness(gspca_dev);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
@@ -474,7 +476,7 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
        sd->contrast = val;
        if (gspca_dev->streaming)
                setcontrast(gspca_dev);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
@@ -492,7 +494,7 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
        sd->colors = val;
        if (gspca_dev->streaming)
                setcolors(gspca_dev);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
@@ -510,7 +512,7 @@ static int sd_setfreq(struct gspca_dev *gspca_dev, __s32 val)
        sd->lightfreq = val;
        if (gspca_dev->streaming)
                setfreq(gspca_dev);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val)
@@ -552,7 +554,7 @@ static int sd_set_jcomp(struct gspca_dev *gspca_dev,
                sd->quality = jcomp->quality;
        if (gspca_dev->streaming)
                jpeg_set_qual(sd->jpeg_hdr, sd->quality);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_get_jcomp(struct gspca_dev *gspca_dev,
index 72bf3b4f0a316950637d7829beba23d9bad7cdcb..716df6b15fc5a199105c8afa3584cb1eed29cbc1 100644 (file)
@@ -460,13 +460,17 @@ static void reg_r(struct gspca_dev *gspca_dev,
                  u16 index,
                  u16 len)
 {
+       int ret;
+
 #ifdef GSPCA_DEBUG
        if (len > USB_BUF_SZ) {
                err("reg_r: buffer overflow");
                return;
        }
 #endif
-       usb_control_msg(gspca_dev->dev,
+       if (gspca_dev->usb_err < 0)
+               return;
+       ret = usb_control_msg(gspca_dev->dev,
                        usb_rcvctrlpipe(gspca_dev->dev, 0),
                        req,
                        USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
@@ -474,6 +478,10 @@ static void reg_r(struct gspca_dev *gspca_dev,
                        index,
                        len ? gspca_dev->usb_buf : NULL, len,
                        500);
+       if (ret < 0) {
+               PDEBUG(D_ERR, "reg_r err %d", ret);
+               gspca_dev->usb_err = ret;
+       }
 }
 
 /* write one byte */
@@ -483,40 +491,55 @@ static void reg_w_1(struct gspca_dev *gspca_dev,
                   u16 index,
                   u16 byte)
 {
+       int ret;
+
+       if (gspca_dev->usb_err < 0)
+               return;
        gspca_dev->usb_buf[0] = byte;
-       usb_control_msg(gspca_dev->dev,
+       ret = usb_control_msg(gspca_dev->dev,
                        usb_sndctrlpipe(gspca_dev->dev, 0),
                        req,
                        USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
                        value, index,
                        gspca_dev->usb_buf, 1,
                        500);
+       if (ret < 0) {
+               PDEBUG(D_ERR, "reg_w_1 err %d", ret);
+               gspca_dev->usb_err = ret;
+       }
 }
 
 /* write req / index / value */
-static int reg_w_riv(struct usb_device *dev,
+static void reg_w_riv(struct gspca_dev *gspca_dev,
                     u8 req, u16 index, u16 value)
 {
+       struct usb_device *dev = gspca_dev->dev;
        int ret;
 
+       if (gspca_dev->usb_err < 0)
+               return;
        ret = usb_control_msg(dev,
                        usb_sndctrlpipe(dev, 0),
                        req,
                        USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
                        value, index, NULL, 0, 500);
-       PDEBUG(D_USBO, "reg write: 0x%02x,0x%02x:0x%02x, %d",
-               req, index, value, ret);
-       if (ret < 0)
-               PDEBUG(D_ERR, "reg write: error %d", ret);
-       return ret;
+       if (ret < 0) {
+               PDEBUG(D_ERR, "reg_w_riv err %d", ret);
+               gspca_dev->usb_err = ret;
+               return;
+       }
+       PDEBUG(D_USBO, "reg_w_riv: 0x%02x,0x%04x:0x%04x",
+               req, index, value);
 }
 
 /* read 1 byte */
-static int reg_r_1(struct gspca_dev *gspca_dev,
+static u8 reg_r_1(struct gspca_dev *gspca_dev,
                        u16 value)      /* wValue */
 {
        int ret;
 
+       if (gspca_dev->usb_err < 0)
+               return 0;
        ret = usb_control_msg(gspca_dev->dev,
                        usb_rcvctrlpipe(gspca_dev->dev, 0),
                        0x20,                   /* request */
@@ -527,19 +550,22 @@ static int reg_r_1(struct gspca_dev *gspca_dev,
                        500);                   /* timeout */
        if (ret < 0) {
                PDEBUG(D_ERR, "reg_r_1 err %d", ret);
+               gspca_dev->usb_err = ret;
                return 0;
        }
        return gspca_dev->usb_buf[0];
 }
 
-/* read 1 or 2 bytes - returns < 0 if error */
-static int reg_r_12(struct gspca_dev *gspca_dev,
+/* read 1 or 2 bytes */
+static u16 reg_r_12(struct gspca_dev *gspca_dev,
                        u8 req,         /* bRequest */
                        u16 index,      /* wIndex */
                        u16 length)     /* wLength (1 or 2 only) */
 {
        int ret;
 
+       if (gspca_dev->usb_err < 0)
+               return 0;
        gspca_dev->usb_buf[1] = 0;
        ret = usb_control_msg(gspca_dev->dev,
                        usb_rcvctrlpipe(gspca_dev->dev, 0),
@@ -550,62 +576,44 @@ static int reg_r_12(struct gspca_dev *gspca_dev,
                        gspca_dev->usb_buf, length,
                        500);
        if (ret < 0) {
-               PDEBUG(D_ERR, "reg_read err %d", ret);
-               return -1;
+               PDEBUG(D_ERR, "reg_r_12 err %d", ret);
+               gspca_dev->usb_err = ret;
+               return 0;
        }
        return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0];
 }
 
-static int write_vector(struct gspca_dev *gspca_dev,
+static void write_vector(struct gspca_dev *gspca_dev,
                        const struct cmd *data, int ncmds)
 {
-       struct usb_device *dev = gspca_dev->dev;
-       int ret;
-
        while (--ncmds >= 0) {
-               ret = reg_w_riv(dev, data->req, data->idx, data->val);
-               if (ret < 0) {
-                       PDEBUG(D_ERR,
-                          "Register write failed for 0x%02x, 0x%04x, 0x%04x",
-                               data->req, data->val, data->idx);
-                       return ret;
-               }
+               reg_w_riv(gspca_dev, data->req, data->idx, data->val);
                data++;
        }
-       return 0;
 }
 
-static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
-                               const u8 qtable[2][64])
+static void setup_qtable(struct gspca_dev *gspca_dev,
+                       const u8 qtable[2][64])
 {
-       struct usb_device *dev = gspca_dev->dev;
-       int i, err;
+       int i;
 
        /* loop over y components */
-       for (i = 0; i < 64; i++) {
-               err = reg_w_riv(dev, 0x00, 0x2800 + i, qtable[0][i]);
-               if (err < 0)
-                       return err;
-       }
+       for (i = 0; i < 64; i++)
+                reg_w_riv(gspca_dev, 0x00, 0x2800 + i, qtable[0][i]);
 
        /* loop over c components */
-       for (i = 0; i < 64; i++) {
-               err = reg_w_riv(dev, 0x00, 0x2840 + i, qtable[1][i]);
-               if (err < 0)
-                       return err;
-       }
-       return 0;
+       for (i = 0; i < 64; i++)
+               reg_w_riv(gspca_dev, 0x00, 0x2840 + i, qtable[1][i]);
 }
 
 static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
                             u8 req, u16 idx, u16 val)
 {
-       struct usb_device *dev = gspca_dev->dev;
-       int notdone;
+       u16 notdone;
 
-       reg_w_riv(dev, req, idx, val);
+       reg_w_riv(gspca_dev, req, idx, val);
        notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
-       reg_w_riv(dev, req, idx, val);
+       reg_w_riv(gspca_dev, req, idx, val);
 
        PDEBUG(D_FRAM, "before wait 0x%04x", notdone);
 
@@ -616,23 +624,22 @@ static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
 
 static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
                        u8 req,
-                       u16 idx, u16 val, u8 stat, u8 count)
+                       u16 idx, u16 val, u16 endcode, u8 count)
 {
-       struct usb_device *dev = gspca_dev->dev;
-       int status;
-       u8 endcode;
+       u16 status;
 
-       reg_w_riv(dev, req, idx, val);
+       reg_w_riv(gspca_dev, req, idx, val);
        status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
-       endcode = stat;
-       PDEBUG(D_FRAM, "Status 0x%x Need 0x%04x", status, stat);
+       if (gspca_dev->usb_err < 0)
+               return;
+       PDEBUG(D_FRAM, "Status 0x%04x Need 0x%04x", status, endcode);
        if (!count)
                return;
        count = 200;
        while (--count > 0) {
                msleep(10);
                /* gsmart mini2 write a each wait setting 1 ms is enough */
-/*             reg_w_riv(dev, req, idx, val); */
+/*             reg_w_riv(gspca_dev, req, idx, val); */
                status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
                if (status == endcode) {
                        PDEBUG(D_FRAM, "status 0x%04x after wait %d",
@@ -642,7 +649,7 @@ static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
        }
 }
 
-static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
+static void spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
 {
        int count = 10;
 
@@ -652,7 +659,6 @@ static int spca504B_PollingDataReady(struct gspca_dev *gspca_dev)
                        break;
                msleep(10);
        }
-       return gspca_dev->usb_buf[0];
 }
 
 static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
@@ -686,28 +692,26 @@ static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
 static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       struct usb_device *dev = gspca_dev->dev;
        u8 Size;
-       int rc;
 
        Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
        switch (sd->bridge) {
        case BRIDGE_SPCA533:
-               reg_w_riv(dev, 0x31, 0, 0);
+               reg_w_riv(gspca_dev, 0x31, 0, 0);
                spca504B_WaitCmdStatus(gspca_dev);
-               rc = spca504B_PollingDataReady(gspca_dev);
+               spca504B_PollingDataReady(gspca_dev);
                spca50x_GetFirmware(gspca_dev);
                reg_w_1(gspca_dev, 0x24, 0, 8, 2);              /* type */
                reg_r(gspca_dev, 0x24, 8, 1);
 
                reg_w_1(gspca_dev, 0x25, 0, 4, Size);
                reg_r(gspca_dev, 0x25, 4, 1);                   /* size */
-               rc = spca504B_PollingDataReady(gspca_dev);
+               spca504B_PollingDataReady(gspca_dev);
 
                /* Init the cam width height with some values get on init ? */
-               reg_w_riv(dev, 0x31, 0, 0x04);
+               reg_w_riv(gspca_dev, 0x31, 0, 0x04);
                spca504B_WaitCmdStatus(gspca_dev);
-               rc = spca504B_PollingDataReady(gspca_dev);
+               spca504B_PollingDataReady(gspca_dev);
                break;
        default:
 /* case BRIDGE_SPCA504B: */
@@ -716,7 +720,7 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
                reg_r(gspca_dev, 0x25, 4, 1);                   /* size */
                reg_w_1(gspca_dev, 0x27, 0, 0, 6);
                reg_r(gspca_dev, 0x27, 0, 1);                   /* type */
-               rc = spca504B_PollingDataReady(gspca_dev);
+               spca504B_PollingDataReady(gspca_dev);
                break;
        case BRIDGE_SPCA504:
                Size += 3;
@@ -733,8 +737,8 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
                break;
        case BRIDGE_SPCA504C:
                /* capture mode */
-               reg_w_riv(dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00);
-               reg_w_riv(dev, 0x20, 0x01, 0x0500 | (Size & 0x0f));
+               reg_w_riv(gspca_dev, 0xa0, (0x0500 | (Size & 0x0f)), 0x00);
+               reg_w_riv(gspca_dev, 0x20, 0x01, 0x0500 | (Size & 0x0f));
                break;
        }
 }
@@ -762,37 +766,33 @@ static void spca504B_setQtable(struct gspca_dev *gspca_dev)
 static void setbrightness(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       struct usb_device *dev = gspca_dev->dev;
        u16 reg;
 
        reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f0 : 0x21a7;
-       reg_w_riv(dev, 0x00, reg, sd->brightness);
+       reg_w_riv(gspca_dev, 0x00, reg, sd->brightness);
 }
 
 static void setcontrast(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       struct usb_device *dev = gspca_dev->dev;
        u16 reg;
 
        reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f1 : 0x21a8;
-       reg_w_riv(dev, 0x00, reg, sd->contrast);
+       reg_w_riv(gspca_dev, 0x00, reg, sd->contrast);
 }
 
 static void setcolors(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       struct usb_device *dev = gspca_dev->dev;
        u16 reg;
 
        reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f6 : 0x21ae;
-       reg_w_riv(dev, 0x00, reg, sd->colors);
+       reg_w_riv(gspca_dev, 0x00, reg, sd->colors);
 }
 
 static void init_ctl_reg(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       struct usb_device *dev = gspca_dev->dev;
        int pollreg = 1;
 
        setbrightness(gspca_dev);
@@ -807,14 +807,14 @@ static void init_ctl_reg(struct gspca_dev *gspca_dev)
        default:
 /*     case BRIDGE_SPCA533: */
 /*     case BRIDGE_SPCA504B: */
-               reg_w_riv(dev, 0, 0x00, 0x21ad);        /* hue */
-               reg_w_riv(dev, 0, 0x01, 0x21ac);        /* sat/hue */
-               reg_w_riv(dev, 0, 0x00, 0x21a3);        /* gamma */
+               reg_w_riv(gspca_dev, 0, 0x00, 0x21ad);  /* hue */
+               reg_w_riv(gspca_dev, 0, 0x01, 0x21ac);  /* sat/hue */
+               reg_w_riv(gspca_dev, 0, 0x00, 0x21a3);  /* gamma */
                break;
        case BRIDGE_SPCA536:
-               reg_w_riv(dev, 0, 0x40, 0x20f5);
-               reg_w_riv(dev, 0, 0x01, 0x20f4);
-               reg_w_riv(dev, 0, 0x00, 0x2089);
+               reg_w_riv(gspca_dev, 0, 0x40, 0x20f5);
+               reg_w_riv(gspca_dev, 0, 0x01, 0x20f4);
+               reg_w_riv(gspca_dev, 0, 0x00, 0x2089);
                break;
        }
        if (pollreg)
@@ -881,18 +881,17 @@ static int sd_config(struct gspca_dev *gspca_dev,
 static int sd_init(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       struct usb_device *dev = gspca_dev->dev;
-       int i, err_code;
+       int i;
        u8 info[6];
 
        switch (sd->bridge) {
        case BRIDGE_SPCA504B:
-               reg_w_riv(dev, 0x1d, 0x00, 0);
-               reg_w_riv(dev, 0, 0x01, 0x2306);
-               reg_w_riv(dev, 0, 0x00, 0x0d04);
-               reg_w_riv(dev, 0, 0x00, 0x2000);
-               reg_w_riv(dev, 0, 0x13, 0x2301);
-               reg_w_riv(dev, 0, 0x00, 0x2306);
+               reg_w_riv(gspca_dev, 0x1d, 0x00, 0);
+               reg_w_riv(gspca_dev, 0, 0x01, 0x2306);
+               reg_w_riv(gspca_dev, 0, 0x00, 0x0d04);
+               reg_w_riv(gspca_dev, 0, 0x00, 0x2000);
+               reg_w_riv(gspca_dev, 0, 0x13, 0x2301);
+               reg_w_riv(gspca_dev, 0, 0x00, 0x2306);
                /* fall thru */
        case BRIDGE_SPCA533:
                spca504B_PollingDataReady(gspca_dev);
@@ -904,13 +903,13 @@ static int sd_init(struct gspca_dev *gspca_dev)
                reg_w_1(gspca_dev, 0x24, 0, 0, 0);
                reg_r(gspca_dev, 0x24, 0, 1);
                spca504B_PollingDataReady(gspca_dev);
-               reg_w_riv(dev, 0x34, 0, 0);
+               reg_w_riv(gspca_dev, 0x34, 0, 0);
                spca504B_WaitCmdStatus(gspca_dev);
                break;
        case BRIDGE_SPCA504C:   /* pccam600 */
                PDEBUG(D_STREAM, "Opening SPCA504 (PC-CAM 600)");
-               reg_w_riv(dev, 0xe0, 0x0000, 0x0000);
-               reg_w_riv(dev, 0xe0, 0x0000, 0x0001);   /* reset */
+               reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0000);
+               reg_w_riv(gspca_dev, 0xe0, 0x0000, 0x0001);     /* reset */
                spca504_wait_status(gspca_dev);
                if (sd->subtype == LogitechClickSmart420)
                        write_vector(gspca_dev,
@@ -919,12 +918,7 @@ static int sd_init(struct gspca_dev *gspca_dev)
                else
                        write_vector(gspca_dev, spca504_pccam600_open_data,
                                ARRAY_SIZE(spca504_pccam600_open_data));
-               err_code = spca50x_setup_qtable(gspca_dev,
-                                               qtable_creative_pccam);
-               if (err_code < 0) {
-                       PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed");
-                       return err_code;
-               }
+               setup_qtable(gspca_dev, qtable_creative_pccam);
                break;
        default:
 /*     case BRIDGE_SPCA504: */
@@ -958,29 +952,24 @@ static int sd_init(struct gspca_dev *gspca_dev)
                                                        6, 0, 0x86, 1); */
 /*                     spca504A_acknowledged_command (gspca_dev, 0x24,
                                                        0, 0, 0x9D, 1); */
-                       reg_w_riv(dev, 0x00, 0x270c, 0x05); /* L92 sno1t.txt */
-                       reg_w_riv(dev, 0x00, 0x2310, 0x05);
+                       reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
+                                                       /* L92 sno1t.txt */
+                       reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
                        spca504A_acknowledged_command(gspca_dev, 0x01,
                                                        0x0f, 0, 0xff, 0);
                }
                /* setup qtable */
-               reg_w_riv(dev, 0, 0x2000, 0);
-               reg_w_riv(dev, 0, 0x2883, 1);
-               err_code = spca50x_setup_qtable(gspca_dev,
-                                               qtable_spca504_default);
-               if (err_code < 0) {
-                       PDEBUG(D_ERR, "spca50x_setup_qtable failed");
-                       return err_code;
-               }
+               reg_w_riv(gspca_dev, 0, 0x2000, 0);
+               reg_w_riv(gspca_dev, 0, 0x2883, 1);
+               setup_qtable(gspca_dev, qtable_spca504_default);
                break;
        }
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_start(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       struct usb_device *dev = gspca_dev->dev;
        int enable;
        int i;
        u8 info[6];
@@ -1005,13 +994,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
                case MegapixV4:
                case LogitechClickSmart820:
                case MegaImageVI:
-                       reg_w_riv(dev, 0xf0, 0, 0);
+                       reg_w_riv(gspca_dev, 0xf0, 0, 0);
                        spca504B_WaitCmdStatus(gspca_dev);
                        reg_r(gspca_dev, 0xf0, 4, 0);
                        spca504B_WaitCmdStatus(gspca_dev);
                        break;
                default:
-                       reg_w_riv(dev, 0x31, 0, 0x04);
+                       reg_w_riv(gspca_dev, 0x31, 0, 0x04);
                        spca504B_WaitCmdStatus(gspca_dev);
                        spca504B_PollingDataReady(gspca_dev);
                        break;
@@ -1048,8 +1037,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
                        spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
                }
                spca504B_SetSizeType(gspca_dev);
-               reg_w_riv(dev, 0x00, 0x270c, 0x05);     /* L92 sno1t.txt */
-               reg_w_riv(dev, 0x00, 0x2310, 0x05);
+               reg_w_riv(gspca_dev, 0x00, 0x270c, 0x05);
+                                                       /* L92 sno1t.txt */
+               reg_w_riv(gspca_dev, 0x00, 0x2310, 0x05);
                break;
        case BRIDGE_SPCA504C:
                if (sd->subtype == LogitechClickSmart420) {
@@ -1061,36 +1051,37 @@ static int sd_start(struct gspca_dev *gspca_dev)
                                ARRAY_SIZE(spca504_pccam600_init_data));
                }
                enable = (sd->autogain ? 0x04 : 0x01);
-               reg_w_riv(dev, 0x0c, 0x0000, enable);   /* auto exposure */
-               reg_w_riv(dev, 0xb0, 0x0000, enable);   /* auto whiteness */
+               reg_w_riv(gspca_dev, 0x0c, 0x0000, enable);
+                                                       /* auto exposure */
+               reg_w_riv(gspca_dev, 0xb0, 0x0000, enable);
+                                                       /* auto whiteness */
 
                /* set default exposure compensation and whiteness balance */
-               reg_w_riv(dev, 0x30, 0x0001, 800);      /* ~ 20 fps */
-               reg_w_riv(dev, 0x30, 0x0002, 1600);
+               reg_w_riv(gspca_dev, 0x30, 0x0001, 800);        /* ~ 20 fps */
+               reg_w_riv(gspca_dev, 0x30, 0x0002, 1600);
                spca504B_SetSizeType(gspca_dev);
                break;
        }
        init_ctl_reg(gspca_dev);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static void sd_stopN(struct gspca_dev *gspca_dev)
 {
        struct sd *sd = (struct sd *) gspca_dev;
-       struct usb_device *dev = gspca_dev->dev;
 
        switch (sd->bridge) {
        default:
 /*     case BRIDGE_SPCA533: */
 /*     case BRIDGE_SPCA536: */
 /*     case BRIDGE_SPCA504B: */
-               reg_w_riv(dev, 0x31, 0, 0);
+               reg_w_riv(gspca_dev, 0x31, 0, 0);
                spca504B_WaitCmdStatus(gspca_dev);
                spca504B_PollingDataReady(gspca_dev);
                break;
        case BRIDGE_SPCA504:
        case BRIDGE_SPCA504C:
-               reg_w_riv(dev, 0x00, 0x2000, 0x0000);
+               reg_w_riv(gspca_dev, 0x00, 0x2000, 0x0000);
 
                if (sd->subtype == AiptekMiniPenCam13) {
                        /* spca504a aiptek */
@@ -1102,7 +1093,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
                                                        0x0f, 0x00, 0xff, 1);
                } else {
                        spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
-                       reg_w_riv(dev, 0x01, 0x000f, 0x0000);
+                       reg_w_riv(gspca_dev, 0x01, 0x000f, 0x0000);
                }
                break;
        }
@@ -1216,7 +1207,7 @@ static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
        sd->brightness = val;
        if (gspca_dev->streaming)
                setbrightness(gspca_dev);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
@@ -1234,7 +1225,7 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
        sd->contrast = val;
        if (gspca_dev->streaming)
                setcontrast(gspca_dev);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val)
@@ -1252,7 +1243,7 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
        sd->colors = val;
        if (gspca_dev->streaming)
                setcolors(gspca_dev);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
@@ -1292,7 +1283,7 @@ static int sd_set_jcomp(struct gspca_dev *gspca_dev,
                sd->quality = jcomp->quality;
        if (gspca_dev->streaming)
                jpeg_set_qual(sd->jpeg_hdr, sd->quality);
-       return 0;
+       return gspca_dev->usb_err;
 }
 
 static int sd_get_jcomp(struct gspca_dev *gspca_dev,
index 69e5dc4fc9defb9f2eafc379fec3f15d1f5da2a8..1a800fc1c00e6e77bfe515e9dba3b20e919d7581 100644 (file)
@@ -5345,9 +5345,6 @@ static const struct usb_action tas5130cxx_InitialScale[] = {      /* 320x240 */
        {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC},
        {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING},
        {0xa0, 0x05, ZC3XX_R012_VIDEOCONTROLFUNC},
-       {0xa0, 0x07, ZC3XX_R0A5_EXPOSUREGAIN},
-       {0xa0, 0x02, ZC3XX_R0A6_EXPOSUREBLACKLVL},
-
        {0xa0, 0x02, ZC3XX_R003_FRAMEWIDTHHIGH},
        {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW},
        {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH},
@@ -5364,27 +5361,27 @@ static const struct usb_action tas5130cxx_InitialScale[] = {    /* 320x240 */
        {0xa0, 0xf7, ZC3XX_R101_SENSORCORRECTION},
        {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
        {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
-       {0xa0, 0x95, ZC3XX_R18D_YTARGET},
+       {0xa0, 0x70, ZC3XX_R18D_YTARGET},
        {0xa0, 0x50, ZC3XX_R1A8_DIGITALGAIN},
        {0xa0, 0x00, 0x01ad},
        {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE},
        {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05},
        {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
        {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
+       {0xa0, 0x07, ZC3XX_R0A5_EXPOSUREGAIN},
+       {0xa0, 0x02, ZC3XX_R0A6_EXPOSUREBLACKLVL},
        {}
 };
 static const struct usb_action tas5130cxx_Initial[] = {        /* 640x480 */
        {0xa0, 0x01, ZC3XX_R000_SYSTEMCONTROL},
        {0xa0, 0x40, ZC3XX_R002_CLOCKSELECT},
-       {0xa0, 0x03, ZC3XX_R008_CLOCKSETTING},
+       {0xa0, 0x00, ZC3XX_R008_CLOCKSETTING},
        {0xa0, 0x02, ZC3XX_R010_CMOSSENSORSELECT},
        {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING},
        {0xa0, 0x00, ZC3XX_R001_SYSTEMOPERATING},
        {0xa0, 0x01, ZC3XX_R012_VIDEOCONTROLFUNC},
        {0xa0, 0x01, ZC3XX_R001_SYSTEMOPERATING},
        {0xa0, 0x05, ZC3XX_R012_VIDEOCONTROLFUNC},
-       {0xa0, 0x07, ZC3XX_R0A5_EXPOSUREGAIN},
-       {0xa0, 0x02, ZC3XX_R0A6_EXPOSUREBLACKLVL},
        {0xa0, 0x02, ZC3XX_R003_FRAMEWIDTHHIGH},
        {0xa0, 0x80, ZC3XX_R004_FRAMEWIDTHLOW},
        {0xa0, 0x01, ZC3XX_R005_FRAMEHEIGHTHIGH},
@@ -5400,13 +5397,15 @@ static const struct usb_action tas5130cxx_Initial[] = { /* 640x480 */
        {0xa0, 0x37, ZC3XX_R101_SENSORCORRECTION},
        {0xa0, 0x0d, ZC3XX_R100_OPERATIONMODE},
        {0xa0, 0x06, ZC3XX_R189_AWBSTATUS},
-       {0xa0, 0x95, ZC3XX_R18D_YTARGET},
+       {0xa0, 0x70, ZC3XX_R18D_YTARGET},
        {0xa0, 0x50, ZC3XX_R1A8_DIGITALGAIN},
        {0xa0, 0x00, 0x01ad},
        {0xa0, 0x03, ZC3XX_R1C5_SHARPNESSMODE},
        {0xa0, 0x13, ZC3XX_R1CB_SHARPNESS05},
        {0xa0, 0x08, ZC3XX_R250_DEADPIXELSMODE},
        {0xa0, 0x08, ZC3XX_R301_EEPROMACCESS},
+       {0xa0, 0x07, ZC3XX_R0A5_EXPOSUREGAIN},
+       {0xa0, 0x02, ZC3XX_R0A6_EXPOSUREBLACKLVL},
        {}
 };
 static const struct usb_action tas5130cxx_50HZ[] = {
@@ -6424,11 +6423,11 @@ static int vga_2wr_probe(struct gspca_dev *gspca_dev)
        if (retword != 0)
                return 0x0e;                    /* PAS202BCB */
 
-       start_2wr_probe(dev, 0x02);             /* ?? */
+       start_2wr_probe(dev, 0x02);             /* TAS5130C */
        i2c_write(gspca_dev, 0x01, 0xaa, 0x00);
        retword = i2c_read(gspca_dev, 0x01);
        if (retword != 0)
-               return 0x02;                    /* ?? */
+               return 0x02;                    /* TAS5130C */
 ov_check:
        reg_r(gspca_dev, 0x0010);               /* ?? */
        reg_r(gspca_dev, 0x0010);
@@ -6505,6 +6504,8 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
        reg_r(gspca_dev, 0x0010);
        /* value 0x4001 is meaningless */
        if (retword != 0x4001) {
+               if ((retword & 0xff00) == 0x6400)
+                       return 0x02;            /* TAS5130C */
                for (i = 0; i < ARRAY_SIZE(chipset_revision_sensor); i++) {
                        if (chipset_revision_sensor[i].revision == retword) {
                                sd->chip_revision = retword;
@@ -6515,7 +6516,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
                }
        }
 
-       reg_w(dev, 0x01, 0x0000);       /* check ?? */
+       reg_w(dev, 0x01, 0x0000);       /* check PB0330 */
        reg_w(dev, 0x01, 0x0001);
        reg_w(dev, 0xdd, 0x008b);
        reg_w(dev, 0x0a, 0x0010);
@@ -6524,7 +6525,7 @@ static int vga_3wr_probe(struct gspca_dev *gspca_dev)
        retword = i2c_read(gspca_dev, 0x00);
        if (retword != 0) {
                PDEBUG(D_PROBE, "probe 3wr vga type 0a ?");
-               return 0x0a;                    /* ?? */
+               return 0x0a;                    /* PB0330 */
        }
 
        reg_w(dev, 0x01, 0x0000);
@@ -6673,6 +6674,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
                        PDEBUG(D_PROBE, "Find Sensor HV7131B");
                        sd->sensor = SENSOR_HV7131B;
                        break;
+               case 0x02:
+                       PDEBUG(D_PROBE, "Sensor TAS5130C");
+                       sd->sensor = SENSOR_TAS5130CXX;
+                       break;
                case 0x04:
                        PDEBUG(D_PROBE, "Find Sensor CS2102");
                        sd->sensor = SENSOR_CS2102;
@@ -6866,11 +6871,14 @@ static int sd_start(struct gspca_dev *gspca_dev)
        case SENSOR_GC0305:
        case SENSOR_OV7620:
        case SENSOR_PO2030:
+       case SENSOR_TAS5130CXX:
        case SENSOR_TAS5130C_VF0250:
 /*             msleep(100);                     * ?? */
                reg_r(gspca_dev, 0x0002);       /* --> 0x40 */
                reg_w(dev, 0x09, 0x01ad);       /* (from win traces) */
                reg_w(dev, 0x15, 0x01ae);
+               if (sd->sensor == SENSOR_TAS5130CXX)
+                       break;
                reg_w(dev, 0x0d, 0x003a);
                reg_w(dev, 0x02, 0x003b);
                reg_w(dev, 0x00, 0x0038);
@@ -6887,6 +6895,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
                break;
        case SENSOR_PAS202B:
        case SENSOR_GC0305:
+       case SENSOR_TAS5130CXX:
                reg_r(gspca_dev, 0x0008);
                /* fall thru */
        case SENSOR_PO2030:
@@ -6928,6 +6937,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
                reg_w(dev, 0x40, 0x0117);
                break;
        case SENSOR_GC0305:
+       case SENSOR_TAS5130CXX:
                reg_w(dev, 0x09, 0x01ad);       /* (from win traces) */
                reg_w(dev, 0x15, 0x01ae);
                /* fall thru */
@@ -7220,7 +7230,7 @@ static const __devinitdata struct usb_device_id device_table[] = {
        {USB_DEVICE(0x0ac8, 0x0302), .driver_info = SENSOR_PAS106},
        {USB_DEVICE(0x0ac8, 0x301b)},
        {USB_DEVICE(0x0ac8, 0x303b)},
-       {USB_DEVICE(0x0ac8, 0x305b), .driver_info = SENSOR_TAS5130C_VF0250},
+       {USB_DEVICE(0x0ac8, 0x305b)},
        {USB_DEVICE(0x0ac8, 0x307b)},
        {USB_DEVICE(0x10fd, 0x0128)},
        {USB_DEVICE(0x10fd, 0x804d)},
index 1c9bc94c905c0afb29f460c7b044fde1175cc8c6..51f393d03a46eef58873b7278fe8241ebd45b49d 100644 (file)
@@ -145,7 +145,7 @@ static int device_authorization(struct hdpvr_device *dev)
 #ifdef HDPVR_DEBUG
        else {
                hex_dump_to_buffer(dev->usbc_buf, 46, 16, 1, print_buf,
-                                  sizeof(print_buf), 0);
+                                  5*buf_size+1, 0);
                v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
                         "Status request returned, len %d: %s\n",
                         ret, print_buf);
@@ -168,13 +168,13 @@ static int device_authorization(struct hdpvr_device *dev)
 
        response = dev->usbc_buf+38;
 #ifdef HDPVR_DEBUG
-       hex_dump_to_buffer(response, 8, 16, 1, print_buf, sizeof(print_buf), 0);
+       hex_dump_to_buffer(response, 8, 16, 1, print_buf, 5*buf_size+1, 0);
        v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, "challenge: %s\n",
                 print_buf);
 #endif
        challenge(response);
 #ifdef HDPVR_DEBUG
-       hex_dump_to_buffer(response, 8, 16, 1, print_buf, sizeof(print_buf), 0);
+       hex_dump_to_buffer(response, 8, 16, 1, print_buf, 5*buf_size+1, 0);
        v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, " response: %s\n",
                 print_buf);
 #endif
@@ -376,8 +376,8 @@ static int hdpvr_probe(struct usb_interface *interface,
        usb_set_intfdata(interface, dev);
 
        /* let the user know what node this device is now attached to */
-       v4l2_info(&dev->v4l2_dev, "device now attached to /dev/video%d\n",
-                 dev->video_dev->minor);
+       v4l2_info(&dev->v4l2_dev, "device now attached to %s\n",
+                 video_device_node_name(dev->video_dev));
        return 0;
 
 error:
@@ -391,13 +391,10 @@ error:
 static void hdpvr_disconnect(struct usb_interface *interface)
 {
        struct hdpvr_device *dev;
-       int minor;
 
        dev = usb_get_intfdata(interface);
        usb_set_intfdata(interface, NULL);
 
-       minor = dev->video_dev->minor;
-
        /* prevent more I/O from starting and stop any ongoing */
        mutex_lock(&dev->io_mutex);
        dev->status = STATUS_DISCONNECTED;
@@ -425,7 +422,8 @@ static void hdpvr_disconnect(struct usb_interface *interface)
 
        atomic_dec(&dev_nr);
 
-       v4l2_info(&dev->v4l2_dev, "device /dev/video%d disconnected\n", minor);
+       v4l2_info(&dev->v4l2_dev, "device %s disconnected\n",
+                 video_device_node_name(dev->video_dev));
 
        v4l2_device_unregister(&dev->v4l2_dev);
        kfree(dev->usbc_buf);
index b5439cabb381e9bac7ca61ce5e18782be45f6ee8..fdd782039e9de4d266ac6abeade64045858256d4 100644 (file)
@@ -523,7 +523,7 @@ static unsigned int hdpvr_poll(struct file *filp, poll_table *wait)
 
        mutex_lock(&dev->io_mutex);
 
-       if (video_is_unregistered(dev->video_dev)) {
+       if (!video_is_registered(dev->video_dev)) {
                mutex_unlock(&dev->io_mutex);
                return -EIO;
        }
index 64360d26b32d0bf3b13c4a69f96af98c701430ae..b86e35386ceea525a9217a13539fca5045bd185e 100644 (file)
@@ -353,6 +353,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
                ir_type     = IR_TYPE_RC5;
                ir_codes    = &ir_codes_fusionhdtv_mce_table;
                break;
+       case 0x0b:
        case 0x47:
        case 0x71:
                if (adap->id == I2C_HW_B_CX2388x ||
@@ -422,7 +423,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
 
        /* Make sure we are all setup before going on */
        if (!name || !ir->get_key || !ir_type || !ir_codes) {
-               dprintk(1, DEVNAME ": Unsupported device at address 0x%02x\n",
+               dprintk(1, ": Unsupported device at address 0x%02x\n",
                        addr);
                err = -ENODEV;
                goto err_out_free;
@@ -437,7 +438,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
                 dev_name(&client->dev));
 
        /* init + register input device */
-       err = ir_input_init(input_dev, &ir->ir, ir_type, ir->ir_codes);
+       err = ir_input_init(input_dev, &ir->ir, ir_type);
        if (err < 0)
                goto err_out_free;
 
@@ -445,7 +446,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
        input_dev->name       = ir->name;
        input_dev->phys       = ir->phys;
 
-       err = input_register_device(ir->input);
+       err = ir_input_register(ir->input, ir->ir_codes);
        if (err)
                goto err_out_free;
 
@@ -459,8 +460,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
        return 0;
 
  err_out_free:
-       ir_input_free(input_dev);
-       input_free_device(input_dev);
        kfree(ir);
        return err;
 }
@@ -473,8 +472,7 @@ static int ir_remove(struct i2c_client *client)
        cancel_delayed_work_sync(&ir->work);
 
        /* unregister device */
-       ir_input_free(ir->input);
-       input_unregister_device(ir->input);
+       ir_input_unregister(ir->input);
 
        /* free memory */
        kfree(ir);
index e707ef3086b2b7a3e7025cfce4ff7aaaaa12983d..babcabd73c0821aecf8e2ef1aead0b19aa17d222 100644 (file)
@@ -985,8 +985,8 @@ int ivtv_v4l2_open(struct file *filp)
 
        mutex_lock(&itv->serialize_lock);
        if (ivtv_init_on_first_open(itv)) {
-               IVTV_ERR("Failed to initialize on minor %d\n",
-                               vdev->minor);
+               IVTV_ERR("Failed to initialize on device %s\n",
+                        video_device_node_name(vdev));
                mutex_unlock(&itv->serialize_lock);
                return -ENXIO;
        }
index 67699e3f2aaa07346e142c4dd5eeb6fc9a918b1b..e12c6022373e38afaaf0ad3b559f3184b67456f9 100644 (file)
@@ -245,6 +245,7 @@ static int ivtv_reg_dev(struct ivtv *itv, int type)
 {
        struct ivtv_stream *s = &itv->streams[type];
        int vfl_type = ivtv_stream_info[type].vfl_type;
+       const char *name;
        int num;
 
        if (s->vdev == NULL)
@@ -268,24 +269,24 @@ static int ivtv_reg_dev(struct ivtv *itv, int type)
                s->vdev = NULL;
                return -ENOMEM;
        }
-       num = s->vdev->num;
+       name = video_device_node_name(s->vdev);
 
        switch (vfl_type) {
        case VFL_TYPE_GRABBER:
-               IVTV_INFO("Registered device video%d for %s (%d kB)\n",
-                       num, s->name, itv->options.kilobytes[type]);
+               IVTV_INFO("Registered device %s for %s (%d kB)\n",
+                       name, s->name, itv->options.kilobytes[type]);
                break;
        case VFL_TYPE_RADIO:
-               IVTV_INFO("Registered device radio%d for %s\n",
-                       num, s->name);
+               IVTV_INFO("Registered device %s for %s\n",
+                       name, s->name);
                break;
        case VFL_TYPE_VBI:
                if (itv->options.kilobytes[type])
-                       IVTV_INFO("Registered device vbi%d for %s (%d kB)\n",
-                               num, s->name, itv->options.kilobytes[type]);
+                       IVTV_INFO("Registered device %s for %s (%d kB)\n",
+                               name, s->name, itv->options.kilobytes[type]);
                else
-                       IVTV_INFO("Registered device vbi%d for %s\n",
-                               num, s->name);
+                       IVTV_INFO("Registered device %s for %s\n",
+                               name, s->name);
                break;
        }
        return 0;
index 01e1eefcf1eb8549b5d7d1725d1dae607bc26084..b421858ccf907f8fe6a9cc06c62782b11d026ec1 100644 (file)
@@ -800,8 +800,8 @@ again:
                return IRQ_HANDLED;
 
        if (meye.mchip_mode == MCHIP_HIC_MODE_CONT_OUT) {
-               if (kfifo_get(meye.grabq, (unsigned char *)&reqnr,
-                             sizeof(int)) != sizeof(int)) {
+               if (kfifo_out_locked(&meye.grabq, (unsigned char *)&reqnr,
+                             sizeof(int), &meye.grabq_lock) != sizeof(int)) {
                        mchip_free_frame();
                        return IRQ_HANDLED;
                }
@@ -811,7 +811,8 @@ again:
                meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
                do_gettimeofday(&meye.grab_buffer[reqnr].timestamp);
                meye.grab_buffer[reqnr].sequence = sequence++;
-               kfifo_put(meye.doneq, (unsigned char *)&reqnr, sizeof(int));
+               kfifo_in_locked(&meye.doneq, (unsigned char *)&reqnr,
+                               sizeof(int), &meye.doneq_lock);
                wake_up_interruptible(&meye.proc_list);
        } else {
                int size;
@@ -820,8 +821,8 @@ again:
                        mchip_free_frame();
                        goto again;
                }
-               if (kfifo_get(meye.grabq, (unsigned char *)&reqnr,
-                             sizeof(int)) != sizeof(int)) {
+               if (kfifo_out_locked(&meye.grabq, (unsigned char *)&reqnr,
+                             sizeof(int), &meye.grabq_lock) != sizeof(int)) {
                        mchip_free_frame();
                        goto again;
                }
@@ -831,7 +832,8 @@ again:
                meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
                do_gettimeofday(&meye.grab_buffer[reqnr].timestamp);
                meye.grab_buffer[reqnr].sequence = sequence++;
-               kfifo_put(meye.doneq, (unsigned char *)&reqnr, sizeof(int));
+               kfifo_in_locked(&meye.doneq, (unsigned char *)&reqnr,
+                               sizeof(int), &meye.doneq_lock);
                wake_up_interruptible(&meye.proc_list);
        }
        mchip_free_frame();
@@ -859,8 +861,8 @@ static int meye_open(struct file *file)
 
        for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
                meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
-       kfifo_reset(meye.grabq);
-       kfifo_reset(meye.doneq);
+       kfifo_reset(&meye.grabq);
+       kfifo_reset(&meye.doneq);
        return 0;
 }
 
@@ -933,7 +935,8 @@ static int meyeioc_qbuf_capt(int *nb)
                mchip_cont_compression_start();
 
        meye.grab_buffer[*nb].state = MEYE_BUF_USING;
-       kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int));
+       kfifo_in_locked(&meye.grabq, (unsigned char *)nb, sizeof(int),
+                        &meye.grabq_lock);
        mutex_unlock(&meye.lock);
 
        return 0;
@@ -965,7 +968,9 @@ static int meyeioc_sync(struct file *file, void *fh, int *i)
                /* fall through */
        case MEYE_BUF_DONE:
                meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
-               kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int));
+               if (kfifo_out_locked(&meye.doneq, (unsigned char *)&unused,
+                               sizeof(int), &meye.doneq_lock) != sizeof(int))
+                                       break;
        }
        *i = meye.grab_buffer[*i].size;
        mutex_unlock(&meye.lock);
@@ -1452,7 +1457,8 @@ static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
        buf->flags |= V4L2_BUF_FLAG_QUEUED;
        buf->flags &= ~V4L2_BUF_FLAG_DONE;
        meye.grab_buffer[buf->index].state = MEYE_BUF_USING;
-       kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int));
+       kfifo_in_locked(&meye.grabq, (unsigned char *)&buf->index,
+                       sizeof(int), &meye.grabq_lock);
        mutex_unlock(&meye.lock);
 
        return 0;
@@ -1467,19 +1473,19 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 
        mutex_lock(&meye.lock);
 
-       if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) {
+       if (kfifo_len(&meye.doneq) == 0 && file->f_flags & O_NONBLOCK) {
                mutex_unlock(&meye.lock);
                return -EAGAIN;
        }
 
        if (wait_event_interruptible(meye.proc_list,
-                                    kfifo_len(meye.doneq) != 0) < 0) {
+                                    kfifo_len(&meye.doneq) != 0) < 0) {
                mutex_unlock(&meye.lock);
                return -EINTR;
        }
 
-       if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr,
-                      sizeof(int))) {
+       if (!kfifo_out_locked(&meye.doneq, (unsigned char *)&reqnr,
+                      sizeof(int), &meye.doneq_lock)) {
                mutex_unlock(&meye.lock);
                return -EBUSY;
        }
@@ -1529,8 +1535,8 @@ static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i)
 {
        mutex_lock(&meye.lock);
        mchip_hic_stop();
-       kfifo_reset(meye.grabq);
-       kfifo_reset(meye.doneq);
+       kfifo_reset(&meye.grabq);
+       kfifo_reset(&meye.doneq);
 
        for (i = 0; i < MEYE_MAX_BUFNBRS; i++)
                meye.grab_buffer[i].state = MEYE_BUF_UNUSED;
@@ -1572,7 +1578,7 @@ static unsigned int meye_poll(struct file *file, poll_table *wait)
 
        mutex_lock(&meye.lock);
        poll_wait(file, &meye.proc_list, wait);
-       if (kfifo_len(meye.doneq))
+       if (kfifo_len(&meye.doneq))
                res = POLLIN | POLLRDNORM;
        mutex_unlock(&meye.lock);
        return res;
@@ -1681,7 +1687,6 @@ static struct video_device meye_template = {
        .fops           = &meye_fops,
        .ioctl_ops      = &meye_ioctl_ops,
        .release        = video_device_release,
-       .minor          = -1,
 };
 
 #ifdef CONFIG_PM
@@ -1746,16 +1751,14 @@ static int __devinit meye_probe(struct pci_dev *pcidev,
        }
 
        spin_lock_init(&meye.grabq_lock);
-       meye.grabq = kfifo_alloc(sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL,
-                                &meye.grabq_lock);
-       if (IS_ERR(meye.grabq)) {
+       if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS,
+                               GFP_KERNEL)) {
                printk(KERN_ERR "meye: fifo allocation failed\n");
                goto outkfifoalloc1;
        }
        spin_lock_init(&meye.doneq_lock);
-       meye.doneq = kfifo_alloc(sizeof(int) * MEYE_MAX_BUFNBRS, GFP_KERNEL,
-                                &meye.doneq_lock);
-       if (IS_ERR(meye.doneq)) {
+       if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS,
+                               GFP_KERNEL)) {
                printk(KERN_ERR "meye: fifo allocation failed\n");
                goto outkfifoalloc2;
        }
@@ -1869,9 +1872,9 @@ outregions:
 outenabledev:
        sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 0);
 outsonypienable:
-       kfifo_free(meye.doneq);
+       kfifo_free(&meye.doneq);
 outkfifoalloc2:
-       kfifo_free(meye.grabq);
+       kfifo_free(&meye.grabq);
 outkfifoalloc1:
        vfree(meye.grab_temp);
 outvmalloc:
@@ -1902,8 +1905,8 @@ static void __devexit meye_remove(struct pci_dev *pcidev)
 
        sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 0);
 
-       kfifo_free(meye.doneq);
-       kfifo_free(meye.grabq);
+       kfifo_free(&meye.doneq);
+       kfifo_free(&meye.grabq);
 
        vfree(meye.grab_temp);
 
index 5f70a106ba2bbc8597256a8d0443d75fbb98416b..1321ad5d659701a2feb4c132bf203e53af96c429 100644 (file)
@@ -303,9 +303,9 @@ struct meye {
        struct meye_grab_buffer grab_buffer[MEYE_MAX_BUFNBRS];
        int vma_use_count[MEYE_MAX_BUFNBRS]; /* mmap count */
        struct mutex lock;              /* mutex for open/mmap... */
-       struct kfifo *grabq;            /* queue for buffers to be grabbed */
+       struct kfifo grabq;             /* queue for buffers to be grabbed */
        spinlock_t grabq_lock;          /* lock protecting the queue */
-       struct kfifo *doneq;            /* queue for grabbed buffers */
+       struct kfifo doneq;             /* queue for grabbed buffers */
        spinlock_t doneq_lock;          /* lock protecting the queue */
        wait_queue_head_t proc_list;    /* wait queue */
        struct video_device *video_dev; /* video device parameters */
index 45388d2ce2fdb5688498188dde080df2a874e826..b62c0bd3f8ea013de803ceac7f3f25f1c7a9bb57 100644 (file)
 #include <media/v4l2-chip-ident.h>
 #include <media/soc_camera.h>
 
-/* mt9m001 i2c address 0x5d
+/*
+ * mt9m001 i2c address 0x5d
  * The platform has to define ctruct i2c_board_info objects and link to them
- * from struct soc_camera_link */
+ * from struct soc_camera_link
+ */
 
 /* mt9m001 selected register addresses */
 #define MT9M001_CHIP_VERSION           0x00
 #define MT9M001_COLUMN_SKIP            20
 #define MT9M001_ROW_SKIP               12
 
-static const struct soc_camera_data_format mt9m001_colour_formats[] = {
-       /* Order important: first natively supported,
-        * second supported with a GPIO extender */
-       {
-               .name           = "Bayer (sRGB) 10 bit",
-               .depth          = 10,
-               .fourcc         = V4L2_PIX_FMT_SBGGR16,
-               .colorspace     = V4L2_COLORSPACE_SRGB,
-       }, {
-               .name           = "Bayer (sRGB) 8 bit",
-               .depth          = 8,
-               .fourcc         = V4L2_PIX_FMT_SBGGR8,
-               .colorspace     = V4L2_COLORSPACE_SRGB,
-       }
+/* MT9M001 has only one fixed colorspace per pixelcode */
+struct mt9m001_datafmt {
+       enum v4l2_mbus_pixelcode        code;
+       enum v4l2_colorspace            colorspace;
+};
+
+/* Find a data format by a pixel code in an array */
+static const struct mt9m001_datafmt *mt9m001_find_datafmt(
+       enum v4l2_mbus_pixelcode code, const struct mt9m001_datafmt *fmt,
+       int n)
+{
+       int i;
+       for (i = 0; i < n; i++)
+               if (fmt[i].code == code)
+                       return fmt + i;
+
+       return NULL;
+}
+
+static const struct mt9m001_datafmt mt9m001_colour_fmts[] = {
+       /*
+        * Order important: first natively supported,
+        * second supported with a GPIO extender
+        */
+       {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
 };
 
-static const struct soc_camera_data_format mt9m001_monochrome_formats[] = {
+static const struct mt9m001_datafmt mt9m001_monochrome_fmts[] = {
        /* Order important - see above */
-       {
-               .name           = "Monochrome 10 bit",
-               .depth          = 10,
-               .fourcc         = V4L2_PIX_FMT_Y16,
-       }, {
-               .name           = "Monochrome 8 bit",
-               .depth          = 8,
-               .fourcc         = V4L2_PIX_FMT_GREY,
-       },
+       {V4L2_MBUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG},
+       {V4L2_MBUS_FMT_GREY8_1X8, V4L2_COLORSPACE_JPEG},
 };
 
 struct mt9m001 {
        struct v4l2_subdev subdev;
        struct v4l2_rect rect;  /* Sensor window */
-       __u32 fourcc;
+       const struct mt9m001_datafmt *fmt;
+       const struct mt9m001_datafmt *fmts;
+       int num_fmts;
        int model;      /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */
        unsigned int gain;
        unsigned int exposure;
+       unsigned short y_skip_top;      /* Lines to skip at the top */
        unsigned char autoexposure;
 };
 
@@ -204,8 +214,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        const u16 hblank = 9, vblank = 25;
        unsigned int total_h;
 
-       if (mt9m001->fourcc == V4L2_PIX_FMT_SBGGR8 ||
-           mt9m001->fourcc == V4L2_PIX_FMT_SBGGR16)
+       if (mt9m001->fmts == mt9m001_colour_fmts)
                /*
                 * Bayer format - even number of rows for simplicity,
                 * but let the user play with the top row.
@@ -222,15 +231,17 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        soc_camera_limit_side(&rect.top, &rect.height,
                     MT9M001_ROW_SKIP, MT9M001_MIN_HEIGHT, MT9M001_MAX_HEIGHT);
 
-       total_h = rect.height + icd->y_skip_top + vblank;
+       total_h = rect.height + mt9m001->y_skip_top + vblank;
 
        /* Blanking and start values - default... */
        ret = reg_write(client, MT9M001_HORIZONTAL_BLANKING, hblank);
        if (!ret)
                ret = reg_write(client, MT9M001_VERTICAL_BLANKING, vblank);
 
-       /* The caller provides a supported format, as verified per
-        * call to icd->try_fmt() */
+       /*
+        * The caller provides a supported format, as verified per
+        * call to icd->try_fmt()
+        */
        if (!ret)
                ret = reg_write(client, MT9M001_COLUMN_START, rect.left);
        if (!ret)
@@ -239,7 +250,7 @@ static int mt9m001_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
                ret = reg_write(client, MT9M001_WINDOW_WIDTH, rect.width - 1);
        if (!ret)
                ret = reg_write(client, MT9M001_WINDOW_HEIGHT,
-                               rect.height + icd->y_skip_top - 1);
+                               rect.height + mt9m001->y_skip_top - 1);
        if (!ret && mt9m001->autoexposure) {
                ret = reg_write(client, MT9M001_SHUTTER_WIDTH, total_h);
                if (!ret) {
@@ -283,32 +294,32 @@ static int mt9m001_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
-static int mt9m001_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9m001_g_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct mt9m001 *mt9m001 = to_mt9m001(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       pix->width              = mt9m001->rect.width;
-       pix->height             = mt9m001->rect.height;
-       pix->pixelformat        = mt9m001->fourcc;
-       pix->field              = V4L2_FIELD_NONE;
-       pix->colorspace         = V4L2_COLORSPACE_SRGB;
+       mf->width       = mt9m001->rect.width;
+       mf->height      = mt9m001->rect.height;
+       mf->code        = mt9m001->fmt->code;
+       mf->colorspace  = mt9m001->fmt->colorspace;
+       mf->field       = V4L2_FIELD_NONE;
 
        return 0;
 }
 
-static int mt9m001_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9m001_s_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct mt9m001 *mt9m001 = to_mt9m001(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
        struct v4l2_crop a = {
                .c = {
                        .left   = mt9m001->rect.left,
                        .top    = mt9m001->rect.top,
-                       .width  = pix->width,
-                       .height = pix->height,
+                       .width  = mf->width,
+                       .height = mf->height,
                },
        };
        int ret;
@@ -316,28 +327,39 @@ static int mt9m001_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
        /* No support for scaling so far, just crop. TODO: use skipping */
        ret = mt9m001_s_crop(sd, &a);
        if (!ret) {
-               pix->width = mt9m001->rect.width;
-               pix->height = mt9m001->rect.height;
-               mt9m001->fourcc = pix->pixelformat;
+               mf->width       = mt9m001->rect.width;
+               mf->height      = mt9m001->rect.height;
+               mt9m001->fmt    = mt9m001_find_datafmt(mf->code,
+                                       mt9m001->fmts, mt9m001->num_fmts);
+               mf->colorspace  = mt9m001->fmt->colorspace;
        }
 
        return ret;
 }
 
-static int mt9m001_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9m001_try_fmt(struct v4l2_subdev *sd,
+                          struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
-       struct soc_camera_device *icd = client->dev.platform_data;
-       struct v4l2_pix_format *pix = &f->fmt.pix;
+       struct mt9m001 *mt9m001 = to_mt9m001(client);
+       const struct mt9m001_datafmt *fmt;
 
-       v4l_bound_align_image(&pix->width, MT9M001_MIN_WIDTH,
+       v4l_bound_align_image(&mf->width, MT9M001_MIN_WIDTH,
                MT9M001_MAX_WIDTH, 1,
-               &pix->height, MT9M001_MIN_HEIGHT + icd->y_skip_top,
-               MT9M001_MAX_HEIGHT + icd->y_skip_top, 0, 0);
+               &mf->height, MT9M001_MIN_HEIGHT + mt9m001->y_skip_top,
+               MT9M001_MAX_HEIGHT + mt9m001->y_skip_top, 0, 0);
+
+       if (mt9m001->fmts == mt9m001_colour_fmts)
+               mf->height = ALIGN(mf->height - 1, 2);
 
-       if (pix->pixelformat == V4L2_PIX_FMT_SBGGR8 ||
-           pix->pixelformat == V4L2_PIX_FMT_SBGGR16)
-               pix->height = ALIGN(pix->height - 1, 2);
+       fmt = mt9m001_find_datafmt(mf->code, mt9m001->fmts,
+                                  mt9m001->num_fmts);
+       if (!fmt) {
+               fmt = mt9m001->fmt;
+               mf->code = fmt->code;
+       }
+
+       mf->colorspace  = fmt->colorspace;
 
        return 0;
 }
@@ -552,7 +574,7 @@ static int mt9m001_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
                if (ctrl->value) {
                        const u16 vblank = 25;
                        unsigned int total_h = mt9m001->rect.height +
-                               icd->y_skip_top + vblank;
+                               mt9m001->y_skip_top + vblank;
                        if (reg_write(client, MT9M001_SHUTTER_WIDTH,
                                      total_h) < 0)
                                return -EIO;
@@ -568,8 +590,10 @@ static int mt9m001_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
        return 0;
 }
 
-/* Interface active, can use i2c. If it fails, it can indeed mean, that
- * this wasn't our capture interface, so, we wait for the right one */
+/*
+ * Interface active, can use i2c. If it fails, it can indeed mean, that
+ * this wasn't our capture interface, so, we wait for the right one
+ */
 static int mt9m001_video_probe(struct soc_camera_device *icd,
                               struct i2c_client *client)
 {
@@ -579,8 +603,10 @@ static int mt9m001_video_probe(struct soc_camera_device *icd,
        unsigned long flags;
        int ret;
 
-       /* We must have a parent by now. And it cannot be a wrong one.
-        * So this entire test is completely redundant. */
+       /*
+        * We must have a parent by now. And it cannot be a wrong one.
+        * So this entire test is completely redundant.
+        */
        if (!icd->dev.parent ||
            to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
                return -ENODEV;
@@ -597,11 +623,11 @@ static int mt9m001_video_probe(struct soc_camera_device *icd,
        case 0x8411:
        case 0x8421:
                mt9m001->model = V4L2_IDENT_MT9M001C12ST;
-               icd->formats = mt9m001_colour_formats;
+               mt9m001->fmts = mt9m001_colour_fmts;
                break;
        case 0x8431:
                mt9m001->model = V4L2_IDENT_MT9M001C12STM;
-               icd->formats = mt9m001_monochrome_formats;
+               mt9m001->fmts = mt9m001_monochrome_fmts;
                break;
        default:
                dev_err(&client->dev,
@@ -609,7 +635,7 @@ static int mt9m001_video_probe(struct soc_camera_device *icd,
                return -ENODEV;
        }
 
-       icd->num_formats = 0;
+       mt9m001->num_fmts = 0;
 
        /*
         * This is a 10bit sensor, so by default we only allow 10bit.
@@ -622,14 +648,14 @@ static int mt9m001_video_probe(struct soc_camera_device *icd,
                flags = SOCAM_DATAWIDTH_10;
 
        if (flags & SOCAM_DATAWIDTH_10)
-               icd->num_formats++;
+               mt9m001->num_fmts++;
        else
-               icd->formats++;
+               mt9m001->fmts++;
 
        if (flags & SOCAM_DATAWIDTH_8)
-               icd->num_formats++;
+               mt9m001->num_fmts++;
 
-       mt9m001->fourcc = icd->formats->fourcc;
+       mt9m001->fmt = &mt9m001->fmts[0];
 
        dev_info(&client->dev, "Detected a MT9M001 chip ID %x (%s)\n", data,
                 data == 0x8431 ? "C12STM" : "C12ST");
@@ -655,6 +681,16 @@ static void mt9m001_video_remove(struct soc_camera_device *icd)
                icl->free_bus(icl);
 }
 
+static int mt9m001_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines)
+{
+       struct i2c_client *client = sd->priv;
+       struct mt9m001 *mt9m001 = to_mt9m001(client);
+
+       *lines = mt9m001->y_skip_top;
+
+       return 0;
+}
+
 static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = {
        .g_ctrl         = mt9m001_g_ctrl,
        .s_ctrl         = mt9m001_s_ctrl,
@@ -665,19 +701,38 @@ static struct v4l2_subdev_core_ops mt9m001_subdev_core_ops = {
 #endif
 };
 
+static int mt9m001_enum_fmt(struct v4l2_subdev *sd, int index,
+                           enum v4l2_mbus_pixelcode *code)
+{
+       struct i2c_client *client = sd->priv;
+       struct mt9m001 *mt9m001 = to_mt9m001(client);
+
+       if ((unsigned int)index >= mt9m001->num_fmts)
+               return -EINVAL;
+
+       *code = mt9m001->fmts[index].code;
+       return 0;
+}
+
 static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = {
        .s_stream       = mt9m001_s_stream,
-       .s_fmt          = mt9m001_s_fmt,
-       .g_fmt          = mt9m001_g_fmt,
-       .try_fmt        = mt9m001_try_fmt,
+       .s_mbus_fmt     = mt9m001_s_fmt,
+       .g_mbus_fmt     = mt9m001_g_fmt,
+       .try_mbus_fmt   = mt9m001_try_fmt,
        .s_crop         = mt9m001_s_crop,
        .g_crop         = mt9m001_g_crop,
        .cropcap        = mt9m001_cropcap,
+       .enum_mbus_fmt  = mt9m001_enum_fmt,
+};
+
+static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
+       .g_skip_top_lines       = mt9m001_g_skip_top_lines,
 };
 
 static struct v4l2_subdev_ops mt9m001_subdev_ops = {
        .core   = &mt9m001_subdev_core_ops,
        .video  = &mt9m001_subdev_video_ops,
+       .sensor = &mt9m001_subdev_sensor_ops,
 };
 
 static int mt9m001_probe(struct i2c_client *client,
@@ -714,15 +769,17 @@ static int mt9m001_probe(struct i2c_client *client,
 
        /* Second stage probe - when a capture adapter is there */
        icd->ops                = &mt9m001_ops;
-       icd->y_skip_top         = 0;
 
+       mt9m001->y_skip_top     = 0;
        mt9m001->rect.left      = MT9M001_COLUMN_SKIP;
        mt9m001->rect.top       = MT9M001_ROW_SKIP;
        mt9m001->rect.width     = MT9M001_MAX_WIDTH;
        mt9m001->rect.height    = MT9M001_MAX_HEIGHT;
 
-       /* Simulated autoexposure. If enabled, we calculate shutter width
-        * ourselves in the driver based on vertical blanking and frame width */
+       /*
+        * Simulated autoexposure. If enabled, we calculate shutter width
+        * ourselves in the driver based on vertical blanking and frame width
+        */
        mt9m001->autoexposure = 1;
 
        ret = mt9m001_video_probe(icd, client);
index 90da699601ea334d056008d4334c828dac3695a0..d35f536f9fc37fd6729211d9610adbfa2334c77e 100644 (file)
 #define MT9M111_MAX_HEIGHT     1024
 #define MT9M111_MAX_WIDTH      1280
 
-#define COL_FMT(_name, _depth, _fourcc, _colorspace) \
-       { .name = _name, .depth = _depth, .fourcc = _fourcc, \
-       .colorspace = _colorspace }
-#define RGB_FMT(_name, _depth, _fourcc) \
-       COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_SRGB)
-#define JPG_FMT(_name, _depth, _fourcc) \
-       COL_FMT(_name, _depth, _fourcc, V4L2_COLORSPACE_JPEG)
-
-static const struct soc_camera_data_format mt9m111_colour_formats[] = {
-       JPG_FMT("CbYCrY 16 bit", 16, V4L2_PIX_FMT_UYVY),
-       JPG_FMT("CrYCbY 16 bit", 16, V4L2_PIX_FMT_VYUY),
-       JPG_FMT("YCbYCr 16 bit", 16, V4L2_PIX_FMT_YUYV),
-       JPG_FMT("YCrYCb 16 bit", 16, V4L2_PIX_FMT_YVYU),
-       RGB_FMT("RGB 565", 16, V4L2_PIX_FMT_RGB565),
-       RGB_FMT("RGB 555", 16, V4L2_PIX_FMT_RGB555),
-       RGB_FMT("Bayer (sRGB) 10 bit", 10, V4L2_PIX_FMT_SBGGR16),
-       RGB_FMT("Bayer (sRGB) 8 bit", 8, V4L2_PIX_FMT_SBGGR8),
+/* MT9M111 has only one fixed colorspace per pixelcode */
+struct mt9m111_datafmt {
+       enum v4l2_mbus_pixelcode        code;
+       enum v4l2_colorspace            colorspace;
+};
+
+/* Find a data format by a pixel code in an array */
+static const struct mt9m111_datafmt *mt9m111_find_datafmt(
+       enum v4l2_mbus_pixelcode code, const struct mt9m111_datafmt *fmt,
+       int n)
+{
+       int i;
+       for (i = 0; i < n; i++)
+               if (fmt[i].code == code)
+                       return fmt + i;
+
+       return NULL;
+}
+
+static const struct mt9m111_datafmt mt9m111_colour_fmts[] = {
+       {V4L2_MBUS_FMT_YUYV8_2X8_LE, V4L2_COLORSPACE_JPEG},
+       {V4L2_MBUS_FMT_YVYU8_2X8_LE, V4L2_COLORSPACE_JPEG},
+       {V4L2_MBUS_FMT_YUYV8_2X8_BE, V4L2_COLORSPACE_JPEG},
+       {V4L2_MBUS_FMT_YVYU8_2X8_BE, V4L2_COLORSPACE_JPEG},
+       {V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
 };
 
 enum mt9m111_context {
@@ -152,7 +163,7 @@ struct mt9m111 {
        int model;      /* V4L2_IDENT_MT9M11x* codes from v4l2-chip-ident.h */
        enum mt9m111_context context;
        struct v4l2_rect rect;
-       u32 pixfmt;
+       const struct mt9m111_datafmt *fmt;
        unsigned int gain;
        unsigned char autoexposure;
        unsigned char datawidth;
@@ -258,8 +269,8 @@ static int mt9m111_setup_rect(struct i2c_client *client,
        int width = rect->width;
        int height = rect->height;
 
-       if (mt9m111->pixfmt == V4L2_PIX_FMT_SBGGR8 ||
-           mt9m111->pixfmt == V4L2_PIX_FMT_SBGGR16)
+       if (mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
+           mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE)
                is_raw_format = 1;
        else
                is_raw_format = 0;
@@ -307,7 +318,8 @@ static int mt9m111_setup_pixfmt(struct i2c_client *client, u16 outfmt)
 
 static int mt9m111_setfmt_bayer8(struct i2c_client *client)
 {
-       return mt9m111_setup_pixfmt(client, MT9M111_OUTFMT_PROCESSED_BAYER);
+       return mt9m111_setup_pixfmt(client, MT9M111_OUTFMT_PROCESSED_BAYER |
+                                   MT9M111_OUTFMT_RGB);
 }
 
 static int mt9m111_setfmt_bayer10(struct i2c_client *client)
@@ -401,8 +413,8 @@ static int mt9m111_make_rect(struct i2c_client *client,
 {
        struct mt9m111 *mt9m111 = to_mt9m111(client);
 
-       if (mt9m111->pixfmt == V4L2_PIX_FMT_SBGGR8 ||
-           mt9m111->pixfmt == V4L2_PIX_FMT_SBGGR16) {
+       if (mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
+           mt9m111->fmt->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) {
                /* Bayer format - even size lengths */
                rect->width     = ALIGN(rect->width, 2);
                rect->height    = ALIGN(rect->height, 2);
@@ -460,120 +472,139 @@ static int mt9m111_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
-static int mt9m111_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9m111_g_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct mt9m111 *mt9m111 = to_mt9m111(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       pix->width              = mt9m111->rect.width;
-       pix->height             = mt9m111->rect.height;
-       pix->pixelformat        = mt9m111->pixfmt;
-       pix->field              = V4L2_FIELD_NONE;
-       pix->colorspace         = V4L2_COLORSPACE_SRGB;
+       mf->width       = mt9m111->rect.width;
+       mf->height      = mt9m111->rect.height;
+       mf->code        = mt9m111->fmt->code;
+       mf->field       = V4L2_FIELD_NONE;
 
        return 0;
 }
 
-static int mt9m111_set_pixfmt(struct i2c_client *client, u32 pixfmt)
+static int mt9m111_set_pixfmt(struct i2c_client *client,
+                             enum v4l2_mbus_pixelcode code)
 {
        struct mt9m111 *mt9m111 = to_mt9m111(client);
        int ret;
 
-       switch (pixfmt) {
-       case V4L2_PIX_FMT_SBGGR8:
+       switch (code) {
+       case V4L2_MBUS_FMT_SBGGR8_1X8:
                ret = mt9m111_setfmt_bayer8(client);
                break;
-       case V4L2_PIX_FMT_SBGGR16:
+       case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
                ret = mt9m111_setfmt_bayer10(client);
                break;
-       case V4L2_PIX_FMT_RGB555:
+       case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
                ret = mt9m111_setfmt_rgb555(client);
                break;
-       case V4L2_PIX_FMT_RGB565:
+       case V4L2_MBUS_FMT_RGB565_2X8_LE:
                ret = mt9m111_setfmt_rgb565(client);
                break;
-       case V4L2_PIX_FMT_UYVY:
+       case V4L2_MBUS_FMT_YUYV8_2X8_BE:
                mt9m111->swap_yuv_y_chromas = 0;
                mt9m111->swap_yuv_cb_cr = 0;
                ret = mt9m111_setfmt_yuv(client);
                break;
-       case V4L2_PIX_FMT_VYUY:
+       case V4L2_MBUS_FMT_YVYU8_2X8_BE:
                mt9m111->swap_yuv_y_chromas = 0;
                mt9m111->swap_yuv_cb_cr = 1;
                ret = mt9m111_setfmt_yuv(client);
                break;
-       case V4L2_PIX_FMT_YUYV:
+       case V4L2_MBUS_FMT_YUYV8_2X8_LE:
                mt9m111->swap_yuv_y_chromas = 1;
                mt9m111->swap_yuv_cb_cr = 0;
                ret = mt9m111_setfmt_yuv(client);
                break;
-       case V4L2_PIX_FMT_YVYU:
+       case V4L2_MBUS_FMT_YVYU8_2X8_LE:
                mt9m111->swap_yuv_y_chromas = 1;
                mt9m111->swap_yuv_cb_cr = 1;
                ret = mt9m111_setfmt_yuv(client);
                break;
        default:
                dev_err(&client->dev, "Pixel format not handled : %x\n",
-                       pixfmt);
+                       code);
                ret = -EINVAL;
        }
 
-       if (!ret)
-               mt9m111->pixfmt = pixfmt;
-
        return ret;
 }
 
-static int mt9m111_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9m111_s_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
+       const struct mt9m111_datafmt *fmt;
        struct mt9m111 *mt9m111 = to_mt9m111(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
        struct v4l2_rect rect = {
                .left   = mt9m111->rect.left,
                .top    = mt9m111->rect.top,
-               .width  = pix->width,
-               .height = pix->height,
+               .width  = mf->width,
+               .height = mf->height,
        };
        int ret;
 
+       fmt = mt9m111_find_datafmt(mf->code, mt9m111_colour_fmts,
+                                  ARRAY_SIZE(mt9m111_colour_fmts));
+       if (!fmt)
+               return -EINVAL;
+
        dev_dbg(&client->dev,
-               "%s fmt=%x left=%d, top=%d, width=%d, height=%d\n", __func__,
-               pix->pixelformat, rect.left, rect.top, rect.width, rect.height);
+               "%s code=%x left=%d, top=%d, width=%d, height=%d\n", __func__,
+               mf->code, rect.left, rect.top, rect.width, rect.height);
 
        ret = mt9m111_make_rect(client, &rect);
        if (!ret)
-               ret = mt9m111_set_pixfmt(client, pix->pixelformat);
-       if (!ret)
-               mt9m111->rect = rect;
+               ret = mt9m111_set_pixfmt(client, mf->code);
+       if (!ret) {
+               mt9m111->rect   = rect;
+               mt9m111->fmt    = fmt;
+               mf->colorspace  = fmt->colorspace;
+       }
+
        return ret;
 }
 
-static int mt9m111_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9m111_try_fmt(struct v4l2_subdev *sd,
+                          struct v4l2_mbus_framefmt *mf)
 {
-       struct v4l2_pix_format *pix = &f->fmt.pix;
-       bool bayer = pix->pixelformat == V4L2_PIX_FMT_SBGGR8 ||
-               pix->pixelformat == V4L2_PIX_FMT_SBGGR16;
+       struct i2c_client *client = sd->priv;
+       struct mt9m111 *mt9m111 = to_mt9m111(client);
+       const struct mt9m111_datafmt *fmt;
+       bool bayer = mf->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
+               mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE;
+
+       fmt = mt9m111_find_datafmt(mf->code, mt9m111_colour_fmts,
+                                  ARRAY_SIZE(mt9m111_colour_fmts));
+       if (!fmt) {
+               fmt = mt9m111->fmt;
+               mf->code = fmt->code;
+       }
 
        /*
         * With Bayer format enforce even side lengths, but let the user play
         * with the starting pixel
         */
 
-       if (pix->height > MT9M111_MAX_HEIGHT)
-               pix->height = MT9M111_MAX_HEIGHT;
-       else if (pix->height < 2)
-               pix->height = 2;
+       if (mf->height > MT9M111_MAX_HEIGHT)
+               mf->height = MT9M111_MAX_HEIGHT;
+       else if (mf->height < 2)
+               mf->height = 2;
        else if (bayer)
-               pix->height = ALIGN(pix->height, 2);
+               mf->height = ALIGN(mf->height, 2);
 
-       if (pix->width > MT9M111_MAX_WIDTH)
-               pix->width = MT9M111_MAX_WIDTH;
-       else if (pix->width < 2)
-               pix->width = 2;
+       if (mf->width > MT9M111_MAX_WIDTH)
+               mf->width = MT9M111_MAX_WIDTH;
+       else if (mf->width < 2)
+               mf->width = 2;
        else if (bayer)
-               pix->width = ALIGN(pix->width, 2);
+               mf->width = ALIGN(mf->width, 2);
+
+       mf->colorspace = fmt->colorspace;
 
        return 0;
 }
@@ -863,7 +894,7 @@ static int mt9m111_restore_state(struct i2c_client *client)
        struct mt9m111 *mt9m111 = to_mt9m111(client);
 
        mt9m111_set_context(client, mt9m111->context);
-       mt9m111_set_pixfmt(client, mt9m111->pixfmt);
+       mt9m111_set_pixfmt(client, mt9m111->fmt->code);
        mt9m111_setup_rect(client, &mt9m111->rect);
        mt9m111_set_flip(client, mt9m111->hflip, MT9M111_RMB_MIRROR_COLS);
        mt9m111_set_flip(client, mt9m111->vflip, MT9M111_RMB_MIRROR_ROWS);
@@ -952,9 +983,6 @@ static int mt9m111_video_probe(struct soc_camera_device *icd,
                goto ei2c;
        }
 
-       icd->formats = mt9m111_colour_formats;
-       icd->num_formats = ARRAY_SIZE(mt9m111_colour_formats);
-
        dev_info(&client->dev, "Detected a MT9M11x chip ID %x\n", data);
 
 ei2c:
@@ -971,13 +999,24 @@ static struct v4l2_subdev_core_ops mt9m111_subdev_core_ops = {
 #endif
 };
 
+static int mt9m111_enum_fmt(struct v4l2_subdev *sd, int index,
+                           enum v4l2_mbus_pixelcode *code)
+{
+       if ((unsigned int)index >= ARRAY_SIZE(mt9m111_colour_fmts))
+               return -EINVAL;
+
+       *code = mt9m111_colour_fmts[index].code;
+       return 0;
+}
+
 static struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = {
-       .s_fmt          = mt9m111_s_fmt,
-       .g_fmt          = mt9m111_g_fmt,
-       .try_fmt        = mt9m111_try_fmt,
+       .s_mbus_fmt     = mt9m111_s_fmt,
+       .g_mbus_fmt     = mt9m111_g_fmt,
+       .try_mbus_fmt   = mt9m111_try_fmt,
        .s_crop         = mt9m111_s_crop,
        .g_crop         = mt9m111_g_crop,
        .cropcap        = mt9m111_cropcap,
+       .enum_mbus_fmt  = mt9m111_enum_fmt,
 };
 
 static struct v4l2_subdev_ops mt9m111_subdev_ops = {
@@ -1019,12 +1058,12 @@ static int mt9m111_probe(struct i2c_client *client,
 
        /* Second stage probe - when a capture adapter is there */
        icd->ops                = &mt9m111_ops;
-       icd->y_skip_top         = 0;
 
        mt9m111->rect.left      = MT9M111_MIN_DARK_COLS;
        mt9m111->rect.top       = MT9M111_MIN_DARK_ROWS;
        mt9m111->rect.width     = MT9M111_MAX_WIDTH;
        mt9m111->rect.height    = MT9M111_MAX_HEIGHT;
+       mt9m111->fmt            = &mt9m111_colour_fmts[0];
 
        ret = mt9m111_video_probe(icd, client);
        if (ret) {
index 6966f644977ed3be223e4be95170728e52078ddc..a9061bff79b2189b6e542beaab7417ff7ed35a3d 100644 (file)
 #include <media/v4l2-chip-ident.h>
 #include <media/soc_camera.h>
 
-/* mt9t031 i2c address 0x5d
+/*
+ * mt9t031 i2c address 0x5d
  * The platform has to define i2c_board_info and link to it from
- * struct soc_camera_link */
+ * struct soc_camera_link
+ */
 
 /* mt9t031 selected register addresses */
 #define MT9T031_CHIP_VERSION           0x00
        SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_HIGH |      \
        SOCAM_MASTER | SOCAM_DATAWIDTH_10)
 
-static const struct soc_camera_data_format mt9t031_colour_formats[] = {
-       {
-               .name           = "Bayer (sRGB) 10 bit",
-               .depth          = 10,
-               .fourcc         = V4L2_PIX_FMT_SGRBG10,
-               .colorspace     = V4L2_COLORSPACE_SRGB,
-       }
-};
-
 struct mt9t031 {
        struct v4l2_subdev subdev;
        struct v4l2_rect rect;  /* Sensor window */
@@ -74,6 +67,7 @@ struct mt9t031 {
        u16 xskip;
        u16 yskip;
        unsigned int gain;
+       unsigned short y_skip_top;      /* Lines to skip at the top */
        unsigned int exposure;
        unsigned char autoexposure;
 };
@@ -207,6 +201,71 @@ static unsigned long mt9t031_query_bus_param(struct soc_camera_device *icd)
        return soc_camera_apply_sensor_flags(icl, MT9T031_BUS_PARAM);
 }
 
+enum {
+       MT9T031_CTRL_VFLIP,
+       MT9T031_CTRL_HFLIP,
+       MT9T031_CTRL_GAIN,
+       MT9T031_CTRL_EXPOSURE,
+       MT9T031_CTRL_EXPOSURE_AUTO,
+};
+
+static const struct v4l2_queryctrl mt9t031_controls[] = {
+       [MT9T031_CTRL_VFLIP] = {
+               .id             = V4L2_CID_VFLIP,
+               .type           = V4L2_CTRL_TYPE_BOOLEAN,
+               .name           = "Flip Vertically",
+               .minimum        = 0,
+               .maximum        = 1,
+               .step           = 1,
+               .default_value  = 0,
+       },
+       [MT9T031_CTRL_HFLIP] = {
+               .id             = V4L2_CID_HFLIP,
+               .type           = V4L2_CTRL_TYPE_BOOLEAN,
+               .name           = "Flip Horizontally",
+               .minimum        = 0,
+               .maximum        = 1,
+               .step           = 1,
+               .default_value  = 0,
+       },
+       [MT9T031_CTRL_GAIN] = {
+               .id             = V4L2_CID_GAIN,
+               .type           = V4L2_CTRL_TYPE_INTEGER,
+               .name           = "Gain",
+               .minimum        = 0,
+               .maximum        = 127,
+               .step           = 1,
+               .default_value  = 64,
+               .flags          = V4L2_CTRL_FLAG_SLIDER,
+       },
+       [MT9T031_CTRL_EXPOSURE] = {
+               .id             = V4L2_CID_EXPOSURE,
+               .type           = V4L2_CTRL_TYPE_INTEGER,
+               .name           = "Exposure",
+               .minimum        = 1,
+               .maximum        = 255,
+               .step           = 1,
+               .default_value  = 255,
+               .flags          = V4L2_CTRL_FLAG_SLIDER,
+       },
+       [MT9T031_CTRL_EXPOSURE_AUTO] = {
+               .id             = V4L2_CID_EXPOSURE_AUTO,
+               .type           = V4L2_CTRL_TYPE_BOOLEAN,
+               .name           = "Automatic Exposure",
+               .minimum        = 0,
+               .maximum        = 1,
+               .step           = 1,
+               .default_value  = 1,
+       }
+};
+
+static struct soc_camera_ops mt9t031_ops = {
+       .set_bus_param          = mt9t031_set_bus_param,
+       .query_bus_param        = mt9t031_query_bus_param,
+       .controls               = mt9t031_controls,
+       .num_controls           = ARRAY_SIZE(mt9t031_controls),
+};
+
 /* target must be _even_ */
 static u16 mt9t031_skip(s32 *source, s32 target, s32 max)
 {
@@ -226,10 +285,9 @@ static u16 mt9t031_skip(s32 *source, s32 target, s32 max)
 }
 
 /* rect is the sensor rectangle, the caller guarantees parameter validity */
-static int mt9t031_set_params(struct soc_camera_device *icd,
+static int mt9t031_set_params(struct i2c_client *client,
                              struct v4l2_rect *rect, u16 xskip, u16 yskip)
 {
-       struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
        struct mt9t031 *mt9t031 = to_mt9t031(client);
        int ret;
        u16 xbin, ybin;
@@ -291,8 +349,10 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
        dev_dbg(&client->dev, "new physical left %u, top %u\n",
                rect->left, rect->top);
 
-       /* The caller provides a supported format, as guaranteed by
-        * icd->try_fmt_cap(), soc_camera_s_crop() and soc_camera_cropcap() */
+       /*
+        * The caller provides a supported format, as guaranteed by
+        * icd->try_fmt_cap(), soc_camera_s_crop() and soc_camera_cropcap()
+        */
        if (ret >= 0)
                ret = reg_write(client, MT9T031_COLUMN_START, rect->left);
        if (ret >= 0)
@@ -301,15 +361,14 @@ static int mt9t031_set_params(struct soc_camera_device *icd,
                ret = reg_write(client, MT9T031_WINDOW_WIDTH, rect->width - 1);
        if (ret >= 0)
                ret = reg_write(client, MT9T031_WINDOW_HEIGHT,
-                               rect->height + icd->y_skip_top - 1);
+                               rect->height + mt9t031->y_skip_top - 1);
        if (ret >= 0 && mt9t031->autoexposure) {
-               unsigned int total_h = rect->height + icd->y_skip_top + vblank;
+               unsigned int total_h = rect->height + mt9t031->y_skip_top + vblank;
                ret = set_shutter(client, total_h);
                if (ret >= 0) {
                        const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank;
                        const struct v4l2_queryctrl *qctrl =
-                               soc_camera_find_qctrl(icd->ops,
-                                                     V4L2_CID_EXPOSURE);
+                               &mt9t031_controls[MT9T031_CTRL_EXPOSURE];
                        mt9t031->exposure = (shutter_max / 2 + (total_h - 1) *
                                 (qctrl->maximum - qctrl->minimum)) /
                                shutter_max + qctrl->minimum;
@@ -334,7 +393,6 @@ static int mt9t031_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        struct v4l2_rect rect = a->c;
        struct i2c_client *client = sd->priv;
        struct mt9t031 *mt9t031 = to_mt9t031(client);
-       struct soc_camera_device *icd = client->dev.platform_data;
 
        rect.width = ALIGN(rect.width, 2);
        rect.height = ALIGN(rect.height, 2);
@@ -345,7 +403,7 @@ static int mt9t031_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        soc_camera_limit_side(&rect.top, &rect.height,
                     MT9T031_ROW_SKIP, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT);
 
-       return mt9t031_set_params(icd, &rect, mt9t031->xskip, mt9t031->yskip);
+       return mt9t031_set_params(client, &rect, mt9t031->xskip, mt9t031->yskip);
 }
 
 static int mt9t031_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
@@ -373,27 +431,26 @@ static int mt9t031_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
-static int mt9t031_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9t031_g_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct mt9t031 *mt9t031 = to_mt9t031(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       pix->width              = mt9t031->rect.width / mt9t031->xskip;
-       pix->height             = mt9t031->rect.height / mt9t031->yskip;
-       pix->pixelformat        = V4L2_PIX_FMT_SGRBG10;
-       pix->field              = V4L2_FIELD_NONE;
-       pix->colorspace         = V4L2_COLORSPACE_SRGB;
+       mf->width       = mt9t031->rect.width / mt9t031->xskip;
+       mf->height      = mt9t031->rect.height / mt9t031->yskip;
+       mf->code        = V4L2_MBUS_FMT_SBGGR10_1X10;
+       mf->colorspace  = V4L2_COLORSPACE_SRGB;
+       mf->field       = V4L2_FIELD_NONE;
 
        return 0;
 }
 
-static int mt9t031_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9t031_s_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct mt9t031 *mt9t031 = to_mt9t031(client);
-       struct soc_camera_device *icd = client->dev.platform_data;
-       struct v4l2_pix_format *pix = &f->fmt.pix;
        u16 xskip, yskip;
        struct v4l2_rect rect = mt9t031->rect;
 
@@ -401,24 +458,29 @@ static int mt9t031_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
         * try_fmt has put width and height within limits.
         * S_FMT: use binning and skipping for scaling
         */
-       xskip = mt9t031_skip(&rect.width, pix->width, MT9T031_MAX_WIDTH);
-       yskip = mt9t031_skip(&rect.height, pix->height, MT9T031_MAX_HEIGHT);
+       xskip = mt9t031_skip(&rect.width, mf->width, MT9T031_MAX_WIDTH);
+       yskip = mt9t031_skip(&rect.height, mf->height, MT9T031_MAX_HEIGHT);
+
+       mf->code        = V4L2_MBUS_FMT_SBGGR10_1X10;
+       mf->colorspace  = V4L2_COLORSPACE_SRGB;
 
        /* mt9t031_set_params() doesn't change width and height */
-       return mt9t031_set_params(icd, &rect, xskip, yskip);
+       return mt9t031_set_params(client, &rect, xskip, yskip);
 }
 
 /*
  * If a user window larger than sensor window is requested, we'll increase the
  * sensor window.
  */
-static int mt9t031_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9t031_try_fmt(struct v4l2_subdev *sd,
+                          struct v4l2_mbus_framefmt *mf)
 {
-       struct v4l2_pix_format *pix = &f->fmt.pix;
-
        v4l_bound_align_image(
-               &pix->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1,
-               &pix->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0);
+               &mf->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1,
+               &mf->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0);
+
+       mf->code        = V4L2_MBUS_FMT_SBGGR10_1X10;
+       mf->colorspace  = V4L2_COLORSPACE_SRGB;
 
        return 0;
 }
@@ -479,59 +541,6 @@ static int mt9t031_s_register(struct v4l2_subdev *sd,
 }
 #endif
 
-static const struct v4l2_queryctrl mt9t031_controls[] = {
-       {
-               .id             = V4L2_CID_VFLIP,
-               .type           = V4L2_CTRL_TYPE_BOOLEAN,
-               .name           = "Flip Vertically",
-               .minimum        = 0,
-               .maximum        = 1,
-               .step           = 1,
-               .default_value  = 0,
-       }, {
-               .id             = V4L2_CID_HFLIP,
-               .type           = V4L2_CTRL_TYPE_BOOLEAN,
-               .name           = "Flip Horizontally",
-               .minimum        = 0,
-               .maximum        = 1,
-               .step           = 1,
-               .default_value  = 0,
-       }, {
-               .id             = V4L2_CID_GAIN,
-               .type           = V4L2_CTRL_TYPE_INTEGER,
-               .name           = "Gain",
-               .minimum        = 0,
-               .maximum        = 127,
-               .step           = 1,
-               .default_value  = 64,
-               .flags          = V4L2_CTRL_FLAG_SLIDER,
-       }, {
-               .id             = V4L2_CID_EXPOSURE,
-               .type           = V4L2_CTRL_TYPE_INTEGER,
-               .name           = "Exposure",
-               .minimum        = 1,
-               .maximum        = 255,
-               .step           = 1,
-               .default_value  = 255,
-               .flags          = V4L2_CTRL_FLAG_SLIDER,
-       }, {
-               .id             = V4L2_CID_EXPOSURE_AUTO,
-               .type           = V4L2_CTRL_TYPE_BOOLEAN,
-               .name           = "Automatic Exposure",
-               .minimum        = 0,
-               .maximum        = 1,
-               .step           = 1,
-               .default_value  = 1,
-       }
-};
-
-static struct soc_camera_ops mt9t031_ops = {
-       .set_bus_param          = mt9t031_set_bus_param,
-       .query_bus_param        = mt9t031_query_bus_param,
-       .controls               = mt9t031_controls,
-       .num_controls           = ARRAY_SIZE(mt9t031_controls),
-};
-
 static int mt9t031_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 {
        struct i2c_client *client = sd->priv;
@@ -568,15 +577,9 @@ static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 {
        struct i2c_client *client = sd->priv;
        struct mt9t031 *mt9t031 = to_mt9t031(client);
-       struct soc_camera_device *icd = client->dev.platform_data;
        const struct v4l2_queryctrl *qctrl;
        int data;
 
-       qctrl = soc_camera_find_qctrl(&mt9t031_ops, ctrl->id);
-
-       if (!qctrl)
-               return -EINVAL;
-
        switch (ctrl->id) {
        case V4L2_CID_VFLIP:
                if (ctrl->value)
@@ -595,6 +598,7 @@ static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
                        return -EIO;
                break;
        case V4L2_CID_GAIN:
+               qctrl = &mt9t031_controls[MT9T031_CTRL_GAIN];
                if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum)
                        return -EINVAL;
                /* See Datasheet Table 7, Gain settings. */
@@ -634,6 +638,7 @@ static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
                mt9t031->gain = ctrl->value;
                break;
        case V4L2_CID_EXPOSURE:
+               qctrl = &mt9t031_controls[MT9T031_CTRL_EXPOSURE];
                /* mt9t031 has maximum == default */
                if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum)
                        return -EINVAL;
@@ -657,11 +662,11 @@ static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
                        const u16 vblank = MT9T031_VERTICAL_BLANK;
                        const u32 shutter_max = MT9T031_MAX_HEIGHT + vblank;
                        unsigned int total_h = mt9t031->rect.height +
-                               icd->y_skip_top + vblank;
+                               mt9t031->y_skip_top + vblank;
 
                        if (set_shutter(client, total_h) < 0)
                                return -EIO;
-                       qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
+                       qctrl = &mt9t031_controls[MT9T031_CTRL_EXPOSURE];
                        mt9t031->exposure = (shutter_max / 2 + (total_h - 1) *
                                 (qctrl->maximum - qctrl->minimum)) /
                                shutter_max + qctrl->minimum;
@@ -669,15 +674,18 @@ static int mt9t031_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
                } else
                        mt9t031->autoexposure = 0;
                break;
+       default:
+               return -EINVAL;
        }
        return 0;
 }
 
-/* Interface active, can use i2c. If it fails, it can indeed mean, that
- * this wasn't our capture interface, so, we wait for the right one */
+/*
+ * Interface active, can use i2c. If it fails, it can indeed mean, that
+ * this wasn't our capture interface, so, we wait for the right one
+ */
 static int mt9t031_video_probe(struct i2c_client *client)
 {
-       struct soc_camera_device *icd = client->dev.platform_data;
        struct mt9t031 *mt9t031 = to_mt9t031(client);
        s32 data;
        int ret;
@@ -692,8 +700,6 @@ static int mt9t031_video_probe(struct i2c_client *client)
        switch (data) {
        case 0x1621:
                mt9t031->model = V4L2_IDENT_MT9T031;
-               icd->formats = mt9t031_colour_formats;
-               icd->num_formats = ARRAY_SIZE(mt9t031_colour_formats);
                break;
        default:
                dev_err(&client->dev,
@@ -714,6 +720,16 @@ static int mt9t031_video_probe(struct i2c_client *client)
        return ret;
 }
 
+static int mt9t031_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines)
+{
+       struct i2c_client *client = sd->priv;
+       struct mt9t031 *mt9t031 = to_mt9t031(client);
+
+       *lines = mt9t031->y_skip_top;
+
+       return 0;
+}
+
 static struct v4l2_subdev_core_ops mt9t031_subdev_core_ops = {
        .g_ctrl         = mt9t031_g_ctrl,
        .s_ctrl         = mt9t031_s_ctrl,
@@ -724,19 +740,35 @@ static struct v4l2_subdev_core_ops mt9t031_subdev_core_ops = {
 #endif
 };
 
+static int mt9t031_enum_fmt(struct v4l2_subdev *sd, int index,
+                           enum v4l2_mbus_pixelcode *code)
+{
+       if (index)
+               return -EINVAL;
+
+       *code = V4L2_MBUS_FMT_SBGGR10_1X10;
+       return 0;
+}
+
 static struct v4l2_subdev_video_ops mt9t031_subdev_video_ops = {
        .s_stream       = mt9t031_s_stream,
-       .s_fmt          = mt9t031_s_fmt,
-       .g_fmt          = mt9t031_g_fmt,
-       .try_fmt        = mt9t031_try_fmt,
+       .s_mbus_fmt     = mt9t031_s_fmt,
+       .g_mbus_fmt     = mt9t031_g_fmt,
+       .try_mbus_fmt   = mt9t031_try_fmt,
        .s_crop         = mt9t031_s_crop,
        .g_crop         = mt9t031_g_crop,
        .cropcap        = mt9t031_cropcap,
+       .enum_mbus_fmt  = mt9t031_enum_fmt,
+};
+
+static struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = {
+       .g_skip_top_lines       = mt9t031_g_skip_top_lines,
 };
 
 static struct v4l2_subdev_ops mt9t031_subdev_ops = {
        .core   = &mt9t031_subdev_core_ops,
        .video  = &mt9t031_subdev_video_ops,
+       .sensor = &mt9t031_subdev_sensor_ops,
 };
 
 static int mt9t031_probe(struct i2c_client *client,
@@ -745,18 +777,16 @@ static int mt9t031_probe(struct i2c_client *client,
        struct mt9t031 *mt9t031;
        struct soc_camera_device *icd = client->dev.platform_data;
        struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
-       struct soc_camera_link *icl;
        int ret;
 
-       if (!icd) {
-               dev_err(&client->dev, "MT9T031: missing soc-camera data!\n");
-               return -EINVAL;
-       }
+       if (icd) {
+               struct soc_camera_link *icl = to_soc_camera_link(icd);
+               if (!icl) {
+                       dev_err(&client->dev, "MT9T031 driver needs platform data\n");
+                       return -EINVAL;
+               }
 
-       icl = to_soc_camera_link(icd);
-       if (!icl) {
-               dev_err(&client->dev, "MT9T031 driver needs platform data\n");
-               return -EINVAL;
+               icd->ops = &mt9t031_ops;
        }
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {
@@ -771,17 +801,16 @@ static int mt9t031_probe(struct i2c_client *client,
 
        v4l2_i2c_subdev_init(&mt9t031->subdev, client, &mt9t031_subdev_ops);
 
-       /* Second stage probe - when a capture adapter is there */
-       icd->ops                = &mt9t031_ops;
-       icd->y_skip_top         = 0;
-
+       mt9t031->y_skip_top     = 0;
        mt9t031->rect.left      = MT9T031_COLUMN_SKIP;
        mt9t031->rect.top       = MT9T031_ROW_SKIP;
        mt9t031->rect.width     = MT9T031_MAX_WIDTH;
        mt9t031->rect.height    = MT9T031_MAX_HEIGHT;
 
-       /* Simulated autoexposure. If enabled, we calculate shutter width
-        * ourselves in the driver based on vertical blanking and frame width */
+       /*
+        * Simulated autoexposure. If enabled, we calculate shutter width
+        * ourselves in the driver based on vertical blanking and frame width
+        */
        mt9t031->autoexposure = 1;
 
        mt9t031->xskip = 1;
@@ -794,7 +823,8 @@ static int mt9t031_probe(struct i2c_client *client,
        mt9t031_disable(client);
 
        if (ret) {
-               icd->ops = NULL;
+               if (icd)
+                       icd->ops = NULL;
                i2c_set_clientdata(client, NULL);
                kfree(mt9t031);
        }
@@ -807,7 +837,8 @@ static int mt9t031_remove(struct i2c_client *client)
        struct mt9t031 *mt9t031 = to_mt9t031(client);
        struct soc_camera_device *icd = client->dev.platform_data;
 
-       icd->ops = NULL;
+       if (icd)
+               icd->ops = NULL;
        i2c_set_clientdata(client, NULL);
        client->driver = NULL;
        kfree(mt9t031);
diff --git a/drivers/media/video/mt9t112.c b/drivers/media/video/mt9t112.c
new file mode 100644 (file)
index 0000000..fc4dd60
--- /dev/null
@@ -0,0 +1,1177 @@
+/*
+ * mt9t112 Camera Driver
+ *
+ * Copyright (C) 2009 Renesas Solutions Corp.
+ * Kuninori Morimoto <morimoto.kuninori@renesas.com>
+ *
+ * Based on ov772x driver, mt9m111 driver,
+ *
+ * Copyright (C) 2008 Kuninori Morimoto <morimoto.kuninori@renesas.com>
+ * Copyright (C) 2008, Robert Jarzmik <robert.jarzmik@free.fr>
+ * Copyright 2006-7 Jonathan Corbet <corbet@lwn.net>
+ * Copyright (C) 2008 Magnus Damm
+ * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/videodev2.h>
+
+#include <media/mt9t112.h>
+#include <media/soc_camera.h>
+#include <media/soc_mediabus.h>
+#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-common.h>
+
+/* you can check PLL/clock info */
+/* #define EXT_CLOCK 24000000 */
+
+/************************************************************************
+
+
+                       macro
+
+
+************************************************************************/
+/*
+ * frame size
+ */
+#define MAX_WIDTH   2048
+#define MAX_HEIGHT  1536
+
+#define VGA_WIDTH   640
+#define VGA_HEIGHT  480
+
+/*
+ * macro of read/write
+ */
+#define ECHECKER(ret, x)               \
+       do {                            \
+               (ret) = (x);            \
+               if ((ret) < 0)          \
+                       return (ret);   \
+       } while (0)
+
+#define mt9t112_reg_write(ret, client, a, b) \
+       ECHECKER(ret, __mt9t112_reg_write(client, a, b))
+#define mt9t112_mcu_write(ret, client, a, b) \
+       ECHECKER(ret, __mt9t112_mcu_write(client, a, b))
+
+#define mt9t112_reg_mask_set(ret, client, a, b, c) \
+       ECHECKER(ret, __mt9t112_reg_mask_set(client, a, b, c))
+#define mt9t112_mcu_mask_set(ret, client, a, b, c) \
+       ECHECKER(ret, __mt9t112_mcu_mask_set(client, a, b, c))
+
+#define mt9t112_reg_read(ret, client, a) \
+       ECHECKER(ret, __mt9t112_reg_read(client, a))
+
+/*
+ * Logical address
+ */
+#define _VAR(id, offset, base) (base | (id & 0x1f) << 10 | (offset & 0x3ff))
+#define VAR(id, offset)  _VAR(id, offset, 0x0000)
+#define VAR8(id, offset) _VAR(id, offset, 0x8000)
+
+/************************************************************************
+
+
+                       struct
+
+
+************************************************************************/
+struct mt9t112_frame_size {
+       u16 width;
+       u16 height;
+};
+
+struct mt9t112_format {
+       enum v4l2_mbus_pixelcode code;
+       enum v4l2_colorspace colorspace;
+       u16 fmt;
+       u16 order;
+};
+
+struct mt9t112_priv {
+       struct v4l2_subdev               subdev;
+       struct mt9t112_camera_info      *info;
+       struct i2c_client               *client;
+       struct soc_camera_device         icd;
+       struct mt9t112_frame_size        frame;
+       const struct mt9t112_format     *format;
+       int                              model;
+       u32                              flags;
+/* for flags */
+#define INIT_DONE  (1<<0)
+};
+
+/************************************************************************
+
+
+                       supported format
+
+
+************************************************************************/
+
+static const struct mt9t112_format mt9t112_cfmts[] = {
+       {
+               .code           = V4L2_MBUS_FMT_YUYV8_2X8_BE,
+               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .fmt            = 1,
+               .order          = 0,
+       }, {
+               .code           = V4L2_MBUS_FMT_YVYU8_2X8_BE,
+               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .fmt            = 1,
+               .order          = 1,
+       }, {
+               .code           = V4L2_MBUS_FMT_YUYV8_2X8_LE,
+               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .fmt            = 1,
+               .order          = 2,
+       }, {
+               .code           = V4L2_MBUS_FMT_YVYU8_2X8_LE,
+               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .fmt            = 1,
+               .order          = 3,
+       }, {
+               .code           = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
+               .colorspace     = V4L2_COLORSPACE_SRGB,
+               .fmt            = 8,
+               .order          = 2,
+       }, {
+               .code           = V4L2_MBUS_FMT_RGB565_2X8_LE,
+               .colorspace     = V4L2_COLORSPACE_SRGB,
+               .fmt            = 4,
+               .order          = 2,
+       },
+};
+
+/************************************************************************
+
+
+                       general function
+
+
+************************************************************************/
+static struct mt9t112_priv *to_mt9t112(const struct i2c_client *client)
+{
+       return container_of(i2c_get_clientdata(client),
+                           struct mt9t112_priv,
+                           subdev);
+}
+
+static int __mt9t112_reg_read(const struct i2c_client *client, u16 command)
+{
+       struct i2c_msg msg[2];
+       u8 buf[2];
+       int ret;
+
+       command = swab16(command);
+
+       msg[0].addr  = client->addr;
+       msg[0].flags = 0;
+       msg[0].len   = 2;
+       msg[0].buf   = (u8 *)&command;
+
+       msg[1].addr  = client->addr;
+       msg[1].flags = I2C_M_RD;
+       msg[1].len   = 2;
+       msg[1].buf   = buf;
+
+       /*
+        * if return value of this function is < 0,
+        * it mean error.
+        * else, under 16bit is valid data.
+        */
+       ret = i2c_transfer(client->adapter, msg, 2);
+       if (ret < 0)
+               return ret;
+
+       memcpy(&ret, buf, 2);
+       return swab16(ret);
+}
+
+static int __mt9t112_reg_write(const struct i2c_client *client,
+                              u16 command, u16 data)
+{
+       struct i2c_msg msg;
+       u8 buf[4];
+       int ret;
+
+       command = swab16(command);
+       data = swab16(data);
+
+       memcpy(buf + 0, &command, 2);
+       memcpy(buf + 2, &data,    2);
+
+       msg.addr  = client->addr;
+       msg.flags = 0;
+       msg.len   = 4;
+       msg.buf   = buf;
+
+       /*
+        * i2c_transfer return message length,
+        * but this function should return 0 if correct case
+        */
+       ret = i2c_transfer(client->adapter, &msg, 1);
+       if (ret >= 0)
+               ret = 0;
+
+       return ret;
+}
+
+static int __mt9t112_reg_mask_set(const struct i2c_client *client,
+                                 u16  command,
+                                 u16  mask,
+                                 u16  set)
+{
+       int val = __mt9t112_reg_read(client, command);
+       if (val < 0)
+               return val;
+
+       val &= ~mask;
+       val |= set & mask;
+
+       return __mt9t112_reg_write(client, command, val);
+}
+
+/* mcu access */
+static int __mt9t112_mcu_read(const struct i2c_client *client, u16 command)
+{
+       int ret;
+
+       ret = __mt9t112_reg_write(client, 0x098E, command);
+       if (ret < 0)
+               return ret;
+
+       return __mt9t112_reg_read(client, 0x0990);
+}
+
+static int __mt9t112_mcu_write(const struct i2c_client *client,
+                              u16 command, u16 data)
+{
+       int ret;
+
+       ret = __mt9t112_reg_write(client, 0x098E, command);
+       if (ret < 0)
+               return ret;
+
+       return __mt9t112_reg_write(client, 0x0990, data);
+}
+
+static int __mt9t112_mcu_mask_set(const struct i2c_client *client,
+                                 u16  command,
+                                 u16  mask,
+                                 u16  set)
+{
+       int val = __mt9t112_mcu_read(client, command);
+       if (val < 0)
+               return val;
+
+       val &= ~mask;
+       val |= set & mask;
+
+       return __mt9t112_mcu_write(client, command, val);
+}
+
+static int mt9t112_reset(const struct i2c_client *client)
+{
+       int ret;
+
+       mt9t112_reg_mask_set(ret, client, 0x001a, 0x0001, 0x0001);
+       msleep(1);
+       mt9t112_reg_mask_set(ret, client, 0x001a, 0x0001, 0x0000);
+
+       return ret;
+}
+
+#ifndef EXT_CLOCK
+#define CLOCK_INFO(a, b)
+#else
+#define CLOCK_INFO(a, b) mt9t112_clock_info(a, b)
+static int mt9t112_clock_info(const struct i2c_client *client, u32 ext)
+{
+       int m, n, p1, p2, p3, p4, p5, p6, p7;
+       u32 vco, clk;
+       char *enable;
+
+       ext /= 1000; /* kbyte order */
+
+       mt9t112_reg_read(n, client, 0x0012);
+       p1 = n & 0x000f;
+       n = n >> 4;
+       p2 = n & 0x000f;
+       n = n >> 4;
+       p3 = n & 0x000f;
+
+       mt9t112_reg_read(n, client, 0x002a);
+       p4 = n & 0x000f;
+       n = n >> 4;
+       p5 = n & 0x000f;
+       n = n >> 4;
+       p6 = n & 0x000f;
+
+       mt9t112_reg_read(n, client, 0x002c);
+       p7 = n & 0x000f;
+
+       mt9t112_reg_read(n, client, 0x0010);
+       m = n & 0x00ff;
+       n = (n >> 8) & 0x003f;
+
+       enable = ((6000 > ext) || (54000 < ext)) ? "X" : "";
+       dev_info(&client->dev, "EXTCLK          : %10u K %s\n", ext, enable);
+
+       vco = 2 * m * ext / (n+1);
+       enable = ((384000 > vco) || (768000 < vco)) ? "X" : "";
+       dev_info(&client->dev, "VCO             : %10u K %s\n", vco, enable);
+
+       clk = vco / (p1+1) / (p2+1);
+       enable = (96000 < clk) ? "X" : "";
+       dev_info(&client->dev, "PIXCLK          : %10u K %s\n", clk, enable);
+
+       clk = vco / (p3+1);
+       enable = (768000 < clk) ? "X" : "";
+       dev_info(&client->dev, "MIPICLK         : %10u K %s\n", clk, enable);
+
+       clk = vco / (p6+1);
+       enable = (96000 < clk) ? "X" : "";
+       dev_info(&client->dev, "MCU CLK         : %10u K %s\n", clk, enable);
+
+       clk = vco / (p5+1);
+       enable = (54000 < clk) ? "X" : "";
+       dev_info(&client->dev, "SOC CLK         : %10u K %s\n", clk, enable);
+
+       clk = vco / (p4+1);
+       enable = (70000 < clk) ? "X" : "";
+       dev_info(&client->dev, "Sensor CLK      : %10u K %s\n", clk, enable);
+
+       clk = vco / (p7+1);
+       dev_info(&client->dev, "External sensor : %10u K\n", clk);
+
+       clk = ext / (n+1);
+       enable = ((2000 > clk) || (24000 < clk)) ? "X" : "";
+       dev_info(&client->dev, "PFD             : %10u K %s\n", clk, enable);
+
+       return 0;
+}
+#endif
+
+static void mt9t112_frame_check(u32 *width, u32 *height)
+{
+       if (*width > MAX_WIDTH)
+               *width = MAX_WIDTH;
+
+       if (*height > MAX_HEIGHT)
+               *height = MAX_HEIGHT;
+}
+
+static int mt9t112_set_a_frame_size(const struct i2c_client *client,
+                                  u16 width,
+                                  u16 height)
+{
+       int ret;
+       u16 wstart = (MAX_WIDTH - width) / 2;
+       u16 hstart = (MAX_HEIGHT - height) / 2;
+
+       /* (Context A) Image Width/Height */
+       mt9t112_mcu_write(ret, client, VAR(26, 0), width);
+       mt9t112_mcu_write(ret, client, VAR(26, 2), height);
+
+       /* (Context A) Output Width/Height */
+       mt9t112_mcu_write(ret, client, VAR(18, 43), 8 + width);
+       mt9t112_mcu_write(ret, client, VAR(18, 45), 8 + height);
+
+       /* (Context A) Start Row/Column */
+       mt9t112_mcu_write(ret, client, VAR(18, 2), 4 + hstart);
+       mt9t112_mcu_write(ret, client, VAR(18, 4), 4 + wstart);
+
+       /* (Context A) End Row/Column */
+       mt9t112_mcu_write(ret, client, VAR(18, 6), 11 + height + hstart);
+       mt9t112_mcu_write(ret, client, VAR(18, 8), 11 + width  + wstart);
+
+       mt9t112_mcu_write(ret, client, VAR8(1, 0), 0x06);
+
+       return ret;
+}
+
+static int mt9t112_set_pll_dividers(const struct i2c_client *client,
+                                   u8 m, u8 n,
+                                   u8 p1, u8 p2, u8 p3,
+                                   u8 p4, u8 p5, u8 p6,
+                                   u8 p7)
+{
+       int ret;
+       u16 val;
+
+       /* N/M */
+       val = (n << 8) |
+             (m << 0);
+       mt9t112_reg_mask_set(ret, client, 0x0010, 0x3fff, val);
+
+       /* P1/P2/P3 */
+       val = ((p3 & 0x0F) << 8) |
+             ((p2 & 0x0F) << 4) |
+             ((p1 & 0x0F) << 0);
+       mt9t112_reg_mask_set(ret, client, 0x0012, 0x0fff, val);
+
+       /* P4/P5/P6 */
+       val = (0x7         << 12) |
+             ((p6 & 0x0F) <<  8) |
+             ((p5 & 0x0F) <<  4) |
+             ((p4 & 0x0F) <<  0);
+       mt9t112_reg_mask_set(ret, client, 0x002A, 0x7fff, val);
+
+       /* P7 */
+       val = (0x1         << 12) |
+             ((p7 & 0x0F) <<  0);
+       mt9t112_reg_mask_set(ret, client, 0x002C, 0x100f, val);
+
+       return ret;
+}
+
+static int mt9t112_init_pll(const struct i2c_client *client)
+{
+       struct mt9t112_priv *priv = to_mt9t112(client);
+       int data, i, ret;
+
+       mt9t112_reg_mask_set(ret, client, 0x0014, 0x003, 0x0001);
+
+       /* PLL control: BYPASS PLL = 8517 */
+       mt9t112_reg_write(ret, client, 0x0014, 0x2145);
+
+       /* Replace these registers when new timing parameters are generated */
+       mt9t112_set_pll_dividers(client,
+                                priv->info->divider.m,
+                                priv->info->divider.n,
+                                priv->info->divider.p1,
+                                priv->info->divider.p2,
+                                priv->info->divider.p3,
+                                priv->info->divider.p4,
+                                priv->info->divider.p5,
+                                priv->info->divider.p6,
+                                priv->info->divider.p7);
+
+       /*
+        * TEST_BYPASS  on
+        * PLL_ENABLE   on
+        * SEL_LOCK_DET on
+        * TEST_BYPASS  off
+        */
+       mt9t112_reg_write(ret, client, 0x0014, 0x2525);
+       mt9t112_reg_write(ret, client, 0x0014, 0x2527);
+       mt9t112_reg_write(ret, client, 0x0014, 0x3427);
+       mt9t112_reg_write(ret, client, 0x0014, 0x3027);
+
+       mdelay(10);
+
+       /*
+        * PLL_BYPASS off
+        * Reference clock count
+        * I2C Master Clock Divider
+        */
+       mt9t112_reg_write(ret, client, 0x0014, 0x3046);
+       mt9t112_reg_write(ret, client, 0x0022, 0x0190);
+       mt9t112_reg_write(ret, client, 0x3B84, 0x0212);
+
+       /* External sensor clock is PLL bypass */
+       mt9t112_reg_write(ret, client, 0x002E, 0x0500);
+
+       mt9t112_reg_mask_set(ret, client, 0x0018, 0x0002, 0x0002);
+       mt9t112_reg_mask_set(ret, client, 0x3B82, 0x0004, 0x0004);
+
+       /* MCU disabled */
+       mt9t112_reg_mask_set(ret, client, 0x0018, 0x0004, 0x0004);
+
+       /* out of standby */
+       mt9t112_reg_mask_set(ret, client, 0x0018, 0x0001, 0);
+
+       mdelay(50);
+
+       /*
+        * Standby Workaround
+        * Disable Secondary I2C Pads
+        */
+       mt9t112_reg_write(ret, client, 0x0614, 0x0001);
+       mdelay(1);
+       mt9t112_reg_write(ret, client, 0x0614, 0x0001);
+       mdelay(1);
+       mt9t112_reg_write(ret, client, 0x0614, 0x0001);
+       mdelay(1);
+       mt9t112_reg_write(ret, client, 0x0614, 0x0001);
+       mdelay(1);
+       mt9t112_reg_write(ret, client, 0x0614, 0x0001);
+       mdelay(1);
+       mt9t112_reg_write(ret, client, 0x0614, 0x0001);
+       mdelay(1);
+
+       /* poll to verify out of standby. Must Poll this bit */
+       for (i = 0; i < 100; i++) {
+               mt9t112_reg_read(data, client, 0x0018);
+               if (0x4000 & data)
+                       break;
+
+               mdelay(10);
+       }
+
+       return ret;
+}
+
+static int mt9t112_init_setting(const struct i2c_client *client)
+{
+
+       int ret;
+
+       /* Adaptive Output Clock (A) */
+       mt9t112_mcu_mask_set(ret, client, VAR(26, 160), 0x0040, 0x0000);
+
+       /* Read Mode (A) */
+       mt9t112_mcu_write(ret, client, VAR(18, 12), 0x0024);
+
+       /* Fine Correction (A) */
+       mt9t112_mcu_write(ret, client, VAR(18, 15), 0x00CC);
+
+       /* Fine IT Min (A) */
+       mt9t112_mcu_write(ret, client, VAR(18, 17), 0x01f1);
+
+       /* Fine IT Max Margin (A) */
+       mt9t112_mcu_write(ret, client, VAR(18, 19), 0x00fF);
+
+       /* Base Frame Lines (A) */
+       mt9t112_mcu_write(ret, client, VAR(18, 29), 0x032D);
+
+       /* Min Line Length (A) */
+       mt9t112_mcu_write(ret, client, VAR(18, 31), 0x073a);
+
+       /* Line Length (A) */
+       mt9t112_mcu_write(ret, client, VAR(18, 37), 0x07d0);
+
+       /* Adaptive Output Clock (B) */
+       mt9t112_mcu_mask_set(ret, client, VAR(27, 160), 0x0040, 0x0000);
+
+       /* Row Start (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 74), 0x004);
+
+       /* Column Start (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 76), 0x004);
+
+       /* Row End (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 78), 0x60B);
+
+       /* Column End (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 80), 0x80B);
+
+       /* Fine Correction (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 87), 0x008C);
+
+       /* Fine IT Min (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 89), 0x01F1);
+
+       /* Fine IT Max Margin (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 91), 0x00FF);
+
+       /* Base Frame Lines (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 101), 0x0668);
+
+       /* Min Line Length (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 103), 0x0AF0);
+
+       /* Line Length (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 109), 0x0AF0);
+
+       /*
+        * Flicker Dectection registers
+        * This section should be replaced whenever new Timing file is generated
+        * All the following registers need to be replaced
+        * Following registers are generated from Register Wizard but user can
+        * modify them. For detail see auto flicker detection tuning
+        */
+
+       /* FD_FDPERIOD_SELECT */
+       mt9t112_mcu_write(ret, client, VAR8(8, 5), 0x01);
+
+       /* PRI_B_CONFIG_FD_ALGO_RUN */
+       mt9t112_mcu_write(ret, client, VAR(27, 17), 0x0003);
+
+       /* PRI_A_CONFIG_FD_ALGO_RUN */
+       mt9t112_mcu_write(ret, client, VAR(26, 17), 0x0003);
+
+       /*
+        * AFD range detection tuning registers
+        */
+
+       /* search_f1_50 */
+       mt9t112_mcu_write(ret, client, VAR8(18, 165), 0x25);
+
+       /* search_f2_50 */
+       mt9t112_mcu_write(ret, client, VAR8(18, 166), 0x28);
+
+       /* search_f1_60 */
+       mt9t112_mcu_write(ret, client, VAR8(18, 167), 0x2C);
+
+       /* search_f2_60 */
+       mt9t112_mcu_write(ret, client, VAR8(18, 168), 0x2F);
+
+       /* period_50Hz (A) */
+       mt9t112_mcu_write(ret, client, VAR8(18, 68), 0xBA);
+
+       /* secret register by aptina */
+       /* period_50Hz (A MSB) */
+       mt9t112_mcu_write(ret, client, VAR8(18, 303), 0x00);
+
+       /* period_60Hz (A) */
+       mt9t112_mcu_write(ret, client, VAR8(18, 69), 0x9B);
+
+       /* secret register by aptina */
+       /* period_60Hz (A MSB) */
+       mt9t112_mcu_write(ret, client, VAR8(18, 301), 0x00);
+
+       /* period_50Hz (B) */
+       mt9t112_mcu_write(ret, client, VAR8(18, 140), 0x82);
+
+       /* secret register by aptina */
+       /* period_50Hz (B) MSB */
+       mt9t112_mcu_write(ret, client, VAR8(18, 304), 0x00);
+
+       /* period_60Hz (B) */
+       mt9t112_mcu_write(ret, client, VAR8(18, 141), 0x6D);
+
+       /* secret register by aptina */
+       /* period_60Hz (B) MSB */
+       mt9t112_mcu_write(ret, client, VAR8(18, 302), 0x00);
+
+       /* FD Mode */
+       mt9t112_mcu_write(ret, client, VAR8(8, 2), 0x10);
+
+       /* Stat_min */
+       mt9t112_mcu_write(ret, client, VAR8(8, 9), 0x02);
+
+       /* Stat_max */
+       mt9t112_mcu_write(ret, client, VAR8(8, 10), 0x03);
+
+       /* Min_amplitude */
+       mt9t112_mcu_write(ret, client, VAR8(8, 12), 0x0A);
+
+       /* RX FIFO Watermark (A) */
+       mt9t112_mcu_write(ret, client, VAR(18, 70), 0x0014);
+
+       /* RX FIFO Watermark (B) */
+       mt9t112_mcu_write(ret, client, VAR(18, 142), 0x0014);
+
+       /* MCLK: 16MHz
+        * PCLK: 73MHz
+        * CorePixCLK: 36.5 MHz
+        */
+       mt9t112_mcu_write(ret, client, VAR8(18, 0x0044), 133);
+       mt9t112_mcu_write(ret, client, VAR8(18, 0x0045), 110);
+       mt9t112_mcu_write(ret, client, VAR8(18, 0x008c), 130);
+       mt9t112_mcu_write(ret, client, VAR8(18, 0x008d), 108);
+
+       mt9t112_mcu_write(ret, client, VAR8(18, 0x00A5), 27);
+       mt9t112_mcu_write(ret, client, VAR8(18, 0x00a6), 30);
+       mt9t112_mcu_write(ret, client, VAR8(18, 0x00a7), 32);
+       mt9t112_mcu_write(ret, client, VAR8(18, 0x00a8), 35);
+
+       return ret;
+}
+
+static int mt9t112_auto_focus_setting(const struct i2c_client *client)
+{
+       int ret;
+
+       mt9t112_mcu_write(ret, client, VAR(12, 13),     0x000F);
+       mt9t112_mcu_write(ret, client, VAR(12, 23),     0x0F0F);
+       mt9t112_mcu_write(ret, client, VAR8(1, 0),      0x06);
+
+       mt9t112_reg_write(ret, client, 0x0614, 0x0000);
+
+       mt9t112_mcu_write(ret, client, VAR8(1, 0),      0x05);
+       mt9t112_mcu_write(ret, client, VAR8(12, 2),     0x02);
+       mt9t112_mcu_write(ret, client, VAR(12, 3),      0x0002);
+       mt9t112_mcu_write(ret, client, VAR(17, 3),      0x8001);
+       mt9t112_mcu_write(ret, client, VAR(17, 11),     0x0025);
+       mt9t112_mcu_write(ret, client, VAR(17, 13),     0x0193);
+       mt9t112_mcu_write(ret, client, VAR8(17, 33),    0x18);
+       mt9t112_mcu_write(ret, client, VAR8(1, 0),      0x05);
+
+       return ret;
+}
+
+static int mt9t112_auto_focus_trigger(const struct i2c_client *client)
+{
+       int ret;
+
+       mt9t112_mcu_write(ret, client, VAR8(12, 25), 0x01);
+
+       return ret;
+}
+
+static int mt9t112_init_camera(const struct i2c_client *client)
+{
+       int ret;
+
+       ECHECKER(ret, mt9t112_reset(client));
+
+       ECHECKER(ret, mt9t112_init_pll(client));
+
+       ECHECKER(ret, mt9t112_init_setting(client));
+
+       ECHECKER(ret, mt9t112_auto_focus_setting(client));
+
+       mt9t112_reg_mask_set(ret, client, 0x0018, 0x0004, 0);
+
+       /* Analog setting B */
+       mt9t112_reg_write(ret, client, 0x3084, 0x2409);
+       mt9t112_reg_write(ret, client, 0x3092, 0x0A49);
+       mt9t112_reg_write(ret, client, 0x3094, 0x4949);
+       mt9t112_reg_write(ret, client, 0x3096, 0x4950);
+
+       /*
+        * Disable adaptive clock
+        * PRI_A_CONFIG_JPEG_OB_TX_CONTROL_VAR
+        * PRI_B_CONFIG_JPEG_OB_TX_CONTROL_VAR
+        */
+       mt9t112_mcu_write(ret, client, VAR(26, 160), 0x0A2E);
+       mt9t112_mcu_write(ret, client, VAR(27, 160), 0x0A2E);
+
+       /* Configure STatus in Status_before_length Format and enable header */
+       /* PRI_B_CONFIG_JPEG_OB_TX_CONTROL_VAR */
+       mt9t112_mcu_write(ret, client, VAR(27, 144), 0x0CB4);
+
+       /* Enable JPEG in context B */
+       /* PRI_B_CONFIG_JPEG_OB_TX_CONTROL_VAR */
+       mt9t112_mcu_write(ret, client, VAR8(27, 142), 0x01);
+
+       /* Disable Dac_TXLO */
+       mt9t112_reg_write(ret, client, 0x316C, 0x350F);
+
+       /* Set max slew rates */
+       mt9t112_reg_write(ret, client, 0x1E, 0x777);
+
+       return ret;
+}
+
+/************************************************************************
+
+
+                       soc_camera_ops
+
+
+************************************************************************/
+static int mt9t112_set_bus_param(struct soc_camera_device *icd,
+                                unsigned long  flags)
+{
+       return 0;
+}
+
+static unsigned long mt9t112_query_bus_param(struct soc_camera_device *icd)
+{
+       struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
+       struct mt9t112_priv *priv = to_mt9t112(client);
+       struct soc_camera_link *icl = to_soc_camera_link(icd);
+       unsigned long flags = SOCAM_MASTER | SOCAM_VSYNC_ACTIVE_HIGH |
+               SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_DATA_ACTIVE_HIGH;
+
+       flags |= (priv->info->flags & MT9T112_FLAG_PCLK_RISING_EDGE) ?
+               SOCAM_PCLK_SAMPLE_RISING : SOCAM_PCLK_SAMPLE_FALLING;
+
+       if (priv->info->flags & MT9T112_FLAG_DATAWIDTH_8)
+               flags |= SOCAM_DATAWIDTH_8;
+       else
+               flags |= SOCAM_DATAWIDTH_10;
+
+       return soc_camera_apply_sensor_flags(icl, flags);
+}
+
+static struct soc_camera_ops mt9t112_ops = {
+       .set_bus_param          = mt9t112_set_bus_param,
+       .query_bus_param        = mt9t112_query_bus_param,
+};
+
+/************************************************************************
+
+
+                       v4l2_subdev_core_ops
+
+
+************************************************************************/
+static int mt9t112_g_chip_ident(struct v4l2_subdev *sd,
+                               struct v4l2_dbg_chip_ident *id)
+{
+       struct i2c_client *client = sd->priv;
+       struct mt9t112_priv *priv = to_mt9t112(client);
+
+       id->ident    = priv->model;
+       id->revision = 0;
+
+       return 0;
+}
+
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+static int mt9t112_g_register(struct v4l2_subdev *sd,
+                             struct v4l2_dbg_register *reg)
+{
+       struct i2c_client *client = sd->priv;
+       int                ret;
+
+       reg->size = 2;
+       mt9t112_reg_read(ret, client, reg->reg);
+
+       reg->val = (__u64)ret;
+
+       return 0;
+}
+
+static int mt9t112_s_register(struct v4l2_subdev *sd,
+                             struct v4l2_dbg_register *reg)
+{
+       struct i2c_client *client = sd->priv;
+       int ret;
+
+       mt9t112_reg_write(ret, client, reg->reg, reg->val);
+
+       return ret;
+}
+#endif
+
+static struct v4l2_subdev_core_ops mt9t112_subdev_core_ops = {
+       .g_chip_ident   = mt9t112_g_chip_ident,
+#ifdef CONFIG_VIDEO_ADV_DEBUG
+       .g_register     = mt9t112_g_register,
+       .s_register     = mt9t112_s_register,
+#endif
+};
+
+
+/************************************************************************
+
+
+                       v4l2_subdev_video_ops
+
+
+************************************************************************/
+static int mt9t112_s_stream(struct v4l2_subdev *sd, int enable)
+{
+       struct i2c_client *client = sd->priv;
+       struct mt9t112_priv *priv = to_mt9t112(client);
+       int ret = 0;
+
+       if (!enable) {
+               /* FIXME
+                *
+                * If user selected large output size,
+                * and used it long time,
+                * mt9t112 camera will be very warm.
+                *
+                * But current driver can not stop mt9t112 camera.
+                * So, set small size here to solve this problem.
+                */
+               mt9t112_set_a_frame_size(client, VGA_WIDTH, VGA_HEIGHT);
+               return ret;
+       }
+
+       if (!(priv->flags & INIT_DONE)) {
+               u16 param = (MT9T112_FLAG_PCLK_RISING_EDGE &
+                            priv->info->flags) ? 0x0001 : 0x0000;
+
+               ECHECKER(ret, mt9t112_init_camera(client));
+
+               /* Invert PCLK (Data sampled on falling edge of pixclk) */
+               mt9t112_reg_write(ret, client, 0x3C20, param);
+
+               mdelay(5);
+
+               priv->flags |= INIT_DONE;
+       }
+
+       mt9t112_mcu_write(ret, client, VAR(26, 7), priv->format->fmt);
+       mt9t112_mcu_write(ret, client, VAR(26, 9), priv->format->order);
+       mt9t112_mcu_write(ret, client, VAR8(1, 0), 0x06);
+
+       mt9t112_set_a_frame_size(client,
+                                priv->frame.width,
+                                priv->frame.height);
+
+       ECHECKER(ret, mt9t112_auto_focus_trigger(client));
+
+       dev_dbg(&client->dev, "format : %d\n", priv->format->code);
+       dev_dbg(&client->dev, "size   : %d x %d\n",
+               priv->frame.width,
+               priv->frame.height);
+
+       CLOCK_INFO(client, EXT_CLOCK);
+
+       return ret;
+}
+
+static int mt9t112_set_params(struct i2c_client *client, u32 width, u32 height,
+                             enum v4l2_mbus_pixelcode code)
+{
+       struct mt9t112_priv *priv = to_mt9t112(client);
+       int i;
+
+       priv->format = NULL;
+
+       /*
+        * frame size check
+        */
+       mt9t112_frame_check(&width, &height);
+
+       /*
+        * get color format
+        */
+       for (i = 0; i < ARRAY_SIZE(mt9t112_cfmts); i++)
+               if (mt9t112_cfmts[i].code == code)
+                       break;
+
+       if (i == ARRAY_SIZE(mt9t112_cfmts))
+               return -EINVAL;
+
+       priv->frame.width  = (u16)width;
+       priv->frame.height = (u16)height;
+
+       priv->format = mt9t112_cfmts + i;
+
+       return 0;
+}
+
+static int mt9t112_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
+{
+       a->bounds.left                  = 0;
+       a->bounds.top                   = 0;
+       a->bounds.width                 = VGA_WIDTH;
+       a->bounds.height                = VGA_HEIGHT;
+       a->defrect                      = a->bounds;
+       a->type                         = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       a->pixelaspect.numerator        = 1;
+       a->pixelaspect.denominator      = 1;
+
+       return 0;
+}
+
+static int mt9t112_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+{
+       a->c.left       = 0;
+       a->c.top        = 0;
+       a->c.width      = VGA_WIDTH;
+       a->c.height     = VGA_HEIGHT;
+       a->type         = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+       return 0;
+}
+
+static int mt9t112_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+{
+       struct i2c_client *client = sd->priv;
+       struct v4l2_rect *rect = &a->c;
+
+       return mt9t112_set_params(client, rect->width, rect->height,
+                                V4L2_MBUS_FMT_YUYV8_2X8_BE);
+}
+
+static int mt9t112_g_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
+{
+       struct i2c_client *client = sd->priv;
+       struct mt9t112_priv *priv = to_mt9t112(client);
+
+       if (!priv->format) {
+               int ret = mt9t112_set_params(client, VGA_WIDTH, VGA_HEIGHT,
+                                            V4L2_MBUS_FMT_YUYV8_2X8_BE);
+               if (ret < 0)
+                       return ret;
+       }
+
+       mf->width       = priv->frame.width;
+       mf->height      = priv->frame.height;
+       /* TODO: set colorspace */
+       mf->code        = priv->format->code;
+       mf->field       = V4L2_FIELD_NONE;
+
+       return 0;
+}
+
+static int mt9t112_s_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
+{
+       struct i2c_client *client = sd->priv;
+
+       /* TODO: set colorspace */
+       return mt9t112_set_params(client, mf->width, mf->height, mf->code);
+}
+
+static int mt9t112_try_fmt(struct v4l2_subdev *sd,
+                          struct v4l2_mbus_framefmt *mf)
+{
+       mt9t112_frame_check(&mf->width, &mf->height);
+
+       /* TODO: set colorspace */
+       mf->field = V4L2_FIELD_NONE;
+
+       return 0;
+}
+
+static int mt9t112_enum_fmt(struct v4l2_subdev *sd, int index,
+                          enum v4l2_mbus_pixelcode *code)
+{
+       if ((unsigned int)index >= ARRAY_SIZE(mt9t112_cfmts))
+               return -EINVAL;
+
+       *code = mt9t112_cfmts[index].code;
+       return 0;
+}
+
+static struct v4l2_subdev_video_ops mt9t112_subdev_video_ops = {
+       .s_stream       = mt9t112_s_stream,
+       .g_mbus_fmt     = mt9t112_g_fmt,
+       .s_mbus_fmt     = mt9t112_s_fmt,
+       .try_mbus_fmt   = mt9t112_try_fmt,
+       .cropcap        = mt9t112_cropcap,
+       .g_crop         = mt9t112_g_crop,
+       .s_crop         = mt9t112_s_crop,
+       .enum_mbus_fmt  = mt9t112_enum_fmt,
+};
+
+/************************************************************************
+
+
+                       i2c driver
+
+
+************************************************************************/
+static struct v4l2_subdev_ops mt9t112_subdev_ops = {
+       .core   = &mt9t112_subdev_core_ops,
+       .video  = &mt9t112_subdev_video_ops,
+};
+
+static int mt9t112_camera_probe(struct soc_camera_device *icd,
+                               struct i2c_client *client)
+{
+       struct mt9t112_priv *priv = to_mt9t112(client);
+       const char          *devname;
+       int                  chipid;
+
+       /*
+        * We must have a parent by now. And it cannot be a wrong one.
+        * So this entire test is completely redundant.
+        */
+       if (!icd->dev.parent ||
+           to_soc_camera_host(icd->dev.parent)->nr != icd->iface)
+               return -ENODEV;
+
+       /*
+        * check and show chip ID
+        */
+       mt9t112_reg_read(chipid, client, 0x0000);
+
+       switch (chipid) {
+       case 0x2680:
+               devname = "mt9t111";
+               priv->model = V4L2_IDENT_MT9T111;
+               break;
+       case 0x2682:
+               devname = "mt9t112";
+               priv->model = V4L2_IDENT_MT9T112;
+               break;
+       default:
+               dev_err(&client->dev, "Product ID error %04x\n", chipid);
+               return -ENODEV;
+       }
+
+       dev_info(&client->dev, "%s chip ID %04x\n", devname, chipid);
+
+       return 0;
+}
+
+static int mt9t112_probe(struct i2c_client *client,
+                        const struct i2c_device_id *did)
+{
+       struct mt9t112_priv        *priv;
+       struct soc_camera_device   *icd = client->dev.platform_data;
+       struct soc_camera_link     *icl;
+       int                         ret;
+
+       if (!icd) {
+               dev_err(&client->dev, "mt9t112: missing soc-camera data!\n");
+               return -EINVAL;
+       }
+
+       icl = to_soc_camera_link(icd);
+       if (!icl || !icl->priv)
+               return -EINVAL;
+
+       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->info = icl->priv;
+
+       v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
+
+       icd->ops = &mt9t112_ops;
+
+       ret = mt9t112_camera_probe(icd, client);
+       if (ret) {
+               icd->ops = NULL;
+               i2c_set_clientdata(client, NULL);
+               kfree(priv);
+       }
+
+       return ret;
+}
+
+static int mt9t112_remove(struct i2c_client *client)
+{
+       struct mt9t112_priv *priv = to_mt9t112(client);
+       struct soc_camera_device *icd = client->dev.platform_data;
+
+       icd->ops = NULL;
+       i2c_set_clientdata(client, NULL);
+       kfree(priv);
+       return 0;
+}
+
+static const struct i2c_device_id mt9t112_id[] = {
+       { "mt9t112", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, mt9t112_id);
+
+static struct i2c_driver mt9t112_i2c_driver = {
+       .driver = {
+               .name = "mt9t112",
+       },
+       .probe    = mt9t112_probe,
+       .remove   = mt9t112_remove,
+       .id_table = mt9t112_id,
+};
+
+/************************************************************************
+
+
+                       module function
+
+
+************************************************************************/
+static int __init mt9t112_module_init(void)
+{
+       return i2c_add_driver(&mt9t112_i2c_driver);
+}
+
+static void __exit mt9t112_module_exit(void)
+{
+       i2c_del_driver(&mt9t112_i2c_driver);
+}
+
+module_init(mt9t112_module_init);
+module_exit(mt9t112_module_exit);
+
+MODULE_DESCRIPTION("SoC Camera driver for mt9t112");
+MODULE_AUTHOR("Kuninori Morimoto");
+MODULE_LICENSE("GPL v2");
index 995607f9d3ba97a9caea35e0f4fff014866f001c..91df7ec91fb67d06496cc9b0de41bdf1ee15a2c6 100644 (file)
 #include <media/v4l2-chip-ident.h>
 #include <media/soc_camera.h>
 
-/* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c
+/*
+ * mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c
  * The platform has to define ctruct i2c_board_info objects and link to them
- * from struct soc_camera_link */
+ * from struct soc_camera_link
+ */
 
 static char *sensor_type;
 module_param(sensor_type, charp, S_IRUGO);
@@ -62,41 +64,49 @@ MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\"");
 #define MT9V022_COLUMN_SKIP            1
 #define MT9V022_ROW_SKIP               4
 
-static const struct soc_camera_data_format mt9v022_colour_formats[] = {
-       /* Order important: first natively supported,
-        * second supported with a GPIO extender */
-       {
-               .name           = "Bayer (sRGB) 10 bit",
-               .depth          = 10,
-               .fourcc         = V4L2_PIX_FMT_SBGGR16,
-               .colorspace     = V4L2_COLORSPACE_SRGB,
-       }, {
-               .name           = "Bayer (sRGB) 8 bit",
-               .depth          = 8,
-               .fourcc         = V4L2_PIX_FMT_SBGGR8,
-               .colorspace     = V4L2_COLORSPACE_SRGB,
-       }
+/* MT9V022 has only one fixed colorspace per pixelcode */
+struct mt9v022_datafmt {
+       enum v4l2_mbus_pixelcode        code;
+       enum v4l2_colorspace            colorspace;
+};
+
+/* Find a data format by a pixel code in an array */
+static const struct mt9v022_datafmt *mt9v022_find_datafmt(
+       enum v4l2_mbus_pixelcode code, const struct mt9v022_datafmt *fmt,
+       int n)
+{
+       int i;
+       for (i = 0; i < n; i++)
+               if (fmt[i].code == code)
+                       return fmt + i;
+
+       return NULL;
+}
+
+static const struct mt9v022_datafmt mt9v022_colour_fmts[] = {
+       /*
+        * Order important: first natively supported,
+        * second supported with a GPIO extender
+        */
+       {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR8_1X8, V4L2_COLORSPACE_SRGB},
 };
 
-static const struct soc_camera_data_format mt9v022_monochrome_formats[] = {
+static const struct mt9v022_datafmt mt9v022_monochrome_fmts[] = {
        /* Order important - see above */
-       {
-               .name           = "Monochrome 10 bit",
-               .depth          = 10,
-               .fourcc         = V4L2_PIX_FMT_Y16,
-       }, {
-               .name           = "Monochrome 8 bit",
-               .depth          = 8,
-               .fourcc         = V4L2_PIX_FMT_GREY,
-       },
+       {V4L2_MBUS_FMT_Y10_1X10, V4L2_COLORSPACE_JPEG},
+       {V4L2_MBUS_FMT_GREY8_1X8, V4L2_COLORSPACE_JPEG},
 };
 
 struct mt9v022 {
        struct v4l2_subdev subdev;
        struct v4l2_rect rect;  /* Sensor window */
-       __u32 fourcc;
+       const struct mt9v022_datafmt *fmt;
+       const struct mt9v022_datafmt *fmts;
+       int num_fmts;
        int model;      /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */
        u16 chip_control;
+       unsigned short y_skip_top;      /* Lines to skip at the top */
 };
 
 static struct mt9v022 *to_mt9v022(const struct i2c_client *client)
@@ -143,9 +153,11 @@ static int mt9v022_init(struct i2c_client *client)
        struct mt9v022 *mt9v022 = to_mt9v022(client);
        int ret;
 
-       /* Almost the default mode: master, parallel, simultaneous, and an
+       /*
+        * Almost the default mode: master, parallel, simultaneous, and an
         * undocumented bit 0x200, which is present in table 7, but not in 8,
-        * plus snapshot mode to disable scan for now */
+        * plus snapshot mode to disable scan for now
+        */
        mt9v022->chip_control |= 0x10;
        ret = reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
        if (!ret)
@@ -265,12 +277,10 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        struct i2c_client *client = sd->priv;
        struct mt9v022 *mt9v022 = to_mt9v022(client);
        struct v4l2_rect rect = a->c;
-       struct soc_camera_device *icd = client->dev.platform_data;
        int ret;
 
        /* Bayer format - even size lengths */
-       if (mt9v022->fourcc == V4L2_PIX_FMT_SBGGR8 ||
-           mt9v022->fourcc == V4L2_PIX_FMT_SBGGR16) {
+       if (mt9v022->fmts == mt9v022_colour_fmts) {
                rect.width      = ALIGN(rect.width, 2);
                rect.height     = ALIGN(rect.height, 2);
                /* Let the user play with the starting pixel */
@@ -287,10 +297,10 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        if (ret >= 0) {
                if (ret & 1) /* Autoexposure */
                        ret = reg_write(client, MT9V022_MAX_TOTAL_SHUTTER_WIDTH,
-                                       rect.height + icd->y_skip_top + 43);
+                                       rect.height + mt9v022->y_skip_top + 43);
                else
                        ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH,
-                                       rect.height + icd->y_skip_top + 43);
+                                       rect.height + mt9v022->y_skip_top + 43);
        }
        /* Setup frame format: defaults apart from width and height */
        if (!ret)
@@ -298,8 +308,10 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        if (!ret)
                ret = reg_write(client, MT9V022_ROW_START, rect.top);
        if (!ret)
-               /* Default 94, Phytec driver says:
-                * "width + horizontal blank >= 660" */
+               /*
+                * Default 94, Phytec driver says:
+                * "width + horizontal blank >= 660"
+                */
                ret = reg_write(client, MT9V022_HORIZONTAL_BLANKING,
                                rect.width > 660 - 43 ? 43 :
                                660 - rect.width);
@@ -309,7 +321,7 @@ static int mt9v022_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
                ret = reg_write(client, MT9V022_WINDOW_WIDTH, rect.width);
        if (!ret)
                ret = reg_write(client, MT9V022_WINDOW_HEIGHT,
-                               rect.height + icd->y_skip_top);
+                               rect.height + mt9v022->y_skip_top);
 
        if (ret < 0)
                return ret;
@@ -346,46 +358,48 @@ static int mt9v022_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
-static int mt9v022_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9v022_g_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct mt9v022 *mt9v022 = to_mt9v022(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       pix->width              = mt9v022->rect.width;
-       pix->height             = mt9v022->rect.height;
-       pix->pixelformat        = mt9v022->fourcc;
-       pix->field              = V4L2_FIELD_NONE;
-       pix->colorspace         = V4L2_COLORSPACE_SRGB;
+       mf->width       = mt9v022->rect.width;
+       mf->height      = mt9v022->rect.height;
+       mf->code        = mt9v022->fmt->code;
+       mf->colorspace  = mt9v022->fmt->colorspace;
+       mf->field       = V4L2_FIELD_NONE;
 
        return 0;
 }
 
-static int mt9v022_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9v022_s_fmt(struct v4l2_subdev *sd,
+                        struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct mt9v022 *mt9v022 = to_mt9v022(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
        struct v4l2_crop a = {
                .c = {
                        .left   = mt9v022->rect.left,
                        .top    = mt9v022->rect.top,
-                       .width  = pix->width,
-                       .height = pix->height,
+                       .width  = mf->width,
+                       .height = mf->height,
                },
        };
        int ret;
 
-       /* The caller provides a supported format, as verified per call to
-        * icd->try_fmt(), datawidth is from our supported format list */
-       switch (pix->pixelformat) {
-       case V4L2_PIX_FMT_GREY:
-       case V4L2_PIX_FMT_Y16:
+       /*
+        * The caller provides a supported format, as verified per call to
+        * icd->try_fmt(), datawidth is from our supported format list
+        */
+       switch (mf->code) {
+       case V4L2_MBUS_FMT_GREY8_1X8:
+       case V4L2_MBUS_FMT_Y10_1X10:
                if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATM)
                        return -EINVAL;
                break;
-       case V4L2_PIX_FMT_SBGGR8:
-       case V4L2_PIX_FMT_SBGGR16:
+       case V4L2_MBUS_FMT_SBGGR8_1X8:
+       case V4L2_MBUS_FMT_SBGGR10_1X10:
                if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATC)
                        return -EINVAL;
                break;
@@ -399,26 +413,38 @@ static int mt9v022_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
        /* No support for scaling on this camera, just crop. */
        ret = mt9v022_s_crop(sd, &a);
        if (!ret) {
-               pix->width = mt9v022->rect.width;
-               pix->height = mt9v022->rect.height;
-               mt9v022->fourcc = pix->pixelformat;
+               mf->width       = mt9v022->rect.width;
+               mf->height      = mt9v022->rect.height;
+               mt9v022->fmt    = mt9v022_find_datafmt(mf->code,
+                                       mt9v022->fmts, mt9v022->num_fmts);
+               mf->colorspace  = mt9v022->fmt->colorspace;
        }
 
        return ret;
 }
 
-static int mt9v022_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int mt9v022_try_fmt(struct v4l2_subdev *sd,
+                          struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
-       struct soc_camera_device *icd = client->dev.platform_data;
-       struct v4l2_pix_format *pix = &f->fmt.pix;
-       int align = pix->pixelformat == V4L2_PIX_FMT_SBGGR8 ||
-               pix->pixelformat == V4L2_PIX_FMT_SBGGR16;
+       struct mt9v022 *mt9v022 = to_mt9v022(client);
+       const struct mt9v022_datafmt *fmt;
+       int align = mf->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
+               mf->code == V4L2_MBUS_FMT_SBGGR10_1X10;
 
-       v4l_bound_align_image(&pix->width, MT9V022_MIN_WIDTH,
+       v4l_bound_align_image(&mf->width, MT9V022_MIN_WIDTH,
                MT9V022_MAX_WIDTH, align,
-               &pix->height, MT9V022_MIN_HEIGHT + icd->y_skip_top,
-               MT9V022_MAX_HEIGHT + icd->y_skip_top, align, 0);
+               &mf->height, MT9V022_MIN_HEIGHT + mt9v022->y_skip_top,
+               MT9V022_MAX_HEIGHT + mt9v022->y_skip_top, align, 0);
+
+       fmt = mt9v022_find_datafmt(mf->code, mt9v022->fmts,
+                                  mt9v022->num_fmts);
+       if (!fmt) {
+               fmt = mt9v022->fmt;
+               mf->code = fmt->code;
+       }
+
+       mf->colorspace  = fmt->colorspace;
 
        return 0;
 }
@@ -635,8 +661,10 @@ static int mt9v022_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
                                              48 + range / 2) / range + 16;
                        if (gain >= 32)
                                gain &= ~1;
-                       /* The user wants to set gain manually, hope, she
-                        * knows, what she's doing... Switch AGC off. */
+                       /*
+                        * The user wants to set gain manually, hope, she
+                        * knows, what she's doing... Switch AGC off.
+                        */
 
                        if (reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x2) < 0)
                                return -EIO;
@@ -655,8 +683,10 @@ static int mt9v022_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
                        unsigned long range = qctrl->maximum - qctrl->minimum;
                        unsigned long shutter = ((ctrl->value - qctrl->minimum) *
                                                 479 + range / 2) / range + 1;
-                       /* The user wants to set shutter width manually, hope,
-                        * she knows, what she's doing... Switch AEC off. */
+                       /*
+                        * The user wants to set shutter width manually, hope,
+                        * she knows, what she's doing... Switch AEC off.
+                        */
 
                        if (reg_clear(client, MT9V022_AEC_AGC_ENABLE, 0x1) < 0)
                                return -EIO;
@@ -689,8 +719,10 @@ static int mt9v022_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
        return 0;
 }
 
-/* Interface active, can use i2c. If it fails, it can indeed mean, that
- * this wasn't our capture interface, so, we wait for the right one */
+/*
+ * Interface active, can use i2c. If it fails, it can indeed mean, that
+ * this wasn't our capture interface, so, we wait for the right one
+ */
 static int mt9v022_video_probe(struct soc_camera_device *icd,
                               struct i2c_client *client)
 {
@@ -733,17 +765,17 @@ static int mt9v022_video_probe(struct soc_camera_device *icd,
                            !strcmp("color", sensor_type))) {
                ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
                mt9v022->model = V4L2_IDENT_MT9V022IX7ATC;
-               icd->formats = mt9v022_colour_formats;
+               mt9v022->fmts = mt9v022_colour_fmts;
        } else {
                ret = reg_write(client, MT9V022_PIXEL_OPERATION_MODE, 0x11);
                mt9v022->model = V4L2_IDENT_MT9V022IX7ATM;
-               icd->formats = mt9v022_monochrome_formats;
+               mt9v022->fmts = mt9v022_monochrome_fmts;
        }
 
        if (ret < 0)
                goto ei2c;
 
-       icd->num_formats = 0;
+       mt9v022->num_fmts = 0;
 
        /*
         * This is a 10bit sensor, so by default we only allow 10bit.
@@ -756,14 +788,14 @@ static int mt9v022_video_probe(struct soc_camera_device *icd,
                flags = SOCAM_DATAWIDTH_10;
 
        if (flags & SOCAM_DATAWIDTH_10)
-               icd->num_formats++;
+               mt9v022->num_fmts++;
        else
-               icd->formats++;
+               mt9v022->fmts++;
 
        if (flags & SOCAM_DATAWIDTH_8)
-               icd->num_formats++;
+               mt9v022->num_fmts++;
 
-       mt9v022->fourcc = icd->formats->fourcc;
+       mt9v022->fmt = &mt9v022->fmts[0];
 
        dev_info(&client->dev, "Detected a MT9V022 chip ID %x, %s sensor\n",
                 data, mt9v022->model == V4L2_IDENT_MT9V022IX7ATM ?
@@ -787,6 +819,16 @@ static void mt9v022_video_remove(struct soc_camera_device *icd)
                icl->free_bus(icl);
 }
 
+static int mt9v022_g_skip_top_lines(struct v4l2_subdev *sd, u32 *lines)
+{
+       struct i2c_client *client = sd->priv;
+       struct mt9v022 *mt9v022 = to_mt9v022(client);
+
+       *lines = mt9v022->y_skip_top;
+
+       return 0;
+}
+
 static struct v4l2_subdev_core_ops mt9v022_subdev_core_ops = {
        .g_ctrl         = mt9v022_g_ctrl,
        .s_ctrl         = mt9v022_s_ctrl,
@@ -797,19 +839,38 @@ static struct v4l2_subdev_core_ops mt9v022_subdev_core_ops = {
 #endif
 };
 
+static int mt9v022_enum_fmt(struct v4l2_subdev *sd, int index,
+                           enum v4l2_mbus_pixelcode *code)
+{
+       struct i2c_client *client = sd->priv;
+       struct mt9v022 *mt9v022 = to_mt9v022(client);
+
+       if ((unsigned int)index >= mt9v022->num_fmts)
+               return -EINVAL;
+
+       *code = mt9v022->fmts[index].code;
+       return 0;
+}
+
 static struct v4l2_subdev_video_ops mt9v022_subdev_video_ops = {
        .s_stream       = mt9v022_s_stream,
-       .s_fmt          = mt9v022_s_fmt,
-       .g_fmt          = mt9v022_g_fmt,
-       .try_fmt        = mt9v022_try_fmt,
+       .s_mbus_fmt     = mt9v022_s_fmt,
+       .g_mbus_fmt     = mt9v022_g_fmt,
+       .try_mbus_fmt   = mt9v022_try_fmt,
        .s_crop         = mt9v022_s_crop,
        .g_crop         = mt9v022_g_crop,
        .cropcap        = mt9v022_cropcap,
+       .enum_mbus_fmt  = mt9v022_enum_fmt,
+};
+
+static struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = {
+       .g_skip_top_lines       = mt9v022_g_skip_top_lines,
 };
 
 static struct v4l2_subdev_ops mt9v022_subdev_ops = {
        .core   = &mt9v022_subdev_core_ops,
        .video  = &mt9v022_subdev_video_ops,
+       .sensor = &mt9v022_subdev_sensor_ops,
 };
 
 static int mt9v022_probe(struct i2c_client *client,
@@ -851,8 +912,7 @@ static int mt9v022_probe(struct i2c_client *client,
         * MT9V022 _really_ corrupts the first read out line.
         * TODO: verify on i.MX31
         */
-       icd->y_skip_top         = 1;
-
+       mt9v022->y_skip_top     = 1;
        mt9v022->rect.left      = MT9V022_COLUMN_SKIP;
        mt9v022->rect.top       = MT9V022_ROW_SKIP;
        mt9v022->rect.width     = MT9V022_MAX_WIDTH;
index 72802291e81238f5f1797cd7fd6c2336255803d1..2ba14fb5b0311f0f86a42b2148b3fe30e0e7805e 100644 (file)
@@ -37,6 +37,7 @@
 #include <media/v4l2-common.h>
 #include <media/v4l2-dev.h>
 #include <media/videobuf-dma-contig.h>
+#include <media/soc_mediabus.h>
 
 #include <asm/dma.h>
 #include <asm/fiq.h>
 /* buffer for one video frame */
 struct mx1_buffer {
        /* common v4l buffer stuff -- must be first */
-       struct videobuf_buffer vb;
-       const struct soc_camera_data_format *fmt;
-       int inwork;
+       struct videobuf_buffer          vb;
+       enum v4l2_mbus_pixelcode        code;
+       int                             inwork;
 };
 
-/* i.MX1/i.MXL is only supposed to handle one camera on its Camera Sensor
+/*
+ * i.MX1/i.MXL is only supposed to handle one camera on its Camera Sensor
  * Interface. If anyone ever builds hardware to enable more than
- * one camera, they will have to modify this driver too */
+ * one camera, they will have to modify this driver too
+ */
 struct mx1_camera_dev {
        struct soc_camera_host          soc_host;
        struct soc_camera_device        *icd;
@@ -126,9 +129,13 @@ static int mx1_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
                              unsigned int *size)
 {
        struct soc_camera_device *icd = vq->priv_data;
+       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
+
+       if (bytes_per_line < 0)
+               return bytes_per_line;
 
-       *size = icd->user_width * icd->user_height *
-               ((icd->current_fmt->depth + 7) >> 3);
+       *size = bytes_per_line * icd->user_height;
 
        if (!*count)
                *count = 32;
@@ -151,8 +158,10 @@ static void free_buffer(struct videobuf_queue *vq, struct mx1_buffer *buf)
        dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
                vb, vb->baddr, vb->bsize);
 
-       /* This waits until this buffer is out of danger, i.e., until it is no
-        * longer in STATE_QUEUED or STATE_ACTIVE */
+       /*
+        * This waits until this buffer is out of danger, i.e., until it is no
+        * longer in STATE_QUEUED or STATE_ACTIVE
+        */
        videobuf_waiton(vb, 0, 0);
        videobuf_dma_contig_free(vq, vb);
 
@@ -165,6 +174,11 @@ static int mx1_videobuf_prepare(struct videobuf_queue *vq,
        struct soc_camera_device *icd = vq->priv_data;
        struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb);
        int ret;
+       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
+
+       if (bytes_per_line < 0)
+               return bytes_per_line;
 
        dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
                vb, vb->baddr, vb->bsize);
@@ -174,22 +188,24 @@ static int mx1_videobuf_prepare(struct videobuf_queue *vq,
 
        BUG_ON(NULL == icd->current_fmt);
 
-       /* I think, in buf_prepare you only have to protect global data,
-        * the actual buffer is yours */
+       /*
+        * I think, in buf_prepare you only have to protect global data,
+        * the actual buffer is yours
+        */
        buf->inwork = 1;
 
-       if (buf->fmt    != icd->current_fmt ||
+       if (buf->code   != icd->current_fmt->code ||
            vb->width   != icd->user_width ||
            vb->height  != icd->user_height ||
            vb->field   != field) {
-               buf->fmt        = icd->current_fmt;
+               buf->code       = icd->current_fmt->code;
                vb->width       = icd->user_width;
                vb->height      = icd->user_height;
                vb->field       = field;
                vb->state       = VIDEOBUF_NEEDS_INIT;
        }
 
-       vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3);
+       vb->size = bytes_per_line * vb->height;
        if (0 != vb->baddr && vb->bsize < vb->size) {
                ret = -EINVAL;
                goto out;
@@ -381,8 +397,10 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev)
 
        lcdclk = clk_get_rate(pcdev->clk);
 
-       /* We verify platform_mclk_10khz != 0, so if anyone breaks it, here
-        * they get a nice Oops */
+       /*
+        * We verify platform_mclk_10khz != 0, so if anyone breaks it, here
+        * they get a nice Oops
+        */
        div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;
 
        dev_dbg(pcdev->icd->dev.parent,
@@ -420,8 +438,10 @@ static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
        clk_disable(pcdev->clk);
 }
 
-/* The following two functions absolutely depend on the fact, that
- * there can be only one camera on i.MX1/i.MXL camera sensor interface */
+/*
+ * The following two functions absolutely depend on the fact, that
+ * there can be only one camera on i.MX1/i.MXL camera sensor interface
+ */
 static int mx1_camera_add_device(struct soc_camera_device *icd)
 {
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
@@ -487,12 +507,10 @@ static int mx1_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
 
        /* MX1 supports only 8bit buswidth */
        common_flags = soc_camera_bus_param_compatible(camera_flags,
-                                                              CSI_BUS_FLAGS);
+                                                      CSI_BUS_FLAGS);
        if (!common_flags)
                return -EINVAL;
 
-       icd->buswidth = 8;
-
        /* Make choises, based on platform choice */
        if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) &&
                (common_flags & SOCAM_VSYNC_ACTIVE_LOW)) {
@@ -545,7 +563,8 @@ static int mx1_camera_set_fmt(struct soc_camera_device *icd,
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        const struct soc_camera_format_xlate *xlate;
        struct v4l2_pix_format *pix = &f->fmt.pix;
-       int ret;
+       struct v4l2_mbus_framefmt mf;
+       int ret, buswidth;
 
        xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
        if (!xlate) {
@@ -554,12 +573,33 @@ static int mx1_camera_set_fmt(struct soc_camera_device *icd,
                return -EINVAL;
        }
 
-       ret = v4l2_subdev_call(sd, video, s_fmt, f);
-       if (!ret) {
-               icd->buswidth = xlate->buswidth;
-               icd->current_fmt = xlate->host_fmt;
+       buswidth = xlate->host_fmt->bits_per_sample;
+       if (buswidth > 8) {
+               dev_warn(icd->dev.parent,
+                        "bits-per-sample %d for format %x unsupported\n",
+                        buswidth, pix->pixelformat);
+               return -EINVAL;
        }
 
+       mf.width        = pix->width;
+       mf.height       = pix->height;
+       mf.field        = pix->field;
+       mf.colorspace   = pix->colorspace;
+       mf.code         = xlate->code;
+
+       ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
+       if (ret < 0)
+               return ret;
+
+       if (mf.code != xlate->code)
+               return -EINVAL;
+
+       pix->width              = mf.width;
+       pix->height             = mf.height;
+       pix->field              = mf.field;
+       pix->colorspace         = mf.colorspace;
+       icd->current_fmt        = xlate;
+
        return ret;
 }
 
@@ -567,10 +607,36 @@ static int mx1_camera_try_fmt(struct soc_camera_device *icd,
                              struct v4l2_format *f)
 {
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
+       const struct soc_camera_format_xlate *xlate;
+       struct v4l2_pix_format *pix = &f->fmt.pix;
+       struct v4l2_mbus_framefmt mf;
+       int ret;
        /* TODO: limit to mx1 hardware capabilities */
 
+       xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
+       if (!xlate) {
+               dev_warn(icd->dev.parent, "Format %x not found\n",
+                        pix->pixelformat);
+               return -EINVAL;
+       }
+
+       mf.width        = pix->width;
+       mf.height       = pix->height;
+       mf.field        = pix->field;
+       mf.colorspace   = pix->colorspace;
+       mf.code         = xlate->code;
+
        /* limit to sensor capabilities */
-       return v4l2_subdev_call(sd, video, try_fmt, f);
+       ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
+       if (ret < 0)
+               return ret;
+
+       pix->width      = mf.width;
+       pix->height     = mf.height;
+       pix->field      = mf.field;
+       pix->colorspace = mf.colorspace;
+
+       return 0;
 }
 
 static int mx1_camera_reqbufs(struct soc_camera_file *icf,
@@ -578,10 +644,12 @@ static int mx1_camera_reqbufs(struct soc_camera_file *icf,
 {
        int i;
 
-       /* This is for locking debugging only. I removed spinlocks and now I
+       /*
+        * This is for locking debugging only. I removed spinlocks and now I
         * check whether .prepare is ever called on a linked buffer, or whether
         * a dma IRQ can occur for an in-work or unlinked buffer. Until now
-        * it hadn't triggered */
+        * it hadn't triggered
+        */
        for (i = 0; i < p->count; i++) {
                struct mx1_buffer *buf = container_of(icf->vb_vidq.bufs[i],
                                                      struct mx1_buffer, vb);
index 7db82bdf6f31bc9421308b21872fb2da39813da0..bd297f567dc7e1caf5b01f594b633fff6eef27b0 100644 (file)
@@ -23,6 +23,7 @@
 #include <media/v4l2-dev.h>
 #include <media/videobuf-dma-contig.h>
 #include <media/soc_camera.h>
+#include <media/soc_mediabus.h>
 
 #include <mach/ipu.h>
 #include <mach/mx3_camera.h>
@@ -63,7 +64,7 @@
 struct mx3_camera_buffer {
        /* common v4l buffer stuff -- must be first */
        struct videobuf_buffer                  vb;
-       const struct soc_camera_data_format     *fmt;
+       enum v4l2_mbus_pixelcode                code;
 
        /* One descriptot per scatterlist (per frame) */
        struct dma_async_tx_descriptor          *txd;
@@ -118,8 +119,6 @@ struct dma_chan_request {
        enum ipu_channel        id;
 };
 
-static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt);
-
 static u32 csi_reg_read(struct mx3_camera_dev *mx3, off_t reg)
 {
        return __raw_readl(mx3->base + reg);
@@ -211,17 +210,16 @@ static int mx3_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
        struct soc_camera_device *icd = vq->priv_data;
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct mx3_camera_dev *mx3_cam = ici->priv;
-       /*
-        * bits-per-pixel (depth) as specified in camera's pixel format does
-        * not necessarily match what the camera interface writes to RAM, but
-        * it should be good enough for now.
-        */
-       unsigned int bpp = DIV_ROUND_UP(icd->current_fmt->depth, 8);
+       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
+
+       if (bytes_per_line < 0)
+               return bytes_per_line;
 
        if (!mx3_cam->idmac_channel[0])
                return -EINVAL;
 
-       *size = icd->user_width * icd->user_height * bpp;
+       *size = bytes_per_line * icd->user_height;
 
        if (!*count)
                *count = 32;
@@ -241,21 +239,26 @@ static int mx3_videobuf_prepare(struct videobuf_queue *vq,
        struct mx3_camera_dev *mx3_cam = ici->priv;
        struct mx3_camera_buffer *buf =
                container_of(vb, struct mx3_camera_buffer, vb);
-       /* current_fmt _must_ always be set */
-       size_t new_size = icd->user_width * icd->user_height *
-               ((icd->current_fmt->depth + 7) >> 3);
+       size_t new_size;
        int ret;
+       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
+
+       if (bytes_per_line < 0)
+               return bytes_per_line;
+
+       new_size = bytes_per_line * icd->user_height;
 
        /*
         * I think, in buf_prepare you only have to protect global data,
         * the actual buffer is yours
         */
 
-       if (buf->fmt    != icd->current_fmt ||
+       if (buf->code   != icd->current_fmt->code ||
            vb->width   != icd->user_width ||
            vb->height  != icd->user_height ||
            vb->field   != field) {
-               buf->fmt        = icd->current_fmt;
+               buf->code       = icd->current_fmt->code;
                vb->width       = icd->user_width;
                vb->height      = icd->user_height;
                vb->field       = field;
@@ -348,13 +351,13 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq,
        struct dma_async_tx_descriptor *txd = buf->txd;
        struct idmac_channel *ichan = to_idmac_chan(txd->chan);
        struct idmac_video_param *video = &ichan->params.video;
-       const struct soc_camera_data_format *data_fmt = icd->current_fmt;
        dma_cookie_t cookie;
+       u32 fourcc = icd->current_fmt->host_fmt->fourcc;
 
        BUG_ON(!irqs_disabled());
 
        /* This is the configuration of one sg-element */
-       video->out_pixel_fmt    = fourcc_to_ipu_pix(data_fmt->fourcc);
+       video->out_pixel_fmt    = fourcc_to_ipu_pix(fourcc);
        video->out_width        = icd->user_width;
        video->out_height       = icd->user_height;
        video->out_stride       = icd->user_width;
@@ -564,30 +567,37 @@ static int test_platform_param(struct mx3_camera_dev *mx3_cam,
                SOCAM_DATA_ACTIVE_HIGH |
                SOCAM_DATA_ACTIVE_LOW;
 
-       /* If requested data width is supported by the platform, use it or any
-        * possible lower value - i.MX31 is smart enough to schift bits */
+       /*
+        * If requested data width is supported by the platform, use it or any
+        * possible lower value - i.MX31 is smart enough to schift bits
+        */
+       if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_15)
+               *flags |= SOCAM_DATAWIDTH_15 | SOCAM_DATAWIDTH_10 |
+                       SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_4;
+       else if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_10)
+               *flags |= SOCAM_DATAWIDTH_10 | SOCAM_DATAWIDTH_8 |
+                       SOCAM_DATAWIDTH_4;
+       else if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_8)
+               *flags |= SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_4;
+       else if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_4)
+               *flags |= SOCAM_DATAWIDTH_4;
+
        switch (buswidth) {
        case 15:
-               if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_15))
+               if (!(*flags & SOCAM_DATAWIDTH_15))
                        return -EINVAL;
-               *flags |= SOCAM_DATAWIDTH_15 | SOCAM_DATAWIDTH_10 |
-                       SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_4;
                break;
        case 10:
-               if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_10))
+               if (!(*flags & SOCAM_DATAWIDTH_10))
                        return -EINVAL;
-               *flags |= SOCAM_DATAWIDTH_10 | SOCAM_DATAWIDTH_8 |
-                       SOCAM_DATAWIDTH_4;
                break;
        case 8:
-               if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_8))
+               if (!(*flags & SOCAM_DATAWIDTH_8))
                        return -EINVAL;
-               *flags |= SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_4;
                break;
        case 4:
-               if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_4))
+               if (!(*flags & SOCAM_DATAWIDTH_4))
                        return -EINVAL;
-               *flags |= SOCAM_DATAWIDTH_4;
                break;
        default:
                dev_warn(mx3_cam->soc_host.v4l2_dev.dev,
@@ -636,91 +646,92 @@ static bool chan_filter(struct dma_chan *chan, void *arg)
                pdata->dma_dev == chan->device->dev;
 }
 
-static const struct soc_camera_data_format mx3_camera_formats[] = {
+static const struct soc_mbus_pixelfmt mx3_camera_formats[] = {
        {
-               .name           = "Bayer (sRGB) 8 bit",
-               .depth          = 8,
-               .fourcc         = V4L2_PIX_FMT_SBGGR8,
-               .colorspace     = V4L2_COLORSPACE_SRGB,
+               .fourcc                 = V4L2_PIX_FMT_SBGGR8,
+               .name                   = "Bayer BGGR (sRGB) 8 bit",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
        }, {
-               .name           = "Monochrome 8 bit",
-               .depth          = 8,
-               .fourcc         = V4L2_PIX_FMT_GREY,
-               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .fourcc                 = V4L2_PIX_FMT_GREY,
+               .name                   = "Monochrome 8 bit",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
        },
 };
 
-static bool buswidth_supported(struct soc_camera_host *ici, int depth)
+/* This will be corrected as we get more formats */
+static bool mx3_camera_packing_supported(const struct soc_mbus_pixelfmt *fmt)
 {
-       struct mx3_camera_dev *mx3_cam = ici->priv;
-
-       switch (depth) {
-       case 4:
-               return !!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_4);
-       case 8:
-               return !!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_8);
-       case 10:
-               return !!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_10);
-       case 15:
-               return !!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_15);
-       }
-       return false;
+       return  fmt->packing == SOC_MBUS_PACKING_NONE ||
+               (fmt->bits_per_sample == 8 &&
+                fmt->packing == SOC_MBUS_PACKING_2X8_PADHI) ||
+               (fmt->bits_per_sample > 8 &&
+                fmt->packing == SOC_MBUS_PACKING_EXTEND16);
 }
 
 static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
                                  struct soc_camera_format_xlate *xlate)
 {
-       struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
-       int formats = 0, buswidth, ret;
+       struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
+       struct device *dev = icd->dev.parent;
+       int formats = 0, ret;
+       enum v4l2_mbus_pixelcode code;
+       const struct soc_mbus_pixelfmt *fmt;
 
-       buswidth = icd->formats[idx].depth;
+       ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code);
+       if (ret < 0)
+               /* No more formats */
+               return 0;
 
-       if (!buswidth_supported(ici, buswidth))
+       fmt = soc_mbus_get_fmtdesc(code);
+       if (!fmt) {
+               dev_err(icd->dev.parent,
+                       "Invalid format code #%d: %d\n", idx, code);
                return 0;
+       }
 
-       ret = mx3_camera_try_bus_param(icd, buswidth);
+       /* This also checks support for the requested bits-per-sample */
+       ret = mx3_camera_try_bus_param(icd, fmt->bits_per_sample);
        if (ret < 0)
                return 0;
 
-       switch (icd->formats[idx].fourcc) {
-       case V4L2_PIX_FMT_SGRBG10:
+       switch (code) {
+       case V4L2_MBUS_FMT_SBGGR10_1X10:
                formats++;
                if (xlate) {
-                       xlate->host_fmt = &mx3_camera_formats[0];
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = buswidth;
+                       xlate->host_fmt = &mx3_camera_formats[0];
+                       xlate->code     = code;
                        xlate++;
-                       dev_dbg(icd->dev.parent,
-                               "Providing format %s using %s\n",
-                               mx3_camera_formats[0].name,
-                               icd->formats[idx].name);
+                       dev_dbg(dev, "Providing format %s using code %d\n",
+                               mx3_camera_formats[0].name, code);
                }
-               goto passthrough;
-       case V4L2_PIX_FMT_Y16:
+               break;
+       case V4L2_MBUS_FMT_Y10_1X10:
                formats++;
                if (xlate) {
-                       xlate->host_fmt = &mx3_camera_formats[1];
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = buswidth;
+                       xlate->host_fmt = &mx3_camera_formats[1];
+                       xlate->code     = code;
                        xlate++;
-                       dev_dbg(icd->dev.parent,
-                               "Providing format %s using %s\n",
-                               mx3_camera_formats[0].name,
-                               icd->formats[idx].name);
+                       dev_dbg(dev, "Providing format %s using code %d\n",
+                               mx3_camera_formats[1].name, code);
                }
+               break;
        default:
-passthrough:
-               /* Generic pass-through */
-               formats++;
-               if (xlate) {
-                       xlate->host_fmt = icd->formats + idx;
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = buswidth;
-                       xlate++;
-                       dev_dbg(icd->dev.parent,
-                               "Providing format %s in pass-through mode\n",
-                               icd->formats[idx].name);
-               }
+               if (!mx3_camera_packing_supported(fmt))
+                       return 0;
+       }
+
+       /* Generic pass-through */
+       formats++;
+       if (xlate) {
+               xlate->host_fmt = fmt;
+               xlate->code     = code;
+               xlate++;
+               dev_dbg(dev, "Providing format %x in pass-through mode\n",
+                       xlate->host_fmt->fourcc);
        }
 
        return formats;
@@ -804,8 +815,7 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct mx3_camera_dev *mx3_cam = ici->priv;
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-       struct v4l2_format f = {.type = V4L2_BUF_TYPE_VIDEO_CAPTURE};
-       struct v4l2_pix_format *pix = &f.fmt.pix;
+       struct v4l2_mbus_framefmt mf;
        int ret;
 
        soc_camera_limit_side(&rect->left, &rect->width, 0, 2, 4096);
@@ -816,19 +826,19 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
                return ret;
 
        /* The capture device might have changed its output  */
-       ret = v4l2_subdev_call(sd, video, g_fmt, &f);
+       ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
        if (ret < 0)
                return ret;
 
-       if (pix->width & 7) {
+       if (mf.width & 7) {
                /* Ouch! We can only handle 8-byte aligned width... */
-               stride_align(&pix->width);
-               ret = v4l2_subdev_call(sd, video, s_fmt, &f);
+               stride_align(&mf.width);
+               ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
                if (ret < 0)
                        return ret;
        }
 
-       if (pix->width != icd->user_width || pix->height != icd->user_height) {
+       if (mf.width != icd->user_width || mf.height != icd->user_height) {
                /*
                 * We now know pixel formats and can decide upon DMA-channel(s)
                 * So far only direct camera-to-memory is supported
@@ -839,14 +849,14 @@ static int mx3_camera_set_crop(struct soc_camera_device *icd,
                                return ret;
                }
 
-               configure_geometry(mx3_cam, pix->width, pix->height);
+               configure_geometry(mx3_cam, mf.width, mf.height);
        }
 
        dev_dbg(icd->dev.parent, "Sensor cropped %dx%d\n",
-               pix->width, pix->height);
+               mf.width, mf.height);
 
-       icd->user_width = pix->width;
-       icd->user_height = pix->height;
+       icd->user_width         = mf.width;
+       icd->user_height        = mf.height;
 
        return ret;
 }
@@ -859,6 +869,7 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        const struct soc_camera_format_xlate *xlate;
        struct v4l2_pix_format *pix = &f->fmt.pix;
+       struct v4l2_mbus_framefmt mf;
        int ret;
 
        xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
@@ -883,11 +894,24 @@ static int mx3_camera_set_fmt(struct soc_camera_device *icd,
 
        configure_geometry(mx3_cam, pix->width, pix->height);
 
-       ret = v4l2_subdev_call(sd, video, s_fmt, f);
-       if (!ret) {
-               icd->buswidth = xlate->buswidth;
-               icd->current_fmt = xlate->host_fmt;
-       }
+       mf.width        = pix->width;
+       mf.height       = pix->height;
+       mf.field        = pix->field;
+       mf.colorspace   = pix->colorspace;
+       mf.code         = xlate->code;
+
+       ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
+       if (ret < 0)
+               return ret;
+
+       if (mf.code != xlate->code)
+               return -EINVAL;
+
+       pix->width              = mf.width;
+       pix->height             = mf.height;
+       pix->field              = mf.field;
+       pix->colorspace         = mf.colorspace;
+       icd->current_fmt        = xlate;
 
        dev_dbg(icd->dev.parent, "Sensor set %dx%d\n", pix->width, pix->height);
 
@@ -900,8 +924,8 @@ static int mx3_camera_try_fmt(struct soc_camera_device *icd,
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        const struct soc_camera_format_xlate *xlate;
        struct v4l2_pix_format *pix = &f->fmt.pix;
+       struct v4l2_mbus_framefmt mf;
        __u32 pixfmt = pix->pixelformat;
-       enum v4l2_field field;
        int ret;
 
        xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
@@ -916,23 +940,37 @@ static int mx3_camera_try_fmt(struct soc_camera_device *icd,
        if (pix->width > 4096)
                pix->width = 4096;
 
-       pix->bytesperline = pix->width *
-               DIV_ROUND_UP(xlate->host_fmt->depth, 8);
+       pix->bytesperline = soc_mbus_bytes_per_line(pix->width,
+                                                   xlate->host_fmt);
+       if (pix->bytesperline < 0)
+               return pix->bytesperline;
        pix->sizeimage = pix->height * pix->bytesperline;
 
-       /* camera has to see its format, but the user the original one */
-       pix->pixelformat = xlate->cam_fmt->fourcc;
        /* limit to sensor capabilities */
-       ret = v4l2_subdev_call(sd, video, try_fmt, f);
-       pix->pixelformat = xlate->host_fmt->fourcc;
+       mf.width        = pix->width;
+       mf.height       = pix->height;
+       mf.field        = pix->field;
+       mf.colorspace   = pix->colorspace;
+       mf.code         = xlate->code;
+
+       ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
+       if (ret < 0)
+               return ret;
 
-       field = pix->field;
+       pix->width      = mf.width;
+       pix->height     = mf.height;
+       pix->colorspace = mf.colorspace;
 
-       if (field == V4L2_FIELD_ANY) {
+       switch (mf.field) {
+       case V4L2_FIELD_ANY:
                pix->field = V4L2_FIELD_NONE;
-       } else if (field != V4L2_FIELD_NONE) {
-               dev_err(icd->dev.parent, "Field type %d unsupported.\n", field);
-               return -EINVAL;
+               break;
+       case V4L2_FIELD_NONE:
+               break;
+       default:
+               dev_err(icd->dev.parent, "Field type %d unsupported.\n",
+                       mf.field);
+               ret = -EINVAL;
        }
 
        return ret;
@@ -968,18 +1006,26 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
        struct mx3_camera_dev *mx3_cam = ici->priv;
        unsigned long bus_flags, camera_flags, common_flags;
        u32 dw, sens_conf;
-       int ret = test_platform_param(mx3_cam, icd->buswidth, &bus_flags);
+       const struct soc_mbus_pixelfmt *fmt;
+       int buswidth;
+       int ret;
        const struct soc_camera_format_xlate *xlate;
        struct device *dev = icd->dev.parent;
 
+       fmt = soc_mbus_get_fmtdesc(icd->current_fmt->code);
+       if (!fmt)
+               return -EINVAL;
+
+       buswidth = fmt->bits_per_sample;
+       ret = test_platform_param(mx3_cam, buswidth, &bus_flags);
+
        xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
        if (!xlate) {
                dev_warn(dev, "Format %x not found\n", pixfmt);
                return -EINVAL;
        }
 
-       dev_dbg(dev, "requested bus width %d bit: %d\n",
-               icd->buswidth, ret);
+       dev_dbg(dev, "requested bus width %d bit: %d\n", buswidth, ret);
 
        if (ret < 0)
                return ret;
@@ -1027,8 +1073,10 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
                        common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING;
        }
 
-       /* Make the camera work in widest common mode, we'll take care of
-        * the rest */
+       /*
+        * Make the camera work in widest common mode, we'll take care of
+        * the rest
+        */
        if (common_flags & SOCAM_DATAWIDTH_15)
                common_flags = (common_flags & ~SOCAM_DATAWIDTH_MASK) |
                        SOCAM_DATAWIDTH_15;
@@ -1078,7 +1126,7 @@ static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
                sens_conf |= 1 << CSI_SENS_CONF_DATA_POL_SHIFT;
 
        /* Just do what we're asked to do */
-       switch (xlate->host_fmt->depth) {
+       switch (xlate->host_fmt->bits_per_sample) {
        case 4:
                dw = 0 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
                break;
@@ -1152,8 +1200,10 @@ static int __devinit mx3_camera_probe(struct platform_device *pdev)
        if (!(mx3_cam->platform_flags & (MX3_CAMERA_DATAWIDTH_4 |
                        MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10 |
                        MX3_CAMERA_DATAWIDTH_15))) {
-               /* Platform hasn't set available data widths. This is bad.
-                * Warn and use a default. */
+               /*
+                * Platform hasn't set available data widths. This is bad.
+                * Warn and use a default.
+                */
                dev_warn(&pdev->dev, "WARNING! Platform hasn't set available "
                         "data widths, using default 8 bit\n");
                mx3_cam->platform_flags |= MX3_CAMERA_DATAWIDTH_8;
index 5fc4ac0d88f042beb8e4cddf8a8180f90a777266..7400eacb4d64bf48cb4c475fcd3a83d519734abf 100644 (file)
@@ -1450,12 +1450,11 @@ static int omap24xxcam_mmap(struct file *file, struct vm_area_struct *vma)
 
 static int omap24xxcam_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
        struct omap24xxcam_device *cam = omap24xxcam.priv;
        struct omap24xxcam_fh *fh;
        struct v4l2_format format;
 
-       if (!cam || !cam->vfd || (cam->vfd->minor != minor))
+       if (!cam || !cam->vfd)
                return -ENODEV;
 
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
@@ -1660,7 +1659,6 @@ static int omap24xxcam_device_register(struct v4l2_int_device *s)
 
        strlcpy(vfd->name, CAM_NAME, sizeof(vfd->name));
        vfd->fops                = &omap24xxcam_fops;
-       vfd->minor               = -1;
        vfd->ioctl_ops           = &omap24xxcam_ioctl_fops;
 
        omap24xxcam_hwinit(cam);
@@ -1671,14 +1669,14 @@ static int omap24xxcam_device_register(struct v4l2_int_device *s)
 
        if (video_register_device(vfd, VFL_TYPE_GRABBER, video_nr) < 0) {
                dev_err(cam->dev, "could not register V4L device\n");
-               vfd->minor = -1;
                rval = -EBUSY;
                goto err;
        }
 
        omap24xxcam_poweron_reset(cam);
 
-       dev_info(cam->dev, "registered device video%d\n", vfd->minor);
+       dev_info(cam->dev, "registered device %s\n",
+                video_device_node_name(vfd));
 
        return 0;
 
@@ -1695,7 +1693,7 @@ static void omap24xxcam_device_unregister(struct v4l2_int_device *s)
        omap24xxcam_sensor_exit(cam);
 
        if (cam->vfd) {
-               if (cam->vfd->minor == -1) {
+               if (!video_is_registered(cam->vfd)) {
                        /*
                         * The device was never registered, so release the
                         * video_device struct directly.
index 0bc2cf573c764a0aedde5e0353d43cbc8c75176f..e0bce8dc74bf40f9147f005da042724704992531 100644 (file)
@@ -4674,7 +4674,6 @@ static struct video_device vdev_template = {
        .name =         "OV511 USB Camera",
        .fops =         &ov511_fops,
        .release =      video_device_release,
-       .minor =        -1,
 };
 
 /****************************************************************************
@@ -5867,8 +5866,8 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
        ov511_devused |= 1 << nr;
        ov->nr = nr;
 
-       dev_info(&intf->dev, "Device at %s registered to minor %d\n",
-                ov->usb_path, ov->vdev->minor);
+       dev_info(&intf->dev, "Device at %s registered to %s\n",
+                ov->usb_path, video_device_node_name(ov->vdev));
 
        usb_set_intfdata(intf, ov);
        if (ov_create_sysfs(ov->vdev)) {
@@ -5878,13 +5877,13 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
                goto error;
        }
 
-       mutex_lock(&ov->lock);
+       mutex_unlock(&ov->lock);
 
        return 0;
 
 error:
        if (ov->vdev) {
-               if (-1 == ov->vdev->minor)
+               if (!video_is_registered(ov->vdev))
                        video_device_release(ov->vdev);
                else
                        video_unregister_device(ov->vdev);
index 205229333466da471f743d9cf6858711e9437def..3a45e945a528c6fdf63b3c4c72626493f6ab5a4b 100644 (file)
@@ -24,6 +24,7 @@
 #include <media/v4l2-chip-ident.h>
 #include <media/v4l2-subdev.h>
 #include <media/soc_camera.h>
+#include <media/soc_mediabus.h>
 #include <media/ov772x.h>
 
 /*
@@ -382,7 +383,8 @@ struct regval_list {
 };
 
 struct ov772x_color_format {
-       const struct soc_camera_data_format *format;
+       enum v4l2_mbus_pixelcode code;
+       enum v4l2_colorspace colorspace;
        u8 dsp3;
        u8 com3;
        u8 com7;
@@ -399,7 +401,7 @@ struct ov772x_win_size {
 struct ov772x_priv {
        struct v4l2_subdev                subdev;
        struct ov772x_camera_info        *info;
-       const struct ov772x_color_format *fmt;
+       const struct ov772x_color_format *cfmt;
        const struct ov772x_win_size     *win;
        int                               model;
        unsigned short                    flag_vflip:1;
@@ -434,93 +436,57 @@ static const struct regval_list ov772x_vga_regs[] = {
 };
 
 /*
- * supported format list
- */
-
-#define SETFOURCC(type) .name = (#type), .fourcc = (V4L2_PIX_FMT_ ## type)
-static const struct soc_camera_data_format ov772x_fmt_lists[] = {
-       {
-               SETFOURCC(YUYV),
-               .depth      = 16,
-               .colorspace = V4L2_COLORSPACE_JPEG,
-       },
-       {
-               SETFOURCC(YVYU),
-               .depth      = 16,
-               .colorspace = V4L2_COLORSPACE_JPEG,
-       },
-       {
-               SETFOURCC(UYVY),
-               .depth      = 16,
-               .colorspace = V4L2_COLORSPACE_JPEG,
-       },
-       {
-               SETFOURCC(RGB555),
-               .depth      = 16,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-       },
-       {
-               SETFOURCC(RGB555X),
-               .depth      = 16,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-       },
-       {
-               SETFOURCC(RGB565),
-               .depth      = 16,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-       },
-       {
-               SETFOURCC(RGB565X),
-               .depth      = 16,
-               .colorspace = V4L2_COLORSPACE_SRGB,
-       },
-};
-
-/*
- * color format list
+ * supported color format list
  */
 static const struct ov772x_color_format ov772x_cfmts[] = {
        {
-               .format = &ov772x_fmt_lists[0],
-               .dsp3   = 0x0,
-               .com3   = SWAP_YUV,
-               .com7   = OFMT_YUV,
+               .code           = V4L2_MBUS_FMT_YUYV8_2X8_LE,
+               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .dsp3           = 0x0,
+               .com3           = SWAP_YUV,
+               .com7           = OFMT_YUV,
        },
        {
-               .format = &ov772x_fmt_lists[1],
-               .dsp3   = UV_ON,
-               .com3   = SWAP_YUV,
-               .com7   = OFMT_YUV,
+               .code           = V4L2_MBUS_FMT_YVYU8_2X8_LE,
+               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .dsp3           = UV_ON,
+               .com3           = SWAP_YUV,
+               .com7           = OFMT_YUV,
        },
        {
-               .format = &ov772x_fmt_lists[2],
-               .dsp3   = 0x0,
-               .com3   = 0x0,
-               .com7   = OFMT_YUV,
+               .code           = V4L2_MBUS_FMT_YUYV8_2X8_BE,
+               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .dsp3           = 0x0,
+               .com3           = 0x0,
+               .com7           = OFMT_YUV,
        },
        {
-               .format = &ov772x_fmt_lists[3],
-               .dsp3   = 0x0,
-               .com3   = SWAP_RGB,
-               .com7   = FMT_RGB555 | OFMT_RGB,
+               .code           = V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
+               .colorspace     = V4L2_COLORSPACE_SRGB,
+               .dsp3           = 0x0,
+               .com3           = SWAP_RGB,
+               .com7           = FMT_RGB555 | OFMT_RGB,
        },
        {
-               .format = &ov772x_fmt_lists[4],
-               .dsp3   = 0x0,
-               .com3   = 0x0,
-               .com7   = FMT_RGB555 | OFMT_RGB,
+               .code           = V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE,
+               .colorspace     = V4L2_COLORSPACE_SRGB,
+               .dsp3           = 0x0,
+               .com3           = 0x0,
+               .com7           = FMT_RGB555 | OFMT_RGB,
        },
        {
-               .format = &ov772x_fmt_lists[5],
-               .dsp3   = 0x0,
-               .com3   = SWAP_RGB,
-               .com7   = FMT_RGB565 | OFMT_RGB,
+               .code           = V4L2_MBUS_FMT_RGB565_2X8_LE,
+               .colorspace     = V4L2_COLORSPACE_SRGB,
+               .dsp3           = 0x0,
+               .com3           = SWAP_RGB,
+               .com7           = FMT_RGB565 | OFMT_RGB,
        },
        {
-               .format = &ov772x_fmt_lists[6],
-               .dsp3   = 0x0,
-               .com3   = 0x0,
-               .com7   = FMT_RGB565 | OFMT_RGB,
+               .code           = V4L2_MBUS_FMT_RGB565_2X8_BE,
+               .colorspace     = V4L2_COLORSPACE_SRGB,
+               .dsp3           = 0x0,
+               .com3           = 0x0,
+               .com7           = FMT_RGB565 | OFMT_RGB,
        },
 };
 
@@ -642,15 +608,15 @@ static int ov772x_s_stream(struct v4l2_subdev *sd, int enable)
                return 0;
        }
 
-       if (!priv->win || !priv->fmt) {
+       if (!priv->win || !priv->cfmt) {
                dev_err(&client->dev, "norm or win select error\n");
                return -EPERM;
        }
 
        ov772x_mask_set(client, COM2, SOFT_SLEEP_MODE, 0);
 
-       dev_dbg(&client->dev, "format %s, win %s\n",
-               priv->fmt->format->name, priv->win->name);
+       dev_dbg(&client->dev, "format %d, win %s\n",
+               priv->cfmt->code, priv->win->name);
 
        return 0;
 }
@@ -806,8 +772,8 @@ static const struct ov772x_win_size *ov772x_select_win(u32 width, u32 height)
        return win;
 }
 
-static int ov772x_set_params(struct i2c_client *client,
-                            u32 *width, u32 *height, u32 pixfmt)
+static int ov772x_set_params(struct i2c_client *client, u32 *width, u32 *height,
+                            enum v4l2_mbus_pixelcode code)
 {
        struct ov772x_priv *priv = to_ov772x(client);
        int ret = -EINVAL;
@@ -817,14 +783,14 @@ static int ov772x_set_params(struct i2c_client *client,
        /*
         * select format
         */
-       priv->fmt = NULL;
+       priv->cfmt = NULL;
        for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++) {
-               if (pixfmt == ov772x_cfmts[i].format->fourcc) {
-                       priv->fmt = ov772x_cfmts + i;
+               if (code == ov772x_cfmts[i].code) {
+                       priv->cfmt = ov772x_cfmts + i;
                        break;
                }
        }
-       if (!priv->fmt)
+       if (!priv->cfmt)
                goto ov772x_set_fmt_error;
 
        /*
@@ -894,7 +860,7 @@ static int ov772x_set_params(struct i2c_client *client,
        /*
         * set DSP_CTRL3
         */
-       val = priv->fmt->dsp3;
+       val = priv->cfmt->dsp3;
        if (val) {
                ret = ov772x_mask_set(client,
                                      DSP_CTRL3, UV_MASK, val);
@@ -905,7 +871,7 @@ static int ov772x_set_params(struct i2c_client *client,
        /*
         * set COM3
         */
-       val = priv->fmt->com3;
+       val = priv->cfmt->com3;
        if (priv->info->flags & OV772X_FLAG_VFLIP)
                val |= VFLIP_IMG;
        if (priv->info->flags & OV772X_FLAG_HFLIP)
@@ -923,9 +889,9 @@ static int ov772x_set_params(struct i2c_client *client,
        /*
         * set COM7
         */
-       val = priv->win->com7_bit | priv->fmt->com7;
+       val = priv->win->com7_bit | priv->cfmt->com7;
        ret = ov772x_mask_set(client,
-                             COM7, (SLCT_MASK | FMT_MASK | OFMT_MASK),
+                             COM7, SLCT_MASK | FMT_MASK | OFMT_MASK,
                              val);
        if (ret < 0)
                goto ov772x_set_fmt_error;
@@ -951,7 +917,7 @@ ov772x_set_fmt_error:
 
        ov772x_reset(client);
        priv->win = NULL;
-       priv->fmt = NULL;
+       priv->cfmt = NULL;
 
        return ret;
 }
@@ -981,54 +947,79 @@ static int ov772x_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
-static int ov772x_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int ov772x_g_fmt(struct v4l2_subdev *sd,
+                       struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct ov772x_priv *priv = to_ov772x(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       if (!priv->win || !priv->fmt) {
+       if (!priv->win || !priv->cfmt) {
                u32 width = VGA_WIDTH, height = VGA_HEIGHT;
                int ret = ov772x_set_params(client, &width, &height,
-                                           V4L2_PIX_FMT_YUYV);
+                                           V4L2_MBUS_FMT_YUYV8_2X8_LE);
                if (ret < 0)
                        return ret;
        }
 
-       f->type                 = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
-       pix->width              = priv->win->width;
-       pix->height             = priv->win->height;
-       pix->pixelformat        = priv->fmt->format->fourcc;
-       pix->colorspace         = priv->fmt->format->colorspace;
-       pix->field              = V4L2_FIELD_NONE;
+       mf->width       = priv->win->width;
+       mf->height      = priv->win->height;
+       mf->code        = priv->cfmt->code;
+       mf->colorspace  = priv->cfmt->colorspace;
+       mf->field       = V4L2_FIELD_NONE;
 
        return 0;
 }
 
-static int ov772x_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int ov772x_s_fmt(struct v4l2_subdev *sd,
+                       struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
-       struct v4l2_pix_format *pix = &f->fmt.pix;
+       struct ov772x_priv *priv = to_ov772x(client);
+       int ret = ov772x_set_params(client, &mf->width, &mf->height,
+                                   mf->code);
+
+       if (!ret)
+               mf->colorspace = priv->cfmt->colorspace;
 
-       return ov772x_set_params(client, &pix->width, &pix->height,
-                                pix->pixelformat);
+       return ret;
 }
 
 static int ov772x_try_fmt(struct v4l2_subdev *sd,
-                         struct v4l2_format *f)
+                         struct v4l2_mbus_framefmt *mf)
 {
-       struct v4l2_pix_format *pix = &f->fmt.pix;
+       struct i2c_client *client = sd->priv;
+       struct ov772x_priv *priv = to_ov772x(client);
        const struct ov772x_win_size *win;
+       int i;
 
        /*
         * select suitable win
         */
-       win = ov772x_select_win(pix->width, pix->height);
+       win = ov772x_select_win(mf->width, mf->height);
+
+       mf->width       = win->width;
+       mf->height      = win->height;
+       mf->field       = V4L2_FIELD_NONE;
 
-       pix->width  = win->width;
-       pix->height = win->height;
-       pix->field  = V4L2_FIELD_NONE;
+       for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++)
+               if (mf->code == ov772x_cfmts[i].code)
+                       break;
+
+       if (i == ARRAY_SIZE(ov772x_cfmts)) {
+               /* Unsupported format requested. Propose either */
+               if (priv->cfmt) {
+                       /* the current one or */
+                       mf->colorspace = priv->cfmt->colorspace;
+                       mf->code = priv->cfmt->code;
+               } else {
+                       /* the default one */
+                       mf->colorspace = ov772x_cfmts[0].colorspace;
+                       mf->code = ov772x_cfmts[0].code;
+               }
+       } else {
+               /* Also return the colorspace */
+               mf->colorspace  = ov772x_cfmts[i].colorspace;
+       }
 
        return 0;
 }
@@ -1057,9 +1048,6 @@ static int ov772x_video_probe(struct soc_camera_device *icd,
                return -ENODEV;
        }
 
-       icd->formats     = ov772x_fmt_lists;
-       icd->num_formats = ARRAY_SIZE(ov772x_fmt_lists);
-
        /*
         * check and show product ID and manufacturer ID
         */
@@ -1109,13 +1097,24 @@ static struct v4l2_subdev_core_ops ov772x_subdev_core_ops = {
 #endif
 };
 
+static int ov772x_enum_fmt(struct v4l2_subdev *sd, int index,
+                          enum v4l2_mbus_pixelcode *code)
+{
+       if ((unsigned int)index >= ARRAY_SIZE(ov772x_cfmts))
+               return -EINVAL;
+
+       *code = ov772x_cfmts[index].code;
+       return 0;
+}
+
 static struct v4l2_subdev_video_ops ov772x_subdev_video_ops = {
        .s_stream       = ov772x_s_stream,
-       .g_fmt          = ov772x_g_fmt,
-       .s_fmt          = ov772x_s_fmt,
-       .try_fmt        = ov772x_try_fmt,
+       .g_mbus_fmt     = ov772x_g_fmt,
+       .s_mbus_fmt     = ov772x_s_fmt,
+       .try_mbus_fmt   = ov772x_try_fmt,
        .cropcap        = ov772x_cropcap,
        .g_crop         = ov772x_g_crop,
+       .enum_mbus_fmt  = ov772x_enum_fmt,
 };
 
 static struct v4l2_subdev_ops ov772x_subdev_ops = {
@@ -1143,10 +1142,10 @@ static int ov772x_probe(struct i2c_client *client,
        }
 
        icl = to_soc_camera_link(icd);
-       if (!icl)
+       if (!icl || !icl->priv)
                return -EINVAL;
 
-       info = container_of(icl, struct ov772x_camera_info, link);
+       info = icl->priv;
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
                dev_err(&adapter->dev,
index c81ae219288742813e8ff208266141db85a6885b..47bf60ceb7a26feaee7afa23b2ec4d916e39defd 100644 (file)
@@ -154,19 +154,10 @@ static const struct ov9640_reg ov9640_regs_rgb[] = {
        { OV9640_MTXS,  0x65 },
 };
 
-/*
- * TODO: this sensor also supports RGB555 and RGB565 formats, but support for
- * them has not yet been sufficiently tested and so it is not included with
- * this version of the driver. To test and debug these formats add two entries
- * to the below array, see ov722x.c for an example.
- */
-static const struct soc_camera_data_format ov9640_fmt_lists[] = {
-       {
-               .name           = "UYVY",
-               .fourcc         = V4L2_PIX_FMT_UYVY,
-               .depth          = 16,
-               .colorspace     = V4L2_COLORSPACE_JPEG,
-       },
+static enum v4l2_mbus_pixelcode ov9640_codes[] = {
+       V4L2_MBUS_FMT_YUYV8_2X8_BE,
+       V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
+       V4L2_MBUS_FMT_RGB565_2X8_LE,
 };
 
 static const struct v4l2_queryctrl ov9640_controls[] = {
@@ -434,20 +425,22 @@ static void ov9640_res_roundup(u32 *width, u32 *height)
 }
 
 /* Prepare necessary register changes depending on color encoding */
-static void ov9640_alter_regs(u32 pixfmt, struct ov9640_reg_alt *alt)
+static void ov9640_alter_regs(enum v4l2_mbus_pixelcode code,
+                             struct ov9640_reg_alt *alt)
 {
-       switch (pixfmt) {
-       case V4L2_PIX_FMT_UYVY:
+       switch (code) {
+       default:
+       case V4L2_MBUS_FMT_YUYV8_2X8_BE:
                alt->com12      = OV9640_COM12_YUV_AVG;
                alt->com13      = OV9640_COM13_Y_DELAY_EN |
                                        OV9640_COM13_YUV_DLY(0x01);
                break;
-       case V4L2_PIX_FMT_RGB555:
+       case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
                alt->com7       = OV9640_COM7_RGB;
                alt->com13      = OV9640_COM13_RGB_AVG;
                alt->com15      = OV9640_COM15_RGB_555;
                break;
-       case V4L2_PIX_FMT_RGB565:
+       case V4L2_MBUS_FMT_RGB565_2X8_LE:
                alt->com7       = OV9640_COM7_RGB;
                alt->com13      = OV9640_COM13_RGB_AVG;
                alt->com15      = OV9640_COM15_RGB_565;
@@ -456,8 +449,8 @@ static void ov9640_alter_regs(u32 pixfmt, struct ov9640_reg_alt *alt)
 }
 
 /* Setup registers according to resolution and color encoding */
-static int ov9640_write_regs(struct i2c_client *client,
-               u32 width, u32 pixfmt, struct ov9640_reg_alt *alts)
+static int ov9640_write_regs(struct i2c_client *client, u32 width,
+               enum v4l2_mbus_pixelcode code, struct ov9640_reg_alt *alts)
 {
        const struct ov9640_reg *ov9640_regs, *matrix_regs;
        int                     ov9640_regs_len, matrix_regs_len;
@@ -500,7 +493,7 @@ static int ov9640_write_regs(struct i2c_client *client,
        }
 
        /* select color matrix configuration for given color encoding */
-       if (pixfmt == V4L2_PIX_FMT_UYVY) {
+       if (code == V4L2_MBUS_FMT_YUYV8_2X8_BE) {
                matrix_regs     = ov9640_regs_yuv;
                matrix_regs_len = ARRAY_SIZE(ov9640_regs_yuv);
        } else {
@@ -562,15 +555,17 @@ static int ov9640_prog_dflt(struct i2c_client *client)
 }
 
 /* set the format we will capture in */
-static int ov9640_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int ov9640_s_fmt(struct v4l2_subdev *sd,
+                       struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
-       struct v4l2_pix_format *pix = &f->fmt.pix;
        struct ov9640_reg_alt alts = {0};
+       enum v4l2_colorspace cspace;
+       enum v4l2_mbus_pixelcode code = mf->code;
        int ret;
 
-       ov9640_res_roundup(&pix->width, &pix->height);
-       ov9640_alter_regs(pix->pixelformat, &alts);
+       ov9640_res_roundup(&mf->width, &mf->height);
+       ov9640_alter_regs(mf->code, &alts);
 
        ov9640_reset(client);
 
@@ -578,19 +573,57 @@ static int ov9640_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
        if (ret)
                return ret;
 
-       return ov9640_write_regs(client, pix->width, pix->pixelformat, &alts);
+       switch (code) {
+       case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+       case V4L2_MBUS_FMT_RGB565_2X8_LE:
+               cspace = V4L2_COLORSPACE_SRGB;
+               break;
+       default:
+               code = V4L2_MBUS_FMT_YUYV8_2X8_BE;
+       case V4L2_MBUS_FMT_YUYV8_2X8_BE:
+               cspace = V4L2_COLORSPACE_JPEG;
+       }
+
+       ret = ov9640_write_regs(client, mf->width, code, &alts);
+       if (!ret) {
+               mf->code        = code;
+               mf->colorspace  = cspace;
+       }
+
+       return ret;
 }
 
-static int ov9640_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int ov9640_try_fmt(struct v4l2_subdev *sd,
+                         struct v4l2_mbus_framefmt *mf)
 {
-       struct v4l2_pix_format *pix = &f->fmt.pix;
+       ov9640_res_roundup(&mf->width, &mf->height);
 
-       ov9640_res_roundup(&pix->width, &pix->height);
-       pix->field  = V4L2_FIELD_NONE;
+       mf->field = V4L2_FIELD_NONE;
+
+       switch (mf->code) {
+       case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+       case V4L2_MBUS_FMT_RGB565_2X8_LE:
+               mf->colorspace = V4L2_COLORSPACE_SRGB;
+               break;
+       default:
+               mf->code = V4L2_MBUS_FMT_YUYV8_2X8_BE;
+       case V4L2_MBUS_FMT_YUYV8_2X8_BE:
+               mf->colorspace = V4L2_COLORSPACE_JPEG;
+       }
 
        return 0;
 }
 
+static int ov9640_enum_fmt(struct v4l2_subdev *sd, int index,
+                          enum v4l2_mbus_pixelcode *code)
+{
+       if ((unsigned int)index >= ARRAY_SIZE(ov9640_codes))
+               return -EINVAL;
+
+       *code = ov9640_codes[index];
+       return 0;
+}
+
 static int ov9640_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
 {
        a->c.left       = 0;
@@ -637,9 +670,6 @@ static int ov9640_video_probe(struct soc_camera_device *icd,
                goto err;
        }
 
-       icd->formats            = ov9640_fmt_lists;
-       icd->num_formats        = ARRAY_SIZE(ov9640_fmt_lists);
-
        /*
         * check and show product ID and manufacturer ID
         */
@@ -702,11 +732,12 @@ static struct v4l2_subdev_core_ops ov9640_core_ops = {
 };
 
 static struct v4l2_subdev_video_ops ov9640_video_ops = {
-       .s_stream               = ov9640_s_stream,
-       .s_fmt                  = ov9640_s_fmt,
-       .try_fmt                = ov9640_try_fmt,
-       .cropcap                = ov9640_cropcap,
-       .g_crop                 = ov9640_g_crop,
+       .s_stream       = ov9640_s_stream,
+       .s_mbus_fmt     = ov9640_s_fmt,
+       .try_mbus_fmt   = ov9640_try_fmt,
+       .enum_mbus_fmt  = ov9640_enum_fmt,
+       .cropcap        = ov9640_cropcap,
+       .g_crop         = ov9640_g_crop,
 
 };
 
index 73ec970ca5ca0a53c34f6ad933f021570a2d5b55..11a2c26399b53d846945a2afdbc74033a063fc97 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/init.h>
 #include <linux/version.h>
 #include <linux/mutex.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <asm/io.h>
 
 #include <linux/videodev2.h>
index 6aa48e0ae7312cb0324844099175bc8dc001fc9e..cc8ddb2d2382902bb8e67194e3b79dfeaad0a65c 100644 (file)
@@ -151,17 +151,6 @@ static struct v4l2_format pvr_format [] = {
 };
 
 
-static const char *get_v4l_name(int v4l_type)
-{
-       switch (v4l_type) {
-       case VFL_TYPE_GRABBER: return "video";
-       case VFL_TYPE_RADIO: return "radio";
-       case VFL_TYPE_VBI: return "vbi";
-       default: return "?";
-       }
-}
-
-
 /*
  * pvr_ioctl()
  *
@@ -891,10 +880,8 @@ static long pvr2_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 
 static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
 {
-       int num = dip->devbase.num;
        struct pvr2_hdw *hdw = dip->v4lp->channel.mc_head->hdw;
        enum pvr2_config cfg = dip->config;
-       int v4l_type = dip->v4l_type;
 
        pvr2_hdw_v4l_store_minor_number(hdw,dip->minor_type,-1);
 
@@ -906,8 +893,8 @@ static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
           are gone. */
        video_unregister_device(&dip->devbase);
 
-       printk(KERN_INFO "pvrusb2: unregistered device %s%u [%s]\n",
-              get_v4l_name(v4l_type), num,
+       printk(KERN_INFO "pvrusb2: unregistered device %s [%s]\n",
+              video_device_node_name(&dip->devbase),
               pvr2_config_get_name(cfg));
 
 }
@@ -1317,8 +1304,8 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
                        ": Failed to register pvrusb2 v4l device\n");
        }
 
-       printk(KERN_INFO "pvrusb2: registered device %s%u [%s]\n",
-              get_v4l_name(dip->v4l_type), dip->devbase.num,
+       printk(KERN_INFO "pvrusb2: registered device %s [%s]\n",
+              video_device_node_name(&dip->devbase),
               pvr2_config_get_name(dip->config));
 
        pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
index 89b620f6db7b41d8cc44ba901090b6cef666304a..aea7e224cef6bebff3fe4b17c7e24dac7e9c4afd 100644 (file)
@@ -169,7 +169,6 @@ static struct video_device pwc_template = {
        .name =         "Philips Webcam",       /* Filled in later */
        .release =      video_device_release,
        .fops =         &pwc_fops,
-       .minor =        -1,
 };
 
 /***************************************************************************/
@@ -1807,7 +1806,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
                goto err_video_release;
        }
 
-       PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->num);
+       PWC_INFO("Registered as %s.\n", video_device_node_name(pdev->vdev));
 
        /* occupy slot */
        if (hint < MAX_DEV_HINTS)
@@ -1948,7 +1947,9 @@ MODULE_PARM_DESC(size, "Initial image size. One of sqcif, qsif, qcif, sif, cif,
 MODULE_PARM_DESC(fps, "Initial frames per second. Varies with model, useful range 5-30");
 MODULE_PARM_DESC(fbufs, "Number of internal frame buffers to reserve");
 MODULE_PARM_DESC(mbufs, "Number of external (mmap()ed) image buffers");
+#ifdef CONFIG_USB_PWC_DEBUG
 MODULE_PARM_DESC(trace, "For debugging purposes");
+#endif
 MODULE_PARM_DESC(power_save, "Turn power save feature in camera on or off");
 MODULE_PARM_DESC(compression, "Preferred compression quality. Range 0 (uncompressed) to 3 (high compression)");
 MODULE_PARM_DESC(leds, "LED on,off time in milliseconds");
index 51b683c63b70b54bafad3c9f43e583b76b686a49..294f860ce2b068f13ba502fc17c1b6b05b9b6dfc 100644 (file)
@@ -32,6 +32,7 @@
 #include <media/v4l2-dev.h>
 #include <media/videobuf-dma-sg.h>
 #include <media/soc_camera.h>
+#include <media/soc_mediabus.h>
 
 #include <linux/videodev2.h>
 
@@ -183,23 +184,21 @@ struct pxa_cam_dma {
 /* buffer for one video frame */
 struct pxa_buffer {
        /* common v4l buffer stuff -- must be first */
-       struct videobuf_buffer vb;
-
-       const struct soc_camera_data_format        *fmt;
-
+       struct videobuf_buffer          vb;
+       enum v4l2_mbus_pixelcode        code;
        /* our descriptor lists for Y, U and V channels */
-       struct pxa_cam_dma dmas[3];
-
-       int                     inwork;
-
-       enum pxa_camera_active_dma active_dma;
+       struct pxa_cam_dma              dmas[3];
+       int                             inwork;
+       enum pxa_camera_active_dma      active_dma;
 };
 
 struct pxa_camera_dev {
        struct soc_camera_host  soc_host;
-       /* PXA27x is only supposed to handle one camera on its Quick Capture
+       /*
+        * PXA27x is only supposed to handle one camera on its Quick Capture
         * interface. If anyone ever builds hardware to enable more than
-        * one camera, they will have to modify this driver too */
+        * one camera, they will have to modify this driver too
+        */
        struct soc_camera_device *icd;
        struct clk              *clk;
 
@@ -241,11 +240,15 @@ static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
                              unsigned int *size)
 {
        struct soc_camera_device *icd = vq->priv_data;
+       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
+
+       if (bytes_per_line < 0)
+               return bytes_per_line;
 
        dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size);
 
-       *size = roundup(icd->user_width * icd->user_height *
-                       ((icd->current_fmt->depth + 7) >> 3), 8);
+       *size = bytes_per_line * icd->user_height;
 
        if (0 == *count)
                *count = 32;
@@ -267,8 +270,10 @@ static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
        dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
                &buf->vb, buf->vb.baddr, buf->vb.bsize);
 
-       /* This waits until this buffer is out of danger, i.e., until it is no
-        * longer in STATE_QUEUED or STATE_ACTIVE */
+       /*
+        * This waits until this buffer is out of danger, i.e., until it is no
+        * longer in STATE_QUEUED or STATE_ACTIVE
+        */
        videobuf_waiton(&buf->vb, 0, 0);
        videobuf_dma_unmap(vq, dma);
        videobuf_dma_free(dma);
@@ -429,6 +434,11 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
        struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb);
        int ret;
        int size_y, size_u = 0, size_v = 0;
+       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
+
+       if (bytes_per_line < 0)
+               return bytes_per_line;
 
        dev_dbg(dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
                vb, vb->baddr, vb->bsize);
@@ -437,29 +447,33 @@ static int pxa_videobuf_prepare(struct videobuf_queue *vq,
        WARN_ON(!list_empty(&vb->queue));
 
 #ifdef DEBUG
-       /* This can be useful if you want to see if we actually fill
-        * the buffer with something */
+       /*
+        * This can be useful if you want to see if we actually fill
+        * the buffer with something
+        */
        memset((void *)vb->baddr, 0xaa, vb->bsize);
 #endif
 
        BUG_ON(NULL == icd->current_fmt);
 
-       /* I think, in buf_prepare you only have to protect global data,
-        * the actual buffer is yours */
+       /*
+        * I think, in buf_prepare you only have to protect global data,
+        * the actual buffer is yours
+        */
        buf->inwork = 1;
 
-       if (buf->fmt    != icd->current_fmt ||
+       if (buf->code   != icd->current_fmt->code ||
            vb->width   != icd->user_width ||
            vb->height  != icd->user_height ||
            vb->field   != field) {
-               buf->fmt        = icd->current_fmt;
+               buf->code       = icd->current_fmt->code;
                vb->width       = icd->user_width;
                vb->height      = icd->user_height;
                vb->field       = field;
                vb->state       = VIDEOBUF_NEEDS_INIT;
        }
 
-       vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3);
+       vb->size = bytes_per_line * vb->height;
        if (0 != vb->baddr && vb->bsize < vb->size) {
                ret = -EINVAL;
                goto out;
@@ -834,8 +848,10 @@ static void pxa_camera_init_videobuf(struct videobuf_queue *q,
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct pxa_camera_dev *pcdev = ici->priv;
 
-       /* We must pass NULL as dev pointer, then all pci_* dma operations
-        * transform to normal dma_* ones. */
+       /*
+        * We must pass NULL as dev pointer, then all pci_* dma operations
+        * transform to normal dma_* ones.
+        */
        videobuf_queue_sg_init(q, &pxa_videobuf_ops, NULL, &pcdev->lock,
                                V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE,
                                sizeof(struct pxa_buffer), icd);
@@ -1051,11 +1067,18 @@ static void pxa_camera_setup_cicr(struct soc_camera_device *icd,
 {
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct pxa_camera_dev *pcdev = ici->priv;
+       struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        unsigned long dw, bpp;
-       u32 cicr0, cicr1, cicr2, cicr3, cicr4 = 0;
+       u32 cicr0, cicr1, cicr2, cicr3, cicr4 = 0, y_skip_top;
+       int ret = v4l2_subdev_call(sd, sensor, g_skip_top_lines, &y_skip_top);
+
+       if (ret < 0)
+               y_skip_top = 0;
 
-       /* Datawidth is now guaranteed to be equal to one of the three values.
-        * We fix bit-per-pixel equal to data-width... */
+       /*
+        * Datawidth is now guaranteed to be equal to one of the three values.
+        * We fix bit-per-pixel equal to data-width...
+        */
        switch (flags & SOCAM_DATAWIDTH_MASK) {
        case SOCAM_DATAWIDTH_10:
                dw = 4;
@@ -1066,8 +1089,10 @@ static void pxa_camera_setup_cicr(struct soc_camera_device *icd,
                bpp = 0x20;
                break;
        default:
-               /* Actually it can only be 8 now,
-                * default is just to silence compiler warnings */
+               /*
+                * Actually it can only be 8 now,
+                * default is just to silence compiler warnings
+                */
        case SOCAM_DATAWIDTH_8:
                dw = 2;
                bpp = 0;
@@ -1118,7 +1143,7 @@ static void pxa_camera_setup_cicr(struct soc_camera_device *icd,
 
        cicr2 = 0;
        cicr3 = CICR3_LPF_VAL(icd->user_height - 1) |
-               CICR3_BFW_VAL(min((unsigned short)255, icd->y_skip_top));
+               CICR3_BFW_VAL(min((u32)255, y_skip_top));
        cicr4 |= pcdev->mclk_divisor;
 
        __raw_writel(cicr1, pcdev->base + CICR1);
@@ -1138,9 +1163,15 @@ static int pxa_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct pxa_camera_dev *pcdev = ici->priv;
        unsigned long bus_flags, camera_flags, common_flags;
-       int ret = test_platform_param(pcdev, icd->buswidth, &bus_flags);
+       const struct soc_mbus_pixelfmt *fmt;
+       int ret;
        struct pxa_cam *cam = icd->host_priv;
 
+       fmt = soc_mbus_get_fmtdesc(icd->current_fmt->code);
+       if (!fmt)
+               return -EINVAL;
+
+       ret = test_platform_param(pcdev, fmt->bits_per_sample, &bus_flags);
        if (ret < 0)
                return ret;
 
@@ -1204,59 +1235,49 @@ static int pxa_camera_try_bus_param(struct soc_camera_device *icd,
        return soc_camera_bus_param_compatible(camera_flags, bus_flags) ? 0 : -EINVAL;
 }
 
-static const struct soc_camera_data_format pxa_camera_formats[] = {
+static const struct soc_mbus_pixelfmt pxa_camera_formats[] = {
        {
-               .name           = "Planar YUV422 16 bit",
-               .depth          = 16,
-               .fourcc         = V4L2_PIX_FMT_YUV422P,
-               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .fourcc                 = V4L2_PIX_FMT_YUV422P,
+               .name                   = "Planar YUV422 16 bit",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
        },
 };
 
-static bool buswidth_supported(struct soc_camera_device *icd, int depth)
+/* This will be corrected as we get more formats */
+static bool pxa_camera_packing_supported(const struct soc_mbus_pixelfmt *fmt)
 {
-       struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
-       struct pxa_camera_dev *pcdev = ici->priv;
-
-       switch (depth) {
-       case 8:
-               return !!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8);
-       case 9:
-               return !!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9);
-       case 10:
-               return !!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10);
-       }
-       return false;
-}
-
-static int required_buswidth(const struct soc_camera_data_format *fmt)
-{
-       switch (fmt->fourcc) {
-       case V4L2_PIX_FMT_UYVY:
-       case V4L2_PIX_FMT_VYUY:
-       case V4L2_PIX_FMT_YUYV:
-       case V4L2_PIX_FMT_YVYU:
-       case V4L2_PIX_FMT_RGB565:
-       case V4L2_PIX_FMT_RGB555:
-               return 8;
-       default:
-               return fmt->depth;
-       }
+       return  fmt->packing == SOC_MBUS_PACKING_NONE ||
+               (fmt->bits_per_sample == 8 &&
+                fmt->packing == SOC_MBUS_PACKING_2X8_PADHI) ||
+               (fmt->bits_per_sample > 8 &&
+                fmt->packing == SOC_MBUS_PACKING_EXTEND16);
 }
 
 static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx,
                                  struct soc_camera_format_xlate *xlate)
 {
+       struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        struct device *dev = icd->dev.parent;
-       int formats = 0, buswidth, ret;
+       int formats = 0, ret;
        struct pxa_cam *cam;
+       enum v4l2_mbus_pixelcode code;
+       const struct soc_mbus_pixelfmt *fmt;
 
-       buswidth = required_buswidth(icd->formats + idx);
+       ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code);
+       if (ret < 0)
+               /* No more formats */
+               return 0;
 
-       if (!buswidth_supported(icd, buswidth))
+       fmt = soc_mbus_get_fmtdesc(code);
+       if (!fmt) {
+               dev_err(dev, "Invalid format code #%d: %d\n", idx, code);
                return 0;
+       }
 
-       ret = pxa_camera_try_bus_param(icd, buswidth);
+       /* This also checks support for the requested bits-per-sample */
+       ret = pxa_camera_try_bus_param(icd, fmt->bits_per_sample);
        if (ret < 0)
                return 0;
 
@@ -1270,45 +1291,40 @@ static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx,
                cam = icd->host_priv;
        }
 
-       switch (icd->formats[idx].fourcc) {
-       case V4L2_PIX_FMT_UYVY:
+       switch (code) {
+       case V4L2_MBUS_FMT_YUYV8_2X8_BE:
                formats++;
                if (xlate) {
-                       xlate->host_fmt = &pxa_camera_formats[0];
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = buswidth;
+                       xlate->host_fmt = &pxa_camera_formats[0];
+                       xlate->code     = code;
                        xlate++;
-                       dev_dbg(dev, "Providing format %s using %s\n",
-                               pxa_camera_formats[0].name,
-                               icd->formats[idx].name);
+                       dev_dbg(dev, "Providing format %s using code %d\n",
+                               pxa_camera_formats[0].name, code);
                }
-       case V4L2_PIX_FMT_VYUY:
-       case V4L2_PIX_FMT_YUYV:
-       case V4L2_PIX_FMT_YVYU:
-       case V4L2_PIX_FMT_RGB565:
-       case V4L2_PIX_FMT_RGB555:
-               formats++;
-               if (xlate) {
-                       xlate->host_fmt = icd->formats + idx;
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = buswidth;
-                       xlate++;
+       case V4L2_MBUS_FMT_YVYU8_2X8_BE:
+       case V4L2_MBUS_FMT_YUYV8_2X8_LE:
+       case V4L2_MBUS_FMT_YVYU8_2X8_LE:
+       case V4L2_MBUS_FMT_RGB565_2X8_LE:
+       case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE:
+               if (xlate)
                        dev_dbg(dev, "Providing format %s packed\n",
-                               icd->formats[idx].name);
-               }
+                               fmt->name);
                break;
        default:
-               /* Generic pass-through */
-               formats++;
-               if (xlate) {
-                       xlate->host_fmt = icd->formats + idx;
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = icd->formats[idx].depth;
-                       xlate++;
+               if (!pxa_camera_packing_supported(fmt))
+                       return 0;
+               if (xlate)
                        dev_dbg(dev,
                                "Providing format %s in pass-through mode\n",
-                               icd->formats[idx].name);
-               }
+                               fmt->name);
+       }
+
+       /* Generic pass-through */
+       formats++;
+       if (xlate) {
+               xlate->host_fmt = fmt;
+               xlate->code     = code;
+               xlate++;
        }
 
        return formats;
@@ -1320,11 +1336,11 @@ static void pxa_camera_put_formats(struct soc_camera_device *icd)
        icd->host_priv = NULL;
 }
 
-static int pxa_camera_check_frame(struct v4l2_pix_format *pix)
+static int pxa_camera_check_frame(u32 width, u32 height)
 {
        /* limit to pxa hardware capabilities */
-       return pix->height < 32 || pix->height > 2048 || pix->width < 48 ||
-               pix->width > 2048 || (pix->width & 0x01);
+       return height < 32 || height > 2048 || width < 48 || width > 2048 ||
+               (width & 0x01);
 }
 
 static int pxa_camera_set_crop(struct soc_camera_device *icd,
@@ -1339,9 +1355,9 @@ static int pxa_camera_set_crop(struct soc_camera_device *icd,
                .master_clock = pcdev->mclk,
                .pixel_clock_max = pcdev->ciclk / 4,
        };
-       struct v4l2_format f;
-       struct v4l2_pix_format *pix = &f.fmt.pix, pix_tmp;
+       struct v4l2_mbus_framefmt mf;
        struct pxa_cam *cam = icd->host_priv;
+       u32 fourcc = icd->current_fmt->host_fmt->fourcc;
        int ret;
 
        /* If PCLK is used to latch data from the sensor, check sense */
@@ -1358,27 +1374,23 @@ static int pxa_camera_set_crop(struct soc_camera_device *icd,
                return ret;
        }
 
-       f.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
-       ret = v4l2_subdev_call(sd, video, g_fmt, &f);
+       ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
        if (ret < 0)
                return ret;
 
-       pix_tmp = *pix;
-       if (pxa_camera_check_frame(pix)) {
+       if (pxa_camera_check_frame(mf.width, mf.height)) {
                /*
                 * Camera cropping produced a frame beyond our capabilities.
                 * FIXME: just extract a subframe, that we can process.
                 */
-               v4l_bound_align_image(&pix->width, 48, 2048, 1,
-                       &pix->height, 32, 2048, 0,
-                       icd->current_fmt->fourcc == V4L2_PIX_FMT_YUV422P ?
-                               4 : 0);
-               ret = v4l2_subdev_call(sd, video, s_fmt, &f);
+               v4l_bound_align_image(&mf.width, 48, 2048, 1,
+                       &mf.height, 32, 2048, 0,
+                       fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
+               ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
                if (ret < 0)
                        return ret;
 
-               if (pxa_camera_check_frame(pix)) {
+               if (pxa_camera_check_frame(mf.width, mf.height)) {
                        dev_warn(icd->dev.parent,
                                 "Inconsistent state. Use S_FMT to repair\n");
                        return -EINVAL;
@@ -1395,10 +1407,10 @@ static int pxa_camera_set_crop(struct soc_camera_device *icd,
                recalculate_fifo_timeout(pcdev, sense.pixel_clock);
        }
 
-       icd->user_width = pix->width;
-       icd->user_height = pix->height;
+       icd->user_width         = mf.width;
+       icd->user_height        = mf.height;
 
-       pxa_camera_setup_cicr(icd, cam->flags, icd->current_fmt->fourcc);
+       pxa_camera_setup_cicr(icd, cam->flags, fourcc);
 
        return ret;
 }
@@ -1410,14 +1422,13 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
        struct pxa_camera_dev *pcdev = ici->priv;
        struct device *dev = icd->dev.parent;
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
-       const struct soc_camera_data_format *cam_fmt = NULL;
        const struct soc_camera_format_xlate *xlate = NULL;
        struct soc_camera_sense sense = {
                .master_clock = pcdev->mclk,
                .pixel_clock_max = pcdev->ciclk / 4,
        };
        struct v4l2_pix_format *pix = &f->fmt.pix;
-       struct v4l2_format cam_f = *f;
+       struct v4l2_mbus_framefmt mf;
        int ret;
 
        xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
@@ -1426,26 +1437,31 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
                return -EINVAL;
        }
 
-       cam_fmt = xlate->cam_fmt;
-
        /* If PCLK is used to latch data from the sensor, check sense */
        if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
+               /* The caller holds a mutex. */
                icd->sense = &sense;
 
-       cam_f.fmt.pix.pixelformat = cam_fmt->fourcc;
-       ret = v4l2_subdev_call(sd, video, s_fmt, &cam_f);
-       cam_f.fmt.pix.pixelformat = pix->pixelformat;
-       *pix = cam_f.fmt.pix;
+       mf.width        = pix->width;
+       mf.height       = pix->height;
+       mf.field        = pix->field;
+       mf.colorspace   = pix->colorspace;
+       mf.code         = xlate->code;
+
+       ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
+
+       if (mf.code != xlate->code)
+               return -EINVAL;
 
        icd->sense = NULL;
 
        if (ret < 0) {
                dev_warn(dev, "Failed to configure for format %x\n",
                         pix->pixelformat);
-       } else if (pxa_camera_check_frame(pix)) {
+       } else if (pxa_camera_check_frame(mf.width, mf.height)) {
                dev_warn(dev,
                         "Camera driver produced an unsupported frame %dx%d\n",
-                        pix->width, pix->height);
+                        mf.width, mf.height);
                ret = -EINVAL;
        } else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
                if (sense.pixel_clock > sense.pixel_clock_max) {
@@ -1457,10 +1473,14 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
                recalculate_fifo_timeout(pcdev, sense.pixel_clock);
        }
 
-       if (!ret) {
-               icd->buswidth = xlate->buswidth;
-               icd->current_fmt = xlate->host_fmt;
-       }
+       if (ret < 0)
+               return ret;
+
+       pix->width              = mf.width;
+       pix->height             = mf.height;
+       pix->field              = mf.field;
+       pix->colorspace         = mf.colorspace;
+       icd->current_fmt        = xlate;
 
        return ret;
 }
@@ -1468,17 +1488,16 @@ static int pxa_camera_set_fmt(struct soc_camera_device *icd,
 static int pxa_camera_try_fmt(struct soc_camera_device *icd,
                              struct v4l2_format *f)
 {
-       struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        const struct soc_camera_format_xlate *xlate;
        struct v4l2_pix_format *pix = &f->fmt.pix;
+       struct v4l2_mbus_framefmt mf;
        __u32 pixfmt = pix->pixelformat;
-       enum v4l2_field field;
        int ret;
 
        xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
        if (!xlate) {
-               dev_warn(ici->v4l2_dev.dev, "Format %x not found\n", pixfmt);
+               dev_warn(icd->dev.parent, "Format %x not found\n", pixfmt);
                return -EINVAL;
        }
 
@@ -1492,22 +1511,36 @@ static int pxa_camera_try_fmt(struct soc_camera_device *icd,
                              &pix->height, 32, 2048, 0,
                              pixfmt == V4L2_PIX_FMT_YUV422P ? 4 : 0);
 
-       pix->bytesperline = pix->width *
-               DIV_ROUND_UP(xlate->host_fmt->depth, 8);
+       pix->bytesperline = soc_mbus_bytes_per_line(pix->width,
+                                                   xlate->host_fmt);
+       if (pix->bytesperline < 0)
+               return pix->bytesperline;
        pix->sizeimage = pix->height * pix->bytesperline;
 
-       /* camera has to see its format, but the user the original one */
-       pix->pixelformat = xlate->cam_fmt->fourcc;
        /* limit to sensor capabilities */
-       ret = v4l2_subdev_call(sd, video, try_fmt, f);
-       pix->pixelformat = pixfmt;
+       mf.width        = pix->width;
+       mf.height       = pix->height;
+       mf.field        = pix->field;
+       mf.colorspace   = pix->colorspace;
+       mf.code         = xlate->code;
 
-       field = pix->field;
+       ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
+       if (ret < 0)
+               return ret;
 
-       if (field == V4L2_FIELD_ANY) {
-               pix->field = V4L2_FIELD_NONE;
-       } else if (field != V4L2_FIELD_NONE) {
-               dev_err(icd->dev.parent, "Field type %d unsupported.\n", field);
+       pix->width      = mf.width;
+       pix->height     = mf.height;
+       pix->colorspace = mf.colorspace;
+
+       switch (mf.field) {
+       case V4L2_FIELD_ANY:
+       case V4L2_FIELD_NONE:
+               pix->field      = V4L2_FIELD_NONE;
+               break;
+       default:
+               /* TODO: support interlaced at least in pass-through mode */
+               dev_err(icd->dev.parent, "Field type %d unsupported.\n",
+                       mf.field);
                return -EINVAL;
        }
 
@@ -1519,10 +1552,12 @@ static int pxa_camera_reqbufs(struct soc_camera_file *icf,
 {
        int i;
 
-       /* This is for locking debugging only. I removed spinlocks and now I
+       /*
+        * This is for locking debugging only. I removed spinlocks and now I
         * check whether .prepare is ever called on a linked buffer, or whether
         * a dma IRQ can occur for an in-work or unlinked buffer. Until now
-        * it hadn't triggered */
+        * it hadn't triggered
+        */
        for (i = 0; i < p->count; i++) {
                struct pxa_buffer *buf = container_of(icf->vb_vidq.bufs[i],
                                                      struct pxa_buffer, vb);
@@ -1657,8 +1692,10 @@ static int __devinit pxa_camera_probe(struct platform_device *pdev)
        pcdev->platform_flags = pcdev->pdata->flags;
        if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 |
                        PXA_CAMERA_DATAWIDTH_9 | PXA_CAMERA_DATAWIDTH_10))) {
-               /* Platform hasn't set available data widths. This is bad.
-                * Warn and use a default. */
+               /*
+                * Platform hasn't set available data widths. This is bad.
+                * Warn and use a default.
+                */
                dev_warn(&pdev->dev, "WARNING! Platform hasn't set available "
                         "data widths, using default 10 bit\n");
                pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10;
index 373f2a30a677b52bd42f0f873f11dd8fee8da9c3..7e42989ce0e47b8155260c3705ecb58cb21f6604 100644 (file)
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 
+#include <media/rj54n1cb0c.h>
+#include <media/soc_camera.h>
+#include <media/soc_mediabus.h>
 #include <media/v4l2-subdev.h>
 #include <media/v4l2-chip-ident.h>
-#include <media/soc_camera.h>
 
 #define RJ54N1_DEV_CODE                        0x0400
 #define RJ54N1_DEV_CODE2               0x0401
@@ -38,6 +40,7 @@
 #define RJ54N1_H_OBEN_OFS              0x0413
 #define RJ54N1_V_OBEN_OFS              0x0414
 #define RJ54N1_RESIZE_CONTROL          0x0415
+#define RJ54N1_STILL_CONTROL           0x0417
 #define RJ54N1_INC_USE_SEL_H           0x0425
 #define RJ54N1_INC_USE_SEL_L           0x0426
 #define RJ54N1_MIRROR_STILL_MODE       0x0427
 #define RJ54N1_RA_SEL_UL               0x0530
 #define RJ54N1_BYTE_SWAP               0x0531
 #define RJ54N1_OUT_SIGPO               0x053b
+#define RJ54N1_WB_SEL_WEIGHT_I         0x054e
+#define RJ54N1_BIT8_WB                 0x0569
+#define RJ54N1_HCAPS_WB                        0x056a
+#define RJ54N1_VCAPS_WB                        0x056b
+#define RJ54N1_HCAPE_WB                        0x056c
+#define RJ54N1_VCAPE_WB                        0x056d
+#define RJ54N1_EXPOSURE_CONTROL                0x058c
 #define RJ54N1_FRAME_LENGTH_S_H                0x0595
 #define RJ54N1_FRAME_LENGTH_S_L                0x0596
 #define RJ54N1_FRAME_LENGTH_P_H                0x0597
 #define RJ54N1_FRAME_LENGTH_P_L                0x0598
+#define RJ54N1_PEAK_H                  0x05b7
+#define RJ54N1_PEAK_50                 0x05b8
+#define RJ54N1_PEAK_60                 0x05b9
+#define RJ54N1_PEAK_DIFF               0x05ba
 #define RJ54N1_IOC                     0x05ef
 #define RJ54N1_TG_BYPASS               0x0700
 #define RJ54N1_PLL_L                   0x0701
@@ -68,6 +82,7 @@
 #define RJ54N1_OCLK_SEL_EN             0x0713
 #define RJ54N1_CLK_RST                 0x0717
 #define RJ54N1_RESET_STANDBY           0x0718
+#define RJ54N1_FWFLG                   0x07fe
 
 #define E_EXCLK                                (1 << 7)
 #define SOFT_STDBY                     (1 << 4)
 #define RESIZE_HOLD_SEL                        (1 << 2)
 #define RESIZE_GO                      (1 << 1)
 
+/*
+ * When cropping, the camera automatically centers the cropped region, there
+ * doesn't seem to be a way to specify an explicit location of the rectangle.
+ */
 #define RJ54N1_COLUMN_SKIP             0
 #define RJ54N1_ROW_SKIP                        0
 #define RJ54N1_MAX_WIDTH               1600
 #define RJ54N1_MAX_HEIGHT              1200
 
+#define PLL_L                          2
+#define PLL_N                          0x31
+
 /* I2C addresses: 0x50, 0x51, 0x60, 0x61 */
 
-static const struct soc_camera_data_format rj54n1_colour_formats[] = {
-       {
-               .name           = "YUYV",
-               .depth          = 16,
-               .fourcc         = V4L2_PIX_FMT_YUYV,
-               .colorspace     = V4L2_COLORSPACE_JPEG,
-       }, {
-               .name           = "RGB565",
-               .depth          = 16,
-               .fourcc         = V4L2_PIX_FMT_RGB565,
-               .colorspace     = V4L2_COLORSPACE_SRGB,
-       }
+/* RJ54N1CB0C has only one fixed colorspace per pixelcode */
+struct rj54n1_datafmt {
+       enum v4l2_mbus_pixelcode        code;
+       enum v4l2_colorspace            colorspace;
+};
+
+/* Find a data format by a pixel code in an array */
+static const struct rj54n1_datafmt *rj54n1_find_datafmt(
+       enum v4l2_mbus_pixelcode code, const struct rj54n1_datafmt *fmt,
+       int n)
+{
+       int i;
+       for (i = 0; i < n; i++)
+               if (fmt[i].code == code)
+                       return fmt + i;
+
+       return NULL;
+}
+
+static const struct rj54n1_datafmt rj54n1_colour_fmts[] = {
+       {V4L2_MBUS_FMT_YUYV8_2X8_LE, V4L2_COLORSPACE_JPEG},
+       {V4L2_MBUS_FMT_YVYU8_2X8_LE, V4L2_COLORSPACE_JPEG},
+       {V4L2_MBUS_FMT_RGB565_2X8_LE, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_RGB565_2X8_BE, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE, V4L2_COLORSPACE_SRGB},
+       {V4L2_MBUS_FMT_SBGGR10_1X10, V4L2_COLORSPACE_SRGB},
 };
 
 struct rj54n1_clock_div {
-       u8 ratio_tg;
+       u8 ratio_tg;    /* can be 0 or an odd number */
        u8 ratio_t;
        u8 ratio_r;
        u8 ratio_op;
@@ -109,12 +148,14 @@ struct rj54n1_clock_div {
 
 struct rj54n1 {
        struct v4l2_subdev subdev;
+       struct rj54n1_clock_div clk_div;
+       const struct rj54n1_datafmt *fmt;
        struct v4l2_rect rect;  /* Sensor window */
+       unsigned int tgclk_mhz;
+       bool auto_wb;
        unsigned short width;   /* Output window */
        unsigned short height;
        unsigned short resize;  /* Sensor * 1024 / resize = Output */
-       struct rj54n1_clock_div clk_div;
-       u32 fourcc;
        unsigned short scale;
        u8 bank;
 };
@@ -171,7 +212,7 @@ const static struct rj54n1_reg_val bank_7[] = {
        {0x714, 0xff},
        {0x715, 0xff},
        {0x716, 0x1f},
-       {0x7FE, 0x02},
+       {0x7FE, 2},
 };
 
 const static struct rj54n1_reg_val bank_8[] = {
@@ -359,7 +400,7 @@ const static struct rj54n1_reg_val bank_8[] = {
        {0x8BB, 0x00},
        {0x8BC, 0xFF},
        {0x8BD, 0x00},
-       {0x8FE, 0x02},
+       {0x8FE, 2},
 };
 
 const static struct rj54n1_reg_val bank_10[] = {
@@ -440,12 +481,24 @@ static int reg_write_multiple(struct i2c_client *client,
        return 0;
 }
 
-static int rj54n1_s_stream(struct v4l2_subdev *sd, int enable)
+static int rj54n1_enum_fmt(struct v4l2_subdev *sd, int index,
+                          enum v4l2_mbus_pixelcode *code)
 {
-       /* TODO: start / stop streaming */
+       if ((unsigned int)index >= ARRAY_SIZE(rj54n1_colour_fmts))
+               return -EINVAL;
+
+       *code = rj54n1_colour_fmts[index].code;
        return 0;
 }
 
+static int rj54n1_s_stream(struct v4l2_subdev *sd, int enable)
+{
+       struct i2c_client *client = sd->priv;
+
+       /* Switch between preview and still shot modes */
+       return reg_set(client, RJ54N1_STILL_CONTROL, (!enable) << 7, 0x80);
+}
+
 static int rj54n1_set_bus_param(struct soc_camera_device *icd,
                                unsigned long flags)
 {
@@ -502,6 +555,44 @@ static int rj54n1_commit(struct i2c_client *client)
        return ret;
 }
 
+static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
+                              u32 *out_w, u32 *out_h);
+
+static int rj54n1_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
+{
+       struct i2c_client *client = sd->priv;
+       struct rj54n1 *rj54n1 = to_rj54n1(client);
+       struct v4l2_rect *rect = &a->c;
+       unsigned int dummy, output_w, output_h,
+               input_w = rect->width, input_h = rect->height;
+       int ret;
+
+       /* arbitrary minimum width and height, edges unimportant */
+       soc_camera_limit_side(&dummy, &input_w,
+                    RJ54N1_COLUMN_SKIP, 8, RJ54N1_MAX_WIDTH);
+
+       soc_camera_limit_side(&dummy, &input_h,
+                    RJ54N1_ROW_SKIP, 8, RJ54N1_MAX_HEIGHT);
+
+       output_w = (input_w * 1024 + rj54n1->resize / 2) / rj54n1->resize;
+       output_h = (input_h * 1024 + rj54n1->resize / 2) / rj54n1->resize;
+
+       dev_dbg(&client->dev, "Scaling for %ux%u : %u = %ux%u\n",
+               input_w, input_h, rj54n1->resize, output_w, output_h);
+
+       ret = rj54n1_sensor_scale(sd, &input_w, &input_h, &output_w, &output_h);
+       if (ret < 0)
+               return ret;
+
+       rj54n1->width           = output_w;
+       rj54n1->height          = output_h;
+       rj54n1->resize          = ret;
+       rj54n1->rect.width      = input_w;
+       rj54n1->rect.height     = input_h;
+
+       return 0;
+}
+
 static int rj54n1_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
 {
        struct i2c_client *client = sd->priv;
@@ -527,16 +618,17 @@ static int rj54n1_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
-static int rj54n1_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int rj54n1_g_fmt(struct v4l2_subdev *sd,
+                       struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct rj54n1 *rj54n1 = to_rj54n1(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       pix->pixelformat        = rj54n1->fourcc;
-       pix->field              = V4L2_FIELD_NONE;
-       pix->width              = rj54n1->width;
-       pix->height             = rj54n1->height;
+       mf->code        = rj54n1->fmt->code;
+       mf->colorspace  = rj54n1->fmt->colorspace;
+       mf->field       = V4L2_FIELD_NONE;
+       mf->width       = rj54n1->width;
+       mf->height      = rj54n1->height;
 
        return 0;
 }
@@ -550,11 +642,44 @@ static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
                               u32 *out_w, u32 *out_h)
 {
        struct i2c_client *client = sd->priv;
+       struct rj54n1 *rj54n1 = to_rj54n1(client);
        unsigned int skip, resize, input_w = *in_w, input_h = *in_h,
                output_w = *out_w, output_h = *out_h;
-       u16 inc_sel;
+       u16 inc_sel, wb_bit8, wb_left, wb_right, wb_top, wb_bottom;
+       unsigned int peak, peak_50, peak_60;
        int ret;
 
+       /*
+        * We have a problem with crops, where the window is larger than 512x384
+        * and output window is larger than a half of the input one. In this
+        * case we have to either reduce the input window to equal or below
+        * 512x384 or the output window to equal or below 1/2 of the input.
+        */
+       if (output_w > max(512U, input_w / 2)) {
+               if (2 * output_w > RJ54N1_MAX_WIDTH) {
+                       input_w = RJ54N1_MAX_WIDTH;
+                       output_w = RJ54N1_MAX_WIDTH / 2;
+               } else {
+                       input_w = output_w * 2;
+               }
+
+               dev_dbg(&client->dev, "Adjusted output width: in %u, out %u\n",
+                       input_w, output_w);
+       }
+
+       if (output_h > max(384U, input_h / 2)) {
+               if (2 * output_h > RJ54N1_MAX_HEIGHT) {
+                       input_h = RJ54N1_MAX_HEIGHT;
+                       output_h = RJ54N1_MAX_HEIGHT / 2;
+               } else {
+                       input_h = output_h * 2;
+               }
+
+               dev_dbg(&client->dev, "Adjusted output height: in %u, out %u\n",
+                       input_h, output_h);
+       }
+
+       /* Idea: use the read mode for snapshots, handle separate geometries */
        ret = rj54n1_set_rect(client, RJ54N1_X_OUTPUT_SIZE_S_L,
                              RJ54N1_Y_OUTPUT_SIZE_S_L,
                              RJ54N1_XY_OUTPUT_SIZE_S_H, output_w, output_h);
@@ -566,17 +691,27 @@ static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
        if (ret < 0)
                return ret;
 
-       if (output_w > input_w || output_h > input_h) {
+       if (output_w > input_w && output_h > input_h) {
                input_w = output_w;
                input_h = output_h;
 
                resize = 1024;
        } else {
                unsigned int resize_x, resize_y;
-               resize_x = input_w * 1024 / output_w;
-               resize_y = input_h * 1024 / output_h;
-
-               resize = min(resize_x, resize_y);
+               resize_x = (input_w * 1024 + output_w / 2) / output_w;
+               resize_y = (input_h * 1024 + output_h / 2) / output_h;
+
+               /* We want max(resize_x, resize_y), check if it still fits */
+               if (resize_x > resize_y &&
+                   (output_h * resize_x + 512) / 1024 > RJ54N1_MAX_HEIGHT)
+                       resize = (RJ54N1_MAX_HEIGHT * 1024 + output_h / 2) /
+                               output_h;
+               else if (resize_y > resize_x &&
+                        (output_w * resize_y + 512) / 1024 > RJ54N1_MAX_WIDTH)
+                       resize = (RJ54N1_MAX_WIDTH * 1024 + output_w / 2) /
+                               output_w;
+               else
+                       resize = max(resize_x, resize_y);
 
                /* Prohibited value ranges */
                switch (resize) {
@@ -589,12 +724,9 @@ static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
                case 8160 ... 8191:
                        resize = 8159;
                        break;
-               case 16320 ... 16383:
+               case 16320 ... 16384:
                        resize = 16319;
                }
-
-               input_w = output_w * resize / 1024;
-               input_h = output_h * resize / 1024;
        }
 
        /* Set scaling */
@@ -607,9 +739,18 @@ static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
 
        /*
         * Configure a skipping bitmask. The sensor will select a skipping value
-        * among set bits automatically.
+        * among set bits automatically. This is very unclear in the datasheet
+        * too. I was told, in this register one enables all skipping values,
+        * that are required for a specific resize, and the camera selects
+        * automatically, which ones to use. But it is unclear how to identify,
+        * which cropping values are needed. Secondly, why don't we just set all
+        * bits and let the camera choose? Would it increase processing time and
+        * reduce the framerate? Using 0xfffc for INC_USE_SEL doesn't seem to
+        * improve the image quality or stability for larger frames (see comment
+        * above), but I didn't check the framerate.
         */
        skip = min(resize / 1024, (unsigned)15);
+
        inc_sel = 1 << skip;
 
        if (inc_sel <= 2)
@@ -621,6 +762,43 @@ static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
        if (!ret)
                ret = reg_write(client, RJ54N1_INC_USE_SEL_H, inc_sel >> 8);
 
+       if (!rj54n1->auto_wb) {
+               /* Auto white balance window */
+               wb_left   = output_w / 16;
+               wb_right  = (3 * output_w / 4 - 3) / 4;
+               wb_top    = output_h / 16;
+               wb_bottom = (3 * output_h / 4 - 3) / 4;
+               wb_bit8   = ((wb_left >> 2) & 0x40) | ((wb_top >> 4) & 0x10) |
+                       ((wb_right >> 6) & 4) | ((wb_bottom >> 8) & 1);
+
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_BIT8_WB, wb_bit8);
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_HCAPS_WB, wb_left);
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_VCAPS_WB, wb_top);
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_HCAPE_WB, wb_right);
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_VCAPE_WB, wb_bottom);
+       }
+
+       /* Antiflicker */
+       peak = 12 * RJ54N1_MAX_WIDTH * (1 << 14) * resize / rj54n1->tgclk_mhz /
+               10000;
+       peak_50 = peak / 6;
+       peak_60 = peak / 5;
+
+       if (!ret)
+               ret = reg_write(client, RJ54N1_PEAK_H,
+                               ((peak_50 >> 4) & 0xf0) | (peak_60 >> 8));
+       if (!ret)
+               ret = reg_write(client, RJ54N1_PEAK_50, peak_50);
+       if (!ret)
+               ret = reg_write(client, RJ54N1_PEAK_60, peak_60);
+       if (!ret)
+               ret = reg_write(client, RJ54N1_PEAK_DIFF, peak / 150);
+
        /* Start resizing */
        if (!ret)
                ret = reg_write(client, RJ54N1_RESIZE_CONTROL,
@@ -629,8 +807,6 @@ static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
        if (ret < 0)
                return ret;
 
-       dev_dbg(&client->dev, "resize %u, skip %u\n", resize, skip);
-
        /* Constant taken from manufacturer's example */
        msleep(230);
 
@@ -638,11 +814,14 @@ static int rj54n1_sensor_scale(struct v4l2_subdev *sd, u32 *in_w, u32 *in_h,
        if (ret < 0)
                return ret;
 
-       *in_w = input_w;
-       *in_h = input_h;
+       *in_w = (output_w * resize + 512) / 1024;
+       *in_h = (output_h * resize + 512) / 1024;
        *out_w = output_w;
        *out_h = output_h;
 
+       dev_dbg(&client->dev, "Scaled for %ux%u : %u = %ux%u, skip %u\n",
+               *in_w, *in_h, resize, output_w, output_h, skip);
+
        return resize;
 }
 
@@ -653,14 +832,14 @@ static int rj54n1_set_clock(struct i2c_client *client)
 
        /* Enable external clock */
        ret = reg_write(client, RJ54N1_RESET_STANDBY, E_EXCLK | SOFT_STDBY);
-       /* Leave stand-by */
+       /* Leave stand-by. Note: use this when implementing suspend / resume */
        if (!ret)
                ret = reg_write(client, RJ54N1_RESET_STANDBY, E_EXCLK);
 
        if (!ret)
-               ret = reg_write(client, RJ54N1_PLL_L, 2);
+               ret = reg_write(client, RJ54N1_PLL_L, PLL_L);
        if (!ret)
-               ret = reg_write(client, RJ54N1_PLL_N, 0x31);
+               ret = reg_write(client, RJ54N1_PLL_N, PLL_N);
 
        /* TGCLK dividers */
        if (!ret)
@@ -719,6 +898,7 @@ static int rj54n1_set_clock(struct i2c_client *client)
                        "Resetting RJ54N1CB0C clock failed: %d!\n", ret);
                return -EIO;
        }
+
        /* Start the PLL */
        ret = reg_set(client, RJ54N1_OCLK_DSP, 1, 1);
 
@@ -731,6 +911,7 @@ static int rj54n1_set_clock(struct i2c_client *client)
 
 static int rj54n1_reg_init(struct i2c_client *client)
 {
+       struct rj54n1 *rj54n1 = to_rj54n1(client);
        int ret = rj54n1_set_clock(client);
 
        if (!ret)
@@ -753,14 +934,26 @@ static int rj54n1_reg_init(struct i2c_client *client)
        if (!ret)
                ret = reg_write(client, RJ54N1_Y_GAIN, 0x84);
 
-       /* Mirror the image back: default is upside down and left-to-right... */
+       /*
+        * Mirror the image back: default is upside down and left-to-right...
+        * Set manual preview / still shot switching
+        */
        if (!ret)
-               ret = reg_set(client, RJ54N1_MIRROR_STILL_MODE, 3, 3);
+               ret = reg_write(client, RJ54N1_MIRROR_STILL_MODE, 0x27);
 
        if (!ret)
                ret = reg_write_multiple(client, bank_4, ARRAY_SIZE(bank_4));
+
+       /* Auto exposure area */
        if (!ret)
+               ret = reg_write(client, RJ54N1_EXPOSURE_CONTROL, 0x80);
+       /* Check current auto WB config */
+       if (!ret)
+               ret = reg_read(client, RJ54N1_WB_SEL_WEIGHT_I);
+       if (ret >= 0) {
+               rj54n1->auto_wb = ret & 0x80;
                ret = reg_write_multiple(client, bank_5, ARRAY_SIZE(bank_5));
+       }
        if (!ret)
                ret = reg_write_multiple(client, bank_8, ARRAY_SIZE(bank_8));
 
@@ -777,8 +970,9 @@ static int rj54n1_reg_init(struct i2c_client *client)
                ret = reg_write(client, RJ54N1_RESET_STANDBY,
                                E_EXCLK | DSP_RSTX | TG_RSTX | SEN_RSTX);
 
+       /* Start register update? Same register as 0x?FE in many bank_* sets */
        if (!ret)
-               ret = reg_write(client, 0x7fe, 2);
+               ret = reg_write(client, RJ54N1_FWFLG, 2);
 
        /* Constant taken from manufacturer's example */
        msleep(700);
@@ -786,27 +980,44 @@ static int rj54n1_reg_init(struct i2c_client *client)
        return ret;
 }
 
-/* FIXME: streaming output only up to 800x600 is functional */
-static int rj54n1_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int rj54n1_try_fmt(struct v4l2_subdev *sd,
+                         struct v4l2_mbus_framefmt *mf)
 {
-       struct v4l2_pix_format *pix = &f->fmt.pix;
+       struct i2c_client *client = sd->priv;
+       struct rj54n1 *rj54n1 = to_rj54n1(client);
+       const struct rj54n1_datafmt *fmt;
+       int align = mf->code == V4L2_MBUS_FMT_SBGGR10_1X10 ||
+               mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE ||
+               mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE ||
+               mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE ||
+               mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE;
+
+       dev_dbg(&client->dev, "%s: code = %d, width = %u, height = %u\n",
+               __func__, mf->code, mf->width, mf->height);
+
+       fmt = rj54n1_find_datafmt(mf->code, rj54n1_colour_fmts,
+                                 ARRAY_SIZE(rj54n1_colour_fmts));
+       if (!fmt) {
+               fmt = rj54n1->fmt;
+               mf->code = fmt->code;
+       }
 
-       pix->field = V4L2_FIELD_NONE;
+       mf->field       = V4L2_FIELD_NONE;
+       mf->colorspace  = fmt->colorspace;
 
-       if (pix->width > 800)
-               pix->width = 800;
-       if (pix->height > 600)
-               pix->height = 600;
+       v4l_bound_align_image(&mf->width, 112, RJ54N1_MAX_WIDTH, align,
+                             &mf->height, 84, RJ54N1_MAX_HEIGHT, align, 0);
 
        return 0;
 }
 
-static int rj54n1_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int rj54n1_s_fmt(struct v4l2_subdev *sd,
+                       struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct rj54n1 *rj54n1 = to_rj54n1(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
-       unsigned int output_w, output_h,
+       const struct rj54n1_datafmt *fmt;
+       unsigned int output_w, output_h, max_w, max_h,
                input_w = rj54n1->rect.width, input_h = rj54n1->rect.height;
        int ret;
 
@@ -814,14 +1025,13 @@ static int rj54n1_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
         * The host driver can call us without .try_fmt(), so, we have to take
         * care ourseleves
         */
-       ret = rj54n1_try_fmt(sd, f);
+       rj54n1_try_fmt(sd, mf);
 
        /*
         * Verify if the sensor has just been powered on. TODO: replace this
         * with proper PM, when a suitable API is available.
         */
-       if (!ret)
-               ret = reg_read(client, RJ54N1_RESET_STANDBY);
+       ret = reg_read(client, RJ54N1_RESET_STANDBY);
        if (ret < 0)
                return ret;
 
@@ -831,50 +1041,105 @@ static int rj54n1_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
                        return ret;
        }
 
+       dev_dbg(&client->dev, "%s: code = %d, width = %u, height = %u\n",
+               __func__, mf->code, mf->width, mf->height);
+
        /* RA_SEL_UL is only relevant for raw modes, ignored otherwise. */
-       switch (pix->pixelformat) {
-       case V4L2_PIX_FMT_YUYV:
+       switch (mf->code) {
+       case V4L2_MBUS_FMT_YUYV8_2X8_LE:
                ret = reg_write(client, RJ54N1_OUT_SEL, 0);
                if (!ret)
                        ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8);
                break;
-       case V4L2_PIX_FMT_RGB565:
+       case V4L2_MBUS_FMT_YVYU8_2X8_LE:
+               ret = reg_write(client, RJ54N1_OUT_SEL, 0);
+               if (!ret)
+                       ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8);
+               break;
+       case V4L2_MBUS_FMT_RGB565_2X8_LE:
+               ret = reg_write(client, RJ54N1_OUT_SEL, 0x11);
+               if (!ret)
+                       ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8);
+               break;
+       case V4L2_MBUS_FMT_RGB565_2X8_BE:
                ret = reg_write(client, RJ54N1_OUT_SEL, 0x11);
+               if (!ret)
+                       ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8);
+               break;
+       case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE:
+               ret = reg_write(client, RJ54N1_OUT_SEL, 4);
                if (!ret)
                        ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8);
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_RA_SEL_UL, 0);
+               break;
+       case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE:
+               ret = reg_write(client, RJ54N1_OUT_SEL, 4);
+               if (!ret)
+                       ret = reg_set(client, RJ54N1_BYTE_SWAP, 8, 8);
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_RA_SEL_UL, 8);
+               break;
+       case V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE:
+               ret = reg_write(client, RJ54N1_OUT_SEL, 4);
+               if (!ret)
+                       ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8);
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_RA_SEL_UL, 0);
+               break;
+       case V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE:
+               ret = reg_write(client, RJ54N1_OUT_SEL, 4);
+               if (!ret)
+                       ret = reg_set(client, RJ54N1_BYTE_SWAP, 0, 8);
+               if (!ret)
+                       ret = reg_write(client, RJ54N1_RA_SEL_UL, 8);
+               break;
+       case V4L2_MBUS_FMT_SBGGR10_1X10:
+               ret = reg_write(client, RJ54N1_OUT_SEL, 5);
                break;
        default:
                ret = -EINVAL;
        }
 
+       /* Special case: a raw mode with 10 bits of data per clock tick */
+       if (!ret)
+               ret = reg_set(client, RJ54N1_OCLK_SEL_EN,
+                             (mf->code == V4L2_MBUS_FMT_SBGGR10_1X10) << 1, 2);
+
        if (ret < 0)
                return ret;
 
-       /* Supported scales 1:1 - 1:16 */
-       if (pix->width < input_w / 16)
-               pix->width = input_w / 16;
-       if (pix->height < input_h / 16)
-               pix->height = input_h / 16;
+       /* Supported scales 1:1 >= scale > 1:16 */
+       max_w = mf->width * (16 * 1024 - 1) / 1024;
+       if (input_w > max_w)
+               input_w = max_w;
+       max_h = mf->height * (16 * 1024 - 1) / 1024;
+       if (input_h > max_h)
+               input_h = max_h;
 
-       output_w = pix->width;
-       output_h = pix->height;
+       output_w = mf->width;
+       output_h = mf->height;
 
        ret = rj54n1_sensor_scale(sd, &input_w, &input_h, &output_w, &output_h);
        if (ret < 0)
                return ret;
 
-       rj54n1->fourcc          = pix->pixelformat;
+       fmt = rj54n1_find_datafmt(mf->code, rj54n1_colour_fmts,
+                                 ARRAY_SIZE(rj54n1_colour_fmts));
+
+       rj54n1->fmt             = fmt;
        rj54n1->resize          = ret;
        rj54n1->rect.width      = input_w;
        rj54n1->rect.height     = input_h;
        rj54n1->width           = output_w;
        rj54n1->height          = output_h;
 
-       pix->width              = output_w;
-       pix->height             = output_h;
-       pix->field              = V4L2_FIELD_NONE;
+       mf->width               = output_w;
+       mf->height              = output_h;
+       mf->field               = V4L2_FIELD_NONE;
+       mf->colorspace          = fmt->colorspace;
 
-       return ret;
+       return 0;
 }
 
 static int rj54n1_g_chip_ident(struct v4l2_subdev *sd,
@@ -963,6 +1228,14 @@ static const struct v4l2_queryctrl rj54n1_controls[] = {
                .step           = 1,
                .default_value  = 66,
                .flags          = V4L2_CTRL_FLAG_SLIDER,
+       }, {
+               .id             = V4L2_CID_AUTO_WHITE_BALANCE,
+               .type           = V4L2_CTRL_TYPE_BOOLEAN,
+               .name           = "Auto white balance",
+               .minimum        = 0,
+               .maximum        = 1,
+               .step           = 1,
+               .default_value  = 1,
        },
 };
 
@@ -976,6 +1249,7 @@ static struct soc_camera_ops rj54n1_ops = {
 static int rj54n1_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 {
        struct i2c_client *client = sd->priv;
+       struct rj54n1 *rj54n1 = to_rj54n1(client);
        int data;
 
        switch (ctrl->id) {
@@ -998,6 +1272,9 @@ static int rj54n1_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 
                ctrl->value = data / 2;
                break;
+       case V4L2_CID_AUTO_WHITE_BALANCE:
+               ctrl->value = rj54n1->auto_wb;
+               break;
        }
 
        return 0;
@@ -1007,6 +1284,7 @@ static int rj54n1_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 {
        int data;
        struct i2c_client *client = sd->priv;
+       struct rj54n1 *rj54n1 = to_rj54n1(client);
        const struct v4l2_queryctrl *qctrl;
 
        qctrl = soc_camera_find_qctrl(&rj54n1_ops, ctrl->id);
@@ -1037,6 +1315,13 @@ static int rj54n1_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
                else if (reg_write(client, RJ54N1_Y_GAIN, ctrl->value * 2) < 0)
                        return -EIO;
                break;
+       case V4L2_CID_AUTO_WHITE_BALANCE:
+               /* Auto WB area - whole image */
+               if (reg_set(client, RJ54N1_WB_SEL_WEIGHT_I, ctrl->value << 7,
+                           0x80) < 0)
+                       return -EIO;
+               rj54n1->auto_wb = ctrl->value;
+               break;
        }
 
        return 0;
@@ -1054,10 +1339,12 @@ static struct v4l2_subdev_core_ops rj54n1_subdev_core_ops = {
 
 static struct v4l2_subdev_video_ops rj54n1_subdev_video_ops = {
        .s_stream       = rj54n1_s_stream,
-       .s_fmt          = rj54n1_s_fmt,
-       .g_fmt          = rj54n1_g_fmt,
-       .try_fmt        = rj54n1_try_fmt,
+       .s_mbus_fmt     = rj54n1_s_fmt,
+       .g_mbus_fmt     = rj54n1_g_fmt,
+       .try_mbus_fmt   = rj54n1_try_fmt,
+       .enum_mbus_fmt  = rj54n1_enum_fmt,
        .g_crop         = rj54n1_g_crop,
+       .s_crop         = rj54n1_s_crop,
        .cropcap        = rj54n1_cropcap,
 };
 
@@ -1066,21 +1353,13 @@ static struct v4l2_subdev_ops rj54n1_subdev_ops = {
        .video  = &rj54n1_subdev_video_ops,
 };
 
-static int rj54n1_pin_config(struct i2c_client *client)
-{
-       /*
-        * Experimentally found out IOCTRL wired to 0. TODO: add to platform
-        * data: 0 or 1 << 7.
-        */
-       return reg_write(client, RJ54N1_IOC, 0);
-}
-
 /*
  * Interface active, can use i2c. If it fails, it can indeed mean, that
  * this wasn't our capture interface, so, we wait for the right one
  */
 static int rj54n1_video_probe(struct soc_camera_device *icd,
-                             struct i2c_client *client)
+                             struct i2c_client *client,
+                             struct rj54n1_pdata *priv)
 {
        int data1, data2;
        int ret;
@@ -1101,7 +1380,8 @@ static int rj54n1_video_probe(struct soc_camera_device *icd,
                goto ei2c;
        }
 
-       ret = rj54n1_pin_config(client);
+       /* Configure IOCTL polarity from the platform data: 0 or 1 << 7. */
+       ret = reg_write(client, RJ54N1_IOC, priv->ioctl_high << 7);
        if (ret < 0)
                goto ei2c;
 
@@ -1119,6 +1399,7 @@ static int rj54n1_probe(struct i2c_client *client,
        struct soc_camera_device *icd = client->dev.platform_data;
        struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
        struct soc_camera_link *icl;
+       struct rj54n1_pdata *rj54n1_priv;
        int ret;
 
        if (!icd) {
@@ -1127,11 +1408,13 @@ static int rj54n1_probe(struct i2c_client *client,
        }
 
        icl = to_soc_camera_link(icd);
-       if (!icl) {
+       if (!icl || !icl->priv) {
                dev_err(&client->dev, "RJ54N1CB0C: missing platform data!\n");
                return -EINVAL;
        }
 
+       rj54n1_priv = icl->priv;
+
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
                dev_warn(&adapter->dev,
                         "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE\n");
@@ -1153,10 +1436,12 @@ static int rj54n1_probe(struct i2c_client *client,
        rj54n1->rect.height     = RJ54N1_MAX_HEIGHT;
        rj54n1->width           = RJ54N1_MAX_WIDTH;
        rj54n1->height          = RJ54N1_MAX_HEIGHT;
-       rj54n1->fourcc          = V4L2_PIX_FMT_YUYV;
+       rj54n1->fmt             = &rj54n1_colour_fmts[0];
        rj54n1->resize          = 1024;
+       rj54n1->tgclk_mhz       = (rj54n1_priv->mclk_freq / PLL_L * PLL_N) /
+               (clk_div.ratio_tg + 1) / (clk_div.ratio_t + 1);
 
-       ret = rj54n1_video_probe(icd, client);
+       ret = rj54n1_video_probe(icd, client, rj54n1_priv);
        if (ret < 0) {
                icd->ops = NULL;
                i2c_set_clientdata(client, NULL);
@@ -1164,9 +1449,6 @@ static int rj54n1_probe(struct i2c_client *client,
                return ret;
        }
 
-       icd->formats            = rj54n1_colour_formats;
-       icd->num_formats        = ARRAY_SIZE(rj54n1_colour_formats);
-
        return ret;
 }
 
index 41765f3c7c28cc71e5c3106c1035c39e9453fe54..fb742f1ae711a6a5408586810b1726d6ce208f32 100644 (file)
@@ -233,7 +233,6 @@ struct s2255_dev {
 
        struct s2255_dmaqueue   vidq[MAX_CHANNELS];
        struct video_device     *vdev[MAX_CHANNELS];
-       struct list_head        s2255_devlist;
        struct timer_list       timer;
        struct s2255_fw *fw_data;
        struct s2255_pipeinfo   pipes[MAX_PIPE_BUFFERS];
@@ -313,8 +312,6 @@ struct s2255_fh {
 /* Channels on box are in reverse order */
 static unsigned long G_chnmap[MAX_CHANNELS] = {3, 2, 1, 0};
 
-static LIST_HEAD(s2255_devlist);
-
 static int debug;
 static int *s2255_debug = &debug;
 
@@ -1533,32 +1530,24 @@ static int vidioc_s_parm(struct file *file, void *priv,
 }
 static int s2255_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct s2255_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct s2255_dev *dev = video_drvdata(file);
        struct s2255_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        int i = 0;
        int cur_channel = -1;
        int state;
-       dprintk(1, "s2255: open called (minor=%d)\n", minor);
+
+       dprintk(1, "s2255: open called (dev=%s)\n",
+               video_device_node_name(vdev));
 
        lock_kernel();
-       list_for_each(list, &s2255_devlist) {
-               h = list_entry(list, struct s2255_dev, s2255_devlist);
-               for (i = 0; i < MAX_CHANNELS; i++) {
-                       if (h->vdev[i]->minor == minor) {
-                               cur_channel = i;
-                               dev = h;
-                               type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-                       }
-               }
-       }
 
-       if ((NULL == dev) || (cur_channel == -1)) {
-               unlock_kernel();
-               printk(KERN_INFO "s2255: openv4l no dev\n");
-               return -ENODEV;
+       for (i = 0; i < MAX_CHANNELS; i++) {
+               if (dev->vdev[i] == vdev) {
+                       cur_channel = i;
+                       break;
+               }
        }
 
        if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_DISCONNECTING) {
@@ -1662,8 +1651,9 @@ static int s2255_open(struct file *file)
        for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
                qctl_regs[i] = s2255_qctrl[i].default_value;
 
-       dprintk(1, "s2255drv: open minor=%d type=%s users=%d\n",
-               minor, v4l2_type_names[type], dev->users[cur_channel]);
+       dprintk(1, "s2255drv: open dev=%s type=%s users=%d\n",
+               video_device_node_name(vdev), v4l2_type_names[type],
+               dev->users[cur_channel]);
        dprintk(2, "s2255drv: open: fh=0x%08lx, dev=0x%08lx, vidq=0x%08lx\n",
                (unsigned long)fh, (unsigned long)dev,
                (unsigned long)&dev->vidq[cur_channel]);
@@ -1699,7 +1689,6 @@ static unsigned int s2255_poll(struct file *file,
 static void s2255_destroy(struct kref *kref)
 {
        struct s2255_dev *dev = to_s2255_dev(kref);
-       struct list_head *list;
        int i;
        if (!dev) {
                printk(KERN_ERR "s2255drv: kref problem\n");
@@ -1733,10 +1722,6 @@ static void s2255_destroy(struct kref *kref)
        usb_put_dev(dev->udev);
        dprintk(1, "%s", __func__);
 
-       while (!list_empty(&s2255_devlist)) {
-               list = s2255_devlist.next;
-               list_del(list);
-       }
        mutex_unlock(&dev->open_lock);
        kfree(dev);
 }
@@ -1745,7 +1730,8 @@ static int s2255_close(struct file *file)
 {
        struct s2255_fh *fh = file->private_data;
        struct s2255_dev *dev = fh->dev;
-       int minor = video_devdata(file)->minor;
+       struct video_device *vdev = video_devdata(file);
+
        if (!dev)
                return -ENODEV;
 
@@ -1765,8 +1751,8 @@ static int s2255_close(struct file *file)
        mutex_unlock(&dev->open_lock);
 
        kref_put(&dev->kref, s2255_destroy);
-       dprintk(1, "s2255: close called (minor=%d, users=%d)\n",
-               minor, dev->users[fh->channel]);
+       dprintk(1, "s2255: close called (dev=%s, users=%d)\n",
+               video_device_node_name(vdev), dev->users[fh->channel]);
        kfree(fh);
        return 0;
 }
@@ -1830,7 +1816,6 @@ static struct video_device template = {
        .name = "s2255v",
        .fops = &s2255_fops_v4l,
        .ioctl_ops = &s2255_ioctl_ops,
-       .minor = -1,
        .release = video_device_release,
        .tvnorms = S2255_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
@@ -1843,7 +1828,6 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
        int cur_nr = video_nr;
 
        /* initialize all video 4 linux */
-       list_add_tail(&dev->s2255_devlist, &s2255_devlist);
        /* register 4 video devices */
        for (i = 0; i < MAX_CHANNELS; i++) {
                INIT_LIST_HEAD(&dev->vidq[i].active);
@@ -1853,6 +1837,7 @@ static int s2255_probe_v4l(struct s2255_dev *dev)
                dev->vdev[i] = video_device_alloc();
                memcpy(dev->vdev[i], &template, sizeof(struct video_device));
                dev->vdev[i]->parent = &dev->interface->dev;
+               video_set_drvdata(dev->vdev[i], dev);
                if (video_nr == -1)
                        ret = video_register_device(dev->vdev[i],
                                                    VFL_TYPE_GRABBER,
@@ -1880,7 +1865,7 @@ static void s2255_exit_v4l(struct s2255_dev *dev)
 
        int i;
        for (i = 0; i < MAX_CHANNELS; i++) {
-               if (-1 != dev->vdev[i]->minor) {
+               if (video_is_registered(dev->vdev[i])) {
                        video_unregister_device(dev->vdev[i]);
                        printk(KERN_INFO "s2255 unregistered\n");
                } else {
index b624a4c01fdc9faee6e2fe37ad0939da9fdbfee2..5ab6a0f901c022e190087926a40173131cdf7348 100644 (file)
@@ -1036,7 +1036,6 @@ static struct video_device saa_template =
        .name     = "saa5246a",
        .fops     = &saa_fops,
        .release  = video_device_release,
-       .minor    = -1,
 };
 
 static int saa5246a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
index 7e40d6d99dd08f214244257ef89ff5435e78445b..03f572708b85ef6bd658bef30dea586ed23e11ac 100644 (file)
@@ -7211,9 +7211,31 @@ int saa7134_board_init2(struct saa7134_dev *dev)
        }
        case SAA7134_BOARD_FLYDVB_TRIO:
        {
+               u8 temp = 0;
+               int rc;
                u8 data[] = { 0x3c, 0x33, 0x62};
                struct i2c_msg msg = {.addr=0x09, .flags=0, .buf=data, .len = sizeof(data)};
                i2c_transfer(&dev->i2c_adap, &msg, 1);
+
+               /*
+                * send weak up message to pic16C505 chip
+                * @ LifeView FlyDVB Trio
+                */
+               msg.buf = &temp;
+               msg.addr = 0x0b;
+               msg.len = 1;
+               if (1 != i2c_transfer(&dev->i2c_adap, &msg, 1)) {
+                       printk(KERN_WARNING "%s: send wake up byte to pic16C505"
+                                       "(IR chip) failed\n", dev->name);
+               } else {
+                       msg.flags = I2C_M_RD;
+                       rc = i2c_transfer(&dev->i2c_adap, &msg, 1);
+                       printk(KERN_INFO "%s: probe IR chip @ i2c 0x%02x: %s\n",
+                                  dev->name, msg.addr,
+                                  (1 == rc) ? "yes" : "no");
+                       if (rc == 1)
+                               dev->has_remote = SAA7134_REMOTE_I2C;
+               }
                break;
        }
        case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
index 0ba7f5af0fc33056a86d4e407cb10dd317b299d4..9f85e917f9f39da8565954f6c38eb45021d30bad 100644 (file)
@@ -797,27 +797,28 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
        vfd->debug   = video_debug;
        snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
                 dev->name, type, saa7134_boards[dev->board].name);
+       video_set_drvdata(vfd, dev);
        return vfd;
 }
 
 static void saa7134_unregister_video(struct saa7134_dev *dev)
 {
        if (dev->video_dev) {
-               if (-1 != dev->video_dev->minor)
+               if (video_is_registered(dev->video_dev))
                        video_unregister_device(dev->video_dev);
                else
                        video_device_release(dev->video_dev);
                dev->video_dev = NULL;
        }
        if (dev->vbi_dev) {
-               if (-1 != dev->vbi_dev->minor)
+               if (video_is_registered(dev->vbi_dev))
                        video_unregister_device(dev->vbi_dev);
                else
                        video_device_release(dev->vbi_dev);
                dev->vbi_dev = NULL;
        }
        if (dev->radio_dev) {
-               if (-1 != dev->radio_dev->minor)
+               if (video_is_registered(dev->radio_dev))
                        video_unregister_device(dev->radio_dev);
                else
                        video_device_release(dev->radio_dev);
@@ -1046,8 +1047,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
                       dev->name);
                goto fail4;
        }
-       printk(KERN_INFO "%s: registered device video%d [v4l2]\n",
-              dev->name, dev->video_dev->num);
+       printk(KERN_INFO "%s: registered device %s [v4l2]\n",
+              dev->name, video_device_node_name(dev->video_dev));
 
        dev->vbi_dev = vdev_init(dev, &saa7134_video_template, "vbi");
 
@@ -1055,8 +1056,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
                                    vbi_nr[dev->nr]);
        if (err < 0)
                goto fail4;
-       printk(KERN_INFO "%s: registered device vbi%d\n",
-              dev->name, dev->vbi_dev->num);
+       printk(KERN_INFO "%s: registered device %s\n",
+              dev->name, video_device_node_name(dev->vbi_dev));
 
        if (card_has_radio(dev)) {
                dev->radio_dev = vdev_init(dev,&saa7134_radio_template,"radio");
@@ -1064,8 +1065,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
                                            radio_nr[dev->nr]);
                if (err < 0)
                        goto fail4;
-               printk(KERN_INFO "%s: registered device radio%d\n",
-                      dev->name, dev->radio_dev->num);
+               printk(KERN_INFO "%s: registered device %s\n",
+                      dev->name, video_device_node_name(dev->radio_dev));
        }
 
        /* everything worked */
index 296788c3bf0ecc6ddc14301fb10bf198216e155a..7dfecfc6017cab0db7d0bea4c979e783fc4ec13d 100644 (file)
@@ -86,19 +86,11 @@ static int ts_init_encoder(struct saa7134_dev* dev)
 
 static int ts_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct saa7134_dev *dev;
+       struct video_device *vdev = video_devdata(file);
+       struct saa7134_dev *dev = video_drvdata(file);
        int err;
 
-       lock_kernel();
-       list_for_each_entry(dev, &saa7134_devlist, devlist)
-               if (dev->empress_dev && dev->empress_dev->minor == minor)
-                       goto found;
-       unlock_kernel();
-       return -ENODEV;
- found:
-
-       dprintk("open minor=%d\n",minor);
+       dprintk("open dev=%s\n", video_device_node_name(vdev));
        err = -EBUSY;
        if (!mutex_trylock(&dev->empress_tsq.vb_lock))
                goto done;
@@ -489,7 +481,6 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = {
 static struct video_device saa7134_empress_template = {
        .name          = "saa7134-empress",
        .fops          = &ts_fops,
-       .minor         = -1,
        .ioctl_ops     = &ts_ioctl_ops,
 
        .tvnorms                        = SAA7134_NORMS,
@@ -531,6 +522,7 @@ static int empress_init(struct saa7134_dev *dev)
 
        INIT_WORK(&dev->empress_workqueue, empress_signal_update);
 
+       video_set_drvdata(dev->empress_dev, dev);
        err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
                                    empress_nr[dev->nr]);
        if (err < 0) {
@@ -540,8 +532,8 @@ static int empress_init(struct saa7134_dev *dev)
                dev->empress_dev = NULL;
                return err;
        }
-       printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
-              dev->name, dev->empress_dev->num);
+       printk(KERN_INFO "%s: registered device %s [mpeg]\n",
+              dev->name, video_device_node_name(dev->empress_dev));
 
        videobuf_queue_sg_init(&dev->empress_tsq, &saa7134_ts_qops,
                            &dev->pci->dev, &dev->slock,
index 744918b1cd472a96e7680b143b5572bba176bf72..f8e985989ca0a7a7bae70ed8d17a952335827126 100644 (file)
@@ -127,6 +127,61 @@ static int build_key(struct saa7134_dev *dev)
 
 /* --------------------- Chip specific I2C key builders ----------------- */
 
+static int get_key_flydvb_trio(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
+{
+       int gpio;
+       int attempt = 0;
+       unsigned char b;
+
+       /* We need this to access GPI Used by the saa_readl macro. */
+       struct saa7134_dev *dev = ir->c->adapter->algo_data;
+
+       if (dev == NULL) {
+               dprintk("get_key_flydvb_trio: "
+                        "gir->c->adapter->algo_data is NULL!\n");
+               return -EIO;
+       }
+
+       /* rising SAA7134_GPIGPRESCAN reads the status */
+       saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
+       saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
+
+       gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
+
+       if (0x40000 & ~gpio)
+               return 0; /* No button press */
+
+       /* No button press - only before first key pressed */
+       if (b == 0xFF)
+               return 0;
+
+       /* poll IR chip */
+       /* weak up the IR chip */
+       b = 0;
+
+       while (1 != i2c_master_send(ir->c, &b, 1)) {
+               if ((attempt++) < 10) {
+                       /*
+                        * wait a bit for next attempt -
+                        * I don't know how make it better
+                        */
+                       msleep(10);
+                       continue;
+               }
+               i2cdprintk("send wake up byte to pic16C505 (IR chip)"
+                          "failed %dx\n", attempt);
+               return -EIO;
+       }
+       if (1 != i2c_master_recv(ir->c, &b, 1)) {
+               i2cdprintk("read error\n");
+               return -EIO;
+       }
+
+       *ir_key = b;
+       *ir_raw = b;
+       return 1;
+}
+
 static int get_key_msi_tvanywhere_plus(struct IR_i2c *ir, u32 *ir_key,
                                       u32 *ir_raw)
 {
@@ -622,6 +677,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
                mask_keyup   = 0x020000;
                polling      = 50; /* ms */
                break;
+       break;
        }
        if (NULL == ir_codes) {
                printk("%s: Oops: IR config error [card=%d]\n",
@@ -652,7 +708,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
        snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
                 pci_name(dev->pci));
 
-       err = ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
+       err = ir_input_init(input_dev, &ir->ir, ir_type);
        if (err < 0)
                goto err_out_free;
 
@@ -672,7 +728,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
        dev->remote = ir;
        saa7134_ir_start(dev, ir);
 
-       err = input_register_device(ir->dev);
+       err = ir_input_register(ir->dev, ir_codes);
        if (err)
                goto err_out_stop;
 
@@ -686,8 +742,6 @@ int saa7134_input_init1(struct saa7134_dev *dev)
        saa7134_ir_stop(dev);
        dev->remote = NULL;
  err_out_free:
-       ir_input_free(input_dev);
-       input_free_device(input_dev);
        kfree(ir);
        return err;
 }
@@ -698,8 +752,7 @@ void saa7134_input_fini(struct saa7134_dev *dev)
                return;
 
        saa7134_ir_stop(dev);
-       ir_input_free(dev->remote->dev);
-       input_unregister_device(dev->remote->dev);
+       ir_input_unregister(dev->remote->dev);
        kfree(dev->remote);
        dev->remote = NULL;
 }
@@ -788,6 +841,12 @@ void saa7134_probe_i2c_ir(struct saa7134_dev *dev)
        case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
                info.addr = 0x40;
                break;
+       case SAA7134_BOARD_FLYDVB_TRIO:
+               dev->init_data.name = "FlyDVB Trio";
+               dev->init_data.get_key = get_key_flydvb_trio;
+               dev->init_data.ir_codes = &ir_codes_flydvb_table;
+               info.addr = 0x0b;
+               break;
        default:
                dprintk("No I2C IR support for board %x\n", dev->board);
                return;
index 35f8daa3a359cf6cf41a446170df31c1151aed7c..cb732640ac4ad829770b8c40b3761a4c140338bb 100644 (file)
@@ -1326,33 +1326,26 @@ static int saa7134_resource(struct saa7134_fh *fh)
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct saa7134_dev *dev;
+       struct video_device *vdev = video_devdata(file);
+       struct saa7134_dev *dev = video_drvdata(file);
        struct saa7134_fh *fh;
-       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       enum v4l2_buf_type type = 0;
        int radio = 0;
 
-       mutex_lock(&saa7134_devlist_lock);
-       list_for_each_entry(dev, &saa7134_devlist, devlist) {
-               if (dev->video_dev && (dev->video_dev->minor == minor))
-                       goto found;
-               if (dev->radio_dev && (dev->radio_dev->minor == minor)) {
-                       radio = 1;
-                       goto found;
-               }
-               if (dev->vbi_dev && (dev->vbi_dev->minor == minor)) {
-                       type = V4L2_BUF_TYPE_VBI_CAPTURE;
-                       goto found;
-               }
+       switch (vdev->vfl_type) {
+       case VFL_TYPE_GRABBER:
+               type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+               break;
+       case VFL_TYPE_VBI:
+               type = V4L2_BUF_TYPE_VBI_CAPTURE;
+               break;
+       case VFL_TYPE_RADIO:
+               radio = 1;
+               break;
        }
-       mutex_unlock(&saa7134_devlist_lock);
-       return -ENODEV;
-
-found:
-       mutex_unlock(&saa7134_devlist_lock);
 
-       dprintk("open minor=%d radio=%d type=%s\n",minor,radio,
-               v4l2_type_names[type]);
+       dprintk("open dev=%s radio=%d type=%s\n", video_device_node_name(vdev),
+               radio, v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh),GFP_KERNEL);
@@ -2502,7 +2495,6 @@ struct video_device saa7134_video_template = {
        .name                           = "saa7134-video",
        .fops                           = &video_fops,
        .ioctl_ops                      = &video_ioctl_ops,
-       .minor                          = -1,
        .tvnorms                        = SAA7134_NORMS,
        .current_norm                   = V4L2_STD_PAL,
 };
@@ -2511,7 +2503,6 @@ struct video_device saa7134_radio_template = {
        .name                   = "saa7134-radio",
        .fops                   = &radio_fops,
        .ioctl_ops              = &radio_ioctl_ops,
-       .minor                  = -1,
 };
 
 int saa7134_video_init1(struct saa7134_dev *dev)
index 85ffc2cba039b3e6114e5fc8d3bd4671bf9fea20..41d0166c0f95b5ff8156770155d3affe6ce874c5 100644 (file)
@@ -1428,8 +1428,8 @@ static int se401_probe(struct usb_interface *intf,
                err("video_register_device failed");
                return -EIO;
        }
-       dev_info(&intf->dev, "registered new video device: video%d\n",
-                se401->vdev.num);
+       dev_info(&intf->dev, "registered new video device: %s\n",
+                video_device_node_name(&se401->vdev));
 
        usb_set_intfdata(intf, se401);
        return 0;
index a4f3472d4db87025d041d9422c5ed5ea8cd63883..d69363f0d8c9932b21f02ada8f865899b115f336 100644 (file)
@@ -38,6 +38,8 @@
 #include <media/soc_camera.h>
 #include <media/sh_mobile_ceu.h>
 #include <media/videobuf-dma-contig.h>
+#include <media/v4l2-mediabus.h>
+#include <media/soc_mediabus.h>
 
 /* register offsets for sh7722 / sh7723 */
 
@@ -85,7 +87,7 @@
 /* per video frame buffer */
 struct sh_mobile_ceu_buffer {
        struct videobuf_buffer vb; /* v4l buffer must be first */
-       const struct soc_camera_data_format *fmt;
+       enum v4l2_mbus_pixelcode code;
 };
 
 struct sh_mobile_ceu_dev {
@@ -105,7 +107,8 @@ struct sh_mobile_ceu_dev {
 
        u32 cflcr;
 
-       unsigned int is_interlaced:1;
+       enum v4l2_field field;
+
        unsigned int image_mode:1;
        unsigned int is_16bit:1;
 };
@@ -114,8 +117,8 @@ struct sh_mobile_ceu_cam {
        struct v4l2_rect ceu_rect;
        unsigned int cam_width;
        unsigned int cam_height;
-       const struct soc_camera_data_format *extra_fmt;
-       const struct soc_camera_data_format *camera_fmt;
+       const struct soc_mbus_pixelfmt *extra_fmt;
+       enum v4l2_mbus_pixelcode code;
 };
 
 static unsigned long make_bus_param(struct sh_mobile_ceu_dev *pcdev)
@@ -197,16 +200,19 @@ static int sh_mobile_ceu_videobuf_setup(struct videobuf_queue *vq,
        struct soc_camera_device *icd = vq->priv_data;
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
-       int bytes_per_pixel = (icd->current_fmt->depth + 7) >> 3;
+       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
+
+       if (bytes_per_line < 0)
+               return bytes_per_line;
 
-       *size = PAGE_ALIGN(icd->user_width * icd->user_height *
-                          bytes_per_pixel);
+       *size = bytes_per_line * icd->user_height;
 
        if (0 == *count)
                *count = 2;
 
        if (pcdev->video_limit) {
-               while (*size * *count > pcdev->video_limit)
+               while (PAGE_ALIGN(*size) * *count > pcdev->video_limit)
                        (*count)--;
        }
 
@@ -249,10 +255,13 @@ static int sh_mobile_ceu_capture(struct sh_mobile_ceu_dev *pcdev)
 {
        struct soc_camera_device *icd = pcdev->icd;
        dma_addr_t phys_addr_top, phys_addr_bottom;
+       unsigned long top1, top2;
+       unsigned long bottom1, bottom2;
        u32 status;
        int ret = 0;
 
-       /* The hardware is _very_ picky about this sequence. Especially
+       /*
+        * The hardware is _very_ picky about this sequence. Especially
         * the CEU_CETCR_MAGIC value. It seems like we need to acknowledge
         * several not-so-well documented interrupt sources in CETCR.
         */
@@ -276,25 +285,36 @@ static int sh_mobile_ceu_capture(struct sh_mobile_ceu_dev *pcdev)
        if (!pcdev->active)
                return ret;
 
+       if (V4L2_FIELD_INTERLACED_BT == pcdev->field) {
+               top1    = CDBYR;
+               top2    = CDBCR;
+               bottom1 = CDAYR;
+               bottom2 = CDACR;
+       } else {
+               top1    = CDAYR;
+               top2    = CDACR;
+               bottom1 = CDBYR;
+               bottom2 = CDBCR;
+       }
+
        phys_addr_top = videobuf_to_dma_contig(pcdev->active);
-       ceu_write(pcdev, CDAYR, phys_addr_top);
-       if (pcdev->is_interlaced) {
+       ceu_write(pcdev, top1, phys_addr_top);
+       if (V4L2_FIELD_NONE != pcdev->field) {
                phys_addr_bottom = phys_addr_top + icd->user_width;
-               ceu_write(pcdev, CDBYR, phys_addr_bottom);
+               ceu_write(pcdev, bottom1, phys_addr_bottom);
        }
 
-       switch (icd->current_fmt->fourcc) {
+       switch (icd->current_fmt->host_fmt->fourcc) {
        case V4L2_PIX_FMT_NV12:
        case V4L2_PIX_FMT_NV21:
        case V4L2_PIX_FMT_NV16:
        case V4L2_PIX_FMT_NV61:
                phys_addr_top += icd->user_width *
                        icd->user_height;
-               ceu_write(pcdev, CDACR, phys_addr_top);
-               if (pcdev->is_interlaced) {
-                       phys_addr_bottom = phys_addr_top +
-                               icd->user_width;
-                       ceu_write(pcdev, CDBCR, phys_addr_bottom);
+               ceu_write(pcdev, top2, phys_addr_top);
+               if (V4L2_FIELD_NONE != pcdev->field) {
+                       phys_addr_bottom = phys_addr_top + icd->user_width;
+                       ceu_write(pcdev, bottom2, phys_addr_bottom);
                }
        }
 
@@ -310,8 +330,13 @@ static int sh_mobile_ceu_videobuf_prepare(struct videobuf_queue *vq,
 {
        struct soc_camera_device *icd = vq->priv_data;
        struct sh_mobile_ceu_buffer *buf;
+       int bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
+                                               icd->current_fmt->host_fmt);
        int ret;
 
+       if (bytes_per_line < 0)
+               return bytes_per_line;
+
        buf = container_of(vb, struct sh_mobile_ceu_buffer, vb);
 
        dev_dbg(icd->dev.parent, "%s (vb=0x%p) 0x%08lx %zd\n", __func__,
@@ -321,25 +346,27 @@ static int sh_mobile_ceu_videobuf_prepare(struct videobuf_queue *vq,
        WARN_ON(!list_empty(&vb->queue));
 
 #ifdef DEBUG
-       /* This can be useful if you want to see if we actually fill
-        * the buffer with something */
+       /*
+        * This can be useful if you want to see if we actually fill
+        * the buffer with something
+        */
        memset((void *)vb->baddr, 0xaa, vb->bsize);
 #endif
 
        BUG_ON(NULL == icd->current_fmt);
 
-       if (buf->fmt    != icd->current_fmt ||
+       if (buf->code   != icd->current_fmt->code ||
            vb->width   != icd->user_width ||
            vb->height  != icd->user_height ||
            vb->field   != field) {
-               buf->fmt        = icd->current_fmt;
+               buf->code       = icd->current_fmt->code;
                vb->width       = icd->user_width;
                vb->height      = icd->user_height;
                vb->field       = field;
                vb->state       = VIDEOBUF_NEEDS_INIT;
        }
 
-       vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3);
+       vb->size = vb->height * bytes_per_line;
        if (0 != vb->baddr && vb->bsize < vb->size) {
                ret = -EINVAL;
                goto out;
@@ -456,6 +483,7 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)
 {
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
+       int ret;
 
        if (pcdev->icd)
                return -EBUSY;
@@ -466,9 +494,11 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)
 
        pm_runtime_get_sync(ici->v4l2_dev.dev);
 
-       pcdev->icd = icd;
+       ret = sh_mobile_ceu_soft_reset(pcdev);
+       if (!ret)
+               pcdev->icd = icd;
 
-       return sh_mobile_ceu_soft_reset(pcdev);
+       return ret;
 }
 
 /* Called with .video_lock held */
@@ -558,24 +588,35 @@ static void sh_mobile_ceu_set_rect(struct soc_camera_device *icd,
                        in_width *= 2;
                        left_offset *= 2;
                }
-               width = cdwdr_width = out_width;
+               width = out_width;
+               cdwdr_width = out_width;
        } else {
-               unsigned int w_factor = (icd->current_fmt->depth + 7) >> 3;
+               int bytes_per_line = soc_mbus_bytes_per_line(out_width,
+                                               icd->current_fmt->host_fmt);
+               unsigned int w_factor;
 
-               width = out_width * w_factor / 2;
+               width = out_width;
 
-               if (!pcdev->is_16bit)
-                       w_factor *= 2;
+               switch (icd->current_fmt->host_fmt->packing) {
+               case SOC_MBUS_PACKING_2X8_PADHI:
+                       w_factor = 2;
+                       break;
+               default:
+                       w_factor = 1;
+               }
 
-               in_width = rect->width * w_factor / 2;
-               left_offset = left_offset * w_factor / 2;
+               in_width = rect->width * w_factor;
+               left_offset = left_offset * w_factor;
 
-               cdwdr_width = width * 2;
+               if (bytes_per_line < 0)
+                       cdwdr_width = out_width;
+               else
+                       cdwdr_width = bytes_per_line;
        }
 
        height = out_height;
        in_height = rect->height;
-       if (pcdev->is_interlaced) {
+       if (V4L2_FIELD_NONE != pcdev->field) {
                height /= 2;
                in_height /= 2;
                top_offset /= 2;
@@ -646,6 +687,23 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd,
        if (!common_flags)
                return -EINVAL;
 
+       /* Make choises, based on platform preferences */
+       if ((common_flags & SOCAM_HSYNC_ACTIVE_HIGH) &&
+           (common_flags & SOCAM_HSYNC_ACTIVE_LOW)) {
+               if (pcdev->pdata->flags & SH_CEU_FLAG_HSYNC_LOW)
+                       common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH;
+               else
+                       common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW;
+       }
+
+       if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) &&
+           (common_flags & SOCAM_VSYNC_ACTIVE_LOW)) {
+               if (pcdev->pdata->flags & SH_CEU_FLAG_VSYNC_LOW)
+                       common_flags &= ~SOCAM_VSYNC_ACTIVE_HIGH;
+               else
+                       common_flags &= ~SOCAM_VSYNC_ACTIVE_LOW;
+       }
+
        ret = icd->ops->set_bus_param(icd, common_flags);
        if (ret < 0)
                return ret;
@@ -667,24 +725,24 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd,
        value = 0x00000010; /* data fetch by default */
        yuv_lineskip = 0;
 
-       switch (icd->current_fmt->fourcc) {
+       switch (icd->current_fmt->host_fmt->fourcc) {
        case V4L2_PIX_FMT_NV12:
        case V4L2_PIX_FMT_NV21:
                yuv_lineskip = 1; /* skip for NV12/21, no skip for NV16/61 */
                /* fall-through */
        case V4L2_PIX_FMT_NV16:
        case V4L2_PIX_FMT_NV61:
-               switch (cam->camera_fmt->fourcc) {
-               case V4L2_PIX_FMT_UYVY:
+               switch (cam->code) {
+               case V4L2_MBUS_FMT_YUYV8_2X8_BE:
                        value = 0x00000000; /* Cb0, Y0, Cr0, Y1 */
                        break;
-               case V4L2_PIX_FMT_VYUY:
+               case V4L2_MBUS_FMT_YVYU8_2X8_BE:
                        value = 0x00000100; /* Cr0, Y0, Cb0, Y1 */
                        break;
-               case V4L2_PIX_FMT_YUYV:
+               case V4L2_MBUS_FMT_YUYV8_2X8_LE:
                        value = 0x00000200; /* Y0, Cb0, Y1, Cr0 */
                        break;
-               case V4L2_PIX_FMT_YVYU:
+               case V4L2_MBUS_FMT_YVYU8_2X8_LE:
                        value = 0x00000300; /* Y0, Cr0, Y1, Cb0 */
                        break;
                default:
@@ -692,8 +750,8 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd,
                }
        }
 
-       if (icd->current_fmt->fourcc == V4L2_PIX_FMT_NV21 ||
-           icd->current_fmt->fourcc == V4L2_PIX_FMT_NV61)
+       if (icd->current_fmt->host_fmt->fourcc == V4L2_PIX_FMT_NV21 ||
+           icd->current_fmt->host_fmt->fourcc == V4L2_PIX_FMT_NV61)
                value ^= 0x00000100; /* swap U, V to change from NV1x->NVx1 */
 
        value |= common_flags & SOCAM_VSYNC_ACTIVE_LOW ? 1 << 1 : 0;
@@ -702,14 +760,27 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd,
        ceu_write(pcdev, CAMCR, value);
 
        ceu_write(pcdev, CAPCR, 0x00300000);
-       ceu_write(pcdev, CAIFR, pcdev->is_interlaced ? 0x101 : 0);
+
+       switch (pcdev->field) {
+       case V4L2_FIELD_INTERLACED_TB:
+               value = 0x101;
+               break;
+       case V4L2_FIELD_INTERLACED_BT:
+               value = 0x102;
+               break;
+       default:
+               value = 0;
+               break;
+       }
+       ceu_write(pcdev, CAIFR, value);
 
        sh_mobile_ceu_set_rect(icd, icd->user_width, icd->user_height);
        mdelay(1);
 
        ceu_write(pcdev, CFLCR, pcdev->cflcr);
 
-       /* A few words about byte order (observed in Big Endian mode)
+       /*
+        * A few words about byte order (observed in Big Endian mode)
         *
         * In data fetch mode bytes are received in chunks of 8 bytes.
         * D0, D1, D2, D3, D4, D5, D6, D7 (D0 received first)
@@ -739,7 +810,8 @@ static int sh_mobile_ceu_set_bus_param(struct soc_camera_device *icd,
        return 0;
 }
 
-static int sh_mobile_ceu_try_bus_param(struct soc_camera_device *icd)
+static int sh_mobile_ceu_try_bus_param(struct soc_camera_device *icd,
+                                      unsigned char buswidth)
 {
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
@@ -748,48 +820,75 @@ static int sh_mobile_ceu_try_bus_param(struct soc_camera_device *icd)
        camera_flags = icd->ops->query_bus_param(icd);
        common_flags = soc_camera_bus_param_compatible(camera_flags,
                                                       make_bus_param(pcdev));
-       if (!common_flags)
+       if (!common_flags || buswidth > 16 ||
+           (buswidth > 8 && !(common_flags & SOCAM_DATAWIDTH_16)))
                return -EINVAL;
 
        return 0;
 }
 
-static const struct soc_camera_data_format sh_mobile_ceu_formats[] = {
-       {
-               .name           = "NV12",
-               .depth          = 12,
-               .fourcc         = V4L2_PIX_FMT_NV12,
-               .colorspace     = V4L2_COLORSPACE_JPEG,
-       },
-       {
-               .name           = "NV21",
-               .depth          = 12,
-               .fourcc         = V4L2_PIX_FMT_NV21,
-               .colorspace     = V4L2_COLORSPACE_JPEG,
-       },
-       {
-               .name           = "NV16",
-               .depth          = 16,
-               .fourcc         = V4L2_PIX_FMT_NV16,
-               .colorspace     = V4L2_COLORSPACE_JPEG,
-       },
+static const struct soc_mbus_pixelfmt sh_mobile_ceu_formats[] = {
        {
-               .name           = "NV61",
-               .depth          = 16,
-               .fourcc         = V4L2_PIX_FMT_NV61,
-               .colorspace     = V4L2_COLORSPACE_JPEG,
+               .fourcc                 = V4L2_PIX_FMT_NV12,
+               .name                   = "NV12",
+               .bits_per_sample        = 12,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, {
+               .fourcc                 = V4L2_PIX_FMT_NV21,
+               .name                   = "NV21",
+               .bits_per_sample        = 12,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, {
+               .fourcc                 = V4L2_PIX_FMT_NV16,
+               .name                   = "NV16",
+               .bits_per_sample        = 16,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, {
+               .fourcc                 = V4L2_PIX_FMT_NV61,
+               .name                   = "NV61",
+               .bits_per_sample        = 16,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
        },
 };
 
+/* This will be corrected as we get more formats */
+static bool sh_mobile_ceu_packing_supported(const struct soc_mbus_pixelfmt *fmt)
+{
+       return  fmt->packing == SOC_MBUS_PACKING_NONE ||
+               (fmt->bits_per_sample == 8 &&
+                fmt->packing == SOC_MBUS_PACKING_2X8_PADHI) ||
+               (fmt->bits_per_sample > 8 &&
+                fmt->packing == SOC_MBUS_PACKING_EXTEND16);
+}
+
 static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
                                     struct soc_camera_format_xlate *xlate)
 {
+       struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        struct device *dev = icd->dev.parent;
        int ret, k, n;
        int formats = 0;
        struct sh_mobile_ceu_cam *cam;
+       enum v4l2_mbus_pixelcode code;
+       const struct soc_mbus_pixelfmt *fmt;
 
-       ret = sh_mobile_ceu_try_bus_param(icd);
+       ret = v4l2_subdev_call(sd, video, enum_mbus_fmt, idx, &code);
+       if (ret < 0)
+               /* No more formats */
+               return 0;
+
+       fmt = soc_mbus_get_fmtdesc(code);
+       if (!fmt) {
+               dev_err(icd->dev.parent,
+                       "Invalid format code #%d: %d\n", idx, code);
+               return -EINVAL;
+       }
+
+       ret = sh_mobile_ceu_try_bus_param(icd, fmt->bits_per_sample);
        if (ret < 0)
                return 0;
 
@@ -807,13 +906,13 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
        if (!idx)
                cam->extra_fmt = NULL;
 
-       switch (icd->formats[idx].fourcc) {
-       case V4L2_PIX_FMT_UYVY:
-       case V4L2_PIX_FMT_VYUY:
-       case V4L2_PIX_FMT_YUYV:
-       case V4L2_PIX_FMT_YVYU:
+       switch (code) {
+       case V4L2_MBUS_FMT_YUYV8_2X8_BE:
+       case V4L2_MBUS_FMT_YVYU8_2X8_BE:
+       case V4L2_MBUS_FMT_YUYV8_2X8_LE:
+       case V4L2_MBUS_FMT_YVYU8_2X8_LE:
                if (cam->extra_fmt)
-                       goto add_single_format;
+                       break;
 
                /*
                 * Our case is simple so far: for any of the above four camera
@@ -824,32 +923,31 @@ static int sh_mobile_ceu_get_formats(struct soc_camera_device *icd, int idx,
                 * the host_priv pointer and check whether the format you're
                 * going to add now is already there.
                 */
-               cam->extra_fmt = (void *)sh_mobile_ceu_formats;
+               cam->extra_fmt = sh_mobile_ceu_formats;
 
                n = ARRAY_SIZE(sh_mobile_ceu_formats);
                formats += n;
                for (k = 0; xlate && k < n; k++) {
-                       xlate->host_fmt = &sh_mobile_ceu_formats[k];
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = icd->formats[idx].depth;
+                       xlate->host_fmt = &sh_mobile_ceu_formats[k];
+                       xlate->code     = code;
                        xlate++;
-                       dev_dbg(dev, "Providing format %s using %s\n",
-                               sh_mobile_ceu_formats[k].name,
-                               icd->formats[idx].name);
+                       dev_dbg(dev, "Providing format %s using code %d\n",
+                               sh_mobile_ceu_formats[k].name, code);
                }
+               break;
        default:
-add_single_format:
-               /* Generic pass-through */
-               formats++;
-               if (xlate) {
-                       xlate->host_fmt = icd->formats + idx;
-                       xlate->cam_fmt = icd->formats + idx;
-                       xlate->buswidth = icd->formats[idx].depth;
-                       xlate++;
-                       dev_dbg(dev,
-                               "Providing format %s in pass-through mode\n",
-                               icd->formats[idx].name);
-               }
+               if (!sh_mobile_ceu_packing_supported(fmt))
+                       return 0;
+       }
+
+       /* Generic pass-through */
+       formats++;
+       if (xlate) {
+               xlate->host_fmt = fmt;
+               xlate->code     = code;
+               xlate++;
+               dev_dbg(dev, "Providing format %s in pass-through mode\n",
+                       xlate->host_fmt->name);
        }
 
        return formats;
@@ -1029,17 +1127,15 @@ static int client_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *crop,
 static int get_camera_scales(struct v4l2_subdev *sd, struct v4l2_rect *rect,
                             unsigned int *scale_h, unsigned int *scale_v)
 {
-       struct v4l2_format f;
+       struct v4l2_mbus_framefmt mf;
        int ret;
 
-       f.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
-       ret = v4l2_subdev_call(sd, video, g_fmt, &f);
+       ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
        if (ret < 0)
                return ret;
 
-       *scale_h = calc_generic_scale(rect->width, f.fmt.pix.width);
-       *scale_v = calc_generic_scale(rect->height, f.fmt.pix.height);
+       *scale_h = calc_generic_scale(rect->width, mf.width);
+       *scale_v = calc_generic_scale(rect->height, mf.height);
 
        return 0;
 }
@@ -1054,32 +1150,29 @@ static int get_camera_subwin(struct soc_camera_device *icd,
        if (!ceu_rect->width) {
                struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
                struct device *dev = icd->dev.parent;
-               struct v4l2_format f;
-               struct v4l2_pix_format *pix = &f.fmt.pix;
+               struct v4l2_mbus_framefmt mf;
                int ret;
                /* First time */
 
-               f.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
-               ret = v4l2_subdev_call(sd, video, g_fmt, &f);
+               ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
                if (ret < 0)
                        return ret;
 
-               dev_geo(dev, "camera fmt %ux%u\n", pix->width, pix->height);
+               dev_geo(dev, "camera fmt %ux%u\n", mf.width, mf.height);
 
-               if (pix->width > 2560) {
+               if (mf.width > 2560) {
                        ceu_rect->width  = 2560;
-                       ceu_rect->left   = (pix->width - 2560) / 2;
+                       ceu_rect->left   = (mf.width - 2560) / 2;
                } else {
-                       ceu_rect->width  = pix->width;
+                       ceu_rect->width  = mf.width;
                        ceu_rect->left   = 0;
                }
 
-               if (pix->height > 1920) {
+               if (mf.height > 1920) {
                        ceu_rect->height = 1920;
-                       ceu_rect->top    = (pix->height - 1920) / 2;
+                       ceu_rect->top    = (mf.height - 1920) / 2;
                } else {
-                       ceu_rect->height = pix->height;
+                       ceu_rect->height = mf.height;
                        ceu_rect->top    = 0;
                }
 
@@ -1096,13 +1189,12 @@ static int get_camera_subwin(struct soc_camera_device *icd,
        return 0;
 }
 
-static int client_s_fmt(struct soc_camera_device *icd, struct v4l2_format *f,
-                       bool ceu_can_scale)
+static int client_s_fmt(struct soc_camera_device *icd,
+                       struct v4l2_mbus_framefmt *mf, bool ceu_can_scale)
 {
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        struct device *dev = icd->dev.parent;
-       struct v4l2_pix_format *pix = &f->fmt.pix;
-       unsigned int width = pix->width, height = pix->height, tmp_w, tmp_h;
+       unsigned int width = mf->width, height = mf->height, tmp_w, tmp_h;
        unsigned int max_width, max_height;
        struct v4l2_cropcap cap;
        int ret;
@@ -1116,29 +1208,29 @@ static int client_s_fmt(struct soc_camera_device *icd, struct v4l2_format *f,
        max_width = min(cap.bounds.width, 2560);
        max_height = min(cap.bounds.height, 1920);
 
-       ret = v4l2_subdev_call(sd, video, s_fmt, f);
+       ret = v4l2_subdev_call(sd, video, s_mbus_fmt, mf);
        if (ret < 0)
                return ret;
 
-       dev_geo(dev, "camera scaled to %ux%u\n", pix->width, pix->height);
+       dev_geo(dev, "camera scaled to %ux%u\n", mf->width, mf->height);
 
-       if ((width == pix->width && height == pix->height) || !ceu_can_scale)
+       if ((width == mf->width && height == mf->height) || !ceu_can_scale)
                return 0;
 
        /* Camera set a format, but geometry is not precise, try to improve */
-       tmp_w = pix->width;
-       tmp_h = pix->height;
+       tmp_w = mf->width;
+       tmp_h = mf->height;
 
        /* width <= max_width && height <= max_height - guaranteed by try_fmt */
        while ((width > tmp_w || height > tmp_h) &&
               tmp_w < max_width && tmp_h < max_height) {
                tmp_w = min(2 * tmp_w, max_width);
                tmp_h = min(2 * tmp_h, max_height);
-               pix->width = tmp_w;
-               pix->height = tmp_h;
-               ret = v4l2_subdev_call(sd, video, s_fmt, f);
+               mf->width = tmp_w;
+               mf->height = tmp_h;
+               ret = v4l2_subdev_call(sd, video, s_mbus_fmt, mf);
                dev_geo(dev, "Camera scaled to %ux%u\n",
-                       pix->width, pix->height);
+                       mf->width, mf->height);
                if (ret < 0) {
                        /* This shouldn't happen */
                        dev_err(dev, "Client failed to set format: %d\n", ret);
@@ -1156,27 +1248,26 @@ static int client_s_fmt(struct soc_camera_device *icd, struct v4l2_format *f,
  */
 static int client_scale(struct soc_camera_device *icd, struct v4l2_rect *rect,
                        struct v4l2_rect *sub_rect, struct v4l2_rect *ceu_rect,
-                       struct v4l2_format *f, bool ceu_can_scale)
+                       struct v4l2_mbus_framefmt *mf, bool ceu_can_scale)
 {
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        struct sh_mobile_ceu_cam *cam = icd->host_priv;
        struct device *dev = icd->dev.parent;
-       struct v4l2_format f_tmp = *f;
-       struct v4l2_pix_format *pix_tmp = &f_tmp.fmt.pix;
+       struct v4l2_mbus_framefmt mf_tmp = *mf;
        unsigned int scale_h, scale_v;
        int ret;
 
        /* 5. Apply iterative camera S_FMT for camera user window. */
-       ret = client_s_fmt(icd, &f_tmp, ceu_can_scale);
+       ret = client_s_fmt(icd, &mf_tmp, ceu_can_scale);
        if (ret < 0)
                return ret;
 
        dev_geo(dev, "5: camera scaled to %ux%u\n",
-               pix_tmp->width, pix_tmp->height);
+               mf_tmp.width, mf_tmp.height);
 
        /* 6. Retrieve camera output window (g_fmt) */
 
-       /* unneeded - it is already in "f_tmp" */
+       /* unneeded - it is already in "mf_tmp" */
 
        /* 7. Calculate new camera scales. */
        ret = get_camera_scales(sd, rect, &scale_h, &scale_v);
@@ -1185,10 +1276,11 @@ static int client_scale(struct soc_camera_device *icd, struct v4l2_rect *rect,
 
        dev_geo(dev, "7: camera scales %u:%u\n", scale_h, scale_v);
 
-       cam->cam_width          = pix_tmp->width;
-       cam->cam_height         = pix_tmp->height;
-       f->fmt.pix.width        = pix_tmp->width;
-       f->fmt.pix.height       = pix_tmp->height;
+       cam->cam_width  = mf_tmp.width;
+       cam->cam_height = mf_tmp.height;
+       mf->width       = mf_tmp.width;
+       mf->height      = mf_tmp.height;
+       mf->colorspace  = mf_tmp.colorspace;
 
        /*
         * 8. Calculate new CEU crop - apply camera scales to previously
@@ -1252,8 +1344,7 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd,
        struct v4l2_rect *cam_rect = &cam_crop.c, *ceu_rect = &cam->ceu_rect;
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        struct device *dev = icd->dev.parent;
-       struct v4l2_format f;
-       struct v4l2_pix_format *pix = &f.fmt.pix;
+       struct v4l2_mbus_framefmt mf;
        unsigned int scale_comb_h, scale_comb_v, scale_ceu_h, scale_ceu_v,
                out_width, out_height;
        u32 capsr, cflcr;
@@ -1302,26 +1393,25 @@ static int sh_mobile_ceu_set_crop(struct soc_camera_device *icd,
         * 5. Using actual input window and calculated combined scales calculate
         *    camera target output window.
         */
-       pix->width              = scale_down(cam_rect->width, scale_comb_h);
-       pix->height             = scale_down(cam_rect->height, scale_comb_v);
+       mf.width        = scale_down(cam_rect->width, scale_comb_h);
+       mf.height       = scale_down(cam_rect->height, scale_comb_v);
 
-       dev_geo(dev, "5: camera target %ux%u\n", pix->width, pix->height);
+       dev_geo(dev, "5: camera target %ux%u\n", mf.width, mf.height);
 
        /* 6. - 9. */
-       pix->pixelformat        = cam->camera_fmt->fourcc;
-       pix->colorspace         = cam->camera_fmt->colorspace;
+       mf.code         = cam->code;
+       mf.field        = pcdev->field;
 
        capsr = capture_save_reset(pcdev);
        dev_dbg(dev, "CAPSR 0x%x, CFLCR 0x%x\n", capsr, pcdev->cflcr);
 
        /* Make relative to camera rectangle */
-       rect->left              -= cam_rect->left;
-       rect->top               -= cam_rect->top;
+       rect->left      -= cam_rect->left;
+       rect->top       -= cam_rect->top;
 
-       f.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
-       ret = client_scale(icd, cam_rect, rect, ceu_rect, &f,
-                          pcdev->image_mode && !pcdev->is_interlaced);
+       ret = client_scale(icd, cam_rect, rect, ceu_rect, &mf,
+                          pcdev->image_mode &&
+                          V4L2_FIELD_NONE == pcdev->field);
 
        dev_geo(dev, "6-9: %d\n", ret);
 
@@ -1368,8 +1458,7 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
        struct sh_mobile_ceu_cam *cam = icd->host_priv;
        struct v4l2_pix_format *pix = &f->fmt.pix;
-       struct v4l2_format cam_f = *f;
-       struct v4l2_pix_format *cam_pix = &cam_f.fmt.pix;
+       struct v4l2_mbus_framefmt mf;
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        struct device *dev = icd->dev.parent;
        __u32 pixfmt = pix->pixelformat;
@@ -1379,18 +1468,20 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
        unsigned int scale_cam_h, scale_cam_v;
        u16 scale_v, scale_h;
        int ret;
-       bool is_interlaced, image_mode;
+       bool image_mode;
+       enum v4l2_field field;
 
        switch (pix->field) {
-       case V4L2_FIELD_INTERLACED:
-               is_interlaced = true;
-               break;
-       case V4L2_FIELD_ANY:
        default:
                pix->field = V4L2_FIELD_NONE;
                /* fall-through */
+       case V4L2_FIELD_INTERLACED_TB:
+       case V4L2_FIELD_INTERLACED_BT:
        case V4L2_FIELD_NONE:
-               is_interlaced = false;
+               field = pix->field;
+               break;
+       case V4L2_FIELD_INTERLACED:
+               field = V4L2_FIELD_INTERLACED_TB;
                break;
        }
 
@@ -1438,9 +1529,11 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
         * 4. Calculate camera output window by applying combined scales to real
         *    input window.
         */
-       cam_pix->width = scale_down(cam_rect->width, scale_h);
-       cam_pix->height = scale_down(cam_rect->height, scale_v);
-       cam_pix->pixelformat = xlate->cam_fmt->fourcc;
+       mf.width        = scale_down(cam_rect->width, scale_h);
+       mf.height       = scale_down(cam_rect->height, scale_v);
+       mf.field        = pix->field;
+       mf.colorspace   = pix->colorspace;
+       mf.code         = xlate->code;
 
        switch (pixfmt) {
        case V4L2_PIX_FMT_NV12:
@@ -1453,51 +1546,61 @@ static int sh_mobile_ceu_set_fmt(struct soc_camera_device *icd,
                image_mode = false;
        }
 
-       dev_geo(dev, "4: camera output %ux%u\n",
-               cam_pix->width, cam_pix->height);
+       dev_geo(dev, "4: camera output %ux%u\n", mf.width, mf.height);
 
        /* 5. - 9. */
-       ret = client_scale(icd, cam_rect, &cam_subrect, &ceu_rect, &cam_f,
-                          image_mode && !is_interlaced);
+       ret = client_scale(icd, cam_rect, &cam_subrect, &ceu_rect, &mf,
+                          image_mode && V4L2_FIELD_NONE == field);
 
        dev_geo(dev, "5-9: client scale %d\n", ret);
 
        /* Done with the camera. Now see if we can improve the result */
 
        dev_dbg(dev, "Camera %d fmt %ux%u, requested %ux%u\n",
-               ret, cam_pix->width, cam_pix->height, pix->width, pix->height);
+               ret, mf.width, mf.height, pix->width, pix->height);
        if (ret < 0)
                return ret;
 
+       if (mf.code != xlate->code)
+               return -EINVAL;
+
        /* 10. Use CEU scaling to scale to the requested user window. */
 
        /* We cannot scale up */
-       if (pix->width > cam_pix->width)
-               pix->width = cam_pix->width;
+       if (pix->width > mf.width)
+               pix->width = mf.width;
        if (pix->width > ceu_rect.width)
                pix->width = ceu_rect.width;
 
-       if (pix->height > cam_pix->height)
-               pix->height = cam_pix->height;
+       if (pix->height > mf.height)
+               pix->height = mf.height;
        if (pix->height > ceu_rect.height)
                pix->height = ceu_rect.height;
 
-       /* Let's rock: scale pix->{width x height} down to width x height */
-       scale_h = calc_scale(ceu_rect.width, &pix->width);
-       scale_v = calc_scale(ceu_rect.height, &pix->height);
+       pix->colorspace = mf.colorspace;
+
+       if (image_mode) {
+               /* Scale pix->{width x height} down to width x height */
+               scale_h = calc_scale(ceu_rect.width, &pix->width);
+               scale_v = calc_scale(ceu_rect.height, &pix->height);
+
+               pcdev->cflcr = scale_h | (scale_v << 16);
+       } else {
+               pix->width = ceu_rect.width;
+               pix->height = ceu_rect.height;
+               scale_h = scale_v = 0;
+               pcdev->cflcr = 0;
+       }
 
        dev_geo(dev, "10: W: %u : 0x%x = %u, H: %u : 0x%x = %u\n",
                ceu_rect.width, scale_h, pix->width,
                ceu_rect.height, scale_v, pix->height);
 
-       pcdev->cflcr = scale_h | (scale_v << 16);
+       cam->code               = xlate->code;
+       cam->ceu_rect           = ceu_rect;
+       icd->current_fmt        = xlate;
 
-       icd->buswidth = xlate->buswidth;
-       icd->current_fmt = xlate->host_fmt;
-       cam->camera_fmt = xlate->cam_fmt;
-       cam->ceu_rect = ceu_rect;
-
-       pcdev->is_interlaced = is_interlaced;
+       pcdev->field = field;
        pcdev->image_mode = image_mode;
 
        return 0;
@@ -1509,6 +1612,7 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
        const struct soc_camera_format_xlate *xlate;
        struct v4l2_pix_format *pix = &f->fmt.pix;
        struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
+       struct v4l2_mbus_framefmt mf;
        __u32 pixfmt = pix->pixelformat;
        int width, height;
        int ret;
@@ -1527,18 +1631,27 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
        width = pix->width;
        height = pix->height;
 
-       pix->bytesperline = pix->width *
-               DIV_ROUND_UP(xlate->host_fmt->depth, 8);
-       pix->sizeimage = pix->height * pix->bytesperline;
-
-       pix->pixelformat = xlate->cam_fmt->fourcc;
+       pix->bytesperline = soc_mbus_bytes_per_line(width, xlate->host_fmt);
+       if (pix->bytesperline < 0)
+               return pix->bytesperline;
+       pix->sizeimage = height * pix->bytesperline;
 
        /* limit to sensor capabilities */
-       ret = v4l2_subdev_call(sd, video, try_fmt, f);
-       pix->pixelformat = pixfmt;
+       mf.width        = pix->width;
+       mf.height       = pix->height;
+       mf.field        = pix->field;
+       mf.code         = xlate->code;
+       mf.colorspace   = pix->colorspace;
+
+       ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
        if (ret < 0)
                return ret;
 
+       pix->width      = mf.width;
+       pix->height     = mf.height;
+       pix->field      = mf.field;
+       pix->colorspace = mf.colorspace;
+
        switch (pixfmt) {
        case V4L2_PIX_FMT_NV12:
        case V4L2_PIX_FMT_NV21:
@@ -1547,21 +1660,25 @@ static int sh_mobile_ceu_try_fmt(struct soc_camera_device *icd,
                /* FIXME: check against rect_max after converting soc-camera */
                /* We can scale precisely, need a bigger image from camera */
                if (pix->width < width || pix->height < height) {
-                       int tmp_w = pix->width, tmp_h = pix->height;
-                       pix->width = 2560;
-                       pix->height = 1920;
-                       ret = v4l2_subdev_call(sd, video, try_fmt, f);
+                       /*
+                        * We presume, the sensor behaves sanely, i.e., if
+                        * requested a bigger rectangle, it will not return a
+                        * smaller one.
+                        */
+                       mf.width = 2560;
+                       mf.height = 1920;
+                       ret = v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
                        if (ret < 0) {
                                /* Shouldn't actually happen... */
                                dev_err(icd->dev.parent,
-                                       "FIXME: try_fmt() returned %d\n", ret);
-                               pix->width = tmp_w;
-                               pix->height = tmp_h;
+                                       "FIXME: client try_fmt() = %d\n", ret);
+                               return ret;
                        }
                }
-               if (pix->width > width)
+               /* We will scale exactly */
+               if (mf.width > width)
                        pix->width = width;
-               if (pix->height > height)
+               if (mf.height > height)
                        pix->height = height;
        }
 
@@ -1573,10 +1690,12 @@ static int sh_mobile_ceu_reqbufs(struct soc_camera_file *icf,
 {
        int i;
 
-       /* This is for locking debugging only. I removed spinlocks and now I
+       /*
+        * This is for locking debugging only. I removed spinlocks and now I
         * check whether .prepare is ever called on a linked buffer, or whether
         * a dma IRQ can occur for an in-work or unlinked buffer. Until now
-        * it hadn't triggered */
+        * it hadn't triggered
+        */
        for (i = 0; i < p->count; i++) {
                struct sh_mobile_ceu_buffer *buf;
 
@@ -1624,8 +1743,7 @@ static void sh_mobile_ceu_init_videobuf(struct videobuf_queue *q,
                                       &sh_mobile_ceu_videobuf_ops,
                                       icd->dev.parent, &pcdev->lock,
                                       V4L2_BUF_TYPE_VIDEO_CAPTURE,
-                                      pcdev->is_interlaced ?
-                                      V4L2_FIELD_INTERLACED : V4L2_FIELD_NONE,
+                                      pcdev->field,
                                       sizeof(struct sh_mobile_ceu_buffer),
                                       icd);
 }
@@ -1654,7 +1772,7 @@ static int sh_mobile_ceu_set_ctrl(struct soc_camera_device *icd,
 
        switch (ctrl->id) {
        case V4L2_CID_SHARPNESS:
-               switch (icd->current_fmt->fourcc) {
+               switch (icd->current_fmt->host_fmt->fourcc) {
                case V4L2_PIX_FMT_NV12:
                case V4L2_PIX_FMT_NV21:
                case V4L2_PIX_FMT_NV16:
@@ -1825,7 +1943,7 @@ static int sh_mobile_ceu_runtime_nop(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops sh_mobile_ceu_dev_pm_ops = {
+static const struct dev_pm_ops sh_mobile_ceu_dev_pm_ops = {
        .runtime_suspend = sh_mobile_ceu_runtime_nop,
        .runtime_resume = sh_mobile_ceu_runtime_nop,
 };
@@ -1836,7 +1954,7 @@ static struct platform_driver sh_mobile_ceu_driver = {
                .pm     = &sh_mobile_ceu_dev_pm_ops,
        },
        .probe          = sh_mobile_ceu_probe,
-       .remove         = __exit_p(sh_mobile_ceu_remove),
+       .remove         = __devexit_p(sh_mobile_ceu_remove),
 };
 
 static int __init sh_mobile_ceu_init(void)
index 4a7711c3e745f33f6e362ed246490a5e4d0971fe..cbf8087b286fd8ae477a2e1aa0bd21321176eb06 100644 (file)
@@ -1007,8 +1007,8 @@ static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
        else if (cam->stream != STREAM_OFF) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "URB timeout reached. The camera is misconfigured. "
-                      "To use it, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "To use it, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -1734,7 +1734,8 @@ static void sn9c102_release_resources(struct kref *kref)
 
        cam = container_of(kref, struct sn9c102_device, kref);
 
-       DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->num);
+       DBG(2, "V4L2 device %s deregistered",
+           video_device_node_name(cam->v4ldev));
        video_set_drvdata(cam->v4ldev, NULL);
        video_unregister_device(cam->v4ldev);
        usb_put_dev(cam->usbdev);
@@ -1791,8 +1792,8 @@ static int sn9c102_open(struct file *filp)
        }
 
        if (cam->users) {
-               DBG(2, "Device /dev/video%d is already in use",
-                      cam->v4ldev->num);
+               DBG(2, "Device %s is already in use",
+                   video_device_node_name(cam->v4ldev));
                DBG(3, "Simultaneous opens are not supported");
                /*
                   open() must follow the open flags and should block
@@ -1845,7 +1846,7 @@ static int sn9c102_open(struct file *filp)
        cam->frame_count = 0;
        sn9c102_empty_framequeues(cam);
 
-       DBG(3, "Video device /dev/video%d is open", cam->v4ldev->num);
+       DBG(3, "Video device %s is open", video_device_node_name(cam->v4ldev));
 
 out:
        mutex_unlock(&cam->open_mutex);
@@ -1870,7 +1871,7 @@ static int sn9c102_release(struct file *filp)
        cam->users--;
        wake_up_interruptible_nr(&cam->wait_open, 1);
 
-       DBG(3, "Video device /dev/video%d closed", cam->v4ldev->num);
+       DBG(3, "Video device %s closed", video_device_node_name(cam->v4ldev));
 
        kref_put(&cam->kref, sn9c102_release_resources);
 
@@ -2433,8 +2434,8 @@ sn9c102_vidioc_s_crop(struct sn9c102_device* cam, void __user * arg)
        if (err) { /* atomic, no rollback in ioctl() */
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -2446,8 +2447,8 @@ sn9c102_vidioc_s_crop(struct sn9c102_device* cam, void __user * arg)
            nbuffers != sn9c102_request_buffers(cam, nbuffers, cam->io)) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -ENOMEM;
        }
 
@@ -2690,8 +2691,8 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
        if (err) { /* atomic, no rollback in ioctl() */
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -2702,8 +2703,8 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
            nbuffers != sn9c102_request_buffers(cam, nbuffers, cam->io)) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -ENOMEM;
        }
 
@@ -2748,9 +2749,9 @@ sn9c102_vidioc_s_jpegcomp(struct sn9c102_device* cam, void __user * arg)
        err += sn9c102_set_compression(cam, &jc);
        if (err) { /* atomic, no rollback in ioctl() */
                cam->state |= DEV_MISCONFIGURED;
-               DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
-                      "problems. To use the camera, close and open "
-                      "/dev/video%d again.", cam->v4ldev->num);
+               DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware problems. "
+                      "To use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -3328,7 +3329,6 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
 
        strcpy(cam->v4ldev->name, "SN9C1xx PC Camera");
        cam->v4ldev->fops = &sn9c102_fops;
-       cam->v4ldev->minor = video_nr[dev_nr];
        cam->v4ldev->release = video_device_release;
        cam->v4ldev->parent = &udev->dev;
 
@@ -3346,7 +3346,8 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
                goto fail;
        }
 
-       DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->num);
+       DBG(2, "V4L2 device registered as %s",
+           video_device_node_name(cam->v4ldev));
 
        video_set_drvdata(cam->v4ldev, cam);
        cam->module_param.force_munmap = force_munmap[dev_nr];
@@ -3398,9 +3399,9 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf)
        DBG(2, "Disconnecting %s...", cam->v4ldev->name);
 
        if (cam->users) {
-               DBG(2, "Device /dev/video%d is open! Deregistration and "
-                      "memory deallocation are deferred.",
-                   cam->v4ldev->num);
+               DBG(2, "Device %s is open! Deregistration and memory "
+                      "deallocation are deferred.",
+                   video_device_node_name(cam->v4ldev));
                cam->state |= DEV_MISCONFIGURED;
                sn9c102_stop_transfer(cam);
                cam->state |= DEV_DISCONNECTED;
index 95fdeb23c2c1455f2930c4645369d266f62bc74e..6b3fbcca7747bf43205d121adeb02c7af4ef66b5 100644 (file)
@@ -31,6 +31,7 @@
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
 #include <media/videobuf-core.h>
+#include <media/soc_mediabus.h>
 
 /* Default to VGA resolution */
 #define DEFAULT_WIDTH  640
@@ -40,18 +41,6 @@ static LIST_HEAD(hosts);
 static LIST_HEAD(devices);
 static DEFINE_MUTEX(list_lock);                /* Protects the list of hosts */
 
-const struct soc_camera_data_format *soc_camera_format_by_fourcc(
-       struct soc_camera_device *icd, unsigned int fourcc)
-{
-       unsigned int i;
-
-       for (i = 0; i < icd->num_formats; i++)
-               if (icd->formats[i].fourcc == fourcc)
-                       return icd->formats + i;
-       return NULL;
-}
-EXPORT_SYMBOL(soc_camera_format_by_fourcc);
-
 const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
        struct soc_camera_device *icd, unsigned int fourcc)
 {
@@ -207,21 +196,26 @@ static int soc_camera_dqbuf(struct file *file, void *priv,
 /* Always entered with .video_lock held */
 static int soc_camera_init_user_formats(struct soc_camera_device *icd)
 {
+       struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
        struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
-       int i, fmts = 0, ret;
+       int i, fmts = 0, raw_fmts = 0, ret;
+       enum v4l2_mbus_pixelcode code;
+
+       while (!v4l2_subdev_call(sd, video, enum_mbus_fmt, raw_fmts, &code))
+               raw_fmts++;
 
        if (!ici->ops->get_formats)
                /*
                 * Fallback mode - the host will have to serve all
                 * sensor-provided formats one-to-one to the user
                 */
-               fmts = icd->num_formats;
+               fmts = raw_fmts;
        else
                /*
                 * First pass - only count formats this host-sensor
                 * configuration can provide
                 */
-               for (i = 0; i < icd->num_formats; i++) {
+               for (i = 0; i < raw_fmts; i++) {
                        ret = ici->ops->get_formats(icd, i, NULL);
                        if (ret < 0)
                                return ret;
@@ -242,11 +236,12 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
 
        /* Second pass - actually fill data formats */
        fmts = 0;
-       for (i = 0; i < icd->num_formats; i++)
+       for (i = 0; i < raw_fmts; i++)
                if (!ici->ops->get_formats) {
-                       icd->user_formats[i].host_fmt = icd->formats + i;
-                       icd->user_formats[i].cam_fmt = icd->formats + i;
-                       icd->user_formats[i].buswidth = icd->formats[i].depth;
+                       v4l2_subdev_call(sd, video, enum_mbus_fmt, i, &code);
+                       icd->user_formats[i].host_fmt =
+                               soc_mbus_get_fmtdesc(code);
+                       icd->user_formats[i].code = code;
                } else {
                        ret = ici->ops->get_formats(icd, i,
                                                    &icd->user_formats[fmts]);
@@ -255,7 +250,7 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
                        fmts += ret;
                }
 
-       icd->current_fmt = icd->user_formats[0].host_fmt;
+       icd->current_fmt = &icd->user_formats[0];
 
        return 0;
 
@@ -281,7 +276,7 @@ static void soc_camera_free_user_formats(struct soc_camera_device *icd)
 #define pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, \
        ((x) >> 24) & 0xff
 
-/* Called with .vb_lock held */
+/* Called with .vb_lock held, or from the first open(2), see comment there */
 static int soc_camera_set_fmt(struct soc_camera_file *icf,
                              struct v4l2_format *f)
 {
@@ -302,7 +297,7 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf,
        if (ret < 0) {
                return ret;
        } else if (!icd->current_fmt ||
-                  icd->current_fmt->fourcc != pix->pixelformat) {
+                  icd->current_fmt->host_fmt->fourcc != pix->pixelformat) {
                dev_err(&icd->dev,
                        "Host driver hasn't set up current format correctly!\n");
                return -EINVAL;
@@ -310,6 +305,7 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf,
 
        icd->user_width         = pix->width;
        icd->user_height        = pix->height;
+       icd->colorspace         = pix->colorspace;
        icf->vb_vidq.field      =
                icd->field      = pix->field;
 
@@ -369,8 +365,9 @@ static int soc_camera_open(struct file *file)
                                .width          = icd->user_width,
                                .height         = icd->user_height,
                                .field          = icd->field,
-                               .pixelformat    = icd->current_fmt->fourcc,
-                               .colorspace     = icd->current_fmt->colorspace,
+                               .colorspace     = icd->colorspace,
+                               .pixelformat    =
+                                       icd->current_fmt->host_fmt->fourcc,
                        },
                };
 
@@ -390,7 +387,12 @@ static int soc_camera_open(struct file *file)
                        goto eiciadd;
                }
 
-               /* Try to configure with default parameters */
+               /*
+                * Try to configure with default parameters. Notice: this is the
+                * very first open, so, we cannot race against other calls,
+                * apart from someone else calling open() simultaneously, but
+                * .video_lock is protecting us against it.
+                */
                ret = soc_camera_set_fmt(icf, &f);
                if (ret < 0)
                        goto esfmt;
@@ -534,7 +536,7 @@ static int soc_camera_enum_fmt_vid_cap(struct file *file, void  *priv,
 {
        struct soc_camera_file *icf = file->private_data;
        struct soc_camera_device *icd = icf->icd;
-       const struct soc_camera_data_format *format;
+       const struct soc_mbus_pixelfmt *format;
 
        WARN_ON(priv != file->private_data);
 
@@ -543,7 +545,8 @@ static int soc_camera_enum_fmt_vid_cap(struct file *file, void  *priv,
 
        format = icd->user_formats[f->index].host_fmt;
 
-       strlcpy(f->description, format->name, sizeof(f->description));
+       if (format->name)
+               strlcpy(f->description, format->name, sizeof(f->description));
        f->pixelformat = format->fourcc;
        return 0;
 }
@@ -560,12 +563,15 @@ static int soc_camera_g_fmt_vid_cap(struct file *file, void *priv,
        pix->width              = icd->user_width;
        pix->height             = icd->user_height;
        pix->field              = icf->vb_vidq.field;
-       pix->pixelformat        = icd->current_fmt->fourcc;
-       pix->bytesperline       = pix->width *
-               DIV_ROUND_UP(icd->current_fmt->depth, 8);
+       pix->pixelformat        = icd->current_fmt->host_fmt->fourcc;
+       pix->bytesperline       = soc_mbus_bytes_per_line(pix->width,
+                                               icd->current_fmt->host_fmt);
+       pix->colorspace         = icd->colorspace;
+       if (pix->bytesperline < 0)
+               return pix->bytesperline;
        pix->sizeimage          = pix->height * pix->bytesperline;
        dev_dbg(&icd->dev, "current_fmt->fourcc: 0x%08x\n",
-               icd->current_fmt->fourcc);
+               icd->current_fmt->host_fmt->fourcc);
        return 0;
 }
 
@@ -621,8 +627,10 @@ static int soc_camera_streamoff(struct file *file, void *priv,
 
        mutex_lock(&icd->video_lock);
 
-       /* This calls buf_release from host driver's videobuf_queue_ops for all
-        * remaining buffers. When the last buffer is freed, stop capture */
+       /*
+        * This calls buf_release from host driver's videobuf_queue_ops for all
+        * remaining buffers. When the last buffer is freed, stop capture
+        */
        videobuf_streamoff(&icf->vb_vidq);
 
        v4l2_subdev_call(sd, video, s_stream, 0);
@@ -892,7 +900,7 @@ static int soc_camera_probe(struct device *dev)
        struct soc_camera_link *icl = to_soc_camera_link(icd);
        struct device *control = NULL;
        struct v4l2_subdev *sd;
-       struct v4l2_format f = {.type = V4L2_BUF_TYPE_VIDEO_CAPTURE};
+       struct v4l2_mbus_framefmt mf;
        int ret;
 
        dev_info(dev, "Probing %s\n", dev_name(dev));
@@ -963,9 +971,11 @@ static int soc_camera_probe(struct device *dev)
 
        /* Try to improve our guess of a reasonable window format */
        sd = soc_camera_to_subdev(icd);
-       if (!v4l2_subdev_call(sd, video, g_fmt, &f)) {
-               icd->user_width         = f.fmt.pix.width;
-               icd->user_height        = f.fmt.pix.height;
+       if (!v4l2_subdev_call(sd, video, g_mbus_fmt, &mf)) {
+               icd->user_width         = mf.width;
+               icd->user_height        = mf.height;
+               icd->colorspace         = mf.colorspace;
+               icd->field              = mf.field;
        }
 
        /* Do we have to sysfs_remove_link() before device_unregister()? */
@@ -1004,8 +1014,10 @@ epower:
        return ret;
 }
 
-/* This is called on device_unregister, which only means we have to disconnect
- * from the host, but not remove ourselves from the device list */
+/*
+ * This is called on device_unregister, which only means we have to disconnect
+ * from the host, but not remove ourselves from the device list
+ */
 static int soc_camera_remove(struct device *dev)
 {
        struct soc_camera_device *icd = to_soc_camera_dev(dev);
@@ -1205,8 +1217,10 @@ static int soc_camera_device_register(struct soc_camera_device *icd)
        }
 
        if (num < 0)
-               /* ok, we have 256 cameras on this host...
-                * man, stay reasonable... */
+               /*
+                * ok, we have 256 cameras on this host...
+                * man, stay reasonable...
+                */
                return -ENOMEM;
 
        icd->devnum             = num;
@@ -1268,7 +1282,6 @@ static int video_dev_create(struct soc_camera_device *icd)
        vdev->fops              = &soc_camera_fops;
        vdev->ioctl_ops         = &soc_camera_ioctl_ops;
        vdev->release           = video_device_release;
-       vdev->minor             = -1;
        vdev->tvnorms           = V4L2_STD_UNKNOWN;
 
        icd->vdev = vdev;
@@ -1291,8 +1304,7 @@ static int soc_camera_video_start(struct soc_camera_device *icd)
            !icd->ops->set_bus_param)
                return -EINVAL;
 
-       ret = video_register_device(icd->vdev, VFL_TYPE_GRABBER,
-                                   icd->vdev->minor);
+       ret = video_register_device(icd->vdev, VFL_TYPE_GRABBER, -1);
        if (ret < 0) {
                dev_err(&icd->dev, "video_register_device failed: %d\n", ret);
                return ret;
@@ -1335,9 +1347,11 @@ escdevreg:
        return ret;
 }
 
-/* Only called on rmmod for each platform device, since they are not
+/*
+ * Only called on rmmod for each platform device, since they are not
  * hot-pluggable. Now we know, that all our users - hosts and devices have
- * been unloaded already */
+ * been unloaded already
+ */
 static int __devexit soc_camera_pdrv_remove(struct platform_device *pdev)
 {
        struct soc_camera_device *icd = platform_get_drvdata(pdev);
index b6a575ce5da2e22dd0a1e25b43cf07087533d6e1..10b003a8be83c21fbf7b7964c6dc142c8c0e93f3 100644 (file)
@@ -22,7 +22,6 @@
 
 struct soc_camera_platform_priv {
        struct v4l2_subdev subdev;
-       struct soc_camera_data_format format;
 };
 
 static struct soc_camera_platform_priv *get_priv(struct platform_device *pdev)
@@ -58,36 +57,36 @@ soc_camera_platform_query_bus_param(struct soc_camera_device *icd)
 }
 
 static int soc_camera_platform_try_fmt(struct v4l2_subdev *sd,
-                                      struct v4l2_format *f)
+                                      struct v4l2_mbus_framefmt *mf)
 {
        struct soc_camera_platform_info *p = v4l2_get_subdevdata(sd);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
 
-       pix->width = p->format.width;
-       pix->height = p->format.height;
+       mf->width       = p->format.width;
+       mf->height      = p->format.height;
+       mf->code        = p->format.code;
+       mf->colorspace  = p->format.colorspace;
+
        return 0;
 }
 
-static void soc_camera_platform_video_probe(struct soc_camera_device *icd,
-                                           struct platform_device *pdev)
+static struct v4l2_subdev_core_ops platform_subdev_core_ops;
+
+static int soc_camera_platform_enum_fmt(struct v4l2_subdev *sd, int index,
+                                       enum v4l2_mbus_pixelcode *code)
 {
-       struct soc_camera_platform_priv *priv = get_priv(pdev);
-       struct soc_camera_platform_info *p = pdev->dev.platform_data;
+       struct soc_camera_platform_info *p = v4l2_get_subdevdata(sd);
 
-       priv->format.name = p->format_name;
-       priv->format.depth = p->format_depth;
-       priv->format.fourcc = p->format.pixelformat;
-       priv->format.colorspace = p->format.colorspace;
+       if (index)
+               return -EINVAL;
 
-       icd->formats = &priv->format;
-       icd->num_formats = 1;
+       *code = p->format.code;
+       return 0;
 }
 
-static struct v4l2_subdev_core_ops platform_subdev_core_ops;
-
 static struct v4l2_subdev_video_ops platform_subdev_video_ops = {
        .s_stream       = soc_camera_platform_s_stream,
-       .try_fmt        = soc_camera_platform_try_fmt,
+       .try_mbus_fmt   = soc_camera_platform_try_fmt,
+       .enum_mbus_fmt  = soc_camera_platform_enum_fmt,
 };
 
 static struct v4l2_subdev_ops platform_subdev_ops = {
@@ -128,13 +127,10 @@ static int soc_camera_platform_probe(struct platform_device *pdev)
        /* Set the control device reference */
        dev_set_drvdata(&icd->dev, &pdev->dev);
 
-       icd->y_skip_top         = 0;
-       icd->ops                = &soc_camera_platform_ops;
+       icd->ops = &soc_camera_platform_ops;
 
        ici = to_soc_camera_host(icd->dev.parent);
 
-       soc_camera_platform_video_probe(icd, pdev);
-
        v4l2_subdev_init(&priv->subdev, &platform_subdev_ops);
        v4l2_set_subdevdata(&priv->subdev, p);
        strncpy(priv->subdev.name, dev_name(&pdev->dev), V4L2_SUBDEV_NAME_SIZE);
diff --git a/drivers/media/video/soc_mediabus.c b/drivers/media/video/soc_mediabus.c
new file mode 100644 (file)
index 0000000..f8d5c87
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * soc-camera media bus helper routines
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include <media/v4l2-device.h>
+#include <media/v4l2-mediabus.h>
+#include <media/soc_mediabus.h>
+
+#define MBUS_IDX(f) (V4L2_MBUS_FMT_ ## f - V4L2_MBUS_FMT_FIXED - 1)
+
+static const struct soc_mbus_pixelfmt mbus_fmt[] = {
+       [MBUS_IDX(YUYV8_2X8_LE)] = {
+               .fourcc                 = V4L2_PIX_FMT_YUYV,
+               .name                   = "YUYV",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(YVYU8_2X8_LE)] = {
+               .fourcc                 = V4L2_PIX_FMT_YVYU,
+               .name                   = "YVYU",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(YUYV8_2X8_BE)] = {
+               .fourcc                 = V4L2_PIX_FMT_UYVY,
+               .name                   = "UYVY",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(YVYU8_2X8_BE)] = {
+               .fourcc                 = V4L2_PIX_FMT_VYUY,
+               .name                   = "VYUY",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(RGB555_2X8_PADHI_LE)] = {
+               .fourcc                 = V4L2_PIX_FMT_RGB555,
+               .name                   = "RGB555",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(RGB555_2X8_PADHI_BE)] = {
+               .fourcc                 = V4L2_PIX_FMT_RGB555X,
+               .name                   = "RGB555X",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(RGB565_2X8_LE)] = {
+               .fourcc                 = V4L2_PIX_FMT_RGB565,
+               .name                   = "RGB565",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(RGB565_2X8_BE)] = {
+               .fourcc                 = V4L2_PIX_FMT_RGB565X,
+               .name                   = "RGB565X",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(SBGGR8_1X8)] = {
+               .fourcc                 = V4L2_PIX_FMT_SBGGR8,
+               .name                   = "Bayer 8 BGGR",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(SBGGR10_1X10)] = {
+               .fourcc                 = V4L2_PIX_FMT_SBGGR10,
+               .name                   = "Bayer 10 BGGR",
+               .bits_per_sample        = 10,
+               .packing                = SOC_MBUS_PACKING_EXTEND16,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(GREY8_1X8)] = {
+               .fourcc                 = V4L2_PIX_FMT_GREY,
+               .name                   = "Grey",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_NONE,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(Y10_1X10)] = {
+               .fourcc                 = V4L2_PIX_FMT_Y10,
+               .name                   = "Grey 10bit",
+               .bits_per_sample        = 10,
+               .packing                = SOC_MBUS_PACKING_EXTEND16,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(SBGGR10_2X8_PADHI_LE)] = {
+               .fourcc                 = V4L2_PIX_FMT_SBGGR10,
+               .name                   = "Bayer 10 BGGR",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(SBGGR10_2X8_PADLO_LE)] = {
+               .fourcc                 = V4L2_PIX_FMT_SBGGR10,
+               .name                   = "Bayer 10 BGGR",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADLO,
+               .order                  = SOC_MBUS_ORDER_LE,
+       }, [MBUS_IDX(SBGGR10_2X8_PADHI_BE)] = {
+               .fourcc                 = V4L2_PIX_FMT_SBGGR10,
+               .name                   = "Bayer 10 BGGR",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADHI,
+               .order                  = SOC_MBUS_ORDER_BE,
+       }, [MBUS_IDX(SBGGR10_2X8_PADLO_BE)] = {
+               .fourcc                 = V4L2_PIX_FMT_SBGGR10,
+               .name                   = "Bayer 10 BGGR",
+               .bits_per_sample        = 8,
+               .packing                = SOC_MBUS_PACKING_2X8_PADLO,
+               .order                  = SOC_MBUS_ORDER_BE,
+       },
+};
+
+s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf)
+{
+       switch (mf->packing) {
+       case SOC_MBUS_PACKING_NONE:
+               return width * mf->bits_per_sample / 8;
+       case SOC_MBUS_PACKING_2X8_PADHI:
+       case SOC_MBUS_PACKING_2X8_PADLO:
+       case SOC_MBUS_PACKING_EXTEND16:
+               return width * 2;
+       }
+       return -EINVAL;
+}
+EXPORT_SYMBOL(soc_mbus_bytes_per_line);
+
+const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
+       enum v4l2_mbus_pixelcode code)
+{
+       if ((unsigned int)(code - V4L2_MBUS_FMT_FIXED) > ARRAY_SIZE(mbus_fmt))
+               return NULL;
+       return mbus_fmt + code - V4L2_MBUS_FMT_FIXED - 1;
+}
+EXPORT_SYMBOL(soc_mbus_get_fmtdesc);
+
+static int __init soc_mbus_init(void)
+{
+       return 0;
+}
+
+static void __exit soc_mbus_exit(void)
+{
+}
+
+module_init(soc_mbus_init);
+module_exit(soc_mbus_exit);
+
+MODULE_DESCRIPTION("soc-camera media bus interface");
+MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");
+MODULE_LICENSE("GPL v2");
index 6b41865f42bdaf93078be0229124e6af403e7fc4..f07a0f6b71c455a253845df29705ed96c3b32083 100644 (file)
@@ -1307,7 +1307,6 @@ static void stk_v4l_dev_release(struct video_device *vd)
 
 static struct video_device stk_v4l_data = {
        .name = "stkwebcam",
-       .minor = -1,
        .tvnorms = V4L2_STD_UNKNOWN,
        .current_norm = V4L2_STD_UNKNOWN,
        .fops = &v4l_stk_fops,
@@ -1327,8 +1326,8 @@ static int stk_register_video_device(struct stk_camera *dev)
        if (err)
                STK_ERROR("v4l registration failed\n");
        else
-               STK_INFO("Syntek USB2.0 Camera is now controlling video device"
-                       " /dev/video%d\n", dev->vdev.num);
+               STK_INFO("Syntek USB2.0 Camera is now controlling device %s\n",
+                        video_device_node_name(&dev->vdev));
        return err;
 }
 
@@ -1418,8 +1417,8 @@ static void stk_camera_disconnect(struct usb_interface *interface)
        wake_up_interruptible(&dev->wait_frame);
        stk_remove_sysfs_files(&dev->vdev);
 
-       STK_INFO("Syntek USB2.0 Camera release resources "
-               "video device /dev/video%d\n", dev->vdev.num);
+       STK_INFO("Syntek USB2.0 Camera release resources device %s\n",
+                video_device_node_name(&dev->vdev));
 
        video_unregister_device(&dev->vdev);
 }
index eaada39c76fdfcf5d2273bd3c31af6dca0350da1..a057824e7ebc25ac5e2b5102d002804a79c983d2 100644 (file)
@@ -1921,7 +1921,6 @@ static const struct v4l2_file_operations saa_fops = {
 static struct video_device saa_template = {
        .name = "SAA7146A",
        .fops = &saa_fops,
-       .minor = -1,
        .release = video_device_release_empty,
 };
 
@@ -1972,7 +1971,6 @@ static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
 
        saa->id = pdev->device;
        saa->irq = pdev->irq;
-       saa->video_dev.minor = -1;
        saa->saa7146_adr = pci_resource_start(pdev, 0);
        pci_read_config_byte(pdev, PCI_CLASS_REVISION, &saa->revision);
 
@@ -2134,7 +2132,7 @@ static void stradis_release_saa(struct pci_dev *pdev)
        free_irq(saa->irq, saa);
        if (saa->saa7146_mem)
                iounmap(saa->saa7146_mem);
-       if (saa->video_dev.minor != -1)
+       if (video_is_registered(&saa->video_dev))
                video_unregister_device(&saa->video_dev);
 }
 
index 6a91714125d27dd2fc054a9f953656f24a9cc4ab..5938ad8702ef0d302e956521e3dc8867009762b7 100644 (file)
@@ -1405,7 +1405,6 @@ static struct video_device stv680_template = {
        .name =         "STV0680 USB camera",
        .fops =         &stv680_fops,
        .release =      video_device_release,
-       .minor =        -1,
 };
 
 static int stv680_probe (struct usb_interface *intf, const struct usb_device_id *id)
@@ -1467,8 +1466,8 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
                retval = -EIO;
                goto error_vdev;
        }
-       PDEBUG(0, "STV(i): registered new video device: video%d",
-               stv680->vdev->num);
+       PDEBUG(0, "STV(i): registered new video device: %s",
+               video_device_node_name(stv680->vdev));
 
        usb_set_intfdata (intf, stv680);
        retval = stv680_create_sysfs_files(stv680->vdev);
index 269ab044072a86939d263aa82da0fbd36e23b0b5..5b801a6e1eea49fd947729d30e70366d3b4c61fb 100644 (file)
@@ -29,7 +29,7 @@
 #include <media/tw9910.h>
 
 #define GET_ID(val)  ((val & 0xF8) >> 3)
-#define GET_ReV(val) (val & 0x07)
+#define GET_REV(val) (val & 0x07)
 
 /*
  * register offset
 #define LCTL24         0x68
 #define LCTL25         0x69
 #define LCTL26         0x6A
-#define HSGEGIN                0x6B
+#define HSBEGIN                0x6B
 #define HSEND          0x6C
 #define OVSDLY         0x6D
 #define OVSEND         0x6E
                         /* 1 : non-auto */
 #define VSCTL       0x08 /* 1 : Vertical out ctrl by DVALID */
                         /* 0 : Vertical out ctrl by HACTIVE and DVALID */
-#define OEN         0x04 /* Output Enable together with TRI_SEL. */
+#define OEN_TRI_SEL_MASK       0x07
+#define OEN_TRI_SEL_ALL_ON     0x00 /* Enable output for Rev0/Rev1 */
+#define OEN_TRI_SEL_ALL_OFF_r0 0x06 /* All tri-stated for Rev0 */
+#define OEN_TRI_SEL_ALL_OFF_r1 0x07 /* All tri-stated for Rev1 */
 
 /* OUTCTR1 */
 #define VSP_LO      0x00 /* 0 : VS pin output polarity is active low */
                          * but all register content remain unchanged.
                          * This bit is self-resetting.
                          */
+#define ACNTL1_PDN_MASK        0x0e
+#define CLK_PDN                0x08 /* system clock power down */
+#define Y_PDN          0x04 /* Luma ADC power down */
+#define C_PDN          0x02 /* Chroma ADC power down */
+
+/* ACNTL2 */
+#define ACNTL2_PDN_MASK        0x40
+#define PLL_PDN                0x40 /* PLL power down */
 
 /* VBICNTL */
-/* RTSEL : control the real time signal
-*          output from the MPOUT pin
-*/
+
+/* RTSEL : control the real time signal output from the MPOUT pin */
 #define RTSEL_MASK  0x07
 #define RTSEL_VLOSS 0x00 /* 0000 = Video loss */
 #define RTSEL_HLOCK 0x01 /* 0001 = H-lock */
@@ -226,28 +236,7 @@ struct tw9910_priv {
        struct v4l2_subdev                subdev;
        struct tw9910_video_info       *info;
        const struct tw9910_scale_ctrl *scale;
-};
-
-/*
- * register settings
- */
-
-#define ENDMARKER { 0xff, 0xff }
-
-static const struct regval_list tw9910_default_regs[] =
-{
-       { OPFORM,  0x00 },
-       { OUTCTR1, VSP_LO | VSSL_VVALID | HSP_HI | HSSL_HSYNC },
-       ENDMARKER,
-};
-
-static const struct soc_camera_data_format tw9910_color_fmt[] = {
-       {
-               .name       = "VYUY",
-               .fourcc     = V4L2_PIX_FMT_VYUY,
-               .depth      = 16,
-               .colorspace = V4L2_COLORSPACE_SMPTE170M,
-       }
+       u32                             revision;
 };
 
 static const struct tw9910_scale_ctrl tw9910_ntsc_scales[] = {
@@ -340,13 +329,6 @@ static const struct tw9910_scale_ctrl tw9910_pal_scales[] = {
        },
 };
 
-static const struct tw9910_cropping_ctrl tw9910_cropping_ctrl = {
-       .vdelay  = 0x0012,
-       .vactive = 0x00F0,
-       .hdelay  = 0x0010,
-       .hactive = 0x02D0,
-};
-
 static const struct tw9910_hsync_ctrl tw9910_hsync_ctrl = {
        .start = 0x0260,
        .end   = 0x0300,
@@ -361,6 +343,19 @@ static struct tw9910_priv *to_tw9910(const struct i2c_client *client)
                            subdev);
 }
 
+static int tw9910_mask_set(struct i2c_client *client, u8 command,
+                          u8 mask, u8 set)
+{
+       s32 val = i2c_smbus_read_byte_data(client, command);
+       if (val < 0)
+               return val;
+
+       val &= ~mask;
+       val |= set & mask;
+
+       return i2c_smbus_write_byte_data(client, command, val);
+}
+
 static int tw9910_set_scale(struct i2c_client *client,
                            const struct tw9910_scale_ctrl *scale)
 {
@@ -383,47 +378,14 @@ static int tw9910_set_scale(struct i2c_client *client,
        return ret;
 }
 
-static int tw9910_set_cropping(struct i2c_client *client,
-                              const struct tw9910_cropping_ctrl *cropping)
-{
-       int ret;
-
-       ret = i2c_smbus_write_byte_data(client, CROP_HI,
-                                       (cropping->vdelay  & 0x0300) >> 2 |
-                                       (cropping->vactive & 0x0300) >> 4 |
-                                       (cropping->hdelay  & 0x0300) >> 6 |
-                                       (cropping->hactive & 0x0300) >> 8);
-       if (ret < 0)
-               return ret;
-
-       ret = i2c_smbus_write_byte_data(client, VDELAY_LO,
-                                       cropping->vdelay & 0x00FF);
-       if (ret < 0)
-               return ret;
-
-       ret = i2c_smbus_write_byte_data(client, VACTIVE_LO,
-                                       cropping->vactive & 0x00FF);
-       if (ret < 0)
-               return ret;
-
-       ret = i2c_smbus_write_byte_data(client, HDELAY_LO,
-                                       cropping->hdelay & 0x00FF);
-       if (ret < 0)
-               return ret;
-
-       ret = i2c_smbus_write_byte_data(client, HACTIVE_LO,
-                                       cropping->hactive & 0x00FF);
-
-       return ret;
-}
-
 static int tw9910_set_hsync(struct i2c_client *client,
                            const struct tw9910_hsync_ctrl *hsync)
 {
+       struct tw9910_priv *priv = to_tw9910(client);
        int ret;
 
        /* bit 10 - 3 */
-       ret = i2c_smbus_write_byte_data(client, HSGEGIN,
+       ret = i2c_smbus_write_byte_data(client, HSBEGIN,
                                        (hsync->start & 0x07F8) >> 3);
        if (ret < 0)
                return ret;
@@ -434,50 +396,41 @@ static int tw9910_set_hsync(struct i2c_client *client,
        if (ret < 0)
                return ret;
 
+       /* So far only revisions 0 and 1 have been seen */
        /* bit 2 - 0 */
-       ret = i2c_smbus_read_byte_data(client, HSLOWCTL);
-       if (ret < 0)
-               return ret;
-
-       ret = i2c_smbus_write_byte_data(client, HSLOWCTL,
-                                       (ret & 0x88)                 |
-                                       (hsync->start & 0x0007) << 4 |
-                                       (hsync->end   & 0x0007));
+       if (1 == priv->revision)
+               ret = tw9910_mask_set(client, HSLOWCTL, 0x77,
+                                     (hsync->start & 0x0007) << 4 |
+                                     (hsync->end   & 0x0007));
 
        return ret;
 }
 
-static int tw9910_write_array(struct i2c_client *client,
-                             const struct regval_list *vals)
+static void tw9910_reset(struct i2c_client *client)
 {
-       while (vals->reg_num != 0xff) {
-               int ret = i2c_smbus_write_byte_data(client,
-                                                   vals->reg_num,
-                                                   vals->value);
-               if (ret < 0)
-                       return ret;
-               vals++;
-       }
-       return 0;
+       tw9910_mask_set(client, ACNTL1, SRESET, SRESET);
+       msleep(1);
 }
 
-static int tw9910_mask_set(struct i2c_client *client, u8 command,
-                          u8 mask, u8 set)
+static int tw9910_power(struct i2c_client *client, int enable)
 {
-       s32 val = i2c_smbus_read_byte_data(client, command);
-       if (val < 0)
-               return val;
+       int ret;
+       u8 acntl1;
+       u8 acntl2;
 
-       val &= ~mask;
-       val |= set & mask;
+       if (enable) {
+               acntl1 = 0;
+               acntl2 = 0;
+       } else {
+               acntl1 = CLK_PDN | Y_PDN | C_PDN;
+               acntl2 = PLL_PDN;
+       }
 
-       return i2c_smbus_write_byte_data(client, command, val);
-}
+       ret = tw9910_mask_set(client, ACNTL1, ACNTL1_PDN_MASK, acntl1);
+       if (ret < 0)
+               return ret;
 
-static void tw9910_reset(struct i2c_client *client)
-{
-       i2c_smbus_write_byte_data(client, ACNTL1, SRESET);
-       msleep(1);
+       return tw9910_mask_set(client, ACNTL2, ACNTL2_PDN_MASK, acntl2);
 }
 
 static const struct tw9910_scale_ctrl*
@@ -518,27 +471,62 @@ static int tw9910_s_stream(struct v4l2_subdev *sd, int enable)
 {
        struct i2c_client *client = sd->priv;
        struct tw9910_priv *priv = to_tw9910(client);
+       u8 val;
+       int ret;
 
-       if (!enable)
-               return 0;
+       if (!enable) {
+               switch (priv->revision) {
+               case 0:
+                       val = OEN_TRI_SEL_ALL_OFF_r0;
+                       break;
+               case 1:
+                       val = OEN_TRI_SEL_ALL_OFF_r1;
+                       break;
+               default:
+                       dev_err(&client->dev, "un-supported revision\n");
+                       return -EINVAL;
+               }
+       } else {
+               val = OEN_TRI_SEL_ALL_ON;
 
-       if (!priv->scale) {
-               dev_err(&client->dev, "norm select error\n");
-               return -EPERM;
+               if (!priv->scale) {
+                       dev_err(&client->dev, "norm select error\n");
+                       return -EPERM;
+               }
+
+               dev_dbg(&client->dev, "%s %dx%d\n",
+                       priv->scale->name,
+                       priv->scale->width,
+                       priv->scale->height);
        }
 
-       dev_dbg(&client->dev, "%s %dx%d\n",
-                priv->scale->name,
-                priv->scale->width,
-                priv->scale->height);
+       ret = tw9910_mask_set(client, OPFORM, OEN_TRI_SEL_MASK, val);
+       if (ret < 0)
+               return ret;
 
-       return 0;
+       return tw9910_power(client, enable);
 }
 
 static int tw9910_set_bus_param(struct soc_camera_device *icd,
                                unsigned long flags)
 {
-       return 0;
+       struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
+       struct i2c_client *client = sd->priv;
+       u8 val = VSSL_VVALID | HSSL_DVALID;
+
+       /*
+        * set OUTCTR1
+        *
+        * We use VVALID and DVALID signals to control VSYNC and HSYNC
+        * outputs, in this mode their polarity is inverted.
+        */
+       if (flags & SOCAM_HSYNC_ACTIVE_LOW)
+               val |= HSP_HI;
+
+       if (flags & SOCAM_VSYNC_ACTIVE_LOW)
+               val |= VSP_HI;
+
+       return i2c_smbus_write_byte_data(client, OUTCTR1, val);
 }
 
 static unsigned long tw9910_query_bus_param(struct soc_camera_device *icd)
@@ -548,6 +536,7 @@ static unsigned long tw9910_query_bus_param(struct soc_camera_device *icd)
        struct soc_camera_link *icl = to_soc_camera_link(icd);
        unsigned long flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_MASTER |
                SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_HIGH |
+               SOCAM_VSYNC_ACTIVE_LOW  | SOCAM_HSYNC_ACTIVE_LOW  |
                SOCAM_DATA_ACTIVE_HIGH | priv->info->buswidth;
 
        return soc_camera_apply_sensor_flags(icl, flags);
@@ -576,8 +565,11 @@ static int tw9910_enum_input(struct soc_camera_device *icd,
 static int tw9910_g_chip_ident(struct v4l2_subdev *sd,
                               struct v4l2_dbg_chip_ident *id)
 {
+       struct i2c_client *client = sd->priv;
+       struct tw9910_priv *priv = to_tw9910(client);
+
        id->ident = V4L2_IDENT_TW9910;
-       id->revision = 0;
+       id->revision = priv->revision;
 
        return 0;
 }
@@ -596,7 +588,8 @@ static int tw9910_g_register(struct v4l2_subdev *sd,
        if (ret < 0)
                return ret;
 
-       /* ret      = int
+       /*
+        * ret      = int
         * reg->val = __u64
         */
        reg->val = (__u64)ret;
@@ -637,9 +630,6 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
         * reset hardware
         */
        tw9910_reset(client);
-       ret = tw9910_write_array(client, tw9910_default_regs);
-       if (ret < 0)
-               goto tw9910_set_fmt_error;
 
        /*
         * set bus width
@@ -687,13 +677,6 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
        if (ret < 0)
                goto tw9910_set_fmt_error;
 
-       /*
-        * set cropping
-        */
-       ret = tw9910_set_cropping(client, &tw9910_cropping_ctrl);
-       if (ret < 0)
-               goto tw9910_set_fmt_error;
-
        /*
         * set hsync
         */
@@ -762,11 +745,11 @@ static int tw9910_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
-static int tw9910_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int tw9910_g_fmt(struct v4l2_subdev *sd,
+                       struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct tw9910_priv *priv = to_tw9910(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
 
        if (!priv->scale) {
                int ret;
@@ -783,74 +766,76 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
                        return ret;
        }
 
-       f->type                 = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
-       pix->width              = priv->scale->width;
-       pix->height             = priv->scale->height;
-       pix->pixelformat        = V4L2_PIX_FMT_VYUY;
-       pix->colorspace         = V4L2_COLORSPACE_SMPTE170M;
-       pix->field              = V4L2_FIELD_INTERLACED;
+       mf->width       = priv->scale->width;
+       mf->height      = priv->scale->height;
+       mf->code        = V4L2_MBUS_FMT_YUYV8_2X8_BE;
+       mf->colorspace  = V4L2_COLORSPACE_JPEG;
+       mf->field       = V4L2_FIELD_INTERLACED_BT;
 
        return 0;
 }
 
-static int tw9910_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int tw9910_s_fmt(struct v4l2_subdev *sd,
+                       struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct tw9910_priv *priv = to_tw9910(client);
-       struct v4l2_pix_format *pix = &f->fmt.pix;
        /* See tw9910_s_crop() - no proper cropping support */
        struct v4l2_crop a = {
                .c = {
                        .left   = 0,
                        .top    = 0,
-                       .width  = pix->width,
-                       .height = pix->height,
+                       .width  = mf->width,
+                       .height = mf->height,
                },
        };
-       int i, ret;
+       int ret;
+
+       WARN_ON(mf->field != V4L2_FIELD_ANY &&
+               mf->field != V4L2_FIELD_INTERLACED_BT);
 
        /*
         * check color format
         */
-       for (i = 0; i < ARRAY_SIZE(tw9910_color_fmt); i++)
-               if (pix->pixelformat == tw9910_color_fmt[i].fourcc)
-                       break;
-
-       if (i == ARRAY_SIZE(tw9910_color_fmt))
+       if (mf->code != V4L2_MBUS_FMT_YUYV8_2X8_BE)
                return -EINVAL;
 
+       mf->colorspace = V4L2_COLORSPACE_JPEG;
+
        ret = tw9910_s_crop(sd, &a);
        if (!ret) {
-               pix->width = priv->scale->width;
-               pix->height = priv->scale->height;
+               mf->width       = priv->scale->width;
+               mf->height      = priv->scale->height;
        }
        return ret;
 }
 
-static int tw9910_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
+static int tw9910_try_fmt(struct v4l2_subdev *sd,
+                         struct v4l2_mbus_framefmt *mf)
 {
        struct i2c_client *client = sd->priv;
        struct soc_camera_device *icd = client->dev.platform_data;
-       struct v4l2_pix_format *pix = &f->fmt.pix;
        const struct tw9910_scale_ctrl *scale;
 
-       if (V4L2_FIELD_ANY == pix->field) {
-               pix->field = V4L2_FIELD_INTERLACED;
-       } else if (V4L2_FIELD_INTERLACED != pix->field) {
-               dev_err(&client->dev, "Field type invalid.\n");
+       if (V4L2_FIELD_ANY == mf->field) {
+               mf->field = V4L2_FIELD_INTERLACED_BT;
+       } else if (V4L2_FIELD_INTERLACED_BT != mf->field) {
+               dev_err(&client->dev, "Field type %d invalid.\n", mf->field);
                return -EINVAL;
        }
 
+       mf->code = V4L2_MBUS_FMT_YUYV8_2X8_BE;
+       mf->colorspace = V4L2_COLORSPACE_JPEG;
+
        /*
         * select suitable norm
         */
-       scale = tw9910_select_norm(icd, pix->width, pix->height);
+       scale = tw9910_select_norm(icd, mf->width, mf->height);
        if (!scale)
                return -EINVAL;
 
-       pix->width  = scale->width;
-       pix->height = scale->height;
+       mf->width       = scale->width;
+       mf->height      = scale->height;
 
        return 0;
 }
@@ -859,7 +844,7 @@ static int tw9910_video_probe(struct soc_camera_device *icd,
                              struct i2c_client *client)
 {
        struct tw9910_priv *priv = to_tw9910(client);
-       s32 val;
+       s32 id;
 
        /*
         * We must have a parent by now. And it cannot be a wrong one.
@@ -878,23 +863,24 @@ static int tw9910_video_probe(struct soc_camera_device *icd,
                return -ENODEV;
        }
 
-       icd->formats     = tw9910_color_fmt;
-       icd->num_formats = ARRAY_SIZE(tw9910_color_fmt);
-
        /*
         * check and show Product ID
+        * So far only revisions 0 and 1 have been seen
         */
-       val = i2c_smbus_read_byte_data(client, ID);
+       id = i2c_smbus_read_byte_data(client, ID);
+       priv->revision = GET_REV(id);
+       id = GET_ID(id);
 
-       if (0x0B != GET_ID(val) ||
-           0x00 != GET_ReV(val)) {
+       if (0x0B != id ||
+           0x01 < priv->revision) {
                dev_err(&client->dev,
-                       "Product ID error %x:%x\n", GET_ID(val), GET_ReV(val));
+                       "Product ID error %x:%x\n",
+                       id, priv->revision);
                return -ENODEV;
        }
 
        dev_info(&client->dev,
-                "tw9910 Product ID %0x:%0x\n", GET_ID(val), GET_ReV(val));
+                "tw9910 Product ID %0x:%0x\n", id, priv->revision);
 
        icd->vdev->tvnorms      = V4L2_STD_NTSC | V4L2_STD_PAL;
        icd->vdev->current_norm = V4L2_STD_NTSC;
@@ -917,14 +903,25 @@ static struct v4l2_subdev_core_ops tw9910_subdev_core_ops = {
 #endif
 };
 
+static int tw9910_enum_fmt(struct v4l2_subdev *sd, int index,
+                          enum v4l2_mbus_pixelcode *code)
+{
+       if (index)
+               return -EINVAL;
+
+       *code = V4L2_MBUS_FMT_YUYV8_2X8_BE;
+       return 0;
+}
+
 static struct v4l2_subdev_video_ops tw9910_subdev_video_ops = {
        .s_stream       = tw9910_s_stream,
-       .g_fmt          = tw9910_g_fmt,
-       .s_fmt          = tw9910_s_fmt,
-       .try_fmt        = tw9910_try_fmt,
+       .g_mbus_fmt     = tw9910_g_fmt,
+       .s_mbus_fmt     = tw9910_s_fmt,
+       .try_mbus_fmt   = tw9910_try_fmt,
        .cropcap        = tw9910_cropcap,
        .g_crop         = tw9910_g_crop,
        .s_crop         = tw9910_s_crop,
+       .enum_mbus_fmt  = tw9910_enum_fmt,
 };
 
 static struct v4l2_subdev_ops tw9910_subdev_ops = {
@@ -954,10 +951,10 @@ static int tw9910_probe(struct i2c_client *client,
        }
 
        icl = to_soc_camera_link(icd);
-       if (!icl)
+       if (!icl || !icl->priv)
                return -EINVAL;
 
-       info = container_of(icl, struct tw9910_video_info, link);
+       info = icl->priv;
 
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
                dev_err(&client->dev,
@@ -975,7 +972,7 @@ static int tw9910_probe(struct i2c_client *client,
        v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops);
 
        icd->ops     = &tw9910_ops;
-       icd->iface   = info->link.bus_id;
+       icd->iface   = icl->bus_id;
 
        ret = tw9910_video_probe(icd, client);
        if (ret) {
index dea8b321fb4a5b983f35da9f56fa6a83a22c1895..5ac37c6c43131503dc95cbf4e496bee1ee2d1460 100644 (file)
@@ -1053,9 +1053,9 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd)
                         "%s: video_register_device() successful\n", __func__);
        }
 
-       dev_info(&uvd->dev->dev, "%s on /dev/video%d: canvas=%s videosize=%s\n",
+       dev_info(&uvd->dev->dev, "%s on %s: canvas=%s videosize=%s\n",
                 (uvd->handle != NULL) ? uvd->handle->drvName : "???",
-                uvd->vdev.num, tmp2, tmp1);
+                video_device_node_name(&uvd->vdev), tmp2, tmp1);
 
        usb_get_dev(uvd->dev);
        return 0;
index 45fce39ec9ad56b77c5b7db00eca8dccf3d5a0f3..6030410c66770fd906a8864b7994b4d97fee7805 100644 (file)
@@ -796,7 +796,6 @@ static const struct v4l2_file_operations vicam_fops = {
 static struct video_device vicam_template = {
        .name           = "ViCam-based USB Camera",
        .fops           = &vicam_fops,
-       .minor          = -1,
        .release        = video_device_release_empty,
 };
 
@@ -873,8 +872,8 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
                return -EIO;
        }
 
-       printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",
-                       cam->vdev.num);
+       printk(KERN_INFO "ViCam webcam driver now controlling device %s\n",
+               video_device_node_name(&cam->vdev));
 
        usb_set_intfdata (intf, cam);
 
index c19f51dba2ee28b3d0827c93df30044ebfe69766..0613922997e0c588ac1f9e1884b92ba54bc82e77 100644 (file)
@@ -215,8 +215,8 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
        memcpy(&usbvision->i2c_adap, &i2c_adap_template,
               sizeof(struct i2c_adapter));
 
-       sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name),
-               " #%d", usbvision->vdev->num);
+       sprintf(usbvision->i2c_adap.name, "%s-%d-%s", i2c_adap_template.name,
+               usbvision->dev->bus->busnum, usbvision->dev->devpath);
        PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name);
        usbvision->i2c_adap.dev.parent = &usbvision->dev->dev;
 
index c07b0ac452abf8a986d134ab260e78ae5890f463..1054546db9080a7445e74b2d3ef23f790fc5372c 100644 (file)
@@ -1328,7 +1328,6 @@ static struct video_device usbvision_video_template = {
        .ioctl_ops      = &usbvision_ioctl_ops,
        .name           = "usbvision-video",
        .release        = video_device_release,
-       .minor          = -1,
        .tvnorms              = USBVISION_NORMS,
        .current_norm         = V4L2_STD_PAL
 };
@@ -1362,7 +1361,6 @@ static struct video_device usbvision_radio_template = {
        .fops           = &usbvision_radio_fops,
        .name           = "usbvision-radio",
        .release        = video_device_release,
-       .minor          = -1,
        .ioctl_ops      = &usbvision_radio_ioctl_ops,
 
        .tvnorms              = USBVISION_NORMS,
@@ -1382,7 +1380,6 @@ static struct video_device usbvision_vbi_template=
        .fops           = &usbvision_vbi_fops,
        .release        = video_device_release,
        .name           = "usbvision-vbi",
-       .minor          = -1,
 };
 
 
@@ -1404,7 +1401,6 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision,
                return NULL;
        }
        *vdev = *vdev_template;
-//     vdev->minor   = -1;
        vdev->v4l2_dev = &usbvision->v4l2_dev;
        snprintf(vdev->name, sizeof(vdev->name), "%s", name);
        video_set_drvdata(vdev, usbvision);
@@ -1416,9 +1412,9 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision)
 {
        // vbi Device:
        if (usbvision->vbi) {
-               PDEBUG(DBG_PROBE, "unregister /dev/vbi%d [v4l2]",
-                      usbvision->vbi->num);
-               if (usbvision->vbi->minor != -1) {
+               PDEBUG(DBG_PROBE, "unregister %s [v4l2]",
+                      video_device_node_name(usbvision->vbi));
+               if (video_is_registered(usbvision->vbi)) {
                        video_unregister_device(usbvision->vbi);
                } else {
                        video_device_release(usbvision->vbi);
@@ -1428,9 +1424,9 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision)
 
        // Radio Device:
        if (usbvision->rdev) {
-               PDEBUG(DBG_PROBE, "unregister /dev/radio%d [v4l2]",
-                      usbvision->rdev->num);
-               if (usbvision->rdev->minor != -1) {
+               PDEBUG(DBG_PROBE, "unregister %s [v4l2]",
+                      video_device_node_name(usbvision->rdev));
+               if (video_is_registered(usbvision->rdev)) {
                        video_unregister_device(usbvision->rdev);
                } else {
                        video_device_release(usbvision->rdev);
@@ -1440,9 +1436,9 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision)
 
        // Video Device:
        if (usbvision->vdev) {
-               PDEBUG(DBG_PROBE, "unregister /dev/video%d [v4l2]",
-                      usbvision->vdev->num);
-               if (usbvision->vdev->minor != -1) {
+               PDEBUG(DBG_PROBE, "unregister %s [v4l2]",
+                      video_device_node_name(usbvision->vdev));
+               if (video_is_registered(usbvision->vdev)) {
                        video_unregister_device(usbvision->vdev);
                } else {
                        video_device_release(usbvision->vdev);
@@ -1466,8 +1462,8 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision)
                                  video_nr)<0) {
                goto err_exit;
        }
-       printk(KERN_INFO "USBVision[%d]: registered USBVision Video device /dev/video%d [v4l2]\n",
-              usbvision->nr, usbvision->vdev->num);
+       printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n",
+              usbvision->nr, video_device_node_name(usbvision->vdev));
 
        // Radio Device:
        if (usbvision_device_data[usbvision->DevModel].Radio) {
@@ -1483,8 +1479,8 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision)
                                          radio_nr)<0) {
                        goto err_exit;
                }
-               printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device /dev/radio%d [v4l2]\n",
-                      usbvision->nr, usbvision->rdev->num);
+               printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device %s [v4l2]\n",
+                      usbvision->nr, video_device_node_name(usbvision->rdev));
        }
        // vbi Device:
        if (usbvision_device_data[usbvision->DevModel].vbi) {
@@ -1499,8 +1495,8 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision)
                                          vbi_nr)<0) {
                        goto err_exit;
                }
-               printk(KERN_INFO "USBVision[%d]: registered USBVision VBI device /dev/vbi%d [v4l2] (Not Working Yet!)\n",
-                      usbvision->nr, usbvision->vbi->num);
+               printk(KERN_INFO "USBVision[%d]: registered USBVision VBI device %s [v4l2] (Not Working Yet!)\n",
+                      usbvision->nr, video_device_node_name(usbvision->vbi));
        }
        // all done
        return 0;
index c31bc50113bca9bb144bda087338da030644ff3e..391cccca7ffcb6f31bb7dca1a13521d1391b2299 100644 (file)
@@ -1651,7 +1651,6 @@ static int uvc_register_video(struct uvc_device *dev,
         * get another one.
         */
        vdev->parent = &dev->intf->dev;
-       vdev->minor = -1;
        vdev->fops = &uvc_fops;
        vdev->release = uvc_release;
        strlcpy(vdev->name, dev->name, sizeof vdev->name);
index 05139a4f14f6739f9f97dc30bc16e93959f7dfa2..9a9802830d41ea1676f456e335c2e53e8e6fb4cc 100644 (file)
@@ -145,7 +145,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
                uvc_warn_once(stream->dev, UVC_WARN_MINMAX, "UVC non "
                        "compliance - GET_MIN/MAX(PROBE) incorrectly "
                        "supported. Enabling workaround.\n");
-               memset(ctrl, 0, sizeof ctrl);
+               memset(ctrl, 0, sizeof *ctrl);
                ctrl->wCompQuality = le16_to_cpup((__le16 *)data);
                ret = 0;
                goto out;
index e8e5affbabcedb04189536a7819273bb94991ccc..36b5cb86fb57c10e9786d51d5e4b13aef0ed5a91 100644 (file)
@@ -1024,3 +1024,50 @@ void v4l_bound_align_image(u32 *w, unsigned int wmin, unsigned int wmax,
        }
 }
 EXPORT_SYMBOL_GPL(v4l_bound_align_image);
+
+/**
+ * v4l_fill_dv_preset_info - fill description of a digital video preset
+ * @preset - preset value
+ * @info - pointer to struct v4l2_dv_enum_preset
+ *
+ * drivers can use this helper function to fill description of dv preset
+ * in info.
+ */
+int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info)
+{
+       static const struct v4l2_dv_preset_info {
+               u16 width;
+               u16 height;
+               const char *name;
+       } dv_presets[] = {
+               { 0, 0, "Invalid" },            /* V4L2_DV_INVALID */
+               { 720,  480, "480p@59.94" },    /* V4L2_DV_480P59_94 */
+               { 720,  576, "576p@50" },       /* V4L2_DV_576P50 */
+               { 1280, 720, "720p@24" },       /* V4L2_DV_720P24 */
+               { 1280, 720, "720p@25" },       /* V4L2_DV_720P25 */
+               { 1280, 720, "720p@30" },       /* V4L2_DV_720P30 */
+               { 1280, 720, "720p@50" },       /* V4L2_DV_720P50 */
+               { 1280, 720, "720p@59.94" },    /* V4L2_DV_720P59_94 */
+               { 1280, 720, "720p@60" },       /* V4L2_DV_720P60 */
+               { 1920, 1080, "1080i@29.97" },  /* V4L2_DV_1080I29_97 */
+               { 1920, 1080, "1080i@30" },     /* V4L2_DV_1080I30 */
+               { 1920, 1080, "1080i@25" },     /* V4L2_DV_1080I25 */
+               { 1920, 1080, "1080i@50" },     /* V4L2_DV_1080I50 */
+               { 1920, 1080, "1080i@60" },     /* V4L2_DV_1080I60 */
+               { 1920, 1080, "1080p@24" },     /* V4L2_DV_1080P24 */
+               { 1920, 1080, "1080p@25" },     /* V4L2_DV_1080P25 */
+               { 1920, 1080, "1080p@30" },     /* V4L2_DV_1080P30 */
+               { 1920, 1080, "1080p@50" },     /* V4L2_DV_1080P50 */
+               { 1920, 1080, "1080p@60" },     /* V4L2_DV_1080P60 */
+       };
+
+       if (info == NULL || preset >= ARRAY_SIZE(dv_presets))
+               return -EINVAL;
+
+       info->preset = preset;
+       info->width = dv_presets[preset].width;
+       info->height = dv_presets[preset].height;
+       strlcpy(info->name, dv_presets[preset].name, sizeof(info->name));
+       return 0;
+}
+EXPORT_SYMBOL_GPL(v4l_fill_dv_preset_info);
index 997975d5e024b06934e0a4d1d39bba4c091be85b..c4150bd263371484abdb0f094319b1bff5649428 100644 (file)
@@ -1077,6 +1077,12 @@ long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
        case VIDIOC_DBG_G_REGISTER:
        case VIDIOC_DBG_G_CHIP_IDENT:
        case VIDIOC_S_HW_FREQ_SEEK:
+       case VIDIOC_ENUM_DV_PRESETS:
+       case VIDIOC_S_DV_PRESET:
+       case VIDIOC_G_DV_PRESET:
+       case VIDIOC_QUERY_DV_PRESET:
+       case VIDIOC_S_DV_TIMINGS:
+       case VIDIOC_G_DV_TIMINGS:
                ret = do_video_ioctl(file, cmd, arg);
                break;
 
index 500cbe9891ac45b4ab14faf5ee642b38a7173366..709069916068f45daf28b595272b77d4e2d2324c 100644 (file)
@@ -189,7 +189,7 @@ static ssize_t v4l2_read(struct file *filp, char __user *buf,
 
        if (!vdev->fops->read)
                return -EINVAL;
-       if (video_is_unregistered(vdev))
+       if (!video_is_registered(vdev))
                return -EIO;
        return vdev->fops->read(filp, buf, sz, off);
 }
@@ -201,7 +201,7 @@ static ssize_t v4l2_write(struct file *filp, const char __user *buf,
 
        if (!vdev->fops->write)
                return -EINVAL;
-       if (video_is_unregistered(vdev))
+       if (!video_is_registered(vdev))
                return -EIO;
        return vdev->fops->write(filp, buf, sz, off);
 }
@@ -210,7 +210,7 @@ static unsigned int v4l2_poll(struct file *filp, struct poll_table_struct *poll)
 {
        struct video_device *vdev = video_devdata(filp);
 
-       if (!vdev->fops->poll || video_is_unregistered(vdev))
+       if (!vdev->fops->poll || !video_is_registered(vdev))
                return DEFAULT_POLLMASK;
        return vdev->fops->poll(filp, poll);
 }
@@ -250,7 +250,7 @@ static unsigned long v4l2_get_unmapped_area(struct file *filp,
 
        if (!vdev->fops->get_unmapped_area)
                return -ENOSYS;
-       if (video_is_unregistered(vdev))
+       if (!video_is_registered(vdev))
                return -ENODEV;
        return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
 }
@@ -260,8 +260,7 @@ static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
 {
        struct video_device *vdev = video_devdata(filp);
 
-       if (!vdev->fops->mmap ||
-           video_is_unregistered(vdev))
+       if (!vdev->fops->mmap || !video_is_registered(vdev))
                return -ENODEV;
        return vdev->fops->mmap(filp, vm);
 }
@@ -277,7 +276,7 @@ static int v4l2_open(struct inode *inode, struct file *filp)
        vdev = video_devdata(filp);
        /* return ENODEV if the video device has been removed
           already or if it is not registered anymore. */
-       if (vdev == NULL || video_is_unregistered(vdev)) {
+       if (vdev == NULL || !video_is_registered(vdev)) {
                mutex_unlock(&videodev_lock);
                return -ENODEV;
        }
@@ -551,10 +550,11 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
        vdev->dev.release = v4l2_device_release;
 
        if (nr != -1 && nr != vdev->num && warn_if_nr_in_use)
-               printk(KERN_WARNING "%s: requested %s%d, got %s%d\n",
-                               __func__, name_base, nr, name_base, vdev->num);
+               printk(KERN_WARNING "%s: requested %s%d, got %s\n", __func__,
+                       name_base, nr, video_device_node_name(vdev));
 
        /* Part 5: Activate this minor. The char device can now be used. */
+       set_bit(V4L2_FL_REGISTERED, &vdev->flags);
        mutex_lock(&videodev_lock);
        video_device[vdev->minor] = vdev;
        mutex_unlock(&videodev_lock);
@@ -593,11 +593,11 @@ EXPORT_SYMBOL(video_register_device_no_warn);
 void video_unregister_device(struct video_device *vdev)
 {
        /* Check if vdev was ever registered at all */
-       if (!vdev || vdev->minor < 0)
+       if (!vdev || !video_is_registered(vdev))
                return;
 
        mutex_lock(&videodev_lock);
-       set_bit(V4L2_FL_UNREGISTERED, &vdev->flags);
+       clear_bit(V4L2_FL_REGISTERED, &vdev->flags);
        mutex_unlock(&videodev_lock);
        device_unregister(&vdev->dev);
 }
index 30cc3347ae52a417c83c9c899cb9c39f88b36667..4b11257c31846759132243f39a7a6a885a9cbff6 100644 (file)
@@ -284,6 +284,12 @@ static const char *v4l2_ioctls[] = {
        [_IOC_NR(VIDIOC_DBG_G_CHIP_IDENT)] = "VIDIOC_DBG_G_CHIP_IDENT",
        [_IOC_NR(VIDIOC_S_HW_FREQ_SEEK)]   = "VIDIOC_S_HW_FREQ_SEEK",
 #endif
+       [_IOC_NR(VIDIOC_ENUM_DV_PRESETS)]  = "VIDIOC_ENUM_DV_PRESETS",
+       [_IOC_NR(VIDIOC_S_DV_PRESET)]      = "VIDIOC_S_DV_PRESET",
+       [_IOC_NR(VIDIOC_G_DV_PRESET)]      = "VIDIOC_G_DV_PRESET",
+       [_IOC_NR(VIDIOC_QUERY_DV_PRESET)]  = "VIDIOC_QUERY_DV_PRESET",
+       [_IOC_NR(VIDIOC_S_DV_TIMINGS)]     = "VIDIOC_S_DV_TIMINGS",
+       [_IOC_NR(VIDIOC_G_DV_TIMINGS)]     = "VIDIOC_G_DV_TIMINGS",
 };
 #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
 
@@ -1135,6 +1141,19 @@ static long __video_do_ioctl(struct file *file,
        {
                struct v4l2_input *p = arg;
 
+               /*
+                * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS &
+                * CAP_STD here based on ioctl handler provided by the
+                * driver. If the driver doesn't support these
+                * for a specific input, it must override these flags.
+                */
+               if (ops->vidioc_s_std)
+                       p->capabilities |= V4L2_IN_CAP_STD;
+               if (ops->vidioc_s_dv_preset)
+                       p->capabilities |= V4L2_IN_CAP_PRESETS;
+               if (ops->vidioc_s_dv_timings)
+                       p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS;
+
                if (!ops->vidioc_enum_input)
                        break;
 
@@ -1179,6 +1198,19 @@ static long __video_do_ioctl(struct file *file,
                if (!ops->vidioc_enum_output)
                        break;
 
+               /*
+                * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS &
+                * CAP_STD here based on ioctl handler provided by the
+                * driver. If the driver doesn't support these
+                * for a specific output, it must override these flags.
+                */
+               if (ops->vidioc_s_std)
+                       p->capabilities |= V4L2_OUT_CAP_STD;
+               if (ops->vidioc_s_dv_preset)
+                       p->capabilities |= V4L2_OUT_CAP_PRESETS;
+               if (ops->vidioc_s_dv_timings)
+                       p->capabilities |= V4L2_OUT_CAP_CUSTOM_TIMINGS;
+
                ret = ops->vidioc_enum_output(file, fh, p);
                if (!ret)
                        dbgarg(cmd, "index=%d, name=%s, type=%d, "
@@ -1794,6 +1826,121 @@ static long __video_do_ioctl(struct file *file,
                }
                break;
        }
+       case VIDIOC_ENUM_DV_PRESETS:
+       {
+               struct v4l2_dv_enum_preset *p = arg;
+
+               if (!ops->vidioc_enum_dv_presets)
+                       break;
+
+               ret = ops->vidioc_enum_dv_presets(file, fh, p);
+               if (!ret)
+                       dbgarg(cmd,
+                               "index=%d, preset=%d, name=%s, width=%d,"
+                               " height=%d ",
+                               p->index, p->preset, p->name, p->width,
+                               p->height);
+               break;
+       }
+       case VIDIOC_S_DV_PRESET:
+       {
+               struct v4l2_dv_preset *p = arg;
+
+               if (!ops->vidioc_s_dv_preset)
+                       break;
+
+               dbgarg(cmd, "preset=%d\n", p->preset);
+               ret = ops->vidioc_s_dv_preset(file, fh, p);
+               break;
+       }
+       case VIDIOC_G_DV_PRESET:
+       {
+               struct v4l2_dv_preset *p = arg;
+
+               if (!ops->vidioc_g_dv_preset)
+                       break;
+
+               ret = ops->vidioc_g_dv_preset(file, fh, p);
+               if (!ret)
+                       dbgarg(cmd, "preset=%d\n", p->preset);
+               break;
+       }
+       case VIDIOC_QUERY_DV_PRESET:
+       {
+               struct v4l2_dv_preset *p = arg;
+
+               if (!ops->vidioc_query_dv_preset)
+                       break;
+
+               ret = ops->vidioc_query_dv_preset(file, fh, p);
+               if (!ret)
+                       dbgarg(cmd, "preset=%d\n", p->preset);
+               break;
+       }
+       case VIDIOC_S_DV_TIMINGS:
+       {
+               struct v4l2_dv_timings *p = arg;
+
+               if (!ops->vidioc_s_dv_timings)
+                       break;
+
+               switch (p->type) {
+               case V4L2_DV_BT_656_1120:
+                       dbgarg2("bt-656/1120:interlaced=%d, pixelclock=%lld,"
+                               " width=%d, height=%d, polarities=%x,"
+                               " hfrontporch=%d, hsync=%d, hbackporch=%d,"
+                               " vfrontporch=%d, vsync=%d, vbackporch=%d,"
+                               " il_vfrontporch=%d, il_vsync=%d,"
+                               " il_vbackporch=%d\n",
+                               p->bt.interlaced, p->bt.pixelclock,
+                               p->bt.width, p->bt.height, p->bt.polarities,
+                               p->bt.hfrontporch, p->bt.hsync,
+                               p->bt.hbackporch, p->bt.vfrontporch,
+                               p->bt.vsync, p->bt.vbackporch,
+                               p->bt.il_vfrontporch, p->bt.il_vsync,
+                               p->bt.il_vbackporch);
+                       ret = ops->vidioc_s_dv_timings(file, fh, p);
+                       break;
+               default:
+                       dbgarg2("Unknown type %d!\n", p->type);
+                       break;
+               }
+               break;
+       }
+       case VIDIOC_G_DV_TIMINGS:
+       {
+               struct v4l2_dv_timings *p = arg;
+
+               if (!ops->vidioc_g_dv_timings)
+                       break;
+
+               ret = ops->vidioc_g_dv_timings(file, fh, p);
+               if (!ret) {
+                       switch (p->type) {
+                       case V4L2_DV_BT_656_1120:
+                               dbgarg2("bt-656/1120:interlaced=%d,"
+                                       " pixelclock=%lld,"
+                                       " width=%d, height=%d, polarities=%x,"
+                                       " hfrontporch=%d, hsync=%d,"
+                                       " hbackporch=%d, vfrontporch=%d,"
+                                       " vsync=%d, vbackporch=%d,"
+                                       " il_vfrontporch=%d, il_vsync=%d,"
+                                       " il_vbackporch=%d\n",
+                                       p->bt.interlaced, p->bt.pixelclock,
+                                       p->bt.width, p->bt.height,
+                                       p->bt.polarities, p->bt.hfrontporch,
+                                       p->bt.hsync, p->bt.hbackporch,
+                                       p->bt.vfrontporch, p->bt.vsync,
+                                       p->bt.vbackporch, p->bt.il_vfrontporch,
+                                       p->bt.il_vsync, p->bt.il_vbackporch);
+                               break;
+                       default:
+                               dbgarg2("Unknown type %d!\n", p->type);
+                               break;
+                       }
+               }
+               break;
+       }
 
        default:
        {
index d25f28461da1fcaac4b5d74ad8d6cac65e286b4f..22c01097e8a821f95c04ae9d8ae9432623381d46 100644 (file)
@@ -141,9 +141,11 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem,
        struct vm_area_struct *vma;
        unsigned long prev_pfn, this_pfn;
        unsigned long pages_done, user_address;
+       unsigned int offset;
        int ret;
 
-       mem->size = PAGE_ALIGN(vb->size);
+       offset = vb->baddr & ~PAGE_MASK;
+       mem->size = PAGE_ALIGN(vb->size + offset);
        mem->is_userptr = 0;
        ret = -EINVAL;
 
@@ -166,7 +168,7 @@ static int videobuf_dma_contig_user_get(struct videobuf_dma_contig_memory *mem,
                        break;
 
                if (pages_done == 0)
-                       mem->dma_handle = this_pfn << PAGE_SHIFT;
+                       mem->dma_handle = (this_pfn << PAGE_SHIFT) + offset;
                else if (this_pfn != (prev_pfn + 1))
                        ret = -EFAULT;
 
index b034a81d2b1c41f0cdb4cf73eef0ff36ebf1cb6d..a15d1e7cbed8529dc69bbe37304a5eba0ac42523 100644 (file)
@@ -4068,7 +4068,6 @@ static struct video_device vdev_template = {
        .fops           = &vino_fops,
        .ioctl_ops      = &vino_ioctl_ops,
        .tvnorms        = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM,
-       .minor          = -1,
 };
 
 static void vino_module_cleanup(int stage)
index 7705fc6baf00d6eab93fbf43eb17bfb9febece0a..37632a0649667c8102eabe2567f1fb882d2b7abd 100644 (file)
@@ -1148,7 +1148,8 @@ static int vivi_open(struct file *file)
                return -EBUSY;
        }
 
-       dprintk(dev, 1, "open /dev/video%d type=%s users=%d\n", dev->vfd->num,
+       dprintk(dev, 1, "open %s type=%s users=%d\n",
+               video_device_node_name(dev->vfd),
                v4l2_type_names[V4L2_BUF_TYPE_VIDEO_CAPTURE], dev->users);
 
        /* allocate + initialize per filehandle data */
@@ -1221,8 +1222,7 @@ static int vivi_close(struct file *file)
        struct vivi_fh         *fh = file->private_data;
        struct vivi_dev *dev       = fh->dev;
        struct vivi_dmaqueue *vidq = &dev->vidq;
-
-       int minor = video_devdata(file)->minor;
+       struct video_device  *vdev = video_devdata(file);
 
        vivi_stop_thread(vidq);
        videobuf_stop(&fh->vb_vidq);
@@ -1234,8 +1234,8 @@ static int vivi_close(struct file *file)
        dev->users--;
        mutex_unlock(&dev->mutex);
 
-       dprintk(dev, 1, "close called (minor=%d, users=%d)\n",
-               minor, dev->users);
+       dprintk(dev, 1, "close called (dev=%s, users=%d)\n",
+               video_device_node_name(vdev), dev->users);
 
        return 0;
 }
@@ -1296,7 +1296,6 @@ static struct video_device vivi_template = {
        .name           = "vivi",
        .fops           = &vivi_fops,
        .ioctl_ops      = &vivi_ioctl_ops,
-       .minor          = -1,
        .release        = video_device_release,
 
        .tvnorms              = V4L2_STD_525_60,
@@ -1317,8 +1316,8 @@ static int vivi_release(void)
                list_del(list);
                dev = list_entry(list, struct vivi_dev, vivi_devlist);
 
-               v4l2_info(&dev->v4l2_dev, "unregistering /dev/video%d\n",
-                       dev->vfd->num);
+               v4l2_info(&dev->v4l2_dev, "unregistering %s\n",
+                       video_device_node_name(dev->vfd));
                video_unregister_device(dev->vfd);
                v4l2_device_unregister(&dev->v4l2_dev);
                kfree(dev);
@@ -1372,15 +1371,12 @@ static int __init vivi_create_instance(int inst)
        /* Now that everything is fine, let's add it to device list */
        list_add_tail(&dev->vivi_devlist, &vivi_devlist);
 
-       snprintf(vfd->name, sizeof(vfd->name), "%s (%i)",
-                       vivi_template.name, vfd->num);
-
        if (video_nr >= 0)
                video_nr++;
 
        dev->vfd = vfd;
-       v4l2_info(&dev->v4l2_dev, "V4L2 device registered as /dev/video%d\n",
-                       vfd->num);
+       v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s\n",
+                 video_device_node_name(vfd));
        return 0;
 
 rel_vdev:
index 37fcdc447db589a37c00e6a95521500d5b047928..d807eea9175783a0e9b57610e9b6ba095c83c6f1 100644 (file)
@@ -2323,9 +2323,9 @@ static int w9968cf_sensor_init(struct w9968cf_device* cam)
 error:
        cam->sensor_initialized = 0;
        cam->sensor = CC_UNKNOWN;
-       DBG(1, "Image sensor initialization failed for %s (/dev/video%d). "
+       DBG(1, "Image sensor initialization failed for %s (%s). "
               "Try to detach and attach this device again",
-           symbolic(camlist, cam->id), cam->v4ldev->num)
+           symbolic(camlist, cam->id), video_device_node_name(cam->v4ldev))
        return err;
 }
 
@@ -2571,7 +2571,8 @@ static void w9968cf_release_resources(struct w9968cf_device* cam)
 {
        mutex_lock(&w9968cf_devlist_mutex);
 
-       DBG(2, "V4L device deregistered: /dev/video%d", cam->v4ldev->num)
+       DBG(2, "V4L device deregistered: %s",
+           video_device_node_name(cam->v4ldev))
 
        video_unregister_device(cam->v4ldev);
        list_del(&cam->v4llist);
@@ -2605,17 +2606,19 @@ static int w9968cf_open(struct file *filp)
 
        if (cam->sensor == CC_UNKNOWN) {
                DBG(2, "No supported image sensor has been detected by the "
-                      "'ovcamchip' module for the %s (/dev/video%d). Make "
-                      "sure it is loaded *before* (re)connecting the camera.",
-                   symbolic(camlist, cam->id), cam->v4ldev->num)
+                      "'ovcamchip' module for the %s (%s). Make sure "
+                      "it is loaded *before* (re)connecting the camera.",
+                   symbolic(camlist, cam->id),
+                   video_device_node_name(cam->v4ldev))
                mutex_unlock(&cam->dev_mutex);
                up_read(&w9968cf_disconnect);
                return -ENODEV;
        }
 
        if (cam->users) {
-               DBG(2, "%s (/dev/video%d) has been already occupied by '%s'",
-                   symbolic(camlist, cam->id), cam->v4ldev->num, cam->command)
+               DBG(2, "%s (%s) has been already occupied by '%s'",
+                   symbolic(camlist, cam->id),
+                   video_device_node_name(cam->v4ldev), cam->command)
                if ((filp->f_flags & O_NONBLOCK)||(filp->f_flags & O_NDELAY)) {
                        mutex_unlock(&cam->dev_mutex);
                        up_read(&w9968cf_disconnect);
@@ -2636,8 +2639,8 @@ static int w9968cf_open(struct file *filp)
                mutex_lock(&cam->dev_mutex);
        }
 
-       DBG(5, "Opening '%s', /dev/video%d ...",
-           symbolic(camlist, cam->id), cam->v4ldev->num)
+       DBG(5, "Opening '%s', %s ...",
+           symbolic(camlist, cam->id), video_device_node_name(cam->v4ldev))
 
        cam->streaming = 0;
        cam->misconfigured = 0;
@@ -2874,8 +2877,7 @@ static long w9968cf_v4l_ioctl(struct file *filp,
                        .minwidth = cam->minwidth,
                        .minheight = cam->minheight,
                };
-               sprintf(cap.name, "W996[87]CF USB Camera #%d",
-                       cam->v4ldev->num);
+               sprintf(cap.name, "W996[87]CF USB Camera");
                cap.maxwidth = (cam->upscaling && w9968cf_vpp)
                               ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
                                 : cam->maxwidth;
@@ -3485,7 +3487,6 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
 
        strcpy(cam->v4ldev->name, symbolic(camlist, mod_id));
        cam->v4ldev->fops = &w9968cf_fops;
-       cam->v4ldev->minor = video_nr[dev_nr];
        cam->v4ldev->release = video_device_release;
        video_set_drvdata(cam->v4ldev, cam);
        cam->v4ldev->v4l2_dev = &cam->v4l2_dev;
@@ -3501,7 +3502,8 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
                goto fail;
        }
 
-       DBG(2, "V4L device registered as /dev/video%d", cam->v4ldev->num)
+       DBG(2, "V4L device registered as %s",
+           video_device_node_name(cam->v4ldev))
 
        /* Set some basic constants */
        w9968cf_configure_camera(cam, udev, mod_id, dev_nr);
@@ -3557,10 +3559,10 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf)
                wake_up_interruptible_all(&cam->open);
 
                if (cam->users) {
-                       DBG(2, "The device is open (/dev/video%d)! "
+                       DBG(2, "The device is open (%s)! "
                               "Process name: %s. Deregistration and memory "
                               "deallocation are deferred on close.",
-                           cam->v4ldev->num, cam->command)
+                           video_device_node_name(cam->v4ldev), cam->command)
                        cam->misconfigured = 1;
                        w9968cf_stop_transfer(cam);
                        wake_up_interruptible(&cam->wait_queue);
index 312a71336fd040d3519a04b41901ce4bb70f6084..e44e4b5f3e50a5231d2cc957679592ad6ab29d25 100644 (file)
@@ -538,8 +538,8 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
        else if (cam->stream != STREAM_OFF) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "URB timeout reached. The camera is misconfigured. To "
-                      "use it, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use it, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -640,7 +640,8 @@ static void zc0301_release_resources(struct kref *kref)
 {
        struct zc0301_device *cam = container_of(kref, struct zc0301_device,
                                                 kref);
-       DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->num);
+       DBG(2, "V4L2 device %s deregistered",
+           video_device_node_name(cam->v4ldev));
        video_set_drvdata(cam->v4ldev, NULL);
        video_unregister_device(cam->v4ldev);
        usb_put_dev(cam->usbdev);
@@ -679,7 +680,8 @@ static int zc0301_open(struct file *filp)
        }
 
        if (cam->users) {
-               DBG(2, "Device /dev/video%d is busy...", cam->v4ldev->num);
+               DBG(2, "Device %s is busy...",
+                   video_device_node_name(cam->v4ldev));
                DBG(3, "Simultaneous opens are not supported");
                if ((filp->f_flags & O_NONBLOCK) ||
                    (filp->f_flags & O_NDELAY)) {
@@ -722,7 +724,8 @@ static int zc0301_open(struct file *filp)
        cam->frame_count = 0;
        zc0301_empty_framequeues(cam);
 
-       DBG(3, "Video device /dev/video%d is open", cam->v4ldev->num);
+       DBG(3, "Video device %s is open",
+           video_device_node_name(cam->v4ldev));
 
 out:
        mutex_unlock(&cam->open_mutex);
@@ -746,7 +749,8 @@ static int zc0301_release(struct file *filp)
        cam->users--;
        wake_up_interruptible_nr(&cam->wait_open, 1);
 
-       DBG(3, "Video device /dev/video%d closed", cam->v4ldev->num);
+       DBG(3, "Video device %s closed",
+           video_device_node_name(cam->v4ldev));
 
        kref_put(&cam->kref, zc0301_release_resources);
 
@@ -1276,8 +1280,8 @@ zc0301_vidioc_s_crop(struct zc0301_device* cam, void __user * arg)
        if (err) { /* atomic, no rollback in ioctl() */
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_CROP failed because of hardware problems. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -1289,8 +1293,8 @@ zc0301_vidioc_s_crop(struct zc0301_device* cam, void __user * arg)
            nbuffers != zc0301_request_buffers(cam, nbuffers, cam->io)) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_CROP failed because of not enough memory. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -ENOMEM;
        }
 
@@ -1471,8 +1475,8 @@ zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd,
        if (err) { /* atomic, no rollback in ioctl() */
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_FMT failed because of hardware problems. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -1483,8 +1487,8 @@ zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd,
            nbuffers != zc0301_request_buffers(cam, nbuffers, cam->io)) {
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_FMT failed because of not enough memory. To "
-                      "use the camera, close and open /dev/video%d again.",
-                   cam->v4ldev->num);
+                      "use the camera, close and open %s again.",
+                   video_device_node_name(cam->v4ldev));
                return -ENOMEM;
        }
 
@@ -1530,8 +1534,8 @@ zc0301_vidioc_s_jpegcomp(struct zc0301_device* cam, void __user * arg)
        if (err) { /* atomic, no rollback in ioctl() */
                cam->state |= DEV_MISCONFIGURED;
                DBG(1, "VIDIOC_S_JPEGCOMP failed because of hardware "
-                      "problems. To use the camera, close and open "
-                      "/dev/video%d again.", cam->v4ldev->num);
+                      "problems. To use the camera, close and open %s again.",
+                      video_device_node_name(cam->v4ldev));
                return -EIO;
        }
 
@@ -1984,7 +1988,6 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
 
        strcpy(cam->v4ldev->name, "ZC0301[P] PC Camera");
        cam->v4ldev->fops = &zc0301_fops;
-       cam->v4ldev->minor = video_nr[dev_nr];
        cam->v4ldev->release = video_device_release;
        cam->v4ldev->parent = &udev->dev;
        video_set_drvdata(cam->v4ldev, cam);
@@ -2003,7 +2006,8 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
                goto fail;
        }
 
-       DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->num);
+       DBG(2, "V4L2 device registered as %s",
+           video_device_node_name(cam->v4ldev));
 
        cam->module_param.force_munmap = force_munmap[dev_nr];
        cam->module_param.frame_timeout = frame_timeout[dev_nr];
@@ -2040,9 +2044,9 @@ static void zc0301_usb_disconnect(struct usb_interface* intf)
        DBG(2, "Disconnecting %s...", cam->v4ldev->name);
 
        if (cam->users) {
-               DBG(2, "Device /dev/video%d is open! Deregistration and "
+               DBG(2, "Device %s is open! Deregistration and "
                       "memory deallocation are deferred.",
-                   cam->v4ldev->num);
+                   video_device_node_name(cam->v4ldev));
                cam->state |= DEV_MISCONFIGURED;
                zc0301_stop_transfer(cam);
                cam->state |= DEV_DISCONNECTED;
index e9f72ca458f1b977dada7cf3b177f47483073889..2ddffed019eee90d5d501c382c062f149241ff82 100644 (file)
@@ -3387,6 +3387,5 @@ struct video_device zoran_template __devinitdata = {
        .ioctl_ops = &zoran_ioctl_ops,
        .release = &zoran_vdev_release,
        .tvnorms = V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM,
-       .minor = -1
 };
 
index 2ef110b5221bd961d2d66fe995969cc133f870bb..f0eae83e3d89950b33dda05bf644e0f396932978 100644 (file)
@@ -1455,7 +1455,6 @@ static struct video_device zr364xx_template = {
        .fops = &zr364xx_fops,
        .ioctl_ops = &zr364xx_ioctl_ops,
        .release = video_device_release,
-       .minor = -1,
 };
 
 
@@ -1635,8 +1634,8 @@ static int zr364xx_probe(struct usb_interface *intf,
 
        spin_lock_init(&cam->slock);
 
-       dev_info(&udev->dev, DRIVER_DESC " controlling video device %d\n",
-                cam->vdev->num);
+       dev_info(&udev->dev, DRIVER_DESC " controlling device %s\n",
+                video_device_node_name(cam->vdev));
        return 0;
 }
 
index 610e914abe6cfc92bd83b097455f8f2f2e3b5cef..85bc6a685e36297291e6e677ee818094f7c7020b 100644 (file)
@@ -1587,7 +1587,7 @@ mpt_mapresources(MPT_ADAPTER *ioc)
 {
        u8              __iomem *mem;
        int              ii;
-       unsigned long    mem_phys;
+       resource_size_t  mem_phys;
        unsigned long    port;
        u32              msize;
        u32              psize;
@@ -1677,8 +1677,8 @@ mpt_mapresources(MPT_ADAPTER *ioc)
                return -EINVAL;
        }
        ioc->memmap = mem;
-       dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %lx\n",
-           ioc->name, mem, mem_phys));
+       dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %llx\n",
+           ioc->name, mem, (unsigned long long)mem_phys));
 
        ioc->mem_phys = mem_phys;
        ioc->chip = (SYSIF_REGS __iomem *)mem;
index 77b914907d7c20a96c9d1db4c2c18a9c8b49edda..700b149c1b918251285cd2a0d80582521cf1f976 100644 (file)
@@ -26,7 +26,7 @@
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/platform_device.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/twl4030-codec.h>
 
@@ -56,7 +56,7 @@ static int twl4030_codec_set_resource(enum twl4030_codec_res id, int enable)
        struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev);
        u8 val;
 
-       twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val,
+       twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val,
                        codec->resource[id].reg);
 
        if (enable)
@@ -64,7 +64,7 @@ static int twl4030_codec_set_resource(enum twl4030_codec_res id, int enable)
        else
                val &= ~codec->resource[id].mask;
 
-       twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
+       twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
                                        val, codec->resource[id].reg);
 
        return val;
@@ -75,7 +75,7 @@ static inline int twl4030_codec_get_resource(enum twl4030_codec_res id)
        struct twl4030_codec *codec = platform_get_drvdata(twl4030_codec_dev);
        u8 val;
 
-       twl4030_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val,
+       twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &val,
                        codec->resource[id].reg);
 
        return val;
@@ -183,7 +183,7 @@ static int __devinit twl4030_codec_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "Invalid audio_mclk\n");
                return -EINVAL;
        }
-       twl4030_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
+       twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
                                        val, TWL4030_REG_APLL_CTL);
 
        codec = kzalloc(sizeof(struct twl4030_codec), GFP_KERNEL);
index 223a90c7492fbe71710dd4e1538608db90b75605..4b2021af1d9646be71d5a257c9adc0ded9b8052d 100644 (file)
@@ -808,6 +808,9 @@ static struct resource wm831x_wdt_resources[] = {
 };
 
 static struct mfd_cell wm8310_devs[] = {
+       {
+               .name = "wm831x-backup",
+       },
        {
                .name = "wm831x-buckv",
                .id = 1,
@@ -961,6 +964,9 @@ static struct mfd_cell wm8310_devs[] = {
 };
 
 static struct mfd_cell wm8311_devs[] = {
+       {
+               .name = "wm831x-backup",
+       },
        {
                .name = "wm831x-buckv",
                .id = 1,
@@ -1095,6 +1101,9 @@ static struct mfd_cell wm8311_devs[] = {
 };
 
 static struct mfd_cell wm8312_devs[] = {
+       {
+               .name = "wm831x-backup",
+       },
        {
                .name = "wm831x-buckv",
                .id = 1,
index 2c16ca6501d5f58ab9ab66c9f718be22042a8126..e3551d20464fe8f56c9edecfd9babe8c496e1aec 100644 (file)
@@ -13,6 +13,20 @@ menuconfig MISC_DEVICES
 
 if MISC_DEVICES
 
+config AD525X_DPOT
+       tristate "Analog Devices AD525x Digital Potentiometers"
+       depends on I2C && SYSFS
+       help
+         If you say yes here, you get support for the Analog Devices
+         AD5258, AD5259, AD5251, AD5252, AD5253, AD5254 and AD5255
+         digital potentiometer chips.
+
+         See Documentation/misc-devices/ad525x_dpot.txt for the
+         userspace interface.
+
+         This driver can also be built as a module.  If so, the module
+         will be called ad525x_dpot.
+
 config ATMEL_PWM
        tristate "Atmel AT32/AT91 PWM support"
        depends on AVR32 || ARCH_AT91SAM9263 || ARCH_AT91SAM9RL || ARCH_AT91CAP9
@@ -173,6 +187,31 @@ config SGI_XP
          this feature will allow for direct communication between SSIs
          based on a network adapter and DMA messaging.
 
+config CS5535_MFGPT
+       tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support"
+       depends on PCI
+       depends on X86
+       default n
+       help
+         This driver provides access to MFGPT functionality for other
+         drivers that need timers.  MFGPTs are available in the CS5535 and
+         CS5536 companion chips that are found in AMD Geode and several
+         other platforms.  They have a better resolution and max interval
+         than the generic PIT, and are suitable for use as high-res timers.
+         You probably don't want to enable this manually; other drivers that
+         make use of it should enable it.
+
+config CS5535_MFGPT_DEFAULT_IRQ
+       int
+       depends on CS5535_MFGPT
+       default 7
+       help
+         MFGPTs on the CS5535 require an interrupt.  The selected IRQ
+         can be overridden as a module option as well as by driver that
+         use the cs5535_mfgpt_ API; however, different architectures might
+         want to use a different IRQ by default.  This is here for
+         architectures to set as necessary.
+
 config HP_ILO
        tristate "Channel interface driver for HP iLO/iLO2 processor"
        depends on PCI
@@ -210,19 +249,6 @@ config SGI_GRU_DEBUG
        This option enables addition debugging code for the SGI GRU driver. If
        you are unsure, say N.
 
-config DELL_LAPTOP
-       tristate "Dell Laptop Extras (EXPERIMENTAL)"
-       depends on X86
-       depends on DCDBAS
-       depends on EXPERIMENTAL
-       depends on BACKLIGHT_CLASS_DEVICE
-       depends on RFKILL
-       depends on POWER_SUPPLY
-       default n
-       ---help---
-       This driver adds support for rfkill and backlight control to Dell
-       laptops.
-
 config ISL29003
        tristate "Intersil ISL29003 ambient light sensor"
        depends on I2C && SYSFS
@@ -256,6 +282,16 @@ config DS1682
          This driver can also be built as a module.  If so, the module
          will be called ds1682.
 
+config TI_DAC7512
+       tristate "Texas Instruments DAC7512"
+       depends on SPI && SYSFS
+       help
+         If you say yes here you get support for the Texas Instruments
+         DAC7512 16-bit digital-to-analog converter.
+
+         This driver can also be built as a module. If so, the module
+         will be calles ti_dac7512.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
index 906a0edcea40e16f79d7af76c1635edd995fd684..049ff2482f309999e2be3e7517c89ea727ab4e74 100644 (file)
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_IBM_ASM)          += ibmasm/
 obj-$(CONFIG_HDPU_FEATURES)    += hdpuftrs/
+obj-$(CONFIG_AD525X_DPOT)      += ad525x_dpot.o
 obj-$(CONFIG_ATMEL_PWM)                += atmel_pwm.o
 obj-$(CONFIG_ATMEL_SSC)                += atmel-ssc.o
 obj-$(CONFIG_ATMEL_TCLIB)      += atmel_tclib.o
@@ -17,10 +18,12 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
 obj-$(CONFIG_KGDB_TESTS)       += kgdbts.o
 obj-$(CONFIG_SGI_XP)           += sgi-xp/
 obj-$(CONFIG_SGI_GRU)          += sgi-gru/
+obj-$(CONFIG_CS5535_MFGPT)     += cs5535-mfgpt.o
 obj-$(CONFIG_HP_ILO)           += hpilo.o
 obj-$(CONFIG_ISL29003)         += isl29003.o
 obj-$(CONFIG_EP93XX_PWM)       += ep93xx_pwm.o
 obj-$(CONFIG_DS1682)           += ds1682.o
+obj-$(CONFIG_TI_DAC7512)       += ti_dac7512.o
 obj-$(CONFIG_C2PORT)           += c2port/
 obj-$(CONFIG_IWMC3200TOP)      += iwmc3200top/
 obj-y                          += eeprom/
diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
new file mode 100644 (file)
index 0000000..30a59f2
--- /dev/null
@@ -0,0 +1,666 @@
+/*
+ * ad525x_dpot: Driver for the Analog Devices AD525x digital potentiometers
+ * Copyright (c) 2009 Analog Devices, Inc.
+ * Author: Michael Hennerich <hennerich@blackfin.uclinux.org>
+ *
+ * DEVID               #Wipers         #Positions      Resistor Options (kOhm)
+ * AD5258              1               64              1, 10, 50, 100
+ * AD5259              1               256             5, 10, 50, 100
+ * AD5251              2               64              1, 10, 50, 100
+ * AD5252              2               256             1, 10, 50, 100
+ * AD5255              3               512             25, 250
+ * AD5253              4               64              1, 10, 50, 100
+ * AD5254              4               256             1, 10, 50, 100
+ *
+ * See Documentation/misc-devices/ad525x_dpot.txt for more info.
+ *
+ * derived from ad5258.c
+ * Copyright (c) 2009 Cyber Switching, Inc.
+ * Author: Chris Verges <chrisv@cyberswitching.com>
+ *
+ * derived from ad5252.c
+ * Copyright (c) 2006 Michael Hennerich <hennerich@blackfin.uclinux.org>
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/delay.h>
+
+#define DRIVER_NAME                    "ad525x_dpot"
+#define DRIVER_VERSION                 "0.1"
+
+enum dpot_devid {
+       AD5258_ID,
+       AD5259_ID,
+       AD5251_ID,
+       AD5252_ID,
+       AD5253_ID,
+       AD5254_ID,
+       AD5255_ID,
+};
+
+#define AD5258_MAX_POSITION            64
+#define AD5259_MAX_POSITION            256
+#define AD5251_MAX_POSITION            64
+#define AD5252_MAX_POSITION            256
+#define AD5253_MAX_POSITION            64
+#define AD5254_MAX_POSITION            256
+#define AD5255_MAX_POSITION            512
+
+#define AD525X_RDAC0           0
+#define AD525X_RDAC1           1
+#define AD525X_RDAC2           2
+#define AD525X_RDAC3           3
+
+#define AD525X_REG_TOL         0x18
+#define AD525X_TOL_RDAC0       (AD525X_REG_TOL | AD525X_RDAC0)
+#define AD525X_TOL_RDAC1       (AD525X_REG_TOL | AD525X_RDAC1)
+#define AD525X_TOL_RDAC2       (AD525X_REG_TOL | AD525X_RDAC2)
+#define AD525X_TOL_RDAC3       (AD525X_REG_TOL | AD525X_RDAC3)
+
+/* RDAC-to-EEPROM Interface Commands */
+#define AD525X_I2C_RDAC                (0x00 << 5)
+#define AD525X_I2C_EEPROM      (0x01 << 5)
+#define AD525X_I2C_CMD         (0x80)
+
+#define AD525X_DEC_ALL_6DB     (AD525X_I2C_CMD | (0x4 << 3))
+#define AD525X_INC_ALL_6DB     (AD525X_I2C_CMD | (0x9 << 3))
+#define AD525X_DEC_ALL         (AD525X_I2C_CMD | (0x6 << 3))
+#define AD525X_INC_ALL         (AD525X_I2C_CMD | (0xB << 3))
+
+static s32 ad525x_read(struct i2c_client *client, u8 reg);
+static s32 ad525x_write(struct i2c_client *client, u8 reg, u8 value);
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct dpot_data {
+       struct mutex update_lock;
+       unsigned rdac_mask;
+       unsigned max_pos;
+       unsigned devid;
+};
+
+/* sysfs functions */
+
+static ssize_t sysfs_show_reg(struct device *dev,
+                             struct device_attribute *attr, char *buf, u32 reg)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct dpot_data *data = i2c_get_clientdata(client);
+       s32 value;
+
+       mutex_lock(&data->update_lock);
+       value = ad525x_read(client, reg);
+       mutex_unlock(&data->update_lock);
+
+       if (value < 0)
+               return -EINVAL;
+       /*
+        * Let someone else deal with converting this ...
+        * the tolerance is a two-byte value where the MSB
+        * is a sign + integer value, and the LSB is a
+        * decimal value.  See page 18 of the AD5258
+        * datasheet (Rev. A) for more details.
+        */
+
+       if (reg & AD525X_REG_TOL)
+               return sprintf(buf, "0x%04x\n", value & 0xFFFF);
+       else
+               return sprintf(buf, "%u\n", value & data->rdac_mask);
+}
+
+static ssize_t sysfs_set_reg(struct device *dev,
+                            struct device_attribute *attr,
+                            const char *buf, size_t count, u32 reg)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct dpot_data *data = i2c_get_clientdata(client);
+       unsigned long value;
+       int err;
+
+       err = strict_strtoul(buf, 10, &value);
+       if (err)
+               return err;
+
+       if (value > data->rdac_mask)
+               value = data->rdac_mask;
+
+       mutex_lock(&data->update_lock);
+       ad525x_write(client, reg, value);
+       if (reg & AD525X_I2C_EEPROM)
+               msleep(26);     /* Sleep while the EEPROM updates */
+       mutex_unlock(&data->update_lock);
+
+       return count;
+}
+
+static ssize_t sysfs_do_cmd(struct device *dev,
+                           struct device_attribute *attr,
+                           const char *buf, size_t count, u32 reg)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct dpot_data *data = i2c_get_clientdata(client);
+
+       mutex_lock(&data->update_lock);
+       ad525x_write(client, reg, 0);
+       mutex_unlock(&data->update_lock);
+
+       return count;
+}
+
+/* ------------------------------------------------------------------------- */
+
+static ssize_t show_rdac0(struct device *dev,
+                         struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf, AD525X_I2C_RDAC | AD525X_RDAC0);
+}
+
+static ssize_t set_rdac0(struct device *dev,
+                        struct device_attribute *attr,
+                        const char *buf, size_t count)
+{
+       return sysfs_set_reg(dev, attr, buf, count,
+                            AD525X_I2C_RDAC | AD525X_RDAC0);
+}
+
+static DEVICE_ATTR(rdac0, S_IWUSR | S_IRUGO, show_rdac0, set_rdac0);
+
+static ssize_t show_eeprom0(struct device *dev,
+                           struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf, AD525X_I2C_EEPROM | AD525X_RDAC0);
+}
+
+static ssize_t set_eeprom0(struct device *dev,
+                          struct device_attribute *attr,
+                          const char *buf, size_t count)
+{
+       return sysfs_set_reg(dev, attr, buf, count,
+                            AD525X_I2C_EEPROM | AD525X_RDAC0);
+}
+
+static DEVICE_ATTR(eeprom0, S_IWUSR | S_IRUGO, show_eeprom0, set_eeprom0);
+
+static ssize_t show_tolerance0(struct device *dev,
+                              struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf,
+                             AD525X_I2C_EEPROM | AD525X_TOL_RDAC0);
+}
+
+static DEVICE_ATTR(tolerance0, S_IRUGO, show_tolerance0, NULL);
+
+/* ------------------------------------------------------------------------- */
+
+static ssize_t show_rdac1(struct device *dev,
+                         struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf, AD525X_I2C_RDAC | AD525X_RDAC1);
+}
+
+static ssize_t set_rdac1(struct device *dev,
+                        struct device_attribute *attr,
+                        const char *buf, size_t count)
+{
+       return sysfs_set_reg(dev, attr, buf, count,
+                            AD525X_I2C_RDAC | AD525X_RDAC1);
+}
+
+static DEVICE_ATTR(rdac1, S_IWUSR | S_IRUGO, show_rdac1, set_rdac1);
+
+static ssize_t show_eeprom1(struct device *dev,
+                           struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf, AD525X_I2C_EEPROM | AD525X_RDAC1);
+}
+
+static ssize_t set_eeprom1(struct device *dev,
+                          struct device_attribute *attr,
+                          const char *buf, size_t count)
+{
+       return sysfs_set_reg(dev, attr, buf, count,
+                            AD525X_I2C_EEPROM | AD525X_RDAC1);
+}
+
+static DEVICE_ATTR(eeprom1, S_IWUSR | S_IRUGO, show_eeprom1, set_eeprom1);
+
+static ssize_t show_tolerance1(struct device *dev,
+                              struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf,
+                             AD525X_I2C_EEPROM | AD525X_TOL_RDAC1);
+}
+
+static DEVICE_ATTR(tolerance1, S_IRUGO, show_tolerance1, NULL);
+
+/* ------------------------------------------------------------------------- */
+
+static ssize_t show_rdac2(struct device *dev,
+                         struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf, AD525X_I2C_RDAC | AD525X_RDAC2);
+}
+
+static ssize_t set_rdac2(struct device *dev,
+                        struct device_attribute *attr,
+                        const char *buf, size_t count)
+{
+       return sysfs_set_reg(dev, attr, buf, count,
+                            AD525X_I2C_RDAC | AD525X_RDAC2);
+}
+
+static DEVICE_ATTR(rdac2, S_IWUSR | S_IRUGO, show_rdac2, set_rdac2);
+
+static ssize_t show_eeprom2(struct device *dev,
+                           struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf, AD525X_I2C_EEPROM | AD525X_RDAC2);
+}
+
+static ssize_t set_eeprom2(struct device *dev,
+                          struct device_attribute *attr,
+                          const char *buf, size_t count)
+{
+       return sysfs_set_reg(dev, attr, buf, count,
+                            AD525X_I2C_EEPROM | AD525X_RDAC2);
+}
+
+static DEVICE_ATTR(eeprom2, S_IWUSR | S_IRUGO, show_eeprom2, set_eeprom2);
+
+static ssize_t show_tolerance2(struct device *dev,
+                              struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf,
+                             AD525X_I2C_EEPROM | AD525X_TOL_RDAC2);
+}
+
+static DEVICE_ATTR(tolerance2, S_IRUGO, show_tolerance2, NULL);
+
+/* ------------------------------------------------------------------------- */
+
+static ssize_t show_rdac3(struct device *dev,
+                         struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf, AD525X_I2C_RDAC | AD525X_RDAC3);
+}
+
+static ssize_t set_rdac3(struct device *dev,
+                        struct device_attribute *attr,
+                        const char *buf, size_t count)
+{
+       return sysfs_set_reg(dev, attr, buf, count,
+                            AD525X_I2C_RDAC | AD525X_RDAC3);
+}
+
+static DEVICE_ATTR(rdac3, S_IWUSR | S_IRUGO, show_rdac3, set_rdac3);
+
+static ssize_t show_eeprom3(struct device *dev,
+                           struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf, AD525X_I2C_EEPROM | AD525X_RDAC3);
+}
+
+static ssize_t set_eeprom3(struct device *dev,
+                          struct device_attribute *attr,
+                          const char *buf, size_t count)
+{
+       return sysfs_set_reg(dev, attr, buf, count,
+                            AD525X_I2C_EEPROM | AD525X_RDAC3);
+}
+
+static DEVICE_ATTR(eeprom3, S_IWUSR | S_IRUGO, show_eeprom3, set_eeprom3);
+
+static ssize_t show_tolerance3(struct device *dev,
+                              struct device_attribute *attr, char *buf)
+{
+       return sysfs_show_reg(dev, attr, buf,
+                             AD525X_I2C_EEPROM | AD525X_TOL_RDAC3);
+}
+
+static DEVICE_ATTR(tolerance3, S_IRUGO, show_tolerance3, NULL);
+
+static struct attribute *ad525x_attributes_wipers[4][4] = {
+       {
+               &dev_attr_rdac0.attr,
+               &dev_attr_eeprom0.attr,
+               &dev_attr_tolerance0.attr,
+               NULL
+       }, {
+               &dev_attr_rdac1.attr,
+               &dev_attr_eeprom1.attr,
+               &dev_attr_tolerance1.attr,
+               NULL
+       }, {
+               &dev_attr_rdac2.attr,
+               &dev_attr_eeprom2.attr,
+               &dev_attr_tolerance2.attr,
+               NULL
+       }, {
+               &dev_attr_rdac3.attr,
+               &dev_attr_eeprom3.attr,
+               &dev_attr_tolerance3.attr,
+               NULL
+       }
+};
+
+static const struct attribute_group ad525x_group_wipers[] = {
+       {.attrs = ad525x_attributes_wipers[AD525X_RDAC0]},
+       {.attrs = ad525x_attributes_wipers[AD525X_RDAC1]},
+       {.attrs = ad525x_attributes_wipers[AD525X_RDAC2]},
+       {.attrs = ad525x_attributes_wipers[AD525X_RDAC3]},
+};
+
+/* ------------------------------------------------------------------------- */
+
+static ssize_t set_inc_all(struct device *dev,
+                          struct device_attribute *attr,
+                          const char *buf, size_t count)
+{
+       return sysfs_do_cmd(dev, attr, buf, count, AD525X_INC_ALL);
+}
+
+static DEVICE_ATTR(inc_all, S_IWUSR, NULL, set_inc_all);
+
+static ssize_t set_dec_all(struct device *dev,
+                          struct device_attribute *attr,
+                          const char *buf, size_t count)
+{
+       return sysfs_do_cmd(dev, attr, buf, count, AD525X_DEC_ALL);
+}
+
+static DEVICE_ATTR(dec_all, S_IWUSR, NULL, set_dec_all);
+
+static ssize_t set_inc_all_6db(struct device *dev,
+                              struct device_attribute *attr,
+                              const char *buf, size_t count)
+{
+       return sysfs_do_cmd(dev, attr, buf, count, AD525X_INC_ALL_6DB);
+}
+
+static DEVICE_ATTR(inc_all_6db, S_IWUSR, NULL, set_inc_all_6db);
+
+static ssize_t set_dec_all_6db(struct device *dev,
+                              struct device_attribute *attr,
+                              const char *buf, size_t count)
+{
+       return sysfs_do_cmd(dev, attr, buf, count, AD525X_DEC_ALL_6DB);
+}
+
+static DEVICE_ATTR(dec_all_6db, S_IWUSR, NULL, set_dec_all_6db);
+
+static struct attribute *ad525x_attributes_commands[] = {
+       &dev_attr_inc_all.attr,
+       &dev_attr_dec_all.attr,
+       &dev_attr_inc_all_6db.attr,
+       &dev_attr_dec_all_6db.attr,
+       NULL
+};
+
+static const struct attribute_group ad525x_group_commands = {
+       .attrs = ad525x_attributes_commands,
+};
+
+/* ------------------------------------------------------------------------- */
+
+/* i2c device functions */
+
+/**
+ * ad525x_read - return the value contained in the specified register
+ * on the AD5258 device.
+ * @client: value returned from i2c_new_device()
+ * @reg: the register to read
+ *
+ * If the tolerance register is specified, 2 bytes are returned.
+ * Otherwise, 1 byte is returned.  A negative value indicates an error
+ * occurred while reading the register.
+ */
+static s32 ad525x_read(struct i2c_client *client, u8 reg)
+{
+       struct dpot_data *data = i2c_get_clientdata(client);
+
+       if ((reg & AD525X_REG_TOL) || (data->max_pos > 256))
+               return i2c_smbus_read_word_data(client, (reg & 0xF8) |
+                                               ((reg & 0x7) << 1));
+       else
+               return i2c_smbus_read_byte_data(client, reg);
+}
+
+/**
+ * ad525x_write - store the given value in the specified register on
+ * the AD5258 device.
+ * @client: value returned from i2c_new_device()
+ * @reg: the register to write
+ * @value: the byte to store in the register
+ *
+ * For certain instructions that do not require a data byte, "NULL"
+ * should be specified for the "value" parameter.  These instructions
+ * include NOP, RESTORE_FROM_EEPROM, and STORE_TO_EEPROM.
+ *
+ * A negative return value indicates an error occurred while reading
+ * the register.
+ */
+static s32 ad525x_write(struct i2c_client *client, u8 reg, u8 value)
+{
+       struct dpot_data *data = i2c_get_clientdata(client);
+
+       /* Only write the instruction byte for certain commands */
+       if (reg & AD525X_I2C_CMD)
+               return i2c_smbus_write_byte(client, reg);
+
+       if (data->max_pos > 256)
+               return i2c_smbus_write_word_data(client, (reg & 0xF8) |
+                                               ((reg & 0x7) << 1), value);
+       else
+               /* All other registers require instruction + data bytes */
+               return i2c_smbus_write_byte_data(client, reg, value);
+}
+
+static int ad525x_probe(struct i2c_client *client,
+                       const struct i2c_device_id *id)
+{
+       struct device *dev = &client->dev;
+       struct dpot_data *data;
+       int err = 0;
+
+       dev_dbg(dev, "%s\n", __func__);
+
+       if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) {
+               dev_err(dev, "missing I2C functionality for this driver\n");
+               goto exit;
+       }
+
+       data = kzalloc(sizeof(struct dpot_data), GFP_KERNEL);
+       if (!data) {
+               err = -ENOMEM;
+               goto exit;
+       }
+
+       i2c_set_clientdata(client, data);
+       mutex_init(&data->update_lock);
+
+       switch (id->driver_data) {
+       case AD5258_ID:
+               data->max_pos = AD5258_MAX_POSITION;
+               err = sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC0]);
+               break;
+       case AD5259_ID:
+               data->max_pos = AD5259_MAX_POSITION;
+               err = sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC0]);
+               break;
+       case AD5251_ID:
+               data->max_pos = AD5251_MAX_POSITION;
+               err = sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC1]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC3]);
+               err |= sysfs_create_group(&dev->kobj, &ad525x_group_commands);
+               break;
+       case AD5252_ID:
+               data->max_pos = AD5252_MAX_POSITION;
+               err = sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC1]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC3]);
+               err |= sysfs_create_group(&dev->kobj, &ad525x_group_commands);
+               break;
+       case AD5253_ID:
+               data->max_pos = AD5253_MAX_POSITION;
+               err = sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC0]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC1]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC2]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC3]);
+               err |= sysfs_create_group(&dev->kobj, &ad525x_group_commands);
+               break;
+       case AD5254_ID:
+               data->max_pos = AD5254_MAX_POSITION;
+               err = sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC0]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC1]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC2]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC3]);
+               err |= sysfs_create_group(&dev->kobj, &ad525x_group_commands);
+               break;
+       case AD5255_ID:
+               data->max_pos = AD5255_MAX_POSITION;
+               err = sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC0]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC1]);
+               err |= sysfs_create_group(&dev->kobj,
+                                      &ad525x_group_wipers[AD525X_RDAC2]);
+               err |= sysfs_create_group(&dev->kobj, &ad525x_group_commands);
+               break;
+       default:
+               err = -ENODEV;
+               goto exit_free;
+       }
+
+       if (err) {
+               dev_err(dev, "failed to register sysfs hooks\n");
+               goto exit_free;
+       }
+
+       data->devid = id->driver_data;
+       data->rdac_mask = data->max_pos - 1;
+
+       dev_info(dev, "%s %d-Position Digital Potentiometer registered\n",
+                id->name, data->max_pos);
+
+       return 0;
+
+exit_free:
+       kfree(data);
+       i2c_set_clientdata(client, NULL);
+exit:
+       dev_err(dev, "failed to create client\n");
+       return err;
+}
+
+static int __devexit ad525x_remove(struct i2c_client *client)
+{
+       struct dpot_data *data = i2c_get_clientdata(client);
+       struct device *dev = &client->dev;
+
+       switch (data->devid) {
+       case AD5258_ID:
+       case AD5259_ID:
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC0]);
+               break;
+       case AD5251_ID:
+       case AD5252_ID:
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC1]);
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC3]);
+               sysfs_remove_group(&dev->kobj, &ad525x_group_commands);
+               break;
+       case AD5253_ID:
+       case AD5254_ID:
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC0]);
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC1]);
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC2]);
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC3]);
+               sysfs_remove_group(&dev->kobj, &ad525x_group_commands);
+               break;
+       case AD5255_ID:
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC0]);
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC1]);
+               sysfs_remove_group(&dev->kobj,
+                                  &ad525x_group_wipers[AD525X_RDAC2]);
+               sysfs_remove_group(&dev->kobj, &ad525x_group_commands);
+               break;
+       }
+
+       i2c_set_clientdata(client, NULL);
+       kfree(data);
+
+       return 0;
+}
+
+static const struct i2c_device_id ad525x_idtable[] = {
+       {"ad5258", AD5258_ID},
+       {"ad5259", AD5259_ID},
+       {"ad5251", AD5251_ID},
+       {"ad5252", AD5252_ID},
+       {"ad5253", AD5253_ID},
+       {"ad5254", AD5254_ID},
+       {"ad5255", AD5255_ID},
+       {}
+};
+
+MODULE_DEVICE_TABLE(i2c, ad525x_idtable);
+
+static struct i2c_driver ad525x_driver = {
+       .driver = {
+                  .owner = THIS_MODULE,
+                  .name = DRIVER_NAME,
+                  },
+       .id_table = ad525x_idtable,
+       .probe = ad525x_probe,
+       .remove = __devexit_p(ad525x_remove),
+};
+
+static int __init ad525x_init(void)
+{
+       return i2c_add_driver(&ad525x_driver);
+}
+
+module_init(ad525x_init);
+
+static void __exit ad525x_exit(void)
+{
+       i2c_del_driver(&ad525x_driver);
+}
+
+module_exit(ad525x_exit);
+
+MODULE_AUTHOR("Chris Verges <chrisv@cyberswitching.com>, "
+             "Michael Hennerich <hennerich@blackfin.uclinux.org>, ");
+MODULE_DESCRIPTION("AD5258/9 digital potentiometer driver");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRIVER_VERSION);
diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c
new file mode 100644 (file)
index 0000000..8110460
--- /dev/null
@@ -0,0 +1,370 @@
+/*
+ * Driver for the CS5535/CS5536 Multi-Function General Purpose Timers (MFGPT)
+ *
+ * Copyright (C) 2006, Advanced Micro Devices, Inc.
+ * Copyright (C) 2007  Andres Salomon <dilinger@debian.org>
+ * Copyright (C) 2009  Andres Salomon <dilinger@collabora.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * The MFGPTs are documented in AMD Geode CS5536 Companion Device Data Book.
+ */
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/cs5535.h>
+
+#define DRV_NAME "cs5535-mfgpt"
+#define MFGPT_BAR 2
+
+static int mfgpt_reset_timers;
+module_param_named(mfgptfix, mfgpt_reset_timers, int, 0644);
+MODULE_PARM_DESC(mfgptfix, "Reset the MFGPT timers during init; "
+               "required by some broken BIOSes (ie, TinyBIOS < 0.99).");
+
+struct cs5535_mfgpt_timer {
+       struct cs5535_mfgpt_chip *chip;
+       int nr;
+};
+
+static struct cs5535_mfgpt_chip {
+       DECLARE_BITMAP(avail, MFGPT_MAX_TIMERS);
+       resource_size_t base;
+
+       struct pci_dev *pdev;
+       spinlock_t lock;
+       int initialized;
+} cs5535_mfgpt_chip;
+
+int cs5535_mfgpt_toggle_event(struct cs5535_mfgpt_timer *timer, int cmp,
+               int event, int enable)
+{
+       uint32_t msr, mask, value, dummy;
+       int shift = (cmp == MFGPT_CMP1) ? 0 : 8;
+
+       if (!timer) {
+               WARN_ON(1);
+               return -EIO;
+       }
+
+       /*
+        * The register maps for these are described in sections 6.17.1.x of
+        * the AMD Geode CS5536 Companion Device Data Book.
+        */
+       switch (event) {
+       case MFGPT_EVENT_RESET:
+               /*
+                * XXX: According to the docs, we cannot reset timers above
+                * 6; that is, resets for 7 and 8 will be ignored.  Is this
+                * a problem?   -dilinger
+                */
+               msr = MSR_MFGPT_NR;
+               mask = 1 << (timer->nr + 24);
+               break;
+
+       case MFGPT_EVENT_NMI:
+               msr = MSR_MFGPT_NR;
+               mask = 1 << (timer->nr + shift);
+               break;
+
+       case MFGPT_EVENT_IRQ:
+               msr = MSR_MFGPT_IRQ;
+               mask = 1 << (timer->nr + shift);
+               break;
+
+       default:
+               return -EIO;
+       }
+
+       rdmsr(msr, value, dummy);
+
+       if (enable)
+               value |= mask;
+       else
+               value &= ~mask;
+
+       wrmsr(msr, value, dummy);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(cs5535_mfgpt_toggle_event);
+
+int cs5535_mfgpt_set_irq(struct cs5535_mfgpt_timer *timer, int cmp, int *irq,
+               int enable)
+{
+       uint32_t zsel, lpc, dummy;
+       int shift;
+
+       if (!timer) {
+               WARN_ON(1);
+               return -EIO;
+       }
+
+       /*
+        * Unfortunately, MFGPTs come in pairs sharing their IRQ lines. If VSA
+        * is using the same CMP of the timer's Siamese twin, the IRQ is set to
+        * 2, and we mustn't use nor change it.
+        * XXX: Likewise, 2 Linux drivers might clash if the 2nd overwrites the
+        * IRQ of the 1st. This can only happen if forcing an IRQ, calling this
+        * with *irq==0 is safe. Currently there _are_ no 2 drivers.
+        */
+       rdmsr(MSR_PIC_ZSEL_LOW, zsel, dummy);
+       shift = ((cmp == MFGPT_CMP1 ? 0 : 4) + timer->nr % 4) * 4;
+       if (((zsel >> shift) & 0xF) == 2)
+               return -EIO;
+
+       /* Choose IRQ: if none supplied, keep IRQ already set or use default */
+       if (!*irq)
+               *irq = (zsel >> shift) & 0xF;
+       if (!*irq)
+               *irq = CONFIG_CS5535_MFGPT_DEFAULT_IRQ;
+
+       /* Can't use IRQ if it's 0 (=disabled), 2, or routed to LPC */
+       if (*irq < 1 || *irq == 2 || *irq > 15)
+               return -EIO;
+       rdmsr(MSR_PIC_IRQM_LPC, lpc, dummy);
+       if (lpc & (1 << *irq))
+               return -EIO;
+
+       /* All chosen and checked - go for it */
+       if (cs5535_mfgpt_toggle_event(timer, cmp, MFGPT_EVENT_IRQ, enable))
+               return -EIO;
+       if (enable) {
+               zsel = (zsel & ~(0xF << shift)) | (*irq << shift);
+               wrmsr(MSR_PIC_ZSEL_LOW, zsel, dummy);
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(cs5535_mfgpt_set_irq);
+
+struct cs5535_mfgpt_timer *cs5535_mfgpt_alloc_timer(int timer_nr, int domain)
+{
+       struct cs5535_mfgpt_chip *mfgpt = &cs5535_mfgpt_chip;
+       struct cs5535_mfgpt_timer *timer = NULL;
+       unsigned long flags;
+       int max;
+
+       if (!mfgpt->initialized)
+               goto done;
+
+       /* only allocate timers from the working domain if requested */
+       if (domain == MFGPT_DOMAIN_WORKING)
+               max = 6;
+       else
+               max = MFGPT_MAX_TIMERS;
+
+       if (timer_nr >= max) {
+               /* programmer error.  silly programmers! */
+               WARN_ON(1);
+               goto done;
+       }
+
+       spin_lock_irqsave(&mfgpt->lock, flags);
+       if (timer_nr < 0) {
+               unsigned long t;
+
+               /* try to find any available timer */
+               t = find_first_bit(mfgpt->avail, max);
+               /* set timer_nr to -1 if no timers available */
+               timer_nr = t < max ? (int) t : -1;
+       } else {
+               /* check if the requested timer's available */
+               if (test_bit(timer_nr, mfgpt->avail))
+                       timer_nr = -1;
+       }
+
+       if (timer_nr >= 0)
+               /* if timer_nr is not -1, it's an available timer */
+               __clear_bit(timer_nr, mfgpt->avail);
+       spin_unlock_irqrestore(&mfgpt->lock, flags);
+
+       if (timer_nr < 0)
+               goto done;
+
+       timer = kmalloc(sizeof(*timer), GFP_KERNEL);
+       if (!timer) {
+               /* aw hell */
+               spin_lock_irqsave(&mfgpt->lock, flags);
+               __set_bit(timer_nr, mfgpt->avail);
+               spin_unlock_irqrestore(&mfgpt->lock, flags);
+               goto done;
+       }
+       timer->chip = mfgpt;
+       timer->nr = timer_nr;
+       dev_info(&mfgpt->pdev->dev, "registered timer %d\n", timer_nr);
+
+done:
+       return timer;
+}
+EXPORT_SYMBOL_GPL(cs5535_mfgpt_alloc_timer);
+
+/*
+ * XXX: This frees the timer memory, but never resets the actual hardware
+ * timer.  The old geode_mfgpt code did this; it would be good to figure
+ * out a way to actually release the hardware timer.  See comments below.
+ */
+void cs5535_mfgpt_free_timer(struct cs5535_mfgpt_timer *timer)
+{
+       kfree(timer);
+}
+EXPORT_SYMBOL_GPL(cs5535_mfgpt_free_timer);
+
+uint16_t cs5535_mfgpt_read(struct cs5535_mfgpt_timer *timer, uint16_t reg)
+{
+       return inw(timer->chip->base + reg + (timer->nr * 8));
+}
+EXPORT_SYMBOL_GPL(cs5535_mfgpt_read);
+
+void cs5535_mfgpt_write(struct cs5535_mfgpt_timer *timer, uint16_t reg,
+               uint16_t value)
+{
+       outw(value, timer->chip->base + reg + (timer->nr * 8));
+}
+EXPORT_SYMBOL_GPL(cs5535_mfgpt_write);
+
+/*
+ * This is a sledgehammer that resets all MFGPT timers. This is required by
+ * some broken BIOSes which leave the system in an unstable state
+ * (TinyBIOS 0.98, for example; fixed in 0.99).  It's uncertain as to
+ * whether or not this secret MSR can be used to release individual timers.
+ * Jordan tells me that he and Mitch once played w/ it, but it's unclear
+ * what the results of that were (and they experienced some instability).
+ */
+static void __init reset_all_timers(void)
+{
+       uint32_t val, dummy;
+
+       /* The following undocumented bit resets the MFGPT timers */
+       val = 0xFF; dummy = 0;
+       wrmsr(MSR_MFGPT_SETUP, val, dummy);
+}
+
+/*
+ * Check whether any MFGPTs are available for the kernel to use.  In most
+ * cases, firmware that uses AMD's VSA code will claim all timers during
+ * bootup; we certainly don't want to take them if they're already in use.
+ * In other cases (such as with VSAless OpenFirmware), the system firmware
+ * leaves timers available for us to use.
+ */
+static int __init scan_timers(struct cs5535_mfgpt_chip *mfgpt)
+{
+       struct cs5535_mfgpt_timer timer = { .chip = mfgpt };
+       unsigned long flags;
+       int timers = 0;
+       uint16_t val;
+       int i;
+
+       /* bios workaround */
+       if (mfgpt_reset_timers)
+               reset_all_timers();
+
+       /* just to be safe, protect this section w/ lock */
+       spin_lock_irqsave(&mfgpt->lock, flags);
+       for (i = 0; i < MFGPT_MAX_TIMERS; i++) {
+               timer.nr = i;
+               val = cs5535_mfgpt_read(&timer, MFGPT_REG_SETUP);
+               if (!(val & MFGPT_SETUP_SETUP)) {
+                       __set_bit(i, mfgpt->avail);
+                       timers++;
+               }
+       }
+       spin_unlock_irqrestore(&mfgpt->lock, flags);
+
+       return timers;
+}
+
+static int __init cs5535_mfgpt_probe(struct pci_dev *pdev,
+               const struct pci_device_id *pci_id)
+{
+       int err, t;
+
+       /* There are two ways to get the MFGPT base address; one is by
+        * fetching it from MSR_LBAR_MFGPT, the other is by reading the
+        * PCI BAR info.  The latter method is easier (especially across
+        * different architectures), so we'll stick with that for now.  If
+        * it turns out to be unreliable in the face of crappy BIOSes, we
+        * can always go back to using MSRs.. */
+
+       err = pci_enable_device_io(pdev);
+       if (err) {
+               dev_err(&pdev->dev, "can't enable device IO\n");
+               goto done;
+       }
+
+       err = pci_request_region(pdev, MFGPT_BAR, DRV_NAME);
+       if (err) {
+               dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", MFGPT_BAR);
+               goto done;
+       }
+
+       /* set up the driver-specific struct */
+       cs5535_mfgpt_chip.base = pci_resource_start(pdev, MFGPT_BAR);
+       cs5535_mfgpt_chip.pdev = pdev;
+       spin_lock_init(&cs5535_mfgpt_chip.lock);
+
+       dev_info(&pdev->dev, "allocated PCI BAR #%d: base 0x%llx\n", MFGPT_BAR,
+                       (unsigned long long) cs5535_mfgpt_chip.base);
+
+       /* detect the available timers */
+       t = scan_timers(&cs5535_mfgpt_chip);
+       dev_info(&pdev->dev, DRV_NAME ": %d MFGPT timers available\n", t);
+       cs5535_mfgpt_chip.initialized = 1;
+       return 0;
+
+done:
+       return err;
+}
+
+static struct pci_device_id cs5535_mfgpt_pci_tbl[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) },
+       { 0, },
+};
+MODULE_DEVICE_TABLE(pci, cs5535_mfgpt_pci_tbl);
+
+/*
+ * Just like with the cs5535-gpio driver, we can't use the standard PCI driver
+ * registration stuff.  It only allows only one driver to bind to each PCI
+ * device, and we want the GPIO and MFGPT drivers to be able to share a PCI
+ * device.  Instead, we manually scan for the PCI device, request a single
+ * region, and keep track of the devices that we're using.
+ */
+
+static int __init cs5535_mfgpt_scan_pci(void)
+{
+       struct pci_dev *pdev;
+       int err = -ENODEV;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(cs5535_mfgpt_pci_tbl); i++) {
+               pdev = pci_get_device(cs5535_mfgpt_pci_tbl[i].vendor,
+                               cs5535_mfgpt_pci_tbl[i].device, NULL);
+               if (pdev) {
+                       err = cs5535_mfgpt_probe(pdev,
+                                       &cs5535_mfgpt_pci_tbl[i]);
+                       if (err)
+                               pci_dev_put(pdev);
+
+                       /* we only support a single CS5535/6 southbridge */
+                       break;
+               }
+       }
+
+       return err;
+}
+
+static int __init cs5535_mfgpt_init(void)
+{
+       return cs5535_mfgpt_scan_pci();
+}
+
+module_init(cs5535_mfgpt_init);
+
+MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>");
+MODULE_DESCRIPTION("CS5535/CS5536 MFGPT timer driver");
+MODULE_LICENSE("GPL");
index 2c27193aeaa04721ee3159a279e4925abf28edd5..f939ebc2507c48ef64af3e5cfe632b387d744d14 100644 (file)
@@ -32,9 +32,6 @@
 static const unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
                                        0x55, 0x56, 0x57, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(eeprom);
-
 
 /* Size of EEPROM in bytes */
 #define EEPROM_SIZE            256
@@ -135,8 +132,7 @@ static struct bin_attribute eeprom_attr = {
 };
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int eeprom_detect(struct i2c_client *client, int kind,
-                        struct i2c_board_info *info)
+static int eeprom_detect(struct i2c_client *client, struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
 
@@ -233,7 +229,7 @@ static struct i2c_driver eeprom_driver = {
 
        .class          = I2C_CLASS_DDC | I2C_CLASS_SPD,
        .detect         = eeprom_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static int __init eeprom_init(void)
index e9eae4a784026303935d5f475e0ce938832d220d..1eac626e710a38dddab8673b1cc5f751a1df7366 100644 (file)
@@ -391,6 +391,7 @@ static const char *const enclosure_status [] = {
        [ENCLOSURE_STATUS_NOT_INSTALLED] = "not installed",
        [ENCLOSURE_STATUS_UNKNOWN] = "unknown",
        [ENCLOSURE_STATUS_UNAVAILABLE] = "unavailable",
+       [ENCLOSURE_STATUS_MAX] = NULL,
 };
 
 static const char *const enclosure_type [] = {
index 4bb7a3af9ad97bb1e5e8a2e02a03ebf54165e135..395a4ea64e9cd81623abc06be926d5f3e4eadd6b 100644 (file)
@@ -30,9 +30,6 @@
 /* Addresses to scan */
 static const unsigned short normal_i2c[] = { 0x69, I2C_CLIENT_END };
 
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(ics932s401);
-
 /* ICS932S401 registers */
 #define ICS932S401_REG_CFG2                    0x01
 #define        ICS932S401_CFG1_SPREAD          0x01
@@ -106,12 +103,12 @@ struct ics932s401_data {
 
 static int ics932s401_probe(struct i2c_client *client,
                         const struct i2c_device_id *id);
-static int ics932s401_detect(struct i2c_client *client, int kind,
+static int ics932s401_detect(struct i2c_client *client,
                          struct i2c_board_info *info);
 static int ics932s401_remove(struct i2c_client *client);
 
 static const struct i2c_device_id ics932s401_id[] = {
-       { "ics932s401", ics932s401 },
+       { "ics932s401", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, ics932s401_id);
@@ -125,7 +122,7 @@ static struct i2c_driver ics932s401_driver = {
        .remove         = ics932s401_remove,
        .id_table       = ics932s401_id,
        .detect         = ics932s401_detect,
-       .address_data   = &addr_data,
+       .address_list   = normal_i2c,
 };
 
 static struct ics932s401_data *ics932s401_update_device(struct device *dev)
@@ -413,7 +410,7 @@ static ssize_t show_spread(struct device *dev,
 }
 
 /* Return 0 if detection is successful, -ENODEV otherwise */
-static int ics932s401_detect(struct i2c_client *client, int kind,
+static int ics932s401_detect(struct i2c_client *client,
                          struct i2c_board_info *info)
 {
        struct i2c_adapter *adapter = client->adapter;
index 60b0b1a4fb3a8ff7817c14d59a490f2665f4e933..09dcb699e6674e4ba5d3301149be994fcf17c46d 100644 (file)
@@ -138,7 +138,7 @@ ioc4_unregister_submodule(struct ioc4_submodule *is)
  * even though the following code utilizes external interrupt registers
  * to perform the speed calculation.
  */
-static void
+static void __devinit
 ioc4_clock_calibrate(struct ioc4_driver_data *idd)
 {
        union ioc4_int_out int_out;
@@ -230,7 +230,7 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
  * on the same PCI bus at slot number 3 to differentiate IO9 from IO10.
  * If neither is present, it's a PCI-RT.
  */
-static unsigned int
+static unsigned int __devinit
 ioc4_variant(struct ioc4_driver_data *idd)
 {
        struct pci_dev *pdev = NULL;
@@ -269,7 +269,7 @@ ioc4_variant(struct ioc4_driver_data *idd)
        return IOC4_VARIANT_PCI_RT;
 }
 
-static void
+static void __devinit
 ioc4_load_modules(struct work_struct *work)
 {
        /* arg just has to be freed */
@@ -280,7 +280,7 @@ ioc4_load_modules(struct work_struct *work)
 }
 
 /* Adds a new instance of an IOC4 card */
-static int
+static int __devinit
 ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 {
        struct ioc4_driver_data *idd;
@@ -425,7 +425,7 @@ out:
 }
 
 /* Removes a particular instance of an IOC4 card. */
-static void
+static void __devexit
 ioc4_remove(struct pci_dev *pdev)
 {
        struct ioc4_submodule *is;
@@ -476,7 +476,7 @@ static struct pci_driver ioc4_driver = {
        .name = "IOC4",
        .id_table = ioc4_id_table,
        .probe = ioc4_probe,
-       .remove = ioc4_remove,
+       .remove = __devexit_p(ioc4_remove),
 };
 
 MODULE_DEVICE_TABLE(pci, ioc4_id_table);
@@ -486,14 +486,14 @@ MODULE_DEVICE_TABLE(pci, ioc4_id_table);
  *********************/
 
 /* Module load */
-static int __devinit
+static int __init
 ioc4_init(void)
 {
        return pci_register_driver(&ioc4_driver);
 }
 
 /* Module unload */
-static void __devexit
+static void __exit
 ioc4_exit(void)
 {
        /* Ensure ioc4_load_modules() has completed before exiting */
index f93f03a9e6e9e3c0cb1d034b7f746386df76bfe2..3ad76cd18b4bb41afec47c2e7b6b1ec6ad9268bc 100644 (file)
@@ -53,6 +53,17 @@ struct gru_chiplet_info {
        int     free_user_cbr;
 };
 
+/*
+ * Statictics kept for each context.
+ */
+struct gru_gseg_statistics {
+       unsigned long   fmm_tlbmiss;
+       unsigned long   upm_tlbmiss;
+       unsigned long   tlbdropin;
+       unsigned long   context_stolen;
+       unsigned long   reserved[10];
+};
+
 /* Flags for GRU options on the gru_create_context() call */
 /* Select one of the follow 4 options to specify how TLB misses are handled */
 #define GRU_OPT_MISS_DEFAULT   0x0000  /* Use default mode */
index 3c9c06618e6adaf0b3febba4cc74d9c45356bc5c..d95587cc794c81288f2211bf311f8823b9258321 100644 (file)
@@ -34,17 +34,17 @@ extern void gru_wait_abort_proc(void *cb);
 #include <asm/intrinsics.h>
 #define __flush_cache(p)               ia64_fc((unsigned long)p)
 /* Use volatile on IA64 to ensure ordering via st4.rel */
-#define gru_ordered_store_int(p, v)                                    \
+#define gru_ordered_store_ulong(p, v)                                  \
                do {                                                    \
                        barrier();                                      \
-                       *((volatile int *)(p)) = v; /* force st.rel */  \
+                       *((volatile unsigned long *)(p)) = v; /* force st.rel */        \
                } while (0)
 #elif defined(CONFIG_X86_64)
 #define __flush_cache(p)               clflush(p)
-#define gru_ordered_store_int(p, v)                                    \
+#define gru_ordered_store_ulong(p, v)                                  \
                do {                                                    \
                        barrier();                                      \
-                       *(int *)p = v;                                  \
+                       *(unsigned long *)p = v;                        \
                } while (0)
 #else
 #error "Unsupported architecture"
@@ -129,8 +129,13 @@ struct gru_instruction_bits {
  */
 struct gru_instruction {
     /* DW 0 */
-    unsigned int               op32;    /* icmd,xtype,iaa0,ima,opc */
-    unsigned int               tri0;
+    union {
+       unsigned long           op64;    /* icmd,xtype,iaa0,ima,opc,tri0 */
+       struct {
+               unsigned int    op32;
+               unsigned int    tri0;
+       };
+    };
     unsigned long              tri1_bufsize;           /* DW 1 */
     unsigned long              baddr0;                 /* DW 2 */
     unsigned long              nelem;                  /* DW 3 */
@@ -140,7 +145,7 @@ struct gru_instruction {
     unsigned long              avalue;                 /* DW 7 */
 };
 
-/* Some shifts and masks for the low 32 bits of a GRU command */
+/* Some shifts and masks for the low 64 bits of a GRU command */
 #define GRU_CB_ICMD_SHFT       0
 #define GRU_CB_ICMD_MASK       0x1
 #define GRU_CB_XTYPE_SHFT      8
@@ -155,6 +160,10 @@ struct gru_instruction {
 #define GRU_CB_OPC_MASK                0xff
 #define GRU_CB_EXOPC_SHFT      24
 #define GRU_CB_EXOPC_MASK      0xff
+#define GRU_IDEF2_SHFT         32
+#define GRU_IDEF2_MASK         0x3ffff
+#define GRU_ISTATUS_SHFT       56
+#define GRU_ISTATUS_MASK       0x3
 
 /* GRU instruction opcodes (opc field) */
 #define OP_NOP         0x00
@@ -256,6 +265,7 @@ struct gru_instruction {
 #define CBE_CAUSE_PROTOCOL_STATE_DATA_ERROR    (1 << 16)
 #define CBE_CAUSE_RA_RESPONSE_DATA_ERROR       (1 << 17)
 #define CBE_CAUSE_HA_RESPONSE_DATA_ERROR       (1 << 18)
+#define CBE_CAUSE_FORCED_ERROR                 (1 << 19)
 
 /* CBE cbrexecstatus bits */
 #define CBR_EXS_ABORT_OCC_BIT                  0
@@ -264,13 +274,15 @@ struct gru_instruction {
 #define CBR_EXS_QUEUED_BIT                     3
 #define CBR_EXS_TLB_INVAL_BIT                  4
 #define CBR_EXS_EXCEPTION_BIT                  5
+#define CBR_EXS_CB_INT_PENDING_BIT             6
 
 #define CBR_EXS_ABORT_OCC                      (1 << CBR_EXS_ABORT_OCC_BIT)
 #define CBR_EXS_INT_OCC                                (1 << CBR_EXS_INT_OCC_BIT)
 #define CBR_EXS_PENDING                                (1 << CBR_EXS_PENDING_BIT)
 #define CBR_EXS_QUEUED                         (1 << CBR_EXS_QUEUED_BIT)
-#define CBR_TLB_INVAL                          (1 << CBR_EXS_TLB_INVAL_BIT)
+#define CBR_EXS_TLB_INVAL                      (1 << CBR_EXS_TLB_INVAL_BIT)
 #define CBR_EXS_EXCEPTION                      (1 << CBR_EXS_EXCEPTION_BIT)
+#define CBR_EXS_CB_INT_PENDING                 (1 << CBR_EXS_CB_INT_PENDING_BIT)
 
 /*
  * Exceptions are retried for the following cases. If any OTHER bits are set
@@ -296,12 +308,14 @@ union gru_mesqhead {
 
 
 /* Generate the low word of a GRU instruction */
-static inline unsigned int
-__opword(unsigned char opcode, unsigned char exopc, unsigned char xtype,
+static inline unsigned long
+__opdword(unsigned char opcode, unsigned char exopc, unsigned char xtype,
        unsigned char iaa0, unsigned char iaa1,
-       unsigned char ima)
+       unsigned long idef2, unsigned char ima)
 {
     return (1 << GRU_CB_ICMD_SHFT) |
+          ((unsigned long)CBS_ACTIVE << GRU_ISTATUS_SHFT) |
+          (idef2<< GRU_IDEF2_SHFT) |
           (iaa0 << GRU_CB_IAA0_SHFT) |
           (iaa1 << GRU_CB_IAA1_SHFT) |
           (ima << GRU_CB_IMA_SHFT) |
@@ -319,12 +333,13 @@ static inline void gru_flush_cache(void *p)
 }
 
 /*
- * Store the lower 32 bits of the command including the "start" bit. Then
+ * Store the lower 64 bits of the command including the "start" bit. Then
  * start the instruction executing.
  */
-static inline void gru_start_instruction(struct gru_instruction *ins, int op32)
+static inline void gru_start_instruction(struct gru_instruction *ins, unsigned long op64)
 {
-       gru_ordered_store_int(ins, op32);
+       gru_ordered_store_ulong(ins, op64);
+       mb();
        gru_flush_cache(ins);
 }
 
@@ -340,6 +355,30 @@ static inline void gru_start_instruction(struct gru_instruction *ins, int op32)
  *             - nelem and stride are in elements
  *             - tri0/tri1 is in bytes for the beginning of the data segment.
  */
+static inline void gru_vload_phys(void *cb, unsigned long gpa,
+               unsigned int tri0, int iaa, unsigned long hints)
+{
+       struct gru_instruction *ins = (struct gru_instruction *)cb;
+
+       ins->baddr0 = (long)gpa | ((unsigned long)iaa << 62);
+       ins->nelem = 1;
+       ins->op1_stride = 1;
+       gru_start_instruction(ins, __opdword(OP_VLOAD, 0, XTYPE_DW, iaa, 0,
+                                       (unsigned long)tri0, CB_IMA(hints)));
+}
+
+static inline void gru_vstore_phys(void *cb, unsigned long gpa,
+               unsigned int tri0, int iaa, unsigned long hints)
+{
+       struct gru_instruction *ins = (struct gru_instruction *)cb;
+
+       ins->baddr0 = (long)gpa | ((unsigned long)iaa << 62);
+       ins->nelem = 1;
+       ins->op1_stride = 1;
+       gru_start_instruction(ins, __opdword(OP_VSTORE, 0, XTYPE_DW, iaa, 0,
+                                       (unsigned long)tri0, CB_IMA(hints)));
+}
+
 static inline void gru_vload(void *cb, unsigned long mem_addr,
                unsigned int tri0, unsigned char xtype, unsigned long nelem,
                unsigned long stride, unsigned long hints)
@@ -348,10 +387,9 @@ static inline void gru_vload(void *cb, unsigned long mem_addr,
 
        ins->baddr0 = (long)mem_addr;
        ins->nelem = nelem;
-       ins->tri0 = tri0;
        ins->op1_stride = stride;
-       gru_start_instruction(ins, __opword(OP_VLOAD, 0, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_VLOAD, 0, xtype, IAA_RAM, 0,
+                                       (unsigned long)tri0, CB_IMA(hints)));
 }
 
 static inline void gru_vstore(void *cb, unsigned long mem_addr,
@@ -362,10 +400,9 @@ static inline void gru_vstore(void *cb, unsigned long mem_addr,
 
        ins->baddr0 = (long)mem_addr;
        ins->nelem = nelem;
-       ins->tri0 = tri0;
        ins->op1_stride = stride;
-       gru_start_instruction(ins, __opword(OP_VSTORE, 0, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_VSTORE, 0, xtype, IAA_RAM, 0,
+                                       tri0, CB_IMA(hints)));
 }
 
 static inline void gru_ivload(void *cb, unsigned long mem_addr,
@@ -376,10 +413,9 @@ static inline void gru_ivload(void *cb, unsigned long mem_addr,
 
        ins->baddr0 = (long)mem_addr;
        ins->nelem = nelem;
-       ins->tri0 = tri0;
        ins->tri1_bufsize = tri1;
-       gru_start_instruction(ins, __opword(OP_IVLOAD, 0, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_IVLOAD, 0, xtype, IAA_RAM, 0,
+                                       tri0, CB_IMA(hints)));
 }
 
 static inline void gru_ivstore(void *cb, unsigned long mem_addr,
@@ -390,10 +426,9 @@ static inline void gru_ivstore(void *cb, unsigned long mem_addr,
 
        ins->baddr0 = (long)mem_addr;
        ins->nelem = nelem;
-       ins->tri0 = tri0;
        ins->tri1_bufsize = tri1;
-       gru_start_instruction(ins, __opword(OP_IVSTORE, 0, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_IVSTORE, 0, xtype, IAA_RAM, 0,
+                                       tri0, CB_IMA(hints)));
 }
 
 static inline void gru_vset(void *cb, unsigned long mem_addr,
@@ -406,8 +441,8 @@ static inline void gru_vset(void *cb, unsigned long mem_addr,
        ins->op2_value_baddr1 = value;
        ins->nelem = nelem;
        ins->op1_stride = stride;
-       gru_start_instruction(ins, __opword(OP_VSET, 0, xtype, IAA_RAM, 0,
-                                        CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_VSET, 0, xtype, IAA_RAM, 0,
+                                        0, CB_IMA(hints)));
 }
 
 static inline void gru_ivset(void *cb, unsigned long mem_addr,
@@ -420,8 +455,8 @@ static inline void gru_ivset(void *cb, unsigned long mem_addr,
        ins->op2_value_baddr1 = value;
        ins->nelem = nelem;
        ins->tri1_bufsize = tri1;
-       gru_start_instruction(ins, __opword(OP_IVSET, 0, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_IVSET, 0, xtype, IAA_RAM, 0,
+                                       0, CB_IMA(hints)));
 }
 
 static inline void gru_vflush(void *cb, unsigned long mem_addr,
@@ -433,15 +468,15 @@ static inline void gru_vflush(void *cb, unsigned long mem_addr,
        ins->baddr0 = (long)mem_addr;
        ins->op1_stride = stride;
        ins->nelem = nelem;
-       gru_start_instruction(ins, __opword(OP_VFLUSH, 0, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_VFLUSH, 0, xtype, IAA_RAM, 0,
+                                       0, CB_IMA(hints)));
 }
 
 static inline void gru_nop(void *cb, int hints)
 {
        struct gru_instruction *ins = (void *)cb;
 
-       gru_start_instruction(ins, __opword(OP_NOP, 0, 0, 0, 0, CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_NOP, 0, 0, 0, 0, 0, CB_IMA(hints)));
 }
 
 
@@ -455,10 +490,9 @@ static inline void gru_bcopy(void *cb, const unsigned long src,
        ins->baddr0 = (long)src;
        ins->op2_value_baddr1 = (long)dest;
        ins->nelem = nelem;
-       ins->tri0 = tri0;
        ins->tri1_bufsize = bufsize;
-       gru_start_instruction(ins, __opword(OP_BCOPY, 0, xtype, IAA_RAM,
-                                       IAA_RAM, CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_BCOPY, 0, xtype, IAA_RAM,
+                                       IAA_RAM, tri0, CB_IMA(hints)));
 }
 
 static inline void gru_bstore(void *cb, const unsigned long src,
@@ -470,9 +504,8 @@ static inline void gru_bstore(void *cb, const unsigned long src,
        ins->baddr0 = (long)src;
        ins->op2_value_baddr1 = (long)dest;
        ins->nelem = nelem;
-       ins->tri0 = tri0;
-       gru_start_instruction(ins, __opword(OP_BSTORE, 0, xtype, 0, IAA_RAM,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_BSTORE, 0, xtype, 0, IAA_RAM,
+                                       tri0, CB_IMA(hints)));
 }
 
 static inline void gru_gamir(void *cb, int exopc, unsigned long src,
@@ -481,8 +514,8 @@ static inline void gru_gamir(void *cb, int exopc, unsigned long src,
        struct gru_instruction *ins = (void *)cb;
 
        ins->baddr0 = (long)src;
-       gru_start_instruction(ins, __opword(OP_GAMIR, exopc, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_GAMIR, exopc, xtype, IAA_RAM, 0,
+                                       0, CB_IMA(hints)));
 }
 
 static inline void gru_gamirr(void *cb, int exopc, unsigned long src,
@@ -491,8 +524,8 @@ static inline void gru_gamirr(void *cb, int exopc, unsigned long src,
        struct gru_instruction *ins = (void *)cb;
 
        ins->baddr0 = (long)src;
-       gru_start_instruction(ins, __opword(OP_GAMIRR, exopc, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_GAMIRR, exopc, xtype, IAA_RAM, 0,
+                                       0, CB_IMA(hints)));
 }
 
 static inline void gru_gamer(void *cb, int exopc, unsigned long src,
@@ -505,8 +538,8 @@ static inline void gru_gamer(void *cb, int exopc, unsigned long src,
        ins->baddr0 = (long)src;
        ins->op1_stride = operand1;
        ins->op2_value_baddr1 = operand2;
-       gru_start_instruction(ins, __opword(OP_GAMER, exopc, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_GAMER, exopc, xtype, IAA_RAM, 0,
+                                       0, CB_IMA(hints)));
 }
 
 static inline void gru_gamerr(void *cb, int exopc, unsigned long src,
@@ -518,8 +551,8 @@ static inline void gru_gamerr(void *cb, int exopc, unsigned long src,
        ins->baddr0 = (long)src;
        ins->op1_stride = operand1;
        ins->op2_value_baddr1 = operand2;
-       gru_start_instruction(ins, __opword(OP_GAMERR, exopc, xtype, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_GAMERR, exopc, xtype, IAA_RAM, 0,
+                                       0, CB_IMA(hints)));
 }
 
 static inline void gru_gamxr(void *cb, unsigned long src,
@@ -529,8 +562,8 @@ static inline void gru_gamxr(void *cb, unsigned long src,
 
        ins->baddr0 = (long)src;
        ins->nelem = 4;
-       gru_start_instruction(ins, __opword(OP_GAMXR, EOP_XR_CSWAP, XTYPE_DW,
-                                IAA_RAM, 0, CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_GAMXR, EOP_XR_CSWAP, XTYPE_DW,
+                                IAA_RAM, 0, 0, CB_IMA(hints)));
 }
 
 static inline void gru_mesq(void *cb, unsigned long queue,
@@ -541,9 +574,8 @@ static inline void gru_mesq(void *cb, unsigned long queue,
 
        ins->baddr0 = (long)queue;
        ins->nelem = nelem;
-       ins->tri0 = tri0;
-       gru_start_instruction(ins, __opword(OP_MESQ, 0, XTYPE_CL, IAA_RAM, 0,
-                                       CB_IMA(hints)));
+       gru_start_instruction(ins, __opdword(OP_MESQ, 0, XTYPE_CL, IAA_RAM, 0,
+                                       tri0, CB_IMA(hints)));
 }
 
 static inline unsigned long gru_get_amo_value(void *cb)
@@ -662,6 +694,14 @@ static inline void gru_wait_abort(void *cb)
        gru_wait_abort_proc(cb);
 }
 
+/*
+ * Get a pointer to the start of a gseg
+ *     p       - Any valid pointer within the gseg
+ */
+static inline void *gru_get_gseg_pointer (void *p)
+{
+       return (void *)((unsigned long)p & ~(GRU_GSEG_PAGESIZE - 1));
+}
 
 /*
  * Get a pointer to a control block
index 679e01778286029bf21299db49e6284ee001475f..38657cdaf54d32b247c89e105611f0b96a267c75 100644 (file)
 #include "gru_instructions.h"
 #include <asm/uv/uv_hub.h>
 
+/* Return codes for vtop functions */
+#define VTOP_SUCCESS               0
+#define VTOP_INVALID               -1
+#define VTOP_RETRY                 -2
+
+
 /*
  * Test if a physical address is a valid GRU GSEG address
  */
@@ -90,19 +96,22 @@ static struct gru_thread_state *gru_alloc_locked_gts(unsigned long vaddr)
 {
        struct mm_struct *mm = current->mm;
        struct vm_area_struct *vma;
-       struct gru_thread_state *gts = NULL;
+       struct gru_thread_state *gts = ERR_PTR(-EINVAL);
 
        down_write(&mm->mmap_sem);
        vma = gru_find_vma(vaddr);
-       if (vma)
-               gts = gru_alloc_thread_state(vma, TSID(vaddr, vma));
-       if (gts) {
-               mutex_lock(&gts->ts_ctxlock);
-               downgrade_write(&mm->mmap_sem);
-       } else {
-               up_write(&mm->mmap_sem);
-       }
+       if (!vma)
+               goto err;
 
+       gts = gru_alloc_thread_state(vma, TSID(vaddr, vma));
+       if (IS_ERR(gts))
+               goto err;
+       mutex_lock(&gts->ts_ctxlock);
+       downgrade_write(&mm->mmap_sem);
+       return gts;
+
+err:
+       up_write(&mm->mmap_sem);
        return gts;
 }
 
@@ -122,38 +131,14 @@ static void gru_unlock_gts(struct gru_thread_state *gts)
  * is necessary to prevent the user from seeing a stale cb.istatus that will
  * change as soon as the TFH restart is complete. Races may cause an
  * occasional failure to clear the cb.istatus, but that is ok.
- *
- * If the cb address is not valid (should not happen, but...), nothing
- * bad will happen.. The get_user()/put_user() will fail but there
- * are no bad side-effects.
  */
-static void gru_cb_set_istatus_active(unsigned long __user *cb)
+static void gru_cb_set_istatus_active(struct gru_instruction_bits *cbk)
 {
-       union {
-               struct gru_instruction_bits bits;
-               unsigned long dw;
-       } u;
-
-       if (cb) {
-               get_user(u.dw, cb);
-               u.bits.istatus = CBS_ACTIVE;
-               put_user(u.dw, cb);
+       if (cbk) {
+               cbk->istatus = CBS_ACTIVE;
        }
 }
 
-/*
- * Convert a interrupt IRQ to a pointer to the GRU GTS that caused the
- * interrupt. Interrupts are always sent to a cpu on the blade that contains the
- * GRU (except for headless blades which are not currently supported). A blade
- * has N grus; a block of N consecutive IRQs is assigned to the GRUs. The IRQ
- * number uniquely identifies the GRU chiplet on the local blade that caused the
- * interrupt. Always called in interrupt context.
- */
-static inline struct gru_state *irq_to_gru(int irq)
-{
-       return &gru_base[uv_numa_blade_id()]->bs_grus[irq - IRQ_GRU];
-}
-
 /*
  * Read & clear a TFM
  *
@@ -207,10 +192,11 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
 {
        struct page *page;
 
-       /* ZZZ Need to handle HUGE pages */
-       if (is_vm_hugetlb_page(vma))
-               return -EFAULT;
+#ifdef CONFIG_HUGETLB_PAGE
+       *pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
+#else
        *pageshift = PAGE_SHIFT;
+#endif
        if (get_user_pages
            (current, current->mm, vaddr, 1, write, 0, &page, NULL) <= 0)
                return -EFAULT;
@@ -268,7 +254,6 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
        return 0;
 
 err:
-       local_irq_enable();
        return 1;
 }
 
@@ -301,14 +286,69 @@ static int gru_vtop(struct gru_thread_state *gts, unsigned long vaddr,
        paddr = paddr & ~((1UL << ps) - 1);
        *gpa = uv_soc_phys_ram_to_gpa(paddr);
        *pageshift = ps;
-       return 0;
+       return VTOP_SUCCESS;
 
 inval:
-       return -1;
+       return VTOP_INVALID;
 upm:
-       return -2;
+       return VTOP_RETRY;
+}
+
+
+/*
+ * Flush a CBE from cache. The CBE is clean in the cache. Dirty the
+ * CBE cacheline so that the line will be written back to home agent.
+ * Otherwise the line may be silently dropped. This has no impact
+ * except on performance.
+ */
+static void gru_flush_cache_cbe(struct gru_control_block_extended *cbe)
+{
+       if (unlikely(cbe)) {
+               cbe->cbrexecstatus = 0;         /* make CL dirty */
+               gru_flush_cache(cbe);
+       }
 }
 
+/*
+ * Preload the TLB with entries that may be required. Currently, preloading
+ * is implemented only for BCOPY. Preload  <tlb_preload_count> pages OR to
+ * the end of the bcopy tranfer, whichever is smaller.
+ */
+static void gru_preload_tlb(struct gru_state *gru,
+                       struct gru_thread_state *gts, int atomic,
+                       unsigned long fault_vaddr, int asid, int write,
+                       unsigned char tlb_preload_count,
+                       struct gru_tlb_fault_handle *tfh,
+                       struct gru_control_block_extended *cbe)
+{
+       unsigned long vaddr = 0, gpa;
+       int ret, pageshift;
+
+       if (cbe->opccpy != OP_BCOPY)
+               return;
+
+       if (fault_vaddr == cbe->cbe_baddr0)
+               vaddr = fault_vaddr + GRU_CACHE_LINE_BYTES * cbe->cbe_src_cl - 1;
+       else if (fault_vaddr == cbe->cbe_baddr1)
+               vaddr = fault_vaddr + (1 << cbe->xtypecpy) * cbe->cbe_nelemcur - 1;
+
+       fault_vaddr &= PAGE_MASK;
+       vaddr &= PAGE_MASK;
+       vaddr = min(vaddr, fault_vaddr + tlb_preload_count * PAGE_SIZE);
+
+       while (vaddr > fault_vaddr) {
+               ret = gru_vtop(gts, vaddr, write, atomic, &gpa, &pageshift);
+               if (ret || tfh_write_only(tfh, gpa, GAA_RAM, vaddr, asid, write,
+                                         GRU_PAGESIZE(pageshift)))
+                       return;
+               gru_dbg(grudev,
+                       "%s: gid %d, gts 0x%p, tfh 0x%p, vaddr 0x%lx, asid 0x%x, rw %d, ps %d, gpa 0x%lx\n",
+                       atomic ? "atomic" : "non-atomic", gru->gs_gid, gts, tfh,
+                       vaddr, asid, write, pageshift, gpa);
+               vaddr -= PAGE_SIZE;
+               STAT(tlb_preload_page);
+       }
+}
 
 /*
  * Drop a TLB entry into the GRU. The fault is described by info in an TFH.
@@ -320,11 +360,14 @@ upm:
  *             < 0 = error code
  *
  */
-static int gru_try_dropin(struct gru_thread_state *gts,
+static int gru_try_dropin(struct gru_state *gru,
+                         struct gru_thread_state *gts,
                          struct gru_tlb_fault_handle *tfh,
-                         unsigned long __user *cb)
+                         struct gru_instruction_bits *cbk)
 {
-       int pageshift = 0, asid, write, ret, atomic = !cb;
+       struct gru_control_block_extended *cbe = NULL;
+       unsigned char tlb_preload_count = gts->ts_tlb_preload_count;
+       int pageshift = 0, asid, write, ret, atomic = !cbk, indexway;
        unsigned long gpa = 0, vaddr = 0;
 
        /*
@@ -334,6 +377,14 @@ static int gru_try_dropin(struct gru_thread_state *gts,
         * the dropin is ignored. This eliminates the need for additional locks.
         */
 
+       /*
+        * Prefetch the CBE if doing TLB preloading
+        */
+       if (unlikely(tlb_preload_count)) {
+               cbe = gru_tfh_to_cbe(tfh);
+               prefetchw(cbe);
+       }
+
        /*
         * Error if TFH state is IDLE or FMM mode & the user issuing a UPM call.
         * Might be a hardware race OR a stupid user. Ignore FMM because FMM
@@ -341,18 +392,20 @@ static int gru_try_dropin(struct gru_thread_state *gts,
         */
        if (tfh->status != TFHSTATUS_EXCEPTION) {
                gru_flush_cache(tfh);
+               sync_core();
                if (tfh->status != TFHSTATUS_EXCEPTION)
                        goto failnoexception;
                STAT(tfh_stale_on_fault);
        }
        if (tfh->state == TFHSTATE_IDLE)
                goto failidle;
-       if (tfh->state == TFHSTATE_MISS_FMM && cb)
+       if (tfh->state == TFHSTATE_MISS_FMM && cbk)
                goto failfmm;
 
        write = (tfh->cause & TFHCAUSE_TLB_MOD) != 0;
        vaddr = tfh->missvaddr;
        asid = tfh->missasid;
+       indexway = tfh->indexway;
        if (asid == 0)
                goto failnoasid;
 
@@ -366,41 +419,51 @@ static int gru_try_dropin(struct gru_thread_state *gts,
                goto failactive;
 
        ret = gru_vtop(gts, vaddr, write, atomic, &gpa, &pageshift);
-       if (ret == -1)
+       if (ret == VTOP_INVALID)
                goto failinval;
-       if (ret == -2)
+       if (ret == VTOP_RETRY)
                goto failupm;
 
        if (!(gts->ts_sizeavail & GRU_SIZEAVAIL(pageshift))) {
                gts->ts_sizeavail |= GRU_SIZEAVAIL(pageshift);
-               if (atomic || !gru_update_cch(gts, 0)) {
+               if (atomic || !gru_update_cch(gts)) {
                        gts->ts_force_cch_reload = 1;
                        goto failupm;
                }
        }
-       gru_cb_set_istatus_active(cb);
+
+       if (unlikely(cbe) && pageshift == PAGE_SHIFT) {
+               gru_preload_tlb(gru, gts, atomic, vaddr, asid, write, tlb_preload_count, tfh, cbe);
+               gru_flush_cache_cbe(cbe);
+       }
+
+       gru_cb_set_istatus_active(cbk);
+       gts->ustats.tlbdropin++;
        tfh_write_restart(tfh, gpa, GAA_RAM, vaddr, asid, write,
                          GRU_PAGESIZE(pageshift));
-       STAT(tlb_dropin);
        gru_dbg(grudev,
-               "%s: tfh 0x%p, vaddr 0x%lx, asid 0x%x, ps %d, gpa 0x%lx\n",
-               ret ? "non-atomic" : "atomic", tfh, vaddr, asid,
-               pageshift, gpa);
+               "%s: gid %d, gts 0x%p, tfh 0x%p, vaddr 0x%lx, asid 0x%x, indexway 0x%x,"
+               " rw %d, ps %d, gpa 0x%lx\n",
+               atomic ? "atomic" : "non-atomic", gru->gs_gid, gts, tfh, vaddr, asid,
+               indexway, write, pageshift, gpa);
+       STAT(tlb_dropin);
        return 0;
 
 failnoasid:
        /* No asid (delayed unload). */
        STAT(tlb_dropin_fail_no_asid);
        gru_dbg(grudev, "FAILED no_asid tfh: 0x%p, vaddr 0x%lx\n", tfh, vaddr);
-       if (!cb)
+       if (!cbk)
                tfh_user_polling_mode(tfh);
        else
                gru_flush_cache(tfh);
+       gru_flush_cache_cbe(cbe);
        return -EAGAIN;
 
 failupm:
        /* Atomic failure switch CBR to UPM */
        tfh_user_polling_mode(tfh);
+       gru_flush_cache_cbe(cbe);
        STAT(tlb_dropin_fail_upm);
        gru_dbg(grudev, "FAILED upm tfh: 0x%p, vaddr 0x%lx\n", tfh, vaddr);
        return 1;
@@ -408,6 +471,7 @@ failupm:
 failfmm:
        /* FMM state on UPM call */
        gru_flush_cache(tfh);
+       gru_flush_cache_cbe(cbe);
        STAT(tlb_dropin_fail_fmm);
        gru_dbg(grudev, "FAILED fmm tfh: 0x%p, state %d\n", tfh, tfh->state);
        return 0;
@@ -415,17 +479,20 @@ failfmm:
 failnoexception:
        /* TFH status did not show exception pending */
        gru_flush_cache(tfh);
-       if (cb)
-               gru_flush_cache(cb);
+       gru_flush_cache_cbe(cbe);
+       if (cbk)
+               gru_flush_cache(cbk);
        STAT(tlb_dropin_fail_no_exception);
-       gru_dbg(grudev, "FAILED non-exception tfh: 0x%p, status %d, state %d\n", tfh, tfh->status, tfh->state);
+       gru_dbg(grudev, "FAILED non-exception tfh: 0x%p, status %d, state %d\n",
+               tfh, tfh->status, tfh->state);
        return 0;
 
 failidle:
        /* TFH state was idle  - no miss pending */
        gru_flush_cache(tfh);
-       if (cb)
-               gru_flush_cache(cb);
+       gru_flush_cache_cbe(cbe);
+       if (cbk)
+               gru_flush_cache(cbk);
        STAT(tlb_dropin_fail_idle);
        gru_dbg(grudev, "FAILED idle tfh: 0x%p, state %d\n", tfh, tfh->state);
        return 0;
@@ -433,16 +500,18 @@ failidle:
 failinval:
        /* All errors (atomic & non-atomic) switch CBR to EXCEPTION state */
        tfh_exception(tfh);
+       gru_flush_cache_cbe(cbe);
        STAT(tlb_dropin_fail_invalid);
        gru_dbg(grudev, "FAILED inval tfh: 0x%p, vaddr 0x%lx\n", tfh, vaddr);
        return -EFAULT;
 
 failactive:
        /* Range invalidate active. Switch to UPM iff atomic */
-       if (!cb)
+       if (!cbk)
                tfh_user_polling_mode(tfh);
        else
                gru_flush_cache(tfh);
+       gru_flush_cache_cbe(cbe);
        STAT(tlb_dropin_fail_range_active);
        gru_dbg(grudev, "FAILED range active: tfh 0x%p, vaddr 0x%lx\n",
                tfh, vaddr);
@@ -455,31 +524,41 @@ failactive:
  * Note that this is the interrupt handler that is registered with linux
  * interrupt handlers.
  */
-irqreturn_t gru_intr(int irq, void *dev_id)
+static irqreturn_t gru_intr(int chiplet, int blade)
 {
        struct gru_state *gru;
        struct gru_tlb_fault_map imap, dmap;
        struct gru_thread_state *gts;
        struct gru_tlb_fault_handle *tfh = NULL;
+       struct completion *cmp;
        int cbrnum, ctxnum;
 
        STAT(intr);
 
-       gru = irq_to_gru(irq);
+       gru = &gru_base[blade]->bs_grus[chiplet];
        if (!gru) {
-               dev_err(grudev, "GRU: invalid interrupt: cpu %d, irq %d\n",
-                       raw_smp_processor_id(), irq);
+               dev_err(grudev, "GRU: invalid interrupt: cpu %d, chiplet %d\n",
+                       raw_smp_processor_id(), chiplet);
                return IRQ_NONE;
        }
        get_clear_fault_map(gru, &imap, &dmap);
+       gru_dbg(grudev,
+               "cpu %d, chiplet %d, gid %d, imap %016lx %016lx, dmap %016lx %016lx\n",
+               smp_processor_id(), chiplet, gru->gs_gid,
+               imap.fault_bits[0], imap.fault_bits[1],
+               dmap.fault_bits[0], dmap.fault_bits[1]);
 
        for_each_cbr_in_tfm(cbrnum, dmap.fault_bits) {
-               complete(gru->gs_blade->bs_async_wq);
+               STAT(intr_cbr);
+               cmp = gru->gs_blade->bs_async_wq;
+               if (cmp)
+                       complete(cmp);
                gru_dbg(grudev, "gid %d, cbr_done %d, done %d\n",
-                       gru->gs_gid, cbrnum, gru->gs_blade->bs_async_wq->done);
+                       gru->gs_gid, cbrnum, cmp ? cmp->done : -1);
        }
 
        for_each_cbr_in_tfm(cbrnum, imap.fault_bits) {
+               STAT(intr_tfh);
                tfh = get_tfh_by_index(gru, cbrnum);
                prefetchw(tfh); /* Helps on hdw, required for emulator */
 
@@ -492,14 +571,20 @@ irqreturn_t gru_intr(int irq, void *dev_id)
                ctxnum = tfh->ctxnum;
                gts = gru->gs_gts[ctxnum];
 
+               /* Spurious interrupts can cause this. Ignore. */
+               if (!gts) {
+                       STAT(intr_spurious);
+                       continue;
+               }
+
                /*
                 * This is running in interrupt context. Trylock the mmap_sem.
                 * If it fails, retry the fault in user context.
                 */
+               gts->ustats.fmm_tlbmiss++;
                if (!gts->ts_force_cch_reload &&
                                        down_read_trylock(&gts->ts_mm->mmap_sem)) {
-                       gts->ustats.fmm_tlbdropin++;
-                       gru_try_dropin(gts, tfh, NULL);
+                       gru_try_dropin(gru, gts, tfh, NULL);
                        up_read(&gts->ts_mm->mmap_sem);
                } else {
                        tfh_user_polling_mode(tfh);
@@ -509,20 +594,43 @@ irqreturn_t gru_intr(int irq, void *dev_id)
        return IRQ_HANDLED;
 }
 
+irqreturn_t gru0_intr(int irq, void *dev_id)
+{
+       return gru_intr(0, uv_numa_blade_id());
+}
+
+irqreturn_t gru1_intr(int irq, void *dev_id)
+{
+       return gru_intr(1, uv_numa_blade_id());
+}
+
+irqreturn_t gru_intr_mblade(int irq, void *dev_id)
+{
+       int blade;
+
+       for_each_possible_blade(blade) {
+               if (uv_blade_nr_possible_cpus(blade))
+                       continue;
+                gru_intr(0, blade);
+                gru_intr(1, blade);
+       }
+       return IRQ_HANDLED;
+}
+
 
 static int gru_user_dropin(struct gru_thread_state *gts,
                           struct gru_tlb_fault_handle *tfh,
-                          unsigned long __user *cb)
+                          void *cb)
 {
        struct gru_mm_struct *gms = gts->ts_gms;
        int ret;
 
-       gts->ustats.upm_tlbdropin++;
+       gts->ustats.upm_tlbmiss++;
        while (1) {
                wait_event(gms->ms_wait_queue,
                           atomic_read(&gms->ms_range_active) == 0);
                prefetchw(tfh); /* Helps on hdw, required for emulator */
-               ret = gru_try_dropin(gts, tfh, cb);
+               ret = gru_try_dropin(gts->ts_gru, gts, tfh, cb);
                if (ret <= 0)
                        return ret;
                STAT(call_os_wait_queue);
@@ -538,52 +646,41 @@ int gru_handle_user_call_os(unsigned long cb)
 {
        struct gru_tlb_fault_handle *tfh;
        struct gru_thread_state *gts;
-       unsigned long __user *cbp;
+       void *cbk;
        int ucbnum, cbrnum, ret = -EINVAL;
 
        STAT(call_os);
-       gru_dbg(grudev, "address 0x%lx\n", cb);
 
        /* sanity check the cb pointer */
        ucbnum = get_cb_number((void *)cb);
        if ((cb & (GRU_HANDLE_STRIDE - 1)) || ucbnum >= GRU_NUM_CB)
                return -EINVAL;
-       cbp = (unsigned long *)cb;
 
        gts = gru_find_lock_gts(cb);
        if (!gts)
                return -EINVAL;
+       gru_dbg(grudev, "address 0x%lx, gid %d, gts 0x%p\n", cb, gts->ts_gru ? gts->ts_gru->gs_gid : -1, gts);
 
        if (ucbnum >= gts->ts_cbr_au_count * GRU_CBR_AU_SIZE)
                goto exit;
 
-       /*
-        * If force_unload is set, the UPM TLB fault is phony. The task
-        * has migrated to another node and the GSEG must be moved. Just
-        * unload the context. The task will page fault and assign a new
-        * context.
-        */
-       if (gts->ts_tgid_owner == current->tgid && gts->ts_blade >= 0 &&
-                               gts->ts_blade != uv_numa_blade_id()) {
-               STAT(call_os_offnode_reference);
-               gts->ts_force_unload = 1;
-       }
+       gru_check_context_placement(gts);
 
        /*
         * CCH may contain stale data if ts_force_cch_reload is set.
         */
        if (gts->ts_gru && gts->ts_force_cch_reload) {
                gts->ts_force_cch_reload = 0;
-               gru_update_cch(gts, 0);
+               gru_update_cch(gts);
        }
 
        ret = -EAGAIN;
        cbrnum = thread_cbr_number(gts, ucbnum);
-       if (gts->ts_force_unload) {
-               gru_unload_context(gts, 1);
-       } else if (gts->ts_gru) {
+       if (gts->ts_gru) {
                tfh = get_tfh_by_index(gts->ts_gru, cbrnum);
-               ret = gru_user_dropin(gts, tfh, cbp);
+               cbk = get_gseg_base_address_cb(gts->ts_gru->gs_gru_base_vaddr,
+                               gts->ts_ctxnum, ucbnum);
+               ret = gru_user_dropin(gts, tfh, cbk);
        }
 exit:
        gru_unlock_gts(gts);
@@ -605,11 +702,11 @@ int gru_get_exception_detail(unsigned long arg)
        if (copy_from_user(&excdet, (void __user *)arg, sizeof(excdet)))
                return -EFAULT;
 
-       gru_dbg(grudev, "address 0x%lx\n", excdet.cb);
        gts = gru_find_lock_gts(excdet.cb);
        if (!gts)
                return -EINVAL;
 
+       gru_dbg(grudev, "address 0x%lx, gid %d, gts 0x%p\n", excdet.cb, gts->ts_gru ? gts->ts_gru->gs_gid : -1, gts);
        ucbnum = get_cb_number((void *)excdet.cb);
        if (ucbnum >= gts->ts_cbr_au_count * GRU_CBR_AU_SIZE) {
                ret = -EINVAL;
@@ -617,6 +714,7 @@ int gru_get_exception_detail(unsigned long arg)
                cbrnum = thread_cbr_number(gts, ucbnum);
                cbe = get_cbe_by_index(gts->ts_gru, cbrnum);
                gru_flush_cache(cbe);   /* CBE not coherent */
+               sync_core();            /* make sure we are have current data */
                excdet.opc = cbe->opccpy;
                excdet.exopc = cbe->exopccpy;
                excdet.ecause = cbe->ecause;
@@ -624,7 +722,7 @@ int gru_get_exception_detail(unsigned long arg)
                excdet.exceptdet1 = cbe->idef3upd;
                excdet.cbrstate = cbe->cbrstate;
                excdet.cbrexecstatus = cbe->cbrexecstatus;
-               gru_flush_cache(cbe);
+               gru_flush_cache_cbe(cbe);
                ret = 0;
        } else {
                ret = -EAGAIN;
@@ -733,6 +831,11 @@ long gru_get_gseg_statistics(unsigned long arg)
        if (copy_from_user(&req, (void __user *)arg, sizeof(req)))
                return -EFAULT;
 
+       /*
+        * The library creates arrays of contexts for threaded programs.
+        * If no gts exists in the array, the context has never been used & all
+        * statistics are implicitly 0.
+        */
        gts = gru_find_lock_gts(req.gseg);
        if (gts) {
                memcpy(&req.stats, &gts->ustats, sizeof(gts->ustats));
@@ -762,11 +865,25 @@ int gru_set_context_option(unsigned long arg)
                return -EFAULT;
        gru_dbg(grudev, "op %d, gseg 0x%lx, value1 0x%lx\n", req.op, req.gseg, req.val1);
 
-       gts = gru_alloc_locked_gts(req.gseg);
-       if (!gts)
-               return -EINVAL;
+       gts = gru_find_lock_gts(req.gseg);
+       if (!gts) {
+               gts = gru_alloc_locked_gts(req.gseg);
+               if (IS_ERR(gts))
+                       return PTR_ERR(gts);
+       }
 
        switch (req.op) {
+       case sco_blade_chiplet:
+               /* Select blade/chiplet for GRU context */
+               if (req.val1 < -1 || req.val1 >= GRU_MAX_BLADES || !gru_base[req.val1] ||
+                   req.val0 < -1 || req.val0 >= GRU_CHIPLETS_PER_HUB) {
+                       ret = -EINVAL;
+               } else {
+                       gts->ts_user_blade_id = req.val1;
+                       gts->ts_user_chiplet_id = req.val0;
+                       gru_check_context_placement(gts);
+               }
+               break;
        case sco_gseg_owner:
                /* Register the current task as the GSEG owner */
                gts->ts_tgid_owner = current->tgid;
index ce5eda985ab0ebbed365a9a65dd56fe1ce7949bc..cb3b4d228475905fbdc25bc00605188e2afc53c4 100644 (file)
@@ -35,6 +35,9 @@
 #include <linux/interrupt.h>
 #include <linux/proc_fs.h>
 #include <linux/uaccess.h>
+#ifdef CONFIG_X86_64
+#include <asm/uv/uv_irq.h>
+#endif
 #include <asm/uv/uv.h>
 #include "gru.h"
 #include "grulib.h"
@@ -130,7 +133,6 @@ static int gru_create_new_context(unsigned long arg)
        struct gru_vma_data *vdata;
        int ret = -EINVAL;
 
-
        if (copy_from_user(&req, (void __user *)arg, sizeof(req)))
                return -EFAULT;
 
@@ -150,6 +152,7 @@ static int gru_create_new_context(unsigned long arg)
                vdata->vd_dsr_au_count =
                    GRU_DS_BYTES_TO_AU(req.data_segment_bytes);
                vdata->vd_cbr_au_count = GRU_CB_COUNT_TO_AU(req.control_blocks);
+               vdata->vd_tlb_preload_count = req.tlb_preload_count;
                ret = 0;
        }
        up_write(&current->mm->mmap_sem);
@@ -190,7 +193,7 @@ static long gru_file_unlocked_ioctl(struct file *file, unsigned int req,
 {
        int err = -EBADRQC;
 
-       gru_dbg(grudev, "file %p\n", file);
+       gru_dbg(grudev, "file %p, req 0x%x, 0x%lx\n", file, req, arg);
 
        switch (req) {
        case GRU_CREATE_CONTEXT:
@@ -232,23 +235,24 @@ static long gru_file_unlocked_ioctl(struct file *file, unsigned int req,
  * system.
  */
 static void gru_init_chiplet(struct gru_state *gru, unsigned long paddr,
-                            void *vaddr, int nid, int bid, int grunum)
+                            void *vaddr, int blade_id, int chiplet_id)
 {
        spin_lock_init(&gru->gs_lock);
        spin_lock_init(&gru->gs_asid_lock);
        gru->gs_gru_base_paddr = paddr;
        gru->gs_gru_base_vaddr = vaddr;
-       gru->gs_gid = bid * GRU_CHIPLETS_PER_BLADE + grunum;
-       gru->gs_blade = gru_base[bid];
-       gru->gs_blade_id = bid;
+       gru->gs_gid = blade_id * GRU_CHIPLETS_PER_BLADE + chiplet_id;
+       gru->gs_blade = gru_base[blade_id];
+       gru->gs_blade_id = blade_id;
+       gru->gs_chiplet_id = chiplet_id;
        gru->gs_cbr_map = (GRU_CBR_AU == 64) ? ~0 : (1UL << GRU_CBR_AU) - 1;
        gru->gs_dsr_map = (1UL << GRU_DSR_AU) - 1;
        gru->gs_asid_limit = MAX_ASID;
        gru_tgh_flush_init(gru);
        if (gru->gs_gid >= gru_max_gids)
                gru_max_gids = gru->gs_gid + 1;
-       gru_dbg(grudev, "bid %d, nid %d, gid %d, vaddr %p (0x%lx)\n",
-               bid, nid, gru->gs_gid, gru->gs_gru_base_vaddr,
+       gru_dbg(grudev, "bid %d, gid %d, vaddr %p (0x%lx)\n",
+               blade_id, gru->gs_gid, gru->gs_gru_base_vaddr,
                gru->gs_gru_base_paddr);
 }
 
@@ -264,12 +268,10 @@ static int gru_init_tables(unsigned long gru_base_paddr, void *gru_base_vaddr)
 
        max_user_cbrs = GRU_NUM_CB;
        max_user_dsr_bytes = GRU_NUM_DSR_BYTES;
-       for_each_online_node(nid) {
-               bid = uv_node_to_blade_id(nid);
-               pnode = uv_node_to_pnode(nid);
-               if (bid < 0 || gru_base[bid])
-                       continue;
-               page = alloc_pages_exact_node(nid, GFP_KERNEL, order);
+       for_each_possible_blade(bid) {
+               pnode = uv_blade_to_pnode(bid);
+               nid = uv_blade_to_memory_nid(bid);/* -1 if no memory on blade */
+               page = alloc_pages_node(nid, GFP_KERNEL, order);
                if (!page)
                        goto fail;
                gru_base[bid] = page_address(page);
@@ -285,7 +287,7 @@ static int gru_init_tables(unsigned long gru_base_paddr, void *gru_base_vaddr)
                                chip++, gru++) {
                        paddr = gru_chiplet_paddr(gru_base_paddr, pnode, chip);
                        vaddr = gru_chiplet_vaddr(gru_base_vaddr, pnode, chip);
-                       gru_init_chiplet(gru, paddr, vaddr, nid, bid, chip);
+                       gru_init_chiplet(gru, paddr, vaddr, bid, chip);
                        n = hweight64(gru->gs_cbr_map) * GRU_CBR_AU_SIZE;
                        cbrs = max(cbrs, n);
                        n = hweight64(gru->gs_dsr_map) * GRU_DSR_AU_BYTES;
@@ -298,39 +300,215 @@ static int gru_init_tables(unsigned long gru_base_paddr, void *gru_base_vaddr)
        return 0;
 
 fail:
-       for (nid--; nid >= 0; nid--)
-               free_pages((unsigned long)gru_base[nid], order);
+       for (bid--; bid >= 0; bid--)
+               free_pages((unsigned long)gru_base[bid], order);
        return -ENOMEM;
 }
 
-#ifdef CONFIG_IA64
+static void gru_free_tables(void)
+{
+       int bid;
+       int order = get_order(sizeof(struct gru_state) *
+                             GRU_CHIPLETS_PER_BLADE);
 
-static int get_base_irq(void)
+       for (bid = 0; bid < GRU_MAX_BLADES; bid++)
+               free_pages((unsigned long)gru_base[bid], order);
+}
+
+static unsigned long gru_chiplet_cpu_to_mmr(int chiplet, int cpu, int *corep)
 {
-       return IRQ_GRU;
+       unsigned long mmr = 0;
+       int core;
+
+       /*
+        * We target the cores of a blade and not the hyperthreads themselves.
+        * There is a max of 8 cores per socket and 2 sockets per blade,
+        * making for a max total of 16 cores (i.e., 16 CPUs without
+        * hyperthreading and 32 CPUs with hyperthreading).
+        */
+       core = uv_cpu_core_number(cpu) + UV_MAX_INT_CORES * uv_cpu_socket_number(cpu);
+       if (core >= GRU_NUM_TFM || uv_cpu_ht_number(cpu))
+               return 0;
+
+       if (chiplet == 0) {
+               mmr = UVH_GR0_TLB_INT0_CONFIG +
+                   core * (UVH_GR0_TLB_INT1_CONFIG - UVH_GR0_TLB_INT0_CONFIG);
+       } else if (chiplet == 1) {
+               mmr = UVH_GR1_TLB_INT0_CONFIG +
+                   core * (UVH_GR1_TLB_INT1_CONFIG - UVH_GR1_TLB_INT0_CONFIG);
+       } else {
+               BUG();
+       }
+
+       *corep = core;
+       return mmr;
 }
 
-#elif defined CONFIG_X86_64
+#ifdef CONFIG_IA64
 
-static void noop(unsigned int irq)
+static int gru_irq_count[GRU_CHIPLETS_PER_BLADE];
+
+static void gru_noop(unsigned int irq)
 {
 }
 
-static struct irq_chip gru_chip = {
-       .name           = "gru",
-       .mask           = noop,
-       .unmask         = noop,
-       .ack            = noop,
+static struct irq_chip gru_chip[GRU_CHIPLETS_PER_BLADE] = {
+       [0 ... GRU_CHIPLETS_PER_BLADE - 1] {
+               .mask           = gru_noop,
+               .unmask         = gru_noop,
+               .ack            = gru_noop
+       }
 };
 
-static int get_base_irq(void)
+static int gru_chiplet_setup_tlb_irq(int chiplet, char *irq_name,
+                       irq_handler_t irq_handler, int cpu, int blade)
+{
+       unsigned long mmr;
+       int irq = IRQ_GRU + chiplet;
+       int ret, core;
+
+       mmr = gru_chiplet_cpu_to_mmr(chiplet, cpu, &core);
+       if (mmr == 0)
+               return 0;
+
+       if (gru_irq_count[chiplet] == 0) {
+               gru_chip[chiplet].name = irq_name;
+               ret = set_irq_chip(irq, &gru_chip[chiplet]);
+               if (ret) {
+                       printk(KERN_ERR "%s: set_irq_chip failed, errno=%d\n",
+                              GRU_DRIVER_ID_STR, -ret);
+                       return ret;
+               }
+
+               ret = request_irq(irq, irq_handler, 0, irq_name, NULL);
+               if (ret) {
+                       printk(KERN_ERR "%s: request_irq failed, errno=%d\n",
+                              GRU_DRIVER_ID_STR, -ret);
+                       return ret;
+               }
+       }
+       gru_irq_count[chiplet]++;
+
+       return 0;
+}
+
+static void gru_chiplet_teardown_tlb_irq(int chiplet, int cpu, int blade)
+{
+       unsigned long mmr;
+       int core, irq = IRQ_GRU + chiplet;
+
+       if (gru_irq_count[chiplet] == 0)
+               return;
+
+       mmr = gru_chiplet_cpu_to_mmr(chiplet, cpu, &core);
+       if (mmr == 0)
+               return;
+
+       if (--gru_irq_count[chiplet] == 0)
+               free_irq(irq, NULL);
+}
+
+#elif defined CONFIG_X86_64
+
+static int gru_chiplet_setup_tlb_irq(int chiplet, char *irq_name,
+                       irq_handler_t irq_handler, int cpu, int blade)
+{
+       unsigned long mmr;
+       int irq, core;
+       int ret;
+
+       mmr = gru_chiplet_cpu_to_mmr(chiplet, cpu, &core);
+       if (mmr == 0)
+               return 0;
+
+       irq = uv_setup_irq(irq_name, cpu, blade, mmr, UV_AFFINITY_CPU);
+       if (irq < 0) {
+               printk(KERN_ERR "%s: uv_setup_irq failed, errno=%d\n",
+                      GRU_DRIVER_ID_STR, -irq);
+               return irq;
+       }
+
+       ret = request_irq(irq, irq_handler, 0, irq_name, NULL);
+       if (ret) {
+               uv_teardown_irq(irq);
+               printk(KERN_ERR "%s: request_irq failed, errno=%d\n",
+                      GRU_DRIVER_ID_STR, -ret);
+               return ret;
+       }
+       gru_base[blade]->bs_grus[chiplet].gs_irq[core] = irq;
+       return 0;
+}
+
+static void gru_chiplet_teardown_tlb_irq(int chiplet, int cpu, int blade)
 {
-       set_irq_chip(IRQ_GRU, &gru_chip);
-       set_irq_chip(IRQ_GRU + 1, &gru_chip);
-       return IRQ_GRU;
+       int irq, core;
+       unsigned long mmr;
+
+       mmr = gru_chiplet_cpu_to_mmr(chiplet, cpu, &core);
+       if (mmr) {
+               irq = gru_base[blade]->bs_grus[chiplet].gs_irq[core];
+               if (irq) {
+                       free_irq(irq, NULL);
+                       uv_teardown_irq(irq);
+               }
+       }
 }
+
 #endif
 
+static void gru_teardown_tlb_irqs(void)
+{
+       int blade;
+       int cpu;
+
+       for_each_online_cpu(cpu) {
+               blade = uv_cpu_to_blade_id(cpu);
+               gru_chiplet_teardown_tlb_irq(0, cpu, blade);
+               gru_chiplet_teardown_tlb_irq(1, cpu, blade);
+       }
+       for_each_possible_blade(blade) {
+               if (uv_blade_nr_possible_cpus(blade))
+                       continue;
+               gru_chiplet_teardown_tlb_irq(0, 0, blade);
+               gru_chiplet_teardown_tlb_irq(1, 0, blade);
+       }
+}
+
+static int gru_setup_tlb_irqs(void)
+{
+       int blade;
+       int cpu;
+       int ret;
+
+       for_each_online_cpu(cpu) {
+               blade = uv_cpu_to_blade_id(cpu);
+               ret = gru_chiplet_setup_tlb_irq(0, "GRU0_TLB", gru0_intr, cpu, blade);
+               if (ret != 0)
+                       goto exit1;
+
+               ret = gru_chiplet_setup_tlb_irq(1, "GRU1_TLB", gru1_intr, cpu, blade);
+               if (ret != 0)
+                       goto exit1;
+       }
+       for_each_possible_blade(blade) {
+               if (uv_blade_nr_possible_cpus(blade))
+                       continue;
+               ret = gru_chiplet_setup_tlb_irq(0, "GRU0_TLB", gru_intr_mblade, 0, blade);
+               if (ret != 0)
+                       goto exit1;
+
+               ret = gru_chiplet_setup_tlb_irq(1, "GRU1_TLB", gru_intr_mblade, 0, blade);
+               if (ret != 0)
+                       goto exit1;
+       }
+
+       return 0;
+
+exit1:
+       gru_teardown_tlb_irqs();
+       return ret;
+}
+
 /*
  * gru_init
  *
@@ -338,8 +516,7 @@ static int get_base_irq(void)
  */
 static int __init gru_init(void)
 {
-       int ret, irq, chip;
-       char id[10];
+       int ret;
 
        if (!is_uv_system())
                return 0;
@@ -354,41 +531,29 @@ static int __init gru_init(void)
        gru_end_paddr = gru_start_paddr + GRU_MAX_BLADES * GRU_SIZE;
        printk(KERN_INFO "GRU space: 0x%lx - 0x%lx\n",
               gru_start_paddr, gru_end_paddr);
-       irq = get_base_irq();
-       for (chip = 0; chip < GRU_CHIPLETS_PER_BLADE; chip++) {
-               ret = request_irq(irq + chip, gru_intr, 0, id, NULL);
-               /* TODO: fix irq handling on x86. For now ignore failure because
-                * interrupts are not required & not yet fully supported */
-               if (ret) {
-                       printk(KERN_WARNING
-                              "!!!WARNING: GRU ignoring request failure!!!\n");
-                       ret = 0;
-               }
-               if (ret) {
-                       printk(KERN_ERR "%s: request_irq failed\n",
-                              GRU_DRIVER_ID_STR);
-                       goto exit1;
-               }
-       }
-
        ret = misc_register(&gru_miscdev);
        if (ret) {
                printk(KERN_ERR "%s: misc_register failed\n",
                       GRU_DRIVER_ID_STR);
-               goto exit1;
+               goto exit0;
        }
 
        ret = gru_proc_init();
        if (ret) {
                printk(KERN_ERR "%s: proc init failed\n", GRU_DRIVER_ID_STR);
-               goto exit2;
+               goto exit1;
        }
 
        ret = gru_init_tables(gru_start_paddr, gru_start_vaddr);
        if (ret) {
                printk(KERN_ERR "%s: init tables failed\n", GRU_DRIVER_ID_STR);
-               goto exit3;
+               goto exit2;
        }
+
+       ret = gru_setup_tlb_irqs();
+       if (ret != 0)
+               goto exit3;
+
        gru_kservices_init();
 
        printk(KERN_INFO "%s: v%s\n", GRU_DRIVER_ID_STR,
@@ -396,31 +561,24 @@ static int __init gru_init(void)
        return 0;
 
 exit3:
-       gru_proc_exit();
+       gru_free_tables();
 exit2:
-       misc_deregister(&gru_miscdev);
+       gru_proc_exit();
 exit1:
-       for (--chip; chip >= 0; chip--)
-               free_irq(irq + chip, NULL);
+       misc_deregister(&gru_miscdev);
+exit0:
        return ret;
 
 }
 
 static void __exit gru_exit(void)
 {
-       int i, bid;
-       int order = get_order(sizeof(struct gru_state) *
-                             GRU_CHIPLETS_PER_BLADE);
-
        if (!is_uv_system())
                return;
 
-       for (i = 0; i < GRU_CHIPLETS_PER_BLADE; i++)
-               free_irq(IRQ_GRU + i, NULL);
+       gru_teardown_tlb_irqs();
        gru_kservices_exit();
-       for (bid = 0; bid < GRU_MAX_BLADES; bid++)
-               free_pages((unsigned long)gru_base[bid], order);
-
+       gru_free_tables();
        misc_deregister(&gru_miscdev);
        gru_proc_exit();
 }
index 37e7cfc53b9c3be715f79413af5e07fe98b260d8..2f30badc6ffd9251cd2e59835e3061b2816cd09f 100644 (file)
 #ifdef CONFIG_IA64
 #include <asm/processor.h>
 #define GRU_OPERATION_TIMEOUT  (((cycles_t) local_cpu_data->itc_freq)*10)
+#define CLKS2NSEC(c)           ((c) *1000000000 / local_cpu_data->itc_freq)
 #else
 #include <asm/tsc.h>
 #define GRU_OPERATION_TIMEOUT  ((cycles_t) tsc_khz*10*1000)
+#define CLKS2NSEC(c)           ((c) * 1000000 / tsc_khz)
 #endif
 
 /* Extract the status field from a kernel handle */
@@ -39,21 +41,39 @@ struct mcs_op_statistic mcs_op_statistics[mcsop_last];
 
 static void update_mcs_stats(enum mcs_op op, unsigned long clks)
 {
+       unsigned long nsec;
+
+       nsec = CLKS2NSEC(clks);
        atomic_long_inc(&mcs_op_statistics[op].count);
-       atomic_long_add(clks, &mcs_op_statistics[op].total);
-       if (mcs_op_statistics[op].max < clks)
-               mcs_op_statistics[op].max = clks;
+       atomic_long_add(nsec, &mcs_op_statistics[op].total);
+       if (mcs_op_statistics[op].max < nsec)
+               mcs_op_statistics[op].max = nsec;
 }
 
 static void start_instruction(void *h)
 {
        unsigned long *w0 = h;
 
-       wmb();          /* setting CMD bit must be last */
-       *w0 = *w0 | 1;
+       wmb();          /* setting CMD/STATUS bits must be last */
+       *w0 = *w0 | 0x20001;
        gru_flush_cache(h);
 }
 
+static void report_instruction_timeout(void *h)
+{
+       unsigned long goff = GSEGPOFF((unsigned long)h);
+       char *id = "???";
+
+       if (TYPE_IS(CCH, goff))
+               id = "CCH";
+       else if (TYPE_IS(TGH, goff))
+               id = "TGH";
+       else if (TYPE_IS(TFH, goff))
+               id = "TFH";
+
+       panic(KERN_ALERT "GRU %p (%s) is malfunctioning\n", h, id);
+}
+
 static int wait_instruction_complete(void *h, enum mcs_op opc)
 {
        int status;
@@ -64,9 +84,10 @@ static int wait_instruction_complete(void *h, enum mcs_op opc)
                status = GET_MSEG_HANDLE_STATUS(h);
                if (status != CCHSTATUS_ACTIVE)
                        break;
-               if (GRU_OPERATION_TIMEOUT < (get_cycles() - start_time))
-                       panic("GRU %p is malfunctioning: start %ld, end %ld\n",
-                             h, start_time, (unsigned long)get_cycles());
+               if (GRU_OPERATION_TIMEOUT < (get_cycles() - start_time)) {
+                       report_instruction_timeout(h);
+                       start_time = get_cycles();
+               }
        }
        if (gru_options & OPT_STATS)
                update_mcs_stats(opc, get_cycles() - start_time);
@@ -75,9 +96,18 @@ static int wait_instruction_complete(void *h, enum mcs_op opc)
 
 int cch_allocate(struct gru_context_configuration_handle *cch)
 {
+       int ret;
+
        cch->opc = CCHOP_ALLOCATE;
        start_instruction(cch);
-       return wait_instruction_complete(cch, cchop_allocate);
+       ret = wait_instruction_complete(cch, cchop_allocate);
+
+       /*
+        * Stop speculation into the GSEG being mapped by the previous ALLOCATE.
+        * The GSEG memory does not exist until the ALLOCATE completes.
+        */
+       sync_core();
+       return ret;
 }
 
 int cch_start(struct gru_context_configuration_handle *cch)
@@ -96,9 +126,18 @@ int cch_interrupt(struct gru_context_configuration_handle *cch)
 
 int cch_deallocate(struct gru_context_configuration_handle *cch)
 {
+       int ret;
+
        cch->opc = CCHOP_DEALLOCATE;
        start_instruction(cch);
-       return wait_instruction_complete(cch, cchop_deallocate);
+       ret = wait_instruction_complete(cch, cchop_deallocate);
+
+       /*
+        * Stop speculation into the GSEG being unmapped by the previous
+        * DEALLOCATE.
+        */
+       sync_core();
+       return ret;
 }
 
 int cch_interrupt_sync(struct gru_context_configuration_handle
@@ -126,17 +165,20 @@ int tgh_invalidate(struct gru_tlb_global_handle *tgh,
        return wait_instruction_complete(tgh, tghop_invalidate);
 }
 
-void tfh_write_only(struct gru_tlb_fault_handle *tfh,
-                                 unsigned long pfn, unsigned long vaddr,
-                                 int asid, int dirty, int pagesize)
+int tfh_write_only(struct gru_tlb_fault_handle *tfh,
+                                 unsigned long paddr, int gaa,
+                                 unsigned long vaddr, int asid, int dirty,
+                                 int pagesize)
 {
        tfh->fillasid = asid;
        tfh->fillvaddr = vaddr;
-       tfh->pfn = pfn;
+       tfh->pfn = paddr >> GRU_PADDR_SHIFT;
+       tfh->gaa = gaa;
        tfh->dirty = dirty;
        tfh->pagesize = pagesize;
        tfh->opc = TFHOP_WRITE_ONLY;
        start_instruction(tfh);
+       return wait_instruction_complete(tfh, tfhop_write_only);
 }
 
 void tfh_write_restart(struct gru_tlb_fault_handle *tfh,
index f44112242d00f739c5da87822862c3b074c3c20f..3f998b924d8f8cdca04b082a0cade431e63988e8 100644 (file)
 /* Convert an arbitrary handle address to the beginning of the GRU segment */
 #define GRUBASE(h)             ((void *)((unsigned long)(h) & ~(GRU_SIZE - 1)))
 
+/* Test a valid handle address to determine the type */
+#define TYPE_IS(hn, h)         ((h) >= GRU_##hn##_BASE && (h) <        \
+               GRU_##hn##_BASE + GRU_NUM_##hn * GRU_HANDLE_STRIDE &&   \
+               (((h) & (GRU_HANDLE_STRIDE - 1)) == 0))
+
+
 /* General addressing macros. */
 static inline void *get_gseg_base_address(void *base, int ctxnum)
 {
@@ -158,6 +164,16 @@ static inline void *gru_chiplet_vaddr(void *vaddr, int pnode, int chiplet)
        return vaddr + GRU_SIZE * (2 * pnode  + chiplet);
 }
 
+static inline struct gru_control_block_extended *gru_tfh_to_cbe(
+                                       struct gru_tlb_fault_handle *tfh)
+{
+       unsigned long cbe;
+
+       cbe = (unsigned long)tfh - GRU_TFH_BASE + GRU_CBE_BASE;
+       return (struct gru_control_block_extended*)cbe;
+}
+
+
 
 
 /*
@@ -236,6 +252,17 @@ enum gru_tgh_state {
        TGHSTATE_RESTART_CTX,
 };
 
+enum gru_tgh_cause {
+       TGHCAUSE_RR_ECC,
+       TGHCAUSE_TLB_ECC,
+       TGHCAUSE_LRU_ECC,
+       TGHCAUSE_PS_ECC,
+       TGHCAUSE_MUL_ERR,
+       TGHCAUSE_DATA_ERR,
+       TGHCAUSE_SW_FORCE
+};
+
+
 /*
  * TFH - TLB Global Handle
  *     Used for TLB dropins into the GRU TLB.
@@ -440,6 +467,12 @@ struct gru_control_block_extended {
        unsigned int cbrexecstatus:8;
 };
 
+/* CBE fields for active BCOPY instructions */
+#define cbe_baddr0     idef1upd
+#define cbe_baddr1     idef3upd
+#define cbe_src_cl     idef6cpy
+#define cbe_nelemcur   idef5upd
+
 enum gru_cbr_state {
        CBRSTATE_INACTIVE,
        CBRSTATE_IDLE,
@@ -487,8 +520,8 @@ int cch_interrupt_sync(struct gru_context_configuration_handle *cch);
 int tgh_invalidate(struct gru_tlb_global_handle *tgh, unsigned long vaddr,
        unsigned long vaddrmask, int asid, int pagesize, int global, int n,
        unsigned short ctxbitmap);
-void tfh_write_only(struct gru_tlb_fault_handle *tfh, unsigned long pfn,
-       unsigned long vaddr, int asid, int dirty, int pagesize);
+int tfh_write_only(struct gru_tlb_fault_handle *tfh, unsigned long paddr,
+       int gaa, unsigned long vaddr, int asid, int dirty, int pagesize);
 void tfh_write_restart(struct gru_tlb_fault_handle *tfh, unsigned long paddr,
        int gaa, unsigned long vaddr, int asid, int dirty, int pagesize);
 void tfh_restart(struct gru_tlb_fault_handle *tfh);
index 55eabfa85585eb60dd889ec09dc441f187623c7b..9b2062d173279438a92b6f1ba548404fe4c429b0 100644 (file)
@@ -44,7 +44,8 @@ static int gru_user_copy_handle(void __user **dp, void *s)
 
 static int gru_dump_context_data(void *grubase,
                        struct gru_context_configuration_handle *cch,
-                       void __user *ubuf, int ctxnum, int dsrcnt)
+                       void __user *ubuf, int ctxnum, int dsrcnt,
+                       int flush_cbrs)
 {
        void *cb, *cbe, *tfh, *gseg;
        int i, scr;
@@ -55,6 +56,8 @@ static int gru_dump_context_data(void *grubase,
        tfh = grubase + GRU_TFH_BASE;
 
        for_each_cbr_in_allocation_map(i, &cch->cbr_allocation_map, scr) {
+               if (flush_cbrs)
+                       gru_flush_cache(cb);
                if (gru_user_copy_handle(&ubuf, cb))
                        goto fail;
                if (gru_user_copy_handle(&ubuf, tfh + i * GRU_HANDLE_STRIDE))
@@ -115,7 +118,7 @@ fail:
 
 static int gru_dump_context(struct gru_state *gru, int ctxnum,
                void __user *ubuf, void __user *ubufend, char data_opt,
-               char lock_cch)
+               char lock_cch, char flush_cbrs)
 {
        struct gru_dump_context_header hdr;
        struct gru_dump_context_header __user *uhdr = ubuf;
@@ -159,8 +162,7 @@ static int gru_dump_context(struct gru_state *gru, int ctxnum,
                        ret = -EFBIG;
                else
                        ret = gru_dump_context_data(grubase, cch, ubuf, ctxnum,
-                                                       dsrcnt);
-
+                                                       dsrcnt, flush_cbrs);
        }
        if (cch_locked)
                unlock_cch_handle(cch);
@@ -215,7 +217,8 @@ int gru_dump_chiplet_request(unsigned long arg)
        for (ctxnum = 0; ctxnum < GRU_NUM_CCH; ctxnum++) {
                if (req.ctxnum == ctxnum || req.ctxnum < 0) {
                        ret = gru_dump_context(gru, ctxnum, ubuf, ubufend,
-                                               req.data_opt, req.lock_cch);
+                                               req.data_opt, req.lock_cch,
+                                               req.flush_cbrs);
                        if (ret < 0)
                                goto fail;
                        ubuf += ret;
index 766e21e15574c75ceba18828a4d492ac6a90a189..34749ee88dfa8966c7c453aaaf8dcec980206223 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/interrupt.h>
 #include <linux/uaccess.h>
 #include <linux/delay.h>
+#include <asm/io_apic.h>
 #include "gru.h"
 #include "grulib.h"
 #include "grutables.h"
@@ -97,9 +98,6 @@
 #define ASYNC_HAN_TO_BID(h)    ((h) - 1)
 #define ASYNC_BID_TO_HAN(b)    ((b) + 1)
 #define ASYNC_HAN_TO_BS(h)     gru_base[ASYNC_HAN_TO_BID(h)]
-#define KCB_TO_GID(cb)         ((cb - gru_start_vaddr) /               \
-                                       (GRU_SIZE * GRU_CHIPLETS_PER_BLADE))
-#define KCB_TO_BS(cb)          gru_base[KCB_TO_GID(cb)]
 
 #define GRU_NUM_KERNEL_CBR     1
 #define GRU_NUM_KERNEL_DSR_BYTES 256
@@ -160,8 +158,10 @@ static void gru_load_kernel_context(struct gru_blade_state *bs, int blade_id)
        up_read(&bs->bs_kgts_sema);
        down_write(&bs->bs_kgts_sema);
 
-       if (!bs->bs_kgts)
-               bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0);
+       if (!bs->bs_kgts) {
+               bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
+               bs->bs_kgts->ts_user_blade_id = blade_id;
+       }
        kgts = bs->bs_kgts;
 
        if (!kgts->ts_gru) {
@@ -172,9 +172,9 @@ static void gru_load_kernel_context(struct gru_blade_state *bs, int blade_id)
                kgts->ts_dsr_au_count = GRU_DS_BYTES_TO_AU(
                        GRU_NUM_KERNEL_DSR_BYTES * ncpus +
                                bs->bs_async_dsr_bytes);
-               while (!gru_assign_gru_context(kgts, blade_id)) {
+               while (!gru_assign_gru_context(kgts)) {
                        msleep(1);
-                       gru_steal_context(kgts, blade_id);
+                       gru_steal_context(kgts);
                }
                gru_load_context(kgts);
                gru = bs->bs_kgts->ts_gru;
@@ -200,13 +200,15 @@ static int gru_free_kernel_contexts(void)
                bs = gru_base[bid];
                if (!bs)
                        continue;
+
+               /* Ignore busy contexts. Don't want to block here.  */
                if (down_write_trylock(&bs->bs_kgts_sema)) {
                        kgts = bs->bs_kgts;
                        if (kgts && kgts->ts_gru)
                                gru_unload_context(kgts, 0);
-                       kfree(kgts);
                        bs->bs_kgts = NULL;
                        up_write(&bs->bs_kgts_sema);
+                       kfree(kgts);
                } else {
                        ret++;
                }
@@ -220,13 +222,21 @@ static int gru_free_kernel_contexts(void)
 static struct gru_blade_state *gru_lock_kernel_context(int blade_id)
 {
        struct gru_blade_state *bs;
+       int bid;
 
        STAT(lock_kernel_context);
-       bs = gru_base[blade_id];
+again:
+       bid = blade_id < 0 ? uv_numa_blade_id() : blade_id;
+       bs = gru_base[bid];
 
+       /* Handle the case where migration occured while waiting for the sema */
        down_read(&bs->bs_kgts_sema);
+       if (blade_id < 0 && bid != uv_numa_blade_id()) {
+               up_read(&bs->bs_kgts_sema);
+               goto again;
+       }
        if (!bs->bs_kgts || !bs->bs_kgts->ts_gru)
-               gru_load_kernel_context(bs, blade_id);
+               gru_load_kernel_context(bs, bid);
        return bs;
 
 }
@@ -255,7 +265,7 @@ static int gru_get_cpu_resources(int dsr_bytes, void **cb, void **dsr)
 
        BUG_ON(dsr_bytes > GRU_NUM_KERNEL_DSR_BYTES);
        preempt_disable();
-       bs = gru_lock_kernel_context(uv_numa_blade_id());
+       bs = gru_lock_kernel_context(-1);
        lcpu = uv_blade_processor_id();
        *cb = bs->kernel_cb + lcpu * GRU_HANDLE_STRIDE;
        *dsr = bs->kernel_dsr + lcpu * GRU_NUM_KERNEL_DSR_BYTES;
@@ -384,13 +394,31 @@ int gru_get_cb_exception_detail(void *cb,
                struct control_block_extended_exc_detail *excdet)
 {
        struct gru_control_block_extended *cbe;
-       struct gru_blade_state *bs;
-       int cbrnum;
-
-       bs = KCB_TO_BS(cb);
-       cbrnum = thread_cbr_number(bs->bs_kgts, get_cb_number(cb));
+       struct gru_thread_state *kgts = NULL;
+       unsigned long off;
+       int cbrnum, bid;
+
+       /*
+        * Locate kgts for cb. This algorithm is SLOW but
+        * this function is rarely called (ie., almost never).
+        * Performance does not matter.
+        */
+       for_each_possible_blade(bid) {
+               if (!gru_base[bid])
+                       break;
+               kgts = gru_base[bid]->bs_kgts;
+               if (!kgts || !kgts->ts_gru)
+                       continue;
+               off = cb - kgts->ts_gru->gs_gru_base_vaddr;
+               if (off < GRU_SIZE)
+                       break;
+               kgts = NULL;
+       }
+       BUG_ON(!kgts);
+       cbrnum = thread_cbr_number(kgts, get_cb_number(cb));
        cbe = get_cbe(GRUBASE(cb), cbrnum);
        gru_flush_cache(cbe);   /* CBE not coherent */
+       sync_core();
        excdet->opc = cbe->opccpy;
        excdet->exopc = cbe->exopccpy;
        excdet->ecause = cbe->ecause;
@@ -409,8 +437,8 @@ char *gru_get_cb_exception_detail_str(int ret, void *cb,
        if (ret > 0 && gen->istatus == CBS_EXCEPTION) {
                gru_get_cb_exception_detail(cb, &excdet);
                snprintf(buf, size,
-                       "GRU exception: cb %p, opc %d, exopc %d, ecause 0x%x,"
-                       "excdet0 0x%lx, excdet1 0x%x",
+                       "GRU:%d exception: cb %p, opc %d, exopc %d, ecause 0x%x,"
+                       "excdet0 0x%lx, excdet1 0x%x", smp_processor_id(),
                        gen, excdet.opc, excdet.exopc, excdet.ecause,
                        excdet.exceptdet0, excdet.exceptdet1);
        } else {
@@ -457,9 +485,10 @@ int gru_check_status_proc(void *cb)
        int ret;
 
        ret = gen->istatus;
-       if (ret != CBS_EXCEPTION)
-               return ret;
-       return gru_retry_exception(cb);
+       if (ret == CBS_EXCEPTION)
+               ret = gru_retry_exception(cb);
+       rmb();
+       return ret;
 
 }
 
@@ -471,7 +500,7 @@ int gru_wait_proc(void *cb)
        ret = gru_wait_idle_or_exception(gen);
        if (ret == CBS_EXCEPTION)
                ret = gru_retry_exception(cb);
-
+       rmb();
        return ret;
 }
 
@@ -538,7 +567,7 @@ int gru_create_message_queue(struct gru_message_queue_desc *mqd,
        mqd->mq = mq;
        mqd->mq_gpa = uv_gpa(mq);
        mqd->qlines = qlines;
-       mqd->interrupt_pnode = UV_NASID_TO_PNODE(nasid);
+       mqd->interrupt_pnode = nasid >> 1;
        mqd->interrupt_vector = vector;
        mqd->interrupt_apicid = apicid;
        return 0;
@@ -598,6 +627,8 @@ static int send_noop_message(void *cb, struct gru_message_queue_desc *mqd,
                                ret = MQE_UNEXPECTED_CB_ERR;
                        break;
                case CBSS_PAGE_OVERFLOW:
+                       STAT(mesq_noop_page_overflow);
+                       /* fallthru */
                default:
                        BUG();
                }
@@ -672,18 +703,6 @@ cberr:
        return MQE_UNEXPECTED_CB_ERR;
 }
 
-/*
- * Send a cross-partition interrupt to the SSI that contains the target
- * message queue. Normally, the interrupt is automatically delivered by hardware
- * but some error conditions require explicit delivery.
- */
-static void send_message_queue_interrupt(struct gru_message_queue_desc *mqd)
-{
-       if (mqd->interrupt_vector)
-               uv_hub_send_ipi(mqd->interrupt_pnode, mqd->interrupt_apicid,
-                               mqd->interrupt_vector);
-}
-
 /*
  * Handle a PUT failure. Note: if message was a 2-line message, one of the
  * lines might have successfully have been written. Before sending the
@@ -693,7 +712,8 @@ static void send_message_queue_interrupt(struct gru_message_queue_desc *mqd)
 static int send_message_put_nacked(void *cb, struct gru_message_queue_desc *mqd,
                        void *mesg, int lines)
 {
-       unsigned long m;
+       unsigned long m, *val = mesg, gpa, save;
+       int ret;
 
        m = mqd->mq_gpa + (gru_get_amo_value_head(cb) << 6);
        if (lines == 2) {
@@ -704,7 +724,26 @@ static int send_message_put_nacked(void *cb, struct gru_message_queue_desc *mqd,
        gru_vstore(cb, m, gru_get_tri(mesg), XTYPE_CL, lines, 1, IMA);
        if (gru_wait(cb) != CBS_IDLE)
                return MQE_UNEXPECTED_CB_ERR;
-       send_message_queue_interrupt(mqd);
+
+       if (!mqd->interrupt_vector)
+               return MQE_OK;
+
+       /*
+        * Send a cross-partition interrupt to the SSI that contains the target
+        * message queue. Normally, the interrupt is automatically delivered by
+        * hardware but some error conditions require explicit delivery.
+        * Use the GRU to deliver the interrupt. Otherwise partition failures
+        * could cause unrecovered errors.
+        */
+       gpa = uv_global_gru_mmr_address(mqd->interrupt_pnode, UVH_IPI_INT);
+       save = *val;
+       *val = uv_hub_ipi_value(mqd->interrupt_apicid, mqd->interrupt_vector,
+                               dest_Fixed);
+       gru_vstore_phys(cb, gpa, gru_get_tri(mesg), IAA_REGISTER, IMA);
+       ret = gru_wait(cb);
+       *val = save;
+       if (ret != CBS_IDLE)
+               return MQE_UNEXPECTED_CB_ERR;
        return MQE_OK;
 }
 
@@ -739,6 +778,9 @@ static int send_message_failure(void *cb, struct gru_message_queue_desc *mqd,
                STAT(mesq_send_put_nacked);
                ret = send_message_put_nacked(cb, mqd, mesg, lines);
                break;
+       case CBSS_PAGE_OVERFLOW:
+               STAT(mesq_page_overflow);
+               /* fallthru */
        default:
                BUG();
        }
@@ -831,7 +873,6 @@ void *gru_get_next_message(struct gru_message_queue_desc *mqd)
        int present = mhdr->present;
 
        /* skip NOOP messages */
-       STAT(mesq_receive);
        while (present == MQS_NOOP) {
                gru_free_message(mqd, mhdr);
                mhdr = mq->next;
@@ -851,12 +892,36 @@ void *gru_get_next_message(struct gru_message_queue_desc *mqd)
        if (mhdr->lines == 2)
                restore_present2(mhdr, mhdr->present2);
 
+       STAT(mesq_receive);
        return mhdr;
 }
 EXPORT_SYMBOL_GPL(gru_get_next_message);
 
 /* ---------------------- GRU DATA COPY FUNCTIONS ---------------------------*/
 
+/*
+ * Load a DW from a global GPA. The GPA can be a memory or MMR address.
+ */
+int gru_read_gpa(unsigned long *value, unsigned long gpa)
+{
+       void *cb;
+       void *dsr;
+       int ret, iaa;
+
+       STAT(read_gpa);
+       if (gru_get_cpu_resources(GRU_NUM_KERNEL_DSR_BYTES, &cb, &dsr))
+               return MQE_BUG_NO_RESOURCES;
+       iaa = gpa >> 62;
+       gru_vload_phys(cb, gpa, gru_get_tri(dsr), iaa, IMA);
+       ret = gru_wait(cb);
+       if (ret == CBS_IDLE)
+               *value = *(unsigned long *)dsr;
+       gru_free_cpu_resources(cb, dsr);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(gru_read_gpa);
+
+
 /*
  * Copy a block of data using the GRU resources
  */
@@ -898,24 +963,24 @@ static int quicktest0(unsigned long arg)
 
        gru_vload(cb, uv_gpa(&word0), gru_get_tri(dsr), XTYPE_DW, 1, 1, IMA);
        if (gru_wait(cb) != CBS_IDLE) {
-               printk(KERN_DEBUG "GRU quicktest0: CBR failure 1\n");
+               printk(KERN_DEBUG "GRU:%d quicktest0: CBR failure 1\n", smp_processor_id());
                goto done;
        }
 
        if (*p != MAGIC) {
-               printk(KERN_DEBUG "GRU: quicktest0 bad magic 0x%lx\n", *p);
+               printk(KERN_DEBUG "GRU:%d quicktest0 bad magic 0x%lx\n", smp_processor_id(), *p);
                goto done;
        }
        gru_vstore(cb, uv_gpa(&word1), gru_get_tri(dsr), XTYPE_DW, 1, 1, IMA);
        if (gru_wait(cb) != CBS_IDLE) {
-               printk(KERN_DEBUG "GRU quicktest0: CBR failure 2\n");
+               printk(KERN_DEBUG "GRU:%d quicktest0: CBR failure 2\n", smp_processor_id());
                goto done;
        }
 
        if (word0 != word1 || word1 != MAGIC) {
                printk(KERN_DEBUG
-                      "GRU quicktest0 err: found 0x%lx, expected 0x%lx\n",
-                    word1, MAGIC);
+                      "GRU:%d quicktest0 err: found 0x%lx, expected 0x%lx\n",
+                    smp_processor_id(), word1, MAGIC);
                goto done;
        }
        ret = 0;
@@ -952,8 +1017,11 @@ static int quicktest1(unsigned long arg)
                if (ret)
                        break;
        }
-       if (ret != MQE_QUEUE_FULL || i != 4)
+       if (ret != MQE_QUEUE_FULL || i != 4) {
+               printk(KERN_DEBUG "GRU:%d quicktest1: unexpect status %d, i %d\n",
+                      smp_processor_id(), ret, i);
                goto done;
+       }
 
        for (i = 0; i < 6; i++) {
                m = gru_get_next_message(&mqd);
@@ -961,7 +1029,12 @@ static int quicktest1(unsigned long arg)
                        break;
                gru_free_message(&mqd, m);
        }
-       ret = (i == 4) ? 0 : -EIO;
+       if (i != 4) {
+               printk(KERN_DEBUG "GRU:%d quicktest2: bad message, i %d, m %p, m8 %d\n",
+                       smp_processor_id(), i, m, m ? m[8] : -1);
+               goto done;
+       }
+       ret = 0;
 
 done:
        kfree(p);
@@ -977,6 +1050,7 @@ static int quicktest2(unsigned long arg)
        int ret = 0;
        unsigned long *buf;
        void *cb0, *cb;
+       struct gru_control_block_status *gen;
        int i, k, istatus, bytes;
 
        bytes = numcb * 4 * 8;
@@ -996,20 +1070,30 @@ static int quicktest2(unsigned long arg)
                                XTYPE_DW, 4, 1, IMA_INTERRUPT);
 
        ret = 0;
-       for (k = 0; k < numcb; k++) {
+       k = numcb;
+       do {
                gru_wait_async_cbr(han);
                for (i = 0; i < numcb; i++) {
                        cb = cb0 + i * GRU_HANDLE_STRIDE;
                        istatus = gru_check_status(cb);
-                       if (istatus == CBS_ACTIVE)
-                               continue;
-                       if (istatus == CBS_EXCEPTION)
-                               ret = -EFAULT;
-                       else if (buf[i] || buf[i + 1] || buf[i + 2] ||
-                                       buf[i + 3])
-                               ret = -EIO;
+                       if (istatus != CBS_ACTIVE && istatus != CBS_CALL_OS)
+                               break;
                }
-       }
+               if (i == numcb)
+                       continue;
+               if (istatus != CBS_IDLE) {
+                       printk(KERN_DEBUG "GRU:%d quicktest2: cb %d, exception\n", smp_processor_id(), i);
+                       ret = -EFAULT;
+               } else if (buf[4 * i] || buf[4 * i + 1] || buf[4 * i + 2] ||
+                               buf[4 * i + 3]) {
+                       printk(KERN_DEBUG "GRU:%d quicktest2:cb %d,  buf 0x%lx, 0x%lx, 0x%lx, 0x%lx\n",
+                              smp_processor_id(), i, buf[4 * i], buf[4 * i + 1], buf[4 * i + 2], buf[4 * i + 3]);
+                       ret = -EIO;
+               }
+               k--;
+               gen = cb;
+               gen->istatus = CBS_CALL_OS; /* don't handle this CBR again */
+       } while (k);
        BUG_ON(cmp.done);
 
        gru_unlock_async_resource(han);
@@ -1019,6 +1103,22 @@ done:
        return ret;
 }
 
+#define BUFSIZE 200
+static int quicktest3(unsigned long arg)
+{
+       char buf1[BUFSIZE], buf2[BUFSIZE];
+       int ret = 0;
+
+       memset(buf2, 0, sizeof(buf2));
+       memset(buf1, get_cycles() & 255, sizeof(buf1));
+       gru_copy_gpa(uv_gpa(buf2), uv_gpa(buf1), BUFSIZE);
+       if (memcmp(buf1, buf2, BUFSIZE)) {
+               printk(KERN_DEBUG "GRU:%d quicktest3 error\n", smp_processor_id());
+               ret = -EIO;
+       }
+       return ret;
+}
+
 /*
  * Debugging only. User hook for various kernel tests
  * of driver & gru.
@@ -1037,6 +1137,9 @@ int gru_ktest(unsigned long arg)
        case 2:
                ret = quicktest2(arg);
                break;
+       case 3:
+               ret = quicktest3(arg);
+               break;
        case 99:
                ret = gru_free_kernel_contexts();
                break;
index d60d34bca44d9ccc66a44c481b4043e041a5e832..02aa94d8484ad8e7ec01aee963d563e216f30fa4 100644 (file)
@@ -130,6 +130,20 @@ extern void gru_free_message(struct gru_message_queue_desc *mqd,
 extern void *gru_get_next_message(struct gru_message_queue_desc *mqd);
 
 
+/*
+ * Read a GRU global GPA. Source can be located in a remote partition.
+ *
+ *    Input:
+ *     value           memory address where MMR value is returned
+ *     gpa             source numalink physical address of GPA
+ *
+ *    Output:
+ *     0               OK
+ *     >0              error
+ */
+int gru_read_gpa(unsigned long *value, unsigned long gpa);
+
+
 /*
  * Copy data using the GRU. Source or destination can be located in a remote
  * partition.
index 889bc442a3e81c8d09791f0e7256935f5378ee2b..e77d1b1f9d0500d6e689c6c945562c40d21802bb 100644 (file)
 #define THREAD_POINTER(p, th)          (p + GRU_GSEG_PAGESIZE * (th))
 #define GSEG_START(cb)                 ((void *)((unsigned long)(cb) & ~(GRU_GSEG_PAGESIZE - 1)))
 
-/*
- * Statictics kept on a per-GTS basis.
- */
-struct gts_statistics {
-       unsigned long   fmm_tlbdropin;
-       unsigned long   upm_tlbdropin;
-       unsigned long   context_stolen;
-};
-
 struct gru_get_gseg_statistics_req {
-       unsigned long           gseg;
-       struct gts_statistics   stats;
+       unsigned long                   gseg;
+       struct gru_gseg_statistics      stats;
 };
 
 /*
@@ -86,6 +77,7 @@ struct gru_create_context_req {
        unsigned int            control_blocks;
        unsigned int            maximum_thread_count;
        unsigned int            options;
+       unsigned char           tlb_preload_count;
 };
 
 /*
@@ -98,11 +90,12 @@ struct gru_unload_context_req {
 /*
  * Structure used to set context options
  */
-enum {sco_gseg_owner, sco_cch_req_slice};
+enum {sco_gseg_owner, sco_cch_req_slice, sco_blade_chiplet};
 struct gru_set_context_option_req {
        unsigned long   gseg;
        int             op;
-       unsigned long   val1;
+       int             val0;
+       long            val1;
 };
 
 /*
@@ -124,6 +117,8 @@ struct gru_dump_chiplet_state_req {
        int             ctxnum;
        char            data_opt;
        char            lock_cch;
+       char            flush_cbrs;
+       char            fill[10];
        pid_t           pid;
        void            *buf;
        size_t          buflen;
index 3bc643dad606aa955788fa866bb6c12a7e315ee5..f8538bbd0bfae72c11128d773f00aadc91f0c1ba 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/sched.h>
 #include <linux/device.h>
 #include <linux/list.h>
+#include <linux/err.h>
 #include <asm/uv/uv_hub.h>
 #include "gru.h"
 #include "grutables.h"
@@ -48,12 +49,20 @@ struct device *grudev = &gru_device;
 /*
  * Select a gru fault map to be used by the current cpu. Note that
  * multiple cpus may be using the same map.
- *     ZZZ should "shift" be used?? Depends on HT cpu numbering
  *     ZZZ should be inline but did not work on emulator
  */
 int gru_cpu_fault_map_id(void)
 {
+#ifdef CONFIG_IA64
        return uv_blade_processor_id() % GRU_NUM_TFM;
+#else
+       int cpu = smp_processor_id();
+       int id, core;
+
+       core = uv_cpu_core_number(cpu);
+       id = core + UV_MAX_INT_CORES * uv_cpu_socket_number(cpu);
+       return id;
+#endif
 }
 
 /*--------- ASID Management -------------------------------------------
@@ -286,7 +295,8 @@ static void gru_unload_mm_tracker(struct gru_state *gru,
 void gts_drop(struct gru_thread_state *gts)
 {
        if (gts && atomic_dec_return(&gts->ts_refcnt) == 0) {
-               gru_drop_mmu_notifier(gts->ts_gms);
+               if (gts->ts_gms)
+                       gru_drop_mmu_notifier(gts->ts_gms);
                kfree(gts);
                STAT(gts_free);
        }
@@ -310,16 +320,18 @@ static struct gru_thread_state *gru_find_current_gts_nolock(struct gru_vma_data
  * Allocate a thread state structure.
  */
 struct gru_thread_state *gru_alloc_gts(struct vm_area_struct *vma,
-               int cbr_au_count, int dsr_au_count, int options, int tsid)
+               int cbr_au_count, int dsr_au_count,
+               unsigned char tlb_preload_count, int options, int tsid)
 {
        struct gru_thread_state *gts;
+       struct gru_mm_struct *gms;
        int bytes;
 
        bytes = DSR_BYTES(dsr_au_count) + CBR_BYTES(cbr_au_count);
        bytes += sizeof(struct gru_thread_state);
        gts = kmalloc(bytes, GFP_KERNEL);
        if (!gts)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        STAT(gts_alloc);
        memset(gts, 0, sizeof(struct gru_thread_state)); /* zero out header */
@@ -327,7 +339,10 @@ struct gru_thread_state *gru_alloc_gts(struct vm_area_struct *vma,
        mutex_init(&gts->ts_ctxlock);
        gts->ts_cbr_au_count = cbr_au_count;
        gts->ts_dsr_au_count = dsr_au_count;
+       gts->ts_tlb_preload_count = tlb_preload_count;
        gts->ts_user_options = options;
+       gts->ts_user_blade_id = -1;
+       gts->ts_user_chiplet_id = -1;
        gts->ts_tsid = tsid;
        gts->ts_ctxnum = NULLCTX;
        gts->ts_tlb_int_select = -1;
@@ -336,9 +351,10 @@ struct gru_thread_state *gru_alloc_gts(struct vm_area_struct *vma,
        if (vma) {
                gts->ts_mm = current->mm;
                gts->ts_vma = vma;
-               gts->ts_gms = gru_register_mmu_notifier();
-               if (!gts->ts_gms)
+               gms = gru_register_mmu_notifier();
+               if (IS_ERR(gms))
                        goto err;
+               gts->ts_gms = gms;
        }
 
        gru_dbg(grudev, "alloc gts %p\n", gts);
@@ -346,7 +362,7 @@ struct gru_thread_state *gru_alloc_gts(struct vm_area_struct *vma,
 
 err:
        gts_drop(gts);
-       return NULL;
+       return ERR_CAST(gms);
 }
 
 /*
@@ -360,6 +376,7 @@ struct gru_vma_data *gru_alloc_vma_data(struct vm_area_struct *vma, int tsid)
        if (!vdata)
                return NULL;
 
+       STAT(vdata_alloc);
        INIT_LIST_HEAD(&vdata->vd_head);
        spin_lock_init(&vdata->vd_lock);
        gru_dbg(grudev, "alloc vdata %p\n", vdata);
@@ -392,10 +409,12 @@ struct gru_thread_state *gru_alloc_thread_state(struct vm_area_struct *vma,
        struct gru_vma_data *vdata = vma->vm_private_data;
        struct gru_thread_state *gts, *ngts;
 
-       gts = gru_alloc_gts(vma, vdata->vd_cbr_au_count, vdata->vd_dsr_au_count,
+       gts = gru_alloc_gts(vma, vdata->vd_cbr_au_count,
+                           vdata->vd_dsr_au_count,
+                           vdata->vd_tlb_preload_count,
                            vdata->vd_user_options, tsid);
-       if (!gts)
-               return NULL;
+       if (IS_ERR(gts))
+               return gts;
 
        spin_lock(&vdata->vd_lock);
        ngts = gru_find_current_gts_nolock(vdata, tsid);
@@ -493,6 +512,9 @@ static void gru_load_context_data(void *save, void *grubase, int ctxnum,
                        memset(cbe + i * GRU_HANDLE_STRIDE, 0,
                                                GRU_CACHE_LINE_BYTES);
                }
+               /* Flush CBE to hide race in context restart */
+               mb();
+               gru_flush_cache(cbe + i * GRU_HANDLE_STRIDE);
                cb += GRU_HANDLE_STRIDE;
        }
 
@@ -513,6 +535,12 @@ static void gru_unload_context_data(void *save, void *grubase, int ctxnum,
        cb = gseg + GRU_CB_BASE;
        cbe = grubase + GRU_CBE_BASE;
        length = hweight64(dsrmap) * GRU_DSR_AU_BYTES;
+
+       /* CBEs may not be coherent. Flush them from cache */
+       for_each_cbr_in_allocation_map(i, &cbrmap, scr)
+               gru_flush_cache(cbe + i * GRU_HANDLE_STRIDE);
+       mb();           /* Let the CL flush complete */
+
        gru_prefetch_context(gseg, cb, cbe, cbrmap, length);
 
        for_each_cbr_in_allocation_map(i, &cbrmap, scr) {
@@ -533,7 +561,8 @@ void gru_unload_context(struct gru_thread_state *gts, int savestate)
                zap_vma_ptes(gts->ts_vma, UGRUADDR(gts), GRU_GSEG_PAGESIZE);
        cch = get_cch(gru->gs_gru_base_vaddr, ctxnum);
 
-       gru_dbg(grudev, "gts %p\n", gts);
+       gru_dbg(grudev, "gts %p, cbrmap 0x%lx, dsrmap 0x%lx\n",
+               gts, gts->ts_cbr_map, gts->ts_dsr_map);
        lock_cch_handle(cch);
        if (cch_interrupt_sync(cch))
                BUG();
@@ -549,7 +578,6 @@ void gru_unload_context(struct gru_thread_state *gts, int savestate)
 
        if (cch_deallocate(cch))
                BUG();
-       gts->ts_force_unload = 0;       /* ts_force_unload locked by CCH lock */
        unlock_cch_handle(cch);
 
        gru_free_gru_context(gts);
@@ -565,9 +593,7 @@ void gru_load_context(struct gru_thread_state *gts)
        struct gru_context_configuration_handle *cch;
        int i, err, asid, ctxnum = gts->ts_ctxnum;
 
-       gru_dbg(grudev, "gts %p\n", gts);
        cch = get_cch(gru->gs_gru_base_vaddr, ctxnum);
-
        lock_cch_handle(cch);
        cch->tfm_fault_bit_enable =
            (gts->ts_user_options == GRU_OPT_MISS_FMM_POLL
@@ -591,6 +617,7 @@ void gru_load_context(struct gru_thread_state *gts)
                cch->unmap_enable = 1;
                cch->tfm_done_bit_enable = 1;
                cch->cb_int_enable = 1;
+               cch->tlb_int_select = 0;        /* For now, ints go to cpu 0 */
        } else {
                cch->unmap_enable = 0;
                cch->tfm_done_bit_enable = 0;
@@ -616,17 +643,18 @@ void gru_load_context(struct gru_thread_state *gts)
        if (cch_start(cch))
                BUG();
        unlock_cch_handle(cch);
+
+       gru_dbg(grudev, "gid %d, gts %p, cbrmap 0x%lx, dsrmap 0x%lx, tie %d, tis %d\n",
+               gts->ts_gru->gs_gid, gts, gts->ts_cbr_map, gts->ts_dsr_map,
+               (gts->ts_user_options == GRU_OPT_MISS_FMM_INTR), gts->ts_tlb_int_select);
 }
 
 /*
  * Update fields in an active CCH:
  *     - retarget interrupts on local blade
  *     - update sizeavail mask
- *     - force a delayed context unload by clearing the CCH asids. This
- *       forces TLB misses for new GRU instructions. The context is unloaded
- *       when the next TLB miss occurs.
  */
-int gru_update_cch(struct gru_thread_state *gts, int force_unload)
+int gru_update_cch(struct gru_thread_state *gts)
 {
        struct gru_context_configuration_handle *cch;
        struct gru_state *gru = gts->ts_gru;
@@ -640,21 +668,13 @@ int gru_update_cch(struct gru_thread_state *gts, int force_unload)
                        goto exit;
                if (cch_interrupt(cch))
                        BUG();
-               if (!force_unload) {
-                       for (i = 0; i < 8; i++)
-                               cch->sizeavail[i] = gts->ts_sizeavail;
-                       gts->ts_tlb_int_select = gru_cpu_fault_map_id();
-                       cch->tlb_int_select = gru_cpu_fault_map_id();
-                       cch->tfm_fault_bit_enable =
-                         (gts->ts_user_options == GRU_OPT_MISS_FMM_POLL
-                           || gts->ts_user_options == GRU_OPT_MISS_FMM_INTR);
-               } else {
-                       for (i = 0; i < 8; i++)
-                               cch->asid[i] = 0;
-                       cch->tfm_fault_bit_enable = 0;
-                       cch->tlb_int_enable = 0;
-                       gts->ts_force_unload = 1;
-               }
+               for (i = 0; i < 8; i++)
+                       cch->sizeavail[i] = gts->ts_sizeavail;
+               gts->ts_tlb_int_select = gru_cpu_fault_map_id();
+               cch->tlb_int_select = gru_cpu_fault_map_id();
+               cch->tfm_fault_bit_enable =
+                 (gts->ts_user_options == GRU_OPT_MISS_FMM_POLL
+                   || gts->ts_user_options == GRU_OPT_MISS_FMM_INTR);
                if (cch_start(cch))
                        BUG();
                ret = 1;
@@ -679,7 +699,54 @@ static int gru_retarget_intr(struct gru_thread_state *gts)
 
        gru_dbg(grudev, "retarget from %d to %d\n", gts->ts_tlb_int_select,
                gru_cpu_fault_map_id());
-       return gru_update_cch(gts, 0);
+       return gru_update_cch(gts);
+}
+
+/*
+ * Check if a GRU context is allowed to use a specific chiplet. By default
+ * a context is assigned to any blade-local chiplet. However, users can
+ * override this.
+ *     Returns 1 if assignment allowed, 0 otherwise
+ */
+static int gru_check_chiplet_assignment(struct gru_state *gru,
+                                       struct gru_thread_state *gts)
+{
+       int blade_id;
+       int chiplet_id;
+
+       blade_id = gts->ts_user_blade_id;
+       if (blade_id < 0)
+               blade_id = uv_numa_blade_id();
+
+       chiplet_id = gts->ts_user_chiplet_id;
+       return gru->gs_blade_id == blade_id &&
+               (chiplet_id < 0 || chiplet_id == gru->gs_chiplet_id);
+}
+
+/*
+ * Unload the gru context if it is not assigned to the correct blade or
+ * chiplet. Misassignment can occur if the process migrates to a different
+ * blade or if the user changes the selected blade/chiplet.
+ */
+void gru_check_context_placement(struct gru_thread_state *gts)
+{
+       struct gru_state *gru;
+
+       /*
+        * If the current task is the context owner, verify that the
+        * context is correctly placed. This test is skipped for non-owner
+        * references. Pthread apps use non-owner references to the CBRs.
+        */
+       gru = gts->ts_gru;
+       if (!gru || gts->ts_tgid_owner != current->tgid)
+               return;
+
+       if (!gru_check_chiplet_assignment(gru, gts)) {
+               STAT(check_context_unload);
+               gru_unload_context(gts, 1);
+       } else if (gru_retarget_intr(gts)) {
+               STAT(check_context_retarget_intr);
+       }
 }
 
 
@@ -712,13 +779,17 @@ static void gts_stolen(struct gru_thread_state *gts,
        }
 }
 
-void gru_steal_context(struct gru_thread_state *gts, int blade_id)
+void gru_steal_context(struct gru_thread_state *gts)
 {
        struct gru_blade_state *blade;
        struct gru_state *gru, *gru0;
        struct gru_thread_state *ngts = NULL;
        int ctxnum, ctxnum0, flag = 0, cbr, dsr;
+       int blade_id;
 
+       blade_id = gts->ts_user_blade_id;
+       if (blade_id < 0)
+               blade_id = uv_numa_blade_id();
        cbr = gts->ts_cbr_au_count;
        dsr = gts->ts_dsr_au_count;
 
@@ -729,35 +800,39 @@ void gru_steal_context(struct gru_thread_state *gts, int blade_id)
        gru = blade->bs_lru_gru;
        if (ctxnum == 0)
                gru = next_gru(blade, gru);
+       blade->bs_lru_gru = gru;
+       blade->bs_lru_ctxnum = ctxnum;
        ctxnum0 = ctxnum;
        gru0 = gru;
        while (1) {
-               if (check_gru_resources(gru, cbr, dsr, GRU_NUM_CCH))
-                       break;
-               spin_lock(&gru->gs_lock);
-               for (; ctxnum < GRU_NUM_CCH; ctxnum++) {
-                       if (flag && gru == gru0 && ctxnum == ctxnum0)
+               if (gru_check_chiplet_assignment(gru, gts)) {
+                       if (check_gru_resources(gru, cbr, dsr, GRU_NUM_CCH))
                                break;
-                       ngts = gru->gs_gts[ctxnum];
-                       /*
-                        * We are grabbing locks out of order, so trylock is
-                        * needed. GTSs are usually not locked, so the odds of
-                        * success are high. If trylock fails, try to steal a
-                        * different GSEG.
-                        */
-                       if (ngts && is_gts_stealable(ngts, blade))
+                       spin_lock(&gru->gs_lock);
+                       for (; ctxnum < GRU_NUM_CCH; ctxnum++) {
+                               if (flag && gru == gru0 && ctxnum == ctxnum0)
+                                       break;
+                               ngts = gru->gs_gts[ctxnum];
+                               /*
+                               * We are grabbing locks out of order, so trylock is
+                               * needed. GTSs are usually not locked, so the odds of
+                               * success are high. If trylock fails, try to steal a
+                               * different GSEG.
+                               */
+                               if (ngts && is_gts_stealable(ngts, blade))
+                                       break;
+                               ngts = NULL;
+                       }
+                       spin_unlock(&gru->gs_lock);
+                       if (ngts || (flag && gru == gru0 && ctxnum == ctxnum0))
                                break;
-                       ngts = NULL;
-                       flag = 1;
                }
-               spin_unlock(&gru->gs_lock);
-               if (ngts || (flag && gru == gru0 && ctxnum == ctxnum0))
+               if (flag && gru == gru0)
                        break;
+               flag = 1;
                ctxnum = 0;
                gru = next_gru(blade, gru);
        }
-       blade->bs_lru_gru = gru;
-       blade->bs_lru_ctxnum = ctxnum;
        spin_unlock(&blade->bs_lock);
 
        if (ngts) {
@@ -775,20 +850,35 @@ void gru_steal_context(struct gru_thread_state *gts, int blade_id)
                hweight64(gru->gs_dsr_map));
 }
 
+/*
+ * Assign a gru context.
+ */
+static int gru_assign_context_number(struct gru_state *gru)
+{
+       int ctxnum;
+
+       ctxnum = find_first_zero_bit(&gru->gs_context_map, GRU_NUM_CCH);
+       __set_bit(ctxnum, &gru->gs_context_map);
+       return ctxnum;
+}
+
 /*
  * Scan the GRUs on the local blade & assign a GRU context.
  */
-struct gru_state *gru_assign_gru_context(struct gru_thread_state *gts,
-                                               int blade)
+struct gru_state *gru_assign_gru_context(struct gru_thread_state *gts)
 {
        struct gru_state *gru, *grux;
        int i, max_active_contexts;
+       int blade_id = gts->ts_user_blade_id;
 
-
+       if (blade_id < 0)
+               blade_id = uv_numa_blade_id();
 again:
        gru = NULL;
        max_active_contexts = GRU_NUM_CCH;
-       for_each_gru_on_blade(grux, blade, i) {
+       for_each_gru_on_blade(grux, blade_id, i) {
+               if (!gru_check_chiplet_assignment(grux, gts))
+                       continue;
                if (check_gru_resources(grux, gts->ts_cbr_au_count,
                                        gts->ts_dsr_au_count,
                                        max_active_contexts)) {
@@ -809,12 +899,9 @@ again:
                reserve_gru_resources(gru, gts);
                gts->ts_gru = gru;
                gts->ts_blade = gru->gs_blade_id;
-               gts->ts_ctxnum =
-                   find_first_zero_bit(&gru->gs_context_map, GRU_NUM_CCH);
-               BUG_ON(gts->ts_ctxnum == GRU_NUM_CCH);
+               gts->ts_ctxnum = gru_assign_context_number(gru);
                atomic_inc(&gts->ts_refcnt);
                gru->gs_gts[gts->ts_ctxnum] = gts;
-               __set_bit(gts->ts_ctxnum, &gru->gs_context_map);
                spin_unlock(&gru->gs_lock);
 
                STAT(assign_context);
@@ -842,7 +929,6 @@ int gru_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        struct gru_thread_state *gts;
        unsigned long paddr, vaddr;
-       int blade_id;
 
        vaddr = (unsigned long)vmf->virtual_address;
        gru_dbg(grudev, "vma %p, vaddr 0x%lx (0x%lx)\n",
@@ -857,28 +943,18 @@ int gru_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 again:
        mutex_lock(&gts->ts_ctxlock);
        preempt_disable();
-       blade_id = uv_numa_blade_id();
 
-       if (gts->ts_gru) {
-               if (gts->ts_gru->gs_blade_id != blade_id) {
-                       STAT(migrated_nopfn_unload);
-                       gru_unload_context(gts, 1);
-               } else {
-                       if (gru_retarget_intr(gts))
-                               STAT(migrated_nopfn_retarget);
-               }
-       }
+       gru_check_context_placement(gts);
 
        if (!gts->ts_gru) {
                STAT(load_user_context);
-               if (!gru_assign_gru_context(gts, blade_id)) {
+               if (!gru_assign_gru_context(gts)) {
                        preempt_enable();
                        mutex_unlock(&gts->ts_ctxlock);
                        set_current_state(TASK_INTERRUPTIBLE);
                        schedule_timeout(GRU_ASSIGN_DELAY);  /* true hack ZZZ */
-                       blade_id = uv_numa_blade_id();
                        if (gts->ts_steal_jiffies + GRU_STEAL_DELAY < jiffies)
-                               gru_steal_context(gts, blade_id);
+                               gru_steal_context(gts);
                        goto again;
                }
                gru_load_context(gts);
index 3f2375c5ba5bd3a98ef37f6e628474d507188197..7768b87d995be6888b0b540f3cee7344546d25ea 100644 (file)
@@ -36,8 +36,7 @@ static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
 {
        unsigned long val = atomic_long_read(v);
 
-       if (val)
-               seq_printf(s, "%16lu %s\n", val, id);
+       seq_printf(s, "%16lu %s\n", val, id);
 }
 
 static int statistics_show(struct seq_file *s, void *p)
@@ -46,7 +45,8 @@ static int statistics_show(struct seq_file *s, void *p)
        printstat(s, vdata_free);
        printstat(s, gts_alloc);
        printstat(s, gts_free);
-       printstat(s, vdata_double_alloc);
+       printstat(s, gms_alloc);
+       printstat(s, gms_free);
        printstat(s, gts_double_allocate);
        printstat(s, assign_context);
        printstat(s, assign_context_failed);
@@ -59,28 +59,25 @@ static int statistics_show(struct seq_file *s, void *p)
        printstat(s, steal_kernel_context);
        printstat(s, steal_context_failed);
        printstat(s, nopfn);
-       printstat(s, break_cow);
        printstat(s, asid_new);
        printstat(s, asid_next);
        printstat(s, asid_wrap);
        printstat(s, asid_reuse);
        printstat(s, intr);
+       printstat(s, intr_cbr);
+       printstat(s, intr_tfh);
+       printstat(s, intr_spurious);
        printstat(s, intr_mm_lock_failed);
        printstat(s, call_os);
-       printstat(s, call_os_offnode_reference);
-       printstat(s, call_os_check_for_bug);
        printstat(s, call_os_wait_queue);
        printstat(s, user_flush_tlb);
        printstat(s, user_unload_context);
        printstat(s, user_exception);
        printstat(s, set_context_option);
-       printstat(s, migrate_check);
-       printstat(s, migrated_retarget);
-       printstat(s, migrated_unload);
-       printstat(s, migrated_unload_delay);
-       printstat(s, migrated_nopfn_retarget);
-       printstat(s, migrated_nopfn_unload);
+       printstat(s, check_context_retarget_intr);
+       printstat(s, check_context_unload);
        printstat(s, tlb_dropin);
+       printstat(s, tlb_preload_page);
        printstat(s, tlb_dropin_fail_no_asid);
        printstat(s, tlb_dropin_fail_upm);
        printstat(s, tlb_dropin_fail_invalid);
@@ -88,16 +85,15 @@ static int statistics_show(struct seq_file *s, void *p)
        printstat(s, tlb_dropin_fail_idle);
        printstat(s, tlb_dropin_fail_fmm);
        printstat(s, tlb_dropin_fail_no_exception);
-       printstat(s, tlb_dropin_fail_no_exception_war);
        printstat(s, tfh_stale_on_fault);
        printstat(s, mmu_invalidate_range);
        printstat(s, mmu_invalidate_page);
-       printstat(s, mmu_clear_flush_young);
        printstat(s, flush_tlb);
        printstat(s, flush_tlb_gru);
        printstat(s, flush_tlb_gru_tgh);
        printstat(s, flush_tlb_gru_zero_asid);
        printstat(s, copy_gpa);
+       printstat(s, read_gpa);
        printstat(s, mesq_receive);
        printstat(s, mesq_receive_none);
        printstat(s, mesq_send);
@@ -108,7 +104,6 @@ static int statistics_show(struct seq_file *s, void *p)
        printstat(s, mesq_send_qlimit_reached);
        printstat(s, mesq_send_amo_nacked);
        printstat(s, mesq_send_put_nacked);
-       printstat(s, mesq_qf_not_full);
        printstat(s, mesq_qf_locked);
        printstat(s, mesq_qf_noop_not_full);
        printstat(s, mesq_qf_switch_head_failed);
@@ -118,6 +113,7 @@ static int statistics_show(struct seq_file *s, void *p)
        printstat(s, mesq_noop_qlimit_reached);
        printstat(s, mesq_noop_amo_nacked);
        printstat(s, mesq_noop_put_nacked);
+       printstat(s, mesq_noop_page_overflow);
        return 0;
 }
 
@@ -133,8 +129,10 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
        int op;
        unsigned long total, count, max;
        static char *id[] = {"cch_allocate", "cch_start", "cch_interrupt",
-               "cch_interrupt_sync", "cch_deallocate", "tgh_invalidate"};
+               "cch_interrupt_sync", "cch_deallocate", "tfh_write_only",
+               "tfh_write_restart", "tgh_invalidate"};
 
+       seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
        for (op = 0; op < mcsop_last; op++) {
                count = atomic_long_read(&mcs_op_statistics[op].count);
                total = atomic_long_read(&mcs_op_statistics[op].total);
@@ -154,6 +152,7 @@ static ssize_t mcs_statistics_write(struct file *file,
 
 static int options_show(struct seq_file *s, void *p)
 {
+       seq_printf(s, "#bitmask: 1=trace, 2=statistics\n");
        seq_printf(s, "0x%lx\n", gru_options);
        return 0;
 }
@@ -183,16 +182,17 @@ static int cch_seq_show(struct seq_file *file, void *data)
        const char *mode[] = { "??", "UPM", "INTR", "OS_POLL" };
 
        if (gid == 0)
-               seq_printf(file, "#%5s%5s%6s%9s%6s%8s%8s\n", "gid", "bid",
-                          "ctx#", "pid", "cbrs", "dsbytes", "mode");
+               seq_printf(file, "#%5s%5s%6s%7s%9s%6s%8s%8s\n", "gid", "bid",
+                          "ctx#", "asid", "pid", "cbrs", "dsbytes", "mode");
        if (gru)
                for (i = 0; i < GRU_NUM_CCH; i++) {
                        ts = gru->gs_gts[i];
                        if (!ts)
                                continue;
-                       seq_printf(file, " %5d%5d%6d%9d%6d%8d%8s\n",
+                       seq_printf(file, " %5d%5d%6d%7d%9d%6d%8d%8s\n",
                                   gru->gs_gid, gru->gs_blade_id, i,
-                                  ts->ts_tgid_owner,
+                                  is_kernel_context(ts) ? 0 : ts->ts_gms->ms_asids[gid].mt_asid,
+                                  is_kernel_context(ts) ? 0 : ts->ts_tgid_owner,
                                   ts->ts_cbr_au_count * GRU_CBR_AU_SIZE,
                                   ts->ts_cbr_au_count * GRU_DSR_AU_BYTES,
                                   mode[ts->ts_user_options &
@@ -355,7 +355,7 @@ static void delete_proc_files(void)
                for (p = proc_files; p->name; p++)
                        if (p->entry)
                                remove_proc_entry(p->name, proc_gru);
-               remove_proc_entry("gru", NULL);
+               remove_proc_entry("gru", proc_gru->parent);
        }
 }
 
index 46990bcfa5369a541719cfcde7d0532aedaaca8c..02a77b8b8eef36c59117742c8970083b9d382ea9 100644 (file)
@@ -161,7 +161,7 @@ extern unsigned int gru_max_gids;
 #define GRU_MAX_GRUS           (GRU_MAX_BLADES * GRU_CHIPLETS_PER_BLADE)
 
 #define GRU_DRIVER_ID_STR      "SGI GRU Device Driver"
-#define GRU_DRIVER_VERSION_STR "0.80"
+#define GRU_DRIVER_VERSION_STR "0.85"
 
 /*
  * GRU statistics.
@@ -171,7 +171,8 @@ struct gru_stats_s {
        atomic_long_t vdata_free;
        atomic_long_t gts_alloc;
        atomic_long_t gts_free;
-       atomic_long_t vdata_double_alloc;
+       atomic_long_t gms_alloc;
+       atomic_long_t gms_free;
        atomic_long_t gts_double_allocate;
        atomic_long_t assign_context;
        atomic_long_t assign_context_failed;
@@ -184,28 +185,25 @@ struct gru_stats_s {
        atomic_long_t steal_kernel_context;
        atomic_long_t steal_context_failed;
        atomic_long_t nopfn;
-       atomic_long_t break_cow;
        atomic_long_t asid_new;
        atomic_long_t asid_next;
        atomic_long_t asid_wrap;
        atomic_long_t asid_reuse;
        atomic_long_t intr;
+       atomic_long_t intr_cbr;
+       atomic_long_t intr_tfh;
+       atomic_long_t intr_spurious;
        atomic_long_t intr_mm_lock_failed;
        atomic_long_t call_os;
-       atomic_long_t call_os_offnode_reference;
-       atomic_long_t call_os_check_for_bug;
        atomic_long_t call_os_wait_queue;
        atomic_long_t user_flush_tlb;
        atomic_long_t user_unload_context;
        atomic_long_t user_exception;
        atomic_long_t set_context_option;
-       atomic_long_t migrate_check;
-       atomic_long_t migrated_retarget;
-       atomic_long_t migrated_unload;
-       atomic_long_t migrated_unload_delay;
-       atomic_long_t migrated_nopfn_retarget;
-       atomic_long_t migrated_nopfn_unload;
+       atomic_long_t check_context_retarget_intr;
+       atomic_long_t check_context_unload;
        atomic_long_t tlb_dropin;
+       atomic_long_t tlb_preload_page;
        atomic_long_t tlb_dropin_fail_no_asid;
        atomic_long_t tlb_dropin_fail_upm;
        atomic_long_t tlb_dropin_fail_invalid;
@@ -213,17 +211,16 @@ struct gru_stats_s {
        atomic_long_t tlb_dropin_fail_idle;
        atomic_long_t tlb_dropin_fail_fmm;
        atomic_long_t tlb_dropin_fail_no_exception;
-       atomic_long_t tlb_dropin_fail_no_exception_war;
        atomic_long_t tfh_stale_on_fault;
        atomic_long_t mmu_invalidate_range;
        atomic_long_t mmu_invalidate_page;
-       atomic_long_t mmu_clear_flush_young;
        atomic_long_t flush_tlb;
        atomic_long_t flush_tlb_gru;
        atomic_long_t flush_tlb_gru_tgh;
        atomic_long_t flush_tlb_gru_zero_asid;
 
        atomic_long_t copy_gpa;
+       atomic_long_t read_gpa;
 
        atomic_long_t mesq_receive;
        atomic_long_t mesq_receive_none;
@@ -235,7 +232,7 @@ struct gru_stats_s {
        atomic_long_t mesq_send_qlimit_reached;
        atomic_long_t mesq_send_amo_nacked;
        atomic_long_t mesq_send_put_nacked;
-       atomic_long_t mesq_qf_not_full;
+       atomic_long_t mesq_page_overflow;
        atomic_long_t mesq_qf_locked;
        atomic_long_t mesq_qf_noop_not_full;
        atomic_long_t mesq_qf_switch_head_failed;
@@ -245,11 +242,13 @@ struct gru_stats_s {
        atomic_long_t mesq_noop_qlimit_reached;
        atomic_long_t mesq_noop_amo_nacked;
        atomic_long_t mesq_noop_put_nacked;
+       atomic_long_t mesq_noop_page_overflow;
 
 };
 
 enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
-       cchop_deallocate, tghop_invalidate, mcsop_last};
+       cchop_deallocate, tfhop_write_only, tfhop_write_restart,
+       tghop_invalidate, mcsop_last};
 
 struct mcs_op_statistic {
        atomic_long_t   count;
@@ -259,8 +258,8 @@ struct mcs_op_statistic {
 
 extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
 
-#define OPT_DPRINT     1
-#define OPT_STATS      2
+#define OPT_DPRINT             1
+#define OPT_STATS              2
 
 
 #define IRQ_GRU                        110     /* Starting IRQ number for interrupts */
@@ -283,7 +282,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
 #define gru_dbg(dev, fmt, x...)                                                \
        do {                                                            \
                if (gru_options & OPT_DPRINT)                           \
-                       dev_dbg(dev, "%s: " fmt, __func__, x);          \
+                       printk(KERN_DEBUG "GRU:%d %s: " fmt, smp_processor_id(), __func__, x);\
        } while (0)
 #else
 #define gru_dbg(x...)
@@ -297,13 +296,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
 #define ASID_INC       8       /* number of regions */
 
 /* Generate a GRU asid value from a GRU base asid & a virtual address. */
-#if defined CONFIG_IA64
 #define VADDR_HI_BIT           64
-#elif defined CONFIG_X86_64
-#define VADDR_HI_BIT           48
-#else
-#error "Unsupported architecture"
-#endif
 #define GRUREGION(addr)                ((addr) >> (VADDR_HI_BIT - 3) & 3)
 #define GRUASID(asid, addr)    ((asid) + GRUREGION(addr))
 
@@ -345,6 +338,7 @@ struct gru_vma_data {
        long                    vd_user_options;/* misc user option flags */
        int                     vd_cbr_au_count;
        int                     vd_dsr_au_count;
+       unsigned char           vd_tlb_preload_count;
 };
 
 /*
@@ -360,6 +354,7 @@ struct gru_thread_state {
        struct gru_state        *ts_gru;        /* GRU where the context is
                                                   loaded */
        struct gru_mm_struct    *ts_gms;        /* asid & ioproc struct */
+       unsigned char           ts_tlb_preload_count; /* TLB preload pages */
        unsigned long           ts_cbr_map;     /* map of allocated CBRs */
        unsigned long           ts_dsr_map;     /* map of allocated DATA
                                                   resources */
@@ -368,6 +363,8 @@ struct gru_thread_state {
        long                    ts_user_options;/* misc user option flags */
        pid_t                   ts_tgid_owner;  /* task that is using the
                                                   context - for migration */
+       short                   ts_user_blade_id;/* user selected blade */
+       char                    ts_user_chiplet_id;/* user selected chiplet */
        unsigned short          ts_sizeavail;   /* Pagesizes in use */
        int                     ts_tsid;        /* thread that owns the
                                                   structure */
@@ -384,13 +381,11 @@ struct gru_thread_state {
        char                    ts_blade;       /* If >= 0, migrate context if
                                                   ref from diferent blade */
        char                    ts_force_cch_reload;
-       char                    ts_force_unload;/* force context to be unloaded
-                                                  after migration */
        char                    ts_cbr_idx[GRU_CBR_AU];/* CBR numbers of each
                                                          allocated CB */
        int                     ts_data_valid;  /* Indicates if ts_gdata has
                                                   valid data */
-       struct gts_statistics   ustats;         /* User statistics */
+       struct gru_gseg_statistics ustats;      /* User statistics */
        unsigned long           ts_gdata[0];    /* save area for GRU data (CB,
                                                   DS, CBE) */
 };
@@ -422,6 +417,7 @@ struct gru_state {
                                                           gru segments (64) */
        unsigned short          gs_gid;                 /* unique GRU number */
        unsigned short          gs_blade_id;            /* blade of GRU */
+       unsigned char           gs_chiplet_id;          /* blade chiplet of GRU */
        unsigned char           gs_tgh_local_shift;     /* used to pick TGH for
                                                           local flush */
        unsigned char           gs_tgh_first_remote;    /* starting TGH# for
@@ -453,6 +449,7 @@ struct gru_state {
                                                           in use */
        struct gru_thread_state *gs_gts[GRU_NUM_CCH];   /* GTS currently using
                                                           the context */
+       int                     gs_irq[GRU_NUM_TFM];    /* Interrupt irqs */
 };
 
 /*
@@ -619,6 +616,15 @@ static inline int is_kernel_context(struct gru_thread_state *gts)
        return !gts->ts_mm;
 }
 
+/*
+ * The following are for Nehelem-EX. A more general scheme is needed for
+ * future processors.
+ */
+#define UV_MAX_INT_CORES               8
+#define uv_cpu_socket_number(p)                ((cpu_physical_id(p) >> 5) & 1)
+#define uv_cpu_ht_number(p)            (cpu_physical_id(p) & 1)
+#define uv_cpu_core_number(p)          (((cpu_physical_id(p) >> 2) & 4) |      \
+                                       ((cpu_physical_id(p) >> 1) & 3))
 /*-----------------------------------------------------------------------------
  * Function prototypes & externs
  */
@@ -633,24 +639,26 @@ extern struct gru_thread_state *gru_find_thread_state(struct vm_area_struct
                                *vma, int tsid);
 extern struct gru_thread_state *gru_alloc_thread_state(struct vm_area_struct
                                *vma, int tsid);
-extern struct gru_state *gru_assign_gru_context(struct gru_thread_state *gts,
-               int blade);
+extern struct gru_state *gru_assign_gru_context(struct gru_thread_state *gts);
 extern void gru_load_context(struct gru_thread_state *gts);
-extern void gru_steal_context(struct gru_thread_state *gts, int blade_id);
+extern void gru_steal_context(struct gru_thread_state *gts);
 extern void gru_unload_context(struct gru_thread_state *gts, int savestate);
-extern int gru_update_cch(struct gru_thread_state *gts, int force_unload);
+extern int gru_update_cch(struct gru_thread_state *gts);
 extern void gts_drop(struct gru_thread_state *gts);
 extern void gru_tgh_flush_init(struct gru_state *gru);
 extern int gru_kservices_init(void);
 extern void gru_kservices_exit(void);
+extern irqreturn_t gru0_intr(int irq, void *dev_id);
+extern irqreturn_t gru1_intr(int irq, void *dev_id);
+extern irqreturn_t gru_intr_mblade(int irq, void *dev_id);
 extern int gru_dump_chiplet_request(unsigned long arg);
 extern long gru_get_gseg_statistics(unsigned long arg);
-extern irqreturn_t gru_intr(int irq, void *dev_id);
 extern int gru_handle_user_call_os(unsigned long address);
 extern int gru_user_flush_tlb(unsigned long arg);
 extern int gru_user_unload_context(unsigned long arg);
 extern int gru_get_exception_detail(unsigned long arg);
 extern int gru_set_context_option(unsigned long address);
+extern void gru_check_context_placement(struct gru_thread_state *gts);
 extern int gru_cpu_fault_map_id(void);
 extern struct vm_area_struct *gru_find_vma(unsigned long vaddr);
 extern void gru_flush_all_tlb(struct gru_state *gru);
@@ -658,7 +666,8 @@ extern int gru_proc_init(void);
 extern void gru_proc_exit(void);
 
 extern struct gru_thread_state *gru_alloc_gts(struct vm_area_struct *vma,
-               int cbr_au_count, int dsr_au_count, int options, int tsid);
+               int cbr_au_count, int dsr_au_count,
+               unsigned char tlb_preload_count, int options, int tsid);
 extern unsigned long gru_reserve_cb_resources(struct gru_state *gru,
                int cbr_au_count, char *cbmap);
 extern unsigned long gru_reserve_ds_resources(struct gru_state *gru,
index 1d125091f5e721f773e0c10597b2d5a232f18a49..240a6d361665bdc97de3877fd842b9daa8f063a9 100644 (file)
@@ -184,8 +184,8 @@ void gru_flush_tlb_range(struct gru_mm_struct *gms, unsigned long start,
                        STAT(flush_tlb_gru_tgh);
                        asid = GRUASID(asid, start);
                        gru_dbg(grudev,
-       "  FLUSH gruid %d, asid 0x%x, num %ld, cbmap 0x%x\n",
-                               gid, asid, num, asids->mt_ctxbitmap);
+       "  FLUSH gruid %d, asid 0x%x, vaddr 0x%lx, vamask 0x%x, num %ld, cbmap 0x%x\n",
+                             gid, asid, start, grupagesize, num, asids->mt_ctxbitmap);
                        tgh = get_lock_tgh_handle(gru);
                        tgh_invalidate(tgh, start, ~0, asid, grupagesize, 0,
                                       num - 1, asids->mt_ctxbitmap);
@@ -299,6 +299,7 @@ struct gru_mm_struct *gru_register_mmu_notifier(void)
 {
        struct gru_mm_struct *gms;
        struct mmu_notifier *mn;
+       int err;
 
        mn = mmu_find_ops(current->mm, &gru_mmuops);
        if (mn) {
@@ -307,16 +308,22 @@ struct gru_mm_struct *gru_register_mmu_notifier(void)
        } else {
                gms = kzalloc(sizeof(*gms), GFP_KERNEL);
                if (gms) {
+                       STAT(gms_alloc);
                        spin_lock_init(&gms->ms_asid_lock);
                        gms->ms_notifier.ops = &gru_mmuops;
                        atomic_set(&gms->ms_refcnt, 1);
                        init_waitqueue_head(&gms->ms_wait_queue);
-                       __mmu_notifier_register(&gms->ms_notifier, current->mm);
+                       err = __mmu_notifier_register(&gms->ms_notifier, current->mm);
+                       if (err)
+                               goto error;
                }
        }
        gru_dbg(grudev, "gms %p, refcnt %d\n", gms,
                atomic_read(&gms->ms_refcnt));
        return gms;
+error:
+       kfree(gms);
+       return ERR_PTR(err);
 }
 
 void gru_drop_mmu_notifier(struct gru_mm_struct *gms)
@@ -327,6 +334,7 @@ void gru_drop_mmu_notifier(struct gru_mm_struct *gms)
                if (!gms->ms_released)
                        mmu_notifier_unregister(&gms->ms_notifier, current->mm);
                kfree(gms);
+               STAT(gms_free);
        }
 }
 
index 2275126cb3348f203903978265943edbbbaf846c..851b2f25ce0ee7120ca8b000807f87f1cef34853 100644 (file)
@@ -339,6 +339,7 @@ extern short xp_partition_id;
 extern u8 xp_region_size;
 
 extern unsigned long (*xp_pa) (void *);
+extern unsigned long (*xp_socket_pa) (unsigned long);
 extern enum xp_retval (*xp_remote_memcpy) (unsigned long, const unsigned long,
                       size_t);
 extern int (*xp_cpu_to_nasid) (int);
index 7896849b16dc1dbbb4ee432c033b7f2ee265954f..01be66d02ca8ce52c84b809fa55a7aeb6b219bc2 100644 (file)
@@ -44,6 +44,9 @@ EXPORT_SYMBOL_GPL(xp_region_size);
 unsigned long (*xp_pa) (void *addr);
 EXPORT_SYMBOL_GPL(xp_pa);
 
+unsigned long (*xp_socket_pa) (unsigned long gpa);
+EXPORT_SYMBOL_GPL(xp_socket_pa);
+
 enum xp_retval (*xp_remote_memcpy) (unsigned long dst_gpa,
                                    const unsigned long src_gpa, size_t len);
 EXPORT_SYMBOL_GPL(xp_remote_memcpy);
index fb3ec9d735a901fb7825c1d254f188d0334a2509..d8e463f8724144e48be51c5430fc327b309603e4 100644 (file)
@@ -83,6 +83,15 @@ xp_pa_sn2(void *addr)
        return __pa(addr);
 }
 
+/*
+ * Convert a global physical to a socket physical address.
+ */
+static unsigned long
+xp_socket_pa_sn2(unsigned long gpa)
+{
+       return gpa;
+}
+
 /*
  * Wrapper for bte_copy().
  *
@@ -162,6 +171,7 @@ xp_init_sn2(void)
        xp_region_size = sn_region_size;
 
        xp_pa = xp_pa_sn2;
+       xp_socket_pa = xp_socket_pa_sn2;
        xp_remote_memcpy = xp_remote_memcpy_sn2;
        xp_cpu_to_nasid = xp_cpu_to_nasid_sn2;
        xp_expand_memprotect = xp_expand_memprotect_sn2;
index d238576b26fa9b6c8f5d96b8f41760db444d43f1..a0d093274dc07a2bdf50c99d4d35c12490c77e01 100644 (file)
@@ -32,12 +32,44 @@ xp_pa_uv(void *addr)
        return uv_gpa(addr);
 }
 
+/*
+ * Convert a global physical to socket physical address.
+ */
+static unsigned long
+xp_socket_pa_uv(unsigned long gpa)
+{
+       return uv_gpa_to_soc_phys_ram(gpa);
+}
+
+static enum xp_retval
+xp_remote_mmr_read(unsigned long dst_gpa, const unsigned long src_gpa,
+                  size_t len)
+{
+       int ret;
+       unsigned long *dst_va = __va(uv_gpa_to_soc_phys_ram(dst_gpa));
+
+       BUG_ON(!uv_gpa_in_mmr_space(src_gpa));
+       BUG_ON(len != 8);
+
+       ret = gru_read_gpa(dst_va, src_gpa);
+       if (ret == 0)
+               return xpSuccess;
+
+       dev_err(xp, "gru_read_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx "
+               "len=%ld\n", dst_gpa, src_gpa, len);
+       return xpGruCopyError;
+}
+
+
 static enum xp_retval
 xp_remote_memcpy_uv(unsigned long dst_gpa, const unsigned long src_gpa,
                    size_t len)
 {
        int ret;
 
+       if (uv_gpa_in_mmr_space(src_gpa))
+               return xp_remote_mmr_read(dst_gpa, src_gpa, len);
+
        ret = gru_copy_gpa(dst_gpa, src_gpa, len);
        if (ret == 0)
                return xpSuccess;
@@ -123,6 +155,7 @@ xp_init_uv(void)
        xp_region_size = sn_region_size;
 
        xp_pa = xp_pa_uv;
+       xp_socket_pa = xp_socket_pa_uv;
        xp_remote_memcpy = xp_remote_memcpy_uv;
        xp_cpu_to_nasid = xp_cpu_to_nasid_uv;
        xp_expand_memprotect = xp_expand_memprotect_uv;
index 65877bc5edaae9e67dd391b665de91670556fd20..9a6268c89fddc0c49f65001941e13d045a5063a5 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/device.h>
 #include <linux/hardirq.h>
 #include "xpc.h"
+#include <asm/uv/uv_hub.h>
 
 /* XPC is exiting flag */
 int xpc_exiting;
@@ -92,8 +93,12 @@ xpc_get_rsvd_page_pa(int nasid)
                        break;
 
                /* !!! L1_CACHE_ALIGN() is only a sn2-bte_copy requirement */
-               if (L1_CACHE_ALIGN(len) > buf_len) {
-                       kfree(buf_base);
+               if (is_shub())
+                       len = L1_CACHE_ALIGN(len);
+
+               if (len > buf_len) {
+                       if (buf_base != NULL)
+                               kfree(buf_base);
                        buf_len = L1_CACHE_ALIGN(len);
                        buf = xpc_kmalloc_cacheline_aligned(buf_len, GFP_KERNEL,
                                                            &buf_base);
@@ -105,7 +110,7 @@ xpc_get_rsvd_page_pa(int nasid)
                        }
                }
 
-               ret = xp_remote_memcpy(xp_pa(buf), rp_pa, buf_len);
+               ret = xp_remote_memcpy(xp_pa(buf), rp_pa, len);
                if (ret != xpSuccess) {
                        dev_dbg(xpc_part, "xp_remote_memcpy failed %d\n", ret);
                        break;
@@ -143,7 +148,7 @@ xpc_setup_rsvd_page(void)
                dev_err(xpc_part, "SAL failed to locate the reserved page\n");
                return -ESRCH;
        }
-       rp = (struct xpc_rsvd_page *)__va(rp_pa);
+       rp = (struct xpc_rsvd_page *)__va(xp_socket_pa(rp_pa));
 
        if (rp->SAL_version < 3) {
                /* SAL_versions < 3 had a SAL_partid defined as a u8 */
index b5bbe59f9c5729c964f3749bf9e94883256da6d2..8725d5e8ab0c29bff2f6ab27fbacbc33891b48aa 100644 (file)
@@ -157,22 +157,24 @@ xpc_gru_mq_watchlist_alloc_uv(struct xpc_gru_mq_uv *mq)
 {
        int ret;
 
-#if defined CONFIG_X86_64
-       ret = uv_bios_mq_watchlist_alloc(mq->mmr_blade, uv_gpa(mq->address),
-                                        mq->order, &mq->mmr_offset);
-       if (ret < 0) {
-               dev_err(xpc_part, "uv_bios_mq_watchlist_alloc() failed, "
-                       "ret=%d\n", ret);
-               return ret;
-       }
-#elif defined CONFIG_IA64_GENERIC || defined CONFIG_IA64_SGI_UV
-       ret = sn_mq_watchlist_alloc(mq->mmr_blade, (void *)uv_gpa(mq->address),
+#if defined CONFIG_IA64_GENERIC || defined CONFIG_IA64_SGI_UV
+       int mmr_pnode = uv_blade_to_pnode(mq->mmr_blade);
+
+       ret = sn_mq_watchlist_alloc(mmr_pnode, (void *)uv_gpa(mq->address),
                                    mq->order, &mq->mmr_offset);
        if (ret < 0) {
                dev_err(xpc_part, "sn_mq_watchlist_alloc() failed, ret=%d\n",
                        ret);
                return -EBUSY;
        }
+#elif defined CONFIG_X86_64
+       ret = uv_bios_mq_watchlist_alloc(uv_gpa(mq->address),
+                                        mq->order, &mq->mmr_offset);
+       if (ret < 0) {
+               dev_err(xpc_part, "uv_bios_mq_watchlist_alloc() failed, "
+                       "ret=%d\n", ret);
+               return ret;
+       }
 #else
        #error not a supported configuration
 #endif
@@ -185,12 +187,13 @@ static void
 xpc_gru_mq_watchlist_free_uv(struct xpc_gru_mq_uv *mq)
 {
        int ret;
+       int mmr_pnode = uv_blade_to_pnode(mq->mmr_blade);
 
 #if defined CONFIG_X86_64
-       ret = uv_bios_mq_watchlist_free(mq->mmr_blade, mq->watchlist_num);
+       ret = uv_bios_mq_watchlist_free(mmr_pnode, mq->watchlist_num);
        BUG_ON(ret != BIOS_STATUS_SUCCESS);
 #elif defined CONFIG_IA64_GENERIC || defined CONFIG_IA64_SGI_UV
-       ret = sn_mq_watchlist_free(mq->mmr_blade, mq->watchlist_num);
+       ret = sn_mq_watchlist_free(mmr_pnode, mq->watchlist_num);
        BUG_ON(ret != SALRET_OK);
 #else
        #error not a supported configuration
@@ -204,6 +207,7 @@ xpc_create_gru_mq_uv(unsigned int mq_size, int cpu, char *irq_name,
        enum xp_retval xp_ret;
        int ret;
        int nid;
+       int nasid;
        int pg_order;
        struct page *page;
        struct xpc_gru_mq_uv *mq;
@@ -259,9 +263,11 @@ xpc_create_gru_mq_uv(unsigned int mq_size, int cpu, char *irq_name,
                goto out_5;
        }
 
+       nasid = UV_PNODE_TO_NASID(uv_cpu_to_pnode(cpu));
+
        mmr_value = (struct uv_IO_APIC_route_entry *)&mq->mmr_value;
        ret = gru_create_message_queue(mq->gru_mq_desc, mq->address, mq_size,
-                                      nid, mmr_value->vector, mmr_value->dest);
+                                    nasid, mmr_value->vector, mmr_value->dest);
        if (ret != 0) {
                dev_err(xpc_part, "gru_create_message_queue() returned "
                        "error=%d\n", ret);
@@ -946,11 +952,13 @@ xpc_get_fifo_entry_uv(struct xpc_fifo_head_uv *head)
                head->first = first->next;
                if (head->first == NULL)
                        head->last = NULL;
+
+               head->n_entries--;
+               BUG_ON(head->n_entries < 0);
+
+               first->next = NULL;
        }
-       head->n_entries--;
-       BUG_ON(head->n_entries < 0);
        spin_unlock_irqrestore(&head->lock, irq_flags);
-       first->next = NULL;
        return first;
 }
 
@@ -1019,7 +1027,8 @@ xpc_make_first_contact_uv(struct xpc_partition *part)
        xpc_send_activate_IRQ_part_uv(part, &msg, sizeof(msg),
                                      XPC_ACTIVATE_MQ_MSG_SYNC_ACT_STATE_UV);
 
-       while (part->sn.uv.remote_act_state != XPC_P_AS_ACTIVATING) {
+       while (!((part->sn.uv.remote_act_state == XPC_P_AS_ACTIVATING) ||
+                (part->sn.uv.remote_act_state == XPC_P_AS_ACTIVE))) {
 
                dev_dbg(xpc_part, "waiting to make first contact with "
                        "partition %d\n", XPC_PARTID(part));
@@ -1422,7 +1431,6 @@ xpc_handle_notify_mq_msg_uv(struct xpc_partition *part,
        msg_slot = ch_uv->recv_msg_slots +
            (msg->hdr.msg_slot_number % ch->remote_nentries) * ch->entry_size;
 
-       BUG_ON(msg->hdr.msg_slot_number != msg_slot->hdr.msg_slot_number);
        BUG_ON(msg_slot->hdr.size != 0);
 
        memcpy(msg_slot, msg, msg->hdr.size);
@@ -1646,8 +1654,6 @@ xpc_received_payload_uv(struct xpc_channel *ch, void *payload)
                               sizeof(struct xpc_notify_mq_msghdr_uv));
        if (ret != xpSuccess)
                XPC_DEACTIVATE_PARTITION(&xpc_partitions[ch->partid], ret);
-
-       msg->hdr.msg_slot_number += ch->remote_nentries;
 }
 
 static struct xpc_arch_operations xpc_arch_ops_uv = {
diff --git a/drivers/misc/ti_dac7512.c b/drivers/misc/ti_dac7512.c
new file mode 100644 (file)
index 0000000..d3f229a
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ *  dac7512.c - Linux kernel module for
+ *     Texas Instruments DAC7512
+ *
+ *  Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/spi/spi.h>
+
+#define DAC7512_DRV_NAME       "dac7512"
+#define DRIVER_VERSION         "1.0"
+
+static ssize_t dac7512_store_val(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf, size_t count)
+{
+       struct spi_device *spi = to_spi_device(dev);
+       unsigned char tmp[2];
+       unsigned long val;
+
+       if (strict_strtoul(buf, 10, &val) < 0)
+               return -EINVAL;
+
+       tmp[0] = val >> 8;
+       tmp[1] = val & 0xff;
+       spi_write(spi, tmp, sizeof(tmp));
+       return count;
+}
+
+static DEVICE_ATTR(value, S_IWUSR, NULL, dac7512_store_val);
+
+static struct attribute *dac7512_attributes[] = {
+       &dev_attr_value.attr,
+       NULL
+};
+
+static const struct attribute_group dac7512_attr_group = {
+       .attrs = dac7512_attributes,
+};
+
+static int __devinit dac7512_probe(struct spi_device *spi)
+{
+       int ret;
+
+       spi->bits_per_word = 8;
+       spi->mode = SPI_MODE_0;
+       ret = spi_setup(spi);
+       if (ret < 0)
+               return ret;
+
+       return sysfs_create_group(&spi->dev.kobj, &dac7512_attr_group);
+}
+
+static int __devexit dac7512_remove(struct spi_device *spi)
+{
+       sysfs_remove_group(&spi->dev.kobj, &dac7512_attr_group);
+       return 0;
+}
+
+static struct spi_driver dac7512_driver = {
+       .driver = {
+               .name   = DAC7512_DRV_NAME,
+               .owner  = THIS_MODULE,
+       },
+       .probe  = dac7512_probe,
+       .remove = __devexit_p(dac7512_remove),
+};
+
+static int __init dac7512_init(void)
+{
+       return spi_register_driver(&dac7512_driver);
+}
+
+static void __exit dac7512_exit(void)
+{
+       spi_unregister_driver(&dac7512_driver);
+}
+
+MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
+MODULE_DESCRIPTION("DAC7512 16-bit DAC");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(DRIVER_VERSION);
+
+module_init(dac7512_init);
+module_exit(dac7512_exit);
index ab37a6d9d32a046d7318b3a89a6358c8456b5ef9..bb22ffd76ef8a2bfba0bbdc29d73faabc51911bc 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 config MMC_UNSAFE_RESUME
-       bool "Allow unsafe resume (DANGEROUS)"
+       bool "Assume MMC/SD cards are non-removable (DANGEROUS)"
        help
          If you say Y here, the MMC layer will assume that all cards
          stayed in their respective slots during the suspend. The
@@ -14,3 +14,5 @@ config MMC_UNSAFE_RESUME
          This option is usually just for embedded systems which use
          a MMC/SD card for rootfs. Most people should say N here.
 
+         This option sets a default which can be overridden by the
+         module parameter "removable=0" or "removable=1".
index 7dab2e5f4bc9c87c53779a3d49cf2cb368114ef7..30acd526582162033ec3d35d4f770bfa876a41fd 100644 (file)
@@ -47,6 +47,22 @@ static struct workqueue_struct *workqueue;
 int use_spi_crc = 1;
 module_param(use_spi_crc, bool, 0);
 
+/*
+ * We normally treat cards as removed during suspend if they are not
+ * known to be on a non-removable bus, to avoid the risk of writing
+ * back data to a different card after resume.  Allow this to be
+ * overridden if necessary.
+ */
+#ifdef CONFIG_MMC_UNSAFE_RESUME
+int mmc_assume_removable;
+#else
+int mmc_assume_removable = 1;
+#endif
+module_param_named(removable, mmc_assume_removable, bool, 0644);
+MODULE_PARM_DESC(
+       removable,
+       "MMC/SD cards are removable and may be removed during suspend");
+
 /*
  * Internal function. Schedule delayed work in the MMC work queue.
  */
index 67ae6abc4230928242109df7f5ab2c773f2971a3..a811c52a165957219bc55e03f7fbe1faab43379f 100644 (file)
@@ -54,7 +54,9 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr);
 int mmc_attach_sd(struct mmc_host *host, u32 ocr);
 int mmc_attach_sdio(struct mmc_host *host, u32 ocr);
 
+/* Module parameters */
 extern int use_spi_crc;
+extern int mmc_assume_removable;
 
 /* Debugfs information for hosts and cards */
 void mmc_add_host_debugfs(struct mmc_host *host);
index bfefce365ae788ea93d73382298c915fba72288e..c11189446a1f70cd93bcf778e89a41ca06eeac52 100644 (file)
@@ -602,25 +602,6 @@ static int mmc_awake(struct mmc_host *host)
        return err;
 }
 
-#ifdef CONFIG_MMC_UNSAFE_RESUME
-
-static const struct mmc_bus_ops mmc_ops = {
-       .awake = mmc_awake,
-       .sleep = mmc_sleep,
-       .remove = mmc_remove,
-       .detect = mmc_detect,
-       .suspend = mmc_suspend,
-       .resume = mmc_resume,
-       .power_restore = mmc_power_restore,
-};
-
-static void mmc_attach_bus_ops(struct mmc_host *host)
-{
-       mmc_attach_bus(host, &mmc_ops);
-}
-
-#else
-
 static const struct mmc_bus_ops mmc_ops = {
        .awake = mmc_awake,
        .sleep = mmc_sleep,
@@ -645,15 +626,13 @@ static void mmc_attach_bus_ops(struct mmc_host *host)
 {
        const struct mmc_bus_ops *bus_ops;
 
-       if (host->caps & MMC_CAP_NONREMOVABLE)
+       if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
                bus_ops = &mmc_ops_unsafe;
        else
                bus_ops = &mmc_ops;
        mmc_attach_bus(host, bus_ops);
 }
 
-#endif
-
 /*
  * Starting point for MMC card init.
  */
index 10b2a4d20f5a1a6b270592d6b048514126bda96a..fdd414eded09a9eef14968a59d026e369c046aa5 100644 (file)
@@ -606,23 +606,6 @@ static void mmc_sd_power_restore(struct mmc_host *host)
        mmc_release_host(host);
 }
 
-#ifdef CONFIG_MMC_UNSAFE_RESUME
-
-static const struct mmc_bus_ops mmc_sd_ops = {
-       .remove = mmc_sd_remove,
-       .detect = mmc_sd_detect,
-       .suspend = mmc_sd_suspend,
-       .resume = mmc_sd_resume,
-       .power_restore = mmc_sd_power_restore,
-};
-
-static void mmc_sd_attach_bus_ops(struct mmc_host *host)
-{
-       mmc_attach_bus(host, &mmc_sd_ops);
-}
-
-#else
-
 static const struct mmc_bus_ops mmc_sd_ops = {
        .remove = mmc_sd_remove,
        .detect = mmc_sd_detect,
@@ -643,15 +626,13 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host)
 {
        const struct mmc_bus_ops *bus_ops;
 
-       if (host->caps & MMC_CAP_NONREMOVABLE)
+       if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
                bus_ops = &mmc_sd_ops_unsafe;
        else
                bus_ops = &mmc_sd_ops;
        mmc_attach_bus(host, bus_ops);
 }
 
-#endif
-
 /*
  * Starting point for SD card init.
  */
index cdb845b68ab5e37222048b47769014fa32186b8a..06b64085a355b3aed5198548b406ddcc79174a48 100644 (file)
@@ -516,7 +516,8 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr)
         * The number of functions on the card is encoded inside
         * the ocr.
         */
-       card->sdio_funcs = funcs = (ocr & 0x70000000) >> 28;
+       funcs = (ocr & 0x70000000) >> 28;
+       card->sdio_funcs = 0;
 
        /*
         * If needed, disconnect card detection pull-up resistor.
@@ -528,7 +529,7 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr)
        /*
         * Initialize (but don't add) all present functions.
         */
-       for (i = 0;i < funcs;i++) {
+       for (i = 0; i < funcs; i++, card->sdio_funcs++) {
                err = sdio_init_func(host->card, i + 1);
                if (err)
                        goto remove;
index d37464e296a507deb743182c3764714f83cdda9c..9e060c87e64db6775fc5aa7b8aa07033dae7e365 100644 (file)
@@ -248,12 +248,15 @@ int sdio_add_func(struct sdio_func *func)
 /*
  * Unregister a SDIO function with the driver model, and
  * (eventually) free it.
+ * This function can be called through error paths where sdio_add_func() was
+ * never executed (because a failure occurred at an earlier point).
  */
 void sdio_remove_func(struct sdio_func *func)
 {
-       if (sdio_func_present(func))
-               device_del(&func->dev);
+       if (!sdio_func_present(func))
+               return;
 
+       device_del(&func->dev);
        put_device(&func->dev);
 }
 
index f85dcd5365082ab27cc77adefcb84f1364892f80..9538389783c10e17d4494e875499c302b93ed01b 100644 (file)
@@ -97,26 +97,56 @@ static const unsigned char speed_val[16] =
 static const unsigned int speed_unit[8] =
        { 10000, 100000, 1000000, 10000000, 0, 0, 0, 0 };
 
-/* FUNCE tuples with these types get passed to SDIO drivers */
-static const unsigned char funce_type_whitelist[] = {
-       4 /* CISTPL_FUNCE_LAN_NODE_ID used in Broadcom cards */
+
+typedef int (tpl_parse_t)(struct mmc_card *, struct sdio_func *,
+                          const unsigned char *, unsigned);
+
+struct cis_tpl {
+       unsigned char code;
+       unsigned char min_size;
+       tpl_parse_t *parse;
 };
 
-static int cistpl_funce_whitelisted(unsigned char type)
+static int cis_tpl_parse(struct mmc_card *card, struct sdio_func *func,
+                        const char *tpl_descr,
+                        const struct cis_tpl *tpl, int tpl_count,
+                        unsigned char code,
+                        const unsigned char *buf, unsigned size)
 {
-       int i;
+       int i, ret;
 
-       for (i = 0; i < ARRAY_SIZE(funce_type_whitelist); i++) {
-               if (funce_type_whitelist[i] == type)
-                       return 1;
+       /* look for a matching code in the table */
+       for (i = 0; i < tpl_count; i++, tpl++) {
+               if (tpl->code == code)
+                       break;
        }
-       return 0;
+       if (i < tpl_count) {
+               if (size >= tpl->min_size) {
+                       if (tpl->parse)
+                               ret = tpl->parse(card, func, buf, size);
+                       else
+                               ret = -EILSEQ;  /* known tuple, not parsed */
+               } else {
+                       /* invalid tuple */
+                       ret = -EINVAL;
+               }
+               if (ret && ret != -EILSEQ && ret != -ENOENT) {
+                       printk(KERN_ERR "%s: bad %s tuple 0x%02x (%u bytes)\n",
+                              mmc_hostname(card->host), tpl_descr, code, size);
+               }
+       } else {
+               /* unknown tuple */
+               ret = -ENOENT;
+       }
+
+       return ret;
 }
 
-static int cistpl_funce_common(struct mmc_card *card,
+static int cistpl_funce_common(struct mmc_card *card, struct sdio_func *func,
                               const unsigned char *buf, unsigned size)
 {
-       if (size < 0x04 || buf[0] != 0)
+       /* Only valid for the common CIS (function 0) */
+       if (func)
                return -EINVAL;
 
        /* TPLFE_FN0_BLK_SIZE */
@@ -129,20 +159,24 @@ static int cistpl_funce_common(struct mmc_card *card,
        return 0;
 }
 
-static int cistpl_funce_func(struct sdio_func *func,
+static int cistpl_funce_func(struct mmc_card *card, struct sdio_func *func,
                             const unsigned char *buf, unsigned size)
 {
        unsigned vsn;
        unsigned min_size;
 
-       /* let SDIO drivers take care of whitelisted FUNCE tuples */
-       if (cistpl_funce_whitelisted(buf[0]))
-               return -EILSEQ;
+       /* Only valid for the individual function's CIS (1-7) */
+       if (!func)
+               return -EINVAL;
 
+       /*
+        * This tuple has a different length depending on the SDIO spec
+        * version.
+        */
        vsn = func->card->cccr.sdio_vsn;
        min_size = (vsn == SDIO_SDIO_REV_1_00) ? 28 : 42;
 
-       if (size < min_size || buf[0] != 1)
+       if (size < min_size)
                return -EINVAL;
 
        /* TPLFE_MAX_BLK_SIZE */
@@ -157,39 +191,32 @@ static int cistpl_funce_func(struct sdio_func *func,
        return 0;
 }
 
+/*
+ * Known TPLFE_TYPEs table for CISTPL_FUNCE tuples.
+ *
+ * Note that, unlike PCMCIA, CISTPL_FUNCE tuples are not parsed depending
+ * on the TPLFID_FUNCTION value of the previous CISTPL_FUNCID as on SDIO
+ * TPLFID_FUNCTION is always hardcoded to 0x0C.
+ */
+static const struct cis_tpl cis_tpl_funce_list[] = {
+       {       0x00,   4,      cistpl_funce_common             },
+       {       0x01,   0,      cistpl_funce_func               },
+       {       0x04,   1+1+6,  /* CISTPL_FUNCE_LAN_NODE_ID */  },
+};
+
 static int cistpl_funce(struct mmc_card *card, struct sdio_func *func,
                        const unsigned char *buf, unsigned size)
 {
-       int ret;
-
-       /*
-        * There should be two versions of the CISTPL_FUNCE tuple,
-        * one for the common CIS (function 0) and a version used by
-        * the individual function's CIS (1-7). Yet, the later has a
-        * different length depending on the SDIO spec version.
-        */
-       if (func)
-               ret = cistpl_funce_func(func, buf, size);
-       else
-               ret = cistpl_funce_common(card, buf, size);
-
-       if (ret && ret != -EILSEQ) {
-               printk(KERN_ERR "%s: bad CISTPL_FUNCE size %u "
-                      "type %u\n", mmc_hostname(card->host), size, buf[0]);
-       }
+       if (size < 1)
+               return -EINVAL;
 
-       return ret;
+       return cis_tpl_parse(card, func, "CISTPL_FUNCE",
+                            cis_tpl_funce_list,
+                            ARRAY_SIZE(cis_tpl_funce_list),
+                            buf[0], buf, size);
 }
 
-typedef int (tpl_parse_t)(struct mmc_card *, struct sdio_func *,
-                          const unsigned char *, unsigned);
-
-struct cis_tpl {
-       unsigned char code;
-       unsigned char min_size;
-       tpl_parse_t *parse;
-};
-
+/* Known TPL_CODEs table for CIS tuples */
 static const struct cis_tpl cis_tpl_list[] = {
        {       0x15,   3,      cistpl_vers_1           },
        {       0x20,   4,      cistpl_manfid           },
@@ -268,46 +295,38 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
                        break;
                }
 
-               for (i = 0; i < ARRAY_SIZE(cis_tpl_list); i++)
-                       if (cis_tpl_list[i].code == tpl_code)
-                               break;
-               if (i < ARRAY_SIZE(cis_tpl_list)) {
-                       const struct cis_tpl *tpl = cis_tpl_list + i;
-                       if (tpl_link < tpl->min_size) {
-                               printk(KERN_ERR
-                                      "%s: bad CIS tuple 0x%02x"
-                                      " (length = %u, expected >= %u)\n",
-                                      mmc_hostname(card->host),
-                                      tpl_code, tpl_link, tpl->min_size);
-                               ret = -EINVAL;
-                       } else if (tpl->parse) {
-                               ret = tpl->parse(card, func,
-                                                this->data, tpl_link);
-                       }
+               /* Try to parse the CIS tuple */
+               ret = cis_tpl_parse(card, func, "CIS",
+                                   cis_tpl_list, ARRAY_SIZE(cis_tpl_list),
+                                   tpl_code, this->data, tpl_link);
+               if (ret == -EILSEQ || ret == -ENOENT) {
                        /*
-                        * We don't need the tuple anymore if it was
-                        * successfully parsed by the SDIO core or if it is
-                        * not going to be parsed by SDIO drivers.
+                        * The tuple is unknown or known but not parsed.
+                        * Queue the tuple for the function driver.
                         */
-                       if (!ret || ret != -EILSEQ)
-                               kfree(this);
-               } else {
-                       /* unknown tuple */
-                       ret = -EILSEQ;
-               }
-
-               if (ret == -EILSEQ) {
-                       /* this tuple is unknown to the core or whitelisted */
                        this->next = NULL;
                        this->code = tpl_code;
                        this->size = tpl_link;
                        *prev = this;
                        prev = &this->next;
-                       printk(KERN_DEBUG
-                              "%s: queuing CIS tuple 0x%02x length %u\n",
-                              mmc_hostname(card->host), tpl_code, tpl_link);
+
+                       if (ret == -ENOENT) {
+                               /* warn about unknown tuples */
+                               printk(KERN_WARNING "%s: queuing unknown"
+                                      " CIS tuple 0x%02x (%u bytes)\n",
+                                      mmc_hostname(card->host),
+                                      tpl_code, tpl_link);
+                       }
+
                        /* keep on analyzing tuples */
                        ret = 0;
+               } else {
+                       /*
+                        * We don't need the tuple anymore if it was
+                        * successfully parsed by the SDIO core or if it is
+                        * not going to be queued for a driver.
+                        */
+                       kfree(this);
                }
 
                ptr += tpl_link;
index e04b751680d0a763fe980b174bb62fae4917043a..ce1d28884e2987a059f9cba3ead143d041fc9a57 100644 (file)
@@ -44,6 +44,19 @@ config MMC_SDHCI_IO_ACCESSORS
          This is silent Kconfig symbol that is selected by the drivers that
          need to overwrite SDHCI IO memory accessors.
 
+config MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
+       bool
+       select MMC_SDHCI_IO_ACCESSORS
+       help
+         This option is selected by drivers running on big endian hosts
+         and performing I/O to a SDHCI controller through a bus that
+         implements a hardware byte swapper using a 32-bit datum.
+         This endian mapping mode is called "data invariance" and
+         has the effect of scrambling the addresses and formats of data
+         accessed in sizes other than the datum size.
+
+         This is the case for the Freescale eSDHC and Nintendo Wii SDHCI.
+
 config MMC_SDHCI_PCI
        tristate "SDHCI support on PCI bus"
        depends on MMC_SDHCI && PCI
@@ -75,11 +88,29 @@ config MMC_RICOH_MMC
 config MMC_SDHCI_OF
        tristate "SDHCI support on OpenFirmware platforms"
        depends on MMC_SDHCI && PPC_OF
-       select MMC_SDHCI_IO_ACCESSORS
        help
          This selects the OF support for Secure Digital Host Controller
-         Interfaces. So far, only the Freescale eSDHC controller is known
-         to exist on OF platforms.
+         Interfaces.
+
+         If unsure, say N.
+
+config MMC_SDHCI_OF_ESDHC
+       bool "SDHCI OF support for the Freescale eSDHC controller"
+       depends on MMC_SDHCI_OF
+       select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
+       help
+         This selects the Freescale eSDHC controller support.
+
+         If unsure, say N.
+
+config MMC_SDHCI_OF_HLWD
+       bool "SDHCI OF support for the Nintendo Wii SDHCI controllers"
+       depends on MMC_SDHCI_OF
+       select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
+       help
+         This selects the Secure Digital Host Controller Interface (SDHCI)
+         found in the "Hollywood" chipset of the Nintendo Wii video game
+         console.
 
          If unsure, say N.
 
@@ -251,6 +282,14 @@ config MMC_MVSDIO
          To compile this driver as a module, choose M here: the
          module will be called mvsdio.
 
+config MMC_DAVINCI
+        tristate "TI DAVINCI Multimedia Card Interface support"
+        depends on ARCH_DAVINCI
+        help
+          This selects the TI DAVINCI Multimedia card Interface.
+          If you have an DAVINCI board with a Multimedia Card slot,
+          say Y or M here.  If unsure, say N.
+
 config MMC_SPI
        tristate "MMC/SD/SDIO over SPI"
        depends on SPI_MASTER && !HIGHMEM && HAS_DMA
@@ -357,3 +396,22 @@ config MMC_VIA_SDMMC
          If you have a controller with this interface, say Y or M here.
 
          If unsure, say N.
+
+config SDH_BFIN
+       tristate "Blackfin Secure Digital Host support"
+       depends on MMC && ((BF54x && !BF544) || (BF51x && !BF512))
+       help
+         If you say yes here you will get support for the Blackfin on-chip
+         Secure Digital Host interface.  This includes support for MMC and
+         SD cards.
+
+         To compile this driver as a module, choose M here: the
+         module will be called bfin_sdh.
+
+         If unsure, say N.
+
+config SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND
+       bool "Blackfin EZkit Missing SDH_CMD Pull Up Resistor Workaround"
+       depends on SDH_BFIN
+       help
+         If you say yes here SD-Cards may work on the EZkit.
index abcb0400e06d23236b1d1b6cfde623a1bb706abf..3d253dd4240fee2c7d8fbb42f631563af370fb36 100644 (file)
@@ -13,7 +13,6 @@ obj-$(CONFIG_MMC_MXC)         += mxcmmc.o
 obj-$(CONFIG_MMC_SDHCI)                += sdhci.o
 obj-$(CONFIG_MMC_SDHCI_PCI)    += sdhci-pci.o
 obj-$(CONFIG_MMC_RICOH_MMC)    += ricoh_mmc.o
-obj-$(CONFIG_MMC_SDHCI_OF)     += sdhci-of.o
 obj-$(CONFIG_MMC_SDHCI_PLTFM)  += sdhci-pltfm.o
 obj-$(CONFIG_MMC_SDHCI_S3C)    += sdhci-s3c.o
 obj-$(CONFIG_MMC_WBSD)         += wbsd.o
@@ -25,6 +24,7 @@ obj-$(CONFIG_MMC_ATMELMCI)    += atmel-mci.o
 obj-$(CONFIG_MMC_TIFM_SD)      += tifm_sd.o
 obj-$(CONFIG_MMC_MSM7X00A)     += msm_sdcc.o
 obj-$(CONFIG_MMC_MVSDIO)       += mvsdio.o
+obj-$(CONFIG_MMC_DAVINCI)       += davinci_mmc.o
 obj-$(CONFIG_MMC_SPI)          += mmc_spi.o
 ifeq ($(CONFIG_OF),y)
 obj-$(CONFIG_MMC_SPI)          += of_mmc_spi.o
@@ -34,6 +34,12 @@ obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o
 obj-$(CONFIG_MMC_TMIO)         += tmio_mmc.o
 obj-$(CONFIG_MMC_CB710)        += cb710-mmc.o
 obj-$(CONFIG_MMC_VIA_SDMMC)    += via-sdmmc.o
+obj-$(CONFIG_SDH_BFIN)         += bfin_sdh.o
+
+obj-$(CONFIG_MMC_SDHCI_OF)     += sdhci-of.o
+sdhci-of-y                             := sdhci-of-core.o
+sdhci-of-$(CONFIG_MMC_SDHCI_OF_ESDHC)  += sdhci-of-esdhc.o
+sdhci-of-$(CONFIG_MMC_SDHCI_OF_HLWD)   += sdhci-of-hlwd.o
 
 ifeq ($(CONFIG_CB710_DEBUG),y)
        CFLAGS-cb710-mmc        += -DDEBUG
index fc25586b7ee1c94575e5674f89c3382c2a7ffd88..8072128e933b80a8ff6f68f2ed160a964ed04bc2 100644 (file)
@@ -25,6 +25,8 @@
 #include <linux/stat.h>
 
 #include <linux/mmc/host.h>
+
+#include <mach/atmel-mci.h>
 #include <linux/atmel-mci.h>
 
 #include <asm/io.h>
@@ -92,6 +94,7 @@ struct atmel_mci_dma {
  * @need_clock_update: Update the clock rate before the next request.
  * @need_reset: Reset controller before next request.
  * @mode_reg: Value of the MR register.
+ * @cfg_reg: Value of the CFG register.
  * @bus_hz: The rate of @mck in Hz. This forms the basis for MMC bus
  *     rate and timeout calculations.
  * @mapbase: Physical address of the MMIO registers.
@@ -155,6 +158,7 @@ struct atmel_mci {
        bool                    need_clock_update;
        bool                    need_reset;
        u32                     mode_reg;
+       u32                     cfg_reg;
        unsigned long           bus_hz;
        unsigned long           mapbase;
        struct clk              *mck;
@@ -222,6 +226,19 @@ static bool mci_has_rwproof(void)
                return true;
 }
 
+/*
+ * The new MCI2 module isn't 100% compatible with the old MCI module,
+ * and it has a few nice features which we want to use...
+ */
+static inline bool atmci_is_mci2(void)
+{
+       if (cpu_is_at91sam9g45())
+               return true;
+
+       return false;
+}
+
+
 /*
  * The debugfs stuff below is mostly optimized away when
  * CONFIG_DEBUG_FS is not set.
@@ -357,12 +374,33 @@ static int atmci_regs_show(struct seq_file *s, void *v)
                        buf[MCI_BLKR / 4],
                        buf[MCI_BLKR / 4] & 0xffff,
                        (buf[MCI_BLKR / 4] >> 16) & 0xffff);
+       if (atmci_is_mci2())
+               seq_printf(s, "CSTOR:\t0x%08x\n", buf[MCI_CSTOR / 4]);
 
        /* Don't read RSPR and RDR; it will consume the data there */
 
        atmci_show_status_reg(s, "SR", buf[MCI_SR / 4]);
        atmci_show_status_reg(s, "IMR", buf[MCI_IMR / 4]);
 
+       if (atmci_is_mci2()) {
+               u32 val;
+
+               val = buf[MCI_DMA / 4];
+               seq_printf(s, "DMA:\t0x%08x OFFSET=%u CHKSIZE=%u%s\n",
+                               val, val & 3,
+                               ((val >> 4) & 3) ?
+                                       1 << (((val >> 4) & 3) + 1) : 1,
+                               val & MCI_DMAEN ? " DMAEN" : "");
+
+               val = buf[MCI_CFG / 4];
+               seq_printf(s, "CFG:\t0x%08x%s%s%s%s\n",
+                               val,
+                               val & MCI_CFG_FIFOMODE_1DATA ? " FIFOMODE_ONE_DATA" : "",
+                               val & MCI_CFG_FERRCTRL_COR ? " FERRCTRL_CLEAR_ON_READ" : "",
+                               val & MCI_CFG_HSMODE ? " HSMODE" : "",
+                               val & MCI_CFG_LSYNC ? " LSYNC" : "");
+       }
+
        kfree(buf);
 
        return 0;
@@ -557,6 +595,10 @@ static void atmci_dma_complete(void *arg)
 
        dev_vdbg(&host->pdev->dev, "DMA complete\n");
 
+       if (atmci_is_mci2())
+               /* Disable DMA hardware handshaking on MCI */
+               mci_writel(host, DMA, mci_readl(host, DMA) & ~MCI_DMAEN);
+
        atmci_dma_cleanup(host);
 
        /*
@@ -592,7 +634,7 @@ static void atmci_dma_complete(void *arg)
 }
 
 static int
-atmci_submit_data_dma(struct atmel_mci *host, struct mmc_data *data)
+atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
 {
        struct dma_chan                 *chan;
        struct dma_async_tx_descriptor  *desc;
@@ -624,6 +666,9 @@ atmci_submit_data_dma(struct atmel_mci *host, struct mmc_data *data)
        if (!chan)
                return -ENODEV;
 
+       if (atmci_is_mci2())
+               mci_writel(host, DMA, MCI_DMA_CHKSIZE(3) | MCI_DMAEN);
+
        if (data->flags & MMC_DATA_READ)
                direction = DMA_FROM_DEVICE;
        else
@@ -641,10 +686,6 @@ atmci_submit_data_dma(struct atmel_mci *host, struct mmc_data *data)
        host->dma.data_desc = desc;
        desc->callback = atmci_dma_complete;
        desc->callback_param = host;
-       desc->tx_submit(desc);
-
-       /* Go! */
-       chan->device->device_issue_pending(chan);
 
        return 0;
 unmap_exit:
@@ -652,13 +693,26 @@ unmap_exit:
        return -ENOMEM;
 }
 
+static void atmci_submit_data(struct atmel_mci *host)
+{
+       struct dma_chan                 *chan = host->data_chan;
+       struct dma_async_tx_descriptor  *desc = host->dma.data_desc;
+
+       if (chan) {
+               desc->tx_submit(desc);
+               chan->device->device_issue_pending(chan);
+       }
+}
+
 #else /* CONFIG_MMC_ATMELMCI_DMA */
 
-static int atmci_submit_data_dma(struct atmel_mci *host, struct mmc_data *data)
+static int atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
 {
        return -ENOSYS;
 }
 
+static void atmci_submit_data(struct atmel_mci *host) {}
+
 static void atmci_stop_dma(struct atmel_mci *host)
 {
        /* Data transfer was stopped by the interrupt handler */
@@ -672,7 +726,7 @@ static void atmci_stop_dma(struct atmel_mci *host)
  * Returns a mask of interrupt flags to be enabled after the whole
  * request has been prepared.
  */
-static u32 atmci_submit_data(struct atmel_mci *host, struct mmc_data *data)
+static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data)
 {
        u32 iflags;
 
@@ -683,7 +737,7 @@ static u32 atmci_submit_data(struct atmel_mci *host, struct mmc_data *data)
        host->data = data;
 
        iflags = ATMCI_DATA_ERROR_FLAGS;
-       if (atmci_submit_data_dma(host, data)) {
+       if (atmci_prepare_data_dma(host, data)) {
                host->data_chan = NULL;
 
                /*
@@ -729,6 +783,8 @@ static void atmci_start_request(struct atmel_mci *host,
                mci_writel(host, CR, MCI_CR_SWRST);
                mci_writel(host, CR, MCI_CR_MCIEN);
                mci_writel(host, MR, host->mode_reg);
+               if (atmci_is_mci2())
+                       mci_writel(host, CFG, host->cfg_reg);
                host->need_reset = false;
        }
        mci_writel(host, SDCR, slot->sdc_reg);
@@ -744,6 +800,7 @@ static void atmci_start_request(struct atmel_mci *host,
                while (!(mci_readl(host, SR) & MCI_CMDRDY))
                        cpu_relax();
        }
+       iflags = 0;
        data = mrq->data;
        if (data) {
                atmci_set_timeout(host, slot, data);
@@ -753,15 +810,17 @@ static void atmci_start_request(struct atmel_mci *host,
                                | MCI_BLKLEN(data->blksz));
                dev_vdbg(&slot->mmc->class_dev, "BLKR=0x%08x\n",
                        MCI_BCNT(data->blocks) | MCI_BLKLEN(data->blksz));
+
+               iflags |= atmci_prepare_data(host, data);
        }
 
-       iflags = MCI_CMDRDY;
+       iflags |= MCI_CMDRDY;
        cmd = mrq->cmd;
        cmdflags = atmci_prepare_command(slot->mmc, cmd);
        atmci_start_command(host, cmd, cmdflags);
 
        if (data)
-               iflags |= atmci_submit_data(host, data);
+               atmci_submit_data(host);
 
        if (mrq->stop) {
                host->stop_cmdr = atmci_prepare_command(slot->mmc, mrq->stop);
@@ -857,6 +916,8 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                        clk_enable(host->mck);
                        mci_writel(host, CR, MCI_CR_SWRST);
                        mci_writel(host, CR, MCI_CR_MCIEN);
+                       if (atmci_is_mci2())
+                               mci_writel(host, CFG, host->cfg_reg);
                }
 
                /*
@@ -1095,6 +1156,8 @@ static void atmci_detect_change(unsigned long data)
                                mci_writel(host, CR, MCI_CR_SWRST);
                                mci_writel(host, CR, MCI_CR_MCIEN);
                                mci_writel(host, MR, host->mode_reg);
+                               if (atmci_is_mci2())
+                                       mci_writel(host, CFG, host->cfg_reg);
 
                                host->data = NULL;
                                host->cmd = NULL;
@@ -1584,14 +1647,47 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
 #ifdef CONFIG_MMC_ATMELMCI_DMA
 static bool filter(struct dma_chan *chan, void *slave)
 {
-       struct dw_dma_slave *dws = slave;
+       struct mci_dma_data     *sl = slave;
 
-       if (dws->dma_dev == chan->device->dev) {
-               chan->private = dws;
+       if (sl && find_slave_dev(sl) == chan->device->dev) {
+               chan->private = slave_data_ptr(sl);
                return true;
-       } else
+       } else {
                return false;
+       }
 }
+
+static void atmci_configure_dma(struct atmel_mci *host)
+{
+       struct mci_platform_data        *pdata;
+
+       if (host == NULL)
+               return;
+
+       pdata = host->pdev->dev.platform_data;
+
+       if (pdata && find_slave_dev(pdata->dma_slave)) {
+               dma_cap_mask_t mask;
+
+               setup_dma_addr(pdata->dma_slave,
+                              host->mapbase + MCI_TDR,
+                              host->mapbase + MCI_RDR);
+
+               /* Try to grab a DMA channel */
+               dma_cap_zero(mask);
+               dma_cap_set(DMA_SLAVE, mask);
+               host->dma.chan =
+                       dma_request_channel(mask, filter, pdata->dma_slave);
+       }
+       if (!host->dma.chan)
+               dev_notice(&host->pdev->dev, "DMA not available, using PIO\n");
+       else
+               dev_info(&host->pdev->dev,
+                                       "Using %s for DMA transfers\n",
+                                       dma_chan_name(host->dma.chan));
+}
+#else
+static void atmci_configure_dma(struct atmel_mci *host) {}
 #endif
 
 static int __init atmci_probe(struct platform_device *pdev)
@@ -1645,22 +1741,7 @@ static int __init atmci_probe(struct platform_device *pdev)
        if (ret)
                goto err_request_irq;
 
-#ifdef CONFIG_MMC_ATMELMCI_DMA
-       if (pdata->dma_slave.dma_dev) {
-               struct dw_dma_slave *dws = &pdata->dma_slave;
-               dma_cap_mask_t mask;
-
-               dws->tx_reg = regs->start + MCI_TDR;
-               dws->rx_reg = regs->start + MCI_RDR;
-
-               /* Try to grab a DMA channel */
-               dma_cap_zero(mask);
-               dma_cap_set(DMA_SLAVE, mask);
-               host->dma.chan = dma_request_channel(mask, filter, dws);
-       }
-       if (!host->dma.chan)
-               dev_notice(&pdev->dev, "DMA not available, using PIO\n");
-#endif /* CONFIG_MMC_ATMELMCI_DMA */
+       atmci_configure_dma(host);
 
        platform_set_drvdata(pdev, host);
 
diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c
new file mode 100644 (file)
index 0000000..3343a57
--- /dev/null
@@ -0,0 +1,639 @@
+/*
+ * bfin_sdh.c - Analog Devices Blackfin SDH Controller
+ *
+ * Copyright (C) 2007-2009 Analog Device Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#define DRIVER_NAME    "bfin-sdh"
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/dma-mapping.h>
+#include <linux/mmc/host.h>
+#include <linux/proc_fs.h>
+
+#include <asm/cacheflush.h>
+#include <asm/dma.h>
+#include <asm/portmux.h>
+#include <asm/bfin_sdh.h>
+
+#if defined(CONFIG_BF51x)
+#define bfin_read_SDH_PWR_CTL          bfin_read_RSI_PWR_CTL
+#define bfin_write_SDH_PWR_CTL         bfin_write_RSI_PWR_CTL
+#define bfin_read_SDH_CLK_CTL          bfin_read_RSI_CLK_CTL
+#define bfin_write_SDH_CLK_CTL         bfin_write_RSI_CLK_CTL
+#define bfin_write_SDH_ARGUMENT                bfin_write_RSI_ARGUMENT
+#define bfin_write_SDH_COMMAND         bfin_write_RSI_COMMAND
+#define bfin_write_SDH_DATA_TIMER      bfin_write_RSI_DATA_TIMER
+#define bfin_read_SDH_RESPONSE0                bfin_read_RSI_RESPONSE0
+#define bfin_read_SDH_RESPONSE1                bfin_read_RSI_RESPONSE1
+#define bfin_read_SDH_RESPONSE2                bfin_read_RSI_RESPONSE2
+#define bfin_read_SDH_RESPONSE3                bfin_read_RSI_RESPONSE3
+#define bfin_write_SDH_DATA_LGTH       bfin_write_RSI_DATA_LGTH
+#define bfin_read_SDH_DATA_CTL         bfin_read_RSI_DATA_CTL
+#define bfin_write_SDH_DATA_CTL                bfin_write_RSI_DATA_CTL
+#define bfin_read_SDH_DATA_CNT         bfin_read_RSI_DATA_CNT
+#define bfin_write_SDH_STATUS_CLR      bfin_write_RSI_STATUS_CLR
+#define bfin_read_SDH_E_STATUS         bfin_read_RSI_E_STATUS
+#define bfin_write_SDH_E_STATUS                bfin_write_RSI_E_STATUS
+#define bfin_read_SDH_STATUS           bfin_read_RSI_STATUS
+#define bfin_write_SDH_MASK0           bfin_write_RSI_MASK0
+#define bfin_read_SDH_CFG              bfin_read_RSI_CFG
+#define bfin_write_SDH_CFG             bfin_write_RSI_CFG
+#endif
+
+struct dma_desc_array {
+       unsigned long   start_addr;
+       unsigned short  cfg;
+       unsigned short  x_count;
+       short           x_modify;
+} __packed;
+
+struct sdh_host {
+       struct mmc_host         *mmc;
+       spinlock_t              lock;
+       struct resource         *res;
+       void __iomem            *base;
+       int                     irq;
+       int                     stat_irq;
+       int                     dma_ch;
+       int                     dma_dir;
+       struct dma_desc_array   *sg_cpu;
+       dma_addr_t              sg_dma;
+       int                     dma_len;
+
+       unsigned int            imask;
+       unsigned int            power_mode;
+       unsigned int            clk_div;
+
+       struct mmc_request      *mrq;
+       struct mmc_command      *cmd;
+       struct mmc_data         *data;
+};
+
+static struct bfin_sd_host *get_sdh_data(struct platform_device *pdev)
+{
+       return pdev->dev.platform_data;
+}
+
+static void sdh_stop_clock(struct sdh_host *host)
+{
+       bfin_write_SDH_CLK_CTL(bfin_read_SDH_CLK_CTL() & ~CLK_E);
+       SSYNC();
+}
+
+static void sdh_enable_stat_irq(struct sdh_host *host, unsigned int mask)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&host->lock, flags);
+       host->imask |= mask;
+       bfin_write_SDH_MASK0(mask);
+       SSYNC();
+       spin_unlock_irqrestore(&host->lock, flags);
+}
+
+static void sdh_disable_stat_irq(struct sdh_host *host, unsigned int mask)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&host->lock, flags);
+       host->imask &= ~mask;
+       bfin_write_SDH_MASK0(host->imask);
+       SSYNC();
+       spin_unlock_irqrestore(&host->lock, flags);
+}
+
+static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data)
+{
+       unsigned int length;
+       unsigned int data_ctl;
+       unsigned int dma_cfg;
+       struct scatterlist *sg;
+
+       dev_dbg(mmc_dev(host->mmc), "%s enter flags: 0x%x\n", __func__, data->flags);
+       host->data = data;
+       data_ctl = 0;
+       dma_cfg = 0;
+
+       length = data->blksz * data->blocks;
+       bfin_write_SDH_DATA_LGTH(length);
+
+       if (data->flags & MMC_DATA_STREAM)
+               data_ctl |= DTX_MODE;
+
+       if (data->flags & MMC_DATA_READ)
+               data_ctl |= DTX_DIR;
+       /* Only supports power-of-2 block size */
+       if (data->blksz & (data->blksz - 1))
+               return -EINVAL;
+       data_ctl |= ((ffs(data->blksz) - 1) << 4);
+
+       bfin_write_SDH_DATA_CTL(data_ctl);
+
+       bfin_write_SDH_DATA_TIMER(0xFFFF);
+       SSYNC();
+
+       if (data->flags & MMC_DATA_READ) {
+               host->dma_dir = DMA_FROM_DEVICE;
+               dma_cfg |= WNR;
+       } else
+               host->dma_dir = DMA_TO_DEVICE;
+
+       sdh_enable_stat_irq(host, (DAT_CRC_FAIL | DAT_TIME_OUT | DAT_END));
+       host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len, host->dma_dir);
+#if defined(CONFIG_BF54x)
+       dma_cfg |= DMAFLOW_ARRAY | NDSIZE_5 | RESTART | WDSIZE_32 | DMAEN;
+       {
+               int i;
+               for_each_sg(data->sg, sg, host->dma_len, i) {
+                       host->sg_cpu[i].start_addr = sg_dma_address(sg);
+                       host->sg_cpu[i].cfg = dma_cfg;
+                       host->sg_cpu[i].x_count = sg_dma_len(sg) / 4;
+                       host->sg_cpu[i].x_modify = 4;
+                       dev_dbg(mmc_dev(host->mmc), "%d: start_addr:0x%lx, "
+                               "cfg:0x%x, x_count:0x%x, x_modify:0x%x\n",
+                               i, host->sg_cpu[i].start_addr,
+                               host->sg_cpu[i].cfg, host->sg_cpu[i].x_count,
+                               host->sg_cpu[i].x_modify);
+               }
+       }
+       flush_dcache_range((unsigned int)host->sg_cpu,
+               (unsigned int)host->sg_cpu +
+                       host->dma_len * sizeof(struct dma_desc_array));
+       /* Set the last descriptor to stop mode */
+       host->sg_cpu[host->dma_len - 1].cfg &= ~(DMAFLOW | NDSIZE);
+       host->sg_cpu[host->dma_len - 1].cfg |= DI_EN;
+
+       set_dma_curr_desc_addr(host->dma_ch, (unsigned long *)host->sg_dma);
+       set_dma_x_count(host->dma_ch, 0);
+       set_dma_x_modify(host->dma_ch, 0);
+       set_dma_config(host->dma_ch, dma_cfg);
+#elif defined(CONFIG_BF51x)
+       /* RSI DMA doesn't work in array mode */
+       dma_cfg |= WDSIZE_32 | DMAEN;
+       set_dma_start_addr(host->dma_ch, sg_dma_address(&data->sg[0]));
+       set_dma_x_count(host->dma_ch, length / 4);
+       set_dma_x_modify(host->dma_ch, 4);
+       set_dma_config(host->dma_ch, dma_cfg);
+#endif
+       bfin_write_SDH_DATA_CTL(bfin_read_SDH_DATA_CTL() | DTX_DMA_E | DTX_E);
+
+       SSYNC();
+
+       dev_dbg(mmc_dev(host->mmc), "%s exit\n", __func__);
+       return 0;
+}
+
+static void sdh_start_cmd(struct sdh_host *host, struct mmc_command *cmd)
+{
+       unsigned int sdh_cmd;
+       unsigned int stat_mask;
+
+       dev_dbg(mmc_dev(host->mmc), "%s enter cmd: 0x%p\n", __func__, cmd);
+       WARN_ON(host->cmd != NULL);
+       host->cmd = cmd;
+
+       sdh_cmd = 0;
+       stat_mask = 0;
+
+       sdh_cmd |= cmd->opcode;
+
+       if (cmd->flags & MMC_RSP_PRESENT) {
+               sdh_cmd |= CMD_RSP;
+               stat_mask |= CMD_RESP_END;
+       } else {
+               stat_mask |= CMD_SENT;
+       }
+
+       if (cmd->flags & MMC_RSP_136)
+               sdh_cmd |= CMD_L_RSP;
+
+       stat_mask |= CMD_CRC_FAIL | CMD_TIME_OUT;
+
+       sdh_enable_stat_irq(host, stat_mask);
+
+       bfin_write_SDH_ARGUMENT(cmd->arg);
+       bfin_write_SDH_COMMAND(sdh_cmd | CMD_E);
+       bfin_write_SDH_CLK_CTL(bfin_read_SDH_CLK_CTL() | CLK_E);
+       SSYNC();
+}
+
+static void sdh_finish_request(struct sdh_host *host, struct mmc_request *mrq)
+{
+       dev_dbg(mmc_dev(host->mmc), "%s enter\n", __func__);
+       host->mrq = NULL;
+       host->cmd = NULL;
+       host->data = NULL;
+       mmc_request_done(host->mmc, mrq);
+}
+
+static int sdh_cmd_done(struct sdh_host *host, unsigned int stat)
+{
+       struct mmc_command *cmd = host->cmd;
+       int ret = 0;
+
+       dev_dbg(mmc_dev(host->mmc), "%s enter cmd: %p\n", __func__, cmd);
+       if (!cmd)
+               return 0;
+
+       host->cmd = NULL;
+
+       if (cmd->flags & MMC_RSP_PRESENT) {
+               cmd->resp[0] = bfin_read_SDH_RESPONSE0();
+               if (cmd->flags & MMC_RSP_136) {
+                       cmd->resp[1] = bfin_read_SDH_RESPONSE1();
+                       cmd->resp[2] = bfin_read_SDH_RESPONSE2();
+                       cmd->resp[3] = bfin_read_SDH_RESPONSE3();
+               }
+       }
+       if (stat & CMD_TIME_OUT)
+               cmd->error = -ETIMEDOUT;
+       else if (stat & CMD_CRC_FAIL && cmd->flags & MMC_RSP_CRC)
+               cmd->error = -EILSEQ;
+
+       sdh_disable_stat_irq(host, (CMD_SENT | CMD_RESP_END | CMD_TIME_OUT | CMD_CRC_FAIL));
+
+       if (host->data && !cmd->error) {
+               if (host->data->flags & MMC_DATA_WRITE) {
+                       ret = sdh_setup_data(host, host->data);
+                       if (ret)
+                               return 0;
+               }
+
+               sdh_enable_stat_irq(host, DAT_END | RX_OVERRUN | TX_UNDERRUN | DAT_TIME_OUT);
+       } else
+               sdh_finish_request(host, host->mrq);
+
+       return 1;
+}
+
+static int sdh_data_done(struct sdh_host *host, unsigned int stat)
+{
+       struct mmc_data *data = host->data;
+
+       dev_dbg(mmc_dev(host->mmc), "%s enter stat: 0x%x\n", __func__, stat);
+       if (!data)
+               return 0;
+
+       disable_dma(host->dma_ch);
+       dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
+                    host->dma_dir);
+
+       if (stat & DAT_TIME_OUT)
+               data->error = -ETIMEDOUT;
+       else if (stat & DAT_CRC_FAIL)
+               data->error = -EILSEQ;
+       else if (stat & (RX_OVERRUN | TX_UNDERRUN))
+               data->error = -EIO;
+
+       if (!data->error)
+               data->bytes_xfered = data->blocks * data->blksz;
+       else
+               data->bytes_xfered = 0;
+
+       sdh_disable_stat_irq(host, DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL | RX_OVERRUN | TX_UNDERRUN);
+       bfin_write_SDH_STATUS_CLR(DAT_END_STAT | DAT_TIMEOUT_STAT | \
+                       DAT_CRC_FAIL_STAT | DAT_BLK_END_STAT | RX_OVERRUN | TX_UNDERRUN);
+       bfin_write_SDH_DATA_CTL(0);
+       SSYNC();
+
+       host->data = NULL;
+       if (host->mrq->stop) {
+               sdh_stop_clock(host);
+               sdh_start_cmd(host, host->mrq->stop);
+       } else {
+               sdh_finish_request(host, host->mrq);
+       }
+
+       return 1;
+}
+
+static void sdh_request(struct mmc_host *mmc, struct mmc_request *mrq)
+{
+       struct sdh_host *host = mmc_priv(mmc);
+       int ret = 0;
+
+       dev_dbg(mmc_dev(host->mmc), "%s enter, mrp:%p, cmd:%p\n", __func__, mrq, mrq->cmd);
+       WARN_ON(host->mrq != NULL);
+
+       host->mrq = mrq;
+       host->data = mrq->data;
+
+       if (mrq->data && mrq->data->flags & MMC_DATA_READ) {
+               ret = sdh_setup_data(host, mrq->data);
+               if (ret)
+                       return;
+       }
+
+       sdh_start_cmd(host, mrq->cmd);
+}
+
+static void sdh_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+       struct sdh_host *host;
+       unsigned long flags;
+       u16 clk_ctl = 0;
+       u16 pwr_ctl = 0;
+       u16 cfg;
+       host = mmc_priv(mmc);
+
+       spin_lock_irqsave(&host->lock, flags);
+       if (ios->clock) {
+               unsigned long  sys_clk, ios_clk;
+               unsigned char clk_div;
+               ios_clk = 2 * ios->clock;
+               sys_clk = get_sclk();
+               clk_div = sys_clk / ios_clk;
+               if (sys_clk % ios_clk == 0)
+                       clk_div -= 1;
+               clk_div = min_t(unsigned char, clk_div, 0xFF);
+               clk_ctl |= clk_div;
+               clk_ctl |= CLK_E;
+               host->clk_div = clk_div;
+       } else
+               sdh_stop_clock(host);
+
+       if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
+#ifdef CONFIG_SDH_BFIN_MISSING_CMD_PULLUP_WORKAROUND
+               pwr_ctl |= ROD_CTL;
+#else
+               pwr_ctl |= SD_CMD_OD | ROD_CTL;
+#endif
+
+       if (ios->bus_width == MMC_BUS_WIDTH_4) {
+               cfg = bfin_read_SDH_CFG();
+               cfg &= ~PD_SDDAT3;
+               cfg |= PUP_SDDAT3;
+               /* Enable 4 bit SDIO */
+               cfg |= (SD4E | MWE);
+               bfin_write_SDH_CFG(cfg);
+               clk_ctl |= WIDE_BUS;
+       } else {
+               cfg = bfin_read_SDH_CFG();
+               cfg |= MWE;
+               bfin_write_SDH_CFG(cfg);
+       }
+
+       bfin_write_SDH_CLK_CTL(clk_ctl);
+
+       host->power_mode = ios->power_mode;
+       if (ios->power_mode == MMC_POWER_ON)
+               pwr_ctl |= PWR_ON;
+
+       bfin_write_SDH_PWR_CTL(pwr_ctl);
+       SSYNC();
+
+       spin_unlock_irqrestore(&host->lock, flags);
+
+       dev_dbg(mmc_dev(host->mmc), "SDH: clk_div = 0x%x actual clock:%ld expected clock:%d\n",
+               host->clk_div,
+               host->clk_div ? get_sclk() / (2 * (host->clk_div + 1)) : 0,
+               ios->clock);
+}
+
+static const struct mmc_host_ops sdh_ops = {
+       .request        = sdh_request,
+       .set_ios        = sdh_set_ios,
+};
+
+static irqreturn_t sdh_dma_irq(int irq, void *devid)
+{
+       struct sdh_host *host = devid;
+
+       dev_dbg(mmc_dev(host->mmc), "%s enter, irq_stat: 0x%04x\n", __func__,
+               get_dma_curr_irqstat(host->dma_ch));
+       clear_dma_irqstat(host->dma_ch);
+       SSYNC();
+
+       return IRQ_HANDLED;
+}
+
+static irqreturn_t sdh_stat_irq(int irq, void *devid)
+{
+       struct sdh_host *host = devid;
+       unsigned int status;
+       int handled = 0;
+
+       dev_dbg(mmc_dev(host->mmc), "%s enter\n", __func__);
+       status = bfin_read_SDH_E_STATUS();
+       if (status & SD_CARD_DET) {
+               mmc_detect_change(host->mmc, 0);
+               bfin_write_SDH_E_STATUS(SD_CARD_DET);
+       }
+       status = bfin_read_SDH_STATUS();
+       if (status & (CMD_SENT | CMD_RESP_END | CMD_TIME_OUT | CMD_CRC_FAIL)) {
+               handled |= sdh_cmd_done(host, status);
+               bfin_write_SDH_STATUS_CLR(CMD_SENT_STAT | CMD_RESP_END_STAT | \
+                               CMD_TIMEOUT_STAT | CMD_CRC_FAIL_STAT);
+               SSYNC();
+       }
+
+       status = bfin_read_SDH_STATUS();
+       if (status & (DAT_END | DAT_TIME_OUT | DAT_CRC_FAIL | RX_OVERRUN | TX_UNDERRUN))
+               handled |= sdh_data_done(host, status);
+
+       dev_dbg(mmc_dev(host->mmc), "%s exit\n\n", __func__);
+
+       return IRQ_RETVAL(handled);
+}
+
+static int __devinit sdh_probe(struct platform_device *pdev)
+{
+       struct mmc_host *mmc;
+       struct sdh_host *host;
+       struct bfin_sd_host *drv_data = get_sdh_data(pdev);
+       int ret;
+
+       if (!drv_data) {
+               dev_err(&pdev->dev, "missing platform driver data\n");
+               ret = -EINVAL;
+               goto out;
+       }
+
+       mmc = mmc_alloc_host(sizeof(*mmc), &pdev->dev);
+       if (!mmc) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       mmc->ops = &sdh_ops;
+       mmc->max_phys_segs = 32;
+       mmc->max_seg_size = 1 << 16;
+       mmc->max_blk_size = 1 << 11;
+       mmc->max_blk_count = 1 << 11;
+       mmc->max_req_size = PAGE_SIZE;
+       mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+       mmc->f_max = get_sclk();
+       mmc->f_min = mmc->f_max >> 9;
+       mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_NEEDS_POLL;
+       host = mmc_priv(mmc);
+       host->mmc = mmc;
+
+       spin_lock_init(&host->lock);
+       host->irq = drv_data->irq_int0;
+       host->dma_ch = drv_data->dma_chan;
+
+       ret = request_dma(host->dma_ch, DRIVER_NAME "DMA");
+       if (ret) {
+               dev_err(&pdev->dev, "unable to request DMA channel\n");
+               goto out1;
+       }
+
+       ret = set_dma_callback(host->dma_ch, sdh_dma_irq, host);
+       if (ret) {
+               dev_err(&pdev->dev, "unable to request DMA irq\n");
+               goto out2;
+       }
+
+       host->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, &host->sg_dma, GFP_KERNEL);
+       if (host->sg_cpu == NULL) {
+               ret = -ENOMEM;
+               goto out2;
+       }
+
+       platform_set_drvdata(pdev, mmc);
+       mmc_add_host(mmc);
+
+       ret = request_irq(host->irq, sdh_stat_irq, 0, "SDH Status IRQ", host);
+       if (ret) {
+               dev_err(&pdev->dev, "unable to request status irq\n");
+               goto out3;
+       }
+
+       ret = peripheral_request_list(drv_data->pin_req, DRIVER_NAME);
+       if (ret) {
+               dev_err(&pdev->dev, "unable to request peripheral pins\n");
+               goto out4;
+       }
+#if defined(CONFIG_BF54x)
+       /* Secure Digital Host shares DMA with Nand controller */
+       bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1);
+#endif
+
+       bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN);
+       SSYNC();
+
+       /* Disable card inserting detection pin. set MMC_CAP_NEES_POLL, and
+        * mmc stack will do the detection.
+        */
+       bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3));
+       SSYNC();
+
+       return 0;
+
+out4:
+       free_irq(host->irq, host);
+out3:
+       mmc_remove_host(mmc);
+       dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
+out2:
+       free_dma(host->dma_ch);
+out1:
+       mmc_free_host(mmc);
+ out:
+       return ret;
+}
+
+static int __devexit sdh_remove(struct platform_device *pdev)
+{
+       struct mmc_host *mmc = platform_get_drvdata(pdev);
+
+       platform_set_drvdata(pdev, NULL);
+
+       if (mmc) {
+               struct sdh_host *host = mmc_priv(mmc);
+
+               mmc_remove_host(mmc);
+
+               sdh_stop_clock(host);
+               free_irq(host->irq, host);
+               free_dma(host->dma_ch);
+               dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
+
+               mmc_free_host(mmc);
+       }
+
+       return 0;
+}
+
+#ifdef CONFIG_PM
+static int sdh_suspend(struct platform_device *dev, pm_message_t state)
+{
+       struct mmc_host *mmc = platform_get_drvdata(dev);
+       struct bfin_sd_host *drv_data = get_sdh_data(dev);
+       int ret = 0;
+
+       if (mmc)
+               ret = mmc_suspend_host(mmc, state);
+
+       bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() & ~PWR_ON);
+       peripheral_free_list(drv_data->pin_req);
+
+       return ret;
+}
+
+static int sdh_resume(struct platform_device *dev)
+{
+       struct mmc_host *mmc = platform_get_drvdata(dev);
+       struct bfin_sd_host *drv_data = get_sdh_data(dev);
+       int ret = 0;
+
+       ret = peripheral_request_list(drv_data->pin_req, DRIVER_NAME);
+       if (ret) {
+               dev_err(&dev->dev, "unable to request peripheral pins\n");
+               return ret;
+       }
+
+       bfin_write_SDH_PWR_CTL(bfin_read_SDH_PWR_CTL() | PWR_ON);
+#if defined(CONFIG_BF54x)
+       /* Secure Digital Host shares DMA with Nand controller */
+       bfin_write_DMAC1_PERIMUX(bfin_read_DMAC1_PERIMUX() | 0x1);
+#endif
+       bfin_write_SDH_CFG(bfin_read_SDH_CFG() | CLKS_EN);
+       SSYNC();
+
+       bfin_write_SDH_CFG((bfin_read_SDH_CFG() & 0x1F) | (PUP_SDDAT | PUP_SDDAT3));
+       SSYNC();
+
+       if (mmc)
+               ret = mmc_resume_host(mmc);
+
+       return ret;
+}
+#else
+# define sdh_suspend NULL
+# define sdh_resume  NULL
+#endif
+
+static struct platform_driver sdh_driver = {
+       .probe   = sdh_probe,
+       .remove  = __devexit_p(sdh_remove),
+       .suspend = sdh_suspend,
+       .resume  = sdh_resume,
+       .driver  = {
+               .name = DRIVER_NAME,
+       },
+};
+
+static int __init sdh_init(void)
+{
+       return platform_driver_register(&sdh_driver);
+}
+module_init(sdh_init);
+
+static void __exit sdh_exit(void)
+{
+       platform_driver_unregister(&sdh_driver);
+}
+module_exit(sdh_exit);
+
+MODULE_DESCRIPTION("Blackfin Secure Digital Host Driver");
+MODULE_AUTHOR("Cliff Cai, Roy Huang");
+MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
new file mode 100644 (file)
index 0000000..dd45e7c
--- /dev/null
@@ -0,0 +1,1349 @@
+/*
+ * davinci_mmc.c - TI DaVinci MMC/SD/SDIO driver
+ *
+ * Copyright (C) 2006 Texas Instruments.
+ *       Original author: Purushotam Kumar
+ * Copyright (C) 2009 David Brownell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/cpufreq.h>
+#include <linux/mmc/host.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/mmc/mmc.h>
+
+#include <mach/mmc.h>
+#include <mach/edma.h>
+
+/*
+ * Register Definitions
+ */
+#define DAVINCI_MMCCTL       0x00 /* Control Register                  */
+#define DAVINCI_MMCCLK       0x04 /* Memory Clock Control Register     */
+#define DAVINCI_MMCST0       0x08 /* Status Register 0                 */
+#define DAVINCI_MMCST1       0x0C /* Status Register 1                 */
+#define DAVINCI_MMCIM        0x10 /* Interrupt Mask Register           */
+#define DAVINCI_MMCTOR       0x14 /* Response Time-Out Register        */
+#define DAVINCI_MMCTOD       0x18 /* Data Read Time-Out Register       */
+#define DAVINCI_MMCBLEN      0x1C /* Block Length Register             */
+#define DAVINCI_MMCNBLK      0x20 /* Number of Blocks Register         */
+#define DAVINCI_MMCNBLC      0x24 /* Number of Blocks Counter Register */
+#define DAVINCI_MMCDRR       0x28 /* Data Receive Register             */
+#define DAVINCI_MMCDXR       0x2C /* Data Transmit Register            */
+#define DAVINCI_MMCCMD       0x30 /* Command Register                  */
+#define DAVINCI_MMCARGHL     0x34 /* Argument Register                 */
+#define DAVINCI_MMCRSP01     0x38 /* Response Register 0 and 1         */
+#define DAVINCI_MMCRSP23     0x3C /* Response Register 0 and 1         */
+#define DAVINCI_MMCRSP45     0x40 /* Response Register 0 and 1         */
+#define DAVINCI_MMCRSP67     0x44 /* Response Register 0 and 1         */
+#define DAVINCI_MMCDRSP      0x48 /* Data Response Register            */
+#define DAVINCI_MMCETOK      0x4C
+#define DAVINCI_MMCCIDX      0x50 /* Command Index Register            */
+#define DAVINCI_MMCCKC       0x54
+#define DAVINCI_MMCTORC      0x58
+#define DAVINCI_MMCTODC      0x5C
+#define DAVINCI_MMCBLNC      0x60
+#define DAVINCI_SDIOCTL      0x64
+#define DAVINCI_SDIOST0      0x68
+#define DAVINCI_SDIOEN       0x6C
+#define DAVINCI_SDIOST       0x70
+#define DAVINCI_MMCFIFOCTL   0x74 /* FIFO Control Register             */
+
+/* DAVINCI_MMCCTL definitions */
+#define MMCCTL_DATRST         (1 << 0)
+#define MMCCTL_CMDRST         (1 << 1)
+#define MMCCTL_WIDTH_4_BIT    (1 << 2)
+#define MMCCTL_DATEG_DISABLED (0 << 6)
+#define MMCCTL_DATEG_RISING   (1 << 6)
+#define MMCCTL_DATEG_FALLING  (2 << 6)
+#define MMCCTL_DATEG_BOTH     (3 << 6)
+#define MMCCTL_PERMDR_LE      (0 << 9)
+#define MMCCTL_PERMDR_BE      (1 << 9)
+#define MMCCTL_PERMDX_LE      (0 << 10)
+#define MMCCTL_PERMDX_BE      (1 << 10)
+
+/* DAVINCI_MMCCLK definitions */
+#define MMCCLK_CLKEN          (1 << 8)
+#define MMCCLK_CLKRT_MASK     (0xFF << 0)
+
+/* IRQ bit definitions, for DAVINCI_MMCST0 and DAVINCI_MMCIM */
+#define MMCST0_DATDNE         BIT(0)   /* data done */
+#define MMCST0_BSYDNE         BIT(1)   /* busy done */
+#define MMCST0_RSPDNE         BIT(2)   /* command done */
+#define MMCST0_TOUTRD         BIT(3)   /* data read timeout */
+#define MMCST0_TOUTRS         BIT(4)   /* command response timeout */
+#define MMCST0_CRCWR          BIT(5)   /* data write CRC error */
+#define MMCST0_CRCRD          BIT(6)   /* data read CRC error */
+#define MMCST0_CRCRS          BIT(7)   /* command response CRC error */
+#define MMCST0_DXRDY          BIT(9)   /* data transmit ready (fifo empty) */
+#define MMCST0_DRRDY          BIT(10)  /* data receive ready (data in fifo)*/
+#define MMCST0_DATED          BIT(11)  /* DAT3 edge detect */
+#define MMCST0_TRNDNE         BIT(12)  /* transfer done */
+
+/* DAVINCI_MMCST1 definitions */
+#define MMCST1_BUSY           (1 << 0)
+
+/* DAVINCI_MMCCMD definitions */
+#define MMCCMD_CMD_MASK       (0x3F << 0)
+#define MMCCMD_PPLEN          (1 << 7)
+#define MMCCMD_BSYEXP         (1 << 8)
+#define MMCCMD_RSPFMT_MASK    (3 << 9)
+#define MMCCMD_RSPFMT_NONE    (0 << 9)
+#define MMCCMD_RSPFMT_R1456   (1 << 9)
+#define MMCCMD_RSPFMT_R2      (2 << 9)
+#define MMCCMD_RSPFMT_R3      (3 << 9)
+#define MMCCMD_DTRW           (1 << 11)
+#define MMCCMD_STRMTP         (1 << 12)
+#define MMCCMD_WDATX          (1 << 13)
+#define MMCCMD_INITCK         (1 << 14)
+#define MMCCMD_DCLR           (1 << 15)
+#define MMCCMD_DMATRIG        (1 << 16)
+
+/* DAVINCI_MMCFIFOCTL definitions */
+#define MMCFIFOCTL_FIFORST    (1 << 0)
+#define MMCFIFOCTL_FIFODIR_WR (1 << 1)
+#define MMCFIFOCTL_FIFODIR_RD (0 << 1)
+#define MMCFIFOCTL_FIFOLEV    (1 << 2) /* 0 = 128 bits, 1 = 256 bits */
+#define MMCFIFOCTL_ACCWD_4    (0 << 3) /* access width of 4 bytes    */
+#define MMCFIFOCTL_ACCWD_3    (1 << 3) /* access width of 3 bytes    */
+#define MMCFIFOCTL_ACCWD_2    (2 << 3) /* access width of 2 bytes    */
+#define MMCFIFOCTL_ACCWD_1    (3 << 3) /* access width of 1 byte     */
+
+
+/* MMCSD Init clock in Hz in opendrain mode */
+#define MMCSD_INIT_CLOCK               200000
+
+/*
+ * One scatterlist dma "segment" is at most MAX_CCNT rw_threshold units,
+ * and we handle up to NR_SG segments.  MMC_BLOCK_BOUNCE kicks in only
+ * for drivers with max_hw_segs == 1, making the segments bigger (64KB)
+ * than the page or two that's otherwise typical.  NR_SG == 16 gives at
+ * least the same throughput boost, using EDMA transfer linkage instead
+ * of spending CPU time copying pages.
+ */
+#define MAX_CCNT       ((1 << 16) - 1)
+
+#define NR_SG          16
+
+static unsigned rw_threshold = 32;
+module_param(rw_threshold, uint, S_IRUGO);
+MODULE_PARM_DESC(rw_threshold,
+               "Read/Write threshold. Default = 32");
+
+static unsigned __initdata use_dma = 1;
+module_param(use_dma, uint, 0);
+MODULE_PARM_DESC(use_dma, "Whether to use DMA or not. Default = 1");
+
+struct mmc_davinci_host {
+       struct mmc_command *cmd;
+       struct mmc_data *data;
+       struct mmc_host *mmc;
+       struct clk *clk;
+       unsigned int mmc_input_clk;
+       void __iomem *base;
+       struct resource *mem_res;
+       int irq;
+       unsigned char bus_mode;
+
+#define DAVINCI_MMC_DATADIR_NONE       0
+#define DAVINCI_MMC_DATADIR_READ       1
+#define DAVINCI_MMC_DATADIR_WRITE      2
+       unsigned char data_dir;
+
+       /* buffer is used during PIO of one scatterlist segment, and
+        * is updated along with buffer_bytes_left.  bytes_left applies
+        * to all N blocks of the PIO transfer.
+        */
+       u8 *buffer;
+       u32 buffer_bytes_left;
+       u32 bytes_left;
+
+       u32 rxdma, txdma;
+       bool use_dma;
+       bool do_dma;
+
+       /* Scatterlist DMA uses one or more parameter RAM entries:
+        * the main one (associated with rxdma or txdma) plus zero or
+        * more links.  The entries for a given transfer differ only
+        * by memory buffer (address, length) and link field.
+        */
+       struct edmacc_param     tx_template;
+       struct edmacc_param     rx_template;
+       unsigned                n_link;
+       u32                     links[NR_SG - 1];
+
+       /* For PIO we walk scatterlists one segment at a time. */
+       unsigned int            sg_len;
+       struct scatterlist *sg;
+
+       /* Version of the MMC/SD controller */
+       u8 version;
+       /* for ns in one cycle calculation */
+       unsigned ns_in_one_cycle;
+#ifdef CONFIG_CPU_FREQ
+       struct notifier_block   freq_transition;
+#endif
+};
+
+
+/* PIO only */
+static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host)
+{
+       host->buffer_bytes_left = sg_dma_len(host->sg);
+       host->buffer = sg_virt(host->sg);
+       if (host->buffer_bytes_left > host->bytes_left)
+               host->buffer_bytes_left = host->bytes_left;
+}
+
+static void davinci_fifo_data_trans(struct mmc_davinci_host *host,
+                                       unsigned int n)
+{
+       u8 *p;
+       unsigned int i;
+
+       if (host->buffer_bytes_left == 0) {
+               host->sg = sg_next(host->data->sg);
+               mmc_davinci_sg_to_buf(host);
+       }
+
+       p = host->buffer;
+       if (n > host->buffer_bytes_left)
+               n = host->buffer_bytes_left;
+       host->buffer_bytes_left -= n;
+       host->bytes_left -= n;
+
+       /* NOTE:  we never transfer more than rw_threshold bytes
+        * to/from the fifo here; there's no I/O overlap.
+        * This also assumes that access width( i.e. ACCWD) is 4 bytes
+        */
+       if (host->data_dir == DAVINCI_MMC_DATADIR_WRITE) {
+               for (i = 0; i < (n >> 2); i++) {
+                       writel(*((u32 *)p), host->base + DAVINCI_MMCDXR);
+                       p = p + 4;
+               }
+               if (n & 3) {
+                       iowrite8_rep(host->base + DAVINCI_MMCDXR, p, (n & 3));
+                       p = p + (n & 3);
+               }
+       } else {
+               for (i = 0; i < (n >> 2); i++) {
+                       *((u32 *)p) = readl(host->base + DAVINCI_MMCDRR);
+                       p  = p + 4;
+               }
+               if (n & 3) {
+                       ioread8_rep(host->base + DAVINCI_MMCDRR, p, (n & 3));
+                       p = p + (n & 3);
+               }
+       }
+       host->buffer = p;
+}
+
+static void mmc_davinci_start_command(struct mmc_davinci_host *host,
+               struct mmc_command *cmd)
+{
+       u32 cmd_reg = 0;
+       u32 im_val;
+
+       dev_dbg(mmc_dev(host->mmc), "CMD%d, arg 0x%08x%s\n",
+               cmd->opcode, cmd->arg,
+               ({ char *s;
+               switch (mmc_resp_type(cmd)) {
+               case MMC_RSP_R1:
+                       s = ", R1/R5/R6/R7 response";
+                       break;
+               case MMC_RSP_R1B:
+                       s = ", R1b response";
+                       break;
+               case MMC_RSP_R2:
+                       s = ", R2 response";
+                       break;
+               case MMC_RSP_R3:
+                       s = ", R3/R4 response";
+                       break;
+               default:
+                       s = ", (R? response)";
+                       break;
+               }; s; }));
+       host->cmd = cmd;
+
+       switch (mmc_resp_type(cmd)) {
+       case MMC_RSP_R1B:
+               /* There's some spec confusion about when R1B is
+                * allowed, but if the card doesn't issue a BUSY
+                * then it's harmless for us to allow it.
+                */
+               cmd_reg |= MMCCMD_BSYEXP;
+               /* FALLTHROUGH */
+       case MMC_RSP_R1:                /* 48 bits, CRC */
+               cmd_reg |= MMCCMD_RSPFMT_R1456;
+               break;
+       case MMC_RSP_R2:                /* 136 bits, CRC */
+               cmd_reg |= MMCCMD_RSPFMT_R2;
+               break;
+       case MMC_RSP_R3:                /* 48 bits, no CRC */
+               cmd_reg |= MMCCMD_RSPFMT_R3;
+               break;
+       default:
+               cmd_reg |= MMCCMD_RSPFMT_NONE;
+               dev_dbg(mmc_dev(host->mmc), "unknown resp_type %04x\n",
+                       mmc_resp_type(cmd));
+               break;
+       }
+
+       /* Set command index */
+       cmd_reg |= cmd->opcode;
+
+       /* Enable EDMA transfer triggers */
+       if (host->do_dma)
+               cmd_reg |= MMCCMD_DMATRIG;
+
+       if (host->version == MMC_CTLR_VERSION_2 && host->data != NULL &&
+                       host->data_dir == DAVINCI_MMC_DATADIR_READ)
+               cmd_reg |= MMCCMD_DMATRIG;
+
+       /* Setting whether command involves data transfer or not */
+       if (cmd->data)
+               cmd_reg |= MMCCMD_WDATX;
+
+       /* Setting whether stream or block transfer */
+       if (cmd->flags & MMC_DATA_STREAM)
+               cmd_reg |= MMCCMD_STRMTP;
+
+       /* Setting whether data read or write */
+       if (host->data_dir == DAVINCI_MMC_DATADIR_WRITE)
+               cmd_reg |= MMCCMD_DTRW;
+
+       if (host->bus_mode == MMC_BUSMODE_PUSHPULL)
+               cmd_reg |= MMCCMD_PPLEN;
+
+       /* set Command timeout */
+       writel(0x1FFF, host->base + DAVINCI_MMCTOR);
+
+       /* Enable interrupt (calculate here, defer until FIFO is stuffed). */
+       im_val =  MMCST0_RSPDNE | MMCST0_CRCRS | MMCST0_TOUTRS;
+       if (host->data_dir == DAVINCI_MMC_DATADIR_WRITE) {
+               im_val |= MMCST0_DATDNE | MMCST0_CRCWR;
+
+               if (!host->do_dma)
+                       im_val |= MMCST0_DXRDY;
+       } else if (host->data_dir == DAVINCI_MMC_DATADIR_READ) {
+               im_val |= MMCST0_DATDNE | MMCST0_CRCRD | MMCST0_TOUTRD;
+
+               if (!host->do_dma)
+                       im_val |= MMCST0_DRRDY;
+       }
+
+       /*
+        * Before non-DMA WRITE commands the controller needs priming:
+        * FIFO should be populated with 32 bytes i.e. whatever is the FIFO size
+        */
+       if (!host->do_dma && (host->data_dir == DAVINCI_MMC_DATADIR_WRITE))
+               davinci_fifo_data_trans(host, rw_threshold);
+
+       writel(cmd->arg, host->base + DAVINCI_MMCARGHL);
+       writel(cmd_reg,  host->base + DAVINCI_MMCCMD);
+       writel(im_val, host->base + DAVINCI_MMCIM);
+}
+
+/*----------------------------------------------------------------------*/
+
+/* DMA infrastructure */
+
+static void davinci_abort_dma(struct mmc_davinci_host *host)
+{
+       int sync_dev;
+
+       if (host->data_dir == DAVINCI_MMC_DATADIR_READ)
+               sync_dev = host->rxdma;
+       else
+               sync_dev = host->txdma;
+
+       edma_stop(sync_dev);
+       edma_clean_channel(sync_dev);
+}
+
+static void
+mmc_davinci_xfer_done(struct mmc_davinci_host *host, struct mmc_data *data);
+
+static void mmc_davinci_dma_cb(unsigned channel, u16 ch_status, void *data)
+{
+       if (DMA_COMPLETE != ch_status) {
+               struct mmc_davinci_host *host = data;
+
+               /* Currently means:  DMA Event Missed, or "null" transfer
+                * request was seen.  In the future, TC errors (like bad
+                * addresses) might be presented too.
+                */
+               dev_warn(mmc_dev(host->mmc), "DMA %s error\n",
+                       (host->data->flags & MMC_DATA_WRITE)
+                               ? "write" : "read");
+               host->data->error = -EIO;
+               mmc_davinci_xfer_done(host, host->data);
+       }
+}
+
+/* Set up tx or rx template, to be modified and updated later */
+static void __init mmc_davinci_dma_setup(struct mmc_davinci_host *host,
+               bool tx, struct edmacc_param *template)
+{
+       unsigned        sync_dev;
+       const u16       acnt = 4;
+       const u16       bcnt = rw_threshold >> 2;
+       const u16       ccnt = 0;
+       u32             src_port = 0;
+       u32             dst_port = 0;
+       s16             src_bidx, dst_bidx;
+       s16             src_cidx, dst_cidx;
+
+       /*
+        * A-B Sync transfer:  each DMA request is for one "frame" of
+        * rw_threshold bytes, broken into "acnt"-size chunks repeated
+        * "bcnt" times.  Each segment needs "ccnt" such frames; since
+        * we tell the block layer our mmc->max_seg_size limit, we can
+        * trust (later) that it's within bounds.
+        *
+        * The FIFOs are read/written in 4-byte chunks (acnt == 4) and
+        * EDMA will optimize memory operations to use larger bursts.
+        */
+       if (tx) {
+               sync_dev = host->txdma;
+
+               /* src_prt, ccnt, and link to be set up later */
+               src_bidx = acnt;
+               src_cidx = acnt * bcnt;
+
+               dst_port = host->mem_res->start + DAVINCI_MMCDXR;
+               dst_bidx = 0;
+               dst_cidx = 0;
+       } else {
+               sync_dev = host->rxdma;
+
+               src_port = host->mem_res->start + DAVINCI_MMCDRR;
+               src_bidx = 0;
+               src_cidx = 0;
+
+               /* dst_prt, ccnt, and link to be set up later */
+               dst_bidx = acnt;
+               dst_cidx = acnt * bcnt;
+       }
+
+       /*
+        * We can't use FIFO mode for the FIFOs because MMC FIFO addresses
+        * are not 256-bit (32-byte) aligned.  So we use INCR, and the W8BIT
+        * parameter is ignored.
+        */
+       edma_set_src(sync_dev, src_port, INCR, W8BIT);
+       edma_set_dest(sync_dev, dst_port, INCR, W8BIT);
+
+       edma_set_src_index(sync_dev, src_bidx, src_cidx);
+       edma_set_dest_index(sync_dev, dst_bidx, dst_cidx);
+
+       edma_set_transfer_params(sync_dev, acnt, bcnt, ccnt, 8, ABSYNC);
+
+       edma_read_slot(sync_dev, template);
+
+       /* don't bother with irqs or chaining */
+       template->opt |= EDMA_CHAN_SLOT(sync_dev) << 12;
+}
+
+static void mmc_davinci_send_dma_request(struct mmc_davinci_host *host,
+               struct mmc_data *data)
+{
+       struct edmacc_param     *template;
+       int                     channel, slot;
+       unsigned                link;
+       struct scatterlist      *sg;
+       unsigned                sg_len;
+       unsigned                bytes_left = host->bytes_left;
+       const unsigned          shift = ffs(rw_threshold) - 1;;
+
+       if (host->data_dir == DAVINCI_MMC_DATADIR_WRITE) {
+               template = &host->tx_template;
+               channel = host->txdma;
+       } else {
+               template = &host->rx_template;
+               channel = host->rxdma;
+       }
+
+       /* We know sg_len and ccnt will never be out of range because
+        * we told the mmc layer which in turn tells the block layer
+        * to ensure that it only hands us one scatterlist segment
+        * per EDMA PARAM entry.  Update the PARAM
+        * entries needed for each segment of this scatterlist.
+        */
+       for (slot = channel, link = 0, sg = data->sg, sg_len = host->sg_len;
+                       sg_len-- != 0 && bytes_left;
+                       sg = sg_next(sg), slot = host->links[link++]) {
+               u32             buf = sg_dma_address(sg);
+               unsigned        count = sg_dma_len(sg);
+
+               template->link_bcntrld = sg_len
+                               ? (EDMA_CHAN_SLOT(host->links[link]) << 5)
+                               : 0xffff;
+
+               if (count > bytes_left)
+                       count = bytes_left;
+               bytes_left -= count;
+
+               if (host->data_dir == DAVINCI_MMC_DATADIR_WRITE)
+                       template->src = buf;
+               else
+                       template->dst = buf;
+               template->ccnt = count >> shift;
+
+               edma_write_slot(slot, template);
+       }
+
+       if (host->version == MMC_CTLR_VERSION_2)
+               edma_clear_event(channel);
+
+       edma_start(channel);
+}
+
+static int mmc_davinci_start_dma_transfer(struct mmc_davinci_host *host,
+               struct mmc_data *data)
+{
+       int i;
+       int mask = rw_threshold - 1;
+
+       host->sg_len = dma_map_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
+                               ((data->flags & MMC_DATA_WRITE)
+                               ? DMA_TO_DEVICE
+                               : DMA_FROM_DEVICE));
+
+       /* no individual DMA segment should need a partial FIFO */
+       for (i = 0; i < host->sg_len; i++) {
+               if (sg_dma_len(data->sg + i) & mask) {
+                       dma_unmap_sg(mmc_dev(host->mmc),
+                                       data->sg, data->sg_len,
+                                       (data->flags & MMC_DATA_WRITE)
+                                       ? DMA_TO_DEVICE
+                                       : DMA_FROM_DEVICE);
+                       return -1;
+               }
+       }
+
+       host->do_dma = 1;
+       mmc_davinci_send_dma_request(host, data);
+
+       return 0;
+}
+
+static void __init_or_module
+davinci_release_dma_channels(struct mmc_davinci_host *host)
+{
+       unsigned        i;
+
+       if (!host->use_dma)
+               return;
+
+       for (i = 0; i < host->n_link; i++)
+               edma_free_slot(host->links[i]);
+
+       edma_free_channel(host->txdma);
+       edma_free_channel(host->rxdma);
+}
+
+static int __init davinci_acquire_dma_channels(struct mmc_davinci_host *host)
+{
+       int r, i;
+
+       /* Acquire master DMA write channel */
+       r = edma_alloc_channel(host->txdma, mmc_davinci_dma_cb, host,
+                       EVENTQ_DEFAULT);
+       if (r < 0) {
+               dev_warn(mmc_dev(host->mmc), "alloc %s channel err %d\n",
+                               "tx", r);
+               return r;
+       }
+       mmc_davinci_dma_setup(host, true, &host->tx_template);
+
+       /* Acquire master DMA read channel */
+       r = edma_alloc_channel(host->rxdma, mmc_davinci_dma_cb, host,
+                       EVENTQ_DEFAULT);
+       if (r < 0) {
+               dev_warn(mmc_dev(host->mmc), "alloc %s channel err %d\n",
+                               "rx", r);
+               goto free_master_write;
+       }
+       mmc_davinci_dma_setup(host, false, &host->rx_template);
+
+       /* Allocate parameter RAM slots, which will later be bound to a
+        * channel as needed to handle a scatterlist.
+        */
+       for (i = 0; i < ARRAY_SIZE(host->links); i++) {
+               r = edma_alloc_slot(EDMA_CTLR(host->txdma), EDMA_SLOT_ANY);
+               if (r < 0) {
+                       dev_dbg(mmc_dev(host->mmc), "dma PaRAM alloc --> %d\n",
+                               r);
+                       break;
+               }
+               host->links[i] = r;
+       }
+       host->n_link = i;
+
+       return 0;
+
+free_master_write:
+       edma_free_channel(host->txdma);
+
+       return r;
+}
+
+/*----------------------------------------------------------------------*/
+
+static void
+mmc_davinci_prepare_data(struct mmc_davinci_host *host, struct mmc_request *req)
+{
+       int fifo_lev = (rw_threshold == 32) ? MMCFIFOCTL_FIFOLEV : 0;
+       int timeout;
+       struct mmc_data *data = req->data;
+
+       if (host->version == MMC_CTLR_VERSION_2)
+               fifo_lev = (rw_threshold == 64) ? MMCFIFOCTL_FIFOLEV : 0;
+
+       host->data = data;
+       if (data == NULL) {
+               host->data_dir = DAVINCI_MMC_DATADIR_NONE;
+               writel(0, host->base + DAVINCI_MMCBLEN);
+               writel(0, host->base + DAVINCI_MMCNBLK);
+               return;
+       }
+
+       dev_dbg(mmc_dev(host->mmc), "%s %s, %d blocks of %d bytes\n",
+               (data->flags & MMC_DATA_STREAM) ? "stream" : "block",
+               (data->flags & MMC_DATA_WRITE) ? "write" : "read",
+               data->blocks, data->blksz);
+       dev_dbg(mmc_dev(host->mmc), "  DTO %d cycles + %d ns\n",
+               data->timeout_clks, data->timeout_ns);
+       timeout = data->timeout_clks +
+               (data->timeout_ns / host->ns_in_one_cycle);
+       if (timeout > 0xffff)
+               timeout = 0xffff;
+
+       writel(timeout, host->base + DAVINCI_MMCTOD);
+       writel(data->blocks, host->base + DAVINCI_MMCNBLK);
+       writel(data->blksz, host->base + DAVINCI_MMCBLEN);
+
+       /* Configure the FIFO */
+       switch (data->flags & MMC_DATA_WRITE) {
+       case MMC_DATA_WRITE:
+               host->data_dir = DAVINCI_MMC_DATADIR_WRITE;
+               writel(fifo_lev | MMCFIFOCTL_FIFODIR_WR | MMCFIFOCTL_FIFORST,
+                       host->base + DAVINCI_MMCFIFOCTL);
+               writel(fifo_lev | MMCFIFOCTL_FIFODIR_WR,
+                       host->base + DAVINCI_MMCFIFOCTL);
+               break;
+
+       default:
+               host->data_dir = DAVINCI_MMC_DATADIR_READ;
+               writel(fifo_lev | MMCFIFOCTL_FIFODIR_RD | MMCFIFOCTL_FIFORST,
+                       host->base + DAVINCI_MMCFIFOCTL);
+               writel(fifo_lev | MMCFIFOCTL_FIFODIR_RD,
+                       host->base + DAVINCI_MMCFIFOCTL);
+               break;
+       }
+
+       host->buffer = NULL;
+       host->bytes_left = data->blocks * data->blksz;
+
+       /* For now we try to use DMA whenever we won't need partial FIFO
+        * reads or writes, either for the whole transfer (as tested here)
+        * or for any individual scatterlist segment (tested when we call
+        * start_dma_transfer).
+        *
+        * While we *could* change that, unusual block sizes are rarely
+        * used.  The occasional fallback to PIO should't hurt.
+        */
+       if (host->use_dma && (host->bytes_left & (rw_threshold - 1)) == 0
+                       && mmc_davinci_start_dma_transfer(host, data) == 0) {
+               /* zero this to ensure we take no PIO paths */
+               host->bytes_left = 0;
+       } else {
+               /* Revert to CPU Copy */
+               host->sg_len = data->sg_len;
+               host->sg = host->data->sg;
+               mmc_davinci_sg_to_buf(host);
+       }
+}
+
+static void mmc_davinci_request(struct mmc_host *mmc, struct mmc_request *req)
+{
+       struct mmc_davinci_host *host = mmc_priv(mmc);
+       unsigned long timeout = jiffies + msecs_to_jiffies(900);
+       u32 mmcst1 = 0;
+
+       /* Card may still be sending BUSY after a previous operation,
+        * typically some kind of write.  If so, we can't proceed yet.
+        */
+       while (time_before(jiffies, timeout)) {
+               mmcst1  = readl(host->base + DAVINCI_MMCST1);
+               if (!(mmcst1 & MMCST1_BUSY))
+                       break;
+               cpu_relax();
+       }
+       if (mmcst1 & MMCST1_BUSY) {
+               dev_err(mmc_dev(host->mmc), "still BUSY? bad ... \n");
+               req->cmd->error = -ETIMEDOUT;
+               mmc_request_done(mmc, req);
+               return;
+       }
+
+       host->do_dma = 0;
+       mmc_davinci_prepare_data(host, req);
+       mmc_davinci_start_command(host, req->cmd);
+}
+
+static unsigned int calculate_freq_for_card(struct mmc_davinci_host *host,
+       unsigned int mmc_req_freq)
+{
+       unsigned int mmc_freq = 0, mmc_pclk = 0, mmc_push_pull_divisor = 0;
+
+       mmc_pclk = host->mmc_input_clk;
+       if (mmc_req_freq && mmc_pclk > (2 * mmc_req_freq))
+               mmc_push_pull_divisor = ((unsigned int)mmc_pclk
+                               / (2 * mmc_req_freq)) - 1;
+       else
+               mmc_push_pull_divisor = 0;
+
+       mmc_freq = (unsigned int)mmc_pclk
+               / (2 * (mmc_push_pull_divisor + 1));
+
+       if (mmc_freq > mmc_req_freq)
+               mmc_push_pull_divisor = mmc_push_pull_divisor + 1;
+       /* Convert ns to clock cycles */
+       if (mmc_req_freq <= 400000)
+               host->ns_in_one_cycle = (1000000) / (((mmc_pclk
+                               / (2 * (mmc_push_pull_divisor + 1)))/1000));
+       else
+               host->ns_in_one_cycle = (1000000) / (((mmc_pclk
+                               / (2 * (mmc_push_pull_divisor + 1)))/1000000));
+
+       return mmc_push_pull_divisor;
+}
+
+static void calculate_clk_divider(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+       unsigned int open_drain_freq = 0, mmc_pclk = 0;
+       unsigned int mmc_push_pull_freq = 0;
+       struct mmc_davinci_host *host = mmc_priv(mmc);
+
+       if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
+               u32 temp;
+
+               /* Ignoring the init clock value passed for fixing the inter
+                * operability with different cards.
+                */
+               open_drain_freq = ((unsigned int)mmc_pclk
+                               / (2 * MMCSD_INIT_CLOCK)) - 1;
+
+               if (open_drain_freq > 0xFF)
+                       open_drain_freq = 0xFF;
+
+               temp = readl(host->base + DAVINCI_MMCCLK) & ~MMCCLK_CLKRT_MASK;
+               temp |= open_drain_freq;
+               writel(temp, host->base + DAVINCI_MMCCLK);
+
+               /* Convert ns to clock cycles */
+               host->ns_in_one_cycle = (1000000) / (MMCSD_INIT_CLOCK/1000);
+       } else {
+               u32 temp;
+               mmc_push_pull_freq = calculate_freq_for_card(host, ios->clock);
+
+               if (mmc_push_pull_freq > 0xFF)
+                       mmc_push_pull_freq = 0xFF;
+
+               temp = readl(host->base + DAVINCI_MMCCLK) & ~MMCCLK_CLKEN;
+               writel(temp, host->base + DAVINCI_MMCCLK);
+
+               udelay(10);
+
+               temp = readl(host->base + DAVINCI_MMCCLK) & ~MMCCLK_CLKRT_MASK;
+               temp |= mmc_push_pull_freq;
+               writel(temp, host->base + DAVINCI_MMCCLK);
+
+               writel(temp | MMCCLK_CLKEN, host->base + DAVINCI_MMCCLK);
+
+               udelay(10);
+       }
+}
+
+static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+       unsigned int mmc_pclk = 0;
+       struct mmc_davinci_host *host = mmc_priv(mmc);
+
+       mmc_pclk = host->mmc_input_clk;
+       dev_dbg(mmc_dev(host->mmc),
+               "clock %dHz busmode %d powermode %d Vdd %04x\n",
+               ios->clock, ios->bus_mode, ios->power_mode,
+               ios->vdd);
+       if (ios->bus_width == MMC_BUS_WIDTH_4) {
+               dev_dbg(mmc_dev(host->mmc), "Enabling 4 bit mode\n");
+               writel(readl(host->base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT,
+                       host->base + DAVINCI_MMCCTL);
+       } else {
+               dev_dbg(mmc_dev(host->mmc), "Disabling 4 bit mode\n");
+               writel(readl(host->base + DAVINCI_MMCCTL) & ~MMCCTL_WIDTH_4_BIT,
+                       host->base + DAVINCI_MMCCTL);
+       }
+
+       calculate_clk_divider(mmc, ios);
+
+       host->bus_mode = ios->bus_mode;
+       if (ios->power_mode == MMC_POWER_UP) {
+               unsigned long timeout = jiffies + msecs_to_jiffies(50);
+               bool lose = true;
+
+               /* Send clock cycles, poll completion */
+               writel(0, host->base + DAVINCI_MMCARGHL);
+               writel(MMCCMD_INITCK, host->base + DAVINCI_MMCCMD);
+               while (time_before(jiffies, timeout)) {
+                       u32 tmp = readl(host->base + DAVINCI_MMCST0);
+
+                       if (tmp & MMCST0_RSPDNE) {
+                               lose = false;
+                               break;
+                       }
+                       cpu_relax();
+               }
+               if (lose)
+                       dev_warn(mmc_dev(host->mmc), "powerup timeout\n");
+       }
+
+       /* FIXME on power OFF, reset things ... */
+}
+
+static void
+mmc_davinci_xfer_done(struct mmc_davinci_host *host, struct mmc_data *data)
+{
+       host->data = NULL;
+
+       if (host->do_dma) {
+               davinci_abort_dma(host);
+
+               dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
+                            (data->flags & MMC_DATA_WRITE)
+                            ? DMA_TO_DEVICE
+                            : DMA_FROM_DEVICE);
+               host->do_dma = false;
+       }
+       host->data_dir = DAVINCI_MMC_DATADIR_NONE;
+
+       if (!data->stop || (host->cmd && host->cmd->error)) {
+               mmc_request_done(host->mmc, data->mrq);
+               writel(0, host->base + DAVINCI_MMCIM);
+       } else
+               mmc_davinci_start_command(host, data->stop);
+}
+
+static void mmc_davinci_cmd_done(struct mmc_davinci_host *host,
+                                struct mmc_command *cmd)
+{
+       host->cmd = NULL;
+
+       if (cmd->flags & MMC_RSP_PRESENT) {
+               if (cmd->flags & MMC_RSP_136) {
+                       /* response type 2 */
+                       cmd->resp[3] = readl(host->base + DAVINCI_MMCRSP01);
+                       cmd->resp[2] = readl(host->base + DAVINCI_MMCRSP23);
+                       cmd->resp[1] = readl(host->base + DAVINCI_MMCRSP45);
+                       cmd->resp[0] = readl(host->base + DAVINCI_MMCRSP67);
+               } else {
+                       /* response types 1, 1b, 3, 4, 5, 6 */
+                       cmd->resp[0] = readl(host->base + DAVINCI_MMCRSP67);
+               }
+       }
+
+       if (host->data == NULL || cmd->error) {
+               if (cmd->error == -ETIMEDOUT)
+                       cmd->mrq->cmd->retries = 0;
+               mmc_request_done(host->mmc, cmd->mrq);
+               writel(0, host->base + DAVINCI_MMCIM);
+       }
+}
+
+static void
+davinci_abort_data(struct mmc_davinci_host *host, struct mmc_data *data)
+{
+       u32 temp;
+
+       /* reset command and data state machines */
+       temp = readl(host->base + DAVINCI_MMCCTL);
+       writel(temp | MMCCTL_CMDRST | MMCCTL_DATRST,
+               host->base + DAVINCI_MMCCTL);
+
+       temp &= ~(MMCCTL_CMDRST | MMCCTL_DATRST);
+       udelay(10);
+       writel(temp, host->base + DAVINCI_MMCCTL);
+}
+
+static irqreturn_t mmc_davinci_irq(int irq, void *dev_id)
+{
+       struct mmc_davinci_host *host = (struct mmc_davinci_host *)dev_id;
+       unsigned int status, qstatus;
+       int end_command = 0;
+       int end_transfer = 0;
+       struct mmc_data *data = host->data;
+
+       if (host->cmd == NULL && host->data == NULL) {
+               status = readl(host->base + DAVINCI_MMCST0);
+               dev_dbg(mmc_dev(host->mmc),
+                       "Spurious interrupt 0x%04x\n", status);
+               /* Disable the interrupt from mmcsd */
+               writel(0, host->base + DAVINCI_MMCIM);
+               return IRQ_NONE;
+       }
+
+       status = readl(host->base + DAVINCI_MMCST0);
+       qstatus = status;
+
+       /* handle FIFO first when using PIO for data.
+        * bytes_left will decrease to zero as I/O progress and status will
+        * read zero over iteration because this controller status
+        * register(MMCST0) reports any status only once and it is cleared
+        * by read. So, it is not unbouned loop even in the case of
+        * non-dma.
+        */
+       while (host->bytes_left && (status & (MMCST0_DXRDY | MMCST0_DRRDY))) {
+               davinci_fifo_data_trans(host, rw_threshold);
+               status = readl(host->base + DAVINCI_MMCST0);
+               if (!status)
+                       break;
+               qstatus |= status;
+       }
+
+       if (qstatus & MMCST0_DATDNE) {
+               /* All blocks sent/received, and CRC checks passed */
+               if (data != NULL) {
+                       if ((host->do_dma == 0) && (host->bytes_left > 0)) {
+                               /* if datasize < rw_threshold
+                                * no RX ints are generated
+                                */
+                               davinci_fifo_data_trans(host, host->bytes_left);
+                       }
+                       end_transfer = 1;
+                       data->bytes_xfered = data->blocks * data->blksz;
+               } else {
+                       dev_err(mmc_dev(host->mmc),
+                                       "DATDNE with no host->data\n");
+               }
+       }
+
+       if (qstatus & MMCST0_TOUTRD) {
+               /* Read data timeout */
+               data->error = -ETIMEDOUT;
+               end_transfer = 1;
+
+               dev_dbg(mmc_dev(host->mmc),
+                       "read data timeout, status %x\n",
+                       qstatus);
+
+               davinci_abort_data(host, data);
+       }
+
+       if (qstatus & (MMCST0_CRCWR | MMCST0_CRCRD)) {
+               /* Data CRC error */
+               data->error = -EILSEQ;
+               end_transfer = 1;
+
+               /* NOTE:  this controller uses CRCWR to report both CRC
+                * errors and timeouts (on writes).  MMCDRSP values are
+                * only weakly documented, but 0x9f was clearly a timeout
+                * case and the two three-bit patterns in various SD specs
+                * (101, 010) aren't part of it ...
+                */
+               if (qstatus & MMCST0_CRCWR) {
+                       u32 temp = readb(host->base + DAVINCI_MMCDRSP);
+
+                       if (temp == 0x9f)
+                               data->error = -ETIMEDOUT;
+               }
+               dev_dbg(mmc_dev(host->mmc), "data %s %s error\n",
+                       (qstatus & MMCST0_CRCWR) ? "write" : "read",
+                       (data->error == -ETIMEDOUT) ? "timeout" : "CRC");
+
+               davinci_abort_data(host, data);
+       }
+
+       if (qstatus & MMCST0_TOUTRS) {
+               /* Command timeout */
+               if (host->cmd) {
+                       dev_dbg(mmc_dev(host->mmc),
+                               "CMD%d timeout, status %x\n",
+                               host->cmd->opcode, qstatus);
+                       host->cmd->error = -ETIMEDOUT;
+                       if (data) {
+                               end_transfer = 1;
+                               davinci_abort_data(host, data);
+                       } else
+                               end_command = 1;
+               }
+       }
+
+       if (qstatus & MMCST0_CRCRS) {
+               /* Command CRC error */
+               dev_dbg(mmc_dev(host->mmc), "Command CRC error\n");
+               if (host->cmd) {
+                       host->cmd->error = -EILSEQ;
+                       end_command = 1;
+               }
+       }
+
+       if (qstatus & MMCST0_RSPDNE) {
+               /* End of command phase */
+               end_command = (int) host->cmd;
+       }
+
+       if (end_command)
+               mmc_davinci_cmd_done(host, host->cmd);
+       if (end_transfer)
+               mmc_davinci_xfer_done(host, data);
+       return IRQ_HANDLED;
+}
+
+static int mmc_davinci_get_cd(struct mmc_host *mmc)
+{
+       struct platform_device *pdev = to_platform_device(mmc->parent);
+       struct davinci_mmc_config *config = pdev->dev.platform_data;
+
+       if (!config || !config->get_cd)
+               return -ENOSYS;
+       return config->get_cd(pdev->id);
+}
+
+static int mmc_davinci_get_ro(struct mmc_host *mmc)
+{
+       struct platform_device *pdev = to_platform_device(mmc->parent);
+       struct davinci_mmc_config *config = pdev->dev.platform_data;
+
+       if (!config || !config->get_ro)
+               return -ENOSYS;
+       return config->get_ro(pdev->id);
+}
+
+static struct mmc_host_ops mmc_davinci_ops = {
+       .request        = mmc_davinci_request,
+       .set_ios        = mmc_davinci_set_ios,
+       .get_cd         = mmc_davinci_get_cd,
+       .get_ro         = mmc_davinci_get_ro,
+};
+
+/*----------------------------------------------------------------------*/
+
+#ifdef CONFIG_CPU_FREQ
+static int mmc_davinci_cpufreq_transition(struct notifier_block *nb,
+                                    unsigned long val, void *data)
+{
+       struct mmc_davinci_host *host;
+       unsigned int mmc_pclk;
+       struct mmc_host *mmc;
+       unsigned long flags;
+
+       host = container_of(nb, struct mmc_davinci_host, freq_transition);
+       mmc = host->mmc;
+       mmc_pclk = clk_get_rate(host->clk);
+
+       if (val == CPUFREQ_POSTCHANGE) {
+               spin_lock_irqsave(&mmc->lock, flags);
+               host->mmc_input_clk = mmc_pclk;
+               calculate_clk_divider(mmc, &mmc->ios);
+               spin_unlock_irqrestore(&mmc->lock, flags);
+       }
+
+       return 0;
+}
+
+static inline int mmc_davinci_cpufreq_register(struct mmc_davinci_host *host)
+{
+       host->freq_transition.notifier_call = mmc_davinci_cpufreq_transition;
+
+       return cpufreq_register_notifier(&host->freq_transition,
+                                        CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host *host)
+{
+       cpufreq_unregister_notifier(&host->freq_transition,
+                                   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#else
+static inline int mmc_davinci_cpufreq_register(struct mmc_davinci_host *host)
+{
+       return 0;
+}
+
+static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host *host)
+{
+}
+#endif
+static void __init init_mmcsd_host(struct mmc_davinci_host *host)
+{
+       /* DAT line portion is diabled and in reset state */
+       writel(readl(host->base + DAVINCI_MMCCTL) | MMCCTL_DATRST,
+               host->base + DAVINCI_MMCCTL);
+
+       /* CMD line portion is diabled and in reset state */
+       writel(readl(host->base + DAVINCI_MMCCTL) | MMCCTL_CMDRST,
+               host->base + DAVINCI_MMCCTL);
+
+       udelay(10);
+
+       writel(0, host->base + DAVINCI_MMCCLK);
+       writel(MMCCLK_CLKEN, host->base + DAVINCI_MMCCLK);
+
+       writel(0x1FFF, host->base + DAVINCI_MMCTOR);
+       writel(0xFFFF, host->base + DAVINCI_MMCTOD);
+
+       writel(readl(host->base + DAVINCI_MMCCTL) & ~MMCCTL_DATRST,
+               host->base + DAVINCI_MMCCTL);
+       writel(readl(host->base + DAVINCI_MMCCTL) & ~MMCCTL_CMDRST,
+               host->base + DAVINCI_MMCCTL);
+
+       udelay(10);
+}
+
+static int __init davinci_mmcsd_probe(struct platform_device *pdev)
+{
+       struct davinci_mmc_config *pdata = pdev->dev.platform_data;
+       struct mmc_davinci_host *host = NULL;
+       struct mmc_host *mmc = NULL;
+       struct resource *r, *mem = NULL;
+       int ret = 0, irq = 0;
+       size_t mem_size;
+
+       /* REVISIT:  when we're fully converted, fail if pdata is NULL */
+
+       ret = -ENODEV;
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       irq = platform_get_irq(pdev, 0);
+       if (!r || irq == NO_IRQ)
+               goto out;
+
+       ret = -EBUSY;
+       mem_size = resource_size(r);
+       mem = request_mem_region(r->start, mem_size, pdev->name);
+       if (!mem)
+               goto out;
+
+       ret = -ENOMEM;
+       mmc = mmc_alloc_host(sizeof(struct mmc_davinci_host), &pdev->dev);
+       if (!mmc)
+               goto out;
+
+       host = mmc_priv(mmc);
+       host->mmc = mmc;        /* Important */
+
+       r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
+       if (!r)
+               goto out;
+       host->rxdma = r->start;
+
+       r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
+       if (!r)
+               goto out;
+       host->txdma = r->start;
+
+       host->mem_res = mem;
+       host->base = ioremap(mem->start, mem_size);
+       if (!host->base)
+               goto out;
+
+       ret = -ENXIO;
+       host->clk = clk_get(&pdev->dev, "MMCSDCLK");
+       if (IS_ERR(host->clk)) {
+               ret = PTR_ERR(host->clk);
+               goto out;
+       }
+       clk_enable(host->clk);
+       host->mmc_input_clk = clk_get_rate(host->clk);
+
+       init_mmcsd_host(host);
+
+       host->use_dma = use_dma;
+       host->irq = irq;
+
+       if (host->use_dma && davinci_acquire_dma_channels(host) != 0)
+               host->use_dma = 0;
+
+       /* REVISIT:  someday, support IRQ-driven card detection.  */
+       mmc->caps |= MMC_CAP_NEEDS_POLL;
+
+       if (!pdata || pdata->wires == 4 || pdata->wires == 0)
+               mmc->caps |= MMC_CAP_4_BIT_DATA;
+
+       host->version = pdata->version;
+
+       mmc->ops = &mmc_davinci_ops;
+       mmc->f_min = 312500;
+       mmc->f_max = 25000000;
+       if (pdata && pdata->max_freq)
+               mmc->f_max = pdata->max_freq;
+       if (pdata && pdata->caps)
+               mmc->caps |= pdata->caps;
+       mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+
+       /* With no iommu coalescing pages, each phys_seg is a hw_seg.
+        * Each hw_seg uses one EDMA parameter RAM slot, always one
+        * channel and then usually some linked slots.
+        */
+       mmc->max_hw_segs        = 1 + host->n_link;
+       mmc->max_phys_segs      = mmc->max_hw_segs;
+
+       /* EDMA limit per hw segment (one or two MBytes) */
+       mmc->max_seg_size       = MAX_CCNT * rw_threshold;
+
+       /* MMC/SD controller limits for multiblock requests */
+       mmc->max_blk_size       = 4095;  /* BLEN is 12 bits */
+       mmc->max_blk_count      = 65535; /* NBLK is 16 bits */
+       mmc->max_req_size       = mmc->max_blk_size * mmc->max_blk_count;
+
+       dev_dbg(mmc_dev(host->mmc), "max_phys_segs=%d\n", mmc->max_phys_segs);
+       dev_dbg(mmc_dev(host->mmc), "max_hw_segs=%d\n", mmc->max_hw_segs);
+       dev_dbg(mmc_dev(host->mmc), "max_blk_size=%d\n", mmc->max_blk_size);
+       dev_dbg(mmc_dev(host->mmc), "max_req_size=%d\n", mmc->max_req_size);
+       dev_dbg(mmc_dev(host->mmc), "max_seg_size=%d\n", mmc->max_seg_size);
+
+       platform_set_drvdata(pdev, host);
+
+       ret = mmc_davinci_cpufreq_register(host);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to register cpufreq\n");
+               goto cpu_freq_fail;
+       }
+
+       ret = mmc_add_host(mmc);
+       if (ret < 0)
+               goto out;
+
+       ret = request_irq(irq, mmc_davinci_irq, 0, mmc_hostname(mmc), host);
+       if (ret)
+               goto out;
+
+       rename_region(mem, mmc_hostname(mmc));
+
+       dev_info(mmc_dev(host->mmc), "Using %s, %d-bit mode\n",
+               host->use_dma ? "DMA" : "PIO",
+               (mmc->caps & MMC_CAP_4_BIT_DATA) ? 4 : 1);
+
+       return 0;
+
+out:
+       mmc_davinci_cpufreq_deregister(host);
+cpu_freq_fail:
+       if (host) {
+               davinci_release_dma_channels(host);
+
+               if (host->clk) {
+                       clk_disable(host->clk);
+                       clk_put(host->clk);
+               }
+
+               if (host->base)
+                       iounmap(host->base);
+       }
+
+       if (mmc)
+               mmc_free_host(mmc);
+
+       if (mem)
+               release_resource(mem);
+
+       dev_dbg(&pdev->dev, "probe err %d\n", ret);
+
+       return ret;
+}
+
+static int __exit davinci_mmcsd_remove(struct platform_device *pdev)
+{
+       struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+
+       platform_set_drvdata(pdev, NULL);
+       if (host) {
+               mmc_davinci_cpufreq_deregister(host);
+
+               mmc_remove_host(host->mmc);
+               free_irq(host->irq, host);
+
+               davinci_release_dma_channels(host);
+
+               clk_disable(host->clk);
+               clk_put(host->clk);
+
+               iounmap(host->base);
+
+               release_resource(host->mem_res);
+
+               mmc_free_host(host->mmc);
+       }
+
+       return 0;
+}
+
+#ifdef CONFIG_PM
+static int davinci_mmcsd_suspend(struct platform_device *pdev, pm_message_t msg)
+{
+       struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+
+       return mmc_suspend_host(host->mmc, msg);
+}
+
+static int davinci_mmcsd_resume(struct platform_device *pdev)
+{
+       struct mmc_davinci_host *host = platform_get_drvdata(pdev);
+
+       return mmc_resume_host(host->mmc);
+}
+#else
+#define davinci_mmcsd_suspend  NULL
+#define davinci_mmcsd_resume   NULL
+#endif
+
+static struct platform_driver davinci_mmcsd_driver = {
+       .driver         = {
+               .name   = "davinci_mmc",
+               .owner  = THIS_MODULE,
+       },
+       .remove         = __exit_p(davinci_mmcsd_remove),
+       .suspend        = davinci_mmcsd_suspend,
+       .resume         = davinci_mmcsd_resume,
+};
+
+static int __init davinci_mmcsd_init(void)
+{
+       return platform_driver_probe(&davinci_mmcsd_driver,
+                                    davinci_mmcsd_probe);
+}
+module_init(davinci_mmcsd_init);
+
+static void __exit davinci_mmcsd_exit(void)
+{
+       platform_driver_unregister(&davinci_mmcsd_driver);
+}
+module_exit(davinci_mmcsd_exit);
+
+MODULE_AUTHOR("Texas Instruments India");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("MMC/SD driver for Davinci MMC controller");
+
index 88671529c45d7690061f289d8fe005abd4701a09..60a2b69e54f569e6336c8efa2c25f8c05697a192 100644 (file)
@@ -679,17 +679,17 @@ static int mxcmci_probe(struct platform_device *pdev)
 {
        struct mmc_host *mmc;
        struct mxcmci_host *host = NULL;
-       struct resource *r;
+       struct resource *iores, *r;
        int ret = 0, irq;
 
        printk(KERN_INFO "i.MX SDHC driver\n");
 
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
-       if (!r || irq < 0)
+       if (!iores || irq < 0)
                return -EINVAL;
 
-       r = request_mem_region(r->start, resource_size(r), pdev->name);
+       r = request_mem_region(iores->start, resource_size(iores), pdev->name);
        if (!r)
                return -EBUSY;
 
@@ -809,7 +809,7 @@ out_iounmap:
 out_free:
        mmc_free_host(mmc);
 out_release_mem:
-       release_mem_region(host->res->start, resource_size(host->res));
+       release_mem_region(iores->start, resource_size(iores));
        return ret;
 }
 
index 5f970e253e500f2709dea4e04bb3b45565f5c39a..c6d7e8ecadbf586691d484cdbf7b94b7f4550913 100644 (file)
@@ -1459,8 +1459,10 @@ static int __init mmc_omap_probe(struct platform_device *pdev)
                goto err_ioremap;
 
        host->iclk = clk_get(&pdev->dev, "ick");
-       if (IS_ERR(host->iclk))
+       if (IS_ERR(host->iclk)) {
+               ret = PTR_ERR(host->iclk);
                goto err_free_mmc_host;
+       }
        clk_enable(host->iclk);
 
        host->fclk = clk_get(&pdev->dev, "fck");
@@ -1500,10 +1502,8 @@ err_free_irq:
 err_free_fclk:
        clk_put(host->fclk);
 err_free_iclk:
-       if (host->iclk != NULL) {
-               clk_disable(host->iclk);
-               clk_put(host->iclk);
-       }
+       clk_disable(host->iclk);
+       clk_put(host->iclk);
 err_free_mmc_host:
        iounmap(host->virt_base);
 err_ioremap:
index bb47ff465c04d30acaeb1fc2a0463b785bb63917..0d783f3e79edf609f2297c7eaab42240d678feb0 100644 (file)
@@ -828,7 +828,7 @@ static int pxamci_resume(struct device *dev)
        return ret;
 }
 
-static struct dev_pm_ops pxamci_pm_ops = {
+static const struct dev_pm_ops pxamci_pm_ops = {
        .suspend        = pxamci_suspend,
        .resume         = pxamci_resume,
 };
index 941a4d35ef8da44cdc627bee9dde0a06a9b0455e..d96e1abf2d64a77fae5a52b0c82e9db8c697ecfc 100644 (file)
@@ -820,7 +820,7 @@ fail_request:
 static void finalize_request(struct s3cmci_host *host)
 {
        struct mmc_request *mrq = host->mrq;
-       struct mmc_command *cmd = host->cmd_is_stop ? mrq->stop : mrq->cmd;
+       struct mmc_command *cmd;
        int debug_as_failure = 0;
 
        if (host->complete_what != COMPLETION_FINALIZE)
@@ -828,6 +828,7 @@ static void finalize_request(struct s3cmci_host *host)
 
        if (!mrq)
                return;
+       cmd = host->cmd_is_stop ? mrq->stop : mrq->cmd;
 
        if (cmd->data && (cmd->error == 0) &&
            (cmd->data->error == 0)) {
@@ -1302,10 +1303,8 @@ static int s3cmci_get_ro(struct mmc_host *mmc)
        if (pdata->no_wprotect)
                return 0;
 
-       ret = s3c2410_gpio_getpin(pdata->gpio_wprotect);
-
-       if (pdata->wprotect_invert)
-               ret = !ret;
+       ret = gpio_get_value(pdata->gpio_wprotect) ? 1 : 0;
+       ret ^= pdata->wprotect_invert;
 
        return ret;
 }
@@ -1654,7 +1653,7 @@ static int __devinit s3cmci_probe(struct platform_device *pdev)
                        goto probe_free_irq;
                }
 
-               host->irq_cd = s3c2410_gpio_getirq(host->pdata->gpio_detect);
+               host->irq_cd = gpio_to_irq(host->pdata->gpio_detect);
 
                if (host->irq_cd >= 0) {
                        if (request_irq(host->irq_cd, s3cmci_irq_cd,
@@ -1892,7 +1891,7 @@ static int s3cmci_resume(struct device *dev)
        return mmc_resume_host(mmc);
 }
 
-static struct dev_pm_ops s3cmci_pm = {
+static const struct dev_pm_ops s3cmci_pm = {
        .suspend        = s3cmci_suspend,
        .resume         = s3cmci_resume,
 };
similarity index 58%
rename from drivers/mmc/host/sdhci-of.c
rename to drivers/mmc/host/sdhci-of-core.c
index 01ab916c2802dc90e21bc7aa7513c2d5c0fa2cb6..55e33135edb4dbc60b800e9207b7ae1b0e3b8139 100644 (file)
 #include <linux/of_platform.h>
 #include <linux/mmc/host.h>
 #include <asm/machdep.h>
+#include "sdhci-of.h"
 #include "sdhci.h"
 
-struct sdhci_of_data {
-       unsigned int quirks;
-       struct sdhci_ops ops;
-};
-
-struct sdhci_of_host {
-       unsigned int clock;
-       u16 xfer_mode_shadow;
-};
+#ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
 
 /*
- * Ops and quirks for the Freescale eSDHC controller.
+ * These accessors are designed for big endian hosts doing I/O to
+ * little endian controllers incorporating a 32-bit hardware byte swapper.
  */
 
-#define ESDHC_DMA_SYSCTL       0x40c
-#define ESDHC_DMA_SNOOP                0x00000040
-
-#define ESDHC_SYSTEM_CONTROL   0x2c
-#define ESDHC_CLOCK_MASK       0x0000fff0
-#define ESDHC_PREDIV_SHIFT     8
-#define ESDHC_DIVIDER_SHIFT    4
-#define ESDHC_CLOCK_PEREN      0x00000004
-#define ESDHC_CLOCK_HCKEN      0x00000002
-#define ESDHC_CLOCK_IPGEN      0x00000001
-
-#define ESDHC_HOST_CONTROL_RES 0x05
-
-static u32 esdhc_readl(struct sdhci_host *host, int reg)
+u32 sdhci_be32bs_readl(struct sdhci_host *host, int reg)
 {
        return in_be32(host->ioaddr + reg);
 }
 
-static u16 esdhc_readw(struct sdhci_host *host, int reg)
+u16 sdhci_be32bs_readw(struct sdhci_host *host, int reg)
 {
-       u16 ret;
-
-       if (unlikely(reg == SDHCI_HOST_VERSION))
-               ret = in_be16(host->ioaddr + reg);
-       else
-               ret = in_be16(host->ioaddr + (reg ^ 0x2));
-       return ret;
+       return in_be16(host->ioaddr + (reg ^ 0x2));
 }
 
-static u8 esdhc_readb(struct sdhci_host *host, int reg)
+u8 sdhci_be32bs_readb(struct sdhci_host *host, int reg)
 {
        return in_8(host->ioaddr + (reg ^ 0x3));
 }
 
-static void esdhc_writel(struct sdhci_host *host, u32 val, int reg)
+void sdhci_be32bs_writel(struct sdhci_host *host, u32 val, int reg)
 {
        out_be32(host->ioaddr + reg, val);
 }
 
-static void esdhc_writew(struct sdhci_host *host, u16 val, int reg)
+void sdhci_be32bs_writew(struct sdhci_host *host, u16 val, int reg)
 {
        struct sdhci_of_host *of_host = sdhci_priv(host);
        int base = reg & ~0x3;
@@ -92,106 +67,21 @@ static void esdhc_writew(struct sdhci_host *host, u16 val, int reg)
                of_host->xfer_mode_shadow = val;
                return;
        case SDHCI_COMMAND:
-               esdhc_writel(host, val << 16 | of_host->xfer_mode_shadow,
-                            SDHCI_TRANSFER_MODE);
+               sdhci_be32bs_writel(host, val << 16 | of_host->xfer_mode_shadow,
+                                   SDHCI_TRANSFER_MODE);
                return;
-       case SDHCI_BLOCK_SIZE:
-               /*
-                * Two last DMA bits are reserved, and first one is used for
-                * non-standard blksz of 4096 bytes that we don't support
-                * yet. So clear the DMA boundary bits.
-                */
-               val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);
-               /* fall through */
        }
        clrsetbits_be32(host->ioaddr + base, 0xffff << shift, val << shift);
 }
 
-static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg)
+void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg)
 {
        int base = reg & ~0x3;
        int shift = (reg & 0x3) * 8;
 
-       /* Prevent SDHCI core from writing reserved bits (e.g. HISPD). */
-       if (reg == SDHCI_HOST_CONTROL)
-               val &= ~ESDHC_HOST_CONTROL_RES;
-
        clrsetbits_be32(host->ioaddr + base , 0xff << shift, val << shift);
 }
-
-static void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
-{
-       int pre_div = 2;
-       int div = 1;
-
-       clrbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN |
-                 ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | ESDHC_CLOCK_MASK);
-
-       if (clock == 0)
-               goto out;
-
-       while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
-               pre_div *= 2;
-
-       while (host->max_clk / pre_div / div > clock && div < 16)
-               div++;
-
-       dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
-               clock, host->max_clk / pre_div / div);
-
-       pre_div >>= 1;
-       div--;
-
-       setbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN |
-                 ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN |
-                 div << ESDHC_DIVIDER_SHIFT | pre_div << ESDHC_PREDIV_SHIFT);
-       mdelay(100);
-out:
-       host->clock = clock;
-}
-
-static int esdhc_enable_dma(struct sdhci_host *host)
-{
-       setbits32(host->ioaddr + ESDHC_DMA_SYSCTL, ESDHC_DMA_SNOOP);
-       return 0;
-}
-
-static unsigned int esdhc_get_max_clock(struct sdhci_host *host)
-{
-       struct sdhci_of_host *of_host = sdhci_priv(host);
-
-       return of_host->clock;
-}
-
-static unsigned int esdhc_get_min_clock(struct sdhci_host *host)
-{
-       struct sdhci_of_host *of_host = sdhci_priv(host);
-
-       return of_host->clock / 256 / 16;
-}
-
-static struct sdhci_of_data sdhci_esdhc = {
-       .quirks = SDHCI_QUIRK_FORCE_BLK_SZ_2048 |
-                 SDHCI_QUIRK_BROKEN_CARD_DETECTION |
-                 SDHCI_QUIRK_NO_BUSY_IRQ |
-                 SDHCI_QUIRK_NONSTANDARD_CLOCK |
-                 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
-                 SDHCI_QUIRK_PIO_NEEDS_DELAY |
-                 SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET |
-                 SDHCI_QUIRK_NO_CARD_NO_RESET,
-       .ops = {
-               .readl = esdhc_readl,
-               .readw = esdhc_readw,
-               .readb = esdhc_readb,
-               .writel = esdhc_writel,
-               .writew = esdhc_writew,
-               .writeb = esdhc_writeb,
-               .set_clock = esdhc_set_clock,
-               .enable_dma = esdhc_enable_dma,
-               .get_max_clock = esdhc_get_max_clock,
-               .get_min_clock = esdhc_get_min_clock,
-       },
-};
+#endif /* CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER */
 
 #ifdef CONFIG_PM
 
@@ -301,9 +191,14 @@ static int __devexit sdhci_of_remove(struct of_device *ofdev)
 }
 
 static const struct of_device_id sdhci_of_match[] = {
+#ifdef CONFIG_MMC_SDHCI_OF_ESDHC
        { .compatible = "fsl,mpc8379-esdhc", .data = &sdhci_esdhc, },
        { .compatible = "fsl,mpc8536-esdhc", .data = &sdhci_esdhc, },
        { .compatible = "fsl,esdhc", .data = &sdhci_esdhc, },
+#endif
+#ifdef CONFIG_MMC_SDHCI_OF_HLWD
+       { .compatible = "nintendo,hollywood-sdhci", .data = &sdhci_hlwd, },
+#endif
        { .compatible = "generic-sdhci", },
        {},
 };
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
new file mode 100644 (file)
index 0000000..d5b11a1
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Freescale eSDHC controller driver.
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ * Copyright (c) 2009 MontaVista Software, Inc.
+ *
+ * Authors: Xiaobo Xie <X.Xie@freescale.com>
+ *         Anton Vorontsov <avorontsov@ru.mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+
+#include <linux/io.h>
+#include <linux/delay.h>
+#include <linux/mmc/host.h>
+#include "sdhci-of.h"
+#include "sdhci.h"
+
+/*
+ * Ops and quirks for the Freescale eSDHC controller.
+ */
+
+#define ESDHC_DMA_SYSCTL       0x40c
+#define ESDHC_DMA_SNOOP                0x00000040
+
+#define ESDHC_SYSTEM_CONTROL   0x2c
+#define ESDHC_CLOCK_MASK       0x0000fff0
+#define ESDHC_PREDIV_SHIFT     8
+#define ESDHC_DIVIDER_SHIFT    4
+#define ESDHC_CLOCK_PEREN      0x00000004
+#define ESDHC_CLOCK_HCKEN      0x00000002
+#define ESDHC_CLOCK_IPGEN      0x00000001
+
+#define ESDHC_HOST_CONTROL_RES 0x05
+
+static u16 esdhc_readw(struct sdhci_host *host, int reg)
+{
+       u16 ret;
+
+       if (unlikely(reg == SDHCI_HOST_VERSION))
+               ret = in_be16(host->ioaddr + reg);
+       else
+               ret = sdhci_be32bs_readw(host, reg);
+       return ret;
+}
+
+static void esdhc_writew(struct sdhci_host *host, u16 val, int reg)
+{
+       if (reg == SDHCI_BLOCK_SIZE) {
+               /*
+                * Two last DMA bits are reserved, and first one is used for
+                * non-standard blksz of 4096 bytes that we don't support
+                * yet. So clear the DMA boundary bits.
+                */
+               val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);
+       }
+       sdhci_be32bs_writew(host, val, reg);
+}
+
+static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg)
+{
+       /* Prevent SDHCI core from writing reserved bits (e.g. HISPD). */
+       if (reg == SDHCI_HOST_CONTROL)
+               val &= ~ESDHC_HOST_CONTROL_RES;
+       sdhci_be32bs_writeb(host, val, reg);
+}
+
+static void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+       int pre_div = 2;
+       int div = 1;
+
+       clrbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN |
+                 ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | ESDHC_CLOCK_MASK);
+
+       if (clock == 0)
+               goto out;
+
+       while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
+               pre_div *= 2;
+
+       while (host->max_clk / pre_div / div > clock && div < 16)
+               div++;
+
+       dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
+               clock, host->max_clk / pre_div / div);
+
+       pre_div >>= 1;
+       div--;
+
+       setbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN |
+                 ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN |
+                 div << ESDHC_DIVIDER_SHIFT | pre_div << ESDHC_PREDIV_SHIFT);
+       mdelay(100);
+out:
+       host->clock = clock;
+}
+
+static int esdhc_enable_dma(struct sdhci_host *host)
+{
+       setbits32(host->ioaddr + ESDHC_DMA_SYSCTL, ESDHC_DMA_SNOOP);
+       return 0;
+}
+
+static unsigned int esdhc_get_max_clock(struct sdhci_host *host)
+{
+       struct sdhci_of_host *of_host = sdhci_priv(host);
+
+       return of_host->clock;
+}
+
+static unsigned int esdhc_get_min_clock(struct sdhci_host *host)
+{
+       struct sdhci_of_host *of_host = sdhci_priv(host);
+
+       return of_host->clock / 256 / 16;
+}
+
+struct sdhci_of_data sdhci_esdhc = {
+       .quirks = SDHCI_QUIRK_FORCE_BLK_SZ_2048 |
+                 SDHCI_QUIRK_BROKEN_CARD_DETECTION |
+                 SDHCI_QUIRK_NO_BUSY_IRQ |
+                 SDHCI_QUIRK_NONSTANDARD_CLOCK |
+                 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
+                 SDHCI_QUIRK_PIO_NEEDS_DELAY |
+                 SDHCI_QUIRK_RESTORE_IRQS_AFTER_RESET |
+                 SDHCI_QUIRK_NO_CARD_NO_RESET,
+       .ops = {
+               .readl = sdhci_be32bs_readl,
+               .readw = esdhc_readw,
+               .readb = sdhci_be32bs_readb,
+               .writel = sdhci_be32bs_writel,
+               .writew = esdhc_writew,
+               .writeb = esdhc_writeb,
+               .set_clock = esdhc_set_clock,
+               .enable_dma = esdhc_enable_dma,
+               .get_max_clock = esdhc_get_max_clock,
+               .get_min_clock = esdhc_get_min_clock,
+       },
+};
diff --git a/drivers/mmc/host/sdhci-of-hlwd.c b/drivers/mmc/host/sdhci-of-hlwd.c
new file mode 100644 (file)
index 0000000..35117f3
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * drivers/mmc/host/sdhci-of-hlwd.c
+ *
+ * Nintendo Wii Secure Digital Host Controller Interface.
+ * Copyright (C) 2009 The GameCube Linux Team
+ * Copyright (C) 2009 Albert Herranz
+ *
+ * Based on sdhci-of-esdhc.c
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ * Copyright (c) 2009 MontaVista Software, Inc.
+ *
+ * Authors: Xiaobo Xie <X.Xie@freescale.com>
+ *         Anton Vorontsov <avorontsov@ru.mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+
+#include <linux/delay.h>
+#include <linux/mmc/host.h>
+#include "sdhci-of.h"
+#include "sdhci.h"
+
+/*
+ * Ops and quirks for the Nintendo Wii SDHCI controllers.
+ */
+
+/*
+ * We need a small delay after each write, or things go horribly wrong.
+ */
+#define SDHCI_HLWD_WRITE_DELAY 5 /* usecs */
+
+static void sdhci_hlwd_writel(struct sdhci_host *host, u32 val, int reg)
+{
+       sdhci_be32bs_writel(host, val, reg);
+       udelay(SDHCI_HLWD_WRITE_DELAY);
+}
+
+static void sdhci_hlwd_writew(struct sdhci_host *host, u16 val, int reg)
+{
+       sdhci_be32bs_writew(host, val, reg);
+       udelay(SDHCI_HLWD_WRITE_DELAY);
+}
+
+static void sdhci_hlwd_writeb(struct sdhci_host *host, u8 val, int reg)
+{
+       sdhci_be32bs_writeb(host, val, reg);
+       udelay(SDHCI_HLWD_WRITE_DELAY);
+}
+
+struct sdhci_of_data sdhci_hlwd = {
+       .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR |
+                 SDHCI_QUIRK_32BIT_DMA_SIZE,
+       .ops = {
+               .readl = sdhci_be32bs_readl,
+               .readw = sdhci_be32bs_readw,
+               .readb = sdhci_be32bs_readb,
+               .writel = sdhci_hlwd_writel,
+               .writew = sdhci_hlwd_writew,
+               .writeb = sdhci_hlwd_writeb,
+       },
+};
diff --git a/drivers/mmc/host/sdhci-of.h b/drivers/mmc/host/sdhci-of.h
new file mode 100644 (file)
index 0000000..ad09ad9
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * OpenFirmware bindings for Secure Digital Host Controller Interface.
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ * Copyright (c) 2009 MontaVista Software, Inc.
+ *
+ * Authors: Xiaobo Xie <X.Xie@freescale.com>
+ *         Anton Vorontsov <avorontsov@ru.mvista.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+
+#ifndef __SDHCI_OF_H
+#define __SDHCI_OF_H
+
+#include <linux/types.h>
+#include "sdhci.h"
+
+struct sdhci_of_data {
+       unsigned int quirks;
+       struct sdhci_ops ops;
+};
+
+struct sdhci_of_host {
+       unsigned int clock;
+       u16 xfer_mode_shadow;
+};
+
+extern u32 sdhci_be32bs_readl(struct sdhci_host *host, int reg);
+extern u16 sdhci_be32bs_readw(struct sdhci_host *host, int reg);
+extern u8 sdhci_be32bs_readb(struct sdhci_host *host, int reg);
+extern void sdhci_be32bs_writel(struct sdhci_host *host, u32 val, int reg);
+extern void sdhci_be32bs_writew(struct sdhci_host *host, u16 val, int reg);
+extern void sdhci_be32bs_writeb(struct sdhci_host *host, u8 val, int reg);
+
+extern struct sdhci_of_data sdhci_esdhc;
+extern struct sdhci_of_data sdhci_hlwd;
+
+#endif /* __SDHCI_OF_H */
index e0356644d1aa4592faa28ccccb485d5cab944087..5c3a1767770a2cb78d1c726abeaaec39a84113f7 100644 (file)
@@ -285,6 +285,73 @@ static const struct sdhci_pci_fixes sdhci_jmicron = {
        .resume         = jmicron_resume,
 };
 
+/* SysKonnect CardBus2SDIO extra registers */
+#define SYSKT_CTRL             0x200
+#define SYSKT_RDFIFO_STAT      0x204
+#define SYSKT_WRFIFO_STAT      0x208
+#define SYSKT_POWER_DATA       0x20c
+#define   SYSKT_POWER_330      0xef
+#define   SYSKT_POWER_300      0xf8
+#define   SYSKT_POWER_184      0xcc
+#define SYSKT_POWER_CMD                0x20d
+#define   SYSKT_POWER_START    (1 << 7)
+#define SYSKT_POWER_STATUS     0x20e
+#define   SYSKT_POWER_STATUS_OK        (1 << 0)
+#define SYSKT_BOARD_REV                0x210
+#define SYSKT_CHIP_REV         0x211
+#define SYSKT_CONF_DATA                0x212
+#define   SYSKT_CONF_DATA_1V8  (1 << 2)
+#define   SYSKT_CONF_DATA_2V5  (1 << 1)
+#define   SYSKT_CONF_DATA_3V3  (1 << 0)
+
+static int syskt_probe(struct sdhci_pci_chip *chip)
+{
+       if ((chip->pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) {
+               chip->pdev->class &= ~0x0000FF;
+               chip->pdev->class |= PCI_SDHCI_IFDMA;
+       }
+       return 0;
+}
+
+static int syskt_probe_slot(struct sdhci_pci_slot *slot)
+{
+       int tm, ps;
+
+       u8 board_rev = readb(slot->host->ioaddr + SYSKT_BOARD_REV);
+       u8  chip_rev = readb(slot->host->ioaddr + SYSKT_CHIP_REV);
+       dev_info(&slot->chip->pdev->dev, "SysKonnect CardBus2SDIO, "
+                                        "board rev %d.%d, chip rev %d.%d\n",
+                                        board_rev >> 4, board_rev & 0xf,
+                                        chip_rev >> 4,  chip_rev & 0xf);
+       if (chip_rev >= 0x20)
+               slot->host->quirks |= SDHCI_QUIRK_FORCE_DMA;
+
+       writeb(SYSKT_POWER_330, slot->host->ioaddr + SYSKT_POWER_DATA);
+       writeb(SYSKT_POWER_START, slot->host->ioaddr + SYSKT_POWER_CMD);
+       udelay(50);
+       tm = 10;  /* Wait max 1 ms */
+       do {
+               ps = readw(slot->host->ioaddr + SYSKT_POWER_STATUS);
+               if (ps & SYSKT_POWER_STATUS_OK)
+                       break;
+               udelay(100);
+       } while (--tm);
+       if (!tm) {
+               dev_err(&slot->chip->pdev->dev,
+                       "power regulator never stabilized");
+               writeb(0, slot->host->ioaddr + SYSKT_POWER_CMD);
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
+static const struct sdhci_pci_fixes sdhci_syskt = {
+       .quirks         = SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER,
+       .probe          = syskt_probe,
+       .probe_slot     = syskt_probe_slot,
+};
+
 static int via_probe(struct sdhci_pci_chip *chip)
 {
        if (chip->pdev->revision == 0x10)
@@ -362,6 +429,14 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
                .driver_data    = (kernel_ulong_t)&sdhci_jmicron,
        },
 
+       {
+               .vendor         = PCI_VENDOR_ID_SYSKONNECT,
+               .device         = 0x8000,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+               .driver_data    = (kernel_ulong_t)&sdhci_syskt,
+       },
+
        {
                .vendor         = PCI_VENDOR_ID_VIA,
                .device         = 0x95d0,
index ce5f1d73dc04667841c6da99973500e9e3c96e7f..842f46f9428469657679e45c1b5b1dc8097c694f 100644 (file)
@@ -8,6 +8,8 @@
  * the Free Software Foundation; either version 2 of the License, or (at
  * your option) any later version.
  */
+#ifndef __SDHCI_H
+#define __SDHCI_H
 
 #include <linux/scatterlist.h>
 #include <linux/compiler.h>
@@ -408,3 +410,5 @@ extern void sdhci_remove_host(struct sdhci_host *host, int dead);
 extern int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state);
 extern int sdhci_resume_host(struct sdhci_host *host);
 #endif
+
+#endif /* __SDHCI_H */
index 91991b460c4547c7a90a583ca987f087c6babd53..7cccc852374772d4d2479e4eb9f681a5bdb74bb5 100644 (file)
@@ -591,7 +591,7 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev)
        disable_mmc_irqs(host, TMIO_MASK_ALL);
 
        ret = request_irq(host->irq, tmio_mmc_irq, IRQF_DISABLED |
-               IRQF_TRIGGER_FALLING, "tmio-mmc", host);
+               IRQF_TRIGGER_FALLING, dev_name(&dev->dev), host);
        if (ret)
                goto unmap_cnf;
 
index e7563a9872d0af6404f64adae9610a9fffad027f..5fbf29e1e64fcfc9aa7a55ece397670bb79d683a 100644 (file)
 // debugging, turns off buffer write mode if set to 1
 #define FORCE_WORD_WRITE 0
 
-#define MANUFACTURER_INTEL     0x0089
+/* Intel chips */
 #define I82802AB       0x00ad
 #define I82802AC       0x00ac
 #define PF38F4476      0x881c
-#define MANUFACTURER_ST         0x0020
+/* STMicroelectronics chips */
 #define M50LPW080       0x002F
 #define M50FLW080A     0x0080
 #define M50FLW080B     0x0081
+/* Atmel chips */
 #define AT49BV640D     0x02de
+#define AT49BV640DT    0x02db
 
 static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
 static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
@@ -199,6 +201,16 @@ static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param)
        cfi->cfiq->BufWriteTimeoutMax = 0;
 }
 
+static void fixup_at49bv640dx_lock(struct mtd_info *mtd, void *param)
+{
+       struct map_info *map = mtd->priv;
+       struct cfi_private *cfi = map->fldrv_priv;
+       struct cfi_pri_intelext *cfip = cfi->cmdset_priv;
+
+       cfip->FeatureSupport |= (1 << 5);
+       mtd->flags |= MTD_POWERUP_LOCK;
+}
+
 #ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
 /* Some Intel Strata Flash prior to FPO revision C has bugs in this area */
 static void fixup_intel_strataflash(struct mtd_info *mtd, void* param)
@@ -283,6 +295,8 @@ static void fixup_unlock_powerup_lock(struct mtd_info *mtd, void *param)
 
 static struct cfi_fixup cfi_fixup_table[] = {
        { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
+       { CFI_MFR_ATMEL, AT49BV640D, fixup_at49bv640dx_lock, NULL },
+       { CFI_MFR_ATMEL, AT49BV640DT, fixup_at49bv640dx_lock, NULL },
 #ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE
        { CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL },
 #endif
@@ -294,16 +308,16 @@ static struct cfi_fixup cfi_fixup_table[] = {
 #endif
        { CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct, NULL },
        { CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb, NULL },
-       { MANUFACTURER_INTEL, CFI_ID_ANY, fixup_unlock_powerup_lock, NULL, },
+       { CFI_MFR_INTEL, CFI_ID_ANY, fixup_unlock_powerup_lock, NULL, },
        { 0, 0, NULL, NULL }
 };
 
 static struct cfi_fixup jedec_fixup_table[] = {
-       { MANUFACTURER_INTEL, I82802AB,   fixup_use_fwh_lock, NULL, },
-       { MANUFACTURER_INTEL, I82802AC,   fixup_use_fwh_lock, NULL, },
-       { MANUFACTURER_ST,    M50LPW080,  fixup_use_fwh_lock, NULL, },
-       { MANUFACTURER_ST,    M50FLW080A, fixup_use_fwh_lock, NULL, },
-       { MANUFACTURER_ST,    M50FLW080B, fixup_use_fwh_lock, NULL, },
+       { CFI_MFR_INTEL, I82802AB,   fixup_use_fwh_lock, NULL, },
+       { CFI_MFR_INTEL, I82802AC,   fixup_use_fwh_lock, NULL, },
+       { CFI_MFR_ST,    M50LPW080,  fixup_use_fwh_lock, NULL, },
+       { CFI_MFR_ST,    M50FLW080A, fixup_use_fwh_lock, NULL, },
+       { CFI_MFR_ST,    M50FLW080B, fixup_use_fwh_lock, NULL, },
        { 0, 0, NULL, NULL }
 };
 static struct cfi_fixup fixup_table[] = {
@@ -319,7 +333,7 @@ static struct cfi_fixup fixup_table[] = {
 static void cfi_fixup_major_minor(struct cfi_private *cfi,
                                                struct cfi_pri_intelext *extp)
 {
-       if (cfi->mfr == MANUFACTURER_INTEL &&
+       if (cfi->mfr == CFI_MFR_INTEL &&
                        cfi->id == PF38F4476 && extp->MinorVersion == '3')
                extp->MinorVersion = '1';
 }
@@ -2235,7 +2249,7 @@ static int cfi_intelext_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
 
        /* Some chips have OTP located in the _top_ partition only.
           For example: Intel 28F256L18T (T means top-parameter device) */
-       if (cfi->mfr == MANUFACTURER_INTEL) {
+       if (cfi->mfr == CFI_MFR_INTEL) {
                switch (cfi->id) {
                case 0x880b:
                case 0x880c:
@@ -2564,6 +2578,7 @@ static int cfi_intelext_reset(struct mtd_info *mtd)
                if (!ret) {
                        map_write(map, CMD(0xff), chip->start);
                        chip->state = FL_SHUTDOWN;
+                       put_chip(map, chip, chip->start);
                }
                spin_unlock(chip->mutex);
        }
index 94bb61e19047764ae06dcf91408946219869fa06..f3600e8d5382ba9536161340e8196e6b23c0f305 100644 (file)
@@ -490,10 +490,6 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
        }
 #endif
 
-       /* FIXME: erase-suspend-program is broken.  See
-          http://lists.infradead.org/pipermail/linux-mtd/2003-December/009001.html */
-       printk(KERN_NOTICE "cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.\n");
-
        __module_get(THIS_MODULE);
        return mtd;
 
@@ -573,7 +569,6 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
 
                        if (time_after(jiffies, timeo)) {
                                printk(KERN_ERR "Waiting for chip to be ready timed out.\n");
-                               spin_unlock(chip->mutex);
                                return -EIO;
                        }
                        spin_unlock(chip->mutex);
@@ -589,15 +584,9 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
                return 0;
 
        case FL_ERASING:
-               if (mode == FL_WRITING) /* FIXME: Erase-suspend-program appears broken. */
-                       goto sleep;
-
-               if (!(   mode == FL_READY
-                     || mode == FL_POINT
-                     || !cfip
-                     || (mode == FL_WRITING && (cfip->EraseSuspend & 0x2))
-                     || (mode == FL_WRITING && (cfip->EraseSuspend & 0x1)
-                   )))
+               if (!cfip || !(cfip->EraseSuspend & (0x1|0x2)) ||
+                   !(mode == FL_READY || mode == FL_POINT ||
+                   (mode == FL_WRITING && (cfip->EraseSuspend & 0x2))))
                        goto sleep;
 
                /* We could check to see if we're trying to access the sector
index c5a84fda54107f32ebb5e00d3ae457914a958aa4..ca584d0380b44a6c6cf798a356894cbe4f630742 100755 (executable)
@@ -69,6 +69,13 @@ int __xipram cfi_qry_mode_on(uint32_t base, struct map_info *map,
        /* ST M29DW chips */
        cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
        cfi_send_gen_cmd(0x98, 0x555, base, map, cfi, cfi->device_type, NULL);
+       if (cfi_qry_present(map, base, cfi))
+               return 1;
+       /* some old SST chips, e.g. 39VF160x/39VF320x */
+       cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+       cfi_send_gen_cmd(0xAA, 0x5555, base, map, cfi, cfi->device_type, NULL);
+       cfi_send_gen_cmd(0x55, 0x2AAA, base, map, cfi, cfi->device_type, NULL);
+       cfi_send_gen_cmd(0x98, 0x5555, base, map, cfi, cfi->device_type, NULL);
        if (cfi_qry_present(map, base, cfi))
                return 1;
        /* QRY not found */
index 736a3be265f2b3da75975dc7af2614b68c58a8ee..1bec5e1ce6acd00153c084e5bed8c12c4b65161e 100644 (file)
 
 /* ST - www.st.com */
 #define M29F800AB      0x0058
-#define M29W800DT      0x00D7
-#define M29W800DB      0x005B
+#define M29W800DT      0x22D7
+#define M29W800DB      0x225B
 #define M29W400DT      0x00EE
 #define M29W400DB      0x00EF
 #define M29W160DT      0x22C4
@@ -1575,7 +1575,7 @@ static const struct amd_flash_info jedec_table[] = {
                .dev_id         = M29W800DT,
                .name           = "ST M29W800DT",
                .devtypes       = CFI_DEVICETYPE_X16|CFI_DEVICETYPE_X8,
-               .uaddr          = MTD_UADDR_0x5555_0x2AAA,      /* ???? */
+               .uaddr          = MTD_UADDR_0x0AAA_0x0555,
                .dev_size       = SIZE_1MiB,
                .cmd_set        = P_ID_AMD_STD,
                .nr_regions     = 4,
@@ -1590,7 +1590,7 @@ static const struct amd_flash_info jedec_table[] = {
                .dev_id         = M29W800DB,
                .name           = "ST M29W800DB",
                .devtypes       = CFI_DEVICETYPE_X16|CFI_DEVICETYPE_X8,
-               .uaddr          = MTD_UADDR_0x5555_0x2AAA,      /* ???? */
+               .uaddr          = MTD_UADDR_0x0AAA_0x0555,
                .dev_size       = SIZE_1MiB,
                .cmd_set        = P_ID_AMD_STD,
                .nr_regions     = 4,
index 4c19269de91a4ad8afb3383ea7f27d10e02325a5..f3f4768d6e18df89ba99e4efc5723c5e6593715d 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/mutex.h>
 #include <linux/math64.h>
 #include <linux/sched.h>
+#include <linux/mod_devicetable.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -29,9 +30,6 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 
-
-#define FLASH_PAGESIZE         256
-
 /* Flash opcodes. */
 #define        OPCODE_WREN             0x06    /* Write enable */
 #define        OPCODE_RDSR             0x05    /* Read status register */
@@ -61,7 +59,7 @@
 
 /* Define max times to check status register before we give up. */
 #define        MAX_READY_WAIT_JIFFIES  (40 * HZ)       /* M25P16 specs 40s max chip erase */
-#define        CMD_SIZE                4
+#define        MAX_CMD_SIZE            4
 
 #ifdef CONFIG_M25PXX_USE_FAST_READ
 #define OPCODE_READ    OPCODE_FAST_READ
@@ -78,8 +76,10 @@ struct m25p {
        struct mutex            lock;
        struct mtd_info         mtd;
        unsigned                partitioned:1;
+       u16                     page_size;
+       u16                     addr_width;
        u8                      erase_opcode;
-       u8                      command[CMD_SIZE + FAST_READ_DUMMY_BYTE];
+       u8                      *command;
 };
 
 static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd)
@@ -198,6 +198,19 @@ static int erase_chip(struct m25p *flash)
        return 0;
 }
 
+static void m25p_addr2cmd(struct m25p *flash, unsigned int addr, u8 *cmd)
+{
+       /* opcode is in cmd[0] */
+       cmd[1] = addr >> (flash->addr_width * 8 -  8);
+       cmd[2] = addr >> (flash->addr_width * 8 - 16);
+       cmd[3] = addr >> (flash->addr_width * 8 - 24);
+}
+
+static int m25p_cmdsz(struct m25p *flash)
+{
+       return 1 + flash->addr_width;
+}
+
 /*
  * Erase one sector of flash memory at offset ``offset'' which is any
  * address within the sector which should be erased.
@@ -219,11 +232,9 @@ static int erase_sector(struct m25p *flash, u32 offset)
 
        /* Set up command buffer. */
        flash->command[0] = flash->erase_opcode;
-       flash->command[1] = offset >> 16;
-       flash->command[2] = offset >> 8;
-       flash->command[3] = offset;
+       m25p_addr2cmd(flash, offset, flash->command);
 
-       spi_write(flash->spi, flash->command, CMD_SIZE);
+       spi_write(flash->spi, flash->command, m25p_cmdsz(flash));
 
        return 0;
 }
@@ -325,7 +336,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,
         * Should add 1 byte DUMMY_BYTE.
         */
        t[0].tx_buf = flash->command;
-       t[0].len = CMD_SIZE + FAST_READ_DUMMY_BYTE;
+       t[0].len = m25p_cmdsz(flash) + FAST_READ_DUMMY_BYTE;
        spi_message_add_tail(&t[0], &m);
 
        t[1].rx_buf = buf;
@@ -352,13 +363,11 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,
 
        /* Set up the write data buffer. */
        flash->command[0] = OPCODE_READ;
-       flash->command[1] = from >> 16;
-       flash->command[2] = from >> 8;
-       flash->command[3] = from;
+       m25p_addr2cmd(flash, from, flash->command);
 
        spi_sync(flash->spi, &m);
 
-       *retlen = m.actual_length - CMD_SIZE - FAST_READ_DUMMY_BYTE;
+       *retlen = m.actual_length - m25p_cmdsz(flash) - FAST_READ_DUMMY_BYTE;
 
        mutex_unlock(&flash->lock);
 
@@ -396,7 +405,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
        memset(t, 0, (sizeof t));
 
        t[0].tx_buf = flash->command;
-       t[0].len = CMD_SIZE;
+       t[0].len = m25p_cmdsz(flash);
        spi_message_add_tail(&t[0], &m);
 
        t[1].tx_buf = buf;
@@ -414,41 +423,36 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
 
        /* Set up the opcode in the write buffer. */
        flash->command[0] = OPCODE_PP;
-       flash->command[1] = to >> 16;
-       flash->command[2] = to >> 8;
-       flash->command[3] = to;
+       m25p_addr2cmd(flash, to, flash->command);
 
-       /* what page do we start with? */
-       page_offset = to % FLASH_PAGESIZE;
+       page_offset = to & (flash->page_size - 1);
 
        /* do all the bytes fit onto one page? */
-       if (page_offset + len <= FLASH_PAGESIZE) {
+       if (page_offset + len <= flash->page_size) {
                t[1].len = len;
 
                spi_sync(flash->spi, &m);
 
-               *retlen = m.actual_length - CMD_SIZE;
+               *retlen = m.actual_length - m25p_cmdsz(flash);
        } else {
                u32 i;
 
                /* the size of data remaining on the first page */
-               page_size = FLASH_PAGESIZE - page_offset;
+               page_size = flash->page_size - page_offset;
 
                t[1].len = page_size;
                spi_sync(flash->spi, &m);
 
-               *retlen = m.actual_length - CMD_SIZE;
+               *retlen = m.actual_length - m25p_cmdsz(flash);
 
-               /* write everything in PAGESIZE chunks */
+               /* write everything in flash->page_size chunks */
                for (i = page_size; i < len; i += page_size) {
                        page_size = len - i;
-                       if (page_size > FLASH_PAGESIZE)
-                               page_size = FLASH_PAGESIZE;
+                       if (page_size > flash->page_size)
+                               page_size = flash->page_size;
 
                        /* write the next page to flash */
-                       flash->command[1] = (to + i) >> 16;
-                       flash->command[2] = (to + i) >> 8;
-                       flash->command[3] = (to + i);
+                       m25p_addr2cmd(flash, to + i, flash->command);
 
                        t[1].tx_buf = buf + i;
                        t[1].len = page_size;
@@ -460,7 +464,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
                        spi_sync(flash->spi, &m);
 
                        if (retlen)
-                               *retlen += m.actual_length - CMD_SIZE;
+                               *retlen += m.actual_length - m25p_cmdsz(flash);
                }
        }
 
@@ -492,7 +496,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
        memset(t, 0, (sizeof t));
 
        t[0].tx_buf = flash->command;
-       t[0].len = CMD_SIZE;
+       t[0].len = m25p_cmdsz(flash);
        spi_message_add_tail(&t[0], &m);
 
        t[1].tx_buf = buf;
@@ -511,9 +515,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
        /* Start write from odd address. */
        if (actual) {
                flash->command[0] = OPCODE_BP;
-               flash->command[1] = to >> 16;
-               flash->command[2] = to >> 8;
-               flash->command[3] = to;
+               m25p_addr2cmd(flash, to, flash->command);
 
                /* write one byte. */
                t[1].len = 1;
@@ -521,17 +523,15 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
                ret = wait_till_ready(flash);
                if (ret)
                        goto time_out;
-               *retlen += m.actual_length - CMD_SIZE;
+               *retlen += m.actual_length - m25p_cmdsz(flash);
        }
        to += actual;
 
        flash->command[0] = OPCODE_AAI_WP;
-       flash->command[1] = to >> 16;
-       flash->command[2] = to >> 8;
-       flash->command[3] = to;
+       m25p_addr2cmd(flash, to, flash->command);
 
        /* Write out most of the data here. */
-       cmd_sz = CMD_SIZE;
+       cmd_sz = m25p_cmdsz(flash);
        for (; actual < len - 1; actual += 2) {
                t[0].len = cmd_sz;
                /* write two bytes. */
@@ -555,10 +555,8 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
        if (actual != len) {
                write_enable(flash);
                flash->command[0] = OPCODE_BP;
-               flash->command[1] = to >> 16;
-               flash->command[2] = to >> 8;
-               flash->command[3] = to;
-               t[0].len = CMD_SIZE;
+               m25p_addr2cmd(flash, to, flash->command);
+               t[0].len = m25p_cmdsz(flash);
                t[1].len = 1;
                t[1].tx_buf = buf + actual;
 
@@ -566,7 +564,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
                ret = wait_till_ready(flash);
                if (ret)
                        goto time_out;
-               *retlen += m.actual_length - CMD_SIZE;
+               *retlen += m.actual_length - m25p_cmdsz(flash);
                write_disable(flash);
        }
 
@@ -582,8 +580,6 @@ time_out:
  */
 
 struct flash_info {
-       char            *name;
-
        /* JEDEC id zero means "no ID" (most older chips); otherwise it has
         * a high byte of zero plus three data bytes: the manufacturer id,
         * then a two byte device id.
@@ -597,87 +593,119 @@ struct flash_info {
        unsigned        sector_size;
        u16             n_sectors;
 
+       u16             page_size;
+       u16             addr_width;
+
        u16             flags;
 #define        SECT_4K         0x01            /* OPCODE_BE_4K works uniformly */
+#define        M25P_NO_ERASE   0x02            /* No erase command needed */
 };
 
+#define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)     \
+       ((kernel_ulong_t)&(struct flash_info) {                         \
+               .jedec_id = (_jedec_id),                                \
+               .ext_id = (_ext_id),                                    \
+               .sector_size = (_sector_size),                          \
+               .n_sectors = (_n_sectors),                              \
+               .page_size = 256,                                       \
+               .addr_width = 3,                                        \
+               .flags = (_flags),                                      \
+       })
+
+#define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_width)  \
+       ((kernel_ulong_t)&(struct flash_info) {                         \
+               .sector_size = (_sector_size),                          \
+               .n_sectors = (_n_sectors),                              \
+               .page_size = (_page_size),                              \
+               .addr_width = (_addr_width),                            \
+               .flags = M25P_NO_ERASE,                                 \
+       })
 
 /* NOTE: double check command sets and memory organization when you add
  * more flash chips.  This current list focusses on newer chips, which
  * have been converging on command sets which including JEDEC ID.
  */
-static struct flash_info __devinitdata m25p_data [] = {
-
+static const struct spi_device_id m25p_ids[] = {
        /* Atmel -- some are (confusingly) marketed as "DataFlash" */
-       { "at25fs010",  0x1f6601, 0, 32 * 1024, 4, SECT_4K, },
-       { "at25fs040",  0x1f6604, 0, 64 * 1024, 8, SECT_4K, },
+       { "at25fs010",  INFO(0x1f6601, 0, 32 * 1024,   4, SECT_4K) },
+       { "at25fs040",  INFO(0x1f6604, 0, 64 * 1024,   8, SECT_4K) },
 
-       { "at25df041a", 0x1f4401, 0, 64 * 1024, 8, SECT_4K, },
-       { "at25df641",  0x1f4800, 0, 64 * 1024, 128, SECT_4K, },
+       { "at25df041a", INFO(0x1f4401, 0, 64 * 1024,   8, SECT_4K) },
+       { "at25df641",  INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) },
 
-       { "at26f004",   0x1f0400, 0, 64 * 1024, 8, SECT_4K, },
-       { "at26df081a", 0x1f4501, 0, 64 * 1024, 16, SECT_4K, },
-       { "at26df161a", 0x1f4601, 0, 64 * 1024, 32, SECT_4K, },
-       { "at26df321",  0x1f4701, 0, 64 * 1024, 64, SECT_4K, },
+       { "at26f004",   INFO(0x1f0400, 0, 64 * 1024,  8, SECT_4K) },
+       { "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K) },
+       { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K) },
+       { "at26df321",  INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K) },
 
        /* Macronix */
-       { "mx25l3205d", 0xc22016, 0, 64 * 1024, 64, },
-       { "mx25l6405d", 0xc22017, 0, 64 * 1024, 128, },
-       { "mx25l12805d", 0xc22018, 0, 64 * 1024, 256, },
-       { "mx25l12855e", 0xc22618, 0, 64 * 1024, 256, },
+       { "mx25l4005a",  INFO(0xc22013, 0, 64 * 1024,   8, SECT_4K) },
+       { "mx25l3205d",  INFO(0xc22016, 0, 64 * 1024,  64, 0) },
+       { "mx25l6405d",  INFO(0xc22017, 0, 64 * 1024, 128, 0) },
+       { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) },
+       { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
 
        /* Spansion -- single (large) sector size only, at least
         * for the chips listed here (without boot sectors).
         */
-       { "s25sl004a", 0x010212, 0, 64 * 1024, 8, },
-       { "s25sl008a", 0x010213, 0, 64 * 1024, 16, },
-       { "s25sl016a", 0x010214, 0, 64 * 1024, 32, },
-       { "s25sl032a", 0x010215, 0, 64 * 1024, 64, },
-       { "s25sl064a", 0x010216, 0, 64 * 1024, 128, },
-       { "s25sl12800", 0x012018, 0x0300, 256 * 1024, 64, },
-       { "s25sl12801", 0x012018, 0x0301, 64 * 1024, 256, },
-       { "s25fl129p0", 0x012018, 0x4d00, 256 * 1024, 64, },
-       { "s25fl129p1", 0x012018, 0x4d01, 64 * 1024, 256, },
+       { "s25sl004a",  INFO(0x010212,      0,  64 * 1024,   8, 0) },
+       { "s25sl008a",  INFO(0x010213,      0,  64 * 1024,  16, 0) },
+       { "s25sl016a",  INFO(0x010214,      0,  64 * 1024,  32, 0) },
+       { "s25sl032a",  INFO(0x010215,      0,  64 * 1024,  64, 0) },
+       { "s25sl064a",  INFO(0x010216,      0,  64 * 1024, 128, 0) },
+       { "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024,  64, 0) },
+       { "s25sl12801", INFO(0x012018, 0x0301,  64 * 1024, 256, 0) },
+       { "s25fl129p0", INFO(0x012018, 0x4d00, 256 * 1024,  64, 0) },
+       { "s25fl129p1", INFO(0x012018, 0x4d01,  64 * 1024, 256, 0) },
 
        /* SST -- large erase sizes are "overlays", "sectors" are 4K */
-       { "sst25vf040b", 0xbf258d, 0, 64 * 1024, 8, SECT_4K, },
-       { "sst25vf080b", 0xbf258e, 0, 64 * 1024, 16, SECT_4K, },
-       { "sst25vf016b", 0xbf2541, 0, 64 * 1024, 32, SECT_4K, },
-       { "sst25vf032b", 0xbf254a, 0, 64 * 1024, 64, SECT_4K, },
-       { "sst25wf512",  0xbf2501, 0, 64 * 1024, 1, SECT_4K, },
-       { "sst25wf010",  0xbf2502, 0, 64 * 1024, 2, SECT_4K, },
-       { "sst25wf020",  0xbf2503, 0, 64 * 1024, 4, SECT_4K, },
-       { "sst25wf040",  0xbf2504, 0, 64 * 1024, 8, SECT_4K, },
+       { "sst25vf040b", INFO(0xbf258d, 0, 64 * 1024,  8, SECT_4K) },
+       { "sst25vf080b", INFO(0xbf258e, 0, 64 * 1024, 16, SECT_4K) },
+       { "sst25vf016b", INFO(0xbf2541, 0, 64 * 1024, 32, SECT_4K) },
+       { "sst25vf032b", INFO(0xbf254a, 0, 64 * 1024, 64, SECT_4K) },
+       { "sst25wf512",  INFO(0xbf2501, 0, 64 * 1024,  1, SECT_4K) },
+       { "sst25wf010",  INFO(0xbf2502, 0, 64 * 1024,  2, SECT_4K) },
+       { "sst25wf020",  INFO(0xbf2503, 0, 64 * 1024,  4, SECT_4K) },
+       { "sst25wf040",  INFO(0xbf2504, 0, 64 * 1024,  8, SECT_4K) },
 
        /* ST Microelectronics -- newer production may have feature updates */
-       { "m25p05",  0x202010,  0, 32 * 1024, 2, },
-       { "m25p10",  0x202011,  0, 32 * 1024, 4, },
-       { "m25p20",  0x202012,  0, 64 * 1024, 4, },
-       { "m25p40",  0x202013,  0, 64 * 1024, 8, },
-       { "m25p80",         0,  0, 64 * 1024, 16, },
-       { "m25p16",  0x202015,  0, 64 * 1024, 32, },
-       { "m25p32",  0x202016,  0, 64 * 1024, 64, },
-       { "m25p64",  0x202017,  0, 64 * 1024, 128, },
-       { "m25p128", 0x202018, 0, 256 * 1024, 64, },
-
-       { "m45pe10", 0x204011,  0, 64 * 1024, 2, },
-       { "m45pe80", 0x204014,  0, 64 * 1024, 16, },
-       { "m45pe16", 0x204015,  0, 64 * 1024, 32, },
-
-       { "m25pe80", 0x208014,  0, 64 * 1024, 16, },
-       { "m25pe16", 0x208015,  0, 64 * 1024, 32, SECT_4K, },
+       { "m25p05",  INFO(0x202010,  0,  32 * 1024,   2, 0) },
+       { "m25p10",  INFO(0x202011,  0,  32 * 1024,   4, 0) },
+       { "m25p20",  INFO(0x202012,  0,  64 * 1024,   4, 0) },
+       { "m25p40",  INFO(0x202013,  0,  64 * 1024,   8, 0) },
+       { "m25p80",  INFO(0x202014,  0,  64 * 1024,  16, 0) },
+       { "m25p16",  INFO(0x202015,  0,  64 * 1024,  32, 0) },
+       { "m25p32",  INFO(0x202016,  0,  64 * 1024,  64, 0) },
+       { "m25p64",  INFO(0x202017,  0,  64 * 1024, 128, 0) },
+       { "m25p128", INFO(0x202018,  0, 256 * 1024,  64, 0) },
+
+       { "m45pe10", INFO(0x204011,  0, 64 * 1024,    2, 0) },
+       { "m45pe80", INFO(0x204014,  0, 64 * 1024,   16, 0) },
+       { "m45pe16", INFO(0x204015,  0, 64 * 1024,   32, 0) },
+
+       { "m25pe80", INFO(0x208014,  0, 64 * 1024, 16,       0) },
+       { "m25pe16", INFO(0x208015,  0, 64 * 1024, 32, SECT_4K) },
 
        /* Winbond -- w25x "blocks" are 64K, "sectors" are 4KiB */
-       { "w25x10", 0xef3011, 0, 64 * 1024, 2, SECT_4K, },
-       { "w25x20", 0xef3012, 0, 64 * 1024, 4, SECT_4K, },
-       { "w25x40", 0xef3013, 0, 64 * 1024, 8, SECT_4K, },
-       { "w25x80", 0xef3014, 0, 64 * 1024, 16, SECT_4K, },
-       { "w25x16", 0xef3015, 0, 64 * 1024, 32, SECT_4K, },
-       { "w25x32", 0xef3016, 0, 64 * 1024, 64, SECT_4K, },
-       { "w25x64", 0xef3017, 0, 64 * 1024, 128, SECT_4K, },
+       { "w25x10", INFO(0xef3011, 0, 64 * 1024,  2,  SECT_4K) },
+       { "w25x20", INFO(0xef3012, 0, 64 * 1024,  4,  SECT_4K) },
+       { "w25x40", INFO(0xef3013, 0, 64 * 1024,  8,  SECT_4K) },
+       { "w25x80", INFO(0xef3014, 0, 64 * 1024,  16, SECT_4K) },
+       { "w25x16", INFO(0xef3015, 0, 64 * 1024,  32, SECT_4K) },
+       { "w25x32", INFO(0xef3016, 0, 64 * 1024,  64, SECT_4K) },
+       { "w25x64", INFO(0xef3017, 0, 64 * 1024, 128, SECT_4K) },
+
+       /* Catalyst / On Semiconductor -- non-JEDEC */
+       { "cat25c11", CAT25_INFO(  16, 8, 16, 1) },
+       { "cat25c03", CAT25_INFO(  32, 8, 16, 2) },
+       { "cat25c09", CAT25_INFO( 128, 8, 32, 2) },
+       { "cat25c17", CAT25_INFO( 256, 8, 32, 2) },
+       { "cat25128", CAT25_INFO(2048, 8, 64, 2) },
+       { },
 };
+MODULE_DEVICE_TABLE(spi, m25p_ids);
 
-static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
+static const struct spi_device_id *__devinit jedec_probe(struct spi_device *spi)
 {
        int                     tmp;
        u8                      code = OPCODE_RDID;
@@ -702,18 +730,24 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
        jedec = jedec << 8;
        jedec |= id[2];
 
+       /*
+        * Some chips (like Numonyx M25P80) have JEDEC and non-JEDEC variants,
+        * which depend on technology process. Officially RDID command doesn't
+        * exist for non-JEDEC chips, but for compatibility they return ID 0.
+        */
+       if (jedec == 0)
+               return NULL;
+
        ext_jedec = id[3] << 8 | id[4];
 
-       for (tmp = 0, info = m25p_data;
-                       tmp < ARRAY_SIZE(m25p_data);
-                       tmp++, info++) {
+       for (tmp = 0; tmp < ARRAY_SIZE(m25p_ids) - 1; tmp++) {
+               info = (void *)m25p_ids[tmp].driver_data;
                if (info->jedec_id == jedec) {
                        if (info->ext_id != 0 && info->ext_id != ext_jedec)
                                continue;
-                       return info;
+                       return &m25p_ids[tmp];
                }
        }
-       dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec);
        return NULL;
 }
 
@@ -725,6 +759,7 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi)
  */
 static int __devinit m25p_probe(struct spi_device *spi)
 {
+       const struct spi_device_id      *id = spi_get_device_id(spi);
        struct flash_platform_data      *data;
        struct m25p                     *flash;
        struct flash_info               *info;
@@ -737,50 +772,65 @@ static int __devinit m25p_probe(struct spi_device *spi)
         */
        data = spi->dev.platform_data;
        if (data && data->type) {
-               for (i = 0, info = m25p_data;
-                               i < ARRAY_SIZE(m25p_data);
-                               i++, info++) {
-                       if (strcmp(data->type, info->name) == 0)
-                               break;
-               }
+               const struct spi_device_id *plat_id;
 
-               /* unrecognized chip? */
-               if (i == ARRAY_SIZE(m25p_data)) {
-                       DEBUG(MTD_DEBUG_LEVEL0, "%s: unrecognized id %s\n",
-                                       dev_name(&spi->dev), data->type);
-                       info = NULL;
-
-               /* recognized; is that chip really what's there? */
-               } else if (info->jedec_id) {
-                       struct flash_info       *chip = jedec_probe(spi);
-
-                       if (!chip || chip != info) {
-                               dev_warn(&spi->dev, "found %s, expected %s\n",
-                                               chip ? chip->name : "UNKNOWN",
-                                               info->name);
-                               info = NULL;
-                       }
+               for (i = 0; i < ARRAY_SIZE(m25p_ids) - 1; i++) {
+                       plat_id = &m25p_ids[i];
+                       if (strcmp(data->type, plat_id->name))
+                               continue;
+                       break;
                }
-       } else
-               info = jedec_probe(spi);
 
-       if (!info)
-               return -ENODEV;
+               if (plat_id)
+                       id = plat_id;
+               else
+                       dev_warn(&spi->dev, "unrecognized id %s\n", data->type);
+       }
+
+       info = (void *)id->driver_data;
+
+       if (info->jedec_id) {
+               const struct spi_device_id *jid;
+
+               jid = jedec_probe(spi);
+               if (!jid) {
+                       dev_info(&spi->dev, "non-JEDEC variant of %s\n",
+                                id->name);
+               } else if (jid != id) {
+                       /*
+                        * JEDEC knows better, so overwrite platform ID. We
+                        * can't trust partitions any longer, but we'll let
+                        * mtd apply them anyway, since some partitions may be
+                        * marked read-only, and we don't want to lose that
+                        * information, even if it's not 100% accurate.
+                        */
+                       dev_warn(&spi->dev, "found %s, expected %s\n",
+                                jid->name, id->name);
+                       id = jid;
+                       info = (void *)jid->driver_data;
+               }
+       }
 
        flash = kzalloc(sizeof *flash, GFP_KERNEL);
        if (!flash)
                return -ENOMEM;
+       flash->command = kmalloc(MAX_CMD_SIZE + FAST_READ_DUMMY_BYTE, GFP_KERNEL);
+       if (!flash->command) {
+               kfree(flash);
+               return -ENOMEM;
+       }
 
        flash->spi = spi;
        mutex_init(&flash->lock);
        dev_set_drvdata(&spi->dev, flash);
 
        /*
-        * Atmel serial flash tend to power up
-        * with the software protection bits set
+        * Atmel and SST serial flash tend to power
+        * up with the software protection bits set
         */
 
-       if (info->jedec_id >> 16 == 0x1f) {
+       if (info->jedec_id >> 16 == 0x1f ||
+           info->jedec_id >> 16 == 0xbf) {
                write_enable(flash);
                write_sr(flash, 0);
        }
@@ -812,9 +862,14 @@ static int __devinit m25p_probe(struct spi_device *spi)
                flash->mtd.erasesize = info->sector_size;
        }
 
+       if (info->flags & M25P_NO_ERASE)
+               flash->mtd.flags |= MTD_NO_ERASE;
+
        flash->mtd.dev.parent = &spi->dev;
+       flash->page_size = info->page_size;
+       flash->addr_width = info->addr_width;
 
-       dev_info(&spi->dev, "%s (%lld Kbytes)\n", info->name,
+       dev_info(&spi->dev, "%s (%lld Kbytes)\n", id->name,
                        (long long)flash->mtd.size >> 10);
 
        DEBUG(MTD_DEBUG_LEVEL2,
@@ -888,8 +943,10 @@ static int __devexit m25p_remove(struct spi_device *spi)
                status = del_mtd_partitions(&flash->mtd);
        else
                status = del_mtd_device(&flash->mtd);
-       if (status == 0)
+       if (status == 0) {
+               kfree(flash->command);
                kfree(flash);
+       }
        return 0;
 }
 
@@ -900,6 +957,7 @@ static struct spi_driver m25p80_driver = {
                .bus    = &spi_bus_type,
                .owner  = THIS_MODULE,
        },
+       .id_table       = m25p_ids,
        .probe  = m25p_probe,
        .remove = __devexit_p(m25p_remove),
 
index 93e3627be74c76a37117f13883e74d0bd1607f11..19817404ce7d9e6f240e27cf299b3b724b005268 100644 (file)
@@ -636,6 +636,7 @@ add_dataflash_otp(struct spi_device *spi, char *name,
        struct mtd_info                 *device;
        struct flash_platform_data      *pdata = spi->dev.platform_data;
        char                            *otp_tag = "";
+       int                             err = 0;
 
        priv = kzalloc(sizeof *priv, GFP_KERNEL);
        if (!priv)
@@ -693,13 +694,23 @@ add_dataflash_otp(struct spi_device *spi, char *name,
 
                if (nr_parts > 0) {
                        priv->partitioned = 1;
-                       return add_mtd_partitions(device, parts, nr_parts);
+                       err = add_mtd_partitions(device, parts, nr_parts);
+                       goto out;
                }
        } else if (pdata && pdata->nr_parts)
                dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
                                pdata->nr_parts, device->name);
 
-       return add_mtd_device(device) == 1 ? -ENODEV : 0;
+       if (add_mtd_device(device) == 1)
+               err = -ENODEV;
+
+out:
+       if (!err)
+               return 0;
+
+       dev_set_drvdata(&spi->dev, NULL);
+       kfree(priv);
+       return err;
 }
 
 static inline int __devinit
@@ -932,8 +943,10 @@ static int __devexit dataflash_remove(struct spi_device *spi)
                status = del_mtd_partitions(&flash->mtd);
        else
                status = del_mtd_device(&flash->mtd);
-       if (status == 0)
+       if (status == 0) {
+               dev_set_drvdata(&spi->dev, NULL);
                kfree(flash);
+       }
        return status;
 }
 
index 847e214ade5915792438193461603389171a369e..4c364d44ad59e34f4fdc02c89a2551b016bb4c23 100644 (file)
@@ -359,12 +359,6 @@ config MTD_SA1100
          the SA1100 and SA1110, including the Assabet and the Compaq iPAQ.
          If you have such a board, say 'Y'.
 
-config MTD_IPAQ
-       tristate "CFI Flash device mapped on Compaq/HP iPAQ"
-       depends on IPAQ_HANDHELD && MTD_CFI
-       help
-         This provides a driver for the on-board flash of the iPAQ.
-
 config MTD_DC21285
        tristate "CFI Flash device mapped on DC21285 Footbridge"
        depends on MTD_CFI && ARCH_FOOTBRIDGE && MTD_COMPLEX_MAPPINGS
index ae2f6dbe43c37b9f524ffd72fef863acbcce7680..ce315214ff2ba4a4bbec44b46ef9a25b6afabdc2 100644 (file)
@@ -24,12 +24,12 @@ obj-$(CONFIG_MTD_CEIVA)             += ceiva.o
 obj-$(CONFIG_MTD_OCTAGON)      += octagon-5066.o
 obj-$(CONFIG_MTD_PHYSMAP)      += physmap.o
 obj-$(CONFIG_MTD_PHYSMAP_OF)   += physmap_of.o
+obj-$(CONFIG_MTD_PISMO)                += pismo.o
 obj-$(CONFIG_MTD_PMC_MSP_EVM)   += pmcmsp-flash.o
 obj-$(CONFIG_MTD_PCMCIA)       += pcmciamtd.o
 obj-$(CONFIG_MTD_RPXLITE)      += rpxlite.o
 obj-$(CONFIG_MTD_TQM8XXL)      += tqm8xxl.o
 obj-$(CONFIG_MTD_SA1100)       += sa1100-flash.o
-obj-$(CONFIG_MTD_IPAQ)         += ipaq-flash.o
 obj-$(CONFIG_MTD_SBC_GXX)      += sbc_gxx.o
 obj-$(CONFIG_MTD_SC520CDP)     += sc520cdp.o
 obj-$(CONFIG_MTD_NETSC520)     += netsc520.o
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
deleted file mode 100644 (file)
index 76708e7..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * Flash memory access on iPAQ Handhelds (either SA1100 or PXA250 based)
- *
- * (C) 2000 Nicolas Pitre <nico@fluxnic.net>
- * (C) 2002 Hewlett-Packard Company <jamey.hicks@hp.com>
- * (C) 2003 Christian Pellegrin <chri@ascensit.com>, <chri@infis.univ.ts.it>: concatenation of multiple flashes
- */
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <asm/page.h>
-#include <asm/mach-types.h>
-#include <asm/system.h>
-#include <asm/errno.h>
-
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/partitions.h>
-#ifdef CONFIG_MTD_CONCAT
-#include <linux/mtd/concat.h>
-#endif
-
-#include <mach/hardware.h>
-#include <mach/h3600.h>
-#include <asm/io.h>
-
-
-#ifndef CONFIG_IPAQ_HANDHELD
-#error This is for iPAQ Handhelds only
-#endif
-#ifdef CONFIG_SA1100_JORNADA56X
-
-static void jornada56x_set_vpp(struct map_info *map, int vpp)
-{
-       if (vpp)
-               GPSR = GPIO_GPIO26;
-       else
-               GPCR = GPIO_GPIO26;
-       GPDR |= GPIO_GPIO26;
-}
-
-#endif
-
-#ifdef CONFIG_SA1100_JORNADA720
-
-static void jornada720_set_vpp(struct map_info *map, int vpp)
-{
-       if (vpp)
-               PPSR |= 0x80;
-       else
-               PPSR &= ~0x80;
-       PPDR |= 0x80;
-}
-
-#endif
-
-#define MAX_IPAQ_CS 2          /* Number of CS we are going to test */
-
-#define IPAQ_MAP_INIT(X) \
-       { \
-               name:           "IPAQ flash " X, \
-       }
-
-
-static struct map_info ipaq_map[MAX_IPAQ_CS] = {
-       IPAQ_MAP_INIT("bank 1"),
-       IPAQ_MAP_INIT("bank 2")
-};
-
-static struct mtd_info *my_sub_mtd[MAX_IPAQ_CS] = {
-       NULL,
-       NULL
-};
-
-/*
- * Here are partition information for all known IPAQ-based devices.
- * See include/linux/mtd/partitions.h for definition of the mtd_partition
- * structure.
- *
- * The *_max_flash_size is the maximum possible mapped flash size which
- * is not necessarily the actual flash size.  It must be no more than
- * the value specified in the "struct map_desc *_io_desc" mapping
- * definition for the corresponding machine.
- *
- * Please keep these in alphabetical order, and formatted as per existing
- * entries.  Thanks.
- */
-
-#ifdef CONFIG_IPAQ_HANDHELD
-static unsigned long h3xxx_max_flash_size = 0x04000000;
-static struct mtd_partition h3xxx_partitions[] = {
-       {
-               name:           "H3XXX boot firmware",
-#ifndef CONFIG_LAB
-               size:           0x00040000,
-#else
-               size:           0x00080000,
-#endif
-               offset:         0,
-#ifndef CONFIG_LAB
-               mask_flags:     MTD_WRITEABLE,  /* force read-only */
-#endif
-       },
-       {
-               name:           "H3XXX root jffs2",
-#ifndef CONFIG_LAB
-               size:           0x2000000 - 2*0x40000, /* Warning, this is fixed later */
-               offset:         0x00040000,
-#else
-               size:           0x2000000 - 0x40000 - 0x80000, /* Warning, this is fixed later */
-               offset:         0x00080000,
-#endif
-       },
-       {
-               name:           "asset",
-               size:           0x40000,
-               offset:         0x2000000 - 0x40000, /* Warning, this is fixed later */
-               mask_flags:     MTD_WRITEABLE,  /* force read-only */
-       }
-};
-
-#ifndef CONFIG_MTD_CONCAT
-static struct mtd_partition h3xxx_partitions_bank2[] = {
-       /* this is used only on 2 CS machines when concat is not present */
-       {
-               name:           "second H3XXX root jffs2",
-               size:           0x1000000 - 0x40000, /* Warning, this is fixed later */
-               offset:         0x00000000,
-       },
-       {
-               name:           "second asset",
-               size:           0x40000,
-               offset:         0x1000000 - 0x40000, /* Warning, this is fixed later */
-               mask_flags:     MTD_WRITEABLE,  /* force read-only */
-       }
-};
-#endif
-
-static DEFINE_SPINLOCK(ipaq_vpp_lock);
-
-static void h3xxx_set_vpp(struct map_info *map, int vpp)
-{
-       static int nest = 0;
-
-       spin_lock(&ipaq_vpp_lock);
-       if (vpp)
-               nest++;
-       else
-               nest--;
-       if (nest)
-               assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, 1);
-       else
-               assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, 0);
-       spin_unlock(&ipaq_vpp_lock);
-}
-
-#endif
-
-#if defined(CONFIG_SA1100_JORNADA56X) || defined(CONFIG_SA1100_JORNADA720)
-static unsigned long jornada_max_flash_size = 0x02000000;
-static struct mtd_partition jornada_partitions[] = {
-       {
-               name:           "Jornada boot firmware",
-               size:           0x00040000,
-               offset:         0,
-               mask_flags:     MTD_WRITEABLE,  /* force read-only */
-       }, {
-               name:           "Jornada root jffs2",
-               size:           MTDPART_SIZ_FULL,
-               offset:         0x00040000,
-       }
-};
-#endif
-
-
-static struct mtd_partition *parsed_parts;
-static struct mtd_info *mymtd;
-
-static unsigned long cs_phys[] = {
-#ifdef CONFIG_ARCH_SA1100
-       SA1100_CS0_PHYS,
-       SA1100_CS1_PHYS,
-       SA1100_CS2_PHYS,
-       SA1100_CS3_PHYS,
-       SA1100_CS4_PHYS,
-       SA1100_CS5_PHYS,
-#else
-       PXA_CS0_PHYS,
-       PXA_CS1_PHYS,
-       PXA_CS2_PHYS,
-       PXA_CS3_PHYS,
-       PXA_CS4_PHYS,
-       PXA_CS5_PHYS,
-#endif
-};
-
-static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
-
-static int __init h1900_special_case(void);
-
-static int __init ipaq_mtd_init(void)
-{
-       struct mtd_partition *parts = NULL;
-       int nb_parts = 0;
-       int parsed_nr_parts = 0;
-       const char *part_type;
-       int i; /* used when we have >1 flash chips */
-       unsigned long tot_flashsize = 0; /* used when we have >1 flash chips */
-
-       /* Default flash bankwidth */
-       // ipaq_map.bankwidth = (MSC0 & MSC_RBW) ? 2 : 4;
-
-       if (machine_is_h1900())
-       {
-               /* For our intents, the h1900 is not a real iPAQ, so we special-case it. */
-               return h1900_special_case();
-       }
-
-       if (machine_is_h3100() || machine_is_h1900())
-               for(i=0; i<MAX_IPAQ_CS; i++)
-                       ipaq_map[i].bankwidth = 2;
-       else
-               for(i=0; i<MAX_IPAQ_CS; i++)
-                       ipaq_map[i].bankwidth = 4;
-
-       /*
-        * Static partition definition selection
-        */
-       part_type = "static";
-
-       simple_map_init(&ipaq_map[0]);
-       simple_map_init(&ipaq_map[1]);
-
-#ifdef CONFIG_IPAQ_HANDHELD
-       if (machine_is_ipaq()) {
-               parts = h3xxx_partitions;
-               nb_parts = ARRAY_SIZE(h3xxx_partitions);
-               for(i=0; i<MAX_IPAQ_CS; i++) {
-                       ipaq_map[i].size = h3xxx_max_flash_size;
-                       ipaq_map[i].set_vpp = h3xxx_set_vpp;
-                       ipaq_map[i].phys = cs_phys[i];
-                       ipaq_map[i].virt = ioremap(cs_phys[i], 0x04000000);
-                       if (machine_is_h3100 () || machine_is_h1900())
-                               ipaq_map[i].bankwidth = 2;
-               }
-               if (machine_is_h3600()) {
-                       /* No asset partition here */
-                       h3xxx_partitions[1].size += 0x40000;
-                       nb_parts--;
-               }
-       }
-#endif
-#ifdef CONFIG_ARCH_H5400
-       if (machine_is_h5400()) {
-               ipaq_map[0].size = 0x02000000;
-               ipaq_map[1].size = 0x02000000;
-               ipaq_map[1].phys = 0x02000000;
-               ipaq_map[1].virt = ipaq_map[0].virt + 0x02000000;
-       }
-#endif
-#ifdef CONFIG_ARCH_H1900
-       if (machine_is_h1900()) {
-               ipaq_map[0].size = 0x00400000;
-               ipaq_map[1].size = 0x02000000;
-               ipaq_map[1].phys = 0x00080000;
-               ipaq_map[1].virt = ipaq_map[0].virt + 0x00080000;
-       }
-#endif
-
-#ifdef CONFIG_SA1100_JORNADA56X
-       if (machine_is_jornada56x()) {
-               parts = jornada_partitions;
-               nb_parts = ARRAY_SIZE(jornada_partitions);
-               ipaq_map[0].size = jornada_max_flash_size;
-               ipaq_map[0].set_vpp = jornada56x_set_vpp;
-               ipaq_map[0].virt = (__u32)ioremap(0x0, 0x04000000);
-       }
-#endif
-#ifdef CONFIG_SA1100_JORNADA720
-       if (machine_is_jornada720()) {
-               parts = jornada_partitions;
-               nb_parts = ARRAY_SIZE(jornada_partitions);
-               ipaq_map[0].size = jornada_max_flash_size;
-               ipaq_map[0].set_vpp = jornada720_set_vpp;
-       }
-#endif
-
-
-       if (machine_is_ipaq()) { /* for iPAQs only */
-               for(i=0; i<MAX_IPAQ_CS; i++) {
-                       printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with CFI.\n", ipaq_map[i].bankwidth*8, ipaq_map[i].virt);
-                       my_sub_mtd[i] = do_map_probe("cfi_probe", &ipaq_map[i]);
-                       if (!my_sub_mtd[i]) {
-                               printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with JEDEC.\n", ipaq_map[i].bankwidth*8, ipaq_map[i].virt);
-                               my_sub_mtd[i] = do_map_probe("jedec_probe", &ipaq_map[i]);
-                       }
-                       if (!my_sub_mtd[i]) {
-                               printk(KERN_NOTICE "iPAQ flash: failed to find flash.\n");
-                               if (i)
-                                       break;
-                               else
-                                       return -ENXIO;
-                       } else
-                               printk(KERN_NOTICE "iPAQ flash: found %d bytes\n", my_sub_mtd[i]->size);
-
-                       /* do we really need this debugging? --joshua 20030703 */
-                       // printk("my_sub_mtd[%d]=%p\n", i, my_sub_mtd[i]);
-                       my_sub_mtd[i]->owner = THIS_MODULE;
-                       tot_flashsize += my_sub_mtd[i]->size;
-               }
-#ifdef CONFIG_MTD_CONCAT
-               /* fix the asset location */
-#      ifdef CONFIG_LAB
-               h3xxx_partitions[1].size = tot_flashsize - 0x40000 - 0x80000 /* extra big boot block */;
-#      else
-               h3xxx_partitions[1].size = tot_flashsize - 2 * 0x40000;
-#      endif
-               h3xxx_partitions[2].offset = tot_flashsize - 0x40000;
-               /* and concat the devices */
-               mymtd = mtd_concat_create(&my_sub_mtd[0], i,
-                                         "ipaq");
-               if (!mymtd) {
-                       printk("Cannot create iPAQ concat device\n");
-                       return -ENXIO;
-               }
-#else
-               mymtd = my_sub_mtd[0];
-
-               /*
-                *In the very near future, command line partition parsing
-                * will use the device name as 'mtd-id' instead of a value
-                * passed to the parse_cmdline_partitions() routine. Since
-                * the bootldr says 'ipaq', make sure it continues to work.
-                */
-               mymtd->name = "ipaq";
-
-               if ((machine_is_h3600())) {
-#      ifdef CONFIG_LAB
-                       h3xxx_partitions[1].size = my_sub_mtd[0]->size - 0x80000;
-#      else
-                       h3xxx_partitions[1].size = my_sub_mtd[0]->size - 0x40000;
-#      endif
-                       nb_parts = 2;
-               } else {
-#      ifdef CONFIG_LAB
-                       h3xxx_partitions[1].size = my_sub_mtd[0]->size - 0x40000 - 0x80000; /* extra big boot block */
-#      else
-                       h3xxx_partitions[1].size = my_sub_mtd[0]->size - 2*0x40000;
-#      endif
-                       h3xxx_partitions[2].offset = my_sub_mtd[0]->size - 0x40000;
-               }
-
-               if (my_sub_mtd[1]) {
-#      ifdef CONFIG_LAB
-                       h3xxx_partitions_bank2[0].size = my_sub_mtd[1]->size - 0x80000;
-#      else
-                       h3xxx_partitions_bank2[0].size = my_sub_mtd[1]->size - 0x40000;
-#      endif
-                       h3xxx_partitions_bank2[1].offset = my_sub_mtd[1]->size - 0x40000;
-               }
-#endif
-       }
-       else {
-               /*
-                * Now let's probe for the actual flash.  Do it here since
-                * specific machine settings might have been set above.
-                */
-               printk(KERN_NOTICE "IPAQ flash: probing %d-bit flash bus, window=%lx\n", ipaq_map[0].bankwidth*8, ipaq_map[0].virt);
-               mymtd = do_map_probe("cfi_probe", &ipaq_map[0]);
-               if (!mymtd)
-                       return -ENXIO;
-               mymtd->owner = THIS_MODULE;
-       }
-
-
-       /*
-        * Dynamic partition selection stuff (might override the static ones)
-        */
-
-        i = parse_mtd_partitions(mymtd, part_probes, &parsed_parts, 0);
-
-        if (i > 0) {
-                nb_parts = parsed_nr_parts = i;
-                parts = parsed_parts;
-                part_type = "dynamic";
-        }
-
-        if (!parts) {
-                printk(KERN_NOTICE "IPAQ flash: no partition info available, registering whole flash at once\n");
-                add_mtd_device(mymtd);
-#ifndef CONFIG_MTD_CONCAT
-                if (my_sub_mtd[1])
-                        add_mtd_device(my_sub_mtd[1]);
-#endif
-        } else {
-                printk(KERN_NOTICE "Using %s partition definition\n", part_type);
-                add_mtd_partitions(mymtd, parts, nb_parts);
-#ifndef CONFIG_MTD_CONCAT
-                if (my_sub_mtd[1])
-                        add_mtd_partitions(my_sub_mtd[1], h3xxx_partitions_bank2, ARRAY_SIZE(h3xxx_partitions_bank2));
-#endif
-        }
-
-        return 0;
-}
-
-static void __exit ipaq_mtd_cleanup(void)
-{
-       int i;
-
-       if (mymtd) {
-               del_mtd_partitions(mymtd);
-#ifndef CONFIG_MTD_CONCAT
-               if (my_sub_mtd[1])
-                       del_mtd_partitions(my_sub_mtd[1]);
-#endif
-               map_destroy(mymtd);
-#ifdef CONFIG_MTD_CONCAT
-               for(i=0; i<MAX_IPAQ_CS; i++)
-#else
-                       for(i=1; i<MAX_IPAQ_CS; i++)
-#endif
-                       {
-                               if (my_sub_mtd[i])
-                                       map_destroy(my_sub_mtd[i]);
-                       }
-               kfree(parsed_parts);
-       }
-}
-
-static int __init h1900_special_case(void)
-{
-       /* The iPAQ h1900 is a special case - it has weird ROM. */
-       simple_map_init(&ipaq_map[0]);
-       ipaq_map[0].size = 0x80000;
-       ipaq_map[0].set_vpp = h3xxx_set_vpp;
-       ipaq_map[0].phys = 0x0;
-       ipaq_map[0].virt = ioremap(0x0, 0x04000000);
-       ipaq_map[0].bankwidth = 2;
-
-       printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with JEDEC.\n", ipaq_map[0].bankwidth*8, ipaq_map[0].virt);
-       mymtd = do_map_probe("jedec_probe", &ipaq_map[0]);
-       if (!mymtd)
-               return -ENODEV;
-       add_mtd_device(mymtd);
-       printk(KERN_NOTICE "iPAQ flash: registered h1910 flash\n");
-
-       return 0;
-}
-
-module_init(ipaq_mtd_init);
-module_exit(ipaq_mtd_cleanup);
-
-MODULE_AUTHOR("Jamey Hicks");
-MODULE_DESCRIPTION("IPAQ CFI map driver");
-MODULE_LICENSE("MIT");
index 7214b876febaea91e339e5964a0d6c1cb463899f..7b0515297411fc092a3793222f95dd11c9adb6a8 100644 (file)
@@ -210,7 +210,7 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
         * not attempt to do a direct access on us.
         */
        info->map.phys = NO_XIP;
-       info->map.size = dev->resource->end - dev->resource->start + 1;
+       info->map.size = resource_size(dev->resource);
 
        /*
         * We only support 16-bit accesses for now. If and when
@@ -224,7 +224,7 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
        info->map.copy_from = ixp4xx_copy_from,
 
        info->res = request_mem_region(dev->resource->start,
-                       dev->resource->end - dev->resource->start + 1,
+                       resource_size(dev->resource),
                        "IXP4XXFlash");
        if (!info->res) {
                printk(KERN_ERR "IXP4XXFlash: Could not reserve memory region\n");
@@ -233,7 +233,7 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
        }
 
        info->map.virt = ioremap(dev->resource->start,
-                                dev->resource->end - dev->resource->start + 1);
+                                resource_size(dev->resource));
        if (!info->map.virt) {
                printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n");
                err = -EIO;
index 380648e9051adc1b2d25eb295147859b40f2b140..d9603f7f96522e66fdb6647a77f323371d2af9ed 100644 (file)
@@ -48,23 +48,22 @@ static int physmap_flash_remove(struct platform_device *dev)
 
        if (info->cmtd) {
 #ifdef CONFIG_MTD_PARTITIONS
-               if (info->nr_parts || physmap_data->nr_parts)
+               if (info->nr_parts || physmap_data->nr_parts) {
                        del_mtd_partitions(info->cmtd);
-               else
+
+                       if (info->nr_parts)
+                               kfree(info->parts);
+               } else {
                        del_mtd_device(info->cmtd);
+               }
 #else
                del_mtd_device(info->cmtd);
 #endif
-       }
-#ifdef CONFIG_MTD_PARTITIONS
-       if (info->nr_parts)
-               kfree(info->parts);
-#endif
-
 #ifdef CONFIG_MTD_CONCAT
-       if (info->cmtd != info->mtd[0])
-               mtd_concat_destroy(info->cmtd);
+               if (info->cmtd != info->mtd[0])
+                       mtd_concat_destroy(info->cmtd);
 #endif
+       }
 
        for (i = 0; i < MAX_RESOURCES; i++) {
                if (info->mtd[i] != NULL)
@@ -130,7 +129,7 @@ static int physmap_flash_probe(struct platform_device *dev)
                                                 info->map[i].size);
                if (info->map[i].virt == NULL) {
                        dev_err(&dev->dev, "Failed to ioremap flash region\n");
-                       err = EIO;
+                       err = -EIO;
                        goto err_out;
                }
 
index 74fa075c838a52209c2c6db29d49df1a7e00f7bc..b13f6417b5b262a81b149713184fe4de9364bea9 100644 (file)
 
 #include <asm/io.h>
 #include <mach/hardware.h>
-#include <asm/cacheflush.h>
 
 #include <asm/mach/flash.h>
 
+#define CACHELINESIZE  32
+
 static void pxa2xx_map_inval_cache(struct map_info *map, unsigned long from,
                                      ssize_t len)
 {
-       flush_ioremap_region(map->phys, map->cached, from, len);
+       unsigned long start = (unsigned long)map->cached + from;
+       unsigned long end = start + len;
+
+       start &= ~(CACHELINESIZE - 1);
+       while (start < end) {
+               /* invalidate D cache line */
+               asm volatile ("mcr p15, 0, %0, c7, c6, 1" : : "r" (start));
+               start += CACHELINESIZE;
+       }
 }
 
 struct pxa2xx_flash_info {
index d7a47574d21e5b9d3cb69a64fba9917eca6acce3..f3af87e08ecd8c8d2cd9839dc127f1565f4cdf7c 100644 (file)
@@ -248,7 +248,7 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla
                plat->exit();
 }
 
-static struct sa_info *__init
+static struct sa_info *__devinit
 sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
 {
        struct sa_info *info;
index 1f73297e7776338b26298028eb20b1109b8eeca6..82afad0ddd726ca0efd0dbaa6e6a0c040219d718 100644 (file)
@@ -612,16 +612,15 @@ static int __devinit vmu_connect(struct maple_device *mdev)
 
        test_flash_data = be32_to_cpu(mdev->devinfo.function);
        /* Need to count how many bits are set - to find out which
-        * function_data element has details of the memory card:
-        * using Brian Kernighan's/Peter Wegner's method */
-       for (c = 0; test_flash_data; c++)
-               test_flash_data &= test_flash_data - 1;
+        * function_data element has details of the memory card
+        */
+       c = hweight_long(test_flash_data);
 
        basic_flash_data = be32_to_cpu(mdev->devinfo.function_data[c - 1]);
 
        card = kmalloc(sizeof(struct memcard), GFP_KERNEL);
        if (!card) {
-               error = ENOMEM;
+               error = -ENOMEM;
                goto fail_nomem;
        }
 
index 64e2b379a3500c7ceeef10277f64dee6a7199e4c..c82e09bbc5fd0c31ddf5919db4d645462b984763 100644 (file)
@@ -84,9 +84,6 @@ static int mtd_blktrans_thread(void *arg)
        struct request_queue *rq = tr->blkcore_priv->rq;
        struct request *req = NULL;
 
-       /* we might get involved when memory gets low, so use PF_MEMALLOC */
-       current->flags |= PF_MEMALLOC;
-
        spin_lock_irq(rq->queue_lock);
 
        while (!kthread_should_stop()) {
@@ -381,7 +378,7 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
        tr->blkcore_priv->thread = kthread_run(mtd_blktrans_thread, tr,
                        "%sd", tr->name);
        if (IS_ERR(tr->blkcore_priv->thread)) {
-               int ret = PTR_ERR(tr->blkcore_priv->thread);
+               ret = PTR_ERR(tr->blkcore_priv->thread);
                blk_cleanup_queue(tr->blkcore_priv->rq);
                unregister_blkdev(tr->major, tr->name);
                kfree(tr->blkcore_priv);
index 467a4f177bfb269d684029954fb1731a011a12ce..c356c0a30c3e46b82d5dca258491390494098c82 100644 (file)
@@ -447,7 +447,7 @@ struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num)
                for (i=0; i< MAX_MTD_DEVICES; i++)
                        if (mtd_table[i] == mtd)
                                ret = mtd_table[i];
-       } else if (num < MAX_MTD_DEVICES) {
+       } else if (num >= 0 && num < MAX_MTD_DEVICES) {
                ret = mtd_table[num];
                if (mtd && mtd != ret)
                        ret = NULL;
index 1060337c06df7a57b0a1a76455635a004ad22543..a714ec482761fbba566379e31b6b8b3a147c5d78 100644 (file)
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/delay.h>
-#include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/mtd/mtd.h>
+#include <linux/kmsg_dump.h>
+
+/* Maximum MTD partition size */
+#define MTDOOPS_MAX_MTD_SIZE (8 * 1024 * 1024)
 
 #define MTDOOPS_KERNMSG_MAGIC 0x5d005d00
-#define OOPS_PAGE_SIZE 4096
+#define MTDOOPS_HEADER_SIZE   8
+
+static unsigned long record_size = 4096;
+module_param(record_size, ulong, 0400);
+MODULE_PARM_DESC(record_size,
+               "record size for MTD OOPS pages in bytes (default 4096)");
+
+static char mtddev[80];
+module_param_string(mtddev, mtddev, 80, 0400);
+MODULE_PARM_DESC(mtddev,
+               "name or index number of the MTD device to use");
+
+static int dump_oops = 1;
+module_param(dump_oops, int, 0600);
+MODULE_PARM_DESC(dump_oops,
+               "set to 1 to dump oopses, 0 to only dump panics (default 1)");
 
 static struct mtdoops_context {
+       struct kmsg_dumper dump;
+
        int mtd_index;
        struct work_struct work_erase;
        struct work_struct work_write;
@@ -44,28 +64,43 @@ static struct mtdoops_context {
        int oops_pages;
        int nextpage;
        int nextcount;
-       char *name;
+       unsigned long *oops_page_used;
 
        void *oops_buf;
-
-       /* writecount and disabling ready are spin lock protected */
-       spinlock_t writecount_lock;
-       int ready;
-       int writecount;
 } oops_cxt;
 
+static void mark_page_used(struct mtdoops_context *cxt, int page)
+{
+       set_bit(page, cxt->oops_page_used);
+}
+
+static void mark_page_unused(struct mtdoops_context *cxt, int page)
+{
+       clear_bit(page, cxt->oops_page_used);
+}
+
+static int page_is_used(struct mtdoops_context *cxt, int page)
+{
+       return test_bit(page, cxt->oops_page_used);
+}
+
 static void mtdoops_erase_callback(struct erase_info *done)
 {
        wait_queue_head_t *wait_q = (wait_queue_head_t *)done->priv;
        wake_up(wait_q);
 }
 
-static int mtdoops_erase_block(struct mtd_info *mtd, int offset)
+static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset)
 {
+       struct mtd_info *mtd = cxt->mtd;
+       u32 start_page_offset = mtd_div_by_eb(offset, mtd) * mtd->erasesize;
+       u32 start_page = start_page_offset / record_size;
+       u32 erase_pages = mtd->erasesize / record_size;
        struct erase_info erase;
        DECLARE_WAITQUEUE(wait, current);
        wait_queue_head_t wait_q;
        int ret;
+       int page;
 
        init_waitqueue_head(&wait_q);
        erase.mtd = mtd;
@@ -81,25 +116,24 @@ static int mtdoops_erase_block(struct mtd_info *mtd, int offset)
        if (ret) {
                set_current_state(TASK_RUNNING);
                remove_wait_queue(&wait_q, &wait);
-               printk (KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] "
-                                    "on \"%s\" failed\n",
-                       (unsigned long long)erase.addr, (unsigned long long)erase.len, mtd->name);
+               printk(KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] on \"%s\" failed\n",
+                      (unsigned long long)erase.addr,
+                      (unsigned long long)erase.len, mtddev);
                return ret;
        }
 
        schedule();  /* Wait for erase to finish. */
        remove_wait_queue(&wait_q, &wait);
 
+       /* Mark pages as unused */
+       for (page = start_page; page < start_page + erase_pages; page++)
+               mark_page_unused(cxt, page);
+
        return 0;
 }
 
 static void mtdoops_inc_counter(struct mtdoops_context *cxt)
 {
-       struct mtd_info *mtd = cxt->mtd;
-       size_t retlen;
-       u32 count;
-       int ret;
-
        cxt->nextpage++;
        if (cxt->nextpage >= cxt->oops_pages)
                cxt->nextpage = 0;
@@ -107,25 +141,13 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt)
        if (cxt->nextcount == 0xffffffff)
                cxt->nextcount = 0;
 
-       ret = mtd->read(mtd, cxt->nextpage * OOPS_PAGE_SIZE, 4,
-                       &retlen, (u_char *) &count);
-       if ((retlen != 4) || ((ret < 0) && (ret != -EUCLEAN))) {
-               printk(KERN_ERR "mtdoops: Read failure at %d (%td of 4 read)"
-                               ", err %d.\n", cxt->nextpage * OOPS_PAGE_SIZE,
-                               retlen, ret);
+       if (page_is_used(cxt, cxt->nextpage)) {
                schedule_work(&cxt->work_erase);
                return;
        }
 
-       /* See if we need to erase the next block */
-       if (count != 0xffffffff) {
-               schedule_work(&cxt->work_erase);
-               return;
-       }
-
-       printk(KERN_DEBUG "mtdoops: Ready %d, %d (no erase)\n",
-                       cxt->nextpage, cxt->nextcount);
-       cxt->ready = 1;
+       printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n",
+              cxt->nextpage, cxt->nextcount);
 }
 
 /* Scheduled work - when we can't proceed without erasing a block */
@@ -140,47 +162,47 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
        if (!mtd)
                return;
 
-       mod = (cxt->nextpage * OOPS_PAGE_SIZE) % mtd->erasesize;
+       mod = (cxt->nextpage * record_size) % mtd->erasesize;
        if (mod != 0) {
-               cxt->nextpage = cxt->nextpage + ((mtd->erasesize - mod) / OOPS_PAGE_SIZE);
+               cxt->nextpage = cxt->nextpage + ((mtd->erasesize - mod) / record_size);
                if (cxt->nextpage >= cxt->oops_pages)
                        cxt->nextpage = 0;
        }
 
        while (mtd->block_isbad) {
-               ret = mtd->block_isbad(mtd, cxt->nextpage * OOPS_PAGE_SIZE);
+               ret = mtd->block_isbad(mtd, cxt->nextpage * record_size);
                if (!ret)
                        break;
                if (ret < 0) {
-                       printk(KERN_ERR "mtdoops: block_isbad failed, aborting.\n");
+                       printk(KERN_ERR "mtdoops: block_isbad failed, aborting\n");
                        return;
                }
 badblock:
-               printk(KERN_WARNING "mtdoops: Bad block at %08x\n",
-                               cxt->nextpage * OOPS_PAGE_SIZE);
+               printk(KERN_WARNING "mtdoops: bad block at %08lx\n",
+                      cxt->nextpage * record_size);
                i++;
-               cxt->nextpage = cxt->nextpage + (mtd->erasesize / OOPS_PAGE_SIZE);
+               cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size);
                if (cxt->nextpage >= cxt->oops_pages)
                        cxt->nextpage = 0;
-               if (i == (cxt->oops_pages / (mtd->erasesize / OOPS_PAGE_SIZE))) {
-                       printk(KERN_ERR "mtdoops: All blocks bad!\n");
+               if (i == cxt->oops_pages / (mtd->erasesize / record_size)) {
+                       printk(KERN_ERR "mtdoops: all blocks bad!\n");
                        return;
                }
        }
 
        for (j = 0, ret = -1; (j < 3) && (ret < 0); j++)
-               ret = mtdoops_erase_block(mtd, cxt->nextpage * OOPS_PAGE_SIZE);
+               ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size);
 
        if (ret >= 0) {
-               printk(KERN_DEBUG "mtdoops: Ready %d, %d \n", cxt->nextpage, cxt->nextcount);
-               cxt->ready = 1;
+               printk(KERN_DEBUG "mtdoops: ready %d, %d\n",
+                      cxt->nextpage, cxt->nextcount);
                return;
        }
 
-       if (mtd->block_markbad && (ret == -EIO)) {
-               ret = mtd->block_markbad(mtd, cxt->nextpage * OOPS_PAGE_SIZE);
+       if (mtd->block_markbad && ret == -EIO) {
+               ret = mtd->block_markbad(mtd, cxt->nextpage * record_size);
                if (ret < 0) {
-                       printk(KERN_ERR "mtdoops: block_markbad failed, aborting.\n");
+                       printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n");
                        return;
                }
        }
@@ -191,36 +213,37 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
 {
        struct mtd_info *mtd = cxt->mtd;
        size_t retlen;
+       u32 *hdr;
        int ret;
 
-       if (cxt->writecount < OOPS_PAGE_SIZE)
-               memset(cxt->oops_buf + cxt->writecount, 0xff,
-                                       OOPS_PAGE_SIZE - cxt->writecount);
+       /* Add mtdoops header to the buffer */
+       hdr = cxt->oops_buf;
+       hdr[0] = cxt->nextcount;
+       hdr[1] = MTDOOPS_KERNMSG_MAGIC;
 
        if (panic)
-               ret = mtd->panic_write(mtd, cxt->nextpage * OOPS_PAGE_SIZE,
-                                       OOPS_PAGE_SIZE, &retlen, cxt->oops_buf);
+               ret = mtd->panic_write(mtd, cxt->nextpage * record_size,
+                                       record_size, &retlen, cxt->oops_buf);
        else
-               ret = mtd->write(mtd, cxt->nextpage * OOPS_PAGE_SIZE,
-                                       OOPS_PAGE_SIZE, &retlen, cxt->oops_buf);
-
-       cxt->writecount = 0;
+               ret = mtd->write(mtd, cxt->nextpage * record_size,
+                                       record_size, &retlen, cxt->oops_buf);
 
-       if ((retlen != OOPS_PAGE_SIZE) || (ret < 0))
-               printk(KERN_ERR "mtdoops: Write failure at %d (%td of %d written), err %d.\n",
-                       cxt->nextpage * OOPS_PAGE_SIZE, retlen, OOPS_PAGE_SIZE, ret);
+       if (retlen != record_size || ret < 0)
+               printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n",
+                      cxt->nextpage * record_size, retlen, record_size, ret);
+       mark_page_used(cxt, cxt->nextpage);
+       memset(cxt->oops_buf, 0xff, record_size);
 
        mtdoops_inc_counter(cxt);
 }
 
-
 static void mtdoops_workfunc_write(struct work_struct *work)
 {
        struct mtdoops_context *cxt =
                        container_of(work, struct mtdoops_context, work_write);
 
        mtdoops_write(cxt, 0);
-}                                      
+}
 
 static void find_next_position(struct mtdoops_context *cxt)
 {
@@ -230,28 +253,33 @@ static void find_next_position(struct mtdoops_context *cxt)
        size_t retlen;
 
        for (page = 0; page < cxt->oops_pages; page++) {
-               ret = mtd->read(mtd, page * OOPS_PAGE_SIZE, 8, &retlen, (u_char *) &count[0]);
-               if ((retlen != 8) || ((ret < 0) && (ret != -EUCLEAN))) {
-                       printk(KERN_ERR "mtdoops: Read failure at %d (%td of 8 read)"
-                               ", err %d.\n", page * OOPS_PAGE_SIZE, retlen, ret);
+               /* Assume the page is used */
+               mark_page_used(cxt, page);
+               ret = mtd->read(mtd, page * record_size, MTDOOPS_HEADER_SIZE,
+                               &retlen, (u_char *) &count[0]);
+               if (retlen != MTDOOPS_HEADER_SIZE ||
+                               (ret < 0 && ret != -EUCLEAN)) {
+                       printk(KERN_ERR "mtdoops: read failure at %ld (%td of %d read), err %d\n",
+                              page * record_size, retlen,
+                              MTDOOPS_HEADER_SIZE, ret);
                        continue;
                }
 
-               if (count[1] != MTDOOPS_KERNMSG_MAGIC)
-                       continue;
+               if (count[0] == 0xffffffff && count[1] == 0xffffffff)
+                       mark_page_unused(cxt, page);
                if (count[0] == 0xffffffff)
                        continue;
                if (maxcount == 0xffffffff) {
                        maxcount = count[0];
                        maxpos = page;
-               } else if ((count[0] < 0x40000000) && (maxcount > 0xc0000000)) {
+               } else if (count[0] < 0x40000000 && maxcount > 0xc0000000) {
                        maxcount = count[0];
                        maxpos = page;
-               } else if ((count[0] > maxcount) && (count[0] < 0xc0000000)) {
+               } else if (count[0] > maxcount && count[0] < 0xc0000000) {
                        maxcount = count[0];
                        maxpos = page;
-               } else if ((count[0] > maxcount) && (count[0] > 0xc0000000)
-                                       && (maxcount > 0x80000000)) {
+               } else if (count[0] > maxcount && count[0] > 0xc0000000
+                                       && maxcount > 0x80000000) {
                        maxcount = count[0];
                        maxpos = page;
                }
@@ -269,187 +297,170 @@ static void find_next_position(struct mtdoops_context *cxt)
        mtdoops_inc_counter(cxt);
 }
 
-
-static void mtdoops_notify_add(struct mtd_info *mtd)
+static void mtdoops_do_dump(struct kmsg_dumper *dumper,
+               enum kmsg_dump_reason reason, const char *s1, unsigned long l1,
+               const char *s2, unsigned long l2)
 {
-       struct mtdoops_context *cxt = &oops_cxt;
+       struct mtdoops_context *cxt = container_of(dumper,
+                       struct mtdoops_context, dump);
+       unsigned long s1_start, s2_start;
+       unsigned long l1_cpy, l2_cpy;
+       char *dst;
+
+       /* Only dump oopses if dump_oops is set */
+       if (reason == KMSG_DUMP_OOPS && !dump_oops)
+               return;
 
-       if (cxt->name && !strcmp(mtd->name, cxt->name))
-               cxt->mtd_index = mtd->index;
+       dst = cxt->oops_buf + MTDOOPS_HEADER_SIZE; /* Skip the header */
+       l2_cpy = min(l2, record_size - MTDOOPS_HEADER_SIZE);
+       l1_cpy = min(l1, record_size - MTDOOPS_HEADER_SIZE - l2_cpy);
 
-       if ((mtd->index != cxt->mtd_index) || cxt->mtd_index < 0)
-               return;
+       s2_start = l2 - l2_cpy;
+       s1_start = l1 - l1_cpy;
 
-       if (mtd->size < (mtd->erasesize * 2)) {
-               printk(KERN_ERR "MTD partition %d not big enough for mtdoops\n",
-                               mtd->index);
-               return;
-       }
+       memcpy(dst, s1 + s1_start, l1_cpy);
+       memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);
 
-       if (mtd->erasesize < OOPS_PAGE_SIZE) {
-               printk(KERN_ERR "Eraseblock size of MTD partition %d too small\n",
-                               mtd->index);
+       /* Panics must be written immediately */
+       if (reason == KMSG_DUMP_PANIC) {
+               if (!cxt->mtd->panic_write)
+                       printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n");
+               else
+                       mtdoops_write(cxt, 1);
                return;
        }
 
-       cxt->mtd = mtd;
-       if (mtd->size > INT_MAX)
-               cxt->oops_pages = INT_MAX / OOPS_PAGE_SIZE;
-       else
-               cxt->oops_pages = (int)mtd->size / OOPS_PAGE_SIZE;
-
-       find_next_position(cxt);
-
-       printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index);
+       /* For other cases, schedule work to write it "nicely" */
+       schedule_work(&cxt->work_write);
 }
 
-static void mtdoops_notify_remove(struct mtd_info *mtd)
+static void mtdoops_notify_add(struct mtd_info *mtd)
 {
        struct mtdoops_context *cxt = &oops_cxt;
+       u64 mtdoops_pages = div_u64(mtd->size, record_size);
+       int err;
 
-       if ((mtd->index != cxt->mtd_index) || cxt->mtd_index < 0)
-               return;
-
-       cxt->mtd = NULL;
-       flush_scheduled_work();
-}
-
-static void mtdoops_console_sync(void)
-{
-       struct mtdoops_context *cxt = &oops_cxt;
-       struct mtd_info *mtd = cxt->mtd;
-       unsigned long flags;
+       if (!strcmp(mtd->name, mtddev))
+               cxt->mtd_index = mtd->index;
 
-       if (!cxt->ready || !mtd || cxt->writecount == 0)
+       if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0)
                return;
 
-       /* 
-        *  Once ready is 0 and we've held the lock no further writes to the 
-        *  buffer will happen
-        */
-       spin_lock_irqsave(&cxt->writecount_lock, flags);
-       if (!cxt->ready) {
-               spin_unlock_irqrestore(&cxt->writecount_lock, flags);
+       if (mtd->size < mtd->erasesize * 2) {
+               printk(KERN_ERR "mtdoops: MTD partition %d not big enough for mtdoops\n",
+                      mtd->index);
                return;
        }
-       cxt->ready = 0;
-       spin_unlock_irqrestore(&cxt->writecount_lock, flags);
-
-       if (mtd->panic_write && in_interrupt())
-               /* Interrupt context, we're going to panic so try and log */
-               mtdoops_write(cxt, 1);
-       else
-               schedule_work(&cxt->work_write);
-}
-
-static void
-mtdoops_console_write(struct console *co, const char *s, unsigned int count)
-{
-       struct mtdoops_context *cxt = co->data;
-       struct mtd_info *mtd = cxt->mtd;
-       unsigned long flags;
-
-       if (!oops_in_progress) {
-               mtdoops_console_sync();
+       if (mtd->erasesize < record_size) {
+               printk(KERN_ERR "mtdoops: eraseblock size of MTD partition %d too small\n",
+                      mtd->index);
                return;
        }
-
-       if (!cxt->ready || !mtd)
+       if (mtd->size > MTDOOPS_MAX_MTD_SIZE) {
+               printk(KERN_ERR "mtdoops: mtd%d is too large (limit is %d MiB)\n",
+                      mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024);
                return;
+       }
 
-       /* Locking on writecount ensures sequential writes to the buffer */
-       spin_lock_irqsave(&cxt->writecount_lock, flags);
-
-       /* Check ready status didn't change whilst waiting for the lock */
-       if (!cxt->ready) {
-               spin_unlock_irqrestore(&cxt->writecount_lock, flags);
+       /* oops_page_used is a bit field */
+       cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
+                       BITS_PER_LONG));
+       if (!cxt->oops_page_used) {
+               printk(KERN_ERR "mtdoops: could not allocate page array\n");
                return;
        }
 
-       if (cxt->writecount == 0) {
-               u32 *stamp = cxt->oops_buf;
-               *stamp++ = cxt->nextcount;
-               *stamp = MTDOOPS_KERNMSG_MAGIC;
-               cxt->writecount = 8;
+       cxt->dump.dump = mtdoops_do_dump;
+       err = kmsg_dump_register(&cxt->dump);
+       if (err) {
+               printk(KERN_ERR "mtdoops: registering kmsg dumper failed, error %d\n", err);
+               vfree(cxt->oops_page_used);
+               cxt->oops_page_used = NULL;
+               return;
        }
 
-       if ((count + cxt->writecount) > OOPS_PAGE_SIZE)
-               count = OOPS_PAGE_SIZE - cxt->writecount;
-
-       memcpy(cxt->oops_buf + cxt->writecount, s, count);
-       cxt->writecount += count;
-
-       spin_unlock_irqrestore(&cxt->writecount_lock, flags);
-
-       if (cxt->writecount == OOPS_PAGE_SIZE)
-               mtdoops_console_sync();
+       cxt->mtd = mtd;
+       cxt->oops_pages = (int)mtd->size / record_size;
+       find_next_position(cxt);
+       printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index);
 }
 
-static int __init mtdoops_console_setup(struct console *co, char *options)
+static void mtdoops_notify_remove(struct mtd_info *mtd)
 {
-       struct mtdoops_context *cxt = co->data;
+       struct mtdoops_context *cxt = &oops_cxt;
 
-       if (cxt->mtd_index != -1 || cxt->name)
-               return -EBUSY;
-       if (options) {
-               cxt->name = kstrdup(options, GFP_KERNEL);
-               return 0;
-       }
-       if (co->index == -1)
-               return -EINVAL;
+       if (mtd->index != cxt->mtd_index || cxt->mtd_index < 0)
+               return;
 
-       cxt->mtd_index = co->index;
-       return 0;
+       if (kmsg_dump_unregister(&cxt->dump) < 0)
+               printk(KERN_WARNING "mtdoops: could not unregister kmsg_dumper\n");
+
+       cxt->mtd = NULL;
+       flush_scheduled_work();
 }
 
+
 static struct mtd_notifier mtdoops_notifier = {
        .add    = mtdoops_notify_add,
        .remove = mtdoops_notify_remove,
 };
 
-static struct console mtdoops_console = {
-       .name           = "ttyMTD",
-       .write          = mtdoops_console_write,
-       .setup          = mtdoops_console_setup,
-       .unblank        = mtdoops_console_sync,
-       .index          = -1,
-       .data           = &oops_cxt,
-};
-
-static int __init mtdoops_console_init(void)
+static int __init mtdoops_init(void)
 {
        struct mtdoops_context *cxt = &oops_cxt;
+       int mtd_index;
+       char *endp;
 
+       if (strlen(mtddev) == 0) {
+               printk(KERN_ERR "mtdoops: mtd device (mtddev=name/number) must be supplied\n");
+               return -EINVAL;
+       }
+       if ((record_size & 4095) != 0) {
+               printk(KERN_ERR "mtdoops: record_size must be a multiple of 4096\n");
+               return -EINVAL;
+       }
+       if (record_size < 4096) {
+               printk(KERN_ERR "mtdoops: record_size must be over 4096 bytes\n");
+               return -EINVAL;
+       }
+
+       /* Setup the MTD device to use */
        cxt->mtd_index = -1;
-       cxt->oops_buf = vmalloc(OOPS_PAGE_SIZE);
-       spin_lock_init(&cxt->writecount_lock);
+       mtd_index = simple_strtoul(mtddev, &endp, 0);
+       if (*endp == '\0')
+               cxt->mtd_index = mtd_index;
+       if (cxt->mtd_index > MAX_MTD_DEVICES) {
+               printk(KERN_ERR "mtdoops: invalid mtd device number (%u) given\n",
+                               mtd_index);
+               return -EINVAL;
+       }
 
+       cxt->oops_buf = vmalloc(record_size);
        if (!cxt->oops_buf) {
-               printk(KERN_ERR "Failed to allocate mtdoops buffer workspace\n");
+               printk(KERN_ERR "mtdoops: failed to allocate buffer workspace\n");
                return -ENOMEM;
        }
+       memset(cxt->oops_buf, 0xff, record_size);
 
        INIT_WORK(&cxt->work_erase, mtdoops_workfunc_erase);
        INIT_WORK(&cxt->work_write, mtdoops_workfunc_write);
 
-       register_console(&mtdoops_console);
        register_mtd_user(&mtdoops_notifier);
        return 0;
 }
 
-static void __exit mtdoops_console_exit(void)
+static void __exit mtdoops_exit(void)
 {
        struct mtdoops_context *cxt = &oops_cxt;
 
        unregister_mtd_user(&mtdoops_notifier);
-       unregister_console(&mtdoops_console);
-       kfree(cxt->name);
        vfree(cxt->oops_buf);
+       vfree(cxt->oops_page_used);
 }
 
 
-subsys_initcall(mtdoops_console_init);
-module_exit(mtdoops_console_exit);
+module_init(mtdoops_init);
+module_exit(mtdoops_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
index 0e35e1aefd220f736298ab9a82b0c7a15e5fbd49..677cd53f18c3416c489a11b3934c42b16c14a49a 100644 (file)
@@ -201,6 +201,22 @@ config MTD_NAND_S3C2410_CLKSTOP
          when the is NAND chip selected or released, but will save
          approximately 5mA of power when there is nothing happening.
 
+config MTD_NAND_BCM_UMI
+       tristate "NAND Flash support for BCM Reference Boards"
+       depends on ARCH_BCMRING && MTD_NAND
+       help
+         This enables the NAND flash controller on the BCM UMI block.
+
+         No board specfic support is done by this driver, each board
+         must advertise a platform_device for the driver to attach.
+
+config MTD_NAND_BCM_UMI_HWCS
+       bool "BCM UMI NAND Hardware CS"
+       depends on MTD_NAND_BCM_UMI
+       help
+         Enable the use of the BCM UMI block's internal CS using NAND.
+         This should only be used if you know the external NAND CS can toggle.
+
 config MTD_NAND_DISKONCHIP
        tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation) (EXPERIMENTAL)"
        depends on EXPERIMENTAL
@@ -275,14 +291,6 @@ config MTD_NAND_SHARPSL
        tristate "Support for NAND Flash on Sharp SL Series (C7xx + others)"
        depends on ARCH_PXA
 
-config MTD_NAND_BASLER_EXCITE
-       tristate  "Support for NAND Flash on Basler eXcite"
-       depends on BASLER_EXCITE
-       help
-          This enables the driver for the NAND flash device found on the
-          Basler eXcite Smart Camera. If built as a module, the driver
-          will be named excite_nandflash.
-
 config MTD_NAND_CAFE
        tristate "NAND support for OLPC CAFÉ chip"
        depends on PCI
index 6950d3dabf104a1815fa5699183633d36b4ae955..1407bd1440154b0373bce8e253b619db9f039b4a 100644 (file)
@@ -27,7 +27,6 @@ obj-$(CONFIG_MTD_NAND_ATMEL)          += atmel_nand.o
 obj-$(CONFIG_MTD_NAND_GPIO)            += gpio.o
 obj-$(CONFIG_MTD_NAND_OMAP2)           += omap2.o
 obj-$(CONFIG_MTD_NAND_CM_X270)         += cmx270_nand.o
-obj-$(CONFIG_MTD_NAND_BASLER_EXCITE)   += excite_nandflash.o
 obj-$(CONFIG_MTD_NAND_PXA3xx)          += pxa3xx_nand.o
 obj-$(CONFIG_MTD_NAND_TMIO)            += tmio_nand.o
 obj-$(CONFIG_MTD_NAND_PLATFORM)                += plat_nand.o
@@ -42,5 +41,6 @@ obj-$(CONFIG_MTD_NAND_SOCRATES)               += socrates_nand.o
 obj-$(CONFIG_MTD_NAND_TXX9NDFMC)       += txx9ndfmc.o
 obj-$(CONFIG_MTD_NAND_W90P910)         += w90p910_nand.o
 obj-$(CONFIG_MTD_NAND_NOMADIK)         += nomadik_nand.o
+obj-$(CONFIG_MTD_NAND_BCM_UMI)         += bcm_umi_nand.o nand_bcm_umi.o
 
 nand-objs := nand_base.o nand_bbt.o
index 6d9649159a18ad49f88c3e89e88df39ce3906864..2d6773281fd90b967bb98b05e4b1cf6299c66cab 100644 (file)
@@ -372,15 +372,6 @@ static int alauda_read_oob(struct mtd_info *mtd, loff_t from, void *oob)
        return __alauda_read_page(mtd, from, ignore_buf, oob);
 }
 
-static int popcount8(u8 c)
-{
-       int ret = 0;
-
-       for ( ; c; c>>=1)
-               ret += c & 1;
-       return ret;
-}
-
 static int alauda_isbad(struct mtd_info *mtd, loff_t ofs)
 {
        u8 oob[16];
@@ -391,7 +382,7 @@ static int alauda_isbad(struct mtd_info *mtd, loff_t ofs)
                return err;
 
        /* A block is marked bad if two or more bits are zero */
-       return popcount8(oob[5]) >= 7 ? 0 : 1;
+       return hweight8(oob[5]) >= 7 ? 0 : 1;
 }
 
 static int alauda_bounce_read(struct mtd_info *mtd, loff_t from, size_t len,
index f8e9975c86e562ca471601ca5f129ee9f402e7cc..524e6c9e0672a2b800a91d4858269cc4f4e745b7 100644 (file)
@@ -192,7 +192,6 @@ static int atmel_nand_calculate(struct mtd_info *mtd,
 {
        struct nand_chip *nand_chip = mtd->priv;
        struct atmel_nand_host *host = nand_chip->priv;
-       uint32_t *eccpos = nand_chip->ecc.layout->eccpos;
        unsigned int ecc_value;
 
        /* get the first 2 ECC bytes */
@@ -464,7 +463,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
        if (host->board->det_pin) {
                if (gpio_get_value(host->board->det_pin)) {
                        printk(KERN_INFO "No SmartMedia card inserted.\n");
-                       res = ENXIO;
+                       res = -ENXIO;
                        goto err_no_card;
                }
        }
@@ -535,7 +534,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
 
        if ((!partitions) || (num_partitions == 0)) {
                printk(KERN_ERR "atmel_nand: No partitions defined, or unsupported device.\n");
-               res = ENXIO;
+               res = -ENXIO;
                goto err_no_partitions;
        }
 
diff --git a/drivers/mtd/nand/bcm_umi_bch.c b/drivers/mtd/nand/bcm_umi_bch.c
new file mode 100644 (file)
index 0000000..a930666
--- /dev/null
@@ -0,0 +1,213 @@
+/*****************************************************************************
+* Copyright 2004 - 2009 Broadcom Corporation.  All rights reserved.
+*
+* Unless you and Broadcom execute a separate written software license
+* agreement governing use of this software, this software is licensed to you
+* under the terms of the GNU General Public License version 2, available at
+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
+*
+* Notwithstanding the above, under no circumstances may you combine this
+* software in any way with any other Broadcom software provided under a
+* license other than the GPL, without Broadcom's express prior written
+* consent.
+*****************************************************************************/
+
+/* ---- Include Files ---------------------------------------------------- */
+#include "nand_bcm_umi.h"
+
+/* ---- External Variable Declarations ----------------------------------- */
+/* ---- External Function Prototypes ------------------------------------- */
+/* ---- Public Variables ------------------------------------------------- */
+/* ---- Private Constants and Types -------------------------------------- */
+
+/* ---- Private Function Prototypes -------------------------------------- */
+static int bcm_umi_bch_read_page_hwecc(struct mtd_info *mtd,
+       struct nand_chip *chip, uint8_t *buf, int page);
+static void bcm_umi_bch_write_page_hwecc(struct mtd_info *mtd,
+       struct nand_chip *chip, const uint8_t *buf);
+
+/* ---- Private Variables ------------------------------------------------ */
+
+/*
+** nand_hw_eccoob
+** New oob placement block for use with hardware ecc generation.
+*/
+static struct nand_ecclayout nand_hw_eccoob_512 = {
+       /* Reserve 5 for BI indicator */
+       .oobfree = {
+#if (NAND_ECC_NUM_BYTES > 3)
+                   {.offset = 0, .length = 2}
+#else
+                   {.offset = 0, .length = 5},
+                   {.offset = 6, .length = 7}
+#endif
+                   }
+};
+
+/*
+** We treat the OOB for a 2K page as if it were 4 512 byte oobs,
+** except the BI is at byte 0.
+*/
+static struct nand_ecclayout nand_hw_eccoob_2048 = {
+       /* Reserve 0 as BI indicator */
+       .oobfree = {
+#if (NAND_ECC_NUM_BYTES > 10)
+                   {.offset = 1, .length = 2},
+#elif (NAND_ECC_NUM_BYTES > 7)
+                   {.offset = 1, .length = 5},
+                   {.offset = 16, .length = 6},
+                   {.offset = 32, .length = 6},
+                   {.offset = 48, .length = 6}
+#else
+                   {.offset = 1, .length = 8},
+                   {.offset = 16, .length = 9},
+                   {.offset = 32, .length = 9},
+                   {.offset = 48, .length = 9}
+#endif
+                   }
+};
+
+/* We treat the OOB for a 4K page as if it were 8 512 byte oobs,
+ * except the BI is at byte 0. */
+static struct nand_ecclayout nand_hw_eccoob_4096 = {
+       /* Reserve 0 as BI indicator */
+       .oobfree = {
+#if (NAND_ECC_NUM_BYTES > 10)
+                   {.offset = 1, .length = 2},
+                   {.offset = 16, .length = 3},
+                   {.offset = 32, .length = 3},
+                   {.offset = 48, .length = 3},
+                   {.offset = 64, .length = 3},
+                   {.offset = 80, .length = 3},
+                   {.offset = 96, .length = 3},
+                   {.offset = 112, .length = 3}
+#else
+                   {.offset = 1, .length = 5},
+                   {.offset = 16, .length = 6},
+                   {.offset = 32, .length = 6},
+                   {.offset = 48, .length = 6},
+                   {.offset = 64, .length = 6},
+                   {.offset = 80, .length = 6},
+                   {.offset = 96, .length = 6},
+                   {.offset = 112, .length = 6}
+#endif
+                   }
+};
+
+/* ---- Private Functions ------------------------------------------------ */
+/* ==== Public Functions ================================================= */
+
+/****************************************************************************
+*
+*  bcm_umi_bch_read_page_hwecc - hardware ecc based page read function
+*  @mtd:       mtd info structure
+*  @chip:      nand chip info structure
+*  @buf:       buffer to store read data
+*
+***************************************************************************/
+static int bcm_umi_bch_read_page_hwecc(struct mtd_info *mtd,
+                                      struct nand_chip *chip, uint8_t * buf,
+                                                int page)
+{
+       int sectorIdx = 0;
+       int eccsize = chip->ecc.size;
+       int eccsteps = chip->ecc.steps;
+       uint8_t *datap = buf;
+       uint8_t eccCalc[NAND_ECC_NUM_BYTES];
+       int sectorOobSize = mtd->oobsize / eccsteps;
+       int stat;
+
+       for (sectorIdx = 0; sectorIdx < eccsteps;
+                       sectorIdx++, datap += eccsize) {
+               if (sectorIdx > 0) {
+                       /* Seek to page location within sector */
+                       chip->cmdfunc(mtd, NAND_CMD_RNDOUT, sectorIdx * eccsize,
+                                     -1);
+               }
+
+               /* Enable hardware ECC before reading the buf */
+               nand_bcm_umi_bch_enable_read_hwecc();
+
+               /* Read in data */
+               bcm_umi_nand_read_buf(mtd, datap, eccsize);
+
+               /* Pause hardware ECC after reading the buf */
+               nand_bcm_umi_bch_pause_read_ecc_calc();
+
+               /* Read the OOB ECC */
+               chip->cmdfunc(mtd, NAND_CMD_RNDOUT,
+                             mtd->writesize + sectorIdx * sectorOobSize, -1);
+               nand_bcm_umi_bch_read_oobEcc(mtd->writesize, eccCalc,
+                                            NAND_ECC_NUM_BYTES,
+                                            chip->oob_poi +
+                                            sectorIdx * sectorOobSize);
+
+               /* Correct any ECC detected errors */
+               stat =
+                   nand_bcm_umi_bch_correct_page(datap, eccCalc,
+                                                 NAND_ECC_NUM_BYTES);
+
+               /* Update Stats */
+               if (stat < 0) {
+#if defined(NAND_BCM_UMI_DEBUG)
+                       printk(KERN_WARNING "%s uncorr_err sectorIdx=%d\n",
+                              __func__, sectorIdx);
+                       printk(KERN_WARNING
+                              "%s data %02x %02x %02x %02x "
+                                        "%02x %02x %02x %02x\n",
+                              __func__, datap[0], datap[1], datap[2], datap[3],
+                              datap[4], datap[5], datap[6], datap[7]);
+                       printk(KERN_WARNING
+                              "%s ecc  %02x %02x %02x %02x "
+                                        "%02x %02x %02x %02x %02x %02x "
+                                        "%02x %02x %02x\n",
+                              __func__, eccCalc[0], eccCalc[1], eccCalc[2],
+                              eccCalc[3], eccCalc[4], eccCalc[5], eccCalc[6],
+                              eccCalc[7], eccCalc[8], eccCalc[9], eccCalc[10],
+                              eccCalc[11], eccCalc[12]);
+                       BUG();
+#endif
+                       mtd->ecc_stats.failed++;
+               } else {
+#if defined(NAND_BCM_UMI_DEBUG)
+                       if (stat > 0) {
+                               printk(KERN_INFO
+                                      "%s %d correctable_errors detected\n",
+                                      __func__, stat);
+                       }
+#endif
+                       mtd->ecc_stats.corrected += stat;
+               }
+       }
+       return 0;
+}
+
+/****************************************************************************
+*
+*  bcm_umi_bch_write_page_hwecc - hardware ecc based page write function
+*  @mtd:       mtd info structure
+*  @chip:      nand chip info structure
+*  @buf:       data buffer
+*
+***************************************************************************/
+static void bcm_umi_bch_write_page_hwecc(struct mtd_info *mtd,
+       struct nand_chip *chip, const uint8_t *buf)
+{
+       int sectorIdx = 0;
+       int eccsize = chip->ecc.size;
+       int eccsteps = chip->ecc.steps;
+       const uint8_t *datap = buf;
+       uint8_t *oobp = chip->oob_poi;
+       int sectorOobSize = mtd->oobsize / eccsteps;
+
+       for (sectorIdx = 0; sectorIdx < eccsteps;
+            sectorIdx++, datap += eccsize, oobp += sectorOobSize) {
+               /* Enable hardware ECC before writing the buf */
+               nand_bcm_umi_bch_enable_write_hwecc();
+               bcm_umi_nand_write_buf(mtd, datap, eccsize);
+               nand_bcm_umi_bch_write_oobEcc(mtd->writesize, oobp,
+                                             NAND_ECC_NUM_BYTES);
+       }
+
+       bcm_umi_nand_write_buf(mtd, chip->oob_poi, mtd->oobsize);
+}
diff --git a/drivers/mtd/nand/bcm_umi_nand.c b/drivers/mtd/nand/bcm_umi_nand.c
new file mode 100644 (file)
index 0000000..087bcd7
--- /dev/null
@@ -0,0 +1,581 @@
+/*****************************************************************************
+* Copyright 2004 - 2009 Broadcom Corporation.  All rights reserved.
+*
+* Unless you and Broadcom execute a separate written software license
+* agreement governing use of this software, this software is licensed to you
+* under the terms of the GNU General Public License version 2, available at
+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
+*
+* Notwithstanding the above, under no circumstances may you combine this
+* software in any way with any other Broadcom software provided under a
+* license other than the GPL, without Broadcom's express prior written
+* consent.
+*****************************************************************************/
+
+/* ---- Include Files ---------------------------------------------------- */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/string.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/nand_ecc.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/mach-types.h>
+#include <asm/system.h>
+
+#include <mach/reg_nand.h>
+#include <mach/reg_umi.h>
+
+#include "nand_bcm_umi.h"
+
+#include <mach/memory_settings.h>
+
+#define USE_DMA 1
+#include <mach/dma.h>
+#include <linux/dma-mapping.h>
+#include <linux/completion.h>
+
+/* ---- External Variable Declarations ----------------------------------- */
+/* ---- External Function Prototypes ------------------------------------- */
+/* ---- Public Variables ------------------------------------------------- */
+/* ---- Private Constants and Types -------------------------------------- */
+static const __devinitconst char gBanner[] = KERN_INFO \
+       "BCM UMI MTD NAND Driver: 1.00\n";
+
+#ifdef CONFIG_MTD_PARTITIONS
+const char *part_probes[] = { "cmdlinepart", NULL };
+#endif
+
+#if NAND_ECC_BCH
+static uint8_t scan_ff_pattern[] = { 0xff };
+
+static struct nand_bbt_descr largepage_bbt = {
+       .options = 0,
+       .offs = 0,
+       .len = 1,
+       .pattern = scan_ff_pattern
+};
+#endif
+
+/*
+** Preallocate a buffer to avoid having to do this every dma operation.
+** This is the size of the preallocated coherent DMA buffer.
+*/
+#if USE_DMA
+#define DMA_MIN_BUFLEN 512
+#define DMA_MAX_BUFLEN PAGE_SIZE
+#define USE_DIRECT_IO(len)     (((len) < DMA_MIN_BUFLEN) || \
+       ((len) > DMA_MAX_BUFLEN))
+
+/*
+ * The current NAND data space goes from 0x80001900 to 0x80001FFF,
+ * which is only 0x700 = 1792 bytes long. This is too small for 2K, 4K page
+ * size NAND flash. Need to break the DMA down to multiple 1Ks.
+ *
+ * Need to make sure REG_NAND_DATA_PADDR + DMA_MAX_LEN < 0x80002000
+ */
+#define DMA_MAX_LEN             1024
+
+#else /* !USE_DMA */
+#define DMA_MIN_BUFLEN          0
+#define DMA_MAX_BUFLEN          0
+#define USE_DIRECT_IO(len)      1
+#endif
+/* ---- Private Function Prototypes -------------------------------------- */
+static void bcm_umi_nand_read_buf(struct mtd_info *mtd, u_char * buf, int len);
+static void bcm_umi_nand_write_buf(struct mtd_info *mtd, const u_char * buf,
+                                  int len);
+
+/* ---- Private Variables ------------------------------------------------ */
+static struct mtd_info *board_mtd;
+static void __iomem *bcm_umi_io_base;
+static void *virtPtr;
+static dma_addr_t physPtr;
+static struct completion nand_comp;
+
+/* ---- Private Functions ------------------------------------------------ */
+#if NAND_ECC_BCH
+#include "bcm_umi_bch.c"
+#else
+#include "bcm_umi_hamming.c"
+#endif
+
+#if USE_DMA
+
+/* Handler called when the DMA finishes. */
+static void nand_dma_handler(DMA_Device_t dev, int reason, void *userData)
+{
+       complete(&nand_comp);
+}
+
+static int nand_dma_init(void)
+{
+       int rc;
+
+       rc = dma_set_device_handler(DMA_DEVICE_NAND_MEM_TO_MEM,
+               nand_dma_handler, NULL);
+       if (rc != 0) {
+               printk(KERN_ERR "dma_set_device_handler failed: %d\n", rc);
+               return rc;
+       }
+
+       virtPtr =
+           dma_alloc_coherent(NULL, DMA_MAX_BUFLEN, &physPtr, GFP_KERNEL);
+       if (virtPtr == NULL) {
+               printk(KERN_ERR "NAND - Failed to allocate memory for DMA buffer\n");
+               return -ENOMEM;
+       }
+
+       return 0;
+}
+
+static void nand_dma_term(void)
+{
+       if (virtPtr != NULL)
+               dma_free_coherent(NULL, DMA_MAX_BUFLEN, virtPtr, physPtr);
+}
+
+static void nand_dma_read(void *buf, int len)
+{
+       int offset = 0;
+       int tmp_len = 0;
+       int len_left = len;
+       DMA_Handle_t hndl;
+
+       if (virtPtr == NULL)
+               panic("nand_dma_read: virtPtr == NULL\n");
+
+       if ((void *)physPtr == NULL)
+               panic("nand_dma_read: physPtr == NULL\n");
+
+       hndl = dma_request_channel(DMA_DEVICE_NAND_MEM_TO_MEM);
+       if (hndl < 0) {
+               printk(KERN_ERR
+                      "nand_dma_read: unable to allocate dma channel: %d\n",
+                      (int)hndl);
+               panic("\n");
+       }
+
+       while (len_left > 0) {
+               if (len_left > DMA_MAX_LEN) {
+                       tmp_len = DMA_MAX_LEN;
+                       len_left -= DMA_MAX_LEN;
+               } else {
+                       tmp_len = len_left;
+                       len_left = 0;
+               }
+
+               init_completion(&nand_comp);
+               dma_transfer_mem_to_mem(hndl, REG_NAND_DATA_PADDR,
+                                       physPtr + offset, tmp_len);
+               wait_for_completion(&nand_comp);
+
+               offset += tmp_len;
+       }
+
+       dma_free_channel(hndl);
+
+       if (buf != NULL)
+               memcpy(buf, virtPtr, len);
+}
+
+static void nand_dma_write(const void *buf, int len)
+{
+       int offset = 0;
+       int tmp_len = 0;
+       int len_left = len;
+       DMA_Handle_t hndl;
+
+       if (buf == NULL)
+               panic("nand_dma_write: buf == NULL\n");
+
+       if (virtPtr == NULL)
+               panic("nand_dma_write: virtPtr == NULL\n");
+
+       if ((void *)physPtr == NULL)
+               panic("nand_dma_write: physPtr == NULL\n");
+
+       memcpy(virtPtr, buf, len);
+
+
+       hndl = dma_request_channel(DMA_DEVICE_NAND_MEM_TO_MEM);
+       if (hndl < 0) {
+               printk(KERN_ERR
+                      "nand_dma_write: unable to allocate dma channel: %d\n",
+                      (int)hndl);
+               panic("\n");
+       }
+
+       while (len_left > 0) {
+               if (len_left > DMA_MAX_LEN) {
+                       tmp_len = DMA_MAX_LEN;
+                       len_left -= DMA_MAX_LEN;
+               } else {
+                       tmp_len = len_left;
+                       len_left = 0;
+               }
+
+               init_completion(&nand_comp);
+               dma_transfer_mem_to_mem(hndl, physPtr + offset,
+                                       REG_NAND_DATA_PADDR, tmp_len);
+               wait_for_completion(&nand_comp);
+
+               offset += tmp_len;
+       }
+
+       dma_free_channel(hndl);
+}
+
+#endif
+
+static int nand_dev_ready(struct mtd_info *mtd)
+{
+       return nand_bcm_umi_dev_ready();
+}
+
+/****************************************************************************
+*
+*  bcm_umi_nand_inithw
+*
+*   This routine does the necessary hardware (board-specific)
+*   initializations.  This includes setting up the timings, etc.
+*
+***************************************************************************/
+int bcm_umi_nand_inithw(void)
+{
+       /* Configure nand timing parameters */
+       REG_UMI_NAND_TCR &= ~0x7ffff;
+       REG_UMI_NAND_TCR |= HW_CFG_NAND_TCR;
+
+#if !defined(CONFIG_MTD_NAND_BCM_UMI_HWCS)
+       /* enable software control of CS */
+       REG_UMI_NAND_TCR |= REG_UMI_NAND_TCR_CS_SWCTRL;
+#endif
+
+       /* keep NAND chip select asserted */
+       REG_UMI_NAND_RCSR |= REG_UMI_NAND_RCSR_CS_ASSERTED;
+
+       REG_UMI_NAND_TCR &= ~REG_UMI_NAND_TCR_WORD16;
+       /* enable writes to flash */
+       REG_UMI_MMD_ICR |= REG_UMI_MMD_ICR_FLASH_WP;
+
+       writel(NAND_CMD_RESET, bcm_umi_io_base + REG_NAND_CMD_OFFSET);
+       nand_bcm_umi_wait_till_ready();
+
+#if NAND_ECC_BCH
+       nand_bcm_umi_bch_config_ecc(NAND_ECC_NUM_BYTES);
+#endif
+
+       return 0;
+}
+
+/* Used to turn latch the proper register for access. */
+static void bcm_umi_nand_hwcontrol(struct mtd_info *mtd, int cmd,
+                                  unsigned int ctrl)
+{
+       /* send command to hardware */
+       struct nand_chip *chip = mtd->priv;
+       if (ctrl & NAND_CTRL_CHANGE) {
+               if (ctrl & NAND_CLE) {
+                       chip->IO_ADDR_W = bcm_umi_io_base + REG_NAND_CMD_OFFSET;
+                       goto CMD;
+               }
+               if (ctrl & NAND_ALE) {
+                       chip->IO_ADDR_W =
+                           bcm_umi_io_base + REG_NAND_ADDR_OFFSET;
+                       goto CMD;
+               }
+               chip->IO_ADDR_W = bcm_umi_io_base + REG_NAND_DATA8_OFFSET;
+       }
+
+CMD:
+       /* Send command to chip directly */
+       if (cmd != NAND_CMD_NONE)
+               writeb(cmd, chip->IO_ADDR_W);
+}
+
+static void bcm_umi_nand_write_buf(struct mtd_info *mtd, const u_char * buf,
+                                  int len)
+{
+       if (USE_DIRECT_IO(len)) {
+               /* Do it the old way if the buffer is small or too large.
+                * Probably quicker than starting and checking dma. */
+               int i;
+               struct nand_chip *this = mtd->priv;
+
+               for (i = 0; i < len; i++)
+                       writeb(buf[i], this->IO_ADDR_W);
+       }
+#if USE_DMA
+       else
+               nand_dma_write(buf, len);
+#endif
+}
+
+static void bcm_umi_nand_read_buf(struct mtd_info *mtd, u_char * buf, int len)
+{
+       if (USE_DIRECT_IO(len)) {
+               int i;
+               struct nand_chip *this = mtd->priv;
+
+               for (i = 0; i < len; i++)
+                       buf[i] = readb(this->IO_ADDR_R);
+       }
+#if USE_DMA
+       else
+               nand_dma_read(buf, len);
+#endif
+}
+
+static uint8_t readbackbuf[NAND_MAX_PAGESIZE];
+static int bcm_umi_nand_verify_buf(struct mtd_info *mtd, const u_char * buf,
+                                  int len)
+{
+       /*
+        * Try to readback page with ECC correction. This is necessary
+        * for MLC parts which may have permanently stuck bits.
+        */
+       struct nand_chip *chip = mtd->priv;
+       int ret = chip->ecc.read_page(mtd, chip, readbackbuf, 0);
+       if (ret < 0)
+               return -EFAULT;
+       else {
+               if (memcmp(readbackbuf, buf, len) == 0)
+                       return 0;
+
+               return -EFAULT;
+       }
+       return 0;
+}
+
+static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
+{
+       struct nand_chip *this;
+       struct resource *r;
+       int err = 0;
+
+       printk(gBanner);
+
+       /* Allocate memory for MTD device structure and private data */
+       board_mtd =
+           kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip),
+                   GFP_KERNEL);
+       if (!board_mtd) {
+               printk(KERN_WARNING
+                      "Unable to allocate NAND MTD device structure.\n");
+               return -ENOMEM;
+       }
+
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+       if (!r)
+               return -ENXIO;
+
+       /* map physical adress */
+       bcm_umi_io_base = ioremap(r->start, r->end - r->start + 1);
+
+       if (!bcm_umi_io_base) {
+               printk(KERN_ERR "ioremap to access BCM UMI NAND chip failed\n");
+               kfree(board_mtd);
+               return -EIO;
+       }
+
+       /* Get pointer to private data */
+       this = (struct nand_chip *)(&board_mtd[1]);
+
+       /* Initialize structures */
+       memset((char *)board_mtd, 0, sizeof(struct mtd_info));
+       memset((char *)this, 0, sizeof(struct nand_chip));
+
+       /* Link the private data with the MTD structure */
+       board_mtd->priv = this;
+
+       /* Initialize the NAND hardware.  */
+       if (bcm_umi_nand_inithw() < 0) {
+               printk(KERN_ERR "BCM UMI NAND chip could not be initialized\n");
+               iounmap(bcm_umi_io_base);
+               kfree(board_mtd);
+               return -EIO;
+       }
+
+       /* Set address of NAND IO lines */
+       this->IO_ADDR_W = bcm_umi_io_base + REG_NAND_DATA8_OFFSET;
+       this->IO_ADDR_R = bcm_umi_io_base + REG_NAND_DATA8_OFFSET;
+
+       /* Set command delay time, see datasheet for correct value */
+       this->chip_delay = 0;
+       /* Assign the device ready function, if available */
+       this->dev_ready = nand_dev_ready;
+       this->options = 0;
+
+       this->write_buf = bcm_umi_nand_write_buf;
+       this->read_buf = bcm_umi_nand_read_buf;
+       this->verify_buf = bcm_umi_nand_verify_buf;
+
+       this->cmd_ctrl = bcm_umi_nand_hwcontrol;
+       this->ecc.mode = NAND_ECC_HW;
+       this->ecc.size = 512;
+       this->ecc.bytes = NAND_ECC_NUM_BYTES;
+#if NAND_ECC_BCH
+       this->ecc.read_page = bcm_umi_bch_read_page_hwecc;
+       this->ecc.write_page = bcm_umi_bch_write_page_hwecc;
+#else
+       this->ecc.correct = nand_correct_data512;
+       this->ecc.calculate = bcm_umi_hamming_get_hw_ecc;
+       this->ecc.hwctl = bcm_umi_hamming_enable_hwecc;
+#endif
+
+#if USE_DMA
+       err = nand_dma_init();
+       if (err != 0)
+               return err;
+#endif
+
+       /* Figure out the size of the device that we have.
+        * We need to do this to figure out which ECC
+        * layout we'll be using.
+        */
+
+       err = nand_scan_ident(board_mtd, 1);
+       if (err) {
+               printk(KERN_ERR "nand_scan failed: %d\n", err);
+               iounmap(bcm_umi_io_base);
+               kfree(board_mtd);
+               return err;
+       }
+
+       /* Now that we know the nand size, we can setup the ECC layout */
+
+       switch (board_mtd->writesize) { /* writesize is the pagesize */
+       case 4096:
+               this->ecc.layout = &nand_hw_eccoob_4096;
+               break;
+       case 2048:
+               this->ecc.layout = &nand_hw_eccoob_2048;
+               break;
+       case 512:
+               this->ecc.layout = &nand_hw_eccoob_512;
+               break;
+       default:
+               {
+                       printk(KERN_ERR "NAND - Unrecognized pagesize: %d\n",
+                                        board_mtd->writesize);
+                       return -EINVAL;
+               }
+       }
+
+#if NAND_ECC_BCH
+       if (board_mtd->writesize > 512) {
+               if (this->options & NAND_USE_FLASH_BBT)
+                       largepage_bbt.options = NAND_BBT_SCAN2NDPAGE;
+               this->badblock_pattern = &largepage_bbt;
+       }
+#endif
+
+       /* Now finish off the scan, now that ecc.layout has been initialized. */
+
+       err = nand_scan_tail(board_mtd);
+       if (err) {
+               printk(KERN_ERR "nand_scan failed: %d\n", err);
+               iounmap(bcm_umi_io_base);
+               kfree(board_mtd);
+               return err;
+       }
+
+       /* Register the partitions */
+       {
+               int nr_partitions;
+               struct mtd_partition *partition_info;
+
+               board_mtd->name = "bcm_umi-nand";
+               nr_partitions =
+                   parse_mtd_partitions(board_mtd, part_probes,
+                                        &partition_info, 0);
+
+               if (nr_partitions <= 0) {
+                       printk(KERN_ERR "BCM UMI NAND: Too few partitions - %d\n",
+                              nr_partitions);
+                       iounmap(bcm_umi_io_base);
+                       kfree(board_mtd);
+                       return -EIO;
+               }
+               add_mtd_partitions(board_mtd, partition_info, nr_partitions);
+       }
+
+       /* Return happy */
+       return 0;
+}
+
+static int bcm_umi_nand_remove(struct platform_device *pdev)
+{
+#if USE_DMA
+       nand_dma_term();
+#endif
+
+       /* Release resources, unregister device */
+       nand_release(board_mtd);
+
+       /* unmap physical adress */
+       iounmap(bcm_umi_io_base);
+
+       /* Free the MTD device structure */
+       kfree(board_mtd);
+
+       return 0;
+}
+
+#ifdef CONFIG_PM
+static int bcm_umi_nand_suspend(struct platform_device *pdev,
+                               pm_message_t state)
+{
+       printk(KERN_ERR "MTD NAND suspend is being called\n");
+       return 0;
+}
+
+static int bcm_umi_nand_resume(struct platform_device *pdev)
+{
+       printk(KERN_ERR "MTD NAND resume is being called\n");
+       return 0;
+}
+#else
+#define bcm_umi_nand_suspend   NULL
+#define bcm_umi_nand_resume    NULL
+#endif
+
+static struct platform_driver nand_driver = {
+       .driver = {
+                  .name = "bcm-nand",
+                  .owner = THIS_MODULE,
+                  },
+       .probe = bcm_umi_nand_probe,
+       .remove = bcm_umi_nand_remove,
+       .suspend = bcm_umi_nand_suspend,
+       .resume = bcm_umi_nand_resume,
+};
+
+static int __init nand_init(void)
+{
+       return platform_driver_register(&nand_driver);
+}
+
+static void __exit nand_exit(void)
+{
+       platform_driver_unregister(&nand_driver);
+}
+
+module_init(nand_init);
+module_exit(nand_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Broadcom");
+MODULE_DESCRIPTION("BCM UMI MTD NAND driver");
index f13f5b9afaf744f0ef6e234bf45115c01a83b219..fe3eba87de40687225658d2aea50f1760b15de1f 100644 (file)
@@ -591,6 +591,8 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
 
        /* options such as NAND_USE_FLASH_BBT or 16-bit widths */
        info->chip.options      = pdata->options;
+       info->chip.bbt_td       = pdata->bbt_td;
+       info->chip.bbt_md       = pdata->bbt_md;
 
        info->ioaddr            = (uint32_t __force) vaddr;
 
@@ -599,7 +601,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
        info->mask_chipsel      = pdata->mask_chipsel;
 
        /* use nandboot-capable ALE/CLE masks by default */
-       info->mask_ale          = pdata->mask_cle ? : MASK_ALE;
+       info->mask_ale          = pdata->mask_ale ? : MASK_ALE;
        info->mask_cle          = pdata->mask_cle ? : MASK_CLE;
 
        /* Set address of hardware control function */
diff --git a/drivers/mtd/nand/excite_nandflash.c b/drivers/mtd/nand/excite_nandflash.c
deleted file mode 100644 (file)
index 72446fb..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
-*  Copyright (C) 2005 - 2007 by Basler Vision Technologies AG
-*  Author: Thomas Koeller <thomas.koeller.qbaslerweb.com>
-*  Original code by Thies Moeller <thies.moeller@baslerweb.com>
-*
-*  This program is free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  This program is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  You should have received a copy of the GNU General Public License
-*  along with this program; if not, write to the Free Software
-*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/ioport.h>
-#include <linux/platform_device.h>
-#include <linux/delay.h>
-#include <linux/err.h>
-
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/nand.h>
-#include <linux/mtd/nand_ecc.h>
-#include <linux/mtd/partitions.h>
-
-#include <asm/io.h>
-#include <asm/rm9k-ocd.h>
-
-#include <excite_nandflash.h>
-
-#define EXCITE_NANDFLASH_VERSION "0.1"
-
-/* I/O register offsets */
-#define EXCITE_NANDFLASH_DATA_BYTE   0x00
-#define EXCITE_NANDFLASH_STATUS_BYTE 0x0c
-#define EXCITE_NANDFLASH_ADDR_BYTE   0x10
-#define EXCITE_NANDFLASH_CMD_BYTE    0x14
-
-/* prefix for debug output */
-static const char module_id[] = "excite_nandflash";
-
-/*
- * partition definition
- */
-static const struct mtd_partition partition_info[] = {
-       {
-               .name = "eXcite RootFS",
-               .offset = 0,
-               .size = MTDPART_SIZ_FULL
-       }
-};
-
-static inline const struct resource *
-excite_nand_get_resource(struct platform_device *d, unsigned long flags,
-                        const char *basename)
-{
-       char buf[80];
-
-       if (snprintf(buf, sizeof buf, "%s_%u", basename, d->id) >= sizeof buf)
-               return NULL;
-       return platform_get_resource_byname(d, flags, buf);
-}
-
-static inline void __iomem *
-excite_nand_map_regs(struct platform_device *d, const char *basename)
-{
-       void *result = NULL;
-       const struct resource *const r =
-           excite_nand_get_resource(d, IORESOURCE_MEM, basename);
-
-       if (r)
-               result = ioremap_nocache(r->start, r->end + 1 - r->start);
-       return result;
-}
-
-/* controller and mtd information */
-struct excite_nand_drvdata {
-       struct mtd_info board_mtd;
-       struct nand_chip board_chip;
-       void __iomem *regs;
-       void __iomem *tgt;
-};
-
-/* Control function */
-static void excite_nand_control(struct mtd_info *mtd, int cmd,
-                                      unsigned int ctrl)
-{
-       struct excite_nand_drvdata * const d =
-           container_of(mtd, struct excite_nand_drvdata, board_mtd);
-
-       switch (ctrl) {
-       case NAND_CTRL_CHANGE | NAND_CTRL_CLE:
-               d->tgt = d->regs + EXCITE_NANDFLASH_CMD_BYTE;
-               break;
-       case NAND_CTRL_CHANGE | NAND_CTRL_ALE:
-               d->tgt = d->regs + EXCITE_NANDFLASH_ADDR_BYTE;
-               break;
-       case NAND_CTRL_CHANGE | NAND_NCE:
-               d->tgt = d->regs + EXCITE_NANDFLASH_DATA_BYTE;
-               break;
-       }
-
-       if (cmd != NAND_CMD_NONE)
-               __raw_writeb(cmd, d->tgt);
-}
-
-/* Return 0 if flash is busy, 1 if ready */
-static int excite_nand_devready(struct mtd_info *mtd)
-{
-       struct excite_nand_drvdata * const drvdata =
-           container_of(mtd, struct excite_nand_drvdata, board_mtd);
-
-       return __raw_readb(drvdata->regs + EXCITE_NANDFLASH_STATUS_BYTE);
-}
-
-/*
- * Called by device layer to remove the driver.
- * The binding to the mtd and all allocated
- * resources are released.
- */
-static int __exit excite_nand_remove(struct platform_device *dev)
-{
-       struct excite_nand_drvdata * const this = platform_get_drvdata(dev);
-
-       platform_set_drvdata(dev, NULL);
-
-       if (unlikely(!this)) {
-               printk(KERN_ERR "%s: called %s without private data!!",
-                      module_id, __func__);
-               return -EINVAL;
-       }
-
-       /* first thing we need to do is release our mtd
-        * then go through freeing the resource used
-        */
-       nand_release(&this->board_mtd);
-
-       /* free the common resources */
-       iounmap(this->regs);
-       kfree(this);
-
-       DEBUG(MTD_DEBUG_LEVEL1, "%s: removed\n", module_id);
-       return 0;
-}
-
-/*
- * Called by device layer when it finds a device matching
- * one our driver can handle. This code checks to see if
- * it can allocate all necessary resources then calls the
- * nand layer to look for devices.
-*/
-static int __init excite_nand_probe(struct platform_device *pdev)
-{
-       struct excite_nand_drvdata *drvdata;    /* private driver data */
-       struct nand_chip *board_chip;   /* private flash chip data */
-       struct mtd_info *board_mtd;     /* mtd info for this board */
-       int scan_res;
-
-       drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
-       if (unlikely(!drvdata)) {
-               printk(KERN_ERR "%s: no memory for drvdata\n",
-                      module_id);
-               return -ENOMEM;
-       }
-
-       /* bind private data into driver */
-       platform_set_drvdata(pdev, drvdata);
-
-       /* allocate and map the resource */
-       drvdata->regs =
-               excite_nand_map_regs(pdev, EXCITE_NANDFLASH_RESOURCE_REGS);
-
-       if (unlikely(!drvdata->regs)) {
-               printk(KERN_ERR "%s: cannot reserve register region\n",
-                      module_id);
-               kfree(drvdata);
-               return -ENXIO;
-       }
-       
-       drvdata->tgt = drvdata->regs + EXCITE_NANDFLASH_DATA_BYTE;
-
-       /* initialise our chip */
-       board_chip = &drvdata->board_chip;
-       board_chip->IO_ADDR_R = board_chip->IO_ADDR_W =
-               drvdata->regs + EXCITE_NANDFLASH_DATA_BYTE;
-       board_chip->cmd_ctrl = excite_nand_control;
-       board_chip->dev_ready = excite_nand_devready;
-       board_chip->chip_delay = 25;
-       board_chip->ecc.mode = NAND_ECC_SOFT;
-
-       /* link chip to mtd */
-       board_mtd = &drvdata->board_mtd;
-       board_mtd->priv = board_chip;
-
-       DEBUG(MTD_DEBUG_LEVEL2, "%s: device scan\n", module_id);
-       scan_res = nand_scan(&drvdata->board_mtd, 1);
-
-       if (likely(!scan_res)) {
-               DEBUG(MTD_DEBUG_LEVEL2, "%s: register partitions\n", module_id);
-               add_mtd_partitions(&drvdata->board_mtd, partition_info,
-                                  ARRAY_SIZE(partition_info));
-       } else {
-               iounmap(drvdata->regs);
-               kfree(drvdata);
-               printk(KERN_ERR "%s: device scan failed\n", module_id);
-               return -EIO;
-       }
-       return 0;
-}
-
-static struct platform_driver excite_nand_driver = {
-       .driver = {
-               .name = "excite_nand",
-               .owner          = THIS_MODULE,
-       },
-       .probe = excite_nand_probe,
-       .remove = __devexit_p(excite_nand_remove)
-};
-
-static int __init excite_nand_init(void)
-{
-       pr_info("Basler eXcite nand flash driver Version "
-               EXCITE_NANDFLASH_VERSION "\n");
-       return platform_driver_register(&excite_nand_driver);
-}
-
-static void __exit excite_nand_exit(void)
-{
-       platform_driver_unregister(&excite_nand_driver);
-}
-
-module_init(excite_nand_init);
-module_exit(excite_nand_exit);
-
-MODULE_AUTHOR("Thomas Koeller <thomas.koeller@baslerweb.com>");
-MODULE_DESCRIPTION("Basler eXcite NAND-Flash driver");
-MODULE_LICENSE("GPL");
-MODULE_VERSION(EXCITE_NANDFLASH_VERSION)
index ddd37d2554ede02c08044642d4f30c2d3307ee57..ae30fb6eed970d245b7c98dd8bab72c6c38630bf 100644 (file)
@@ -237,12 +237,15 @@ static int fsl_elbc_run_command(struct mtd_info *mtd)
 
        ctrl->use_mdr = 0;
 
-       dev_vdbg(ctrl->dev,
-                "fsl_elbc_run_command: stat=%08x mdr=%08x fmr=%08x\n",
-                ctrl->status, ctrl->mdr, in_be32(&lbc->fmr));
+       if (ctrl->status != LTESR_CC) {
+               dev_info(ctrl->dev,
+                        "command failed: fir %x fcr %x status %x mdr %x\n",
+                        in_be32(&lbc->fir), in_be32(&lbc->fcr),
+                        ctrl->status, ctrl->mdr);
+               return -EIO;
+       }
 
-       /* returns 0 on success otherwise non-zero) */
-       return ctrl->status == LTESR_CC ? 0 : -EIO;
+       return 0;
 }
 
 static void fsl_elbc_do_read(struct nand_chip *chip, int oob)
@@ -253,17 +256,17 @@ static void fsl_elbc_do_read(struct nand_chip *chip, int oob)
 
        if (priv->page_size) {
                out_be32(&lbc->fir,
-                        (FIR_OP_CW0 << FIR_OP0_SHIFT) |
+                        (FIR_OP_CM0 << FIR_OP0_SHIFT) |
                         (FIR_OP_CA  << FIR_OP1_SHIFT) |
                         (FIR_OP_PA  << FIR_OP2_SHIFT) |
-                        (FIR_OP_CW1 << FIR_OP3_SHIFT) |
+                        (FIR_OP_CM1 << FIR_OP3_SHIFT) |
                         (FIR_OP_RBW << FIR_OP4_SHIFT));
 
                out_be32(&lbc->fcr, (NAND_CMD_READ0 << FCR_CMD0_SHIFT) |
                                    (NAND_CMD_READSTART << FCR_CMD1_SHIFT));
        } else {
                out_be32(&lbc->fir,
-                        (FIR_OP_CW0 << FIR_OP0_SHIFT) |
+                        (FIR_OP_CM0 << FIR_OP0_SHIFT) |
                         (FIR_OP_CA  << FIR_OP1_SHIFT) |
                         (FIR_OP_PA  << FIR_OP2_SHIFT) |
                         (FIR_OP_RBW << FIR_OP3_SHIFT));
@@ -332,7 +335,7 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,
        case NAND_CMD_READID:
                dev_vdbg(ctrl->dev, "fsl_elbc_cmdfunc: NAND_CMD_READID.\n");
 
-               out_be32(&lbc->fir, (FIR_OP_CW0 << FIR_OP0_SHIFT) |
+               out_be32(&lbc->fir, (FIR_OP_CM0 << FIR_OP0_SHIFT) |
                                    (FIR_OP_UA  << FIR_OP1_SHIFT) |
                                    (FIR_OP_RBW << FIR_OP2_SHIFT));
                out_be32(&lbc->fcr, NAND_CMD_READID << FCR_CMD0_SHIFT);
@@ -359,16 +362,20 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,
                dev_vdbg(ctrl->dev, "fsl_elbc_cmdfunc: NAND_CMD_ERASE2.\n");
 
                out_be32(&lbc->fir,
-                        (FIR_OP_CW0 << FIR_OP0_SHIFT) |
+                        (FIR_OP_CM0 << FIR_OP0_SHIFT) |
                         (FIR_OP_PA  << FIR_OP1_SHIFT) |
-                        (FIR_OP_CM1 << FIR_OP2_SHIFT));
+                        (FIR_OP_CM2 << FIR_OP2_SHIFT) |
+                        (FIR_OP_CW1 << FIR_OP3_SHIFT) |
+                        (FIR_OP_RS  << FIR_OP4_SHIFT));
 
                out_be32(&lbc->fcr,
                         (NAND_CMD_ERASE1 << FCR_CMD0_SHIFT) |
-                        (NAND_CMD_ERASE2 << FCR_CMD1_SHIFT));
+                        (NAND_CMD_STATUS << FCR_CMD1_SHIFT) |
+                        (NAND_CMD_ERASE2 << FCR_CMD2_SHIFT));
 
                out_be32(&lbc->fbcr, 0);
                ctrl->read_bytes = 0;
+               ctrl->use_mdr = 1;
 
                fsl_elbc_run_command(mtd);
                return;
@@ -383,40 +390,41 @@ static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,
 
                ctrl->column = column;
                ctrl->oob = 0;
+               ctrl->use_mdr = 1;
 
-               if (priv->page_size) {
-                       fcr = (NAND_CMD_SEQIN << FCR_CMD0_SHIFT) |
-                             (NAND_CMD_PAGEPROG << FCR_CMD1_SHIFT);
+               fcr = (NAND_CMD_STATUS   << FCR_CMD1_SHIFT) |
+                     (NAND_CMD_SEQIN    << FCR_CMD2_SHIFT) |
+                     (NAND_CMD_PAGEPROG << FCR_CMD3_SHIFT);
 
+               if (priv->page_size) {
                        out_be32(&lbc->fir,
-                                (FIR_OP_CW0 << FIR_OP0_SHIFT) |
+                                (FIR_OP_CM2 << FIR_OP0_SHIFT) |
                                 (FIR_OP_CA  << FIR_OP1_SHIFT) |
                                 (FIR_OP_PA  << FIR_OP2_SHIFT) |
                                 (FIR_OP_WB  << FIR_OP3_SHIFT) |
-                                (FIR_OP_CW1 << FIR_OP4_SHIFT));
+                                (FIR_OP_CM3 << FIR_OP4_SHIFT) |
+                                (FIR_OP_CW1 << FIR_OP5_SHIFT) |
+                                (FIR_OP_RS  << FIR_OP6_SHIFT));
                } else {
-                       fcr = (NAND_CMD_PAGEPROG << FCR_CMD1_SHIFT) |
-                             (NAND_CMD_SEQIN << FCR_CMD2_SHIFT);
-
                        out_be32(&lbc->fir,
-                                (FIR_OP_CW0 << FIR_OP0_SHIFT) |
+                                (FIR_OP_CM0 << FIR_OP0_SHIFT) |
                                 (FIR_OP_CM2 << FIR_OP1_SHIFT) |
                                 (FIR_OP_CA  << FIR_OP2_SHIFT) |
                                 (FIR_OP_PA  << FIR_OP3_SHIFT) |
                                 (FIR_OP_WB  << FIR_OP4_SHIFT) |
-                                (FIR_OP_CW1 << FIR_OP5_SHIFT));
+                                (FIR_OP_CM3 << FIR_OP5_SHIFT) |
+                                (FIR_OP_CW1 << FIR_OP6_SHIFT) |
+                                (FIR_OP_RS  << FIR_OP7_SHIFT));
 
                        if (column >= mtd->writesize) {
                                /* OOB area --> READOOB */
                                column -= mtd->writesize;
                                fcr |= NAND_CMD_READOOB << FCR_CMD0_SHIFT;
                                ctrl->oob = 1;
-                       } else if (column < 256) {
+                       } else {
+                               WARN_ON(column != 0);
                                /* First 256 bytes --> READ0 */
                                fcr |= NAND_CMD_READ0 << FCR_CMD0_SHIFT;
-                       } else {
-                               /* Second 256 bytes --> READ1 */
-                               fcr |= NAND_CMD_READ1 << FCR_CMD0_SHIFT;
                        }
                }
 
@@ -628,22 +636,6 @@ static int fsl_elbc_wait(struct mtd_info *mtd, struct nand_chip *chip)
 {
        struct fsl_elbc_mtd *priv = chip->priv;
        struct fsl_elbc_ctrl *ctrl = priv->ctrl;
-       struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
-
-       if (ctrl->status != LTESR_CC)
-               return NAND_STATUS_FAIL;
-
-       /* Use READ_STATUS command, but wait for the device to be ready */
-       ctrl->use_mdr = 0;
-       out_be32(&lbc->fir,
-                (FIR_OP_CW0 << FIR_OP0_SHIFT) |
-                (FIR_OP_RBW << FIR_OP1_SHIFT));
-       out_be32(&lbc->fcr, NAND_CMD_STATUS << FCR_CMD0_SHIFT);
-       out_be32(&lbc->fbcr, 1);
-       set_addr(mtd, 0, 0, 0);
-       ctrl->read_bytes = 1;
-
-       fsl_elbc_run_command(mtd);
 
        if (ctrl->status != LTESR_CC)
                return NAND_STATUS_FAIL;
@@ -651,8 +643,7 @@ static int fsl_elbc_wait(struct mtd_info *mtd, struct nand_chip *chip)
        /* The chip always seems to report that it is
         * write-protected, even when it is not.
         */
-       setbits8(ctrl->addr, NAND_STATUS_WP);
-       return fsl_elbc_read_byte(mtd);
+       return (ctrl->mdr & 0xff) | NAND_STATUS_WP;
 }
 
 static int fsl_elbc_chip_init_tail(struct mtd_info *mtd)
@@ -946,6 +937,13 @@ static int __devinit fsl_elbc_ctrl_init(struct fsl_elbc_ctrl *ctrl)
 {
        struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
 
+       /*
+        * NAND transactions can tie up the bus for a long time, so set the
+        * bus timeout to max by clearing LBCR[BMT] (highest base counter
+        * value) and setting LBCR[BMTPS] to the highest prescaler value.
+        */
+       clrsetbits_be32(&lbc->lbcr, LBCR_BMT, 15);
+
        /* clear event registers */
        setbits32(&lbc->ltesr, LTESR_NAND_MASK);
        out_be32(&lbc->lteatr, 0);
index d120cd8d72674919fc453870978765ebf95d9a00..071a60cb42041b4d660189a1b01223a17b081b00 100644 (file)
@@ -112,7 +112,7 @@ static void fun_select_chip(struct mtd_info *mtd, int mchip_nr)
 
        if (mchip_nr == -1) {
                chip->cmd_ctrl(mtd, NAND_CMD_NONE, 0 | NAND_CTRL_CHANGE);
-       } else if (mchip_nr >= 0) {
+       } else if (mchip_nr >= 0 && mchip_nr < NAND_MAX_CHIPS) {
                fun->mchip_number = mchip_nr;
                chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr];
                chip->IO_ADDR_W = chip->IO_ADDR_R;
index 65b26d5a5c0d391cf72559f6d6f38eadb7b089a1..45dec5770da0b93ea560bc812b482d7e34951a56 100644 (file)
 
 #include <asm/mach/flash.h>
 #include <mach/mxc_nand.h>
+#include <mach/hardware.h>
 
 #define DRIVER_NAME "mxc_nand"
 
+#define nfc_is_v21()           (cpu_is_mx25() || cpu_is_mx35())
+#define nfc_is_v1()            (cpu_is_mx31() || cpu_is_mx27())
+
 /* Addresses for NFC registers */
 #define NFC_BUF_SIZE           0xE00
 #define NFC_BUF_ADDR           0xE04
 #define NFC_RSLTMAIN_AREA      0xE0E
 #define NFC_RSLTSPARE_AREA     0xE10
 #define NFC_WRPROT             0xE12
-#define NFC_UNLOCKSTART_BLKADDR        0xE14
-#define NFC_UNLOCKEND_BLKADDR  0xE16
+#define NFC_V1_UNLOCKSTART_BLKADDR     0xe14
+#define NFC_V1_UNLOCKEND_BLKADDR       0xe16
+#define NFC_V21_UNLOCKSTART_BLKADDR    0xe20
+#define NFC_V21_UNLOCKEND_BLKADDR      0xe22
 #define NFC_NF_WRPRST          0xE18
 #define NFC_CONFIG1            0xE1A
 #define NFC_CONFIG2            0xE1C
 
-/* Addresses for NFC RAM BUFFER Main area 0 */
-#define MAIN_AREA0             0x000
-#define MAIN_AREA1             0x200
-#define MAIN_AREA2             0x400
-#define MAIN_AREA3             0x600
-
-/* Addresses for NFC SPARE BUFFER Spare area 0 */
-#define SPARE_AREA0            0x800
-#define SPARE_AREA1            0x810
-#define SPARE_AREA2            0x820
-#define SPARE_AREA3            0x830
-
 /* Set INT to 0, FCMD to 1, rest to 0 in NFC_CONFIG2 Register
  * for Command operation */
 #define NFC_CMD            0x1
@@ -106,48 +100,66 @@ struct mxc_nand_host {
        struct mtd_partition    *parts;
        struct device           *dev;
 
+       void                    *spare0;
+       void                    *main_area0;
+       void                    *main_area1;
+
+       void __iomem            *base;
        void __iomem            *regs;
-       int                     spare_only;
        int                     status_request;
-       int                     pagesize_2k;
-       uint16_t                col_addr;
        struct clk              *clk;
        int                     clk_act;
        int                     irq;
 
        wait_queue_head_t       irq_waitq;
-};
-
-/* Define delays in microsec for NAND device operations */
-#define TROP_US_DELAY   2000
-/* Macros to get byte and bit positions of ECC */
-#define COLPOS(x)  ((x) >> 3)
-#define BITPOS(x) ((x) & 0xf)
 
-/* Define single bit Error positions in Main & Spare area */
-#define MAIN_SINGLEBIT_ERROR 0x4
-#define SPARE_SINGLEBIT_ERROR 0x1
-
-/* OOB placement block for use with hardware ecc generation */
-static struct nand_ecclayout nand_hw_eccoob_8 = {
-       .eccbytes = 5,
-       .eccpos = {6, 7, 8, 9, 10},
-       .oobfree = {{0, 5}, {11, 5}, }
+       uint8_t                 *data_buf;
+       unsigned int            buf_start;
+       int                     spare_len;
 };
 
-static struct nand_ecclayout nand_hw_eccoob_16 = {
+/* OOB placement block for use with hardware ecc generation */
+static struct nand_ecclayout nandv1_hw_eccoob_smallpage = {
        .eccbytes = 5,
        .eccpos = {6, 7, 8, 9, 10},
-       .oobfree = {{0, 5}, {11, 5}, }
+       .oobfree = {{0, 5}, {12, 4}, }
 };
 
-static struct nand_ecclayout nand_hw_eccoob_64 = {
+static struct nand_ecclayout nandv1_hw_eccoob_largepage = {
        .eccbytes = 20,
        .eccpos = {6, 7, 8, 9, 10, 22, 23, 24, 25, 26,
                   38, 39, 40, 41, 42, 54, 55, 56, 57, 58},
        .oobfree = {{2, 4}, {11, 10}, {27, 10}, {43, 10}, {59, 5}, }
 };
 
+/* OOB description for 512 byte pages with 16 byte OOB */
+static struct nand_ecclayout nandv2_hw_eccoob_smallpage = {
+       .eccbytes = 1 * 9,
+       .eccpos = {
+                7,  8,  9, 10, 11, 12, 13, 14, 15
+       },
+       .oobfree = {
+               {.offset = 0, .length = 5}
+       }
+};
+
+/* OOB description for 2048 byte pages with 64 byte OOB */
+static struct nand_ecclayout nandv2_hw_eccoob_largepage = {
+       .eccbytes = 4 * 9,
+       .eccpos = {
+                7,  8,  9, 10, 11, 12, 13, 14, 15,
+               23, 24, 25, 26, 27, 28, 29, 30, 31,
+               39, 40, 41, 42, 43, 44, 45, 46, 47,
+               55, 56, 57, 58, 59, 60, 61, 62, 63
+       },
+       .oobfree = {
+               {.offset = 2, .length = 4},
+               {.offset = 16, .length = 7},
+               {.offset = 32, .length = 7},
+               {.offset = 48, .length = 7}
+       }
+};
+
 #ifdef CONFIG_MTD_PARTITIONS
 static const char *part_probes[] = { "RedBoot", "cmdlinepart", NULL };
 #endif
@@ -170,10 +182,10 @@ static irqreturn_t mxc_nfc_irq(int irq, void *dev_id)
 /* This function polls the NANDFC to wait for the basic operation to
  * complete by checking the INT bit of config2 register.
  */
-static void wait_op_done(struct mxc_nand_host *host, int max_retries,
-                               uint16_t param, int useirq)
+static void wait_op_done(struct mxc_nand_host *host, int useirq)
 {
        uint32_t tmp;
+       int max_retries = 2000;
 
        if (useirq) {
                if ((readw(host->regs + NFC_CONFIG2) & NFC_INT) == 0) {
@@ -200,8 +212,8 @@ static void wait_op_done(struct mxc_nand_host *host, int max_retries,
                        udelay(1);
                }
                if (max_retries < 0)
-                       DEBUG(MTD_DEBUG_LEVEL0, "%s(%d): INT not set\n",
-                             __func__, param);
+                       DEBUG(MTD_DEBUG_LEVEL0, "%s: INT not set\n",
+                             __func__);
        }
 }
 
@@ -215,7 +227,7 @@ static void send_cmd(struct mxc_nand_host *host, uint16_t cmd, int useirq)
        writew(NFC_CMD, host->regs + NFC_CONFIG2);
 
        /* Wait for operation to complete */
-       wait_op_done(host, TROP_US_DELAY, cmd, useirq);
+       wait_op_done(host, useirq);
 }
 
 /* This function sends an address (or partial address) to the
@@ -229,82 +241,47 @@ static void send_addr(struct mxc_nand_host *host, uint16_t addr, int islast)
        writew(NFC_ADDR, host->regs + NFC_CONFIG2);
 
        /* Wait for operation to complete */
-       wait_op_done(host, TROP_US_DELAY, addr, islast);
+       wait_op_done(host, islast);
 }
 
-/* This function requests the NANDFC to initate the transfer
- * of data currently in the NANDFC RAM buffer to the NAND device. */
-static void send_prog_page(struct mxc_nand_host *host, uint8_t buf_id,
-                       int spare_only)
+static void send_page(struct mtd_info *mtd, unsigned int ops)
 {
-       DEBUG(MTD_DEBUG_LEVEL3, "send_prog_page (%d)\n", spare_only);
-
-       /* NANDFC buffer 0 is used for page read/write */
-       writew(buf_id, host->regs + NFC_BUF_ADDR);
-
-       /* Configure spare or page+spare access */
-       if (!host->pagesize_2k) {
-               uint16_t config1 = readw(host->regs + NFC_CONFIG1);
-               if (spare_only)
-                       config1 |= NFC_SP_EN;
-               else
-                       config1 &= ~(NFC_SP_EN);
-               writew(config1, host->regs + NFC_CONFIG1);
-       }
+       struct nand_chip *nand_chip = mtd->priv;
+       struct mxc_nand_host *host = nand_chip->priv;
+       int bufs, i;
 
-       writew(NFC_INPUT, host->regs + NFC_CONFIG2);
+       if (nfc_is_v1() && mtd->writesize > 512)
+               bufs = 4;
+       else
+               bufs = 1;
 
-       /* Wait for operation to complete */
-       wait_op_done(host, TROP_US_DELAY, spare_only, true);
-}
+       for (i = 0; i < bufs; i++) {
 
-/* Requests NANDFC to initated the transfer of data from the
- * NAND device into in the NANDFC ram buffer. */
-static void send_read_page(struct mxc_nand_host *host, uint8_t buf_id,
-               int spare_only)
-{
-       DEBUG(MTD_DEBUG_LEVEL3, "send_read_page (%d)\n", spare_only);
+               /* NANDFC buffer 0 is used for page read/write */
+               writew(i, host->regs + NFC_BUF_ADDR);
 
-       /* NANDFC buffer 0 is used for page read/write */
-       writew(buf_id, host->regs + NFC_BUF_ADDR);
+               writew(ops, host->regs + NFC_CONFIG2);
 
-       /* Configure spare or page+spare access */
-       if (!host->pagesize_2k) {
-               uint32_t config1 = readw(host->regs + NFC_CONFIG1);
-               if (spare_only)
-                       config1 |= NFC_SP_EN;
-               else
-                       config1 &= ~NFC_SP_EN;
-               writew(config1, host->regs + NFC_CONFIG1);
+               /* Wait for operation to complete */
+               wait_op_done(host, true);
        }
-
-       writew(NFC_OUTPUT, host->regs + NFC_CONFIG2);
-
-       /* Wait for operation to complete */
-       wait_op_done(host, TROP_US_DELAY, spare_only, true);
 }
 
 /* Request the NANDFC to perform a read of the NAND device ID. */
 static void send_read_id(struct mxc_nand_host *host)
 {
        struct nand_chip *this = &host->nand;
-       uint16_t tmp;
 
        /* NANDFC buffer 0 is used for device ID output */
        writew(0x0, host->regs + NFC_BUF_ADDR);
 
-       /* Read ID into main buffer */
-       tmp = readw(host->regs + NFC_CONFIG1);
-       tmp &= ~NFC_SP_EN;
-       writew(tmp, host->regs + NFC_CONFIG1);
-
        writew(NFC_ID, host->regs + NFC_CONFIG2);
 
        /* Wait for operation to complete */
-       wait_op_done(host, TROP_US_DELAY, 0, true);
+       wait_op_done(host, true);
 
        if (this->options & NAND_BUSWIDTH_16) {
-               void __iomem *main_buf = host->regs + MAIN_AREA0;
+               void __iomem *main_buf = host->main_area0;
                /* compress the ID info */
                writeb(readb(main_buf + 2), main_buf + 1);
                writeb(readb(main_buf + 4), main_buf + 2);
@@ -312,15 +289,16 @@ static void send_read_id(struct mxc_nand_host *host)
                writeb(readb(main_buf + 8), main_buf + 4);
                writeb(readb(main_buf + 10), main_buf + 5);
        }
+       memcpy(host->data_buf, host->main_area0, 16);
 }
 
 /* This function requests the NANDFC to perform a read of the
  * NAND device status and returns the current status. */
 static uint16_t get_dev_status(struct mxc_nand_host *host)
 {
-       void __iomem *main_buf = host->regs + MAIN_AREA1;
+       void __iomem *main_buf = host->main_area1;
        uint32_t store;
-       uint16_t ret, tmp;
+       uint16_t ret;
        /* Issue status request to NAND device */
 
        /* store the main area1 first word, later do recovery */
@@ -329,15 +307,10 @@ static uint16_t get_dev_status(struct mxc_nand_host *host)
         * corruption of read/write buffer on status requests. */
        writew(1, host->regs + NFC_BUF_ADDR);
 
-       /* Read status into main buffer */
-       tmp = readw(host->regs + NFC_CONFIG1);
-       tmp &= ~NFC_SP_EN;
-       writew(tmp, host->regs + NFC_CONFIG1);
-
        writew(NFC_STATUS, host->regs + NFC_CONFIG2);
 
        /* Wait for operation to complete */
-       wait_op_done(host, TROP_US_DELAY, 0, true);
+       wait_op_done(host, true);
 
        /* Status is placed in first word of main buffer */
        /* get status, then recovery area 1 data */
@@ -397,32 +370,14 @@ static u_char mxc_nand_read_byte(struct mtd_info *mtd)
 {
        struct nand_chip *nand_chip = mtd->priv;
        struct mxc_nand_host *host = nand_chip->priv;
-       uint8_t ret = 0;
-       uint16_t col, rd_word;
-       uint16_t __iomem *main_buf = host->regs + MAIN_AREA0;
-       uint16_t __iomem *spare_buf = host->regs + SPARE_AREA0;
+       uint8_t ret;
 
        /* Check for status request */
        if (host->status_request)
                return get_dev_status(host) & 0xFF;
 
-       /* Get column for 16-bit access */
-       col = host->col_addr >> 1;
-
-       /* If we are accessing the spare region */
-       if (host->spare_only)
-               rd_word = readw(&spare_buf[col]);
-       else
-               rd_word = readw(&main_buf[col]);
-
-       /* Pick upper/lower byte of word from RAM buffer */
-       if (host->col_addr & 0x1)
-               ret = (rd_word >> 8) & 0xFF;
-       else
-               ret = rd_word & 0xFF;
-
-       /* Update saved column address */
-       host->col_addr++;
+       ret = *(uint8_t *)(host->data_buf + host->buf_start);
+       host->buf_start++;
 
        return ret;
 }
@@ -431,33 +386,10 @@ static uint16_t mxc_nand_read_word(struct mtd_info *mtd)
 {
        struct nand_chip *nand_chip = mtd->priv;
        struct mxc_nand_host *host = nand_chip->priv;
-       uint16_t col, rd_word, ret;
-       uint16_t __iomem *p;
-
-       DEBUG(MTD_DEBUG_LEVEL3,
-             "mxc_nand_read_word(col = %d)\n", host->col_addr);
-
-       col = host->col_addr;
-       /* Adjust saved column address */
-       if (col < mtd->writesize && host->spare_only)
-               col += mtd->writesize;
+       uint16_t ret;
 
-       if (col < mtd->writesize)
-               p = (host->regs + MAIN_AREA0) + (col >> 1);
-       else
-               p = (host->regs + SPARE_AREA0) + ((col - mtd->writesize) >> 1);
-
-       if (col & 1) {
-               rd_word = readw(p);
-               ret = (rd_word >> 8) & 0xff;
-               rd_word = readw(&p[1]);
-               ret |= (rd_word << 8) & 0xff00;
-
-       } else
-               ret = readw(p);
-
-       /* Update saved column address */
-       host->col_addr = col + 2;
+       ret = *(uint16_t *)(host->data_buf + host->buf_start);
+       host->buf_start += 2;
 
        return ret;
 }
@@ -470,94 +402,14 @@ static void mxc_nand_write_buf(struct mtd_info *mtd,
 {
        struct nand_chip *nand_chip = mtd->priv;
        struct mxc_nand_host *host = nand_chip->priv;
-       int n, col, i = 0;
-
-       DEBUG(MTD_DEBUG_LEVEL3,
-             "mxc_nand_write_buf(col = %d, len = %d)\n", host->col_addr,
-             len);
-
-       col = host->col_addr;
+       u16 col = host->buf_start;
+       int n = mtd->oobsize + mtd->writesize - col;
 
-       /* Adjust saved column address */
-       if (col < mtd->writesize && host->spare_only)
-               col += mtd->writesize;
+       n = min(n, len);
 
-       n = mtd->writesize + mtd->oobsize - col;
-       n = min(len, n);
-
-       DEBUG(MTD_DEBUG_LEVEL3,
-             "%s:%d: col = %d, n = %d\n", __func__, __LINE__, col, n);
-
-       while (n) {
-               void __iomem *p;
-
-               if (col < mtd->writesize)
-                       p = host->regs + MAIN_AREA0 + (col & ~3);
-               else
-                       p = host->regs + SPARE_AREA0 -
-                                               mtd->writesize + (col & ~3);
-
-               DEBUG(MTD_DEBUG_LEVEL3, "%s:%d: p = %p\n", __func__,
-                     __LINE__, p);
-
-               if (((col | (int)&buf[i]) & 3) || n < 16) {
-                       uint32_t data = 0;
-
-                       if (col & 3 || n < 4)
-                               data = readl(p);
-
-                       switch (col & 3) {
-                       case 0:
-                               if (n) {
-                                       data = (data & 0xffffff00) |
-                                           (buf[i++] << 0);
-                                       n--;
-                                       col++;
-                               }
-                       case 1:
-                               if (n) {
-                                       data = (data & 0xffff00ff) |
-                                           (buf[i++] << 8);
-                                       n--;
-                                       col++;
-                               }
-                       case 2:
-                               if (n) {
-                                       data = (data & 0xff00ffff) |
-                                           (buf[i++] << 16);
-                                       n--;
-                                       col++;
-                               }
-                       case 3:
-                               if (n) {
-                                       data = (data & 0x00ffffff) |
-                                           (buf[i++] << 24);
-                                       n--;
-                                       col++;
-                               }
-                       }
-
-                       writel(data, p);
-               } else {
-                       int m = mtd->writesize - col;
+       memcpy(host->data_buf + col, buf, n);
 
-                       if (col >= mtd->writesize)
-                               m += mtd->oobsize;
-
-                       m = min(n, m) & ~3;
-
-                       DEBUG(MTD_DEBUG_LEVEL3,
-                             "%s:%d: n = %d, m = %d, i = %d, col = %d\n",
-                             __func__,  __LINE__, n, m, i, col);
-
-                       memcpy(p, &buf[i], m);
-                       col += m;
-                       i += m;
-                       n -= m;
-               }
-       }
-       /* Update saved column address */
-       host->col_addr = col;
+       host->buf_start += n;
 }
 
 /* Read the data buffer from the NAND Flash. To read the data from NAND
@@ -568,75 +420,14 @@ static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
 {
        struct nand_chip *nand_chip = mtd->priv;
        struct mxc_nand_host *host = nand_chip->priv;
-       int n, col, i = 0;
-
-       DEBUG(MTD_DEBUG_LEVEL3,
-             "mxc_nand_read_buf(col = %d, len = %d)\n", host->col_addr, len);
-
-       col = host->col_addr;
+       u16 col = host->buf_start;
+       int n = mtd->oobsize + mtd->writesize - col;
 
-       /* Adjust saved column address */
-       if (col < mtd->writesize && host->spare_only)
-               col += mtd->writesize;
+       n = min(n, len);
 
-       n = mtd->writesize + mtd->oobsize - col;
-       n = min(len, n);
-
-       while (n) {
-               void __iomem *p;
-
-               if (col < mtd->writesize)
-                       p = host->regs + MAIN_AREA0 + (col & ~3);
-               else
-                       p = host->regs + SPARE_AREA0 -
-                                       mtd->writesize + (col & ~3);
-
-               if (((col | (int)&buf[i]) & 3) || n < 16) {
-                       uint32_t data;
-
-                       data = readl(p);
-                       switch (col & 3) {
-                       case 0:
-                               if (n) {
-                                       buf[i++] = (uint8_t) (data);
-                                       n--;
-                                       col++;
-                               }
-                       case 1:
-                               if (n) {
-                                       buf[i++] = (uint8_t) (data >> 8);
-                                       n--;
-                                       col++;
-                               }
-                       case 2:
-                               if (n) {
-                                       buf[i++] = (uint8_t) (data >> 16);
-                                       n--;
-                                       col++;
-                               }
-                       case 3:
-                               if (n) {
-                                       buf[i++] = (uint8_t) (data >> 24);
-                                       n--;
-                                       col++;
-                               }
-                       }
-               } else {
-                       int m = mtd->writesize - col;
-
-                       if (col >= mtd->writesize)
-                               m += mtd->oobsize;
-
-                       m = min(n, m) & ~3;
-                       memcpy(&buf[i], p, m);
-                       col += m;
-                       i += m;
-                       n -= m;
-               }
-       }
-       /* Update saved column address */
-       host->col_addr = col;
+       memcpy(buf, host->data_buf + col, len);
 
+       host->buf_start += len;
 }
 
 /* Used by the upper layer to verify the data in NAND Flash
@@ -654,23 +445,6 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
        struct nand_chip *nand_chip = mtd->priv;
        struct mxc_nand_host *host = nand_chip->priv;
 
-#ifdef CONFIG_MTD_NAND_MXC_FORCE_CE
-       if (chip > 0) {
-               DEBUG(MTD_DEBUG_LEVEL0,
-                     "ERROR:  Illegal chip select (chip = %d)\n", chip);
-               return;
-       }
-
-       if (chip == -1) {
-               writew(readw(host->regs + NFC_CONFIG1) & ~NFC_CE,
-                               host->regs + NFC_CONFIG1);
-               return;
-       }
-
-       writew(readw(host->regs + NFC_CONFIG1) | NFC_CE,
-                       host->regs + NFC_CONFIG1);
-#endif
-
        switch (chip) {
        case -1:
                /* Disable the NFC clock */
@@ -692,94 +466,40 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)
        }
 }
 
-/* Used by the upper layer to write command to NAND Flash for
- * different operations to be carried out on NAND Flash */
-static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
-                               int column, int page_addr)
+/*
+ * Function to transfer data to/from spare area.
+ */
+static void copy_spare(struct mtd_info *mtd, bool bfrom)
 {
-       struct nand_chip *nand_chip = mtd->priv;
-       struct mxc_nand_host *host = nand_chip->priv;
-       int useirq = true;
-
-       DEBUG(MTD_DEBUG_LEVEL3,
-             "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",
-             command, column, page_addr);
-
-       /* Reset command state information */
-       host->status_request = false;
-
-       /* Command pre-processing step */
-       switch (command) {
-
-       case NAND_CMD_STATUS:
-               host->col_addr = 0;
-               host->status_request = true;
-               break;
-
-       case NAND_CMD_READ0:
-               host->col_addr = column;
-               host->spare_only = false;
-               useirq = false;
-               break;
-
-       case NAND_CMD_READOOB:
-               host->col_addr = column;
-               host->spare_only = true;
-               useirq = false;
-               if (host->pagesize_2k)
-                       command = NAND_CMD_READ0; /* only READ0 is valid */
-               break;
-
-       case NAND_CMD_SEQIN:
-               if (column >= mtd->writesize) {
-                       /*
-                        * FIXME: before send SEQIN command for write OOB,
-                        * We must read one page out.
-                        * For K9F1GXX has no READ1 command to set current HW
-                        * pointer to spare area, we must write the whole page
-                        * including OOB together.
-                        */
-                       if (host->pagesize_2k)
-                               /* call ourself to read a page */
-                               mxc_nand_command(mtd, NAND_CMD_READ0, 0,
-                                               page_addr);
-
-                       host->col_addr = column - mtd->writesize;
-                       host->spare_only = true;
-
-                       /* Set program pointer to spare region */
-                       if (!host->pagesize_2k)
-                               send_cmd(host, NAND_CMD_READOOB, false);
-               } else {
-                       host->spare_only = false;
-                       host->col_addr = column;
-
-                       /* Set program pointer to page start */
-                       if (!host->pagesize_2k)
-                               send_cmd(host, NAND_CMD_READ0, false);
-               }
-               useirq = false;
-               break;
-
-       case NAND_CMD_PAGEPROG:
-               send_prog_page(host, 0, host->spare_only);
-
-               if (host->pagesize_2k) {
-                       /* data in 4 areas datas */
-                       send_prog_page(host, 1, host->spare_only);
-                       send_prog_page(host, 2, host->spare_only);
-                       send_prog_page(host, 3, host->spare_only);
-               }
-
-               break;
+       struct nand_chip *this = mtd->priv;
+       struct mxc_nand_host *host = this->priv;
+       u16 i, j;
+       u16 n = mtd->writesize >> 9;
+       u8 *d = host->data_buf + mtd->writesize;
+       u8 *s = host->spare0;
+       u16 t = host->spare_len;
+
+       j = (mtd->oobsize / n >> 1) << 1;
+
+       if (bfrom) {
+               for (i = 0; i < n - 1; i++)
+                       memcpy(d + i * j, s + i * t, j);
+
+               /* the last section */
+               memcpy(d + i * j, s + i * t, mtd->oobsize - i * j);
+       } else {
+               for (i = 0; i < n - 1; i++)
+                       memcpy(&s[i * t], &d[i * j], j);
 
-       case NAND_CMD_ERASE1:
-               useirq = false;
-               break;
+               /* the last section */
+               memcpy(&s[i * t], &d[i * j], mtd->oobsize - i * j);
        }
+}
 
-       /* Write out the command to the device. */
-       send_cmd(host, command, useirq);
+static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
+{
+       struct nand_chip *nand_chip = mtd->priv;
+       struct mxc_nand_host *host = nand_chip->priv;
 
        /* Write out column address, if necessary */
        if (column != -1) {
@@ -791,7 +511,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
                 * the full page.
                 */
                send_addr(host, 0, page_addr == -1);
-               if (host->pagesize_2k)
+               if (mtd->writesize > 512)
                        /* another col addr cycle for 2k page */
                        send_addr(host, 0, false);
        }
@@ -801,7 +521,7 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
                /* paddr_0 - p_addr_7 */
                send_addr(host, (page_addr & 0xff), false);
 
-               if (host->pagesize_2k) {
+               if (mtd->writesize > 512) {
                        if (mtd->size >= 0x10000000) {
                                /* paddr_8 - paddr_15 */
                                send_addr(host, (page_addr >> 8) & 0xff, false);
@@ -820,52 +540,136 @@ static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
                                send_addr(host, (page_addr >> 8) & 0xff, true);
                }
        }
+}
+
+/* Used by the upper layer to write command to NAND Flash for
+ * different operations to be carried out on NAND Flash */
+static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
+                               int column, int page_addr)
+{
+       struct nand_chip *nand_chip = mtd->priv;
+       struct mxc_nand_host *host = nand_chip->priv;
+
+       DEBUG(MTD_DEBUG_LEVEL3,
+             "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",
+             command, column, page_addr);
+
+       /* Reset command state information */
+       host->status_request = false;
 
-       /* Command post-processing step */
+       /* Command pre-processing step */
        switch (command) {
 
-       case NAND_CMD_RESET:
+       case NAND_CMD_STATUS:
+               host->buf_start = 0;
+               host->status_request = true;
+
+               send_cmd(host, command, true);
+               mxc_do_addr_cycle(mtd, column, page_addr);
                break;
 
-       case NAND_CMD_READOOB:
        case NAND_CMD_READ0:
-               if (host->pagesize_2k) {
-                       /* send read confirm command */
+       case NAND_CMD_READOOB:
+               if (command == NAND_CMD_READ0)
+                       host->buf_start = column;
+               else
+                       host->buf_start = column + mtd->writesize;
+
+               if (mtd->writesize > 512)
+                       command = NAND_CMD_READ0; /* only READ0 is valid */
+
+               send_cmd(host, command, false);
+               mxc_do_addr_cycle(mtd, column, page_addr);
+
+               if (mtd->writesize > 512)
                        send_cmd(host, NAND_CMD_READSTART, true);
-                       /* read for each AREA */
-                       send_read_page(host, 0, host->spare_only);
-                       send_read_page(host, 1, host->spare_only);
-                       send_read_page(host, 2, host->spare_only);
-                       send_read_page(host, 3, host->spare_only);
-               } else
-                       send_read_page(host, 0, host->spare_only);
+
+               send_page(mtd, NFC_OUTPUT);
+
+               memcpy(host->data_buf, host->main_area0, mtd->writesize);
+               copy_spare(mtd, true);
                break;
 
-       case NAND_CMD_READID:
-               host->col_addr = 0;
-               send_read_id(host);
+       case NAND_CMD_SEQIN:
+               if (column >= mtd->writesize) {
+                       /*
+                        * FIXME: before send SEQIN command for write OOB,
+                        * We must read one page out.
+                        * For K9F1GXX has no READ1 command to set current HW
+                        * pointer to spare area, we must write the whole page
+                        * including OOB together.
+                        */
+                       if (mtd->writesize > 512)
+                               /* call ourself to read a page */
+                               mxc_nand_command(mtd, NAND_CMD_READ0, 0,
+                                               page_addr);
+
+                       host->buf_start = column;
+
+                       /* Set program pointer to spare region */
+                       if (mtd->writesize == 512)
+                               send_cmd(host, NAND_CMD_READOOB, false);
+               } else {
+                       host->buf_start = column;
+
+                       /* Set program pointer to page start */
+                       if (mtd->writesize == 512)
+                               send_cmd(host, NAND_CMD_READ0, false);
+               }
+
+               send_cmd(host, command, false);
+               mxc_do_addr_cycle(mtd, column, page_addr);
                break;
 
        case NAND_CMD_PAGEPROG:
+               memcpy(host->main_area0, host->data_buf, mtd->writesize);
+               copy_spare(mtd, false);
+               send_page(mtd, NFC_INPUT);
+               send_cmd(host, command, true);
+               mxc_do_addr_cycle(mtd, column, page_addr);
                break;
 
-       case NAND_CMD_STATUS:
+       case NAND_CMD_READID:
+               send_cmd(host, command, true);
+               mxc_do_addr_cycle(mtd, column, page_addr);
+               send_read_id(host);
+               host->buf_start = column;
                break;
 
+       case NAND_CMD_ERASE1:
        case NAND_CMD_ERASE2:
+               send_cmd(host, command, false);
+               mxc_do_addr_cycle(mtd, column, page_addr);
+
                break;
        }
 }
 
-/* Define some generic bad / good block scan pattern which are used
- * while scanning a device for factory marked good / bad blocks. */
-static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
+/*
+ * The generic flash bbt decriptors overlap with our ecc
+ * hardware, so define some i.MX specific ones.
+ */
+static uint8_t bbt_pattern[] = { 'B', 'b', 't', '0' };
+static uint8_t mirror_pattern[] = { '1', 't', 'b', 'B' };
+
+static struct nand_bbt_descr bbt_main_descr = {
+       .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
+           | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+       .offs = 0,
+       .len = 4,
+       .veroffs = 4,
+       .maxblocks = 4,
+       .pattern = bbt_pattern,
+};
 
-static struct nand_bbt_descr smallpage_memorybased = {
-       .options = NAND_BBT_SCAN2NDPAGE,
-       .offs = 5,
-       .len = 1,
-       .pattern = scan_ff_pattern
+static struct nand_bbt_descr bbt_mirror_descr = {
+       .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE
+           | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP,
+       .offs = 0,
+       .len = 4,
+       .veroffs = 4,
+       .maxblocks = 4,
+       .pattern = mirror_pattern,
 };
 
 static int __init mxcnd_probe(struct platform_device *pdev)
@@ -877,12 +681,16 @@ static int __init mxcnd_probe(struct platform_device *pdev)
        struct resource *res;
        uint16_t tmp;
        int err = 0, nr_parts = 0;
+       struct nand_ecclayout *oob_smallpage, *oob_largepage;
 
        /* Allocate memory for MTD device structure and private data */
-       host = kzalloc(sizeof(struct mxc_nand_host), GFP_KERNEL);
+       host = kzalloc(sizeof(struct mxc_nand_host) + NAND_MAX_PAGESIZE +
+                       NAND_MAX_OOBSIZE, GFP_KERNEL);
        if (!host)
                return -ENOMEM;
 
+       host->data_buf = (uint8_t *)(host + 1);
+
        host->dev = &pdev->dev;
        /* structures must be linked */
        this = &host->nand;
@@ -890,7 +698,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
        mtd->priv = this;
        mtd->owner = THIS_MODULE;
        mtd->dev.parent = &pdev->dev;
-       mtd->name = "mxc_nand";
+       mtd->name = DRIVER_NAME;
 
        /* 50 us command delay time */
        this->chip_delay = 5;
@@ -920,62 +728,93 @@ static int __init mxcnd_probe(struct platform_device *pdev)
                goto eres;
        }
 
-       host->regs = ioremap(res->start, res->end - res->start + 1);
-       if (!host->regs) {
+       host->base = ioremap(res->start, resource_size(res));
+       if (!host->base) {
                err = -ENOMEM;
                goto eres;
        }
 
+       host->main_area0 = host->base;
+       host->main_area1 = host->base + 0x200;
+
+       if (nfc_is_v21()) {
+               host->regs = host->base + 0x1000;
+               host->spare0 = host->base + 0x1000;
+               host->spare_len = 64;
+               oob_smallpage = &nandv2_hw_eccoob_smallpage;
+               oob_largepage = &nandv2_hw_eccoob_largepage;
+       } else if (nfc_is_v1()) {
+               host->regs = host->base;
+               host->spare0 = host->base + 0x800;
+               host->spare_len = 16;
+               oob_smallpage = &nandv1_hw_eccoob_smallpage;
+               oob_largepage = &nandv1_hw_eccoob_largepage;
+       } else
+               BUG();
+
+       /* disable interrupt and spare enable */
        tmp = readw(host->regs + NFC_CONFIG1);
        tmp |= NFC_INT_MSK;
+       tmp &= ~NFC_SP_EN;
        writew(tmp, host->regs + NFC_CONFIG1);
 
        init_waitqueue_head(&host->irq_waitq);
 
        host->irq = platform_get_irq(pdev, 0);
 
-       err = request_irq(host->irq, mxc_nfc_irq, 0, "mxc_nd", host);
+       err = request_irq(host->irq, mxc_nfc_irq, 0, DRIVER_NAME, host);
        if (err)
                goto eirq;
 
+       /* Reset NAND */
+       this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
+
+       /* preset operation */
+       /* Unlock the internal RAM Buffer */
+       writew(0x2, host->regs + NFC_CONFIG);
+
+       /* Blocks to be unlocked */
+       if (nfc_is_v21()) {
+               writew(0x0, host->regs + NFC_V21_UNLOCKSTART_BLKADDR);
+               writew(0xffff, host->regs + NFC_V21_UNLOCKEND_BLKADDR);
+               this->ecc.bytes = 9;
+       } else if (nfc_is_v1()) {
+               writew(0x0, host->regs + NFC_V1_UNLOCKSTART_BLKADDR);
+               writew(0x4000, host->regs + NFC_V1_UNLOCKEND_BLKADDR);
+               this->ecc.bytes = 3;
+       } else
+               BUG();
+
+       /* Unlock Block Command for given address range */
+       writew(0x4, host->regs + NFC_WRPROT);
+
+       this->ecc.size = 512;
+       this->ecc.layout = oob_smallpage;
+
        if (pdata->hw_ecc) {
                this->ecc.calculate = mxc_nand_calculate_ecc;
                this->ecc.hwctl = mxc_nand_enable_hwecc;
                this->ecc.correct = mxc_nand_correct_data;
                this->ecc.mode = NAND_ECC_HW;
-               this->ecc.size = 512;
-               this->ecc.bytes = 3;
                tmp = readw(host->regs + NFC_CONFIG1);
                tmp |= NFC_ECC_EN;
                writew(tmp, host->regs + NFC_CONFIG1);
        } else {
-               this->ecc.size = 512;
-               this->ecc.bytes = 3;
-               this->ecc.layout = &nand_hw_eccoob_8;
                this->ecc.mode = NAND_ECC_SOFT;
                tmp = readw(host->regs + NFC_CONFIG1);
                tmp &= ~NFC_ECC_EN;
                writew(tmp, host->regs + NFC_CONFIG1);
        }
 
-       /* Reset NAND */
-       this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
-
-       /* preset operation */
-       /* Unlock the internal RAM Buffer */
-       writew(0x2, host->regs + NFC_CONFIG);
-
-       /* Blocks to be unlocked */
-       writew(0x0, host->regs + NFC_UNLOCKSTART_BLKADDR);
-       writew(0x4000, host->regs + NFC_UNLOCKEND_BLKADDR);
-
-       /* Unlock Block Command for given address range */
-       writew(0x4, host->regs + NFC_WRPROT);
-
        /* NAND bus width determines access funtions used by upper layer */
-       if (pdata->width == 2) {
+       if (pdata->width == 2)
                this->options |= NAND_BUSWIDTH_16;
-               this->ecc.layout = &nand_hw_eccoob_16;
+
+       if (pdata->flash_bbt) {
+               this->bbt_td = &bbt_main_descr;
+               this->bbt_md = &bbt_mirror_descr;
+               /* update flash based bbt */
+               this->options |= NAND_USE_FLASH_BBT;
        }
 
        /* first scan to find the device and get the page size */
@@ -984,38 +823,8 @@ static int __init mxcnd_probe(struct platform_device *pdev)
                goto escan;
        }
 
-       if (mtd->writesize == 2048) {
-               host->pagesize_2k = 1;
-               this->badblock_pattern = &smallpage_memorybased;
-       }
-
-       if (this->ecc.mode == NAND_ECC_HW) {
-               switch (mtd->oobsize) {
-               case 8:
-                       this->ecc.layout = &nand_hw_eccoob_8;
-                       break;
-               case 16:
-                       this->ecc.layout = &nand_hw_eccoob_16;
-                       break;
-               case 64:
-                       this->ecc.layout = &nand_hw_eccoob_64;
-                       break;
-               default:
-                       /* page size not handled by HW ECC */
-                       /* switching back to soft ECC */
-                       this->ecc.size = 512;
-                       this->ecc.bytes = 3;
-                       this->ecc.layout = &nand_hw_eccoob_8;
-                       this->ecc.mode = NAND_ECC_SOFT;
-                       this->ecc.calculate = NULL;
-                       this->ecc.correct = NULL;
-                       this->ecc.hwctl = NULL;
-                       tmp = readw(host->regs + NFC_CONFIG1);
-                       tmp &= ~NFC_ECC_EN;
-                       writew(tmp, host->regs + NFC_CONFIG1);
-                       break;
-               }
-       }
+       if (mtd->writesize == 2048)
+               this->ecc.layout = oob_largepage;
 
        /* second phase scan */
        if (nand_scan_tail(mtd)) {
@@ -1043,7 +852,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
 escan:
        free_irq(host->irq, host);
 eirq:
-       iounmap(host->regs);
+       iounmap(host->base);
 eres:
        clk_put(host->clk);
 eclk:
@@ -1062,7 +871,7 @@ static int __devexit mxcnd_remove(struct platform_device *pdev)
 
        nand_release(&host->mtd);
        free_irq(host->irq, host);
-       iounmap(host->regs);
+       iounmap(host->base);
        kfree(host);
 
        return 0;
@@ -1113,7 +922,7 @@ static struct platform_driver mxcnd_driver = {
        .driver = {
                   .name = DRIVER_NAME,
                   },
-       .remove = __exit_p(mxcnd_remove),
+       .remove = __devexit_p(mxcnd_remove),
        .suspend = mxcnd_suspend,
        .resume = mxcnd_resume,
 };
index 2957cc70da3d16cb25477c54adcbbaee6d4fcc18..8f2958fe2148a1d14b24ef33fc1b509bff809a7a 100644 (file)
@@ -428,6 +428,28 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,
        return nand_isbad_bbt(mtd, ofs, allowbbt);
 }
 
+/**
+ * panic_nand_wait_ready - [GENERIC] Wait for the ready pin after commands.
+ * @mtd:       MTD device structure
+ * @timeo:     Timeout
+ *
+ * Helper function for nand_wait_ready used when needing to wait in interrupt
+ * context.
+ */
+static void panic_nand_wait_ready(struct mtd_info *mtd, unsigned long timeo)
+{
+       struct nand_chip *chip = mtd->priv;
+       int i;
+
+       /* Wait for the device to get ready */
+       for (i = 0; i < timeo; i++) {
+               if (chip->dev_ready(mtd))
+                       break;
+               touch_softlockup_watchdog();
+               mdelay(1);
+       }
+}
+
 /*
  * Wait for the ready pin, after a command
  * The timeout is catched later.
@@ -437,6 +459,10 @@ void nand_wait_ready(struct mtd_info *mtd)
        struct nand_chip *chip = mtd->priv;
        unsigned long timeo = jiffies + 2;
 
+       /* 400ms timeout */
+       if (in_interrupt() || oops_in_progress)
+               return panic_nand_wait_ready(mtd, 400);
+
        led_trigger_event(nand_led_trigger, LED_FULL);
        /* wait until command is processed or timeout occures */
        do {
@@ -671,6 +697,22 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
        nand_wait_ready(mtd);
 }
 
+/**
+ * panic_nand_get_device - [GENERIC] Get chip for selected access
+ * @chip:      the nand chip descriptor
+ * @mtd:       MTD device structure
+ * @new_state: the state which is requested
+ *
+ * Used when in panic, no locks are taken.
+ */
+static void panic_nand_get_device(struct nand_chip *chip,
+                     struct mtd_info *mtd, int new_state)
+{
+       /* Hardware controller shared among independend devices */
+       chip->controller->active = chip;
+       chip->state = new_state;
+}
+
 /**
  * nand_get_device - [GENERIC] Get chip for selected access
  * @chip:      the nand chip descriptor
@@ -698,8 +740,14 @@ nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state)
                return 0;
        }
        if (new_state == FL_PM_SUSPENDED) {
-               spin_unlock(lock);
-               return (chip->state == FL_PM_SUSPENDED) ? 0 : -EAGAIN;
+               if (chip->controller->active->state == FL_PM_SUSPENDED) {
+                       chip->state = FL_PM_SUSPENDED;
+                       spin_unlock(lock);
+                       return 0;
+               } else {
+                       spin_unlock(lock);
+                       return -EAGAIN;
+               }
        }
        set_current_state(TASK_UNINTERRUPTIBLE);
        add_wait_queue(wq, &wait);
@@ -709,6 +757,32 @@ nand_get_device(struct nand_chip *chip, struct mtd_info *mtd, int new_state)
        goto retry;
 }
 
+/**
+ * panic_nand_wait - [GENERIC]  wait until the command is done
+ * @mtd:       MTD device structure
+ * @chip:      NAND chip structure
+ * @timeo:     Timeout
+ *
+ * Wait for command done. This is a helper function for nand_wait used when
+ * we are in interrupt context. May happen when in panic and trying to write
+ * an oops trough mtdoops.
+ */
+static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,
+                           unsigned long timeo)
+{
+       int i;
+       for (i = 0; i < timeo; i++) {
+               if (chip->dev_ready) {
+                       if (chip->dev_ready(mtd))
+                               break;
+               } else {
+                       if (chip->read_byte(mtd) & NAND_STATUS_READY)
+                               break;
+               }
+               mdelay(1);
+        }
+}
+
 /**
  * nand_wait - [DEFAULT]  wait until the command is done
  * @mtd:       MTD device structure
@@ -740,15 +814,19 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)
        else
                chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
 
-       while (time_before(jiffies, timeo)) {
-               if (chip->dev_ready) {
-                       if (chip->dev_ready(mtd))
-                               break;
-               } else {
-                       if (chip->read_byte(mtd) & NAND_STATUS_READY)
-                               break;
+       if (in_interrupt() || oops_in_progress)
+               panic_nand_wait(mtd, chip, timeo);
+       else {
+               while (time_before(jiffies, timeo)) {
+                       if (chip->dev_ready) {
+                               if (chip->dev_ready(mtd))
+                                       break;
+                       } else {
+                               if (chip->read_byte(mtd) & NAND_STATUS_READY)
+                                       break;
+                       }
+                       cond_resched();
                }
-               cond_resched();
        }
        led_trigger_event(nand_led_trigger, LED_OFF);
 
@@ -1948,6 +2026,45 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
        return ret;
 }
 
+/**
+ * panic_nand_write - [MTD Interface] NAND write with ECC
+ * @mtd:       MTD device structure
+ * @to:                offset to write to
+ * @len:       number of bytes to write
+ * @retlen:    pointer to variable to store the number of written bytes
+ * @buf:       the data to write
+ *
+ * NAND write with ECC. Used when performing writes in interrupt context, this
+ * may for example be called by mtdoops when writing an oops while in panic.
+ */
+static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
+                           size_t *retlen, const uint8_t *buf)
+{
+       struct nand_chip *chip = mtd->priv;
+       int ret;
+
+       /* Do not allow reads past end of device */
+       if ((to + len) > mtd->size)
+               return -EINVAL;
+       if (!len)
+               return 0;
+
+       /* Wait for the device to get ready.  */
+       panic_nand_wait(mtd, chip, 400);
+
+       /* Grab the device.  */
+       panic_nand_get_device(chip, mtd, FL_WRITING);
+
+       chip->ops.len = len;
+       chip->ops.datbuf = (uint8_t *)buf;
+       chip->ops.oobbuf = NULL;
+
+       ret = nand_do_write_ops(mtd, to, &chip->ops);
+
+       *retlen = chip->ops.retlen;
+       return ret;
+}
+
 /**
  * nand_write - [MTD Interface] NAND write with ECC
  * @mtd:       MTD device structure
@@ -2645,7 +2762,8 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
        type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id);
 
        if (IS_ERR(type)) {
-               printk(KERN_WARNING "No NAND device found!!!\n");
+               if (!(chip->options & NAND_SCAN_SILENT_NODEV))
+                       printk(KERN_WARNING "No NAND device found.\n");
                chip->select_chip(mtd, -1);
                return PTR_ERR(type);
        }
@@ -2877,6 +2995,7 @@ int nand_scan_tail(struct mtd_info *mtd)
        mtd->unpoint = NULL;
        mtd->read = nand_read;
        mtd->write = nand_write;
+       mtd->panic_write = panic_nand_write;
        mtd->read_oob = nand_read_oob;
        mtd->write_oob = nand_write_oob;
        mtd->sync = nand_sync;
diff --git a/drivers/mtd/nand/nand_bcm_umi.c b/drivers/mtd/nand/nand_bcm_umi.c
new file mode 100644 (file)
index 0000000..46a6bc9
--- /dev/null
@@ -0,0 +1,149 @@
+/*****************************************************************************
+* Copyright 2004 - 2009 Broadcom Corporation.  All rights reserved.
+*
+* Unless you and Broadcom execute a separate written software license
+* agreement governing use of this software, this software is licensed to you
+* under the terms of the GNU General Public License version 2, available at
+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
+*
+* Notwithstanding the above, under no circumstances may you combine this
+* software in any way with any other Broadcom software provided under a
+* license other than the GPL, without Broadcom's express prior written
+* consent.
+*****************************************************************************/
+
+/* ---- Include Files ---------------------------------------------------- */
+#include <mach/reg_umi.h>
+#include "nand_bcm_umi.h"
+#ifdef BOOT0_BUILD
+#include <uart.h>
+#endif
+
+/* ---- External Variable Declarations ----------------------------------- */
+/* ---- External Function Prototypes ------------------------------------- */
+/* ---- Public Variables ------------------------------------------------- */
+/* ---- Private Constants and Types -------------------------------------- */
+/* ---- Private Function Prototypes -------------------------------------- */
+/* ---- Private Variables ------------------------------------------------ */
+/* ---- Private Functions ------------------------------------------------ */
+
+#if NAND_ECC_BCH
+/****************************************************************************
+*  nand_bch_ecc_flip_bit - Routine to flip an errored bit
+*
+*  PURPOSE:
+*     This is a helper routine that flips the bit (0 -> 1 or 1 -> 0) of the
+*     errored bit specified
+*
+*  PARAMETERS:
+*     datap - Container that holds the 512 byte data
+*     errorLocation - Location of the bit that needs to be flipped
+*
+*  RETURNS:
+*     None
+****************************************************************************/
+static void nand_bcm_umi_bch_ecc_flip_bit(uint8_t *datap, int errorLocation)
+{
+       int locWithinAByte = (errorLocation & REG_UMI_BCH_ERR_LOC_BYTE) >> 0;
+       int locWithinAWord = (errorLocation & REG_UMI_BCH_ERR_LOC_WORD) >> 3;
+       int locWithinAPage = (errorLocation & REG_UMI_BCH_ERR_LOC_PAGE) >> 5;
+
+       uint8_t errorByte = 0;
+       uint8_t byteMask = 1 << locWithinAByte;
+
+       /* BCH uses big endian, need to change the location
+        * bits to little endian */
+       locWithinAWord = 3 - locWithinAWord;
+
+       errorByte = datap[locWithinAPage * sizeof(uint32_t) + locWithinAWord];
+
+#ifdef BOOT0_BUILD
+       puthexs("\nECC Correct Offset: ",
+               locWithinAPage * sizeof(uint32_t) + locWithinAWord);
+       puthexs(" errorByte:", errorByte);
+       puthex8(" Bit: ", locWithinAByte);
+#endif
+
+       if (errorByte & byteMask) {
+               /* bit needs to be cleared */
+               errorByte &= ~byteMask;
+       } else {
+               /* bit needs to be set */
+               errorByte |= byteMask;
+       }
+
+       /* write back the value with the fixed bit */
+       datap[locWithinAPage * sizeof(uint32_t) + locWithinAWord] = errorByte;
+}
+
+/****************************************************************************
+*  nand_correct_page_bch - Routine to correct bit errors when reading NAND
+*
+*  PURPOSE:
+*     This routine reads the BCH registers to determine if there are any bit
+*     errors during the read of the last 512 bytes of data + ECC bytes.  If
+*     errors exists, the routine fixes it.
+*
+*  PARAMETERS:
+*     datap - Container that holds the 512 byte data
+*
+*  RETURNS:
+*     0 or greater = Number of errors corrected
+*                    (No errors are found or errors have been fixed)
+*    -1 = Error(s) cannot be fixed
+****************************************************************************/
+int nand_bcm_umi_bch_correct_page(uint8_t *datap, uint8_t *readEccData,
+                                 int numEccBytes)
+{
+       int numErrors;
+       int errorLocation;
+       int idx;
+       uint32_t regValue;
+
+       /* wait for read ECC to be valid */
+       regValue = nand_bcm_umi_bch_poll_read_ecc_calc();
+
+       /*
+        * read the control status register to determine if there
+        * are error'ed bits
+        * see if errors are correctible
+        */
+       if ((regValue & REG_UMI_BCH_CTRL_STATUS_UNCORR_ERR) > 0) {
+               int i;
+
+               for (i = 0; i < numEccBytes; i++) {
+                       if (readEccData[i] != 0xff) {
+                               /* errors cannot be fixed, return -1 */
+                               return -1;
+                       }
+               }
+               /* If ECC is unprogrammed then we can't correct,
+                * assume everything OK */
+               return 0;
+       }
+
+       if ((regValue & REG_UMI_BCH_CTRL_STATUS_CORR_ERR) == 0) {
+               /* no errors */
+               return 0;
+       }
+
+       /*
+        * Fix errored bits by doing the following:
+        * 1. Read the number of errors in the control and status register
+        * 2. Read the error location registers that corresponds to the number
+        *    of errors reported
+        * 3. Invert the bit in the data
+        */
+       numErrors = (regValue & REG_UMI_BCH_CTRL_STATUS_NB_CORR_ERROR) >> 20;
+
+       for (idx = 0; idx < numErrors; idx++) {
+               errorLocation =
+                   REG_UMI_BCH_ERR_LOC_ADDR(idx) & REG_UMI_BCH_ERR_LOC_MASK;
+
+               /* Flip bit */
+               nand_bcm_umi_bch_ecc_flip_bit(datap, errorLocation);
+       }
+       /* Errors corrected */
+       return numErrors;
+}
+#endif
diff --git a/drivers/mtd/nand/nand_bcm_umi.h b/drivers/mtd/nand/nand_bcm_umi.h
new file mode 100644 (file)
index 0000000..7cec2cd
--- /dev/null
@@ -0,0 +1,358 @@
+/*****************************************************************************
+* Copyright 2003 - 2009 Broadcom Corporation.  All rights reserved.
+*
+* Unless you and Broadcom execute a separate written software license
+* agreement governing use of this software, this software is licensed to you
+* under the terms of the GNU General Public License version 2, available at
+* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
+*
+* Notwithstanding the above, under no circumstances may you combine this
+* software in any way with any other Broadcom software provided under a
+* license other than the GPL, without Broadcom's express prior written
+* consent.
+*****************************************************************************/
+#ifndef NAND_BCM_UMI_H
+#define NAND_BCM_UMI_H
+
+/* ---- Include Files ---------------------------------------------------- */
+#include <mach/reg_umi.h>
+#include <mach/reg_nand.h>
+#include <cfg_global.h>
+
+/* ---- Constants and Types ---------------------------------------------- */
+#if (CFG_GLOBAL_CHIP_FAMILY == CFG_GLOBAL_CHIP_FAMILY_BCMRING)
+#define NAND_ECC_BCH (CFG_GLOBAL_CHIP_REV > 0xA0)
+#else
+#define NAND_ECC_BCH 0
+#endif
+
+#define CFG_GLOBAL_NAND_ECC_BCH_NUM_BYTES      13
+
+#if NAND_ECC_BCH
+#ifdef BOOT0_BUILD
+#define NAND_ECC_NUM_BYTES 13
+#else
+#define NAND_ECC_NUM_BYTES CFG_GLOBAL_NAND_ECC_BCH_NUM_BYTES
+#endif
+#else
+#define NAND_ECC_NUM_BYTES 3
+#endif
+
+#define NAND_DATA_ACCESS_SIZE 512
+
+/* ---- Variable Externs ------------------------------------------ */
+/* ---- Function Prototypes --------------------------------------- */
+int nand_bcm_umi_bch_correct_page(uint8_t *datap, uint8_t *readEccData,
+                                 int numEccBytes);
+
+/* Check in device is ready */
+static inline int nand_bcm_umi_dev_ready(void)
+{
+       return REG_UMI_NAND_RCSR & REG_UMI_NAND_RCSR_RDY;
+}
+
+/* Wait until device is ready */
+static inline void nand_bcm_umi_wait_till_ready(void)
+{
+       while (nand_bcm_umi_dev_ready() == 0)
+               ;
+}
+
+/* Enable Hamming ECC */
+static inline void nand_bcm_umi_hamming_enable_hwecc(void)
+{
+       /* disable and reset ECC, 512 byte page */
+       REG_UMI_NAND_ECC_CSR &= ~(REG_UMI_NAND_ECC_CSR_ECC_ENABLE |
+               REG_UMI_NAND_ECC_CSR_256BYTE);
+       /* enable ECC */
+       REG_UMI_NAND_ECC_CSR |= REG_UMI_NAND_ECC_CSR_ECC_ENABLE;
+}
+
+#if NAND_ECC_BCH
+/* BCH ECC specifics */
+#define ECC_BITS_PER_CORRECTABLE_BIT 13
+
+/* Enable BCH Read ECC */
+static inline void nand_bcm_umi_bch_enable_read_hwecc(void)
+{
+       /* disable and reset ECC */
+       REG_UMI_BCH_CTRL_STATUS = REG_UMI_BCH_CTRL_STATUS_RD_ECC_VALID;
+       /* Turn on ECC */
+       REG_UMI_BCH_CTRL_STATUS = REG_UMI_BCH_CTRL_STATUS_ECC_RD_EN;
+}
+
+/* Enable BCH Write ECC */
+static inline void nand_bcm_umi_bch_enable_write_hwecc(void)
+{
+       /* disable and reset ECC */
+       REG_UMI_BCH_CTRL_STATUS = REG_UMI_BCH_CTRL_STATUS_WR_ECC_VALID;
+       /* Turn on ECC */
+       REG_UMI_BCH_CTRL_STATUS = REG_UMI_BCH_CTRL_STATUS_ECC_WR_EN;
+}
+
+/* Config number of BCH ECC bytes */
+static inline void nand_bcm_umi_bch_config_ecc(uint8_t numEccBytes)
+{
+       uint32_t nValue;
+       uint32_t tValue;
+       uint32_t kValue;
+       uint32_t numBits = numEccBytes * 8;
+
+       /* disable and reset ECC */
+       REG_UMI_BCH_CTRL_STATUS =
+           REG_UMI_BCH_CTRL_STATUS_WR_ECC_VALID |
+           REG_UMI_BCH_CTRL_STATUS_RD_ECC_VALID;
+
+       /* Every correctible bit requires 13 ECC bits */
+       tValue = (uint32_t) (numBits / ECC_BITS_PER_CORRECTABLE_BIT);
+
+       /* Total data in number of bits for generating and computing BCH ECC */
+       nValue = (NAND_DATA_ACCESS_SIZE + numEccBytes) * 8;
+
+       /* K parameter is used internally.  K = N - (T * 13) */
+       kValue = nValue - (tValue * ECC_BITS_PER_CORRECTABLE_BIT);
+
+       /* Write the settings */
+       REG_UMI_BCH_N = nValue;
+       REG_UMI_BCH_T = tValue;
+       REG_UMI_BCH_K = kValue;
+}
+
+/* Pause during ECC read calculation to skip bytes in OOB */
+static inline void nand_bcm_umi_bch_pause_read_ecc_calc(void)
+{
+       REG_UMI_BCH_CTRL_STATUS =
+           REG_UMI_BCH_CTRL_STATUS_ECC_RD_EN |
+           REG_UMI_BCH_CTRL_STATUS_PAUSE_ECC_DEC;
+}
+
+/* Resume during ECC read calculation after skipping bytes in OOB */
+static inline void nand_bcm_umi_bch_resume_read_ecc_calc(void)
+{
+       REG_UMI_BCH_CTRL_STATUS = REG_UMI_BCH_CTRL_STATUS_ECC_RD_EN;
+}
+
+/* Poll read ECC calc to check when hardware completes */
+static inline uint32_t nand_bcm_umi_bch_poll_read_ecc_calc(void)
+{
+       uint32_t regVal;
+
+       do {
+               /* wait for ECC to be valid */
+               regVal = REG_UMI_BCH_CTRL_STATUS;
+       } while ((regVal & REG_UMI_BCH_CTRL_STATUS_RD_ECC_VALID) == 0);
+
+       return regVal;
+}
+
+/* Poll write ECC calc to check when hardware completes */
+static inline void nand_bcm_umi_bch_poll_write_ecc_calc(void)
+{
+       /* wait for ECC to be valid */
+       while ((REG_UMI_BCH_CTRL_STATUS & REG_UMI_BCH_CTRL_STATUS_WR_ECC_VALID)
+              == 0)
+               ;
+}
+
+/* Read the OOB and ECC, for kernel write OOB to a buffer */
+#if defined(__KERNEL__) && !defined(STANDALONE)
+static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
+       uint8_t *eccCalc, int numEccBytes, uint8_t *oobp)
+#else
+static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
+       uint8_t *eccCalc, int numEccBytes)
+#endif
+{
+       int eccPos = 0;
+       int numToRead = 16;     /* There are 16 bytes per sector in the OOB */
+
+       /* ECC is already paused when this function is called */
+
+       if (pageSize == NAND_DATA_ACCESS_SIZE) {
+               while (numToRead > numEccBytes) {
+                       /* skip free oob region */
+#if defined(__KERNEL__) && !defined(STANDALONE)
+                       *oobp++ = REG_NAND_DATA8;
+#else
+                       REG_NAND_DATA8;
+#endif
+                       numToRead--;
+               }
+
+               /* read ECC bytes before BI */
+               nand_bcm_umi_bch_resume_read_ecc_calc();
+
+               while (numToRead > 11) {
+#if defined(__KERNEL__) && !defined(STANDALONE)
+                       *oobp = REG_NAND_DATA8;
+                       eccCalc[eccPos++] = *oobp;
+                       oobp++;
+#else
+                       eccCalc[eccPos++] = REG_NAND_DATA8;
+#endif
+               }
+
+               nand_bcm_umi_bch_pause_read_ecc_calc();
+
+               if (numToRead == 11) {
+                       /* read BI */
+#if defined(__KERNEL__) && !defined(STANDALONE)
+                       *oobp++ = REG_NAND_DATA8;
+#else
+                       REG_NAND_DATA8;
+#endif
+                       numToRead--;
+               }
+
+               /* read ECC bytes */
+               nand_bcm_umi_bch_resume_read_ecc_calc();
+               while (numToRead) {
+#if defined(__KERNEL__) && !defined(STANDALONE)
+                       *oobp = REG_NAND_DATA8;
+                       eccCalc[eccPos++] = *oobp;
+                       oobp++;
+#else
+                       eccCalc[eccPos++] = REG_NAND_DATA8;
+#endif
+                       numToRead--;
+               }
+       } else {
+               /* skip BI */
+#if defined(__KERNEL__) && !defined(STANDALONE)
+               *oobp++ = REG_NAND_DATA8;
+#else
+               REG_NAND_DATA8;
+#endif
+               numToRead--;
+
+               while (numToRead > numEccBytes) {
+                       /* skip free oob region */
+#if defined(__KERNEL__) && !defined(STANDALONE)
+                       *oobp++ = REG_NAND_DATA8;
+#else
+                       REG_NAND_DATA8;
+#endif
+                       numToRead--;
+               }
+
+               /* read ECC bytes */
+               nand_bcm_umi_bch_resume_read_ecc_calc();
+               while (numToRead) {
+#if defined(__KERNEL__) && !defined(STANDALONE)
+                       *oobp = REG_NAND_DATA8;
+                       eccCalc[eccPos++] = *oobp;
+                       oobp++;
+#else
+                       eccCalc[eccPos++] = REG_NAND_DATA8;
+#endif
+                       numToRead--;
+               }
+       }
+}
+
+/* Helper function to write ECC */
+static inline void NAND_BCM_UMI_ECC_WRITE(int numEccBytes, int eccBytePos,
+                                         uint8_t *oobp, uint8_t eccVal)
+{
+       if (eccBytePos <= numEccBytes)
+               *oobp = eccVal;
+}
+
+/* Write OOB with ECC */
+static inline void nand_bcm_umi_bch_write_oobEcc(uint32_t pageSize,
+                                                uint8_t *oobp, int numEccBytes)
+{
+       uint32_t eccVal = 0xffffffff;
+
+       /* wait for write ECC to be valid */
+       nand_bcm_umi_bch_poll_write_ecc_calc();
+
+       /*
+        ** Get the hardware ecc from the 32-bit result registers.
+        ** Read after 512 byte accesses. Format B3B2B1B0
+        ** where B3 = ecc3, etc.
+        */
+
+       if (pageSize == NAND_DATA_ACCESS_SIZE) {
+               /* Now fill in the ECC bytes */
+               if (numEccBytes >= 13)
+                       eccVal = REG_UMI_BCH_WR_ECC_3;
+
+               /* Usually we skip CM in oob[0,1] */
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 15, &oobp[0],
+                       (eccVal >> 16) & 0xff);
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 14, &oobp[1],
+                       (eccVal >> 8) & 0xff);
+
+               /* Write ECC in oob[2,3,4] */
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 13, &oobp[2],
+                       eccVal & 0xff); /* ECC 12 */
+
+               if (numEccBytes >= 9)
+                       eccVal = REG_UMI_BCH_WR_ECC_2;
+
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 12, &oobp[3],
+                       (eccVal >> 24) & 0xff); /* ECC11 */
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 11, &oobp[4],
+                       (eccVal >> 16) & 0xff); /* ECC10 */
+
+               /* Always Skip BI in oob[5] */
+       } else {
+               /* Always Skip BI in oob[0] */
+
+               /* Now fill in the ECC bytes */
+               if (numEccBytes >= 13)
+                       eccVal = REG_UMI_BCH_WR_ECC_3;
+
+               /* Usually skip CM in oob[1,2] */
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 15, &oobp[1],
+                       (eccVal >> 16) & 0xff);
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 14, &oobp[2],
+                       (eccVal >> 8) & 0xff);
+
+               /* Write ECC in oob[3-15] */
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 13, &oobp[3],
+                       eccVal & 0xff); /* ECC12 */
+
+               if (numEccBytes >= 9)
+                       eccVal = REG_UMI_BCH_WR_ECC_2;
+
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 12, &oobp[4],
+                       (eccVal >> 24) & 0xff); /* ECC11 */
+               NAND_BCM_UMI_ECC_WRITE(numEccBytes, 11, &oobp[5],
+                       (eccVal >> 16) & 0xff); /* ECC10 */
+       }
+
+       /* Fill in the remainder of ECC locations */
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 10, &oobp[6],
+               (eccVal >> 8) & 0xff);  /* ECC9 */
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 9, &oobp[7],
+               eccVal & 0xff); /* ECC8 */
+
+       if (numEccBytes >= 5)
+               eccVal = REG_UMI_BCH_WR_ECC_1;
+
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 8, &oobp[8],
+               (eccVal >> 24) & 0xff); /* ECC7 */
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 7, &oobp[9],
+               (eccVal >> 16) & 0xff); /* ECC6 */
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 6, &oobp[10],
+               (eccVal >> 8) & 0xff);  /* ECC5 */
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 5, &oobp[11],
+               eccVal & 0xff); /* ECC4 */
+
+       if (numEccBytes >= 1)
+               eccVal = REG_UMI_BCH_WR_ECC_0;
+
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 4, &oobp[12],
+               (eccVal >> 24) & 0xff); /* ECC3 */
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 3, &oobp[13],
+               (eccVal >> 16) & 0xff); /* ECC2 */
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 2, &oobp[14],
+               (eccVal >> 8) & 0xff);  /* ECC1 */
+       NAND_BCM_UMI_ECC_WRITE(numEccBytes, 1, &oobp[15],
+               eccVal & 0xff); /* ECC0 */
+}
+#endif
+
+#endif /* NAND_BCM_UMI_H */
index 92320a6432759f0f82f353a92334c1ff94fe3796..271b8e735e8fa1ea21f64a0751d5ab94e147c398 100644 (file)
@@ -150,20 +150,19 @@ static const char addressbits[256] = {
 };
 
 /**
- * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
+ * __nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
  *                      block
- * @mtd:       MTD block structure
  * @buf:       input buffer with raw data
+ * @eccsize:   data bytes per ecc step (256 or 512)
  * @code:      output buffer with ECC
  */
-int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
+void __nand_calculate_ecc(const unsigned char *buf, unsigned int eccsize,
                       unsigned char *code)
 {
        int i;
        const uint32_t *bp = (uint32_t *)buf;
        /* 256 or 512 bytes/ecc  */
-       const uint32_t eccsize_mult =
-                       (((struct nand_chip *)mtd->priv)->ecc.size) >> 8;
+       const uint32_t eccsize_mult = eccsize >> 8;
        uint32_t cur;           /* current value in buffer */
        /* rp0..rp15..rp17 are the various accumulated parities (per byte) */
        uint32_t rp0, rp1, rp2, rp3, rp4, rp5, rp6, rp7;
@@ -412,6 +411,22 @@ int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
                    (invparity[par & 0x55] << 2) |
                    (invparity[rp17] << 1) |
                    (invparity[rp16] << 0);
+}
+EXPORT_SYMBOL(__nand_calculate_ecc);
+
+/**
+ * nand_calculate_ecc - [NAND Interface] Calculate 3-byte ECC for 256/512-byte
+ *                      block
+ * @mtd:       MTD block structure
+ * @buf:       input buffer with raw data
+ * @code:      output buffer with ECC
+ */
+int nand_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,
+                      unsigned char *code)
+{
+       __nand_calculate_ecc(buf,
+                       ((struct nand_chip *)mtd->priv)->ecc.size, code);
+
        return 0;
 }
 EXPORT_SYMBOL(nand_calculate_ecc);
index cd0711b83ac4bca101e34bcba578af5c76fac0cf..7281000fef2d346803d7414af8b91bf1ed3de1aa 100644 (file)
@@ -161,7 +161,7 @@ MODULE_PARM_DESC(overridesize,   "Specifies the NAND Flash size overriding the I
 MODULE_PARM_DESC(cache_file,     "File to use to cache nand pages instead of memory");
 
 /* The largest possible page size */
-#define NS_LARGEST_PAGE_SIZE   2048
+#define NS_LARGEST_PAGE_SIZE   4096
 
 /* The prefix for simulator output */
 #define NS_OUTPUT_PREFIX "[nandsim]"
@@ -259,7 +259,8 @@ MODULE_PARM_DESC(cache_file,     "File to use to cache nand pages instead of mem
 #define OPT_SMARTMEDIA   0x00000010 /* SmartMedia technology chips */
 #define OPT_AUTOINCR     0x00000020 /* page number auto inctimentation is possible */
 #define OPT_PAGE512_8BIT 0x00000040 /* 512-byte page chips with 8-bit bus width */
-#define OPT_LARGEPAGE    (OPT_PAGE2048) /* 2048-byte page chips */
+#define OPT_PAGE4096     0x00000080 /* 4096-byte page chips */
+#define OPT_LARGEPAGE    (OPT_PAGE2048 | OPT_PAGE4096) /* 2048 & 4096-byte page chips */
 #define OPT_SMALLPAGE    (OPT_PAGE256  | OPT_PAGE512)  /* 256 and 512-byte page chips */
 
 /* Remove action bits ftom state */
@@ -588,6 +589,8 @@ static int init_nandsim(struct mtd_info *mtd)
                        ns->options |= OPT_PAGE512_8BIT;
        } else if (ns->geom.pgsz == 2048) {
                ns->options |= OPT_PAGE2048;
+       } else if (ns->geom.pgsz == 4096) {
+               ns->options |= OPT_PAGE4096;
        } else {
                NS_ERR("init_nandsim: unknown page size %u\n", ns->geom.pgsz);
                return -EIO;
index 7c302d55910e6dfb8f63bcf7ac4f4a4027423180..66123419f65d4561f4912a60e68d499d9e0406e7 100644 (file)
@@ -216,7 +216,7 @@ static int nomadik_nand_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops nomadik_nand_pm_ops = {
+static const struct dev_pm_ops nomadik_nand_pm_ops = {
        .suspend = nomadik_nand_suspend,
        .resume = nomadik_nand_resume,
 };
index 4e16c6f5bdd5a7642b4fff683e2e05e2aadf7267..8d467315f02be00efd5b124f104feed37a8282b0 100644 (file)
@@ -34,7 +34,12 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
 {
        struct platform_nand_data *pdata = pdev->dev.platform_data;
        struct plat_nand_data *data;
-       int res = 0;
+       struct resource *res;
+       int err = 0;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res)
+               return -ENXIO;
 
        /* Allocate memory for the device structure (and zero it) */
        data = kzalloc(sizeof(struct plat_nand_data), GFP_KERNEL);
@@ -43,12 +48,18 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       data->io_base = ioremap(pdev->resource[0].start,
-                               pdev->resource[0].end - pdev->resource[0].start + 1);
+       if (!request_mem_region(res->start, resource_size(res),
+                               dev_name(&pdev->dev))) {
+               dev_err(&pdev->dev, "request_mem_region failed\n");
+               err = -EBUSY;
+               goto out_free;
+       }
+
+       data->io_base = ioremap(res->start, resource_size(res));
        if (data->io_base == NULL) {
                dev_err(&pdev->dev, "ioremap failed\n");
-               kfree(data);
-               return -EIO;
+               err = -EIO;
+               goto out_release_io;
        }
 
        data->chip.priv = &data;
@@ -74,24 +85,24 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
 
        /* Handle any platform specific setup */
        if (pdata->ctrl.probe) {
-               res = pdata->ctrl.probe(pdev);
-               if (res)
+               err = pdata->ctrl.probe(pdev);
+               if (err)
                        goto out;
        }
 
        /* Scan to find existance of the device */
        if (nand_scan(&data->mtd, 1)) {
-               res = -ENXIO;
+               err = -ENXIO;
                goto out;
        }
 
 #ifdef CONFIG_MTD_PARTITIONS
        if (pdata->chip.part_probe_types) {
-               res = parse_mtd_partitions(&data->mtd,
+               err = parse_mtd_partitions(&data->mtd,
                                        pdata->chip.part_probe_types,
                                        &data->parts, 0);
-               if (res > 0) {
-                       add_mtd_partitions(&data->mtd, data->parts, res);
+               if (err > 0) {
+                       add_mtd_partitions(&data->mtd, data->parts, err);
                        return 0;
                }
        }
@@ -99,14 +110,14 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
                pdata->chip.set_parts(data->mtd.size, &pdata->chip);
        if (pdata->chip.partitions) {
                data->parts = pdata->chip.partitions;
-               res = add_mtd_partitions(&data->mtd, data->parts,
+               err = add_mtd_partitions(&data->mtd, data->parts,
                        pdata->chip.nr_partitions);
        } else
 #endif
-       res = add_mtd_device(&data->mtd);
+       err = add_mtd_device(&data->mtd);
 
-       if (!res)
-               return res;
+       if (!err)
+               return err;
 
        nand_release(&data->mtd);
 out:
@@ -114,8 +125,11 @@ out:
                pdata->ctrl.remove(pdev);
        platform_set_drvdata(pdev, NULL);
        iounmap(data->io_base);
+out_release_io:
+       release_mem_region(res->start, resource_size(res));
+out_free:
        kfree(data);
-       return res;
+       return err;
 }
 
 /*
@@ -125,6 +139,9 @@ static int __devexit plat_nand_remove(struct platform_device *pdev)
 {
        struct plat_nand_data *data = platform_get_drvdata(pdev);
        struct platform_nand_data *pdata = pdev->dev.platform_data;
+       struct resource *res;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
        nand_release(&data->mtd);
 #ifdef CONFIG_MTD_PARTITIONS
@@ -134,6 +151,7 @@ static int __devexit plat_nand_remove(struct platform_device *pdev)
        if (pdata->ctrl.remove)
                pdata->ctrl.remove(pdev);
        iounmap(data->io_base);
+       release_mem_region(res->start, resource_size(res));
        kfree(data);
 
        return 0;
index 68b5b3a486a9c66571ad0012c4337b81d3a23841..fa6e9c7fe51103c092ff4214e66cfeaf8e424af3 100644 (file)
@@ -774,7 +774,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
        chip->select_chip  = s3c2410_nand_select_chip;
        chip->chip_delay   = 50;
        chip->priv         = nmtd;
-       chip->options      = 0;
+       chip->options      = set->options;
        chip->controller   = &info->controller;
 
        switch (info->cpu_type) {
index 73af8324d0d0b4e540195063c9b311dcaf875b3b..863513c3b69af5942fae4da6b135e460e2681a94 100644 (file)
@@ -429,11 +429,10 @@ static int __exit txx9ndfmc_remove(struct platform_device *dev)
                chip = mtd->priv;
                txx9_priv = chip->priv;
 
+               nand_release(mtd);
 #ifdef CONFIG_MTD_PARTITIONS
-               del_mtd_partitions(mtd);
                kfree(drvdata->parts[i]);
 #endif
-               del_mtd_device(mtd);
                kfree(txx9_priv->mtdname);
                kfree(txx9_priv);
        }
index 86c4f6dcdc659723dcfeb670cc136e5ff2369373..75f38b95811ea729b0e9f2494399253d93ed8472 100644 (file)
@@ -112,10 +112,24 @@ static int omap2_onenand_wait(struct mtd_info *mtd, int state)
        unsigned long timeout;
        u32 syscfg;
 
-       if (state == FL_RESETING) {
-               int i;
+       if (state == FL_RESETING || state == FL_PREPARING_ERASE ||
+           state == FL_VERIFYING_ERASE) {
+               int i = 21;
+               unsigned int intr_flags = ONENAND_INT_MASTER;
+
+               switch (state) {
+               case FL_RESETING:
+                       intr_flags |= ONENAND_INT_RESET;
+                       break;
+               case FL_PREPARING_ERASE:
+                       intr_flags |= ONENAND_INT_ERASE;
+                       break;
+               case FL_VERIFYING_ERASE:
+                       i = 101;
+                       break;
+               }
 
-               for (i = 0; i < 20; i++) {
+               while (--i) {
                        udelay(1);
                        intr = read_reg(c, ONENAND_REG_INTERRUPT);
                        if (intr & ONENAND_INT_MASTER)
@@ -126,7 +140,7 @@ static int omap2_onenand_wait(struct mtd_info *mtd, int state)
                        wait_err("controller error", state, ctrl, intr);
                        return -EIO;
                }
-               if (!(intr & ONENAND_INT_RESET)) {
+               if ((intr & intr_flags) != intr_flags) {
                        wait_err("timeout", state, ctrl, intr);
                        return -EIO;
                }
index ff66e4330aa71ebde90b830b0faca5e4dc6f31d0..f63b1db3ffb3f0266658a787bc59dd09dd7f2a2a 100644 (file)
@@ -1,17 +1,19 @@
 /*
  *  linux/drivers/mtd/onenand/onenand_base.c
  *
- *  Copyright (C) 2005-2007 Samsung Electronics
+ *  Copyright Â© 2005-2009 Samsung Electronics
+ *  Copyright Â© 2007 Nokia Corporation
+ *
  *  Kyungmin Park <kyungmin.park@samsung.com>
  *
  *  Credits:
  *     Adrian Hunter <ext-adrian.hunter@nokia.com>:
  *     auto-placement support, read-while load support, various fixes
- *     Copyright (C) Nokia Corporation, 2007
  *
  *     Vishak G <vishak.g at samsung.com>, Rohit Hagargundgi <h.rohit at samsung.com>
  *     Flex-OneNAND support
- *     Copyright (C) Samsung Electronics, 2008
+ *     Amul Kumar Saha <amul.saha at samsung.com>
+ *     OTP support
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
 
 #include <asm/io.h>
 
+/*
+ * Multiblock erase if number of blocks to erase is 2 or more.
+ * Maximum number of blocks for simultaneous erase is 64.
+ */
+#define MB_ERASE_MIN_BLK_COUNT 2
+#define MB_ERASE_MAX_BLK_COUNT 64
+
 /* Default Flex-OneNAND boundary and lock respectively */
 static int flex_bdry[MAX_DIES * 2] = { -1, 0, -1, 0 };
 
@@ -43,6 +52,18 @@ MODULE_PARM_DESC(flex_bdry,  "SLC Boundary information for Flex-OneNAND"
                                "    : 0->Set boundary in unlocked status"
                                "    : 1->Set boundary in locked status");
 
+/* Default OneNAND/Flex-OneNAND OTP options*/
+static int otp;
+
+module_param(otp, int, 0400);
+MODULE_PARM_DESC(otp,  "Corresponding behaviour of OneNAND in OTP"
+                       "Syntax : otp=LOCK_TYPE"
+                       "LOCK_TYPE : Keys issued, for specific OTP Lock type"
+                       "          : 0 -> Default (No Blocks Locked)"
+                       "          : 1 -> OTP Block lock"
+                       "          : 2 -> 1st Block lock"
+                       "          : 3 -> BOTH OTP Block and 1st Block lock");
+
 /**
  *  onenand_oob_128 - oob info for Flex-Onenand with 4KB page
  *  For now, we expose only 64 out of 80 ecc bytes
@@ -339,6 +360,8 @@ static int onenand_command(struct mtd_info *mtd, int cmd, loff_t addr, size_t le
                break;
 
        case ONENAND_CMD_ERASE:
+       case ONENAND_CMD_MULTIBLOCK_ERASE:
+       case ONENAND_CMD_ERASE_VERIFY:
        case ONENAND_CMD_BUFFERRAM:
        case ONENAND_CMD_OTP_ACCESS:
                block = onenand_block(this, addr);
@@ -483,7 +506,7 @@ static int onenand_wait(struct mtd_info *mtd, int state)
                if (interrupt & flags)
                        break;
 
-               if (state != FL_READING)
+               if (state != FL_READING && state != FL_PREPARING_ERASE)
                        cond_resched();
        }
        /* To get correct interrupt status in timeout case */
@@ -500,25 +523,40 @@ static int onenand_wait(struct mtd_info *mtd, int state)
                int ecc = onenand_read_ecc(this);
                if (ecc) {
                        if (ecc & ONENAND_ECC_2BIT_ALL) {
-                               printk(KERN_ERR "onenand_wait: ECC error = 0x%04x\n", ecc);
+                               printk(KERN_ERR "%s: ECC error = 0x%04x\n",
+                                       __func__, ecc);
                                mtd->ecc_stats.failed++;
                                return -EBADMSG;
                        } else if (ecc & ONENAND_ECC_1BIT_ALL) {
-                               printk(KERN_DEBUG "onenand_wait: correctable ECC error = 0x%04x\n", ecc);
+                               printk(KERN_DEBUG "%s: correctable ECC error = 0x%04x\n",
+                                       __func__, ecc);
                                mtd->ecc_stats.corrected++;
                        }
                }
        } else if (state == FL_READING) {
-               printk(KERN_ERR "onenand_wait: read timeout! ctrl=0x%04x intr=0x%04x\n", ctrl, interrupt);
+               printk(KERN_ERR "%s: read timeout! ctrl=0x%04x intr=0x%04x\n",
+                       __func__, ctrl, interrupt);
+               return -EIO;
+       }
+
+       if (state == FL_PREPARING_ERASE && !(interrupt & ONENAND_INT_ERASE)) {
+               printk(KERN_ERR "%s: mb erase timeout! ctrl=0x%04x intr=0x%04x\n",
+                      __func__, ctrl, interrupt);
+               return -EIO;
+       }
+
+       if (!(interrupt & ONENAND_INT_MASTER)) {
+               printk(KERN_ERR "%s: timeout! ctrl=0x%04x intr=0x%04x\n",
+                      __func__, ctrl, interrupt);
                return -EIO;
        }
 
        /* If there's controller error, it's a real error */
        if (ctrl & ONENAND_CTRL_ERROR) {
-               printk(KERN_ERR "onenand_wait: controller error = 0x%04x\n",
-                       ctrl);
+               printk(KERN_ERR "%s: controller error = 0x%04x\n",
+                       __func__, ctrl);
                if (ctrl & ONENAND_CTRL_LOCK)
-                       printk(KERN_ERR "onenand_wait: it's locked error.\n");
+                       printk(KERN_ERR "%s: it's locked error.\n", __func__);
                return -EIO;
        }
 
@@ -1015,7 +1053,8 @@ static int onenand_recover_lsb(struct mtd_info *mtd, loff_t addr, int status)
        /* We are attempting to reread, so decrement stats.failed
         * which was incremented by onenand_wait due to read failure
         */
-       printk(KERN_INFO "onenand_recover_lsb: Attempting to recover from uncorrectable read\n");
+       printk(KERN_INFO "%s: Attempting to recover from uncorrectable read\n",
+               __func__);
        mtd->ecc_stats.failed--;
 
        /* Issue the LSB page recovery command */
@@ -1046,7 +1085,8 @@ static int onenand_mlc_read_ops_nolock(struct mtd_info *mtd, loff_t from,
        int ret = 0;
        int writesize = this->writesize;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_mlc_read_ops_nolock: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: from = 0x%08x, len = %i\n",
+             __func__, (unsigned int) from, (int) len);
 
        if (ops->mode == MTD_OOB_AUTO)
                oobsize = this->ecclayout->oobavail;
@@ -1057,7 +1097,8 @@ static int onenand_mlc_read_ops_nolock(struct mtd_info *mtd, loff_t from,
 
        /* Do not allow reads past end of device */
        if (from + len > mtd->size) {
-               printk(KERN_ERR "onenand_mlc_read_ops_nolock: Attempt read beyond end of device\n");
+               printk(KERN_ERR "%s: Attempt read beyond end of device\n",
+                       __func__);
                ops->retlen = 0;
                ops->oobretlen = 0;
                return -EINVAL;
@@ -1146,7 +1187,8 @@ static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from,
        int ret = 0, boundary = 0;
        int writesize = this->writesize;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_ops_nolock: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: from = 0x%08x, len = %i\n",
+                       __func__, (unsigned int) from, (int) len);
 
        if (ops->mode == MTD_OOB_AUTO)
                oobsize = this->ecclayout->oobavail;
@@ -1157,7 +1199,8 @@ static int onenand_read_ops_nolock(struct mtd_info *mtd, loff_t from,
 
        /* Do not allow reads past end of device */
        if ((from + len) > mtd->size) {
-               printk(KERN_ERR "onenand_read_ops_nolock: Attempt read beyond end of device\n");
+               printk(KERN_ERR "%s: Attempt read beyond end of device\n",
+                       __func__);
                ops->retlen = 0;
                ops->oobretlen = 0;
                return -EINVAL;
@@ -1275,7 +1318,8 @@ static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from,
 
        from += ops->ooboffs;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_read_oob_nolock: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len);
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: from = 0x%08x, len = %i\n",
+               __func__, (unsigned int) from, (int) len);
 
        /* Initialize return length value */
        ops->oobretlen = 0;
@@ -1288,7 +1332,8 @@ static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from,
        column = from & (mtd->oobsize - 1);
 
        if (unlikely(column >= oobsize)) {
-               printk(KERN_ERR "onenand_read_oob_nolock: Attempted to start read outside oob\n");
+               printk(KERN_ERR "%s: Attempted to start read outside oob\n",
+                       __func__);
                return -EINVAL;
        }
 
@@ -1296,7 +1341,8 @@ static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from,
        if (unlikely(from >= mtd->size ||
                     column + len > ((mtd->size >> this->page_shift) -
                                     (from >> this->page_shift)) * oobsize)) {
-               printk(KERN_ERR "onenand_read_oob_nolock: Attempted to read beyond end of device\n");
+               printk(KERN_ERR "%s: Attempted to read beyond end of device\n",
+                       __func__);
                return -EINVAL;
        }
 
@@ -1319,7 +1365,8 @@ static int onenand_read_oob_nolock(struct mtd_info *mtd, loff_t from,
                        ret = onenand_recover_lsb(mtd, from, ret);
 
                if (ret && ret != -EBADMSG) {
-                       printk(KERN_ERR "onenand_read_oob_nolock: read failed = 0x%x\n", ret);
+                       printk(KERN_ERR "%s: read failed = 0x%x\n",
+                               __func__, ret);
                        break;
                }
 
@@ -1450,20 +1497,21 @@ static int onenand_bbt_wait(struct mtd_info *mtd, int state)
        if (interrupt & ONENAND_INT_READ) {
                int ecc = onenand_read_ecc(this);
                if (ecc & ONENAND_ECC_2BIT_ALL) {
-                       printk(KERN_INFO "onenand_bbt_wait: ecc error = 0x%04x"
-                               ", controller error 0x%04x\n", ecc, ctrl);
+                       printk(KERN_WARNING "%s: ecc error = 0x%04x, "
+                               "controller error 0x%04x\n",
+                               __func__, ecc, ctrl);
                        return ONENAND_BBT_READ_ECC_ERROR;
                }
        } else {
-               printk(KERN_ERR "onenand_bbt_wait: read timeout!"
-                       "ctrl=0x%04x intr=0x%04x\n", ctrl, interrupt);
+               printk(KERN_ERR "%s: read timeout! ctrl=0x%04x intr=0x%04x\n",
+                       __func__, ctrl, interrupt);
                return ONENAND_BBT_READ_FATAL_ERROR;
        }
 
        /* Initial bad block case: 0x2400 or 0x0400 */
        if (ctrl & ONENAND_CTRL_ERROR) {
-               printk(KERN_DEBUG "onenand_bbt_wait: "
-                       "controller error = 0x%04x\n", ctrl);
+               printk(KERN_DEBUG "%s: controller error = 0x%04x\n",
+                       __func__, ctrl);
                return ONENAND_BBT_READ_ERROR;
        }
 
@@ -1487,14 +1535,16 @@ int onenand_bbt_read_oob(struct mtd_info *mtd, loff_t from,
        size_t len = ops->ooblen;
        u_char *buf = ops->oobbuf;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_bbt_read_oob: from = 0x%08x, len = %zi\n", (unsigned int) from, len);
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: from = 0x%08x, len = %zi\n",
+               __func__, (unsigned int) from, len);
 
        /* Initialize return value */
        ops->oobretlen = 0;
 
        /* Do not allow reads past end of device */
        if (unlikely((from + len) > mtd->size)) {
-               printk(KERN_ERR "onenand_bbt_read_oob: Attempt read beyond end of device\n");
+               printk(KERN_ERR "%s: Attempt read beyond end of device\n",
+                       __func__);
                return ONENAND_BBT_READ_FATAL_ERROR;
        }
 
@@ -1661,21 +1711,23 @@ static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
        /* Wait for any existing operation to clear */
        onenand_panic_wait(mtd);
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_panic_write: to = 0x%08x, len = %i\n",
-             (unsigned int) to, (int) len);
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: to = 0x%08x, len = %i\n",
+               __func__, (unsigned int) to, (int) len);
 
        /* Initialize retlen, in case of early exit */
        *retlen = 0;
 
        /* Do not allow writes past end of device */
        if (unlikely((to + len) > mtd->size)) {
-               printk(KERN_ERR "onenand_panic_write: Attempt write to past end of device\n");
+               printk(KERN_ERR "%s: Attempt write to past end of device\n",
+                       __func__);
                return -EINVAL;
        }
 
        /* Reject writes, which are not page aligned */
         if (unlikely(NOTALIGNED(to) || NOTALIGNED(len))) {
-                printk(KERN_ERR "onenand_panic_write: Attempt to write not page aligned data\n");
+               printk(KERN_ERR "%s: Attempt to write not page aligned data\n",
+                       __func__);
                 return -EINVAL;
         }
 
@@ -1711,7 +1763,7 @@ static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
                }
 
                if (ret) {
-                       printk(KERN_ERR "onenand_panic_write: write failed %d\n", ret);
+                       printk(KERN_ERR "%s: write failed %d\n", __func__, ret);
                        break;
                }
 
@@ -1792,7 +1844,8 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
        u_char *oobbuf;
        int ret = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_ops_nolock: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: to = 0x%08x, len = %i\n",
+               __func__, (unsigned int) to, (int) len);
 
        /* Initialize retlen, in case of early exit */
        ops->retlen = 0;
@@ -1800,13 +1853,15 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
 
        /* Do not allow writes past end of device */
        if (unlikely((to + len) > mtd->size)) {
-               printk(KERN_ERR "onenand_write_ops_nolock: Attempt write to past end of device\n");
+               printk(KERN_ERR "%s: Attempt write to past end of device\n",
+                       __func__);
                return -EINVAL;
        }
 
        /* Reject writes, which are not page aligned */
         if (unlikely(NOTALIGNED(to) || NOTALIGNED(len))) {
-                printk(KERN_ERR "onenand_write_ops_nolock: Attempt to write not page aligned data\n");
+               printk(KERN_ERR "%s: Attempt to write not page aligned data\n",
+                       __func__);
                 return -EINVAL;
         }
 
@@ -1879,7 +1934,8 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
                        onenand_update_bufferram(mtd, prev, !ret && !prev_subpage);
                        if (ret) {
                                written -= prevlen;
-                               printk(KERN_ERR "onenand_write_ops_nolock: write failed %d\n", ret);
+                               printk(KERN_ERR "%s: write failed %d\n",
+                                       __func__, ret);
                                break;
                        }
 
@@ -1887,7 +1943,8 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
                                /* Only check verify write turn on */
                                ret = onenand_verify(mtd, buf - len, to - len, len);
                                if (ret)
-                                       printk(KERN_ERR "onenand_write_ops_nolock: verify failed %d\n", ret);
+                                       printk(KERN_ERR "%s: verify failed %d\n",
+                                               __func__, ret);
                                break;
                        }
 
@@ -1905,14 +1962,16 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
                        /* In partial page write we don't update bufferram */
                        onenand_update_bufferram(mtd, to, !ret && !subpage);
                        if (ret) {
-                               printk(KERN_ERR "onenand_write_ops_nolock: write failed %d\n", ret);
+                               printk(KERN_ERR "%s: write failed %d\n",
+                                       __func__, ret);
                                break;
                        }
 
                        /* Only check verify write turn on */
                        ret = onenand_verify(mtd, buf, to, thislen);
                        if (ret) {
-                               printk(KERN_ERR "onenand_write_ops_nolock: verify failed %d\n", ret);
+                               printk(KERN_ERR "%s: verify failed %d\n",
+                                       __func__, ret);
                                break;
                        }
 
@@ -1968,7 +2027,8 @@ static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to,
 
        to += ops->ooboffs;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_write_oob_nolock: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len);
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: to = 0x%08x, len = %i\n",
+               __func__, (unsigned int) to, (int) len);
 
        /* Initialize retlen, in case of early exit */
        ops->oobretlen = 0;
@@ -1981,14 +2041,15 @@ static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to,
        column = to & (mtd->oobsize - 1);
 
        if (unlikely(column >= oobsize)) {
-               printk(KERN_ERR "onenand_write_oob_nolock: Attempted to start write outside oob\n");
+               printk(KERN_ERR "%s: Attempted to start write outside oob\n",
+                       __func__);
                return -EINVAL;
        }
 
        /* For compatibility with NAND: Do not allow write past end of page */
        if (unlikely(column + len > oobsize)) {
-               printk(KERN_ERR "onenand_write_oob_nolock: "
-                     "Attempt to write past end of page\n");
+               printk(KERN_ERR "%s: Attempt to write past end of page\n",
+                       __func__);
                return -EINVAL;
        }
 
@@ -1996,7 +2057,8 @@ static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to,
        if (unlikely(to >= mtd->size ||
                     column + len > ((mtd->size >> this->page_shift) -
                                     (to >> this->page_shift)) * oobsize)) {
-               printk(KERN_ERR "onenand_write_oob_nolock: Attempted to write past end of device\n");
+               printk(KERN_ERR "%s: Attempted to write past end of device\n",
+                      __func__);
                return -EINVAL;
        }
 
@@ -2038,13 +2100,14 @@ static int onenand_write_oob_nolock(struct mtd_info *mtd, loff_t to,
 
                ret = this->wait(mtd, FL_WRITING);
                if (ret) {
-                       printk(KERN_ERR "onenand_write_oob_nolock: write failed %d\n", ret);
+                       printk(KERN_ERR "%s: write failed %d\n", __func__, ret);
                        break;
                }
 
                ret = onenand_verify_oob(mtd, oobbuf, to);
                if (ret) {
-                       printk(KERN_ERR "onenand_write_oob_nolock: verify failed %d\n", ret);
+                       printk(KERN_ERR "%s: verify failed %d\n",
+                               __func__, ret);
                        break;
                }
 
@@ -2140,78 +2203,186 @@ static int onenand_block_isbad_nolock(struct mtd_info *mtd, loff_t ofs, int allo
        return bbm->isbad_bbt(mtd, ofs, allowbbt);
 }
 
+
+static int onenand_multiblock_erase_verify(struct mtd_info *mtd,
+                                          struct erase_info *instr)
+{
+       struct onenand_chip *this = mtd->priv;
+       loff_t addr = instr->addr;
+       int len = instr->len;
+       unsigned int block_size = (1 << this->erase_shift);
+       int ret = 0;
+
+       while (len) {
+               this->command(mtd, ONENAND_CMD_ERASE_VERIFY, addr, block_size);
+               ret = this->wait(mtd, FL_VERIFYING_ERASE);
+               if (ret) {
+                       printk(KERN_ERR "%s: Failed verify, block %d\n",
+                              __func__, onenand_block(this, addr));
+                       instr->state = MTD_ERASE_FAILED;
+                       instr->fail_addr = addr;
+                       return -1;
+               }
+               len -= block_size;
+               addr += block_size;
+       }
+       return 0;
+}
+
 /**
- * onenand_erase - [MTD Interface] erase block(s)
+ * onenand_multiblock_erase - [Internal] erase block(s) using multiblock erase
  * @param mtd          MTD device structure
  * @param instr                erase instruction
+ * @param region       erase region
  *
- * Erase one ore more blocks
+ * Erase one or more blocks up to 64 block at a time
  */
-static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
+static int onenand_multiblock_erase(struct mtd_info *mtd,
+                                   struct erase_info *instr,
+                                   unsigned int block_size)
 {
        struct onenand_chip *this = mtd->priv;
-       unsigned int block_size;
        loff_t addr = instr->addr;
-       loff_t len = instr->len;
-       int ret = 0, i;
-       struct mtd_erase_region_info *region = NULL;
-       loff_t region_end = 0;
+       int len = instr->len;
+       int eb_count = 0;
+       int ret = 0;
+       int bdry_block = 0;
 
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%012llx, len = %llu\n", (unsigned long long) instr->addr, (unsigned long long) instr->len);
+       instr->state = MTD_ERASING;
 
-       /* Do not allow erase past end of device */
-       if (unlikely((len + addr) > mtd->size)) {
-               printk(KERN_ERR "onenand_erase: Erase past end of device\n");
-               return -EINVAL;
+       if (ONENAND_IS_DDP(this)) {
+               loff_t bdry_addr = this->chipsize >> 1;
+               if (addr < bdry_addr && (addr + len) > bdry_addr)
+                       bdry_block = bdry_addr >> this->erase_shift;
        }
 
-       if (FLEXONENAND(this)) {
-               /* Find the eraseregion of this address */
-               i = flexonenand_region(mtd, addr);
-               region = &mtd->eraseregions[i];
+       /* Pre-check bbs */
+       while (len) {
+               /* Check if we have a bad block, we do not erase bad blocks */
+               if (onenand_block_isbad_nolock(mtd, addr, 0)) {
+                       printk(KERN_WARNING "%s: attempt to erase a bad block "
+                              "at addr 0x%012llx\n",
+                              __func__, (unsigned long long) addr);
+                       instr->state = MTD_ERASE_FAILED;
+                       return -EIO;
+               }
+               len -= block_size;
+               addr += block_size;
+       }
 
-               block_size = region->erasesize;
-               region_end = region->offset + region->erasesize * region->numblocks;
+       len = instr->len;
+       addr = instr->addr;
 
-               /* Start address within region must align on block boundary.
-                * Erase region's start offset is always block start address.
-                */
-               if (unlikely((addr - region->offset) & (block_size - 1))) {
-                       printk(KERN_ERR "onenand_erase: Unaligned address\n");
-                       return -EINVAL;
+       /* loop over 64 eb batches */
+       while (len) {
+               struct erase_info verify_instr = *instr;
+               int max_eb_count = MB_ERASE_MAX_BLK_COUNT;
+
+               verify_instr.addr = addr;
+               verify_instr.len = 0;
+
+               /* do not cross chip boundary */
+               if (bdry_block) {
+                       int this_block = (addr >> this->erase_shift);
+
+                       if (this_block < bdry_block) {
+                               max_eb_count = min(max_eb_count,
+                                                  (bdry_block - this_block));
+                       }
                }
-       } else {
-               block_size = 1 << this->erase_shift;
 
-               /* Start address must align on block boundary */
-               if (unlikely(addr & (block_size - 1))) {
-                       printk(KERN_ERR "onenand_erase: Unaligned address\n");
-                       return -EINVAL;
+               eb_count = 0;
+
+               while (len > block_size && eb_count < (max_eb_count - 1)) {
+                       this->command(mtd, ONENAND_CMD_MULTIBLOCK_ERASE,
+                                     addr, block_size);
+                       onenand_invalidate_bufferram(mtd, addr, block_size);
+
+                       ret = this->wait(mtd, FL_PREPARING_ERASE);
+                       if (ret) {
+                               printk(KERN_ERR "%s: Failed multiblock erase, "
+                                      "block %d\n", __func__,
+                                      onenand_block(this, addr));
+                               instr->state = MTD_ERASE_FAILED;
+                               instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
+                               return -EIO;
+                       }
+
+                       len -= block_size;
+                       addr += block_size;
+                       eb_count++;
+               }
+
+               /* last block of 64-eb series */
+               cond_resched();
+               this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
+               onenand_invalidate_bufferram(mtd, addr, block_size);
+
+               ret = this->wait(mtd, FL_ERASING);
+               /* Check if it is write protected */
+               if (ret) {
+                       printk(KERN_ERR "%s: Failed erase, block %d\n",
+                              __func__, onenand_block(this, addr));
+                       instr->state = MTD_ERASE_FAILED;
+                       instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
+                       return -EIO;
+               }
+
+               len -= block_size;
+               addr += block_size;
+               eb_count++;
+
+               /* verify */
+               verify_instr.len = eb_count * block_size;
+               if (onenand_multiblock_erase_verify(mtd, &verify_instr)) {
+                       instr->state = verify_instr.state;
+                       instr->fail_addr = verify_instr.fail_addr;
+                       return -EIO;
                }
-       }
 
-       /* Length must align on block boundary */
-       if (unlikely(len & (block_size - 1))) {
-               printk(KERN_ERR "onenand_erase: Length not block aligned\n");
-               return -EINVAL;
        }
+       return 0;
+}
 
-       instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
 
-       /* Grab the lock and see if the device is available */
-       onenand_get_device(mtd, FL_ERASING);
+/**
+ * onenand_block_by_block_erase - [Internal] erase block(s) using regular erase
+ * @param mtd          MTD device structure
+ * @param instr                erase instruction
+ * @param region       erase region
+ * @param block_size   erase block size
+ *
+ * Erase one or more blocks one block at a time
+ */
+static int onenand_block_by_block_erase(struct mtd_info *mtd,
+                                       struct erase_info *instr,
+                                       struct mtd_erase_region_info *region,
+                                       unsigned int block_size)
+{
+       struct onenand_chip *this = mtd->priv;
+       loff_t addr = instr->addr;
+       int len = instr->len;
+       loff_t region_end = 0;
+       int ret = 0;
+
+       if (region) {
+               /* region is set for Flex-OneNAND */
+               region_end = region->offset + region->erasesize * region->numblocks;
+       }
 
-       /* Loop through the blocks */
        instr->state = MTD_ERASING;
 
+       /* Loop through the blocks */
        while (len) {
                cond_resched();
 
                /* Check if we have a bad block, we do not erase bad blocks */
                if (onenand_block_isbad_nolock(mtd, addr, 0)) {
-                       printk (KERN_WARNING "onenand_erase: attempt to erase a bad block at addr 0x%012llx\n", (unsigned long long) addr);
+                       printk(KERN_WARNING "%s: attempt to erase a bad block "
+                                       "at addr 0x%012llx\n",
+                                       __func__, (unsigned long long) addr);
                        instr->state = MTD_ERASE_FAILED;
-                       goto erase_exit;
+                       return -EIO;
                }
 
                this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
@@ -2221,11 +2392,11 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
                ret = this->wait(mtd, FL_ERASING);
                /* Check, if it is write protected */
                if (ret) {
-                       printk(KERN_ERR "onenand_erase: Failed erase, block %d\n",
-                                                onenand_block(this, addr));
+                       printk(KERN_ERR "%s: Failed erase, block %d\n",
+                               __func__, onenand_block(this, addr));
                        instr->state = MTD_ERASE_FAILED;
                        instr->fail_addr = addr;
-                       goto erase_exit;
+                       return -EIO;
                }
 
                len -= block_size;
@@ -2241,25 +2412,88 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
 
                        if (len & (block_size - 1)) {
                                /* FIXME: This should be handled at MTD partitioning level. */
-                               printk(KERN_ERR "onenand_erase: Unaligned address\n");
-                               goto erase_exit;
+                               printk(KERN_ERR "%s: Unaligned address\n",
+                                       __func__);
+                               return -EIO;
                        }
                }
+       }
+       return 0;
+}
+
+/**
+ * onenand_erase - [MTD Interface] erase block(s)
+ * @param mtd          MTD device structure
+ * @param instr                erase instruction
+ *
+ * Erase one or more blocks
+ */
+static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
+{
+       struct onenand_chip *this = mtd->priv;
+       unsigned int block_size;
+       loff_t addr = instr->addr;
+       loff_t len = instr->len;
+       int ret = 0;
+       struct mtd_erase_region_info *region = NULL;
+       loff_t region_offset = 0;
+
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: start=0x%012llx, len=%llu\n", __func__,
+             (unsigned long long) instr->addr, (unsigned long long) instr->len);
+
+       /* Do not allow erase past end of device */
+       if (unlikely((len + addr) > mtd->size)) {
+               printk(KERN_ERR "%s: Erase past end of device\n", __func__);
+               return -EINVAL;
+       }
+
+       if (FLEXONENAND(this)) {
+               /* Find the eraseregion of this address */
+               int i = flexonenand_region(mtd, addr);
+
+               region = &mtd->eraseregions[i];
+               block_size = region->erasesize;
+
+               /* Start address within region must align on block boundary.
+                * Erase region's start offset is always block start address.
+                */
+               region_offset = region->offset;
+       } else
+               block_size = 1 << this->erase_shift;
+
+       /* Start address must align on block boundary */
+       if (unlikely((addr - region_offset) & (block_size - 1))) {
+               printk(KERN_ERR "%s: Unaligned address\n", __func__);
+               return -EINVAL;
+       }
 
+       /* Length must align on block boundary */
+       if (unlikely(len & (block_size - 1))) {
+               printk(KERN_ERR "%s: Length not block aligned\n", __func__);
+               return -EINVAL;
        }
 
-       instr->state = MTD_ERASE_DONE;
+       instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
 
-erase_exit:
+       /* Grab the lock and see if the device is available */
+       onenand_get_device(mtd, FL_ERASING);
 
-       ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
+       if (region || instr->len < MB_ERASE_MIN_BLK_COUNT * block_size) {
+               /* region is set for Flex-OneNAND (no mb erase) */
+               ret = onenand_block_by_block_erase(mtd, instr,
+                                                  region, block_size);
+       } else {
+               ret = onenand_multiblock_erase(mtd, instr, block_size);
+       }
 
        /* Deselect and wake up anyone waiting on the device */
        onenand_release_device(mtd);
 
        /* Do call back function */
-       if (!ret)
+       if (!ret) {
+               instr->state = MTD_ERASE_DONE;
                mtd_erase_callback(instr);
+       }
 
        return ret;
 }
@@ -2272,7 +2506,7 @@ erase_exit:
  */
 static void onenand_sync(struct mtd_info *mtd)
 {
-       DEBUG(MTD_DEBUG_LEVEL3, "onenand_sync: called\n");
+       DEBUG(MTD_DEBUG_LEVEL3, "%s: called\n", __func__);
 
        /* Grab the lock and see if the device is available */
        onenand_get_device(mtd, FL_SYNCING);
@@ -2406,7 +2640,8 @@ static int onenand_do_lock_cmd(struct mtd_info *mtd, loff_t ofs, size_t len, int
                /* Check lock status */
                status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
                if (!(status & wp_status_mask))
-                       printk(KERN_ERR "wp status = 0x%x\n", status);
+                       printk(KERN_ERR "%s: wp status = 0x%x\n",
+                               __func__, status);
 
                return 0;
        }
@@ -2435,7 +2670,8 @@ static int onenand_do_lock_cmd(struct mtd_info *mtd, loff_t ofs, size_t len, int
                /* Check lock status */
                status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
                if (!(status & wp_status_mask))
-                       printk(KERN_ERR "block = %d, wp status = 0x%x\n", block, status);
+                       printk(KERN_ERR "%s: block = %d, wp status = 0x%x\n",
+                               __func__, block, status);
        }
 
        return 0;
@@ -2502,7 +2738,8 @@ static int onenand_check_lock_status(struct onenand_chip *this)
                /* Check lock status */
                status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
                if (!(status & ONENAND_WP_US)) {
-                       printk(KERN_ERR "block = %d, wp status = 0x%x\n", block, status);
+                       printk(KERN_ERR "%s: block = %d, wp status = 0x%x\n",
+                               __func__, block, status);
                        return 0;
                }
        }
@@ -2557,6 +2794,208 @@ static void onenand_unlock_all(struct mtd_info *mtd)
 
 #ifdef CONFIG_MTD_ONENAND_OTP
 
+/**
+ * onenand_otp_command - Send OTP specific command to OneNAND device
+ * @param mtd   MTD device structure
+ * @param cmd   the command to be sent
+ * @param addr  offset to read from or write to
+ * @param len   number of bytes to read or write
+ */
+static int onenand_otp_command(struct mtd_info *mtd, int cmd, loff_t addr,
+                               size_t len)
+{
+       struct onenand_chip *this = mtd->priv;
+       int value, block, page;
+
+       /* Address translation */
+       switch (cmd) {
+       case ONENAND_CMD_OTP_ACCESS:
+               block = (int) (addr >> this->erase_shift);
+               page = -1;
+               break;
+
+       default:
+               block = (int) (addr >> this->erase_shift);
+               page = (int) (addr >> this->page_shift);
+
+               if (ONENAND_IS_2PLANE(this)) {
+                       /* Make the even block number */
+                       block &= ~1;
+                       /* Is it the odd plane? */
+                       if (addr & this->writesize)
+                               block++;
+                       page >>= 1;
+               }
+               page &= this->page_mask;
+               break;
+       }
+
+       if (block != -1) {
+               /* Write 'DFS, FBA' of Flash */
+               value = onenand_block_address(this, block);
+               this->write_word(value, this->base +
+                               ONENAND_REG_START_ADDRESS1);
+       }
+
+       if (page != -1) {
+               /* Now we use page size operation */
+               int sectors = 4, count = 4;
+               int dataram;
+
+               switch (cmd) {
+               default:
+                       if (ONENAND_IS_2PLANE(this) && cmd == ONENAND_CMD_PROG)
+                               cmd = ONENAND_CMD_2X_PROG;
+                       dataram = ONENAND_CURRENT_BUFFERRAM(this);
+                       break;
+               }
+
+               /* Write 'FPA, FSA' of Flash */
+               value = onenand_page_address(page, sectors);
+               this->write_word(value, this->base +
+                               ONENAND_REG_START_ADDRESS8);
+
+               /* Write 'BSA, BSC' of DataRAM */
+               value = onenand_buffer_address(dataram, sectors, count);
+               this->write_word(value, this->base + ONENAND_REG_START_BUFFER);
+       }
+
+       /* Interrupt clear */
+       this->write_word(ONENAND_INT_CLEAR, this->base + ONENAND_REG_INTERRUPT);
+
+       /* Write command */
+       this->write_word(cmd, this->base + ONENAND_REG_COMMAND);
+
+       return 0;
+}
+
+/**
+ * onenand_otp_write_oob_nolock - [Internal] OneNAND write out-of-band, specific to OTP
+ * @param mtd          MTD device structure
+ * @param to           offset to write to
+ * @param len          number of bytes to write
+ * @param retlen       pointer to variable to store the number of written bytes
+ * @param buf          the data to write
+ *
+ * OneNAND write out-of-band only for OTP
+ */
+static int onenand_otp_write_oob_nolock(struct mtd_info *mtd, loff_t to,
+                                   struct mtd_oob_ops *ops)
+{
+       struct onenand_chip *this = mtd->priv;
+       int column, ret = 0, oobsize;
+       int written = 0;
+       u_char *oobbuf;
+       size_t len = ops->ooblen;
+       const u_char *buf = ops->oobbuf;
+       int block, value, status;
+
+       to += ops->ooboffs;
+
+       /* Initialize retlen, in case of early exit */
+       ops->oobretlen = 0;
+
+       oobsize = mtd->oobsize;
+
+       column = to & (mtd->oobsize - 1);
+
+       oobbuf = this->oob_buf;
+
+       /* Loop until all data write */
+       while (written < len) {
+               int thislen = min_t(int, oobsize, len - written);
+
+               cond_resched();
+
+               block = (int) (to >> this->erase_shift);
+               /*
+                * Write 'DFS, FBA' of Flash
+                * Add: F100h DQ=DFS, FBA
+                */
+
+               value = onenand_block_address(this, block);
+               this->write_word(value, this->base +
+                               ONENAND_REG_START_ADDRESS1);
+
+               /*
+                * Select DataRAM for DDP
+                * Add: F101h DQ=DBS
+                */
+
+               value = onenand_bufferram_address(this, block);
+               this->write_word(value, this->base +
+                               ONENAND_REG_START_ADDRESS2);
+               ONENAND_SET_NEXT_BUFFERRAM(this);
+
+               /*
+                * Enter OTP access mode
+                */
+               this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
+               this->wait(mtd, FL_OTPING);
+
+               /* We send data to spare ram with oobsize
+                * to prevent byte access */
+               memcpy(oobbuf + column, buf, thislen);
+
+               /*
+                * Write Data into DataRAM
+                * Add: 8th Word
+                * in sector0/spare/page0
+                * DQ=XXFCh
+                */
+               this->write_bufferram(mtd, ONENAND_SPARERAM,
+                                       oobbuf, 0, mtd->oobsize);
+
+               onenand_otp_command(mtd, ONENAND_CMD_PROGOOB, to, mtd->oobsize);
+               onenand_update_bufferram(mtd, to, 0);
+               if (ONENAND_IS_2PLANE(this)) {
+                       ONENAND_SET_BUFFERRAM1(this);
+                       onenand_update_bufferram(mtd, to + this->writesize, 0);
+               }
+
+               ret = this->wait(mtd, FL_WRITING);
+               if (ret) {
+                       printk(KERN_ERR "%s: write failed %d\n", __func__, ret);
+                       break;
+               }
+
+               /* Exit OTP access mode */
+               this->command(mtd, ONENAND_CMD_RESET, 0, 0);
+               this->wait(mtd, FL_RESETING);
+
+               status = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
+               status &= 0x60;
+
+               if (status == 0x60) {
+                       printk(KERN_DEBUG "\nBLOCK\tSTATUS\n");
+                       printk(KERN_DEBUG "1st Block\tLOCKED\n");
+                       printk(KERN_DEBUG "OTP Block\tLOCKED\n");
+               } else if (status == 0x20) {
+                       printk(KERN_DEBUG "\nBLOCK\tSTATUS\n");
+                       printk(KERN_DEBUG "1st Block\tLOCKED\n");
+                       printk(KERN_DEBUG "OTP Block\tUN-LOCKED\n");
+               } else if (status == 0x40) {
+                       printk(KERN_DEBUG "\nBLOCK\tSTATUS\n");
+                       printk(KERN_DEBUG "1st Block\tUN-LOCKED\n");
+                       printk(KERN_DEBUG "OTP Block\tLOCKED\n");
+               } else {
+                       printk(KERN_DEBUG "Reboot to check\n");
+               }
+
+               written += thislen;
+               if (written == len)
+                       break;
+
+               to += mtd->writesize;
+               buf += thislen;
+               column = 0;
+       }
+
+       ops->oobretlen = written;
+
+       return ret;
+}
+
 /* Internal OTP operation */
 typedef int (*otp_op_t)(struct mtd_info *mtd, loff_t form, size_t len,
                size_t *retlen, u_char *buf);
@@ -2659,11 +3098,11 @@ static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len,
        struct mtd_oob_ops ops;
        int ret;
 
-       /* Enter OTP access mode */
-       this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
-       this->wait(mtd, FL_OTPING);
-
        if (FLEXONENAND(this)) {
+
+               /* Enter OTP access mode */
+               this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0);
+               this->wait(mtd, FL_OTPING);
                /*
                 * For Flex-OneNAND, we write lock mark to 1st word of sector 4 of
                 * main area of page 49.
@@ -2674,19 +3113,19 @@ static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len,
                ops.oobbuf = NULL;
                ret = onenand_write_ops_nolock(mtd, mtd->writesize * 49, &ops);
                *retlen = ops.retlen;
+
+               /* Exit OTP access mode */
+               this->command(mtd, ONENAND_CMD_RESET, 0, 0);
+               this->wait(mtd, FL_RESETING);
        } else {
                ops.mode = MTD_OOB_PLACE;
                ops.ooblen = len;
                ops.oobbuf = buf;
                ops.ooboffs = 0;
-               ret = onenand_write_oob_nolock(mtd, from, &ops);
+               ret = onenand_otp_write_oob_nolock(mtd, from, &ops);
                *retlen = ops.oobretlen;
        }
 
-       /* Exit OTP access mode */
-       this->command(mtd, ONENAND_CMD_RESET, 0, 0);
-       this->wait(mtd, FL_RESETING);
-
        return ret;
 }
 
@@ -2717,16 +3156,21 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
        if (density < ONENAND_DEVICE_DENSITY_512Mb)
                otp_pages = 20;
        else
-               otp_pages = 10;
+               otp_pages = 50;
 
        if (mode == MTD_OTP_FACTORY) {
                from += mtd->writesize * otp_pages;
-               otp_pages = 64 - otp_pages;
+               otp_pages = ONENAND_PAGES_PER_BLOCK - otp_pages;
        }
 
        /* Check User/Factory boundary */
-       if (((mtd->writesize * otp_pages) - (from + len)) < 0)
-               return 0;
+       if (mode == MTD_OTP_USER) {
+               if (mtd->writesize * otp_pages < from + len)
+                       return 0;
+       } else {
+               if (mtd->writesize * otp_pages <  len)
+                       return 0;
+       }
 
        onenand_get_device(mtd, FL_OTPING);
        while (len > 0 && otp_pages > 0) {
@@ -2749,13 +3193,12 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
                        *retlen += sizeof(struct otp_info);
                } else {
                        size_t tmp_retlen;
-                       int size = len;
 
                        ret = action(mtd, from, len, &tmp_retlen, buf);
 
-                       buf += size;
-                       len -= size;
-                       *retlen += size;
+                       buf += tmp_retlen;
+                       len -= tmp_retlen;
+                       *retlen += tmp_retlen;
 
                        if (ret)
                                break;
@@ -2868,20 +3311,10 @@ static int onenand_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
        u_char *buf = FLEXONENAND(this) ? this->page_buf : this->oob_buf;
        size_t retlen;
        int ret;
+       unsigned int otp_lock_offset = ONENAND_OTP_LOCK_OFFSET;
 
        memset(buf, 0xff, FLEXONENAND(this) ? this->writesize
                                                 : mtd->oobsize);
-       /*
-        * Note: OTP lock operation
-        *       OTP block : 0xXXFC
-        *       1st block : 0xXXF3 (If chip support)
-        *       Both      : 0xXXF0 (If chip support)
-        */
-       if (FLEXONENAND(this))
-               buf[FLEXONENAND_OTP_LOCK_OFFSET] = 0xFC;
-       else
-               buf[ONENAND_OTP_LOCK_OFFSET] = 0xFC;
-
        /*
         * Write lock mark to 8th word of sector0 of page0 of the spare0.
         * We write 16 bytes spare area instead of 2 bytes.
@@ -2892,10 +3325,30 @@ static int onenand_lock_user_prot_reg(struct mtd_info *mtd, loff_t from,
        from = 0;
        len = FLEXONENAND(this) ? mtd->writesize : 16;
 
+       /*
+        * Note: OTP lock operation
+        *       OTP block : 0xXXFC                     XX 1111 1100
+        *       1st block : 0xXXF3 (If chip support)   XX 1111 0011
+        *       Both      : 0xXXF0 (If chip support)   XX 1111 0000
+        */
+       if (FLEXONENAND(this))
+               otp_lock_offset = FLEXONENAND_OTP_LOCK_OFFSET;
+
+       /* ONENAND_OTP_AREA | ONENAND_OTP_BLOCK0 | ONENAND_OTP_AREA_BLOCK0 */
+       if (otp == 1)
+               buf[otp_lock_offset] = 0xFC;
+       else if (otp == 2)
+               buf[otp_lock_offset] = 0xF3;
+       else if (otp == 3)
+               buf[otp_lock_offset] = 0xF0;
+       else if (otp != 0)
+               printk(KERN_DEBUG "[OneNAND] Invalid option selected for OTP\n");
+
        ret = onenand_otp_walk(mtd, from, len, &retlen, buf, do_otp_lock, MTD_OTP_USER);
 
        return ret ? : retlen;
 }
+
 #endif /* CONFIG_MTD_ONENAND_OTP */
 
 /**
@@ -3172,7 +3625,8 @@ static int flexonenand_check_blocks_erased(struct mtd_info *mtd, int start, int
                                break;
 
                if (i != mtd->oobsize) {
-                       printk(KERN_WARNING "Block %d not erased.\n", block);
+                       printk(KERN_WARNING "%s: Block %d not erased.\n",
+                               __func__, block);
                        return 1;
                }
        }
@@ -3204,8 +3658,8 @@ int flexonenand_set_boundary(struct mtd_info *mtd, int die,
        blksperdie >>= ONENAND_IS_DDP(this) ? 1 : 0;
 
        if (boundary >= blksperdie) {
-               printk(KERN_ERR "flexonenand_set_boundary: Invalid boundary value. "
-                               "Boundary not changed.\n");
+               printk(KERN_ERR "%s: Invalid boundary value. "
+                               "Boundary not changed.\n", __func__);
                return -EINVAL;
        }
 
@@ -3214,7 +3668,8 @@ int flexonenand_set_boundary(struct mtd_info *mtd, int die,
        new = boundary + (die * this->density_mask);
        ret = flexonenand_check_blocks_erased(mtd, min(old, new) + 1, max(old, new));
        if (ret) {
-               printk(KERN_ERR "flexonenand_set_boundary: Please erase blocks before boundary change\n");
+               printk(KERN_ERR "%s: Please erase blocks "
+                               "before boundary change\n", __func__);
                return ret;
        }
 
@@ -3227,12 +3682,12 @@ int flexonenand_set_boundary(struct mtd_info *mtd, int die,
 
        thisboundary = this->read_word(this->base + ONENAND_DATARAM);
        if ((thisboundary >> FLEXONENAND_PI_UNLOCK_SHIFT) != 3) {
-               printk(KERN_ERR "flexonenand_set_boundary: boundary locked\n");
+               printk(KERN_ERR "%s: boundary locked\n", __func__);
                ret = 1;
                goto out;
        }
 
-       printk(KERN_INFO "flexonenand_set_boundary: Changing die %d boundary: %d%s\n",
+       printk(KERN_INFO "Changing die %d boundary: %d%s\n",
                        die, boundary, lock ? "(Locked)" : "(Unlocked)");
 
        addr = die ? this->diesize[0] : 0;
@@ -3243,7 +3698,8 @@ int flexonenand_set_boundary(struct mtd_info *mtd, int die,
        this->command(mtd, ONENAND_CMD_ERASE, addr, 0);
        ret = this->wait(mtd, FL_ERASING);
        if (ret) {
-               printk(KERN_ERR "flexonenand_set_boundary: Failed PI erase for Die %d\n", die);
+               printk(KERN_ERR "%s: Failed PI erase for Die %d\n",
+                      __func__, die);
                goto out;
        }
 
@@ -3251,7 +3707,8 @@ int flexonenand_set_boundary(struct mtd_info *mtd, int die,
        this->command(mtd, ONENAND_CMD_PROG, addr, 0);
        ret = this->wait(mtd, FL_WRITING);
        if (ret) {
-               printk(KERN_ERR "flexonenand_set_boundary: Failed PI write for Die %d\n", die);
+               printk(KERN_ERR "%s: Failed PI write for Die %d\n",
+                       __func__, die);
                goto out;
        }
 
@@ -3408,8 +3865,8 @@ static void onenand_resume(struct mtd_info *mtd)
        if (this->state == FL_PM_SUSPENDED)
                onenand_release_device(mtd);
        else
-               printk(KERN_ERR "resume() called for the chip which is not"
-                               "in suspended state\n");
+               printk(KERN_ERR "%s: resume() called for the chip which is not "
+                               "in suspended state\n", __func__);
 }
 
 /**
@@ -3464,7 +3921,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
        if (!this->page_buf) {
                this->page_buf = kzalloc(mtd->writesize, GFP_KERNEL);
                if (!this->page_buf) {
-                       printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n");
+                       printk(KERN_ERR "%s: Can't allocate page_buf\n",
+                               __func__);
                        return -ENOMEM;
                }
                this->options |= ONENAND_PAGEBUF_ALLOC;
@@ -3472,7 +3930,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
        if (!this->oob_buf) {
                this->oob_buf = kzalloc(mtd->oobsize, GFP_KERNEL);
                if (!this->oob_buf) {
-                       printk(KERN_ERR "onenand_scan(): Can't allocate oob_buf\n");
+                       printk(KERN_ERR "%s: Can't allocate oob_buf\n",
+                               __func__);
                        if (this->options & ONENAND_PAGEBUF_ALLOC) {
                                this->options &= ~ONENAND_PAGEBUF_ALLOC;
                                kfree(this->page_buf);
@@ -3505,8 +3964,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
                break;
 
        default:
-               printk(KERN_WARNING "No OOB scheme defined for oobsize %d\n",
-                       mtd->oobsize);
+               printk(KERN_WARNING "%s: No OOB scheme defined for oobsize %d\n",
+                       __func__, mtd->oobsize);
                mtd->subpage_sft = 0;
                /* To prevent kernel oops */
                this->ecclayout = &onenand_oob_32;
index c1d5013350063dde437ecce1e48949c897f34fae..b44dcab940d889346c4dfa3f22a8af348f32062c 100644 (file)
@@ -5,3 +5,4 @@ obj-$(CONFIG_MTD_TESTS) += mtd_speedtest.o
 obj-$(CONFIG_MTD_TESTS) += mtd_stresstest.o
 obj-$(CONFIG_MTD_TESTS) += mtd_subpagetest.o
 obj-$(CONFIG_MTD_TESTS) += mtd_torturetest.o
+obj-$(CONFIG_MTD_TESTS) += mtd_nandecctest.o
diff --git a/drivers/mtd/tests/mtd_nandecctest.c b/drivers/mtd/tests/mtd_nandecctest.c
new file mode 100644 (file)
index 0000000..c1f3105
--- /dev/null
@@ -0,0 +1,87 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+#include <linux/string.h>
+#include <linux/bitops.h>
+#include <linux/jiffies.h>
+#include <linux/mtd/nand_ecc.h>
+
+#if defined(CONFIG_MTD_NAND) || defined(CONFIG_MTD_NAND_MODULE)
+
+static void inject_single_bit_error(void *data, size_t size)
+{
+       unsigned long offset = random32() % (size * BITS_PER_BYTE);
+
+       __change_bit(offset, data);
+}
+
+static unsigned char data[512];
+static unsigned char error_data[512];
+
+static int nand_ecc_test(const size_t size)
+{
+       unsigned char code[3];
+       unsigned char error_code[3];
+       char testname[30];
+
+       BUG_ON(sizeof(data) < size);
+
+       sprintf(testname, "nand-ecc-%zu", size);
+
+       get_random_bytes(data, size);
+
+       memcpy(error_data, data, size);
+       inject_single_bit_error(error_data, size);
+
+       __nand_calculate_ecc(data, size, code);
+       __nand_calculate_ecc(error_data, size, error_code);
+       __nand_correct_data(error_data, code, error_code, size);
+
+       if (!memcmp(data, error_data, size)) {
+               printk(KERN_INFO "mtd_nandecctest: ok - %s\n", testname);
+               return 0;
+       }
+
+       printk(KERN_ERR "mtd_nandecctest: not ok - %s\n", testname);
+
+       printk(KERN_DEBUG "hexdump of data:\n");
+       print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
+                       data, size, false);
+       printk(KERN_DEBUG "hexdump of error data:\n");
+       print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
+                       error_data, size, false);
+
+       return -1;
+}
+
+#else
+
+static int nand_ecc_test(const size_t size)
+{
+       return 0;
+}
+
+#endif
+
+static int __init ecc_test_init(void)
+{
+       srandom32(jiffies);
+
+       nand_ecc_test(256);
+       nand_ecc_test(512);
+
+       return 0;
+}
+
+static void __exit ecc_test_exit(void)
+{
+}
+
+module_init(ecc_test_init);
+module_exit(ecc_test_exit);
+
+MODULE_DESCRIPTION("NAND ECC function test module");
+MODULE_AUTHOR("Akinobu Mita");
+MODULE_LICENSE("GPL");
index 5553cd4eab2083d80824f49e95423e1e2507a705..5813920e79a5f346278247de54990a03062e91c8 100644 (file)
@@ -343,7 +343,6 @@ static int scan_for_bad_eraseblocks(void)
                printk(PRINT_PREF "error: cannot allocate memory\n");
                return -ENOMEM;
        }
-       memset(bbt, 0 , ebcnt);
 
        printk(PRINT_PREF "scanning for bad eraseblocks\n");
        for (i = 0; i < ebcnt; ++i) {
@@ -392,7 +391,6 @@ static int __init mtd_oobtest_init(void)
               mtd->writesize, ebcnt, pgcnt, mtd->oobsize);
 
        err = -ENOMEM;
-       mtd->erasesize = mtd->erasesize;
        readbuf = kmalloc(mtd->erasesize, GFP_KERNEL);
        if (!readbuf) {
                printk(PRINT_PREF "error: cannot allocate memory\n");
@@ -476,18 +474,10 @@ static int __init mtd_oobtest_init(void)
        use_len_max = mtd->ecclayout->oobavail;
        vary_offset = 1;
        simple_srand(5);
-       printk(PRINT_PREF "writing OOBs of whole device\n");
-       for (i = 0; i < ebcnt; ++i) {
-               if (bbt[i])
-                       continue;
-               err = write_eraseblock(i);
-               if (err)
-                       goto out;
-               if (i % 256 == 0)
-                       printk(PRINT_PREF "written up to eraseblock %u\n", i);
-               cond_resched();
-       }
-       printk(PRINT_PREF "written %u eraseblocks\n", i);
+
+       err = write_whole_device();
+       if (err)
+               goto out;
 
        /* Check all eraseblocks */
        use_offset = 0;
index 103cac480feec2fbf622db0d4d65694cc611547a..ce17cbe918c5a1e4fe411a51eb7d92eafa22308e 100644 (file)
@@ -523,6 +523,7 @@ static int __init mtd_pagetest_init(void)
        do_div(tmp, mtd->erasesize);
        ebcnt = tmp;
        pgcnt = mtd->erasesize / mtd->writesize;
+       pgsize = mtd->writesize;
 
        printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
               "page size %u, count of eraseblocks %u, pages per "
index fbc231153e555f41b8c341670db078c8d7b21520..77cf0901a441146b99292755353d25bfd50222ae 100644 (file)
@@ -56,6 +56,7 @@ static const char version[] =
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/if_ether.h>
 #include <linux/skbuff.h>
 #include <linux/slab.h>
 #include <linux/init.h>
@@ -734,8 +735,7 @@ static void init_82586_mem(struct net_device *dev)
        memcpy_toio(lp->base, init_words + 5, sizeof(init_words) - 10);
 
        /* Fill in the station address. */
-       memcpy_toio(lp->base+SA_OFFSET, dev->dev_addr,
-                  sizeof(dev->dev_addr));
+       memcpy_toio(lp->base+SA_OFFSET, dev->dev_addr, ETH_ALEN);
 
        /* The Tx-block list is written as needed.  We just set up the values. */
        lp->tx_cmd_link = IDLELOOP + 4;
index 78b7167a8ce36f64e07a4f7fea6703e76d27d3df..39db0e96815dfba17d6dc8cab444a8181c06da71 100644 (file)
@@ -837,7 +837,7 @@ static int vortex_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops vortex_pm_ops = {
+static const struct dev_pm_ops vortex_pm_ops = {
        .suspend = vortex_suspend,
        .resume = vortex_resume,
        .freeze = vortex_suspend,
index a5be9ac6405cfa27fcc918ae888fadd487902f40..dd9a09c72dfff2b080f09499a4afe8d6b2ad68ad 100644 (file)
@@ -1953,6 +1953,8 @@ config BCM63XX_ENET
 
 source "drivers/net/fs_enet/Kconfig"
 
+source "drivers/net/octeon/Kconfig"
+
 endif # NET_ETHERNET
 
 #
@@ -2344,6 +2346,7 @@ config GELIC_NET
 
 config GELIC_WIRELESS
        bool "PS3 Wireless support"
+       depends on WLAN
        depends on GELIC_NET
        select WIRELESS_EXT
        help
@@ -2356,6 +2359,7 @@ config GELIC_WIRELESS
 config GELIC_WIRELESS_OLD_PSK_INTERFACE
        bool "PS3 Wireless private PSK interface (OBSOLETE)"
        depends on GELIC_WIRELESS
+       select WEXT_PRIV
        help
           This option retains the obsolete private interface to pass
           the PSK from user space programs to the driver.  The PSK
index 246323d7f16171cf475c76d07dcc4160248224e7..ad1346dd9da9e3e0f5a2558f1f0c1e8478a53fba 100644 (file)
@@ -285,3 +285,5 @@ obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
 obj-$(CONFIG_SFC) += sfc/
 
 obj-$(CONFIG_WIMAX) += wimax/
+
+obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/
index 1f6c5486d71593e1f3f1428a5e0dcc46a8a75e0a..0bd47d32ec425c531fac9468eaf297531e2140cc 100644 (file)
@@ -1245,9 +1245,15 @@ static void bcm_enet_get_drvinfo(struct net_device *netdev,
        drvinfo->n_stats = BCM_ENET_STATS_LEN;
 }
 
-static int bcm_enet_get_stats_count(struct net_device *netdev)
+static int bcm_enet_get_sset_count(struct net_device *netdev,
+                                       int string_set)
 {
-       return BCM_ENET_STATS_LEN;
+       switch (string_set) {
+       case ETH_SS_STATS:
+               return BCM_ENET_STATS_LEN;
+       default:
+               return -EINVAL;
+       }
 }
 
 static void bcm_enet_get_strings(struct net_device *netdev,
@@ -1473,7 +1479,7 @@ static int bcm_enet_set_pauseparam(struct net_device *dev,
 
 static struct ethtool_ops bcm_enet_ethtool_ops = {
        .get_strings            = bcm_enet_get_strings,
-       .get_stats_count        = bcm_enet_get_stats_count,
+       .get_sset_count         = bcm_enet_get_sset_count,
        .get_ethtool_stats      = bcm_enet_get_ethtool_stats,
        .get_settings           = bcm_enet_get_settings,
        .set_settings           = bcm_enet_set_settings,
index 9e56014d27edad57c88bb19f36eb05559f28c344..9fd8e5ecd5d75dcd81cf30827fd2257ba50d1284 100644 (file)
@@ -275,6 +275,7 @@ struct be_adapter {
        u32 tx_fc;              /* Tx flow control */
        int link_speed;
        u8 port_type;
+       u8 transceiver;
 };
 
 extern const struct ethtool_ops be_ethtool_ops;
index 1b68bd98dc0c1955dfc6c33b5bb00875835a6b06..102ade13416526066e3639519beaf4f497bc8830 100644 (file)
@@ -1479,6 +1479,41 @@ err:
        return status;
 }
 
+int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num,
+                       u8 loopback_type, u8 enable)
+{
+       struct be_mcc_wrb *wrb;
+       struct be_cmd_req_set_lmode *req;
+       int status;
+
+       spin_lock_bh(&adapter->mcc_lock);
+
+       wrb = wrb_from_mccq(adapter);
+       if (!wrb) {
+               status = -EBUSY;
+               goto err;
+       }
+
+       req = embedded_payload(wrb);
+
+       be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0,
+                               OPCODE_LOWLEVEL_SET_LOOPBACK_MODE);
+
+       be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL,
+                       OPCODE_LOWLEVEL_SET_LOOPBACK_MODE,
+                       sizeof(*req));
+
+       req->src_port = port_num;
+       req->dest_port = port_num;
+       req->loopback_type = loopback_type;
+       req->loopback_state = enable;
+
+       status = be_mcc_notify_wait(adapter);
+err:
+       spin_unlock_bh(&adapter->mcc_lock);
+       return status;
+}
+
 int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
                u32 loopback_type, u32 pkt_size, u32 num_pkts, u64 pattern)
 {
@@ -1501,6 +1536,7 @@ int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
 
        be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL,
                        OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req));
+       req->hdr.timeout = 4;
 
        req->pattern = cpu_to_le64(pattern);
        req->src_port = cpu_to_le32(port_num);
index 92b87ef156ed912f8ff998cb3c7db7135aa8b6af..c002b8391b4dc18c24e0a6e4b48a8e39ff9549b1 100644 (file)
@@ -155,6 +155,7 @@ struct be_mcc_mailbox {
 
 #define OPCODE_LOWLEVEL_HOST_DDR_DMA                    17
 #define OPCODE_LOWLEVEL_LOOPBACK_TEST                   18
+#define OPCODE_LOWLEVEL_SET_LOOPBACK_MODE              19
 
 struct be_cmd_req_hdr {
        u8 opcode;              /* dword 0 */
@@ -821,6 +822,19 @@ struct be_cmd_resp_loopback_test {
        u32    ticks_compl;
 };
 
+struct be_cmd_req_set_lmode {
+       struct be_cmd_req_hdr hdr;
+       u8 src_port;
+       u8 dest_port;
+       u8 loopback_type;
+       u8 loopback_state;
+};
+
+struct be_cmd_resp_set_lmode {
+       struct be_cmd_resp_hdr resp_hdr;
+       u8 rsvd0[4];
+};
+
 /********************** DDR DMA test *********************/
 struct be_cmd_req_ddrdma_test {
        struct be_cmd_req_hdr hdr;
@@ -912,3 +926,5 @@ extern int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
                                u32 num_pkts, u64 pattern);
 extern int be_cmd_ddr_dma_test(struct be_adapter *adapter, u64 pattern,
                        u32 byte_cnt, struct be_dma_mem *cmd);
+extern int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num,
+                               u8 loopback_type, u8 enable);
index 298b92cbd68948e3d54893a7e8f11885bda7c01c..5d001c4deac1d3b8684c91261cb0c15769c96cfa 100644 (file)
@@ -118,6 +118,7 @@ static const char et_self_tests[][ETH_GSTRING_LEN] = {
 #define BE_MAC_LOOPBACK 0x0
 #define BE_PHY_LOOPBACK 0x1
 #define BE_ONE_PORT_EXT_LOOPBACK 0x2
+#define BE_NO_LOOPBACK 0xff
 
 static void
 be_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
@@ -339,28 +340,50 @@ static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 
                status = be_cmd_read_port_type(adapter, adapter->port_num,
                                                &connector);
-               switch (connector) {
-               case 7:
-                       ecmd->port = PORT_FIBRE;
-                       break;
-               default:
-                       ecmd->port = PORT_TP;
-                       break;
+               if (!status) {
+                       switch (connector) {
+                       case 7:
+                               ecmd->port = PORT_FIBRE;
+                               ecmd->transceiver = XCVR_EXTERNAL;
+                               break;
+                       case 0:
+                               ecmd->port = PORT_TP;
+                               ecmd->transceiver = XCVR_EXTERNAL;
+                               break;
+                       default:
+                               ecmd->port = PORT_TP;
+                               ecmd->transceiver = XCVR_INTERNAL;
+                               break;
+                       }
+               } else {
+                       ecmd->port = PORT_AUI;
+                       ecmd->transceiver = XCVR_INTERNAL;
                }
 
                /* Save for future use */
                adapter->link_speed = ecmd->speed;
                adapter->port_type = ecmd->port;
+               adapter->transceiver = ecmd->transceiver;
        } else {
                ecmd->speed = adapter->link_speed;
                ecmd->port = adapter->port_type;
+               ecmd->transceiver = adapter->transceiver;
        }
 
        ecmd->duplex = DUPLEX_FULL;
        ecmd->autoneg = AUTONEG_DISABLE;
-       ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_TP);
        ecmd->phy_address = adapter->port_num;
-       ecmd->transceiver = XCVR_INTERNAL;
+       switch (ecmd->port) {
+       case PORT_FIBRE:
+               ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
+               break;
+       case PORT_TP:
+               ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_TP);
+               break;
+       case PORT_AUI:
+               ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_AUI);
+               break;
+       }
 
        return 0;
 }
@@ -489,6 +512,19 @@ err:
        return ret;
 }
 
+static u64 be_loopback_test(struct be_adapter *adapter, u8 loopback_type,
+                               u64 *status)
+{
+       be_cmd_set_loopback(adapter, adapter->port_num,
+                               loopback_type, 1);
+       *status = be_cmd_loopback_test(adapter, adapter->port_num,
+                               loopback_type, 1500,
+                               2, 0xabc);
+       be_cmd_set_loopback(adapter, adapter->port_num,
+                               BE_NO_LOOPBACK, 1);
+       return *status;
+}
+
 static void
 be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
 {
@@ -497,23 +533,18 @@ be_self_test(struct net_device *netdev, struct ethtool_test *test, u64 *data)
        memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM);
 
        if (test->flags & ETH_TEST_FL_OFFLINE) {
-               data[0] = be_cmd_loopback_test(adapter, adapter->port_num,
-                                               BE_MAC_LOOPBACK, 1500,
-                                               2, 0xabc);
-               if (data[0] != 0)
+               if (be_loopback_test(adapter, BE_MAC_LOOPBACK,
+                                               &data[0]) != 0) {
                        test->flags |= ETH_TEST_FL_FAILED;
-
-               data[1] = be_cmd_loopback_test(adapter, adapter->port_num,
-                                               BE_PHY_LOOPBACK, 1500,
-                                               2, 0xabc);
-               if (data[1] != 0)
+               }
+               if (be_loopback_test(adapter, BE_PHY_LOOPBACK,
+                                               &data[1]) != 0) {
                        test->flags |= ETH_TEST_FL_FAILED;
-
-               data[2] = be_cmd_loopback_test(adapter, adapter->port_num,
-                                               BE_ONE_PORT_EXT_LOOPBACK,
-                                               1500, 2, 0xabc);
-               if (data[2] != 0)
+               }
+               if (be_loopback_test(adapter, BE_ONE_PORT_EXT_LOOPBACK,
+                                               &data[2]) != 0) {
                        test->flags |= ETH_TEST_FL_FAILED;
+               }
 
                data[3] = be_test_ddr_dma(adapter);
                if (data[3] != 0)
index 4bfc8081292649114cf6bc8de011f8cf4b54797a..65df1de447e4d8db176ee14ea8605b4ccac09be4 100644 (file)
@@ -653,12 +653,20 @@ static void
 bnx2_netif_stop(struct bnx2 *bp)
 {
        bnx2_cnic_stop(bp);
-       bnx2_disable_int_sync(bp);
        if (netif_running(bp->dev)) {
+               int i;
+
                bnx2_napi_disable(bp);
                netif_tx_disable(bp->dev);
-               bp->dev->trans_start = jiffies; /* prevent tx timeout */
+               /* prevent tx timeout */
+               for (i = 0; i <  bp->dev->num_tx_queues; i++) {
+                       struct netdev_queue *txq;
+
+                       txq = netdev_get_tx_queue(bp->dev, i);
+                       txq->trans_start = jiffies;
+               }
        }
+       bnx2_disable_int_sync(bp);
 }
 
 static void
index 77ba13520d87ae539854da167551892655b3ec3d..306c2b8165e242c8400d6b416de9cc201540484a 100644 (file)
@@ -7593,6 +7593,8 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
                if (bp->cnic_eth_dev.drv_state & CNIC_DRV_STATE_REGD) {
                        bnx2x_set_iscsi_eth_mac_addr(bp, 1);
                        bp->cnic_flags |= BNX2X_CNIC_FLAG_MAC_SET;
+                       bnx2x_init_sb(bp, bp->cnic_sb, bp->cnic_sb_mapping,
+                                     CNIC_SB_ID(bp));
                }
                mutex_unlock(&bp->cnic_mutex);
 #endif
index d69e6838f21ee4e9931e99d7c908ad43eae51bc4..822f586d72afa67d8abd5c606f38b11f60f0147d 100644 (file)
@@ -20,6 +20,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/skbuff.h>
 #include <linux/if_ether.h>
 #include <linux/netdevice.h>
@@ -352,7 +354,8 @@ static u16 __get_link_speed(struct port *port)
                }
        }
 
-       pr_debug("Port %d Received link speed %d update from adapter\n", port->actor_port_number, speed);
+       pr_debug("Port %d Received link speed %d update from adapter\n",
+                port->actor_port_number, speed);
        return speed;
 }
 
@@ -378,12 +381,14 @@ static u8 __get_duplex(struct port *port)
                switch (slave->duplex) {
                case DUPLEX_FULL:
                        retval=0x1;
-                       pr_debug("Port %d Received status full duplex update from adapter\n", port->actor_port_number);
+                       pr_debug("Port %d Received status full duplex update from adapter\n",
+                                port->actor_port_number);
                        break;
                case DUPLEX_HALF:
                default:
                        retval=0x0;
-                       pr_debug("Port %d Received status NOT full duplex update from adapter\n", port->actor_port_number);
+                       pr_debug("Port %d Received status NOT full duplex update from adapter\n",
+                                port->actor_port_number);
                        break;
                }
        }
@@ -980,7 +985,9 @@ static void ad_mux_machine(struct port *port)
 
        // check if the state machine was changed
        if (port->sm_mux_state != last_state) {
-               pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_mux_state);
+               pr_debug("Mux Machine: Port=%d, Last State=%d, Curr State=%d\n",
+                        port->actor_port_number, last_state,
+                        port->sm_mux_state);
                switch (port->sm_mux_state) {
                case AD_MUX_DETACHED:
                        __detach_bond_from_agg(port);
@@ -1079,7 +1086,9 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
 
        // check if the State machine was changed or new lacpdu arrived
        if ((port->sm_rx_state != last_state) || (lacpdu)) {
-               pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_rx_state);
+               pr_debug("Rx Machine: Port=%d, Last State=%d, Curr State=%d\n",
+                        port->actor_port_number, last_state,
+                        port->sm_rx_state);
                switch (port->sm_rx_state) {
                case AD_RX_INITIALIZE:
                        if (!(port->actor_oper_port_key & AD_DUPLEX_KEY_BITS)) {
@@ -1126,9 +1135,8 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
                        // detect loopback situation
                        if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
                                // INFO_RECEIVED_LOOPBACK_FRAMES
-                               pr_err(DRV_NAME ": %s: An illegal loopback occurred on "
-                                      "adapter (%s). Check the configuration to verify that all "
-                                      "Adapters are connected to 802.3ad compliant switch ports\n",
+                               pr_err("%s: An illegal loopback occurred on adapter (%s).\n"
+                                      "Check the configuration to verify that all adapters are connected to 802.3ad compliant switch ports\n",
                                       port->slave->dev->master->name, port->slave->dev->name);
                                __release_rx_machine_lock(port);
                                return;
@@ -1166,7 +1174,8 @@ static void ad_tx_machine(struct port *port)
                        __update_lacpdu_from_port(port);
 
                        if (ad_lacpdu_send(port) >= 0) {
-                               pr_debug("Sent LACPDU on port %d\n", port->actor_port_number);
+                               pr_debug("Sent LACPDU on port %d\n",
+                                        port->actor_port_number);
 
                                /* mark ntt as false, so it will not be sent again until
                                   demanded */
@@ -1241,7 +1250,9 @@ static void ad_periodic_machine(struct port *port)
 
        // check if the state machine was changed
        if (port->sm_periodic_state != last_state) {
-               pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n", port->actor_port_number, last_state, port->sm_periodic_state);
+               pr_debug("Periodic Machine: Port=%d, Last State=%d, Curr State=%d\n",
+                        port->actor_port_number, last_state,
+                        port->sm_periodic_state);
                switch (port->sm_periodic_state) {
                case AD_NO_PERIODIC:
                        port->sm_periodic_timer_counter = 0;       // zero timer
@@ -1298,7 +1309,9 @@ static void ad_port_selection_logic(struct port *port)
                                port->next_port_in_aggregator=NULL;
                                port->actor_port_aggregator_identifier=0;
 
-                               pr_debug("Port %d left LAG %d\n", port->actor_port_number, temp_aggregator->aggregator_identifier);
+                               pr_debug("Port %d left LAG %d\n",
+                                        port->actor_port_number,
+                                        temp_aggregator->aggregator_identifier);
                                // if the aggregator is empty, clear its parameters, and set it ready to be attached
                                if (!temp_aggregator->lag_ports) {
                                        ad_clear_agg(temp_aggregator);
@@ -1307,9 +1320,7 @@ static void ad_port_selection_logic(struct port *port)
                        }
                }
                if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
-                       pr_warning(DRV_NAME ": %s: Warning: Port %d (on %s) "
-                                  "was related to aggregator %d but was not "
-                                  "on its port list\n",
+                       pr_warning("%s: Warning: Port %d (on %s) was related to aggregator %d but was not on its port list\n",
                                   port->slave->dev->master->name,
                                   port->actor_port_number,
                                   port->slave->dev->name,
@@ -1343,7 +1354,9 @@ static void ad_port_selection_logic(struct port *port)
                        port->next_port_in_aggregator=aggregator->lag_ports;
                        port->aggregator->num_of_ports++;
                        aggregator->lag_ports=port;
-                       pr_debug("Port %d joined LAG %d(existing LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier);
+                       pr_debug("Port %d joined LAG %d(existing LAG)\n",
+                                port->actor_port_number,
+                                port->aggregator->aggregator_identifier);
 
                        // mark this port as selected
                        port->sm_vars |= AD_PORT_SELECTED;
@@ -1380,10 +1393,11 @@ static void ad_port_selection_logic(struct port *port)
                        // mark this port as selected
                        port->sm_vars |= AD_PORT_SELECTED;
 
-                       pr_debug("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier);
+                       pr_debug("Port %d joined LAG %d(new LAG)\n",
+                                port->actor_port_number,
+                                port->aggregator->aggregator_identifier);
                } else {
-                       pr_err(DRV_NAME ": %s: Port %d (on %s) did not find "
-                              "a suitable aggregator\n",
+                       pr_err("%s: Port %d (on %s) did not find a suitable aggregator\n",
                               port->slave->dev->master->name,
                               port->actor_port_number, port->slave->dev->name);
                }
@@ -1460,8 +1474,7 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
                break;
 
        default:
-               pr_warning(DRV_NAME
-                          ": %s: Impossible agg select mode %d\n",
+               pr_warning("%s: Impossible agg select mode %d\n",
                           curr->slave->dev->master->name,
                           __get_agg_selection_mode(curr->lag_ports));
                break;
@@ -1546,40 +1559,38 @@ static void ad_agg_selection_logic(struct aggregator *agg)
        // if there is new best aggregator, activate it
        if (best) {
                pr_debug("best Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
-                      best->aggregator_identifier, best->num_of_ports,
-                      best->actor_oper_aggregator_key,
-                      best->partner_oper_aggregator_key,
-                      best->is_individual, best->is_active);
+                        best->aggregator_identifier, best->num_of_ports,
+                        best->actor_oper_aggregator_key,
+                        best->partner_oper_aggregator_key,
+                        best->is_individual, best->is_active);
                pr_debug("best ports %p slave %p %s\n",
-                      best->lag_ports, best->slave,
-                      best->slave ? best->slave->dev->name : "NULL");
+                        best->lag_ports, best->slave,
+                        best->slave ? best->slave->dev->name : "NULL");
 
                for (agg = __get_first_agg(best->lag_ports); agg;
                     agg = __get_next_agg(agg)) {
 
                        pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
-                               agg->aggregator_identifier, agg->num_of_ports,
-                               agg->actor_oper_aggregator_key,
-                               agg->partner_oper_aggregator_key,
-                               agg->is_individual, agg->is_active);
+                                agg->aggregator_identifier, agg->num_of_ports,
+                                agg->actor_oper_aggregator_key,
+                                agg->partner_oper_aggregator_key,
+                                agg->is_individual, agg->is_active);
                }
 
                // check if any partner replys
                if (best->is_individual) {
-                       pr_warning(DRV_NAME ": %s: Warning: No 802.3ad"
-                              " response from the link partner for any"
-                              " adapters in the bond\n",
-                              best->slave->dev->master->name);
+                       pr_warning("%s: Warning: No 802.3ad response from the link partner for any adapters in the bond\n",
+                                  best->slave ? best->slave->dev->master->name : "NULL");
                }
 
                best->is_active = 1;
                pr_debug("LAG %d chosen as the active LAG\n",
-                       best->aggregator_identifier);
+                        best->aggregator_identifier);
                pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n",
-                       best->aggregator_identifier, best->num_of_ports,
-                       best->actor_oper_aggregator_key,
-                       best->partner_oper_aggregator_key,
-                       best->is_individual, best->is_active);
+                        best->aggregator_identifier, best->num_of_ports,
+                        best->actor_oper_aggregator_key,
+                        best->partner_oper_aggregator_key,
+                        best->is_individual, best->is_active);
 
                // disable the ports that were related to the former active_aggregator
                if (active) {
@@ -1633,7 +1644,8 @@ static void ad_clear_agg(struct aggregator *aggregator)
                aggregator->lag_ports = NULL;
                aggregator->is_active = 0;
                aggregator->num_of_ports = 0;
-               pr_debug("LAG %d was cleared\n", aggregator->aggregator_identifier);
+               pr_debug("LAG %d was cleared\n",
+                        aggregator->aggregator_identifier);
        }
 }
 
@@ -1728,7 +1740,9 @@ static void ad_initialize_port(struct port *port, int lacp_fast)
 static void ad_enable_collecting_distributing(struct port *port)
 {
        if (port->aggregator->is_active) {
-               pr_debug("Enabling port %d(LAG %d)\n", port->actor_port_number, port->aggregator->aggregator_identifier);
+               pr_debug("Enabling port %d(LAG %d)\n",
+                        port->actor_port_number,
+                        port->aggregator->aggregator_identifier);
                __enable_port(port);
        }
 }
@@ -1741,7 +1755,9 @@ static void ad_enable_collecting_distributing(struct port *port)
 static void ad_disable_collecting_distributing(struct port *port)
 {
        if (port->aggregator && MAC_ADDRESS_COMPARE(&(port->aggregator->partner_system), &(null_mac_addr))) {
-               pr_debug("Disabling port %d(LAG %d)\n", port->actor_port_number, port->aggregator->aggregator_identifier);
+               pr_debug("Disabling port %d(LAG %d)\n",
+                        port->actor_port_number,
+                        port->aggregator->aggregator_identifier);
                __disable_port(port);
        }
 }
@@ -1779,7 +1795,8 @@ static void ad_marker_info_send(struct port *port)
 
        // send the marker information
        if (ad_marker_send(port, &marker) >= 0) {
-               pr_debug("Sent Marker Information on port %d\n", port->actor_port_number);
+               pr_debug("Sent Marker Information on port %d\n",
+                        port->actor_port_number);
        }
 }
 #endif
@@ -1803,7 +1820,8 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
        // send the marker response
 
        if (ad_marker_send(port, &marker) >= 0) {
-               pr_debug("Sent Marker Response on port %d\n", port->actor_port_number);
+               pr_debug("Sent Marker Response on port %d\n",
+                        port->actor_port_number);
        }
 }
 
@@ -1889,8 +1907,7 @@ int bond_3ad_bind_slave(struct slave *slave)
        struct aggregator *aggregator;
 
        if (bond == NULL) {
-               pr_err(DRV_NAME ": %s: The slave %s is not attached to "
-                      "its bond\n",
+               pr_err("%s: The slave %s is not attached to its bond\n",
                       slave->dev->master->name, slave->dev->name);
                return -1;
        }
@@ -1966,13 +1983,13 @@ void bond_3ad_unbind_slave(struct slave *slave)
 
        // if slave is null, the whole port is not initialized
        if (!port->slave) {
-               pr_warning(DRV_NAME ": Warning: %s: Trying to "
-                          "unbind an uninitialized port on %s\n",
+               pr_warning("Warning: %s: Trying to unbind an uninitialized port on %s\n",
                           slave->dev->master->name, slave->dev->name);
                return;
        }
 
-       pr_debug("Unbinding Link Aggregation Group %d\n", aggregator->aggregator_identifier);
+       pr_debug("Unbinding Link Aggregation Group %d\n",
+                aggregator->aggregator_identifier);
 
        /* Tell the partner that this port is not suitable for aggregation */
        port->actor_oper_port_state &= ~AD_STATE_AGGREGATION;
@@ -1996,10 +2013,12 @@ void bond_3ad_unbind_slave(struct slave *slave)
                        // if new aggregator found, copy the aggregator's parameters
                        // and connect the related lag_ports to the new aggregator
                        if ((new_aggregator) && ((!new_aggregator->lag_ports) || ((new_aggregator->lag_ports == port) && !new_aggregator->lag_ports->next_port_in_aggregator))) {
-                               pr_debug("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier);
+                               pr_debug("Some port(s) related to LAG %d - replaceing with LAG %d\n",
+                                        aggregator->aggregator_identifier,
+                                        new_aggregator->aggregator_identifier);
 
                                if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
-                                       pr_info(DRV_NAME ": %s: Removing an active aggregator\n",
+                                       pr_info("%s: Removing an active aggregator\n",
                                                aggregator->slave->dev->master->name);
                                        // select new active aggregator
                                         select_new_active_agg = 1;
@@ -2030,8 +2049,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
                                        ad_agg_selection_logic(__get_first_agg(port));
                                }
                        } else {
-                               pr_warning(DRV_NAME ": %s: Warning: unbinding aggregator, "
-                                          "and could not find a new aggregator for its ports\n",
+                               pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n",
                                           slave->dev->master->name);
                        }
                } else { // in case that the only port related to this aggregator is the one we want to remove
@@ -2039,7 +2057,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
                        // clear the aggregator
                        ad_clear_agg(aggregator);
                        if (select_new_active_agg) {
-                               pr_info(DRV_NAME ": %s: Removing an active aggregator\n",
+                               pr_info("%s: Removing an active aggregator\n",
                                        slave->dev->master->name);
                                // select new active aggregator
                                ad_agg_selection_logic(__get_first_agg(port));
@@ -2066,7 +2084,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
                                        // clear the aggregator
                                        ad_clear_agg(temp_aggregator);
                                        if (select_new_active_agg) {
-                                               pr_info(DRV_NAME ": %s: Removing an active aggregator\n",
+                                               pr_info("%s: Removing an active aggregator\n",
                                                        slave->dev->master->name);
                                                // select new active aggregator
                                                ad_agg_selection_logic(__get_first_agg(port));
@@ -2115,8 +2133,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
                // select the active aggregator for the bond
                if ((port = __get_first_port(bond))) {
                        if (!port->slave) {
-                               pr_warning(DRV_NAME ": %s: Warning: bond's first port is "
-                                          "uninitialized\n", bond->dev->name);
+                               pr_warning("%s: Warning: bond's first port is uninitialized\n",
+                                          bond->dev->name);
                                goto re_arm;
                        }
 
@@ -2129,8 +2147,8 @@ void bond_3ad_state_machine_handler(struct work_struct *work)
        // for each port run the state machines
        for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
                if (!port->slave) {
-                       pr_warning(DRV_NAME ": %s: Warning: Found an uninitialized "
-                                  "port\n", bond->dev->name);
+                       pr_warning("%s: Warning: Found an uninitialized port\n",
+                                  bond->dev->name);
                        goto re_arm;
                }
 
@@ -2171,15 +2189,15 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
                port = &(SLAVE_AD_INFO(slave).port);
 
                if (!port->slave) {
-                       pr_warning(DRV_NAME ": %s: Warning: port of slave %s "
-                                  "is uninitialized\n",
+                       pr_warning("%s: Warning: port of slave %s is uninitialized\n",
                                   slave->dev->name, slave->dev->master->name);
                        return;
                }
 
                switch (lacpdu->subtype) {
                case AD_TYPE_LACPDU:
-                       pr_debug("Received LACPDU on port %d\n", port->actor_port_number);
+                       pr_debug("Received LACPDU on port %d\n",
+                                port->actor_port_number);
                        ad_rx_machine(lacpdu, port);
                        break;
 
@@ -2188,17 +2206,20 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
 
                        switch (((struct bond_marker *)lacpdu)->tlv_type) {
                        case AD_MARKER_INFORMATION_SUBTYPE:
-                               pr_debug("Received Marker Information on port %d\n", port->actor_port_number);
+                               pr_debug("Received Marker Information on port %d\n",
+                                        port->actor_port_number);
                                ad_marker_info_received((struct bond_marker *)lacpdu, port);
                                break;
 
                        case AD_MARKER_RESPONSE_SUBTYPE:
-                               pr_debug("Received Marker Response on port %d\n", port->actor_port_number);
+                               pr_debug("Received Marker Response on port %d\n",
+                                        port->actor_port_number);
                                ad_marker_response_received((struct bond_marker *)lacpdu, port);
                                break;
 
                        default:
-                               pr_debug("Received an unknown Marker subtype on slot %d\n", port->actor_port_number);
+                               pr_debug("Received an unknown Marker subtype on slot %d\n",
+                                        port->actor_port_number);
                        }
                }
        }
@@ -2218,8 +2239,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
 
        // if slave is null, the whole port is not initialized
        if (!port->slave) {
-               pr_warning(DRV_NAME ": Warning: %s: speed "
-                          "changed for uninitialized port on %s\n",
+               pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
                           slave->dev->master->name, slave->dev->name);
                return;
        }
@@ -2246,8 +2266,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
 
        // if slave is null, the whole port is not initialized
        if (!port->slave) {
-               pr_warning(DRV_NAME ": %s: Warning: duplex changed "
-                          "for uninitialized port on %s\n",
+               pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
                           slave->dev->master->name, slave->dev->name);
                return;
        }
@@ -2275,8 +2294,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
 
        // if slave is null, the whole port is not initialized
        if (!port->slave) {
-               pr_warning(DRV_NAME ": Warning: %s: link status changed for "
-                          "uninitialized port on %s\n",
+               pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
                           slave->dev->master->name, slave->dev->name);
                return;
        }
@@ -2381,8 +2399,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
        }
 
        if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
-               pr_debug(DRV_NAME ": %s: Error: "
-                        "bond_3ad_get_active_agg_info failed\n", dev->name);
+               pr_debug("%s: Error: bond_3ad_get_active_agg_info failed\n",
+                        dev->name);
                goto out;
        }
 
@@ -2391,8 +2409,7 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
 
        if (slaves_in_agg == 0) {
                /*the aggregator is empty*/
-               pr_debug(DRV_NAME ": %s: Error: active aggregator is empty\n",
-                        dev->name);
+               pr_debug("%s: Error: active aggregator is empty\n", dev->name);
                goto out;
        }
 
@@ -2410,8 +2427,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
        }
 
        if (slave_agg_no >= 0) {
-               pr_err(DRV_NAME ": %s: Error: Couldn't find a slave to tx on "
-                      "for aggregator ID %d\n", dev->name, agg_id);
+               pr_err("%s: Error: Couldn't find a slave to tx on for aggregator ID %d\n",
+                      dev->name, agg_id);
                goto out;
        }
 
index 00ab51ef3129c835523bc2aefebbb076f7a89aa9..40fdc41446cc130f1363e9d4a17a9d3203b3166b 100644 (file)
@@ -20,6 +20,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -201,8 +203,7 @@ static int tlb_initialize(struct bonding *bond)
 
        new_hashtbl = kzalloc(size, GFP_KERNEL);
        if (!new_hashtbl) {
-               pr_err(DRV_NAME
-                      ": %s: Error: Failed to allocate TLB hash table\n",
+               pr_err("%s: Error: Failed to allocate TLB hash table\n",
                       bond->dev->name);
                return -1;
        }
@@ -514,8 +515,7 @@ static void rlb_update_client(struct rlb_client_info *client_info)
                                 client_info->slave->dev->dev_addr,
                                 client_info->mac_dst);
                if (!skb) {
-                       pr_err(DRV_NAME
-                              ": %s: Error: failed to create an ARP packet\n",
+                       pr_err("%s: Error: failed to create an ARP packet\n",
                               client_info->slave->dev->master->name);
                        continue;
                }
@@ -525,8 +525,7 @@ static void rlb_update_client(struct rlb_client_info *client_info)
                if (client_info->tag) {
                        skb = vlan_put_tag(skb, client_info->vlan_id);
                        if (!skb) {
-                               pr_err(DRV_NAME
-                                      ": %s: Error: failed to insert VLAN tag\n",
+                               pr_err("%s: Error: failed to insert VLAN tag\n",
                                       client_info->slave->dev->master->name);
                                continue;
                        }
@@ -609,9 +608,7 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, __be32 src_ip)
                client_info = &(bond_info->rx_hashtbl[hash_index]);
 
                if (!client_info->slave) {
-                       pr_err(DRV_NAME
-                              ": %s: Error: found a client with no channel in "
-                              "the client's hash table\n",
+                       pr_err("%s: Error: found a client with no channel in the client's hash table\n",
                               bond->dev->name);
                        continue;
                }
@@ -806,8 +803,7 @@ static int rlb_initialize(struct bonding *bond)
 
        new_hashtbl = kmalloc(size, GFP_KERNEL);
        if (!new_hashtbl) {
-               pr_err(DRV_NAME
-                      ": %s: Error: Failed to allocate RLB hash table\n",
+               pr_err("%s: Error: Failed to allocate RLB hash table\n",
                       bond->dev->name);
                return -1;
        }
@@ -928,8 +924,7 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
 
                        skb = vlan_put_tag(skb, vlan->vlan_id);
                        if (!skb) {
-                               pr_err(DRV_NAME
-                                      ": %s: Error: failed to insert VLAN tag\n",
+                               pr_err("%s: Error: failed to insert VLAN tag\n",
                                       bond->dev->name);
                                continue;
                        }
@@ -958,11 +953,8 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
        memcpy(s_addr.sa_data, addr, dev->addr_len);
        s_addr.sa_family = dev->type;
        if (dev_set_mac_address(dev, &s_addr)) {
-               pr_err(DRV_NAME
-                      ": %s: Error: dev_set_mac_address of dev %s failed! ALB "
-                      "mode requires that the base driver support setting "
-                      "the hw address also when the network device's "
-                      "interface is open\n",
+               pr_err("%s: Error: dev_set_mac_address of dev %s failed!\n"
+                      "ALB mode requires that the base driver support setting the hw address also when the network device's interface is open\n",
                       dev->master->name, dev->name);
                return -EOPNOTSUPP;
        }
@@ -1169,18 +1161,12 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
                alb_set_slave_mac_addr(slave, free_mac_slave->perm_hwaddr,
                                       bond->alb_info.rlb_enabled);
 
-               pr_warning(DRV_NAME
-                          ": %s: Warning: the hw address of slave %s is "
-                          "in use by the bond; giving it the hw address "
-                          "of %s\n",
+               pr_warning("%s: Warning: the hw address of slave %s is in use by the bond; giving it the hw address of %s\n",
                           bond->dev->name, slave->dev->name,
                           free_mac_slave->dev->name);
 
        } else if (has_bond_addr) {
-               pr_err(DRV_NAME
-                      ": %s: Error: the hw address of slave %s is in use by the "
-                      "bond; couldn't find a slave with a free hw address to "
-                      "give it (this should not have happened)\n",
+               pr_err("%s: Error: the hw address of slave %s is in use by the bond; couldn't find a slave with a free hw address to give it (this should not have happened)\n",
                       bond->dev->name, slave->dev->name);
                return -EFAULT;
        }
index b72e1dc8cf8fc9cf7722e093ad51900bdfc253db..6dd64cf3cb76889d3f5be1ffdd0db84d6b395196 100644 (file)
@@ -20,6 +20,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/types.h>
 #include <linux/if_vlan.h>
 #include <net/ipv6.h>
@@ -74,20 +76,20 @@ static void bond_na_send(struct net_device *slave_dev,
        addrconf_addr_solict_mult(daddr, &mcaddr);
 
        pr_debug("ipv6 na on slave %s: dest %pI6, src %pI6\n",
-              slave_dev->name, &mcaddr, daddr);
+                slave_dev->name, &mcaddr, daddr);
 
        skb = ndisc_build_skb(slave_dev, &mcaddr, daddr, &icmp6h, daddr,
                              ND_OPT_TARGET_LL_ADDR);
 
        if (!skb) {
-               pr_err(DRV_NAME ": NA packet allocation failed\n");
+               pr_err("NA packet allocation failed\n");
                return;
        }
 
        if (vlan_id) {
                skb = vlan_put_tag(skb, vlan_id);
                if (!skb) {
-                       pr_err(DRV_NAME ": failed to insert VLAN tag\n");
+                       pr_err("failed to insert VLAN tag\n");
                        return;
                }
        }
@@ -109,8 +111,8 @@ void bond_send_unsolicited_na(struct bonding *bond)
        struct inet6_dev *idev;
        int is_router;
 
-       pr_debug("bond_send_unsol_na: bond %s slave %s\n", bond->dev->name,
-                               slave ? slave->dev->name : "NULL");
+       pr_debug("%s: bond %s slave %s\n", bond->dev->name,
+                __func__, slave ? slave->dev->name : "NULL");
 
        if (!slave || !bond->send_unsol_na ||
            test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))
index af9b9c4eb496eb5d6200cca8bbf57cee36f23b10..3f0071cfe56b3a06c6f53e4ca29503393a4c5d94 100644 (file)
@@ -31,6 +31,8 @@
  *
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -260,7 +262,7 @@ static int bond_add_vlan(struct bonding *bond, unsigned short vlan_id)
        struct vlan_entry *vlan;
 
        pr_debug("bond: %s, vlan id %d\n",
-               (bond ? bond->dev->name : "None"), vlan_id);
+                (bond ? bond->dev->name : "None"), vlan_id);
 
        vlan = kzalloc(sizeof(struct vlan_entry), GFP_KERNEL);
        if (!vlan)
@@ -303,8 +305,8 @@ static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id)
                        if (bond_is_lb(bond))
                                bond_alb_clear_vlan(bond, vlan_id);
 
-                       pr_debug("removed VLAN ID %d from bond %s\n", vlan_id,
-                               bond->dev->name);
+                       pr_debug("removed VLAN ID %d from bond %s\n",
+                                vlan_id, bond->dev->name);
 
                        kfree(vlan);
 
@@ -323,8 +325,8 @@ static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id)
                }
        }
 
-       pr_debug("couldn't find VLAN ID %d in bond %s\n", vlan_id,
-               bond->dev->name);
+       pr_debug("couldn't find VLAN ID %d in bond %s\n",
+                vlan_id, bond->dev->name);
 
 out:
        write_unlock_bh(&bond->lock);
@@ -348,7 +350,7 @@ static int bond_has_challenged_slaves(struct bonding *bond)
        bond_for_each_slave(bond, slave, i) {
                if (slave->dev->features & NETIF_F_VLAN_CHALLENGED) {
                        pr_debug("found VLAN challenged slave - %s\n",
-                               slave->dev->name);
+                                slave->dev->name);
                        return 1;
                }
        }
@@ -499,8 +501,7 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
 
        res = bond_add_vlan(bond, vid);
        if (res) {
-               pr_err(DRV_NAME
-                      ": %s: Error: Failed to add vlan id %d\n",
+               pr_err("%s: Error: Failed to add vlan id %d\n",
                       bond_dev->name, vid);
        }
 }
@@ -534,8 +535,7 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
 
        res = bond_del_vlan(bond, vid);
        if (res) {
-               pr_err(DRV_NAME
-                      ": %s: Error: Failed to remove vlan id %d\n",
+               pr_err("%s: Error: Failed to remove vlan id %d\n",
                       bond_dev->name, vid);
        }
 }
@@ -1053,8 +1053,7 @@ static void bond_do_fail_over_mac(struct bonding *bond,
 
                rv = dev_set_mac_address(new_active->dev, &saddr);
                if (rv) {
-                       pr_err(DRV_NAME
-                              ": %s: Error %d setting MAC of slave %s\n",
+                       pr_err("%s: Error %d setting MAC of slave %s\n",
                               bond->dev->name, -rv, new_active->dev->name);
                        goto out;
                }
@@ -1067,16 +1066,14 @@ static void bond_do_fail_over_mac(struct bonding *bond,
 
                rv = dev_set_mac_address(old_active->dev, &saddr);
                if (rv)
-                       pr_err(DRV_NAME
-                              ": %s: Error %d setting MAC of slave %s\n",
+                       pr_err("%s: Error %d setting MAC of slave %s\n",
                               bond->dev->name, -rv, new_active->dev->name);
 out:
                read_lock(&bond->lock);
                write_lock_bh(&bond->curr_slave_lock);
                break;
        default:
-               pr_err(DRV_NAME
-                      ": %s: bond_do_fail_over_mac impossible: bad policy %d\n",
+               pr_err("%s: bond_do_fail_over_mac impossible: bad policy %d\n",
                       bond->dev->name, bond->params.fail_over_mac);
                break;
        }
@@ -1178,11 +1175,9 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
 
                if (new_active->link == BOND_LINK_BACK) {
                        if (USES_PRIMARY(bond->params.mode)) {
-                               pr_info(DRV_NAME
-                                      ": %s: making interface %s the new "
-                                      "active one %d ms earlier.\n",
-                                      bond->dev->name, new_active->dev->name,
-                                      (bond->params.updelay - new_active->delay) * bond->params.miimon);
+                               pr_info("%s: making interface %s the new active one %d ms earlier.\n",
+                                       bond->dev->name, new_active->dev->name,
+                                       (bond->params.updelay - new_active->delay) * bond->params.miimon);
                        }
 
                        new_active->delay = 0;
@@ -1195,10 +1190,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
                                bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP);
                } else {
                        if (USES_PRIMARY(bond->params.mode)) {
-                               pr_info(DRV_NAME
-                                      ": %s: making interface %s the new "
-                                      "active one.\n",
-                                      bond->dev->name, new_active->dev->name);
+                               pr_info("%s: making interface %s the new active one.\n",
+                                       bond->dev->name, new_active->dev->name);
                        }
                }
        }
@@ -1268,13 +1261,11 @@ void bond_select_active_slave(struct bonding *bond)
                        return;
 
                if (netif_carrier_ok(bond->dev)) {
-                       pr_info(DRV_NAME
-                              ": %s: first active interface up!\n",
-                              bond->dev->name);
+                       pr_info("%s: first active interface up!\n",
+                               bond->dev->name);
                } else {
-                       pr_info(DRV_NAME ": %s: "
-                              "now running without any active interface !\n",
-                              bond->dev->name);
+                       pr_info("%s: now running without any active interface !\n",
+                               bond->dev->name);
                }
        }
 }
@@ -1423,16 +1414,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 
        if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL &&
                slave_ops->ndo_do_ioctl == NULL) {
-               pr_warning(DRV_NAME
-                      ": %s: Warning: no link monitoring support for %s\n",
-                      bond_dev->name, slave_dev->name);
+               pr_warning("%s: Warning: no link monitoring support for %s\n",
+                          bond_dev->name, slave_dev->name);
        }
 
        /* bond must be initialized by bond_open() before enslaving */
        if (!(bond_dev->flags & IFF_UP)) {
-               pr_warning(DRV_NAME
-                       " %s: master_dev is not up in bond_enslave\n",
-                       bond_dev->name);
+               pr_warning("%s: master_dev is not up in bond_enslave\n",
+                          bond_dev->name);
        }
 
        /* already enslaved */
@@ -1446,19 +1435,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
        if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
                pr_debug("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name);
                if (!list_empty(&bond->vlan_list)) {
-                       pr_err(DRV_NAME
-                              ": %s: Error: cannot enslave VLAN "
-                              "challenged slave %s on VLAN enabled "
-                              "bond %s\n", bond_dev->name, slave_dev->name,
-                              bond_dev->name);
+                       pr_err("%s: Error: cannot enslave VLAN challenged slave %s on VLAN enabled bond %s\n",
+                              bond_dev->name, slave_dev->name, bond_dev->name);
                        return -EPERM;
                } else {
-                       pr_warning(DRV_NAME
-                              ": %s: Warning: enslaved VLAN challenged "
-                              "slave %s. Adding VLANs will be blocked as "
-                              "long as %s is part of bond %s\n",
-                              bond_dev->name, slave_dev->name, slave_dev->name,
-                              bond_dev->name);
+                       pr_warning("%s: Warning: enslaved VLAN challenged slave %s. Adding VLANs will be blocked as long as %s is part of bond %s\n",
+                                  bond_dev->name, slave_dev->name,
+                                  slave_dev->name, bond_dev->name);
                        bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
                }
        } else {
@@ -1478,8 +1461,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
         * enslaving it; the old ifenslave will not.
         */
        if ((slave_dev->flags & IFF_UP)) {
-               pr_err(DRV_NAME ": %s is up. "
-                      "This may be due to an out of date ifenslave.\n",
+               pr_err("%s is up. This may be due to an out of date ifenslave.\n",
                       slave_dev->name);
                res = -EPERM;
                goto err_undo_flags;
@@ -1495,7 +1477,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
        if (bond->slave_cnt == 0) {
                if (bond_dev->type != slave_dev->type) {
                        pr_debug("%s: change device type from %d to %d\n",
-                               bond_dev->name, bond_dev->type, slave_dev->type);
+                                bond_dev->name,
+                                bond_dev->type, slave_dev->type);
 
                        netdev_bonding_change(bond_dev, NETDEV_BONDING_OLDTYPE);
 
@@ -1507,28 +1490,21 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
                        netdev_bonding_change(bond_dev, NETDEV_BONDING_NEWTYPE);
                }
        } else if (bond_dev->type != slave_dev->type) {
-               pr_err(DRV_NAME ": %s ether type (%d) is different "
-                       "from other slaves (%d), can not enslave it.\n",
-                       slave_dev->name,
-                       slave_dev->type, bond_dev->type);
-                       res = -EINVAL;
-                       goto err_undo_flags;
+               pr_err("%s ether type (%d) is different from other slaves (%d), can not enslave it.\n",
+                      slave_dev->name,
+                      slave_dev->type, bond_dev->type);
+               res = -EINVAL;
+               goto err_undo_flags;
        }
 
        if (slave_ops->ndo_set_mac_address == NULL) {
                if (bond->slave_cnt == 0) {
-                       pr_warning(DRV_NAME
-                              ": %s: Warning: The first slave device "
-                              "specified does not support setting the MAC "
-                              "address. Setting fail_over_mac to active.",
-                              bond_dev->name);
+                       pr_warning("%s: Warning: The first slave device specified does not support setting the MAC address. Setting fail_over_mac to active.",
+                                  bond_dev->name);
                        bond->params.fail_over_mac = BOND_FOM_ACTIVE;
                } else if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) {
-                       pr_err(DRV_NAME
-                               ": %s: Error: The slave device specified "
-                               "does not support setting the MAC address, "
-                               "but fail_over_mac is not set to active.\n"
-                               , bond_dev->name);
+                       pr_err("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active.\n",
+                              bond_dev->name);
                        res = -EOPNOTSUPP;
                        goto err_undo_flags;
                }
@@ -1655,22 +1631,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
                         * supported); thus, we don't need to change
                         * the messages for netif_carrier.
                         */
-                       pr_warning(DRV_NAME
-                              ": %s: Warning: MII and ETHTOOL support not "
-                              "available for interface %s, and "
-                              "arp_interval/arp_ip_target module parameters "
-                              "not specified, thus bonding will not detect "
-                              "link failures! see bonding.txt for details.\n",
+                       pr_warning("%s: Warning: MII and ETHTOOL support not available for interface %s, and arp_interval/arp_ip_target module parameters not specified, thus bonding will not detect link failures! see bonding.txt for details.\n",
                               bond_dev->name, slave_dev->name);
                } else if (link_reporting == -1) {
                        /* unable get link status using mii/ethtool */
-                       pr_warning(DRV_NAME
-                              ": %s: Warning: can't get link status from "
-                              "interface %s; the network driver associated "
-                              "with this interface does not support MII or "
-                              "ETHTOOL link status reporting, thus miimon "
-                              "has no effect on this interface.\n",
-                              bond_dev->name, slave_dev->name);
+                       pr_warning("%s: Warning: can't get link status from interface %s; the network driver associated with this interface does not support MII or ETHTOOL link status reporting, thus miimon has no effect on this interface.\n",
+                                  bond_dev->name, slave_dev->name);
                }
        }
 
@@ -1678,34 +1644,27 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
        if (!bond->params.miimon ||
            (bond_check_dev_link(bond, slave_dev, 0) == BMSR_LSTATUS)) {
                if (bond->params.updelay) {
-                       pr_debug("Initial state of slave_dev is "
-                               "BOND_LINK_BACK\n");
+                       pr_debug("Initial state of slave_dev is BOND_LINK_BACK\n");
                        new_slave->link  = BOND_LINK_BACK;
                        new_slave->delay = bond->params.updelay;
                } else {
-                       pr_debug("Initial state of slave_dev is "
-                               "BOND_LINK_UP\n");
+                       pr_debug("Initial state of slave_dev is BOND_LINK_UP\n");
                        new_slave->link  = BOND_LINK_UP;
                }
                new_slave->jiffies = jiffies;
        } else {
-               pr_debug("Initial state of slave_dev is "
-                       "BOND_LINK_DOWN\n");
+               pr_debug("Initial state of slave_dev is BOND_LINK_DOWN\n");
                new_slave->link  = BOND_LINK_DOWN;
        }
 
        if (bond_update_speed_duplex(new_slave) &&
            (new_slave->link != BOND_LINK_DOWN)) {
-               pr_warning(DRV_NAME
-                      ": %s: Warning: failed to get speed and duplex from %s, "
-                      "assumed to be 100Mb/sec and Full.\n",
-                      bond_dev->name, new_slave->dev->name);
+               pr_warning("%s: Warning: failed to get speed and duplex from %s, assumed to be 100Mb/sec and Full.\n",
+                          bond_dev->name, new_slave->dev->name);
 
                if (bond->params.mode == BOND_MODE_8023AD) {
-                       pr_warning(DRV_NAME
-                              ": %s: Warning: Operation of 802.3ad mode requires ETHTOOL "
-                              "support in base driver for proper aggregator "
-                              "selection.\n", bond_dev->name);
+                       pr_warning("%s: Warning: Operation of 802.3ad mode requires ETHTOOL support in base driver for proper aggregator selection.\n",
+                                  bond_dev->name);
                }
        }
 
@@ -1777,11 +1736,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
        if (res)
                goto err_close;
 
-       pr_info(DRV_NAME
-              ": %s: enslaving %s as a%s interface with a%s link.\n",
-              bond_dev->name, slave_dev->name,
-              new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup",
-              new_slave->link != BOND_LINK_DOWN ? "n up" : " down");
+       pr_info("%s: enslaving %s as a%s interface with a%s link.\n",
+               bond_dev->name, slave_dev->name,
+               new_slave->state == BOND_STATE_ACTIVE ? "n active" : " backup",
+               new_slave->link != BOND_LINK_DOWN ? "n up" : " down");
 
        /* enslave is successful */
        return 0;
@@ -1833,8 +1791,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
        /* slave is not a slave or master is not master of this slave */
        if (!(slave_dev->flags & IFF_SLAVE) ||
            (slave_dev->master != bond_dev)) {
-               pr_err(DRV_NAME
-                      ": %s: Error: cannot release %s.\n",
+               pr_err("%s: Error: cannot release %s.\n",
                       bond_dev->name, slave_dev->name);
                return -EINVAL;
        }
@@ -1844,9 +1801,8 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
        slave = bond_get_slave_by_dev(bond, slave_dev);
        if (!slave) {
                /* not a slave of this bond */
-               pr_info(DRV_NAME
-                      ": %s: %s not enslaved\n",
-                      bond_dev->name, slave_dev->name);
+               pr_info("%s: %s not enslaved\n",
+                       bond_dev->name, slave_dev->name);
                write_unlock_bh(&bond->lock);
                return -EINVAL;
        }
@@ -1854,14 +1810,10 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
        if (!bond->params.fail_over_mac) {
                if (!compare_ether_addr(bond_dev->dev_addr, slave->perm_hwaddr) &&
                    bond->slave_cnt > 1)
-                       pr_warning(DRV_NAME
-                              ": %s: Warning: the permanent HWaddr of %s - "
-                              "%pM - is still in use by %s. "
-                              "Set the HWaddr of %s to a different address "
-                              "to avoid conflicts.\n",
-                              bond_dev->name, slave_dev->name,
-                              slave->perm_hwaddr,
-                              bond_dev->name, slave_dev->name);
+                       pr_warning("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s. Set the HWaddr of %s to a different address to avoid conflicts.\n",
+                                  bond_dev->name, slave_dev->name,
+                                  slave->perm_hwaddr,
+                                  bond_dev->name, slave_dev->name);
        }
 
        /* Inform AD package of unbinding of slave. */
@@ -1872,12 +1824,10 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
                bond_3ad_unbind_slave(slave);
        }
 
-       pr_info(DRV_NAME
-              ": %s: releasing %s interface %s\n",
-              bond_dev->name,
-              (slave->state == BOND_STATE_ACTIVE)
-              ? "active" : "backup",
-              slave_dev->name);
+       pr_info("%s: releasing %s interface %s\n",
+               bond_dev->name,
+               (slave->state == BOND_STATE_ACTIVE) ? "active" : "backup",
+               slave_dev->name);
 
        oldcurrent = bond->curr_active_slave;
 
@@ -1934,21 +1884,15 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
                if (list_empty(&bond->vlan_list)) {
                        bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
                } else {
-                       pr_warning(DRV_NAME
-                              ": %s: Warning: clearing HW address of %s while it "
-                              "still has VLANs.\n",
-                              bond_dev->name, bond_dev->name);
-                       pr_warning(DRV_NAME
-                              ": %s: When re-adding slaves, make sure the bond's "
-                              "HW address matches its VLANs'.\n",
-                              bond_dev->name);
+                       pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n",
+                                  bond_dev->name, bond_dev->name);
+                       pr_warning("%s: When re-adding slaves, make sure the bond's HW address matches its VLANs'.\n",
+                                  bond_dev->name);
                }
        } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) &&
                   !bond_has_challenged_slaves(bond)) {
-               pr_info(DRV_NAME
-                      ": %s: last VLAN challenged slave %s "
-                      "left bond %s. VLAN blocking is removed\n",
-                      bond_dev->name, slave_dev->name, bond_dev->name);
+               pr_info("%s: last VLAN challenged slave %s left bond %s. VLAN blocking is removed\n",
+                       bond_dev->name, slave_dev->name, bond_dev->name);
                bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED;
        }
 
@@ -2011,8 +1955,8 @@ int  bond_release_and_destroy(struct net_device *bond_dev,
 
        ret = bond_release(bond_dev, slave_dev);
        if ((ret == 0) && (bond->slave_cnt == 0)) {
-               pr_info(DRV_NAME ": %s: destroying bond %s.\n",
-                      bond_dev->name, bond_dev->name);
+               pr_info("%s: destroying bond %s.\n",
+                       bond_dev->name, bond_dev->name);
                unregister_netdevice(bond_dev);
        }
        return ret;
@@ -2116,19 +2060,13 @@ static int bond_release_all(struct net_device *bond_dev)
        if (list_empty(&bond->vlan_list))
                bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
        else {
-               pr_warning(DRV_NAME
-                      ": %s: Warning: clearing HW address of %s while it "
-                      "still has VLANs.\n",
-                      bond_dev->name, bond_dev->name);
-               pr_warning(DRV_NAME
-                      ": %s: When re-adding slaves, make sure the bond's "
-                      "HW address matches its VLANs'.\n",
-                      bond_dev->name);
+               pr_warning("%s: Warning: clearing HW address of %s while it still has VLANs.\n",
+                          bond_dev->name, bond_dev->name);
+               pr_warning("%s: When re-adding slaves, make sure the bond's HW address matches its VLANs'.\n",
+                          bond_dev->name);
        }
 
-       pr_info(DRV_NAME
-              ": %s: released all slaves\n",
-              bond_dev->name);
+       pr_info("%s: released all slaves\n", bond_dev->name);
 
 out:
        write_unlock_bh(&bond->lock);
@@ -2254,16 +2192,14 @@ static int bond_miimon_inspect(struct bonding *bond)
                        slave->link = BOND_LINK_FAIL;
                        slave->delay = bond->params.downdelay;
                        if (slave->delay) {
-                               pr_info(DRV_NAME
-                                      ": %s: link status down for %s"
-                                      "interface %s, disabling it in %d ms.\n",
-                                      bond->dev->name,
-                                      (bond->params.mode ==
-                                       BOND_MODE_ACTIVEBACKUP) ?
-                                      ((slave->state == BOND_STATE_ACTIVE) ?
-                                       "active " : "backup ") : "",
-                                      slave->dev->name,
-                                      bond->params.downdelay * bond->params.miimon);
+                               pr_info("%s: link status down for %sinterface %s, disabling it in %d ms.\n",
+                                       bond->dev->name,
+                                       (bond->params.mode ==
+                                        BOND_MODE_ACTIVEBACKUP) ?
+                                       ((slave->state == BOND_STATE_ACTIVE) ?
+                                        "active " : "backup ") : "",
+                                       slave->dev->name,
+                                       bond->params.downdelay * bond->params.miimon);
                        }
                        /*FALLTHRU*/
                case BOND_LINK_FAIL:
@@ -2273,13 +2209,11 @@ static int bond_miimon_inspect(struct bonding *bond)
                                 */
                                slave->link = BOND_LINK_UP;
                                slave->jiffies = jiffies;
-                               pr_info(DRV_NAME
-                                      ": %s: link status up again after %d "
-                                      "ms for interface %s.\n",
-                                      bond->dev->name,
-                                      (bond->params.downdelay - slave->delay) *
-                                      bond->params.miimon,
-                                      slave->dev->name);
+                               pr_info("%s: link status up again after %d ms for interface %s.\n",
+                                       bond->dev->name,
+                                       (bond->params.downdelay - slave->delay) *
+                                       bond->params.miimon,
+                                       slave->dev->name);
                                continue;
                        }
 
@@ -2300,25 +2234,21 @@ static int bond_miimon_inspect(struct bonding *bond)
                        slave->delay = bond->params.updelay;
 
                        if (slave->delay) {
-                               pr_info(DRV_NAME
-                                      ": %s: link status up for "
-                                      "interface %s, enabling it in %d ms.\n",
-                                      bond->dev->name, slave->dev->name,
-                                      ignore_updelay ? 0 :
-                                      bond->params.updelay *
-                                      bond->params.miimon);
+                               pr_info("%s: link status up for interface %s, enabling it in %d ms.\n",
+                                       bond->dev->name, slave->dev->name,
+                                       ignore_updelay ? 0 :
+                                       bond->params.updelay *
+                                       bond->params.miimon);
                        }
                        /*FALLTHRU*/
                case BOND_LINK_BACK:
                        if (!link_state) {
                                slave->link = BOND_LINK_DOWN;
-                               pr_info(DRV_NAME
-                                      ": %s: link status down again after %d "
-                                      "ms for interface %s.\n",
-                                      bond->dev->name,
-                                      (bond->params.updelay - slave->delay) *
-                                      bond->params.miimon,
-                                      slave->dev->name);
+                               pr_info("%s: link status down again after %d ms for interface %s.\n",
+                                       bond->dev->name,
+                                       (bond->params.updelay - slave->delay) *
+                                       bond->params.miimon,
+                                       slave->dev->name);
 
                                continue;
                        }
@@ -2366,10 +2296,8 @@ static void bond_miimon_commit(struct bonding *bond)
                                slave->state = BOND_STATE_BACKUP;
                        }
 
-                       pr_info(DRV_NAME
-                              ": %s: link status definitely "
-                              "up for interface %s.\n",
-                              bond->dev->name, slave->dev->name);
+                       pr_info("%s: link status definitely up for interface %s.\n",
+                               bond->dev->name, slave->dev->name);
 
                        /* notify ad that the link status has changed */
                        if (bond->params.mode == BOND_MODE_8023AD)
@@ -2395,10 +2323,8 @@ static void bond_miimon_commit(struct bonding *bond)
                            bond->params.mode == BOND_MODE_8023AD)
                                bond_set_slave_inactive_flags(slave);
 
-                       pr_info(DRV_NAME
-                              ": %s: link status definitely down for "
-                              "interface %s, disabling it\n",
-                              bond->dev->name, slave->dev->name);
+                       pr_info("%s: link status definitely down for interface %s, disabling it\n",
+                               bond->dev->name, slave->dev->name);
 
                        if (bond->params.mode == BOND_MODE_8023AD)
                                bond_3ad_handle_link_change(slave,
@@ -2414,8 +2340,7 @@ static void bond_miimon_commit(struct bonding *bond)
                        continue;
 
                default:
-                       pr_err(DRV_NAME
-                              ": %s: invalid new link %d on slave %s\n",
+                       pr_err("%s: invalid new link %d on slave %s\n",
                               bond->dev->name, slave->new_link,
                               slave->dev->name);
                        slave->new_link = BOND_LINK_NOCHANGE;
@@ -2534,19 +2459,19 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op, __be32 dest_
        struct sk_buff *skb;
 
        pr_debug("arp %d on slave %s: dst %x src %x vid %d\n", arp_op,
-              slave_dev->name, dest_ip, src_ip, vlan_id);
+                slave_dev->name, dest_ip, src_ip, vlan_id);
 
        skb = arp_create(arp_op, ETH_P_ARP, dest_ip, slave_dev, src_ip,
                         NULL, slave_dev->dev_addr, NULL);
 
        if (!skb) {
-               pr_err(DRV_NAME ": ARP packet allocation failed\n");
+               pr_err("ARP packet allocation failed\n");
                return;
        }
        if (vlan_id) {
                skb = vlan_put_tag(skb, vlan_id);
                if (!skb) {
-                       pr_err(DRV_NAME ": failed to insert VLAN tag\n");
+                       pr_err("failed to insert VLAN tag\n");
                        return;
                }
        }
@@ -2586,9 +2511,8 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
                rv = ip_route_output_key(dev_net(bond->dev), &rt, &fl);
                if (rv) {
                        if (net_ratelimit()) {
-                               pr_warning(DRV_NAME
-                            ": %s: no route to arp_ip_target %pI4\n",
-                                      bond->dev->name, &fl.fl4_dst);
+                               pr_warning("%s: no route to arp_ip_target %pI4\n",
+                                          bond->dev->name, &fl.fl4_dst);
                        }
                        continue;
                }
@@ -2623,10 +2547,9 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
                }
 
                if (net_ratelimit()) {
-                       pr_warning(DRV_NAME
-              ": %s: no path to arp_ip_target %pI4 via rt.dev %s\n",
-                              bond->dev->name, &fl.fl4_dst,
-                              rt->u.dst.dev ? rt->u.dst.dev->name : "NULL");
+                       pr_warning("%s: no path to arp_ip_target %pI4 via rt.dev %s\n",
+                                  bond->dev->name, &fl.fl4_dst,
+                                  rt->u.dst.dev ? rt->u.dst.dev->name : "NULL");
                }
                ip_rt_put(rt);
        }
@@ -2644,8 +2567,8 @@ static void bond_send_gratuitous_arp(struct bonding *bond)
        struct vlan_entry *vlan;
        struct net_device *vlan_dev;
 
-       pr_debug("bond_send_grat_arp: bond %s slave %s\n", bond->dev->name,
-                               slave ? slave->dev->name : "NULL");
+       pr_debug("bond_send_grat_arp: bond %s slave %s\n",
+                bond->dev->name, slave ? slave->dev->name : "NULL");
 
        if (!slave || !bond->send_grat_arp ||
            test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))
@@ -2674,7 +2597,8 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32
 
        for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
                pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip) %d\n",
-                       &sip, &tip, i, &targets[i], bond_has_this_ip(bond, tip));
+                        &sip, &tip, i, &targets[i],
+                        bond_has_this_ip(bond, tip));
                if (sip == targets[i]) {
                        if (bond_has_this_ip(bond, tip))
                                slave->last_arp_rx = jiffies;
@@ -2698,8 +2622,8 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
        read_lock(&bond->lock);
 
        pr_debug("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n",
-               bond->dev->name, skb->dev ? skb->dev->name : "NULL",
-               orig_dev ? orig_dev->name : "NULL");
+                bond->dev->name, skb->dev ? skb->dev->name : "NULL",
+                orig_dev ? orig_dev->name : "NULL");
 
        slave = bond_get_slave_by_dev(bond, orig_dev);
        if (!slave || !slave_do_arp_validate(bond, slave))
@@ -2724,9 +2648,9 @@ static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct pack
        memcpy(&tip, arp_ptr, 4);
 
        pr_debug("bond_arp_rcv: %s %s/%d av %d sv %d sip %pI4 tip %pI4\n",
-               bond->dev->name, slave->dev->name, slave->state,
-               bond->params.arp_validate, slave_do_arp_validate(bond, slave),
-               &sip, &tip);
+                bond->dev->name, slave->dev->name, slave->state,
+                bond->params.arp_validate, slave_do_arp_validate(bond, slave),
+                &sip, &tip);
 
        /*
         * Backup slaves won't see the ARP reply, but do come through
@@ -2800,17 +2724,14 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
                                 * is closed.
                                 */
                                if (!oldcurrent) {
-                                       pr_info(DRV_NAME
-                                              ": %s: link status definitely "
-                                              "up for interface %s, ",
-                                              bond->dev->name,
-                                              slave->dev->name);
+                                       pr_info("%s: link status definitely up for interface %s, ",
+                                               bond->dev->name,
+                                               slave->dev->name);
                                        do_failover = 1;
                                } else {
-                                       pr_info(DRV_NAME
-                                              ": %s: interface %s is now up\n",
-                                              bond->dev->name,
-                                              slave->dev->name);
+                                       pr_info("%s: interface %s is now up\n",
+                                               bond->dev->name,
+                                               slave->dev->name);
                                }
                        }
                } else {
@@ -2829,10 +2750,9 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
                                if (slave->link_failure_count < UINT_MAX)
                                        slave->link_failure_count++;
 
-                               pr_info(DRV_NAME
-                                      ": %s: interface %s is now down.\n",
-                                      bond->dev->name,
-                                      slave->dev->name);
+                               pr_info("%s: interface %s is now down.\n",
+                                       bond->dev->name,
+                                       slave->dev->name);
 
                                if (slave == oldcurrent)
                                        do_failover = 1;
@@ -2965,9 +2885,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
                                slave->link = BOND_LINK_UP;
                                bond->current_arp_slave = NULL;
 
-                               pr_info(DRV_NAME
-                                       ": %s: link status definitely "
-                                       "up for interface %s.\n",
+                               pr_info("%s: link status definitely up for interface %s.\n",
                                        bond->dev->name, slave->dev->name);
 
                                if (!bond->curr_active_slave ||
@@ -2985,9 +2903,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
                        slave->link = BOND_LINK_DOWN;
                        bond_set_slave_inactive_flags(slave);
 
-                       pr_info(DRV_NAME
-                               ": %s: link status definitely down for "
-                               "interface %s, disabling it\n",
+                       pr_info("%s: link status definitely down for interface %s, disabling it\n",
                                bond->dev->name, slave->dev->name);
 
                        if (slave == bond->curr_active_slave) {
@@ -2998,8 +2914,7 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
                        continue;
 
                default:
-                       pr_err(DRV_NAME
-                              ": %s: impossible: new_link %d on slave %s\n",
+                       pr_err("%s: impossible: new_link %d on slave %s\n",
                               bond->dev->name, slave->new_link,
                               slave->dev->name);
                        continue;
@@ -3028,9 +2943,9 @@ static void bond_ab_arp_probe(struct bonding *bond)
        read_lock(&bond->curr_slave_lock);
 
        if (bond->current_arp_slave && bond->curr_active_slave)
-               pr_info(DRV_NAME "PROBE: c_arp %s && cas %s BAD\n",
-                      bond->current_arp_slave->dev->name,
-                      bond->curr_active_slave->dev->name);
+               pr_info("PROBE: c_arp %s && cas %s BAD\n",
+                       bond->current_arp_slave->dev->name,
+                       bond->curr_active_slave->dev->name);
 
        if (bond->curr_active_slave) {
                bond_arp_send_all(bond, bond->curr_active_slave);
@@ -3078,9 +2993,8 @@ static void bond_ab_arp_probe(struct bonding *bond)
 
                        bond_set_slave_inactive_flags(slave);
 
-                       pr_info(DRV_NAME
-                              ": %s: backup interface %s is now down.\n",
-                              bond->dev->name, slave->dev->name);
+                       pr_info("%s: backup interface %s is now down.\n",
+                               bond->dev->name, slave->dev->name);
                }
        }
 }
@@ -3360,9 +3274,8 @@ static void bond_create_proc_entry(struct bonding *bond)
                                                    S_IRUGO, bn->proc_dir,
                                                    &bond_info_fops, bond);
                if (bond->proc_entry == NULL)
-                       pr_warning(DRV_NAME
-                              ": Warning: Cannot create /proc/net/%s/%s\n",
-                              DRV_NAME, bond_dev->name);
+                       pr_warning("Warning: Cannot create /proc/net/%s/%s\n",
+                                  DRV_NAME, bond_dev->name);
                else
                        memcpy(bond->proc_file_name, bond_dev->name, IFNAMSIZ);
        }
@@ -3388,9 +3301,8 @@ static void bond_create_proc_dir(struct bond_net *bn)
        if (!bn->proc_dir) {
                bn->proc_dir = proc_mkdir(DRV_NAME, bn->net->proc_net);
                if (!bn->proc_dir)
-                       pr_warning(DRV_NAME
-                               ": Warning: cannot create /proc/net/%s\n",
-                               DRV_NAME);
+                       pr_warning("Warning: cannot create /proc/net/%s\n",
+                                  DRV_NAME);
        }
 }
 
@@ -3539,8 +3451,8 @@ static int bond_netdev_event(struct notifier_block *this,
        struct net_device *event_dev = (struct net_device *)ptr;
 
        pr_debug("event_dev: %s, event: %lx\n",
-               (event_dev ? event_dev->name : "None"),
-               event);
+                event_dev ? event_dev->name : "None",
+                event);
 
        if (!(event_dev->priv_flags & IFF_BONDING))
                return NOTIFY_DONE;
@@ -3875,8 +3787,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
        struct mii_ioctl_data *mii = NULL;
        int res = 0;
 
-       pr_debug("bond_ioctl: master=%s, cmd=%d\n",
-               bond_dev->name, cmd);
+       pr_debug("bond_ioctl: master=%s, cmd=%d\n", bond_dev->name, cmd);
 
        switch (cmd) {
        case SIOCGMIIPHY:
@@ -3945,12 +3856,12 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
 
        slave_dev = dev_get_by_name(dev_net(bond_dev), ifr->ifr_slave);
 
-       pr_debug("slave_dev=%p: \n", slave_dev);
+       pr_debug("slave_dev=%p:\n", slave_dev);
 
        if (!slave_dev)
                res = -ENODEV;
        else {
-               pr_debug("slave_dev->name=%s: \n", slave_dev->name);
+               pr_debug("slave_dev->name=%s:\n", slave_dev->name);
                switch (cmd) {
                case BOND_ENSLAVE_OLD:
                case SIOCBONDENSLAVE:
@@ -4059,7 +3970,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
        int i;
 
        pr_debug("bond=%p, name=%s, new_mtu=%d\n", bond,
-               (bond_dev ? bond_dev->name : "None"), new_mtu);
+                (bond_dev ? bond_dev->name : "None"), new_mtu);
 
        /* Can't hold bond->lock with bh disabled here since
         * some base drivers panic. On the other hand we can't
@@ -4077,8 +3988,10 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
         */
 
        bond_for_each_slave(bond, slave, i) {
-               pr_debug("s %p s->p %p c_m %p\n", slave,
-                       slave->prev, slave->dev->netdev_ops->ndo_change_mtu);
+               pr_debug("s %p s->p %p c_m %p\n",
+                        slave,
+                        slave->prev,
+                        slave->dev->netdev_ops->ndo_change_mtu);
 
                res = dev_set_mtu(slave->dev, new_mtu);
 
@@ -4108,8 +4021,8 @@ unwind:
 
                tmp_res = dev_set_mtu(slave->dev, bond_dev->mtu);
                if (tmp_res) {
-                       pr_debug("unwind err %d dev %s\n", tmp_res,
-                               slave->dev->name);
+                       pr_debug("unwind err %d dev %s\n",
+                                tmp_res, slave->dev->name);
                }
        }
 
@@ -4135,7 +4048,8 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
                return bond_alb_set_mac_address(bond_dev, addr);
 
 
-       pr_debug("bond=%p, name=%s\n", bond, (bond_dev ? bond_dev->name : "None"));
+       pr_debug("bond=%p, name=%s\n",
+                bond, bond_dev ? bond_dev->name : "None");
 
        /*
         * If fail_over_mac is set to active, do nothing and return
@@ -4200,8 +4114,8 @@ unwind:
 
                tmp_res = dev_set_mac_address(slave->dev, &tmp_sa);
                if (tmp_res) {
-                       pr_debug("unwind err %d dev %s\n", tmp_res,
-                               slave->dev->name);
+                       pr_debug("unwind err %d dev %s\n",
+                                tmp_res, slave->dev->name);
                }
        }
 
@@ -4357,9 +4271,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
                        if (tx_dev) {
                                struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
                                if (!skb2) {
-                                       pr_err(DRV_NAME
-                                              ": %s: Error: bond_xmit_broadcast(): "
-                                              "skb_clone() failed\n",
+                                       pr_err("%s: Error: bond_xmit_broadcast(): skb_clone() failed\n",
                                               bond_dev->name);
                                        continue;
                                }
@@ -4425,8 +4337,8 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
                return bond_alb_xmit(skb, dev);
        default:
                /* Should never happen, mode already checked */
-               pr_err(DRV_NAME ": %s: Error: Unknown bonding mode %d\n",
-                    dev->name, bond->params.mode);
+               pr_err("%s: Error: Unknown bonding mode %d\n",
+                      dev->name, bond->params.mode);
                WARN_ON_ONCE(1);
                dev_kfree_skb(skb);
                return NETDEV_TX_OK;
@@ -4462,10 +4374,8 @@ void bond_set_mode_ops(struct bonding *bond, int mode)
                break;
        default:
                /* Should never happen, mode already checked */
-               pr_err(DRV_NAME
-                      ": %s: Error: Unknown bonding mode %d\n",
-                      bond_dev->name,
-                      mode);
+               pr_err("%s: Error: Unknown bonding mode %d\n",
+                      bond_dev->name, mode);
                break;
        }
 }
@@ -4650,8 +4560,7 @@ static int bond_check_params(struct bond_params *params)
        if (mode) {
                bond_mode = bond_parse_parm(mode, bond_mode_tbl);
                if (bond_mode == -1) {
-                       pr_err(DRV_NAME
-                              ": Error: Invalid bonding mode \"%s\"\n",
+                       pr_err("Error: Invalid bonding mode \"%s\"\n",
                               mode == NULL ? "NULL" : mode);
                        return -EINVAL;
                }
@@ -4660,16 +4569,13 @@ static int bond_check_params(struct bond_params *params)
        if (xmit_hash_policy) {
                if ((bond_mode != BOND_MODE_XOR) &&
                    (bond_mode != BOND_MODE_8023AD)) {
-                       pr_info(DRV_NAME
-                               ": xmit_hash_policy param is irrelevant in"
-                               " mode %s\n",
+                       pr_info("xmit_hash_policy param is irrelevant in mode %s\n",
                               bond_mode_name(bond_mode));
                } else {
                        xmit_hashtype = bond_parse_parm(xmit_hash_policy,
                                                        xmit_hashtype_tbl);
                        if (xmit_hashtype == -1) {
-                               pr_err(DRV_NAME
-                                      ": Error: Invalid xmit_hash_policy \"%s\"\n",
+                               pr_err("Error: Invalid xmit_hash_policy \"%s\"\n",
                                       xmit_hash_policy == NULL ? "NULL" :
                                       xmit_hash_policy);
                                return -EINVAL;
@@ -4679,14 +4585,12 @@ static int bond_check_params(struct bond_params *params)
 
        if (lacp_rate) {
                if (bond_mode != BOND_MODE_8023AD) {
-                       pr_info(DRV_NAME
-                              ": lacp_rate param is irrelevant in mode %s\n",
-                              bond_mode_name(bond_mode));
+                       pr_info("lacp_rate param is irrelevant in mode %s\n",
+                               bond_mode_name(bond_mode));
                } else {
                        lacp_fast = bond_parse_parm(lacp_rate, bond_lacp_tbl);
                        if (lacp_fast == -1) {
-                               pr_err(DRV_NAME
-                                      ": Error: Invalid lacp rate \"%s\"\n",
+                               pr_err("Error: Invalid lacp rate \"%s\"\n",
                                       lacp_rate == NULL ? "NULL" : lacp_rate);
                                return -EINVAL;
                        }
@@ -4696,82 +4600,64 @@ static int bond_check_params(struct bond_params *params)
        if (ad_select) {
                params->ad_select = bond_parse_parm(ad_select, ad_select_tbl);
                if (params->ad_select == -1) {
-                       pr_err(DRV_NAME
-                              ": Error: Invalid ad_select \"%s\"\n",
+                       pr_err("Error: Invalid ad_select \"%s\"\n",
                               ad_select == NULL ? "NULL" : ad_select);
                        return -EINVAL;
                }
 
                if (bond_mode != BOND_MODE_8023AD) {
-                       pr_warning(DRV_NAME
-                              ": ad_select param only affects 802.3ad mode\n");
+                       pr_warning("ad_select param only affects 802.3ad mode\n");
                }
        } else {
                params->ad_select = BOND_AD_STABLE;
        }
 
        if (max_bonds < 0) {
-               pr_warning(DRV_NAME
-                      ": Warning: max_bonds (%d) not in range %d-%d, so it "
-                      "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n",
-                      max_bonds, 0, INT_MAX, BOND_DEFAULT_MAX_BONDS);
+               pr_warning("Warning: max_bonds (%d) not in range %d-%d, so it was reset to BOND_DEFAULT_MAX_BONDS (%d)\n",
+                          max_bonds, 0, INT_MAX, BOND_DEFAULT_MAX_BONDS);
                max_bonds = BOND_DEFAULT_MAX_BONDS;
        }
 
        if (miimon < 0) {
-               pr_warning(DRV_NAME
-                      ": Warning: miimon module parameter (%d), "
-                      "not in range 0-%d, so it was reset to %d\n",
-                      miimon, INT_MAX, BOND_LINK_MON_INTERV);
+               pr_warning("Warning: miimon module parameter (%d), not in range 0-%d, so it was reset to %d\n",
+                          miimon, INT_MAX, BOND_LINK_MON_INTERV);
                miimon = BOND_LINK_MON_INTERV;
        }
 
        if (updelay < 0) {
-               pr_warning(DRV_NAME
-                      ": Warning: updelay module parameter (%d), "
-                      "not in range 0-%d, so it was reset to 0\n",
-                      updelay, INT_MAX);
+               pr_warning("Warning: updelay module parameter (%d), not in range 0-%d, so it was reset to 0\n",
+                          updelay, INT_MAX);
                updelay = 0;
        }
 
        if (downdelay < 0) {
-               pr_warning(DRV_NAME
-                      ": Warning: downdelay module parameter (%d), "
-                      "not in range 0-%d, so it was reset to 0\n",
-                      downdelay, INT_MAX);
+               pr_warning("Warning: downdelay module parameter (%d), not in range 0-%d, so it was reset to 0\n",
+                          downdelay, INT_MAX);
                downdelay = 0;
        }
 
        if ((use_carrier != 0) && (use_carrier != 1)) {
-               pr_warning(DRV_NAME
-                      ": Warning: use_carrier module parameter (%d), "
-                      "not of valid value (0/1), so it was set to 1\n",
-                      use_carrier);
+               pr_warning("Warning: use_carrier module parameter (%d), not of valid value (0/1), so it was set to 1\n",
+                          use_carrier);
                use_carrier = 1;
        }
 
        if (num_grat_arp < 0 || num_grat_arp > 255) {
-               pr_warning(DRV_NAME
-                      ": Warning: num_grat_arp (%d) not in range 0-255 so it "
-                      "was reset to 1 \n", num_grat_arp);
+               pr_warning("Warning: num_grat_arp (%d) not in range 0-255 so it was reset to 1 \n",
+                          num_grat_arp);
                num_grat_arp = 1;
        }
 
        if (num_unsol_na < 0 || num_unsol_na > 255) {
-               pr_warning(DRV_NAME
-                      ": Warning: num_unsol_na (%d) not in range 0-255 so it "
-                      "was reset to 1 \n", num_unsol_na);
+               pr_warning("Warning: num_unsol_na (%d) not in range 0-255 so it was reset to 1 \n",
+                          num_unsol_na);
                num_unsol_na = 1;
        }
 
        /* reset values for 802.3ad */
        if (bond_mode == BOND_MODE_8023AD) {
                if (!miimon) {
-                       pr_warning(DRV_NAME
-                              ": Warning: miimon must be specified, "
-                              "otherwise bonding will not detect link "
-                              "failure, speed and duplex which are "
-                              "essential for 802.3ad operation\n");
+                       pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n");
                        pr_warning("Forcing miimon to 100msec\n");
                        miimon = 100;
                }
@@ -4781,24 +4667,15 @@ static int bond_check_params(struct bond_params *params)
        if ((bond_mode == BOND_MODE_TLB) ||
            (bond_mode == BOND_MODE_ALB)) {
                if (!miimon) {
-                       pr_warning(DRV_NAME
-                              ": Warning: miimon must be specified, "
-                              "otherwise bonding will not detect link "
-                              "failure and link speed which are essential "
-                              "for TLB/ALB load balancing\n");
+                       pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure and link speed which are essential for TLB/ALB load balancing\n");
                        pr_warning("Forcing miimon to 100msec\n");
                        miimon = 100;
                }
        }
 
        if (bond_mode == BOND_MODE_ALB) {
-               pr_notice(DRV_NAME
-                      ": In ALB mode you might experience client "
-                      "disconnections upon reconnection of a link if the "
-                      "bonding module updelay parameter (%d msec) is "
-                      "incompatible with the forwarding delay time of the "
-                      "switch\n",
-                      updelay);
+               pr_notice("In ALB mode you might experience client disconnections upon reconnection of a link if the bonding module updelay parameter (%d msec) is incompatible with the forwarding delay time of the switch\n",
+                         updelay);
        }
 
        if (!miimon) {
@@ -4806,49 +4683,37 @@ static int bond_check_params(struct bond_params *params)
                        /* just warn the user the up/down delay will have
                         * no effect since miimon is zero...
                         */
-                       pr_warning(DRV_NAME
-                              ": Warning: miimon module parameter not set "
-                              "and updelay (%d) or downdelay (%d) module "
-                              "parameter is set; updelay and downdelay have "
-                              "no effect unless miimon is set\n",
-                              updelay, downdelay);
+                       pr_warning("Warning: miimon module parameter not set and updelay (%d) or downdelay (%d) module parameter is set; updelay and downdelay have no effect unless miimon is set\n",
+                                  updelay, downdelay);
                }
        } else {
                /* don't allow arp monitoring */
                if (arp_interval) {
-                       pr_warning(DRV_NAME
-                              ": Warning: miimon (%d) and arp_interval (%d) "
-                              "can't be used simultaneously, disabling ARP "
-                              "monitoring\n",
-                              miimon, arp_interval);
+                       pr_warning("Warning: miimon (%d) and arp_interval (%d) can't be used simultaneously, disabling ARP monitoring\n",
+                                  miimon, arp_interval);
                        arp_interval = 0;
                }
 
                if ((updelay % miimon) != 0) {
-                       pr_warning(DRV_NAME
-                              ": Warning: updelay (%d) is not a multiple "
-                              "of miimon (%d), updelay rounded to %d ms\n",
-                              updelay, miimon, (updelay / miimon) * miimon);
+                       pr_warning("Warning: updelay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
+                                  updelay, miimon,
+                                  (updelay / miimon) * miimon);
                }
 
                updelay /= miimon;
 
                if ((downdelay % miimon) != 0) {
-                       pr_warning(DRV_NAME
-                              ": Warning: downdelay (%d) is not a multiple "
-                              "of miimon (%d), downdelay rounded to %d ms\n",
-                              downdelay, miimon,
-                              (downdelay / miimon) * miimon);
+                       pr_warning("Warning: downdelay (%d) is not a multiple of miimon (%d), downdelay rounded to %d ms\n",
+                                  downdelay, miimon,
+                                  (downdelay / miimon) * miimon);
                }
 
                downdelay /= miimon;
        }
 
        if (arp_interval < 0) {
-               pr_warning(DRV_NAME
-                      ": Warning: arp_interval module parameter (%d) "
-                      ", not in range 0-%d, so it was reset to %d\n",
-                      arp_interval, INT_MAX, BOND_LINK_ARP_INTERV);
+               pr_warning("Warning: arp_interval module parameter (%d) , not in range 0-%d, so it was reset to %d\n",
+                          arp_interval, INT_MAX, BOND_LINK_ARP_INTERV);
                arp_interval = BOND_LINK_ARP_INTERV;
        }
 
@@ -4858,10 +4723,8 @@ static int bond_check_params(struct bond_params *params)
                /* not complete check, but should be good enough to
                   catch mistakes */
                if (!isdigit(arp_ip_target[arp_ip_count][0])) {
-                       pr_warning(DRV_NAME
-                              ": Warning: bad arp_ip_target module parameter "
-                              "(%s), ARP monitoring will not be performed\n",
-                              arp_ip_target[arp_ip_count]);
+                       pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n",
+                                  arp_ip_target[arp_ip_count]);
                        arp_interval = 0;
                } else {
                        __be32 ip = in_aton(arp_ip_target[arp_ip_count]);
@@ -4871,31 +4734,25 @@ static int bond_check_params(struct bond_params *params)
 
        if (arp_interval && !arp_ip_count) {
                /* don't allow arping if no arp_ip_target given... */
-               pr_warning(DRV_NAME
-                      ": Warning: arp_interval module parameter (%d) "
-                      "specified without providing an arp_ip_target "
-                      "parameter, arp_interval was reset to 0\n",
-                      arp_interval);
+               pr_warning("Warning: arp_interval module parameter (%d) specified without providing an arp_ip_target parameter, arp_interval was reset to 0\n",
+                          arp_interval);
                arp_interval = 0;
        }
 
        if (arp_validate) {
                if (bond_mode != BOND_MODE_ACTIVEBACKUP) {
-                       pr_err(DRV_NAME
-                              ": arp_validate only supported in active-backup mode\n");
+                       pr_err("arp_validate only supported in active-backup mode\n");
                        return -EINVAL;
                }
                if (!arp_interval) {
-                       pr_err(DRV_NAME
-                              ": arp_validate requires arp_interval\n");
+                       pr_err("arp_validate requires arp_interval\n");
                        return -EINVAL;
                }
 
                arp_validate_value = bond_parse_parm(arp_validate,
                                                     arp_validate_tbl);
                if (arp_validate_value == -1) {
-                       pr_err(DRV_NAME
-                              ": Error: invalid arp_validate \"%s\"\n",
+                       pr_err("Error: invalid arp_validate \"%s\"\n",
                               arp_validate == NULL ? "NULL" : arp_validate);
                        return -EINVAL;
                }
@@ -4903,17 +4760,14 @@ static int bond_check_params(struct bond_params *params)
                arp_validate_value = 0;
 
        if (miimon) {
-               pr_info(DRV_NAME
-                      ": MII link monitoring set to %d ms\n",
-                      miimon);
+               pr_info("MII link monitoring set to %d ms\n", miimon);
        } else if (arp_interval) {
                int i;
 
-               pr_info(DRV_NAME ": ARP monitoring set to %d ms,"
-                      " validate %s, with %d target(s):",
-                      arp_interval,
-                      arp_validate_tbl[arp_validate_value].modename,
-                      arp_ip_count);
+               pr_info("ARP monitoring set to %d ms, validate %s, with %d target(s):",
+                       arp_interval,
+                       arp_validate_tbl[arp_validate_value].modename,
+                       arp_ip_count);
 
                for (i = 0; i < arp_ip_count; i++)
                        pr_info(" %s", arp_ip_target[i]);
@@ -4924,21 +4778,15 @@ static int bond_check_params(struct bond_params *params)
                /* miimon and arp_interval not set, we need one so things
                 * work as expected, see bonding.txt for details
                 */
-               pr_warning(DRV_NAME
-                      ": Warning: either miimon or arp_interval and "
-                      "arp_ip_target module parameters must be specified, "
-                      "otherwise bonding will not detect link failures! see "
-                      "bonding.txt for details.\n");
+               pr_warning("Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details.\n");
        }
 
        if (primary && !USES_PRIMARY(bond_mode)) {
                /* currently, using a primary only makes sense
                 * in active backup, TLB or ALB modes
                 */
-               pr_warning(DRV_NAME
-                      ": Warning: %s primary device specified but has no "
-                      "effect in %s mode\n",
-                      primary, bond_mode_name(bond_mode));
+               pr_warning("Warning: %s primary device specified but has no effect in %s mode\n",
+                          primary, bond_mode_name(bond_mode));
                primary = NULL;
        }
 
@@ -4946,8 +4794,7 @@ static int bond_check_params(struct bond_params *params)
                primary_reselect_value = bond_parse_parm(primary_reselect,
                                                         pri_reselect_tbl);
                if (primary_reselect_value == -1) {
-                       pr_err(DRV_NAME
-                              ": Error: Invalid primary_reselect \"%s\"\n",
+                       pr_err("Error: Invalid primary_reselect \"%s\"\n",
                               primary_reselect ==
                                        NULL ? "NULL" : primary_reselect);
                        return -EINVAL;
@@ -4960,16 +4807,13 @@ static int bond_check_params(struct bond_params *params)
                fail_over_mac_value = bond_parse_parm(fail_over_mac,
                                                      fail_over_mac_tbl);
                if (fail_over_mac_value == -1) {
-                       pr_err(DRV_NAME
-                              ": Error: invalid fail_over_mac \"%s\"\n",
+                       pr_err("Error: invalid fail_over_mac \"%s\"\n",
                               arp_validate == NULL ? "NULL" : arp_validate);
                        return -EINVAL;
                }
 
                if (bond_mode != BOND_MODE_ACTIVEBACKUP)
-                       pr_warning(DRV_NAME
-                              ": Warning: fail_over_mac only affects "
-                              "active-backup mode.\n");
+                       pr_warning("Warning: fail_over_mac only affects active-backup mode.\n");
        } else {
                fail_over_mac_value = BOND_FOM_NONE;
        }
@@ -5076,8 +4920,7 @@ int bond_create(struct net *net, const char *name)
        bond_dev = alloc_netdev(sizeof(struct bonding), name ? name : "",
                                bond_setup);
        if (!bond_dev) {
-               pr_err(DRV_NAME ": %s: eek! can't alloc netdev!\n",
-                      name);
+               pr_err("%s: eek! can't alloc netdev!\n", name);
                res = -ENOMEM;
                goto out;
        }
index 4e00b4f836411eabb4fcc41959c5415bc9bcb13d..5acd557cea9ba7ab4c4cbcb36323dccee02bff20 100644 (file)
@@ -19,6 +19,9 @@
  * file called LICENSE.
  *
  */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/device.h>
@@ -109,11 +112,10 @@ static ssize_t bonding_store_bonds(struct class *cls,
                goto err_no_cmd;
 
        if (command[0] == '+') {
-               pr_info(DRV_NAME
-                       ": %s is being created...\n", ifname);
+               pr_info("%s is being created...\n", ifname);
                rv = bond_create(net, ifname);
                if (rv) {
-                       pr_info(DRV_NAME ": Bond creation failed.\n");
+                       pr_info("Bond creation failed.\n");
                        res = rv;
                }
        } else if (command[0] == '-') {
@@ -122,12 +124,10 @@ static ssize_t bonding_store_bonds(struct class *cls,
                rtnl_lock();
                bond_dev = bond_get_by_name(net, ifname);
                if (bond_dev) {
-                       pr_info(DRV_NAME ": %s is being deleted...\n",
-                               ifname);
+                       pr_info("%s is being deleted...\n", ifname);
                        unregister_netdevice(bond_dev);
                } else {
-                       pr_err(DRV_NAME ": unable to delete non-existent %s\n",
-                              ifname);
+                       pr_err("unable to delete non-existent %s\n", ifname);
                        res = -ENODEV;
                }
                rtnl_unlock();
@@ -140,8 +140,7 @@ static ssize_t bonding_store_bonds(struct class *cls,
        return res;
 
 err_no_cmd:
-       pr_err(DRV_NAME ": no command found in bonding_masters."
-              " Use +ifname or -ifname.\n");
+       pr_err("no command found in bonding_masters. Use +ifname or -ifname.\n");
        return -EPERM;
 }
 
@@ -225,8 +224,8 @@ static ssize_t bonding_store_slaves(struct device *d,
 
        /* Quick sanity check -- is the bond interface up? */
        if (!(bond->dev->flags & IFF_UP)) {
-               pr_warning(DRV_NAME ": %s: doing slave updates when "
-                          "interface is down.\n", bond->dev->name);
+               pr_warning("%s: doing slave updates when interface is down.\n",
+                          bond->dev->name);
        }
 
        /* Note:  We can't hold bond->lock here, as bond_create grabs it. */
@@ -247,17 +246,14 @@ static ssize_t bonding_store_slaves(struct device *d,
 
                dev = __dev_get_by_name(dev_net(bond->dev), ifname);
                if (!dev) {
-                       pr_info(DRV_NAME
-                              ": %s: Interface %s does not exist!\n",
-                              bond->dev->name, ifname);
+                       pr_info("%s: Interface %s does not exist!\n",
+                               bond->dev->name, ifname);
                        ret = -ENODEV;
                        goto out;
                }
 
                if (dev->flags & IFF_UP) {
-                       pr_err(DRV_NAME
-                              ": %s: Error: Unable to enslave %s "
-                              "because it is already up.\n",
+                       pr_err("%s: Error: Unable to enslave %s because it is already up.\n",
                               bond->dev->name, dev->name);
                        ret = -EPERM;
                        goto out;
@@ -266,8 +262,7 @@ static ssize_t bonding_store_slaves(struct device *d,
                read_lock(&bond->lock);
                bond_for_each_slave(bond, slave, i)
                        if (slave->dev == dev) {
-                               pr_err(DRV_NAME
-                                      ": %s: Interface %s is already enslaved!\n",
+                               pr_err("%s: Interface %s is already enslaved!\n",
                                       bond->dev->name, ifname);
                                ret = -EPERM;
                                read_unlock(&bond->lock);
@@ -275,8 +270,7 @@ static ssize_t bonding_store_slaves(struct device *d,
                        }
                read_unlock(&bond->lock);
 
-               pr_info(DRV_NAME ": %s: Adding slave %s.\n",
-                       bond->dev->name, ifname);
+               pr_info("%s: Adding slave %s.\n", bond->dev->name, ifname);
 
                /* If this is the first slave, then we need to set
                   the master's hardware address to be the same as the
@@ -313,7 +307,7 @@ static ssize_t bonding_store_slaves(struct device *d,
                                break;
                        }
                if (dev) {
-                       pr_info(DRV_NAME ": %s: Removing slave %s\n",
+                       pr_info("%s: Removing slave %s\n",
                                bond->dev->name, dev->name);
                                res = bond_release(bond->dev, dev);
                        if (res) {
@@ -323,16 +317,16 @@ static ssize_t bonding_store_slaves(struct device *d,
                        /* set the slave MTU to the default */
                        dev_set_mtu(dev, original_mtu);
                } else {
-                       pr_err(DRV_NAME ": unable to remove non-existent"
-                              " slave %s for bond %s.\n",
-                               ifname, bond->dev->name);
+                       pr_err("unable to remove non-existent slave %s for bond %s.\n",
+                              ifname, bond->dev->name);
                        ret = -ENODEV;
                }
                goto out;
        }
 
 err_no_cmd:
-       pr_err(DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name);
+       pr_err("no command found in slaves file for bond %s. Use +ifname or -ifname.\n",
+              bond->dev->name);
        ret = -EPERM;
 
 out:
@@ -365,18 +359,16 @@ static ssize_t bonding_store_mode(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (bond->dev->flags & IFF_UP) {
-               pr_err(DRV_NAME ": unable to update mode of %s"
-                      " because interface is up.\n", bond->dev->name);
+               pr_err("unable to update mode of %s because interface is up.\n",
+                      bond->dev->name);
                ret = -EPERM;
                goto out;
        }
 
        new_value = bond_parse_parm(buf, bond_mode_tbl);
        if (new_value < 0)  {
-               pr_err(DRV_NAME
-                      ": %s: Ignoring invalid mode value %.*s.\n",
-                      bond->dev->name,
-                      (int)strlen(buf) - 1, buf);
+               pr_err("%s: Ignoring invalid mode value %.*s.\n",
+                      bond->dev->name, (int)strlen(buf) - 1, buf);
                ret = -EINVAL;
                goto out;
        } else {
@@ -388,8 +380,8 @@ static ssize_t bonding_store_mode(struct device *d,
 
                bond->params.mode = new_value;
                bond_set_mode_ops(bond, bond->params.mode);
-               pr_info(DRV_NAME ": %s: setting mode to %s (%d).\n",
-                      bond->dev->name, bond_mode_tbl[new_value].modename,
+               pr_info("%s: setting mode to %s (%d).\n",
+                       bond->dev->name, bond_mode_tbl[new_value].modename,
                       new_value);
        }
 out:
@@ -421,8 +413,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (bond->dev->flags & IFF_UP) {
-               pr_err(DRV_NAME
-                      "%s: Interface is up. Unable to update xmit policy.\n",
+               pr_err("%s: Interface is up. Unable to update xmit policy.\n",
                       bond->dev->name);
                ret = -EPERM;
                goto out;
@@ -430,8 +421,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
 
        new_value = bond_parse_parm(buf, xmit_hashtype_tbl);
        if (new_value < 0)  {
-               pr_err(DRV_NAME
-                      ": %s: Ignoring invalid xmit hash policy value %.*s.\n",
+               pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n",
                       bond->dev->name,
                       (int)strlen(buf) - 1, buf);
                ret = -EINVAL;
@@ -439,7 +429,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d,
        } else {
                bond->params.xmit_policy = new_value;
                bond_set_mode_ops(bond, bond->params.mode);
-               pr_info(DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n",
+               pr_info("%s: setting xmit hash policy to %s (%d).\n",
                        bond->dev->name,
                        xmit_hashtype_tbl[new_value].modename, new_value);
        }
@@ -472,20 +462,18 @@ static ssize_t bonding_store_arp_validate(struct device *d,
 
        new_value = bond_parse_parm(buf, arp_validate_tbl);
        if (new_value < 0) {
-               pr_err(DRV_NAME
-                      ": %s: Ignoring invalid arp_validate value %s\n",
+               pr_err("%s: Ignoring invalid arp_validate value %s\n",
                       bond->dev->name, buf);
                return -EINVAL;
        }
        if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
-               pr_err(DRV_NAME
-                      ": %s: arp_validate only supported in active-backup mode.\n",
+               pr_err("%s: arp_validate only supported in active-backup mode.\n",
                       bond->dev->name);
                return -EINVAL;
        }
-       pr_info(DRV_NAME ": %s: setting arp_validate to %s (%d).\n",
-              bond->dev->name, arp_validate_tbl[new_value].modename,
-              new_value);
+       pr_info("%s: setting arp_validate to %s (%d).\n",
+               bond->dev->name, arp_validate_tbl[new_value].modename,
+               new_value);
 
        if (!bond->params.arp_validate && new_value)
                bond_register_arp(bond);
@@ -523,24 +511,22 @@ static ssize_t bonding_store_fail_over_mac(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (bond->slave_cnt != 0) {
-               pr_err(DRV_NAME
-                      ": %s: Can't alter fail_over_mac with slaves in bond.\n",
+               pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
                       bond->dev->name);
                return -EPERM;
        }
 
        new_value = bond_parse_parm(buf, fail_over_mac_tbl);
        if (new_value < 0) {
-               pr_err(DRV_NAME
-                      ": %s: Ignoring invalid fail_over_mac value %s.\n",
+               pr_err("%s: Ignoring invalid fail_over_mac value %s.\n",
                       bond->dev->name, buf);
                return -EINVAL;
        }
 
        bond->params.fail_over_mac = new_value;
-       pr_info(DRV_NAME ": %s: Setting fail_over_mac to %s (%d).\n",
-              bond->dev->name, fail_over_mac_tbl[new_value].modename,
-              new_value);
+       pr_info("%s: Setting fail_over_mac to %s (%d).\n",
+               bond->dev->name, fail_over_mac_tbl[new_value].modename,
+               new_value);
 
        return count;
 }
@@ -571,31 +557,26 @@ static ssize_t bonding_store_arp_interval(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err(DRV_NAME
-                      ": %s: no arp_interval value specified.\n",
+               pr_err("%s: no arp_interval value specified.\n",
                       bond->dev->name);
                ret = -EINVAL;
                goto out;
        }
        if (new_value < 0) {
-               pr_err(DRV_NAME
-                      ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
+               pr_err("%s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
                       bond->dev->name, new_value, INT_MAX);
                ret = -EINVAL;
                goto out;
        }
 
-       pr_info(DRV_NAME
-              ": %s: Setting ARP monitoring interval to %d.\n",
-              bond->dev->name, new_value);
+       pr_info("%s: Setting ARP monitoring interval to %d.\n",
+               bond->dev->name, new_value);
        bond->params.arp_interval = new_value;
        if (bond->params.arp_interval)
                bond->dev->priv_flags |= IFF_MASTER_ARPMON;
        if (bond->params.miimon) {
-               pr_info(DRV_NAME
-                      ": %s: ARP monitoring cannot be used with MII monitoring. "
-                      "%s Disabling MII monitoring.\n",
-                      bond->dev->name, bond->dev->name);
+               pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n",
+                       bond->dev->name, bond->dev->name);
                bond->params.miimon = 0;
                if (delayed_work_pending(&bond->mii_work)) {
                        cancel_delayed_work(&bond->mii_work);
@@ -603,10 +584,8 @@ static ssize_t bonding_store_arp_interval(struct device *d,
                }
        }
        if (!bond->params.arp_targets[0]) {
-               pr_info(DRV_NAME
-                      ": %s: ARP monitoring has been set up, "
-                      "but no ARP targets have been specified.\n",
-                      bond->dev->name);
+               pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n",
+                       bond->dev->name);
        }
        if (bond->dev->flags & IFF_UP) {
                /* If the interface is up, we may need to fire off
@@ -666,8 +645,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
        /* look for adds */
        if (buf[0] == '+') {
                if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
-                       pr_err(DRV_NAME
-                              ": %s: invalid ARP target %pI4 specified for addition\n",
+                       pr_err("%s: invalid ARP target %pI4 specified for addition\n",
                               bond->dev->name, &newtarget);
                        ret = -EINVAL;
                        goto out;
@@ -675,23 +653,20 @@ static ssize_t bonding_store_arp_targets(struct device *d,
                /* look for an empty slot to put the target in, and check for dupes */
                for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) {
                        if (targets[i] == newtarget) { /* duplicate */
-                               pr_err(DRV_NAME
-                                      ": %s: ARP target %pI4 is already present\n",
+                               pr_err("%s: ARP target %pI4 is already present\n",
                                       bond->dev->name, &newtarget);
                                ret = -EINVAL;
                                goto out;
                        }
                        if (targets[i] == 0) {
-                               pr_info(DRV_NAME
-                                      ": %s: adding ARP target %pI4.\n",
-                                      bond->dev->name, &newtarget);
+                               pr_info("%s: adding ARP target %pI4.\n",
+                                       bond->dev->name, &newtarget);
                                done = 1;
                                targets[i] = newtarget;
                        }
                }
                if (!done) {
-                       pr_err(DRV_NAME
-                              ": %s: ARP target table is full!\n",
+                       pr_err("%s: ARP target table is full!\n",
                               bond->dev->name);
                        ret = -EINVAL;
                        goto out;
@@ -699,8 +674,7 @@ static ssize_t bonding_store_arp_targets(struct device *d,
 
        } else if (buf[0] == '-')       {
                if ((newtarget == 0) || (newtarget == htonl(INADDR_BROADCAST))) {
-                       pr_err(DRV_NAME
-                              ": %s: invalid ARP target %pI4 specified for removal\n",
+                       pr_err("%s: invalid ARP target %pI4 specified for removal\n",
                               bond->dev->name, &newtarget);
                        ret = -EINVAL;
                        goto out;
@@ -709,9 +683,8 @@ static ssize_t bonding_store_arp_targets(struct device *d,
                for (i = 0; (i < BOND_MAX_ARP_TARGETS) && !done; i++) {
                        if (targets[i] == newtarget) {
                                int j;
-                               pr_info(DRV_NAME
-                                      ": %s: removing ARP target %pI4.\n",
-                                      bond->dev->name, &newtarget);
+                               pr_info("%s: removing ARP target %pI4.\n",
+                                       bond->dev->name, &newtarget);
                                for (j = i; (j < (BOND_MAX_ARP_TARGETS-1)) && targets[j+1]; j++)
                                        targets[j] = targets[j+1];
 
@@ -720,16 +693,14 @@ static ssize_t bonding_store_arp_targets(struct device *d,
                        }
                }
                if (!done) {
-                       pr_info(DRV_NAME
-                              ": %s: unable to remove nonexistent ARP target %pI4.\n",
-                              bond->dev->name, &newtarget);
+                       pr_info("%s: unable to remove nonexistent ARP target %pI4.\n",
+                               bond->dev->name, &newtarget);
                        ret = -EINVAL;
                        goto out;
                }
        } else {
-               pr_err(DRV_NAME ": no command found in arp_ip_targets file"
-                      " for bond %s. Use +<addr> or -<addr>.\n",
-                       bond->dev->name);
+               pr_err("no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n",
+                      bond->dev->name);
                ret = -EPERM;
                goto out;
        }
@@ -761,41 +732,34 @@ static ssize_t bonding_store_downdelay(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (!(bond->params.miimon)) {
-               pr_err(DRV_NAME
-                      ": %s: Unable to set down delay as MII monitoring is disabled\n",
+               pr_err("%s: Unable to set down delay as MII monitoring is disabled\n",
                       bond->dev->name);
                ret = -EPERM;
                goto out;
        }
 
        if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err(DRV_NAME
-                      ": %s: no down delay value specified.\n",
-                      bond->dev->name);
+               pr_err("%s: no down delay value specified.\n", bond->dev->name);
                ret = -EINVAL;
                goto out;
        }
        if (new_value < 0) {
-               pr_err(DRV_NAME
-                      ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
+               pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
                       bond->dev->name, new_value, 1, INT_MAX);
                ret = -EINVAL;
                goto out;
        } else {
                if ((new_value % bond->params.miimon) != 0) {
-                       pr_warning(DRV_NAME
-                                  ": %s: Warning: down delay (%d) is not a "
-                                  "multiple of miimon (%d), delay rounded "
-                                  "to %d ms\n",
+                       pr_warning("%s: Warning: down delay (%d) is not a multiple of miimon (%d), delay rounded to %d ms\n",
                                   bond->dev->name, new_value,
                                   bond->params.miimon,
                                   (new_value / bond->params.miimon) *
                                   bond->params.miimon);
                }
                bond->params.downdelay = new_value / bond->params.miimon;
-               pr_info(DRV_NAME ": %s: Setting down delay to %d.\n",
-                      bond->dev->name,
-                      bond->params.downdelay * bond->params.miimon);
+               pr_info("%s: Setting down delay to %d.\n",
+                       bond->dev->name,
+                       bond->params.downdelay * bond->params.miimon);
 
        }
 
@@ -823,41 +787,35 @@ static ssize_t bonding_store_updelay(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (!(bond->params.miimon)) {
-               pr_err(DRV_NAME
-                      ": %s: Unable to set up delay as MII monitoring is disabled\n",
+               pr_err("%s: Unable to set up delay as MII monitoring is disabled\n",
                       bond->dev->name);
                ret = -EPERM;
                goto out;
        }
 
        if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err(DRV_NAME
-                      ": %s: no up delay value specified.\n",
+               pr_err("%s: no up delay value specified.\n",
                       bond->dev->name);
                ret = -EINVAL;
                goto out;
        }
        if (new_value < 0) {
-               pr_err(DRV_NAME
-                      ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
+               pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n",
                       bond->dev->name, new_value, 1, INT_MAX);
                ret = -EINVAL;
                goto out;
        } else {
                if ((new_value % bond->params.miimon) != 0) {
-                       pr_warning(DRV_NAME
-                                  ": %s: Warning: up delay (%d) is not a "
-                                  "multiple of miimon (%d), updelay rounded "
-                                  "to %d ms\n",
+                       pr_warning("%s: Warning: up delay (%d) is not a multiple of miimon (%d), updelay rounded to %d ms\n",
                                   bond->dev->name, new_value,
                                   bond->params.miimon,
                                   (new_value / bond->params.miimon) *
                                   bond->params.miimon);
                }
                bond->params.updelay = new_value / bond->params.miimon;
-               pr_info(DRV_NAME ": %s: Setting up delay to %d.\n",
-                      bond->dev->name, bond->params.updelay * bond->params.miimon);
-
+               pr_info("%s: Setting up delay to %d.\n",
+                       bond->dev->name,
+                       bond->params.updelay * bond->params.miimon);
        }
 
 out:
@@ -889,16 +847,14 @@ static ssize_t bonding_store_lacp(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (bond->dev->flags & IFF_UP) {
-               pr_err(DRV_NAME
-                      ": %s: Unable to update LACP rate because interface is up.\n",
+               pr_err("%s: Unable to update LACP rate because interface is up.\n",
                       bond->dev->name);
                ret = -EPERM;
                goto out;
        }
 
        if (bond->params.mode != BOND_MODE_8023AD) {
-               pr_err(DRV_NAME
-                      ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
+               pr_err("%s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
                       bond->dev->name);
                ret = -EPERM;
                goto out;
@@ -908,12 +864,11 @@ static ssize_t bonding_store_lacp(struct device *d,
 
        if ((new_value == 1) || (new_value == 0)) {
                bond->params.lacp_fast = new_value;
-               pr_info(DRV_NAME ": %s: Setting LACP rate to %s (%d).\n",
+               pr_info("%s: Setting LACP rate to %s (%d).\n",
                        bond->dev->name, bond_lacp_tbl[new_value].modename,
                        new_value);
        } else {
-               pr_err(DRV_NAME
-                      ": %s: Ignoring invalid LACP rate value %.*s.\n",
+               pr_err("%s: Ignoring invalid LACP rate value %.*s.\n",
                       bond->dev->name, (int)strlen(buf) - 1, buf);
                ret = -EINVAL;
        }
@@ -943,9 +898,8 @@ static ssize_t bonding_store_ad_select(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (bond->dev->flags & IFF_UP) {
-               pr_err(DRV_NAME
-                      ": %s: Unable to update ad_select because interface "
-                      "is up.\n", bond->dev->name);
+               pr_err("%s: Unable to update ad_select because interface is up.\n",
+                      bond->dev->name);
                ret = -EPERM;
                goto out;
        }
@@ -954,13 +908,11 @@ static ssize_t bonding_store_ad_select(struct device *d,
 
        if (new_value != -1) {
                bond->params.ad_select = new_value;
-               pr_info(DRV_NAME
-                      ": %s: Setting ad_select to %s (%d).\n",
-                      bond->dev->name, ad_select_tbl[new_value].modename,
-                      new_value);
+               pr_info("%s: Setting ad_select to %s (%d).\n",
+                       bond->dev->name, ad_select_tbl[new_value].modename,
+                       new_value);
        } else {
-               pr_err(DRV_NAME
-                      ": %s: Ignoring invalid ad_select value %.*s.\n",
+               pr_err("%s: Ignoring invalid ad_select value %.*s.\n",
                       bond->dev->name, (int)strlen(buf) - 1, buf);
                ret = -EINVAL;
        }
@@ -990,15 +942,13 @@ static ssize_t bonding_store_n_grat_arp(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err(DRV_NAME
-                      ": %s: no num_grat_arp value specified.\n",
+               pr_err("%s: no num_grat_arp value specified.\n",
                       bond->dev->name);
                ret = -EINVAL;
                goto out;
        }
        if (new_value < 0 || new_value > 255) {
-               pr_err(DRV_NAME
-                      ": %s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
+               pr_err("%s: Invalid num_grat_arp value %d not in range 0-255; rejected.\n",
                       bond->dev->name, new_value);
                ret = -EINVAL;
                goto out;
@@ -1031,16 +981,14 @@ static ssize_t bonding_store_n_unsol_na(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err(DRV_NAME
-                      ": %s: no num_unsol_na value specified.\n",
+               pr_err("%s: no num_unsol_na value specified.\n",
                       bond->dev->name);
                ret = -EINVAL;
                goto out;
        }
 
        if (new_value < 0 || new_value > 255) {
-               pr_err(DRV_NAME
-                      ": %s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
+               pr_err("%s: Invalid num_unsol_na value %d not in range 0-255; rejected.\n",
                       bond->dev->name, new_value);
                ret = -EINVAL;
                goto out;
@@ -1075,40 +1023,31 @@ static ssize_t bonding_store_miimon(struct device *d,
        struct bonding *bond = to_bond(d);
 
        if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err(DRV_NAME
-                      ": %s: no miimon value specified.\n",
+               pr_err("%s: no miimon value specified.\n",
                       bond->dev->name);
                ret = -EINVAL;
                goto out;
        }
        if (new_value < 0) {
-               pr_err(DRV_NAME
-                      ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n",
+               pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n",
                       bond->dev->name, new_value, 1, INT_MAX);
                ret = -EINVAL;
                goto out;
        } else {
-               pr_info(DRV_NAME
-                      ": %s: Setting MII monitoring interval to %d.\n",
-                      bond->dev->name, new_value);
+               pr_info("%s: Setting MII monitoring interval to %d.\n",
+                       bond->dev->name, new_value);
                bond->params.miimon = new_value;
                if (bond->params.updelay)
-                       pr_info(DRV_NAME
-                             ": %s: Note: Updating updelay (to %d) "
-                             "since it is a multiple of the miimon value.\n",
-                             bond->dev->name,
-                             bond->params.updelay * bond->params.miimon);
+                       pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n",
+                               bond->dev->name,
+                               bond->params.updelay * bond->params.miimon);
                if (bond->params.downdelay)
-                       pr_info(DRV_NAME
-                             ": %s: Note: Updating downdelay (to %d) "
-                             "since it is a multiple of the miimon value.\n",
-                             bond->dev->name,
-                             bond->params.downdelay * bond->params.miimon);
+                       pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n",
+                               bond->dev->name,
+                               bond->params.downdelay * bond->params.miimon);
                if (bond->params.arp_interval) {
-                       pr_info(DRV_NAME
-                              ": %s: MII monitoring cannot be used with "
-                              "ARP monitoring. Disabling ARP monitoring...\n",
-                              bond->dev->name);
+                       pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n",
+                               bond->dev->name);
                        bond->params.arp_interval = 0;
                        bond->dev->priv_flags &= ~IFF_MASTER_ARPMON;
                        if (bond->params.arp_validate) {
@@ -1176,17 +1115,15 @@ static ssize_t bonding_store_primary(struct device *d,
        write_lock_bh(&bond->curr_slave_lock);
 
        if (!USES_PRIMARY(bond->params.mode)) {
-               pr_info(DRV_NAME
-                      ": %s: Unable to set primary slave; %s is in mode %d\n",
-                      bond->dev->name, bond->dev->name, bond->params.mode);
+               pr_info("%s: Unable to set primary slave; %s is in mode %d\n",
+                       bond->dev->name, bond->dev->name, bond->params.mode);
        } else {
                bond_for_each_slave(bond, slave, i) {
                        if (strnicmp
                            (slave->dev->name, buf,
                             strlen(slave->dev->name)) == 0) {
-                               pr_info(DRV_NAME
-                                      ": %s: Setting %s as primary slave.\n",
-                                      bond->dev->name, slave->dev->name);
+                               pr_info("%s: Setting %s as primary slave.\n",
+                                       bond->dev->name, slave->dev->name);
                                bond->primary_slave = slave;
                                strcpy(bond->params.primary, slave->dev->name);
                                bond_select_active_slave(bond);
@@ -1197,15 +1134,13 @@ static ssize_t bonding_store_primary(struct device *d,
                /* if we got here, then we didn't match the name of any slave */
 
                if (strlen(buf) == 0 || buf[0] == '\n') {
-                       pr_info(DRV_NAME
-                              ": %s: Setting primary slave to None.\n",
-                              bond->dev->name);
+                       pr_info("%s: Setting primary slave to None.\n",
+                               bond->dev->name);
                        bond->primary_slave = NULL;
                                bond_select_active_slave(bond);
                } else {
-                       pr_info(DRV_NAME
-                              ": %s: Unable to set %.*s as primary slave as it is not a slave.\n",
-                              bond->dev->name, (int)strlen(buf) - 1, buf);
+                       pr_info("%s: Unable to set %.*s as primary slave as it is not a slave.\n",
+                               bond->dev->name, (int)strlen(buf) - 1, buf);
                }
        }
 out:
@@ -1244,8 +1179,7 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
 
        new_value = bond_parse_parm(buf, pri_reselect_tbl);
        if (new_value < 0)  {
-               pr_err(DRV_NAME
-                      ": %s: Ignoring invalid primary_reselect value %.*s.\n",
+               pr_err("%s: Ignoring invalid primary_reselect value %.*s.\n",
                       bond->dev->name,
                       (int) strlen(buf) - 1, buf);
                ret = -EINVAL;
@@ -1253,7 +1187,7 @@ static ssize_t bonding_store_primary_reselect(struct device *d,
        }
 
        bond->params.primary_reselect = new_value;
-       pr_info(DRV_NAME ": %s: setting primary_reselect to %s (%d).\n",
+       pr_info("%s: setting primary_reselect to %s (%d).\n",
                bond->dev->name, pri_reselect_tbl[new_value].modename,
                new_value);
 
@@ -1291,20 +1225,18 @@ static ssize_t bonding_store_carrier(struct device *d,
 
 
        if (sscanf(buf, "%d", &new_value) != 1) {
-               pr_err(DRV_NAME
-                      ": %s: no use_carrier value specified.\n",
+               pr_err("%s: no use_carrier value specified.\n",
                       bond->dev->name);
                ret = -EINVAL;
                goto out;
        }
        if ((new_value == 0) || (new_value == 1)) {
                bond->params.use_carrier = new_value;
-               pr_info(DRV_NAME ": %s: Setting use_carrier to %d.\n",
-                      bond->dev->name, new_value);
+               pr_info("%s: Setting use_carrier to %d.\n",
+                       bond->dev->name, new_value);
        } else {
-               pr_info(DRV_NAME
-                      ": %s: Ignoring invalid use_carrier value %d.\n",
-                      bond->dev->name, new_value);
+               pr_info("%s: Ignoring invalid use_carrier value %d.\n",
+                       bond->dev->name, new_value);
        }
 out:
        return count;
@@ -1349,8 +1281,7 @@ static ssize_t bonding_store_active_slave(struct device *d,
        write_lock_bh(&bond->curr_slave_lock);
 
        if (!USES_PRIMARY(bond->params.mode))
-               pr_info(DRV_NAME ": %s: Unable to change active slave;"
-                       " %s is in mode %d\n",
+               pr_info("%s: Unable to change active slave; %s is in mode %d\n",
                        bond->dev->name, bond->dev->name, bond->params.mode);
        else {
                bond_for_each_slave(bond, slave, i) {
@@ -1361,9 +1292,9 @@ static ssize_t bonding_store_active_slave(struct device *d,
                                new_active = slave;
                                if (new_active == old_active) {
                                        /* do nothing */
-                                       pr_info(DRV_NAME
-                                               ": %s: %s is already the current active slave.\n",
-                                               bond->dev->name, slave->dev->name);
+                                       pr_info("%s: %s is already the current active slave.\n",
+                                               bond->dev->name,
+                                               slave->dev->name);
                                        goto out;
                                }
                                else {
@@ -1371,16 +1302,15 @@ static ssize_t bonding_store_active_slave(struct device *d,
                                            (old_active) &&
                                            (new_active->link == BOND_LINK_UP) &&
                                            IS_UP(new_active->dev)) {
-                                               pr_info(DRV_NAME
-                                                       ": %s: Setting %s as active slave.\n",
-                                                       bond->dev->name, slave->dev->name);
+                                               pr_info("%s: Setting %s as active slave.\n",
+                                                       bond->dev->name,
+                                                       slave->dev->name);
                                                        bond_change_active_slave(bond, new_active);
                                        }
                                        else {
-                                               pr_info(DRV_NAME
-                                                       ": %s: Could not set %s as active slave; "
-                                                       "either %s is down or the link is down.\n",
-                                                       bond->dev->name, slave->dev->name,
+                                               pr_info("%s: Could not set %s as active slave; either %s is down or the link is down.\n",
+                                                       bond->dev->name,
+                                                       slave->dev->name,
                                                        slave->dev->name);
                                        }
                                        goto out;
@@ -1391,14 +1321,12 @@ static ssize_t bonding_store_active_slave(struct device *d,
                /* if we got here, then we didn't match the name of any slave */
 
                if (strlen(buf) == 0 || buf[0] == '\n') {
-                       pr_info(DRV_NAME
-                               ": %s: Setting active slave to None.\n",
+                       pr_info("%s: Setting active slave to None.\n",
                                bond->dev->name);
                        bond->primary_slave = NULL;
                        bond_select_active_slave(bond);
                } else {
-                       pr_info(DRV_NAME ": %s: Unable to set %.*s"
-                               " as active slave as it is not a slave.\n",
+                       pr_info("%s: Unable to set %.*s as active slave as it is not a slave.\n",
                                bond->dev->name, (int)strlen(buf) - 1, buf);
                }
        }
@@ -1600,8 +1528,7 @@ int bond_create_sysfs(void)
                /* Is someone being kinky and naming a device bonding_master? */
                if (__dev_get_by_name(&init_net,
                                      class_attr_bonding_masters.attr.name))
-                       pr_err("network device named %s already "
-                              "exists in sysfs",
+                       pr_err("network device named %s already exists in sysfs",
                               class_attr_bonding_masters.attr.name);
                ret = 0;
        }
index 8c485aad1b94007ca98ff8cc6db39ba2f19f44f8..05b751719bd5dd4634b7a1234291cc764fbd82ec 100644 (file)
@@ -50,7 +50,7 @@ config CAN_TI_HECC
 
 config CAN_MCP251X
        tristate "Microchip MCP251x SPI CAN controllers"
-       depends on CAN_DEV && SPI
+       depends on CAN_DEV && SPI && HAS_DMA
        ---help---
          Driver for the Microchip MCP251x SPI CAN controllers.
 
index cbe3fce53e3b108df0be08b4e96929438289516e..166cc7e579c0a8c1eaadc9193dffdfedac0a6b82 100644 (file)
@@ -474,7 +474,7 @@ static void at91_read_mb(struct net_device *dev, unsigned int mb,
        reg_msr = at91_read(priv, AT91_MSR(mb));
        if (reg_msr & AT91_MSR_MRTR)
                cf->can_id |= CAN_RTR_FLAG;
-       cf->can_dlc = min_t(__u8, (reg_msr >> 16) & 0xf, 8);
+       cf->can_dlc = get_can_dlc((reg_msr >> 16) & 0xf);
 
        *(u32 *)(cf->data + 0) = at91_read(priv, AT91_MDL(mb));
        *(u32 *)(cf->data + 4) = at91_read(priv, AT91_MDH(mb));
@@ -1037,7 +1037,7 @@ static int __init at91_can_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
-       if (!res || !irq) {
+       if (!res || irq <= 0) {
                err = -ENODEV;
                goto exit_put;
        }
index c7fc1de28173527157711881666067fc20cb996b..0ec1524523ccaa939988d3d0c1f55bcd3450114f 100644 (file)
@@ -392,7 +392,7 @@ static void bfin_can_rx(struct net_device *dev, u16 isrc)
                cf->can_id |= CAN_RTR_FLAG;
 
        /* get data length code */
-       cf->can_dlc = bfin_read16(&reg->chl[obj].dlc);
+       cf->can_dlc = get_can_dlc(bfin_read16(&reg->chl[obj].dlc) & 0xF);
 
        /* get payload */
        for (i = 0; i < 8; i += 2) {
index 78b1b69b29211d8dc6a0d365839b22e191bcb215..9c5a1537939ce5c5ce4a3f6950686c66389ea1a3 100644 (file)
@@ -403,9 +403,8 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
 
                for (i = 1; i < RXBDAT_OFF; i++)
                        buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
-               len = buf[RXBDLC_OFF] & RXBDLC_LEN_MASK;
-               if (len > 8)
-                       len = 8;
+
+               len = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
                for (; i < (RXBDAT_OFF + len); i++)
                        buf[i] = mcp251x_read_reg(spi, RXBCTRL(buf_idx) + i);
        } else {
@@ -455,13 +454,7 @@ static void mcp251x_hw_rx(struct spi_device *spi, int buf_idx)
                        (buf[RXBSIDL_OFF] >> RXBSIDL_SHIFT);
        }
        /* Data length */
-       frame->can_dlc = buf[RXBDLC_OFF] & RXBDLC_LEN_MASK;
-       if (frame->can_dlc > 8) {
-               dev_warn(&spi->dev, "invalid frame recevied\n");
-               priv->net->stats.rx_errors++;
-               dev_kfree_skb(skb);
-               return;
-       }
+       frame->can_dlc = get_can_dlc(buf[RXBDLC_OFF] & RXBDLC_LEN_MASK);
        memcpy(frame->data, buf + RXBDAT_OFF, frame->can_dlc);
 
        priv->net->stats.rx_packets++;
index bb06dfb58f2541bb60fff71e84ff2d7042f78cfd..07346f880ca680e49668f7dc783bf734b5dbd157 100644 (file)
@@ -297,7 +297,8 @@ static void mscan_get_rx_frame(struct net_device *dev, struct can_frame *frame)
        frame->can_id |= can_id >> 1;
        if (can_id & 1)
                frame->can_id |= CAN_RTR_FLAG;
-       frame->can_dlc = in_8(&regs->rx.dlr) & 0xf;
+
+       frame->can_dlc = get_can_dlc(in_8(&regs->rx.dlr) & 0xf);
 
        if (!(frame->can_id & CAN_RTR_FLAG)) {
                void __iomem *data = &regs->rx.dsr1_0;
index b4ba88a3107571b65c53ecdae9011b7f6bd8a1c1..542a4f7255b4f5db367ef755abb623aed752c9b1 100644 (file)
@@ -293,15 +293,14 @@ static void sja1000_rx(struct net_device *dev)
        uint8_t fi;
        uint8_t dreg;
        canid_t id;
-       uint8_t dlc;
        int i;
 
+       /* create zero'ed CAN frame buffer */
        skb = alloc_can_skb(dev, &cf);
        if (skb == NULL)
                return;
 
        fi = priv->read_reg(priv, REG_FI);
-       dlc = fi & 0x0F;
 
        if (fi & FI_FF) {
                /* extended frame format (EFF) */
@@ -318,16 +317,15 @@ static void sja1000_rx(struct net_device *dev)
                    | (priv->read_reg(priv, REG_ID2) >> 5);
        }
 
-       if (fi & FI_RTR)
+       if (fi & FI_RTR) {
                id |= CAN_RTR_FLAG;
+       } else {
+               cf->can_dlc = get_can_dlc(fi & 0x0F);
+               for (i = 0; i < cf->can_dlc; i++)
+                       cf->data[i] = priv->read_reg(priv, dreg++);
+       }
 
        cf->can_id = id;
-       cf->can_dlc = dlc;
-       for (i = 0; i < dlc; i++)
-               cf->data[i] = priv->read_reg(priv, dreg++);
-
-       while (i < 8)
-               cf->data[i++] = 0;
 
        /* release receive buffer */
        priv->write_reg(priv, REG_CMR, CMD_RRB);
@@ -335,7 +333,7 @@ static void sja1000_rx(struct net_device *dev)
        netif_rx(skb);
 
        stats->rx_packets++;
-       stats->rx_bytes += dlc;
+       stats->rx_bytes += cf->can_dlc;
 }
 
 static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
index 07e8016b17eca24f79e9e862f73d5f85e8ce4e94..5c993c2da5281b24c74434ad54ccb0862fa9bc72 100644 (file)
@@ -552,7 +552,7 @@ static int ti_hecc_rx_pkt(struct ti_hecc_priv *priv, int mbxno)
        data = hecc_read_mbx(priv, mbxno, HECC_CANMCF);
        if (data & HECC_CANMCF_RTR)
                cf->can_id |= CAN_RTR_FLAG;
-       cf->can_dlc = data & 0xF;
+       cf->can_dlc = get_can_dlc(data & 0xF);
        data = hecc_read_mbx(priv, mbxno, HECC_CANMDL);
        *(u32 *)(cf->data) = cpu_to_be32(data);
        if (cf->can_dlc > 4) {
index 591eb0eb1c2bdcc5ec147173a41829bd497c093b..efbb05c71bf47fdde6af69fb13d1a38fdd80f032 100644 (file)
@@ -316,7 +316,7 @@ static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg)
                return;
 
        cf->can_id = le32_to_cpu(msg->msg.can_msg.id);
-       cf->can_dlc = min_t(u8, msg->msg.can_msg.length, 8);
+       cf->can_dlc = get_can_dlc(msg->msg.can_msg.length & 0xF);
 
        if (msg->type == CPC_MSG_TYPE_EXT_CAN_FRAME ||
            msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME)
index 678222389407b91ba0073780e18c7c04c10dde4a..8d0be26f94e3b61229721d7e8d95529d929549f7 100644 (file)
@@ -1163,7 +1163,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
        priv->dev = dev;
        priv->ring_size = 64;
        priv->msg_enable = netif_msg_init(debug_level, 0xff);
-       memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
+       memcpy(dev->dev_addr, pdata->dev_addr, sizeof(pdata->dev_addr));
 
        snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
 
index 8edac8915ea8ee27e3c14f4511bda8cb80d9654c..34e03104c3c16de1d7f9ebcd709caf110eff3112 100644 (file)
@@ -2272,7 +2272,7 @@ static int emac_mii_reset(struct mii_bus *bus)
        unsigned int clk_div;
        int mdio_bus_freq = emac_bus_frequency;
 
-       if (mdio_max_freq & mdio_bus_freq)
+       if (mdio_max_freq && mdio_bus_freq)
                clk_div = ((mdio_bus_freq / mdio_max_freq) - 1);
        else
                clk_div = 0xFF;
index 0cbe3c0e7c065b181ebaa725e5f18e6711c454f8..b377300656889cd9db9a2242bcc213611798cd91 100644 (file)
@@ -1646,7 +1646,7 @@ dm9000_drv_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops dm9000_drv_pm_ops = {
+static const struct dev_pm_ops dm9000_drv_pm_ops = {
        .suspend        = dm9000_drv_suspend,
        .resume         = dm9000_drv_resume,
 };
index 929701ca07d31bf1aedbcb7e54a9ba93bc6db654..839fb2b136d37bd9993cbfe42d44ddcffec90e2c 100644 (file)
@@ -1829,6 +1829,7 @@ static int e100_alloc_cbs(struct nic *nic)
                                  &nic->cbs_dma_addr);
        if (!nic->cbs)
                return -ENOMEM;
+       memset(nic->cbs, 0, count * sizeof(struct cb));
 
        for (cb = nic->cbs, i = 0; i < count; cb++, i++) {
                cb->next = (i + 1 < count) ? cb + 1 : nic->cbs;
@@ -1837,7 +1838,6 @@ static int e100_alloc_cbs(struct nic *nic)
                cb->dma_addr = nic->cbs_dma_addr + i * sizeof(struct cb);
                cb->link = cpu_to_le32(nic->cbs_dma_addr +
                        ((i+1) % count) * sizeof(struct cb));
-               cb->skb = NULL;
        }
 
        nic->cb_to_use = nic->cb_to_send = nic->cb_to_clean = nic->cbs;
index c1a42cfc80baf65db08b771e43d97bc427128819..b979464091bb1cba01db7ebf477de6e442e4ab19 100644 (file)
@@ -1290,7 +1290,6 @@ static s32 e1000_setup_link_82571(struct e1000_hw *hw)
 static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
 {
        u32 ctrl;
-       u32 led_ctrl;
        s32 ret_val;
 
        ctrl = er32(CTRL);
@@ -1305,11 +1304,6 @@ static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw)
                break;
        case e1000_phy_igp_2:
                ret_val = e1000e_copper_link_setup_igp(hw);
-               /* Setup activity LED */
-               led_ctrl = er32(LEDCTL);
-               led_ctrl &= IGP_ACTIVITY_LED_MASK;
-               led_ctrl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
-               ew32(LEDCTL, led_ctrl);
                break;
        default:
                return -E1000_ERR_PHY;
index 6850dc0a7b9194c34807762eccb2d7d04a4a007c..8bd3c9f17532529e6f3c445024f9e5e4c8d6ac96 100644 (file)
@@ -143,7 +143,6 @@ void gfar_start(struct net_device *dev);
 static void gfar_clear_exact_match(struct net_device *dev);
 static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr);
 static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-u16 gfar_select_queue(struct net_device *dev, struct sk_buff *skb);
 
 MODULE_AUTHOR("Freescale Semiconductor, Inc");
 MODULE_DESCRIPTION("Gianfar Ethernet Driver");
@@ -357,8 +356,11 @@ static void gfar_init_mac(struct net_device *ndev)
        /* Configure the coalescing support */
        gfar_configure_coalescing(priv, 0xFF, 0xFF);
 
-       if (priv->rx_filer_enable)
+       if (priv->rx_filer_enable) {
                rctrl |= RCTRL_FILREN;
+               /* Program the RIR0 reg with the required distribution */
+               gfar_write(&regs->rir0, DEFAULT_RIR0);
+       }
 
        if (priv->rx_csum_enable)
                rctrl |= RCTRL_CHECKSUMMING;
@@ -414,6 +416,36 @@ static void gfar_init_mac(struct net_device *ndev)
        gfar_write(&regs->fifo_tx_starve_shutoff, priv->fifo_starve_off);
 }
 
+static struct net_device_stats *gfar_get_stats(struct net_device *dev)
+{
+       struct gfar_private *priv = netdev_priv(dev);
+       struct netdev_queue *txq;
+       unsigned long rx_packets = 0, rx_bytes = 0, rx_dropped = 0;
+       unsigned long tx_packets = 0, tx_bytes = 0;
+       int i = 0;
+
+       for (i = 0; i < priv->num_rx_queues; i++) {
+               rx_packets += priv->rx_queue[i]->stats.rx_packets;
+               rx_bytes += priv->rx_queue[i]->stats.rx_bytes;
+               rx_dropped += priv->rx_queue[i]->stats.rx_dropped;
+       }
+
+       dev->stats.rx_packets = rx_packets;
+       dev->stats.rx_bytes = rx_bytes;
+       dev->stats.rx_dropped = rx_dropped;
+
+       for (i = 0; i < priv->num_tx_queues; i++) {
+               txq = netdev_get_tx_queue(dev, i);
+               tx_bytes += txq->tx_bytes;
+               tx_packets += txq->tx_packets;
+       }
+
+       dev->stats.tx_bytes = tx_bytes;
+       dev->stats.tx_packets = tx_packets;
+
+       return &dev->stats;
+}
+
 static const struct net_device_ops gfar_netdev_ops = {
        .ndo_open = gfar_enet_open,
        .ndo_start_xmit = gfar_start_xmit,
@@ -422,7 +454,7 @@ static const struct net_device_ops gfar_netdev_ops = {
        .ndo_set_multicast_list = gfar_set_multi,
        .ndo_tx_timeout = gfar_timeout,
        .ndo_do_ioctl = gfar_ioctl,
-       .ndo_select_queue = gfar_select_queue,
+       .ndo_get_stats = gfar_get_stats,
        .ndo_vlan_rx_register = gfar_vlan_rx_register,
        .ndo_set_mac_address = eth_mac_addr,
        .ndo_validate_addr = eth_validate_addr,
@@ -472,10 +504,6 @@ static inline int gfar_uses_fcb(struct gfar_private *priv)
        return priv->vlgrp || priv->rx_csum_enable;
 }
 
-u16 gfar_select_queue(struct net_device *dev, struct sk_buff *skb)
-{
-       return skb_get_queue_mapping(skb);
-}
 static void free_tx_pointers(struct gfar_private *priv)
 {
        int i = 0;
@@ -1022,6 +1050,9 @@ static int gfar_probe(struct of_device *ofdev,
                priv->rx_queue[i]->rxic = DEFAULT_RXIC;
        }
 
+       /* enable filer if using multiple RX queues*/
+       if(priv->num_rx_queues > 1)
+               priv->rx_filer_enable = 1;
        /* Enable most messages by default */
        priv->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1;
 
@@ -1937,7 +1968,8 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 
        /* Update transmit stats */
-       dev->stats.tx_bytes += skb->len;
+       txq->tx_bytes += skb->len;
+       txq->tx_packets ++;
 
        txbdp = txbdp_start = tx_queue->cur_tx;
 
@@ -2295,8 +2327,6 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
        tx_queue->skb_dirtytx = skb_dirtytx;
        tx_queue->dirty_tx = bdp;
 
-       dev->stats.tx_packets += howmany;
-
        return howmany;
 }
 
@@ -2434,10 +2464,11 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
        fcb = (struct rxfcb *)skb->data;
 
        /* Remove the FCB from the skb */
-       skb_set_queue_mapping(skb, fcb->rq);
        /* Remove the padded bytes, if there are any */
-       if (amount_pull)
+       if (amount_pull) {
+               skb_record_rx_queue(skb, fcb->rq);
                skb_pull(skb, amount_pull);
+       }
 
        if (priv->rx_csum_enable)
                gfar_rx_checksum(skb, fcb);
@@ -2510,22 +2541,22 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
                        }
                } else {
                        /* Increment the number of packets */
-                       dev->stats.rx_packets++;
+                       rx_queue->stats.rx_packets++;
                        howmany++;
 
                        if (likely(skb)) {
                                pkt_len = bdp->length - ETH_FCS_LEN;
                                /* Remove the FCS from the packet length */
                                skb_put(skb, pkt_len);
-                               dev->stats.rx_bytes += pkt_len;
-
+                               rx_queue->stats.rx_bytes += pkt_len;
+                               skb_record_rx_queue(skb, rx_queue->qindex);
                                gfar_process_frame(dev, skb, amount_pull);
 
                        } else {
                                if (netif_msg_rx_err(priv))
                                        printk(KERN_WARNING
                                               "%s: Missing skb!\n", dev->name);
-                               dev->stats.rx_dropped++;
+                               rx_queue->stats.rx_dropped++;
                                priv->extra_stats.rx_skbmissing++;
                        }
 
index cbb451011cb5475ecf61cfebfcd014d6bdb67a87..3d72dc43dca56bdbaba7a510e4e9cb624aa8044f 100644 (file)
@@ -333,7 +333,7 @@ extern const char gfar_driver_version[];
 #define IMASK_BSY               0x20000000
 #define IMASK_EBERR             0x10000000
 #define IMASK_MSRO             0x04000000
-#define IMASK_GRSC              0x02000000
+#define IMASK_GTSC              0x02000000
 #define IMASK_BABT             0x01000000
 #define IMASK_TXC               0x00800000
 #define IMASK_TXEEN            0x00400000
@@ -344,7 +344,7 @@ extern const char gfar_driver_version[];
 #define IMASK_XFUN             0x00010000
 #define IMASK_RXB0              0x00008000
 #define IMASK_MAG              0x00000800
-#define IMASK_GTSC              0x00000100
+#define IMASK_GRSC              0x00000100
 #define IMASK_RXFEN0           0x00000080
 #define IMASK_FIR              0x00000008
 #define IMASK_FIQ              0x00000004
@@ -401,6 +401,10 @@ extern const char gfar_driver_version[];
 #define FPR_FILER_MASK 0xFFFFFFFF
 #define MAX_FILER_IDX  0xFF
 
+/* This default RIR value directly corresponds
+ * to the 3-bit hash value generated */
+#define DEFAULT_RIR0   0x05397700
+
 /* RQFCR register bits */
 #define RQFCR_GPI              0x80000000
 #define RQFCR_HASHTBL_Q                0x00000000
@@ -936,6 +940,15 @@ struct gfar_priv_tx_q {
        unsigned short txtime;
 };
 
+/*
+ * Per RX queue stats
+ */
+struct rx_q_stats {
+       unsigned long rx_packets;
+       unsigned long rx_bytes;
+       unsigned long rx_dropped;
+};
+
 /**
  *     struct gfar_priv_rx_q - per rx queue structure
  *     @rxlock: per queue rx spin lock
@@ -958,6 +971,7 @@ struct gfar_priv_rx_q {
        struct  rxbd8 *cur_rx;
        struct  net_device *dev;
        struct gfar_priv_grp *grp;
+       struct rx_q_stats stats;
        u16     skb_currx;
        u16     qindex;
        unsigned int    rx_ring_size;
index 090a6d3af11212caefdb8abe794aa063d12b0823..052c74091d91065c6c419149361a92cfad6cb844 100644 (file)
@@ -87,6 +87,7 @@ History:
 #include <linux/module.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/if_ether.h>
 #include <linux/skbuff.h>
 #include <linux/bitops.h>
 
@@ -988,7 +989,7 @@ static int __devinit ibmlana_init_one(struct device *kdev)
 
        /* copy out MAC address */
 
-       for (z = 0; z < sizeof(dev->dev_addr); z++)
+       for (z = 0; z < ETH_ALEN; z++)
                dev->dev_addr[z] = inb(dev->base_addr + MACADDRPROM + z);
 
        /* print config */
index e8e9e9194a8825c29cb9008e49c566b8e873be12..c505b50d1fa32930164a250f82cd9d749bdaec98 100644 (file)
@@ -1096,9 +1096,7 @@ static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw)
                hw_dbg("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg);
        } else {
                /* Set PCS register for forced link */
-               reg |= E1000_PCS_LCTL_FSD |        /* Force Speed */
-                      E1000_PCS_LCTL_FORCE_LINK | /* Force Link */
-                      E1000_PCS_LCTL_FLV_LINK_UP; /* Force link value up */
+               reg |= E1000_PCS_LCTL_FSD;        /* Force Speed */
 
                hw_dbg("Configuring Forced Link:PCS_LCTL=0x%08X\n", reg);
        }
index 5c9d73e9bb8d8733fe926bf6c9d7c9073fe5c35a..3670a66401b87923d5ff3dc82cc67f1701cc4986 100644 (file)
@@ -457,15 +457,6 @@ s32 igb_copper_link_setup_82580(struct e1000_hw *hw)
        phy_data |= I82580_CFG_ENABLE_DOWNSHIFT;
 
        ret_val = phy->ops.write_reg(hw, I82580_CFG_REG, phy_data);
-       if (ret_val)
-               goto out;
-
-       /* Set number of link attempts before downshift */
-       ret_val = phy->ops.read_reg(hw, I82580_CTRL_REG, &phy_data);
-       if (ret_val)
-               goto out;
-       phy_data &= ~I82580_CTRL_DOWNSHIFT_MASK;
-       ret_val = phy->ops.write_reg(hw, I82580_CTRL_REG, phy_data);
 
 out:
        return ret_val;
index ac9d5272650dbee362ded07308ea8cac651bab32..f771a6c08777c8438db7f25e37e388089464ccae 100644 (file)
@@ -1795,7 +1795,7 @@ static int igb_wol_exclusion(struct igb_adapter *adapter,
                /* dual port cards only support WoL on port A from now on
                 * unless it was enabled in the eeprom for port B
                 * so exclude FUNC_1 ports from having WoL enabled */
-               if (rd32(E1000_STATUS) & E1000_STATUS_FUNC_1 &&
+               if ((rd32(E1000_STATUS) & E1000_STATUS_FUNC_MASK) &&
                    !adapter->eeprom_wol) {
                        wol->supported = 0;
                        break;
index 78963a0e128dcf4171c9d8a8d1ac579c0b529d15..933c64ff24657d362a2d3e34cb1c525c04826bb6 100644 (file)
@@ -1306,13 +1306,8 @@ void igb_reset(struct igb_adapter *adapter)
        hwm = min(((pba << 10) * 9 / 10),
                        ((pba << 10) - 2 * adapter->max_frame_size));
 
-       if (mac->type < e1000_82576) {
-               fc->high_water = hwm & 0xFFF8;  /* 8-byte granularity */
-               fc->low_water = fc->high_water - 8;
-       } else {
-               fc->high_water = hwm & 0xFFF0;  /* 16-byte granularity */
-               fc->low_water = fc->high_water - 16;
-       }
+       fc->high_water = hwm & 0xFFF0;  /* 16-byte granularity */
+       fc->low_water = fc->high_water - 16;
        fc->pause_time = 0xFFFF;
        fc->send_xon = 1;
        fc->current_mode = fc->requested_mode;
index e9dd95f136aa8432d1542fc344a19cd0acdf3abb..0dbd0320023acf47ff36f2b97fe434b567cfc414 100644 (file)
@@ -2763,7 +2763,8 @@ static int __devinit igbvf_probe(struct pci_dev *pdev,
        err = hw->mac.ops.reset_hw(hw);
        if (err) {
                dev_info(&pdev->dev,
-                        "PF still in reset state, assigning new address\n");
+                        "PF still in reset state, assigning new address."
+                        " Is the PF interface up?\n");
                random_ether_addr(hw->mac.addr);
        } else {
                err = hw->mac.ops.read_mac_addr(hw);
index e2d5343f127553d7ad7c5d4b032bd087f66db990..204177d78cecfc1479ae867d0e40709ec2297ec1 100644 (file)
@@ -509,6 +509,40 @@ static s32 ixgbe_start_mac_link_82598(struct ixgbe_hw *hw,
        return status;
 }
 
+/**
+ *  ixgbe_validate_link_ready - Function looks for phy link
+ *  @hw: pointer to hardware structure
+ *
+ *  Function indicates success when phy link is available. If phy is not ready
+ *  within 5 seconds of MAC indicating link, the function returns error.
+ **/
+static s32 ixgbe_validate_link_ready(struct ixgbe_hw *hw)
+{
+       u32 timeout;
+       u16 an_reg;
+
+       if (hw->device_id != IXGBE_DEV_ID_82598AT2)
+               return 0;
+
+       for (timeout = 0;
+            timeout < IXGBE_VALIDATE_LINK_READY_TIMEOUT; timeout++) {
+               hw->phy.ops.read_reg(hw, MDIO_STAT1, MDIO_MMD_AN, &an_reg);
+
+               if ((an_reg & MDIO_AN_STAT1_COMPLETE) &&
+                   (an_reg & MDIO_STAT1_LSTATUS))
+                       break;
+
+               msleep(100);
+       }
+
+       if (timeout == IXGBE_VALIDATE_LINK_READY_TIMEOUT) {
+               hw_dbg(hw, "Link was indicated but link is down\n");
+               return IXGBE_ERR_LINK_SETUP;
+       }
+
+       return 0;
+}
+
 /**
  *  ixgbe_check_mac_link_82598 - Get link/speed status
  *  @hw: pointer to hardware structure
@@ -589,6 +623,10 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
        else
                *speed = IXGBE_LINK_SPEED_1GB_FULL;
 
+       if ((hw->device_id == IXGBE_DEV_ID_82598AT2) && (*link_up == true) &&
+           (ixgbe_validate_link_ready(hw) != 0))
+               *link_up = false;
+
        /* if link is down, zero out the current_mode */
        if (*link_up == false) {
                hw->fc.current_mode = ixgbe_fc_none;
index 35ea8c93fd809b082c78e035aaa2b7c31966bd0c..1a2ea621e3716d35fa4ed28853b5af66ac2ebdea 100644 (file)
@@ -4373,6 +4373,11 @@ static int ixgbe_resume(struct pci_dev *pdev)
 
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
+       /*
+        * pci_restore_state clears dev->state_saved so call
+        * pci_save_state to restore it.
+        */
+       pci_save_state(pdev);
 
        err = pci_enable_device_mem(pdev);
        if (err) {
@@ -4511,6 +4516,7 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
        struct ixgbe_hw *hw = &adapter->hw;
        u64 total_mpc = 0;
        u32 i, missed_rx = 0, mpc, bprc, lxon, lxoff, xon_off_tot;
+       u64 non_eop_descs = 0, restart_queue = 0;
 
        if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
                u64 rsc_count = 0;
@@ -4528,10 +4534,12 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
 
        /* gather some stats to the adapter struct that are per queue */
        for (i = 0; i < adapter->num_tx_queues; i++)
-               adapter->restart_queue += adapter->tx_ring[i].restart_queue;
+               restart_queue += adapter->tx_ring[i].restart_queue;
+       adapter->restart_queue = restart_queue;
 
        for (i = 0; i < adapter->num_rx_queues; i++)
-               adapter->non_eop_descs += adapter->tx_ring[i].non_eop_descs;
+               non_eop_descs += adapter->rx_ring[i].non_eop_descs;
+       adapter->non_eop_descs = non_eop_descs;
 
        adapter->stats.crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
        for (i = 0; i < 8; i++) {
@@ -5003,7 +5011,18 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter,
                                    IXGBE_ADVTXD_DTYP_CTXT);
 
                if (skb->ip_summed == CHECKSUM_PARTIAL) {
-                       switch (skb->protocol) {
+                       __be16 protocol;
+
+                       if (skb->protocol == cpu_to_be16(ETH_P_8021Q)) {
+                               const struct vlan_ethhdr *vhdr =
+                                       (const struct vlan_ethhdr *)skb->data;
+
+                               protocol = vhdr->h_vlan_encapsulated_proto;
+                       } else {
+                               protocol = skb->protocol;
+                       }
+
+                       switch (protocol) {
                        case cpu_to_be16(ETH_P_IP):
                                type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV4;
                                if (ip_hdr(skb)->protocol == IPPROTO_TCP)
index f3e8d52610b7d57960dbbe835cdb7845ed05dc2f..84650c6ebe038bcfbebf872b1c56c4804ec50680 100644 (file)
 #define IXGBE_MPVC      0x04318
 #define IXGBE_SGMIIC    0x04314
 
+#define IXGBE_VALIDATE_LINK_READY_TIMEOUT 50
+
 /* Omer CORECTL */
 #define IXGBE_CORECTL           0x014F00
 /* BARCTRL */
index ad95d5f7b63054c6e2e17ff6647fb008179ea5cf..8c8515619b8e9b808aafbf08bdab91bb080bb17a 100644 (file)
@@ -72,35 +72,6 @@ void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj)
        mlx4_bitmap_free_range(bitmap, obj, 1);
 }
 
-static unsigned long find_aligned_range(unsigned long *bitmap,
-                                       u32 start, u32 nbits,
-                                       int len, int align)
-{
-       unsigned long end, i;
-
-again:
-       start = ALIGN(start, align);
-
-       while ((start < nbits) && test_bit(start, bitmap))
-               start += align;
-
-       if (start >= nbits)
-               return -1;
-
-       end = start+len;
-       if (end > nbits)
-               return -1;
-
-       for (i = start + 1; i < end; i++) {
-               if (test_bit(i, bitmap)) {
-                       start = i + 1;
-                       goto again;
-               }
-       }
-
-       return start;
-}
-
 u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align)
 {
        u32 obj, i;
@@ -110,13 +81,13 @@ u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align)
 
        spin_lock(&bitmap->lock);
 
-       obj = find_aligned_range(bitmap->table, bitmap->last,
-                                bitmap->max, cnt, align);
+       obj = bitmap_find_next_zero_area(bitmap->table, bitmap->max,
+                               bitmap->last, cnt, align - 1);
        if (obj >= bitmap->max) {
                bitmap->top = (bitmap->top + bitmap->max + bitmap->reserved_top)
                                & bitmap->mask;
-               obj = find_aligned_range(bitmap->table, 0, bitmap->max,
-                                        cnt, align);
+               obj = bitmap_find_next_zero_area(bitmap->table, bitmap->max,
+                                               0, cnt, align - 1);
        }
 
        if (obj < bitmap->max) {
index 3c16602172fc3ca1b9f40d1b302d2d4cf0512a5f..04f42ae1eda092d9650af5ef23d16a1b9efdbf52 100644 (file)
@@ -90,6 +90,7 @@ static void dump_dev_cap_flags(struct mlx4_dev *dev, u32 flags)
                [ 9] = "Q_Key violation counter",
                [10] = "VMM",
                [12] = "DPDP",
+               [15] = "Big LSO headers",
                [16] = "MW support",
                [17] = "APM support",
                [18] = "Atomic ops support",
@@ -235,7 +236,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_MPT_OFFSET);
        dev_cap->max_mpts = 1 << (field & 0x3f);
        MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_EQ_OFFSET);
-       dev_cap->reserved_eqs = 1 << (field & 0xf);
+       dev_cap->reserved_eqs = field & 0xf;
        MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_EQ_OFFSET);
        dev_cap->max_eqs = 1 << (field & 0xf);
        MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_MTT_OFFSET);
index f36ae691cab3c343091fb7130591c8737ab4afee..015fbe785c13304aab333759a4629250b531b8d9 100644 (file)
@@ -53,7 +53,7 @@ static int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
 
        if (out_param > 2) {
                mlx4_err(dev, "Sense returned illegal value: 0x%llx\n", out_param);
-               return EINVAL;
+               return -EINVAL;
        }
 
        *type = out_param;
index f4996846a234b0edd6bbc7bb8d49bb19e28ca4b2..6cae26a5bd6797e3cd82d07336a86e34d5d62701 100644 (file)
@@ -57,7 +57,9 @@ static int use_msi = 1;
 
 static int use_msi_x = 1;
 
-static unsigned long auto_fw_reset = AUTO_FW_RESET_ENABLED;
+static int auto_fw_reset = AUTO_FW_RESET_ENABLED;
+module_param(auto_fw_reset, int, 0644);
+MODULE_PARM_DESC(auto_fw_reset,"Auto firmware reset (0=disabled, 1=enabled");
 
 static int __devinit netxen_nic_probe(struct pci_dev *pdev,
                const struct pci_device_id *ent);
@@ -2534,42 +2536,6 @@ static struct bin_attribute bin_attr_mem = {
        .write = netxen_sysfs_write_mem,
 };
 
-#ifdef CONFIG_MODULES
-static ssize_t
-netxen_store_auto_fw_reset(struct module_attribute *mattr,
-               struct module *mod, const char *buf, size_t count)
-
-{
-       unsigned long new;
-
-       if (strict_strtoul(buf, 16, &new))
-               return -EINVAL;
-
-       if ((new == AUTO_FW_RESET_ENABLED) || (new == AUTO_FW_RESET_DISABLED)) {
-               auto_fw_reset = new;
-               return count;
-       }
-
-       return -EINVAL;
-}
-
-static ssize_t
-netxen_show_auto_fw_reset(struct module_attribute *mattr,
-               struct module *mod, char *buf)
-
-{
-       if (auto_fw_reset == AUTO_FW_RESET_ENABLED)
-               return sprintf(buf, "enabled\n");
-       else
-               return sprintf(buf, "disabled\n");
-}
-
-static struct module_attribute mod_attr_fw_reset = {
-       .attr = {.name = "auto_fw_reset", .mode = (S_IRUGO | S_IWUSR)},
-       .show = netxen_show_auto_fw_reset,
-       .store = netxen_store_auto_fw_reset,
-};
-#endif
 
 static void
 netxen_create_sysfs_entries(struct netxen_adapter *adapter)
@@ -2775,23 +2741,12 @@ static struct pci_driver netxen_driver = {
 
 static int __init netxen_init_module(void)
 {
-#ifdef CONFIG_MODULES
-       struct module *mod = THIS_MODULE;
-#endif
-
        printk(KERN_INFO "%s\n", netxen_nic_driver_string);
 
 #ifdef CONFIG_INET
        register_netdevice_notifier(&netxen_netdev_cb);
        register_inetaddr_notifier(&netxen_inetaddr_cb);
 #endif
-
-#ifdef CONFIG_MODULES
-       if (sysfs_create_file(&mod->mkobj.kobj, &mod_attr_fw_reset.attr))
-               printk(KERN_ERR "%s: Failed to create auto_fw_reset "
-                               "sysfs entry.", netxen_nic_driver_name);
-#endif
-
        return pci_register_driver(&netxen_driver);
 }
 
@@ -2799,12 +2754,6 @@ module_init(netxen_init_module);
 
 static void __exit netxen_exit_module(void)
 {
-#ifdef CONFIG_MODULES
-       struct module *mod = THIS_MODULE;
-
-       sysfs_remove_file(&mod->mkobj.kobj, &mod_attr_fw_reset.attr);
-#endif
-
        pci_unregister_driver(&netxen_driver);
 
 #ifdef CONFIG_INET
diff --git a/drivers/net/octeon/Kconfig b/drivers/net/octeon/Kconfig
new file mode 100644 (file)
index 0000000..1e56bbf
--- /dev/null
@@ -0,0 +1,10 @@
+config OCTEON_MGMT_ETHERNET
+       tristate "Octeon Management port ethernet driver (CN5XXX, CN6XXX)"
+       depends on  CPU_CAVIUM_OCTEON
+       select PHYLIB
+       select MDIO_OCTEON
+       default y
+       help
+         This option enables the ethernet driver for the management
+         port on Cavium Networks' Octeon CN57XX, CN56XX, CN55XX,
+         CN54XX, CN52XX, and CN6XXX chips.
diff --git a/drivers/net/octeon/Makefile b/drivers/net/octeon/Makefile
new file mode 100644 (file)
index 0000000..906edec
--- /dev/null
@@ -0,0 +1,2 @@
+
+obj-$(CONFIG_OCTEON_MGMT_ETHERNET)     += octeon_mgmt.o
diff --git a/drivers/net/octeon/octeon_mgmt.c b/drivers/net/octeon/octeon_mgmt.c
new file mode 100644 (file)
index 0000000..050538b
--- /dev/null
@@ -0,0 +1,1176 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2009 Cavium Networks
+ */
+
+#include <linux/capability.h>
+#include <linux/dma-mapping.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/if_vlan.h>
+#include <linux/phy.h>
+#include <linux/spinlock.h>
+
+#include <asm/octeon/octeon.h>
+#include <asm/octeon/cvmx-mixx-defs.h>
+#include <asm/octeon/cvmx-agl-defs.h>
+
+#define DRV_NAME "octeon_mgmt"
+#define DRV_VERSION "2.0"
+#define DRV_DESCRIPTION \
+       "Cavium Networks Octeon MII (management) port Network Driver"
+
+#define OCTEON_MGMT_NAPI_WEIGHT 16
+
+/*
+ * Ring sizes that are powers of two allow for more efficient modulo
+ * opertions.
+ */
+#define OCTEON_MGMT_RX_RING_SIZE 512
+#define OCTEON_MGMT_TX_RING_SIZE 128
+
+/* Allow 8 bytes for vlan and FCS. */
+#define OCTEON_MGMT_RX_HEADROOM (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN)
+
+union mgmt_port_ring_entry {
+       u64 d64;
+       struct {
+               u64    reserved_62_63:2;
+               /* Length of the buffer/packet in bytes */
+               u64    len:14;
+               /* For TX, signals that the packet should be timestamped */
+               u64    tstamp:1;
+               /* The RX error code */
+               u64    code:7;
+#define RING_ENTRY_CODE_DONE 0xf
+#define RING_ENTRY_CODE_MORE 0x10
+               /* Physical address of the buffer */
+               u64    addr:40;
+       } s;
+};
+
+struct octeon_mgmt {
+       struct net_device *netdev;
+       int port;
+       int irq;
+       u64 *tx_ring;
+       dma_addr_t tx_ring_handle;
+       unsigned int tx_next;
+       unsigned int tx_next_clean;
+       unsigned int tx_current_fill;
+       /* The tx_list lock also protects the ring related variables */
+       struct sk_buff_head tx_list;
+
+       /* RX variables only touched in napi_poll.  No locking necessary. */
+       u64 *rx_ring;
+       dma_addr_t rx_ring_handle;
+       unsigned int rx_next;
+       unsigned int rx_next_fill;
+       unsigned int rx_current_fill;
+       struct sk_buff_head rx_list;
+
+       spinlock_t lock;
+       unsigned int last_duplex;
+       unsigned int last_link;
+       struct device *dev;
+       struct napi_struct napi;
+       struct tasklet_struct tx_clean_tasklet;
+       struct phy_device *phydev;
+};
+
+static void octeon_mgmt_set_rx_irq(struct octeon_mgmt *p, int enable)
+{
+       int port = p->port;
+       union cvmx_mixx_intena mix_intena;
+       unsigned long flags;
+
+       spin_lock_irqsave(&p->lock, flags);
+       mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port));
+       mix_intena.s.ithena = enable ? 1 : 0;
+       cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+       spin_unlock_irqrestore(&p->lock, flags);
+}
+
+static void octeon_mgmt_set_tx_irq(struct octeon_mgmt *p, int enable)
+{
+       int port = p->port;
+       union cvmx_mixx_intena mix_intena;
+       unsigned long flags;
+
+       spin_lock_irqsave(&p->lock, flags);
+       mix_intena.u64 = cvmx_read_csr(CVMX_MIXX_INTENA(port));
+       mix_intena.s.othena = enable ? 1 : 0;
+       cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+       spin_unlock_irqrestore(&p->lock, flags);
+}
+
+static inline void octeon_mgmt_enable_rx_irq(struct octeon_mgmt *p)
+{
+       octeon_mgmt_set_rx_irq(p, 1);
+}
+
+static inline void octeon_mgmt_disable_rx_irq(struct octeon_mgmt *p)
+{
+       octeon_mgmt_set_rx_irq(p, 0);
+}
+
+static inline void octeon_mgmt_enable_tx_irq(struct octeon_mgmt *p)
+{
+       octeon_mgmt_set_tx_irq(p, 1);
+}
+
+static inline void octeon_mgmt_disable_tx_irq(struct octeon_mgmt *p)
+{
+       octeon_mgmt_set_tx_irq(p, 0);
+}
+
+static unsigned int ring_max_fill(unsigned int ring_size)
+{
+       return ring_size - 8;
+}
+
+static unsigned int ring_size_to_bytes(unsigned int ring_size)
+{
+       return ring_size * sizeof(union mgmt_port_ring_entry);
+}
+
+static void octeon_mgmt_rx_fill_ring(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+
+       while (p->rx_current_fill < ring_max_fill(OCTEON_MGMT_RX_RING_SIZE)) {
+               unsigned int size;
+               union mgmt_port_ring_entry re;
+               struct sk_buff *skb;
+
+               /* CN56XX pass 1 needs 8 bytes of padding.  */
+               size = netdev->mtu + OCTEON_MGMT_RX_HEADROOM + 8 + NET_IP_ALIGN;
+
+               skb = netdev_alloc_skb(netdev, size);
+               if (!skb)
+                       break;
+               skb_reserve(skb, NET_IP_ALIGN);
+               __skb_queue_tail(&p->rx_list, skb);
+
+               re.d64 = 0;
+               re.s.len = size;
+               re.s.addr = dma_map_single(p->dev, skb->data,
+                                          size,
+                                          DMA_FROM_DEVICE);
+
+               /* Put it in the ring.  */
+               p->rx_ring[p->rx_next_fill] = re.d64;
+               dma_sync_single_for_device(p->dev, p->rx_ring_handle,
+                                          ring_size_to_bytes(OCTEON_MGMT_RX_RING_SIZE),
+                                          DMA_BIDIRECTIONAL);
+               p->rx_next_fill =
+                       (p->rx_next_fill + 1) % OCTEON_MGMT_RX_RING_SIZE;
+               p->rx_current_fill++;
+               /* Ring the bell.  */
+               cvmx_write_csr(CVMX_MIXX_IRING2(port), 1);
+       }
+}
+
+static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p)
+{
+       int port = p->port;
+       union cvmx_mixx_orcnt mix_orcnt;
+       union mgmt_port_ring_entry re;
+       struct sk_buff *skb;
+       int cleaned = 0;
+       unsigned long flags;
+
+       mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
+       while (mix_orcnt.s.orcnt) {
+               dma_sync_single_for_cpu(p->dev, p->tx_ring_handle,
+                                       ring_size_to_bytes(OCTEON_MGMT_TX_RING_SIZE),
+                                       DMA_BIDIRECTIONAL);
+
+               spin_lock_irqsave(&p->tx_list.lock, flags);
+
+               re.d64 = p->tx_ring[p->tx_next_clean];
+               p->tx_next_clean =
+                       (p->tx_next_clean + 1) % OCTEON_MGMT_TX_RING_SIZE;
+               skb = __skb_dequeue(&p->tx_list);
+
+               mix_orcnt.u64 = 0;
+               mix_orcnt.s.orcnt = 1;
+
+               /* Acknowledge to hardware that we have the buffer.  */
+               cvmx_write_csr(CVMX_MIXX_ORCNT(port), mix_orcnt.u64);
+               p->tx_current_fill--;
+
+               spin_unlock_irqrestore(&p->tx_list.lock, flags);
+
+               dma_unmap_single(p->dev, re.s.addr, re.s.len,
+                                DMA_TO_DEVICE);
+               dev_kfree_skb_any(skb);
+               cleaned++;
+
+               mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port));
+       }
+
+       if (cleaned && netif_queue_stopped(p->netdev))
+               netif_wake_queue(p->netdev);
+}
+
+static void octeon_mgmt_clean_tx_tasklet(unsigned long arg)
+{
+       struct octeon_mgmt *p = (struct octeon_mgmt *)arg;
+       octeon_mgmt_clean_tx_buffers(p);
+       octeon_mgmt_enable_tx_irq(p);
+}
+
+static void octeon_mgmt_update_rx_stats(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+       unsigned long flags;
+       u64 drop, bad;
+
+       /* These reads also clear the count registers.  */
+       drop = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port));
+       bad = cvmx_read_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port));
+
+       if (drop || bad) {
+               /* Do an atomic update. */
+               spin_lock_irqsave(&p->lock, flags);
+               netdev->stats.rx_errors += bad;
+               netdev->stats.rx_dropped += drop;
+               spin_unlock_irqrestore(&p->lock, flags);
+       }
+}
+
+static void octeon_mgmt_update_tx_stats(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+       unsigned long flags;
+
+       union cvmx_agl_gmx_txx_stat0 s0;
+       union cvmx_agl_gmx_txx_stat1 s1;
+
+       /* These reads also clear the count registers.  */
+       s0.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT0(port));
+       s1.u64 = cvmx_read_csr(CVMX_AGL_GMX_TXX_STAT1(port));
+
+       if (s0.s.xsdef || s0.s.xscol || s1.s.scol || s1.s.mcol) {
+               /* Do an atomic update. */
+               spin_lock_irqsave(&p->lock, flags);
+               netdev->stats.tx_errors += s0.s.xsdef + s0.s.xscol;
+               netdev->stats.collisions += s1.s.scol + s1.s.mcol;
+               spin_unlock_irqrestore(&p->lock, flags);
+       }
+}
+
+/*
+ * Dequeue a receive skb and its corresponding ring entry.  The ring
+ * entry is returned, *pskb is updated to point to the skb.
+ */
+static u64 octeon_mgmt_dequeue_rx_buffer(struct octeon_mgmt *p,
+                                        struct sk_buff **pskb)
+{
+       union mgmt_port_ring_entry re;
+
+       dma_sync_single_for_cpu(p->dev, p->rx_ring_handle,
+                               ring_size_to_bytes(OCTEON_MGMT_RX_RING_SIZE),
+                               DMA_BIDIRECTIONAL);
+
+       re.d64 = p->rx_ring[p->rx_next];
+       p->rx_next = (p->rx_next + 1) % OCTEON_MGMT_RX_RING_SIZE;
+       p->rx_current_fill--;
+       *pskb = __skb_dequeue(&p->rx_list);
+
+       dma_unmap_single(p->dev, re.s.addr,
+                        ETH_FRAME_LEN + OCTEON_MGMT_RX_HEADROOM,
+                        DMA_FROM_DEVICE);
+
+       return re.d64;
+}
+
+
+static int octeon_mgmt_receive_one(struct octeon_mgmt *p)
+{
+       int port = p->port;
+       struct net_device *netdev = p->netdev;
+       union cvmx_mixx_ircnt mix_ircnt;
+       union mgmt_port_ring_entry re;
+       struct sk_buff *skb;
+       struct sk_buff *skb2;
+       struct sk_buff *skb_new;
+       union mgmt_port_ring_entry re2;
+       int rc = 1;
+
+
+       re.d64 = octeon_mgmt_dequeue_rx_buffer(p, &skb);
+       if (likely(re.s.code == RING_ENTRY_CODE_DONE)) {
+               /* A good packet, send it up. */
+               skb_put(skb, re.s.len);
+good:
+               skb->protocol = eth_type_trans(skb, netdev);
+               netdev->stats.rx_packets++;
+               netdev->stats.rx_bytes += skb->len;
+               netdev->last_rx = jiffies;
+               netif_receive_skb(skb);
+               rc = 0;
+       } else if (re.s.code == RING_ENTRY_CODE_MORE) {
+               /*
+                * Packet split across skbs.  This can happen if we
+                * increase the MTU.  Buffers that are already in the
+                * rx ring can then end up being too small.  As the rx
+                * ring is refilled, buffers sized for the new MTU
+                * will be used and we should go back to the normal
+                * non-split case.
+                */
+               skb_put(skb, re.s.len);
+               do {
+                       re2.d64 = octeon_mgmt_dequeue_rx_buffer(p, &skb2);
+                       if (re2.s.code != RING_ENTRY_CODE_MORE
+                               && re2.s.code != RING_ENTRY_CODE_DONE)
+                               goto split_error;
+                       skb_put(skb2,  re2.s.len);
+                       skb_new = skb_copy_expand(skb, 0, skb2->len,
+                                                 GFP_ATOMIC);
+                       if (!skb_new)
+                               goto split_error;
+                       if (skb_copy_bits(skb2, 0, skb_tail_pointer(skb_new),
+                                         skb2->len))
+                               goto split_error;
+                       skb_put(skb_new, skb2->len);
+                       dev_kfree_skb_any(skb);
+                       dev_kfree_skb_any(skb2);
+                       skb = skb_new;
+               } while (re2.s.code == RING_ENTRY_CODE_MORE);
+               goto good;
+       } else {
+               /* Some other error, discard it. */
+               dev_kfree_skb_any(skb);
+               /*
+                * Error statistics are accumulated in
+                * octeon_mgmt_update_rx_stats.
+                */
+       }
+       goto done;
+split_error:
+       /* Discard the whole mess. */
+       dev_kfree_skb_any(skb);
+       dev_kfree_skb_any(skb2);
+       while (re2.s.code == RING_ENTRY_CODE_MORE) {
+               re2.d64 = octeon_mgmt_dequeue_rx_buffer(p, &skb2);
+               dev_kfree_skb_any(skb2);
+       }
+       netdev->stats.rx_errors++;
+
+done:
+       /* Tell the hardware we processed a packet.  */
+       mix_ircnt.u64 = 0;
+       mix_ircnt.s.ircnt = 1;
+       cvmx_write_csr(CVMX_MIXX_IRCNT(port), mix_ircnt.u64);
+       return rc;
+
+}
+
+static int octeon_mgmt_receive_packets(struct octeon_mgmt *p, int budget)
+{
+       int port = p->port;
+       unsigned int work_done = 0;
+       union cvmx_mixx_ircnt mix_ircnt;
+       int rc;
+
+
+       mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port));
+       while (work_done < budget && mix_ircnt.s.ircnt) {
+
+               rc = octeon_mgmt_receive_one(p);
+               if (!rc)
+                       work_done++;
+
+               /* Check for more packets. */
+               mix_ircnt.u64 = cvmx_read_csr(CVMX_MIXX_IRCNT(port));
+       }
+
+       octeon_mgmt_rx_fill_ring(p->netdev);
+
+       return work_done;
+}
+
+static int octeon_mgmt_napi_poll(struct napi_struct *napi, int budget)
+{
+       struct octeon_mgmt *p = container_of(napi, struct octeon_mgmt, napi);
+       struct net_device *netdev = p->netdev;
+       unsigned int work_done = 0;
+
+       work_done = octeon_mgmt_receive_packets(p, budget);
+
+       if (work_done < budget) {
+               /* We stopped because no more packets were available. */
+               napi_complete(napi);
+               octeon_mgmt_enable_rx_irq(p);
+       }
+       octeon_mgmt_update_rx_stats(netdev);
+
+       return work_done;
+}
+
+/* Reset the hardware to clean state.  */
+static void octeon_mgmt_reset_hw(struct octeon_mgmt *p)
+{
+       union cvmx_mixx_ctl mix_ctl;
+       union cvmx_mixx_bist mix_bist;
+       union cvmx_agl_gmx_bist agl_gmx_bist;
+
+       mix_ctl.u64 = 0;
+       cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64);
+       do {
+               mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(p->port));
+       } while (mix_ctl.s.busy);
+       mix_ctl.s.reset = 1;
+       cvmx_write_csr(CVMX_MIXX_CTL(p->port), mix_ctl.u64);
+       cvmx_read_csr(CVMX_MIXX_CTL(p->port));
+       cvmx_wait(64);
+
+       mix_bist.u64 = cvmx_read_csr(CVMX_MIXX_BIST(p->port));
+       if (mix_bist.u64)
+               dev_warn(p->dev, "MIX failed BIST (0x%016llx)\n",
+                       (unsigned long long)mix_bist.u64);
+
+       agl_gmx_bist.u64 = cvmx_read_csr(CVMX_AGL_GMX_BIST);
+       if (agl_gmx_bist.u64)
+               dev_warn(p->dev, "AGL failed BIST (0x%016llx)\n",
+                        (unsigned long long)agl_gmx_bist.u64);
+}
+
+struct octeon_mgmt_cam_state {
+       u64 cam[6];
+       u64 cam_mask;
+       int cam_index;
+};
+
+static void octeon_mgmt_cam_state_add(struct octeon_mgmt_cam_state *cs,
+                                     unsigned char *addr)
+{
+       int i;
+
+       for (i = 0; i < 6; i++)
+               cs->cam[i] |= (u64)addr[i] << (8 * (cs->cam_index));
+       cs->cam_mask |= (1ULL << cs->cam_index);
+       cs->cam_index++;
+}
+
+static void octeon_mgmt_set_rx_filtering(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+       int i;
+       union cvmx_agl_gmx_rxx_adr_ctl adr_ctl;
+       union cvmx_agl_gmx_prtx_cfg agl_gmx_prtx;
+       unsigned long flags;
+       unsigned int prev_packet_enable;
+       unsigned int cam_mode = 1; /* 1 - Accept on CAM match */
+       unsigned int multicast_mode = 1; /* 1 - Reject all multicast.  */
+       struct octeon_mgmt_cam_state cam_state;
+       struct dev_addr_list *list;
+       struct list_head *pos;
+       int available_cam_entries;
+
+       memset(&cam_state, 0, sizeof(cam_state));
+
+       if ((netdev->flags & IFF_PROMISC) || netdev->dev_addrs.count > 7) {
+               cam_mode = 0;
+               available_cam_entries = 8;
+       } else {
+               /*
+                * One CAM entry for the primary address, leaves seven
+                * for the secondary addresses.
+                */
+               available_cam_entries = 7 - netdev->dev_addrs.count;
+       }
+
+       if (netdev->flags & IFF_MULTICAST) {
+               if (cam_mode == 0 || (netdev->flags & IFF_ALLMULTI)
+                   || netdev->mc_count  > available_cam_entries)
+                       multicast_mode = 2; /* 1 - Accept all multicast.  */
+               else
+                       multicast_mode = 0; /* 0 - Use CAM.  */
+       }
+
+       if (cam_mode == 1) {
+               /* Add primary address. */
+               octeon_mgmt_cam_state_add(&cam_state, netdev->dev_addr);
+               list_for_each(pos, &netdev->dev_addrs.list) {
+                       struct netdev_hw_addr *hw_addr;
+                       hw_addr = list_entry(pos, struct netdev_hw_addr, list);
+                       octeon_mgmt_cam_state_add(&cam_state, hw_addr->addr);
+                       list = list->next;
+               }
+       }
+       if (multicast_mode == 0) {
+               i = netdev->mc_count;
+               list = netdev->mc_list;
+               while (i--) {
+                       octeon_mgmt_cam_state_add(&cam_state, list->da_addr);
+                       list = list->next;
+               }
+       }
+
+
+       spin_lock_irqsave(&p->lock, flags);
+
+       /* Disable packet I/O. */
+       agl_gmx_prtx.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+       prev_packet_enable = agl_gmx_prtx.s.en;
+       agl_gmx_prtx.s.en = 0;
+       cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64);
+
+
+       adr_ctl.u64 = 0;
+       adr_ctl.s.cam_mode = cam_mode;
+       adr_ctl.s.mcst = multicast_mode;
+       adr_ctl.s.bcst = 1;     /* Allow broadcast */
+
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CTL(port), adr_ctl.u64);
+
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM0(port), cam_state.cam[0]);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM1(port), cam_state.cam[1]);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM2(port), cam_state.cam[2]);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM3(port), cam_state.cam[3]);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM4(port), cam_state.cam[4]);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM5(port), cam_state.cam[5]);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_ADR_CAM_EN(port), cam_state.cam_mask);
+
+       /* Restore packet I/O. */
+       agl_gmx_prtx.s.en = prev_packet_enable;
+       cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), agl_gmx_prtx.u64);
+
+       spin_unlock_irqrestore(&p->lock, flags);
+}
+
+static int octeon_mgmt_set_mac_address(struct net_device *netdev, void *addr)
+{
+       struct sockaddr *sa = addr;
+
+       if (!is_valid_ether_addr(sa->sa_data))
+               return -EADDRNOTAVAIL;
+
+       memcpy(netdev->dev_addr, sa->sa_data, ETH_ALEN);
+
+       octeon_mgmt_set_rx_filtering(netdev);
+
+       return 0;
+}
+
+static int octeon_mgmt_change_mtu(struct net_device *netdev, int new_mtu)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+       int size_without_fcs = new_mtu + OCTEON_MGMT_RX_HEADROOM;
+
+       /*
+        * Limit the MTU to make sure the ethernet packets are between
+        * 64 bytes and 16383 bytes.
+        */
+       if (size_without_fcs < 64 || size_without_fcs > 16383) {
+               dev_warn(p->dev, "MTU must be between %d and %d.\n",
+                        64 - OCTEON_MGMT_RX_HEADROOM,
+                        16383 - OCTEON_MGMT_RX_HEADROOM);
+               return -EINVAL;
+       }
+
+       netdev->mtu = new_mtu;
+
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_MAX(port), size_without_fcs);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_JABBER(port),
+                      (size_without_fcs + 7) & 0xfff8);
+
+       return 0;
+}
+
+static irqreturn_t octeon_mgmt_interrupt(int cpl, void *dev_id)
+{
+       struct net_device *netdev = dev_id;
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+       union cvmx_mixx_isr mixx_isr;
+
+       mixx_isr.u64 = cvmx_read_csr(CVMX_MIXX_ISR(port));
+
+       /* Clear any pending interrupts */
+       cvmx_write_csr(CVMX_MIXX_ISR(port),
+                      cvmx_read_csr(CVMX_MIXX_ISR(port)));
+       cvmx_read_csr(CVMX_MIXX_ISR(port));
+
+       if (mixx_isr.s.irthresh) {
+               octeon_mgmt_disable_rx_irq(p);
+               napi_schedule(&p->napi);
+       }
+       if (mixx_isr.s.orthresh) {
+               octeon_mgmt_disable_tx_irq(p);
+               tasklet_schedule(&p->tx_clean_tasklet);
+       }
+
+       return IRQ_HANDLED;
+}
+
+static int octeon_mgmt_ioctl(struct net_device *netdev,
+                            struct ifreq *rq, int cmd)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+
+       if (!netif_running(netdev))
+               return -EINVAL;
+
+       if (!p->phydev)
+               return -EINVAL;
+
+       return phy_mii_ioctl(p->phydev, if_mii(rq), cmd);
+}
+
+static void octeon_mgmt_adjust_link(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+       union cvmx_agl_gmx_prtx_cfg prtx_cfg;
+       unsigned long flags;
+       int link_changed = 0;
+
+       spin_lock_irqsave(&p->lock, flags);
+       if (p->phydev->link) {
+               if (!p->last_link)
+                       link_changed = 1;
+               if (p->last_duplex != p->phydev->duplex) {
+                       p->last_duplex = p->phydev->duplex;
+                       prtx_cfg.u64 =
+                               cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+                       prtx_cfg.s.duplex = p->phydev->duplex;
+                       cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port),
+                                      prtx_cfg.u64);
+               }
+       } else {
+               if (p->last_link)
+                       link_changed = -1;
+       }
+       p->last_link = p->phydev->link;
+       spin_unlock_irqrestore(&p->lock, flags);
+
+       if (link_changed != 0) {
+               if (link_changed > 0) {
+                       netif_carrier_on(netdev);
+                       pr_info("%s: Link is up - %d/%s\n", netdev->name,
+                               p->phydev->speed,
+                               DUPLEX_FULL == p->phydev->duplex ?
+                               "Full" : "Half");
+               } else {
+                       netif_carrier_off(netdev);
+                       pr_info("%s: Link is down\n", netdev->name);
+               }
+       }
+}
+
+static int octeon_mgmt_init_phy(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       char phy_id[20];
+
+       if (octeon_is_simulation()) {
+               /* No PHYs in the simulator. */
+               netif_carrier_on(netdev);
+               return 0;
+       }
+
+       snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "0", p->port);
+
+       p->phydev = phy_connect(netdev, phy_id, octeon_mgmt_adjust_link, 0,
+                               PHY_INTERFACE_MODE_MII);
+
+       if (IS_ERR(p->phydev)) {
+               p->phydev = NULL;
+               return -1;
+       }
+
+       phy_start_aneg(p->phydev);
+
+       return 0;
+}
+
+static int octeon_mgmt_open(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+       union cvmx_mixx_ctl mix_ctl;
+       union cvmx_agl_gmx_inf_mode agl_gmx_inf_mode;
+       union cvmx_mixx_oring1 oring1;
+       union cvmx_mixx_iring1 iring1;
+       union cvmx_agl_gmx_prtx_cfg prtx_cfg;
+       union cvmx_agl_gmx_rxx_frm_ctl rxx_frm_ctl;
+       union cvmx_mixx_irhwm mix_irhwm;
+       union cvmx_mixx_orhwm mix_orhwm;
+       union cvmx_mixx_intena mix_intena;
+       struct sockaddr sa;
+
+       /* Allocate ring buffers.  */
+       p->tx_ring = kzalloc(ring_size_to_bytes(OCTEON_MGMT_TX_RING_SIZE),
+                            GFP_KERNEL);
+       if (!p->tx_ring)
+               return -ENOMEM;
+       p->tx_ring_handle =
+               dma_map_single(p->dev, p->tx_ring,
+                              ring_size_to_bytes(OCTEON_MGMT_TX_RING_SIZE),
+                              DMA_BIDIRECTIONAL);
+       p->tx_next = 0;
+       p->tx_next_clean = 0;
+       p->tx_current_fill = 0;
+
+
+       p->rx_ring = kzalloc(ring_size_to_bytes(OCTEON_MGMT_RX_RING_SIZE),
+                            GFP_KERNEL);
+       if (!p->rx_ring)
+               goto err_nomem;
+       p->rx_ring_handle =
+               dma_map_single(p->dev, p->rx_ring,
+                              ring_size_to_bytes(OCTEON_MGMT_RX_RING_SIZE),
+                              DMA_BIDIRECTIONAL);
+
+       p->rx_next = 0;
+       p->rx_next_fill = 0;
+       p->rx_current_fill = 0;
+
+       octeon_mgmt_reset_hw(p);
+
+       mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port));
+
+       /* Bring it out of reset if needed. */
+       if (mix_ctl.s.reset) {
+               mix_ctl.s.reset = 0;
+               cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64);
+               do {
+                       mix_ctl.u64 = cvmx_read_csr(CVMX_MIXX_CTL(port));
+               } while (mix_ctl.s.reset);
+       }
+
+       agl_gmx_inf_mode.u64 = 0;
+       agl_gmx_inf_mode.s.en = 1;
+       cvmx_write_csr(CVMX_AGL_GMX_INF_MODE, agl_gmx_inf_mode.u64);
+
+       oring1.u64 = 0;
+       oring1.s.obase = p->tx_ring_handle >> 3;
+       oring1.s.osize = OCTEON_MGMT_TX_RING_SIZE;
+       cvmx_write_csr(CVMX_MIXX_ORING1(port), oring1.u64);
+
+       iring1.u64 = 0;
+       iring1.s.ibase = p->rx_ring_handle >> 3;
+       iring1.s.isize = OCTEON_MGMT_RX_RING_SIZE;
+       cvmx_write_csr(CVMX_MIXX_IRING1(port), iring1.u64);
+
+       /* Disable packet I/O. */
+       prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+       prtx_cfg.s.en = 0;
+       cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64);
+
+       memcpy(sa.sa_data, netdev->dev_addr, ETH_ALEN);
+       octeon_mgmt_set_mac_address(netdev, &sa);
+
+       octeon_mgmt_change_mtu(netdev, netdev->mtu);
+
+       /*
+        * Enable the port HW. Packets are not allowed until
+        * cvmx_mgmt_port_enable() is called.
+        */
+       mix_ctl.u64 = 0;
+       mix_ctl.s.crc_strip = 1;    /* Strip the ending CRC */
+       mix_ctl.s.en = 1;           /* Enable the port */
+       mix_ctl.s.nbtarb = 0;       /* Arbitration mode */
+       /* MII CB-request FIFO programmable high watermark */
+       mix_ctl.s.mrq_hwm = 1;
+       cvmx_write_csr(CVMX_MIXX_CTL(port), mix_ctl.u64);
+
+       if (OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
+           || OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X)) {
+               /*
+                * Force compensation values, as they are not
+                * determined properly by HW
+                */
+               union cvmx_agl_gmx_drv_ctl drv_ctl;
+
+               drv_ctl.u64 = cvmx_read_csr(CVMX_AGL_GMX_DRV_CTL);
+               if (port) {
+                       drv_ctl.s.byp_en1 = 1;
+                       drv_ctl.s.nctl1 = 6;
+                       drv_ctl.s.pctl1 = 6;
+               } else {
+                       drv_ctl.s.byp_en = 1;
+                       drv_ctl.s.nctl = 6;
+                       drv_ctl.s.pctl = 6;
+               }
+               cvmx_write_csr(CVMX_AGL_GMX_DRV_CTL, drv_ctl.u64);
+       }
+
+       octeon_mgmt_rx_fill_ring(netdev);
+
+       /* Clear statistics. */
+       /* Clear on read. */
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_CTL(port), 1);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_DRP(port), 0);
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_STATS_PKTS_BAD(port), 0);
+
+       cvmx_write_csr(CVMX_AGL_GMX_TXX_STATS_CTL(port), 1);
+       cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT0(port), 0);
+       cvmx_write_csr(CVMX_AGL_GMX_TXX_STAT1(port), 0);
+
+       /* Clear any pending interrupts */
+       cvmx_write_csr(CVMX_MIXX_ISR(port), cvmx_read_csr(CVMX_MIXX_ISR(port)));
+
+       if (request_irq(p->irq, octeon_mgmt_interrupt, 0, netdev->name,
+                       netdev)) {
+               dev_err(p->dev, "request_irq(%d) failed.\n", p->irq);
+               goto err_noirq;
+       }
+
+       /* Interrupt every single RX packet */
+       mix_irhwm.u64 = 0;
+       mix_irhwm.s.irhwm = 0;
+       cvmx_write_csr(CVMX_MIXX_IRHWM(port), mix_irhwm.u64);
+
+       /* Interrupt when we have 5 or more packets to clean.  */
+       mix_orhwm.u64 = 0;
+       mix_orhwm.s.orhwm = 5;
+       cvmx_write_csr(CVMX_MIXX_ORHWM(port), mix_orhwm.u64);
+
+       /* Enable receive and transmit interrupts */
+       mix_intena.u64 = 0;
+       mix_intena.s.ithena = 1;
+       mix_intena.s.othena = 1;
+       cvmx_write_csr(CVMX_MIXX_INTENA(port), mix_intena.u64);
+
+
+       /* Enable packet I/O. */
+
+       rxx_frm_ctl.u64 = 0;
+       rxx_frm_ctl.s.pre_align = 1;
+       /*
+        * When set, disables the length check for non-min sized pkts
+        * with padding in the client data.
+        */
+       rxx_frm_ctl.s.pad_len = 1;
+       /* When set, disables the length check for VLAN pkts */
+       rxx_frm_ctl.s.vlan_len = 1;
+       /* When set, PREAMBLE checking is  less strict */
+       rxx_frm_ctl.s.pre_free = 1;
+       /* Control Pause Frames can match station SMAC */
+       rxx_frm_ctl.s.ctl_smac = 0;
+       /* Control Pause Frames can match globally assign Multicast address */
+       rxx_frm_ctl.s.ctl_mcst = 1;
+       /* Forward pause information to TX block */
+       rxx_frm_ctl.s.ctl_bck = 1;
+       /* Drop Control Pause Frames */
+       rxx_frm_ctl.s.ctl_drp = 1;
+       /* Strip off the preamble */
+       rxx_frm_ctl.s.pre_strp = 1;
+       /*
+        * This port is configured to send PREAMBLE+SFD to begin every
+        * frame.  GMX checks that the PREAMBLE is sent correctly.
+        */
+       rxx_frm_ctl.s.pre_chk = 1;
+       cvmx_write_csr(CVMX_AGL_GMX_RXX_FRM_CTL(port), rxx_frm_ctl.u64);
+
+       /* Enable the AGL block */
+       agl_gmx_inf_mode.u64 = 0;
+       agl_gmx_inf_mode.s.en = 1;
+       cvmx_write_csr(CVMX_AGL_GMX_INF_MODE, agl_gmx_inf_mode.u64);
+
+       /* Configure the port duplex and enables */
+       prtx_cfg.u64 = cvmx_read_csr(CVMX_AGL_GMX_PRTX_CFG(port));
+       prtx_cfg.s.tx_en = 1;
+       prtx_cfg.s.rx_en = 1;
+       prtx_cfg.s.en = 1;
+       p->last_duplex = 1;
+       prtx_cfg.s.duplex = p->last_duplex;
+       cvmx_write_csr(CVMX_AGL_GMX_PRTX_CFG(port), prtx_cfg.u64);
+
+       p->last_link = 0;
+       netif_carrier_off(netdev);
+
+       if (octeon_mgmt_init_phy(netdev)) {
+               dev_err(p->dev, "Cannot initialize PHY.\n");
+               goto err_noirq;
+       }
+
+       netif_wake_queue(netdev);
+       napi_enable(&p->napi);
+
+       return 0;
+err_noirq:
+       octeon_mgmt_reset_hw(p);
+       dma_unmap_single(p->dev, p->rx_ring_handle,
+                        ring_size_to_bytes(OCTEON_MGMT_RX_RING_SIZE),
+                        DMA_BIDIRECTIONAL);
+       kfree(p->rx_ring);
+err_nomem:
+       dma_unmap_single(p->dev, p->tx_ring_handle,
+                        ring_size_to_bytes(OCTEON_MGMT_TX_RING_SIZE),
+                        DMA_BIDIRECTIONAL);
+       kfree(p->tx_ring);
+       return -ENOMEM;
+}
+
+static int octeon_mgmt_stop(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+
+       napi_disable(&p->napi);
+       netif_stop_queue(netdev);
+
+       if (p->phydev)
+               phy_disconnect(p->phydev);
+
+       netif_carrier_off(netdev);
+
+       octeon_mgmt_reset_hw(p);
+
+
+       free_irq(p->irq, netdev);
+
+       /* dma_unmap is a nop on Octeon, so just free everything.  */
+       skb_queue_purge(&p->tx_list);
+       skb_queue_purge(&p->rx_list);
+
+       dma_unmap_single(p->dev, p->rx_ring_handle,
+                        ring_size_to_bytes(OCTEON_MGMT_RX_RING_SIZE),
+                        DMA_BIDIRECTIONAL);
+       kfree(p->rx_ring);
+
+       dma_unmap_single(p->dev, p->tx_ring_handle,
+                        ring_size_to_bytes(OCTEON_MGMT_TX_RING_SIZE),
+                        DMA_BIDIRECTIONAL);
+       kfree(p->tx_ring);
+
+
+       return 0;
+}
+
+static int octeon_mgmt_xmit(struct sk_buff *skb, struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+       int port = p->port;
+       union mgmt_port_ring_entry re;
+       unsigned long flags;
+
+       re.d64 = 0;
+       re.s.len = skb->len;
+       re.s.addr = dma_map_single(p->dev, skb->data,
+                                  skb->len,
+                                  DMA_TO_DEVICE);
+
+       spin_lock_irqsave(&p->tx_list.lock, flags);
+
+       if (unlikely(p->tx_current_fill >=
+                    ring_max_fill(OCTEON_MGMT_TX_RING_SIZE))) {
+               spin_unlock_irqrestore(&p->tx_list.lock, flags);
+
+               dma_unmap_single(p->dev, re.s.addr, re.s.len,
+                                DMA_TO_DEVICE);
+
+               netif_stop_queue(netdev);
+               return NETDEV_TX_BUSY;
+       }
+
+       __skb_queue_tail(&p->tx_list, skb);
+
+       /* Put it in the ring.  */
+       p->tx_ring[p->tx_next] = re.d64;
+       p->tx_next = (p->tx_next + 1) % OCTEON_MGMT_TX_RING_SIZE;
+       p->tx_current_fill++;
+
+       spin_unlock_irqrestore(&p->tx_list.lock, flags);
+
+       dma_sync_single_for_device(p->dev, p->tx_ring_handle,
+                                  ring_size_to_bytes(OCTEON_MGMT_TX_RING_SIZE),
+                                  DMA_BIDIRECTIONAL);
+
+       netdev->stats.tx_packets++;
+       netdev->stats.tx_bytes += skb->len;
+
+       /* Ring the bell.  */
+       cvmx_write_csr(CVMX_MIXX_ORING2(port), 1);
+
+       netdev->trans_start = jiffies;
+       octeon_mgmt_clean_tx_buffers(p);
+       octeon_mgmt_update_tx_stats(netdev);
+       return NETDEV_TX_OK;
+}
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void octeon_mgmt_poll_controller(struct net_device *netdev)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+
+       octeon_mgmt_receive_packets(p, 16);
+       octeon_mgmt_update_rx_stats(netdev);
+       return;
+}
+#endif
+
+static void octeon_mgmt_get_drvinfo(struct net_device *netdev,
+                                   struct ethtool_drvinfo *info)
+{
+       strncpy(info->driver, DRV_NAME, sizeof(info->driver));
+       strncpy(info->version, DRV_VERSION, sizeof(info->version));
+       strncpy(info->fw_version, "N/A", sizeof(info->fw_version));
+       strncpy(info->bus_info, "N/A", sizeof(info->bus_info));
+       info->n_stats = 0;
+       info->testinfo_len = 0;
+       info->regdump_len = 0;
+       info->eedump_len = 0;
+}
+
+static int octeon_mgmt_get_settings(struct net_device *netdev,
+                                   struct ethtool_cmd *cmd)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+
+       if (p->phydev)
+               return phy_ethtool_gset(p->phydev, cmd);
+
+       return -EINVAL;
+}
+
+static int octeon_mgmt_set_settings(struct net_device *netdev,
+                                   struct ethtool_cmd *cmd)
+{
+       struct octeon_mgmt *p = netdev_priv(netdev);
+
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
+       if (p->phydev)
+               return phy_ethtool_sset(p->phydev, cmd);
+
+       return -EINVAL;
+}
+
+static const struct ethtool_ops octeon_mgmt_ethtool_ops = {
+       .get_drvinfo = octeon_mgmt_get_drvinfo,
+       .get_link = ethtool_op_get_link,
+       .get_settings = octeon_mgmt_get_settings,
+       .set_settings = octeon_mgmt_set_settings
+};
+
+static const struct net_device_ops octeon_mgmt_ops = {
+       .ndo_open =                     octeon_mgmt_open,
+       .ndo_stop =                     octeon_mgmt_stop,
+       .ndo_start_xmit =               octeon_mgmt_xmit,
+       .ndo_set_rx_mode =              octeon_mgmt_set_rx_filtering,
+       .ndo_set_multicast_list =       octeon_mgmt_set_rx_filtering,
+       .ndo_set_mac_address =          octeon_mgmt_set_mac_address,
+       .ndo_do_ioctl =                 octeon_mgmt_ioctl,
+       .ndo_change_mtu =               octeon_mgmt_change_mtu,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller =          octeon_mgmt_poll_controller,
+#endif
+};
+
+static int __init octeon_mgmt_probe(struct platform_device *pdev)
+{
+       struct resource *res_irq;
+       struct net_device *netdev;
+       struct octeon_mgmt *p;
+       int i;
+
+       netdev = alloc_etherdev(sizeof(struct octeon_mgmt));
+       if (netdev == NULL)
+               return -ENOMEM;
+
+       dev_set_drvdata(&pdev->dev, netdev);
+       p = netdev_priv(netdev);
+       netif_napi_add(netdev, &p->napi, octeon_mgmt_napi_poll,
+                      OCTEON_MGMT_NAPI_WEIGHT);
+
+       p->netdev = netdev;
+       p->dev = &pdev->dev;
+
+       p->port = pdev->id;
+       snprintf(netdev->name, IFNAMSIZ, "mgmt%d", p->port);
+
+       res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+       if (!res_irq)
+               goto err;
+
+       p->irq = res_irq->start;
+       spin_lock_init(&p->lock);
+
+       skb_queue_head_init(&p->tx_list);
+       skb_queue_head_init(&p->rx_list);
+       tasklet_init(&p->tx_clean_tasklet,
+                    octeon_mgmt_clean_tx_tasklet, (unsigned long)p);
+
+       netdev->netdev_ops = &octeon_mgmt_ops;
+       netdev->ethtool_ops = &octeon_mgmt_ethtool_ops;
+
+
+       /* The mgmt ports get the first N MACs.  */
+       for (i = 0; i < 6; i++)
+               netdev->dev_addr[i] = octeon_bootinfo->mac_addr_base[i];
+       netdev->dev_addr[5] += p->port;
+
+       if (p->port >= octeon_bootinfo->mac_addr_count)
+               dev_err(&pdev->dev,
+                       "Error %s: Using MAC outside of the assigned range: "
+                       "%02x:%02x:%02x:%02x:%02x:%02x\n", netdev->name,
+                       netdev->dev_addr[0], netdev->dev_addr[1],
+                       netdev->dev_addr[2], netdev->dev_addr[3],
+                       netdev->dev_addr[4], netdev->dev_addr[5]);
+
+       if (register_netdev(netdev))
+               goto err;
+
+       dev_info(&pdev->dev, "Version " DRV_VERSION "\n");
+       return 0;
+err:
+       free_netdev(netdev);
+       return -ENOENT;
+}
+
+static int __exit octeon_mgmt_remove(struct platform_device *pdev)
+{
+       struct net_device *netdev = dev_get_drvdata(&pdev->dev);
+
+       unregister_netdev(netdev);
+       free_netdev(netdev);
+       return 0;
+}
+
+static struct platform_driver octeon_mgmt_driver = {
+       .driver = {
+               .name           = "octeon_mgmt",
+               .owner          = THIS_MODULE,
+       },
+       .probe          = octeon_mgmt_probe,
+       .remove         = __exit_p(octeon_mgmt_remove),
+};
+
+extern void octeon_mdiobus_force_mod_depencency(void);
+
+static int __init octeon_mgmt_mod_init(void)
+{
+       /* Force our mdiobus driver module to be loaded first. */
+       octeon_mdiobus_force_mod_depencency();
+       return platform_driver_register(&octeon_mgmt_driver);
+}
+
+static void __exit octeon_mgmt_mod_exit(void)
+{
+       platform_driver_unregister(&octeon_mgmt_driver);
+}
+
+module_init(octeon_mgmt_mod_init);
+module_exit(octeon_mgmt_mod_exit);
+
+MODULE_DESCRIPTION(DRV_DESCRIPTION);
+MODULE_AUTHOR("David Daney");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(DRV_VERSION);
index 17a27225cc98cbc076f705ec6c850812ed6f56c8..98938ea9e0bdc05bb7c3f5e18d83ef535e844869 100644 (file)
@@ -912,7 +912,11 @@ static void media_check(unsigned long arg)
        if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) == 0xff)) {
                if (!lp->fast_poll)
                        printk(KERN_INFO "%s: interrupt(s) dropped!\n", dev->name);
+
+               local_irq_save(flags);
                el3_interrupt(dev->irq, dev);
+               local_irq_restore(flags);
+
                lp->fast_poll = HZ;
        }
        if (lp->fast_poll) {
index 6f8d7e2e592246205df9ae45625ae1816e9f03b3..322e11df0097f1f04204fd6a09d6a892273b1965 100644 (file)
@@ -711,7 +711,11 @@ static void media_check(unsigned long arg)
        (inb(ioaddr + EL3_TIMER) == 0xff)) {
        if (!lp->fast_poll)
            printk(KERN_WARNING "%s: interrupt(s) dropped!\n", dev->name);
+
+       local_irq_save(flags);
        el3_interrupt(dev->irq, dev);
+       local_irq_restore(flags);
+
        lp->fast_poll = HZ;
     }
     if (lp->fast_poll) {
index dcc67a35e8f24f2a6c54eb3d65aedce23b55b3e0..e154677ff706834285ce6f4a7bd6f00d83118818 100644 (file)
@@ -45,6 +45,7 @@ static const char *const version =
 #include <linux/crc32.h>
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
+#include <linux/if_ether.h>
 #include <linux/skbuff.h>
 #include <linux/spinlock.h>
 #include <linux/moduleparam.h>
@@ -1765,7 +1766,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
 
        /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */
        if (!is_valid_ether_addr(dev->perm_addr))
-               memset(dev->dev_addr, 0, sizeof(dev->dev_addr));
+               memset(dev->dev_addr, 0, ETH_ALEN);
 
        if (pcnet32_debug & NETIF_MSG_PROBE) {
                printk(" %pM", dev->dev_addr);
index d5d8e1c5bc910a7f0c657f38922f02741063c43d..fc5938ba3d7874f591cc16a05aa6aa084bccd6aa 100644 (file)
@@ -115,4 +115,15 @@ config MDIO_GPIO
          To compile this driver as a module, choose M here: the module
          will be called mdio-gpio.
 
+config MDIO_OCTEON
+       tristate "Support for MDIO buses on Octeon SOCs"
+       depends on  CPU_CAVIUM_OCTEON
+       default y
+       help
+
+         This module provides a driver for the Octeon MDIO busses.
+         It is required by the Octeon Ethernet device drivers.
+
+         If in doubt, say Y.
+
 endif # PHYLIB
index edfaac48cbd5feaa944bddd9a5ab2ce813dfb925..1342585af3812de222ccd99f8d7090e127c916df 100644 (file)
@@ -20,3 +20,4 @@ obj-$(CONFIG_MDIO_BITBANG)    += mdio-bitbang.o
 obj-$(CONFIG_MDIO_GPIO)                += mdio-gpio.o
 obj-$(CONFIG_NATIONAL_PHY)     += national.o
 obj-$(CONFIG_STE10XP)          += ste10Xp.o
+obj-$(CONFIG_MDIO_OCTEON)      += mdio-octeon.o
index f63c96a4ecb46b1d891ec70b225cc1affca8b51d..c13cf64095b68b457b528a36fe71532478349aa5 100644 (file)
@@ -326,7 +326,8 @@ error:
 
 static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
 {
-       u32 val, orig;
+       u32 orig;
+       int val;
        bool clk125en = true;
 
        /* Abort if we are using an untested phy. */
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
new file mode 100644 (file)
index 0000000..61a4461
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2009 Cavium Networks
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/phy.h>
+
+#include <asm/octeon/octeon.h>
+#include <asm/octeon/cvmx-smix-defs.h>
+
+#define DRV_VERSION "1.0"
+#define DRV_DESCRIPTION "Cavium Networks Octeon SMI/MDIO driver"
+
+struct octeon_mdiobus {
+       struct mii_bus *mii_bus;
+       int unit;
+       int phy_irq[PHY_MAX_ADDR];
+};
+
+static int octeon_mdiobus_read(struct mii_bus *bus, int phy_id, int regnum)
+{
+       struct octeon_mdiobus *p = bus->priv;
+       union cvmx_smix_cmd smi_cmd;
+       union cvmx_smix_rd_dat smi_rd;
+       int timeout = 1000;
+
+       smi_cmd.u64 = 0;
+       smi_cmd.s.phy_op = 1; /* MDIO_CLAUSE_22_READ */
+       smi_cmd.s.phy_adr = phy_id;
+       smi_cmd.s.reg_adr = regnum;
+       cvmx_write_csr(CVMX_SMIX_CMD(p->unit), smi_cmd.u64);
+
+       do {
+               /*
+                * Wait 1000 clocks so we don't saturate the RSL bus
+                * doing reads.
+                */
+               cvmx_wait(1000);
+               smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(p->unit));
+       } while (smi_rd.s.pending && --timeout);
+
+       if (smi_rd.s.val)
+               return smi_rd.s.dat;
+       else
+               return -EIO;
+}
+
+static int octeon_mdiobus_write(struct mii_bus *bus, int phy_id,
+                               int regnum, u16 val)
+{
+       struct octeon_mdiobus *p = bus->priv;
+       union cvmx_smix_cmd smi_cmd;
+       union cvmx_smix_wr_dat smi_wr;
+       int timeout = 1000;
+
+       smi_wr.u64 = 0;
+       smi_wr.s.dat = val;
+       cvmx_write_csr(CVMX_SMIX_WR_DAT(p->unit), smi_wr.u64);
+
+       smi_cmd.u64 = 0;
+       smi_cmd.s.phy_op = 0; /* MDIO_CLAUSE_22_WRITE */
+       smi_cmd.s.phy_adr = phy_id;
+       smi_cmd.s.reg_adr = regnum;
+       cvmx_write_csr(CVMX_SMIX_CMD(p->unit), smi_cmd.u64);
+
+       do {
+               /*
+                * Wait 1000 clocks so we don't saturate the RSL bus
+                * doing reads.
+                */
+               cvmx_wait(1000);
+               smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(p->unit));
+       } while (smi_wr.s.pending && --timeout);
+
+       if (timeout <= 0)
+               return -EIO;
+
+       return 0;
+}
+
+static int __init octeon_mdiobus_probe(struct platform_device *pdev)
+{
+       struct octeon_mdiobus *bus;
+       int i;
+       int err = -ENOENT;
+
+       bus = devm_kzalloc(&pdev->dev, sizeof(*bus), GFP_KERNEL);
+       if (!bus)
+               return -ENOMEM;
+
+       /* The platform_device id is our unit number.  */
+       bus->unit = pdev->id;
+
+       bus->mii_bus = mdiobus_alloc();
+
+       if (!bus->mii_bus)
+               goto err;
+
+       /*
+        * Standard Octeon evaluation boards don't support phy
+        * interrupts, we need to poll.
+        */
+       for (i = 0; i < PHY_MAX_ADDR; i++)
+               bus->phy_irq[i] = PHY_POLL;
+
+       bus->mii_bus->priv = bus;
+       bus->mii_bus->irq = bus->phy_irq;
+       bus->mii_bus->name = "mdio-octeon";
+       snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%x", bus->unit);
+       bus->mii_bus->parent = &pdev->dev;
+
+       bus->mii_bus->read = octeon_mdiobus_read;
+       bus->mii_bus->write = octeon_mdiobus_write;
+
+       dev_set_drvdata(&pdev->dev, bus);
+
+       err = mdiobus_register(bus->mii_bus);
+       if (err)
+               goto err_register;
+
+       dev_info(&pdev->dev, "Version " DRV_VERSION "\n");
+
+       return 0;
+err_register:
+       mdiobus_free(bus->mii_bus);
+
+err:
+       devm_kfree(&pdev->dev, bus);
+       return err;
+}
+
+static int __exit octeon_mdiobus_remove(struct platform_device *pdev)
+{
+       struct octeon_mdiobus *bus;
+
+       bus = dev_get_drvdata(&pdev->dev);
+
+       mdiobus_unregister(bus->mii_bus);
+       mdiobus_free(bus->mii_bus);
+       return 0;
+}
+
+static struct platform_driver octeon_mdiobus_driver = {
+       .driver = {
+               .name           = "mdio-octeon",
+               .owner          = THIS_MODULE,
+       },
+       .probe          = octeon_mdiobus_probe,
+       .remove         = __exit_p(octeon_mdiobus_remove),
+};
+
+void octeon_mdiobus_force_mod_depencency(void)
+{
+       /* Let ethernet drivers force us to be loaded.  */
+}
+EXPORT_SYMBOL(octeon_mdiobus_force_mod_depencency);
+
+static int __init octeon_mdiobus_mod_init(void)
+{
+       return platform_driver_register(&octeon_mdiobus_driver);
+}
+
+static void __exit octeon_mdiobus_mod_exit(void)
+{
+       platform_driver_unregister(&octeon_mdiobus_driver);
+}
+
+module_init(octeon_mdiobus_mod_init);
+module_exit(octeon_mdiobus_mod_exit);
+
+MODULE_DESCRIPTION(DRV_DESCRIPTION);
+MODULE_VERSION(DRV_VERSION);
+MODULE_AUTHOR("David Daney");
+MODULE_LICENSE("GPL");
index acfc5a3aa490b5dbe3cb9e638803946944ef0abb..60f96c468a2465e3f3b9c7d3634b4f521d153216 100644 (file)
@@ -4859,7 +4859,7 @@ out:
        return 0;
 }
 
-static struct dev_pm_ops rtl8169_pm_ops = {
+static const struct dev_pm_ops rtl8169_pm_ops = {
        .suspend = rtl8169_suspend,
        .resume = rtl8169_resume,
        .freeze = rtl8169_suspend,
index f983e3b507cc8951fd1837a946ab87b6acb2991f..103e8b0e2a0d67e6682cb827e010a7e8f260e025 100644 (file)
@@ -741,14 +741,14 @@ static int efx_probe_port(struct efx_nic *efx)
 
        EFX_LOG(efx, "create port\n");
 
+       if (phy_flash_cfg)
+               efx->phy_mode = PHY_MODE_SPECIAL;
+
        /* Connect up MAC/PHY operations table */
        rc = efx->type->probe_port(efx);
        if (rc)
                goto err;
 
-       if (phy_flash_cfg)
-               efx->phy_mode = PHY_MODE_SPECIAL;
-
        /* Sanity check MAC address */
        if (is_valid_ether_addr(efx->mac_address)) {
                memcpy(efx->net_dev->dev_addr, efx->mac_address, ETH_ALEN);
index 17afcd26e870c09058e8a3df8545d76566ccdb75..9d009c46e962c343befff8c1395e3651133e5ccb 100644 (file)
@@ -925,6 +925,7 @@ static int falcon_probe_port(struct efx_nic *efx)
 
 static void falcon_remove_port(struct efx_nic *efx)
 {
+       efx->phy_op->remove(efx);
        efx_nic_free_buffer(efx, &efx->stats_buffer);
 }
 
index 3da933f8f0797bc577027d489d4717ea8ec79dd3..8ccab2c67a2094680ef743df277cd7e20a8d16c2 100644 (file)
@@ -111,16 +111,12 @@ static void falcon_mask_status_intr(struct efx_nic *efx, bool enable)
        efx_writeo(efx, &reg, FR_AB_XM_MGT_INT_MASK);
 }
 
-/* Get status of XAUI link */
-static bool falcon_xaui_link_ok(struct efx_nic *efx)
+static bool falcon_xgxs_link_ok(struct efx_nic *efx)
 {
        efx_oword_t reg;
        bool align_done, link_ok = false;
        int sync_status;
 
-       if (LOOPBACK_INTERNAL(efx))
-               return true;
-
        /* Read link status */
        efx_reado(efx, &reg, FR_AB_XX_CORE_STAT);
 
@@ -135,14 +131,24 @@ static bool falcon_xaui_link_ok(struct efx_nic *efx)
        EFX_SET_OWORD_FIELD(reg, FRF_AB_XX_DISPERR, FFE_AB_XX_STAT_ALL_LANES);
        efx_writeo(efx, &reg, FR_AB_XX_CORE_STAT);
 
-       /* If the link is up, then check the phy side of the xaui link */
-       if (efx->link_state.up && link_ok)
-               if (efx->mdio.mmds & (1 << MDIO_MMD_PHYXS))
-                       link_ok = efx_mdio_phyxgxs_lane_sync(efx);
-
        return link_ok;
 }
 
+static bool falcon_xmac_link_ok(struct efx_nic *efx)
+{
+       /*
+        * Check MAC's XGXS link status except when using XGMII loopback
+        * which bypasses the XGXS block.
+        * If possible, check PHY's XGXS link status except when using
+        * MAC loopback.
+        */
+       return (efx->loopback_mode == LOOPBACK_XGMII ||
+               falcon_xgxs_link_ok(efx)) &&
+               (!(efx->mdio.mmds & (1 << MDIO_MMD_PHYXS)) ||
+                LOOPBACK_INTERNAL(efx) || 
+                efx_mdio_phyxgxs_lane_sync(efx));
+}
+
 void falcon_reconfigure_xmac_core(struct efx_nic *efx)
 {
        unsigned int max_frame_len;
@@ -245,9 +251,9 @@ static void falcon_reconfigure_xgxs_core(struct efx_nic *efx)
 
 
 /* Try to bring up the Falcon side of the Falcon-Phy XAUI link */
-static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries)
+static bool falcon_xmac_link_ok_retry(struct efx_nic *efx, int tries)
 {
-       bool mac_up = falcon_xaui_link_ok(efx);
+       bool mac_up = falcon_xmac_link_ok(efx);
 
        if (LOOPBACK_MASK(efx) & LOOPBACKS_EXTERNAL(efx) & LOOPBACKS_WS ||
            efx_phy_mode_disabled(efx->phy_mode))
@@ -261,7 +267,7 @@ static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries)
                falcon_reset_xaui(efx);
                udelay(200);
 
-               mac_up = falcon_xaui_link_ok(efx);
+               mac_up = falcon_xmac_link_ok(efx);
                --tries;
        }
 
@@ -272,7 +278,7 @@ static bool falcon_check_xaui_link_up(struct efx_nic *efx, int tries)
 
 static bool falcon_xmac_check_fault(struct efx_nic *efx)
 {
-       return !falcon_check_xaui_link_up(efx, 5);
+       return !falcon_xmac_link_ok_retry(efx, 5);
 }
 
 static int falcon_reconfigure_xmac(struct efx_nic *efx)
@@ -284,7 +290,7 @@ static int falcon_reconfigure_xmac(struct efx_nic *efx)
 
        falcon_reconfigure_mac_wrapper(efx);
 
-       efx->xmac_poll_required = !falcon_check_xaui_link_up(efx, 5);
+       efx->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 5);
        falcon_mask_status_intr(efx, true);
 
        return 0;
@@ -357,7 +363,7 @@ void falcon_poll_xmac(struct efx_nic *efx)
                return;
 
        falcon_mask_status_intr(efx, false);
-       efx->xmac_poll_required = !falcon_check_xaui_link_up(efx, 1);
+       efx->xmac_poll_required = !falcon_xmac_link_ok_retry(efx, 1);
        falcon_mask_status_intr(efx, true);
 }
 
index 0e1bcc5a0d52c5e4ee637c529f0b062a3f22eb65..eb694af7a473503b176a23fb37cddce97e70b6cc 100644 (file)
@@ -304,31 +304,47 @@ static u32 mcdi_to_ethtool_media(u32 media)
 
 static int efx_mcdi_phy_probe(struct efx_nic *efx)
 {
-       struct efx_mcdi_phy_cfg *phy_cfg;
+       struct efx_mcdi_phy_cfg *phy_data;
+       u8 outbuf[MC_CMD_GET_LINK_OUT_LEN];
+       u32 caps;
        int rc;
 
-       /* TODO: Move phy_data initialisation to
-        * phy_op->probe/remove, rather than init/fini */
-       phy_cfg = kzalloc(sizeof(*phy_cfg), GFP_KERNEL);
-       if (phy_cfg == NULL) {
-               rc = -ENOMEM;
-               goto fail_alloc;
-       }
-       rc = efx_mcdi_get_phy_cfg(efx, phy_cfg);
+       /* Initialise and populate phy_data */
+       phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
+       if (phy_data == NULL)
+               return -ENOMEM;
+
+       rc = efx_mcdi_get_phy_cfg(efx, phy_data);
        if (rc != 0)
                goto fail;
 
-       efx->phy_type = phy_cfg->type;
+       /* Read initial link advertisement */
+       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
+       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
+                         outbuf, sizeof(outbuf), NULL);
+       if (rc)
+               goto fail;
+
+       /* Fill out nic state */
+       efx->phy_data = phy_data;
+       efx->phy_type = phy_data->type;
 
-       efx->mdio_bus = phy_cfg->channel;
-       efx->mdio.prtad = phy_cfg->port;
-       efx->mdio.mmds = phy_cfg->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22);
+       efx->mdio_bus = phy_data->channel;
+       efx->mdio.prtad = phy_data->port;
+       efx->mdio.mmds = phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22);
        efx->mdio.mode_support = 0;
-       if (phy_cfg->mmd_mask & (1 << MC_CMD_MMD_CLAUSE22))
+       if (phy_data->mmd_mask & (1 << MC_CMD_MMD_CLAUSE22))
                efx->mdio.mode_support |= MDIO_SUPPORTS_C22;
-       if (phy_cfg->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22))
+       if (phy_data->mmd_mask & ~(1 << MC_CMD_MMD_CLAUSE22))
                efx->mdio.mode_support |= MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
 
+       caps = MCDI_DWORD(outbuf, GET_LINK_OUT_CAP);
+       if (caps & (1 << MC_CMD_PHY_CAP_AN_LBN))
+               efx->link_advertising =
+                       mcdi_to_ethtool_cap(phy_data->media, caps);
+       else
+               phy_data->forced_cap = caps;
+
        /* Assert that we can map efx -> mcdi loopback modes */
        BUILD_BUG_ON(LOOPBACK_NONE != MC_CMD_LOOPBACK_NONE);
        BUILD_BUG_ON(LOOPBACK_DATA != MC_CMD_LOOPBACK_DATA);
@@ -365,46 +381,6 @@ static int efx_mcdi_phy_probe(struct efx_nic *efx)
         * but by convention we don't */
        efx->loopback_modes &= ~(1 << LOOPBACK_NONE);
 
-       kfree(phy_cfg);
-
-       return 0;
-
-fail:
-       kfree(phy_cfg);
-fail_alloc:
-       return rc;
-}
-
-static int efx_mcdi_phy_init(struct efx_nic *efx)
-{
-       struct efx_mcdi_phy_cfg *phy_data;
-       u8 outbuf[MC_CMD_GET_LINK_OUT_LEN];
-       u32 caps;
-       int rc;
-
-       phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
-       if (phy_data == NULL)
-               return -ENOMEM;
-
-       rc = efx_mcdi_get_phy_cfg(efx, phy_data);
-       if (rc != 0)
-               goto fail;
-
-       efx->phy_data = phy_data;
-
-       BUILD_BUG_ON(MC_CMD_GET_LINK_IN_LEN != 0);
-       rc = efx_mcdi_rpc(efx, MC_CMD_GET_LINK, NULL, 0,
-                         outbuf, sizeof(outbuf), NULL);
-       if (rc)
-               goto fail;
-
-       caps = MCDI_DWORD(outbuf, GET_LINK_OUT_CAP);
-       if (caps & (1 << MC_CMD_PHY_CAP_AN_LBN))
-               efx->link_advertising =
-                       mcdi_to_ethtool_cap(phy_data->media, caps);
-       else
-               phy_data->forced_cap = caps;
-
        return 0;
 
 fail:
@@ -504,7 +480,7 @@ static bool efx_mcdi_phy_poll(struct efx_nic *efx)
        return !efx_link_state_equal(&efx->link_state, &old_state);
 }
 
-static void efx_mcdi_phy_fini(struct efx_nic *efx)
+static void efx_mcdi_phy_remove(struct efx_nic *efx)
 {
        struct efx_mcdi_phy_data *phy_data = efx->phy_data;
 
@@ -586,10 +562,11 @@ static int efx_mcdi_phy_set_settings(struct efx_nic *efx, struct ethtool_cmd *ec
 
 struct efx_phy_operations efx_mcdi_phy_ops = {
        .probe          = efx_mcdi_phy_probe,
-       .init           = efx_mcdi_phy_init,
+       .init           = efx_port_dummy_op_int,
        .reconfigure    = efx_mcdi_phy_reconfigure,
        .poll           = efx_mcdi_phy_poll,
-       .fini           = efx_mcdi_phy_fini,
+       .fini           = efx_port_dummy_op_void,
+       .remove         = efx_mcdi_phy_remove,
        .get_settings   = efx_mcdi_phy_get_settings,
        .set_settings   = efx_mcdi_phy_set_settings,
        .run_tests      = NULL,
index 34c381f009b77b13aa90e67be90b25b45375552f..d5aab5b3fa066e27666c44b01dd35c241a0b86f7 100644 (file)
@@ -524,6 +524,7 @@ struct efx_phy_operations {
        int (*probe) (struct efx_nic *efx);
        int (*init) (struct efx_nic *efx);
        void (*fini) (struct efx_nic *efx);
+       void (*remove) (struct efx_nic *efx);
        int (*reconfigure) (struct efx_nic *efx);
        bool (*poll) (struct efx_nic *efx);
        void (*get_settings) (struct efx_nic *efx,
index a577be2278621cd7281ae50b668abe5c860f1cfa..db44224ed2cad53789f7d5410db1a7988f34bca1 100644 (file)
@@ -1576,6 +1576,8 @@ void efx_nic_init_common(struct efx_nic *efx)
        EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_SOFT_EVT_EN, 1);
        /* Prefetch threshold 2 => fetch when descriptor cache half empty */
        EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_PREF_THRESHOLD, 2);
+       /* Disable hardware watchdog which can misfire */
+       EFX_SET_OWORD_FIELD(temp, FRF_AZ_TX_PREF_WD_TMR, 0x3fffff);
        /* Squash TX of packets of 16 bytes or less */
        if (efx_nic_rev(efx) >= EFX_REV_FALCON_B0)
                EFX_SET_OWORD_FIELD(temp, FRF_BZ_TX_FLUSH_MIN_LEN_EN, 1);
index 3800fc791b2f788f69a2c19241f7cc54ebc392f6..ff8f0a417fa3effb8b508cb7ac2681447da7247a 100644 (file)
@@ -33,6 +33,9 @@
 #define PCS_FW_HEARTBEAT_REG   0xd7ee
 #define PCS_FW_HEARTB_LBN      0
 #define PCS_FW_HEARTB_WIDTH    8
+#define PCS_FW_PRODUCT_CODE_1  0xd7f0
+#define PCS_FW_VERSION_1       0xd7f3
+#define PCS_FW_BUILD_1         0xd7f6
 #define PCS_UC8051_STATUS_REG  0xd7fd
 #define PCS_UC_STATUS_LBN      0
 #define PCS_UC_STATUS_WIDTH    8
@@ -52,14 +55,24 @@ void falcon_qt202x_set_led(struct efx_nic *p, int led, int mode)
 
 struct qt202x_phy_data {
        enum efx_phy_mode phy_mode;
+       bool bug17190_in_bad_state;
+       unsigned long bug17190_timer;
+       u32 firmware_ver;
 };
 
 #define QT2022C2_MAX_RESET_TIME 500
 #define QT2022C2_RESET_WAIT 10
 
-static int qt2025c_wait_reset(struct efx_nic *efx)
+#define QT2025C_MAX_HEARTB_TIME (5 * HZ)
+#define QT2025C_HEARTB_WAIT 100
+#define QT2025C_MAX_FWSTART_TIME (25 * HZ / 10)
+#define QT2025C_FWSTART_WAIT 100
+
+#define BUG17190_INTERVAL (2 * HZ)
+
+static int qt2025c_wait_heartbeat(struct efx_nic *efx)
 {
-       unsigned long timeout = jiffies + 10 * HZ;
+       unsigned long timeout = jiffies + QT2025C_MAX_HEARTB_TIME;
        int reg, old_counter = 0;
 
        /* Wait for firmware heartbeat to start */
@@ -74,11 +87,25 @@ static int qt2025c_wait_reset(struct efx_nic *efx)
                        old_counter = counter;
                else if (counter != old_counter)
                        break;
-               if (time_after(jiffies, timeout))
+               if (time_after(jiffies, timeout)) {
+                       /* Some cables have EEPROMs that conflict with the
+                        * PHY's on-board EEPROM so it cannot load firmware */
+                       EFX_ERR(efx, "If an SFP+ direct attach cable is"
+                               " connected, please check that it complies"
+                               " with the SFP+ specification\n");
                        return -ETIMEDOUT;
-               msleep(10);
+               }
+               msleep(QT2025C_HEARTB_WAIT);
        }
 
+       return 0;
+}
+
+static int qt2025c_wait_fw_status_good(struct efx_nic *efx)
+{
+       unsigned long timeout = jiffies + QT2025C_MAX_FWSTART_TIME;
+       int reg;
+
        /* Wait for firmware status to look good */
        for (;;) {
                reg = efx_mdio_read(efx, MDIO_MMD_PCS, PCS_UC8051_STATUS_REG);
@@ -90,7 +117,178 @@ static int qt2025c_wait_reset(struct efx_nic *efx)
                        break;
                if (time_after(jiffies, timeout))
                        return -ETIMEDOUT;
+               msleep(QT2025C_FWSTART_WAIT);
+       }
+
+       return 0;
+}
+
+static void qt2025c_restart_firmware(struct efx_nic *efx)
+{
+       /* Restart microcontroller execution of firmware from RAM */
+       efx_mdio_write(efx, 3, 0xe854, 0x00c0);
+       efx_mdio_write(efx, 3, 0xe854, 0x0040);
+       msleep(50);
+}
+
+static int qt2025c_wait_reset(struct efx_nic *efx)
+{
+       int rc;
+
+       rc = qt2025c_wait_heartbeat(efx);
+       if (rc != 0)
+               return rc;
+
+       rc = qt2025c_wait_fw_status_good(efx);
+       if (rc == -ETIMEDOUT) {
+               /* Bug 17689: occasionally heartbeat starts but firmware status
+                * code never progresses beyond 0x00.  Try again, once, after
+                * restarting execution of the firmware image. */
+               EFX_LOG(efx, "bashing QT2025C microcontroller\n");
+               qt2025c_restart_firmware(efx);
+               rc = qt2025c_wait_heartbeat(efx);
+               if (rc != 0)
+                       return rc;
+               rc = qt2025c_wait_fw_status_good(efx);
+       }
+
+       return rc;
+}
+
+static void qt2025c_firmware_id(struct efx_nic *efx)
+{
+       struct qt202x_phy_data *phy_data = efx->phy_data;
+       u8 firmware_id[9];
+       size_t i;
+
+       for (i = 0; i < sizeof(firmware_id); i++)
+               firmware_id[i] = efx_mdio_read(efx, MDIO_MMD_PCS,
+                                              PCS_FW_PRODUCT_CODE_1 + i);
+       EFX_INFO(efx, "QT2025C firmware %xr%d v%d.%d.%d.%d [20%02d-%02d-%02d]\n",
+                (firmware_id[0] << 8) | firmware_id[1], firmware_id[2],
+                firmware_id[3] >> 4, firmware_id[3] & 0xf,
+                firmware_id[4], firmware_id[5],
+                firmware_id[6], firmware_id[7], firmware_id[8]);
+       phy_data->firmware_ver = ((firmware_id[3] & 0xf0) << 20) |
+                                ((firmware_id[3] & 0x0f) << 16) |
+                                (firmware_id[4] << 8) | firmware_id[5];
+}
+
+static void qt2025c_bug17190_workaround(struct efx_nic *efx)
+{
+       struct qt202x_phy_data *phy_data = efx->phy_data;
+
+       /* The PHY can get stuck in a state where it reports PHY_XS and PMA/PMD
+        * layers up, but PCS down (no block_lock).  If we notice this state
+        * persisting for a couple of seconds, we switch PMA/PMD loopback
+        * briefly on and then off again, which is normally sufficient to
+        * recover it.
+        */
+       if (efx->link_state.up ||
+           !efx_mdio_links_ok(efx, MDIO_DEVS_PMAPMD | MDIO_DEVS_PHYXS)) {
+               phy_data->bug17190_in_bad_state = false;
+               return;
+       }
+
+       if (!phy_data->bug17190_in_bad_state) {
+               phy_data->bug17190_in_bad_state = true;
+               phy_data->bug17190_timer = jiffies + BUG17190_INTERVAL;
+               return;
+       }
+
+       if (time_after_eq(jiffies, phy_data->bug17190_timer)) {
+               EFX_LOG(efx, "bashing QT2025C PMA/PMD\n");
+               efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD, MDIO_CTRL1,
+                                 MDIO_PMA_CTRL1_LOOPBACK, true);
                msleep(100);
+               efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD, MDIO_CTRL1,
+                                 MDIO_PMA_CTRL1_LOOPBACK, false);
+               phy_data->bug17190_timer = jiffies + BUG17190_INTERVAL;
+       }
+}
+
+static int qt2025c_select_phy_mode(struct efx_nic *efx)
+{
+       struct qt202x_phy_data *phy_data = efx->phy_data;
+       struct falcon_board *board = falcon_board(efx);
+       int reg, rc, i;
+       uint16_t phy_op_mode;
+
+       /* Only 2.0.1.0+ PHY firmware supports the more optimal SFP+
+        * Self-Configure mode.  Don't attempt any switching if we encounter
+        * older firmware. */
+       if (phy_data->firmware_ver < 0x02000100)
+               return 0;
+
+       /* In general we will get optimal behaviour in "SFP+ Self-Configure"
+        * mode; however, that powers down most of the PHY when no module is
+        * present, so we must use a different mode (any fixed mode will do)
+        * to be sure that loopbacks will work. */
+       phy_op_mode = (efx->loopback_mode == LOOPBACK_NONE) ? 0x0038 : 0x0020;
+
+       /* Only change mode if really necessary */
+       reg = efx_mdio_read(efx, 1, 0xc319);
+       if ((reg & 0x0038) == phy_op_mode)
+               return 0;
+       EFX_LOG(efx, "Switching PHY to mode 0x%04x\n", phy_op_mode);
+
+       /* This sequence replicates the register writes configured in the boot
+        * EEPROM (including the differences between board revisions), except
+        * that the operating mode is changed, and the PHY is prevented from
+        * unnecessarily reloading the main firmware image again. */
+       efx_mdio_write(efx, 1, 0xc300, 0x0000);
+       /* (Note: this portion of the boot EEPROM sequence, which bit-bashes 9
+        * STOPs onto the firmware/module I2C bus to reset it, varies across
+        * board revisions, as the bus is connected to different GPIO/LED
+        * outputs on the PHY.) */
+       if (board->major == 0 && board->minor < 2) {
+               efx_mdio_write(efx, 1, 0xc303, 0x4498);
+               for (i = 0; i < 9; i++) {
+                       efx_mdio_write(efx, 1, 0xc303, 0x4488);
+                       efx_mdio_write(efx, 1, 0xc303, 0x4480);
+                       efx_mdio_write(efx, 1, 0xc303, 0x4490);
+                       efx_mdio_write(efx, 1, 0xc303, 0x4498);
+               }
+       } else {
+               efx_mdio_write(efx, 1, 0xc303, 0x0920);
+               efx_mdio_write(efx, 1, 0xd008, 0x0004);
+               for (i = 0; i < 9; i++) {
+                       efx_mdio_write(efx, 1, 0xc303, 0x0900);
+                       efx_mdio_write(efx, 1, 0xd008, 0x0005);
+                       efx_mdio_write(efx, 1, 0xc303, 0x0920);
+                       efx_mdio_write(efx, 1, 0xd008, 0x0004);
+               }
+               efx_mdio_write(efx, 1, 0xc303, 0x4900);
+       }
+       efx_mdio_write(efx, 1, 0xc303, 0x4900);
+       efx_mdio_write(efx, 1, 0xc302, 0x0004);
+       efx_mdio_write(efx, 1, 0xc316, 0x0013);
+       efx_mdio_write(efx, 1, 0xc318, 0x0054);
+       efx_mdio_write(efx, 1, 0xc319, phy_op_mode);
+       efx_mdio_write(efx, 1, 0xc31a, 0x0098);
+       efx_mdio_write(efx, 3, 0x0026, 0x0e00);
+       efx_mdio_write(efx, 3, 0x0027, 0x0013);
+       efx_mdio_write(efx, 3, 0x0028, 0xa528);
+       efx_mdio_write(efx, 1, 0xd006, 0x000a);
+       efx_mdio_write(efx, 1, 0xd007, 0x0009);
+       efx_mdio_write(efx, 1, 0xd008, 0x0004);
+       /* This additional write is not present in the boot EEPROM.  It
+        * prevents the PHY's internal boot ROM doing another pointless (and
+        * slow) reload of the firmware image (the microcontroller's code
+        * memory is not affected by the microcontroller reset). */
+       efx_mdio_write(efx, 1, 0xc317, 0x00ff);
+       efx_mdio_write(efx, 1, 0xc300, 0x0002);
+       msleep(20);
+
+       /* Restart microcontroller execution of firmware from RAM */
+       qt2025c_restart_firmware(efx);
+
+       /* Wait for the microcontroller to be ready again */
+       rc = qt2025c_wait_reset(efx);
+       if (rc < 0) {
+               EFX_ERR(efx, "PHY microcontroller reset during mode switch "
+                               "timed out\n");
+               return rc;
        }
 
        return 0;
@@ -137,6 +335,16 @@ static int qt202x_reset_phy(struct efx_nic *efx)
 
 static int qt202x_phy_probe(struct efx_nic *efx)
 {
+       struct qt202x_phy_data *phy_data;
+
+       phy_data = kzalloc(sizeof(struct qt202x_phy_data), GFP_KERNEL);
+       if (!phy_data)
+               return -ENOMEM;
+       efx->phy_data = phy_data;
+       phy_data->phy_mode = efx->phy_mode;
+       phy_data->bug17190_in_bad_state = false;
+       phy_data->bug17190_timer = 0;
+
        efx->mdio.mmds = QT202X_REQUIRED_DEVS;
        efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
        efx->loopback_modes = QT202X_LOOPBACKS | FALCON_XMAC_LOOPBACKS;
@@ -145,7 +353,6 @@ static int qt202x_phy_probe(struct efx_nic *efx)
 
 static int qt202x_phy_init(struct efx_nic *efx)
 {
-       struct qt202x_phy_data *phy_data;
        u32 devid;
        int rc;
 
@@ -155,17 +362,14 @@ static int qt202x_phy_init(struct efx_nic *efx)
                return rc;
        }
 
-       phy_data = kzalloc(sizeof(struct qt202x_phy_data), GFP_KERNEL);
-       if (!phy_data)
-               return -ENOMEM;
-       efx->phy_data = phy_data;
-
        devid = efx_mdio_read_id(efx, MDIO_MMD_PHYXS);
        EFX_INFO(efx, "PHY ID reg %x (OUI %06x model %02x revision %x)\n",
                 devid, efx_mdio_id_oui(devid), efx_mdio_id_model(devid),
                 efx_mdio_id_rev(devid));
 
-       phy_data->phy_mode = efx->phy_mode;
+       if (efx->phy_type == PHY_TYPE_QT2025C)
+               qt2025c_firmware_id(efx);
+
        return 0;
 }
 
@@ -183,6 +387,9 @@ static bool qt202x_phy_poll(struct efx_nic *efx)
        efx->link_state.fd = true;
        efx->link_state.fc = efx->wanted_fc;
 
+       if (efx->phy_type == PHY_TYPE_QT2025C)
+               qt2025c_bug17190_workaround(efx);
+
        return efx->link_state.up != was_up;
 }
 
@@ -191,6 +398,10 @@ static int qt202x_phy_reconfigure(struct efx_nic *efx)
        struct qt202x_phy_data *phy_data = efx->phy_data;
 
        if (efx->phy_type == PHY_TYPE_QT2025C) {
+               int rc = qt2025c_select_phy_mode(efx);
+               if (rc)
+                       return rc;
+
                /* There are several different register bits which can
                 * disable TX (and save power) on direct-attach cables
                 * or optical transceivers, varying somewhat between
@@ -224,7 +435,7 @@ static void qt202x_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecm
        mdio45_ethtool_gset(&efx->mdio, ecmd);
 }
 
-static void qt202x_phy_fini(struct efx_nic *efx)
+static void qt202x_phy_remove(struct efx_nic *efx)
 {
        /* Free the context block */
        kfree(efx->phy_data);
@@ -236,7 +447,8 @@ struct efx_phy_operations falcon_qt202x_phy_ops = {
        .init            = qt202x_phy_init,
        .reconfigure     = qt202x_phy_reconfigure,
        .poll            = qt202x_phy_poll,
-       .fini            = qt202x_phy_fini,
+       .fini            = efx_port_dummy_op_void,
+       .remove          = qt202x_phy_remove,
        .get_settings    = qt202x_phy_get_settings,
        .set_settings    = efx_mdio_set_settings,
 };
index 14949bb303a0bca7e87d4fea48e6e4f69d6eca0c..af3933579790f8aacc4302f193729552efea4fb2 100644 (file)
@@ -47,7 +47,7 @@ static const unsigned char payload_source[ETH_ALEN] = {
        0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b,
 };
 
-static const char *payload_msg =
+static const char payload_msg[] =
        "Hello world! This is an Efx loopback test in progress!";
 
 /**
index de07a4f031b2f0c34cc47d08f829187c0b1aa57a..f8c6771e66d861488bd12fc69d51346a0fedebb6 100644 (file)
@@ -133,6 +133,7 @@ static int siena_probe_port(struct efx_nic *efx)
 
 void siena_remove_port(struct efx_nic *efx)
 {
+       efx->phy_op->remove(efx);
        efx_nic_free_buffer(efx, &efx->stats_buffer);
 }
 
index ca11572a49a93cab33554bdf49d422155c194f46..3009c297c135a647e945b26fc3acfe38fc24237b 100644 (file)
@@ -202,10 +202,14 @@ static ssize_t set_phy_short_reach(struct device *dev,
        int rc;
 
        rtnl_lock();
-       efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TXPWR,
-                         MDIO_PMA_10GBT_TXPWR_SHORT,
-                         count != 0 && *buf != '0');
-       rc = efx_reconfigure_port(efx);
+       if (efx->state != STATE_RUNNING) {
+               rc = -EBUSY;
+       } else {
+               efx_mdio_set_flag(efx, MDIO_MMD_PMAPMD, MDIO_PMA_10GBT_TXPWR,
+                                 MDIO_PMA_10GBT_TXPWR_SHORT,
+                                 count != 0 && *buf != '0');
+               rc = efx_reconfigure_port(efx);
+       }
        rtnl_unlock();
 
        return rc < 0 ? rc : (ssize_t)count;
@@ -298,36 +302,62 @@ static int tenxpress_init(struct efx_nic *efx)
        return 0;
 }
 
-static int sfx7101_phy_probe(struct efx_nic *efx)
+static int tenxpress_phy_probe(struct efx_nic *efx)
 {
-       efx->mdio.mmds = TENXPRESS_REQUIRED_DEVS;
-       efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
-       efx->loopback_modes = SFX7101_LOOPBACKS | FALCON_XMAC_LOOPBACKS;
-       return 0;
-}
+       struct tenxpress_phy_data *phy_data;
+       int rc;
+
+       /* Allocate phy private storage */
+       phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
+       if (!phy_data)
+               return -ENOMEM;
+       efx->phy_data = phy_data;
+       phy_data->phy_mode = efx->phy_mode;
+
+       /* Create any special files */
+       if (efx->phy_type == PHY_TYPE_SFT9001B) {
+               rc = device_create_file(&efx->pci_dev->dev,
+                                       &dev_attr_phy_short_reach);
+               if (rc)
+                       goto fail;
+       }
+
+       if (efx->phy_type == PHY_TYPE_SFX7101) {
+               efx->mdio.mmds = TENXPRESS_REQUIRED_DEVS;
+               efx->mdio.mode_support = MDIO_SUPPORTS_C45;
+
+               efx->loopback_modes = SFX7101_LOOPBACKS | FALCON_XMAC_LOOPBACKS;
+
+               efx->link_advertising = (ADVERTISED_TP | ADVERTISED_Autoneg |
+                                        ADVERTISED_10000baseT_Full);
+       } else {
+               efx->mdio.mmds = TENXPRESS_REQUIRED_DEVS;
+               efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
+
+               efx->loopback_modes = (SFT9001_LOOPBACKS |
+                                      FALCON_XMAC_LOOPBACKS | 
+                                      FALCON_GMAC_LOOPBACKS);
+
+               efx->link_advertising = (ADVERTISED_TP | ADVERTISED_Autoneg |
+                                        ADVERTISED_10000baseT_Full |
+                                        ADVERTISED_1000baseT_Full |
+                                        ADVERTISED_100baseT_Full);
+       }
 
-static int sft9001_phy_probe(struct efx_nic *efx)
-{
-       efx->mdio.mmds = TENXPRESS_REQUIRED_DEVS;
-       efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22;
-       efx->loopback_modes = (SFT9001_LOOPBACKS | FALCON_XMAC_LOOPBACKS |
-                              FALCON_GMAC_LOOPBACKS);
        return 0;
+
+fail:
+       kfree(efx->phy_data);
+       efx->phy_data = NULL;
+       return rc;
 }
 
 static int tenxpress_phy_init(struct efx_nic *efx)
 {
-       struct tenxpress_phy_data *phy_data;
-       int rc = 0;
+       int rc;
 
        falcon_board(efx)->type->init_phy(efx);
 
-       phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
-       if (!phy_data)
-               return -ENOMEM;
-       efx->phy_data = phy_data;
-       phy_data->phy_mode = efx->phy_mode;
-
        if (!(efx->phy_mode & PHY_MODE_SPECIAL)) {
                if (efx->phy_type == PHY_TYPE_SFT9001A) {
                        int reg;
@@ -341,44 +371,27 @@ static int tenxpress_phy_init(struct efx_nic *efx)
 
                rc = efx_mdio_wait_reset_mmds(efx, TENXPRESS_REQUIRED_DEVS);
                if (rc < 0)
-                       goto fail;
+                       return rc;
 
                rc = efx_mdio_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0);
                if (rc < 0)
-                       goto fail;
+                       return rc;
        }
 
        rc = tenxpress_init(efx);
        if (rc < 0)
-               goto fail;
+               return rc;
 
-       /* Initialise advertising flags */
-       efx->link_advertising = (ADVERTISED_TP | ADVERTISED_Autoneg |
-                                 ADVERTISED_10000baseT_Full);
-       if (efx->phy_type != PHY_TYPE_SFX7101)
-               efx->link_advertising |= (ADVERTISED_1000baseT_Full |
-                                          ADVERTISED_100baseT_Full);
+       /* Reinitialise flow control settings */
        efx_link_set_wanted_fc(efx, efx->wanted_fc);
        efx_mdio_an_reconfigure(efx);
 
-       if (efx->phy_type == PHY_TYPE_SFT9001B) {
-               rc = device_create_file(&efx->pci_dev->dev,
-                                       &dev_attr_phy_short_reach);
-               if (rc)
-                       goto fail;
-       }
-
        schedule_timeout_uninterruptible(HZ / 5); /* 200ms */
 
        /* Let XGXS and SerDes out of reset */
        falcon_reset_xaui(efx);
 
        return 0;
-
- fail:
-       kfree(efx->phy_data);
-       efx->phy_data = NULL;
-       return rc;
 }
 
 /* Perform a "special software reset" on the PHY. The caller is
@@ -589,25 +602,26 @@ static bool tenxpress_phy_poll(struct efx_nic *efx)
        return !efx_link_state_equal(&efx->link_state, &old_state);
 }
 
-static void tenxpress_phy_fini(struct efx_nic *efx)
+static void sfx7101_phy_fini(struct efx_nic *efx)
 {
        int reg;
 
+       /* Power down the LNPGA */
+       reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN);
+       efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG, reg);
+
+       /* Waiting here ensures that the board fini, which can turn
+        * off the power to the PHY, won't get run until the LNPGA
+        * powerdown has been given long enough to complete. */
+       schedule_timeout_uninterruptible(LNPGA_PDOWN_WAIT); /* 200 ms */
+}
+
+static void tenxpress_phy_remove(struct efx_nic *efx)
+{
        if (efx->phy_type == PHY_TYPE_SFT9001B)
                device_remove_file(&efx->pci_dev->dev,
                                   &dev_attr_phy_short_reach);
 
-       if (efx->phy_type == PHY_TYPE_SFX7101) {
-               /* Power down the LNPGA */
-               reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN);
-               efx_mdio_write(efx, MDIO_MMD_PMAPMD, PMA_PMD_XCONTROL_REG, reg);
-
-               /* Waiting here ensures that the board fini, which can turn
-                * off the power to the PHY, won't get run until the LNPGA
-                * powerdown has been given long enough to complete. */
-               schedule_timeout_uninterruptible(LNPGA_PDOWN_WAIT); /* 200 ms */
-       }
-
        kfree(efx->phy_data);
        efx->phy_data = NULL;
 }
@@ -819,11 +833,12 @@ static void sft9001_set_npage_adv(struct efx_nic *efx, u32 advertising)
 }
 
 struct efx_phy_operations falcon_sfx7101_phy_ops = {
-       .probe            = sfx7101_phy_probe,
+       .probe            = tenxpress_phy_probe,
        .init             = tenxpress_phy_init,
        .reconfigure      = tenxpress_phy_reconfigure,
        .poll             = tenxpress_phy_poll,
-       .fini             = tenxpress_phy_fini,
+       .fini             = sfx7101_phy_fini,
+       .remove           = tenxpress_phy_remove,
        .get_settings     = tenxpress_get_settings,
        .set_settings     = tenxpress_set_settings,
        .set_npage_adv    = sfx7101_set_npage_adv,
@@ -832,11 +847,12 @@ struct efx_phy_operations falcon_sfx7101_phy_ops = {
 };
 
 struct efx_phy_operations falcon_sft9001_phy_ops = {
-       .probe            = sft9001_phy_probe,
+       .probe            = tenxpress_phy_probe,
        .init             = tenxpress_phy_init,
        .reconfigure      = tenxpress_phy_reconfigure,
        .poll             = tenxpress_phy_poll,
-       .fini             = tenxpress_phy_fini,
+       .fini             = efx_port_dummy_op_void,
+       .remove           = tenxpress_phy_remove,
        .get_settings     = tenxpress_get_settings,
        .set_settings     = tenxpress_set_settings,
        .set_npage_adv    = sft9001_set_npage_adv,
index e669f94e821bde87e23d842fe25005e9568a93a8..a8b70ef6d817ea51a867c217f25fa78871cf5624 100644 (file)
@@ -821,8 +821,6 @@ static void efx_enqueue_unwind(struct efx_tx_queue *tx_queue)
                                           EFX_TXQ_MASK];
                efx_tsoh_free(tx_queue, buffer);
                EFX_BUG_ON_PARANOID(buffer->skb);
-               buffer->len = 0;
-               buffer->continuation = true;
                if (buffer->unmap_len) {
                        unmap_addr = (buffer->dma_addr + buffer->len -
                                      buffer->unmap_len);
@@ -836,6 +834,8 @@ static void efx_enqueue_unwind(struct efx_tx_queue *tx_queue)
                                               PCI_DMA_TODEVICE);
                        buffer->unmap_len = 0;
                }
+               buffer->len = 0;
+               buffer->continuation = true;
        }
 }
 
index c88bc1013047573b9945658970ffd06b082389f0..ca6285016dfd633633c70605c296e703f40c5ee7 100644 (file)
@@ -84,6 +84,8 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
        .mpr            = 1,
        .tpauser        = 1,
        .hw_swap        = 1,
+       .rpadir         = 1,
+       .rpadir_value   = 0x00020000, /* NET_IP_ALIGN assumed to be 2 */
 };
 
 #elif defined(CONFIG_CPU_SUBTYPE_SH7763)
@@ -175,7 +177,6 @@ static struct sh_eth_cpu_data sh_eth_my_cpu_data = {
        .tpauser        = 1,
        .bculr          = 1,
        .hw_swap        = 1,
-       .rpadir         = 1,
        .no_trimd       = 1,
        .no_ade         = 1,
 };
@@ -501,6 +502,8 @@ static int sh_eth_ring_init(struct net_device *ndev)
         */
        mdp->rx_buf_sz = (ndev->mtu <= 1492 ? PKT_BUF_SZ :
                          (((ndev->mtu + 26 + 7) & ~7) + 2 + 16));
+       if (mdp->cd->rpadir)
+               mdp->rx_buf_sz += NET_IP_ALIGN;
 
        /* Allocate RX and TX skb rings */
        mdp->rx_skbuff = kmalloc(sizeof(*mdp->rx_skbuff) * RX_RING_SIZE,
@@ -715,6 +718,8 @@ static int sh_eth_rx(struct net_device *ndev)
                                        pkt_len + 2);
                        skb = mdp->rx_skbuff[entry];
                        mdp->rx_skbuff[entry] = NULL;
+                       if (mdp->cd->rpadir)
+                               skb_reserve(skb, NET_IP_ALIGN);
                        skb_put(skb, pkt_len);
                        skb->protocol = eth_type_trans(skb, ndev);
                        netif_rx(skb);
index 89a05d674ddca5c1acc6748fe2774299f5cc2b95..1c01b96c9611220554a10385e447f579ad36e133 100644 (file)
@@ -644,7 +644,6 @@ static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
 {
        u32 reg1;
 
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
        reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
        reg1 &= ~phy_power[port];
 
@@ -652,7 +651,6 @@ static void sky2_phy_power_up(struct sky2_hw *hw, unsigned port)
                reg1 |= coma_mode[port];
 
        sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
        sky2_pci_read32(hw, PCI_DEV_REG1);
 
        if (hw->chip_id == CHIP_ID_YUKON_FE)
@@ -709,11 +707,9 @@ static void sky2_phy_power_down(struct sky2_hw *hw, unsigned port)
                gm_phy_write(hw, port, PHY_MARV_CTRL, PHY_CT_PDOWN);
        }
 
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
        reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
        reg1 |= phy_power[port];                /* set PHY to PowerDown/COMA Mode */
        sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
 }
 
 /* Force a renegotiation */
@@ -2152,9 +2148,7 @@ static void sky2_qlink_intr(struct sky2_hw *hw)
 
        /* reset PHY Link Detect */
        phy = sky2_pci_read16(hw, PSM_CONFIG_REG4);
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
        sky2_pci_write16(hw, PSM_CONFIG_REG4, phy | 1);
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
 
        sky2_link_up(sky2);
 }
@@ -2645,7 +2639,6 @@ static void sky2_hw_intr(struct sky2_hw *hw)
        if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
                u16 pci_err;
 
-               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
                pci_err = sky2_pci_read16(hw, PCI_STATUS);
                if (net_ratelimit())
                        dev_err(&pdev->dev, "PCI hardware error (0x%x)\n",
@@ -2653,14 +2646,12 @@ static void sky2_hw_intr(struct sky2_hw *hw)
 
                sky2_pci_write16(hw, PCI_STATUS,
                                      pci_err | PCI_STATUS_ERROR_BITS);
-               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
        }
 
        if (status & Y2_IS_PCI_EXP) {
                /* PCI-Express uncorrectable Error occurred */
                u32 err;
 
-               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
                err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
                sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
                             0xfffffffful);
@@ -2668,7 +2659,6 @@ static void sky2_hw_intr(struct sky2_hw *hw)
                        dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err);
 
                sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
-               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
        }
 
        if (status & Y2_HWE_L1_MASK)
@@ -3047,7 +3037,6 @@ static void sky2_reset(struct sky2_hw *hw)
        }
 
        sky2_power_on(hw);
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
 
        for (i = 0; i < hw->ports; i++) {
                sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET);
@@ -3084,7 +3073,6 @@ static void sky2_reset(struct sky2_hw *hw)
                reg <<= PSM_CONFIG_REG4_TIMER_PHY_LINK_DETECT_BASE;
 
                /* reset PHY Link Detect */
-               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
                sky2_pci_write16(hw, PSM_CONFIG_REG4,
                                 reg | PSM_CONFIG_REG4_RST_PHY_LINK_DETECT);
                sky2_pci_write16(hw, PSM_CONFIG_REG4, reg);
@@ -3102,7 +3090,6 @@ static void sky2_reset(struct sky2_hw *hw)
                        /* restore the PCIe Link Control register */
                        sky2_pci_write16(hw, cap + PCI_EXP_LNKCTL, reg);
                }
-               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
 
                /* re-enable PEX PM in PEX PHY debug reg. 8 (clear bit 12) */
                sky2_write32(hw, Y2_PEX_PHY_DATA, PEX_DB_ACCESS | (0x08UL << 16));
@@ -4530,7 +4517,7 @@ static const char *sky2_name(u8 chipid, char *buf, int sz)
                "Optima",       /* 0xbc */
        };
 
-       if (chipid >= CHIP_ID_YUKON_XL && chipid < CHIP_ID_YUKON_OPT)
+       if (chipid >= CHIP_ID_YUKON_XL && chipid <= CHIP_ID_YUKON_OPT)
                strncpy(buf, name[chipid - CHIP_ID_YUKON_XL], sz);
        else
                snprintf(buf, sz, "(chip %#x)", chipid);
index 20d6095cf4118911b6586cbf13dd85bdaaae931e..494cd91ea39c5956102eb4afee1808295d2c5d18 100644 (file)
@@ -2154,7 +2154,7 @@ static int smsc911x_resume(struct device *dev)
        return (to == 0) ? -EIO : 0;
 }
 
-static struct dev_pm_ops smsc911x_pm_ops = {
+static const struct dev_pm_ops smsc911x_pm_ops = {
        .suspend        = smsc911x_suspend,
        .resume         = smsc911x_resume,
 };
index 01e99f22210e0710b8e1bfe77565b051aa849b54..2834a01bae24a9d3e410f342a291b160b43cee02 100644 (file)
@@ -849,13 +849,13 @@ static void tun_sock_write_space(struct sock *sk)
        if (sk->sk_sleep && waitqueue_active(sk->sk_sleep))
                wake_up_interruptible_sync(sk->sk_sleep);
 
-       tun = container_of(sk, struct tun_sock, sk)->tun;
+       tun = tun_sk(sk)->tun;
        kill_fasync(&tun->fasync, SIGIO, POLL_OUT);
 }
 
 static void tun_sock_destruct(struct sock *sk)
 {
-       free_netdev(container_of(sk, struct tun_sock, sk)->tun->dev);
+       free_netdev(tun_sk(sk)->tun->dev);
 }
 
 static struct proto tun_proto = {
@@ -990,7 +990,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
                sk->sk_write_space = tun_sock_write_space;
                sk->sk_sndbuf = INT_MAX;
 
-               container_of(sk, struct tun_sock, sk)->tun = tun;
+               tun_sk(sk)->tun = tun;
 
                security_tun_dev_post_create(sk);
 
index afaf088b72eaab23d1a6847f0e91abcae49ee2d6..41ad2f3697c710dd8be1e46985100e14242e218c 100644 (file)
@@ -1563,7 +1563,10 @@ static int ugeth_disable(struct ucc_geth_private *ugeth, enum comm_dir mode)
 
 static void ugeth_quiesce(struct ucc_geth_private *ugeth)
 {
-       /* Wait for and prevent any further xmits. */
+       /* Prevent any further xmits, plus detach the device. */
+       netif_device_detach(ugeth->ndev);
+
+       /* Wait for any current xmits to finish. */
        netif_tx_disable(ugeth->ndev);
 
        /* Disable the interrupt to avoid NAPI rescheduling. */
@@ -1577,7 +1580,7 @@ static void ugeth_activate(struct ucc_geth_private *ugeth)
 {
        napi_enable(&ugeth->napi);
        enable_irq(ugeth->ug_info->uf_info.irq);
-       netif_tx_wake_all_queues(ugeth->ndev);
+       netif_device_attach(ugeth->ndev);
 }
 
 /* Called every time the controller might need to be made
@@ -1648,25 +1651,28 @@ static void adjust_link(struct net_device *dev)
                        ugeth->oldspeed = phydev->speed;
                }
 
-               /*
-                * To change the MAC configuration we need to disable the
-                * controller. To do so, we have to either grab ugeth->lock,
-                * which is a bad idea since 'graceful stop' commands might
-                * take quite a while, or we can quiesce driver's activity.
-                */
-               ugeth_quiesce(ugeth);
-               ugeth_disable(ugeth, COMM_DIR_RX_AND_TX);
-
-               out_be32(&ug_regs->maccfg2, tempval);
-               out_be32(&uf_regs->upsmr, upsmr);
-
-               ugeth_enable(ugeth, COMM_DIR_RX_AND_TX);
-               ugeth_activate(ugeth);
-
                if (!ugeth->oldlink) {
                        new_state = 1;
                        ugeth->oldlink = 1;
                }
+
+               if (new_state) {
+                       /*
+                        * To change the MAC configuration we need to disable
+                        * the controller. To do so, we have to either grab
+                        * ugeth->lock, which is a bad idea since 'graceful
+                        * stop' commands might take quite a while, or we can
+                        * quiesce driver's activity.
+                        */
+                       ugeth_quiesce(ugeth);
+                       ugeth_disable(ugeth, COMM_DIR_RX_AND_TX);
+
+                       out_be32(&ug_regs->maccfg2, tempval);
+                       out_be32(&uf_regs->upsmr, upsmr);
+
+                       ugeth_enable(ugeth, COMM_DIR_RX_AND_TX);
+                       ugeth_activate(ugeth);
+               }
        } else if (ugeth->oldlink) {
                        new_state = 1;
                        ugeth->oldlink = 0;
@@ -3273,7 +3279,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
                /* Handle the transmitted buffer and release */
                /* the BD to be used with the current frame  */
 
-               if ((bd == ugeth->txBd[txQ]) && (netif_queue_stopped(dev) == 0))
+               if (bd == ugeth->txBd[txQ]) /* queue empty? */
                        break;
 
                dev->stats.tx_packets++;
index b091e20ca1679d82544751a5aa39683b69d244ac..f14d225404da59c5b5ce84b6e3849663e799aca1 100644 (file)
@@ -324,7 +324,7 @@ static int rtl8150_set_mac_address(struct net_device *netdev, void *p)
                dbg("%02X:", netdev->dev_addr[i]);
        dbg("%02X\n", netdev->dev_addr[i]);
        /* Set the IDR registers. */
-       set_registers(dev, IDR, sizeof(netdev->dev_addr), netdev->dev_addr);
+       set_registers(dev, IDR, netdev->addr_len, netdev->dev_addr);
 #ifdef EEPROM_WRITE
        {
        u8 cr;
index 593e01f64e9bbc6c62e518e68fa198dd0a245155..611b80435955343eb53e25fc2ef868e76440d9a5 100644 (file)
@@ -102,6 +102,7 @@ static const int multicast_filter_limit = 32;
 #include <linux/ethtool.h>
 #include <linux/crc32.h>
 #include <linux/bitops.h>
+#include <linux/workqueue.h>
 #include <asm/processor.h>     /* Processor type for cache alignment. */
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -389,6 +390,7 @@ struct rhine_private {
        struct net_device *dev;
        struct napi_struct napi;
        spinlock_t lock;
+       struct work_struct reset_task;
 
        /* Frequently used values: keep some adjacent for cache effect. */
        u32 quirks;
@@ -407,6 +409,7 @@ struct rhine_private {
 static int  mdio_read(struct net_device *dev, int phy_id, int location);
 static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
 static int  rhine_open(struct net_device *dev);
+static void rhine_reset_task(struct work_struct *work);
 static void rhine_tx_timeout(struct net_device *dev);
 static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
                                  struct net_device *dev);
@@ -775,6 +778,8 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
        dev->irq = pdev->irq;
 
        spin_lock_init(&rp->lock);
+       INIT_WORK(&rp->reset_task, rhine_reset_task);
+
        rp->mii_if.dev = dev;
        rp->mii_if.mdio_read = mdio_read;
        rp->mii_if.mdio_write = mdio_write;
@@ -1179,22 +1184,18 @@ static int rhine_open(struct net_device *dev)
        return 0;
 }
 
-static void rhine_tx_timeout(struct net_device *dev)
+static void rhine_reset_task(struct work_struct *work)
 {
-       struct rhine_private *rp = netdev_priv(dev);
-       void __iomem *ioaddr = rp->base;
-
-       printk(KERN_WARNING "%s: Transmit timed out, status %4.4x, PHY status "
-              "%4.4x, resetting...\n",
-              dev->name, ioread16(ioaddr + IntrStatus),
-              mdio_read(dev, rp->mii_if.phy_id, MII_BMSR));
+       struct rhine_private *rp = container_of(work, struct rhine_private,
+                                               reset_task);
+       struct net_device *dev = rp->dev;
 
        /* protect against concurrent rx interrupts */
        disable_irq(rp->pdev->irq);
 
        napi_disable(&rp->napi);
 
-       spin_lock(&rp->lock);
+       spin_lock_bh(&rp->lock);
 
        /* clear all descriptors */
        free_tbufs(dev);
@@ -1206,7 +1207,7 @@ static void rhine_tx_timeout(struct net_device *dev)
        rhine_chip_reset(dev);
        init_registers(dev);
 
-       spin_unlock(&rp->lock);
+       spin_unlock_bh(&rp->lock);
        enable_irq(rp->pdev->irq);
 
        dev->trans_start = jiffies;
@@ -1214,6 +1215,19 @@ static void rhine_tx_timeout(struct net_device *dev)
        netif_wake_queue(dev);
 }
 
+static void rhine_tx_timeout(struct net_device *dev)
+{
+       struct rhine_private *rp = netdev_priv(dev);
+       void __iomem *ioaddr = rp->base;
+
+       printk(KERN_WARNING "%s: Transmit timed out, status %4.4x, PHY status "
+              "%4.4x, resetting...\n",
+              dev->name, ioread16(ioaddr + IntrStatus),
+              mdio_read(dev, rp->mii_if.phy_id, MII_BMSR));
+
+       schedule_work(&rp->reset_task);
+}
+
 static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
                                  struct net_device *dev)
 {
@@ -1830,10 +1844,11 @@ static int rhine_close(struct net_device *dev)
        struct rhine_private *rp = netdev_priv(dev);
        void __iomem *ioaddr = rp->base;
 
-       spin_lock_irq(&rp->lock);
-
-       netif_stop_queue(dev);
        napi_disable(&rp->napi);
+       cancel_work_sync(&rp->reset_task);
+       netif_stop_queue(dev);
+
+       spin_lock_irq(&rp->lock);
 
        if (debug > 1)
                printk(KERN_DEBUG "%s: Shutting down ethercard, "
index 1ceb9d0f8b9720309beceb4a2f62581a9bf2e5f8..9cc438282d776c5e8e4d57d96f0267a15371403a 100644 (file)
@@ -2689,7 +2689,7 @@ vmxnet3_resume(struct device *device)
        return 0;
 }
 
-static struct dev_pm_ops vmxnet3_pm_ops = {
+static const struct dev_pm_ops vmxnet3_pm_ops = {
        .suspend = vmxnet3_suspend,
        .resume = vmxnet3_resume,
 };
index f1c4b2a1e8678ea43085c55f522a1ea12d599979..0fdfd58a35a1bc9572c27b164b4ed8e81a0060e1 100644 (file)
@@ -4087,21 +4087,21 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
                goto _exit0;
        }
 
-       if (!pci_set_dma_mask(pdev, 0xffffffffffffffffULL)) {
+       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
                vxge_debug_ll_config(VXGE_TRACE,
                        "%s : using 64bit DMA", __func__);
 
                high_dma = 1;
 
                if (pci_set_consistent_dma_mask(pdev,
-                                               0xffffffffffffffffULL)) {
+                                               DMA_BIT_MASK(64))) {
                        vxge_debug_init(VXGE_ERR,
                                "%s : unable to obtain 64bit DMA for "
                                "consistent allocations", __func__);
                        ret = -ENOMEM;
                        goto _exit1;
                }
-       } else if (!pci_set_dma_mask(pdev, 0xffffffffUL)) {
+       } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
                vxge_debug_ll_config(VXGE_TRACE,
                        "%s : using 32bit DMA", __func__);
        } else {
index a4c086f069b168aad8e9a434104e3a809e40bff1..e63b7c40d0eeb5ce0b8fcca0df66beece476e209 100644 (file)
@@ -1903,17 +1903,6 @@ accept:
                rxs->noise = sc->ah->ah_noise_floor;
                rxs->signal = rxs->noise + rs.rs_rssi;
 
-               /* An rssi of 35 indicates you should be able use
-                * 54 Mbps reliably. A more elaborate scheme can be used
-                * here but it requires a map of SNR/throughput for each
-                * possible mode used */
-               rxs->qual = rs.rs_rssi * 100 / 35;
-
-               /* rssi can be more than 35 though, anything above that
-                * should be considered at 100% */
-               if (rxs->qual > 100)
-                       rxs->qual = 100;
-
                rxs->antenna = rs.rs_antenna;
                rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate);
                rxs->flag |= ath5k_rx_decrypted(sc, ds, skb, &rs);
@@ -2381,6 +2370,9 @@ ath5k_init(struct ath5k_softc *sc)
         */
        ath5k_stop_locked(sc);
 
+       /* Set PHY calibration interval */
+       ah->ah_cal_intval = ath5k_calinterval;
+
        /*
         * The basic interface to setting the hardware in a good
         * state is ``reset''.  On return the hardware is known to
@@ -2408,10 +2400,6 @@ ath5k_init(struct ath5k_softc *sc)
 
        /* Set ack to be sent at low bit-rates */
        ath5k_hw_set_ack_bitrate_high(ah, false);
-
-       /* Set PHY calibration inteval */
-       ah->ah_cal_intval = ath5k_calinterval;
-
        ret = 0;
 done:
        mmiowb();
index 71b84d91dcffbb2d6edd2e66ede4b9d73f1d9fab..efc420cd42bf91322f23cf711e638b3f7e8906c2 100644 (file)
@@ -186,7 +186,7 @@ bool ath9k_hw_stoptxdma(struct ath_hw *ah, u32 q)
                wait = wait_time;
                while (ath9k_hw_numtxpending(ah, q)) {
                        if ((--wait) == 0) {
-                               ath_print(common, ATH_DBG_QUEUE,
+                               ath_print(common, ATH_DBG_FATAL,
                                          "Failed to stop TX DMA in 100 "
                                          "msec after killing last frame\n");
                                break;
index 0c87771383f08902a0610b873ce04bc6f238b3f6..e185479e295e9407e771b654ee7cfcfecf436ad1 100644 (file)
@@ -77,6 +77,9 @@
 #define ATH9K_TXERR_XTXOP          0x08
 #define ATH9K_TXERR_TIMER_EXPIRED  0x10
 #define ATH9K_TX_ACKED            0x20
+#define ATH9K_TXERR_MASK                                               \
+       (ATH9K_TXERR_XRETRY | ATH9K_TXERR_FILT | ATH9K_TXERR_FIFO |     \
+        ATH9K_TXERR_XTXOP | ATH9K_TXERR_TIMER_EXPIRED)
 
 #define ATH9K_TX_BA                0x01
 #define ATH9K_TX_PWRMGMT           0x02
index c48743452515c16c5fdae713ceeda416156fccab..996eb90263ccba96363b17076504bdccfe8863db 100644 (file)
@@ -1973,6 +1973,9 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
        struct ieee80211_hw *hw = sc->hw;
        int r;
 
+       /* Stop ANI */
+       del_timer_sync(&common->ani.timer);
+
        ath9k_hw_set_interrupts(ah, 0);
        ath_drain_all_txq(sc, retry_tx);
        ath_stoprecv(sc);
@@ -2014,6 +2017,9 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
                }
        }
 
+       /* Start ANI */
+       ath_start_ani(common);
+
        return r;
 }
 
@@ -2508,6 +2514,9 @@ static void ath9k_stop(struct ieee80211_hw *hw)
                return; /* another wiphy still in use */
        }
 
+       /* Ensure HW is awake when we try to shut it down. */
+       ath9k_ps_wakeup(sc);
+
        if (ah->btcoex_hw.enabled) {
                ath9k_hw_btcoex_disable(ah);
                if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
@@ -2528,6 +2537,9 @@ static void ath9k_stop(struct ieee80211_hw *hw)
        /* disable HAL and put h/w to sleep */
        ath9k_hw_disable(ah);
        ath9k_hw_configpcipowersave(ah, 1, 1);
+       ath9k_ps_restore(sc);
+
+       /* Finally, put the chip in FULL SLEEP mode */
        ath9k_setpower(sc, ATH9K_PM_FULL_SLEEP);
 
        sc->sc_flags |= SC_OP_INVALID;
@@ -2641,8 +2653,10 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
        if ((sc->sc_ah->opmode == NL80211_IFTYPE_AP) ||
            (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) ||
            (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) {
+               ath9k_ps_wakeup(sc);
                ath9k_hw_stoptxdma(sc->sc_ah, sc->beacon.beaconq);
                ath_beacon_return(sc, avp);
+               ath9k_ps_restore(sc);
        }
 
        sc->sc_flags &= ~SC_OP_BEACONS;
@@ -3091,15 +3105,21 @@ static int ath9k_ampdu_action(struct ieee80211_hw *hw,
        case IEEE80211_AMPDU_RX_STOP:
                break;
        case IEEE80211_AMPDU_TX_START:
+               ath9k_ps_wakeup(sc);
                ath_tx_aggr_start(sc, sta, tid, ssn);
                ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
+               ath9k_ps_restore(sc);
                break;
        case IEEE80211_AMPDU_TX_STOP:
+               ath9k_ps_wakeup(sc);
                ath_tx_aggr_stop(sc, sta, tid);
                ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
+               ath9k_ps_restore(sc);
                break;
        case IEEE80211_AMPDU_TX_OPERATIONAL:
+               ath9k_ps_wakeup(sc);
                ath_tx_aggr_resume(sc, sta, tid);
+               ath9k_ps_restore(sc);
                break;
        default:
                ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
index 5321f735e5a01592a59869343c2dae16de127210..f7af5ea54753725b45325d719c8e3b0ad22f97c8 100644 (file)
@@ -96,7 +96,7 @@ static void ath_pci_bt_coex_prep(struct ath_common *common)
        pci_write_config_byte(pdev, ATH_PCIE_CAP_LINK_CTRL, aspm);
 }
 
-const static struct ath_bus_ops ath_pci_bus_ops = {
+static const struct ath_bus_ops ath_pci_bus_ops = {
        .read_cachesize = ath_pci_read_cachesize,
        .cleanup = ath_pci_cleanup,
        .eeprom_read = ath_pci_eeprom_read,
index 2a11cc57ceeae891b2ef7a0f8c1bbf105e9a7f17..fa12b9060b0bbc1f0d5ae375501abdb9c2d31a0b 100644 (file)
@@ -1108,11 +1108,11 @@ void ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
        if (npend) {
                int r;
 
-               ath_print(common, ATH_DBG_XMIT,
+               ath_print(common, ATH_DBG_FATAL,
                          "Unable to stop TxDMA. Reset HAL!\n");
 
                spin_lock_bh(&sc->sc_resetlock);
-               r = ath9k_hw_reset(ah, sc->sc_ah->curchan, true);
+               r = ath9k_hw_reset(ah, sc->sc_ah->curchan, false);
                if (r)
                        ath_print(common, ATH_DBG_FATAL,
                                  "Unable to reset hardware; reset status %d\n",
@@ -1414,17 +1414,9 @@ static void assign_aggr_tid_seqno(struct sk_buff *skb,
         * For HT capable stations, we save tidno for later use.
         * We also override seqno set by upper layer with the one
         * in tx aggregation state.
-        *
-        * If fragmentation is on, the sequence number is
-        * not overridden, since it has been
-        * incremented by the fragmentation routine.
-        *
-        * FIXME: check if the fragmentation threshold exceeds
-        * IEEE80211 max.
         */
        tid = ATH_AN_2_TID(an, bf->bf_tidno);
-       hdr->seq_ctrl = cpu_to_le16(tid->seq_next <<
-                       IEEE80211_SEQ_SEQ_SHIFT);
+       hdr->seq_ctrl = cpu_to_le16(tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT);
        bf->bf_seqno = tid->seq_next;
        INCR(tid->seq_next, IEEE80211_SEQ_MAX);
 }
@@ -1636,7 +1628,8 @@ static int ath_tx_setup_buffer(struct ieee80211_hw *hw, struct ath_buf *bf,
                bf->bf_keyix = ATH9K_TXKEYIX_INVALID;
        }
 
-       if (ieee80211_is_data_qos(fc) && (sc->sc_flags & SC_OP_TXAGGR))
+       if (ieee80211_is_data_qos(fc) && bf_isht(bf) &&
+           (sc->sc_flags & SC_OP_TXAGGR))
                assign_aggr_tid_seqno(skb, bf);
 
        bf->bf_mpdu = skb;
@@ -1780,7 +1773,8 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
        struct ath_wiphy *aphy = hw->priv;
        struct ath_softc *sc = aphy->sc;
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-       int hdrlen, padsize;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       int padpos, padsize;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        struct ath_tx_control txctl;
 
@@ -1792,7 +1786,6 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
         * BSSes.
         */
        if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
-               struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
                if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
                        sc->tx.seq_no += 0x10;
                hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
@@ -1800,9 +1793,9 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
        }
 
        /* Add the padding after the header if this is not already done */
-       hdrlen = ieee80211_get_hdrlen_from_skb(skb);
-       if (hdrlen & 3) {
-               padsize = hdrlen % 4;
+       padpos = ath9k_cmn_padpos(hdr->frame_control);
+       padsize = padpos & 3;
+       if (padsize && skb->len>padpos) {
                if (skb_headroom(skb) < padsize) {
                        ath_print(common, ATH_DBG_XMIT,
                                  "TX CABQ padding failed\n");
@@ -1810,7 +1803,7 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct sk_buff *skb)
                        return;
                }
                skb_push(skb, padsize);
-               memmove(skb->data, skb->data + padsize, hdrlen);
+               memmove(skb->data, skb->data + padsize, padpos);
        }
 
        txctl.txq = sc->beacon.cabq;
@@ -1838,7 +1831,8 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
        struct ieee80211_hw *hw = sc->hw;
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-       int hdrlen, padsize;
+       struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
+       int padpos, padsize;
 
        ath_print(common, ATH_DBG_XMIT, "TX complete: skb: %p\n", skb);
 
@@ -1853,14 +1847,14 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
                tx_info->flags |= IEEE80211_TX_STAT_ACK;
        }
 
-       hdrlen = ieee80211_get_hdrlen_from_skb(skb);
-       padsize = hdrlen & 3;
-       if (padsize && hdrlen >= 24) {
+       padpos = ath9k_cmn_padpos(hdr->frame_control);
+       padsize = padpos & 3;
+       if (padsize && skb->len>padpos+padsize) {
                /*
                 * Remove MAC header padding before giving the frame back to
                 * mac80211.
                 */
-               memmove(skb->data + padsize, skb->data, hdrlen);
+               memmove(skb->data + padsize, skb->data, padpos);
                skb_pull(skb, padsize);
        }
 
@@ -2078,7 +2072,7 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
                                &txq->axq_q, lastbf->list.prev);
 
                txq->axq_depth--;
-               txok = !(ds->ds_txstat.ts_status & ATH9K_TXERR_FILT);
+               txok = !(ds->ds_txstat.ts_status & ATH9K_TXERR_MASK);
                txq->axq_tx_inprogress = false;
                spin_unlock_bh(&txq->axq_lock);
 
index 027be275e0351ee401e28d4b7f5993bbe3c0def5..88d1fd02d40ae50fd01b645e921e83e8c48fbced 100644 (file)
@@ -383,160 +383,44 @@ static inline
        }
 }
 
-/* Check if a DMA region fits the device constraints.
- * Returns true, if the region is OK for usage with this device. */
-static inline bool b43_dma_address_ok(struct b43_dmaring *ring,
-                                     dma_addr_t addr, size_t size)
-{
-       switch (ring->type) {
-       case B43_DMA_30BIT:
-               if ((u64)addr + size > (1ULL << 30))
-                       return 0;
-               break;
-       case B43_DMA_32BIT:
-               if ((u64)addr + size > (1ULL << 32))
-                       return 0;
-               break;
-       case B43_DMA_64BIT:
-               /* Currently we can't have addresses beyond
-                * 64bit in the kernel. */
-               break;
-       }
-       return 1;
-}
-
-#define is_4k_aligned(addr)    (((u64)(addr) & 0x0FFFull) == 0)
-#define is_8k_aligned(addr)    (((u64)(addr) & 0x1FFFull) == 0)
-
-static void b43_unmap_and_free_ringmem(struct b43_dmaring *ring, void *base,
-                                      dma_addr_t dmaaddr, size_t size)
-{
-       ssb_dma_unmap_single(ring->dev->dev, dmaaddr, size, DMA_TO_DEVICE);
-       free_pages((unsigned long)base, get_order(size));
-}
-
-static void * __b43_get_and_map_ringmem(struct b43_dmaring *ring,
-                                       dma_addr_t *dmaaddr, size_t size,
-                                       gfp_t gfp_flags)
-{
-       void *base;
-
-       base = (void *)__get_free_pages(gfp_flags, get_order(size));
-       if (!base)
-               return NULL;
-       memset(base, 0, size);
-       *dmaaddr = ssb_dma_map_single(ring->dev->dev, base, size,
-                                     DMA_TO_DEVICE);
-       if (ssb_dma_mapping_error(ring->dev->dev, *dmaaddr)) {
-               free_pages((unsigned long)base, get_order(size));
-               return NULL;
-       }
-
-       return base;
-}
-
-static void * b43_get_and_map_ringmem(struct b43_dmaring *ring,
-                                     dma_addr_t *dmaaddr, size_t size)
-{
-       void *base;
-
-       base = __b43_get_and_map_ringmem(ring, dmaaddr, size,
-                                        GFP_KERNEL);
-       if (!base) {
-               b43err(ring->dev->wl, "Failed to allocate or map pages "
-                      "for DMA ringmemory\n");
-               return NULL;
-       }
-       if (!b43_dma_address_ok(ring, *dmaaddr, size)) {
-               /* The memory does not fit our device constraints.
-                * Retry with GFP_DMA set to get lower memory. */
-               b43_unmap_and_free_ringmem(ring, base, *dmaaddr, size);
-               base = __b43_get_and_map_ringmem(ring, dmaaddr, size,
-                                                GFP_KERNEL | GFP_DMA);
-               if (!base) {
-                       b43err(ring->dev->wl, "Failed to allocate or map pages "
-                              "in the GFP_DMA region for DMA ringmemory\n");
-                       return NULL;
-               }
-               if (!b43_dma_address_ok(ring, *dmaaddr, size)) {
-                       b43_unmap_and_free_ringmem(ring, base, *dmaaddr, size);
-                       b43err(ring->dev->wl, "Failed to allocate DMA "
-                              "ringmemory that fits device constraints\n");
-                       return NULL;
-               }
-       }
-       /* We expect the memory to be 4k aligned, at least. */
-       if (B43_WARN_ON(!is_4k_aligned(*dmaaddr))) {
-               b43_unmap_and_free_ringmem(ring, base, *dmaaddr, size);
-               return NULL;
-       }
-
-       return base;
-}
-
 static int alloc_ringmemory(struct b43_dmaring *ring)
 {
-       unsigned int required;
-       void *base;
-       dma_addr_t dmaaddr;
-
-       /* There are several requirements to the descriptor ring memory:
-        * - The memory region needs to fit the address constraints for the
-        *   device (same as for frame buffers).
-        * - For 30/32bit DMA devices, the descriptor ring must be 4k aligned.
-        * - For 64bit DMA devices, the descriptor ring must be 8k aligned.
+       gfp_t flags = GFP_KERNEL;
+
+       /* The specs call for 4K buffers for 30- and 32-bit DMA with 4K
+        * alignment and 8K buffers for 64-bit DMA with 8K alignment. Testing
+        * has shown that 4K is sufficient for the latter as long as the buffer
+        * does not cross an 8K boundary.
+        *
+        * For unknown reasons - possibly a hardware error - the BCM4311 rev
+        * 02, which uses 64-bit DMA, needs the ring buffer in very low memory,
+        * which accounts for the GFP_DMA flag below.
+        *
+        * The flags here must match the flags in free_ringmemory below!
         */
-
        if (ring->type == B43_DMA_64BIT)
-               required = ring->nr_slots * sizeof(struct b43_dmadesc64);
-       else
-               required = ring->nr_slots * sizeof(struct b43_dmadesc32);
-       if (B43_WARN_ON(required > 0x1000))
+               flags |= GFP_DMA;
+       ring->descbase = ssb_dma_alloc_consistent(ring->dev->dev,
+                                                 B43_DMA_RINGMEMSIZE,
+                                                 &(ring->dmabase), flags);
+       if (!ring->descbase) {
+               b43err(ring->dev->wl, "DMA ringmemory allocation failed\n");
                return -ENOMEM;
-
-       ring->alloc_descsize = 0x1000;
-       base = b43_get_and_map_ringmem(ring, &dmaaddr, ring->alloc_descsize);
-       if (!base)
-               return -ENOMEM;
-       ring->alloc_descbase = base;
-       ring->alloc_dmabase = dmaaddr;
-
-       if ((ring->type != B43_DMA_64BIT) || is_8k_aligned(dmaaddr)) {
-               /* We're on <=32bit DMA, or we already got 8k aligned memory.
-                * That's all we need, so we're fine. */
-               ring->descbase = base;
-               ring->dmabase = dmaaddr;
-               return 0;
-       }
-       b43_unmap_and_free_ringmem(ring, base, dmaaddr, ring->alloc_descsize);
-
-       /* Ok, we failed at the 8k alignment requirement.
-        * Try to force-align the memory region now. */
-       ring->alloc_descsize = 0x2000;
-       base = b43_get_and_map_ringmem(ring, &dmaaddr, ring->alloc_descsize);
-       if (!base)
-               return -ENOMEM;
-       ring->alloc_descbase = base;
-       ring->alloc_dmabase = dmaaddr;
-
-       if (is_8k_aligned(dmaaddr)) {
-               /* We're already 8k aligned. That Ok, too. */
-               ring->descbase = base;
-               ring->dmabase = dmaaddr;
-               return 0;
        }
-       /* Force-align it to 8k */
-       ring->descbase = (void *)((u8 *)base + 0x1000);
-       ring->dmabase = dmaaddr + 0x1000;
-       B43_WARN_ON(!is_8k_aligned(ring->dmabase));
+       memset(ring->descbase, 0, B43_DMA_RINGMEMSIZE);
 
        return 0;
 }
 
 static void free_ringmemory(struct b43_dmaring *ring)
 {
-       b43_unmap_and_free_ringmem(ring, ring->alloc_descbase,
-                                  ring->alloc_dmabase, ring->alloc_descsize);
+       gfp_t flags = GFP_KERNEL;
+
+       if (ring->type == B43_DMA_64BIT)
+               flags |= GFP_DMA;
+
+       ssb_dma_free_consistent(ring->dev->dev, B43_DMA_RINGMEMSIZE,
+                               ring->descbase, ring->dmabase, flags);
 }
 
 /* Reset the RX DMA channel */
@@ -646,14 +530,29 @@ static bool b43_dma_mapping_error(struct b43_dmaring *ring,
        if (unlikely(ssb_dma_mapping_error(ring->dev->dev, addr)))
                return 1;
 
-       if (!b43_dma_address_ok(ring, addr, buffersize)) {
-               /* We can't support this address. Unmap it again. */
-               unmap_descbuffer(ring, addr, buffersize, dma_to_device);
-               return 1;
+       switch (ring->type) {
+       case B43_DMA_30BIT:
+               if ((u64)addr + buffersize > (1ULL << 30))
+                       goto address_error;
+               break;
+       case B43_DMA_32BIT:
+               if ((u64)addr + buffersize > (1ULL << 32))
+                       goto address_error;
+               break;
+       case B43_DMA_64BIT:
+               /* Currently we can't have addresses beyond
+                * 64bit in the kernel. */
+               break;
        }
 
        /* The address is OK. */
        return 0;
+
+address_error:
+       /* We can't support this address. Unmap it again. */
+       unmap_descbuffer(ring, addr, buffersize, dma_to_device);
+
+       return 1;
 }
 
 static bool b43_rx_buffer_is_poisoned(struct b43_dmaring *ring, struct sk_buff *skb)
@@ -715,9 +614,6 @@ static int setup_rx_descbuffer(struct b43_dmaring *ring,
        meta->dmaaddr = dmaaddr;
        ring->ops->fill_descriptor(ring, desc, dmaaddr,
                                   ring->rx_buffersize, 0, 0, 0);
-       ssb_dma_sync_single_for_device(ring->dev->dev,
-                                      ring->alloc_dmabase,
-                                      ring->alloc_descsize, DMA_TO_DEVICE);
 
        return 0;
 }
@@ -1354,9 +1250,6 @@ static int dma_tx_fragment(struct b43_dmaring *ring,
        }
        /* Now transfer the whole frame. */
        wmb();
-       ssb_dma_sync_single_for_device(ring->dev->dev,
-                                      ring->alloc_dmabase,
-                                      ring->alloc_descsize, DMA_TO_DEVICE);
        ops->poke_tx(ring, next_slot(ring, slot));
        return 0;
 
index e607b392314c9449a49431dcb92ebf47f8da1dfd..f7ab37c4cdbc8dfa88301c5384c91650e1046f63 100644 (file)
@@ -157,6 +157,7 @@ struct b43_dmadesc_generic {
 } __attribute__ ((__packed__));
 
 /* Misc DMA constants */
+#define B43_DMA_RINGMEMSIZE            PAGE_SIZE
 #define B43_DMA0_RX_FRAMEOFFSET                30
 
 /* DMA engine tuning knobs */
@@ -246,12 +247,6 @@ struct b43_dmaring {
        /* The QOS priority assigned to this ring. Only used for TX rings.
         * This is the mac80211 "queue" value. */
        u8 queue_prio;
-       /* Pointers and size of the originally allocated and mapped memory
-        * region for the descriptor ring. */
-       void *alloc_descbase;
-       dma_addr_t alloc_dmabase;
-       unsigned int alloc_descsize;
-       /* Pointer to our wireless device. */
        struct b43_wldev *dev;
 #ifdef CONFIG_B43_DEBUG
        /* Maximum number of used slots. */
index 7da1dab933d985b2777ce51412b5650e91e7c62c..234891d8cc1080b5358b624cf992fbc6d43510a6 100644 (file)
@@ -681,19 +681,13 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv,
                snr = rx_stats_sig_avg / rx_stats_noise_diff;
                rx_status.noise = rx_status.signal -
                                        iwl3945_calc_db_from_ratio(snr);
-               rx_status.qual = iwl3945_calc_sig_qual(rx_status.signal,
-                                                        rx_status.noise);
-
-       /* If noise info not available, calculate signal quality indicator (%)
-        *   using just the dBm signal level. */
        } else {
                rx_status.noise = priv->last_rx_noise;
-               rx_status.qual = iwl3945_calc_sig_qual(rx_status.signal, 0);
        }
 
 
-       IWL_DEBUG_STATS(priv, "Rssi %d noise %d qual %d sig_avg %d noise_diff %d\n",
-                       rx_status.signal, rx_status.noise, rx_status.qual,
+       IWL_DEBUG_STATS(priv, "Rssi %d noise %d sig_avg %d noise_diff %d\n",
+                       rx_status.signal, rx_status.noise,
                        rx_stats_sig_avg, rx_stats_noise_diff);
 
        header = (struct ieee80211_hdr *)IWL_RX_DATA(pkt);
@@ -1835,8 +1829,7 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv)
                rc = -EIO;
        }
 
-       priv->alloc_rxb_page--;
-       free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
+       iwl_free_pages(priv, cmd.reply_page);
 
        return rc;
 }
@@ -2836,6 +2829,7 @@ static struct iwl_cfg iwl3945_bg_cfg = {
        .use_isr_legacy = true,
        .ht_greenfield_support = false,
        .led_compensation = 64,
+       .broken_powersave = true,
 };
 
 static struct iwl_cfg iwl3945_abg_cfg = {
@@ -2852,6 +2846,7 @@ static struct iwl_cfg iwl3945_abg_cfg = {
        .use_isr_legacy = true,
        .ht_greenfield_support = false,
        .led_compensation = 64,
+       .broken_powersave = true,
 };
 
 struct pci_device_id iwl3945_hw_card_ids[] = {
index ecc23ec1f6a42981040112aca718afc5d6d15ea7..531fa125f5a60744b4c20f33bc61db4713394420 100644 (file)
@@ -222,7 +222,6 @@ struct iwl3945_ibss_seq {
  *
  *****************************************************************************/
 extern int iwl3945_calc_db_from_ratio(int sig_ratio);
-extern int iwl3945_calc_sig_qual(int rssi_dbm, int noise_dbm);
 extern void iwl3945_rx_replenish(void *data);
 extern void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
 extern unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv,
index 386513b601f5caff86e22c73d90e106015cdc8be..484c5fdf7c2a511143ed569ec11833f7d45d7424 100644 (file)
@@ -1204,7 +1204,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel,
        iwl4965_interpolate_chan(priv, channel, &ch_eeprom_info);
 
        /* calculate tx gain adjustment based on power supply voltage */
-       voltage = priv->calib_info->voltage;
+       voltage = le16_to_cpu(priv->calib_info->voltage);
        init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage);
        voltage_compensation =
            iwl4965_get_voltage_compensation(voltage, init_voltage);
index 4ef6804a455af2e31259db3a048fe4360f20dfe1..bc056e9ab85f0e38f73f60614462f8d36236fa73 100644 (file)
 
 static inline s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
 {
-       u16 *temp_calib = (u16 *)iwl_eeprom_query_addr(priv,
-                                                      EEPROM_5000_TEMPERATURE);
-       /* offset =  temperature -  voltage / coef */
-       s32 offset = (s32)(temp_calib[0] - temp_calib[1] / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
-       return offset;
+       u16 temperature, voltage;
+       __le16 *temp_calib =
+               (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_TEMPERATURE);
+
+       temperature = le16_to_cpu(temp_calib[0]);
+       voltage = le16_to_cpu(temp_calib[1]);
+
+       /* offset = temp - volt / coeff */
+       return (s32)(temperature - voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
 }
 
 /* Fixed (non-configurable) rx data from phy */
index e2f8615c8c9b77bf81004bc7e415133fc5b2eb74..33a5866538e7dbbbc0c7b0a13085075a59939fba 100644 (file)
@@ -333,14 +333,15 @@ static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
 static int iwl5000_set_Xtal_calib(struct iwl_priv *priv)
 {
        struct iwl_calib_xtal_freq_cmd cmd;
-       u16 *xtal_calib = (u16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
+       __le16 *xtal_calib =
+               (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_5000_XTAL);
 
        cmd.hdr.op_code = IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD;
        cmd.hdr.first_group = 0;
        cmd.hdr.groups_num = 1;
        cmd.hdr.data_valid = 1;
-       cmd.cap_pin1 = (u8)xtal_calib[0];
-       cmd.cap_pin2 = (u8)xtal_calib[1];
+       cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]);
+       cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]);
        return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL],
                             (u8 *)&cmd, sizeof(cmd));
 }
index fe511cbf012e009daaecb22e1be14d4be2b0d466..b93e49158196b47cc7f01c5f69c7a1b7badfbd96 100644 (file)
@@ -150,7 +150,7 @@ static s32 expected_tpt_mimo3_40MHz[4][IWL_RATE_COUNT] = {
 };
 
 /* mbps, mcs */
-const static struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = {
+static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = {
        {  "1", "BPSK DSSS"},
        {  "2", "QPSK DSSS"},
        {"5.5", "BPSK CCK"},
index b8377efb3ba71f873b646ae5020669d1b6c8fb16..1c9866daf81565007beb6ee596063702e4bf387f 100644 (file)
@@ -1842,7 +1842,7 @@ void iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log)
        }
 
 #ifdef CONFIG_IWLWIFI_DEBUG
-       if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS))
+       if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log)
                size = (size > DEFAULT_DUMP_EVENT_LOG_ENTRIES)
                        ? DEFAULT_DUMP_EVENT_LOG_ENTRIES : size;
 #else
@@ -3173,7 +3173,6 @@ static int iwl_init_drv(struct iwl_priv *priv)
 
        priv->ibss_beacon = NULL;
 
-       spin_lock_init(&priv->lock);
        spin_lock_init(&priv->sta_lock);
        spin_lock_init(&priv->hcmd_lock);
 
@@ -3361,10 +3360,11 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                (unsigned long long) pci_resource_len(pdev, 0));
        IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base);
 
-       /* this spin lock will be used in apm_ops.init and EEPROM access
+       /* these spin locks will be used in apm_ops.init and EEPROM access
         * we should init now
         */
        spin_lock_init(&priv->reg_lock);
+       spin_lock_init(&priv->lock);
        iwl_hw_detect(priv);
        IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s REV=0x%X\n",
                priv->cfg->name, priv->hw_rev);
index 675b7df632fc1a1076f9b16862bb5bac2652b964..27ca859e7453c250ca70aea6d64ce9820ae6f98d 100644 (file)
@@ -63,7 +63,7 @@
 #ifndef __iwl_core_h__
 #define __iwl_core_h__
 
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 
 /************************
  * forward declarations *
index a7bfae01f19b017e674ca15eee0a50aff8c2411f..1ec8cb4d5eae4f541ec2bc158a963f72c9a456f8 100644 (file)
@@ -77,8 +77,7 @@
  * The MAC (uCode processor, etc.) does not need to be powered up for accessing
  * the CSR registers.
  *
- * NOTE:  Newer devices using one-time-programmable (OTP) memory
- *        require device to be awake in order to read this memory
+ * NOTE:  Device does need to be awake in order to read this memory
  *        via CSR_EEPROM and CSR_OTP registers
  */
 #define CSR_BASE    (0x000)
 /*
  * EEPROM and OTP (one-time-programmable) memory reads
  *
- * NOTE:  For (newer) devices using OTP, device must be awake, initialized via
- *        apm_ops.init() in order to read.  Older devices (3945/4965/5000)
- *        use EEPROM and do not require this.
+ * NOTE:  Device must be awake, initialized via apm_ops.init(),
+ *        in order to read.
  */
 #define CSR_EEPROM_REG          (CSR_BASE+0x02c)
 #define CSR_EEPROM_GP           (CSR_BASE+0x030)
index 2673e9a4db92c4992a52bb34a0bbfd0a99cb1f0d..165d1f6e2dd9304046895b437fd65e0d2f88e580 100644 (file)
@@ -1168,7 +1168,7 @@ struct iwl_priv {
        u32 last_beacon_time;
        u64 last_tsf;
 
-       /* eeprom */
+       /* eeprom -- this is in the card's little endian byte order */
        u8 *eeprom;
        int    nvm_device_type;
        struct iwl_eeprom_calib_info *calib_info;
@@ -1353,4 +1353,15 @@ static inline int is_channel_ibss(const struct iwl_channel_info *ch)
        return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
 }
 
+static inline void __iwl_free_pages(struct iwl_priv *priv, struct page *page)
+{
+       __free_pages(page, priv->hw_params.rx_page_order);
+       priv->alloc_rxb_page--;
+}
+
+static inline void iwl_free_pages(struct iwl_priv *priv, unsigned long page)
+{
+       free_pages(page, priv->hw_params.rx_page_order);
+       priv->alloc_rxb_page--;
+}
 #endif                         /* __iwl_dev_h__ */
index 3946e5c03f818e75651c7387d807edce2ab26078..4a30969689ff5eb777e76f4d8609f84f66570bd4 100644 (file)
@@ -370,7 +370,7 @@ static int iwl_init_otp_access(struct iwl_priv *priv)
        return ret;
 }
 
-static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, u16 *eeprom_data)
+static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, __le16 *eeprom_data)
 {
        int ret = 0;
        u32 r;
@@ -404,7 +404,7 @@ static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, u16 *eeprom_data)
                                CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK);
                IWL_ERR(priv, "Correctable OTP ECC error, continue read\n");
        }
-       *eeprom_data = le16_to_cpu((__force __le16)(r >> 16));
+       *eeprom_data = cpu_to_le16(r >> 16);
        return 0;
 }
 
@@ -413,7 +413,8 @@ static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, u16 *eeprom_data)
  */
 static bool iwl_is_otp_empty(struct iwl_priv *priv)
 {
-       u16 next_link_addr = 0, link_value;
+       u16 next_link_addr = 0;
+       __le16 link_value;
        bool is_empty = false;
 
        /* locate the beginning of OTP link list */
@@ -443,7 +444,8 @@ static bool iwl_is_otp_empty(struct iwl_priv *priv)
 static int iwl_find_otp_image(struct iwl_priv *priv,
                                        u16 *validblockaddr)
 {
-       u16 next_link_addr = 0, link_value = 0, valid_addr;
+       u16 next_link_addr = 0, valid_addr;
+       __le16 link_value = 0;
        int usedblocks = 0;
 
        /* set addressing mode to absolute to traverse the link list */
@@ -463,7 +465,7 @@ static int iwl_find_otp_image(struct iwl_priv *priv,
                 * check for more block on the link list
                 */
                valid_addr = next_link_addr;
-               next_link_addr = link_value * sizeof(u16);
+               next_link_addr = le16_to_cpu(link_value) * sizeof(u16);
                IWL_DEBUG_INFO(priv, "OTP blocks %d addr 0x%x\n",
                               usedblocks, next_link_addr);
                if (iwl_read_otp_word(priv, next_link_addr, &link_value))
@@ -497,7 +499,7 @@ static int iwl_find_otp_image(struct iwl_priv *priv,
  */
 int iwl_eeprom_init(struct iwl_priv *priv)
 {
-       u16 *e;
+       __le16 *e;
        u32 gp = iwl_read32(priv, CSR_EEPROM_GP);
        int sz;
        int ret;
@@ -516,12 +518,9 @@ int iwl_eeprom_init(struct iwl_priv *priv)
                ret = -ENOMEM;
                goto alloc_err;
        }
-       e = (u16 *)priv->eeprom;
+       e = (__le16 *)priv->eeprom;
 
-       if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) {
-               /* OTP reads require powered-up chip */
-               priv->cfg->ops->lib->apm_ops.init(priv);
-       }
+       priv->cfg->ops->lib->apm_ops.init(priv);
 
        ret = priv->cfg->ops->lib->eeprom_ops.verify_signature(priv);
        if (ret < 0) {
@@ -562,7 +561,7 @@ int iwl_eeprom_init(struct iwl_priv *priv)
                }
                for (addr = validblockaddr; addr < validblockaddr + sz;
                     addr += sizeof(u16)) {
-                       u16 eeprom_data;
+                       __le16 eeprom_data;
 
                        ret = iwl_read_otp_word(priv, addr, &eeprom_data);
                        if (ret)
@@ -570,13 +569,6 @@ int iwl_eeprom_init(struct iwl_priv *priv)
                        e[cache_addr / 2] = eeprom_data;
                        cache_addr += sizeof(u16);
                }
-
-               /*
-                * Now that OTP reads are complete, reset chip to save
-                *   power until we load uCode during "up".
-                */
-               priv->cfg->ops->lib->apm_ops.stop(priv);
-
        } else {
                /* eeprom is an array of 16bit values */
                for (addr = 0; addr < sz; addr += sizeof(u16)) {
@@ -594,7 +586,7 @@ int iwl_eeprom_init(struct iwl_priv *priv)
                                goto done;
                        }
                        r = _iwl_read_direct32(priv, CSR_EEPROM_REG);
-                       e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
+                       e[addr / 2] = cpu_to_le16(r >> 16);
                }
        }
        ret = 0;
@@ -603,6 +595,8 @@ done:
 err:
        if (ret)
                iwl_eeprom_free(priv);
+       /* Reset chip to save power until we load uCode during "up". */
+       priv->cfg->ops->lib->apm_ops.stop(priv);
 alloc_err:
        return ret;
 }
@@ -755,7 +749,8 @@ static int iwl_mod_ht40_chan_info(struct iwl_priv *priv,
        ch_info->ht40_eeprom = *eeprom_ch;
        ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg;
        ch_info->ht40_flags = eeprom_ch->flags;
-       ch_info->ht40_extension_channel &= ~clear_ht40_extension_channel;
+       if (eeprom_ch->flags & EEPROM_CHANNEL_VALID)
+               ch_info->ht40_extension_channel &= ~clear_ht40_extension_channel;
 
        return 0;
 }
index 5cd2b66bbe45235525c990f609021807704089ad..0cd9c02ee0441be719117a81037c2db9cd5993da 100644 (file)
@@ -137,7 +137,7 @@ struct iwl_eeprom_channel {
  *
  */
 struct iwl_eeprom_enhanced_txpwr {
-       u16 common;
+       __le16 common;
        s8 chain_a_max;
        s8 chain_b_max;
        s8 chain_c_max;
@@ -360,7 +360,7 @@ struct iwl_eeprom_calib_subband_info {
 struct iwl_eeprom_calib_info {
        u8 saturation_power24;  /* half-dBm (e.g. "34" = 17 dBm) */
        u8 saturation_power52;  /* half-dBm */
-       s16 voltage;            /* signed */
+       __le16 voltage;         /* signed */
        struct iwl_eeprom_calib_subband_info
                band_info[EEPROM_TX_POWER_BANDS];
 } __attribute__ ((packed));
index a23165948202054c4ec59a78f42a6ddb580efb10..30e9ea6d54ecd8dc18f2fa4416cd581bfdaa67e8 100644 (file)
@@ -234,7 +234,7 @@ cancel:
        }
 fail:
        if (cmd->reply_page) {
-               free_pages(cmd->reply_page, priv->hw_params.rx_page_order);
+               iwl_free_pages(priv, cmd->reply_page);
                cmd->reply_page = 0;
        }
 out:
index 6090bc15a6d536ab18c0219740c4a44740974835..6f36b6e79f5e3db56d72fdcbcab1da493ae41e8a 100644 (file)
@@ -345,10 +345,8 @@ void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
                        pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
                                PAGE_SIZE << priv->hw_params.rx_page_order,
                                PCI_DMA_FROMDEVICE);
-                       __free_pages(rxq->pool[i].page,
-                                    priv->hw_params.rx_page_order);
+                       __iwl_free_pages(priv, rxq->pool[i].page);
                        rxq->pool[i].page = NULL;
-                       priv->alloc_rxb_page--;
                }
        }
 
@@ -416,9 +414,7 @@ void iwl_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
                        pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
                                PAGE_SIZE << priv->hw_params.rx_page_order,
                                PCI_DMA_FROMDEVICE);
-                       priv->alloc_rxb_page--;
-                       __free_pages(rxq->pool[i].page,
-                                    priv->hw_params.rx_page_order);
+                       __iwl_free_pages(priv, rxq->pool[i].page);
                        rxq->pool[i].page = NULL;
                }
                list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
@@ -654,47 +650,6 @@ void iwl_reply_statistics(struct iwl_priv *priv,
 }
 EXPORT_SYMBOL(iwl_reply_statistics);
 
-#define PERFECT_RSSI (-20) /* dBm */
-#define WORST_RSSI (-95)   /* dBm */
-#define RSSI_RANGE (PERFECT_RSSI - WORST_RSSI)
-
-/* Calculate an indication of rx signal quality (a percentage, not dBm!).
- * See http://www.ces.clemson.edu/linux/signal_quality.shtml for info
- *   about formulas used below. */
-static int iwl_calc_sig_qual(int rssi_dbm, int noise_dbm)
-{
-       int sig_qual;
-       int degradation = PERFECT_RSSI - rssi_dbm;
-
-       /* If we get a noise measurement, use signal-to-noise ratio (SNR)
-        * as indicator; formula is (signal dbm - noise dbm).
-        * SNR at or above 40 is a great signal (100%).
-        * Below that, scale to fit SNR of 0 - 40 dB within 0 - 100% indicator.
-        * Weakest usable signal is usually 10 - 15 dB SNR. */
-       if (noise_dbm) {
-               if (rssi_dbm - noise_dbm >= 40)
-                       return 100;
-               else if (rssi_dbm < noise_dbm)
-                       return 0;
-               sig_qual = ((rssi_dbm - noise_dbm) * 5) / 2;
-
-       /* Else use just the signal level.
-        * This formula is a least squares fit of data points collected and
-        *   compared with a reference system that had a percentage (%) display
-        *   for signal quality. */
-       } else
-               sig_qual = (100 * (RSSI_RANGE * RSSI_RANGE) - degradation *
-                           (15 * RSSI_RANGE + 62 * degradation)) /
-                          (RSSI_RANGE * RSSI_RANGE);
-
-       if (sig_qual > 100)
-               sig_qual = 100;
-       else if (sig_qual < 1)
-               sig_qual = 0;
-
-       return sig_qual;
-}
-
 /* Calc max signal level (dBm) among 3 possible receivers */
 static inline int iwl_calc_rssi(struct iwl_priv *priv,
                                struct iwl_rx_phy_res *rx_resp)
@@ -1105,11 +1060,8 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
        if (iwl_is_associated(priv) &&
            !test_bit(STATUS_SCANNING, &priv->status)) {
                rx_status.noise = priv->last_rx_noise;
-               rx_status.qual = iwl_calc_sig_qual(rx_status.signal,
-                                                        rx_status.noise);
        } else {
                rx_status.noise = IWL_NOISE_MEAS_NOT_AVAILABLE;
-               rx_status.qual = iwl_calc_sig_qual(rx_status.signal, 0);
        }
 
        /* Reset beacon noise level if not associated. */
@@ -1122,8 +1074,8 @@ void iwl_rx_reply_rx(struct iwl_priv *priv,
                iwl_dbg_report_frame(priv, phy_res, len, header, 1);
 #endif
        iwl_dbg_log_rx_data_frame(priv, len, header);
-       IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, noise %d, qual %d, TSF %llu\n",
-               rx_status.signal, rx_status.noise, rx_status.qual,
+       IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, noise %d, TSF %llu\n",
+               rx_status.signal, rx_status.noise,
                (unsigned long long)rx_status.mactime);
 
        /*
index a2b2b8315ff9efa2509c47dbfafe123644423d7f..fa1c89ba6459645632d3425511b0a016edd97a08 100644 (file)
@@ -144,8 +144,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
                clear_bit(STATUS_SCAN_HW, &priv->status);
        }
 
-       priv->alloc_rxb_page--;
-       free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
+       iwl_free_pages(priv, cmd.reply_page);
 
        return ret;
 }
index cd6a6901216ec63892617f167591b32ddbfb2984..cde09a890b73f281fc65bf62e14a9dde8ab7bb61 100644 (file)
@@ -164,9 +164,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
                        break;
                }
        }
-
-       priv->alloc_rxb_page--;
-       free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
+       iwl_free_pages(priv, cmd.reply_page);
 
        return ret;
 }
@@ -391,9 +389,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, const u8 *addr,
                        break;
                }
        }
-
-       priv->alloc_rxb_page--;
-       free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
+       iwl_free_pages(priv, cmd.reply_page);
 
        return ret;
 }
index 00da5e152d46330de2bc701f6969434c8853f092..87ce2bd292c7810630cd382239a15283f82add76 100644 (file)
@@ -407,13 +407,14 @@ void iwl_hw_txq_ctx_free(struct iwl_priv *priv)
        int txq_id;
 
        /* Tx queues */
-       if (priv->txq)
+       if (priv->txq) {
                for (txq_id = 0; txq_id < priv->hw_params.max_txq_num;
                     txq_id++)
                        if (txq_id == IWL_CMD_QUEUE_NUM)
                                iwl_cmd_queue_free(priv);
                        else
                                iwl_tx_queue_free(priv, txq_id);
+       }
        iwl_free_dma_ptr(priv, &priv->kw);
 
        iwl_free_dma_ptr(priv, &priv->scd_bc_tbls);
index 2a28a1f8b1fe170eea264ed4a96bdb472ded3240..f8e4e4b18d02bee66f711e29080c4cc2b8a6366a 100644 (file)
@@ -548,6 +548,9 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
        txq = &priv->txq[txq_id];
        q = &txq->q;
 
+       if ((iwl_queue_space(q) < q->high_mark))
+               goto drop;
+
        spin_lock_irqsave(&priv->lock, flags);
 
        idx = get_cmd_index(q, q->write_ptr, 0);
@@ -812,7 +815,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv,
                break;
        }
 
-       free_pages(cmd.reply_page, priv->hw_params.rx_page_order);
+       iwl_free_pages(priv, cmd.reply_page);
 
        return rc;
 }
@@ -1198,9 +1201,7 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq)
                        pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
                                PAGE_SIZE << priv->hw_params.rx_page_order,
                                PCI_DMA_FROMDEVICE);
-                       priv->alloc_rxb_page--;
-                       __free_pages(rxq->pool[i].page,
-                                    priv->hw_params.rx_page_order);
+                       __iwl_free_pages(priv, rxq->pool[i].page);
                        rxq->pool[i].page = NULL;
                }
                list_add_tail(&rxq->pool[i].list, &rxq->rx_used);
@@ -1247,10 +1248,8 @@ static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rx
                        pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma,
                                PAGE_SIZE << priv->hw_params.rx_page_order,
                                PCI_DMA_FROMDEVICE);
-                       __free_pages(rxq->pool[i].page,
-                                    priv->hw_params.rx_page_order);
+                       __iwl_free_pages(priv, rxq->pool[i].page);
                        rxq->pool[i].page = NULL;
-                       priv->alloc_rxb_page--;
                }
        }
 
@@ -1300,47 +1299,6 @@ int iwl3945_calc_db_from_ratio(int sig_ratio)
        return (int)ratio2dB[sig_ratio];
 }
 
-#define PERFECT_RSSI (-20) /* dBm */
-#define WORST_RSSI (-95)   /* dBm */
-#define RSSI_RANGE (PERFECT_RSSI - WORST_RSSI)
-
-/* Calculate an indication of rx signal quality (a percentage, not dBm!).
- * See http://www.ces.clemson.edu/linux/signal_quality.shtml for info
- *   about formulas used below. */
-int iwl3945_calc_sig_qual(int rssi_dbm, int noise_dbm)
-{
-       int sig_qual;
-       int degradation = PERFECT_RSSI - rssi_dbm;
-
-       /* If we get a noise measurement, use signal-to-noise ratio (SNR)
-        * as indicator; formula is (signal dbm - noise dbm).
-        * SNR at or above 40 is a great signal (100%).
-        * Below that, scale to fit SNR of 0 - 40 dB within 0 - 100% indicator.
-        * Weakest usable signal is usually 10 - 15 dB SNR. */
-       if (noise_dbm) {
-               if (rssi_dbm - noise_dbm >= 40)
-                       return 100;
-               else if (rssi_dbm < noise_dbm)
-                       return 0;
-               sig_qual = ((rssi_dbm - noise_dbm) * 5) / 2;
-
-       /* Else use just the signal level.
-        * This formula is a least squares fit of data points collected and
-        *   compared with a reference system that had a percentage (%) display
-        *   for signal quality. */
-       } else
-               sig_qual = (100 * (RSSI_RANGE * RSSI_RANGE) - degradation *
-                           (15 * RSSI_RANGE + 62 * degradation)) /
-                          (RSSI_RANGE * RSSI_RANGE);
-
-       if (sig_qual > 100)
-               sig_qual = 100;
-       else if (sig_qual < 1)
-               sig_qual = 0;
-
-       return sig_qual;
-}
-
 /**
  * iwl3945_rx_handle - Main entry function for receiving responses from uCode
  *
@@ -1688,7 +1646,7 @@ void iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log)
        }
 
 #ifdef CONFIG_IWLWIFI_DEBUG
-       if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS))
+       if (!(iwl_get_debug_level(priv) & IWL_DL_FW_ERRORS) && !full_log)
                size = (size > DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES)
                        ? DEFAULT_IWL3945_DUMP_EVENT_LOG_ENTRIES : size;
 #else
@@ -3867,7 +3825,6 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
        priv->retry_rate = 1;
        priv->ibss_beacon = NULL;
 
-       spin_lock_init(&priv->lock);
        spin_lock_init(&priv->sta_lock);
        spin_lock_init(&priv->hcmd_lock);
 
@@ -3936,9 +3893,11 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
        /* Tell mac80211 our characteristics */
        hw->flags = IEEE80211_HW_SIGNAL_DBM |
                    IEEE80211_HW_NOISE_DBM |
-                   IEEE80211_HW_SPECTRUM_MGMT |
-                   IEEE80211_HW_SUPPORTS_PS |
-                   IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
+                   IEEE80211_HW_SPECTRUM_MGMT;
+
+       if (!priv->cfg->broken_powersave)
+               hw->flags |= IEEE80211_HW_SUPPORTS_PS |
+                            IEEE80211_HW_SUPPORTS_DYNAMIC_PS;
 
        hw->wiphy->interface_modes =
                BIT(NL80211_IFTYPE_STATION) |
@@ -4057,10 +4016,11 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
         * PCI Tx retries from interfering with C3 CPU state */
        pci_write_config_byte(pdev, 0x41, 0x00);
 
-       /* this spin lock will be used in apm_ops.init and EEPROM access
+       /* these spin locks will be used in apm_ops.init and EEPROM access
         * we should init now
         */
        spin_lock_init(&priv->reg_lock);
+       spin_lock_init(&priv->lock);
 
        /***********************
         * 4. Read EEPROM
index 5a26bb05a33ae8867f77179c5329053d9f258a11..842811142bef0c951eea272e93ac674fe21c76ae 100644 (file)
@@ -268,7 +268,7 @@ struct iwm_priv {
 
        struct sk_buff_head rx_list;
        struct list_head rx_tickets;
-       struct list_head rx_packets[IWM_RX_ID_HASH];
+       struct list_head rx_packets[IWM_RX_ID_HASH + 1];
        struct workqueue_struct *rx_wq;
        struct work_struct rx_worker;
 
@@ -349,7 +349,7 @@ int iwm_up(struct iwm_priv *iwm);
 int iwm_down(struct iwm_priv *iwm);
 
 /* TX API */
-u16 iwm_tid_to_queue(u16 tid);
+int iwm_tid_to_queue(u16 tid);
 void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages);
 void iwm_tx_worker(struct work_struct *work);
 int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
index e4f0f8705f65c29b3935d81e5dc481b1f0b0055d..c4c0d23c63ecbcefc6a8b7896849bbd779ece0dc 100644 (file)
@@ -76,7 +76,7 @@ static int iwm_stop(struct net_device *ndev)
  */
 static const u16 iwm_1d_to_queue[8] = { 1, 0, 0, 1, 2, 2, 3, 3 };
 
-u16 iwm_tid_to_queue(u16 tid)
+int iwm_tid_to_queue(u16 tid)
 {
        if (tid > IWM_UMAC_TID_NR - 2)
                return -EINVAL;
index 1c57c1f72cba46c9f6cc2545208d67ef9677857e..6d6ed7485175a6f2d8f8d05793767e08c6f91c69 100644 (file)
@@ -1126,7 +1126,7 @@ static int iwm_ntf_stop_resume_tx(struct iwm_priv *iwm, u8 *buf,
 
                if (!stop) {
                        struct iwm_tx_queue *txq;
-                       u16 queue = iwm_tid_to_queue(bit);
+                       int queue = iwm_tid_to_queue(bit);
 
                        if (queue < 0)
                                continue;
index b9b371bfa30fffd30f3b5525863f312707d0f2e3..42611bea76a3e4805399294123c23837630e74b4 100644 (file)
@@ -1365,7 +1365,7 @@ static void lbs_send_confirmsleep(struct lbs_private *priv)
        priv->dnld_sent = DNLD_RES_RECEIVED;
 
        /* If nothing to do, go back to sleep (?) */
-       if (!__kfifo_len(priv->event_fifo) && !priv->resp_len[priv->resp_idx])
+       if (!kfifo_len(&priv->event_fifo) && !priv->resp_len[priv->resp_idx])
                priv->psstate = PS_STATE_SLEEP;
 
        spin_unlock_irqrestore(&priv->driver_lock, flags);
@@ -1439,7 +1439,7 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv)
        }
 
        /* Pending events or command responses? */
-       if (__kfifo_len(priv->event_fifo) || priv->resp_len[priv->resp_idx]) {
+       if (kfifo_len(&priv->event_fifo) || priv->resp_len[priv->resp_idx]) {
                allowed = 0;
                lbs_deb_host("pending events or command responses\n");
        }
index 6a8d2b291d8c6d20495881257d2771ddc844673f..05bb298dfae9a017be7458c8055d961e289e5de6 100644 (file)
@@ -10,7 +10,7 @@
 #include "scan.h"
 #include "assoc.h"
 
-
+#include <linux/kfifo.h>
 
 /** sleep_params */
 struct sleep_params {
@@ -120,7 +120,7 @@ struct lbs_private {
        u32 resp_len[2];
 
        /* Events sent from hardware to driver */
-       struct kfifo *event_fifo;
+       struct kfifo event_fifo;
 
        /** thread to service interrupts */
        struct task_struct *main_thread;
index db38a5a719fa58f05c8233826360bbc18d02d9cc..c2975c8e2f211ff2f9cb64ac61db3e26f7d93862 100644 (file)
@@ -459,7 +459,7 @@ static int lbs_thread(void *data)
                else if (!list_empty(&priv->cmdpendingq) &&
                                        !(priv->wakeup_dev_required))
                        shouldsleep = 0;        /* We have a command to send */
-               else if (__kfifo_len(priv->event_fifo))
+               else if (kfifo_len(&priv->event_fifo))
                        shouldsleep = 0;        /* We have an event to process */
                else
                        shouldsleep = 1;        /* No command */
@@ -511,10 +511,13 @@ static int lbs_thread(void *data)
 
                /* Process hardware events, e.g. card removed, link lost */
                spin_lock_irq(&priv->driver_lock);
-               while (__kfifo_len(priv->event_fifo)) {
+               while (kfifo_len(&priv->event_fifo)) {
                        u32 event;
-                       __kfifo_get(priv->event_fifo, (unsigned char *) &event,
-                               sizeof(event));
+
+                       if (kfifo_out(&priv->event_fifo,
+                               (unsigned char *) &event, sizeof(event)) !=
+                               sizeof(event))
+                                       break;
                        spin_unlock_irq(&priv->driver_lock);
                        lbs_process_event(priv, event);
                        spin_lock_irq(&priv->driver_lock);
@@ -883,10 +886,9 @@ static int lbs_init_adapter(struct lbs_private *priv)
        priv->resp_len[0] = priv->resp_len[1] = 0;
 
        /* Create the event FIFO */
-       priv->event_fifo = kfifo_alloc(sizeof(u32) * 16, GFP_KERNEL, NULL);
-       if (IS_ERR(priv->event_fifo)) {
+       ret = kfifo_alloc(&priv->event_fifo, sizeof(u32) * 16, GFP_KERNEL);
+       if (ret) {
                lbs_pr_err("Out of memory allocating event FIFO buffer\n");
-               ret = -ENOMEM;
                goto out;
        }
 
@@ -901,8 +903,7 @@ static void lbs_free_adapter(struct lbs_private *priv)
        lbs_deb_enter(LBS_DEB_MAIN);
 
        lbs_free_cmd_buffer(priv);
-       if (priv->event_fifo)
-               kfifo_free(priv->event_fifo);
+       kfifo_free(&priv->event_fifo);
        del_timer(&priv->command_timer);
        del_timer(&priv->auto_deepsleep_timer);
        kfree(priv->networks);
@@ -1177,7 +1178,7 @@ void lbs_queue_event(struct lbs_private *priv, u32 event)
        if (priv->psstate == PS_STATE_SLEEP)
                priv->psstate = PS_STATE_AWAKE;
 
-       __kfifo_put(priv->event_fifo, (unsigned char *) &event, sizeof(u32));
+       kfifo_in(&priv->event_fifo, (unsigned char *) &event, sizeof(u32));
 
        wake_up_interruptible(&priv->waitq);
 
index 2f91c9b808af0b2b9434b771381b88c95b548dc8..92b7a357a5e491d538477140d3f4f9855da99394 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/delay.h>
 #include <linux/etherdevice.h>
 #include <linux/netdevice.h>
+#include <linux/if_ether.h>
 #include <linux/if_arp.h>
 #include <linux/kthread.h>
 #include <linux/kfifo.h>
@@ -351,8 +352,7 @@ int lbs_add_mesh(struct lbs_private *priv)
 
        mesh_dev->netdev_ops = &mesh_netdev_ops;
        mesh_dev->ethtool_ops = &lbs_ethtool_ops;
-       memcpy(mesh_dev->dev_addr, priv->dev->dev_addr,
-                       sizeof(priv->dev->dev_addr));
+       memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, ETH_ALEN);
 
        SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
 
index c6a6c042b82f66acddc00fe02e9f4e523d11b600..b0b1c7841500281eb7031554131aa8e713cdc3b4 100644 (file)
@@ -567,11 +567,8 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
        chan_count = lbs_scan_create_channel_list(priv, chan_list);
 
        netif_stop_queue(priv->dev);
-       netif_carrier_off(priv->dev);
-       if (priv->mesh_dev) {
+       if (priv->mesh_dev)
                netif_stop_queue(priv->mesh_dev);
-               netif_carrier_off(priv->mesh_dev);
-       }
 
        /* Prepare to continue an interrupted scan */
        lbs_deb_scan("chan_count %d, scan_channel %d\n",
@@ -635,16 +632,13 @@ out2:
        priv->scan_channel = 0;
 
 out:
-       if (priv->connect_status == LBS_CONNECTED) {
-               netif_carrier_on(priv->dev);
-               if (!priv->tx_pending_len)
-                       netif_wake_queue(priv->dev);
-       }
-       if (priv->mesh_dev && (priv->mesh_connect_status == LBS_CONNECTED)) {
-               netif_carrier_on(priv->mesh_dev);
-               if (!priv->tx_pending_len)
-                       netif_wake_queue(priv->mesh_dev);
-       }
+       if (priv->connect_status == LBS_CONNECTED && !priv->tx_pending_len)
+               netif_wake_queue(priv->dev);
+
+       if (priv->mesh_dev && (priv->mesh_connect_status == LBS_CONNECTED) &&
+           !priv->tx_pending_len)
+               netif_wake_queue(priv->mesh_dev);
+
        kfree(chan_list);
 
        lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
index a8eb9e1fcf36ac7cca8cd3c4965af40f1454f310..4b1aab593a84ea93fbfd7721d58004e65113fd26 100644 (file)
@@ -2025,10 +2025,8 @@ static int lbs_get_essid(struct net_device *dev, struct iw_request_info *info,
        if (priv->connect_status == LBS_CONNECTED) {
                memcpy(extra, priv->curbssparams.ssid,
                       priv->curbssparams.ssid_len);
-               extra[priv->curbssparams.ssid_len] = '\0';
        } else {
                memset(extra, 0, 32);
-               extra[priv->curbssparams.ssid_len] = '\0';
        }
        /*
         * If none, we may want to get the one that was set
index 019431d2f8a900ebe1f981aff8fd40b309e419b1..26a1abd5bb031c9b9c63565eaf1b9e298373d136 100644 (file)
@@ -495,7 +495,6 @@ int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb)
        stats.band = IEEE80211_BAND_2GHZ;
        stats.signal = prxpd->snr;
        stats.noise = prxpd->nf;
-       stats.qual = prxpd->snr - prxpd->nf;
        /* Marvell rate index has a hole at value 4 */
        if (prxpd->rx_rate > 4)
                --prxpd->rx_rate;
index 7698fdd6a3a23e721550a73215e05d15d1ef04a5..31ca241f775351a7129ff3007c1eea0f6e621b0d 100644 (file)
@@ -23,7 +23,7 @@
 #define MAX_RID_LEN 1024
 
 /* Helper routine to record keys
- * Do not call from interrupt context */
+ * It is called under orinoco_lock so it may not sleep */
 static int orinoco_set_key(struct orinoco_private *priv, int index,
                           enum orinoco_alg alg, const u8 *key, int key_len,
                           const u8 *seq, int seq_len)
@@ -32,14 +32,14 @@ static int orinoco_set_key(struct orinoco_private *priv, int index,
        kzfree(priv->keys[index].seq);
 
        if (key_len) {
-               priv->keys[index].key = kzalloc(key_len, GFP_KERNEL);
+               priv->keys[index].key = kzalloc(key_len, GFP_ATOMIC);
                if (!priv->keys[index].key)
                        goto nomem;
        } else
                priv->keys[index].key = NULL;
 
        if (seq_len) {
-               priv->keys[index].seq = kzalloc(seq_len, GFP_KERNEL);
+               priv->keys[index].seq = kzalloc(seq_len, GFP_ATOMIC);
                if (!priv->keys[index].seq)
                        goto free_key;
        } else
index c5fe867665e6f4feb11c5dbfbb32dba621b81c70..1a7eae357fef937efbc7e65429f763bf6fb83b32 100644 (file)
 #define PAIRWISE_KEY_ENTRY(__idx) \
        ( PAIRWISE_KEY_TABLE_BASE + ((__idx) * sizeof(struct hw_key_entry)) )
 #define MAC_IVEIV_ENTRY(__idx) \
-       ( MAC_IVEIV_TABLE_BASE + ((__idx) & sizeof(struct mac_iveiv_entry)) )
+       ( MAC_IVEIV_TABLE_BASE + ((__idx) * sizeof(struct mac_iveiv_entry)) )
 #define MAC_WCID_ATTR_ENTRY(__idx) \
        ( MAC_WCID_ATTRIBUTE_BASE + ((__idx) * sizeof(u32)) )
 #define SHARED_KEY_ENTRY(__idx) \
index eb1e1d00bec31455c95a85068c9d959e7abbf45d..27bf887f1453ccc175e253c237abdc5516120965 100644 (file)
@@ -37,7 +37,7 @@
 #include <linux/module.h>
 
 #include "rt2x00.h"
-#ifdef CONFIG_RT2800USB
+#if defined(CONFIG_RT2800USB) || defined(CONFIG_RT2800USB_MODULE)
 #include "rt2x00usb.h"
 #endif
 #include "rt2800lib.h"
@@ -1121,7 +1121,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
 
        if (rt2x00_intf_is_usb(rt2x00dev)) {
                rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000);
-#ifdef CONFIG_RT2800USB
+#if defined(CONFIG_RT2800USB) || defined(CONFIG_RT2800USB_MODULE)
                rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
                                            USB_MODE_RESET, REGISTER_TIMEOUT);
 #endif
@@ -2021,6 +2021,12 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
        unsigned int i;
        u16 eeprom;
 
+       /*
+        * Disable powersaving as default on PCI devices.
+        */
+       if (rt2x00_intf_is_pci(rt2x00dev))
+               rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
+
        /*
         * Initialize all hw fields.
         */
@@ -2074,8 +2080,7 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
            IEEE80211_HT_CAP_SGI_20 |
            IEEE80211_HT_CAP_SGI_40 |
            IEEE80211_HT_CAP_TX_STBC |
-           IEEE80211_HT_CAP_RX_STBC |
-           IEEE80211_HT_CAP_PSMP_SUPPORT;
+           IEEE80211_HT_CAP_RX_STBC;
        spec->ht.ampdu_factor = 3;
        spec->ht.ampdu_density = 4;
        spec->ht.mcs.tx_params =
@@ -2140,8 +2145,8 @@ static void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,
        rt2800_register_multiread(rt2x00dev, offset,
                                      &iveiv_entry, sizeof(iveiv_entry));
 
-       memcpy(&iveiv_entry.iv[0], iv16, sizeof(iv16));
-       memcpy(&iveiv_entry.iv[4], iv32, sizeof(iv32));
+       memcpy(iv16, &iveiv_entry.iv[0], sizeof(*iv16));
+       memcpy(iv32, &iveiv_entry.iv[4], sizeof(*iv32));
 }
 
 static int rt2800_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
index af85d18cdbe7d96170b686413c4b732f00ab99b1..ab95346cf6a369102043018b2ee917910c44840d 100644 (file)
@@ -922,6 +922,7 @@ static struct usb_device_id rt2800usb_device_table[] = {
        { USB_DEVICE(0x1737, 0x0070), USB_DEVICE_DATA(&rt2800usb_ops) },
        { USB_DEVICE(0x1737, 0x0071), USB_DEVICE_DATA(&rt2800usb_ops) },
        { USB_DEVICE(0x1737, 0x0077), USB_DEVICE_DATA(&rt2800usb_ops) },
+       { USB_DEVICE(0x1737, 0x0079), USB_DEVICE_DATA(&rt2800usb_ops) },
        /* Logitec */
        { USB_DEVICE(0x0789, 0x0162), USB_DEVICE_DATA(&rt2800usb_ops) },
        { USB_DEVICE(0x0789, 0x0163), USB_DEVICE_DATA(&rt2800usb_ops) },
index 687e17dc2e9f2d7d06a30c6ebfe7b58925764ab8..0ca589306d7172eec437fb5dfcfd088ee0351ff0 100644 (file)
@@ -2538,6 +2538,11 @@ static int rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
        char *tx_power;
        unsigned int i;
 
+       /*
+        * Disable powersaving as default.
+        */
+       rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
+
        /*
         * Initialize all hw fields.
         */
index a1a3dd15c66419d63f6e11a5869067585f55575e..8a40a14399842c46b4dc9b845db79ce1141f1718 100644 (file)
@@ -132,7 +132,6 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev)
 
                        rx_status.antenna = (flags2 >> 15) & 1;
                        /* TODO: improve signal/rssi reporting */
-                       rx_status.qual = flags2 & 0xFF;
                        rx_status.signal = (flags2 >> 8) & 0x7F;
                        /* XXX: is this correct? */
                        rx_status.rate_idx = (flags >> 20) & 0xF;
index 2e733e7bdfd41453f77f3a607e0e7cc2da3bee4c..28a808674080952b73e1615fefcba75d784ef406 100644 (file)
@@ -256,7 +256,7 @@ int wl1251_boot_run_firmware(struct wl1251 *wl)
                }
        }
 
-       if (loop >= INIT_LOOP) {
+       if (loop > INIT_LOOP) {
                wl1251_error("timeout waiting for the hardware to "
                             "complete initialization");
                return -EIO;
index 886a9bc39cc1ddb87bd24d1a4a173c7b798af4f7..c3385b3d246cf988d3efb5d882a5d1c0e877ffd5 100644 (file)
@@ -777,7 +777,7 @@ out:
        return ret;
 }
 
-static int wl1271_build_basic_rates(char *rates, u8 band)
+static int wl1271_build_basic_rates(u8 *rates, u8 band)
 {
        u8 index = 0;
 
@@ -804,7 +804,7 @@ static int wl1271_build_basic_rates(char *rates, u8 band)
        return index;
 }
 
-static int wl1271_build_extended_rates(char *rates, u8 band)
+static int wl1271_build_extended_rates(u8 *rates, u8 band)
 {
        u8 index = 0;
 
index dfa1b9bc22c8f796908c12ef2041501798111d82..7ca95c414fa83d9e6b19e7fccb1b4ee43c7965a6 100644 (file)
@@ -1325,151 +1325,11 @@ int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates)
        return r;
 }
 
-static int ofdm_qual_db(u8 status_quality, u8 zd_rate, unsigned int size)
-{
-       static const u16 constants[] = {
-               715, 655, 585, 540, 470, 410, 360, 315,
-               270, 235, 205, 175, 150, 125, 105,  85,
-                65,  50,  40,  25,  15
-       };
-
-       int i;
-       u32 x;
-
-       /* It seems that their quality parameter is somehow per signal
-        * and is now transferred per bit.
-        */
-       switch (zd_rate) {
-       case ZD_OFDM_RATE_6M:
-       case ZD_OFDM_RATE_12M:
-       case ZD_OFDM_RATE_24M:
-               size *= 2;
-               break;
-       case ZD_OFDM_RATE_9M:
-       case ZD_OFDM_RATE_18M:
-       case ZD_OFDM_RATE_36M:
-       case ZD_OFDM_RATE_54M:
-               size *= 4;
-               size /= 3;
-               break;
-       case ZD_OFDM_RATE_48M:
-               size *= 3;
-               size /= 2;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       x = (10000 * status_quality)/size;
-       for (i = 0; i < ARRAY_SIZE(constants); i++) {
-               if (x > constants[i])
-                       break;
-       }
-
-       switch (zd_rate) {
-       case ZD_OFDM_RATE_6M:
-       case ZD_OFDM_RATE_9M:
-               i += 3;
-               break;
-       case ZD_OFDM_RATE_12M:
-       case ZD_OFDM_RATE_18M:
-               i += 5;
-               break;
-       case ZD_OFDM_RATE_24M:
-       case ZD_OFDM_RATE_36M:
-               i += 9;
-               break;
-       case ZD_OFDM_RATE_48M:
-       case ZD_OFDM_RATE_54M:
-               i += 15;
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return i;
-}
-
-static int ofdm_qual_percent(u8 status_quality, u8 zd_rate, unsigned int size)
-{
-       int r;
-
-       r = ofdm_qual_db(status_quality, zd_rate, size);
-       ZD_ASSERT(r >= 0);
-       if (r < 0)
-               r = 0;
-
-       r = (r * 100)/29;
-       return r <= 100 ? r : 100;
-}
-
-static unsigned int log10times100(unsigned int x)
-{
-       static const u8 log10[] = {
-                 0,
-                 0,   30,   47,   60,   69,   77,   84,   90,   95,  100,
-               104,  107,  111,  114,  117,  120,  123,  125,  127,  130,
-               132,  134,  136,  138,  139,  141,  143,  144,  146,  147,
-               149,  150,  151,  153,  154,  155,  156,  157,  159,  160,
-               161,  162,  163,  164,  165,  166,  167,  168,  169,  169,
-               170,  171,  172,  173,  174,  174,  175,  176,  177,  177,
-               178,  179,  179,  180,  181,  181,  182,  183,  183,  184,
-               185,  185,  186,  186,  187,  188,  188,  189,  189,  190,
-               190,  191,  191,  192,  192,  193,  193,  194,  194,  195,
-               195,  196,  196,  197,  197,  198,  198,  199,  199,  200,
-               200,  200,  201,  201,  202,  202,  202,  203,  203,  204,
-               204,  204,  205,  205,  206,  206,  206,  207,  207,  207,
-               208,  208,  208,  209,  209,  210,  210,  210,  211,  211,
-               211,  212,  212,  212,  213,  213,  213,  213,  214,  214,
-               214,  215,  215,  215,  216,  216,  216,  217,  217,  217,
-               217,  218,  218,  218,  219,  219,  219,  219,  220,  220,
-               220,  220,  221,  221,  221,  222,  222,  222,  222,  223,
-               223,  223,  223,  224,  224,  224,  224,
-       };
-
-       return x < ARRAY_SIZE(log10) ? log10[x] : 225;
-}
-
-enum {
-       MAX_CCK_EVM_DB = 45,
-};
-
-static int cck_evm_db(u8 status_quality)
-{
-       return (20 * log10times100(status_quality)) / 100;
-}
-
-static int cck_snr_db(u8 status_quality)
-{
-       int r = MAX_CCK_EVM_DB - cck_evm_db(status_quality);
-       ZD_ASSERT(r >= 0);
-       return r;
-}
-
-static int cck_qual_percent(u8 status_quality)
-{
-       int r;
-
-       r = cck_snr_db(status_quality);
-       r = (100*r)/17;
-       return r <= 100 ? r : 100;
-}
-
 static inline u8 zd_rate_from_ofdm_plcp_header(const void *rx_frame)
 {
        return ZD_OFDM | zd_ofdm_plcp_header_rate(rx_frame);
 }
 
-u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size,
-                     const struct rx_status *status)
-{
-       return (status->frame_status&ZD_RX_OFDM) ?
-               ofdm_qual_percent(status->signal_quality_ofdm,
-                                 zd_rate_from_ofdm_plcp_header(rx_frame),
-                                 size) :
-               cck_qual_percent(status->signal_quality_cck);
-}
-
 /**
  * zd_rx_rate - report zd-rate
  * @rx_frame - received frame
index 9fd8f3508d661a7d1c46027983d6423e4a5c2ae2..f8bbf7d302ae6758b3d98ea69acf3dbeb4ad41e2 100644 (file)
@@ -929,9 +929,6 @@ static inline int zd_get_beacon_interval(struct zd_chip *chip, u32 *interval)
 
 struct rx_status;
 
-u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size,
-                      const struct rx_status *status);
-
 u8 zd_rx_rate(const void *rx_frame, const struct rx_status *status);
 
 struct zd_mc_hash {
index cf51e8f8174bd92dbdd04b70cdc0807bb187e544..8ebf5c33955d791551dd20ac107fca41f75c2b97 100644 (file)
@@ -828,9 +828,6 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
        stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq;
        stats.band = IEEE80211_BAND_2GHZ;
        stats.signal = status->signal_strength;
-       stats.qual = zd_rx_qual_percent(buffer,
-                                         length - sizeof(struct rx_status),
-                                         status);
 
        rate = zd_rx_rate(buffer, status);
 
index d69bde6a234305638cf8943857f4e93d7f1d6f4b..c542c7bb7454aff8fe600809d7e6d844eb43e24a 100644 (file)
@@ -354,7 +354,7 @@ static unsigned int dino_startup_irq(unsigned int irq)
 }
 
 static struct irq_chip dino_interrupt_type = {
-       .typename       = "GSC-PCI",
+       .name           = "GSC-PCI",
        .startup        = dino_startup_irq,
        .shutdown       = dino_disable_irq,
        .enable         = dino_enable_irq, 
index 51220749cb656805fa98a52117e799eeedee8944..46f503fb7fc553a183849b85f85c69f3be0a6a76 100644 (file)
@@ -189,7 +189,7 @@ static unsigned int eisa_startup_irq(unsigned int irq)
 }
 
 static struct irq_chip eisa_interrupt_type = {
-       .typename =     "EISA",
+       .name    =      "EISA",
        .startup =      eisa_startup_irq,
        .shutdown =     eisa_disable_irq,
        .enable =       eisa_enable_irq,
index 647adc9f85adf1118f7b294a89cac45200344b6c..c4e1f3c3c2fadd9cc1c4bf6f5e6561e803b3002d 100644 (file)
@@ -149,7 +149,7 @@ static unsigned int gsc_asic_startup_irq(unsigned int irq)
 }
 
 static struct irq_chip gsc_asic_interrupt_type = {
-       .typename =     "GSC-ASIC",
+       .name    =      "GSC-ASIC",
        .startup =      gsc_asic_startup_irq,
        .shutdown =     gsc_asic_disable_irq,
        .enable =       gsc_asic_enable_irq,
index 88e333553212c33d4c38985040c95f4fb23249b1..c76836727cae029ff39a1ecec272a95809849605 100644 (file)
@@ -730,7 +730,7 @@ static int iosapic_set_affinity_irq(unsigned int irq,
 #endif
 
 static struct irq_chip iosapic_interrupt_type = {
-       .typename =     "IO-SAPIC-level",
+       .name    =      "IO-SAPIC-level",
        .startup =      iosapic_startup_irq,
        .shutdown =     iosapic_disable_irq,
        .enable =       iosapic_enable_irq,
index 79caf1ca4a29a8de1b9d42cd94c4bd7ada3a8702..188bc8496a264feb05758e36cd7c2e23dea37b63 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/reboot.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/ctype.h>
 #include <linux/blkdev.h>
 #include <linux/workqueue.h>
@@ -147,41 +148,34 @@ device_initcall(start_task);
 static void (*led_func_ptr) (unsigned char) __read_mostly;
 
 #ifdef CONFIG_PROC_FS
-static int led_proc_read(char *page, char **start, off_t off, int count, 
-       int *eof, void *data)
+static int led_proc_show(struct seq_file *m, void *v)
 {
-       char *out = page;
-       int len;
-
-       switch ((long)data)
+       switch ((long)m->private)
        {
        case LED_NOLCD:
-               out += sprintf(out, "Heartbeat: %d\n", led_heartbeat);
-               out += sprintf(out, "Disk IO: %d\n", led_diskio);
-               out += sprintf(out, "LAN Rx/Tx: %d\n", led_lanrxtx);
+               seq_printf(m, "Heartbeat: %d\n", led_heartbeat);
+               seq_printf(m, "Disk IO: %d\n", led_diskio);
+               seq_printf(m, "LAN Rx/Tx: %d\n", led_lanrxtx);
                break;
        case LED_HASLCD:
-               out += sprintf(out, "%s\n", lcd_text);
+               seq_printf(m, "%s\n", lcd_text);
                break;
        default:
-               *eof = 1;
                return 0;
        }
+       return 0;
+}
 
-       len = out - page - off;
-       if (len < count) {
-               *eof = 1;
-               if (len <= 0) return 0;
-       } else {
-               len = count;
-       }
-       *start = page + off;
-       return len;
+static int led_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, led_proc_show, PDE(inode)->data);
 }
 
-static int led_proc_write(struct file *file, const char *buf, 
-       unsigned long count, void *data)
+
+static ssize_t led_proc_write(struct file *file, const char *buf,
+       size_t count, loff_t *pos)
 {
+       void *data = PDE(file->f_path.dentry->d_inode)->data;
        char *cur, lbuf[count + 1];
        int d;
 
@@ -234,6 +228,15 @@ parse_error:
        return -EINVAL;
 }
 
+static const struct file_operations led_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = led_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = led_proc_write,
+};
+
 static int __init led_create_procfs(void)
 {
        struct proc_dir_entry *proc_pdc_root = NULL;
@@ -243,19 +246,15 @@ static int __init led_create_procfs(void)
 
        proc_pdc_root = proc_mkdir("pdc", 0);
        if (!proc_pdc_root) return -1;
-       ent = create_proc_entry("led", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root);
+       ent = proc_create_data("led", S_IRUGO|S_IWUSR, proc_pdc_root,
+                               &led_proc_fops, (void *)LED_NOLCD); /* LED */
        if (!ent) return -1;
-       ent->data = (void *)LED_NOLCD; /* LED */
-       ent->read_proc = led_proc_read;
-       ent->write_proc = led_proc_write;
 
        if (led_type == LED_HASLCD)
        {
-               ent = create_proc_entry("lcd", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root);
+               ent = proc_create_data("lcd", S_IRUGO|S_IWUSR, proc_pdc_root,
+                                       &led_proc_fops, (void *)LED_HASLCD); /* LCD */
                if (!ent) return -1;
-               ent->data = (void *)LED_HASLCD; /* LCD */
-               ent->read_proc = led_proc_read;
-               ent->write_proc = led_proc_write;
        }
 
        return 0;
index 13a64bc081b6762d873204c3ddd0cbe7c35d074c..0bc5d474b1688aa74b4dd96d9b2f016154ce065e 100644 (file)
@@ -779,12 +779,9 @@ static ssize_t pdcs_auto_write(struct kobject *kobj,
        read_unlock(&pathentry->rw_lock);
        
        DPRINTK("%s: flags before: 0x%X\n", __func__, flags);
-                       
-       temp = in;
-       
-       while (*temp && isspace(*temp))
-               temp++;
-       
+
+       temp = skip_spaces(in);
+
        c = *temp++ - '0';
        if ((c != 0) && (c != 1))
                goto parse_error;
index 675f04e6597a5d664f6f535f670be1f5c9855c9e..a35c9c5b89e8b25d39896709a1c111dbc5a6e866 100644 (file)
@@ -326,7 +326,7 @@ static unsigned int superio_startup_irq(unsigned int irq)
 }
 
 static struct irq_chip superio_interrupt_type = {
-       .typename =     SUPERIO,
+       .name    =      SUPERIO,
        .startup =      superio_startup_irq,
        .shutdown =     superio_disable_irq,
        .enable =       superio_enable_irq,
index 2597145a066e391fa988ecbbf44921f2f249ef1d..ad113b0f62dbe056643de8960a610f318cd3a1ee 100644 (file)
@@ -3403,7 +3403,7 @@ static int __init parport_parse_param(const char *s, int *val,
                *val = automatic;
        else if (!strncmp(s, "none", 4))
                *val = none;
-       else if (nofifo && !strncmp(s, "nofifo", 4))
+       else if (nofifo && !strncmp(s, "nofifo", 6))
                *val = nofifo;
        else {
                char *ep;
index 6cdc931f7c1773e6fb59b2c8bbac85df950a9f86..83aae47475940b383fe89c5fd3cf30c7c7cb3ec4 100644 (file)
@@ -339,6 +339,35 @@ found:
 }
 #endif
 
+#ifdef CONFIG_ACPI_NUMA
+static int __init
+dmar_parse_one_rhsa(struct acpi_dmar_header *header)
+{
+       struct acpi_dmar_rhsa *rhsa;
+       struct dmar_drhd_unit *drhd;
+
+       rhsa = (struct acpi_dmar_rhsa *)header;
+       for_each_drhd_unit(drhd) {
+               if (drhd->reg_base_addr == rhsa->base_address) {
+                       int node = acpi_map_pxm_to_node(rhsa->proximity_domain);
+
+                       if (!node_online(node))
+                               node = -1;
+                       drhd->iommu->node = node;
+                       return 0;
+               }
+       }
+       WARN(1, "Your BIOS is broken; RHSA refers to non-existent DMAR unit at %llx\n"
+            "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
+            drhd->reg_base_addr,
+            dmi_get_system_info(DMI_BIOS_VENDOR),
+            dmi_get_system_info(DMI_BIOS_VERSION),
+            dmi_get_system_info(DMI_PRODUCT_VERSION));
+
+       return 0;
+}
+#endif
+
 static void __init
 dmar_table_print_dmar_entry(struct acpi_dmar_header *header)
 {
@@ -458,7 +487,9 @@ parse_dmar_table(void)
 #endif
                        break;
                case ACPI_DMAR_HARDWARE_AFFINITY:
-                       /* We don't do anything with RHSA (yet?) */
+#ifdef CONFIG_ACPI_NUMA
+                       ret = dmar_parse_one_rhsa(entry_header);
+#endif
                        break;
                default:
                        printk(KERN_WARNING PREFIX
@@ -582,6 +613,8 @@ int __init dmar_table_init(void)
        return 0;
 }
 
+static int bios_warned;
+
 int __init check_zero_address(void)
 {
        struct acpi_table_dmar *dmar;
@@ -601,6 +634,9 @@ int __init check_zero_address(void)
                }
 
                if (entry_header->type == ACPI_DMAR_TYPE_HARDWARE_UNIT) {
+                       void __iomem *addr;
+                       u64 cap, ecap;
+
                        drhd = (void *)entry_header;
                        if (!drhd->address) {
                                /* Promote an attitude of violence to a BIOS engineer today */
@@ -609,17 +645,40 @@ int __init check_zero_address(void)
                                     dmi_get_system_info(DMI_BIOS_VENDOR),
                                     dmi_get_system_info(DMI_BIOS_VERSION),
                                     dmi_get_system_info(DMI_PRODUCT_VERSION));
-#ifdef CONFIG_DMAR
-                               dmar_disabled = 1;
-#endif
-                               return 0;
+                               bios_warned = 1;
+                               goto failed;
+                       }
+
+                       addr = early_ioremap(drhd->address, VTD_PAGE_SIZE);
+                       if (!addr ) {
+                               printk("IOMMU: can't validate: %llx\n", drhd->address);
+                               goto failed;
+                       }
+                       cap = dmar_readq(addr + DMAR_CAP_REG);
+                       ecap = dmar_readq(addr + DMAR_ECAP_REG);
+                       early_iounmap(addr, VTD_PAGE_SIZE);
+                       if (cap == (uint64_t)-1 && ecap == (uint64_t)-1) {
+                               /* Promote an attitude of violence to a BIOS engineer today */
+                               WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n"
+                                    "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
+                                     drhd->address,
+                                     dmi_get_system_info(DMI_BIOS_VENDOR),
+                                     dmi_get_system_info(DMI_BIOS_VERSION),
+                                     dmi_get_system_info(DMI_PRODUCT_VERSION));
+                               bios_warned = 1;
+                               goto failed;
                        }
-                       break;
                }
 
                entry_header = ((void *)entry_header + entry_header->length);
        }
        return 1;
+
+failed:
+#ifdef CONFIG_DMAR
+       dmar_disabled = 1;
+#endif
+       return 0;
 }
 
 void __init detect_intel_iommu(void)
@@ -670,6 +729,18 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
        int agaw = 0;
        int msagaw = 0;
 
+       if (!drhd->reg_base_addr) {
+               if (!bios_warned) {
+                       WARN(1, "Your BIOS is broken; DMAR reported at address zero!\n"
+                            "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
+                            dmi_get_system_info(DMI_BIOS_VENDOR),
+                            dmi_get_system_info(DMI_BIOS_VERSION),
+                            dmi_get_system_info(DMI_PRODUCT_VERSION));
+                       bios_warned = 1;
+               }
+               return -EINVAL;
+       }
+
        iommu = kzalloc(sizeof(*iommu), GFP_KERNEL);
        if (!iommu)
                return -ENOMEM;
@@ -686,13 +757,16 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
        iommu->ecap = dmar_readq(iommu->reg + DMAR_ECAP_REG);
 
        if (iommu->cap == (uint64_t)-1 && iommu->ecap == (uint64_t)-1) {
-               /* Promote an attitude of violence to a BIOS engineer today */
-               WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n"
-                    "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
-                    drhd->reg_base_addr,
-                    dmi_get_system_info(DMI_BIOS_VENDOR),
-                    dmi_get_system_info(DMI_BIOS_VERSION),
-                    dmi_get_system_info(DMI_PRODUCT_VERSION));
+               if (!bios_warned) {
+                       /* Promote an attitude of violence to a BIOS engineer today */
+                       WARN(1, "Your BIOS is broken; DMAR reported at address %llx returns all ones!\n"
+                            "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
+                            drhd->reg_base_addr,
+                            dmi_get_system_info(DMI_BIOS_VENDOR),
+                            dmi_get_system_info(DMI_BIOS_VERSION),
+                            dmi_get_system_info(DMI_PRODUCT_VERSION));
+                       bios_warned = 1;
+               }
                goto err_unmap;
        }
 
@@ -715,6 +789,8 @@ int alloc_iommu(struct dmar_drhd_unit *drhd)
        iommu->agaw = agaw;
        iommu->msagaw = msagaw;
 
+       iommu->node = -1;
+
        /* the registers might be more than one page */
        map_size = max_t(int, ecap_max_iotlb_offset(iommu->ecap),
                cap_max_fault_reg_offset(iommu->cap));
@@ -1056,6 +1132,7 @@ static void __dmar_enable_qi(struct intel_iommu *iommu)
 int dmar_enable_qi(struct intel_iommu *iommu)
 {
        struct q_inval *qi;
+       struct page *desc_page;
 
        if (!ecap_qis(iommu->ecap))
                return -ENOENT;
@@ -1072,13 +1149,16 @@ int dmar_enable_qi(struct intel_iommu *iommu)
 
        qi = iommu->qi;
 
-       qi->desc = (void *)(get_zeroed_page(GFP_ATOMIC));
-       if (!qi->desc) {
+
+       desc_page = alloc_pages_node(iommu->node, GFP_ATOMIC | __GFP_ZERO, 0);
+       if (!desc_page) {
                kfree(qi);
                iommu->qi = 0;
                return -ENOMEM;
        }
 
+       qi->desc = page_address(desc_page);
+
        qi->desc_status = kmalloc(QI_LENGTH * sizeof(int), GFP_ATOMIC);
        if (!qi->desc_status) {
                free_page((unsigned long) qi->desc);
index bd588eb8e9225206ec39a7b707aceaaffda879d1..8e210cd76e55c34c617ccabd4c6b752acbd45401 100644 (file)
@@ -121,7 +121,7 @@ struct controller {
 #define PCI_DEVICE_ID_AMD_GOLAM_7450   0x7450
 #define PCI_DEVICE_ID_AMD_POGO_7458    0x7458
 
-/* AMD PCIX bridge registers */
+/* AMD PCI-X bridge registers */
 #define PCIX_MEM_BASE_LIMIT_OFFSET     0x1C
 #define PCIX_MISCII_OFFSET             0x48
 #define PCIX_MISC_BRIDGE_ERRORS_OFFSET 0x80
index 8d6159426311bda6a5bcab491b282e5427d6eff2..417312528ddff29ab4ead4fd5bc7d89e9a718121 100644 (file)
@@ -277,6 +277,7 @@ static int hw_pass_through = 1;
 
 struct dmar_domain {
        int     id;                     /* domain id */
+       int     nid;                    /* node id */
        unsigned long iommu_bmp;        /* bitmap of iommus this domain uses*/
 
        struct list_head devices;       /* all devices' list */
@@ -304,7 +305,7 @@ struct device_domain_info {
        int segment;            /* PCI domain */
        u8 bus;                 /* PCI bus number */
        u8 devfn;               /* PCI devfn number */
-       struct pci_dev *dev; /* it's NULL for PCIE-to-PCI bridge */
+       struct pci_dev *dev; /* it's NULL for PCIe-to-PCI bridge */
        struct intel_iommu *iommu; /* IOMMU used by this device */
        struct dmar_domain *domain; /* pointer to domain */
 };
@@ -386,30 +387,14 @@ static struct kmem_cache *iommu_domain_cache;
 static struct kmem_cache *iommu_devinfo_cache;
 static struct kmem_cache *iommu_iova_cache;
 
-static inline void *iommu_kmem_cache_alloc(struct kmem_cache *cachep)
+static inline void *alloc_pgtable_page(int node)
 {
-       unsigned int flags;
-       void *vaddr;
-
-       /* trying to avoid low memory issues */
-       flags = current->flags & PF_MEMALLOC;
-       current->flags |= PF_MEMALLOC;
-       vaddr = kmem_cache_alloc(cachep, GFP_ATOMIC);
-       current->flags &= (~PF_MEMALLOC | flags);
-       return vaddr;
-}
-
+       struct page *page;
+       void *vaddr = NULL;
 
-static inline void *alloc_pgtable_page(void)
-{
-       unsigned int flags;
-       void *vaddr;
-
-       /* trying to avoid low memory issues */
-       flags = current->flags & PF_MEMALLOC;
-       current->flags |= PF_MEMALLOC;
-       vaddr = (void *)get_zeroed_page(GFP_ATOMIC);
-       current->flags &= (~PF_MEMALLOC | flags);
+       page = alloc_pages_node(node, GFP_ATOMIC | __GFP_ZERO, 0);
+       if (page)
+               vaddr = page_address(page);
        return vaddr;
 }
 
@@ -420,7 +405,7 @@ static inline void free_pgtable_page(void *vaddr)
 
 static inline void *alloc_domain_mem(void)
 {
-       return iommu_kmem_cache_alloc(iommu_domain_cache);
+       return kmem_cache_alloc(iommu_domain_cache, GFP_ATOMIC);
 }
 
 static void free_domain_mem(void *vaddr)
@@ -430,7 +415,7 @@ static void free_domain_mem(void *vaddr)
 
 static inline void * alloc_devinfo_mem(void)
 {
-       return iommu_kmem_cache_alloc(iommu_devinfo_cache);
+       return kmem_cache_alloc(iommu_devinfo_cache, GFP_ATOMIC);
 }
 
 static inline void free_devinfo_mem(void *vaddr)
@@ -440,7 +425,7 @@ static inline void free_devinfo_mem(void *vaddr)
 
 struct iova *alloc_iova_mem(void)
 {
-       return iommu_kmem_cache_alloc(iommu_iova_cache);
+       return kmem_cache_alloc(iommu_iova_cache, GFP_ATOMIC);
 }
 
 void free_iova_mem(struct iova *iova)
@@ -589,7 +574,8 @@ static struct context_entry * device_to_context_entry(struct intel_iommu *iommu,
        root = &iommu->root_entry[bus];
        context = get_context_addr_from_root(root);
        if (!context) {
-               context = (struct context_entry *)alloc_pgtable_page();
+               context = (struct context_entry *)
+                               alloc_pgtable_page(iommu->node);
                if (!context) {
                        spin_unlock_irqrestore(&iommu->lock, flags);
                        return NULL;
@@ -732,7 +718,7 @@ static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,
                if (!dma_pte_present(pte)) {
                        uint64_t pteval;
 
-                       tmp_page = alloc_pgtable_page();
+                       tmp_page = alloc_pgtable_page(domain->nid);
 
                        if (!tmp_page)
                                return NULL;
@@ -868,7 +854,7 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu)
        struct root_entry *root;
        unsigned long flags;
 
-       root = (struct root_entry *)alloc_pgtable_page();
+       root = (struct root_entry *)alloc_pgtable_page(iommu->node);
        if (!root)
                return -ENOMEM;
 
@@ -1263,6 +1249,7 @@ static struct dmar_domain *alloc_domain(void)
        if (!domain)
                return NULL;
 
+       domain->nid = -1;
        memset(&domain->iommu_bmp, 0, sizeof(unsigned long));
        domain->flags = 0;
 
@@ -1420,9 +1407,10 @@ static int domain_init(struct dmar_domain *domain, int guest_width)
                domain->iommu_snooping = 0;
 
        domain->iommu_count = 1;
+       domain->nid = iommu->node;
 
        /* always allocate the top pgd */
-       domain->pgd = (struct dma_pte *)alloc_pgtable_page();
+       domain->pgd = (struct dma_pte *)alloc_pgtable_page(domain->nid);
        if (!domain->pgd)
                return -ENOMEM;
        __iommu_flush_cache(iommu, domain->pgd, PAGE_SIZE);
@@ -1523,12 +1511,15 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
 
                /* Skip top levels of page tables for
                 * iommu which has less agaw than default.
+                * Unnecessary for PT mode.
                 */
-               for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) {
-                       pgd = phys_to_virt(dma_pte_addr(pgd));
-                       if (!dma_pte_present(pgd)) {
-                               spin_unlock_irqrestore(&iommu->lock, flags);
-                               return -ENOMEM;
+               if (translation != CONTEXT_TT_PASS_THROUGH) {
+                       for (agaw = domain->agaw; agaw != iommu->agaw; agaw--) {
+                               pgd = phys_to_virt(dma_pte_addr(pgd));
+                               if (!dma_pte_present(pgd)) {
+                                       spin_unlock_irqrestore(&iommu->lock, flags);
+                                       return -ENOMEM;
+                               }
                        }
                }
        }
@@ -1577,6 +1568,8 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
        spin_lock_irqsave(&domain->iommu_lock, flags);
        if (!test_and_set_bit(iommu->seq_id, &domain->iommu_bmp)) {
                domain->iommu_count++;
+               if (domain->iommu_count == 1)
+                       domain->nid = iommu->node;
                domain_update_iommu_cap(domain);
        }
        spin_unlock_irqrestore(&domain->iommu_lock, flags);
@@ -1611,7 +1604,7 @@ domain_context_mapping(struct dmar_domain *domain, struct pci_dev *pdev,
                        return ret;
                parent = parent->bus->self;
        }
-       if (pci_is_pcie(tmp)) /* this is a PCIE-to-PCI bridge */
+       if (pci_is_pcie(tmp)) /* this is a PCIe-to-PCI bridge */
                return domain_context_mapping_one(domain,
                                        pci_domain_nr(tmp->subordinate),
                                        tmp->subordinate->number, 0,
@@ -1991,6 +1984,16 @@ static int iommu_prepare_identity_map(struct pci_dev *pdev,
               "IOMMU: Setting identity map for device %s [0x%Lx - 0x%Lx]\n",
               pci_name(pdev), start, end);
        
+       if (end < start) {
+               WARN(1, "Your BIOS is broken; RMRR ends before it starts!\n"
+                       "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
+                       dmi_get_system_info(DMI_BIOS_VENDOR),
+                       dmi_get_system_info(DMI_BIOS_VERSION),
+                    dmi_get_system_info(DMI_PRODUCT_VERSION));
+               ret = -EIO;
+               goto error;
+       }
+
        if (end >> agaw_to_width(domain->agaw)) {
                WARN(1, "Your BIOS is broken; RMRR exceeds permitted address width (%d bits)\n"
                     "BIOS vendor: %s; Ver: %s; Product Version: %s\n",
@@ -3228,6 +3231,9 @@ static int device_notifier(struct notifier_block *nb,
        struct pci_dev *pdev = to_pci_dev(dev);
        struct dmar_domain *domain;
 
+       if (iommu_no_mapping(dev))
+               return 0;
+
        domain = find_domain(pdev);
        if (!domain)
                return 0;
@@ -3319,7 +3325,7 @@ static void iommu_detach_dependent_devices(struct intel_iommu *iommu,
                                         parent->devfn);
                        parent = parent->bus->self;
                }
-               if (pci_is_pcie(tmp)) /* this is a PCIE-to-PCI bridge */
+               if (pci_is_pcie(tmp)) /* this is a PCIe-to-PCI bridge */
                        iommu_detach_dev(iommu,
                                tmp->subordinate->number, 0);
                else /* this is a legacy PCI bridge */
@@ -3455,6 +3461,7 @@ static struct dmar_domain *iommu_alloc_vm_domain(void)
                return NULL;
 
        domain->id = vm_domid++;
+       domain->nid = -1;
        memset(&domain->iommu_bmp, 0, sizeof(unsigned long));
        domain->flags = DOMAIN_FLAG_VIRTUAL_MACHINE;
 
@@ -3481,9 +3488,10 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width)
        domain->iommu_coherency = 0;
        domain->iommu_snooping = 0;
        domain->max_addr = 0;
+       domain->nid = -1;
 
        /* always allocate the top pgd */
-       domain->pgd = (struct dma_pte *)alloc_pgtable_page();
+       domain->pgd = (struct dma_pte *)alloc_pgtable_page(domain->nid);
        if (!domain->pgd)
                return -ENOMEM;
        domain_flush_cache(domain, domain->pgd, PAGE_SIZE);
index 1487bf2be863115a9f858b9ed0886945d012dae1..95b849130ad41189ea2540272ffc84f5407a5bc6 100644 (file)
@@ -528,7 +528,7 @@ int set_msi_sid(struct irte *irte, struct pci_dev *dev)
 
        bridge = pci_find_upstream_pcie_bridge(dev);
        if (bridge) {
-               if (pci_is_pcie(bridge))/* this is a PCIE-to-PCI/PCIX bridge */
+               if (pci_is_pcie(bridge))/* this is a PCIe-to-PCI/PCIX bridge */
                        set_irte_sid(irte, SVT_VERIFY_BUS, SQ_ALL_16,
                                (bridge->bus->number << 8) | dev->bus->number);
                else /* this is a legacy PCI bridge */
@@ -590,7 +590,8 @@ static int setup_intr_remapping(struct intel_iommu *iommu, int mode)
        if (!iommu->ir_table)
                return -ENOMEM;
 
-       pages = alloc_pages(GFP_ATOMIC | __GFP_ZERO, INTR_REMAP_PAGE_ORDER);
+       pages = alloc_pages_node(iommu->node, GFP_ATOMIC | __GFP_ZERO,
+                                INTR_REMAP_PAGE_ORDER);
 
        if (!pages) {
                printk(KERN_ERR "failed to allocate pages of order %d\n",
index cc617ddd33d03ce8c16717249ad7413fdd0a0e3e..7e2829538a4cfc5bf03131971930d4463ded11cf 100644 (file)
@@ -112,11 +112,7 @@ static bool acpi_pci_can_wakeup(struct pci_dev *dev)
 static void acpi_pci_propagate_wakeup_enable(struct pci_bus *bus, bool enable)
 {
        while (bus->parent) {
-               struct pci_dev *bridge = bus->self;
-               int ret;
-
-               ret = acpi_pm_device_sleep_wake(&bridge->dev, enable);
-               if (!ret || pci_is_pcie(bridge))
+               if (!acpi_pm_device_sleep_wake(&bus->self->dev, enable))
                        return;
                bus = bus->parent;
        }
@@ -131,9 +127,7 @@ static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable)
        if (acpi_pci_can_wakeup(dev))
                return acpi_pm_device_sleep_wake(&dev->dev, enable);
 
-       if (!pci_is_pcie(dev))
-               acpi_pci_propagate_wakeup_enable(dev->bus, enable);
-
+       acpi_pci_propagate_wakeup_enable(dev->bus, enable);
        return 0;
 }
 
index 0bc27e0590196484b7733c1e0dbb049e4571cda5..864e703cf73795982195e16acaa8095405ca1412 100644 (file)
@@ -1153,11 +1153,11 @@ pci_disable_device(struct pci_dev *dev)
 
 /**
  * pcibios_set_pcie_reset_state - set reset state for device dev
- * @dev: the PCI-E device reset
+ * @dev: the PCIe device reset
  * @state: Reset state to enter into
  *
  *
- * Sets the PCI-E reset state for the device. This is the default
+ * Sets the PCIe reset state for the device. This is the default
  * implementation. Architecture implementations can override this.
  */
 int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
@@ -1168,7 +1168,7 @@ int __attribute__ ((weak)) pcibios_set_pcie_reset_state(struct pci_dev *dev,
 
 /**
  * pci_set_pcie_reset_state - set reset state for device dev
- * @dev: the PCI-E device reset
+ * @dev: the PCIe device reset
  * @state: Reset state to enter into
  *
  *
@@ -2284,6 +2284,21 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe)
        return 0;
 }
 
+static int pci_dev_specific_reset(struct pci_dev *dev, int probe)
+{
+       struct pci_dev_reset_methods *i;
+
+       for (i = pci_dev_reset_methods; i->reset; i++) {
+               if ((i->vendor == dev->vendor ||
+                    i->vendor == (u16)PCI_ANY_ID) &&
+                   (i->device == dev->device ||
+                    i->device == (u16)PCI_ANY_ID))
+                       return i->reset(dev, probe);
+       }
+
+       return -ENOTTY;
+}
+
 static int pci_dev_reset(struct pci_dev *dev, int probe)
 {
        int rc;
@@ -2296,6 +2311,10 @@ static int pci_dev_reset(struct pci_dev *dev, int probe)
                down(&dev->dev.sem);
        }
 
+       rc = pci_dev_specific_reset(dev, probe);
+       if (rc != -ENOTTY)
+               goto done;
+
        rc = pcie_flr(dev, probe);
        if (rc != -ENOTTY)
                goto done;
@@ -2779,6 +2798,11 @@ int __attribute__ ((weak)) pci_ext_cfg_avail(struct pci_dev *dev)
        return 1;
 }
 
+void __weak pci_fixup_cardbus(struct pci_bus *bus)
+{
+}
+EXPORT_SYMBOL(pci_fixup_cardbus);
+
 static int __init pci_setup(char *str)
 {
        while (str) {
index 33ed8e0aba1ea25b54c928691e1a03c78b1391f8..709eaa4fee518c48a0c8195bc5f57f24594ecca9 100644 (file)
@@ -313,4 +313,12 @@ static inline int pci_resource_alignment(struct pci_dev *dev,
 
 extern void pci_enable_acs(struct pci_dev *dev);
 
+struct pci_dev_reset_methods {
+       u16 vendor;
+       u16 device;
+       int (*reset)(struct pci_dev *dev, int probe);
+};
+
+extern struct pci_dev_reset_methods pci_dev_reset_methods[];
+
 #endif /* DRIVERS_PCI_H */
index b8c925c1f6aa8ad97331d640e2f95bfcc929e13f..9142949734f541630a7cb7a4512be15f6986f0fc 100644 (file)
@@ -3,14 +3,14 @@
 #
 
 config PCIEAER_INJECT
-       tristate "PCIE AER error injector support"
+       tristate "PCIe AER error injector support"
        depends on PCIEAER
        default n
        help
          This enables PCI Express Root Port Advanced Error Reporting
          (AER) software error injector.
 
-         Debuging PCIE AER code is quite difficult because it is hard
+         Debugging PCIe AER code is quite difficult because it is hard
          to trigger various real hardware errors. Software based
          error injection can fake almost all kinds of errors with the
          help of a user space helper tool aer-inject, which can be
index 7fcd5331b14c37fdbbe4662e80afdf393191dcb8..797d47809f7a417b7c4b447b75d5757ef5c098b1 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * PCIE AER software error injection support.
+ * PCIe AER software error injection support.
  *
- * Debuging PCIE AER code is quite difficult because it is hard to
+ * Debuging PCIe AER code is quite difficult because it is hard to
  * trigger various real hardware errors. Software based error
  * injection can fake almost all kinds of errors with the help of a
  * user space helper tool aer-inject, which can be gotten from:
@@ -484,5 +484,5 @@ static void __exit aer_inject_exit(void)
 module_init(aer_inject_init);
 module_exit(aer_inject_exit);
 
-MODULE_DESCRIPTION("PCIE AER software error injector");
+MODULE_DESCRIPTION("PCIe AER software error injector");
 MODULE_LICENSE("GPL");
index 97a345927b55644e1798095d385ff6104abb3499..21f215f4daa30cc090424ee25f4b24bb90d27115 100644 (file)
@@ -155,7 +155,7 @@ static struct aer_rpc *aer_alloc_rpc(struct pcie_device *dev)
        mutex_init(&rpc->rpc_mutex);
        init_waitqueue_head(&rpc->wait_release);
 
-       /* Use PCIE bus function to store rpc into PCIE device */
+       /* Use PCIe bus function to store rpc into PCIe device */
        set_service_data(dev, rpc);
 
        return rpc;
index 8edb2f300e8f85cc91c31ad8f6c208b6363cb118..04814087658d32a27ed6cd5dc8571b2ee077e59f 100644 (file)
@@ -24,7 +24,7 @@
  *
  * @return: Zero on success. Nonzero otherwise.
  *
- * Invoked when PCIE bus loads AER service driver. To avoid conflict with
+ * Invoked when PCIe bus loads AER service driver. To avoid conflict with
  * BIOS AER support requires BIOS to yield AER control to OS native driver.
  **/
 int aer_osc_setup(struct pcie_device *pciedev)
index ae672ca803331f6c70ad12422110b5079a2090c2..c843a799814d28fde6e8a4832edf986ccde977f0 100644 (file)
@@ -587,7 +587,7 @@ static void handle_error_source(struct pcie_device *aerdev,
  * aer_enable_rootport - enable Root Port's interrupts when receiving messages
  * @rpc: pointer to a Root Port data structure
  *
- * Invoked when PCIE bus loads AER service driver.
+ * Invoked when PCIe bus loads AER service driver.
  */
 void aer_enable_rootport(struct aer_rpc *rpc)
 {
@@ -597,7 +597,7 @@ void aer_enable_rootport(struct aer_rpc *rpc)
        u32 reg32;
 
        pos = pci_pcie_cap(pdev);
-       /* Clear PCIE Capability's Device Status */
+       /* Clear PCIe Capability's Device Status */
        pci_read_config_word(pdev, pos+PCI_EXP_DEVSTA, &reg16);
        pci_write_config_word(pdev, pos+PCI_EXP_DEVSTA, reg16);
 
@@ -631,7 +631,7 @@ void aer_enable_rootport(struct aer_rpc *rpc)
  * disable_root_aer - disable Root Port's interrupts when receiving messages
  * @rpc: pointer to a Root Port data structure
  *
- * Invoked when PCIE bus unloads AER service driver.
+ * Invoked when PCIe bus unloads AER service driver.
  */
 static void disable_root_aer(struct aer_rpc *rpc)
 {
index 44acde72294f80210136f808135efeed76a128fe..9d3e4c8d0184202ce58177d88b2d6ac9454c20d2 100644 (file)
@@ -184,7 +184,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
 
        if (info->status == 0) {
                AER_PR(info, dev,
-                       "PCIE Bus Error: severity=%s, type=Unaccessible, "
+                       "PCIe Bus Error: severity=%s, type=Unaccessible, "
                        "id=%04x(Unregistered Agent ID)\n",
                        aer_error_severity_string[info->severity], id);
        } else {
@@ -194,7 +194,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
                agent = AER_GET_AGENT(info->severity, info->status);
 
                AER_PR(info, dev,
-                       "PCIE Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
+                       "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
                        aer_error_severity_string[info->severity],
                        aer_error_layer[layer], id, aer_agent_string[agent]);
 
index 5a01fc7fbf056371e6a1e90c874060cec486c221..be53d98fa38466992e762ca029d7c32007998d88 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * File:       drivers/pci/pcie/aspm.c
- * Enabling PCIE link L0s/L1 state and Clock Power Management
+ * Enabling PCIe link L0s/L1 state and Clock Power Management
  *
  * Copyright (C) 2007 Intel
  * Copyright (C) Zhang Yanmin (yanmin.zhang@intel.com)
@@ -499,7 +499,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
        int pos;
        u32 reg32;
        /*
-        * Some functions in a slot might not all be PCIE functions,
+        * Some functions in a slot might not all be PCIe functions,
         * very strange. Disable ASPM for the whole slot
         */
        list_for_each_entry(child, &pdev->subordinate->devices, bus_list) {
index ce52ea34fee5513822ef903a8b27ab8d38dfb359..34d65172a4d7ffe3d47b3e7f182273944a44183c 100644 (file)
@@ -24,7 +24,7 @@
  */
 #define DRIVER_VERSION "v1.0"
 #define DRIVER_AUTHOR "tom.l.nguyen@intel.com"
-#define DRIVER_DESC "PCIE Port Bus Driver"
+#define DRIVER_DESC "PCIe Port Bus Driver"
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
@@ -43,7 +43,7 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev)
 }
 
 #ifdef CONFIG_PM
-static struct dev_pm_ops pcie_portdrv_pm_ops = {
+static const struct dev_pm_ops pcie_portdrv_pm_ops = {
        .suspend        = pcie_port_device_suspend,
        .resume         = pcie_port_device_resume,
        .freeze         = pcie_port_device_suspend,
index 7cfa7c38d31869bd482138fa2fc3fcba06d561e7..8726698866b170d5f28ca17f612bbe6d78cd282e 100644 (file)
@@ -2629,13 +2629,68 @@ static int __init pci_apply_final_quirks(void)
        if (!pci_cache_line_size) {
                printk(KERN_DEBUG "PCI: CLS %u bytes, default %u\n",
                       cls << 2, pci_dfl_cache_line_size << 2);
-               pci_cache_line_size = cls;
+               pci_cache_line_size = cls ? cls : pci_dfl_cache_line_size;
        }
 
        return 0;
 }
 
 fs_initcall_sync(pci_apply_final_quirks);
+
+/*
+ * Followings are device-specific reset methods which can be used to
+ * reset a single function if other methods (e.g. FLR, PM D0->D3) are
+ * not available.
+ */
+static int reset_intel_generic_dev(struct pci_dev *dev, int probe)
+{
+       int pos;
+
+       /* only implement PCI_CLASS_SERIAL_USB at present */
+       if (dev->class == PCI_CLASS_SERIAL_USB) {
+               pos = pci_find_capability(dev, PCI_CAP_ID_VNDR);
+               if (!pos)
+                       return -ENOTTY;
+
+               if (probe)
+                       return 0;
+
+               pci_write_config_byte(dev, pos + 0x4, 1);
+               msleep(100);
+
+               return 0;
+       } else {
+               return -ENOTTY;
+       }
+}
+
+static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe)
+{
+       int pos;
+
+       pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
+       if (!pos)
+               return -ENOTTY;
+
+       if (probe)
+               return 0;
+
+       pci_write_config_word(dev, pos + PCI_EXP_DEVCTL,
+                               PCI_EXP_DEVCTL_BCR_FLR);
+       msleep(100);
+
+       return 0;
+}
+
+#define PCI_DEVICE_ID_INTEL_82599_SFP_VF   0x10ed
+
+struct pci_dev_reset_methods pci_dev_reset_methods[] = {
+       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF,
+                reset_intel_82599_sfp_virtfn },
+       { PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
+               reset_intel_generic_dev },
+       { 0 }
+};
 #else
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) {}
 #endif
index 6dae871432588e29f93b86e7a2565856cc36ab99..4a471dc4f4b9c6167a11de5d8041df65aa371fc1 100644 (file)
@@ -15,9 +15,9 @@
 
 DECLARE_RWSEM(pci_bus_sem);
 /*
- * find the upstream PCIE-to-PCI bridge of a PCI device
+ * find the upstream PCIe-to-PCI bridge of a PCI device
  * if the device is PCIE, return NULL
- * if the device isn't connected to a PCIE bridge (that is its parent is a
+ * if the device isn't connected to a PCIe bridge (that is its parent is a
  * legacy PCI bridge and the bridge is directly connected to bus 0), return its
  * parent
  */
@@ -37,7 +37,7 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
                        tmp = pdev;
                        continue;
                }
-               /* PCI device should connect to a PCIE bridge */
+               /* PCI device should connect to a PCIe bridge */
                if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) {
                        /* Busted hardware? */
                        WARN_ON_ONCE(1);
index cdf50f3bc2df389af234ed8976017ba5c717e218..d99f846451a3ecbba1d2608c6bd828696c9c15a7 100644 (file)
@@ -222,7 +222,7 @@ int __ref cb_alloc(struct pcmcia_socket *s)
        unsigned int max, pass;
 
        s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0));
-/*     pcibios_fixup_bus(bus); */
+       pci_fixup_cardbus(bus); 
 
        max = bus->secondary;
        for (pass = 0; pass < 2; pass++)
index da346eb7e77eba91474027329794c94ceb8cd2b7..76e640bccde848c258799b2d4b245e73a17e37bb 100644 (file)
@@ -291,7 +291,7 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
                skt->nr = ops->first + i;
                skt->ops = ops;
                skt->socket.owner = ops->owner;
-               skt->socket.dev.parent = dev;
+               skt->socket.dev.parent = &dev->dev;
                skt->socket.pci_irq = NO_IRQ;
 
                ret = pxa2xx_drv_pcmcia_add_one(skt);
@@ -304,8 +304,8 @@ static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
                        soc_pcmcia_remove_one(&sinfo->skt[i]);
                kfree(sinfo);
        } else {
-               pxa2xx_configure_sockets(dev);
-               dev_set_drvdata(dev, sinfo);
+               pxa2xx_configure_sockets(&dev->dev);
+               dev_set_drvdata(&dev->dev, sinfo);
        }
 
        return ret;
@@ -336,7 +336,7 @@ static int pxa2xx_drv_pcmcia_resume(struct device *dev)
        return pcmcia_socket_dev_resume(dev);
 }
 
-static struct dev_pm_ops  pxa2xx_drv_pcmcia_pm_ops = {
+static const struct dev_pm_ops pxa2xx_drv_pcmcia_pm_ops = {
        .suspend        = pxa2xx_drv_pcmcia_suspend,
        .resume         = pxa2xx_drv_pcmcia_resume,
 };
index fe02cfd4b5e905673fddb4f0d9e98391d7379ce2..e4d12acdd525d2a5acb1337f52d2c3a2fc441c9e 100644 (file)
@@ -1330,7 +1330,7 @@ static int yenta_dev_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops yenta_pm_ops = {
+static const struct dev_pm_ops yenta_pm_ops = {
        .suspend_noirq = yenta_dev_suspend_noirq,
        .resume_noirq = yenta_dev_resume_noirq,
        .resume = yenta_dev_resume,
index 55ca39dea42e7f4177a3cd9f79f709cfb7dd1a64..db32c25e360591c7dd232e6463ca00d3001e00ae 100644 (file)
@@ -231,8 +231,36 @@ config THINKPAD_ACPI
 
          This driver was formerly known as ibm-acpi.
 
+         Extra functionality will be available if the rfkill (CONFIG_RFKILL)
+         and/or ALSA (CONFIG_SND) subsystems are available in the kernel.
+         Note that if you want ThinkPad-ACPI to be built-in instead of
+         modular, ALSA and rfkill will also have to be built-in.
+
          If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
 
+config THINKPAD_ACPI_ALSA_SUPPORT
+       bool "Console audio control ALSA interface"
+       depends on THINKPAD_ACPI
+       depends on SND
+       depends on SND = y || THINKPAD_ACPI = SND
+       default y
+       ---help---
+         Enables monitoring of the built-in console audio output control
+         (headphone and speakers), which is operated by the mute and (in
+         some ThinkPad models) volume hotkeys.
+
+         If this option is enabled, ThinkPad-ACPI will export an ALSA card
+         with a single read-only mixer control, which should be used for
+         on-screen-display feedback purposes by the Desktop Environment.
+
+         Optionally, the driver will also allow software control (the
+         ALSA mixer will be made read-write).  Please refer to the driver
+         documentation for details.
+
+         All IBM models have both volume and mute control.  Newer Lenovo
+         models only have mute control (the volume hotkeys are just normal
+         keys and volume control is done through the main HDA mixer).
+
 config THINKPAD_ACPI_DEBUGFACILITIES
        bool "Maintainer debug facilities"
        depends on THINKPAD_ACPI
@@ -334,6 +362,8 @@ config EEEPC_LAPTOP
        depends on HOTPLUG_PCI
        select BACKLIGHT_CLASS_DEVICE
        select HWMON
+       select LEDS_CLASS
+       select NEW_LEDS
        ---help---
          This driver supports the Fn-Fx keys on Eee PC laptops.
 
@@ -365,6 +395,18 @@ config ACPI_WMI
          It is safe to enable this driver even if your DSDT doesn't define
          any ACPI-WMI devices.
 
+config MSI_WMI
+       tristate "MSI WMI extras"
+       depends on ACPI_WMI
+       depends on INPUT
+       depends on BACKLIGHT_CLASS_DEVICE
+       select INPUT_SPARSEKMAP
+       help
+        Say Y here if you want to support WMI-based hotkeys on MSI laptops.
+
+        To compile this driver as a module, choose M here: the module will
+        be called msi-wmi.
+
 config ACPI_ASUS
        tristate "ASUS/Medion Laptop Extras (DEPRECATED)"
        depends on ACPI
@@ -435,4 +477,31 @@ config ACPI_TOSHIBA
 
          If you have a legacy free Toshiba laptop (such as the Libretto L1
          series), say Y.
+
+config TOSHIBA_BT_RFKILL
+       tristate "Toshiba Bluetooth RFKill switch support"
+       depends on ACPI
+       ---help---
+         This driver adds support for Bluetooth events for the RFKill
+         switch on modern Toshiba laptops with full ACPI support and
+         an RFKill switch.
+
+         This driver handles RFKill events for the TOS6205 Bluetooth,
+         and re-enables it when the switch is set back to the 'on'
+         position.
+
+         If you have a modern Toshiba laptop with a Bluetooth and an
+         RFKill switch (such as the Portege R500), say Y.
+
+config ACPI_CMPC
+       tristate "CMPC Laptop Extras"
+       depends on X86 && ACPI
+       select INPUT
+       select BACKLIGHT_CLASS_DEVICE
+       default n
+       help
+         Support for Intel Classmate PC ACPI devices, including some
+         keys as input device, backlight device, tablet and accelerometer
+         devices.
+
 endif # X86_PLATFORM_DEVICES
index d1c16210a5124a3ea14ce8219db11994b0ce30a6..9cd9fa0a27e640389cd22a0872cbbdf48933adf5 100644 (file)
@@ -5,6 +5,7 @@
 obj-$(CONFIG_ASUS_LAPTOP)      += asus-laptop.o
 obj-$(CONFIG_EEEPC_LAPTOP)     += eeepc-laptop.o
 obj-$(CONFIG_MSI_LAPTOP)       += msi-laptop.o
+obj-$(CONFIG_ACPI_CMPC)                += classmate-laptop.o
 obj-$(CONFIG_COMPAL_LAPTOP)    += compal-laptop.o
 obj-$(CONFIG_DELL_LAPTOP)      += dell-laptop.o
 obj-$(CONFIG_DELL_WMI)         += dell-wmi.o
@@ -18,6 +19,8 @@ obj-$(CONFIG_FUJITSU_LAPTOP)  += fujitsu-laptop.o
 obj-$(CONFIG_PANASONIC_LAPTOP) += panasonic-laptop.o
 obj-$(CONFIG_INTEL_MENLOW)     += intel_menlow.o
 obj-$(CONFIG_ACPI_WMI)         += wmi.o
+obj-$(CONFIG_MSI_WMI)          += msi-wmi.o
 obj-$(CONFIG_ACPI_ASUS)                += asus_acpi.o
 obj-$(CONFIG_TOPSTAR_LAPTOP)   += topstar-laptop.o
 obj-$(CONFIG_ACPI_TOSHIBA)     += toshiba_acpi.o
+obj-$(CONFIG_TOSHIBA_BT_RFKILL)        += toshiba_bluetooth.o
index 454970d2d701b807317f06415a8baccaf7af50fe..07d14dfdf0b42f01caab15df68123f023219517c 100644 (file)
@@ -96,9 +96,6 @@ struct acer_quirks {
 MODULE_ALIAS("wmi:67C3371D-95A3-4C37-BB61-DD47B491DAAB");
 MODULE_ALIAS("wmi:6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3");
 
-/* Temporary workaround until the WMI sysfs interface goes in */
-MODULE_ALIAS("dmi:*:*Acer*:*:");
-
 /*
  * Interface capability flags
  */
index ab64522aaa6433df3e1fcb3c2d92c5633d2c72ad..7b2384d674d0355c24aed0c5c9f3f013826e2ed6 100644 (file)
@@ -52,7 +52,7 @@
  */
 #undef START_IN_KERNEL_MODE
 
-#define DRV_VER "0.5.18"
+#define DRV_VER "0.5.22"
 
 /*
  * According to the Atom N270 datasheet,
@@ -112,12 +112,14 @@ module_param_string(force_product, force_product, 16, 0);
 MODULE_PARM_DESC(force_product, "Force BIOS product and omit BIOS check");
 
 /*
- * cmd_off: to switch the fan completely off / to check if the fan is off
+ * cmd_off: to switch the fan completely off
+ * chk_off: to check if the fan is off
  *     cmd_auto: to set the BIOS in control of the fan. The BIOS regulates then
  *             the fan speed depending on the temperature
  */
 struct fancmd {
        u8 cmd_off;
+       u8 chk_off;
        u8 cmd_auto;
 };
 
@@ -134,32 +136,47 @@ struct bios_settings_t {
 /* Register addresses and values for different BIOS versions */
 static const struct bios_settings_t bios_tbl[] = {
        /* AOA110 */
-       {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x00} },
-       {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x00} },
-       {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0x00} },
-       {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0x00} },
-       {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0x00} },
-       {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0x00} },
-       {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x00} },
-       {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x00} },
-       {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x00} },
+       {"Acer", "AOA110", "v0.3109", 0x55, 0x58, {0x1f, 0x1f, 0x00} },
+       {"Acer", "AOA110", "v0.3114", 0x55, 0x58, {0x1f, 0x1f, 0x00} },
+       {"Acer", "AOA110", "v0.3301", 0x55, 0x58, {0xaf, 0xaf, 0x00} },
+       {"Acer", "AOA110", "v0.3304", 0x55, 0x58, {0xaf, 0xaf, 0x00} },
+       {"Acer", "AOA110", "v0.3305", 0x55, 0x58, {0xaf, 0xaf, 0x00} },
+       {"Acer", "AOA110", "v0.3307", 0x55, 0x58, {0xaf, 0xaf, 0x00} },
+       {"Acer", "AOA110", "v0.3308", 0x55, 0x58, {0x21, 0x21, 0x00} },
+       {"Acer", "AOA110", "v0.3309", 0x55, 0x58, {0x21, 0x21, 0x00} },
+       {"Acer", "AOA110", "v0.3310", 0x55, 0x58, {0x21, 0x21, 0x00} },
        /* AOA150 */
-       {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x20, 0x00} },
-       {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x00} },
-       {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x00} },
-       {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x00} },
-       {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x00} },
-       {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x00} },
-       {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x00} },
-       {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x00} },
-       /* special BIOS / other */
-       {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x00} },
-       {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x00} },
-       {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x00} },
-       {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x00} },
-       {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x00} },
+       {"Acer", "AOA150", "v0.3114", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Acer", "AOA150", "v0.3301", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Acer", "AOA150", "v0.3304", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Acer", "AOA150", "v0.3305", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Acer", "AOA150", "v0.3307", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Acer", "AOA150", "v0.3308", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Acer", "AOA150", "v0.3309", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Acer", "AOA150", "v0.3310", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       /* Acer 1410 */
+       {"Acer", "Aspire 1410", "v0.3120", 0x55, 0x58, {0x9e, 0x9e, 0x00} },
+       {"Acer", "Aspire 1410", "v1.3303", 0x55, 0x58, {0x9e, 0x9e, 0x00} },
+       /* Acer 1810xx */
+       {"Acer", "Aspire 1810TZ", "v0.3120", 0x55, 0x58, {0x9e, 0x9e, 0x00} },
+       {"Acer", "Aspire 1810T", "v0.3120", 0x55, 0x58, {0x9e, 0x9e, 0x00} },
+       {"Acer", "Aspire 1810T", "v1.3303", 0x55, 0x58, {0x9e, 0x9e, 0x00} },
+       {"Acer", "Aspire 1810TZ", "v1.3303", 0x55, 0x58, {0x9e, 0x9e, 0x00} },
+       /* Gateway */
+       {"Gateway", "AOA110", "v0.3103", 0x55, 0x58, {0x21, 0x21, 0x00} },
+       {"Gateway", "AOA150", "v0.3103", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Gateway", "LT31", "v1.3103", 0x55, 0x58, {0x10, 0x0f, 0x00} },
+       {"Gateway", "LT31", "v1.3201", 0x55, 0x58, {0x10, 0x0f, 0x00} },
+       {"Gateway", "LT31", "v1.3302", 0x55, 0x58, {0x10, 0x0f, 0x00} },
+       /* Packard Bell */
+       {"Packard Bell", "DOA150", "v0.3104", 0x55, 0x58, {0x21, 0x21, 0x00} },
+       {"Packard Bell", "DOA150", "v0.3105", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Packard Bell", "AOA110", "v0.3105", 0x55, 0x58, {0x21, 0x21, 0x00} },
+       {"Packard Bell", "AOA150", "v0.3105", 0x55, 0x58, {0x20, 0x20, 0x00} },
+       {"Packard Bell", "DOTMU", "v1.3303", 0x55, 0x58, {0x9e, 0x9e, 0x00} },
+       {"Packard Bell", "DOTMU", "v0.3120", 0x55, 0x58, {0x9e, 0x9e, 0x00} },
        /* pewpew-terminator */
-       {"", "", "", 0, 0, {0, 0} }
+       {"", "", "", 0, 0, {0, 0, 0} }
 };
 
 static const struct bios_settings_t *bios_cfg __read_mostly;
@@ -183,7 +200,7 @@ static int acerhdf_get_fanstate(int *state)
        if (ec_read(bios_cfg->fanreg, &fan))
                return -EINVAL;
 
-       if (fan != bios_cfg->cmd.cmd_off)
+       if (fan != bios_cfg->cmd.chk_off)
                *state = ACERHDF_FAN_AUTO;
        else
                *state = ACERHDF_FAN_OFF;
@@ -460,7 +477,7 @@ static int acerhdf_remove(struct platform_device *device)
        return 0;
 }
 
-static struct dev_pm_ops acerhdf_pm_ops = {
+static const struct dev_pm_ops acerhdf_pm_ops = {
        .suspend = acerhdf_suspend,
        .freeze  = acerhdf_suspend,
 };
@@ -475,13 +492,26 @@ static struct platform_driver acerhdf_driver = {
        .remove = acerhdf_remove,
 };
 
+/* checks if str begins with start */
+static int str_starts_with(const char *str, const char *start)
+{
+       unsigned long str_len = 0, start_len = 0;
+
+       str_len = strlen(str);
+       start_len = strlen(start);
+
+       if (str_len >= start_len &&
+                       !strncmp(str, start, start_len))
+               return 1;
+
+       return 0;
+}
 
 /* check hardware */
 static int acerhdf_check_hardware(void)
 {
        char const *vendor, *version, *product;
-       int i;
-       unsigned long prod_len = 0;
+       const struct bios_settings_t *bt = NULL;
 
        /* get BIOS data */
        vendor  = dmi_get_system_info(DMI_SYS_VENDOR);
@@ -503,20 +533,20 @@ static int acerhdf_check_hardware(void)
                kernelmode = 0;
        }
 
-       prod_len = strlen(product);
-
        if (verbose)
                pr_info("BIOS info: %s %s, product: %s\n",
                        vendor, version, product);
 
        /* search BIOS version and vendor in BIOS settings table */
-       for (i = 0; bios_tbl[i].version[0]; i++) {
-               if (strlen(bios_tbl[i].product) >= prod_len &&
-                   !strncmp(bios_tbl[i].product, product,
-                          strlen(bios_tbl[i].product)) &&
-                   !strcmp(bios_tbl[i].vendor, vendor) &&
-                   !strcmp(bios_tbl[i].version, version)) {
-                       bios_cfg = &bios_tbl[i];
+       for (bt = bios_tbl; bt->vendor[0]; bt++) {
+               /*
+                * check if actual hardware BIOS vendor, product and version
+                * IDs start with the strings of BIOS table entry
+                */
+               if (str_starts_with(vendor, bt->vendor) &&
+                               str_starts_with(product, bt->product) &&
+                               str_starts_with(version, bt->version)) {
+                       bios_cfg = bt;
                        break;
                }
        }
@@ -629,9 +659,14 @@ static void __exit acerhdf_exit(void)
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Peter Feuerer");
 MODULE_DESCRIPTION("Aspire One temperature and fan driver");
-MODULE_ALIAS("dmi:*:*Acer*:*:");
-MODULE_ALIAS("dmi:*:*Gateway*:*:");
-MODULE_ALIAS("dmi:*:*Packard Bell*:*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAOA*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire 1410*:");
+MODULE_ALIAS("dmi:*:*Acer*:pnAspire 1810*:");
+MODULE_ALIAS("dmi:*:*Gateway*:pnAOA*:");
+MODULE_ALIAS("dmi:*:*Gateway*:pnLT31*:");
+MODULE_ALIAS("dmi:*:*Packard Bell*:pnAOA*:");
+MODULE_ALIAS("dmi:*:*Packard Bell*:pnDOA*:");
+MODULE_ALIAS("dmi:*:*Packard Bell*:pnDOTMU*:");
 
 module_init(acerhdf_init);
 module_exit(acerhdf_exit);
index b39d2bb3e75b897ddfc48e2e8856f118d93aa95e..61a1c75036582b2f2cb968a757b95c556f94082b 100644 (file)
@@ -221,6 +221,7 @@ static struct asus_hotk *hotk;
  */
 static const struct acpi_device_id asus_device_ids[] = {
        {"ATK0100", 0},
+       {"ATK0101", 0},
        {"", 0},
 };
 MODULE_DEVICE_TABLE(acpi, asus_device_ids);
@@ -232,6 +233,7 @@ static void asus_hotk_notify(struct acpi_device *device, u32 event);
 static struct acpi_driver asus_hotk_driver = {
        .name = ASUS_HOTK_NAME,
        .class = ASUS_HOTK_CLASS,
+       .owner = THIS_MODULE,
        .ids = asus_device_ids,
        .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
        .ops = {
@@ -293,6 +295,11 @@ struct key_entry {
 enum { KE_KEY, KE_END };
 
 static struct key_entry asus_keymap[] = {
+       {KE_KEY, 0x02, KEY_SCREENLOCK},
+       {KE_KEY, 0x05, KEY_WLAN},
+       {KE_KEY, 0x08, KEY_F13},
+       {KE_KEY, 0x17, KEY_ZOOM},
+       {KE_KEY, 0x1f, KEY_BATTERY},
        {KE_KEY, 0x30, KEY_VOLUMEUP},
        {KE_KEY, 0x31, KEY_VOLUMEDOWN},
        {KE_KEY, 0x32, KEY_MUTE},
@@ -312,8 +319,11 @@ static struct key_entry asus_keymap[] = {
        {KE_KEY, 0x5F, KEY_WLAN},
        {KE_KEY, 0x60, KEY_SWITCHVIDEOMODE},
        {KE_KEY, 0x61, KEY_SWITCHVIDEOMODE},
-       {KE_KEY, 0x6B, BTN_TOUCH}, /* Lock Mouse */
+       {KE_KEY, 0x62, KEY_SWITCHVIDEOMODE},
+       {KE_KEY, 0x63, KEY_SWITCHVIDEOMODE},
+       {KE_KEY, 0x6B, KEY_F13}, /* Lock Touchpad */
        {KE_KEY, 0x82, KEY_CAMERA},
+       {KE_KEY, 0x88, KEY_WLAN },
        {KE_KEY, 0x8A, KEY_PROG1},
        {KE_KEY, 0x95, KEY_MEDIA},
        {KE_KEY, 0x99, KEY_PHONE},
@@ -1240,9 +1250,6 @@ static int asus_hotk_add(struct acpi_device *device)
 {
        int result;
 
-       if (!device)
-               return -EINVAL;
-
        pr_notice("Asus Laptop Support version %s\n",
               ASUS_LAPTOP_VERSION);
 
@@ -1283,8 +1290,8 @@ static int asus_hotk_add(struct acpi_device *device)
        hotk->ledd_status = 0xFFF;
 
        /* Set initial values of light sensor and level */
-       hotk->light_switch = 1; /* Default to light sensor disabled */
-       hotk->light_level = 0;  /* level 5 for sensor sensitivity */
+       hotk->light_switch = 0; /* Default to light sensor disabled */
+       hotk->light_level = 5;  /* level 5 for sensor sensitivity */
 
        if (ls_switch_handle)
                set_light_sens_switch(hotk->light_switch);
@@ -1306,9 +1313,6 @@ end:
 
 static int asus_hotk_remove(struct acpi_device *device, int type)
 {
-       if (!device || !acpi_driver_data(device))
-               return -EINVAL;
-
        kfree(hotk->name);
        kfree(hotk);
 
@@ -1444,9 +1448,6 @@ static int __init asus_laptop_init(void)
 {
        int result;
 
-       if (acpi_disabled)
-               return -ENODEV;
-
        result = acpi_bus_register_driver(&asus_hotk_driver);
        if (result < 0)
                return result;
index ddf5240ade8cc0e10358553382ffa68716933ce0..c1d2aeeea9482fd5b6730d78e35e412c27df25b1 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/backlight.h>
 #include <acpi/acpi_drivers.h>
 #include <acpi/acpi_bus.h>
@@ -466,6 +467,7 @@ MODULE_DEVICE_TABLE(acpi, asus_device_ids);
 static struct acpi_driver asus_hotk_driver = {
        .name = "asus_acpi",
        .class = ACPI_HOTK_CLASS,
+       .owner = THIS_MODULE,
        .ids = asus_device_ids,
        .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
        .ops = {
@@ -512,26 +514,12 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val)
        return (status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER);
 }
 
-/*
- * We write our info in page, we begin at offset off and cannot write more
- * than count bytes. We set eof to 1 if we handle those 2 values. We return the
- * number of bytes written in page
- */
-static int
-proc_read_info(char *page, char **start, off_t off, int count, int *eof,
-              void *data)
+static int asus_info_proc_show(struct seq_file *m, void *v)
 {
-       int len = 0;
        int temp;
-       char buf[16];           /* enough for all info */
-       /*
-        * We use the easy way, we don't care of off and count,
-        * so we don't set eof to 1
-        */
 
-       len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
-       len += sprintf(page + len, "Model reference    : %s\n",
-                      hotk->methods->name);
+       seq_printf(m, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
+       seq_printf(m, "Model reference    : %s\n", hotk->methods->name);
        /*
         * The SFUN method probably allows the original driver to get the list
         * of features supported by a given model. For now, 0x0100 or 0x0800
@@ -539,8 +527,7 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
         * The significance of others is yet to be found.
         */
        if (read_acpi_int(hotk->handle, "SFUN", &temp))
-               len +=
-                   sprintf(page + len, "SFUN value         : 0x%04x\n", temp);
+               seq_printf(m, "SFUN value         : 0x%04x\n", temp);
        /*
         * Another value for userspace: the ASYM method returns 0x02 for
         * battery low and 0x04 for battery critical, its readings tend to be
@@ -549,30 +536,34 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
         * silently ignored.
         */
        if (read_acpi_int(hotk->handle, "ASYM", &temp))
-               len +=
-                   sprintf(page + len, "ASYM value         : 0x%04x\n", temp);
+               seq_printf(m, "ASYM value         : 0x%04x\n", temp);
        if (asus_info) {
-               snprintf(buf, 16, "%d", asus_info->length);
-               len += sprintf(page + len, "DSDT length        : %s\n", buf);
-               snprintf(buf, 16, "%d", asus_info->checksum);
-               len += sprintf(page + len, "DSDT checksum      : %s\n", buf);
-               snprintf(buf, 16, "%d", asus_info->revision);
-               len += sprintf(page + len, "DSDT revision      : %s\n", buf);
-               snprintf(buf, 7, "%s", asus_info->oem_id);
-               len += sprintf(page + len, "OEM id             : %s\n", buf);
-               snprintf(buf, 9, "%s", asus_info->oem_table_id);
-               len += sprintf(page + len, "OEM table id       : %s\n", buf);
-               snprintf(buf, 16, "%x", asus_info->oem_revision);
-               len += sprintf(page + len, "OEM revision       : 0x%s\n", buf);
-               snprintf(buf, 5, "%s", asus_info->asl_compiler_id);
-               len += sprintf(page + len, "ASL comp vendor id : %s\n", buf);
-               snprintf(buf, 16, "%x", asus_info->asl_compiler_revision);
-               len += sprintf(page + len, "ASL comp revision  : 0x%s\n", buf);
+               seq_printf(m, "DSDT length        : %d\n", asus_info->length);
+               seq_printf(m, "DSDT checksum      : %d\n", asus_info->checksum);
+               seq_printf(m, "DSDT revision      : %d\n", asus_info->revision);
+               seq_printf(m, "OEM id             : %.*s\n", ACPI_OEM_ID_SIZE, asus_info->oem_id);
+               seq_printf(m, "OEM table id       : %.*s\n", ACPI_OEM_TABLE_ID_SIZE, asus_info->oem_table_id);
+               seq_printf(m, "OEM revision       : 0x%x\n", asus_info->oem_revision);
+               seq_printf(m, "ASL comp vendor id : %.*s\n", ACPI_NAME_SIZE, asus_info->asl_compiler_id);
+               seq_printf(m, "ASL comp revision  : 0x%x\n", asus_info->asl_compiler_revision);
        }
 
-       return len;
+       return 0;
+}
+
+static int asus_info_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, asus_info_proc_show, NULL);
 }
 
+static const struct file_operations asus_info_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = asus_info_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 /*
  * /proc handlers
  * We write our info in page, we begin at offset off and cannot write more
@@ -638,34 +629,48 @@ write_led(const char __user *buffer, unsigned long count,
 /*
  * Proc handlers for MLED
  */
-static int
-proc_read_mled(char *page, char **start, off_t off, int count, int *eof,
-              void *data)
+static int mled_proc_show(struct seq_file *m, void *v)
 {
-       return sprintf(page, "%d\n",
-                      read_led(hotk->methods->mled_status, MLED_ON));
+       seq_printf(m, "%d\n", read_led(hotk->methods->mled_status, MLED_ON));
+       return 0;
 }
 
-static int
-proc_write_mled(struct file *file, const char __user *buffer,
-               unsigned long count, void *data)
+static int mled_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, mled_proc_show, NULL);
+}
+
+static ssize_t mled_proc_write(struct file *file, const char __user *buffer,
+               size_t count, loff_t *pos)
 {
        return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1);
 }
 
+static const struct file_operations mled_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = mled_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = mled_proc_write,
+};
+
 /*
  * Proc handlers for LED display
  */
-static int
-proc_read_ledd(char *page, char **start, off_t off, int count, int *eof,
-              void *data)
+static int ledd_proc_show(struct seq_file *m, void *v)
 {
-       return sprintf(page, "0x%08x\n", hotk->ledd_status);
+       seq_printf(m, "0x%08x\n", hotk->ledd_status);
+       return 0;
 }
 
-static int
-proc_write_ledd(struct file *file, const char __user *buffer,
-               unsigned long count, void *data)
+static int ledd_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, ledd_proc_show, NULL);
+}
+
+static ssize_t ledd_proc_write(struct file *file, const char __user *buffer,
+               size_t count, loff_t *pos)
 {
        int rv, value;
 
@@ -681,61 +686,104 @@ proc_write_ledd(struct file *file, const char __user *buffer,
        return rv;
 }
 
+static const struct file_operations ledd_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = ledd_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = ledd_proc_write,
+};
+
 /*
  * Proc handlers for WLED
  */
-static int
-proc_read_wled(char *page, char **start, off_t off, int count, int *eof,
-              void *data)
+static int wled_proc_show(struct seq_file *m, void *v)
 {
-       return sprintf(page, "%d\n",
-                      read_led(hotk->methods->wled_status, WLED_ON));
+       seq_printf(m, "%d\n", read_led(hotk->methods->wled_status, WLED_ON));
+       return 0;
 }
 
-static int
-proc_write_wled(struct file *file, const char __user *buffer,
-               unsigned long count, void *data)
+static int wled_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, wled_proc_show, NULL);
+}
+
+static ssize_t wled_proc_write(struct file *file, const char __user *buffer,
+               size_t count, loff_t *pos)
 {
        return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0);
 }
 
+static const struct file_operations wled_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = wled_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = wled_proc_write,
+};
+
 /*
  * Proc handlers for Bluetooth
  */
-static int
-proc_read_bluetooth(char *page, char **start, off_t off, int count, int *eof,
-                   void *data)
+static int bluetooth_proc_show(struct seq_file *m, void *v)
 {
-       return sprintf(page, "%d\n", read_led(hotk->methods->bt_status, BT_ON));
+       seq_printf(m, "%d\n", read_led(hotk->methods->bt_status, BT_ON));
+       return 0;
 }
 
-static int
-proc_write_bluetooth(struct file *file, const char __user *buffer,
-                    unsigned long count, void *data)
+static int bluetooth_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, bluetooth_proc_show, NULL);
+}
+
+static ssize_t bluetooth_proc_write(struct file *file,
+               const char __user *buffer, size_t count, loff_t *pos)
 {
        /* Note: mt_bt_switch controls both internal Bluetooth adapter's
           presence and its LED */
        return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0);
 }
 
+static const struct file_operations bluetooth_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = bluetooth_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = bluetooth_proc_write,
+};
+
 /*
  * Proc handlers for TLED
  */
-static int
-proc_read_tled(char *page, char **start, off_t off, int count, int *eof,
-              void *data)
+static int tled_proc_show(struct seq_file *m, void *v)
 {
-       return sprintf(page, "%d\n",
-                      read_led(hotk->methods->tled_status, TLED_ON));
+       seq_printf(m, "%d\n", read_led(hotk->methods->tled_status, TLED_ON));
+       return 0;
 }
 
-static int
-proc_write_tled(struct file *file, const char __user *buffer,
-               unsigned long count, void *data)
+static int tled_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, tled_proc_show, NULL);
+}
+
+static ssize_t tled_proc_write(struct file *file, const char __user *buffer,
+               size_t count, loff_t *pos)
 {
        return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0);
 }
 
+static const struct file_operations tled_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = tled_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = tled_proc_write,
+};
+
 static int get_lcd_state(void)
 {
        int lcd = 0;
@@ -828,16 +876,19 @@ static int set_lcd_state(int value)
 
 }
 
-static int
-proc_read_lcd(char *page, char **start, off_t off, int count, int *eof,
-             void *data)
+static int lcd_proc_show(struct seq_file *m, void *v)
 {
-       return sprintf(page, "%d\n", get_lcd_state());
+       seq_printf(m, "%d\n", get_lcd_state());
+       return 0;
 }
 
-static int
-proc_write_lcd(struct file *file, const char __user *buffer,
-              unsigned long count, void *data)
+static int lcd_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, lcd_proc_show, NULL);
+}
+
+static ssize_t lcd_proc_write(struct file *file, const char __user *buffer,
+              size_t count, loff_t *pos)
 {
        int rv, value;
 
@@ -847,6 +898,15 @@ proc_write_lcd(struct file *file, const char __user *buffer,
        return rv;
 }
 
+static const struct file_operations lcd_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = lcd_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = lcd_proc_write,
+};
+
 static int read_brightness(struct backlight_device *bd)
 {
        int value;
@@ -906,16 +966,19 @@ static int set_brightness_status(struct backlight_device *bd)
        return set_brightness(bd->props.brightness);
 }
 
-static int
-proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
-             void *data)
+static int brn_proc_show(struct seq_file *m, void *v)
 {
-       return sprintf(page, "%d\n", read_brightness(NULL));
+       seq_printf(m, "%d\n", read_brightness(NULL));
+       return 0;
 }
 
-static int
-proc_write_brn(struct file *file, const char __user *buffer,
-              unsigned long count, void *data)
+static int brn_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, brn_proc_show, NULL);
+}
+
+static ssize_t brn_proc_write(struct file *file, const char __user *buffer,
+              size_t count, loff_t *pos)
 {
        int rv, value;
 
@@ -928,6 +991,15 @@ proc_write_brn(struct file *file, const char __user *buffer,
        return rv;
 }
 
+static const struct file_operations brn_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = brn_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = brn_proc_write,
+};
+
 static void set_display(int value)
 {
        /* no sanity check needed for now */
@@ -941,9 +1013,7 @@ static void set_display(int value)
  * Now, *this* one could be more user-friendly, but so far, no-one has
  * complained. The significance of bits is the same as in proc_write_disp()
  */
-static int
-proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
-              void *data)
+static int disp_proc_show(struct seq_file *m, void *v)
 {
        int value = 0;
 
@@ -951,7 +1021,13 @@ proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
                printk(KERN_WARNING
                       "Asus ACPI: Error reading display status\n");
        value &= 0x07;  /* needed for some models, shouldn't hurt others */
-       return sprintf(page, "%d\n", value);
+       seq_printf(m, "%d\n", value);
+       return 0;
+}
+
+static int disp_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, disp_proc_show, NULL);
 }
 
 /*
@@ -960,9 +1036,8 @@ proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
  * (bitwise) of these will suffice. I never actually tested 3 displays hooked
  * up simultaneously, so be warned. See the acpi4asus README for more info.
  */
-static int
-proc_write_disp(struct file *file, const char __user *buffer,
-               unsigned long count, void *data)
+static ssize_t disp_proc_write(struct file *file, const char __user *buffer,
+               size_t count, loff_t *pos)
 {
        int rv, value;
 
@@ -972,25 +1047,27 @@ proc_write_disp(struct file *file, const char __user *buffer,
        return rv;
 }
 
-typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,
-                            int *eof, void *data);
-typedef int (proc_writefunc) (struct file *file, const char __user *buffer,
-                             unsigned long count, void *data);
+static const struct file_operations disp_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = disp_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = disp_proc_write,
+};
 
 static int
-asus_proc_add(char *name, proc_writefunc *writefunc,
-                    proc_readfunc *readfunc, mode_t mode,
+asus_proc_add(char *name, const struct file_operations *proc_fops, mode_t mode,
                     struct acpi_device *device)
 {
-       struct proc_dir_entry *proc =
-           create_proc_entry(name, mode, acpi_device_dir(device));
+       struct proc_dir_entry *proc;
+
+       proc = proc_create_data(name, mode, acpi_device_dir(device),
+                               proc_fops, acpi_driver_data(device));
        if (!proc) {
                printk(KERN_WARNING "  Unable to create %s fs entry\n", name);
                return -1;
        }
-       proc->write_proc = writefunc;
-       proc->read_proc = readfunc;
-       proc->data = acpi_driver_data(device);
        proc->uid = asus_uid;
        proc->gid = asus_gid;
        return 0;
@@ -1019,10 +1096,9 @@ static int asus_hotk_add_fs(struct acpi_device *device)
        if (!acpi_device_dir(device))
                return -ENODEV;
 
-       proc = create_proc_entry(PROC_INFO, mode, acpi_device_dir(device));
+       proc = proc_create(PROC_INFO, mode, acpi_device_dir(device),
+                          &asus_info_proc_fops);
        if (proc) {
-               proc->read_proc = proc_read_info;
-               proc->data = acpi_driver_data(device);
                proc->uid = asus_uid;
                proc->gid = asus_gid;
        } else {
@@ -1031,28 +1107,23 @@ static int asus_hotk_add_fs(struct acpi_device *device)
        }
 
        if (hotk->methods->mt_wled) {
-               asus_proc_add(PROC_WLED, &proc_write_wled, &proc_read_wled,
-                             mode, device);
+               asus_proc_add(PROC_WLED, &wled_proc_fops, mode, device);
        }
 
        if (hotk->methods->mt_ledd) {
-               asus_proc_add(PROC_LEDD, &proc_write_ledd, &proc_read_ledd,
-                             mode, device);
+               asus_proc_add(PROC_LEDD, &ledd_proc_fops, mode, device);
        }
 
        if (hotk->methods->mt_mled) {
-               asus_proc_add(PROC_MLED, &proc_write_mled, &proc_read_mled,
-                             mode, device);
+               asus_proc_add(PROC_MLED, &mled_proc_fops, mode, device);
        }
 
        if (hotk->methods->mt_tled) {
-               asus_proc_add(PROC_TLED, &proc_write_tled, &proc_read_tled,
-                             mode, device);
+               asus_proc_add(PROC_TLED, &tled_proc_fops, mode, device);
        }
 
        if (hotk->methods->mt_bt_switch) {
-               asus_proc_add(PROC_BT, &proc_write_bluetooth,
-                             &proc_read_bluetooth, mode, device);
+               asus_proc_add(PROC_BT, &bluetooth_proc_fops, mode, device);
        }
 
        /*
@@ -1060,19 +1131,16 @@ static int asus_hotk_add_fs(struct acpi_device *device)
         * accessible from the keyboard
         */
        if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) {
-               asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode,
-                             device);
+               asus_proc_add(PROC_LCD, &lcd_proc_fops, mode, device);
        }
 
        if ((hotk->methods->brightness_up && hotk->methods->brightness_down) ||
            (hotk->methods->brightness_get && hotk->methods->brightness_set)) {
-               asus_proc_add(PROC_BRN, &proc_write_brn, &proc_read_brn, mode,
-                             device);
+               asus_proc_add(PROC_BRN, &brn_proc_fops, mode, device);
        }
 
        if (hotk->methods->display_set) {
-               asus_proc_add(PROC_DISP, &proc_write_disp, &proc_read_disp,
-                             mode, device);
+               asus_proc_add(PROC_DISP, &disp_proc_fops, mode, device);
        }
 
        return 0;
@@ -1334,9 +1402,6 @@ static int asus_hotk_add(struct acpi_device *device)
        acpi_status status = AE_OK;
        int result;
 
-       if (!device)
-               return -EINVAL;
-
        printk(KERN_NOTICE "Asus Laptop ACPI Extras version %s\n",
               ASUS_ACPI_VERSION);
 
@@ -1392,9 +1457,6 @@ end:
 
 static int asus_hotk_remove(struct acpi_device *device, int type)
 {
-       if (!device || !acpi_driver_data(device))
-               return -EINVAL;
-
        asus_hotk_remove_fs(device);
 
        kfree(hotk);
@@ -1422,21 +1484,17 @@ static int __init asus_acpi_init(void)
 {
        int result;
 
-       if (acpi_disabled)
-               return -ENODEV;
+       result = acpi_bus_register_driver(&asus_hotk_driver);
+       if (result < 0)
+               return result;
 
        asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
        if (!asus_proc_dir) {
                printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
+               acpi_bus_unregister_driver(&asus_hotk_driver);
                return -ENODEV;
        }
 
-       result = acpi_bus_register_driver(&asus_hotk_driver);
-       if (result < 0) {
-               remove_proc_entry(PROC_ASUS, acpi_root_dir);
-               return result;
-       }
-
        /*
         * This is a bit of a kludge.  We only want this module loaded
         * for ASUS systems, but there's currently no way to probe the
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
new file mode 100644 (file)
index 0000000..ed90082
--- /dev/null
@@ -0,0 +1,609 @@
+/*
+ *  Copyright (C) 2009  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/workqueue.h>
+#include <acpi/acpi_drivers.h>
+#include <linux/backlight.h>
+#include <linux/input.h>
+
+MODULE_LICENSE("GPL");
+
+
+struct cmpc_accel {
+       int sensitivity;
+};
+
+#define CMPC_ACCEL_SENSITIVITY_DEFAULT         5
+
+
+/*
+ * Generic input device code.
+ */
+
+typedef void (*input_device_init)(struct input_dev *dev);
+
+static int cmpc_add_acpi_notify_device(struct acpi_device *acpi, char *name,
+                                      input_device_init idev_init)
+{
+       struct input_dev *inputdev;
+       int error;
+
+       inputdev = input_allocate_device();
+       if (!inputdev)
+               return -ENOMEM;
+       inputdev->name = name;
+       inputdev->dev.parent = &acpi->dev;
+       idev_init(inputdev);
+       error = input_register_device(inputdev);
+       if (error) {
+               input_free_device(inputdev);
+               return error;
+       }
+       dev_set_drvdata(&acpi->dev, inputdev);
+       return 0;
+}
+
+static int cmpc_remove_acpi_notify_device(struct acpi_device *acpi)
+{
+       struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+       input_unregister_device(inputdev);
+       return 0;
+}
+
+/*
+ * Accelerometer code.
+ */
+static acpi_status cmpc_start_accel(acpi_handle handle)
+{
+       union acpi_object param[2];
+       struct acpi_object_list input;
+       acpi_status status;
+
+       param[0].type = ACPI_TYPE_INTEGER;
+       param[0].integer.value = 0x3;
+       param[1].type = ACPI_TYPE_INTEGER;
+       input.count = 2;
+       input.pointer = param;
+       status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
+       return status;
+}
+
+static acpi_status cmpc_stop_accel(acpi_handle handle)
+{
+       union acpi_object param[2];
+       struct acpi_object_list input;
+       acpi_status status;
+
+       param[0].type = ACPI_TYPE_INTEGER;
+       param[0].integer.value = 0x4;
+       param[1].type = ACPI_TYPE_INTEGER;
+       input.count = 2;
+       input.pointer = param;
+       status = acpi_evaluate_object(handle, "ACMD", &input, NULL);
+       return status;
+}
+
+static acpi_status cmpc_accel_set_sensitivity(acpi_handle handle, int val)
+{
+       union acpi_object param[2];
+       struct acpi_object_list input;
+
+       param[0].type = ACPI_TYPE_INTEGER;
+       param[0].integer.value = 0x02;
+       param[1].type = ACPI_TYPE_INTEGER;
+       param[1].integer.value = val;
+       input.count = 2;
+       input.pointer = param;
+       return acpi_evaluate_object(handle, "ACMD", &input, NULL);
+}
+
+static acpi_status cmpc_get_accel(acpi_handle handle,
+                                 unsigned char *x,
+                                 unsigned char *y,
+                                 unsigned char *z)
+{
+       union acpi_object param[2];
+       struct acpi_object_list input;
+       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, 0 };
+       unsigned char *locs;
+       acpi_status status;
+
+       param[0].type = ACPI_TYPE_INTEGER;
+       param[0].integer.value = 0x01;
+       param[1].type = ACPI_TYPE_INTEGER;
+       input.count = 2;
+       input.pointer = param;
+       status = acpi_evaluate_object(handle, "ACMD", &input, &output);
+       if (ACPI_SUCCESS(status)) {
+               union acpi_object *obj;
+               obj = output.pointer;
+               locs = obj->buffer.pointer;
+               *x = locs[0];
+               *y = locs[1];
+               *z = locs[2];
+               kfree(output.pointer);
+       }
+       return status;
+}
+
+static void cmpc_accel_handler(struct acpi_device *dev, u32 event)
+{
+       if (event == 0x81) {
+               unsigned char x, y, z;
+               acpi_status status;
+
+               status = cmpc_get_accel(dev->handle, &x, &y, &z);
+               if (ACPI_SUCCESS(status)) {
+                       struct input_dev *inputdev = dev_get_drvdata(&dev->dev);
+
+                       input_report_abs(inputdev, ABS_X, x);
+                       input_report_abs(inputdev, ABS_Y, y);
+                       input_report_abs(inputdev, ABS_Z, z);
+                       input_sync(inputdev);
+               }
+       }
+}
+
+static ssize_t cmpc_accel_sensitivity_show(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct acpi_device *acpi;
+       struct input_dev *inputdev;
+       struct cmpc_accel *accel;
+
+       acpi = to_acpi_device(dev);
+       inputdev = dev_get_drvdata(&acpi->dev);
+       accel = dev_get_drvdata(&inputdev->dev);
+
+       return sprintf(buf, "%d\n", accel->sensitivity);
+}
+
+static ssize_t cmpc_accel_sensitivity_store(struct device *dev,
+                                           struct device_attribute *attr,
+                                           const char *buf, size_t count)
+{
+       struct acpi_device *acpi;
+       struct input_dev *inputdev;
+       struct cmpc_accel *accel;
+       unsigned long sensitivity;
+       int r;
+
+       acpi = to_acpi_device(dev);
+       inputdev = dev_get_drvdata(&acpi->dev);
+       accel = dev_get_drvdata(&inputdev->dev);
+
+       r = strict_strtoul(buf, 0, &sensitivity);
+       if (r)
+               return r;
+
+       accel->sensitivity = sensitivity;
+       cmpc_accel_set_sensitivity(acpi->handle, sensitivity);
+
+       return strnlen(buf, count);
+}
+
+struct device_attribute cmpc_accel_sensitivity_attr = {
+       .attr = { .name = "sensitivity", .mode = 0660 },
+       .show = cmpc_accel_sensitivity_show,
+       .store = cmpc_accel_sensitivity_store
+};
+
+static int cmpc_accel_open(struct input_dev *input)
+{
+       struct acpi_device *acpi;
+
+       acpi = to_acpi_device(input->dev.parent);
+       if (ACPI_SUCCESS(cmpc_start_accel(acpi->handle)))
+               return 0;
+       return -EIO;
+}
+
+static void cmpc_accel_close(struct input_dev *input)
+{
+       struct acpi_device *acpi;
+
+       acpi = to_acpi_device(input->dev.parent);
+       cmpc_stop_accel(acpi->handle);
+}
+
+static void cmpc_accel_idev_init(struct input_dev *inputdev)
+{
+       set_bit(EV_ABS, inputdev->evbit);
+       input_set_abs_params(inputdev, ABS_X, 0, 255, 8, 0);
+       input_set_abs_params(inputdev, ABS_Y, 0, 255, 8, 0);
+       input_set_abs_params(inputdev, ABS_Z, 0, 255, 8, 0);
+       inputdev->open = cmpc_accel_open;
+       inputdev->close = cmpc_accel_close;
+}
+
+static int cmpc_accel_add(struct acpi_device *acpi)
+{
+       int error;
+       struct input_dev *inputdev;
+       struct cmpc_accel *accel;
+
+       accel = kmalloc(sizeof(*accel), GFP_KERNEL);
+       if (!accel)
+               return -ENOMEM;
+
+       accel->sensitivity = CMPC_ACCEL_SENSITIVITY_DEFAULT;
+       cmpc_accel_set_sensitivity(acpi->handle, accel->sensitivity);
+
+       error = device_create_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
+       if (error)
+               goto failed_file;
+
+       error = cmpc_add_acpi_notify_device(acpi, "cmpc_accel",
+                                           cmpc_accel_idev_init);
+       if (error)
+               goto failed_input;
+
+       inputdev = dev_get_drvdata(&acpi->dev);
+       dev_set_drvdata(&inputdev->dev, accel);
+
+       return 0;
+
+failed_input:
+       device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
+failed_file:
+       kfree(accel);
+       return error;
+}
+
+static int cmpc_accel_remove(struct acpi_device *acpi, int type)
+{
+       struct input_dev *inputdev;
+       struct cmpc_accel *accel;
+
+       inputdev = dev_get_drvdata(&acpi->dev);
+       accel = dev_get_drvdata(&inputdev->dev);
+
+       device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
+       return cmpc_remove_acpi_notify_device(acpi);
+}
+
+static const struct acpi_device_id cmpc_accel_device_ids[] = {
+       {"ACCE0000", 0},
+       {"", 0}
+};
+MODULE_DEVICE_TABLE(acpi, cmpc_accel_device_ids);
+
+static struct acpi_driver cmpc_accel_acpi_driver = {
+       .owner = THIS_MODULE,
+       .name = "cmpc_accel",
+       .class = "cmpc_accel",
+       .ids = cmpc_accel_device_ids,
+       .ops = {
+               .add = cmpc_accel_add,
+               .remove = cmpc_accel_remove,
+               .notify = cmpc_accel_handler,
+       }
+};
+
+
+/*
+ * Tablet mode code.
+ */
+static acpi_status cmpc_get_tablet(acpi_handle handle,
+                                  unsigned long long *value)
+{
+       union acpi_object param;
+       struct acpi_object_list input;
+       unsigned long long output;
+       acpi_status status;
+
+       param.type = ACPI_TYPE_INTEGER;
+       param.integer.value = 0x01;
+       input.count = 1;
+       input.pointer = &param;
+       status = acpi_evaluate_integer(handle, "TCMD", &input, &output);
+       if (ACPI_SUCCESS(status))
+               *value = output;
+       return status;
+}
+
+static void cmpc_tablet_handler(struct acpi_device *dev, u32 event)
+{
+       unsigned long long val = 0;
+       struct input_dev *inputdev = dev_get_drvdata(&dev->dev);
+
+       if (event == 0x81) {
+               if (ACPI_SUCCESS(cmpc_get_tablet(dev->handle, &val)))
+                       input_report_switch(inputdev, SW_TABLET_MODE, !val);
+       }
+}
+
+static void cmpc_tablet_idev_init(struct input_dev *inputdev)
+{
+       unsigned long long val = 0;
+       struct acpi_device *acpi;
+
+       set_bit(EV_SW, inputdev->evbit);
+       set_bit(SW_TABLET_MODE, inputdev->swbit);
+
+       acpi = to_acpi_device(inputdev->dev.parent);
+       if (ACPI_SUCCESS(cmpc_get_tablet(acpi->handle, &val)))
+               input_report_switch(inputdev, SW_TABLET_MODE, !val);
+}
+
+static int cmpc_tablet_add(struct acpi_device *acpi)
+{
+       return cmpc_add_acpi_notify_device(acpi, "cmpc_tablet",
+                                          cmpc_tablet_idev_init);
+}
+
+static int cmpc_tablet_remove(struct acpi_device *acpi, int type)
+{
+       return cmpc_remove_acpi_notify_device(acpi);
+}
+
+static int cmpc_tablet_resume(struct acpi_device *acpi)
+{
+       struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+       unsigned long long val = 0;
+       if (ACPI_SUCCESS(cmpc_get_tablet(acpi->handle, &val)))
+               input_report_switch(inputdev, SW_TABLET_MODE, !val);
+       return 0;
+}
+
+static const struct acpi_device_id cmpc_tablet_device_ids[] = {
+       {"TBLT0000", 0},
+       {"", 0}
+};
+MODULE_DEVICE_TABLE(acpi, cmpc_tablet_device_ids);
+
+static struct acpi_driver cmpc_tablet_acpi_driver = {
+       .owner = THIS_MODULE,
+       .name = "cmpc_tablet",
+       .class = "cmpc_tablet",
+       .ids = cmpc_tablet_device_ids,
+       .ops = {
+               .add = cmpc_tablet_add,
+               .remove = cmpc_tablet_remove,
+               .resume = cmpc_tablet_resume,
+               .notify = cmpc_tablet_handler,
+       }
+};
+
+
+/*
+ * Backlight code.
+ */
+
+static acpi_status cmpc_get_brightness(acpi_handle handle,
+                                      unsigned long long *value)
+{
+       union acpi_object param;
+       struct acpi_object_list input;
+       unsigned long long output;
+       acpi_status status;
+
+       param.type = ACPI_TYPE_INTEGER;
+       param.integer.value = 0xC0;
+       input.count = 1;
+       input.pointer = &param;
+       status = acpi_evaluate_integer(handle, "GRDI", &input, &output);
+       if (ACPI_SUCCESS(status))
+               *value = output;
+       return status;
+}
+
+static acpi_status cmpc_set_brightness(acpi_handle handle,
+                                      unsigned long long value)
+{
+       union acpi_object param[2];
+       struct acpi_object_list input;
+       acpi_status status;
+       unsigned long long output;
+
+       param[0].type = ACPI_TYPE_INTEGER;
+       param[0].integer.value = 0xC0;
+       param[1].type = ACPI_TYPE_INTEGER;
+       param[1].integer.value = value;
+       input.count = 2;
+       input.pointer = param;
+       status = acpi_evaluate_integer(handle, "GWRI", &input, &output);
+       return status;
+}
+
+static int cmpc_bl_get_brightness(struct backlight_device *bd)
+{
+       acpi_status status;
+       acpi_handle handle;
+       unsigned long long brightness;
+
+       handle = bl_get_data(bd);
+       status = cmpc_get_brightness(handle, &brightness);
+       if (ACPI_SUCCESS(status))
+               return brightness;
+       else
+               return -1;
+}
+
+static int cmpc_bl_update_status(struct backlight_device *bd)
+{
+       acpi_status status;
+       acpi_handle handle;
+
+       handle = bl_get_data(bd);
+       status = cmpc_set_brightness(handle, bd->props.brightness);
+       if (ACPI_SUCCESS(status))
+               return 0;
+       else
+               return -1;
+}
+
+static struct backlight_ops cmpc_bl_ops = {
+       .get_brightness = cmpc_bl_get_brightness,
+       .update_status = cmpc_bl_update_status
+};
+
+static int cmpc_bl_add(struct acpi_device *acpi)
+{
+       struct backlight_device *bd;
+
+       bd = backlight_device_register("cmpc_bl", &acpi->dev,
+                                      acpi->handle, &cmpc_bl_ops);
+       bd->props.max_brightness = 7;
+       dev_set_drvdata(&acpi->dev, bd);
+       return 0;
+}
+
+static int cmpc_bl_remove(struct acpi_device *acpi, int type)
+{
+       struct backlight_device *bd;
+
+       bd = dev_get_drvdata(&acpi->dev);
+       backlight_device_unregister(bd);
+       return 0;
+}
+
+static const struct acpi_device_id cmpc_device_ids[] = {
+       {"IPML200", 0},
+       {"", 0}
+};
+MODULE_DEVICE_TABLE(acpi, cmpc_device_ids);
+
+static struct acpi_driver cmpc_bl_acpi_driver = {
+       .owner = THIS_MODULE,
+       .name = "cmpc",
+       .class = "cmpc",
+       .ids = cmpc_device_ids,
+       .ops = {
+               .add = cmpc_bl_add,
+               .remove = cmpc_bl_remove
+       }
+};
+
+
+/*
+ * Extra keys code.
+ */
+static int cmpc_keys_codes[] = {
+       KEY_UNKNOWN,
+       KEY_WLAN,
+       KEY_SWITCHVIDEOMODE,
+       KEY_BRIGHTNESSDOWN,
+       KEY_BRIGHTNESSUP,
+       KEY_VENDOR,
+       KEY_MAX
+};
+
+static void cmpc_keys_handler(struct acpi_device *dev, u32 event)
+{
+       struct input_dev *inputdev;
+       int code = KEY_MAX;
+
+       if ((event & 0x0F) < ARRAY_SIZE(cmpc_keys_codes))
+               code = cmpc_keys_codes[event & 0x0F];
+       inputdev = dev_get_drvdata(&dev->dev);;
+       input_report_key(inputdev, code, !(event & 0x10));
+}
+
+static void cmpc_keys_idev_init(struct input_dev *inputdev)
+{
+       int i;
+
+       set_bit(EV_KEY, inputdev->evbit);
+       for (i = 0; cmpc_keys_codes[i] != KEY_MAX; i++)
+               set_bit(cmpc_keys_codes[i], inputdev->keybit);
+}
+
+static int cmpc_keys_add(struct acpi_device *acpi)
+{
+       return cmpc_add_acpi_notify_device(acpi, "cmpc_keys",
+                                          cmpc_keys_idev_init);
+}
+
+static int cmpc_keys_remove(struct acpi_device *acpi, int type)
+{
+       return cmpc_remove_acpi_notify_device(acpi);
+}
+
+static const struct acpi_device_id cmpc_keys_device_ids[] = {
+       {"FnBT0000", 0},
+       {"", 0}
+};
+MODULE_DEVICE_TABLE(acpi, cmpc_keys_device_ids);
+
+static struct acpi_driver cmpc_keys_acpi_driver = {
+       .owner = THIS_MODULE,
+       .name = "cmpc_keys",
+       .class = "cmpc_keys",
+       .ids = cmpc_keys_device_ids,
+       .ops = {
+               .add = cmpc_keys_add,
+               .remove = cmpc_keys_remove,
+               .notify = cmpc_keys_handler,
+       }
+};
+
+
+/*
+ * General init/exit code.
+ */
+
+static int cmpc_init(void)
+{
+       int r;
+
+       r = acpi_bus_register_driver(&cmpc_keys_acpi_driver);
+       if (r)
+               goto failed_keys;
+
+       r = acpi_bus_register_driver(&cmpc_bl_acpi_driver);
+       if (r)
+               goto failed_bl;
+
+       r = acpi_bus_register_driver(&cmpc_tablet_acpi_driver);
+       if (r)
+               goto failed_tablet;
+
+       r = acpi_bus_register_driver(&cmpc_accel_acpi_driver);
+       if (r)
+               goto failed_accel;
+
+       return r;
+
+failed_accel:
+       acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
+
+failed_tablet:
+       acpi_bus_unregister_driver(&cmpc_bl_acpi_driver);
+
+failed_bl:
+       acpi_bus_unregister_driver(&cmpc_keys_acpi_driver);
+
+failed_keys:
+       return r;
+}
+
+static void cmpc_exit(void)
+{
+       acpi_bus_unregister_driver(&cmpc_accel_acpi_driver);
+       acpi_bus_unregister_driver(&cmpc_tablet_acpi_driver);
+       acpi_bus_unregister_driver(&cmpc_bl_acpi_driver);
+       acpi_bus_unregister_driver(&cmpc_keys_acpi_driver);
+}
+
+module_init(cmpc_init);
+module_exit(cmpc_exit);
index 11003bba10d3e495cee585b83d49dc27f5b4ee80..1a387e79f71945ac92b6536643ec83ec8398be3e 100644 (file)
@@ -51,7 +51,6 @@
 #include <linux/dmi.h>
 #include <linux/backlight.h>
 #include <linux/platform_device.h>
-#include <linux/autoconf.h>
 
 #define COMPAL_DRIVER_VERSION "0.2.6"
 
index 74909c4aaeea8777bd8edd668dc10602705ff186..3780994dc8f2a533795397cce09aba310d950b0a 100644 (file)
@@ -58,6 +58,14 @@ static int da_command_code;
 static int da_num_tokens;
 static struct calling_interface_token *da_tokens;
 
+static struct platform_driver platform_driver = {
+       .driver = {
+               .name = "dell-laptop",
+               .owner = THIS_MODULE,
+       }
+};
+
+static struct platform_device *platform_device;
 static struct backlight_device *dell_backlight_device;
 static struct rfkill *wifi_rfkill;
 static struct rfkill *bluetooth_rfkill;
@@ -74,7 +82,7 @@ static const struct dmi_system_id __initdata dell_device_table[] = {
        { }
 };
 
-static void parse_da_table(const struct dmi_header *dm)
+static void __init parse_da_table(const struct dmi_header *dm)
 {
        /* Final token is a terminator, so we don't want to copy it */
        int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1;
@@ -103,7 +111,7 @@ static void parse_da_table(const struct dmi_header *dm)
        da_num_tokens += tokens;
 }
 
-static void find_tokens(const struct dmi_header *dm, void *dummy)
+static void __init find_tokens(const struct dmi_header *dm, void *dummy)
 {
        switch (dm->type) {
        case 0xd4: /* Indexed IO */
@@ -197,8 +205,8 @@ static void dell_rfkill_query(struct rfkill *rfkill, void *data)
        dell_send_request(&buffer, 17, 11);
        status = buffer.output[1];
 
-       if (status & BIT(bit))
-               rfkill_set_hw_state(rfkill, !!(status & BIT(16)));
+       rfkill_set_sw_state(rfkill, !!(status & BIT(bit)));
+       rfkill_set_hw_state(rfkill, !(status & BIT(16)));
 }
 
 static const struct rfkill_ops dell_rfkill_ops = {
@@ -206,7 +214,7 @@ static const struct rfkill_ops dell_rfkill_ops = {
        .query = dell_rfkill_query,
 };
 
-static int dell_setup_rfkill(void)
+static int __init dell_setup_rfkill(void)
 {
        struct calling_interface_buffer buffer;
        int status;
@@ -217,7 +225,8 @@ static int dell_setup_rfkill(void)
        status = buffer.output[1];
 
        if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) {
-               wifi_rfkill = rfkill_alloc("dell-wifi", NULL, RFKILL_TYPE_WLAN,
+               wifi_rfkill = rfkill_alloc("dell-wifi", &platform_device->dev,
+                                          RFKILL_TYPE_WLAN,
                                           &dell_rfkill_ops, (void *) 1);
                if (!wifi_rfkill) {
                        ret = -ENOMEM;
@@ -229,7 +238,8 @@ static int dell_setup_rfkill(void)
        }
 
        if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) {
-               bluetooth_rfkill = rfkill_alloc("dell-bluetooth", NULL,
+               bluetooth_rfkill = rfkill_alloc("dell-bluetooth",
+                                               &platform_device->dev,
                                                RFKILL_TYPE_BLUETOOTH,
                                                &dell_rfkill_ops, (void *) 2);
                if (!bluetooth_rfkill) {
@@ -242,7 +252,9 @@ static int dell_setup_rfkill(void)
        }
 
        if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) {
-               wwan_rfkill = rfkill_alloc("dell-wwan", NULL, RFKILL_TYPE_WWAN,
+               wwan_rfkill = rfkill_alloc("dell-wwan",
+                                          &platform_device->dev,
+                                          RFKILL_TYPE_WWAN,
                                           &dell_rfkill_ops, (void *) 3);
                if (!wwan_rfkill) {
                        ret = -ENOMEM;
@@ -268,6 +280,22 @@ err_wifi:
        return ret;
 }
 
+static void dell_cleanup_rfkill(void)
+{
+       if (wifi_rfkill) {
+               rfkill_unregister(wifi_rfkill);
+               rfkill_destroy(wifi_rfkill);
+       }
+       if (bluetooth_rfkill) {
+               rfkill_unregister(bluetooth_rfkill);
+               rfkill_destroy(bluetooth_rfkill);
+       }
+       if (wwan_rfkill) {
+               rfkill_unregister(wwan_rfkill);
+               rfkill_destroy(wwan_rfkill);
+       }
+}
+
 static int dell_send_intensity(struct backlight_device *bd)
 {
        struct calling_interface_buffer buffer;
@@ -326,11 +354,23 @@ static int __init dell_init(void)
                return -ENODEV;
        }
 
+       ret = platform_driver_register(&platform_driver);
+       if (ret)
+               goto fail_platform_driver;
+       platform_device = platform_device_alloc("dell-laptop", -1);
+       if (!platform_device) {
+               ret = -ENOMEM;
+               goto fail_platform_device1;
+       }
+       ret = platform_device_add(platform_device);
+       if (ret)
+               goto fail_platform_device2;
+
        ret = dell_setup_rfkill();
 
        if (ret) {
                printk(KERN_WARNING "dell-laptop: Unable to setup rfkill\n");
-               goto out;
+               goto fail_rfkill;
        }
 
 #ifdef CONFIG_ACPI
@@ -352,13 +392,13 @@ static int __init dell_init(void)
        if (max_intensity) {
                dell_backlight_device = backlight_device_register(
                        "dell_backlight",
-                       NULL, NULL,
+                       &platform_device->dev, NULL,
                        &dell_ops);
 
                if (IS_ERR(dell_backlight_device)) {
                        ret = PTR_ERR(dell_backlight_device);
                        dell_backlight_device = NULL;
-                       goto out;
+                       goto fail_backlight;
                }
 
                dell_backlight_device->props.max_brightness = max_intensity;
@@ -368,13 +408,16 @@ static int __init dell_init(void)
        }
 
        return 0;
-out:
-       if (wifi_rfkill)
-               rfkill_unregister(wifi_rfkill);
-       if (bluetooth_rfkill)
-               rfkill_unregister(bluetooth_rfkill);
-       if (wwan_rfkill)
-               rfkill_unregister(wwan_rfkill);
+
+fail_backlight:
+       dell_cleanup_rfkill();
+fail_rfkill:
+       platform_device_del(platform_device);
+fail_platform_device2:
+       platform_device_put(platform_device);
+fail_platform_device1:
+       platform_driver_unregister(&platform_driver);
+fail_platform_driver:
        kfree(da_tokens);
        return ret;
 }
@@ -382,12 +425,7 @@ out:
 static void __exit dell_exit(void)
 {
        backlight_device_unregister(dell_backlight_device);
-       if (wifi_rfkill)
-               rfkill_unregister(wifi_rfkill);
-       if (bluetooth_rfkill)
-               rfkill_unregister(bluetooth_rfkill);
-       if (wwan_rfkill)
-               rfkill_unregister(wwan_rfkill);
+       dell_cleanup_rfkill();
 }
 
 module_init(dell_init);
index 0f900cc9fa7a5131283c14b2aae8e11d7667b949..1b1dddbd5744e85d0a1123ac27d0a7379190eb13 100644 (file)
@@ -31,6 +31,7 @@
 #include <acpi/acpi_drivers.h>
 #include <linux/acpi.h>
 #include <linux/string.h>
+#include <linux/dmi.h>
 
 MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
 MODULE_DESCRIPTION("Dell laptop WMI hotkeys driver");
@@ -38,6 +39,8 @@ MODULE_LICENSE("GPL");
 
 #define DELL_EVENT_GUID "9DBB5994-A997-11DA-B012-B622A1EF5492"
 
+static int acpi_video;
+
 MODULE_ALIAS("wmi:"DELL_EVENT_GUID);
 
 struct key_entry {
@@ -54,7 +57,7 @@ enum { KE_KEY, KE_SW, KE_IGNORE, KE_END };
  * via the keyboard controller so should not be sent again.
  */
 
-static struct key_entry dell_wmi_keymap[] = {
+static struct key_entry dell_legacy_wmi_keymap[] = {
        {KE_KEY, 0xe045, KEY_PROG1},
        {KE_KEY, 0xe009, KEY_EJECTCD},
 
@@ -72,7 +75,7 @@ static struct key_entry dell_wmi_keymap[] = {
 
        /* The next device is at offset 6, the active devices are at
           offset 8 and the attached devices at offset 10 */
-       {KE_KEY, 0xe00b, KEY_DISPLAYTOGGLE},
+       {KE_KEY, 0xe00b, KEY_SWITCHVIDEOMODE},
 
        {KE_IGNORE, 0xe00c, KEY_KBDILLUMTOGGLE},
 
@@ -96,6 +99,47 @@ static struct key_entry dell_wmi_keymap[] = {
        {KE_END, 0}
 };
 
+static bool dell_new_hk_type;
+
+struct dell_new_keymap_entry {
+       u16 scancode;
+       u16 keycode;
+};
+
+struct dell_hotkey_table {
+       struct dmi_header header;
+       struct dell_new_keymap_entry keymap[];
+
+};
+
+static struct key_entry *dell_new_wmi_keymap;
+
+static u16 bios_to_linux_keycode[256] = {
+
+       KEY_MEDIA,      KEY_NEXTSONG,   KEY_PLAYPAUSE, KEY_PREVIOUSSONG,
+       KEY_STOPCD,     KEY_UNKNOWN,    KEY_UNKNOWN,    KEY_UNKNOWN,
+       KEY_WWW,        KEY_UNKNOWN,    KEY_VOLUMEDOWN, KEY_MUTE,
+       KEY_VOLUMEUP,   KEY_UNKNOWN,    KEY_BATTERY,    KEY_EJECTCD,
+       KEY_UNKNOWN,    KEY_SLEEP,      KEY_PROG1, KEY_BRIGHTNESSDOWN,
+       KEY_BRIGHTNESSUP,       KEY_UNKNOWN,    KEY_KBDILLUMTOGGLE,
+       KEY_UNKNOWN,    KEY_SWITCHVIDEOMODE,    KEY_UNKNOWN, KEY_UNKNOWN,
+       KEY_SWITCHVIDEOMODE,    KEY_UNKNOWN,    KEY_UNKNOWN, KEY_PROG2,
+       KEY_UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+       KEY_PROG3
+};
+
+
+static struct key_entry *dell_wmi_keymap = dell_legacy_wmi_keymap;
+
 static struct input_dev *dell_wmi_input_dev;
 
 static struct key_entry *dell_wmi_get_entry_by_scancode(int code)
@@ -158,30 +202,90 @@ static void dell_wmi_notify(u32 value, void *context)
        struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
        static struct key_entry *key;
        union acpi_object *obj;
+       acpi_status status;
 
-       wmi_get_event_data(value, &response);
+       status = wmi_get_event_data(value, &response);
+       if (status != AE_OK) {
+               printk(KERN_INFO "dell-wmi: bad event status 0x%x\n", status);
+               return;
+       }
 
        obj = (union acpi_object *)response.pointer;
 
        if (obj && obj->type == ACPI_TYPE_BUFFER) {
-               int *buffer = (int *)obj->buffer.pointer;
-               /*
-                *  The upper bytes of the event may contain
-                *  additional information, so mask them off for the
-                *  scancode lookup
-                */
-               key = dell_wmi_get_entry_by_scancode(buffer[1] & 0xFFFF);
-               if (key) {
+               int reported_key;
+               u16 *buffer_entry = (u16 *)obj->buffer.pointer;
+               if (dell_new_hk_type && (buffer_entry[1] != 0x10)) {
+                       printk(KERN_INFO "dell-wmi: Received unknown WMI event"
+                                        " (0x%x)\n", buffer_entry[1]);
+                       return;
+               }
+
+               if (dell_new_hk_type)
+                       reported_key = (int)buffer_entry[2];
+               else
+                       reported_key = (int)buffer_entry[1] & 0xffff;
+
+               key = dell_wmi_get_entry_by_scancode(reported_key);
+
+               if (!key) {
+                       printk(KERN_INFO "dell-wmi: Unknown key %x pressed\n",
+                               reported_key);
+               } else if ((key->keycode == KEY_BRIGHTNESSUP ||
+                           key->keycode == KEY_BRIGHTNESSDOWN) && acpi_video) {
+                       /* Don't report brightness notifications that will also
+                        * come via ACPI */
+                       return;
+               } else {
                        input_report_key(dell_wmi_input_dev, key->keycode, 1);
                        input_sync(dell_wmi_input_dev);
                        input_report_key(dell_wmi_input_dev, key->keycode, 0);
                        input_sync(dell_wmi_input_dev);
-               } else if (buffer[1] & 0xFFFF)
-                       printk(KERN_INFO "dell-wmi: Unknown key %x pressed\n",
-                              buffer[1] & 0xFFFF);
+               }
+       }
+       kfree(obj);
+}
+
+
+static void setup_new_hk_map(const struct dmi_header *dm)
+{
+
+       int i;
+       int hotkey_num = (dm->length-4)/sizeof(struct dell_new_keymap_entry);
+       struct dell_hotkey_table *table =
+               container_of(dm, struct dell_hotkey_table, header);
+
+       dell_new_wmi_keymap = kzalloc((hotkey_num+1) *
+                                     sizeof(struct key_entry), GFP_KERNEL);
+
+       for (i = 0; i < hotkey_num; i++) {
+               dell_new_wmi_keymap[i].type = KE_KEY;
+               dell_new_wmi_keymap[i].code = table->keymap[i].scancode;
+               dell_new_wmi_keymap[i].keycode =
+                       (table->keymap[i].keycode > 255) ? 0 :
+                       bios_to_linux_keycode[table->keymap[i].keycode];
+       }
+
+       dell_new_wmi_keymap[i].type = KE_END;
+       dell_new_wmi_keymap[i].code = 0;
+       dell_new_wmi_keymap[i].keycode = 0;
+
+       dell_wmi_keymap = dell_new_wmi_keymap;
+
+}
+
+
+static void find_hk_type(const struct dmi_header *dm, void *dummy)
+{
+
+       if ((dm->type == 0xb2) && (dm->length > 6)) {
+               dell_new_hk_type = true;
+               setup_new_hk_map(dm);
        }
+
 }
 
+
 static int __init dell_wmi_input_setup(void)
 {
        struct key_entry *key;
@@ -224,34 +328,37 @@ static int __init dell_wmi_input_setup(void)
 static int __init dell_wmi_init(void)
 {
        int err;
+       acpi_status status;
 
-       if (wmi_has_guid(DELL_EVENT_GUID)) {
-               err = dell_wmi_input_setup();
+       if (!wmi_has_guid(DELL_EVENT_GUID)) {
+               printk(KERN_WARNING "dell-wmi: No known WMI GUID found\n");
+               return -ENODEV;
+       }
 
-               if (err)
-                       return err;
+       dmi_walk(find_hk_type, NULL);
+       acpi_video = acpi_video_backlight_support();
 
-               err = wmi_install_notify_handler(DELL_EVENT_GUID,
-                                                dell_wmi_notify, NULL);
-               if (err) {
-                       input_unregister_device(dell_wmi_input_dev);
-                       printk(KERN_ERR "dell-wmi: Unable to register"
-                              " notify handler - %d\n", err);
-                       return err;
-               }
+       err = dell_wmi_input_setup();
+       if (err)
+               return err;
 
-       } else
-               printk(KERN_WARNING "dell-wmi: No known WMI GUID found\n");
+       status = wmi_install_notify_handler(DELL_EVENT_GUID,
+                                        dell_wmi_notify, NULL);
+       if (ACPI_FAILURE(status)) {
+               input_unregister_device(dell_wmi_input_dev);
+               printk(KERN_ERR
+                       "dell-wmi: Unable to register notify handler - %d\n",
+                       status);
+               return -ENODEV;
+       }
 
        return 0;
 }
 
 static void __exit dell_wmi_exit(void)
 {
-       if (wmi_has_guid(DELL_EVENT_GUID)) {
-               wmi_remove_notify_handler(DELL_EVENT_GUID);
-               input_unregister_device(dell_wmi_input_dev);
-       }
+       wmi_remove_notify_handler(DELL_EVENT_GUID);
+       input_unregister_device(dell_wmi_input_dev);
 }
 
 module_init(dell_wmi_init);
index 4226e535273874fb06aea0344c4c8ce00a8b957c..5838c69b2fb304937da89c53cab090bf6d9a65de 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  eepc-laptop.c - Asus Eee PC extras
+ *  eeepc-laptop.c - Asus Eee PC extras
  *
  *  Based on asus_acpi.c as patched for the Eee PC by Asus:
  *  ftp://ftp.asus.com/pub/ASUS/EeePC/701/ASUS_ACPI_071126.rar
 #include <linux/rfkill.h>
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
+#include <linux/leds.h>
 
 #define EEEPC_LAPTOP_VERSION   "0.1"
+#define EEEPC_LAPTOP_NAME      "Eee PC Hotkey Driver"
+#define EEEPC_LAPTOP_FILE      "eeepc"
 
-#define EEEPC_HOTK_NAME                "Eee PC Hotkey Driver"
-#define EEEPC_HOTK_FILE                "eeepc"
-#define EEEPC_HOTK_CLASS       "hotkey"
-#define EEEPC_HOTK_DEVICE_NAME "Hotkey"
-#define EEEPC_HOTK_HID         "ASUS010"
+#define EEEPC_ACPI_CLASS       "hotkey"
+#define EEEPC_ACPI_DEVICE_NAME "Hotkey"
+#define EEEPC_ACPI_HID         "ASUS010"
 
+MODULE_AUTHOR("Corentin Chary, Eric Cooper");
+MODULE_DESCRIPTION(EEEPC_LAPTOP_NAME);
+MODULE_LICENSE("GPL");
 
 /*
  * Definitions for Asus EeePC
  */
-#define        NOTIFY_WLAN_ON  0x10
 #define NOTIFY_BRN_MIN 0x20
 #define NOTIFY_BRN_MAX 0x2f
 
@@ -117,58 +120,6 @@ static const char *cm_setv[] = {
        NULL, NULL, "PBPS", "TPDS"
 };
 
-#define EEEPC_EC       "\\_SB.PCI0.SBRG.EC0."
-
-#define EEEPC_EC_FAN_PWM       EEEPC_EC "SC02" /* Fan PWM duty cycle (%) */
-#define EEEPC_EC_SC02          0x63
-#define EEEPC_EC_FAN_HRPM      EEEPC_EC "SC05" /* High byte, fan speed (RPM) */
-#define EEEPC_EC_FAN_LRPM      EEEPC_EC "SC06" /* Low byte, fan speed (RPM) */
-#define EEEPC_EC_FAN_CTRL      EEEPC_EC "SFB3" /* Byte containing SF25  */
-#define EEEPC_EC_SFB3          0xD3
-
-/*
- * This is the main structure, we can use it to store useful information
- * about the hotk device
- */
-struct eeepc_hotk {
-       struct acpi_device *device;     /* the device we are in */
-       acpi_handle handle;             /* the handle of the hotk device */
-       u32 cm_supported;               /* the control methods supported
-                                          by this BIOS */
-       uint init_flag;                 /* Init flags */
-       u16 event_count[128];           /* count for each event */
-       struct input_dev *inputdev;
-       u16 *keycode_map;
-       struct rfkill *wlan_rfkill;
-       struct rfkill *bluetooth_rfkill;
-       struct rfkill *wwan3g_rfkill;
-       struct rfkill *wimax_rfkill;
-       struct hotplug_slot *hotplug_slot;
-       struct mutex hotplug_lock;
-};
-
-/* The actual device the driver binds to */
-static struct eeepc_hotk *ehotk;
-
-/* Platform device/driver */
-static int eeepc_hotk_thaw(struct device *device);
-static int eeepc_hotk_restore(struct device *device);
-
-static struct dev_pm_ops eeepc_pm_ops = {
-       .thaw = eeepc_hotk_thaw,
-       .restore = eeepc_hotk_restore,
-};
-
-static struct platform_driver platform_driver = {
-       .driver = {
-               .name = EEEPC_HOTK_FILE,
-               .owner = THIS_MODULE,
-               .pm = &eeepc_pm_ops,
-       }
-};
-
-static struct platform_device *platform_device;
-
 struct key_entry {
        char type;
        u8 code;
@@ -177,7 +128,7 @@ struct key_entry {
 
 enum { KE_KEY, KE_END };
 
-static struct key_entry eeepc_keymap[] = {
+static const struct key_entry eeepc_keymap[] = {
        /* Sleep already handled via generic ACPI code */
        {KE_KEY, 0x10, KEY_WLAN },
        {KE_KEY, 0x11, KEY_WLAN },
@@ -185,77 +136,56 @@ static struct key_entry eeepc_keymap[] = {
        {KE_KEY, 0x13, KEY_MUTE },
        {KE_KEY, 0x14, KEY_VOLUMEDOWN },
        {KE_KEY, 0x15, KEY_VOLUMEUP },
+       {KE_KEY, 0x16, KEY_DISPLAY_OFF },
        {KE_KEY, 0x1a, KEY_COFFEE },
        {KE_KEY, 0x1b, KEY_ZOOM },
        {KE_KEY, 0x1c, KEY_PROG2 },
        {KE_KEY, 0x1d, KEY_PROG3 },
-       {KE_KEY, NOTIFY_BRN_MIN,     KEY_BRIGHTNESSDOWN },
-       {KE_KEY, NOTIFY_BRN_MIN + 2, KEY_BRIGHTNESSUP },
+       {KE_KEY, NOTIFY_BRN_MIN, KEY_BRIGHTNESSDOWN },
+       {KE_KEY, NOTIFY_BRN_MAX, KEY_BRIGHTNESSUP },
        {KE_KEY, 0x30, KEY_SWITCHVIDEOMODE },
        {KE_KEY, 0x31, KEY_SWITCHVIDEOMODE },
        {KE_KEY, 0x32, KEY_SWITCHVIDEOMODE },
+       {KE_KEY, 0x37, KEY_F13 }, /* Disable Touchpad */
+       {KE_KEY, 0x38, KEY_F14 },
        {KE_END, 0},
 };
 
+
 /*
- * The hotkey driver declaration
+ * This is the main structure, we can use it to store useful information
  */
-static int eeepc_hotk_add(struct acpi_device *device);
-static int eeepc_hotk_remove(struct acpi_device *device, int type);
-static void eeepc_hotk_notify(struct acpi_device *device, u32 event);
-
-static const struct acpi_device_id eeepc_device_ids[] = {
-       {EEEPC_HOTK_HID, 0},
-       {"", 0},
-};
-MODULE_DEVICE_TABLE(acpi, eeepc_device_ids);
-
-static struct acpi_driver eeepc_hotk_driver = {
-       .name = EEEPC_HOTK_NAME,
-       .class = EEEPC_HOTK_CLASS,
-       .ids = eeepc_device_ids,
-       .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
-       .ops = {
-               .add = eeepc_hotk_add,
-               .remove = eeepc_hotk_remove,
-               .notify = eeepc_hotk_notify,
-       },
-};
+struct eeepc_laptop {
+       acpi_handle handle;             /* the handle of the acpi device */
+       u32 cm_supported;               /* the control methods supported
+                                          by this BIOS */
+       u16 event_count[128];           /* count for each event */
 
-/* PCI hotplug ops */
-static int eeepc_get_adapter_status(struct hotplug_slot *slot, u8 *value);
+       struct platform_device *platform_device;
+       struct device *hwmon_device;
+       struct backlight_device *backlight_device;
 
-static struct hotplug_slot_ops eeepc_hotplug_slot_ops = {
-       .owner = THIS_MODULE,
-       .get_adapter_status = eeepc_get_adapter_status,
-       .get_power_status = eeepc_get_adapter_status,
-};
+       struct input_dev *inputdev;
+       struct key_entry *keymap;
 
-/* The backlight device /sys/class/backlight */
-static struct backlight_device *eeepc_backlight_device;
+       struct rfkill *wlan_rfkill;
+       struct rfkill *bluetooth_rfkill;
+       struct rfkill *wwan3g_rfkill;
+       struct rfkill *wimax_rfkill;
 
-/* The hwmon device */
-static struct device *eeepc_hwmon_device;
+       struct hotplug_slot *hotplug_slot;
+       struct mutex hotplug_lock;
 
-/*
- * The backlight class declaration
- */
-static int read_brightness(struct backlight_device *bd);
-static int update_bl_status(struct backlight_device *bd);
-static struct backlight_ops eeepcbl_ops = {
-       .get_brightness = read_brightness,
-       .update_status = update_bl_status,
+       struct led_classdev tpd_led;
+       int tpd_led_wk;
+       struct workqueue_struct *led_workqueue;
+       struct work_struct tpd_led_work;
 };
 
-MODULE_AUTHOR("Corentin Chary, Eric Cooper");
-MODULE_DESCRIPTION(EEEPC_HOTK_NAME);
-MODULE_LICENSE("GPL");
-
 /*
  * ACPI Helpers
  */
-static int write_acpi_int(acpi_handle handle, const char *method, int val,
-                         struct acpi_buffer *output)
+static int write_acpi_int(acpi_handle handle, const char *method, int val)
 {
        struct acpi_object_list params;
        union acpi_object in_obj;
@@ -266,7 +196,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
        in_obj.type = ACPI_TYPE_INTEGER;
        in_obj.integer.value = val;
 
-       status = acpi_evaluate_object(handle, (char *)method, &params, output);
+       status = acpi_evaluate_object(handle, (char *)method, &params, NULL);
        return (status == AE_OK ? 0 : -1);
 }
 
@@ -285,81 +215,56 @@ static int read_acpi_int(acpi_handle handle, const char *method, int *val)
        }
 }
 
-static int set_acpi(int cm, int value)
-{
-       if (ehotk->cm_supported & (0x1 << cm)) {
-               const char *method = cm_setv[cm];
-               if (method == NULL)
-                       return -ENODEV;
-               if (write_acpi_int(ehotk->handle, method, value, NULL))
-                       pr_warning("Error writing %s\n", method);
-       }
-       return 0;
-}
-
-static int get_acpi(int cm)
+static int set_acpi(struct eeepc_laptop *eeepc, int cm, int value)
 {
-       int value = -ENODEV;
-       if ((ehotk->cm_supported & (0x1 << cm))) {
-               const char *method = cm_getv[cm];
-               if (method == NULL)
-                       return -ENODEV;
-               if (read_acpi_int(ehotk->handle, method, &value))
-                       pr_warning("Error reading %s\n", method);
-       }
-       return value;
-}
+       const char *method = cm_setv[cm];
 
-/*
- * Backlight
- */
-static int read_brightness(struct backlight_device *bd)
-{
-       return get_acpi(CM_ASL_PANELBRIGHT);
-}
+       if (method == NULL)
+               return -ENODEV;
+       if ((eeepc->cm_supported & (0x1 << cm)) == 0)
+               return -ENODEV;
 
-static int set_brightness(struct backlight_device *bd, int value)
-{
-       value = max(0, min(15, value));
-       return set_acpi(CM_ASL_PANELBRIGHT, value);
+       if (write_acpi_int(eeepc->handle, method, value))
+               pr_warning("Error writing %s\n", method);
+       return 0;
 }
 
-static int update_bl_status(struct backlight_device *bd)
+static int get_acpi(struct eeepc_laptop *eeepc, int cm)
 {
-       return set_brightness(bd, bd->props.brightness);
-}
+       const char *method = cm_getv[cm];
+       int value;
 
-/*
- * Rfkill helpers
- */
+       if (method == NULL)
+               return -ENODEV;
+       if ((eeepc->cm_supported & (0x1 << cm)) == 0)
+               return -ENODEV;
 
-static bool eeepc_wlan_rfkill_blocked(void)
-{
-       if (get_acpi(CM_ASL_WLAN) == 1)
-               return false;
-       return true;
+       if (read_acpi_int(eeepc->handle, method, &value))
+               pr_warning("Error reading %s\n", method);
+       return value;
 }
 
-static int eeepc_rfkill_set(void *data, bool blocked)
+static int acpi_setter_handle(struct eeepc_laptop *eeepc, int cm,
+                             acpi_handle *handle)
 {
-       unsigned long asl = (unsigned long)data;
-       return set_acpi(asl, !blocked);
-}
+       const char *method = cm_setv[cm];
+       acpi_status status;
 
-static const struct rfkill_ops eeepc_rfkill_ops = {
-       .set_block = eeepc_rfkill_set,
-};
+       if (method == NULL)
+               return -ENODEV;
+       if ((eeepc->cm_supported & (0x1 << cm)) == 0)
+               return -ENODEV;
 
-static void __devinit eeepc_enable_camera(void)
-{
-       /*
-        * If the following call to set_acpi() fails, it's because there's no
-        * camera so we can ignore the error.
-        */
-       if (get_acpi(CM_ASL_CAMERA) == 0)
-               set_acpi(CM_ASL_CAMERA, 1);
+       status = acpi_get_handle(eeepc->handle, (char *)method,
+                                handle);
+       if (status != AE_OK) {
+               pr_warning("Error finding %s\n", method);
+               return -ENODEV;
+       }
+       return 0;
 }
 
+
 /*
  * Sys helpers
  */
@@ -372,60 +277,63 @@ static int parse_arg(const char *buf, unsigned long count, int *val)
        return count;
 }
 
-static ssize_t store_sys_acpi(int cm, const char *buf, size_t count)
+static ssize_t store_sys_acpi(struct device *dev, int cm,
+                             const char *buf, size_t count)
 {
+       struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
        int rv, value;
 
        rv = parse_arg(buf, count, &value);
        if (rv > 0)
-               value = set_acpi(cm, value);
+               value = set_acpi(eeepc, cm, value);
        if (value < 0)
-               return value;
+               return -EIO;
        return rv;
 }
 
-static ssize_t show_sys_acpi(int cm, char *buf)
+static ssize_t show_sys_acpi(struct device *dev, int cm, char *buf)
 {
-       int value = get_acpi(cm);
+       struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
+       int value = get_acpi(eeepc, cm);
 
        if (value < 0)
-               return value;
+               return -EIO;
        return sprintf(buf, "%d\n", value);
 }
 
-#define EEEPC_CREATE_DEVICE_ATTR(_name, _cm)                           \
+#define EEEPC_CREATE_DEVICE_ATTR(_name, _mode, _cm)                    \
        static ssize_t show_##_name(struct device *dev,                 \
                                    struct device_attribute *attr,      \
                                    char *buf)                          \
        {                                                               \
-               return show_sys_acpi(_cm, buf);                         \
+               return show_sys_acpi(dev, _cm, buf);                    \
        }                                                               \
        static ssize_t store_##_name(struct device *dev,                \
                                     struct device_attribute *attr,     \
                                     const char *buf, size_t count)     \
        {                                                               \
-               return store_sys_acpi(_cm, buf, count);                 \
+               return store_sys_acpi(dev, _cm, buf, count);            \
        }                                                               \
        static struct device_attribute dev_attr_##_name = {             \
                .attr = {                                               \
                        .name = __stringify(_name),                     \
-                       .mode = 0644 },                                 \
+                       .mode = _mode },                                \
                .show   = show_##_name,                                 \
                .store  = store_##_name,                                \
        }
 
-EEEPC_CREATE_DEVICE_ATTR(camera, CM_ASL_CAMERA);
-EEEPC_CREATE_DEVICE_ATTR(cardr, CM_ASL_CARDREADER);
-EEEPC_CREATE_DEVICE_ATTR(disp, CM_ASL_DISPLAYSWITCH);
+EEEPC_CREATE_DEVICE_ATTR(camera, 0644, CM_ASL_CAMERA);
+EEEPC_CREATE_DEVICE_ATTR(cardr, 0644, CM_ASL_CARDREADER);
+EEEPC_CREATE_DEVICE_ATTR(disp, 0200, CM_ASL_DISPLAYSWITCH);
 
 struct eeepc_cpufv {
        int num;
        int cur;
 };
 
-static int get_cpufv(struct eeepc_cpufv *c)
+static int get_cpufv(struct eeepc_laptop *eeepc, struct eeepc_cpufv *c)
 {
-       c->cur = get_acpi(CM_ASL_CPUFV);
+       c->cur = get_acpi(eeepc, CM_ASL_CPUFV);
        c->num = (c->cur >> 8) & 0xff;
        c->cur &= 0xff;
        if (c->cur < 0 || c->num <= 0 || c->num > 12)
@@ -437,11 +345,12 @@ static ssize_t show_available_cpufv(struct device *dev,
                                    struct device_attribute *attr,
                                    char *buf)
 {
+       struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
        struct eeepc_cpufv c;
        int i;
        ssize_t len = 0;
 
-       if (get_cpufv(&c))
+       if (get_cpufv(eeepc, &c))
                return -ENODEV;
        for (i = 0; i < c.num; i++)
                len += sprintf(buf + len, "%d ", i);
@@ -453,9 +362,10 @@ static ssize_t show_cpufv(struct device *dev,
                          struct device_attribute *attr,
                          char *buf)
 {
+       struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
        struct eeepc_cpufv c;
 
-       if (get_cpufv(&c))
+       if (get_cpufv(eeepc, &c))
                return -ENODEV;
        return sprintf(buf, "%#x\n", (c.num << 8) | c.cur);
 }
@@ -464,17 +374,18 @@ static ssize_t store_cpufv(struct device *dev,
                           struct device_attribute *attr,
                           const char *buf, size_t count)
 {
+       struct eeepc_laptop *eeepc = dev_get_drvdata(dev);
        struct eeepc_cpufv c;
        int rv, value;
 
-       if (get_cpufv(&c))
+       if (get_cpufv(eeepc, &c))
                return -ENODEV;
        rv = parse_arg(buf, count, &value);
        if (rv < 0)
                return rv;
        if (!rv || value < 0 || value >= c.num)
                return -EINVAL;
-       set_acpi(CM_ASL_CPUFV, value);
+       set_acpi(eeepc, CM_ASL_CPUFV, value);
        return rv;
 }
 
@@ -506,156 +417,125 @@ static struct attribute_group platform_attribute_group = {
        .attrs = platform_attributes
 };
 
-/*
- * Hotkey functions
- */
-static struct key_entry *eepc_get_entry_by_scancode(int code)
+static int eeepc_platform_init(struct eeepc_laptop *eeepc)
 {
-       struct key_entry *key;
-
-       for (key = eeepc_keymap; key->type != KE_END; key++)
-               if (code == key->code)
-                       return key;
+       int result;
 
-       return NULL;
-}
+       eeepc->platform_device = platform_device_alloc(EEEPC_LAPTOP_FILE, -1);
+       if (!eeepc->platform_device)
+               return -ENOMEM;
+       platform_set_drvdata(eeepc->platform_device, eeepc);
 
-static struct key_entry *eepc_get_entry_by_keycode(int code)
-{
-       struct key_entry *key;
+       result = platform_device_add(eeepc->platform_device);
+       if (result)
+               goto fail_platform_device;
 
-       for (key = eeepc_keymap; key->type != KE_END; key++)
-               if (code == key->keycode && key->type == KE_KEY)
-                       return key;
+       result = sysfs_create_group(&eeepc->platform_device->dev.kobj,
+                                   &platform_attribute_group);
+       if (result)
+               goto fail_sysfs;
+       return 0;
 
-       return NULL;
+fail_sysfs:
+       platform_device_del(eeepc->platform_device);
+fail_platform_device:
+       platform_device_put(eeepc->platform_device);
+       return result;
 }
 
-static int eeepc_getkeycode(struct input_dev *dev, int scancode, int *keycode)
+static void eeepc_platform_exit(struct eeepc_laptop *eeepc)
 {
-       struct key_entry *key = eepc_get_entry_by_scancode(scancode);
+       sysfs_remove_group(&eeepc->platform_device->dev.kobj,
+                          &platform_attribute_group);
+       platform_device_unregister(eeepc->platform_device);
+}
 
-       if (key && key->type == KE_KEY) {
-               *keycode = key->keycode;
-               return 0;
-       }
+/*
+ * LEDs
+ */
+/*
+ * These functions actually update the LED's, and are called from a
+ * workqueue. By doing this as separate work rather than when the LED
+ * subsystem asks, we avoid messing with the Asus ACPI stuff during a
+ * potentially bad time, such as a timer interrupt.
+ */
+static void tpd_led_update(struct work_struct *work)
+ {
+       struct eeepc_laptop *eeepc;
 
-       return -EINVAL;
+       eeepc = container_of(work, struct eeepc_laptop, tpd_led_work);
+
+       set_acpi(eeepc, CM_ASL_TPD, eeepc->tpd_led_wk);
 }
 
-static int eeepc_setkeycode(struct input_dev *dev, int scancode, int keycode)
+static void tpd_led_set(struct led_classdev *led_cdev,
+                       enum led_brightness value)
 {
-       struct key_entry *key;
-       int old_keycode;
-
-       if (keycode < 0 || keycode > KEY_MAX)
-               return -EINVAL;
+       struct eeepc_laptop *eeepc;
 
-       key = eepc_get_entry_by_scancode(scancode);
-       if (key && key->type == KE_KEY) {
-               old_keycode = key->keycode;
-               key->keycode = keycode;
-               set_bit(keycode, dev->keybit);
-               if (!eepc_get_entry_by_keycode(old_keycode))
-                       clear_bit(old_keycode, dev->keybit);
-               return 0;
-       }
+       eeepc = container_of(led_cdev, struct eeepc_laptop, tpd_led);
 
-       return -EINVAL;
+       eeepc->tpd_led_wk = (value > 0) ? 1 : 0;
+       queue_work(eeepc->led_workqueue, &eeepc->tpd_led_work);
 }
 
-static void cmsg_quirk(int cm, const char *name)
+static int eeepc_led_init(struct eeepc_laptop *eeepc)
 {
-       int dummy;
+       int rv;
 
-       /* Some BIOSes do not report cm although it is avaliable.
-          Check if cm_getv[cm] works and, if yes, assume cm should be set. */
-       if (!(ehotk->cm_supported & (1 << cm))
-           && !read_acpi_int(ehotk->handle, cm_getv[cm], &dummy)) {
-               pr_info("%s (%x) not reported by BIOS,"
-                       " enabling anyway\n", name, 1 << cm);
-               ehotk->cm_supported |= 1 << cm;
-       }
-}
+       if (get_acpi(eeepc, CM_ASL_TPD) == -ENODEV)
+               return 0;
 
-static void cmsg_quirks(void)
-{
-       cmsg_quirk(CM_ASL_LID, "LID");
-       cmsg_quirk(CM_ASL_TYPE, "TYPE");
-       cmsg_quirk(CM_ASL_PANELPOWER, "PANELPOWER");
-       cmsg_quirk(CM_ASL_TPD, "TPD");
-}
+       eeepc->led_workqueue = create_singlethread_workqueue("led_workqueue");
+       if (!eeepc->led_workqueue)
+               return -ENOMEM;
+       INIT_WORK(&eeepc->tpd_led_work, tpd_led_update);
 
-static int eeepc_hotk_check(void)
-{
-       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-       int result;
+       eeepc->tpd_led.name = "eeepc::touchpad";
+       eeepc->tpd_led.brightness_set = tpd_led_set;
+       eeepc->tpd_led.max_brightness = 1;
 
-       result = acpi_bus_get_status(ehotk->device);
-       if (result)
-               return result;
-       if (ehotk->device->status.present) {
-               if (write_acpi_int(ehotk->handle, "INIT", ehotk->init_flag,
-                                   &buffer)) {
-                       pr_err("Hotkey initialization failed\n");
-                       return -ENODEV;
-               } else {
-                       pr_notice("Hotkey init flags 0x%x\n", ehotk->init_flag);
-               }
-               /* get control methods supported */
-               if (read_acpi_int(ehotk->handle, "CMSG"
-                                  , &ehotk->cm_supported)) {
-                       pr_err("Get control methods supported failed\n");
-                       return -ENODEV;
-               } else {
-                       cmsg_quirks();
-                       pr_info("Get control methods supported: 0x%x\n",
-                               ehotk->cm_supported);
-               }
-       } else {
-               pr_err("Hotkey device not present, aborting\n");
-               return -EINVAL;
+       rv = led_classdev_register(&eeepc->platform_device->dev,
+                                  &eeepc->tpd_led);
+       if (rv) {
+               destroy_workqueue(eeepc->led_workqueue);
+               return rv;
        }
+
        return 0;
 }
 
-static int notify_brn(void)
+static void eeepc_led_exit(struct eeepc_laptop *eeepc)
 {
-       /* returns the *previous* brightness, or -1 */
-       struct backlight_device *bd = eeepc_backlight_device;
-       if (bd) {
-               int old = bd->props.brightness;
-               backlight_force_update(bd, BACKLIGHT_UPDATE_HOTKEY);
-               return old;
-       }
-       return -1;
+       if (eeepc->tpd_led.dev)
+               led_classdev_unregister(&eeepc->tpd_led);
+       if (eeepc->led_workqueue)
+               destroy_workqueue(eeepc->led_workqueue);
 }
 
-static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
-                                   u8 *value)
-{
-       int val = get_acpi(CM_ASL_WLAN);
-
-       if (val == 1 || val == 0)
-               *value = val;
-       else
-               return -EINVAL;
 
-       return 0;
+/*
+ * PCI hotplug (for wlan rfkill)
+ */
+static bool eeepc_wlan_rfkill_blocked(struct eeepc_laptop *eeepc)
+{
+       if (get_acpi(eeepc, CM_ASL_WLAN) == 1)
+               return false;
+       return true;
 }
 
-static void eeepc_rfkill_hotplug(void)
+static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc)
 {
        struct pci_dev *dev;
        struct pci_bus *bus;
-       bool blocked = eeepc_wlan_rfkill_blocked();
+       bool blocked = eeepc_wlan_rfkill_blocked(eeepc);
 
-       if (ehotk->wlan_rfkill)
-               rfkill_set_sw_state(ehotk->wlan_rfkill, blocked);
+       if (eeepc->wlan_rfkill)
+               rfkill_set_sw_state(eeepc->wlan_rfkill, blocked);
 
-       mutex_lock(&ehotk->hotplug_lock);
+       mutex_lock(&eeepc->hotplug_lock);
 
-       if (ehotk->hotplug_slot) {
+       if (eeepc->hotplug_slot) {
                bus = pci_find_bus(0, 1);
                if (!bus) {
                        pr_warning("Unable to find PCI bus 1?\n");
@@ -685,69 +565,23 @@ static void eeepc_rfkill_hotplug(void)
        }
 
 out_unlock:
-       mutex_unlock(&ehotk->hotplug_lock);
+       mutex_unlock(&eeepc->hotplug_lock);
 }
 
 static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
 {
+       struct eeepc_laptop *eeepc = data;
+
        if (event != ACPI_NOTIFY_BUS_CHECK)
                return;
 
-       eeepc_rfkill_hotplug();
-}
-
-static void eeepc_hotk_notify(struct acpi_device *device, u32 event)
-{
-       static struct key_entry *key;
-       u16 count;
-       int brn = -ENODEV;
-
-       if (!ehotk)
-               return;
-       if (event > ACPI_MAX_SYS_NOTIFY)
-               return;
-       if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
-               brn = notify_brn();
-       count = ehotk->event_count[event % 128]++;
-       acpi_bus_generate_proc_event(ehotk->device, event, count);
-       acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class,
-                                       dev_name(&ehotk->device->dev), event,
-                                       count);
-       if (ehotk->inputdev) {
-               if (brn != -ENODEV) {
-                       /* brightness-change events need special
-                        * handling for conversion to key events
-                        */
-                       if (brn < 0)
-                               brn = event;
-                       else
-                               brn += NOTIFY_BRN_MIN;
-                       if (event < brn)
-                               event = NOTIFY_BRN_MIN; /* brightness down */
-                       else if (event > brn)
-                               event = NOTIFY_BRN_MIN + 2; /* ... up */
-                       else
-                               event = NOTIFY_BRN_MIN + 1; /* ... unchanged */
-               }
-               key = eepc_get_entry_by_scancode(event);
-               if (key) {
-                       switch (key->type) {
-                       case KE_KEY:
-                               input_report_key(ehotk->inputdev, key->keycode,
-                                                1);
-                               input_sync(ehotk->inputdev);
-                               input_report_key(ehotk->inputdev, key->keycode,
-                                                0);
-                               input_sync(ehotk->inputdev);
-                               break;
-                       }
-               }
-       }
+       eeepc_rfkill_hotplug(eeepc);
 }
 
-static int eeepc_register_rfkill_notifier(char *node)
+static int eeepc_register_rfkill_notifier(struct eeepc_laptop *eeepc,
+                                         char *node)
 {
-       acpi_status status = AE_OK;
+       acpi_status status;
        acpi_handle handle;
 
        status = acpi_get_handle(NULL, node, &handle);
@@ -756,7 +590,7 @@ static int eeepc_register_rfkill_notifier(char *node)
                status = acpi_install_notify_handler(handle,
                                                     ACPI_SYSTEM_NOTIFY,
                                                     eeepc_rfkill_notify,
-                                                    NULL);
+                                                    eeepc);
                if (ACPI_FAILURE(status))
                        pr_warning("Failed to register notify on %s\n", node);
        } else
@@ -765,7 +599,8 @@ static int eeepc_register_rfkill_notifier(char *node)
        return 0;
 }
 
-static void eeepc_unregister_rfkill_notifier(char *node)
+static void eeepc_unregister_rfkill_notifier(struct eeepc_laptop *eeepc,
+                                            char *node)
 {
        acpi_status status = AE_OK;
        acpi_handle handle;
@@ -782,13 +617,33 @@ static void eeepc_unregister_rfkill_notifier(char *node)
        }
 }
 
+static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
+                                   u8 *value)
+{
+       struct eeepc_laptop *eeepc = hotplug_slot->private;
+       int val = get_acpi(eeepc, CM_ASL_WLAN);
+
+       if (val == 1 || val == 0)
+               *value = val;
+       else
+               return -EINVAL;
+
+       return 0;
+}
+
 static void eeepc_cleanup_pci_hotplug(struct hotplug_slot *hotplug_slot)
 {
        kfree(hotplug_slot->info);
        kfree(hotplug_slot);
 }
 
-static int eeepc_setup_pci_hotplug(void)
+static struct hotplug_slot_ops eeepc_hotplug_slot_ops = {
+       .owner = THIS_MODULE,
+       .get_adapter_status = eeepc_get_adapter_status,
+       .get_power_status = eeepc_get_adapter_status,
+};
+
+static int eeepc_setup_pci_hotplug(struct eeepc_laptop *eeepc)
 {
        int ret = -ENOMEM;
        struct pci_bus *bus = pci_find_bus(0, 1);
@@ -798,22 +653,22 @@ static int eeepc_setup_pci_hotplug(void)
                return -ENODEV;
        }
 
-       ehotk->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
-       if (!ehotk->hotplug_slot)
+       eeepc->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
+       if (!eeepc->hotplug_slot)
                goto error_slot;
 
-       ehotk->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
+       eeepc->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
                                            GFP_KERNEL);
-       if (!ehotk->hotplug_slot->info)
+       if (!eeepc->hotplug_slot->info)
                goto error_info;
 
-       ehotk->hotplug_slot->private = ehotk;
-       ehotk->hotplug_slot->release = &eeepc_cleanup_pci_hotplug;
-       ehotk->hotplug_slot->ops = &eeepc_hotplug_slot_ops;
-       eeepc_get_adapter_status(ehotk->hotplug_slot,
-                                &ehotk->hotplug_slot->info->adapter_status);
+       eeepc->hotplug_slot->private = eeepc;
+       eeepc->hotplug_slot->release = &eeepc_cleanup_pci_hotplug;
+       eeepc->hotplug_slot->ops = &eeepc_hotplug_slot_ops;
+       eeepc_get_adapter_status(eeepc->hotplug_slot,
+                                &eeepc->hotplug_slot->info->adapter_status);
 
-       ret = pci_hp_register(ehotk->hotplug_slot, bus, 0, "eeepc-wifi");
+       ret = pci_hp_register(eeepc->hotplug_slot, bus, 0, "eeepc-wifi");
        if (ret) {
                pr_err("Unable to register hotplug slot - %d\n", ret);
                goto error_register;
@@ -822,97 +677,262 @@ static int eeepc_setup_pci_hotplug(void)
        return 0;
 
 error_register:
-       kfree(ehotk->hotplug_slot->info);
+       kfree(eeepc->hotplug_slot->info);
 error_info:
-       kfree(ehotk->hotplug_slot);
-       ehotk->hotplug_slot = NULL;
+       kfree(eeepc->hotplug_slot);
+       eeepc->hotplug_slot = NULL;
 error_slot:
        return ret;
 }
 
-static int eeepc_hotk_thaw(struct device *device)
+/*
+ * Rfkill devices
+ */
+static int eeepc_rfkill_set(void *data, bool blocked)
 {
-       if (ehotk->wlan_rfkill) {
-               bool wlan;
-
-               /*
-                * Work around bios bug - acpi _PTS turns off the wireless led
-                * during suspend.  Normally it restores it on resume, but
-                * we should kick it ourselves in case hibernation is aborted.
-                */
-               wlan = get_acpi(CM_ASL_WLAN);
-               set_acpi(CM_ASL_WLAN, wlan);
-       }
+       acpi_handle handle = data;
 
-       return 0;
+       return write_acpi_int(handle, NULL, !blocked);
 }
 
-static int eeepc_hotk_restore(struct device *device)
-{
-       /* Refresh both wlan rfkill state and pci hotplug */
-       if (ehotk->wlan_rfkill)
-               eeepc_rfkill_hotplug();
-
-       if (ehotk->bluetooth_rfkill)
-               rfkill_set_sw_state(ehotk->bluetooth_rfkill,
-                                   get_acpi(CM_ASL_BLUETOOTH) != 1);
-       if (ehotk->wwan3g_rfkill)
-               rfkill_set_sw_state(ehotk->wwan3g_rfkill,
-                                   get_acpi(CM_ASL_3G) != 1);
-       if (ehotk->wimax_rfkill)
-               rfkill_set_sw_state(ehotk->wimax_rfkill,
-                                   get_acpi(CM_ASL_WIMAX) != 1);
-
+static const struct rfkill_ops eeepc_rfkill_ops = {
+       .set_block = eeepc_rfkill_set,
+};
+
+static int eeepc_new_rfkill(struct eeepc_laptop *eeepc,
+                           struct rfkill **rfkill,
+                           const char *name,
+                           enum rfkill_type type, int cm)
+{
+       acpi_handle handle;
+       int result;
+
+       result = acpi_setter_handle(eeepc, cm, &handle);
+       if (result < 0)
+               return result;
+
+       *rfkill = rfkill_alloc(name, &eeepc->platform_device->dev, type,
+                              &eeepc_rfkill_ops, handle);
+
+       if (!*rfkill)
+               return -EINVAL;
+
+       rfkill_init_sw_state(*rfkill, get_acpi(eeepc, cm) != 1);
+       result = rfkill_register(*rfkill);
+       if (result) {
+               rfkill_destroy(*rfkill);
+               *rfkill = NULL;
+               return result;
+       }
        return 0;
 }
 
+static void eeepc_rfkill_exit(struct eeepc_laptop *eeepc)
+{
+       eeepc_unregister_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5");
+       eeepc_unregister_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6");
+       eeepc_unregister_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7");
+       if (eeepc->wlan_rfkill) {
+               rfkill_unregister(eeepc->wlan_rfkill);
+               rfkill_destroy(eeepc->wlan_rfkill);
+               eeepc->wlan_rfkill = NULL;
+       }
+       /*
+        * Refresh pci hotplug in case the rfkill state was changed after
+        * eeepc_unregister_rfkill_notifier()
+        */
+       eeepc_rfkill_hotplug(eeepc);
+       if (eeepc->hotplug_slot)
+               pci_hp_deregister(eeepc->hotplug_slot);
+
+       if (eeepc->bluetooth_rfkill) {
+               rfkill_unregister(eeepc->bluetooth_rfkill);
+               rfkill_destroy(eeepc->bluetooth_rfkill);
+               eeepc->bluetooth_rfkill = NULL;
+       }
+       if (eeepc->wwan3g_rfkill) {
+               rfkill_unregister(eeepc->wwan3g_rfkill);
+               rfkill_destroy(eeepc->wwan3g_rfkill);
+               eeepc->wwan3g_rfkill = NULL;
+       }
+       if (eeepc->wimax_rfkill) {
+               rfkill_unregister(eeepc->wimax_rfkill);
+               rfkill_destroy(eeepc->wimax_rfkill);
+               eeepc->wimax_rfkill = NULL;
+       }
+}
+
+static int eeepc_rfkill_init(struct eeepc_laptop *eeepc)
+{
+       int result = 0;
+
+       mutex_init(&eeepc->hotplug_lock);
+
+       result = eeepc_new_rfkill(eeepc, &eeepc->wlan_rfkill,
+                                 "eeepc-wlan", RFKILL_TYPE_WLAN,
+                                 CM_ASL_WLAN);
+
+       if (result && result != -ENODEV)
+               goto exit;
+
+       result = eeepc_new_rfkill(eeepc, &eeepc->bluetooth_rfkill,
+                                 "eeepc-bluetooth", RFKILL_TYPE_BLUETOOTH,
+                                 CM_ASL_BLUETOOTH);
+
+       if (result && result != -ENODEV)
+               goto exit;
+
+       result = eeepc_new_rfkill(eeepc, &eeepc->wwan3g_rfkill,
+                                 "eeepc-wwan3g", RFKILL_TYPE_WWAN,
+                                 CM_ASL_3G);
+
+       if (result && result != -ENODEV)
+               goto exit;
+
+       result = eeepc_new_rfkill(eeepc, &eeepc->wimax_rfkill,
+                                 "eeepc-wimax", RFKILL_TYPE_WIMAX,
+                                 CM_ASL_WIMAX);
+
+       if (result && result != -ENODEV)
+               goto exit;
+
+       result = eeepc_setup_pci_hotplug(eeepc);
+       /*
+        * If we get -EBUSY then something else is handling the PCI hotplug -
+        * don't fail in this case
+        */
+       if (result == -EBUSY)
+               result = 0;
+
+       eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P5");
+       eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P6");
+       eeepc_register_rfkill_notifier(eeepc, "\\_SB.PCI0.P0P7");
+       /*
+        * Refresh pci hotplug in case the rfkill state was changed during
+        * setup.
+        */
+       eeepc_rfkill_hotplug(eeepc);
+
+exit:
+       if (result && result != -ENODEV)
+               eeepc_rfkill_exit(eeepc);
+       return result;
+}
+
 /*
- * Hwmon
+ * Platform driver - hibernate/resume callbacks
  */
+static int eeepc_hotk_thaw(struct device *device)
+{
+       struct eeepc_laptop *eeepc = dev_get_drvdata(device);
+
+       if (eeepc->wlan_rfkill) {
+               bool wlan;
+
+               /*
+                * Work around bios bug - acpi _PTS turns off the wireless led
+                * during suspend.  Normally it restores it on resume, but
+                * we should kick it ourselves in case hibernation is aborted.
+                */
+               wlan = get_acpi(eeepc, CM_ASL_WLAN);
+               set_acpi(eeepc, CM_ASL_WLAN, wlan);
+       }
+
+       return 0;
+}
+
+static int eeepc_hotk_restore(struct device *device)
+{
+       struct eeepc_laptop *eeepc = dev_get_drvdata(device);
+
+       /* Refresh both wlan rfkill state and pci hotplug */
+       if (eeepc->wlan_rfkill)
+               eeepc_rfkill_hotplug(eeepc);
+
+       if (eeepc->bluetooth_rfkill)
+               rfkill_set_sw_state(eeepc->bluetooth_rfkill,
+                                   get_acpi(eeepc, CM_ASL_BLUETOOTH) != 1);
+       if (eeepc->wwan3g_rfkill)
+               rfkill_set_sw_state(eeepc->wwan3g_rfkill,
+                                   get_acpi(eeepc, CM_ASL_3G) != 1);
+       if (eeepc->wimax_rfkill)
+               rfkill_set_sw_state(eeepc->wimax_rfkill,
+                                   get_acpi(eeepc, CM_ASL_WIMAX) != 1);
+
+       return 0;
+}
+
+static const struct dev_pm_ops eeepc_pm_ops = {
+       .thaw = eeepc_hotk_thaw,
+       .restore = eeepc_hotk_restore,
+};
+
+static struct platform_driver platform_driver = {
+       .driver = {
+               .name = EEEPC_LAPTOP_FILE,
+               .owner = THIS_MODULE,
+               .pm = &eeepc_pm_ops,
+       }
+};
+
+/*
+ * Hwmon device
+ */
+
+#define EEEPC_EC_SC00      0x61
+#define EEEPC_EC_FAN_PWM   (EEEPC_EC_SC00 + 2) /* Fan PWM duty cycle (%) */
+#define EEEPC_EC_FAN_HRPM  (EEEPC_EC_SC00 + 5) /* High byte, fan speed (RPM) */
+#define EEEPC_EC_FAN_LRPM  (EEEPC_EC_SC00 + 6) /* Low byte, fan speed (RPM) */
+
+#define EEEPC_EC_SFB0      0xD0
+#define EEEPC_EC_FAN_CTRL  (EEEPC_EC_SFB0 + 3) /* Byte containing SF25  */
+
 static int eeepc_get_fan_pwm(void)
 {
-       int value = 0;
+       u8 value = 0;
 
-       read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value);
-       value = value * 255 / 100;
-       return (value);
+       ec_read(EEEPC_EC_FAN_PWM, &value);
+       return value * 255 / 100;
 }
 
 static void eeepc_set_fan_pwm(int value)
 {
        value = SENSORS_LIMIT(value, 0, 255);
        value = value * 100 / 255;
-       ec_write(EEEPC_EC_SC02, value);
+       ec_write(EEEPC_EC_FAN_PWM, value);
 }
 
 static int eeepc_get_fan_rpm(void)
 {
-       int high = 0;
-       int low = 0;
+       u8 high = 0;
+       u8 low = 0;
 
-       read_acpi_int(NULL, EEEPC_EC_FAN_HRPM, &high);
-       read_acpi_int(NULL, EEEPC_EC_FAN_LRPM, &low);
-       return (high << 8 | low);
+       ec_read(EEEPC_EC_FAN_HRPM, &high);
+       ec_read(EEEPC_EC_FAN_LRPM, &low);
+       return high << 8 | low;
 }
 
 static int eeepc_get_fan_ctrl(void)
 {
-       int value = 0;
+       u8 value = 0;
 
-       read_acpi_int(NULL, EEEPC_EC_FAN_CTRL, &value);
-       return ((value & 0x02 ? 1 : 0));
+       ec_read(EEEPC_EC_FAN_CTRL, &value);
+       if (value & 0x02)
+               return 1; /* manual */
+       else
+               return 2; /* automatic */
 }
 
 static void eeepc_set_fan_ctrl(int manual)
 {
-       int value = 0;
+       u8 value = 0;
 
-       read_acpi_int(NULL, EEEPC_EC_FAN_CTRL, &value);
-       if (manual)
+       ec_read(EEEPC_EC_FAN_CTRL, &value);
+       if (manual == 1)
                value |= 0x02;
        else
                value &= ~0x02;
-       ec_write(EEEPC_EC_SFB3, value);
+       ec_write(EEEPC_EC_FAN_CTRL, value);
 }
 
 static ssize_t store_sys_hwmon(void (*set)(int), const char *buf, size_t count)
@@ -970,348 +990,485 @@ static struct attribute_group hwmon_attribute_group = {
        .attrs = hwmon_attributes
 };
 
-/*
- * exit/init
- */
-static void eeepc_backlight_exit(void)
+static void eeepc_hwmon_exit(struct eeepc_laptop *eeepc)
 {
-       if (eeepc_backlight_device)
-               backlight_device_unregister(eeepc_backlight_device);
-       eeepc_backlight_device = NULL;
+       struct device *hwmon;
+
+       hwmon = eeepc->hwmon_device;
+       if (!hwmon)
+               return;
+       sysfs_remove_group(&hwmon->kobj,
+                          &hwmon_attribute_group);
+       hwmon_device_unregister(hwmon);
+       eeepc->hwmon_device = NULL;
 }
 
-static void eeepc_rfkill_exit(void)
+static int eeepc_hwmon_init(struct eeepc_laptop *eeepc)
 {
-       eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P5");
-       eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P6");
-       eeepc_unregister_rfkill_notifier("\\_SB.PCI0.P0P7");
-       if (ehotk->wlan_rfkill) {
-               rfkill_unregister(ehotk->wlan_rfkill);
-               rfkill_destroy(ehotk->wlan_rfkill);
-               ehotk->wlan_rfkill = NULL;
-       }
-       /*
-        * Refresh pci hotplug in case the rfkill state was changed after
-        * eeepc_unregister_rfkill_notifier()
-        */
-       eeepc_rfkill_hotplug();
-       if (ehotk->hotplug_slot)
-               pci_hp_deregister(ehotk->hotplug_slot);
-
-       if (ehotk->bluetooth_rfkill) {
-               rfkill_unregister(ehotk->bluetooth_rfkill);
-               rfkill_destroy(ehotk->bluetooth_rfkill);
-               ehotk->bluetooth_rfkill = NULL;
-       }
-       if (ehotk->wwan3g_rfkill) {
-               rfkill_unregister(ehotk->wwan3g_rfkill);
-               rfkill_destroy(ehotk->wwan3g_rfkill);
-               ehotk->wwan3g_rfkill = NULL;
-       }
-       if (ehotk->wimax_rfkill) {
-               rfkill_unregister(ehotk->wimax_rfkill);
-               rfkill_destroy(ehotk->wimax_rfkill);
-               ehotk->wimax_rfkill = NULL;
+       struct device *hwmon;
+       int result;
+
+       hwmon = hwmon_device_register(&eeepc->platform_device->dev);
+       if (IS_ERR(hwmon)) {
+               pr_err("Could not register eeepc hwmon device\n");
+               eeepc->hwmon_device = NULL;
+               return PTR_ERR(hwmon);
        }
+       eeepc->hwmon_device = hwmon;
+       result = sysfs_create_group(&hwmon->kobj,
+                                   &hwmon_attribute_group);
+       if (result)
+               eeepc_hwmon_exit(eeepc);
+       return result;
 }
 
-static void eeepc_input_exit(void)
+/*
+ * Backlight device
+ */
+static int read_brightness(struct backlight_device *bd)
 {
-       if (ehotk->inputdev)
-               input_unregister_device(ehotk->inputdev);
+       struct eeepc_laptop *eeepc = bl_get_data(bd);
+
+       return get_acpi(eeepc, CM_ASL_PANELBRIGHT);
 }
 
-static void eeepc_hwmon_exit(void)
+static int set_brightness(struct backlight_device *bd, int value)
 {
-       struct device *hwmon;
+       struct eeepc_laptop *eeepc = bl_get_data(bd);
 
-       hwmon = eeepc_hwmon_device;
-       if (!hwmon)
-               return ;
-       sysfs_remove_group(&hwmon->kobj,
-                          &hwmon_attribute_group);
-       hwmon_device_unregister(hwmon);
-       eeepc_hwmon_device = NULL;
+       return set_acpi(eeepc, CM_ASL_PANELBRIGHT, value);
 }
 
-static int eeepc_new_rfkill(struct rfkill **rfkill,
-                           const char *name, struct device *dev,
-                           enum rfkill_type type, int cm)
+static int update_bl_status(struct backlight_device *bd)
 {
-       int result;
+       return set_brightness(bd, bd->props.brightness);
+}
 
-       result = get_acpi(cm);
-       if (result < 0)
-               return result;
+static struct backlight_ops eeepcbl_ops = {
+       .get_brightness = read_brightness,
+       .update_status = update_bl_status,
+};
 
-       *rfkill = rfkill_alloc(name, dev, type,
-                              &eeepc_rfkill_ops, (void *)(unsigned long)cm);
+static int eeepc_backlight_notify(struct eeepc_laptop *eeepc)
+{
+       struct backlight_device *bd = eeepc->backlight_device;
+       int old = bd->props.brightness;
 
-       if (!*rfkill)
-               return -EINVAL;
+       backlight_force_update(bd, BACKLIGHT_UPDATE_HOTKEY);
 
-       rfkill_init_sw_state(*rfkill, get_acpi(cm) != 1);
-       result = rfkill_register(*rfkill);
-       if (result) {
-               rfkill_destroy(*rfkill);
-               *rfkill = NULL;
-               return result;
-       }
-       return 0;
+       return old;
 }
 
-
-static int eeepc_rfkill_init(struct device *dev)
+static int eeepc_backlight_init(struct eeepc_laptop *eeepc)
 {
-       int result = 0;
-
-       mutex_init(&ehotk->hotplug_lock);
+       struct backlight_device *bd;
 
-       result = eeepc_new_rfkill(&ehotk->wlan_rfkill,
-                                 "eeepc-wlan", dev,
-                                 RFKILL_TYPE_WLAN, CM_ASL_WLAN);
+       bd = backlight_device_register(EEEPC_LAPTOP_FILE,
+                                      &eeepc->platform_device->dev,
+                                      eeepc, &eeepcbl_ops);
+       if (IS_ERR(bd)) {
+               pr_err("Could not register eeepc backlight device\n");
+               eeepc->backlight_device = NULL;
+               return PTR_ERR(bd);
+       }
+       eeepc->backlight_device = bd;
+       bd->props.max_brightness = 15;
+       bd->props.brightness = read_brightness(bd);
+       bd->props.power = FB_BLANK_UNBLANK;
+       backlight_update_status(bd);
+       return 0;
+}
 
-       if (result && result != -ENODEV)
-               goto exit;
+static void eeepc_backlight_exit(struct eeepc_laptop *eeepc)
+{
+       if (eeepc->backlight_device)
+               backlight_device_unregister(eeepc->backlight_device);
+       eeepc->backlight_device = NULL;
+}
 
-       result = eeepc_new_rfkill(&ehotk->bluetooth_rfkill,
-                                 "eeepc-bluetooth", dev,
-                                 RFKILL_TYPE_BLUETOOTH, CM_ASL_BLUETOOTH);
 
-       if (result && result != -ENODEV)
-               goto exit;
+/*
+ * Input device (i.e. hotkeys)
+ */
+static struct key_entry *eeepc_get_entry_by_scancode(
+       struct eeepc_laptop *eeepc,
+       int code)
+{
+       struct key_entry *key;
 
-       result = eeepc_new_rfkill(&ehotk->wwan3g_rfkill,
-                                 "eeepc-wwan3g", dev,
-                                 RFKILL_TYPE_WWAN, CM_ASL_3G);
+       for (key = eeepc->keymap; key->type != KE_END; key++)
+               if (code == key->code)
+                       return key;
 
-       if (result && result != -ENODEV)
-               goto exit;
+       return NULL;
+}
 
-       result = eeepc_new_rfkill(&ehotk->wimax_rfkill,
-                                 "eeepc-wimax", dev,
-                                 RFKILL_TYPE_WIMAX, CM_ASL_WIMAX);
+static void eeepc_input_notify(struct eeepc_laptop *eeepc, int event)
+{
+       static struct key_entry *key;
 
-       if (result && result != -ENODEV)
-               goto exit;
+       key = eeepc_get_entry_by_scancode(eeepc, event);
+       if (key) {
+               switch (key->type) {
+               case KE_KEY:
+                       input_report_key(eeepc->inputdev, key->keycode,
+                                               1);
+                       input_sync(eeepc->inputdev);
+                       input_report_key(eeepc->inputdev, key->keycode,
+                                               0);
+                       input_sync(eeepc->inputdev);
+                       break;
+               }
+       }
+}
 
-       result = eeepc_setup_pci_hotplug();
-       /*
-        * If we get -EBUSY then something else is handling the PCI hotplug -
-        * don't fail in this case
-        */
-       if (result == -EBUSY)
-               result = 0;
+static struct key_entry *eeepc_get_entry_by_keycode(
+       struct eeepc_laptop *eeepc, int code)
+{
+       struct key_entry *key;
 
-       eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P5");
-       eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6");
-       eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7");
-       /*
-        * Refresh pci hotplug in case the rfkill state was changed during
-        * setup.
-        */
-       eeepc_rfkill_hotplug();
+       for (key = eeepc->keymap; key->type != KE_END; key++)
+               if (code == key->keycode && key->type == KE_KEY)
+                       return key;
 
-exit:
-       if (result && result != -ENODEV)
-               eeepc_rfkill_exit();
-       return result;
+       return NULL;
 }
 
-static int eeepc_backlight_init(struct device *dev)
+static int eeepc_getkeycode(struct input_dev *dev, int scancode, int *keycode)
 {
-       struct backlight_device *bd;
+       struct eeepc_laptop *eeepc = input_get_drvdata(dev);
+       struct key_entry *key = eeepc_get_entry_by_scancode(eeepc, scancode);
 
-       bd = backlight_device_register(EEEPC_HOTK_FILE, dev,
-                                      NULL, &eeepcbl_ops);
-       if (IS_ERR(bd)) {
-               pr_err("Could not register eeepc backlight device\n");
-               eeepc_backlight_device = NULL;
-               return PTR_ERR(bd);
+       if (key && key->type == KE_KEY) {
+               *keycode = key->keycode;
+               return 0;
        }
-       eeepc_backlight_device = bd;
-       bd->props.max_brightness = 15;
-       bd->props.brightness = read_brightness(NULL);
-       bd->props.power = FB_BLANK_UNBLANK;
-       backlight_update_status(bd);
-       return 0;
+
+       return -EINVAL;
 }
 
-static int eeepc_hwmon_init(struct device *dev)
+static int eeepc_setkeycode(struct input_dev *dev, int scancode, int keycode)
 {
-       struct device *hwmon;
-       int result;
+       struct eeepc_laptop *eeepc = input_get_drvdata(dev);
+       struct key_entry *key;
+       int old_keycode;
 
-       hwmon = hwmon_device_register(dev);
-       if (IS_ERR(hwmon)) {
-               pr_err("Could not register eeepc hwmon device\n");
-               eeepc_hwmon_device = NULL;
-               return PTR_ERR(hwmon);
+       if (keycode < 0 || keycode > KEY_MAX)
+               return -EINVAL;
+
+       key = eeepc_get_entry_by_scancode(eeepc, scancode);
+       if (key && key->type == KE_KEY) {
+               old_keycode = key->keycode;
+               key->keycode = keycode;
+               set_bit(keycode, dev->keybit);
+               if (!eeepc_get_entry_by_keycode(eeepc, old_keycode))
+                       clear_bit(old_keycode, dev->keybit);
+               return 0;
        }
-       eeepc_hwmon_device = hwmon;
-       result = sysfs_create_group(&hwmon->kobj,
-                                   &hwmon_attribute_group);
-       if (result)
-               eeepc_hwmon_exit();
-       return result;
+
+       return -EINVAL;
 }
 
-static int eeepc_input_init(struct device *dev)
+static int eeepc_input_init(struct eeepc_laptop *eeepc)
 {
        const struct key_entry *key;
        int result;
 
-       ehotk->inputdev = input_allocate_device();
-       if (!ehotk->inputdev) {
+       eeepc->inputdev = input_allocate_device();
+       if (!eeepc->inputdev) {
                pr_info("Unable to allocate input device\n");
                return -ENOMEM;
        }
-       ehotk->inputdev->name = "Asus EeePC extra buttons";
-       ehotk->inputdev->dev.parent = dev;
-       ehotk->inputdev->phys = EEEPC_HOTK_FILE "/input0";
-       ehotk->inputdev->id.bustype = BUS_HOST;
-       ehotk->inputdev->getkeycode = eeepc_getkeycode;
-       ehotk->inputdev->setkeycode = eeepc_setkeycode;
-
+       eeepc->inputdev->name = "Asus EeePC extra buttons";
+       eeepc->inputdev->dev.parent = &eeepc->platform_device->dev;
+       eeepc->inputdev->phys = EEEPC_LAPTOP_FILE "/input0";
+       eeepc->inputdev->id.bustype = BUS_HOST;
+       eeepc->inputdev->getkeycode = eeepc_getkeycode;
+       eeepc->inputdev->setkeycode = eeepc_setkeycode;
+       input_set_drvdata(eeepc->inputdev, eeepc);
+
+       eeepc->keymap = kmemdup(eeepc_keymap, sizeof(eeepc_keymap),
+                               GFP_KERNEL);
        for (key = eeepc_keymap; key->type != KE_END; key++) {
                switch (key->type) {
                case KE_KEY:
-                       set_bit(EV_KEY, ehotk->inputdev->evbit);
-                       set_bit(key->keycode, ehotk->inputdev->keybit);
+                       set_bit(EV_KEY, eeepc->inputdev->evbit);
+                       set_bit(key->keycode, eeepc->inputdev->keybit);
                        break;
                }
        }
-       result = input_register_device(ehotk->inputdev);
+       result = input_register_device(eeepc->inputdev);
        if (result) {
                pr_info("Unable to register input device\n");
-               input_free_device(ehotk->inputdev);
+               input_free_device(eeepc->inputdev);
                return result;
        }
        return 0;
 }
 
-static int __devinit eeepc_hotk_add(struct acpi_device *device)
+static void eeepc_input_exit(struct eeepc_laptop *eeepc)
 {
-       struct device *dev;
+       if (eeepc->inputdev) {
+               input_unregister_device(eeepc->inputdev);
+               kfree(eeepc->keymap);
+       }
+}
+
+/*
+ * ACPI driver
+ */
+static void eeepc_acpi_notify(struct acpi_device *device, u32 event)
+{
+       struct eeepc_laptop *eeepc = acpi_driver_data(device);
+       u16 count;
+
+       if (event > ACPI_MAX_SYS_NOTIFY)
+               return;
+       count = eeepc->event_count[event % 128]++;
+       acpi_bus_generate_proc_event(device, event, count);
+       acpi_bus_generate_netlink_event(device->pnp.device_class,
+                                       dev_name(&device->dev), event,
+                                       count);
+
+       /* Brightness events are special */
+       if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) {
+
+               /* Ignore them completely if the acpi video driver is used */
+               if (eeepc->backlight_device != NULL) {
+                       int old_brightness, new_brightness;
+
+                       /* Update the backlight device. */
+                       old_brightness = eeepc_backlight_notify(eeepc);
+
+                       /* Convert event to keypress (obsolescent hack) */
+                       new_brightness = event - NOTIFY_BRN_MIN;
+
+                       if (new_brightness < old_brightness) {
+                               event = NOTIFY_BRN_MIN; /* brightness down */
+                       } else if (new_brightness > old_brightness) {
+                               event = NOTIFY_BRN_MAX; /* brightness up */
+                       } else {
+                               /*
+                               * no change in brightness - already at min/max,
+                               * event will be desired value (or else ignored)
+                               */
+                       }
+                       eeepc_input_notify(eeepc, event);
+               }
+       } else {
+               /* Everything else is a bona-fide keypress event */
+               eeepc_input_notify(eeepc, event);
+       }
+}
+
+static void cmsg_quirk(struct eeepc_laptop *eeepc, int cm, const char *name)
+{
+       int dummy;
+
+       /* Some BIOSes do not report cm although it is avaliable.
+          Check if cm_getv[cm] works and, if yes, assume cm should be set. */
+       if (!(eeepc->cm_supported & (1 << cm))
+           && !read_acpi_int(eeepc->handle, cm_getv[cm], &dummy)) {
+               pr_info("%s (%x) not reported by BIOS,"
+                       " enabling anyway\n", name, 1 << cm);
+               eeepc->cm_supported |= 1 << cm;
+       }
+}
+
+static void cmsg_quirks(struct eeepc_laptop *eeepc)
+{
+       cmsg_quirk(eeepc, CM_ASL_LID, "LID");
+       cmsg_quirk(eeepc, CM_ASL_TYPE, "TYPE");
+       cmsg_quirk(eeepc, CM_ASL_PANELPOWER, "PANELPOWER");
+       cmsg_quirk(eeepc, CM_ASL_TPD, "TPD");
+}
+
+static int eeepc_acpi_init(struct eeepc_laptop *eeepc,
+                          struct acpi_device *device)
+{
+       unsigned int init_flags;
        int result;
 
-       if (!device)
-               return -EINVAL;
-       pr_notice(EEEPC_HOTK_NAME "\n");
-       ehotk = kzalloc(sizeof(struct eeepc_hotk), GFP_KERNEL);
-       if (!ehotk)
-               return -ENOMEM;
-       ehotk->init_flag = DISABLE_ASL_WLAN | DISABLE_ASL_DISPLAYSWITCH;
-       ehotk->handle = device->handle;
-       strcpy(acpi_device_name(device), EEEPC_HOTK_DEVICE_NAME);
-       strcpy(acpi_device_class(device), EEEPC_HOTK_CLASS);
-       device->driver_data = ehotk;
-       ehotk->device = device;
-
-       result = eeepc_hotk_check();
+       result = acpi_bus_get_status(device);
        if (result)
-               goto fail_platform_driver;
-       eeepc_enable_camera();
+               return result;
+       if (!device->status.present) {
+               pr_err("Hotkey device not present, aborting\n");
+               return -ENODEV;
+       }
 
-       /* Register platform stuff */
-       result = platform_driver_register(&platform_driver);
-       if (result)
-               goto fail_platform_driver;
-       platform_device = platform_device_alloc(EEEPC_HOTK_FILE, -1);
-       if (!platform_device) {
-               result = -ENOMEM;
-               goto fail_platform_device1;
+       init_flags = DISABLE_ASL_WLAN | DISABLE_ASL_DISPLAYSWITCH;
+       pr_notice("Hotkey init flags 0x%x\n", init_flags);
+
+       if (write_acpi_int(eeepc->handle, "INIT", init_flags)) {
+               pr_err("Hotkey initialization failed\n");
+               return -ENODEV;
        }
-       result = platform_device_add(platform_device);
-       if (result)
-               goto fail_platform_device2;
-       result = sysfs_create_group(&platform_device->dev.kobj,
-                                   &platform_attribute_group);
+
+       /* get control methods supported */
+       if (read_acpi_int(eeepc->handle, "CMSG", &eeepc->cm_supported)) {
+               pr_err("Get control methods supported failed\n");
+               return -ENODEV;
+       }
+       cmsg_quirks(eeepc);
+       pr_info("Get control methods supported: 0x%x\n", eeepc->cm_supported);
+
+       return 0;
+}
+
+static void __devinit eeepc_enable_camera(struct eeepc_laptop *eeepc)
+{
+       /*
+        * If the following call to set_acpi() fails, it's because there's no
+        * camera so we can ignore the error.
+        */
+       if (get_acpi(eeepc, CM_ASL_CAMERA) == 0)
+               set_acpi(eeepc, CM_ASL_CAMERA, 1);
+}
+
+static bool eeepc_device_present;
+
+static int __devinit eeepc_acpi_add(struct acpi_device *device)
+{
+       struct eeepc_laptop *eeepc;
+       int result;
+
+       pr_notice(EEEPC_LAPTOP_NAME "\n");
+       eeepc = kzalloc(sizeof(struct eeepc_laptop), GFP_KERNEL);
+       if (!eeepc)
+               return -ENOMEM;
+       eeepc->handle = device->handle;
+       strcpy(acpi_device_name(device), EEEPC_ACPI_DEVICE_NAME);
+       strcpy(acpi_device_class(device), EEEPC_ACPI_CLASS);
+       device->driver_data = eeepc;
+
+       result = eeepc_acpi_init(eeepc, device);
        if (result)
-               goto fail_sysfs;
+               goto fail_platform;
+       eeepc_enable_camera(eeepc);
 
-       dev = &platform_device->dev;
+       /*
+        * Register the platform device first.  It is used as a parent for the
+        * sub-devices below.
+        *
+        * Note that if there are multiple instances of this ACPI device it
+        * will bail out, because the platform device is registered with a
+        * fixed name.  Of course it doesn't make sense to have more than one,
+        * and machine-specific scripts find the fixed name convenient.  But
+        * It's also good for us to exclude multiple instances because both
+        * our hwmon and our wlan rfkill subdevice use global ACPI objects
+        * (the EC and the wlan PCI slot respectively).
+        */
+       result = eeepc_platform_init(eeepc);
+       if (result)
+               goto fail_platform;
 
        if (!acpi_video_backlight_support()) {
-               result = eeepc_backlight_init(dev);
+               result = eeepc_backlight_init(eeepc);
                if (result)
                        goto fail_backlight;
        } else
-               pr_info("Backlight controlled by ACPI video "
-                       "driver\n");
+               pr_info("Backlight controlled by ACPI video driver\n");
 
-       result = eeepc_input_init(dev);
+       result = eeepc_input_init(eeepc);
        if (result)
                goto fail_input;
 
-       result = eeepc_hwmon_init(dev);
+       result = eeepc_hwmon_init(eeepc);
        if (result)
                goto fail_hwmon;
 
-       result = eeepc_rfkill_init(dev);
+       result = eeepc_led_init(eeepc);
+       if (result)
+               goto fail_led;
+
+       result = eeepc_rfkill_init(eeepc);
        if (result)
                goto fail_rfkill;
 
+       eeepc_device_present = true;
        return 0;
 
 fail_rfkill:
-       eeepc_hwmon_exit();
+       eeepc_led_exit(eeepc);
+fail_led:
+       eeepc_hwmon_exit(eeepc);
 fail_hwmon:
-       eeepc_input_exit();
+       eeepc_input_exit(eeepc);
 fail_input:
-       eeepc_backlight_exit();
+       eeepc_backlight_exit(eeepc);
 fail_backlight:
-       sysfs_remove_group(&platform_device->dev.kobj,
-                          &platform_attribute_group);
-fail_sysfs:
-       platform_device_del(platform_device);
-fail_platform_device2:
-       platform_device_put(platform_device);
-fail_platform_device1:
-       platform_driver_unregister(&platform_driver);
-fail_platform_driver:
-       kfree(ehotk);
+       eeepc_platform_exit(eeepc);
+fail_platform:
+       kfree(eeepc);
 
        return result;
 }
 
-static int eeepc_hotk_remove(struct acpi_device *device, int type)
+static int eeepc_acpi_remove(struct acpi_device *device, int type)
 {
-       if (!device || !acpi_driver_data(device))
-               return -EINVAL;
+       struct eeepc_laptop *eeepc = acpi_driver_data(device);
 
-       eeepc_backlight_exit();
-       eeepc_rfkill_exit();
-       eeepc_input_exit();
-       eeepc_hwmon_exit();
-       sysfs_remove_group(&platform_device->dev.kobj,
-                          &platform_attribute_group);
-       platform_device_unregister(platform_device);
-       platform_driver_unregister(&platform_driver);
+       eeepc_backlight_exit(eeepc);
+       eeepc_rfkill_exit(eeepc);
+       eeepc_input_exit(eeepc);
+       eeepc_hwmon_exit(eeepc);
+       eeepc_led_exit(eeepc);
+       eeepc_platform_exit(eeepc);
 
-       kfree(ehotk);
+       kfree(eeepc);
        return 0;
 }
 
+
+static const struct acpi_device_id eeepc_device_ids[] = {
+       {EEEPC_ACPI_HID, 0},
+       {"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, eeepc_device_ids);
+
+static struct acpi_driver eeepc_acpi_driver = {
+       .name = EEEPC_LAPTOP_NAME,
+       .class = EEEPC_ACPI_CLASS,
+       .owner = THIS_MODULE,
+       .ids = eeepc_device_ids,
+       .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
+       .ops = {
+               .add = eeepc_acpi_add,
+               .remove = eeepc_acpi_remove,
+               .notify = eeepc_acpi_notify,
+       },
+};
+
+
 static int __init eeepc_laptop_init(void)
 {
        int result;
 
-       if (acpi_disabled)
-               return -ENODEV;
-       result = acpi_bus_register_driver(&eeepc_hotk_driver);
+       result = platform_driver_register(&platform_driver);
        if (result < 0)
                return result;
-       if (!ehotk) {
-               acpi_bus_unregister_driver(&eeepc_hotk_driver);
-               return -ENODEV;
+
+       result = acpi_bus_register_driver(&eeepc_acpi_driver);
+       if (result < 0)
+               goto fail_acpi_driver;
+       if (!eeepc_device_present) {
+               result = -ENODEV;
+               goto fail_no_device;
        }
        return 0;
+
+fail_no_device:
+       acpi_bus_unregister_driver(&eeepc_acpi_driver);
+fail_acpi_driver:
+       platform_driver_unregister(&platform_driver);
+       return result;
 }
 
 static void __exit eeepc_laptop_exit(void)
 {
-       acpi_bus_unregister_driver(&eeepc_hotk_driver);
+       acpi_bus_unregister_driver(&eeepc_acpi_driver);
+       platform_driver_unregister(&platform_driver);
 }
 
 module_init(eeepc_laptop_init);
index bcd4ba8be7db4781699d7d862d81d2372160e368..5f3320d468f61bd6aa37d7606e86570508910b81 100644 (file)
@@ -164,7 +164,7 @@ struct fujitsu_hotkey_t {
        struct input_dev *input;
        char phys[32];
        struct platform_device *pf_device;
-       struct kfifo *fifo;
+       struct kfifo fifo;
        spinlock_t fifo_lock;
        int rfkill_supported;
        int rfkill_state;
@@ -376,8 +376,8 @@ static int get_lcd_level(void)
 
        status =
            acpi_evaluate_integer(fujitsu->acpi_handle, "GBLL", NULL, &state);
-       if (status < 0)
-               return status;
+       if (ACPI_FAILURE(status))
+               return 0;
 
        fujitsu->brightness_level = state & 0x0fffffff;
 
@@ -398,8 +398,8 @@ static int get_max_brightness(void)
 
        status =
            acpi_evaluate_integer(fujitsu->acpi_handle, "RBLL", NULL, &state);
-       if (status < 0)
-               return status;
+       if (ACPI_FAILURE(status))
+               return -1;
 
        fujitsu->max_brightness = state;
 
@@ -824,12 +824,10 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
 
        /* kfifo */
        spin_lock_init(&fujitsu_hotkey->fifo_lock);
-       fujitsu_hotkey->fifo =
-           kfifo_alloc(RINGBUFFERSIZE * sizeof(int), GFP_KERNEL,
-                       &fujitsu_hotkey->fifo_lock);
-       if (IS_ERR(fujitsu_hotkey->fifo)) {
+       error = kfifo_alloc(&fujitsu_hotkey->fifo, RINGBUFFERSIZE * sizeof(int),
+                       GFP_KERNEL);
+       if (error) {
                printk(KERN_ERR "kfifo_alloc failed\n");
-               error = PTR_ERR(fujitsu_hotkey->fifo);
                goto err_stop;
        }
 
@@ -934,7 +932,7 @@ err_unregister_input_dev:
 err_free_input_dev:
        input_free_device(input);
 err_free_fifo:
-       kfifo_free(fujitsu_hotkey->fifo);
+       kfifo_free(&fujitsu_hotkey->fifo);
 err_stop:
        return result;
 }
@@ -956,7 +954,7 @@ static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
 
        input_free_device(input);
 
-       kfifo_free(fujitsu_hotkey->fifo);
+       kfifo_free(&fujitsu_hotkey->fifo);
 
        fujitsu_hotkey->acpi_handle = NULL;
 
@@ -1008,9 +1006,10 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
                                vdbg_printk(FUJLAPTOP_DBG_TRACE,
                                        "Push keycode into ringbuffer [%d]\n",
                                        keycode);
-                               status = kfifo_put(fujitsu_hotkey->fifo,
+                               status = kfifo_in_locked(&fujitsu_hotkey->fifo,
                                                   (unsigned char *)&keycode,
-                                                  sizeof(keycode));
+                                                  sizeof(keycode),
+                                                  &fujitsu_hotkey->fifo_lock);
                                if (status != sizeof(keycode)) {
                                        vdbg_printk(FUJLAPTOP_DBG_WARN,
                                            "Could not push keycode [0x%x]\n",
@@ -1021,11 +1020,12 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
                                }
                        } else if (keycode == 0) {
                                while ((status =
-                                       kfifo_get
-                                       (fujitsu_hotkey->fifo, (unsigned char *)
-                                        &keycode_r,
-                                        sizeof
-                                        (keycode_r))) == sizeof(keycode_r)) {
+                                       kfifo_out_locked(
+                                        &fujitsu_hotkey->fifo,
+                                        (unsigned char *) &keycode_r,
+                                        sizeof(keycode_r),
+                                        &fujitsu_hotkey->fifo_lock))
+                                        == sizeof(keycode_r)) {
                                        input_report_key(input, keycode_r, 0);
                                        input_sync(input);
                                        vdbg_printk(FUJLAPTOP_DBG_TRACE,
index c2842171cec6b9942c3e844954842612d5db0d20..5b648f0c6075411464842ae29f70912cfd1aa658 100644 (file)
@@ -51,6 +51,12 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
 #define HPWMI_WIRELESS_QUERY 0x5
 #define HPWMI_HOTKEY_QUERY 0xc
 
+enum hp_wmi_radio {
+       HPWMI_WIFI = 0,
+       HPWMI_BLUETOOTH = 1,
+       HPWMI_WWAN = 2,
+};
+
 static int __init hp_wmi_bios_setup(struct platform_device *device);
 static int __exit hp_wmi_bios_remove(struct platform_device *device);
 static int hp_wmi_resume_handler(struct device *device);
@@ -94,7 +100,7 @@ static struct rfkill *wifi_rfkill;
 static struct rfkill *bluetooth_rfkill;
 static struct rfkill *wwan_rfkill;
 
-static struct dev_pm_ops hp_wmi_pm_ops = {
+static const struct dev_pm_ops hp_wmi_pm_ops = {
        .resume  = hp_wmi_resume_handler,
        .restore  = hp_wmi_resume_handler,
 };
@@ -128,10 +134,15 @@ static int hp_wmi_perform_query(int query, int write, int value)
 
        obj = output.pointer;
 
-       if (!obj || obj->type != ACPI_TYPE_BUFFER)
+       if (!obj)
                return -EINVAL;
+       else if (obj->type != ACPI_TYPE_BUFFER) {
+               kfree(obj);
+               return -EINVAL;
+       }
 
        bios_return = *((struct bios_return *)obj->buffer.pointer);
+       kfree(obj);
        if (bios_return.return_code > 0)
                return bios_return.return_code * -1;
        else
@@ -175,8 +186,8 @@ static int hp_wmi_tablet_state(void)
 
 static int hp_wmi_set_block(void *data, bool blocked)
 {
-       unsigned long b = (unsigned long) data;
-       int query = BIT(b + 8) | ((!blocked) << b);
+       enum hp_wmi_radio r = (enum hp_wmi_radio) data;
+       int query = BIT(r + 8) | ((!blocked) << r);
 
        return hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, query);
 }
@@ -185,31 +196,23 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {
        .set_block = hp_wmi_set_block,
 };
 
-static bool hp_wmi_wifi_state(void)
-{
-       int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
-
-       if (wireless & 0x100)
-               return false;
-       else
-               return true;
-}
-
-static bool hp_wmi_bluetooth_state(void)
+static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
 {
        int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+       int mask = 0x200 << (r * 8);
 
-       if (wireless & 0x10000)
+       if (wireless & mask)
                return false;
        else
                return true;
 }
 
-static bool hp_wmi_wwan_state(void)
+static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)
 {
        int wireless = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 0, 0);
+       int mask = 0x800 << (r * 8);
 
-       if (wireless & 0x1000000)
+       if (wireless & mask)
                return false;
        else
                return true;
@@ -334,49 +337,64 @@ static void hp_wmi_notify(u32 value, void *context)
        struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
        static struct key_entry *key;
        union acpi_object *obj;
+       int eventcode;
+       acpi_status status;
 
-       wmi_get_event_data(value, &response);
+       status = wmi_get_event_data(value, &response);
+       if (status != AE_OK) {
+               printk(KERN_INFO "hp-wmi: bad event status 0x%x\n", status);
+               return;
+       }
 
        obj = (union acpi_object *)response.pointer;
 
-       if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length == 8) {
-               int eventcode = *((u8 *) obj->buffer.pointer);
-               if (eventcode == 0x4)
-                       eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
-                                                        0);
-               key = hp_wmi_get_entry_by_scancode(eventcode);
-               if (key) {
-                       switch (key->type) {
-                       case KE_KEY:
-                               input_report_key(hp_wmi_input_dev,
-                                                key->keycode, 1);
-                               input_sync(hp_wmi_input_dev);
-                               input_report_key(hp_wmi_input_dev,
-                                                key->keycode, 0);
-                               input_sync(hp_wmi_input_dev);
-                               break;
-                       }
-               } else if (eventcode == 0x1) {
-                       input_report_switch(hp_wmi_input_dev, SW_DOCK,
-                                           hp_wmi_dock_state());
-                       input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
-                                           hp_wmi_tablet_state());
+       if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
+               printk(KERN_INFO "HP WMI: Unknown response received\n");
+               kfree(obj);
+               return;
+       }
+
+       eventcode = *((u8 *) obj->buffer.pointer);
+       kfree(obj);
+       if (eventcode == 0x4)
+               eventcode = hp_wmi_perform_query(HPWMI_HOTKEY_QUERY, 0,
+                                               0);
+       key = hp_wmi_get_entry_by_scancode(eventcode);
+       if (key) {
+               switch (key->type) {
+               case KE_KEY:
+                       input_report_key(hp_wmi_input_dev,
+                                        key->keycode, 1);
+                       input_sync(hp_wmi_input_dev);
+                       input_report_key(hp_wmi_input_dev,
+                                        key->keycode, 0);
                        input_sync(hp_wmi_input_dev);
-               } else if (eventcode == 0x5) {
-                       if (wifi_rfkill)
-                               rfkill_set_sw_state(wifi_rfkill,
-                                                   hp_wmi_wifi_state());
-                       if (bluetooth_rfkill)
-                               rfkill_set_sw_state(bluetooth_rfkill,
-                                                   hp_wmi_bluetooth_state());
-                       if (wwan_rfkill)
-                               rfkill_set_sw_state(wwan_rfkill,
-                                                   hp_wmi_wwan_state());
-               } else
-                       printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
-                              eventcode);
+                       break;
+               }
+       } else if (eventcode == 0x1) {
+               input_report_switch(hp_wmi_input_dev, SW_DOCK,
+                                   hp_wmi_dock_state());
+               input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
+                                   hp_wmi_tablet_state());
+               input_sync(hp_wmi_input_dev);
+       } else if (eventcode == 0x5) {
+               if (wifi_rfkill)
+                       rfkill_set_states(wifi_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_WIFI),
+                                         hp_wmi_get_hw_state(HPWMI_WIFI));
+               if (bluetooth_rfkill)
+                       rfkill_set_states(bluetooth_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+                                         hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+               if (wwan_rfkill)
+                       rfkill_set_states(wwan_rfkill,
+                                         hp_wmi_get_sw_state(HPWMI_WWAN),
+                                         hp_wmi_get_hw_state(HPWMI_WWAN));
        } else
-               printk(KERN_INFO "HP WMI: Unknown response received\n");
+               printk(KERN_INFO "HP WMI: Unknown key pressed - %x\n",
+                       eventcode);
+
+       kfree(obj);
 }
 
 static int __init hp_wmi_input_setup(void)
@@ -455,7 +473,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                wifi_rfkill = rfkill_alloc("hp-wifi", &device->dev,
                                           RFKILL_TYPE_WLAN,
                                           &hp_wmi_rfkill_ops,
-                                          (void *) 0);
+                                          (void *) HPWMI_WIFI);
+               rfkill_init_sw_state(wifi_rfkill,
+                                    hp_wmi_get_sw_state(HPWMI_WIFI));
+               rfkill_set_hw_state(wifi_rfkill,
+                                   hp_wmi_get_hw_state(HPWMI_WIFI));
                err = rfkill_register(wifi_rfkill);
                if (err)
                        goto register_wifi_error;
@@ -465,7 +487,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                bluetooth_rfkill = rfkill_alloc("hp-bluetooth", &device->dev,
                                                RFKILL_TYPE_BLUETOOTH,
                                                &hp_wmi_rfkill_ops,
-                                               (void *) 1);
+                                               (void *) HPWMI_BLUETOOTH);
+               rfkill_init_sw_state(bluetooth_rfkill,
+                                    hp_wmi_get_sw_state(HPWMI_BLUETOOTH));
+               rfkill_set_hw_state(bluetooth_rfkill,
+                                   hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
                err = rfkill_register(bluetooth_rfkill);
                if (err)
                        goto register_bluetooth_error;
@@ -475,7 +501,11 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
                wwan_rfkill = rfkill_alloc("hp-wwan", &device->dev,
                                           RFKILL_TYPE_WWAN,
                                           &hp_wmi_rfkill_ops,
-                                          (void *) 2);
+                                          (void *) HPWMI_WWAN);
+               rfkill_init_sw_state(wwan_rfkill,
+                                    hp_wmi_get_sw_state(HPWMI_WWAN));
+               rfkill_set_hw_state(wwan_rfkill,
+                                   hp_wmi_get_hw_state(HPWMI_WWAN));
                err = rfkill_register(wwan_rfkill);
                if (err)
                        goto register_wwan_err;
@@ -533,6 +563,19 @@ static int hp_wmi_resume_handler(struct device *device)
                input_sync(hp_wmi_input_dev);
        }
 
+       if (wifi_rfkill)
+               rfkill_set_states(wifi_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_WIFI),
+                                 hp_wmi_get_hw_state(HPWMI_WIFI));
+       if (bluetooth_rfkill)
+               rfkill_set_states(bluetooth_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_BLUETOOTH),
+                                 hp_wmi_get_hw_state(HPWMI_BLUETOOTH));
+       if (wwan_rfkill)
+               rfkill_set_states(wwan_rfkill,
+                                 hp_wmi_get_sw_state(HPWMI_WWAN),
+                                 hp_wmi_get_hw_state(HPWMI_WWAN));
+
        return 0;
 }
 
@@ -543,7 +586,7 @@ static int __init hp_wmi_init(void)
        if (wmi_has_guid(HPWMI_EVENT_GUID)) {
                err = wmi_install_notify_handler(HPWMI_EVENT_GUID,
                                                 hp_wmi_notify, NULL);
-               if (!err)
+               if (ACPI_SUCCESS(err))
                        hp_wmi_input_setup();
        }
 
diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
new file mode 100644 (file)
index 0000000..f5f70d4
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * MSI WMI hotkeys
+ *
+ * Copyright (C) 2009 Novell <trenn@suse.de>
+ *
+ * Most stuff taken over from hp-wmi
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include <linux/kernel.h>
+#include <linux/input.h>
+#include <linux/input/sparse-keymap.h>
+#include <linux/acpi.h>
+#include <linux/backlight.h>
+
+MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
+MODULE_DESCRIPTION("MSI laptop WMI hotkeys driver");
+MODULE_LICENSE("GPL");
+
+MODULE_ALIAS("wmi:551A1F84-FBDD-4125-91DB-3EA8F44F1D45");
+MODULE_ALIAS("wmi:B6F3EEF2-3D2F-49DC-9DE3-85BCE18C62F2");
+
+#define DRV_NAME "msi-wmi"
+#define DRV_PFX DRV_NAME ": "
+
+#define MSIWMI_BIOS_GUID "551A1F84-FBDD-4125-91DB-3EA8F44F1D45"
+#define MSIWMI_EVENT_GUID "B6F3EEF2-3D2F-49DC-9DE3-85BCE18C62F2"
+
+#define dprintk(msg...) pr_debug(DRV_PFX msg)
+
+#define KEYCODE_BASE 0xD0
+#define MSI_WMI_BRIGHTNESSUP   KEYCODE_BASE
+#define MSI_WMI_BRIGHTNESSDOWN (KEYCODE_BASE + 1)
+#define MSI_WMI_VOLUMEUP       (KEYCODE_BASE + 2)
+#define MSI_WMI_VOLUMEDOWN     (KEYCODE_BASE + 3)
+static struct key_entry msi_wmi_keymap[] = {
+       { KE_KEY, MSI_WMI_BRIGHTNESSUP,   {KEY_BRIGHTNESSUP} },
+       { KE_KEY, MSI_WMI_BRIGHTNESSDOWN, {KEY_BRIGHTNESSDOWN} },
+       { KE_KEY, MSI_WMI_VOLUMEUP,       {KEY_VOLUMEUP} },
+       { KE_KEY, MSI_WMI_VOLUMEDOWN,     {KEY_VOLUMEDOWN} },
+       { KE_END, 0}
+};
+static ktime_t last_pressed[ARRAY_SIZE(msi_wmi_keymap) - 1];
+
+struct backlight_device *backlight;
+
+static int backlight_map[] = { 0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF };
+
+static struct input_dev *msi_wmi_input_dev;
+
+static int msi_wmi_query_block(int instance, int *ret)
+{
+       acpi_status status;
+       union acpi_object *obj;
+
+       struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+
+       status = wmi_query_block(MSIWMI_BIOS_GUID, instance, &output);
+
+       obj = output.pointer;
+
+       if (!obj || obj->type != ACPI_TYPE_INTEGER) {
+               if (obj) {
+                       printk(KERN_ERR DRV_PFX "query block returned object "
+                              "type: %d - buffer length:%d\n", obj->type,
+                              obj->type == ACPI_TYPE_BUFFER ?
+                              obj->buffer.length : 0);
+               }
+               kfree(obj);
+               return -EINVAL;
+       }
+       *ret = obj->integer.value;
+       kfree(obj);
+       return 0;
+}
+
+static int msi_wmi_set_block(int instance, int value)
+{
+       acpi_status status;
+
+       struct acpi_buffer input = { sizeof(int), &value };
+
+       dprintk("Going to set block of instance: %d - value: %d\n",
+               instance, value);
+
+       status = wmi_set_block(MSIWMI_BIOS_GUID, instance, &input);
+
+       return ACPI_SUCCESS(status) ? 0 : 1;
+}
+
+static int bl_get(struct backlight_device *bd)
+{
+       int level, err, ret;
+
+       /* Instance 1 is "get backlight", cmp with DSDT */
+       err = msi_wmi_query_block(1, &ret);
+       if (err) {
+               printk(KERN_ERR DRV_PFX "Could not query backlight: %d\n", err);
+               return -EINVAL;
+       }
+       dprintk("Get: Query block returned: %d\n", ret);
+       for (level = 0; level < ARRAY_SIZE(backlight_map); level++) {
+               if (backlight_map[level] == ret) {
+                       dprintk("Current backlight level: 0x%X - index: %d\n",
+                               backlight_map[level], level);
+                       break;
+               }
+       }
+       if (level == ARRAY_SIZE(backlight_map)) {
+               printk(KERN_ERR DRV_PFX "get: Invalid brightness value: 0x%X\n",
+                      ret);
+               return -EINVAL;
+       }
+       return level;
+}
+
+static int bl_set_status(struct backlight_device *bd)
+{
+       int bright = bd->props.brightness;
+       if (bright >= ARRAY_SIZE(backlight_map) || bright < 0)
+               return -EINVAL;
+
+       /* Instance 0 is "set backlight" */
+       return msi_wmi_set_block(0, backlight_map[bright]);
+}
+
+static struct backlight_ops msi_backlight_ops = {
+       .get_brightness = bl_get,
+       .update_status  = bl_set_status,
+};
+
+static void msi_wmi_notify(u32 value, void *context)
+{
+       struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
+       static struct key_entry *key;
+       union acpi_object *obj;
+       ktime_t cur;
+       acpi_status status;
+
+       status = wmi_get_event_data(value, &response);
+       if (status != AE_OK) {
+               printk(KERN_INFO DRV_PFX "bad event status 0x%x\n", status);
+               return;
+       }
+
+       obj = (union acpi_object *)response.pointer;
+
+       if (obj && obj->type == ACPI_TYPE_INTEGER) {
+               int eventcode = obj->integer.value;
+               dprintk("Eventcode: 0x%x\n", eventcode);
+               key = sparse_keymap_entry_from_scancode(msi_wmi_input_dev,
+                               eventcode);
+               if (key) {
+                       ktime_t diff;
+                       cur = ktime_get_real();
+                       diff = ktime_sub(cur, last_pressed[key->code -
+                                       KEYCODE_BASE]);
+                       /* Ignore event if the same event happened in a 50 ms
+                          timeframe -> Key press may result in 10-20 GPEs */
+                       if (ktime_to_us(diff) < 1000 * 50) {
+                               dprintk("Suppressed key event 0x%X - "
+                                       "Last press was %lld us ago\n",
+                                        key->code, ktime_to_us(diff));
+                               return;
+                       }
+                       last_pressed[key->code - KEYCODE_BASE] = cur;
+
+                       if (key->type == KE_KEY &&
+                       /* Brightness is served via acpi video driver */
+                       (!acpi_video_backlight_support() ||
+                       (key->code != MSI_WMI_BRIGHTNESSUP &&
+                       key->code != MSI_WMI_BRIGHTNESSDOWN))) {
+                               dprintk("Send key: 0x%X - "
+                                       "Input layer keycode: %d\n", key->code,
+                                        key->keycode);
+                               sparse_keymap_report_entry(msi_wmi_input_dev,
+                                               key, 1, true);
+                       }
+               } else
+                       printk(KERN_INFO "Unknown key pressed - %x\n",
+                              eventcode);
+       } else
+               printk(KERN_INFO DRV_PFX "Unknown event received\n");
+       kfree(response.pointer);
+}
+
+static int __init msi_wmi_input_setup(void)
+{
+       int err;
+
+       msi_wmi_input_dev = input_allocate_device();
+       if (!msi_wmi_input_dev)
+               return -ENOMEM;
+
+       msi_wmi_input_dev->name = "MSI WMI hotkeys";
+       msi_wmi_input_dev->phys = "wmi/input0";
+       msi_wmi_input_dev->id.bustype = BUS_HOST;
+
+       err = sparse_keymap_setup(msi_wmi_input_dev, msi_wmi_keymap, NULL);
+       if (err)
+               goto err_free_dev;
+
+       err = input_register_device(msi_wmi_input_dev);
+
+       if (err)
+               goto err_free_keymap;
+
+       memset(last_pressed, 0, sizeof(last_pressed));
+
+       return 0;
+
+err_free_keymap:
+       sparse_keymap_free(msi_wmi_input_dev);
+err_free_dev:
+       input_free_device(msi_wmi_input_dev);
+       return err;
+}
+
+static int __init msi_wmi_init(void)
+{
+       int err;
+
+       if (!wmi_has_guid(MSIWMI_EVENT_GUID)) {
+               printk(KERN_ERR
+                      "This machine doesn't have MSI-hotkeys through WMI\n");
+               return -ENODEV;
+       }
+       err = wmi_install_notify_handler(MSIWMI_EVENT_GUID,
+                       msi_wmi_notify, NULL);
+       if (ACPI_FAILURE(err))
+               return -EINVAL;
+
+       err = msi_wmi_input_setup();
+       if (err)
+               goto err_uninstall_notifier;
+
+       if (!acpi_video_backlight_support()) {
+               backlight = backlight_device_register(DRV_NAME,
+                               NULL, NULL, &msi_backlight_ops);
+               if (IS_ERR(backlight))
+                       goto err_free_input;
+
+               backlight->props.max_brightness = ARRAY_SIZE(backlight_map) - 1;
+               err = bl_get(NULL);
+               if (err < 0)
+                       goto err_free_backlight;
+
+               backlight->props.brightness = err;
+       }
+       dprintk("Event handler installed\n");
+
+       return 0;
+
+err_free_backlight:
+       backlight_device_unregister(backlight);
+err_free_input:
+       input_unregister_device(msi_wmi_input_dev);
+err_uninstall_notifier:
+       wmi_remove_notify_handler(MSIWMI_EVENT_GUID);
+       return err;
+}
+
+static void __exit msi_wmi_exit(void)
+{
+       if (wmi_has_guid(MSIWMI_EVENT_GUID)) {
+               wmi_remove_notify_handler(MSIWMI_EVENT_GUID);
+               sparse_keymap_free(msi_wmi_input_dev);
+               input_unregister_device(msi_wmi_input_dev);
+               backlight_device_unregister(backlight);
+       }
+}
+
+module_init(msi_wmi_init);
+module_exit(msi_wmi_exit);
index 7a2cc8a5c975899d9a88fc1367d9cf4908b388f7..5af53340da6f4736fb86c65c30fc296b2e5c97f7 100644 (file)
@@ -131,6 +131,7 @@ enum sony_nc_rfkill {
        N_SONY_RFKILL,
 };
 
+static int sony_rfkill_handle;
 static struct rfkill *sony_rfkill_devices[N_SONY_RFKILL];
 static int sony_rfkill_address[N_SONY_RFKILL] = {0x300, 0x500, 0x700, 0x900};
 static void sony_nc_rfkill_update(void);
@@ -142,7 +143,7 @@ struct sony_laptop_input_s {
        atomic_t                users;
        struct input_dev        *jog_dev;
        struct input_dev        *key_dev;
-       struct kfifo            *fifo;
+       struct kfifo            fifo;
        spinlock_t              fifo_lock;
        struct workqueue_struct *wq;
 };
@@ -232,6 +233,7 @@ static int sony_laptop_input_index[] = {
        56,     /* 69 SONYPI_EVENT_VOLUME_INC_PRESSED */
        57,     /* 70 SONYPI_EVENT_VOLUME_DEC_PRESSED */
        -1,     /* 71 SONYPI_EVENT_BRIGHTNESS_PRESSED */
+       58,     /* 72 SONYPI_EVENT_MEDIA_PRESSED */
 };
 
 static int sony_laptop_input_keycode_map[] = {
@@ -293,6 +295,7 @@ static int sony_laptop_input_keycode_map[] = {
        KEY_F15,        /* 55 SONYPI_EVENT_SETTINGKEY_PRESSED */
        KEY_VOLUMEUP,   /* 56 SONYPI_EVENT_VOLUME_INC_PRESSED */
        KEY_VOLUMEDOWN, /* 57 SONYPI_EVENT_VOLUME_DEC_PRESSED */
+       KEY_MEDIA,      /* 58 SONYPI_EVENT_MEDIA_PRESSED */
 };
 
 /* release buttons after a short delay if pressed */
@@ -300,8 +303,9 @@ static void do_sony_laptop_release_key(struct work_struct *work)
 {
        struct sony_laptop_keypress kp;
 
-       while (kfifo_get(sony_laptop_input.fifo, (unsigned char *)&kp,
-                        sizeof(kp)) == sizeof(kp)) {
+       while (kfifo_out_locked(&sony_laptop_input.fifo, (unsigned char *)&kp,
+                       sizeof(kp), &sony_laptop_input.fifo_lock)
+                       == sizeof(kp)) {
                msleep(10);
                input_report_key(kp.dev, kp.key, 0);
                input_sync(kp.dev);
@@ -362,8 +366,9 @@ static void sony_laptop_report_input_event(u8 event)
                /* we emit the scancode so we can always remap the key */
                input_event(kp.dev, EV_MSC, MSC_SCAN, event);
                input_sync(kp.dev);
-               kfifo_put(sony_laptop_input.fifo,
-                         (unsigned char *)&kp, sizeof(kp));
+               kfifo_in_locked(&sony_laptop_input.fifo,
+                         (unsigned char *)&kp, sizeof(kp),
+                         &sony_laptop_input.fifo_lock);
 
                if (!work_pending(&sony_laptop_release_key_work))
                        queue_work(sony_laptop_input.wq,
@@ -385,12 +390,10 @@ static int sony_laptop_setup_input(struct acpi_device *acpi_device)
 
        /* kfifo */
        spin_lock_init(&sony_laptop_input.fifo_lock);
-       sony_laptop_input.fifo =
-               kfifo_alloc(SONY_LAPTOP_BUF_SIZE, GFP_KERNEL,
-                           &sony_laptop_input.fifo_lock);
-       if (IS_ERR(sony_laptop_input.fifo)) {
+       error =
+        kfifo_alloc(&sony_laptop_input.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL);
+       if (error) {
                printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n");
-               error = PTR_ERR(sony_laptop_input.fifo);
                goto err_dec_users;
        }
 
@@ -474,7 +477,7 @@ err_destroy_wq:
        destroy_workqueue(sony_laptop_input.wq);
 
 err_free_kfifo:
-       kfifo_free(sony_laptop_input.fifo);
+       kfifo_free(&sony_laptop_input.fifo);
 
 err_dec_users:
        atomic_dec(&sony_laptop_input.users);
@@ -500,7 +503,7 @@ static void sony_laptop_remove_input(void)
        }
 
        destroy_workqueue(sony_laptop_input.wq);
-       kfifo_free(sony_laptop_input.fifo);
+       kfifo_free(&sony_laptop_input.fifo);
 }
 
 /*********** Platform Device ***********/
@@ -890,6 +893,8 @@ static struct sony_nc_event sony_100_events[] = {
        { 0x0C, SONYPI_EVENT_FNKEY_RELEASED },
        { 0x9f, SONYPI_EVENT_CD_EJECT_PRESSED },
        { 0x1f, SONYPI_EVENT_ANYBUTTON_RELEASED },
+       { 0xa1, SONYPI_EVENT_MEDIA_PRESSED },
+       { 0x21, SONYPI_EVENT_ANYBUTTON_RELEASED },
        { 0, 0 },
 };
 
@@ -961,7 +966,7 @@ static void sony_nc_notify(struct acpi_device *device, u32 event)
                                else
                                        sony_laptop_report_input_event(ev);
                        }
-               } else if (sony_find_snc_handle(0x124) == ev) {
+               } else if (sony_find_snc_handle(sony_rfkill_handle) == ev) {
                        sony_nc_rfkill_update();
                        return;
                }
@@ -1067,7 +1072,7 @@ static int sony_nc_rfkill_set(void *data, bool blocked)
        if (!blocked)
                argument |= 0xff0000;
 
-       return sony_call_snc_handle(0x124, argument, &result);
+       return sony_call_snc_handle(sony_rfkill_handle, argument, &result);
 }
 
 static const struct rfkill_ops sony_rfkill_ops = {
@@ -1110,7 +1115,7 @@ static int sony_nc_setup_rfkill(struct acpi_device *device,
        if (!rfk)
                return -ENOMEM;
 
-       sony_call_snc_handle(0x124, 0x200, &result);
+       sony_call_snc_handle(sony_rfkill_handle, 0x200, &result);
        hwblock = !(result & 0x1);
        rfkill_set_hw_state(rfk, hwblock);
 
@@ -1129,7 +1134,7 @@ static void sony_nc_rfkill_update()
        int result;
        bool hwblock;
 
-       sony_call_snc_handle(0x124, 0x200, &result);
+       sony_call_snc_handle(sony_rfkill_handle, 0x200, &result);
        hwblock = !(result & 0x1);
 
        for (i = 0; i < N_SONY_RFKILL; i++) {
@@ -1145,36 +1150,79 @@ static void sony_nc_rfkill_update()
                        continue;
                }
 
-               sony_call_snc_handle(0x124, argument, &result);
+               sony_call_snc_handle(sony_rfkill_handle, argument, &result);
                rfkill_set_states(sony_rfkill_devices[i],
                                  !(result & 0xf), false);
        }
 }
 
-static int sony_nc_rfkill_setup(struct acpi_device *device)
+static void sony_nc_rfkill_setup(struct acpi_device *device)
 {
-       int result, ret;
+       int offset;
+       u8 dev_code, i;
+       acpi_status status;
+       struct acpi_object_list params;
+       union acpi_object in_obj;
+       union acpi_object *device_enum;
+       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 
-       if (sony_find_snc_handle(0x124) == -1)
-               return -1;
+       offset = sony_find_snc_handle(0x124);
+       if (offset == -1) {
+               offset = sony_find_snc_handle(0x135);
+               if (offset == -1)
+                       return;
+               else
+                       sony_rfkill_handle = 0x135;
+       } else
+               sony_rfkill_handle = 0x124;
+       dprintk("Found rkfill handle: 0x%.4x\n", sony_rfkill_handle);
 
-       ret = sony_call_snc_handle(0x124, 0xb00, &result);
-       if (ret) {
-               printk(KERN_INFO DRV_PFX
-                      "Unable to enumerate rfkill devices: %x\n", ret);
-               return ret;
+       /* need to read the whole buffer returned by the acpi call to SN06
+        * here otherwise we may miss some features
+        */
+       params.count = 1;
+       params.pointer = &in_obj;
+       in_obj.type = ACPI_TYPE_INTEGER;
+       in_obj.integer.value = offset;
+       status = acpi_evaluate_object(sony_nc_acpi_handle, "SN06", &params,
+                       &buffer);
+       if (ACPI_FAILURE(status)) {
+               dprintk("Radio device enumeration failed\n");
+               return;
+       }
+
+       device_enum = (union acpi_object *) buffer.pointer;
+       if (!device_enum || device_enum->type != ACPI_TYPE_BUFFER) {
+               printk(KERN_ERR "Invalid SN06 return object 0x%.2x\n",
+                               device_enum->type);
+               goto out_no_enum;
        }
 
-       if (result & 0x1)
-               sony_nc_setup_rfkill(device, SONY_WIFI);
-       if (result & 0x2)
-               sony_nc_setup_rfkill(device, SONY_BLUETOOTH);
-       if (result & 0x1c)
-               sony_nc_setup_rfkill(device, SONY_WWAN);
-       if (result & 0x20)
-               sony_nc_setup_rfkill(device, SONY_WIMAX);
+       /* the buffer is filled with magic numbers describing the devices
+        * available, 0xff terminates the enumeration
+        */
+       while ((dev_code = *(device_enum->buffer.pointer + i)) != 0xff &&
+                       i < device_enum->buffer.length) {
+               i++;
+               dprintk("Radio devices, looking at 0x%.2x\n", dev_code);
 
-       return 0;
+               if (dev_code == 0 && !sony_rfkill_devices[SONY_WIFI])
+                       sony_nc_setup_rfkill(device, SONY_WIFI);
+
+               if (dev_code == 0x10 && !sony_rfkill_devices[SONY_BLUETOOTH])
+                       sony_nc_setup_rfkill(device, SONY_BLUETOOTH);
+
+               if ((0xf0 & dev_code) == 0x20 &&
+                               !sony_rfkill_devices[SONY_WWAN])
+                       sony_nc_setup_rfkill(device, SONY_WWAN);
+
+               if (dev_code == 0x30 && !sony_rfkill_devices[SONY_WIMAX])
+                       sony_nc_setup_rfkill(device, SONY_WIMAX);
+       }
+
+out_no_enum:
+       kfree(buffer.pointer);
+       return;
 }
 
 static int sony_nc_add(struct acpi_device *device)
@@ -2079,7 +2127,7 @@ static struct attribute_group spic_attribute_group = {
 
 struct sonypi_compat_s {
        struct fasync_struct    *fifo_async;
-       struct kfifo            *fifo;
+       struct kfifo            fifo;
        spinlock_t              fifo_lock;
        wait_queue_head_t       fifo_proc_list;
        atomic_t                open_count;
@@ -2104,12 +2152,12 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
        /* Flush input queue on first open */
        unsigned long flags;
 
-       spin_lock_irqsave(sonypi_compat.fifo->lock, flags);
+       spin_lock_irqsave(&sonypi_compat.fifo_lock, flags);
 
        if (atomic_inc_return(&sonypi_compat.open_count) == 1)
-               __kfifo_reset(sonypi_compat.fifo);
+               kfifo_reset(&sonypi_compat.fifo);
 
-       spin_unlock_irqrestore(sonypi_compat.fifo->lock, flags);
+       spin_unlock_irqrestore(&sonypi_compat.fifo_lock, flags);
 
        return 0;
 }
@@ -2120,17 +2168,18 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
        ssize_t ret;
        unsigned char c;
 
-       if ((kfifo_len(sonypi_compat.fifo) == 0) &&
+       if ((kfifo_len(&sonypi_compat.fifo) == 0) &&
            (file->f_flags & O_NONBLOCK))
                return -EAGAIN;
 
        ret = wait_event_interruptible(sonypi_compat.fifo_proc_list,
-                                      kfifo_len(sonypi_compat.fifo) != 0);
+                                      kfifo_len(&sonypi_compat.fifo) != 0);
        if (ret)
                return ret;
 
        while (ret < count &&
-              (kfifo_get(sonypi_compat.fifo, &c, sizeof(c)) == sizeof(c))) {
+              (kfifo_out_locked(&sonypi_compat.fifo, &c, sizeof(c),
+                         &sonypi_compat.fifo_lock) == sizeof(c))) {
                if (put_user(c, buf++))
                        return -EFAULT;
                ret++;
@@ -2147,7 +2196,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
 static unsigned int sonypi_misc_poll(struct file *file, poll_table *wait)
 {
        poll_wait(file, &sonypi_compat.fifo_proc_list, wait);
-       if (kfifo_len(sonypi_compat.fifo))
+       if (kfifo_len(&sonypi_compat.fifo))
                return POLLIN | POLLRDNORM;
        return 0;
 }
@@ -2309,7 +2358,8 @@ static struct miscdevice sonypi_misc_device = {
 
 static void sonypi_compat_report_event(u8 event)
 {
-       kfifo_put(sonypi_compat.fifo, (unsigned char *)&event, sizeof(event));
+       kfifo_in_locked(&sonypi_compat.fifo, (unsigned char *)&event,
+                       sizeof(event), &sonypi_compat.fifo_lock);
        kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN);
        wake_up_interruptible(&sonypi_compat.fifo_proc_list);
 }
@@ -2319,11 +2369,11 @@ static int sonypi_compat_init(void)
        int error;
 
        spin_lock_init(&sonypi_compat.fifo_lock);
-       sonypi_compat.fifo = kfifo_alloc(SONY_LAPTOP_BUF_SIZE, GFP_KERNEL,
-                                        &sonypi_compat.fifo_lock);
-       if (IS_ERR(sonypi_compat.fifo)) {
+       error =
+        kfifo_alloc(&sonypi_compat.fifo, SONY_LAPTOP_BUF_SIZE, GFP_KERNEL);
+       if (error) {
                printk(KERN_ERR DRV_PFX "kfifo_alloc failed\n");
-               return PTR_ERR(sonypi_compat.fifo);
+               return error;
        }
 
        init_waitqueue_head(&sonypi_compat.fifo_proc_list);
@@ -2342,14 +2392,14 @@ static int sonypi_compat_init(void)
        return 0;
 
 err_free_kfifo:
-       kfifo_free(sonypi_compat.fifo);
+       kfifo_free(&sonypi_compat.fifo);
        return error;
 }
 
 static void sonypi_compat_exit(void)
 {
        misc_deregister(&sonypi_misc_device);
-       kfifo_free(sonypi_compat.fifo);
+       kfifo_free(&sonypi_compat.fifo);
 }
 #else
 static int sonypi_compat_init(void) { return 0; }
index 44166003d4ef15f12b73ee71bff7f2fadcd9181e..dd33b51c34869b098ee43ce9e63e36b89c3d4a22 100644 (file)
@@ -47,22 +47,6 @@ MODULE_DESCRIPTION("HP Compaq TC1100 Tablet WMI Extras");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("wmi:C364AC71-36DB-495A-8494-B439D472A505");
 
-static int tc1100_probe(struct platform_device *device);
-static int tc1100_remove(struct platform_device *device);
-static int tc1100_suspend(struct platform_device *device, pm_message_t state);
-static int tc1100_resume(struct platform_device *device);
-
-static struct platform_driver tc1100_driver = {
-       .driver = {
-               .name = "tc1100-wmi",
-               .owner = THIS_MODULE,
-       },
-       .probe = tc1100_probe,
-       .remove = tc1100_remove,
-       .suspend = tc1100_suspend,
-       .resume = tc1100_resume,
-};
-
 static struct platform_device *tc1100_device;
 
 struct tc1100_data {
@@ -183,51 +167,35 @@ static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \
 show_set_bool(wireless, TC1100_INSTANCE_WIRELESS);
 show_set_bool(jogdial, TC1100_INSTANCE_JOGDIAL);
 
-static void remove_fs(void)
-{
-       device_remove_file(&tc1100_device->dev, &dev_attr_wireless);
-       device_remove_file(&tc1100_device->dev, &dev_attr_jogdial);
-}
-
-static int add_fs(void)
-{
-       int ret;
-
-       ret = device_create_file(&tc1100_device->dev, &dev_attr_wireless);
-       if (ret)
-               goto add_sysfs_error;
-
-       ret = device_create_file(&tc1100_device->dev, &dev_attr_jogdial);
-       if (ret)
-               goto add_sysfs_error;
-
-       return ret;
+static struct attribute *tc1100_attributes[] = {
+       &dev_attr_wireless.attr,
+       &dev_attr_jogdial.attr,
+       NULL
+};
 
-add_sysfs_error:
-       remove_fs();
-       return ret;
-}
+static struct attribute_group tc1100_attribute_group = {
+       .attrs  = tc1100_attributes,
+};
 
 /* --------------------------------------------------------------------------
                                Driver Model
    -------------------------------------------------------------------------- */
 
-static int tc1100_probe(struct platform_device *device)
+static int __init tc1100_probe(struct platform_device *device)
 {
-       int result = 0;
-
-       result = add_fs();
-       return result;
+       return sysfs_create_group(&device->dev.kobj, &tc1100_attribute_group);
 }
 
 
-static int tc1100_remove(struct platform_device *device)
+static int __devexit tc1100_remove(struct platform_device *device)
 {
-       remove_fs();
+       sysfs_remove_group(&device->dev.kobj, &tc1100_attribute_group);
+
        return 0;
 }
 
-static int tc1100_suspend(struct platform_device *dev, pm_message_t state)
+#ifdef CONFIG_PM
+static int tc1100_suspend(struct device *dev)
 {
        int ret;
 
@@ -239,10 +207,10 @@ static int tc1100_suspend(struct platform_device *dev, pm_message_t state)
        if (ret)
                return ret;
 
-       return ret;
+       return 0;
 }
 
-static int tc1100_resume(struct platform_device *dev)
+static int tc1100_resume(struct device *dev)
 {
        int ret;
 
@@ -254,34 +222,61 @@ static int tc1100_resume(struct platform_device *dev)
        if (ret)
                return ret;
 
-       return ret;
+       return 0;
 }
 
+static const struct dev_pm_ops tc1100_pm_ops = {
+       .suspend        = tc1100_suspend,
+       .resume         = tc1100_resume,
+       .freeze         = tc1100_suspend,
+       .restore        = tc1100_resume,
+};
+#endif
+
+static struct platform_driver tc1100_driver = {
+       .driver = {
+               .name = "tc1100-wmi",
+               .owner = THIS_MODULE,
+#ifdef CONFIG_PM
+               .pm = &tc1100_pm_ops,
+#endif
+       },
+       .remove = __devexit_p(tc1100_remove),
+};
+
 static int __init tc1100_init(void)
 {
-       int result = 0;
+       int error;
 
        if (!wmi_has_guid(GUID))
                return -ENODEV;
 
-       result = platform_driver_register(&tc1100_driver);
-       if (result)
-               return result;
-
        tc1100_device = platform_device_alloc("tc1100-wmi", -1);
-       platform_device_add(tc1100_device);
+       if (!tc1100_device)
+               return -ENOMEM;
+
+       error = platform_device_add(tc1100_device);
+       if (error)
+               goto err_device_put;
+
+       error = platform_driver_probe(&tc1100_driver, tc1100_probe);
+       if (error)
+               goto err_device_del;
 
        printk(TC1100_INFO "HP Compaq TC1100 Tablet WMI Extras loaded\n");
+       return 0;
 
-       return result;
+ err_device_del:
+       platform_device_del(tc1100_device);
+ err_device_put:
+       platform_device_put(tc1100_device);
+       return error;
 }
 
 static void __exit tc1100_exit(void)
 {
-       platform_device_del(tc1100_device);
+       platform_device_unregister(tc1100_device);
        platform_driver_unregister(&tc1100_driver);
-
-       printk(TC1100_INFO "HP Compaq TC1100 Tablet WMI Extras unloaded\n");
 }
 
 module_init(tc1100_init);
index 0ed84806f8ae26e24d48d334694c88ee2a465254..e67e4feb35cb814f85ad2df10bc1836c00cc79b6 100644 (file)
@@ -21,8 +21,8 @@
  *  02110-1301, USA.
  */
 
-#define TPACPI_VERSION "0.23"
-#define TPACPI_SYSFS_VERSION 0x020500
+#define TPACPI_VERSION "0.24"
+#define TPACPI_SYSFS_VERSION 0x020700
 
 /*
  *  Changelog:
@@ -61,6 +61,7 @@
 
 #include <linux/nvram.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/sysfs.h>
 #include <linux/backlight.h>
 #include <linux/fb.h>
 #include <linux/jiffies.h>
 #include <linux/workqueue.h>
 
+#include <sound/core.h>
+#include <sound/control.h>
+#include <sound/initval.h>
+
 #include <acpi/acpi_drivers.h>
 
 #include <linux/pci_ids.h>
@@ -231,6 +236,7 @@ enum tpacpi_hkey_event_t {
 #define TPACPI_DBG_HKEY                0x0008
 #define TPACPI_DBG_FAN         0x0010
 #define TPACPI_DBG_BRGHT       0x0020
+#define TPACPI_DBG_MIXER       0x0040
 
 #define onoff(status, bit) ((status) & (1 << (bit)) ? "on" : "off")
 #define enabled(status, bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -256,7 +262,7 @@ struct tp_acpi_drv_struct {
 struct ibm_struct {
        char *name;
 
-       int (*read) (char *);
+       int (*read) (struct seq_file *);
        int (*write) (char *);
        void (*exit) (void);
        void (*resume) (void);
@@ -298,6 +304,7 @@ static struct {
        u32 fan_ctrl_status_undef:1;
        u32 second_fan:1;
        u32 beep_needs_two_args:1;
+       u32 mixer_no_level_control:1;
        u32 input_device_registered:1;
        u32 platform_drv_registered:1;
        u32 platform_drv_attrs_registered:1;
@@ -309,6 +316,7 @@ static struct {
 
 static struct {
        u16 hotkey_mask_ff:1;
+       u16 volume_ctrl_forbidden:1;
 } tp_warned;
 
 struct thinkpad_id_data {
@@ -425,6 +433,12 @@ static void tpacpi_log_usertask(const char * const what)
          .ec = TPACPI_MATCH_ANY,               \
          .quirks = (__quirk) }
 
+#define TPACPI_QEC_LNV(__id1, __id2, __quirk)  \
+       { .vendor = PCI_VENDOR_ID_LENOVO,       \
+         .bios = TPACPI_MATCH_ANY,             \
+         .ec = TPID(__id1, __id2),             \
+         .quirks = (__quirk) }
+
 struct tpacpi_quirk {
        unsigned int vendor;
        u16 bios;
@@ -776,36 +790,25 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
  ****************************************************************************
  ****************************************************************************/
 
-static int dispatch_procfs_read(char *page, char **start, off_t off,
-                       int count, int *eof, void *data)
+static int dispatch_proc_show(struct seq_file *m, void *v)
 {
-       struct ibm_struct *ibm = data;
-       int len;
+       struct ibm_struct *ibm = m->private;
 
        if (!ibm || !ibm->read)
                return -EINVAL;
+       return ibm->read(m);
+}
 
-       len = ibm->read(page);
-       if (len < 0)
-               return len;
-
-       if (len <= off + count)
-               *eof = 1;
-       *start = page + off;
-       len -= off;
-       if (len > count)
-               len = count;
-       if (len < 0)
-               len = 0;
-
-       return len;
+static int dispatch_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, dispatch_proc_show, PDE(inode)->data);
 }
 
-static int dispatch_procfs_write(struct file *file,
+static ssize_t dispatch_proc_write(struct file *file,
                        const char __user *userbuf,
-                       unsigned long count, void *data)
+                       size_t count, loff_t *pos)
 {
-       struct ibm_struct *ibm = data;
+       struct ibm_struct *ibm = PDE(file->f_path.dentry->d_inode)->data;
        char *kernbuf;
        int ret;
 
@@ -834,6 +837,15 @@ static int dispatch_procfs_write(struct file *file,
        return ret;
 }
 
+static const struct file_operations dispatch_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = dispatch_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = dispatch_proc_write,
+};
+
 static char *next_cmd(char **cmds)
 {
        char *start = *cmds;
@@ -1006,11 +1018,8 @@ static int parse_strtoul(const char *buf,
 {
        char *endp;
 
-       while (*buf && isspace(*buf))
-               buf++;
-       *value = simple_strtoul(buf, &endp, 0);
-       while (*endp && isspace(*endp))
-               endp++;
+       *value = simple_strtoul(skip_spaces(buf), &endp, 0);
+       endp = skip_spaces(endp);
        if (*endp || *value > max)
                return -EINVAL;
 
@@ -1264,6 +1273,7 @@ static int __init tpacpi_new_rfkill(const enum tpacpi_rfk_id id,
        struct tpacpi_rfk *atp_rfk;
        int res;
        bool sw_state = false;
+       bool hw_state;
        int sw_status;
 
        BUG_ON(id >= TPACPI_RFK_SW_MAX || tpacpi_rfkill_switches[id]);
@@ -1298,7 +1308,8 @@ static int __init tpacpi_new_rfkill(const enum tpacpi_rfk_id id,
                        rfkill_init_sw_state(atp_rfk->rfkill, sw_state);
                }
        }
-       rfkill_set_hw_state(atp_rfk->rfkill, tpacpi_rfk_check_hwblock_state());
+       hw_state = tpacpi_rfk_check_hwblock_state();
+       rfkill_set_hw_state(atp_rfk->rfkill, hw_state);
 
        res = rfkill_register(atp_rfk->rfkill);
        if (res < 0) {
@@ -1311,6 +1322,9 @@ static int __init tpacpi_new_rfkill(const enum tpacpi_rfk_id id,
        }
 
        tpacpi_rfkill_switches[id] = atp_rfk;
+
+       printk(TPACPI_INFO "rfkill switch %s: radio is %sblocked\n",
+               name, (sw_state || hw_state) ? "" : "un");
        return 0;
 }
 
@@ -1383,12 +1397,10 @@ static ssize_t tpacpi_rfk_sysfs_enable_store(const enum tpacpi_rfk_id id,
 }
 
 /* procfs -------------------------------------------------------------- */
-static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, char *p)
+static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, struct seq_file *m)
 {
-       int len = 0;
-
        if (id >= TPACPI_RFK_SW_MAX)
-               len += sprintf(p + len, "status:\t\tnot supported\n");
+               seq_printf(m, "status:\t\tnot supported\n");
        else {
                int status;
 
@@ -1402,13 +1414,13 @@ static int tpacpi_rfk_procfs_read(const enum tpacpi_rfk_id id, char *p)
                                return status;
                }
 
-               len += sprintf(p + len, "status:\t\t%s\n",
+               seq_printf(m, "status:\t\t%s\n",
                                (status == TPACPI_RFK_RADIO_ON) ?
                                        "enabled" : "disabled");
-               len += sprintf(p + len, "commands:\tenable, disable\n");
+               seq_printf(m, "commands:\tenable, disable\n");
        }
 
-       return len;
+       return 0;
 }
 
 static int tpacpi_rfk_procfs_write(const enum tpacpi_rfk_id id, char *buf)
@@ -1779,7 +1791,7 @@ static const struct tpacpi_quirk tpacpi_bios_version_qtable[] __initconst = {
 
        TPV_QL1('7', '9',  'E', '3',  '5', '0'), /* T60/p */
        TPV_QL1('7', 'C',  'D', '2',  '2', '2'), /* R60, R60i */
-       TPV_QL0('7', 'E',  'D', '0'),            /* R60e, R60i */
+       TPV_QL1('7', 'E',  'D', '0',  '1', '5'), /* R60e, R60i */
 
        /*      BIOS FW    BIOS VERS  EC FW     EC VERS */
        TPV_QI2('1', 'W',  '9', '0',  '1', 'V', '2', '8'), /* R50e (1) */
@@ -1795,8 +1807,8 @@ static const struct tpacpi_quirk tpacpi_bios_version_qtable[] __initconst = {
        TPV_QI1('7', '4',  '6', '4',  '2', '7'), /* X41 (0) */
        TPV_QI1('7', '5',  '6', '0',  '2', '0'), /* X41t (0) */
 
-       TPV_QL0('7', 'B',  'D', '7'),            /* X60/s */
-       TPV_QL0('7', 'J',  '3', '0'),            /* X60t */
+       TPV_QL1('7', 'B',  'D', '7',  '4', '0'), /* X60/s */
+       TPV_QL1('7', 'J',  '3', '0',  '1', '3'), /* X60t */
 
        /* (0) - older versions lack DMI EC fw string and functionality */
        /* (1) - older versions known to lack functionality */
@@ -1886,14 +1898,11 @@ static int __init thinkpad_acpi_driver_init(struct ibm_init_struct *iibm)
        return 0;
 }
 
-static int thinkpad_acpi_driver_read(char *p)
+static int thinkpad_acpi_driver_read(struct seq_file *m)
 {
-       int len = 0;
-
-       len += sprintf(p + len, "driver:\t\t%s\n", TPACPI_DESC);
-       len += sprintf(p + len, "version:\t%s\n", TPACPI_VERSION);
-
-       return len;
+       seq_printf(m, "driver:\t\t%s\n", TPACPI_DESC);
+       seq_printf(m, "version:\t%s\n", TPACPI_VERSION);
+       return 0;
 }
 
 static struct ibm_struct thinkpad_acpi_driver_data = {
@@ -2189,7 +2198,8 @@ static int hotkey_mask_set(u32 mask)
                       fwmask, hotkey_acpi_mask);
        }
 
-       hotkey_mask_warn_incomplete_mask();
+       if (tpacpi_lifecycle != TPACPI_LIFE_EXITING)
+               hotkey_mask_warn_incomplete_mask();
 
        return rc;
 }
@@ -3185,6 +3195,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
        int res, i;
        int status;
        int hkeyv;
+       bool radiosw_state  = false;
+       bool tabletsw_state = false;
 
        unsigned long quirks;
 
@@ -3290,6 +3302,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
        if (dbg_wlswemul) {
                tp_features.hotkey_wlsw = 1;
+               radiosw_state = !!tpacpi_wlsw_emulstate;
                printk(TPACPI_INFO
                        "radio switch emulation enabled\n");
        } else
@@ -3297,6 +3310,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
        /* Not all thinkpads have a hardware radio switch */
        if (acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
                tp_features.hotkey_wlsw = 1;
+               radiosw_state = !!status;
                printk(TPACPI_INFO
                        "radio switch found; radios are %s\n",
                        enabled(status, 0));
@@ -3308,11 +3322,11 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
        /* For X41t, X60t, X61t Tablets... */
        if (!res && acpi_evalf(hkey_handle, &status, "MHKG", "qd")) {
                tp_features.hotkey_tablet = 1;
+               tabletsw_state = !!(status & TP_HOTKEY_TABLET_MASK);
                printk(TPACPI_INFO
                        "possible tablet mode switch found; "
                        "ThinkPad in %s mode\n",
-                       (status & TP_HOTKEY_TABLET_MASK)?
-                               "tablet" : "laptop");
+                       (tabletsw_state) ? "tablet" : "laptop");
                res = add_to_attr_set(hotkey_dev_attributes,
                                &dev_attr_hotkey_tablet_mode.attr);
        }
@@ -3347,16 +3361,14 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
                        TPACPI_HOTKEY_MAP_SIZE);
        }
 
-       set_bit(EV_KEY, tpacpi_inputdev->evbit);
-       set_bit(EV_MSC, tpacpi_inputdev->evbit);
-       set_bit(MSC_SCAN, tpacpi_inputdev->mscbit);
+       input_set_capability(tpacpi_inputdev, EV_MSC, MSC_SCAN);
        tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE;
        tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN;
        tpacpi_inputdev->keycode = hotkey_keycode_map;
        for (i = 0; i < TPACPI_HOTKEY_MAP_LEN; i++) {
                if (hotkey_keycode_map[i] != KEY_RESERVED) {
-                       set_bit(hotkey_keycode_map[i],
-                               tpacpi_inputdev->keybit);
+                       input_set_capability(tpacpi_inputdev, EV_KEY,
+                                               hotkey_keycode_map[i]);
                } else {
                        if (i < sizeof(hotkey_reserved_mask)*8)
                                hotkey_reserved_mask |= 1 << i;
@@ -3364,12 +3376,14 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
        }
 
        if (tp_features.hotkey_wlsw) {
-               set_bit(EV_SW, tpacpi_inputdev->evbit);
-               set_bit(SW_RFKILL_ALL, tpacpi_inputdev->swbit);
+               input_set_capability(tpacpi_inputdev, EV_SW, SW_RFKILL_ALL);
+               input_report_switch(tpacpi_inputdev,
+                                   SW_RFKILL_ALL, radiosw_state);
        }
        if (tp_features.hotkey_tablet) {
-               set_bit(EV_SW, tpacpi_inputdev->evbit);
-               set_bit(SW_TABLET_MODE, tpacpi_inputdev->swbit);
+               input_set_capability(tpacpi_inputdev, EV_SW, SW_TABLET_MODE);
+               input_report_switch(tpacpi_inputdev,
+                                   SW_TABLET_MODE, tabletsw_state);
        }
 
        /* Do not issue duplicate brightness change events to
@@ -3436,8 +3450,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
        tpacpi_inputdev->close = &hotkey_inputdev_close;
 
        hotkey_poll_setup_safe(true);
-       tpacpi_send_radiosw_update();
-       tpacpi_input_send_tabletsw();
 
        return 0;
 
@@ -3545,49 +3557,57 @@ static bool hotkey_notify_usrevent(const u32 hkey,
        }
 }
 
+static void thermal_dump_all_sensors(void);
+
 static bool hotkey_notify_thermal(const u32 hkey,
                                 bool *send_acpi_ev,
                                 bool *ignore_acpi_ev)
 {
+       bool known = true;
+
        /* 0x6000-0x6FFF: thermal alarms */
        *send_acpi_ev = true;
        *ignore_acpi_ev = false;
 
        switch (hkey) {
+       case TP_HKEY_EV_THM_TABLE_CHANGED:
+               printk(TPACPI_INFO
+                       "EC reports that Thermal Table has changed\n");
+               /* recommended action: do nothing, we don't have
+                * Lenovo ATM information */
+               return true;
        case TP_HKEY_EV_ALARM_BAT_HOT:
                printk(TPACPI_CRIT
                        "THERMAL ALARM: battery is too hot!\n");
                /* recommended action: warn user through gui */
-               return true;
+               break;
        case TP_HKEY_EV_ALARM_BAT_XHOT:
                printk(TPACPI_ALERT
                        "THERMAL EMERGENCY: battery is extremely hot!\n");
                /* recommended action: immediate sleep/hibernate */
-               return true;
+               break;
        case TP_HKEY_EV_ALARM_SENSOR_HOT:
                printk(TPACPI_CRIT
                        "THERMAL ALARM: "
                        "a sensor reports something is too hot!\n");
                /* recommended action: warn user through gui, that */
                /* some internal component is too hot */
-               return true;
+               break;
        case TP_HKEY_EV_ALARM_SENSOR_XHOT:
                printk(TPACPI_ALERT
                        "THERMAL EMERGENCY: "
                        "a sensor reports something is extremely hot!\n");
                /* recommended action: immediate sleep/hibernate */
-               return true;
-       case TP_HKEY_EV_THM_TABLE_CHANGED:
-               printk(TPACPI_INFO
-                       "EC reports that Thermal Table has changed\n");
-               /* recommended action: do nothing, we don't have
-                * Lenovo ATM information */
-               return true;
+               break;
        default:
                printk(TPACPI_ALERT
                         "THERMAL ALERT: unknown thermal alarm received\n");
-               return false;
+               known = false;
        }
+
+       thermal_dump_all_sensors();
+
+       return known;
 }
 
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
@@ -3730,14 +3750,13 @@ static void hotkey_resume(void)
 }
 
 /* procfs -------------------------------------------------------------- */
-static int hotkey_read(char *p)
+static int hotkey_read(struct seq_file *m)
 {
        int res, status;
-       int len = 0;
 
        if (!tp_features.hotkey) {
-               len += sprintf(p + len, "status:\t\tnot supported\n");
-               return len;
+               seq_printf(m, "status:\t\tnot supported\n");
+               return 0;
        }
 
        if (mutex_lock_killable(&hotkey_mutex))
@@ -3749,17 +3768,16 @@ static int hotkey_read(char *p)
        if (res)
                return res;
 
-       len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
+       seq_printf(m, "status:\t\t%s\n", enabled(status, 0));
        if (hotkey_all_mask) {
-               len += sprintf(p + len, "mask:\t\t0x%08x\n", hotkey_user_mask);
-               len += sprintf(p + len,
-                              "commands:\tenable, disable, reset, <mask>\n");
+               seq_printf(m, "mask:\t\t0x%08x\n", hotkey_user_mask);
+               seq_printf(m, "commands:\tenable, disable, reset, <mask>\n");
        } else {
-               len += sprintf(p + len, "mask:\t\tnot supported\n");
-               len += sprintf(p + len, "commands:\tenable, disable, reset\n");
+               seq_printf(m, "mask:\t\tnot supported\n");
+               seq_printf(m, "commands:\tenable, disable, reset\n");
        }
 
-       return len;
+       return 0;
 }
 
 static void hotkey_enabledisable_warn(bool enable)
@@ -3866,15 +3884,6 @@ enum {
 
 #define TPACPI_RFK_BLUETOOTH_SW_NAME   "tpacpi_bluetooth_sw"
 
-static void bluetooth_suspend(pm_message_t state)
-{
-       /* Try to make sure radio will resume powered off */
-       if (!acpi_evalf(NULL, NULL, "\\BLTH", "vd",
-                  TP_ACPI_BLTH_PWR_OFF_ON_RESUME))
-               vdbg_printk(TPACPI_DBG_RFKILL,
-                       "bluetooth power down on resume request failed\n");
-}
-
 static int bluetooth_get_status(void)
 {
        int status;
@@ -3908,10 +3917,9 @@ static int bluetooth_set_status(enum tpacpi_rfkill_state state)
 #endif
 
        /* We make sure to keep TP_ACPI_BLUETOOTH_RESUMECTRL off */
+       status = TP_ACPI_BLUETOOTH_RESUMECTRL;
        if (state == TPACPI_RFK_RADIO_ON)
-               status = TP_ACPI_BLUETOOTH_RADIOSSW;
-       else
-               status = 0;
+               status |= TP_ACPI_BLUETOOTH_RADIOSSW;
 
        if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
                return -EIO;
@@ -4035,9 +4043,9 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
 }
 
 /* procfs -------------------------------------------------------------- */
-static int bluetooth_read(char *p)
+static int bluetooth_read(struct seq_file *m)
 {
-       return tpacpi_rfk_procfs_read(TPACPI_RFK_BLUETOOTH_SW_ID, p);
+       return tpacpi_rfk_procfs_read(TPACPI_RFK_BLUETOOTH_SW_ID, m);
 }
 
 static int bluetooth_write(char *buf)
@@ -4050,7 +4058,6 @@ static struct ibm_struct bluetooth_driver_data = {
        .read = bluetooth_read,
        .write = bluetooth_write,
        .exit = bluetooth_exit,
-       .suspend = bluetooth_suspend,
        .shutdown = bluetooth_shutdown,
 };
 
@@ -4068,15 +4075,6 @@ enum {
 
 #define TPACPI_RFK_WWAN_SW_NAME                "tpacpi_wwan_sw"
 
-static void wan_suspend(pm_message_t state)
-{
-       /* Try to make sure radio will resume powered off */
-       if (!acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
-                  TP_ACPI_WGSV_PWR_OFF_ON_RESUME))
-               vdbg_printk(TPACPI_DBG_RFKILL,
-                       "WWAN power down on resume request failed\n");
-}
-
 static int wan_get_status(void)
 {
        int status;
@@ -4109,11 +4107,10 @@ static int wan_set_status(enum tpacpi_rfkill_state state)
        }
 #endif
 
-       /* We make sure to keep TP_ACPI_WANCARD_RESUMECTRL off */
+       /* We make sure to set TP_ACPI_WANCARD_RESUMECTRL */
+       status = TP_ACPI_WANCARD_RESUMECTRL;
        if (state == TPACPI_RFK_RADIO_ON)
-               status = TP_ACPI_WANCARD_RADIOSSW;
-       else
-               status = 0;
+               status |= TP_ACPI_WANCARD_RADIOSSW;
 
        if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
                return -EIO;
@@ -4236,9 +4233,9 @@ static int __init wan_init(struct ibm_init_struct *iibm)
 }
 
 /* procfs -------------------------------------------------------------- */
-static int wan_read(char *p)
+static int wan_read(struct seq_file *m)
 {
-       return tpacpi_rfk_procfs_read(TPACPI_RFK_WWAN_SW_ID, p);
+       return tpacpi_rfk_procfs_read(TPACPI_RFK_WWAN_SW_ID, m);
 }
 
 static int wan_write(char *buf)
@@ -4251,7 +4248,6 @@ static struct ibm_struct wan_driver_data = {
        .read = wan_read,
        .write = wan_write,
        .exit = wan_exit,
-       .suspend = wan_suspend,
        .shutdown = wan_shutdown,
 };
 
@@ -4614,14 +4610,13 @@ static int video_expand_toggle(void)
        /* not reached */
 }
 
-static int video_read(char *p)
+static int video_read(struct seq_file *m)
 {
        int status, autosw;
-       int len = 0;
 
        if (video_supported == TPACPI_VIDEO_NONE) {
-               len += sprintf(p + len, "status:\t\tnot supported\n");
-               return len;
+               seq_printf(m, "status:\t\tnot supported\n");
+               return 0;
        }
 
        status = video_outputsw_get();
@@ -4632,20 +4627,20 @@ static int video_read(char *p)
        if (autosw < 0)
                return autosw;
 
-       len += sprintf(p + len, "status:\t\tsupported\n");
-       len += sprintf(p + len, "lcd:\t\t%s\n", enabled(status, 0));
-       len += sprintf(p + len, "crt:\t\t%s\n", enabled(status, 1));
+       seq_printf(m, "status:\t\tsupported\n");
+       seq_printf(m, "lcd:\t\t%s\n", enabled(status, 0));
+       seq_printf(m, "crt:\t\t%s\n", enabled(status, 1));
        if (video_supported == TPACPI_VIDEO_NEW)
-               len += sprintf(p + len, "dvi:\t\t%s\n", enabled(status, 3));
-       len += sprintf(p + len, "auto:\t\t%s\n", enabled(autosw, 0));
-       len += sprintf(p + len, "commands:\tlcd_enable, lcd_disable\n");
-       len += sprintf(p + len, "commands:\tcrt_enable, crt_disable\n");
+               seq_printf(m, "dvi:\t\t%s\n", enabled(status, 3));
+       seq_printf(m, "auto:\t\t%s\n", enabled(autosw, 0));
+       seq_printf(m, "commands:\tlcd_enable, lcd_disable\n");
+       seq_printf(m, "commands:\tcrt_enable, crt_disable\n");
        if (video_supported == TPACPI_VIDEO_NEW)
-               len += sprintf(p + len, "commands:\tdvi_enable, dvi_disable\n");
-       len += sprintf(p + len, "commands:\tauto_enable, auto_disable\n");
-       len += sprintf(p + len, "commands:\tvideo_switch, expand_toggle\n");
+               seq_printf(m, "commands:\tdvi_enable, dvi_disable\n");
+       seq_printf(m, "commands:\tauto_enable, auto_disable\n");
+       seq_printf(m, "commands:\tvideo_switch, expand_toggle\n");
 
-       return len;
+       return 0;
 }
 
 static int video_write(char *buf)
@@ -4837,25 +4832,24 @@ static void light_exit(void)
                flush_workqueue(tpacpi_wq);
 }
 
-static int light_read(char *p)
+static int light_read(struct seq_file *m)
 {
-       int len = 0;
        int status;
 
        if (!tp_features.light) {
-               len += sprintf(p + len, "status:\t\tnot supported\n");
+               seq_printf(m, "status:\t\tnot supported\n");
        } else if (!tp_features.light_status) {
-               len += sprintf(p + len, "status:\t\tunknown\n");
-               len += sprintf(p + len, "commands:\ton, off\n");
+               seq_printf(m, "status:\t\tunknown\n");
+               seq_printf(m, "commands:\ton, off\n");
        } else {
                status = light_get_status();
                if (status < 0)
                        return status;
-               len += sprintf(p + len, "status:\t\t%s\n", onoff(status, 0));
-               len += sprintf(p + len, "commands:\ton, off\n");
+               seq_printf(m, "status:\t\t%s\n", onoff(status, 0));
+               seq_printf(m, "commands:\ton, off\n");
        }
 
-       return len;
+       return 0;
 }
 
 static int light_write(char *buf)
@@ -4933,20 +4927,18 @@ static void cmos_exit(void)
        device_remove_file(&tpacpi_pdev->dev, &dev_attr_cmos_command);
 }
 
-static int cmos_read(char *p)
+static int cmos_read(struct seq_file *m)
 {
-       int len = 0;
-
        /* cmos not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p,
           R30, R31, T20-22, X20-21 */
        if (!cmos_handle)
-               len += sprintf(p + len, "status:\t\tnot supported\n");
+               seq_printf(m, "status:\t\tnot supported\n");
        else {
-               len += sprintf(p + len, "status:\t\tsupported\n");
-               len += sprintf(p + len, "commands:\t<cmd> (<cmd> is 0-21)\n");
+               seq_printf(m, "status:\t\tsupported\n");
+               seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n");
        }
 
-       return len;
+       return 0;
 }
 
 static int cmos_write(char *buf)
@@ -5321,15 +5313,13 @@ static int __init led_init(struct ibm_init_struct *iibm)
        ((s) == TPACPI_LED_OFF ? "off" : \
                ((s) == TPACPI_LED_ON ? "on" : "blinking"))
 
-static int led_read(char *p)
+static int led_read(struct seq_file *m)
 {
-       int len = 0;
-
        if (!led_supported) {
-               len += sprintf(p + len, "status:\t\tnot supported\n");
-               return len;
+               seq_printf(m, "status:\t\tnot supported\n");
+               return 0;
        }
-       len += sprintf(p + len, "status:\t\tsupported\n");
+       seq_printf(m, "status:\t\tsupported\n");
 
        if (led_supported == TPACPI_LED_570) {
                /* 570 */
@@ -5338,15 +5328,15 @@ static int led_read(char *p)
                        status = led_get_status(i);
                        if (status < 0)
                                return -EIO;
-                       len += sprintf(p + len, "%d:\t\t%s\n",
+                       seq_printf(m, "%d:\t\t%s\n",
                                       i, str_led_status(status));
                }
        }
 
-       len += sprintf(p + len, "commands:\t"
+       seq_printf(m, "commands:\t"
                       "<led> on, <led> off, <led> blink (<led> is 0-15)\n");
 
-       return len;
+       return 0;
 }
 
 static int led_write(char *buf)
@@ -5419,18 +5409,16 @@ static int __init beep_init(struct ibm_init_struct *iibm)
        return (beep_handle)? 0 : 1;
 }
 
-static int beep_read(char *p)
+static int beep_read(struct seq_file *m)
 {
-       int len = 0;
-
        if (!beep_handle)
-               len += sprintf(p + len, "status:\t\tnot supported\n");
+               seq_printf(m, "status:\t\tnot supported\n");
        else {
-               len += sprintf(p + len, "status:\t\tsupported\n");
-               len += sprintf(p + len, "commands:\t<cmd> (<cmd> is 0-17)\n");
+               seq_printf(m, "status:\t\tsupported\n");
+               seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n");
        }
 
-       return len;
+       return 0;
 }
 
 static int beep_write(char *buf)
@@ -5483,8 +5471,11 @@ enum { /* TPACPI_THERMAL_TPEC_* */
        TP_EC_THERMAL_TMP0 = 0x78,      /* ACPI EC regs TMP 0..7 */
        TP_EC_THERMAL_TMP8 = 0xC0,      /* ACPI EC regs TMP 8..15 */
        TP_EC_THERMAL_TMP_NA = -128,    /* ACPI EC sensor not available */
+
+       TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
 };
 
+
 #define TPACPI_MAX_THERMAL_SENSORS 16  /* Max thermal sensors supported */
 struct ibm_thermal_sensors_struct {
        s32 temp[TPACPI_MAX_THERMAL_SENSORS];
@@ -5574,6 +5565,28 @@ static int thermal_get_sensors(struct ibm_thermal_sensors_struct *s)
        return n;
 }
 
+static void thermal_dump_all_sensors(void)
+{
+       int n, i;
+       struct ibm_thermal_sensors_struct t;
+
+       n = thermal_get_sensors(&t);
+       if (n <= 0)
+               return;
+
+       printk(TPACPI_NOTICE
+               "temperatures (Celsius):");
+
+       for (i = 0; i < n; i++) {
+               if (t.temp[i] != TPACPI_THERMAL_SENSOR_NA)
+                       printk(KERN_CONT " %d", (int)(t.temp[i] / 1000));
+               else
+                       printk(KERN_CONT " N/A");
+       }
+
+       printk(KERN_CONT "\n");
+}
+
 /* sysfs temp##_input -------------------------------------------------- */
 
 static ssize_t thermal_temp_input_show(struct device *dev,
@@ -5589,7 +5602,7 @@ static ssize_t thermal_temp_input_show(struct device *dev,
        res = thermal_get_sensor(idx, &value);
        if (res)
                return res;
-       if (value == TP_EC_THERMAL_TMP_NA * 1000)
+       if (value == TPACPI_THERMAL_SENSOR_NA)
                return -ENXIO;
 
        return snprintf(buf, PAGE_SIZE, "%d\n", value);
@@ -5766,9 +5779,8 @@ static void thermal_exit(void)
        }
 }
 
-static int thermal_read(char *p)
+static int thermal_read(struct seq_file *m)
 {
-       int len = 0;
        int n, i;
        struct ibm_thermal_sensors_struct t;
 
@@ -5776,16 +5788,16 @@ static int thermal_read(char *p)
        if (unlikely(n < 0))
                return n;
 
-       len += sprintf(p + len, "temperatures:\t");
+       seq_printf(m, "temperatures:\t");
 
        if (n > 0) {
                for (i = 0; i < (n - 1); i++)
-                       len += sprintf(p + len, "%d ", t.temp[i] / 1000);
-               len += sprintf(p + len, "%d\n", t.temp[i] / 1000);
+                       seq_printf(m, "%d ", t.temp[i] / 1000);
+               seq_printf(m, "%d\n", t.temp[i] / 1000);
        } else
-               len += sprintf(p + len, "not supported\n");
+               seq_printf(m, "not supported\n");
 
-       return len;
+       return 0;
 }
 
 static struct ibm_struct thermal_driver_data = {
@@ -5800,39 +5812,38 @@ static struct ibm_struct thermal_driver_data = {
 
 static u8 ecdump_regs[256];
 
-static int ecdump_read(char *p)
+static int ecdump_read(struct seq_file *m)
 {
-       int len = 0;
        int i, j;
        u8 v;
 
-       len += sprintf(p + len, "EC      "
+       seq_printf(m, "EC      "
                       " +00 +01 +02 +03 +04 +05 +06 +07"
                       " +08 +09 +0a +0b +0c +0d +0e +0f\n");
        for (i = 0; i < 256; i += 16) {
-               len += sprintf(p + len, "EC 0x%02x:", i);
+               seq_printf(m, "EC 0x%02x:", i);
                for (j = 0; j < 16; j++) {
                        if (!acpi_ec_read(i + j, &v))
                                break;
                        if (v != ecdump_regs[i + j])
-                               len += sprintf(p + len, " *%02x", v);
+                               seq_printf(m, " *%02x", v);
                        else
-                               len += sprintf(p + len, "  %02x", v);
+                               seq_printf(m, "  %02x", v);
                        ecdump_regs[i + j] = v;
                }
-               len += sprintf(p + len, "\n");
+               seq_putc(m, '\n');
                if (j != 16)
                        break;
        }
 
        /* These are way too dangerous to advertise openly... */
 #if 0
-       len += sprintf(p + len, "commands:\t0x<offset> 0x<value>"
+       seq_printf(m, "commands:\t0x<offset> 0x<value>"
                       " (<offset> is 00-ff, <value> is 00-ff)\n");
-       len += sprintf(p + len, "commands:\t0x<offset> <value>  "
+       seq_printf(m, "commands:\t0x<offset> <value>  "
                       " (<offset> is 00-ff, <value> is 0-255)\n");
 #endif
-       return len;
+       return 0;
 }
 
 static int ecdump_write(char *buf)
@@ -6095,6 +6106,12 @@ static int brightness_get(struct backlight_device *bd)
        return status & TP_EC_BACKLIGHT_LVLMSK;
 }
 
+static void tpacpi_brightness_notify_change(void)
+{
+       backlight_force_update(ibm_backlight_device,
+                              BACKLIGHT_UPDATE_HOTKEY);
+}
+
 static struct backlight_ops ibm_backlight_data = {
        .get_brightness = brightness_get,
        .update_status  = brightness_update_status,
@@ -6123,8 +6140,8 @@ static const struct tpacpi_quirk brightness_quirk_table[] __initconst = {
 
        /* Models with Intel Extreme Graphics 2 */
        TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_NOEC),
-       TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC),
-       TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC),
+       TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
+       TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
 
        /* Models with Intel GMA900 */
        TPACPI_Q_IBM('7', '0', TPACPI_BRGHT_Q_NOEC),    /* T43, R52 */
@@ -6249,6 +6266,12 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
        ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK;
        backlight_update_status(ibm_backlight_device);
 
+       vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_BRGHT,
+                       "brightness: registering brightness hotkeys "
+                       "as change notification\n");
+       tpacpi_hotkey_driver_mask_set(hotkey_driver_mask
+                               | TP_ACPI_HKEY_BRGHTUP_MASK
+                               | TP_ACPI_HKEY_BRGHTDWN_MASK);;
        return 0;
 }
 
@@ -6273,23 +6296,22 @@ static void brightness_exit(void)
        tpacpi_brightness_checkpoint_nvram();
 }
 
-static int brightness_read(char *p)
+static int brightness_read(struct seq_file *m)
 {
-       int len = 0;
        int level;
 
        level = brightness_get(NULL);
        if (level < 0) {
-               len += sprintf(p + len, "level:\t\tunreadable\n");
+               seq_printf(m, "level:\t\tunreadable\n");
        } else {
-               len += sprintf(p + len, "level:\t\t%d\n", level);
-               len += sprintf(p + len, "commands:\tup, down\n");
-               len += sprintf(p + len, "commands:\tlevel <level>"
+               seq_printf(m, "level:\t\t%d\n", level);
+               seq_printf(m, "commands:\tup, down\n");
+               seq_printf(m, "commands:\tlevel <level>"
                               " (<level> is 0-%d)\n",
                               (tp_features.bright_16levels) ? 15 : 7);
        }
 
-       return len;
+       return 0;
 }
 
 static int brightness_write(char *buf)
@@ -6325,6 +6347,9 @@ static int brightness_write(char *buf)
         * Doing it this way makes the syscall restartable in case of EINTR
         */
        rc = brightness_set(level);
+       if (!rc && ibm_backlight_device)
+               backlight_force_update(ibm_backlight_device,
+                                       BACKLIGHT_UPDATE_SYSFS);
        return (rc == -EINTR)? -ERESTARTSYS : rc;
 }
 
@@ -6341,101 +6366,685 @@ static struct ibm_struct brightness_driver_data = {
  * Volume subdriver
  */
 
-static int volume_offset = 0x30;
+/*
+ * IBM ThinkPads have a simple volume controller with MUTE gating.
+ * Very early Lenovo ThinkPads follow the IBM ThinkPad spec.
+ *
+ * Since the *61 series (and probably also the later *60 series), Lenovo
+ * ThinkPads only implement the MUTE gate.
+ *
+ * EC register 0x30
+ *   Bit 6: MUTE (1 mutes sound)
+ *   Bit 3-0: Volume
+ *   Other bits should be zero as far as we know.
+ *
+ * This is also stored in CMOS NVRAM, byte 0x60, bit 6 (MUTE), and
+ * bits 3-0 (volume).  Other bits in NVRAM may have other functions,
+ * such as bit 7 which is used to detect repeated presses of MUTE,
+ * and we leave them unchanged.
+ */
+
+#ifdef CONFIG_THINKPAD_ACPI_ALSA_SUPPORT
+
+#define TPACPI_ALSA_DRVNAME  "ThinkPad EC"
+#define TPACPI_ALSA_SHRTNAME "ThinkPad Console Audio Control"
+#define TPACPI_ALSA_MIXERNAME TPACPI_ALSA_SHRTNAME
+
+static int alsa_index = ~((1 << (SNDRV_CARDS - 3)) - 1); /* last three slots */
+static char *alsa_id = "ThinkPadEC";
+static int alsa_enable = SNDRV_DEFAULT_ENABLE1;
+
+struct tpacpi_alsa_data {
+       struct snd_card *card;
+       struct snd_ctl_elem_id *ctl_mute_id;
+       struct snd_ctl_elem_id *ctl_vol_id;
+};
 
-static int volume_read(char *p)
+static struct snd_card *alsa_card;
+
+enum {
+       TP_EC_AUDIO = 0x30,
+
+       /* TP_EC_AUDIO bits */
+       TP_EC_AUDIO_MUTESW = 6,
+
+       /* TP_EC_AUDIO bitmasks */
+       TP_EC_AUDIO_LVL_MSK = 0x0F,
+       TP_EC_AUDIO_MUTESW_MSK = (1 << TP_EC_AUDIO_MUTESW),
+
+       /* Maximum volume */
+       TP_EC_VOLUME_MAX = 14,
+};
+
+enum tpacpi_volume_access_mode {
+       TPACPI_VOL_MODE_AUTO = 0,       /* Not implemented yet */
+       TPACPI_VOL_MODE_EC,             /* Pure EC control */
+       TPACPI_VOL_MODE_UCMS_STEP,      /* UCMS step-based control: N/A */
+       TPACPI_VOL_MODE_ECNVRAM,        /* EC control w/ NVRAM store */
+       TPACPI_VOL_MODE_MAX
+};
+
+enum tpacpi_volume_capabilities {
+       TPACPI_VOL_CAP_AUTO = 0,        /* Use white/blacklist */
+       TPACPI_VOL_CAP_VOLMUTE,         /* Output vol and mute */
+       TPACPI_VOL_CAP_MUTEONLY,        /* Output mute only */
+       TPACPI_VOL_CAP_MAX
+};
+
+static enum tpacpi_volume_access_mode volume_mode =
+       TPACPI_VOL_MODE_MAX;
+
+static enum tpacpi_volume_capabilities volume_capabilities;
+static int volume_control_allowed;
+
+/*
+ * Used to syncronize writers to TP_EC_AUDIO and
+ * TP_NVRAM_ADDR_MIXER, as we need to do read-modify-write
+ */
+static struct mutex volume_mutex;
+
+static void tpacpi_volume_checkpoint_nvram(void)
 {
-       int len = 0;
-       u8 level;
+       u8 lec = 0;
+       u8 b_nvram;
+       u8 ec_mask;
 
-       if (!acpi_ec_read(volume_offset, &level)) {
-               len += sprintf(p + len, "level:\t\tunreadable\n");
+       if (volume_mode != TPACPI_VOL_MODE_ECNVRAM)
+               return;
+       if (!volume_control_allowed)
+               return;
+
+       vdbg_printk(TPACPI_DBG_MIXER,
+               "trying to checkpoint mixer state to NVRAM...\n");
+
+       if (tp_features.mixer_no_level_control)
+               ec_mask = TP_EC_AUDIO_MUTESW_MSK;
+       else
+               ec_mask = TP_EC_AUDIO_MUTESW_MSK | TP_EC_AUDIO_LVL_MSK;
+
+       if (mutex_lock_killable(&volume_mutex) < 0)
+               return;
+
+       if (unlikely(!acpi_ec_read(TP_EC_AUDIO, &lec)))
+               goto unlock;
+       lec &= ec_mask;
+       b_nvram = nvram_read_byte(TP_NVRAM_ADDR_MIXER);
+
+       if (lec != (b_nvram & ec_mask)) {
+               /* NVRAM needs update */
+               b_nvram &= ~ec_mask;
+               b_nvram |= lec;
+               nvram_write_byte(b_nvram, TP_NVRAM_ADDR_MIXER);
+               dbg_printk(TPACPI_DBG_MIXER,
+                          "updated NVRAM mixer status to 0x%02x (0x%02x)\n",
+                          (unsigned int) lec, (unsigned int) b_nvram);
        } else {
-               len += sprintf(p + len, "level:\t\t%d\n", level & 0xf);
-               len += sprintf(p + len, "mute:\t\t%s\n", onoff(level, 6));
-               len += sprintf(p + len, "commands:\tup, down, mute\n");
-               len += sprintf(p + len, "commands:\tlevel <level>"
-                              " (<level> is 0-15)\n");
+               vdbg_printk(TPACPI_DBG_MIXER,
+                          "NVRAM mixer status already is 0x%02x (0x%02x)\n",
+                          (unsigned int) lec, (unsigned int) b_nvram);
        }
 
-       return len;
+unlock:
+       mutex_unlock(&volume_mutex);
 }
 
-static int volume_write(char *buf)
+static int volume_get_status_ec(u8 *status)
 {
-       int cmos_cmd, inc, i;
-       u8 level, mute;
-       int new_level, new_mute;
-       char *cmd;
+       u8 s;
 
-       while ((cmd = next_cmd(&buf))) {
-               if (!acpi_ec_read(volume_offset, &level))
-                       return -EIO;
-               new_mute = mute = level & 0x40;
-               new_level = level = level & 0xf;
+       if (!acpi_ec_read(TP_EC_AUDIO, &s))
+               return -EIO;
 
-               if (strlencmp(cmd, "up") == 0) {
-                       if (mute)
-                               new_mute = 0;
-                       else
-                               new_level = level == 15 ? 15 : level + 1;
-               } else if (strlencmp(cmd, "down") == 0) {
-                       if (mute)
-                               new_mute = 0;
-                       else
-                               new_level = level == 0 ? 0 : level - 1;
-               } else if (sscanf(cmd, "level %d", &new_level) == 1 &&
-                          new_level >= 0 && new_level <= 15) {
-                       /* new_level set */
-               } else if (strlencmp(cmd, "mute") == 0) {
-                       new_mute = 0x40;
-               } else
-                       return -EINVAL;
+       *status = s;
 
-               if (new_level != level) {
-                       /* mute doesn't change */
+       dbg_printk(TPACPI_DBG_MIXER, "status 0x%02x\n", s);
 
-                       cmos_cmd = (new_level > level) ?
-                                       TP_CMOS_VOLUME_UP : TP_CMOS_VOLUME_DOWN;
-                       inc = new_level > level ? 1 : -1;
+       return 0;
+}
 
-                       if (mute && (issue_thinkpad_cmos_command(cmos_cmd) ||
-                                    !acpi_ec_write(volume_offset, level)))
-                               return -EIO;
+static int volume_get_status(u8 *status)
+{
+       return volume_get_status_ec(status);
+}
+
+static int volume_set_status_ec(const u8 status)
+{
+       if (!acpi_ec_write(TP_EC_AUDIO, status))
+               return -EIO;
 
-                       for (i = level; i != new_level; i += inc)
-                               if (issue_thinkpad_cmos_command(cmos_cmd) ||
-                                   !acpi_ec_write(volume_offset, i + inc))
-                                       return -EIO;
+       dbg_printk(TPACPI_DBG_MIXER, "set EC mixer to 0x%02x\n", status);
 
-                       if (mute &&
-                           (issue_thinkpad_cmos_command(TP_CMOS_VOLUME_MUTE) ||
-                            !acpi_ec_write(volume_offset, new_level + mute))) {
-                               return -EIO;
-                       }
+       return 0;
+}
+
+static int volume_set_status(const u8 status)
+{
+       return volume_set_status_ec(status);
+}
+
+static int volume_set_mute_ec(const bool mute)
+{
+       int rc;
+       u8 s, n;
+
+       if (mutex_lock_killable(&volume_mutex) < 0)
+               return -EINTR;
+
+       rc = volume_get_status_ec(&s);
+       if (rc)
+               goto unlock;
+
+       n = (mute) ? s | TP_EC_AUDIO_MUTESW_MSK :
+                    s & ~TP_EC_AUDIO_MUTESW_MSK;
+
+       if (n != s)
+               rc = volume_set_status_ec(n);
+
+unlock:
+       mutex_unlock(&volume_mutex);
+       return rc;
+}
+
+static int volume_set_mute(const bool mute)
+{
+       dbg_printk(TPACPI_DBG_MIXER, "trying to %smute\n",
+                  (mute) ? "" : "un");
+       return volume_set_mute_ec(mute);
+}
+
+static int volume_set_volume_ec(const u8 vol)
+{
+       int rc;
+       u8 s, n;
+
+       if (vol > TP_EC_VOLUME_MAX)
+               return -EINVAL;
+
+       if (mutex_lock_killable(&volume_mutex) < 0)
+               return -EINTR;
+
+       rc = volume_get_status_ec(&s);
+       if (rc)
+               goto unlock;
+
+       n = (s & ~TP_EC_AUDIO_LVL_MSK) | vol;
+
+       if (n != s)
+               rc = volume_set_status_ec(n);
+
+unlock:
+       mutex_unlock(&volume_mutex);
+       return rc;
+}
+
+static int volume_set_volume(const u8 vol)
+{
+       dbg_printk(TPACPI_DBG_MIXER,
+                  "trying to set volume level to %hu\n", vol);
+       return volume_set_volume_ec(vol);
+}
+
+static void volume_alsa_notify_change(void)
+{
+       struct tpacpi_alsa_data *d;
+
+       if (alsa_card && alsa_card->private_data) {
+               d = alsa_card->private_data;
+               if (d->ctl_mute_id)
+                       snd_ctl_notify(alsa_card,
+                                       SNDRV_CTL_EVENT_MASK_VALUE,
+                                       d->ctl_mute_id);
+               if (d->ctl_vol_id)
+                       snd_ctl_notify(alsa_card,
+                                       SNDRV_CTL_EVENT_MASK_VALUE,
+                                       d->ctl_vol_id);
+       }
+}
+
+static int volume_alsa_vol_info(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_info *uinfo)
+{
+       uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+       uinfo->count = 1;
+       uinfo->value.integer.min = 0;
+       uinfo->value.integer.max = TP_EC_VOLUME_MAX;
+       return 0;
+}
+
+static int volume_alsa_vol_get(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       u8 s;
+       int rc;
+
+       rc = volume_get_status(&s);
+       if (rc < 0)
+               return rc;
+
+       ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK;
+       return 0;
+}
+
+static int volume_alsa_vol_put(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       return volume_set_volume(ucontrol->value.integer.value[0]);
+}
+
+#define volume_alsa_mute_info snd_ctl_boolean_mono_info
+
+static int volume_alsa_mute_get(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       u8 s;
+       int rc;
+
+       rc = volume_get_status(&s);
+       if (rc < 0)
+               return rc;
+
+       ucontrol->value.integer.value[0] =
+                               (s & TP_EC_AUDIO_MUTESW_MSK) ? 0 : 1;
+       return 0;
+}
+
+static int volume_alsa_mute_put(struct snd_kcontrol *kcontrol,
+                               struct snd_ctl_elem_value *ucontrol)
+{
+       return volume_set_mute(!ucontrol->value.integer.value[0]);
+}
+
+static struct snd_kcontrol_new volume_alsa_control_vol __devinitdata = {
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name = "Console Playback Volume",
+       .index = 0,
+       .access = SNDRV_CTL_ELEM_ACCESS_READ,
+       .info = volume_alsa_vol_info,
+       .get = volume_alsa_vol_get,
+};
+
+static struct snd_kcontrol_new volume_alsa_control_mute __devinitdata = {
+       .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+       .name = "Console Playback Switch",
+       .index = 0,
+       .access = SNDRV_CTL_ELEM_ACCESS_READ,
+       .info = volume_alsa_mute_info,
+       .get = volume_alsa_mute_get,
+};
+
+static void volume_suspend(pm_message_t state)
+{
+       tpacpi_volume_checkpoint_nvram();
+}
+
+static void volume_resume(void)
+{
+       volume_alsa_notify_change();
+}
+
+static void volume_shutdown(void)
+{
+       tpacpi_volume_checkpoint_nvram();
+}
+
+static void volume_exit(void)
+{
+       if (alsa_card) {
+               snd_card_free(alsa_card);
+               alsa_card = NULL;
+       }
+
+       tpacpi_volume_checkpoint_nvram();
+}
+
+static int __init volume_create_alsa_mixer(void)
+{
+       struct snd_card *card;
+       struct tpacpi_alsa_data *data;
+       struct snd_kcontrol *ctl_vol;
+       struct snd_kcontrol *ctl_mute;
+       int rc;
+
+       rc = snd_card_create(alsa_index, alsa_id, THIS_MODULE,
+                           sizeof(struct tpacpi_alsa_data), &card);
+       if (rc < 0 || !card) {
+               printk(TPACPI_ERR
+                       "Failed to create ALSA card structures: %d\n", rc);
+               return 1;
+       }
+
+       BUG_ON(!card->private_data);
+       data = card->private_data;
+       data->card = card;
+
+       strlcpy(card->driver, TPACPI_ALSA_DRVNAME,
+               sizeof(card->driver));
+       strlcpy(card->shortname, TPACPI_ALSA_SHRTNAME,
+               sizeof(card->shortname));
+       snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s",
+                (thinkpad_id.ec_version_str) ?
+                       thinkpad_id.ec_version_str : "(unknown)");
+       snprintf(card->longname, sizeof(card->longname),
+                "%s at EC reg 0x%02x, fw %s", card->shortname, TP_EC_AUDIO,
+                (thinkpad_id.ec_version_str) ?
+                       thinkpad_id.ec_version_str : "unknown");
+
+       if (volume_control_allowed) {
+               volume_alsa_control_vol.put = volume_alsa_vol_put;
+               volume_alsa_control_vol.access =
+                               SNDRV_CTL_ELEM_ACCESS_READWRITE;
+
+               volume_alsa_control_mute.put = volume_alsa_mute_put;
+               volume_alsa_control_mute.access =
+                               SNDRV_CTL_ELEM_ACCESS_READWRITE;
+       }
+
+       if (!tp_features.mixer_no_level_control) {
+               ctl_vol = snd_ctl_new1(&volume_alsa_control_vol, NULL);
+               rc = snd_ctl_add(card, ctl_vol);
+               if (rc < 0) {
+                       printk(TPACPI_ERR
+                               "Failed to create ALSA volume control: %d\n",
+                               rc);
+                       goto err_exit;
                }
+               data->ctl_vol_id = &ctl_vol->id;
+       }
 
-               if (new_mute != mute) {
-                       /* level doesn't change */
+       ctl_mute = snd_ctl_new1(&volume_alsa_control_mute, NULL);
+       rc = snd_ctl_add(card, ctl_mute);
+       if (rc < 0) {
+               printk(TPACPI_ERR "Failed to create ALSA mute control: %d\n",
+                       rc);
+               goto err_exit;
+       }
+       data->ctl_mute_id = &ctl_mute->id;
 
-                       cmos_cmd = (new_mute) ?
-                                  TP_CMOS_VOLUME_MUTE : TP_CMOS_VOLUME_UP;
+       snd_card_set_dev(card, &tpacpi_pdev->dev);
+       rc = snd_card_register(card);
+       if (rc < 0) {
+               printk(TPACPI_ERR "Failed to register ALSA card: %d\n", rc);
+               goto err_exit;
+       }
 
-                       if (issue_thinkpad_cmos_command(cmos_cmd) ||
-                           !acpi_ec_write(volume_offset, level + new_mute))
-                               return -EIO;
+       alsa_card = card;
+       return 0;
+
+err_exit:
+       snd_card_free(card);
+       return 1;
+}
+
+#define TPACPI_VOL_Q_MUTEONLY  0x0001  /* Mute-only control available */
+#define TPACPI_VOL_Q_LEVEL     0x0002  /* Volume control available */
+
+static const struct tpacpi_quirk volume_quirk_table[] __initconst = {
+       /* Whitelist volume level on all IBM by default */
+       { .vendor = PCI_VENDOR_ID_IBM,
+         .bios   = TPACPI_MATCH_ANY,
+         .ec     = TPACPI_MATCH_ANY,
+         .quirks = TPACPI_VOL_Q_LEVEL },
+
+       /* Lenovo models with volume control (needs confirmation) */
+       TPACPI_QEC_LNV('7', 'C', TPACPI_VOL_Q_LEVEL), /* R60/i */
+       TPACPI_QEC_LNV('7', 'E', TPACPI_VOL_Q_LEVEL), /* R60e/i */
+       TPACPI_QEC_LNV('7', '9', TPACPI_VOL_Q_LEVEL), /* T60/p */
+       TPACPI_QEC_LNV('7', 'B', TPACPI_VOL_Q_LEVEL), /* X60/s */
+       TPACPI_QEC_LNV('7', 'J', TPACPI_VOL_Q_LEVEL), /* X60t */
+       TPACPI_QEC_LNV('7', '7', TPACPI_VOL_Q_LEVEL), /* Z60 */
+       TPACPI_QEC_LNV('7', 'F', TPACPI_VOL_Q_LEVEL), /* Z61 */
+
+       /* Whitelist mute-only on all Lenovo by default */
+       { .vendor = PCI_VENDOR_ID_LENOVO,
+         .bios   = TPACPI_MATCH_ANY,
+         .ec     = TPACPI_MATCH_ANY,
+         .quirks = TPACPI_VOL_Q_MUTEONLY }
+};
+
+static int __init volume_init(struct ibm_init_struct *iibm)
+{
+       unsigned long quirks;
+       int rc;
+
+       vdbg_printk(TPACPI_DBG_INIT, "initializing volume subdriver\n");
+
+       mutex_init(&volume_mutex);
+
+       /*
+        * Check for module parameter bogosity, note that we
+        * init volume_mode to TPACPI_VOL_MODE_MAX in order to be
+        * able to detect "unspecified"
+        */
+       if (volume_mode > TPACPI_VOL_MODE_MAX)
+               return -EINVAL;
+
+       if (volume_mode == TPACPI_VOL_MODE_UCMS_STEP) {
+               printk(TPACPI_ERR
+                       "UCMS step volume mode not implemented, "
+                       "please contact %s\n", TPACPI_MAIL);
+               return 1;
+       }
+
+       if (volume_capabilities >= TPACPI_VOL_CAP_MAX)
+               return -EINVAL;
+
+       /*
+        * The ALSA mixer is our primary interface.
+        * When disabled, don't install the subdriver at all
+        */
+       if (!alsa_enable) {
+               vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_MIXER,
+                           "ALSA mixer disabled by parameter, "
+                           "not loading volume subdriver...\n");
+               return 1;
+       }
+
+       quirks = tpacpi_check_quirks(volume_quirk_table,
+                                    ARRAY_SIZE(volume_quirk_table));
+
+       switch (volume_capabilities) {
+       case TPACPI_VOL_CAP_AUTO:
+               if (quirks & TPACPI_VOL_Q_MUTEONLY)
+                       tp_features.mixer_no_level_control = 1;
+               else if (quirks & TPACPI_VOL_Q_LEVEL)
+                       tp_features.mixer_no_level_control = 0;
+               else
+                       return 1; /* no mixer */
+               break;
+       case TPACPI_VOL_CAP_VOLMUTE:
+               tp_features.mixer_no_level_control = 0;
+               break;
+       case TPACPI_VOL_CAP_MUTEONLY:
+               tp_features.mixer_no_level_control = 1;
+               break;
+       default:
+               return 1;
+       }
+
+       if (volume_capabilities != TPACPI_VOL_CAP_AUTO)
+               dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_MIXER,
+                               "using user-supplied volume_capabilities=%d\n",
+                               volume_capabilities);
+
+       if (volume_mode == TPACPI_VOL_MODE_AUTO ||
+           volume_mode == TPACPI_VOL_MODE_MAX) {
+               volume_mode = TPACPI_VOL_MODE_ECNVRAM;
+
+               dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_MIXER,
+                               "driver auto-selected volume_mode=%d\n",
+                               volume_mode);
+       } else {
+               dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_MIXER,
+                               "using user-supplied volume_mode=%d\n",
+                               volume_mode);
+       }
+
+       vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_MIXER,
+                       "mute is supported, volume control is %s\n",
+                       str_supported(!tp_features.mixer_no_level_control));
+
+       rc = volume_create_alsa_mixer();
+       if (rc) {
+               printk(TPACPI_ERR
+                       "Could not create the ALSA mixer interface\n");
+               return rc;
+       }
+
+       printk(TPACPI_INFO
+               "Console audio control enabled, mode: %s\n",
+               (volume_control_allowed) ?
+                       "override (read/write)" :
+                       "monitor (read only)");
+
+       vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_MIXER,
+               "registering volume hotkeys as change notification\n");
+       tpacpi_hotkey_driver_mask_set(hotkey_driver_mask
+                       | TP_ACPI_HKEY_VOLUP_MASK
+                       | TP_ACPI_HKEY_VOLDWN_MASK
+                       | TP_ACPI_HKEY_MUTE_MASK);
+
+       return 0;
+}
+
+static int volume_read(struct seq_file *m)
+{
+       u8 status;
+
+       if (volume_get_status(&status) < 0) {
+               seq_printf(m, "level:\t\tunreadable\n");
+       } else {
+               if (tp_features.mixer_no_level_control)
+                       seq_printf(m, "level:\t\tunsupported\n");
+               else
+                       seq_printf(m, "level:\t\t%d\n",
+                                       status & TP_EC_AUDIO_LVL_MSK);
+
+               seq_printf(m, "mute:\t\t%s\n",
+                               onoff(status, TP_EC_AUDIO_MUTESW));
+
+               if (volume_control_allowed) {
+                       seq_printf(m, "commands:\tunmute, mute\n");
+                       if (!tp_features.mixer_no_level_control) {
+                               seq_printf(m,
+                                              "commands:\tup, down\n");
+                               seq_printf(m,
+                                              "commands:\tlevel <level>"
+                                              " (<level> is 0-%d)\n",
+                                              TP_EC_VOLUME_MAX);
+                       }
                }
        }
 
        return 0;
 }
 
+static int volume_write(char *buf)
+{
+       u8 s;
+       u8 new_level, new_mute;
+       int l;
+       char *cmd;
+       int rc;
+
+       /*
+        * We do allow volume control at driver startup, so that the
+        * user can set initial state through the volume=... parameter hack.
+        */
+       if (!volume_control_allowed && tpacpi_lifecycle != TPACPI_LIFE_INIT) {
+               if (unlikely(!tp_warned.volume_ctrl_forbidden)) {
+                       tp_warned.volume_ctrl_forbidden = 1;
+                       printk(TPACPI_NOTICE
+                               "Console audio control in monitor mode, "
+                               "changes are not allowed.\n");
+                       printk(TPACPI_NOTICE
+                               "Use the volume_control=1 module parameter "
+                               "to enable volume control\n");
+               }
+               return -EPERM;
+       }
+
+       rc = volume_get_status(&s);
+       if (rc < 0)
+               return rc;
+
+       new_level = s & TP_EC_AUDIO_LVL_MSK;
+       new_mute  = s & TP_EC_AUDIO_MUTESW_MSK;
+
+       while ((cmd = next_cmd(&buf))) {
+               if (!tp_features.mixer_no_level_control) {
+                       if (strlencmp(cmd, "up") == 0) {
+                               if (new_mute)
+                                       new_mute = 0;
+                               else if (new_level < TP_EC_VOLUME_MAX)
+                                       new_level++;
+                               continue;
+                       } else if (strlencmp(cmd, "down") == 0) {
+                               if (new_mute)
+                                       new_mute = 0;
+                               else if (new_level > 0)
+                                       new_level--;
+                               continue;
+                       } else if (sscanf(cmd, "level %u", &l) == 1 &&
+                                  l >= 0 && l <= TP_EC_VOLUME_MAX) {
+                                       new_level = l;
+                               continue;
+                       }
+               }
+               if (strlencmp(cmd, "mute") == 0)
+                       new_mute = TP_EC_AUDIO_MUTESW_MSK;
+               else if (strlencmp(cmd, "unmute") == 0)
+                       new_mute = 0;
+               else
+                       return -EINVAL;
+       }
+
+       if (tp_features.mixer_no_level_control) {
+               tpacpi_disclose_usertask("procfs volume", "%smute\n",
+                                       new_mute ? "" : "un");
+               rc = volume_set_mute(!!new_mute);
+       } else {
+               tpacpi_disclose_usertask("procfs volume",
+                                       "%smute and set level to %d\n",
+                                       new_mute ? "" : "un", new_level);
+               rc = volume_set_status(new_mute | new_level);
+       }
+       volume_alsa_notify_change();
+
+       return (rc == -EINTR) ? -ERESTARTSYS : rc;
+}
+
 static struct ibm_struct volume_driver_data = {
        .name = "volume",
        .read = volume_read,
        .write = volume_write,
+       .exit = volume_exit,
+       .suspend = volume_suspend,
+       .resume = volume_resume,
+       .shutdown = volume_shutdown,
 };
 
+#else /* !CONFIG_THINKPAD_ACPI_ALSA_SUPPORT */
+
+#define alsa_card NULL
+
+static void inline volume_alsa_notify_change(void)
+{
+}
+
+static int __init volume_init(struct ibm_init_struct *iibm)
+{
+       printk(TPACPI_INFO
+               "volume: disabled as there is no ALSA support in this kernel\n");
+
+       return 1;
+}
+
+static struct ibm_struct volume_driver_data = {
+       .name = "volume",
+};
+
+#endif /* CONFIG_THINKPAD_ACPI_ALSA_SUPPORT */
+
 /*************************************************************************
  * Fan subdriver
  */
@@ -7510,9 +8119,8 @@ static void fan_resume(void)
        }
 }
 
-static int fan_read(char *p)
+static int fan_read(struct seq_file *m)
 {
-       int len = 0;
        int rc;
        u8 status;
        unsigned int speed = 0;
@@ -7524,7 +8132,7 @@ static int fan_read(char *p)
                if (rc < 0)
                        return rc;
 
-               len += sprintf(p + len, "status:\t\t%s\n"
+               seq_printf(m, "status:\t\t%s\n"
                               "level:\t\t%d\n",
                               (status != 0) ? "enabled" : "disabled", status);
                break;
@@ -7535,54 +8143,54 @@ static int fan_read(char *p)
                if (rc < 0)
                        return rc;
 
-               len += sprintf(p + len, "status:\t\t%s\n",
+               seq_printf(m, "status:\t\t%s\n",
                               (status != 0) ? "enabled" : "disabled");
 
                rc = fan_get_speed(&speed);
                if (rc < 0)
                        return rc;
 
-               len += sprintf(p + len, "speed:\t\t%d\n", speed);
+               seq_printf(m, "speed:\t\t%d\n", speed);
 
                if (status & TP_EC_FAN_FULLSPEED)
                        /* Disengaged mode takes precedence */
-                       len += sprintf(p + len, "level:\t\tdisengaged\n");
+                       seq_printf(m, "level:\t\tdisengaged\n");
                else if (status & TP_EC_FAN_AUTO)
-                       len += sprintf(p + len, "level:\t\tauto\n");
+                       seq_printf(m, "level:\t\tauto\n");
                else
-                       len += sprintf(p + len, "level:\t\t%d\n", status);
+                       seq_printf(m, "level:\t\t%d\n", status);
                break;
 
        case TPACPI_FAN_NONE:
        default:
-               len += sprintf(p + len, "status:\t\tnot supported\n");
+               seq_printf(m, "status:\t\tnot supported\n");
        }
 
        if (fan_control_commands & TPACPI_FAN_CMD_LEVEL) {
-               len += sprintf(p + len, "commands:\tlevel <level>");
+               seq_printf(m, "commands:\tlevel <level>");
 
                switch (fan_control_access_mode) {
                case TPACPI_FAN_WR_ACPI_SFAN:
-                       len += sprintf(p + len, " (<level> is 0-7)\n");
+                       seq_printf(m, " (<level> is 0-7)\n");
                        break;
 
                default:
-                       len += sprintf(p + len, " (<level> is 0-7, "
+                       seq_printf(m, " (<level> is 0-7, "
                                       "auto, disengaged, full-speed)\n");
                        break;
                }
        }
 
        if (fan_control_commands & TPACPI_FAN_CMD_ENABLE)
-               len += sprintf(p + len, "commands:\tenable, disable\n"
+               seq_printf(m, "commands:\tenable, disable\n"
                               "commands:\twatchdog <timeout> (<timeout> "
                               "is 0 (off), 1-120 (seconds))\n");
 
        if (fan_control_commands & TPACPI_FAN_CMD_SPEED)
-               len += sprintf(p + len, "commands:\tspeed <speed>"
+               seq_printf(m, "commands:\tspeed <speed>"
                               " (<speed> is 0-65535)\n");
 
-       return len;
+       return 0;
 }
 
 static int fan_write_cmd_level(const char *cmd, int *rc)
@@ -7724,10 +8332,23 @@ static struct ibm_struct fan_driver_data = {
  */
 static void tpacpi_driver_event(const unsigned int hkey_event)
 {
+       if (ibm_backlight_device) {
+               switch (hkey_event) {
+               case TP_HKEY_EV_BRGHT_UP:
+               case TP_HKEY_EV_BRGHT_DOWN:
+                       tpacpi_brightness_notify_change();
+               }
+       }
+       if (alsa_card) {
+               switch (hkey_event) {
+               case TP_HKEY_EV_VOL_UP:
+               case TP_HKEY_EV_VOL_DOWN:
+               case TP_HKEY_EV_VOL_MUTE:
+                       volume_alsa_notify_change();
+               }
+       }
 }
 
-
-
 static void hotkey_driver_event(const unsigned int scancode)
 {
        tpacpi_driver_event(TP_HKEY_EV_HOTKEY_BASE + scancode);
@@ -7856,19 +8477,19 @@ static int __init ibm_init(struct ibm_init_struct *iibm)
                "%s installed\n", ibm->name);
 
        if (ibm->read) {
-               entry = create_proc_entry(ibm->name,
-                                         S_IFREG | S_IRUGO | S_IWUSR,
-                                         proc_dir);
+               mode_t mode;
+
+               mode = S_IRUGO;
+               if (ibm->write)
+                       mode |= S_IWUSR;
+               entry = proc_create_data(ibm->name, mode, proc_dir,
+                                        &dispatch_proc_fops, ibm);
                if (!entry) {
                        printk(TPACPI_ERR "unable to create proc entry %s\n",
                               ibm->name);
                        ret = -ENODEV;
                        goto err_out;
                }
-               entry->data = ibm;
-               entry->read_proc = &dispatch_procfs_read;
-               if (ibm->write)
-                       entry->write_proc = &dispatch_procfs_write;
                ibm->flags.proc_created = 1;
        }
 
@@ -8080,6 +8701,7 @@ static struct ibm_init_struct ibms_init[] __initdata = {
                .data = &brightness_driver_data,
        },
        {
+               .init = volume_init,
                .data = &volume_driver_data,
        },
        {
@@ -8115,36 +8737,61 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp)
        return -EINVAL;
 }
 
-module_param(experimental, int, 0);
+module_param(experimental, int, 0444);
 MODULE_PARM_DESC(experimental,
                 "Enables experimental features when non-zero");
 
 module_param_named(debug, dbg_level, uint, 0);
 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
 
-module_param(force_load, bool, 0);
+module_param(force_load, bool, 0444);
 MODULE_PARM_DESC(force_load,
                 "Attempts to load the driver even on a "
                 "mis-identified ThinkPad when true");
 
-module_param_named(fan_control, fan_control_allowed, bool, 0);
+module_param_named(fan_control, fan_control_allowed, bool, 0444);
 MODULE_PARM_DESC(fan_control,
                 "Enables setting fan parameters features when true");
 
-module_param_named(brightness_mode, brightness_mode, uint, 0);
+module_param_named(brightness_mode, brightness_mode, uint, 0444);
 MODULE_PARM_DESC(brightness_mode,
                 "Selects brightness control strategy: "
                 "0=auto, 1=EC, 2=UCMS, 3=EC+NVRAM");
 
-module_param(brightness_enable, uint, 0);
+module_param(brightness_enable, uint, 0444);
 MODULE_PARM_DESC(brightness_enable,
                 "Enables backlight control when 1, disables when 0");
 
-module_param(hotkey_report_mode, uint, 0);
+module_param(hotkey_report_mode, uint, 0444);
 MODULE_PARM_DESC(hotkey_report_mode,
                 "used for backwards compatibility with userspace, "
                 "see documentation");
 
+#ifdef CONFIG_THINKPAD_ACPI_ALSA_SUPPORT
+module_param_named(volume_mode, volume_mode, uint, 0444);
+MODULE_PARM_DESC(volume_mode,
+                "Selects volume control strategy: "
+                "0=auto, 1=EC, 2=N/A, 3=EC+NVRAM");
+
+module_param_named(volume_capabilities, volume_capabilities, uint, 0444);
+MODULE_PARM_DESC(volume_capabilities,
+                "Selects the mixer capabilites: "
+                "0=auto, 1=volume and mute, 2=mute only");
+
+module_param_named(volume_control, volume_control_allowed, bool, 0444);
+MODULE_PARM_DESC(volume_control,
+                "Enables software override for the console audio "
+                "control when true");
+
+/* ALSA module API parameters */
+module_param_named(index, alsa_index, int, 0444);
+MODULE_PARM_DESC(index, "ALSA index for the ACPI EC Mixer");
+module_param_named(id, alsa_id, charp, 0444);
+MODULE_PARM_DESC(id, "ALSA id for the ACPI EC Mixer");
+module_param_named(enable, alsa_enable, bool, 0444);
+MODULE_PARM_DESC(enable, "Enable the ALSA interface for the ACPI EC Mixer");
+#endif /* CONFIG_THINKPAD_ACPI_ALSA_SUPPORT */
+
 #define TPACPI_PARAM(feature) \
        module_param_call(feature, set_ibm_param, NULL, NULL, 0); \
        MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command " \
@@ -8163,25 +8810,25 @@ TPACPI_PARAM(volume);
 TPACPI_PARAM(fan);
 
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
-module_param(dbg_wlswemul, uint, 0);
+module_param(dbg_wlswemul, uint, 0444);
 MODULE_PARM_DESC(dbg_wlswemul, "Enables WLSW emulation");
 module_param_named(wlsw_state, tpacpi_wlsw_emulstate, bool, 0);
 MODULE_PARM_DESC(wlsw_state,
                 "Initial state of the emulated WLSW switch");
 
-module_param(dbg_bluetoothemul, uint, 0);
+module_param(dbg_bluetoothemul, uint, 0444);
 MODULE_PARM_DESC(dbg_bluetoothemul, "Enables bluetooth switch emulation");
 module_param_named(bluetooth_state, tpacpi_bluetooth_emulstate, bool, 0);
 MODULE_PARM_DESC(bluetooth_state,
                 "Initial state of the emulated bluetooth switch");
 
-module_param(dbg_wwanemul, uint, 0);
+module_param(dbg_wwanemul, uint, 0444);
 MODULE_PARM_DESC(dbg_wwanemul, "Enables WWAN switch emulation");
 module_param_named(wwan_state, tpacpi_wwan_emulstate, bool, 0);
 MODULE_PARM_DESC(wwan_state,
                 "Initial state of the emulated WWAN switch");
 
-module_param(dbg_uwbemul, uint, 0);
+module_param(dbg_uwbemul, uint, 0444);
 MODULE_PARM_DESC(dbg_uwbemul, "Enables UWB switch emulation");
 module_param_named(uwb_state, tpacpi_uwb_emulstate, bool, 0);
 MODULE_PARM_DESC(uwb_state,
@@ -8374,6 +9021,7 @@ static int __init thinkpad_acpi_module_init(void)
                                                PCI_VENDOR_ID_IBM;
                tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT;
                tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION;
+               tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev;
        }
        for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
                ret = ibm_init(&ibms_init[i]);
index 51c0a8bee4144ff800ff200e463315590e2d729a..77bf5d8f893aae8368f3ae6253c9f5c98e4d86a9 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/backlight.h>
 #include <linux/platform_device.h>
 #include <linux/rfkill.h>
@@ -357,63 +358,6 @@ static int force_fan;
 static int last_key_event;
 static int key_event_valid;
 
-typedef struct _ProcItem {
-       const char *name;
-       char *(*read_func) (char *);
-       unsigned long (*write_func) (const char *, unsigned long);
-} ProcItem;
-
-/* proc file handlers
- */
-
-static int
-dispatch_read(char *page, char **start, off_t off, int count, int *eof,
-             ProcItem * item)
-{
-       char *p = page;
-       int len;
-
-       if (off == 0)
-               p = item->read_func(p);
-
-       /* ISSUE: I don't understand this code */
-       len = (p - page);
-       if (len <= off + count)
-               *eof = 1;
-       *start = page + off;
-       len -= off;
-       if (len > count)
-               len = count;
-       if (len < 0)
-               len = 0;
-       return len;
-}
-
-static int
-dispatch_write(struct file *file, const char __user * buffer,
-              unsigned long count, ProcItem * item)
-{
-       int result;
-       char *tmp_buffer;
-
-       /* Arg buffer points to userspace memory, which can't be accessed
-        * directly.  Since we're making a copy, zero-terminate the
-        * destination so that sscanf can be used on it safely.
-        */
-       tmp_buffer = kmalloc(count + 1, GFP_KERNEL);
-       if (!tmp_buffer)
-               return -ENOMEM;
-
-       if (copy_from_user(tmp_buffer, buffer, count)) {
-               result = -EFAULT;
-       } else {
-               tmp_buffer[count] = 0;
-               result = item->write_func(tmp_buffer, count);
-       }
-       kfree(tmp_buffer);
-       return result;
-}
-
 static int get_lcd(struct backlight_device *bd)
 {
        u32 hci_result;
@@ -426,19 +370,24 @@ static int get_lcd(struct backlight_device *bd)
                return -EFAULT;
 }
 
-static char *read_lcd(char *p)
+static int lcd_proc_show(struct seq_file *m, void *v)
 {
        int value = get_lcd(NULL);
 
        if (value >= 0) {
-               p += sprintf(p, "brightness:              %d\n", value);
-               p += sprintf(p, "brightness_levels:       %d\n",
+               seq_printf(m, "brightness:              %d\n", value);
+               seq_printf(m, "brightness_levels:       %d\n",
                             HCI_LCD_BRIGHTNESS_LEVELS);
        } else {
                printk(MY_ERR "Error reading LCD brightness\n");
        }
 
-       return p;
+       return 0;
+}
+
+static int lcd_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, lcd_proc_show, NULL);
 }
 
 static int set_lcd(int value)
@@ -458,12 +407,20 @@ static int set_lcd_status(struct backlight_device *bd)
        return set_lcd(bd->props.brightness);
 }
 
-static unsigned long write_lcd(const char *buffer, unsigned long count)
+static ssize_t lcd_proc_write(struct file *file, const char __user *buf,
+                             size_t count, loff_t *pos)
 {
+       char cmd[42];
+       size_t len;
        int value;
        int ret;
 
-       if (sscanf(buffer, " brightness : %i", &value) == 1 &&
+       len = min(count, sizeof(cmd) - 1);
+       if (copy_from_user(cmd, buf, len))
+               return -EFAULT;
+       cmd[len] = '\0';
+
+       if (sscanf(cmd, " brightness : %i", &value) == 1 &&
            value >= 0 && value < HCI_LCD_BRIGHTNESS_LEVELS) {
                ret = set_lcd(value);
                if (ret == 0)
@@ -474,7 +431,16 @@ static unsigned long write_lcd(const char *buffer, unsigned long count)
        return ret;
 }
 
-static char *read_video(char *p)
+static const struct file_operations lcd_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = lcd_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = lcd_proc_write,
+};
+
+static int video_proc_show(struct seq_file *m, void *v)
 {
        u32 hci_result;
        u32 value;
@@ -484,18 +450,25 @@ static char *read_video(char *p)
                int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0;
                int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0;
                int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0;
-               p += sprintf(p, "lcd_out:                 %d\n", is_lcd);
-               p += sprintf(p, "crt_out:                 %d\n", is_crt);
-               p += sprintf(p, "tv_out:                  %d\n", is_tv);
+               seq_printf(m, "lcd_out:                 %d\n", is_lcd);
+               seq_printf(m, "crt_out:                 %d\n", is_crt);
+               seq_printf(m, "tv_out:                  %d\n", is_tv);
        } else {
                printk(MY_ERR "Error reading video out status\n");
        }
 
-       return p;
+       return 0;
 }
 
-static unsigned long write_video(const char *buffer, unsigned long count)
+static int video_proc_open(struct inode *inode, struct file *file)
 {
+       return single_open(file, video_proc_show, NULL);
+}
+
+static ssize_t video_proc_write(struct file *file, const char __user *buf,
+                               size_t count, loff_t *pos)
+{
+       char *cmd, *buffer;
        int value;
        int remain = count;
        int lcd_out = -1;
@@ -504,6 +477,17 @@ static unsigned long write_video(const char *buffer, unsigned long count)
        u32 hci_result;
        u32 video_out;
 
+       cmd = kmalloc(count + 1, GFP_KERNEL);
+       if (!cmd)
+               return -ENOMEM;
+       if (copy_from_user(cmd, buf, count)) {
+               kfree(cmd);
+               return -EFAULT;
+       }
+       cmd[count] = '\0';
+
+       buffer = cmd;
+
        /* scan expression.  Multiple expressions may be delimited with ;
         *
         *  NOTE: to keep scanning simple, invalid fields are ignored
@@ -523,6 +507,8 @@ static unsigned long write_video(const char *buffer, unsigned long count)
                while (remain && *(buffer - 1) != ';');
        }
 
+       kfree(cmd);
+
        hci_read1(HCI_VIDEO_OUT, &video_out, &hci_result);
        if (hci_result == HCI_SUCCESS) {
                unsigned int new_video_out = video_out;
@@ -543,28 +529,50 @@ static unsigned long write_video(const char *buffer, unsigned long count)
        return count;
 }
 
-static char *read_fan(char *p)
+static const struct file_operations video_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = video_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = video_proc_write,
+};
+
+static int fan_proc_show(struct seq_file *m, void *v)
 {
        u32 hci_result;
        u32 value;
 
        hci_read1(HCI_FAN, &value, &hci_result);
        if (hci_result == HCI_SUCCESS) {
-               p += sprintf(p, "running:                 %d\n", (value > 0));
-               p += sprintf(p, "force_on:                %d\n", force_fan);
+               seq_printf(m, "running:                 %d\n", (value > 0));
+               seq_printf(m, "force_on:                %d\n", force_fan);
        } else {
                printk(MY_ERR "Error reading fan status\n");
        }
 
-       return p;
+       return 0;
+}
+
+static int fan_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, fan_proc_show, NULL);
 }
 
-static unsigned long write_fan(const char *buffer, unsigned long count)
+static ssize_t fan_proc_write(struct file *file, const char __user *buf,
+                             size_t count, loff_t *pos)
 {
+       char cmd[42];
+       size_t len;
        int value;
        u32 hci_result;
 
-       if (sscanf(buffer, " force_on : %i", &value) == 1 &&
+       len = min(count, sizeof(cmd) - 1);
+       if (copy_from_user(cmd, buf, len))
+               return -EFAULT;
+       cmd[len] = '\0';
+
+       if (sscanf(cmd, " force_on : %i", &value) == 1 &&
            value >= 0 && value <= 1) {
                hci_write1(HCI_FAN, value, &hci_result);
                if (hci_result != HCI_SUCCESS)
@@ -578,7 +586,16 @@ static unsigned long write_fan(const char *buffer, unsigned long count)
        return count;
 }
 
-static char *read_keys(char *p)
+static const struct file_operations fan_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = fan_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = fan_proc_write,
+};
+
+static int keys_proc_show(struct seq_file *m, void *v)
 {
        u32 hci_result;
        u32 value;
@@ -602,18 +619,30 @@ static char *read_keys(char *p)
                }
        }
 
-       p += sprintf(p, "hotkey_ready:            %d\n", key_event_valid);
-       p += sprintf(p, "hotkey:                  0x%04x\n", last_key_event);
+       seq_printf(m, "hotkey_ready:            %d\n", key_event_valid);
+       seq_printf(m, "hotkey:                  0x%04x\n", last_key_event);
+end:
+       return 0;
+}
 
-      end:
-       return p;
+static int keys_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, keys_proc_show, NULL);
 }
 
-static unsigned long write_keys(const char *buffer, unsigned long count)
+static ssize_t keys_proc_write(struct file *file, const char __user *buf,
+                              size_t count, loff_t *pos)
 {
+       char cmd[42];
+       size_t len;
        int value;
 
-       if (sscanf(buffer, " hotkey_ready : %i", &value) == 1 && value == 0) {
+       len = min(count, sizeof(cmd) - 1);
+       if (copy_from_user(cmd, buf, len))
+               return -EFAULT;
+       cmd[len] = '\0';
+
+       if (sscanf(cmd, " hotkey_ready : %i", &value) == 1 && value == 0) {
                key_event_valid = 0;
        } else {
                return -EINVAL;
@@ -622,52 +651,58 @@ static unsigned long write_keys(const char *buffer, unsigned long count)
        return count;
 }
 
-static char *read_version(char *p)
+static const struct file_operations keys_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = keys_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = keys_proc_write,
+};
+
+static int version_proc_show(struct seq_file *m, void *v)
 {
-       p += sprintf(p, "driver:                  %s\n", TOSHIBA_ACPI_VERSION);
-       p += sprintf(p, "proc_interface:          %d\n",
-                    PROC_INTERFACE_VERSION);
-       return p;
+       seq_printf(m, "driver:                  %s\n", TOSHIBA_ACPI_VERSION);
+       seq_printf(m, "proc_interface:          %d\n", PROC_INTERFACE_VERSION);
+       return 0;
 }
 
+static int version_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, version_proc_show, PDE(inode)->data);
+}
+
+static const struct file_operations version_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = version_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 /* proc and module init
  */
 
 #define PROC_TOSHIBA           "toshiba"
 
-static ProcItem proc_items[] = {
-       {"lcd", read_lcd, write_lcd},
-       {"video", read_video, write_video},
-       {"fan", read_fan, write_fan},
-       {"keys", read_keys, write_keys},
-       {"version", read_version, NULL},
-       {NULL}
-};
-
 static acpi_status __init add_device(void)
 {
-       struct proc_dir_entry *proc;
-       ProcItem *item;
-
-       for (item = proc_items; item->name; ++item) {
-               proc = create_proc_read_entry(item->name,
-                                             S_IFREG | S_IRUGO | S_IWUSR,
-                                             toshiba_proc_dir,
-                                             (read_proc_t *) dispatch_read,
-                                             item);
-               if (proc && item->write_func)
-                       proc->write_proc = (write_proc_t *) dispatch_write;
-       }
+       proc_create("lcd", S_IRUGO | S_IWUSR, toshiba_proc_dir, &lcd_proc_fops);
+       proc_create("video", S_IRUGO | S_IWUSR, toshiba_proc_dir, &video_proc_fops);
+       proc_create("fan", S_IRUGO | S_IWUSR, toshiba_proc_dir, &fan_proc_fops);
+       proc_create("keys", S_IRUGO | S_IWUSR, toshiba_proc_dir, &keys_proc_fops);
+       proc_create("version", S_IRUGO, toshiba_proc_dir, &version_proc_fops);
 
        return AE_OK;
 }
 
 static acpi_status remove_device(void)
 {
-       ProcItem *item;
-
-       for (item = proc_items; item->name; ++item)
-               remove_proc_entry(item->name, toshiba_proc_dir);
+       remove_proc_entry("lcd", toshiba_proc_dir);
+       remove_proc_entry("video", toshiba_proc_dir);
+       remove_proc_entry("fan", toshiba_proc_dir);
+       remove_proc_entry("keys", toshiba_proc_dir);
+       remove_proc_entry("version", toshiba_proc_dir);
        return AE_OK;
 }
 
diff --git a/drivers/platform/x86/toshiba_bluetooth.c b/drivers/platform/x86/toshiba_bluetooth.c
new file mode 100644 (file)
index 0000000..a350418
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Toshiba Bluetooth Enable Driver
+ *
+ * Copyright (C) 2009 Jes Sorensen <Jes.Sorensen@gmail.com>
+ *
+ * Thanks to Matthew Garrett for background info on ACPI innards which
+ * normal people aren't meant to understand :-)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Note the Toshiba Bluetooth RFKill switch seems to be a strange
+ * fish. It only provides a BT event when the switch is flipped to
+ * the 'on' position. When flipping it to 'off', the USB device is
+ * simply pulled away underneath us, without any BT event being
+ * delivered.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/acpi_drivers.h>
+
+MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@gmail.com>");
+MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver");
+MODULE_LICENSE("GPL");
+
+
+static int toshiba_bt_rfkill_add(struct acpi_device *device);
+static int toshiba_bt_rfkill_remove(struct acpi_device *device, int type);
+static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
+static int toshiba_bt_resume(struct acpi_device *device);
+
+static const struct acpi_device_id bt_device_ids[] = {
+       { "TOS6205", 0},
+       { "", 0},
+};
+MODULE_DEVICE_TABLE(acpi, bt_device_ids);
+
+static struct acpi_driver toshiba_bt_rfkill_driver = {
+       .name =         "Toshiba BT",
+       .class =        "Toshiba",
+       .ids =          bt_device_ids,
+       .ops =          {
+                               .add =          toshiba_bt_rfkill_add,
+                               .remove =       toshiba_bt_rfkill_remove,
+                               .notify =       toshiba_bt_rfkill_notify,
+                               .resume =       toshiba_bt_resume,
+                       },
+       .owner =        THIS_MODULE,
+};
+
+
+static int toshiba_bluetooth_enable(acpi_handle handle)
+{
+       acpi_status res1, res2;
+       acpi_integer result;
+
+       /*
+        * Query ACPI to verify RFKill switch is set to 'on'.
+        * If not, we return silently, no need to report it as
+        * an error.
+        */
+       res1 = acpi_evaluate_integer(handle, "BTST", NULL, &result);
+       if (ACPI_FAILURE(res1))
+               return res1;
+       if (!(result & 0x01))
+               return 0;
+
+       printk(KERN_INFO "toshiba_bluetooth: Re-enabling Toshiba Bluetooth\n");
+       res1 = acpi_evaluate_object(handle, "AUSB", NULL, NULL);
+       res2 = acpi_evaluate_object(handle, "BTPO", NULL, NULL);
+       if (!ACPI_FAILURE(res1) || !ACPI_FAILURE(res2))
+               return 0;
+
+       printk(KERN_WARNING "toshiba_bluetooth: Failed to re-enable "
+              "Toshiba Bluetooth\n");
+
+       return -ENODEV;
+}
+
+static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event)
+{
+       toshiba_bluetooth_enable(device->handle);
+}
+
+static int toshiba_bt_resume(struct acpi_device *device)
+{
+       return toshiba_bluetooth_enable(device->handle);
+}
+
+static int toshiba_bt_rfkill_add(struct acpi_device *device)
+{
+       acpi_status status;
+       acpi_integer bt_present;
+       int result = -ENODEV;
+
+       /*
+        * Some Toshiba laptops may have a fake TOS6205 device in
+        * their ACPI BIOS, so query the _STA method to see if there
+        * is really anything there, before trying to enable it.
+        */
+       status = acpi_evaluate_integer(device->handle, "_STA", NULL,
+                                      &bt_present);
+
+       if (!ACPI_FAILURE(status) && bt_present) {
+               printk(KERN_INFO "Detected Toshiba ACPI Bluetooth device - "
+                     "installing RFKill handler\n");
+               result = toshiba_bluetooth_enable(device->handle);
+       }
+
+       return result;
+}
+
+static int __init toshiba_bt_rfkill_init(void)
+{
+       int result;
+
+       result = acpi_bus_register_driver(&toshiba_bt_rfkill_driver);
+       if (result < 0) {
+               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
+                                 "Error registering driver\n"));
+               return result;
+       }
+
+       return 0;
+}
+
+static int toshiba_bt_rfkill_remove(struct acpi_device *device, int type)
+{
+       /* clean up */
+       return 0;
+}
+
+static void __exit toshiba_bt_rfkill_exit(void)
+{
+       acpi_bus_unregister_driver(&toshiba_bt_rfkill_driver);
+}
+
+module_init(toshiba_bt_rfkill_init);
+module_exit(toshiba_bt_rfkill_exit);
index 177f8d767df40f3a61528a1df582392121181969..b104302fea0a1e9dbc4a91f82290a185ad244e00 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
+#include <linux/device.h>
 #include <linux/list.h>
 #include <linux/acpi.h>
 #include <acpi/acpi_bus.h>
@@ -65,6 +66,7 @@ struct wmi_block {
        acpi_handle handle;
        wmi_notify_handler handler;
        void *handler_data;
+       struct device *dev;
 };
 
 static struct wmi_block wmi_blocks;
@@ -195,6 +197,34 @@ static bool wmi_parse_guid(const u8 *src, u8 *dest)
        return true;
 }
 
+/*
+ * Convert a raw GUID to the ACII string representation
+ */
+static int wmi_gtoa(const char *in, char *out)
+{
+       int i;
+
+       for (i = 3; i >= 0; i--)
+               out += sprintf(out, "%02X", in[i] & 0xFF);
+
+       out += sprintf(out, "-");
+       out += sprintf(out, "%02X", in[5] & 0xFF);
+       out += sprintf(out, "%02X", in[4] & 0xFF);
+       out += sprintf(out, "-");
+       out += sprintf(out, "%02X", in[7] & 0xFF);
+       out += sprintf(out, "%02X", in[6] & 0xFF);
+       out += sprintf(out, "-");
+       out += sprintf(out, "%02X", in[8] & 0xFF);
+       out += sprintf(out, "%02X", in[9] & 0xFF);
+       out += sprintf(out, "-");
+
+       for (i = 10; i <= 15; i++)
+               out += sprintf(out, "%02X", in[i] & 0xFF);
+
+       out = '\0';
+       return 0;
+}
+
 static bool find_guid(const char *guid_string, struct wmi_block **out)
 {
        char tmp[16], guid_input[16];
@@ -462,8 +492,7 @@ wmi_notify_handler handler, void *data)
        if (!guid || !handler)
                return AE_BAD_PARAMETER;
 
-       find_guid(guid, &block);
-       if (!block)
+       if (!find_guid(guid, &block))
                return AE_NOT_EXIST;
 
        if (block->handler)
@@ -491,8 +520,7 @@ acpi_status wmi_remove_notify_handler(const char *guid)
        if (!guid)
                return AE_BAD_PARAMETER;
 
-       find_guid(guid, &block);
-       if (!block)
+       if (!find_guid(guid, &block))
                return AE_NOT_EXIST;
 
        if (!block->handler)
@@ -510,8 +538,8 @@ EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);
 /**
  * wmi_get_event_data - Get WMI data associated with an event
  *
- * @event - Event to find
- * &out - Buffer to hold event data
+ * @event: Event to find
+ * @out: Buffer to hold event data. out->pointer should be freed with kfree()
  *
  * Returns extra data associated with an event in WMI.
  */
@@ -554,6 +582,154 @@ bool wmi_has_guid(const char *guid_string)
 }
 EXPORT_SYMBOL_GPL(wmi_has_guid);
 
+/*
+ * sysfs interface
+ */
+static ssize_t show_modalias(struct device *dev, struct device_attribute *attr,
+                            char *buf)
+{
+       char guid_string[37];
+       struct wmi_block *wblock;
+
+       wblock = dev_get_drvdata(dev);
+       if (!wblock)
+               return -ENOMEM;
+
+       wmi_gtoa(wblock->gblock.guid, guid_string);
+
+       return sprintf(buf, "wmi:%s\n", guid_string);
+}
+static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
+
+static int wmi_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+       char guid_string[37];
+
+       struct wmi_block *wblock;
+
+       if (add_uevent_var(env, "MODALIAS="))
+               return -ENOMEM;
+
+       wblock = dev_get_drvdata(dev);
+       if (!wblock)
+               return -ENOMEM;
+
+       wmi_gtoa(wblock->gblock.guid, guid_string);
+
+       strcpy(&env->buf[env->buflen - 1], "wmi:");
+       memcpy(&env->buf[env->buflen - 1 + 4], guid_string, 36);
+       env->buflen += 40;
+
+       return 0;
+}
+
+static void wmi_dev_free(struct device *dev)
+{
+       kfree(dev);
+}
+
+static struct class wmi_class = {
+       .name = "wmi",
+       .dev_release = wmi_dev_free,
+       .dev_uevent = wmi_dev_uevent,
+};
+
+static int wmi_create_devs(void)
+{
+       int result;
+       char guid_string[37];
+       struct guid_block *gblock;
+       struct wmi_block *wblock;
+       struct list_head *p;
+       struct device *guid_dev;
+
+       /* Create devices for all the GUIDs */
+       list_for_each(p, &wmi_blocks.list) {
+               wblock = list_entry(p, struct wmi_block, list);
+
+               guid_dev = kzalloc(sizeof(struct device), GFP_KERNEL);
+               if (!guid_dev)
+                       return -ENOMEM;
+
+               wblock->dev = guid_dev;
+
+               guid_dev->class = &wmi_class;
+               dev_set_drvdata(guid_dev, wblock);
+
+               gblock = &wblock->gblock;
+
+               wmi_gtoa(gblock->guid, guid_string);
+               dev_set_name(guid_dev, guid_string);
+
+               result = device_register(guid_dev);
+               if (result)
+                       return result;
+
+               result = device_create_file(guid_dev, &dev_attr_modalias);
+               if (result)
+                       return result;
+       }
+
+       return 0;
+}
+
+static void wmi_remove_devs(void)
+{
+       struct guid_block *gblock;
+       struct wmi_block *wblock;
+       struct list_head *p;
+       struct device *guid_dev;
+
+       /* Delete devices for all the GUIDs */
+       list_for_each(p, &wmi_blocks.list) {
+               wblock = list_entry(p, struct wmi_block, list);
+
+               guid_dev = wblock->dev;
+               gblock = &wblock->gblock;
+
+               device_remove_file(guid_dev, &dev_attr_modalias);
+
+               device_unregister(guid_dev);
+       }
+}
+
+static void wmi_class_exit(void)
+{
+       wmi_remove_devs();
+       class_unregister(&wmi_class);
+}
+
+static int wmi_class_init(void)
+{
+       int ret;
+
+       ret = class_register(&wmi_class);
+       if (ret)
+               return ret;
+
+       ret = wmi_create_devs();
+       if (ret)
+               wmi_class_exit();
+
+       return ret;
+}
+
+static bool guid_already_parsed(const char *guid_string)
+{
+       struct guid_block *gblock;
+       struct wmi_block *wblock;
+       struct list_head *p;
+
+       list_for_each(p, &wmi_blocks.list) {
+               wblock = list_entry(p, struct wmi_block, list);
+               gblock = &wblock->gblock;
+
+               if (strncmp(gblock->guid, guid_string, 16) == 0)
+                       return true;
+       }
+       return false;
+}
+
 /*
  * Parse the _WDG method for the GUID data blocks
  */
@@ -563,6 +739,7 @@ static __init acpi_status parse_wdg(acpi_handle handle)
        union acpi_object *obj;
        struct guid_block *gblock;
        struct wmi_block *wblock;
+       char guid_string[37];
        acpi_status status;
        u32 i, total;
 
@@ -585,6 +762,19 @@ static __init acpi_status parse_wdg(acpi_handle handle)
        memcpy(gblock, obj->buffer.pointer, obj->buffer.length);
 
        for (i = 0; i < total; i++) {
+               /*
+                 Some WMI devices, like those for nVidia hooks, have a
+                 duplicate GUID. It's not clear what we should do in this
+                 case yet, so for now, we'll just ignore the duplicate.
+                 Anyone who wants to add support for that device can come
+                 up with a better workaround for the mess then.
+               */
+               if (guid_already_parsed(gblock[i].guid) == true) {
+                       wmi_gtoa(gblock[i].guid, guid_string);
+                       printk(KERN_INFO PREFIX "Skipping duplicate GUID %s\n",
+                               guid_string);
+                       continue;
+               }
                wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
                if (!wblock)
                        return AE_NO_MEMORY;
@@ -709,10 +899,17 @@ static int __init acpi_wmi_init(void)
 
        if (result < 0) {
                printk(KERN_INFO PREFIX "Error loading mapper\n");
-       } else {
-               printk(KERN_INFO PREFIX "Mapper loaded\n");
+               return -ENODEV;
+       }
+
+       result = wmi_class_init();
+       if (result) {
+               acpi_bus_unregister_driver(&acpi_wmi_driver);
+               return result;
        }
 
+       printk(KERN_INFO PREFIX "Mapper loaded\n");
+
        return result;
 }
 
@@ -721,6 +918,8 @@ static void __exit acpi_wmi_exit(void)
        struct list_head *p, *tmp;
        struct wmi_block *wblock;
 
+       wmi_class_exit();
+
        acpi_bus_unregister_driver(&acpi_wmi_driver);
 
        list_for_each_safe(p, tmp, &wmi_blocks.list) {
index c3f1c8e9d2545a4859d984ed7237455ec8e8ca36..68b0c04987e4434c69a43d842b1bdc3c422481ad 100644 (file)
@@ -310,8 +310,7 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
                goto done;
        }
 
-       while (isspace(*buf))
-               ++buf;
+       buf = skip_spaces(buf);
        if (!strnicmp(buf, "disable", 7)) {
                retval = pnp_disable_dev(dev);
                goto done;
@@ -353,19 +352,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
                pnp_init_resources(dev);
                mutex_lock(&pnp_res_mutex);
                while (1) {
-                       while (isspace(*buf))
-                               ++buf;
+                       buf = skip_spaces(buf);
                        if (!strnicmp(buf, "io", 2)) {
-                               buf += 2;
-                               while (isspace(*buf))
-                                       ++buf;
+                               buf = skip_spaces(buf + 2);
                                start = simple_strtoul(buf, &buf, 0);
-                               while (isspace(*buf))
-                                       ++buf;
+                               buf = skip_spaces(buf);
                                if (*buf == '-') {
-                                       buf += 1;
-                                       while (isspace(*buf))
-                                               ++buf;
+                                       buf = skip_spaces(buf + 1);
                                        end = simple_strtoul(buf, &buf, 0);
                                } else
                                        end = start;
@@ -373,16 +366,11 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
                                continue;
                        }
                        if (!strnicmp(buf, "mem", 3)) {
-                               buf += 3;
-                               while (isspace(*buf))
-                                       ++buf;
+                               buf = skip_spaces(buf + 3);
                                start = simple_strtoul(buf, &buf, 0);
-                               while (isspace(*buf))
-                                       ++buf;
+                               buf = skip_spaces(buf);
                                if (*buf == '-') {
-                                       buf += 1;
-                                       while (isspace(*buf))
-                                               ++buf;
+                                       buf = skip_spaces(buf + 1);
                                        end = simple_strtoul(buf, &buf, 0);
                                } else
                                        end = start;
@@ -390,17 +378,13 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
                                continue;
                        }
                        if (!strnicmp(buf, "irq", 3)) {
-                               buf += 3;
-                               while (isspace(*buf))
-                                       ++buf;
+                               buf = skip_spaces(buf + 3);
                                start = simple_strtoul(buf, &buf, 0);
                                pnp_add_irq_resource(dev, start, 0);
                                continue;
                        }
                        if (!strnicmp(buf, "dma", 3)) {
-                               buf += 3;
-                               while (isspace(*buf))
-                                       ++buf;
+                               buf = skip_spaces(buf + 3);
                                start = simple_strtoul(buf, &buf, 0);
                                pnp_add_dma_resource(dev, start, 0);
                                continue;
index 83b8b5ac49c90b1a0085962efd41aeefe457692c..5314bf630bc4c7fe1b227e4eb0e39b6cf618e79b 100644 (file)
@@ -80,7 +80,8 @@ static int pnpacpi_get_resources(struct pnp_dev *dev)
 
 static int pnpacpi_set_resources(struct pnp_dev *dev)
 {
-       acpi_handle handle = dev->data;
+       struct acpi_device *acpi_dev = dev->data;
+       acpi_handle handle = acpi_dev->handle;
        struct acpi_buffer buffer;
        int ret;
 
@@ -103,7 +104,8 @@ static int pnpacpi_set_resources(struct pnp_dev *dev)
 
 static int pnpacpi_disable_resources(struct pnp_dev *dev)
 {
-       acpi_handle handle = dev->data;
+       struct acpi_device *acpi_dev = dev->data;
+       acpi_handle handle = acpi_dev->handle;
        int ret;
 
        dev_dbg(&dev->dev, "disable resources\n");
@@ -121,6 +123,8 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
 #ifdef CONFIG_ACPI_SLEEP
 static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
 {
+       struct acpi_device *acpi_dev = dev->data;
+       acpi_handle handle = acpi_dev->handle;
        int power_state;
 
        power_state = acpi_pm_device_sleep_state(&dev->dev, NULL);
@@ -128,16 +132,19 @@ static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
                power_state = (state.event == PM_EVENT_ON) ?
                                ACPI_STATE_D0 : ACPI_STATE_D3;
 
-       return acpi_bus_set_power((acpi_handle) dev->data, power_state);
+       return acpi_bus_set_power(handle, power_state);
 }
 
 static int pnpacpi_resume(struct pnp_dev *dev)
 {
-       return acpi_bus_set_power((acpi_handle) dev->data, ACPI_STATE_D0);
+       struct acpi_device *acpi_dev = dev->data;
+       acpi_handle handle = acpi_dev->handle;
+
+       return acpi_bus_set_power(handle, ACPI_STATE_D0);
 }
 #endif
 
-static struct pnp_protocol pnpacpi_protocol = {
+struct pnp_protocol pnpacpi_protocol = {
        .name    = "Plug and Play ACPI",
        .get     = pnpacpi_get_resources,
        .set     = pnpacpi_set_resources,
@@ -147,6 +154,7 @@ static struct pnp_protocol pnpacpi_protocol = {
        .resume = pnpacpi_resume,
 #endif
 };
+EXPORT_SYMBOL(pnpacpi_protocol);
 
 static int __init pnpacpi_add_device(struct acpi_device *device)
 {
@@ -168,7 +176,7 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
        if (!dev)
                return -ENOMEM;
 
-       dev->data = device->handle;
+       dev->data = device;
        /* .enabled means the device can decode the resources */
        dev->active = device->status.enabled;
        status = acpi_get_handle(device->handle, "_SRS", &temp);
index ef3a2cd3a7a0ac80a188cfb5cacbda03373cf3e3..5702b2c8691fa8ca80c20c25dd4d76849f7031dc 100644 (file)
@@ -465,7 +465,8 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
 
 int pnpacpi_parse_allocated_resource(struct pnp_dev *dev)
 {
-       acpi_handle handle = dev->data;
+       struct acpi_device *acpi_dev = dev->data;
+       acpi_handle handle = acpi_dev->handle;
        acpi_status status;
 
        pnp_dbg(&dev->dev, "parse allocated resources\n");
@@ -773,7 +774,8 @@ static __init acpi_status pnpacpi_option_resource(struct acpi_resource *res,
 
 int __init pnpacpi_parse_resource_option_data(struct pnp_dev *dev)
 {
-       acpi_handle handle = dev->data;
+       struct acpi_device *acpi_dev = dev->data;
+       acpi_handle handle = acpi_dev->handle;
        acpi_status status;
        struct acpipnp_parse_option_s parse_data;
 
@@ -845,7 +847,8 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data)
 int pnpacpi_build_resource_template(struct pnp_dev *dev,
                                    struct acpi_buffer *buffer)
 {
-       acpi_handle handle = dev->data;
+       struct acpi_device *acpi_dev = dev->data;
+       acpi_handle handle = acpi_dev->handle;
        struct acpi_resource *resource;
        int res_cnt = 0;
        acpi_status status;
index b35d921bac6e47a0bc79b5d99e3dbbe14a31e6df..2d8ac43f78e8b9d30986d869003b77e296e2d67d 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/types.h>
 #include <linux/proc_fs.h>
 #include <linux/pnp.h>
+#include <linux/seq_file.h>
 #include <linux/init.h>
 
 #include <asm/uaccess.h>
 static struct proc_dir_entry *proc_pnp = NULL;
 static struct proc_dir_entry *proc_pnp_boot = NULL;
 
-static int proc_read_pnpconfig(char *buf, char **start, off_t pos,
-                              int count, int *eof, void *data)
+static int pnpconfig_proc_show(struct seq_file *m, void *v)
 {
        struct pnp_isa_config_struc pnps;
 
        if (pnp_bios_isapnp_config(&pnps))
                return -EIO;
-       return snprintf(buf, count,
-                       "structure_revision %d\n"
-                       "number_of_CSNs %d\n"
-                       "ISA_read_data_port 0x%x\n",
-                       pnps.revision, pnps.no_csns, pnps.isa_rd_data_port);
+       seq_printf(m, "structure_revision %d\n"
+                     "number_of_CSNs %d\n"
+                     "ISA_read_data_port 0x%x\n",
+                  pnps.revision, pnps.no_csns, pnps.isa_rd_data_port);
+       return 0;
 }
 
-static int proc_read_escdinfo(char *buf, char **start, off_t pos,
-                             int count, int *eof, void *data)
+static int pnpconfig_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, pnpconfig_proc_show, NULL);
+}
+
+static const struct file_operations pnpconfig_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = pnpconfig_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int escd_info_proc_show(struct seq_file *m, void *v)
 {
        struct escd_info_struc escd;
 
        if (pnp_bios_escd_info(&escd))
                return -EIO;
-       return snprintf(buf, count,
-                       "min_ESCD_write_size %d\n"
+       seq_printf(m, "min_ESCD_write_size %d\n"
                        "ESCD_size %d\n"
                        "NVRAM_base 0x%x\n",
                        escd.min_escd_write_size,
                        escd.escd_size, escd.nv_storage_base);
+       return 0;
 }
 
+static int escd_info_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, escd_info_proc_show, NULL);
+}
+
+static const struct file_operations escd_info_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = escd_info_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 #define MAX_SANE_ESCD_SIZE (32*1024)
-static int proc_read_escd(char *buf, char **start, off_t pos,
-                         int count, int *eof, void *data)
+static int escd_proc_show(struct seq_file *m, void *v)
 {
        struct escd_info_struc escd;
        char *tmpbuf;
-       int escd_size, escd_left_to_read, n;
+       int escd_size;
 
        if (pnp_bios_escd_info(&escd))
                return -EIO;
@@ -76,7 +100,7 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
        /* sanity check */
        if (escd.escd_size > MAX_SANE_ESCD_SIZE) {
                printk(KERN_ERR
-                      "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n");
+                      "PnPBIOS: %s: ESCD size reported by BIOS escd_info call is too great\n", __func__);
                return -EFBIG;
        }
 
@@ -94,56 +118,75 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
 
        /* sanity check */
        if (escd_size > MAX_SANE_ESCD_SIZE) {
-               printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by"
-                               " BIOS read_escd call is too great\n");
+               printk(KERN_ERR "PnPBIOS: %s: ESCD size reported by"
+                               " BIOS read_escd call is too great\n", __func__);
                kfree(tmpbuf);
                return -EFBIG;
        }
 
-       escd_left_to_read = escd_size - pos;
-       if (escd_left_to_read < 0)
-               escd_left_to_read = 0;
-       if (escd_left_to_read == 0)
-               *eof = 1;
-       n = min(count, escd_left_to_read);
-       memcpy(buf, tmpbuf + pos, n);
+       seq_write(m, tmpbuf, escd_size);
        kfree(tmpbuf);
-       *start = buf;
-       return n;
+       return 0;
 }
 
-static int proc_read_legacyres(char *buf, char **start, off_t pos,
-                              int count, int *eof, void *data)
+static int escd_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, escd_proc_show, NULL);
+}
+
+static const struct file_operations escd_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = escd_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int pnp_legacyres_proc_show(struct seq_file *m, void *v)
 {
-       /* Assume that the following won't overflow the buffer */
-       if (pnp_bios_get_stat_res(buf))
+       void *buf;
+
+       buf = kmalloc(65536, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+       if (pnp_bios_get_stat_res(buf)) {
+               kfree(buf);
                return -EIO;
+       }
+
+       seq_write(m, buf, 65536);
+       kfree(buf);
+       return 0;
+}
 
-       return count;           // FIXME: Return actual length
+static int pnp_legacyres_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, pnp_legacyres_proc_show, NULL);
 }
 
-static int proc_read_devices(char *buf, char **start, off_t pos,
-                            int count, int *eof, void *data)
+static const struct file_operations pnp_legacyres_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = pnp_legacyres_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int pnp_devices_proc_show(struct seq_file *m, void *v)
 {
        struct pnp_bios_node *node;
        u8 nodenum;
-       char *p = buf;
-
-       if (pos >= 0xff)
-               return 0;
 
        node = kzalloc(node_info.max_node_size, GFP_KERNEL);
        if (!node)
                return -ENOMEM;
 
-       for (nodenum = pos; nodenum < 0xff;) {
+       for (nodenum = 0; nodenum < 0xff;) {
                u8 thisnodenum = nodenum;
-               /* 26 = the number of characters per line sprintf'ed */
-               if ((p - buf + 26) > count)
-                       break;
+
                if (pnp_bios_get_dev_node(&nodenum, PNPMODE_DYNAMIC, node))
                        break;
-               p += sprintf(p, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n",
+               seq_printf(m, "%02x\t%08x\t%02x:%02x:%02x\t%04x\n",
                             node->handle, node->eisa_id,
                             node->type_code[0], node->type_code[1],
                             node->type_code[2], node->flags);
@@ -153,20 +196,29 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
                               "PnPBIOS: proc_read_devices:",
                               (unsigned int)nodenum,
                               (unsigned int)thisnodenum);
-                       *eof = 1;
                        break;
                }
        }
        kfree(node);
-       if (nodenum == 0xff)
-               *eof = 1;
-       *start = (char *)((off_t) nodenum - pos);
-       return p - buf;
+       return 0;
+}
+
+static int pnp_devices_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, pnp_devices_proc_show, NULL);
 }
 
-static int proc_read_node(char *buf, char **start, off_t pos,
-                         int count, int *eof, void *data)
+static const struct file_operations pnp_devices_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = pnp_devices_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int pnpbios_proc_show(struct seq_file *m, void *v)
 {
+       void *data = m->private;
        struct pnp_bios_node *node;
        int boot = (long)data >> 8;
        u8 nodenum = (long)data;
@@ -180,14 +232,20 @@ static int proc_read_node(char *buf, char **start, off_t pos,
                return -EIO;
        }
        len = node->size - sizeof(struct pnp_bios_node);
-       memcpy(buf, node->data, len);
+       seq_write(m, node->data, len);
        kfree(node);
-       return len;
+       return 0;
+}
+
+static int pnpbios_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, pnpbios_proc_show, PDE(inode)->data);
 }
 
-static int proc_write_node(struct file *file, const char __user * buf,
-                          unsigned long count, void *data)
+static ssize_t pnpbios_proc_write(struct file *file, const char __user *buf,
+                                 size_t count, loff_t *pos)
 {
+       void *data = PDE(file->f_path.dentry->d_inode)->data;
        struct pnp_bios_node *node;
        int boot = (long)data >> 8;
        u8 nodenum = (long)data;
@@ -218,34 +276,33 @@ out:
        return ret;
 }
 
+static const struct file_operations pnpbios_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = pnpbios_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = pnpbios_proc_write,
+};
+
 int pnpbios_interface_attach_device(struct pnp_bios_node *node)
 {
        char name[3];
-       struct proc_dir_entry *ent;
 
        sprintf(name, "%02x", node->handle);
 
        if (!proc_pnp)
                return -EIO;
        if (!pnpbios_dont_use_current_config) {
-               ent = create_proc_entry(name, 0, proc_pnp);
-               if (ent) {
-                       ent->read_proc = proc_read_node;
-                       ent->write_proc = proc_write_node;
-                       ent->data = (void *)(long)(node->handle);
-               }
+               proc_create_data(name, 0644, proc_pnp, &pnpbios_proc_fops,
+                                (void *)(long)(node->handle));
        }
 
        if (!proc_pnp_boot)
                return -EIO;
-       ent = create_proc_entry(name, 0, proc_pnp_boot);
-       if (ent) {
-               ent->read_proc = proc_read_node;
-               ent->write_proc = proc_write_node;
-               ent->data = (void *)(long)(node->handle + 0x100);
+       if (proc_create_data(name, 0644, proc_pnp_boot, &pnpbios_proc_fops,
+                            (void *)(long)(node->handle + 0x100)))
                return 0;
-       }
-
        return -EIO;
 }
 
@@ -262,14 +319,11 @@ int __init pnpbios_proc_init(void)
        proc_pnp_boot = proc_mkdir("boot", proc_pnp);
        if (!proc_pnp_boot)
                return -EIO;
-       create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL);
-       create_proc_read_entry("configuration_info", 0, proc_pnp,
-                              proc_read_pnpconfig, NULL);
-       create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo,
-                              NULL);
-       create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL);
-       create_proc_read_entry("legacy_device_resources", 0, proc_pnp,
-                              proc_read_legacyres, NULL);
+       proc_create("devices", 0, proc_pnp, &pnp_devices_proc_fops);
+       proc_create("configuration_info", 0, proc_pnp, &pnpconfig_proc_fops);
+       proc_create("escd_info", 0, proc_pnp, &escd_info_proc_fops);
+       proc_create("escd", S_IRUSR, proc_pnp, &escd_proc_fops);
+       proc_create("legacy_device_resources", 0, proc_pnp, &pnp_legacyres_proc_fops);
 
        return 0;
 }
index 1186749255162501b3179b46568de528a4f94a39..d4b3d67f05487e484a811a152ba6f233b8c00c4a 100644 (file)
@@ -29,6 +29,13 @@ config APM_POWER
          Say Y here to enable support APM status emulation using
          battery class devices.
 
+config WM831X_BACKUP
+       tristate "WM831X backup battery charger support"
+       depends on MFD_WM831X
+       help
+         Say Y here to enable support for the backup battery charger
+         in the Wolfson Microelectronics WM831x PMICs.
+
 config WM831X_POWER
        tristate "WM831X PMU support"
        depends on MFD_WM831X
index 356cdfd3c8b250888d27f91d7bee72af1b692b90..573597c683b46b3c9b3298780f0c9365e86428a6 100644 (file)
@@ -16,6 +16,7 @@ obj-$(CONFIG_POWER_SUPPLY)    += power_supply.o
 
 obj-$(CONFIG_PDA_POWER)                += pda_power.o
 obj-$(CONFIG_APM_POWER)                += apm_power.o
+obj-$(CONFIG_WM831X_BACKUP)    += wm831x_backup.o
 obj-$(CONFIG_WM831X_POWER)     += wm831x_power.o
 obj-$(CONFIG_WM8350_POWER)     += wm8350_power.o
 
index 6a84a8eb8d7ac711ae0fa46b87ea8d63d7be80ff..ea3fdfaca90dd70cd31815d4fdc23901414f0b4c 100644 (file)
 struct pcf50633_mbc {
        struct pcf50633 *pcf;
 
-       int adapter_active;
        int adapter_online;
-       int usb_active;
        int usb_online;
 
        struct power_supply usb;
        struct power_supply adapter;
-
-       struct delayed_work charging_restart_work;
+       struct power_supply ac;
 };
 
 int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
@@ -47,16 +44,21 @@ int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
        u8 bits;
        int charging_start = 1;
        u8 mbcs2, chgmod;
+       unsigned int mbcc5;
 
-       if (ma >= 1000)
+       if (ma >= 1000) {
                bits = PCF50633_MBCC7_USB_1000mA;
-       else if (ma >= 500)
+               ma = 1000;
+       } else if (ma >= 500) {
                bits = PCF50633_MBCC7_USB_500mA;
-       else if (ma >= 100)
+               ma = 500;
+       } else if (ma >= 100) {
                bits = PCF50633_MBCC7_USB_100mA;
-       else {
+               ma = 100;
+       } else {
                bits = PCF50633_MBCC7_USB_SUSPEND;
                charging_start = 0;
+               ma = 0;
        }
 
        ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC7,
@@ -66,21 +68,40 @@ int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
        else
                dev_info(pcf->dev, "usb curlim to %d mA\n", ma);
 
-       /* Manual charging start */
-       mbcs2 = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
+       /*
+        * We limit the charging current to be the USB current limit.
+        * The reason is that on pcf50633, when it enters PMU Standby mode,
+        * which it does when the device goes "off", the USB current limit
+        * reverts to the variant default.  In at least one common case, that
+        * default is 500mA.  By setting the charging current to be the same
+        * as the USB limit we set here before PMU standby, we enforce it only
+        * using the correct amount of current even when the USB current limit
+        * gets reset to the wrong thing
+        */
+
+       if (mbc->pcf->pdata->charger_reference_current_ma) {
+               mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma;
+               if (mbcc5 > 255)
+                       mbcc5 = 255;
+               pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
+       }
+
+       mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2);
        chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
 
        /* If chgmod == BATFULL, setting chgena has no effect.
-        * We need to set resume instead.
+        * Datasheet says we need to set resume instead but when autoresume is
+        * used resume doesn't work. Clear and set chgena instead.
         */
        if (chgmod != PCF50633_MBCS2_MBC_BAT_FULL)
                pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC1,
                                PCF50633_MBCC1_CHGENA, PCF50633_MBCC1_CHGENA);
-       else
+       else {
+               pcf50633_reg_clear_bits(pcf, PCF50633_REG_MBCC1,
+                               PCF50633_MBCC1_CHGENA);
                pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC1,
-                               PCF50633_MBCC1_RESUME, PCF50633_MBCC1_RESUME);
-
-       mbc->usb_active = charging_start;
+                               PCF50633_MBCC1_CHGENA, PCF50633_MBCC1_CHGENA);
+       }
 
        power_supply_changed(&mbc->usb);
 
@@ -92,20 +113,44 @@ int pcf50633_mbc_get_status(struct pcf50633 *pcf)
 {
        struct pcf50633_mbc *mbc  = platform_get_drvdata(pcf->mbc_pdev);
        int status = 0;
+       u8 chgmod;
+
+       if (!mbc)
+               return 0;
+
+       chgmod = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2)
+               & PCF50633_MBCS2_MBC_MASK;
 
        if (mbc->usb_online)
                status |= PCF50633_MBC_USB_ONLINE;
-       if (mbc->usb_active)
+       if (chgmod == PCF50633_MBCS2_MBC_USB_PRE ||
+           chgmod == PCF50633_MBCS2_MBC_USB_PRE_WAIT ||
+           chgmod == PCF50633_MBCS2_MBC_USB_FAST ||
+           chgmod == PCF50633_MBCS2_MBC_USB_FAST_WAIT)
                status |= PCF50633_MBC_USB_ACTIVE;
        if (mbc->adapter_online)
                status |= PCF50633_MBC_ADAPTER_ONLINE;
-       if (mbc->adapter_active)
+       if (chgmod == PCF50633_MBCS2_MBC_ADP_PRE ||
+           chgmod == PCF50633_MBCS2_MBC_ADP_PRE_WAIT ||
+           chgmod == PCF50633_MBCS2_MBC_ADP_FAST ||
+           chgmod == PCF50633_MBCS2_MBC_ADP_FAST_WAIT)
                status |= PCF50633_MBC_ADAPTER_ACTIVE;
 
        return status;
 }
 EXPORT_SYMBOL_GPL(pcf50633_mbc_get_status);
 
+int pcf50633_mbc_get_usb_online_status(struct pcf50633 *pcf)
+{
+       struct pcf50633_mbc *mbc  = platform_get_drvdata(pcf->mbc_pdev);
+
+       if (!mbc)
+               return 0;
+
+       return mbc->usb_online;
+}
+EXPORT_SYMBOL_GPL(pcf50633_mbc_get_usb_online_status);
+
 static ssize_t
 show_chgmode(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -156,9 +201,55 @@ static ssize_t set_usblim(struct device *dev,
 
 static DEVICE_ATTR(usb_curlim, S_IRUGO | S_IWUSR, show_usblim, set_usblim);
 
+static ssize_t
+show_chglim(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
+       u8 mbcc5 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC5);
+       unsigned int ma;
+
+       if (!mbc->pcf->pdata->charger_reference_current_ma)
+               return -ENODEV;
+
+       ma = (mbc->pcf->pdata->charger_reference_current_ma *  mbcc5) >> 8;
+
+       return sprintf(buf, "%u\n", ma);
+}
+
+static ssize_t set_chglim(struct device *dev,
+               struct device_attribute *attr, const char *buf, size_t count)
+{
+       struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
+       unsigned long ma;
+       unsigned int mbcc5;
+       int ret;
+
+       if (!mbc->pcf->pdata->charger_reference_current_ma)
+               return -ENODEV;
+
+       ret = strict_strtoul(buf, 10, &ma);
+       if (ret)
+               return -EINVAL;
+
+       mbcc5 = (ma << 8) / mbc->pcf->pdata->charger_reference_current_ma;
+       if (mbcc5 > 255)
+               mbcc5 = 255;
+       pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
+
+       return count;
+}
+
+/*
+ * This attribute allows to change MBC charging limit on the fly
+ * independently of usb current limit. It also gets set automatically every
+ * time usb current limit is changed.
+ */
+static DEVICE_ATTR(chg_curlim, S_IRUGO | S_IWUSR, show_chglim, set_chglim);
+
 static struct attribute *pcf50633_mbc_sysfs_entries[] = {
        &dev_attr_chgmode.attr,
        &dev_attr_usb_curlim.attr,
+       &dev_attr_chg_curlim.attr,
        NULL,
 };
 
@@ -167,76 +258,26 @@ static struct attribute_group mbc_attr_group = {
        .attrs  = pcf50633_mbc_sysfs_entries,
 };
 
-/* MBC state machine switches into charging mode when the battery voltage
- * falls below 96% of a battery float voltage. But the voltage drop in Li-ion
- * batteries is marginal(1~2 %) till about 80% of its capacity - which means,
- * after a BATFULL, charging won't be restarted until 80%.
- *
- * This work_struct function restarts charging at regular intervals to make
- * sure we don't discharge too much
- */
-
-static void pcf50633_mbc_charging_restart(struct work_struct *work)
-{
-       struct pcf50633_mbc *mbc;
-       u8 mbcs2, chgmod;
-
-       mbc = container_of(work, struct pcf50633_mbc,
-                               charging_restart_work.work);
-
-       mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2);
-       chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
-
-       if (chgmod != PCF50633_MBCS2_MBC_BAT_FULL)
-               return;
-
-       /* Restart charging */
-       pcf50633_reg_set_bit_mask(mbc->pcf, PCF50633_REG_MBCC1,
-                               PCF50633_MBCC1_RESUME, PCF50633_MBCC1_RESUME);
-       mbc->usb_active = 1;
-       power_supply_changed(&mbc->usb);
-
-       dev_info(mbc->pcf->dev, "Charging restarted\n");
-}
-
 static void
 pcf50633_mbc_irq_handler(int irq, void *data)
 {
        struct pcf50633_mbc *mbc = data;
-       int chg_restart_interval =
-                       mbc->pcf->pdata->charging_restart_interval;
 
        /* USB */
        if (irq == PCF50633_IRQ_USBINS) {
                mbc->usb_online = 1;
        } else if (irq == PCF50633_IRQ_USBREM) {
                mbc->usb_online = 0;
-               mbc->usb_active = 0;
                pcf50633_mbc_usb_curlim_set(mbc->pcf, 0);
-               cancel_delayed_work_sync(&mbc->charging_restart_work);
        }
 
        /* Adapter */
-       if (irq == PCF50633_IRQ_ADPINS) {
+       if (irq == PCF50633_IRQ_ADPINS)
                mbc->adapter_online = 1;
-               mbc->adapter_active = 1;
-       } else if (irq == PCF50633_IRQ_ADPREM) {
+       else if (irq == PCF50633_IRQ_ADPREM)
                mbc->adapter_online = 0;
-               mbc->adapter_active = 0;
-       }
-
-       if (irq == PCF50633_IRQ_BATFULL) {
-               mbc->usb_active = 0;
-               mbc->adapter_active = 0;
-
-               if (chg_restart_interval > 0)
-                       schedule_delayed_work(&mbc->charging_restart_work,
-                                                       chg_restart_interval);
-       } else if (irq == PCF50633_IRQ_USBLIMON)
-               mbc->usb_active = 0;
-       else if (irq == PCF50633_IRQ_USBLIMOFF)
-               mbc->usb_active = 1;
 
+       power_supply_changed(&mbc->ac);
        power_supply_changed(&mbc->usb);
        power_supply_changed(&mbc->adapter);
 
@@ -269,10 +310,34 @@ static int usb_get_property(struct power_supply *psy,
 {
        struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb);
        int ret = 0;
+       u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
+                                               PCF50633_MBCC7_USB_MASK;
 
        switch (psp) {
        case POWER_SUPPLY_PROP_ONLINE:
-               val->intval = mbc->usb_online;
+               val->intval = mbc->usb_online &&
+                               (usblim <= PCF50633_MBCC7_USB_500mA);
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+       return ret;
+}
+
+static int ac_get_property(struct power_supply *psy,
+                       enum power_supply_property psp,
+                       union power_supply_propval *val)
+{
+       struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, ac);
+       int ret = 0;
+       u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
+                                               PCF50633_MBCC7_USB_MASK;
+
+       switch (psp) {
+       case POWER_SUPPLY_PROP_ONLINE:
+               val->intval = mbc->usb_online &&
+                               (usblim == PCF50633_MBCC7_USB_1000mA);
                break;
        default:
                ret = -EINVAL;
@@ -336,6 +401,14 @@ static int __devinit pcf50633_mbc_probe(struct platform_device *pdev)
        mbc->usb.supplied_to            = mbc->pcf->pdata->batteries;
        mbc->usb.num_supplicants        = mbc->pcf->pdata->num_batteries;
 
+       mbc->ac.name                    = "ac";
+       mbc->ac.type                    = POWER_SUPPLY_TYPE_MAINS;
+       mbc->ac.properties              = power_props;
+       mbc->ac.num_properties          = ARRAY_SIZE(power_props);
+       mbc->ac.get_property            = ac_get_property;
+       mbc->ac.supplied_to             = mbc->pcf->pdata->batteries;
+       mbc->ac.num_supplicants         = mbc->pcf->pdata->num_batteries;
+
        ret = power_supply_register(&pdev->dev, &mbc->adapter);
        if (ret) {
                dev_err(mbc->pcf->dev, "failed to register adapter\n");
@@ -351,8 +424,14 @@ static int __devinit pcf50633_mbc_probe(struct platform_device *pdev)
                return ret;
        }
 
-       INIT_DELAYED_WORK(&mbc->charging_restart_work,
-                               pcf50633_mbc_charging_restart);
+       ret = power_supply_register(&pdev->dev, &mbc->ac);
+       if (ret) {
+               dev_err(mbc->pcf->dev, "failed to register ac\n");
+               power_supply_unregister(&mbc->adapter);
+               power_supply_unregister(&mbc->usb);
+               kfree(mbc);
+               return ret;
+       }
 
        ret = sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group);
        if (ret)
@@ -378,8 +457,7 @@ static int __devexit pcf50633_mbc_remove(struct platform_device *pdev)
 
        power_supply_unregister(&mbc->usb);
        power_supply_unregister(&mbc->adapter);
-
-       cancel_delayed_work_sync(&mbc->charging_restart_work);
+       power_supply_unregister(&mbc->ac);
 
        kfree(mbc);
 
index 08144393d64b72e7b2a54d44929a6d47cbf18036..c790e0c77d4be02c71917fcdea8a2f91d2c9c33e 100644 (file)
@@ -65,7 +65,10 @@ static ssize_t power_supply_show_property(struct device *dev,
        ret = psy->get_property(psy, off, &value);
 
        if (ret < 0) {
-               if (ret != -ENODEV)
+               if (ret == -ENODATA)
+                       dev_dbg(dev, "driver has no data for `%s' property\n",
+                               attr->attr.name);
+               else if (ret != -ENODEV)
                        dev_err(dev, "driver failed to report `%s' property\n",
                                attr->attr.name);
                return ret;
diff --git a/drivers/power/wm831x_backup.c b/drivers/power/wm831x_backup.c
new file mode 100644 (file)
index 0000000..bf4f387
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Backup battery driver for Wolfson Microelectronics wm831x PMICs
+ *
+ * Copyright 2009 Wolfson Microelectronics PLC.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+
+#include <linux/mfd/wm831x/core.h>
+#include <linux/mfd/wm831x/auxadc.h>
+#include <linux/mfd/wm831x/pmu.h>
+#include <linux/mfd/wm831x/pdata.h>
+
+struct wm831x_backup {
+       struct wm831x *wm831x;
+       struct power_supply backup;
+};
+
+static int wm831x_backup_read_voltage(struct wm831x *wm831x,
+                                    enum wm831x_auxadc src,
+                                    union power_supply_propval *val)
+{
+       int ret;
+
+       ret = wm831x_auxadc_read_uv(wm831x, src);
+       if (ret >= 0)
+               val->intval = ret;
+
+       return ret;
+}
+
+/*********************************************************************
+ *             Backup supply properties
+ *********************************************************************/
+
+static void wm831x_config_backup(struct wm831x *wm831x)
+{
+       struct wm831x_pdata *wm831x_pdata = wm831x->dev->platform_data;
+       struct wm831x_backup_pdata *pdata;
+       int ret, reg;
+
+       if (!wm831x_pdata || !wm831x_pdata->backup) {
+               dev_warn(wm831x->dev,
+                        "No backup battery charger configuration\n");
+               return;
+       }
+
+       pdata = wm831x_pdata->backup;
+
+       reg = 0;
+
+       if (pdata->charger_enable)
+               reg |= WM831X_BKUP_CHG_ENA | WM831X_BKUP_BATT_DET_ENA;
+       if (pdata->no_constant_voltage)
+               reg |= WM831X_BKUP_CHG_MODE;
+
+       switch (pdata->vlim) {
+       case 2500:
+               break;
+       case 3100:
+               reg |= WM831X_BKUP_CHG_VLIM;
+               break;
+       default:
+               dev_err(wm831x->dev, "Invalid backup voltage limit %dmV\n",
+                       pdata->vlim);
+       }
+
+       switch (pdata->ilim) {
+       case 100:
+               break;
+       case 200:
+               reg |= 1;
+               break;
+       case 300:
+               reg |= 2;
+               break;
+       case 400:
+               reg |= 3;
+               break;
+       default:
+               dev_err(wm831x->dev, "Invalid backup current limit %duA\n",
+                       pdata->ilim);
+       }
+
+       ret = wm831x_reg_unlock(wm831x);
+       if (ret != 0) {
+               dev_err(wm831x->dev, "Failed to unlock registers: %d\n", ret);
+               return;
+       }
+
+       ret = wm831x_set_bits(wm831x, WM831X_BACKUP_CHARGER_CONTROL,
+                             WM831X_BKUP_CHG_ENA_MASK |
+                             WM831X_BKUP_CHG_MODE_MASK |
+                             WM831X_BKUP_BATT_DET_ENA_MASK |
+                             WM831X_BKUP_CHG_VLIM_MASK |
+                             WM831X_BKUP_CHG_ILIM_MASK,
+                             reg);
+       if (ret != 0)
+               dev_err(wm831x->dev,
+                       "Failed to set backup charger config: %d\n", ret);
+
+       wm831x_reg_lock(wm831x);
+}
+
+static int wm831x_backup_get_prop(struct power_supply *psy,
+                                 enum power_supply_property psp,
+                                 union power_supply_propval *val)
+{
+       struct wm831x_backup *devdata = dev_get_drvdata(psy->dev->parent);
+       struct wm831x *wm831x = devdata->wm831x;
+       int ret = 0;
+
+       ret = wm831x_reg_read(wm831x, WM831X_BACKUP_CHARGER_CONTROL);
+       if (ret < 0)
+               return ret;
+
+       switch (psp) {
+       case POWER_SUPPLY_PROP_STATUS:
+               if (ret & WM831X_BKUP_CHG_STS)
+                       val->intval = POWER_SUPPLY_STATUS_CHARGING;
+               else
+                       val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
+               break;
+
+       case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+               ret = wm831x_backup_read_voltage(wm831x, WM831X_AUX_BKUP_BATT,
+                                               val);
+               break;
+
+       case POWER_SUPPLY_PROP_PRESENT:
+               if (ret & WM831X_BKUP_CHG_STS)
+                       val->intval = 1;
+               else
+                       val->intval = 0;
+               break;
+
+       default:
+               ret = -EINVAL;
+               break;
+       }
+
+       return ret;
+}
+
+static enum power_supply_property wm831x_backup_props[] = {
+       POWER_SUPPLY_PROP_STATUS,
+       POWER_SUPPLY_PROP_VOLTAGE_NOW,
+       POWER_SUPPLY_PROP_PRESENT,
+};
+
+/*********************************************************************
+ *             Initialisation
+ *********************************************************************/
+
+static __devinit int wm831x_backup_probe(struct platform_device *pdev)
+{
+       struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
+       struct wm831x_backup *devdata;
+       struct power_supply *backup;
+       int ret;
+
+       devdata = kzalloc(sizeof(struct wm831x_backup), GFP_KERNEL);
+       if (devdata == NULL)
+               return -ENOMEM;
+
+       devdata->wm831x = wm831x;
+       platform_set_drvdata(pdev, devdata);
+
+       backup = &devdata->backup;
+
+       /* We ignore configuration failures since we can still read
+        * back the status without enabling the charger (which may
+        * already be enabled anyway).
+        */
+       wm831x_config_backup(wm831x);
+
+       backup->name = "wm831x-backup";
+       backup->type = POWER_SUPPLY_TYPE_BATTERY;
+       backup->properties = wm831x_backup_props;
+       backup->num_properties = ARRAY_SIZE(wm831x_backup_props);
+       backup->get_property = wm831x_backup_get_prop;
+       ret = power_supply_register(&pdev->dev, backup);
+       if (ret)
+               goto err_kmalloc;
+
+       return ret;
+
+err_kmalloc:
+       kfree(devdata);
+       return ret;
+}
+
+static __devexit int wm831x_backup_remove(struct platform_device *pdev)
+{
+       struct wm831x_backup *devdata = platform_get_drvdata(pdev);
+
+       power_supply_unregister(&devdata->backup);
+       kfree(devdata);
+
+       return 0;
+}
+
+static struct platform_driver wm831x_backup_driver = {
+       .probe = wm831x_backup_probe,
+       .remove = __devexit_p(wm831x_backup_remove),
+       .driver = {
+               .name = "wm831x-backup",
+       },
+};
+
+static int __init wm831x_backup_init(void)
+{
+       return platform_driver_register(&wm831x_backup_driver);
+}
+module_init(wm831x_backup_init);
+
+static void __exit wm831x_backup_exit(void)
+{
+       platform_driver_unregister(&wm831x_backup_driver);
+}
+module_exit(wm831x_backup_exit);
+
+MODULE_DESCRIPTION("Backup battery charger driver for WM831x PMICs");
+MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:wm831x-backup");
index 2a4c8b0b829c81d23dbf852f6def327071521d89..f85e80b1b400c917963010d679dd394c0326b7d7 100644 (file)
@@ -21,7 +21,6 @@
 struct wm831x_power {
        struct wm831x *wm831x;
        struct power_supply wall;
-       struct power_supply backup;
        struct power_supply usb;
        struct power_supply battery;
 };
@@ -453,125 +452,6 @@ static irqreturn_t wm831x_bat_irq(int irq, void *data)
 }
 
 
-/*********************************************************************
- *             Backup supply properties
- *********************************************************************/
-
-static void wm831x_config_backup(struct wm831x *wm831x)
-{
-       struct wm831x_pdata *wm831x_pdata = wm831x->dev->platform_data;
-       struct wm831x_backup_pdata *pdata;
-       int ret, reg;
-
-       if (!wm831x_pdata || !wm831x_pdata->backup) {
-               dev_warn(wm831x->dev,
-                        "No backup battery charger configuration\n");
-               return;
-       }
-
-       pdata = wm831x_pdata->backup;
-
-       reg = 0;
-
-       if (pdata->charger_enable)
-               reg |= WM831X_BKUP_CHG_ENA | WM831X_BKUP_BATT_DET_ENA;
-       if (pdata->no_constant_voltage)
-               reg |= WM831X_BKUP_CHG_MODE;
-
-       switch (pdata->vlim) {
-       case 2500:
-               break;
-       case 3100:
-               reg |= WM831X_BKUP_CHG_VLIM;
-               break;
-       default:
-               dev_err(wm831x->dev, "Invalid backup voltage limit %dmV\n",
-                       pdata->vlim);
-       }
-
-       switch (pdata->ilim) {
-       case 100:
-               break;
-       case 200:
-               reg |= 1;
-               break;
-       case 300:
-               reg |= 2;
-               break;
-       case 400:
-               reg |= 3;
-               break;
-       default:
-               dev_err(wm831x->dev, "Invalid backup current limit %duA\n",
-                       pdata->ilim);
-       }
-
-       ret = wm831x_reg_unlock(wm831x);
-       if (ret != 0) {
-               dev_err(wm831x->dev, "Failed to unlock registers: %d\n", ret);
-               return;
-       }
-
-       ret = wm831x_set_bits(wm831x, WM831X_BACKUP_CHARGER_CONTROL,
-                             WM831X_BKUP_CHG_ENA_MASK |
-                             WM831X_BKUP_CHG_MODE_MASK |
-                             WM831X_BKUP_BATT_DET_ENA_MASK |
-                             WM831X_BKUP_CHG_VLIM_MASK |
-                             WM831X_BKUP_CHG_ILIM_MASK,
-                             reg);
-       if (ret != 0)
-               dev_err(wm831x->dev,
-                       "Failed to set backup charger config: %d\n", ret);
-
-       wm831x_reg_lock(wm831x);
-}
-
-static int wm831x_backup_get_prop(struct power_supply *psy,
-                                 enum power_supply_property psp,
-                                 union power_supply_propval *val)
-{
-       struct wm831x_power *wm831x_power = dev_get_drvdata(psy->dev->parent);
-       struct wm831x *wm831x = wm831x_power->wm831x;
-       int ret = 0;
-
-       ret = wm831x_reg_read(wm831x, WM831X_BACKUP_CHARGER_CONTROL);
-       if (ret < 0)
-               return ret;
-
-       switch (psp) {
-       case POWER_SUPPLY_PROP_STATUS:
-               if (ret & WM831X_BKUP_CHG_STS)
-                       val->intval = POWER_SUPPLY_STATUS_CHARGING;
-               else
-                       val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
-               break;
-
-       case POWER_SUPPLY_PROP_VOLTAGE_NOW:
-               ret = wm831x_power_read_voltage(wm831x, WM831X_AUX_BKUP_BATT,
-                                               val);
-               break;
-
-       case POWER_SUPPLY_PROP_PRESENT:
-               if (ret & WM831X_BKUP_CHG_STS)
-                       val->intval = 1;
-               else
-                       val->intval = 0;
-               break;
-
-       default:
-               ret = -EINVAL;
-               break;
-       }
-
-       return ret;
-}
-
-static enum power_supply_property wm831x_backup_props[] = {
-       POWER_SUPPLY_PROP_STATUS,
-       POWER_SUPPLY_PROP_VOLTAGE_NOW,
-       POWER_SUPPLY_PROP_PRESENT,
-};
-
 /*********************************************************************
  *             Initialisation
  *********************************************************************/
@@ -595,10 +475,7 @@ static irqreturn_t wm831x_pwr_src_irq(int irq, void *data)
 
        dev_dbg(wm831x->dev, "Power source changed\n");
 
-       /* Just notify for everything - little harm in overnotifying.
-        * The backup battery is not a power source while the system
-        * is running so skip that.
-        */
+       /* Just notify for everything - little harm in overnotifying. */
        power_supply_changed(&wm831x_power->battery);
        power_supply_changed(&wm831x_power->usb);
        power_supply_changed(&wm831x_power->wall);
@@ -613,7 +490,6 @@ static __devinit int wm831x_power_probe(struct platform_device *pdev)
        struct power_supply *usb;
        struct power_supply *battery;
        struct power_supply *wall;
-       struct power_supply *backup;
        int ret, irq, i;
 
        power = kzalloc(sizeof(struct wm831x_power), GFP_KERNEL);
@@ -626,13 +502,11 @@ static __devinit int wm831x_power_probe(struct platform_device *pdev)
        usb = &power->usb;
        battery = &power->battery;
        wall = &power->wall;
-       backup = &power->backup;
 
        /* We ignore configuration failures since we can still read back
-        * the status without enabling either of the chargers.
+        * the status without enabling the charger.
         */
        wm831x_config_battery(wm831x);
-       wm831x_config_backup(wm831x);
 
        wall->name = "wm831x-wall";
        wall->type = POWER_SUPPLY_TYPE_MAINS;
@@ -661,15 +535,6 @@ static __devinit int wm831x_power_probe(struct platform_device *pdev)
        if (ret)
                goto err_battery;
 
-       backup->name = "wm831x-backup";
-       backup->type = POWER_SUPPLY_TYPE_BATTERY;
-       backup->properties = wm831x_backup_props;
-       backup->num_properties = ARRAY_SIZE(wm831x_backup_props);
-       backup->get_property = wm831x_backup_get_prop;
-       ret = power_supply_register(&pdev->dev, backup);
-       if (ret)
-               goto err_usb;
-
        irq = platform_get_irq_byname(pdev, "SYSLO");
        ret = wm831x_request_irq(wm831x, irq, wm831x_syslo_irq,
                                 IRQF_TRIGGER_RISING, "SYSLO",
@@ -677,7 +542,7 @@ static __devinit int wm831x_power_probe(struct platform_device *pdev)
        if (ret != 0) {
                dev_err(&pdev->dev, "Failed to request SYSLO IRQ %d: %d\n",
                        irq, ret);
-               goto err_backup;
+               goto err_usb;
        }
 
        irq = platform_get_irq_byname(pdev, "PWR SRC");
@@ -716,8 +581,6 @@ err_bat_irq:
 err_syslo:
        irq = platform_get_irq_byname(pdev, "SYSLO");
        wm831x_free_irq(wm831x, irq, power);
-err_backup:
-       power_supply_unregister(backup);
 err_usb:
        power_supply_unregister(usb);
 err_battery:
@@ -746,7 +609,6 @@ static __devexit int wm831x_power_remove(struct platform_device *pdev)
        irq = platform_get_irq_byname(pdev, "SYSLO");
        wm831x_free_irq(wm831x, irq, wm831x_power);
 
-       power_supply_unregister(&wm831x_power->backup);
        power_supply_unregister(&wm831x_power->battery);
        power_supply_unregister(&wm831x_power->wall);
        power_supply_unregister(&wm831x_power->usb);
index f2bfd296dbae05133134b02c05daf9df12da6fa0..fa39e759a275a2a49ef7a0ceb306c4eee9c5abbf 100644 (file)
@@ -157,7 +157,7 @@ static int wm97xx_bat_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops wm97xx_bat_pm_ops = {
+static const struct dev_pm_ops wm97xx_bat_pm_ops = {
        .suspend        = wm97xx_bat_suspend,
        .resume         = wm97xx_bat_resume,
 };
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
new file mode 100644 (file)
index 0000000..0471955
--- /dev/null
@@ -0,0 +1,685 @@
+/*
+ * Regulators driver for Marvell 88PM8607
+ *
+ * Copyright (C) 2009 Marvell International Ltd.
+ *     Haojian Zhuang <haojian.zhuang@marvell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/mfd/88pm8607.h>
+
+struct pm8607_regulator_info {
+       struct regulator_desc   desc;
+       struct pm8607_chip      *chip;
+       struct regulator_dev    *regulator;
+
+       int     min_uV;
+       int     max_uV;
+       int     step_uV;
+       int     vol_reg;
+       int     vol_shift;
+       int     vol_nbits;
+       int     update_reg;
+       int     update_bit;
+       int     enable_reg;
+       int     enable_bit;
+       int     slope_double;
+};
+
+static inline int check_range(struct pm8607_regulator_info *info,
+                               int min_uV, int max_uV)
+{
+       if (max_uV < info->min_uV || min_uV > info->max_uV || min_uV > max_uV)
+               return -EINVAL;
+
+       return 0;
+}
+
+static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
+{
+       struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
+       uint8_t chip_id = info->chip->chip_id;
+       int ret = -EINVAL;
+
+       switch (info->desc.id) {
+       case PM8607_ID_BUCK1:
+               ret = (index < 0x1d) ? (index * 25000 + 800000) :
+                       ((index < 0x20) ? 1500000 :
+                       ((index < 0x40) ? ((index - 0x20) * 25000) :
+                       -EINVAL));
+               break;
+       case PM8607_ID_BUCK3:
+               ret = (index < 0x3d) ? (index * 25000) :
+                       ((index < 0x40) ? 1500000 : -EINVAL);
+               if (ret < 0)
+                       break;
+               if (info->slope_double)
+                       ret <<= 1;
+               break;
+       case PM8607_ID_LDO1:
+               ret = (index == 0) ? 1800000 :
+                       ((index == 1) ? 1200000 :
+                       ((index == 2) ? 2800000 : -EINVAL));
+               break;
+       case PM8607_ID_LDO5:
+               ret = (index == 0) ? 2900000 :
+                       ((index == 1) ? 3000000 :
+                       ((index == 2) ? 3100000 : 3300000));
+               break;
+       case PM8607_ID_LDO7:
+       case PM8607_ID_LDO8:
+               ret = (index < 3) ? (index * 50000 + 1800000) :
+                       ((index < 8) ? (index * 50000 + 2550000) :
+                        -EINVAL);
+               break;
+       case PM8607_ID_LDO12:
+               ret = (index < 2) ? (index * 100000 + 1800000) :
+                       ((index < 7) ? (index * 100000 + 2500000) :
+                       ((index == 7) ? 3300000 : 1200000));
+               break;
+       case PM8607_ID_LDO2:
+       case PM8607_ID_LDO3:
+       case PM8607_ID_LDO9:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       ret = (index < 3) ? (index * 50000 + 1800000) :
+                               ((index < 8) ? (index * 50000 + 2550000) :
+                                -EINVAL);
+                       break;
+               case PM8607_CHIP_B0:
+                       ret = (index < 3) ? (index * 50000 + 1800000) :
+                               ((index < 7) ? (index * 50000 + 2550000) :
+                               3300000);
+                       break;
+               }
+               break;
+       case PM8607_ID_LDO4:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       ret = (index < 3) ? (index * 50000 + 1800000) :
+                               ((index < 8) ? (index * 50000 + 2550000) :
+                                -EINVAL);
+                       break;
+               case PM8607_CHIP_B0:
+                       ret = (index < 3) ? (index * 50000 + 1800000) :
+                               ((index < 6) ? (index * 50000 + 2550000) :
+                               ((index == 6) ? 2900000 : 3300000));
+                       break;
+               }
+               break;
+       case PM8607_ID_LDO6:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       ret = (index < 3) ? (index * 50000 + 1800000) :
+                               ((index < 8) ? (index * 50000 + 2450000) :
+                               -EINVAL);
+                       break;
+               case PM8607_CHIP_B0:
+                       ret = (index < 2) ? (index * 50000 + 1800000) :
+                               ((index < 7) ? (index * 50000 + 2500000) :
+                               3300000);
+                       break;
+               }
+               break;
+       case PM8607_ID_LDO10:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       ret = (index < 3) ? (index * 50000 + 1800000) :
+                               ((index < 8) ? (index * 50000 + 2550000) :
+                               1200000);
+                       break;
+               case PM8607_CHIP_B0:
+                       ret = (index < 3) ? (index * 50000 + 1800000) :
+                               ((index < 7) ? (index * 50000 + 2550000) :
+                               ((index == 7) ? 3300000 : 1200000));
+                       break;
+               }
+               break;
+       case PM8607_ID_LDO14:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       ret = (index < 3) ? (index * 50000 + 1800000) :
+                               ((index < 8) ? (index * 50000 + 2550000) :
+                                -EINVAL);
+                       break;
+               case PM8607_CHIP_B0:
+                       ret = (index < 2) ? (index * 50000 + 1800000) :
+                               ((index < 7) ? (index * 50000 + 2600000) :
+                               3300000);
+                       break;
+               }
+               break;
+       }
+       return ret;
+}
+
+static int choose_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
+{
+       struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
+       uint8_t chip_id = info->chip->chip_id;
+       int val = -ENOENT;
+       int ret;
+
+       switch (info->desc.id) {
+       case PM8607_ID_BUCK1:
+               if (min_uV >= 800000)           /* 800mV ~ 1500mV / 25mV */
+                       val = (min_uV - 775001) / 25000;
+               else {                          /* 25mV ~ 775mV / 25mV */
+                       val = (min_uV + 249999) / 25000;
+                       val += 32;
+               }
+               break;
+       case PM8607_ID_BUCK3:
+               if (info->slope_double)
+                       min_uV = min_uV >> 1;
+               val = (min_uV + 249999) / 25000; /* 0mV ~ 1500mV / 25mV */
+
+               break;
+       case PM8607_ID_LDO1:
+               if (min_uV > 1800000)
+                       val = 2;
+               else if (min_uV > 1200000)
+                       val = 0;
+               else
+                       val = 1;
+               break;
+       case PM8607_ID_LDO5:
+               if (min_uV > 3100000)
+                       val = 3;
+               else                            /* 2900mV ~ 3100mV / 100mV */
+                       val = (min_uV - 2800001) / 100000;
+               break;
+       case PM8607_ID_LDO7:
+       case PM8607_ID_LDO8:
+               if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */
+                       if (min_uV <= 1800000)
+                               val = 0;        /* 1800mv */
+                       else if (min_uV <= 1900000)
+                               val = (min_uV - 1750001) / 50000;
+                       else
+                               val = 3;        /* 2700mV */
+               } else {                 /* 2700mV ~ 2900mV / 50mV */
+                       if (min_uV <= 2900000) {
+                               val = (min_uV - 2650001) / 50000;
+                               val += 3;
+                       } else
+                               val = -EINVAL;
+               }
+               break;
+       case PM8607_ID_LDO10:
+               if (min_uV > 2850000)
+                       val = 7;
+               else if (min_uV <= 1200000)
+                       val = 8;
+               else if (min_uV < 2700000)      /* 1800mV ~ 1900mV / 50mV */
+                       val = (min_uV - 1750001) / 50000;
+               else {                          /* 2700mV ~ 2850mV / 50mV */
+                       val = (min_uV - 2650001) / 50000;
+                       val += 3;
+               }
+               break;
+       case PM8607_ID_LDO12:
+               if (min_uV < 2700000) {         /* 1800mV ~ 1900mV / 100mV */
+                       if (min_uV <= 1200000)
+                               val = 8;        /* 1200mV */
+                       else if (min_uV <= 1800000)
+                               val = 0;        /* 1800mV */
+                       else if (min_uV <= 1900000)
+                               val = (min_uV - 1700001) / 100000;
+                       else
+                               val = 2;        /* 2700mV */
+               } else {                        /* 2700mV ~ 3100mV / 100mV */
+                       if (min_uV <= 3100000) {
+                               val = (min_uV - 2600001) / 100000;
+                               val += 2;
+                       } else if (min_uV <= 3300000)
+                               val = 7;
+                       else
+                               val = -EINVAL;
+               }
+               break;
+       case PM8607_ID_LDO2:
+       case PM8607_ID_LDO3:
+       case PM8607_ID_LDO9:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       if (min_uV < 2700000)   /* 1800mV ~ 1900mV / 50mV */
+                               if (min_uV <= 1800000)
+                                       val = 0;
+                               else if (min_uV <= 1900000)
+                                       val = (min_uV - 1750001) / 50000;
+                               else
+                                       val = 3;        /* 2700mV */
+                       else {                  /* 2700mV ~ 2900mV / 50mV */
+                               if (min_uV <= 2900000) {
+                                       val = (min_uV - 2650001) / 50000;
+                                       val += 3;
+                               } else
+                                       val = -EINVAL;
+                       }
+                       break;
+               case PM8607_CHIP_B0:
+                       if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */
+                               if (min_uV <= 1800000)
+                                       val = 0;
+                               else if (min_uV <= 1900000)
+                                       val = (min_uV - 1750001) / 50000;
+                               else
+                                       val = 3;        /* 2700mV */
+                       } else {                 /* 2700mV ~ 2850mV / 50mV */
+                               if (min_uV <= 2850000) {
+                                       val = (min_uV - 2650001) / 50000;
+                                       val += 3;
+                               } else if (min_uV <= 3300000)
+                                       val = 7;
+                               else
+                                       val = -EINVAL;
+                       }
+                       break;
+               }
+               break;
+       case PM8607_ID_LDO4:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       if (min_uV < 2700000)   /* 1800mV ~ 1900mV / 50mV */
+                               if (min_uV <= 1800000)
+                                       val = 0;
+                               else if (min_uV <= 1900000)
+                                       val = (min_uV - 1750001) / 50000;
+                               else
+                                       val = 3;        /* 2700mV */
+                       else {                  /* 2700mV ~ 2900mV / 50mV */
+                               if (min_uV <= 2900000) {
+                                       val = (min_uV - 2650001) / 50000;
+                                       val += 3;
+                               } else
+                                       val = -EINVAL;
+                       }
+                       break;
+               case PM8607_CHIP_B0:
+                       if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */
+                               if (min_uV <= 1800000)
+                                       val = 0;
+                               else if (min_uV <= 1900000)
+                                       val = (min_uV - 1750001) / 50000;
+                               else
+                                       val = 3;        /* 2700mV */
+                       } else {                 /* 2700mV ~ 2800mV / 50mV */
+                               if (min_uV <= 2850000) {
+                                       val = (min_uV - 2650001) / 50000;
+                                       val += 3;
+                               } else if (min_uV <= 2900000)
+                                       val = 6;
+                               else if (min_uV <= 3300000)
+                                       val = 7;
+                               else
+                                       val = -EINVAL;
+                       }
+                       break;
+               }
+               break;
+       case PM8607_ID_LDO6:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       if (min_uV < 2600000) { /* 1800mV ~ 1900mV / 50mV */
+                               if (min_uV <= 1800000)
+                                       val = 0;
+                               else if (min_uV <= 1900000)
+                                       val = (min_uV - 1750001) / 50000;
+                               else
+                                       val = 3;        /* 2600mV */
+                       } else {                /* 2600mV ~ 2800mV / 50mV */
+                               if (min_uV <= 2800000) {
+                                       val = (min_uV - 2550001) / 50000;
+                                       val += 3;
+                               } else
+                                       val = -EINVAL;
+                       }
+                       break;
+               case PM8607_CHIP_B0:
+                       if (min_uV < 2600000) { /* 1800mV ~ 1850mV / 50mV */
+                               if (min_uV <= 1800000)
+                                       val = 0;
+                               else if (min_uV <= 1850000)
+                                       val = (min_uV - 1750001) / 50000;
+                               else
+                                       val = 2;        /* 2600mV */
+                       } else {                /* 2600mV ~ 2800mV / 50mV */
+                               if (min_uV <= 2800000) {
+                                       val = (min_uV - 2550001) / 50000;
+                                       val += 2;
+                               } else if (min_uV <= 3300000)
+                                       val = 7;
+                               else
+                                       val = -EINVAL;
+                       }
+                       break;
+               }
+               break;
+       case PM8607_ID_LDO14:
+               switch (chip_id) {
+               case PM8607_CHIP_A0:
+               case PM8607_CHIP_A1:
+                       if (min_uV < 2700000) { /* 1800mV ~ 1900mV / 50mV */
+                               if (min_uV <= 1800000)
+                                       val = 0;
+                               else if (min_uV <= 1900000)
+                                       val = (min_uV - 1750001) / 50000;
+                               else
+                                       val = 3;        /* 2700mV */
+                       } else {                 /* 2700mV ~ 2900mV / 50mV */
+                               if (min_uV <= 2900000) {
+                                       val = (min_uV - 2650001) / 50000;
+                                       val += 3;
+                               } else
+                                       val = -EINVAL;
+                       }
+                       break;
+               case PM8607_CHIP_B0:
+                       if (min_uV < 2700000) { /* 1800mV ~ 1850mV / 50mV */
+                               if (min_uV <= 1800000)
+                                       val = 0;
+                               else if (min_uV <= 1850000)
+                                       val = (min_uV - 1750001) / 50000;
+                               else
+                                       val = 2;        /* 2700mV */
+                       } else {                 /* 2700mV ~ 2900mV / 50mV */
+                               if (min_uV <= 2900000) {
+                                       val = (min_uV - 2650001) / 50000;
+                                       val += 2;
+                               } else if (min_uV <= 3300000)
+                                       val = 7;
+                               else
+                                       val = -EINVAL;
+                       }
+                       break;
+               }
+               break;
+       }
+       if (val >= 0) {
+               ret = pm8607_list_voltage(rdev, val);
+               if (ret > max_uV) {
+                       pr_err("exceed voltage range (%d %d) uV",
+                               min_uV, max_uV);
+                       return -EINVAL;
+               }
+       } else
+               pr_err("invalid voltage range (%d %d) uV", min_uV, max_uV);
+       return val;
+}
+
+static int pm8607_set_voltage(struct regulator_dev *rdev,
+                             int min_uV, int max_uV)
+{
+       struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
+       struct pm8607_chip *chip = info->chip;
+       uint8_t val, mask;
+       int ret;
+
+       if (check_range(info, min_uV, max_uV)) {
+               pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
+               return -EINVAL;
+       }
+
+       ret = choose_voltage(rdev, min_uV, max_uV);
+       if (ret < 0)
+               return -EINVAL;
+       val = (uint8_t)(ret << info->vol_shift);
+       mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
+
+       ret = pm8607_set_bits(chip, info->vol_reg, mask, val);
+       if (ret)
+               return ret;
+       switch (info->desc.id) {
+       case PM8607_ID_BUCK1:
+       case PM8607_ID_BUCK3:
+               ret = pm8607_set_bits(chip, info->update_reg,
+                                     1 << info->update_bit,
+                                     1 << info->update_bit);
+               break;
+       }
+       return ret;
+}
+
+static int pm8607_get_voltage(struct regulator_dev *rdev)
+{
+       struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
+       struct pm8607_chip *chip = info->chip;
+       uint8_t val, mask;
+       int ret;
+
+       ret = pm8607_reg_read(chip, info->vol_reg);
+       if (ret < 0)
+               return ret;
+
+       mask = ((1 << info->vol_nbits) - 1)  << info->vol_shift;
+       val = ((unsigned char)ret & mask) >> info->vol_shift;
+
+       return pm8607_list_voltage(rdev, val);
+}
+
+static int pm8607_enable(struct regulator_dev *rdev)
+{
+       struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
+       struct pm8607_chip *chip = info->chip;
+
+       return pm8607_set_bits(chip, info->enable_reg,
+                              1 << info->enable_bit,
+                              1 << info->enable_bit);
+}
+
+static int pm8607_disable(struct regulator_dev *rdev)
+{
+       struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
+       struct pm8607_chip *chip = info->chip;
+
+       return pm8607_set_bits(chip, info->enable_reg,
+                              1 << info->enable_bit, 0);
+}
+
+static int pm8607_is_enabled(struct regulator_dev *rdev)
+{
+       struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
+       struct pm8607_chip *chip = info->chip;
+       int ret;
+
+       ret = pm8607_reg_read(chip, info->enable_reg);
+       if (ret < 0)
+               return ret;
+
+       return !!((unsigned char)ret & (1 << info->enable_bit));
+}
+
+static struct regulator_ops pm8607_regulator_ops = {
+       .set_voltage    = pm8607_set_voltage,
+       .get_voltage    = pm8607_get_voltage,
+       .enable         = pm8607_enable,
+       .disable        = pm8607_disable,
+       .is_enabled     = pm8607_is_enabled,
+};
+
+#define PM8607_DVC(_id, min, max, step, vreg, nbits, ureg, ubit, ereg, ebit) \
+{                                                                      \
+       .desc   = {                                                     \
+               .name   = "BUCK" #_id,                                  \
+               .ops    = &pm8607_regulator_ops,                        \
+               .type   = REGULATOR_VOLTAGE,                            \
+               .id     = PM8607_ID_BUCK##_id,                          \
+               .owner  = THIS_MODULE,                                  \
+       },                                                              \
+       .min_uV         = (min) * 1000,                                 \
+       .max_uV         = (max) * 1000,                                 \
+       .step_uV        = (step) * 1000,                                \
+       .vol_reg        = PM8607_##vreg,                                \
+       .vol_shift      = (0),                                          \
+       .vol_nbits      = (nbits),                                      \
+       .update_reg     = PM8607_##ureg,                                \
+       .update_bit     = (ubit),                                       \
+       .enable_reg     = PM8607_##ereg,                                \
+       .enable_bit     = (ebit),                                       \
+       .slope_double   = (0),                                          \
+}
+
+#define PM8607_LDO(_id, min, max, step, vreg, shift, nbits, ereg, ebit)        \
+{                                                                      \
+       .desc   = {                                                     \
+               .name   = "LDO" #_id,                                   \
+               .ops    = &pm8607_regulator_ops,                        \
+               .type   = REGULATOR_VOLTAGE,                            \
+               .id     = PM8607_ID_LDO##_id,                           \
+               .owner  = THIS_MODULE,                                  \
+       },                                                              \
+       .min_uV         = (min) * 1000,                                 \
+       .max_uV         = (max) * 1000,                                 \
+       .step_uV        = (step) * 1000,                                \
+       .vol_reg        = PM8607_##vreg,                                \
+       .vol_shift      = (shift),                                      \
+       .vol_nbits      = (nbits),                                      \
+       .enable_reg     = PM8607_##ereg,                                \
+       .enable_bit     = (ebit),                                       \
+       .slope_double   = (0),                                          \
+}
+
+static struct pm8607_regulator_info pm8607_regulator_info[] = {
+       PM8607_DVC(1, 0, 1500, 25, BUCK1, 6, GO, 0, SUPPLIES_EN11, 0),
+       PM8607_DVC(3, 0, 1500, 25, BUCK3, 6, GO, 2, SUPPLIES_EN11, 2),
+
+       PM8607_LDO(1 , 1200, 2800, 0, LDO1 , 0, 2, SUPPLIES_EN11, 3),
+       PM8607_LDO(2 , 1800, 3300, 0, LDO2 , 0, 3, SUPPLIES_EN11, 4),
+       PM8607_LDO(3 , 1800, 3300, 0, LDO3 , 0, 3, SUPPLIES_EN11, 5),
+       PM8607_LDO(4 , 1800, 3300, 0, LDO4 , 0, 3, SUPPLIES_EN11, 6),
+       PM8607_LDO(5 , 2900, 3300, 0, LDO5 , 0, 2, SUPPLIES_EN11, 7),
+       PM8607_LDO(6 , 1800, 3300, 0, LDO6 , 0, 3, SUPPLIES_EN12, 0),
+       PM8607_LDO(7 , 1800, 2900, 0, LDO7 , 0, 3, SUPPLIES_EN12, 1),
+       PM8607_LDO(8 , 1800, 2900, 0, LDO8 , 0, 3, SUPPLIES_EN12, 2),
+       PM8607_LDO(9 , 1800, 3300, 0, LDO9 , 0, 3, SUPPLIES_EN12, 3),
+       PM8607_LDO(10, 1200, 3300, 0, LDO10, 0, 4, SUPPLIES_EN11, 4),
+       PM8607_LDO(12, 1200, 3300, 0, LDO12, 0, 4, SUPPLIES_EN11, 5),
+       PM8607_LDO(14, 1800, 3300, 0, LDO14, 0, 3, SUPPLIES_EN11, 6),
+};
+
+static inline struct pm8607_regulator_info *find_regulator_info(int id)
+{
+       struct pm8607_regulator_info *info;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) {
+               info = &pm8607_regulator_info[i];
+               if (info->desc.id == id)
+                       return info;
+       }
+       return NULL;
+}
+
+static int __devinit pm8607_regulator_probe(struct platform_device *pdev)
+{
+       struct pm8607_chip *chip = dev_get_drvdata(pdev->dev.parent);
+       struct pm8607_platform_data *pdata = chip->dev->platform_data;
+       struct pm8607_regulator_info *info = NULL;
+
+       info = find_regulator_info(pdev->id);
+       if (info == NULL) {
+               dev_err(&pdev->dev, "invalid regulator ID specified\n");
+               return -EINVAL;
+       }
+
+       info->chip = chip;
+
+       info->regulator = regulator_register(&info->desc, &pdev->dev,
+                                            pdata->regulator[pdev->id], info);
+       if (IS_ERR(info->regulator)) {
+               dev_err(&pdev->dev, "failed to register regulator %s\n",
+                       info->desc.name);
+               return PTR_ERR(info->regulator);
+       }
+
+       /* check DVC ramp slope double */
+       if (info->desc.id == PM8607_ID_BUCK3)
+               if (info->chip->buck3_double)
+                       info->slope_double = 1;
+
+       platform_set_drvdata(pdev, info);
+       return 0;
+}
+
+static int __devexit pm8607_regulator_remove(struct platform_device *pdev)
+{
+       struct pm8607_regulator_info *info = platform_get_drvdata(pdev);
+
+       regulator_unregister(info->regulator);
+       return 0;
+}
+
+#define PM8607_REGULATOR_DRIVER(_name)                         \
+{                                                              \
+       .driver         = {                                     \
+               .name   = "88pm8607-" #_name,                   \
+               .owner  = THIS_MODULE,                          \
+       },                                                      \
+       .probe          = pm8607_regulator_probe,               \
+       .remove         = __devexit_p(pm8607_regulator_remove), \
+}
+
+static struct platform_driver pm8607_regulator_driver[] = {
+       PM8607_REGULATOR_DRIVER(buck1),
+       PM8607_REGULATOR_DRIVER(buck2),
+       PM8607_REGULATOR_DRIVER(buck3),
+       PM8607_REGULATOR_DRIVER(ldo1),
+       PM8607_REGULATOR_DRIVER(ldo2),
+       PM8607_REGULATOR_DRIVER(ldo3),
+       PM8607_REGULATOR_DRIVER(ldo4),
+       PM8607_REGULATOR_DRIVER(ldo5),
+       PM8607_REGULATOR_DRIVER(ldo6),
+       PM8607_REGULATOR_DRIVER(ldo7),
+       PM8607_REGULATOR_DRIVER(ldo8),
+       PM8607_REGULATOR_DRIVER(ldo9),
+       PM8607_REGULATOR_DRIVER(ldo10),
+       PM8607_REGULATOR_DRIVER(ldo12),
+       PM8607_REGULATOR_DRIVER(ldo14),
+};
+
+static int __init pm8607_regulator_init(void)
+{
+       int i, count, ret;
+
+       count = ARRAY_SIZE(pm8607_regulator_driver);
+       for (i = 0; i < count; i++) {
+               ret = platform_driver_register(&pm8607_regulator_driver[i]);
+               if (ret != 0)
+                       pr_err("Failed to register regulator driver: %d\n",
+                               ret);
+       }
+       return 0;
+}
+subsys_initcall(pm8607_regulator_init);
+
+static void __exit pm8607_regulator_exit(void)
+{
+       int i, count;
+
+       count = ARRAY_SIZE(pm8607_regulator_driver);
+       for (i = 0; i < count; i++)
+               platform_driver_unregister(&pm8607_regulator_driver[i]);
+}
+module_exit(pm8607_regulator_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
+MODULE_DESCRIPTION("Regulator Driver for Marvell 88PM8607 PMIC");
+MODULE_ALIAS("platform:88pm8607-regulator");
index 7cfdd65bebb4185efb9552d2be4afa9f3611385f..262f62eec837438f36a5adbf53ebdabae96fe9f7 100644 (file)
@@ -69,6 +69,13 @@ config REGULATOR_MAX1586
          regulator via I2C bus. The provided regulator is suitable
          for PXA27x chips to control VCC_CORE and VCC_USIM voltages.
 
+config REGULATOR_MAX8660
+       tristate "Maxim 8660/8661 voltage regulator"
+       depends on I2C
+       help
+         This driver controls a Maxim 8660/8661 voltage output
+         regulator via I2C bus.
+
 config REGULATOR_TWL4030
        bool "TI TWL4030/TWL5030/TWL6030/TPS695x0 PMIC"
        depends on TWL4030_CORE
@@ -157,5 +164,11 @@ config REGULATOR_TPS6507X
          three step-down converters and two general-purpose LDO voltage regulators.
          It supports TI's software based Class-2 SmartReflex implementation.
 
+config REGULATOR_88PM8607
+       bool "Marvell 88PM8607 Power regulators"
+       depends on MFD_88PM8607=y
+       help
+         This driver supports 88PM8607 voltage regulator chips.
+
 endif
 
index 9ae3cc44e668d97dacaecee4489322de94f8d56e..b3c806c794157aac2f2604d16e9b6a47d82d0ac2 100644 (file)
@@ -12,6 +12,7 @@ obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
 obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
 obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
 obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
+obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o
 obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
 obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
 obj-$(CONFIG_REGULATOR_WM831X) += wm831x-ldo.o
@@ -20,10 +21,11 @@ obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
 obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
-obj-$(CONFIG_REGULATOR_MC13783) += mc13783.o
+obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
 obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
 
 obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
 obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o
+obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
 
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
index 49aeee823a25889e8eebd1c21d15ec6b1949ea28..b349db4504b79c6d122ee94221793541af4e0f32 100644 (file)
@@ -81,7 +81,7 @@ static const u8 ab3100_reg_init_order[AB3100_NUM_REGULATORS+2] = {
 #define LDO_C_VOLTAGE 2650000
 #define LDO_D_VOLTAGE 2650000
 
-static const int const ldo_e_buck_typ_voltages[] = {
+static const int ldo_e_buck_typ_voltages[] = {
        1800000,
        1400000,
        1300000,
@@ -91,7 +91,7 @@ static const int const ldo_e_buck_typ_voltages[] = {
        900000,
 };
 
-static const int const ldo_f_typ_voltages[] = {
+static const int ldo_f_typ_voltages[] = {
        1800000,
        1400000,
        1300000,
@@ -102,21 +102,21 @@ static const int const ldo_f_typ_voltages[] = {
        2650000,
 };
 
-static const int const ldo_g_typ_voltages[] = {
+static const int ldo_g_typ_voltages[] = {
        2850000,
        2750000,
        1800000,
        1500000,
 };
 
-static const int const ldo_h_typ_voltages[] = {
+static const int ldo_h_typ_voltages[] = {
        2750000,
        1800000,
        1500000,
        1200000,
 };
 
-static const int const ldo_k_typ_voltages[] = {
+static const int ldo_k_typ_voltages[] = {
        2750000,
        1800000,
 };
@@ -241,24 +241,12 @@ static int ab3100_disable_regulator(struct regulator_dev *reg)
         * LDO D is a special regulator. When it is disabled, the entire
         * system is shut down. So this is handled specially.
         */
+       pr_info("Called ab3100_disable_regulator\n");
        if (abreg->regreg == AB3100_LDO_D) {
-               int i;
-
                dev_info(&reg->dev, "disabling LDO D - shut down system\n");
-               /*
-                * Set regulators to default values, ignore any errors,
-                * we're going DOWN
-                */
-               for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) {
-                       (void) ab3100_set_register_interruptible(abreg->ab3100,
-                                       ab3100_reg_init_order[i],
-                                       abreg->plfdata->reg_initvals[i]);
-               }
-
                /* Setting LDO D to 0x00 cuts the power to the SoC */
                return ab3100_set_register_interruptible(abreg->ab3100,
                                                         AB3100_LDO_D, 0x00U);
-
        }
 
        /*
@@ -607,13 +595,6 @@ static int __init ab3100_regulators_probe(struct platform_device *pdev)
                }
        }
 
-       if (err) {
-               dev_err(&pdev->dev,
-                       "LDO D regulator initialization failed with error %d\n",
-                       err);
-               return err;
-       }
-
        /* Register the regulators */
        for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
                struct ab3100_regulator *reg = &ab3100_regulators[i];
@@ -688,7 +669,7 @@ static __init int ab3100_regulators_init(void)
 
 static __exit void ab3100_regulators_exit(void)
 {
-       platform_driver_register(&ab3100_regulators_driver);
+       platform_driver_unregister(&ab3100_regulators_driver);
 }
 
 subsys_initcall(ab3100_regulators_init);
index efe568deda12b7710e882e07d81388af9053e484..686ef270ecf7f01d23bf84a85b5f512be4566f10 100644 (file)
@@ -66,6 +66,16 @@ static unsigned int _regulator_get_mode(struct regulator_dev *rdev);
 static void _notifier_call_chain(struct regulator_dev *rdev,
                                  unsigned long event, void *data);
 
+static const char *rdev_get_name(struct regulator_dev *rdev)
+{
+       if (rdev->constraints && rdev->constraints->name)
+               return rdev->constraints->name;
+       else if (rdev->desc->name)
+               return rdev->desc->name;
+       else
+               return "";
+}
+
 /* gets the regulator for a given consumer device */
 static struct regulator *get_device_regulator(struct device *dev)
 {
@@ -96,12 +106,12 @@ static int regulator_check_voltage(struct regulator_dev *rdev,
 
        if (!rdev->constraints) {
                printk(KERN_ERR "%s: no constraints for %s\n", __func__,
-                      rdev->desc->name);
+                      rdev_get_name(rdev));
                return -ENODEV;
        }
        if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
                printk(KERN_ERR "%s: operation not allowed for %s\n",
-                      __func__, rdev->desc->name);
+                      __func__, rdev_get_name(rdev));
                return -EPERM;
        }
 
@@ -124,12 +134,12 @@ static int regulator_check_current_limit(struct regulator_dev *rdev,
 
        if (!rdev->constraints) {
                printk(KERN_ERR "%s: no constraints for %s\n", __func__,
-                      rdev->desc->name);
+                      rdev_get_name(rdev));
                return -ENODEV;
        }
        if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_CURRENT)) {
                printk(KERN_ERR "%s: operation not allowed for %s\n",
-                      __func__, rdev->desc->name);
+                      __func__, rdev_get_name(rdev));
                return -EPERM;
        }
 
@@ -159,17 +169,17 @@ static int regulator_check_mode(struct regulator_dev *rdev, int mode)
 
        if (!rdev->constraints) {
                printk(KERN_ERR "%s: no constraints for %s\n", __func__,
-                      rdev->desc->name);
+                      rdev_get_name(rdev));
                return -ENODEV;
        }
        if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_MODE)) {
                printk(KERN_ERR "%s: operation not allowed for %s\n",
-                      __func__, rdev->desc->name);
+                      __func__, rdev_get_name(rdev));
                return -EPERM;
        }
        if (!(rdev->constraints->valid_modes_mask & mode)) {
                printk(KERN_ERR "%s: invalid mode %x for %s\n",
-                      __func__, mode, rdev->desc->name);
+                      __func__, mode, rdev_get_name(rdev));
                return -EINVAL;
        }
        return 0;
@@ -180,12 +190,12 @@ static int regulator_check_drms(struct regulator_dev *rdev)
 {
        if (!rdev->constraints) {
                printk(KERN_ERR "%s: no constraints for %s\n", __func__,
-                      rdev->desc->name);
+                      rdev_get_name(rdev));
                return -ENODEV;
        }
        if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_DRMS)) {
                printk(KERN_ERR "%s: operation not allowed for %s\n",
-                      __func__, rdev->desc->name);
+                      __func__, rdev_get_name(rdev));
                return -EPERM;
        }
        return 0;
@@ -230,16 +240,8 @@ static ssize_t regulator_name_show(struct device *dev,
                             struct device_attribute *attr, char *buf)
 {
        struct regulator_dev *rdev = dev_get_drvdata(dev);
-       const char *name;
 
-       if (rdev->constraints && rdev->constraints->name)
-               name = rdev->constraints->name;
-       else if (rdev->desc->name)
-               name = rdev->desc->name;
-       else
-               name = "";
-
-       return sprintf(buf, "%s\n", name);
+       return sprintf(buf, "%s\n", rdev_get_name(rdev));
 }
 
 static ssize_t regulator_print_opmode(char *buf, int mode)
@@ -388,7 +390,7 @@ static ssize_t regulator_total_uA_show(struct device *dev,
 
        mutex_lock(&rdev->mutex);
        list_for_each_entry(regulator, &rdev->consumer_list, list)
-           uA += regulator->uA_load;
+               uA += regulator->uA_load;
        mutex_unlock(&rdev->mutex);
        return sprintf(buf, "%d\n", uA);
 }
@@ -563,7 +565,7 @@ static void drms_uA_update(struct regulator_dev *rdev)
 
        /* calc total requested load */
        list_for_each_entry(sibling, &rdev->consumer_list, list)
-           current_uA += sibling->uA_load;
+               current_uA += sibling->uA_load;
 
        /* now get the optimum mode for our new total regulator load */
        mode = rdev->desc->ops->get_optimum_mode(rdev, input_uV,
@@ -579,10 +581,29 @@ static int suspend_set_state(struct regulator_dev *rdev,
        struct regulator_state *rstate)
 {
        int ret = 0;
+       bool can_set_state;
 
-       /* enable & disable are mandatory for suspend control */
-       if (!rdev->desc->ops->set_suspend_enable ||
-               !rdev->desc->ops->set_suspend_disable) {
+       can_set_state = rdev->desc->ops->set_suspend_enable &&
+               rdev->desc->ops->set_suspend_disable;
+
+       /* If we have no suspend mode configration don't set anything;
+        * only warn if the driver actually makes the suspend mode
+        * configurable.
+        */
+       if (!rstate->enabled && !rstate->disabled) {
+               if (can_set_state)
+                       printk(KERN_WARNING "%s: No configuration for %s\n",
+                              __func__, rdev_get_name(rdev));
+               return 0;
+       }
+
+       if (rstate->enabled && rstate->disabled) {
+               printk(KERN_ERR "%s: invalid configuration for %s\n",
+                      __func__, rdev_get_name(rdev));
+               return -EINVAL;
+       }
+
+       if (!can_set_state) {
                printk(KERN_ERR "%s: no way to set suspend state\n",
                        __func__);
                return -EINVAL;
@@ -641,25 +662,43 @@ static void print_constraints(struct regulator_dev *rdev)
 {
        struct regulation_constraints *constraints = rdev->constraints;
        char buf[80];
-       int count;
+       int count = 0;
+       int ret;
 
-       if (rdev->desc->type == REGULATOR_VOLTAGE) {
+       if (constraints->min_uV && constraints->max_uV) {
                if (constraints->min_uV == constraints->max_uV)
-                       count = sprintf(buf, "%d mV ",
-                                       constraints->min_uV / 1000);
+                       count += sprintf(buf + count, "%d mV ",
+                                        constraints->min_uV / 1000);
                else
-                       count = sprintf(buf, "%d <--> %d mV ",
-                                       constraints->min_uV / 1000,
-                                       constraints->max_uV / 1000);
-       } else {
+                       count += sprintf(buf + count, "%d <--> %d mV ",
+                                        constraints->min_uV / 1000,
+                                        constraints->max_uV / 1000);
+       }
+
+       if (!constraints->min_uV ||
+           constraints->min_uV != constraints->max_uV) {
+               ret = _regulator_get_voltage(rdev);
+               if (ret > 0)
+                       count += sprintf(buf + count, "at %d mV ", ret / 1000);
+       }
+
+       if (constraints->min_uA && constraints->max_uA) {
                if (constraints->min_uA == constraints->max_uA)
-                       count = sprintf(buf, "%d mA ",
-                                       constraints->min_uA / 1000);
+                       count += sprintf(buf + count, "%d mA ",
+                                        constraints->min_uA / 1000);
                else
-                       count = sprintf(buf, "%d <--> %d mA ",
-                                       constraints->min_uA / 1000,
-                                       constraints->max_uA / 1000);
+                       count += sprintf(buf + count, "%d <--> %d mA ",
+                                        constraints->min_uA / 1000,
+                                        constraints->max_uA / 1000);
        }
+
+       if (!constraints->min_uA ||
+           constraints->min_uA != constraints->max_uA) {
+               ret = _regulator_get_current_limit(rdev);
+               if (ret > 0)
+                       count += sprintf(buf + count, "at %d uA ", ret / 1000);
+       }
+
        if (constraints->valid_modes_mask & REGULATOR_MODE_FAST)
                count += sprintf(buf + count, "fast ");
        if (constraints->valid_modes_mask & REGULATOR_MODE_NORMAL)
@@ -669,33 +708,30 @@ static void print_constraints(struct regulator_dev *rdev)
        if (constraints->valid_modes_mask & REGULATOR_MODE_STANDBY)
                count += sprintf(buf + count, "standby");
 
-       printk(KERN_INFO "regulator: %s: %s\n", rdev->desc->name, buf);
+       printk(KERN_INFO "regulator: %s: %s\n", rdev_get_name(rdev), buf);
 }
 
-/**
- * set_machine_constraints - sets regulator constraints
- * @rdev: regulator source
- * @constraints: constraints to apply
- *
- * Allows platform initialisation code to define and constrain
- * regulator circuits e.g. valid voltage/current ranges, etc.  NOTE:
- * Constraints *must* be set by platform code in order for some
- * regulator operations to proceed i.e. set_voltage, set_current_limit,
- * set_mode.
- */
-static int set_machine_constraints(struct regulator_dev *rdev,
+static int machine_constraints_voltage(struct regulator_dev *rdev,
        struct regulation_constraints *constraints)
 {
-       int ret = 0;
-       const char *name;
        struct regulator_ops *ops = rdev->desc->ops;
+       const char *name = rdev_get_name(rdev);
+       int ret;
 
-       if (constraints->name)
-               name = constraints->name;
-       else if (rdev->desc->name)
-               name = rdev->desc->name;
-       else
-               name = "regulator";
+       /* do we need to apply the constraint voltage */
+       if (rdev->constraints->apply_uV &&
+               rdev->constraints->min_uV == rdev->constraints->max_uV &&
+               ops->set_voltage) {
+               ret = ops->set_voltage(rdev,
+                       rdev->constraints->min_uV, rdev->constraints->max_uV);
+                       if (ret < 0) {
+                               printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n",
+                                      __func__,
+                                      rdev->constraints->min_uV, name);
+                               rdev->constraints = NULL;
+                               return ret;
+                       }
+       }
 
        /* constrain machine-level voltage specs to fit
         * the actual range supported by this regulator.
@@ -719,14 +755,13 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 
                /* voltage constraints are optional */
                if ((cmin == 0) && (cmax == 0))
-                       goto out;
+                       return 0;
 
                /* else require explicit machine-level constraints */
                if (cmin <= 0 || cmax <= 0 || cmax < cmin) {
                        pr_err("%s: %s '%s' voltage constraints\n",
                                       __func__, "invalid", name);
-                       ret = -EINVAL;
-                       goto out;
+                       return -EINVAL;
                }
 
                /* initial: [cmin..cmax] valid, [min_uV..max_uV] not */
@@ -748,8 +783,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                if (max_uV < min_uV) {
                        pr_err("%s: %s '%s' voltage constraints\n",
                                       __func__, "unsupportable", name);
-                       ret = -EINVAL;
-                       goto out;
+                       return -EINVAL;
                }
 
                /* use regulator's subset of machine constraints */
@@ -767,22 +801,34 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                }
        }
 
+       return 0;
+}
+
+/**
+ * set_machine_constraints - sets regulator constraints
+ * @rdev: regulator source
+ * @constraints: constraints to apply
+ *
+ * Allows platform initialisation code to define and constrain
+ * regulator circuits e.g. valid voltage/current ranges, etc.  NOTE:
+ * Constraints *must* be set by platform code in order for some
+ * regulator operations to proceed i.e. set_voltage, set_current_limit,
+ * set_mode.
+ */
+static int set_machine_constraints(struct regulator_dev *rdev,
+       struct regulation_constraints *constraints)
+{
+       int ret = 0;
+       const char *name;
+       struct regulator_ops *ops = rdev->desc->ops;
+
        rdev->constraints = constraints;
 
-       /* do we need to apply the constraint voltage */
-       if (rdev->constraints->apply_uV &&
-               rdev->constraints->min_uV == rdev->constraints->max_uV &&
-               ops->set_voltage) {
-               ret = ops->set_voltage(rdev,
-                       rdev->constraints->min_uV, rdev->constraints->max_uV);
-                       if (ret < 0) {
-                               printk(KERN_ERR "%s: failed to apply %duV constraint to %s\n",
-                                      __func__,
-                                      rdev->constraints->min_uV, name);
-                               rdev->constraints = NULL;
-                               goto out;
-                       }
-       }
+       name = rdev_get_name(rdev);
+
+       ret = machine_constraints_voltage(rdev, constraints);
+       if (ret != 0)
+               goto out;
 
        /* do we need to setup our suspend state */
        if (constraints->initial_state) {
@@ -903,7 +949,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
                                dev_name(&node->regulator->dev),
                                node->regulator->desc->name,
                                supply,
-                               dev_name(&rdev->dev), rdev->desc->name);
+                               dev_name(&rdev->dev), rdev_get_name(rdev));
                return -EBUSY;
        }
 
@@ -1212,7 +1258,7 @@ static int _regulator_enable(struct regulator_dev *rdev)
                ret = _regulator_enable(rdev->supply);
                if (ret < 0) {
                        printk(KERN_ERR "%s: failed to enable %s: %d\n",
-                              __func__, rdev->desc->name, ret);
+                              __func__, rdev_get_name(rdev), ret);
                        return ret;
                }
        }
@@ -1238,7 +1284,7 @@ static int _regulator_enable(struct regulator_dev *rdev)
                        }
                } else if (ret < 0) {
                        printk(KERN_ERR "%s: is_enabled() failed for %s: %d\n",
-                              __func__, rdev->desc->name, ret);
+                              __func__, rdev_get_name(rdev), ret);
                        return ret;
                }
                /* Fallthrough on positive return values - already enabled */
@@ -1279,7 +1325,7 @@ static int _regulator_disable(struct regulator_dev *rdev)
 
        if (WARN(rdev->use_count <= 0,
                        "unbalanced disables for %s\n",
-                       rdev->desc->name))
+                       rdev_get_name(rdev)))
                return -EIO;
 
        /* are we the last user and permitted to disable ? */
@@ -1292,7 +1338,7 @@ static int _regulator_disable(struct regulator_dev *rdev)
                        ret = rdev->desc->ops->disable(rdev);
                        if (ret < 0) {
                                printk(KERN_ERR "%s: failed to disable %s\n",
-                                      __func__, rdev->desc->name);
+                                      __func__, rdev_get_name(rdev));
                                return ret;
                        }
                }
@@ -1349,7 +1395,7 @@ static int _regulator_force_disable(struct regulator_dev *rdev)
                ret = rdev->desc->ops->disable(rdev);
                if (ret < 0) {
                        printk(KERN_ERR "%s: failed to force disable %s\n",
-                              __func__, rdev->desc->name);
+                              __func__, rdev_get_name(rdev));
                        return ret;
                }
                /* notify other consumers that power has been forced off */
@@ -1766,7 +1812,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
        output_uV = rdev->desc->ops->get_voltage(rdev);
        if (output_uV <= 0) {
                printk(KERN_ERR "%s: invalid output voltage found for %s\n",
-                       __func__, rdev->desc->name);
+                       __func__, rdev_get_name(rdev));
                goto out;
        }
 
@@ -1777,13 +1823,13 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
                input_uV = rdev->constraints->input_uV;
        if (input_uV <= 0) {
                printk(KERN_ERR "%s: invalid input voltage found for %s\n",
-                       __func__, rdev->desc->name);
+                       __func__, rdev_get_name(rdev));
                goto out;
        }
 
        /* calc total requested load for this regulator */
        list_for_each_entry(consumer, &rdev->consumer_list, list)
-           total_uA_load += consumer->uA_load;
+               total_uA_load += consumer->uA_load;
 
        mode = rdev->desc->ops->get_optimum_mode(rdev,
                                                 input_uV, output_uV,
@@ -1791,7 +1837,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
        ret = regulator_check_mode(rdev, mode);
        if (ret < 0) {
                printk(KERN_ERR "%s: failed to get optimum mode for %s @"
-                       " %d uA %d -> %d uV\n", __func__, rdev->desc->name,
+                       " %d uA %d -> %d uV\n", __func__, rdev_get_name(rdev),
                        total_uA_load, input_uV, output_uV);
                goto out;
        }
@@ -1799,7 +1845,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
        ret = rdev->desc->ops->set_mode(rdev, mode);
        if (ret < 0) {
                printk(KERN_ERR "%s: failed to set optimum mode %x for %s\n",
-                       __func__, mode, rdev->desc->name);
+                       __func__, mode, rdev_get_name(rdev));
                goto out;
        }
        ret = mode;
@@ -1852,9 +1898,9 @@ static void _notifier_call_chain(struct regulator_dev *rdev,
 
        /* now notify regulator we supply */
        list_for_each_entry(_rdev, &rdev->supply_list, slist) {
-         mutex_lock(&_rdev->mutex);
-         _notifier_call_chain(_rdev, event, data);
-         mutex_unlock(&_rdev->mutex);
+               mutex_lock(&_rdev->mutex);
+               _notifier_call_chain(_rdev, event, data);
+               mutex_unlock(&_rdev->mutex);
        }
 }
 
@@ -1885,9 +1931,9 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
                consumers[i].consumer = regulator_get(dev,
                                                      consumers[i].supply);
                if (IS_ERR(consumers[i].consumer)) {
-                       dev_err(dev, "Failed to get supply '%s'\n",
-                               consumers[i].supply);
                        ret = PTR_ERR(consumers[i].consumer);
+                       dev_err(dev, "Failed to get supply '%s': %d\n",
+                               consumers[i].supply, ret);
                        consumers[i].consumer = NULL;
                        goto err;
                }
@@ -1930,8 +1976,8 @@ int regulator_bulk_enable(int num_consumers,
        return 0;
 
 err:
-       printk(KERN_ERR "Failed to enable %s\n", consumers[i].supply);
-       for (i = 0; i < num_consumers; i++)
+       printk(KERN_ERR "Failed to enable %s: %d\n", consumers[i].supply, ret);
+       for (--i; i >= 0; --i)
                regulator_disable(consumers[i].consumer);
 
        return ret;
@@ -1965,8 +2011,9 @@ int regulator_bulk_disable(int num_consumers,
        return 0;
 
 err:
-       printk(KERN_ERR "Failed to disable %s\n", consumers[i].supply);
-       for (i = 0; i < num_consumers; i++)
+       printk(KERN_ERR "Failed to disable %s: %d\n", consumers[i].supply,
+              ret);
+       for (--i; i >= 0; --i)
                regulator_enable(consumers[i].consumer);
 
        return ret;
@@ -2316,7 +2363,7 @@ int regulator_suspend_prepare(suspend_state_t state)
 
                if (ret < 0) {
                        printk(KERN_ERR "%s: failed to prepare %s\n",
-                               __func__, rdev->desc->name);
+                               __func__, rdev_get_name(rdev));
                        goto out;
                }
        }
@@ -2429,12 +2476,7 @@ static int __init regulator_init_complete(void)
                ops = rdev->desc->ops;
                c = rdev->constraints;
 
-               if (c && c->name)
-                       name = c->name;
-               else if (rdev->desc->name)
-                       name = rdev->desc->name;
-               else
-                       name = "regulator";
+               name = rdev_get_name(rdev);
 
                if (!ops->disable || (c && c->always_on))
                        continue;
index aa224d936e0de4c92665faf14115bc5592e63bde..f8c4661a7a81ae82705b51691669e230553203b1 100644 (file)
@@ -331,7 +331,7 @@ static int da9034_get_ldo12_voltage(struct regulator_dev *rdev)
 static int da9034_list_ldo12_voltage(struct regulator_dev *rdev,
                                     unsigned selector)
 {
-       if (selector > ARRAY_SIZE(da9034_ldo12_data))
+       if (selector >= ARRAY_SIZE(da9034_ldo12_data))
                return -EINVAL;
        return da9034_ldo12_data[selector] * 1000;
 }
index 7803a320543b1da4f9da2d64ed33e0f108b2f634..76d08c282f9cac3a54133acc30b88fda81b37738 100644 (file)
@@ -446,8 +446,8 @@ static int setup_regulators(struct lp3971 *lp3971,
                lp3971->rdev[i] = regulator_register(&regulators[id],
                        lp3971->dev, pdata->regulators[i].initdata, lp3971);
 
-               err = IS_ERR(lp3971->rdev[i]);
-               if (err) {
+               if (IS_ERR(lp3971->rdev[i])) {
+                       err = PTR_ERR(lp3971->rdev[i]);
                        dev_err(lp3971->dev, "regulator init failed: %d\n",
                                err);
                        goto error;
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
new file mode 100644 (file)
index 0000000..acc2fb7
--- /dev/null
@@ -0,0 +1,510 @@
+/*
+ * max8660.c  --  Voltage regulation for the Maxim 8660/8661
+ *
+ * based on max1586.c and wm8400-regulator.c
+ *
+ * Copyright (C) 2009 Wolfram Sang, Pengutronix e.K.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Some info:
+ *
+ * Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX8660-MAX8661.pdf
+ *
+ * This chip is a bit nasty because it is a write-only device. Thus, the driver
+ * uses shadow registers to keep track of its values. The main problem appears
+ * to be the initialization: When Linux boots up, we cannot know if the chip is
+ * in the default state or not, so we would have to pass such information in
+ * platform_data. As this adds a bit of complexity to the driver, this is left
+ * out for now until it is really needed.
+ *
+ * [A|S|M]DTV1 registers are currently not used, but [A|S|M]DTV2.
+ *
+ * If the driver is feature complete, it might be worth to check if one set of
+ * functions for V3-V7 is sufficient. For maximum flexibility during
+ * development, they are separated for now.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/max8660.h>
+
+#define MAX8660_DCDC_MIN_UV     725000
+#define MAX8660_DCDC_MAX_UV    1800000
+#define MAX8660_DCDC_STEP        25000
+#define MAX8660_DCDC_MAX_SEL   0x2b
+
+#define MAX8660_LDO5_MIN_UV    1700000
+#define MAX8660_LDO5_MAX_UV    2000000
+#define MAX8660_LDO5_STEP        25000
+#define MAX8660_LDO5_MAX_SEL   0x0c
+
+#define MAX8660_LDO67_MIN_UV   1800000
+#define MAX8660_LDO67_MAX_UV   3300000
+#define MAX8660_LDO67_STEP      100000
+#define MAX8660_LDO67_MAX_SEL  0x0f
+
+enum {
+       MAX8660_OVER1,
+       MAX8660_OVER2,
+       MAX8660_VCC1,
+       MAX8660_ADTV1,
+       MAX8660_ADTV2,
+       MAX8660_SDTV1,
+       MAX8660_SDTV2,
+       MAX8660_MDTV1,
+       MAX8660_MDTV2,
+       MAX8660_L12VCR,
+       MAX8660_FPWM,
+       MAX8660_N_REGS, /* not a real register */
+};
+
+struct max8660 {
+       struct i2c_client *client;
+       u8 shadow_regs[MAX8660_N_REGS];         /* as chip is write only */
+       struct regulator_dev *rdev[];
+};
+
+static int max8660_write(struct max8660 *max8660, u8 reg, u8 mask, u8 val)
+{
+       static const u8 max8660_addresses[MAX8660_N_REGS] =
+         { 0x10, 0x12, 0x20, 0x23, 0x24, 0x29, 0x2a, 0x32, 0x33, 0x39, 0x80 };
+
+       int ret;
+       u8 reg_val = (max8660->shadow_regs[reg] & mask) | val;
+       dev_vdbg(&max8660->client->dev, "Writing reg %02x with %02x\n",
+                       max8660_addresses[reg], reg_val);
+
+       ret = i2c_smbus_write_byte_data(max8660->client,
+                       max8660_addresses[reg], reg_val);
+       if (ret == 0)
+               max8660->shadow_regs[reg] = reg_val;
+
+       return ret;
+}
+
+
+/*
+ * DCDC functions
+ */
+
+static int max8660_dcdc_is_enabled(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 val = max8660->shadow_regs[MAX8660_OVER1];
+       u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4;
+       return !!(val & mask);
+}
+
+static int max8660_dcdc_enable(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 bit = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4;
+       return max8660_write(max8660, MAX8660_OVER1, 0xff, bit);
+}
+
+static int max8660_dcdc_disable(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? ~1 : ~4;
+       return max8660_write(max8660, MAX8660_OVER1, mask, 0);
+}
+
+static int max8660_dcdc_list(struct regulator_dev *rdev, unsigned selector)
+{
+       if (selector > MAX8660_DCDC_MAX_SEL)
+               return -EINVAL;
+       return MAX8660_DCDC_MIN_UV + selector * MAX8660_DCDC_STEP;
+}
+
+static int max8660_dcdc_get(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2;
+       u8 selector = max8660->shadow_regs[reg];
+       return MAX8660_DCDC_MIN_UV + selector * MAX8660_DCDC_STEP;
+}
+
+static int max8660_dcdc_set(struct regulator_dev *rdev, int min_uV, int max_uV)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 reg, selector, bits;
+       int ret;
+
+       if (min_uV < MAX8660_DCDC_MIN_UV || min_uV > MAX8660_DCDC_MAX_UV)
+               return -EINVAL;
+       if (max_uV < MAX8660_DCDC_MIN_UV || max_uV > MAX8660_DCDC_MAX_UV)
+               return -EINVAL;
+
+       selector = (min_uV - (MAX8660_DCDC_MIN_UV - MAX8660_DCDC_STEP + 1))
+                       / MAX8660_DCDC_STEP;
+
+       ret = max8660_dcdc_list(rdev, selector);
+       if (ret < 0 || ret > max_uV)
+               return -EINVAL;
+
+       reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2;
+       ret = max8660_write(max8660, reg, 0, selector);
+       if (ret)
+               return ret;
+
+       /* Select target voltage register and activate regulation */
+       bits = (rdev_get_id(rdev) == MAX8660_V3) ? 0x03 : 0x30;
+       return max8660_write(max8660, MAX8660_VCC1, 0xff, bits);
+}
+
+static struct regulator_ops max8660_dcdc_ops = {
+       .is_enabled = max8660_dcdc_is_enabled,
+       .list_voltage = max8660_dcdc_list,
+       .set_voltage = max8660_dcdc_set,
+       .get_voltage = max8660_dcdc_get,
+};
+
+
+/*
+ * LDO5 functions
+ */
+
+static int max8660_ldo5_list(struct regulator_dev *rdev, unsigned selector)
+{
+       if (selector > MAX8660_LDO5_MAX_SEL)
+               return -EINVAL;
+       return MAX8660_LDO5_MIN_UV + selector * MAX8660_LDO5_STEP;
+}
+
+static int max8660_ldo5_get(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 selector = max8660->shadow_regs[MAX8660_MDTV2];
+
+       return MAX8660_LDO5_MIN_UV + selector * MAX8660_LDO5_STEP;
+}
+
+static int max8660_ldo5_set(struct regulator_dev *rdev, int min_uV, int max_uV)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 selector;
+       int ret;
+
+       if (min_uV < MAX8660_LDO5_MIN_UV || min_uV > MAX8660_LDO5_MAX_UV)
+               return -EINVAL;
+       if (max_uV < MAX8660_LDO5_MIN_UV || max_uV > MAX8660_LDO5_MAX_UV)
+               return -EINVAL;
+
+       selector = (min_uV - (MAX8660_LDO5_MIN_UV - MAX8660_LDO5_STEP + 1))
+                       / MAX8660_LDO5_STEP;
+       ret = max8660_ldo5_list(rdev, selector);
+       if (ret < 0 || ret > max_uV)
+               return -EINVAL;
+
+       ret = max8660_write(max8660, MAX8660_MDTV2, 0, selector);
+       if (ret)
+               return ret;
+
+       /* Select target voltage register and activate regulation */
+       return max8660_write(max8660, MAX8660_VCC1, 0xff, 0xc0);
+}
+
+static struct regulator_ops max8660_ldo5_ops = {
+       .list_voltage = max8660_ldo5_list,
+       .set_voltage = max8660_ldo5_set,
+       .get_voltage = max8660_ldo5_get,
+};
+
+
+/*
+ * LDO67 functions
+ */
+
+static int max8660_ldo67_is_enabled(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 val = max8660->shadow_regs[MAX8660_OVER2];
+       u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4;
+       return !!(val & mask);
+}
+
+static int max8660_ldo67_enable(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 bit = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4;
+       return max8660_write(max8660, MAX8660_OVER2, 0xff, bit);
+}
+
+static int max8660_ldo67_disable(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? ~2 : ~4;
+       return max8660_write(max8660, MAX8660_OVER2, mask, 0);
+}
+
+static int max8660_ldo67_list(struct regulator_dev *rdev, unsigned selector)
+{
+       if (selector > MAX8660_LDO67_MAX_SEL)
+               return -EINVAL;
+       return MAX8660_LDO67_MIN_UV + selector * MAX8660_LDO67_STEP;
+}
+
+static int max8660_ldo67_get(struct regulator_dev *rdev)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 shift = (rdev_get_id(rdev) == MAX8660_V6) ? 0 : 4;
+       u8 selector = (max8660->shadow_regs[MAX8660_L12VCR] >> shift) & 0xf;
+
+       return MAX8660_LDO67_MIN_UV + selector * MAX8660_LDO67_STEP;
+}
+
+static int max8660_ldo67_set(struct regulator_dev *rdev, int min_uV, int max_uV)
+{
+       struct max8660 *max8660 = rdev_get_drvdata(rdev);
+       u8 selector;
+       int ret;
+
+       if (min_uV < MAX8660_LDO67_MIN_UV || min_uV > MAX8660_LDO67_MAX_UV)
+               return -EINVAL;
+       if (max_uV < MAX8660_LDO67_MIN_UV || max_uV > MAX8660_LDO67_MAX_UV)
+               return -EINVAL;
+
+       selector = (min_uV - (MAX8660_LDO67_MIN_UV - MAX8660_LDO67_STEP + 1))
+                       / MAX8660_LDO67_STEP;
+
+       ret = max8660_ldo67_list(rdev, selector);
+       if (ret < 0 || ret > max_uV)
+               return -EINVAL;
+
+       if (rdev_get_id(rdev) == MAX8660_V6)
+               return max8660_write(max8660, MAX8660_L12VCR, 0xf0, selector);
+       else
+               return max8660_write(max8660, MAX8660_L12VCR, 0x0f, selector << 4);
+}
+
+static struct regulator_ops max8660_ldo67_ops = {
+       .is_enabled = max8660_ldo67_is_enabled,
+       .enable = max8660_ldo67_enable,
+       .disable = max8660_ldo67_disable,
+       .list_voltage = max8660_ldo67_list,
+       .get_voltage = max8660_ldo67_get,
+       .set_voltage = max8660_ldo67_set,
+};
+
+static struct regulator_desc max8660_reg[] = {
+       {
+               .name = "V3(DCDC)",
+               .id = MAX8660_V3,
+               .ops = &max8660_dcdc_ops,
+               .type = REGULATOR_VOLTAGE,
+               .n_voltages = MAX8660_DCDC_MAX_SEL + 1,
+               .owner = THIS_MODULE,
+       },
+       {
+               .name = "V4(DCDC)",
+               .id = MAX8660_V4,
+               .ops = &max8660_dcdc_ops,
+               .type = REGULATOR_VOLTAGE,
+               .n_voltages = MAX8660_DCDC_MAX_SEL + 1,
+               .owner = THIS_MODULE,
+       },
+       {
+               .name = "V5(LDO)",
+               .id = MAX8660_V5,
+               .ops = &max8660_ldo5_ops,
+               .type = REGULATOR_VOLTAGE,
+               .n_voltages = MAX8660_LDO5_MAX_SEL + 1,
+               .owner = THIS_MODULE,
+       },
+       {
+               .name = "V6(LDO)",
+               .id = MAX8660_V6,
+               .ops = &max8660_ldo67_ops,
+               .type = REGULATOR_VOLTAGE,
+               .n_voltages = MAX8660_LDO67_MAX_SEL + 1,
+               .owner = THIS_MODULE,
+       },
+       {
+               .name = "V7(LDO)",
+               .id = MAX8660_V7,
+               .ops = &max8660_ldo67_ops,
+               .type = REGULATOR_VOLTAGE,
+               .n_voltages = MAX8660_LDO67_MAX_SEL + 1,
+               .owner = THIS_MODULE,
+       },
+};
+
+static int max8660_probe(struct i2c_client *client,
+                             const struct i2c_device_id *i2c_id)
+{
+       struct regulator_dev **rdev;
+       struct max8660_platform_data *pdata = client->dev.platform_data;
+       struct max8660 *max8660;
+       int boot_on, i, id, ret = -EINVAL;
+
+       if (pdata->num_subdevs > MAX8660_V_END) {
+               dev_err(&client->dev, "Too much regulators found!\n");
+               goto out;
+       }
+
+       max8660 = kzalloc(sizeof(struct max8660) +
+                       sizeof(struct regulator_dev *) * MAX8660_V_END,
+                       GFP_KERNEL);
+       if (!max8660) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       max8660->client = client;
+       rdev = max8660->rdev;
+
+       if (pdata->en34_is_high) {
+               /* Simulate always on */
+               max8660->shadow_regs[MAX8660_OVER1] = 5;
+       } else {
+               /* Otherwise devices can be toggled via software */
+               max8660_dcdc_ops.enable = max8660_dcdc_enable;
+               max8660_dcdc_ops.disable = max8660_dcdc_disable;
+       }
+
+       /*
+        * First, set up shadow registers to prevent glitches. As some
+        * registers are shared between regulators, everything must be properly
+        * set up for all regulators in advance.
+        */
+       max8660->shadow_regs[MAX8660_ADTV1] =
+               max8660->shadow_regs[MAX8660_ADTV2] =
+               max8660->shadow_regs[MAX8660_SDTV1] =
+               max8660->shadow_regs[MAX8660_SDTV2] = 0x1b;
+       max8660->shadow_regs[MAX8660_MDTV1] =
+               max8660->shadow_regs[MAX8660_MDTV2] = 0x04;
+
+       for (i = 0; i < pdata->num_subdevs; i++) {
+
+               if (!pdata->subdevs[i].platform_data)
+                       goto err_free;
+
+               boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;
+
+               switch (pdata->subdevs[i].id) {
+               case MAX8660_V3:
+                       if (boot_on)
+                               max8660->shadow_regs[MAX8660_OVER1] |= 1;
+                       break;
+
+               case MAX8660_V4:
+                       if (boot_on)
+                               max8660->shadow_regs[MAX8660_OVER1] |= 4;
+                       break;
+
+               case MAX8660_V5:
+                       break;
+
+               case MAX8660_V6:
+                       if (boot_on)
+                               max8660->shadow_regs[MAX8660_OVER2] |= 2;
+                       break;
+
+               case MAX8660_V7:
+                       if (!strcmp(i2c_id->name, "max8661")) {
+                               dev_err(&client->dev, "Regulator not on this chip!\n");
+                               goto err_free;
+                       }
+
+                       if (boot_on)
+                               max8660->shadow_regs[MAX8660_OVER2] |= 4;
+                       break;
+
+               default:
+                       dev_err(&client->dev, "invalid regulator %s\n",
+                                pdata->subdevs[i].name);
+                       goto err_free;
+               }
+       }
+
+       /* Finally register devices */
+       for (i = 0; i < pdata->num_subdevs; i++) {
+
+               id = pdata->subdevs[i].id;
+
+               rdev[i] = regulator_register(&max8660_reg[id], &client->dev,
+                                            pdata->subdevs[i].platform_data,
+                                            max8660);
+               if (IS_ERR(rdev[i])) {
+                       ret = PTR_ERR(rdev[i]);
+                       dev_err(&client->dev, "failed to register %s\n",
+                               max8660_reg[id].name);
+                       goto err_unregister;
+               }
+       }
+
+       i2c_set_clientdata(client, rdev);
+       dev_info(&client->dev, "Maxim 8660/8661 regulator driver loaded\n");
+       return 0;
+
+err_unregister:
+       while (--i >= 0)
+               regulator_unregister(rdev[i]);
+err_free:
+       kfree(max8660);
+out:
+       return ret;
+}
+
+static int max8660_remove(struct i2c_client *client)
+{
+       struct regulator_dev **rdev = i2c_get_clientdata(client);
+       int i;
+
+       for (i = 0; i < MAX8660_V_END; i++)
+               if (rdev[i])
+                       regulator_unregister(rdev[i]);
+       kfree(rdev);
+       i2c_set_clientdata(client, NULL);
+
+       return 0;
+}
+
+static const struct i2c_device_id max8660_id[] = {
+       { "max8660", 0 },
+       { "max8661", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, max8660_id);
+
+static struct i2c_driver max8660_driver = {
+       .probe = max8660_probe,
+       .remove = max8660_remove,
+       .driver         = {
+               .name   = "max8660",
+       },
+       .id_table       = max8660_id,
+};
+
+static int __init max8660_init(void)
+{
+       return i2c_add_driver(&max8660_driver);
+}
+subsys_initcall(max8660_init);
+
+static void __exit max8660_exit(void)
+{
+       i2c_del_driver(&max8660_driver);
+}
+module_exit(max8660_exit);
+
+/* Module information */
+MODULE_DESCRIPTION("MAXIM 8660/8661 voltage regulator driver");
+MODULE_AUTHOR("Wolfram Sang");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c
new file mode 100644 (file)
index 0000000..39c4953
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ * Regulator Driver for Freescale MC13783 PMIC
+ *
+ * Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/mfd/mc13783.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/driver.h>
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/err.h>
+
+#define MC13783_REG_SWITCHERS4                 28
+#define MC13783_REG_SWITCHERS4_PLLEN                   (1 << 18)
+
+#define MC13783_REG_SWITCHERS5                 29
+#define MC13783_REG_SWITCHERS5_SW3EN                   (1 << 20)
+
+#define MC13783_REG_REGULATORMODE0             32
+#define MC13783_REG_REGULATORMODE0_VAUDIOEN            (1 << 0)
+#define MC13783_REG_REGULATORMODE0_VIOHIEN             (1 << 3)
+#define MC13783_REG_REGULATORMODE0_VIOLOEN             (1 << 6)
+#define MC13783_REG_REGULATORMODE0_VDIGEN              (1 << 9)
+#define MC13783_REG_REGULATORMODE0_VGENEN              (1 << 12)
+#define MC13783_REG_REGULATORMODE0_VRFDIGEN            (1 << 15)
+#define MC13783_REG_REGULATORMODE0_VRFREFEN            (1 << 18)
+#define MC13783_REG_REGULATORMODE0_VRFCPEN             (1 << 21)
+
+#define MC13783_REG_REGULATORMODE1             33
+#define MC13783_REG_REGULATORMODE1_VSIMEN              (1 << 0)
+#define MC13783_REG_REGULATORMODE1_VESIMEN             (1 << 3)
+#define MC13783_REG_REGULATORMODE1_VCAMEN              (1 << 6)
+#define MC13783_REG_REGULATORMODE1_VRFBGEN             (1 << 9)
+#define MC13783_REG_REGULATORMODE1_VVIBEN              (1 << 11)
+#define MC13783_REG_REGULATORMODE1_VRF1EN              (1 << 12)
+#define MC13783_REG_REGULATORMODE1_VRF2EN              (1 << 15)
+#define MC13783_REG_REGULATORMODE1_VMMC1EN             (1 << 18)
+#define MC13783_REG_REGULATORMODE1_VMMC2EN             (1 << 21)
+
+#define MC13783_REG_POWERMISC                  34
+#define MC13783_REG_POWERMISC_GPO1EN                   (1 << 6)
+#define MC13783_REG_POWERMISC_GPO2EN                   (1 << 8)
+#define MC13783_REG_POWERMISC_GPO3EN                   (1 << 10)
+#define MC13783_REG_POWERMISC_GPO4EN                   (1 << 12)
+
+struct mc13783_regulator {
+       struct regulator_desc desc;
+       int reg;
+       int enable_bit;
+};
+
+static struct regulator_ops mc13783_regulator_ops;
+
+#define MC13783_DEFINE(prefix, _name, _reg)                            \
+       [MC13783_ ## prefix ## _ ## _name] = {                          \
+               .desc = {                                               \
+                       .name = #prefix "_" #_name,                     \
+                       .ops = &mc13783_regulator_ops,                  \
+                       .type = REGULATOR_VOLTAGE,                      \
+                       .id = MC13783_ ## prefix ## _ ## _name,         \
+                       .owner = THIS_MODULE,                           \
+               },                                                      \
+               .reg = MC13783_REG_ ## _reg,                            \
+               .enable_bit = MC13783_REG_ ## _reg ## _ ## _name ## EN, \
+       }
+
+#define MC13783_DEFINE_SW(_name, _reg) MC13783_DEFINE(SW, _name, _reg)
+#define MC13783_DEFINE_REGU(_name, _reg) MC13783_DEFINE(REGU, _name, _reg)
+
+static struct mc13783_regulator mc13783_regulators[] = {
+       MC13783_DEFINE_SW(SW3, SWITCHERS5),
+       MC13783_DEFINE_SW(PLL, SWITCHERS4),
+
+       MC13783_DEFINE_REGU(VAUDIO, REGULATORMODE0),
+       MC13783_DEFINE_REGU(VIOHI, REGULATORMODE0),
+       MC13783_DEFINE_REGU(VIOLO, REGULATORMODE0),
+       MC13783_DEFINE_REGU(VDIG, REGULATORMODE0),
+       MC13783_DEFINE_REGU(VGEN, REGULATORMODE0),
+       MC13783_DEFINE_REGU(VRFDIG, REGULATORMODE0),
+       MC13783_DEFINE_REGU(VRFREF, REGULATORMODE0),
+       MC13783_DEFINE_REGU(VRFCP, REGULATORMODE0),
+       MC13783_DEFINE_REGU(VSIM, REGULATORMODE1),
+       MC13783_DEFINE_REGU(VESIM, REGULATORMODE1),
+       MC13783_DEFINE_REGU(VCAM, REGULATORMODE1),
+       MC13783_DEFINE_REGU(VRFBG, REGULATORMODE1),
+       MC13783_DEFINE_REGU(VVIB, REGULATORMODE1),
+       MC13783_DEFINE_REGU(VRF1, REGULATORMODE1),
+       MC13783_DEFINE_REGU(VRF2, REGULATORMODE1),
+       MC13783_DEFINE_REGU(VMMC1, REGULATORMODE1),
+       MC13783_DEFINE_REGU(VMMC2, REGULATORMODE1),
+       MC13783_DEFINE_REGU(GPO1, POWERMISC),
+       MC13783_DEFINE_REGU(GPO2, POWERMISC),
+       MC13783_DEFINE_REGU(GPO3, POWERMISC),
+       MC13783_DEFINE_REGU(GPO4, POWERMISC),
+};
+
+struct mc13783_regulator_priv {
+       struct mc13783 *mc13783;
+       struct regulator_dev *regulators[];
+};
+
+static int mc13783_regulator_enable(struct regulator_dev *rdev)
+{
+       struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev);
+       int id = rdev_get_id(rdev);
+       int ret;
+
+       dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
+
+       mc13783_lock(priv->mc13783);
+       ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].reg,
+                       mc13783_regulators[id].enable_bit,
+                       mc13783_regulators[id].enable_bit);
+       mc13783_unlock(priv->mc13783);
+
+       return ret;
+}
+
+static int mc13783_regulator_disable(struct regulator_dev *rdev)
+{
+       struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev);
+       int id = rdev_get_id(rdev);
+       int ret;
+
+       dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
+
+       mc13783_lock(priv->mc13783);
+       ret = mc13783_reg_rmw(priv->mc13783, mc13783_regulators[id].reg,
+                       mc13783_regulators[id].enable_bit, 0);
+       mc13783_unlock(priv->mc13783);
+
+       return ret;
+}
+
+static int mc13783_regulator_is_enabled(struct regulator_dev *rdev)
+{
+       struct mc13783_regulator_priv *priv = rdev_get_drvdata(rdev);
+       int ret, id = rdev_get_id(rdev);
+       unsigned int val;
+
+       mc13783_lock(priv->mc13783);
+       ret = mc13783_reg_read(priv->mc13783, mc13783_regulators[id].reg, &val);
+       mc13783_unlock(priv->mc13783);
+
+       if (ret)
+               return ret;
+
+       return (val & mc13783_regulators[id].enable_bit) != 0;
+}
+
+static struct regulator_ops mc13783_regulator_ops = {
+       .enable = mc13783_regulator_enable,
+       .disable = mc13783_regulator_disable,
+       .is_enabled = mc13783_regulator_is_enabled,
+};
+
+static int __devinit mc13783_regulator_probe(struct platform_device *pdev)
+{
+       struct mc13783_regulator_priv *priv;
+       struct mc13783 *mc13783 = dev_get_drvdata(pdev->dev.parent);
+       struct mc13783_regulator_platform_data *pdata =
+               dev_get_platdata(&pdev->dev);
+       struct mc13783_regulator_init_data *init_data;
+       int i, ret;
+
+       dev_dbg(&pdev->dev, "mc13783_regulator_probe id %d\n", pdev->id);
+
+       priv = kzalloc(sizeof(*priv) +
+                       pdata->num_regulators * sizeof(priv->regulators[0]),
+                       GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->mc13783 = mc13783;
+
+       for (i = 0; i < pdata->num_regulators; i++) {
+               init_data = &pdata->regulators[i];
+               priv->regulators[i] = regulator_register(
+                               &mc13783_regulators[init_data->id].desc,
+                               &pdev->dev, init_data->init_data, priv);
+
+               if (IS_ERR(priv->regulators[i])) {
+                       dev_err(&pdev->dev, "failed to register regulator %s\n",
+                               mc13783_regulators[i].desc.name);
+                       ret = PTR_ERR(priv->regulators[i]);
+                       goto err;
+               }
+       }
+
+       platform_set_drvdata(pdev, priv);
+
+       return 0;
+err:
+       while (--i >= 0)
+               regulator_unregister(priv->regulators[i]);
+
+       kfree(priv);
+
+       return ret;
+}
+
+static int __devexit mc13783_regulator_remove(struct platform_device *pdev)
+{
+       struct mc13783_regulator_priv *priv = platform_get_drvdata(pdev);
+       struct mc13783_regulator_platform_data *pdata =
+               dev_get_platdata(&pdev->dev);
+       int i;
+
+       for (i = 0; i < pdata->num_regulators; i++)
+               regulator_unregister(priv->regulators[i]);
+
+       return 0;
+}
+
+static struct platform_driver mc13783_regulator_driver = {
+       .driver = {
+               .name   = "mc13783-regulator",
+               .owner  = THIS_MODULE,
+       },
+       .remove         = __devexit_p(mc13783_regulator_remove),
+       .probe          = mc13783_regulator_probe,
+};
+
+static int __init mc13783_regulator_init(void)
+{
+       return platform_driver_register(&mc13783_regulator_driver);
+}
+subsys_initcall(mc13783_regulator_init);
+
+static void __exit mc13783_regulator_exit(void)
+{
+       platform_driver_unregister(&mc13783_regulator_driver);
+}
+module_exit(mc13783_regulator_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de");
+MODULE_DESCRIPTION("Regulator Driver for Freescale MC13783 PMIC");
+MODULE_ALIAS("platform:mc13783-regulator");
diff --git a/drivers/regulator/mc13783.c b/drivers/regulator/mc13783.c
deleted file mode 100644 (file)
index 710211f..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Regulator Driver for Freescale MC13783 PMIC
- *
- * Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/mfd/mc13783-private.h>
-#include <linux/regulator/machine.h>
-#include <linux/regulator/driver.h>
-#include <linux/platform_device.h>
-#include <linux/mfd/mc13783.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/err.h>
-
-struct mc13783_regulator {
-       struct regulator_desc desc;
-       int reg;
-       int enable_bit;
-};
-
-static struct regulator_ops mc13783_regulator_ops;
-
-static struct mc13783_regulator mc13783_regulators[] = {
-       [MC13783_SW_SW3] = {
-               .desc = {
-                       .name   = "SW_SW3",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_SW_SW3,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_SWITCHERS_5,
-               .enable_bit = MC13783_SWCTRL_SW3_EN,
-       },
-       [MC13783_SW_PLL] = {
-               .desc = {
-                       .name   = "SW_PLL",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_SW_PLL,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_SWITCHERS_4,
-               .enable_bit = MC13783_SWCTRL_PLL_EN,
-       },
-       [MC13783_REGU_VAUDIO] = {
-               .desc = {
-                       .name   = "REGU_VAUDIO",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VAUDIO,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_0,
-               .enable_bit = MC13783_REGCTRL_VAUDIO_EN,
-       },
-       [MC13783_REGU_VIOHI] = {
-               .desc = {
-                       .name   = "REGU_VIOHI",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VIOHI,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_0,
-               .enable_bit = MC13783_REGCTRL_VIOHI_EN,
-       },
-       [MC13783_REGU_VIOLO] = {
-               .desc = {
-                       .name   = "REGU_VIOLO",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VIOLO,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_0,
-               .enable_bit = MC13783_REGCTRL_VIOLO_EN,
-       },
-       [MC13783_REGU_VDIG] = {
-               .desc = {
-                       .name   = "REGU_VDIG",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VDIG,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_0,
-               .enable_bit = MC13783_REGCTRL_VDIG_EN,
-       },
-       [MC13783_REGU_VGEN] = {
-               .desc = {
-                       .name   = "REGU_VGEN",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VGEN,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_0,
-               .enable_bit = MC13783_REGCTRL_VGEN_EN,
-       },
-       [MC13783_REGU_VRFDIG] = {
-               .desc = {
-                       .name   = "REGU_VRFDIG",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VRFDIG,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_0,
-               .enable_bit = MC13783_REGCTRL_VRFDIG_EN,
-       },
-       [MC13783_REGU_VRFREF] = {
-               .desc = {
-                       .name   = "REGU_VRFREF",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VRFREF,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_0,
-               .enable_bit = MC13783_REGCTRL_VRFREF_EN,
-       },
-       [MC13783_REGU_VRFCP] = {
-               .desc = {
-                       .name   = "REGU_VRFCP",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VRFCP,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_0,
-               .enable_bit = MC13783_REGCTRL_VRFCP_EN,
-       },
-       [MC13783_REGU_VSIM] = {
-               .desc = {
-                       .name   = "REGU_VSIM",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VSIM,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VSIM_EN,
-       },
-       [MC13783_REGU_VESIM] = {
-               .desc = {
-                       .name   = "REGU_VESIM",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VESIM,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VESIM_EN,
-       },
-       [MC13783_REGU_VCAM] = {
-               .desc = {
-                       .name   = "REGU_VCAM",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VCAM,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VCAM_EN,
-       },
-       [MC13783_REGU_VRFBG] = {
-               .desc = {
-                       .name   = "REGU_VRFBG",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VRFBG,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VRFBG_EN,
-       },
-       [MC13783_REGU_VVIB] = {
-               .desc = {
-                       .name   = "REGU_VVIB",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VVIB,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VVIB_EN,
-       },
-       [MC13783_REGU_VRF1] = {
-               .desc = {
-                       .name   = "REGU_VRF1",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VRF1,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VRF1_EN,
-       },
-       [MC13783_REGU_VRF2] = {
-               .desc = {
-                       .name   = "REGU_VRF2",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VRF2,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VRF2_EN,
-       },
-       [MC13783_REGU_VMMC1] = {
-               .desc = {
-                       .name   = "REGU_VMMC1",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VMMC1,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VMMC1_EN,
-       },
-       [MC13783_REGU_VMMC2] = {
-               .desc = {
-                       .name   = "REGU_VMMC2",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_VMMC2,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_REGULATOR_MODE_1,
-               .enable_bit = MC13783_REGCTRL_VMMC2_EN,
-       },
-       [MC13783_REGU_GPO1] = {
-               .desc = {
-                       .name   = "REGU_GPO1",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_GPO1,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_POWER_MISCELLANEOUS,
-               .enable_bit = MC13783_REGCTRL_GPO1_EN,
-       },
-       [MC13783_REGU_GPO2] = {
-               .desc = {
-                       .name   = "REGU_GPO2",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_GPO2,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_POWER_MISCELLANEOUS,
-               .enable_bit = MC13783_REGCTRL_GPO2_EN,
-       },
-       [MC13783_REGU_GPO3] = {
-               .desc = {
-                       .name   = "REGU_GPO3",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_GPO3,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_POWER_MISCELLANEOUS,
-               .enable_bit = MC13783_REGCTRL_GPO3_EN,
-       },
-       [MC13783_REGU_GPO4] = {
-               .desc = {
-                       .name   = "REGU_GPO4",
-                       .ops    = &mc13783_regulator_ops,
-                       .type   = REGULATOR_VOLTAGE,
-                       .id     = MC13783_REGU_GPO4,
-                       .owner  = THIS_MODULE,
-               },
-               .reg = MC13783_REG_POWER_MISCELLANEOUS,
-               .enable_bit = MC13783_REGCTRL_GPO4_EN,
-       },
-};
-
-struct mc13783_priv {
-       struct regulator_desc desc[ARRAY_SIZE(mc13783_regulators)];
-       struct mc13783 *mc13783;
-       struct regulator_dev *regulators[0];
-};
-
-static int mc13783_enable(struct regulator_dev *rdev)
-{
-       struct mc13783_priv *priv = rdev_get_drvdata(rdev);
-       int id = rdev_get_id(rdev);
-
-       dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
-
-       return mc13783_set_bits(priv->mc13783, mc13783_regulators[id].reg,
-                       mc13783_regulators[id].enable_bit,
-                       mc13783_regulators[id].enable_bit);
-}
-
-static int mc13783_disable(struct regulator_dev *rdev)
-{
-       struct mc13783_priv *priv = rdev_get_drvdata(rdev);
-       int id = rdev_get_id(rdev);
-
-       dev_dbg(rdev_get_dev(rdev), "%s id: %d\n", __func__, id);
-
-       return mc13783_set_bits(priv->mc13783, mc13783_regulators[id].reg,
-                       mc13783_regulators[id].enable_bit, 0);
-}
-
-static int mc13783_is_enabled(struct regulator_dev *rdev)
-{
-       struct mc13783_priv *priv = rdev_get_drvdata(rdev);
-       int ret, id = rdev_get_id(rdev);
-       unsigned int val;
-
-       ret = mc13783_reg_read(priv->mc13783, mc13783_regulators[id].reg, &val);
-       if (ret)
-               return ret;
-
-       return (val & mc13783_regulators[id].enable_bit) != 0;
-}
-
-static struct regulator_ops mc13783_regulator_ops = {
-       .enable         = mc13783_enable,
-       .disable        = mc13783_disable,
-       .is_enabled     = mc13783_is_enabled,
-};
-
-static int __devinit mc13783_regulator_probe(struct platform_device *pdev)
-{
-       struct mc13783_priv *priv;
-       struct mc13783 *mc13783 = dev_get_drvdata(pdev->dev.parent);
-       struct mc13783_regulator_init_data *init_data;
-       int i, ret;
-
-       dev_dbg(&pdev->dev, "mc13783_regulator_probe id %d\n", pdev->id);
-
-       priv = kzalloc(sizeof(*priv) + mc13783->num_regulators * sizeof(void *),
-                       GFP_KERNEL);
-       if (!priv)
-               return -ENOMEM;
-
-       priv->mc13783 = mc13783;
-
-       for (i = 0; i < mc13783->num_regulators; i++) {
-               init_data = &mc13783->regulators[i];
-               priv->regulators[i] = regulator_register(
-                               &mc13783_regulators[init_data->id].desc,
-                               &pdev->dev, init_data->init_data, priv);
-
-               if (IS_ERR(priv->regulators[i])) {
-                       dev_err(&pdev->dev, "failed to register regulator %s\n",
-                               mc13783_regulators[i].desc.name);
-                       ret = PTR_ERR(priv->regulators[i]);
-                       goto err;
-               }
-       }
-
-       platform_set_drvdata(pdev, priv);
-
-       return 0;
-err:
-       while (--i >= 0)
-               regulator_unregister(priv->regulators[i]);
-
-       kfree(priv);
-
-       return ret;
-}
-
-static int __devexit mc13783_regulator_remove(struct platform_device *pdev)
-{
-       struct mc13783_priv *priv = platform_get_drvdata(pdev);
-       struct mc13783 *mc13783 = priv->mc13783;
-       int i;
-
-       for (i = 0; i < mc13783->num_regulators; i++)
-               regulator_unregister(priv->regulators[i]);
-
-       return 0;
-}
-
-static struct platform_driver mc13783_regulator_driver = {
-       .driver = {
-               .name   = "mc13783-regulator",
-               .owner  = THIS_MODULE,
-       },
-       .remove         = __devexit_p(mc13783_regulator_remove),
-};
-
-static int __init mc13783_regulator_init(void)
-{
-       return platform_driver_probe(&mc13783_regulator_driver,
-                       mc13783_regulator_probe);
-}
-subsys_initcall(mc13783_regulator_init);
-
-static void __exit mc13783_regulator_exit(void)
-{
-       platform_driver_unregister(&mc13783_regulator_driver);
-}
-module_exit(mc13783_regulator_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de");
-MODULE_DESCRIPTION("Regulator Driver for Freescale MC13783 PMIC");
-MODULE_ALIAS("platform:mc13783-regulator");
index 7ea1c3a31081cd656b85ee62a1694ae943d34993..7e674859bd59b366288d43bf9baf2bc13dab8b11 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/err.h>
+#include <linux/delay.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/machine.h>
@@ -40,6 +41,12 @@ struct twlreg_info {
        u8                      table_len;
        const u16               *table;
 
+       /* regulator specific turn-on delay */
+       u16                     delay;
+
+       /* State REMAP default configuration */
+       u8                      remap;
+
        /* chip constraints on regulator behavior */
        u16                     min_mV;
 
@@ -128,6 +135,7 @@ static int twlreg_enable(struct regulator_dev *rdev)
 {
        struct twlreg_info      *info = rdev_get_drvdata(rdev);
        int                     grp;
+       int                     ret;
 
        grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
        if (grp < 0)
@@ -138,7 +146,11 @@ static int twlreg_enable(struct regulator_dev *rdev)
        else
                grp |= P1_GRP_6030;
 
-       return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
+       ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
+
+       udelay(info->delay);
+
+       return ret;
 }
 
 static int twlreg_disable(struct regulator_dev *rdev)
@@ -151,9 +163,9 @@ static int twlreg_disable(struct regulator_dev *rdev)
                return grp;
 
        if (twl_class_is_4030())
-               grp &= ~P1_GRP_4030;
+               grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030);
        else
-               grp &= ~P1_GRP_6030;
+               grp &= ~(P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030);
 
        return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
 }
@@ -294,6 +306,18 @@ static const u16 VSIM_VSEL_table[] = {
 static const u16 VDAC_VSEL_table[] = {
        1200, 1300, 1800, 1800,
 };
+static const u16 VDD1_VSEL_table[] = {
+       800, 1450,
+};
+static const u16 VDD2_VSEL_table[] = {
+       800, 1450, 1500,
+};
+static const u16 VIO_VSEL_table[] = {
+       1800, 1850,
+};
+static const u16 VINTANA2_VSEL_table[] = {
+       2500, 2750,
+};
 static const u16 VAUX1_6030_VSEL_table[] = {
        1000, 1300, 1800, 2500,
        2800, 2900, 3000, 3000,
@@ -414,20 +438,30 @@ static struct regulator_ops twlfixed_ops = {
 
 /*----------------------------------------------------------------------*/
 
-#define TWL4030_ADJUSTABLE_LDO(label, offset, num) \
-               TWL_ADJUSTABLE_LDO(label, offset, num, TWL4030)
-#define TWL4030_FIXED_LDO(label, offset, mVolts, num) \
-               TWL_FIXED_LDO(label, offset, mVolts, num, TWL4030)
-#define TWL6030_ADJUSTABLE_LDO(label, offset, num) \
-               TWL_ADJUSTABLE_LDO(label, offset, num, TWL6030)
-#define TWL6030_FIXED_LDO(label, offset, mVolts, num) \
-               TWL_FIXED_LDO(label, offset, mVolts, num, TWL6030)
-
-#define TWL_ADJUSTABLE_LDO(label, offset, num, family) { \
+#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \
+               TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \
+                       remap_conf, TWL4030)
+#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
+                       remap_conf) \
+               TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
+                       remap_conf, TWL4030)
+#define TWL6030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \
+                       remap_conf) \
+               TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, \
+                       remap_conf, TWL6030)
+#define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
+                       remap_conf) \
+               TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
+                       remap_conf, TWL6030)
+
+#define TWL_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf, \
+               family) { \
        .base = offset, \
        .id = num, \
        .table_len = ARRAY_SIZE(label##_VSEL_table), \
        .table = label##_VSEL_table, \
+       .delay = turnon_delay, \
+       .remap = remap_conf, \
        .desc = { \
                .name = #label, \
                .id = family##_REG_##label, \
@@ -438,10 +472,13 @@ static struct regulator_ops twlfixed_ops = {
                }, \
        }
 
-#define TWL_FIXED_LDO(label, offset, mVolts, num, family) { \
+#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
+               family) { \
        .base = offset, \
        .id = num, \
        .min_mV = mVolts, \
+       .delay = turnon_delay, \
+       .remap = remap_conf, \
        .desc = { \
                .name = #label, \
                .id = family##_REG_##label, \
@@ -457,43 +494,41 @@ static struct regulator_ops twlfixed_ops = {
  * software control over them after boot.
  */
 static struct twlreg_info twl_regs[] = {
-       TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1),
-       TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2),
-       TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2),
-       TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3),
-       TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4),
-       TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5),
-       TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6),
-       /*
-       TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7),
-       */
-       TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8),
-       TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9),
-       TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10),
-       /*
-       TWL4030_ADJUSTABLE_LDO(VINTANA1, 0x3f, 11),
-       TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12),
-       TWL4030_ADJUSTABLE_LDO(VINTDIG, 0x47, 13),
-       TWL4030_SMPS(VIO, 0x4b, 14),
-       TWL4030_SMPS(VDD1, 0x55, 15),
-       TWL4030_SMPS(VDD2, 0x63, 16),
-        */
-       TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17),
-       TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18),
-       TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19),
+       TWL4030_ADJUSTABLE_LDO(VAUX1, 0x17, 1, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VAUX2, 0x1b, 2, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VAUX3, 0x1f, 3, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VAUX4, 0x23, 4, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VMMC1, 0x27, 5, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VMMC2, 0x2b, 6, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VPLL1, 0x2f, 7, 100, 0x00),
+       TWL4030_ADJUSTABLE_LDO(VPLL2, 0x33, 8, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VSIM, 0x37, 9, 100, 0x00),
+       TWL4030_ADJUSTABLE_LDO(VDAC, 0x3b, 10, 100, 0x08),
+       TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VINTANA2, 0x43, 12, 100, 0x08),
+       TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VDD1, 0x55, 15, 1000, 0x08),
+       TWL4030_ADJUSTABLE_LDO(VDD2, 0x63, 16, 1000, 0x08),
+       TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08),
+       TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08),
+       TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08),
        /* VUSBCP is managed *only* by the USB subchip */
 
        /* 6030 REG with base as PMC Slave Misc : 0x0030 */
-       TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1),
-       TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 2),
-       TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 3),
-       TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 4),
-       TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 5),
-       TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 7),
-       TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15),
-       TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16),
-       TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17),
-       TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18)
+       /* Turnon-delay and remap configuration values for 6030 are not
+          verified since the specification is not public */
+       TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1, 0, 0x08),
+       TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 2, 0, 0x08),
+       TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 3, 0, 0x08),
+       TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 4, 0, 0x08),
+       TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 5, 0, 0x08),
+       TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 7, 0, 0x08),
+       TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0, 0x08),
+       TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0, 0x08),
+       TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0, 0x08),
+       TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18, 0, 0x08)
 };
 
 static int twlreg_probe(struct platform_device *pdev)
@@ -525,6 +560,19 @@ static int twlreg_probe(struct platform_device *pdev)
        c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
                                | REGULATOR_CHANGE_MODE
                                | REGULATOR_CHANGE_STATUS;
+       switch (pdev->id) {
+       case TWL4030_REG_VIO:
+       case TWL4030_REG_VDD1:
+       case TWL4030_REG_VDD2:
+       case TWL4030_REG_VPLL1:
+       case TWL4030_REG_VINTANA1:
+       case TWL4030_REG_VINTANA2:
+       case TWL4030_REG_VINTDIG:
+               c->always_on = true;
+               break;
+       default:
+               break;
+       }
 
        rdev = regulator_register(&info->desc, &pdev->dev, initdata, info);
        if (IS_ERR(rdev)) {
@@ -534,6 +582,9 @@ static int twlreg_probe(struct platform_device *pdev)
        }
        platform_set_drvdata(pdev, rdev);
 
+       twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP,
+                                               info->remap);
+
        /* NOTE:  many regulators support short-circuit IRQs (presentable
         * as REGULATOR_OVER_CURRENT notifications?) configured via:
         *  - SC_CONFIG
index 2eefc1a0cf08eedcb68235dcd2dcfe0857910151..0a6577577e8d674252ea8b2a025f4a23515c5681 100644 (file)
@@ -19,6 +19,8 @@
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/gpio.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/regulator.h>
@@ -39,6 +41,7 @@
 #define WM831X_DCDC_CONTROL_2     1
 #define WM831X_DCDC_ON_CONFIG     2
 #define WM831X_DCDC_SLEEP_CONTROL 3
+#define WM831X_DCDC_DVS_CONTROL   4
 
 /*
  * Shared
@@ -50,6 +53,10 @@ struct wm831x_dcdc {
        int base;
        struct wm831x *wm831x;
        struct regulator_dev *regulator;
+       int dvs_gpio;
+       int dvs_gpio_state;
+       int on_vsel;
+       int dvs_vsel;
 };
 
 static int wm831x_dcdc_is_enabled(struct regulator_dev *rdev)
@@ -240,11 +247,9 @@ static int wm831x_buckv_list_voltage(struct regulator_dev *rdev,
        return -EINVAL;
 }
 
-static int wm831x_buckv_set_voltage_int(struct regulator_dev *rdev, int reg,
-                                        int min_uV, int max_uV)
+static int wm831x_buckv_select_min_voltage(struct regulator_dev *rdev,
+                                          int min_uV, int max_uV)
 {
-       struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
-       struct wm831x *wm831x = dcdc->wm831x;
        u16 vsel;
 
        if (min_uV < 600000)
@@ -257,39 +262,126 @@ static int wm831x_buckv_set_voltage_int(struct regulator_dev *rdev, int reg,
        if (wm831x_buckv_list_voltage(rdev, vsel) > max_uV)
                return -EINVAL;
 
-       return wm831x_set_bits(wm831x, reg, WM831X_DC1_ON_VSEL_MASK, vsel);
+       return vsel;
+}
+
+static int wm831x_buckv_select_max_voltage(struct regulator_dev *rdev,
+                                          int min_uV, int max_uV)
+{
+       u16 vsel;
+
+       if (max_uV < 600000 || max_uV > 1800000)
+               return -EINVAL;
+
+       vsel = ((max_uV - 600000) / 12500) + 8;
+
+       if (wm831x_buckv_list_voltage(rdev, vsel) < min_uV ||
+           wm831x_buckv_list_voltage(rdev, vsel) < max_uV)
+               return -EINVAL;
+
+       return vsel;
+}
+
+static int wm831x_buckv_set_dvs(struct regulator_dev *rdev, int state)
+{
+       struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
+
+       if (state == dcdc->dvs_gpio_state)
+               return 0;
+
+       dcdc->dvs_gpio_state = state;
+       gpio_set_value(dcdc->dvs_gpio, state);
+
+       /* Should wait for DVS state change to be asserted if we have
+        * a GPIO for it, for now assume the device is configured
+        * for the fastest possible transition.
+        */
+
+       return 0;
 }
 
 static int wm831x_buckv_set_voltage(struct regulator_dev *rdev,
-                                    int min_uV, int max_uV)
+                                   int min_uV, int max_uV)
 {
        struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
-       u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
+       struct wm831x *wm831x = dcdc->wm831x;
+       int on_reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
+       int dvs_reg = dcdc->base + WM831X_DCDC_DVS_CONTROL;
+       int vsel, ret;
+
+       vsel = wm831x_buckv_select_min_voltage(rdev, min_uV, max_uV);
+       if (vsel < 0)
+               return vsel;
+
+       /* If this value is already set then do a GPIO update if we can */
+       if (dcdc->dvs_gpio && dcdc->on_vsel == vsel)
+               return wm831x_buckv_set_dvs(rdev, 0);
+
+       if (dcdc->dvs_gpio && dcdc->dvs_vsel == vsel)
+               return wm831x_buckv_set_dvs(rdev, 1);
+
+       /* Always set the ON status to the minimum voltage */
+       ret = wm831x_set_bits(wm831x, on_reg, WM831X_DC1_ON_VSEL_MASK, vsel);
+       if (ret < 0)
+               return ret;
+       dcdc->on_vsel = vsel;
+
+       if (!dcdc->dvs_gpio)
+               return ret;
+
+       /* Kick the voltage transition now */
+       ret = wm831x_buckv_set_dvs(rdev, 0);
+       if (ret < 0)
+               return ret;
+
+       /* Set the high voltage as the DVS voltage.  This is optimised
+        * for CPUfreq usage, most processors will keep the maximum
+        * voltage constant and lower the minimum with the frequency. */
+       vsel = wm831x_buckv_select_max_voltage(rdev, min_uV, max_uV);
+       if (vsel < 0) {
+               /* This should never happen - at worst the same vsel
+                * should be chosen */
+               WARN_ON(vsel < 0);
+               return 0;
+       }
+
+       /* Don't bother if it's the same VSEL we're already using */
+       if (vsel == dcdc->on_vsel)
+               return 0;
 
-       return wm831x_buckv_set_voltage_int(rdev, reg, min_uV, max_uV);
+       ret = wm831x_set_bits(wm831x, dvs_reg, WM831X_DC1_DVS_VSEL_MASK, vsel);
+       if (ret == 0)
+               dcdc->dvs_vsel = vsel;
+       else
+               dev_warn(wm831x->dev, "Failed to set DCDC DVS VSEL: %d\n",
+                        ret);
+
+       return 0;
 }
 
 static int wm831x_buckv_set_suspend_voltage(struct regulator_dev *rdev,
-                                            int uV)
+                                           int uV)
 {
        struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
+       struct wm831x *wm831x = dcdc->wm831x;
        u16 reg = dcdc->base + WM831X_DCDC_SLEEP_CONTROL;
+       int vsel;
+
+       vsel = wm831x_buckv_select_min_voltage(rdev, uV, uV);
+       if (vsel < 0)
+               return vsel;
 
-       return wm831x_buckv_set_voltage_int(rdev, reg, uV, uV);
+       return wm831x_set_bits(wm831x, reg, WM831X_DC1_SLP_VSEL_MASK, vsel);
 }
 
 static int wm831x_buckv_get_voltage(struct regulator_dev *rdev)
 {
        struct wm831x_dcdc *dcdc = rdev_get_drvdata(rdev);
-       struct wm831x *wm831x = dcdc->wm831x;
-       u16 reg = dcdc->base + WM831X_DCDC_ON_CONFIG;
-       int val;
 
-       val = wm831x_reg_read(wm831x, reg);
-       if (val < 0)
-               return val;
-
-       return wm831x_buckv_list_voltage(rdev, val & WM831X_DC1_ON_VSEL_MASK);
+       if (dcdc->dvs_gpio && dcdc->dvs_gpio_state)
+               return wm831x_buckv_list_voltage(rdev, dcdc->dvs_vsel);
+       else
+               return wm831x_buckv_list_voltage(rdev, dcdc->on_vsel);
 }
 
 /* Current limit options */
@@ -346,6 +438,64 @@ static struct regulator_ops wm831x_buckv_ops = {
        .set_suspend_mode = wm831x_dcdc_set_suspend_mode,
 };
 
+/*
+ * Set up DVS control.  We just log errors since we can still run
+ * (with reduced performance) if we fail.
+ */
+static __devinit void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc,
+                                           struct wm831x_buckv_pdata *pdata)
+{
+       struct wm831x *wm831x = dcdc->wm831x;
+       int ret;
+       u16 ctrl;
+
+       if (!pdata || !pdata->dvs_gpio)
+               return;
+
+       switch (pdata->dvs_control_src) {
+       case 1:
+               ctrl = 2 << WM831X_DC1_DVS_SRC_SHIFT;
+               break;
+       case 2:
+               ctrl = 3 << WM831X_DC1_DVS_SRC_SHIFT;
+               break;
+       default:
+               dev_err(wm831x->dev, "Invalid DVS control source %d for %s\n",
+                       pdata->dvs_control_src, dcdc->name);
+               return;
+       }
+
+       ret = wm831x_set_bits(wm831x, dcdc->base + WM831X_DCDC_DVS_CONTROL,
+                             WM831X_DC1_DVS_SRC_MASK, ctrl);
+       if (ret < 0) {
+               dev_err(wm831x->dev, "Failed to set %s DVS source: %d\n",
+                       dcdc->name, ret);
+               return;
+       }
+
+       ret = gpio_request(pdata->dvs_gpio, "DCDC DVS");
+       if (ret < 0) {
+               dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n",
+                       dcdc->name, ret);
+               return;
+       }
+
+       /* gpiolib won't let us read the GPIO status so pick the higher
+        * of the two existing voltages so we take it as platform data.
+        */
+       dcdc->dvs_gpio_state = pdata->dvs_init_state;
+
+       ret = gpio_direction_output(pdata->dvs_gpio, dcdc->dvs_gpio_state);
+       if (ret < 0) {
+               dev_err(wm831x->dev, "Failed to enable %s DVS GPIO: %d\n",
+                       dcdc->name, ret);
+               gpio_free(pdata->dvs_gpio);
+               return;
+       }
+
+       dcdc->dvs_gpio = pdata->dvs_gpio;
+}
+
 static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
 {
        struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
@@ -384,6 +534,23 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
        dcdc->desc.ops = &wm831x_buckv_ops;
        dcdc->desc.owner = THIS_MODULE;
 
+       ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG);
+       if (ret < 0) {
+               dev_err(wm831x->dev, "Failed to read ON VSEL: %d\n", ret);
+               goto err;
+       }
+       dcdc->on_vsel = ret & WM831X_DC1_ON_VSEL_MASK;
+
+       ret = wm831x_reg_read(wm831x, dcdc->base + WM831X_DCDC_ON_CONFIG);
+       if (ret < 0) {
+               dev_err(wm831x->dev, "Failed to read DVS VSEL: %d\n", ret);
+               goto err;
+       }
+       dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK;
+
+       if (pdata->dcdc[id])
+               wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data);
+
        dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev,
                                             pdata->dcdc[id], dcdc);
        if (IS_ERR(dcdc->regulator)) {
@@ -422,6 +589,8 @@ err_uv:
 err_regulator:
        regulator_unregister(dcdc->regulator);
 err:
+       if (dcdc->dvs_gpio)
+               gpio_free(dcdc->dvs_gpio);
        kfree(dcdc);
        return ret;
 }
@@ -434,6 +603,8 @@ static __devexit int wm831x_buckv_remove(struct platform_device *pdev)
        wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "HC"), dcdc);
        wm831x_free_irq(wm831x, platform_get_irq_byname(pdev, "UV"), dcdc);
        regulator_unregister(dcdc->regulator);
+       if (dcdc->dvs_gpio)
+               gpio_free(dcdc->dvs_gpio);
        kfree(dcdc);
 
        return 0;
index 902db56ce099676f6a2a3f2483dd0d7b3c75811f..61e02ac2fda334f9e17dd145cf65d938f816548e 100644 (file)
@@ -470,7 +470,7 @@ static unsigned int wm831x_aldo_get_mode(struct regulator_dev *rdev)
        struct wm831x_ldo *ldo = rdev_get_drvdata(rdev);
        struct wm831x *wm831x = ldo->wm831x;
        int on_reg = ldo->base + WM831X_LDO_ON_CONTROL;
-       unsigned int ret;
+       int ret;
 
        ret = wm831x_reg_read(wm831x, on_reg);
        if (ret < 0)
index 71fbd6e8edf71b9fda76a3df084ba00d50e77681..8167e9e6827aa589a4a936082ccabf8ff65976ac 100644 (file)
@@ -242,6 +242,15 @@ config RTC_DRV_M41T80_WDT
          If you say Y here you will get support for the
          watchdog timer in the ST M41T60 and M41T80 RTC chips series.
 
+config RTC_DRV_BQ32K
+       tristate "TI BQ32000"
+       help
+         If you say Y here you will get support for the TI
+         BQ32000 I2C RTC chip.
+
+         This driver can also be built as a module. If so, the module
+         will be called rtc-bq32k.
+
 config RTC_DRV_DM355EVM
        tristate "TI DaVinci DM355 EVM RTC"
        depends on MFD_DM355EVM_MSP
@@ -592,15 +601,22 @@ config RTC_DRV_AB3100
          Select this to enable the ST-Ericsson AB3100 Mixed Signal IC RTC
          support. This chip contains a battery- and capacitor-backed RTC.
 
+config RTC_DRV_NUC900
+       tristate "NUC910/NUC920 RTC driver"
+       depends on RTC_CLASS && ARCH_W90X900
+       help
+         If you say yes here you get support for the RTC subsystem of the
+         NUC910/NUC920 used in embedded systems.
 
 comment "on-CPU RTC drivers"
 
 config RTC_DRV_OMAP
        tristate "TI OMAP1"
-       depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730
+       depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX
        help
-         Say "yes" here to support the real time clock on TI OMAP1 chips.
-         This driver can also be built as a module called rtc-omap.
+         Say "yes" here to support the real time clock on TI OMAP1 and
+         DA8xx/OMAP-L13x chips.  This driver can also be built as a
+         module called rtc-omap.
 
 config RTC_DRV_S3C
        tristate "Samsung S3C series SoC RTC"
@@ -846,4 +862,10 @@ config RTC_DRV_PCAP
          If you say Y here you will get support for the RTC found on
          the PCAP2 ASIC used on some Motorola phones.
 
+config RTC_DRV_MC13783
+       depends on MFD_MC13783
+       tristate "Freescale MC13783 RTC"
+       help
+         This enables support for the Freescale MC13783 PMIC RTC
+
 endif # RTC_CLASS
index 7da6efb3e953407d9be5723797dd7a9c4ece1e30..e5160fddc4463da7ea295452e80948d0447d4f03 100644 (file)
@@ -23,6 +23,7 @@ obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
 obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
 obj-$(CONFIG_RTC_DRV_AU1XXX)   += rtc-au1xxx.o
 obj-$(CONFIG_RTC_DRV_BFIN)     += rtc-bfin.o
+obj-$(CONFIG_RTC_DRV_BQ32K)    += rtc-bq32k.o
 obj-$(CONFIG_RTC_DRV_BQ4802)   += rtc-bq4802.o
 obj-$(CONFIG_RTC_DRV_CMOS)     += rtc-cmos.o
 obj-$(CONFIG_RTC_DRV_COH901331)        += rtc-coh901331.o
@@ -52,8 +53,10 @@ obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o
 obj-$(CONFIG_RTC_MXC)          += rtc-mxc.o
 obj-$(CONFIG_RTC_DRV_MAX6900)  += rtc-max6900.o
 obj-$(CONFIG_RTC_DRV_MAX6902)  += rtc-max6902.o
+obj-$(CONFIG_RTC_DRV_MC13783)  += rtc-mc13783.o
 obj-$(CONFIG_RTC_DRV_MSM6242)  += rtc-msm6242.o
 obj-$(CONFIG_RTC_DRV_MV)       += rtc-mv.o
+obj-$(CONFIG_RTC_DRV_NUC900)   += rtc-nuc900.o
 obj-$(CONFIG_RTC_DRV_OMAP)     += rtc-omap.o
 obj-$(CONFIG_RTC_DRV_PCAP)     += rtc-pcap.o
 obj-$(CONFIG_RTC_DRV_PCF8563)  += rtc-pcf8563.o
index e1ec33e40e388d229d55b27cc78e79275951da0e..8825695777df281777a3d61e7179b0afa9d61f55 100644 (file)
@@ -256,6 +256,8 @@ static int __init at32_rtc_probe(struct platform_device *pdev)
                goto out_iounmap;
        }
 
+       platform_set_drvdata(pdev, rtc);
+
        rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
                                &at32_rtc_ops, THIS_MODULE);
        if (IS_ERR(rtc->rtc)) {
@@ -264,7 +266,6 @@ static int __init at32_rtc_probe(struct platform_device *pdev)
                goto out_free_irq;
        }
 
-       platform_set_drvdata(pdev, rtc);
        device_init_wakeup(&pdev->dev, 1);
 
        dev_info(&pdev->dev, "Atmel RTC for AT32AP700x at %08lx irq %ld\n",
@@ -273,6 +274,7 @@ static int __init at32_rtc_probe(struct platform_device *pdev)
        return 0;
 
 out_free_irq:
+       platform_set_drvdata(pdev, NULL);
        free_irq(irq, rtc);
 out_iounmap:
        iounmap(rtc->regs);
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c
new file mode 100644 (file)
index 0000000..408cc8f
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Driver for TI BQ32000 RTC.
+ *
+ * Copyright (C) 2009 Semihalf.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/rtc.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/bcd.h>
+
+#define BQ32K_SECONDS          0x00    /* Seconds register address */
+#define BQ32K_SECONDS_MASK     0x7F    /* Mask over seconds value */
+#define BQ32K_STOP             0x80    /* Oscillator Stop flat */
+
+#define BQ32K_MINUTES          0x01    /* Minutes register address */
+#define BQ32K_MINUTES_MASK     0x7F    /* Mask over minutes value */
+#define BQ32K_OF               0x80    /* Oscillator Failure flag */
+
+#define BQ32K_HOURS_MASK       0x3F    /* Mask over hours value */
+#define BQ32K_CENT             0x40    /* Century flag */
+#define BQ32K_CENT_EN          0x80    /* Century flag enable bit */
+
+struct bq32k_regs {
+       uint8_t         seconds;
+       uint8_t         minutes;
+       uint8_t         cent_hours;
+       uint8_t         day;
+       uint8_t         date;
+       uint8_t         month;
+       uint8_t         years;
+};
+
+static struct i2c_driver bq32k_driver;
+
+static int bq32k_read(struct device *dev, void *data, uint8_t off, uint8_t len)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct i2c_msg msgs[] = {
+               {
+                       .addr = client->addr,
+                       .flags = 0,
+                       .len = 1,
+                       .buf = &off,
+               }, {
+                       .addr = client->addr,
+                       .flags = I2C_M_RD,
+                       .len = len,
+                       .buf = data,
+               }
+       };
+
+       if (i2c_transfer(client->adapter, msgs, 2) == 2)
+               return 0;
+
+       return -EIO;
+}
+
+static int bq32k_write(struct device *dev, void *data, uint8_t off, uint8_t len)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       uint8_t buffer[len + 1];
+
+       buffer[0] = off;
+       memcpy(&buffer[1], data, len);
+
+       if (i2c_master_send(client, buffer, len + 1) == len + 1)
+               return 0;
+
+       return -EIO;
+}
+
+static int bq32k_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+       struct bq32k_regs regs;
+       int error;
+
+       error = bq32k_read(dev, &regs, 0, sizeof(regs));
+       if (error)
+               return error;
+
+       tm->tm_sec = bcd2bin(regs.seconds & BQ32K_SECONDS_MASK);
+       tm->tm_min = bcd2bin(regs.minutes & BQ32K_SECONDS_MASK);
+       tm->tm_hour = bcd2bin(regs.cent_hours & BQ32K_HOURS_MASK);
+       tm->tm_mday = bcd2bin(regs.date);
+       tm->tm_wday = bcd2bin(regs.day) - 1;
+       tm->tm_mon = bcd2bin(regs.month) - 1;
+       tm->tm_year = bcd2bin(regs.years) +
+                               ((regs.cent_hours & BQ32K_CENT) ? 100 : 0);
+
+       return rtc_valid_tm(tm);
+}
+
+static int bq32k_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+       struct bq32k_regs regs;
+
+       regs.seconds = bin2bcd(tm->tm_sec);
+       regs.minutes = bin2bcd(tm->tm_min);
+       regs.cent_hours = bin2bcd(tm->tm_hour) | BQ32K_CENT_EN;
+       regs.day = bin2bcd(tm->tm_wday + 1);
+       regs.date = bin2bcd(tm->tm_mday);
+       regs.month = bin2bcd(tm->tm_mon + 1);
+
+       if (tm->tm_year >= 100) {
+               regs.cent_hours |= BQ32K_CENT;
+               regs.years = bin2bcd(tm->tm_year - 100);
+       } else
+               regs.years = bin2bcd(tm->tm_year);
+
+       return bq32k_write(dev, &regs, 0, sizeof(regs));
+}
+
+static const struct rtc_class_ops bq32k_rtc_ops = {
+       .read_time      = bq32k_rtc_read_time,
+       .set_time       = bq32k_rtc_set_time,
+};
+
+static int bq32k_probe(struct i2c_client *client,
+                               const struct i2c_device_id *id)
+{
+       struct device *dev = &client->dev;
+       struct rtc_device *rtc;
+       uint8_t reg;
+       int error;
+
+       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+               return -ENODEV;
+
+       /* Check Oscillator Stop flag */
+       error = bq32k_read(dev, &reg, BQ32K_SECONDS, 1);
+       if (!error && (reg & BQ32K_STOP)) {
+               dev_warn(dev, "Oscillator was halted. Restarting...\n");
+               reg &= ~BQ32K_STOP;
+               error = bq32k_write(dev, &reg, BQ32K_SECONDS, 1);
+       }
+       if (error)
+               return error;
+
+       /* Check Oscillator Failure flag */
+       error = bq32k_read(dev, &reg, BQ32K_MINUTES, 1);
+       if (!error && (reg & BQ32K_OF)) {
+               dev_warn(dev, "Oscillator Failure. Check RTC battery.\n");
+               reg &= ~BQ32K_OF;
+               error = bq32k_write(dev, &reg, BQ32K_MINUTES, 1);
+       }
+       if (error)
+               return error;
+
+       rtc = rtc_device_register(bq32k_driver.driver.name, &client->dev,
+                                               &bq32k_rtc_ops, THIS_MODULE);
+       if (IS_ERR(rtc))
+               return PTR_ERR(rtc);
+
+       i2c_set_clientdata(client, rtc);
+
+       return 0;
+}
+
+static int __devexit bq32k_remove(struct i2c_client *client)
+{
+       struct rtc_device *rtc = i2c_get_clientdata(client);
+
+       rtc_device_unregister(rtc);
+       return 0;
+}
+
+static const struct i2c_device_id bq32k_id[] = {
+       { "bq32000", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, bq32k_id);
+
+static struct i2c_driver bq32k_driver = {
+       .driver = {
+               .name   = "bq32k",
+               .owner  = THIS_MODULE,
+       },
+       .probe          = bq32k_probe,
+       .remove         = __devexit_p(bq32k_remove),
+       .id_table       = bq32k_id,
+};
+
+static __init int bq32k_init(void)
+{
+       return i2c_add_driver(&bq32k_driver);
+}
+module_init(bq32k_init);
+
+static __exit void bq32k_exit(void)
+{
+       i2c_del_driver(&bq32k_driver);
+}
+module_exit(bq32k_exit);
+
+MODULE_AUTHOR("Semihalf, Piotr Ziecik <kosmo@semihalf.com>");
+MODULE_DESCRIPTION("TI BQ32000 I2C RTC driver");
+MODULE_LICENSE("GPL");
index d00a274df8fcedf76d00d52d668493e9e9e068cf..280fe48ada0bfa629556a9da28d232d7f3462064 100644 (file)
@@ -169,6 +169,8 @@ static int __devinit bq4802_probe(struct platform_device *pdev)
                goto out_free;
        }
 
+       platform_set_drvdata(pdev, p);
+
        p->rtc = rtc_device_register("bq4802", &pdev->dev,
                                     &bq4802_ops, THIS_MODULE);
        if (IS_ERR(p->rtc)) {
@@ -176,7 +178,6 @@ static int __devinit bq4802_probe(struct platform_device *pdev)
                goto out_iounmap;
        }
 
-       platform_set_drvdata(pdev, p);
        err = 0;
 out:
        return err;
index f7a4701bf863695d567340451f4b98a13ce6e14b..c8c12325e69b9feef3e7a5918fd59ef99fea8192 100644 (file)
@@ -420,49 +420,43 @@ static int cmos_irq_set_state(struct device *dev, int enabled)
        return 0;
 }
 
-#if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE)
-
-static int
-cmos_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled)
 {
        struct cmos_rtc *cmos = dev_get_drvdata(dev);
        unsigned long   flags;
 
-       switch (cmd) {
-       case RTC_AIE_OFF:
-       case RTC_AIE_ON:
-       case RTC_UIE_OFF:
-       case RTC_UIE_ON:
-               if (!is_valid_irq(cmos->irq))
-                       return -EINVAL;
-               break;
-       /* PIE ON/OFF is handled by cmos_irq_set_state() */
-       default:
-               return -ENOIOCTLCMD;
-       }
+       if (!is_valid_irq(cmos->irq))
+               return -EINVAL;
 
        spin_lock_irqsave(&rtc_lock, flags);
-       switch (cmd) {
-       case RTC_AIE_OFF:       /* alarm off */
-               cmos_irq_disable(cmos, RTC_AIE);
-               break;
-       case RTC_AIE_ON:        /* alarm on */
+
+       if (enabled)
                cmos_irq_enable(cmos, RTC_AIE);
-               break;
-       case RTC_UIE_OFF:       /* update off */
-               cmos_irq_disable(cmos, RTC_UIE);
-               break;
-       case RTC_UIE_ON:        /* update on */
-               cmos_irq_enable(cmos, RTC_UIE);
-               break;
-       }
+       else
+               cmos_irq_disable(cmos, RTC_AIE);
+
        spin_unlock_irqrestore(&rtc_lock, flags);
        return 0;
 }
 
-#else
-#define        cmos_rtc_ioctl  NULL
-#endif
+static int cmos_update_irq_enable(struct device *dev, unsigned int enabled)
+{
+       struct cmos_rtc *cmos = dev_get_drvdata(dev);
+       unsigned long   flags;
+
+       if (!is_valid_irq(cmos->irq))
+               return -EINVAL;
+
+       spin_lock_irqsave(&rtc_lock, flags);
+
+       if (enabled)
+               cmos_irq_enable(cmos, RTC_UIE);
+       else
+               cmos_irq_disable(cmos, RTC_UIE);
+
+       spin_unlock_irqrestore(&rtc_lock, flags);
+       return 0;
+}
 
 #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE)
 
@@ -503,14 +497,15 @@ static int cmos_procfs(struct device *dev, struct seq_file *seq)
 #endif
 
 static const struct rtc_class_ops cmos_rtc_ops = {
-       .ioctl          = cmos_rtc_ioctl,
-       .read_time      = cmos_read_time,
-       .set_time       = cmos_set_time,
-       .read_alarm     = cmos_read_alarm,
-       .set_alarm      = cmos_set_alarm,
-       .proc           = cmos_procfs,
-       .irq_set_freq   = cmos_irq_set_freq,
-       .irq_set_state  = cmos_irq_set_state,
+       .read_time              = cmos_read_time,
+       .set_time               = cmos_set_time,
+       .read_alarm             = cmos_read_alarm,
+       .set_alarm              = cmos_set_alarm,
+       .proc                   = cmos_procfs,
+       .irq_set_freq           = cmos_irq_set_freq,
+       .irq_set_state          = cmos_irq_set_state,
+       .alarm_irq_enable       = cmos_alarm_irq_enable,
+       .update_irq_enable      = cmos_update_irq_enable,
 };
 
 /*----------------------------------------------------------------*/
@@ -691,7 +686,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
         */
 #if    defined(CONFIG_ATARI)
        address_space = 64;
-#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__sparc__)
+#elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) \
+                       || defined(__sparc__) || defined(__mips__)
        address_space = 128;
 #else
 #warning Assuming 128 bytes of RTC+NVRAM address space, not 64 bytes.
@@ -871,8 +867,9 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg)
                        mask = RTC_IRQMASK;
                tmp &= ~mask;
                CMOS_WRITE(tmp, RTC_CONTROL);
-               hpet_mask_rtc_irq_bit(mask);
 
+               /* shut down hpet emulation - we don't need it for alarm */
+               hpet_mask_rtc_irq_bit(RTC_PIE|RTC_AIE|RTC_UIE);
                cmos_checkintr(cmos, tmp);
        }
        spin_unlock_irq(&rtc_lock);
index 1e73c8f42e387473e6d116b906833c25bedd07b6..532acf9b05d895f2a7c8762ce0ec9c98cfe620ff 100644 (file)
@@ -143,7 +143,6 @@ static int ds1302_rtc_ioctl(struct device *dev, unsigned int cmd,
 #ifdef RTC_SET_CHARGE
        case RTC_SET_CHARGE:
        {
-               struct ds1302_rtc *rtc = dev_get_drvdata(dev);
                int tcs_val;
 
                if (copy_from_user(&tcs_val, (int __user *)arg, sizeof(int)))
index 2736b11a1b1ec4e45e12e391d6ddee5b95c2e8b0..9630e7d3314e59d19dd9e94be9f917cab7307f16 100644 (file)
@@ -617,7 +617,6 @@ static struct bin_attribute nvram = {
 static int __devinit ds1305_probe(struct spi_device *spi)
 {
        struct ds1305                   *ds1305;
-       struct rtc_device               *rtc;
        int                             status;
        u8                              addr, value;
        struct ds1305_platform_data     *pdata = spi->dev.platform_data;
@@ -756,14 +755,13 @@ static int __devinit ds1305_probe(struct spi_device *spi)
                dev_dbg(&spi->dev, "AM/PM\n");
 
        /* register RTC ... from here on, ds1305->ctrl needs locking */
-       rtc = rtc_device_register("ds1305", &spi->dev,
+       ds1305->rtc = rtc_device_register("ds1305", &spi->dev,
                        &ds1305_ops, THIS_MODULE);
-       if (IS_ERR(rtc)) {
-               status = PTR_ERR(rtc);
+       if (IS_ERR(ds1305->rtc)) {
+               status = PTR_ERR(ds1305->rtc);
                dev_dbg(&spi->dev, "register rtc --> %d\n", status);
                goto fail0;
        }
-       ds1305->rtc = rtc;
 
        /* Maybe set up alarm IRQ; be ready to handle it triggering right
         * away.  NOTE that we don't share this.  The signal is active low,
@@ -774,12 +772,14 @@ static int __devinit ds1305_probe(struct spi_device *spi)
        if (spi->irq) {
                INIT_WORK(&ds1305->work, ds1305_work);
                status = request_irq(spi->irq, ds1305_irq,
-                               0, dev_name(&rtc->dev), ds1305);
+                               0, dev_name(&ds1305->rtc->dev), ds1305);
                if (status < 0) {
                        dev_dbg(&spi->dev, "request_irq %d --> %d\n",
                                        spi->irq, status);
                        goto fail1;
                }
+
+               device_set_wakeup_capable(&spi->dev, 1);
        }
 
        /* export NVRAM */
@@ -794,7 +794,7 @@ static int __devinit ds1305_probe(struct spi_device *spi)
 fail2:
        free_irq(spi->irq, ds1305);
 fail1:
-       rtc_device_unregister(rtc);
+       rtc_device_unregister(ds1305->rtc);
 fail0:
        kfree(ds1305);
        return status;
@@ -802,7 +802,7 @@ fail0:
 
 static int __devexit ds1305_remove(struct spi_device *spi)
 {
-       struct ds1305   *ds1305 = spi_get_drvdata(spi);
+       struct ds1305 *ds1305 = spi_get_drvdata(spi);
 
        sysfs_remove_bin_file(&spi->dev.kobj, &nvram);
 
index eb99ee4fa0f5778a39e4faddd892766b06d0f078..c4ec5c158aa14f81ca355c9c0b0366ffa383e11c 100644 (file)
@@ -874,13 +874,15 @@ read_rtc:
        }
 
        if (want_irq) {
-               err = request_irq(client->irq, ds1307_irq, 0,
+               err = request_irq(client->irq, ds1307_irq, IRQF_SHARED,
                          ds1307->rtc->name, client);
                if (err) {
                        dev_err(&client->dev,
                                "unable to request IRQ!\n");
                        goto exit_irq;
                }
+
+               device_set_wakeup_capable(&client->dev, 1);
                set_bit(HAS_ALARM, &ds1307->flags);
                dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
        }
index 713f7bf5afb330c508b5d2482804f97ed0083470..5317bbcbc7a0c7cb3f60e16e6bafac483327a666 100644 (file)
@@ -383,6 +383,8 @@ static int ds1374_probe(struct i2c_client *client,
                        dev_err(&client->dev, "unable to request IRQ\n");
                        goto out_free;
                }
+
+               device_set_wakeup_capable(&client->dev, 1);
        }
 
        ds1374->rtc = rtc_device_register(client->name, &client->dev,
index 539676e25fd87515e85c43a704833a001be61240..4166b84cb514f6ff68d918d4e0ebf3fbd0c97bc5 100644 (file)
@@ -87,7 +87,6 @@ enum ds1511reg {
 struct rtc_plat_data {
        struct rtc_device *rtc;
        void __iomem *ioaddr;           /* virtual base address */
-       unsigned long baseaddr;         /* physical base address */
        int size;                               /* amount of memory mapped */
        int irq;
        unsigned int irqen;
@@ -95,6 +94,7 @@ struct rtc_plat_data {
        int alrm_min;
        int alrm_hour;
        int alrm_mday;
+       spinlock_t lock;
 };
 
 static DEFINE_SPINLOCK(ds1511_lock);
@@ -302,7 +302,7 @@ ds1511_rtc_update_alarm(struct rtc_plat_data *pdata)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&pdata->rtc->irq_lock, flags);
+       spin_lock_irqsave(&pdata->lock, flags);
        rtc_write(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ?
               0x80 : bin2bcd(pdata->alrm_mday) & 0x3f,
               RTC_ALARM_DATE);
@@ -317,7 +317,7 @@ ds1511_rtc_update_alarm(struct rtc_plat_data *pdata)
               RTC_ALARM_SEC);
        rtc_write(rtc_read(RTC_CMD) | (pdata->irqen ? RTC_TIE : 0), RTC_CMD);
        rtc_read(RTC_CMD1);     /* clear interrupts */
-       spin_unlock_irqrestore(&pdata->rtc->irq_lock, flags);
+       spin_unlock_irqrestore(&pdata->lock, flags);
 }
 
  static int
@@ -362,61 +362,63 @@ ds1511_interrupt(int irq, void *dev_id)
 {
        struct platform_device *pdev = dev_id;
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
-       unsigned long events = RTC_IRQF;
+       unsigned long events = 0;
 
+       spin_lock(&pdata->lock);
        /*
         * read and clear interrupt
         */
-       if (!(rtc_read(RTC_CMD1) & DS1511_IRQF)) {
-               return IRQ_NONE;
-       }
-       if (rtc_read(RTC_ALARM_SEC) & 0x80) {
-               events |= RTC_UF;
-       } else {
-               events |= RTC_AF;
-       }
-       rtc_update_irq(pdata->rtc, 1, events);
-       return IRQ_HANDLED;
+       if (rtc_read(RTC_CMD1) & DS1511_IRQF) {
+               events = RTC_IRQF;
+               if (rtc_read(RTC_ALARM_SEC) & 0x80)
+                       events |= RTC_UF;
+               else
+                       events |= RTC_AF;
+               if (likely(pdata->rtc))
+                       rtc_update_irq(pdata->rtc, 1, events);
+       }
+       spin_unlock(&pdata->lock);
+       return events ? IRQ_HANDLED : IRQ_NONE;
 }
 
- static int
-ds1511_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+static int ds1511_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
 
-       if (pdata->irq <= 0) {
-               return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */
-       }
-       switch (cmd) {
-       case RTC_AIE_OFF:
-               pdata->irqen &= ~RTC_AF;
-               ds1511_rtc_update_alarm(pdata);
-               break;
-       case RTC_AIE_ON:
+       if (pdata->irq <= 0)
+               return -EINVAL;
+       if (enabled)
                pdata->irqen |= RTC_AF;
-               ds1511_rtc_update_alarm(pdata);
-               break;
-       case RTC_UIE_OFF:
-               pdata->irqen &= ~RTC_UF;
-               ds1511_rtc_update_alarm(pdata);
-               break;
-       case RTC_UIE_ON:
+       else
+               pdata->irqen &= ~RTC_AF;
+       ds1511_rtc_update_alarm(pdata);
+       return 0;
+}
+
+static int ds1511_rtc_update_irq_enable(struct device *dev,
+       unsigned int enabled)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
+
+       if (pdata->irq <= 0)
+               return -EINVAL;
+       if (enabled)
                pdata->irqen |= RTC_UF;
-               ds1511_rtc_update_alarm(pdata);
-               break;
-       default:
-               return -ENOIOCTLCMD;
-       }
+       else
+               pdata->irqen &= ~RTC_UF;
+       ds1511_rtc_update_alarm(pdata);
        return 0;
 }
 
 static const struct rtc_class_ops ds1511_rtc_ops = {
-       .read_time      = ds1511_rtc_read_time,
-       .set_time       = ds1511_rtc_set_time,
-       .read_alarm     = ds1511_rtc_read_alarm,
-       .set_alarm      = ds1511_rtc_set_alarm,
-       .ioctl          = ds1511_rtc_ioctl,
+       .read_time              = ds1511_rtc_read_time,
+       .set_time               = ds1511_rtc_set_time,
+       .read_alarm             = ds1511_rtc_read_alarm,
+       .set_alarm              = ds1511_rtc_set_alarm,
+       .alarm_irq_enable       = ds1511_rtc_alarm_irq_enable,
+       .update_irq_enable      = ds1511_rtc_update_irq_enable,
 };
 
  static ssize_t
@@ -492,29 +494,23 @@ ds1511_rtc_probe(struct platform_device *pdev)
 {
        struct rtc_device *rtc;
        struct resource *res;
-       struct rtc_plat_data *pdata = NULL;
+       struct rtc_plat_data *pdata;
        int ret = 0;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res) {
                return -ENODEV;
        }
-       pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
+       pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+       if (!pdata)
                return -ENOMEM;
-       }
        pdata->size = res->end - res->start + 1;
-       if (!request_mem_region(res->start, pdata->size, pdev->name)) {
-               ret = -EBUSY;
-               goto out;
-       }
-       pdata->baseaddr = res->start;
-       pdata->size = pdata->size;
-       ds1511_base = ioremap(pdata->baseaddr, pdata->size);
-       if (!ds1511_base) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size,
+                       pdev->name))
+               return -EBUSY;
+       ds1511_base = devm_ioremap(&pdev->dev, res->start, pdata->size);
+       if (!ds1511_base)
+               return -ENOMEM;
        pdata->ioaddr = ds1511_base;
        pdata->irq = platform_get_irq(pdev, 0);
 
@@ -540,13 +536,15 @@ ds1511_rtc_probe(struct platform_device *pdev)
                dev_warn(&pdev->dev, "voltage-low detected.\n");
        }
 
+       spin_lock_init(&pdata->lock);
+       platform_set_drvdata(pdev, pdata);
        /*
         * if the platform has an interrupt in mind for this device,
         * then by all means, set it
         */
        if (pdata->irq > 0) {
                rtc_read(RTC_CMD1);
-               if (request_irq(pdata->irq, ds1511_interrupt,
+               if (devm_request_irq(&pdev->dev, pdata->irq, ds1511_interrupt,
                        IRQF_DISABLED | IRQF_SHARED, pdev->name, pdev) < 0) {
 
                        dev_warn(&pdev->dev, "interrupt not available.\n");
@@ -556,33 +554,13 @@ ds1511_rtc_probe(struct platform_device *pdev)
 
        rtc = rtc_device_register(pdev->name, &pdev->dev, &ds1511_rtc_ops,
                THIS_MODULE);
-       if (IS_ERR(rtc)) {
-               ret = PTR_ERR(rtc);
-               goto out;
-       }
+       if (IS_ERR(rtc))
+               return PTR_ERR(rtc);
        pdata->rtc = rtc;
-       platform_set_drvdata(pdev, pdata);
+
        ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1511_nvram_attr);
-       if (ret) {
-               goto out;
-       }
-       return 0;
- out:
-       if (pdata->rtc) {
+       if (ret)
                rtc_device_unregister(pdata->rtc);
-       }
-       if (pdata->irq > 0) {
-               free_irq(pdata->irq, pdev);
-       }
-       if (ds1511_base) {
-               iounmap(ds1511_base);
-               ds1511_base = NULL;
-       }
-       if (pdata->baseaddr) {
-               release_mem_region(pdata->baseaddr, pdata->size);
-       }
-
-       kfree(pdata);
        return ret;
 }
 
@@ -593,19 +571,13 @@ ds1511_rtc_remove(struct platform_device *pdev)
 
        sysfs_remove_bin_file(&pdev->dev.kobj, &ds1511_nvram_attr);
        rtc_device_unregister(pdata->rtc);
-       pdata->rtc = NULL;
        if (pdata->irq > 0) {
                /*
                 * disable the alarm interrupt
                 */
                rtc_write(rtc_read(RTC_CMD) & ~RTC_TIE, RTC_CMD);
                rtc_read(RTC_CMD1);
-               free_irq(pdata->irq, pdev);
        }
-       iounmap(pdata->ioaddr);
-       ds1511_base = NULL;
-       release_mem_region(pdata->baseaddr, pdata->size);
-       kfree(pdata);
        return 0;
 }
 
index 717288527c6bebd01e094bd1d1f214777d95bebb..ed1ef7c9cc069fc2d2634429827f66c783734aa6 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 
-#define DRV_VERSION "0.2"
+#define DRV_VERSION "0.3"
 
 #define RTC_REG_SIZE           0x2000
 #define RTC_OFFSET             0x1ff0
@@ -61,7 +61,6 @@
 struct rtc_plat_data {
        struct rtc_device *rtc;
        void __iomem *ioaddr;
-       resource_size_t baseaddr;
        unsigned long last_jiffies;
        int irq;
        unsigned int irqen;
@@ -69,6 +68,7 @@ struct rtc_plat_data {
        int alrm_min;
        int alrm_hour;
        int alrm_mday;
+       spinlock_t lock;
 };
 
 static int ds1553_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -139,7 +139,7 @@ static void ds1553_rtc_update_alarm(struct rtc_plat_data *pdata)
        void __iomem *ioaddr = pdata->ioaddr;
        unsigned long flags;
 
-       spin_lock_irqsave(&pdata->rtc->irq_lock, flags);
+       spin_lock_irqsave(&pdata->lock, flags);
        writeb(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ?
               0x80 : bin2bcd(pdata->alrm_mday),
               ioaddr + RTC_DATE_ALARM);
@@ -154,7 +154,7 @@ static void ds1553_rtc_update_alarm(struct rtc_plat_data *pdata)
               ioaddr + RTC_SECONDS_ALARM);
        writeb(pdata->irqen ? RTC_INTS_AE : 0, ioaddr + RTC_INTERRUPTS);
        readb(ioaddr + RTC_FLAGS);      /* clear interrupts */
-       spin_unlock_irqrestore(&pdata->rtc->irq_lock, flags);
+       spin_unlock_irqrestore(&pdata->lock, flags);
 }
 
 static int ds1553_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
@@ -194,64 +194,69 @@ static irqreturn_t ds1553_rtc_interrupt(int irq, void *dev_id)
        struct platform_device *pdev = dev_id;
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
        void __iomem *ioaddr = pdata->ioaddr;
-       unsigned long events = RTC_IRQF;
+       unsigned long events = 0;
 
+       spin_lock(&pdata->lock);
        /* read and clear interrupt */
-       if (!(readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF))
-               return IRQ_NONE;
-       if (readb(ioaddr + RTC_SECONDS_ALARM) & 0x80)
-               events |= RTC_UF;
-       else
-               events |= RTC_AF;
-       rtc_update_irq(pdata->rtc, 1, events);
-       return IRQ_HANDLED;
+       if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF) {
+               events = RTC_IRQF;
+               if (readb(ioaddr + RTC_SECONDS_ALARM) & 0x80)
+                       events |= RTC_UF;
+               else
+                       events |= RTC_AF;
+               if (likely(pdata->rtc))
+                       rtc_update_irq(pdata->rtc, 1, events);
+       }
+       spin_unlock(&pdata->lock);
+       return events ? IRQ_HANDLED : IRQ_NONE;
 }
 
-static int ds1553_rtc_ioctl(struct device *dev, unsigned int cmd,
-                           unsigned long arg)
+static int ds1553_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
 
        if (pdata->irq <= 0)
-               return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */
-       switch (cmd) {
-       case RTC_AIE_OFF:
-               pdata->irqen &= ~RTC_AF;
-               ds1553_rtc_update_alarm(pdata);
-               break;
-       case RTC_AIE_ON:
+               return -EINVAL;
+       if (enabled)
                pdata->irqen |= RTC_AF;
-               ds1553_rtc_update_alarm(pdata);
-               break;
-       case RTC_UIE_OFF:
-               pdata->irqen &= ~RTC_UF;
-               ds1553_rtc_update_alarm(pdata);
-               break;
-       case RTC_UIE_ON:
+       else
+               pdata->irqen &= ~RTC_AF;
+       ds1553_rtc_update_alarm(pdata);
+       return 0;
+}
+
+static int ds1553_rtc_update_irq_enable(struct device *dev,
+       unsigned int enabled)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
+
+       if (pdata->irq <= 0)
+               return -EINVAL;
+       if (enabled)
                pdata->irqen |= RTC_UF;
-               ds1553_rtc_update_alarm(pdata);
-               break;
-       default:
-               return -ENOIOCTLCMD;
-       }
+       else
+               pdata->irqen &= ~RTC_UF;
+       ds1553_rtc_update_alarm(pdata);
        return 0;
 }
 
 static const struct rtc_class_ops ds1553_rtc_ops = {
-       .read_time      = ds1553_rtc_read_time,
-       .set_time       = ds1553_rtc_set_time,
-       .read_alarm     = ds1553_rtc_read_alarm,
-       .set_alarm      = ds1553_rtc_set_alarm,
-       .ioctl          = ds1553_rtc_ioctl,
+       .read_time              = ds1553_rtc_read_time,
+       .set_time               = ds1553_rtc_set_time,
+       .read_alarm             = ds1553_rtc_read_alarm,
+       .set_alarm              = ds1553_rtc_set_alarm,
+       .alarm_irq_enable       = ds1553_rtc_alarm_irq_enable,
+       .update_irq_enable      = ds1553_rtc_update_irq_enable,
 };
 
 static ssize_t ds1553_nvram_read(struct kobject *kobj,
                                 struct bin_attribute *bin_attr,
                                 char *buf, loff_t pos, size_t size)
 {
-       struct platform_device *pdev =
-               to_platform_device(container_of(kobj, struct device, kobj));
+       struct device *dev = container_of(kobj, struct device, kobj);
+       struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
        void __iomem *ioaddr = pdata->ioaddr;
        ssize_t count;
@@ -265,8 +270,8 @@ static ssize_t ds1553_nvram_write(struct kobject *kobj,
                                  struct bin_attribute *bin_attr,
                                  char *buf, loff_t pos, size_t size)
 {
-       struct platform_device *pdev =
-               to_platform_device(container_of(kobj, struct device, kobj));
+       struct device *dev = container_of(kobj, struct device, kobj);
+       struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
        void __iomem *ioaddr = pdata->ioaddr;
        ssize_t count;
@@ -291,26 +296,23 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev)
        struct rtc_device *rtc;
        struct resource *res;
        unsigned int cen, sec;
-       struct rtc_plat_data *pdata = NULL;
-       void __iomem *ioaddr = NULL;
+       struct rtc_plat_data *pdata;
+       void __iomem *ioaddr;
        int ret = 0;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res)
                return -ENODEV;
-       pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+       pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                return -ENOMEM;
-       if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) {
-               ret = -EBUSY;
-               goto out;
-       }
-       pdata->baseaddr = res->start;
-       ioaddr = ioremap(pdata->baseaddr, RTC_REG_SIZE);
-       if (!ioaddr) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!devm_request_mem_region(&pdev->dev, res->start, RTC_REG_SIZE,
+                       pdev->name))
+               return -EBUSY;
+
+       ioaddr = devm_ioremap(&pdev->dev, res->start, RTC_REG_SIZE);
+       if (!ioaddr)
+               return -ENOMEM;
        pdata->ioaddr = ioaddr;
        pdata->irq = platform_get_irq(pdev, 0);
 
@@ -326,9 +328,13 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev)
        if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_BLF)
                dev_warn(&pdev->dev, "voltage-low detected.\n");
 
+       spin_lock_init(&pdata->lock);
+       pdata->last_jiffies = jiffies;
+       platform_set_drvdata(pdev, pdata);
        if (pdata->irq > 0) {
                writeb(0, ioaddr + RTC_INTERRUPTS);
-               if (request_irq(pdata->irq, ds1553_rtc_interrupt,
+               if (devm_request_irq(&pdev->dev, pdata->irq,
+                               ds1553_rtc_interrupt,
                                IRQF_DISABLED, pdev->name, pdev) < 0) {
                        dev_warn(&pdev->dev, "interrupt not available.\n");
                        pdata->irq = 0;
@@ -337,27 +343,13 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev)
 
        rtc = rtc_device_register(pdev->name, &pdev->dev,
                                  &ds1553_rtc_ops, THIS_MODULE);
-       if (IS_ERR(rtc)) {
-               ret = PTR_ERR(rtc);
-               goto out;
-       }
+       if (IS_ERR(rtc))
+               return PTR_ERR(rtc);
        pdata->rtc = rtc;
-       pdata->last_jiffies = jiffies;
-       platform_set_drvdata(pdev, pdata);
+
        ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr);
        if (ret)
-               goto out;
-       return 0;
- out:
-       if (pdata->rtc)
-               rtc_device_unregister(pdata->rtc);
-       if (pdata->irq > 0)
-               free_irq(pdata->irq, pdev);
-       if (ioaddr)
-               iounmap(ioaddr);
-       if (pdata->baseaddr)
-               release_mem_region(pdata->baseaddr, RTC_REG_SIZE);
-       kfree(pdata);
+               rtc_device_unregister(rtc);
        return ret;
 }
 
@@ -367,13 +359,8 @@ static int __devexit ds1553_rtc_remove(struct platform_device *pdev)
 
        sysfs_remove_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr);
        rtc_device_unregister(pdata->rtc);
-       if (pdata->irq > 0) {
+       if (pdata->irq > 0)
                writeb(0, pdata->ioaddr + RTC_INTERRUPTS);
-               free_irq(pdata->irq, pdev);
-       }
-       iounmap(pdata->ioaddr);
-       release_mem_region(pdata->baseaddr, RTC_REG_SIZE);
-       kfree(pdata);
        return 0;
 }
 
index 09249459e9a47b80192a113dd9cff5b845489564..a1273360a44e872c295b1a54eb57f892153ffa2e 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 
-#define DRV_VERSION "0.3"
+#define DRV_VERSION "0.4"
 
 #define RTC_SIZE               8
 
@@ -55,7 +55,6 @@ struct rtc_plat_data {
        void __iomem *ioaddr_rtc;
        size_t size_nvram;
        size_t size;
-       resource_size_t baseaddr;
        unsigned long last_jiffies;
        struct bin_attribute nvram_attr;
 };
@@ -132,8 +131,8 @@ static ssize_t ds1742_nvram_read(struct kobject *kobj,
                                 struct bin_attribute *bin_attr,
                                 char *buf, loff_t pos, size_t size)
 {
-       struct platform_device *pdev =
-               to_platform_device(container_of(kobj, struct device, kobj));
+       struct device *dev = container_of(kobj, struct device, kobj);
+       struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
        void __iomem *ioaddr = pdata->ioaddr_nvram;
        ssize_t count;
@@ -147,8 +146,8 @@ static ssize_t ds1742_nvram_write(struct kobject *kobj,
                                  struct bin_attribute *bin_attr,
                                  char *buf, loff_t pos, size_t size)
 {
-       struct platform_device *pdev =
-               to_platform_device(container_of(kobj, struct device, kobj));
+       struct device *dev = container_of(kobj, struct device, kobj);
+       struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
        void __iomem *ioaddr = pdata->ioaddr_nvram;
        ssize_t count;
@@ -163,27 +162,24 @@ static int __devinit ds1742_rtc_probe(struct platform_device *pdev)
        struct rtc_device *rtc;
        struct resource *res;
        unsigned int cen, sec;
-       struct rtc_plat_data *pdata = NULL;
-       void __iomem *ioaddr = NULL;
+       struct rtc_plat_data *pdata;
+       void __iomem *ioaddr;
        int ret = 0;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res)
                return -ENODEV;
-       pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+       pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                return -ENOMEM;
        pdata->size = res->end - res->start + 1;
-       if (!request_mem_region(res->start, pdata->size, pdev->name)) {
-               ret = -EBUSY;
-               goto out;
-       }
-       pdata->baseaddr = res->start;
-       ioaddr = ioremap(pdata->baseaddr, pdata->size);
-       if (!ioaddr) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size,
+               pdev->name))
+               return -EBUSY;
+       ioaddr = devm_ioremap(&pdev->dev, res->start, pdata->size);
+       if (!ioaddr)
+               return -ENOMEM;
+
        pdata->ioaddr_nvram = ioaddr;
        pdata->size_nvram = pdata->size - RTC_SIZE;
        pdata->ioaddr_rtc = ioaddr + pdata->size_nvram;
@@ -207,31 +203,19 @@ static int __devinit ds1742_rtc_probe(struct platform_device *pdev)
        if (!(readb(ioaddr + RTC_DAY) & RTC_BATT_FLAG))
                dev_warn(&pdev->dev, "voltage-low detected.\n");
 
+       pdata->last_jiffies = jiffies;
+       platform_set_drvdata(pdev, pdata);
        rtc = rtc_device_register(pdev->name, &pdev->dev,
                                  &ds1742_rtc_ops, THIS_MODULE);
-       if (IS_ERR(rtc)) {
-               ret = PTR_ERR(rtc);
-               goto out;
-       }
+       if (IS_ERR(rtc))
+               return PTR_ERR(rtc);
        pdata->rtc = rtc;
-       pdata->last_jiffies = jiffies;
-       platform_set_drvdata(pdev, pdata);
 
        ret = sysfs_create_bin_file(&pdev->dev.kobj, &pdata->nvram_attr);
        if (ret) {
                dev_err(&pdev->dev, "creating nvram file in sysfs failed\n");
-               goto out;
+               rtc_device_unregister(rtc);
        }
-
-       return 0;
- out:
-       if (pdata->rtc)
-               rtc_device_unregister(pdata->rtc);
-       if (pdata->ioaddr_nvram)
-               iounmap(pdata->ioaddr_nvram);
-       if (pdata->baseaddr)
-               release_mem_region(pdata->baseaddr, pdata->size);
-       kfree(pdata);
        return ret;
 }
 
@@ -241,9 +225,6 @@ static int __devexit ds1742_rtc_remove(struct platform_device *pdev)
 
        sysfs_remove_bin_file(&pdev->dev.kobj, &pdata->nvram_attr);
        rtc_device_unregister(pdata->rtc);
-       iounmap(pdata->ioaddr_nvram);
-       release_mem_region(pdata->baseaddr, pdata->size);
-       kfree(pdata);
        return 0;
 }
 
index 0b21975599400c809098b905c26a5d6dd802002f..8cb5b8959e5b2c2befd63f59323e89f7657324ab 100644 (file)
@@ -142,7 +142,6 @@ static const struct rtc_class_ops m48t35_ops = {
 
 static int __devinit m48t35_probe(struct platform_device *pdev)
 {
-       struct rtc_device *rtc;
        struct resource *res;
        struct m48t35_priv *priv;
        int ret = 0;
@@ -171,20 +170,21 @@ static int __devinit m48t35_probe(struct platform_device *pdev)
                ret = -ENOMEM;
                goto out;
        }
+
        spin_lock_init(&priv->lock);
-       rtc = rtc_device_register("m48t35", &pdev->dev,
+
+       platform_set_drvdata(pdev, priv);
+
+       priv->rtc = rtc_device_register("m48t35", &pdev->dev,
                                  &m48t35_ops, THIS_MODULE);
-       if (IS_ERR(rtc)) {
-               ret = PTR_ERR(rtc);
+       if (IS_ERR(priv->rtc)) {
+               ret = PTR_ERR(priv->rtc);
                goto out;
        }
-       priv->rtc = rtc;
-       platform_set_drvdata(pdev, priv);
+
        return 0;
 
 out:
-       if (priv->rtc)
-               rtc_device_unregister(priv->rtc);
        if (priv->reg)
                iounmap(priv->reg);
        if (priv->baseaddr)
index 33921a6b17076770042f41ddd3c887a470bdb87f..ede43b8468596e3ac0037d9b25e4b251d1466036 100644 (file)
@@ -481,6 +481,9 @@ static int __devinit m48t59_rtc_probe(struct platform_device *pdev)
                goto out;
        }
 
+       spin_lock_init(&m48t59->lock);
+       platform_set_drvdata(pdev, m48t59);
+
        m48t59->rtc = rtc_device_register(name, &pdev->dev, ops, THIS_MODULE);
        if (IS_ERR(m48t59->rtc)) {
                ret = PTR_ERR(m48t59->rtc);
@@ -490,16 +493,14 @@ static int __devinit m48t59_rtc_probe(struct platform_device *pdev)
        m48t59_nvram_attr.size = pdata->offset;
 
        ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
-       if (ret)
+       if (ret) {
+               rtc_device_unregister(m48t59->rtc);
                goto out;
+       }
 
-       spin_lock_init(&m48t59->lock);
-       platform_set_drvdata(pdev, m48t59);
        return 0;
 
 out:
-       if (!IS_ERR(m48t59->rtc))
-               rtc_device_unregister(m48t59->rtc);
        if (m48t59->irq != NO_IRQ)
                free_irq(m48t59->irq, &pdev->dev);
        if (m48t59->ioaddr)
diff --git a/drivers/rtc/rtc-mc13783.c b/drivers/rtc/rtc-mc13783.c
new file mode 100644 (file)
index 0000000..850f983
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+ * Real Time Clock driver for Freescale MC13783 PMIC
+ *
+ * (C) 2009 Sascha Hauer, Pengutronix
+ * (C) 2009 Uwe Kleine-Koenig, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/mfd/mc13783.h>
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/rtc.h>
+
+#define DRIVER_NAME "mc13783-rtc"
+
+#define MC13783_RTCTOD 20
+#define MC13783_RTCTODA        21
+#define MC13783_RTCDAY 22
+#define MC13783_RTCDAYA        23
+
+struct mc13783_rtc {
+       struct rtc_device *rtc;
+       struct mc13783 *mc13783;
+       int valid;
+};
+
+static int mc13783_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+       struct mc13783_rtc *priv = dev_get_drvdata(dev);
+       unsigned int seconds, days1, days2;
+       unsigned long s1970;
+       int ret;
+
+       mc13783_lock(priv->mc13783);
+
+       if (!priv->valid) {
+               ret = -ENODATA;
+               goto out;
+       }
+
+       ret = mc13783_reg_read(priv->mc13783, MC13783_RTCDAY, &days1);
+       if (unlikely(ret))
+               goto out;
+
+       ret = mc13783_reg_read(priv->mc13783, MC13783_RTCTOD, &seconds);
+       if (unlikely(ret))
+               goto out;
+
+       ret = mc13783_reg_read(priv->mc13783, MC13783_RTCDAY, &days2);
+out:
+       mc13783_unlock(priv->mc13783);
+
+       if (ret)
+               return ret;
+
+       if (days2 == days1 + 1) {
+               if (seconds >= 86400 / 2)
+                       days2 = days1;
+               else
+                       days1 = days2;
+       }
+
+       if (days1 != days2)
+               return -EIO;
+
+       s1970 = days1 * 86400 + seconds;
+
+       rtc_time_to_tm(s1970, tm);
+
+       return rtc_valid_tm(tm);
+}
+
+static int mc13783_rtc_set_mmss(struct device *dev, unsigned long secs)
+{
+       struct mc13783_rtc *priv = dev_get_drvdata(dev);
+       unsigned int seconds, days;
+       int ret;
+
+       seconds = secs % 86400;
+       days = secs / 86400;
+
+       mc13783_lock(priv->mc13783);
+
+       /*
+        * first write seconds=0 to prevent a day switch between writing days
+        * and seconds below
+        */
+       ret = mc13783_reg_write(priv->mc13783, MC13783_RTCTOD, 0);
+       if (unlikely(ret))
+               goto out;
+
+       ret = mc13783_reg_write(priv->mc13783, MC13783_RTCDAY, days);
+       if (unlikely(ret))
+               goto out;
+
+       ret = mc13783_reg_write(priv->mc13783, MC13783_RTCTOD, seconds);
+       if (unlikely(ret))
+               goto out;
+
+       ret = mc13783_ackirq(priv->mc13783, MC13783_IRQ_RTCRST);
+       if (unlikely(ret))
+               goto out;
+
+       ret = mc13783_unmask(priv->mc13783, MC13783_IRQ_RTCRST);
+out:
+       priv->valid = !ret;
+
+       mc13783_unlock(priv->mc13783);
+
+       return ret;
+}
+
+static irqreturn_t mc13783_rtc_update_handler(int irq, void *dev)
+{
+       struct mc13783_rtc *priv = dev;
+       struct mc13783 *mc13783 = priv->mc13783;
+
+       dev_dbg(&priv->rtc->dev, "1HZ\n");
+
+       rtc_update_irq(priv->rtc, 1, RTC_IRQF | RTC_UF);
+
+       mc13783_ackirq(mc13783, irq);
+
+       return IRQ_HANDLED;
+}
+
+static int mc13783_rtc_update_irq_enable(struct device *dev,
+               unsigned int enabled)
+{
+       struct mc13783_rtc *priv = dev_get_drvdata(dev);
+       int ret = -ENODATA;
+
+       mc13783_lock(priv->mc13783);
+       if (!priv->valid)
+               goto out;
+
+       ret = (enabled ? mc13783_unmask : mc13783_mask)(priv->mc13783,
+                       MC13783_IRQ_1HZ);
+out:
+       mc13783_unlock(priv->mc13783);
+
+       return ret;
+}
+
+static const struct rtc_class_ops mc13783_rtc_ops = {
+       .read_time = mc13783_rtc_read_time,
+       .set_mmss = mc13783_rtc_set_mmss,
+       .update_irq_enable = mc13783_rtc_update_irq_enable,
+};
+
+static irqreturn_t mc13783_rtc_reset_handler(int irq, void *dev)
+{
+       struct mc13783_rtc *priv = dev;
+       struct mc13783 *mc13783 = priv->mc13783;
+
+       dev_dbg(&priv->rtc->dev, "RTCRST\n");
+       priv->valid = 0;
+
+       mc13783_mask(mc13783, irq);
+
+       return IRQ_HANDLED;
+}
+
+static int __devinit mc13783_rtc_probe(struct platform_device *pdev)
+{
+       int ret;
+       struct mc13783_rtc *priv;
+
+       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->mc13783 = dev_get_drvdata(pdev->dev.parent);
+       platform_set_drvdata(pdev, priv);
+
+       priv->valid = 1;
+
+       mc13783_lock(priv->mc13783);
+
+       ret = mc13783_irq_request(priv->mc13783, MC13783_IRQ_RTCRST,
+                       mc13783_rtc_reset_handler, DRIVER_NAME, priv);
+       if (ret)
+               goto err_reset_irq_request;
+
+       ret = mc13783_irq_request_nounmask(priv->mc13783, MC13783_IRQ_1HZ,
+                       mc13783_rtc_update_handler, DRIVER_NAME, priv);
+       if (ret)
+               goto err_update_irq_request;
+
+       mc13783_unlock(priv->mc13783);
+
+       priv->rtc = rtc_device_register(pdev->name,
+                       &pdev->dev, &mc13783_rtc_ops, THIS_MODULE);
+
+       if (IS_ERR(priv->rtc)) {
+               ret = PTR_ERR(priv->rtc);
+
+               mc13783_lock(priv->mc13783);
+
+               mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
+err_update_irq_request:
+
+               mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv);
+err_reset_irq_request:
+
+               mc13783_unlock(priv->mc13783);
+
+               platform_set_drvdata(pdev, NULL);
+               kfree(priv);
+       }
+
+       return ret;
+}
+
+static int __devexit mc13783_rtc_remove(struct platform_device *pdev)
+{
+       struct mc13783_rtc *priv = platform_get_drvdata(pdev);
+
+       rtc_device_unregister(priv->rtc);
+
+       mc13783_lock(priv->mc13783);
+
+       mc13783_irq_free(priv->mc13783, MC13783_IRQ_1HZ, priv);
+       mc13783_irq_free(priv->mc13783, MC13783_IRQ_RTCRST, priv);
+
+       mc13783_unlock(priv->mc13783);
+
+       platform_set_drvdata(pdev, NULL);
+
+       kfree(priv);
+
+       return 0;
+}
+
+static struct platform_driver mc13783_rtc_driver = {
+       .remove = __devexit_p(mc13783_rtc_remove),
+       .driver = {
+               .name = DRIVER_NAME,
+               .owner = THIS_MODULE,
+       },
+};
+
+static int __init mc13783_rtc_init(void)
+{
+       return platform_driver_probe(&mc13783_rtc_driver, &mc13783_rtc_probe);
+}
+module_init(mc13783_rtc_init);
+
+static void __exit mc13783_rtc_exit(void)
+{
+       platform_driver_unregister(&mc13783_rtc_driver);
+}
+module_exit(mc13783_rtc_exit);
+
+MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
+MODULE_DESCRIPTION("RTC driver for Freescale MC13783 PMIC");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:" DRIVER_NAME);
index e0263d2005eeba6beb78c73809bae192f9c40bfb..dc052ce6e63a8af6525cd067d0748927298c0c41 100644 (file)
 #define RTC_MONTH_OFFS         8
 #define RTC_YEAR_OFFS          16
 
+#define RTC_ALARM_TIME_REG_OFFS        8
+#define RTC_ALARM_DATE_REG_OFFS        0xc
+#define RTC_ALARM_VALID                (1 << 7)
+
+#define RTC_ALARM_INTERRUPT_MASK_REG_OFFS      0x10
+#define RTC_ALARM_INTERRUPT_CASUE_REG_OFFS     0x14
 
 struct rtc_plat_data {
        struct rtc_device *rtc;
        void __iomem *ioaddr;
+       int             irq;
 };
 
 static int mv_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -84,12 +91,134 @@ static int mv_rtc_read_time(struct device *dev, struct rtc_time *tm)
        return rtc_valid_tm(tm);
 }
 
+static int mv_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
+{
+       struct rtc_plat_data *pdata = dev_get_drvdata(dev);
+       void __iomem *ioaddr = pdata->ioaddr;
+       u32     rtc_time, rtc_date;
+       unsigned int year, month, day, hour, minute, second, wday;
+
+       rtc_time = readl(ioaddr + RTC_ALARM_TIME_REG_OFFS);
+       rtc_date = readl(ioaddr + RTC_ALARM_DATE_REG_OFFS);
+
+       second = rtc_time & 0x7f;
+       minute = (rtc_time >> RTC_MINUTES_OFFS) & 0x7f;
+       hour = (rtc_time >> RTC_HOURS_OFFS) & 0x3f; /* assume 24 hours mode */
+       wday = (rtc_time >> RTC_WDAY_OFFS) & 0x7;
+
+       day = rtc_date & 0x3f;
+       month = (rtc_date >> RTC_MONTH_OFFS) & 0x3f;
+       year = (rtc_date >> RTC_YEAR_OFFS) & 0xff;
+
+       alm->time.tm_sec = bcd2bin(second);
+       alm->time.tm_min = bcd2bin(minute);
+       alm->time.tm_hour = bcd2bin(hour);
+       alm->time.tm_mday = bcd2bin(day);
+       alm->time.tm_wday = bcd2bin(wday);
+       alm->time.tm_mon = bcd2bin(month) - 1;
+       /* hw counts from year 2000, but tm_year is relative to 1900 */
+       alm->time.tm_year = bcd2bin(year) + 100;
+
+       if (rtc_valid_tm(&alm->time) < 0) {
+               dev_err(dev, "retrieved alarm date/time is not valid.\n");
+               rtc_time_to_tm(0, &alm->time);
+       }
+
+       alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
+       return 0;
+}
+
+static int mv_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
+{
+       struct rtc_plat_data *pdata = dev_get_drvdata(dev);
+       void __iomem *ioaddr = pdata->ioaddr;
+       u32 rtc_reg = 0;
+
+       if (alm->time.tm_sec >= 0)
+               rtc_reg |= (RTC_ALARM_VALID | bin2bcd(alm->time.tm_sec))
+                       << RTC_SECONDS_OFFS;
+       if (alm->time.tm_min >= 0)
+               rtc_reg |= (RTC_ALARM_VALID | bin2bcd(alm->time.tm_min))
+                       << RTC_MINUTES_OFFS;
+       if (alm->time.tm_hour >= 0)
+               rtc_reg |= (RTC_ALARM_VALID | bin2bcd(alm->time.tm_hour))
+                       << RTC_HOURS_OFFS;
+
+       writel(rtc_reg, ioaddr + RTC_ALARM_TIME_REG_OFFS);
+
+       if (alm->time.tm_mday >= 0)
+               rtc_reg = (RTC_ALARM_VALID | bin2bcd(alm->time.tm_mday))
+                       << RTC_MDAY_OFFS;
+       else
+               rtc_reg = 0;
+
+       if (alm->time.tm_mon >= 0)
+               rtc_reg |= (RTC_ALARM_VALID | bin2bcd(alm->time.tm_mon + 1))
+                       << RTC_MONTH_OFFS;
+
+       if (alm->time.tm_year >= 0)
+               rtc_reg |= (RTC_ALARM_VALID | bin2bcd(alm->time.tm_year % 100))
+                       << RTC_YEAR_OFFS;
+
+       writel(rtc_reg, ioaddr + RTC_ALARM_DATE_REG_OFFS);
+       writel(0, ioaddr + RTC_ALARM_INTERRUPT_CASUE_REG_OFFS);
+       writel(alm->enabled ? 1 : 0,
+              ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
+
+       return 0;
+}
+
+static int mv_rtc_ioctl(struct device *dev, unsigned int cmd,
+                       unsigned long arg)
+{
+       struct platform_device *pdev = to_platform_device(dev);
+       struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
+       void __iomem *ioaddr = pdata->ioaddr;
+
+       if (pdata->irq < 0)
+               return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */
+       switch (cmd) {
+       case RTC_AIE_OFF:
+               writel(0, ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
+               break;
+       case RTC_AIE_ON:
+               writel(1, ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
+               break;
+       default:
+               return -ENOIOCTLCMD;
+       }
+       return 0;
+}
+
+static irqreturn_t mv_rtc_interrupt(int irq, void *data)
+{
+       struct rtc_plat_data *pdata = data;
+       void __iomem *ioaddr = pdata->ioaddr;
+
+       /* alarm irq? */
+       if (!readl(ioaddr + RTC_ALARM_INTERRUPT_CASUE_REG_OFFS))
+               return IRQ_NONE;
+
+       /* clear interrupt */
+       writel(0, ioaddr + RTC_ALARM_INTERRUPT_CASUE_REG_OFFS);
+       rtc_update_irq(pdata->rtc, 1, RTC_IRQF | RTC_AF);
+       return IRQ_HANDLED;
+}
+
 static const struct rtc_class_ops mv_rtc_ops = {
        .read_time      = mv_rtc_read_time,
        .set_time       = mv_rtc_set_time,
 };
 
-static int __init mv_rtc_probe(struct platform_device *pdev)
+static const struct rtc_class_ops mv_rtc_alarm_ops = {
+       .read_time      = mv_rtc_read_time,
+       .set_time       = mv_rtc_set_time,
+       .read_alarm     = mv_rtc_read_alarm,
+       .set_alarm      = mv_rtc_set_alarm,
+       .ioctl          = mv_rtc_ioctl,
+};
+
+static int __devinit mv_rtc_probe(struct platform_device *pdev)
 {
        struct resource *res;
        struct rtc_plat_data *pdata;
@@ -130,12 +259,31 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
                }
        }
 
+       pdata->irq = platform_get_irq(pdev, 0);
+
        platform_set_drvdata(pdev, pdata);
-       pdata->rtc = rtc_device_register(pdev->name, &pdev->dev,
-                                        &mv_rtc_ops, THIS_MODULE);
+
+       if (pdata->irq >= 0) {
+               device_init_wakeup(&pdev->dev, 1);
+               pdata->rtc = rtc_device_register(pdev->name, &pdev->dev,
+                                                &mv_rtc_alarm_ops,
+                                                THIS_MODULE);
+       } else
+               pdata->rtc = rtc_device_register(pdev->name, &pdev->dev,
+                                                &mv_rtc_ops, THIS_MODULE);
        if (IS_ERR(pdata->rtc))
                return PTR_ERR(pdata->rtc);
 
+       if (pdata->irq >= 0) {
+               writel(0, pdata->ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS);
+               if (devm_request_irq(&pdev->dev, pdata->irq, mv_rtc_interrupt,
+                                    IRQF_DISABLED | IRQF_SHARED,
+                                    pdev->name, pdata) < 0) {
+                       dev_warn(&pdev->dev, "interrupt not available.\n");
+                       pdata->irq = -1;
+               }
+       }
+
        return 0;
 }
 
@@ -143,6 +291,9 @@ static int __exit mv_rtc_remove(struct platform_device *pdev)
 {
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
 
+       if (pdata->irq >= 0)
+               device_init_wakeup(&pdev->dev, 0);
+
        rtc_device_unregister(pdata->rtc);
        return 0;
 }
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c
new file mode 100644 (file)
index 0000000..bf59c9c
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * Copyright (c) 2008-2009 Nuvoton technology corporation.
+ *
+ * Wan ZongShun <mcuos.com@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation;version 2 of the License.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/bcd.h>
+
+/* RTC Control Registers */
+#define REG_RTC_INIR           0x00
+#define REG_RTC_AER            0x04
+#define REG_RTC_FCR            0x08
+#define REG_RTC_TLR            0x0C
+#define REG_RTC_CLR            0x10
+#define REG_RTC_TSSR           0x14
+#define REG_RTC_DWR            0x18
+#define REG_RTC_TAR            0x1C
+#define REG_RTC_CAR            0x20
+#define REG_RTC_LIR            0x24
+#define REG_RTC_RIER           0x28
+#define REG_RTC_RIIR           0x2C
+#define REG_RTC_TTR            0x30
+
+#define RTCSET                 0x01
+#define AERRWENB               0x10000
+#define INIRRESET              0xa5eb1357
+#define AERPOWERON             0xA965
+#define AERPOWEROFF            0x0000
+#define LEAPYEAR               0x0001
+#define TICKENB                        0x80
+#define TICKINTENB             0x0002
+#define ALARMINTENB            0x0001
+#define MODE24                 0x0001
+
+struct nuc900_rtc {
+       int                     irq_num;
+       void __iomem            *rtc_reg;
+       struct rtc_device       *rtcdev;
+};
+
+struct nuc900_bcd_time {
+       int bcd_sec;
+       int bcd_min;
+       int bcd_hour;
+       int bcd_mday;
+       int bcd_mon;
+       int bcd_year;
+};
+
+static irqreturn_t nuc900_rtc_interrupt(int irq, void *_rtc)
+{
+       struct nuc900_rtc *rtc = _rtc;
+       unsigned long events = 0, rtc_irq;
+
+       rtc_irq = __raw_readl(rtc->rtc_reg + REG_RTC_RIIR);
+
+       if (rtc_irq & ALARMINTENB) {
+               rtc_irq &= ~ALARMINTENB;
+               __raw_writel(rtc_irq, rtc->rtc_reg + REG_RTC_RIIR);
+               events |= RTC_AF | RTC_IRQF;
+       }
+
+       if (rtc_irq & TICKINTENB) {
+               rtc_irq &= ~TICKINTENB;
+               __raw_writel(rtc_irq, rtc->rtc_reg + REG_RTC_RIIR);
+               events |= RTC_UF | RTC_IRQF;
+       }
+
+       rtc_update_irq(rtc->rtcdev, 1, events);
+
+       return IRQ_HANDLED;
+}
+
+static int *check_rtc_access_enable(struct nuc900_rtc *nuc900_rtc)
+{
+       unsigned int i;
+       __raw_writel(INIRRESET, nuc900_rtc->rtc_reg + REG_RTC_INIR);
+
+       mdelay(10);
+
+       __raw_writel(AERPOWERON, nuc900_rtc->rtc_reg + REG_RTC_AER);
+
+       for (i = 0; i < 1000; i++) {
+               if (__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB)
+                       return 0;
+       }
+
+       if ((__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_AER) & AERRWENB) == 0x0)
+               return ERR_PTR(-ENODEV);
+
+       return ERR_PTR(-EPERM);
+}
+
+static void nuc900_rtc_bcd2bin(unsigned int timereg,
+                               unsigned int calreg, struct rtc_time *tm)
+{
+       tm->tm_mday     = bcd2bin(calreg >> 0);
+       tm->tm_mon      = bcd2bin(calreg >> 8);
+       tm->tm_year     = bcd2bin(calreg >> 16) + 100;
+
+       tm->tm_sec      = bcd2bin(timereg >> 0);
+       tm->tm_min      = bcd2bin(timereg >> 8);
+       tm->tm_hour     = bcd2bin(timereg >> 16);
+
+       rtc_valid_tm(tm);
+}
+
+static void nuc900_rtc_bin2bcd(struct rtc_time *settm,
+                                               struct nuc900_bcd_time *gettm)
+{
+       gettm->bcd_mday = bin2bcd(settm->tm_mday) << 0;
+       gettm->bcd_mon  = bin2bcd(settm->tm_mon) << 8;
+       gettm->bcd_year = bin2bcd(settm->tm_year - 100) << 16;
+
+       gettm->bcd_sec  = bin2bcd(settm->tm_sec) << 0;
+       gettm->bcd_min  = bin2bcd(settm->tm_min) << 8;
+       gettm->bcd_hour = bin2bcd(settm->tm_hour) << 16;
+}
+
+static int nuc900_update_irq_enable(struct device *dev, unsigned int enabled)
+{
+       struct nuc900_rtc *rtc = dev_get_drvdata(dev);
+
+       if (enabled)
+               __raw_writel(__raw_readl(rtc->rtc_reg + REG_RTC_RIER)|
+                               (TICKINTENB), rtc->rtc_reg + REG_RTC_RIER);
+       else
+               __raw_writel(__raw_readl(rtc->rtc_reg + REG_RTC_RIER)&
+                               (~TICKINTENB), rtc->rtc_reg + REG_RTC_RIER);
+
+       return 0;
+}
+
+static int nuc900_alarm_irq_enable(struct device *dev, unsigned int enabled)
+{
+       struct nuc900_rtc *rtc = dev_get_drvdata(dev);
+
+       if (enabled)
+               __raw_writel(__raw_readl(rtc->rtc_reg + REG_RTC_RIER)|
+                               (ALARMINTENB), rtc->rtc_reg + REG_RTC_RIER);
+       else
+               __raw_writel(__raw_readl(rtc->rtc_reg + REG_RTC_RIER)&
+                               (~ALARMINTENB), rtc->rtc_reg + REG_RTC_RIER);
+
+       return 0;
+}
+
+static int nuc900_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+       struct nuc900_rtc *rtc = dev_get_drvdata(dev);
+       unsigned int timeval, clrval;
+
+       timeval = __raw_readl(rtc->rtc_reg + REG_RTC_TLR);
+       clrval  = __raw_readl(rtc->rtc_reg + REG_RTC_CLR);
+
+       nuc900_rtc_bcd2bin(timeval, clrval, tm);
+
+       return 0;
+}
+
+static int nuc900_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+       struct nuc900_rtc *rtc = dev_get_drvdata(dev);
+       struct nuc900_bcd_time gettm;
+       unsigned long val;
+       int *err;
+
+       nuc900_rtc_bin2bcd(tm, &gettm);
+
+       err = check_rtc_access_enable(rtc);
+       if (IS_ERR(err))
+               return PTR_ERR(err);
+
+       val = gettm.bcd_mday | gettm.bcd_mon | gettm.bcd_year;
+       __raw_writel(val, rtc->rtc_reg + REG_RTC_CLR);
+
+       val = gettm.bcd_sec | gettm.bcd_min | gettm.bcd_hour;
+       __raw_writel(val, rtc->rtc_reg + REG_RTC_TLR);
+
+       return 0;
+}
+
+static int nuc900_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+       struct nuc900_rtc *rtc = dev_get_drvdata(dev);
+       unsigned int timeval, carval;
+
+       timeval = __raw_readl(rtc->rtc_reg + REG_RTC_TAR);
+       carval  = __raw_readl(rtc->rtc_reg + REG_RTC_CAR);
+
+       nuc900_rtc_bcd2bin(timeval, carval, &alrm->time);
+
+       return 0;
+}
+
+static int nuc900_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+       struct nuc900_rtc *rtc = dev_get_drvdata(dev);
+       struct nuc900_bcd_time tm;
+       unsigned long val;
+       int *err;
+
+       nuc900_rtc_bin2bcd(&alrm->time, &tm);
+
+       err = check_rtc_access_enable(rtc);
+       if (IS_ERR(err))
+               return PTR_ERR(err);
+
+       val = tm.bcd_mday | tm.bcd_mon | tm.bcd_year;
+       __raw_writel(val, rtc->rtc_reg + REG_RTC_CAR);
+
+       val = tm.bcd_sec | tm.bcd_min | tm.bcd_hour;
+       __raw_writel(val, rtc->rtc_reg + REG_RTC_TAR);
+
+       return 0;
+}
+
+static struct rtc_class_ops nuc900_rtc_ops = {
+       .read_time = nuc900_rtc_read_time,
+       .set_time = nuc900_rtc_set_time,
+       .read_alarm = nuc900_rtc_read_alarm,
+       .set_alarm = nuc900_rtc_set_alarm,
+       .alarm_irq_enable = nuc900_alarm_irq_enable,
+       .update_irq_enable = nuc900_update_irq_enable,
+};
+
+static int __devinit nuc900_rtc_probe(struct platform_device *pdev)
+{
+       struct resource *res;
+       struct nuc900_rtc *nuc900_rtc;
+       int err = 0;
+
+       nuc900_rtc = kzalloc(sizeof(struct nuc900_rtc), GFP_KERNEL);
+       if (!nuc900_rtc) {
+               dev_err(&pdev->dev, "kzalloc nuc900_rtc failed\n");
+               return -ENOMEM;
+       }
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res) {
+               dev_err(&pdev->dev, "platform_get_resource failed\n");
+               err = -ENXIO;
+               goto fail1;
+       }
+
+       if (!request_mem_region(res->start, resource_size(res),
+                               pdev->name)) {
+               dev_err(&pdev->dev, "request_mem_region failed\n");
+               err = -EBUSY;
+               goto fail1;
+       }
+
+       nuc900_rtc->rtc_reg = ioremap(res->start, resource_size(res));
+       if (!nuc900_rtc->rtc_reg) {
+               dev_err(&pdev->dev, "ioremap rtc_reg failed\n");
+               err = -ENOMEM;
+               goto fail2;
+       }
+
+       nuc900_rtc->irq_num = platform_get_irq(pdev, 0);
+       if (request_irq(nuc900_rtc->irq_num, nuc900_rtc_interrupt,
+                               IRQF_DISABLED, "nuc900rtc", nuc900_rtc)) {
+               dev_err(&pdev->dev, "NUC900 RTC request irq failed\n");
+               err = -EBUSY;
+               goto fail3;
+       }
+
+       nuc900_rtc->rtcdev = rtc_device_register(pdev->name, &pdev->dev,
+                                               &nuc900_rtc_ops, THIS_MODULE);
+       if (IS_ERR(nuc900_rtc->rtcdev)) {
+               dev_err(&pdev->dev, "rtc device register faild\n");
+               err = PTR_ERR(nuc900_rtc->rtcdev);
+               goto fail4;
+       }
+
+       platform_set_drvdata(pdev, nuc900_rtc);
+       __raw_writel(__raw_readl(nuc900_rtc->rtc_reg + REG_RTC_TSSR) | MODE24,
+                                       nuc900_rtc->rtc_reg + REG_RTC_TSSR);
+
+       return 0;
+
+fail4: free_irq(nuc900_rtc->irq_num, nuc900_rtc);
+fail3: iounmap(nuc900_rtc->rtc_reg);
+fail2: release_mem_region(res->start, resource_size(res));
+fail1: kfree(nuc900_rtc);
+       return err;
+}
+
+static int __devexit nuc900_rtc_remove(struct platform_device *pdev)
+{
+       struct nuc900_rtc *nuc900_rtc = platform_get_drvdata(pdev);
+       struct resource *res;
+
+       rtc_device_unregister(nuc900_rtc->rtcdev);
+       free_irq(nuc900_rtc->irq_num, nuc900_rtc);
+       iounmap(nuc900_rtc->rtc_reg);
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       release_mem_region(res->start, resource_size(res));
+
+       kfree(nuc900_rtc);
+
+       platform_set_drvdata(pdev, NULL);
+
+       return 0;
+}
+
+static struct platform_driver nuc900_rtc_driver = {
+       .remove         = __devexit_p(nuc900_rtc_remove),
+       .driver         = {
+               .name   = "nuc900-rtc",
+               .owner  = THIS_MODULE,
+       },
+};
+
+static int __init nuc900_rtc_init(void)
+{
+       return platform_driver_probe(&nuc900_rtc_driver, nuc900_rtc_probe);
+}
+
+static void __exit nuc900_rtc_exit(void)
+{
+       platform_driver_unregister(&nuc900_rtc_driver);
+}
+
+module_init(nuc900_rtc_init);
+module_exit(nuc900_rtc_exit);
+
+MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
+MODULE_DESCRIPTION("nuc910/nuc920 RTC driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:nuc900-rtc");
index 0587d53987fe7db838e77ebac4555b1ba11bb76f..64d9727b722970a080155e0527676e9f0a1defcf 100644 (file)
 #define OMAP_RTC_INTERRUPTS_IT_ALARM    (1<<3)
 #define OMAP_RTC_INTERRUPTS_IT_TIMER    (1<<2)
 
+static void __iomem    *rtc_base;
 
-#define rtc_read(addr)         omap_readb(OMAP_RTC_BASE + (addr))
-#define rtc_write(val, addr)   omap_writeb(val, OMAP_RTC_BASE + (addr))
+#define rtc_read(addr)         __raw_readb(rtc_base + (addr))
+#define rtc_write(val, addr)   __raw_writeb(val, rtc_base + (addr))
 
 
 /* we rely on the rtc framework to handle locking (rtc->ops_lock),
@@ -330,32 +331,31 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
                return -ENOENT;
        }
 
-       /* NOTE:  using static mapping for RTC registers */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (res && res->start != OMAP_RTC_BASE) {
-               pr_debug("%s: RTC registers at %08x, expected %08x\n",
-                       pdev->name, (unsigned) res->start, OMAP_RTC_BASE);
+       if (!res) {
+               pr_debug("%s: RTC resource data missing\n", pdev->name);
                return -ENOENT;
        }
 
-       if (res)
-               mem = request_mem_region(res->start,
-                               res->end - res->start + 1,
-                               pdev->name);
-       else
-               mem = NULL;
+       mem = request_mem_region(res->start, resource_size(res), pdev->name);
        if (!mem) {
                pr_debug("%s: RTC registers at %08x are not free\n",
-                       pdev->name, OMAP_RTC_BASE);
+                       pdev->name, res->start);
                return -EBUSY;
        }
 
+       rtc_base = ioremap(res->start, resource_size(res));
+       if (!rtc_base) {
+               pr_debug("%s: RTC registers can't be mapped\n", pdev->name);
+               goto fail;
+       }
+
        rtc = rtc_device_register(pdev->name, &pdev->dev,
                        &omap_rtc_ops, THIS_MODULE);
        if (IS_ERR(rtc)) {
                pr_debug("%s: can't register RTC device, err %ld\n",
                        pdev->name, PTR_ERR(rtc));
-               goto fail;
+               goto fail0;
        }
        platform_set_drvdata(pdev, rtc);
        dev_set_drvdata(&rtc->dev, mem);
@@ -380,13 +380,14 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
                        dev_name(&rtc->dev), rtc)) {
                pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
                        pdev->name, omap_rtc_timer);
-               goto fail0;
+               goto fail1;
        }
-       if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
-                       dev_name(&rtc->dev), rtc)) {
+       if ((omap_rtc_timer != omap_rtc_alarm) &&
+               (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
+                       dev_name(&rtc->dev), rtc))) {
                pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
                        pdev->name, omap_rtc_alarm);
-               goto fail1;
+               goto fail2;
        }
 
        /* On boards with split power, RTC_ON_NOFF won't reset the RTC */
@@ -419,10 +420,12 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
 
        return 0;
 
-fail1:
+fail2:
        free_irq(omap_rtc_timer, NULL);
-fail0:
+fail1:
        rtc_device_unregister(rtc);
+fail0:
+       iounmap(rtc_base);
 fail:
        release_resource(mem);
        return -EIO;
@@ -438,7 +441,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
        rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
 
        free_irq(omap_rtc_timer, rtc);
-       free_irq(omap_rtc_alarm, rtc);
+
+       if (omap_rtc_timer != omap_rtc_alarm)
+               free_irq(omap_rtc_alarm, rtc);
 
        release_resource(dev_get_drvdata(&rtc->dev));
        rtc_device_unregister(rtc);
index 9b74e9c9151c6276c42256b8545508521cafcbd3..854c3cb365a1919d0c6a92dad726f2a648ed4a5e 100644 (file)
@@ -58,6 +58,7 @@ struct pcf50633_time {
 struct pcf50633_rtc {
        int alarm_enabled;
        int second_enabled;
+       int alarm_pending;
 
        struct pcf50633 *pcf;
        struct rtc_device *rtc_dev;
@@ -209,6 +210,7 @@ static int pcf50633_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        rtc = dev_get_drvdata(dev);
 
        alrm->enabled = rtc->alarm_enabled;
+       alrm->pending = rtc->alarm_pending;
 
        ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSCA,
                                PCF50633_TI_EXTENT, &pcf_tm.time[0]);
@@ -244,6 +246,8 @@ static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        /* Returns 0 on success */
        ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA,
                                PCF50633_TI_EXTENT, &pcf_tm.time[0]);
+       if (!alrm->enabled)
+               rtc->alarm_pending = 0;
 
        if (!alarm_masked || alrm->enabled)
                pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
@@ -268,6 +272,7 @@ static void pcf50633_rtc_irq(int irq, void *data)
        switch (irq) {
        case PCF50633_IRQ_ALARM:
                rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
+               rtc->alarm_pending = 1;
                break;
        case PCF50633_IRQ_SECOND:
                rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
index b725913ccbe805ecb843252277c02ae8fc4169b0..65f346b2fbaebfcf73b58759e6622d6e9ababefd 100644 (file)
@@ -212,6 +212,8 @@ static int pcf8563_probe(struct i2c_client *client,
 
        dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
 
+       i2c_set_clientdata(client, pcf8563);
+
        pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name,
                                &client->dev, &pcf8563_rtc_ops, THIS_MODULE);
 
@@ -220,8 +222,6 @@ static int pcf8563_probe(struct i2c_client *client,
                goto exit_kfree;
        }
 
-       i2c_set_clientdata(client, pcf8563);
-
        return 0;
 
 exit_kfree:
index 7d33cda3f8f6cc5f00331635cc86ca32ddd62283..2d201afead3bce2f9230ec3d629a0bb77245ccf8 100644 (file)
@@ -277,6 +277,8 @@ static int pcf8583_probe(struct i2c_client *client,
        if (!pcf8583)
                return -ENOMEM;
 
+       i2c_set_clientdata(client, pcf8583);
+
        pcf8583->rtc = rtc_device_register(pcf8583_driver.driver.name,
                        &client->dev, &pcf8583_rtc_ops, THIS_MODULE);
 
@@ -285,7 +287,6 @@ static int pcf8583_probe(struct i2c_client *client,
                goto exit_kfree;
        }
 
-       i2c_set_clientdata(client, pcf8583);
        return 0;
 
 exit_kfree:
index f41873f98f6668322d7a29173c803d4435999316..0264b117893b36eba4616843d0e5a48f10e03721 100644 (file)
@@ -51,10 +51,10 @@ static int pl031_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
 
        switch (cmd) {
        case RTC_AIE_OFF:
-               __raw_writel(1, ldata->base + RTC_MIS);
+               writel(1, ldata->base + RTC_MIS);
                return 0;
        case RTC_AIE_ON:
-               __raw_writel(0, ldata->base + RTC_MIS);
+               writel(0, ldata->base + RTC_MIS);
                return 0;
        }
 
@@ -65,7 +65,7 @@ static int pl031_read_time(struct device *dev, struct rtc_time *tm)
 {
        struct pl031_local *ldata = dev_get_drvdata(dev);
 
-       rtc_time_to_tm(__raw_readl(ldata->base + RTC_DR), tm);
+       rtc_time_to_tm(readl(ldata->base + RTC_DR), tm);
 
        return 0;
 }
@@ -76,7 +76,7 @@ static int pl031_set_time(struct device *dev, struct rtc_time *tm)
        struct pl031_local *ldata = dev_get_drvdata(dev);
 
        rtc_tm_to_time(tm, &time);
-       __raw_writel(time, ldata->base + RTC_LR);
+       writel(time, ldata->base + RTC_LR);
 
        return 0;
 }
@@ -85,9 +85,9 @@ static int pl031_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
        struct pl031_local *ldata = dev_get_drvdata(dev);
 
-       rtc_time_to_tm(__raw_readl(ldata->base + RTC_MR), &alarm->time);
-       alarm->pending = __raw_readl(ldata->base + RTC_RIS);
-       alarm->enabled = __raw_readl(ldata->base + RTC_IMSC);
+       rtc_time_to_tm(readl(ldata->base + RTC_MR), &alarm->time);
+       alarm->pending = readl(ldata->base + RTC_RIS);
+       alarm->enabled = readl(ldata->base + RTC_IMSC);
 
        return 0;
 }
@@ -99,8 +99,8 @@ static int pl031_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 
        rtc_tm_to_time(&alarm->time, &time);
 
-       __raw_writel(time, ldata->base + RTC_MR);
-       __raw_writel(!alarm->enabled, ldata->base + RTC_MIS);
+       writel(time, ldata->base + RTC_MR);
+       writel(!alarm->enabled, ldata->base + RTC_MIS);
 
        return 0;
 }
@@ -180,8 +180,9 @@ err_req:
 
 static struct amba_id pl031_ids[] __initdata = {
        {
-                .id = 0x00041031,
-               .mask = 0x000fffff, },
+               .id = 0x00041031,
+               .mask = 0x000fffff,
+       },
        {0, 0},
 };
 
index 747ca194fad4ac2ec319eac087bda3396fa3f309..e6351b743da644cd78dd34b0cfd73b667e885cfe 100644 (file)
@@ -456,7 +456,7 @@ static int pxa_rtc_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops pxa_rtc_pm_ops = {
+static const struct dev_pm_ops pxa_rtc_pm_ops = {
        .suspend        = pxa_rtc_suspend,
        .resume         = pxa_rtc_resume,
 };
index 29f98a70586e4e677fb99373f24a62056852ea1f..e4a44b641702677ba99884f03089477f1c04f3cd 100644 (file)
@@ -407,7 +407,7 @@ static int sa1100_rtc_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops sa1100_rtc_pm_ops = {
+static const struct dev_pm_ops sa1100_rtc_pm_ops = {
        .suspend        = sa1100_rtc_suspend,
        .resume         = sa1100_rtc_resume,
 };
index e6ed5404bca0e8d32d4623bd123c6d0b8e6a1b54..e95cc6f8d61e28c035fed8d0648fd92463ed595e 100644 (file)
@@ -826,7 +826,7 @@ static int sh_rtc_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops sh_rtc_dev_pm_ops = {
+static const struct dev_pm_ops sh_rtc_dev_pm_ops = {
        .suspend = sh_rtc_suspend,
        .resume = sh_rtc_resume,
 };
index d491eb265c38776fdd392baa02988052fdb25831..67700831b5c991e948e7b03b48e9ea75777b5938 100644 (file)
@@ -62,7 +62,6 @@
 struct rtc_plat_data {
        struct rtc_device *rtc;
        void __iomem *ioaddr;
-       unsigned long baseaddr;
        unsigned long last_jiffies;
        int irq;
        unsigned int irqen;
@@ -70,6 +69,7 @@ struct rtc_plat_data {
        int alrm_min;
        int alrm_hour;
        int alrm_mday;
+       spinlock_t lock;
 };
 
 static int stk17ta8_rtc_set_time(struct device *dev, struct rtc_time *tm)
@@ -142,7 +142,7 @@ static void stk17ta8_rtc_update_alarm(struct rtc_plat_data *pdata)
        unsigned long irqflags;
        u8 flags;
 
-       spin_lock_irqsave(&pdata->rtc->irq_lock, irqflags);
+       spin_lock_irqsave(&pdata->lock, irqflags);
 
        flags = readb(ioaddr + RTC_FLAGS);
        writeb(flags | RTC_WRITE, ioaddr + RTC_FLAGS);
@@ -162,7 +162,7 @@ static void stk17ta8_rtc_update_alarm(struct rtc_plat_data *pdata)
        writeb(pdata->irqen ? RTC_INTS_AIE : 0, ioaddr + RTC_INTERRUPTS);
        readb(ioaddr + RTC_FLAGS);      /* clear interrupts */
        writeb(flags & ~RTC_WRITE, ioaddr + RTC_FLAGS);
-       spin_unlock_irqrestore(&pdata->rtc->irq_lock, irqflags);
+       spin_unlock_irqrestore(&pdata->lock, irqflags);
 }
 
 static int stk17ta8_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
@@ -202,56 +202,53 @@ static irqreturn_t stk17ta8_rtc_interrupt(int irq, void *dev_id)
        struct platform_device *pdev = dev_id;
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
        void __iomem *ioaddr = pdata->ioaddr;
-       unsigned long events = RTC_IRQF;
+       unsigned long events = 0;
 
+       spin_lock(&pdata->lock);
        /* read and clear interrupt */
-       if (!(readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF))
-               return IRQ_NONE;
-       if (readb(ioaddr + RTC_SECONDS_ALARM) & 0x80)
-               events |= RTC_UF;
-       else
-               events |= RTC_AF;
-       rtc_update_irq(pdata->rtc, 1, events);
-       return IRQ_HANDLED;
+       if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF) {
+               events = RTC_IRQF;
+               if (readb(ioaddr + RTC_SECONDS_ALARM) & 0x80)
+                       events |= RTC_UF;
+               else
+                       events |= RTC_AF;
+               if (likely(pdata->rtc))
+                       rtc_update_irq(pdata->rtc, 1, events);
+       }
+       spin_unlock(&pdata->lock);
+       return events ? IRQ_HANDLED : IRQ_NONE;
 }
 
-static int stk17ta8_rtc_ioctl(struct device *dev, unsigned int cmd,
-                           unsigned long arg)
+static int stk17ta8_rtc_alarm_irq_enable(struct device *dev,
+       unsigned int enabled)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
 
        if (pdata->irq <= 0)
-               return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */
-       switch (cmd) {
-       case RTC_AIE_OFF:
-               pdata->irqen &= ~RTC_AF;
-               stk17ta8_rtc_update_alarm(pdata);
-               break;
-       case RTC_AIE_ON:
+               return -EINVAL;
+       if (enabled)
                pdata->irqen |= RTC_AF;
-               stk17ta8_rtc_update_alarm(pdata);
-               break;
-       default:
-               return -ENOIOCTLCMD;
-       }
+       else
+               pdata->irqen &= ~RTC_AF;
+       stk17ta8_rtc_update_alarm(pdata);
        return 0;
 }
 
 static const struct rtc_class_ops stk17ta8_rtc_ops = {
-       .read_time      = stk17ta8_rtc_read_time,
-       .set_time       = stk17ta8_rtc_set_time,
-       .read_alarm     = stk17ta8_rtc_read_alarm,
-       .set_alarm      = stk17ta8_rtc_set_alarm,
-       .ioctl          = stk17ta8_rtc_ioctl,
+       .read_time              = stk17ta8_rtc_read_time,
+       .set_time               = stk17ta8_rtc_set_time,
+       .read_alarm             = stk17ta8_rtc_read_alarm,
+       .set_alarm              = stk17ta8_rtc_set_alarm,
+       .alarm_irq_enable       = stk17ta8_rtc_alarm_irq_enable,
 };
 
 static ssize_t stk17ta8_nvram_read(struct kobject *kobj,
                                 struct bin_attribute *attr, char *buf,
                                 loff_t pos, size_t size)
 {
-       struct platform_device *pdev =
-               to_platform_device(container_of(kobj, struct device, kobj));
+       struct device *dev = container_of(kobj, struct device, kobj);
+       struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
        void __iomem *ioaddr = pdata->ioaddr;
        ssize_t count;
@@ -265,8 +262,8 @@ static ssize_t stk17ta8_nvram_write(struct kobject *kobj,
                                  struct bin_attribute *attr, char *buf,
                                  loff_t pos, size_t size)
 {
-       struct platform_device *pdev =
-               to_platform_device(container_of(kobj, struct device, kobj));
+       struct device *dev = container_of(kobj, struct device, kobj);
+       struct platform_device *pdev = to_platform_device(dev);
        struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
        void __iomem *ioaddr = pdata->ioaddr;
        ssize_t count;
@@ -288,31 +285,26 @@ static struct bin_attribute stk17ta8_nvram_attr = {
 
 static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
 {
-       struct rtc_device *rtc;
        struct resource *res;
        unsigned int cal;
        unsigned int flags;
        struct rtc_plat_data *pdata;
-       void __iomem *ioaddr = NULL;
+       void __iomem *ioaddr;
        int ret = 0;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res)
                return -ENODEV;
 
-       pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+       pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                return -ENOMEM;
-       if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) {
-               ret = -EBUSY;
-               goto out;
-       }
-       pdata->baseaddr = res->start;
-       ioaddr = ioremap(pdata->baseaddr, RTC_REG_SIZE);
-       if (!ioaddr) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!devm_request_mem_region(&pdev->dev, res->start, RTC_REG_SIZE,
+                       pdev->name))
+               return -EBUSY;
+       ioaddr = devm_ioremap(&pdev->dev, res->start, RTC_REG_SIZE);
+       if (!ioaddr)
+               return -ENOMEM;
        pdata->ioaddr = ioaddr;
        pdata->irq = platform_get_irq(pdev, 0);
 
@@ -328,9 +320,13 @@ static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
        if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_PF)
                dev_warn(&pdev->dev, "voltage-low detected.\n");
 
+       spin_lock_init(&pdata->lock);
+       pdata->last_jiffies = jiffies;
+       platform_set_drvdata(pdev, pdata);
        if (pdata->irq > 0) {
                writeb(0, ioaddr + RTC_INTERRUPTS);
-               if (request_irq(pdata->irq, stk17ta8_rtc_interrupt,
+               if (devm_request_irq(&pdev->dev, pdata->irq,
+                               stk17ta8_rtc_interrupt,
                                IRQF_DISABLED | IRQF_SHARED,
                                pdev->name, pdev) < 0) {
                        dev_warn(&pdev->dev, "interrupt not available.\n");
@@ -338,29 +334,14 @@ static int __devinit stk17ta8_rtc_probe(struct platform_device *pdev)
                }
        }
 
-       rtc = rtc_device_register(pdev->name, &pdev->dev,
+       pdata->rtc = rtc_device_register(pdev->name, &pdev->dev,
                                  &stk17ta8_rtc_ops, THIS_MODULE);
-       if (IS_ERR(rtc)) {
-               ret = PTR_ERR(rtc);
-               goto out;
-       }
-       pdata->rtc = rtc;
-       pdata->last_jiffies = jiffies;
-       platform_set_drvdata(pdev, pdata);
+       if (IS_ERR(pdata->rtc))
+               return PTR_ERR(pdata->rtc);
+
        ret = sysfs_create_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr);
        if (ret)
-               goto out;
-       return 0;
- out:
-       if (pdata->rtc)
                rtc_device_unregister(pdata->rtc);
-       if (pdata->irq > 0)
-               free_irq(pdata->irq, pdev);
-       if (ioaddr)
-               iounmap(ioaddr);
-       if (pdata->baseaddr)
-               release_mem_region(pdata->baseaddr, RTC_REG_SIZE);
-       kfree(pdata);
        return ret;
 }
 
@@ -370,13 +351,8 @@ static int __devexit stk17ta8_rtc_remove(struct platform_device *pdev)
 
        sysfs_remove_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr);
        rtc_device_unregister(pdata->rtc);
-       if (pdata->irq > 0) {
+       if (pdata->irq > 0)
                writeb(0, pdata->ioaddr + RTC_INTERRUPTS);
-               free_irq(pdata->irq, pdev);
-       }
-       iounmap(pdata->ioaddr);
-       release_mem_region(pdata->baseaddr, RTC_REG_SIZE);
-       kfree(pdata);
        return 0;
 }
 
index 4a6ed1104fbb4a86ca3579677d6a558384ceedc5..9ee81d8aa7c02ecd88c637776b82d14978e063ef 100644 (file)
@@ -17,6 +17,7 @@
 struct tx4939rtc_plat_data {
        struct rtc_device *rtc;
        struct tx4939_rtc_reg __iomem *rtcreg;
+       spinlock_t lock;
 };
 
 static struct tx4939rtc_plat_data *get_tx4939rtc_plat_data(struct device *dev)
@@ -52,14 +53,14 @@ static int tx4939_rtc_set_mmss(struct device *dev, unsigned long secs)
        buf[3] = secs >> 8;
        buf[4] = secs >> 16;
        buf[5] = secs >> 24;
-       spin_lock_irq(&pdata->rtc->irq_lock);
+       spin_lock_irq(&pdata->lock);
        __raw_writel(0, &rtcreg->adr);
        for (i = 0; i < 6; i++)
                __raw_writel(buf[i], &rtcreg->dat);
        ret = tx4939_rtc_cmd(rtcreg,
                             TX4939_RTCCTL_COMMAND_SETTIME |
                             (__raw_readl(&rtcreg->ctl) & TX4939_RTCCTL_ALME));
-       spin_unlock_irq(&pdata->rtc->irq_lock);
+       spin_unlock_irq(&pdata->lock);
        return ret;
 }
 
@@ -71,18 +72,18 @@ static int tx4939_rtc_read_time(struct device *dev, struct rtc_time *tm)
        unsigned long sec;
        unsigned char buf[6];
 
-       spin_lock_irq(&pdata->rtc->irq_lock);
+       spin_lock_irq(&pdata->lock);
        ret = tx4939_rtc_cmd(rtcreg,
                             TX4939_RTCCTL_COMMAND_GETTIME |
                             (__raw_readl(&rtcreg->ctl) & TX4939_RTCCTL_ALME));
        if (ret) {
-               spin_unlock_irq(&pdata->rtc->irq_lock);
+               spin_unlock_irq(&pdata->lock);
                return ret;
        }
        __raw_writel(2, &rtcreg->adr);
        for (i = 2; i < 6; i++)
                buf[i] = __raw_readl(&rtcreg->dat);
-       spin_unlock_irq(&pdata->rtc->irq_lock);
+       spin_unlock_irq(&pdata->lock);
        sec = (buf[5] << 24) | (buf[4] << 16) | (buf[3] << 8) | buf[2];
        rtc_time_to_tm(sec, tm);
        return rtc_valid_tm(tm);
@@ -110,13 +111,13 @@ static int tx4939_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        buf[3] = sec >> 8;
        buf[4] = sec >> 16;
        buf[5] = sec >> 24;
-       spin_lock_irq(&pdata->rtc->irq_lock);
+       spin_lock_irq(&pdata->lock);
        __raw_writel(0, &rtcreg->adr);
        for (i = 0; i < 6; i++)
                __raw_writel(buf[i], &rtcreg->dat);
        ret = tx4939_rtc_cmd(rtcreg, TX4939_RTCCTL_COMMAND_SETALARM |
                             (alrm->enabled ? TX4939_RTCCTL_ALME : 0));
-       spin_unlock_irq(&pdata->rtc->irq_lock);
+       spin_unlock_irq(&pdata->lock);
        return ret;
 }
 
@@ -129,12 +130,12 @@ static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        unsigned char buf[6];
        u32 ctl;
 
-       spin_lock_irq(&pdata->rtc->irq_lock);
+       spin_lock_irq(&pdata->lock);
        ret = tx4939_rtc_cmd(rtcreg,
                             TX4939_RTCCTL_COMMAND_GETALARM |
                             (__raw_readl(&rtcreg->ctl) & TX4939_RTCCTL_ALME));
        if (ret) {
-               spin_unlock_irq(&pdata->rtc->irq_lock);
+               spin_unlock_irq(&pdata->lock);
                return ret;
        }
        __raw_writel(2, &rtcreg->adr);
@@ -143,7 +144,7 @@ static int tx4939_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
        ctl = __raw_readl(&rtcreg->ctl);
        alrm->enabled = (ctl & TX4939_RTCCTL_ALME) ? 1 : 0;
        alrm->pending = (ctl & TX4939_RTCCTL_ALMD) ? 1 : 0;
-       spin_unlock_irq(&pdata->rtc->irq_lock);
+       spin_unlock_irq(&pdata->lock);
        sec = (buf[5] << 24) | (buf[4] << 16) | (buf[3] << 8) | buf[2];
        rtc_time_to_tm(sec, &alrm->time);
        return rtc_valid_tm(&alrm->time);
@@ -153,11 +154,11 @@ static int tx4939_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
 {
        struct tx4939rtc_plat_data *pdata = get_tx4939rtc_plat_data(dev);
 
-       spin_lock_irq(&pdata->rtc->irq_lock);
+       spin_lock_irq(&pdata->lock);
        tx4939_rtc_cmd(pdata->rtcreg,
                       TX4939_RTCCTL_COMMAND_NOP |
                       (enabled ? TX4939_RTCCTL_ALME : 0));
-       spin_unlock_irq(&pdata->rtc->irq_lock);
+       spin_unlock_irq(&pdata->lock);
        return 0;
 }
 
@@ -167,13 +168,14 @@ static irqreturn_t tx4939_rtc_interrupt(int irq, void *dev_id)
        struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
        unsigned long events = RTC_IRQF;
 
-       spin_lock(&pdata->rtc->irq_lock);
+       spin_lock(&pdata->lock);
        if (__raw_readl(&rtcreg->ctl) & TX4939_RTCCTL_ALMD) {
                events |= RTC_AF;
                tx4939_rtc_cmd(rtcreg, TX4939_RTCCTL_COMMAND_NOP);
        }
-       spin_unlock(&pdata->rtc->irq_lock);
-       rtc_update_irq(pdata->rtc, 1, events);
+       spin_unlock(&pdata->lock);
+       if (likely(pdata->rtc))
+               rtc_update_irq(pdata->rtc, 1, events);
        return IRQ_HANDLED;
 }
 
@@ -194,13 +196,13 @@ static ssize_t tx4939_rtc_nvram_read(struct kobject *kobj,
        struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
        ssize_t count;
 
-       spin_lock_irq(&pdata->rtc->irq_lock);
+       spin_lock_irq(&pdata->lock);
        for (count = 0; size > 0 && pos < TX4939_RTC_REG_RAMSIZE;
             count++, size--) {
                __raw_writel(pos++, &rtcreg->adr);
                *buf++ = __raw_readl(&rtcreg->dat);
        }
-       spin_unlock_irq(&pdata->rtc->irq_lock);
+       spin_unlock_irq(&pdata->lock);
        return count;
 }
 
@@ -213,13 +215,13 @@ static ssize_t tx4939_rtc_nvram_write(struct kobject *kobj,
        struct tx4939_rtc_reg __iomem *rtcreg = pdata->rtcreg;
        ssize_t count;
 
-       spin_lock_irq(&pdata->rtc->irq_lock);
+       spin_lock_irq(&pdata->lock);
        for (count = 0; size > 0 && pos < TX4939_RTC_REG_RAMSIZE;
             count++, size--) {
                __raw_writel(pos++, &rtcreg->adr);
                __raw_writel(*buf++, &rtcreg->dat);
        }
-       spin_unlock_irq(&pdata->rtc->irq_lock);
+       spin_unlock_irq(&pdata->lock);
        return count;
 }
 
@@ -259,6 +261,7 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev)
        if (!pdata->rtcreg)
                return -EBUSY;
 
+       spin_lock_init(&pdata->lock);
        tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP);
        if (devm_request_irq(&pdev->dev, irq, tx4939_rtc_interrupt,
                             IRQF_DISABLED, pdev->name, &pdev->dev) < 0)
@@ -277,14 +280,12 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev)
 static int __exit tx4939_rtc_remove(struct platform_device *pdev)
 {
        struct tx4939rtc_plat_data *pdata = platform_get_drvdata(pdev);
-       struct rtc_device *rtc = pdata->rtc;
 
-       spin_lock_irq(&rtc->irq_lock);
-       tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP);
-       spin_unlock_irq(&rtc->irq_lock);
        sysfs_remove_bin_file(&pdev->dev.kobj, &tx4939_rtc_nvram_attr);
-       rtc_device_unregister(rtc);
-       platform_set_drvdata(pdev, NULL);
+       rtc_device_unregister(pdata->rtc);
+       spin_lock_irq(&pdata->lock);
+       tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP);
+       spin_unlock_irq(&pdata->lock);
        return 0;
 }
 
index ad741afd47d8eb272824f9d15dd4048b9acc35d6..bed4cab07043674615ab7fef5d3093e67577af44 100644 (file)
@@ -304,7 +304,6 @@ static int rtc_probe(struct platform_device *pdev)
 {
        struct v3020_platform_data *pdata = pdev->dev.platform_data;
        struct v3020 *chip;
-       struct rtc_device *rtc;
        int retval = -EBUSY;
        int i;
        int temp;
@@ -353,13 +352,12 @@ static int rtc_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, chip);
 
-       rtc = rtc_device_register("v3020",
+       chip->rtc = rtc_device_register("v3020",
                                &pdev->dev, &v3020_rtc_ops, THIS_MODULE);
-       if (IS_ERR(rtc)) {
-               retval = PTR_ERR(rtc);
+       if (IS_ERR(chip->rtc)) {
+               retval = PTR_ERR(chip->rtc);
                goto err_io;
        }
-       chip->rtc = rtc;
 
        return 0;
 
index fadddac1e5a44d5658536828c62db7122474a49b..c3244244e8cfd7a508963cdcc9e4d16fba57a78c 100644 (file)
@@ -327,7 +327,7 @@ static int __devinit rtc_probe(struct platform_device *pdev)
        if (!res)
                return -EBUSY;
 
-       rtc1_base = ioremap(res->start, res->end - res->start + 1);
+       rtc1_base = ioremap(res->start, resource_size(res));
        if (!rtc1_base)
                return -EBUSY;
 
@@ -337,7 +337,7 @@ static int __devinit rtc_probe(struct platform_device *pdev)
                goto err_rtc1_iounmap;
        }
 
-       rtc2_base = ioremap(res->start, res->end - res->start + 1);
+       rtc2_base = ioremap(res->start, resource_size(res));
        if (!rtc2_base) {
                retval = -EBUSY;
                goto err_rtc1_iounmap;
index 79795cdf6ed81f9796ea914f21180f03694ac184..000c7e481e594ab8216b5c5d05098af188a9d876 100644 (file)
@@ -485,7 +485,7 @@ static int __devexit wm831x_rtc_remove(struct platform_device *pdev)
        return 0;
 }
 
-static struct dev_pm_ops wm831x_rtc_pm_ops = {
+static const struct dev_pm_ops wm831x_rtc_pm_ops = {
        .suspend = wm831x_rtc_suspend,
        .resume = wm831x_rtc_resume,
 
index f16486635a8efab098e21e22c1ada0c42f91b2da..f1e440521c541ad5fb98852987e27af75bc1600e 100644 (file)
@@ -354,8 +354,9 @@ static const struct rtc_class_ops wm8350_rtc_ops = {
 };
 
 #ifdef CONFIG_PM
-static int wm8350_rtc_suspend(struct platform_device *pdev, pm_message_t state)
+static int wm8350_rtc_suspend(struct device *dev)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev);
        int ret = 0;
        u16 reg;
@@ -373,8 +374,9 @@ static int wm8350_rtc_suspend(struct platform_device *pdev, pm_message_t state)
        return ret;
 }
 
-static int wm8350_rtc_resume(struct platform_device *pdev)
+static int wm8350_rtc_resume(struct device *dev)
 {
+       struct platform_device *pdev = to_platform_device(dev);
        struct wm8350 *wm8350 = dev_get_drvdata(&pdev->dev);
        int ret;
 
@@ -484,13 +486,17 @@ static int __devexit wm8350_rtc_remove(struct platform_device *pdev)
        return 0;
 }
 
+static struct dev_pm_ops wm8350_rtc_pm_ops = {
+       .suspend = wm8350_rtc_suspend,
+       .resume = wm8350_rtc_resume,
+};
+
 static struct platform_driver wm8350_rtc_driver = {
        .probe = wm8350_rtc_probe,
        .remove = __devexit_p(wm8350_rtc_remove),
-       .suspend = wm8350_rtc_suspend,
-       .resume = wm8350_rtc_resume,
        .driver = {
                .name = "wm8350-rtc",
+               .pm = &wm8350_rtc_pm_ops,
        },
 };
 
index 6583c1a8b0702b260c70cb7f13845ea8257b0f2b..9aae49139a0a81d8b75c1822c9dd5d55f526893b 100644 (file)
@@ -155,11 +155,11 @@ static int x1205_get_status(struct i2c_client *client, unsigned char *sr)
 }
 
 static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
-                       int datetoo, u8 reg_base, unsigned char alm_enable)
+                       u8 reg_base, unsigned char alm_enable)
 {
-       int i, xfer, nbytes;
-       unsigned char buf[8];
+       int i, xfer;
        unsigned char rdata[10] = { 0, reg_base };
+       unsigned char *buf = rdata + 2;
 
        static const unsigned char wel[3] = { 0, X1205_REG_SR,
                                                X1205_SR_WEL };
@@ -170,9 +170,9 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
        static const unsigned char diswe[3] = { 0, X1205_REG_SR, 0 };
 
        dev_dbg(&client->dev,
-               "%s: secs=%d, mins=%d, hours=%d\n",
-               __func__,
-               tm->tm_sec, tm->tm_min, tm->tm_hour);
+               "%s: sec=%d min=%d hour=%d mday=%d mon=%d year=%d wday=%d\n",
+               __func__, tm->tm_sec, tm->tm_min, tm->tm_hour, tm->tm_mday,
+               tm->tm_mon, tm->tm_year, tm->tm_wday);
 
        buf[CCR_SEC] = bin2bcd(tm->tm_sec);
        buf[CCR_MIN] = bin2bcd(tm->tm_min);
@@ -180,23 +180,15 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
        /* set hour and 24hr bit */
        buf[CCR_HOUR] = bin2bcd(tm->tm_hour) | X1205_HR_MIL;
 
-       /* should we also set the date? */
-       if (datetoo) {
-               dev_dbg(&client->dev,
-                       "%s: mday=%d, mon=%d, year=%d, wday=%d\n",
-                       __func__,
-                       tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
+       buf[CCR_MDAY] = bin2bcd(tm->tm_mday);
 
-               buf[CCR_MDAY] = bin2bcd(tm->tm_mday);
+       /* month, 1 - 12 */
+       buf[CCR_MONTH] = bin2bcd(tm->tm_mon + 1);
 
-               /* month, 1 - 12 */
-               buf[CCR_MONTH] = bin2bcd(tm->tm_mon + 1);
-
-               /* year, since the rtc epoch*/
-               buf[CCR_YEAR] = bin2bcd(tm->tm_year % 100);
-               buf[CCR_WDAY] = tm->tm_wday & 0x07;
-               buf[CCR_Y2K] = bin2bcd((tm->tm_year + 1900) / 100);
-       }
+       /* year, since the rtc epoch*/
+       buf[CCR_YEAR] = bin2bcd(tm->tm_year % 100);
+       buf[CCR_WDAY] = tm->tm_wday & 0x07;
+       buf[CCR_Y2K] = bin2bcd((tm->tm_year + 1900) / 100);
 
        /* If writing alarm registers, set compare bits on registers 0-4 */
        if (reg_base < X1205_CCR_BASE)
@@ -214,17 +206,8 @@ static int x1205_set_datetime(struct i2c_client *client, struct rtc_time *tm,
                return -EIO;
        }
 
-
-       /* write register's data */
-       if (datetoo)
-               nbytes = 8;
-       else
-               nbytes = 3;
-       for (i = 0; i < nbytes; i++)
-               rdata[2+i] = buf[i];
-
-       xfer = i2c_master_send(client, rdata, nbytes+2);
-       if (xfer != nbytes+2) {
+       xfer = i2c_master_send(client, rdata, sizeof(rdata));
+       if (xfer != sizeof(rdata)) {
                dev_err(&client->dev,
                        "%s: result=%d addr=%02x, data=%02x\n",
                        __func__,
@@ -282,7 +265,7 @@ static int x1205_fix_osc(struct i2c_client *client)
 
        memset(&tm, 0, sizeof(tm));
 
-       err = x1205_set_datetime(client, &tm, 1, X1205_CCR_BASE, 0);
+       err = x1205_set_datetime(client, &tm, X1205_CCR_BASE, 0);
        if (err < 0)
                dev_err(&client->dev, "unable to restart the oscillator\n");
 
@@ -481,7 +464,7 @@ static int x1205_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 static int x1205_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
        return x1205_set_datetime(to_i2c_client(dev),
-               &alrm->time, 1, X1205_ALM0_BASE, alrm->enabled);
+               &alrm->time, X1205_ALM0_BASE, alrm->enabled);
 }
 
 static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm)
@@ -493,7 +476,7 @@ static int x1205_rtc_read_time(struct device *dev, struct rtc_time *tm)
 static int x1205_rtc_set_time(struct device *dev, struct rtc_time *tm)
 {
        return x1205_set_datetime(to_i2c_client(dev),
-               tm, 1, X1205_CCR_BASE, 0);
+               tm, X1205_CCR_BASE, 0);
 }
 
 static int x1205_rtc_proc(struct device *dev, struct seq_file *seq)
index fd1231738ef4eb5b8007dbc1e6b4382199ece1f1..148b1dd240704e8d472b6ba83f5c435d40fb0fb3 100644 (file)
@@ -218,7 +218,7 @@ int dasd_alias_make_device_known_to_lcu(struct dasd_device *device)
                spin_unlock_irqrestore(&aliastree.lock, flags);
                newlcu = _allocate_lcu(uid);
                if (IS_ERR(newlcu))
-                       return PTR_ERR(lcu);
+                       return PTR_ERR(newlcu);
                spin_lock_irqsave(&aliastree.lock, flags);
                lcu = _find_lcu(server, uid);
                if (!lcu) {
index f64d0db881b42d72153f6f6ebd32e2595799b831..6e14863f5c70b2dce947b677ab239b2dae466d1d 100644 (file)
@@ -8,7 +8,7 @@
  *
  */
 
-#define KMSG_COMPONENT "dasd-diag"
+#define KMSG_COMPONENT "dasd"
 
 #include <linux/stddef.h>
 #include <linux/kernel.h>
@@ -146,16 +146,16 @@ dasd_diag_erp(struct dasd_device *device)
        rc = mdsk_init_io(device, device->block->bp_block, 0, NULL);
        if (rc == 4) {
                if (!(device->features & DASD_FEATURE_READONLY)) {
-                       dev_warn(&device->cdev->dev,
-                                "The access mode of a DIAG device changed"
-                                " to read-only");
+                       pr_warning("%s: The access mode of a DIAG device "
+                                  "changed to read-only\n",
+                                  dev_name(&device->cdev->dev));
                        device->features |= DASD_FEATURE_READONLY;
                }
                rc = 0;
        }
        if (rc)
-               dev_warn(&device->cdev->dev, "DIAG ERP failed with "
-                           "rc=%d\n", rc);
+               pr_warning("%s: DIAG ERP failed with "
+                           "rc=%d\n", dev_name(&device->cdev->dev), rc);
 }
 
 /* Start a given request at the device. Return zero on success, non-zero
@@ -371,8 +371,9 @@ dasd_diag_check_device(struct dasd_device *device)
                private->pt_block = 2;
                break;
        default:
-               dev_warn(&device->cdev->dev, "Device type %d is not supported "
-                           "in DIAG mode\n", private->rdc_data.vdev_class);
+               pr_warning("%s: Device type %d is not supported "
+                          "in DIAG mode\n", dev_name(&device->cdev->dev),
+                          private->rdc_data.vdev_class);
                rc = -EOPNOTSUPP;
                goto out;
        }
@@ -413,8 +414,8 @@ dasd_diag_check_device(struct dasd_device *device)
                private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;
                rc = dia250(&private->iob, RW_BIO);
                if (rc == 3) {
-                       dev_warn(&device->cdev->dev,
-                               "A 64-bit DIAG call failed\n");
+                       pr_warning("%s: A 64-bit DIAG call failed\n",
+                                  dev_name(&device->cdev->dev));
                        rc = -EOPNOTSUPP;
                        goto out_label;
                }
@@ -423,8 +424,9 @@ dasd_diag_check_device(struct dasd_device *device)
                        break;
        }
        if (bsize > PAGE_SIZE) {
-               dev_warn(&device->cdev->dev, "Accessing the DASD failed because"
-                        " of an incorrect format (rc=%d)\n", rc);
+               pr_warning("%s: Accessing the DASD failed because of an "
+                          "incorrect format (rc=%d)\n",
+                          dev_name(&device->cdev->dev), rc);
                rc = -EIO;
                goto out_label;
        }
@@ -442,18 +444,18 @@ dasd_diag_check_device(struct dasd_device *device)
                block->s2b_shift++;
        rc = mdsk_init_io(device, block->bp_block, 0, NULL);
        if (rc && (rc != 4)) {
-               dev_warn(&device->cdev->dev, "DIAG initialization "
-                       "failed with rc=%d\n", rc);
+               pr_warning("%s: DIAG initialization failed with rc=%d\n",
+                          dev_name(&device->cdev->dev), rc);
                rc = -EIO;
        } else {
                if (rc == 4)
                        device->features |= DASD_FEATURE_READONLY;
-               dev_info(&device->cdev->dev,
-                        "New DASD with %ld byte/block, total size %ld KB%s\n",
-                        (unsigned long) block->bp_block,
-                        (unsigned long) (block->blocks <<
-                                         block->s2b_shift) >> 1,
-                        (rc == 4) ? ", read-only device" : "");
+               pr_info("%s: New DASD with %ld byte/block, total size %ld "
+                       "KB%s\n", dev_name(&device->cdev->dev),
+                       (unsigned long) block->bp_block,
+                       (unsigned long) (block->blocks <<
+                                        block->s2b_shift) >> 1,
+                       (rc == 4) ? ", read-only device" : "");
                rc = 0;
        }
 out_label:
index 5f23eca8280429fe0f33b598fbceb1987d1467e9..6315fbd8e68bf0fe1d8bf557c7932adda91c752f 100644 (file)
@@ -14,6 +14,7 @@
 #define KMSG_COMPONENT "dasd"
 
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/seq_file.h>
 #include <linux/vmalloc.h>
 #include <linux/proc_fs.h>
@@ -272,10 +273,10 @@ dasd_statistics_write(struct file *file, const char __user *user_buf,
        DBF_EVENT(DBF_DEBUG, "/proc/dasd/statictics: '%s'\n", buffer);
 
        /* check for valid verbs */
-       for (str = buffer; isspace(*str); str++);
+       str = skip_spaces(buffer);
        if (strncmp(str, "set", 3) == 0 && isspace(str[3])) {
                /* 'set xxx' was given */
-               for (str = str + 4; isspace(*str); str++);
+               str = skip_spaces(str + 4);
                if (strcmp(str, "on") == 0) {
                        /* switch on statistics profiling */
                        dasd_profile_level = DASD_PROFILE_ON;
index f76f4bd82b9f9810e3bae0b4d914f1f8673803ab..9b43ae94beba1dea263e1687d38060e9a1f243d6 100644 (file)
@@ -1005,7 +1005,7 @@ static int dcssblk_thaw(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops dcssblk_pm_ops = {
+static const struct dev_pm_ops dcssblk_pm_ops = {
        .freeze         = dcssblk_freeze,
        .thaw           = dcssblk_thaw,
        .restore        = dcssblk_restore,
index 116d1b3eeb157093002ea32edbf7c45133dc695b..118de392af63895b98b42afc0123911f054168f5 100644 (file)
@@ -407,7 +407,7 @@ static int xpram_restore(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops xpram_pm_ops = {
+static const struct dev_pm_ops xpram_pm_ops = {
        .restore        = xpram_restore,
 };
 
index 28e4649fa9e44415ba8420d99df6ac8ab240d34a..247b2b934728bacbcc4974ec04c3939fbc5c4764 100644 (file)
@@ -467,7 +467,7 @@ fs3270_open(struct inode *inode, struct file *filp)
        if (IS_ERR(ib)) {
                raw3270_put_view(&fp->view);
                raw3270_del_view(&fp->view);
-               rc = PTR_ERR(fp);
+               rc = PTR_ERR(ib);
                goto out;
        }
        fp->rdbuf = ib;
index 60473f86e1f9271e6f12d1fcddcd85991d66df50..33e96484d54fd1bf5d28aeb369751eed9dbef539 100644 (file)
@@ -529,7 +529,7 @@ static int monreader_restore(struct device *dev)
        return monreader_thaw(dev);
 }
 
-static struct dev_pm_ops monreader_pm_ops = {
+static const struct dev_pm_ops monreader_pm_ops = {
        .freeze  = monreader_freeze,
        .thaw    = monreader_thaw,
        .restore = monreader_restore,
index 6532ed8b4afad0a75a2fef4037eb86c121e3f659..668a0579b26b8b7767d2fbc912c220d02d3a874b 100644 (file)
@@ -323,7 +323,7 @@ static int monwriter_thaw(struct device *dev)
        return monwriter_restore(dev);
 }
 
-static struct dev_pm_ops monwriter_pm_ops = {
+static const struct dev_pm_ops monwriter_pm_ops = {
        .freeze         = monwriter_freeze,
        .thaw           = monwriter_thaw,
        .restore        = monwriter_restore,
index a983f50867881643f06ad0b2364fc5b9cbf2bb04..ec88c59842e3532d1b3b6fde3a402a9101b18266 100644 (file)
@@ -1019,7 +1019,7 @@ static int sclp_restore(struct device *dev)
        return sclp_undo_suspend(SCLP_PM_EVENT_RESTORE);
 }
 
-static struct dev_pm_ops sclp_pm_ops = {
+static const struct dev_pm_ops sclp_pm_ops = {
        .freeze         = sclp_freeze,
        .thaw           = sclp_thaw,
        .restore        = sclp_restore,
index 28b5afc129c36be0cc2396a8f965aafef02fd108..b3beab610da445334be1818b4f8ae05e81e941ba 100644 (file)
@@ -547,7 +547,7 @@ struct read_storage_sccb {
        u32 entries[0];
 } __packed;
 
-static struct dev_pm_ops sclp_mem_pm_ops = {
+static const struct dev_pm_ops sclp_mem_pm_ops = {
        .freeze         = sclp_mem_freeze,
 };
 
index 3657fe103c279e42df29a72ceb11b2e2dd09705d..cb70fa1cf5398fb5d8ff5cd58b5c0a24f45baec6 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #define KMSG_COMPONENT "tape_34xx"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/module.h>
 #include <linux/init.h>
index 0c72aadb8391f1d4db05a717400cfbb306dbc52a..9821c58866137710bfa2e52aaa5bd6a2045831ae 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #define KMSG_COMPONENT "tape_3590"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/module.h>
 #include <linux/init.h>
@@ -136,7 +137,7 @@ static void int_to_ext_kekl(struct tape3592_kekl *in,
                out->type_on_tape = TAPE390_KEKL_TYPE_LABEL;
        memcpy(out->label, in->label, sizeof(in->label));
        EBCASC(out->label, sizeof(in->label));
-       strstrip(out->label);
+       strim(out->label);
 }
 
 static void int_to_ext_kekl_pair(struct tape3592_kekl_pair *in,
index 4799cc2f73c34fbc3d829db114de5c819a45c29b..96816149368a94ad396a86a2d6622c14d01ae04a 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #define KMSG_COMPONENT "tape"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/fs.h>
 #include <linux/module.h>
index 23d773a0d11317ec15362c457b2109db11bb38c6..2125ec7d95f0231223d5351b3e0daa7423f2594b 100644 (file)
@@ -10,6 +10,9 @@
  *              Martin Schwidefsky <schwidefsky@de.ibm.com>
  */
 
+#define KMSG_COMPONENT "tape"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
index ddc914ccea8fccef284bd467cd9a4fe7eb4c625a..b2864e3edb6da8a80cb70ff99b2812918c7cfefb 100644 (file)
@@ -7,6 +7,10 @@
  * Author: Stefan Bader <shbader@de.ibm.com>
  * Based on simple class device code by Greg K-H
  */
+
+#define KMSG_COMPONENT "tape"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
 #include "tape_class.h"
 
 MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>");
index f5d6802dc5da9c71aee814067f536cf10b874e36..81b094e480e66f0f9d7823a0afeb0a2067d340b1 100644 (file)
@@ -12,6 +12,8 @@
  */
 
 #define KMSG_COMPONENT "tape"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
 #include <linux/module.h>
 #include <linux/init.h>             // for kernel parameters
 #include <linux/kmod.h>             // for requesting modules
index ebd820ccfb24f6ef3d0d38070df1d603559da224..0ceb37984f7766d3a565a45f3f9b8373ad4b21e7 100644 (file)
@@ -11,6 +11,9 @@
  * PROCFS Functions
  */
 
+#define KMSG_COMPONENT "tape"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
 #include <linux/module.h>
 #include <linux/vmalloc.h>
 #include <linux/seq_file.h>
index 750354ad16e5506cb6628304462036cc96482df8..03f07e5dd6e9ebe9699ae7306d585101f0db38ec 100644 (file)
@@ -11,6 +11,9 @@
  *              Stefan Bader <shbader@de.ibm.com>
  */
 
+#define KMSG_COMPONENT "tape"
+#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
+
 #include <linux/stddef.h>
 #include <linux/kernel.h>
 #include <linux/bio.h>
index 899aa795bf38eef009cb08299b6a27b6d330fbe3..7dfa5412d5a8bc9d5c0b6ddcacffc6fe6d958981 100644 (file)
@@ -675,7 +675,7 @@ static int vmlogrdr_pm_prepare(struct device *dev)
 }
 
 
-static struct dev_pm_ops vmlogrdr_pm_ops = {
+static const struct dev_pm_ops vmlogrdr_pm_ops = {
        .prepare = vmlogrdr_pm_prepare,
 };
 
index a5a62f1f7747c66107c71ea62be654473765541f..5f97ea2ee6b19f8b6ca80ac7e70239ab2f1dca7e 100644 (file)
@@ -560,7 +560,7 @@ static int ccwgroup_pm_restore(struct device *dev)
        return gdrv->restore ? gdrv->restore(gdev) : 0;
 }
 
-static struct dev_pm_ops ccwgroup_pm_ops = {
+static const struct dev_pm_ops ccwgroup_pm_ops = {
        .prepare = ccwgroup_pm_prepare,
        .complete = ccwgroup_pm_complete,
        .freeze = ccwgroup_pm_freeze,
index 9509e3860934a81b396288ca3492853c7edd3709..7a28a3029a3f9d747a9ecf59d572c7146de74a1b 100644 (file)
@@ -49,7 +49,6 @@ static u16 ccwreq_next_path(struct ccw_device *cdev)
  */
 static void ccwreq_stop(struct ccw_device *cdev, int rc)
 {
-       struct subchannel *sch = to_subchannel(cdev->dev.parent);
        struct ccw_request *req = &cdev->private->req;
 
        if (req->done)
@@ -57,7 +56,6 @@ static void ccwreq_stop(struct ccw_device *cdev, int rc)
        req->done = 1;
        ccw_device_set_timeout(cdev, 0);
        memset(&cdev->private->irb, 0, sizeof(struct irb));
-       sch->lpm = sch->schib.pmcw.pam;
        if (rc && rc != -ENODEV && req->drc)
                rc = req->drc;
        req->callback(cdev, req->data, rc);
@@ -80,7 +78,6 @@ static void ccwreq_do(struct ccw_device *cdev)
                        continue;
                }
                /* Perform start function. */
-               sch->lpm = 0xff;
                memset(&cdev->private->irb, 0, sizeof(struct irb));
                rc = cio_start(sch, cp, (u8) req->mask);
                if (rc == 0) {
index 92ff88ac11072d95d8249f695212cd9ac19b27b3..7679aee6fa147af0459855a899888850752437a4 100644 (file)
@@ -1148,7 +1148,7 @@ static int css_pm_restore(struct device *dev)
        return drv->restore ? drv->restore(sch) : 0;
 }
 
-static struct dev_pm_ops css_pm_ops = {
+static const struct dev_pm_ops css_pm_ops = {
        .prepare = css_pm_prepare,
        .complete = css_pm_complete,
        .freeze = css_pm_freeze,
index 9fecfb4223a85272246b74d35d24154f86eac57c..a6c7d5426fb2ba4dd2bd24d349562f84a4893fcf 100644 (file)
@@ -1519,6 +1519,7 @@ static int ccw_device_console_enable(struct ccw_device *cdev,
        sch->driver = &io_subchannel_driver;
        /* Initialize the ccw_device structure. */
        cdev->dev.parent= &sch->dev;
+       sch_set_cdev(sch, cdev);
        io_subchannel_recog(cdev, sch);
        /* Now wait for the async. recognition to come to an end. */
        spin_lock_irq(cdev->ccwlock);
@@ -1904,7 +1905,7 @@ out_unlock:
        return ret;
 }
 
-static struct dev_pm_ops ccw_pm_ops = {
+static const struct dev_pm_ops ccw_pm_ops = {
        .prepare = ccw_device_pm_prepare,
        .complete = ccw_device_pm_complete,
        .freeze = ccw_device_pm_freeze,
index aad188e43b4fe4f6ad260eb168efddd4fb3852d2..6facb5499a6529dd3fbafe725d69457c302dcc04 100644 (file)
@@ -142,7 +142,7 @@ static void spid_do(struct ccw_device *cdev)
        u8 fn;
 
        /* Use next available path that is not already in correct state. */
-       req->lpm = lpm_adjust(req->lpm, sch->schib.pmcw.pam & ~sch->vpm);
+       req->lpm = lpm_adjust(req->lpm, cdev->private->pgid_todo_mask);
        if (!req->lpm)
                goto out_nopath;
        /* Channel program setup. */
@@ -254,15 +254,15 @@ static void pgid_analyze(struct ccw_device *cdev, struct pgid **p,
        *p = first;
 }
 
-static u8 pgid_to_vpm(struct ccw_device *cdev)
+static u8 pgid_to_donepm(struct ccw_device *cdev)
 {
        struct subchannel *sch = to_subchannel(cdev->dev.parent);
        struct pgid *pgid;
        int i;
        int lpm;
-       u8 vpm = 0;
+       u8 donepm = 0;
 
-       /* Set VPM bits for paths which are already in the target state. */
+       /* Set bits for paths which are already in the target state. */
        for (i = 0; i < 8; i++) {
                lpm = 0x80 >> i;
                if ((cdev->private->pgid_valid_mask & lpm) == 0)
@@ -282,10 +282,10 @@ static u8 pgid_to_vpm(struct ccw_device *cdev)
                        if (pgid->inf.ps.state3 != SNID_STATE3_SINGLE_PATH)
                                continue;
                }
-               vpm |= lpm;
+               donepm |= lpm;
        }
 
-       return vpm;
+       return donepm;
 }
 
 static void pgid_fill(struct ccw_device *cdev, struct pgid *pgid)
@@ -307,6 +307,7 @@ static void snid_done(struct ccw_device *cdev, int rc)
        int mismatch = 0;
        int reserved = 0;
        int reset = 0;
+       u8 donepm;
 
        if (rc)
                goto out;
@@ -316,18 +317,20 @@ static void snid_done(struct ccw_device *cdev, int rc)
        else if (mismatch)
                rc = -EOPNOTSUPP;
        else {
-               sch->vpm = pgid_to_vpm(cdev);
+               donepm = pgid_to_donepm(cdev);
+               sch->vpm = donepm & sch->opm;
+               cdev->private->pgid_todo_mask &= ~donepm;
                pgid_fill(cdev, pgid);
        }
 out:
        CIO_MSG_EVENT(2, "snid: device 0.%x.%04x: rc=%d pvm=%02x vpm=%02x "
-                     "mism=%d rsvd=%d reset=%d\n", id->ssid, id->devno, rc,
-                     cdev->private->pgid_valid_mask, sch->vpm, mismatch,
-                     reserved, reset);
+                     "todo=%02x mism=%d rsvd=%d reset=%d\n", id->ssid,
+                     id->devno, rc, cdev->private->pgid_valid_mask, sch->vpm,
+                     cdev->private->pgid_todo_mask, mismatch, reserved, reset);
        switch (rc) {
        case 0:
                /* Anything left to do? */
-               if (sch->vpm == sch->schib.pmcw.pam) {
+               if (cdev->private->pgid_todo_mask == 0) {
                        verify_done(cdev, sch->vpm == 0 ? -EACCES : 0);
                        return;
                }
@@ -411,6 +414,7 @@ static void verify_start(struct ccw_device *cdev)
        struct ccw_dev_id *devid = &cdev->private->dev_id;
 
        sch->vpm = 0;
+       sch->lpm = sch->schib.pmcw.pam;
        /* Initialize request data. */
        memset(req, 0, sizeof(*req));
        req->timeout    = PGID_TIMEOUT;
@@ -442,11 +446,14 @@ static void verify_start(struct ccw_device *cdev)
  */
 void ccw_device_verify_start(struct ccw_device *cdev)
 {
+       struct subchannel *sch = to_subchannel(cdev->dev.parent);
+
        CIO_TRACE_EVENT(4, "vrfy");
        CIO_HEX_EVENT(4, &cdev->private->dev_id, sizeof(cdev->private->dev_id));
        /* Initialize PGID data. */
        memset(cdev->private->pgid, 0, sizeof(cdev->private->pgid));
        cdev->private->pgid_valid_mask = 0;
+       cdev->private->pgid_todo_mask = sch->schib.pmcw.pam;
        /*
         * Initialize pathgroup and multipath state with target values.
         * They may change in the course of path verification.
index 61677dfbdc9b0d13f98202672718bdf14437b7c8..ca5e9bb9d45805c7b4223d1a41b61e324292621e 100644 (file)
@@ -163,7 +163,7 @@ void tcw_finalize(struct tcw *tcw, int num_tidaws)
        /* Add tcat to tccb. */
        tccb = tcw_get_tccb(tcw);
        tcat = (struct tccb_tcat *) &tccb->tca[tca_size(tccb)];
-       memset(tcat, 0, sizeof(tcat));
+       memset(tcat, 0, sizeof(*tcat));
        /* Calculate tcw input/output count and tcat transport count. */
        count = calc_dcw_count(tccb);
        if (tcw->w && (tcw->flags & TCW_FLAGS_OUTPUT_TIDA))
@@ -269,7 +269,7 @@ EXPORT_SYMBOL(tccb_init);
  */
 void tsb_init(struct tsb *tsb)
 {
-       memset(tsb, 0, sizeof(tsb));
+       memset(tsb, 0, sizeof(*tsb));
 }
 EXPORT_SYMBOL(tsb_init);
 
index d72ae4c93af9beb497c8d4de9a01a4c70f0ac9aa..b9ce712a7f25847fcd752585c256273ab28f323a 100644 (file)
@@ -150,6 +150,7 @@ struct ccw_device_private {
        struct ccw_request req;         /* internal I/O request */
        int iretry;
        u8 pgid_valid_mask;             /* mask of valid PGIDs */
+       u8 pgid_todo_mask;              /* mask of PGIDs to be adjusted */
        struct {
                unsigned int fast:1;    /* post with "channel end" */
                unsigned int repall:1;  /* report every interrupt status */
index 4be6e84b9599c4aa905cf085a1ee75220ac5e1eb..b2275c5000e7c458b1afaf9c2542c25a3e7dc976 100644 (file)
@@ -486,7 +486,8 @@ static int get_inbound_buffer_frontier(struct qdio_q *q)
        case SLSB_P_INPUT_PRIMED:
                inbound_primed(q, count);
                q->first_to_check = add_buf(q->first_to_check, count);
-               atomic_sub(count, &q->nr_buf_used);
+               if (atomic_sub(count, &q->nr_buf_used) == 0)
+                       qdio_perf_stat_inc(&perf_stats.inbound_queue_full);
                break;
        case SLSB_P_INPUT_ERROR:
                announce_buffer_error(q, count);
index 968e3c7c263269bda6c7d04261871729ce8bbbe6..54f7c325a3e6a970ab3d063f0ed35a447c5cf6d6 100644 (file)
@@ -64,6 +64,8 @@ static int qdio_perf_proc_show(struct seq_file *m, void *v)
                   (long)atomic_long_read(&perf_stats.fast_requeue));
        seq_printf(m, "Number of outbound target full condition\t: %li\n",
                   (long)atomic_long_read(&perf_stats.outbound_target_full));
+       seq_printf(m, "Number of inbound queue full condition\t\t: %li\n",
+                  (long)atomic_long_read(&perf_stats.inbound_queue_full));
        seq_printf(m, "Number of outbound tasklet mod_timer calls\t: %li\n",
                   (long)atomic_long_read(&perf_stats.debug_tl_out_timer));
        seq_printf(m, "Number of stop polling calls\t\t\t: %li\n",
index ff4504ce1e3c0ad5577e86d0642895d08b8c7924..12454231dc8b0bc4cb5fbbffde804c4f869937c4 100644 (file)
@@ -36,6 +36,7 @@ struct qdio_perf_stats {
        atomic_long_t outbound_handler;
        atomic_long_t fast_requeue;
        atomic_long_t outbound_target_full;
+       atomic_long_t inbound_queue_full;
 
        /* for debugging */
        atomic_long_t debug_tl_out_timer;
index 18d54fc21ce90b43b9e43418a4b3a47e9e6e15ae..8c2dea5fa2b48b6bd559cc5e77c49c8f26e76956 100644 (file)
@@ -48,7 +48,6 @@ static void set_impl_params(struct qdio_irq *irq_ptr,
        if (!irq_ptr)
                return;
 
-       WARN_ON((unsigned long)&irq_ptr->qib & 0xff);
        irq_ptr->qib.pfmt = qib_param_field_format;
        if (qib_param_field)
                memcpy(irq_ptr->qib.parm, qib_param_field,
@@ -82,14 +81,12 @@ static int __qdio_allocate_qs(struct qdio_q **irq_ptr_qs, int nr_queues)
                q = kmem_cache_alloc(qdio_q_cache, GFP_KERNEL);
                if (!q)
                        return -ENOMEM;
-               WARN_ON((unsigned long)q & 0xff);
 
                q->slib = (struct slib *) __get_free_page(GFP_KERNEL);
                if (!q->slib) {
                        kmem_cache_free(qdio_q_cache, q);
                        return -ENOMEM;
                }
-               WARN_ON((unsigned long)q->slib & 0x7ff);
                irq_ptr_qs[i] = q;
        }
        return 0;
@@ -131,7 +128,7 @@ static void setup_storage_lists(struct qdio_q *q, struct qdio_irq *irq_ptr,
        /* fill in sbal */
        for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++) {
                q->sbal[j] = *sbals_array++;
-               WARN_ON((unsigned long)q->sbal[j] & 0xff);
+               BUG_ON((unsigned long)q->sbal[j] & 0xff);
        }
 
        /* fill in slib */
@@ -147,11 +144,6 @@ static void setup_storage_lists(struct qdio_q *q, struct qdio_irq *irq_ptr,
        /* fill in sl */
        for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
                q->sl->element[j].sbal = (unsigned long)q->sbal[j];
-
-       DBF_EVENT("sl-slsb-sbal");
-       DBF_HEX(q->sl, sizeof(void *));
-       DBF_HEX(&q->slsb, sizeof(void *));
-       DBF_HEX(q->sbal, sizeof(void *));
 }
 
 static void setup_queues(struct qdio_irq *irq_ptr,
index 98c04cac43c1d87467ee60f43807c0dbc654409b..65ebee0a326674432d3e1d0e092d6afc3d02ff2b 100644 (file)
@@ -159,7 +159,7 @@ static void netiucv_pm_complete(struct device *);
 static int netiucv_pm_freeze(struct device *);
 static int netiucv_pm_restore_thaw(struct device *);
 
-static struct dev_pm_ops netiucv_pm_ops = {
+static const struct dev_pm_ops netiucv_pm_ops = {
        .prepare = netiucv_pm_prepare,
        .complete = netiucv_pm_complete,
        .freeze = netiucv_pm_freeze,
index 3012355f8304e875953a732d2ab4b4e6dde1681f..67f2485d2372512376c770031aac583201ad27d9 100644 (file)
@@ -168,7 +168,7 @@ static int smsg_pm_restore_thaw(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops smsg_pm_ops = {
+static const struct dev_pm_ops smsg_pm_ops = {
        .freeze = smsg_pm_freeze,
        .thaw = smsg_pm_restore_thaw,
        .restore = smsg_pm_restore_thaw,
index 3bf75924741ffbce58349e3981f254011fe65b9d..84d3bbaa95e7868f8cb3d2aa20e3844c721e79c6 100644 (file)
@@ -76,6 +76,7 @@
                  Fix bug in twa_get_param() on 4GB+.
                  Use pci_resource_len() for ioremap().
    2.26.02.012 - Add power management support.
+   2.26.02.013 - Fix bug in twa_load_sgl().
 */
 
 #include <linux/module.h>
 #include "3w-9xxx.h"
 
 /* Globals */
-#define TW_DRIVER_VERSION "2.26.02.012"
+#define TW_DRIVER_VERSION "2.26.02.013"
 static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
 static unsigned int twa_device_extension_count;
 static int twa_major = -1;
@@ -1382,10 +1383,12 @@ static void twa_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_comm
                newcommand = &full_command_packet->command.newcommand;
                newcommand->request_id__lunl =
                        cpu_to_le16(TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->request_id__lunl), request_id));
-               newcommand->sg_list[0].address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1);
-               newcommand->sg_list[0].length = cpu_to_le32(length);
+               if (length) {
+                       newcommand->sg_list[0].address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1);
+                       newcommand->sg_list[0].length = cpu_to_le32(length);
+               }
                newcommand->sgl_entries__lunh =
-                       cpu_to_le16(TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->sgl_entries__lunh), 1));
+                       cpu_to_le16(TW_REQ_LUN_IN(TW_LUN_OUT(newcommand->sgl_entries__lunh), length ? 1 : 0));
        } else {
                oldcommand = &full_command_packet->command.oldcommand;
                oldcommand->request_id = request_id;
index 36900c71a592a76355415897393a8118f1e6464f..9191d1ea6451a5e1cbbdac3d1ec34e5ba640888a 100644 (file)
@@ -388,6 +388,16 @@ config BLK_DEV_3W_XXXX_RAID
          Please read the comments at the top of
          <file:drivers/scsi/3w-xxxx.c>.
 
+config SCSI_HPSA
+       tristate "HP Smart Array SCSI driver"
+       depends on PCI && SCSI
+       help
+         This driver supports HP Smart Array Controllers (circa 2009).
+         It is a SCSI alternative to the cciss driver, which is a block
+         driver.  Anyone wishing to use HP Smart Array controllers who
+         would prefer the devices be presented to linux as SCSI devices,
+         rather than as generic block devices should say Y here.
+
 config SCSI_3W_9XXX
        tristate "3ware 9xxx SATA-RAID support"
        depends on PCI && SCSI
index 280d3c657d60f492671bdc7eaec732d515729a0c..92a8c500b23d8f384c601419097b0a245484c5b4 100644 (file)
@@ -91,6 +91,7 @@ obj-$(CONFIG_SCSI_BFA_FC)     += bfa/
 obj-$(CONFIG_SCSI_PAS16)       += pas16.o
 obj-$(CONFIG_SCSI_T128)                += t128.o
 obj-$(CONFIG_SCSI_DMX3191D)    += dmx3191d.o
+obj-$(CONFIG_SCSI_HPSA)                += hpsa.o
 obj-$(CONFIG_SCSI_DTC3280)     += dtc.o
 obj-$(CONFIG_SCSI_SYM53C8XX_2) += sym53c8xx_2/
 obj-$(CONFIG_SCSI_ZALON)       += zalon7xx.o
index 698a527d6ccad07be1bad6a2eb9cf2a3e9513011..f008708f1b08e440bc0985ff03eec004cb4346ee 100644 (file)
@@ -135,11 +135,15 @@ int beiscsi_process_mcc(struct beiscsi_hba *phba)
        while ((compl = be_mcc_compl_get(phba))) {
                if (compl->flags & CQE_FLAGS_ASYNC_MASK) {
                        /* Interpret flags as an async trailer */
-                       BUG_ON(!is_link_state_evt(compl->flags));
+                       if (is_link_state_evt(compl->flags))
+                               /* Interpret compl as a async link evt */
+                               beiscsi_async_link_state_process(phba,
+                                  (struct be_async_event_link_state *) compl);
+                       else
+                               SE_DEBUG(DBG_LVL_1,
+                                        " Unsupported Async Event, flags"
+                                        " = 0x%08x \n", compl->flags);
 
-                       /* Interpret compl as a async link evt */
-                       beiscsi_async_link_state_process(phba,
-                               (struct be_async_event_link_state *) compl);
                } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) {
                                status = be_mcc_compl_process(ctrl, compl);
                                atomic_dec(&phba->ctrl.mcc_obj.q.used);
index 2b973f3c2eb2a7da1e0166c4713947c05d480283..6cf9dc37d78b4883e59ee40cf6f19aaea80636da 100644 (file)
@@ -684,6 +684,7 @@ extern unsigned int error_mask1, error_mask2;
 extern u64 iscsi_error_mask;
 extern unsigned int en_tcp_dack;
 extern unsigned int event_coal_div;
+extern unsigned int event_coal_min;
 
 extern struct scsi_transport_template *bnx2i_scsi_xport_template;
 extern struct iscsi_transport bnx2i_iscsi_transport;
index 5c8d7630c13e4c0a403aeacc4cf1533ef40579c0..1af578dec276da2b2254cf85451d9c4c235503f0 100644 (file)
@@ -133,20 +133,38 @@ void bnx2i_arm_cq_event_coalescing(struct bnx2i_endpoint *ep, u8 action)
 {
        struct bnx2i_5771x_cq_db *cq_db;
        u16 cq_index;
+       u16 next_index;
+       u32 num_active_cmds;
 
+
+       /* Coalesce CQ entries only on 10G devices */
        if (!test_bit(BNX2I_NX2_DEV_57710, &ep->hba->cnic_dev_type))
                return;
 
+       /* Do not update CQ DB multiple times before firmware writes
+        * '0xFFFF' to CQDB->SQN field. Deviation may cause spurious
+        * interrupts and other unwanted results
+        */
+       cq_db = (struct bnx2i_5771x_cq_db *) ep->qp.cq_pgtbl_virt;
+       if (cq_db->sqn[0] && cq_db->sqn[0] != 0xFFFF)
+               return;
+
        if (action == CNIC_ARM_CQE) {
-               cq_index = ep->qp.cqe_exp_seq_sn +
-                          ep->num_active_cmds / event_coal_div;
-               cq_index %= (ep->qp.cqe_size * 2 + 1);
-               if (!cq_index) {
+               num_active_cmds = ep->num_active_cmds;
+               if (num_active_cmds <= event_coal_min)
+                       next_index = 1;
+               else
+                       next_index = event_coal_min +
+                               (num_active_cmds - event_coal_min) / event_coal_div;
+               if (!next_index)
+                       next_index = 1;
+               cq_index = ep->qp.cqe_exp_seq_sn + next_index - 1;
+               if (cq_index > ep->qp.cqe_size * 2)
+                       cq_index -= ep->qp.cqe_size * 2;
+               if (!cq_index)
                        cq_index = 1;
-                       cq_db = (struct bnx2i_5771x_cq_db *)
-                                       ep->qp.cq_pgtbl_virt;
-                       cq_db->sqn[0] = cq_index;
-               }
+
+               cq_db->sqn[0] = cq_index;
        }
 }
 
@@ -366,6 +384,7 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
        struct bnx2i_cmd *bnx2i_cmd;
        struct bnx2i_tmf_request *tmfabort_wqe;
        u32 dword;
+       u32 scsi_lun[2];
 
        bnx2i_cmd = (struct bnx2i_cmd *)mtask->dd_data;
        tmfabort_hdr = (struct iscsi_tm *)mtask->hdr;
@@ -376,27 +395,35 @@ int bnx2i_send_iscsi_tmf(struct bnx2i_conn *bnx2i_conn,
        tmfabort_wqe->op_attr = 0;
        tmfabort_wqe->op_attr =
                ISCSI_TMF_REQUEST_ALWAYS_ONE | ISCSI_TM_FUNC_ABORT_TASK;
-       tmfabort_wqe->lun[0] = be32_to_cpu(tmfabort_hdr->lun[0]);
-       tmfabort_wqe->lun[1] = be32_to_cpu(tmfabort_hdr->lun[1]);
 
        tmfabort_wqe->itt = (mtask->itt | (ISCSI_TASK_TYPE_MPATH << 14));
        tmfabort_wqe->reserved2 = 0;
        tmfabort_wqe->cmd_sn = be32_to_cpu(tmfabort_hdr->cmdsn);
 
        ctask = iscsi_itt_to_task(conn, tmfabort_hdr->rtt);
-       if (!ctask || ctask->sc)
+       if (!ctask || !ctask->sc)
                /*
                 * the iscsi layer must have completed the cmd while this
                 * was starting up.
+                *
+                * Note: In the case of a SCSI cmd timeout, the task's sc
+                *       is still active; hence ctask->sc != 0
+                *       In this case, the task must be aborted
                 */
                return 0;
+
        ref_sc = ctask->sc;
 
+       /* Retrieve LUN directly from the ref_sc */
+       int_to_scsilun(ref_sc->device->lun, (struct scsi_lun *) scsi_lun);
+       tmfabort_wqe->lun[0] = be32_to_cpu(scsi_lun[0]);
+       tmfabort_wqe->lun[1] = be32_to_cpu(scsi_lun[1]);
+
        if (ref_sc->sc_data_direction == DMA_TO_DEVICE)
                dword = (ISCSI_TASK_TYPE_WRITE << ISCSI_CMD_REQUEST_TYPE_SHIFT);
        else
                dword = (ISCSI_TASK_TYPE_READ << ISCSI_CMD_REQUEST_TYPE_SHIFT);
-       tmfabort_wqe->ref_itt = (dword | tmfabort_hdr->rtt);
+       tmfabort_wqe->ref_itt = (dword | (tmfabort_hdr->rtt & ISCSI_ITT_MASK));
        tmfabort_wqe->ref_cmd_sn = be32_to_cpu(tmfabort_hdr->refcmdsn);
 
        tmfabort_wqe->bd_list_addr_lo = (u32) bnx2i_conn->hba->mp_bd_dma;
index 0c4210d48ee8a7d8932e0b1431c9ea4fb4c5b973..6d8172e781cff03c976223e49c7e8fc30812b6b5 100644 (file)
@@ -17,8 +17,8 @@ static struct list_head adapter_list = LIST_HEAD_INIT(adapter_list);
 static u32 adapter_count;
 
 #define DRV_MODULE_NAME                "bnx2i"
-#define DRV_MODULE_VERSION     "2.0.1e"
-#define DRV_MODULE_RELDATE     "June 22, 2009"
+#define DRV_MODULE_VERSION     "2.1.0"
+#define DRV_MODULE_RELDATE     "Dec 06, 2009"
 
 static char version[] __devinitdata =
                "Broadcom NetXtreme II iSCSI Driver " DRV_MODULE_NAME \
@@ -32,6 +32,10 @@ MODULE_VERSION(DRV_MODULE_VERSION);
 
 static DEFINE_MUTEX(bnx2i_dev_lock);
 
+unsigned int event_coal_min = 24;
+module_param(event_coal_min, int, 0664);
+MODULE_PARM_DESC(event_coal_min, "Event Coalescing Minimum Commands");
+
 unsigned int event_coal_div = 1;
 module_param(event_coal_div, int, 0664);
 MODULE_PARM_DESC(event_coal_div, "Event Coalescing Divide Factor");
@@ -83,8 +87,12 @@ void bnx2i_identify_device(struct bnx2i_hba *hba)
                set_bit(BNX2I_NX2_DEV_5709, &hba->cnic_dev_type);
                hba->mail_queue_access = BNX2I_MQ_BIN_MODE;
        } else if (hba->pci_did == PCI_DEVICE_ID_NX2_57710 ||
-                  hba->pci_did == PCI_DEVICE_ID_NX2_57711)
+                  hba->pci_did == PCI_DEVICE_ID_NX2_57711 ||
+                  hba->pci_did == PCI_DEVICE_ID_NX2_57711E)
                set_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type);
+       else
+               printk(KERN_ALERT "bnx2i: unknown device, 0x%x\n",
+                                 hba->pci_did);
 }
 
 
@@ -363,7 +371,7 @@ static int __init bnx2i_mod_init(void)
 
        printk(KERN_INFO "%s", version);
 
-       if (!is_power_of_2(sq_size))
+       if (sq_size && !is_power_of_2(sq_size))
                sq_size = roundup_pow_of_two(sq_size);
 
        mutex_init(&bnx2i_dev_lock);
index 132898c88d5e8808b85490acdc96b5440f5fe2df..33b2294625bbf336f308af94a37045b87012ec5e 100644 (file)
@@ -485,7 +485,6 @@ static int bnx2i_setup_cmd_pool(struct bnx2i_hba *hba,
                struct iscsi_task *task = session->cmds[i];
                struct bnx2i_cmd *cmd = task->dd_data;
 
-               /* Anil */
                task->hdr = &cmd->hdr;
                task->hdr_max = sizeof(struct iscsi_hdr);
 
@@ -765,7 +764,6 @@ struct bnx2i_hba *bnx2i_alloc_hba(struct cnic_dev *cnic)
        hba->pci_svid = hba->pcidev->subsystem_vendor;
        hba->pci_func = PCI_FUNC(hba->pcidev->devfn);
        hba->pci_devno = PCI_SLOT(hba->pcidev->devfn);
-       bnx2i_identify_device(hba);
 
        bnx2i_identify_device(hba);
        bnx2i_setup_host_queue_size(hba, shost);
index c1d5be4adf9c6cdfe7fa530c93821f22f091ba97..26ffdcd5a43701db2792a3187f23ac1ab845c601 100644 (file)
@@ -291,7 +291,7 @@ static void act_open_req_arp_failure(struct t3cdev *dev, struct sk_buff *skb)
        c3cn_hold(c3cn);
        spin_lock_bh(&c3cn->lock);
        if (c3cn->state == C3CN_STATE_CONNECTING)
-               fail_act_open(c3cn, EHOSTUNREACH);
+               fail_act_open(c3cn, -EHOSTUNREACH);
        spin_unlock_bh(&c3cn->lock);
        c3cn_put(c3cn);
        __kfree_skb(skb);
@@ -792,18 +792,18 @@ static int act_open_rpl_status_to_errno(int status)
 {
        switch (status) {
        case CPL_ERR_CONN_RESET:
-               return ECONNREFUSED;
+               return -ECONNREFUSED;
        case CPL_ERR_ARP_MISS:
-               return EHOSTUNREACH;
+               return -EHOSTUNREACH;
        case CPL_ERR_CONN_TIMEDOUT:
-               return ETIMEDOUT;
+               return -ETIMEDOUT;
        case CPL_ERR_TCAM_FULL:
-               return ENOMEM;
+               return -ENOMEM;
        case CPL_ERR_CONN_EXIST:
                cxgb3i_log_error("ACTIVE_OPEN_RPL: 4-tuple in use\n");
-               return EADDRINUSE;
+               return -EADDRINUSE;
        default:
-               return EIO;
+               return -EIO;
        }
 }
 
@@ -817,7 +817,7 @@ static void act_open_retry_timer(unsigned long data)
        spin_lock_bh(&c3cn->lock);
        skb = alloc_skb(sizeof(struct cpl_act_open_req), GFP_ATOMIC);
        if (!skb)
-               fail_act_open(c3cn, ENOMEM);
+               fail_act_open(c3cn, -ENOMEM);
        else {
                skb->sk = (struct sock *)c3cn;
                set_arp_failure_handler(skb, act_open_req_arp_failure);
@@ -966,14 +966,14 @@ static int abort_status_to_errno(struct s3_conn *c3cn, int abort_reason,
        case CPL_ERR_BAD_SYN: /* fall through */
        case CPL_ERR_CONN_RESET:
                return c3cn->state > C3CN_STATE_ESTABLISHED ?
-                       EPIPE : ECONNRESET;
+                       -EPIPE : -ECONNRESET;
        case CPL_ERR_XMIT_TIMEDOUT:
        case CPL_ERR_PERSIST_TIMEDOUT:
        case CPL_ERR_FINWAIT2_TIMEDOUT:
        case CPL_ERR_KEEPALIVE_TIMEDOUT:
-               return ETIMEDOUT;
+               return -ETIMEDOUT;
        default:
-               return EIO;
+               return -EIO;
        }
 }
 
@@ -1563,7 +1563,7 @@ free_tid:
        s3_free_atid(cdev, c3cn->tid);
        c3cn->tid = 0;
 out_err:
-       return -1;
+       return -EINVAL;
 }
 
 
index 70910507117791b66e50ebc7820590c0cf935bfa..1fe3b0f1f3c94353fbda92df4769bfb82c28a0bc 100644 (file)
@@ -388,8 +388,8 @@ int cxgb3i_conn_xmit_pdu(struct iscsi_task *task)
        if (err > 0) {
                int pdulen = err;
 
-       cxgb3i_tx_debug("task 0x%p, skb 0x%p, len %u/%u, rv %d.\n",
-                       task, skb, skb->len, skb->data_len, err);
+               cxgb3i_tx_debug("task 0x%p, skb 0x%p, len %u/%u, rv %d.\n",
+                               task, skb, skb->len, skb->data_len, err);
 
                if (task->conn->hdrdgst_en)
                        pdulen += ISCSI_DIGEST_SIZE;
index 47cfe1c49c3ec8ec3162fdd6fdb8cb06d6090ad4..1a660191a90547039ae7b5815e3ad8620a8b79d3 100644 (file)
@@ -748,6 +748,8 @@ static const struct scsi_dh_devlist rdac_dev_list[] = {
        {"IBM", "1724"},
        {"IBM", "1726"},
        {"IBM", "1742"},
+       {"IBM", "1745"},
+       {"IBM", "1746"},
        {"IBM", "1814"},
        {"IBM", "1815"},
        {"IBM", "1818"},
index a30ffaa1222c4fa3e1eb05b0f8f780bd10d5dbe8..10be9f36a4cc01b3ce9ce14a0d78f88dd1a6a30a 100644 (file)
@@ -101,6 +101,8 @@ static int fcoe_cpu_callback(struct notifier_block *, unsigned long, void *);
 
 static int fcoe_create(const char *, struct kernel_param *);
 static int fcoe_destroy(const char *, struct kernel_param *);
+static int fcoe_enable(const char *, struct kernel_param *);
+static int fcoe_disable(const char *, struct kernel_param *);
 
 static struct fc_seq *fcoe_elsct_send(struct fc_lport *,
                                      u32 did, struct fc_frame *,
@@ -115,10 +117,16 @@ static void fcoe_get_lesb(struct fc_lport *, struct fc_els_lesb *);
 
 module_param_call(create, fcoe_create, NULL, NULL, S_IWUSR);
 __MODULE_PARM_TYPE(create, "string");
-MODULE_PARM_DESC(create, "Create fcoe fcoe using net device passed in.");
+MODULE_PARM_DESC(create, " Creates fcoe instance on a ethernet interface");
 module_param_call(destroy, fcoe_destroy, NULL, NULL, S_IWUSR);
 __MODULE_PARM_TYPE(destroy, "string");
-MODULE_PARM_DESC(destroy, "Destroy fcoe fcoe");
+MODULE_PARM_DESC(destroy, " Destroys fcoe instance on a ethernet interface");
+module_param_call(enable, fcoe_enable, NULL, NULL, S_IWUSR);
+__MODULE_PARM_TYPE(enable, "string");
+MODULE_PARM_DESC(enable, " Enables fcoe on a ethernet interface.");
+module_param_call(disable, fcoe_disable, NULL, NULL, S_IWUSR);
+__MODULE_PARM_TYPE(disable, "string");
+MODULE_PARM_DESC(disable, " Disables fcoe on a ethernet interface.");
 
 /* notification function for packets from net device */
 static struct notifier_block fcoe_notifier = {
@@ -544,6 +552,23 @@ static void fcoe_queue_timer(ulong lport)
        fcoe_check_wait_queue((struct fc_lport *)lport, NULL);
 }
 
+/**
+ * fcoe_get_wwn() - Get the world wide name from LLD if it supports it
+ * @netdev: the associated net device
+ * @wwn: the output WWN
+ * @type: the type of WWN (WWPN or WWNN)
+ *
+ * Returns: 0 for success
+ */
+static int fcoe_get_wwn(struct net_device *netdev, u64 *wwn, int type)
+{
+       const struct net_device_ops *ops = netdev->netdev_ops;
+
+       if (ops->ndo_fcoe_get_wwn)
+               return ops->ndo_fcoe_get_wwn(netdev, wwn, type);
+       return -EINVAL;
+}
+
 /**
  * fcoe_netdev_config() - Set up net devive for SW FCoE
  * @lport:  The local port that is associated with the net device
@@ -611,9 +636,13 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
                 */
                if (netdev->priv_flags & IFF_802_1Q_VLAN)
                        vid = vlan_dev_vlan_id(netdev);
-               wwnn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 1, 0);
+
+               if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN))
+                       wwnn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 1, 0);
                fc_set_wwnn(lport, wwnn);
-               wwpn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr, 2, vid);
+               if (fcoe_get_wwn(netdev, &wwpn, NETDEV_FCOE_WWPN))
+                       wwpn = fcoe_wwn_from_mac(fcoe->ctlr.ctl_src_addr,
+                                                2, vid);
                fc_set_wwpn(lport, wwpn);
        }
 
@@ -1231,7 +1260,7 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
                                "CPU.\n");
 
                spin_unlock_bh(&fps->fcoe_rx_list.lock);
-               cpu = first_cpu(cpu_online_map);
+               cpu = cpumask_first(cpu_online_mask);
                fps = &per_cpu(fcoe_percpu, cpu);
                spin_lock_bh(&fps->fcoe_rx_list.lock);
                if (!fps->thread) {
@@ -1837,6 +1866,104 @@ static struct net_device *fcoe_if_to_netdev(const char *buffer)
        return NULL;
 }
 
+/**
+ * fcoe_disable() - Disables a FCoE interface
+ * @buffer: The name of the Ethernet interface to be disabled
+ * @kp:            The associated kernel parameter
+ *
+ * Called from sysfs.
+ *
+ * Returns: 0 for success
+ */
+static int fcoe_disable(const char *buffer, struct kernel_param *kp)
+{
+       struct fcoe_interface *fcoe;
+       struct net_device *netdev;
+       int rc = 0;
+
+       mutex_lock(&fcoe_config_mutex);
+#ifdef CONFIG_FCOE_MODULE
+       /*
+        * Make sure the module has been initialized, and is not about to be
+        * removed.  Module paramter sysfs files are writable before the
+        * module_init function is called and after module_exit.
+        */
+       if (THIS_MODULE->state != MODULE_STATE_LIVE) {
+               rc = -ENODEV;
+               goto out_nodev;
+       }
+#endif
+
+       netdev = fcoe_if_to_netdev(buffer);
+       if (!netdev) {
+               rc = -ENODEV;
+               goto out_nodev;
+       }
+
+       rtnl_lock();
+       fcoe = fcoe_hostlist_lookup_port(netdev);
+       rtnl_unlock();
+
+       if (fcoe)
+               fc_fabric_logoff(fcoe->ctlr.lp);
+       else
+               rc = -ENODEV;
+
+       dev_put(netdev);
+out_nodev:
+       mutex_unlock(&fcoe_config_mutex);
+       return rc;
+}
+
+/**
+ * fcoe_enable() - Enables a FCoE interface
+ * @buffer: The name of the Ethernet interface to be enabled
+ * @kp:     The associated kernel parameter
+ *
+ * Called from sysfs.
+ *
+ * Returns: 0 for success
+ */
+static int fcoe_enable(const char *buffer, struct kernel_param *kp)
+{
+       struct fcoe_interface *fcoe;
+       struct net_device *netdev;
+       int rc = 0;
+
+       mutex_lock(&fcoe_config_mutex);
+#ifdef CONFIG_FCOE_MODULE
+       /*
+        * Make sure the module has been initialized, and is not about to be
+        * removed.  Module paramter sysfs files are writable before the
+        * module_init function is called and after module_exit.
+        */
+       if (THIS_MODULE->state != MODULE_STATE_LIVE) {
+               rc = -ENODEV;
+               goto out_nodev;
+       }
+#endif
+
+       netdev = fcoe_if_to_netdev(buffer);
+       if (!netdev) {
+               rc = -ENODEV;
+               goto out_nodev;
+       }
+
+       rtnl_lock();
+       fcoe = fcoe_hostlist_lookup_port(netdev);
+       rtnl_unlock();
+
+       if (fcoe)
+               rc = fc_fabric_login(fcoe->ctlr.lp);
+       else
+               rc = -ENODEV;
+
+       dev_put(netdev);
+out_nodev:
+       mutex_unlock(&fcoe_config_mutex);
+       return rc;
+}
+
 /**
  * fcoe_destroy() - Destroy a FCoE interface
  * @buffer: The name of the Ethernet interface to be destroyed
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
new file mode 100644 (file)
index 0000000..bb96fdd
--- /dev/null
@@ -0,0 +1,3531 @@
+/*
+ *    Disk Array driver for HP Smart Array SAS controllers
+ *    Copyright 2000, 2009 Hewlett-Packard Development Company, L.P.
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; version 2 of the License.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ *    NON INFRINGEMENT.  See the GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *    Questions/Comments/Bugfixes to iss_storagedev@hp.com
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/timer.h>
+#include <linux/seq_file.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
+#include <linux/compat.h>
+#include <linux/blktrace_api.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
+#include <linux/dma-mapping.h>
+#include <linux/completion.h>
+#include <linux/moduleparam.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <linux/cciss_ioctl.h>
+#include <linux/string.h>
+#include <linux/bitmap.h>
+#include <asm/atomic.h>
+#include <linux/kthread.h>
+#include "hpsa_cmd.h"
+#include "hpsa.h"
+
+/* HPSA_DRIVER_VERSION must be 3 byte values (0-255) separated by '.' */
+#define HPSA_DRIVER_VERSION "1.0.0"
+#define DRIVER_NAME "HP HPSA Driver (v " HPSA_DRIVER_VERSION ")"
+
+/* How long to wait (in milliseconds) for board to go into simple mode */
+#define MAX_CONFIG_WAIT 30000
+#define MAX_IOCTL_CONFIG_WAIT 1000
+
+/*define how many times we will try a command because of bus resets */
+#define MAX_CMD_RETRIES 3
+
+/* Embedded module documentation macros - see modules.h */
+MODULE_AUTHOR("Hewlett-Packard Company");
+MODULE_DESCRIPTION("Driver for HP Smart Array Controller version " \
+       HPSA_DRIVER_VERSION);
+MODULE_SUPPORTED_DEVICE("HP Smart Array Controllers");
+MODULE_VERSION(HPSA_DRIVER_VERSION);
+MODULE_LICENSE("GPL");
+
+static int hpsa_allow_any;
+module_param(hpsa_allow_any, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(hpsa_allow_any,
+               "Allow hpsa driver to access unknown HP Smart Array hardware");
+
+/* define the PCI info for the cards we can control */
+static const struct pci_device_id hpsa_pci_device_id[] = {
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSC,     0x103C, 0x3223},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSC,     0x103C, 0x3234},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSC,     0x103C, 0x323D},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3241},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3243},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3245},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3247},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x3249},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x324a},
+       {PCI_VENDOR_ID_HP,     PCI_DEVICE_ID_HP_CISSE,     0x103C, 0x324b},
+       {PCI_VENDOR_ID_HP,     PCI_ANY_ID,             PCI_ANY_ID, PCI_ANY_ID,
+               PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
+       {0,}
+};
+
+MODULE_DEVICE_TABLE(pci, hpsa_pci_device_id);
+
+/*  board_id = Subsystem Device ID & Vendor ID
+ *  product = Marketing Name for the board
+ *  access = Address of the struct of function pointers
+ */
+static struct board_type products[] = {
+       {0x3223103C, "Smart Array P800", &SA5_access},
+       {0x3234103C, "Smart Array P400", &SA5_access},
+       {0x323d103c, "Smart Array P700M", &SA5_access},
+       {0x3241103C, "Smart Array P212", &SA5_access},
+       {0x3243103C, "Smart Array P410", &SA5_access},
+       {0x3245103C, "Smart Array P410i", &SA5_access},
+       {0x3247103C, "Smart Array P411", &SA5_access},
+       {0x3249103C, "Smart Array P812", &SA5_access},
+       {0x324a103C, "Smart Array P712m", &SA5_access},
+       {0x324b103C, "Smart Array P711m", &SA5_access},
+       {0xFFFF103C, "Unknown Smart Array", &SA5_access},
+};
+
+static int number_of_controllers;
+
+static irqreturn_t do_hpsa_intr(int irq, void *dev_id);
+static int hpsa_ioctl(struct scsi_device *dev, int cmd, void *arg);
+static void start_io(struct ctlr_info *h);
+
+#ifdef CONFIG_COMPAT
+static int hpsa_compat_ioctl(struct scsi_device *dev, int cmd, void *arg);
+#endif
+
+static void cmd_free(struct ctlr_info *h, struct CommandList *c);
+static void cmd_special_free(struct ctlr_info *h, struct CommandList *c);
+static struct CommandList *cmd_alloc(struct ctlr_info *h);
+static struct CommandList *cmd_special_alloc(struct ctlr_info *h);
+static void fill_cmd(struct CommandList *c, __u8 cmd, struct ctlr_info *h,
+       void *buff, size_t size, __u8 page_code, unsigned char *scsi3addr,
+       int cmd_type);
+
+static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd,
+               void (*done)(struct scsi_cmnd *));
+
+static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd);
+static int hpsa_slave_alloc(struct scsi_device *sdev);
+static void hpsa_slave_destroy(struct scsi_device *sdev);
+
+static ssize_t raid_level_show(struct device *dev,
+       struct device_attribute *attr, char *buf);
+static ssize_t lunid_show(struct device *dev,
+       struct device_attribute *attr, char *buf);
+static ssize_t unique_id_show(struct device *dev,
+       struct device_attribute *attr, char *buf);
+static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno);
+static ssize_t host_store_rescan(struct device *dev,
+        struct device_attribute *attr, const char *buf, size_t count);
+static int check_for_unit_attention(struct ctlr_info *h,
+       struct CommandList *c);
+static void check_ioctl_unit_attention(struct ctlr_info *h,
+       struct CommandList *c);
+
+static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL);
+static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL);
+static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL);
+static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
+
+static struct device_attribute *hpsa_sdev_attrs[] = {
+       &dev_attr_raid_level,
+       &dev_attr_lunid,
+       &dev_attr_unique_id,
+       NULL,
+};
+
+static struct device_attribute *hpsa_shost_attrs[] = {
+       &dev_attr_rescan,
+       NULL,
+};
+
+static struct scsi_host_template hpsa_driver_template = {
+       .module                 = THIS_MODULE,
+       .name                   = "hpsa",
+       .proc_name              = "hpsa",
+       .queuecommand           = hpsa_scsi_queue_command,
+       .can_queue              = 512,
+       .this_id                = -1,
+       .sg_tablesize           = MAXSGENTRIES,
+       .cmd_per_lun            = 512,
+       .use_clustering         = ENABLE_CLUSTERING,
+       .eh_device_reset_handler = hpsa_eh_device_reset_handler,
+       .ioctl                  = hpsa_ioctl,
+       .slave_alloc            = hpsa_slave_alloc,
+       .slave_destroy          = hpsa_slave_destroy,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl           = hpsa_compat_ioctl,
+#endif
+       .sdev_attrs = hpsa_sdev_attrs,
+       .shost_attrs = hpsa_shost_attrs,
+};
+
+static inline struct ctlr_info *sdev_to_hba(struct scsi_device *sdev)
+{
+       unsigned long *priv = shost_priv(sdev->host);
+       return (struct ctlr_info *) *priv;
+}
+
+static struct task_struct *hpsa_scan_thread;
+static DEFINE_MUTEX(hpsa_scan_mutex);
+static LIST_HEAD(hpsa_scan_q);
+static int hpsa_scan_func(void *data);
+
+/**
+ * add_to_scan_list() - add controller to rescan queue
+ * @h:               Pointer to the controller.
+ *
+ * Adds the controller to the rescan queue if not already on the queue.
+ *
+ * returns 1 if added to the queue, 0 if skipped (could be on the
+ * queue already, or the controller could be initializing or shutting
+ * down).
+ **/
+static int add_to_scan_list(struct ctlr_info *h)
+{
+       struct ctlr_info *test_h;
+       int found = 0;
+       int ret = 0;
+
+       if (h->busy_initializing)
+               return 0;
+
+       /*
+        * If we don't get the lock, it means the driver is unloading
+        * and there's no point in scheduling a new scan.
+        */
+       if (!mutex_trylock(&h->busy_shutting_down))
+               return 0;
+
+       mutex_lock(&hpsa_scan_mutex);
+       list_for_each_entry(test_h, &hpsa_scan_q, scan_list) {
+               if (test_h == h) {
+                       found = 1;
+                       break;
+               }
+       }
+       if (!found && !h->busy_scanning) {
+               INIT_COMPLETION(h->scan_wait);
+               list_add_tail(&h->scan_list, &hpsa_scan_q);
+               ret = 1;
+       }
+       mutex_unlock(&hpsa_scan_mutex);
+       mutex_unlock(&h->busy_shutting_down);
+
+       return ret;
+}
+
+/**
+ * remove_from_scan_list() - remove controller from rescan queue
+ * @h:                    Pointer to the controller.
+ *
+ * Removes the controller from the rescan queue if present. Blocks if
+ * the controller is currently conducting a rescan.  The controller
+ * can be in one of three states:
+ * 1. Doesn't need a scan
+ * 2. On the scan list, but not scanning yet (we remove it)
+ * 3. Busy scanning (and not on the list). In this case we want to wait for
+ *    the scan to complete to make sure the scanning thread for this
+ *    controller is completely idle.
+ **/
+static void remove_from_scan_list(struct ctlr_info *h)
+{
+       struct ctlr_info *test_h, *tmp_h;
+
+       mutex_lock(&hpsa_scan_mutex);
+       list_for_each_entry_safe(test_h, tmp_h, &hpsa_scan_q, scan_list) {
+               if (test_h == h) { /* state 2. */
+                       list_del(&h->scan_list);
+                       complete_all(&h->scan_wait);
+                       mutex_unlock(&hpsa_scan_mutex);
+                       return;
+               }
+       }
+       if (h->busy_scanning) { /* state 3. */
+               mutex_unlock(&hpsa_scan_mutex);
+               wait_for_completion(&h->scan_wait);
+       } else { /* state 1, nothing to do. */
+               mutex_unlock(&hpsa_scan_mutex);
+       }
+}
+
+/* hpsa_scan_func() - kernel thread used to rescan controllers
+ * @data:       Ignored.
+ *
+ * A kernel thread used scan for drive topology changes on
+ * controllers. The thread processes only one controller at a time
+ * using a queue.  Controllers are added to the queue using
+ * add_to_scan_list() and removed from the queue either after done
+ * processing or using remove_from_scan_list().
+ *
+ * returns 0.
+ **/
+static int hpsa_scan_func(__attribute__((unused)) void *data)
+{
+       struct ctlr_info *h;
+       int host_no;
+
+       while (1) {
+               set_current_state(TASK_INTERRUPTIBLE);
+               schedule();
+               if (kthread_should_stop())
+                       break;
+
+               while (1) {
+                       mutex_lock(&hpsa_scan_mutex);
+                       if (list_empty(&hpsa_scan_q)) {
+                               mutex_unlock(&hpsa_scan_mutex);
+                               break;
+                       }
+                       h = list_entry(hpsa_scan_q.next, struct ctlr_info,
+                                       scan_list);
+                       list_del(&h->scan_list);
+                       h->busy_scanning = 1;
+                       mutex_unlock(&hpsa_scan_mutex);
+                       host_no = h->scsi_host ?  h->scsi_host->host_no : -1;
+                       hpsa_update_scsi_devices(h, host_no);
+                       complete_all(&h->scan_wait);
+                       mutex_lock(&hpsa_scan_mutex);
+                       h->busy_scanning = 0;
+                       mutex_unlock(&hpsa_scan_mutex);
+               }
+       }
+       return 0;
+}
+
+static int check_for_unit_attention(struct ctlr_info *h,
+       struct CommandList *c)
+{
+       if (c->err_info->SenseInfo[2] != UNIT_ATTENTION)
+               return 0;
+
+       switch (c->err_info->SenseInfo[12]) {
+       case STATE_CHANGED:
+               dev_warn(&h->pdev->dev, "hpsa%d: a state change "
+                       "detected, command retried\n", h->ctlr);
+               break;
+       case LUN_FAILED:
+               dev_warn(&h->pdev->dev, "hpsa%d: LUN failure "
+                       "detected, action required\n", h->ctlr);
+               break;
+       case REPORT_LUNS_CHANGED:
+               dev_warn(&h->pdev->dev, "hpsa%d: report LUN data "
+                       "changed\n", h->ctlr);
+       /*
+        * Here, we could call add_to_scan_list and wake up the scan thread,
+        * except that it's quite likely that we will get more than one
+        * REPORT_LUNS_CHANGED condition in quick succession, which means
+        * that those which occur after the first one will likely happen
+        * *during* the hpsa_scan_thread's rescan.  And the rescan code is not
+        * robust enough to restart in the middle, undoing what it has already
+        * done, and it's not clear that it's even possible to do this, since
+        * part of what it does is notify the SCSI mid layer, which starts
+        * doing it's own i/o to read partition tables and so on, and the
+        * driver doesn't have visibility to know what might need undoing.
+        * In any event, if possible, it is horribly complicated to get right
+        * so we just don't do it for now.
+        *
+        * Note: this REPORT_LUNS_CHANGED condition only occurs on the MSA2012.
+        */
+               break;
+       case POWER_OR_RESET:
+               dev_warn(&h->pdev->dev, "hpsa%d: a power on "
+                       "or device reset detected\n", h->ctlr);
+               break;
+       case UNIT_ATTENTION_CLEARED:
+               dev_warn(&h->pdev->dev, "hpsa%d: unit attention "
+                   "cleared by another initiator\n", h->ctlr);
+               break;
+       default:
+               dev_warn(&h->pdev->dev, "hpsa%d: unknown "
+                       "unit attention detected\n", h->ctlr);
+               break;
+       }
+       return 1;
+}
+
+static ssize_t host_store_rescan(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf, size_t count)
+{
+       struct ctlr_info *h;
+       struct Scsi_Host *shost = class_to_shost(dev);
+       unsigned long *priv = shost_priv(shost);
+       h = (struct ctlr_info *) *priv;
+       if (add_to_scan_list(h)) {
+               wake_up_process(hpsa_scan_thread);
+               wait_for_completion_interruptible(&h->scan_wait);
+       }
+       return count;
+}
+
+/* Enqueuing and dequeuing functions for cmdlists. */
+static inline void addQ(struct hlist_head *list, struct CommandList *c)
+{
+       hlist_add_head(&c->list, list);
+}
+
+static void enqueue_cmd_and_start_io(struct ctlr_info *h,
+       struct CommandList *c)
+{
+       unsigned long flags;
+       spin_lock_irqsave(&h->lock, flags);
+       addQ(&h->reqQ, c);
+       h->Qdepth++;
+       start_io(h);
+       spin_unlock_irqrestore(&h->lock, flags);
+}
+
+static inline void removeQ(struct CommandList *c)
+{
+       if (WARN_ON(hlist_unhashed(&c->list)))
+               return;
+       hlist_del_init(&c->list);
+}
+
+static inline int is_hba_lunid(unsigned char scsi3addr[])
+{
+       return memcmp(scsi3addr, RAID_CTLR_LUNID, 8) == 0;
+}
+
+static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])
+{
+       return (scsi3addr[3] & 0xC0) == 0x40;
+}
+
+static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG",
+       "UNKNOWN"
+};
+#define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 1)
+
+static ssize_t raid_level_show(struct device *dev,
+            struct device_attribute *attr, char *buf)
+{
+       ssize_t l = 0;
+       int rlevel;
+       struct ctlr_info *h;
+       struct scsi_device *sdev;
+       struct hpsa_scsi_dev_t *hdev;
+       unsigned long flags;
+
+       sdev = to_scsi_device(dev);
+       h = sdev_to_hba(sdev);
+       spin_lock_irqsave(&h->lock, flags);
+       hdev = sdev->hostdata;
+       if (!hdev) {
+               spin_unlock_irqrestore(&h->lock, flags);
+               return -ENODEV;
+       }
+
+       /* Is this even a logical drive? */
+       if (!is_logical_dev_addr_mode(hdev->scsi3addr)) {
+               spin_unlock_irqrestore(&h->lock, flags);
+               l = snprintf(buf, PAGE_SIZE, "N/A\n");
+               return l;
+       }
+
+       rlevel = hdev->raid_level;
+       spin_unlock_irqrestore(&h->lock, flags);
+       if (rlevel < 0 || rlevel > RAID_UNKNOWN)
+               rlevel = RAID_UNKNOWN;
+       l = snprintf(buf, PAGE_SIZE, "RAID %s\n", raid_label[rlevel]);
+       return l;
+}
+
+static ssize_t lunid_show(struct device *dev,
+            struct device_attribute *attr, char *buf)
+{
+       struct ctlr_info *h;
+       struct scsi_device *sdev;
+       struct hpsa_scsi_dev_t *hdev;
+       unsigned long flags;
+       unsigned char lunid[8];
+
+       sdev = to_scsi_device(dev);
+       h = sdev_to_hba(sdev);
+       spin_lock_irqsave(&h->lock, flags);
+       hdev = sdev->hostdata;
+       if (!hdev) {
+               spin_unlock_irqrestore(&h->lock, flags);
+               return -ENODEV;
+       }
+       memcpy(lunid, hdev->scsi3addr, sizeof(lunid));
+       spin_unlock_irqrestore(&h->lock, flags);
+       return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
+               lunid[0], lunid[1], lunid[2], lunid[3],
+               lunid[4], lunid[5], lunid[6], lunid[7]);
+}
+
+static ssize_t unique_id_show(struct device *dev,
+            struct device_attribute *attr, char *buf)
+{
+       struct ctlr_info *h;
+       struct scsi_device *sdev;
+       struct hpsa_scsi_dev_t *hdev;
+       unsigned long flags;
+       unsigned char sn[16];
+
+       sdev = to_scsi_device(dev);
+       h = sdev_to_hba(sdev);
+       spin_lock_irqsave(&h->lock, flags);
+       hdev = sdev->hostdata;
+       if (!hdev) {
+               spin_unlock_irqrestore(&h->lock, flags);
+               return -ENODEV;
+       }
+       memcpy(sn, hdev->device_id, sizeof(sn));
+       spin_unlock_irqrestore(&h->lock, flags);
+       return snprintf(buf, 16 * 2 + 2,
+                       "%02X%02X%02X%02X%02X%02X%02X%02X"
+                       "%02X%02X%02X%02X%02X%02X%02X%02X\n",
+                       sn[0], sn[1], sn[2], sn[3],
+                       sn[4], sn[5], sn[6], sn[7],
+                       sn[8], sn[9], sn[10], sn[11],
+                       sn[12], sn[13], sn[14], sn[15]);
+}
+
+static int hpsa_find_target_lun(struct ctlr_info *h,
+       unsigned char scsi3addr[], int bus, int *target, int *lun)
+{
+       /* finds an unused bus, target, lun for a new physical device
+        * assumes h->devlock is held
+        */
+       int i, found = 0;
+       DECLARE_BITMAP(lun_taken, HPSA_MAX_SCSI_DEVS_PER_HBA);
+
+       memset(&lun_taken[0], 0, HPSA_MAX_SCSI_DEVS_PER_HBA >> 3);
+
+       for (i = 0; i < h->ndevices; i++) {
+               if (h->dev[i]->bus == bus && h->dev[i]->target != -1)
+                       set_bit(h->dev[i]->target, lun_taken);
+       }
+
+       for (i = 0; i < HPSA_MAX_SCSI_DEVS_PER_HBA; i++) {
+               if (!test_bit(i, lun_taken)) {
+                       /* *bus = 1; */
+                       *target = i;
+                       *lun = 0;
+                       found = 1;
+                       break;
+               }
+       }
+       return !found;
+}
+
+/* Add an entry into h->dev[] array. */
+static int hpsa_scsi_add_entry(struct ctlr_info *h, int hostno,
+               struct hpsa_scsi_dev_t *device,
+               struct hpsa_scsi_dev_t *added[], int *nadded)
+{
+       /* assumes h->devlock is held */
+       int n = h->ndevices;
+       int i;
+       unsigned char addr1[8], addr2[8];
+       struct hpsa_scsi_dev_t *sd;
+
+       if (n >= HPSA_MAX_SCSI_DEVS_PER_HBA) {
+               dev_err(&h->pdev->dev, "too many devices, some will be "
+                       "inaccessible.\n");
+               return -1;
+       }
+
+       /* physical devices do not have lun or target assigned until now. */
+       if (device->lun != -1)
+               /* Logical device, lun is already assigned. */
+               goto lun_assigned;
+
+       /* If this device a non-zero lun of a multi-lun device
+        * byte 4 of the 8-byte LUN addr will contain the logical
+        * unit no, zero otherise.
+        */
+       if (device->scsi3addr[4] == 0) {
+               /* This is not a non-zero lun of a multi-lun device */
+               if (hpsa_find_target_lun(h, device->scsi3addr,
+                       device->bus, &device->target, &device->lun) != 0)
+                       return -1;
+               goto lun_assigned;
+       }
+
+       /* This is a non-zero lun of a multi-lun device.
+        * Search through our list and find the device which
+        * has the same 8 byte LUN address, excepting byte 4.
+        * Assign the same bus and target for this new LUN.
+        * Use the logical unit number from the firmware.
+        */
+       memcpy(addr1, device->scsi3addr, 8);
+       addr1[4] = 0;
+       for (i = 0; i < n; i++) {
+               sd = h->dev[i];
+               memcpy(addr2, sd->scsi3addr, 8);
+               addr2[4] = 0;
+               /* differ only in byte 4? */
+               if (memcmp(addr1, addr2, 8) == 0) {
+                       device->bus = sd->bus;
+                       device->target = sd->target;
+                       device->lun = device->scsi3addr[4];
+                       break;
+               }
+       }
+       if (device->lun == -1) {
+               dev_warn(&h->pdev->dev, "physical device with no LUN=0,"
+                       " suspect firmware bug or unsupported hardware "
+                       "configuration.\n");
+                       return -1;
+       }
+
+lun_assigned:
+
+       h->dev[n] = device;
+       h->ndevices++;
+       added[*nadded] = device;
+       (*nadded)++;
+
+       /* initially, (before registering with scsi layer) we don't
+        * know our hostno and we don't want to print anything first
+        * time anyway (the scsi layer's inquiries will show that info)
+        */
+       /* if (hostno != -1) */
+               dev_info(&h->pdev->dev, "%s device c%db%dt%dl%d added.\n",
+                       scsi_device_type(device->devtype), hostno,
+                       device->bus, device->target, device->lun);
+       return 0;
+}
+
+/* Remove an entry from h->dev[] array. */
+static void hpsa_scsi_remove_entry(struct ctlr_info *h, int hostno, int entry,
+       struct hpsa_scsi_dev_t *removed[], int *nremoved)
+{
+       /* assumes h->devlock is held */
+       int i;
+       struct hpsa_scsi_dev_t *sd;
+
+       if (entry < 0 || entry >= HPSA_MAX_SCSI_DEVS_PER_HBA)
+               BUG();
+
+       sd = h->dev[entry];
+       removed[*nremoved] = h->dev[entry];
+       (*nremoved)++;
+
+       for (i = entry; i < h->ndevices-1; i++)
+               h->dev[i] = h->dev[i+1];
+       h->ndevices--;
+       dev_info(&h->pdev->dev, "%s device c%db%dt%dl%d removed.\n",
+               scsi_device_type(sd->devtype), hostno, sd->bus, sd->target,
+               sd->lun);
+}
+
+#define SCSI3ADDR_EQ(a, b) ( \
+       (a)[7] == (b)[7] && \
+       (a)[6] == (b)[6] && \
+       (a)[5] == (b)[5] && \
+       (a)[4] == (b)[4] && \
+       (a)[3] == (b)[3] && \
+       (a)[2] == (b)[2] && \
+       (a)[1] == (b)[1] && \
+       (a)[0] == (b)[0])
+
+static void fixup_botched_add(struct ctlr_info *h,
+       struct hpsa_scsi_dev_t *added)
+{
+       /* called when scsi_add_device fails in order to re-adjust
+        * h->dev[] to match the mid layer's view.
+        */
+       unsigned long flags;
+       int i, j;
+
+       spin_lock_irqsave(&h->lock, flags);
+       for (i = 0; i < h->ndevices; i++) {
+               if (h->dev[i] == added) {
+                       for (j = i; j < h->ndevices-1; j++)
+                               h->dev[j] = h->dev[j+1];
+                       h->ndevices--;
+                       break;
+               }
+       }
+       spin_unlock_irqrestore(&h->lock, flags);
+       kfree(added);
+}
+
+static inline int device_is_the_same(struct hpsa_scsi_dev_t *dev1,
+       struct hpsa_scsi_dev_t *dev2)
+{
+       if ((is_logical_dev_addr_mode(dev1->scsi3addr) ||
+               (dev1->lun != -1 && dev2->lun != -1)) &&
+               dev1->devtype != 0x0C)
+               return (memcmp(dev1, dev2, sizeof(*dev1)) == 0);
+
+       /* we compare everything except lun and target as these
+        * are not yet assigned.  Compare parts likely
+        * to differ first
+        */
+       if (memcmp(dev1->scsi3addr, dev2->scsi3addr,
+               sizeof(dev1->scsi3addr)) != 0)
+               return 0;
+       if (memcmp(dev1->device_id, dev2->device_id,
+               sizeof(dev1->device_id)) != 0)
+               return 0;
+       if (memcmp(dev1->model, dev2->model, sizeof(dev1->model)) != 0)
+               return 0;
+       if (memcmp(dev1->vendor, dev2->vendor, sizeof(dev1->vendor)) != 0)
+               return 0;
+       if (memcmp(dev1->revision, dev2->revision, sizeof(dev1->revision)) != 0)
+               return 0;
+       if (dev1->devtype != dev2->devtype)
+               return 0;
+       if (dev1->raid_level != dev2->raid_level)
+               return 0;
+       if (dev1->bus != dev2->bus)
+               return 0;
+       return 1;
+}
+
+/* Find needle in haystack.  If exact match found, return DEVICE_SAME,
+ * and return needle location in *index.  If scsi3addr matches, but not
+ * vendor, model, serial num, etc. return DEVICE_CHANGED, and return needle
+ * location in *index.  If needle not found, return DEVICE_NOT_FOUND.
+ */
+static int hpsa_scsi_find_entry(struct hpsa_scsi_dev_t *needle,
+       struct hpsa_scsi_dev_t *haystack[], int haystack_size,
+       int *index)
+{
+       int i;
+#define DEVICE_NOT_FOUND 0
+#define DEVICE_CHANGED 1
+#define DEVICE_SAME 2
+       for (i = 0; i < haystack_size; i++) {
+               if (SCSI3ADDR_EQ(needle->scsi3addr, haystack[i]->scsi3addr)) {
+                       *index = i;
+                       if (device_is_the_same(needle, haystack[i]))
+                               return DEVICE_SAME;
+                       else
+                               return DEVICE_CHANGED;
+               }
+       }
+       *index = -1;
+       return DEVICE_NOT_FOUND;
+}
+
+static int adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
+       struct hpsa_scsi_dev_t *sd[], int nsds)
+{
+       /* sd contains scsi3 addresses and devtypes, and inquiry
+        * data.  This function takes what's in sd to be the current
+        * reality and updates h->dev[] to reflect that reality.
+        */
+       int i, entry, device_change, changes = 0;
+       struct hpsa_scsi_dev_t *csd;
+       unsigned long flags;
+       struct hpsa_scsi_dev_t **added, **removed;
+       int nadded, nremoved;
+       struct Scsi_Host *sh = NULL;
+
+       added = kzalloc(sizeof(*added) * HPSA_MAX_SCSI_DEVS_PER_HBA,
+               GFP_KERNEL);
+       removed = kzalloc(sizeof(*removed) * HPSA_MAX_SCSI_DEVS_PER_HBA,
+               GFP_KERNEL);
+
+       if (!added || !removed) {
+               dev_warn(&h->pdev->dev, "out of memory in "
+                       "adjust_hpsa_scsi_table\n");
+               goto free_and_out;
+       }
+
+       spin_lock_irqsave(&h->devlock, flags);
+
+       /* find any devices in h->dev[] that are not in
+        * sd[] and remove them from h->dev[], and for any
+        * devices which have changed, remove the old device
+        * info and add the new device info.
+        */
+       i = 0;
+       nremoved = 0;
+       nadded = 0;
+       while (i < h->ndevices) {
+               csd = h->dev[i];
+               device_change = hpsa_scsi_find_entry(csd, sd, nsds, &entry);
+               if (device_change == DEVICE_NOT_FOUND) {
+                       changes++;
+                       hpsa_scsi_remove_entry(h, hostno, i,
+                               removed, &nremoved);
+                       continue; /* remove ^^^, hence i not incremented */
+               } else if (device_change == DEVICE_CHANGED) {
+                       changes++;
+                       hpsa_scsi_remove_entry(h, hostno, i,
+                               removed, &nremoved);
+                       (void) hpsa_scsi_add_entry(h, hostno, sd[entry],
+                               added, &nadded);
+                       /* add can't fail, we just removed one. */
+                       sd[entry] = NULL; /* prevent it from being freed */
+               }
+               i++;
+       }
+
+       /* Now, make sure every device listed in sd[] is also
+        * listed in h->dev[], adding them if they aren't found
+        */
+
+       for (i = 0; i < nsds; i++) {
+               if (!sd[i]) /* if already added above. */
+                       continue;
+               device_change = hpsa_scsi_find_entry(sd[i], h->dev,
+                                       h->ndevices, &entry);
+               if (device_change == DEVICE_NOT_FOUND) {
+                       changes++;
+                       if (hpsa_scsi_add_entry(h, hostno, sd[i],
+                               added, &nadded) != 0)
+                               break;
+                       sd[i] = NULL; /* prevent from being freed later. */
+               } else if (device_change == DEVICE_CHANGED) {
+                       /* should never happen... */
+                       changes++;
+                       dev_warn(&h->pdev->dev,
+                               "device unexpectedly changed.\n");
+                       /* but if it does happen, we just ignore that device */
+               }
+       }
+       spin_unlock_irqrestore(&h->devlock, flags);
+
+       /* Don't notify scsi mid layer of any changes the first time through
+        * (or if there are no changes) scsi_scan_host will do it later the
+        * first time through.
+        */
+       if (hostno == -1 || !changes)
+               goto free_and_out;
+
+       sh = h->scsi_host;
+       /* Notify scsi mid layer of any removed devices */
+       for (i = 0; i < nremoved; i++) {
+               struct scsi_device *sdev =
+                       scsi_device_lookup(sh, removed[i]->bus,
+                               removed[i]->target, removed[i]->lun);
+               if (sdev != NULL) {
+                       scsi_remove_device(sdev);
+                       scsi_device_put(sdev);
+               } else {
+                       /* We don't expect to get here.
+                        * future cmds to this device will get selection
+                        * timeout as if the device was gone.
+                        */
+                       dev_warn(&h->pdev->dev, "didn't find c%db%dt%dl%d "
+                               " for removal.", hostno, removed[i]->bus,
+                               removed[i]->target, removed[i]->lun);
+               }
+               kfree(removed[i]);
+               removed[i] = NULL;
+       }
+
+       /* Notify scsi mid layer of any added devices */
+       for (i = 0; i < nadded; i++) {
+               if (scsi_add_device(sh, added[i]->bus,
+                       added[i]->target, added[i]->lun) == 0)
+                       continue;
+               dev_warn(&h->pdev->dev, "scsi_add_device c%db%dt%dl%d failed, "
+                       "device not added.\n", hostno, added[i]->bus,
+                       added[i]->target, added[i]->lun);
+               /* now we have to remove it from h->dev,
+                * since it didn't get added to scsi mid layer
+                */
+               fixup_botched_add(h, added[i]);
+       }
+
+free_and_out:
+       kfree(added);
+       kfree(removed);
+       return 0;
+}
+
+/*
+ * Lookup bus/target/lun and retrun corresponding struct hpsa_scsi_dev_t *
+ * Assume's h->devlock is held.
+ */
+static struct hpsa_scsi_dev_t *lookup_hpsa_scsi_dev(struct ctlr_info *h,
+       int bus, int target, int lun)
+{
+       int i;
+       struct hpsa_scsi_dev_t *sd;
+
+       for (i = 0; i < h->ndevices; i++) {
+               sd = h->dev[i];
+               if (sd->bus == bus && sd->target == target && sd->lun == lun)
+                       return sd;
+       }
+       return NULL;
+}
+
+/* link sdev->hostdata to our per-device structure. */
+static int hpsa_slave_alloc(struct scsi_device *sdev)
+{
+       struct hpsa_scsi_dev_t *sd;
+       unsigned long flags;
+       struct ctlr_info *h;
+
+       h = sdev_to_hba(sdev);
+       spin_lock_irqsave(&h->devlock, flags);
+       sd = lookup_hpsa_scsi_dev(h, sdev_channel(sdev),
+               sdev_id(sdev), sdev->lun);
+       if (sd != NULL)
+               sdev->hostdata = sd;
+       spin_unlock_irqrestore(&h->devlock, flags);
+       return 0;
+}
+
+static void hpsa_slave_destroy(struct scsi_device *sdev)
+{
+       return; /* nothing to do. */
+}
+
+static void hpsa_scsi_setup(struct ctlr_info *h)
+{
+       h->ndevices = 0;
+       h->scsi_host = NULL;
+       spin_lock_init(&h->devlock);
+       return;
+}
+
+static void complete_scsi_command(struct CommandList *cp,
+       int timeout, __u32 tag)
+{
+       struct scsi_cmnd *cmd;
+       struct ctlr_info *h;
+       struct ErrorInfo *ei;
+
+       unsigned char sense_key;
+       unsigned char asc;      /* additional sense code */
+       unsigned char ascq;     /* additional sense code qualifier */
+
+       ei = cp->err_info;
+       cmd = (struct scsi_cmnd *) cp->scsi_cmd;
+       h = cp->h;
+
+       scsi_dma_unmap(cmd); /* undo the DMA mappings */
+
+       cmd->result = (DID_OK << 16);           /* host byte */
+       cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */
+       cmd->result |= (ei->ScsiStatus << 1);
+
+       /* copy the sense data whether we need to or not. */
+       memcpy(cmd->sense_buffer, ei->SenseInfo,
+               ei->SenseLen > SCSI_SENSE_BUFFERSIZE ?
+                       SCSI_SENSE_BUFFERSIZE :
+                       ei->SenseLen);
+       scsi_set_resid(cmd, ei->ResidualCnt);
+
+       if (ei->CommandStatus == 0) {
+               cmd->scsi_done(cmd);
+               cmd_free(h, cp);
+               return;
+       }
+
+       /* an error has occurred */
+       switch (ei->CommandStatus) {
+
+       case CMD_TARGET_STATUS:
+               if (ei->ScsiStatus) {
+                       /* Get sense key */
+                       sense_key = 0xf & ei->SenseInfo[2];
+                       /* Get additional sense code */
+                       asc = ei->SenseInfo[12];
+                       /* Get addition sense code qualifier */
+                       ascq = ei->SenseInfo[13];
+               }
+
+               if (ei->ScsiStatus == SAM_STAT_CHECK_CONDITION) {
+                       if (check_for_unit_attention(h, cp)) {
+                               cmd->result = DID_SOFT_ERROR << 16;
+                               break;
+                       }
+                       if (sense_key == ILLEGAL_REQUEST) {
+                               /*
+                                * SCSI REPORT_LUNS is commonly unsupported on
+                                * Smart Array.  Suppress noisy complaint.
+                                */
+                               if (cp->Request.CDB[0] == REPORT_LUNS)
+                                       break;
+
+                               /* If ASC/ASCQ indicate Logical Unit
+                                * Not Supported condition,
+                                */
+                               if ((asc == 0x25) && (ascq == 0x0)) {
+                                       dev_warn(&h->pdev->dev, "cp %p "
+                                               "has check condition\n", cp);
+                                       break;
+                               }
+                       }
+
+                       if (sense_key == NOT_READY) {
+                               /* If Sense is Not Ready, Logical Unit
+                                * Not ready, Manual Intervention
+                                * required
+                                */
+                               if ((asc == 0x04) && (ascq == 0x03)) {
+                                       cmd->result = DID_NO_CONNECT << 16;
+                                       dev_warn(&h->pdev->dev, "cp %p "
+                                               "has check condition: unit "
+                                               "not ready, manual "
+                                               "intervention required\n", cp);
+                                       break;
+                               }
+                       }
+
+
+                       /* Must be some other type of check condition */
+                       dev_warn(&h->pdev->dev, "cp %p has check condition: "
+                                       "unknown type: "
+                                       "Sense: 0x%x, ASC: 0x%x, ASCQ: 0x%x, "
+                                       "Returning result: 0x%x, "
+                                       "cmd=[%02x %02x %02x %02x %02x "
+                                       "%02x %02x %02x %02x %02x]\n",
+                                       cp, sense_key, asc, ascq,
+                                       cmd->result,
+                                       cmd->cmnd[0], cmd->cmnd[1],
+                                       cmd->cmnd[2], cmd->cmnd[3],
+                                       cmd->cmnd[4], cmd->cmnd[5],
+                                       cmd->cmnd[6], cmd->cmnd[7],
+                                       cmd->cmnd[8], cmd->cmnd[9]);
+                       break;
+               }
+
+
+               /* Problem was not a check condition
+                * Pass it up to the upper layers...
+                */
+               if (ei->ScsiStatus) {
+                       dev_warn(&h->pdev->dev, "cp %p has status 0x%x "
+                               "Sense: 0x%x, ASC: 0x%x, ASCQ: 0x%x, "
+                               "Returning result: 0x%x\n",
+                               cp, ei->ScsiStatus,
+                               sense_key, asc, ascq,
+                               cmd->result);
+               } else {  /* scsi status is zero??? How??? */
+                       dev_warn(&h->pdev->dev, "cp %p SCSI status was 0. "
+                               "Returning no connection.\n", cp),
+
+                       /* Ordinarily, this case should never happen,
+                        * but there is a bug in some released firmware
+                        * revisions that allows it to happen if, for
+                        * example, a 4100 backplane loses power and
+                        * the tape drive is in it.  We assume that
+                        * it's a fatal error of some kind because we
+                        * can't show that it wasn't. We will make it
+                        * look like selection timeout since that is
+                        * the most common reason for this to occur,
+                        * and it's severe enough.
+                        */
+
+                       cmd->result = DID_NO_CONNECT << 16;
+               }
+               break;
+
+       case CMD_DATA_UNDERRUN: /* let mid layer handle it. */
+               break;
+       case CMD_DATA_OVERRUN:
+               dev_warn(&h->pdev->dev, "cp %p has"
+                       " completed with data overrun "
+                       "reported\n", cp);
+               break;
+       case CMD_INVALID: {
+               /* print_bytes(cp, sizeof(*cp), 1, 0);
+               print_cmd(cp); */
+               /* We get CMD_INVALID if you address a non-existent device
+                * instead of a selection timeout (no response).  You will
+                * see this if you yank out a drive, then try to access it.
+                * This is kind of a shame because it means that any other
+                * CMD_INVALID (e.g. driver bug) will get interpreted as a
+                * missing target. */
+               cmd->result = DID_NO_CONNECT << 16;
+       }
+               break;
+       case CMD_PROTOCOL_ERR:
+               dev_warn(&h->pdev->dev, "cp %p has "
+                       "protocol error \n", cp);
+               break;
+       case CMD_HARDWARE_ERR:
+               cmd->result = DID_ERROR << 16;
+               dev_warn(&h->pdev->dev, "cp %p had  hardware error\n", cp);
+               break;
+       case CMD_CONNECTION_LOST:
+               cmd->result = DID_ERROR << 16;
+               dev_warn(&h->pdev->dev, "cp %p had connection lost\n", cp);
+               break;
+       case CMD_ABORTED:
+               cmd->result = DID_ABORT << 16;
+               dev_warn(&h->pdev->dev, "cp %p was aborted with status 0x%x\n",
+                               cp, ei->ScsiStatus);
+               break;
+       case CMD_ABORT_FAILED:
+               cmd->result = DID_ERROR << 16;
+               dev_warn(&h->pdev->dev, "cp %p reports abort failed\n", cp);
+               break;
+       case CMD_UNSOLICITED_ABORT:
+               cmd->result = DID_ABORT << 16;
+               dev_warn(&h->pdev->dev, "cp %p aborted do to an unsolicited "
+                       "abort\n", cp);
+               break;
+       case CMD_TIMEOUT:
+               cmd->result = DID_TIME_OUT << 16;
+               dev_warn(&h->pdev->dev, "cp %p timedout\n", cp);
+               break;
+       default:
+               cmd->result = DID_ERROR << 16;
+               dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n",
+                               cp, ei->CommandStatus);
+       }
+       cmd->scsi_done(cmd);
+       cmd_free(h, cp);
+}
+
+static int hpsa_scsi_detect(struct ctlr_info *h)
+{
+       struct Scsi_Host *sh;
+       int error;
+
+       sh = scsi_host_alloc(&hpsa_driver_template, sizeof(h));
+       if (sh == NULL)
+               goto fail;
+
+       sh->io_port = 0;
+       sh->n_io_port = 0;
+       sh->this_id = -1;
+       sh->max_channel = 3;
+       sh->max_cmd_len = MAX_COMMAND_SIZE;
+       sh->max_lun = HPSA_MAX_LUN;
+       sh->max_id = HPSA_MAX_LUN;
+       h->scsi_host = sh;
+       sh->hostdata[0] = (unsigned long) h;
+       sh->irq = h->intr[SIMPLE_MODE_INT];
+       sh->unique_id = sh->irq;
+       error = scsi_add_host(sh, &h->pdev->dev);
+       if (error)
+               goto fail_host_put;
+       scsi_scan_host(sh);
+       return 0;
+
+ fail_host_put:
+       dev_err(&h->pdev->dev, "hpsa_scsi_detect: scsi_add_host"
+               " failed for controller %d\n", h->ctlr);
+       scsi_host_put(sh);
+       return -1;
+ fail:
+       dev_err(&h->pdev->dev, "hpsa_scsi_detect: scsi_host_alloc"
+               " failed for controller %d\n", h->ctlr);
+       return -1;
+}
+
+static void hpsa_pci_unmap(struct pci_dev *pdev,
+       struct CommandList *c, int sg_used, int data_direction)
+{
+       int i;
+       union u64bit addr64;
+
+       for (i = 0; i < sg_used; i++) {
+               addr64.val32.lower = c->SG[i].Addr.lower;
+               addr64.val32.upper = c->SG[i].Addr.upper;
+               pci_unmap_single(pdev, (dma_addr_t) addr64.val, c->SG[i].Len,
+                       data_direction);
+       }
+}
+
+static void hpsa_map_one(struct pci_dev *pdev,
+               struct CommandList *cp,
+               unsigned char *buf,
+               size_t buflen,
+               int data_direction)
+{
+       __u64 addr64;
+
+       if (buflen == 0 || data_direction == PCI_DMA_NONE) {
+               cp->Header.SGList = 0;
+               cp->Header.SGTotal = 0;
+               return;
+       }
+
+       addr64 = (__u64) pci_map_single(pdev, buf, buflen, data_direction);
+       cp->SG[0].Addr.lower =
+         (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF);
+       cp->SG[0].Addr.upper =
+         (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF);
+       cp->SG[0].Len = buflen;
+       cp->Header.SGList = (__u8) 1;   /* no. SGs contig in this cmd */
+       cp->Header.SGTotal = (__u16) 1; /* total sgs in this cmd list */
+}
+
+static inline void hpsa_scsi_do_simple_cmd_core(struct ctlr_info *h,
+       struct CommandList *c)
+{
+       DECLARE_COMPLETION_ONSTACK(wait);
+
+       c->waiting = &wait;
+       enqueue_cmd_and_start_io(h, c);
+       wait_for_completion(&wait);
+}
+
+static void hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h,
+       struct CommandList *c, int data_direction)
+{
+       int retry_count = 0;
+
+       do {
+               memset(c->err_info, 0, sizeof(c->err_info));
+               hpsa_scsi_do_simple_cmd_core(h, c);
+               retry_count++;
+       } while (check_for_unit_attention(h, c) && retry_count <= 3);
+       hpsa_pci_unmap(h->pdev, c, 1, data_direction);
+}
+
+static void hpsa_scsi_interpret_error(struct CommandList *cp)
+{
+       struct ErrorInfo *ei;
+       struct device *d = &cp->h->pdev->dev;
+
+       ei = cp->err_info;
+       switch (ei->CommandStatus) {
+       case CMD_TARGET_STATUS:
+               dev_warn(d, "cmd %p has completed with errors\n", cp);
+               dev_warn(d, "cmd %p has SCSI Status = %x\n", cp,
+                               ei->ScsiStatus);
+               if (ei->ScsiStatus == 0)
+                       dev_warn(d, "SCSI status is abnormally zero.  "
+                       "(probably indicates selection timeout "
+                       "reported incorrectly due to a known "
+                       "firmware bug, circa July, 2001.)\n");
+               break;
+       case CMD_DATA_UNDERRUN: /* let mid layer handle it. */
+                       dev_info(d, "UNDERRUN\n");
+               break;
+       case CMD_DATA_OVERRUN:
+               dev_warn(d, "cp %p has completed with data overrun\n", cp);
+               break;
+       case CMD_INVALID: {
+               /* controller unfortunately reports SCSI passthru's
+                * to non-existent targets as invalid commands.
+                */
+               dev_warn(d, "cp %p is reported invalid (probably means "
+                       "target device no longer present)\n", cp);
+               /* print_bytes((unsigned char *) cp, sizeof(*cp), 1, 0);
+               print_cmd(cp);  */
+               }
+               break;
+       case CMD_PROTOCOL_ERR:
+               dev_warn(d, "cp %p has protocol error \n", cp);
+               break;
+       case CMD_HARDWARE_ERR:
+               /* cmd->result = DID_ERROR << 16; */
+               dev_warn(d, "cp %p had hardware error\n", cp);
+               break;
+       case CMD_CONNECTION_LOST:
+               dev_warn(d, "cp %p had connection lost\n", cp);
+               break;
+       case CMD_ABORTED:
+               dev_warn(d, "cp %p was aborted\n", cp);
+               break;
+       case CMD_ABORT_FAILED:
+               dev_warn(d, "cp %p reports abort failed\n", cp);
+               break;
+       case CMD_UNSOLICITED_ABORT:
+               dev_warn(d, "cp %p aborted due to an unsolicited abort\n", cp);
+               break;
+       case CMD_TIMEOUT:
+               dev_warn(d, "cp %p timed out\n", cp);
+               break;
+       default:
+               dev_warn(d, "cp %p returned unknown status %x\n", cp,
+                               ei->CommandStatus);
+       }
+}
+
+static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr,
+                       unsigned char page, unsigned char *buf,
+                       unsigned char bufsize)
+{
+       int rc = IO_OK;
+       struct CommandList *c;
+       struct ErrorInfo *ei;
+
+       c = cmd_special_alloc(h);
+
+       if (c == NULL) {                        /* trouble... */
+               dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n");
+               return -1;
+       }
+
+       fill_cmd(c, HPSA_INQUIRY, h, buf, bufsize, page, scsi3addr, TYPE_CMD);
+       hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE);
+       ei = c->err_info;
+       if (ei->CommandStatus != 0 && ei->CommandStatus != CMD_DATA_UNDERRUN) {
+               hpsa_scsi_interpret_error(c);
+               rc = -1;
+       }
+       cmd_special_free(h, c);
+       return rc;
+}
+
+static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr)
+{
+       int rc = IO_OK;
+       struct CommandList *c;
+       struct ErrorInfo *ei;
+
+       c = cmd_special_alloc(h);
+
+       if (c == NULL) {                        /* trouble... */
+               dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n");
+               return -1;
+       }
+
+       fill_cmd(c, HPSA_DEVICE_RESET_MSG, h, NULL, 0, 0, scsi3addr, TYPE_MSG);
+       hpsa_scsi_do_simple_cmd_core(h, c);
+       /* no unmap needed here because no data xfer. */
+
+       ei = c->err_info;
+       if (ei->CommandStatus != 0) {
+               hpsa_scsi_interpret_error(c);
+               rc = -1;
+       }
+       cmd_special_free(h, c);
+       return rc;
+}
+
+static void hpsa_get_raid_level(struct ctlr_info *h,
+       unsigned char *scsi3addr, unsigned char *raid_level)
+{
+       int rc;
+       unsigned char *buf;
+
+       *raid_level = RAID_UNKNOWN;
+       buf = kzalloc(64, GFP_KERNEL);
+       if (!buf)
+               return;
+       rc = hpsa_scsi_do_inquiry(h, scsi3addr, 0xC1, buf, 64);
+       if (rc == 0)
+               *raid_level = buf[8];
+       if (*raid_level > RAID_UNKNOWN)
+               *raid_level = RAID_UNKNOWN;
+       kfree(buf);
+       return;
+}
+
+/* Get the device id from inquiry page 0x83 */
+static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr,
+       unsigned char *device_id, int buflen)
+{
+       int rc;
+       unsigned char *buf;
+
+       if (buflen > 16)
+               buflen = 16;
+       buf = kzalloc(64, GFP_KERNEL);
+       if (!buf)
+               return -1;
+       rc = hpsa_scsi_do_inquiry(h, scsi3addr, 0x83, buf, 64);
+       if (rc == 0)
+               memcpy(device_id, &buf[8], buflen);
+       kfree(buf);
+       return rc != 0;
+}
+
+static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical,
+               struct ReportLUNdata *buf, int bufsize,
+               int extended_response)
+{
+       int rc = IO_OK;
+       struct CommandList *c;
+       unsigned char scsi3addr[8];
+       struct ErrorInfo *ei;
+
+       c = cmd_special_alloc(h);
+       if (c == NULL) {                        /* trouble... */
+               dev_err(&h->pdev->dev, "cmd_special_alloc returned NULL!\n");
+               return -1;
+       }
+
+       memset(&scsi3addr[0], 0, 8); /* address the controller */
+
+       fill_cmd(c, logical ? HPSA_REPORT_LOG : HPSA_REPORT_PHYS, h,
+               buf, bufsize, 0, scsi3addr, TYPE_CMD);
+       if (extended_response)
+               c->Request.CDB[1] = extended_response;
+       hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_FROMDEVICE);
+       ei = c->err_info;
+       if (ei->CommandStatus != 0 &&
+           ei->CommandStatus != CMD_DATA_UNDERRUN) {
+               hpsa_scsi_interpret_error(c);
+               rc = -1;
+       }
+       cmd_special_free(h, c);
+       return rc;
+}
+
+static inline int hpsa_scsi_do_report_phys_luns(struct ctlr_info *h,
+               struct ReportLUNdata *buf,
+               int bufsize, int extended_response)
+{
+       return hpsa_scsi_do_report_luns(h, 0, buf, bufsize, extended_response);
+}
+
+static inline int hpsa_scsi_do_report_log_luns(struct ctlr_info *h,
+               struct ReportLUNdata *buf, int bufsize)
+{
+       return hpsa_scsi_do_report_luns(h, 1, buf, bufsize, 0);
+}
+
+static inline void hpsa_set_bus_target_lun(struct hpsa_scsi_dev_t *device,
+       int bus, int target, int lun)
+{
+       device->bus = bus;
+       device->target = target;
+       device->lun = lun;
+}
+
+static int hpsa_update_device_info(struct ctlr_info *h,
+       unsigned char scsi3addr[], struct hpsa_scsi_dev_t *this_device)
+{
+#define OBDR_TAPE_INQ_SIZE 49
+       unsigned char *inq_buff = NULL;
+
+       inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
+       if (!inq_buff)
+               goto bail_out;
+
+       memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE);
+       /* Do an inquiry to the device to see what it is. */
+       if (hpsa_scsi_do_inquiry(h, scsi3addr, 0, inq_buff,
+               (unsigned char) OBDR_TAPE_INQ_SIZE) != 0) {
+               /* Inquiry failed (msg printed already) */
+               dev_err(&h->pdev->dev,
+                       "hpsa_update_device_info: inquiry failed\n");
+               goto bail_out;
+       }
+
+       /* As a side effect, record the firmware version number
+        * if we happen to be talking to the RAID controller.
+        */
+       if (is_hba_lunid(scsi3addr))
+               memcpy(h->firm_ver, &inq_buff[32], 4);
+
+       this_device->devtype = (inq_buff[0] & 0x1f);
+       memcpy(this_device->scsi3addr, scsi3addr, 8);
+       memcpy(this_device->vendor, &inq_buff[8],
+               sizeof(this_device->vendor));
+       memcpy(this_device->model, &inq_buff[16],
+               sizeof(this_device->model));
+       memcpy(this_device->revision, &inq_buff[32],
+               sizeof(this_device->revision));
+       memset(this_device->device_id, 0,
+               sizeof(this_device->device_id));
+       hpsa_get_device_id(h, scsi3addr, this_device->device_id,
+               sizeof(this_device->device_id));
+
+       if (this_device->devtype == TYPE_DISK &&
+               is_logical_dev_addr_mode(scsi3addr))
+               hpsa_get_raid_level(h, scsi3addr, &this_device->raid_level);
+       else
+               this_device->raid_level = RAID_UNKNOWN;
+
+       kfree(inq_buff);
+       return 0;
+
+bail_out:
+       kfree(inq_buff);
+       return 1;
+}
+
+static unsigned char *msa2xxx_model[] = {
+       "MSA2012",
+       "MSA2024",
+       "MSA2312",
+       "MSA2324",
+       NULL,
+};
+
+static int is_msa2xxx(struct ctlr_info *h, struct hpsa_scsi_dev_t *device)
+{
+       int i;
+
+       for (i = 0; msa2xxx_model[i]; i++)
+               if (strncmp(device->model, msa2xxx_model[i],
+                       strlen(msa2xxx_model[i])) == 0)
+                       return 1;
+       return 0;
+}
+
+/* Helper function to assign bus, target, lun mapping of devices.
+ * Puts non-msa2xxx logical volumes on bus 0, msa2xxx logical
+ * volumes on bus 1, physical devices on bus 2. and the hba on bus 3.
+ * Logical drive target and lun are assigned at this time, but
+ * physical device lun and target assignment are deferred (assigned
+ * in hpsa_find_target_lun, called by hpsa_scsi_add_entry.)
+ */
+static void figure_bus_target_lun(struct ctlr_info *h,
+       __u8 *lunaddrbytes, int *bus, int *target, int *lun,
+       struct hpsa_scsi_dev_t *device)
+{
+
+       __u32 lunid;
+
+       if (is_logical_dev_addr_mode(lunaddrbytes)) {
+               /* logical device */
+               memcpy(&lunid, lunaddrbytes, sizeof(lunid));
+               lunid = le32_to_cpu(lunid);
+
+               if (is_msa2xxx(h, device)) {
+                       *bus = 1;
+                       *target = (lunid >> 16) & 0x3fff;
+                       *lun = lunid & 0x00ff;
+               } else {
+                       *bus = 0;
+                       *lun = 0;
+                       *target = lunid & 0x3fff;
+               }
+       } else {
+               /* physical device */
+               if (is_hba_lunid(lunaddrbytes))
+                       *bus = 3;
+               else
+                       *bus = 2;
+               *target = -1;
+               *lun = -1; /* we will fill these in later. */
+       }
+}
+
+/*
+ * If there is no lun 0 on a target, linux won't find any devices.
+ * For the MSA2xxx boxes, we have to manually detect the enclosure
+ * which is at lun zero, as CCISS_REPORT_PHYSICAL_LUNS doesn't report
+ * it for some reason.  *tmpdevice is the target we're adding,
+ * this_device is a pointer into the current element of currentsd[]
+ * that we're building up in update_scsi_devices(), below.
+ * lunzerobits is a bitmap that tracks which targets already have a
+ * lun 0 assigned.
+ * Returns 1 if an enclosure was added, 0 if not.
+ */
+static int add_msa2xxx_enclosure_device(struct ctlr_info *h,
+       struct hpsa_scsi_dev_t *tmpdevice,
+       struct hpsa_scsi_dev_t *this_device, __u8 *lunaddrbytes,
+       int bus, int target, int lun, unsigned long lunzerobits[],
+       int *nmsa2xxx_enclosures)
+{
+       unsigned char scsi3addr[8];
+
+       if (test_bit(target, lunzerobits))
+               return 0; /* There is already a lun 0 on this target. */
+
+       if (!is_logical_dev_addr_mode(lunaddrbytes))
+               return 0; /* It's the logical targets that may lack lun 0. */
+
+       if (!is_msa2xxx(h, tmpdevice))
+               return 0; /* It's only the MSA2xxx that have this problem. */
+
+       if (lun == 0) /* if lun is 0, then obviously we have a lun 0. */
+               return 0;
+
+       if (is_hba_lunid(scsi3addr))
+               return 0; /* Don't add the RAID controller here. */
+
+#define MAX_MSA2XXX_ENCLOSURES 32
+       if (*nmsa2xxx_enclosures >= MAX_MSA2XXX_ENCLOSURES) {
+               dev_warn(&h->pdev->dev, "Maximum number of MSA2XXX "
+                       "enclosures exceeded.  Check your hardware "
+                       "configuration.");
+               return 0;
+       }
+
+       memset(scsi3addr, 0, 8);
+       scsi3addr[3] = target;
+       if (hpsa_update_device_info(h, scsi3addr, this_device))
+               return 0;
+       (*nmsa2xxx_enclosures)++;
+       hpsa_set_bus_target_lun(this_device, bus, target, 0);
+       set_bit(target, lunzerobits);
+       return 1;
+}
+
+/*
+ * Do CISS_REPORT_PHYS and CISS_REPORT_LOG.  Data is returned in physdev,
+ * logdev.  The number of luns in physdev and logdev are returned in
+ * *nphysicals and *nlogicals, respectively.
+ * Returns 0 on success, -1 otherwise.
+ */
+static int hpsa_gather_lun_info(struct ctlr_info *h,
+       int reportlunsize,
+       struct ReportLUNdata *physdev, __u32 *nphysicals,
+       struct ReportLUNdata *logdev, __u32 *nlogicals)
+{
+       if (hpsa_scsi_do_report_phys_luns(h, physdev, reportlunsize, 0)) {
+               dev_err(&h->pdev->dev, "report physical LUNs failed.\n");
+               return -1;
+       }
+       memcpy(nphysicals, &physdev->LUNListLength[0], sizeof(*nphysicals));
+       *nphysicals = be32_to_cpu(*nphysicals) / 8;
+#ifdef DEBUG
+       dev_info(&h->pdev->dev, "number of physical luns is %d\n", *nphysicals);
+#endif
+       if (*nphysicals > HPSA_MAX_PHYS_LUN) {
+               dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded."
+                       "  %d LUNs ignored.\n", HPSA_MAX_PHYS_LUN,
+                       *nphysicals - HPSA_MAX_PHYS_LUN);
+               *nphysicals = HPSA_MAX_PHYS_LUN;
+       }
+       if (hpsa_scsi_do_report_log_luns(h, logdev, reportlunsize)) {
+               dev_err(&h->pdev->dev, "report logical LUNs failed.\n");
+               return -1;
+       }
+       memcpy(nlogicals, &logdev->LUNListLength[0], sizeof(*nlogicals));
+       *nlogicals = be32_to_cpu(*nlogicals) / 8;
+#ifdef DEBUG
+       dev_info(&h->pdev->dev, "number of logical luns is %d\n", *nlogicals);
+#endif
+       /* Reject Logicals in excess of our max capability. */
+       if (*nlogicals > HPSA_MAX_LUN) {
+               dev_warn(&h->pdev->dev,
+                       "maximum logical LUNs (%d) exceeded.  "
+                       "%d LUNs ignored.\n", HPSA_MAX_LUN,
+                       *nlogicals - HPSA_MAX_LUN);
+                       *nlogicals = HPSA_MAX_LUN;
+       }
+       if (*nlogicals + *nphysicals > HPSA_MAX_PHYS_LUN) {
+               dev_warn(&h->pdev->dev,
+                       "maximum logical + physical LUNs (%d) exceeded. "
+                       "%d LUNs ignored.\n", HPSA_MAX_PHYS_LUN,
+                       *nphysicals + *nlogicals - HPSA_MAX_PHYS_LUN);
+               *nlogicals = HPSA_MAX_PHYS_LUN - *nphysicals;
+       }
+       return 0;
+}
+
+static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)
+{
+       /* the idea here is we could get notified
+        * that some devices have changed, so we do a report
+        * physical luns and report logical luns cmd, and adjust
+        * our list of devices accordingly.
+        *
+        * The scsi3addr's of devices won't change so long as the
+        * adapter is not reset.  That means we can rescan and
+        * tell which devices we already know about, vs. new
+        * devices, vs.  disappearing devices.
+        */
+       struct ReportLUNdata *physdev_list = NULL;
+       struct ReportLUNdata *logdev_list = NULL;
+       unsigned char *inq_buff = NULL;
+       __u32 nphysicals = 0;
+       __u32 nlogicals = 0;
+       __u32 ndev_allocated = 0;
+       struct hpsa_scsi_dev_t **currentsd, *this_device, *tmpdevice;
+       int ncurrent = 0;
+       int reportlunsize = sizeof(*physdev_list) + HPSA_MAX_PHYS_LUN * 8;
+       int i, nmsa2xxx_enclosures, ndevs_to_allocate;
+       int bus, target, lun;
+       DECLARE_BITMAP(lunzerobits, HPSA_MAX_TARGETS_PER_CTLR);
+
+       currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_SCSI_DEVS_PER_HBA,
+               GFP_KERNEL);
+       physdev_list = kzalloc(reportlunsize, GFP_KERNEL);
+       logdev_list = kzalloc(reportlunsize, GFP_KERNEL);
+       inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
+       tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL);
+
+       if (!currentsd || !physdev_list || !logdev_list ||
+               !inq_buff || !tmpdevice) {
+               dev_err(&h->pdev->dev, "out of memory\n");
+               goto out;
+       }
+       memset(lunzerobits, 0, sizeof(lunzerobits));
+
+       if (hpsa_gather_lun_info(h, reportlunsize, physdev_list, &nphysicals,
+                       logdev_list, &nlogicals))
+               goto out;
+
+       /* We might see up to 32 MSA2xxx enclosures, actually 8 of them
+        * but each of them 4 times through different paths.  The plus 1
+        * is for the RAID controller.
+        */
+       ndevs_to_allocate = nphysicals + nlogicals + MAX_MSA2XXX_ENCLOSURES + 1;
+
+       /* Allocate the per device structures */
+       for (i = 0; i < ndevs_to_allocate; i++) {
+               currentsd[i] = kzalloc(sizeof(*currentsd[i]), GFP_KERNEL);
+               if (!currentsd[i]) {
+                       dev_warn(&h->pdev->dev, "out of memory at %s:%d\n",
+                               __FILE__, __LINE__);
+                       goto out;
+               }
+               ndev_allocated++;
+       }
+
+       /* adjust our table of devices */
+       nmsa2xxx_enclosures = 0;
+       for (i = 0; i < nphysicals + nlogicals + 1; i++) {
+               __u8 *lunaddrbytes;
+
+               /* Figure out where the LUN ID info is coming from */
+               if (i < nphysicals)
+                       lunaddrbytes = &physdev_list->LUN[i][0];
+               else
+                       if (i < nphysicals + nlogicals)
+                               lunaddrbytes =
+                                       &logdev_list->LUN[i-nphysicals][0];
+                       else /* jam in the RAID controller at the end */
+                               lunaddrbytes = RAID_CTLR_LUNID;
+
+               /* skip masked physical devices. */
+               if (lunaddrbytes[3] & 0xC0 && i < nphysicals)
+                       continue;
+
+               /* Get device type, vendor, model, device id */
+               if (hpsa_update_device_info(h, lunaddrbytes, tmpdevice))
+                       continue; /* skip it if we can't talk to it. */
+               figure_bus_target_lun(h, lunaddrbytes, &bus, &target, &lun,
+                       tmpdevice);
+               this_device = currentsd[ncurrent];
+
+               /*
+                * For the msa2xxx boxes, we have to insert a LUN 0 which
+                * doesn't show up in CCISS_REPORT_PHYSICAL data, but there
+                * is nonetheless an enclosure device there.  We have to
+                * present that otherwise linux won't find anything if
+                * there is no lun 0.
+                */
+               if (add_msa2xxx_enclosure_device(h, tmpdevice, this_device,
+                               lunaddrbytes, bus, target, lun, lunzerobits,
+                               &nmsa2xxx_enclosures)) {
+                       ncurrent++;
+                       this_device = currentsd[ncurrent];
+               }
+
+               *this_device = *tmpdevice;
+               hpsa_set_bus_target_lun(this_device, bus, target, lun);
+
+               switch (this_device->devtype) {
+               case TYPE_ROM: {
+                       /* We don't *really* support actual CD-ROM devices,
+                        * just "One Button Disaster Recovery" tape drive
+                        * which temporarily pretends to be a CD-ROM drive.
+                        * So we check that the device is really an OBDR tape
+                        * device by checking for "$DR-10" in bytes 43-48 of
+                        * the inquiry data.
+                        */
+                               char obdr_sig[7];
+#define OBDR_TAPE_SIG "$DR-10"
+                               strncpy(obdr_sig, &inq_buff[43], 6);
+                               obdr_sig[6] = '\0';
+                               if (strncmp(obdr_sig, OBDR_TAPE_SIG, 6) != 0)
+                                       /* Not OBDR device, ignore it. */
+                                       break;
+                       }
+                       ncurrent++;
+                       break;
+               case TYPE_DISK:
+                       if (i < nphysicals)
+                               break;
+                       ncurrent++;
+                       break;
+               case TYPE_TAPE:
+               case TYPE_MEDIUM_CHANGER:
+                       ncurrent++;
+                       break;
+               case TYPE_RAID:
+                       /* Only present the Smartarray HBA as a RAID controller.
+                        * If it's a RAID controller other than the HBA itself
+                        * (an external RAID controller, MSA500 or similar)
+                        * don't present it.
+                        */
+                       if (!is_hba_lunid(lunaddrbytes))
+                               break;
+                       ncurrent++;
+                       break;
+               default:
+                       break;
+               }
+               if (ncurrent >= HPSA_MAX_SCSI_DEVS_PER_HBA)
+                       break;
+       }
+       adjust_hpsa_scsi_table(h, hostno, currentsd, ncurrent);
+out:
+       kfree(tmpdevice);
+       for (i = 0; i < ndev_allocated; i++)
+               kfree(currentsd[i]);
+       kfree(currentsd);
+       kfree(inq_buff);
+       kfree(physdev_list);
+       kfree(logdev_list);
+       return;
+}
+
+/* hpsa_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci
+ * dma mapping  and fills in the scatter gather entries of the
+ * hpsa command, cp.
+ */
+static int hpsa_scatter_gather(struct pci_dev *pdev,
+               struct CommandList *cp,
+               struct scsi_cmnd *cmd)
+{
+       unsigned int len;
+       struct scatterlist *sg;
+       __u64 addr64;
+       int use_sg, i;
+
+       BUG_ON(scsi_sg_count(cmd) > MAXSGENTRIES);
+
+       use_sg = scsi_dma_map(cmd);
+       if (use_sg < 0)
+               return use_sg;
+
+       if (!use_sg)
+               goto sglist_finished;
+
+       scsi_for_each_sg(cmd, sg, use_sg, i) {
+               addr64 = (__u64) sg_dma_address(sg);
+               len  = sg_dma_len(sg);
+               cp->SG[i].Addr.lower =
+                       (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF);
+               cp->SG[i].Addr.upper =
+                       (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF);
+               cp->SG[i].Len = len;
+               cp->SG[i].Ext = 0;  /* we are not chaining */
+       }
+
+sglist_finished:
+
+       cp->Header.SGList = (__u8) use_sg;   /* no. SGs contig in this cmd */
+       cp->Header.SGTotal = (__u16) use_sg; /* total sgs in this cmd list */
+       return 0;
+}
+
+
+static int hpsa_scsi_queue_command(struct scsi_cmnd *cmd,
+       void (*done)(struct scsi_cmnd *))
+{
+       struct ctlr_info *h;
+       struct hpsa_scsi_dev_t *dev;
+       unsigned char scsi3addr[8];
+       struct CommandList *c;
+       unsigned long flags;
+
+       /* Get the ptr to our adapter structure out of cmd->host. */
+       h = sdev_to_hba(cmd->device);
+       dev = cmd->device->hostdata;
+       if (!dev) {
+               cmd->result = DID_NO_CONNECT << 16;
+               done(cmd);
+               return 0;
+       }
+       memcpy(scsi3addr, dev->scsi3addr, sizeof(scsi3addr));
+
+       /* Need a lock as this is being allocated from the pool */
+       spin_lock_irqsave(&h->lock, flags);
+       c = cmd_alloc(h);
+       spin_unlock_irqrestore(&h->lock, flags);
+       if (c == NULL) {                        /* trouble... */
+               dev_err(&h->pdev->dev, "cmd_alloc returned NULL!\n");
+               return SCSI_MLQUEUE_HOST_BUSY;
+       }
+
+       /* Fill in the command list header */
+
+       cmd->scsi_done = done;    /* save this for use by completion code */
+
+       /* save c in case we have to abort it  */
+       cmd->host_scribble = (unsigned char *) c;
+
+       c->cmd_type = CMD_SCSI;
+       c->scsi_cmd = cmd;
+       c->Header.ReplyQueue = 0;  /* unused in simple mode */
+       memcpy(&c->Header.LUN.LunAddrBytes[0], &scsi3addr[0], 8);
+       c->Header.Tag.lower = c->busaddr;  /* Use k. address of cmd as tag */
+
+       /* Fill in the request block... */
+
+       c->Request.Timeout = 0;
+       memset(c->Request.CDB, 0, sizeof(c->Request.CDB));
+       BUG_ON(cmd->cmd_len > sizeof(c->Request.CDB));
+       c->Request.CDBLen = cmd->cmd_len;
+       memcpy(c->Request.CDB, cmd->cmnd, cmd->cmd_len);
+       c->Request.Type.Type = TYPE_CMD;
+       c->Request.Type.Attribute = ATTR_SIMPLE;
+       switch (cmd->sc_data_direction) {
+       case DMA_TO_DEVICE:
+               c->Request.Type.Direction = XFER_WRITE;
+               break;
+       case DMA_FROM_DEVICE:
+               c->Request.Type.Direction = XFER_READ;
+               break;
+       case DMA_NONE:
+               c->Request.Type.Direction = XFER_NONE;
+               break;
+       case DMA_BIDIRECTIONAL:
+               /* This can happen if a buggy application does a scsi passthru
+                * and sets both inlen and outlen to non-zero. ( see
+                * ../scsi/scsi_ioctl.c:scsi_ioctl_send_command() )
+                */
+
+               c->Request.Type.Direction = XFER_RSVD;
+               /* This is technically wrong, and hpsa controllers should
+                * reject it with CMD_INVALID, which is the most correct
+                * response, but non-fibre backends appear to let it
+                * slide by, and give the same results as if this field
+                * were set correctly.  Either way is acceptable for
+                * our purposes here.
+                */
+
+               break;
+
+       default:
+               dev_err(&h->pdev->dev, "unknown data direction: %d\n",
+                       cmd->sc_data_direction);
+               BUG();
+               break;
+       }
+
+       if (hpsa_scatter_gather(h->pdev, c, cmd) < 0) { /* Fill SG list */
+               cmd_free(h, c);
+               return SCSI_MLQUEUE_HOST_BUSY;
+       }
+       enqueue_cmd_and_start_io(h, c);
+       /* the cmd'll come back via intr handler in complete_scsi_command()  */
+       return 0;
+}
+
+static void hpsa_unregister_scsi(struct ctlr_info *h)
+{
+       /* we are being forcibly unloaded, and may not refuse. */
+       scsi_remove_host(h->scsi_host);
+       scsi_host_put(h->scsi_host);
+       h->scsi_host = NULL;
+}
+
+static int hpsa_register_scsi(struct ctlr_info *h)
+{
+       int rc;
+
+       hpsa_update_scsi_devices(h, -1);
+       rc = hpsa_scsi_detect(h);
+       if (rc != 0)
+               dev_err(&h->pdev->dev, "hpsa_register_scsi: failed"
+                       " hpsa_scsi_detect(), rc is %d\n", rc);
+       return rc;
+}
+
+static int wait_for_device_to_become_ready(struct ctlr_info *h,
+       unsigned char lunaddr[])
+{
+       int rc = 0;
+       int count = 0;
+       int waittime = 1; /* seconds */
+       struct CommandList *c;
+
+       c = cmd_special_alloc(h);
+       if (!c) {
+               dev_warn(&h->pdev->dev, "out of memory in "
+                       "wait_for_device_to_become_ready.\n");
+               return IO_ERROR;
+       }
+
+       /* Send test unit ready until device ready, or give up. */
+       while (count < HPSA_TUR_RETRY_LIMIT) {
+
+               /* Wait for a bit.  do this first, because if we send
+                * the TUR right away, the reset will just abort it.
+                */
+               msleep(1000 * waittime);
+               count++;
+
+               /* Increase wait time with each try, up to a point. */
+               if (waittime < HPSA_MAX_WAIT_INTERVAL_SECS)
+                       waittime = waittime * 2;
+
+               /* Send the Test Unit Ready */
+               fill_cmd(c, TEST_UNIT_READY, h, NULL, 0, 0, lunaddr, TYPE_CMD);
+               hpsa_scsi_do_simple_cmd_core(h, c);
+               /* no unmap needed here because no data xfer. */
+
+               if (c->err_info->CommandStatus == CMD_SUCCESS)
+                       break;
+
+               if (c->err_info->CommandStatus == CMD_TARGET_STATUS &&
+                       c->err_info->ScsiStatus == SAM_STAT_CHECK_CONDITION &&
+                       (c->err_info->SenseInfo[2] == NO_SENSE ||
+                       c->err_info->SenseInfo[2] == UNIT_ATTENTION))
+                       break;
+
+               dev_warn(&h->pdev->dev, "waiting %d secs "
+                       "for device to become ready.\n", waittime);
+               rc = 1; /* device not ready. */
+       }
+
+       if (rc)
+               dev_warn(&h->pdev->dev, "giving up on device.\n");
+       else
+               dev_warn(&h->pdev->dev, "device is ready.\n");
+
+       cmd_special_free(h, c);
+       return rc;
+}
+
+/* Need at least one of these error handlers to keep ../scsi/hosts.c from
+ * complaining.  Doing a host- or bus-reset can't do anything good here.
+ */
+static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
+{
+       int rc;
+       struct ctlr_info *h;
+       struct hpsa_scsi_dev_t *dev;
+
+       /* find the controller to which the command to be aborted was sent */
+       h = sdev_to_hba(scsicmd->device);
+       if (h == NULL) /* paranoia */
+               return FAILED;
+       dev_warn(&h->pdev->dev, "resetting drive\n");
+
+       dev = scsicmd->device->hostdata;
+       if (!dev) {
+               dev_err(&h->pdev->dev, "hpsa_eh_device_reset_handler: "
+                       "device lookup failed.\n");
+               return FAILED;
+       }
+       /* send a reset to the SCSI LUN which the command was sent to */
+       rc = hpsa_send_reset(h, dev->scsi3addr);
+       if (rc == 0 && wait_for_device_to_become_ready(h, dev->scsi3addr) == 0)
+               return SUCCESS;
+
+       dev_warn(&h->pdev->dev, "resetting device failed.\n");
+       return FAILED;
+}
+
+/*
+ * For operations that cannot sleep, a command block is allocated at init,
+ * and managed by cmd_alloc() and cmd_free() using a simple bitmap to track
+ * which ones are free or in use.  Lock must be held when calling this.
+ * cmd_free() is the complement.
+ */
+static struct CommandList *cmd_alloc(struct ctlr_info *h)
+{
+       struct CommandList *c;
+       int i;
+       union u64bit temp64;
+       dma_addr_t cmd_dma_handle, err_dma_handle;
+
+       do {
+               i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
+               if (i == h->nr_cmds)
+                       return NULL;
+       } while (test_and_set_bit
+                (i & (BITS_PER_LONG - 1),
+                 h->cmd_pool_bits + (i / BITS_PER_LONG)) != 0);
+       c = h->cmd_pool + i;
+       memset(c, 0, sizeof(*c));
+       cmd_dma_handle = h->cmd_pool_dhandle
+           + i * sizeof(*c);
+       c->err_info = h->errinfo_pool + i;
+       memset(c->err_info, 0, sizeof(*c->err_info));
+       err_dma_handle = h->errinfo_pool_dhandle
+           + i * sizeof(*c->err_info);
+       h->nr_allocs++;
+
+       c->cmdindex = i;
+
+       INIT_HLIST_NODE(&c->list);
+       c->busaddr = (__u32) cmd_dma_handle;
+       temp64.val = (__u64) err_dma_handle;
+       c->ErrDesc.Addr.lower = temp64.val32.lower;
+       c->ErrDesc.Addr.upper = temp64.val32.upper;
+       c->ErrDesc.Len = sizeof(*c->err_info);
+
+       c->h = h;
+       return c;
+}
+
+/* For operations that can wait for kmalloc to possibly sleep,
+ * this routine can be called. Lock need not be held to call
+ * cmd_special_alloc. cmd_special_free() is the complement.
+ */
+static struct CommandList *cmd_special_alloc(struct ctlr_info *h)
+{
+       struct CommandList *c;
+       union u64bit temp64;
+       dma_addr_t cmd_dma_handle, err_dma_handle;
+
+       c = pci_alloc_consistent(h->pdev, sizeof(*c), &cmd_dma_handle);
+       if (c == NULL)
+               return NULL;
+       memset(c, 0, sizeof(*c));
+
+       c->cmdindex = -1;
+
+       c->err_info = pci_alloc_consistent(h->pdev, sizeof(*c->err_info),
+                   &err_dma_handle);
+
+       if (c->err_info == NULL) {
+               pci_free_consistent(h->pdev,
+                       sizeof(*c), c, cmd_dma_handle);
+               return NULL;
+       }
+       memset(c->err_info, 0, sizeof(*c->err_info));
+
+       INIT_HLIST_NODE(&c->list);
+       c->busaddr = (__u32) cmd_dma_handle;
+       temp64.val = (__u64) err_dma_handle;
+       c->ErrDesc.Addr.lower = temp64.val32.lower;
+       c->ErrDesc.Addr.upper = temp64.val32.upper;
+       c->ErrDesc.Len = sizeof(*c->err_info);
+
+       c->h = h;
+       return c;
+}
+
+static void cmd_free(struct ctlr_info *h, struct CommandList *c)
+{
+       int i;
+
+       i = c - h->cmd_pool;
+       clear_bit(i & (BITS_PER_LONG - 1),
+                 h->cmd_pool_bits + (i / BITS_PER_LONG));
+       h->nr_frees++;
+}
+
+static void cmd_special_free(struct ctlr_info *h, struct CommandList *c)
+{
+       union u64bit temp64;
+
+       temp64.val32.lower = c->ErrDesc.Addr.lower;
+       temp64.val32.upper = c->ErrDesc.Addr.upper;
+       pci_free_consistent(h->pdev, sizeof(*c->err_info),
+                           c->err_info, (dma_addr_t) temp64.val);
+       pci_free_consistent(h->pdev, sizeof(*c),
+                           c, (dma_addr_t) c->busaddr);
+}
+
+#ifdef CONFIG_COMPAT
+
+static int do_ioctl(struct scsi_device *dev, int cmd, void *arg)
+{
+       int ret;
+
+       lock_kernel();
+       ret = hpsa_ioctl(dev, cmd, arg);
+       unlock_kernel();
+       return ret;
+}
+
+static int hpsa_ioctl32_passthru(struct scsi_device *dev, int cmd, void *arg);
+static int hpsa_ioctl32_big_passthru(struct scsi_device *dev,
+       int cmd, void *arg);
+
+static int hpsa_compat_ioctl(struct scsi_device *dev, int cmd, void *arg)
+{
+       switch (cmd) {
+       case CCISS_GETPCIINFO:
+       case CCISS_GETINTINFO:
+       case CCISS_SETINTINFO:
+       case CCISS_GETNODENAME:
+       case CCISS_SETNODENAME:
+       case CCISS_GETHEARTBEAT:
+       case CCISS_GETBUSTYPES:
+       case CCISS_GETFIRMVER:
+       case CCISS_GETDRIVVER:
+       case CCISS_REVALIDVOLS:
+       case CCISS_DEREGDISK:
+       case CCISS_REGNEWDISK:
+       case CCISS_REGNEWD:
+       case CCISS_RESCANDISK:
+       case CCISS_GETLUNINFO:
+               return do_ioctl(dev, cmd, arg);
+
+       case CCISS_PASSTHRU32:
+               return hpsa_ioctl32_passthru(dev, cmd, arg);
+       case CCISS_BIG_PASSTHRU32:
+               return hpsa_ioctl32_big_passthru(dev, cmd, arg);
+
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+
+static int hpsa_ioctl32_passthru(struct scsi_device *dev, int cmd, void *arg)
+{
+       IOCTL32_Command_struct __user *arg32 =
+           (IOCTL32_Command_struct __user *) arg;
+       IOCTL_Command_struct arg64;
+       IOCTL_Command_struct __user *p = compat_alloc_user_space(sizeof(arg64));
+       int err;
+       u32 cp;
+
+       err = 0;
+       err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
+                          sizeof(arg64.LUN_info));
+       err |= copy_from_user(&arg64.Request, &arg32->Request,
+                          sizeof(arg64.Request));
+       err |= copy_from_user(&arg64.error_info, &arg32->error_info,
+                          sizeof(arg64.error_info));
+       err |= get_user(arg64.buf_size, &arg32->buf_size);
+       err |= get_user(cp, &arg32->buf);
+       arg64.buf = compat_ptr(cp);
+       err |= copy_to_user(p, &arg64, sizeof(arg64));
+
+       if (err)
+               return -EFAULT;
+
+       err = do_ioctl(dev, CCISS_PASSTHRU, (void *)p);
+       if (err)
+               return err;
+       err |= copy_in_user(&arg32->error_info, &p->error_info,
+                        sizeof(arg32->error_info));
+       if (err)
+               return -EFAULT;
+       return err;
+}
+
+static int hpsa_ioctl32_big_passthru(struct scsi_device *dev,
+       int cmd, void *arg)
+{
+       BIG_IOCTL32_Command_struct __user *arg32 =
+           (BIG_IOCTL32_Command_struct __user *) arg;
+       BIG_IOCTL_Command_struct arg64;
+       BIG_IOCTL_Command_struct __user *p =
+           compat_alloc_user_space(sizeof(arg64));
+       int err;
+       u32 cp;
+
+       err = 0;
+       err |= copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
+                          sizeof(arg64.LUN_info));
+       err |= copy_from_user(&arg64.Request, &arg32->Request,
+                          sizeof(arg64.Request));
+       err |= copy_from_user(&arg64.error_info, &arg32->error_info,
+                          sizeof(arg64.error_info));
+       err |= get_user(arg64.buf_size, &arg32->buf_size);
+       err |= get_user(arg64.malloc_size, &arg32->malloc_size);
+       err |= get_user(cp, &arg32->buf);
+       arg64.buf = compat_ptr(cp);
+       err |= copy_to_user(p, &arg64, sizeof(arg64));
+
+       if (err)
+               return -EFAULT;
+
+       err = do_ioctl(dev, CCISS_BIG_PASSTHRU, (void *)p);
+       if (err)
+               return err;
+       err |= copy_in_user(&arg32->error_info, &p->error_info,
+                        sizeof(arg32->error_info));
+       if (err)
+               return -EFAULT;
+       return err;
+}
+#endif
+
+static int hpsa_getpciinfo_ioctl(struct ctlr_info *h, void __user *argp)
+{
+       struct hpsa_pci_info pciinfo;
+
+       if (!argp)
+               return -EINVAL;
+       pciinfo.domain = pci_domain_nr(h->pdev->bus);
+       pciinfo.bus = h->pdev->bus->number;
+       pciinfo.dev_fn = h->pdev->devfn;
+       pciinfo.board_id = h->board_id;
+       if (copy_to_user(argp, &pciinfo, sizeof(pciinfo)))
+               return -EFAULT;
+       return 0;
+}
+
+static int hpsa_getdrivver_ioctl(struct ctlr_info *h, void __user *argp)
+{
+       DriverVer_type DriverVer;
+       unsigned char vmaj, vmin, vsubmin;
+       int rc;
+
+       rc = sscanf(HPSA_DRIVER_VERSION, "%hhu.%hhu.%hhu",
+               &vmaj, &vmin, &vsubmin);
+       if (rc != 3) {
+               dev_info(&h->pdev->dev, "driver version string '%s' "
+                       "unrecognized.", HPSA_DRIVER_VERSION);
+               vmaj = 0;
+               vmin = 0;
+               vsubmin = 0;
+       }
+       DriverVer = (vmaj << 16) | (vmin << 8) | vsubmin;
+       if (!argp)
+               return -EINVAL;
+       if (copy_to_user(argp, &DriverVer, sizeof(DriverVer_type)))
+               return -EFAULT;
+       return 0;
+}
+
+static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp)
+{
+       IOCTL_Command_struct iocommand;
+       struct CommandList *c;
+       char *buff = NULL;
+       union u64bit temp64;
+
+       if (!argp)
+               return -EINVAL;
+       if (!capable(CAP_SYS_RAWIO))
+               return -EPERM;
+       if (copy_from_user(&iocommand, argp, sizeof(iocommand)))
+               return -EFAULT;
+       if ((iocommand.buf_size < 1) &&
+           (iocommand.Request.Type.Direction != XFER_NONE)) {
+               return -EINVAL;
+       }
+       if (iocommand.buf_size > 0) {
+               buff = kmalloc(iocommand.buf_size, GFP_KERNEL);
+               if (buff == NULL)
+                       return -EFAULT;
+       }
+       if (iocommand.Request.Type.Direction == XFER_WRITE) {
+               /* Copy the data into the buffer we created */
+               if (copy_from_user(buff, iocommand.buf, iocommand.buf_size)) {
+                       kfree(buff);
+                       return -EFAULT;
+               }
+       } else
+               memset(buff, 0, iocommand.buf_size);
+       c = cmd_special_alloc(h);
+       if (c == NULL) {
+               kfree(buff);
+               return -ENOMEM;
+       }
+       /* Fill in the command type */
+       c->cmd_type = CMD_IOCTL_PEND;
+       /* Fill in Command Header */
+       c->Header.ReplyQueue = 0; /* unused in simple mode */
+       if (iocommand.buf_size > 0) {   /* buffer to fill */
+               c->Header.SGList = 1;
+               c->Header.SGTotal = 1;
+       } else  { /* no buffers to fill */
+               c->Header.SGList = 0;
+               c->Header.SGTotal = 0;
+       }
+       memcpy(&c->Header.LUN, &iocommand.LUN_info, sizeof(c->Header.LUN));
+       /* use the kernel address the cmd block for tag */
+       c->Header.Tag.lower = c->busaddr;
+
+       /* Fill in Request block */
+       memcpy(&c->Request, &iocommand.Request,
+               sizeof(c->Request));
+
+       /* Fill in the scatter gather information */
+       if (iocommand.buf_size > 0) {
+               temp64.val = pci_map_single(h->pdev, buff,
+                       iocommand.buf_size, PCI_DMA_BIDIRECTIONAL);
+               c->SG[0].Addr.lower = temp64.val32.lower;
+               c->SG[0].Addr.upper = temp64.val32.upper;
+               c->SG[0].Len = iocommand.buf_size;
+               c->SG[0].Ext = 0; /* we are not chaining*/
+       }
+       hpsa_scsi_do_simple_cmd_core(h, c);
+       hpsa_pci_unmap(h->pdev, c, 1, PCI_DMA_BIDIRECTIONAL);
+       check_ioctl_unit_attention(h, c);
+
+       /* Copy the error information out */
+       memcpy(&iocommand.error_info, c->err_info,
+               sizeof(iocommand.error_info));
+       if (copy_to_user(argp, &iocommand, sizeof(iocommand))) {
+               kfree(buff);
+               cmd_special_free(h, c);
+               return -EFAULT;
+       }
+
+       if (iocommand.Request.Type.Direction == XFER_READ) {
+               /* Copy the data out of the buffer we created */
+               if (copy_to_user(iocommand.buf, buff, iocommand.buf_size)) {
+                       kfree(buff);
+                       cmd_special_free(h, c);
+                       return -EFAULT;
+               }
+       }
+       kfree(buff);
+       cmd_special_free(h, c);
+       return 0;
+}
+
+static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
+{
+       BIG_IOCTL_Command_struct *ioc;
+       struct CommandList *c;
+       unsigned char **buff = NULL;
+       int *buff_size = NULL;
+       union u64bit temp64;
+       BYTE sg_used = 0;
+       int status = 0;
+       int i;
+       __u32 left;
+       __u32 sz;
+       BYTE __user *data_ptr;
+
+       if (!argp)
+               return -EINVAL;
+       if (!capable(CAP_SYS_RAWIO))
+               return -EPERM;
+       ioc = (BIG_IOCTL_Command_struct *)
+           kmalloc(sizeof(*ioc), GFP_KERNEL);
+       if (!ioc) {
+               status = -ENOMEM;
+               goto cleanup1;
+       }
+       if (copy_from_user(ioc, argp, sizeof(*ioc))) {
+               status = -EFAULT;
+               goto cleanup1;
+       }
+       if ((ioc->buf_size < 1) &&
+           (ioc->Request.Type.Direction != XFER_NONE)) {
+               status = -EINVAL;
+               goto cleanup1;
+       }
+       /* Check kmalloc limits  using all SGs */
+       if (ioc->malloc_size > MAX_KMALLOC_SIZE) {
+               status = -EINVAL;
+               goto cleanup1;
+       }
+       if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) {
+               status = -EINVAL;
+               goto cleanup1;
+       }
+       buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL);
+       if (!buff) {
+               status = -ENOMEM;
+               goto cleanup1;
+       }
+       buff_size = kmalloc(MAXSGENTRIES * sizeof(int), GFP_KERNEL);
+       if (!buff_size) {
+               status = -ENOMEM;
+               goto cleanup1;
+       }
+       left = ioc->buf_size;
+       data_ptr = ioc->buf;
+       while (left) {
+               sz = (left > ioc->malloc_size) ? ioc->malloc_size : left;
+               buff_size[sg_used] = sz;
+               buff[sg_used] = kmalloc(sz, GFP_KERNEL);
+               if (buff[sg_used] == NULL) {
+                       status = -ENOMEM;
+                       goto cleanup1;
+               }
+               if (ioc->Request.Type.Direction == XFER_WRITE) {
+                       if (copy_from_user(buff[sg_used], data_ptr, sz)) {
+                               status = -ENOMEM;
+                               goto cleanup1;
+                       }
+               } else
+                       memset(buff[sg_used], 0, sz);
+               left -= sz;
+               data_ptr += sz;
+               sg_used++;
+       }
+       c = cmd_special_alloc(h);
+       if (c == NULL) {
+               status = -ENOMEM;
+               goto cleanup1;
+       }
+       c->cmd_type = CMD_IOCTL_PEND;
+       c->Header.ReplyQueue = 0;
+
+       if (ioc->buf_size > 0) {
+               c->Header.SGList = sg_used;
+               c->Header.SGTotal = sg_used;
+       } else {
+               c->Header.SGList = 0;
+               c->Header.SGTotal = 0;
+       }
+       memcpy(&c->Header.LUN, &ioc->LUN_info, sizeof(c->Header.LUN));
+       c->Header.Tag.lower = c->busaddr;
+       memcpy(&c->Request, &ioc->Request, sizeof(c->Request));
+       if (ioc->buf_size > 0) {
+               int i;
+               for (i = 0; i < sg_used; i++) {
+                       temp64.val = pci_map_single(h->pdev, buff[i],
+                                   buff_size[i], PCI_DMA_BIDIRECTIONAL);
+                       c->SG[i].Addr.lower = temp64.val32.lower;
+                       c->SG[i].Addr.upper = temp64.val32.upper;
+                       c->SG[i].Len = buff_size[i];
+                       /* we are not chaining */
+                       c->SG[i].Ext = 0;
+               }
+       }
+       hpsa_scsi_do_simple_cmd_core(h, c);
+       hpsa_pci_unmap(h->pdev, c, sg_used, PCI_DMA_BIDIRECTIONAL);
+       check_ioctl_unit_attention(h, c);
+       /* Copy the error information out */
+       memcpy(&ioc->error_info, c->err_info, sizeof(ioc->error_info));
+       if (copy_to_user(argp, ioc, sizeof(*ioc))) {
+               cmd_special_free(h, c);
+               status = -EFAULT;
+               goto cleanup1;
+       }
+       if (ioc->Request.Type.Direction == XFER_READ) {
+               /* Copy the data out of the buffer we created */
+               BYTE __user *ptr = ioc->buf;
+               for (i = 0; i < sg_used; i++) {
+                       if (copy_to_user(ptr, buff[i], buff_size[i])) {
+                               cmd_special_free(h, c);
+                               status = -EFAULT;
+                               goto cleanup1;
+                       }
+                       ptr += buff_size[i];
+               }
+       }
+       cmd_special_free(h, c);
+       status = 0;
+cleanup1:
+       if (buff) {
+               for (i = 0; i < sg_used; i++)
+                       kfree(buff[i]);
+               kfree(buff);
+       }
+       kfree(buff_size);
+       kfree(ioc);
+       return status;
+}
+
+static void check_ioctl_unit_attention(struct ctlr_info *h,
+       struct CommandList *c)
+{
+       if (c->err_info->CommandStatus == CMD_TARGET_STATUS &&
+                       c->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION)
+               (void) check_for_unit_attention(h, c);
+}
+/*
+ * ioctl
+ */
+static int hpsa_ioctl(struct scsi_device *dev, int cmd, void *arg)
+{
+       struct ctlr_info *h;
+       void __user *argp = (void __user *)arg;
+
+       h = sdev_to_hba(dev);
+
+       switch (cmd) {
+       case CCISS_DEREGDISK:
+       case CCISS_REGNEWDISK:
+       case CCISS_REGNEWD:
+               hpsa_update_scsi_devices(h, dev->host->host_no);
+               return 0;
+       case CCISS_GETPCIINFO:
+               return hpsa_getpciinfo_ioctl(h, argp);
+       case CCISS_GETDRIVVER:
+               return hpsa_getdrivver_ioctl(h, argp);
+       case CCISS_PASSTHRU:
+               return hpsa_passthru_ioctl(h, argp);
+       case CCISS_BIG_PASSTHRU:
+               return hpsa_big_passthru_ioctl(h, argp);
+       default:
+               return -ENOTTY;
+       }
+}
+
+static void fill_cmd(struct CommandList *c, __u8 cmd, struct ctlr_info *h,
+       void *buff, size_t size, __u8 page_code, unsigned char *scsi3addr,
+       int cmd_type)
+{
+       int pci_dir = XFER_NONE;
+
+       c->cmd_type = CMD_IOCTL_PEND;
+       c->Header.ReplyQueue = 0;
+       if (buff != NULL && size > 0) {
+               c->Header.SGList = 1;
+               c->Header.SGTotal = 1;
+       } else {
+               c->Header.SGList = 0;
+               c->Header.SGTotal = 0;
+       }
+       c->Header.Tag.lower = c->busaddr;
+       memcpy(c->Header.LUN.LunAddrBytes, scsi3addr, 8);
+
+       c->Request.Type.Type = cmd_type;
+       if (cmd_type == TYPE_CMD) {
+               switch (cmd) {
+               case HPSA_INQUIRY:
+                       /* are we trying to read a vital product page */
+                       if (page_code != 0) {
+                               c->Request.CDB[1] = 0x01;
+                               c->Request.CDB[2] = page_code;
+                       }
+                       c->Request.CDBLen = 6;
+                       c->Request.Type.Attribute = ATTR_SIMPLE;
+                       c->Request.Type.Direction = XFER_READ;
+                       c->Request.Timeout = 0;
+                       c->Request.CDB[0] = HPSA_INQUIRY;
+                       c->Request.CDB[4] = size & 0xFF;
+                       break;
+               case HPSA_REPORT_LOG:
+               case HPSA_REPORT_PHYS:
+                       /* Talking to controller so It's a physical command
+                          mode = 00 target = 0.  Nothing to write.
+                        */
+                       c->Request.CDBLen = 12;
+                       c->Request.Type.Attribute = ATTR_SIMPLE;
+                       c->Request.Type.Direction = XFER_READ;
+                       c->Request.Timeout = 0;
+                       c->Request.CDB[0] = cmd;
+                       c->Request.CDB[6] = (size >> 24) & 0xFF; /* MSB */
+                       c->Request.CDB[7] = (size >> 16) & 0xFF;
+                       c->Request.CDB[8] = (size >> 8) & 0xFF;
+                       c->Request.CDB[9] = size & 0xFF;
+                       break;
+
+               case HPSA_READ_CAPACITY:
+                       c->Request.CDBLen = 10;
+                       c->Request.Type.Attribute = ATTR_SIMPLE;
+                       c->Request.Type.Direction = XFER_READ;
+                       c->Request.Timeout = 0;
+                       c->Request.CDB[0] = cmd;
+                       break;
+               case HPSA_CACHE_FLUSH:
+                       c->Request.CDBLen = 12;
+                       c->Request.Type.Attribute = ATTR_SIMPLE;
+                       c->Request.Type.Direction = XFER_WRITE;
+                       c->Request.Timeout = 0;
+                       c->Request.CDB[0] = BMIC_WRITE;
+                       c->Request.CDB[6] = BMIC_CACHE_FLUSH;
+                       break;
+               case TEST_UNIT_READY:
+                       c->Request.CDBLen = 6;
+                       c->Request.Type.Attribute = ATTR_SIMPLE;
+                       c->Request.Type.Direction = XFER_NONE;
+                       c->Request.Timeout = 0;
+                       break;
+               default:
+                       dev_warn(&h->pdev->dev, "unknown command 0x%c\n", cmd);
+                       BUG();
+                       return;
+               }
+       } else if (cmd_type == TYPE_MSG) {
+               switch (cmd) {
+
+               case  HPSA_DEVICE_RESET_MSG:
+                       c->Request.CDBLen = 16;
+                       c->Request.Type.Type =  1; /* It is a MSG not a CMD */
+                       c->Request.Type.Attribute = ATTR_SIMPLE;
+                       c->Request.Type.Direction = XFER_NONE;
+                       c->Request.Timeout = 0; /* Don't time out */
+                       c->Request.CDB[0] =  0x01; /* RESET_MSG is 0x01 */
+                       c->Request.CDB[1] = 0x03;  /* Reset target above */
+                       /* If bytes 4-7 are zero, it means reset the */
+                       /* LunID device */
+                       c->Request.CDB[4] = 0x00;
+                       c->Request.CDB[5] = 0x00;
+                       c->Request.CDB[6] = 0x00;
+                       c->Request.CDB[7] = 0x00;
+               break;
+
+               default:
+                       dev_warn(&h->pdev->dev, "unknown message type %d\n",
+                               cmd);
+                       BUG();
+               }
+       } else {
+               dev_warn(&h->pdev->dev, "unknown command type %d\n", cmd_type);
+               BUG();
+       }
+
+       switch (c->Request.Type.Direction) {
+       case XFER_READ:
+               pci_dir = PCI_DMA_FROMDEVICE;
+               break;
+       case XFER_WRITE:
+               pci_dir = PCI_DMA_TODEVICE;
+               break;
+       case XFER_NONE:
+               pci_dir = PCI_DMA_NONE;
+               break;
+       default:
+               pci_dir = PCI_DMA_BIDIRECTIONAL;
+       }
+
+       hpsa_map_one(h->pdev, c, buff, size, pci_dir);
+
+       return;
+}
+
+/*
+ * Map (physical) PCI mem into (virtual) kernel space
+ */
+static void __iomem *remap_pci_mem(ulong base, ulong size)
+{
+       ulong page_base = ((ulong) base) & PAGE_MASK;
+       ulong page_offs = ((ulong) base) - page_base;
+       void __iomem *page_remapped = ioremap(page_base, page_offs + size);
+
+       return page_remapped ? (page_remapped + page_offs) : NULL;
+}
+
+/* Takes cmds off the submission queue and sends them to the hardware,
+ * then puts them on the queue of cmds waiting for completion.
+ */
+static void start_io(struct ctlr_info *h)
+{
+       struct CommandList *c;
+
+       while (!hlist_empty(&h->reqQ)) {
+               c = hlist_entry(h->reqQ.first, struct CommandList, list);
+               /* can't do anything if fifo is full */
+               if ((h->access.fifo_full(h))) {
+                       dev_warn(&h->pdev->dev, "fifo full\n");
+                       break;
+               }
+
+               /* Get the first entry from the Request Q */
+               removeQ(c);
+               h->Qdepth--;
+
+               /* Tell the controller execute command */
+               h->access.submit_command(h, c);
+
+               /* Put job onto the completed Q */
+               addQ(&h->cmpQ, c);
+       }
+}
+
+static inline unsigned long get_next_completion(struct ctlr_info *h)
+{
+       return h->access.command_completed(h);
+}
+
+static inline int interrupt_pending(struct ctlr_info *h)
+{
+       return h->access.intr_pending(h);
+}
+
+static inline long interrupt_not_for_us(struct ctlr_info *h)
+{
+       return ((h->access.intr_pending(h) == 0) ||
+                (h->interrupts_enabled == 0));
+}
+
+static inline int bad_tag(struct ctlr_info *h, __u32 tag_index,
+       __u32 raw_tag)
+{
+       if (unlikely(tag_index >= h->nr_cmds)) {
+               dev_warn(&h->pdev->dev, "bad tag 0x%08x ignored.\n", raw_tag);
+               return 1;
+       }
+       return 0;
+}
+
+static inline void finish_cmd(struct CommandList *c, __u32 raw_tag)
+{
+       removeQ(c);
+       if (likely(c->cmd_type == CMD_SCSI))
+               complete_scsi_command(c, 0, raw_tag);
+       else if (c->cmd_type == CMD_IOCTL_PEND)
+               complete(c->waiting);
+}
+
+static irqreturn_t do_hpsa_intr(int irq, void *dev_id)
+{
+       struct ctlr_info *h = dev_id;
+       struct CommandList *c;
+       unsigned long flags;
+       __u32 raw_tag, tag, tag_index;
+       struct hlist_node *tmp;
+
+       if (interrupt_not_for_us(h))
+               return IRQ_NONE;
+       spin_lock_irqsave(&h->lock, flags);
+       while (interrupt_pending(h)) {
+               while ((raw_tag = get_next_completion(h)) != FIFO_EMPTY) {
+                       if (likely(HPSA_TAG_CONTAINS_INDEX(raw_tag))) {
+                               tag_index = HPSA_TAG_TO_INDEX(raw_tag);
+                               if (bad_tag(h, tag_index, raw_tag))
+                                       return IRQ_HANDLED;
+                               c = h->cmd_pool + tag_index;
+                               finish_cmd(c, raw_tag);
+                               continue;
+                       }
+                       tag = HPSA_TAG_DISCARD_ERROR_BITS(raw_tag);
+                       c = NULL;
+                       hlist_for_each_entry(c, tmp, &h->cmpQ, list) {
+                               if (c->busaddr == tag) {
+                                       finish_cmd(c, raw_tag);
+                                       break;
+                               }
+                       }
+               }
+       }
+       spin_unlock_irqrestore(&h->lock, flags);
+       return IRQ_HANDLED;
+}
+
+/* Send a message CDB to the firmware. */
+static __devinit int hpsa_message(struct pci_dev *pdev, unsigned char opcode,
+                                               unsigned char type)
+{
+       struct Command {
+               struct CommandListHeader CommandHeader;
+               struct RequestBlock Request;
+               struct ErrDescriptor ErrorDescriptor;
+       };
+       struct Command *cmd;
+       static const size_t cmd_sz = sizeof(*cmd) +
+                                       sizeof(cmd->ErrorDescriptor);
+       dma_addr_t paddr64;
+       uint32_t paddr32, tag;
+       void __iomem *vaddr;
+       int i, err;
+
+       vaddr = pci_ioremap_bar(pdev, 0);
+       if (vaddr == NULL)
+               return -ENOMEM;
+
+       /* The Inbound Post Queue only accepts 32-bit physical addresses for the
+        * CCISS commands, so they must be allocated from the lower 4GiB of
+        * memory.
+        */
+       err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+       if (err) {
+               iounmap(vaddr);
+               return -ENOMEM;
+       }
+
+       cmd = pci_alloc_consistent(pdev, cmd_sz, &paddr64);
+       if (cmd == NULL) {
+               iounmap(vaddr);
+               return -ENOMEM;
+       }
+
+       /* This must fit, because of the 32-bit consistent DMA mask.  Also,
+        * although there's no guarantee, we assume that the address is at
+        * least 4-byte aligned (most likely, it's page-aligned).
+        */
+       paddr32 = paddr64;
+
+       cmd->CommandHeader.ReplyQueue = 0;
+       cmd->CommandHeader.SGList = 0;
+       cmd->CommandHeader.SGTotal = 0;
+       cmd->CommandHeader.Tag.lower = paddr32;
+       cmd->CommandHeader.Tag.upper = 0;
+       memset(&cmd->CommandHeader.LUN.LunAddrBytes, 0, 8);
+
+       cmd->Request.CDBLen = 16;
+       cmd->Request.Type.Type = TYPE_MSG;
+       cmd->Request.Type.Attribute = ATTR_HEADOFQUEUE;
+       cmd->Request.Type.Direction = XFER_NONE;
+       cmd->Request.Timeout = 0; /* Don't time out */
+       cmd->Request.CDB[0] = opcode;
+       cmd->Request.CDB[1] = type;
+       memset(&cmd->Request.CDB[2], 0, 14); /* rest of the CDB is reserved */
+       cmd->ErrorDescriptor.Addr.lower = paddr32 + sizeof(*cmd);
+       cmd->ErrorDescriptor.Addr.upper = 0;
+       cmd->ErrorDescriptor.Len = sizeof(struct ErrorInfo);
+
+       writel(paddr32, vaddr + SA5_REQUEST_PORT_OFFSET);
+
+       for (i = 0; i < HPSA_MSG_SEND_RETRY_LIMIT; i++) {
+               tag = readl(vaddr + SA5_REPLY_PORT_OFFSET);
+               if (HPSA_TAG_DISCARD_ERROR_BITS(tag) == paddr32)
+                       break;
+               msleep(HPSA_MSG_SEND_RETRY_INTERVAL_MSECS);
+       }
+
+       iounmap(vaddr);
+
+       /* we leak the DMA buffer here ... no choice since the controller could
+        *  still complete the command.
+        */
+       if (i == HPSA_MSG_SEND_RETRY_LIMIT) {
+               dev_err(&pdev->dev, "controller message %02x:%02x timed out\n",
+                       opcode, type);
+               return -ETIMEDOUT;
+       }
+
+       pci_free_consistent(pdev, cmd_sz, cmd, paddr64);
+
+       if (tag & HPSA_ERROR_BIT) {
+               dev_err(&pdev->dev, "controller message %02x:%02x failed\n",
+                       opcode, type);
+               return -EIO;
+       }
+
+       dev_info(&pdev->dev, "controller message %02x:%02x succeeded\n",
+               opcode, type);
+       return 0;
+}
+
+#define hpsa_soft_reset_controller(p) hpsa_message(p, 1, 0)
+#define hpsa_noop(p) hpsa_message(p, 3, 0)
+
+static __devinit int hpsa_reset_msi(struct pci_dev *pdev)
+{
+/* the #defines are stolen from drivers/pci/msi.h. */
+#define msi_control_reg(base)          (base + PCI_MSI_FLAGS)
+#define PCI_MSIX_FLAGS_ENABLE          (1 << 15)
+
+       int pos;
+       u16 control = 0;
+
+       pos = pci_find_capability(pdev, PCI_CAP_ID_MSI);
+       if (pos) {
+               pci_read_config_word(pdev, msi_control_reg(pos), &control);
+               if (control & PCI_MSI_FLAGS_ENABLE) {
+                       dev_info(&pdev->dev, "resetting MSI\n");
+                       pci_write_config_word(pdev, msi_control_reg(pos),
+                                       control & ~PCI_MSI_FLAGS_ENABLE);
+               }
+       }
+
+       pos = pci_find_capability(pdev, PCI_CAP_ID_MSIX);
+       if (pos) {
+               pci_read_config_word(pdev, msi_control_reg(pos), &control);
+               if (control & PCI_MSIX_FLAGS_ENABLE) {
+                       dev_info(&pdev->dev, "resetting MSI-X\n");
+                       pci_write_config_word(pdev, msi_control_reg(pos),
+                                       control & ~PCI_MSIX_FLAGS_ENABLE);
+               }
+       }
+
+       return 0;
+}
+
+/* This does a hard reset of the controller using PCI power management
+ * states.
+ */
+static __devinit int hpsa_hard_reset_controller(struct pci_dev *pdev)
+{
+       u16 pmcsr, saved_config_space[32];
+       int i, pos;
+
+       dev_info(&pdev->dev, "using PCI PM to reset controller\n");
+
+       /* This is very nearly the same thing as
+        *
+        * pci_save_state(pci_dev);
+        * pci_set_power_state(pci_dev, PCI_D3hot);
+        * pci_set_power_state(pci_dev, PCI_D0);
+        * pci_restore_state(pci_dev);
+        *
+        * but we can't use these nice canned kernel routines on
+        * kexec, because they also check the MSI/MSI-X state in PCI
+        * configuration space and do the wrong thing when it is
+        * set/cleared.  Also, the pci_save/restore_state functions
+        * violate the ordering requirements for restoring the
+        * configuration space from the CCISS document (see the
+        * comment below).  So we roll our own ....
+        */
+
+       for (i = 0; i < 32; i++)
+               pci_read_config_word(pdev, 2*i, &saved_config_space[i]);
+
+       pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
+       if (pos == 0) {
+               dev_err(&pdev->dev,
+                       "hpsa_reset_controller: PCI PM not supported\n");
+               return -ENODEV;
+       }
+
+       /* Quoting from the Open CISS Specification: "The Power
+        * Management Control/Status Register (CSR) controls the power
+        * state of the device.  The normal operating state is D0,
+        * CSR=00h.  The software off state is D3, CSR=03h.  To reset
+        * the controller, place the interface device in D3 then to
+        * D0, this causes a secondary PCI reset which will reset the
+        * controller."
+        */
+
+       /* enter the D3hot power management state */
+       pci_read_config_word(pdev, pos + PCI_PM_CTRL, &pmcsr);
+       pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
+       pmcsr |= PCI_D3hot;
+       pci_write_config_word(pdev, pos + PCI_PM_CTRL, pmcsr);
+
+       msleep(500);
+
+       /* enter the D0 power management state */
+       pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
+       pmcsr |= PCI_D0;
+       pci_write_config_word(pdev, pos + PCI_PM_CTRL, pmcsr);
+
+       msleep(500);
+
+       /* Restore the PCI configuration space.  The Open CISS
+        * Specification says, "Restore the PCI Configuration
+        * Registers, offsets 00h through 60h. It is important to
+        * restore the command register, 16-bits at offset 04h,
+        * last. Do not restore the configuration status register,
+        * 16-bits at offset 06h."  Note that the offset is 2*i.
+        */
+       for (i = 0; i < 32; i++) {
+               if (i == 2 || i == 3)
+                       continue;
+               pci_write_config_word(pdev, 2*i, saved_config_space[i]);
+       }
+       wmb();
+       pci_write_config_word(pdev, 4, saved_config_space[2]);
+
+       return 0;
+}
+
+/*
+ *  We cannot read the structure directly, for portability we must use
+ *   the io functions.
+ *   This is for debug only.
+ */
+#ifdef HPSA_DEBUG
+static void print_cfg_table(struct device *dev, struct CfgTable *tb)
+{
+       int i;
+       char temp_name[17];
+
+       dev_info(dev, "Controller Configuration information\n");
+       dev_info(dev, "------------------------------------\n");
+       for (i = 0; i < 4; i++)
+               temp_name[i] = readb(&(tb->Signature[i]));
+       temp_name[4] = '\0';
+       dev_info(dev, "   Signature = %s\n", temp_name);
+       dev_info(dev, "   Spec Number = %d\n", readl(&(tb->SpecValence)));
+       dev_info(dev, "   Transport methods supported = 0x%x\n",
+              readl(&(tb->TransportSupport)));
+       dev_info(dev, "   Transport methods active = 0x%x\n",
+              readl(&(tb->TransportActive)));
+       dev_info(dev, "   Requested transport Method = 0x%x\n",
+              readl(&(tb->HostWrite.TransportRequest)));
+       dev_info(dev, "   Coalesce Interrupt Delay = 0x%x\n",
+              readl(&(tb->HostWrite.CoalIntDelay)));
+       dev_info(dev, "   Coalesce Interrupt Count = 0x%x\n",
+              readl(&(tb->HostWrite.CoalIntCount)));
+       dev_info(dev, "   Max outstanding commands = 0x%d\n",
+              readl(&(tb->CmdsOutMax)));
+       dev_info(dev, "   Bus Types = 0x%x\n", readl(&(tb->BusTypes)));
+       for (i = 0; i < 16; i++)
+               temp_name[i] = readb(&(tb->ServerName[i]));
+       temp_name[16] = '\0';
+       dev_info(dev, "   Server Name = %s\n", temp_name);
+       dev_info(dev, "   Heartbeat Counter = 0x%x\n\n\n",
+               readl(&(tb->HeartBeat)));
+}
+#endif                         /* HPSA_DEBUG */
+
+static int find_PCI_BAR_index(struct pci_dev *pdev, unsigned long pci_bar_addr)
+{
+       int i, offset, mem_type, bar_type;
+
+       if (pci_bar_addr == PCI_BASE_ADDRESS_0) /* looking for BAR zero? */
+               return 0;
+       offset = 0;
+       for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+               bar_type = pci_resource_flags(pdev, i) & PCI_BASE_ADDRESS_SPACE;
+               if (bar_type == PCI_BASE_ADDRESS_SPACE_IO)
+                       offset += 4;
+               else {
+                       mem_type = pci_resource_flags(pdev, i) &
+                           PCI_BASE_ADDRESS_MEM_TYPE_MASK;
+                       switch (mem_type) {
+                       case PCI_BASE_ADDRESS_MEM_TYPE_32:
+                       case PCI_BASE_ADDRESS_MEM_TYPE_1M:
+                               offset += 4;    /* 32 bit */
+                               break;
+                       case PCI_BASE_ADDRESS_MEM_TYPE_64:
+                               offset += 8;
+                               break;
+                       default:        /* reserved in PCI 2.2 */
+                               dev_warn(&pdev->dev,
+                                      "base address is invalid\n");
+                               return -1;
+                               break;
+                       }
+               }
+               if (offset == pci_bar_addr - PCI_BASE_ADDRESS_0)
+                       return i + 1;
+       }
+       return -1;
+}
+
+/* If MSI/MSI-X is supported by the kernel we will try to enable it on
+ * controllers that are capable. If not, we use IO-APIC mode.
+ */
+
+static void __devinit hpsa_interrupt_mode(struct ctlr_info *h,
+                                          struct pci_dev *pdev, __u32 board_id)
+{
+#ifdef CONFIG_PCI_MSI
+       int err;
+       struct msix_entry hpsa_msix_entries[4] = { {0, 0}, {0, 1},
+       {0, 2}, {0, 3}
+       };
+
+       /* Some boards advertise MSI but don't really support it */
+       if ((board_id == 0x40700E11) ||
+           (board_id == 0x40800E11) ||
+           (board_id == 0x40820E11) || (board_id == 0x40830E11))
+               goto default_int_mode;
+       if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
+               dev_info(&pdev->dev, "MSIX\n");
+               err = pci_enable_msix(pdev, hpsa_msix_entries, 4);
+               if (!err) {
+                       h->intr[0] = hpsa_msix_entries[0].vector;
+                       h->intr[1] = hpsa_msix_entries[1].vector;
+                       h->intr[2] = hpsa_msix_entries[2].vector;
+                       h->intr[3] = hpsa_msix_entries[3].vector;
+                       h->msix_vector = 1;
+                       return;
+               }
+               if (err > 0) {
+                       dev_warn(&pdev->dev, "only %d MSI-X vectors "
+                              "available\n", err);
+                       goto default_int_mode;
+               } else {
+                       dev_warn(&pdev->dev, "MSI-X init failed %d\n",
+                              err);
+                       goto default_int_mode;
+               }
+       }
+       if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
+               dev_info(&pdev->dev, "MSI\n");
+               if (!pci_enable_msi(pdev))
+                       h->msi_vector = 1;
+               else
+                       dev_warn(&pdev->dev, "MSI init failed\n");
+       }
+default_int_mode:
+#endif                         /* CONFIG_PCI_MSI */
+       /* if we get here we're going to use the default interrupt mode */
+       h->intr[SIMPLE_MODE_INT] = pdev->irq;
+       return;
+}
+
+static int hpsa_pci_init(struct ctlr_info *h, struct pci_dev *pdev)
+{
+       ushort subsystem_vendor_id, subsystem_device_id, command;
+       __u32 board_id, scratchpad = 0;
+       __u64 cfg_offset;
+       __u32 cfg_base_addr;
+       __u64 cfg_base_addr_index;
+       int i, prod_index, err;
+
+       subsystem_vendor_id = pdev->subsystem_vendor;
+       subsystem_device_id = pdev->subsystem_device;
+       board_id = (((__u32) (subsystem_device_id << 16) & 0xffff0000) |
+                   subsystem_vendor_id);
+
+       for (i = 0; i < ARRAY_SIZE(products); i++)
+               if (board_id == products[i].board_id)
+                       break;
+
+       prod_index = i;
+
+       if (prod_index == ARRAY_SIZE(products)) {
+               prod_index--;
+               if (subsystem_vendor_id != PCI_VENDOR_ID_HP ||
+                               !hpsa_allow_any) {
+                       dev_warn(&pdev->dev, "unrecognized board ID:"
+                               " 0x%08lx, ignoring.\n",
+                               (unsigned long) board_id);
+                       return -ENODEV;
+               }
+       }
+       /* check to see if controller has been disabled
+        * BEFORE trying to enable it
+        */
+       (void)pci_read_config_word(pdev, PCI_COMMAND, &command);
+       if (!(command & 0x02)) {
+               dev_warn(&pdev->dev, "controller appears to be disabled\n");
+               return -ENODEV;
+       }
+
+       err = pci_enable_device(pdev);
+       if (err) {
+               dev_warn(&pdev->dev, "unable to enable PCI device\n");
+               return err;
+       }
+
+       err = pci_request_regions(pdev, "hpsa");
+       if (err) {
+               dev_err(&pdev->dev, "cannot obtain PCI resources, aborting\n");
+               return err;
+       }
+
+       /* If the kernel supports MSI/MSI-X we will try to enable that,
+        * else we use the IO-APIC interrupt assigned to us by system ROM.
+        */
+       hpsa_interrupt_mode(h, pdev, board_id);
+
+       /* find the memory BAR */
+       for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
+               if (pci_resource_flags(pdev, i) & IORESOURCE_MEM)
+                       break;
+       }
+       if (i == DEVICE_COUNT_RESOURCE) {
+               dev_warn(&pdev->dev, "no memory BAR found\n");
+               err = -ENODEV;
+               goto err_out_free_res;
+       }
+
+       h->paddr = pci_resource_start(pdev, i); /* addressing mode bits
+                                                * already removed
+                                                */
+
+       h->vaddr = remap_pci_mem(h->paddr, 0x250);
+
+       /* Wait for the board to become ready.  */
+       for (i = 0; i < HPSA_BOARD_READY_ITERATIONS; i++) {
+               scratchpad = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
+               if (scratchpad == HPSA_FIRMWARE_READY)
+                       break;
+               msleep(HPSA_BOARD_READY_POLL_INTERVAL_MSECS);
+       }
+       if (scratchpad != HPSA_FIRMWARE_READY) {
+               dev_warn(&pdev->dev, "board not ready, timed out.\n");
+               err = -ENODEV;
+               goto err_out_free_res;
+       }
+
+       /* get the address index number */
+       cfg_base_addr = readl(h->vaddr + SA5_CTCFG_OFFSET);
+       cfg_base_addr &= (__u32) 0x0000ffff;
+       cfg_base_addr_index = find_PCI_BAR_index(pdev, cfg_base_addr);
+       if (cfg_base_addr_index == -1) {
+               dev_warn(&pdev->dev, "cannot find cfg_base_addr_index\n");
+               err = -ENODEV;
+               goto err_out_free_res;
+       }
+
+       cfg_offset = readl(h->vaddr + SA5_CTMEM_OFFSET);
+       h->cfgtable = remap_pci_mem(pci_resource_start(pdev,
+                              cfg_base_addr_index) + cfg_offset,
+                               sizeof(h->cfgtable));
+       h->board_id = board_id;
+
+       /* Query controller for max supported commands: */
+       h->max_commands = readl(&(h->cfgtable->CmdsOutMax));
+
+       h->product_name = products[prod_index].product_name;
+       h->access = *(products[prod_index].access);
+       /* Allow room for some ioctls */
+       h->nr_cmds = h->max_commands - 4;
+
+       if ((readb(&h->cfgtable->Signature[0]) != 'C') ||
+           (readb(&h->cfgtable->Signature[1]) != 'I') ||
+           (readb(&h->cfgtable->Signature[2]) != 'S') ||
+           (readb(&h->cfgtable->Signature[3]) != 'S')) {
+               dev_warn(&pdev->dev, "not a valid CISS config table\n");
+               err = -ENODEV;
+               goto err_out_free_res;
+       }
+#ifdef CONFIG_X86
+       {
+               /* Need to enable prefetch in the SCSI core for 6400 in x86 */
+               __u32 prefetch;
+               prefetch = readl(&(h->cfgtable->SCSI_Prefetch));
+               prefetch |= 0x100;
+               writel(prefetch, &(h->cfgtable->SCSI_Prefetch));
+       }
+#endif
+
+       /* Disabling DMA prefetch for the P600
+        * An ASIC bug may result in a prefetch beyond
+        * physical memory.
+        */
+       if (board_id == 0x3225103C) {
+               __u32 dma_prefetch;
+               dma_prefetch = readl(h->vaddr + I2O_DMA1_CFG);
+               dma_prefetch |= 0x8000;
+               writel(dma_prefetch, h->vaddr + I2O_DMA1_CFG);
+       }
+
+       h->max_commands = readl(&(h->cfgtable->CmdsOutMax));
+       /* Update the field, and then ring the doorbell */
+       writel(CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest));
+       writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL);
+
+       /* under certain very rare conditions, this can take awhile.
+        * (e.g.: hot replace a failed 144GB drive in a RAID 5 set right
+        * as we enter this code.)
+        */
+       for (i = 0; i < MAX_CONFIG_WAIT; i++) {
+               if (!(readl(h->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq))
+                       break;
+               /* delay and try again */
+               msleep(10);
+       }
+
+#ifdef HPSA_DEBUG
+       print_cfg_table(&pdev->dev, h->cfgtable);
+#endif                         /* HPSA_DEBUG */
+
+       if (!(readl(&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) {
+               dev_warn(&pdev->dev, "unable to get board into simple mode\n");
+               err = -ENODEV;
+               goto err_out_free_res;
+       }
+       return 0;
+
+err_out_free_res:
+       /*
+        * Deliberately omit pci_disable_device(): it does something nasty to
+        * Smart Array controllers that pci_enable_device does not undo
+        */
+       pci_release_regions(pdev);
+       return err;
+}
+
+static int __devinit hpsa_init_one(struct pci_dev *pdev,
+                                   const struct pci_device_id *ent)
+{
+       int i;
+       int dac;
+       struct ctlr_info *h;
+
+       if (number_of_controllers == 0)
+               printk(KERN_INFO DRIVER_NAME "\n");
+       if (reset_devices) {
+               /* Reset the controller with a PCI power-cycle */
+               if (hpsa_hard_reset_controller(pdev) || hpsa_reset_msi(pdev))
+                       return -ENODEV;
+
+               /* Some devices (notably the HP Smart Array 5i Controller)
+                  need a little pause here */
+               msleep(HPSA_POST_RESET_PAUSE_MSECS);
+
+               /* Now try to get the controller to respond to a no-op */
+               for (i = 0; i < HPSA_POST_RESET_NOOP_RETRIES; i++) {
+                       if (hpsa_noop(pdev) == 0)
+                               break;
+                       else
+                               dev_warn(&pdev->dev, "no-op failed%s\n",
+                                               (i < 11 ? "; re-trying" : ""));
+               }
+       }
+
+       BUILD_BUG_ON(sizeof(struct CommandList) % 8);
+       h = kzalloc(sizeof(*h), GFP_KERNEL);
+       if (!h)
+               return -1;
+
+       h->busy_initializing = 1;
+       INIT_HLIST_HEAD(&h->cmpQ);
+       INIT_HLIST_HEAD(&h->reqQ);
+       mutex_init(&h->busy_shutting_down);
+       init_completion(&h->scan_wait);
+       if (hpsa_pci_init(h, pdev) != 0)
+               goto clean1;
+
+       sprintf(h->devname, "hpsa%d", number_of_controllers);
+       h->ctlr = number_of_controllers;
+       number_of_controllers++;
+       h->pdev = pdev;
+
+       /* configure PCI DMA stuff */
+       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
+               dac = 1;
+       else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))
+               dac = 0;
+       else {
+               dev_err(&pdev->dev, "no suitable DMA available\n");
+               goto clean1;
+       }
+
+       /* make sure the board interrupts are off */
+       h->access.set_intr_mask(h, HPSA_INTR_OFF);
+       if (request_irq(h->intr[SIMPLE_MODE_INT], do_hpsa_intr,
+                       IRQF_DISABLED | IRQF_SHARED, h->devname, h)) {
+               dev_err(&pdev->dev, "unable to get irq %d for %s\n",
+                      h->intr[SIMPLE_MODE_INT], h->devname);
+               goto clean2;
+       }
+
+       dev_info(&pdev->dev, "%s: <0x%x> at PCI %s IRQ %d%s using DAC\n",
+              h->devname, pdev->device, pci_name(pdev),
+              h->intr[SIMPLE_MODE_INT], dac ? "" : " not");
+
+       h->cmd_pool_bits =
+           kmalloc(((h->nr_cmds + BITS_PER_LONG -
+                     1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
+       h->cmd_pool = pci_alloc_consistent(h->pdev,
+                   h->nr_cmds * sizeof(*h->cmd_pool),
+                   &(h->cmd_pool_dhandle));
+       h->errinfo_pool = pci_alloc_consistent(h->pdev,
+                   h->nr_cmds * sizeof(*h->errinfo_pool),
+                   &(h->errinfo_pool_dhandle));
+       if ((h->cmd_pool_bits == NULL)
+           || (h->cmd_pool == NULL)
+           || (h->errinfo_pool == NULL)) {
+               dev_err(&pdev->dev, "out of memory");
+               goto clean4;
+       }
+       spin_lock_init(&h->lock);
+
+       pci_set_drvdata(pdev, h);
+       memset(h->cmd_pool_bits, 0,
+              ((h->nr_cmds + BITS_PER_LONG -
+                1) / BITS_PER_LONG) * sizeof(unsigned long));
+
+       hpsa_scsi_setup(h);
+
+       /* Turn the interrupts on so we can service requests */
+       h->access.set_intr_mask(h, HPSA_INTR_ON);
+
+       hpsa_register_scsi(h);  /* hook ourselves into SCSI subsystem */
+       h->busy_initializing = 0;
+       return 1;
+
+clean4:
+       kfree(h->cmd_pool_bits);
+       if (h->cmd_pool)
+               pci_free_consistent(h->pdev,
+                           h->nr_cmds * sizeof(struct CommandList),
+                           h->cmd_pool, h->cmd_pool_dhandle);
+       if (h->errinfo_pool)
+               pci_free_consistent(h->pdev,
+                           h->nr_cmds * sizeof(struct ErrorInfo),
+                           h->errinfo_pool,
+                           h->errinfo_pool_dhandle);
+       free_irq(h->intr[SIMPLE_MODE_INT], h);
+clean2:
+clean1:
+       h->busy_initializing = 0;
+       kfree(h);
+       return -1;
+}
+
+static void hpsa_flush_cache(struct ctlr_info *h)
+{
+       char *flush_buf;
+       struct CommandList *c;
+
+       flush_buf = kzalloc(4, GFP_KERNEL);
+       if (!flush_buf)
+               return;
+
+       c = cmd_special_alloc(h);
+       if (!c) {
+               dev_warn(&h->pdev->dev, "cmd_special_alloc returned NULL!\n");
+               goto out_of_memory;
+       }
+       fill_cmd(c, HPSA_CACHE_FLUSH, h, flush_buf, 4, 0,
+               RAID_CTLR_LUNID, TYPE_CMD);
+       hpsa_scsi_do_simple_cmd_with_retry(h, c, PCI_DMA_TODEVICE);
+       if (c->err_info->CommandStatus != 0)
+               dev_warn(&h->pdev->dev,
+                       "error flushing cache on controller\n");
+       cmd_special_free(h, c);
+out_of_memory:
+       kfree(flush_buf);
+}
+
+static void hpsa_shutdown(struct pci_dev *pdev)
+{
+       struct ctlr_info *h;
+
+       h = pci_get_drvdata(pdev);
+       /* Turn board interrupts off  and send the flush cache command
+        * sendcmd will turn off interrupt, and send the flush...
+        * To write all data in the battery backed cache to disks
+        */
+       hpsa_flush_cache(h);
+       h->access.set_intr_mask(h, HPSA_INTR_OFF);
+       free_irq(h->intr[2], h);
+#ifdef CONFIG_PCI_MSI
+       if (h->msix_vector)
+               pci_disable_msix(h->pdev);
+       else if (h->msi_vector)
+               pci_disable_msi(h->pdev);
+#endif                         /* CONFIG_PCI_MSI */
+}
+
+static void __devexit hpsa_remove_one(struct pci_dev *pdev)
+{
+       struct ctlr_info *h;
+
+       if (pci_get_drvdata(pdev) == NULL) {
+               dev_err(&pdev->dev, "unable to remove device \n");
+               return;
+       }
+       h = pci_get_drvdata(pdev);
+       mutex_lock(&h->busy_shutting_down);
+       remove_from_scan_list(h);
+       hpsa_unregister_scsi(h);        /* unhook from SCSI subsystem */
+       hpsa_shutdown(pdev);
+       iounmap(h->vaddr);
+       pci_free_consistent(h->pdev,
+               h->nr_cmds * sizeof(struct CommandList),
+               h->cmd_pool, h->cmd_pool_dhandle);
+       pci_free_consistent(h->pdev,
+               h->nr_cmds * sizeof(struct ErrorInfo),
+               h->errinfo_pool, h->errinfo_pool_dhandle);
+       kfree(h->cmd_pool_bits);
+       /*
+        * Deliberately omit pci_disable_device(): it does something nasty to
+        * Smart Array controllers that pci_enable_device does not undo
+        */
+       pci_release_regions(pdev);
+       pci_set_drvdata(pdev, NULL);
+       mutex_unlock(&h->busy_shutting_down);
+       kfree(h);
+}
+
+static int hpsa_suspend(__attribute__((unused)) struct pci_dev *pdev,
+       __attribute__((unused)) pm_message_t state)
+{
+       return -ENOSYS;
+}
+
+static int hpsa_resume(__attribute__((unused)) struct pci_dev *pdev)
+{
+       return -ENOSYS;
+}
+
+static struct pci_driver hpsa_pci_driver = {
+       .name = "hpsa",
+       .probe = hpsa_init_one,
+       .remove = __devexit_p(hpsa_remove_one),
+       .id_table = hpsa_pci_device_id, /* id_table */
+       .shutdown = hpsa_shutdown,
+       .suspend = hpsa_suspend,
+       .resume = hpsa_resume,
+};
+
+/*
+ *  This is it.  Register the PCI driver information for the cards we control
+ *  the OS will call our registered routines when it finds one of our cards.
+ */
+static int __init hpsa_init(void)
+{
+       int err;
+       /* Start the scan thread */
+       hpsa_scan_thread = kthread_run(hpsa_scan_func, NULL, "hpsa_scan");
+       if (IS_ERR(hpsa_scan_thread)) {
+               err = PTR_ERR(hpsa_scan_thread);
+               return -ENODEV;
+       }
+       err = pci_register_driver(&hpsa_pci_driver);
+       if (err)
+               kthread_stop(hpsa_scan_thread);
+       return err;
+}
+
+static void __exit hpsa_cleanup(void)
+{
+       pci_unregister_driver(&hpsa_pci_driver);
+       kthread_stop(hpsa_scan_thread);
+}
+
+module_init(hpsa_init);
+module_exit(hpsa_cleanup);
diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
new file mode 100644 (file)
index 0000000..6bd1949
--- /dev/null
@@ -0,0 +1,273 @@
+/*
+ *    Disk Array driver for HP Smart Array SAS controllers
+ *    Copyright 2000, 2009 Hewlett-Packard Development Company, L.P.
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; version 2 of the License.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ *    NON INFRINGEMENT.  See the GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *    Questions/Comments/Bugfixes to iss_storagedev@hp.com
+ *
+ */
+#ifndef HPSA_H
+#define HPSA_H
+
+#include <scsi/scsicam.h>
+
+#define IO_OK          0
+#define IO_ERROR       1
+
+struct ctlr_info;
+
+struct access_method {
+       void (*submit_command)(struct ctlr_info *h,
+               struct CommandList *c);
+       void (*set_intr_mask)(struct ctlr_info *h, unsigned long val);
+       unsigned long (*fifo_full)(struct ctlr_info *h);
+       unsigned long (*intr_pending)(struct ctlr_info *h);
+       unsigned long (*command_completed)(struct ctlr_info *h);
+};
+
+struct hpsa_scsi_dev_t {
+       int devtype;
+       int bus, target, lun;           /* as presented to the OS */
+       unsigned char scsi3addr[8];     /* as presented to the HW */
+#define RAID_CTLR_LUNID "\0\0\0\0\0\0\0\0"
+       unsigned char device_id[16];    /* from inquiry pg. 0x83 */
+       unsigned char vendor[8];        /* bytes 8-15 of inquiry data */
+       unsigned char model[16];        /* bytes 16-31 of inquiry data */
+       unsigned char revision[4];      /* bytes 32-35 of inquiry data */
+       unsigned char raid_level;       /* from inquiry page 0xC1 */
+};
+
+struct ctlr_info {
+       int     ctlr;
+       char    devname[8];
+       char    *product_name;
+       char    firm_ver[4]; /* Firmware version */
+       struct pci_dev *pdev;
+       __u32   board_id;
+       void __iomem *vaddr;
+       unsigned long paddr;
+       int     nr_cmds; /* Number of commands allowed on this controller */
+       struct CfgTable __iomem *cfgtable;
+       int     interrupts_enabled;
+       int     major;
+       int     max_commands;
+       int     commands_outstanding;
+       int     max_outstanding; /* Debug */
+       int     usage_count;  /* number of opens all all minor devices */
+#      define DOORBELL_INT     0
+#      define PERF_MODE_INT    1
+#      define SIMPLE_MODE_INT  2
+#      define MEMQ_MODE_INT    3
+       unsigned int intr[4];
+       unsigned int msix_vector;
+       unsigned int msi_vector;
+       struct access_method access;
+
+       /* queue and queue Info */
+       struct hlist_head reqQ;
+       struct hlist_head cmpQ;
+       unsigned int Qdepth;
+       unsigned int maxQsinceinit;
+       unsigned int maxSG;
+       spinlock_t lock;
+
+       /* pointers to command and error info pool */
+       struct CommandList      *cmd_pool;
+       dma_addr_t              cmd_pool_dhandle;
+       struct ErrorInfo        *errinfo_pool;
+       dma_addr_t              errinfo_pool_dhandle;
+       unsigned long           *cmd_pool_bits;
+       int                     nr_allocs;
+       int                     nr_frees;
+       int                     busy_initializing;
+       int                     busy_scanning;
+       struct mutex            busy_shutting_down;
+       struct list_head        scan_list;
+       struct completion       scan_wait;
+
+       struct Scsi_Host *scsi_host;
+       spinlock_t devlock; /* to protect hba[ctlr]->dev[];  */
+       int ndevices; /* number of used elements in .dev[] array. */
+#define HPSA_MAX_SCSI_DEVS_PER_HBA 256
+       struct hpsa_scsi_dev_t *dev[HPSA_MAX_SCSI_DEVS_PER_HBA];
+};
+#define HPSA_ABORT_MSG 0
+#define HPSA_DEVICE_RESET_MSG 1
+#define HPSA_BUS_RESET_MSG 2
+#define HPSA_HOST_RESET_MSG 3
+#define HPSA_MSG_SEND_RETRY_LIMIT 10
+#define HPSA_MSG_SEND_RETRY_INTERVAL_MSECS 1000
+
+/* Maximum time in seconds driver will wait for command completions
+ * when polling before giving up.
+ */
+#define HPSA_MAX_POLL_TIME_SECS (20)
+
+/* During SCSI error recovery, HPSA_TUR_RETRY_LIMIT defines
+ * how many times to retry TEST UNIT READY on a device
+ * while waiting for it to become ready before giving up.
+ * HPSA_MAX_WAIT_INTERVAL_SECS is the max wait interval
+ * between sending TURs while waiting for a device
+ * to become ready.
+ */
+#define HPSA_TUR_RETRY_LIMIT (20)
+#define HPSA_MAX_WAIT_INTERVAL_SECS (30)
+
+/* HPSA_BOARD_READY_WAIT_SECS is how long to wait for a board
+ * to become ready, in seconds, before giving up on it.
+ * HPSA_BOARD_READY_POLL_INTERVAL_MSECS * is how long to wait
+ * between polling the board to see if it is ready, in
+ * milliseconds.  HPSA_BOARD_READY_POLL_INTERVAL and
+ * HPSA_BOARD_READY_ITERATIONS are derived from those.
+ */
+#define HPSA_BOARD_READY_WAIT_SECS (120)
+#define HPSA_BOARD_READY_POLL_INTERVAL_MSECS (100)
+#define HPSA_BOARD_READY_POLL_INTERVAL \
+       ((HPSA_BOARD_READY_POLL_INTERVAL_MSECS * HZ) / 1000)
+#define HPSA_BOARD_READY_ITERATIONS \
+       ((HPSA_BOARD_READY_WAIT_SECS * 1000) / \
+               HPSA_BOARD_READY_POLL_INTERVAL_MSECS)
+#define HPSA_POST_RESET_PAUSE_MSECS (3000)
+#define HPSA_POST_RESET_NOOP_RETRIES (12)
+
+/*  Defining the diffent access_menthods */
+/*
+ * Memory mapped FIFO interface (SMART 53xx cards)
+ */
+#define SA5_DOORBELL   0x20
+#define SA5_REQUEST_PORT_OFFSET        0x40
+#define SA5_REPLY_INTR_MASK_OFFSET     0x34
+#define SA5_REPLY_PORT_OFFSET          0x44
+#define SA5_INTR_STATUS                0x30
+#define SA5_SCRATCHPAD_OFFSET  0xB0
+
+#define SA5_CTCFG_OFFSET       0xB4
+#define SA5_CTMEM_OFFSET       0xB8
+
+#define SA5_INTR_OFF           0x08
+#define SA5B_INTR_OFF          0x04
+#define SA5_INTR_PENDING       0x08
+#define SA5B_INTR_PENDING      0x04
+#define FIFO_EMPTY             0xffffffff
+#define HPSA_FIRMWARE_READY    0xffff0000 /* value in scratchpad register */
+
+#define HPSA_ERROR_BIT         0x02
+#define HPSA_TAG_CONTAINS_INDEX(tag) ((tag) & 0x04)
+#define HPSA_TAG_TO_INDEX(tag) ((tag) >> 3)
+#define HPSA_TAG_DISCARD_ERROR_BITS(tag) ((tag) & ~3)
+
+#define HPSA_INTR_ON   1
+#define HPSA_INTR_OFF  0
+/*
+       Send the command to the hardware
+*/
+static void SA5_submit_command(struct ctlr_info *h,
+       struct CommandList *c)
+{
+#ifdef HPSA_DEBUG
+        printk(KERN_WARNING "hpsa: Sending %x - down to controller\n",
+               c->busaddr);
+#endif /* HPSA_DEBUG */
+       writel(c->busaddr, h->vaddr + SA5_REQUEST_PORT_OFFSET);
+       h->commands_outstanding++;
+       if (h->commands_outstanding > h->max_outstanding)
+               h->max_outstanding = h->commands_outstanding;
+}
+
+/*
+ *  This card is the opposite of the other cards.
+ *   0 turns interrupts on...
+ *   0x08 turns them off...
+ */
+static void SA5_intr_mask(struct ctlr_info *h, unsigned long val)
+{
+       if (val) { /* Turn interrupts on */
+               h->interrupts_enabled = 1;
+               writel(0, h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
+       } else { /* Turn them off */
+               h->interrupts_enabled = 0;
+               writel(SA5_INTR_OFF,
+                       h->vaddr + SA5_REPLY_INTR_MASK_OFFSET);
+       }
+}
+/*
+ *  Returns true if fifo is full.
+ *
+ */
+static unsigned long SA5_fifo_full(struct ctlr_info *h)
+{
+       if (h->commands_outstanding >= h->max_commands)
+               return 1;
+       else
+               return 0;
+
+}
+/*
+ *   returns value read from hardware.
+ *     returns FIFO_EMPTY if there is nothing to read
+ */
+static unsigned long SA5_completed(struct ctlr_info *h)
+{
+       unsigned long register_value
+               = readl(h->vaddr + SA5_REPLY_PORT_OFFSET);
+
+       if (register_value != FIFO_EMPTY)
+               h->commands_outstanding--;
+
+#ifdef HPSA_DEBUG
+       if (register_value != FIFO_EMPTY)
+               printk(KERN_INFO "hpsa:  Read %lx back from board\n",
+                       register_value);
+       else
+               printk(KERN_INFO "hpsa:  FIFO Empty read\n");
+#endif
+
+       return register_value;
+}
+/*
+ *     Returns true if an interrupt is pending..
+ */
+static unsigned long SA5_intr_pending(struct ctlr_info *h)
+{
+       unsigned long register_value  =
+               readl(h->vaddr + SA5_INTR_STATUS);
+#ifdef HPSA_DEBUG
+       printk(KERN_INFO "hpsa: intr_pending %lx\n", register_value);
+#endif  /* HPSA_DEBUG */
+       if (register_value &  SA5_INTR_PENDING)
+               return  1;
+       return 0 ;
+}
+
+
+static struct access_method SA5_access = {
+       SA5_submit_command,
+       SA5_intr_mask,
+       SA5_fifo_full,
+       SA5_intr_pending,
+       SA5_completed,
+};
+
+struct board_type {
+       __u32   board_id;
+       char    *product_name;
+       struct access_method *access;
+};
+
+
+/* end of old hpsa_scsi.h file */
+
+#endif /* HPSA_H */
+
diff --git a/drivers/scsi/hpsa_cmd.h b/drivers/scsi/hpsa_cmd.h
new file mode 100644 (file)
index 0000000..12d7138
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ *    Disk Array driver for HP Smart Array SAS controllers
+ *    Copyright 2000, 2009 Hewlett-Packard Development Company, L.P.
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; version 2 of the License.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ *    NON INFRINGEMENT.  See the GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *    Questions/Comments/Bugfixes to iss_storagedev@hp.com
+ *
+ */
+#ifndef HPSA_CMD_H
+#define HPSA_CMD_H
+
+/* general boundary defintions */
+#define SENSEINFOBYTES          32 /* may vary between hbas */
+#define MAXSGENTRIES            31
+#define MAXREPLYQS              256
+
+/* Command Status value */
+#define CMD_SUCCESS             0x0000
+#define CMD_TARGET_STATUS       0x0001
+#define CMD_DATA_UNDERRUN       0x0002
+#define CMD_DATA_OVERRUN        0x0003
+#define CMD_INVALID             0x0004
+#define CMD_PROTOCOL_ERR        0x0005
+#define CMD_HARDWARE_ERR        0x0006
+#define CMD_CONNECTION_LOST     0x0007
+#define CMD_ABORTED             0x0008
+#define CMD_ABORT_FAILED        0x0009
+#define CMD_UNSOLICITED_ABORT   0x000A
+#define CMD_TIMEOUT             0x000B
+#define CMD_UNABORTABLE                0x000C
+
+/* Unit Attentions ASC's as defined for the MSA2012sa */
+#define POWER_OR_RESET                 0x29
+#define STATE_CHANGED                  0x2a
+#define UNIT_ATTENTION_CLEARED         0x2f
+#define LUN_FAILED                     0x3e
+#define REPORT_LUNS_CHANGED            0x3f
+
+/* Unit Attentions ASCQ's as defined for the MSA2012sa */
+
+       /* These ASCQ's defined for ASC = POWER_OR_RESET */
+#define POWER_ON_RESET                 0x00
+#define POWER_ON_REBOOT                        0x01
+#define SCSI_BUS_RESET                 0x02
+#define MSA_TARGET_RESET               0x03
+#define CONTROLLER_FAILOVER            0x04
+#define TRANSCEIVER_SE                 0x05
+#define TRANSCEIVER_LVD                        0x06
+
+       /* These ASCQ's defined for ASC = STATE_CHANGED */
+#define RESERVATION_PREEMPTED          0x03
+#define ASYM_ACCESS_CHANGED            0x06
+#define LUN_CAPACITY_CHANGED           0x09
+
+/* transfer direction */
+#define XFER_NONE               0x00
+#define XFER_WRITE              0x01
+#define XFER_READ               0x02
+#define XFER_RSVD               0x03
+
+/* task attribute */
+#define ATTR_UNTAGGED           0x00
+#define ATTR_SIMPLE             0x04
+#define ATTR_HEADOFQUEUE        0x05
+#define ATTR_ORDERED            0x06
+#define ATTR_ACA                0x07
+
+/* cdb type */
+#define TYPE_CMD                               0x00
+#define TYPE_MSG                               0x01
+
+/* config space register offsets */
+#define CFG_VENDORID            0x00
+#define CFG_DEVICEID            0x02
+#define CFG_I2OBAR              0x10
+#define CFG_MEM1BAR             0x14
+
+/* i2o space register offsets */
+#define I2O_IBDB_SET            0x20
+#define I2O_IBDB_CLEAR          0x70
+#define I2O_INT_STATUS          0x30
+#define I2O_INT_MASK            0x34
+#define I2O_IBPOST_Q            0x40
+#define I2O_OBPOST_Q            0x44
+#define I2O_DMA1_CFG           0x214
+
+/* Configuration Table */
+#define CFGTBL_ChangeReq        0x00000001l
+#define CFGTBL_AccCmds          0x00000001l
+
+#define CFGTBL_Trans_Simple     0x00000002l
+
+#define CFGTBL_BusType_Ultra2   0x00000001l
+#define CFGTBL_BusType_Ultra3   0x00000002l
+#define CFGTBL_BusType_Fibre1G  0x00000100l
+#define CFGTBL_BusType_Fibre2G  0x00000200l
+struct vals32 {
+       __u32   lower;
+       __u32   upper;
+};
+
+union u64bit {
+       struct vals32 val32;
+       __u64 val;
+};
+
+/* FIXME this is a per controller value (barf!) */
+#define HPSA_MAX_TARGETS_PER_CTLR 16
+#define HPSA_MAX_LUN 256
+#define HPSA_MAX_PHYS_LUN 1024
+
+/* SCSI-3 Commands */
+#pragma pack(1)
+
+#define HPSA_INQUIRY 0x12
+struct InquiryData {
+       __u8 data_byte[36];
+};
+
+#define HPSA_REPORT_LOG 0xc2    /* Report Logical LUNs */
+#define HPSA_REPORT_PHYS 0xc3   /* Report Physical LUNs */
+struct ReportLUNdata {
+       __u8 LUNListLength[4];
+       __u32 reserved;
+       __u8 LUN[HPSA_MAX_LUN][8];
+};
+
+struct ReportExtendedLUNdata {
+       __u8 LUNListLength[4];
+       __u8 extended_response_flag;
+       __u8 reserved[3];
+       __u8 LUN[HPSA_MAX_LUN][24];
+};
+
+struct SenseSubsystem_info {
+       __u8 reserved[36];
+       __u8 portname[8];
+       __u8 reserved1[1108];
+};
+
+#define HPSA_READ_CAPACITY 0x25 /* Read Capacity */
+struct ReadCapdata {
+       __u8 total_size[4];     /* Total size in blocks */
+       __u8 block_size[4];     /* Size of blocks in bytes */
+};
+
+#if 0
+/* 12 byte commands not implemented in firmware yet. */
+#define HPSA_READ      0xa8
+#define HPSA_WRITE     0xaa
+#endif
+
+#define HPSA_READ   0x28    /* Read(10) */
+#define HPSA_WRITE  0x2a    /* Write(10) */
+
+/* BMIC commands */
+#define BMIC_READ 0x26
+#define BMIC_WRITE 0x27
+#define BMIC_CACHE_FLUSH 0xc2
+#define HPSA_CACHE_FLUSH 0x01  /* C2 was already being used by HPSA */
+
+/* Command List Structure */
+union SCSI3Addr {
+       struct {
+               __u8 Dev;
+               __u8 Bus:6;
+               __u8 Mode:2;        /* b00 */
+       } PeripDev;
+       struct {
+               __u8 DevLSB;
+               __u8 DevMSB:6;
+               __u8 Mode:2;        /* b01 */
+       } LogDev;
+       struct {
+               __u8 Dev:5;
+               __u8 Bus:3;
+               __u8 Targ:6;
+               __u8 Mode:2;        /* b10 */
+       } LogUnit;
+};
+
+struct PhysDevAddr {
+       __u32             TargetId:24;
+       __u32             Bus:6;
+       __u32             Mode:2;
+       /* 2 level target device addr */
+       union SCSI3Addr  Target[2];
+};
+
+struct LogDevAddr {
+       __u32            VolId:30;
+       __u32            Mode:2;
+       __u8             reserved[4];
+};
+
+union LUNAddr {
+       __u8               LunAddrBytes[8];
+       union SCSI3Addr    SCSI3Lun[4];
+       struct PhysDevAddr PhysDev;
+       struct LogDevAddr  LogDev;
+};
+
+struct CommandListHeader {
+       __u8              ReplyQueue;
+       __u8              SGList;
+       __u16             SGTotal;
+       struct vals32     Tag;
+       union LUNAddr     LUN;
+};
+
+struct RequestBlock {
+       __u8   CDBLen;
+       struct {
+               __u8 Type:3;
+               __u8 Attribute:3;
+               __u8 Direction:2;
+       } Type;
+       __u16  Timeout;
+       __u8   CDB[16];
+};
+
+struct ErrDescriptor {
+       struct vals32 Addr;
+       __u32  Len;
+};
+
+struct SGDescriptor {
+       struct vals32 Addr;
+       __u32  Len;
+       __u32  Ext;
+};
+
+union MoreErrInfo {
+       struct {
+               __u8  Reserved[3];
+               __u8  Type;
+               __u32 ErrorInfo;
+       } Common_Info;
+       struct {
+               __u8  Reserved[2];
+               __u8  offense_size; /* size of offending entry */
+               __u8  offense_num;  /* byte # of offense 0-base */
+               __u32 offense_value;
+       } Invalid_Cmd;
+};
+struct ErrorInfo {
+       __u8               ScsiStatus;
+       __u8               SenseLen;
+       __u16              CommandStatus;
+       __u32              ResidualCnt;
+       union MoreErrInfo  MoreErrInfo;
+       __u8               SenseInfo[SENSEINFOBYTES];
+};
+/* Command types */
+#define CMD_IOCTL_PEND  0x01
+#define CMD_SCSI       0x03
+
+struct ctlr_info; /* defined in hpsa.h */
+/* The size of this structure needs to be divisible by 8
+ * od on all architectures, because the controller uses 2
+ * lower bits of the address, and the driver uses 1 lower
+ * bit (3 bits total.)
+ */
+struct CommandList {
+       struct CommandListHeader Header;
+       struct RequestBlock      Request;
+       struct ErrDescriptor     ErrDesc;
+       struct SGDescriptor      SG[MAXSGENTRIES];
+       /* information associated with the command */
+       __u32                      busaddr; /* physical addr of this record */
+       struct ErrorInfo *err_info; /* pointer to the allocated mem */
+       struct ctlr_info           *h;
+       int                        cmd_type;
+       long                       cmdindex;
+       struct hlist_node list;
+       struct CommandList *prev;
+       struct CommandList *next;
+       struct request *rq;
+       struct completion *waiting;
+       int      retry_count;
+       void   *scsi_cmd;
+};
+
+/* Configuration Table Structure */
+struct HostWrite {
+       __u32 TransportRequest;
+       __u32 Reserved;
+       __u32 CoalIntDelay;
+       __u32 CoalIntCount;
+};
+
+struct CfgTable {
+       __u8             Signature[4];
+       __u32            SpecValence;
+       __u32            TransportSupport;
+       __u32            TransportActive;
+       struct HostWrite HostWrite;
+       __u32            CmdsOutMax;
+       __u32            BusTypes;
+       __u32            Reserved;
+       __u8             ServerName[16];
+       __u32            HeartBeat;
+       __u32            SCSI_Prefetch;
+};
+
+struct hpsa_pci_info {
+       unsigned char   bus;
+       unsigned char   dev_fn;
+       unsigned short  domain;
+       __u32           board_id;
+};
+
+#pragma pack()
+#endif /* HPSA_CMD_H */
index 206c2fa8c1ba1ba51a53681975c7b1976ebacf5a..9e52d16c7c3908319e97eff73d85de1102ac8859 100644 (file)
@@ -1333,7 +1333,7 @@ static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
 
        error = &hostrcb->hcam.u.error.u.type_17_error;
        error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
-       strstrip(error->failure_reason);
+       strim(error->failure_reason);
 
        ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason,
                     be32_to_cpu(hostrcb->hcam.u.error.prc));
@@ -1359,7 +1359,7 @@ static void ipr_log_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
 
        error = &hostrcb->hcam.u.error.u.type_07_error;
        error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
-       strstrip(error->failure_reason);
+       strim(error->failure_reason);
 
        ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason,
                     be32_to_cpu(hostrcb->hcam.u.error.prc));
@@ -6521,6 +6521,7 @@ static int ipr_reset_restore_cfg_space(struct ipr_cmnd *ipr_cmd)
        int rc;
 
        ENTER;
+       ioa_cfg->pdev->state_saved = true;
        rc = pci_restore_state(ioa_cfg->pdev);
 
        if (rc != PCIBIOS_SUCCESSFUL) {
index c4b58d042f6f81b6a49b20b83eeb18b8fdd0ad80..881d5dfe8c74f5a37c58474690c832d1d1ac1a78 100644 (file)
@@ -68,18 +68,20 @@ struct kmem_cache *scsi_pkt_cachep;
 
 /**
  * struct fc_fcp_internal - FCP layer internal data
- * @scsi_pkt_pool:  Memory pool to draw FCP packets from
+ * @scsi_pkt_pool: Memory pool to draw FCP packets from
+ * @scsi_queue_lock: Protects the scsi_pkt_queue
  * @scsi_pkt_queue: Current FCP packets
  * @last_can_queue_ramp_down_time: ramp down time
  * @last_can_queue_ramp_up_time: ramp up time
  * @max_can_queue: max can_queue size
  */
 struct fc_fcp_internal {
-       mempool_t        *scsi_pkt_pool;
-       struct list_head scsi_pkt_queue;
-       unsigned long last_can_queue_ramp_down_time;
-       unsigned long last_can_queue_ramp_up_time;
-       int max_can_queue;
+       mempool_t               *scsi_pkt_pool;
+       spinlock_t              scsi_queue_lock;
+       struct list_head        scsi_pkt_queue;
+       unsigned long           last_can_queue_ramp_down_time;
+       unsigned long           last_can_queue_ramp_up_time;
+       int                     max_can_queue;
 };
 
 #define fc_get_scsi_internal(x)        ((struct fc_fcp_internal *)(x)->scsi_priv)
@@ -410,12 +412,14 @@ static inline struct fc_frame *fc_fcp_frame_alloc(struct fc_lport *lport,
        unsigned long flags;
 
        fp = fc_frame_alloc(lport, len);
-       if (!fp) {
-               spin_lock_irqsave(lport->host->host_lock, flags);
-               fc_fcp_can_queue_ramp_down(lport);
-               spin_unlock_irqrestore(lport->host->host_lock, flags);
-       }
-       return fp;
+       if (likely(fp))
+               return fp;
+
+       /* error case */
+       spin_lock_irqsave(lport->host->host_lock, flags);
+       fc_fcp_can_queue_ramp_down(lport);
+       spin_unlock_irqrestore(lport->host->host_lock, flags);
+       return NULL;
 }
 
 /**
@@ -990,7 +994,7 @@ static void fc_fcp_cleanup_each_cmd(struct fc_lport *lport, unsigned int id,
        struct scsi_cmnd *sc_cmd;
        unsigned long flags;
 
-       spin_lock_irqsave(lport->host->host_lock, flags);
+       spin_lock_irqsave(&si->scsi_queue_lock, flags);
 restart:
        list_for_each_entry(fsp, &si->scsi_pkt_queue, list) {
                sc_cmd = fsp->cmd;
@@ -1001,7 +1005,7 @@ restart:
                        continue;
 
                fc_fcp_pkt_hold(fsp);
-               spin_unlock_irqrestore(lport->host->host_lock, flags);
+               spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
 
                if (!fc_fcp_lock_pkt(fsp)) {
                        fc_fcp_cleanup_cmd(fsp, error);
@@ -1010,14 +1014,14 @@ restart:
                }
 
                fc_fcp_pkt_release(fsp);
-               spin_lock_irqsave(lport->host->host_lock, flags);
+               spin_lock_irqsave(&si->scsi_queue_lock, flags);
                /*
                 * while we dropped the lock multiple pkts could
                 * have been released, so we have to start over.
                 */
                goto restart;
        }
-       spin_unlock_irqrestore(lport->host->host_lock, flags);
+       spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
 }
 
 /**
@@ -1035,11 +1039,12 @@ static void fc_fcp_abort_io(struct fc_lport *lport)
  * @fsp:   The FCP packet to send
  *
  * Return:  Zero for success and -1 for failure
- * Locks:   Called with the host lock and irqs disabled.
+ * Locks:   Called without locks held
  */
 static int fc_fcp_pkt_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp)
 {
        struct fc_fcp_internal *si = fc_get_scsi_internal(lport);
+       unsigned long flags;
        int rc;
 
        fsp->cmd->SCp.ptr = (char *)fsp;
@@ -1049,13 +1054,16 @@ static int fc_fcp_pkt_send(struct fc_lport *lport, struct fc_fcp_pkt *fsp)
        int_to_scsilun(fsp->cmd->device->lun,
                       (struct scsi_lun *)fsp->cdb_cmd.fc_lun);
        memcpy(fsp->cdb_cmd.fc_cdb, fsp->cmd->cmnd, fsp->cmd->cmd_len);
-       list_add_tail(&fsp->list, &si->scsi_pkt_queue);
 
-       spin_unlock_irq(lport->host->host_lock);
+       spin_lock_irqsave(&si->scsi_queue_lock, flags);
+       list_add_tail(&fsp->list, &si->scsi_pkt_queue);
+       spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
        rc = lport->tt.fcp_cmd_send(lport, fsp, fc_fcp_recv);
-       spin_lock_irq(lport->host->host_lock);
-       if (rc)
+       if (unlikely(rc)) {
+               spin_lock_irqsave(&si->scsi_queue_lock, flags);
                list_del(&fsp->list);
+               spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
+       }
 
        return rc;
 }
@@ -1752,6 +1760,7 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *))
        struct fcoe_dev_stats *stats;
 
        lport = shost_priv(sc_cmd->device->host);
+       spin_unlock_irq(lport->host->host_lock);
 
        rval = fc_remote_port_chkready(rport);
        if (rval) {
@@ -1834,6 +1843,7 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *))
                rc = SCSI_MLQUEUE_HOST_BUSY;
        }
 out:
+       spin_lock_irq(lport->host->host_lock);
        return rc;
 }
 EXPORT_SYMBOL(fc_queuecommand);
@@ -1864,11 +1874,8 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
 
        lport = fsp->lp;
        si = fc_get_scsi_internal(lport);
-       spin_lock_irqsave(lport->host->host_lock, flags);
-       if (!fsp->cmd) {
-               spin_unlock_irqrestore(lport->host->host_lock, flags);
+       if (!fsp->cmd)
                return;
-       }
 
        /*
         * if can_queue ramp down is done then try can_queue ramp up
@@ -1880,10 +1887,8 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
        sc_cmd = fsp->cmd;
        fsp->cmd = NULL;
 
-       if (!sc_cmd->SCp.ptr) {
-               spin_unlock_irqrestore(lport->host->host_lock, flags);
+       if (!sc_cmd->SCp.ptr)
                return;
-       }
 
        CMD_SCSI_STATUS(sc_cmd) = fsp->cdb_status;
        switch (fsp->status_code) {
@@ -1945,10 +1950,11 @@ static void fc_io_compl(struct fc_fcp_pkt *fsp)
                break;
        }
 
+       spin_lock_irqsave(&si->scsi_queue_lock, flags);
        list_del(&fsp->list);
+       spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
        sc_cmd->SCp.ptr = NULL;
        sc_cmd->scsi_done(sc_cmd);
-       spin_unlock_irqrestore(lport->host->host_lock, flags);
 
        /* release ref from initial allocation in queue command */
        fc_fcp_pkt_release(fsp);
@@ -2216,6 +2222,7 @@ int fc_fcp_init(struct fc_lport *lport)
        lport->scsi_priv = si;
        si->max_can_queue = lport->host->can_queue;
        INIT_LIST_HEAD(&si->scsi_pkt_queue);
+       spin_lock_init(&si->scsi_queue_lock);
 
        si->scsi_pkt_pool = mempool_create_slab_pool(2, scsi_pkt_cachep);
        if (!si->scsi_pkt_pool) {
index 74338c83ad0aa3ed1f39fd903df694bf6ebb046d..0b165024a2196a2458f546296bd3471b6e9dd8e3 100644 (file)
@@ -537,7 +537,9 @@ int fc_fabric_login(struct fc_lport *lport)
        int rc = -1;
 
        mutex_lock(&lport->lp_mutex);
-       if (lport->state == LPORT_ST_DISABLED) {
+       if (lport->state == LPORT_ST_DISABLED ||
+           lport->state == LPORT_ST_LOGO) {
+               fc_lport_state_enter(lport, LPORT_ST_RESET);
                fc_lport_enter_reset(lport);
                rc = 0;
        }
@@ -967,6 +969,9 @@ static void fc_lport_enter_reset(struct fc_lport *lport)
        FC_LPORT_DBG(lport, "Entered RESET state from %s state\n",
                     fc_lport_state(lport));
 
+       if (lport->state == LPORT_ST_DISABLED || lport->state == LPORT_ST_LOGO)
+               return;
+
        if (lport->vport) {
                if (lport->link_up)
                        fc_vport_set_state(lport->vport, FC_VPORT_INITIALIZING);
index 35ca0e72df465633eec2843fbb9f68c59e43e416..02300523b2341c77d9c4015bafab120f96d229ce 100644 (file)
@@ -310,6 +310,7 @@ static void fc_rport_work(struct work_struct *work)
                                restart = 1;
                        else
                                list_del(&rdata->peers);
+                       rdata->event = RPORT_EV_NONE;
                        mutex_unlock(&rdata->rp_mutex);
                        mutex_unlock(&lport->disc.disc_mutex);
                }
index b7689f3d05f529d113a243afd74df6a477438d40..c28a712fd4db58dfa0880d4df60cf17af0719622 100644 (file)
@@ -517,7 +517,7 @@ static void iscsi_free_task(struct iscsi_task *task)
        if (conn->login_task == task)
                return;
 
-       __kfifo_put(session->cmdpool.queue, (void*)&task, sizeof(void*));
+       kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*));
 
        if (sc) {
                task->sc = NULL;
@@ -737,7 +737,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
                BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
                BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
 
-               if (!__kfifo_get(session->cmdpool.queue,
+               if (!kfifo_out(&session->cmdpool.queue,
                                 (void*)&task, sizeof(void*)))
                        return NULL;
        }
@@ -1567,7 +1567,7 @@ static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn,
 {
        struct iscsi_task *task;
 
-       if (!__kfifo_get(conn->session->cmdpool.queue,
+       if (!kfifo_out(&conn->session->cmdpool.queue,
                         (void *) &task, sizeof(void *)))
                return NULL;
 
@@ -2461,12 +2461,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
        if (q->pool == NULL)
                return -ENOMEM;
 
-       q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),
-                             GFP_KERNEL, NULL);
-       if (IS_ERR(q->queue)) {
-               q->queue = NULL;
-               goto enomem;
-       }
+       kfifo_init(&q->queue, (void*)q->pool, max * sizeof(void*));
 
        for (i = 0; i < max; i++) {
                q->pool[i] = kzalloc(item_size, GFP_KERNEL);
@@ -2474,7 +2469,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
                        q->max = i;
                        goto enomem;
                }
-               __kfifo_put(q->queue, (void*)&q->pool[i], sizeof(void*));
+               kfifo_in(&q->queue, (void*)&q->pool[i], sizeof(void*));
        }
 
        if (items) {
@@ -2497,7 +2492,6 @@ void iscsi_pool_free(struct iscsi_pool *q)
        for (i = 0; i < q->max; i++)
                kfree(q->pool[i]);
        kfree(q->pool);
-       kfree(q->queue);
 }
 EXPORT_SYMBOL_GPL(iscsi_pool_free);
 
@@ -2825,7 +2819,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
 
        /* allocate login_task used for the login/text sequences */
        spin_lock_bh(&session->lock);
-       if (!__kfifo_get(session->cmdpool.queue,
+       if (!kfifo_out(&session->cmdpool.queue,
                          (void*)&conn->login_task,
                         sizeof(void*))) {
                spin_unlock_bh(&session->lock);
@@ -2845,7 +2839,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
        return cls_conn;
 
 login_task_data_alloc_fail:
-       __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task,
+       kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
                    sizeof(void*));
 login_task_alloc_fail:
        iscsi_destroy_conn(cls_conn);
@@ -2908,7 +2902,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
        free_pages((unsigned long) conn->data,
                   get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
        kfree(conn->persistent_address);
-       __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task,
+       kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
                    sizeof(void*));
        if (session->leadconn == conn)
                session->leadconn = NULL;
index ca25ee5190b006df23822e25f2abbed5fe4ea075..db6856c138fcd9d28af1c422bc2c0333540de328 100644 (file)
@@ -445,15 +445,15 @@ void iscsi_tcp_cleanup_task(struct iscsi_task *task)
                return;
 
        /* flush task's r2t queues */
-       while (__kfifo_get(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
-               __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
+       while (kfifo_out(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
+               kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
                            sizeof(void*));
                ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n");
        }
 
        r2t = tcp_task->r2t;
        if (r2t != NULL) {
-               __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
+               kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
                            sizeof(void*));
                tcp_task->r2t = NULL;
        }
@@ -541,7 +541,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
                return 0;
        }
 
-       rc = __kfifo_get(tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
+       rc = kfifo_out(&tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
        if (!rc) {
                iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. "
                                  "Target has sent more R2Ts than it "
@@ -554,7 +554,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
        if (r2t->data_length == 0) {
                iscsi_conn_printk(KERN_ERR, conn,
                                  "invalid R2T with zero data len\n");
-               __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
+               kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
                            sizeof(void*));
                return ISCSI_ERR_DATALEN;
        }
@@ -570,7 +570,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
                                  "invalid R2T with data len %u at offset %u "
                                  "and total length %d\n", r2t->data_length,
                                  r2t->data_offset, scsi_out(task->sc)->length);
-               __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
+               kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
                            sizeof(void*));
                return ISCSI_ERR_DATALEN;
        }
@@ -580,7 +580,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
        r2t->sent = 0;
 
        tcp_task->exp_datasn = r2tsn + 1;
-       __kfifo_put(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
+       kfifo_in(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
        conn->r2t_pdus_cnt++;
 
        iscsi_requeue_task(task);
@@ -951,7 +951,7 @@ int iscsi_tcp_task_init(struct iscsi_task *task)
                return conn->session->tt->init_pdu(task, 0, task->data_count);
        }
 
-       BUG_ON(__kfifo_len(tcp_task->r2tqueue));
+       BUG_ON(kfifo_len(&tcp_task->r2tqueue));
        tcp_task->exp_datasn = 0;
 
        /* Prepare PDU, optionally w/ immediate data */
@@ -982,7 +982,7 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
                        if (r2t->data_length <= r2t->sent) {
                                ISCSI_DBG_TCP(task->conn,
                                              "  done with r2t %p\n", r2t);
-                               __kfifo_put(tcp_task->r2tpool.queue,
+                               kfifo_in(&tcp_task->r2tpool.queue,
                                            (void *)&tcp_task->r2t,
                                            sizeof(void *));
                                tcp_task->r2t = r2t = NULL;
@@ -990,8 +990,13 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
                }
 
                if (r2t == NULL) {
-                       __kfifo_get(tcp_task->r2tqueue,
-                                   (void *)&tcp_task->r2t, sizeof(void *));
+                       if (kfifo_out(&tcp_task->r2tqueue,
+                           (void *)&tcp_task->r2t, sizeof(void *)) !=
+                           sizeof(void *)) {
+                               WARN_ONCE(1, "unexpected fifo state");
+                               r2t = NULL;
+                       }
+
                        r2t = tcp_task->r2t;
                }
                spin_unlock_bh(&session->lock);
@@ -1127,9 +1132,8 @@ int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session)
                }
 
                /* R2T xmit queue */
-               tcp_task->r2tqueue = kfifo_alloc(
-                     session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL);
-               if (tcp_task->r2tqueue == ERR_PTR(-ENOMEM)) {
+               if (kfifo_alloc(&tcp_task->r2tqueue,
+                     session->max_r2t * 4 * sizeof(void*), GFP_KERNEL)) {
                        iscsi_pool_free(&tcp_task->r2tpool);
                        goto r2t_alloc_fail;
                }
@@ -1142,7 +1146,7 @@ r2t_alloc_fail:
                struct iscsi_task *task = session->cmds[i];
                struct iscsi_tcp_task *tcp_task = task->dd_data;
 
-               kfifo_free(tcp_task->r2tqueue);
+               kfifo_free(&tcp_task->r2tqueue);
                iscsi_pool_free(&tcp_task->r2tpool);
        }
        return -ENOMEM;
@@ -1157,7 +1161,7 @@ void iscsi_tcp_r2tpool_free(struct iscsi_session *session)
                struct iscsi_task *task = session->cmds[i];
                struct iscsi_tcp_task *tcp_task = task->dd_data;
 
-               kfifo_free(tcp_task->r2tqueue);
+               kfifo_free(&tcp_task->r2tqueue);
                iscsi_pool_free(&tcp_task->r2tpool);
        }
 }
index 9ad38e81e343ee1b9d419b175f266131dbceb0cf..ab19b3b4be524a679774601f2193da98bfa369d9 100644 (file)
@@ -58,19 +58,15 @@ static int srp_iu_pool_alloc(struct srp_queue *q, size_t max,
                goto free_pool;
 
        spin_lock_init(&q->lock);
-       q->queue = kfifo_init((void *) q->pool, max * sizeof(void *),
-                             GFP_KERNEL, &q->lock);
-       if (IS_ERR(q->queue))
-               goto free_item;
+       kfifo_init(&q->queue, (void *) q->pool, max * sizeof(void *));
 
        for (i = 0, iue = q->items; i < max; i++) {
-               __kfifo_put(q->queue, (void *) &iue, sizeof(void *));
+               kfifo_in(&q->queue, (void *) &iue, sizeof(void *));
                iue->sbuf = ring[i];
                iue++;
        }
        return 0;
 
-free_item:
        kfree(q->items);
 free_pool:
        kfree(q->pool);
@@ -167,7 +163,11 @@ struct iu_entry *srp_iu_get(struct srp_target *target)
 {
        struct iu_entry *iue = NULL;
 
-       kfifo_get(target->iu_queue.queue, (void *) &iue, sizeof(void *));
+       if (kfifo_out_locked(&target->iu_queue.queue, (void *) &iue,
+               sizeof(void *), &target->iu_queue.lock) != sizeof(void *)) {
+                       WARN_ONCE(1, "unexpected fifo state");
+                       return NULL;
+       }
        if (!iue)
                return iue;
        iue->target = target;
@@ -179,7 +179,8 @@ EXPORT_SYMBOL_GPL(srp_iu_get);
 
 void srp_iu_put(struct iu_entry *iue)
 {
-       kfifo_put(iue->target->iu_queue.queue, (void *) &iue, sizeof(void *));
+       kfifo_in_locked(&iue->target->iu_queue.queue, (void *) &iue,
+                       sizeof(void *), &iue->target->iu_queue.lock);
 }
 EXPORT_SYMBOL_GPL(srp_iu_put);
 
index 226920d15ea1b31be3191be671987f6d441a399d..d4da6bdd0e73fd5d4442b2487e185920f59ef7de 100644 (file)
@@ -4506,9 +4506,13 @@ lpfc_sli_pci_mem_setup(struct lpfc_hba *phba)
                pdev = phba->pcidev;
 
        /* Set the device DMA mask size */
-       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0)
-               if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0)
+       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0
+        || pci_set_consistent_dma_mask(pdev,DMA_BIT_MASK(64)) != 0) {
+               if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0
+                || pci_set_consistent_dma_mask(pdev,DMA_BIT_MASK(32)) != 0) {
                        return error;
+               }
+       }
 
        /* Get the bus address of Bar0 and Bar2 and the number of bytes
         * required by each mapping.
@@ -6021,9 +6025,13 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)
                pdev = phba->pcidev;
 
        /* Set the device DMA mask size */
-       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0)
-               if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0)
+       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) != 0
+        || pci_set_consistent_dma_mask(pdev,DMA_BIT_MASK(64)) != 0) {
+               if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) != 0
+                || pci_set_consistent_dma_mask(pdev,DMA_BIT_MASK(32)) != 0) {
                        return error;
+               }
+       }
 
        /* Get the bus address of SLI4 device Bar0, Bar1, and Bar2 and the
         * number of bytes required by each mapping. They are actually
index 134c63ef6d3851e14bab96a2d0cf2b4b1b9cb5c7..99ff99e45beeac31167428ddedca6405a5aedef4 100644 (file)
@@ -2501,7 +2501,9 @@ static int megasas_init_mfi(struct megasas_instance *instance)
                instance->base_addr = pci_resource_start(instance->pdev, 0);
        }
 
-       if (pci_request_regions(instance->pdev, "megasas: LSI")) {
+       if (pci_request_selected_regions(instance->pdev,
+               pci_select_bars(instance->pdev, IORESOURCE_MEM),
+               "megasas: LSI")) {
                printk(KERN_DEBUG "megasas: IO memory region busy!\n");
                return -EBUSY;
        }
@@ -2642,7 +2644,8 @@ static int megasas_init_mfi(struct megasas_instance *instance)
        iounmap(instance->reg_set);
 
       fail_ioremap:
-       pci_release_regions(instance->pdev);
+       pci_release_selected_regions(instance->pdev,
+               pci_select_bars(instance->pdev, IORESOURCE_MEM));
 
        return -EINVAL;
 }
@@ -2662,7 +2665,8 @@ static void megasas_release_mfi(struct megasas_instance *instance)
 
        iounmap(instance->reg_set);
 
-       pci_release_regions(instance->pdev);
+       pci_release_selected_regions(instance->pdev,
+               pci_select_bars(instance->pdev, IORESOURCE_MEM));
 }
 
 /**
@@ -2971,7 +2975,7 @@ megasas_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        /*
         * PCI prepping: enable device set bus mastering and dma mask
         */
-       rval = pci_enable_device(pdev);
+       rval = pci_enable_device_mem(pdev);
 
        if (rval) {
                return rval;
@@ -3276,7 +3280,7 @@ megasas_resume(struct pci_dev *pdev)
        /*
         * PCI prepping: enable device set bus mastering and dma mask
         */
-       rval = pci_enable_device(pdev);
+       rval = pci_enable_device_mem(pdev);
 
        if (rval) {
                printk(KERN_ERR "megasas: Enable device failed\n");
index 6422e258fd52717b944ffa820bdecf504edcee92..89d02401b9eca54aa5c1de99eebdf73558e05bdc 100644 (file)
@@ -3583,6 +3583,11 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
        ioc->transport_cmds.status = MPT2_CMD_NOT_USED;
        mutex_init(&ioc->transport_cmds.mutex);
 
+       /* scsih internal command bits */
+       ioc->scsih_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
+       ioc->scsih_cmds.status = MPT2_CMD_NOT_USED;
+       mutex_init(&ioc->scsih_cmds.mutex);
+
        /* task management internal command bits */
        ioc->tm_cmds.reply = kzalloc(ioc->reply_sz, GFP_KERNEL);
        ioc->tm_cmds.status = MPT2_CMD_NOT_USED;
index c790d45876c47591d04f8906b79aaa134cbccb2d..cae6b2cf492fb099cd2b7b6a2257dd8a768c2105 100644 (file)
@@ -657,6 +657,7 @@ static struct pci_device_id __devinitdata mvs_pci_table[] = {
        { PCI_VDEVICE(MARVELL, 0x9180), chip_9180 },
        { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1300), chip_1300 },
        { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1320), chip_1320 },
+       { PCI_VDEVICE(ADAPTEC2, 0x0450), chip_6440 },
 
        { }     /* terminate list */
 };
index 950202a70bcf5ea236924edaad5cf35734bfc4cf..24223473f573c9b9e3ffd51714e015a68f8fa0cb 100644 (file)
@@ -432,30 +432,23 @@ static void _osd_free_seg(struct osd_request *or __unused,
        seg->alloc_size = 0;
 }
 
-static void _put_request(struct request *rq , bool is_async)
+static void _put_request(struct request *rq)
 {
-       if (is_async) {
-               WARN_ON(rq->bio);
-               __blk_put_request(rq->q, rq);
-       } else {
-               /*
-                * If osd_finalize_request() was called but the request was not
-                * executed through the block layer, then we must release BIOs.
-                * TODO: Keep error code in or->async_error. Need to audit all
-                *       code paths.
-                */
-               if (unlikely(rq->bio))
-                       blk_end_request(rq, -ENOMEM, blk_rq_bytes(rq));
-               else
-                       blk_put_request(rq);
-       }
+       /*
+        * If osd_finalize_request() was called but the request was not
+        * executed through the block layer, then we must release BIOs.
+        * TODO: Keep error code in or->async_error. Need to audit all
+        *       code paths.
+        */
+       if (unlikely(rq->bio))
+               blk_end_request(rq, -ENOMEM, blk_rq_bytes(rq));
+       else
+               blk_put_request(rq);
 }
 
 void osd_end_request(struct osd_request *or)
 {
        struct request *rq = or->request;
-       /* IMPORTANT: make sure this agrees with osd_execute_request_async */
-       bool is_async = (or->request->end_io_data == or);
 
        _osd_free_seg(or, &or->set_attr);
        _osd_free_seg(or, &or->enc_get_attr);
@@ -463,20 +456,34 @@ void osd_end_request(struct osd_request *or)
 
        if (rq) {
                if (rq->next_rq) {
-                       _put_request(rq->next_rq, is_async);
+                       _put_request(rq->next_rq);
                        rq->next_rq = NULL;
                }
 
-               _put_request(rq, is_async);
+               _put_request(rq);
        }
        _osd_request_free(or);
 }
 EXPORT_SYMBOL(osd_end_request);
 
+static void _set_error_resid(struct osd_request *or, struct request *req,
+                            int error)
+{
+       or->async_error = error;
+       or->req_errors = req->errors ? : error;
+       or->sense_len = req->sense_len;
+       if (or->out.req)
+               or->out.residual = or->out.req->resid_len;
+       if (or->in.req)
+               or->in.residual = or->in.req->resid_len;
+}
+
 int osd_execute_request(struct osd_request *or)
 {
-       return or->async_error =
-                       blk_execute_rq(or->request->q, NULL, or->request, 0);
+       int error = blk_execute_rq(or->request->q, NULL, or->request, 0);
+
+       _set_error_resid(or, or->request, error);
+       return error;
 }
 EXPORT_SYMBOL(osd_execute_request);
 
@@ -484,15 +491,17 @@ static void osd_request_async_done(struct request *req, int error)
 {
        struct osd_request *or = req->end_io_data;
 
-       or->async_error = error;
-
-       if (unlikely(error)) {
-               OSD_DEBUG("osd_request_async_done error recieved %d "
-                         "errors 0x%x\n", error, req->errors);
-               if (!req->errors) /* don't miss out on this one */
-                       req->errors = error;
+       _set_error_resid(or, req, error);
+       if (req->next_rq) {
+               __blk_put_request(req->q, req->next_rq);
+               req->next_rq = NULL;
        }
 
+       __blk_put_request(req->q, req);
+       or->request = NULL;
+       or->in.req = NULL;
+       or->out.req = NULL;
+
        if (or->async_done)
                or->async_done(or, or->async_private);
        else
@@ -1489,21 +1498,18 @@ int osd_req_decode_sense_full(struct osd_request *or,
 #endif
        int ret;
 
-       if (likely(!or->request->errors)) {
-               osi->out_resid = 0;
-               osi->in_resid = 0;
+       if (likely(!or->req_errors))
                return 0;
-       }
 
        osi = osi ? : &local_osi;
        memset(osi, 0, sizeof(*osi));
 
-       ssdb = or->request->sense;
-       sense_len = or->request->sense_len;
+       ssdb = (typeof(ssdb))or->sense;
+       sense_len = or->sense_len;
        if ((sense_len < (int)sizeof(*ssdb) || !ssdb->sense_key)) {
                OSD_ERR("Block-layer returned error(0x%x) but "
                        "sense_len(%u) || key(%d) is empty\n",
-                       or->request->errors, sense_len, ssdb->sense_key);
+                       or->req_errors, sense_len, ssdb->sense_key);
                goto analyze;
        }
 
@@ -1525,7 +1531,7 @@ int osd_req_decode_sense_full(struct osd_request *or,
                        "additional_code=0x%x async_error=%d errors=0x%x\n",
                        osi->key, original_sense_len, sense_len,
                        osi->additional_code, or->async_error,
-                       or->request->errors);
+                       or->req_errors);
 
        if (original_sense_len < sense_len)
                sense_len = original_sense_len;
@@ -1695,10 +1701,10 @@ analyze:
                ret = -EIO;
        }
 
-       if (or->out.req)
-               osi->out_resid = or->out.req->resid_len ?: or->out.total_bytes;
-       if (or->in.req)
-               osi->in_resid = or->in.req->resid_len ?: or->in.total_bytes;
+       if (!or->out.residual)
+               or->out.residual = or->out.total_bytes;
+       if (!or->in.residual)
+               or->in.residual = or->in.total_bytes;
 
        return ret;
 }
index 22644de2639939bd2156242843ee81349f14e8b0..63ad4aa0c4222b0240068e7168af6f9ea79c3dd2 100644 (file)
 #define HEADER_LEN                     28
 #define SIZE_OFFSET                    16
 
-struct pm8001_ioctl_payload {
-       u32     signature;
-       u16     major_function;
-       u16     minor_function;
-       u16     length;
-       u16     status;
-       u16     offset;
-       u16     id;
-       u8      func_specific[1];
-};
 
 #define FLASH_OK                        0x000000
 #define FAIL_OPEN_BIOS_FILE             0x000100
index a3de306b9045486985c4ed4ccaf9d3b543ea122f..9b44c6f1b10e554525fe54d1f0b928c614d47568 100644 (file)
@@ -373,10 +373,7 @@ static int bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shiftValue)
 static void __devinit
 mpi_set_phys_g3_with_ssc(struct pm8001_hba_info *pm8001_ha, u32 SSCbit)
 {
-       u32 offset;
-       u32 value;
-       u32 i, j;
-       u32 bit_cnt;
+       u32 value, offset, i;
 
 #define SAS2_SETTINGS_LOCAL_PHY_0_3_SHIFT_ADDR 0x00030000
 #define SAS2_SETTINGS_LOCAL_PHY_4_7_SHIFT_ADDR 0x00040000
@@ -392,55 +389,35 @@ mpi_set_phys_g3_with_ssc(struct pm8001_hba_info *pm8001_ha, u32 SSCbit)
     */
        if (-1 == bar4_shift(pm8001_ha, SAS2_SETTINGS_LOCAL_PHY_0_3_SHIFT_ADDR))
                return;
-       /* set SSC bit of PHY 0 - 3 */
+
        for (i = 0; i < 4; i++) {
                offset = SAS2_SETTINGS_LOCAL_PHY_0_3_OFFSET + 0x4000 * i;
-               value = pm8001_cr32(pm8001_ha, 2, offset);
-               if (SSCbit) {
-                       value |= 0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT;
-                       value &= ~(0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT);
-               } else {
-                       value |= 0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT;
-                       value &= ~(0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT);
-               }
-               bit_cnt = 0;
-               for (j = 0; j < 31; j++)
-                       if ((value >> j) & 0x00000001)
-                               bit_cnt++;
-               if (bit_cnt % 2)
-                       value &= ~(0x00000001 << SNW3_PHY_CAPABILITIES_PARITY);
-               else
-                       value |= 0x00000001 << SNW3_PHY_CAPABILITIES_PARITY;
-
-               pm8001_cw32(pm8001_ha, 2, offset, value);
+               pm8001_cw32(pm8001_ha, 2, offset, 0x80001501);
        }
-
        /* shift membase 3 for SAS2_SETTINGS_LOCAL_PHY 4 - 7 */
        if (-1 == bar4_shift(pm8001_ha, SAS2_SETTINGS_LOCAL_PHY_4_7_SHIFT_ADDR))
                return;
-
-       /* set SSC bit of PHY 4 - 7 */
        for (i = 4; i < 8; i++) {
                offset = SAS2_SETTINGS_LOCAL_PHY_4_7_OFFSET + 0x4000 * (i-4);
-               value = pm8001_cr32(pm8001_ha, 2, offset);
-               if (SSCbit) {
-                       value |= 0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT;
-                       value &= ~(0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT);
-               } else {
-                       value |= 0x00000001 << PHY_G3_WITHOUT_SSC_BIT_SHIFT;
-                       value &= ~(0x00000001 << PHY_G3_WITH_SSC_BIT_SHIFT);
-               }
-               bit_cnt = 0;
-               for (j = 0; j < 31; j++)
-                       if ((value >> j) & 0x00000001)
-                               bit_cnt++;
-               if (bit_cnt % 2)
-                       value &= ~(0x00000001 << SNW3_PHY_CAPABILITIES_PARITY);
-               else
-                       value |= 0x00000001 << SNW3_PHY_CAPABILITIES_PARITY;
-
-               pm8001_cw32(pm8001_ha, 2, offset, value);
+               pm8001_cw32(pm8001_ha, 2, offset, 0x80001501);
        }
+       /*************************************************************
+       Change the SSC upspreading value to 0x0 so that upspreading is disabled.
+       Device MABC SMOD0 Controls
+       Address: (via MEMBASE-III):
+       Using shifted destination address 0x0_0000: with Offset 0xD8
+
+       31:28 R/W Reserved Do not change
+       27:24 R/W SAS_SMOD_SPRDUP 0000
+       23:20 R/W SAS_SMOD_SPRDDN 0000
+       19:0  R/W  Reserved Do not change
+       Upon power-up this register will read as 0x8990c016,
+       and I would like you to change the SAS_SMOD_SPRDUP bits to 0b0000
+       so that the written value will be 0x8090c016.
+       This will ensure only down-spreading SSC is enabled on the SPC.
+       *************************************************************/
+       value = pm8001_cr32(pm8001_ha, 2, 0xd8);
+       pm8001_cw32(pm8001_ha, 2, 0xd8, 0x8000C016);
 
        /*set the shifted destination address to 0x0 to avoid error operation */
        bar4_shift(pm8001_ha, 0x0);
@@ -1901,7 +1878,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 {
        struct sas_task *t;
        struct pm8001_ccb_info *ccb;
-       unsigned long flags;
+       unsigned long flags = 0;
        u32 param;
        u32 status;
        u32 tag;
@@ -2040,7 +2017,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*in order to force CPU ordering*/
+                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                        t->task_done(t);
+                       spin_lock_irqsave(&pm8001_ha->lock, flags);
                        return;
                }
                break;
@@ -2058,7 +2037,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*ditto*/
+                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                        t->task_done(t);
+                       spin_lock_irqsave(&pm8001_ha->lock, flags);
                        return;
                }
                break;
@@ -2084,7 +2065,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/* ditto*/
+                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                        t->task_done(t);
+                       spin_lock_irqsave(&pm8001_ha->lock, flags);
                        return;
                }
                break;
@@ -2149,7 +2132,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*ditto*/
+                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                        t->task_done(t);
+                       spin_lock_irqsave(&pm8001_ha->lock, flags);
                        return;
                }
                break;
@@ -2171,7 +2156,9 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*ditto*/
+                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                        t->task_done(t);
+                       spin_lock_irqsave(&pm8001_ha->lock, flags);
                        return;
                }
                break;
@@ -2200,11 +2187,20 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        " resp 0x%x stat 0x%x but aborted by upper layer!\n",
                        t, status, ts->resp, ts->stat));
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
-       } else {
+       } else if (t->uldd_task) {
                spin_unlock_irqrestore(&t->task_state_lock, flags);
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                mb();/* ditto */
+               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                t->task_done(t);
+               spin_lock_irqsave(&pm8001_ha->lock, flags);
+       } else if (!t->uldd_task) {
+               spin_unlock_irqrestore(&t->task_state_lock, flags);
+               pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
+               mb();/*ditto*/
+               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+               t->task_done(t);
+               spin_lock_irqsave(&pm8001_ha->lock, flags);
        }
 }
 
@@ -2212,7 +2208,7 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
 {
        struct sas_task *t;
-       unsigned long flags;
+       unsigned long flags = 0;
        struct task_status_struct *ts;
        struct pm8001_ccb_info *ccb;
        struct pm8001_device *pm8001_dev;
@@ -2292,7 +2288,9 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
                        ts->stat = SAS_QUEUE_FULL;
                        pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
                        mb();/*ditto*/
+                       spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                        t->task_done(t);
+                       spin_lock_irqsave(&pm8001_ha->lock, flags);
                        return;
                }
                break;
@@ -2401,11 +2399,20 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb)
                        " resp 0x%x stat 0x%x but aborted by upper layer!\n",
                        t, event, ts->resp, ts->stat));
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
-       } else {
+       } else if (t->uldd_task) {
                spin_unlock_irqrestore(&t->task_state_lock, flags);
                pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
-               mb();/* in order to force CPU ordering */
+               mb();/* ditto */
+               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                t->task_done(t);
+               spin_lock_irqsave(&pm8001_ha->lock, flags);
+       } else if (!t->uldd_task) {
+               spin_unlock_irqrestore(&t->task_state_lock, flags);
+               pm8001_ccb_task_free(pm8001_ha, t, ccb, tag);
+               mb();/*ditto*/
+               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+               t->task_done(t);
+               spin_lock_irqsave(&pm8001_ha->lock, flags);
        }
 }
 
@@ -2876,15 +2883,20 @@ hw_event_sas_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb)
                le32_to_cpu(pPayload->lr_evt_status_phyid_portid);
        u8 link_rate =
                (u8)((lr_evt_status_phyid_portid & 0xF0000000) >> 28);
+       u8 port_id = (u8)(lr_evt_status_phyid_portid & 0x0000000F);
        u8 phy_id =
                (u8)((lr_evt_status_phyid_portid & 0x000000F0) >> 4);
+       u32 npip_portstate = le32_to_cpu(pPayload->npip_portstate);
+       u8 portstate = (u8)(npip_portstate & 0x0000000F);
+       struct pm8001_port *port = &pm8001_ha->port[port_id];
        struct sas_ha_struct *sas_ha = pm8001_ha->sas;
        struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];
        unsigned long flags;
        u8 deviceType = pPayload->sas_identify.dev_type;
-
+       port->port_state =  portstate;
        PM8001_MSG_DBG(pm8001_ha,
-               pm8001_printk("HW_EVENT_SAS_PHY_UP \n"));
+               pm8001_printk("HW_EVENT_SAS_PHY_UP port id = %d, phy id = %d\n",
+               port_id, phy_id));
 
        switch (deviceType) {
        case SAS_PHY_UNUSED:
@@ -2895,16 +2907,19 @@ hw_event_sas_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb)
                PM8001_MSG_DBG(pm8001_ha, pm8001_printk("end device.\n"));
                pm8001_chip_phy_ctl_req(pm8001_ha, phy_id,
                        PHY_NOTIFY_ENABLE_SPINUP);
+               port->port_attached = 1;
                get_lrate_mode(phy, link_rate);
                break;
        case SAS_EDGE_EXPANDER_DEVICE:
                PM8001_MSG_DBG(pm8001_ha,
                        pm8001_printk("expander device.\n"));
+               port->port_attached = 1;
                get_lrate_mode(phy, link_rate);
                break;
        case SAS_FANOUT_EXPANDER_DEVICE:
                PM8001_MSG_DBG(pm8001_ha,
                        pm8001_printk("fanout expander device.\n"));
+               port->port_attached = 1;
                get_lrate_mode(phy, link_rate);
                break;
        default:
@@ -2946,11 +2961,20 @@ hw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb)
                le32_to_cpu(pPayload->lr_evt_status_phyid_portid);
        u8 link_rate =
                (u8)((lr_evt_status_phyid_portid & 0xF0000000) >> 28);
+       u8 port_id = (u8)(lr_evt_status_phyid_portid & 0x0000000F);
        u8 phy_id =
                (u8)((lr_evt_status_phyid_portid & 0x000000F0) >> 4);
+       u32 npip_portstate = le32_to_cpu(pPayload->npip_portstate);
+       u8 portstate = (u8)(npip_portstate & 0x0000000F);
+       struct pm8001_port *port = &pm8001_ha->port[port_id];
        struct sas_ha_struct *sas_ha = pm8001_ha->sas;
        struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];
        unsigned long flags;
+       PM8001_MSG_DBG(pm8001_ha,
+               pm8001_printk("HW_EVENT_SATA_PHY_UP port id = %d,"
+               " phy id = %d\n", port_id, phy_id));
+       port->port_state =  portstate;
+       port->port_attached = 1;
        get_lrate_mode(phy, link_rate);
        phy->phy_type |= PORT_TYPE_SATA;
        phy->phy_attached = 1;
@@ -2984,7 +3008,13 @@ hw_event_phy_down(struct pm8001_hba_info *pm8001_ha, void *piomb)
                (u8)((lr_evt_status_phyid_portid & 0x000000F0) >> 4);
        u32 npip_portstate = le32_to_cpu(pPayload->npip_portstate);
        u8 portstate = (u8)(npip_portstate & 0x0000000F);
-
+       struct pm8001_port *port = &pm8001_ha->port[port_id];
+       struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];
+       port->port_state =  portstate;
+       phy->phy_type = 0;
+       phy->identify.device_type = 0;
+       phy->phy_attached = 0;
+       memset(&phy->dev_sas_addr, 0, SAS_ADDR_SIZE);
        switch (portstate) {
        case PORT_VALID:
                break;
@@ -2993,26 +3023,30 @@ hw_event_phy_down(struct pm8001_hba_info *pm8001_ha, void *piomb)
                        pm8001_printk(" PortInvalid portID %d \n", port_id));
                PM8001_MSG_DBG(pm8001_ha,
                        pm8001_printk(" Last phy Down and port invalid\n"));
+               port->port_attached = 0;
                pm8001_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_PHY_DOWN,
                        port_id, phy_id, 0, 0);
                break;
        case PORT_IN_RESET:
                PM8001_MSG_DBG(pm8001_ha,
-                       pm8001_printk(" PortInReset portID %d \n", port_id));
+                       pm8001_printk(" Port In Reset portID %d \n", port_id));
                break;
        case PORT_NOT_ESTABLISHED:
                PM8001_MSG_DBG(pm8001_ha,
                        pm8001_printk(" phy Down and PORT_NOT_ESTABLISHED\n"));
+               port->port_attached = 0;
                break;
        case PORT_LOSTCOMM:
                PM8001_MSG_DBG(pm8001_ha,
                        pm8001_printk(" phy Down and PORT_LOSTCOMM\n"));
                PM8001_MSG_DBG(pm8001_ha,
                        pm8001_printk(" Last phy Down and port invalid\n"));
+               port->port_attached = 0;
                pm8001_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_PHY_DOWN,
                        port_id, phy_id, 0, 0);
                break;
        default:
+               port->port_attached = 0;
                PM8001_MSG_DBG(pm8001_ha,
                        pm8001_printk(" phy Down and(default) = %x\n",
                        portstate));
@@ -3770,7 +3804,8 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha,
        u32 opc = OPC_INB_SSPINIIOSTART;
        memset(&ssp_cmd, 0, sizeof(ssp_cmd));
        memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8);
-       ssp_cmd.dir_m_tlr = data_dir_flags[task->data_dir] << 8 | 0x0;/*0 for
+       ssp_cmd.dir_m_tlr =
+               cpu_to_le32(data_dir_flags[task->data_dir] << 8 | 0x0);/*0 for
        SAS 1.1 compatible TLR*/
        ssp_cmd.data_len = cpu_to_le32(task->total_xfer_len);
        ssp_cmd.device_id = cpu_to_le32(pm8001_dev->device_id);
@@ -3841,7 +3876,7 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
                }
        }
        if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag))
-               ncg_tag = cpu_to_le32(hdr_tag);
+               ncg_tag = hdr_tag;
        dir = data_dir_flags[task->data_dir] << 8;
        sata_cmd.tag = cpu_to_le32(tag);
        sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id);
@@ -3986,7 +4021,7 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha,
                ((stp_sspsmp_sata & 0x03) * 0x10000000));
        payload.firstburstsize_ITNexustimeout =
                cpu_to_le32(ITNT | (firstBurstSize * 0x10000));
-       memcpy(&payload.sas_addr_hi, pm8001_dev->sas_device->sas_addr,
+       memcpy(payload.sas_addr, pm8001_dev->sas_device->sas_addr,
                SAS_ADDR_SIZE);
        rc = mpi_build_cmd(pm8001_ha, circularQ, opc, &payload);
        return rc;
@@ -4027,7 +4062,7 @@ static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
        struct inbound_queue_table *circularQ;
        int ret;
        u32 opc = OPC_INB_LOCAL_PHY_CONTROL;
-       memset((u8 *)&payload, 0, sizeof(payload));
+       memset(&payload, 0, sizeof(payload));
        circularQ = &pm8001_ha->inbnd_q_tbl[0];
        payload.tag = 1;
        payload.phyop_phyid =
index 96e4daa68b8fafd41c9ca0138edf9abb6a694e15..833a5201eda4dd0b640c0e33d5eac0212fd7acd4 100644 (file)
@@ -242,8 +242,7 @@ struct reg_dev_req {
        __le32  phyid_portid;
        __le32  dtype_dlr_retry;
        __le32  firstburstsize_ITNexustimeout;
-       u32     sas_addr_hi;
-       u32     sas_addr_low;
+       u8      sas_addr[SAS_ADDR_SIZE];
        __le32  upper_device_id;
        u32     reserved[8];
 } __attribute__((packed, aligned(4)));
index 42ebe725d5a509ea911118d217d61a5430599637..c2f1032496cb6acac2bdd8dba7192e52c75970d2 100644 (file)
@@ -200,8 +200,13 @@ static int __devinit pm8001_alloc(struct pm8001_hba_info *pm8001_ha)
 {
        int i;
        spin_lock_init(&pm8001_ha->lock);
-       for (i = 0; i < pm8001_ha->chip->n_phy; i++)
+       for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
                pm8001_phy_init(pm8001_ha, i);
+               pm8001_ha->port[i].wide_port_phymap = 0;
+               pm8001_ha->port[i].port_attached = 0;
+               pm8001_ha->port[i].port_state = 0;
+               INIT_LIST_HEAD(&pm8001_ha->port[i].list);
+       }
 
        pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL);
        if (!pm8001_ha->tags)
@@ -511,19 +516,23 @@ static void pm8001_init_sas_add(struct pm8001_hba_info *pm8001_ha)
        u8 i;
 #ifdef PM8001_READ_VPD
        DECLARE_COMPLETION_ONSTACK(completion);
+       struct pm8001_ioctl_payload payload;
        pm8001_ha->nvmd_completion = &completion;
-       PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, 0, 0);
+       payload.minor_function = 0;
+       payload.length = 128;
+       payload.func_specific = kzalloc(128, GFP_KERNEL);
+       PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload);
        wait_for_completion(&completion);
        for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
                memcpy(&pm8001_ha->phy[i].dev_sas_addr, pm8001_ha->sas_addr,
                        SAS_ADDR_SIZE);
                PM8001_INIT_DBG(pm8001_ha,
-                       pm8001_printk("phy %d sas_addr = %x \n", i,
-                       (u64)pm8001_ha->phy[i].dev_sas_addr));
+                       pm8001_printk("phy %d sas_addr = %016llx \n", i,
+                       pm8001_ha->phy[i].dev_sas_addr));
        }
 #else
        for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
-               pm8001_ha->phy[i].dev_sas_addr = 0x500e004010000004ULL;
+               pm8001_ha->phy[i].dev_sas_addr = 0x50010c600047f9d0ULL;
                pm8001_ha->phy[i].dev_sas_addr =
                        cpu_to_be64((u64)
                                (*(u64 *)&pm8001_ha->phy[i].dev_sas_addr));
index 1f767a0e727a9b46d5fc4e073576c1422e3b9eea..7f9c83a76390d61b1724278f229001463f523093 100644 (file)
@@ -329,6 +329,23 @@ int pm8001_slave_configure(struct scsi_device *sdev)
        }
        return 0;
 }
+ /* Find the local port id that's attached to this device */
+static int sas_find_local_port_id(struct domain_device *dev)
+{
+       struct domain_device *pdev = dev->parent;
+
+       /* Directly attached device */
+       if (!pdev)
+               return dev->port->id;
+       while (pdev) {
+               struct domain_device *pdev_p = pdev->parent;
+               if (!pdev_p)
+                       return pdev->port->id;
+               pdev = pdev->parent;
+       }
+       return 0;
+}
+
 /**
   * pm8001_task_exec - queue the task(ssp, smp && ata) to the hardware.
   * @task: the task to be execute.
@@ -346,11 +363,12 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
        struct domain_device *dev = task->dev;
        struct pm8001_hba_info *pm8001_ha;
        struct pm8001_device *pm8001_dev;
+       struct pm8001_port *port = NULL;
        struct sas_task *t = task;
        struct pm8001_ccb_info *ccb;
        u32 tag = 0xdeadbeef, rc, n_elem = 0;
        u32 n = num;
-       unsigned long flags = 0;
+       unsigned long flags = 0, flags_libsas = 0;
 
        if (!dev->port) {
                struct task_status_struct *tsm = &t->task_status;
@@ -379,6 +397,35 @@ static int pm8001_task_exec(struct sas_task *task, const int num,
                        rc = SAS_PHY_DOWN;
                        goto out_done;
                }
+               port = &pm8001_ha->port[sas_find_local_port_id(dev)];
+               if (!port->port_attached) {
+                       if (sas_protocol_ata(t->task_proto)) {
+                               struct task_status_struct *ts = &t->task_status;
+                               ts->resp = SAS_TASK_UNDELIVERED;
+                               ts->stat = SAS_PHY_DOWN;
+
+                               spin_unlock_irqrestore(&pm8001_ha->lock, flags);
+                               spin_unlock_irqrestore(dev->sata_dev.ap->lock,
+                                               flags_libsas);
+                               t->task_done(t);
+                               spin_lock_irqsave(dev->sata_dev.ap->lock,
+                                       flags_libsas);
+                               spin_lock_irqsave(&pm8001_ha->lock, flags);
+                               if (n > 1)
+                                       t = list_entry(t->list.next,
+                                                       struct sas_task, list);
+                               continue;
+                       } else {
+                               struct task_status_struct *ts = &t->task_status;
+                               ts->resp = SAS_TASK_UNDELIVERED;
+                               ts->stat = SAS_PHY_DOWN;
+                               t->task_done(t);
+                               if (n > 1)
+                                       t = list_entry(t->list.next,
+                                                       struct sas_task, list);
+                               continue;
+                       }
+               }
                rc = pm8001_tag_alloc(pm8001_ha, &tag);
                if (rc)
                        goto err_out;
@@ -569,11 +616,11 @@ static int pm8001_dev_found_notify(struct domain_device *dev)
        spin_lock_irqsave(&pm8001_ha->lock, flags);
 
        pm8001_device = pm8001_alloc_dev(pm8001_ha);
-       pm8001_device->sas_device = dev;
        if (!pm8001_device) {
                res = -1;
                goto found_out;
        }
+       pm8001_device->sas_device = dev;
        dev->lldd_dev = pm8001_device;
        pm8001_device->dev_type = dev->dev_type;
        pm8001_device->dcompletion = &completion;
@@ -609,7 +656,7 @@ static int pm8001_dev_found_notify(struct domain_device *dev)
        wait_for_completion(&completion);
        if (dev->dev_type == SAS_END_DEV)
                msleep(50);
-       pm8001_ha->flags = PM8001F_RUN_TIME ;
+       pm8001_ha->flags |= PM8001F_RUN_TIME ;
        return 0;
 found_out:
        spin_unlock_irqrestore(&pm8001_ha->lock, flags);
@@ -772,7 +819,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
                task->task_done = pm8001_task_done;
                task->timer.data = (unsigned long)task;
                task->timer.function = pm8001_tmf_timedout;
-               task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
+               task->timer.expires = jiffies + PM8001_TASK_TIMEOUT * HZ;
                add_timer(&task->timer);
 
                res = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
@@ -897,6 +944,8 @@ int pm8001_I_T_nexus_reset(struct domain_device *dev)
 
        if (dev_is_sata(dev)) {
                DECLARE_COMPLETION_ONSTACK(completion_setstate);
+               if (scsi_is_sas_phy_local(phy))
+                       return 0;
                rc = sas_phy_reset(phy, 1);
                msleep(2000);
                rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
index 30f2ede55a756c8cf36f264e0467334d6ea7df49..8e38ca8cd1016461e9642d4032d579feb6fac6fc 100644 (file)
 
 #define DRV_NAME               "pm8001"
 #define DRV_VERSION            "0.1.36"
-#define PM8001_FAIL_LOGGING    0x01 /* libsas EH function logging */
+#define PM8001_FAIL_LOGGING    0x01 /* Error message logging */
 #define PM8001_INIT_LOGGING    0x02 /* driver init logging */
 #define PM8001_DISC_LOGGING    0x04 /* discovery layer logging */
 #define PM8001_IO_LOGGING      0x08 /* I/O path logging */
-#define PM8001_EH_LOGGING      0x10 /* Error message logging */
+#define PM8001_EH_LOGGING      0x10 /* libsas EH function logging*/
 #define PM8001_IOCTL_LOGGING   0x20 /* IOCTL message logging */
 #define PM8001_MSG_LOGGING     0x40 /* misc message logging */
 #define pm8001_printk(format, arg...)  printk(KERN_INFO "%s %d:" format,\
@@ -100,6 +100,7 @@ do {                                                \
 
 #define PM8001_USE_TASKLET
 #define PM8001_USE_MSIX
+#define PM8001_READ_VPD
 
 
 #define DEV_IS_EXPANDER(type)  ((type == EDGE_DEV) || (type == FANOUT_DEV))
@@ -111,7 +112,22 @@ extern const struct pm8001_dispatch pm8001_8001_dispatch;
 struct pm8001_hba_info;
 struct pm8001_ccb_info;
 struct pm8001_device;
-struct pm8001_tmf_task;
+/* define task management IU */
+struct pm8001_tmf_task {
+       u8      tmf;
+       u32     tag_of_task_to_be_managed;
+};
+struct pm8001_ioctl_payload {
+       u32     signature;
+       u16     major_function;
+       u16     minor_function;
+       u16     length;
+       u16     status;
+       u16     offset;
+       u16     id;
+       u8      *func_specific;
+};
+
 struct pm8001_dispatch {
        char *name;
        int (*chip_init)(struct pm8001_hba_info *pm8001_ha);
@@ -164,6 +180,10 @@ struct pm8001_chip_info {
 
 struct pm8001_port {
        struct asd_sas_port     sas_port;
+       u8                      port_attached;
+       u8                      wide_port_phymap;
+       u8                      port_state;
+       struct list_head        list;
 };
 
 struct pm8001_phy {
@@ -386,11 +406,7 @@ struct pm8001_fw_image_header {
        __be32 startup_entry;
 } __attribute__((packed, aligned(4)));
 
-/* define task management IU */
-struct pm8001_tmf_task {
-       u8      tmf;
-       u32     tag_of_task_to_be_managed;
-};
+
 /**
  * FW Flash Update status values
  */
index 34c6b896a91b98cf2328b251058c7aa82ce2829a..e7d2688fbeba9f6cd2ca37d27f5c4229347bd4ae 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * pmcraid.c -- driver for PMC Sierra MaxRAID controller adapters
  *
- * Written By: PMC Sierra Corporation
+ * Written By: Anil Ravindranath<anil_ravindranath@pmc-sierra.com>
+ *             PMC-Sierra Inc
  *
  * Copyright (C) 2008, 2009 PMC Sierra Inc
  *
@@ -79,7 +80,7 @@ DECLARE_BITMAP(pmcraid_minor, PMCRAID_MAX_ADAPTERS);
 /*
  * Module parameters
  */
-MODULE_AUTHOR("PMC Sierra Corporation, anil_ravindranath@pmc-sierra.com");
+MODULE_AUTHOR("Anil Ravindranath<anil_ravindranath@pmc-sierra.com>");
 MODULE_DESCRIPTION("PMC Sierra MaxRAID Controller Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(PMCRAID_DRIVER_VERSION);
@@ -162,10 +163,10 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
        spin_lock_irqsave(&pinstance->resource_lock, lock_flags);
        list_for_each_entry(temp, &pinstance->used_res_q, queue) {
 
-               /* do not expose VSETs with order-ids >= 240 */
+               /* do not expose VSETs with order-ids > MAX_VSET_TARGETS */
                if (RES_IS_VSET(temp->cfg_entry)) {
                        target = temp->cfg_entry.unique_flags1;
-                       if (target >= PMCRAID_MAX_VSET_TARGETS)
+                       if (target > PMCRAID_MAX_VSET_TARGETS)
                                continue;
                        bus = PMCRAID_VSET_BUS_ID;
                        lun = 0;
@@ -1210,7 +1211,7 @@ static int pmcraid_expose_resource(struct pmcraid_config_table_entry *cfgte)
        int retval = 0;
 
        if (cfgte->resource_type == RES_TYPE_VSET)
-               retval = ((cfgte->unique_flags1 & 0xFF) < 0xFE);
+               retval = ((cfgte->unique_flags1 & 0x80) == 0);
        else if (cfgte->resource_type == RES_TYPE_GSCSI)
                retval = (RES_BUS(cfgte->resource_address) !=
                                PMCRAID_VIRTUAL_ENCL_BUS_ID);
@@ -1361,6 +1362,7 @@ static int pmcraid_notify_aen(struct pmcraid_instance *pinstance, u8 type)
  * Return value:
  *  none
  */
+
 static void pmcraid_handle_config_change(struct pmcraid_instance *pinstance)
 {
        struct pmcraid_config_table_entry *cfg_entry;
@@ -1368,9 +1370,10 @@ static void pmcraid_handle_config_change(struct pmcraid_instance *pinstance)
        struct pmcraid_cmd *cmd;
        struct pmcraid_cmd *cfgcmd;
        struct pmcraid_resource_entry *res = NULL;
-       u32 new_entry = 1;
        unsigned long lock_flags;
        unsigned long host_lock_flags;
+       u32 new_entry = 1;
+       u32 hidden_entry = 0;
        int rc;
 
        ccn_hcam = (struct pmcraid_hcam_ccn *)pinstance->ccn.hcam;
@@ -1406,9 +1409,15 @@ static void pmcraid_handle_config_change(struct pmcraid_instance *pinstance)
        }
 
        /* If this resource is not going to be added to mid-layer, just notify
-        * applications and return
+        * applications and return. If this notification is about hiding a VSET
+        * resource, check if it was exposed already.
         */
-       if (!pmcraid_expose_resource(cfg_entry))
+       if (pinstance->ccn.hcam->notification_type ==
+           NOTIFICATION_TYPE_ENTRY_CHANGED &&
+           cfg_entry->resource_type == RES_TYPE_VSET &&
+           cfg_entry->unique_flags1 & 0x80) {
+               hidden_entry = 1;
+       } else if (!pmcraid_expose_resource(cfg_entry))
                goto out_notify_apps;
 
        spin_lock_irqsave(&pinstance->resource_lock, lock_flags);
@@ -1424,6 +1433,12 @@ static void pmcraid_handle_config_change(struct pmcraid_instance *pinstance)
 
        if (new_entry) {
 
+               if (hidden_entry) {
+                       spin_unlock_irqrestore(&pinstance->resource_lock,
+                                               lock_flags);
+                       goto out_notify_apps;
+               }
+
                /* If there are more number of resources than what driver can
                 * manage, do not notify the applications about the CCN. Just
                 * ignore this notifications and re-register the same HCAM
@@ -1454,8 +1469,9 @@ static void pmcraid_handle_config_change(struct pmcraid_instance *pinstance)
                sizeof(struct pmcraid_config_table_entry));
 
        if (pinstance->ccn.hcam->notification_type ==
-           NOTIFICATION_TYPE_ENTRY_DELETED) {
+           NOTIFICATION_TYPE_ENTRY_DELETED || hidden_entry) {
                if (res->scsi_dev) {
+                       res->cfg_entry.unique_flags1 &= 0x7F;
                        res->change_detected = RES_CHANGE_DEL;
                        res->cfg_entry.resource_handle =
                                PMCRAID_INVALID_RES_HANDLE;
index 2752b56cad56441ed5bc98583c22d3608b7d632a..92f89d50850c95aae55c195a354caef666a370d5 100644 (file)
@@ -1,6 +1,9 @@
 /*
  * pmcraid.h -- PMC Sierra MaxRAID controller driver header file
  *
+ * Written By: Anil Ravindranath<anil_ravindranath@pmc-sierra.com>
+ *             PMC-Sierra Inc
+ *
  * Copyright (C) 2008, 2009 PMC Sierra Inc.
  *
  * This program is free software; you can redistribute it and/or modify
 #define PMCRAID_VSET_LUN_ID                      0x0
 #define PMCRAID_PHYS_BUS_ID                      0x0
 #define PMCRAID_VIRTUAL_ENCL_BUS_ID              0x8
-#define PMCRAID_MAX_VSET_TARGETS                 240
+#define PMCRAID_MAX_VSET_TARGETS                 0x7F
 #define PMCRAID_MAX_VSET_LUNS_PER_TARGET         8
 
 #define PMCRAID_IOA_MAX_SECTORS                  32767
index 6b9bf23c7735267a7805181ddcbc4bd2bc08bc7b..384afda7dbe942f2ade0f189be0da5e4e7d71685 100644 (file)
@@ -1570,9 +1570,6 @@ typedef struct fc_port {
        struct fc_rport *rport, *drport;
        u32 supported_classes;
 
-       unsigned long last_queue_full;
-       unsigned long last_ramp_up;
-
        uint16_t vp_idx;
 } fc_port_t;
 
@@ -2265,6 +2262,7 @@ struct qla_hw_data {
                uint32_t        port0                   :1;
                uint32_t        running_gold_fw         :1;
                uint32_t        cpu_affinity_enabled    :1;
+               uint32_t        disable_msix_handshake  :1;
        } flags;
 
        /* This spinlock is used to protect "io transactions", you must
@@ -2387,6 +2385,7 @@ struct qla_hw_data {
 #define IS_QLA81XX(ha)         (IS_QLA8001(ha))
 #define IS_QLA2XXX_MIDTYPE(ha) (IS_QLA24XX(ha) || IS_QLA84XX(ha) || \
                                IS_QLA25XX(ha) || IS_QLA81XX(ha))
+#define IS_MSIX_NACK_CAPABLE(ha) (IS_QLA81XX(ha))
 #define IS_NOPOLLING_TYPE(ha)  ((IS_QLA25XX(ha) || IS_QLA81XX(ha)) && \
                                (ha)->flags.msix_enabled)
 #define IS_FAC_REQUIRED(ha)    (IS_QLA81XX(ha))
index e21851358509b1cdb6194eb53b7ae674a53731d4..0b6801fc6389dcce0a07720db60b423275e2a1ee 100644 (file)
@@ -72,8 +72,6 @@ extern int ql2xloginretrycount;
 extern int ql2xfdmienable;
 extern int ql2xallocfwdump;
 extern int ql2xextended_error_logging;
-extern int ql2xqfullrampup;
-extern int ql2xqfulltracking;
 extern int ql2xiidmaenable;
 extern int ql2xmaxqueues;
 extern int ql2xmultique_tag;
index b74924b279ef2854cfc09e238cff4f5cfc950820..73a793539d4512ba0ac7a5921a6cd0783ffd4308 100644 (file)
@@ -1442,7 +1442,17 @@ qla24xx_config_rings(struct scsi_qla_host *vha)
                        icb->firmware_options_2 |=
                                __constant_cpu_to_le32(BIT_18);
 
-               icb->firmware_options_2 &= __constant_cpu_to_le32(~BIT_22);
+               /* Use Disable MSIX Handshake mode for capable adapters */
+               if (IS_MSIX_NACK_CAPABLE(ha)) {
+                       icb->firmware_options_2 &=
+                               __constant_cpu_to_le32(~BIT_22);
+                       ha->flags.disable_msix_handshake = 1;
+                       qla_printk(KERN_INFO, ha,
+                               "MSIX Handshake Disable Mode turned on\n");
+               } else {
+                       icb->firmware_options_2 |=
+                               __constant_cpu_to_le32(BIT_22);
+               }
                icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_23);
 
                WRT_REG_DWORD(&reg->isp25mq.req_q_in, 0);
index 804987397b774265eff4a69aea3a4a3ed9a103b5..1692a883f4de837b7cd386bd6ea02e4de4c278ef 100644 (file)
@@ -811,78 +811,6 @@ skip_rio:
                qla2x00_alert_all_vps(rsp, mb);
 }
 
-static void
-qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, void *data)
-{
-       fc_port_t *fcport = data;
-       struct scsi_qla_host *vha = fcport->vha;
-       struct qla_hw_data *ha = vha->hw;
-       struct req_que *req = NULL;
-
-       if (!ql2xqfulltracking)
-               return;
-
-       req = vha->req;
-       if (!req)
-               return;
-       if (req->max_q_depth <= sdev->queue_depth)
-               return;
-
-       if (sdev->ordered_tags)
-               scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG,
-                   sdev->queue_depth + 1);
-       else
-               scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG,
-                   sdev->queue_depth + 1);
-
-       fcport->last_ramp_up = jiffies;
-
-       DEBUG2(qla_printk(KERN_INFO, ha,
-           "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
-           fcport->vha->host_no, sdev->channel, sdev->id, sdev->lun,
-           sdev->queue_depth));
-}
-
-static void
-qla2x00_adjust_sdev_qdepth_down(struct scsi_device *sdev, void *data)
-{
-       fc_port_t *fcport = data;
-
-       if (!scsi_track_queue_full(sdev, sdev->queue_depth - 1))
-               return;
-
-       DEBUG2(qla_printk(KERN_INFO, fcport->vha->hw,
-           "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
-           fcport->vha->host_no, sdev->channel, sdev->id, sdev->lun,
-           sdev->queue_depth));
-}
-
-static inline void
-qla2x00_ramp_up_queue_depth(scsi_qla_host_t *vha, struct req_que *req,
-                                                               srb_t *sp)
-{
-       fc_port_t *fcport;
-       struct scsi_device *sdev;
-
-       if (!ql2xqfulltracking)
-               return;
-
-       sdev = sp->cmd->device;
-       if (sdev->queue_depth >= req->max_q_depth)
-               return;
-
-       fcport = sp->fcport;
-       if (time_before(jiffies,
-           fcport->last_ramp_up + ql2xqfullrampup * HZ))
-               return;
-       if (time_before(jiffies,
-           fcport->last_queue_full + ql2xqfullrampup * HZ))
-               return;
-
-       starget_for_each_device(sdev->sdev_target, fcport,
-           qla2x00_adjust_sdev_qdepth_up);
-}
-
 /**
  * qla2x00_process_completed_request() - Process a Fast Post response.
  * @ha: SCSI driver HA context
@@ -913,8 +841,6 @@ qla2x00_process_completed_request(struct scsi_qla_host *vha,
 
                /* Save ISP completion status */
                sp->cmd->result = DID_OK << 16;
-
-               qla2x00_ramp_up_queue_depth(vha, req, sp);
                qla2x00_sp_compl(ha, sp);
        } else {
                DEBUG2(printk("scsi(%ld) Req:%d: Invalid ISP SCSI completion"
@@ -1435,13 +1361,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
                            "scsi(%ld): QUEUE FULL status detected "
                            "0x%x-0x%x.\n", vha->host_no, comp_status,
                            scsi_status));
-
-                       /* Adjust queue depth for all luns on the port. */
-                       if (!ql2xqfulltracking)
-                               break;
-                       fcport->last_queue_full = jiffies;
-                       starget_for_each_device(cp->device->sdev_target,
-                           fcport, qla2x00_adjust_sdev_qdepth_down);
                        break;
                }
                if (lscsi_status != SS_CHECK_CONDITION)
@@ -1516,17 +1435,6 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
                                    "scsi(%ld): QUEUE FULL status detected "
                                    "0x%x-0x%x.\n", vha->host_no, comp_status,
                                    scsi_status));
-
-                               /*
-                                * Adjust queue depth for all luns on the
-                                * port.
-                                */
-                               if (!ql2xqfulltracking)
-                                       break;
-                               fcport->last_queue_full = jiffies;
-                               starget_for_each_device(
-                                   cp->device->sdev_target, fcport,
-                                   qla2x00_adjust_sdev_qdepth_down);
                                break;
                        }
                        if (lscsi_status != SS_CHECK_CONDITION)
@@ -2020,7 +1928,7 @@ qla24xx_msix_rsp_q(int irq, void *dev_id)
 
        vha = qla25xx_get_host(rsp);
        qla24xx_process_response_queue(vha, rsp);
-       if (!ha->mqenable) {
+       if (!ha->flags.disable_msix_handshake) {
                WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
                RD_REG_DWORD_RELAXED(&reg->hccr);
        }
@@ -2034,6 +1942,7 @@ qla25xx_msix_rsp_q(int irq, void *dev_id)
 {
        struct qla_hw_data *ha;
        struct rsp_que *rsp;
+       struct device_reg_24xx __iomem *reg;
 
        rsp = (struct rsp_que *) dev_id;
        if (!rsp) {
@@ -2043,6 +1952,14 @@ qla25xx_msix_rsp_q(int irq, void *dev_id)
        }
        ha = rsp->hw;
 
+       /* Clear the interrupt, if enabled, for this response queue */
+       if (rsp->options & ~BIT_6) {
+               reg = &ha->iobase->isp24;
+               spin_lock_irq(&ha->hardware_lock);
+               WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
+               RD_REG_DWORD_RELAXED(&reg->hccr);
+               spin_unlock_irq(&ha->hardware_lock);
+       }
        queue_work_on((int) (rsp->id - 1), ha->wq, &rsp->q_work);
 
        return IRQ_HANDLED;
index a47d34308a3a0fa050ec343085cef8d7d5ec7783..2a4c7f4e7b69b0a4fcaf13cf044044c60639a3f6 100644 (file)
@@ -696,6 +696,10 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options,
        /* Use alternate PCI devfn */
        if (LSB(rsp->rid))
                options |= BIT_5;
+       /* Enable MSIX handshake mode on for uncapable adapters */
+       if (!IS_MSIX_NACK_CAPABLE(ha))
+               options |= BIT_6;
+
        rsp->options = options;
        rsp->id = que_id;
        reg = ISP_QUE_REG(ha, que_id);
index 41669357b186f482524de9b6af3b1831b1040dfb..2f873d23732584e334be93a64e6ae6e2ba204744 100644 (file)
@@ -78,21 +78,6 @@ module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(ql2xmaxqdepth,
                "Maximum queue depth to report for target devices.");
 
-int ql2xqfulltracking = 1;
-module_param(ql2xqfulltracking, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(ql2xqfulltracking,
-               "Controls whether the driver tracks queue full status "
-               "returns and dynamically adjusts a scsi device's queue "
-               "depth.  Default is 1, perform tracking.  Set to 0 to "
-               "disable dynamic tracking and adjustment of queue depth.");
-
-int ql2xqfullrampup = 120;
-module_param(ql2xqfullrampup, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(ql2xqfullrampup,
-               "Number of seconds to wait to begin to ramp-up the queue "
-               "depth for a device after a queue-full condition has been "
-               "detected.  Default is 120 seconds.");
-
 int ql2xiidmaenable=1;
 module_param(ql2xiidmaenable, int, S_IRUGO|S_IRUSR);
 MODULE_PARM_DESC(ql2xiidmaenable,
@@ -1217,13 +1202,61 @@ qla2xxx_slave_destroy(struct scsi_device *sdev)
        sdev->hostdata = NULL;
 }
 
+static void qla2x00_handle_queue_full(struct scsi_device *sdev, int qdepth)
+{
+       fc_port_t *fcport = (struct fc_port *) sdev->hostdata;
+
+       if (!scsi_track_queue_full(sdev, qdepth))
+               return;
+
+       DEBUG2(qla_printk(KERN_INFO, fcport->vha->hw,
+               "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
+               fcport->vha->host_no, sdev->channel, sdev->id, sdev->lun,
+               sdev->queue_depth));
+}
+
+static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth)
+{
+       fc_port_t *fcport = sdev->hostdata;
+       struct scsi_qla_host *vha = fcport->vha;
+       struct qla_hw_data *ha = vha->hw;
+       struct req_que *req = NULL;
+
+       req = vha->req;
+       if (!req)
+               return;
+
+       if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth)
+               return;
+
+       if (sdev->ordered_tags)
+               scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, qdepth);
+       else
+               scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth);
+
+       DEBUG2(qla_printk(KERN_INFO, ha,
+              "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
+              fcport->vha->host_no, sdev->channel, sdev->id, sdev->lun,
+              sdev->queue_depth));
+}
+
 static int
 qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
 {
-       if (reason != SCSI_QDEPTH_DEFAULT)
-               return -EOPNOTSUPP;
+       switch (reason) {
+       case SCSI_QDEPTH_DEFAULT:
+               scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
+               break;
+       case SCSI_QDEPTH_QFULL:
+               qla2x00_handle_queue_full(sdev, qdepth);
+               break;
+       case SCSI_QDEPTH_RAMP_UP:
+               qla2x00_adjust_sdev_qdepth_up(sdev, qdepth);
+               break;
+       default:
+               return EOPNOTSUPP;
+       }
 
-       scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
        return sdev->queue_depth;
 }
 
@@ -2003,13 +2036,13 @@ skip_dpc:
        DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
            base_vha->host_no, ha));
 
-       base_vha->flags.init_done = 1;
-       base_vha->flags.online = 1;
-
        ret = scsi_add_host(host, &pdev->dev);
        if (ret)
                goto probe_failed;
 
+       base_vha->flags.init_done = 1;
+       base_vha->flags.online = 1;
+
        ha->isp_ops->enable_intrs(ha);
 
        scsi_scan_host(host);
index 807e0dbc67fa236a6b1f09906e8ba957327fff8c..c482220f7eed4fc0530ef41c4ea9c524597b4059 100644 (file)
@@ -7,7 +7,7 @@
 /*
  * Driver version
  */
-#define QLA2XXX_VERSION      "8.03.01-k7"
+#define QLA2XXX_VERSION      "8.03.01-k8"
 
 #define QLA_DRIVER_MAJOR_VER   8
 #define QLA_DRIVER_MINOR_VER   3
index e495d3813948900bed56c497ba1649c73be889d3..d8927681ec8837c5c227712688324473e2c729b6 100644 (file)
@@ -859,6 +859,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
                                case 0x07: /* operation in progress */
                                case 0x08: /* Long write in progress */
                                case 0x09: /* self test in progress */
+                               case 0x14: /* space allocation in progress */
                                        action = ACTION_DELAYED_RETRY;
                                        break;
                                default:
index 6531c91501be4beae3d9a8e60cff08b26617bd2a..ddfcecd5099f5688d1ec7667d050eb1671e78267 100644 (file)
@@ -649,11 +649,22 @@ static __init int fc_transport_init(void)
                return error;
        error = transport_class_register(&fc_vport_class);
        if (error)
-               return error;
+               goto unreg_host_class;
        error = transport_class_register(&fc_rport_class);
        if (error)
-               return error;
-       return transport_class_register(&fc_transport_class);
+               goto unreg_vport_class;
+       error = transport_class_register(&fc_transport_class);
+       if (error)
+               goto unreg_rport_class;
+       return 0;
+
+unreg_rport_class:
+       transport_class_unregister(&fc_rport_class);
+unreg_vport_class:
+       transport_class_unregister(&fc_vport_class);
+unreg_host_class:
+       transport_class_unregister(&fc_host_class);
+       return error;
 }
 
 static void __exit fc_transport_exit(void)
index 9093c7261f330085bf4ba843b18b8e53ad4270cd..255da53e5a01a1dd970fac95b2106888b6e91c6b 100644 (file)
@@ -264,6 +264,15 @@ sd_show_app_tag_own(struct device *dev, struct device_attribute *attr,
        return snprintf(buf, 20, "%u\n", sdkp->ATO);
 }
 
+static ssize_t
+sd_show_thin_provisioning(struct device *dev, struct device_attribute *attr,
+                         char *buf)
+{
+       struct scsi_disk *sdkp = to_scsi_disk(dev);
+
+       return snprintf(buf, 20, "%u\n", sdkp->thin_provisioning);
+}
+
 static struct device_attribute sd_disk_attrs[] = {
        __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type,
               sd_store_cache_type),
@@ -274,6 +283,7 @@ static struct device_attribute sd_disk_attrs[] = {
               sd_store_manage_start_stop),
        __ATTR(protection_type, S_IRUGO, sd_show_protection_type, NULL),
        __ATTR(app_tag_own, S_IRUGO, sd_show_app_tag_own, NULL),
+       __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL),
        __ATTR_NULL,
 };
 
@@ -398,6 +408,57 @@ static void sd_prot_op(struct scsi_cmnd *scmd, unsigned int dif)
        scsi_set_prot_type(scmd, dif);
 }
 
+/**
+ * sd_prepare_discard - unmap blocks on thinly provisioned device
+ * @rq: Request to prepare
+ *
+ * Will issue either UNMAP or WRITE SAME(16) depending on preference
+ * indicated by target device.
+ **/
+static int sd_prepare_discard(struct request *rq)
+{
+       struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
+       struct bio *bio = rq->bio;
+       sector_t sector = bio->bi_sector;
+       unsigned int num = bio_sectors(bio);
+
+       if (sdkp->device->sector_size == 4096) {
+               sector >>= 3;
+               num >>= 3;
+       }
+
+       rq->cmd_type = REQ_TYPE_BLOCK_PC;
+       rq->timeout = SD_TIMEOUT;
+
+       memset(rq->cmd, 0, rq->cmd_len);
+
+       if (sdkp->unmap) {
+               char *buf = kmap_atomic(bio_page(bio), KM_USER0);
+
+               rq->cmd[0] = UNMAP;
+               rq->cmd[8] = 24;
+               rq->cmd_len = 10;
+
+               /* Ensure that data length matches payload */
+               rq->__data_len = bio->bi_size = bio->bi_io_vec->bv_len = 24;
+
+               put_unaligned_be16(6 + 16, &buf[0]);
+               put_unaligned_be16(16, &buf[2]);
+               put_unaligned_be64(sector, &buf[8]);
+               put_unaligned_be32(num, &buf[16]);
+
+               kunmap_atomic(buf, KM_USER0);
+       } else {
+               rq->cmd[0] = WRITE_SAME_16;
+               rq->cmd[1] = 0x8; /* UNMAP */
+               put_unaligned_be64(sector, &rq->cmd[2]);
+               put_unaligned_be32(num, &rq->cmd[10]);
+               rq->cmd_len = 16;
+       }
+
+       return BLKPREP_OK;
+}
+
 /**
  *     sd_init_command - build a scsi (read or write) command from
  *     information in the request structure.
@@ -418,6 +479,13 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
        int ret, host_dif;
        unsigned char protect;
 
+       /*
+        * Discard request come in as REQ_TYPE_FS but we turn them into
+        * block PC requests to make life easier.
+        */
+       if (blk_discard_rq(rq))
+               ret = sd_prepare_discard(rq);
+
        if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
                ret = scsi_setup_blk_pc_cmnd(sdp, rq);
                goto out;
@@ -1432,6 +1500,19 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
                sd_printk(KERN_NOTICE, sdkp,
                          "physical block alignment offset: %u\n", alignment);
 
+       if (buffer[14] & 0x80) { /* TPE */
+               struct request_queue *q = sdp->request_queue;
+
+               sdkp->thin_provisioning = 1;
+               q->limits.discard_granularity = sdkp->hw_sector_size;
+               q->limits.max_discard_sectors = 0xffffffff;
+
+               if (buffer[14] & 0x40) /* TPRZ */
+                       q->limits.discard_zeroes_data = 1;
+
+               queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
+       }
+
        sdkp->capacity = lba + 1;
        return sector_size;
 }
@@ -1863,6 +1944,7 @@ void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer)
  */
 static void sd_read_block_limits(struct scsi_disk *sdkp)
 {
+       struct request_queue *q = sdkp->disk->queue;
        unsigned int sector_sz = sdkp->device->sector_size;
        char *buffer;
 
@@ -1877,6 +1959,31 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
        blk_queue_io_opt(sdkp->disk->queue,
                         get_unaligned_be32(&buffer[12]) * sector_sz);
 
+       /* Thin provisioning enabled and page length indicates TP support */
+       if (sdkp->thin_provisioning && buffer[3] == 0x3c) {
+               unsigned int lba_count, desc_count, granularity;
+
+               lba_count = get_unaligned_be32(&buffer[20]);
+               desc_count = get_unaligned_be32(&buffer[24]);
+
+               if (lba_count) {
+                       q->limits.max_discard_sectors =
+                               lba_count * sector_sz >> 9;
+
+                       if (desc_count)
+                               sdkp->unmap = 1;
+               }
+
+               granularity = get_unaligned_be32(&buffer[28]);
+
+               if (granularity)
+                       q->limits.discard_granularity = granularity * sector_sz;
+
+               if (buffer[32] & 0x80)
+                       q->limits.discard_alignment =
+                               get_unaligned_be32(&buffer[32]) & ~(1 << 31);
+       }
+
        kfree(buffer);
 }
 
index e374804d26fbdb11cf17987b35c1db73386568ee..43d3caf268efb50a00783b647caa1b25b1e7fe56 100644 (file)
@@ -60,6 +60,8 @@ struct scsi_disk {
        unsigned        RCD : 1;        /* state of disk RCD bit, unused */
        unsigned        DPOFUA : 1;     /* state of disk DPOFUA bit */
        unsigned        first_scan : 1;
+       unsigned        thin_provisioning : 1;
+       unsigned        unmap : 1;
 };
 #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
 
index ad59abb4772234cb2ef6eb6dbc2ee8882b49af09..d04ea9a6f6732b27526d748ba5b2524e6ebb7c23 100644 (file)
@@ -552,13 +552,15 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd
        SRpnt->waiting = waiting;
 
        if (STp->buffer->do_dio) {
+               mdata->page_order = 0;
                mdata->nr_entries = STp->buffer->sg_segs;
                mdata->pages = STp->buffer->mapped_pages;
        } else {
+               mdata->page_order = STp->buffer->reserved_page_order;
                mdata->nr_entries =
                        DIV_ROUND_UP(bytes, PAGE_SIZE << mdata->page_order);
-               STp->buffer->map_data.pages = STp->buffer->reserved_pages;
-               STp->buffer->map_data.offset = 0;
+               mdata->pages = STp->buffer->reserved_pages;
+               mdata->offset = 0;
        }
 
        memcpy(SRpnt->cmd, cmd, sizeof(SRpnt->cmd));
@@ -3719,7 +3721,7 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm
                priority |= __GFP_ZERO;
 
        if (STbuffer->frp_segs) {
-               order = STbuffer->map_data.page_order;
+               order = STbuffer->reserved_page_order;
                b_size = PAGE_SIZE << order;
        } else {
                for (b_size = PAGE_SIZE, order = 0;
@@ -3752,7 +3754,7 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm
                segs++;
        }
        STbuffer->b_data = page_address(STbuffer->reserved_pages[0]);
-       STbuffer->map_data.page_order = order;
+       STbuffer->reserved_page_order = order;
 
        return 1;
 }
@@ -3765,7 +3767,7 @@ static void clear_buffer(struct st_buffer * st_bp)
 
        for (i=0; i < st_bp->frp_segs; i++)
                memset(page_address(st_bp->reserved_pages[i]), 0,
-                      PAGE_SIZE << st_bp->map_data.page_order);
+                      PAGE_SIZE << st_bp->reserved_page_order);
        st_bp->cleared = 1;
 }
 
@@ -3773,7 +3775,7 @@ static void clear_buffer(struct st_buffer * st_bp)
 /* Release the extra buffer */
 static void normalize_buffer(struct st_buffer * STbuffer)
 {
-       int i, order = STbuffer->map_data.page_order;
+       int i, order = STbuffer->reserved_page_order;
 
        for (i = 0; i < STbuffer->frp_segs; i++) {
                __free_pages(STbuffer->reserved_pages[i], order);
@@ -3781,7 +3783,7 @@ static void normalize_buffer(struct st_buffer * STbuffer)
        }
        STbuffer->frp_segs = 0;
        STbuffer->sg_segs = 0;
-       STbuffer->map_data.page_order = 0;
+       STbuffer->reserved_page_order = 0;
        STbuffer->map_data.offset = 0;
 }
 
@@ -3791,7 +3793,7 @@ static void normalize_buffer(struct st_buffer * STbuffer)
 static int append_to_buffer(const char __user *ubp, struct st_buffer * st_bp, int do_count)
 {
        int i, cnt, res, offset;
-       int length = PAGE_SIZE << st_bp->map_data.page_order;
+       int length = PAGE_SIZE << st_bp->reserved_page_order;
 
        for (i = 0, offset = st_bp->buffer_bytes;
             i < st_bp->frp_segs && offset >= length; i++)
@@ -3823,7 +3825,7 @@ static int append_to_buffer(const char __user *ubp, struct st_buffer * st_bp, in
 static int from_buffer(struct st_buffer * st_bp, char __user *ubp, int do_count)
 {
        int i, cnt, res, offset;
-       int length = PAGE_SIZE << st_bp->map_data.page_order;
+       int length = PAGE_SIZE << st_bp->reserved_page_order;
 
        for (i = 0, offset = st_bp->read_pointer;
             i < st_bp->frp_segs && offset >= length; i++)
@@ -3856,7 +3858,7 @@ static void move_buffer_data(struct st_buffer * st_bp, int offset)
 {
        int src_seg, dst_seg, src_offset = 0, dst_offset;
        int count, total;
-       int length = PAGE_SIZE << st_bp->map_data.page_order;
+       int length = PAGE_SIZE << st_bp->reserved_page_order;
 
        if (offset == 0)
                return;
@@ -4578,7 +4580,6 @@ static int sgl_map_user_pages(struct st_buffer *STbp,
         }
 
        mdata->offset = uaddr & ~PAGE_MASK;
-       mdata->page_order = 0;
        STbp->mapped_pages = pages;
 
        return nr_pages;
index 544dc6b1f54808516ce2890356c49536ea956d30..f91a67c6d9686c07646538e3dbd5745a6ca7fefe 100644 (file)
@@ -46,6 +46,7 @@ struct st_buffer {
        struct st_request *last_SRpnt;
        struct st_cmdstatus cmdstat;
        struct page **reserved_pages;
+       int reserved_page_order;
        struct page **mapped_pages;
        struct rq_map_data map_data;
        unsigned char *b_data;
index 2b38f6ad6e11153f8e7133d633c18e9ed7d7bc8e..8b955b534a36f7ce836967b49978b2deb7bd8d64 100644 (file)
@@ -984,7 +984,7 @@ static void sym_exec_user_command (struct sym_hcb *np, struct sym_usrcmd *uc)
        }
 }
 
-static int skip_spaces(char *ptr, int len)
+static int sym_skip_spaces(char *ptr, int len)
 {
        int cnt, c;
 
@@ -1012,7 +1012,7 @@ static int is_keyword(char *ptr, int len, char *verb)
 }
 
 #define SKIP_SPACES(ptr, len)                                          \
-       if ((arg_len = skip_spaces(ptr, len)) < 1)                      \
+       if ((arg_len = sym_skip_spaces(ptr, len)) < 1)                  \
                return -EINVAL;                                         \
        ptr += arg_len; len -= arg_len;
 
index d8983dd5c4b22e82e0355f8af1bb53671e561d31..85dc0410ac1a8d3f2bed7a08f8078f23b4de57cd 100644 (file)
@@ -2162,7 +2162,7 @@ static struct ioc3_submodule ioc3uart_ops = {
 /**
  * ioc3_detect - module init called,
  */
-static int __devinit ioc3uart_init(void)
+static int __init ioc3uart_init(void)
 {
        int ret;
 
@@ -2179,7 +2179,7 @@ static int __devinit ioc3uart_init(void)
        return ret;
 }
 
-static void __devexit ioc3uart_exit(void)
+static void __exit ioc3uart_exit(void)
 {
        ioc3_unregister_submodule(&ioc3uart_ops);
        uart_unregister_driver(&ioc3_uart);
index 2e02c3026d24f464ebca356d548ffed7e2e9b189..836d9ab4f729669ac11f941a3b3e246b367fdcb3 100644 (file)
@@ -2904,7 +2904,7 @@ static struct ioc4_submodule ioc4_serial_submodule = {
 /**
  * ioc4_serial_init - module init
  */
-int ioc4_serial_init(void)
+static int __init ioc4_serial_init(void)
 {
        int ret;
 
@@ -2913,20 +2913,30 @@ int ioc4_serial_init(void)
                printk(KERN_WARNING
                        "%s: Couldn't register rs232 IOC4 serial driver\n",
                        __func__);
-               return ret;
+               goto out;
        }
        if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) {
                printk(KERN_WARNING
                        "%s: Couldn't register rs422 IOC4 serial driver\n",
                        __func__);
-               return ret;
+               goto out_uart_rs232;
        }
 
        /* register with IOC4 main module */
-       return ioc4_register_submodule(&ioc4_serial_submodule);
+       ret = ioc4_register_submodule(&ioc4_serial_submodule);
+       if (ret)
+               goto out_uart_rs422;
+       return 0;
+
+out_uart_rs422:
+       uart_unregister_driver(&ioc4_uart_rs422);
+out_uart_rs232:
+       uart_unregister_driver(&ioc4_uart_rs232);
+out:
+       return ret;
 }
 
-static void __devexit ioc4_serial_exit(void)
+static void __exit ioc4_serial_exit(void)
 {
        ioc4_unregister_submodule(&ioc4_serial_submodule);
        uart_unregister_driver(&ioc4_uart_rs232);
index 4a821046baae0124e6bb9a36824979d49e69952e..56ee082157aaf121c755fd3a42ef4005e9667f14 100644 (file)
@@ -756,7 +756,7 @@ static int serial_pxa_resume(struct device *dev)
         return 0;
 }
 
-static struct dev_pm_ops serial_pxa_pm_ops = {
+static const struct dev_pm_ops serial_pxa_pm_ops = {
        .suspend        = serial_pxa_suspend,
        .resume         = serial_pxa_resume,
 };
index ff38dbdb5c6ecf7686371dad4a4e909eae9c52d3..37f0de9dd9ce555caff819a93b97148db4d61798 100644 (file)
@@ -222,9 +222,9 @@ static inline void sci_init_pins(struct uart_port *port, unsigned int cflag)
                   Set SCP6MD1,0 = {01} (output)  */
                __raw_writew((data & 0x0fcf) | 0x1000, SCPCR);
 
-               data = ctrl_inb(SCPDR);
+               data = __raw_readb(SCPDR);
                /* Set /RTS2 (bit6) = 0 */
-               ctrl_outb(data & 0xbf, SCPDR);
+               __raw_writeb(data & 0xbf, SCPDR);
        }
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7722)
@@ -897,11 +897,21 @@ static void sci_shutdown(struct uart_port *port)
 static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
                            struct ktermios *old)
 {
-       unsigned int status, baud, smr_val;
+       unsigned int status, baud, smr_val, max_baud;
        int t = -1;
 
-       baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
-       if (likely(baud))
+       /*
+        * earlyprintk comes here early on with port->uartclk set to zero.
+        * the clock framework is not up and running at this point so here
+        * we assume that 115200 is the maximum baud rate. please note that
+        * the baud rate is not programmed during earlyprintk - it is assumed
+        * that the previous boot loader has enabled required clocks and
+        * setup the baud rate generator hardware for us already.
+        */
+       max_baud = port->uartclk ? port->uartclk / 16 : 115200;
+
+       baud = uart_get_baud_rate(port, termios, old, 0, max_baud);
+       if (likely(baud && port->uartclk))
                t = SCBRR_VALUE(baud, port->uartclk);
 
        do {
@@ -1043,10 +1053,14 @@ static void __devinit sci_init_single(struct platform_device *dev,
        sci_port->port.iotype   = UPIO_MEM;
        sci_port->port.line     = index;
        sci_port->port.fifosize = 1;
-       sci_port->iclk          = p->clk ? clk_get(&dev->dev, p->clk) : NULL;
-       sci_port->dclk          = clk_get(&dev->dev, "peripheral_clk");
-       sci_port->enable        = sci_clk_enable;
-       sci_port->disable       = sci_clk_disable;
+
+       if (dev) {
+               sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL;
+               sci_port->dclk = clk_get(&dev->dev, "peripheral_clk");
+               sci_port->enable = sci_clk_enable;
+               sci_port->disable = sci_clk_disable;
+               sci_port->port.dev = &dev->dev;
+       }
 
        sci_port->break_timer.data = (unsigned long)sci_port;
        sci_port->break_timer.function = sci_break_timer;
@@ -1057,7 +1071,6 @@ static void __devinit sci_init_single(struct platform_device *dev,
 
        sci_port->port.irq      = p->irqs[SCIx_TXI_IRQ];
        sci_port->port.flags    = p->flags;
-       sci_port->port.dev      = &dev->dev;
        sci_port->type          = sci_port->port.type = p->type;
 
        memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs));
@@ -1101,7 +1114,7 @@ static void serial_console_write(struct console *co, const char *s,
                sci_port->disable(port);
 }
 
-static int __init serial_console_setup(struct console *co, char *options)
+static int __devinit serial_console_setup(struct console *co, char *options)
 {
        struct sci_port *sci_port;
        struct uart_port *port;
@@ -1119,9 +1132,14 @@ static int __init serial_console_setup(struct console *co, char *options)
        if (co->index >= SCI_NPORTS)
                co->index = 0;
 
-       sci_port = &sci_ports[co->index];
-       port = &sci_port->port;
-       co->data = port;
+       if (co->data) {
+               port = co->data;
+               sci_port = to_sci_port(port);
+       } else {
+               sci_port = &sci_ports[co->index];
+               port = &sci_port->port;
+               co->data = port;
+       }
 
        /*
         * Also need to check port->type, we don't actually have any
@@ -1165,6 +1183,15 @@ static int __init sci_console_init(void)
        return 0;
 }
 console_initcall(sci_console_init);
+
+static struct sci_port early_serial_port;
+static struct console early_serial_console = {
+       .name           = "early_ttySC",
+       .write          = serial_console_write,
+       .flags          = CON_PRINTBUFFER,
+};
+static char early_serial_buf[32];
+
 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
 
 #if defined(CONFIG_SERIAL_SH_SCI_CONSOLE)
@@ -1250,6 +1277,21 @@ static int __devinit sci_probe(struct platform_device *dev)
        struct sh_sci_priv *priv;
        int i, ret = -EINVAL;
 
+#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
+       if (is_early_platform_device(dev)) {
+               if (dev->id == -1)
+                       return -ENOTSUPP;
+               early_serial_console.index = dev->id;
+               early_serial_console.data = &early_serial_port.port;
+               sci_init_single(NULL, &early_serial_port, dev->id, p);
+               serial_console_setup(&early_serial_console, early_serial_buf);
+               if (!strstr(early_serial_buf, "keep"))
+                       early_serial_console.flags |= CON_BOOT;
+               register_console(&early_serial_console);
+               return 0;
+       }
+#endif
+
        priv = kzalloc(sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
@@ -1312,7 +1354,7 @@ static int sci_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops sci_dev_pm_ops = {
+static const struct dev_pm_ops sci_dev_pm_ops = {
        .suspend        = sci_suspend,
        .resume         = sci_resume,
 };
@@ -1349,6 +1391,10 @@ static void __exit sci_exit(void)
        uart_unregister_driver(&sci_uart_driver);
 }
 
+#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
+early_platform_init_buffer("earlyprintk", &sci_driver,
+                          early_serial_buf, ARRAY_SIZE(early_serial_buf));
+#endif
 module_init(sci_init);
 module_exit(sci_exit);
 
index a32094eeb42bbdf009d256ec50f2b55d78b4c349..0efcded59ae613bdf1dd8aa906599bff9e5904f8 100644 (file)
@@ -517,20 +517,20 @@ static const struct __attribute__((packed)) {
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xfffffe80)
-               return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCI */
+               return __raw_readb(SCPDR)&0x01 ? 1 : 0; /* SCI */
        if (port->mapbase == 0xa4000150)
-               return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
+               return __raw_readb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xa4000140)
-               return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
+               return __raw_readb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7705)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == SCIF0)
-               return ctrl_inb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
+               return __raw_readb(SCPDR)&0x04 ? 1 : 0; /* IRDA */
        if (port->mapbase == SCIF2)
-               return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
+               return __raw_readb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
@@ -557,68 +557,68 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffe00000)
-               return ctrl_inb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
+               return __raw_readb(SCSPTR1)&0x01 ? 1 : 0; /* SCI */
        if (port->mapbase == 0xffe80000)
-               return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffe80000)
-               return ctrl_inw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2)&0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7757)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xfe4b0000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0;
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0;
        if (port->mapbase == 0xfe4c0000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0;
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0;
        if (port->mapbase == 0xfe4d0000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0;
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7760)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xfe600000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xfe610000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xfe620000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7343)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffe00000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffe10000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffe20000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffe30000)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7366)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffe00000)
-               return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */
+               return __raw_readb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7722)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffe00000)
-               return ctrl_inb(PSDR) & 0x02 ? 1 : 0; /* SCIF0 */
+               return __raw_readb(PSDR) & 0x02 ? 1 : 0; /* SCIF0 */
        if (port->mapbase == 0xffe10000)
-               return ctrl_inb(PADR) & 0x40 ? 1 : 0; /* SCIF1 */
+               return __raw_readb(PADR) & 0x40 ? 1 : 0; /* SCIF1 */
        if (port->mapbase == 0xffe20000)
-               return ctrl_inb(PWDR) & 0x04 ? 1 : 0; /* SCIF2 */
+               return __raw_readb(PWDR) & 0x04 ? 1 : 0; /* SCIF2 */
 
        return 1;
 }
@@ -626,17 +626,17 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
         if (port->mapbase == 0xffe00000)
-                return ctrl_inb(SCSPTR0) & 0x0008 ? 1 : 0; /* SCIF0 */
+                return __raw_readb(SCSPTR0) & 0x0008 ? 1 : 0; /* SCIF0 */
         if (port->mapbase == 0xffe10000)
-                return ctrl_inb(SCSPTR1) & 0x0020 ? 1 : 0; /* SCIF1 */
+                return __raw_readb(SCSPTR1) & 0x0020 ? 1 : 0; /* SCIF1 */
         if (port->mapbase == 0xffe20000)
-                return ctrl_inb(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF2 */
+                return __raw_readb(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF2 */
         if (port->mapbase == 0xa4e30000)
-                return ctrl_inb(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF3 */
+                return __raw_readb(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF3 */
         if (port->mapbase == 0xa4e40000)
-                return ctrl_inb(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF4 */
+                return __raw_readb(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF4 */
         if (port->mapbase == 0xa4e50000)
-                return ctrl_inb(SCSPTR5) & 0x0008 ? 1 : 0; /* SCIF5 */
+                return __raw_readb(SCSPTR5) & 0x0008 ? 1 : 0; /* SCIF5 */
         return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7724)
@@ -645,9 +645,9 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->type == PORT_SCIF)
-               return ctrl_inw((port->mapbase + SCFSR))  & SCIF_BRK ? 1 : 0;
+               return __raw_readw((port->mapbase + SCFSR))  & SCIF_BRK ? 1 : 0;
        if (port->type == PORT_SCIFA)
-               return ctrl_inw((port->mapbase + SCASSR)) & SCIF_BRK ? 1 : 0;
+               return __raw_readw((port->mapbase + SCASSR)) & SCIF_BRK ? 1 : 0;
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
@@ -665,11 +665,11 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffe00000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffe08000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffe10000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF/IRDA */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF/IRDA */
 
        return 1;
 }
@@ -677,20 +677,20 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xff923000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xff924000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xff925000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7780)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffe00000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffe10000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7785) || \
@@ -698,17 +698,17 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffea0000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffeb0000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffec0000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffed0000)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffee0000)
-               return ctrl_inw(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR4) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffef0000)
-               return ctrl_inw(SCSPTR5) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR5) & 0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SH7201) || \
@@ -718,22 +718,22 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xfffe8000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xfffe8800)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xfffe9000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xfffe9800)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
 #if defined(CONFIG_CPU_SUBTYPE_SH7201)
        if (port->mapbase == 0xfffeA000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xfffeA800)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xfffeB000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xfffeB800)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
 #endif
        return 1;
 }
@@ -741,24 +741,24 @@ static inline int sci_rxd_in(struct uart_port *port)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xf8400000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xf8410000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xf8420000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #elif defined(CONFIG_CPU_SUBTYPE_SHX3)
 static inline int sci_rxd_in(struct uart_port *port)
 {
        if (port->mapbase == 0xffc30000)
-               return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffc40000)
-               return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffc50000)
-               return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
        if (port->mapbase == 0xffc60000)
-               return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
+               return __raw_readw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
        return 1;
 }
 #endif
index a7e5c2e9986c0c700cf76f154f5c3c907914166d..d5d7f23c19a5e5bdc399670994c324bb3e08dbff 100644 (file)
@@ -806,6 +806,8 @@ static int intc_suspend(struct sys_device *dev, pm_message_t state)
                if (d->state.event != PM_EVENT_FREEZE)
                        break;
                for_each_irq_desc(irq, desc) {
+                       if (desc->handle_irq == intc_redirect_irq)
+                               continue;
                        if (desc->chip != &d->chip)
                                continue;
                        if (desc->status & IRQ_DISABLED)
index 841ed5030c8f82f15d22ff0b74fff26cd903f244..082604edc4c2943d16678411498f33ddff560e46 100644 (file)
@@ -71,7 +71,7 @@ static void gpio_write_bit(struct pinmux_data_reg *dr,
 
        pos = dr->reg_width - (in_pos + 1);
 
-       pr_debug("write_bit addr = %lx, value = %ld, pos = %ld, "
+       pr_debug("write_bit addr = %lx, value = %d, pos = %ld, "
                 "r_width = %ld\n",
                 dr->reg, !!value, pos, dr->reg_width);
 
index 816d4c592a3ca6d609e4c9481ad2e4ef2ee05a9c..66802a4390ccff59bd51025dbb62800e6fd92336 100644 (file)
@@ -574,11 +574,11 @@ void ioc3_unregister_submodule(struct ioc3_submodule *is)
  * Device management *
  *********************/
 
-static char *
+static char * __devinitdata
 ioc3_class_names[]={"unknown", "IP27 BaseIO", "IP30 system", "MENET 1/2/3",
                        "MENET 4", "CADduo", "Altix Serial"};
 
-static int ioc3_class(struct ioc3_driver_data *idd)
+static int __devinit ioc3_class(struct ioc3_driver_data *idd)
 {
        int res = IOC3_CLASS_NONE;
        /* NIC-based logic */
@@ -601,7 +601,8 @@ static int ioc3_class(struct ioc3_driver_data *idd)
        return res;
 }
 /* Adds a new instance of an IOC3 card */
-static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
+static int __devinit
+ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 {
        struct ioc3_driver_data *idd;
        uint32_t pcmd;
@@ -753,7 +754,7 @@ out:
 }
 
 /* Removes a particular instance of an IOC3 card. */
-static void ioc3_remove(struct pci_dev *pdev)
+static void __devexit ioc3_remove(struct pci_dev *pdev)
 {
        int id;
        struct ioc3_driver_data *idd;
@@ -805,7 +806,7 @@ static struct pci_driver ioc3_driver = {
        .name = "IOC3",
        .id_table = ioc3_id_table,
        .probe = ioc3_probe,
-       .remove = ioc3_remove,
+       .remove = __devexit_p(ioc3_remove),
 };
 
 MODULE_DEVICE_TABLE(pci, ioc3_id_table);
@@ -815,15 +816,15 @@ MODULE_DEVICE_TABLE(pci, ioc3_id_table);
  *********************/
 
 /* Module load */
-static int __devinit ioc3_init(void)
+static int __init ioc3_init(void)
 {
        if (ia64_platform_is("sn2"))
                return pci_register_driver(&ioc3_driver);
-       return 0;
+       return -ENODEV;
 }
 
 /* Module unload */
-static void __devexit ioc3_exit(void)
+static void __exit ioc3_exit(void)
 {
        pci_unregister_driver(&ioc3_driver);
 }
index 2d9d70359360719ea3851ee8ad33fba70f884635..f55eb0107336b0a66ca8f68dd41b9a3752d3bb3a 100644 (file)
@@ -216,6 +216,17 @@ config SPI_S3C24XX
        help
          SPI driver for Samsung S3C24XX series ARM SoCs
 
+config SPI_S3C24XX_FIQ
+       bool "S3C24XX driver with FIQ pseudo-DMA"
+       depends on SPI_S3C24XX
+       select FIQ
+       help
+         Enable FIQ support for the S3C24XX SPI driver to provide pseudo
+         DMA by using the fast-interrupt request framework, This allows
+         the driver to get DMA-like performance when there are either
+         no free DMA channels, or when doing transfers that required both
+         TX and RX data paths.
+
 config SPI_S3C24XX_GPIO
        tristate "Samsung S3C24XX series SPI by GPIO"
        depends on ARCH_S3C2410 && EXPERIMENTAL
@@ -226,6 +237,13 @@ config SPI_S3C24XX_GPIO
          the inbuilt hardware cannot provide the transfer mode, or
          where the board is using non hardware connected pins.
 
+config SPI_S3C64XX
+       tristate "Samsung S3C64XX series type SPI"
+       depends on ARCH_S3C64XX && EXPERIMENTAL
+       select S3C64XX_DMA
+       help
+         SPI driver for Samsung S3C64XX and newer SoCs.
+
 config SPI_SH_MSIOF
        tristate "SuperH MSIOF SPI controller"
        depends on SUPERH && HAVE_CLK
@@ -289,6 +307,16 @@ config SPI_NUC900
 # Add new SPI master controllers in alphabetical order above this line
 #
 
+config SPI_DESIGNWARE
+       bool "DesignWare SPI controller core support"
+       depends on SPI_MASTER
+       help
+         general driver for SPI controller core from DesignWare
+
+config SPI_DW_PCI
+       tristate "PCI interface driver for DW SPI core"
+       depends on SPI_DESIGNWARE && PCI
+
 #
 # There are lots of SPI device types, with sensors and memory
 # being probably the most widely used ones.
index ed8c1675b52f8c1af6918eb016fe871b85ccf973..f3d2810ba11c9f3fd11cbdaddf9b50431e70b70b 100644 (file)
@@ -16,6 +16,8 @@ obj-$(CONFIG_SPI_BFIN)                        += spi_bfin5xx.o
 obj-$(CONFIG_SPI_BITBANG)              += spi_bitbang.o
 obj-$(CONFIG_SPI_AU1550)               += au1550_spi.o
 obj-$(CONFIG_SPI_BUTTERFLY)            += spi_butterfly.o
+obj-$(CONFIG_SPI_DESIGNWARE)           += dw_spi.o
+obj-$(CONFIG_SPI_DW_PCI)               += dw_spi_pci.o
 obj-$(CONFIG_SPI_GPIO)                 += spi_gpio.o
 obj-$(CONFIG_SPI_IMX)                  += spi_imx.o
 obj-$(CONFIG_SPI_LM70_LLP)             += spi_lm70llp.o
@@ -30,7 +32,8 @@ obj-$(CONFIG_SPI_MPC52xx)             += mpc52xx_spi.o
 obj-$(CONFIG_SPI_MPC8xxx)              += spi_mpc8xxx.o
 obj-$(CONFIG_SPI_PPC4xx)               += spi_ppc4xx.o
 obj-$(CONFIG_SPI_S3C24XX_GPIO)         += spi_s3c24xx_gpio.o
-obj-$(CONFIG_SPI_S3C24XX)              += spi_s3c24xx.o
+obj-$(CONFIG_SPI_S3C24XX)              += spi_s3c24xx_hw.o
+obj-$(CONFIG_SPI_S3C64XX)              += spi_s3c64xx.o
 obj-$(CONFIG_SPI_TXX9)                 += spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)               += xilinx_spi.o
 obj-$(CONFIG_SPI_XILINX_OF)            += xilinx_spi_of.o
@@ -39,6 +42,11 @@ obj-$(CONFIG_SPI_SH_SCI)             += spi_sh_sci.o
 obj-$(CONFIG_SPI_SH_MSIOF)             += spi_sh_msiof.o
 obj-$(CONFIG_SPI_STMP3XXX)             += spi_stmp.o
 obj-$(CONFIG_SPI_NUC900)               += spi_nuc900.o
+
+# special build for s3c24xx spi driver with fiq support
+spi_s3c24xx_hw-y                       := spi_s3c24xx.o
+spi_s3c24xx_hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi_s3c24xx_fiq.o
+
 #      ... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
index f5b3fdbb1e27c22044df0b8c8759129a98622712..d21c24eaf0a95537baae7f22e783bff8658aa816 100644 (file)
@@ -189,14 +189,14 @@ static void atmel_spi_next_xfer_data(struct spi_master *master,
 
        /* use scratch buffer only when rx or tx data is unspecified */
        if (xfer->rx_buf)
-               *rx_dma = xfer->rx_dma + xfer->len - len;
+               *rx_dma = xfer->rx_dma + xfer->len - *plen;
        else {
                *rx_dma = as->buffer_dma;
                if (len > BUFFER_SIZE)
                        len = BUFFER_SIZE;
        }
        if (xfer->tx_buf)
-               *tx_dma = xfer->tx_dma + xfer->len - len;
+               *tx_dma = xfer->tx_dma + xfer->len - *plen;
        else {
                *tx_dma = as->buffer_dma;
                if (len > BUFFER_SIZE)
@@ -788,7 +788,7 @@ static int __init atmel_spi_probe(struct platform_device *pdev)
        spin_lock_init(&as->lock);
        INIT_LIST_HEAD(&as->queue);
        as->pdev = pdev;
-       as->regs = ioremap(regs->start, (regs->end - regs->start) + 1);
+       as->regs = ioremap(regs->start, resource_size(regs));
        if (!as->regs)
                goto out_free_buffer;
        as->irq = irq;
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
new file mode 100644 (file)
index 0000000..31620fa
--- /dev/null
@@ -0,0 +1,944 @@
+/*
+ * dw_spi.c - Designware SPI core controller driver (refer pxa2xx_spi.c)
+ *
+ * Copyright (c) 2009, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/dma-mapping.h>
+#include <linux/interrupt.h>
+#include <linux/highmem.h>
+#include <linux/delay.h>
+
+#include <linux/spi/dw_spi.h>
+#include <linux/spi/spi.h>
+
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+#endif
+
+#define START_STATE    ((void *)0)
+#define RUNNING_STATE  ((void *)1)
+#define DONE_STATE     ((void *)2)
+#define ERROR_STATE    ((void *)-1)
+
+#define QUEUE_RUNNING  0
+#define QUEUE_STOPPED  1
+
+#define MRST_SPI_DEASSERT      0
+#define MRST_SPI_ASSERT                1
+
+/* Slave spi_dev related */
+struct chip_data {
+       u16 cr0;
+       u8 cs;                  /* chip select pin */
+       u8 n_bytes;             /* current is a 1/2/4 byte op */
+       u8 tmode;               /* TR/TO/RO/EEPROM */
+       u8 type;                /* SPI/SSP/MicroWire */
+
+       u8 poll_mode;           /* 1 means use poll mode */
+
+       u32 dma_width;
+       u32 rx_threshold;
+       u32 tx_threshold;
+       u8 enable_dma;
+       u8 bits_per_word;
+       u16 clk_div;            /* baud rate divider */
+       u32 speed_hz;           /* baud rate */
+       int (*write)(struct dw_spi *dws);
+       int (*read)(struct dw_spi *dws);
+       void (*cs_control)(u32 command);
+};
+
+#ifdef CONFIG_DEBUG_FS
+static int spi_show_regs_open(struct inode *inode, struct file *file)
+{
+       file->private_data = inode->i_private;
+       return 0;
+}
+
+#define SPI_REGS_BUFSIZE       1024
+static ssize_t  spi_show_regs(struct file *file, char __user *user_buf,
+                               size_t count, loff_t *ppos)
+{
+       struct dw_spi *dws;
+       char *buf;
+       u32 len = 0;
+       ssize_t ret;
+
+       dws = file->private_data;
+
+       buf = kzalloc(SPI_REGS_BUFSIZE, GFP_KERNEL);
+       if (!buf)
+               return 0;
+
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "MRST SPI0 registers:\n");
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "=================================\n");
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "CTRL0: \t\t0x%08x\n", dw_readl(dws, ctrl0));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "CTRL1: \t\t0x%08x\n", dw_readl(dws, ctrl1));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "SSIENR: \t0x%08x\n", dw_readl(dws, ssienr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "SER: \t\t0x%08x\n", dw_readl(dws, ser));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "BAUDR: \t\t0x%08x\n", dw_readl(dws, baudr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "TXFTLR: \t0x%08x\n", dw_readl(dws, txfltr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "RXFTLR: \t0x%08x\n", dw_readl(dws, rxfltr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "TXFLR: \t\t0x%08x\n", dw_readl(dws, txflr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "RXFLR: \t\t0x%08x\n", dw_readl(dws, rxflr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "SR: \t\t0x%08x\n", dw_readl(dws, sr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "IMR: \t\t0x%08x\n", dw_readl(dws, imr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "ISR: \t\t0x%08x\n", dw_readl(dws, isr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "DMACR: \t\t0x%08x\n", dw_readl(dws, dmacr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "DMATDLR: \t0x%08x\n", dw_readl(dws, dmatdlr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "DMARDLR: \t0x%08x\n", dw_readl(dws, dmardlr));
+       len += snprintf(buf + len, SPI_REGS_BUFSIZE - len,
+                       "=================================\n");
+
+       ret =  simple_read_from_buffer(user_buf, count, ppos, buf, len);
+       kfree(buf);
+       return ret;
+}
+
+static const struct file_operations mrst_spi_regs_ops = {
+       .owner          = THIS_MODULE,
+       .open           = spi_show_regs_open,
+       .read           = spi_show_regs,
+};
+
+static int mrst_spi_debugfs_init(struct dw_spi *dws)
+{
+       dws->debugfs = debugfs_create_dir("mrst_spi", NULL);
+       if (!dws->debugfs)
+               return -ENOMEM;
+
+       debugfs_create_file("registers", S_IFREG | S_IRUGO,
+               dws->debugfs, (void *)dws, &mrst_spi_regs_ops);
+       return 0;
+}
+
+static void mrst_spi_debugfs_remove(struct dw_spi *dws)
+{
+       if (dws->debugfs)
+               debugfs_remove_recursive(dws->debugfs);
+}
+
+#else
+static inline int mrst_spi_debugfs_init(struct dw_spi *dws)
+{
+}
+
+static inline void mrst_spi_debugfs_remove(struct dw_spi *dws)
+{
+}
+#endif /* CONFIG_DEBUG_FS */
+
+static void wait_till_not_busy(struct dw_spi *dws)
+{
+       unsigned long end = jiffies + usecs_to_jiffies(1000);
+
+       while (time_before(jiffies, end)) {
+               if (!(dw_readw(dws, sr) & SR_BUSY))
+                       return;
+       }
+       dev_err(&dws->master->dev,
+               "DW SPI: Stutus keeps busy for 1000us after a read/write!\n");
+}
+
+static void flush(struct dw_spi *dws)
+{
+       while (dw_readw(dws, sr) & SR_RF_NOT_EMPT)
+               dw_readw(dws, dr);
+
+       wait_till_not_busy(dws);
+}
+
+static void null_cs_control(u32 command)
+{
+}
+
+static int null_writer(struct dw_spi *dws)
+{
+       u8 n_bytes = dws->n_bytes;
+
+       if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL)
+               || (dws->tx == dws->tx_end))
+               return 0;
+       dw_writew(dws, dr, 0);
+       dws->tx += n_bytes;
+
+       wait_till_not_busy(dws);
+       return 1;
+}
+
+static int null_reader(struct dw_spi *dws)
+{
+       u8 n_bytes = dws->n_bytes;
+
+       while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT)
+               && (dws->rx < dws->rx_end)) {
+               dw_readw(dws, dr);
+               dws->rx += n_bytes;
+       }
+       wait_till_not_busy(dws);
+       return dws->rx == dws->rx_end;
+}
+
+static int u8_writer(struct dw_spi *dws)
+{
+       if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL)
+               || (dws->tx == dws->tx_end))
+               return 0;
+
+       dw_writew(dws, dr, *(u8 *)(dws->tx));
+       ++dws->tx;
+
+       wait_till_not_busy(dws);
+       return 1;
+}
+
+static int u8_reader(struct dw_spi *dws)
+{
+       while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT)
+               && (dws->rx < dws->rx_end)) {
+               *(u8 *)(dws->rx) = dw_readw(dws, dr);
+               ++dws->rx;
+       }
+
+       wait_till_not_busy(dws);
+       return dws->rx == dws->rx_end;
+}
+
+static int u16_writer(struct dw_spi *dws)
+{
+       if (!(dw_readw(dws, sr) & SR_TF_NOT_FULL)
+               || (dws->tx == dws->tx_end))
+               return 0;
+
+       dw_writew(dws, dr, *(u16 *)(dws->tx));
+       dws->tx += 2;
+
+       wait_till_not_busy(dws);
+       return 1;
+}
+
+static int u16_reader(struct dw_spi *dws)
+{
+       u16 temp;
+
+       while ((dw_readw(dws, sr) & SR_RF_NOT_EMPT)
+               && (dws->rx < dws->rx_end)) {
+               temp = dw_readw(dws, dr);
+               *(u16 *)(dws->rx) = temp;
+               dws->rx += 2;
+       }
+
+       wait_till_not_busy(dws);
+       return dws->rx == dws->rx_end;
+}
+
+static void *next_transfer(struct dw_spi *dws)
+{
+       struct spi_message *msg = dws->cur_msg;
+       struct spi_transfer *trans = dws->cur_transfer;
+
+       /* Move to next transfer */
+       if (trans->transfer_list.next != &msg->transfers) {
+               dws->cur_transfer =
+                       list_entry(trans->transfer_list.next,
+                                       struct spi_transfer,
+                                       transfer_list);
+               return RUNNING_STATE;
+       } else
+               return DONE_STATE;
+}
+
+/*
+ * Note: first step is the protocol driver prepares
+ * a dma-capable memory, and this func just need translate
+ * the virt addr to physical
+ */
+static int map_dma_buffers(struct dw_spi *dws)
+{
+       if (!dws->cur_msg->is_dma_mapped || !dws->dma_inited
+               || !dws->cur_chip->enable_dma)
+               return 0;
+
+       if (dws->cur_transfer->tx_dma)
+               dws->tx_dma = dws->cur_transfer->tx_dma;
+
+       if (dws->cur_transfer->rx_dma)
+               dws->rx_dma = dws->cur_transfer->rx_dma;
+
+       return 1;
+}
+
+/* Caller already set message->status; dma and pio irqs are blocked */
+static void giveback(struct dw_spi *dws)
+{
+       struct spi_transfer *last_transfer;
+       unsigned long flags;
+       struct spi_message *msg;
+
+       spin_lock_irqsave(&dws->lock, flags);
+       msg = dws->cur_msg;
+       dws->cur_msg = NULL;
+       dws->cur_transfer = NULL;
+       dws->prev_chip = dws->cur_chip;
+       dws->cur_chip = NULL;
+       dws->dma_mapped = 0;
+       queue_work(dws->workqueue, &dws->pump_messages);
+       spin_unlock_irqrestore(&dws->lock, flags);
+
+       last_transfer = list_entry(msg->transfers.prev,
+                                       struct spi_transfer,
+                                       transfer_list);
+
+       if (!last_transfer->cs_change)
+               dws->cs_control(MRST_SPI_DEASSERT);
+
+       msg->state = NULL;
+       if (msg->complete)
+               msg->complete(msg->context);
+}
+
+static void int_error_stop(struct dw_spi *dws, const char *msg)
+{
+       /* Stop and reset hw */
+       flush(dws);
+       spi_enable_chip(dws, 0);
+
+       dev_err(&dws->master->dev, "%s\n", msg);
+       dws->cur_msg->state = ERROR_STATE;
+       tasklet_schedule(&dws->pump_transfers);
+}
+
+static void transfer_complete(struct dw_spi *dws)
+{
+       /* Update total byte transfered return count actual bytes read */
+       dws->cur_msg->actual_length += dws->len;
+
+       /* Move to next transfer */
+       dws->cur_msg->state = next_transfer(dws);
+
+       /* Handle end of message */
+       if (dws->cur_msg->state == DONE_STATE) {
+               dws->cur_msg->status = 0;
+               giveback(dws);
+       } else
+               tasklet_schedule(&dws->pump_transfers);
+}
+
+static irqreturn_t interrupt_transfer(struct dw_spi *dws)
+{
+       u16 irq_status, irq_mask = 0x3f;
+
+       irq_status = dw_readw(dws, isr) & irq_mask;
+       /* Error handling */
+       if (irq_status & (SPI_INT_TXOI | SPI_INT_RXOI | SPI_INT_RXUI)) {
+               dw_readw(dws, txoicr);
+               dw_readw(dws, rxoicr);
+               dw_readw(dws, rxuicr);
+               int_error_stop(dws, "interrupt_transfer: fifo overrun");
+               return IRQ_HANDLED;
+       }
+
+       /* INT comes from tx */
+       if (dws->tx && (irq_status & SPI_INT_TXEI)) {
+               while (dws->tx < dws->tx_end)
+                       dws->write(dws);
+
+               if (dws->tx == dws->tx_end) {
+                       spi_mask_intr(dws, SPI_INT_TXEI);
+                       transfer_complete(dws);
+               }
+       }
+
+       /* INT comes from rx */
+       if (dws->rx && (irq_status & SPI_INT_RXFI)) {
+               if (dws->read(dws))
+                       transfer_complete(dws);
+       }
+       return IRQ_HANDLED;
+}
+
+static irqreturn_t dw_spi_irq(int irq, void *dev_id)
+{
+       struct dw_spi *dws = dev_id;
+
+       if (!dws->cur_msg) {
+               spi_mask_intr(dws, SPI_INT_TXEI);
+               /* Never fail */
+               return IRQ_HANDLED;
+       }
+
+       return dws->transfer_handler(dws);
+}
+
+/* Must be called inside pump_transfers() */
+static void poll_transfer(struct dw_spi *dws)
+{
+       if (dws->tx) {
+               while (dws->write(dws))
+                       dws->read(dws);
+       }
+
+       dws->read(dws);
+       transfer_complete(dws);
+}
+
+static void dma_transfer(struct dw_spi *dws, int cs_change)
+{
+}
+
+static void pump_transfers(unsigned long data)
+{
+       struct dw_spi *dws = (struct dw_spi *)data;
+       struct spi_message *message = NULL;
+       struct spi_transfer *transfer = NULL;
+       struct spi_transfer *previous = NULL;
+       struct spi_device *spi = NULL;
+       struct chip_data *chip = NULL;
+       u8 bits = 0;
+       u8 imask = 0;
+       u8 cs_change = 0;
+       u16 clk_div = 0;
+       u32 speed = 0;
+       u32 cr0 = 0;
+
+       /* Get current state information */
+       message = dws->cur_msg;
+       transfer = dws->cur_transfer;
+       chip = dws->cur_chip;
+       spi = message->spi;
+
+       if (message->state == ERROR_STATE) {
+               message->status = -EIO;
+               goto early_exit;
+       }
+
+       /* Handle end of message */
+       if (message->state == DONE_STATE) {
+               message->status = 0;
+               goto early_exit;
+       }
+
+       /* Delay if requested at end of transfer*/
+       if (message->state == RUNNING_STATE) {
+               previous = list_entry(transfer->transfer_list.prev,
+                                       struct spi_transfer,
+                                       transfer_list);
+               if (previous->delay_usecs)
+                       udelay(previous->delay_usecs);
+       }
+
+       dws->n_bytes = chip->n_bytes;
+       dws->dma_width = chip->dma_width;
+       dws->cs_control = chip->cs_control;
+
+       dws->rx_dma = transfer->rx_dma;
+       dws->tx_dma = transfer->tx_dma;
+       dws->tx = (void *)transfer->tx_buf;
+       dws->tx_end = dws->tx + transfer->len;
+       dws->rx = transfer->rx_buf;
+       dws->rx_end = dws->rx + transfer->len;
+       dws->write = dws->tx ? chip->write : null_writer;
+       dws->read = dws->rx ? chip->read : null_reader;
+       dws->cs_change = transfer->cs_change;
+       dws->len = dws->cur_transfer->len;
+       if (chip != dws->prev_chip)
+               cs_change = 1;
+
+       cr0 = chip->cr0;
+
+       /* Handle per transfer options for bpw and speed */
+       if (transfer->speed_hz) {
+               speed = chip->speed_hz;
+
+               if (transfer->speed_hz != speed) {
+                       speed = transfer->speed_hz;
+                       if (speed > dws->max_freq) {
+                               printk(KERN_ERR "MRST SPI0: unsupported"
+                                       "freq: %dHz\n", speed);
+                               message->status = -EIO;
+                               goto early_exit;
+                       }
+
+                       /* clk_div doesn't support odd number */
+                       clk_div = dws->max_freq / speed;
+                       clk_div = (clk_div >> 1) << 1;
+
+                       chip->speed_hz = speed;
+                       chip->clk_div = clk_div;
+               }
+       }
+       if (transfer->bits_per_word) {
+               bits = transfer->bits_per_word;
+
+               switch (bits) {
+               case 8:
+                       dws->n_bytes = 1;
+                       dws->dma_width = 1;
+                       dws->read = (dws->read != null_reader) ?
+                                       u8_reader : null_reader;
+                       dws->write = (dws->write != null_writer) ?
+                                       u8_writer : null_writer;
+                       break;
+               case 16:
+                       dws->n_bytes = 2;
+                       dws->dma_width = 2;
+                       dws->read = (dws->read != null_reader) ?
+                                       u16_reader : null_reader;
+                       dws->write = (dws->write != null_writer) ?
+                                       u16_writer : null_writer;
+                       break;
+               default:
+                       printk(KERN_ERR "MRST SPI0: unsupported bits:"
+                               "%db\n", bits);
+                       message->status = -EIO;
+                       goto early_exit;
+               }
+
+               cr0 = (bits - 1)
+                       | (chip->type << SPI_FRF_OFFSET)
+                       | (spi->mode << SPI_MODE_OFFSET)
+                       | (chip->tmode << SPI_TMOD_OFFSET);
+       }
+       message->state = RUNNING_STATE;
+
+       /* Check if current transfer is a DMA transaction */
+       dws->dma_mapped = map_dma_buffers(dws);
+
+       if (!dws->dma_mapped && !chip->poll_mode) {
+               if (dws->rx)
+                       imask |= SPI_INT_RXFI;
+               if (dws->tx)
+                       imask |= SPI_INT_TXEI;
+               dws->transfer_handler = interrupt_transfer;
+       }
+
+       /*
+        * Reprogram registers only if
+        *      1. chip select changes
+        *      2. clk_div is changed
+        *      3. control value changes
+        */
+       if (dw_readw(dws, ctrl0) != cr0 || cs_change || clk_div) {
+               spi_enable_chip(dws, 0);
+
+               if (dw_readw(dws, ctrl0) != cr0)
+                       dw_writew(dws, ctrl0, cr0);
+
+               /* Set the interrupt mask, for poll mode just diable all int */
+               spi_mask_intr(dws, 0xff);
+               if (!chip->poll_mode)
+                       spi_umask_intr(dws, imask);
+
+               spi_set_clk(dws, clk_div ? clk_div : chip->clk_div);
+               spi_chip_sel(dws, spi->chip_select);
+               spi_enable_chip(dws, 1);
+
+               if (cs_change)
+                       dws->prev_chip = chip;
+       }
+
+       if (dws->dma_mapped)
+               dma_transfer(dws, cs_change);
+
+       if (chip->poll_mode)
+               poll_transfer(dws);
+
+       return;
+
+early_exit:
+       giveback(dws);
+       return;
+}
+
+static void pump_messages(struct work_struct *work)
+{
+       struct dw_spi *dws =
+               container_of(work, struct dw_spi, pump_messages);
+       unsigned long flags;
+
+       /* Lock queue and check for queue work */
+       spin_lock_irqsave(&dws->lock, flags);
+       if (list_empty(&dws->queue) || dws->run == QUEUE_STOPPED) {
+               dws->busy = 0;
+               spin_unlock_irqrestore(&dws->lock, flags);
+               return;
+       }
+
+       /* Make sure we are not already running a message */
+       if (dws->cur_msg) {
+               spin_unlock_irqrestore(&dws->lock, flags);
+               return;
+       }
+
+       /* Extract head of queue */
+       dws->cur_msg = list_entry(dws->queue.next, struct spi_message, queue);
+       list_del_init(&dws->cur_msg->queue);
+
+       /* Initial message state*/
+       dws->cur_msg->state = START_STATE;
+       dws->cur_transfer = list_entry(dws->cur_msg->transfers.next,
+                                               struct spi_transfer,
+                                               transfer_list);
+       dws->cur_chip = spi_get_ctldata(dws->cur_msg->spi);
+
+       /* Mark as busy and launch transfers */
+       tasklet_schedule(&dws->pump_transfers);
+
+       dws->busy = 1;
+       spin_unlock_irqrestore(&dws->lock, flags);
+}
+
+/* spi_device use this to queue in their spi_msg */
+static int dw_spi_transfer(struct spi_device *spi, struct spi_message *msg)
+{
+       struct dw_spi *dws = spi_master_get_devdata(spi->master);
+       unsigned long flags;
+
+       spin_lock_irqsave(&dws->lock, flags);
+
+       if (dws->run == QUEUE_STOPPED) {
+               spin_unlock_irqrestore(&dws->lock, flags);
+               return -ESHUTDOWN;
+       }
+
+       msg->actual_length = 0;
+       msg->status = -EINPROGRESS;
+       msg->state = START_STATE;
+
+       list_add_tail(&msg->queue, &dws->queue);
+
+       if (dws->run == QUEUE_RUNNING && !dws->busy) {
+
+               if (dws->cur_transfer || dws->cur_msg)
+                       queue_work(dws->workqueue,
+                                       &dws->pump_messages);
+               else {
+                       /* If no other data transaction in air, just go */
+                       spin_unlock_irqrestore(&dws->lock, flags);
+                       pump_messages(&dws->pump_messages);
+                       return 0;
+               }
+       }
+
+       spin_unlock_irqrestore(&dws->lock, flags);
+       return 0;
+}
+
+/* This may be called twice for each spi dev */
+static int dw_spi_setup(struct spi_device *spi)
+{
+       struct dw_spi_chip *chip_info = NULL;
+       struct chip_data *chip;
+
+       if (spi->bits_per_word != 8 && spi->bits_per_word != 16)
+               return -EINVAL;
+
+       /* Only alloc on first setup */
+       chip = spi_get_ctldata(spi);
+       if (!chip) {
+               chip = kzalloc(sizeof(struct chip_data), GFP_KERNEL);
+               if (!chip)
+                       return -ENOMEM;
+
+               chip->cs_control = null_cs_control;
+               chip->enable_dma = 0;
+       }
+
+       /*
+        * Protocol drivers may change the chip settings, so...
+        * if chip_info exists, use it
+        */
+       chip_info = spi->controller_data;
+
+       /* chip_info doesn't always exist */
+       if (chip_info) {
+               if (chip_info->cs_control)
+                       chip->cs_control = chip_info->cs_control;
+
+               chip->poll_mode = chip_info->poll_mode;
+               chip->type = chip_info->type;
+
+               chip->rx_threshold = 0;
+               chip->tx_threshold = 0;
+
+               chip->enable_dma = chip_info->enable_dma;
+       }
+
+       if (spi->bits_per_word <= 8) {
+               chip->n_bytes = 1;
+               chip->dma_width = 1;
+               chip->read = u8_reader;
+               chip->write = u8_writer;
+       } else if (spi->bits_per_word <= 16) {
+               chip->n_bytes = 2;
+               chip->dma_width = 2;
+               chip->read = u16_reader;
+               chip->write = u16_writer;
+       } else {
+               /* Never take >16b case for MRST SPIC */
+               dev_err(&spi->dev, "invalid wordsize\n");
+               return -EINVAL;
+       }
+       chip->bits_per_word = spi->bits_per_word;
+
+       chip->speed_hz = spi->max_speed_hz;
+       if (chip->speed_hz)
+               chip->clk_div = 25000000 / chip->speed_hz;
+       else
+               chip->clk_div = 8;      /* default value */
+
+       chip->tmode = 0; /* Tx & Rx */
+       /* Default SPI mode is SCPOL = 0, SCPH = 0 */
+       chip->cr0 = (chip->bits_per_word - 1)
+                       | (chip->type << SPI_FRF_OFFSET)
+                       | (spi->mode  << SPI_MODE_OFFSET)
+                       | (chip->tmode << SPI_TMOD_OFFSET);
+
+       spi_set_ctldata(spi, chip);
+       return 0;
+}
+
+static void dw_spi_cleanup(struct spi_device *spi)
+{
+       struct chip_data *chip = spi_get_ctldata(spi);
+       kfree(chip);
+}
+
+static int __init init_queue(struct dw_spi *dws)
+{
+       INIT_LIST_HEAD(&dws->queue);
+       spin_lock_init(&dws->lock);
+
+       dws->run = QUEUE_STOPPED;
+       dws->busy = 0;
+
+       tasklet_init(&dws->pump_transfers,
+                       pump_transfers, (unsigned long)dws);
+
+       INIT_WORK(&dws->pump_messages, pump_messages);
+       dws->workqueue = create_singlethread_workqueue(
+                                       dev_name(dws->master->dev.parent));
+       if (dws->workqueue == NULL)
+               return -EBUSY;
+
+       return 0;
+}
+
+static int start_queue(struct dw_spi *dws)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&dws->lock, flags);
+
+       if (dws->run == QUEUE_RUNNING || dws->busy) {
+               spin_unlock_irqrestore(&dws->lock, flags);
+               return -EBUSY;
+       }
+
+       dws->run = QUEUE_RUNNING;
+       dws->cur_msg = NULL;
+       dws->cur_transfer = NULL;
+       dws->cur_chip = NULL;
+       dws->prev_chip = NULL;
+       spin_unlock_irqrestore(&dws->lock, flags);
+
+       queue_work(dws->workqueue, &dws->pump_messages);
+
+       return 0;
+}
+
+static int stop_queue(struct dw_spi *dws)
+{
+       unsigned long flags;
+       unsigned limit = 50;
+       int status = 0;
+
+       spin_lock_irqsave(&dws->lock, flags);
+       dws->run = QUEUE_STOPPED;
+       while (!list_empty(&dws->queue) && dws->busy && limit--) {
+               spin_unlock_irqrestore(&dws->lock, flags);
+               msleep(10);
+               spin_lock_irqsave(&dws->lock, flags);
+       }
+
+       if (!list_empty(&dws->queue) || dws->busy)
+               status = -EBUSY;
+       spin_unlock_irqrestore(&dws->lock, flags);
+
+       return status;
+}
+
+static int destroy_queue(struct dw_spi *dws)
+{
+       int status;
+
+       status = stop_queue(dws);
+       if (status != 0)
+               return status;
+       destroy_workqueue(dws->workqueue);
+       return 0;
+}
+
+/* Restart the controller, disable all interrupts, clean rx fifo */
+static void spi_hw_init(struct dw_spi *dws)
+{
+       spi_enable_chip(dws, 0);
+       spi_mask_intr(dws, 0xff);
+       spi_enable_chip(dws, 1);
+       flush(dws);
+}
+
+int __devinit dw_spi_add_host(struct dw_spi *dws)
+{
+       struct spi_master *master;
+       int ret;
+
+       BUG_ON(dws == NULL);
+
+       master = spi_alloc_master(dws->parent_dev, 0);
+       if (!master) {
+               ret = -ENOMEM;
+               goto exit;
+       }
+
+       dws->master = master;
+       dws->type = SSI_MOTO_SPI;
+       dws->prev_chip = NULL;
+       dws->dma_inited = 0;
+       dws->dma_addr = (dma_addr_t)(dws->paddr + 0x60);
+
+       ret = request_irq(dws->irq, dw_spi_irq, 0,
+                       "dw_spi", dws);
+       if (ret < 0) {
+               dev_err(&master->dev, "can not get IRQ\n");
+               goto err_free_master;
+       }
+
+       master->mode_bits = SPI_CPOL | SPI_CPHA;
+       master->bus_num = dws->bus_num;
+       master->num_chipselect = dws->num_cs;
+       master->cleanup = dw_spi_cleanup;
+       master->setup = dw_spi_setup;
+       master->transfer = dw_spi_transfer;
+
+       dws->dma_inited = 0;
+
+       /* Basic HW init */
+       spi_hw_init(dws);
+
+       /* Initial and start queue */
+       ret = init_queue(dws);
+       if (ret) {
+               dev_err(&master->dev, "problem initializing queue\n");
+               goto err_diable_hw;
+       }
+       ret = start_queue(dws);
+       if (ret) {
+               dev_err(&master->dev, "problem starting queue\n");
+               goto err_diable_hw;
+       }
+
+       spi_master_set_devdata(master, dws);
+       ret = spi_register_master(master);
+       if (ret) {
+               dev_err(&master->dev, "problem registering spi master\n");
+               goto err_queue_alloc;
+       }
+
+       mrst_spi_debugfs_init(dws);
+       return 0;
+
+err_queue_alloc:
+       destroy_queue(dws);
+err_diable_hw:
+       spi_enable_chip(dws, 0);
+       free_irq(dws->irq, dws);
+err_free_master:
+       spi_master_put(master);
+exit:
+       return ret;
+}
+EXPORT_SYMBOL(dw_spi_add_host);
+
+void __devexit dw_spi_remove_host(struct dw_spi *dws)
+{
+       int status = 0;
+
+       if (!dws)
+               return;
+       mrst_spi_debugfs_remove(dws);
+
+       /* Remove the queue */
+       status = destroy_queue(dws);
+       if (status != 0)
+               dev_err(&dws->master->dev, "dw_spi_remove: workqueue will not "
+                       "complete, message memory not freed\n");
+
+       spi_enable_chip(dws, 0);
+       /* Disable clk */
+       spi_set_clk(dws, 0);
+       free_irq(dws->irq, dws);
+
+       /* Disconnect from the SPI framework */
+       spi_unregister_master(dws->master);
+}
+
+int dw_spi_suspend_host(struct dw_spi *dws)
+{
+       int ret = 0;
+
+       ret = stop_queue(dws);
+       if (ret)
+               return ret;
+       spi_enable_chip(dws, 0);
+       spi_set_clk(dws, 0);
+       return ret;
+}
+EXPORT_SYMBOL(dw_spi_suspend_host);
+
+int dw_spi_resume_host(struct dw_spi *dws)
+{
+       int ret;
+
+       spi_hw_init(dws);
+       ret = start_queue(dws);
+       if (ret)
+               dev_err(&dws->master->dev, "fail to start queue (%d)\n", ret);
+       return ret;
+}
+EXPORT_SYMBOL(dw_spi_resume_host);
+
+MODULE_AUTHOR("Feng Tang <feng.tang@intel.com>");
+MODULE_DESCRIPTION("Driver for DesignWare SPI controller core");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/spi/dw_spi_pci.c b/drivers/spi/dw_spi_pci.c
new file mode 100644 (file)
index 0000000..34ba691
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * mrst_spi_pci.c - PCI interface driver for DW SPI Core
+ *
+ * Copyright (c) 2009, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/spi/dw_spi.h>
+#include <linux/spi/spi.h>
+
+#define DRIVER_NAME "dw_spi_pci"
+
+struct dw_spi_pci {
+       struct pci_dev          *pdev;
+       struct dw_spi           dws;
+};
+
+static int __devinit spi_pci_probe(struct pci_dev *pdev,
+       const struct pci_device_id *ent)
+{
+       struct dw_spi_pci *dwpci;
+       struct dw_spi *dws;
+       int pci_bar = 0;
+       int ret;
+
+       printk(KERN_INFO "DW: found PCI SPI controller(ID: %04x:%04x)\n",
+               pdev->vendor, pdev->device);
+
+       ret = pci_enable_device(pdev);
+       if (ret)
+               return ret;
+
+       dwpci = kzalloc(sizeof(struct dw_spi_pci), GFP_KERNEL);
+       if (!dwpci) {
+               ret = -ENOMEM;
+               goto err_disable;
+       }
+
+       dwpci->pdev = pdev;
+       dws = &dwpci->dws;
+
+       /* Get basic io resource and map it */
+       dws->paddr = pci_resource_start(pdev, pci_bar);
+       dws->iolen = pci_resource_len(pdev, pci_bar);
+
+       ret = pci_request_region(pdev, pci_bar, dev_name(&pdev->dev));
+       if (ret)
+               goto err_kfree;
+
+       dws->regs = ioremap_nocache((unsigned long)dws->paddr,
+                               pci_resource_len(pdev, pci_bar));
+       if (!dws->regs) {
+               ret = -ENOMEM;
+               goto err_release_reg;
+       }
+
+       dws->parent_dev = &pdev->dev;
+       dws->bus_num = 0;
+       dws->num_cs = 4;
+       dws->max_freq = 25000000;       /* for Moorestwon */
+       dws->irq = pdev->irq;
+
+       ret = dw_spi_add_host(dws);
+       if (ret)
+               goto err_unmap;
+
+       /* PCI hook and SPI hook use the same drv data */
+       pci_set_drvdata(pdev, dwpci);
+       return 0;
+
+err_unmap:
+       iounmap(dws->regs);
+err_release_reg:
+       pci_release_region(pdev, pci_bar);
+err_kfree:
+       kfree(dwpci);
+err_disable:
+       pci_disable_device(pdev);
+       return ret;
+}
+
+static void __devexit spi_pci_remove(struct pci_dev *pdev)
+{
+       struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
+
+       pci_set_drvdata(pdev, NULL);
+       iounmap(dwpci->dws.regs);
+       pci_release_region(pdev, 0);
+       kfree(dwpci);
+       pci_disable_device(pdev);
+}
+
+#ifdef CONFIG_PM
+static int spi_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
+       int ret;
+
+       ret = dw_spi_suspend_host(&dwpci->dws);
+       if (ret)
+               return ret;
+       pci_save_state(pdev);
+       pci_disable_device(pdev);
+       pci_set_power_state(pdev, pci_choose_state(pdev, state));
+       return ret;
+}
+
+static int spi_resume(struct pci_dev *pdev)
+{
+       struct dw_spi_pci *dwpci = pci_get_drvdata(pdev);
+       int ret;
+
+       pci_set_power_state(pdev, PCI_D0);
+       pci_restore_state(pdev);
+       ret = pci_enable_device(pdev);
+       if (ret)
+               return ret;
+       return dw_spi_resume_host(&dwpci->dws);
+}
+#else
+#define spi_suspend    NULL
+#define spi_resume     NULL
+#endif
+
+static const struct pci_device_id pci_ids[] __devinitdata = {
+       /* Intel Moorestown platform SPI controller 0 */
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0800) },
+       {},
+};
+
+static struct pci_driver dw_spi_driver = {
+       .name =         DRIVER_NAME,
+       .id_table =     pci_ids,
+       .probe =        spi_pci_probe,
+       .remove =       __devexit_p(spi_pci_remove),
+       .suspend =      spi_suspend,
+       .resume =       spi_resume,
+};
+
+static int __init mrst_spi_init(void)
+{
+       return pci_register_driver(&dw_spi_driver);
+}
+
+static void __exit mrst_spi_exit(void)
+{
+       pci_unregister_driver(&dw_spi_driver);
+}
+
+module_init(mrst_spi_init);
+module_exit(mrst_spi_exit);
+
+MODULE_AUTHOR("Feng Tang <feng.tang@intel.com>");
+MODULE_DESCRIPTION("PCI interface driver for DW SPI Core");
+MODULE_LICENSE("GPL v2");
index c8c2b693ffacbb757b281f7190f02f118e4da3fc..c2f707e5ce74accbc44a4c3766a25ea2fde93272 100644 (file)
@@ -1709,7 +1709,7 @@ static int pxa2xx_spi_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops pxa2xx_spi_pm_ops = {
+static const struct dev_pm_ops pxa2xx_spi_pm_ops = {
        .suspend        = pxa2xx_spi_suspend,
        .resume         = pxa2xx_spi_resume,
 };
index 73e24ef5a2f961fa41c0d3ee81dc03143e768cd5..1d41058bbab2a4227dc663f388e3e026e1ce84b3 100644 (file)
@@ -1294,7 +1294,7 @@ static int __init bfin_spi_probe(struct platform_device *pdev)
                goto out_error_get_res;
        }
 
-       drv_data->regs_base = ioremap(res->start, (res->end - res->start + 1));
+       drv_data->regs_base = ioremap(res->start, resource_size(res));
        if (drv_data->regs_base == NULL) {
                dev_err(dev, "Cannot map IO\n");
                status = -ENXIO;
index e9390d747bfcf35e018747fcfc6a1b2e529ef486..1fb2a6ea328cfcff9ce8ec3a03700f3bec729947 100644 (file)
@@ -1013,7 +1013,7 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq)
 
        init_completion(&mpc8xxx_spi->done);
 
-       mpc8xxx_spi->base = ioremap(mem->start, mem->end - mem->start + 1);
+       mpc8xxx_spi->base = ioremap(mem->start, resource_size(mem));
        if (mpc8xxx_spi->base == NULL) {
                ret = -ENOMEM;
                goto err_ioremap;
index 33d94f76b9ef47fd92bddd54815e72262b6dffda..c010733877ae73f8dc57c211c97163d0301a34d6 100644 (file)
@@ -1,7 +1,7 @@
 /* linux/drivers/spi/spi_s3c24xx.c
  *
  * Copyright (c) 2006 Ben Dooks
- * Copyright (c) 2006 Simtec Electronics
+ * Copyright 2006-2009 Simtec Electronics
  *     Ben Dooks <ben@simtec.co.uk>
  *
  * This program is free software; you can redistribute it and/or modify
 #include <plat/regs-spi.h>
 #include <mach/spi.h>
 
+#include <plat/fiq.h>
+#include <asm/fiq.h>
+
+#include "spi_s3c24xx_fiq.h"
+
 /**
  * s3c24xx_spi_devstate - per device data
  * @hz: Last frequency calculated for @sppre field.
@@ -42,6 +47,13 @@ struct s3c24xx_spi_devstate {
        u8              sppre;
 };
 
+enum spi_fiq_mode {
+       FIQ_MODE_NONE   = 0,
+       FIQ_MODE_TX     = 1,
+       FIQ_MODE_RX     = 2,
+       FIQ_MODE_TXRX   = 3,
+};
+
 struct s3c24xx_spi {
        /* bitbang has to be first */
        struct spi_bitbang       bitbang;
@@ -52,6 +64,11 @@ struct s3c24xx_spi {
        int                      len;
        int                      count;
 
+       struct fiq_handler       fiq_handler;
+       enum spi_fiq_mode        fiq_mode;
+       unsigned char            fiq_inuse;
+       unsigned char            fiq_claimed;
+
        void                    (*set_cs)(struct s3c2410_spi_info *spi,
                                          int cs, int pol);
 
@@ -67,6 +84,7 @@ struct s3c24xx_spi {
        struct s3c2410_spi_info *pdata;
 };
 
+
 #define SPCON_DEFAULT (S3C2410_SPCON_MSTR | S3C2410_SPCON_SMOD_INT)
 #define SPPIN_DEFAULT (S3C2410_SPPIN_KEEP)
 
@@ -127,7 +145,7 @@ static int s3c24xx_spi_update_state(struct spi_device *spi,
        }
 
        if (spi->mode != cs->mode) {
-               u8 spcon = SPCON_DEFAULT;
+               u8 spcon = SPCON_DEFAULT | S3C2410_SPCON_ENSCK;
 
                if (spi->mode & SPI_CPHA)
                        spcon |= S3C2410_SPCON_CPHA_FMTB;
@@ -214,13 +232,196 @@ static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count)
        return hw->tx ? hw->tx[count] : 0;
 }
 
+#ifdef CONFIG_SPI_S3C24XX_FIQ
+/* Support for FIQ based pseudo-DMA to improve the transfer speed.
+ *
+ * This code uses the assembly helper in spi_s3c24xx_spi.S which is
+ * used by the FIQ core to move data between main memory and the peripheral
+ * block. Since this is code running on the processor, there is no problem
+ * with cache coherency of the buffers, so we can use any buffer we like.
+ */
+
+/**
+ * struct spi_fiq_code - FIQ code and header
+ * @length: The length of the code fragment, excluding this header.
+ * @ack_offset: The offset from @data to the word to place the IRQ ACK bit at.
+ * @data: The code itself to install as a FIQ handler.
+ */
+struct spi_fiq_code {
+       u32     length;
+       u32     ack_offset;
+       u8      data[0];
+};
+
+extern struct spi_fiq_code s3c24xx_spi_fiq_txrx;
+extern struct spi_fiq_code s3c24xx_spi_fiq_tx;
+extern struct spi_fiq_code s3c24xx_spi_fiq_rx;
+
+/**
+ * ack_bit - turn IRQ into IRQ acknowledgement bit
+ * @irq: The interrupt number
+ *
+ * Returns the bit to write to the interrupt acknowledge register.
+ */
+static inline u32 ack_bit(unsigned int irq)
+{
+       return 1 << (irq - IRQ_EINT0);
+}
+
+/**
+ * s3c24xx_spi_tryfiq - attempt to claim and setup FIQ for transfer
+ * @hw: The hardware state.
+ *
+ * Claim the FIQ handler (only one can be active at any one time) and
+ * then setup the correct transfer code for this transfer.
+ *
+ * This call updates all the necessary state information if sucessful,
+ * so the caller does not need to do anything more than start the transfer
+ * as normal, since the IRQ will have been re-routed to the FIQ handler.
+*/
+void s3c24xx_spi_tryfiq(struct s3c24xx_spi *hw)
+{
+       struct pt_regs regs;
+       enum spi_fiq_mode mode;
+       struct spi_fiq_code *code;
+       int ret;
+
+       if (!hw->fiq_claimed) {
+               /* try and claim fiq if we haven't got it, and if not
+                * then return and simply use another transfer method */
+
+               ret = claim_fiq(&hw->fiq_handler);
+               if (ret)
+                       return;
+       }
+
+       if (hw->tx && !hw->rx)
+               mode = FIQ_MODE_TX;
+       else if (hw->rx && !hw->tx)
+               mode = FIQ_MODE_RX;
+       else
+               mode = FIQ_MODE_TXRX;
+
+       regs.uregs[fiq_rspi] = (long)hw->regs;
+       regs.uregs[fiq_rrx]  = (long)hw->rx;
+       regs.uregs[fiq_rtx]  = (long)hw->tx + 1;
+       regs.uregs[fiq_rcount] = hw->len - 1;
+       regs.uregs[fiq_rirq] = (long)S3C24XX_VA_IRQ;
+
+       set_fiq_regs(&regs);
+
+       if (hw->fiq_mode != mode) {
+               u32 *ack_ptr;
+
+               hw->fiq_mode = mode;
+
+               switch (mode) {
+               case FIQ_MODE_TX:
+                       code = &s3c24xx_spi_fiq_tx;
+                       break;
+               case FIQ_MODE_RX:
+                       code = &s3c24xx_spi_fiq_rx;
+                       break;
+               case FIQ_MODE_TXRX:
+                       code = &s3c24xx_spi_fiq_txrx;
+                       break;
+               default:
+                       code = NULL;
+               }
+
+               BUG_ON(!code);
+
+               ack_ptr = (u32 *)&code->data[code->ack_offset];
+               *ack_ptr = ack_bit(hw->irq);
+
+               set_fiq_handler(&code->data, code->length);
+       }
+
+       s3c24xx_set_fiq(hw->irq, true);
+
+       hw->fiq_mode = mode;
+       hw->fiq_inuse = 1;
+}
+
+/**
+ * s3c24xx_spi_fiqop - FIQ core code callback
+ * @pw: Data registered with the handler
+ * @release: Whether this is a release or a return.
+ *
+ * Called by the FIQ code when another module wants to use the FIQ, so
+ * return whether we are currently using this or not and then update our
+ * internal state.
+ */
+static int s3c24xx_spi_fiqop(void *pw, int release)
+{
+       struct s3c24xx_spi *hw = pw;
+       int ret = 0;
+
+       if (release) {
+               if (hw->fiq_inuse)
+                       ret = -EBUSY;
+
+               /* note, we do not need to unroute the FIQ, as the FIQ
+                * vector code de-routes it to signal the end of transfer */
+
+               hw->fiq_mode = FIQ_MODE_NONE;
+               hw->fiq_claimed = 0;
+       } else {
+               hw->fiq_claimed = 1;
+       }
+
+       return ret;
+}
+
+/**
+ * s3c24xx_spi_initfiq - setup the information for the FIQ core
+ * @hw: The hardware state.
+ *
+ * Setup the fiq_handler block to pass to the FIQ core.
+ */
+static inline void s3c24xx_spi_initfiq(struct s3c24xx_spi *hw)
+{
+       hw->fiq_handler.dev_id = hw;
+       hw->fiq_handler.name = dev_name(hw->dev);
+       hw->fiq_handler.fiq_op = s3c24xx_spi_fiqop;
+}
+
+/**
+ * s3c24xx_spi_usefiq - return if we should be using FIQ.
+ * @hw: The hardware state.
+ *
+ * Return true if the platform data specifies whether this channel is
+ * allowed to use the FIQ.
+ */
+static inline bool s3c24xx_spi_usefiq(struct s3c24xx_spi *hw)
+{
+       return hw->pdata->use_fiq;
+}
+
+/**
+ * s3c24xx_spi_usingfiq - return if channel is using FIQ
+ * @spi: The hardware state.
+ *
+ * Return whether the channel is currently using the FIQ (separate from
+ * whether the FIQ is claimed).
+ */
+static inline bool s3c24xx_spi_usingfiq(struct s3c24xx_spi *spi)
+{
+       return spi->fiq_inuse;
+}
+#else
+
+static inline void s3c24xx_spi_initfiq(struct s3c24xx_spi *s) { }
+static inline void s3c24xx_spi_tryfiq(struct s3c24xx_spi *s) { }
+static inline bool s3c24xx_spi_usefiq(struct s3c24xx_spi *s) { return false; }
+static inline bool s3c24xx_spi_usingfiq(struct s3c24xx_spi *s) { return false; }
+
+#endif /* CONFIG_SPI_S3C24XX_FIQ */
+
 static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
 {
        struct s3c24xx_spi *hw = to_hw(spi);
 
-       dev_dbg(&spi->dev, "txrx: tx %p, rx %p, len %d\n",
-               t->tx_buf, t->rx_buf, t->len);
-
        hw->tx = t->tx_buf;
        hw->rx = t->rx_buf;
        hw->len = t->len;
@@ -228,11 +429,14 @@ static int s3c24xx_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
 
        init_completion(&hw->done);
 
+       hw->fiq_inuse = 0;
+       if (s3c24xx_spi_usefiq(hw) && t->len >= 3)
+               s3c24xx_spi_tryfiq(hw);
+
        /* send the first byte */
        writeb(hw_txbyte(hw, 0), hw->regs + S3C2410_SPTDAT);
 
        wait_for_completion(&hw->done);
-
        return hw->count;
 }
 
@@ -254,17 +458,27 @@ static irqreturn_t s3c24xx_spi_irq(int irq, void *dev)
                goto irq_done;
        }
 
-       hw->count++;
+       if (!s3c24xx_spi_usingfiq(hw)) {
+               hw->count++;
 
-       if (hw->rx)
-               hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT);
+               if (hw->rx)
+                       hw->rx[count] = readb(hw->regs + S3C2410_SPRDAT);
 
-       count++;
+               count++;
+
+               if (count < hw->len)
+                       writeb(hw_txbyte(hw, count), hw->regs + S3C2410_SPTDAT);
+               else
+                       complete(&hw->done);
+       } else {
+               hw->count = hw->len;
+               hw->fiq_inuse = 0;
+
+               if (hw->rx)
+                       hw->rx[hw->len-1] = readb(hw->regs + S3C2410_SPRDAT);
 
-       if (count < hw->len)
-               writeb(hw_txbyte(hw, count), hw->regs + S3C2410_SPTDAT);
-       else
                complete(&hw->done);
+       }
 
  irq_done:
        return IRQ_HANDLED;
@@ -322,6 +536,10 @@ static int __init s3c24xx_spi_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, hw);
        init_completion(&hw->done);
 
+       /* initialise fiq handler */
+
+       s3c24xx_spi_initfiq(hw);
+
        /* setup the master state. */
 
        /* the spi->mode bits understood by this driver: */
@@ -489,7 +707,7 @@ static int s3c24xx_spi_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops s3c24xx_spi_pmops = {
+static const struct dev_pm_ops s3c24xx_spi_pmops = {
        .suspend        = s3c24xx_spi_suspend,
        .resume         = s3c24xx_spi_resume,
 };
diff --git a/drivers/spi/spi_s3c24xx_fiq.S b/drivers/spi/spi_s3c24xx_fiq.S
new file mode 100644 (file)
index 0000000..3793cae
--- /dev/null
@@ -0,0 +1,116 @@
+/* linux/drivers/spi/spi_s3c24xx_fiq.S
+ *
+ * Copyright 2009 Simtec Electronics
+ *     Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C24XX SPI - FIQ pseudo-DMA transfer code
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+
+#include <mach/map.h>
+#include <mach/regs-irq.h>
+#include <plat/regs-spi.h>
+
+#include "spi_s3c24xx_fiq.h"
+
+       .text
+
+       @ entry to these routines is as follows, with the register names
+       @ defined in fiq.h so that they can be shared with the C files which
+       @ setup the calling registers.
+       @
+       @ fiq_rirq      The base of the IRQ registers to find S3C2410_SRCPND
+       @ fiq_rtmp      Temporary register to hold tx/rx data
+       @ fiq_rspi      The base of the SPI register block
+       @ fiq_rtx       The tx buffer pointer
+       @ fiq_rrx       The rx buffer pointer
+       @ fiq_rcount    The number of bytes to move
+
+       @ each entry starts with a word entry of how long it is
+       @ and an offset to the irq acknowledgment word
+
+ENTRY(s3c24xx_spi_fiq_rx)
+s3c24xx_spi_fix_rx:
+       .word   fiq_rx_end - fiq_rx_start
+       .word   fiq_rx_irq_ack - fiq_rx_start
+fiq_rx_start:
+       ldr     fiq_rtmp, fiq_rx_irq_ack
+       str     fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ]
+
+       ldrb    fiq_rtmp, [ fiq_rspi, #  S3C2410_SPRDAT ]
+       strb    fiq_rtmp, [ fiq_rrx ], #1
+
+       mov     fiq_rtmp, #0xff
+       strb    fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ]
+
+       subs    fiq_rcount, fiq_rcount, #1
+       subnes  pc, lr, #4              @@ return, still have work to do
+
+       @@ set IRQ controller so that next op will trigger IRQ
+       mov     fiq_rtmp, #0
+       str     fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD  - S3C24XX_VA_IRQ ]
+       subs    pc, lr, #4
+
+fiq_rx_irq_ack:
+       .word   0
+fiq_rx_end:
+
+ENTRY(s3c24xx_spi_fiq_txrx)
+s3c24xx_spi_fiq_txrx:
+       .word   fiq_txrx_end - fiq_txrx_start
+       .word   fiq_txrx_irq_ack - fiq_txrx_start
+fiq_txrx_start:
+
+       ldrb    fiq_rtmp, [ fiq_rspi, #  S3C2410_SPRDAT ]
+       strb    fiq_rtmp, [ fiq_rrx ], #1
+
+       ldr     fiq_rtmp, fiq_txrx_irq_ack
+       str     fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ]
+
+       ldrb    fiq_rtmp, [ fiq_rtx ], #1
+       strb    fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ]
+
+       subs    fiq_rcount, fiq_rcount, #1
+       subnes  pc, lr, #4              @@ return, still have work to do
+
+       mov     fiq_rtmp, #0
+       str     fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD  - S3C24XX_VA_IRQ ]
+       subs    pc, lr, #4
+
+fiq_txrx_irq_ack:
+       .word   0
+
+fiq_txrx_end:
+
+ENTRY(s3c24xx_spi_fiq_tx)
+s3c24xx_spi_fix_tx:
+       .word   fiq_tx_end - fiq_tx_start
+       .word   fiq_tx_irq_ack - fiq_tx_start
+fiq_tx_start:
+       ldrb    fiq_rtmp, [ fiq_rspi, #  S3C2410_SPRDAT ]
+
+       ldr     fiq_rtmp, fiq_tx_irq_ack
+       str     fiq_rtmp, [ fiq_rirq, # S3C2410_SRCPND - S3C24XX_VA_IRQ ]
+
+       ldrb    fiq_rtmp, [ fiq_rtx ], #1
+       strb    fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ]
+
+       subs    fiq_rcount, fiq_rcount, #1
+       subnes  pc, lr, #4              @@ return, still have work to do
+
+       mov     fiq_rtmp, #0
+       str     fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD  - S3C24XX_VA_IRQ ]
+       subs    pc, lr, #4
+
+fiq_tx_irq_ack:
+       .word   0
+
+fiq_tx_end:
+
+       .end
diff --git a/drivers/spi/spi_s3c24xx_fiq.h b/drivers/spi/spi_s3c24xx_fiq.h
new file mode 100644 (file)
index 0000000..a5950bb
--- /dev/null
@@ -0,0 +1,26 @@
+/* linux/drivers/spi/spi_s3c24xx_fiq.h
+ *
+ * Copyright 2009 Simtec Electronics
+ *     Ben Dooks <ben@simtec.co.uk>
+ *
+ * S3C24XX SPI - FIQ pseudo-DMA transfer support
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+/* We have R8 through R13 to play with */
+
+#ifdef __ASSEMBLY__
+#define __REG_NR(x)     r##x
+#else
+#define __REG_NR(x)     (x)
+#endif
+
+#define fiq_rspi       __REG_NR(8)
+#define fiq_rtmp       __REG_NR(9)
+#define fiq_rrx                __REG_NR(10)
+#define fiq_rtx                __REG_NR(11)
+#define fiq_rcount     __REG_NR(12)
+#define fiq_rirq       __REG_NR(13)
diff --git a/drivers/spi/spi_s3c64xx.c b/drivers/spi/spi_s3c64xx.c
new file mode 100644 (file)
index 0000000..88a456d
--- /dev/null
@@ -0,0 +1,1196 @@
+/* linux/drivers/spi/spi_s3c64xx.c
+ *
+ * Copyright (C) 2009 Samsung Electronics Ltd.
+ *     Jaswinder Singh <jassi.brar@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/workqueue.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+
+#include <mach/dma.h>
+#include <plat/spi.h>
+
+/* Registers and bit-fields */
+
+#define S3C64XX_SPI_CH_CFG             0x00
+#define S3C64XX_SPI_CLK_CFG            0x04
+#define S3C64XX_SPI_MODE_CFG   0x08
+#define S3C64XX_SPI_SLAVE_SEL  0x0C
+#define S3C64XX_SPI_INT_EN             0x10
+#define S3C64XX_SPI_STATUS             0x14
+#define S3C64XX_SPI_TX_DATA            0x18
+#define S3C64XX_SPI_RX_DATA            0x1C
+#define S3C64XX_SPI_PACKET_CNT 0x20
+#define S3C64XX_SPI_PENDING_CLR        0x24
+#define S3C64XX_SPI_SWAP_CFG   0x28
+#define S3C64XX_SPI_FB_CLK             0x2C
+
+#define S3C64XX_SPI_CH_HS_EN           (1<<6)  /* High Speed Enable */
+#define S3C64XX_SPI_CH_SW_RST          (1<<5)
+#define S3C64XX_SPI_CH_SLAVE           (1<<4)
+#define S3C64XX_SPI_CPOL_L             (1<<3)
+#define S3C64XX_SPI_CPHA_B             (1<<2)
+#define S3C64XX_SPI_CH_RXCH_ON         (1<<1)
+#define S3C64XX_SPI_CH_TXCH_ON         (1<<0)
+
+#define S3C64XX_SPI_CLKSEL_SRCMSK      (3<<9)
+#define S3C64XX_SPI_CLKSEL_SRCSHFT     9
+#define S3C64XX_SPI_ENCLK_ENABLE       (1<<8)
+#define S3C64XX_SPI_PSR_MASK           0xff
+
+#define S3C64XX_SPI_MODE_CH_TSZ_BYTE           (0<<29)
+#define S3C64XX_SPI_MODE_CH_TSZ_HALFWORD       (1<<29)
+#define S3C64XX_SPI_MODE_CH_TSZ_WORD           (2<<29)
+#define S3C64XX_SPI_MODE_CH_TSZ_MASK           (3<<29)
+#define S3C64XX_SPI_MODE_BUS_TSZ_BYTE          (0<<17)
+#define S3C64XX_SPI_MODE_BUS_TSZ_HALFWORD      (1<<17)
+#define S3C64XX_SPI_MODE_BUS_TSZ_WORD          (2<<17)
+#define S3C64XX_SPI_MODE_BUS_TSZ_MASK          (3<<17)
+#define S3C64XX_SPI_MODE_RXDMA_ON              (1<<2)
+#define S3C64XX_SPI_MODE_TXDMA_ON              (1<<1)
+#define S3C64XX_SPI_MODE_4BURST                        (1<<0)
+
+#define S3C64XX_SPI_SLAVE_AUTO                 (1<<1)
+#define S3C64XX_SPI_SLAVE_SIG_INACT            (1<<0)
+
+#define S3C64XX_SPI_ACT(c) writel(0, (c)->regs + S3C64XX_SPI_SLAVE_SEL)
+
+#define S3C64XX_SPI_DEACT(c) writel(S3C64XX_SPI_SLAVE_SIG_INACT, \
+                                       (c)->regs + S3C64XX_SPI_SLAVE_SEL)
+
+#define S3C64XX_SPI_INT_TRAILING_EN            (1<<6)
+#define S3C64XX_SPI_INT_RX_OVERRUN_EN          (1<<5)
+#define S3C64XX_SPI_INT_RX_UNDERRUN_EN         (1<<4)
+#define S3C64XX_SPI_INT_TX_OVERRUN_EN          (1<<3)
+#define S3C64XX_SPI_INT_TX_UNDERRUN_EN         (1<<2)
+#define S3C64XX_SPI_INT_RX_FIFORDY_EN          (1<<1)
+#define S3C64XX_SPI_INT_TX_FIFORDY_EN          (1<<0)
+
+#define S3C64XX_SPI_ST_RX_OVERRUN_ERR          (1<<5)
+#define S3C64XX_SPI_ST_RX_UNDERRUN_ERR (1<<4)
+#define S3C64XX_SPI_ST_TX_OVERRUN_ERR          (1<<3)
+#define S3C64XX_SPI_ST_TX_UNDERRUN_ERR (1<<2)
+#define S3C64XX_SPI_ST_RX_FIFORDY              (1<<1)
+#define S3C64XX_SPI_ST_TX_FIFORDY              (1<<0)
+
+#define S3C64XX_SPI_PACKET_CNT_EN              (1<<16)
+
+#define S3C64XX_SPI_PND_TX_UNDERRUN_CLR                (1<<4)
+#define S3C64XX_SPI_PND_TX_OVERRUN_CLR         (1<<3)
+#define S3C64XX_SPI_PND_RX_UNDERRUN_CLR                (1<<2)
+#define S3C64XX_SPI_PND_RX_OVERRUN_CLR         (1<<1)
+#define S3C64XX_SPI_PND_TRAILING_CLR           (1<<0)
+
+#define S3C64XX_SPI_SWAP_RX_HALF_WORD          (1<<7)
+#define S3C64XX_SPI_SWAP_RX_BYTE               (1<<6)
+#define S3C64XX_SPI_SWAP_RX_BIT                        (1<<5)
+#define S3C64XX_SPI_SWAP_RX_EN                 (1<<4)
+#define S3C64XX_SPI_SWAP_TX_HALF_WORD          (1<<3)
+#define S3C64XX_SPI_SWAP_TX_BYTE               (1<<2)
+#define S3C64XX_SPI_SWAP_TX_BIT                        (1<<1)
+#define S3C64XX_SPI_SWAP_TX_EN                 (1<<0)
+
+#define S3C64XX_SPI_FBCLK_MSK          (3<<0)
+
+#define S3C64XX_SPI_ST_TRLCNTZ(v, i) ((((v) >> (i)->rx_lvl_offset) & \
+                                       (((i)->fifo_lvl_mask + 1))) \
+                                       ? 1 : 0)
+
+#define S3C64XX_SPI_ST_TX_DONE(v, i) ((((v) >> (i)->rx_lvl_offset) & \
+                                       (((i)->fifo_lvl_mask + 1) << 1)) \
+                                       ? 1 : 0)
+#define TX_FIFO_LVL(v, i) (((v) >> 6) & (i)->fifo_lvl_mask)
+#define RX_FIFO_LVL(v, i) (((v) >> (i)->rx_lvl_offset) & (i)->fifo_lvl_mask)
+
+#define S3C64XX_SPI_MAX_TRAILCNT       0x3ff
+#define S3C64XX_SPI_TRAILCNT_OFF       19
+
+#define S3C64XX_SPI_TRAILCNT           S3C64XX_SPI_MAX_TRAILCNT
+
+#define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t)
+
+#define SUSPND    (1<<0)
+#define SPIBUSY   (1<<1)
+#define RXBUSY    (1<<2)
+#define TXBUSY    (1<<3)
+
+/**
+ * struct s3c64xx_spi_driver_data - Runtime info holder for SPI driver.
+ * @clk: Pointer to the spi clock.
+ * @master: Pointer to the SPI Protocol master.
+ * @workqueue: Work queue for the SPI xfer requests.
+ * @cntrlr_info: Platform specific data for the controller this driver manages.
+ * @tgl_spi: Pointer to the last CS left untoggled by the cs_change hint.
+ * @work: Work
+ * @queue: To log SPI xfer requests.
+ * @lock: Controller specific lock.
+ * @state: Set of FLAGS to indicate status.
+ * @rx_dmach: Controller's DMA channel for Rx.
+ * @tx_dmach: Controller's DMA channel for Tx.
+ * @sfr_start: BUS address of SPI controller regs.
+ * @regs: Pointer to ioremap'ed controller registers.
+ * @xfer_completion: To indicate completion of xfer task.
+ * @cur_mode: Stores the active configuration of the controller.
+ * @cur_bpw: Stores the active bits per word settings.
+ * @cur_speed: Stores the active xfer clock speed.
+ */
+struct s3c64xx_spi_driver_data {
+       void __iomem                    *regs;
+       struct clk                      *clk;
+       struct platform_device          *pdev;
+       struct spi_master               *master;
+       struct workqueue_struct         *workqueue;
+       struct s3c64xx_spi_cntrlr_info  *cntrlr_info;
+       struct spi_device               *tgl_spi;
+       struct work_struct              work;
+       struct list_head                queue;
+       spinlock_t                      lock;
+       enum dma_ch                     rx_dmach;
+       enum dma_ch                     tx_dmach;
+       unsigned long                   sfr_start;
+       struct completion               xfer_completion;
+       unsigned                        state;
+       unsigned                        cur_mode, cur_bpw;
+       unsigned                        cur_speed;
+};
+
+static struct s3c2410_dma_client s3c64xx_spi_dma_client = {
+       .name = "samsung-spi-dma",
+};
+
+static void flush_fifo(struct s3c64xx_spi_driver_data *sdd)
+{
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       void __iomem *regs = sdd->regs;
+       unsigned long loops;
+       u32 val;
+
+       writel(0, regs + S3C64XX_SPI_PACKET_CNT);
+
+       val = readl(regs + S3C64XX_SPI_CH_CFG);
+       val |= S3C64XX_SPI_CH_SW_RST;
+       val &= ~S3C64XX_SPI_CH_HS_EN;
+       writel(val, regs + S3C64XX_SPI_CH_CFG);
+
+       /* Flush TxFIFO*/
+       loops = msecs_to_loops(1);
+       do {
+               val = readl(regs + S3C64XX_SPI_STATUS);
+       } while (TX_FIFO_LVL(val, sci) && loops--);
+
+       /* Flush RxFIFO*/
+       loops = msecs_to_loops(1);
+       do {
+               val = readl(regs + S3C64XX_SPI_STATUS);
+               if (RX_FIFO_LVL(val, sci))
+                       readl(regs + S3C64XX_SPI_RX_DATA);
+               else
+                       break;
+       } while (loops--);
+
+       val = readl(regs + S3C64XX_SPI_CH_CFG);
+       val &= ~S3C64XX_SPI_CH_SW_RST;
+       writel(val, regs + S3C64XX_SPI_CH_CFG);
+
+       val = readl(regs + S3C64XX_SPI_MODE_CFG);
+       val &= ~(S3C64XX_SPI_MODE_TXDMA_ON | S3C64XX_SPI_MODE_RXDMA_ON);
+       writel(val, regs + S3C64XX_SPI_MODE_CFG);
+
+       val = readl(regs + S3C64XX_SPI_CH_CFG);
+       val &= ~(S3C64XX_SPI_CH_RXCH_ON | S3C64XX_SPI_CH_TXCH_ON);
+       writel(val, regs + S3C64XX_SPI_CH_CFG);
+}
+
+static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,
+                               struct spi_device *spi,
+                               struct spi_transfer *xfer, int dma_mode)
+{
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       void __iomem *regs = sdd->regs;
+       u32 modecfg, chcfg;
+
+       modecfg = readl(regs + S3C64XX_SPI_MODE_CFG);
+       modecfg &= ~(S3C64XX_SPI_MODE_TXDMA_ON | S3C64XX_SPI_MODE_RXDMA_ON);
+
+       chcfg = readl(regs + S3C64XX_SPI_CH_CFG);
+       chcfg &= ~S3C64XX_SPI_CH_TXCH_ON;
+
+       if (dma_mode) {
+               chcfg &= ~S3C64XX_SPI_CH_RXCH_ON;
+       } else {
+               /* Always shift in data in FIFO, even if xfer is Tx only,
+                * this helps setting PCKT_CNT value for generating clocks
+                * as exactly needed.
+                */
+               chcfg |= S3C64XX_SPI_CH_RXCH_ON;
+               writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff)
+                                       | S3C64XX_SPI_PACKET_CNT_EN,
+                                       regs + S3C64XX_SPI_PACKET_CNT);
+       }
+
+       if (xfer->tx_buf != NULL) {
+               sdd->state |= TXBUSY;
+               chcfg |= S3C64XX_SPI_CH_TXCH_ON;
+               if (dma_mode) {
+                       modecfg |= S3C64XX_SPI_MODE_TXDMA_ON;
+                       s3c2410_dma_config(sdd->tx_dmach, 1);
+                       s3c2410_dma_enqueue(sdd->tx_dmach, (void *)sdd,
+                                               xfer->tx_dma, xfer->len);
+                       s3c2410_dma_ctrl(sdd->tx_dmach, S3C2410_DMAOP_START);
+               } else {
+                       unsigned char *buf = (unsigned char *) xfer->tx_buf;
+                       int i = 0;
+                       while (i < xfer->len)
+                               writeb(buf[i++], regs + S3C64XX_SPI_TX_DATA);
+               }
+       }
+
+       if (xfer->rx_buf != NULL) {
+               sdd->state |= RXBUSY;
+
+               if (sci->high_speed && sdd->cur_speed >= 30000000UL
+                                       && !(sdd->cur_mode & SPI_CPHA))
+                       chcfg |= S3C64XX_SPI_CH_HS_EN;
+
+               if (dma_mode) {
+                       modecfg |= S3C64XX_SPI_MODE_RXDMA_ON;
+                       chcfg |= S3C64XX_SPI_CH_RXCH_ON;
+                       writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff)
+                                       | S3C64XX_SPI_PACKET_CNT_EN,
+                                       regs + S3C64XX_SPI_PACKET_CNT);
+                       s3c2410_dma_config(sdd->rx_dmach, 1);
+                       s3c2410_dma_enqueue(sdd->rx_dmach, (void *)sdd,
+                                               xfer->rx_dma, xfer->len);
+                       s3c2410_dma_ctrl(sdd->rx_dmach, S3C2410_DMAOP_START);
+               }
+       }
+
+       writel(modecfg, regs + S3C64XX_SPI_MODE_CFG);
+       writel(chcfg, regs + S3C64XX_SPI_CH_CFG);
+}
+
+static inline void enable_cs(struct s3c64xx_spi_driver_data *sdd,
+                                               struct spi_device *spi)
+{
+       struct s3c64xx_spi_csinfo *cs;
+
+       if (sdd->tgl_spi != NULL) { /* If last device toggled after mssg */
+               if (sdd->tgl_spi != spi) { /* if last mssg on diff device */
+                       /* Deselect the last toggled device */
+                       cs = sdd->tgl_spi->controller_data;
+                       cs->set_level(spi->mode & SPI_CS_HIGH ? 0 : 1);
+               }
+               sdd->tgl_spi = NULL;
+       }
+
+       cs = spi->controller_data;
+       cs->set_level(spi->mode & SPI_CS_HIGH ? 1 : 0);
+}
+
+static int wait_for_xfer(struct s3c64xx_spi_driver_data *sdd,
+                               struct spi_transfer *xfer, int dma_mode)
+{
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       void __iomem *regs = sdd->regs;
+       unsigned long val;
+       int ms;
+
+       /* millisecs to xfer 'len' bytes @ 'cur_speed' */
+       ms = xfer->len * 8 * 1000 / sdd->cur_speed;
+       ms += 5; /* some tolerance */
+
+       if (dma_mode) {
+               val = msecs_to_jiffies(ms) + 10;
+               val = wait_for_completion_timeout(&sdd->xfer_completion, val);
+       } else {
+               val = msecs_to_loops(ms);
+               do {
+                       val = readl(regs + S3C64XX_SPI_STATUS);
+               } while (RX_FIFO_LVL(val, sci) < xfer->len && --val);
+       }
+
+       if (!val)
+               return -EIO;
+
+       if (dma_mode) {
+               u32 status;
+
+               /*
+                * DmaTx returns after simply writing data in the FIFO,
+                * w/o waiting for real transmission on the bus to finish.
+                * DmaRx returns only after Dma read data from FIFO which
+                * needs bus transmission to finish, so we don't worry if
+                * Xfer involved Rx(with or without Tx).
+                */
+               if (xfer->rx_buf == NULL) {
+                       val = msecs_to_loops(10);
+                       status = readl(regs + S3C64XX_SPI_STATUS);
+                       while ((TX_FIFO_LVL(status, sci)
+                               || !S3C64XX_SPI_ST_TX_DONE(status, sci))
+                                       && --val) {
+                               cpu_relax();
+                               status = readl(regs + S3C64XX_SPI_STATUS);
+                       }
+
+                       if (!val)
+                               return -EIO;
+               }
+       } else {
+               unsigned char *buf;
+               int i;
+
+               /* If it was only Tx */
+               if (xfer->rx_buf == NULL) {
+                       sdd->state &= ~TXBUSY;
+                       return 0;
+               }
+
+               i = 0;
+               buf = xfer->rx_buf;
+               while (i < xfer->len)
+                       buf[i++] = readb(regs + S3C64XX_SPI_RX_DATA);
+
+               sdd->state &= ~RXBUSY;
+       }
+
+       return 0;
+}
+
+static inline void disable_cs(struct s3c64xx_spi_driver_data *sdd,
+                                               struct spi_device *spi)
+{
+       struct s3c64xx_spi_csinfo *cs = spi->controller_data;
+
+       if (sdd->tgl_spi == spi)
+               sdd->tgl_spi = NULL;
+
+       cs->set_level(spi->mode & SPI_CS_HIGH ? 0 : 1);
+}
+
+static void s3c64xx_spi_config(struct s3c64xx_spi_driver_data *sdd)
+{
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       void __iomem *regs = sdd->regs;
+       u32 val;
+
+       /* Disable Clock */
+       val = readl(regs + S3C64XX_SPI_CLK_CFG);
+       val &= ~S3C64XX_SPI_ENCLK_ENABLE;
+       writel(val, regs + S3C64XX_SPI_CLK_CFG);
+
+       /* Set Polarity and Phase */
+       val = readl(regs + S3C64XX_SPI_CH_CFG);
+       val &= ~(S3C64XX_SPI_CH_SLAVE |
+                       S3C64XX_SPI_CPOL_L |
+                       S3C64XX_SPI_CPHA_B);
+
+       if (sdd->cur_mode & SPI_CPOL)
+               val |= S3C64XX_SPI_CPOL_L;
+
+       if (sdd->cur_mode & SPI_CPHA)
+               val |= S3C64XX_SPI_CPHA_B;
+
+       writel(val, regs + S3C64XX_SPI_CH_CFG);
+
+       /* Set Channel & DMA Mode */
+       val = readl(regs + S3C64XX_SPI_MODE_CFG);
+       val &= ~(S3C64XX_SPI_MODE_BUS_TSZ_MASK
+                       | S3C64XX_SPI_MODE_CH_TSZ_MASK);
+
+       switch (sdd->cur_bpw) {
+       case 32:
+               val |= S3C64XX_SPI_MODE_BUS_TSZ_WORD;
+               break;
+       case 16:
+               val |= S3C64XX_SPI_MODE_BUS_TSZ_HALFWORD;
+               break;
+       default:
+               val |= S3C64XX_SPI_MODE_BUS_TSZ_BYTE;
+               break;
+       }
+       val |= S3C64XX_SPI_MODE_CH_TSZ_BYTE; /* Always 8bits wide */
+
+       writel(val, regs + S3C64XX_SPI_MODE_CFG);
+
+       /* Configure Clock */
+       val = readl(regs + S3C64XX_SPI_CLK_CFG);
+       val &= ~S3C64XX_SPI_PSR_MASK;
+       val |= ((clk_get_rate(sci->src_clk) / sdd->cur_speed / 2 - 1)
+                       & S3C64XX_SPI_PSR_MASK);
+       writel(val, regs + S3C64XX_SPI_CLK_CFG);
+
+       /* Enable Clock */
+       val = readl(regs + S3C64XX_SPI_CLK_CFG);
+       val |= S3C64XX_SPI_ENCLK_ENABLE;
+       writel(val, regs + S3C64XX_SPI_CLK_CFG);
+}
+
+void s3c64xx_spi_dma_rxcb(struct s3c2410_dma_chan *chan, void *buf_id,
+                               int size, enum s3c2410_dma_buffresult res)
+{
+       struct s3c64xx_spi_driver_data *sdd = buf_id;
+       unsigned long flags;
+
+       spin_lock_irqsave(&sdd->lock, flags);
+
+       if (res == S3C2410_RES_OK)
+               sdd->state &= ~RXBUSY;
+       else
+               dev_err(&sdd->pdev->dev, "DmaAbrtRx-%d\n", size);
+
+       /* If the other done */
+       if (!(sdd->state & TXBUSY))
+               complete(&sdd->xfer_completion);
+
+       spin_unlock_irqrestore(&sdd->lock, flags);
+}
+
+void s3c64xx_spi_dma_txcb(struct s3c2410_dma_chan *chan, void *buf_id,
+                               int size, enum s3c2410_dma_buffresult res)
+{
+       struct s3c64xx_spi_driver_data *sdd = buf_id;
+       unsigned long flags;
+
+       spin_lock_irqsave(&sdd->lock, flags);
+
+       if (res == S3C2410_RES_OK)
+               sdd->state &= ~TXBUSY;
+       else
+               dev_err(&sdd->pdev->dev, "DmaAbrtTx-%d \n", size);
+
+       /* If the other done */
+       if (!(sdd->state & RXBUSY))
+               complete(&sdd->xfer_completion);
+
+       spin_unlock_irqrestore(&sdd->lock, flags);
+}
+
+#define XFER_DMAADDR_INVALID DMA_BIT_MASK(32)
+
+static int s3c64xx_spi_map_mssg(struct s3c64xx_spi_driver_data *sdd,
+                                               struct spi_message *msg)
+{
+       struct device *dev = &sdd->pdev->dev;
+       struct spi_transfer *xfer;
+
+       if (msg->is_dma_mapped)
+               return 0;
+
+       /* First mark all xfer unmapped */
+       list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+               xfer->rx_dma = XFER_DMAADDR_INVALID;
+               xfer->tx_dma = XFER_DMAADDR_INVALID;
+       }
+
+       /* Map until end or first fail */
+       list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+
+               if (xfer->tx_buf != NULL) {
+                       xfer->tx_dma = dma_map_single(dev, xfer->tx_buf,
+                                               xfer->len, DMA_TO_DEVICE);
+                       if (dma_mapping_error(dev, xfer->tx_dma)) {
+                               dev_err(dev, "dma_map_single Tx failed\n");
+                               xfer->tx_dma = XFER_DMAADDR_INVALID;
+                               return -ENOMEM;
+                       }
+               }
+
+               if (xfer->rx_buf != NULL) {
+                       xfer->rx_dma = dma_map_single(dev, xfer->rx_buf,
+                                               xfer->len, DMA_FROM_DEVICE);
+                       if (dma_mapping_error(dev, xfer->rx_dma)) {
+                               dev_err(dev, "dma_map_single Rx failed\n");
+                               dma_unmap_single(dev, xfer->tx_dma,
+                                               xfer->len, DMA_TO_DEVICE);
+                               xfer->tx_dma = XFER_DMAADDR_INVALID;
+                               xfer->rx_dma = XFER_DMAADDR_INVALID;
+                               return -ENOMEM;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+static void s3c64xx_spi_unmap_mssg(struct s3c64xx_spi_driver_data *sdd,
+                                               struct spi_message *msg)
+{
+       struct device *dev = &sdd->pdev->dev;
+       struct spi_transfer *xfer;
+
+       if (msg->is_dma_mapped)
+               return;
+
+       list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+
+               if (xfer->rx_buf != NULL
+                               && xfer->rx_dma != XFER_DMAADDR_INVALID)
+                       dma_unmap_single(dev, xfer->rx_dma,
+                                               xfer->len, DMA_FROM_DEVICE);
+
+               if (xfer->tx_buf != NULL
+                               && xfer->tx_dma != XFER_DMAADDR_INVALID)
+                       dma_unmap_single(dev, xfer->tx_dma,
+                                               xfer->len, DMA_TO_DEVICE);
+       }
+}
+
+static void handle_msg(struct s3c64xx_spi_driver_data *sdd,
+                                       struct spi_message *msg)
+{
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       struct spi_device *spi = msg->spi;
+       struct s3c64xx_spi_csinfo *cs = spi->controller_data;
+       struct spi_transfer *xfer;
+       int status = 0, cs_toggle = 0;
+       u32 speed;
+       u8 bpw;
+
+       /* If Master's(controller) state differs from that needed by Slave */
+       if (sdd->cur_speed != spi->max_speed_hz
+                       || sdd->cur_mode != spi->mode
+                       || sdd->cur_bpw != spi->bits_per_word) {
+               sdd->cur_bpw = spi->bits_per_word;
+               sdd->cur_speed = spi->max_speed_hz;
+               sdd->cur_mode = spi->mode;
+               s3c64xx_spi_config(sdd);
+       }
+
+       /* Map all the transfers if needed */
+       if (s3c64xx_spi_map_mssg(sdd, msg)) {
+               dev_err(&spi->dev,
+                       "Xfer: Unable to map message buffers!\n");
+               status = -ENOMEM;
+               goto out;
+       }
+
+       /* Configure feedback delay */
+       writel(cs->fb_delay & 0x3, sdd->regs + S3C64XX_SPI_FB_CLK);
+
+       list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+
+               unsigned long flags;
+               int use_dma;
+
+               INIT_COMPLETION(sdd->xfer_completion);
+
+               /* Only BPW and Speed may change across transfers */
+               bpw = xfer->bits_per_word ? : spi->bits_per_word;
+               speed = xfer->speed_hz ? : spi->max_speed_hz;
+
+               if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) {
+                       sdd->cur_bpw = bpw;
+                       sdd->cur_speed = speed;
+                       s3c64xx_spi_config(sdd);
+               }
+
+               /* Polling method for xfers not bigger than FIFO capacity */
+               if (xfer->len <= ((sci->fifo_lvl_mask >> 1) + 1))
+                       use_dma = 0;
+               else
+                       use_dma = 1;
+
+               spin_lock_irqsave(&sdd->lock, flags);
+
+               /* Pending only which is to be done */
+               sdd->state &= ~RXBUSY;
+               sdd->state &= ~TXBUSY;
+
+               enable_datapath(sdd, spi, xfer, use_dma);
+
+               /* Slave Select */
+               enable_cs(sdd, spi);
+
+               /* Start the signals */
+               S3C64XX_SPI_ACT(sdd);
+
+               spin_unlock_irqrestore(&sdd->lock, flags);
+
+               status = wait_for_xfer(sdd, xfer, use_dma);
+
+               /* Quiese the signals */
+               S3C64XX_SPI_DEACT(sdd);
+
+               if (status) {
+                       dev_err(&spi->dev, "I/O Error: \
+                               rx-%d tx-%d res:rx-%c tx-%c len-%d\n",
+                               xfer->rx_buf ? 1 : 0, xfer->tx_buf ? 1 : 0,
+                               (sdd->state & RXBUSY) ? 'f' : 'p',
+                               (sdd->state & TXBUSY) ? 'f' : 'p',
+                               xfer->len);
+
+                       if (use_dma) {
+                               if (xfer->tx_buf != NULL
+                                               && (sdd->state & TXBUSY))
+                                       s3c2410_dma_ctrl(sdd->tx_dmach,
+                                                       S3C2410_DMAOP_FLUSH);
+                               if (xfer->rx_buf != NULL
+                                               && (sdd->state & RXBUSY))
+                                       s3c2410_dma_ctrl(sdd->rx_dmach,
+                                                       S3C2410_DMAOP_FLUSH);
+                       }
+
+                       goto out;
+               }
+
+               if (xfer->delay_usecs)
+                       udelay(xfer->delay_usecs);
+
+               if (xfer->cs_change) {
+                       /* Hint that the next mssg is gonna be
+                          for the same device */
+                       if (list_is_last(&xfer->transfer_list,
+                                               &msg->transfers))
+                               cs_toggle = 1;
+                       else
+                               disable_cs(sdd, spi);
+               }
+
+               msg->actual_length += xfer->len;
+
+               flush_fifo(sdd);
+       }
+
+out:
+       if (!cs_toggle || status)
+               disable_cs(sdd, spi);
+       else
+               sdd->tgl_spi = spi;
+
+       s3c64xx_spi_unmap_mssg(sdd, msg);
+
+       msg->status = status;
+
+       if (msg->complete)
+               msg->complete(msg->context);
+}
+
+static int acquire_dma(struct s3c64xx_spi_driver_data *sdd)
+{
+       if (s3c2410_dma_request(sdd->rx_dmach,
+                                       &s3c64xx_spi_dma_client, NULL) < 0) {
+               dev_err(&sdd->pdev->dev, "cannot get RxDMA\n");
+               return 0;
+       }
+       s3c2410_dma_set_buffdone_fn(sdd->rx_dmach, s3c64xx_spi_dma_rxcb);
+       s3c2410_dma_devconfig(sdd->rx_dmach, S3C2410_DMASRC_HW,
+                                       sdd->sfr_start + S3C64XX_SPI_RX_DATA);
+
+       if (s3c2410_dma_request(sdd->tx_dmach,
+                                       &s3c64xx_spi_dma_client, NULL) < 0) {
+               dev_err(&sdd->pdev->dev, "cannot get TxDMA\n");
+               s3c2410_dma_free(sdd->rx_dmach, &s3c64xx_spi_dma_client);
+               return 0;
+       }
+       s3c2410_dma_set_buffdone_fn(sdd->tx_dmach, s3c64xx_spi_dma_txcb);
+       s3c2410_dma_devconfig(sdd->tx_dmach, S3C2410_DMASRC_MEM,
+                                       sdd->sfr_start + S3C64XX_SPI_TX_DATA);
+
+       return 1;
+}
+
+static void s3c64xx_spi_work(struct work_struct *work)
+{
+       struct s3c64xx_spi_driver_data *sdd = container_of(work,
+                                       struct s3c64xx_spi_driver_data, work);
+       unsigned long flags;
+
+       /* Acquire DMA channels */
+       while (!acquire_dma(sdd))
+               msleep(10);
+
+       spin_lock_irqsave(&sdd->lock, flags);
+
+       while (!list_empty(&sdd->queue)
+                               && !(sdd->state & SUSPND)) {
+
+               struct spi_message *msg;
+
+               msg = container_of(sdd->queue.next, struct spi_message, queue);
+
+               list_del_init(&msg->queue);
+
+               /* Set Xfer busy flag */
+               sdd->state |= SPIBUSY;
+
+               spin_unlock_irqrestore(&sdd->lock, flags);
+
+               handle_msg(sdd, msg);
+
+               spin_lock_irqsave(&sdd->lock, flags);
+
+               sdd->state &= ~SPIBUSY;
+       }
+
+       spin_unlock_irqrestore(&sdd->lock, flags);
+
+       /* Free DMA channels */
+       s3c2410_dma_free(sdd->tx_dmach, &s3c64xx_spi_dma_client);
+       s3c2410_dma_free(sdd->rx_dmach, &s3c64xx_spi_dma_client);
+}
+
+static int s3c64xx_spi_transfer(struct spi_device *spi,
+                                               struct spi_message *msg)
+{
+       struct s3c64xx_spi_driver_data *sdd;
+       unsigned long flags;
+
+       sdd = spi_master_get_devdata(spi->master);
+
+       spin_lock_irqsave(&sdd->lock, flags);
+
+       if (sdd->state & SUSPND) {
+               spin_unlock_irqrestore(&sdd->lock, flags);
+               return -ESHUTDOWN;
+       }
+
+       msg->status = -EINPROGRESS;
+       msg->actual_length = 0;
+
+       list_add_tail(&msg->queue, &sdd->queue);
+
+       queue_work(sdd->workqueue, &sdd->work);
+
+       spin_unlock_irqrestore(&sdd->lock, flags);
+
+       return 0;
+}
+
+/*
+ * Here we only check the validity of requested configuration
+ * and save the configuration in a local data-structure.
+ * The controller is actually configured only just before we
+ * get a message to transfer.
+ */
+static int s3c64xx_spi_setup(struct spi_device *spi)
+{
+       struct s3c64xx_spi_csinfo *cs = spi->controller_data;
+       struct s3c64xx_spi_driver_data *sdd;
+       struct s3c64xx_spi_cntrlr_info *sci;
+       struct spi_message *msg;
+       u32 psr, speed;
+       unsigned long flags;
+       int err = 0;
+
+       if (cs == NULL || cs->set_level == NULL) {
+               dev_err(&spi->dev, "No CS for SPI(%d)\n", spi->chip_select);
+               return -ENODEV;
+       }
+
+       sdd = spi_master_get_devdata(spi->master);
+       sci = sdd->cntrlr_info;
+
+       spin_lock_irqsave(&sdd->lock, flags);
+
+       list_for_each_entry(msg, &sdd->queue, queue) {
+               /* Is some mssg is already queued for this device */
+               if (msg->spi == spi) {
+                       dev_err(&spi->dev,
+                               "setup: attempt while mssg in queue!\n");
+                       spin_unlock_irqrestore(&sdd->lock, flags);
+                       return -EBUSY;
+               }
+       }
+
+       if (sdd->state & SUSPND) {
+               spin_unlock_irqrestore(&sdd->lock, flags);
+               dev_err(&spi->dev,
+                       "setup: SPI-%d not active!\n", spi->master->bus_num);
+               return -ESHUTDOWN;
+       }
+
+       spin_unlock_irqrestore(&sdd->lock, flags);
+
+       if (spi->bits_per_word != 8
+                       && spi->bits_per_word != 16
+                       && spi->bits_per_word != 32) {
+               dev_err(&spi->dev, "setup: %dbits/wrd not supported!\n",
+                                                       spi->bits_per_word);
+               err = -EINVAL;
+               goto setup_exit;
+       }
+
+       /* Check if we can provide the requested rate */
+       speed = clk_get_rate(sci->src_clk) / 2 / (0 + 1); /* Max possible */
+
+       if (spi->max_speed_hz > speed)
+               spi->max_speed_hz = speed;
+
+       psr = clk_get_rate(sci->src_clk) / 2 / spi->max_speed_hz - 1;
+       psr &= S3C64XX_SPI_PSR_MASK;
+       if (psr == S3C64XX_SPI_PSR_MASK)
+               psr--;
+
+       speed = clk_get_rate(sci->src_clk) / 2 / (psr + 1);
+       if (spi->max_speed_hz < speed) {
+               if (psr+1 < S3C64XX_SPI_PSR_MASK) {
+                       psr++;
+               } else {
+                       err = -EINVAL;
+                       goto setup_exit;
+               }
+       }
+
+       speed = clk_get_rate(sci->src_clk) / 2 / (psr + 1);
+       if (spi->max_speed_hz >= speed)
+               spi->max_speed_hz = speed;
+       else
+               err = -EINVAL;
+
+setup_exit:
+
+       /* setup() returns with device de-selected */
+       disable_cs(sdd, spi);
+
+       return err;
+}
+
+static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel)
+{
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       void __iomem *regs = sdd->regs;
+       unsigned int val;
+
+       sdd->cur_speed = 0;
+
+       S3C64XX_SPI_DEACT(sdd);
+
+       /* Disable Interrupts - we use Polling if not DMA mode */
+       writel(0, regs + S3C64XX_SPI_INT_EN);
+
+       writel(sci->src_clk_nr << S3C64XX_SPI_CLKSEL_SRCSHFT,
+                               regs + S3C64XX_SPI_CLK_CFG);
+       writel(0, regs + S3C64XX_SPI_MODE_CFG);
+       writel(0, regs + S3C64XX_SPI_PACKET_CNT);
+
+       /* Clear any irq pending bits */
+       writel(readl(regs + S3C64XX_SPI_PENDING_CLR),
+                               regs + S3C64XX_SPI_PENDING_CLR);
+
+       writel(0, regs + S3C64XX_SPI_SWAP_CFG);
+
+       val = readl(regs + S3C64XX_SPI_MODE_CFG);
+       val &= ~S3C64XX_SPI_MODE_4BURST;
+       val &= ~(S3C64XX_SPI_MAX_TRAILCNT << S3C64XX_SPI_TRAILCNT_OFF);
+       val |= (S3C64XX_SPI_TRAILCNT << S3C64XX_SPI_TRAILCNT_OFF);
+       writel(val, regs + S3C64XX_SPI_MODE_CFG);
+
+       flush_fifo(sdd);
+}
+
+static int __init s3c64xx_spi_probe(struct platform_device *pdev)
+{
+       struct resource *mem_res, *dmatx_res, *dmarx_res;
+       struct s3c64xx_spi_driver_data *sdd;
+       struct s3c64xx_spi_cntrlr_info *sci;
+       struct spi_master *master;
+       int ret;
+
+       if (pdev->id < 0) {
+               dev_err(&pdev->dev,
+                               "Invalid platform device id-%d\n", pdev->id);
+               return -ENODEV;
+       }
+
+       if (pdev->dev.platform_data == NULL) {
+               dev_err(&pdev->dev, "platform_data missing!\n");
+               return -ENODEV;
+       }
+
+       /* Check for availability of necessary resource */
+
+       dmatx_res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
+       if (dmatx_res == NULL) {
+               dev_err(&pdev->dev, "Unable to get SPI-Tx dma resource\n");
+               return -ENXIO;
+       }
+
+       dmarx_res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
+       if (dmarx_res == NULL) {
+               dev_err(&pdev->dev, "Unable to get SPI-Rx dma resource\n");
+               return -ENXIO;
+       }
+
+       mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (mem_res == NULL) {
+               dev_err(&pdev->dev, "Unable to get SPI MEM resource\n");
+               return -ENXIO;
+       }
+
+       master = spi_alloc_master(&pdev->dev,
+                               sizeof(struct s3c64xx_spi_driver_data));
+       if (master == NULL) {
+               dev_err(&pdev->dev, "Unable to allocate SPI Master\n");
+               return -ENOMEM;
+       }
+
+       sci = pdev->dev.platform_data;
+
+       platform_set_drvdata(pdev, master);
+
+       sdd = spi_master_get_devdata(master);
+       sdd->master = master;
+       sdd->cntrlr_info = sci;
+       sdd->pdev = pdev;
+       sdd->sfr_start = mem_res->start;
+       sdd->tx_dmach = dmatx_res->start;
+       sdd->rx_dmach = dmarx_res->start;
+
+       sdd->cur_bpw = 8;
+
+       master->bus_num = pdev->id;
+       master->setup = s3c64xx_spi_setup;
+       master->transfer = s3c64xx_spi_transfer;
+       master->num_chipselect = sci->num_cs;
+       master->dma_alignment = 8;
+       /* the spi->mode bits understood by this driver: */
+       master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
+
+       if (request_mem_region(mem_res->start,
+                       resource_size(mem_res), pdev->name) == NULL) {
+               dev_err(&pdev->dev, "Req mem region failed\n");
+               ret = -ENXIO;
+               goto err0;
+       }
+
+       sdd->regs = ioremap(mem_res->start, resource_size(mem_res));
+       if (sdd->regs == NULL) {
+               dev_err(&pdev->dev, "Unable to remap IO\n");
+               ret = -ENXIO;
+               goto err1;
+       }
+
+       if (sci->cfg_gpio == NULL || sci->cfg_gpio(pdev)) {
+               dev_err(&pdev->dev, "Unable to config gpio\n");
+               ret = -EBUSY;
+               goto err2;
+       }
+
+       /* Setup clocks */
+       sdd->clk = clk_get(&pdev->dev, "spi");
+       if (IS_ERR(sdd->clk)) {
+               dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
+               ret = PTR_ERR(sdd->clk);
+               goto err3;
+       }
+
+       if (clk_enable(sdd->clk)) {
+               dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
+               ret = -EBUSY;
+               goto err4;
+       }
+
+       if (sci->src_clk_nr == S3C64XX_SPI_SRCCLK_PCLK)
+               sci->src_clk = sdd->clk;
+       else
+               sci->src_clk = clk_get(&pdev->dev, sci->src_clk_name);
+       if (IS_ERR(sci->src_clk)) {
+               dev_err(&pdev->dev,
+                       "Unable to acquire clock '%s'\n", sci->src_clk_name);
+               ret = PTR_ERR(sci->src_clk);
+               goto err5;
+       }
+
+       if (sci->src_clk != sdd->clk && clk_enable(sci->src_clk)) {
+               dev_err(&pdev->dev, "Couldn't enable clock '%s'\n",
+                                                       sci->src_clk_name);
+               ret = -EBUSY;
+               goto err6;
+       }
+
+       sdd->workqueue = create_singlethread_workqueue(
+                                               dev_name(master->dev.parent));
+       if (sdd->workqueue == NULL) {
+               dev_err(&pdev->dev, "Unable to create workqueue\n");
+               ret = -ENOMEM;
+               goto err7;
+       }
+
+       /* Setup Deufult Mode */
+       s3c64xx_spi_hwinit(sdd, pdev->id);
+
+       spin_lock_init(&sdd->lock);
+       init_completion(&sdd->xfer_completion);
+       INIT_WORK(&sdd->work, s3c64xx_spi_work);
+       INIT_LIST_HEAD(&sdd->queue);
+
+       if (spi_register_master(master)) {
+               dev_err(&pdev->dev, "cannot register SPI master\n");
+               ret = -EBUSY;
+               goto err8;
+       }
+
+       dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d \
+                                       with %d Slaves attached\n",
+                                       pdev->id, master->num_chipselect);
+       dev_dbg(&pdev->dev, "\tIOmem=[0x%x-0x%x]\
+                                       \tDMA=[Rx-%d, Tx-%d]\n",
+                                       mem_res->end, mem_res->start,
+                                       sdd->rx_dmach, sdd->tx_dmach);
+
+       return 0;
+
+err8:
+       destroy_workqueue(sdd->workqueue);
+err7:
+       if (sci->src_clk != sdd->clk)
+               clk_disable(sci->src_clk);
+err6:
+       if (sci->src_clk != sdd->clk)
+               clk_put(sci->src_clk);
+err5:
+       clk_disable(sdd->clk);
+err4:
+       clk_put(sdd->clk);
+err3:
+err2:
+       iounmap((void *) sdd->regs);
+err1:
+       release_mem_region(mem_res->start, resource_size(mem_res));
+err0:
+       platform_set_drvdata(pdev, NULL);
+       spi_master_put(master);
+
+       return ret;
+}
+
+static int s3c64xx_spi_remove(struct platform_device *pdev)
+{
+       struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
+       struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       struct resource *mem_res;
+       unsigned long flags;
+
+       spin_lock_irqsave(&sdd->lock, flags);
+       sdd->state |= SUSPND;
+       spin_unlock_irqrestore(&sdd->lock, flags);
+
+       while (sdd->state & SPIBUSY)
+               msleep(10);
+
+       spi_unregister_master(master);
+
+       destroy_workqueue(sdd->workqueue);
+
+       if (sci->src_clk != sdd->clk)
+               clk_disable(sci->src_clk);
+
+       if (sci->src_clk != sdd->clk)
+               clk_put(sci->src_clk);
+
+       clk_disable(sdd->clk);
+       clk_put(sdd->clk);
+
+       iounmap((void *) sdd->regs);
+
+       mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       release_mem_region(mem_res->start, resource_size(mem_res));
+
+       platform_set_drvdata(pdev, NULL);
+       spi_master_put(master);
+
+       return 0;
+}
+
+#ifdef CONFIG_PM
+static int s3c64xx_spi_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
+       struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       struct s3c64xx_spi_csinfo *cs;
+       unsigned long flags;
+
+       spin_lock_irqsave(&sdd->lock, flags);
+       sdd->state |= SUSPND;
+       spin_unlock_irqrestore(&sdd->lock, flags);
+
+       while (sdd->state & SPIBUSY)
+               msleep(10);
+
+       /* Disable the clock */
+       if (sci->src_clk != sdd->clk)
+               clk_disable(sci->src_clk);
+
+       clk_disable(sdd->clk);
+
+       sdd->cur_speed = 0; /* Output Clock is stopped */
+
+       return 0;
+}
+
+static int s3c64xx_spi_resume(struct platform_device *pdev)
+{
+       struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
+       struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
+       struct s3c64xx_spi_cntrlr_info *sci = sdd->cntrlr_info;
+       unsigned long flags;
+
+       sci->cfg_gpio(pdev);
+
+       /* Enable the clock */
+       if (sci->src_clk != sdd->clk)
+               clk_enable(sci->src_clk);
+
+       clk_enable(sdd->clk);
+
+       s3c64xx_spi_hwinit(sdd, pdev->id);
+
+       spin_lock_irqsave(&sdd->lock, flags);
+       sdd->state &= ~SUSPND;
+       spin_unlock_irqrestore(&sdd->lock, flags);
+
+       return 0;
+}
+#else
+#define s3c64xx_spi_suspend    NULL
+#define s3c64xx_spi_resume     NULL
+#endif /* CONFIG_PM */
+
+static struct platform_driver s3c64xx_spi_driver = {
+       .driver = {
+               .name   = "s3c64xx-spi",
+               .owner = THIS_MODULE,
+       },
+       .remove = s3c64xx_spi_remove,
+       .suspend = s3c64xx_spi_suspend,
+       .resume = s3c64xx_spi_resume,
+};
+MODULE_ALIAS("platform:s3c64xx-spi");
+
+static int __init s3c64xx_spi_init(void)
+{
+       return platform_driver_probe(&s3c64xx_spi_driver, s3c64xx_spi_probe);
+}
+module_init(s3c64xx_spi_init);
+
+static void __exit s3c64xx_spi_exit(void)
+{
+       platform_driver_unregister(&s3c64xx_spi_driver);
+}
+module_exit(s3c64xx_spi_exit);
+
+MODULE_AUTHOR("Jaswinder Singh <jassi.brar@samsung.com>");
+MODULE_DESCRIPTION("S3C64XX SPI Controller Driver");
+MODULE_LICENSE("GPL");
index 7d36720eb98299858878c777ffe09b74d6641a96..a65c12ffa73352a79a160dcc5ae665fecb862dc1 100644 (file)
@@ -148,7 +148,7 @@ static int sh_sci_spi_probe(struct platform_device *dev)
                ret = -ENOENT;
                goto err1;
        }
-       sp->membase = ioremap(r->start, r->end - r->start + 1);
+       sp->membase = ioremap(r->start, resource_size(r));
        if (!sp->membase) {
                ret = -ENXIO;
                goto err1;
index 19f75627c3deaf0dd0d31a38689a550abf66f488..dfa024b633e173787dd7c467d7581b27f2d0fd79 100644 (file)
@@ -375,12 +375,10 @@ static int __init txx9spi_probe(struct platform_device *dev)
        res = platform_get_resource(dev, IORESOURCE_MEM, 0);
        if (!res)
                goto exit_busy;
-       if (!devm_request_mem_region(&dev->dev,
-                                    res->start, res->end - res->start + 1,
+       if (!devm_request_mem_region(&dev->dev, res->start, resource_size(res),
                                     "spi_txx9"))
                goto exit_busy;
-       c->membase = devm_ioremap(&dev->dev,
-                                 res->start, res->end - res->start + 1);
+       c->membase = devm_ioremap(&dev->dev, res->start, resource_size(res));
        if (!c->membase)
                goto exit_busy;
 
index 9c446e6003d5c16bae4b9b7c5cb589411bc79770..ea1bec3c9a13359a4058a762e9f2f8de7755cc36 100644 (file)
@@ -53,7 +53,7 @@
 #define SPIDEV_MAJOR                   153     /* assigned */
 #define N_SPI_MINORS                   32      /* ... up to 256 */
 
-static unsigned long   minors[N_SPI_MINORS / BITS_PER_LONG];
+static DECLARE_BITMAP(minors, N_SPI_MINORS);
 
 
 /* Bit masks for spi_device.mode management.  Note that incorrect
@@ -558,7 +558,7 @@ static struct class *spidev_class;
 
 /*-------------------------------------------------------------------------*/
 
-static int spidev_probe(struct spi_device *spi)
+static int __devinit spidev_probe(struct spi_device *spi)
 {
        struct spidev_data      *spidev;
        int                     status;
@@ -607,7 +607,7 @@ static int spidev_probe(struct spi_device *spi)
        return status;
 }
 
-static int spidev_remove(struct spi_device *spi)
+static int __devexit spidev_remove(struct spi_device *spi)
 {
        struct spidev_data      *spidev = spi_get_drvdata(spi);
 
@@ -629,7 +629,7 @@ static int spidev_remove(struct spi_device *spi)
        return 0;
 }
 
-static struct spi_driver spidev_spi = {
+static struct spi_driver spidev_spi_driver = {
        .driver = {
                .name =         "spidev",
                .owner =        THIS_MODULE,
@@ -661,14 +661,14 @@ static int __init spidev_init(void)
 
        spidev_class = class_create(THIS_MODULE, "spidev");
        if (IS_ERR(spidev_class)) {
-               unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
+               unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
                return PTR_ERR(spidev_class);
        }
 
-       status = spi_register_driver(&spidev_spi);
+       status = spi_register_driver(&spidev_spi_driver);
        if (status < 0) {
                class_destroy(spidev_class);
-               unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
+               unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
        }
        return status;
 }
@@ -676,9 +676,9 @@ module_init(spidev_init);
 
 static void __exit spidev_exit(void)
 {
-       spi_unregister_driver(&spidev_spi);
+       spi_unregister_driver(&spidev_spi_driver);
        class_destroy(spidev_class);
-       unregister_chrdev(SPIDEV_MAJOR, spidev_spi.driver.name);
+       unregister_chrdev(SPIDEV_MAJOR, spidev_spi_driver.driver.name);
 }
 module_exit(spidev_exit);
 
index 54e174d28234600c49f8845f94c6fcfb7162aa03..94eb86319ff34a91ed781d2f7ddfbe990f9d7d0b 100644 (file)
@@ -87,8 +87,6 @@ source "drivers/staging/frontier/Kconfig"
 
 source "drivers/staging/dream/Kconfig"
 
-source "drivers/staging/dst/Kconfig"
-
 source "drivers/staging/pohmelfs/Kconfig"
 
 source "drivers/staging/b3dfg/Kconfig"
@@ -99,6 +97,8 @@ source "drivers/staging/p9auth/Kconfig"
 
 source "drivers/staging/line6/Kconfig"
 
+source "drivers/gpu/drm/vmwgfx/Kconfig"
+
 source "drivers/gpu/drm/radeon/Kconfig"
 
 source "drivers/gpu/drm/nouveau/Kconfig"
@@ -143,5 +143,7 @@ source "drivers/staging/wavelan/Kconfig"
 
 source "drivers/staging/netwave/Kconfig"
 
+source "drivers/staging/sm7xx/Kconfig"
+
 endif # !STAGING_EXCLUDE_BUILD
 endif # STAGING
index 069864f4391ecbc20c68e820a22c324669b4240f..b5e67b889f60f73808772ff85ec99343f8d18b8c 100644 (file)
@@ -26,7 +26,6 @@ obj-$(CONFIG_RTL8192E)                += rtl8192e/
 obj-$(CONFIG_INPUT_MIMIO)      += mimio/
 obj-$(CONFIG_TRANZPORT)                += frontier/
 obj-$(CONFIG_DREAM)            += dream/
-obj-$(CONFIG_DST)              += dst/
 obj-$(CONFIG_POHMELFS)         += pohmelfs/
 obj-$(CONFIG_B3DFG)            += b3dfg/
 obj-$(CONFIG_IDE_PHISON)       += phison/
@@ -53,3 +52,4 @@ obj-$(CONFIG_ARLAN)           += arlan/
 obj-$(CONFIG_WAVELAN)          += wavelan/
 obj-$(CONFIG_PCMCIA_WAVELAN)   += wavelan/
 obj-$(CONFIG_PCMCIA_NETWAVE)   += netwave/
+obj-$(CONFIG_FB_SM7XX)         += sm7xx/
index 7632f57600609ddbca11b67ba645f570e89c0c53..1d74dabf9511aff4c03c12973deba299762ad232 100644 (file)
@@ -4,6 +4,7 @@
 
 config BATMAN_ADV
        tristate "B.A.T.M.A.N. Advanced Meshing Protocol"
+       depends on PROC_FS && PACKET
         default n
        ---help---
 
index d724798278d6c813f9fafa88b4fb18bd394c1edf..eb617508cca4c5e8481b8729f50f0b692dae2c71 100644 (file)
@@ -363,8 +363,10 @@ void add_bcast_packet_to_list(unsigned char *packet_buff, int packet_len)
                return;
 
        forw_packet->packet_buff = kmalloc(packet_len, GFP_ATOMIC);
-       if (!forw_packet->packet_buff)
+       if (!forw_packet->packet_buff) {
+               kfree(forw_packet);
                return;
+       }
 
        forw_packet->packet_len = packet_len;
        memcpy(forw_packet->packet_buff, packet_buff, forw_packet->packet_len);
index ccc5cdc008c6eaf3e7323afd677f5b9775a0ad7f..b559a9c2f8579deaf0480ea38e72b47e40c8760f 100644 (file)
 
 #define COMEDI_CB_EOS          1       /* end of scan */
 #define COMEDI_CB_EOA          2       /* end of acquisition */
-#define COMEDI_CB_BLOCK                4       /* DEPRECATED: convenient block size */
+#define COMEDI_CB_BLOCK                4       /* data has arrived: wakes up read() / write() */
 #define COMEDI_CB_EOBUF                8       /* DEPRECATED: end of buffer */
 #define COMEDI_CB_ERROR                16      /* card error during acquisition */
 #define COMEDI_CB_OVERFLOW     32      /* buffer overflow/underflow */
index 0d2c2eb23b2328c40594bace90dc114db28c72ee..bd397840dcbabc8c6204f2485a54faef24aa2438 100644 (file)
@@ -849,8 +849,11 @@ static int jr3_pci_attach(struct comedi_device *dev,
        }
 
        devpriv->pci_enabled = 1;
-       devpriv->iobase =
-           ioremap(pci_resource_start(card, 0), sizeof(struct jr3_t));
+       devpriv->iobase = ioremap(pci_resource_start(card, 0),
+                       offsetof(struct jr3_t, channel[devpriv->n_channels]));
+       if (!devpriv->iobase)
+               return -ENOMEM;
+
        result = alloc_subdevices(dev, devpriv->n_channels);
        if (result < 0)
                goto out;
index 06c020466298a04cd82dae666133309be624a976..9a1b559c4b0d2b29ed06f52322951266f881c330 100644 (file)
@@ -1,4 +1,4 @@
-#define DRIVER_VERSION "v2.3"
+#define DRIVER_VERSION "v2.4"
 #define DRIVER_AUTHOR "Bernd Porr, BerndPorr@f2s.com"
 #define DRIVER_DESC "Stirling/ITL USB-DUX -- Bernd.Porr@f2s.com"
 /*
@@ -81,6 +81,8 @@ sampling rate. If you sample two channels you get 4kHz and so on.
  * 2.1:  changed PWM API
  * 2.2:  added firmware kernel request to fix an udev problem
  * 2.3:  corrected a bug in bulk timeouts which were far too short
+ * 2.4:  fixed a bug which causes the driver to hang when it ran out of data.
+ *       Thanks to Jan-Matthias Braun and Ian to spot the bug and fix it.
  *
  */
 
@@ -532,6 +534,7 @@ static void usbduxsub_ai_IsocIrq(struct urb *urb)
                }
        }
        /* tell comedi that data is there */
+       s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS;
        comedi_event(this_usbduxsub->comedidev, s);
 }
 
index f78b8912d9053e6635c183d3921b1ca081b903d0..89c8fe2997fa75730f9498dcb73dd8ccc1b717d3 100644 (file)
@@ -94,36 +94,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH11]
-                   && h->video_dev[SRAM_CH11]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
 
        file->private_data = fh;
        fh->dev = dev;
@@ -427,7 +411,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template11 = {
        .name = "cx25821-audioupstream",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 8834bc80a5ab575c4a54efbea1cf10fbdaddb09d..c7c14c7698a7665de42470c36f4359f2e4d1b128 100644 (file)
@@ -184,11 +184,11 @@ struct video_device *cx25821_vdev_init(struct cx25821_dev *dev,
        if (NULL == vfd)
                return NULL;
        *vfd = *template;
-       vfd->minor = -1;
        vfd->v4l2_dev = &dev->v4l2_dev;
        vfd->release = video_device_release;
        snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type,
                 cx25821_boards[dev->board].name);
+       video_set_drvdata(vfd, dev);
        return vfd;
 }
 
@@ -424,7 +424,7 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status)
 void cx25821_videoioctl_unregister(struct cx25821_dev *dev)
 {
        if (dev->ioctl_dev) {
-               if (dev->ioctl_dev->minor != -1)
+               if (video_is_registered(dev->ioctl_dev))
                        video_unregister_device(dev->ioctl_dev);
                else
                        video_device_release(dev->ioctl_dev);
@@ -438,7 +438,7 @@ void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num)
        cx_clear(PCI_INT_MSK, 1);
 
        if (dev->video_dev[chan_num]) {
-               if (-1 != dev->video_dev[chan_num]->minor)
+               if (video_is_registered(dev->video_dev[chan_num]))
                        video_unregister_device(dev->video_dev[chan_num]);
                else
                        video_device_release(dev->video_dev[chan_num]);
index 950fac1d70033c7386df44f8f9ece92ee21eab0e..ad7a6912911899b360773ff3e6723e50746258cb 100644 (file)
@@ -94,37 +94,21 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH00]
-                   && h->video_dev[SRAM_CH00]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
 
        file->private_data = fh;
        fh->dev = dev;
@@ -444,7 +428,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template0 = {
        .name = "cx25821-video",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index a4dddc684adfbeb3ade90b835b290741e2972b3e..e3f3c4ac7908e7cd414c906b16a39defde09f21c 100644 (file)
@@ -94,37 +94,21 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH01]
-                   && h->video_dev[SRAM_CH01]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
 
        file->private_data = fh;
        fh->dev = dev;
@@ -444,7 +428,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template1 = {
        .name = "cx25821-video",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 8e04e253f5d940c4f64bf0ec48000fef15650790..36fb855a497e9278d7a2fea41bec4f1ad4031bcf 100644 (file)
@@ -94,37 +94,22 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH02]
-                   && h->video_dev[SRAM_CH02]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev = dev;
        fh->type = type;
@@ -445,7 +430,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template2 = {
        .name = "cx25821-video",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 8801a8ead904b2e00eb5006603c96f1ec69aee2c..1e0f10abdbcda52fa92bf8bb55447ae0066deccd 100644 (file)
@@ -94,37 +94,22 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH03]
-                   && h->video_dev[SRAM_CH03]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev = dev;
        fh->type = type;
@@ -444,7 +429,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template3 = {
        .name = "cx25821-video",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index ab0d747138addc14ee0697e69196485547c06864..0cbe7a79d8c063d2a418968d76b089ac61261c58 100644 (file)
@@ -94,37 +94,22 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH04]
-                   && h->video_dev[SRAM_CH04]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev = dev;
        fh->type = type;
@@ -443,7 +428,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template4 = {
        .name = "cx25821-video",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 7ef0b971f5cfbfc606690d204f14f61c875b8808..5dc08adc12e8e75ba8fbe636b8659b67f106ecf0 100644 (file)
@@ -94,37 +94,22 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH05]
-                   && h->video_dev[SRAM_CH05]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev = dev;
        fh->type = type;
@@ -443,7 +428,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template5 = {
        .name = "cx25821-video",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 3c41b49e2ea98d5e4fbf6afc3dc22d600cb3c163..2938ad3ad3c5b54bdd53e8e8ecc479e66035c4ed 100644 (file)
@@ -94,37 +94,22 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH06]
-                   && h->video_dev[SRAM_CH06]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev = dev;
        fh->type = type;
@@ -443,7 +428,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template6 = {
        .name = "cx25821-video",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 625c9b78a9cfe61c2aaf2f11d9dc642248e1fb51..458e525d72af319ca615927ea4e49792076eb16e 100644 (file)
@@ -93,37 +93,22 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH07]
-                   && h->video_dev[SRAM_CH07]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
+
        file->private_data = fh;
        fh->dev = dev;
        fh->type = type;
@@ -442,7 +427,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template7 = {
        .name = "cx25821-video",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 2a312ce78c636fe9442dd364e62165e59f0d5663..1da52b54a454dcafaebfbac8f28ead1cc3fa90b8 100644 (file)
@@ -94,36 +94,21 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        u32 pix_format;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->ioctl_dev && h->ioctl_dev->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
 
        file->private_data = fh;
        fh->dev = dev;
@@ -489,7 +474,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_videoioctl_template = {
        .name = "cx25821-videoioctl",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 77b63b06040563282ec4398b3a21c1d8d6618d20..b76d9f62c3d1c2d3f64cdb4e004693e82e6e3028 100644 (file)
@@ -94,36 +94,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH10]
-                   && h->video_dev[SRAM_CH10]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
 
        file->private_data = fh;
        fh->dev = dev;
@@ -428,7 +412,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template10 = {
        .name = "cx25821-upstream10",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
index 75c8c1eed2da9a9fe523056593cb39f41739594f..1580da3b29aa17df1210cf79d13dd9d5dcb57e56 100644 (file)
@@ -94,36 +94,20 @@ static struct videobuf_queue_ops cx25821_video_qops = {
 
 static int video_open(struct file *file)
 {
-       int minor = video_devdata(file)->minor;
-       struct cx25821_dev *h, *dev = NULL;
+       struct video_device *vdev = video_devdata(file);
+       struct cx25821_dev *dev = video_drvdata(file);
        struct cx25821_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 
-       lock_kernel();
-       list_for_each(list, &cx25821_devlist) {
-               h = list_entry(list, struct cx25821_dev, devlist);
-
-               if (h->video_dev[SRAM_CH09]
-                   && h->video_dev[SRAM_CH09]->minor == minor) {
-                       dev = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-
-       if (NULL == dev) {
-               unlock_kernel();
-               return -ENODEV;
-       }
-
-       printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]);
+       printk("open dev=%s type=%s\n", video_device_node_name(vdev),
+               v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
+       lock_kernel();
 
        file->private_data = fh;
        fh->dev = dev;
@@ -426,7 +410,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 struct video_device cx25821_video_template9 = {
        .name = "cx25821-upstream9",
        .fops = &video_fops,
-       .minor = -1,
        .ioctl_ops = &video_ioctl_ops,
        .tvnorms = CX25821_NORMS,
        .current_norm = V4L2_STD_NTSC_M,
diff --git a/drivers/staging/dst/Kconfig b/drivers/staging/dst/Kconfig
deleted file mode 100644 (file)
index 448d342..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-config DST
-       tristate "Distributed storage"
-       depends on NET && CRYPTO && SYSFS && BLK_DEV
-       select CONNECTOR
-       ---help---
-       DST is a network block device storage, which can be used to organize
-       exported storage on the remote nodes into the local block device.
-
-       DST works on top of any network media and protocol; it is just a matter
-       of configuration utility to understand the correct addresses. The most
-       common example is TCP over IP, which allows to pass through firewalls and
-       create remote backup storage in a different datacenter. DST requires
-       single port to be enabled on the exporting node and outgoing connections
-       on the local node.
-
-       DST works with in-kernel client and server, which improves performance by
-       eliminating unneded data copies and by not depending on the version
-       of the external IO components. It requires userspace configuration utility
-       though.
-
-       DST uses transaction model, when each store has to be explicitly acked
-       from the remote node to be considered as successfully written. There
-       may be lots of in-flight transactions. When remote host does not ack
-       the transaction it will be resent predefined number of times with specified
-       timeouts between them. All those parameters are configurable. Transactions
-       are marked as failed after all resends complete unsuccessfully; having
-       long enough resend timeout and/or large number of resends allows not to
-       return error to the higher (FS usually) layer in case of short network
-       problems or remote node outages. In case of network RAID setup this means
-       that storage will not degrade until transactions are marked as failed, and
-       thus will not force checksum recalculation and data rebuild. In case of
-       connection failure DST will try to reconnect to the remote node automatically.
-       DST sends ping commands at idle time to detect if remote node is alive.
-
-       Because of transactional model it is possible to use zero-copy sending
-       without worry of data corruption (which in turn could be detected by the
-       strong checksums though).
-
-       DST may fully encrypt the data channel in case of untrusted channel and implement
-       strong checksum of the transferred data. It is possible to configure algorithms
-       and crypto keys; they should match on both sides of the network channel.
-       Crypto processing does not introduce noticeble performance overhead, since DST
-       uses configurable pool of threads to perform crypto processing.
-
-       DST utilizes memory pool model of all its transaction allocations (it is the
-       only additional allocation on the client) and server allocations (bio pools,
-       while pages are allocated from the slab).
-
-       At startup DST performs a simple negotiation with the export node to determine
-       access permissions and size of the exported storage. It can be extended if
-       new parameters should be autonegotiated.
-
-       DST carries block IO flags in the protocol, which allows to transparently implement
-       barriers and sync/flush operations. Those flags are used in the export node where
-       IO against the local storage is performed, which means that sync write will be sync
-       on the remote node too, which in turn improves data integrity and improved resistance
-       to errors and data corruption during power outages or storage damages.
-
-       Homepage: http://www.ioremap.net/projects/dst
-       Userspace configuration utility and the latest releases: http://www.ioremap.net/archive/dst/
-
-config DST_DEBUG
-       bool "DST debug"
-       depends on DST
-       ---help---
-       This option will enable HEAVY debugging of the DST.
-       Turn it on ONLY if you have to debug some really obscure problem.
diff --git a/drivers/staging/dst/Makefile b/drivers/staging/dst/Makefile
deleted file mode 100644 (file)
index 3a8b0cf..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-$(CONFIG_DST) += nst.o
-
-nst-y := dcore.o state.o export.o thread_pool.o crypto.o trans.o
diff --git a/drivers/staging/dst/crypto.c b/drivers/staging/dst/crypto.c
deleted file mode 100644 (file)
index 351295c..0000000
+++ /dev/null
@@ -1,733 +0,0 @@
-/*
- * 2007+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <linux/bio.h>
-#include <linux/crypto.h>
-#include <linux/dst.h>
-#include <linux/kernel.h>
-#include <linux/scatterlist.h>
-#include <linux/slab.h>
-
-/*
- * Tricky bastard, but IV can be more complex with time...
- */
-static inline u64 dst_gen_iv(struct dst_trans *t)
-{
-       return t->gen;
-}
-
-/*
- * Crypto machinery: hash/cipher support for the given crypto controls.
- */
-static struct crypto_hash *dst_init_hash(struct dst_crypto_ctl *ctl, u8 *key)
-{
-       int err;
-       struct crypto_hash *hash;
-
-       hash = crypto_alloc_hash(ctl->hash_algo, 0, CRYPTO_ALG_ASYNC);
-       if (IS_ERR(hash)) {
-               err = PTR_ERR(hash);
-               dprintk("%s: failed to allocate hash '%s', err: %d.\n",
-                               __func__, ctl->hash_algo, err);
-               goto err_out_exit;
-       }
-
-       ctl->crypto_attached_size = crypto_hash_digestsize(hash);
-
-       if (!ctl->hash_keysize)
-               return hash;
-
-       err = crypto_hash_setkey(hash, key, ctl->hash_keysize);
-       if (err) {
-               dprintk("%s: failed to set key for hash '%s', err: %d.\n",
-                               __func__, ctl->hash_algo, err);
-               goto err_out_free;
-       }
-
-       return hash;
-
-err_out_free:
-       crypto_free_hash(hash);
-err_out_exit:
-       return ERR_PTR(err);
-}
-
-static struct crypto_ablkcipher *dst_init_cipher(struct dst_crypto_ctl *ctl,
-               u8 *key)
-{
-       int err = -EINVAL;
-       struct crypto_ablkcipher *cipher;
-
-       if (!ctl->cipher_keysize)
-               goto err_out_exit;
-
-       cipher = crypto_alloc_ablkcipher(ctl->cipher_algo, 0, 0);
-       if (IS_ERR(cipher)) {
-               err = PTR_ERR(cipher);
-               dprintk("%s: failed to allocate cipher '%s', err: %d.\n",
-                               __func__, ctl->cipher_algo, err);
-               goto err_out_exit;
-       }
-
-       crypto_ablkcipher_clear_flags(cipher, ~0);
-
-       err = crypto_ablkcipher_setkey(cipher, key, ctl->cipher_keysize);
-       if (err) {
-               dprintk("%s: failed to set key for cipher '%s', err: %d.\n",
-                               __func__, ctl->cipher_algo, err);
-               goto err_out_free;
-       }
-
-       return cipher;
-
-err_out_free:
-       crypto_free_ablkcipher(cipher);
-err_out_exit:
-       return ERR_PTR(err);
-}
-
-/*
- * Crypto engine has a pool of pages to encrypt data into before sending
- * it over the network. This pool is freed/allocated here.
- */
-static void dst_crypto_pages_free(struct dst_crypto_engine *e)
-{
-       unsigned int i;
-
-       for (i = 0; i < e->page_num; ++i)
-               __free_page(e->pages[i]);
-       kfree(e->pages);
-}
-
-static int dst_crypto_pages_alloc(struct dst_crypto_engine *e, int num)
-{
-       int i;
-
-       e->pages = kmalloc(num * sizeof(struct page **), GFP_KERNEL);
-       if (!e->pages)
-               return -ENOMEM;
-
-       for (i = 0; i < num; ++i) {
-               e->pages[i] = alloc_page(GFP_KERNEL);
-               if (!e->pages[i])
-                       goto err_out_free_pages;
-       }
-
-       e->page_num = num;
-       return 0;
-
-err_out_free_pages:
-       while (--i >= 0)
-               __free_page(e->pages[i]);
-
-       kfree(e->pages);
-       return -ENOMEM;
-}
-
-/*
- * Initialize crypto engine for given node.
- * Setup cipher/hash, keys, pool of threads and private data.
- */
-static int dst_crypto_engine_init(struct dst_crypto_engine *e,
-               struct dst_node *n)
-{
-       int err;
-       struct dst_crypto_ctl *ctl = &n->crypto;
-
-       err = dst_crypto_pages_alloc(e, n->max_pages);
-       if (err)
-               goto err_out_exit;
-
-       e->size = PAGE_SIZE;
-       e->data = kmalloc(e->size, GFP_KERNEL);
-       if (!e->data) {
-               err = -ENOMEM;
-               goto err_out_free_pages;
-       }
-
-       if (ctl->hash_algo[0]) {
-               e->hash = dst_init_hash(ctl, n->hash_key);
-               if (IS_ERR(e->hash)) {
-                       err = PTR_ERR(e->hash);
-                       e->hash = NULL;
-                       goto err_out_free;
-               }
-       }
-
-       if (ctl->cipher_algo[0]) {
-               e->cipher = dst_init_cipher(ctl, n->cipher_key);
-               if (IS_ERR(e->cipher)) {
-                       err = PTR_ERR(e->cipher);
-                       e->cipher = NULL;
-                       goto err_out_free_hash;
-               }
-       }
-
-       return 0;
-
-err_out_free_hash:
-       crypto_free_hash(e->hash);
-err_out_free:
-       kfree(e->data);
-err_out_free_pages:
-       dst_crypto_pages_free(e);
-err_out_exit:
-       return err;
-}
-
-static void dst_crypto_engine_exit(struct dst_crypto_engine *e)
-{
-       if (e->hash)
-               crypto_free_hash(e->hash);
-       if (e->cipher)
-               crypto_free_ablkcipher(e->cipher);
-       dst_crypto_pages_free(e);
-       kfree(e->data);
-}
-
-/*
- * Waiting for cipher processing to be completed.
- */
-struct dst_crypto_completion {
-       struct completion               complete;
-       int                             error;
-};
-
-static void dst_crypto_complete(struct crypto_async_request *req, int err)
-{
-       struct dst_crypto_completion *c = req->data;
-
-       if (err == -EINPROGRESS)
-               return;
-
-       dprintk("%s: req: %p, err: %d.\n", __func__, req, err);
-       c->error = err;
-       complete(&c->complete);
-}
-
-static int dst_crypto_process(struct ablkcipher_request *req,
-               struct scatterlist *sg_dst, struct scatterlist *sg_src,
-               void *iv, int enc, unsigned long timeout)
-{
-       struct dst_crypto_completion c;
-       int err;
-
-       init_completion(&c.complete);
-       c.error = -EINPROGRESS;
-
-       ablkcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
-                                       dst_crypto_complete, &c);
-
-       ablkcipher_request_set_crypt(req, sg_src, sg_dst, sg_src->length, iv);
-
-       if (enc)
-               err = crypto_ablkcipher_encrypt(req);
-       else
-               err = crypto_ablkcipher_decrypt(req);
-
-       switch (err) {
-       case -EINPROGRESS:
-       case -EBUSY:
-               err = wait_for_completion_interruptible_timeout(&c.complete,
-                               timeout);
-               if (!err)
-                       err = -ETIMEDOUT;
-               else
-                       err = c.error;
-               break;
-       default:
-               break;
-       }
-
-       return err;
-}
-
-/*
- * DST uses generic iteration approach for data crypto processing.
- * Single block IO request is switched into array of scatterlists,
- * which are submitted to the crypto processing iterator.
- *
- * Input and output iterator initialization are different, since
- * in output case we can not encrypt data in-place and need a
- * temporary storage, which is then being sent to the remote peer.
- */
-static int dst_trans_iter_out(struct bio *bio, struct dst_crypto_engine *e,
-               int (*iterator) (struct dst_crypto_engine *e,
-                                 struct scatterlist *dst,
-                                 struct scatterlist *src))
-{
-       struct bio_vec *bv;
-       int err, i;
-
-       sg_init_table(e->src, bio->bi_vcnt);
-       sg_init_table(e->dst, bio->bi_vcnt);
-
-       bio_for_each_segment(bv, bio, i) {
-               sg_set_page(&e->src[i], bv->bv_page, bv->bv_len, bv->bv_offset);
-               sg_set_page(&e->dst[i], e->pages[i], bv->bv_len, bv->bv_offset);
-
-               err = iterator(e, &e->dst[i], &e->src[i]);
-               if (err)
-                       return err;
-       }
-
-       return 0;
-}
-
-static int dst_trans_iter_in(struct bio *bio, struct dst_crypto_engine *e,
-               int (*iterator) (struct dst_crypto_engine *e,
-                                 struct scatterlist *dst,
-                                 struct scatterlist *src))
-{
-       struct bio_vec *bv;
-       int err, i;
-
-       sg_init_table(e->src, bio->bi_vcnt);
-       sg_init_table(e->dst, bio->bi_vcnt);
-
-       bio_for_each_segment(bv, bio, i) {
-               sg_set_page(&e->src[i], bv->bv_page, bv->bv_len, bv->bv_offset);
-               sg_set_page(&e->dst[i], bv->bv_page, bv->bv_len, bv->bv_offset);
-
-               err = iterator(e, &e->dst[i], &e->src[i]);
-               if (err)
-                       return err;
-       }
-
-       return 0;
-}
-
-static int dst_crypt_iterator(struct dst_crypto_engine *e,
-               struct scatterlist *sg_dst, struct scatterlist *sg_src)
-{
-       struct ablkcipher_request *req = e->data;
-       u8 iv[32];
-
-       memset(iv, 0, sizeof(iv));
-
-       memcpy(iv, &e->iv, sizeof(e->iv));
-
-       return dst_crypto_process(req, sg_dst, sg_src, iv, e->enc, e->timeout);
-}
-
-static int dst_crypt(struct dst_crypto_engine *e, struct bio *bio)
-{
-       struct ablkcipher_request *req = e->data;
-
-       memset(req, 0, sizeof(struct ablkcipher_request));
-       ablkcipher_request_set_tfm(req, e->cipher);
-
-       if (e->enc)
-               return dst_trans_iter_out(bio, e, dst_crypt_iterator);
-       else
-               return dst_trans_iter_in(bio, e, dst_crypt_iterator);
-}
-
-static int dst_hash_iterator(struct dst_crypto_engine *e,
-               struct scatterlist *sg_dst, struct scatterlist *sg_src)
-{
-       return crypto_hash_update(e->data, sg_src, sg_src->length);
-}
-
-static int dst_hash(struct dst_crypto_engine *e, struct bio *bio, void *dst)
-{
-       struct hash_desc *desc = e->data;
-       int err;
-
-       desc->tfm = e->hash;
-       desc->flags = 0;
-
-       err = crypto_hash_init(desc);
-       if (err)
-               return err;
-
-       err = dst_trans_iter_in(bio, e, dst_hash_iterator);
-       if (err)
-               return err;
-
-       err = crypto_hash_final(desc, dst);
-       if (err)
-               return err;
-
-       return 0;
-}
-
-/*
- * Initialize/cleanup a crypto thread. The only thing it should
- * do is to allocate a pool of pages as temporary storage.
- * And to setup cipher and/or hash.
- */
-static void *dst_crypto_thread_init(void *data)
-{
-       struct dst_node *n = data;
-       struct dst_crypto_engine *e;
-       int err = -ENOMEM;
-
-       e = kzalloc(sizeof(struct dst_crypto_engine), GFP_KERNEL);
-       if (!e)
-               goto err_out_exit;
-       e->src = kcalloc(2 * n->max_pages, sizeof(struct scatterlist),
-                       GFP_KERNEL);
-       if (!e->src)
-               goto err_out_free;
-
-       e->dst = e->src + n->max_pages;
-
-       err = dst_crypto_engine_init(e, n);
-       if (err)
-               goto err_out_free_all;
-
-       return e;
-
-err_out_free_all:
-       kfree(e->src);
-err_out_free:
-       kfree(e);
-err_out_exit:
-       return ERR_PTR(err);
-}
-
-static void dst_crypto_thread_cleanup(void *private)
-{
-       struct dst_crypto_engine *e = private;
-
-       dst_crypto_engine_exit(e);
-       kfree(e->src);
-       kfree(e);
-}
-
-/*
- * Initialize crypto engine for given node: store keys, create pool
- * of threads, initialize each one.
- *
- * Each thread has unique ID, but 0 and 1 are reserved for receiving and
- * accepting threads (if export node), so IDs could start from 2, but starting
- * them from 10 allows easily understand what this thread is for.
- */
-int dst_node_crypto_init(struct dst_node *n, struct dst_crypto_ctl *ctl)
-{
-       void *key = (ctl + 1);
-       int err = -ENOMEM, i;
-       char name[32];
-
-       if (ctl->hash_keysize) {
-               n->hash_key = kmalloc(ctl->hash_keysize, GFP_KERNEL);
-               if (!n->hash_key)
-                       goto err_out_exit;
-               memcpy(n->hash_key, key, ctl->hash_keysize);
-       }
-
-       if (ctl->cipher_keysize) {
-               n->cipher_key = kmalloc(ctl->cipher_keysize, GFP_KERNEL);
-               if (!n->cipher_key)
-                       goto err_out_free_hash;
-               memcpy(n->cipher_key, key, ctl->cipher_keysize);
-       }
-       memcpy(&n->crypto, ctl, sizeof(struct dst_crypto_ctl));
-
-       for (i = 0; i < ctl->thread_num; ++i) {
-               snprintf(name, sizeof(name), "%s-crypto-%d", n->name, i);
-               /* Unique ids... */
-               err = thread_pool_add_worker(n->pool, name, i + 10,
-                       dst_crypto_thread_init, dst_crypto_thread_cleanup, n);
-               if (err)
-                       goto err_out_free_threads;
-       }
-
-       return 0;
-
-err_out_free_threads:
-       while (--i >= 0)
-               thread_pool_del_worker_id(n->pool, i+10);
-
-       if (ctl->cipher_keysize)
-               kfree(n->cipher_key);
-       ctl->cipher_keysize = 0;
-err_out_free_hash:
-       if (ctl->hash_keysize)
-               kfree(n->hash_key);
-       ctl->hash_keysize = 0;
-err_out_exit:
-       return err;
-}
-
-void dst_node_crypto_exit(struct dst_node *n)
-{
-       struct dst_crypto_ctl *ctl = &n->crypto;
-
-       if (ctl->cipher_algo[0] || ctl->hash_algo[0]) {
-               kfree(n->hash_key);
-               kfree(n->cipher_key);
-       }
-}
-
-/*
- * Thrad pool setup callback. Just stores a transaction in private data.
- */
-static int dst_trans_crypto_setup(void *crypto_engine, void *trans)
-{
-       struct dst_crypto_engine *e = crypto_engine;
-
-       e->private = trans;
-       return 0;
-}
-
-#if 0
-static void dst_dump_bio(struct bio *bio)
-{
-       u8 *p;
-       struct bio_vec *bv;
-       int i;
-
-       bio_for_each_segment(bv, bio, i) {
-               dprintk("%s: %llu/%u: size: %u, offset: %u, data: ",
-                               __func__, bio->bi_sector, bio->bi_size,
-                               bv->bv_len, bv->bv_offset);
-
-               p = kmap(bv->bv_page) + bv->bv_offset;
-               for (i = 0; i < bv->bv_len; ++i)
-                       printk(KERN_DEBUG "%02x ", p[i]);
-               kunmap(bv->bv_page);
-               printk("\n");
-       }
-}
-#endif
-
-/*
- * Encrypt/hash data and send it to the network.
- */
-static int dst_crypto_process_sending(struct dst_crypto_engine *e,
-               struct bio *bio, u8 *hash)
-{
-       int err;
-
-       if (e->cipher) {
-               err = dst_crypt(e, bio);
-               if (err)
-                       goto err_out_exit;
-       }
-
-       if (e->hash) {
-               err = dst_hash(e, bio, hash);
-               if (err)
-                       goto err_out_exit;
-
-#ifdef CONFIG_DST_DEBUG
-               {
-                       unsigned int i;
-
-                       /* dst_dump_bio(bio); */
-
-                       printk(KERN_DEBUG "%s: bio: %llu/%u, rw: %lu, hash: ",
-                               __func__, (u64)bio->bi_sector,
-                               bio->bi_size, bio_data_dir(bio));
-                       for (i = 0; i < crypto_hash_digestsize(e->hash); ++i)
-                                       printk("%02x ", hash[i]);
-                       printk("\n");
-               }
-#endif
-       }
-
-       return 0;
-
-err_out_exit:
-       return err;
-}
-
-/*
- * Check if received data is valid. Decipher if it is.
- */
-static int dst_crypto_process_receiving(struct dst_crypto_engine *e,
-               struct bio *bio, u8 *hash, u8 *recv_hash)
-{
-       int err;
-
-       if (e->hash) {
-               int mismatch;
-
-               err = dst_hash(e, bio, hash);
-               if (err)
-                       goto err_out_exit;
-
-               mismatch = !!memcmp(recv_hash, hash,
-                               crypto_hash_digestsize(e->hash));
-#ifdef CONFIG_DST_DEBUG
-               /* dst_dump_bio(bio); */
-
-               printk(KERN_DEBUG "%s: bio: %llu/%u, rw: %lu, hash mismatch: %d",
-                       __func__, (u64)bio->bi_sector, bio->bi_size,
-                       bio_data_dir(bio), mismatch);
-               if (mismatch) {
-                       unsigned int i;
-
-                       printk(", recv/calc: ");
-                       for (i = 0; i < crypto_hash_digestsize(e->hash); ++i)
-                               printk("%02x/%02x ", recv_hash[i], hash[i]);
-
-               }
-               printk("\n");
-#endif
-               err = -1;
-               if (mismatch)
-                       goto err_out_exit;
-       }
-
-       if (e->cipher) {
-               err = dst_crypt(e, bio);
-               if (err)
-                       goto err_out_exit;
-       }
-
-       return 0;
-
-err_out_exit:
-       return err;
-}
-
-/*
- * Thread pool callback to encrypt data and send it to the netowork.
- */
-static int dst_trans_crypto_action(void *crypto_engine, void *schedule_data)
-{
-       struct dst_crypto_engine *e = crypto_engine;
-       struct dst_trans *t = schedule_data;
-       struct bio *bio = t->bio;
-       int err;
-
-       dprintk("%s: t: %p, gen: %llu, cipher: %p, hash: %p.\n",
-                       __func__, t, t->gen, e->cipher, e->hash);
-
-       e->enc = t->enc;
-       e->iv = dst_gen_iv(t);
-
-       if (bio_data_dir(bio) == WRITE) {
-               err = dst_crypto_process_sending(e, bio, t->cmd.hash);
-               if (err)
-                       goto err_out_exit;
-
-               if (e->hash) {
-                       t->cmd.csize = crypto_hash_digestsize(e->hash);
-                       t->cmd.size += t->cmd.csize;
-               }
-
-               return dst_trans_send(t);
-       } else {
-               u8 *hash = e->data + e->size/2;
-
-               err = dst_crypto_process_receiving(e, bio, hash, t->cmd.hash);
-               if (err)
-                       goto err_out_exit;
-
-               dst_trans_remove(t);
-               dst_trans_put(t);
-       }
-
-       return 0;
-
-err_out_exit:
-       t->error = err;
-       dst_trans_put(t);
-       return err;
-}
-
-/*
- * Schedule crypto processing for given transaction.
- */
-int dst_trans_crypto(struct dst_trans *t)
-{
-       struct dst_node *n = t->n;
-       int err;
-
-       err = thread_pool_schedule(n->pool,
-               dst_trans_crypto_setup, dst_trans_crypto_action,
-               t, MAX_SCHEDULE_TIMEOUT);
-       if (err)
-               goto err_out_exit;
-
-       return 0;
-
-err_out_exit:
-       dst_trans_put(t);
-       return err;
-}
-
-/*
- * Crypto machinery for the export node.
- */
-static int dst_export_crypto_setup(void *crypto_engine, void *bio)
-{
-       struct dst_crypto_engine *e = crypto_engine;
-
-       e->private = bio;
-       return 0;
-}
-
-static int dst_export_crypto_action(void *crypto_engine, void *schedule_data)
-{
-       struct dst_crypto_engine *e = crypto_engine;
-       struct bio *bio = schedule_data;
-       struct dst_export_priv *p = bio->bi_private;
-       int err;
-
-       dprintk("%s: e: %p, data: %p, bio: %llu/%u, dir: %lu.\n",
-                       __func__, e, e->data, (u64)bio->bi_sector,
-                       bio->bi_size, bio_data_dir(bio));
-
-       e->enc = (bio_data_dir(bio) == READ);
-       e->iv = p->cmd.id;
-
-       if (bio_data_dir(bio) == WRITE) {
-               u8 *hash = e->data + e->size/2;
-
-               err = dst_crypto_process_receiving(e, bio, hash, p->cmd.hash);
-               if (err)
-                       goto err_out_exit;
-
-               generic_make_request(bio);
-       } else {
-               err = dst_crypto_process_sending(e, bio, p->cmd.hash);
-               if (err)
-                       goto err_out_exit;
-
-               if (e->hash) {
-                       p->cmd.csize = crypto_hash_digestsize(e->hash);
-                       p->cmd.size += p->cmd.csize;
-               }
-
-               err = dst_export_send_bio(bio);
-       }
-       return 0;
-
-err_out_exit:
-       bio_put(bio);
-       return err;
-}
-
-int dst_export_crypto(struct dst_node *n, struct bio *bio)
-{
-       int err;
-
-       err = thread_pool_schedule(n->pool,
-               dst_export_crypto_setup, dst_export_crypto_action,
-               bio, MAX_SCHEDULE_TIMEOUT);
-       if (err)
-               goto err_out_exit;
-
-       return 0;
-
-err_out_exit:
-       bio_put(bio);
-       return err;
-}
diff --git a/drivers/staging/dst/dcore.c b/drivers/staging/dst/dcore.c
deleted file mode 100644 (file)
index fd5bd0e..0000000
+++ /dev/null
@@ -1,1004 +0,0 @@
-/*
- * 2007+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/blkdev.h>
-#include <linux/bio.h>
-#include <linux/buffer_head.h>
-#include <linux/connector.h>
-#include <linux/dst.h>
-#include <linux/device.h>
-#include <linux/jhash.h>
-#include <linux/idr.h>
-#include <linux/init.h>
-#include <linux/namei.h>
-#include <linux/slab.h>
-#include <linux/socket.h>
-
-#include <linux/in.h>
-#include <linux/in6.h>
-
-#include <net/sock.h>
-
-static int dst_major;
-
-static DEFINE_MUTEX(dst_hash_lock);
-static struct list_head *dst_hashtable;
-static unsigned int dst_hashtable_size = 128;
-module_param(dst_hashtable_size, uint, 0644);
-
-static char dst_name[] = "Dementianting goldfish";
-
-static DEFINE_IDR(dst_index_idr);
-static struct cb_id cn_dst_id = { CN_DST_IDX, CN_DST_VAL };
-
-/*
- * DST sysfs tree for device called 'storage':
- *
- * /sys/bus/dst/devices/storage/
- * /sys/bus/dst/devices/storage/type : 192.168.4.80:1025
- * /sys/bus/dst/devices/storage/size : 800
- * /sys/bus/dst/devices/storage/name : storage
- */
-
-static int dst_dev_match(struct device *dev, struct device_driver *drv)
-{
-       return 1;
-}
-
-static struct bus_type dst_dev_bus_type = {
-       .name           = "dst",
-       .match          = &dst_dev_match,
-};
-
-static void dst_node_release(struct device *dev)
-{
-       struct dst_info *info = container_of(dev, struct dst_info, device);
-
-       kfree(info);
-}
-
-static struct device dst_node_dev = {
-       .bus            = &dst_dev_bus_type,
-       .release        = &dst_node_release
-};
-
-/*
- * Setting size of the node after it was changed.
- */
-static void dst_node_set_size(struct dst_node *n)
-{
-       struct block_device *bdev;
-
-       set_capacity(n->disk, n->size >> 9);
-
-       bdev = bdget_disk(n->disk, 0);
-       if (bdev) {
-               mutex_lock(&bdev->bd_inode->i_mutex);
-               i_size_write(bdev->bd_inode, n->size);
-               mutex_unlock(&bdev->bd_inode->i_mutex);
-               bdput(bdev);
-       }
-}
-
-/*
- * Distributed storage request processing function.
- */
-static int dst_request(struct request_queue *q, struct bio *bio)
-{
-       struct dst_node *n = q->queuedata;
-       int err = -EIO;
-
-       if (bio_empty_barrier(bio) && !blk_queue_discard(q)) {
-               /*
-                * This is a dirty^Wnice hack, but if we complete this
-                * operation with -EOPNOTSUPP like intended, XFS
-                * will stuck and freeze the machine. This may be
-                * not particulary XFS problem though, but it is the
-                * only FS which sends empty barrier at umount time
-                * I worked with.
-                *
-                * Empty barriers are not allowed anyway, see 51fd77bd9f512
-                * for example, although later it was changed to
-                * bio_rw_flagged(bio, BIO_RW_DISCARD) only, which does not
-                * work in this case.
-                */
-               /* err = -EOPNOTSUPP; */
-               err = 0;
-               goto end_io;
-       }
-
-       bio_get(bio);
-
-       return dst_process_bio(n, bio);
-
-end_io:
-       bio_endio(bio, err);
-       return err;
-}
-
-/*
- * Open/close callbacks for appropriate block device.
- */
-static int dst_bdev_open(struct block_device *bdev, fmode_t mode)
-{
-       struct dst_node *n = bdev->bd_disk->private_data;
-
-       dst_node_get(n);
-       return 0;
-}
-
-static int dst_bdev_release(struct gendisk *disk, fmode_t mode)
-{
-       struct dst_node *n = disk->private_data;
-
-       dst_node_put(n);
-       return 0;
-}
-
-static struct block_device_operations dst_blk_ops = {
-       .open           = dst_bdev_open,
-       .release        = dst_bdev_release,
-       .owner          = THIS_MODULE,
-};
-
-/*
- * Block layer binding - disk is created when array is fully configured
- * by userspace request.
- */
-static int dst_node_create_disk(struct dst_node *n)
-{
-       int err = -ENOMEM;
-       u32 index = 0;
-
-       n->queue = blk_init_queue(NULL, NULL);
-       if (!n->queue)
-               goto err_out_exit;
-
-       n->queue->queuedata = n;
-       blk_queue_make_request(n->queue, dst_request);
-       blk_queue_max_phys_segments(n->queue, n->max_pages);
-       blk_queue_max_hw_segments(n->queue, n->max_pages);
-
-       err = -ENOMEM;
-       n->disk = alloc_disk(1);
-       if (!n->disk)
-               goto err_out_free_queue;
-
-       if (!(n->state->permissions & DST_PERM_WRITE)) {
-               printk(KERN_INFO "DST node %s attached read-only.\n", n->name);
-               set_disk_ro(n->disk, 1);
-       }
-
-       if (!idr_pre_get(&dst_index_idr, GFP_KERNEL))
-               goto err_out_put;
-
-       mutex_lock(&dst_hash_lock);
-       err = idr_get_new(&dst_index_idr, NULL, &index);
-       mutex_unlock(&dst_hash_lock);
-       if (err)
-               goto err_out_put;
-
-       n->disk->major = dst_major;
-       n->disk->first_minor = index;
-       n->disk->fops = &dst_blk_ops;
-       n->disk->queue = n->queue;
-       n->disk->private_data = n;
-       snprintf(n->disk->disk_name, sizeof(n->disk->disk_name),
-                       "dst-%s", n->name);
-
-       return 0;
-
-err_out_put:
-       put_disk(n->disk);
-err_out_free_queue:
-       blk_cleanup_queue(n->queue);
-err_out_exit:
-       return err;
-}
-
-/*
- * Sysfs machinery: show device's size.
- */
-static ssize_t dst_show_size(struct device *dev,
-               struct device_attribute *attr, char *buf)
-{
-       struct dst_info *info = container_of(dev, struct dst_info, device);
-
-       return sprintf(buf, "%llu\n", info->size);
-}
-
-/*
- * Show local exported device.
- */
-static ssize_t dst_show_local(struct device *dev,
-               struct device_attribute *attr, char *buf)
-{
-       struct dst_info *info = container_of(dev, struct dst_info, device);
-
-       return sprintf(buf, "%s\n", info->local);
-}
-
-/*
- * Shows type of the remote node - device major/minor number
- * for local nodes and address (af_inet ipv4/ipv6 only) for remote nodes.
- */
-static ssize_t dst_show_type(struct device *dev,
-               struct device_attribute *attr, char *buf)
-{
-       struct dst_info *info = container_of(dev, struct dst_info, device);
-       int family = info->net.addr.sa_family;
-
-       if (family == AF_INET) {
-               struct sockaddr_in *sin = (struct sockaddr_in *)&info->net.addr;
-               return sprintf(buf, "%u.%u.%u.%u:%d\n",
-                       NIPQUAD(sin->sin_addr.s_addr), ntohs(sin->sin_port));
-       } else if (family == AF_INET6) {
-               struct sockaddr_in6 *sin = (struct sockaddr_in6 *)
-                               &info->net.addr;
-               return sprintf(buf,
-                       "%pi6:%d\n",
-                       &sin->sin6_addr, ntohs(sin->sin6_port));
-       } else {
-               int i, sz = PAGE_SIZE - 2; /* 0 symbol and '\n' below */
-               int size, addrlen = info->net.addr.sa_data_len;
-               unsigned char *a = (unsigned char *)&info->net.addr.sa_data;
-               char *buf_orig = buf;
-
-               size = snprintf(buf, sz, "family: %d, addrlen: %u, addr: ",
-                               family, addrlen);
-               sz -= size;
-               buf += size;
-
-               for (i = 0; i < addrlen; ++i) {
-                       if (sz < 3)
-                               break;
-
-                       size = snprintf(buf, sz, "%02x ", a[i]);
-                       sz -= size;
-                       buf += size;
-               }
-               buf += sprintf(buf, "\n");
-
-               return buf - buf_orig;
-       }
-       return 0;
-}
-
-static struct device_attribute dst_node_attrs[] = {
-       __ATTR(size, 0444, dst_show_size, NULL),
-       __ATTR(type, 0444, dst_show_type, NULL),
-       __ATTR(local, 0444, dst_show_local, NULL),
-};
-
-static int dst_create_node_attributes(struct dst_node *n)
-{
-       int err, i;
-
-       for (i = 0; i < ARRAY_SIZE(dst_node_attrs); ++i) {
-               err = device_create_file(&n->info->device,
-                               &dst_node_attrs[i]);
-               if (err)
-                       goto err_out_remove_all;
-       }
-       return 0;
-
-err_out_remove_all:
-       while (--i >= 0)
-               device_remove_file(&n->info->device,
-                               &dst_node_attrs[i]);
-
-       return err;
-}
-
-static void dst_remove_node_attributes(struct dst_node *n)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(dst_node_attrs); ++i)
-               device_remove_file(&n->info->device,
-                               &dst_node_attrs[i]);
-}
-
-/*
- * Sysfs cleanup and initialization.
- * Shows number of useful parameters.
- */
-static void dst_node_sysfs_exit(struct dst_node *n)
-{
-       if (n->info) {
-               dst_remove_node_attributes(n);
-               device_unregister(&n->info->device);
-               n->info = NULL;
-       }
-}
-
-static int dst_node_sysfs_init(struct dst_node *n)
-{
-       int err;
-
-       n->info = kzalloc(sizeof(struct dst_info), GFP_KERNEL);
-       if (!n->info)
-               return -ENOMEM;
-
-       memcpy(&n->info->device, &dst_node_dev, sizeof(struct device));
-       n->info->size = n->size;
-
-       dev_set_name(&n->info->device, "dst-%s", n->name);
-       err = device_register(&n->info->device);
-       if (err) {
-               dprintk(KERN_ERR "Failed to register node '%s', err: %d.\n",
-                               n->name, err);
-               goto err_out_exit;
-       }
-
-       dst_create_node_attributes(n);
-
-       return 0;
-
-err_out_exit:
-       kfree(n->info);
-       n->info = NULL;
-       return err;
-}
-
-/*
- * DST node hash tables machinery.
- */
-static inline unsigned int dst_hash(char *str, unsigned int size)
-{
-       return jhash(str, size, 0) % dst_hashtable_size;
-}
-
-static void dst_node_remove(struct dst_node *n)
-{
-       mutex_lock(&dst_hash_lock);
-       list_del_init(&n->node_entry);
-       mutex_unlock(&dst_hash_lock);
-}
-
-static void dst_node_add(struct dst_node *n)
-{
-       unsigned hash = dst_hash(n->name, sizeof(n->name));
-
-       mutex_lock(&dst_hash_lock);
-       list_add_tail(&n->node_entry, &dst_hashtable[hash]);
-       mutex_unlock(&dst_hash_lock);
-}
-
-/*
- * Cleaning node when it is about to be freed.
- * There are still users of the socket though,
- * so connection cleanup should be protected.
- */
-static void dst_node_cleanup(struct dst_node *n)
-{
-       struct dst_state *st = n->state;
-
-       if (!st)
-               return;
-
-       if (n->queue) {
-               blk_cleanup_queue(n->queue);
-
-               mutex_lock(&dst_hash_lock);
-               idr_remove(&dst_index_idr, n->disk->first_minor);
-               mutex_unlock(&dst_hash_lock);
-
-               put_disk(n->disk);
-       }
-
-       if (n->bdev) {
-               sync_blockdev(n->bdev);
-               blkdev_put(n->bdev, FMODE_READ|FMODE_WRITE);
-       }
-
-       dst_state_lock(st);
-       st->need_exit = 1;
-       dst_state_exit_connected(st);
-       dst_state_unlock(st);
-
-       wake_up(&st->thread_wait);
-
-       dst_state_put(st);
-       n->state = NULL;
-}
-
-/*
- * Free security attributes attached to given node.
- */
-static void dst_security_exit(struct dst_node *n)
-{
-       struct dst_secure *s, *tmp;
-
-       list_for_each_entry_safe(s, tmp, &n->security_list, sec_entry) {
-               list_del(&s->sec_entry);
-               kfree(s);
-       }
-}
-
-/*
- * Free node when there are no more users.
- * Actually node has to be freed on behalf od userspace process,
- * since there are number of threads, which are embedded in the
- * node, so they can not exit and free node from there, that is
- * why there is a wakeup if reference counter is not equal to zero.
- */
-void dst_node_put(struct dst_node *n)
-{
-       if (unlikely(!n))
-               return;
-
-       dprintk("%s: n: %p, refcnt: %d.\n",
-                       __func__, n, atomic_read(&n->refcnt));
-
-       if (atomic_dec_and_test(&n->refcnt)) {
-               dst_node_remove(n);
-               n->trans_scan_timeout = 0;
-               dst_node_cleanup(n);
-               thread_pool_destroy(n->pool);
-               dst_node_sysfs_exit(n);
-               dst_node_crypto_exit(n);
-               dst_security_exit(n);
-               dst_node_trans_exit(n);
-
-               kfree(n);
-
-               dprintk("%s: freed n: %p.\n", __func__, n);
-       } else {
-               wake_up(&n->wait);
-       }
-}
-
-/*
- * This function finds devices major/minor numbers for given pathname.
- */
-static int dst_lookup_device(const char *path, dev_t *dev)
-{
-       int err;
-       struct nameidata nd;
-       struct inode *inode;
-
-       err = path_lookup(path, LOOKUP_FOLLOW, &nd);
-       if (err)
-               return err;
-
-       inode = nd.path.dentry->d_inode;
-       if (!inode) {
-               err = -ENOENT;
-               goto out;
-       }
-
-       if (!S_ISBLK(inode->i_mode)) {
-               err = -ENOTBLK;
-               goto out;
-       }
-
-       *dev = inode->i_rdev;
-
-out:
-       path_put(&nd.path);
-       return err;
-}
-
-/*
- * Setting up export device: lookup by the name, get its size
- * and setup listening socket, which will accept clients, which
- * will submit IO for given storage.
- */
-static int dst_setup_export(struct dst_node *n, struct dst_ctl *ctl,
-               struct dst_export_ctl *le)
-{
-       int err;
-       dev_t dev = 0; /* gcc likes to scream here */
-
-       snprintf(n->info->local, sizeof(n->info->local), "%s", le->device);
-
-       err = dst_lookup_device(le->device, &dev);
-       if (err)
-               return err;
-
-       n->bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE);
-       if (!n->bdev)
-               return -ENODEV;
-
-       if (n->size != 0)
-               n->size = min_t(loff_t, n->bdev->bd_inode->i_size, n->size);
-       else
-               n->size = n->bdev->bd_inode->i_size;
-
-       n->info->size = n->size;
-       err = dst_node_init_listened(n, le);
-       if (err)
-               goto err_out_cleanup;
-
-       return 0;
-
-err_out_cleanup:
-       blkdev_put(n->bdev, FMODE_READ|FMODE_WRITE);
-       n->bdev = NULL;
-
-       return err;
-}
-
-/* Empty thread pool callbacks for the network processing threads. */
-static inline void *dst_thread_network_init(void *data)
-{
-       dprintk("%s: data: %p.\n", __func__, data);
-       return data;
-}
-
-static inline void dst_thread_network_cleanup(void *data)
-{
-       dprintk("%s: data: %p.\n", __func__, data);
-}
-
-/*
- * Allocate DST node and initialize some of its parameters.
- */
-static struct dst_node *dst_alloc_node(struct dst_ctl *ctl,
-               int (*start)(struct dst_node *),
-               int num)
-{
-       struct dst_node *n;
-       int err;
-
-       n = kzalloc(sizeof(struct dst_node), GFP_KERNEL);
-       if (!n)
-               return NULL;
-
-       INIT_LIST_HEAD(&n->node_entry);
-
-       INIT_LIST_HEAD(&n->security_list);
-       mutex_init(&n->security_lock);
-
-       init_waitqueue_head(&n->wait);
-
-       n->trans_scan_timeout = msecs_to_jiffies(ctl->trans_scan_timeout);
-       if (!n->trans_scan_timeout)
-               n->trans_scan_timeout = HZ;
-
-       n->trans_max_retries = ctl->trans_max_retries;
-       if (!n->trans_max_retries)
-               n->trans_max_retries = 10;
-
-       /*
-        * Pretty much arbitrary default numbers.
-        * 32 matches maximum number of pages in bio originated from ext3 (31).
-        */
-       n->max_pages = ctl->max_pages;
-       if (!n->max_pages)
-               n->max_pages = 32;
-
-       if (n->max_pages > 1024)
-               n->max_pages = 1024;
-
-       n->start = start;
-       n->size = ctl->size;
-
-       atomic_set(&n->refcnt, 1);
-       atomic_long_set(&n->gen, 0);
-       snprintf(n->name, sizeof(n->name), "%s", ctl->name);
-
-       err = dst_node_sysfs_init(n);
-       if (err)
-               goto err_out_free;
-
-       n->pool = thread_pool_create(num, n->name, dst_thread_network_init,
-                       dst_thread_network_cleanup, n);
-       if (IS_ERR(n->pool)) {
-               err = PTR_ERR(n->pool);
-               goto err_out_sysfs_exit;
-       }
-
-       dprintk("%s: n: %p, name: %s.\n", __func__, n, n->name);
-
-       return n;
-
-err_out_sysfs_exit:
-       dst_node_sysfs_exit(n);
-err_out_free:
-       kfree(n);
-       return NULL;
-}
-
-/*
- * Starting a node, connected to the remote server:
- * register block device and initialize transaction mechanism.
- * In revers order though.
- *
- * It will autonegotiate some parameters with the remote node
- * and update local if needed.
- *
- * Transaction initialization should be the last thing before
- * starting the node, since transaction should include not only
- * block IO, but also crypto related data (if any), which are
- * initialized separately.
- */
-static int dst_start_remote(struct dst_node *n)
-{
-       int err;
-
-       err = dst_node_trans_init(n, sizeof(struct dst_trans));
-       if (err)
-               return err;
-
-       err = dst_node_create_disk(n);
-       if (err)
-               return err;
-
-       dst_node_set_size(n);
-       add_disk(n->disk);
-
-       dprintk("DST: started remote node '%s', minor: %d.\n",
-                       n->name, n->disk->first_minor);
-
-       return 0;
-}
-
-/*
- * Adding remote node and initialize connection.
- */
-static int dst_add_remote(struct dst_node *n, struct dst_ctl *ctl,
-               void *data, unsigned int size)
-{
-       int err;
-       struct dst_network_ctl *rctl = data;
-
-       if (n)
-               return -EEXIST;
-
-       if (size != sizeof(struct dst_network_ctl))
-               return -EINVAL;
-
-       n = dst_alloc_node(ctl, dst_start_remote, 1);
-       if (!n)
-               return -ENOMEM;
-
-       memcpy(&n->info->net, rctl, sizeof(struct dst_network_ctl));
-       err = dst_node_init_connected(n, rctl);
-       if (err)
-               goto err_out_free;
-
-       dst_node_add(n);
-
-       return 0;
-
-err_out_free:
-       dst_node_put(n);
-       return err;
-}
-
-/*
- * Adding export node: initializing block device and listening socket.
- */
-static int dst_add_export(struct dst_node *n, struct dst_ctl *ctl,
-               void *data, unsigned int size)
-{
-       int err;
-       struct dst_export_ctl *le = data;
-
-       if (n)
-               return -EEXIST;
-
-       if (size != sizeof(struct dst_export_ctl))
-               return -EINVAL;
-
-       n = dst_alloc_node(ctl, dst_start_export, 2);
-       if (!n)
-               return -EINVAL;
-
-       err = dst_setup_export(n, ctl, le);
-       if (err)
-               goto err_out_free;
-
-       dst_node_add(n);
-
-       return 0;
-
-err_out_free:
-       dst_node_put(n);
-       return err;
-}
-
-static int dst_node_remove_unload(struct dst_node *n)
-{
-       printk(KERN_INFO "STOPPED name: '%s', size: %llu.\n",
-                       n->name, n->size);
-
-       if (n->disk)
-               del_gendisk(n->disk);
-
-       dst_node_remove(n);
-       dst_node_sysfs_exit(n);
-
-       /*
-        * This is not a hack. Really.
-        * Node's reference counter allows to implement fine grained
-        * node freeing, but since all transactions (which hold node's
-        * reference counter) are processed in the dedicated thread,
-        * it is possible that reference will hit zero in that thread,
-        * so we will not be able to exit thread and cleanup the node.
-        *
-        * So, we remove disk, so no new activity is possible, and
-        * wait until all pending transaction are completed (either
-        * in receiving thread or by timeout in workqueue), in this
-        * case reference counter will be less or equal to 2 (once set in
-        * dst_alloc_node() and then in connector message parser;
-        * or when we force module unloading, and connector message
-        * parser does not hold a reference, in this case reference
-        * counter will be equal to 1),
-        * and subsequent dst_node_put() calls will free the node.
-        */
-       dprintk("%s: going to sleep with %d refcnt.\n",
-                       __func__, atomic_read(&n->refcnt));
-       wait_event(n->wait, atomic_read(&n->refcnt) <= 2);
-
-       dst_node_put(n);
-       return 0;
-}
-
-/*
- * Remove node from the hash table.
- */
-static int dst_del_node(struct dst_node *n, struct dst_ctl *ctl,
-               void *data, unsigned int size)
-{
-       if (!n)
-               return -ENODEV;
-
-       return dst_node_remove_unload(n);
-}
-
-/*
- * Initialize crypto processing for given node.
- */
-static int dst_crypto_init(struct dst_node *n, struct dst_ctl *ctl,
-               void *data, unsigned int size)
-{
-       struct dst_crypto_ctl *crypto = data;
-
-       if (!n)
-               return -ENODEV;
-
-       if (size != sizeof(struct dst_crypto_ctl) + crypto->hash_keysize +
-                       crypto->cipher_keysize)
-               return -EINVAL;
-
-       if (n->trans_cache)
-               return -EEXIST;
-
-       return dst_node_crypto_init(n, crypto);
-}
-
-/*
- * Security attributes for given node.
- */
-static int dst_security_init(struct dst_node *n, struct dst_ctl *ctl,
-               void *data, unsigned int size)
-{
-       struct dst_secure *s;
-
-       if (!n)
-               return -ENODEV;
-
-       if (size != sizeof(struct dst_secure_user))
-               return -EINVAL;
-
-       s = kmalloc(sizeof(struct dst_secure), GFP_KERNEL);
-       if (!s)
-               return -ENOMEM;
-
-       memcpy(&s->sec, data, size);
-
-       mutex_lock(&n->security_lock);
-       list_add_tail(&s->sec_entry, &n->security_list);
-       mutex_unlock(&n->security_lock);
-
-       return 0;
-}
-
-/*
- * Kill'em all!
- */
-static int dst_start_node(struct dst_node *n, struct dst_ctl *ctl,
-               void *data, unsigned int size)
-{
-       int err;
-
-       if (!n)
-               return -ENODEV;
-
-       if (n->trans_cache)
-               return 0;
-
-       err = n->start(n);
-       if (err)
-               return err;
-
-       printk(KERN_INFO "STARTED name: '%s', size: %llu.\n", n->name, n->size);
-       return 0;
-}
-
-typedef int (*dst_command_func)(struct dst_node *n, struct dst_ctl *ctl,
-               void *data, unsigned int size);
-
-/*
- * List of userspace commands.
- */
-static dst_command_func dst_commands[] = {
-       [DST_ADD_REMOTE] = &dst_add_remote,
-       [DST_ADD_EXPORT] = &dst_add_export,
-       [DST_DEL_NODE] = &dst_del_node,
-       [DST_CRYPTO] = &dst_crypto_init,
-       [DST_SECURITY] = &dst_security_init,
-       [DST_START] = &dst_start_node,
-};
-
-/*
- * Configuration parser.
- */
-static void cn_dst_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
-{
-       struct dst_ctl *ctl;
-       int err;
-       struct dst_ctl_ack ack;
-       struct dst_node *n = NULL, *tmp;
-       unsigned int hash;
-
-       if (!cap_raised(nsp->eff_cap, CAP_SYS_ADMIN)) {
-               err = -EPERM;
-               goto out;
-       }
-
-       if (msg->len < sizeof(struct dst_ctl)) {
-               err = -EBADMSG;
-               goto out;
-       }
-
-       ctl = (struct dst_ctl *)msg->data;
-
-       if (ctl->cmd >= DST_CMD_MAX) {
-               err = -EINVAL;
-               goto out;
-       }
-       hash = dst_hash(ctl->name, sizeof(ctl->name));
-
-       mutex_lock(&dst_hash_lock);
-       list_for_each_entry(tmp, &dst_hashtable[hash], node_entry) {
-               if (!memcmp(tmp->name, ctl->name, sizeof(tmp->name))) {
-                       n = tmp;
-                       dst_node_get(n);
-                       break;
-               }
-       }
-       mutex_unlock(&dst_hash_lock);
-
-       err = dst_commands[ctl->cmd](n, ctl, msg->data + sizeof(struct dst_ctl),
-                       msg->len - sizeof(struct dst_ctl));
-
-       dst_node_put(n);
-out:
-       memcpy(&ack.msg, msg, sizeof(struct cn_msg));
-
-       ack.msg.ack = msg->ack + 1;
-       ack.msg.len = sizeof(struct dst_ctl_ack) - sizeof(struct cn_msg);
-
-       ack.error = err;
-
-       cn_netlink_send(&ack.msg, 0, GFP_KERNEL);
-}
-
-/*
- * Global initialization: sysfs, hash table, block device registration,
- * connector and various caches.
- */
-static int __init dst_sysfs_init(void)
-{
-       return bus_register(&dst_dev_bus_type);
-}
-
-static void dst_sysfs_exit(void)
-{
-       bus_unregister(&dst_dev_bus_type);
-}
-
-static int __init dst_hashtable_init(void)
-{
-       unsigned int i;
-
-       dst_hashtable = kcalloc(dst_hashtable_size, sizeof(struct list_head),
-                       GFP_KERNEL);
-       if (!dst_hashtable)
-               return -ENOMEM;
-
-       for (i = 0; i < dst_hashtable_size; ++i)
-               INIT_LIST_HEAD(&dst_hashtable[i]);
-
-       return 0;
-}
-
-static void dst_hashtable_exit(void)
-{
-       unsigned int i;
-       struct dst_node *n, *tmp;
-
-       for (i = 0; i < dst_hashtable_size; ++i) {
-               list_for_each_entry_safe(n, tmp, &dst_hashtable[i], node_entry) {
-                       dst_node_remove_unload(n);
-               }
-       }
-
-       kfree(dst_hashtable);
-}
-
-static int __init dst_sys_init(void)
-{
-       int err = -ENOMEM;
-
-       err = dst_hashtable_init();
-       if (err)
-               goto err_out_exit;
-
-       err = dst_export_init();
-       if (err)
-               goto err_out_hashtable_exit;
-
-       err = register_blkdev(dst_major, DST_NAME);
-       if (err < 0)
-               goto err_out_export_exit;
-       if (err)
-               dst_major = err;
-
-       err = dst_sysfs_init();
-       if (err)
-               goto err_out_unregister;
-
-       err = cn_add_callback(&cn_dst_id, "DST", cn_dst_callback);
-       if (err)
-               goto err_out_sysfs_exit;
-
-       printk(KERN_INFO "Distributed storage, '%s' release.\n", dst_name);
-
-       return 0;
-
-err_out_sysfs_exit:
-       dst_sysfs_exit();
-err_out_unregister:
-       unregister_blkdev(dst_major, DST_NAME);
-err_out_export_exit:
-       dst_export_exit();
-err_out_hashtable_exit:
-       dst_hashtable_exit();
-err_out_exit:
-       return err;
-}
-
-static void __exit dst_sys_exit(void)
-{
-       cn_del_callback(&cn_dst_id);
-       unregister_blkdev(dst_major, DST_NAME);
-       dst_hashtable_exit();
-       dst_sysfs_exit();
-       dst_export_exit();
-}
-
-module_init(dst_sys_init);
-module_exit(dst_sys_exit);
-
-MODULE_DESCRIPTION("Distributed storage");
-MODULE_AUTHOR("Evgeniy Polyakov <zbr@ioremap.net>");
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/dst/export.c b/drivers/staging/dst/export.c
deleted file mode 100644 (file)
index c324230..0000000
+++ /dev/null
@@ -1,660 +0,0 @@
-/*
- * 2007+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <linux/blkdev.h>
-#include <linux/bio.h>
-#include <linux/dst.h>
-#include <linux/in.h>
-#include <linux/in6.h>
-#include <linux/poll.h>
-#include <linux/slab.h>
-#include <linux/socket.h>
-
-#include <net/sock.h>
-
-/*
- * Export bioset is used for server block IO requests.
- */
-static struct bio_set *dst_bio_set;
-
-int __init dst_export_init(void)
-{
-       int err = -ENOMEM;
-
-       dst_bio_set = bioset_create(32, sizeof(struct dst_export_priv));
-       if (!dst_bio_set)
-               goto err_out_exit;
-
-       return 0;
-
-err_out_exit:
-       return err;
-}
-
-void dst_export_exit(void)
-{
-       bioset_free(dst_bio_set);
-}
-
-/*
- * When client connects and autonegotiates with the server node,
- * its permissions are checked in a security attributes and sent
- * back.
- */
-static unsigned int dst_check_permissions(struct dst_state *main,
-               struct dst_state *st)
-{
-       struct dst_node *n = main->node;
-       struct dst_secure *sentry;
-       struct dst_secure_user *s;
-       struct saddr *sa = &st->ctl.addr;
-       unsigned int perm = 0;
-
-       mutex_lock(&n->security_lock);
-       list_for_each_entry(sentry, &n->security_list, sec_entry) {
-               s = &sentry->sec;
-
-               if (s->addr.sa_family != sa->sa_family)
-                       continue;
-
-               if (s->addr.sa_data_len != sa->sa_data_len)
-                       continue;
-
-               /*
-                * This '2' below is a port field. This may be very wrong to do
-                * in atalk for example though. If there will be any need
-                * to extent protocol to something else, I can create
-                * per-family helpers and use them instead of this memcmp.
-                */
-               if (memcmp(s->addr.sa_data + 2, sa->sa_data + 2,
-                                       sa->sa_data_len - 2))
-                       continue;
-
-               perm = s->permissions;
-       }
-       mutex_unlock(&n->security_lock);
-
-       return perm;
-}
-
-/*
- * Accept new client: allocate appropriate network state and check permissions.
- */
-static struct dst_state *dst_accept_client(struct dst_state *st)
-{
-       unsigned int revents = 0;
-       unsigned int err_mask = POLLERR | POLLHUP | POLLRDHUP;
-       unsigned int mask = err_mask | POLLIN;
-       struct dst_node *n = st->node;
-       int err = 0;
-       struct socket *sock = NULL;
-       struct dst_state *new;
-
-       while (!err && !sock) {
-               revents = dst_state_poll(st);
-
-               if (!(revents & mask)) {
-                       DEFINE_WAIT(wait);
-
-                       for (;;) {
-                               prepare_to_wait(&st->thread_wait,
-                                               &wait, TASK_INTERRUPTIBLE);
-                               if (!n->trans_scan_timeout || st->need_exit)
-                                       break;
-
-                               revents = dst_state_poll(st);
-
-                               if (revents & mask)
-                                       break;
-
-                               if (signal_pending(current))
-                                       break;
-
-                               /*
-                                * Magic HZ? Polling check above is not safe in
-                                * all cases (like socket reset in BH context),
-                                * so it is simpler just to postpone it to the
-                                * process context instead of implementing
-                                * special locking there.
-                                */
-                               schedule_timeout(HZ);
-                       }
-                       finish_wait(&st->thread_wait, &wait);
-               }
-
-               err = -ECONNRESET;
-               dst_state_lock(st);
-
-               dprintk("%s: st: %p, revents: %x [err: %d, in: %d].\n",
-                       __func__, st, revents, revents & err_mask,
-                       revents & POLLIN);
-
-               if (revents & err_mask) {
-                       dprintk("%s: revents: %x, socket: %p, err: %d.\n",
-                                       __func__, revents, st->socket, err);
-                       err = -ECONNRESET;
-               }
-
-               if (!n->trans_scan_timeout || st->need_exit)
-                       err = -ENODEV;
-
-               if (st->socket && (revents & POLLIN))
-                       err = kernel_accept(st->socket, &sock, 0);
-
-               dst_state_unlock(st);
-       }
-
-       if (err)
-               goto err_out_exit;
-
-       new = dst_state_alloc(st->node);
-       if (IS_ERR(new)) {
-               err = -ENOMEM;
-               goto err_out_release;
-       }
-       new->socket = sock;
-
-       new->ctl.addr.sa_data_len = sizeof(struct sockaddr);
-       err = kernel_getpeername(sock, (struct sockaddr *)&new->ctl.addr,
-                       (int *)&new->ctl.addr.sa_data_len);
-       if (err)
-               goto err_out_put;
-
-       new->permissions = dst_check_permissions(st, new);
-       if (new->permissions == 0) {
-               err = -EPERM;
-               dst_dump_addr(sock, (struct sockaddr *)&new->ctl.addr,
-                               "Client is not allowed to connect");
-               goto err_out_put;
-       }
-
-       err = dst_poll_init(new);
-       if (err)
-               goto err_out_put;
-
-       dst_dump_addr(sock, (struct sockaddr *)&new->ctl.addr,
-                       "Connected client");
-
-       return new;
-
-err_out_put:
-       dst_state_put(new);
-err_out_release:
-       sock_release(sock);
-err_out_exit:
-       return ERR_PTR(err);
-}
-
-/*
- * Each server's block request sometime finishes.
- * Usually it happens in hard irq context of the appropriate controller,
- * so to play good with all cases we just queue BIO into the queue
- * and wake up processing thread, which gets completed request and
- * send (encrypting if needed) it back to the client (if it was a read
- * request), or sends back reply that writing successfully completed.
- */
-static int dst_export_process_request_queue(struct dst_state *st)
-{
-       unsigned long flags;
-       struct dst_export_priv *p = NULL;
-       struct bio *bio;
-       int err = 0;
-
-       while (!list_empty(&st->request_list)) {
-               spin_lock_irqsave(&st->request_lock, flags);
-               if (!list_empty(&st->request_list)) {
-                       p = list_first_entry(&st->request_list,
-                               struct dst_export_priv, request_entry);
-                       list_del(&p->request_entry);
-               }
-               spin_unlock_irqrestore(&st->request_lock, flags);
-
-               if (!p)
-                       break;
-
-               bio = p->bio;
-
-               if (dst_need_crypto(st->node) && (bio_data_dir(bio) == READ))
-                       err = dst_export_crypto(st->node, bio);
-               else
-                       err = dst_export_send_bio(bio);
-
-               if (err)
-                       break;
-       }
-
-       return err;
-}
-
-/*
- * Cleanup export state.
- * It has to wait until all requests are finished,
- * and then free them all.
- */
-static void dst_state_cleanup_export(struct dst_state *st)
-{
-       struct dst_export_priv *p;
-       unsigned long flags;
-
-       /*
-        * This loop waits for all pending bios to be completed and freed.
-        */
-       while (atomic_read(&st->refcnt) > 1) {
-               dprintk("%s: st: %p, refcnt: %d, list_empty: %d.\n",
-                               __func__, st, atomic_read(&st->refcnt),
-                               list_empty(&st->request_list));
-               wait_event_timeout(st->thread_wait,
-                               (atomic_read(&st->refcnt) == 1) ||
-                               !list_empty(&st->request_list),
-                               HZ/2);
-
-               while (!list_empty(&st->request_list)) {
-                       p = NULL;
-                       spin_lock_irqsave(&st->request_lock, flags);
-                       if (!list_empty(&st->request_list)) {
-                               p = list_first_entry(&st->request_list,
-                                       struct dst_export_priv, request_entry);
-                               list_del(&p->request_entry);
-                       }
-                       spin_unlock_irqrestore(&st->request_lock, flags);
-
-                       if (p)
-                               bio_put(p->bio);
-
-                       dprintk("%s: st: %p, refcnt: %d, list_empty: %d, p: "
-                               "%p.\n", __func__, st, atomic_read(&st->refcnt),
-                               list_empty(&st->request_list), p);
-               }
-       }
-
-       dst_state_put(st);
-}
-
-/*
- * Client accepting thread.
- * Not only accepts new connection, but also schedules receiving thread
- * and performs request completion described above.
- */
-static int dst_accept(void *init_data, void *schedule_data)
-{
-       struct dst_state *main_st = schedule_data;
-       struct dst_node *n = init_data;
-       struct dst_state *st;
-       int err;
-
-       while (n->trans_scan_timeout && !main_st->need_exit) {
-               dprintk("%s: main_st: %p, n: %p.\n", __func__, main_st, n);
-               st = dst_accept_client(main_st);
-               if (IS_ERR(st))
-                       continue;
-
-               err = dst_state_schedule_receiver(st);
-               if (!err) {
-                       while (n->trans_scan_timeout) {
-                               err = wait_event_interruptible_timeout(st->thread_wait,
-                                       !list_empty(&st->request_list) ||
-                                       !n->trans_scan_timeout ||
-                                       st->need_exit,
-                                       HZ);
-
-                               if (!n->trans_scan_timeout || st->need_exit)
-                                       break;
-
-                               if (list_empty(&st->request_list))
-                                       continue;
-
-                               err = dst_export_process_request_queue(st);
-                               if (err)
-                                       break;
-                       }
-
-                       st->need_exit = 1;
-                       wake_up(&st->thread_wait);
-               }
-
-               dst_state_cleanup_export(st);
-       }
-
-       dprintk("%s: freeing listening socket st: %p.\n", __func__, main_st);
-
-       dst_state_lock(main_st);
-       dst_poll_exit(main_st);
-       dst_state_socket_release(main_st);
-       dst_state_unlock(main_st);
-       dst_state_put(main_st);
-       dprintk("%s: freed listening socket st: %p.\n", __func__, main_st);
-
-       return 0;
-}
-
-int dst_start_export(struct dst_node *n)
-{
-       if (list_empty(&n->security_list)) {
-               printk(KERN_ERR "You are trying to export node '%s' "
-                               "without security attributes.\nNo clients will "
-                               "be allowed to connect. Exiting.\n", n->name);
-               return -EINVAL;
-       }
-       return dst_node_trans_init(n, sizeof(struct dst_export_priv));
-}
-
-/*
- * Initialize listening state and schedule accepting thread.
- */
-int dst_node_init_listened(struct dst_node *n, struct dst_export_ctl *le)
-{
-       struct dst_state *st;
-       int err = -ENOMEM;
-       struct dst_network_ctl *ctl = &le->ctl;
-
-       memcpy(&n->info->net, ctl, sizeof(struct dst_network_ctl));
-
-       st = dst_state_alloc(n);
-       if (IS_ERR(st)) {
-               err = PTR_ERR(st);
-               goto err_out_exit;
-       }
-       memcpy(&st->ctl, ctl, sizeof(struct dst_network_ctl));
-
-       err = dst_state_socket_create(st);
-       if (err)
-               goto err_out_put;
-
-       st->socket->sk->sk_reuse = 1;
-
-       err = kernel_bind(st->socket, (struct sockaddr *)&ctl->addr,
-                       ctl->addr.sa_data_len);
-       if (err)
-               goto err_out_socket_release;
-
-       err = kernel_listen(st->socket, 1024);
-       if (err)
-               goto err_out_socket_release;
-       n->state = st;
-
-       err = dst_poll_init(st);
-       if (err)
-               goto err_out_socket_release;
-
-       dst_state_get(st);
-
-       err = thread_pool_schedule(n->pool, dst_thread_setup,
-                       dst_accept, st, MAX_SCHEDULE_TIMEOUT);
-       if (err)
-               goto err_out_poll_exit;
-
-       return 0;
-
-err_out_poll_exit:
-       dst_poll_exit(st);
-err_out_socket_release:
-       dst_state_socket_release(st);
-err_out_put:
-       dst_state_put(st);
-err_out_exit:
-       n->state = NULL;
-       return err;
-}
-
-/*
- * Free bio and related private data.
- * Also drop a reference counter for appropriate state,
- * which waits when there are no more block IOs in-flight.
- */
-static void dst_bio_destructor(struct bio *bio)
-{
-       struct bio_vec *bv;
-       struct dst_export_priv *priv = bio->bi_private;
-       int i;
-
-       bio_for_each_segment(bv, bio, i) {
-               if (!bv->bv_page)
-                       break;
-
-               __free_page(bv->bv_page);
-       }
-
-       if (priv)
-               dst_state_put(priv->state);
-       bio_free(bio, dst_bio_set);
-}
-
-/*
- * Block IO completion. Queue request to be sent back to
- * the client (or just confirmation).
- */
-static void dst_bio_end_io(struct bio *bio, int err)
-{
-       struct dst_export_priv *p = bio->bi_private;
-       struct dst_state *st = p->state;
-       unsigned long flags;
-
-       spin_lock_irqsave(&st->request_lock, flags);
-       list_add_tail(&p->request_entry, &st->request_list);
-       spin_unlock_irqrestore(&st->request_lock, flags);
-
-       wake_up(&st->thread_wait);
-}
-
-/*
- * Allocate read request for the server.
- */
-static int dst_export_read_request(struct bio *bio, unsigned int total_size)
-{
-       unsigned int size;
-       struct page *page;
-       int err;
-
-       while (total_size) {
-               err = -ENOMEM;
-               page = alloc_page(GFP_KERNEL);
-               if (!page)
-                       goto err_out_exit;
-
-               size = min_t(unsigned int, PAGE_SIZE, total_size);
-
-               err = bio_add_page(bio, page, size, 0);
-               dprintk("%s: bio: %llu/%u, size: %u, err: %d.\n",
-                               __func__, (u64)bio->bi_sector, bio->bi_size,
-                               size, err);
-               if (err <= 0)
-                       goto err_out_free_page;
-
-               total_size -= size;
-       }
-
-       return 0;
-
-err_out_free_page:
-       __free_page(page);
-err_out_exit:
-       return err;
-}
-
-/*
- * Allocate write request for the server.
- * Should not only get pages, but also read data from the network.
- */
-static int dst_export_write_request(struct dst_state *st,
-               struct bio *bio, unsigned int total_size)
-{
-       unsigned int size;
-       struct page *page;
-       void *data;
-       int err;
-
-       while (total_size) {
-               err = -ENOMEM;
-               page = alloc_page(GFP_KERNEL);
-               if (!page)
-                       goto err_out_exit;
-
-               data = kmap(page);
-               if (!data)
-                       goto err_out_free_page;
-
-               size = min_t(unsigned int, PAGE_SIZE, total_size);
-
-               err = dst_data_recv(st, data, size);
-               if (err)
-                       goto err_out_unmap_page;
-
-               err = bio_add_page(bio, page, size, 0);
-               if (err <= 0)
-                       goto err_out_unmap_page;
-
-               kunmap(page);
-
-               total_size -= size;
-       }
-
-       return 0;
-
-err_out_unmap_page:
-       kunmap(page);
-err_out_free_page:
-       __free_page(page);
-err_out_exit:
-       return err;
-}
-
-/*
- * Groovy, we've gotten an IO request from the client.
- * Allocate BIO from the bioset, private data from the mempool
- * and lots of pages for IO.
- */
-int dst_process_io(struct dst_state *st)
-{
-       struct dst_node *n = st->node;
-       struct dst_cmd *cmd = st->data;
-       struct bio *bio;
-       struct dst_export_priv *priv;
-       int err = -ENOMEM;
-
-       if (unlikely(!n->bdev)) {
-               err = -EINVAL;
-               goto err_out_exit;
-       }
-
-       bio = bio_alloc_bioset(GFP_KERNEL,
-                       PAGE_ALIGN(cmd->size) >> PAGE_SHIFT,
-                       dst_bio_set);
-       if (!bio)
-               goto err_out_exit;
-
-       priv = (struct dst_export_priv *)(((void *)bio) -
-                       sizeof (struct dst_export_priv));
-
-       priv->state = dst_state_get(st);
-       priv->bio = bio;
-
-       bio->bi_private = priv;
-       bio->bi_end_io = dst_bio_end_io;
-       bio->bi_destructor = dst_bio_destructor;
-       bio->bi_bdev = n->bdev;
-
-       /*
-        * Server side is only interested in two low bits:
-        * uptodate (set by itself actually) and rw block
-        */
-       bio->bi_flags |= cmd->flags & 3;
-
-       bio->bi_rw = cmd->rw;
-       bio->bi_size = 0;
-       bio->bi_sector = cmd->sector;
-
-       dst_bio_to_cmd(bio, &priv->cmd, DST_IO_RESPONSE, cmd->id);
-
-       priv->cmd.flags = 0;
-       priv->cmd.size = cmd->size;
-
-       if (bio_data_dir(bio) == WRITE) {
-               err = dst_recv_cdata(st, priv->cmd.hash);
-               if (err)
-                       goto err_out_free;
-
-               err = dst_export_write_request(st, bio, cmd->size);
-               if (err)
-                       goto err_out_free;
-
-               if (dst_need_crypto(n))
-                       return dst_export_crypto(n, bio);
-       } else {
-               err = dst_export_read_request(bio, cmd->size);
-               if (err)
-                       goto err_out_free;
-       }
-
-       dprintk("%s: bio: %llu/%u, rw: %lu, dir: %lu, flags: %lx, phys: %d.\n",
-                       __func__, (u64)bio->bi_sector, bio->bi_size,
-                       bio->bi_rw, bio_data_dir(bio),
-                       bio->bi_flags, bio->bi_phys_segments);
-
-       generic_make_request(bio);
-
-       return 0;
-
-err_out_free:
-       bio_put(bio);
-err_out_exit:
-       return err;
-}
-
-/*
- * Ok, block IO is ready, let's send it back to the client...
- */
-int dst_export_send_bio(struct bio *bio)
-{
-       struct dst_export_priv *p = bio->bi_private;
-       struct dst_state *st = p->state;
-       struct dst_cmd *cmd = &p->cmd;
-       int err;
-
-       dprintk("%s: id: %llu, bio: %llu/%u, csize: %u, flags: %lu, rw: %lu.\n",
-                       __func__, cmd->id, (u64)bio->bi_sector, bio->bi_size,
-                       cmd->csize, bio->bi_flags, bio->bi_rw);
-
-       dst_convert_cmd(cmd);
-
-       dst_state_lock(st);
-       if (!st->socket) {
-               err = -ECONNRESET;
-               goto err_out_unlock;
-       }
-
-       if (bio_data_dir(bio) == WRITE) {
-               /* ... or just confirmation that writing has completed. */
-               cmd->size = cmd->csize = 0;
-               err = dst_data_send_header(st->socket, cmd,
-                               sizeof(struct dst_cmd), 0);
-               if (err)
-                       goto err_out_unlock;
-       } else {
-               err = dst_send_bio(st, cmd, bio);
-               if (err)
-                       goto err_out_unlock;
-       }
-
-       dst_state_unlock(st);
-
-       bio_put(bio);
-       return 0;
-
-err_out_unlock:
-       dst_state_unlock(st);
-
-       bio_put(bio);
-       return err;
-}
diff --git a/drivers/staging/dst/state.c b/drivers/staging/dst/state.c
deleted file mode 100644 (file)
index 02a05e6..0000000
+++ /dev/null
@@ -1,844 +0,0 @@
-/*
- * 2007+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <linux/buffer_head.h>
-#include <linux/blkdev.h>
-#include <linux/bio.h>
-#include <linux/connector.h>
-#include <linux/dst.h>
-#include <linux/device.h>
-#include <linux/in.h>
-#include <linux/in6.h>
-#include <linux/socket.h>
-#include <linux/slab.h>
-
-#include <net/sock.h>
-
-/*
- * Polling machinery.
- */
-
-struct dst_poll_helper {
-       poll_table              pt;
-       struct dst_state        *st;
-};
-
-static int dst_queue_wake(wait_queue_t *wait, unsigned mode,
-               int sync, void *key)
-{
-       struct dst_state *st = container_of(wait, struct dst_state, wait);
-
-       wake_up(&st->thread_wait);
-       return 1;
-}
-
-static void dst_queue_func(struct file *file, wait_queue_head_t *whead,
-                                poll_table *pt)
-{
-       struct dst_state *st = container_of(pt, struct dst_poll_helper, pt)->st;
-
-       st->whead = whead;
-       init_waitqueue_func_entry(&st->wait, dst_queue_wake);
-       add_wait_queue(whead, &st->wait);
-}
-
-void dst_poll_exit(struct dst_state *st)
-{
-       if (st->whead) {
-               remove_wait_queue(st->whead, &st->wait);
-               st->whead = NULL;
-       }
-}
-
-int dst_poll_init(struct dst_state *st)
-{
-       struct dst_poll_helper ph;
-
-       ph.st = st;
-       init_poll_funcptr(&ph.pt, &dst_queue_func);
-
-       st->socket->ops->poll(NULL, st->socket, &ph.pt);
-       return 0;
-}
-
-/*
- * Header receiving function - may block.
- */
-static int dst_data_recv_header(struct socket *sock,
-               void *data, unsigned int size, int block)
-{
-       struct msghdr msg;
-       struct kvec iov;
-       int err;
-
-       iov.iov_base = data;
-       iov.iov_len = size;
-
-       msg.msg_iov = (struct iovec *)&iov;
-       msg.msg_iovlen = 1;
-       msg.msg_name = NULL;
-       msg.msg_namelen = 0;
-       msg.msg_control = NULL;
-       msg.msg_controllen = 0;
-       msg.msg_flags = (block) ? MSG_WAITALL : MSG_DONTWAIT;
-
-       err = kernel_recvmsg(sock, &msg, &iov, 1, iov.iov_len,
-                       msg.msg_flags);
-       if (err != size)
-               return -1;
-
-       return 0;
-}
-
-/*
- * Header sending function - may block.
- */
-int dst_data_send_header(struct socket *sock,
-               void *data, unsigned int size, int more)
-{
-       struct msghdr msg;
-       struct kvec iov;
-       int err;
-
-       iov.iov_base = data;
-       iov.iov_len = size;
-
-       msg.msg_iov = (struct iovec *)&iov;
-       msg.msg_iovlen = 1;
-       msg.msg_name = NULL;
-       msg.msg_namelen = 0;
-       msg.msg_control = NULL;
-       msg.msg_controllen = 0;
-       msg.msg_flags = MSG_WAITALL | (more ? MSG_MORE : 0);
-
-       err = kernel_sendmsg(sock, &msg, &iov, 1, iov.iov_len);
-       if (err != size) {
-               dprintk("%s: size: %u, more: %d, err: %d.\n",
-                               __func__, size, more, err);
-               return -1;
-       }
-
-       return 0;
-}
-
-/*
- * Block autoconfiguration: request size of the storage and permissions.
- */
-static int dst_request_remote_config(struct dst_state *st)
-{
-       struct dst_node *n = st->node;
-       int err = -EINVAL;
-       struct dst_cmd *cmd = st->data;
-
-       memset(cmd, 0, sizeof(struct dst_cmd));
-       cmd->cmd = DST_CFG;
-
-       dst_convert_cmd(cmd);
-
-       err = dst_data_send_header(st->socket, cmd, sizeof(struct dst_cmd), 0);
-       if (err)
-               goto out;
-
-       err = dst_data_recv_header(st->socket, cmd, sizeof(struct dst_cmd), 1);
-       if (err)
-               goto out;
-
-       dst_convert_cmd(cmd);
-
-       if (cmd->cmd != DST_CFG) {
-               err = -EINVAL;
-               dprintk("%s: checking result: cmd: %d, size reported: %llu.\n",
-                       __func__, cmd->cmd, cmd->sector);
-               goto out;
-       }
-
-       if (n->size != 0)
-               n->size = min_t(loff_t, n->size, cmd->sector);
-       else
-               n->size = cmd->sector;
-
-       n->info->size = n->size;
-       st->permissions = cmd->rw;
-
-out:
-       dprintk("%s: n: %p, err: %d, size: %llu, permission: %x.\n",
-                       __func__, n, err, n->size, st->permissions);
-       return err;
-}
-
-/*
- * Socket machinery.
- */
-
-#define DST_DEFAULT_TIMEO      20000
-
-int dst_state_socket_create(struct dst_state *st)
-{
-       int err;
-       struct socket *sock;
-       struct dst_network_ctl *ctl = &st->ctl;
-
-       err = sock_create(ctl->addr.sa_family, ctl->type, ctl->proto, &sock);
-       if (err < 0)
-               return err;
-
-       sock->sk->sk_sndtimeo = sock->sk->sk_rcvtimeo =
-               msecs_to_jiffies(DST_DEFAULT_TIMEO);
-       sock->sk->sk_allocation = GFP_NOIO;
-
-       st->socket = st->read_socket = sock;
-       return 0;
-}
-
-void dst_state_socket_release(struct dst_state *st)
-{
-       dprintk("%s: st: %p, socket: %p, n: %p.\n",
-                       __func__, st, st->socket, st->node);
-       if (st->socket) {
-               sock_release(st->socket);
-               st->socket = NULL;
-               st->read_socket = NULL;
-       }
-}
-
-void dst_dump_addr(struct socket *sk, struct sockaddr *sa, char *str)
-{
-       if (sk->ops->family == AF_INET) {
-               struct sockaddr_in *sin = (struct sockaddr_in *)sa;
-               printk(KERN_INFO "%s %u.%u.%u.%u:%d.\n", str,
-                       NIPQUAD(sin->sin_addr.s_addr), ntohs(sin->sin_port));
-       } else if (sk->ops->family == AF_INET6) {
-               struct sockaddr_in6 *sin = (struct sockaddr_in6 *)sa;
-               printk(KERN_INFO "%s %pi6:%d",
-                       str, &sin->sin6_addr, ntohs(sin->sin6_port));
-       }
-}
-
-void dst_state_exit_connected(struct dst_state *st)
-{
-       if (st->socket) {
-               dst_poll_exit(st);
-               st->socket->ops->shutdown(st->socket, 2);
-
-               dst_dump_addr(st->socket, (struct sockaddr *)&st->ctl.addr,
-                               "Disconnected peer");
-               dst_state_socket_release(st);
-       }
-}
-
-static int dst_state_init_connected(struct dst_state *st)
-{
-       int err;
-       struct dst_network_ctl *ctl = &st->ctl;
-
-       err = dst_state_socket_create(st);
-       if (err)
-               goto err_out_exit;
-
-       err = kernel_connect(st->socket, (struct sockaddr *)&st->ctl.addr,
-                       st->ctl.addr.sa_data_len, 0);
-       if (err)
-               goto err_out_release;
-
-       err = dst_poll_init(st);
-       if (err)
-               goto err_out_release;
-
-       dst_dump_addr(st->socket, (struct sockaddr *)&ctl->addr,
-                       "Connected to peer");
-
-       return 0;
-
-err_out_release:
-       dst_state_socket_release(st);
-err_out_exit:
-       return err;
-}
-
-/*
- * State reset is used to reconnect to the remote peer.
- * May fail, but who cares, we will try again later.
- */
-static inline void dst_state_reset_nolock(struct dst_state *st)
-{
-       dst_state_exit_connected(st);
-       dst_state_init_connected(st);
-}
-
-static inline void dst_state_reset(struct dst_state *st)
-{
-       dst_state_lock(st);
-       dst_state_reset_nolock(st);
-       dst_state_unlock(st);
-}
-
-/*
- * Basic network sending/receiving functions.
- * Blocked mode is used.
- */
-static int dst_data_recv_raw(struct dst_state *st, void *buf, u64 size)
-{
-       struct msghdr msg;
-       struct kvec iov;
-       int err;
-
-       BUG_ON(!size);
-
-       iov.iov_base = buf;
-       iov.iov_len = size;
-
-       msg.msg_iov = (struct iovec *)&iov;
-       msg.msg_iovlen = 1;
-       msg.msg_name = NULL;
-       msg.msg_namelen = 0;
-       msg.msg_control = NULL;
-       msg.msg_controllen = 0;
-       msg.msg_flags = MSG_DONTWAIT;
-
-       err = kernel_recvmsg(st->socket, &msg, &iov, 1, iov.iov_len,
-                       msg.msg_flags);
-       if (err <= 0) {
-               dprintk("%s: failed to recv data: size: %llu, err: %d.\n",
-                               __func__, size, err);
-               if (err == 0)
-                       err = -ECONNRESET;
-
-               dst_state_exit_connected(st);
-       }
-
-       return err;
-}
-
-/*
- * Ping command to early detect failed nodes.
- */
-static int dst_send_ping(struct dst_state *st)
-{
-       struct dst_cmd *cmd = st->data;
-       int err = -ECONNRESET;
-
-       dst_state_lock(st);
-       if (st->socket) {
-               memset(cmd, 0, sizeof(struct dst_cmd));
-
-               cmd->cmd = __cpu_to_be32(DST_PING);
-
-               err = dst_data_send_header(st->socket, cmd,
-                               sizeof(struct dst_cmd), 0);
-       }
-       dprintk("%s: st: %p, socket: %p, err: %d.\n", __func__,
-                       st, st->socket, err);
-       dst_state_unlock(st);
-
-       return err;
-}
-
-/*
- * Receiving function, which should either return error or read
- * whole block request. If there was no traffic for a one second,
- * send a ping, since remote node may die.
- */
-int dst_data_recv(struct dst_state *st, void *data, unsigned int size)
-{
-       unsigned int revents = 0;
-       unsigned int err_mask = POLLERR | POLLHUP | POLLRDHUP;
-       unsigned int mask = err_mask | POLLIN;
-       struct dst_node *n = st->node;
-       int err = 0;
-
-       while (size && !err) {
-               revents = dst_state_poll(st);
-
-               if (!(revents & mask)) {
-                       DEFINE_WAIT(wait);
-
-                       for (;;) {
-                               prepare_to_wait(&st->thread_wait, &wait,
-                                               TASK_INTERRUPTIBLE);
-                               if (!n->trans_scan_timeout || st->need_exit)
-                                       break;
-
-                               revents = dst_state_poll(st);
-
-                               if (revents & mask)
-                                       break;
-
-                               if (signal_pending(current))
-                                       break;
-
-                               if (!schedule_timeout(HZ)) {
-                                       err = dst_send_ping(st);
-                                       if (err)
-                                               return err;
-                               }
-
-                               continue;
-                       }
-                       finish_wait(&st->thread_wait, &wait);
-               }
-
-               err = -ECONNRESET;
-               dst_state_lock(st);
-
-               if (st->socket && (st->read_socket == st->socket) &&
-                               (revents & POLLIN)) {
-                       err = dst_data_recv_raw(st, data, size);
-                       if (err > 0) {
-                               data += err;
-                               size -= err;
-                               err = 0;
-                       }
-               }
-
-               if (revents & err_mask || !st->socket) {
-                       dprintk("%s: revents: %x, socket: %p, size: %u, "
-                                       "err: %d.\n", __func__, revents,
-                                       st->socket, size, err);
-                       err = -ECONNRESET;
-               }
-
-               dst_state_unlock(st);
-
-               if (!n->trans_scan_timeout)
-                       err = -ENODEV;
-       }
-
-       return err;
-}
-
-/*
- * Send block autoconf reply.
- */
-static int dst_process_cfg(struct dst_state *st)
-{
-       struct dst_node *n = st->node;
-       struct dst_cmd *cmd = st->data;
-       int err;
-
-       cmd->sector = n->size;
-       cmd->rw = st->permissions;
-
-       dst_convert_cmd(cmd);
-
-       dst_state_lock(st);
-       err = dst_data_send_header(st->socket, cmd, sizeof(struct dst_cmd), 0);
-       dst_state_unlock(st);
-
-       return err;
-}
-
-/*
- * Receive block IO from the network.
- */
-static int dst_recv_bio(struct dst_state *st, struct bio *bio,
-               unsigned int total_size)
-{
-       struct bio_vec *bv;
-       int i, err;
-       void *data;
-       unsigned int sz;
-
-       bio_for_each_segment(bv, bio, i) {
-               sz = min(total_size, bv->bv_len);
-
-               dprintk("%s: bio: %llu/%u, total: %u, len: %u, sz: %u, "
-                               "off: %u.\n", __func__, (u64)bio->bi_sector,
-                               bio->bi_size, total_size, bv->bv_len, sz,
-                               bv->bv_offset);
-
-               data = kmap(bv->bv_page) + bv->bv_offset;
-               err = dst_data_recv(st, data, sz);
-               kunmap(bv->bv_page);
-
-               bv->bv_len = sz;
-
-               if (err)
-                       return err;
-
-               total_size -= sz;
-               if (total_size == 0)
-                       break;
-       }
-
-       return 0;
-}
-
-/*
- * Our block IO has just completed and arrived: get it.
- */
-static int dst_process_io_response(struct dst_state *st)
-{
-       struct dst_node *n = st->node;
-       struct dst_cmd *cmd = st->data;
-       struct dst_trans *t;
-       int err = 0;
-       struct bio *bio;
-
-       mutex_lock(&n->trans_lock);
-       t = dst_trans_search(n, cmd->id);
-       mutex_unlock(&n->trans_lock);
-
-       if (!t)
-               goto err_out_exit;
-
-       bio = t->bio;
-
-       dprintk("%s: bio: %llu/%u, cmd_size: %u, csize: %u, dir: %lu.\n",
-               __func__, (u64)bio->bi_sector, bio->bi_size, cmd->size,
-               cmd->csize, bio_data_dir(bio));
-
-       if (bio_data_dir(bio) == READ) {
-               if (bio->bi_size != cmd->size - cmd->csize)
-                       goto err_out_exit;
-
-               if (dst_need_crypto(n)) {
-                       err = dst_recv_cdata(st, t->cmd.hash);
-                       if (err)
-                               goto err_out_exit;
-               }
-
-               err = dst_recv_bio(st, t->bio, bio->bi_size);
-               if (err)
-                       goto err_out_exit;
-
-               if (dst_need_crypto(n))
-                       return dst_trans_crypto(t);
-       } else {
-               err = -EBADMSG;
-               if (cmd->size || cmd->csize)
-                       goto err_out_exit;
-       }
-
-       dst_trans_remove(t);
-       dst_trans_put(t);
-
-       return 0;
-
-err_out_exit:
-       return err;
-}
-
-/*
- * Receive crypto data.
- */
-int dst_recv_cdata(struct dst_state *st, void *cdata)
-{
-       struct dst_cmd *cmd = st->data;
-       struct dst_node *n = st->node;
-       struct dst_crypto_ctl *c = &n->crypto;
-       int err;
-
-       if (cmd->csize != c->crypto_attached_size) {
-               dprintk("%s: cmd: cmd: %u, sector: %llu, size: %u, "
-                               "csize: %u != digest size %u.\n",
-                               __func__, cmd->cmd, cmd->sector, cmd->size,
-                               cmd->csize, c->crypto_attached_size);
-               err = -EINVAL;
-               goto err_out_exit;
-       }
-
-       err = dst_data_recv(st, cdata, cmd->csize);
-       if (err)
-               goto err_out_exit;
-
-       cmd->size -= cmd->csize;
-       return 0;
-
-err_out_exit:
-       return err;
-}
-
-/*
- * Receive the command and start its processing.
- */
-static int dst_recv_processing(struct dst_state *st)
-{
-       int err = -EINTR;
-       struct dst_cmd *cmd = st->data;
-
-       /*
-        * If socket will be reset after this statement, then
-        * dst_data_recv() will just fail and loop will
-        * start again, so it can be done without any locks.
-        *
-        * st->read_socket is needed to prevents state machine
-        * breaking between this data reading and subsequent one
-        * in protocol specific functions during connection reset.
-        * In case of reset we have to read next command and do
-        * not expect data for old command to magically appear in
-        * new connection.
-        */
-       st->read_socket = st->socket;
-       err = dst_data_recv(st, cmd, sizeof(struct dst_cmd));
-       if (err)
-               goto out_exit;
-
-       dst_convert_cmd(cmd);
-
-       dprintk("%s: cmd: %u, size: %u, csize: %u, id: %llu, "
-                       "sector: %llu, flags: %llx, rw: %llx.\n",
-                       __func__, cmd->cmd, cmd->size,
-                       cmd->csize, cmd->id, cmd->sector,
-                       cmd->flags, cmd->rw);
-
-       /*
-        * This should catch protocol breakage and random garbage
-        * instead of commands.
-        */
-       if (unlikely(cmd->csize > st->size - sizeof(struct dst_cmd))) {
-               err = -EBADMSG;
-               goto out_exit;
-       }
-
-       err = -EPROTO;
-       switch (cmd->cmd) {
-       case DST_IO_RESPONSE:
-               err = dst_process_io_response(st);
-               break;
-       case DST_IO:
-               err = dst_process_io(st);
-               break;
-       case DST_CFG:
-               err = dst_process_cfg(st);
-               break;
-       case DST_PING:
-               err = 0;
-               break;
-       default:
-               break;
-       }
-
-out_exit:
-       return err;
-}
-
-/*
- * Receiving thread. For the client node we should try to reconnect,
- * for accepted client we just drop the state and expect it to reconnect.
- */
-static int dst_recv(void *init_data, void *schedule_data)
-{
-       struct dst_state *st = schedule_data;
-       struct dst_node *n = init_data;
-       int err = 0;
-
-       dprintk("%s: start st: %p, n: %p, scan: %lu, need_exit: %d.\n",
-                       __func__, st, n, n->trans_scan_timeout, st->need_exit);
-
-       while (n->trans_scan_timeout && !st->need_exit) {
-               err = dst_recv_processing(st);
-               if (err < 0) {
-                       if (!st->ctl.type)
-                               break;
-
-                       if (!n->trans_scan_timeout || st->need_exit)
-                               break;
-
-                       dst_state_reset(st);
-                       msleep(1000);
-               }
-       }
-
-       st->need_exit = 1;
-       wake_up(&st->thread_wait);
-
-       dprintk("%s: freeing receiving socket st: %p.\n", __func__, st);
-       dst_state_lock(st);
-       dst_state_exit_connected(st);
-       dst_state_unlock(st);
-       dst_state_put(st);
-
-       dprintk("%s: freed receiving socket st: %p.\n", __func__, st);
-
-       return err;
-}
-
-/*
- * Network state dies here and borns couple of lines below.
- * This object is the main network state processing engine:
- * sending, receiving, reconnections, all network related
- * tasks are handled on behalf of the state.
- */
-static void dst_state_free(struct dst_state *st)
-{
-       dprintk("%s: st: %p.\n", __func__, st);
-       if (st->cleanup)
-               st->cleanup(st);
-       kfree(st->data);
-       kfree(st);
-}
-
-struct dst_state *dst_state_alloc(struct dst_node *n)
-{
-       struct dst_state *st;
-       int err = -ENOMEM;
-
-       st = kzalloc(sizeof(struct dst_state), GFP_KERNEL);
-       if (!st)
-               goto err_out_exit;
-
-       st->node = n;
-       st->need_exit = 0;
-
-       st->size = PAGE_SIZE;
-       st->data = kmalloc(st->size, GFP_KERNEL);
-       if (!st->data)
-               goto err_out_free;
-
-       spin_lock_init(&st->request_lock);
-       INIT_LIST_HEAD(&st->request_list);
-
-       mutex_init(&st->state_lock);
-       init_waitqueue_head(&st->thread_wait);
-
-       /*
-        * One for processing thread, another one for node itself.
-        */
-       atomic_set(&st->refcnt, 2);
-
-       dprintk("%s: st: %p, n: %p.\n", __func__, st, st->node);
-
-       return st;
-
-err_out_free:
-       kfree(st);
-err_out_exit:
-       return ERR_PTR(err);
-}
-
-int dst_state_schedule_receiver(struct dst_state *st)
-{
-       return thread_pool_schedule_private(st->node->pool, dst_thread_setup,
-                       dst_recv, st, MAX_SCHEDULE_TIMEOUT, st->node);
-}
-
-/*
- * Initialize client's connection to the remote peer: allocate state,
- * connect and perform block IO autoconfiguration.
- */
-int dst_node_init_connected(struct dst_node *n, struct dst_network_ctl *r)
-{
-       struct dst_state *st;
-       int err = -ENOMEM;
-
-       st = dst_state_alloc(n);
-       if (IS_ERR(st)) {
-               err = PTR_ERR(st);
-               goto err_out_exit;
-       }
-       memcpy(&st->ctl, r, sizeof(struct dst_network_ctl));
-
-       err = dst_state_init_connected(st);
-       if (err)
-               goto err_out_free_data;
-
-       err = dst_request_remote_config(st);
-       if (err)
-               goto err_out_exit_connected;
-       n->state = st;
-
-       err = dst_state_schedule_receiver(st);
-       if (err)
-               goto err_out_exit_connected;
-
-       return 0;
-
-err_out_exit_connected:
-       dst_state_exit_connected(st);
-err_out_free_data:
-       dst_state_free(st);
-err_out_exit:
-       n->state = NULL;
-       return err;
-}
-
-void dst_state_put(struct dst_state *st)
-{
-       dprintk("%s: st: %p, refcnt: %d.\n",
-                       __func__, st, atomic_read(&st->refcnt));
-       if (atomic_dec_and_test(&st->refcnt))
-               dst_state_free(st);
-}
-
-/*
- * Send block IO to the network one by one using zero-copy ->sendpage().
- */
-int dst_send_bio(struct dst_state *st, struct dst_cmd *cmd, struct bio *bio)
-{
-       struct bio_vec *bv;
-       struct dst_crypto_ctl *c = &st->node->crypto;
-       int err, i = 0;
-       int flags = MSG_WAITALL;
-
-       err = dst_data_send_header(st->socket, cmd,
-               sizeof(struct dst_cmd) + c->crypto_attached_size, bio->bi_vcnt);
-       if (err)
-               goto err_out_exit;
-
-       bio_for_each_segment(bv, bio, i) {
-               if (i < bio->bi_vcnt - 1)
-                       flags |= MSG_MORE;
-
-               err = kernel_sendpage(st->socket, bv->bv_page, bv->bv_offset,
-                               bv->bv_len, flags);
-               if (err <= 0)
-                       goto err_out_exit;
-       }
-
-       return 0;
-
-err_out_exit:
-       dprintk("%s: %d/%d, flags: %x, err: %d.\n",
-                       __func__, i, bio->bi_vcnt, flags, err);
-       return err;
-}
-
-/*
- * Send transaction to the remote peer.
- */
-int dst_trans_send(struct dst_trans *t)
-{
-       int err;
-       struct dst_state *st = t->n->state;
-       struct bio *bio = t->bio;
-
-       dst_convert_cmd(&t->cmd);
-
-       dst_state_lock(st);
-       if (!st->socket) {
-               err = dst_state_init_connected(st);
-               if (err)
-                       goto err_out_unlock;
-       }
-
-       if (bio_data_dir(bio) == WRITE) {
-               err = dst_send_bio(st, &t->cmd, t->bio);
-       } else {
-               err = dst_data_send_header(st->socket, &t->cmd,
-                               sizeof(struct dst_cmd), 0);
-       }
-       if (err)
-               goto err_out_reset;
-
-       dst_state_unlock(st);
-       return 0;
-
-err_out_reset:
-       dst_state_reset_nolock(st);
-err_out_unlock:
-       dst_state_unlock(st);
-
-       return err;
-}
diff --git a/drivers/staging/dst/thread_pool.c b/drivers/staging/dst/thread_pool.c
deleted file mode 100644 (file)
index 29a82b2..0000000
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * 2007+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <linux/kernel.h>
-#include <linux/dst.h>
-#include <linux/kthread.h>
-#include <linux/slab.h>
-
-/*
- * Thread pool abstraction allows to schedule a work to be performed
- * on behalf of kernel thread. One does not operate with threads itself,
- * instead user provides setup and cleanup callbacks for thread pool itself,
- * and action and cleanup callbacks for each submitted work.
- *
- * Each worker has private data initialized at creation time and data,
- * provided by user at scheduling time.
- *
- * When action is being performed, thread can not be used by other users,
- * instead they will sleep until there is free thread to pick their work.
- */
-struct thread_pool_worker {
-       struct list_head        worker_entry;
-
-       struct task_struct      *thread;
-
-       struct thread_pool      *pool;
-
-       int                     error;
-       int                     has_data;
-       int                     need_exit;
-       unsigned int            id;
-
-       wait_queue_head_t       wait;
-
-       void                    *private;
-       void                    *schedule_data;
-
-       int                     (*action)(void *private, void *schedule_data);
-       void                    (*cleanup)(void *private);
-};
-
-static void thread_pool_exit_worker(struct thread_pool_worker *w)
-{
-       kthread_stop(w->thread);
-
-       w->cleanup(w->private);
-       kfree(w);
-}
-
-/*
- * Called to mark thread as ready and allow users to schedule new work.
- */
-static void thread_pool_worker_make_ready(struct thread_pool_worker *w)
-{
-       struct thread_pool *p = w->pool;
-
-       mutex_lock(&p->thread_lock);
-
-       if (!w->need_exit) {
-               list_move_tail(&w->worker_entry, &p->ready_list);
-               w->has_data = 0;
-               mutex_unlock(&p->thread_lock);
-
-               wake_up(&p->wait);
-       } else {
-               p->thread_num--;
-               list_del(&w->worker_entry);
-               mutex_unlock(&p->thread_lock);
-
-               thread_pool_exit_worker(w);
-       }
-}
-
-/*
- * Thread action loop: waits until there is new work.
- */
-static int thread_pool_worker_func(void *data)
-{
-       struct thread_pool_worker *w = data;
-
-       while (!kthread_should_stop()) {
-               wait_event_interruptible(w->wait,
-                       kthread_should_stop() || w->has_data);
-
-               if (kthread_should_stop())
-                       break;
-
-               if (!w->has_data)
-                       continue;
-
-               w->action(w->private, w->schedule_data);
-               thread_pool_worker_make_ready(w);
-       }
-
-       return 0;
-}
-
-/*
- * Remove single worker without specifying which one.
- */
-void thread_pool_del_worker(struct thread_pool *p)
-{
-       struct thread_pool_worker *w = NULL;
-
-       while (!w && p->thread_num) {
-               wait_event(p->wait, !list_empty(&p->ready_list) ||
-                               !p->thread_num);
-
-               dprintk("%s: locking list_empty: %d, thread_num: %d.\n",
-                               __func__, list_empty(&p->ready_list),
-                               p->thread_num);
-
-               mutex_lock(&p->thread_lock);
-               if (!list_empty(&p->ready_list)) {
-                       w = list_first_entry(&p->ready_list,
-                                       struct thread_pool_worker,
-                                       worker_entry);
-
-                       dprintk("%s: deleting w: %p, thread_num: %d, "
-                                       "list: %p [%p.%p].\n", __func__,
-                                       w, p->thread_num, &p->ready_list,
-                                       p->ready_list.prev, p->ready_list.next);
-
-                       p->thread_num--;
-                       list_del(&w->worker_entry);
-               }
-               mutex_unlock(&p->thread_lock);
-       }
-
-       if (w)
-               thread_pool_exit_worker(w);
-       dprintk("%s: deleted w: %p, thread_num: %d.\n",
-                       __func__, w, p->thread_num);
-}
-
-/*
- * Remove a worker with given ID.
- */
-void thread_pool_del_worker_id(struct thread_pool *p, unsigned int id)
-{
-       struct thread_pool_worker *w;
-       int found = 0;
-
-       mutex_lock(&p->thread_lock);
-       list_for_each_entry(w, &p->ready_list, worker_entry) {
-               if (w->id == id) {
-                       found = 1;
-                       p->thread_num--;
-                       list_del(&w->worker_entry);
-                       break;
-               }
-       }
-
-       if (!found) {
-               list_for_each_entry(w, &p->active_list, worker_entry) {
-                       if (w->id == id) {
-                               w->need_exit = 1;
-                               break;
-                       }
-               }
-       }
-       mutex_unlock(&p->thread_lock);
-
-       if (found)
-               thread_pool_exit_worker(w);
-}
-
-/*
- * Add new worker thread with given parameters.
- * If initialization callback fails, return error.
- */
-int thread_pool_add_worker(struct thread_pool *p,
-               char *name,
-               unsigned int id,
-               void *(*init)(void *private),
-               void (*cleanup)(void *private),
-               void *private)
-{
-       struct thread_pool_worker *w;
-       int err = -ENOMEM;
-
-       w = kzalloc(sizeof(struct thread_pool_worker), GFP_KERNEL);
-       if (!w)
-               goto err_out_exit;
-
-       w->pool = p;
-       init_waitqueue_head(&w->wait);
-       w->cleanup = cleanup;
-       w->id = id;
-
-       w->thread = kthread_run(thread_pool_worker_func, w, "%s", name);
-       if (IS_ERR(w->thread)) {
-               err = PTR_ERR(w->thread);
-               goto err_out_free;
-       }
-
-       w->private = init(private);
-       if (IS_ERR(w->private)) {
-               err = PTR_ERR(w->private);
-               goto err_out_stop_thread;
-       }
-
-       mutex_lock(&p->thread_lock);
-       list_add_tail(&w->worker_entry, &p->ready_list);
-       p->thread_num++;
-       mutex_unlock(&p->thread_lock);
-
-       return 0;
-
-err_out_stop_thread:
-       kthread_stop(w->thread);
-err_out_free:
-       kfree(w);
-err_out_exit:
-       return err;
-}
-
-/*
- * Destroy the whole pool.
- */
-void thread_pool_destroy(struct thread_pool *p)
-{
-       while (p->thread_num) {
-               dprintk("%s: num: %d.\n", __func__, p->thread_num);
-               thread_pool_del_worker(p);
-       }
-
-       kfree(p);
-}
-
-/*
- * Create a pool with given number of threads.
- * They will have sequential IDs started from zero.
- */
-struct thread_pool *thread_pool_create(int num, char *name,
-               void *(*init)(void *private),
-               void (*cleanup)(void *private),
-               void *private)
-{
-       struct thread_pool_worker *w, *tmp;
-       struct thread_pool *p;
-       int err = -ENOMEM;
-       int i;
-
-       p = kzalloc(sizeof(struct thread_pool), GFP_KERNEL);
-       if (!p)
-               goto err_out_exit;
-
-       init_waitqueue_head(&p->wait);
-       mutex_init(&p->thread_lock);
-       INIT_LIST_HEAD(&p->ready_list);
-       INIT_LIST_HEAD(&p->active_list);
-       p->thread_num = 0;
-
-       for (i = 0; i < num; ++i) {
-               err = thread_pool_add_worker(p, name, i, init,
-                               cleanup, private);
-               if (err)
-                       goto err_out_free_all;
-       }
-
-       return p;
-
-err_out_free_all:
-       list_for_each_entry_safe(w, tmp, &p->ready_list, worker_entry) {
-               list_del(&w->worker_entry);
-               thread_pool_exit_worker(w);
-       }
-       kfree(p);
-err_out_exit:
-       return ERR_PTR(err);
-}
-
-/*
- * Schedule execution of the action on a given thread,
- * provided ID pointer has to match previously stored
- * private data.
- */
-int thread_pool_schedule_private(struct thread_pool *p,
-               int (*setup)(void *private, void *data),
-               int (*action)(void *private, void *data),
-               void *data, long timeout, void *id)
-{
-       struct thread_pool_worker *w, *tmp, *worker = NULL;
-       int err = 0;
-
-       while (!worker && !err) {
-               timeout = wait_event_interruptible_timeout(p->wait,
-                               !list_empty(&p->ready_list),
-                               timeout);
-
-               if (!timeout) {
-                       err = -ETIMEDOUT;
-                       break;
-               }
-
-               worker = NULL;
-               mutex_lock(&p->thread_lock);
-               list_for_each_entry_safe(w, tmp, &p->ready_list, worker_entry) {
-                       if (id && id != w->private)
-                               continue;
-
-                       worker = w;
-
-                       list_move_tail(&w->worker_entry, &p->active_list);
-
-                       err = setup(w->private, data);
-                       if (!err) {
-                               w->schedule_data = data;
-                               w->action = action;
-                               w->has_data = 1;
-                               wake_up(&w->wait);
-                       } else {
-                               list_move_tail(&w->worker_entry,
-                                               &p->ready_list);
-                       }
-
-                       break;
-               }
-               mutex_unlock(&p->thread_lock);
-       }
-
-       return err;
-}
-
-/*
- * Schedule execution on arbitrary thread from the pool.
- */
-int thread_pool_schedule(struct thread_pool *p,
-               int (*setup)(void *private, void *data),
-               int (*action)(void *private, void *data),
-               void *data, long timeout)
-{
-       return thread_pool_schedule_private(p, setup,
-                       action, data, timeout, NULL);
-}
diff --git a/drivers/staging/dst/trans.c b/drivers/staging/dst/trans.c
deleted file mode 100644 (file)
index 1c36a6b..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * 2007+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <linux/bio.h>
-#include <linux/dst.h>
-#include <linux/slab.h>
-#include <linux/mempool.h>
-
-/*
- * Transaction memory pool size.
- */
-static int dst_mempool_num = 32;
-module_param(dst_mempool_num, int, 0644);
-
-/*
- * Transaction tree management.
- */
-static inline int dst_trans_cmp(dst_gen_t gen, dst_gen_t new)
-{
-       if (gen < new)
-               return 1;
-       if (gen > new)
-               return -1;
-       return 0;
-}
-
-struct dst_trans *dst_trans_search(struct dst_node *node, dst_gen_t gen)
-{
-       struct rb_root *root = &node->trans_root;
-       struct rb_node *n = root->rb_node;
-       struct dst_trans *t, *ret = NULL;
-       int cmp;
-
-       while (n) {
-               t = rb_entry(n, struct dst_trans, trans_entry);
-
-               cmp = dst_trans_cmp(t->gen, gen);
-               if (cmp < 0)
-                       n = n->rb_left;
-               else if (cmp > 0)
-                       n = n->rb_right;
-               else {
-                       ret = t;
-                       break;
-               }
-       }
-
-       dprintk("%s: %s transaction: id: %llu.\n", __func__,
-                       (ret) ? "found" : "not found", gen);
-
-       return ret;
-}
-
-static int dst_trans_insert(struct dst_trans *new)
-{
-       struct rb_root *root = &new->n->trans_root;
-       struct rb_node **n = &root->rb_node, *parent = NULL;
-       struct dst_trans *ret = NULL, *t;
-       int cmp;
-
-       while (*n) {
-               parent = *n;
-
-               t = rb_entry(parent, struct dst_trans, trans_entry);
-
-               cmp = dst_trans_cmp(t->gen, new->gen);
-               if (cmp < 0)
-                       n = &parent->rb_left;
-               else if (cmp > 0)
-                       n = &parent->rb_right;
-               else {
-                       ret = t;
-                       break;
-               }
-       }
-
-       new->send_time = jiffies;
-       if (ret) {
-               printk(KERN_DEBUG "%s: exist: old: gen: %llu, bio: %llu/%u, "
-                       "send_time: %lu, new: gen: %llu, bio: %llu/%u, "
-                       "send_time: %lu.\n", __func__,
-                       ret->gen, (u64)ret->bio->bi_sector,
-                       ret->bio->bi_size, ret->send_time,
-                       new->gen, (u64)new->bio->bi_sector,
-                       new->bio->bi_size, new->send_time);
-               return -EEXIST;
-       }
-
-       rb_link_node(&new->trans_entry, parent, n);
-       rb_insert_color(&new->trans_entry, root);
-
-       dprintk("%s: inserted: gen: %llu, bio: %llu/%u, send_time: %lu.\n",
-               __func__, new->gen, (u64)new->bio->bi_sector,
-               new->bio->bi_size, new->send_time);
-
-       return 0;
-}
-
-int dst_trans_remove_nolock(struct dst_trans *t)
-{
-       struct dst_node *n = t->n;
-
-       if (t->trans_entry.rb_parent_color) {
-               rb_erase(&t->trans_entry, &n->trans_root);
-               t->trans_entry.rb_parent_color = 0;
-       }
-       return 0;
-}
-
-int dst_trans_remove(struct dst_trans *t)
-{
-       int ret;
-       struct dst_node *n = t->n;
-
-       mutex_lock(&n->trans_lock);
-       ret = dst_trans_remove_nolock(t);
-       mutex_unlock(&n->trans_lock);
-
-       return ret;
-}
-
-/*
- * When transaction is completed and there are no more users,
- * we complete appriate block IO request with given error status.
- */
-void dst_trans_put(struct dst_trans *t)
-{
-       if (atomic_dec_and_test(&t->refcnt)) {
-               struct bio *bio = t->bio;
-
-               dprintk("%s: completed t: %p, gen: %llu, bio: %p.\n",
-                               __func__, t, t->gen, bio);
-
-               bio_endio(bio, t->error);
-               bio_put(bio);
-
-               dst_node_put(t->n);
-               mempool_free(t, t->n->trans_pool);
-       }
-}
-
-/*
- * Process given block IO request: allocate transaction, insert it into the tree
- * and send/schedule crypto processing.
- */
-int dst_process_bio(struct dst_node *n, struct bio *bio)
-{
-       struct dst_trans *t;
-       int err = -ENOMEM;
-
-       t = mempool_alloc(n->trans_pool, GFP_NOFS);
-       if (!t)
-               goto err_out_exit;
-
-       t->n = dst_node_get(n);
-       t->bio = bio;
-       t->error = 0;
-       t->retries = 0;
-       atomic_set(&t->refcnt, 1);
-       t->gen = atomic_long_inc_return(&n->gen);
-
-       t->enc = bio_data_dir(bio);
-       dst_bio_to_cmd(bio, &t->cmd, DST_IO, t->gen);
-
-       mutex_lock(&n->trans_lock);
-       err = dst_trans_insert(t);
-       mutex_unlock(&n->trans_lock);
-       if (err)
-               goto err_out_free;
-
-       dprintk("%s: gen: %llu, bio: %llu/%u, dir/enc: %d, need_crypto: %d.\n",
-                       __func__, t->gen, (u64)bio->bi_sector,
-                       bio->bi_size, t->enc, dst_need_crypto(n));
-
-       if (dst_need_crypto(n) && t->enc)
-               dst_trans_crypto(t);
-       else
-               dst_trans_send(t);
-
-       return 0;
-
-err_out_free:
-       dst_node_put(n);
-       mempool_free(t, n->trans_pool);
-err_out_exit:
-       bio_endio(bio, err);
-       bio_put(bio);
-       return err;
-}
-
-/*
- * Scan for timeout/stale transactions.
- * Each transaction is being resent multiple times before error completion.
- */
-static void dst_trans_scan(struct work_struct *work)
-{
-       struct dst_node *n = container_of(work, struct dst_node,
-                       trans_work.work);
-       struct rb_node *rb_node;
-       struct dst_trans *t;
-       unsigned long timeout = n->trans_scan_timeout;
-       int num = 10 * n->trans_max_retries;
-
-       mutex_lock(&n->trans_lock);
-
-       for (rb_node = rb_first(&n->trans_root); rb_node; ) {
-               t = rb_entry(rb_node, struct dst_trans, trans_entry);
-
-               if (timeout && time_after(t->send_time + timeout, jiffies)
-                               && t->retries == 0)
-                       break;
-#if 0
-               dprintk("%s: t: %p, gen: %llu, n: %s, retries: %u, max: %u.\n",
-                       __func__, t, t->gen, n->name,
-                       t->retries, n->trans_max_retries);
-#endif
-               if (--num == 0)
-                       break;
-
-               dst_trans_get(t);
-
-               rb_node = rb_next(rb_node);
-
-               if (timeout && (++t->retries < n->trans_max_retries)) {
-                       dst_trans_send(t);
-               } else {
-                       t->error = -ETIMEDOUT;
-                       dst_trans_remove_nolock(t);
-                       dst_trans_put(t);
-               }
-
-               dst_trans_put(t);
-       }
-
-       mutex_unlock(&n->trans_lock);
-
-       /*
-        * If no timeout specified then system is in the middle of exiting
-        * process, so no need to reschedule scanning process again.
-        */
-       if (timeout) {
-               if (!num)
-                       timeout = HZ;
-               schedule_delayed_work(&n->trans_work, timeout);
-       }
-}
-
-/*
- * Flush all transactions and mark them as timed out.
- * Destroy transaction pools.
- */
-void dst_node_trans_exit(struct dst_node *n)
-{
-       struct dst_trans *t;
-       struct rb_node *rb_node;
-
-       if (!n->trans_cache)
-               return;
-
-       dprintk("%s: n: %p, cancelling the work.\n", __func__, n);
-       cancel_delayed_work_sync(&n->trans_work);
-       flush_scheduled_work();
-       dprintk("%s: n: %p, work has been cancelled.\n", __func__, n);
-
-       for (rb_node = rb_first(&n->trans_root); rb_node; ) {
-               t = rb_entry(rb_node, struct dst_trans, trans_entry);
-
-               dprintk("%s: t: %p, gen: %llu, n: %s.\n",
-                       __func__, t, t->gen, n->name);
-
-               rb_node = rb_next(rb_node);
-
-               t->error = -ETIMEDOUT;
-               dst_trans_remove_nolock(t);
-               dst_trans_put(t);
-       }
-
-       mempool_destroy(n->trans_pool);
-       kmem_cache_destroy(n->trans_cache);
-}
-
-/*
- * Initialize transaction storage for given node.
- * Transaction stores not only control information,
- * but also network command and crypto data (if needed)
- * to reduce number of allocations. Thus transaction size
- * differs from node to node.
- */
-int dst_node_trans_init(struct dst_node *n, unsigned int size)
-{
-       /*
-        * We need this, since node with given name can be dropped from the
-        * hash table, but be still alive, so subsequent creation of the node
-        * with the same name may collide with existing cache name.
-        */
-
-       snprintf(n->cache_name, sizeof(n->cache_name), "%s-%p", n->name, n);
-
-       n->trans_cache = kmem_cache_create(n->cache_name,
-                       size + n->crypto.crypto_attached_size,
-                       0, 0, NULL);
-       if (!n->trans_cache)
-               goto err_out_exit;
-
-       n->trans_pool = mempool_create_slab_pool(dst_mempool_num,
-                       n->trans_cache);
-       if (!n->trans_pool)
-               goto err_out_cache_destroy;
-
-       mutex_init(&n->trans_lock);
-       n->trans_root = RB_ROOT;
-
-       INIT_DELAYED_WORK(&n->trans_work, dst_trans_scan);
-       schedule_delayed_work(&n->trans_work, n->trans_scan_timeout);
-
-       dprintk("%s: n: %p, size: %u, crypto: %u.\n",
-               __func__, n, size, n->crypto.crypto_attached_size);
-
-       return 0;
-
-err_out_cache_destroy:
-       kmem_cache_destroy(n->trans_cache);
-err_out_exit:
-       return -ENOMEM;
-}
index b18d8e2d4c5e78cc9b20799257e92716f091d704..3af79242313e5cdfb6281b46d08e0a0ef9a3a346 100644 (file)
@@ -1787,7 +1787,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
 static struct video_device go7007_template = {
        .name           = "go7007",
        .fops           = &go7007_fops,
-       .minor          = -1,
        .release        = go7007_vfl_release,
        .ioctl_ops      = &video_ioctl_ops,
        .tvnorms        = V4L2_STD_ALL,
@@ -1817,8 +1816,8 @@ int go7007_v4l2_init(struct go7007 *go)
        }
        video_set_drvdata(go->video_dev, go);
        ++go->ref_count;
-       printk(KERN_INFO "%s: registered device video%d [v4l2]\n",
-              go->video_dev->name, go->video_dev->num);
+       printk(KERN_INFO "%s: registered device %s [v4l2]\n",
+              go->video_dev->name, video_device_node_name(go->video_dev));
 
        return 0;
 }
index f0b86f02cd808afc287db224cc1f1f21b9cabe1f..fd677f008365115abd0b23f7b47d740e5ff873c9 100644 (file)
@@ -29,7 +29,6 @@
  * driver requests - some may support multiple options */
 
 
-#include <linux/autoconf.h>
 #include "iio.h"
 #include "ring_generic.h"
 
index 536e2382de542b8734914931e4dc4769a02ab5ed..638ad6b3589107d6f6f146e64eb6f4011d425597 100644 (file)
@@ -1,7 +1,8 @@
 config OCTEON_ETHERNET
        tristate "Cavium Networks Octeon Ethernet support"
        depends on CPU_CAVIUM_OCTEON
-       select MII
+       select PHYLIB
+       select MDIO_OCTEON
        help
          This driver supports the builtin ethernet ports on Cavium
          Networks' products in the Octeon family. This driver supports the
index 31a58e50892417b57f58b28374e6a320eaff5c43..05a5cc0f43eda40a1b358edec808dfad7ce039b7 100644 (file)
@@ -26,7 +26,8 @@
 **********************************************************************/
 #include <linux/kernel.h>
 #include <linux/ethtool.h>
-#include <linux/mii.h>
+#include <linux/phy.h>
+
 #include <net/dst.h>
 
 #include <asm/octeon/octeon.h>
 #include "ethernet-defines.h"
 #include "octeon-ethernet.h"
 #include "ethernet-mdio.h"
+#include "ethernet-util.h"
 
 #include "cvmx-helper-board.h"
 
 #include "cvmx-smix-defs.h"
 
-DECLARE_MUTEX(mdio_sem);
-
-/**
- * Perform an MII read. Called by the generic MII routines
- *
- * @dev:      Device to perform read for
- * @phy_id:   The MII phy id
- * @location: Register location to read
- * Returns Result from the read or zero on failure
- */
-static int cvm_oct_mdio_read(struct net_device *dev, int phy_id, int location)
-{
-       union cvmx_smix_cmd smi_cmd;
-       union cvmx_smix_rd_dat smi_rd;
-
-       smi_cmd.u64 = 0;
-       smi_cmd.s.phy_op = 1;
-       smi_cmd.s.phy_adr = phy_id;
-       smi_cmd.s.reg_adr = location;
-       cvmx_write_csr(CVMX_SMIX_CMD(0), smi_cmd.u64);
-
-       do {
-               if (!in_interrupt())
-                       yield();
-               smi_rd.u64 = cvmx_read_csr(CVMX_SMIX_RD_DAT(0));
-       } while (smi_rd.s.pending);
-
-       if (smi_rd.s.val)
-               return smi_rd.s.dat;
-       else
-               return 0;
-}
-
-static int cvm_oct_mdio_dummy_read(struct net_device *dev, int phy_id,
-                                  int location)
-{
-       return 0xffff;
-}
-
-/**
- * Perform an MII write. Called by the generic MII routines
- *
- * @dev:      Device to perform write for
- * @phy_id:   The MII phy id
- * @location: Register location to write
- * @val:      Value to write
- */
-static void cvm_oct_mdio_write(struct net_device *dev, int phy_id, int location,
-                              int val)
-{
-       union cvmx_smix_cmd smi_cmd;
-       union cvmx_smix_wr_dat smi_wr;
-
-       smi_wr.u64 = 0;
-       smi_wr.s.dat = val;
-       cvmx_write_csr(CVMX_SMIX_WR_DAT(0), smi_wr.u64);
-
-       smi_cmd.u64 = 0;
-       smi_cmd.s.phy_op = 0;
-       smi_cmd.s.phy_adr = phy_id;
-       smi_cmd.s.reg_adr = location;
-       cvmx_write_csr(CVMX_SMIX_CMD(0), smi_cmd.u64);
-
-       do {
-               if (!in_interrupt())
-                       yield();
-               smi_wr.u64 = cvmx_read_csr(CVMX_SMIX_WR_DAT(0));
-       } while (smi_wr.s.pending);
-}
-
-static void cvm_oct_mdio_dummy_write(struct net_device *dev, int phy_id,
-                                    int location, int val)
-{
-}
-
 static void cvm_oct_get_drvinfo(struct net_device *dev,
                                struct ethtool_drvinfo *info)
 {
@@ -125,49 +52,37 @@ static void cvm_oct_get_drvinfo(struct net_device *dev,
 static int cvm_oct_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct octeon_ethernet *priv = netdev_priv(dev);
-       int ret;
 
-       down(&mdio_sem);
-       ret = mii_ethtool_gset(&priv->mii_info, cmd);
-       up(&mdio_sem);
+       if (priv->phydev)
+               return phy_ethtool_gset(priv->phydev, cmd);
 
-       return ret;
+       return -EINVAL;
 }
 
 static int cvm_oct_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct octeon_ethernet *priv = netdev_priv(dev);
-       int ret;
 
-       down(&mdio_sem);
-       ret = mii_ethtool_sset(&priv->mii_info, cmd);
-       up(&mdio_sem);
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
+       if (priv->phydev)
+               return phy_ethtool_sset(priv->phydev, cmd);
 
-       return ret;
+       return -EINVAL;
 }
 
 static int cvm_oct_nway_reset(struct net_device *dev)
 {
        struct octeon_ethernet *priv = netdev_priv(dev);
-       int ret;
 
-       down(&mdio_sem);
-       ret = mii_nway_restart(&priv->mii_info);
-       up(&mdio_sem);
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
 
-       return ret;
-}
+       if (priv->phydev)
+               return phy_start_aneg(priv->phydev);
 
-static u32 cvm_oct_get_link(struct net_device *dev)
-{
-       struct octeon_ethernet *priv = netdev_priv(dev);
-       u32 ret;
-
-       down(&mdio_sem);
-       ret = mii_link_ok(&priv->mii_info);
-       up(&mdio_sem);
-
-       return ret;
+       return -EINVAL;
 }
 
 const struct ethtool_ops cvm_oct_ethtool_ops = {
@@ -175,7 +90,7 @@ const struct ethtool_ops cvm_oct_ethtool_ops = {
        .get_settings = cvm_oct_get_settings,
        .set_settings = cvm_oct_set_settings,
        .nway_reset = cvm_oct_nway_reset,
-       .get_link = cvm_oct_get_link,
+       .get_link = ethtool_op_get_link,
        .get_sg = ethtool_op_get_sg,
        .get_tx_csum = ethtool_op_get_tx_csum,
 };
@@ -191,41 +106,78 @@ const struct ethtool_ops cvm_oct_ethtool_ops = {
 int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
        struct octeon_ethernet *priv = netdev_priv(dev);
-       struct mii_ioctl_data *data = if_mii(rq);
-       unsigned int duplex_chg;
-       int ret;
 
-       down(&mdio_sem);
-       ret = generic_mii_ioctl(&priv->mii_info, data, cmd, &duplex_chg);
-       up(&mdio_sem);
+       if (!netif_running(dev))
+               return -EINVAL;
+
+       if (!priv->phydev)
+               return -EINVAL;
+
+       return phy_mii_ioctl(priv->phydev, if_mii(rq), cmd);
+}
 
-       return ret;
+static void cvm_oct_adjust_link(struct net_device *dev)
+{
+       struct octeon_ethernet *priv = netdev_priv(dev);
+       cvmx_helper_link_info_t link_info;
+
+       if (priv->last_link != priv->phydev->link) {
+               priv->last_link = priv->phydev->link;
+               link_info.u64 = 0;
+               link_info.s.link_up = priv->last_link ? 1 : 0;
+               link_info.s.full_duplex = priv->phydev->duplex ? 1 : 0;
+               link_info.s.speed = priv->phydev->speed;
+               cvmx_helper_link_set( priv->port, link_info);
+               if (priv->last_link) {
+                       netif_carrier_on(dev);
+                       if (priv->queue != -1)
+                               DEBUGPRINT("%s: %u Mbps %s duplex, "
+                                          "port %2d, queue %2d\n",
+                                          dev->name, priv->phydev->speed,
+                                          priv->phydev->duplex ?
+                                               "Full" : "Half",
+                                          priv->port, priv->queue);
+                       else
+                               DEBUGPRINT("%s: %u Mbps %s duplex, "
+                                          "port %2d, POW\n",
+                                          dev->name, priv->phydev->speed,
+                                          priv->phydev->duplex ?
+                                               "Full" : "Half",
+                                          priv->port);
+               } else {
+                       netif_carrier_off(dev);
+                       DEBUGPRINT("%s: Link down\n", dev->name);
+               }
+       }
 }
 
+
 /**
- * Setup the MDIO device structures
+ * Setup the PHY
  *
  * @dev:    Device to setup
  *
  * Returns Zero on success, negative on failure
  */
-int cvm_oct_mdio_setup_device(struct net_device *dev)
+int cvm_oct_phy_setup_device(struct net_device *dev)
 {
        struct octeon_ethernet *priv = netdev_priv(dev);
-       int phy_id = cvmx_helper_board_get_mii_address(priv->port);
-       if (phy_id != -1) {
-               priv->mii_info.dev = dev;
-               priv->mii_info.phy_id = phy_id;
-               priv->mii_info.phy_id_mask = 0xff;
-               priv->mii_info.supports_gmii = 1;
-               priv->mii_info.reg_num_mask = 0x1f;
-               priv->mii_info.mdio_read = cvm_oct_mdio_read;
-               priv->mii_info.mdio_write = cvm_oct_mdio_write;
-       } else {
-               /* Supply dummy MDIO routines so the kernel won't crash
-                  if the user tries to read them */
-               priv->mii_info.mdio_read = cvm_oct_mdio_dummy_read;
-               priv->mii_info.mdio_write = cvm_oct_mdio_dummy_write;
+
+       int phy_addr = cvmx_helper_board_get_mii_address(priv->port);
+       if (phy_addr != -1) {
+               char phy_id[20];
+
+               snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, "0", phy_addr);
+
+               priv->phydev = phy_connect(dev, phy_id, cvm_oct_adjust_link, 0,
+                                       PHY_INTERFACE_MODE_GMII);
+
+               if (IS_ERR(priv->phydev)) {
+                       priv->phydev = NULL;
+                       return -1;
+               }
+               priv->last_link = 0;
+               phy_start_aneg(priv->phydev);
        }
        return 0;
 }
index b3328aeec2dfcb6ed7400c586b044596442335c9..55d0614a7cd94f67e867e8b6eb2f8f498405f722 100644 (file)
@@ -43,4 +43,4 @@
 
 extern const struct ethtool_ops cvm_oct_ethtool_ops;
 int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
-int cvm_oct_mdio_setup_device(struct net_device *dev);
+int cvm_oct_phy_setup_device(struct net_device *dev);
index 8fa88fc419b7b6f144bf9f4cf6a83c25cdb6c556..16308d484d3b6910f77b23504894126158d1d2aa 100644 (file)
@@ -25,7 +25,6 @@
  * Contact Cavium Networks for more information
 **********************************************************************/
 #include <linux/kernel.h>
-#include <linux/mii.h>
 #include <linux/seq_file.h>
 #include <linux/proc_fs.h>
 #include <net/dst.h>
 #include "cvmx-helper.h"
 #include "cvmx-pip.h"
 
-static unsigned long long cvm_oct_stats_read_switch(struct net_device *dev,
-                                                   int phy_id, int offset)
-{
-       struct octeon_ethernet *priv = netdev_priv(dev);
-
-       priv->mii_info.mdio_write(dev, phy_id, 0x1d, 0xcc00 | offset);
-       return ((uint64_t) priv->mii_info.
-               mdio_read(dev, phy_id,
-                         0x1e) << 16) | (uint64_t) priv->mii_info.
-           mdio_read(dev, phy_id, 0x1f);
-}
-
-static int cvm_oct_stats_switch_show(struct seq_file *m, void *v)
-{
-       static const int ports[] = { 0, 1, 2, 3, 9, -1 };
-       struct net_device *dev = cvm_oct_device[0];
-       int index = 0;
-
-       while (ports[index] != -1) {
-
-               /* Latch port */
-               struct octeon_ethernet *priv = netdev_priv(dev);
-
-               priv->mii_info.mdio_write(dev, 0x1b, 0x1d,
-                                         0xdc00 | ports[index]);
-               seq_printf(m, "\nSwitch Port %d\n", ports[index]);
-               seq_printf(m, "InGoodOctets:   %12llu\t"
-                          "OutOctets:      %12llu\t"
-                          "64 Octets:      %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b,
-                                                    0x00) |
-                          (cvm_oct_stats_read_switch(dev, 0x1b, 0x01) << 32),
-                          cvm_oct_stats_read_switch(dev, 0x1b,
-                                                    0x0E) |
-                          (cvm_oct_stats_read_switch(dev, 0x1b, 0x0F) << 32),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x08));
-
-               seq_printf(m, "InBadOctets:    %12llu\t"
-                          "OutUnicast:     %12llu\t"
-                          "65-127 Octets:  %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x02),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x10),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x09));
-
-               seq_printf(m, "InUnicast:      %12llu\t"
-                          "OutBroadcasts:  %12llu\t"
-                          "128-255 Octets: %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x04),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x13),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x0A));
-
-               seq_printf(m, "InBroadcasts:   %12llu\t"
-                          "OutMulticasts:  %12llu\t"
-                          "256-511 Octets: %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x06),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x12),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x0B));
-
-               seq_printf(m, "InMulticasts:   %12llu\t"
-                          "OutPause:       %12llu\t"
-                          "512-1023 Octets:%12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x07),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x15),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x0C));
-
-               seq_printf(m, "InPause:        %12llu\t"
-                          "Excessive:      %12llu\t"
-                          "1024-Max Octets:%12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x16),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x11),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x0D));
-
-               seq_printf(m, "InUndersize:    %12llu\t"
-                          "Collisions:     %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x18),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x1E));
-
-               seq_printf(m, "InFragments:    %12llu\t"
-                          "Deferred:       %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x19),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x05));
-
-               seq_printf(m, "InOversize:     %12llu\t"
-                          "Single:         %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x1A),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x14));
-
-               seq_printf(m, "InJabber:       %12llu\t"
-                          "Multiple:       %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x1B),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x17));
-
-               seq_printf(m, "In RxErr:       %12llu\t"
-                          "OutFCSErr:      %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x1C),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x03));
-
-               seq_printf(m, "InFCSErr:       %12llu\t"
-                          "Late:           %12llu\n",
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x1D),
-                          cvm_oct_stats_read_switch(dev, 0x1b, 0x1F));
-               index++;
-       }
-       return 0;
-}
-
 /**
  * User is reading /proc/octeon_ethernet_stats
  *
@@ -215,11 +108,6 @@ static int cvm_oct_stats_show(struct seq_file *m, void *v)
                }
        }
 
-       if (cvm_oct_device[0]) {
-               priv = netdev_priv(cvm_oct_device[0]);
-               if (priv->imode == CVMX_HELPER_INTERFACE_MODE_GMII)
-                       cvm_oct_stats_switch_show(m, v);
-       }
        return 0;
 }
 
index fbaa465d2fac3e2424d81f92d1a446b9cb107133..3820f1ec11d16a98dd24357f4c32e5036178b1ac 100644 (file)
@@ -147,32 +147,36 @@ static void cvm_oct_rgmii_poll(struct net_device *dev)
                cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface),
                               gmxx_rxx_int_reg.u64);
        }
-
-       link_info = cvmx_helper_link_autoconf(priv->port);
-       priv->link_info = link_info.u64;
+       if (priv->phydev == NULL) {
+               link_info = cvmx_helper_link_autoconf(priv->port);
+               priv->link_info = link_info.u64;
+       }
        spin_unlock_irqrestore(&global_register_lock, flags);
 
-       /* Tell Linux */
-       if (link_info.s.link_up) {
-
-               if (!netif_carrier_ok(dev))
-                       netif_carrier_on(dev);
-               if (priv->queue != -1)
-                       DEBUGPRINT
-                           ("%s: %u Mbps %s duplex, port %2d, queue %2d\n",
-                            dev->name, link_info.s.speed,
-                            (link_info.s.full_duplex) ? "Full" : "Half",
-                            priv->port, priv->queue);
-               else
-                       DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, POW\n",
-                                  dev->name, link_info.s.speed,
-                                  (link_info.s.full_duplex) ? "Full" : "Half",
-                                  priv->port);
-       } else {
-
-               if (netif_carrier_ok(dev))
-                       netif_carrier_off(dev);
-               DEBUGPRINT("%s: Link down\n", dev->name);
+       if (priv->phydev == NULL) {
+               /* Tell core. */
+               if (link_info.s.link_up) {
+                       if (!netif_carrier_ok(dev))
+                               netif_carrier_on(dev);
+                       if (priv->queue != -1)
+                               DEBUGPRINT("%s: %u Mbps %s duplex, "
+                                          "port %2d, queue %2d\n",
+                                          dev->name, link_info.s.speed,
+                                          (link_info.s.full_duplex) ?
+                                               "Full" : "Half",
+                                          priv->port, priv->queue);
+                       else
+                               DEBUGPRINT("%s: %u Mbps %s duplex, "
+                                          "port %2d, POW\n",
+                                          dev->name, link_info.s.speed,
+                                          (link_info.s.full_duplex) ?
+                                               "Full" : "Half",
+                                          priv->port);
+               } else {
+                       if (netif_carrier_ok(dev))
+                               netif_carrier_off(dev);
+                       DEBUGPRINT("%s: Link down\n", dev->name);
+               }
        }
 }
 
index 2b54996bd85dbe676a9bdc1daca400cae156f45c..6061d01eca2daf067fe091f96545f356b99f1280 100644 (file)
@@ -113,7 +113,7 @@ int cvm_oct_sgmii_init(struct net_device *dev)
        struct octeon_ethernet *priv = netdev_priv(dev);
        cvm_oct_common_init(dev);
        dev->netdev_ops->ndo_stop(dev);
-       if (!octeon_is_simulation())
+       if (!octeon_is_simulation() && priv->phydev == NULL)
                priv->poll = cvm_oct_sgmii_poll;
 
        /* FIXME: Need autoneg logic */
index 0c2e7cc40f35338dc2e7ed8f179d2e5bf21c43be..ee3dc41b2c53cd7331a856e78678298518360cd7 100644 (file)
@@ -112,7 +112,7 @@ int cvm_oct_xaui_init(struct net_device *dev)
        struct octeon_ethernet *priv = netdev_priv(dev);
        cvm_oct_common_init(dev);
        dev->netdev_ops->ndo_stop(dev);
-       if (!octeon_is_simulation())
+       if (!octeon_is_simulation() && priv->phydev == NULL)
                priv->poll = cvm_oct_xaui_poll;
 
        return 0;
index 492c5029992de65c9b35e854fd141d9fd8c5969a..4cfd4b136b328697f36ba3294f3273bf76bd1142 100644 (file)
@@ -30,7 +30,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/delay.h>
-#include <linux/mii.h>
+#include <linux/phy.h>
 
 #include <net/dst.h>
 
@@ -132,8 +132,6 @@ static struct timer_list cvm_oct_poll_timer;
  */
 struct net_device *cvm_oct_device[TOTAL_NUMBER_OF_PORTS];
 
-extern struct semaphore mdio_sem;
-
 /**
  * Periodic timer tick for slow management operations
  *
@@ -160,13 +158,8 @@ static void cvm_do_timer(unsigned long arg)
                goto out;
 
        priv = netdev_priv(cvm_oct_device[port]);
-       if (priv->poll) {
-               /* skip polling if we don't get the lock */
-               if (!down_trylock(&mdio_sem)) {
-                       priv->poll(cvm_oct_device[port]);
-                       up(&mdio_sem);
-               }
-       }
+       if (priv->poll)
+               priv->poll(cvm_oct_device[port]);
 
        queues_per_port = cvmx_pko_get_num_queues(port);
        /* Drain any pending packets in the free list */
@@ -524,7 +517,7 @@ int cvm_oct_common_init(struct net_device *dev)
        dev->features |= NETIF_F_LLTX;
        SET_ETHTOOL_OPS(dev, &cvm_oct_ethtool_ops);
 
-       cvm_oct_mdio_setup_device(dev);
+       cvm_oct_phy_setup_device(dev);
        dev->netdev_ops->ndo_set_mac_address(dev, &sa);
        dev->netdev_ops->ndo_change_mtu(dev, dev->mtu);
 
@@ -540,7 +533,10 @@ int cvm_oct_common_init(struct net_device *dev)
 
 void cvm_oct_common_uninit(struct net_device *dev)
 {
-       /* Currently nothing to do */
+       struct octeon_ethernet *priv = netdev_priv(dev);
+
+       if (priv->phydev)
+               phy_disconnect(priv->phydev);
 }
 
 static const struct net_device_ops cvm_oct_npi_netdev_ops = {
@@ -627,6 +623,8 @@ static const struct net_device_ops cvm_oct_pow_netdev_ops = {
 #endif
 };
 
+extern void octeon_mdiobus_force_mod_depencency(void);
+
 /**
  * Module/ driver initialization. Creates the linux network
  * devices.
@@ -640,6 +638,7 @@ static int __init cvm_oct_init_module(void)
        int fau = FAU_NUM_PACKET_BUFFERS_TO_FREE;
        int qos;
 
+       octeon_mdiobus_force_mod_depencency();
        pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION);
 
        if (OCTEON_IS_MODEL(OCTEON_CN52XX))
index 3aef9878fc0ad0cb178f4f9537761bb8ecb0303d..402a15b9bb0ee1d2ffa725be0d4b71d93c0c7162 100644 (file)
@@ -50,9 +50,9 @@ struct octeon_ethernet {
        /* List of outstanding tx buffers per queue */
        struct sk_buff_head tx_free_list[16];
        /* Device statistics */
-       struct net_device_stats stats
-;      /* Generic MII info structure */
-       struct mii_if_info mii_info;
+       struct net_device_stats stats;
+       struct phy_device *phydev;
+       unsigned int last_link;
        /* Last negotiated link state */
        uint64_t link_info;
        /* Called periodically to check link status */
index 3abe7c9d558d70c0c3b6f8be743c4435dca8cb5f..3defa0133f2eb97d8e6829bbd38be765283be1cd 100644 (file)
@@ -47,7 +47,7 @@ config PANEL_PROFILE
 config PANEL_KEYPAD
        depends on PANEL && PANEL_PROFILE="0"
        int "Keypad type (0=none, 1=old 6 keys, 2=new 6 keys, 3=Nexcom 4 keys)"
-       range 0 4
+       range 0 3
        default 0
        ---help---
          This enables and configures a keypad connected to the parallel port.
index 4ce399b6d237546961b826734ca8c77003915eb4..95c93e82ccec474d44849b1ca77a46d168cfc1db 100644 (file)
@@ -55,7 +55,7 @@
 #include <linux/list.h>
 #include <linux/notifier.h>
 #include <linux/reboot.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 
 #include <linux/io.h>
 #include <asm/uaccess.h>
@@ -378,7 +378,7 @@ static unsigned char lcd_bits[LCD_PORTS][LCD_BITS][BIT_STATES];
 
 #ifdef CONFIG_PANEL_LCD_CHARSET
 #undef DEFAULT_LCD_CHARSET
-#define DEFAULT_LCD_CHARSET
+#define DEFAULT_LCD_CHARSET CONFIG_PANEL_LCD_CHARSET
 #endif
 
 #endif /* DEFAULT_PROFILE == 0 */
index 6c5b261e9f0683dd5f0b1c361f8a9ea2be225db0..aacd25bfb0cb8e00fc554f30316890cc7ada47e0 100644 (file)
@@ -722,8 +722,6 @@ static int pohmelfs_remove_entry(struct inode *dir, struct dentry *dentry)
                if (inode->i_nlink)
                        inode_dec_link_count(inode);
        }
-       dprintk("%s: inode: %p, lock: %ld, unhashed: %d.\n",
-               __func__, pi, inode->i_state & I_LOCK, hlist_unhashed(&inode->i_hash));
 
        return err;
 }
index bac40d6cb9f13927e445a3dc7860352b16ec0337..8d64e28fac0e0b7d18c5d7fb823e07f991ed8b30 100644 (file)
@@ -1,6 +1,5 @@
 TODO:
        - Add support for swap notifiers
-       - Remove CONFIG_ARM hack
 
 Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
 Nitin Gupta <ngupta@vflare.org>
index b839f05efbcedbd3a70142cebfaef12d654a3a5b..989fac5b01b3c88d830cf109bc73dfbaa652fbf1 100644 (file)
@@ -222,28 +222,6 @@ out:
        return ret;
 }
 
-static void ramzswap_flush_dcache_page(struct page *page)
-{
-#ifdef CONFIG_ARM
-       int flag = 0;
-       /*
-        * Ugly hack to get flush_dcache_page() work on ARM.
-        * page_mapping(page) == NULL after clearing this swap cache flag.
-        * Without clearing this flag, flush_dcache_page() will simply set
-        * "PG_dcache_dirty" bit and return.
-        */
-       if (PageSwapCache(page)) {
-               flag = 1;
-               ClearPageSwapCache(page);
-       }
-#endif
-       flush_dcache_page(page);
-#ifdef CONFIG_ARM
-       if (flag)
-               SetPageSwapCache(page);
-#endif
-}
-
 void ramzswap_ioctl_get_stats(struct ramzswap *rzs,
                        struct ramzswap_ioctl_stats *s)
 {
@@ -655,7 +633,7 @@ static int handle_zero_page(struct bio *bio)
        memset(user_mem, 0, PAGE_SIZE);
        kunmap_atomic(user_mem, KM_USER0);
 
-       ramzswap_flush_dcache_page(page);
+       flush_dcache_page(page);
 
        set_bit(BIO_UPTODATE, &bio->bi_flags);
        bio_endio(bio, 0);
@@ -679,7 +657,7 @@ static int handle_uncompressed_page(struct ramzswap *rzs, struct bio *bio)
        kunmap_atomic(user_mem, KM_USER0);
        kunmap_atomic(cmem, KM_USER1);
 
-       ramzswap_flush_dcache_page(page);
+       flush_dcache_page(page);
 
        set_bit(BIO_UPTODATE, &bio->bi_flags);
        bio_endio(bio, 0);
@@ -779,7 +757,7 @@ static int ramzswap_read(struct ramzswap *rzs, struct bio *bio)
                goto out;
        }
 
-       ramzswap_flush_dcache_page(page);
+       flush_dcache_page(page);
 
        set_bit(BIO_UPTODATE, &bio->bi_flags);
        bio_endio(bio, 0);
index 3222c22152fbf46ac39635b31853b1c7b2644598..0d490c164db6c8a94527ebc01ddde62b9a0ee229 100644 (file)
@@ -1318,13 +1318,13 @@ extern int ieee80211_encrypt_fragment(
        struct sk_buff *frag,
        int hdr_len);
 
-extern int ieee80211_xmit(struct sk_buff *skb,
+extern int ieee80211_rtl_xmit(struct sk_buff *skb,
                          struct net_device *dev);
 extern void ieee80211_txb_free(struct ieee80211_txb *);
 
 
 /* ieee80211_rx.c */
-extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                        struct ieee80211_rx_stats *rx_stats);
 extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
                             struct ieee80211_hdr_4addr *header,
@@ -1376,8 +1376,8 @@ extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
-extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
-extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
 extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
 extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
@@ -1385,7 +1385,7 @@ extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct
 extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
 extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
 extern void SendDisassociation(struct ieee80211_device *ieee,u8* asSta,u8 asRsn);
-extern void ieee80211_start_scan(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_start_scan(struct ieee80211_device *ieee);
 
 //Add for RF power on power off by lizhaoming 080512
 extern void SendDisassociation(struct ieee80211_device *ieee,
index f882dd8cf9b56ec38ea12cff7d315190cf62aeff..9128c181bc7d07a96a5a984d534f921e32e00ffc 100644 (file)
@@ -469,7 +469,7 @@ drop:
 /* All received frames are sent to this function. @skb contains the frame in
  * IEEE 802.11 format, i.e., in the format it was sent over air.
  * This function is called only as a tasklet (software IRQ). */
-int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                 struct ieee80211_rx_stats *rx_stats)
 {
        struct net_device *dev = ieee->dev;
index 1fe19c39d702000a95652f0dbeed42e08506bac6..c7c645af0ebb2a8627187394a6219cd979708cdd 100644 (file)
@@ -689,7 +689,7 @@ void ieee80211_stop_scan(struct ieee80211_device *ieee)
 }
 
 /* called with ieee->lock held */
-void ieee80211_start_scan(struct ieee80211_device *ieee)
+void ieee80211_rtl_start_scan(struct ieee80211_device *ieee)
 {
        if(IS_DOT11D_ENABLE(ieee) )
        {
@@ -1196,7 +1196,7 @@ void ieee80211_associate_step1(struct ieee80211_device *ieee)
        }
 }
 
-void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
+void ieee80211_rtl_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
 {
        u8 *c;
        struct sk_buff *skb;
@@ -1898,7 +1898,7 @@ associate_complete:
 
                                                                ieee80211_associate_step2(ieee);
                                                        }else{
-                                                               ieee80211_auth_challenge(ieee, challenge, chlen);
+                                                               ieee80211_rtl_auth_challenge(ieee, challenge, chlen);
                                                        }
                                                }else{
                                                        ieee->softmac_stats.rx_auth_rs_err++;
@@ -2047,7 +2047,7 @@ void ieee80211_reset_queue(struct ieee80211_device *ieee)
 
 }
 
-void ieee80211_wake_queue(struct ieee80211_device *ieee)
+void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee)
 {
 
        unsigned long flags;
@@ -2089,7 +2089,7 @@ exit :
 }
 
 
-void ieee80211_stop_queue(struct ieee80211_device *ieee)
+void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee)
 {
        //unsigned long flags;
        //spin_lock_irqsave(&ieee->lock,flags);
@@ -2301,7 +2301,7 @@ void ieee80211_start_bss(struct ieee80211_device *ieee)
 //#else
        if (ieee->state == IEEE80211_NOLINK){
                ieee->actscanning = true;
-               ieee80211_start_scan(ieee);
+               ieee80211_rtl_start_scan(ieee);
        }
 //#endif
        spin_unlock_irqrestore(&ieee->lock, flags);
@@ -2357,7 +2357,7 @@ void ieee80211_associate_retry_wq(struct work_struct *work)
        if(ieee->state == IEEE80211_NOLINK){
                ieee->beinretry = false;
                ieee->actscanning = true;
-               ieee80211_start_scan(ieee);
+               ieee80211_rtl_start_scan(ieee);
        }
        //YJ,add,080828, notify os here
        if(ieee->state == IEEE80211_NOLINK)
index dde1f2e0cf32c4b1eb7d2634e0ce410938088ca4..69bd02164b0c39b6166e044f5d7232f166487aa5 100644 (file)
@@ -304,7 +304,7 @@ ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network)
 }
 
 /* SKBs are added to the ieee->tx_queue. */
-int ieee80211_xmit(struct sk_buff *skb,
+int ieee80211_rtl_xmit(struct sk_buff *skb,
                   struct net_device *dev)
 {
        struct ieee80211_device *ieee = netdev_priv(dev);
index 57c62b0a402fd08ba4f2f5d8bcce2115ddef960e..e0f13efdb15a16f15a3d89653cf579b76bfc6e84 100644 (file)
@@ -1811,7 +1811,7 @@ void rtl8180_rx(struct net_device *dev)
                        if(priv->rx_skb->len > 4)
                                skb_trim(priv->rx_skb,priv->rx_skb->len-4);
 #ifndef RX_DONT_PASS_UL
-                       if(!ieee80211_rx(priv->ieee80211,
+                       if(!ieee80211_rtl_rx(priv->ieee80211,
                                         priv->rx_skb, &stats)){
 #endif // RX_DONT_PASS_UL
 
@@ -1917,11 +1917,11 @@ rate)
        if (!check_nic_enought_desc(dev, priority)){
                DMESGW("Error: no descriptor left by previous TX (avail %d) ",
                        get_curr_tx_free_desc(dev, priority));
-               ieee80211_stop_queue(priv->ieee80211);
+               ieee80211_rtl_stop_queue(priv->ieee80211);
        }
        rtl8180_tx(dev, skb->data, skb->len, priority, morefrag,0,rate);
        if (!check_nic_enought_desc(dev, priority))
-               ieee80211_stop_queue(priv->ieee80211);
+               ieee80211_rtl_stop_queue(priv->ieee80211);
 
        spin_unlock_irqrestore(&priv->tx_lock,flags);
 }
@@ -3680,7 +3680,7 @@ static const struct net_device_ops rtl8180_netdev_ops = {
        .ndo_set_mac_address    = r8180_set_mac_adr,
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_change_mtu         = eth_change_mtu,
-       .ndo_start_xmit         = ieee80211_xmit,
+       .ndo_start_xmit         = ieee80211_rtl_xmit,
 };
 
 static int __devinit rtl8180_pci_probe(struct pci_dev *pdev,
@@ -3900,7 +3900,7 @@ void rtl8180_try_wake_queue(struct net_device *dev, int pri)
        spin_unlock_irqrestore(&priv->tx_lock,flags);
 
        if(enough_desc)
-               ieee80211_wake_queue(priv->ieee80211);
+               ieee80211_rtl_wake_queue(priv->ieee80211);
 }
 
 void rtl8180_tx_isr(struct net_device *dev, int pri,short error)
index 536cb6e8e7966ea12021c0c2da969e99f3409d04..124cde356cbc3047fd89995906ec394ece0e41e4 100644 (file)
@@ -377,7 +377,7 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
        //      queue_work(priv->ieee80211->wq, &priv->ieee80211->wx_sync_scan_wq);
                //printk("start scan============================>\n");
                ieee80211_softmac_ips_scan_syncro(priv->ieee80211);
-//ieee80211_start_scan(priv->ieee80211);
+//ieee80211_rtl_start_scan(priv->ieee80211);
                /* intentionally forget to up sem */
 //                     up(&priv->ieee80211->wx_sem);
                        ret = 0;
index 97137ddefff468f303b4fce2f3935f08e5e30576..3ba9e9e90bda5b2d7e79ce371237873a7627f32a 100644 (file)
@@ -303,8 +303,8 @@ enum        _ReasonCode{
 #define ieee80211_rx_mgt               ieee80211_rx_mgt_rsl
 
 #define ieee80211_get_beacon           ieee80211_get_beacon_rsl
-#define ieee80211_wake_queue           ieee80211_wake_queue_rsl
-#define ieee80211_stop_queue           ieee80211_stop_queue_rsl
+#define ieee80211_rtl_wake_queue               ieee80211_rtl_wake_queue_rsl
+#define ieee80211_rtl_stop_queue               ieee80211_rtl_stop_queue_rsl
 #define ieee80211_reset_queue          ieee80211_reset_queue_rsl
 #define ieee80211_softmac_stop_protocol        ieee80211_softmac_stop_protocol_rsl
 #define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl
@@ -2435,13 +2435,13 @@ extern int ieee80211_encrypt_fragment(
        struct sk_buff *frag,
        int hdr_len);
 
-extern int ieee80211_xmit(struct sk_buff *skb,
+extern int ieee80211_rtl_xmit(struct sk_buff *skb,
                          struct net_device *dev);
 extern void ieee80211_txb_free(struct ieee80211_txb *);
 
 
 /* ieee80211_rx.c */
-extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                        struct ieee80211_rx_stats *rx_stats);
 extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
                             struct ieee80211_hdr_4addr *header,
@@ -2502,8 +2502,8 @@ extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
-extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
-extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
 extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
 extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
index 83c8452de378a41146318b12ef393f80da68f2b3..aa76390487bb755159d6f6d5d60415eff82c7eda 100644 (file)
@@ -333,8 +333,8 @@ enum        _ReasonCode{
 #define ieee80211_rx_mgt               ieee80211_rx_mgt_rsl
 
 #define ieee80211_get_beacon           ieee80211_get_beacon_rsl
-#define ieee80211_wake_queue           ieee80211_wake_queue_rsl
-#define ieee80211_stop_queue           ieee80211_stop_queue_rsl
+#define ieee80211_rtl_wake_queue               ieee80211_rtl_wake_queue_rsl
+#define ieee80211_rtl_stop_queue               ieee80211_rtl_stop_queue_rsl
 #define ieee80211_reset_queue          ieee80211_reset_queue_rsl
 #define ieee80211_softmac_stop_protocol        ieee80211_softmac_stop_protocol_rsl
 #define ieee80211_softmac_start_protocol ieee80211_softmac_start_protocol_rsl
@@ -2546,13 +2546,13 @@ extern int ieee80211_encrypt_fragment(
        struct sk_buff *frag,
        int hdr_len);
 
-extern int ieee80211_xmit(struct sk_buff *skb,
+extern int ieee80211_rtl_xmit(struct sk_buff *skb,
                          struct net_device *dev);
 extern void ieee80211_txb_free(struct ieee80211_txb *);
 
 
 /* ieee80211_rx.c */
-extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                        struct ieee80211_rx_stats *rx_stats);
 extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
                             struct ieee80211_hdr_4addr *header,
@@ -2613,8 +2613,8 @@ extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
-extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
-extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
 extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
 extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
index 2644155737a8e2c4a4535ddd71607f7fda1279b9..f43a7db5c78bfd10a1f252f68d1dd93c85f93b86 100644 (file)
@@ -119,7 +119,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
        ieee = (struct ieee80211_device *)dev->priv;
 #endif
 #if 0
-       dev->hard_start_xmit = ieee80211_xmit;
+       dev->hard_start_xmit = ieee80211_rtl_xmit;
 #endif
 
        memset(ieee, 0, sizeof(struct ieee80211_device)+sizeof_priv);
@@ -333,7 +333,7 @@ extern void ieee80211_crypto_ccmp_exit(void);
 extern int ieee80211_crypto_wep_init(void);
 extern void ieee80211_crypto_wep_exit(void);
 
-int __init ieee80211_init(void)
+int __init ieee80211_rtl_init(void)
 {
        struct proc_dir_entry *e;
        int retval;
@@ -389,7 +389,7 @@ int __init ieee80211_init(void)
        return 0;
 }
 
-void __exit ieee80211_exit(void)
+void __exit ieee80211_rtl_exit(void)
 {
        if (ieee80211_proc) {
                remove_proc_entry("debug_level", ieee80211_proc);
@@ -412,8 +412,8 @@ module_param(debug, int, 0444);
 MODULE_PARM_DESC(debug, "debug output mask");
 
 
-//module_exit(ieee80211_exit);
-//module_init(ieee80211_init);
+//module_exit(ieee80211_rtl_exit);
+//module_init(ieee80211_rtl_init);
 #endif
 #endif
 
index 5dc478b8637523b2a0c25b68c21429c0ee82a6c6..06d91715143c37fddd1447c563ff13f8c5daeccf 100644 (file)
@@ -923,7 +923,7 @@ u8 parse_subframe(struct sk_buff *skb,
 /* All received frames are sent to this function. @skb contains the frame in
  * IEEE 802.11 format, i.e., in the format it was sent over air.
  * This function is called only as a tasklet (software IRQ). */
-int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                 struct ieee80211_rx_stats *rx_stats)
 {
        struct net_device *dev = ieee->dev;
index 593d228251849692dfded47831551c360ba42da0..6d1ddec39f0e943ae4cbbcdcf1ca933665f14d0d 100644 (file)
@@ -684,7 +684,7 @@ void ieee80211_stop_scan(struct ieee80211_device *ieee)
 }
 
 /* called with ieee->lock held */
-void ieee80211_start_scan(struct ieee80211_device *ieee)
+void ieee80211_rtl_start_scan(struct ieee80211_device *ieee)
 {
 #ifdef ENABLE_DOT11D
        if(IS_DOT11D_ENABLE(ieee) )
@@ -1430,7 +1430,7 @@ void ieee80211_associate_step1(struct ieee80211_device *ieee)
        }
 }
 
-void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
+void ieee80211_rtl_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
 {
        u8 *c;
        struct sk_buff *skb;
@@ -2262,7 +2262,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
 
                                                                ieee80211_associate_step2(ieee);
                                                        }else{
-                                                               ieee80211_auth_challenge(ieee, challenge, chlen);
+                                                               ieee80211_rtl_auth_challenge(ieee, challenge, chlen);
                                                        }
                                                }else{
                                                        ieee->softmac_stats.rx_auth_rs_err++;
@@ -2376,7 +2376,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *
                         * to check it any more.
                         * */
                        //printk("error:no descriptor left@queue_index %d\n", queue_index);
-                       //ieee80211_stop_queue(ieee);
+                       //ieee80211_rtl_stop_queue(ieee);
 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
                        skb_queue_tail(&ieee->skb_drv_aggQ[queue_index], txb->fragments[i]);
 #else
@@ -2440,7 +2440,7 @@ void ieee80211_reset_queue(struct ieee80211_device *ieee)
 
 }
 
-void ieee80211_wake_queue(struct ieee80211_device *ieee)
+void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee)
 {
 
        unsigned long flags;
@@ -2481,7 +2481,7 @@ exit :
 }
 
 
-void ieee80211_stop_queue(struct ieee80211_device *ieee)
+void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee)
 {
        //unsigned long flags;
        //spin_lock_irqsave(&ieee->lock,flags);
@@ -2706,7 +2706,7 @@ void ieee80211_start_bss(struct ieee80211_device *ieee)
 
        if (ieee->state == IEEE80211_NOLINK){
                ieee->actscanning = true;
-               ieee80211_start_scan(ieee);
+               ieee80211_rtl_start_scan(ieee);
        }
        spin_unlock_irqrestore(&ieee->lock, flags);
 }
@@ -2775,7 +2775,7 @@ void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
        {
                ieee->is_roaming= false;
                ieee->actscanning = true;
-               ieee80211_start_scan(ieee);
+               ieee80211_rtl_start_scan(ieee);
        }
        spin_unlock_irqrestore(&ieee->lock, flags);
 
@@ -3497,8 +3497,8 @@ void notify_wx_assoc_event(struct ieee80211_device *ieee)
 
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
 //EXPORT_SYMBOL(ieee80211_get_beacon);
-//EXPORT_SYMBOL(ieee80211_wake_queue);
-//EXPORT_SYMBOL(ieee80211_stop_queue);
+//EXPORT_SYMBOL(ieee80211_rtl_wake_queue);
+//EXPORT_SYMBOL(ieee80211_rtl_stop_queue);
 //EXPORT_SYMBOL(ieee80211_reset_queue);
 //EXPORT_SYMBOL(ieee80211_softmac_stop_protocol);
 //EXPORT_SYMBOL(ieee80211_softmac_start_protocol);
@@ -3518,8 +3518,8 @@ void notify_wx_assoc_event(struct ieee80211_device *ieee)
 //EXPORT_SYMBOL(ieee80211_start_scan_syncro);
 #else
 EXPORT_SYMBOL_NOVERS(ieee80211_get_beacon);
-EXPORT_SYMBOL_NOVERS(ieee80211_wake_queue);
-EXPORT_SYMBOL_NOVERS(ieee80211_stop_queue);
+EXPORT_SYMBOL_NOVERS(ieee80211_rtl_wake_queue);
+EXPORT_SYMBOL_NOVERS(ieee80211_rtl_stop_queue);
 EXPORT_SYMBOL_NOVERS(ieee80211_reset_queue);
 EXPORT_SYMBOL_NOVERS(ieee80211_softmac_stop_protocol);
 EXPORT_SYMBOL_NOVERS(ieee80211_softmac_start_protocol);
index 103b33c093f581645ce6cbc142660a79cb82ab9c..798fb4154c2587943aa01011af8cc2ddc5fe31b4 100644 (file)
@@ -604,7 +604,7 @@ void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u
        }
 }
 
-int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
+int ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
        struct ieee80211_device *ieee = netdev_priv(dev);
index 4e34a1f4c66b5a3159339724e3253c57722216a5..3441b72dd8fa17ef517eb1b171dacd62f7fd9b30 100644 (file)
@@ -976,7 +976,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
        {
                if (len != ie[1]+2)
                {
-                       printk("len:%d, ie:%d\n", len, ie[1]);
+                       printk("len:%zu, ie:%d\n", len, ie[1]);
                        return -EINVAL;
                }
                buf = kmalloc(len, GFP_KERNEL);
index 98b3bb6b6d69d7a5899e2d3e5e1f7e887d43583a..e41e8a0c739c36cd38ba88ba12aaa37c596ba838 100644 (file)
@@ -382,7 +382,7 @@ int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %d)\n", skb->len,     (sizeof( struct ieee80211_hdr_3addr) + 9));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 9));
                return -1;
        }
 
@@ -481,7 +481,7 @@ int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %d)\n", skb->len,     (sizeof( struct ieee80211_hdr_3addr) + 9));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 9));
                return -1;
        }
        rsp = ( struct ieee80211_hdr_3addr*)skb->data;
@@ -611,7 +611,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", skb->len,     (sizeof( struct ieee80211_hdr_3addr) + 6));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 6));
                return -1;
        }
 
index ff8fe7e32a9284d6a6cac344961fd9423867767e..0ca5d8b4f746a4004332dbd392e02088dc190e67 100644 (file)
@@ -5795,7 +5795,7 @@ static void rtl8192_rx(struct net_device *dev)
                 stats.fragoffset = 0;
                 stats.ntotalfrag = 1;
 
-                if(!ieee80211_rx(priv->ieee80211, skb, &stats)){
+                if(!ieee80211_rtl_rx(priv->ieee80211, skb, &stats)){
                     dev_kfree_skb_any(skb);
                 } else {
                     priv->stats.rxok++;
@@ -5837,7 +5837,7 @@ static const struct net_device_ops rtl8192_netdev_ops = {
        .ndo_do_ioctl =                 rtl8192_ioctl,
        .ndo_set_multicast_list =       r8192_set_multicast,
        .ndo_set_mac_address =          r8192_set_mac_adr,
-       .ndo_start_xmit =               ieee80211_xmit,
+       .ndo_start_xmit =               ieee80211_rtl_xmit,
 };
 
 /****************************************************************************
@@ -6121,14 +6121,14 @@ static void __devexit rtl8192_pci_disconnect(struct pci_dev *pdev)
        RT_TRACE(COMP_DOWN, "wlan driver removed\n");
 }
 
-extern int ieee80211_init(void);
-extern void ieee80211_exit(void);
+extern int ieee80211_rtl_init(void);
+extern void ieee80211_rtl_exit(void);
 
 static int __init rtl8192_pci_module_init(void)
 {
        int retval;
 
-       retval = ieee80211_init();
+       retval = ieee80211_rtl_init();
        if (retval)
                return retval;
 
@@ -6153,7 +6153,7 @@ static void __exit rtl8192_pci_module_exit(void)
 
        RT_TRACE(COMP_DOWN, "Exiting");
        rtl8192_proc_module_remove();
-       ieee80211_exit();
+       ieee80211_rtl_exit();
 }
 
 //warning message WB
@@ -6313,7 +6313,7 @@ void rtl8192_try_wake_queue(struct net_device *dev, int pri)
         spin_unlock_irqrestore(&priv->tx_lock,flags);
 
        if(enough_desc)
-               ieee80211_wake_queue(priv->ieee80211);
+               ieee80211_rtl_wake_queue(priv->ieee80211);
 #endif
 }
 
index f22d024b1c39bdd7710cfc7213f4ef9ec6d2c25d..9a4c858b0666695d9bb81bb734cb18109881259c 100644 (file)
@@ -1721,13 +1721,13 @@ extern int ieee80211_encrypt_fragment(
        struct sk_buff *frag,
        int hdr_len);
 
-extern int rtl8192_ieee80211_xmit(struct sk_buff *skb,
+extern int rtl8192_ieee80211_rtl_xmit(struct sk_buff *skb,
                          struct net_device *dev);
 extern void ieee80211_txb_free(struct ieee80211_txb *);
 
 
 /* ieee80211_rx.c */
-extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+extern int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                        struct ieee80211_rx_stats *rx_stats);
 extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
                             struct ieee80211_hdr_4addr *header,
@@ -1783,8 +1783,8 @@ extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
 extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
-extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
-extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee);
+extern void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee);
 extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
 extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
 extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
index ac223cef1d3334aac059a8bf46bea0a38d0eaa88..fecfa120ff488b8fd956ce850cd2eefd6bf4bbe8 100644 (file)
@@ -208,7 +208,7 @@ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
  *
  * Responsible for handling management control frames
  *
- * Called by ieee80211_rx */
+ * Called by ieee80211_rtl_rx */
 static inline int
 ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
                        struct ieee80211_rx_stats *rx_stats, u16 type,
@@ -289,7 +289,7 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
        return 0;
 }
 
-/* Called only as a tasklet (software IRQ), by ieee80211_rx */
+/* Called only as a tasklet (software IRQ), by ieee80211_rtl_rx */
 static inline int
 ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
                           struct ieee80211_crypt_data *crypt)
@@ -858,7 +858,7 @@ u8 parse_subframe(struct sk_buff *skb,
 /* All received frames are sent to this function. @skb contains the frame in
  * IEEE 802.11 format, i.e., in the format it was sent over air.
  * This function is called only as a tasklet (software IRQ). */
-int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
+int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
                 struct ieee80211_rx_stats *rx_stats)
 {
        struct net_device *dev = ieee->dev;
index 203c0a5cc8c16f2f7dbeed4da26efefb3554c26f..95d4f84dcf3fff9d360b4ee37d20c91b631c86ce 100644 (file)
@@ -610,7 +610,7 @@ void ieee80211_stop_scan(struct ieee80211_device *ieee)
 }
 
 /* called with ieee->lock held */
-void ieee80211_start_scan(struct ieee80211_device *ieee)
+void ieee80211_rtl_start_scan(struct ieee80211_device *ieee)
 {
        if(IS_DOT11D_ENABLE(ieee) )
        {
@@ -1281,7 +1281,7 @@ void ieee80211_associate_step1(struct ieee80211_device *ieee)
        }
 }
 
-void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
+void ieee80211_rtl_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
 {
        u8 *c;
        struct sk_buff *skb;
@@ -2054,7 +2054,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
 
                                                                ieee80211_associate_step2(ieee);
                                                        }else{
-                                                               ieee80211_auth_challenge(ieee, challenge, chlen);
+                                                               ieee80211_rtl_auth_challenge(ieee, challenge, chlen);
                                                        }
                                                }else{
                                                        ieee->softmac_stats.rx_auth_rs_err++;
@@ -2162,7 +2162,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *
                         * to check it any more.
                         * */
                        //printk("error:no descriptor left@queue_index %d, %d, %d\n", queue_index, skb_queue_len(&ieee->skb_waitQ[queue_index]), ieee->check_nic_enough_desc(ieee->dev,queue_index));
-                       //ieee80211_stop_queue(ieee);
+                       //ieee80211_rtl_stop_queue(ieee);
                        skb_queue_tail(&ieee->skb_waitQ[queue_index], txb->fragments[i]);
                }else{
                        ieee->softmac_data_hard_start_xmit(
@@ -2222,7 +2222,7 @@ void ieee80211_reset_queue(struct ieee80211_device *ieee)
 
 }
 
-void ieee80211_wake_queue(struct ieee80211_device *ieee)
+void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee)
 {
 
        unsigned long flags;
@@ -2263,7 +2263,7 @@ exit :
 }
 
 
-void ieee80211_stop_queue(struct ieee80211_device *ieee)
+void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee)
 {
        //unsigned long flags;
        //spin_lock_irqsave(&ieee->lock,flags);
@@ -2479,7 +2479,7 @@ void ieee80211_start_bss(struct ieee80211_device *ieee)
 
        if (ieee->state == IEEE80211_NOLINK){
                ieee->actscanning = true;
-               ieee80211_start_scan(ieee);
+               ieee80211_rtl_start_scan(ieee);
        }
        spin_unlock_irqrestore(&ieee->lock, flags);
 }
@@ -2552,7 +2552,7 @@ void ieee80211_associate_retry_wq(struct work_struct *work)
        if(ieee->state == IEEE80211_NOLINK)
        {
                ieee->actscanning = true;
-               ieee80211_start_scan(ieee);
+               ieee80211_rtl_start_scan(ieee);
        }
        spin_unlock_irqrestore(&ieee->lock, flags);
 
index 60621d6b2a6bbb3565de8c3071573aaf47b88c3b..4d54e1e62d22585b37511b5270f897ef103feac6 100644 (file)
@@ -604,7 +604,7 @@ void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u
        }
 }
 
-int rtl8192_ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
+int rtl8192_ieee80211_rtl_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct ieee80211_device *ieee = netdev_priv(dev);
        struct ieee80211_txb *txb = NULL;
index 66274d7666ff04de3b7e6215196d377e740f1b9d..ccb9d5b8cd444c154813fa270499f6cdbc407291 100644 (file)
@@ -126,6 +126,8 @@ static struct usb_device_id rtl8192_usb_id_tbl[] = {
        {USB_DEVICE(0x2001, 0x3301)},
        /* Zinwell */
        {USB_DEVICE(0x5a57, 0x0290)},
+       /* Guillemot */
+       {USB_DEVICE(0x06f8, 0xe031)},
        //92SU
        {USB_DEVICE(0x0bda, 0x8172)},
        {}
@@ -1501,7 +1503,7 @@ static void rtl8192_rx_isr(struct urb *urb)
         urb->context = skb;
         skb_queue_tail(&priv->rx_queue, skb);
         err = usb_submit_urb(urb, GFP_ATOMIC);
-       if(err && err != EPERM)
+       if(err && err != -EPERM)
                printk("can not submit rxurb, err is %x,URB status is %x\n",err,urb->status);
 }
 
@@ -7155,7 +7157,7 @@ void rtl8192SU_rx_nomal(struct sk_buff* skb)
                        unicast_packet = true;
                }
 
-               if(!ieee80211_rx(priv->ieee80211,skb, &stats)) {
+               if(!ieee80211_rtl_rx(priv->ieee80211,skb, &stats)) {
                        dev_kfree_skb_any(skb);
                } else {
                //      priv->stats.rxoktotal++;  //YJ,test,090108
@@ -7426,7 +7428,7 @@ static const struct net_device_ops rtl8192_netdev_ops = {
        .ndo_set_mac_address    = r8192_set_mac_adr,
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_change_mtu         = eth_change_mtu,
-       .ndo_start_xmit         = rtl8192_ieee80211_xmit,
+       .ndo_start_xmit         = rtl8192_ieee80211_rtl_xmit,
 };
 
 static int __devinit rtl8192_usb_probe(struct usb_interface *intf,
@@ -7619,7 +7621,7 @@ void rtl8192_try_wake_queue(struct net_device *dev, int pri)
         spin_unlock_irqrestore(&priv->tx_lock,flags);
 
        if(enough_desc)
-               ieee80211_wake_queue(priv->ieee80211);
+               ieee80211_rtl_wake_queue(priv->ieee80211);
 }
 
 void EnableHWSecurityConfig8192(struct net_device *dev)
index d397f1d68eb7640668ad05591f0d1908d0d4e957..5f12d62658c9eba5047321c75903bd8962d0e24d 100644 (file)
@@ -845,7 +845,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
        {
                if (len != ie[1]+2)
                {
-                       printk("len:%d, ie:%d\n", len, ie[1]);
+                       printk("len:%zu, ie:%d\n", len, ie[1]);
                        return -EINVAL;
                }
                buf = kmalloc(len, GFP_KERNEL);
index 26af43bb8390632e248e8ccbd88d68bfe5139c4a..512a57aebde3bc045fade27d874b0233d0fbc3c2 100644 (file)
@@ -340,7 +340,7 @@ int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %d)\n", skb->len,     (sizeof( struct ieee80211_hdr_3addr) + 9));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 9));
                return -1;
        }
 
@@ -439,7 +439,7 @@ int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 9)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %d)\n", skb->len,     (sizeof( struct ieee80211_hdr_3addr) + 9));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 9));
                return -1;
        }
        rsp = ( struct ieee80211_hdr_3addr*)skb->data;
@@ -569,7 +569,7 @@ int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
 
        if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
        {
-               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", skb->len,     (sizeof( struct ieee80211_hdr_3addr) + 6));
+               IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len,    (sizeof( struct ieee80211_hdr_3addr) + 6));
                return -1;
        }
 
diff --git a/drivers/staging/sm7xx/Kconfig b/drivers/staging/sm7xx/Kconfig
new file mode 100644 (file)
index 0000000..204dbfc
--- /dev/null
@@ -0,0 +1,15 @@
+config FB_SM7XX
+       tristate "Silicon Motion SM7XX Frame Buffer Support"
+       depends on FB
+       select FB_CFB_FILLRECT
+       select FB_CFB_COPYAREA
+       select FB_CFB_IMAGEBLIT
+       help
+         Frame Buffer driver for the Silicon Motion SM7XX serial graphic card.
+
+config FB_SM7XX_ACCEL
+       bool "Siliconmotion Acceleration functions (EXPERIMENTAL)"
+       depends on FB_SM7XX && EXPERIMENTAL
+       help
+         This will compile the Trident frame buffer device with
+         acceleration functions.
diff --git a/drivers/staging/sm7xx/Makefile b/drivers/staging/sm7xx/Makefile
new file mode 100644 (file)
index 0000000..f43cb91
--- /dev/null
@@ -0,0 +1,3 @@
+obj-$(CONFIG_FB_SM7XX) += sm7xx.o
+
+sm7xx-y := smtcfb.o
diff --git a/drivers/staging/sm7xx/TODO b/drivers/staging/sm7xx/TODO
new file mode 100644 (file)
index 0000000..1f61f5e
--- /dev/null
@@ -0,0 +1,10 @@
+TODO:
+- Dual head support
+- use kernel coding style
+- checkpatch.pl clean
+- refine the code and remove unused code
+- use kernel framebuffer mode setting instead of hard code
+- move it to drivers/video/sm7xx/ or make it be drivers/video/sm7xxfb.c
+
+Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and
+Teddy Wang <teddy.wang@siliconmotion.com.cn>.
diff --git a/drivers/staging/sm7xx/smtc2d.c b/drivers/staging/sm7xx/smtc2d.c
new file mode 100644 (file)
index 0000000..133b86c
--- /dev/null
@@ -0,0 +1,979 @@
+/*
+ * Silicon Motion SM7XX 2D drawing engine functions.
+ *
+ * Copyright (C) 2006 Silicon Motion Technology Corp.
+ * Author: Boyod boyod.yang@siliconmotion.com.cn
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License. See the file COPYING in the main directory of this archive for
+ *  more details.
+ *
+ * Version 0.10.26192.21.01
+ *     - Add PowerPC support
+ *     - Add 2D support for Lynx -
+ * Verified on 2.6.19.2
+ *     Boyod.yang  <boyod.yang@siliconmotion.com.cn>
+ */
+
+unsigned char smtc_de_busy;
+
+void SMTC_write2Dreg(unsigned long nOffset, unsigned long nData)
+{
+       writel(nData, smtc_2DBaseAddress + nOffset);
+}
+
+unsigned long SMTC_read2Dreg(unsigned long nOffset)
+{
+       return readl(smtc_2DBaseAddress + nOffset);
+}
+
+void SMTC_write2Ddataport(unsigned long nOffset, unsigned long nData)
+{
+       writel(nData, smtc_2Ddataport + nOffset);
+}
+
+/**********************************************************************
+ *
+ * deInit
+ *
+ * Purpose
+ *    Drawing engine initialization.
+ *
+ **********************************************************************/
+
+void deInit(unsigned int nModeWidth, unsigned int nModeHeight,
+               unsigned int bpp)
+{
+       /* Get current power configuration. */
+       unsigned char clock;
+       clock = smtc_seqr(0x21);
+
+       /* initialize global 'mutex lock' variable */
+       smtc_de_busy = 0;
+
+       /* Enable 2D Drawing Engine */
+       smtc_seqw(0x21, clock & 0xF8);
+
+       SMTC_write2Dreg(DE_CLIP_TL,
+                       FIELD_VALUE(0, DE_CLIP_TL, TOP, 0) |
+                       FIELD_SET(0, DE_CLIP_TL, STATUS, DISABLE) |
+                       FIELD_SET(0, DE_CLIP_TL, INHIBIT, OUTSIDE) |
+                       FIELD_VALUE(0, DE_CLIP_TL, LEFT, 0));
+
+       if (bpp >= 24) {
+               SMTC_write2Dreg(DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION,
+                                           nModeWidth * 3) | FIELD_VALUE(0,
+                                                                 DE_PITCH,
+                                                                 SOURCE,
+                                                                 nModeWidth
+                                                                 * 3));
+       } else {
+               SMTC_write2Dreg(DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION,
+                                           nModeWidth) | FIELD_VALUE(0,
+                                                             DE_PITCH,
+                                                             SOURCE,
+                                                             nModeWidth));
+       }
+
+       SMTC_write2Dreg(DE_WINDOW_WIDTH,
+                       FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION,
+                                   nModeWidth) | FIELD_VALUE(0,
+                                                             DE_WINDOW_WIDTH,
+                                                             SOURCE,
+                                                             nModeWidth));
+
+       switch (bpp) {
+       case 8:
+               SMTC_write2Dreg(DE_STRETCH_FORMAT,
+                               FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY,
+                                         NORMAL) | FIELD_VALUE(0,
+                                                       DE_STRETCH_FORMAT,
+                                                       PATTERN_Y,
+                                                       0) |
+                               FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X,
+                                   0) | FIELD_SET(0, DE_STRETCH_FORMAT,
+                                                  PIXEL_FORMAT,
+                                                  8) | FIELD_SET(0,
+                                                         DE_STRETCH_FORMAT,
+                                                         ADDRESSING,
+                                                         XY) |
+                               FIELD_VALUE(0, DE_STRETCH_FORMAT,
+                                       SOURCE_HEIGHT, 3));
+               break;
+       case 24:
+               SMTC_write2Dreg(DE_STRETCH_FORMAT,
+                               FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY,
+                                         NORMAL) | FIELD_VALUE(0,
+                                                       DE_STRETCH_FORMAT,
+                                                       PATTERN_Y,
+                                                       0) |
+                               FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X,
+                                   0) | FIELD_SET(0, DE_STRETCH_FORMAT,
+                                                          PIXEL_FORMAT,
+                                                          24) | FIELD_SET(0,
+                                                          DE_STRETCH_FORMAT,
+                                                          ADDRESSING,
+                                                          XY) |
+                               FIELD_VALUE(0, DE_STRETCH_FORMAT,
+                                       SOURCE_HEIGHT, 3));
+               break;
+       case 16:
+       default:
+               SMTC_write2Dreg(DE_STRETCH_FORMAT,
+                               FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY,
+                                         NORMAL) | FIELD_VALUE(0,
+                                                       DE_STRETCH_FORMAT,
+                                                       PATTERN_Y,
+                                                       0) |
+                               FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X,
+                                   0) | FIELD_SET(0, DE_STRETCH_FORMAT,
+                                                          PIXEL_FORMAT,
+                                                          16) | FIELD_SET(0,
+                                                          DE_STRETCH_FORMAT,
+                                                          ADDRESSING,
+                                                          XY) |
+                               FIELD_VALUE(0, DE_STRETCH_FORMAT,
+                                       SOURCE_HEIGHT, 3));
+               break;
+       }
+
+       SMTC_write2Dreg(DE_MASKS,
+                       FIELD_VALUE(0, DE_MASKS, BYTE_MASK, 0xFFFF) |
+                       FIELD_VALUE(0, DE_MASKS, BIT_MASK, 0xFFFF));
+       SMTC_write2Dreg(DE_COLOR_COMPARE_MASK,
+                       FIELD_VALUE(0, DE_COLOR_COMPARE_MASK, MASKS, \
+                               0xFFFFFF));
+       SMTC_write2Dreg(DE_COLOR_COMPARE,
+                       FIELD_VALUE(0, DE_COLOR_COMPARE, COLOR, 0xFFFFFF));
+}
+
+void deVerticalLine(unsigned long dst_base,
+                   unsigned long dst_pitch,
+                   unsigned long nX,
+                   unsigned long nY,
+                   unsigned long dst_height, unsigned long nColor)
+{
+       deWaitForNotBusy();
+
+       SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE,
+                       FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, ADDRESS,
+                                   dst_base));
+
+       SMTC_write2Dreg(DE_PITCH,
+                       FIELD_VALUE(0, DE_PITCH, DESTINATION, dst_pitch) |
+                       FIELD_VALUE(0, DE_PITCH, SOURCE, dst_pitch));
+
+       SMTC_write2Dreg(DE_WINDOW_WIDTH,
+                       FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION,
+                           dst_pitch) | FIELD_VALUE(0, DE_WINDOW_WIDTH,
+                                                    SOURCE,
+                                                    dst_pitch));
+
+       SMTC_write2Dreg(DE_FOREGROUND,
+                       FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor));
+
+       SMTC_write2Dreg(DE_DESTINATION,
+                       FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) |
+                       FIELD_VALUE(0, DE_DESTINATION, X, nX) |
+                       FIELD_VALUE(0, DE_DESTINATION, Y, nY));
+
+       SMTC_write2Dreg(DE_DIMENSION,
+                       FIELD_VALUE(0, DE_DIMENSION, X, 1) |
+                       FIELD_VALUE(0, DE_DIMENSION, Y_ET, dst_height));
+
+       SMTC_write2Dreg(DE_CONTROL,
+                       FIELD_SET(0, DE_CONTROL, STATUS, START) |
+                       FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT) |
+                       FIELD_SET(0, DE_CONTROL, MAJOR, Y) |
+                       FIELD_SET(0, DE_CONTROL, STEP_X, NEGATIVE) |
+                       FIELD_SET(0, DE_CONTROL, STEP_Y, POSITIVE) |
+                       FIELD_SET(0, DE_CONTROL, LAST_PIXEL, OFF) |
+                       FIELD_SET(0, DE_CONTROL, COMMAND, SHORT_STROKE) |
+                       FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) |
+                       FIELD_VALUE(0, DE_CONTROL, ROP, 0x0C));
+
+       smtc_de_busy = 1;
+}
+
+void deHorizontalLine(unsigned long dst_base,
+                     unsigned long dst_pitch,
+                     unsigned long nX,
+                     unsigned long nY,
+                     unsigned long dst_width, unsigned long nColor)
+{
+       deWaitForNotBusy();
+
+       SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE,
+                       FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, ADDRESS,
+                                   dst_base));
+
+       SMTC_write2Dreg(DE_PITCH,
+                       FIELD_VALUE(0, DE_PITCH, DESTINATION, dst_pitch) |
+                       FIELD_VALUE(0, DE_PITCH, SOURCE, dst_pitch));
+
+       SMTC_write2Dreg(DE_WINDOW_WIDTH,
+                       FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION,
+                           dst_pitch) | FIELD_VALUE(0, DE_WINDOW_WIDTH,
+                                                    SOURCE,
+                                                    dst_pitch));
+       SMTC_write2Dreg(DE_FOREGROUND,
+                       FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor));
+       SMTC_write2Dreg(DE_DESTINATION,
+                       FIELD_SET(0, DE_DESTINATION, WRAP,
+                         DISABLE) | FIELD_VALUE(0, DE_DESTINATION, X,
+                                                nX) | FIELD_VALUE(0,
+                                                          DE_DESTINATION,
+                                                          Y,
+                                                          nY));
+       SMTC_write2Dreg(DE_DIMENSION,
+                       FIELD_VALUE(0, DE_DIMENSION, X,
+                           dst_width) | FIELD_VALUE(0, DE_DIMENSION,
+                                                    Y_ET, 1));
+       SMTC_write2Dreg(DE_CONTROL,
+               FIELD_SET(0, DE_CONTROL, STATUS, START) | FIELD_SET(0,
+                                                           DE_CONTROL,
+                                                           DIRECTION,
+                                                           RIGHT_TO_LEFT)
+               | FIELD_SET(0, DE_CONTROL, MAJOR, X) | FIELD_SET(0,
+                                                        DE_CONTROL,
+                                                        STEP_X,
+                                                        POSITIVE)
+               | FIELD_SET(0, DE_CONTROL, STEP_Y,
+                           NEGATIVE) | FIELD_SET(0, DE_CONTROL,
+                                                 LAST_PIXEL,
+                                                 OFF) | FIELD_SET(0,
+                                                          DE_CONTROL,
+                                                          COMMAND,
+                                                          SHORT_STROKE)
+               | FIELD_SET(0, DE_CONTROL, ROP_SELECT,
+                           ROP2) | FIELD_VALUE(0, DE_CONTROL, ROP,
+                                               0x0C));
+
+       smtc_de_busy = 1;
+}
+
+void deLine(unsigned long dst_base,
+           unsigned long dst_pitch,
+           unsigned long nX1,
+           unsigned long nY1,
+           unsigned long nX2, unsigned long nY2, unsigned long nColor)
+{
+       unsigned long nCommand =
+           FIELD_SET(0, DE_CONTROL, STATUS, START) |
+           FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT) |
+           FIELD_SET(0, DE_CONTROL, MAJOR, X) |
+           FIELD_SET(0, DE_CONTROL, STEP_X, POSITIVE) |
+           FIELD_SET(0, DE_CONTROL, STEP_Y, POSITIVE) |
+           FIELD_SET(0, DE_CONTROL, LAST_PIXEL, OFF) |
+           FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) |
+           FIELD_VALUE(0, DE_CONTROL, ROP, 0x0C);
+       unsigned long DeltaX;
+       unsigned long DeltaY;
+
+       /* Calculate delta X */
+       if (nX1 <= nX2)
+               DeltaX = nX2 - nX1;
+       else {
+               DeltaX = nX1 - nX2;
+               nCommand = FIELD_SET(nCommand, DE_CONTROL, STEP_X, NEGATIVE);
+       }
+
+       /* Calculate delta Y */
+       if (nY1 <= nY2)
+               DeltaY = nY2 - nY1;
+       else {
+               DeltaY = nY1 - nY2;
+               nCommand = FIELD_SET(nCommand, DE_CONTROL, STEP_Y, NEGATIVE);
+       }
+
+       /* Determine the major axis */
+       if (DeltaX < DeltaY)
+               nCommand = FIELD_SET(nCommand, DE_CONTROL, MAJOR, Y);
+
+       /* Vertical line? */
+       if (nX1 == nX2)
+               deVerticalLine(dst_base, dst_pitch, nX1, nY1, DeltaY, nColor);
+
+       /* Horizontal line? */
+       else if (nY1 == nY2)
+               deHorizontalLine(dst_base, dst_pitch, nX1, nY1, \
+                               DeltaX, nColor);
+
+       /* Diagonal line? */
+       else if (DeltaX == DeltaY) {
+               deWaitForNotBusy();
+
+               SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE,
+                               FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE,
+                                           ADDRESS, dst_base));
+
+               SMTC_write2Dreg(DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION,
+                                           dst_pitch) | FIELD_VALUE(0,
+                                                            DE_PITCH,
+                                                            SOURCE,
+                                                            dst_pitch));
+
+               SMTC_write2Dreg(DE_WINDOW_WIDTH,
+                               FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION,
+                                           dst_pitch) | FIELD_VALUE(0,
+                                                            DE_WINDOW_WIDTH,
+                                                            SOURCE,
+                                                            dst_pitch));
+
+               SMTC_write2Dreg(DE_FOREGROUND,
+                               FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor));
+
+               SMTC_write2Dreg(DE_DESTINATION,
+                               FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) |
+                               FIELD_VALUE(0, DE_DESTINATION, X, 1) |
+                               FIELD_VALUE(0, DE_DESTINATION, Y, nY1));
+
+               SMTC_write2Dreg(DE_DIMENSION,
+                               FIELD_VALUE(0, DE_DIMENSION, X, 1) |
+                               FIELD_VALUE(0, DE_DIMENSION, Y_ET, DeltaX));
+
+               SMTC_write2Dreg(DE_CONTROL,
+                               FIELD_SET(nCommand, DE_CONTROL, COMMAND,
+                                         SHORT_STROKE));
+       }
+
+       /* Generic line */
+       else {
+               unsigned int k1, k2, et, w;
+               if (DeltaX < DeltaY) {
+                       k1 = 2 * DeltaX;
+                       et = k1 - DeltaY;
+                       k2 = et - DeltaY;
+                       w = DeltaY + 1;
+               } else {
+                       k1 = 2 * DeltaY;
+                       et = k1 - DeltaX;
+                       k2 = et - DeltaX;
+                       w = DeltaX + 1;
+               }
+
+               deWaitForNotBusy();
+
+               SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE,
+                               FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE,
+                                           ADDRESS, dst_base));
+
+               SMTC_write2Dreg(DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION,
+                                           dst_pitch) | FIELD_VALUE(0,
+                                                            DE_PITCH,
+                                                            SOURCE,
+                                                            dst_pitch));
+
+               SMTC_write2Dreg(DE_WINDOW_WIDTH,
+                               FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION,
+                                           dst_pitch) | FIELD_VALUE(0,
+                                                            DE_WINDOW_WIDTH,
+                                                            SOURCE,
+                                                            dst_pitch));
+
+               SMTC_write2Dreg(DE_FOREGROUND,
+                               FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor));
+
+               SMTC_write2Dreg(DE_SOURCE,
+                               FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) |
+                               FIELD_VALUE(0, DE_SOURCE, X_K1, k1) |
+                               FIELD_VALUE(0, DE_SOURCE, Y_K2, k2));
+
+               SMTC_write2Dreg(DE_DESTINATION,
+                               FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) |
+                               FIELD_VALUE(0, DE_DESTINATION, X, nX1) |
+                               FIELD_VALUE(0, DE_DESTINATION, Y, nY1));
+
+               SMTC_write2Dreg(DE_DIMENSION,
+                               FIELD_VALUE(0, DE_DIMENSION, X, w) |
+                               FIELD_VALUE(0, DE_DIMENSION, Y_ET, et));
+
+               SMTC_write2Dreg(DE_CONTROL,
+                               FIELD_SET(nCommand, DE_CONTROL, COMMAND,
+                                         LINE_DRAW));
+       }
+
+       smtc_de_busy = 1;
+}
+
+void deFillRect(unsigned long dst_base,
+               unsigned long dst_pitch,
+               unsigned long dst_X,
+               unsigned long dst_Y,
+               unsigned long dst_width,
+               unsigned long dst_height, unsigned long nColor)
+{
+       deWaitForNotBusy();
+
+       SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE,
+                       FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, ADDRESS,
+                                   dst_base));
+
+       if (dst_pitch) {
+               SMTC_write2Dreg(DE_PITCH,
+                               FIELD_VALUE(0, DE_PITCH, DESTINATION,
+                                           dst_pitch) | FIELD_VALUE(0,
+                                                            DE_PITCH,
+                                                            SOURCE,
+                                                            dst_pitch));
+
+               SMTC_write2Dreg(DE_WINDOW_WIDTH,
+                               FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION,
+                                           dst_pitch) | FIELD_VALUE(0,
+                                                            DE_WINDOW_WIDTH,
+                                                            SOURCE,
+                                                            dst_pitch));
+       }
+
+       SMTC_write2Dreg(DE_FOREGROUND,
+                       FIELD_VALUE(0, DE_FOREGROUND, COLOR, nColor));
+
+       SMTC_write2Dreg(DE_DESTINATION,
+                       FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) |
+                       FIELD_VALUE(0, DE_DESTINATION, X, dst_X) |
+                       FIELD_VALUE(0, DE_DESTINATION, Y, dst_Y));
+
+       SMTC_write2Dreg(DE_DIMENSION,
+                       FIELD_VALUE(0, DE_DIMENSION, X, dst_width) |
+                       FIELD_VALUE(0, DE_DIMENSION, Y_ET, dst_height));
+
+       SMTC_write2Dreg(DE_CONTROL,
+                       FIELD_SET(0, DE_CONTROL, STATUS, START) |
+                       FIELD_SET(0, DE_CONTROL, DIRECTION, LEFT_TO_RIGHT) |
+                       FIELD_SET(0, DE_CONTROL, LAST_PIXEL, OFF) |
+                       FIELD_SET(0, DE_CONTROL, COMMAND, RECTANGLE_FILL) |
+                       FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) |
+                       FIELD_VALUE(0, DE_CONTROL, ROP, 0x0C));
+
+       smtc_de_busy = 1;
+}
+
+/**********************************************************************
+ *
+ * deRotatePattern
+ *
+ * Purpose
+ *    Rotate the given pattern if necessary
+ *
+ * Parameters
+ *    [in]
+ *        pPattern  - Pointer to DE_SURFACE structure containing
+ *                    pattern attributes
+ *        patternX  - X position (0-7) of pattern origin
+ *        patternY  - Y position (0-7) of pattern origin
+ *
+ *    [out]
+ *        pattern_dstaddr - Pointer to pre-allocated buffer containing
+ *        rotated pattern
+ *
+ **********************************************************************/
+void deRotatePattern(unsigned char *pattern_dstaddr,
+                    unsigned long pattern_src_addr,
+                    unsigned long pattern_BPP,
+                    unsigned long pattern_stride, int patternX, int patternY)
+{
+       unsigned int i;
+       unsigned long pattern[PATTERN_WIDTH * PATTERN_HEIGHT];
+       unsigned int x, y;
+       unsigned char *pjPatByte;
+
+       if (pattern_dstaddr != NULL) {
+               deWaitForNotBusy();
+
+               if (patternX || patternY) {
+                       /* Rotate pattern */
+                       pjPatByte = (unsigned char *)pattern;
+
+                       switch (pattern_BPP) {
+                       case 8:
+                               {
+                                       for (y = 0; y < 8; y++) {
+                                               unsigned char *pjBuffer =
+                                                   pattern_dstaddr +
+                                                   ((patternY + y) & 7) * 8;
+                                               for (x = 0; x < 8; x++) {
+                                                       pjBuffer[(patternX +
+                                                                 x) & 7] =
+                                                           pjPatByte[x];
+                                               }
+                                               pjPatByte += pattern_stride;
+                                       }
+                                       break;
+                               }
+
+                       case 16:
+                               {
+                                       for (y = 0; y < 8; y++) {
+                                               unsigned short *pjBuffer =
+                                                   (unsigned short *)
+                                                   pattern_dstaddr +
+                                                   ((patternY + y) & 7) * 8;
+                                               for (x = 0; x < 8; x++) {
+                                                       pjBuffer[(patternX +
+                                                                 x) & 7] =
+                                                           ((unsigned short *)
+                                                            pjPatByte)[x];
+                                               }
+                                               pjPatByte += pattern_stride;
+                                       }
+                                       break;
+                               }
+
+                       case 32:
+                               {
+                                       for (y = 0; y < 8; y++) {
+                                               unsigned long *pjBuffer =
+                                                   (unsigned long *)
+                                                   pattern_dstaddr +
+                                                   ((patternY + y) & 7) * 8;
+                                               for (x = 0; x < 8; x++) {
+                                                       pjBuffer[(patternX +
+                                                                 x) & 7] =
+                                                           ((unsigned long *)
+                                                            pjPatByte)[x];
+                                               }
+                                               pjPatByte += pattern_stride;
+                                       }
+                                       break;
+                               }
+                       }
+               } else {
+                       /*Don't rotate,just copy pattern into pattern_dstaddr*/
+                       for (i = 0; i < (pattern_BPP * 2); i++) {
+                               ((unsigned long *)pattern_dstaddr)[i] =
+                                   pattern[i];
+                       }
+               }
+
+       }
+}
+
+/**********************************************************************
+ *
+ * deCopy
+ *
+ * Purpose
+ *    Copy a rectangular area of the source surface to a destination surface
+ *
+ * Remarks
+ *    Source bitmap must have the same color depth (BPP) as the destination
+ *    bitmap.
+ *
+**********************************************************************/
+void deCopy(unsigned long dst_base,
+           unsigned long dst_pitch,
+           unsigned long dst_BPP,
+           unsigned long dst_X,
+           unsigned long dst_Y,
+           unsigned long dst_width,
+           unsigned long dst_height,
+           unsigned long src_base,
+           unsigned long src_pitch,
+           unsigned long src_X,
+           unsigned long src_Y, pTransparent pTransp, unsigned char nROP2)
+{
+       unsigned long nDirection = 0;
+       unsigned long nTransparent = 0;
+       /* Direction of ROP2 operation:
+        * 1 = Left to Right,
+        * (-1) = Right to Left
+        */
+       unsigned long opSign = 1;
+       /* xWidth is in pixels */
+       unsigned long xWidth = 192 / (dst_BPP / 8);
+       unsigned long de_ctrl = 0;
+
+       deWaitForNotBusy();
+
+       SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE,
+                       FIELD_VALUE(0, DE_WINDOW_DESTINATION_BASE, ADDRESS,
+                                   dst_base));
+
+       SMTC_write2Dreg(DE_WINDOW_SOURCE_BASE,
+                       FIELD_VALUE(0, DE_WINDOW_SOURCE_BASE, ADDRESS,
+                                   src_base));
+
+       if (dst_pitch && src_pitch) {
+               SMTC_write2Dreg(DE_PITCH,
+                       FIELD_VALUE(0, DE_PITCH, DESTINATION,
+                                   dst_pitch) | FIELD_VALUE(0,
+                                                    DE_PITCH,
+                                                    SOURCE,
+                                                    src_pitch));
+
+               SMTC_write2Dreg(DE_WINDOW_WIDTH,
+                       FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION,
+                                   dst_pitch) | FIELD_VALUE(0,
+                                                    DE_WINDOW_WIDTH,
+                                                    SOURCE,
+                                                    src_pitch));
+       }
+
+       /* Set transparent bits if necessary */
+       if (pTransp != NULL) {
+               nTransparent =
+                   pTransp->match | pTransp->select | pTransp->control;
+
+               /* Set color compare register */
+               SMTC_write2Dreg(DE_COLOR_COMPARE,
+                               FIELD_VALUE(0, DE_COLOR_COMPARE, COLOR,
+                                           pTransp->color));
+       }
+
+       /* Determine direction of operation */
+       if (src_Y < dst_Y) {
+               /* +----------+
+                  |S         |
+                  |          +----------+
+                  |          |      |   |
+                  |          |      |   |
+                  +---|------+      |
+                  |               D |
+                  +----------+ */
+
+               nDirection = BOTTOM_TO_TOP;
+       } else if (src_Y > dst_Y) {
+               /* +----------+
+                  |D         |
+                  |          +----------+
+                  |          |      |   |
+                  |          |      |   |
+                  +---|------+      |
+                  |               S |
+                  +----------+ */
+
+               nDirection = TOP_TO_BOTTOM;
+       } else {
+               /* src_Y == dst_Y */
+
+               if (src_X <= dst_X) {
+                       /* +------+---+------+
+                          |S     |   |     D|
+                          |      |   |      |
+                          |      |   |      |
+                          |      |   |      |
+                          +------+---+------+ */
+
+                       nDirection = RIGHT_TO_LEFT;
+               } else {
+                       /* src_X > dst_X */
+
+                       /* +------+---+------+
+                          |D     |   |     S|
+                          |      |   |      |
+                          |      |   |      |
+                          |      |   |      |
+                          +------+---+------+ */
+
+                       nDirection = LEFT_TO_RIGHT;
+               }
+       }
+
+       if ((nDirection == BOTTOM_TO_TOP) || (nDirection == RIGHT_TO_LEFT)) {
+               src_X += dst_width - 1;
+               src_Y += dst_height - 1;
+               dst_X += dst_width - 1;
+               dst_Y += dst_height - 1;
+               opSign = (-1);
+       }
+
+       if (dst_BPP >= 24) {
+               src_X *= 3;
+               src_Y *= 3;
+               dst_X *= 3;
+               dst_Y *= 3;
+               dst_width *= 3;
+               if ((nDirection == BOTTOM_TO_TOP)
+                   || (nDirection == RIGHT_TO_LEFT)) {
+                       src_X += 2;
+                       dst_X += 2;
+               }
+       }
+
+       /* Workaround for 192 byte hw bug */
+       if ((nROP2 != 0x0C) && ((dst_width * (dst_BPP / 8)) >= 192)) {
+               /*
+                * Perform the ROP2 operation in chunks of (xWidth *
+                * dst_height)
+                */
+               while (1) {
+                       deWaitForNotBusy();
+
+                       SMTC_write2Dreg(DE_SOURCE,
+                               FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) |
+                               FIELD_VALUE(0, DE_SOURCE, X_K1, src_X) |
+                               FIELD_VALUE(0, DE_SOURCE, Y_K2, src_Y));
+
+                       SMTC_write2Dreg(DE_DESTINATION,
+                               FIELD_SET(0, DE_DESTINATION, WRAP,
+                                 DISABLE) | FIELD_VALUE(0,
+                                                        DE_DESTINATION,
+                                                        X,
+                                                        dst_X)
+                       | FIELD_VALUE(0, DE_DESTINATION, Y,
+                                                     dst_Y));
+
+                       SMTC_write2Dreg(DE_DIMENSION,
+                               FIELD_VALUE(0, DE_DIMENSION, X,
+                                   xWidth) | FIELD_VALUE(0,
+                                                         DE_DIMENSION,
+                                                         Y_ET,
+                                                         dst_height));
+
+                       de_ctrl =
+                           FIELD_VALUE(0, DE_CONTROL, ROP,
+                               nROP2) | nTransparent | FIELD_SET(0,
+                                                         DE_CONTROL,
+                                                         ROP_SELECT,
+                                                         ROP2)
+                           | FIELD_SET(0, DE_CONTROL, COMMAND,
+                               BITBLT) | ((nDirection ==
+                                           1) ? FIELD_SET(0,
+                                                  DE_CONTROL,
+                                                  DIRECTION,
+                                                  RIGHT_TO_LEFT)
+                                          : FIELD_SET(0, DE_CONTROL,
+                                              DIRECTION,
+                                              LEFT_TO_RIGHT)) |
+                           FIELD_SET(0, DE_CONTROL, STATUS, START);
+
+                       SMTC_write2Dreg(DE_CONTROL, de_ctrl);
+
+                       src_X += (opSign * xWidth);
+                       dst_X += (opSign * xWidth);
+                       dst_width -= xWidth;
+
+                       if (dst_width <= 0) {
+                               /* ROP2 operation is complete */
+                               break;
+                       }
+
+                       if (xWidth > dst_width)
+                               xWidth = dst_width;
+               }
+       } else {
+               deWaitForNotBusy();
+               SMTC_write2Dreg(DE_SOURCE,
+                       FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) |
+                       FIELD_VALUE(0, DE_SOURCE, X_K1, src_X) |
+                       FIELD_VALUE(0, DE_SOURCE, Y_K2, src_Y));
+
+               SMTC_write2Dreg(DE_DESTINATION,
+                       FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) |
+                       FIELD_VALUE(0, DE_DESTINATION, X, dst_X) |
+                       FIELD_VALUE(0, DE_DESTINATION, Y, dst_Y));
+
+               SMTC_write2Dreg(DE_DIMENSION,
+                       FIELD_VALUE(0, DE_DIMENSION, X, dst_width) |
+                       FIELD_VALUE(0, DE_DIMENSION, Y_ET, dst_height));
+
+               de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, nROP2) |
+                   nTransparent |
+                   FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) |
+                   FIELD_SET(0, DE_CONTROL, COMMAND, BITBLT) |
+                   ((nDirection == 1) ? FIELD_SET(0, DE_CONTROL, DIRECTION,
+                                                  RIGHT_TO_LEFT)
+                    : FIELD_SET(0, DE_CONTROL, DIRECTION,
+                                LEFT_TO_RIGHT)) | FIELD_SET(0, DE_CONTROL,
+                                                            STATUS, START);
+               SMTC_write2Dreg(DE_CONTROL, de_ctrl);
+       }
+
+       smtc_de_busy = 1;
+}
+
+/*
+ * This function sets the pixel format that will apply to the 2D Engine.
+ */
+void deSetPixelFormat(unsigned long bpp)
+{
+       unsigned long de_format;
+
+       de_format = SMTC_read2Dreg(DE_STRETCH_FORMAT);
+
+       switch (bpp) {
+       case 8:
+               de_format =
+                   FIELD_SET(de_format, DE_STRETCH_FORMAT, PIXEL_FORMAT, 8);
+               break;
+       default:
+       case 16:
+               de_format =
+                   FIELD_SET(de_format, DE_STRETCH_FORMAT, PIXEL_FORMAT, 16);
+               break;
+       case 32:
+               de_format =
+                   FIELD_SET(de_format, DE_STRETCH_FORMAT, PIXEL_FORMAT, 32);
+               break;
+       }
+
+       SMTC_write2Dreg(DE_STRETCH_FORMAT, de_format);
+}
+
+/*
+ * System memory to Video memory monochrome expansion.
+ *
+ * Source is monochrome image in system memory.  This function expands the
+ * monochrome data to color image in video memory.
+ */
+
+long deSystemMem2VideoMemMonoBlt(const char *pSrcbuf,
+                                long srcDelta,
+                                unsigned long startBit,
+                                unsigned long dBase,
+                                unsigned long dPitch,
+                                unsigned long bpp,
+                                unsigned long dx, unsigned long dy,
+                                unsigned long width, unsigned long height,
+                                unsigned long fColor,
+                                unsigned long bColor,
+                                unsigned long rop2) {
+       unsigned long bytePerPixel;
+       unsigned long ulBytesPerScan;
+       unsigned long ul4BytesPerScan;
+       unsigned long ulBytesRemain;
+       unsigned long de_ctrl = 0;
+       unsigned char ajRemain[4];
+       long i, j;
+
+       bytePerPixel = bpp / 8;
+
+       /* Just make sure the start bit is within legal range */
+       startBit &= 7;
+
+       ulBytesPerScan = (width + startBit + 7) / 8;
+       ul4BytesPerScan = ulBytesPerScan & ~3;
+       ulBytesRemain = ulBytesPerScan & 3;
+
+       if (smtc_de_busy)
+               deWaitForNotBusy();
+
+       /*
+        * 2D Source Base.  Use 0 for HOST Blt.
+        */
+
+       SMTC_write2Dreg(DE_WINDOW_SOURCE_BASE, 0);
+
+       /*
+        * 2D Destination Base.
+        *
+        * It is an address offset (128 bit aligned) from the beginning of
+        * frame buffer.
+        */
+
+       SMTC_write2Dreg(DE_WINDOW_DESTINATION_BASE, dBase);
+
+       if (dPitch) {
+
+               /*
+                * Program pitch (distance between the 1st points of two
+                * adjacent lines).
+                *
+                * Note that input pitch is BYTE value, but the 2D Pitch
+                * register uses pixel values. Need Byte to pixel convertion.
+                */
+
+               SMTC_write2Dreg(DE_PITCH,
+                       FIELD_VALUE(0, DE_PITCH, DESTINATION,
+                           dPitch /
+                           bytePerPixel) | FIELD_VALUE(0,
+                                                       DE_PITCH,
+                                                       SOURCE,
+                                                       dPitch /
+                                                       bytePerPixel));
+
+               /* Screen Window width in Pixels.
+                *
+                * 2D engine uses this value to calculate the linear address in
+                * frame buffer for a given point.
+                */
+
+               SMTC_write2Dreg(DE_WINDOW_WIDTH,
+                       FIELD_VALUE(0, DE_WINDOW_WIDTH, DESTINATION,
+                           (dPitch /
+                            bytePerPixel)) | FIELD_VALUE(0,
+                                                         DE_WINDOW_WIDTH,
+                                                         SOURCE,
+                                                         (dPitch
+                                                          /
+                                                          bytePerPixel)));
+       }
+       /* Note: For 2D Source in Host Write, only X_K1 field is needed, and
+        * Y_K2 field is not used. For mono bitmap, use startBit for X_K1.
+        */
+
+       SMTC_write2Dreg(DE_SOURCE,
+                       FIELD_SET(0, DE_SOURCE, WRAP, DISABLE) |
+                       FIELD_VALUE(0, DE_SOURCE, X_K1, startBit) |
+                       FIELD_VALUE(0, DE_SOURCE, Y_K2, 0));
+
+       SMTC_write2Dreg(DE_DESTINATION,
+                       FIELD_SET(0, DE_DESTINATION, WRAP, DISABLE) |
+                       FIELD_VALUE(0, DE_DESTINATION, X, dx) |
+                       FIELD_VALUE(0, DE_DESTINATION, Y, dy));
+
+       SMTC_write2Dreg(DE_DIMENSION,
+                       FIELD_VALUE(0, DE_DIMENSION, X, width) |
+                       FIELD_VALUE(0, DE_DIMENSION, Y_ET, height));
+
+       SMTC_write2Dreg(DE_FOREGROUND, fColor);
+       SMTC_write2Dreg(DE_BACKGROUND, bColor);
+
+       if (bpp)
+               deSetPixelFormat(bpp);
+       /* Set the pixel format of the destination */
+
+       de_ctrl = FIELD_VALUE(0, DE_CONTROL, ROP, rop2) |
+           FIELD_SET(0, DE_CONTROL, ROP_SELECT, ROP2) |
+           FIELD_SET(0, DE_CONTROL, COMMAND, HOST_WRITE) |
+           FIELD_SET(0, DE_CONTROL, HOST, MONO) |
+           FIELD_SET(0, DE_CONTROL, STATUS, START);
+
+       SMTC_write2Dreg(DE_CONTROL, de_ctrl | deGetTransparency());
+
+       /* Write MONO data (line by line) to 2D Engine data port */
+       for (i = 0; i < height; i++) {
+               /* For each line, send the data in chunks of 4 bytes */
+               for (j = 0; j < (ul4BytesPerScan / 4); j++)
+                       SMTC_write2Ddataport(0,
+                                            *(unsigned long *)(pSrcbuf +
+                                                               (j * 4)));
+
+               if (ulBytesRemain) {
+                       memcpy(ajRemain, pSrcbuf + ul4BytesPerScan,
+                              ulBytesRemain);
+                       SMTC_write2Ddataport(0, *(unsigned long *)ajRemain);
+               }
+
+               pSrcbuf += srcDelta;
+       }
+       smtc_de_busy = 1;
+
+       return 0;
+}
+
+/*
+ * This function gets the transparency status from DE_CONTROL register.
+ * It returns a double word with the transparent fields properly set,
+ * while other fields are 0.
+ */
+unsigned long deGetTransparency(void)
+{
+       unsigned long de_ctrl;
+
+       de_ctrl = SMTC_read2Dreg(DE_CONTROL);
+
+       de_ctrl &=
+           FIELD_MASK(DE_CONTROL_TRANSPARENCY_MATCH) |
+           FIELD_MASK(DE_CONTROL_TRANSPARENCY_SELECT) |
+           FIELD_MASK(DE_CONTROL_TRANSPARENCY);
+
+       return de_ctrl;
+}
diff --git a/drivers/staging/sm7xx/smtc2d.h b/drivers/staging/sm7xx/smtc2d.h
new file mode 100644 (file)
index 0000000..38d0c33
--- /dev/null
@@ -0,0 +1,530 @@
+/*
+ * Silicon Motion SM712 2D drawing engine functions.
+ *
+ * Copyright (C) 2006 Silicon Motion Technology Corp.
+ * Author: Ge Wang, gewang@siliconmotion.com
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License. See the file COPYING in the main directory of this archive for
+ *  more details.
+ */
+
+#ifndef NULL
+#define NULL    0
+#endif
+
+/* Internal macros */
+
+#define _F_START(f)            (0 ? f)
+#define _F_END(f)              (1 ? f)
+#define _F_SIZE(f)             (1 + _F_END(f) - _F_START(f))
+#define _F_MASK(f)             (((1ULL << _F_SIZE(f)) - 1) << _F_START(f))
+#define _F_NORMALIZE(v, f)     (((v) & _F_MASK(f)) >> _F_START(f))
+#define _F_DENORMALIZE(v, f)   (((v) << _F_START(f)) & _F_MASK(f))
+
+/* Global macros */
+
+#define FIELD_GET(x, reg, field) \
+( \
+    _F_NORMALIZE((x), reg ## _ ## field) \
+)
+
+#define FIELD_SET(x, reg, field, value) \
+( \
+    (x & ~_F_MASK(reg ## _ ## field)) \
+    | _F_DENORMALIZE(reg ## _ ## field ## _ ## value, reg ## _ ## field) \
+)
+
+#define FIELD_VALUE(x, reg, field, value) \
+( \
+    (x & ~_F_MASK(reg ## _ ## field)) \
+    | _F_DENORMALIZE(value, reg ## _ ## field) \
+)
+
+#define FIELD_CLEAR(reg, field) \
+( \
+    ~_F_MASK(reg ## _ ## field) \
+)
+
+/* Field Macros                        */
+
+#define FIELD_START(field)     (0 ? field)
+#define FIELD_END(field)       (1 ? field)
+#define FIELD_SIZE(field) \
+       (1 + FIELD_END(field) - FIELD_START(field))
+
+#define FIELD_MASK(field) \
+       (((1 << (FIELD_SIZE(field)-1)) \
+       | ((1 << (FIELD_SIZE(field)-1)) - 1)) \
+       << FIELD_START(field))
+
+#define FIELD_NORMALIZE(reg, field) \
+       (((reg) & FIELD_MASK(field)) >> FIELD_START(field))
+
+#define FIELD_DENORMALIZE(field, value) \
+       (((value) << FIELD_START(field)) & FIELD_MASK(field))
+
+#define FIELD_INIT(reg, field, value) \
+       FIELD_DENORMALIZE(reg ## _ ## field, \
+               reg ## _ ## field ## _ ## value)
+
+#define FIELD_INIT_VAL(reg, field, value) \
+       (FIELD_DENORMALIZE(reg ## _ ## field, value))
+
+#define FIELD_VAL_SET(x, r, f, v) ({ \
+       x = (x & ~FIELD_MASK(r ## _ ## f)) \
+       | FIELD_DENORMALIZE(r ## _ ## f, r ## _ ## f ## _ ## v) \
+})
+
+#define RGB(r, g, b)   ((unsigned long)(((r) << 16) | ((g) << 8) | (b)))
+
+/* Transparent info definition */
+typedef struct {
+       unsigned long match;    /* Matching pixel is OPAQUE/TRANSPARENT */
+       unsigned long select;   /* Transparency controlled by SRC/DST */
+       unsigned long control;  /* ENABLE/DISABLE transparency */
+       unsigned long color;    /* Transparent color */
+} Transparent, *pTransparent;
+
+#define PIXEL_DEPTH_1_BP       0       /* 1 bit per pixel */
+#define PIXEL_DEPTH_8_BPP      1       /* 8 bits per pixel */
+#define PIXEL_DEPTH_16_BPP     2       /* 16 bits per pixel */
+#define PIXEL_DEPTH_32_BPP     3       /* 32 bits per pixel */
+#define PIXEL_DEPTH_YUV422     8       /* 16 bits per pixel YUV422 */
+#define PIXEL_DEPTH_YUV420     9       /* 16 bits per pixel YUV420 */
+
+#define PATTERN_WIDTH          8
+#define PATTERN_HEIGHT         8
+
+#define        TOP_TO_BOTTOM           0
+#define        BOTTOM_TO_TOP           1
+#define RIGHT_TO_LEFT          BOTTOM_TO_TOP
+#define LEFT_TO_RIGHT          TOP_TO_BOTTOM
+
+/* Constants used in Transparent structure */
+#define MATCH_OPAQUE           0x00000000
+#define MATCH_TRANSPARENT      0x00000400
+#define SOURCE                 0x00000000
+#define DESTINATION            0x00000200
+
+/* 2D registers. */
+
+#define        DE_SOURCE                       0x000000
+#define        DE_SOURCE_WRAP                  31 : 31
+#define        DE_SOURCE_WRAP_DISABLE          0
+#define        DE_SOURCE_WRAP_ENABLE           1
+#define        DE_SOURCE_X_K1                  29 : 16
+#define        DE_SOURCE_Y_K2                  15 : 0
+
+#define        DE_DESTINATION                  0x000004
+#define        DE_DESTINATION_WRAP             31 : 31
+#define        DE_DESTINATION_WRAP_DISABLE     0
+#define        DE_DESTINATION_WRAP_ENABLE      1
+#define        DE_DESTINATION_X                28 : 16
+#define        DE_DESTINATION_Y                15 : 0
+
+#define        DE_DIMENSION                    0x000008
+#define        DE_DIMENSION_X                  28 : 16
+#define        DE_DIMENSION_Y_ET               15 : 0
+
+#define        DE_CONTROL                      0x00000C
+#define        DE_CONTROL_STATUS               31 : 31
+#define        DE_CONTROL_STATUS_STOP          0
+#define        DE_CONTROL_STATUS_START         1
+#define        DE_CONTROL_PATTERN              30 : 30
+#define        DE_CONTROL_PATTERN_MONO         0
+#define        DE_CONTROL_PATTERN_COLOR        1
+#define        DE_CONTROL_UPDATE_DESTINATION_X         29 : 29
+#define        DE_CONTROL_UPDATE_DESTINATION_X_DISABLE 0
+#define        DE_CONTROL_UPDATE_DESTINATION_X_ENABLE  1
+#define        DE_CONTROL_QUICK_START                  28 : 28
+#define        DE_CONTROL_QUICK_START_DISABLE          0
+#define        DE_CONTROL_QUICK_START_ENABLE           1
+#define        DE_CONTROL_DIRECTION                    27 : 27
+#define        DE_CONTROL_DIRECTION_LEFT_TO_RIGHT      0
+#define        DE_CONTROL_DIRECTION_RIGHT_TO_LEFT      1
+#define        DE_CONTROL_MAJOR                        26 : 26
+#define        DE_CONTROL_MAJOR_X                      0
+#define        DE_CONTROL_MAJOR_Y                      1
+#define        DE_CONTROL_STEP_X                       25 : 25
+#define        DE_CONTROL_STEP_X_POSITIVE              1
+#define        DE_CONTROL_STEP_X_NEGATIVE              0
+#define        DE_CONTROL_STEP_Y                       24 : 24
+#define        DE_CONTROL_STEP_Y_POSITIVE              1
+#define        DE_CONTROL_STEP_Y_NEGATIVE              0
+#define        DE_CONTROL_STRETCH                      23 : 23
+#define        DE_CONTROL_STRETCH_DISABLE              0
+#define        DE_CONTROL_STRETCH_ENABLE               1
+#define        DE_CONTROL_HOST                         22 : 22
+#define        DE_CONTROL_HOST_COLOR                   0
+#define        DE_CONTROL_HOST_MONO                    1
+#define        DE_CONTROL_LAST_PIXEL                   21 : 21
+#define        DE_CONTROL_LAST_PIXEL_OFF               0
+#define        DE_CONTROL_LAST_PIXEL_ON                1
+#define        DE_CONTROL_COMMAND                      20 : 16
+#define        DE_CONTROL_COMMAND_BITBLT               0
+#define        DE_CONTROL_COMMAND_RECTANGLE_FILL       1
+#define        DE_CONTROL_COMMAND_DE_TILE              2
+#define        DE_CONTROL_COMMAND_TRAPEZOID_FILL       3
+#define        DE_CONTROL_COMMAND_ALPHA_BLEND          4
+#define        DE_CONTROL_COMMAND_RLE_STRIP            5
+#define        DE_CONTROL_COMMAND_SHORT_STROKE         6
+#define        DE_CONTROL_COMMAND_LINE_DRAW            7
+#define        DE_CONTROL_COMMAND_HOST_WRITE           8
+#define        DE_CONTROL_COMMAND_HOST_READ            9
+#define        DE_CONTROL_COMMAND_HOST_WRITE_BOTTOM_UP 10
+#define        DE_CONTROL_COMMAND_ROTATE               11
+#define        DE_CONTROL_COMMAND_FONT                 12
+#define        DE_CONTROL_COMMAND_TEXTURE_LOAD         15
+#define        DE_CONTROL_ROP_SELECT                   15 : 15
+#define        DE_CONTROL_ROP_SELECT_ROP3              0
+#define        DE_CONTROL_ROP_SELECT_ROP2              1
+#define        DE_CONTROL_ROP2_SOURCE                  14 : 14
+#define        DE_CONTROL_ROP2_SOURCE_BITMAP           0
+#define        DE_CONTROL_ROP2_SOURCE_PATTERN          1
+#define        DE_CONTROL_MONO_DATA                    13 : 12
+#define        DE_CONTROL_MONO_DATA_NOT_PACKED         0
+#define        DE_CONTROL_MONO_DATA_8_PACKED           1
+#define        DE_CONTROL_MONO_DATA_16_PACKED          2
+#define        DE_CONTROL_MONO_DATA_32_PACKED          3
+#define        DE_CONTROL_REPEAT_ROTATE                11 : 11
+#define        DE_CONTROL_REPEAT_ROTATE_DISABLE        0
+#define        DE_CONTROL_REPEAT_ROTATE_ENABLE         1
+#define        DE_CONTROL_TRANSPARENCY_MATCH           10 : 10
+#define        DE_CONTROL_TRANSPARENCY_MATCH_OPAQUE            0
+#define        DE_CONTROL_TRANSPARENCY_MATCH_TRANSPARENT       1
+#define        DE_CONTROL_TRANSPARENCY_SELECT                  9 : 9
+#define        DE_CONTROL_TRANSPARENCY_SELECT_SOURCE           0
+#define        DE_CONTROL_TRANSPARENCY_SELECT_DESTINATION      1
+#define        DE_CONTROL_TRANSPARENCY                         8 : 8
+#define        DE_CONTROL_TRANSPARENCY_DISABLE                 0
+#define        DE_CONTROL_TRANSPARENCY_ENABLE                  1
+#define        DE_CONTROL_ROP                                  7 : 0
+
+/* Pseudo fields. */
+
+#define        DE_CONTROL_SHORT_STROKE_DIR                     27 : 24
+#define        DE_CONTROL_SHORT_STROKE_DIR_225                 0
+#define        DE_CONTROL_SHORT_STROKE_DIR_135                 1
+#define        DE_CONTROL_SHORT_STROKE_DIR_315                 2
+#define        DE_CONTROL_SHORT_STROKE_DIR_45                  3
+#define        DE_CONTROL_SHORT_STROKE_DIR_270                 4
+#define        DE_CONTROL_SHORT_STROKE_DIR_90                  5
+#define        DE_CONTROL_SHORT_STROKE_DIR_180                 8
+#define        DE_CONTROL_SHORT_STROKE_DIR_0                   10
+#define        DE_CONTROL_ROTATION                             25 : 24
+#define        DE_CONTROL_ROTATION_0                           0
+#define        DE_CONTROL_ROTATION_270                         1
+#define        DE_CONTROL_ROTATION_90                          2
+#define        DE_CONTROL_ROTATION_180                         3
+
+#define        DE_PITCH                                        0x000010
+#define        DE_PITCH_DESTINATION                            28 : 16
+#define        DE_PITCH_SOURCE                                 12 : 0
+
+#define        DE_FOREGROUND                                   0x000014
+#define        DE_FOREGROUND_COLOR                             31 : 0
+
+#define        DE_BACKGROUND                                   0x000018
+#define        DE_BACKGROUND_COLOR                             31 : 0
+
+#define        DE_STRETCH_FORMAT                               0x00001C
+#define        DE_STRETCH_FORMAT_PATTERN_XY                    30 : 30
+#define        DE_STRETCH_FORMAT_PATTERN_XY_NORMAL             0
+#define        DE_STRETCH_FORMAT_PATTERN_XY_OVERWRITE          1
+#define        DE_STRETCH_FORMAT_PATTERN_Y                     29 : 27
+#define        DE_STRETCH_FORMAT_PATTERN_X                     25 : 23
+#define        DE_STRETCH_FORMAT_PIXEL_FORMAT                  21 : 20
+#define        DE_STRETCH_FORMAT_PIXEL_FORMAT_8                0
+#define        DE_STRETCH_FORMAT_PIXEL_FORMAT_16               1
+#define        DE_STRETCH_FORMAT_PIXEL_FORMAT_24               3
+#define        DE_STRETCH_FORMAT_PIXEL_FORMAT_32               2
+#define        DE_STRETCH_FORMAT_ADDRESSING                    19 : 16
+#define        DE_STRETCH_FORMAT_ADDRESSING_XY                 0
+#define        DE_STRETCH_FORMAT_ADDRESSING_LINEAR             15
+#define        DE_STRETCH_FORMAT_SOURCE_HEIGHT                 11 : 0
+
+#define        DE_COLOR_COMPARE                                0x000020
+#define        DE_COLOR_COMPARE_COLOR                          23 : 0
+
+#define        DE_COLOR_COMPARE_MASK                           0x000024
+#define        DE_COLOR_COMPARE_MASK_MASKS                     23 : 0
+
+#define        DE_MASKS                                        0x000028
+#define        DE_MASKS_BYTE_MASK                              31 : 16
+#define        DE_MASKS_BIT_MASK                               15 : 0
+
+#define        DE_CLIP_TL                                      0x00002C
+#define        DE_CLIP_TL_TOP                                  31 : 16
+#define        DE_CLIP_TL_STATUS                               13 : 13
+#define        DE_CLIP_TL_STATUS_DISABLE                       0
+#define        DE_CLIP_TL_STATUS_ENABLE                        1
+#define        DE_CLIP_TL_INHIBIT                              12 : 12
+#define        DE_CLIP_TL_INHIBIT_OUTSIDE                      0
+#define        DE_CLIP_TL_INHIBIT_INSIDE                       1
+#define        DE_CLIP_TL_LEFT                                 11 : 0
+
+#define        DE_CLIP_BR                                      0x000030
+#define        DE_CLIP_BR_BOTTOM                               31 : 16
+#define        DE_CLIP_BR_RIGHT                                12 : 0
+
+#define        DE_MONO_PATTERN_LOW                             0x000034
+#define        DE_MONO_PATTERN_LOW_PATTERN                     31 : 0
+
+#define        DE_MONO_PATTERN_HIGH                            0x000038
+#define        DE_MONO_PATTERN_HIGH_PATTERN                    31 : 0
+
+#define        DE_WINDOW_WIDTH                                 0x00003C
+#define        DE_WINDOW_WIDTH_DESTINATION                     28 : 16
+#define        DE_WINDOW_WIDTH_SOURCE                          12 : 0
+
+#define        DE_WINDOW_SOURCE_BASE                           0x000040
+#define        DE_WINDOW_SOURCE_BASE_EXT                       27 : 27
+#define        DE_WINDOW_SOURCE_BASE_EXT_LOCAL                 0
+#define        DE_WINDOW_SOURCE_BASE_EXT_EXTERNAL              1
+#define        DE_WINDOW_SOURCE_BASE_CS                        26 : 26
+#define        DE_WINDOW_SOURCE_BASE_CS_0                      0
+#define        DE_WINDOW_SOURCE_BASE_CS_1                      1
+#define        DE_WINDOW_SOURCE_BASE_ADDRESS                   25 : 0
+
+#define        DE_WINDOW_DESTINATION_BASE                      0x000044
+#define        DE_WINDOW_DESTINATION_BASE_EXT                  27 : 27
+#define        DE_WINDOW_DESTINATION_BASE_EXT_LOCAL            0
+#define        DE_WINDOW_DESTINATION_BASE_EXT_EXTERNAL         1
+#define        DE_WINDOW_DESTINATION_BASE_CS                   26 : 26
+#define        DE_WINDOW_DESTINATION_BASE_CS_0                 0
+#define        DE_WINDOW_DESTINATION_BASE_CS_1                 1
+#define        DE_WINDOW_DESTINATION_BASE_ADDRESS              25 : 0
+
+#define        DE_ALPHA                                        0x000048
+#define        DE_ALPHA_VALUE                                  7 : 0
+
+#define        DE_WRAP                                         0x00004C
+#define        DE_WRAP_X                                       31 : 16
+#define        DE_WRAP_Y                                       15 : 0
+
+#define        DE_STATUS                                       0x000050
+#define        DE_STATUS_CSC                                   1 : 1
+#define        DE_STATUS_CSC_CLEAR                             0
+#define        DE_STATUS_CSC_NOT_ACTIVE                        0
+#define        DE_STATUS_CSC_ACTIVE                            1
+#define        DE_STATUS_2D                                    0 : 0
+#define        DE_STATUS_2D_CLEAR                              0
+#define        DE_STATUS_2D_NOT_ACTIVE                         0
+#define        DE_STATUS_2D_ACTIVE                             1
+
+/* Color Space Conversion registers. */
+
+#define        CSC_Y_SOURCE_BASE                               0x0000C8
+#define        CSC_Y_SOURCE_BASE_EXT                           27 : 27
+#define        CSC_Y_SOURCE_BASE_EXT_LOCAL                     0
+#define        CSC_Y_SOURCE_BASE_EXT_EXTERNAL                  1
+#define        CSC_Y_SOURCE_BASE_CS                            26 : 26
+#define        CSC_Y_SOURCE_BASE_CS_0                          0
+#define        CSC_Y_SOURCE_BASE_CS_1                          1
+#define        CSC_Y_SOURCE_BASE_ADDRESS                       25 : 0
+
+#define        CSC_CONSTANTS                                   0x0000CC
+#define        CSC_CONSTANTS_Y                                 31 : 24
+#define        CSC_CONSTANTS_R                                 23 : 16
+#define        CSC_CONSTANTS_G                                 15 : 8
+#define        CSC_CONSTANTS_B                                 7 : 0
+
+#define        CSC_Y_SOURCE_X                                  0x0000D0
+#define        CSC_Y_SOURCE_X_INTEGER                          26 : 16
+#define        CSC_Y_SOURCE_X_FRACTION                         15 : 3
+
+#define        CSC_Y_SOURCE_Y                                  0x0000D4
+#define        CSC_Y_SOURCE_Y_INTEGER                          27 : 16
+#define        CSC_Y_SOURCE_Y_FRACTION                         15 : 3
+
+#define        CSC_U_SOURCE_BASE                               0x0000D8
+#define        CSC_U_SOURCE_BASE_EXT                           27 : 27
+#define        CSC_U_SOURCE_BASE_EXT_LOCAL                     0
+#define        CSC_U_SOURCE_BASE_EXT_EXTERNAL                  1
+#define        CSC_U_SOURCE_BASE_CS                            26 : 26
+#define        CSC_U_SOURCE_BASE_CS_0                          0
+#define        CSC_U_SOURCE_BASE_CS_1                          1
+#define        CSC_U_SOURCE_BASE_ADDRESS                       25 : 0
+
+#define        CSC_V_SOURCE_BASE                               0x0000DC
+#define        CSC_V_SOURCE_BASE_EXT                           27 : 27
+#define        CSC_V_SOURCE_BASE_EXT_LOCAL                     0
+#define        CSC_V_SOURCE_BASE_EXT_EXTERNAL                  1
+#define        CSC_V_SOURCE_BASE_CS                            26 : 26
+#define        CSC_V_SOURCE_BASE_CS_0                          0
+#define        CSC_V_SOURCE_BASE_CS_1                          1
+#define        CSC_V_SOURCE_BASE_ADDRESS                       25 : 0
+
+#define        CSC_SOURCE_DIMENSION                            0x0000E0
+#define        CSC_SOURCE_DIMENSION_X                          31 : 16
+#define        CSC_SOURCE_DIMENSION_Y                          15 : 0
+
+#define        CSC_SOURCE_PITCH                                0x0000E4
+#define        CSC_SOURCE_PITCH_Y                              31 : 16
+#define        CSC_SOURCE_PITCH_UV                             15 : 0
+
+#define        CSC_DESTINATION                                 0x0000E8
+#define        CSC_DESTINATION_WRAP                            31 : 31
+#define        CSC_DESTINATION_WRAP_DISABLE                    0
+#define        CSC_DESTINATION_WRAP_ENABLE                     1
+#define        CSC_DESTINATION_X                               27 : 16
+#define        CSC_DESTINATION_Y                               11 : 0
+
+#define        CSC_DESTINATION_DIMENSION                       0x0000EC
+#define        CSC_DESTINATION_DIMENSION_X                     31 : 16
+#define        CSC_DESTINATION_DIMENSION_Y                     15 : 0
+
+#define        CSC_DESTINATION_PITCH                           0x0000F0
+#define        CSC_DESTINATION_PITCH_X                         31 : 16
+#define        CSC_DESTINATION_PITCH_Y                         15 : 0
+
+#define        CSC_SCALE_FACTOR                                0x0000F4
+#define        CSC_SCALE_FACTOR_HORIZONTAL                     31 : 16
+#define        CSC_SCALE_FACTOR_VERTICAL                       15 : 0
+
+#define        CSC_DESTINATION_BASE                            0x0000F8
+#define        CSC_DESTINATION_BASE_EXT                        27 : 27
+#define        CSC_DESTINATION_BASE_EXT_LOCAL                  0
+#define        CSC_DESTINATION_BASE_EXT_EXTERNAL               1
+#define        CSC_DESTINATION_BASE_CS                         26 : 26
+#define        CSC_DESTINATION_BASE_CS_0                       0
+#define        CSC_DESTINATION_BASE_CS_1                       1
+#define        CSC_DESTINATION_BASE_ADDRESS                    25 : 0
+
+#define        CSC_CONTROL                                     0x0000FC
+#define        CSC_CONTROL_STATUS                              31 : 31
+#define        CSC_CONTROL_STATUS_STOP                         0
+#define        CSC_CONTROL_STATUS_START                        1
+#define        CSC_CONTROL_SOURCE_FORMAT                       30 : 28
+#define        CSC_CONTROL_SOURCE_FORMAT_YUV422                0
+#define        CSC_CONTROL_SOURCE_FORMAT_YUV420I               1
+#define        CSC_CONTROL_SOURCE_FORMAT_YUV420                2
+#define        CSC_CONTROL_SOURCE_FORMAT_YVU9                  3
+#define        CSC_CONTROL_SOURCE_FORMAT_IYU1                  4
+#define        CSC_CONTROL_SOURCE_FORMAT_IYU2                  5
+#define        CSC_CONTROL_SOURCE_FORMAT_RGB565                6
+#define        CSC_CONTROL_SOURCE_FORMAT_RGB8888               7
+#define        CSC_CONTROL_DESTINATION_FORMAT                  27 : 26
+#define        CSC_CONTROL_DESTINATION_FORMAT_RGB565           0
+#define        CSC_CONTROL_DESTINATION_FORMAT_RGB8888          1
+#define        CSC_CONTROL_HORIZONTAL_FILTER                   25 : 25
+#define        CSC_CONTROL_HORIZONTAL_FILTER_DISABLE           0
+#define        CSC_CONTROL_HORIZONTAL_FILTER_ENABLE            1
+#define        CSC_CONTROL_VERTICAL_FILTER                     24 : 24
+#define        CSC_CONTROL_VERTICAL_FILTER_DISABLE             0
+#define        CSC_CONTROL_VERTICAL_FILTER_ENABLE              1
+#define        CSC_CONTROL_BYTE_ORDER                          23 : 23
+#define        CSC_CONTROL_BYTE_ORDER_YUYV                     0
+#define        CSC_CONTROL_BYTE_ORDER_UYVY                     1
+
+#define        DE_DATA_PORT_501                                0x110000
+#define        DE_DATA_PORT_712                                0x400000
+#define        DE_DATA_PORT_722                                0x6000
+
+/* point to virtual Memory Map IO starting address */
+extern char *smtc_RegBaseAddress;
+/* point to virtual video memory starting address */
+extern char *smtc_VRAMBaseAddress;
+extern unsigned char smtc_de_busy;
+
+extern unsigned long memRead32(unsigned long nOffset);
+extern void memWrite32(unsigned long nOffset, unsigned long nData);
+extern unsigned long SMTC_read2Dreg(unsigned long nOffset);
+
+/* 2D functions */
+extern void deInit(unsigned int nModeWidth, unsigned int nModeHeight,
+                  unsigned int bpp);
+
+extern void deWaitForNotBusy(void);
+
+extern void deVerticalLine(unsigned long dst_base,
+       unsigned long dst_pitch,
+       unsigned long nX,
+       unsigned long nY,
+       unsigned long dst_height,
+       unsigned long nColor);
+
+extern void deHorizontalLine(unsigned long dst_base,
+       unsigned long dst_pitch,
+       unsigned long nX,
+       unsigned long nY,
+       unsigned long dst_width,
+       unsigned long nColor);
+
+extern void deLine(unsigned long dst_base,
+       unsigned long dst_pitch,
+       unsigned long nX1,
+       unsigned long nY1,
+       unsigned long nX2,
+       unsigned long nY2,
+       unsigned long nColor);
+
+extern void deFillRect(unsigned long dst_base,
+       unsigned long dst_pitch,
+       unsigned long dst_X,
+       unsigned long dst_Y,
+       unsigned long dst_width,
+       unsigned long dst_height,
+       unsigned long nColor);
+
+extern void deRotatePattern(unsigned char *pattern_dstaddr,
+       unsigned long pattern_src_addr,
+       unsigned long pattern_BPP,
+       unsigned long pattern_stride,
+       int     patternX,
+       int     patternY);
+
+extern void deCopy(unsigned long dst_base,
+       unsigned long dst_pitch,
+       unsigned long dst_BPP,
+       unsigned long dst_X,
+       unsigned long dst_Y,
+       unsigned long dst_width,
+       unsigned long dst_height,
+       unsigned long src_base,
+       unsigned long src_pitch,
+       unsigned long src_X,
+       unsigned long src_Y,
+       pTransparent    pTransp,
+       unsigned char nROP2);
+
+/*
+ * System memory to Video memory monochrome expansion.
+ *
+ * Source is monochrome image in system memory.  This function expands the
+ * monochrome data to color image in video memory.
+ *
+ * @pSrcbuf: pointer to start of source buffer in system memory
+ * @srcDelta: Pitch value (in bytes) of the source buffer, +ive means top
+ *             down and -ive mean button up
+ * @startBit: Mono data can start at any bit in a byte, this value should
+ *             be 0 to 7
+ * @dBase: Address of destination :  offset in frame buffer
+ * @dPitch: Pitch value of destination surface in BYTE
+ * @bpp: Color depth of destination surface
+ * @dx, dy: Starting coordinate of destination surface
+ * @width, height: width and height of rectange in pixel value
+ * @fColor,bColor: Foreground, Background color (corresponding to a 1, 0 in
+ *     the monochrome data)
+ * @rop2: ROP value
+ */
+
+extern long deSystemMem2VideoMemMonoBlt(
+       const char *pSrcbuf,
+       long srcDelta,
+       unsigned long startBit,
+       unsigned long dBase,
+       unsigned long dPitch,
+       unsigned long bpp,
+       unsigned long dx, unsigned long dy,
+       unsigned long width, unsigned long height,
+       unsigned long fColor,
+       unsigned long bColor,
+       unsigned long rop2);
+
+extern unsigned long deGetTransparency(void);
+extern void deSetPixelFormat(unsigned long bpp);
diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c
new file mode 100644 (file)
index 0000000..161dbc9
--- /dev/null
@@ -0,0 +1,1253 @@
+/*
+ * Silicon Motion SM7XX frame buffer device
+ *
+ * Copyright (C) 2006 Silicon Motion Technology Corp.
+ * Authors: Ge Wang, gewang@siliconmotion.com
+ *         Boyod boyod.yang@siliconmotion.com.cn
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License. See the file COPYING in the main directory of this archive for
+ *  more details.
+ *
+ * Version 0.10.26192.21.01
+ *     - Add PowerPC/Big endian support
+ *     - Add 2D support for Lynx
+ *     - Verified on2.6.19.2  Boyod.yang <boyod.yang@siliconmotion.com.cn>
+ *
+ * Version 0.09.2621.00.01
+ *     - Only support Linux Kernel's version 2.6.21.
+ *     Boyod.yang  <boyod.yang@siliconmotion.com.cn>
+ *
+ * Version 0.09
+ *     - Only support Linux Kernel's version 2.6.12.
+ *     Boyod.yang <boyod.yang@siliconmotion.com.cn>
+ */
+
+#ifndef __KERNEL__
+#define __KERNEL__
+#endif
+
+#include <linux/io.h>
+#include <linux/fb.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/uaccess.h>
+#include <linux/console.h>
+#include <linux/screen_info.h>
+
+#ifdef CONFIG_PM
+#include <linux/pm.h>
+#endif
+
+struct screen_info smtc_screen_info;
+
+#include "smtcfb.h"
+#include "smtc2d.h"
+
+#ifdef DEBUG
+#define smdbg(format, arg...)  printk(KERN_DEBUG format , ## arg)
+#else
+#define smdbg(format, arg...)
+#endif
+
+/*
+* Private structure
+*/
+struct smtcfb_info {
+       /*
+        * The following is a pointer to be passed into the
+        * functions below.  The modules outside the main
+        * voyager.c driver have no knowledge as to what
+        * is within this structure.
+        */
+       struct fb_info fb;
+       struct display_switch *dispsw;
+       struct pci_dev *dev;
+       signed int currcon;
+
+       struct {
+               u8 red, green, blue;
+       } palette[NR_RGB];
+
+       u_int palette_size;
+};
+
+struct par_info {
+       /*
+        * Hardware
+        */
+       u16 chipID;
+       unsigned char __iomem *m_pMMIO;
+       char __iomem *m_pLFB;
+       char *m_pDPR;
+       char *m_pVPR;
+       char *m_pCPR;
+
+       u_int width;
+       u_int height;
+       u_int hz;
+       u_long BaseAddressInVRAM;
+       u8 chipRevID;
+};
+
+struct vesa_mode_table {
+       char mode_index[6];
+       u16 lfb_width;
+       u16 lfb_height;
+       u16 lfb_depth;
+};
+
+static struct vesa_mode_table vesa_mode[] = {
+       {"0x301", 640,  480,  8},
+       {"0x303", 800,  600,  8},
+       {"0x305", 1024, 768,    8},
+       {"0x307", 1280, 1024, 8},
+
+       {"0x311", 640,  480,  16},
+       {"0x314", 800,  600,  16},
+       {"0x317", 1024, 768,    16},
+       {"0x31A", 1280, 1024, 16},
+
+       {"0x312", 640,  480,  24},
+       {"0x315", 800,  600,  24},
+       {"0x318", 1024, 768,    24},
+       {"0x31B", 1280, 1024, 24},
+};
+
+char __iomem *smtc_RegBaseAddress;     /* Memory Map IO starting address */
+char __iomem *smtc_VRAMBaseAddress;    /* video memory starting address */
+
+char *smtc_2DBaseAddress;      /* 2D engine starting address */
+char *smtc_2Ddataport;         /* 2D data port offset */
+short smtc_2Dacceleration;
+
+static u32 colreg[17];
+static struct par_info hw;     /* hardware information */
+
+u16 smtc_ChipIDs[] = {
+       0x710,
+       0x712,
+       0x720
+};
+
+#define numSMTCchipIDs (sizeof(smtc_ChipIDs) / sizeof(u16))
+
+void deWaitForNotBusy(void)
+{
+       unsigned long i = 0x1000000;
+       while (i--) {
+               if ((smtc_seqr(0x16) & 0x18) == 0x10)
+                       break;
+       }
+       smtc_de_busy = 0;
+}
+
+static void sm712_set_timing(struct smtcfb_info *sfb,
+                            struct par_info *ppar_info)
+{
+       int i = 0, j = 0;
+       u32 m_nScreenStride;
+
+       smdbg("\nppar_info->width = %d ppar_info->height = %d"
+                       "sfb->fb.var.bits_per_pixel = %d ppar_info->hz = %d\n",
+                       ppar_info->width, ppar_info->height,
+                       sfb->fb.var.bits_per_pixel, ppar_info->hz);
+
+       for (j = 0; j < numVGAModes; j++) {
+               if (VGAMode[j].mmSizeX == ppar_info->width &&
+                   VGAMode[j].mmSizeY == ppar_info->height &&
+                   VGAMode[j].bpp == sfb->fb.var.bits_per_pixel &&
+                   VGAMode[j].hz == ppar_info->hz) {
+
+                       smdbg("\nVGAMode[j].mmSizeX  = %d VGAMode[j].mmSizeY ="
+                                       "%d VGAMode[j].bpp = %d"
+                                       "VGAMode[j].hz=%d\n",
+                                       VGAMode[j].mmSizeX, VGAMode[j].mmSizeY,
+                                       VGAMode[j].bpp, VGAMode[j].hz);
+
+                       smdbg("VGAMode index=%d\n", j);
+
+                       smtc_mmiowb(0x0, 0x3c6);
+
+                       smtc_seqw(0, 0x1);
+
+                       smtc_mmiowb(VGAMode[j].Init_MISC, 0x3c2);
+
+                       /* init SEQ register SR00 - SR04 */
+                       for (i = 0; i < SIZE_SR00_SR04; i++)
+                               smtc_seqw(i, VGAMode[j].Init_SR00_SR04[i]);
+
+                       /* init SEQ register SR10 - SR24 */
+                       for (i = 0; i < SIZE_SR10_SR24; i++)
+                               smtc_seqw(i + 0x10,
+                                         VGAMode[j].Init_SR10_SR24[i]);
+
+                       /* init SEQ register SR30 - SR75 */
+                       for (i = 0; i < SIZE_SR30_SR75; i++)
+                               if (((i + 0x30) != 0x62) \
+                                       && ((i + 0x30) != 0x6a) \
+                                       && ((i + 0x30) != 0x6b))
+                                       smtc_seqw(i + 0x30,
+                                               VGAMode[j].Init_SR30_SR75[i]);
+
+                       /* init SEQ register SR80 - SR93 */
+                       for (i = 0; i < SIZE_SR80_SR93; i++)
+                               smtc_seqw(i + 0x80,
+                                         VGAMode[j].Init_SR80_SR93[i]);
+
+                       /* init SEQ register SRA0 - SRAF */
+                       for (i = 0; i < SIZE_SRA0_SRAF; i++)
+                               smtc_seqw(i + 0xa0,
+                                         VGAMode[j].Init_SRA0_SRAF[i]);
+
+                       /* init Graphic register GR00 - GR08 */
+                       for (i = 0; i < SIZE_GR00_GR08; i++)
+                               smtc_grphw(i, VGAMode[j].Init_GR00_GR08[i]);
+
+                       /* init Attribute register AR00 - AR14 */
+                       for (i = 0; i < SIZE_AR00_AR14; i++)
+                               smtc_attrw(i, VGAMode[j].Init_AR00_AR14[i]);
+
+                       /* init CRTC register CR00 - CR18 */
+                       for (i = 0; i < SIZE_CR00_CR18; i++)
+                               smtc_crtcw(i, VGAMode[j].Init_CR00_CR18[i]);
+
+                       /* init CRTC register CR30 - CR4D */
+                       for (i = 0; i < SIZE_CR30_CR4D; i++)
+                               smtc_crtcw(i + 0x30,
+                                          VGAMode[j].Init_CR30_CR4D[i]);
+
+                       /* init CRTC register CR90 - CRA7 */
+                       for (i = 0; i < SIZE_CR90_CRA7; i++)
+                               smtc_crtcw(i + 0x90,
+                                          VGAMode[j].Init_CR90_CRA7[i]);
+               }
+       }
+       smtc_mmiowb(0x67, 0x3c2);
+
+       /* set VPR registers */
+       writel(0x0, ppar_info->m_pVPR + 0x0C);
+       writel(0x0, ppar_info->m_pVPR + 0x40);
+
+       /* set data width */
+       m_nScreenStride =
+               (ppar_info->width * sfb->fb.var.bits_per_pixel) / 64;
+       switch (sfb->fb.var.bits_per_pixel) {
+       case 8:
+               writel(0x0, ppar_info->m_pVPR + 0x0);
+               break;
+       case 16:
+               writel(0x00020000, ppar_info->m_pVPR + 0x0);
+               break;
+       case 24:
+               writel(0x00040000, ppar_info->m_pVPR + 0x0);
+               break;
+       case 32:
+               writel(0x00030000, ppar_info->m_pVPR + 0x0);
+               break;
+       }
+       writel((u32) (((m_nScreenStride + 2) << 16) | m_nScreenStride),
+              ppar_info->m_pVPR + 0x10);
+
+}
+
+static void sm712_setpalette(int regno, unsigned red, unsigned green,
+                            unsigned blue, struct fb_info *info)
+{
+       struct par_info *cur_par = (struct par_info *)info->par;
+
+       if (cur_par->BaseAddressInVRAM)
+               /*
+                * second display palette for dual head. Enable CRT RAM, 6-bit
+                * RAM
+                */
+               smtc_seqw(0x66, (smtc_seqr(0x66) & 0xC3) | 0x20);
+       else
+               /* primary display palette. Enable LCD RAM only, 6-bit RAM */
+               smtc_seqw(0x66, (smtc_seqr(0x66) & 0xC3) | 0x10);
+       smtc_mmiowb(regno, dac_reg);
+       smtc_mmiowb(red >> 10, dac_val);
+       smtc_mmiowb(green >> 10, dac_val);
+       smtc_mmiowb(blue >> 10, dac_val);
+}
+
+static void smtc_set_timing(struct smtcfb_info *sfb, struct par_info
+               *ppar_info)
+{
+       switch (ppar_info->chipID) {
+       case 0x710:
+       case 0x712:
+       case 0x720:
+               sm712_set_timing(sfb, ppar_info);
+               break;
+       }
+}
+
+static struct fb_var_screeninfo smtcfb_var = {
+       .xres = 1024,
+       .yres = 600,
+       .xres_virtual = 1024,
+       .yres_virtual = 600,
+       .bits_per_pixel = 16,
+       .red = {16, 8, 0},
+       .green = {8, 8, 0},
+       .blue = {0, 8, 0},
+       .activate = FB_ACTIVATE_NOW,
+       .height = -1,
+       .width = -1,
+       .vmode = FB_VMODE_NONINTERLACED,
+};
+
+static struct fb_fix_screeninfo smtcfb_fix = {
+       .id = "sm712fb",
+       .type = FB_TYPE_PACKED_PIXELS,
+       .visual = FB_VISUAL_TRUECOLOR,
+       .line_length = 800 * 3,
+       .accel = FB_ACCEL_SMI_LYNX,
+};
+
+/* chan_to_field
+ *
+ * convert a colour value into a field position
+ *
+ * from pxafb.c
+ */
+
+static inline unsigned int chan_to_field(unsigned int chan,
+                                        struct fb_bitfield *bf)
+{
+       chan &= 0xffff;
+       chan >>= 16 - bf->length;
+       return chan << bf->offset;
+}
+
+static int smtcfb_blank(int blank_mode, struct fb_info *info)
+{
+       /* clear DPMS setting */
+       switch (blank_mode) {
+       case FB_BLANK_UNBLANK:
+               /* Screen On: HSync: On, VSync : On */
+               smtc_seqw(0x01, (smtc_seqr(0x01) & (~0x20)));
+               smtc_seqw(0x6a, 0x16);
+               smtc_seqw(0x6b, 0x02);
+               smtc_seqw(0x21, (smtc_seqr(0x21) & 0x77));
+               smtc_seqw(0x22, (smtc_seqr(0x22) & (~0x30)));
+               smtc_seqw(0x23, (smtc_seqr(0x23) & (~0xc0)));
+               smtc_seqw(0x24, (smtc_seqr(0x24) | 0x01));
+               smtc_seqw(0x31, (smtc_seqr(0x31) | 0x03));
+               break;
+       case FB_BLANK_NORMAL:
+               /* Screen Off: HSync: On, VSync : On   Soft blank */
+               smtc_seqw(0x01, (smtc_seqr(0x01) & (~0x20)));
+               smtc_seqw(0x6a, 0x16);
+               smtc_seqw(0x6b, 0x02);
+               smtc_seqw(0x22, (smtc_seqr(0x22) & (~0x30)));
+               smtc_seqw(0x23, (smtc_seqr(0x23) & (~0xc0)));
+               smtc_seqw(0x24, (smtc_seqr(0x24) | 0x01));
+               smtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));
+               break;
+       case FB_BLANK_VSYNC_SUSPEND:
+               /* Screen On: HSync: On, VSync : Off */
+               smtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));
+               smtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));
+               smtc_seqw(0x6a, 0x0c);
+               smtc_seqw(0x6b, 0x02);
+               smtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));
+               smtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x20));
+               smtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0x20));
+               smtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));
+               smtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));
+               smtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));
+               break;
+       case FB_BLANK_HSYNC_SUSPEND:
+               /* Screen On: HSync: Off, VSync : On */
+               smtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));
+               smtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));
+               smtc_seqw(0x6a, 0x0c);
+               smtc_seqw(0x6b, 0x02);
+               smtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));
+               smtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x10));
+               smtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0xD8));
+               smtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));
+               smtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));
+               smtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));
+               break;
+       case FB_BLANK_POWERDOWN:
+               /* Screen On: HSync: Off, VSync : Off */
+               smtc_seqw(0x01, (smtc_seqr(0x01) | 0x20));
+               smtc_seqw(0x20, (smtc_seqr(0x20) & (~0xB0)));
+               smtc_seqw(0x6a, 0x0c);
+               smtc_seqw(0x6b, 0x02);
+               smtc_seqw(0x21, (smtc_seqr(0x21) | 0x88));
+               smtc_seqw(0x22, ((smtc_seqr(0x22) & (~0x30)) | 0x30));
+               smtc_seqw(0x23, ((smtc_seqr(0x23) & (~0xc0)) | 0xD8));
+               smtc_seqw(0x24, (smtc_seqr(0x24) & (~0x01)));
+               smtc_seqw(0x31, ((smtc_seqr(0x31) & (~0x07)) | 0x00));
+               smtc_seqw(0x34, (smtc_seqr(0x34) | 0x80));
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green,
+                         unsigned blue, unsigned trans, struct fb_info *info)
+{
+       struct smtcfb_info *sfb = (struct smtcfb_info *)info;
+       u32 val;
+
+       if (regno > 255)
+               return 1;
+
+       switch (sfb->fb.fix.visual) {
+       case FB_VISUAL_DIRECTCOLOR:
+       case FB_VISUAL_TRUECOLOR:
+               /*
+                * 16/32 bit true-colour, use pseuo-palette for 16 base color
+                */
+               if (regno < 16) {
+                       if (sfb->fb.var.bits_per_pixel == 16) {
+                               u32 *pal = sfb->fb.pseudo_palette;
+                               val = chan_to_field(red, &sfb->fb.var.red);
+                               val |= chan_to_field(green, \
+                                               &sfb->fb.var.green);
+                               val |= chan_to_field(blue, &sfb->fb.var.blue);
+#ifdef __BIG_ENDIAN
+                               pal[regno] =
+                                   ((red & 0xf800) >> 8) |
+                                   ((green & 0xe000) >> 13) |
+                                   ((green & 0x1c00) << 3) |
+                                   ((blue & 0xf800) >> 3);
+#else
+                               pal[regno] = val;
+#endif
+                       } else {
+                               u32 *pal = sfb->fb.pseudo_palette;
+                               val = chan_to_field(red, &sfb->fb.var.red);
+                               val |= chan_to_field(green, \
+                                               &sfb->fb.var.green);
+                               val |= chan_to_field(blue, &sfb->fb.var.blue);
+#ifdef __BIG_ENDIAN
+                               val =
+                                   (val & 0xff00ff00 >> 8) |
+                                   (val & 0x00ff00ff << 8);
+#endif
+                               pal[regno] = val;
+                       }
+               }
+               break;
+
+       case FB_VISUAL_PSEUDOCOLOR:
+               /* color depth 8 bit */
+               sm712_setpalette(regno, red, green, blue, info);
+               break;
+
+       default:
+               return 1;       /* unknown type */
+       }
+
+       return 0;
+
+}
+
+#ifdef __BIG_ENDIAN
+static ssize_t smtcfb_read(struct fb_info *info, char __user * buf, size_t
+                               count, loff_t *ppos)
+{
+       unsigned long p = *ppos;
+
+       u32 *buffer, *dst;
+       u32 __iomem *src;
+       int c, i, cnt = 0, err = 0;
+       unsigned long total_size;
+
+       if (!info || !info->screen_base)
+               return -ENODEV;
+
+       if (info->state != FBINFO_STATE_RUNNING)
+               return -EPERM;
+
+       total_size = info->screen_size;
+
+       if (total_size == 0)
+               total_size = info->fix.smem_len;
+
+       if (p >= total_size)
+               return 0;
+
+       if (count >= total_size)
+               count = total_size;
+
+       if (count + p > total_size)
+               count = total_size - p;
+
+       buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL);
+       if (!buffer)
+               return -ENOMEM;
+
+       src = (u32 __iomem *) (info->screen_base + p);
+
+       if (info->fbops->fb_sync)
+               info->fbops->fb_sync(info);
+
+       while (count) {
+               c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
+               dst = buffer;
+               for (i = c >> 2; i--;) {
+                       *dst = fb_readl(src++);
+                       *dst =
+                           (*dst & 0xff00ff00 >> 8) |
+                           (*dst & 0x00ff00ff << 8);
+                       dst++;
+               }
+               if (c & 3) {
+                       u8 *dst8 = (u8 *) dst;
+                       u8 __iomem *src8 = (u8 __iomem *) src;
+
+                       for (i = c & 3; i--;) {
+                               if (i & 1) {
+                                       *dst8++ = fb_readb(++src8);
+                               } else {
+                                       *dst8++ = fb_readb(--src8);
+                                       src8 += 2;
+                               }
+                       }
+                       src = (u32 __iomem *) src8;
+               }
+
+               if (copy_to_user(buf, buffer, c)) {
+                       err = -EFAULT;
+                       break;
+               }
+               *ppos += c;
+               buf += c;
+               cnt += c;
+               count -= c;
+       }
+
+       kfree(buffer);
+
+       return (err) ? err : cnt;
+}
+
+static ssize_t
+smtcfb_write(struct fb_info *info, const char __user *buf, size_t count,
+            loff_t *ppos)
+{
+       unsigned long p = *ppos;
+
+       u32 *buffer, *src;
+       u32 __iomem *dst;
+       int c, i, cnt = 0, err = 0;
+       unsigned long total_size;
+
+       if (!info || !info->screen_base)
+               return -ENODEV;
+
+       if (info->state != FBINFO_STATE_RUNNING)
+               return -EPERM;
+
+       total_size = info->screen_size;
+
+       if (total_size == 0)
+               total_size = info->fix.smem_len;
+
+       if (p > total_size)
+               return -EFBIG;
+
+       if (count > total_size) {
+               err = -EFBIG;
+               count = total_size;
+       }
+
+       if (count + p > total_size) {
+               if (!err)
+                       err = -ENOSPC;
+
+               count = total_size - p;
+       }
+
+       buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL);
+       if (!buffer)
+               return -ENOMEM;
+
+       dst = (u32 __iomem *) (info->screen_base + p);
+
+       if (info->fbops->fb_sync)
+               info->fbops->fb_sync(info);
+
+       while (count) {
+               c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
+               src = buffer;
+
+               if (copy_from_user(src, buf, c)) {
+                       err = -EFAULT;
+                       break;
+               }
+
+               for (i = c >> 2; i--;) {
+                       fb_writel((*src & 0xff00ff00 >> 8) |
+                                 (*src & 0x00ff00ff << 8), dst++);
+                       src++;
+               }
+               if (c & 3) {
+                       u8 *src8 = (u8 *) src;
+                       u8 __iomem *dst8 = (u8 __iomem *) dst;
+
+                       for (i = c & 3; i--;) {
+                               if (i & 1) {
+                                       fb_writeb(*src8++, ++dst8);
+                               } else {
+                                       fb_writeb(*src8++, --dst8);
+                                       dst8 += 2;
+                               }
+                       }
+                       dst = (u32 __iomem *) dst8;
+               }
+
+               *ppos += c;
+               buf += c;
+               cnt += c;
+               count -= c;
+       }
+
+       kfree(buffer);
+
+       return (cnt) ? cnt : err;
+}
+#endif /* ! __BIG_ENDIAN */
+
+#include "smtc2d.c"
+
+void smtcfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
+{
+       struct par_info *p = (struct par_info *)info->par;
+
+       if (smtc_2Dacceleration) {
+               if (!area->width || !area->height)
+                       return;
+
+               deCopy(p->BaseAddressInVRAM, 0, info->var.bits_per_pixel,
+                      area->dx, area->dy, area->width, area->height,
+                      p->BaseAddressInVRAM, 0, area->sx, area->sy, 0, 0xC);
+
+       } else
+               cfb_copyarea(info, area);
+}
+
+void smtcfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
+{
+       struct par_info *p = (struct par_info *)info->par;
+
+       if (smtc_2Dacceleration) {
+               if (!rect->width || !rect->height)
+                       return;
+               if (info->var.bits_per_pixel >= 24)
+                       deFillRect(p->BaseAddressInVRAM, 0, rect->dx * 3,
+                                  rect->dy * 3, rect->width * 3, rect->height,
+                                  rect->color);
+               else
+                       deFillRect(p->BaseAddressInVRAM, 0, rect->dx, rect->dy,
+                                  rect->width, rect->height, rect->color);
+       } else
+               cfb_fillrect(info, rect);
+}
+
+void smtcfb_imageblit(struct fb_info *info, const struct fb_image *image)
+{
+       struct par_info *p = (struct par_info *)info->par;
+       u32 bg_col = 0, fg_col = 0;
+
+       if ((smtc_2Dacceleration) && (image->depth == 1)) {
+               if (smtc_de_busy)
+                       deWaitForNotBusy();
+
+               switch (info->var.bits_per_pixel) {
+               case 8:
+                       bg_col = image->bg_color;
+                       fg_col = image->fg_color;
+                       break;
+               case 16:
+                       bg_col =
+                           ((u32 *) (info->pseudo_palette))[image->bg_color];
+                       fg_col =
+                           ((u32 *) (info->pseudo_palette))[image->fg_color];
+                       break;
+               case 32:
+                       bg_col =
+                           ((u32 *) (info->pseudo_palette))[image->bg_color];
+                       fg_col =
+                           ((u32 *) (info->pseudo_palette))[image->fg_color];
+                       break;
+               }
+
+               deSystemMem2VideoMemMonoBlt(
+                       image->data,
+                       image->width / 8,
+                       0,
+                       p->BaseAddressInVRAM,
+                       0,
+                       0,
+                       image->dx, image->dy,
+                       image->width, image->height,
+                       fg_col, bg_col,
+                       0x0C);
+
+       } else
+               cfb_imageblit(info, image);
+}
+
+static struct fb_ops smtcfb_ops = {
+       .owner = THIS_MODULE,
+       .fb_setcolreg = smtc_setcolreg,
+       .fb_blank = smtcfb_blank,
+       .fb_fillrect = smtcfb_fillrect,
+       .fb_imageblit = smtcfb_imageblit,
+       .fb_copyarea = smtcfb_copyarea,
+#ifdef __BIG_ENDIAN
+       .fb_read = smtcfb_read,
+       .fb_write = smtcfb_write,
+#endif
+
+};
+
+void smtcfb_setmode(struct smtcfb_info *sfb)
+{
+       switch (sfb->fb.var.bits_per_pixel) {
+       case 32:
+               sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
+               sfb->fb.fix.line_length = sfb->fb.var.xres * 4;
+               sfb->fb.var.red.length = 8;
+               sfb->fb.var.green.length = 8;
+               sfb->fb.var.blue.length = 8;
+               sfb->fb.var.red.offset = 16;
+               sfb->fb.var.green.offset = 8;
+               sfb->fb.var.blue.offset = 0;
+
+               break;
+       case 8:
+               sfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+               sfb->fb.fix.line_length = sfb->fb.var.xres;
+               sfb->fb.var.red.offset = 5;
+               sfb->fb.var.red.length = 3;
+               sfb->fb.var.green.offset = 2;
+               sfb->fb.var.green.length = 3;
+               sfb->fb.var.blue.offset = 0;
+               sfb->fb.var.blue.length = 2;
+               break;
+       case 24:
+               sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
+               sfb->fb.fix.line_length = sfb->fb.var.xres * 3;
+               sfb->fb.var.red.length = 8;
+               sfb->fb.var.green.length = 8;
+               sfb->fb.var.blue.length = 8;
+
+               sfb->fb.var.red.offset = 16;
+               sfb->fb.var.green.offset = 8;
+               sfb->fb.var.blue.offset = 0;
+
+               break;
+       case 16:
+       default:
+               sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
+               sfb->fb.fix.line_length = sfb->fb.var.xres * 2;
+
+               sfb->fb.var.red.length = 5;
+               sfb->fb.var.green.length = 6;
+               sfb->fb.var.blue.length = 5;
+
+               sfb->fb.var.red.offset = 11;
+               sfb->fb.var.green.offset = 5;
+               sfb->fb.var.blue.offset = 0;
+
+               break;
+       }
+
+       hw.width = sfb->fb.var.xres;
+       hw.height = sfb->fb.var.yres;
+       hw.hz = 60;
+       smtc_set_timing(sfb, &hw);
+       if (smtc_2Dacceleration) {
+               printk("2D acceleration enabled!\n");
+               /* Init smtc drawing engine */
+               deInit(sfb->fb.var.xres, sfb->fb.var.yres,
+                               sfb->fb.var.bits_per_pixel);
+       }
+}
+
+/*
+ * Alloc struct smtcfb_info and assign the default value
+ */
+static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *dev,
+                                                       char *name)
+{
+       struct smtcfb_info *sfb;
+
+       sfb = kmalloc(sizeof(struct smtcfb_info), GFP_KERNEL);
+
+       if (!sfb)
+               return NULL;
+
+       memset(sfb, 0, sizeof(struct smtcfb_info));
+
+       sfb->currcon = -1;
+       sfb->dev = dev;
+
+       /*** Init sfb->fb with default value ***/
+       sfb->fb.flags = FBINFO_FLAG_DEFAULT;
+       sfb->fb.fbops = &smtcfb_ops;
+       sfb->fb.var = smtcfb_var;
+       sfb->fb.fix = smtcfb_fix;
+
+       strcpy(sfb->fb.fix.id, name);
+
+       sfb->fb.fix.type = FB_TYPE_PACKED_PIXELS;
+       sfb->fb.fix.type_aux = 0;
+       sfb->fb.fix.xpanstep = 0;
+       sfb->fb.fix.ypanstep = 0;
+       sfb->fb.fix.ywrapstep = 0;
+       sfb->fb.fix.accel = FB_ACCEL_SMI_LYNX;
+
+       sfb->fb.var.nonstd = 0;
+       sfb->fb.var.activate = FB_ACTIVATE_NOW;
+       sfb->fb.var.height = -1;
+       sfb->fb.var.width = -1;
+       /* text mode acceleration */
+       sfb->fb.var.accel_flags = FB_ACCELF_TEXT;
+       sfb->fb.var.vmode = FB_VMODE_NONINTERLACED;
+       sfb->fb.par = &hw;
+       sfb->fb.pseudo_palette = colreg;
+
+       return sfb;
+}
+
+/*
+ * Unmap in the memory mapped IO registers
+ */
+
+static void smtc_unmap_mmio(struct smtcfb_info *sfb)
+{
+       if (sfb && smtc_RegBaseAddress)
+               smtc_RegBaseAddress = NULL;
+}
+
+/*
+ * Map in the screen memory
+ */
+
+static int smtc_map_smem(struct smtcfb_info *sfb,
+               struct pci_dev *dev, u_long smem_len)
+{
+       if (sfb->fb.var.bits_per_pixel == 32) {
+#ifdef __BIG_ENDIAN
+               sfb->fb.fix.smem_start = pci_resource_start(dev, 0)
+                       + 0x800000;
+#else
+               sfb->fb.fix.smem_start = pci_resource_start(dev, 0);
+#endif
+       } else {
+               sfb->fb.fix.smem_start = pci_resource_start(dev, 0);
+       }
+
+       sfb->fb.fix.smem_len = smem_len;
+
+       sfb->fb.screen_base = smtc_VRAMBaseAddress;
+
+       if (!sfb->fb.screen_base) {
+               printk(KERN_INFO "%s: unable to map screen memory\n",
+                               sfb->fb.fix.id);
+               return -ENOMEM;
+       }
+
+       return 0;
+}
+
+/*
+ * Unmap in the screen memory
+ *
+ */
+static void smtc_unmap_smem(struct smtcfb_info *sfb)
+{
+       if (sfb && sfb->fb.screen_base) {
+               iounmap(sfb->fb.screen_base);
+               sfb->fb.screen_base = NULL;
+       }
+}
+
+/*
+ * We need to wake up the LynxEM+, and make sure its in linear memory mode.
+ */
+static inline void sm7xx_init_hw(void)
+{
+       outb_p(0x18, 0x3c4);
+       outb_p(0x11, 0x3c5);
+}
+
+static void smtc_free_fb_info(struct smtcfb_info *sfb)
+{
+       if (sfb) {
+               fb_alloc_cmap(&sfb->fb.cmap, 0, 0);
+               kfree(sfb);
+       }
+}
+
+/*
+ *     sm712vga_setup - process command line options, get vga parameter
+ *     @options: string of options
+ *     Returns zero.
+ *
+ */
+static int __init __maybe_unused sm712vga_setup(char *options)
+{
+       int index;
+
+       if (!options || !*options) {
+               smdbg("\n No vga parameter\n");
+               return -EINVAL;
+       }
+
+       smtc_screen_info.lfb_width = 0;
+       smtc_screen_info.lfb_height = 0;
+       smtc_screen_info.lfb_depth = 0;
+
+       smdbg("\nsm712vga_setup = %s\n", options);
+
+       for (index = 0;
+            index < (sizeof(vesa_mode) / sizeof(struct vesa_mode_table));
+            index++) {
+               if (strstr(options, vesa_mode[index].mode_index)) {
+                       smtc_screen_info.lfb_width = vesa_mode[index].lfb_width;
+                       smtc_screen_info.lfb_height =
+                                       vesa_mode[index].lfb_height;
+                       smtc_screen_info.lfb_depth = vesa_mode[index].lfb_depth;
+                       return 0;
+               }
+       }
+
+       return -1;
+}
+__setup("vga=", sm712vga_setup);
+
+/* Jason (08/13/2009)
+ * Original init function changed to probe method to be used by pci_drv
+ * process used to detect chips replaced with kernel process in pci_drv
+ */
+static int __init smtcfb_pci_probe(struct pci_dev *pdev,
+                                  const struct pci_device_id *ent)
+{
+       struct smtcfb_info *sfb;
+       u_long smem_size = 0x00800000;  /* default 8MB */
+       char name[16];
+       int err;
+       unsigned long pFramebufferPhysical;
+
+       printk(KERN_INFO
+               "Silicon Motion display driver " SMTC_LINUX_FB_VERSION "\n");
+
+       err = pci_enable_device(pdev);  /* enable SMTC chip */
+
+       if (err)
+               return err;
+       err = -ENOMEM;
+
+       hw.chipID = ent->device;
+       sprintf(name, "sm%Xfb", hw.chipID);
+
+       sfb = smtc_alloc_fb_info(pdev, name);
+
+       if (!sfb)
+               goto failed;
+       /* Jason (08/13/2009)
+        * Store fb_info to be further used when suspending and resuming
+        */
+       pci_set_drvdata(pdev, sfb);
+
+       sm7xx_init_hw();
+
+       /*get mode parameter from smtc_screen_info */
+       if (smtc_screen_info.lfb_width != 0) {
+               sfb->fb.var.xres = smtc_screen_info.lfb_width;
+               sfb->fb.var.yres = smtc_screen_info.lfb_height;
+               sfb->fb.var.bits_per_pixel = smtc_screen_info.lfb_depth;
+       } else {
+               /* default resolution 1024x600 16bit mode */
+               sfb->fb.var.xres = SCREEN_X_RES;
+               sfb->fb.var.yres = SCREEN_Y_RES;
+               sfb->fb.var.bits_per_pixel = SCREEN_BPP;
+       }
+
+#ifdef __BIG_ENDIAN
+       if (sfb->fb.var.bits_per_pixel == 24)
+               sfb->fb.var.bits_per_pixel = (smtc_screen_info.lfb_depth = 32);
+#endif
+       /* Map address and memory detection */
+       pFramebufferPhysical = pci_resource_start(pdev, 0);
+       pci_read_config_byte(pdev, PCI_REVISION_ID, &hw.chipRevID);
+
+       switch (hw.chipID) {
+       case 0x710:
+       case 0x712:
+               sfb->fb.fix.mmio_start = pFramebufferPhysical + 0x00400000;
+               sfb->fb.fix.mmio_len = 0x00400000;
+               smem_size = SM712_VIDEOMEMORYSIZE;
+#ifdef __BIG_ENDIAN
+               hw.m_pLFB = (smtc_VRAMBaseAddress =
+                   ioremap(pFramebufferPhysical, 0x00c00000));
+#else
+               hw.m_pLFB = (smtc_VRAMBaseAddress =
+                   ioremap(pFramebufferPhysical, 0x00800000));
+#endif
+               hw.m_pMMIO = (smtc_RegBaseAddress =
+                   smtc_VRAMBaseAddress + 0x00700000);
+               smtc_2DBaseAddress = (hw.m_pDPR =
+                   smtc_VRAMBaseAddress + 0x00408000);
+               smtc_2Ddataport = smtc_VRAMBaseAddress + DE_DATA_PORT_712;
+               hw.m_pVPR = hw.m_pLFB + 0x0040c000;
+#ifdef __BIG_ENDIAN
+               if (sfb->fb.var.bits_per_pixel == 32) {
+                       smtc_VRAMBaseAddress += 0x800000;
+                       hw.m_pLFB += 0x800000;
+                       printk(KERN_INFO
+                               "\nsmtc_VRAMBaseAddress=%p hw.m_pLFB=%p\n",
+                                       smtc_VRAMBaseAddress, hw.m_pLFB);
+               }
+#endif
+               if (!smtc_RegBaseAddress) {
+                       printk(KERN_INFO
+                               "%s: unable to map memory mapped IO\n",
+                               sfb->fb.fix.id);
+                       return -ENOMEM;
+               }
+
+               /* set MCLK = 14.31818 * (0x16 / 0x2) */
+               smtc_seqw(0x6a, 0x16);
+               smtc_seqw(0x6b, 0x02);
+               smtc_seqw(0x62, 0x3e);
+               /* enable PCI burst */
+               smtc_seqw(0x17, 0x20);
+               /* enable word swap */
+#ifdef __BIG_ENDIAN
+               if (sfb->fb.var.bits_per_pixel == 32)
+                       smtc_seqw(0x17, 0x30);
+#endif
+#ifdef CONFIG_FB_SM7XX_ACCEL
+               smtc_2Dacceleration = 1;
+#endif
+               break;
+       case 0x720:
+               sfb->fb.fix.mmio_start = pFramebufferPhysical;
+               sfb->fb.fix.mmio_len = 0x00200000;
+               smem_size = SM722_VIDEOMEMORYSIZE;
+               smtc_2DBaseAddress = (hw.m_pDPR =
+                   ioremap(pFramebufferPhysical, 0x00a00000));
+               hw.m_pLFB = (smtc_VRAMBaseAddress =
+                   smtc_2DBaseAddress + 0x00200000);
+               hw.m_pMMIO = (smtc_RegBaseAddress =
+                   smtc_2DBaseAddress + 0x000c0000);
+               smtc_2Ddataport = smtc_2DBaseAddress + DE_DATA_PORT_722;
+               hw.m_pVPR = smtc_2DBaseAddress + 0x800;
+
+               smtc_seqw(0x62, 0xff);
+               smtc_seqw(0x6a, 0x0d);
+               smtc_seqw(0x6b, 0x02);
+               smtc_2Dacceleration = 0;
+               break;
+       default:
+               printk(KERN_INFO
+               "No valid Silicon Motion display chip was detected!\n");
+
+               smtc_free_fb_info(sfb);
+               return err;
+       }
+
+       /* can support 32 bpp */
+       if (15 == sfb->fb.var.bits_per_pixel)
+               sfb->fb.var.bits_per_pixel = 16;
+
+       sfb->fb.var.xres_virtual = sfb->fb.var.xres;
+       sfb->fb.var.yres_virtual = sfb->fb.var.yres;
+       err = smtc_map_smem(sfb, pdev, smem_size);
+       if (err)
+               goto failed;
+
+       smtcfb_setmode(sfb);
+       /* Primary display starting from 0 postion */
+       hw.BaseAddressInVRAM = 0;
+       sfb->fb.par = &hw;
+
+       err = register_framebuffer(&sfb->fb);
+       if (err < 0)
+               goto failed;
+
+       printk(KERN_INFO "Silicon Motion SM%X Rev%X primary display mode"
+                       "%dx%d-%d Init Complete.\n", hw.chipID, hw.chipRevID,
+                       sfb->fb.var.xres, sfb->fb.var.yres,
+                       sfb->fb.var.bits_per_pixel);
+
+       return 0;
+
+ failed:
+       printk(KERN_INFO "Silicon Motion, Inc.  primary display init fail\n");
+
+       smtc_unmap_smem(sfb);
+       smtc_unmap_mmio(sfb);
+       smtc_free_fb_info(sfb);
+
+       return err;
+}
+
+
+/* Jason (08/11/2009) PCI_DRV wrapper essential structs */
+static struct pci_device_id smtcfb_pci_table[] = {
+       {0x126f, 0x710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       {0x126f, 0x712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       {0x126f, 0x720, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       {0,}
+};
+
+
+/* Jason (08/14/2009)
+ * do some clean up when the driver module is removed
+ */
+static void __devexit smtcfb_pci_remove(struct pci_dev *pdev)
+{
+       struct smtcfb_info *sfb;
+
+       sfb = pci_get_drvdata(pdev);
+       pci_set_drvdata(pdev, NULL);
+       smtc_unmap_smem(sfb);
+       smtc_unmap_mmio(sfb);
+       unregister_framebuffer(&sfb->fb);
+       smtc_free_fb_info(sfb);
+}
+
+/* Jason (08/14/2009)
+ * suspend function, called when the suspend event is triggered
+ */
+static int __maybe_unused smtcfb_suspend(struct pci_dev *pdev, pm_message_t msg)
+{
+       struct smtcfb_info *sfb;
+       int retv;
+
+       sfb = pci_get_drvdata(pdev);
+
+       /* set the hw in sleep mode use externel clock and self memory refresh
+        * so that we can turn off internal PLLs later on
+        */
+       smtc_seqw(0x20, (smtc_seqr(0x20) | 0xc0));
+       smtc_seqw(0x69, (smtc_seqr(0x69) & 0xf7));
+
+       switch (msg.event) {
+       case PM_EVENT_FREEZE:
+       case PM_EVENT_PRETHAW:
+               pdev->dev.power.power_state = msg;
+               return 0;
+       }
+
+       /* when doing suspend, call fb apis and pci apis */
+       if (msg.event == PM_EVENT_SUSPEND) {
+               acquire_console_sem();
+               fb_set_suspend(&sfb->fb, 1);
+               release_console_sem();
+               retv = pci_save_state(pdev);
+               pci_disable_device(pdev);
+               retv = pci_choose_state(pdev, msg);
+               retv = pci_set_power_state(pdev, retv);
+       }
+
+       pdev->dev.power.power_state = msg;
+
+       /* additionaly turn off all function blocks including internal PLLs */
+       smtc_seqw(0x21, 0xff);
+
+       return 0;
+}
+
+static int __maybe_unused smtcfb_resume(struct pci_dev *pdev)
+{
+       struct smtcfb_info *sfb;
+       int retv;
+
+       sfb = pci_get_drvdata(pdev);
+
+       /* when resuming, restore pci data and fb cursor */
+       if (pdev->dev.power.power_state.event != PM_EVENT_FREEZE) {
+               retv = pci_set_power_state(pdev, PCI_D0);
+               retv = pci_restore_state(pdev);
+               if (pci_enable_device(pdev))
+                       return -1;
+               pci_set_master(pdev);
+       }
+
+       /* reinit hardware */
+       sm7xx_init_hw();
+       switch (hw.chipID) {
+       case 0x710:
+       case 0x712:
+               /* set MCLK = 14.31818 *  (0x16 / 0x2) */
+               smtc_seqw(0x6a, 0x16);
+               smtc_seqw(0x6b, 0x02);
+               smtc_seqw(0x62, 0x3e);
+               /* enable PCI burst */
+               smtc_seqw(0x17, 0x20);
+#ifdef __BIG_ENDIAN
+               if (sfb->fb.var.bits_per_pixel == 32)
+                       smtc_seqw(0x17, 0x30);
+#endif
+               break;
+       case 0x720:
+               smtc_seqw(0x62, 0xff);
+               smtc_seqw(0x6a, 0x0d);
+               smtc_seqw(0x6b, 0x02);
+               break;
+       }
+
+       smtc_seqw(0x34, (smtc_seqr(0x34) | 0xc0));
+       smtc_seqw(0x33, ((smtc_seqr(0x33) | 0x08) & 0xfb));
+
+       smtcfb_setmode(sfb);
+
+       acquire_console_sem();
+       fb_set_suspend(&sfb->fb, 0);
+       release_console_sem();
+
+       return 0;
+}
+
+/* Jason (08/13/2009)
+ * pci_driver struct used to wrap the original driver
+ * so that it can be registered into the kernel and
+ * the proper method would be called when suspending and resuming
+ */
+static struct pci_driver smtcfb_driver = {
+       .name = "smtcfb",
+       .id_table = smtcfb_pci_table,
+       .probe = smtcfb_pci_probe,
+       .remove = __devexit_p(smtcfb_pci_remove),
+#ifdef CONFIG_PM
+       .suspend = smtcfb_suspend,
+       .resume = smtcfb_resume,
+#endif
+};
+
+static int __init smtcfb_init(void)
+{
+       return pci_register_driver(&smtcfb_driver);
+}
+
+static void __exit smtcfb_exit(void)
+{
+       pci_unregister_driver(&smtcfb_driver);
+}
+
+module_init(smtcfb_init);
+module_exit(smtcfb_exit);
+
+MODULE_AUTHOR("Siliconmotion ");
+MODULE_DESCRIPTION("Framebuffer driver for SMI Graphic Cards");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/sm7xx/smtcfb.h b/drivers/staging/sm7xx/smtcfb.h
new file mode 100644 (file)
index 0000000..7f2c341
--- /dev/null
@@ -0,0 +1,793 @@
+/*
+ * Silicon Motion SM712 frame buffer device
+ *
+ * Copyright (C) 2006 Silicon Motion Technology Corp.
+ * Authors:    Ge Wang, gewang@siliconmotion.com
+ *             Boyod boyod.yang@siliconmotion.com.cn
+ *
+ * Copyright (C) 2009 Lemote, Inc.
+ * Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License. See the file COPYING in the main directory of this archive for
+ *  more details.
+ */
+
+#define SMTC_LINUX_FB_VERSION  "version 0.11.2619.21.01 July 27, 2008"
+
+#define NR_PALETTE        256
+#define NR_RGB            2
+
+#define FB_ACCEL_SMI_LYNX 88
+
+#ifdef __BIG_ENDIAN
+#define PC_VGA            0
+#else
+#define PC_VGA            1
+#endif
+
+#define SCREEN_X_RES      1024
+#define SCREEN_Y_RES      600
+#define SCREEN_BPP        16
+
+#ifndef FIELD_OFFSET
+#define FIELD_OFSFET(type, field) \
+       ((unsigned long) (PUCHAR) & (((type *)0)->field))
+#endif
+
+/*Assume SM712 graphics chip has 4MB VRAM */
+#define SM712_VIDEOMEMORYSIZE    0x00400000
+/*Assume SM722 graphics chip has 8MB VRAM */
+#define SM722_VIDEOMEMORYSIZE    0x00800000
+
+#define dac_reg        (0x3c8)
+#define dac_val        (0x3c9)
+
+extern char *smtc_RegBaseAddress;
+#define smtc_mmiowb(dat, reg)  writeb(dat, smtc_RegBaseAddress + reg)
+#define smtc_mmioww(dat, reg)  writew(dat, smtc_RegBaseAddress + reg)
+#define smtc_mmiowl(dat, reg)  writel(dat, smtc_RegBaseAddress + reg)
+
+#define smtc_mmiorb(reg)       readb(smtc_RegBaseAddress + reg)
+#define smtc_mmiorw(reg)       readw(smtc_RegBaseAddress + reg)
+#define smtc_mmiorl(reg)       readl(smtc_RegBaseAddress + reg)
+
+#define SIZE_SR00_SR04      (0x04 - 0x00 + 1)
+#define SIZE_SR10_SR24      (0x24 - 0x10 + 1)
+#define SIZE_SR30_SR75      (0x75 - 0x30 + 1)
+#define SIZE_SR80_SR93      (0x93 - 0x80 + 1)
+#define SIZE_SRA0_SRAF      (0xAF - 0xA0 + 1)
+#define SIZE_GR00_GR08      (0x08 - 0x00 + 1)
+#define SIZE_AR00_AR14      (0x14 - 0x00 + 1)
+#define SIZE_CR00_CR18      (0x18 - 0x00 + 1)
+#define SIZE_CR30_CR4D      (0x4D - 0x30 + 1)
+#define SIZE_CR90_CRA7      (0xA7 - 0x90 + 1)
+#define SIZE_VPR               (0x6C + 1)
+#define SIZE_DPR               (0x44 + 1)
+
+static inline void smtc_crtcw(int reg, int val)
+{
+       smtc_mmiowb(reg, 0x3d4);
+       smtc_mmiowb(val, 0x3d5);
+}
+
+static inline unsigned int smtc_crtcr(int reg)
+{
+       smtc_mmiowb(reg, 0x3d4);
+       return smtc_mmiorb(0x3d5);
+}
+
+static inline void smtc_grphw(int reg, int val)
+{
+       smtc_mmiowb(reg, 0x3ce);
+       smtc_mmiowb(val, 0x3cf);
+}
+
+static inline unsigned int smtc_grphr(int reg)
+{
+       smtc_mmiowb(reg, 0x3ce);
+       return smtc_mmiorb(0x3cf);
+}
+
+static inline void smtc_attrw(int reg, int val)
+{
+       smtc_mmiorb(0x3da);
+       smtc_mmiowb(reg, 0x3c0);
+       smtc_mmiorb(0x3c1);
+       smtc_mmiowb(val, 0x3c0);
+}
+
+static inline void smtc_seqw(int reg, int val)
+{
+       smtc_mmiowb(reg, 0x3c4);
+       smtc_mmiowb(val, 0x3c5);
+}
+
+static inline unsigned int smtc_seqr(int reg)
+{
+       smtc_mmiowb(reg, 0x3c4);
+       return smtc_mmiorb(0x3c5);
+}
+
+/* The next structure holds all information relevant for a specific video mode.
+ */
+
+struct ModeInit {
+       int mmSizeX;
+       int mmSizeY;
+       int bpp;
+       int hz;
+       unsigned char Init_MISC;
+       unsigned char Init_SR00_SR04[SIZE_SR00_SR04];
+       unsigned char Init_SR10_SR24[SIZE_SR10_SR24];
+       unsigned char Init_SR30_SR75[SIZE_SR30_SR75];
+       unsigned char Init_SR80_SR93[SIZE_SR80_SR93];
+       unsigned char Init_SRA0_SRAF[SIZE_SRA0_SRAF];
+       unsigned char Init_GR00_GR08[SIZE_GR00_GR08];
+       unsigned char Init_AR00_AR14[SIZE_AR00_AR14];
+       unsigned char Init_CR00_CR18[SIZE_CR00_CR18];
+       unsigned char Init_CR30_CR4D[SIZE_CR30_CR4D];
+       unsigned char Init_CR90_CRA7[SIZE_CR90_CRA7];
+};
+
+/**********************************************************************
+                        SM712 Mode table.
+ **********************************************************************/
+struct ModeInit VGAMode[] = {
+       {
+        /*  mode#0: 640 x 480  16Bpp  60Hz */
+        640, 480, 16, 60,
+        /*  Init_MISC */
+        0xE3,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x00, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xFF, 0xBE, 0xEF, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x30, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x32, 0x03, 0xA0, 0x09, 0xC0, 0x32, 0x32, 0x32,
+         0x32, 0x32, 0x32, 0x32, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x32, 0x32, 0x32,
+         0x04, 0x24, 0x63, 0x4F, 0x52, 0x0B, 0xDF, 0xEA,
+         0x04, 0x50, 0x19, 0x32, 0x32, 0x00, 0x00, 0x32,
+         0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x07, 0x82, 0x07, 0x04,
+         0x00, 0x45, 0x30, 0x30, 0x40, 0x30,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x32,
+         0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x32, 0x32,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
+         0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xFF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0x5F, 0x4F, 0x4F, 0x00, 0x53, 0x1F, 0x0B, 0x3E,
+         0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xEA, 0x0C, 0xDF, 0x50, 0x40, 0xDF, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x03, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xFF, 0xFD,
+         0x5F, 0x4F, 0x00, 0x54, 0x00, 0x0B, 0xDF, 0x00,
+         0xEA, 0x0C, 0x2E, 0x00, 0x4F, 0xDF,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x56, 0xDD, 0x5E, 0xEA, 0x87, 0x44, 0x8F, 0x55,
+         0x0A, 0x8F, 0x55, 0x0A, 0x00, 0x00, 0x18, 0x00,
+         0x11, 0x10, 0x0B, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,
+         },
+        },
+       {
+        /*  mode#1: 640 x 480  24Bpp  60Hz */
+        640, 480, 24, 60,
+        /*  Init_MISC */
+        0xE3,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x00, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xFF, 0xBE, 0xEF, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x30, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x32, 0x03, 0xA0, 0x09, 0xC0, 0x32, 0x32, 0x32,
+         0x32, 0x32, 0x32, 0x32, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x32, 0x32, 0x32,
+         0x04, 0x24, 0x63, 0x4F, 0x52, 0x0B, 0xDF, 0xEA,
+         0x04, 0x50, 0x19, 0x32, 0x32, 0x00, 0x00, 0x32,
+         0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x07, 0x82, 0x07, 0x04,
+         0x00, 0x45, 0x30, 0x30, 0x40, 0x30,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x32,
+         0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x32, 0x32,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
+         0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xFF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0x5F, 0x4F, 0x4F, 0x00, 0x53, 0x1F, 0x0B, 0x3E,
+         0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xEA, 0x0C, 0xDF, 0x50, 0x40, 0xDF, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x03, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xFF, 0xFD,
+         0x5F, 0x4F, 0x00, 0x54, 0x00, 0x0B, 0xDF, 0x00,
+         0xEA, 0x0C, 0x2E, 0x00, 0x4F, 0xDF,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x56, 0xDD, 0x5E, 0xEA, 0x87, 0x44, 0x8F, 0x55,
+         0x0A, 0x8F, 0x55, 0x0A, 0x00, 0x00, 0x18, 0x00,
+         0x11, 0x10, 0x0B, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,
+         },
+        },
+       {
+        /*  mode#0: 640 x 480  32Bpp  60Hz */
+        640, 480, 32, 60,
+        /*  Init_MISC */
+        0xE3,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x00, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xFF, 0xBE, 0xEF, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x30, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x32, 0x03, 0xA0, 0x09, 0xC0, 0x32, 0x32, 0x32,
+         0x32, 0x32, 0x32, 0x32, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x32, 0x32, 0x32,
+         0x04, 0x24, 0x63, 0x4F, 0x52, 0x0B, 0xDF, 0xEA,
+         0x04, 0x50, 0x19, 0x32, 0x32, 0x00, 0x00, 0x32,
+         0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x07, 0x82, 0x07, 0x04,
+         0x00, 0x45, 0x30, 0x30, 0x40, 0x30,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x32,
+         0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x32, 0x32,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
+         0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xFF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0x5F, 0x4F, 0x4F, 0x00, 0x53, 0x1F, 0x0B, 0x3E,
+         0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xEA, 0x0C, 0xDF, 0x50, 0x40, 0xDF, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x03, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xFF, 0xFD,
+         0x5F, 0x4F, 0x00, 0x54, 0x00, 0x0B, 0xDF, 0x00,
+         0xEA, 0x0C, 0x2E, 0x00, 0x4F, 0xDF,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x56, 0xDD, 0x5E, 0xEA, 0x87, 0x44, 0x8F, 0x55,
+         0x0A, 0x8F, 0x55, 0x0A, 0x00, 0x00, 0x18, 0x00,
+         0x11, 0x10, 0x0B, 0x0A, 0x0A, 0x0A, 0x0A, 0x00,
+         },
+        },
+
+       {                       /*  mode#2: 800 x 600  16Bpp  60Hz */
+        800, 600, 16, 60,
+        /*  Init_MISC */
+        0x2B,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x03, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xFF, 0xBE, 0xEE, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x30, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x34, 0x03, 0x20, 0x09, 0xC0, 0x24, 0x24, 0x24,
+         0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x38, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x24, 0x24, 0x24,
+         0x04, 0x48, 0x83, 0x63, 0x68, 0x72, 0x57, 0x58,
+         0x04, 0x55, 0x59, 0x24, 0x24, 0x00, 0x00, 0x24,
+         0x01, 0x80, 0x7A, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x1C, 0x85, 0x35, 0x13,
+         0x02, 0x45, 0x30, 0x35, 0x40, 0x20,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0x00, 0x00, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x24,
+         0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x24, 0x24,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
+         0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xBF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0x7F, 0x63, 0x63, 0x00, 0x68, 0x18, 0x72, 0xF0,
+         0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x58, 0x0C, 0x57, 0x64, 0x40, 0x57, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x03, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xBF, 0xFD,
+         0x7F, 0x63, 0x00, 0x69, 0x18, 0x72, 0x57, 0x00,
+         0x58, 0x0C, 0xE0, 0x20, 0x63, 0x57,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x56, 0x4B, 0x5E, 0x55, 0x86, 0x9D, 0x8E, 0xAA,
+         0xDB, 0x2A, 0xDF, 0x33, 0x00, 0x00, 0x18, 0x00,
+         0x20, 0x1F, 0x1A, 0x19, 0x0F, 0x0F, 0x0F, 0x00,
+         },
+        },
+       {                       /*  mode#3: 800 x 600  24Bpp  60Hz */
+        800, 600, 24, 60,
+        0x2B,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x03, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xFF, 0xBE, 0xEE, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x30, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x36, 0x03, 0x20, 0x09, 0xC0, 0x36, 0x36, 0x36,
+         0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x36, 0x36, 0x36,
+         0x04, 0x48, 0x83, 0x63, 0x68, 0x72, 0x57, 0x58,
+         0x04, 0x55, 0x59, 0x36, 0x36, 0x00, 0x00, 0x36,
+         0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x1C, 0x85, 0x35, 0x13,
+         0x02, 0x45, 0x30, 0x30, 0x40, 0x20,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x36,
+         0xF7, 0x00, 0x00, 0x00, 0xEF, 0xFF, 0x36, 0x36,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
+         0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xBF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0x7F, 0x63, 0x63, 0x00, 0x68, 0x18, 0x72, 0xF0,
+         0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x58, 0x0C, 0x57, 0x64, 0x40, 0x57, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x03, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xBF, 0xFD,
+         0x7F, 0x63, 0x00, 0x69, 0x18, 0x72, 0x57, 0x00,
+         0x58, 0x0C, 0xE0, 0x20, 0x63, 0x57,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x56, 0x4B, 0x5E, 0x55, 0x86, 0x9D, 0x8E, 0xAA,
+         0xDB, 0x2A, 0xDF, 0x33, 0x00, 0x00, 0x18, 0x00,
+         0x20, 0x1F, 0x1A, 0x19, 0x0F, 0x0F, 0x0F, 0x00,
+         },
+        },
+       {                       /*  mode#7: 800 x 600  32Bpp  60Hz */
+        800, 600, 32, 60,
+        /*  Init_MISC */
+        0x2B,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x03, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xFF, 0xBE, 0xEE, 0xFF, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x30, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x34, 0x03, 0x20, 0x09, 0xC0, 0x24, 0x24, 0x24,
+         0x24, 0x24, 0x24, 0x24, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x38, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x24, 0x24, 0x24,
+         0x04, 0x48, 0x83, 0x63, 0x68, 0x72, 0x57, 0x58,
+         0x04, 0x55, 0x59, 0x24, 0x24, 0x00, 0x00, 0x24,
+         0x01, 0x80, 0x7A, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x1C, 0x85, 0x35, 0x13,
+         0x02, 0x45, 0x30, 0x35, 0x40, 0x20,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0x00, 0x00, 0x00, 0x6F, 0x7F, 0x7F, 0xFF, 0x24,
+         0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x24, 0x24,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFF, 0xBF, 0xFF, 0xFF, 0xED, 0xED, 0xED,
+         0x7B, 0xFF, 0xFF, 0xFF, 0xBF, 0xEF, 0xBF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0x7F, 0x63, 0x63, 0x00, 0x68, 0x18, 0x72, 0xF0,
+         0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x58, 0x0C, 0x57, 0x64, 0x40, 0x57, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x03, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xE7, 0xBF, 0xFD,
+         0x7F, 0x63, 0x00, 0x69, 0x18, 0x72, 0x57, 0x00,
+         0x58, 0x0C, 0xE0, 0x20, 0x63, 0x57,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x56, 0x4B, 0x5E, 0x55, 0x86, 0x9D, 0x8E, 0xAA,
+         0xDB, 0x2A, 0xDF, 0x33, 0x00, 0x00, 0x18, 0x00,
+         0x20, 0x1F, 0x1A, 0x19, 0x0F, 0x0F, 0x0F, 0x00,
+         },
+        },
+       /* We use 1024x768 table to light 1024x600 panel for lemote */
+       {                       /*  mode#4: 1024 x 600  16Bpp  60Hz  */
+        1024, 600, 16, 60,
+        /*  Init_MISC */
+        0xEB,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x00, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xC8, 0x40, 0x14, 0x60, 0x00, 0x0A, 0x17, 0x20,
+         0x51, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x30, 0x02, 0x00, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x22, 0x03, 0x24, 0x09, 0xC0, 0x22, 0x22, 0x22,
+         0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x22, 0x22, 0x22,
+         0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
+         0x00, 0x60, 0x59, 0x22, 0x22, 0x00, 0x00, 0x22,
+         0x01, 0x80, 0x7A, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x16, 0x02, 0x0D, 0x82, 0x09, 0x02,
+         0x04, 0x45, 0x3F, 0x30, 0x40, 0x20,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
+         0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
+         0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
+         0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
+         0xA3, 0x7F, 0x00, 0x82, 0x0b, 0x6f, 0x57, 0x00,
+         0x5c, 0x0f, 0xE0, 0xe0, 0x7F, 0x57,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
+         0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
+         0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
+         },
+        },
+       {                       /*  mode#5: 1024 x 768  24Bpp  60Hz */
+        1024, 768, 24, 60,
+        /*  Init_MISC */
+        0xEB,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x03, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x30, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A,
+         0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A,
+         0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
+         0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A,
+         0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x3B, 0x0D, 0x09, 0x02,
+         0x04, 0x45, 0x30, 0x30, 0x40, 0x20,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
+         0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
+         0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
+         0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
+         0xA3, 0x7F, 0x00, 0x86, 0x15, 0x24, 0xFF, 0x00,
+         0x01, 0x07, 0xE5, 0x20, 0x7F, 0xFF,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
+         0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
+         0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
+         },
+        },
+       {                       /*  mode#4: 1024 x 768  32Bpp  60Hz */
+        1024, 768, 32, 60,
+        /*  Init_MISC */
+        0xEB,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x03, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x32, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A,
+         0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A,
+         0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
+         0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A,
+         0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x3B, 0x0D, 0x09, 0x02,
+         0x04, 0x45, 0x30, 0x30, 0x40, 0x20,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
+         0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
+         0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
+         0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
+         0x00, 0x00, 0x00, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
+         0xA3, 0x7F, 0x00, 0x86, 0x15, 0x24, 0xFF, 0x00,
+         0x01, 0x07, 0xE5, 0x20, 0x7F, 0xFF,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
+         0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
+         0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
+         },
+        },
+       {                       /*  mode#6: 320 x 240  16Bpp  60Hz */
+        320, 240, 16, 60,
+        /*  Init_MISC */
+        0xEB,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x03, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x32, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A,
+         0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A,
+         0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
+         0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A,
+         0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x08, 0x43, 0x08, 0x43,
+         0x04, 0x45, 0x30, 0x30, 0x40, 0x20,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
+         0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
+         0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
+         0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
+         0x00, 0x00, 0x30, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
+         0x2E, 0x27, 0x00, 0x2b, 0x0c, 0x0F, 0xEF, 0x00,
+         0xFe, 0x0f, 0x01, 0xC0, 0x27, 0xEF,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
+         0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
+         0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
+         },
+        },
+
+       {                       /*  mode#8: 320 x 240  32Bpp  60Hz */
+        320, 240, 32, 60,
+        /*  Init_MISC */
+        0xEB,
+        {                      /*  Init_SR0_SR4 */
+         0x03, 0x01, 0x0F, 0x03, 0x0E,
+         },
+        {                      /*  Init_SR10_SR24 */
+         0xF3, 0xB6, 0xC0, 0xDD, 0x00, 0x0E, 0x17, 0x2C,
+         0x99, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0xC4, 0x32, 0x02, 0x01, 0x01,
+         },
+        {                      /*  Init_SR30_SR75 */
+         0x38, 0x03, 0x20, 0x09, 0xC0, 0x3A, 0x3A, 0x3A,
+         0x3A, 0x3A, 0x3A, 0x3A, 0x00, 0x00, 0x03, 0xFF,
+         0x00, 0xFC, 0x00, 0x00, 0x20, 0x18, 0x00, 0xFC,
+         0x20, 0x0C, 0x44, 0x20, 0x00, 0x00, 0x00, 0x3A,
+         0x06, 0x68, 0xA7, 0x7F, 0x83, 0x24, 0xFF, 0x03,
+         0x00, 0x60, 0x59, 0x3A, 0x3A, 0x00, 0x00, 0x3A,
+         0x01, 0x80, 0x7E, 0x1A, 0x1A, 0x00, 0x00, 0x00,
+         0x50, 0x03, 0x74, 0x14, 0x08, 0x43, 0x08, 0x43,
+         0x04, 0x45, 0x30, 0x30, 0x40, 0x20,
+         },
+        {                      /*  Init_SR80_SR93 */
+         0xFF, 0x07, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x3A,
+         0xF7, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3A, 0x3A,
+         0x00, 0x00, 0x00, 0x00,
+         },
+        {                      /*  Init_SRA0_SRAF */
+         0x00, 0xFB, 0x9F, 0x01, 0x00, 0xED, 0xED, 0xED,
+         0x7B, 0xFB, 0xFF, 0xFF, 0x97, 0xEF, 0xBF, 0xDF,
+         },
+        {                      /*  Init_GR00_GR08 */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F,
+         0xFF,
+         },
+        {                      /*  Init_AR00_AR14 */
+         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+         0x41, 0x00, 0x0F, 0x00, 0x00,
+         },
+        {                      /*  Init_CR00_CR18 */
+         0xA3, 0x7F, 0x7F, 0x00, 0x85, 0x16, 0x24, 0xF5,
+         0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+         0x03, 0x09, 0xFF, 0x80, 0x40, 0xFF, 0x00, 0xE3,
+         0xFF,
+         },
+        {                      /*  Init_CR30_CR4D */
+         0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x20,
+         0x00, 0x00, 0x30, 0x40, 0x00, 0xFF, 0xBF, 0xFF,
+         0x2E, 0x27, 0x00, 0x2b, 0x0c, 0x0F, 0xEF, 0x00,
+         0xFe, 0x0f, 0x01, 0xC0, 0x27, 0xEF,
+         },
+        {                      /*  Init_CR90_CRA7 */
+         0x55, 0xD9, 0x5D, 0xE1, 0x86, 0x1B, 0x8E, 0x26,
+         0xDA, 0x8D, 0xDE, 0x94, 0x00, 0x00, 0x18, 0x00,
+         0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x15, 0x03,
+         },
+        },
+};
+
+#define numVGAModes            (sizeof(VGAMode) / sizeof(struct ModeInit))
index 825bbc4fc3fa8573cb56a3c5260f91047978504c..061e730df2d08144d408307e080949b4940081d1 100644 (file)
@@ -1,6 +1,6 @@
 config VT6655
    tristate "VIA Technologies VT6655 support"
-   depends on PCI
+   depends on PCI && WLAN
    select WIRELESS_EXT
    select WEXT_PRIV
    ---help---
index 87bcd269310c80a5aec7dadade66ce308dbbb33d..1055b526c532aa7a90a2daa115493597f28d67f9 100644 (file)
@@ -1,6 +1,6 @@
 config VT6656
        tristate "VIA Technologies VT6656 support"
-       depends on USB
+       depends on USB && WLAN
        select WIRELESS_EXT
        select WEXT_PRIV
        ---help---
index 7d76a7f92a3359052fb757b0fb945b7f64542cf8..aaa70ed5771061b6d682a8fff245d541056e84db 100644 (file)
@@ -439,7 +439,7 @@ void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks)
                }
        }
        *nfchunks = 0;
-       memset(fchunk, 0, sizeof(fchunk));
+       memset(fchunk, 0, sizeof(*fchunk));
 
 }
 
index 6f8d8f971212f39f0a86b2ac424433bf201f424b..5066de5cfc0c5b3f2b9bc7709e09a1bb801b8bbc 100644 (file)
@@ -225,6 +225,12 @@ passive_store(struct device *dev, struct device_attribute *attr,
        if (!sscanf(buf, "%d\n", &state))
                return -EINVAL;
 
+       /* sanity check: values below 1000 millicelcius don't make sense
+        * and can cause the system to go into a thermal heart attack
+        */
+       if (state && state < 1000)
+               return -EINVAL;
+
        if (state && !tz->forced_passive) {
                mutex_lock(&thermal_list_lock);
                list_for_each_entry(cdev, &thermal_cdev_list, node) {
@@ -235,6 +241,8 @@ passive_store(struct device *dev, struct device_attribute *attr,
                                                                 cdev);
                }
                mutex_unlock(&thermal_list_lock);
+               if (!tz->passive_delay)
+                       tz->passive_delay = 1000;
        } else if (!state && tz->forced_passive) {
                mutex_lock(&thermal_list_lock);
                list_for_each_entry(cdev, &thermal_cdev_list, node) {
@@ -245,17 +253,12 @@ passive_store(struct device *dev, struct device_attribute *attr,
                                                                   cdev);
                }
                mutex_unlock(&thermal_list_lock);
+               tz->passive_delay = 0;
        }
 
        tz->tc1 = 1;
        tz->tc2 = 1;
 
-       if (!tz->passive_delay)
-               tz->passive_delay = 1000;
-
-       if (!tz->polling_delay)
-               tz->polling_delay = 10000;
-
        tz->forced_passive = state;
 
        thermal_zone_device_update(tz);
@@ -374,7 +377,7 @@ thermal_cooling_device_cur_state_store(struct device *dev,
        if (!sscanf(buf, "%ld\n", &state))
                return -EINVAL;
 
-       if (state < 0)
+       if ((long)state < 0)
                return -EINVAL;
 
        result = cdev->ops->set_cur_state(cdev, state);
@@ -1016,6 +1019,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
                thermal_zone_device_set_polling(tz, tz->passive_delay);
        else if (tz->polling_delay)
                thermal_zone_device_set_polling(tz, tz->polling_delay);
+       else
+               thermal_zone_device_set_polling(tz, 0);
        mutex_unlock(&tz->lock);
 }
 EXPORT_SYMBOL(thermal_zone_device_update);
index aa53db9f2e88309d739809adf10928fd0a6d1a57..1ef3b8fc50b33063ed3fa988dd7b7ea9740bde08 100644 (file)
@@ -210,7 +210,7 @@ static int uio_pdrv_genirq_runtime_nop(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops uio_pdrv_genirq_dev_pm_ops = {
+static const struct dev_pm_ops uio_pdrv_genirq_dev_pm_ops = {
        .runtime_suspend = uio_pdrv_genirq_runtime_nop,
        .runtime_resume = uio_pdrv_genirq_runtime_nop,
 };
index 473aa1a20de9bab61df2590d049994f8f178ba1e..be3c9b80bc9fb1bfda456f77fc9e83b681ca4dec 100644 (file)
@@ -44,5 +44,3 @@ obj-y                         += early/
 
 obj-$(CONFIG_USB_ATM)          += atm/
 obj-$(CONFIG_USB_SPEEDTOUCH)   += atm/
-
-obj-$(CONFIG_USB_ULPI)         += otg/
index 91f2885b6ee10ca8f6ca396289e0b1ea2ee7060b..2dcf906df569440d18a0cecb9b4801dec581e77f 100644 (file)
@@ -363,7 +363,7 @@ static int hcd_pci_restore(struct device *dev)
        return resume_common(dev, true);
 }
 
-struct dev_pm_ops usb_hcd_pci_pm_ops = {
+const struct dev_pm_ops usb_hcd_pci_pm_ops = {
        .suspend        = hcd_pci_suspend,
        .suspend_noirq  = hcd_pci_suspend_noirq,
        .resume_noirq   = hcd_pci_resume_noirq,
index 6dac3b802d41b5cbc1631b20ecf3cd7a72588385..0495fa651225546836af7ac78bad141df77eaf91 100644 (file)
@@ -1597,7 +1597,9 @@ rescan:
 }
 
 /**
- * Check whether a new bandwidth setting exceeds the bus bandwidth.
+ * usb_hcd_alloc_bandwidth - check whether a new bandwidth setting exceeds
+ *                             the bus bandwidth
+ * @udev: target &usb_device
  * @new_config: new configuration to install
  * @cur_alt: the current alternate interface setting
  * @new_alt: alternate interface setting that is being installed
index d8b43aee581e2d3c463efafcb396f9b8dd86a5e5..bbe2b924aae8d168f4876fff4debb7e0e1d3c96b 100644 (file)
@@ -330,7 +330,7 @@ extern void usb_hcd_pci_remove(struct pci_dev *dev);
 extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
 
 #ifdef CONFIG_PM_SLEEP
-extern struct dev_pm_ops       usb_hcd_pci_pm_ops;
+extern const struct dev_pm_ops usb_hcd_pci_pm_ops;
 #endif
 #endif /* CONFIG_PCI */
 
index 06af970e10641a7fd884cd9cb857a8a5e3c12382..0cec6caf6e9b26ca385927c6e6b19b67fabbfae2 100644 (file)
@@ -1658,12 +1658,12 @@ static inline void announce_device(struct usb_device *udev) { }
 #endif
 
 /**
- * usb_configure_device_otg - FIXME (usbcore-internal)
+ * usb_enumerate_device_otg - FIXME (usbcore-internal)
  * @udev: newly addressed device (in ADDRESS state)
  *
- * Do configuration for On-The-Go devices
+ * Finish enumeration for On-The-Go devices
  */
-static int usb_configure_device_otg(struct usb_device *udev)
+static int usb_enumerate_device_otg(struct usb_device *udev)
 {
        int err = 0;
 
@@ -1734,7 +1734,7 @@ fail:
 
 
 /**
- * usb_configure_device - Detect and probe device intfs/otg (usbcore-internal)
+ * usb_enumerate_device - Read device configs/intfs/otg (usbcore-internal)
  * @udev: newly addressed device (in ADDRESS state)
  *
  * This is only called by usb_new_device() and usb_authorize_device()
@@ -1745,7 +1745,7 @@ fail:
  * the string descriptors, as they will be errored out by the device
  * until it has been authorized.
  */
-static int usb_configure_device(struct usb_device *udev)
+static int usb_enumerate_device(struct usb_device *udev)
 {
        int err;
 
@@ -1769,7 +1769,7 @@ static int usb_configure_device(struct usb_device *udev)
                                                      udev->descriptor.iManufacturer);
                udev->serial = usb_cache_string(udev, udev->descriptor.iSerialNumber);
        }
-       err = usb_configure_device_otg(udev);
+       err = usb_enumerate_device_otg(udev);
 fail:
        return err;
 }
@@ -1779,8 +1779,8 @@ fail:
  * usb_new_device - perform initial device setup (usbcore-internal)
  * @udev: newly addressed device (in ADDRESS state)
  *
- * This is called with devices which have been enumerated, but not yet
- * configured.  The device descriptor is available, but not descriptors
+ * This is called with devices which have been detected but not fully
+ * enumerated.  The device descriptor is available, but not descriptors
  * for any device configuration.  The caller must have locked either
  * the parent hub (if udev is a normal device) or else the
  * usb_bus_list_lock (if udev is a root hub).  The parent's pointer to
@@ -1803,8 +1803,8 @@ int usb_new_device(struct usb_device *udev)
        if (udev->parent)
                usb_autoresume_device(udev->parent);
 
-       usb_detect_quirks(udev);                /* Determine quirks */
-       err = usb_configure_device(udev);       /* detect & probe dev/intfs */
+       usb_detect_quirks(udev);
+       err = usb_enumerate_device(udev);       /* Read descriptors */
        if (err < 0)
                goto fail;
        dev_dbg(&udev->dev, "udev %d, busnum %d, minor = %d\n",
@@ -1849,21 +1849,23 @@ fail:
  */
 int usb_deauthorize_device(struct usb_device *usb_dev)
 {
-       unsigned cnt;
        usb_lock_device(usb_dev);
        if (usb_dev->authorized == 0)
                goto out_unauthorized;
+
        usb_dev->authorized = 0;
        usb_set_configuration(usb_dev, -1);
+
+       kfree(usb_dev->product);
        usb_dev->product = kstrdup("n/a (unauthorized)", GFP_KERNEL);
+       kfree(usb_dev->manufacturer);
        usb_dev->manufacturer = kstrdup("n/a (unauthorized)", GFP_KERNEL);
+       kfree(usb_dev->serial);
        usb_dev->serial = kstrdup("n/a (unauthorized)", GFP_KERNEL);
-       kfree(usb_dev->config);
-       usb_dev->config = NULL;
-       for (cnt = 0; cnt < usb_dev->descriptor.bNumConfigurations; cnt++)
-               kfree(usb_dev->rawdescriptors[cnt]);
+
+       usb_destroy_configuration(usb_dev);
        usb_dev->descriptor.bNumConfigurations = 0;
-       kfree(usb_dev->rawdescriptors);
+
 out_unauthorized:
        usb_unlock_device(usb_dev);
        return 0;
@@ -1873,15 +1875,11 @@ out_unauthorized:
 int usb_authorize_device(struct usb_device *usb_dev)
 {
        int result = 0, c;
+
        usb_lock_device(usb_dev);
        if (usb_dev->authorized == 1)
                goto out_authorized;
-       kfree(usb_dev->product);
-       usb_dev->product = NULL;
-       kfree(usb_dev->manufacturer);
-       usb_dev->manufacturer = NULL;
-       kfree(usb_dev->serial);
-       usb_dev->serial = NULL;
+
        result = usb_autoresume_device(usb_dev);
        if (result < 0) {
                dev_err(&usb_dev->dev,
@@ -1894,10 +1892,18 @@ int usb_authorize_device(struct usb_device *usb_dev)
                        "authorization: %d\n", result);
                goto error_device_descriptor;
        }
+
+       kfree(usb_dev->product);
+       usb_dev->product = NULL;
+       kfree(usb_dev->manufacturer);
+       usb_dev->manufacturer = NULL;
+       kfree(usb_dev->serial);
+       usb_dev->serial = NULL;
+
        usb_dev->authorized = 1;
-       result = usb_configure_device(usb_dev);
+       result = usb_enumerate_device(usb_dev);
        if (result < 0)
-               goto error_configure;
+               goto error_enumerate;
        /* Choose and set the configuration.  This registers the interfaces
         * with the driver core and lets interface drivers bind to them.
         */
@@ -1912,8 +1918,10 @@ int usb_authorize_device(struct usb_device *usb_dev)
                }
        }
        dev_info(&usb_dev->dev, "authorized to connect\n");
-error_configure:
+
+error_enumerate:
 error_device_descriptor:
+       usb_autosuspend_device(usb_dev);
 error_autoresume:
 out_authorized:
        usb_unlock_device(usb_dev);     // complements locktree
index 15477008b63179fdd3f28443c508653be74a744e..485edf937f257ae846b921eae465f2655841f1b7 100644 (file)
@@ -82,9 +82,13 @@ static ssize_t  show_##name(struct device *dev,                              \
                struct device_attribute *attr, char *buf)               \
 {                                                                      \
        struct usb_device *udev;                                        \
+       int retval;                                                     \
                                                                        \
        udev = to_usb_device(dev);                                      \
-       return sprintf(buf, "%s\n", udev->name);                        \
+       usb_lock_device(udev);                                          \
+       retval = sprintf(buf, "%s\n", udev->name);                      \
+       usb_unlock_device(udev);                                        \
+       return retval;                                                  \
 }                                                                      \
 static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
 
index 4e2c6df8d3cc6b0427f3d7ffa645c0073531490e..0daff0d968ba48fd079f86e74e90dc190de109ea 100644 (file)
@@ -66,9 +66,9 @@ MODULE_PARM_DESC(autosuspend, "default autosuspend delay");
 /**
  * usb_find_alt_setting() - Given a configuration, find the alternate setting
  * for the given interface.
- * @config - the configuration to search (not necessarily the current config).
- * @iface_num - interface number to search in
- * @alt_num - alternate interface setting number to search for.
+ * @config: the configuration to search (not necessarily the current config).
+ * @iface_num: interface number to search in
+ * @alt_num: alternate interface setting number to search for.
  *
  * Search the configuration's interface cache for the given alt setting.
  */
@@ -167,18 +167,23 @@ struct usb_host_interface *usb_altnum_to_altsetting(
 }
 EXPORT_SYMBOL_GPL(usb_altnum_to_altsetting);
 
+struct find_interface_arg {
+       int minor;
+       struct device_driver *drv;
+};
+
 static int __find_interface(struct device *dev, void *data)
 {
-       int *minor = data;
+       struct find_interface_arg *arg = data;
        struct usb_interface *intf;
 
        if (!is_usb_interface(dev))
                return 0;
 
+       if (dev->driver != arg->drv)
+               return 0;
        intf = to_usb_interface(dev);
-       if (intf->minor != -1 && intf->minor == *minor)
-               return 1;
-       return 0;
+       return intf->minor == arg->minor;
 }
 
 /**
@@ -187,14 +192,18 @@ static int __find_interface(struct device *dev, void *data)
  * @minor: the minor number of the desired device
  *
  * This walks the bus device list and returns a pointer to the interface
- * with the matching minor.  Note, this only works for devices that share the
- * USB major number.
+ * with the matching minor and driver.  Note, this only works for devices
+ * that share the USB major number.
  */
 struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
 {
+       struct find_interface_arg argb;
        struct device *dev;
 
-       dev = bus_find_device(&usb_bus_type, NULL, &minor, __find_interface);
+       argb.minor = minor;
+       argb.drv = &drv->drvwrap.driver;
+
+       dev = bus_find_device(&usb_bus_type, NULL, &argb, __find_interface);
 
        /* Drop reference count from bus_find_device */
        put_device(dev);
@@ -320,7 +329,7 @@ static int usb_dev_restore(struct device *dev)
        return usb_resume(dev, PMSG_RESTORE);
 }
 
-static struct dev_pm_ops usb_device_pm_ops = {
+static const struct dev_pm_ops usb_device_pm_ops = {
        .prepare =      usb_dev_prepare,
        .complete =     usb_dev_complete,
        .suspend =      usb_dev_suspend,
index 1206a26ef893adf26dd6c498c4dc3bd9cf0ba7ab..2958a1271b20b5b82b7d6d448a30c848a11f5861 100644 (file)
@@ -613,7 +613,7 @@ err:
 }
 EXPORT_SYMBOL_GPL(dbgp_external_startup);
 
-static int __init ehci_reset_port(int port)
+static int ehci_reset_port(int port)
 {
        u32 portsc;
        u32 delay_time, delay;
index 58f2203238471ae06f0504ae26b71b53b27bd71f..a62af7b59094a19236701b9dac1d2609a874bc5f 100644 (file)
@@ -158,6 +158,7 @@ fail:
 
 static int __exit audio_unbind(struct usb_composite_dev *cdev)
 {
+       gaudio_cleanup();
        return 0;
 }
 
index c43c89ffa2c89b07fd690afeca58cb34651b0358..df77f6131c739ca1b7242a7fa03ba400f3cfc042 100644 (file)
@@ -56,13 +56,16 @@ static struct usb_interface_descriptor ac_interface_desc __initdata = {
 DECLARE_UAC_AC_HEADER_DESCRIPTOR(2);
 
 #define UAC_DT_AC_HEADER_LENGTH        UAC_DT_AC_HEADER_SIZE(F_AUDIO_NUM_INTERFACES)
+/* 1 input terminal, 1 output terminal and 1 feature unit */
+#define UAC_DT_TOTAL_LENGTH (UAC_DT_AC_HEADER_LENGTH + UAC_DT_INPUT_TERMINAL_SIZE \
+       + UAC_DT_OUTPUT_TERMINAL_SIZE + UAC_DT_FEATURE_UNIT_SIZE(0))
 /* B.3.2  Class-Specific AC Interface Descriptor */
 static struct uac_ac_header_descriptor_2 ac_header_desc = {
        .bLength =              UAC_DT_AC_HEADER_LENGTH,
        .bDescriptorType =      USB_DT_CS_INTERFACE,
        .bDescriptorSubtype =   UAC_HEADER,
        .bcdADC =               __constant_cpu_to_le16(0x0100),
-       .wTotalLength =         __constant_cpu_to_le16(UAC_DT_AC_HEADER_LENGTH),
+       .wTotalLength =         __constant_cpu_to_le16(UAC_DT_TOTAL_LENGTH),
        .bInCollection =        F_AUDIO_NUM_INTERFACES,
        .baInterfaceNr = {
                [0] =           F_AUDIO_AC_INTERFACE,
@@ -252,12 +255,12 @@ static struct f_audio_buf *f_audio_buffer_alloc(int buf_size)
 
        copy_buf = kzalloc(sizeof *copy_buf, GFP_ATOMIC);
        if (!copy_buf)
-               return (struct f_audio_buf *)-ENOMEM;
+               return ERR_PTR(-ENOMEM);
 
        copy_buf->buf = kzalloc(buf_size, GFP_ATOMIC);
        if (!copy_buf->buf) {
                kfree(copy_buf);
-               return (struct f_audio_buf *)-ENOMEM;
+               return ERR_PTR(-ENOMEM);
        }
 
        return copy_buf;
@@ -332,7 +335,7 @@ static int f_audio_out_ep_complete(struct usb_ep *ep, struct usb_request *req)
                list_add_tail(&copy_buf->list, &audio->play_queue);
                schedule_work(&audio->playback_work);
                copy_buf = f_audio_buffer_alloc(audio_buf_size);
-               if (copy_buf < 0)
+               if (IS_ERR(copy_buf))
                        return -ENOMEM;
        }
 
@@ -576,6 +579,8 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
                        usb_ep_enable(out_ep, audio->out_desc);
                        out_ep->driver_data = audio;
                        audio->copy_buf = f_audio_buffer_alloc(audio_buf_size);
+                       if (IS_ERR(audio->copy_buf))
+                               return -ENOMEM;
 
                        /*
                         * allocate a bunch of read buffers
@@ -787,7 +792,7 @@ int __init audio_bind_config(struct usb_configuration *c)
        return status;
 
 add_fail:
-       gaudio_cleanup(&audio->card);
+       gaudio_cleanup();
 setup_fail:
        kfree(audio);
        return status;
index 8252595d619d1a456e8e4f72db4096b996a1286e..35e0930f5bbb7c4927bceb6523af63e5562a59b8 100644 (file)
@@ -288,6 +288,7 @@ static int gaudio_close_snd_dev(struct gaudio *gau)
        return 0;
 }
 
+static struct gaudio *the_card;
 /**
  * gaudio_setup - setup ALSA interface and preparing for USB transfer
  *
@@ -303,6 +304,9 @@ int __init gaudio_setup(struct gaudio *card)
        if (ret)
                ERROR(card, "we need at least one control device\n");
 
+       if (!the_card)
+               the_card = card;
+
        return ret;
 
 }
@@ -312,9 +316,11 @@ int __init gaudio_setup(struct gaudio *card)
  *
  * This is called to free all resources allocated by @gaudio_setup().
  */
-void gaudio_cleanup(struct gaudio *card)
+void gaudio_cleanup(void)
 {
-       if (card)
-               gaudio_close_snd_dev(card);
+       if (the_card) {
+               gaudio_close_snd_dev(the_card);
+               the_card = NULL;
+       }
 }
 
index cc8d159c648a7eeeca119d07d804e5d00826df31..08ffce3298e6a99c56f2541279cf830408bcbf22 100644 (file)
@@ -51,6 +51,6 @@ struct gaudio {
 };
 
 int gaudio_setup(struct gaudio *card);
-void gaudio_cleanup(struct gaudio *card);
+void gaudio_cleanup(void);
 
 #endif /* __U_AUDIO_H */
index ed77be76d6bb0102f4a6078a2b76f65d769ce1ac..dbfb482a94e37a7389c2d9c13681a5c9da408325 100644 (file)
@@ -297,7 +297,7 @@ static int ehci_hcd_au1xxx_drv_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops au1xxx_ehci_pmops = {
+static const struct dev_pm_ops au1xxx_ehci_pmops = {
        .suspend        = ehci_hcd_au1xxx_drv_suspend,
        .resume         = ehci_hcd_au1xxx_drv_resume,
 };
index 12f1ad2fd0e81282cf3937dc2168822b4f8fc686..74d07f4e8b7d48d74f9ea119d350ab6aed8a2dd1 100644 (file)
@@ -37,7 +37,7 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/gpio.h>
-#include <mach/usb.h>
+#include <plat/usb.h>
 
 /*
  * OMAP USBHOST Register addresses: VIRTUAL ADDRESSES
index 00a29855d0c41f777760e7efc16c7dde83746b7c..ff43747a614fb1fd0d09c60cfddb25def4526f07 100644 (file)
@@ -37,7 +37,7 @@ static void recycle_frame(struct fhci_usb *usb, struct packet *pkt)
        pkt->info = 0;
        pkt->priv_data = NULL;
 
-       cq_put(usb->ep0->empty_frame_Q, pkt);
+       cq_put(&usb->ep0->empty_frame_Q, pkt);
 }
 
 /* confirm submitted packet */
@@ -57,7 +57,7 @@ void fhci_transaction_confirm(struct fhci_usb *usb, struct packet *pkt)
                if ((td->data + td->actual_len) && trans_len)
                        memcpy(td->data + td->actual_len, pkt->data,
                               trans_len);
-               cq_put(usb->ep0->dummy_packets_Q, pkt->data);
+               cq_put(&usb->ep0->dummy_packets_Q, pkt->data);
        }
 
        recycle_frame(usb, pkt);
@@ -213,7 +213,7 @@ static int add_packet(struct fhci_usb *usb, struct ed *ed, struct td *td)
        }
 
        /* update frame object fields before transmitting */
-       pkt = cq_get(usb->ep0->empty_frame_Q);
+       pkt = cq_get(&usb->ep0->empty_frame_Q);
        if (!pkt) {
                fhci_dbg(usb->fhci, "there is no empty frame\n");
                return -1;
@@ -222,7 +222,7 @@ static int add_packet(struct fhci_usb *usb, struct ed *ed, struct td *td)
 
        pkt->info = 0;
        if (data == NULL) {
-               data = cq_get(usb->ep0->dummy_packets_Q);
+               data = cq_get(&usb->ep0->dummy_packets_Q);
                BUG_ON(!data);
                pkt->info = PKT_DUMMY_PACKET;
        }
@@ -246,7 +246,7 @@ static int add_packet(struct fhci_usb *usb, struct ed *ed, struct td *td)
                list_del_init(&td->frame_lh);
                td->status = USB_TD_OK;
                if (pkt->info & PKT_DUMMY_PACKET)
-                       cq_put(usb->ep0->dummy_packets_Q, pkt->data);
+                       cq_put(&usb->ep0->dummy_packets_Q, pkt->data);
                recycle_frame(usb, pkt);
                usb->actual_frame->total_bytes -= (len + PROTOCOL_OVERHEAD);
                fhci_err(usb->fhci, "host transaction failed\n");
index b403322903193a3aa63a684029a1aa9b487e6df1..d224ab467a401d729b13b2d8c9f44f380616f184 100644 (file)
@@ -106,33 +106,33 @@ void fhci_ep0_free(struct fhci_usb *usb)
                        cpm_muram_free(cpm_muram_offset(ep->td_base));
 
                if (ep->conf_frame_Q) {
-                       size = cq_howmany(ep->conf_frame_Q);
+                       size = cq_howmany(&ep->conf_frame_Q);
                        for (; size; size--) {
-                               struct packet *pkt = cq_get(ep->conf_frame_Q);
+                               struct packet *pkt = cq_get(&ep->conf_frame_Q);
 
                                kfree(pkt);
                        }
-                       cq_delete(ep->conf_frame_Q);
+                       cq_delete(&ep->conf_frame_Q);
                }
 
                if (ep->empty_frame_Q) {
-                       size = cq_howmany(ep->empty_frame_Q);
+                       size = cq_howmany(&ep->empty_frame_Q);
                        for (; size; size--) {
-                               struct packet *pkt = cq_get(ep->empty_frame_Q);
+                               struct packet *pkt = cq_get(&ep->empty_frame_Q);
 
                                kfree(pkt);
                        }
-                       cq_delete(ep->empty_frame_Q);
+                       cq_delete(&ep->empty_frame_Q);
                }
 
                if (ep->dummy_packets_Q) {
-                       size = cq_howmany(ep->dummy_packets_Q);
+                       size = cq_howmany(&ep->dummy_packets_Q);
                        for (; size; size--) {
-                               u8 *buff = cq_get(ep->dummy_packets_Q);
+                               u8 *buff = cq_get(&ep->dummy_packets_Q);
 
                                kfree(buff);
                        }
-                       cq_delete(ep->dummy_packets_Q);
+                       cq_delete(&ep->dummy_packets_Q);
                }
 
                kfree(ep);
@@ -175,10 +175,9 @@ u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
        ep->td_base = cpm_muram_addr(ep_offset);
 
        /* zero all queue pointers */
-       ep->conf_frame_Q = cq_new(ring_len + 2);
-       ep->empty_frame_Q = cq_new(ring_len + 2);
-       ep->dummy_packets_Q = cq_new(ring_len + 2);
-       if (!ep->conf_frame_Q || !ep->empty_frame_Q || !ep->dummy_packets_Q) {
+       if (cq_new(&ep->conf_frame_Q, ring_len + 2) ||
+           cq_new(&ep->empty_frame_Q, ring_len + 2) ||
+           cq_new(&ep->dummy_packets_Q, ring_len + 2)) {
                err_for = "frame_queues";
                goto err;
        }
@@ -199,8 +198,8 @@ u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
                        err_for = "buffer";
                        goto err;
                }
-               cq_put(ep->empty_frame_Q, pkt);
-               cq_put(ep->dummy_packets_Q, buff);
+               cq_put(&ep->empty_frame_Q, pkt);
+               cq_put(&ep->dummy_packets_Q, buff);
        }
 
        /* we put the endpoint parameter RAM right behind the TD ring */
@@ -319,7 +318,7 @@ static void fhci_td_transaction_confirm(struct fhci_usb *usb)
                if ((buf == DUMMY2_BD_BUFFER) && !(td_status & ~TD_W))
                        continue;
 
-               pkt = cq_get(ep->conf_frame_Q);
+               pkt = cq_get(&ep->conf_frame_Q);
                if (!pkt)
                        fhci_err(usb->fhci, "no frame to confirm\n");
 
@@ -460,9 +459,9 @@ u32 fhci_host_transaction(struct fhci_usb *usb,
                out_be16(&td->length, pkt->len);
 
        /* put the frame to the confirmation queue */
-       cq_put(ep->conf_frame_Q, pkt);
+       cq_put(&ep->conf_frame_Q, pkt);
 
-       if (cq_howmany(ep->conf_frame_Q) == 1)
+       if (cq_howmany(&ep->conf_frame_Q) == 1)
                out_8(&usb->fhci->regs->usb_comm, USB_CMD_STR_FIFO);
 
        return 0;
index 7116284ed21ab9abdc6b6d69b93b616ebc1cdc94..72dae1c5ab3818202996df091c8d9d583bf7e3f3 100644 (file)
@@ -423,9 +423,9 @@ struct endpoint {
        struct usb_td __iomem *td_base; /* first TD in the ring */
        struct usb_td __iomem *conf_td; /* next TD for confirm after transac */
        struct usb_td __iomem *empty_td;/* next TD for new transaction req. */
-       struct kfifo *empty_frame_Q;  /* Empty frames list to use */
-       struct kfifo *conf_frame_Q;   /* frames passed to TDs,waiting for tx */
-       struct kfifo *dummy_packets_Q;/* dummy packets for the CRC overun */
+       struct kfifo empty_frame_Q;  /* Empty frames list to use */
+       struct kfifo conf_frame_Q;   /* frames passed to TDs,waiting for tx */
+       struct kfifo dummy_packets_Q;/* dummy packets for the CRC overun */
 
        bool already_pushed_dummy_bd;
 };
@@ -493,9 +493,9 @@ static inline struct usb_hcd *fhci_to_hcd(struct fhci_hcd *fhci)
 }
 
 /* fifo of pointers */
-static inline struct kfifo *cq_new(int size)
+static inline int cq_new(struct kfifo *fifo, int size)
 {
-       return kfifo_alloc(size * sizeof(void *), GFP_KERNEL, NULL);
+       return kfifo_alloc(fifo, size * sizeof(void *), GFP_KERNEL);
 }
 
 static inline void cq_delete(struct kfifo *kfifo)
@@ -505,19 +505,19 @@ static inline void cq_delete(struct kfifo *kfifo)
 
 static inline unsigned int cq_howmany(struct kfifo *kfifo)
 {
-       return __kfifo_len(kfifo) / sizeof(void *);
+       return kfifo_len(kfifo) / sizeof(void *);
 }
 
 static inline int cq_put(struct kfifo *kfifo, void *p)
 {
-       return __kfifo_put(kfifo, (void *)&p, sizeof(p));
+       return kfifo_in(kfifo, (void *)&p, sizeof(p));
 }
 
 static inline void *cq_get(struct kfifo *kfifo)
 {
        void *p = NULL;
 
-       __kfifo_get(kfifo, (void *)&p, sizeof(p));
+       kfifo_out(kfifo, (void *)&p, sizeof(p));
        return p;
 }
 
index 5c774ab9825272ead015fe3420f00a71dba81616..73352f3739b5ee654cdcd24f0be85495eeebcc58 100644 (file)
@@ -80,7 +80,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/io.h>
-#include <linux/bitops.h>
+#include <linux/bitmap.h>
 
 #include <asm/irq.h>
 #include <asm/system.h>
@@ -190,10 +190,8 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq,
                             struct isp1362_ep *ep, u16 len)
 {
        int ptd_offset = -EINVAL;
-       int index;
        int num_ptds = ((len + PTD_HEADER_SIZE - 1) / epq->blk_size) + 1;
-       int found = -1;
-       int last = -1;
+       int found;
 
        BUG_ON(len > epq->buf_size);
 
@@ -205,20 +203,9 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq,
                    epq->name, len, epq->blk_size, num_ptds, epq->buf_map, epq->skip_map);
        BUG_ON(ep->num_ptds != 0);
 
-       for (index = 0; index <= epq->buf_count - num_ptds; index++) {
-               if (test_bit(index, &epq->buf_map))
-                       continue;
-               found = index;
-               for (last = index + 1; last < index + num_ptds; last++) {
-                       if (test_bit(last, &epq->buf_map)) {
-                               found = -1;
-                               break;
-                       }
-               }
-               if (found >= 0)
-                       break;
-       }
-       if (found < 0)
+       found = bitmap_find_next_zero_area(&epq->buf_map, epq->buf_count, 0,
+                                               num_ptds, 0);
+       if (found >= epq->buf_count)
                return -EOVERFLOW;
 
        DBG(1, "%s: Found %d PTDs[%d] for %d/%d byte\n", __func__,
@@ -230,8 +217,7 @@ static int claim_ptd_buffers(struct isp1362_ep_queue *epq,
        epq->buf_avail -= num_ptds;
        BUG_ON(epq->buf_avail > epq->buf_count);
        ep->ptd_index = found;
-       for (index = found; index < last; index++)
-               __set_bit(index, &epq->buf_map);
+       bitmap_set(&epq->buf_map, found, num_ptds);
        DBG(1, "%s: Done %s PTD[%d] $%04x, avail %d count %d claimed %d %08lx:%08lx\n",
            __func__, epq->name, ep->ptd_index, ep->ptd_offset,
            epq->buf_avail, epq->buf_count, num_ptds, epq->buf_map, epq->skip_map);
index e4380082ebb110a0e77a8b509da9cc72e66837d2..17a6043c1fa072cba3d84c01fe8f6ba83005fff3 100644 (file)
@@ -294,7 +294,7 @@ static int ohci_hcd_au1xxx_drv_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops au1xxx_ohci_pmops = {
+static const struct dev_pm_ops au1xxx_ohci_pmops = {
        .suspend        = ohci_hcd_au1xxx_drv_suspend,
        .resume         = ohci_hcd_au1xxx_drv_resume,
 };
index f1c06202fdf22d8630cc5647509a10c17a77bc97..a18debdd79b8cec346f7f625baf66a47800affd1 100644 (file)
@@ -518,7 +518,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops ohci_hcd_pxa27x_pm_ops = {
+static const struct dev_pm_ops ohci_hcd_pxa27x_pm_ops = {
        .suspend        = ohci_hcd_pxa27x_drv_suspend,
        .resume         = ohci_hcd_pxa27x_drv_resume,
 };
index 41dbc70ae752eaf41332807d4be86905801c47a8..b7a661c02bcdb5d3edf0a84b39a50a41f2bf411c 100644 (file)
@@ -2353,7 +2353,7 @@ static int r8a66597_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops r8a66597_dev_pm_ops = {
+static const struct dev_pm_ops r8a66597_dev_pm_ops = {
        .suspend = r8a66597_suspend,
        .resume = r8a66597_resume,
        .poweroff = r8a66597_suspend,
index 1d8e39a557d9992509822e12e78bf7bbe41cbb93..1eb9e4162cc6a916a3ed8cce7641be7ffb2aa529 100644 (file)
@@ -60,6 +60,7 @@
 static struct usb_device_id appledisplay_table [] = {
        { APPLEDISPLAY_DEVICE(0x9218) },
        { APPLEDISPLAY_DEVICE(0x9219) },
+       { APPLEDISPLAY_DEVICE(0x921c) },
        { APPLEDISPLAY_DEVICE(0x921d) },
 
        /* Terminating entry */
@@ -72,8 +73,8 @@ struct appledisplay {
        struct usb_device *udev;        /* usb device */
        struct urb *urb;                /* usb request block */
        struct backlight_device *bd;    /* backlight device */
-       char *urbdata;                  /* interrupt URB data buffer */
-       char *msgdata;                  /* control message data buffer */
+       u8 *urbdata;                    /* interrupt URB data buffer */
+       u8 *msgdata;                    /* control message data buffer */
 
        struct delayed_work work;
        int button_pressed;
index 602ee05ba9ff928bd59338690959840cf12ef5d2..59860b328534d893a8075f7cb2681a77f6fe69ce 100644 (file)
@@ -167,7 +167,7 @@ static int emi62_load_firmware (struct usb_device *dev)
                        err("%s - error loading firmware: error = %d", __func__, err);
                        goto wraperr;
                }
-       } while (i > 0);
+       } while (rec);
 
        /* Assert reset (stop the CPU in the EMI) */
        err = emi62_set_reset(dev,1);
index fe4934d9602c9a66d98d1498d5bd5d99a85f2337..ad26e656966510f84ef0244a7f57a56a3faa82c8 100644 (file)
@@ -29,6 +29,8 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
 {
        void __iomem *fifo = hw_ep->fifo;
        void __iomem *epio = hw_ep->regs;
+       u8 epnum = hw_ep->epnum;
+       u16 dma_reg = 0;
 
        prefetch((u8 *)src);
 
@@ -39,67 +41,113 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
 
        dump_fifo_data(src, len);
 
-       if (unlikely((unsigned long)src & 0x01))
-               outsw_8((unsigned long)fifo, src,
-                       len & 0x01 ? (len >> 1) + 1 : len >> 1);
-       else
-               outsw((unsigned long)fifo, src,
-                       len & 0x01 ? (len >> 1) + 1 : len >> 1);
-}
+       if (!ANOMALY_05000380 && epnum != 0) {
+               flush_dcache_range((unsigned int)src,
+                       (unsigned int)(src + len));
+
+               /* Setup DMA address register */
+               dma_reg = (u16) ((u32) src & 0xFFFF);
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg);
+               SSYNC();
+
+               dma_reg = (u16) (((u32) src >> 16) & 0xFFFF);
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg);
+               SSYNC();
+
+               /* Setup DMA count register */
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_LOW), len);
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_HIGH), 0);
+               SSYNC();
+
+               /* Enable the DMA */
+               dma_reg = (epnum << 4) | DMA_ENA | INT_ENA | DIRECTION;
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg);
+               SSYNC();
+
+               /* Wait for compelete */
+               while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum)))
+                       cpu_relax();
+
+               /* acknowledge dma interrupt */
+               bfin_write_USB_DMA_INTERRUPT(1 << epnum);
+               SSYNC();
+
+               /* Reset DMA */
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), 0);
+               SSYNC();
+       } else {
+               SSYNC();
+
+               if (unlikely((unsigned long)src & 0x01))
+                       outsw_8((unsigned long)fifo, src,
+                               len & 0x01 ? (len >> 1) + 1 : len >> 1);
+               else
+                       outsw((unsigned long)fifo, src,
+                               len & 0x01 ? (len >> 1) + 1 : len >> 1);
 
+       }
+}
 /*
  * Unload an endpoint's FIFO
  */
 void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
 {
        void __iomem *fifo = hw_ep->fifo;
-
-#ifdef CONFIG_BF52x
        u8 epnum = hw_ep->epnum;
        u16 dma_reg = 0;
 
-       invalidate_dcache_range((unsigned int)dst,
-               (unsigned int)(dst + len));
+       if (ANOMALY_05000467 && epnum != 0) {
 
-       /* Setup DMA address register */
-       dma_reg = (u16) ((u32) dst & 0xFFFF);
-       bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg);
-       SSYNC();
+               invalidate_dcache_range((unsigned int)dst,
+                       (unsigned int)(dst + len));
 
-       dma_reg = (u16) (((u32) dst >> 16) & 0xFFFF);
-       bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg);
-       SSYNC();
+               /* Setup DMA address register */
+               dma_reg = (u16) ((u32) dst & 0xFFFF);
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg);
+               SSYNC();
 
-       /* Setup DMA count register */
-       bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_LOW), len);
-       bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_HIGH), 0);
-       SSYNC();
+               dma_reg = (u16) (((u32) dst >> 16) & 0xFFFF);
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg);
+               SSYNC();
 
-       /* Enable the DMA */
-       dma_reg = (epnum << 4) | DMA_ENA | INT_ENA;
-       bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg);
-       SSYNC();
+               /* Setup DMA count register */
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_LOW), len);
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_HIGH), 0);
+               SSYNC();
 
-       /* Wait for compelete */
-       while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum)))
-               cpu_relax();
+               /* Enable the DMA */
+               dma_reg = (epnum << 4) | DMA_ENA | INT_ENA;
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg);
+               SSYNC();
 
-       /* acknowledge dma interrupt */
-       bfin_write_USB_DMA_INTERRUPT(1 << epnum);
-       SSYNC();
+               /* Wait for compelete */
+               while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum)))
+                       cpu_relax();
 
-       /* Reset DMA */
-       bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), 0);
-       SSYNC();
-#else
-       if (unlikely((unsigned long)dst & 0x01))
-               insw_8((unsigned long)fifo, dst,
-                       len & 0x01 ? (len >> 1) + 1 : len >> 1);
-       else
-               insw((unsigned long)fifo, dst,
-                       len & 0x01 ? (len >> 1) + 1 : len >> 1);
-#endif
+               /* acknowledge dma interrupt */
+               bfin_write_USB_DMA_INTERRUPT(1 << epnum);
+               SSYNC();
 
+               /* Reset DMA */
+               bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), 0);
+               SSYNC();
+       } else {
+               SSYNC();
+               /* Read the last byte of packet with odd size from address fifo + 4
+                * to trigger 1 byte access to EP0 FIFO.
+                */
+               if (len == 1)
+                       *dst = (u8)inw((unsigned long)fifo + 4);
+               else {
+                       if (unlikely((unsigned long)dst & 0x01))
+                               insw_8((unsigned long)fifo, dst, len >> 1);
+                       else
+                               insw((unsigned long)fifo, dst, len >> 1);
+
+                       if (len & 0x01)
+                               *(dst + len - 1) = (u8)inw((unsigned long)fifo + 4);
+               }
+       }
        DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
                        'R', hw_ep->epnum, fifo, len, dst);
 
index 10b7d7584f4b99e7d6818772a853516e97aec057..bd9352a2ef2a0b89f867121f998a9d3ef486bbed 100644 (file)
@@ -69,7 +69,6 @@ static void dump_fifo_data(u8 *buf, u16 len)
 #define dump_fifo_data(buf, len)       do {} while (0)
 #endif
 
-#ifdef CONFIG_BF52x
 
 #define USB_DMA_BASE           USB_DMA_INTERRUPT
 #define USB_DMAx_CTRL          0x04
@@ -79,7 +78,6 @@ static void dump_fifo_data(u8 *buf, u16 len)
 #define USB_DMAx_COUNT_HIGH    0x14
 
 #define USB_DMA_REG(ep, reg)   (USB_DMA_BASE + 0x20 * ep + reg)
-#endif
 
 /* Almost 1 second */
 #define TIMER_DELAY    (1 * HZ)
index ef2332a9941dec7a39c25d52a69b4fce3943771d..a44a450c860d9e248c3c317d437c67abc4694a8f 100644 (file)
@@ -1154,8 +1154,11 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
        struct musb_hw_ep       *hw_ep = NULL;
        u32                     rx, tx;
        int                     i, index;
+       unsigned long           flags;
 
        cppi = container_of(musb->dma_controller, struct cppi, controller);
+       if (cppi->irq)
+               spin_lock_irqsave(&musb->lock, flags);
 
        tibase = musb->ctrl_base;
 
@@ -1285,6 +1288,9 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id)
        /* write to CPPI EOI register to re-enable interrupts */
        musb_writel(tibase, DAVINCI_CPPI_EOI_REG, 0);
 
+       if (cppi->irq)
+               spin_unlock_irqrestore(&musb->lock, flags);
+
        return IRQ_HANDLED;
 }
 
index e16ff605c458aa5a5b29e224deec2033adb96851..66913811af5e84a4cc433ce6f00c4d8918b66383 100644 (file)
@@ -42,7 +42,7 @@
 #include "musb_core.h"
 
 #ifdef CONFIG_MACH_DAVINCI_EVM
-#define GPIO_nVBUS_DRV         144
+#define GPIO_nVBUS_DRV         160
 #endif
 
 #include "davinci.h"
index 49f2346afad3e8016d5f548e6f74d57b7322d49a..5eb9318cff77baffd12aef9d4767430df4524dcd 100644 (file)
@@ -1319,7 +1319,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
 #endif
        u8 reg;
        char *type;
-       char aInfo[78], aRevision[32], aDate[12];
+       char aInfo[90], aRevision[32], aDate[12];
        void __iomem    *mbase = musb->mregs;
        int             status = 0;
        int             i;
@@ -1521,6 +1521,14 @@ irqreturn_t musb_interrupt(struct musb *musb)
                (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral",
                musb->int_usb, musb->int_tx, musb->int_rx);
 
+#ifdef CONFIG_USB_GADGET_MUSB_HDRC
+       if (is_otg_enabled(musb) || is_peripheral_enabled(musb))
+               if (!musb->gadget_driver) {
+                       DBG(5, "No gadget driver loaded\n");
+                       return IRQ_HANDLED;
+               }
+#endif
+
        /* the core can interrupt us for multiple reasons; docs have
         * a generic interrupt flowchart to follow
         */
@@ -2139,7 +2147,7 @@ static int __init musb_probe(struct platform_device *pdev)
        return musb_init_controller(dev, irq, base);
 }
 
-static int __devexit musb_remove(struct platform_device *pdev)
+static int __exit musb_remove(struct platform_device *pdev)
 {
        struct musb     *musb = dev_to_musb(&pdev->dev);
        void __iomem    *ctrl_base = musb->ctrl_base;
@@ -2214,7 +2222,7 @@ static int musb_resume_noirq(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops musb_dev_pm_ops = {
+static const struct dev_pm_ops musb_dev_pm_ops = {
        .suspend        = musb_suspend,
        .resume_noirq   = musb_resume_noirq,
 };
@@ -2231,7 +2239,7 @@ static struct platform_driver musb_driver = {
                .owner          = THIS_MODULE,
                .pm             = MUSB_DEV_PM_OPS,
        },
-       .remove         = __devexit_p(musb_remove),
+       .remove         = __exit_p(musb_remove),
        .shutdown       = musb_shutdown,
 };
 
index c49b9ba025ab2a75daa6794c4eedc97bcd8e87b1..cbcf14a236e6e3a19e80bfcd8e19af257ce5a727 100644 (file)
@@ -309,7 +309,7 @@ static void txstate(struct musb *musb, struct musb_request *req)
                        size_t request_size;
 
                        /* setup DMA, then program endpoint CSR */
-                       request_size = min(request->length,
+                       request_size = min_t(size_t, request->length,
                                                musb_ep->dma->max_len);
                        if (request_size < musb_ep->packet_sz)
                                musb_ep->dma->desired_mode = 0;
@@ -319,7 +319,7 @@ static void txstate(struct musb *musb, struct musb_request *req)
                        use_dma = use_dma && c->channel_program(
                                        musb_ep->dma, musb_ep->packet_sz,
                                        musb_ep->dma->desired_mode,
-                                       request->dma, request_size);
+                                       request->dma + request->actual, request_size);
                        if (use_dma) {
                                if (musb_ep->dma->desired_mode == 0) {
                                        /*
@@ -515,12 +515,12 @@ void musb_g_tx(struct musb *musb, u8 epnum)
                        if (csr & MUSB_TXCSR_FIFONOTEMPTY)
                                return;
 
-                       if (!musb_ep->desc) {
+                       request = musb_ep->desc ? next_request(musb_ep) : NULL;
+                       if (!request) {
                                DBG(4, "%s idle now\n",
                                        musb_ep->end_point.name);
                                return;
-                       } else
-                               request = next_request(musb_ep);
+                       }
                }
 
                txstate(musb, to_musb_request(request));
@@ -746,6 +746,8 @@ void musb_g_rx(struct musb *musb, u8 epnum)
        musb_ep_select(mbase, epnum);
 
        request = next_request(musb_ep);
+       if (!request)
+               return;
 
        csr = musb_readw(epio, MUSB_RXCSR);
        dma = is_dma_capable() ? musb_ep->dma : NULL;
@@ -1731,6 +1733,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
                spin_lock_irqsave(&musb->lock, flags);
 
                otg_set_peripheral(musb->xceiv, &musb->g);
+               musb->xceiv->state = OTG_STATE_B_IDLE;
                musb->is_active = 1;
 
                /* FIXME this ignores the softconnect flag.  Drivers are
index 8fba3f11e473eaeb45502eef094506bd732cb5bd..53d06451f820348fbe3a7907ce448ffd7d82bd39 100644 (file)
@@ -664,7 +664,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
                        musb->ep0_state = MUSB_EP0_STAGE_STATUSIN;
                        break;
                default:
-                       ERR("SetupEnd came in a wrong ep0stage %s",
+                       ERR("SetupEnd came in a wrong ep0stage %s\n",
                            decode_ep0stage(musb->ep0_state));
                }
                csr = musb_readw(regs, MUSB_CSR0);
@@ -787,12 +787,18 @@ setup:
                                handled = service_zero_data_request(
                                                musb, &setup);
 
+                               /*
+                                * We're expecting no data in any case, so
+                                * always set the DATAEND bit -- doing this
+                                * here helps avoid SetupEnd interrupt coming
+                                * in the idle stage when we're stalling...
+                                */
+                               musb->ackpend |= MUSB_CSR0_P_DATAEND;
+
                                /* status stage might be immediate */
-                               if (handled > 0) {
-                                       musb->ackpend |= MUSB_CSR0_P_DATAEND;
+                               if (handled > 0)
                                        musb->ep0_state =
                                                MUSB_EP0_STAGE_STATUSIN;
-                               }
                                break;
 
                        /* sequence #1 (IN to host), includes GET_STATUS
index d54460a88173fba5dfc96ec84bab3bf557a69916..78a2097092602f35291cc62650bde87300072cb7 100644 (file)
@@ -843,7 +843,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
 
 static struct platform_device *otg_dev;
 
-static int otg_init(struct isp1301 *isp)
+static int isp1301_otg_init(struct isp1301 *isp)
 {
        u32 l;
 
@@ -1275,7 +1275,7 @@ static int __exit isp1301_remove(struct i2c_client *i2c)
 static int isp1301_otg_enable(struct isp1301 *isp)
 {
        power_up(isp);
-       otg_init(isp);
+       isp1301_otg_init(isp);
 
        /* NOTE:  since we don't change this, this provides
         * a few more interrupts than are strictly needed.
index f99498fca99a3c4ed67b39675e7546a93fa96894..216f187582ab4ea17ffe40234a2300c78f3d99a5 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/serial.h>
 #include <linux/usb/serial.h>
 #include "ftdi_sio.h"
+#include "ftdi_sio_ids.h"
 
 /*
  * Version Information
index 4586a24fafb020c5f128c6b385cc10d1611b887c..b0e0d64f822e27b9bcf0c076d34e67ddecdebea5 100644 (file)
@@ -1,7 +1,10 @@
 /*
- * Definitions for the FTDI USB Single Port Serial Converter -
+ * Driver definitions for the FTDI USB Single Port Serial Converter -
  * known as FTDI_SIO (Serial Input/Output application of the chipset)
  *
+ * For USB vendor/product IDs (VID/PID), please see ftdi_sio_ids.h
+ *
+ *
  * The example I have is known as the USC-1000 which is available from
  * http://www.dse.co.nz - cat no XH4214 It looks similar to this:
  * http://www.dansdata.com/usbser.htm but I can't be sure There are other
  * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
  * FTDI_SIO implementation.
  *
- * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais
- * from Rudolf Gugler
- *
- */
-
-#define FTDI_VID       0x0403  /* Vendor Id */
-#define FTDI_SIO_PID   0x8372  /* Product Id SIO application of 8U100AX  */
-#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
-#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
-#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
-#define FTDI_232RL_PID  0xFBFA  /* Product ID for FT232RL */
-#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
-#define FTDI_RELAIS_PID        0xFA10  /* Relais device from Rudolf Gugler */
-#define FTDI_NF_RIC_VID        0x0DCD  /* Vendor Id */
-#define FTDI_NF_RIC_PID        0x0001  /* Product Id */
-#define FTDI_USBX_707_PID 0xF857       /* ADSTech IR Blaster USBX-707 */
-
-/* Larsen and Brusgaard AltiTrack/USBtrack  */
-#define LARSENBRUSGAARD_VID            0x0FD8
-#define LB_ALTITRACK_PID               0x0001
-
-/* www.canusb.com Lawicel CANUSB device */
-#define FTDI_CANUSB_PID 0xFFA8 /* Product Id */
-
-/* AlphaMicro Components AMC-232USB01 device */
-#define FTDI_AMC232_PID 0xFF00 /* Product Id */
-
-/* www.candapter.com Ewert Energy Systems CANdapter device */
-#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
-
-/* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */
-/* the VID is the standard ftdi vid (FTDI_VID) */
-#define FTDI_SCS_DEVICE_0_PID 0xD010    /* SCS PTC-IIusb */
-#define FTDI_SCS_DEVICE_1_PID 0xD011    /* SCS Tracker / DSP TNC */
-#define FTDI_SCS_DEVICE_2_PID 0xD012
-#define FTDI_SCS_DEVICE_3_PID 0xD013
-#define FTDI_SCS_DEVICE_4_PID 0xD014
-#define FTDI_SCS_DEVICE_5_PID 0xD015
-#define FTDI_SCS_DEVICE_6_PID 0xD016
-#define FTDI_SCS_DEVICE_7_PID 0xD017
-
-/* ACT Solutions HomePro ZWave interface (http://www.act-solutions.com/HomePro.htm) */
-#define FTDI_ACTZWAVE_PID      0xF2D0
-
-
-/* www.starting-point-systems.com ÂµChameleon device */
-#define FTDI_MICRO_CHAMELEON_PID       0xCAA0  /* Product Id */
-
-/* www.irtrans.de device */
-#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */
-
-
-/* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */
-#define FTDI_TTUSB_PID 0xFF20 /* Product Id */
-
-/* iPlus device */
-#define FTDI_IPLUS_PID 0xD070 /* Product Id */
-#define FTDI_IPLUS2_PID 0xD071 /* Product Id */
-
-/* DMX4ALL DMX Interfaces */
-#define FTDI_DMX4ALL 0xC850
-
-/* OpenDCC (www.opendcc.de) product id */
-#define FTDI_OPENDCC_PID       0xBFD8
-#define FTDI_OPENDCC_SNIFFER_PID       0xBFD9
-#define FTDI_OPENDCC_THROTTLE_PID      0xBFDA
-#define FTDI_OPENDCC_GATEWAY_PID       0xBFDB
-
-/* Sprog II (Andrew Crosland's SprogII DCC interface) */
-#define FTDI_SPROG_II          0xF0C8
-
-/* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */
-/* they use the ftdi chipset for the USB interface and the vendor id is the same */
-#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
-#define FTDI_XF_634_PID 0xFC09 /* 634: 20x4 Character Display */
-#define FTDI_XF_547_PID 0xFC0A /* 547: Two line Display */
-#define FTDI_XF_633_PID 0xFC0B /* 633: 16x2 Character Display with Keys */
-#define FTDI_XF_631_PID 0xFC0C /* 631: 20x2 Character Display */
-#define FTDI_XF_635_PID 0xFC0D /* 635: 20x4 Character Display */
-#define FTDI_XF_640_PID 0xFC0E /* 640: Two line Display */
-#define FTDI_XF_642_PID 0xFC0F /* 642: Two line Display */
-
-/* Video Networks Limited / Homechoice in the UK use an ftdi-based device for their 1Mb */
-/* broadband internet service.  The following PID is exhibited by the usb device supplied */
-/* (the VID is the standard ftdi vid (FTDI_VID) */
-#define FTDI_VNHCPCUSB_D_PID 0xfe38 /* Product Id */
-
-/*
- * PCDJ use ftdi based dj-controllers.  The following PID is for their DAC-2 device
- * http://www.pcdjhardware.com/DAC2.asp (PID sent by Wouter Paesen)
- * (the VID is the standard ftdi vid (FTDI_VID) */
-#define FTDI_PCDJ_DAC2_PID 0xFA88
-
-/*
- * The following are the values for the Matrix Orbital LCD displays,
- * which are the FT232BM ( similar to the 8U232AM )
- */
-#define FTDI_MTXORB_0_PID      0xFA00  /* Matrix Orbital Product Id */
-#define FTDI_MTXORB_1_PID      0xFA01  /* Matrix Orbital Product Id */
-#define FTDI_MTXORB_2_PID      0xFA02  /* Matrix Orbital Product Id */
-#define FTDI_MTXORB_3_PID      0xFA03  /* Matrix Orbital Product Id */
-#define FTDI_MTXORB_4_PID      0xFA04  /* Matrix Orbital Product Id */
-#define FTDI_MTXORB_5_PID      0xFA05  /* Matrix Orbital Product Id */
-#define FTDI_MTXORB_6_PID      0xFA06  /* Matrix Orbital Product Id */
-
-/* OOCDlink by Joern Kaipf <joernk@web.de>
- * (http://www.joernonline.de/dw/doku.php?id=start&idx=projects:oocdlink) */
-#define FTDI_OOCDLINK_PID      0xbaf8  /* Amontec JTAGkey */
-
-/*
- * The following are the values for the Matrix Orbital FTDI Range
- * Anything in this range will use an FT232RL.
- */
-#define MTXORB_VID                     0x1B3D
-#define MTXORB_FTDI_RANGE_0100_PID     0x0100
-#define MTXORB_FTDI_RANGE_0101_PID     0x0101
-#define MTXORB_FTDI_RANGE_0102_PID     0x0102
-#define MTXORB_FTDI_RANGE_0103_PID     0x0103
-#define MTXORB_FTDI_RANGE_0104_PID     0x0104
-#define MTXORB_FTDI_RANGE_0105_PID     0x0105
-#define MTXORB_FTDI_RANGE_0106_PID     0x0106
-#define MTXORB_FTDI_RANGE_0107_PID     0x0107
-#define MTXORB_FTDI_RANGE_0108_PID     0x0108
-#define MTXORB_FTDI_RANGE_0109_PID     0x0109
-#define MTXORB_FTDI_RANGE_010A_PID     0x010A
-#define MTXORB_FTDI_RANGE_010B_PID     0x010B
-#define MTXORB_FTDI_RANGE_010C_PID     0x010C
-#define MTXORB_FTDI_RANGE_010D_PID     0x010D
-#define MTXORB_FTDI_RANGE_010E_PID     0x010E
-#define MTXORB_FTDI_RANGE_010F_PID     0x010F
-#define MTXORB_FTDI_RANGE_0110_PID     0x0110
-#define MTXORB_FTDI_RANGE_0111_PID     0x0111
-#define MTXORB_FTDI_RANGE_0112_PID     0x0112
-#define MTXORB_FTDI_RANGE_0113_PID     0x0113
-#define MTXORB_FTDI_RANGE_0114_PID     0x0114
-#define MTXORB_FTDI_RANGE_0115_PID     0x0115
-#define MTXORB_FTDI_RANGE_0116_PID     0x0116
-#define MTXORB_FTDI_RANGE_0117_PID     0x0117
-#define MTXORB_FTDI_RANGE_0118_PID     0x0118
-#define MTXORB_FTDI_RANGE_0119_PID     0x0119
-#define MTXORB_FTDI_RANGE_011A_PID     0x011A
-#define MTXORB_FTDI_RANGE_011B_PID     0x011B
-#define MTXORB_FTDI_RANGE_011C_PID     0x011C
-#define MTXORB_FTDI_RANGE_011D_PID     0x011D
-#define MTXORB_FTDI_RANGE_011E_PID     0x011E
-#define MTXORB_FTDI_RANGE_011F_PID     0x011F
-#define MTXORB_FTDI_RANGE_0120_PID     0x0120
-#define MTXORB_FTDI_RANGE_0121_PID     0x0121
-#define MTXORB_FTDI_RANGE_0122_PID     0x0122
-#define MTXORB_FTDI_RANGE_0123_PID     0x0123
-#define MTXORB_FTDI_RANGE_0124_PID     0x0124
-#define MTXORB_FTDI_RANGE_0125_PID     0x0125
-#define MTXORB_FTDI_RANGE_0126_PID     0x0126
-#define MTXORB_FTDI_RANGE_0127_PID     0x0127
-#define MTXORB_FTDI_RANGE_0128_PID     0x0128
-#define MTXORB_FTDI_RANGE_0129_PID     0x0129
-#define MTXORB_FTDI_RANGE_012A_PID     0x012A
-#define MTXORB_FTDI_RANGE_012B_PID     0x012B
-#define MTXORB_FTDI_RANGE_012C_PID     0x012C
-#define MTXORB_FTDI_RANGE_012D_PID     0x012D
-#define MTXORB_FTDI_RANGE_012E_PID     0x012E
-#define MTXORB_FTDI_RANGE_012F_PID     0x012F
-#define MTXORB_FTDI_RANGE_0130_PID     0x0130
-#define MTXORB_FTDI_RANGE_0131_PID     0x0131
-#define MTXORB_FTDI_RANGE_0132_PID     0x0132
-#define MTXORB_FTDI_RANGE_0133_PID     0x0133
-#define MTXORB_FTDI_RANGE_0134_PID     0x0134
-#define MTXORB_FTDI_RANGE_0135_PID     0x0135
-#define MTXORB_FTDI_RANGE_0136_PID     0x0136
-#define MTXORB_FTDI_RANGE_0137_PID     0x0137
-#define MTXORB_FTDI_RANGE_0138_PID     0x0138
-#define MTXORB_FTDI_RANGE_0139_PID     0x0139
-#define MTXORB_FTDI_RANGE_013A_PID     0x013A
-#define MTXORB_FTDI_RANGE_013B_PID     0x013B
-#define MTXORB_FTDI_RANGE_013C_PID     0x013C
-#define MTXORB_FTDI_RANGE_013D_PID     0x013D
-#define MTXORB_FTDI_RANGE_013E_PID     0x013E
-#define MTXORB_FTDI_RANGE_013F_PID     0x013F
-#define MTXORB_FTDI_RANGE_0140_PID     0x0140
-#define MTXORB_FTDI_RANGE_0141_PID     0x0141
-#define MTXORB_FTDI_RANGE_0142_PID     0x0142
-#define MTXORB_FTDI_RANGE_0143_PID     0x0143
-#define MTXORB_FTDI_RANGE_0144_PID     0x0144
-#define MTXORB_FTDI_RANGE_0145_PID     0x0145
-#define MTXORB_FTDI_RANGE_0146_PID     0x0146
-#define MTXORB_FTDI_RANGE_0147_PID     0x0147
-#define MTXORB_FTDI_RANGE_0148_PID     0x0148
-#define MTXORB_FTDI_RANGE_0149_PID     0x0149
-#define MTXORB_FTDI_RANGE_014A_PID     0x014A
-#define MTXORB_FTDI_RANGE_014B_PID     0x014B
-#define MTXORB_FTDI_RANGE_014C_PID     0x014C
-#define MTXORB_FTDI_RANGE_014D_PID     0x014D
-#define MTXORB_FTDI_RANGE_014E_PID     0x014E
-#define MTXORB_FTDI_RANGE_014F_PID     0x014F
-#define MTXORB_FTDI_RANGE_0150_PID     0x0150
-#define MTXORB_FTDI_RANGE_0151_PID     0x0151
-#define MTXORB_FTDI_RANGE_0152_PID     0x0152
-#define MTXORB_FTDI_RANGE_0153_PID     0x0153
-#define MTXORB_FTDI_RANGE_0154_PID     0x0154
-#define MTXORB_FTDI_RANGE_0155_PID     0x0155
-#define MTXORB_FTDI_RANGE_0156_PID     0x0156
-#define MTXORB_FTDI_RANGE_0157_PID     0x0157
-#define MTXORB_FTDI_RANGE_0158_PID     0x0158
-#define MTXORB_FTDI_RANGE_0159_PID     0x0159
-#define MTXORB_FTDI_RANGE_015A_PID     0x015A
-#define MTXORB_FTDI_RANGE_015B_PID     0x015B
-#define MTXORB_FTDI_RANGE_015C_PID     0x015C
-#define MTXORB_FTDI_RANGE_015D_PID     0x015D
-#define MTXORB_FTDI_RANGE_015E_PID     0x015E
-#define MTXORB_FTDI_RANGE_015F_PID     0x015F
-#define MTXORB_FTDI_RANGE_0160_PID     0x0160
-#define MTXORB_FTDI_RANGE_0161_PID     0x0161
-#define MTXORB_FTDI_RANGE_0162_PID     0x0162
-#define MTXORB_FTDI_RANGE_0163_PID     0x0163
-#define MTXORB_FTDI_RANGE_0164_PID     0x0164
-#define MTXORB_FTDI_RANGE_0165_PID     0x0165
-#define MTXORB_FTDI_RANGE_0166_PID     0x0166
-#define MTXORB_FTDI_RANGE_0167_PID     0x0167
-#define MTXORB_FTDI_RANGE_0168_PID     0x0168
-#define MTXORB_FTDI_RANGE_0169_PID     0x0169
-#define MTXORB_FTDI_RANGE_016A_PID     0x016A
-#define MTXORB_FTDI_RANGE_016B_PID     0x016B
-#define MTXORB_FTDI_RANGE_016C_PID     0x016C
-#define MTXORB_FTDI_RANGE_016D_PID     0x016D
-#define MTXORB_FTDI_RANGE_016E_PID     0x016E
-#define MTXORB_FTDI_RANGE_016F_PID     0x016F
-#define MTXORB_FTDI_RANGE_0170_PID     0x0170
-#define MTXORB_FTDI_RANGE_0171_PID     0x0171
-#define MTXORB_FTDI_RANGE_0172_PID     0x0172
-#define MTXORB_FTDI_RANGE_0173_PID     0x0173
-#define MTXORB_FTDI_RANGE_0174_PID     0x0174
-#define MTXORB_FTDI_RANGE_0175_PID     0x0175
-#define MTXORB_FTDI_RANGE_0176_PID     0x0176
-#define MTXORB_FTDI_RANGE_0177_PID     0x0177
-#define MTXORB_FTDI_RANGE_0178_PID     0x0178
-#define MTXORB_FTDI_RANGE_0179_PID     0x0179
-#define MTXORB_FTDI_RANGE_017A_PID     0x017A
-#define MTXORB_FTDI_RANGE_017B_PID     0x017B
-#define MTXORB_FTDI_RANGE_017C_PID     0x017C
-#define MTXORB_FTDI_RANGE_017D_PID     0x017D
-#define MTXORB_FTDI_RANGE_017E_PID     0x017E
-#define MTXORB_FTDI_RANGE_017F_PID     0x017F
-#define MTXORB_FTDI_RANGE_0180_PID     0x0180
-#define MTXORB_FTDI_RANGE_0181_PID     0x0181
-#define MTXORB_FTDI_RANGE_0182_PID     0x0182
-#define MTXORB_FTDI_RANGE_0183_PID     0x0183
-#define MTXORB_FTDI_RANGE_0184_PID     0x0184
-#define MTXORB_FTDI_RANGE_0185_PID     0x0185
-#define MTXORB_FTDI_RANGE_0186_PID     0x0186
-#define MTXORB_FTDI_RANGE_0187_PID     0x0187
-#define MTXORB_FTDI_RANGE_0188_PID     0x0188
-#define MTXORB_FTDI_RANGE_0189_PID     0x0189
-#define MTXORB_FTDI_RANGE_018A_PID     0x018A
-#define MTXORB_FTDI_RANGE_018B_PID     0x018B
-#define MTXORB_FTDI_RANGE_018C_PID     0x018C
-#define MTXORB_FTDI_RANGE_018D_PID     0x018D
-#define MTXORB_FTDI_RANGE_018E_PID     0x018E
-#define MTXORB_FTDI_RANGE_018F_PID     0x018F
-#define MTXORB_FTDI_RANGE_0190_PID     0x0190
-#define MTXORB_FTDI_RANGE_0191_PID     0x0191
-#define MTXORB_FTDI_RANGE_0192_PID     0x0192
-#define MTXORB_FTDI_RANGE_0193_PID     0x0193
-#define MTXORB_FTDI_RANGE_0194_PID     0x0194
-#define MTXORB_FTDI_RANGE_0195_PID     0x0195
-#define MTXORB_FTDI_RANGE_0196_PID     0x0196
-#define MTXORB_FTDI_RANGE_0197_PID     0x0197
-#define MTXORB_FTDI_RANGE_0198_PID     0x0198
-#define MTXORB_FTDI_RANGE_0199_PID     0x0199
-#define MTXORB_FTDI_RANGE_019A_PID     0x019A
-#define MTXORB_FTDI_RANGE_019B_PID     0x019B
-#define MTXORB_FTDI_RANGE_019C_PID     0x019C
-#define MTXORB_FTDI_RANGE_019D_PID     0x019D
-#define MTXORB_FTDI_RANGE_019E_PID     0x019E
-#define MTXORB_FTDI_RANGE_019F_PID     0x019F
-#define MTXORB_FTDI_RANGE_01A0_PID     0x01A0
-#define MTXORB_FTDI_RANGE_01A1_PID     0x01A1
-#define MTXORB_FTDI_RANGE_01A2_PID     0x01A2
-#define MTXORB_FTDI_RANGE_01A3_PID     0x01A3
-#define MTXORB_FTDI_RANGE_01A4_PID     0x01A4
-#define MTXORB_FTDI_RANGE_01A5_PID     0x01A5
-#define MTXORB_FTDI_RANGE_01A6_PID     0x01A6
-#define MTXORB_FTDI_RANGE_01A7_PID     0x01A7
-#define MTXORB_FTDI_RANGE_01A8_PID     0x01A8
-#define MTXORB_FTDI_RANGE_01A9_PID     0x01A9
-#define MTXORB_FTDI_RANGE_01AA_PID     0x01AA
-#define MTXORB_FTDI_RANGE_01AB_PID     0x01AB
-#define MTXORB_FTDI_RANGE_01AC_PID     0x01AC
-#define MTXORB_FTDI_RANGE_01AD_PID     0x01AD
-#define MTXORB_FTDI_RANGE_01AE_PID     0x01AE
-#define MTXORB_FTDI_RANGE_01AF_PID     0x01AF
-#define MTXORB_FTDI_RANGE_01B0_PID     0x01B0
-#define MTXORB_FTDI_RANGE_01B1_PID     0x01B1
-#define MTXORB_FTDI_RANGE_01B2_PID     0x01B2
-#define MTXORB_FTDI_RANGE_01B3_PID     0x01B3
-#define MTXORB_FTDI_RANGE_01B4_PID     0x01B4
-#define MTXORB_FTDI_RANGE_01B5_PID     0x01B5
-#define MTXORB_FTDI_RANGE_01B6_PID     0x01B6
-#define MTXORB_FTDI_RANGE_01B7_PID     0x01B7
-#define MTXORB_FTDI_RANGE_01B8_PID     0x01B8
-#define MTXORB_FTDI_RANGE_01B9_PID     0x01B9
-#define MTXORB_FTDI_RANGE_01BA_PID     0x01BA
-#define MTXORB_FTDI_RANGE_01BB_PID     0x01BB
-#define MTXORB_FTDI_RANGE_01BC_PID     0x01BC
-#define MTXORB_FTDI_RANGE_01BD_PID     0x01BD
-#define MTXORB_FTDI_RANGE_01BE_PID     0x01BE
-#define MTXORB_FTDI_RANGE_01BF_PID     0x01BF
-#define MTXORB_FTDI_RANGE_01C0_PID     0x01C0
-#define MTXORB_FTDI_RANGE_01C1_PID     0x01C1
-#define MTXORB_FTDI_RANGE_01C2_PID     0x01C2
-#define MTXORB_FTDI_RANGE_01C3_PID     0x01C3
-#define MTXORB_FTDI_RANGE_01C4_PID     0x01C4
-#define MTXORB_FTDI_RANGE_01C5_PID     0x01C5
-#define MTXORB_FTDI_RANGE_01C6_PID     0x01C6
-#define MTXORB_FTDI_RANGE_01C7_PID     0x01C7
-#define MTXORB_FTDI_RANGE_01C8_PID     0x01C8
-#define MTXORB_FTDI_RANGE_01C9_PID     0x01C9
-#define MTXORB_FTDI_RANGE_01CA_PID     0x01CA
-#define MTXORB_FTDI_RANGE_01CB_PID     0x01CB
-#define MTXORB_FTDI_RANGE_01CC_PID     0x01CC
-#define MTXORB_FTDI_RANGE_01CD_PID     0x01CD
-#define MTXORB_FTDI_RANGE_01CE_PID     0x01CE
-#define MTXORB_FTDI_RANGE_01CF_PID     0x01CF
-#define MTXORB_FTDI_RANGE_01D0_PID     0x01D0
-#define MTXORB_FTDI_RANGE_01D1_PID     0x01D1
-#define MTXORB_FTDI_RANGE_01D2_PID     0x01D2
-#define MTXORB_FTDI_RANGE_01D3_PID     0x01D3
-#define MTXORB_FTDI_RANGE_01D4_PID     0x01D4
-#define MTXORB_FTDI_RANGE_01D5_PID     0x01D5
-#define MTXORB_FTDI_RANGE_01D6_PID     0x01D6
-#define MTXORB_FTDI_RANGE_01D7_PID     0x01D7
-#define MTXORB_FTDI_RANGE_01D8_PID     0x01D8
-#define MTXORB_FTDI_RANGE_01D9_PID     0x01D9
-#define MTXORB_FTDI_RANGE_01DA_PID     0x01DA
-#define MTXORB_FTDI_RANGE_01DB_PID     0x01DB
-#define MTXORB_FTDI_RANGE_01DC_PID     0x01DC
-#define MTXORB_FTDI_RANGE_01DD_PID     0x01DD
-#define MTXORB_FTDI_RANGE_01DE_PID     0x01DE
-#define MTXORB_FTDI_RANGE_01DF_PID     0x01DF
-#define MTXORB_FTDI_RANGE_01E0_PID     0x01E0
-#define MTXORB_FTDI_RANGE_01E1_PID     0x01E1
-#define MTXORB_FTDI_RANGE_01E2_PID     0x01E2
-#define MTXORB_FTDI_RANGE_01E3_PID     0x01E3
-#define MTXORB_FTDI_RANGE_01E4_PID     0x01E4
-#define MTXORB_FTDI_RANGE_01E5_PID     0x01E5
-#define MTXORB_FTDI_RANGE_01E6_PID     0x01E6
-#define MTXORB_FTDI_RANGE_01E7_PID     0x01E7
-#define MTXORB_FTDI_RANGE_01E8_PID     0x01E8
-#define MTXORB_FTDI_RANGE_01E9_PID     0x01E9
-#define MTXORB_FTDI_RANGE_01EA_PID     0x01EA
-#define MTXORB_FTDI_RANGE_01EB_PID     0x01EB
-#define MTXORB_FTDI_RANGE_01EC_PID     0x01EC
-#define MTXORB_FTDI_RANGE_01ED_PID     0x01ED
-#define MTXORB_FTDI_RANGE_01EE_PID     0x01EE
-#define MTXORB_FTDI_RANGE_01EF_PID     0x01EF
-#define MTXORB_FTDI_RANGE_01F0_PID     0x01F0
-#define MTXORB_FTDI_RANGE_01F1_PID     0x01F1
-#define MTXORB_FTDI_RANGE_01F2_PID     0x01F2
-#define MTXORB_FTDI_RANGE_01F3_PID     0x01F3
-#define MTXORB_FTDI_RANGE_01F4_PID     0x01F4
-#define MTXORB_FTDI_RANGE_01F5_PID     0x01F5
-#define MTXORB_FTDI_RANGE_01F6_PID     0x01F6
-#define MTXORB_FTDI_RANGE_01F7_PID     0x01F7
-#define MTXORB_FTDI_RANGE_01F8_PID     0x01F8
-#define MTXORB_FTDI_RANGE_01F9_PID     0x01F9
-#define MTXORB_FTDI_RANGE_01FA_PID     0x01FA
-#define MTXORB_FTDI_RANGE_01FB_PID     0x01FB
-#define MTXORB_FTDI_RANGE_01FC_PID     0x01FC
-#define MTXORB_FTDI_RANGE_01FD_PID     0x01FD
-#define MTXORB_FTDI_RANGE_01FE_PID     0x01FE
-#define MTXORB_FTDI_RANGE_01FF_PID     0x01FF
-
-
-
-/* Interbiometrics USB I/O Board */
-/* Developed for Interbiometrics by Rudolf Gugler */
-#define INTERBIOMETRICS_VID              0x1209
-#define INTERBIOMETRICS_IOBOARD_PID      0x1002
-#define INTERBIOMETRICS_MINI_IOBOARD_PID 0x1006
-
-/*
- * The following are the values for the Perle Systems
- * UltraPort USB serial converters
- */
-#define FTDI_PERLE_ULTRAPORT_PID 0xF0C0        /* Perle UltraPort Product Id */
-
-/*
- * The following are the values for the Sealevel SeaLINK+ adapters.
- * (Original list sent by Tuan Hoang.  Ian Abbott renamed the macros and
- * removed some PIDs that don't seem to match any existing products.)
- */
-#define SEALEVEL_VID           0x0c52  /* Sealevel Vendor ID */
-#define SEALEVEL_2101_PID      0x2101  /* SeaLINK+232 (2101/2105) */
-#define SEALEVEL_2102_PID      0x2102  /* SeaLINK+485 (2102) */
-#define SEALEVEL_2103_PID      0x2103  /* SeaLINK+232I (2103) */
-#define SEALEVEL_2104_PID      0x2104  /* SeaLINK+485I (2104) */
-#define SEALEVEL_2106_PID      0x9020  /* SeaLINK+422 (2106) */
-#define SEALEVEL_2201_1_PID    0x2211  /* SeaPORT+2/232 (2201) Port 1 */
-#define SEALEVEL_2201_2_PID    0x2221  /* SeaPORT+2/232 (2201) Port 2 */
-#define SEALEVEL_2202_1_PID    0x2212  /* SeaPORT+2/485 (2202) Port 1 */
-#define SEALEVEL_2202_2_PID    0x2222  /* SeaPORT+2/485 (2202) Port 2 */
-#define SEALEVEL_2203_1_PID    0x2213  /* SeaPORT+2 (2203) Port 1 */
-#define SEALEVEL_2203_2_PID    0x2223  /* SeaPORT+2 (2203) Port 2 */
-#define SEALEVEL_2401_1_PID    0x2411  /* SeaPORT+4/232 (2401) Port 1 */
-#define SEALEVEL_2401_2_PID    0x2421  /* SeaPORT+4/232 (2401) Port 2 */
-#define SEALEVEL_2401_3_PID    0x2431  /* SeaPORT+4/232 (2401) Port 3 */
-#define SEALEVEL_2401_4_PID    0x2441  /* SeaPORT+4/232 (2401) Port 4 */
-#define SEALEVEL_2402_1_PID    0x2412  /* SeaPORT+4/485 (2402) Port 1 */
-#define SEALEVEL_2402_2_PID    0x2422  /* SeaPORT+4/485 (2402) Port 2 */
-#define SEALEVEL_2402_3_PID    0x2432  /* SeaPORT+4/485 (2402) Port 3 */
-#define SEALEVEL_2402_4_PID    0x2442  /* SeaPORT+4/485 (2402) Port 4 */
-#define SEALEVEL_2403_1_PID    0x2413  /* SeaPORT+4 (2403) Port 1 */
-#define SEALEVEL_2403_2_PID    0x2423  /* SeaPORT+4 (2403) Port 2 */
-#define SEALEVEL_2403_3_PID    0x2433  /* SeaPORT+4 (2403) Port 3 */
-#define SEALEVEL_2403_4_PID    0x2443  /* SeaPORT+4 (2403) Port 4 */
-#define SEALEVEL_2801_1_PID    0X2811  /* SeaLINK+8/232 (2801) Port 1 */
-#define SEALEVEL_2801_2_PID    0X2821  /* SeaLINK+8/232 (2801) Port 2 */
-#define SEALEVEL_2801_3_PID    0X2831  /* SeaLINK+8/232 (2801) Port 3 */
-#define SEALEVEL_2801_4_PID    0X2841  /* SeaLINK+8/232 (2801) Port 4 */
-#define SEALEVEL_2801_5_PID    0X2851  /* SeaLINK+8/232 (2801) Port 5 */
-#define SEALEVEL_2801_6_PID    0X2861  /* SeaLINK+8/232 (2801) Port 6 */
-#define SEALEVEL_2801_7_PID    0X2871  /* SeaLINK+8/232 (2801) Port 7 */
-#define SEALEVEL_2801_8_PID    0X2881  /* SeaLINK+8/232 (2801) Port 8 */
-#define SEALEVEL_2802_1_PID    0X2812  /* SeaLINK+8/485 (2802) Port 1 */
-#define SEALEVEL_2802_2_PID    0X2822  /* SeaLINK+8/485 (2802) Port 2 */
-#define SEALEVEL_2802_3_PID    0X2832  /* SeaLINK+8/485 (2802) Port 3 */
-#define SEALEVEL_2802_4_PID    0X2842  /* SeaLINK+8/485 (2802) Port 4 */
-#define SEALEVEL_2802_5_PID    0X2852  /* SeaLINK+8/485 (2802) Port 5 */
-#define SEALEVEL_2802_6_PID    0X2862  /* SeaLINK+8/485 (2802) Port 6 */
-#define SEALEVEL_2802_7_PID    0X2872  /* SeaLINK+8/485 (2802) Port 7 */
-#define SEALEVEL_2802_8_PID    0X2882  /* SeaLINK+8/485 (2802) Port 8 */
-#define SEALEVEL_2803_1_PID    0X2813  /* SeaLINK+8 (2803) Port 1 */
-#define SEALEVEL_2803_2_PID    0X2823  /* SeaLINK+8 (2803) Port 2 */
-#define SEALEVEL_2803_3_PID    0X2833  /* SeaLINK+8 (2803) Port 3 */
-#define SEALEVEL_2803_4_PID    0X2843  /* SeaLINK+8 (2803) Port 4 */
-#define SEALEVEL_2803_5_PID    0X2853  /* SeaLINK+8 (2803) Port 5 */
-#define SEALEVEL_2803_6_PID    0X2863  /* SeaLINK+8 (2803) Port 6 */
-#define SEALEVEL_2803_7_PID    0X2873  /* SeaLINK+8 (2803) Port 7 */
-#define SEALEVEL_2803_8_PID    0X2883  /* SeaLINK+8 (2803) Port 8 */
-
-/*
- * The following are the values for two KOBIL chipcard terminals.
- */
-#define KOBIL_VID              0x0d46  /* KOBIL Vendor ID */
-#define KOBIL_CONV_B1_PID      0x2020  /* KOBIL Konverter for B1 */
-#define KOBIL_CONV_KAAN_PID    0x2021  /* KOBIL_Konverter for KAAN */
-
-/*
- * Icom ID-1 digital transceiver
- */
-
-#define ICOM_ID1_VID            0x0C26
-#define ICOM_ID1_PID            0x0004
-
-/*
- * ASK.fr devices
- */
-#define FTDI_ASK_RDR400_PID    0xC991  /* ASK RDR 400 series card reader */
-
-/*
- * FTDI USB UART chips used in construction projects from the
- * Elektor Electronics magazine (http://elektor-electronics.co.uk)
- */
-#define ELEKTOR_VID            0x0C7D
-#define ELEKTOR_FT323R_PID     0x0005  /* RFID-Reader, issue 09-2006 */
-
-/*
- * DSS-20 Sync Station for Sony Ericsson P800
- */
-#define FTDI_DSS20_PID          0xFC82
-
-/*
- * Home Electronics (www.home-electro.com) USB gadgets
- */
-#define FTDI_HE_TIRA1_PID      0xFA78  /* Tira-1 IR transceiver */
-
-/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */
-/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */
-#define FTDI_USB_UIRT_PID      0xF850  /* Product Id */
-
-/* TNC-X USB-to-packet-radio adapter, versions prior to 3.0 (DLP module) */
-
-#define FTDI_TNC_X_PID         0xEBE0
-
-/*
- * ELV USB devices submitted by Christian Abt of ELV (www.elv.de).
- * All of these devices use FTDI's vendor ID (0x0403).
- *
- * The previously included PID for the UO 100 module was incorrect.
- * In fact, that PID was for ELV's UR 100 USB-RS232 converter (0xFB58).
- *
- * Armin Laeuger originally sent the PID for the UM 100 module.
- */
-#define FTDI_R2000KU_TRUE_RNG  0xFB80  /* R2000KU TRUE RNG */
-#define FTDI_ELV_UR100_PID     0xFB58  /* USB-RS232-Umsetzer (UR 100) */
-#define FTDI_ELV_UM100_PID     0xFB5A  /* USB-Modul UM 100 */
-#define FTDI_ELV_UO100_PID     0xFB5B  /* USB-Modul UO 100 */
-#define FTDI_ELV_ALC8500_PID   0xF06E  /* ALC 8500 Expert */
-/* Additional ELV PIDs that default to using the FTDI D2XX drivers on
- * MS Windows, rather than the FTDI Virtual Com Port drivers.
- * Maybe these will be easier to use with the libftdi/libusb user-space
- * drivers, or possibly the Comedi drivers in some cases. */
-#define FTDI_ELV_CLI7000_PID   0xFB59  /* Computer-Light-Interface (CLI 7000) */
-#define FTDI_ELV_PPS7330_PID   0xFB5C  /* Processor-Power-Supply (PPS 7330) */
-#define FTDI_ELV_TFM100_PID    0xFB5D  /* Temperartur-Feuchte Messgeraet (TFM 100) */
-#define FTDI_ELV_UDF77_PID     0xFB5E  /* USB DCF Funkurh (UDF 77) */
-#define FTDI_ELV_UIO88_PID     0xFB5F  /* USB-I/O Interface (UIO 88) */
-#define FTDI_ELV_UAD8_PID      0xF068  /* USB-AD-Wandler (UAD 8) */
-#define FTDI_ELV_UDA7_PID      0xF069  /* USB-DA-Wandler (UDA 7) */
-#define FTDI_ELV_USI2_PID      0xF06A  /* USB-Schrittmotoren-Interface (USI 2) */
-#define FTDI_ELV_T1100_PID     0xF06B  /* Thermometer (T 1100) */
-#define FTDI_ELV_PCD200_PID    0xF06C  /* PC-Datenlogger (PCD 200) */
-#define FTDI_ELV_ULA200_PID    0xF06D  /* USB-LCD-Ansteuerung (ULA 200) */
-#define FTDI_ELV_FHZ1000PC_PID 0xF06F  /* FHZ 1000 PC */
-#define FTDI_ELV_CSI8_PID      0xE0F0  /* Computer-Schalt-Interface (CSI 8) */
-#define FTDI_ELV_EM1000DL_PID  0xE0F1  /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */
-#define FTDI_ELV_PCK100_PID    0xE0F2  /* PC-Kabeltester (PCK 100) */
-#define FTDI_ELV_RFP500_PID    0xE0F3  /* HF-Leistungsmesser (RFP 500) */
-#define FTDI_ELV_FS20SIG_PID   0xE0F4  /* Signalgeber (FS 20 SIG) */
-#define FTDI_ELV_WS300PC_PID   0xE0F6  /* PC-Wetterstation (WS 300 PC) */
-#define FTDI_ELV_FHZ1300PC_PID 0xE0E8  /* FHZ 1300 PC */
-#define FTDI_ELV_WS500_PID     0xE0E9  /* PC-Wetterstation (WS 500) */
-#define FTDI_ELV_HS485_PID     0xE0EA  /* USB to RS-485 adapter */
-#define FTDI_ELV_EM1010PC_PID  0xE0EF  /* Engery monitor EM 1010 PC */
-#define FTDI_PHI_FISCO_PID      0xE40B  /* PHI Fisco USB to Serial cable */
-
-/*
- * Definitions for ID TECH (www.idt-net.com) devices
- */
-#define IDTECH_VID             0x0ACD  /* ID TECH Vendor ID */
-#define IDTECH_IDT1221U_PID    0x0300  /* IDT1221U USB to RS-232 adapter */
-
-/*
- * Definitions for Omnidirectional Control Technology, Inc. devices
- */
-#define OCT_VID                        0x0B39  /* OCT vendor ID */
-/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
-/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
-/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
-#define OCT_US101_PID          0x0421  /* OCT US101 USB to RS-232 */
-
-/* an infrared receiver for user access control with IR tags */
-#define FTDI_PIEGROUP_PID      0xF208  /* Product Id */
-
-/*
- * Definitions for Artemis astronomical USB based cameras
- * Check it at http://www.artemisccd.co.uk/
- */
-#define FTDI_ARTEMIS_PID       0xDF28  /* All Artemis Cameras */
-
-/*
- * Definitions for ATIK Instruments astronomical USB based cameras
- * Check it at http://www.atik-instruments.com/
- */
-#define FTDI_ATIK_ATK16_PID    0xDF30  /* ATIK ATK-16 Grayscale Camera */
-#define FTDI_ATIK_ATK16C_PID   0xDF32  /* ATIK ATK-16C Colour Camera */
-#define FTDI_ATIK_ATK16HR_PID  0xDF31  /* ATIK ATK-16HR Grayscale Camera */
-#define FTDI_ATIK_ATK16HRC_PID 0xDF33  /* ATIK ATK-16HRC Colour Camera */
-#define FTDI_ATIK_ATK16IC_PID   0xDF35  /* ATIK ATK-16IC Grayscale Camera */
-
-/*
- * Protego product ids
- */
-#define PROTEGO_SPECIAL_1      0xFC70  /* special/unknown device */
-#define PROTEGO_R2X0           0xFC71  /* R200-USB TRNG unit (R210, R220, and R230) */
-#define PROTEGO_SPECIAL_3      0xFC72  /* special/unknown device */
-#define PROTEGO_SPECIAL_4      0xFC73  /* special/unknown device */
-
-/*
- * Gude Analog- und Digitalsysteme GmbH
- */
-#define FTDI_GUDEADS_E808_PID    0xE808
-#define FTDI_GUDEADS_E809_PID    0xE809
-#define FTDI_GUDEADS_E80A_PID    0xE80A
-#define FTDI_GUDEADS_E80B_PID    0xE80B
-#define FTDI_GUDEADS_E80C_PID    0xE80C
-#define FTDI_GUDEADS_E80D_PID    0xE80D
-#define FTDI_GUDEADS_E80E_PID    0xE80E
-#define FTDI_GUDEADS_E80F_PID    0xE80F
-#define FTDI_GUDEADS_E888_PID    0xE888  /* Expert ISDN Control USB */
-#define FTDI_GUDEADS_E889_PID    0xE889  /* USB RS-232 OptoBridge */
-#define FTDI_GUDEADS_E88A_PID    0xE88A
-#define FTDI_GUDEADS_E88B_PID    0xE88B
-#define FTDI_GUDEADS_E88C_PID    0xE88C
-#define FTDI_GUDEADS_E88D_PID    0xE88D
-#define FTDI_GUDEADS_E88E_PID    0xE88E
-#define FTDI_GUDEADS_E88F_PID    0xE88F
-
-/*
- * Linx Technologies product ids
- */
-#define LINX_SDMUSBQSS_PID     0xF448  /* Linx SDM-USB-QS-S */
-#define LINX_MASTERDEVEL2_PID   0xF449   /* Linx Master Development 2.0 */
-#define LINX_FUTURE_0_PID   0xF44A   /* Linx future device */
-#define LINX_FUTURE_1_PID   0xF44B   /* Linx future device */
-#define LINX_FUTURE_2_PID   0xF44C   /* Linx future device */
-
-/* CCS Inc. ICDU/ICDU40 product ID - the FT232BM is used in an in-circuit-debugger */
-/* unit for PIC16's/PIC18's */
-#define FTDI_CCSICDU20_0_PID    0xF9D0
-#define FTDI_CCSICDU40_1_PID    0xF9D1
-#define FTDI_CCSMACHX_2_PID     0xF9D2
-#define FTDI_CCSLOAD_N_GO_3_PID 0xF9D3
-#define FTDI_CCSICDU64_4_PID    0xF9D4
-#define FTDI_CCSPRIME8_5_PID    0xF9D5
-
-/* Inside Accesso contactless reader (http://www.insidefr.com) */
-#define INSIDE_ACCESSO         0xFAD0
-
-/*
- * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
- */
-#define INTREPID_VID           0x093C
-#define INTREPID_VALUECAN_PID  0x0601
-#define INTREPID_NEOVI_PID     0x0701
-
-/*
- * Falcom Wireless Communications GmbH
- */
-#define FALCOM_VID             0x0F94  /* Vendor Id */
-#define FALCOM_TWIST_PID       0x0001  /* Falcom Twist USB GPRS modem */
-#define FALCOM_SAMBA_PID       0x0005  /* Falcom Samba USB GPRS modem */
-
-/*
- * SUUNTO product ids
- */
-#define FTDI_SUUNTO_SPORTS_PID 0xF680  /* Suunto Sports instrument */
-
-/*
- * Oceanic product ids
- */
-#define FTDI_OCEANIC_PID       0xF460  /* Oceanic dive instrument */
-
-/*
- * TTi (Thurlby Thandar Instruments)
- */
-#define TTI_VID                        0x103E  /* Vendor Id */
-#define TTI_QL355P_PID         0x03E8  /* TTi QL355P power supply */
-
-/*
- * Definitions for B&B Electronics products.
- */
-#define BANDB_VID              0x0856  /* B&B Electronics Vendor ID */
-#define BANDB_USOTL4_PID       0xAC01  /* USOTL4 Isolated RS-485 Converter */
-#define BANDB_USTL4_PID                0xAC02  /* USTL4 RS-485 Converter */
-#define BANDB_USO9ML2_PID      0xAC03  /* USO9ML2 Isolated RS-232 Converter */
-#define BANDB_USOPTL4_PID      0xAC11
-#define BANDB_USPTL4_PID       0xAC12
-#define BANDB_USO9ML2DR_2_PID  0xAC16
-#define BANDB_USO9ML2DR_PID    0xAC17
-#define BANDB_USOPTL4DR2_PID   0xAC18  /* USOPTL4R-2 2-port Isolated RS-232 Converter */
-#define BANDB_USOPTL4DR_PID    0xAC19
-#define BANDB_485USB9F_2W_PID  0xAC25
-#define BANDB_485USB9F_4W_PID  0xAC26
-#define BANDB_232USB9M_PID     0xAC27
-#define BANDB_485USBTB_2W_PID  0xAC33
-#define BANDB_485USBTB_4W_PID  0xAC34
-#define BANDB_TTL5USB9M_PID    0xAC49
-#define BANDB_TTL3USB9M_PID    0xAC50
-#define BANDB_ZZ_PROG1_USB_PID 0xBA02
-
-/*
- * RM Michaelides CANview USB (http://www.rmcan.com)
- * CAN fieldbus interface adapter, added by port GmbH www.port.de)
- * Ian Abbott changed the macro names for consistency.
- */
-#define FTDI_RM_CANVIEW_PID    0xfd60  /* Product Id */
-
-/*
- * EVER Eco Pro UPS (http://www.ever.com.pl/)
- */
-
-#define        EVER_ECO_PRO_CDS        0xe520  /* RS-232 converter */
-
-/*
- * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
- * USB-TTY activ, USB-TTY passiv.  Some PIDs are used by several devices
- * and I'm not entirely sure which are used by which.
- */
-#define FTDI_4N_GALAXY_DE_1_PID        0xF3C0
-#define FTDI_4N_GALAXY_DE_2_PID        0xF3C1
-
-/*
- * Mobility Electronics products.
- */
-#define MOBILITY_VID                   0x1342
-#define MOBILITY_USB_SERIAL_PID                0x0202  /* EasiDock USB 200 serial */
-
-/*
- * microHAM product IDs (http://www.microham.com).
- * Submitted by Justin Burket (KL1RL) <zorton@jtan.com>
- * and Mike Studer (K6EEP) <k6eep@hamsoftware.org>.
- * Ian Abbott <abbotti@mev.co.uk> added a few more from the driver INF file.
- */
-#define FTDI_MHAM_KW_PID 0xEEE8                /* USB-KW interface */
-#define FTDI_MHAM_YS_PID 0xEEE9                /* USB-YS interface */
-#define FTDI_MHAM_Y6_PID 0xEEEA                /* USB-Y6 interface */
-#define FTDI_MHAM_Y8_PID 0xEEEB                /* USB-Y8 interface */
-#define FTDI_MHAM_IC_PID 0xEEEC                /* USB-IC interface */
-#define FTDI_MHAM_DB9_PID 0xEEED       /* USB-DB9 interface */
-#define FTDI_MHAM_RS232_PID 0xEEEE     /* USB-RS232 interface */
-#define FTDI_MHAM_Y9_PID 0xEEEF                /* USB-Y9 interface */
-
-/*
- * Active Robots product ids.
- */
-#define FTDI_ACTIVE_ROBOTS_PID 0xE548  /* USB comms board */
-
-/*
- * Xsens Technologies BV products (http://www.xsens.com).
- */
-#define XSENS_CONVERTER_0_PID  0xD388
-#define XSENS_CONVERTER_1_PID  0xD389
-#define XSENS_CONVERTER_2_PID  0xD38A
-#define XSENS_CONVERTER_3_PID  0xD38B
-#define XSENS_CONVERTER_4_PID  0xD38C
-#define XSENS_CONVERTER_5_PID  0xD38D
-#define XSENS_CONVERTER_6_PID  0xD38E
-#define XSENS_CONVERTER_7_PID  0xD38F
-
-/*
- * Teratronik product ids.
- * Submitted by O. Wölfelschneider.
- */
-#define FTDI_TERATRONIK_VCP_PID         0xEC88 /* Teratronik device (preferring VCP driver on windows) */
-#define FTDI_TERATRONIK_D2XX_PID 0xEC89        /* Teratronik device (preferring D2XX driver on windows) */
-
-/*
- * Evolution Robotics products (http://www.evolution.com/).
- * Submitted by Shawn M. Lavelle.
- */
-#define EVOLUTION_VID          0xDEEE  /* Vendor ID */
-#define EVOLUTION_ER1_PID      0x0300  /* ER1 Control Module */
-#define EVO_8U232AM_PID        0x02FF  /* Evolution robotics RCM2 (FT232AM)*/
-#define EVO_HYBRID_PID         0x0302  /* Evolution robotics RCM4 PID (FT232BM)*/
-#define EVO_RCM4_PID           0x0303  /* Evolution robotics RCM4 PID */
-
-/* Pyramid Computer GmbH */
-#define FTDI_PYRAMID_PID       0xE6C8  /* Pyramid Appliance Display */
-
-/*
- * NDI (www.ndigital.com) product ids
- */
-#define FTDI_NDI_HUC_PID               0xDA70  /* NDI Host USB Converter */
-#define FTDI_NDI_SPECTRA_SCU_PID       0xDA71  /* NDI Spectra SCU */
-#define FTDI_NDI_FUTURE_2_PID          0xDA72  /* NDI future device #2 */
-#define FTDI_NDI_FUTURE_3_PID          0xDA73  /* NDI future device #3 */
-#define FTDI_NDI_AURORA_SCU_PID                0xDA74  /* NDI Aurora SCU */
-
-/*
- * Posiflex inc retail equipment (http://www.posiflex.com.tw)
- */
-#define POSIFLEX_VID           0x0d3a  /* Vendor ID */
-#define POSIFLEX_PP7000_PID    0x0300  /* PP-7000II thermal printer */
-
-/*
- * Westrex International devices submitted by Cory Lee
- */
-#define FTDI_WESTREX_MODEL_777_PID     0xDC00  /* Model 777 */
-#define FTDI_WESTREX_MODEL_8900F_PID   0xDC01  /* Model 8900F */
-
-/*
- * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
- */
-#define FTDI_RRCIRKITS_LOCOBUFFER_PID  0xc7d0  /* LocoBuffer USB */
-
-/*
- * Eclo (http://www.eclo.pt/) product IDs.
- * PID 0xEA90 submitted by Martin Grill.
- */
-#define FTDI_ECLO_COM_1WIRE_PID        0xEA90  /* COM to 1-Wire USB adaptor */
-
-/*
- * Papouch products (http://www.papouch.com/)
- * Submitted by Folkert van Heusden
- */
-
-#define PAPOUCH_VID                    0x5050  /* Vendor ID */
-#define PAPOUCH_TMU_PID                        0x0400  /* TMU USB Thermometer */
-#define PAPOUCH_QUIDO4x4_PID           0x0900  /* Quido 4/4 Module */
-
-/*
- * ACG Identification Technologies GmbH products (http://www.acg.de/).
- * Submitted by anton -at- goto10 -dot- org.
  */
-#define FTDI_ACG_HFDUAL_PID            0xDD20  /* HF Dual ISO Reader (RFID) */
-
-/*
- * Yost Engineering, Inc. products (www.yostengineering.com).
- * PID 0xE050 submitted by Aaron Prose.
- */
-#define FTDI_YEI_SERVOCENTER31_PID     0xE050  /* YEI ServoCenter3.1 USB */
-
-/*
- * ThorLabs USB motor drivers
- */
-#define FTDI_THORLABS_PID              0xfaf0 /* ThorLabs USB motor drivers */
-
-/*
- * Testo products (http://www.testo.com/)
- * Submitted by Colin Leroy
- */
-#define TESTO_VID                      0x128D
-#define TESTO_USB_INTERFACE_PID                0x0001
-
-/*
- * Gamma Scout (http://gamma-scout.com/). Submitted by rsc@runtux.com.
- */
-#define FTDI_GAMMA_SCOUT_PID           0xD678  /* Gamma Scout online */
-
-/*
- * Tactrix OpenPort (ECU) devices.
- * OpenPort 1.3M submitted by Donour Sizemore.
- * OpenPort 1.3S and 1.3U submitted by Ian Abbott.
- */
-#define FTDI_TACTRIX_OPENPORT_13M_PID  0xCC48  /* OpenPort 1.3 Mitsubishi */
-#define FTDI_TACTRIX_OPENPORT_13S_PID  0xCC49  /* OpenPort 1.3 Subaru */
-#define FTDI_TACTRIX_OPENPORT_13U_PID  0xCC4A  /* OpenPort 1.3 Universal */
-
-/*
- * Telldus Technologies
- */
-#define TELLDUS_VID                    0x1781  /* Vendor ID */
-#define TELLDUS_TELLSTICK_PID          0x0C30  /* RF control dongle 433 MHz using FT232RL */
-
-/*
- * IBS elektronik product ids
- * Submitted by Thomas Schleusener
- */
-#define FTDI_IBS_US485_PID     0xff38  /* IBS US485 (USB<-->RS422/485 interface) */
-#define FTDI_IBS_PICPRO_PID    0xff39  /* IBS PIC-Programmer */
-#define FTDI_IBS_PCMCIA_PID    0xff3a  /* IBS Card reader for PCMCIA SRAM-cards */
-#define FTDI_IBS_PK1_PID       0xff3b  /* IBS PK1 - Particel counter */
-#define FTDI_IBS_RS232MON_PID  0xff3c  /* IBS RS232 - Monitor */
-#define FTDI_IBS_APP70_PID     0xff3d  /* APP 70 (dust monitoring system) */
-#define FTDI_IBS_PEDO_PID      0xff3e  /* IBS PEDO-Modem (RF modem 868.35 MHz) */
-#define FTDI_IBS_PROD_PID      0xff3f  /* future device */
-
-/*
- *  MaxStream devices  www.maxstream.net
- */
-#define FTDI_MAXSTREAM_PID     0xEE18  /* Xbee PKG-U Module */
-
-/* Olimex */
-#define OLIMEX_VID                     0x15BA
-#define OLIMEX_ARM_USB_OCD_PID         0x0003
-
-/* Luminary Micro Stellaris Boards, VID = FTDI_VID */
-/* FTDI 2332C Dual channel device, side A=245 FIFO (JTAG), Side B=RS232 UART */
-#define LMI_LM3S_DEVEL_BOARD_PID       0xbcd8
-#define LMI_LM3S_EVAL_BOARD_PID                0xbcd9
-
-/* www.elsterelectricity.com Elster Unicom III Optical Probe */
-#define FTDI_ELSTER_UNICOM_PID         0xE700 /* Product Id */
-
-/*
- * The Mobility Lab (TML)
- * Submitted by Pierre Castella
- */
-#define TML_VID                        0x1B91  /* Vendor ID */
-#define TML_USB_SERIAL_PID     0x0064  /* USB - Serial Converter */
-
-/* Propox devices */
-#define FTDI_PROPOX_JTAGCABLEII_PID    0xD738
-
-/* Rig Expert Ukraine devices */
-#define FTDI_REU_TINY_PID              0xED22  /* RigExpert Tiny */
-
-/* Domintell products  http://www.domintell.com */
-#define FTDI_DOMINTELL_DGQG_PID        0xEF50  /* Master */
-#define FTDI_DOMINTELL_DUSB_PID        0xEF51  /* DUSB01 module */
-
-/* Alti-2 products  http://www.alti-2.com */
-#define ALTI2_VID      0x1BC9
-#define ALTI2_N3_PID   0x6001  /* Neptune 3 */
 
 /* Commands */
 #define FTDI_SIO_RESET                 0 /* Reset the port */
 #define INTERFACE_C            3
 #define INTERFACE_D            4
 
-/*
- * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3
- * Submitted by Harald Welte <laforge@openmoko.org>
- */
-#define        FIC_VID                 0x1457
-#define        FIC_NEO1973_DEBUG_PID   0x5118
-
-/*
- * RATOC REX-USB60F
- */
-#define RATOC_VENDOR_ID                0x0584
-#define RATOC_PRODUCT_ID_USB60F        0xb020
-
-/*
- * DIEBOLD BCS SE923
- */
-#define DIEBOLD_BCS_SE923_PID  0xfb99
-
-/*
- * Atmel STK541
- */
-#define ATMEL_VID              0x03eb /* Vendor ID */
-#define STK541_PID             0x2109 /* Zigbee Controller */
-
-/*
- * Dresden Elektronic Sensor Terminal Board
- */
-#define DE_VID                 0x1cf1 /* Vendor ID */
-#define STB_PID                        0x0001 /* Sensor Terminal Board */
-#define WHT_PID                        0x0004 /* Wireless Handheld Terminal */
-
-/*
- * Blackfin gnICE JTAG
- * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice
- */
-#define ADI_VID                0x0456
-#define ADI_GNICE_PID          0xF000
-#define ADI_GNICEPLUS_PID      0xF001
-
-/*
- * JETI SPECTROMETER SPECBOS 1201
- * http://www.jeti.com/products/sys/scb/scb1201.php
- */
-#define JETI_VID               0x0c6c
-#define JETI_SPC1201_PID       0x04b2
-
-/*
- * Marvell SheevaPlug
- */
-#define MARVELL_VID            0x9e88
-#define MARVELL_SHEEVAPLUG_PID 0x9e8f
-
-#define FTDI_TURTELIZER_PID    0xBDC8 /* JTAG/RS-232 adapter by egnite GmBH */
-
-/*
- * GN Otometrics (http://www.otometrics.com)
- * Submitted by Ville Sundberg.
- */
-#define GN_OTOMETRICS_VID      0x0c33  /* Vendor ID */
-#define AURICAL_USB_PID                0x0010  /* Aurical USB Audiometer */
-
-/*
- * Bayer Ascensia Contour blood glucose meter USB-converter cable.
- * http://winglucofacts.com/cables/
- */
-#define BAYER_VID                      0x1A79
-#define BAYER_CONTOUR_CABLE_PID        0x6001
-
-/*
- * Marvell OpenRD Base, Client
- * http://www.open-rd.org
- * OpenRD Base, Client use VID 0x0403
- */
-#define MARVELL_OPENRD_PID     0x9e90
-
-/*
- * Hameg HO820 and HO870 interface (using VID 0x0403)
- */
-#define        HAMEG_HO820_PID         0xed74
-#define        HAMEG_HO870_PID         0xed71
 
 /*
  *   BmRequestType:  1100 0000b
@@ -1504,4 +554,3 @@ typedef enum {
  * B2..7       Length of message - (not including Byte 0)
  *
  */
-
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
new file mode 100644 (file)
index 0000000..da92b49
--- /dev/null
@@ -0,0 +1,986 @@
+/*
+ * vendor/product IDs (VID/PID) of devices using FTDI USB serial converters.
+ * Please keep numerically sorted within individual areas, thanks!
+ *
+ * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais
+ * from Rudolf Gugler
+ *
+ */
+
+
+/**********************************/
+/***** devices using FTDI VID *****/
+/**********************************/
+
+
+#define FTDI_VID       0x0403  /* Vendor Id */
+
+
+/*** "original" FTDI device PIDs ***/
+
+#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
+#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
+#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
+#define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */
+#define FTDI_SIO_PID   0x8372  /* Product Id SIO application of 8U100AX  */
+#define FTDI_232RL_PID  0xFBFA  /* Product ID for FT232RL */
+
+
+/*** third-party PIDs (using FTDI_VID) ***/
+
+/*
+ * Marvell OpenRD Base, Client
+ * http://www.open-rd.org
+ * OpenRD Base, Client use VID 0x0403
+ */
+#define MARVELL_OPENRD_PID     0x9e90
+
+/* www.candapter.com Ewert Energy Systems CANdapter device */
+#define FTDI_CANDAPTER_PID 0x9F80 /* Product Id */
+
+/* OOCDlink by Joern Kaipf <joernk@web.de>
+ * (http://www.joernonline.de/dw/doku.php?id=start&idx=projects:oocdlink) */
+#define FTDI_OOCDLINK_PID      0xbaf8  /* Amontec JTAGkey */
+
+/* Luminary Micro Stellaris Boards, VID = FTDI_VID */
+/* FTDI 2332C Dual channel device, side A=245 FIFO (JTAG), Side B=RS232 UART */
+#define LMI_LM3S_DEVEL_BOARD_PID       0xbcd8
+#define LMI_LM3S_EVAL_BOARD_PID                0xbcd9
+
+#define FTDI_TURTELIZER_PID    0xBDC8 /* JTAG/RS-232 adapter by egnite GmBH */
+
+/* OpenDCC (www.opendcc.de) product id */
+#define FTDI_OPENDCC_PID       0xBFD8
+#define FTDI_OPENDCC_SNIFFER_PID       0xBFD9
+#define FTDI_OPENDCC_THROTTLE_PID      0xBFDA
+#define FTDI_OPENDCC_GATEWAY_PID       0xBFDB
+
+/*
+ * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
+ */
+#define FTDI_RRCIRKITS_LOCOBUFFER_PID  0xc7d0  /* LocoBuffer USB */
+
+/* DMX4ALL DMX Interfaces */
+#define FTDI_DMX4ALL 0xC850
+
+/*
+ * ASK.fr devices
+ */
+#define FTDI_ASK_RDR400_PID    0xC991  /* ASK RDR 400 series card reader */
+
+/* www.starting-point-systems.com ÂµChameleon device */
+#define FTDI_MICRO_CHAMELEON_PID       0xCAA0  /* Product Id */
+
+/*
+ * Tactrix OpenPort (ECU) devices.
+ * OpenPort 1.3M submitted by Donour Sizemore.
+ * OpenPort 1.3S and 1.3U submitted by Ian Abbott.
+ */
+#define FTDI_TACTRIX_OPENPORT_13M_PID  0xCC48  /* OpenPort 1.3 Mitsubishi */
+#define FTDI_TACTRIX_OPENPORT_13S_PID  0xCC49  /* OpenPort 1.3 Subaru */
+#define FTDI_TACTRIX_OPENPORT_13U_PID  0xCC4A  /* OpenPort 1.3 Universal */
+
+/* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */
+/* the VID is the standard ftdi vid (FTDI_VID) */
+#define FTDI_SCS_DEVICE_0_PID 0xD010    /* SCS PTC-IIusb */
+#define FTDI_SCS_DEVICE_1_PID 0xD011    /* SCS Tracker / DSP TNC */
+#define FTDI_SCS_DEVICE_2_PID 0xD012
+#define FTDI_SCS_DEVICE_3_PID 0xD013
+#define FTDI_SCS_DEVICE_4_PID 0xD014
+#define FTDI_SCS_DEVICE_5_PID 0xD015
+#define FTDI_SCS_DEVICE_6_PID 0xD016
+#define FTDI_SCS_DEVICE_7_PID 0xD017
+
+/* iPlus device */
+#define FTDI_IPLUS_PID 0xD070 /* Product Id */
+#define FTDI_IPLUS2_PID 0xD071 /* Product Id */
+
+/*
+ * Gamma Scout (http://gamma-scout.com/). Submitted by rsc@runtux.com.
+ */
+#define FTDI_GAMMA_SCOUT_PID           0xD678  /* Gamma Scout online */
+
+/* Propox devices */
+#define FTDI_PROPOX_JTAGCABLEII_PID    0xD738
+
+/*
+ * Xsens Technologies BV products (http://www.xsens.com).
+ */
+#define XSENS_CONVERTER_0_PID  0xD388
+#define XSENS_CONVERTER_1_PID  0xD389
+#define XSENS_CONVERTER_2_PID  0xD38A
+#define XSENS_CONVERTER_3_PID  0xD38B
+#define XSENS_CONVERTER_4_PID  0xD38C
+#define XSENS_CONVERTER_5_PID  0xD38D
+#define XSENS_CONVERTER_6_PID  0xD38E
+#define XSENS_CONVERTER_7_PID  0xD38F
+
+/*
+ * NDI (www.ndigital.com) product ids
+ */
+#define FTDI_NDI_HUC_PID               0xDA70  /* NDI Host USB Converter */
+#define FTDI_NDI_SPECTRA_SCU_PID       0xDA71  /* NDI Spectra SCU */
+#define FTDI_NDI_FUTURE_2_PID          0xDA72  /* NDI future device #2 */
+#define FTDI_NDI_FUTURE_3_PID          0xDA73  /* NDI future device #3 */
+#define FTDI_NDI_AURORA_SCU_PID                0xDA74  /* NDI Aurora SCU */
+
+/*
+ * Westrex International devices submitted by Cory Lee
+ */
+#define FTDI_WESTREX_MODEL_777_PID     0xDC00  /* Model 777 */
+#define FTDI_WESTREX_MODEL_8900F_PID   0xDC01  /* Model 8900F */
+
+/*
+ * ACG Identification Technologies GmbH products (http://www.acg.de/).
+ * Submitted by anton -at- goto10 -dot- org.
+ */
+#define FTDI_ACG_HFDUAL_PID            0xDD20  /* HF Dual ISO Reader (RFID) */
+
+/*
+ * Definitions for Artemis astronomical USB based cameras
+ * Check it at http://www.artemisccd.co.uk/
+ */
+#define FTDI_ARTEMIS_PID       0xDF28  /* All Artemis Cameras */
+
+/*
+ * Definitions for ATIK Instruments astronomical USB based cameras
+ * Check it at http://www.atik-instruments.com/
+ */
+#define FTDI_ATIK_ATK16_PID    0xDF30  /* ATIK ATK-16 Grayscale Camera */
+#define FTDI_ATIK_ATK16C_PID   0xDF32  /* ATIK ATK-16C Colour Camera */
+#define FTDI_ATIK_ATK16HR_PID  0xDF31  /* ATIK ATK-16HR Grayscale Camera */
+#define FTDI_ATIK_ATK16HRC_PID 0xDF33  /* ATIK ATK-16HRC Colour Camera */
+#define FTDI_ATIK_ATK16IC_PID   0xDF35  /* ATIK ATK-16IC Grayscale Camera */
+
+/*
+ * Yost Engineering, Inc. products (www.yostengineering.com).
+ * PID 0xE050 submitted by Aaron Prose.
+ */
+#define FTDI_YEI_SERVOCENTER31_PID     0xE050  /* YEI ServoCenter3.1 USB */
+
+/*
+ * ELV USB devices submitted by Christian Abt of ELV (www.elv.de).
+ * All of these devices use FTDI's vendor ID (0x0403).
+ *
+ * The previously included PID for the UO 100 module was incorrect.
+ * In fact, that PID was for ELV's UR 100 USB-RS232 converter (0xFB58).
+ *
+ * Armin Laeuger originally sent the PID for the UM 100 module.
+ */
+#define FTDI_ELV_FHZ1300PC_PID 0xE0E8  /* FHZ 1300 PC */
+#define FTDI_ELV_WS500_PID     0xE0E9  /* PC-Wetterstation (WS 500) */
+#define FTDI_ELV_HS485_PID     0xE0EA  /* USB to RS-485 adapter */
+#define FTDI_ELV_EM1010PC_PID  0xE0EF  /* Engery monitor EM 1010 PC */
+#define FTDI_ELV_CSI8_PID      0xE0F0  /* Computer-Schalt-Interface (CSI 8) */
+#define FTDI_ELV_EM1000DL_PID  0xE0F1  /* PC-Datenlogger fuer Energiemonitor (EM 1000 DL) */
+#define FTDI_ELV_PCK100_PID    0xE0F2  /* PC-Kabeltester (PCK 100) */
+#define FTDI_ELV_RFP500_PID    0xE0F3  /* HF-Leistungsmesser (RFP 500) */
+#define FTDI_ELV_FS20SIG_PID   0xE0F4  /* Signalgeber (FS 20 SIG) */
+#define FTDI_ELV_WS300PC_PID   0xE0F6  /* PC-Wetterstation (WS 300 PC) */
+#define FTDI_PHI_FISCO_PID      0xE40B  /* PHI Fisco USB to Serial cable */
+#define FTDI_ELV_UAD8_PID      0xF068  /* USB-AD-Wandler (UAD 8) */
+#define FTDI_ELV_UDA7_PID      0xF069  /* USB-DA-Wandler (UDA 7) */
+#define FTDI_ELV_USI2_PID      0xF06A  /* USB-Schrittmotoren-Interface (USI 2) */
+#define FTDI_ELV_T1100_PID     0xF06B  /* Thermometer (T 1100) */
+#define FTDI_ELV_PCD200_PID    0xF06C  /* PC-Datenlogger (PCD 200) */
+#define FTDI_ELV_ULA200_PID    0xF06D  /* USB-LCD-Ansteuerung (ULA 200) */
+#define FTDI_ELV_ALC8500_PID   0xF06E  /* ALC 8500 Expert */
+#define FTDI_ELV_FHZ1000PC_PID 0xF06F  /* FHZ 1000 PC */
+#define FTDI_ELV_UR100_PID     0xFB58  /* USB-RS232-Umsetzer (UR 100) */
+#define FTDI_ELV_UM100_PID     0xFB5A  /* USB-Modul UM 100 */
+#define FTDI_ELV_UO100_PID     0xFB5B  /* USB-Modul UO 100 */
+/* Additional ELV PIDs that default to using the FTDI D2XX drivers on
+ * MS Windows, rather than the FTDI Virtual Com Port drivers.
+ * Maybe these will be easier to use with the libftdi/libusb user-space
+ * drivers, or possibly the Comedi drivers in some cases. */
+#define FTDI_ELV_CLI7000_PID   0xFB59  /* Computer-Light-Interface (CLI 7000) */
+#define FTDI_ELV_PPS7330_PID   0xFB5C  /* Processor-Power-Supply (PPS 7330) */
+#define FTDI_ELV_TFM100_PID    0xFB5D  /* Temperartur-Feuchte Messgeraet (TFM 100) */
+#define FTDI_ELV_UDF77_PID     0xFB5E  /* USB DCF Funkurh (UDF 77) */
+#define FTDI_ELV_UIO88_PID     0xFB5F  /* USB-I/O Interface (UIO 88) */
+
+/*
+ * EVER Eco Pro UPS (http://www.ever.com.pl/)
+ */
+
+#define        EVER_ECO_PRO_CDS        0xe520  /* RS-232 converter */
+
+/*
+ * Active Robots product ids.
+ */
+#define FTDI_ACTIVE_ROBOTS_PID 0xE548  /* USB comms board */
+
+/* Pyramid Computer GmbH */
+#define FTDI_PYRAMID_PID       0xE6C8  /* Pyramid Appliance Display */
+
+/* www.elsterelectricity.com Elster Unicom III Optical Probe */
+#define FTDI_ELSTER_UNICOM_PID         0xE700 /* Product Id */
+
+/*
+ * Gude Analog- und Digitalsysteme GmbH
+ */
+#define FTDI_GUDEADS_E808_PID    0xE808
+#define FTDI_GUDEADS_E809_PID    0xE809
+#define FTDI_GUDEADS_E80A_PID    0xE80A
+#define FTDI_GUDEADS_E80B_PID    0xE80B
+#define FTDI_GUDEADS_E80C_PID    0xE80C
+#define FTDI_GUDEADS_E80D_PID    0xE80D
+#define FTDI_GUDEADS_E80E_PID    0xE80E
+#define FTDI_GUDEADS_E80F_PID    0xE80F
+#define FTDI_GUDEADS_E888_PID    0xE888  /* Expert ISDN Control USB */
+#define FTDI_GUDEADS_E889_PID    0xE889  /* USB RS-232 OptoBridge */
+#define FTDI_GUDEADS_E88A_PID    0xE88A
+#define FTDI_GUDEADS_E88B_PID    0xE88B
+#define FTDI_GUDEADS_E88C_PID    0xE88C
+#define FTDI_GUDEADS_E88D_PID    0xE88D
+#define FTDI_GUDEADS_E88E_PID    0xE88E
+#define FTDI_GUDEADS_E88F_PID    0xE88F
+
+/*
+ * Eclo (http://www.eclo.pt/) product IDs.
+ * PID 0xEA90 submitted by Martin Grill.
+ */
+#define FTDI_ECLO_COM_1WIRE_PID        0xEA90  /* COM to 1-Wire USB adaptor */
+
+/* TNC-X USB-to-packet-radio adapter, versions prior to 3.0 (DLP module) */
+#define FTDI_TNC_X_PID         0xEBE0
+
+/*
+ * Teratronik product ids.
+ * Submitted by O. Wölfelschneider.
+ */
+#define FTDI_TERATRONIK_VCP_PID         0xEC88 /* Teratronik device (preferring VCP driver on windows) */
+#define FTDI_TERATRONIK_D2XX_PID 0xEC89        /* Teratronik device (preferring D2XX driver on windows) */
+
+/* Rig Expert Ukraine devices */
+#define FTDI_REU_TINY_PID              0xED22  /* RigExpert Tiny */
+
+/*
+ * Hameg HO820 and HO870 interface (using VID 0x0403)
+ */
+#define        HAMEG_HO820_PID         0xed74
+#define        HAMEG_HO870_PID         0xed71
+
+/*
+ *  MaxStream devices  www.maxstream.net
+ */
+#define FTDI_MAXSTREAM_PID     0xEE18  /* Xbee PKG-U Module */
+
+/*
+ * microHAM product IDs (http://www.microham.com).
+ * Submitted by Justin Burket (KL1RL) <zorton@jtan.com>
+ * and Mike Studer (K6EEP) <k6eep@hamsoftware.org>.
+ * Ian Abbott <abbotti@mev.co.uk> added a few more from the driver INF file.
+ */
+#define FTDI_MHAM_KW_PID 0xEEE8                /* USB-KW interface */
+#define FTDI_MHAM_YS_PID 0xEEE9                /* USB-YS interface */
+#define FTDI_MHAM_Y6_PID 0xEEEA                /* USB-Y6 interface */
+#define FTDI_MHAM_Y8_PID 0xEEEB                /* USB-Y8 interface */
+#define FTDI_MHAM_IC_PID 0xEEEC                /* USB-IC interface */
+#define FTDI_MHAM_DB9_PID 0xEEED       /* USB-DB9 interface */
+#define FTDI_MHAM_RS232_PID 0xEEEE     /* USB-RS232 interface */
+#define FTDI_MHAM_Y9_PID 0xEEEF                /* USB-Y9 interface */
+
+/* Domintell products  http://www.domintell.com */
+#define FTDI_DOMINTELL_DGQG_PID        0xEF50  /* Master */
+#define FTDI_DOMINTELL_DUSB_PID        0xEF51  /* DUSB01 module */
+
+/*
+ * The following are the values for the Perle Systems
+ * UltraPort USB serial converters
+ */
+#define FTDI_PERLE_ULTRAPORT_PID 0xF0C0        /* Perle UltraPort Product Id */
+
+/* Sprog II (Andrew Crosland's SprogII DCC interface) */
+#define FTDI_SPROG_II          0xF0C8
+
+/* an infrared receiver for user access control with IR tags */
+#define FTDI_PIEGROUP_PID      0xF208  /* Product Id */
+
+/* ACT Solutions HomePro ZWave interface
+   (http://www.act-solutions.com/HomePro.htm) */
+#define FTDI_ACTZWAVE_PID      0xF2D0
+
+/*
+ * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
+ * USB-TTY activ, USB-TTY passiv.  Some PIDs are used by several devices
+ * and I'm not entirely sure which are used by which.
+ */
+#define FTDI_4N_GALAXY_DE_1_PID        0xF3C0
+#define FTDI_4N_GALAXY_DE_2_PID        0xF3C1
+
+/*
+ * Linx Technologies product ids
+ */
+#define LINX_SDMUSBQSS_PID     0xF448  /* Linx SDM-USB-QS-S */
+#define LINX_MASTERDEVEL2_PID   0xF449   /* Linx Master Development 2.0 */
+#define LINX_FUTURE_0_PID   0xF44A   /* Linx future device */
+#define LINX_FUTURE_1_PID   0xF44B   /* Linx future device */
+#define LINX_FUTURE_2_PID   0xF44C   /* Linx future device */
+
+/*
+ * Oceanic product ids
+ */
+#define FTDI_OCEANIC_PID       0xF460  /* Oceanic dive instrument */
+
+/*
+ * SUUNTO product ids
+ */
+#define FTDI_SUUNTO_SPORTS_PID 0xF680  /* Suunto Sports instrument */
+
+/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */
+/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */
+#define FTDI_USB_UIRT_PID      0xF850  /* Product Id */
+
+/* CCS Inc. ICDU/ICDU40 product ID -
+ * the FT232BM is used in an in-circuit-debugger unit for PIC16's/PIC18's */
+#define FTDI_CCSICDU20_0_PID    0xF9D0
+#define FTDI_CCSICDU40_1_PID    0xF9D1
+#define FTDI_CCSMACHX_2_PID     0xF9D2
+#define FTDI_CCSLOAD_N_GO_3_PID 0xF9D3
+#define FTDI_CCSICDU64_4_PID    0xF9D4
+#define FTDI_CCSPRIME8_5_PID    0xF9D5
+
+/*
+ * The following are the values for the Matrix Orbital LCD displays,
+ * which are the FT232BM ( similar to the 8U232AM )
+ */
+#define FTDI_MTXORB_0_PID      0xFA00  /* Matrix Orbital Product Id */
+#define FTDI_MTXORB_1_PID      0xFA01  /* Matrix Orbital Product Id */
+#define FTDI_MTXORB_2_PID      0xFA02  /* Matrix Orbital Product Id */
+#define FTDI_MTXORB_3_PID      0xFA03  /* Matrix Orbital Product Id */
+#define FTDI_MTXORB_4_PID      0xFA04  /* Matrix Orbital Product Id */
+#define FTDI_MTXORB_5_PID      0xFA05  /* Matrix Orbital Product Id */
+#define FTDI_MTXORB_6_PID      0xFA06  /* Matrix Orbital Product Id */
+
+/*
+ * Home Electronics (www.home-electro.com) USB gadgets
+ */
+#define FTDI_HE_TIRA1_PID      0xFA78  /* Tira-1 IR transceiver */
+
+/* Inside Accesso contactless reader (http://www.insidefr.com) */
+#define INSIDE_ACCESSO         0xFAD0
+
+/*
+ * ThorLabs USB motor drivers
+ */
+#define FTDI_THORLABS_PID              0xfaf0 /* ThorLabs USB motor drivers */
+
+/*
+ * Protego product ids
+ */
+#define PROTEGO_SPECIAL_1      0xFC70  /* special/unknown device */
+#define PROTEGO_R2X0           0xFC71  /* R200-USB TRNG unit (R210, R220, and R230) */
+#define PROTEGO_SPECIAL_3      0xFC72  /* special/unknown device */
+#define PROTEGO_SPECIAL_4      0xFC73  /* special/unknown device */
+
+/*
+ * DSS-20 Sync Station for Sony Ericsson P800
+ */
+#define FTDI_DSS20_PID          0xFC82
+
+/* www.irtrans.de device */
+#define FTDI_IRTRANS_PID 0xFC60 /* Product Id */
+
+/*
+ * RM Michaelides CANview USB (http://www.rmcan.com) (FTDI_VID)
+ * CAN fieldbus interface adapter, added by port GmbH www.port.de)
+ * Ian Abbott changed the macro names for consistency.
+ */
+#define FTDI_RM_CANVIEW_PID    0xfd60  /* Product Id */
+/* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */
+#define FTDI_TTUSB_PID 0xFF20 /* Product Id */
+
+#define FTDI_USBX_707_PID 0xF857       /* ADSTech IR Blaster USBX-707 (FTDI_VID) */
+
+#define FTDI_RELAIS_PID        0xFA10  /* Relais device from Rudolf Gugler */
+
+/*
+ * PCDJ use ftdi based dj-controllers. The following PID is
+ * for their DAC-2 device http://www.pcdjhardware.com/DAC2.asp
+ * (the VID is the standard ftdi vid (FTDI_VID), PID sent by Wouter Paesen)
+ */
+#define FTDI_PCDJ_DAC2_PID 0xFA88
+
+#define FTDI_R2000KU_TRUE_RNG  0xFB80  /* R2000KU TRUE RNG (FTDI_VID) */
+
+/*
+ * DIEBOLD BCS SE923 (FTDI_VID)
+ */
+#define DIEBOLD_BCS_SE923_PID  0xfb99
+
+/* www.crystalfontz.com devices
+ * - thanx for providing free devices for evaluation !
+ * they use the ftdi chipset for the USB interface
+ * and the vendor id is the same
+ */
+#define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */
+#define FTDI_XF_634_PID 0xFC09 /* 634: 20x4 Character Display */
+#define FTDI_XF_547_PID 0xFC0A /* 547: Two line Display */
+#define FTDI_XF_633_PID 0xFC0B /* 633: 16x2 Character Display with Keys */
+#define FTDI_XF_631_PID 0xFC0C /* 631: 20x2 Character Display */
+#define FTDI_XF_635_PID 0xFC0D /* 635: 20x4 Character Display */
+#define FTDI_XF_640_PID 0xFC0E /* 640: Two line Display */
+#define FTDI_XF_642_PID 0xFC0F /* 642: Two line Display */
+
+/*
+ * Video Networks Limited / Homechoice in the UK use an ftdi-based device
+ * for their 1Mb broadband internet service.  The following PID is exhibited
+ * by the usb device supplied (the VID is the standard ftdi vid (FTDI_VID)
+ */
+#define FTDI_VNHCPCUSB_D_PID 0xfe38 /* Product Id */
+
+/* AlphaMicro Components AMC-232USB01 device (FTDI_VID) */
+#define FTDI_AMC232_PID 0xFF00 /* Product Id */
+
+/*
+ * IBS elektronik product ids (FTDI_VID)
+ * Submitted by Thomas Schleusener
+ */
+#define FTDI_IBS_US485_PID     0xff38  /* IBS US485 (USB<-->RS422/485 interface) */
+#define FTDI_IBS_PICPRO_PID    0xff39  /* IBS PIC-Programmer */
+#define FTDI_IBS_PCMCIA_PID    0xff3a  /* IBS Card reader for PCMCIA SRAM-cards */
+#define FTDI_IBS_PK1_PID       0xff3b  /* IBS PK1 - Particel counter */
+#define FTDI_IBS_RS232MON_PID  0xff3c  /* IBS RS232 - Monitor */
+#define FTDI_IBS_APP70_PID     0xff3d  /* APP 70 (dust monitoring system) */
+#define FTDI_IBS_PEDO_PID      0xff3e  /* IBS PEDO-Modem (RF modem 868.35 MHz) */
+#define FTDI_IBS_PROD_PID      0xff3f  /* future device */
+/* www.canusb.com Lawicel CANUSB device (FTDI_VID) */
+#define FTDI_CANUSB_PID 0xFFA8 /* Product Id */
+
+
+
+/********************************/
+/** third-party VID/PID combos **/
+/********************************/
+
+
+
+/*
+ * Atmel STK541
+ */
+#define ATMEL_VID              0x03eb /* Vendor ID */
+#define STK541_PID             0x2109 /* Zigbee Controller */
+
+/*
+ * Blackfin gnICE JTAG
+ * http://docs.blackfin.uclinux.org/doku.php?id=hw:jtag:gnice
+ */
+#define ADI_VID                0x0456
+#define ADI_GNICE_PID          0xF000
+#define ADI_GNICEPLUS_PID      0xF001
+
+/*
+ * RATOC REX-USB60F
+ */
+#define RATOC_VENDOR_ID                0x0584
+#define RATOC_PRODUCT_ID_USB60F        0xb020
+
+/*
+ * Definitions for B&B Electronics products.
+ */
+#define BANDB_VID              0x0856  /* B&B Electronics Vendor ID */
+#define BANDB_USOTL4_PID       0xAC01  /* USOTL4 Isolated RS-485 Converter */
+#define BANDB_USTL4_PID                0xAC02  /* USTL4 RS-485 Converter */
+#define BANDB_USO9ML2_PID      0xAC03  /* USO9ML2 Isolated RS-232 Converter */
+#define BANDB_USOPTL4_PID      0xAC11
+#define BANDB_USPTL4_PID       0xAC12
+#define BANDB_USO9ML2DR_2_PID  0xAC16
+#define BANDB_USO9ML2DR_PID    0xAC17
+#define BANDB_USOPTL4DR2_PID   0xAC18  /* USOPTL4R-2 2-port Isolated RS-232 Converter */
+#define BANDB_USOPTL4DR_PID    0xAC19
+#define BANDB_485USB9F_2W_PID  0xAC25
+#define BANDB_485USB9F_4W_PID  0xAC26
+#define BANDB_232USB9M_PID     0xAC27
+#define BANDB_485USBTB_2W_PID  0xAC33
+#define BANDB_485USBTB_4W_PID  0xAC34
+#define BANDB_TTL5USB9M_PID    0xAC49
+#define BANDB_TTL3USB9M_PID    0xAC50
+#define BANDB_ZZ_PROG1_USB_PID 0xBA02
+
+/*
+ * Intrepid Control Systems (http://www.intrepidcs.com/) ValueCAN and NeoVI
+ */
+#define INTREPID_VID           0x093C
+#define INTREPID_VALUECAN_PID  0x0601
+#define INTREPID_NEOVI_PID     0x0701
+
+/*
+ * Definitions for ID TECH (www.idt-net.com) devices
+ */
+#define IDTECH_VID             0x0ACD  /* ID TECH Vendor ID */
+#define IDTECH_IDT1221U_PID    0x0300  /* IDT1221U USB to RS-232 adapter */
+
+/*
+ * Definitions for Omnidirectional Control Technology, Inc. devices
+ */
+#define OCT_VID                        0x0B39  /* OCT vendor ID */
+/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
+/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
+/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
+#define OCT_US101_PID          0x0421  /* OCT US101 USB to RS-232 */
+
+/*
+ * Icom ID-1 digital transceiver
+ */
+
+#define ICOM_ID1_VID            0x0C26
+#define ICOM_ID1_PID            0x0004
+
+/*
+ * GN Otometrics (http://www.otometrics.com)
+ * Submitted by Ville Sundberg.
+ */
+#define GN_OTOMETRICS_VID      0x0c33  /* Vendor ID */
+#define AURICAL_USB_PID                0x0010  /* Aurical USB Audiometer */
+
+/*
+ * The following are the values for the Sealevel SeaLINK+ adapters.
+ * (Original list sent by Tuan Hoang.  Ian Abbott renamed the macros and
+ * removed some PIDs that don't seem to match any existing products.)
+ */
+#define SEALEVEL_VID           0x0c52  /* Sealevel Vendor ID */
+#define SEALEVEL_2101_PID      0x2101  /* SeaLINK+232 (2101/2105) */
+#define SEALEVEL_2102_PID      0x2102  /* SeaLINK+485 (2102) */
+#define SEALEVEL_2103_PID      0x2103  /* SeaLINK+232I (2103) */
+#define SEALEVEL_2104_PID      0x2104  /* SeaLINK+485I (2104) */
+#define SEALEVEL_2106_PID      0x9020  /* SeaLINK+422 (2106) */
+#define SEALEVEL_2201_1_PID    0x2211  /* SeaPORT+2/232 (2201) Port 1 */
+#define SEALEVEL_2201_2_PID    0x2221  /* SeaPORT+2/232 (2201) Port 2 */
+#define SEALEVEL_2202_1_PID    0x2212  /* SeaPORT+2/485 (2202) Port 1 */
+#define SEALEVEL_2202_2_PID    0x2222  /* SeaPORT+2/485 (2202) Port 2 */
+#define SEALEVEL_2203_1_PID    0x2213  /* SeaPORT+2 (2203) Port 1 */
+#define SEALEVEL_2203_2_PID    0x2223  /* SeaPORT+2 (2203) Port 2 */
+#define SEALEVEL_2401_1_PID    0x2411  /* SeaPORT+4/232 (2401) Port 1 */
+#define SEALEVEL_2401_2_PID    0x2421  /* SeaPORT+4/232 (2401) Port 2 */
+#define SEALEVEL_2401_3_PID    0x2431  /* SeaPORT+4/232 (2401) Port 3 */
+#define SEALEVEL_2401_4_PID    0x2441  /* SeaPORT+4/232 (2401) Port 4 */
+#define SEALEVEL_2402_1_PID    0x2412  /* SeaPORT+4/485 (2402) Port 1 */
+#define SEALEVEL_2402_2_PID    0x2422  /* SeaPORT+4/485 (2402) Port 2 */
+#define SEALEVEL_2402_3_PID    0x2432  /* SeaPORT+4/485 (2402) Port 3 */
+#define SEALEVEL_2402_4_PID    0x2442  /* SeaPORT+4/485 (2402) Port 4 */
+#define SEALEVEL_2403_1_PID    0x2413  /* SeaPORT+4 (2403) Port 1 */
+#define SEALEVEL_2403_2_PID    0x2423  /* SeaPORT+4 (2403) Port 2 */
+#define SEALEVEL_2403_3_PID    0x2433  /* SeaPORT+4 (2403) Port 3 */
+#define SEALEVEL_2403_4_PID    0x2443  /* SeaPORT+4 (2403) Port 4 */
+#define SEALEVEL_2801_1_PID    0X2811  /* SeaLINK+8/232 (2801) Port 1 */
+#define SEALEVEL_2801_2_PID    0X2821  /* SeaLINK+8/232 (2801) Port 2 */
+#define SEALEVEL_2801_3_PID    0X2831  /* SeaLINK+8/232 (2801) Port 3 */
+#define SEALEVEL_2801_4_PID    0X2841  /* SeaLINK+8/232 (2801) Port 4 */
+#define SEALEVEL_2801_5_PID    0X2851  /* SeaLINK+8/232 (2801) Port 5 */
+#define SEALEVEL_2801_6_PID    0X2861  /* SeaLINK+8/232 (2801) Port 6 */
+#define SEALEVEL_2801_7_PID    0X2871  /* SeaLINK+8/232 (2801) Port 7 */
+#define SEALEVEL_2801_8_PID    0X2881  /* SeaLINK+8/232 (2801) Port 8 */
+#define SEALEVEL_2802_1_PID    0X2812  /* SeaLINK+8/485 (2802) Port 1 */
+#define SEALEVEL_2802_2_PID    0X2822  /* SeaLINK+8/485 (2802) Port 2 */
+#define SEALEVEL_2802_3_PID    0X2832  /* SeaLINK+8/485 (2802) Port 3 */
+#define SEALEVEL_2802_4_PID    0X2842  /* SeaLINK+8/485 (2802) Port 4 */
+#define SEALEVEL_2802_5_PID    0X2852  /* SeaLINK+8/485 (2802) Port 5 */
+#define SEALEVEL_2802_6_PID    0X2862  /* SeaLINK+8/485 (2802) Port 6 */
+#define SEALEVEL_2802_7_PID    0X2872  /* SeaLINK+8/485 (2802) Port 7 */
+#define SEALEVEL_2802_8_PID    0X2882  /* SeaLINK+8/485 (2802) Port 8 */
+#define SEALEVEL_2803_1_PID    0X2813  /* SeaLINK+8 (2803) Port 1 */
+#define SEALEVEL_2803_2_PID    0X2823  /* SeaLINK+8 (2803) Port 2 */
+#define SEALEVEL_2803_3_PID    0X2833  /* SeaLINK+8 (2803) Port 3 */
+#define SEALEVEL_2803_4_PID    0X2843  /* SeaLINK+8 (2803) Port 4 */
+#define SEALEVEL_2803_5_PID    0X2853  /* SeaLINK+8 (2803) Port 5 */
+#define SEALEVEL_2803_6_PID    0X2863  /* SeaLINK+8 (2803) Port 6 */
+#define SEALEVEL_2803_7_PID    0X2873  /* SeaLINK+8 (2803) Port 7 */
+#define SEALEVEL_2803_8_PID    0X2883  /* SeaLINK+8 (2803) Port 8 */
+
+/*
+ * JETI SPECTROMETER SPECBOS 1201
+ * http://www.jeti.com/products/sys/scb/scb1201.php
+ */
+#define JETI_VID               0x0c6c
+#define JETI_SPC1201_PID       0x04b2
+
+/*
+ * FTDI USB UART chips used in construction projects from the
+ * Elektor Electronics magazine (http://elektor-electronics.co.uk)
+ */
+#define ELEKTOR_VID            0x0C7D
+#define ELEKTOR_FT323R_PID     0x0005  /* RFID-Reader, issue 09-2006 */
+
+/*
+ * Posiflex inc retail equipment (http://www.posiflex.com.tw)
+ */
+#define POSIFLEX_VID           0x0d3a  /* Vendor ID */
+#define POSIFLEX_PP7000_PID    0x0300  /* PP-7000II thermal printer */
+
+/*
+ * The following are the values for two KOBIL chipcard terminals.
+ */
+#define KOBIL_VID              0x0d46  /* KOBIL Vendor ID */
+#define KOBIL_CONV_B1_PID      0x2020  /* KOBIL Konverter for B1 */
+#define KOBIL_CONV_KAAN_PID    0x2021  /* KOBIL_Konverter for KAAN */
+
+#define FTDI_NF_RIC_VID        0x0DCD  /* Vendor Id */
+#define FTDI_NF_RIC_PID        0x0001  /* Product Id */
+
+/*
+ * Falcom Wireless Communications GmbH
+ */
+#define FALCOM_VID             0x0F94  /* Vendor Id */
+#define FALCOM_TWIST_PID       0x0001  /* Falcom Twist USB GPRS modem */
+#define FALCOM_SAMBA_PID       0x0005  /* Falcom Samba USB GPRS modem */
+
+/* Larsen and Brusgaard AltiTrack/USBtrack  */
+#define LARSENBRUSGAARD_VID            0x0FD8
+#define LB_ALTITRACK_PID               0x0001
+
+/*
+ * TTi (Thurlby Thandar Instruments)
+ */
+#define TTI_VID                        0x103E  /* Vendor Id */
+#define TTI_QL355P_PID         0x03E8  /* TTi QL355P power supply */
+
+/* Interbiometrics USB I/O Board */
+/* Developed for Interbiometrics by Rudolf Gugler */
+#define INTERBIOMETRICS_VID              0x1209
+#define INTERBIOMETRICS_IOBOARD_PID      0x1002
+#define INTERBIOMETRICS_MINI_IOBOARD_PID 0x1006
+
+/*
+ * Testo products (http://www.testo.com/)
+ * Submitted by Colin Leroy
+ */
+#define TESTO_VID                      0x128D
+#define TESTO_USB_INTERFACE_PID                0x0001
+
+/*
+ * Mobility Electronics products.
+ */
+#define MOBILITY_VID                   0x1342
+#define MOBILITY_USB_SERIAL_PID                0x0202  /* EasiDock USB 200 serial */
+
+/*
+ * FIC / OpenMoko, Inc. http://wiki.openmoko.org/wiki/Neo1973_Debug_Board_v3
+ * Submitted by Harald Welte <laforge@openmoko.org>
+ */
+#define        FIC_VID                 0x1457
+#define        FIC_NEO1973_DEBUG_PID   0x5118
+
+/* Olimex */
+#define OLIMEX_VID                     0x15BA
+#define OLIMEX_ARM_USB_OCD_PID         0x0003
+
+/*
+ * Telldus Technologies
+ */
+#define TELLDUS_VID                    0x1781  /* Vendor ID */
+#define TELLDUS_TELLSTICK_PID          0x0C30  /* RF control dongle 433 MHz using FT232RL */
+
+/*
+ * Bayer Ascensia Contour blood glucose meter USB-converter cable.
+ * http://winglucofacts.com/cables/
+ */
+#define BAYER_VID                      0x1A79
+#define BAYER_CONTOUR_CABLE_PID        0x6001
+
+/*
+ * The following are the values for the Matrix Orbital FTDI Range
+ * Anything in this range will use an FT232RL.
+ */
+#define MTXORB_VID                     0x1B3D
+#define MTXORB_FTDI_RANGE_0100_PID     0x0100
+#define MTXORB_FTDI_RANGE_0101_PID     0x0101
+#define MTXORB_FTDI_RANGE_0102_PID     0x0102
+#define MTXORB_FTDI_RANGE_0103_PID     0x0103
+#define MTXORB_FTDI_RANGE_0104_PID     0x0104
+#define MTXORB_FTDI_RANGE_0105_PID     0x0105
+#define MTXORB_FTDI_RANGE_0106_PID     0x0106
+#define MTXORB_FTDI_RANGE_0107_PID     0x0107
+#define MTXORB_FTDI_RANGE_0108_PID     0x0108
+#define MTXORB_FTDI_RANGE_0109_PID     0x0109
+#define MTXORB_FTDI_RANGE_010A_PID     0x010A
+#define MTXORB_FTDI_RANGE_010B_PID     0x010B
+#define MTXORB_FTDI_RANGE_010C_PID     0x010C
+#define MTXORB_FTDI_RANGE_010D_PID     0x010D
+#define MTXORB_FTDI_RANGE_010E_PID     0x010E
+#define MTXORB_FTDI_RANGE_010F_PID     0x010F
+#define MTXORB_FTDI_RANGE_0110_PID     0x0110
+#define MTXORB_FTDI_RANGE_0111_PID     0x0111
+#define MTXORB_FTDI_RANGE_0112_PID     0x0112
+#define MTXORB_FTDI_RANGE_0113_PID     0x0113
+#define MTXORB_FTDI_RANGE_0114_PID     0x0114
+#define MTXORB_FTDI_RANGE_0115_PID     0x0115
+#define MTXORB_FTDI_RANGE_0116_PID     0x0116
+#define MTXORB_FTDI_RANGE_0117_PID     0x0117
+#define MTXORB_FTDI_RANGE_0118_PID     0x0118
+#define MTXORB_FTDI_RANGE_0119_PID     0x0119
+#define MTXORB_FTDI_RANGE_011A_PID     0x011A
+#define MTXORB_FTDI_RANGE_011B_PID     0x011B
+#define MTXORB_FTDI_RANGE_011C_PID     0x011C
+#define MTXORB_FTDI_RANGE_011D_PID     0x011D
+#define MTXORB_FTDI_RANGE_011E_PID     0x011E
+#define MTXORB_FTDI_RANGE_011F_PID     0x011F
+#define MTXORB_FTDI_RANGE_0120_PID     0x0120
+#define MTXORB_FTDI_RANGE_0121_PID     0x0121
+#define MTXORB_FTDI_RANGE_0122_PID     0x0122
+#define MTXORB_FTDI_RANGE_0123_PID     0x0123
+#define MTXORB_FTDI_RANGE_0124_PID     0x0124
+#define MTXORB_FTDI_RANGE_0125_PID     0x0125
+#define MTXORB_FTDI_RANGE_0126_PID     0x0126
+#define MTXORB_FTDI_RANGE_0127_PID     0x0127
+#define MTXORB_FTDI_RANGE_0128_PID     0x0128
+#define MTXORB_FTDI_RANGE_0129_PID     0x0129
+#define MTXORB_FTDI_RANGE_012A_PID     0x012A
+#define MTXORB_FTDI_RANGE_012B_PID     0x012B
+#define MTXORB_FTDI_RANGE_012C_PID     0x012C
+#define MTXORB_FTDI_RANGE_012D_PID     0x012D
+#define MTXORB_FTDI_RANGE_012E_PID     0x012E
+#define MTXORB_FTDI_RANGE_012F_PID     0x012F
+#define MTXORB_FTDI_RANGE_0130_PID     0x0130
+#define MTXORB_FTDI_RANGE_0131_PID     0x0131
+#define MTXORB_FTDI_RANGE_0132_PID     0x0132
+#define MTXORB_FTDI_RANGE_0133_PID     0x0133
+#define MTXORB_FTDI_RANGE_0134_PID     0x0134
+#define MTXORB_FTDI_RANGE_0135_PID     0x0135
+#define MTXORB_FTDI_RANGE_0136_PID     0x0136
+#define MTXORB_FTDI_RANGE_0137_PID     0x0137
+#define MTXORB_FTDI_RANGE_0138_PID     0x0138
+#define MTXORB_FTDI_RANGE_0139_PID     0x0139
+#define MTXORB_FTDI_RANGE_013A_PID     0x013A
+#define MTXORB_FTDI_RANGE_013B_PID     0x013B
+#define MTXORB_FTDI_RANGE_013C_PID     0x013C
+#define MTXORB_FTDI_RANGE_013D_PID     0x013D
+#define MTXORB_FTDI_RANGE_013E_PID     0x013E
+#define MTXORB_FTDI_RANGE_013F_PID     0x013F
+#define MTXORB_FTDI_RANGE_0140_PID     0x0140
+#define MTXORB_FTDI_RANGE_0141_PID     0x0141
+#define MTXORB_FTDI_RANGE_0142_PID     0x0142
+#define MTXORB_FTDI_RANGE_0143_PID     0x0143
+#define MTXORB_FTDI_RANGE_0144_PID     0x0144
+#define MTXORB_FTDI_RANGE_0145_PID     0x0145
+#define MTXORB_FTDI_RANGE_0146_PID     0x0146
+#define MTXORB_FTDI_RANGE_0147_PID     0x0147
+#define MTXORB_FTDI_RANGE_0148_PID     0x0148
+#define MTXORB_FTDI_RANGE_0149_PID     0x0149
+#define MTXORB_FTDI_RANGE_014A_PID     0x014A
+#define MTXORB_FTDI_RANGE_014B_PID     0x014B
+#define MTXORB_FTDI_RANGE_014C_PID     0x014C
+#define MTXORB_FTDI_RANGE_014D_PID     0x014D
+#define MTXORB_FTDI_RANGE_014E_PID     0x014E
+#define MTXORB_FTDI_RANGE_014F_PID     0x014F
+#define MTXORB_FTDI_RANGE_0150_PID     0x0150
+#define MTXORB_FTDI_RANGE_0151_PID     0x0151
+#define MTXORB_FTDI_RANGE_0152_PID     0x0152
+#define MTXORB_FTDI_RANGE_0153_PID     0x0153
+#define MTXORB_FTDI_RANGE_0154_PID     0x0154
+#define MTXORB_FTDI_RANGE_0155_PID     0x0155
+#define MTXORB_FTDI_RANGE_0156_PID     0x0156
+#define MTXORB_FTDI_RANGE_0157_PID     0x0157
+#define MTXORB_FTDI_RANGE_0158_PID     0x0158
+#define MTXORB_FTDI_RANGE_0159_PID     0x0159
+#define MTXORB_FTDI_RANGE_015A_PID     0x015A
+#define MTXORB_FTDI_RANGE_015B_PID     0x015B
+#define MTXORB_FTDI_RANGE_015C_PID     0x015C
+#define MTXORB_FTDI_RANGE_015D_PID     0x015D
+#define MTXORB_FTDI_RANGE_015E_PID     0x015E
+#define MTXORB_FTDI_RANGE_015F_PID     0x015F
+#define MTXORB_FTDI_RANGE_0160_PID     0x0160
+#define MTXORB_FTDI_RANGE_0161_PID     0x0161
+#define MTXORB_FTDI_RANGE_0162_PID     0x0162
+#define MTXORB_FTDI_RANGE_0163_PID     0x0163
+#define MTXORB_FTDI_RANGE_0164_PID     0x0164
+#define MTXORB_FTDI_RANGE_0165_PID     0x0165
+#define MTXORB_FTDI_RANGE_0166_PID     0x0166
+#define MTXORB_FTDI_RANGE_0167_PID     0x0167
+#define MTXORB_FTDI_RANGE_0168_PID     0x0168
+#define MTXORB_FTDI_RANGE_0169_PID     0x0169
+#define MTXORB_FTDI_RANGE_016A_PID     0x016A
+#define MTXORB_FTDI_RANGE_016B_PID     0x016B
+#define MTXORB_FTDI_RANGE_016C_PID     0x016C
+#define MTXORB_FTDI_RANGE_016D_PID     0x016D
+#define MTXORB_FTDI_RANGE_016E_PID     0x016E
+#define MTXORB_FTDI_RANGE_016F_PID     0x016F
+#define MTXORB_FTDI_RANGE_0170_PID     0x0170
+#define MTXORB_FTDI_RANGE_0171_PID     0x0171
+#define MTXORB_FTDI_RANGE_0172_PID     0x0172
+#define MTXORB_FTDI_RANGE_0173_PID     0x0173
+#define MTXORB_FTDI_RANGE_0174_PID     0x0174
+#define MTXORB_FTDI_RANGE_0175_PID     0x0175
+#define MTXORB_FTDI_RANGE_0176_PID     0x0176
+#define MTXORB_FTDI_RANGE_0177_PID     0x0177
+#define MTXORB_FTDI_RANGE_0178_PID     0x0178
+#define MTXORB_FTDI_RANGE_0179_PID     0x0179
+#define MTXORB_FTDI_RANGE_017A_PID     0x017A
+#define MTXORB_FTDI_RANGE_017B_PID     0x017B
+#define MTXORB_FTDI_RANGE_017C_PID     0x017C
+#define MTXORB_FTDI_RANGE_017D_PID     0x017D
+#define MTXORB_FTDI_RANGE_017E_PID     0x017E
+#define MTXORB_FTDI_RANGE_017F_PID     0x017F
+#define MTXORB_FTDI_RANGE_0180_PID     0x0180
+#define MTXORB_FTDI_RANGE_0181_PID     0x0181
+#define MTXORB_FTDI_RANGE_0182_PID     0x0182
+#define MTXORB_FTDI_RANGE_0183_PID     0x0183
+#define MTXORB_FTDI_RANGE_0184_PID     0x0184
+#define MTXORB_FTDI_RANGE_0185_PID     0x0185
+#define MTXORB_FTDI_RANGE_0186_PID     0x0186
+#define MTXORB_FTDI_RANGE_0187_PID     0x0187
+#define MTXORB_FTDI_RANGE_0188_PID     0x0188
+#define MTXORB_FTDI_RANGE_0189_PID     0x0189
+#define MTXORB_FTDI_RANGE_018A_PID     0x018A
+#define MTXORB_FTDI_RANGE_018B_PID     0x018B
+#define MTXORB_FTDI_RANGE_018C_PID     0x018C
+#define MTXORB_FTDI_RANGE_018D_PID     0x018D
+#define MTXORB_FTDI_RANGE_018E_PID     0x018E
+#define MTXORB_FTDI_RANGE_018F_PID     0x018F
+#define MTXORB_FTDI_RANGE_0190_PID     0x0190
+#define MTXORB_FTDI_RANGE_0191_PID     0x0191
+#define MTXORB_FTDI_RANGE_0192_PID     0x0192
+#define MTXORB_FTDI_RANGE_0193_PID     0x0193
+#define MTXORB_FTDI_RANGE_0194_PID     0x0194
+#define MTXORB_FTDI_RANGE_0195_PID     0x0195
+#define MTXORB_FTDI_RANGE_0196_PID     0x0196
+#define MTXORB_FTDI_RANGE_0197_PID     0x0197
+#define MTXORB_FTDI_RANGE_0198_PID     0x0198
+#define MTXORB_FTDI_RANGE_0199_PID     0x0199
+#define MTXORB_FTDI_RANGE_019A_PID     0x019A
+#define MTXORB_FTDI_RANGE_019B_PID     0x019B
+#define MTXORB_FTDI_RANGE_019C_PID     0x019C
+#define MTXORB_FTDI_RANGE_019D_PID     0x019D
+#define MTXORB_FTDI_RANGE_019E_PID     0x019E
+#define MTXORB_FTDI_RANGE_019F_PID     0x019F
+#define MTXORB_FTDI_RANGE_01A0_PID     0x01A0
+#define MTXORB_FTDI_RANGE_01A1_PID     0x01A1
+#define MTXORB_FTDI_RANGE_01A2_PID     0x01A2
+#define MTXORB_FTDI_RANGE_01A3_PID     0x01A3
+#define MTXORB_FTDI_RANGE_01A4_PID     0x01A4
+#define MTXORB_FTDI_RANGE_01A5_PID     0x01A5
+#define MTXORB_FTDI_RANGE_01A6_PID     0x01A6
+#define MTXORB_FTDI_RANGE_01A7_PID     0x01A7
+#define MTXORB_FTDI_RANGE_01A8_PID     0x01A8
+#define MTXORB_FTDI_RANGE_01A9_PID     0x01A9
+#define MTXORB_FTDI_RANGE_01AA_PID     0x01AA
+#define MTXORB_FTDI_RANGE_01AB_PID     0x01AB
+#define MTXORB_FTDI_RANGE_01AC_PID     0x01AC
+#define MTXORB_FTDI_RANGE_01AD_PID     0x01AD
+#define MTXORB_FTDI_RANGE_01AE_PID     0x01AE
+#define MTXORB_FTDI_RANGE_01AF_PID     0x01AF
+#define MTXORB_FTDI_RANGE_01B0_PID     0x01B0
+#define MTXORB_FTDI_RANGE_01B1_PID     0x01B1
+#define MTXORB_FTDI_RANGE_01B2_PID     0x01B2
+#define MTXORB_FTDI_RANGE_01B3_PID     0x01B3
+#define MTXORB_FTDI_RANGE_01B4_PID     0x01B4
+#define MTXORB_FTDI_RANGE_01B5_PID     0x01B5
+#define MTXORB_FTDI_RANGE_01B6_PID     0x01B6
+#define MTXORB_FTDI_RANGE_01B7_PID     0x01B7
+#define MTXORB_FTDI_RANGE_01B8_PID     0x01B8
+#define MTXORB_FTDI_RANGE_01B9_PID     0x01B9
+#define MTXORB_FTDI_RANGE_01BA_PID     0x01BA
+#define MTXORB_FTDI_RANGE_01BB_PID     0x01BB
+#define MTXORB_FTDI_RANGE_01BC_PID     0x01BC
+#define MTXORB_FTDI_RANGE_01BD_PID     0x01BD
+#define MTXORB_FTDI_RANGE_01BE_PID     0x01BE
+#define MTXORB_FTDI_RANGE_01BF_PID     0x01BF
+#define MTXORB_FTDI_RANGE_01C0_PID     0x01C0
+#define MTXORB_FTDI_RANGE_01C1_PID     0x01C1
+#define MTXORB_FTDI_RANGE_01C2_PID     0x01C2
+#define MTXORB_FTDI_RANGE_01C3_PID     0x01C3
+#define MTXORB_FTDI_RANGE_01C4_PID     0x01C4
+#define MTXORB_FTDI_RANGE_01C5_PID     0x01C5
+#define MTXORB_FTDI_RANGE_01C6_PID     0x01C6
+#define MTXORB_FTDI_RANGE_01C7_PID     0x01C7
+#define MTXORB_FTDI_RANGE_01C8_PID     0x01C8
+#define MTXORB_FTDI_RANGE_01C9_PID     0x01C9
+#define MTXORB_FTDI_RANGE_01CA_PID     0x01CA
+#define MTXORB_FTDI_RANGE_01CB_PID     0x01CB
+#define MTXORB_FTDI_RANGE_01CC_PID     0x01CC
+#define MTXORB_FTDI_RANGE_01CD_PID     0x01CD
+#define MTXORB_FTDI_RANGE_01CE_PID     0x01CE
+#define MTXORB_FTDI_RANGE_01CF_PID     0x01CF
+#define MTXORB_FTDI_RANGE_01D0_PID     0x01D0
+#define MTXORB_FTDI_RANGE_01D1_PID     0x01D1
+#define MTXORB_FTDI_RANGE_01D2_PID     0x01D2
+#define MTXORB_FTDI_RANGE_01D3_PID     0x01D3
+#define MTXORB_FTDI_RANGE_01D4_PID     0x01D4
+#define MTXORB_FTDI_RANGE_01D5_PID     0x01D5
+#define MTXORB_FTDI_RANGE_01D6_PID     0x01D6
+#define MTXORB_FTDI_RANGE_01D7_PID     0x01D7
+#define MTXORB_FTDI_RANGE_01D8_PID     0x01D8
+#define MTXORB_FTDI_RANGE_01D9_PID     0x01D9
+#define MTXORB_FTDI_RANGE_01DA_PID     0x01DA
+#define MTXORB_FTDI_RANGE_01DB_PID     0x01DB
+#define MTXORB_FTDI_RANGE_01DC_PID     0x01DC
+#define MTXORB_FTDI_RANGE_01DD_PID     0x01DD
+#define MTXORB_FTDI_RANGE_01DE_PID     0x01DE
+#define MTXORB_FTDI_RANGE_01DF_PID     0x01DF
+#define MTXORB_FTDI_RANGE_01E0_PID     0x01E0
+#define MTXORB_FTDI_RANGE_01E1_PID     0x01E1
+#define MTXORB_FTDI_RANGE_01E2_PID     0x01E2
+#define MTXORB_FTDI_RANGE_01E3_PID     0x01E3
+#define MTXORB_FTDI_RANGE_01E4_PID     0x01E4
+#define MTXORB_FTDI_RANGE_01E5_PID     0x01E5
+#define MTXORB_FTDI_RANGE_01E6_PID     0x01E6
+#define MTXORB_FTDI_RANGE_01E7_PID     0x01E7
+#define MTXORB_FTDI_RANGE_01E8_PID     0x01E8
+#define MTXORB_FTDI_RANGE_01E9_PID     0x01E9
+#define MTXORB_FTDI_RANGE_01EA_PID     0x01EA
+#define MTXORB_FTDI_RANGE_01EB_PID     0x01EB
+#define MTXORB_FTDI_RANGE_01EC_PID     0x01EC
+#define MTXORB_FTDI_RANGE_01ED_PID     0x01ED
+#define MTXORB_FTDI_RANGE_01EE_PID     0x01EE
+#define MTXORB_FTDI_RANGE_01EF_PID     0x01EF
+#define MTXORB_FTDI_RANGE_01F0_PID     0x01F0
+#define MTXORB_FTDI_RANGE_01F1_PID     0x01F1
+#define MTXORB_FTDI_RANGE_01F2_PID     0x01F2
+#define MTXORB_FTDI_RANGE_01F3_PID     0x01F3
+#define MTXORB_FTDI_RANGE_01F4_PID     0x01F4
+#define MTXORB_FTDI_RANGE_01F5_PID     0x01F5
+#define MTXORB_FTDI_RANGE_01F6_PID     0x01F6
+#define MTXORB_FTDI_RANGE_01F7_PID     0x01F7
+#define MTXORB_FTDI_RANGE_01F8_PID     0x01F8
+#define MTXORB_FTDI_RANGE_01F9_PID     0x01F9
+#define MTXORB_FTDI_RANGE_01FA_PID     0x01FA
+#define MTXORB_FTDI_RANGE_01FB_PID     0x01FB
+#define MTXORB_FTDI_RANGE_01FC_PID     0x01FC
+#define MTXORB_FTDI_RANGE_01FD_PID     0x01FD
+#define MTXORB_FTDI_RANGE_01FE_PID     0x01FE
+#define MTXORB_FTDI_RANGE_01FF_PID     0x01FF
+
+
+
+/*
+ * The Mobility Lab (TML)
+ * Submitted by Pierre Castella
+ */
+#define TML_VID                        0x1B91  /* Vendor ID */
+#define TML_USB_SERIAL_PID     0x0064  /* USB - Serial Converter */
+
+/* Alti-2 products  http://www.alti-2.com */
+#define ALTI2_VID      0x1BC9
+#define ALTI2_N3_PID   0x6001  /* Neptune 3 */
+
+/*
+ * Dresden Elektronic Sensor Terminal Board
+ */
+#define DE_VID                 0x1cf1 /* Vendor ID */
+#define STB_PID                        0x0001 /* Sensor Terminal Board */
+#define WHT_PID                        0x0004 /* Wireless Handheld Terminal */
+
+/*
+ * Papouch products (http://www.papouch.com/)
+ * Submitted by Folkert van Heusden
+ */
+
+#define PAPOUCH_VID                    0x5050  /* Vendor ID */
+#define PAPOUCH_TMU_PID                        0x0400  /* TMU USB Thermometer */
+#define PAPOUCH_QUIDO4x4_PID           0x0900  /* Quido 4/4 Module */
+
+/*
+ * Marvell SheevaPlug
+ */
+#define MARVELL_VID            0x9e88
+#define MARVELL_SHEEVAPLUG_PID 0x9e8f
+
+/*
+ * Evolution Robotics products (http://www.evolution.com/).
+ * Submitted by Shawn M. Lavelle.
+ */
+#define EVOLUTION_VID          0xDEEE  /* Vendor ID */
+#define EVOLUTION_ER1_PID      0x0300  /* ER1 Control Module */
+#define EVO_8U232AM_PID        0x02FF  /* Evolution robotics RCM2 (FT232AM)*/
+#define EVO_HYBRID_PID         0x0302  /* Evolution robotics RCM4 PID (FT232BM)*/
+#define EVO_RCM4_PID           0x0303  /* Evolution robotics RCM4 PID */
index bbe005cefcfbee6fc27d139541146c7174999468..f1ea3a33b6e6378ad767e7c4783cebf8defb34a6 100644 (file)
@@ -276,7 +276,7 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port)
        if (port->write_urb_busy)
                start_io = false;
        else {
-               start_io = (__kfifo_len(port->write_fifo) != 0);
+               start_io = (kfifo_len(&port->write_fifo) != 0);
                port->write_urb_busy = start_io;
        }
        spin_unlock_irqrestore(&port->lock, flags);
@@ -285,7 +285,7 @@ static int usb_serial_generic_write_start(struct usb_serial_port *port)
                return 0;
 
        data = port->write_urb->transfer_buffer;
-       count = kfifo_get(port->write_fifo, data, port->bulk_out_size);
+       count = kfifo_out_locked(&port->write_fifo, data, port->bulk_out_size, &port->lock);
        usb_serial_debug_data(debug, &port->dev, __func__, count, data);
 
        /* set up our urb */
@@ -345,7 +345,7 @@ int usb_serial_generic_write(struct tty_struct *tty,
                return usb_serial_multi_urb_write(tty, port,
                                                  buf, count);
 
-       count = kfifo_put(port->write_fifo, buf, count);
+       count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock);
        result = usb_serial_generic_write_start(port);
 
        if (result >= 0)
@@ -370,7 +370,7 @@ int usb_serial_generic_write_room(struct tty_struct *tty)
                                (serial->type->max_in_flight_urbs -
                                 port->urbs_in_flight);
        } else if (serial->num_bulk_out)
-               room = port->write_fifo->size - __kfifo_len(port->write_fifo);
+               room = kfifo_avail(&port->write_fifo);
        spin_unlock_irqrestore(&port->lock, flags);
 
        dbg("%s - returns %d", __func__, room);
@@ -391,7 +391,7 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
                chars = port->tx_bytes_flight;
                spin_unlock_irqrestore(&port->lock, flags);
        } else if (serial->num_bulk_out)
-               chars = kfifo_len(port->write_fifo);
+               chars = kfifo_len(&port->write_fifo);
 
        dbg("%s - returns %d", __func__, chars);
        return chars;
@@ -507,7 +507,7 @@ void usb_serial_generic_write_bulk_callback(struct urb *urb)
                if (status) {
                        dbg("%s - nonzero multi-urb write bulk status "
                                "received: %d", __func__, status);
-                       kfifo_reset(port->write_fifo);
+                       kfifo_reset_out(&port->write_fifo);
                } else
                        usb_serial_generic_write_start(port);
        }
index 485fa9c5b10766698caabf03c580f92715c86bba..2cfe2451ed97a349e8be147abd7c3dc80178a9d3 100644 (file)
 #define BANDB_DEVICE_ID_US9ML2_4       0xAC30
 #define BANDB_DEVICE_ID_USPTL4_2       0xAC31
 #define BANDB_DEVICE_ID_USPTL4_4       0xAC32
-#define BANDB_DEVICE_ID_USOPTL4_2       0xAC42
-#define BANDB_DEVICE_ID_USOPTL4_4       0xAC44
+#define BANDB_DEVICE_ID_USOPTL4_2      0xAC42
+#define BANDB_DEVICE_ID_USOPTL4_4      0xAC44
+#define BANDB_DEVICE_ID_USOPTL2_4      0xAC24
 
 /* This driver also supports
  * ATEN UC2324 device using Moschip MCS7840
@@ -191,6 +192,7 @@ static struct usb_device_id moschip_port_id_table[] = {
        {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_4)},
        {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)},
        {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)},
+       {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
        {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
        {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
        {}                      /* terminating entry */
@@ -207,6 +209,7 @@ static __devinitdata struct usb_device_id moschip_id_table_combined[] = {
        {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_4)},
        {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)},
        {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)},
+       {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
        {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
        {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
        {}                      /* terminating entry */
index 9a2b903492ecd028cccddc56fb56d8197dc0b7dd..6e94a6711f08c28f3e3aeb6ca0ac2f1cfa0d3a7f 100644 (file)
@@ -340,6 +340,10 @@ static int  option_resume(struct usb_serial *serial);
 #define FOUR_G_SYSTEMS_VENDOR_ID               0x1c9e
 #define FOUR_G_SYSTEMS_PRODUCT_W14             0x9603
 
+/* Haier products */
+#define HAIER_VENDOR_ID                                0x201e
+#define HAIER_PRODUCT_CE100                    0x2009
+
 static struct usb_device_id option_ids[] = {
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -641,6 +645,7 @@ static struct usb_device_id option_ids[] = {
        { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
        { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
        { USB_DEVICE(FOUR_G_SYSTEMS_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14) },
+       { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) },
        { } /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, option_ids);
index 4543f359be75ea9d423d12dc700d9c1cd479e5e6..33c85f7084f879593b3f47e2833c2776bda97486 100644 (file)
@@ -595,8 +595,7 @@ static void port_release(struct device *dev)
        usb_free_urb(port->write_urb);
        usb_free_urb(port->interrupt_in_urb);
        usb_free_urb(port->interrupt_out_urb);
-       if (!IS_ERR(port->write_fifo) && port->write_fifo)
-               kfifo_free(port->write_fifo);
+       kfifo_free(&port->write_fifo);
        kfree(port->bulk_in_buffer);
        kfree(port->bulk_out_buffer);
        kfree(port->interrupt_in_buffer);
@@ -939,9 +938,7 @@ int usb_serial_probe(struct usb_interface *interface,
                        dev_err(&interface->dev, "No free urbs available\n");
                        goto probe_error;
                }
-               port->write_fifo = kfifo_alloc(PAGE_SIZE, GFP_KERNEL,
-                       &port->lock);
-               if (IS_ERR(port->write_fifo))
+               if (kfifo_alloc(&port->write_fifo, PAGE_SIZE, GFP_KERNEL))
                        goto probe_error;
                buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
                port->bulk_out_size = buffer_size;
index 99c0df1c7ebf5ec9f4fed97d7bfdd2de241b488b..5a5c303a6373501a4de9fcd8a0ad475bc081f539 100644 (file)
@@ -614,6 +614,21 @@ config FB_BFIN_T350MCQB
         This display is a QVGA 320x240 24-bit RGB display interfaced by an 8-bit wide PPI
         It uses PPI[0..7] PPI_FS1, PPI_FS2 and PPI_CLK.
 
+config FB_BFIN_LQ035Q1
+       tristate "SHARP LQ035Q1DH02 TFT LCD"
+       depends on FB && BLACKFIN && SPI
+       select FB_CFB_FILLRECT
+       select FB_CFB_COPYAREA
+       select FB_CFB_IMAGEBLIT
+       select BFIN_GPTIMERS
+       help
+         This is the framebuffer device driver for a SHARP LQ035Q1DH02 TFT display found on
+         the Blackfin Landscape LCD EZ-Extender Card.
+         This display is a QVGA 320x240 18-bit RGB display interfaced by an 16-bit wide PPI
+         It uses PPI[0..15] PPI_FS1, PPI_FS2 and PPI_CLK.
+
+         To compile this driver as a module, choose M here: the
+         module will be called bfin-lq035q1-fb.
 
 config FB_STI
        tristate "HP STI frame buffer device support"
index 0f8da331ba0f7d76a80eb98216d95f4aa9ea6284..4ecb30c4f3f25fa83be323f6206cb12e48ec525b 100644 (file)
@@ -137,6 +137,7 @@ obj-$(CONFIG_FB_EFI)              += efifb.o
 obj-$(CONFIG_FB_VGA16)            += vga16fb.o
 obj-$(CONFIG_FB_OF)               += offb.o
 obj-$(CONFIG_FB_BF54X_LQ043)     += bf54x-lq043fb.o
+obj-$(CONFIG_FB_BFIN_LQ035Q1)     += bfin-lq035q1-fb.o
 obj-$(CONFIG_FB_BFIN_T350MCQB)   += bfin-t350mcqb-fb.o
 obj-$(CONFIG_FB_MX3)             += mx3fb.o
 obj-$(CONFIG_FB_DA8XX)           += da8xx-fb.o
index 4c10edecfb6616070ce46610a5694f2fbf051080..86d95c228adb7289ec294f454b44e9575516d1f7 100644 (file)
@@ -85,7 +85,7 @@ static int adp5520_bl_get_brightness(struct backlight_device *bl)
        return error ? data->current_brightness : reg_val;
 }
 
-static struct backlight_ops adp5520_bl_ops = {
+static const struct backlight_ops adp5520_bl_ops = {
        .update_status  = adp5520_bl_update_status,
        .get_brightness = adp5520_bl_get_brightness,
 };
index 2c3bdfc620b74a0d92cdc0a7bfd5b932b347c682..d769b0bab21abfc5b41105f430210532a7bd948e 100644 (file)
@@ -61,7 +61,7 @@ static int adx_backlight_check_fb(struct fb_info *fb)
        return 1;
 }
 
-static struct backlight_ops adx_backlight_ops = {
+static const struct backlight_ops adx_backlight_ops = {
        .options = 0,
        .update_status = adx_backlight_update_status,
        .get_brightness = adx_backlight_get_brightness,
index 2cf7ba52f67c1f62ffd0f0ee61dc65650f67768e..f625ffc69ad3139cef6ba88688ac1e76878ff1e4 100644 (file)
@@ -113,7 +113,7 @@ static int atmel_pwm_bl_init_pwm(struct atmel_pwm_bl *pwmbl)
        return pwm_channel_enable(&pwmbl->pwmc);
 }
 
-static struct backlight_ops atmel_pwm_bl_ops = {
+static const struct backlight_ops atmel_pwm_bl_ops = {
        .get_brightness = atmel_pwm_bl_get_intensity,
        .update_status  = atmel_pwm_bl_set_intensity,
 };
index 6615ac7fa60a6124e31257a2ce1b09cf871ed719..18829cf68b1b97ca111af2d390820a3576ad68c1 100644 (file)
@@ -269,7 +269,7 @@ EXPORT_SYMBOL(backlight_force_update);
  * ERR_PTR() or a pointer to the newly allocated device.
  */
 struct backlight_device *backlight_device_register(const char *name,
-               struct device *parent, void *devdata, struct backlight_ops *ops)
+               struct device *parent, void *devdata, const struct backlight_ops *ops)
 {
        struct backlight_device *new_bd;
        int rc;
index 96774949cd30ba3964ea1340e47a3524f841c08b..b4bcf8043797d18ced2ab1618ee9ef57853e6399 100644 (file)
@@ -451,7 +451,7 @@ void corgi_lcd_limit_intensity(int limit)
 }
 EXPORT_SYMBOL(corgi_lcd_limit_intensity);
 
-static struct backlight_ops corgi_bl_ops = {
+static const struct backlight_ops corgi_bl_ops = {
        .get_brightness = corgi_bl_get_intensity,
        .update_status  = corgi_bl_update_status,
 };
index b9fe62b475c63a3fa953ea182958496cd4037d52..da86db4374a05a350084b2f06834d489e773f4ba 100644 (file)
@@ -108,7 +108,7 @@ static int cr_backlight_get_intensity(struct backlight_device *bd)
        return intensity;
 }
 
-static struct backlight_ops cr_backlight_ops = {
+static const struct backlight_ops cr_backlight_ops = {
        .get_brightness = cr_backlight_get_intensity,
        .update_status = cr_backlight_set_intensity,
 };
@@ -201,7 +201,7 @@ static int cr_backlight_probe(struct platform_device *pdev)
        if (IS_ERR(ldp)) {
                backlight_device_unregister(bdp);
                pci_dev_put(lpc_dev);
-               return PTR_ERR(bdp);
+               return PTR_ERR(ldp);
        }
 
        pci_read_config_dword(lpc_dev, CRVML_REG_GPIOBAR,
index 7fcb0eb54c6061d1214348c4b45f2730ec1c50b3..74cdc640173de5879af656d46cfaafa4ec8ad6bf 100644 (file)
@@ -95,7 +95,7 @@ static int da903x_backlight_get_brightness(struct backlight_device *bl)
        return data->current_brightness;
 }
 
-static struct backlight_ops da903x_backlight_ops = {
+static const struct backlight_ops da903x_backlight_ops = {
        .update_status  = da903x_backlight_update_status,
        .get_brightness = da903x_backlight_get_brightness,
 };
@@ -177,7 +177,7 @@ static int da903x_backlight_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops da903x_backlight_pm_ops = {
+static const struct dev_pm_ops da903x_backlight_pm_ops = {
        .suspend        = da903x_backlight_suspend,
        .resume         = da903x_backlight_resume,
 };
index 6d27f62fdcd09055db7bba7207a72905fc8aa36d..e6d348e63596455f06d4a3443e82ea4f982a91e6 100644 (file)
@@ -70,7 +70,7 @@ void corgibl_limit_intensity(int limit)
 }
 EXPORT_SYMBOL(corgibl_limit_intensity);
 
-static struct backlight_ops genericbl_ops = {
+static const struct backlight_ops genericbl_ops = {
        .options = BL_CORE_SUSPENDRESUME,
        .get_brightness = genericbl_get_intensity,
        .update_status  = genericbl_send_intensity,
index 7fb4eefff80daa497fdc4440508b5b3ca8739886..f7cc528d5be79a066347e43b3271c0d376e5275c 100644 (file)
@@ -98,7 +98,7 @@ static int hp680bl_get_intensity(struct backlight_device *bd)
        return current_intensity;
 }
 
-static struct backlight_ops hp680bl_ops = {
+static const struct backlight_ops hp680bl_ops = {
        .get_brightness = hp680bl_get_intensity,
        .update_status  = hp680bl_set_intensity,
 };
index 7aed2565c1bd1b666ab7b46f63e02879e6097a54..db9071fc56654add5b279b31845c75e34e7726cc 100644 (file)
@@ -93,7 +93,7 @@ out:
        return ret;
 }
 
-static struct backlight_ops jornada_bl_ops = {
+static const struct backlight_ops jornada_bl_ops = {
        .get_brightness = jornada_bl_get_brightness,
        .update_status = jornada_bl_update_status,
        .options = BL_CORE_SUSPENDRESUME,
index a38fda1742ddb58e374ad825218fd4bc06f6a332..939e7b830cf3f5afabaf104e694d465e63759bd5 100644 (file)
@@ -134,7 +134,7 @@ static int kb3886bl_get_intensity(struct backlight_device *bd)
        return kb3886bl_intensity;
 }
 
-static struct backlight_ops kb3886bl_ops = {
+static const struct backlight_ops kb3886bl_ops = {
        .get_brightness = kb3886bl_get_intensity,
        .update_status  = kb3886bl_send_intensity,
 };
index a482dd7b0311bcd5eacdd1ca8cfaf49d5ff0eac8..9b3be74cee5a7f2e9f000bf4b64f9cec8c7a2715 100644 (file)
@@ -101,7 +101,7 @@ static ssize_t lcd_store_power(struct device *dev,
        int power = simple_strtoul(buf, &endp, 0);
        size_t size = endp - buf;
 
-       if (*endp && isspace(*endp))
+       if (isspace(*endp))
                size++;
        if (size != count)
                return -EINVAL;
@@ -140,7 +140,7 @@ static ssize_t lcd_store_contrast(struct device *dev,
        int contrast = simple_strtoul(buf, &endp, 0);
        size_t size = endp - buf;
 
-       if (*endp && isspace(*endp))
+       if (isspace(*endp))
                size++;
        if (size != count)
                return -EINVAL;
index 6b488b8a7eee6cb6b0e5a9631239d57aac7e66e9..00a9591b00030f8a3bf744ec124cc163ff061ad9 100644 (file)
@@ -141,7 +141,7 @@ static int locomolcd_get_intensity(struct backlight_device *bd)
        return current_intensity;
 }
 
-static struct backlight_ops locomobl_data = {
+static const struct backlight_ops locomobl_data = {
        .get_brightness = locomolcd_get_intensity,
        .update_status  = locomolcd_set_intensity,
 };
index 9edb8d7c295f38ed02a31642b3eba3be1c5681c9..2e78b0784bdc8b1dae7083fbee8f052302a30227 100644 (file)
@@ -33,7 +33,7 @@ struct dmi_match_data {
        unsigned long iostart;
        unsigned long iolen;
        /* Backlight operations structure. */
-       struct backlight_ops backlight_ops;
+       const struct backlight_ops backlight_ops;
 };
 
 /* Module parameters. */
@@ -218,6 +218,24 @@ static const struct dmi_system_id __initdata mbp_device_table[] = {
                },
                .driver_data    = (void *)&nvidia_chipset_data,
        },
+       {
+               .callback       = mbp_dmi_match,
+               .ident          = "MacBookPro 5,3",
+               .matches        = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5,3"),
+               },
+               .driver_data    = (void *)&nvidia_chipset_data,
+       },
+       {
+               .callback       = mbp_dmi_match,
+               .ident          = "MacBookPro 5,4",
+               .matches        = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5,4"),
+               },
+               .driver_data    = (void *)&nvidia_chipset_data,
+       },
        {
                .callback       = mbp_dmi_match,
                .ident          = "MacBookPro 5,5",
index 8693e5fcd2eb83dea83083a5ff3126900c87abc9..409ca9643528b6d52a0906afdd97b3cbcf158a9b 100644 (file)
@@ -125,7 +125,7 @@ static int omapbl_get_intensity(struct backlight_device *dev)
        return bl->current_intensity;
 }
 
-static struct backlight_ops omapbl_ops = {
+static const struct backlight_ops omapbl_ops = {
        .get_brightness = omapbl_get_intensity,
        .update_status  = omapbl_update_status,
 };
index 9edaf24fd82d4e49f0bf439162fa156088cbc25e..075786e05034cc5defba6606a32e13b2e18f8de6 100644 (file)
@@ -54,7 +54,7 @@ static int progearbl_get_intensity(struct backlight_device *bd)
        return intensity - HW_LEVEL_MIN;
 }
 
-static struct backlight_ops progearbl_ops = {
+static const struct backlight_ops progearbl_ops = {
        .get_brightness = progearbl_get_intensity,
        .update_status = progearbl_set_intensity,
 };
index 88716626744391a89cae97a5658fb3cc0ffbd545..9d2ec2a1cce8fff721d40680277d45ac5bc1bb55 100644 (file)
 
 struct pwm_bl_data {
        struct pwm_device       *pwm;
+       struct device           *dev;
        unsigned int            period;
-       int                     (*notify)(int brightness);
+       int                     (*notify)(struct device *,
+                                         int brightness);
 };
 
 static int pwm_backlight_update_status(struct backlight_device *bl)
@@ -39,7 +41,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
                brightness = 0;
 
        if (pb->notify)
-               brightness = pb->notify(brightness);
+               brightness = pb->notify(pb->dev, brightness);
 
        if (brightness == 0) {
                pwm_config(pb->pwm, 0, pb->period);
@@ -56,7 +58,7 @@ static int pwm_backlight_get_brightness(struct backlight_device *bl)
        return bl->props.brightness;
 }
 
-static struct backlight_ops pwm_backlight_ops = {
+static const struct backlight_ops pwm_backlight_ops = {
        .update_status  = pwm_backlight_update_status,
        .get_brightness = pwm_backlight_get_brightness,
 };
@@ -88,6 +90,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 
        pb->period = data->pwm_period_ns;
        pb->notify = data->notify;
+       pb->dev = &pdev->dev;
 
        pb->pwm = pwm_request(data->pwm_id, "backlight");
        if (IS_ERR(pb->pwm)) {
@@ -146,7 +149,7 @@ static int pwm_backlight_suspend(struct platform_device *pdev,
        struct pwm_bl_data *pb = dev_get_drvdata(&bl->dev);
 
        if (pb->notify)
-               pb->notify(0);
+               pb->notify(pb->dev, 0);
        pwm_config(pb->pwm, 0, pb->period);
        pwm_disable(pb->pwm);
        return 0;
index 43edbada12d19156970d5b84f68e56de73333c25..e14ce4d469f57f1ed6525ba53113bcbd6bca6913 100644 (file)
@@ -72,7 +72,7 @@ static int tosa_bl_get_brightness(struct backlight_device *dev)
        return props->brightness;
 }
 
-static struct backlight_ops bl_ops = {
+static const struct backlight_ops bl_ops = {
        .get_brightness         = tosa_bl_get_brightness,
        .update_status          = tosa_bl_update_status,
 };
index 467bdb7efb231057160aa5333960057439fac502..e32add37a203453558c80a6c195276cb402094c6 100644 (file)
@@ -112,7 +112,7 @@ static int wm831x_backlight_get_brightness(struct backlight_device *bl)
        return data->current_brightness;
 }
 
-static struct backlight_ops wm831x_backlight_ops = {
+static const struct backlight_ops wm831x_backlight_ops = {
        .options = BL_CORE_SUSPENDRESUME,
        .update_status  = wm831x_backlight_update_status,
        .get_brightness = wm831x_backlight_get_brightness,
diff --git a/drivers/video/bfin-lq035q1-fb.c b/drivers/video/bfin-lq035q1-fb.c
new file mode 100644 (file)
index 0000000..b690c26
--- /dev/null
@@ -0,0 +1,826 @@
+/*
+ * Blackfin LCD Framebuffer driver SHARP LQ035Q1DH02
+ *
+ * Copyright 2008-2009 Analog Devices Inc.
+ * Licensed under the GPL-2 or later.
+ */
+
+#define DRIVER_NAME "bfin-lq035q1"
+#define pr_fmt(fmt) DRIVER_NAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/fb.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/backlight.h>
+#include <linux/lcd.h>
+#include <linux/dma-mapping.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/blackfin.h>
+#include <asm/irq.h>
+#include <asm/dma.h>
+#include <asm/portmux.h>
+#include <asm/gptimers.h>
+
+#include <asm/bfin-lq035q1.h>
+
+#if defined(BF533_FAMILY) || defined(BF538_FAMILY)
+#define TIMER_HSYNC_id                 TIMER1_id
+#define TIMER_HSYNCbit                 TIMER1bit
+#define TIMER_HSYNC_STATUS_TRUN                TIMER_STATUS_TRUN1
+#define TIMER_HSYNC_STATUS_TIMIL       TIMER_STATUS_TIMIL1
+#define TIMER_HSYNC_STATUS_TOVF                TIMER_STATUS_TOVF1
+
+#define TIMER_VSYNC_id                 TIMER2_id
+#define TIMER_VSYNCbit                 TIMER2bit
+#define TIMER_VSYNC_STATUS_TRUN                TIMER_STATUS_TRUN2
+#define TIMER_VSYNC_STATUS_TIMIL       TIMER_STATUS_TIMIL2
+#define TIMER_VSYNC_STATUS_TOVF                TIMER_STATUS_TOVF2
+#else
+#define TIMER_HSYNC_id                 TIMER0_id
+#define TIMER_HSYNCbit                 TIMER0bit
+#define TIMER_HSYNC_STATUS_TRUN                TIMER_STATUS_TRUN0
+#define TIMER_HSYNC_STATUS_TIMIL       TIMER_STATUS_TIMIL0
+#define TIMER_HSYNC_STATUS_TOVF                TIMER_STATUS_TOVF0
+
+#define TIMER_VSYNC_id                 TIMER1_id
+#define TIMER_VSYNCbit                 TIMER1bit
+#define TIMER_VSYNC_STATUS_TRUN                TIMER_STATUS_TRUN1
+#define TIMER_VSYNC_STATUS_TIMIL       TIMER_STATUS_TIMIL1
+#define TIMER_VSYNC_STATUS_TOVF                TIMER_STATUS_TOVF1
+#endif
+
+#define LCD_X_RES              320     /* Horizontal Resolution */
+#define LCD_Y_RES              240     /* Vertical Resolution */
+#define        DMA_BUS_SIZE            16
+
+#define USE_RGB565_16_BIT_PPI
+
+#ifdef USE_RGB565_16_BIT_PPI
+#define LCD_BPP                16      /* Bit Per Pixel */
+#define CLOCKS_PER_PIX 1
+#define CPLD_PIPELINE_DELAY_COR 0      /* NO CPLB */
+#endif
+
+/* Interface 16/18-bit TFT over an 8-bit wide PPI using a small Programmable Logic Device (CPLD)
+ * http://blackfin.uclinux.org/gf/project/stamp/frs/?action=FrsReleaseBrowse&frs_package_id=165
+ */
+
+#ifdef USE_RGB565_8_BIT_PPI
+#define LCD_BPP                16      /* Bit Per Pixel */
+#define CLOCKS_PER_PIX 2
+#define CPLD_PIPELINE_DELAY_COR 3      /* RGB565 */
+#endif
+
+#ifdef USE_RGB888_8_BIT_PPI
+#define LCD_BPP                24      /* Bit Per Pixel */
+#define CLOCKS_PER_PIX 3
+#define CPLD_PIPELINE_DELAY_COR 5      /* RGB888 */
+#endif
+
+       /*
+        * HS and VS timing parameters (all in number of PPI clk ticks)
+        */
+
+#define U_LINE         4                               /* Blanking Lines */
+
+#define H_ACTPIX       (LCD_X_RES * CLOCKS_PER_PIX)    /* active horizontal pixel */
+#define H_PERIOD       (336 * CLOCKS_PER_PIX)          /* HS period */
+#define H_PULSE                (2 * CLOCKS_PER_PIX)                            /* HS pulse width */
+#define H_START                (7 * CLOCKS_PER_PIX + CPLD_PIPELINE_DELAY_COR)  /* first valid pixel */
+
+#define        V_LINES         (LCD_Y_RES + U_LINE)            /* total vertical lines */
+#define V_PULSE                (2 * CLOCKS_PER_PIX)            /* VS pulse width (1-5 H_PERIODs) */
+#define V_PERIOD       (H_PERIOD * V_LINES)            /* VS period */
+
+#define ACTIVE_VIDEO_MEM_OFFSET                ((U_LINE / 2) * LCD_X_RES * (LCD_BPP / 8))
+
+#define BFIN_LCD_NBR_PALETTE_ENTRIES   256
+
+#define PPI_TX_MODE                    0x2
+#define PPI_XFER_TYPE_11               0xC
+#define PPI_PORT_CFG_01                        0x10
+#define PPI_POLS_1                     0x8000
+
+#if (CLOCKS_PER_PIX > 1)
+#define PPI_PMODE (DLEN_8 | PACK_EN)
+#else
+#define PPI_PMODE (DLEN_16)
+#endif
+
+#define LQ035_INDEX                    0x74
+#define LQ035_DATA                     0x76
+
+#define LQ035_DRIVER_OUTPUT_CTL                0x1
+#define LQ035_SHUT_CTL                 0x11
+
+#define LQ035_DRIVER_OUTPUT_MASK       (LQ035_LR | LQ035_TB | LQ035_BGR | LQ035_REV)
+#define LQ035_DRIVER_OUTPUT_DEFAULT    (0x2AEF & ~LQ035_DRIVER_OUTPUT_MASK)
+
+#define LQ035_SHUT                     (1 << 0)        /* Shutdown */
+#define LQ035_ON                       (0 << 0)        /* Shutdown */
+
+struct bfin_lq035q1fb_info {
+       struct fb_info *fb;
+       struct device *dev;
+       struct spi_driver spidrv;
+       struct bfin_lq035q1fb_disp_info *disp_info;
+       unsigned char *fb_buffer;       /* RGB Buffer */
+       dma_addr_t dma_handle;
+       int lq035_open_cnt;
+       int irq;
+       spinlock_t lock;        /* lock */
+       u32 pseudo_pal[16];
+};
+
+static int nocursor;
+module_param(nocursor, int, 0644);
+MODULE_PARM_DESC(nocursor, "cursor enable/disable");
+
+struct spi_control {
+       unsigned short mode;
+};
+
+static int lq035q1_control(struct spi_device *spi, unsigned char reg, unsigned short value)
+{
+       int ret;
+       u8 regs[3] = { LQ035_INDEX, 0, 0 };
+       u8 dat[3] = { LQ035_DATA, 0, 0 };
+
+       if (!spi)
+               return -ENODEV;
+
+       regs[2] = reg;
+       dat[1] = value >> 8;
+       dat[2] = value & 0xFF;
+
+       ret = spi_write(spi, regs, ARRAY_SIZE(regs));
+       ret |= spi_write(spi, dat, ARRAY_SIZE(dat));
+       return ret;
+}
+
+static int __devinit lq035q1_spidev_probe(struct spi_device *spi)
+{
+       int ret;
+       struct spi_control *ctl;
+       struct bfin_lq035q1fb_info *info = container_of(spi->dev.driver,
+                                               struct bfin_lq035q1fb_info,
+                                               spidrv.driver);
+
+       ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
+
+       if (!ctl)
+               return -ENOMEM;
+
+       ctl->mode = (info->disp_info->mode &
+               LQ035_DRIVER_OUTPUT_MASK) | LQ035_DRIVER_OUTPUT_DEFAULT;
+
+       ret = lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_ON);
+       ret |= lq035q1_control(spi, LQ035_DRIVER_OUTPUT_CTL, ctl->mode);
+       if (ret)
+               return ret;
+
+       spi_set_drvdata(spi, ctl);
+
+       return 0;
+}
+
+static int lq035q1_spidev_remove(struct spi_device *spi)
+{
+       return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT);
+}
+
+#ifdef CONFIG_PM
+static int lq035q1_spidev_suspend(struct spi_device *spi, pm_message_t state)
+{
+       return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT);
+}
+
+static int lq035q1_spidev_resume(struct spi_device *spi)
+{
+       int ret;
+       struct spi_control *ctl = spi_get_drvdata(spi);
+
+       ret = lq035q1_control(spi, LQ035_DRIVER_OUTPUT_CTL, ctl->mode);
+       if (ret)
+               return ret;
+
+       return lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_ON);
+}
+#else
+# define lq035q1_spidev_suspend NULL
+# define lq035q1_spidev_resume  NULL
+#endif
+
+/* Power down all displays on reboot, poweroff or halt */
+static void lq035q1_spidev_shutdown(struct spi_device *spi)
+{
+       lq035q1_control(spi, LQ035_SHUT_CTL, LQ035_SHUT);
+}
+
+static int lq035q1_backlight(struct bfin_lq035q1fb_info *info, unsigned arg)
+{
+       if (info->disp_info->use_bl)
+               gpio_set_value(info->disp_info->gpio_bl, arg);
+
+       return 0;
+}
+
+static void bfin_lq035q1_config_ppi(struct bfin_lq035q1fb_info *fbi)
+{
+       bfin_write_PPI_DELAY(H_START);
+       bfin_write_PPI_COUNT(H_ACTPIX - 1);
+       bfin_write_PPI_FRAME(V_LINES);
+
+       bfin_write_PPI_CONTROL(PPI_TX_MODE |       /* output mode , PORT_DIR */
+                               PPI_XFER_TYPE_11 | /* sync mode XFR_TYPE */
+                               PPI_PORT_CFG_01 |  /* two frame sync PORT_CFG */
+                               PPI_PMODE |        /* 8/16 bit data length / PACK_EN? */
+                               PPI_POLS_1);       /* faling edge syncs POLS */
+}
+
+static inline void bfin_lq035q1_disable_ppi(void)
+{
+       bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() & ~PORT_EN);
+}
+
+static inline void bfin_lq035q1_enable_ppi(void)
+{
+       bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() | PORT_EN);
+}
+
+static void bfin_lq035q1_start_timers(void)
+{
+       enable_gptimers(TIMER_VSYNCbit | TIMER_HSYNCbit);
+}
+
+static void bfin_lq035q1_stop_timers(void)
+{
+       disable_gptimers(TIMER_HSYNCbit | TIMER_VSYNCbit);
+
+       set_gptimer_status(0, TIMER_HSYNC_STATUS_TRUN | TIMER_VSYNC_STATUS_TRUN |
+                               TIMER_HSYNC_STATUS_TIMIL | TIMER_VSYNC_STATUS_TIMIL |
+                                TIMER_HSYNC_STATUS_TOVF | TIMER_VSYNC_STATUS_TOVF);
+
+}
+
+static void bfin_lq035q1_init_timers(void)
+{
+
+       bfin_lq035q1_stop_timers();
+
+       set_gptimer_period(TIMER_HSYNC_id, H_PERIOD);
+       set_gptimer_pwidth(TIMER_HSYNC_id, H_PULSE);
+       set_gptimer_config(TIMER_HSYNC_id, TIMER_MODE_PWM | TIMER_PERIOD_CNT |
+                                     TIMER_TIN_SEL | TIMER_CLK_SEL|
+                                     TIMER_EMU_RUN);
+
+       set_gptimer_period(TIMER_VSYNC_id, V_PERIOD);
+       set_gptimer_pwidth(TIMER_VSYNC_id, V_PULSE);
+       set_gptimer_config(TIMER_VSYNC_id, TIMER_MODE_PWM | TIMER_PERIOD_CNT |
+                                     TIMER_TIN_SEL | TIMER_CLK_SEL |
+                                     TIMER_EMU_RUN);
+
+}
+
+static void bfin_lq035q1_config_dma(struct bfin_lq035q1fb_info *fbi)
+{
+
+       set_dma_config(CH_PPI,
+                      set_bfin_dma_config(DIR_READ, DMA_FLOW_AUTO,
+                                          INTR_DISABLE, DIMENSION_2D,
+                                          DATA_SIZE_16,
+                                          DMA_NOSYNC_KEEP_DMA_BUF));
+       set_dma_x_count(CH_PPI, (LCD_X_RES * LCD_BPP) / DMA_BUS_SIZE);
+       set_dma_x_modify(CH_PPI, DMA_BUS_SIZE / 8);
+       set_dma_y_count(CH_PPI, V_LINES);
+
+       set_dma_y_modify(CH_PPI, DMA_BUS_SIZE / 8);
+       set_dma_start_addr(CH_PPI, (unsigned long)fbi->fb_buffer);
+
+}
+
+#if (CLOCKS_PER_PIX == 1)
+static const u16 ppi0_req_16[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
+                           P_PPI0_D0, P_PPI0_D1, P_PPI0_D2,
+                           P_PPI0_D3, P_PPI0_D4, P_PPI0_D5,
+                           P_PPI0_D6, P_PPI0_D7, P_PPI0_D8,
+                           P_PPI0_D9, P_PPI0_D10, P_PPI0_D11,
+                           P_PPI0_D12, P_PPI0_D13, P_PPI0_D14,
+                           P_PPI0_D15, 0};
+#else
+static const u16 ppi0_req_16[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
+                           P_PPI0_D0, P_PPI0_D1, P_PPI0_D2,
+                           P_PPI0_D3, P_PPI0_D4, P_PPI0_D5,
+                           P_PPI0_D6, P_PPI0_D7, 0};
+#endif
+
+static inline void bfin_lq035q1_free_ports(void)
+{
+       peripheral_free_list(ppi0_req_16);
+       if (ANOMALY_05000400)
+               gpio_free(P_IDENT(P_PPI0_FS3));
+}
+
+static int __devinit bfin_lq035q1_request_ports(struct platform_device *pdev)
+{
+       /* ANOMALY_05000400 - PPI Does Not Start Properly In Specific Mode:
+        * Drive PPI_FS3 Low
+        */
+       if (ANOMALY_05000400) {
+               int ret = gpio_request(P_IDENT(P_PPI0_FS3), "PPI_FS3");
+               if (ret)
+                       return ret;
+               gpio_direction_output(P_IDENT(P_PPI0_FS3), 0);
+       }
+
+       if (peripheral_request_list(ppi0_req_16, DRIVER_NAME)) {
+               dev_err(&pdev->dev, "requesting peripherals failed\n");
+               return -EFAULT;
+       }
+
+       return 0;
+}
+
+static int bfin_lq035q1_fb_open(struct fb_info *info, int user)
+{
+       struct bfin_lq035q1fb_info *fbi = info->par;
+
+       spin_lock(&fbi->lock);
+       fbi->lq035_open_cnt++;
+
+       if (fbi->lq035_open_cnt <= 1) {
+
+               bfin_lq035q1_disable_ppi();
+               SSYNC();
+
+               bfin_lq035q1_config_dma(fbi);
+               bfin_lq035q1_config_ppi(fbi);
+               bfin_lq035q1_init_timers();
+
+               /* start dma */
+               enable_dma(CH_PPI);
+               bfin_lq035q1_enable_ppi();
+               bfin_lq035q1_start_timers();
+               lq035q1_backlight(fbi, 1);
+       }
+
+       spin_unlock(&fbi->lock);
+
+       return 0;
+}
+
+static int bfin_lq035q1_fb_release(struct fb_info *info, int user)
+{
+       struct bfin_lq035q1fb_info *fbi = info->par;
+
+       spin_lock(&fbi->lock);
+
+       fbi->lq035_open_cnt--;
+
+       if (fbi->lq035_open_cnt <= 0) {
+               lq035q1_backlight(fbi, 0);
+               bfin_lq035q1_disable_ppi();
+               SSYNC();
+               disable_dma(CH_PPI);
+               bfin_lq035q1_stop_timers();
+       }
+
+       spin_unlock(&fbi->lock);
+
+       return 0;
+}
+
+static int bfin_lq035q1_fb_check_var(struct fb_var_screeninfo *var,
+                                    struct fb_info *info)
+{
+       switch (var->bits_per_pixel) {
+#if (LCD_BPP == 24)
+       case 24:/* TRUECOLOUR, 16m */
+#else
+       case 16:/* DIRECTCOLOUR, 64k */
+#endif
+               var->red.offset = info->var.red.offset;
+               var->green.offset = info->var.green.offset;
+               var->blue.offset = info->var.blue.offset;
+               var->red.length = info->var.red.length;
+               var->green.length = info->var.green.length;
+               var->blue.length = info->var.blue.length;
+               var->transp.offset = 0;
+               var->transp.length = 0;
+               var->transp.msb_right = 0;
+               var->red.msb_right = 0;
+               var->green.msb_right = 0;
+               var->blue.msb_right = 0;
+               break;
+       default:
+               pr_debug("%s: depth not supported: %u BPP\n", __func__,
+                        var->bits_per_pixel);
+               return -EINVAL;
+       }
+
+       if (info->var.xres != var->xres || info->var.yres != var->yres ||
+           info->var.xres_virtual != var->xres_virtual ||
+           info->var.yres_virtual != var->yres_virtual) {
+               pr_debug("%s: Resolution not supported: X%u x Y%u \n",
+                        __func__, var->xres, var->yres);
+               return -EINVAL;
+       }
+
+       /*
+        *  Memory limit
+        */
+
+       if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) {
+               pr_debug("%s: Memory Limit requested yres_virtual = %u\n",
+                        __func__, var->yres_virtual);
+               return -ENOMEM;
+       }
+
+
+       return 0;
+}
+
+int bfin_lq035q1_fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
+{
+       if (nocursor)
+               return 0;
+       else
+               return -EINVAL; /* just to force soft_cursor() call */
+}
+
+static int bfin_lq035q1_fb_setcolreg(u_int regno, u_int red, u_int green,
+                                  u_int blue, u_int transp,
+                                  struct fb_info *info)
+{
+       if (regno >= BFIN_LCD_NBR_PALETTE_ENTRIES)
+               return -EINVAL;
+
+       if (info->var.grayscale) {
+               /* grayscale = 0.30*R + 0.59*G + 0.11*B */
+               red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
+       }
+
+       if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
+
+               u32 value;
+               /* Place color in the pseudopalette */
+               if (regno > 16)
+                       return -EINVAL;
+
+               red >>= (16 - info->var.red.length);
+               green >>= (16 - info->var.green.length);
+               blue >>= (16 - info->var.blue.length);
+
+               value = (red << info->var.red.offset) |
+                   (green << info->var.green.offset) |
+                   (blue << info->var.blue.offset);
+               value &= 0xFFFFFF;
+
+               ((u32 *) (info->pseudo_palette))[regno] = value;
+
+       }
+
+       return 0;
+}
+
+static struct fb_ops bfin_lq035q1_fb_ops = {
+       .owner = THIS_MODULE,
+       .fb_open = bfin_lq035q1_fb_open,
+       .fb_release = bfin_lq035q1_fb_release,
+       .fb_check_var = bfin_lq035q1_fb_check_var,
+       .fb_fillrect = cfb_fillrect,
+       .fb_copyarea = cfb_copyarea,
+       .fb_imageblit = cfb_imageblit,
+       .fb_cursor = bfin_lq035q1_fb_cursor,
+       .fb_setcolreg = bfin_lq035q1_fb_setcolreg,
+};
+
+static irqreturn_t bfin_lq035q1_irq_error(int irq, void *dev_id)
+{
+       /*struct bfin_lq035q1fb_info *info = (struct bfin_lq035q1fb_info *)dev_id;*/
+
+       u16 status = bfin_read_PPI_STATUS();
+       bfin_write_PPI_STATUS(-1);
+
+       if (status) {
+               bfin_lq035q1_disable_ppi();
+               disable_dma(CH_PPI);
+
+               /* start dma */
+               enable_dma(CH_PPI);
+               bfin_lq035q1_enable_ppi();
+               bfin_write_PPI_STATUS(-1);
+       }
+
+       return IRQ_HANDLED;
+}
+
+static int __devinit bfin_lq035q1_probe(struct platform_device *pdev)
+{
+       struct bfin_lq035q1fb_info *info;
+       struct fb_info *fbinfo;
+       int ret;
+
+       ret = request_dma(CH_PPI, DRIVER_NAME"_CH_PPI");
+       if (ret < 0) {
+               dev_err(&pdev->dev, "PPI DMA unavailable\n");
+               goto out1;
+       }
+
+       fbinfo = framebuffer_alloc(sizeof(*info), &pdev->dev);
+       if (!fbinfo) {
+               ret = -ENOMEM;
+               goto out2;
+       }
+
+       info = fbinfo->par;
+       info->fb = fbinfo;
+       info->dev = &pdev->dev;
+
+       info->disp_info = pdev->dev.platform_data;
+
+       platform_set_drvdata(pdev, fbinfo);
+
+       strcpy(fbinfo->fix.id, DRIVER_NAME);
+
+       fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
+       fbinfo->fix.type_aux = 0;
+       fbinfo->fix.xpanstep = 0;
+       fbinfo->fix.ypanstep = 0;
+       fbinfo->fix.ywrapstep = 0;
+       fbinfo->fix.accel = FB_ACCEL_NONE;
+       fbinfo->fix.visual = FB_VISUAL_TRUECOLOR;
+
+       fbinfo->var.nonstd = 0;
+       fbinfo->var.activate = FB_ACTIVATE_NOW;
+       fbinfo->var.height = -1;
+       fbinfo->var.width = -1;
+       fbinfo->var.accel_flags = 0;
+       fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
+
+       fbinfo->var.xres = LCD_X_RES;
+       fbinfo->var.xres_virtual = LCD_X_RES;
+       fbinfo->var.yres = LCD_Y_RES;
+       fbinfo->var.yres_virtual = LCD_Y_RES;
+       fbinfo->var.bits_per_pixel = LCD_BPP;
+
+       if (info->disp_info->mode & LQ035_BGR) {
+#if (LCD_BPP == 24)
+               fbinfo->var.red.offset = 0;
+               fbinfo->var.green.offset = 8;
+               fbinfo->var.blue.offset = 16;
+#else
+               fbinfo->var.red.offset = 0;
+               fbinfo->var.green.offset = 5;
+               fbinfo->var.blue.offset = 11;
+#endif
+       } else {
+#if (LCD_BPP == 24)
+               fbinfo->var.red.offset = 16;
+               fbinfo->var.green.offset = 8;
+               fbinfo->var.blue.offset = 0;
+#else
+               fbinfo->var.red.offset = 11;
+               fbinfo->var.green.offset = 5;
+               fbinfo->var.blue.offset = 0;
+#endif
+       }
+
+       fbinfo->var.transp.offset = 0;
+
+#if (LCD_BPP == 24)
+       fbinfo->var.red.length = 8;
+       fbinfo->var.green.length = 8;
+       fbinfo->var.blue.length = 8;
+#else
+       fbinfo->var.red.length = 5;
+       fbinfo->var.green.length = 6;
+       fbinfo->var.blue.length = 5;
+#endif
+
+       fbinfo->var.transp.length = 0;
+
+       fbinfo->fix.smem_len = LCD_X_RES * LCD_Y_RES * LCD_BPP / 8
+                               + ACTIVE_VIDEO_MEM_OFFSET;
+
+       fbinfo->fix.line_length = fbinfo->var.xres_virtual *
+           fbinfo->var.bits_per_pixel / 8;
+
+
+       fbinfo->fbops = &bfin_lq035q1_fb_ops;
+       fbinfo->flags = FBINFO_FLAG_DEFAULT;
+
+       info->fb_buffer =
+           dma_alloc_coherent(NULL, fbinfo->fix.smem_len, &info->dma_handle,
+                              GFP_KERNEL);
+
+       if (NULL == info->fb_buffer) {
+               dev_err(&pdev->dev, "couldn't allocate dma buffer\n");
+               ret = -ENOMEM;
+               goto out3;
+       }
+
+       fbinfo->screen_base = (void *)info->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET;
+       fbinfo->fix.smem_start = (int)info->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET;
+
+       fbinfo->fbops = &bfin_lq035q1_fb_ops;
+
+       fbinfo->pseudo_palette = &info->pseudo_pal;
+
+       ret = fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "failed to allocate colormap (%d entries)\n",
+                      BFIN_LCD_NBR_PALETTE_ENTRIES);
+               goto out4;
+       }
+
+       ret = bfin_lq035q1_request_ports(pdev);
+       if (ret) {
+               dev_err(&pdev->dev, "couldn't request gpio port\n");
+               goto out6;
+       }
+
+       info->irq = platform_get_irq(pdev, 0);
+       if (info->irq < 0) {
+               ret = -EINVAL;
+               goto out7;
+       }
+
+       ret = request_irq(info->irq, bfin_lq035q1_irq_error, IRQF_DISABLED,
+                       DRIVER_NAME" PPI ERROR", info);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "unable to request PPI ERROR IRQ\n");
+               goto out7;
+       }
+
+       info->spidrv.driver.name = DRIVER_NAME"-spi";
+       info->spidrv.probe    = lq035q1_spidev_probe;
+       info->spidrv.remove   = __devexit_p(lq035q1_spidev_remove);
+       info->spidrv.shutdown = lq035q1_spidev_shutdown;
+       info->spidrv.suspend  = lq035q1_spidev_suspend;
+       info->spidrv.resume   = lq035q1_spidev_resume;
+
+       ret = spi_register_driver(&info->spidrv);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "couldn't register SPI Interface\n");
+               goto out8;
+       }
+
+       if (info->disp_info->use_bl) {
+               ret = gpio_request(info->disp_info->gpio_bl, "LQ035 Backlight");
+
+               if (ret) {
+                       dev_err(&pdev->dev, "failed to request GPIO %d\n",
+                               info->disp_info->gpio_bl);
+                       goto out9;
+               }
+               gpio_direction_output(info->disp_info->gpio_bl, 0);
+       }
+
+       ret = register_framebuffer(fbinfo);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "unable to register framebuffer\n");
+               goto out10;
+       }
+
+       dev_info(&pdev->dev, "%dx%d %d-bit RGB FrameBuffer initialized\n",
+               LCD_X_RES, LCD_Y_RES, LCD_BPP);
+
+       return 0;
+
+ out10:
+       if (info->disp_info->use_bl)
+               gpio_free(info->disp_info->gpio_bl);
+ out9:
+       spi_unregister_driver(&info->spidrv);
+ out8:
+       free_irq(info->irq, info);
+ out7:
+       bfin_lq035q1_free_ports();
+ out6:
+       fb_dealloc_cmap(&fbinfo->cmap);
+ out4:
+       dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
+                         info->dma_handle);
+ out3:
+       framebuffer_release(fbinfo);
+ out2:
+       free_dma(CH_PPI);
+ out1:
+       platform_set_drvdata(pdev, NULL);
+
+       return ret;
+}
+
+static int __devexit bfin_lq035q1_remove(struct platform_device *pdev)
+{
+       struct fb_info *fbinfo = platform_get_drvdata(pdev);
+       struct bfin_lq035q1fb_info *info = fbinfo->par;
+
+       if (info->disp_info->use_bl)
+               gpio_free(info->disp_info->gpio_bl);
+
+       spi_unregister_driver(&info->spidrv);
+
+       unregister_framebuffer(fbinfo);
+
+       free_dma(CH_PPI);
+       free_irq(info->irq, info);
+
+       if (info->fb_buffer != NULL)
+               dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
+                                 info->dma_handle);
+
+       fb_dealloc_cmap(&fbinfo->cmap);
+
+       bfin_lq035q1_free_ports();
+
+       platform_set_drvdata(pdev, NULL);
+       framebuffer_release(fbinfo);
+
+       dev_info(&pdev->dev, "unregistered LCD driver\n");
+
+       return 0;
+}
+
+#ifdef CONFIG_PM
+static int bfin_lq035q1_suspend(struct device *dev)
+{
+       struct fb_info *fbinfo = dev_get_drvdata(dev);
+       struct bfin_lq035q1fb_info *info = fbinfo->par;
+
+       if (info->lq035_open_cnt) {
+               lq035q1_backlight(info, 0);
+               bfin_lq035q1_disable_ppi();
+               SSYNC();
+               disable_dma(CH_PPI);
+               bfin_lq035q1_stop_timers();
+               bfin_write_PPI_STATUS(-1);
+       }
+
+       return 0;
+}
+
+static int bfin_lq035q1_resume(struct device *dev)
+{
+       struct fb_info *fbinfo = dev_get_drvdata(dev);
+       struct bfin_lq035q1fb_info *info = fbinfo->par;
+
+       if (info->lq035_open_cnt) {
+               bfin_lq035q1_disable_ppi();
+               SSYNC();
+
+               bfin_lq035q1_config_dma(info);
+               bfin_lq035q1_config_ppi(info);
+               bfin_lq035q1_init_timers();
+
+               /* start dma */
+               enable_dma(CH_PPI);
+               bfin_lq035q1_enable_ppi();
+               bfin_lq035q1_start_timers();
+               lq035q1_backlight(info, 1);
+       }
+
+       return 0;
+}
+
+static struct dev_pm_ops bfin_lq035q1_dev_pm_ops = {
+       .suspend = bfin_lq035q1_suspend,
+       .resume  = bfin_lq035q1_resume,
+};
+#endif
+
+static struct platform_driver bfin_lq035q1_driver = {
+       .probe   = bfin_lq035q1_probe,
+       .remove  = __devexit_p(bfin_lq035q1_remove),
+       .driver = {
+               .name = DRIVER_NAME,
+#ifdef CONFIG_PM
+               .pm   = &bfin_lq035q1_dev_pm_ops,
+#endif
+       },
+};
+
+static int __init bfin_lq035q1_driver_init(void)
+{
+       return platform_driver_register(&bfin_lq035q1_driver);
+}
+module_init(bfin_lq035q1_driver_init);
+
+static void __exit bfin_lq035q1_driver_cleanup(void)
+{
+       platform_driver_unregister(&bfin_lq035q1_driver);
+}
+module_exit(bfin_lq035q1_driver_cleanup);
+
+MODULE_DESCRIPTION("Blackfin TFT LCD Driver");
+MODULE_LICENSE("GPL");
index 5cc36cfbf07be275ce2b8ea92104c41e4bda1996..2549c53b26a06ea3755ad4900aaa1615685e39ca 100644 (file)
@@ -487,8 +487,8 @@ static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
 
        fbinfo->var.nonstd = 0;
        fbinfo->var.activate = FB_ACTIVATE_NOW;
-       fbinfo->var.height = -1;
-       fbinfo->var.width = -1;
+       fbinfo->var.height = 53;
+       fbinfo->var.width = 70;
        fbinfo->var.accel_flags = 0;
        fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
 
@@ -634,17 +634,35 @@ static int __devexit bfin_t350mcqb_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM
 static int bfin_t350mcqb_suspend(struct platform_device *pdev, pm_message_t state)
 {
-       bfin_t350mcqb_disable_ppi();
-       disable_dma(CH_PPI);
-       bfin_write_PPI_STATUS(0xFFFF);
+       struct fb_info *fbinfo = platform_get_drvdata(pdev);
+       struct bfin_t350mcqbfb_info *fbi = fbinfo->par;
+
+       if (fbi->lq043_open_cnt) {
+               bfin_t350mcqb_disable_ppi();
+               disable_dma(CH_PPI);
+               bfin_t350mcqb_stop_timers();
+               bfin_write_PPI_STATUS(-1);
+       }
+
 
        return 0;
 }
 
 static int bfin_t350mcqb_resume(struct platform_device *pdev)
 {
-       enable_dma(CH_PPI);
-       bfin_t350mcqb_enable_ppi();
+       struct fb_info *fbinfo = platform_get_drvdata(pdev);
+       struct bfin_t350mcqbfb_info *fbi = fbinfo->par;
+
+       if (fbi->lq043_open_cnt) {
+               bfin_t350mcqb_config_dma(fbi);
+               bfin_t350mcqb_config_ppi(fbi);
+               bfin_t350mcqb_init_timers();
+
+               /* start dma */
+               enable_dma(CH_PPI);
+               bfin_t350mcqb_enable_ppi();
+               bfin_t350mcqb_start_timers();
+       }
 
        return 0;
 }
index 16f5db471ab5e4f63aeb68746351770515e54bbf..99b354b8e2571db68f4a2d4f061829273d53de31 100644 (file)
  *
  *  Framebuffer driver for the CLPS7111 and EP7212 processors.
  */
+#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/fb.h>
 #include <linux/init.h>
@@ -38,14 +40,6 @@ struct fb_info       *cfb;
 
 #define CMAP_MAX_SIZE  16
 
-/* The /proc entry for the backlight. */
-static struct proc_dir_entry *clps7111fb_backlight_proc_entry = NULL;
-
-static int clps7111fb_proc_backlight_read(char *page, char **start, off_t off,
-               int count, int *eof, void *data);
-static int clps7111fb_proc_backlight_write(struct file *file, 
-               const char *buffer, unsigned long count, void *data);
-
 /*
  * LCD AC Prescale.  This comes from the LCD panel manufacturers specifications.
  * This determines how many clocks + 1 of CL1 before the M signal toggles.
@@ -221,26 +215,23 @@ static struct fb_ops clps7111fb_ops = {
        .fb_imageblit   = cfb_imageblit,
 };
 
-static int 
-clps7111fb_proc_backlight_read(char *page, char **start, off_t off,
-               int count, int *eof, void *data)
+static int backlight_proc_show(struct seq_file *m, void *v)
 {
-       /* We need at least two characters, one for the digit, and one for
-        * the terminating NULL. */
-       if (count < 2) 
-               return -EINVAL;
-
        if (machine_is_edb7211()) {
-               return sprintf(page, "%d\n", 
+               seq_printf(m, "%d\n",
                                (clps_readb(PDDR) & EDB_PD3_LCDBL) ? 1 : 0);
        }
 
        return 0;
 }
 
-static int 
-clps7111fb_proc_backlight_write(struct file *file, const char *buffer, 
-               unsigned long count, void *data)
+static int backlight_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, backlight_proc_show, NULL);
+}
+
+static ssize_t backlight_proc_write(struct file *file, const char *buffer,
+                                   size_t count, loff_t *pos)
 {
        unsigned char char_value;
        int value;
@@ -271,6 +262,15 @@ clps7111fb_proc_backlight_write(struct file *file, const char *buffer,
        return count;
 }
 
+static const struct file_operations backlight_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = backlight_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+       .write          = backlight_proc_write,
+};
+
 static void __init clps711x_guess_lcd_params(struct fb_info *info)
 {
        unsigned int lcdcon, syscon, size;
@@ -379,19 +379,11 @@ int __init clps711xfb_init(void)
 
        fb_alloc_cmap(&cfb->cmap, CMAP_MAX_SIZE, 0);
 
-       /* Register the /proc entries. */
-       clps7111fb_backlight_proc_entry = create_proc_entry("backlight", 0444,
-               NULL);
-       if (clps7111fb_backlight_proc_entry == NULL) {
+       if (!proc_create("backlight", 0444, NULL, &backlight_proc_fops)) {
                printk("Couldn't create the /proc entry for the backlight.\n");
                return -EINVAL;
        }
 
-       clps7111fb_backlight_proc_entry->read_proc = 
-               &clps7111fb_proc_backlight_read;
-       clps7111fb_backlight_proc_entry->write_proc = 
-               &clps7111fb_proc_backlight_write;
-
        /*
         * Power up the LCD
         */
index da7c01b39be248129a1a5f99274695cc510872d2..3a561df2e8a29d7b020913beef4a86fb705836a3 100644 (file)
@@ -1573,15 +1573,15 @@ cyberpro_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        if (err)
                return err;
 
-       err = pci_request_regions(dev, name);
-       if (err)
-               return err;
-
        err = -ENOMEM;
        cfb = cyberpro_alloc_fb_info(id->driver_data, name);
        if (!cfb)
                goto failed_release;
 
+       err = pci_request_regions(dev, cfb->fb.fix.id);
+       if (err)
+               goto failed_regions;
+
        cfb->dev = dev;
        cfb->region = pci_ioremap_bar(dev, 0);
        if (!cfb->region)
@@ -1633,10 +1633,10 @@ cyberpro_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
 failed:
        iounmap(cfb->region);
 failed_ioremap:
+       pci_release_regions(dev);
+failed_regions:
        cyberpro_free_fb_info(cfb);
 failed_release:
-       pci_release_regions(dev);
-
        return err;
 }
 
index ea1fd3f475115746a84ceef6a048fa6b09489cd3..369a5b3ac6493b578425a7435ad45b4c2bc3759b 100644 (file)
@@ -28,6 +28,8 @@
 #include <linux/uaccess.h>
 #include <linux/interrupt.h>
 #include <linux/clk.h>
+#include <linux/cpufreq.h>
+#include <linux/console.h>
 #include <video/da8xx-fb.h>
 
 #define DRIVER_NAME "da8xx_lcdc"
@@ -113,6 +115,12 @@ struct da8xx_fb_par {
        unsigned short pseudo_palette[16];
        unsigned int databuf_sz;
        unsigned int palette_sz;
+       unsigned int pxl_clk;
+       int blank;
+#ifdef CONFIG_CPU_FREQ
+       struct notifier_block   freq_transition;
+#endif
+       void (*panel_power_ctrl)(int);
 };
 
 /* Variable Screen Information */
@@ -155,7 +163,7 @@ struct da8xx_panel {
        int             vfp;            /* Vertical front porch */
        int             vbp;            /* Vertical back porch */
        int             vsw;            /* Vertical Sync Pulse Width */
-       int             pxl_clk;        /* Pixel clock */
+       unsigned int    pxl_clk;        /* Pixel clock */
        unsigned char   invert_pxl_clk; /* Invert Pixel clock */
 };
 
@@ -171,7 +179,7 @@ static struct da8xx_panel known_lcd_panels[] = {
                .vfp = 2,
                .vbp = 2,
                .vsw = 0,
-               .pxl_clk = 0x10,
+               .pxl_clk = 4608000,
                .invert_pxl_clk = 1,
        },
        /* Sharp LK043T1DG01 */
@@ -185,13 +193,23 @@ static struct da8xx_panel known_lcd_panels[] = {
                .vfp = 2,
                .vbp = 2,
                .vsw = 10,
-               .pxl_clk = 0x12,
+               .pxl_clk = 7833600,
                .invert_pxl_clk = 0,
        },
 };
 
+/* Enable the Raster Engine of the LCD Controller */
+static inline void lcd_enable_raster(void)
+{
+       u32 reg;
+
+       reg = lcdc_read(LCD_RASTER_CTRL_REG);
+       if (!(reg & LCD_RASTER_ENABLE))
+               lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+}
+
 /* Disable the Raster Engine of the LCD Controller */
-static void lcd_disable_raster(struct da8xx_fb_par *par)
+static inline void lcd_disable_raster(void)
 {
        u32 reg;
 
@@ -443,14 +461,25 @@ static int fb_setcolreg(unsigned regno, unsigned red, unsigned green,
 static void lcd_reset(struct da8xx_fb_par *par)
 {
        /* Disable the Raster if previously Enabled */
-       if (lcdc_read(LCD_RASTER_CTRL_REG) & LCD_RASTER_ENABLE)
-               lcd_disable_raster(par);
+       lcd_disable_raster();
 
        /* DMA has to be disabled */
        lcdc_write(0, LCD_DMA_CTRL_REG);
        lcdc_write(0, LCD_RASTER_CTRL_REG);
 }
 
+static void lcd_calc_clk_divider(struct da8xx_fb_par *par)
+{
+       unsigned int lcd_clk, div;
+
+       lcd_clk = clk_get_rate(par->lcdc_clk);
+       div = lcd_clk / par->pxl_clk;
+
+       /* Configure the LCD clock divisor. */
+       lcdc_write(LCD_CLK_DIVISOR(div) |
+                       (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG);
+}
+
 static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
                struct da8xx_panel *panel)
 {
@@ -459,9 +488,8 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
 
        lcd_reset(par);
 
-       /* Configure the LCD clock divisor. */
-       lcdc_write(LCD_CLK_DIVISOR(panel->pxl_clk) |
-                       (LCD_RASTER_MODE & 0x1), LCD_CTRL_REG);
+       /* Calculate the divider */
+       lcd_calc_clk_divider(par);
 
        if (panel->invert_pxl_clk)
                lcdc_write((lcdc_read(LCD_RASTER_TIMING_2_REG) |
@@ -513,13 +541,11 @@ static int lcd_init(struct da8xx_fb_par *par, const struct lcd_ctrl_config *cfg,
 static irqreturn_t lcdc_irq_handler(int irq, void *arg)
 {
        u32 stat = lcdc_read(LCD_STAT_REG);
-       u32 reg;
 
        if ((stat & LCD_SYNC_LOST) && (stat & LCD_FIFO_UNDERFLOW)) {
-               reg = lcdc_read(LCD_RASTER_CTRL_REG);
-               lcdc_write(reg & ~LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+               lcd_disable_raster();
                lcdc_write(stat, LCD_STAT_REG);
-               lcdc_write(reg | LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+               lcd_enable_raster();
        } else
                lcdc_write(stat, LCD_STAT_REG);
 
@@ -574,6 +600,38 @@ static int fb_check_var(struct fb_var_screeninfo *var,
        return err;
 }
 
+#ifdef CONFIG_CPU_FREQ
+static int lcd_da8xx_cpufreq_transition(struct notifier_block *nb,
+                                    unsigned long val, void *data)
+{
+       struct da8xx_fb_par *par;
+
+       par = container_of(nb, struct da8xx_fb_par, freq_transition);
+       if (val == CPUFREQ_PRECHANGE) {
+               lcd_disable_raster();
+       } else if (val == CPUFREQ_POSTCHANGE) {
+               lcd_calc_clk_divider(par);
+               lcd_enable_raster();
+       }
+
+       return 0;
+}
+
+static inline int lcd_da8xx_cpufreq_register(struct da8xx_fb_par *par)
+{
+       par->freq_transition.notifier_call = lcd_da8xx_cpufreq_transition;
+
+       return cpufreq_register_notifier(&par->freq_transition,
+                                        CPUFREQ_TRANSITION_NOTIFIER);
+}
+
+static inline void lcd_da8xx_cpufreq_deregister(struct da8xx_fb_par *par)
+{
+       cpufreq_unregister_notifier(&par->freq_transition,
+                                   CPUFREQ_TRANSITION_NOTIFIER);
+}
+#endif
+
 static int __devexit fb_remove(struct platform_device *dev)
 {
        struct fb_info *info = dev_get_drvdata(&dev->dev);
@@ -581,8 +639,13 @@ static int __devexit fb_remove(struct platform_device *dev)
        if (info) {
                struct da8xx_fb_par *par = info->par;
 
-               if (lcdc_read(LCD_RASTER_CTRL_REG) & LCD_RASTER_ENABLE)
-                       lcd_disable_raster(par);
+#ifdef CONFIG_CPU_FREQ
+               lcd_da8xx_cpufreq_deregister(par);
+#endif
+               if (par->panel_power_ctrl)
+                       par->panel_power_ctrl(0);
+
+               lcd_disable_raster();
                lcdc_write(0, LCD_RASTER_CTRL_REG);
 
                /* disable DMA  */
@@ -639,6 +702,35 @@ static int fb_ioctl(struct fb_info *info, unsigned int cmd,
        return 0;
 }
 
+static int cfb_blank(int blank, struct fb_info *info)
+{
+       struct da8xx_fb_par *par = info->par;
+       int ret = 0;
+
+       if (par->blank == blank)
+               return 0;
+
+       par->blank = blank;
+       switch (blank) {
+       case FB_BLANK_UNBLANK:
+               if (par->panel_power_ctrl)
+                       par->panel_power_ctrl(1);
+
+               lcd_enable_raster();
+               break;
+       case FB_BLANK_POWERDOWN:
+               if (par->panel_power_ctrl)
+                       par->panel_power_ctrl(0);
+
+               lcd_disable_raster();
+               break;
+       default:
+               ret = -EINVAL;
+       }
+
+       return ret;
+}
+
 static struct fb_ops da8xx_fb_ops = {
        .owner = THIS_MODULE,
        .fb_check_var = fb_check_var,
@@ -647,6 +739,7 @@ static struct fb_ops da8xx_fb_ops = {
        .fb_fillrect = cfb_fillrect,
        .fb_copyarea = cfb_copyarea,
        .fb_imageblit = cfb_imageblit,
+       .fb_blank = cfb_blank,
 };
 
 static int __init fb_probe(struct platform_device *device)
@@ -721,6 +814,12 @@ static int __init fb_probe(struct platform_device *device)
        }
 
        par = da8xx_fb_info->par;
+       par->lcdc_clk = fb_clk;
+       par->pxl_clk = lcdc_info->pxl_clk;
+       if (fb_pdata->panel_power_ctrl) {
+               par->panel_power_ctrl = fb_pdata->panel_power_ctrl;
+               par->panel_power_ctrl(1);
+       }
 
        if (lcd_init(par, lcd_cfg, lcdc_info) < 0) {
                dev_err(&device->dev, "lcd_init failed\n");
@@ -754,8 +853,6 @@ static int __init fb_probe(struct platform_device *device)
        da8xx_fb_fix.smem_len = par->databuf_sz - par->palette_sz;
        da8xx_fb_fix.line_length = (lcdc_info->width * lcd_cfg->bpp) / 8;
 
-       par->lcdc_clk = fb_clk;
-
        par->irq = platform_get_irq(device, 0);
        if (par->irq < 0) {
                ret = -ENOENT;
@@ -814,12 +911,24 @@ static int __init fb_probe(struct platform_device *device)
                goto err_dealloc_cmap;
        }
 
+#ifdef CONFIG_CPU_FREQ
+       ret = lcd_da8xx_cpufreq_register(par);
+       if (ret) {
+               dev_err(&device->dev, "failed to register cpufreq\n");
+               goto err_cpu_freq;
+       }
+#endif
+
        /* enable raster engine */
-       lcdc_write(lcdc_read(LCD_RASTER_CTRL_REG) |
-                       LCD_RASTER_ENABLE, LCD_RASTER_CTRL_REG);
+       lcd_enable_raster();
 
        return 0;
 
+#ifdef CONFIG_CPU_FREQ
+err_cpu_freq:
+       unregister_framebuffer(da8xx_fb_info);
+#endif
+
 err_dealloc_cmap:
        fb_dealloc_cmap(&da8xx_fb_info->cmap);
 
@@ -852,11 +961,35 @@ err_request_mem:
 #ifdef CONFIG_PM
 static int fb_suspend(struct platform_device *dev, pm_message_t state)
 {
-        return -EBUSY;
+       struct fb_info *info = platform_get_drvdata(dev);
+       struct da8xx_fb_par *par = info->par;
+
+       acquire_console_sem();
+       if (par->panel_power_ctrl)
+               par->panel_power_ctrl(0);
+
+       fb_set_suspend(info, 1);
+       lcd_disable_raster();
+       clk_disable(par->lcdc_clk);
+       release_console_sem();
+
+       return 0;
 }
 static int fb_resume(struct platform_device *dev)
 {
-        return -EBUSY;
+       struct fb_info *info = platform_get_drvdata(dev);
+       struct da8xx_fb_par *par = info->par;
+
+       acquire_console_sem();
+       if (par->panel_power_ctrl)
+               par->panel_power_ctrl(1);
+
+       clk_enable(par->lcdc_clk);
+       lcd_enable_raster();
+       fb_set_suspend(info, 0);
+       release_console_sem();
+
+       return 0;
 }
 #else
 #define fb_suspend NULL
index 4830b1bf51e5da7e6fcdadcfe67ce231ea977cc1..80abbf323b99befaa77bd0588463cb01ad1fe578 100644 (file)
@@ -67,7 +67,7 @@ static ssize_t display_store_contrast(struct device *dev,
        contrast = simple_strtoul(buf, &endp, 0);
        size = endp - buf;
 
-       if (*endp && isspace(*endp))
+       if (isspace(*endp))
                size++;
 
        if (size != count)
index bd9d46f95291435622551df82f3a863ab3f1c78e..27aab4a0619851b0d38301f2d3ecba0a761c24db 100644 (file)
@@ -358,6 +358,8 @@ static int ep93xxfb_setcolreg(unsigned int regno, unsigned int red,
 
        switch (info->fix.visual) {
        case FB_VISUAL_PSEUDOCOLOR:
+               if (regno > 255)
+                       return 1;
                rgb = ((red & 0xff00) << 8) | (green & 0xff00) |
                        ((blue & 0xff00) >> 8);
 
index e759895bf3d3d19deb02ec6323f7c8ff646b96fc..f0af911a096d9a781f318794fff9053416e0f0c5 100644 (file)
@@ -17,7 +17,7 @@
 #include <asm/io.h>
 #include <asm/div64.h>
 #include <asm/delay.h>
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 
 #include "gxfb.h"
 
@@ -25,7 +25,7 @@ unsigned int gx_frame_buffer_size(void)
 {
        unsigned int val;
 
-       if (!geode_has_vsa2()) {
+       if (!cs5535_has_vsa2()) {
                uint32_t hi, lo;
 
                /* The number of pages is (PMAX - PMIN)+1 */
index 16a96f8fd8c5f942954ca53fd7379617cce3e43b..d19e9378b0c01423d3776e7171e457c355e17ddc 100644 (file)
@@ -340,7 +340,7 @@ static inline void write_fp(struct gxfb_par *par, int reg, uint32_t val)
 }
 
 
-/* MSRs are defined in asm/geode.h; their bitfields are here */
+/* MSRs are defined in linux/cs5535.h; their bitfields are here */
 
 #define MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3        (1 << 3)
 #define MSR_GLCP_SYS_RSTPLL_DOTPREMULT2        (1 << 2)
index 2552cac39e1c7aa99536c4563933982421f21f04..b3e639d1e12cbf67addef7eaa7455b8684b47b43 100644 (file)
@@ -32,7 +32,7 @@
 #include <linux/suspend.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 
 #include "gxfb.h"
 
index 6a51448fd3f74d53cf4880a9a22ff71062ea18d3..cc781c00f75d04a11a9b371db177dca3ea64b06d 100644 (file)
@@ -1,3 +1,13 @@
+/* Geode LX framebuffer driver
+ *
+ * Copyright (C) 2006-2007, Advanced Micro Devices,Inc.
+ * Copyright (c) 2008  Andres Salomon <dilinger@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
 #ifndef _LXFB_H_
 #define _LXFB_H_
 
@@ -409,7 +419,7 @@ static inline void write_fp(struct lxfb_par *par, int reg, uint32_t val)
 }
 
 
-/* MSRs are defined in asm/geode.h; their bitfields are here */
+/* MSRs are defined in linux/cs5535.h; their bitfields are here */
 
 #define MSR_GLCP_DOTPLL_LOCK           (1 << 25)       /* r/o */
 #define MSR_GLCP_DOTPLL_HALFPIX                (1 << 24)
index b1cd49c9935618a6af9db4602021f41e8aaf23d4..0e5d8c7c3ebae2ad81a62bd693c857e10771f01a 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/fb.h>
 #include <linux/uaccess.h>
 #include <linux/delay.h>
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 
 #include "lxfb.h"
 
@@ -307,7 +307,7 @@ unsigned int lx_framebuffer_size(void)
 {
        unsigned int val;
 
-       if (!geode_has_vsa2()) {
+       if (!cs5535_has_vsa2()) {
                uint32_t hi, lo;
 
                /* The number of pages is (PMAX - PMIN)+1 */
index 9aff32ef8bb602c56ba720e34fcb9be1df547b4b..1bb043d70c647004b68e2615cfec9f8ed7d6cd89 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/fb.h>
 #include <asm/io.h>
 #include <asm/msr.h>
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 #include <asm/delay.h>
 
 #include "gxfb.h"
index b8d52a8360db2436371dc3445a39e3a4fd96c8c2..6082f653c68a448e3e32ea08571f04af97f6acf5 100644 (file)
@@ -16,7 +16,7 @@
 #include <asm/io.h>
 #include <asm/delay.h>
 #include <asm/msr.h>
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 
 #include "gxfb.h"
 
index e7116a6d82d306b51e7b621c1e927fdd156c31ab..73c83a8de2d37a68b35553f7dcc8e18cb5fde890 100644 (file)
@@ -456,7 +456,7 @@ static int hitfb_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops hitfb_dev_pm_ops = {
+static const struct dev_pm_ops hitfb_dev_pm_ops = {
        .suspend        = hitfb_suspend,
        .resume         = hitfb_resume,
 };
index 27fa703a2e0aadcfe820410ed1769b18c3a87bc6..b4b3670667ab8ce42dce3d58cc2d65be02d72eaa 100644 (file)
@@ -212,24 +212,29 @@ inline void round_off_yres(u32 *xres, u32 *yres)
        *yres = (*xres * 3) >> 2;
 }
 
-void i810fb_encode_registers(const struct fb_var_screeninfo *var,
-                            struct i810fb_par *par, u32 xres, u32 yres)
+static int i810fb_find_best_mode(u32 xres, u32 yres, u32 pixclock)
 { 
        u32 diff = 0, diff_best = 0xFFFFFFFF, i = 0, i_best = 0; 
-       u8 hfl;
+       u8 hfl = (u8) ((xres >> 3) - 1);
 
-       hfl = (u8) ((xres >> 3) - 1);
        for (i = 0; i < ARRAY_SIZE(std_modes); i++) { 
                if (std_modes[i].cr01 == hfl) { 
-                       if (std_modes[i].pixclock <= par->regs.pixclock)
-                               diff = par->regs.pixclock - 
-                                       std_modes[i].pixclock;
+                       if (std_modes[i].pixclock <= pixclock)
+                               diff = pixclock - std_modes[i].pixclock;
                        if (diff < diff_best) {  
                                i_best = i;
                                diff_best = diff;
                        }
                }
        }
+       return i_best;
+}
+
+void i810fb_encode_registers(const struct fb_var_screeninfo *var,
+                            struct i810fb_par *par, u32 xres, u32 yres)
+{
+       u32 i_best = i810fb_find_best_mode(xres, yres, par->regs.pixclock);
+
        par->regs = std_modes[i_best];
 
        /* overlay */
@@ -239,36 +244,36 @@ void i810fb_encode_registers(const struct fb_var_screeninfo *var,
 
 void i810fb_fill_var_timings(struct fb_var_screeninfo *var)
 {
-       struct i810fb_par par;
        u32 total, xres, yres;
+       u32 mode, pixclock;
 
        xres = var->xres;
        yres = var->yres;
        
-       par.regs.pixclock = 1000000000/var->pixclock;
-       i810fb_encode_registers(var, &par, xres, yres);
+       pixclock = 1000000000 / var->pixclock;
+       mode = i810fb_find_best_mode(xres, yres, pixclock);
        
-       total = ((par.regs.cr00 | (par.regs.cr35 & 1) << 8) + 3) << 3;
+       total = (std_modes[mode].cr00 | (std_modes[mode].cr35 & 1) << 8) + 3;
+       total <<= 3;
        
-       var->pixclock = 1000000000/par.regs.pixclock;
-       var->right_margin = (par.regs.cr04 << 3) - xres;
-       var->hsync_len = ((par.regs.cr05 & 0x1F) - 
-                              (par.regs.cr04 & 0x1F)) << 3;
+       var->pixclock = 1000000000 / std_modes[mode].pixclock;
+       var->right_margin = (std_modes[mode].cr04 << 3) - xres;
+       var->hsync_len = ((std_modes[mode].cr05 & 0x1F) -
+                        (std_modes[mode].cr04 & 0x1F)) << 3;
        var->left_margin = (total - (xres + var->right_margin + 
                                     var->hsync_len));
        var->sync = FB_SYNC_ON_GREEN;
-       if (~(par.regs.msr & (1 << 6)))
+       if (~(std_modes[mode].msr & (1 << 6)))
                var->sync |= FB_SYNC_HOR_HIGH_ACT;
-       if (~(par.regs.msr & (1 << 7)))
+       if (~(std_modes[mode].msr & (1 << 7)))
                var->sync |= FB_SYNC_VERT_HIGH_ACT;
 
-
-       total = ((par.regs.cr06 | (par.regs.cr30 & 0x0F)  << 8)) + 2;
-       var->lower_margin = (par.regs.cr10 | 
-                            (par.regs.cr32 & 0x0F) << 8) - yres;
-       var->vsync_len = (par.regs.cr11 & 0x0F) - (var->lower_margin & 0x0F);
-       var->upper_margin = total - (yres + var->lower_margin + 
-                                    var->vsync_len);
+       total = (std_modes[mode].cr06 | (std_modes[mode].cr30 & 0xF)  << 8) + 2;
+       var->lower_margin = (std_modes[mode].cr10 |
+                           (std_modes[mode].cr32 & 0x0F) << 8) - yres;
+       var->vsync_len = (std_modes[mode].cr11 & 0x0F) -
+                        (var->lower_margin & 0x0F);
+       var->upper_margin = total - (yres + var->lower_margin + var->vsync_len);
 }
 
 u32 i810_get_watermark(struct fb_var_screeninfo *var,
index 0cafd642fbc0f57b5eaee3fe85a60895c30e1d8d..5ba3999910509f09fc1e0775518d5c23c520ec18 100644 (file)
@@ -874,6 +874,9 @@ static int __devinit intelfb_pci_register(struct pci_dev *pdev,
        if (bailearly == 18)
                bailout(dinfo);
 
+       /* read active pipe */
+       dinfo->pipe = intelfbhw_active_pipe(&dinfo->save_state);
+
        /* Cursor initialisation */
        if (dinfo->hwcursor) {
                intelfbhw_cursor_init(dinfo);
index 0689f97c5238a187ff44360bd57c4d2d86eb13ad..81627466804e1f7ceeba08f63bf7517562ac3ef4 100644 (file)
@@ -469,6 +469,32 @@ void intelfbhw_do_blank(int blank, struct fb_info *info)
 }
 
 
+/* Check which pipe is connected to an active display plane. */
+int intelfbhw_active_pipe(const struct intelfb_hwstate *hw)
+{
+       int pipe = -1;
+
+       /* keep old default behaviour - prefer PIPE_A */
+       if (hw->disp_b_ctrl & DISPPLANE_PLANE_ENABLE) {
+               pipe = (hw->disp_b_ctrl >> DISPPLANE_SEL_PIPE_SHIFT);
+               pipe &= PIPE_MASK;
+               if (unlikely(pipe == PIPE_A))
+                       return PIPE_A;
+       }
+       if (hw->disp_a_ctrl & DISPPLANE_PLANE_ENABLE) {
+               pipe = (hw->disp_a_ctrl >> DISPPLANE_SEL_PIPE_SHIFT);
+               pipe &= PIPE_MASK;
+               if (likely(pipe == PIPE_A))
+                       return PIPE_A;
+       }
+       /* Impossible that no pipe is selected - return PIPE_A */
+       WARN_ON(pipe == -1);
+       if (unlikely(pipe == -1))
+               pipe = PIPE_A;
+
+       return pipe;
+}
+
 void intelfbhw_setcolreg(struct intelfb_info *dinfo, unsigned regno,
                         unsigned red, unsigned green, unsigned blue,
                         unsigned transp)
@@ -1019,7 +1045,7 @@ int intelfbhw_mode_to_hw(struct intelfb_info *dinfo,
                         struct intelfb_hwstate *hw,
                         struct fb_var_screeninfo *var)
 {
-       int pipe = PIPE_A;
+       int pipe = intelfbhw_active_pipe(hw);
        u32 *dpll, *fp0, *fp1;
        u32 m1, m2, n, p1, p2, clock_target, clock;
        u32 hsync_start, hsync_end, hblank_start, hblank_end, htotal, hactive;
@@ -1033,12 +1059,6 @@ int intelfbhw_mode_to_hw(struct intelfb_info *dinfo,
        /* Disable VGA */
        hw->vgacntrl |= VGA_DISABLE;
 
-       /* Check whether pipe A or pipe B is enabled. */
-       if (hw->pipe_a_conf & PIPECONF_ENABLE)
-               pipe = PIPE_A;
-       else if (hw->pipe_b_conf & PIPECONF_ENABLE)
-               pipe = PIPE_B;
-
        /* Set which pipe's registers will be set. */
        if (pipe == PIPE_B) {
                dpll = &hw->dpll_b;
@@ -1262,7 +1282,6 @@ int intelfbhw_mode_to_hw(struct intelfb_info *dinfo,
 int intelfbhw_program_mode(struct intelfb_info *dinfo,
                           const struct intelfb_hwstate *hw, int blank)
 {
-       int pipe = PIPE_A;
        u32 tmp;
        const u32 *dpll, *fp0, *fp1, *pipe_conf;
        const u32 *hs, *ht, *hb, *vs, *vt, *vb, *ss;
@@ -1272,7 +1291,7 @@ int intelfbhw_program_mode(struct intelfb_info *dinfo,
        u32 src_size_reg;
        u32 count, tmp_val[3];
 
-       /* Assume single pipe, display plane A, analog CRT. */
+       /* Assume single pipe */
 
 #if VERBOSE > 0
        DBG_MSG("intelfbhw_program_mode\n");
@@ -1283,15 +1302,9 @@ int intelfbhw_program_mode(struct intelfb_info *dinfo,
        tmp |= VGA_DISABLE;
        OUTREG(VGACNTRL, tmp);
 
-       /* Check whether pipe A or pipe B is enabled. */
-       if (hw->pipe_a_conf & PIPECONF_ENABLE)
-               pipe = PIPE_A;
-       else if (hw->pipe_b_conf & PIPECONF_ENABLE)
-               pipe = PIPE_B;
-
-       dinfo->pipe = pipe;
+       dinfo->pipe = intelfbhw_active_pipe(hw);
 
-       if (pipe == PIPE_B) {
+       if (dinfo->pipe == PIPE_B) {
                dpll = &hw->dpll_b;
                fp0 = &hw->fpb0;
                fp1 = &hw->fpb1;
index 0b076bac321b82559b2240105503751e843b1cc3..216ca20f259f2b39dadab3d9613c6be6ace6fa70 100644 (file)
@@ -604,5 +604,6 @@ extern void intelfbhw_cursor_reset(struct intelfb_info *dinfo);
 extern int intelfbhw_enable_irq(struct intelfb_info *dinfo);
 extern void intelfbhw_disable_irq(struct intelfb_info *dinfo);
 extern int intelfbhw_wait_for_vsync(struct intelfb_info *dinfo, u32 pipe);
+extern int intelfbhw_active_pipe(const struct intelfb_hwstate *hw);
 
 #endif /* _INTELFBHW_H */
index 09f6e045d5beb19755a3449c711cf746321d9c4e..c15f8a57498ed15e9538c18f78c5ced10c42144e 100644 (file)
@@ -368,7 +368,8 @@ static int __g450_setclk(struct matrox_fb_info *minfo, unsigned int fout,
                                        M1064_XDVICLKCTRL_C1DVICLKEN |
                                        M1064_XDVICLKCTRL_DVILOOPCTL |
                                        M1064_XDVICLKCTRL_P1LOOPBWDTCTL;
-                               matroxfb_DAC_out(minfo, M1064_XDVICLKCTRL, tmp);
+                                /* Setting this breaks PC systems so don't do it */
+                               /* matroxfb_DAC_out(minfo, M1064_XDVICLKCTRL, tmp); */
                                matroxfb_DAC_out(minfo, M1064_XPWRCTRL,
                                                 xpwrctrl);
 
index 5e91c2b30af9113edc6fc37d2b22752f59caae62..7854c7a37dc58430e3751ebedbce9c6286cf6280 100644 (file)
@@ -92,6 +92,9 @@ static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
        /* value to be written into the palette reg. */
        unsigned long hw_colorvalue = 0;
 
+       if (regno > 255)
+               return 1;
+
        red   >>= 8;    /* The cmap fields are 16 bits    */
        green >>= 8;    /* wide, but the harware colormap */
        blue  >>= 8;    /* registers are only 8 bits wide */
index 07664814bb1dbf401401911af9ef56d67320b597..d7777714166b89a5ac24e235d7b53b7bc1a0d81f 100644 (file)
@@ -2,4 +2,4 @@
 # Makefile for the MB862xx framebuffer driver
 #
 
-obj-$(CONFIG_FB_MB862XX)       := mb862xxfb.o
+obj-$(CONFIG_FB_MB862XX)       := mb862xxfb.o mb862xxfb_accel.o
index a28e3cfbbf707964099cbf6d04a97eb6a6db2860..fabb0c59a211803e2210053b1cce899a65056f51 100644 (file)
@@ -214,6 +214,8 @@ static int mb862xxfb_set_par(struct fb_info *fbi)
        unsigned long reg, sc;
 
        dev_dbg(par->dev, "%s\n", __func__);
+       if (par->type == BT_CORALP)
+               mb862xxfb_init_accel(fbi, fbi->var.xres);
 
        if (par->pre_init)
                return 0;
@@ -453,6 +455,18 @@ static ssize_t mb862xxfb_show_dispregs(struct device *dev,
                ptr += sprintf(ptr, "%08x = %08x\n",
                               reg, inreg(disp, reg));
 
+       for (reg = 0x400; reg <= 0x410; reg += 4)
+               ptr += sprintf(ptr, "geo %08x = %08x\n",
+                              reg, inreg(geo, reg));
+
+       for (reg = 0x400; reg <= 0x410; reg += 4)
+               ptr += sprintf(ptr, "draw %08x = %08x\n",
+                              reg, inreg(draw, reg));
+
+       for (reg = 0x440; reg <= 0x450; reg += 4)
+               ptr += sprintf(ptr, "draw %08x = %08x\n",
+                              reg, inreg(draw, reg));
+
        return ptr - buf;
 }
 
index c4c8f4dd2217582f05553c3ae6f8b4870b89b52c..d7e7cb76bbf2522dd05398cd6442da90e2ae7c56 100644 (file)
@@ -61,6 +61,8 @@ struct mb862xxfb_par {
        u32                     pseudo_palette[16];
 };
 
+extern void mb862xxfb_init_accel(struct fb_info *info, int xres);
+
 #if defined(CONFIG_FB_MB862XX_LIME) && defined(CONFIG_FB_MB862XX_PCI_GDC)
 #error "Select Lime GDC or CoralP/Carmine support, but not both together"
 #endif
diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
new file mode 100644 (file)
index 0000000..0492560
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ * drivers/mb862xx/mb862xxfb_accel.c
+ *
+ * Fujitsu Carmine/Coral-P(A)/Lime framebuffer driver acceleration support
+ *
+ * (C) 2007 Alexander Shishkin <virtuoso@slind.org>
+ * (C) 2009 Valentin Sitdikov <valentin.sitdikov@siemens.com>
+ * (C) 2009 Siemens AG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#include <linux/fb.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#if defined(CONFIG_OF)
+#include <linux/of_platform.h>
+#endif
+#include "mb862xxfb.h"
+#include "mb862xx_reg.h"
+#include "mb862xxfb_accel.h"
+
+static void mb862xxfb_write_fifo(u32 count, u32 *data, struct fb_info *info)
+{
+       struct mb862xxfb_par *par = info->par;
+       static u32 free;
+
+       u32 total = 0;
+       while (total < count) {
+               if (free) {
+                       outreg(geo, GDC_GEO_REG_INPUT_FIFO, data[total]);
+                       total++;
+                       free--;
+               } else {
+                       free = (u32) inreg(draw, GDC_REG_FIFO_COUNT);
+               }
+       }
+}
+
+static void mb86290fb_copyarea(struct fb_info *info,
+                              const struct fb_copyarea *area)
+{
+       __u32 cmd[6];
+
+       cmd[0] = (GDC_TYPE_SETREGISTER << 24) | (1 << 16) | GDC_REG_MODE_BITMAP;
+       /* Set raster operation */
+       cmd[1] = (2 << 7) | (GDC_ROP_COPY << 9);
+       cmd[2] = GDC_TYPE_BLTCOPYP << 24;
+
+       if (area->sx >= area->dx && area->sy >= area->dy)
+               cmd[2] |= GDC_CMD_BLTCOPY_TOP_LEFT << 16;
+       else if (area->sx >= area->dx && area->sy <= area->dy)
+               cmd[2] |= GDC_CMD_BLTCOPY_BOTTOM_LEFT << 16;
+       else if (area->sx <= area->dx && area->sy >= area->dy)
+               cmd[2] |= GDC_CMD_BLTCOPY_TOP_RIGHT << 16;
+       else
+               cmd[2] |= GDC_CMD_BLTCOPY_BOTTOM_RIGHT << 16;
+
+       cmd[3] = (area->sy << 16) | area->sx;
+       cmd[4] = (area->dy << 16) | area->dx;
+       cmd[5] = (area->height << 16) | area->width;
+       mb862xxfb_write_fifo(6, cmd, info);
+}
+
+/*
+ * Fill in the cmd array /GDC FIFO commands/ to draw a 1bit image.
+ * Make sure cmd has enough room!
+ */
+static void mb86290fb_imageblit1(u32 *cmd, u16 step, u16 dx, u16 dy,
+                                u16 width, u16 height, u32 fgcolor,
+                                u32 bgcolor, const struct fb_image *image,
+                                struct fb_info *info)
+{
+       int i;
+       unsigned const char *line;
+       u16 bytes;
+
+       /* set colors and raster operation regs */
+       cmd[0] = (GDC_TYPE_SETREGISTER << 24) | (1 << 16) | GDC_REG_MODE_BITMAP;
+       /* Set raster operation */
+       cmd[1] = (2 << 7) | (GDC_ROP_COPY << 9);
+       cmd[2] =
+           (GDC_TYPE_SETCOLORREGISTER << 24) | (GDC_CMD_BODY_FORE_COLOR << 16);
+       cmd[3] = fgcolor;
+       cmd[4] =
+           (GDC_TYPE_SETCOLORREGISTER << 24) | (GDC_CMD_BODY_BACK_COLOR << 16);
+       cmd[5] = bgcolor;
+
+       i = 0;
+       line = image->data;
+       bytes = (image->width + 7) >> 3;
+
+       /* and the image */
+       cmd[6] = (GDC_TYPE_DRAWBITMAPP << 24) |
+           (GDC_CMD_BITMAP << 16) | (2 + (step * height));
+       cmd[7] = (dy << 16) | dx;
+       cmd[8] = (height << 16) | width;
+
+       while (i < height) {
+               memcpy(&cmd[9 + i * step], line, step << 2);
+#ifdef __LITTLE_ENDIAN
+               {
+                       int k = 0;
+                       for (k = 0; k < step; k++)
+                               cmd[9 + i * step + k] =
+                                   cpu_to_be32(cmd[9 + i * step + k]);
+               }
+#endif
+               line += bytes;
+               i++;
+       }
+}
+
+/*
+ * Fill in the cmd array /GDC FIFO commands/ to draw a 8bit image.
+ * Make sure cmd has enough room!
+ */
+static void mb86290fb_imageblit8(u32 *cmd, u16 step, u16 dx, u16 dy,
+                                u16 width, u16 height, u32 fgcolor,
+                                u32 bgcolor, const struct fb_image *image,
+                                struct fb_info *info)
+{
+       int i, j;
+       unsigned const char *line, *ptr;
+       u16 bytes;
+
+       cmd[0] = (GDC_TYPE_DRAWBITMAPP << 24) |
+           (GDC_CMD_BLT_DRAW << 16) | (2 + (height * step));
+       cmd[1] = (dy << 16) | dx;
+       cmd[2] = (height << 16) | width;
+
+       i = 0;
+       line = ptr = image->data;
+       bytes = image->width;
+
+       while (i < height) {
+               ptr = line;
+               for (j = 0; j < step; j++) {
+                       cmd[3 + i * step + j] =
+                           (((u32 *) (info->pseudo_palette))[*ptr]) & 0xffff;
+                       ptr++;
+                       cmd[3 + i * step + j] |=
+                           ((((u32 *) (info->
+                                       pseudo_palette))[*ptr]) & 0xffff) << 16;
+                       ptr++;
+               }
+
+               line += bytes;
+               i++;
+       }
+}
+
+/*
+ * Fill in the cmd array /GDC FIFO commands/ to draw a 16bit image.
+ * Make sure cmd has enough room!
+ */
+static void mb86290fb_imageblit16(u32 *cmd, u16 step, u16 dx, u16 dy,
+                                 u16 width, u16 height, u32 fgcolor,
+                                 u32 bgcolor, const struct fb_image *image,
+                                 struct fb_info *info)
+{
+       int i;
+       unsigned const char *line;
+       u16 bytes;
+
+       i = 0;
+       line = image->data;
+       bytes = image->width << 1;
+
+       cmd[0] = (GDC_TYPE_DRAWBITMAPP << 24) |
+           (GDC_CMD_BLT_DRAW << 16) | (2 + step * height);
+       cmd[1] = (dy << 16) | dx;
+       cmd[2] = (height << 16) | width;
+
+       while (i < height) {
+               memcpy(&cmd[3 + i * step], line, step);
+               line += bytes;
+               i++;
+       }
+}
+
+static void mb86290fb_imageblit(struct fb_info *info,
+                               const struct fb_image *image)
+{
+       int mdr;
+       u32 *cmd = NULL;
+       void (*cmdfn) (u32 *, u16, u16, u16, u16, u16, u32, u32,
+                      const struct fb_image *, struct fb_info *) = NULL;
+       u32 cmdlen;
+       u32 fgcolor = 0, bgcolor = 0;
+       u16 step;
+
+       u16 width = image->width, height = image->height;
+       u16 dx = image->dx, dy = image->dy;
+       int x2, y2, vxres, vyres;
+
+       mdr = (GDC_ROP_COPY << 9);
+       x2 = image->dx + image->width;
+       y2 = image->dy + image->height;
+       vxres = info->var.xres_virtual;
+       vyres = info->var.yres_virtual;
+       x2 = min(x2, vxres);
+       y2 = min(y2, vyres);
+       width = x2 - dx;
+       height = y2 - dy;
+
+       switch (image->depth) {
+       case 1:
+               step = (width + 31) >> 5;
+               cmdlen = 9 + height * step;
+               cmdfn = mb86290fb_imageblit1;
+               if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
+                   info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
+                       fgcolor =
+                           ((u32 *) (info->pseudo_palette))[image->fg_color];
+                       bgcolor =
+                           ((u32 *) (info->pseudo_palette))[image->bg_color];
+               } else {
+                       fgcolor = image->fg_color;
+                       bgcolor = image->bg_color;
+               }
+
+               break;
+
+       case 8:
+               step = (width + 1) >> 1;
+               cmdlen = 3 + height * step;
+               cmdfn = mb86290fb_imageblit8;
+               break;
+
+       case 16:
+               step = (width + 1) >> 1;
+               cmdlen = 3 + height * step;
+               cmdfn = mb86290fb_imageblit16;
+               break;
+
+       default:
+               cfb_imageblit(info, image);
+               return;
+       }
+
+       cmd = kmalloc(cmdlen * 4, GFP_DMA);
+       if (!cmd)
+               return cfb_imageblit(info, image);
+       cmdfn(cmd, step, dx, dy, width, height, fgcolor, bgcolor, image, info);
+       mb862xxfb_write_fifo(cmdlen, cmd, info);
+       kfree(cmd);
+}
+
+static void mb86290fb_fillrect(struct fb_info *info,
+                              const struct fb_fillrect *rect)
+{
+
+       u32 x2, y2, vxres, vyres, height, width, fg;
+       u32 cmd[7];
+
+       vxres = info->var.xres_virtual;
+       vyres = info->var.yres_virtual;
+
+       if (!rect->width || !rect->height || rect->dx > vxres
+           || rect->dy > vyres)
+               return;
+
+       /* We could use hardware clipping but on many cards you get around
+        * hardware clipping by writing to framebuffer directly. */
+       x2 = rect->dx + rect->width;
+       y2 = rect->dy + rect->height;
+       x2 = min(x2, vxres);
+       y2 = min(y2, vyres);
+       width = x2 - rect->dx;
+       height = y2 - rect->dy;
+       if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
+           info->fix.visual == FB_VISUAL_DIRECTCOLOR)
+               fg = ((u32 *) (info->pseudo_palette))[rect->color];
+       else
+               fg = rect->color;
+
+       switch (rect->rop) {
+
+       case ROP_XOR:
+               /* Set raster operation */
+               cmd[1] = (2 << 7) | (GDC_ROP_XOR << 9);
+               break;
+
+       case ROP_COPY:
+               /* Set raster operation */
+               cmd[1] = (2 << 7) | (GDC_ROP_COPY << 9);
+               break;
+
+       }
+
+       cmd[0] = (GDC_TYPE_SETREGISTER << 24) | (1 << 16) | GDC_REG_MODE_BITMAP;
+       /* cmd[1] set earlier */
+       cmd[2] =
+           (GDC_TYPE_SETCOLORREGISTER << 24) | (GDC_CMD_BODY_FORE_COLOR << 16);
+       cmd[3] = fg;
+       cmd[4] = (GDC_TYPE_DRAWRECTP << 24) | (GDC_CMD_BLT_FILL << 16);
+       cmd[5] = (rect->dy << 16) | (rect->dx);
+       cmd[6] = (height << 16) | width;
+
+       mb862xxfb_write_fifo(7, cmd, info);
+}
+
+void mb862xxfb_init_accel(struct fb_info *info, int xres)
+{
+       struct mb862xxfb_par *par = info->par;
+
+       if (info->var.bits_per_pixel == 32) {
+               info->fbops->fb_fillrect = cfb_fillrect;
+               info->fbops->fb_copyarea = cfb_copyarea;
+               info->fbops->fb_imageblit = cfb_imageblit;
+       } else {
+               outreg(disp, GC_L0EM, 3);
+               info->fbops->fb_fillrect = mb86290fb_fillrect;
+               info->fbops->fb_copyarea = mb86290fb_copyarea;
+               info->fbops->fb_imageblit = mb86290fb_imageblit;
+       }
+       outreg(draw, GDC_REG_DRAW_BASE, 0);
+       outreg(draw, GDC_REG_MODE_MISC, 0x8000);
+       outreg(draw, GDC_REG_X_RESOLUTION, xres);
+
+       info->flags |=
+           FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
+           FBINFO_HWACCEL_IMAGEBLIT;
+       info->fix.accel = 0xff; /*FIXME: add right define */
+}
+EXPORT_SYMBOL(mb862xxfb_init_accel);
diff --git a/drivers/video/mb862xx/mb862xxfb_accel.h b/drivers/video/mb862xx/mb862xxfb_accel.h
new file mode 100644 (file)
index 0000000..96a2dfe
--- /dev/null
@@ -0,0 +1,203 @@
+#ifndef __MB826XXFB_ACCEL_H__
+#define __MB826XXFB_ACCEL_H__
+
+/* registers */
+#define GDC_GEO_REG_INPUT_FIFO 0x00000400L
+
+/* Special Registers */
+#define GDC_REG_CTRL                0x00000400L
+#define GDC_REG_FIFO_STATUS         0x00000404L
+#define GDC_REG_FIFO_COUNT          0x00000408L
+#define GDC_REG_SETUP_STATUS        0x0000040CL
+#define GDC_REG_DDA_STATUS          0x00000410L
+#define GDC_REG_ENGINE_STATUS       0x00000414L
+#define GDC_REG_ERROR_STATUS        0x00000418L
+#define GDC_REG_MODE_MISC           0x00000420L        /* MDR0 */
+#define GDC_REG_MODE_LINE           0x00000424L        /* MDR1 */
+#define GDC_REG_MODE_POLYGON        0x00000428L        /* MDR2 */
+#define GDC_REG_MODE_TEXTURE        0x0000042CL        /* MDR3 */
+#define GDC_REG_MODE_BITMAP         0x00000430L        /* MDR4 */
+#define GDC_REG_MODE_EXTENSION      0x0000043CL        /* MDR7 */
+
+/* Configuration Registers */
+#define GDC_REG_DRAW_BASE           0x00000440L
+#define GDC_REG_X_RESOLUTION        0x00000444L
+#define GDC_REG_Z_BASE              0x00000448L
+#define GDC_REG_TEXTURE_BASE        0x0000044CL
+#define GDC_REG_POLYGON_FLAG_BASE   0x00000450L
+#define GDC_REG_CLIP_XMIN           0x00000454L
+#define GDC_REG_CLIP_XMAX           0x00000458L
+#define GDC_REG_CLIP_YMIN           0x0000045CL
+#define GDC_REG_CLIP_YMAX           0x00000460L
+#define GDC_REG_TEXURE_SIZE         0x00000464L
+#define GDC_REG_TILE_SIZE           0x00000468L
+#define GDC_REG_TEX_BUF_OFFSET      0x0000046CL
+
+/* for MB86293 or later */
+#define GDC_REG_ALPHA_MAP_BASE      0x00000474L        /* ABR */
+
+/* Constant Registers */
+#define GDC_REG_FOREGROUND_COLOR    0x00000480L
+#define GDC_REG_BACKGROUND_COLOR    0x00000484L
+#define GDC_REG_ALPHA               0x00000488L
+#define GDC_REG_LINE_PATTERN        0x0000048CL
+#define GDC_REG_TEX_BORDER_COLOR    0x00000494L
+#define GDC_REG_LINE_PATTERN_OFFSET 0x000003E0L
+
+/* Coomand Code */
+#define GDC_CMD_PIXEL                   0x00000000L
+#define GDC_CMD_PIXEL_Z                 0x00000001L
+
+#define GDC_CMD_X_VECTOR                0x00000020L
+#define GDC_CMD_Y_VECTOR                0x00000021L
+#define GDC_CMD_X_VECTOR_NOEND          0x00000022L
+#define GDC_CMD_Y_VECTOR_NOEND          0x00000023L
+#define GDC_CMD_X_VECTOR_BLPO           0x00000024L
+#define GDC_CMD_Y_VECTOR_BLPO           0x00000025L
+#define GDC_CMD_X_VECTOR_NOEND_BLPO     0x00000026L
+#define GDC_CMD_Y_VECTOR_NOEND_BLPO     0x00000027L
+#define GDC_CMD_AA_X_VECTOR             0x00000028L
+#define GDC_CMD_AA_Y_VECTOR             0x00000029L
+#define GDC_CMD_AA_X_VECTOR_NOEND       0x0000002AL
+#define GDC_CMD_AA_Y_VECTOR_NOEND       0x0000002BL
+#define GDC_CMD_AA_X_VECTOR_BLPO        0x0000002CL
+#define GDC_CMD_AA_Y_VECTOR_BLPO        0x0000002DL
+#define GDC_CMD_AA_X_VECTOR_NOEND_BLPO  0x0000002EL
+#define GDC_CMD_AA_Y_VECTOR_NOEND_BLPO  0x0000002FL
+
+#define GDC_CMD_0_VECTOR                0x00000030L
+#define GDC_CMD_1_VECTOR                0x00000031L
+#define GDC_CMD_0_VECTOR_NOEND          0x00000032L
+#define GDC_CMD_1_VECTOR_NOEND          0x00000033L
+#define GDC_CMD_0_VECTOR_BLPO           0x00000034L
+#define GDC_CMD_1_VECTOR_BLPO           0x00000035L
+#define GDC_CMD_0_VECTOR_NOEND_BLPO     0x00000036L
+#define GDC_CMD_1_VECTOR_NOEND_BLPO     0x00000037L
+#define GDC_CMD_AA_0_VECTOR             0x00000038L
+#define GDC_CMD_AA_1_VECTOR             0x00000039L
+#define GDC_CMD_AA_0_VECTOR_NOEND       0x0000003AL
+#define GDC_CMD_AA_1_VECTOR_NOEND       0x0000003BL
+#define GDC_CMD_AA_0_VECTOR_BLPO        0x0000003CL
+#define GDC_CMD_AA_1_VECTOR_BLPO        0x0000003DL
+#define GDC_CMD_AA_0_VECTOR_NOEND_BLPO  0x0000003EL
+#define GDC_CMD_AA_1_VECTOR_NOEND_BLPO  0x0000003FL
+
+#define GDC_CMD_BLT_FILL                0x00000041L
+#define GDC_CMD_BLT_DRAW                0x00000042L
+#define GDC_CMD_BITMAP                  0x00000043L
+#define GDC_CMD_BLTCOPY_TOP_LEFT        0x00000044L
+#define GDC_CMD_BLTCOPY_TOP_RIGHT       0x00000045L
+#define GDC_CMD_BLTCOPY_BOTTOM_LEFT     0x00000046L
+#define GDC_CMD_BLTCOPY_BOTTOM_RIGHT    0x00000047L
+#define GDC_CMD_LOAD_TEXTURE            0x00000048L
+#define GDC_CMD_LOAD_TILE               0x00000049L
+
+#define GDC_CMD_TRAP_RIGHT              0x00000060L
+#define GDC_CMD_TRAP_LEFT               0x00000061L
+#define GDC_CMD_TRIANGLE_FAN            0x00000062L
+#define GDC_CMD_FLAG_TRIANGLE_FAN       0x00000063L
+
+#define GDC_CMD_FLUSH_FB                0x000000C1L
+#define GDC_CMD_FLUSH_Z                 0x000000C2L
+
+#define GDC_CMD_POLYGON_BEGIN           0x000000E0L
+#define GDC_CMD_POLYGON_END             0x000000E1L
+#define GDC_CMD_CLEAR_POLY_FLAG         0x000000E2L
+#define GDC_CMD_NORMAL                  0x000000FFL
+
+#define GDC_CMD_VECTOR_BLPO_FLAG        0x00040000L
+#define GDC_CMD_FAST_VECTOR_BLPO_FLAG   0x00000004L
+
+/* for MB86293 or later */
+#define GDC_CMD_MDR1                            0x00000000L
+#define GDC_CMD_MDR1S                           0x00000002L
+#define GDC_CMD_MDR1B                           0x00000004L
+#define GDC_CMD_MDR2                            0x00000001L
+#define GDC_CMD_MDR2S                           0x00000003L
+#define GDC_CMD_MDR2TL                          0x00000007L
+#define GDC_CMD_GMDR1E                          0x00000010L
+#define GDC_CMD_GMDR2E                          0x00000020L
+#define GDC_CMD_OVERLAP_SHADOW_XY               0x00000000L
+#define GDC_CMD_OVERLAP_SHADOW_XY_COMPOSITION   0x00000001L
+#define GDC_CMD_OVERLAP_Z_PACKED_ONBS           0x00000007L
+#define GDC_CMD_OVERLAP_Z_ORIGIN                0x00000000L
+#define GDC_CMD_OVERLAP_Z_NON_TOPLEFT           0x00000001L
+#define GDC_CMD_OVERLAP_Z_BORDER                0x00000002L
+#define GDC_CMD_OVERLAP_Z_SHADOW                0x00000003L
+#define GDC_CMD_BLTCOPY_ALT_ALPHA               0x00000000L    /* Reserverd */
+#define GDC_CMD_DC_LOGOUT                       0x00000000L    /* Reserverd */
+#define GDC_CMD_BODY_FORE_COLOR                 0x00000000L
+#define GDC_CMD_BODY_BACK_COLOR                 0x00000001L
+#define GDC_CMD_SHADOW_FORE_COLOR               0x00000002L
+#define GDC_CMD_SHADOW_BACK_COLOR               0x00000003L
+#define GDC_CMD_BORDER_FORE_COLOR               0x00000004L
+#define GDC_CMD_BORDER_BACK_COLOR               0x00000005L
+
+/* Type Code Table */
+#define GDC_TYPE_G_NOP                                  0x00000020L
+#define GDC_TYPE_G_BEGIN                                0x00000021L
+#define GDC_TYPE_G_BEGINCONT                            0x00000022L
+#define GDC_TYPE_G_END                                  0x00000023L
+#define GDC_TYPE_G_VERTEX                               0x00000030L
+#define GDC_TYPE_G_VERTEXLOG                            0x00000032L
+#define GDC_TYPE_G_VERTEXNOPLOG                         0x00000033L
+#define GDC_TYPE_G_INIT                                 0x00000040L
+#define GDC_TYPE_G_VIEWPORT                             0x00000041L
+#define GDC_TYPE_G_DEPTHRANGE                           0x00000042L
+#define GDC_TYPE_G_LOADMATRIX                           0x00000043L
+#define GDC_TYPE_G_VIEWVOLUMEXYCLIP                     0x00000044L
+#define GDC_TYPE_G_VIEWVOLUMEZCLIP                      0x00000045L
+#define GDC_TYPE_G_VIEWVOLUMEWCLIP                      0x00000046L
+#define GDC_TYPE_SETLVERTEX2I                           0x00000072L
+#define GDC_TYPE_SETLVERTEX2IP                          0x00000073L
+#define GDC_TYPE_SETMODEREGISTER                        0x000000C0L
+#define GDC_TYPE_SETGMODEREGISTER                       0x000000C1L
+#define GDC_TYPE_OVERLAPXYOFFT                          0x000000C8L
+#define GDC_TYPE_OVERLAPZOFFT                           0x000000C9L
+#define GDC_TYPE_DC_LOGOUTADDR                          0x000000CCL
+#define GDC_TYPE_SETCOLORREGISTER                       0x000000CEL
+#define GDC_TYPE_G_BEGINE                               0x000000E1L
+#define GDC_TYPE_G_BEGINCONTE                           0x000000E2L
+#define GDC_TYPE_G_ENDE                                 0x000000E3L
+#define GDC_TYPE_DRAWPIXEL                              0x00000000L
+#define GDC_TYPE_DRAWPIXELZ                             0x00000001L
+#define GDC_TYPE_DRAWLINE                               0x00000002L
+#define GDC_TYPE_DRAWLINE2I                             0x00000003L
+#define GDC_TYPE_DRAWLINE2IP                            0x00000004L
+#define GDC_TYPE_DRAWTRAP                               0x00000005L
+#define GDC_TYPE_DRAWVERTEX2I                           0x00000006L
+#define GDC_TYPE_DRAWVERTEX2IP                          0x00000007L
+#define GDC_TYPE_DRAWRECTP                              0x00000009L
+#define GDC_TYPE_DRAWBITMAPP                            0x0000000BL
+#define GDC_TYPE_BLTCOPYP                               0x0000000DL
+#define GDC_TYPE_BLTCOPYALTERNATEP                      0x0000000FL
+#define GDC_TYPE_LOADTEXTUREP                           0x00000011L
+#define GDC_TYPE_BLTTEXTUREP                            0x00000013L
+#define GDC_TYPE_BLTCOPYALTALPHABLENDP                  0x0000001FL
+#define GDC_TYPE_SETVERTEX2I                            0x00000070L
+#define GDC_TYPE_SETVERTEX2IP                           0x00000071L
+#define GDC_TYPE_DRAW                                   0x000000F0L
+#define GDC_TYPE_SETREGISTER                            0x000000F1L
+#define GDC_TYPE_SYNC                                   0x000000FCL
+#define GDC_TYPE_INTERRUPT                              0x000000FDL
+#define GDC_TYPE_NOP                                    0x0
+
+/* Raster operation */
+#define GDC_ROP_CLEAR                   0x0000
+#define GDC_ROP_AND                     0x0001
+#define GDC_ROP_AND_REVERSE             0x0002
+#define GDC_ROP_COPY                    0x0003
+#define GDC_ROP_AND_INVERTED            0x0004
+#define GDC_ROP_NOP                     0x0005
+#define GDC_ROP_XOR                     0x0006
+#define GDC_ROP_OR                      0x0007
+#define GDC_ROP_NOR                     0x0008
+#define GDC_ROP_EQUIV                   0x0009
+#define GDC_ROP_INVERT                  0x000A
+#define GDC_ROP_OR_REVERSE              0x000B
+#define GDC_ROP_COPY_INVERTED           0x000C
+#define GDC_ROP_OR_INVERTED             0x000D
+#define GDC_ROP_NAND                    0x000E
+#define GDC_ROP_SET                     0x000F
+
+#endif
index 34e4e79951696bd5ac805cb69fea5780e84018c2..0129f1bc35225da593fd2bc15ef0ceaba294f524 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 #include <linux/fb.h>
+#include <linux/kernel.h>
 
 #undef DEBUG
 
@@ -402,21 +403,6 @@ const struct fb_videomode vesa_modes[] = {
 EXPORT_SYMBOL(vesa_modes);
 #endif /* CONFIG_FB_MODE_HELPERS */
 
-static int my_atoi(const char *name)
-{
-    int val = 0;
-
-    for (;; name++) {
-       switch (*name) {
-           case '0' ... '9':
-               val = 10*val+(*name-'0');
-               break;
-           default:
-               return val;
-       }
-    }
-}
-
 /**
  *     fb_try_mode - test a video mode
  *     @var: frame buffer user defined part of display
@@ -539,7 +525,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
                    namelen = i;
                    if (!refresh_specified && !bpp_specified &&
                        !yres_specified) {
-                       refresh = my_atoi(&name[i+1]);
+                       refresh = simple_strtol(&name[i+1], NULL, 10);
                        refresh_specified = 1;
                        if (cvt || rb)
                            cvt = 0;
@@ -549,7 +535,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
                case '-':
                    namelen = i;
                    if (!bpp_specified && !yres_specified) {
-                       bpp = my_atoi(&name[i+1]);
+                       bpp = simple_strtol(&name[i+1], NULL, 10);
                        bpp_specified = 1;
                        if (cvt || rb)
                            cvt = 0;
@@ -558,7 +544,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
                    break;
                case 'x':
                    if (!yres_specified) {
-                       yres = my_atoi(&name[i+1]);
+                       yres = simple_strtol(&name[i+1], NULL, 10);
                        yres_specified = 1;
                    } else
                        goto done;
@@ -586,7 +572,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
            }
        }
        if (i < 0 && yres_specified) {
-           xres = my_atoi(name);
+           xres = simple_strtol(name, NULL, 10);
            res_specified = 1;
        }
 done:
index 5bb7f6f146010ae667a523a95515f3f816808555..0f5952cae85e6b2ddfd47ffd66ac1c0f7c88a919 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 
 #include <mach/gpio.h>
 #include <plat/mux.h>
@@ -59,7 +59,7 @@
 #define TWL4030_VPLL2_DEV_GRP           0x33
 #define TWL4030_VPLL2_DEDICATED         0x36
 
-#define t2_out(c, r, v) twl4030_i2c_write_u8(c, r, v)
+#define t2_out(c, r, v) twl_i2c_write_u8(c, r, v)
 
 
 static int ldp_panel_init(struct lcd_panel *panel,
index 006c2fe7360ee5c3ad8f2604a931f376ee61b368..7e7a65c08452d16e562ad2021197fc2bdee4c291 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 
 #include <plat/mux.h>
 #include <asm/mach-types.h>
@@ -61,9 +61,9 @@ static int omap2evm_panel_init(struct lcd_panel *panel,
        gpio_direction_output(LCD_PANEL_LR, 1);
        gpio_direction_output(LCD_PANEL_UD, 1);
 
-       twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
-       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
-       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
+       twl_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
+       twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
+       twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
        bklight_level = 100;
 
        return 0;
@@ -101,7 +101,7 @@ static int omap2evm_bklight_setlevel(struct lcd_panel *panel,
        u8 c;
        if ((level >= 0) && (level <= 100)) {
                c = (125 * (100 - level)) / 100 + 2;
-               twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
+               twl_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
                bklight_level = level;
        }
        return 0;
index fc503d8f3c24c4790de120650fd479afa7319f44..ca75cc2a87a559df36b93bbd4f495a7b013577ac 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 
 #include <plat/mux.h>
 #include <plat/mux.h>
index ae2edc4081a80f36ee793eed980f3fa27ecd517f..06840da0b0949d628e4167bbcd78daf38d2bbf1e 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 
 #include <plat/mux.h>
 #include <asm/mach-types.h>
@@ -63,9 +63,9 @@ static int omap3evm_panel_init(struct lcd_panel *panel,
        gpio_direction_output(LCD_PANEL_LR, 1);
        gpio_direction_output(LCD_PANEL_UD, 1);
 
-       twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
-       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
-       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
+       twl_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
+       twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
+       twl_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
        bklight_level = 100;
 
        return 0;
@@ -102,7 +102,7 @@ static int omap3evm_bklight_setlevel(struct lcd_panel *panel,
        u8 c;
        if ((level >= 0) && (level <= 100)) {
                c = (125 * (100 - level)) / 100 + 2;
-               twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
+               twl_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
                bklight_level = level;
        }
        return 0;
index 56ee192e9ee231357c8ba104ed5ba5b677cb1f57..564933ffac6ef73fc00b7e36bf81ca155f57d9db 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 
 #include <mach/gpio.h>
 #include <plat/mux.h>
index 5e6439ae739471386ea54fda7e603003dff8eb4f..5137aa016b833589b3ed2855daba5e076a2183d6 100644 (file)
@@ -50,7 +50,7 @@ static ssize_t video_output_store_state(struct device *dev,
        int request_state = simple_strtoul(buf,&endp,0);
        size_t size = endp - buf;
 
-       if (*endp && isspace(*endp))
+       if (isspace(*endp))
                size++;
        if (size != count)
                return -EINVAL;
index 0573ec685a57ebc73156a2d4dcab8f3e177f9ae8..0f361b6100d2b6dc671c1ff1297718e2e47735fc 100644 (file)
@@ -98,7 +98,8 @@ static int pmagbafb_setcolreg(unsigned int regno, unsigned int red,
 {
        struct pmagbafb_par *par = info->par;
 
-       BUG_ON(regno >= info->cmap.len);
+       if (regno >= info->cmap.len)
+               return 1;
 
        red   >>= 8;    /* The cmap fields are 16 bits    */
        green >>= 8;    /* wide, but the hardware colormap */
index 98748723af9f88cf5e433de72889f69e6b0f7ef0..2de0806421b49b450c5a9c73b12aceec4719f3cd 100644 (file)
@@ -102,7 +102,8 @@ static int pmagbbfb_setcolreg(unsigned int regno, unsigned int red,
 {
        struct pmagbbfb_par *par = info->par;
 
-       BUG_ON(regno >= info->cmap.len);
+       if (regno >= info->cmap.len)
+               return 1;
 
        red   >>= 8;    /* The cmap fields are 16 bits    */
        green >>= 8;    /* wide, but the hardware colormap */
index f58a3aae6ea630f931de2a2cc7118a65a0c344b3..415858b421b3591df40f1336e7080fba7e47bbe0 100644 (file)
@@ -1221,13 +1221,14 @@ static void setup_smart_timing(struct pxafb_info *fbi,
 static int pxafb_smart_thread(void *arg)
 {
        struct pxafb_info *fbi = arg;
-       struct pxafb_mach_info *inf = fbi->dev->platform_data;
+       struct pxafb_mach_info *inf;
 
-       if (!fbi || !inf->smart_update) {
+       if (!fbi || !fbi->dev->platform_data->smart_update) {
                pr_err("%s: not properly initialized, thread terminated\n",
                                __func__);
                return -EINVAL;
        }
+       inf = fbi->dev->platform_data;
 
        pr_debug("%s(): task starting\n", __func__);
 
@@ -1667,7 +1668,7 @@ static int pxafb_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops pxafb_pm_ops = {
+static const struct dev_pm_ops pxafb_pm_ops = {
        .suspend        = pxafb_suspend,
        .resume         = pxafb_resume,
 };
index b4b5de930cf528409bd71a5f36009a373fc83ed4..a69830d26f7fbdd7a050ef5daa39522b1962b60a 100644 (file)
@@ -281,6 +281,7 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info,
                                       struct list_head *pagelist)
 {
        struct sh_mobile_lcdc_chan *ch = info->par;
+       struct sh_mobile_lcdc_board_cfg *bcfg = &ch->cfg.board_cfg;
 
        /* enable clocks before accessing hardware */
        sh_mobile_lcdc_clk_on(ch->lcdc);
@@ -305,10 +306,17 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info,
 
                /* trigger panel update */
                dma_map_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE);
+               if (bcfg->start_transfer)
+                       bcfg->start_transfer(bcfg->board_data, ch,
+                                            &sh_mobile_lcdc_sys_bus_ops);
                lcdc_write_chan(ch, LDSM2R, 1);
                dma_unmap_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE);
-       } else
+       } else {
+               if (bcfg->start_transfer)
+                       bcfg->start_transfer(bcfg->board_data, ch,
+                                            &sh_mobile_lcdc_sys_bus_ops);
                lcdc_write_chan(ch, LDSM2R, 1);
+       }
 }
 
 static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info)
@@ -890,7 +898,7 @@ static int sh_mobile_lcdc_runtime_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = {
+static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = {
        .suspend = sh_mobile_lcdc_suspend,
        .resume = sh_mobile_lcdc_resume,
        .runtime_suspend = sh_mobile_lcdc_runtime_suspend,
index a4e05e4d7501256e5311a1a2fc7e808c3d05f1f5..9d2b6bc49036ee44a92d0dd1c448d975d38d0046 100644 (file)
@@ -2115,7 +2115,7 @@ sisfb_detect_VB_connect(struct sis_video_info *ivideo)
           if( (!(ivideo->vbflags2 & VB2_SISBRIDGE)) &&
               (!((ivideo->sisvga_engine == SIS_315_VGA) &&
                        (ivideo->vbflags2 & VB2_CHRONTEL))) ) {
-             if(ivideo->sisfb_tvstd & (TV_PALN | TV_PALN | TV_NTSCJ)) {
+             if(ivideo->sisfb_tvstd & (TV_PALM | TV_PALN | TV_NTSCJ)) {
                 ivideo->sisfb_tvstd = -1;
                 printk(KERN_ERR "sisfb: PALM/PALN/NTSCJ not supported\n");
              }
index 924d79462780c5eb34ee79f5dfa0fb61dec193f8..35370d0ecf037ccb92d5f9136e46f1e1f4d7e683 100644 (file)
@@ -29,8 +29,8 @@
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/console.h>
+#include <linux/io.h>
 
-#include <asm/io.h>
 #include <asm/uaccess.h>
 #include <asm/div64.h>
 
@@ -66,6 +66,7 @@ struct sm501fb_info {
        struct fb_info          *fb[2];         /* fb info for both heads */
        struct resource         *fbmem_res;     /* framebuffer resource */
        struct resource         *regs_res;      /* registers resource */
+       struct resource         *regs2d_res;    /* 2d registers resource */
        struct sm501_platdata_fb *pdata;        /* our platform data */
 
        unsigned long            pm_crt_ctrl;   /* pm: crt ctrl save */
@@ -73,6 +74,7 @@ struct sm501fb_info {
        int                      irq;
        int                      swap_endian;   /* set to swap rgb=>bgr */
        void __iomem            *regs;          /* remapped registers */
+       void __iomem            *regs2d;        /* 2d remapped registers */
        void __iomem            *fbmem;         /* remapped framebuffer */
        size_t                   fbmem_len;     /* length of remapped region */
 };
@@ -123,9 +125,9 @@ static inline void sm501fb_sync_regs(struct sm501fb_info *info)
  * This is an attempt to lay out memory for the two framebuffers and
  * everything else
  *
- * |fbmem_res->start                                          fbmem_res->end|
- * |                                                                         |
- * |fb[0].fix.smem_start    |         |fb[1].fix.smem_start    |     2K      |
+ * |fbmem_res->start                                          fbmem_res->end|
+ * |                                                                        |
+ * |fb[0].fix.smem_start    |        |fb[1].fix.smem_start    |     2K      |
  * |-> fb[0].fix.smem_len <-| spare   |-> fb[1].fix.smem_len <-|-> cursors <-|
  *
  * The "spare" space is for the 2d engine data
@@ -1246,7 +1248,173 @@ static ssize_t sm501fb_debug_show_pnl(struct device *dev,
 
 static DEVICE_ATTR(fbregs_pnl, 0444, sm501fb_debug_show_pnl, NULL);
 
-/* framebuffer ops */
+/* acceleration operations */
+static int sm501fb_sync(struct fb_info *info)
+{
+       int count = 1000000;
+       struct sm501fb_par  *par = info->par;
+       struct sm501fb_info *fbi = par->info;
+
+       /* wait for the 2d engine to be ready */
+       while ((count > 0) &&
+              (readl(fbi->regs + SM501_SYSTEM_CONTROL) &
+               SM501_SYSCTRL_2D_ENGINE_STATUS) != 0)
+               count--;
+
+       if (count <= 0) {
+               dev_err(info->dev, "Timeout waiting for 2d engine sync\n");
+               return 1;
+       }
+       return 0;
+}
+
+static void sm501fb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
+{
+       struct sm501fb_par  *par = info->par;
+       struct sm501fb_info *fbi = par->info;
+       int width = area->width;
+       int height = area->height;
+       int sx = area->sx;
+       int sy = area->sy;
+       int dx = area->dx;
+       int dy = area->dy;
+       unsigned long rtl = 0;
+
+       /* source clip */
+       if ((sx >= info->var.xres_virtual) ||
+           (sy >= info->var.yres_virtual))
+               /* source Area not within virtual screen, skipping */
+               return;
+       if ((sx + width) >= info->var.xres_virtual)
+               width = info->var.xres_virtual - sx - 1;
+       if ((sy + height) >= info->var.yres_virtual)
+               height = info->var.yres_virtual - sy - 1;
+
+       /* dest clip */
+       if ((dx >= info->var.xres_virtual) ||
+           (dy >= info->var.yres_virtual))
+               /* Destination Area not within virtual screen, skipping */
+               return;
+       if ((dx + width) >= info->var.xres_virtual)
+               width = info->var.xres_virtual - dx - 1;
+       if ((dy + height) >= info->var.yres_virtual)
+               height = info->var.yres_virtual - dy - 1;
+
+       if ((sx < dx) || (sy < dy)) {
+               rtl = 1 << 27;
+               sx += width - 1;
+               dx += width - 1;
+               sy += height - 1;
+               dy += height - 1;
+       }
+
+       if (sm501fb_sync(info))
+               return;
+
+       /* set the base addresses */
+       writel(par->screen.sm_addr, fbi->regs2d + SM501_2D_SOURCE_BASE);
+       writel(par->screen.sm_addr, fbi->regs2d + SM501_2D_DESTINATION_BASE);
+
+       /* set the window width */
+       writel((info->var.xres << 16) | info->var.xres,
+              fbi->regs2d + SM501_2D_WINDOW_WIDTH);
+
+       /* set window stride */
+       writel((info->var.xres_virtual << 16) | info->var.xres_virtual,
+              fbi->regs2d + SM501_2D_PITCH);
+
+       /* set data format */
+       switch (info->var.bits_per_pixel) {
+       case 8:
+               writel(0, fbi->regs2d + SM501_2D_STRETCH);
+               break;
+       case 16:
+               writel(0x00100000, fbi->regs2d + SM501_2D_STRETCH);
+               break;
+       case 32:
+               writel(0x00200000, fbi->regs2d + SM501_2D_STRETCH);
+               break;
+       }
+
+       /* 2d compare mask */
+       writel(0xffffffff, fbi->regs2d + SM501_2D_COLOR_COMPARE_MASK);
+
+       /* 2d mask */
+       writel(0xffffffff, fbi->regs2d + SM501_2D_MASK);
+
+       /* source and destination x y */
+       writel((sx << 16) | sy, fbi->regs2d + SM501_2D_SOURCE);
+       writel((dx << 16) | dy, fbi->regs2d + SM501_2D_DESTINATION);
+
+       /* w/h */
+       writel((width << 16) | height, fbi->regs2d + SM501_2D_DIMENSION);
+
+       /* do area move */
+       writel(0x800000cc | rtl, fbi->regs2d + SM501_2D_CONTROL);
+}
+
+static void sm501fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
+{
+       struct sm501fb_par  *par = info->par;
+       struct sm501fb_info *fbi = par->info;
+       int width = rect->width, height = rect->height;
+
+       if ((rect->dx >= info->var.xres_virtual) ||
+           (rect->dy >= info->var.yres_virtual))
+               /* Rectangle not within virtual screen, skipping */
+               return;
+       if ((rect->dx + width) >= info->var.xres_virtual)
+               width = info->var.xres_virtual - rect->dx - 1;
+       if ((rect->dy + height) >= info->var.yres_virtual)
+               height = info->var.yres_virtual - rect->dy - 1;
+
+       if (sm501fb_sync(info))
+               return;
+
+       /* set the base addresses */
+       writel(par->screen.sm_addr, fbi->regs2d + SM501_2D_SOURCE_BASE);
+       writel(par->screen.sm_addr, fbi->regs2d + SM501_2D_DESTINATION_BASE);
+
+       /* set the window width */
+       writel((info->var.xres << 16) | info->var.xres,
+              fbi->regs2d + SM501_2D_WINDOW_WIDTH);
+
+       /* set window stride */
+       writel((info->var.xres_virtual << 16) | info->var.xres_virtual,
+              fbi->regs2d + SM501_2D_PITCH);
+
+       /* set data format */
+       switch (info->var.bits_per_pixel) {
+       case 8:
+               writel(0, fbi->regs2d + SM501_2D_STRETCH);
+               break;
+       case 16:
+               writel(0x00100000, fbi->regs2d + SM501_2D_STRETCH);
+               break;
+       case 32:
+               writel(0x00200000, fbi->regs2d + SM501_2D_STRETCH);
+               break;
+       }
+
+       /* 2d compare mask */
+       writel(0xffffffff, fbi->regs2d + SM501_2D_COLOR_COMPARE_MASK);
+
+       /* 2d mask */
+       writel(0xffffffff, fbi->regs2d + SM501_2D_MASK);
+
+       /* colour */
+       writel(rect->color, fbi->regs2d + SM501_2D_FOREGROUND);
+
+       /* x y */
+       writel((rect->dx << 16) | rect->dy, fbi->regs2d + SM501_2D_DESTINATION);
+
+       /* w/h */
+       writel((width << 16) | height, fbi->regs2d + SM501_2D_DIMENSION);
+
+       /* do rectangle fill */
+       writel(0x800100cc, fbi->regs2d + SM501_2D_CONTROL);
+}
+
 
 static struct fb_ops sm501fb_ops_crt = {
        .owner          = THIS_MODULE,
@@ -1256,9 +1424,10 @@ static struct fb_ops sm501fb_ops_crt = {
        .fb_setcolreg   = sm501fb_setcolreg,
        .fb_pan_display = sm501fb_pan_crt,
        .fb_cursor      = sm501fb_cursor,
-       .fb_fillrect    = cfb_fillrect,
-       .fb_copyarea    = cfb_copyarea,
+       .fb_fillrect    = sm501fb_fillrect,
+       .fb_copyarea    = sm501fb_copyarea,
        .fb_imageblit   = cfb_imageblit,
+       .fb_sync        = sm501fb_sync,
 };
 
 static struct fb_ops sm501fb_ops_pnl = {
@@ -1269,9 +1438,10 @@ static struct fb_ops sm501fb_ops_pnl = {
        .fb_blank       = sm501fb_blank_pnl,
        .fb_setcolreg   = sm501fb_setcolreg,
        .fb_cursor      = sm501fb_cursor,
-       .fb_fillrect    = cfb_fillrect,
-       .fb_copyarea    = cfb_copyarea,
+       .fb_fillrect    = sm501fb_fillrect,
+       .fb_copyarea    = sm501fb_copyarea,
        .fb_imageblit   = cfb_imageblit,
+       .fb_sync        = sm501fb_sync,
 };
 
 /* sm501_init_cursor
@@ -1329,7 +1499,8 @@ static int sm501fb_start(struct sm501fb_info *info,
                dev_warn(dev, "no irq for device\n");
        }
 
-       /* allocate, reserve and remap resources for registers */
+       /* allocate, reserve and remap resources for display
+        * controller registers */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (res == NULL) {
                dev_err(dev, "no resource definition for registers\n");
@@ -1338,7 +1509,7 @@ static int sm501fb_start(struct sm501fb_info *info,
        }
 
        info->regs_res = request_mem_region(res->start,
-                                           res->end - res->start,
+                                           resource_size(res),
                                            pdev->name);
 
        if (info->regs_res == NULL) {
@@ -1347,37 +1518,63 @@ static int sm501fb_start(struct sm501fb_info *info,
                goto err_release;
        }
 
-       info->regs = ioremap(res->start, (res->end - res->start)+1);
+       info->regs = ioremap(res->start, resource_size(res));
        if (info->regs == NULL) {
                dev_err(dev, "cannot remap registers\n");
                ret = -ENXIO;
                goto err_regs_res;
        }
 
+       /* allocate, reserve and remap resources for 2d
+        * controller registers */
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+       if (res == NULL) {
+               dev_err(dev, "no resource definition for 2d registers\n");
+               ret = -ENOENT;
+               goto err_regs_map;
+       }
+
+       info->regs2d_res = request_mem_region(res->start,
+                                             resource_size(res),
+                                             pdev->name);
+
+       if (info->regs2d_res == NULL) {
+               dev_err(dev, "cannot claim registers\n");
+               ret = -ENXIO;
+               goto err_regs_map;
+       }
+
+       info->regs2d = ioremap(res->start, resource_size(res));
+       if (info->regs2d == NULL) {
+               dev_err(dev, "cannot remap registers\n");
+               ret = -ENXIO;
+               goto err_regs2d_res;
+       }
+
        /* allocate, reserve resources for framebuffer */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
        if (res == NULL) {
                dev_err(dev, "no memory resource defined\n");
                ret = -ENXIO;
-               goto err_regs_map;
+               goto err_regs2d_map;
        }
 
        info->fbmem_res = request_mem_region(res->start,
-                                            (res->end - res->start)+1,
+                                            resource_size(res),
                                             pdev->name);
        if (info->fbmem_res == NULL) {
                dev_err(dev, "cannot claim framebuffer\n");
                ret = -ENXIO;
-               goto err_regs_map;
+               goto err_regs2d_map;
        }
 
-       info->fbmem = ioremap(res->start, (res->end - res->start)+1);
+       info->fbmem = ioremap(res->start, resource_size(res));
        if (info->fbmem == NULL) {
                dev_err(dev, "cannot remap framebuffer\n");
                goto err_mem_res;
        }
 
-       info->fbmem_len = (res->end - res->start)+1;
+       info->fbmem_len = resource_size(res);
 
        /* clear framebuffer memory - avoids garbage data on unused fb */
        memset(info->fbmem, 0, info->fbmem_len);
@@ -1389,8 +1586,10 @@ static int sm501fb_start(struct sm501fb_info *info,
        /* enable display controller */
        sm501_unit_power(dev->parent, SM501_GATE_DISPLAY, 1);
 
-       /* setup cursors */
+       /* enable 2d controller */
+       sm501_unit_power(dev->parent, SM501_GATE_2D_ENGINE, 1);
 
+       /* setup cursors */
        sm501_init_cursor(info->fb[HEAD_CRT], SM501_DC_CRT_HWC_ADDR);
        sm501_init_cursor(info->fb[HEAD_PANEL], SM501_DC_PANEL_HWC_ADDR);
 
@@ -1400,6 +1599,13 @@ static int sm501fb_start(struct sm501fb_info *info,
        release_resource(info->fbmem_res);
        kfree(info->fbmem_res);
 
+ err_regs2d_map:
+       iounmap(info->regs2d);
+
+ err_regs2d_res:
+       release_resource(info->regs2d_res);
+       kfree(info->regs2d_res);
+
  err_regs_map:
        iounmap(info->regs);
 
@@ -1420,6 +1626,10 @@ static void sm501fb_stop(struct sm501fb_info *info)
        release_resource(info->fbmem_res);
        kfree(info->fbmem_res);
 
+       iounmap(info->regs2d);
+       release_resource(info->regs2d_res);
+       kfree(info->regs2d_res);
+
        iounmap(info->regs);
        release_resource(info->regs_res);
        kfree(info->regs_res);
@@ -1486,7 +1696,8 @@ static int sm501fb_init_fb(struct fb_info *fb,
                par->ops.fb_cursor = NULL;
 
        fb->fbops = &par->ops;
-       fb->flags = FBINFO_FLAG_DEFAULT |
+       fb->flags = FBINFO_FLAG_DEFAULT | FBINFO_READS_FAST |
+               FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT |
                FBINFO_HWACCEL_XPAN | FBINFO_HWACCEL_YPAN;
 
        /* fixed data */
index e3e597f937a532927f19d1b4b8b635f765ffa691..09353e2b92f665561fd8328572167de157531227 100644 (file)
@@ -1134,45 +1134,33 @@ static void integrated_lvds_enable(struct lvds_setting_information
                            *plvds_setting_info,
                            struct lvds_chip_information *plvds_chip_info)
 {
-       bool turn_on_first_powersequence = false;
-       bool turn_on_second_powersequence = false;
-
        DEBUG_MSG(KERN_INFO "integrated_lvds_enable, out_interface:%d\n",
                  plvds_chip_info->output_interface);
        if (plvds_setting_info->lcd_mode == LCD_SPWG)
                viafb_write_reg_mask(CRD2, VIACR, 0x00, BIT0 + BIT1);
-        else
+       else
                viafb_write_reg_mask(CRD2, VIACR, 0x03, BIT0 + BIT1);
-       if (INTERFACE_LVDS0LVDS1 == plvds_chip_info->output_interface)
-               turn_on_first_powersequence = true;
-       if (INTERFACE_LVDS0 == plvds_chip_info->output_interface)
-               turn_on_first_powersequence = true;
-       if (INTERFACE_LVDS1 == plvds_chip_info->output_interface)
-               turn_on_second_powersequence = true;
-
-       if (turn_on_second_powersequence) {
-               /* Use second power sequence control: */
-
-               /* Use hardware control power sequence. */
-               viafb_write_reg_mask(CRD3, VIACR, 0, BIT0);
-
-               /* Turn on back light. */
-               viafb_write_reg_mask(CRD3, VIACR, 0, BIT6 + BIT7);
 
-               /* Turn on hardware power sequence. */
-               viafb_write_reg_mask(CRD4, VIACR, 0x02, BIT1);
-       }
-       if (turn_on_first_powersequence) {
+       switch (plvds_chip_info->output_interface) {
+       case INTERFACE_LVDS0LVDS1:
+       case INTERFACE_LVDS0:
                /* Use first power sequence control: */
-
                /* Use hardware control power sequence. */
                viafb_write_reg_mask(CR91, VIACR, 0, BIT0);
-
                /* Turn on back light. */
                viafb_write_reg_mask(CR91, VIACR, 0, BIT6 + BIT7);
-
                /* Turn on hardware power sequence. */
                viafb_write_reg_mask(CR6A, VIACR, 0x08, BIT3);
+               break;
+       case INTERFACE_LVDS1:
+               /* Use second power sequence control: */
+               /* Use hardware control power sequence. */
+               viafb_write_reg_mask(CRD3, VIACR, 0, BIT0);
+               /* Turn on back light. */
+               viafb_write_reg_mask(CRD3, VIACR, 0, BIT6 + BIT7);
+               /* Turn on hardware power sequence. */
+               viafb_write_reg_mask(CRD4, VIACR, 0x02, BIT1);
+               break;
        }
 
        /* Turn DFP High/Low pad on. */
index 56ec696e8afa504af10d58b2413e79b5c2240e83..d8df17a7d5fce50a0f2566f5ee06713eb0ae96bd 100644 (file)
@@ -680,7 +680,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
                if (!viafb_gamma_table)
                        return -ENOMEM;
                if (copy_from_user(viafb_gamma_table, argp,
-                               sizeof(viafb_gamma_table))) {
+                               256 * sizeof(u32))) {
                        kfree(viafb_gamma_table);
                        return -EFAULT;
                }
@@ -694,7 +694,7 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
                        return -ENOMEM;
                viafb_get_gamma_table(viafb_gamma_table);
                if (copy_to_user(argp, viafb_gamma_table,
-                       sizeof(viafb_gamma_table))) {
+                       256 * sizeof(u32))) {
                        kfree(viafb_gamma_table);
                        return -EFAULT;
                }
@@ -1797,7 +1797,7 @@ static const struct file_operations viafb_vt1636_proc_fops = {
 static void viafb_init_proc(struct proc_dir_entry **viafb_entry)
 {
        *viafb_entry = proc_mkdir("viafb", NULL);
-       if (viafb_entry) {
+       if (*viafb_entry) {
                proc_create("dvp0", 0, *viafb_entry, &viafb_dvp0_proc_fops);
                proc_create("dvp1", 0, *viafb_entry, &viafb_dvp1_proc_fops);
                proc_create("dfph", 0, *viafb_entry, &viafb_dfph_proc_fops);
index d958b76430a2414bd22958090a57f32af6539b96..088f32f29a6e9fa9b1563b765394539537c5ba30 100644 (file)
@@ -368,7 +368,7 @@ config ALIM7101_WDT
 
 config GEODE_WDT
        tristate "AMD Geode CS5535/CS5536 Watchdog"
-       depends on MGEODE_LX
+       depends on CS5535_MFGPT
        help
          This driver enables a watchdog capability built into the
          CS5535/CS5536 companion chips for the AMD Geode GX and LX
@@ -815,16 +815,6 @@ config PNX833X_WDT
          timer has expired and no process has written to /dev/watchdog during
          that time.
 
-config WDT_RM9K_GPI
-       tristate "RM9000/GPI hardware watchdog"
-       depends on CPU_RM9000
-       help
-         Watchdog implementation using the GPI hardware found on
-         PMC-Sierra RM9xxx CPUs.
-
-         To compile this driver as a module, choose M here: the
-         module will be called rm9k_wdt.
-
 config SIBYTE_WDOG
        tristate "Sibyte SoC hardware watchdog"
        depends on CPU_SB1
index 89c045dc468e388e3a336508a7ab652be4405c2a..475c61100069e2c60d20ddfb44769cda5f1506dc 100644 (file)
@@ -109,7 +109,6 @@ obj-$(CONFIG_RC32434_WDT) += rc32434_wdt.o
 obj-$(CONFIG_INDYDOG) += indydog.o
 obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o
 obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o
-obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o
 obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o
 obj-$(CONFIG_AR7_WDT) += ar7_wdt.o
 obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
index 77afb0acc50045a88a55282e8009f6b2ddd827d2..9d7d155364f8950f09d581135a94d7794f006558 100644 (file)
@@ -242,14 +242,14 @@ static int __devinit adx_wdt_probe(struct platform_device *pdev)
        }
 
        res = devm_request_mem_region(&pdev->dev, res->start,
-                       res->end - res->start + 1, res->name);
+                       resource_size(res), res->name);
        if (!res) {
                dev_err(&pdev->dev, "cannot request I/O memory region\n");
                return -ENXIO;
        }
 
        wdt->base = devm_ioremap_nocache(&pdev->dev, res->start,
-                       res->end - res->start + 1);
+                       resource_size(res));
        if (!wdt->base) {
                dev_err(&pdev->dev, "cannot remap I/O memory region\n");
                return -ENXIO;
@@ -314,7 +314,7 @@ static int adx_wdt_resume(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops adx_wdt_pm_ops = {
+static const struct dev_pm_ops adx_wdt_pm_ops = {
        .suspend = adx_wdt_suspend,
        .resume = adx_wdt_resume,
 };
index e8ae638e5804ceb600acce099555127161848191..037847923dcb46d26c610cf07f8cb7a9e5c11259 100644 (file)
@@ -326,7 +326,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       wdt->regs = ioremap(regs->start, regs->end - regs->start + 1);
+       wdt->regs = ioremap(regs->start, resource_size(regs));
        if (!wdt->regs) {
                ret = -ENOMEM;
                dev_dbg(&pdev->dev, "could not map I/O memory\n");
index 9d7520fa9e9cc171900444d96ed9ac3128960e5a..887136de18573fe98ca559f7196a4b6dd291818a 100644 (file)
@@ -221,7 +221,7 @@ static int __devinit davinci_wdt_probe(struct platform_device *pdev)
                return -ENOENT;
        }
 
-       size = res->end - res->start + 1;
+       size = resource_size(res);
        wdt_mem = request_mem_region(res->start, size, pdev->name);
 
        if (wdt_mem == NULL) {
index 9acf0015a1e747131cbc20d42527a8ccc629b867..38252ff828ca54e3e86340d741e60fe28d588d35 100644 (file)
@@ -1,6 +1,7 @@
-/* Watchdog timer for the Geode GX/LX with the CS5535/CS5536 companion chip
+/* Watchdog timer for machines with the CS5535/CS5536 companion chip
  *
  * Copyright (C) 2006-2007, Advanced Micro Devices, Inc.
+ * Copyright (C) 2009  Andres Salomon <dilinger@collabora.co.uk>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -19,7 +20,7 @@
 #include <linux/reboot.h>
 #include <linux/uaccess.h>
 
-#include <asm/geode.h>
+#include <linux/cs5535.h>
 
 #define GEODEWDT_HZ 500
 #define GEODEWDT_SCALE 6
@@ -46,25 +47,25 @@ MODULE_PARM_DESC(nowayout,
 
 static struct platform_device *geodewdt_platform_device;
 static unsigned long wdt_flags;
-static int wdt_timer;
+static struct cs5535_mfgpt_timer *wdt_timer;
 static int safe_close;
 
 static void geodewdt_ping(void)
 {
        /* Stop the counter */
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, 0);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, 0);
 
        /* Reset the counter */
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_COUNTER, 0);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_COUNTER, 0);
 
        /* Enable the counter */
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, MFGPT_SETUP_CNTEN);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, MFGPT_SETUP_CNTEN);
 }
 
 static void geodewdt_disable(void)
 {
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, 0);
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_COUNTER, 0);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, 0);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_COUNTER, 0);
 }
 
 static int geodewdt_set_heartbeat(int val)
@@ -72,10 +73,10 @@ static int geodewdt_set_heartbeat(int val)
        if (val < 1 || val > GEODEWDT_MAX_SECONDS)
                return -EINVAL;
 
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, 0);
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_CMP2, val * GEODEWDT_HZ);
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_COUNTER, 0);
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, MFGPT_SETUP_CNTEN);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, 0);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_CMP2, val * GEODEWDT_HZ);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_COUNTER, 0);
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_SETUP, MFGPT_SETUP_CNTEN);
 
        timeout = val;
        return 0;
@@ -215,28 +216,25 @@ static struct miscdevice geodewdt_miscdev = {
 
 static int __devinit geodewdt_probe(struct platform_device *dev)
 {
-       int ret, timer;
-
-       timer = geode_mfgpt_alloc_timer(MFGPT_TIMER_ANY, MFGPT_DOMAIN_WORKING);
+       int ret;
 
-       if (timer == -1) {
+       wdt_timer = cs5535_mfgpt_alloc_timer(MFGPT_TIMER_ANY, MFGPT_DOMAIN_WORKING);
+       if (!wdt_timer) {
                printk(KERN_ERR "geodewdt:  No timers were available\n");
                return -ENODEV;
        }
 
-       wdt_timer = timer;
-
        /* Set up the timer */
 
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_SETUP,
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_SETUP,
                          GEODEWDT_SCALE | (3 << 8));
 
        /* Set up comparator 2 to reset when the event fires */
-       geode_mfgpt_toggle_event(wdt_timer, MFGPT_CMP2, MFGPT_EVENT_RESET, 1);
+       cs5535_mfgpt_toggle_event(wdt_timer, MFGPT_CMP2, MFGPT_EVENT_RESET, 1);
 
        /* Set up the initial timeout */
 
-       geode_mfgpt_write(wdt_timer, MFGPT_REG_CMP2,
+       cs5535_mfgpt_write(wdt_timer, MFGPT_REG_CMP2,
                timeout * GEODEWDT_HZ);
 
        ret = misc_register(&geodewdt_miscdev);
index e44fbb31bc6faa1a24582475b4ee82b64a4f1339..c8a3bec26830ae73416b03e24d5f90edc0d84646 100644 (file)
@@ -30,6 +30,7 @@
  *     document number 316972-004, 316973-012: 82801I (ICH9)
  *     document number 319973-002, 319974-002: 82801J (ICH10)
  *     document number 322169-001, 322170-001: 5 Series, 3400 Series (PCH)
+ *     document number 320066-003, 320257-008: EP80597 (IICH)
  */
 
 /*
@@ -100,6 +101,7 @@ enum iTCO_chipsets {
        TCO_PCH,        /* PCH Desktop Full Featured */
        TCO_PCHM,       /* PCH Mobile Full Featured */
        TCO_PCHMSFF,    /* PCH Mobile SFF Full Featured */
+       TCO_EP80579,    /* EP80579 */
 };
 
 static struct {
@@ -143,6 +145,7 @@ static struct {
        {"PCH Desktop Full Featured", 2},
        {"PCH Mobile Full Featured", 2},
        {"PCH Mobile SFF Full Featured", 2},
+       {"EP80579", 2},
        {NULL, 0}
 };
 
@@ -214,6 +217,7 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = {
        { ITCO_PCI_DEVICE(0x3b00,                               TCO_PCH)},
        { ITCO_PCI_DEVICE(0x3b01,                               TCO_PCHM)},
        { ITCO_PCI_DEVICE(0x3b0d,                               TCO_PCHMSFF)},
+       { ITCO_PCI_DEVICE(0x5031,                               TCO_EP80579)},
        { 0, },                 /* End of list */
 };
 MODULE_DEVICE_TABLE(pci, iTCO_wdt_pci_tbl);
index 83fa34b214b41fd2b854219433793ba598055971..a2dc07c2ed49c6f15bc539d7097dfce1d9bdffdd 100644 (file)
@@ -350,7 +350,7 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev)
                ret = -ENXIO;
                goto err_free;
        }
-       wdt->base = ioremap(res->start, res->end - res->start + 1);
+       wdt->base = ioremap(res->start, resource_size(res));
        if (!wdt->base) {
                ret = -ENOMEM;
                goto err_free;
index acf589dc057ce4bfc7fc68037bce4da4ce4c12b0..a51dbe4c43da71da2591750a6081a0e7473c4f98 100644 (file)
@@ -275,7 +275,7 @@ static int __devinit mv64x60_wdt_probe(struct platform_device *dev)
        if (!r)
                return -ENODEV;
 
-       mv64x60_wdt_regs = ioremap(r->start, r->end - r->start + 1);
+       mv64x60_wdt_regs = ioremap(r->start, resource_size(r));
        if (mv64x60_wdt_regs == NULL)
                return -ENOMEM;
 
index 429ea99eaee54c11d4f77f875fc40ffe18454e74..c6aaf2845741379a69235ccc069cc8589600cbf0 100644 (file)
@@ -277,8 +277,7 @@ static int __devinit omap_wdt_probe(struct platform_device *pdev)
                goto err_busy;
        }
 
-       mem = request_mem_region(res->start, res->end - res->start + 1,
-                                pdev->name);
+       mem = request_mem_region(res->start, resource_size(res), pdev->name);
        if (!mem) {
                ret = -EBUSY;
                goto err_busy;
@@ -306,7 +305,7 @@ static int __devinit omap_wdt_probe(struct platform_device *pdev)
                goto err_clk;
        }
 
-       wdev->base = ioremap(res->start, res->end - res->start + 1);
+       wdev->base = ioremap(res->start, resource_size(res));
        if (!wdev->base) {
                ret = -ENOMEM;
                goto err_ioremap;
@@ -358,7 +357,7 @@ err_clk:
        kfree(wdev);
 
 err_kzalloc:
-       release_mem_region(res->start, res->end - res->start + 1);
+       release_mem_region(res->start, resource_size(res));
 
 err_busy:
 err_get_resource:
@@ -383,7 +382,7 @@ static int __devexit omap_wdt_remove(struct platform_device *pdev)
                return -ENOENT;
 
        misc_deregister(&(wdev->omap_wdt_miscdev));
-       release_mem_region(res->start, res->end - res->start + 1);
+       release_mem_region(res->start, resource_size(res));
        platform_set_drvdata(pdev, NULL);
 
        clk_put(wdev->ick);
index 4d227b15200118468be1a355f37ba8e1cc28adf0..430a5848a9a5d40a6bb1aeb770c76e26df357be2 100644 (file)
@@ -264,7 +264,7 @@ static int __devinit pnx4008_wdt_probe(struct platform_device *pdev)
                return -ENOENT;
        }
 
-       size = res->end - res->start + 1;
+       size = resource_size(res);
        wdt_mem = request_mem_region(res->start, size, pdev->name);
 
        if (wdt_mem == NULL) {
diff --git a/drivers/watchdog/rm9k_wdt.c b/drivers/watchdog/rm9k_wdt.c
deleted file mode 100644 (file)
index bb66958..0000000
+++ /dev/null
@@ -1,419 +0,0 @@
-/*
- *  Watchdog implementation for GPI h/w found on PMC-Sierra RM9xxx
- *  chips.
- *
- *  Copyright (C) 2004 by Basler Vision Technologies AG
- *  Author: Thomas Koeller <thomas.koeller@baslerweb.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <linux/platform_device.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/interrupt.h>
-#include <linux/fs.h>
-#include <linux/reboot.h>
-#include <linux/notifier.h>
-#include <linux/miscdevice.h>
-#include <linux/watchdog.h>
-#include <linux/io.h>
-#include <linux/uaccess.h>
-#include <asm/atomic.h>
-#include <asm/processor.h>
-#include <asm/system.h>
-#include <asm/rm9k-ocd.h>
-
-#include <rm9k_wdt.h>
-
-
-#define CLOCK                  125000000
-#define MAX_TIMEOUT_SECONDS    32
-#define CPCCR                  0x0080
-#define CPGIG1SR               0x0044
-#define CPGIG1ER               0x0054
-
-
-/* Function prototypes */
-static irqreturn_t wdt_gpi_irqhdl(int, void *);
-static void wdt_gpi_start(void);
-static void wdt_gpi_stop(void);
-static void wdt_gpi_set_timeout(unsigned int);
-static int wdt_gpi_open(struct inode *, struct file *);
-static int wdt_gpi_release(struct inode *, struct file *);
-static ssize_t wdt_gpi_write(struct file *, const char __user *, size_t,
-                                                               loff_t *);
-static long wdt_gpi_ioctl(struct file *, unsigned int, unsigned long);
-static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *);
-static const struct resource *wdt_gpi_get_resource(struct platform_device *,
-                                               const char *, unsigned int);
-static int __init wdt_gpi_probe(struct platform_device *);
-static int __exit wdt_gpi_remove(struct platform_device *);
-
-
-static const char wdt_gpi_name[] = "wdt_gpi";
-static atomic_t opencnt;
-static int expect_close;
-static int locked;
-
-
-/* These are set from device resources */
-static void __iomem *wd_regs;
-static unsigned int wd_irq, wd_ctr;
-
-
-/* Module arguments */
-static int timeout = MAX_TIMEOUT_SECONDS;
-module_param(timeout, int, 0444);
-MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds");
-
-static unsigned long resetaddr = 0xbffdc200;
-module_param(resetaddr, ulong, 0444);
-MODULE_PARM_DESC(resetaddr, "Address to write to to force a reset");
-
-static unsigned long flagaddr = 0xbffdc104;
-module_param(flagaddr, ulong, 0444);
-MODULE_PARM_DESC(flagaddr, "Address to write to boot flags to");
-
-static int powercycle;
-module_param(powercycle, bool, 0444);
-MODULE_PARM_DESC(powercycle, "Cycle power if watchdog expires");
-
-static int nowayout = WATCHDOG_NOWAYOUT;
-module_param(nowayout, bool, 0444);
-MODULE_PARM_DESC(nowayout, "Watchdog cannot be disabled once started");
-
-
-/* Kernel interfaces */
-static const struct file_operations fops = {
-       .owner          = THIS_MODULE,
-       .open           = wdt_gpi_open,
-       .release        = wdt_gpi_release,
-       .write          = wdt_gpi_write,
-       .unlocked_ioctl = wdt_gpi_ioctl,
-};
-
-static struct miscdevice miscdev = {
-       .minor          = WATCHDOG_MINOR,
-       .name           = wdt_gpi_name,
-       .fops           = &fops,
-};
-
-static struct notifier_block wdt_gpi_shutdown = {
-       .notifier_call  = wdt_gpi_notify,
-};
-
-
-/* Interrupt handler */
-static irqreturn_t wdt_gpi_irqhdl(int irq, void *ctxt)
-{
-       if (!unlikely(__raw_readl(wd_regs + 0x0008) & 0x1))
-               return IRQ_NONE;
-       __raw_writel(0x1, wd_regs + 0x0008);
-
-
-       printk(KERN_CRIT "%s: watchdog expired - resetting system\n",
-               wdt_gpi_name);
-
-       *(volatile char *) flagaddr |= 0x01;
-       *(volatile char *) resetaddr = powercycle ? 0x01 : 0x2;
-       iob();
-       while (1)
-               cpu_relax();
-}
-
-
-/* Watchdog functions */
-static void wdt_gpi_start(void)
-{
-       u32 reg;
-
-       lock_titan_regs();
-       reg = titan_readl(CPGIG1ER);
-       titan_writel(reg | (0x100 << wd_ctr), CPGIG1ER);
-       iob();
-       unlock_titan_regs();
-}
-
-static void wdt_gpi_stop(void)
-{
-       u32 reg;
-
-       lock_titan_regs();
-       reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
-       titan_writel(reg, CPCCR);
-       reg = titan_readl(CPGIG1ER);
-       titan_writel(reg & ~(0x100 << wd_ctr), CPGIG1ER);
-       iob();
-       unlock_titan_regs();
-}
-
-static void wdt_gpi_set_timeout(unsigned int to)
-{
-       u32 reg;
-       const u32 wdval = (to * CLOCK) & ~0x0000000f;
-
-       lock_titan_regs();
-       reg = titan_readl(CPCCR) & ~(0xf << (wd_ctr * 4));
-       titan_writel(reg, CPCCR);
-       wmb();
-       __raw_writel(wdval, wd_regs + 0x0000);
-       wmb();
-       titan_writel(reg | (0x2 << (wd_ctr * 4)), CPCCR);
-       wmb();
-       titan_writel(reg | (0x5 << (wd_ctr * 4)), CPCCR);
-       iob();
-       unlock_titan_regs();
-}
-
-
-/* /dev/watchdog operations */
-static int wdt_gpi_open(struct inode *inode, struct file *file)
-{
-       int res;
-
-       if (unlikely(atomic_dec_if_positive(&opencnt) < 0))
-               return -EBUSY;
-
-       expect_close = 0;
-       if (locked) {
-               module_put(THIS_MODULE);
-               free_irq(wd_irq, &miscdev);
-               locked = 0;
-       }
-
-       res = request_irq(wd_irq, wdt_gpi_irqhdl, IRQF_SHARED | IRQF_DISABLED,
-                         wdt_gpi_name, &miscdev);
-       if (unlikely(res))
-               return res;
-
-       wdt_gpi_set_timeout(timeout);
-       wdt_gpi_start();
-
-       printk(KERN_INFO "%s: watchdog started, timeout = %u seconds\n",
-               wdt_gpi_name, timeout);
-       return nonseekable_open(inode, file);
-}
-
-static int wdt_gpi_release(struct inode *inode, struct file *file)
-{
-       if (nowayout) {
-               printk(KERN_INFO "%s: no way out - watchdog left running\n",
-                       wdt_gpi_name);
-               __module_get(THIS_MODULE);
-               locked = 1;
-       } else {
-               if (expect_close) {
-                       wdt_gpi_stop();
-                       free_irq(wd_irq, &miscdev);
-                       printk(KERN_INFO "%s: watchdog stopped\n",
-                                                       wdt_gpi_name);
-               } else {
-                       printk(KERN_CRIT "%s: unexpected close() -"
-                               " watchdog left running\n",
-                               wdt_gpi_name);
-                       wdt_gpi_set_timeout(timeout);
-                       __module_get(THIS_MODULE);
-                       locked = 1;
-               }
-       }
-
-       atomic_inc(&opencnt);
-       return 0;
-}
-
-static ssize_t wdt_gpi_write(struct file *f, const char __user *d, size_t s,
-                                                               loff_t *o)
-{
-       char val;
-
-       wdt_gpi_set_timeout(timeout);
-       expect_close = (s > 0) && !get_user(val, d) && (val == 'V');
-       return s ? 1 : 0;
-}
-
-static long wdt_gpi_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
-{
-       long res = -ENOTTY;
-       const long size = _IOC_SIZE(cmd);
-       int stat;
-       void __user *argp = (void __user *)arg;
-       static struct watchdog_info wdinfo = {
-               .identity               = "RM9xxx/GPI watchdog",
-               .firmware_version       = 0,
-               .options                = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING
-       };
-
-       if (unlikely(_IOC_TYPE(cmd) != WATCHDOG_IOCTL_BASE))
-               return -ENOTTY;
-
-       if ((_IOC_DIR(cmd) & _IOC_READ)
-           && !access_ok(VERIFY_WRITE, arg, size))
-               return -EFAULT;
-
-       if ((_IOC_DIR(cmd) & _IOC_WRITE)
-           && !access_ok(VERIFY_READ, arg, size))
-               return -EFAULT;
-
-       expect_close = 0;
-
-       switch (cmd) {
-       case WDIOC_GETSUPPORT:
-               wdinfo.options = nowayout ?
-                       WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING :
-                       WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING |
-                       WDIOF_MAGICCLOSE;
-               res = __copy_to_user(argp, &wdinfo, size) ?  -EFAULT : size;
-               break;
-
-       case WDIOC_GETSTATUS:
-               break;
-
-       case WDIOC_GETBOOTSTATUS:
-               stat = (*(volatile char *) flagaddr & 0x01)
-                       ? WDIOF_CARDRESET : 0;
-               res = __copy_to_user(argp, &stat, size) ?
-                       -EFAULT : size;
-               break;
-
-       case WDIOC_SETOPTIONS:
-               break;
-
-       case WDIOC_KEEPALIVE:
-               wdt_gpi_set_timeout(timeout);
-               res = size;
-               break;
-
-       case WDIOC_SETTIMEOUT:
-               {
-                       int val;
-                       if (unlikely(__copy_from_user(&val, argp, size))) {
-                               res = -EFAULT;
-                               break;
-                       }
-
-                       if (val > MAX_TIMEOUT_SECONDS)
-                               val = MAX_TIMEOUT_SECONDS;
-                       timeout = val;
-                       wdt_gpi_set_timeout(val);
-                       res = size;
-                       printk(KERN_INFO "%s: timeout set to %u seconds\n",
-                               wdt_gpi_name, timeout);
-               }
-               break;
-
-       case WDIOC_GETTIMEOUT:
-               res = __copy_to_user(argp, &timeout, size) ?
-                       -EFAULT : size;
-               break;
-       }
-
-       return res;
-}
-
-
-/* Shutdown notifier */
-static int wdt_gpi_notify(struct notifier_block *this, unsigned long code,
-                         void *unused)
-{
-       if (code == SYS_DOWN || code == SYS_HALT)
-               wdt_gpi_stop();
-
-       return NOTIFY_DONE;
-}
-
-
-/* Init & exit procedures */
-static const struct resource *wdt_gpi_get_resource(struct platform_device *pdv,
-                                       const char *name, unsigned int type)
-{
-       char buf[80];
-       if (snprintf(buf, sizeof(buf), "%s_0", name) >= sizeof(buf))
-               return NULL;
-       return platform_get_resource_byname(pdv, type, buf);
-}
-
-/* No hotplugging on the platform bus - use __devinit */
-static int __devinit wdt_gpi_probe(struct platform_device *pdv)
-{
-       int res;
-       const struct resource
-               * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS,
-                                                 IORESOURCE_MEM),
-               * const ri = wdt_gpi_get_resource(pdv, WDT_RESOURCE_IRQ,
-                                                 IORESOURCE_IRQ),
-               * const rc = wdt_gpi_get_resource(pdv, WDT_RESOURCE_COUNTER,
-                                                 0);
-
-       if (unlikely(!rr || !ri || !rc))
-               return -ENXIO;
-
-       wd_regs = ioremap_nocache(rr->start, rr->end + 1 - rr->start);
-       if (unlikely(!wd_regs))
-               return -ENOMEM;
-       wd_irq = ri->start;
-       wd_ctr = rc->start;
-       res = misc_register(&miscdev);
-       if (res)
-               iounmap(wd_regs);
-       else
-               register_reboot_notifier(&wdt_gpi_shutdown);
-       return res;
-}
-
-static int __devexit wdt_gpi_remove(struct platform_device *dev)
-{
-       int res;
-
-       unregister_reboot_notifier(&wdt_gpi_shutdown);
-       res = misc_deregister(&miscdev);
-       iounmap(wd_regs);
-       wd_regs = NULL;
-       return res;
-}
-
-
-/* Device driver init & exit */
-static struct platform_driver wgt_gpi_driver = {
-       .driver = {
-               .name           = wdt_gpi_name,
-               .owner          = THIS_MODULE,
-       },
-       .probe          = wdt_gpi_probe,
-       .remove         = __devexit_p(wdt_gpi_remove),
-};
-
-static int __init wdt_gpi_init_module(void)
-{
-       atomic_set(&opencnt, 1);
-       if (timeout > MAX_TIMEOUT_SECONDS)
-               timeout = MAX_TIMEOUT_SECONDS;
-       return platform_driver_register(&wdt_gpi_driver);
-}
-
-static void __exit wdt_gpi_cleanup_module(void)
-{
-       platform_driver_unregister(&wdt_gpi_driver);
-}
-
-module_init(wdt_gpi_init_module);
-module_exit(wdt_gpi_cleanup_module);
-
-MODULE_AUTHOR("Thomas Koeller <thomas.koeller@baslerweb.com>");
-MODULE_DESCRIPTION("Basler eXcite watchdog driver for gpi devices");
-MODULE_VERSION("0.1");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
-
index 85b93e15d01122aefad8c9433221670041afde97..8760a26ab2a3996fd7b48b4615d7d68f85055b1d 100644 (file)
@@ -421,7 +421,7 @@ static int __devinit s3c2410wdt_probe(struct platform_device *pdev)
                return -ENOENT;
        }
 
-       size = (res->end - res->start) + 1;
+       size = resource_size(res);
        wdt_mem = request_mem_region(res->start, size, pdev->name);
        if (wdt_mem == NULL) {
                dev_err(dev, "failed to get memory region\n");
index 6adab77fbbb09bdfe11dd56b7ad65406e42d0c6d..d635566e9307235f6d09d5f39fb1ce0a963060a9 100644 (file)
@@ -214,12 +214,10 @@ static int __init txx9wdt_probe(struct platform_device *dev)
        res = platform_get_resource(dev, IORESOURCE_MEM, 0);
        if (!res)
                goto exit_busy;
-       if (!devm_request_mem_region(&dev->dev,
-                                    res->start, res->end - res->start + 1,
+       if (!devm_request_mem_region(&dev->dev, res->start, resource_size(res),
                                     "txx9wdt"))
                goto exit_busy;
-       txx9wdt_reg = devm_ioremap(&dev->dev,
-                                  res->start, res->end - res->start + 1);
+       txx9wdt_reg = devm_ioremap(&dev->dev, res->start, resource_size(res));
        if (!txx9wdt_reg)
                goto exit_busy;
 
index c30dfc00610820804bad5950902e4a6a335de50e..1cf12b3dd83a0654d7c0629786d8ab7fd4388a23 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -711,10 +711,8 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
         */
        ret = retry(iocb);
 
-       if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) {
-               BUG_ON(!list_empty(&iocb->ki_wait.task_list));
+       if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED)
                aio_complete(iocb, ret, 0);
-       }
 out:
        spin_lock_irq(&ctx->ctx_lock);
 
@@ -866,13 +864,6 @@ static void try_queue_kicked_iocb(struct kiocb *iocb)
        unsigned long flags;
        int run = 0;
 
-       /* We're supposed to be the only path putting the iocb back on the run
-        * list.  If we find that the iocb is *back* on a wait queue already
-        * than retry has happened before we could queue the iocb.  This also
-        * means that the retry could have completed and freed our iocb, no
-        * good. */
-       BUG_ON((!list_empty(&iocb->ki_wait.task_list)));
-
        spin_lock_irqsave(&ctx->ctx_lock, flags);
        /* set this inside the lock so that we can't race with aio_run_iocb()
         * testing it and putting the iocb on the run list under the lock */
@@ -886,7 +877,7 @@ static void try_queue_kicked_iocb(struct kiocb *iocb)
 /*
  * kick_iocb:
  *      Called typically from a wait queue callback context
- *      (aio_wake_function) to trigger a retry of the iocb.
+ *      to trigger a retry of the iocb.
  *      The retry is usually executed by aio workqueue
  *      threads (See aio_kick_handler).
  */
@@ -1520,31 +1511,6 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb)
        return 0;
 }
 
-/*
- * aio_wake_function:
- *     wait queue callback function for aio notification,
- *     Simply triggers a retry of the operation via kick_iocb.
- *
- *     This callback is specified in the wait queue entry in
- *     a kiocb.
- *
- * Note:
- * This routine is executed with the wait queue lock held.
- * Since kick_iocb acquires iocb->ctx->ctx_lock, it nests
- * the ioctx lock inside the wait queue lock. This is safe
- * because this callback isn't used for wait queues which
- * are nested inside ioctx lock (i.e. ctx->wait)
- */
-static int aio_wake_function(wait_queue_t *wait, unsigned mode,
-                            int sync, void *key)
-{
-       struct kiocb *iocb = container_of(wait, struct kiocb, ki_wait);
-
-       list_del_init(&wait->task_list);
-       kick_iocb(iocb);
-       return 1;
-}
-
 static void aio_batch_add(struct address_space *mapping,
                          struct hlist_head *batch_hash)
 {
@@ -1642,8 +1608,6 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
        req->ki_buf = (char __user *)(unsigned long)iocb->aio_buf;
        req->ki_left = req->ki_nbytes = iocb->aio_nbytes;
        req->ki_opcode = iocb->aio_lio_opcode;
-       init_waitqueue_func_entry(&req->ki_wait, aio_wake_function);
-       INIT_LIST_HEAD(&req->ki_wait.task_list);
 
        ret = aio_setup_iocb(req);
 
index 2ca7a7cafdbf9359ccf1a706a5fdda11f3fe157e..9f0bf13291e53de00b01fe6b12218cb4c3b9f664 100644 (file)
@@ -35,14 +35,13 @@ static int anon_inodefs_get_sb(struct file_system_type *fs_type, int flags,
                             mnt);
 }
 
-static int anon_inodefs_delete_dentry(struct dentry *dentry)
+/*
+ * anon_inodefs_dname() is called from d_path().
+ */
+static char *anon_inodefs_dname(struct dentry *dentry, char *buffer, int buflen)
 {
-       /*
-        * We faked vfs to believe the dentry was hashed when we created it.
-        * Now we restore the flag so that dput() will work correctly.
-        */
-       dentry->d_flags |= DCACHE_UNHASHED;
-       return 1;
+       return dynamic_dname(dentry, buffer, buflen, "anon_inode:%s",
+                               dentry->d_name.name);
 }
 
 static struct file_system_type anon_inode_fs_type = {
@@ -51,7 +50,7 @@ static struct file_system_type anon_inode_fs_type = {
        .kill_sb        = kill_anon_super,
 };
 static const struct dentry_operations anon_inodefs_dentry_operations = {
-       .d_delete       = anon_inodefs_delete_dentry,
+       .d_dname        = anon_inodefs_dname,
 };
 
 /*
@@ -88,7 +87,7 @@ struct file *anon_inode_getfile(const char *name,
                                void *priv, int flags)
 {
        struct qstr this;
-       struct dentry *dentry;
+       struct path path;
        struct file *file;
        int error;
 
@@ -106,10 +105,11 @@ struct file *anon_inode_getfile(const char *name,
        this.name = name;
        this.len = strlen(name);
        this.hash = 0;
-       dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this);
-       if (!dentry)
+       path.dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this);
+       if (!path.dentry)
                goto err_module;
 
+       path.mnt = mntget(anon_inode_mnt);
        /*
         * We know the anon_inode inode count is always greater than zero,
         * so we can avoid doing an igrab() and we can use an open-coded
@@ -117,27 +117,24 @@ struct file *anon_inode_getfile(const char *name,
         */
        atomic_inc(&anon_inode_inode->i_count);
 
-       dentry->d_op = &anon_inodefs_dentry_operations;
-       /* Do not publish this dentry inside the global dentry hash table */
-       dentry->d_flags &= ~DCACHE_UNHASHED;
-       d_instantiate(dentry, anon_inode_inode);
+       path.dentry->d_op = &anon_inodefs_dentry_operations;
+       d_instantiate(path.dentry, anon_inode_inode);
 
        error = -ENFILE;
-       file = alloc_file(anon_inode_mnt, dentry,
-                         FMODE_READ | FMODE_WRITE, fops);
+       file = alloc_file(&path, OPEN_FMODE(flags), fops);
        if (!file)
                goto err_dput;
        file->f_mapping = anon_inode_inode->i_mapping;
 
        file->f_pos = 0;
-       file->f_flags = O_RDWR | (flags & O_NONBLOCK);
+       file->f_flags = flags & (O_ACCMODE | O_NONBLOCK);
        file->f_version = 0;
        file->private_data = priv;
 
        return file;
 
 err_dput:
-       dput(dentry);
+       path_put(&path);
 err_module:
        module_put(fops->owner);
        return ERR_PTR(error);
index 8f7cdde4173358575b292088c7f085d71ba66232..0118d67221b218672c622fdd1927289c1d9459ed 100644 (file)
@@ -60,6 +60,11 @@ do {                                                 \
                current->pid, __func__, ##args);        \
 } while (0)
 
+struct rehash_entry {
+       struct task_struct *task;
+       struct list_head list;
+};
+
 /* Unified info structure.  This is pointed to by both the dentry and
    inode structures.  Each file in the filesystem has an instance of this
    structure.  It holds a reference to the dentry, so dentries are never
@@ -75,6 +80,9 @@ struct autofs_info {
        struct completion expire_complete;
 
        struct list_head active;
+       int active_count;
+       struct list_head rehash_list;
+
        struct list_head expiring;
 
        struct autofs_sb_info *sbi;
@@ -95,6 +103,8 @@ struct autofs_info {
 
 #define AUTOFS_INF_EXPIRING    (1<<0) /* dentry is in the process of expiring */
 #define AUTOFS_INF_MOUNTPOINT  (1<<1) /* mountpoint status for direct expire */
+#define AUTOFS_INF_PENDING     (1<<2) /* dentry pending mount */
+#define AUTOFS_INF_REHASH      (1<<3) /* dentry in transit to ->lookup() */
 
 struct autofs_wait_queue {
        wait_queue_head_t queue;
@@ -161,7 +171,7 @@ static inline int autofs4_ispending(struct dentry *dentry)
 {
        struct autofs_info *inf = autofs4_dentry_ino(dentry);
 
-       if (dentry->d_flags & DCACHE_AUTOFS_PENDING)
+       if (inf->flags & AUTOFS_INF_PENDING)
                return 1;
 
        if (inf->flags & AUTOFS_INF_EXPIRING)
@@ -264,5 +274,31 @@ out:
        return ret;
 }
 
+static inline void autofs4_add_expiring(struct dentry *dentry)
+{
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
+       if (ino) {
+               spin_lock(&sbi->lookup_lock);
+               if (list_empty(&ino->expiring))
+                       list_add(&ino->expiring, &sbi->expiring_list);
+               spin_unlock(&sbi->lookup_lock);
+       }
+       return;
+}
+
+static inline void autofs4_del_expiring(struct dentry *dentry)
+{
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
+       if (ino) {
+               spin_lock(&sbi->lookup_lock);
+               if (!list_empty(&ino->expiring))
+                       list_del_init(&ino->expiring);
+               spin_unlock(&sbi->lookup_lock);
+       }
+       return;
+}
+
 void autofs4_dentry_release(struct dentry *);
 extern void autofs4_kill_sb(struct super_block *);
index 3da18d4534881a199dccfa223d77c3019c813269..74bc9aa6df310d4ccdf0d312dd43976c02f93d1e 100644 (file)
@@ -27,7 +27,7 @@ static inline int autofs4_can_expire(struct dentry *dentry,
                return 0;
 
        /* No point expiring a pending mount */
-       if (dentry->d_flags & DCACHE_AUTOFS_PENDING)
+       if (ino->flags & AUTOFS_INF_PENDING)
                return 0;
 
        if (!do_now) {
@@ -279,6 +279,7 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
                        root->d_mounted--;
                }
                ino->flags |= AUTOFS_INF_EXPIRING;
+               autofs4_add_expiring(root);
                init_completion(&ino->expire_complete);
                spin_unlock(&sbi->fs_lock);
                return root;
@@ -406,6 +407,7 @@ found:
                expired, (int)expired->d_name.len, expired->d_name.name);
        ino = autofs4_dentry_ino(expired);
        ino->flags |= AUTOFS_INF_EXPIRING;
+       autofs4_add_expiring(expired);
        init_completion(&ino->expire_complete);
        spin_unlock(&sbi->fs_lock);
        spin_lock(&dcache_lock);
@@ -433,7 +435,7 @@ int autofs4_expire_wait(struct dentry *dentry)
 
                DPRINTK("expire done status=%d", status);
 
-               if (d_unhashed(dentry))
+               if (d_unhashed(dentry) && IS_DEADDIR(dentry->d_inode))
                        return -EAGAIN;
 
                return status;
@@ -473,6 +475,7 @@ int autofs4_expire_run(struct super_block *sb,
        spin_lock(&sbi->fs_lock);
        ino = autofs4_dentry_ino(dentry);
        ino->flags &= ~AUTOFS_INF_EXPIRING;
+       autofs4_del_expiring(dentry);
        complete_all(&ino->expire_complete);
        spin_unlock(&sbi->fs_lock);
 
@@ -503,6 +506,7 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
                        ino->flags &= ~AUTOFS_INF_MOUNTPOINT;
                }
                ino->flags &= ~AUTOFS_INF_EXPIRING;
+               autofs4_del_expiring(dentry);
                complete_all(&ino->expire_complete);
                spin_unlock(&sbi->fs_lock);
                dput(dentry);
index 69c8142da8386577cba280ba13d229db16067580..d0a3de247458aae03f045bf6788b64e5045ad950 100644 (file)
@@ -49,6 +49,8 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino,
                ino->dentry = NULL;
                ino->size = 0;
                INIT_LIST_HEAD(&ino->active);
+               INIT_LIST_HEAD(&ino->rehash_list);
+               ino->active_count = 0;
                INIT_LIST_HEAD(&ino->expiring);
                atomic_set(&ino->count, 0);
        }
index b96a3c57359d71a73b6698f8d4d1269b116ceaee..30cc9ddf4b708454c772ca95fc848c5c83ca92df 100644 (file)
@@ -72,6 +72,139 @@ const struct inode_operations autofs4_dir_inode_operations = {
        .rmdir          = autofs4_dir_rmdir,
 };
 
+static void autofs4_add_active(struct dentry *dentry)
+{
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
+       if (ino) {
+               spin_lock(&sbi->lookup_lock);
+               if (!ino->active_count) {
+                       if (list_empty(&ino->active))
+                               list_add(&ino->active, &sbi->active_list);
+               }
+               ino->active_count++;
+               spin_unlock(&sbi->lookup_lock);
+       }
+       return;
+}
+
+static void autofs4_del_active(struct dentry *dentry)
+{
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
+       if (ino) {
+               spin_lock(&sbi->lookup_lock);
+               ino->active_count--;
+               if (!ino->active_count) {
+                       if (!list_empty(&ino->active))
+                               list_del_init(&ino->active);
+               }
+               spin_unlock(&sbi->lookup_lock);
+       }
+       return;
+}
+
+static void autofs4_add_rehash_entry(struct autofs_info *ino,
+                                    struct rehash_entry *entry)
+{
+       entry->task = current;
+       INIT_LIST_HEAD(&entry->list);
+       list_add(&entry->list, &ino->rehash_list);
+       return;
+}
+
+static void autofs4_remove_rehash_entry(struct autofs_info *ino)
+{
+       struct list_head *head = &ino->rehash_list;
+       struct rehash_entry *entry;
+       list_for_each_entry(entry, head, list) {
+               if (entry->task == current) {
+                       list_del(&entry->list);
+                       kfree(entry);
+                       break;
+               }
+       }
+       return;
+}
+
+static void autofs4_remove_rehash_entrys(struct autofs_info *ino)
+{
+       struct autofs_sb_info *sbi = ino->sbi;
+       struct rehash_entry *entry, *next;
+       struct list_head *head;
+
+       spin_lock(&sbi->fs_lock);
+       spin_lock(&sbi->lookup_lock);
+       if (!(ino->flags & AUTOFS_INF_REHASH)) {
+               spin_unlock(&sbi->lookup_lock);
+               spin_unlock(&sbi->fs_lock);
+               return;
+       }
+       ino->flags &= ~AUTOFS_INF_REHASH;
+       head = &ino->rehash_list;
+       list_for_each_entry_safe(entry, next, head, list) {
+               list_del(&entry->list);
+               kfree(entry);
+       }
+       spin_unlock(&sbi->lookup_lock);
+       spin_unlock(&sbi->fs_lock);
+       dput(ino->dentry);
+
+       return;
+}
+
+static void autofs4_revalidate_drop(struct dentry *dentry,
+                                   struct rehash_entry *entry)
+{
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
+       /*
+        * Add to the active list so we can pick this up in
+        * ->lookup(). Also add an entry to a rehash list so
+        * we know when there are no dentrys in flight so we
+        * know when we can rehash the dentry.
+        */
+       spin_lock(&sbi->lookup_lock);
+       if (list_empty(&ino->active))
+               list_add(&ino->active, &sbi->active_list);
+       autofs4_add_rehash_entry(ino, entry);
+       spin_unlock(&sbi->lookup_lock);
+       if (!(ino->flags & AUTOFS_INF_REHASH)) {
+               ino->flags |= AUTOFS_INF_REHASH;
+               dget(dentry);
+               spin_lock(&dentry->d_lock);
+               __d_drop(dentry);
+               spin_unlock(&dentry->d_lock);
+       }
+       return;
+}
+
+static void autofs4_revalidate_rehash(struct dentry *dentry)
+{
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
+       if (ino->flags & AUTOFS_INF_REHASH) {
+               spin_lock(&sbi->lookup_lock);
+               autofs4_remove_rehash_entry(ino);
+               if (list_empty(&ino->rehash_list)) {
+                       spin_unlock(&sbi->lookup_lock);
+                       ino->flags &= ~AUTOFS_INF_REHASH;
+                       d_rehash(dentry);
+                       dput(ino->dentry);
+               } else
+                       spin_unlock(&sbi->lookup_lock);
+       }
+       return;
+}
+
+static unsigned int autofs4_need_mount(unsigned int flags)
+{
+       unsigned int res = 0;
+       if (flags & (TRIGGER_FLAGS | TRIGGER_INTENTS))
+               res = 1;
+       return res;
+}
+
 static int autofs4_dir_open(struct inode *inode, struct file *file)
 {
        struct dentry *dentry = file->f_path.dentry;
@@ -93,7 +226,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
         * it.
         */
        spin_lock(&dcache_lock);
-       if (!d_mountpoint(dentry) && __simple_empty(dentry)) {
+       if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
                spin_unlock(&dcache_lock);
                return -ENOENT;
        }
@@ -103,7 +236,7 @@ out:
        return dcache_dir_open(inode, file);
 }
 
-static int try_to_fill_dentry(struct dentry *dentry, int flags)
+static int try_to_fill_dentry(struct dentry *dentry)
 {
        struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
        struct autofs_info *ino = autofs4_dentry_ino(dentry);
@@ -116,55 +249,17 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags)
         * Wait for a pending mount, triggering one if there
         * isn't one already
         */
-       if (dentry->d_inode == NULL) {
-               DPRINTK("waiting for mount name=%.*s",
-                        dentry->d_name.len, dentry->d_name.name);
-
-               status = autofs4_wait(sbi, dentry, NFY_MOUNT);
-
-               DPRINTK("mount done status=%d", status);
-
-               /* Turn this into a real negative dentry? */
-               if (status == -ENOENT) {
-                       spin_lock(&dentry->d_lock);
-                       dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
-                       spin_unlock(&dentry->d_lock);
-                       return status;
-               } else if (status) {
-                       /* Return a negative dentry, but leave it "pending" */
-                       return status;
-               }
-       /* Trigger mount for path component or follow link */
-       } else if (dentry->d_flags & DCACHE_AUTOFS_PENDING ||
-                       flags & (TRIGGER_FLAGS | TRIGGER_INTENTS) ||
-                       current->link_count) {
-               DPRINTK("waiting for mount name=%.*s",
-                       dentry->d_name.len, dentry->d_name.name);
-
-               spin_lock(&dentry->d_lock);
-               dentry->d_flags |= DCACHE_AUTOFS_PENDING;
-               spin_unlock(&dentry->d_lock);
-               status = autofs4_wait(sbi, dentry, NFY_MOUNT);
+       DPRINTK("waiting for mount name=%.*s",
+                dentry->d_name.len, dentry->d_name.name);
 
-               DPRINTK("mount done status=%d", status);
+       status = autofs4_wait(sbi, dentry, NFY_MOUNT);
 
-               if (status) {
-                       spin_lock(&dentry->d_lock);
-                       dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
-                       spin_unlock(&dentry->d_lock);
-                       return status;
-               }
-       }
-
-       /* Initialize expiry counter after successful mount */
-       if (ino)
-               ino->last_used = jiffies;
+       DPRINTK("mount done status=%d", status);
 
-       spin_lock(&dentry->d_lock);
-       dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
-       spin_unlock(&dentry->d_lock);
+       /* Update expiry counter */
+       ino->last_used = jiffies;
 
-       return 0;
+       return status;
 }
 
 /* For autofs direct mounts the follow link triggers the mount */
@@ -202,27 +297,39 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
        autofs4_expire_wait(dentry);
 
        /* We trigger a mount for almost all flags */
-       lookup_type = nd->flags & (TRIGGER_FLAGS | TRIGGER_INTENTS);
-       if (!(lookup_type || dentry->d_flags & DCACHE_AUTOFS_PENDING))
+       lookup_type = autofs4_need_mount(nd->flags);
+       spin_lock(&sbi->fs_lock);
+       spin_lock(&dcache_lock);
+       if (!(lookup_type || ino->flags & AUTOFS_INF_PENDING)) {
+               spin_unlock(&dcache_lock);
+               spin_unlock(&sbi->fs_lock);
                goto follow;
+       }
 
        /*
         * If the dentry contains directories then it is an autofs
         * multi-mount with no root mount offset. So don't try to
         * mount it again.
         */
-       spin_lock(&dcache_lock);
-       if (dentry->d_flags & DCACHE_AUTOFS_PENDING ||
-           (!d_mountpoint(dentry) && __simple_empty(dentry))) {
+       if (ino->flags & AUTOFS_INF_PENDING ||
+           (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) {
+               ino->flags |= AUTOFS_INF_PENDING;
                spin_unlock(&dcache_lock);
+               spin_unlock(&sbi->fs_lock);
+
+               status = try_to_fill_dentry(dentry);
+
+               spin_lock(&sbi->fs_lock);
+               ino->flags &= ~AUTOFS_INF_PENDING;
+               spin_unlock(&sbi->fs_lock);
 
-               status = try_to_fill_dentry(dentry, 0);
                if (status)
                        goto out_error;
 
                goto follow;
        }
        spin_unlock(&dcache_lock);
+       spin_unlock(&sbi->fs_lock);
 follow:
        /*
         * If there is no root mount it must be an autofs
@@ -254,18 +361,47 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
 {
        struct inode *dir = dentry->d_parent->d_inode;
        struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
-       int oz_mode = autofs4_oz_mode(sbi);
+       struct autofs_info *ino = autofs4_dentry_ino(dentry);
+       struct rehash_entry *entry;
        int flags = nd ? nd->flags : 0;
-       int status = 1;
+       unsigned int mutex_aquired;
+
+       DPRINTK("name = %.*s oz_mode = %d",
+               dentry->d_name.len, dentry->d_name.name, oz_mode);
+
+       /* Daemon never causes a mount to trigger */
+       if (autofs4_oz_mode(sbi))
+               return 1;
+
+       entry = kmalloc(sizeof(struct rehash_entry), GFP_KERNEL);
+       if (!entry)
+               return -ENOMEM;
+
+       mutex_aquired = mutex_trylock(&dir->i_mutex);
 
-       /* Pending dentry */
        spin_lock(&sbi->fs_lock);
+       spin_lock(&dcache_lock);
+       /* Pending dentry */
        if (autofs4_ispending(dentry)) {
-               /* The daemon never causes a mount to trigger */
-               spin_unlock(&sbi->fs_lock);
+               int status;
 
-               if (oz_mode)
-                       return 1;
+               /*
+                * We can only unhash and send this to ->lookup() if
+                * the directory mutex is held over d_revalidate() and
+                * ->lookup(). This prevents the VFS from incorrectly
+                * seeing the dentry as non-existent.
+                */
+               ino->flags |= AUTOFS_INF_PENDING;
+               if (!mutex_aquired) {
+                       autofs4_revalidate_drop(dentry, entry);
+                       spin_unlock(&dcache_lock);
+                       spin_unlock(&sbi->fs_lock);
+                       return 0;
+               }
+               spin_unlock(&dcache_lock);
+               spin_unlock(&sbi->fs_lock);
+               mutex_unlock(&dir->i_mutex);
+               kfree(entry);
 
                /*
                 * If the directory has gone away due to an expire
@@ -279,46 +415,82 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
                 * A zero status is success otherwise we have a
                 * negative error code.
                 */
-               status = try_to_fill_dentry(dentry, flags);
+               status = try_to_fill_dentry(dentry);
+
+               spin_lock(&sbi->fs_lock);
+               ino->flags &= ~AUTOFS_INF_PENDING;
+               spin_unlock(&sbi->fs_lock);
+
                if (status == 0)
                        return 1;
 
                return status;
        }
-       spin_unlock(&sbi->fs_lock);
-
-       /* Negative dentry.. invalidate if "old" */
-       if (dentry->d_inode == NULL)
-               return 0;
 
        /* Check for a non-mountpoint directory with no contents */
-       spin_lock(&dcache_lock);
        if (S_ISDIR(dentry->d_inode->i_mode) &&
-           !d_mountpoint(dentry) && 
-           __simple_empty(dentry)) {
+           !d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
                DPRINTK("dentry=%p %.*s, emptydir",
                         dentry, dentry->d_name.len, dentry->d_name.name);
-               spin_unlock(&dcache_lock);
 
-               /* The daemon never causes a mount to trigger */
-               if (oz_mode)
-                       return 1;
+               if (autofs4_need_mount(flags) || current->link_count) {
+                       int status;
 
-               /*
-                * A zero status is success otherwise we have a
-                * negative error code.
-                */
-               status = try_to_fill_dentry(dentry, flags);
-               if (status == 0)
-                       return 1;
+                       /*
+                        * We can only unhash and send this to ->lookup() if
+                        * the directory mutex is held over d_revalidate() and
+                        * ->lookup(). This prevents the VFS from incorrectly
+                        * seeing the dentry as non-existent.
+                        */
+                       ino->flags |= AUTOFS_INF_PENDING;
+                       if (!mutex_aquired) {
+                               autofs4_revalidate_drop(dentry, entry);
+                               spin_unlock(&dcache_lock);
+                               spin_unlock(&sbi->fs_lock);
+                               return 0;
+                       }
+                       spin_unlock(&dcache_lock);
+                       spin_unlock(&sbi->fs_lock);
+                       mutex_unlock(&dir->i_mutex);
+                       kfree(entry);
 
-               return status;
+                       /*
+                        * A zero status is success otherwise we have a
+                        * negative error code.
+                        */
+                       status = try_to_fill_dentry(dentry);
+
+                       spin_lock(&sbi->fs_lock);
+                       ino->flags &= ~AUTOFS_INF_PENDING;
+                       spin_unlock(&sbi->fs_lock);
+
+                       if (status == 0)
+                               return 1;
+
+                       return status;
+               }
        }
        spin_unlock(&dcache_lock);
+       spin_unlock(&sbi->fs_lock);
+
+       if (mutex_aquired)
+               mutex_unlock(&dir->i_mutex);
+
+       kfree(entry);
 
        return 1;
 }
 
+static void autofs4_free_rehash_entrys(struct autofs_info *inf)
+{
+       struct list_head *head = &inf->rehash_list;
+       struct rehash_entry *entry, *next;
+       list_for_each_entry_safe(entry, next, head, list) {
+               list_del(&entry->list);
+               kfree(entry);
+       }
+}
+
 void autofs4_dentry_release(struct dentry *de)
 {
        struct autofs_info *inf;
@@ -337,6 +509,8 @@ void autofs4_dentry_release(struct dentry *de)
                                list_del(&inf->active);
                        if (!list_empty(&inf->expiring))
                                list_del(&inf->expiring);
+                       if (!list_empty(&inf->rehash_list))
+                               autofs4_free_rehash_entrys(inf);
                        spin_unlock(&sbi->lookup_lock);
                }
 
@@ -359,35 +533,52 @@ static const struct dentry_operations autofs4_dentry_operations = {
        .d_release      = autofs4_dentry_release,
 };
 
-static struct dentry *autofs4_lookup_active(struct autofs_sb_info *sbi, struct dentry *parent, struct qstr *name)
+static struct dentry *autofs4_lookup_active(struct dentry *dentry)
 {
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct dentry *parent = dentry->d_parent;
+       struct qstr *name = &dentry->d_name;
        unsigned int len = name->len;
        unsigned int hash = name->hash;
        const unsigned char *str = name->name;
        struct list_head *p, *head;
 
+restart:
        spin_lock(&dcache_lock);
        spin_lock(&sbi->lookup_lock);
        head = &sbi->active_list;
        list_for_each(p, head) {
                struct autofs_info *ino;
-               struct dentry *dentry;
+               struct dentry *active;
                struct qstr *qstr;
 
                ino = list_entry(p, struct autofs_info, active);
-               dentry = ino->dentry;
+               active = ino->dentry;
 
-               spin_lock(&dentry->d_lock);
+               spin_lock(&active->d_lock);
 
                /* Already gone? */
-               if (atomic_read(&dentry->d_count) == 0)
+               if (atomic_read(&active->d_count) == 0)
                        goto next;
 
-               qstr = &dentry->d_name;
+               if (active->d_inode && IS_DEADDIR(active->d_inode)) {
+                       if (!list_empty(&ino->rehash_list)) {
+                               dget(active);
+                               spin_unlock(&active->d_lock);
+                               spin_unlock(&sbi->lookup_lock);
+                               spin_unlock(&dcache_lock);
+                               autofs4_remove_rehash_entrys(ino);
+                               dput(active);
+                               goto restart;
+                       }
+                       goto next;
+               }
+
+               qstr = &active->d_name;
 
-               if (dentry->d_name.hash != hash)
+               if (active->d_name.hash != hash)
                        goto next;
-               if (dentry->d_parent != parent)
+               if (active->d_parent != parent)
                        goto next;
 
                if (qstr->len != len)
@@ -395,15 +586,13 @@ static struct dentry *autofs4_lookup_active(struct autofs_sb_info *sbi, struct d
                if (memcmp(qstr->name, str, len))
                        goto next;
 
-               if (d_unhashed(dentry)) {
-                       dget(dentry);
-                       spin_unlock(&dentry->d_lock);
-                       spin_unlock(&sbi->lookup_lock);
-                       spin_unlock(&dcache_lock);
-                       return dentry;
-               }
+               dget(active);
+               spin_unlock(&active->d_lock);
+               spin_unlock(&sbi->lookup_lock);
+               spin_unlock(&dcache_lock);
+               return active;
 next:
-               spin_unlock(&dentry->d_lock);
+               spin_unlock(&active->d_lock);
        }
        spin_unlock(&sbi->lookup_lock);
        spin_unlock(&dcache_lock);
@@ -411,8 +600,11 @@ next:
        return NULL;
 }
 
-static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct dentry *parent, struct qstr *name)
+static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
 {
+       struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
+       struct dentry *parent = dentry->d_parent;
+       struct qstr *name = &dentry->d_name;
        unsigned int len = name->len;
        unsigned int hash = name->hash;
        const unsigned char *str = name->name;
@@ -423,23 +615,23 @@ static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct
        head = &sbi->expiring_list;
        list_for_each(p, head) {
                struct autofs_info *ino;
-               struct dentry *dentry;
+               struct dentry *expiring;
                struct qstr *qstr;
 
                ino = list_entry(p, struct autofs_info, expiring);
-               dentry = ino->dentry;
+               expiring = ino->dentry;
 
-               spin_lock(&dentry->d_lock);
+               spin_lock(&expiring->d_lock);
 
                /* Bad luck, we've already been dentry_iput */
-               if (!dentry->d_inode)
+               if (!expiring->d_inode)
                        goto next;
 
-               qstr = &dentry->d_name;
+               qstr = &expiring->d_name;
 
-               if (dentry->d_name.hash != hash)
+               if (expiring->d_name.hash != hash)
                        goto next;
-               if (dentry->d_parent != parent)
+               if (expiring->d_parent != parent)
                        goto next;
 
                if (qstr->len != len)
@@ -447,15 +639,13 @@ static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct
                if (memcmp(qstr->name, str, len))
                        goto next;
 
-               if (d_unhashed(dentry)) {
-                       dget(dentry);
-                       spin_unlock(&dentry->d_lock);
-                       spin_unlock(&sbi->lookup_lock);
-                       spin_unlock(&dcache_lock);
-                       return dentry;
-               }
+               dget(expiring);
+               spin_unlock(&expiring->d_lock);
+               spin_unlock(&sbi->lookup_lock);
+               spin_unlock(&dcache_lock);
+               return expiring;
 next:
-               spin_unlock(&dentry->d_lock);
+               spin_unlock(&expiring->d_lock);
        }
        spin_unlock(&sbi->lookup_lock);
        spin_unlock(&dcache_lock);
@@ -463,13 +653,56 @@ next:
        return NULL;
 }
 
+static struct autofs_info *init_new_dentry(struct autofs_sb_info *sbi,
+                                          struct dentry *dentry, int oz_mode)
+{
+       struct autofs_info *ino;
+
+       /*
+        * Mark the dentry incomplete but don't hash it. We do this
+        * to serialize our inode creation operations (symlink and
+        * mkdir) which prevents deadlock during the callback to
+        * the daemon. Subsequent user space lookups for the same
+        * dentry are placed on the wait queue while the daemon
+        * itself is allowed passage unresticted so the create
+        * operation itself can then hash the dentry. Finally,
+        * we check for the hashed dentry and return the newly
+        * hashed dentry.
+        */
+       dentry->d_op = &autofs4_root_dentry_operations;
+
+       /*
+        * And we need to ensure that the same dentry is used for
+        * all following lookup calls until it is hashed so that
+        * the dentry flags are persistent throughout the request.
+        */
+       ino = autofs4_init_ino(NULL, sbi, 0555);
+       if (!ino)
+               return ERR_PTR(-ENOMEM);
+
+       dentry->d_fsdata = ino;
+       ino->dentry = dentry;
+
+       /*
+        * Only set the mount pending flag for new dentrys not created
+        * by the daemon.
+        */
+       if (!oz_mode)
+               ino->flags |= AUTOFS_INF_PENDING;
+
+       d_instantiate(dentry, NULL);
+
+       return ino;
+}
+
 /* Lookups in the root directory */
 static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
 {
        struct autofs_sb_info *sbi;
        struct autofs_info *ino;
-       struct dentry *expiring, *unhashed;
+       struct dentry *expiring, *active;
        int oz_mode;
+       int status = 0;
 
        DPRINTK("name = %.*s",
                dentry->d_name.len, dentry->d_name.name);
@@ -484,123 +717,100 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s
        DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d",
                 current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode);
 
-       unhashed = autofs4_lookup_active(sbi, dentry->d_parent, &dentry->d_name);
-       if (unhashed)
-               dentry = unhashed;
-       else {
-               /*
-                * Mark the dentry incomplete but don't hash it. We do this
-                * to serialize our inode creation operations (symlink and
-                * mkdir) which prevents deadlock during the callback to
-                * the daemon. Subsequent user space lookups for the same
-                * dentry are placed on the wait queue while the daemon
-                * itself is allowed passage unresticted so the create
-                * operation itself can then hash the dentry. Finally,
-                * we check for the hashed dentry and return the newly
-                * hashed dentry.
-                */
-               dentry->d_op = &autofs4_root_dentry_operations;
-
-               /*
-                * And we need to ensure that the same dentry is used for
-                * all following lookup calls until it is hashed so that
-                * the dentry flags are persistent throughout the request.
-                */
-               ino = autofs4_init_ino(NULL, sbi, 0555);
-               if (!ino)
-                       return ERR_PTR(-ENOMEM);
-
-               dentry->d_fsdata = ino;
-               ino->dentry = dentry;
-
-               spin_lock(&sbi->lookup_lock);
-               list_add(&ino->active, &sbi->active_list);
-               spin_unlock(&sbi->lookup_lock);
-
-               d_instantiate(dentry, NULL);
+       spin_lock(&sbi->fs_lock);
+       active = autofs4_lookup_active(dentry);
+       if (active) {
+               dentry = active;
+               ino = autofs4_dentry_ino(dentry);
+               /* If this came from revalidate, rehash it */
+               autofs4_revalidate_rehash(dentry);
+               spin_unlock(&sbi->fs_lock);
+       } else {
+               spin_unlock(&sbi->fs_lock);
+               ino = init_new_dentry(sbi, dentry, oz_mode);
+               if (IS_ERR(ino))
+                       return (struct dentry *) ino;
        }
 
+       autofs4_add_active(dentry);
+
        if (!oz_mode) {
+               expiring = autofs4_lookup_expiring(dentry);
                mutex_unlock(&dir->i_mutex);
-               expiring = autofs4_lookup_expiring(sbi,
-                                                  dentry->d_parent,
-                                                  &dentry->d_name);
                if (expiring) {
                        /*
                         * If we are racing with expire the request might not
                         * be quite complete but the directory has been removed
                         * so it must have been successful, so just wait for it.
                         */
-                       ino = autofs4_dentry_ino(expiring);
                        autofs4_expire_wait(expiring);
-                       spin_lock(&sbi->lookup_lock);
-                       if (!list_empty(&ino->expiring))
-                               list_del_init(&ino->expiring);
-                       spin_unlock(&sbi->lookup_lock);
                        dput(expiring);
                }
-
-               spin_lock(&dentry->d_lock);
-               dentry->d_flags |= DCACHE_AUTOFS_PENDING;
-               spin_unlock(&dentry->d_lock);
-               if (dentry->d_op && dentry->d_op->d_revalidate)
-                       (dentry->d_op->d_revalidate)(dentry, nd);
+               status = try_to_fill_dentry(dentry);
                mutex_lock(&dir->i_mutex);
+               spin_lock(&sbi->fs_lock);
+               ino->flags &= ~AUTOFS_INF_PENDING;
+               spin_unlock(&sbi->fs_lock);
        }
 
+       autofs4_del_active(dentry);
+
        /*
-        * If we are still pending, check if we had to handle
+        * If we had a mount fail, check if we had to handle
         * a signal. If so we can force a restart..
         */
-       if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
+       if (status) {
                /* See if we were interrupted */
                if (signal_pending(current)) {
                        sigset_t *sigset = &current->pending.signal;
                        if (sigismember (sigset, SIGKILL) ||
                            sigismember (sigset, SIGQUIT) ||
                            sigismember (sigset, SIGINT)) {
-                           if (unhashed)
-                               dput(unhashed);
+                           if (active)
+                               dput(active);
                            return ERR_PTR(-ERESTARTNOINTR);
                        }
                }
-               if (!oz_mode) {
-                       spin_lock(&dentry->d_lock);
-                       dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
-                       spin_unlock(&dentry->d_lock);
+       }
+
+       /*
+        * User space can (and has done in the past) remove and re-create
+        * this directory during the callback. This can leave us with an
+        * unhashed dentry, but a successful mount!  So we need to
+        * perform another cached lookup in case the dentry now exists.
+        */
+       if (!oz_mode && !have_submounts(dentry)) {
+               struct dentry *new;
+               new = d_lookup(dentry->d_parent, &dentry->d_name);
+               if (new) {
+                       if (active)
+                               dput(active);
+                       return new;
+               } else {
+                       if (!status)
+                               status = -ENOENT;
                }
        }
 
        /*
-        * If this dentry is unhashed, then we shouldn't honour this
-        * lookup.  Returning ENOENT here doesn't do the right thing
-        * for all system calls, but it should be OK for the operations
-        * we permit from an autofs.
+        * If we had a mount failure, return status to user space.
+        * If the mount succeeded and we used a dentry from the active queue
+        * return it.
         */
-       if (!oz_mode && d_unhashed(dentry)) {
+       if (status) {
+               dentry = ERR_PTR(status);
+               if (active)
+                       dput(active);
+               return dentry;
+       } else {
                /*
-                * A user space application can (and has done in the past)
-                * remove and re-create this directory during the callback.
-                * This can leave us with an unhashed dentry, but a
-                * successful mount!  So we need to perform another
-                * cached lookup in case the dentry now exists.
+                * Valid successful mount, return active dentry or NULL
+                * for a new dentry.
                 */
-               struct dentry *parent = dentry->d_parent;
-               struct dentry *new = d_lookup(parent, &dentry->d_name);
-               if (new != NULL)
-                       dentry = new;
-               else
-                       dentry = ERR_PTR(-ENOENT);
-
-               if (unhashed)
-                       dput(unhashed);
-
-               return dentry;
+               if (active)
+                       return active;
        }
 
-       if (unhashed)
-               return unhashed;
-
        return NULL;
 }
 
@@ -624,11 +834,6 @@ static int autofs4_dir_symlink(struct inode *dir,
        if (!ino)
                return -ENOMEM;
 
-       spin_lock(&sbi->lookup_lock);
-       if (!list_empty(&ino->active))
-               list_del_init(&ino->active);
-       spin_unlock(&sbi->lookup_lock);
-
        ino->size = strlen(symname);
        cp = kmalloc(ino->size + 1, GFP_KERNEL);
        if (!cp) {
@@ -705,10 +910,6 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
        dir->i_mtime = CURRENT_TIME;
 
        spin_lock(&dcache_lock);
-       spin_lock(&sbi->lookup_lock);
-       if (list_empty(&ino->expiring))
-               list_add(&ino->expiring, &sbi->expiring_list);
-       spin_unlock(&sbi->lookup_lock);
        spin_lock(&dentry->d_lock);
        __d_drop(dentry);
        spin_unlock(&dentry->d_lock);
@@ -734,10 +935,6 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
                spin_unlock(&dcache_lock);
                return -ENOTEMPTY;
        }
-       spin_lock(&sbi->lookup_lock);
-       if (list_empty(&ino->expiring))
-               list_add(&ino->expiring, &sbi->expiring_list);
-       spin_unlock(&sbi->lookup_lock);
        spin_lock(&dentry->d_lock);
        __d_drop(dentry);
        spin_unlock(&dentry->d_lock);
@@ -775,11 +972,6 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
        if (!ino)
                return -ENOMEM;
 
-       spin_lock(&sbi->lookup_lock);
-       if (!list_empty(&ino->active))
-               list_del_init(&ino->active);
-       spin_unlock(&sbi->lookup_lock);
-
        inode = autofs4_get_inode(dir->i_sb, ino);
        if (!inode) {
                if (!dentry->d_fsdata)
index b639dcf7c778cfc6f81eca964c8c6748a5840949..346b69405363b7419d7d4b591b240074d72bff6b 100644 (file)
@@ -32,7 +32,7 @@
 
 static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs);
 static int load_aout_library(struct file*);
-static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
+static int aout_core_dump(struct coredump_params *cprm);
 
 static struct linux_binfmt aout_format = {
        .module         = THIS_MODULE,
@@ -89,8 +89,9 @@ if (file->f_op->llseek) { \
  * dumping of the process results in another error..
  */
 
-static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
+static int aout_core_dump(struct coredump_params *cprm)
 {
+       struct file *file = cprm->file;
        mm_segment_t fs;
        int has_dumped = 0;
        unsigned long dump_start, dump_size;
@@ -108,16 +109,16 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u
        current->flags |= PF_DUMPCORE;
                strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm));
        dump.u_ar0 = offsetof(struct user, regs);
-       dump.signal = signr;
-       aout_dump_thread(regs, &dump);
+       dump.signal = cprm->signr;
+       aout_dump_thread(cprm->regs, &dump);
 
 /* If the size of the dump file exceeds the rlimit, then see what would happen
    if we wrote the stack, but not the data area.  */
-       if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > limit)
+       if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
                dump.u_dsize = 0;
 
 /* Make sure we have enough room to write the stack and data areas. */
-       if ((dump.u_ssize + 1) * PAGE_SIZE > limit)
+       if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
                dump.u_ssize = 0;
 
 /* make sure we actually have a data and stack area to dump */
index d15ea1790bfb8f8780f53aa055663895166d91a8..edd90c49003cff3b2fdf62ecb0e406007369eedb 100644 (file)
@@ -44,8 +44,8 @@ static unsigned long elf_map(struct file *, unsigned long, struct elf_phdr *,
  * If we don't support core dumping, then supply a NULL so we
  * don't even try.
  */
-#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
-static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
+#ifdef CONFIG_ELF_CORE
+static int elf_core_dump(struct coredump_params *cprm);
 #else
 #define elf_core_dump  NULL
 #endif
@@ -1101,12 +1101,7 @@ out:
        return error;
 }
 
-/*
- * Note that some platforms still use traditional core dumps and not
- * the ELF core dump.  Each platform can select it as appropriate.
- */
-#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
-
+#ifdef CONFIG_ELF_CORE
 /*
  * ELF core dumper
  *
@@ -1277,8 +1272,9 @@ static int writenote(struct memelfnote *men, struct file *file,
 }
 #undef DUMP_WRITE
 
-#define DUMP_WRITE(addr, nr)   \
-       if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \
+#define DUMP_WRITE(addr, nr)                           \
+       if ((size += (nr)) > cprm->limit ||             \
+           !dump_write(cprm->file, (addr), (nr)))      \
                goto end_coredump;
 
 static void fill_elf_header(struct elfhdr *elf, int segs,
@@ -1906,7 +1902,7 @@ static struct vm_area_struct *next_vma(struct vm_area_struct *this_vma,
  * and then they are actually written out.  If we run out of core limit
  * we just truncate.
  */
-static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
+static int elf_core_dump(struct coredump_params *cprm)
 {
        int has_dumped = 0;
        mm_segment_t fs;
@@ -1952,7 +1948,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
         * notes.  This also sets up the file header.
         */
        if (!fill_note_info(elf, segs + 1, /* including notes section */
-                           &info, signr, regs))
+                           &info, cprm->signr, cprm->regs))
                goto cleanup;
 
        has_dumped = 1;
@@ -2014,14 +2010,14 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
 #endif
 
        /* write out the notes section */
-       if (!write_note_info(&info, file, &foffset))
+       if (!write_note_info(&info, cprm->file, &foffset))
                goto end_coredump;
 
-       if (elf_coredump_extra_notes_write(file, &foffset))
+       if (elf_coredump_extra_notes_write(cprm->file, &foffset))
                goto end_coredump;
 
        /* Align to page */
-       if (!dump_seek(file, dataoff - foffset))
+       if (!dump_seek(cprm->file, dataoff - foffset))
                goto end_coredump;
 
        for (vma = first_vma(current, gate_vma); vma != NULL;
@@ -2038,12 +2034,13 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un
                        page = get_dump_page(addr);
                        if (page) {
                                void *kaddr = kmap(page);
-                               stop = ((size += PAGE_SIZE) > limit) ||
-                                       !dump_write(file, kaddr, PAGE_SIZE);
+                               stop = ((size += PAGE_SIZE) > cprm->limit) ||
+                                       !dump_write(cprm->file, kaddr,
+                                                   PAGE_SIZE);
                                kunmap(page);
                                page_cache_release(page);
                        } else
-                               stop = !dump_seek(file, PAGE_SIZE);
+                               stop = !dump_seek(cprm->file, PAGE_SIZE);
                        if (stop)
                                goto end_coredump;
                }
@@ -2063,7 +2060,7 @@ out:
        return has_dumped;
 }
 
-#endif         /* USE_ELF_CORE_DUMP */
+#endif         /* CONFIG_ELF_CORE */
 
 static int __init init_elf_binfmt(void)
 {
index 38502c67987c573541325aaf0f8a5db1ada1f756..c25256a5c5b0e432f63fe3fd07d8e3a2c61a909b 100644 (file)
@@ -75,14 +75,14 @@ static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *,
 static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *,
                                             struct file *, struct mm_struct *);
 
-#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
-static int elf_fdpic_core_dump(long, struct pt_regs *, struct file *, unsigned long limit);
+#ifdef CONFIG_ELF_CORE
+static int elf_fdpic_core_dump(struct coredump_params *cprm);
 #endif
 
 static struct linux_binfmt elf_fdpic_format = {
        .module         = THIS_MODULE,
        .load_binary    = load_elf_fdpic_binary,
-#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
+#ifdef CONFIG_ELF_CORE
        .core_dump      = elf_fdpic_core_dump,
 #endif
        .min_coredump   = ELF_EXEC_PAGESIZE,
@@ -380,7 +380,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm,
        down_write(&current->mm->mmap_sem);
        current->mm->start_brk = do_mmap(NULL, 0, stack_size,
                                         PROT_READ | PROT_WRITE | PROT_EXEC,
-                                        MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN,
+                                        MAP_PRIVATE | MAP_ANONYMOUS |
+                                        MAP_UNINITIALIZED | MAP_GROWSDOWN,
                                         0);
 
        if (IS_ERR_VALUE(current->mm->start_brk)) {
@@ -1200,7 +1201,7 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
  *
  * Modelled on fs/binfmt_elf.c core dumper
  */
-#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
+#ifdef CONFIG_ELF_CORE
 
 /*
  * These are the only things you should do on a core-file: use only these
@@ -1325,8 +1326,9 @@ static int writenote(struct memelfnote *men, struct file *file)
 #undef DUMP_WRITE
 #undef DUMP_SEEK
 
-#define DUMP_WRITE(addr, nr)   \
-       if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \
+#define DUMP_WRITE(addr, nr)                           \
+       if ((size += (nr)) > cprm->limit ||             \
+           !dump_write(cprm->file, (addr), (nr)))      \
                goto end_coredump;
 
 static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
@@ -1581,8 +1583,7 @@ static int elf_fdpic_dump_segments(struct file *file, size_t *size,
  * and then they are actually written out.  If we run out of core limit
  * we just truncate.
  */
-static int elf_fdpic_core_dump(long signr, struct pt_regs *regs,
-                              struct file *file, unsigned long limit)
+static int elf_fdpic_core_dump(struct coredump_params *cprm)
 {
 #define        NUM_NOTES       6
        int has_dumped = 0;
@@ -1641,7 +1642,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs,
                goto cleanup;
 #endif
 
-       if (signr) {
+       if (cprm->signr) {
                struct core_thread *ct;
                struct elf_thread_status *tmp;
 
@@ -1660,14 +1661,14 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs,
                        int sz;
 
                        tmp = list_entry(t, struct elf_thread_status, list);
-                       sz = elf_dump_thread_status(signr, tmp);
+                       sz = elf_dump_thread_status(cprm->signr, tmp);
                        thread_status_size += sz;
                }
        }
 
        /* now collect the dump for the current */
-       fill_prstatus(prstatus, current, signr);
-       elf_core_copy_regs(&prstatus->pr_reg, regs);
+       fill_prstatus(prstatus, current, cprm->signr);
+       elf_core_copy_regs(&prstatus->pr_reg, cprm->regs);
 
        segs = current->mm->map_count;
 #ifdef ELF_CORE_EXTRA_PHDRS
@@ -1702,7 +1703,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs,
 
        /* Try to dump the FPU. */
        if ((prstatus->pr_fpvalid =
-            elf_core_copy_task_fpregs(current, regs, fpu)))
+            elf_core_copy_task_fpregs(current, cprm->regs, fpu)))
                fill_note(notes + numnote++,
                          "CORE", NT_PRFPREG, sizeof(*fpu), fpu);
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1773,7 +1774,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs,
 
        /* write out the notes section */
        for (i = 0; i < numnote; i++)
-               if (!writenote(notes + i, file))
+               if (!writenote(notes + i, cprm->file))
                        goto end_coredump;
 
        /* write out the thread status notes section */
@@ -1782,14 +1783,15 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs,
                                list_entry(t, struct elf_thread_status, list);
 
                for (i = 0; i < tmp->num_notes; i++)
-                       if (!writenote(&tmp->notes[i], file))
+                       if (!writenote(&tmp->notes[i], cprm->file))
                                goto end_coredump;
        }
 
-       if (!dump_seek(file, dataoff))
+       if (!dump_seek(cprm->file, dataoff))
                goto end_coredump;
 
-       if (elf_fdpic_dump_segments(file, &size, &limit, mm_flags) < 0)
+       if (elf_fdpic_dump_segments(cprm->file, &size, &cprm->limit,
+                                   mm_flags) < 0)
                goto end_coredump;
 
 #ifdef ELF_CORE_WRITE_EXTRA_DATA
@@ -1825,4 +1827,4 @@ cleanup:
 #undef NUM_NOTES
 }
 
-#endif         /* USE_ELF_CORE_DUMP */
+#endif         /* CONFIG_ELF_CORE */
index a2796651e75690eb8e8a875146be852bfb1d637b..d4a00ea1054c63f0401bb0b1ef0e78a245df8851 100644 (file)
@@ -87,7 +87,7 @@ static int load_flat_shared_library(int id, struct lib_info *p);
 #endif
 
 static int load_flat_binary(struct linux_binprm *, struct pt_regs * regs);
-static int flat_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
+static int flat_core_dump(struct coredump_params *cprm);
 
 static struct linux_binfmt flat_format = {
        .module         = THIS_MODULE,
@@ -102,10 +102,10 @@ static struct linux_binfmt flat_format = {
  * Currently only a stub-function.
  */
 
-static int flat_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
+static int flat_core_dump(struct coredump_params *cprm)
 {
        printk("Process %s:%d received signr %d and should have core dumped\n",
-                       current->comm, current->pid, (int) signr);
+                       current->comm, current->pid, (int) cprm->signr);
        return(1);
 }
 
index eff74b9c9e77cf8f0b933adb2addcc9aac899a46..2a9b5330cc5e9ada9c23f41c6007996f58b6b938 100644 (file)
@@ -43,7 +43,7 @@ static int load_som_library(struct file *);
  * don't even try.
  */
 #if 0
-static int som_core_dump(long signr, struct pt_regs *regs, unsigned long limit);
+static int som_core_dump(struct coredump_params *cprm);
 #else
 #define som_core_dump  NULL
 #endif
index 36160424427124947179e7270bfb77e03dbc1686..2e9e69987a82973208724b58899b3479d77feaff 100644 (file)
@@ -73,13 +73,13 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
        return acl;
 }
 
-static int btrfs_xattr_get_acl(struct inode *inode, int type,
-                              void *value, size_t size)
+static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name,
+               void *value, size_t size, int type)
 {
        struct posix_acl *acl;
        int ret = 0;
 
-       acl = btrfs_get_acl(inode, type);
+       acl = btrfs_get_acl(dentry->d_inode, type);
 
        if (IS_ERR(acl))
                return PTR_ERR(acl);
@@ -94,7 +94,8 @@ static int btrfs_xattr_get_acl(struct inode *inode, int type,
 /*
  * Needs to be called with fs_mutex held
  */
-static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+static int btrfs_set_acl(struct btrfs_trans_handle *trans,
+                        struct inode *inode, struct posix_acl *acl, int type)
 {
        int ret, size = 0;
        const char *name;
@@ -140,8 +141,7 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
                        goto out;
        }
 
-       ret = __btrfs_setxattr(inode, name, value, size, 0);
-
+       ret = __btrfs_setxattr(trans, inode, name, value, size, 0);
 out:
        kfree(value);
 
@@ -151,10 +151,10 @@ out:
        return ret;
 }
 
-static int btrfs_xattr_set_acl(struct inode *inode, int type,
-                              const void *value, size_t size)
+static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
-       int ret = 0;
+       int ret;
        struct posix_acl *acl = NULL;
 
        if (value) {
@@ -167,38 +167,13 @@ static int btrfs_xattr_set_acl(struct inode *inode, int type,
                }
        }
 
-       ret = btrfs_set_acl(inode, acl, type);
+       ret = btrfs_set_acl(NULL, dentry->d_inode, acl, type);
 
        posix_acl_release(acl);
 
        return ret;
 }
 
-
-static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name,
-                                     void *value, size_t size)
-{
-       return btrfs_xattr_get_acl(inode, ACL_TYPE_ACCESS, value, size);
-}
-
-static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name,
-                                     const void *value, size_t size, int flags)
-{
-       return btrfs_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
-}
-
-static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name,
-                                      void *value, size_t size)
-{
-       return btrfs_xattr_get_acl(inode, ACL_TYPE_DEFAULT, value, size);
-}
-
-static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name,
-                              const void *value, size_t size, int flags)
-{
-       return btrfs_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
-}
-
 int btrfs_check_acl(struct inode *inode, int mask)
 {
        struct posix_acl *acl;
@@ -221,7 +196,8 @@ int btrfs_check_acl(struct inode *inode, int mask)
  * stuff has been fixed to work with that.  If the locking stuff changes, we
  * need to re-evaluate the acl locking stuff.
  */
-int btrfs_init_acl(struct inode *inode, struct inode *dir)
+int btrfs_init_acl(struct btrfs_trans_handle *trans,
+                  struct inode *inode, struct inode *dir)
 {
        struct posix_acl *acl = NULL;
        int ret = 0;
@@ -246,7 +222,8 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir)
                mode_t mode;
 
                if (S_ISDIR(inode->i_mode)) {
-                       ret = btrfs_set_acl(inode, acl, ACL_TYPE_DEFAULT);
+                       ret = btrfs_set_acl(trans, inode, acl,
+                                           ACL_TYPE_DEFAULT);
                        if (ret)
                                goto failed;
                }
@@ -261,7 +238,7 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir)
                        inode->i_mode = mode;
                        if (ret > 0) {
                                /* we need an acl */
-                               ret = btrfs_set_acl(inode, clone,
+                               ret = btrfs_set_acl(trans, inode, clone,
                                                    ACL_TYPE_ACCESS);
                        }
                }
@@ -294,7 +271,7 @@ int btrfs_acl_chmod(struct inode *inode)
 
        ret = posix_acl_chmod_masq(clone, inode->i_mode);
        if (!ret)
-               ret = btrfs_set_acl(inode, clone, ACL_TYPE_ACCESS);
+               ret = btrfs_set_acl(NULL, inode, clone, ACL_TYPE_ACCESS);
 
        posix_acl_release(clone);
 
@@ -303,14 +280,16 @@ int btrfs_acl_chmod(struct inode *inode)
 
 struct xattr_handler btrfs_xattr_acl_default_handler = {
        .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .get    = btrfs_xattr_acl_default_get,
-       .set    = btrfs_xattr_acl_default_set,
+       .flags  = ACL_TYPE_DEFAULT,
+       .get    = btrfs_xattr_acl_get,
+       .set    = btrfs_xattr_acl_set,
 };
 
 struct xattr_handler btrfs_xattr_acl_access_handler = {
        .prefix = POSIX_ACL_XATTR_ACCESS,
-       .get    = btrfs_xattr_acl_access_get,
-       .set    = btrfs_xattr_acl_access_set,
+       .flags  = ACL_TYPE_ACCESS,
+       .get    = btrfs_xattr_acl_get,
+       .set    = btrfs_xattr_acl_set,
 };
 
 #else /* CONFIG_BTRFS_FS_POSIX_ACL */
@@ -320,7 +299,8 @@ int btrfs_acl_chmod(struct inode *inode)
        return 0;
 }
 
-int btrfs_init_acl(struct inode *inode, struct inode *dir)
+int btrfs_init_acl(struct btrfs_trans_handle *trans,
+                  struct inode *inode, struct inode *dir)
 {
        return 0;
 }
index f6783a42f010965e344fddc68c2689a7d4a9fc14..3f1f50d9d916cf5e3c095101a3af0c220035f625 100644 (file)
@@ -44,9 +44,6 @@ struct btrfs_inode {
         */
        struct extent_io_tree io_failure_tree;
 
-       /* held while inesrting or deleting extents from files */
-       struct mutex extent_mutex;
-
        /* held while logging the inode in tree-log.c */
        struct mutex log_mutex;
 
@@ -166,7 +163,7 @@ static inline struct btrfs_inode *BTRFS_I(struct inode *inode)
 
 static inline void btrfs_i_size_write(struct inode *inode, u64 size)
 {
-       inode->i_size = size;
+       i_size_write(inode, size);
        BTRFS_I(inode)->disk_i_size = size;
 }
 
index ec96f3a6d536640919dd25a08c7ed22e4423ef15..c4bc570a396eebf5ede775dc39b004c9ff493227 100644 (file)
@@ -37,6 +37,11 @@ static int balance_node_right(struct btrfs_trans_handle *trans,
                              struct extent_buffer *src_buf);
 static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root,
                   struct btrfs_path *path, int level, int slot);
+static int setup_items_for_insert(struct btrfs_trans_handle *trans,
+                       struct btrfs_root *root, struct btrfs_path *path,
+                       struct btrfs_key *cpu_key, u32 *data_size,
+                       u32 total_data, u32 total_size, int nr);
+
 
 struct btrfs_path *btrfs_alloc_path(void)
 {
@@ -451,9 +456,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
                extent_buffer_get(cow);
                spin_unlock(&root->node_lock);
 
-               btrfs_free_extent(trans, root, buf->start, buf->len,
-                                 parent_start, root->root_key.objectid,
-                                 level, 0);
+               btrfs_free_tree_block(trans, root, buf->start, buf->len,
+                               parent_start, root->root_key.objectid, level);
                free_extent_buffer(buf);
                add_root_to_dirty_list(root);
        } else {
@@ -468,9 +472,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
                btrfs_set_node_ptr_generation(parent, parent_slot,
                                              trans->transid);
                btrfs_mark_buffer_dirty(parent);
-               btrfs_free_extent(trans, root, buf->start, buf->len,
-                                 parent_start, root->root_key.objectid,
-                                 level, 0);
+               btrfs_free_tree_block(trans, root, buf->start, buf->len,
+                               parent_start, root->root_key.objectid, level);
        }
        if (unlock_orig)
                btrfs_tree_unlock(buf);
@@ -1030,8 +1033,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
                btrfs_tree_unlock(mid);
                /* once for the path */
                free_extent_buffer(mid);
-               ret = btrfs_free_extent(trans, root, mid->start, mid->len,
-                                       0, root->root_key.objectid, level, 1);
+               ret = btrfs_free_tree_block(trans, root, mid->start, mid->len,
+                                           0, root->root_key.objectid, level);
                /* once for the root ptr */
                free_extent_buffer(mid);
                return ret;
@@ -1095,10 +1098,10 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
                                       1);
                        if (wret)
                                ret = wret;
-                       wret = btrfs_free_extent(trans, root, bytenr,
-                                                blocksize, 0,
-                                                root->root_key.objectid,
-                                                level, 0);
+                       wret = btrfs_free_tree_block(trans, root,
+                                                    bytenr, blocksize, 0,
+                                                    root->root_key.objectid,
+                                                    level);
                        if (wret)
                                ret = wret;
                } else {
@@ -1143,9 +1146,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
                wret = del_ptr(trans, root, path, level + 1, pslot);
                if (wret)
                        ret = wret;
-               wret = btrfs_free_extent(trans, root, bytenr, blocksize,
-                                        0, root->root_key.objectid,
-                                        level, 0);
+               wret = btrfs_free_tree_block(trans, root, bytenr, blocksize,
+                                        0, root->root_key.objectid, level);
                if (wret)
                        ret = wret;
        } else {
@@ -2997,75 +2999,85 @@ again:
        return ret;
 }
 
-/*
- * This function splits a single item into two items,
- * giving 'new_key' to the new item and splitting the
- * old one at split_offset (from the start of the item).
- *
- * The path may be released by this operation.  After
- * the split, the path is pointing to the old item.  The
- * new item is going to be in the same node as the old one.
- *
- * Note, the item being split must be smaller enough to live alone on
- * a tree block with room for one extra struct btrfs_item
- *
- * This allows us to split the item in place, keeping a lock on the
- * leaf the entire time.
- */
-int btrfs_split_item(struct btrfs_trans_handle *trans,
-                    struct btrfs_root *root,
-                    struct btrfs_path *path,
-                    struct btrfs_key *new_key,
-                    unsigned long split_offset)
+static noinline int setup_leaf_for_split(struct btrfs_trans_handle *trans,
+                                        struct btrfs_root *root,
+                                        struct btrfs_path *path, int ins_len)
 {
-       u32 item_size;
+       struct btrfs_key key;
        struct extent_buffer *leaf;
-       struct btrfs_key orig_key;
-       struct btrfs_item *item;
-       struct btrfs_item *new_item;
-       int ret = 0;
-       int slot;
-       u32 nritems;
-       u32 orig_offset;
-       struct btrfs_disk_key disk_key;
-       char *buf;
+       struct btrfs_file_extent_item *fi;
+       u64 extent_len = 0;
+       u32 item_size;
+       int ret;
 
        leaf = path->nodes[0];
-       btrfs_item_key_to_cpu(leaf, &orig_key, path->slots[0]);
-       if (btrfs_leaf_free_space(root, leaf) >= sizeof(struct btrfs_item))
-               goto split;
+       btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
+
+       BUG_ON(key.type != BTRFS_EXTENT_DATA_KEY &&
+              key.type != BTRFS_EXTENT_CSUM_KEY);
+
+       if (btrfs_leaf_free_space(root, leaf) >= ins_len)
+               return 0;
 
        item_size = btrfs_item_size_nr(leaf, path->slots[0]);
+       if (key.type == BTRFS_EXTENT_DATA_KEY) {
+               fi = btrfs_item_ptr(leaf, path->slots[0],
+                                   struct btrfs_file_extent_item);
+               extent_len = btrfs_file_extent_num_bytes(leaf, fi);
+       }
        btrfs_release_path(root, path);
 
-       path->search_for_split = 1;
        path->keep_locks = 1;
-
-       ret = btrfs_search_slot(trans, root, &orig_key, path, 0, 1);
+       path->search_for_split = 1;
+       ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
        path->search_for_split = 0;
+       if (ret < 0)
+               goto err;
 
+       ret = -EAGAIN;
+       leaf = path->nodes[0];
        /* if our item isn't there or got smaller, return now */
-       if (ret != 0 || item_size != btrfs_item_size_nr(path->nodes[0],
-                                                       path->slots[0])) {
-               path->keep_locks = 0;
-               return -EAGAIN;
+       if (ret > 0 || item_size != btrfs_item_size_nr(leaf, path->slots[0]))
+               goto err;
+
+       if (key.type == BTRFS_EXTENT_DATA_KEY) {
+               fi = btrfs_item_ptr(leaf, path->slots[0],
+                                   struct btrfs_file_extent_item);
+               if (extent_len != btrfs_file_extent_num_bytes(leaf, fi))
+                       goto err;
        }
 
        btrfs_set_path_blocking(path);
-       ret = split_leaf(trans, root, &orig_key, path,
-                        sizeof(struct btrfs_item), 1);
-       path->keep_locks = 0;
+       ret = split_leaf(trans, root, &key, path, ins_len, 1);
        BUG_ON(ret);
 
+       path->keep_locks = 0;
        btrfs_unlock_up_safe(path, 1);
+       return 0;
+err:
+       path->keep_locks = 0;
+       return ret;
+}
+
+static noinline int split_item(struct btrfs_trans_handle *trans,
+                              struct btrfs_root *root,
+                              struct btrfs_path *path,
+                              struct btrfs_key *new_key,
+                              unsigned long split_offset)
+{
+       struct extent_buffer *leaf;
+       struct btrfs_item *item;
+       struct btrfs_item *new_item;
+       int slot;
+       char *buf;
+       u32 nritems;
+       u32 item_size;
+       u32 orig_offset;
+       struct btrfs_disk_key disk_key;
+
        leaf = path->nodes[0];
        BUG_ON(btrfs_leaf_free_space(root, leaf) < sizeof(struct btrfs_item));
 
-split:
-       /*
-        * make sure any changes to the path from split_leaf leave it
-        * in a blocking state
-        */
        btrfs_set_path_blocking(path);
 
        item = btrfs_item_nr(leaf, path->slots[0]);
@@ -3073,19 +3085,19 @@ split:
        item_size = btrfs_item_size(leaf, item);
 
        buf = kmalloc(item_size, GFP_NOFS);
+       if (!buf)
+               return -ENOMEM;
+
        read_extent_buffer(leaf, buf, btrfs_item_ptr_offset(leaf,
                            path->slots[0]), item_size);
-       slot = path->slots[0] + 1;
-       leaf = path->nodes[0];
 
+       slot = path->slots[0] + 1;
        nritems = btrfs_header_nritems(leaf);
-
        if (slot != nritems) {
                /* shift the items */
                memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + 1),
-                             btrfs_item_nr_offset(slot),
-                             (nritems - slot) * sizeof(struct btrfs_item));
-
+                               btrfs_item_nr_offset(slot),
+                               (nritems - slot) * sizeof(struct btrfs_item));
        }
 
        btrfs_cpu_key_to_disk(&disk_key, new_key);
@@ -3113,15 +3125,80 @@ split:
                            item_size - split_offset);
        btrfs_mark_buffer_dirty(leaf);
 
-       ret = 0;
-       if (btrfs_leaf_free_space(root, leaf) < 0) {
-               btrfs_print_leaf(root, leaf);
-               BUG();
-       }
+       BUG_ON(btrfs_leaf_free_space(root, leaf) < 0);
        kfree(buf);
+       return 0;
+}
+
+/*
+ * This function splits a single item into two items,
+ * giving 'new_key' to the new item and splitting the
+ * old one at split_offset (from the start of the item).
+ *
+ * The path may be released by this operation.  After
+ * the split, the path is pointing to the old item.  The
+ * new item is going to be in the same node as the old one.
+ *
+ * Note, the item being split must be smaller enough to live alone on
+ * a tree block with room for one extra struct btrfs_item
+ *
+ * This allows us to split the item in place, keeping a lock on the
+ * leaf the entire time.
+ */
+int btrfs_split_item(struct btrfs_trans_handle *trans,
+                    struct btrfs_root *root,
+                    struct btrfs_path *path,
+                    struct btrfs_key *new_key,
+                    unsigned long split_offset)
+{
+       int ret;
+       ret = setup_leaf_for_split(trans, root, path,
+                                  sizeof(struct btrfs_item));
+       if (ret)
+               return ret;
+
+       ret = split_item(trans, root, path, new_key, split_offset);
        return ret;
 }
 
+/*
+ * This function duplicate a item, giving 'new_key' to the new item.
+ * It guarantees both items live in the same tree leaf and the new item
+ * is contiguous with the original item.
+ *
+ * This allows us to split file extent in place, keeping a lock on the
+ * leaf the entire time.
+ */
+int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
+                        struct btrfs_root *root,
+                        struct btrfs_path *path,
+                        struct btrfs_key *new_key)
+{
+       struct extent_buffer *leaf;
+       int ret;
+       u32 item_size;
+
+       leaf = path->nodes[0];
+       item_size = btrfs_item_size_nr(leaf, path->slots[0]);
+       ret = setup_leaf_for_split(trans, root, path,
+                                  item_size + sizeof(struct btrfs_item));
+       if (ret)
+               return ret;
+
+       path->slots[0]++;
+       ret = setup_items_for_insert(trans, root, path, new_key, &item_size,
+                                    item_size, item_size +
+                                    sizeof(struct btrfs_item), 1);
+       BUG_ON(ret);
+
+       leaf = path->nodes[0];
+       memcpy_extent_buffer(leaf,
+                            btrfs_item_ptr_offset(leaf, path->slots[0]),
+                            btrfs_item_ptr_offset(leaf, path->slots[0] - 1),
+                            item_size);
+       return 0;
+}
+
 /*
  * make the item pointed to by the path smaller.  new_size indicates
  * how small to make it, and from_end tells us if we just chop bytes
@@ -3714,8 +3791,8 @@ static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans,
         */
        btrfs_unlock_up_safe(path, 0);
 
-       ret = btrfs_free_extent(trans, root, leaf->start, leaf->len,
-                               0, root->root_key.objectid, 0, 0);
+       ret = btrfs_free_tree_block(trans, root, leaf->start, leaf->len,
+                                   0, root->root_key.objectid, 0);
        return ret;
 }
 /*
index 444b3e9b92a4b88391fd610a76346530436baa01..9f806dd04c2704899bf28e5324eebaa14a923e27 100644 (file)
@@ -310,6 +310,9 @@ struct btrfs_header {
 #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
                                        sizeof(struct btrfs_item) - \
                                        sizeof(struct btrfs_file_extent_item))
+#define BTRFS_MAX_XATTR_SIZE(r)        (BTRFS_LEAF_DATA_SIZE(r) - \
+                                sizeof(struct btrfs_item) -\
+                                sizeof(struct btrfs_dir_item))
 
 
 /*
@@ -859,8 +862,9 @@ struct btrfs_fs_info {
        struct mutex ordered_operations_mutex;
        struct rw_semaphore extent_commit_sem;
 
-       struct rw_semaphore subvol_sem;
+       struct rw_semaphore cleanup_work_sem;
 
+       struct rw_semaphore subvol_sem;
        struct srcu_struct subvol_srcu;
 
        struct list_head trans_list;
@@ -868,6 +872,9 @@ struct btrfs_fs_info {
        struct list_head dead_roots;
        struct list_head caching_block_groups;
 
+       spinlock_t delayed_iput_lock;
+       struct list_head delayed_iputs;
+
        atomic_t nr_async_submits;
        atomic_t async_submit_draining;
        atomic_t nr_async_bios;
@@ -1034,12 +1041,12 @@ struct btrfs_root {
        int ref_cows;
        int track_dirty;
        int in_radix;
+       int clean_orphans;
 
        u64 defrag_trans_start;
        struct btrfs_key defrag_progress;
        struct btrfs_key defrag_max;
        int defrag_running;
-       int defrag_level;
        char *name;
        int in_sysfs;
 
@@ -1975,6 +1982,10 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
                                        u64 parent, u64 root_objectid,
                                        struct btrfs_disk_key *key, int level,
                                        u64 hint, u64 empty_size);
+int btrfs_free_tree_block(struct btrfs_trans_handle *trans,
+                         struct btrfs_root *root,
+                         u64 bytenr, u32 blocksize,
+                         u64 parent, u64 root_objectid, int level);
 struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans,
                                            struct btrfs_root *root,
                                            u64 bytenr, u32 blocksize,
@@ -2089,6 +2100,10 @@ int btrfs_split_item(struct btrfs_trans_handle *trans,
                     struct btrfs_path *path,
                     struct btrfs_key *new_key,
                     unsigned long split_offset);
+int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
+                        struct btrfs_root *root,
+                        struct btrfs_path *path,
+                        struct btrfs_key *new_key);
 int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
                      *root, struct btrfs_key *key, struct btrfs_path *p, int
                      ins_len, int cow);
@@ -2196,9 +2211,10 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans,
                              struct btrfs_path *path,
                              struct btrfs_dir_item *di);
 int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
-                           struct btrfs_root *root, const char *name,
-                           u16 name_len, const void *data, u16 data_len,
-                           u64 dir);
+                           struct btrfs_root *root,
+                           struct btrfs_path *path, u64 objectid,
+                           const char *name, u16 name_len,
+                           const void *data, u16 data_len);
 struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
                                          struct btrfs_root *root,
                                          struct btrfs_path *path, u64 dir,
@@ -2292,7 +2308,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
                               struct inode *inode, u64 new_size,
                               u32 min_type);
 
-int btrfs_start_delalloc_inodes(struct btrfs_root *root);
+int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput);
 int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end);
 int btrfs_writepages(struct address_space *mapping,
                     struct writeback_control *wbc);
@@ -2332,6 +2348,8 @@ int btrfs_orphan_del(struct btrfs_trans_handle *trans, struct inode *inode);
 void btrfs_orphan_cleanup(struct btrfs_root *root);
 int btrfs_cont_expand(struct inode *inode, loff_t size);
 int btrfs_invalidate_inodes(struct btrfs_root *root);
+void btrfs_add_delayed_iput(struct inode *inode);
+void btrfs_run_delayed_iputs(struct btrfs_root *root);
 extern const struct dentry_operations btrfs_dentry_operations;
 
 /* ioctl.c */
@@ -2345,12 +2363,9 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
                            int skip_pinned);
 int btrfs_check_file(struct btrfs_root *root, struct inode *inode);
 extern const struct file_operations btrfs_file_operations;
-int btrfs_drop_extents(struct btrfs_trans_handle *trans,
-                      struct btrfs_root *root, struct inode *inode,
-                      u64 start, u64 end, u64 locked_end,
-                      u64 inline_limit, u64 *hint_block, int drop_cache);
+int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode,
+                      u64 start, u64 end, u64 *hint_byte, int drop_cache);
 int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
-                             struct btrfs_root *root,
                              struct inode *inode, u64 start, u64 end);
 int btrfs_release_file(struct inode *inode, struct file *file);
 
@@ -2380,7 +2395,8 @@ int btrfs_check_acl(struct inode *inode, int mask);
 #else
 #define btrfs_check_acl NULL
 #endif
-int btrfs_init_acl(struct inode *inode, struct inode *dir);
+int btrfs_init_acl(struct btrfs_trans_handle *trans,
+                  struct inode *inode, struct inode *dir);
 int btrfs_acl_chmod(struct inode *inode);
 
 /* relocation.c */
index f3a6075519ccc1d96e42157f95769a5ad6641a12..e9103b3baa49f4309c94eca9e0d7b7069665359c 100644 (file)
@@ -68,12 +68,12 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle
  * into the tree
  */
 int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
-                           struct btrfs_root *root, const char *name,
-                           u16 name_len, const void *data, u16 data_len,
-                           u64 dir)
+                           struct btrfs_root *root,
+                           struct btrfs_path *path, u64 objectid,
+                           const char *name, u16 name_len,
+                           const void *data, u16 data_len)
 {
        int ret = 0;
-       struct btrfs_path *path;
        struct btrfs_dir_item *dir_item;
        unsigned long name_ptr, data_ptr;
        struct btrfs_key key, location;
@@ -81,15 +81,11 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
        struct extent_buffer *leaf;
        u32 data_size;
 
-       key.objectid = dir;
+       BUG_ON(name_len + data_len > BTRFS_MAX_XATTR_SIZE(root));
+
+       key.objectid = objectid;
        btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY);
        key.offset = btrfs_name_hash(name, name_len);
-       path = btrfs_alloc_path();
-       if (!path)
-               return -ENOMEM;
-       if (name_len + data_len + sizeof(struct btrfs_dir_item) >
-           BTRFS_LEAF_DATA_SIZE(root) - sizeof(struct btrfs_item))
-               return -ENOSPC;
 
        data_size = sizeof(*dir_item) + name_len + data_len;
        dir_item = insert_with_overflow(trans, root, path, &key, data_size,
@@ -117,7 +113,6 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
        write_extent_buffer(leaf, data, data_ptr, data_len);
        btrfs_mark_buffer_dirty(path->nodes[0]);
 
-       btrfs_free_path(path);
        return ret;
 }
 
index 02b6afbd745020fb51bf43d88c93025459687e12..009e3bd18f23d986a685c50f60e3be73a5020f31 100644 (file)
@@ -892,6 +892,8 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
        root->stripesize = stripesize;
        root->ref_cows = 0;
        root->track_dirty = 0;
+       root->in_radix = 0;
+       root->clean_orphans = 0;
 
        root->fs_info = fs_info;
        root->objectid = objectid;
@@ -928,7 +930,6 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize,
        root->defrag_trans_start = fs_info->generation;
        init_completion(&root->kobj_unregister);
        root->defrag_running = 0;
-       root->defrag_level = 0;
        root->root_key.objectid = objectid;
        root->anon_super.s_root = NULL;
        root->anon_super.s_dev = 0;
@@ -980,12 +981,12 @@ int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans,
 
        while (1) {
                ret = find_first_extent_bit(&log_root_tree->dirty_log_pages,
-                                   0, &start, &end, EXTENT_DIRTY);
+                               0, &start, &end, EXTENT_DIRTY | EXTENT_NEW);
                if (ret)
                        break;
 
-               clear_extent_dirty(&log_root_tree->dirty_log_pages,
-                                  start, end, GFP_NOFS);
+               clear_extent_bits(&log_root_tree->dirty_log_pages, start, end,
+                                 EXTENT_DIRTY | EXTENT_NEW, GFP_NOFS);
        }
        eb = fs_info->log_root_tree->node;
 
@@ -1210,8 +1211,10 @@ again:
        ret = radix_tree_insert(&fs_info->fs_roots_radix,
                                (unsigned long)root->root_key.objectid,
                                root);
-       if (ret == 0)
+       if (ret == 0) {
                root->in_radix = 1;
+               root->clean_orphans = 1;
+       }
        spin_unlock(&fs_info->fs_roots_radix_lock);
        radix_tree_preload_end();
        if (ret) {
@@ -1225,10 +1228,6 @@ again:
        ret = btrfs_find_dead_roots(fs_info->tree_root,
                                    root->root_key.objectid);
        WARN_ON(ret);
-
-       if (!(fs_info->sb->s_flags & MS_RDONLY))
-               btrfs_orphan_cleanup(root);
-
        return root;
 fail:
        free_fs_root(root);
@@ -1477,6 +1476,7 @@ static int cleaner_kthread(void *arg)
 
                if (!(root->fs_info->sb->s_flags & MS_RDONLY) &&
                    mutex_trylock(&root->fs_info->cleaner_mutex)) {
+                       btrfs_run_delayed_iputs(root);
                        btrfs_clean_old_snapshots(root);
                        mutex_unlock(&root->fs_info->cleaner_mutex);
                }
@@ -1606,6 +1606,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
        INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC);
        INIT_LIST_HEAD(&fs_info->trans_list);
        INIT_LIST_HEAD(&fs_info->dead_roots);
+       INIT_LIST_HEAD(&fs_info->delayed_iputs);
        INIT_LIST_HEAD(&fs_info->hashers);
        INIT_LIST_HEAD(&fs_info->delalloc_inodes);
        INIT_LIST_HEAD(&fs_info->ordered_operations);
@@ -1614,6 +1615,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
        spin_lock_init(&fs_info->new_trans_lock);
        spin_lock_init(&fs_info->ref_cache_lock);
        spin_lock_init(&fs_info->fs_roots_radix_lock);
+       spin_lock_init(&fs_info->delayed_iput_lock);
 
        init_completion(&fs_info->kobj_unregister);
        fs_info->tree_root = tree_root;
@@ -1689,6 +1691,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
        mutex_init(&fs_info->cleaner_mutex);
        mutex_init(&fs_info->volume_mutex);
        init_rwsem(&fs_info->extent_commit_sem);
+       init_rwsem(&fs_info->cleanup_work_sem);
        init_rwsem(&fs_info->subvol_sem);
 
        btrfs_init_free_cluster(&fs_info->meta_alloc_cluster);
@@ -2386,8 +2389,14 @@ int btrfs_commit_super(struct btrfs_root *root)
        int ret;
 
        mutex_lock(&root->fs_info->cleaner_mutex);
+       btrfs_run_delayed_iputs(root);
        btrfs_clean_old_snapshots(root);
        mutex_unlock(&root->fs_info->cleaner_mutex);
+
+       /* wait until ongoing cleanup work done */
+       down_write(&root->fs_info->cleanup_work_sem);
+       up_write(&root->fs_info->cleanup_work_sem);
+
        trans = btrfs_start_transaction(root, 1);
        ret = btrfs_commit_transaction(trans, root);
        BUG_ON(ret);
index 94627c4cc193343aacc82b3aca1a6e9eaaefd8dd..56e50137d0e6d066266c074b1e07e10d10cb1b5f 100644 (file)
@@ -195,6 +195,14 @@ static int exclude_super_stripes(struct btrfs_root *root,
        int stripe_len;
        int i, nr, ret;
 
+       if (cache->key.objectid < BTRFS_SUPER_INFO_OFFSET) {
+               stripe_len = BTRFS_SUPER_INFO_OFFSET - cache->key.objectid;
+               cache->bytes_super += stripe_len;
+               ret = add_excluded_extent(root, cache->key.objectid,
+                                         stripe_len);
+               BUG_ON(ret);
+       }
+
        for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) {
                bytenr = btrfs_sb_offset(i);
                ret = btrfs_rmap_block(&root->fs_info->mapping_tree,
@@ -255,7 +263,7 @@ static u64 add_new_free_space(struct btrfs_block_group_cache *block_group,
                if (ret)
                        break;
 
-               if (extent_start == start) {
+               if (extent_start <= start) {
                        start = extent_end + 1;
                } else if (extent_start > start && extent_start < end) {
                        size = extent_start - start;
@@ -2880,9 +2888,9 @@ static noinline void flush_delalloc_async(struct btrfs_work *work)
        root = async->root;
        info = async->info;
 
-       btrfs_start_delalloc_inodes(root);
+       btrfs_start_delalloc_inodes(root, 0);
        wake_up(&info->flush_wait);
-       btrfs_wait_ordered_extents(root, 0);
+       btrfs_wait_ordered_extents(root, 0, 0);
 
        spin_lock(&info->lock);
        info->flushing = 0;
@@ -2956,8 +2964,8 @@ static void flush_delalloc(struct btrfs_root *root,
        return;
 
 flush:
-       btrfs_start_delalloc_inodes(root);
-       btrfs_wait_ordered_extents(root, 0);
+       btrfs_start_delalloc_inodes(root, 0);
+       btrfs_wait_ordered_extents(root, 0, 0);
 
        spin_lock(&info->lock);
        info->flushing = 0;
@@ -3454,14 +3462,6 @@ static int update_block_group(struct btrfs_trans_handle *trans,
        else
                old_val -= num_bytes;
        btrfs_set_super_bytes_used(&info->super_copy, old_val);
-
-       /* block accounting for root item */
-       old_val = btrfs_root_used(&root->root_item);
-       if (alloc)
-               old_val += num_bytes;
-       else
-               old_val -= num_bytes;
-       btrfs_set_root_used(&root->root_item, old_val);
        spin_unlock(&info->delalloc_lock);
 
        while (total) {
@@ -4049,6 +4049,21 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
        return ret;
 }
 
+int btrfs_free_tree_block(struct btrfs_trans_handle *trans,
+                         struct btrfs_root *root,
+                         u64 bytenr, u32 blocksize,
+                         u64 parent, u64 root_objectid, int level)
+{
+       u64 used;
+       spin_lock(&root->node_lock);
+       used = btrfs_root_used(&root->root_item) - blocksize;
+       btrfs_set_root_used(&root->root_item, used);
+       spin_unlock(&root->node_lock);
+
+       return btrfs_free_extent(trans, root, bytenr, blocksize,
+                                parent, root_objectid, level, 0);
+}
+
 static u64 stripe_align(struct btrfs_root *root, u64 val)
 {
        u64 mask = ((u64)root->stripesize - 1);
@@ -4578,7 +4593,6 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans,
 {
        int ret;
        u64 search_start = 0;
-       struct btrfs_fs_info *info = root->fs_info;
 
        data = btrfs_get_alloc_profile(root, data);
 again:
@@ -4586,17 +4600,9 @@ again:
         * the only place that sets empty_size is btrfs_realloc_node, which
         * is not called recursively on allocations
         */
-       if (empty_size || root->ref_cows) {
-               if (!(data & BTRFS_BLOCK_GROUP_METADATA)) {
-                       ret = do_chunk_alloc(trans, root->fs_info->extent_root,
-                                    2 * 1024 * 1024,
-                                    BTRFS_BLOCK_GROUP_METADATA |
-                                    (info->metadata_alloc_profile &
-                                     info->avail_metadata_alloc_bits), 0);
-               }
+       if (empty_size || root->ref_cows)
                ret = do_chunk_alloc(trans, root->fs_info->extent_root,
                                     num_bytes + 2 * 1024 * 1024, data, 0);
-       }
 
        WARN_ON(num_bytes < root->sectorsize);
        ret = find_free_extent(trans, root, num_bytes, empty_size,
@@ -4897,6 +4903,14 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
                                        extent_op);
                BUG_ON(ret);
        }
+
+       if (root_objectid == root->root_key.objectid) {
+               u64 used;
+               spin_lock(&root->node_lock);
+               used = btrfs_root_used(&root->root_item) + num_bytes;
+               btrfs_set_root_used(&root->root_item, used);
+               spin_unlock(&root->node_lock);
+       }
        return ret;
 }
 
@@ -4919,8 +4933,16 @@ struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans,
        btrfs_set_buffer_uptodate(buf);
 
        if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) {
-               set_extent_dirty(&root->dirty_log_pages, buf->start,
-                        buf->start + buf->len - 1, GFP_NOFS);
+               /*
+                * we allow two log transactions at a time, use different
+                * EXENT bit to differentiate dirty pages.
+                */
+               if (root->log_transid % 2 == 0)
+                       set_extent_dirty(&root->dirty_log_pages, buf->start,
+                                       buf->start + buf->len - 1, GFP_NOFS);
+               else
+                       set_extent_new(&root->dirty_log_pages, buf->start,
+                                       buf->start + buf->len - 1, GFP_NOFS);
        } else {
                set_extent_dirty(&trans->transaction->dirty_pages, buf->start,
                         buf->start + buf->len - 1, GFP_NOFS);
index 77f759302e125da0467e8a3ff3341b6ee11f0b97..feaa13b105d953f1be72c50897fafa6943cd5e50 100644 (file)
@@ -179,18 +179,14 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
                }
                flags = em->flags;
                if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) {
-                       if (em->start <= start &&
-                           (!testend || em->start + em->len >= start + len)) {
+                       if (testend && em->start + em->len >= start + len) {
                                free_extent_map(em);
                                write_unlock(&em_tree->lock);
                                break;
                        }
-                       if (start < em->start) {
-                               len = em->start - start;
-                       } else {
+                       start = em->start + em->len;
+                       if (testend)
                                len = start + len - (em->start + em->len);
-                               start = em->start + em->len;
-                       }
                        free_extent_map(em);
                        write_unlock(&em_tree->lock);
                        continue;
@@ -265,319 +261,247 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
  * If an extent intersects the range but is not entirely inside the range
  * it is either truncated or split.  Anything entirely inside the range
  * is deleted from the tree.
- *
- * inline_limit is used to tell this code which offsets in the file to keep
- * if they contain inline extents.
  */
-noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans,
-                      struct btrfs_root *root, struct inode *inode,
-                      u64 start, u64 end, u64 locked_end,
-                      u64 inline_limit, u64 *hint_byte, int drop_cache)
+int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode,
+                      u64 start, u64 end, u64 *hint_byte, int drop_cache)
 {
-       u64 extent_end = 0;
-       u64 search_start = start;
-       u64 ram_bytes = 0;
-       u64 disk_bytenr = 0;
-       u64 orig_locked_end = locked_end;
-       u8 compression;
-       u8 encryption;
-       u16 other_encoding = 0;
+       struct btrfs_root *root = BTRFS_I(inode)->root;
        struct extent_buffer *leaf;
-       struct btrfs_file_extent_item *extent;
+       struct btrfs_file_extent_item *fi;
        struct btrfs_path *path;
        struct btrfs_key key;
-       struct btrfs_file_extent_item old;
-       int keep;
-       int slot;
-       int bookend;
-       int found_type = 0;
-       int found_extent;
-       int found_inline;
+       struct btrfs_key new_key;
+       u64 search_start = start;
+       u64 disk_bytenr = 0;
+       u64 num_bytes = 0;
+       u64 extent_offset = 0;
+       u64 extent_end = 0;
+       int del_nr = 0;
+       int del_slot = 0;
+       int extent_type;
        int recow;
        int ret;
 
-       inline_limit = 0;
        if (drop_cache)
                btrfs_drop_extent_cache(inode, start, end - 1, 0);
 
        path = btrfs_alloc_path();
        if (!path)
                return -ENOMEM;
+
        while (1) {
                recow = 0;
-               btrfs_release_path(root, path);
                ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino,
                                               search_start, -1);
                if (ret < 0)
-                       goto out;
-               if (ret > 0) {
-                       if (path->slots[0] == 0) {
-                               ret = 0;
-                               goto out;
-                       }
-                       path->slots[0]--;
+                       break;
+               if (ret > 0 && path->slots[0] > 0 && search_start == start) {
+                       leaf = path->nodes[0];
+                       btrfs_item_key_to_cpu(leaf, &key, path->slots[0] - 1);
+                       if (key.objectid == inode->i_ino &&
+                           key.type == BTRFS_EXTENT_DATA_KEY)
+                               path->slots[0]--;
                }
+               ret = 0;
 next_slot:
-               keep = 0;
-               bookend = 0;
-               found_extent = 0;
-               found_inline = 0;
-               compression = 0;
-               encryption = 0;
-               extent = NULL;
                leaf = path->nodes[0];
-               slot = path->slots[0];
-               ret = 0;
-               btrfs_item_key_to_cpu(leaf, &key, slot);
-               if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY &&
-                   key.offset >= end) {
-                       goto out;
-               }
-               if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY ||
-                   key.objectid != inode->i_ino) {
-                       goto out;
-               }
-               if (recow) {
-                       search_start = max(key.offset, start);
-                       continue;
-               }
-               if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) {
-                       extent = btrfs_item_ptr(leaf, slot,
-                                               struct btrfs_file_extent_item);
-                       found_type = btrfs_file_extent_type(leaf, extent);
-                       compression = btrfs_file_extent_compression(leaf,
-                                                                   extent);
-                       encryption = btrfs_file_extent_encryption(leaf,
-                                                                 extent);
-                       other_encoding = btrfs_file_extent_other_encoding(leaf,
-                                                                 extent);
-                       if (found_type == BTRFS_FILE_EXTENT_REG ||
-                           found_type == BTRFS_FILE_EXTENT_PREALLOC) {
-                               extent_end =
-                                    btrfs_file_extent_disk_bytenr(leaf,
-                                                                  extent);
-                               if (extent_end)
-                                       *hint_byte = extent_end;
-
-                               extent_end = key.offset +
-                                    btrfs_file_extent_num_bytes(leaf, extent);
-                               ram_bytes = btrfs_file_extent_ram_bytes(leaf,
-                                                               extent);
-                               found_extent = 1;
-                       } else if (found_type == BTRFS_FILE_EXTENT_INLINE) {
-                               found_inline = 1;
-                               extent_end = key.offset +
-                                    btrfs_file_extent_inline_len(leaf, extent);
+               if (path->slots[0] >= btrfs_header_nritems(leaf)) {
+                       BUG_ON(del_nr > 0);
+                       ret = btrfs_next_leaf(root, path);
+                       if (ret < 0)
+                               break;
+                       if (ret > 0) {
+                               ret = 0;
+                               break;
                        }
+                       leaf = path->nodes[0];
+                       recow = 1;
+               }
+
+               btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
+               if (key.objectid > inode->i_ino ||
+                   key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end)
+                       break;
+
+               fi = btrfs_item_ptr(leaf, path->slots[0],
+                                   struct btrfs_file_extent_item);
+               extent_type = btrfs_file_extent_type(leaf, fi);
+
+               if (extent_type == BTRFS_FILE_EXTENT_REG ||
+                   extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
+                       disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi);
+                       num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi);
+                       extent_offset = btrfs_file_extent_offset(leaf, fi);
+                       extent_end = key.offset +
+                               btrfs_file_extent_num_bytes(leaf, fi);
+               } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
+                       extent_end = key.offset +
+                               btrfs_file_extent_inline_len(leaf, fi);
                } else {
+                       WARN_ON(1);
                        extent_end = search_start;
                }
 
-               /* we found nothing we can drop */
-               if ((!found_extent && !found_inline) ||
-                   search_start >= extent_end) {
-                       int nextret;
-                       u32 nritems;
-                       nritems = btrfs_header_nritems(leaf);
-                       if (slot >= nritems - 1) {
-                               nextret = btrfs_next_leaf(root, path);
-                               if (nextret)
-                                       goto out;
-                               recow = 1;
-                       } else {
-                               path->slots[0]++;
-                       }
+               if (extent_end <= search_start) {
+                       path->slots[0]++;
                        goto next_slot;
                }
 
-               if (end <= extent_end && start >= key.offset && found_inline)
-                       *hint_byte = EXTENT_MAP_INLINE;
-
-               if (found_extent) {
-                       read_extent_buffer(leaf, &old, (unsigned long)extent,
-                                          sizeof(old));
-               }
-
-               if (end < extent_end && end >= key.offset) {
-                       bookend = 1;
-                       if (found_inline && start <= key.offset)
-                               keep = 1;
+               search_start = max(key.offset, start);
+               if (recow) {
+                       btrfs_release_path(root, path);
+                       continue;
                }
 
-               if (bookend && found_extent) {
-                       if (locked_end < extent_end) {
-                               ret = try_lock_extent(&BTRFS_I(inode)->io_tree,
-                                               locked_end, extent_end - 1,
-                                               GFP_NOFS);
-                               if (!ret) {
-                                       btrfs_release_path(root, path);
-                                       lock_extent(&BTRFS_I(inode)->io_tree,
-                                               locked_end, extent_end - 1,
-                                               GFP_NOFS);
-                                       locked_end = extent_end;
-                                       continue;
-                               }
-                               locked_end = extent_end;
+               /*
+                *     | - range to drop - |
+                *  | -------- extent -------- |
+                */
+               if (start > key.offset && end < extent_end) {
+                       BUG_ON(del_nr > 0);
+                       BUG_ON(extent_type == BTRFS_FILE_EXTENT_INLINE);
+
+                       memcpy(&new_key, &key, sizeof(new_key));
+                       new_key.offset = start;
+                       ret = btrfs_duplicate_item(trans, root, path,
+                                                  &new_key);
+                       if (ret == -EAGAIN) {
+                               btrfs_release_path(root, path);
+                               continue;
                        }
-                       disk_bytenr = le64_to_cpu(old.disk_bytenr);
-                       if (disk_bytenr != 0) {
+                       if (ret < 0)
+                               break;
+
+                       leaf = path->nodes[0];
+                       fi = btrfs_item_ptr(leaf, path->slots[0] - 1,
+                                           struct btrfs_file_extent_item);
+                       btrfs_set_file_extent_num_bytes(leaf, fi,
+                                                       start - key.offset);
+
+                       fi = btrfs_item_ptr(leaf, path->slots[0],
+                                           struct btrfs_file_extent_item);
+
+                       extent_offset += start - key.offset;
+                       btrfs_set_file_extent_offset(leaf, fi, extent_offset);
+                       btrfs_set_file_extent_num_bytes(leaf, fi,
+                                                       extent_end - start);
+                       btrfs_mark_buffer_dirty(leaf);
+
+                       if (disk_bytenr > 0) {
                                ret = btrfs_inc_extent_ref(trans, root,
-                                          disk_bytenr,
-                                          le64_to_cpu(old.disk_num_bytes), 0,
-                                          root->root_key.objectid,
-                                          key.objectid, key.offset -
-                                          le64_to_cpu(old.offset));
+                                               disk_bytenr, num_bytes, 0,
+                                               root->root_key.objectid,
+                                               new_key.objectid,
+                                               start - extent_offset);
                                BUG_ON(ret);
+                               *hint_byte = disk_bytenr;
                        }
+                       key.offset = start;
                }
+               /*
+                *  | ---- range to drop ----- |
+                *      | -------- extent -------- |
+                */
+               if (start <= key.offset && end < extent_end) {
+                       BUG_ON(extent_type == BTRFS_FILE_EXTENT_INLINE);
 
-               if (found_inline) {
-                       u64 mask = root->sectorsize - 1;
-                       search_start = (extent_end + mask) & ~mask;
-               } else
-                       search_start = extent_end;
-
-               /* truncate existing extent */
-               if (start > key.offset) {
-                       u64 new_num;
-                       u64 old_num;
-                       keep = 1;
-                       WARN_ON(start & (root->sectorsize - 1));
-                       if (found_extent) {
-                               new_num = start - key.offset;
-                               old_num = btrfs_file_extent_num_bytes(leaf,
-                                                                     extent);
-                               *hint_byte =
-                                       btrfs_file_extent_disk_bytenr(leaf,
-                                                                     extent);
-                               if (btrfs_file_extent_disk_bytenr(leaf,
-                                                                 extent)) {
-                                       inode_sub_bytes(inode, old_num -
-                                                       new_num);
-                               }
-                               btrfs_set_file_extent_num_bytes(leaf,
-                                                       extent, new_num);
-                               btrfs_mark_buffer_dirty(leaf);
-                       } else if (key.offset < inline_limit &&
-                                  (end > extent_end) &&
-                                  (inline_limit < extent_end)) {
-                               u32 new_size;
-                               new_size = btrfs_file_extent_calc_inline_size(
-                                                  inline_limit - key.offset);
-                               inode_sub_bytes(inode, extent_end -
-                                               inline_limit);
-                               btrfs_set_file_extent_ram_bytes(leaf, extent,
-                                                       new_size);
-                               if (!compression && !encryption) {
-                                       btrfs_truncate_item(trans, root, path,
-                                                           new_size, 1);
-                               }
+                       memcpy(&new_key, &key, sizeof(new_key));
+                       new_key.offset = end;
+                       btrfs_set_item_key_safe(trans, root, path, &new_key);
+
+                       extent_offset += end - key.offset;
+                       btrfs_set_file_extent_offset(leaf, fi, extent_offset);
+                       btrfs_set_file_extent_num_bytes(leaf, fi,
+                                                       extent_end - end);
+                       btrfs_mark_buffer_dirty(leaf);
+                       if (disk_bytenr > 0) {
+                               inode_sub_bytes(inode, end - key.offset);
+                               *hint_byte = disk_bytenr;
                        }
+                       break;
                }
-               /* delete the entire extent */
-               if (!keep) {
-                       if (found_inline)
-                               inode_sub_bytes(inode, extent_end -
-                                               key.offset);
-                       ret = btrfs_del_item(trans, root, path);
-                       /* TODO update progress marker and return */
-                       BUG_ON(ret);
-                       extent = NULL;
-                       btrfs_release_path(root, path);
-                       /* the extent will be freed later */
-               }
-               if (bookend && found_inline && start <= key.offset) {
-                       u32 new_size;
-                       new_size = btrfs_file_extent_calc_inline_size(
-                                                  extent_end - end);
-                       inode_sub_bytes(inode, end - key.offset);
-                       btrfs_set_file_extent_ram_bytes(leaf, extent,
-                                                       new_size);
-                       if (!compression && !encryption)
-                               ret = btrfs_truncate_item(trans, root, path,
-                                                         new_size, 0);
-                       BUG_ON(ret);
-               }
-               /* create bookend, splitting the extent in two */
-               if (bookend && found_extent) {
-                       struct btrfs_key ins;
-                       ins.objectid = inode->i_ino;
-                       ins.offset = end;
-                       btrfs_set_key_type(&ins, BTRFS_EXTENT_DATA_KEY);
 
-                       btrfs_release_path(root, path);
-                       path->leave_spinning = 1;
-                       ret = btrfs_insert_empty_item(trans, root, path, &ins,
-                                                     sizeof(*extent));
-                       BUG_ON(ret);
+               search_start = extent_end;
+               /*
+                *       | ---- range to drop ----- |
+                *  | -------- extent -------- |
+                */
+               if (start > key.offset && end >= extent_end) {
+                       BUG_ON(del_nr > 0);
+                       BUG_ON(extent_type == BTRFS_FILE_EXTENT_INLINE);
 
-                       leaf = path->nodes[0];
-                       extent = btrfs_item_ptr(leaf, path->slots[0],
-                                               struct btrfs_file_extent_item);
-                       write_extent_buffer(leaf, &old,
-                                           (unsigned long)extent, sizeof(old));
-
-                       btrfs_set_file_extent_compression(leaf, extent,
-                                                         compression);
-                       btrfs_set_file_extent_encryption(leaf, extent,
-                                                        encryption);
-                       btrfs_set_file_extent_other_encoding(leaf, extent,
-                                                            other_encoding);
-                       btrfs_set_file_extent_offset(leaf, extent,
-                                   le64_to_cpu(old.offset) + end - key.offset);
-                       WARN_ON(le64_to_cpu(old.num_bytes) <
-                               (extent_end - end));
-                       btrfs_set_file_extent_num_bytes(leaf, extent,
-                                                       extent_end - end);
+                       btrfs_set_file_extent_num_bytes(leaf, fi,
+                                                       start - key.offset);
+                       btrfs_mark_buffer_dirty(leaf);
+                       if (disk_bytenr > 0) {
+                               inode_sub_bytes(inode, extent_end - start);
+                               *hint_byte = disk_bytenr;
+                       }
+                       if (end == extent_end)
+                               break;
 
-                       /*
-                        * set the ram bytes to the size of the full extent
-                        * before splitting.  This is a worst case flag,
-                        * but its the best we can do because we don't know
-                        * how splitting affects compression
-                        */
-                       btrfs_set_file_extent_ram_bytes(leaf, extent,
-                                                       ram_bytes);
-                       btrfs_set_file_extent_type(leaf, extent, found_type);
-
-                       btrfs_unlock_up_safe(path, 1);
-                       btrfs_mark_buffer_dirty(path->nodes[0]);
-                       btrfs_set_lock_blocking(path->nodes[0]);
-
-                       path->leave_spinning = 0;
-                       btrfs_release_path(root, path);
-                       if (disk_bytenr != 0)
-                               inode_add_bytes(inode, extent_end - end);
+                       path->slots[0]++;
+                       goto next_slot;
                }
 
-               if (found_extent && !keep) {
-                       u64 old_disk_bytenr = le64_to_cpu(old.disk_bytenr);
+               /*
+                *  | ---- range to drop ----- |
+                *    | ------ extent ------ |
+                */
+               if (start <= key.offset && end >= extent_end) {
+                       if (del_nr == 0) {
+                               del_slot = path->slots[0];
+                               del_nr = 1;
+                       } else {
+                               BUG_ON(del_slot + del_nr != path->slots[0]);
+                               del_nr++;
+                       }
 
-                       if (old_disk_bytenr != 0) {
+                       if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
                                inode_sub_bytes(inode,
-                                               le64_to_cpu(old.num_bytes));
+                                               extent_end - key.offset);
+                               extent_end = ALIGN(extent_end,
+                                                  root->sectorsize);
+                       } else if (disk_bytenr > 0) {
                                ret = btrfs_free_extent(trans, root,
-                                               old_disk_bytenr,
-                                               le64_to_cpu(old.disk_num_bytes),
-                                               0, root->root_key.objectid,
+                                               disk_bytenr, num_bytes, 0,
+                                               root->root_key.objectid,
                                                key.objectid, key.offset -
-                                               le64_to_cpu(old.offset));
+                                               extent_offset);
                                BUG_ON(ret);
-                               *hint_byte = old_disk_bytenr;
+                               inode_sub_bytes(inode,
+                                               extent_end - key.offset);
+                               *hint_byte = disk_bytenr;
                        }
-               }
 
-               if (search_start >= end) {
-                       ret = 0;
-                       goto out;
+                       if (end == extent_end)
+                               break;
+
+                       if (path->slots[0] + 1 < btrfs_header_nritems(leaf)) {
+                               path->slots[0]++;
+                               goto next_slot;
+                       }
+
+                       ret = btrfs_del_items(trans, root, path, del_slot,
+                                             del_nr);
+                       BUG_ON(ret);
+
+                       del_nr = 0;
+                       del_slot = 0;
+
+                       btrfs_release_path(root, path);
+                       continue;
                }
+
+               BUG_ON(1);
        }
-out:
-       btrfs_free_path(path);
-       if (locked_end > orig_locked_end) {
-               unlock_extent(&BTRFS_I(inode)->io_tree, orig_locked_end,
-                             locked_end - 1, GFP_NOFS);
+
+       if (del_nr > 0) {
+               ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
+               BUG_ON(ret);
        }
+
+       btrfs_free_path(path);
        return ret;
 }
 
@@ -620,23 +544,23 @@ static int extent_mergeable(struct extent_buffer *leaf, int slot,
  * two or three.
  */
 int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
-                             struct btrfs_root *root,
                              struct inode *inode, u64 start, u64 end)
 {
+       struct btrfs_root *root = BTRFS_I(inode)->root;
        struct extent_buffer *leaf;
        struct btrfs_path *path;
        struct btrfs_file_extent_item *fi;
        struct btrfs_key key;
+       struct btrfs_key new_key;
        u64 bytenr;
        u64 num_bytes;
        u64 extent_end;
        u64 orig_offset;
        u64 other_start;
        u64 other_end;
-       u64 split = start;
-       u64 locked_end = end;
-       int extent_type;
-       int split_end = 1;
+       u64 split;
+       int del_nr = 0;
+       int del_slot = 0;
        int ret;
 
        btrfs_drop_extent_cache(inode, start, end - 1, 0);
@@ -644,12 +568,10 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
        path = btrfs_alloc_path();
        BUG_ON(!path);
 again:
+       split = start;
        key.objectid = inode->i_ino;
        key.type = BTRFS_EXTENT_DATA_KEY;
-       if (split == start)
-               key.offset = split;
-       else
-               key.offset = split - 1;
+       key.offset = split;
 
        ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
        if (ret > 0 && path->slots[0] > 0)
@@ -661,8 +583,8 @@ again:
               key.type != BTRFS_EXTENT_DATA_KEY);
        fi = btrfs_item_ptr(leaf, path->slots[0],
                            struct btrfs_file_extent_item);
-       extent_type = btrfs_file_extent_type(leaf, fi);
-       BUG_ON(extent_type != BTRFS_FILE_EXTENT_PREALLOC);
+       BUG_ON(btrfs_file_extent_type(leaf, fi) !=
+              BTRFS_FILE_EXTENT_PREALLOC);
        extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi);
        BUG_ON(key.offset > start || extent_end < end);
 
@@ -670,150 +592,91 @@ again:
        num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi);
        orig_offset = key.offset - btrfs_file_extent_offset(leaf, fi);
 
-       if (key.offset == start)
-               split = end;
-
-       if (key.offset == start && extent_end == end) {
-               int del_nr = 0;
-               int del_slot = 0;
-               other_start = end;
-               other_end = 0;
-               if (extent_mergeable(leaf, path->slots[0] + 1, inode->i_ino,
-                                    bytenr, &other_start, &other_end)) {
-                       extent_end = other_end;
-                       del_slot = path->slots[0] + 1;
-                       del_nr++;
-                       ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
-                                               0, root->root_key.objectid,
-                                               inode->i_ino, orig_offset);
-                       BUG_ON(ret);
-               }
-               other_start = 0;
-               other_end = start;
-               if (extent_mergeable(leaf, path->slots[0] - 1, inode->i_ino,
-                                    bytenr, &other_start, &other_end)) {
-                       key.offset = other_start;
-                       del_slot = path->slots[0];
-                       del_nr++;
-                       ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
-                                               0, root->root_key.objectid,
-                                               inode->i_ino, orig_offset);
-                       BUG_ON(ret);
-               }
-               split_end = 0;
-               if (del_nr == 0) {
-                       btrfs_set_file_extent_type(leaf, fi,
-                                                  BTRFS_FILE_EXTENT_REG);
-                       goto done;
+       while (start > key.offset || end < extent_end) {
+               if (key.offset == start)
+                       split = end;
+
+               memcpy(&new_key, &key, sizeof(new_key));
+               new_key.offset = split;
+               ret = btrfs_duplicate_item(trans, root, path, &new_key);
+               if (ret == -EAGAIN) {
+                       btrfs_release_path(root, path);
+                       goto again;
                }
+               BUG_ON(ret < 0);
 
-               fi = btrfs_item_ptr(leaf, del_slot - 1,
+               leaf = path->nodes[0];
+               fi = btrfs_item_ptr(leaf, path->slots[0] - 1,
                                    struct btrfs_file_extent_item);
-               btrfs_set_file_extent_type(leaf, fi, BTRFS_FILE_EXTENT_REG);
                btrfs_set_file_extent_num_bytes(leaf, fi,
-                                               extent_end - key.offset);
+                                               split - key.offset);
+
+               fi = btrfs_item_ptr(leaf, path->slots[0],
+                                   struct btrfs_file_extent_item);
+
+               btrfs_set_file_extent_offset(leaf, fi, split - orig_offset);
+               btrfs_set_file_extent_num_bytes(leaf, fi,
+                                               extent_end - split);
                btrfs_mark_buffer_dirty(leaf);
 
-               ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
+               ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0,
+                                          root->root_key.objectid,
+                                          inode->i_ino, orig_offset);
                BUG_ON(ret);
-               goto release;
-       } else if (split == start) {
-               if (locked_end < extent_end) {
-                       ret = try_lock_extent(&BTRFS_I(inode)->io_tree,
-                                       locked_end, extent_end - 1, GFP_NOFS);
-                       if (!ret) {
-                               btrfs_release_path(root, path);
-                               lock_extent(&BTRFS_I(inode)->io_tree,
-                                       locked_end, extent_end - 1, GFP_NOFS);
-                               locked_end = extent_end;
-                               goto again;
-                       }
-                       locked_end = extent_end;
-               }
-               btrfs_set_file_extent_num_bytes(leaf, fi, split - key.offset);
-       } else  {
-               BUG_ON(key.offset != start);
-               key.offset = split;
-               btrfs_set_file_extent_offset(leaf, fi, key.offset -
-                                            orig_offset);
-               btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - split);
-               btrfs_set_item_key_safe(trans, root, path, &key);
-               extent_end = split;
-       }
 
-       if (extent_end == end) {
-               split_end = 0;
-               extent_type = BTRFS_FILE_EXTENT_REG;
-       }
-       if (extent_end == end && split == start) {
-               other_start = end;
-               other_end = 0;
-               if (extent_mergeable(leaf, path->slots[0] + 1, inode->i_ino,
-                                    bytenr, &other_start, &other_end)) {
-                       path->slots[0]++;
-                       fi = btrfs_item_ptr(leaf, path->slots[0],
-                                           struct btrfs_file_extent_item);
-                       key.offset = split;
-                       btrfs_set_item_key_safe(trans, root, path, &key);
-                       btrfs_set_file_extent_offset(leaf, fi, key.offset -
-                                                    orig_offset);
-                       btrfs_set_file_extent_num_bytes(leaf, fi,
-                                                       other_end - split);
-                       goto done;
-               }
-       }
-       if (extent_end == end && split == end) {
-               other_start = 0;
-               other_end = start;
-               if (extent_mergeable(leaf, path->slots[0] - 1 , inode->i_ino,
-                                    bytenr, &other_start, &other_end)) {
+               if (split == start) {
+                       key.offset = start;
+               } else {
+                       BUG_ON(start != key.offset);
                        path->slots[0]--;
-                       fi = btrfs_item_ptr(leaf, path->slots[0],
-                                           struct btrfs_file_extent_item);
-                       btrfs_set_file_extent_num_bytes(leaf, fi, extent_end -
-                                                       other_start);
-                       goto done;
+                       extent_end = end;
                }
        }
 
-       btrfs_mark_buffer_dirty(leaf);
-
-       ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0,
-                                  root->root_key.objectid,
-                                  inode->i_ino, orig_offset);
-       BUG_ON(ret);
-       btrfs_release_path(root, path);
-
-       key.offset = start;
-       ret = btrfs_insert_empty_item(trans, root, path, &key, sizeof(*fi));
-       BUG_ON(ret);
-
-       leaf = path->nodes[0];
        fi = btrfs_item_ptr(leaf, path->slots[0],
                            struct btrfs_file_extent_item);
-       btrfs_set_file_extent_generation(leaf, fi, trans->transid);
-       btrfs_set_file_extent_type(leaf, fi, extent_type);
-       btrfs_set_file_extent_disk_bytenr(leaf, fi, bytenr);
-       btrfs_set_file_extent_disk_num_bytes(leaf, fi, num_bytes);
-       btrfs_set_file_extent_offset(leaf, fi, key.offset - orig_offset);
-       btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - key.offset);
-       btrfs_set_file_extent_ram_bytes(leaf, fi, num_bytes);
-       btrfs_set_file_extent_compression(leaf, fi, 0);
-       btrfs_set_file_extent_encryption(leaf, fi, 0);
-       btrfs_set_file_extent_other_encoding(leaf, fi, 0);
-done:
-       btrfs_mark_buffer_dirty(leaf);
 
-release:
-       btrfs_release_path(root, path);
-       if (split_end && split == start) {
-               split = end;
-               goto again;
+       other_start = end;
+       other_end = 0;
+       if (extent_mergeable(leaf, path->slots[0] + 1, inode->i_ino,
+                            bytenr, &other_start, &other_end)) {
+               extent_end = other_end;
+               del_slot = path->slots[0] + 1;
+               del_nr++;
+               ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
+                                       0, root->root_key.objectid,
+                                       inode->i_ino, orig_offset);
+               BUG_ON(ret);
        }
-       if (locked_end > end) {
-               unlock_extent(&BTRFS_I(inode)->io_tree, end, locked_end - 1,
-                             GFP_NOFS);
+       other_start = 0;
+       other_end = start;
+       if (extent_mergeable(leaf, path->slots[0] - 1, inode->i_ino,
+                            bytenr, &other_start, &other_end)) {
+               key.offset = other_start;
+               del_slot = path->slots[0];
+               del_nr++;
+               ret = btrfs_free_extent(trans, root, bytenr, num_bytes,
+                                       0, root->root_key.objectid,
+                                       inode->i_ino, orig_offset);
+               BUG_ON(ret);
        }
+       if (del_nr == 0) {
+               btrfs_set_file_extent_type(leaf, fi,
+                                          BTRFS_FILE_EXTENT_REG);
+               btrfs_mark_buffer_dirty(leaf);
+               goto out;
+       }
+
+       fi = btrfs_item_ptr(leaf, del_slot - 1,
+                           struct btrfs_file_extent_item);
+       btrfs_set_file_extent_type(leaf, fi, BTRFS_FILE_EXTENT_REG);
+       btrfs_set_file_extent_num_bytes(leaf, fi,
+                                       extent_end - key.offset);
+       btrfs_mark_buffer_dirty(leaf);
+
+       ret = btrfs_del_items(trans, root, path, del_slot, del_nr);
+       BUG_ON(ret);
+out:
        btrfs_free_path(path);
        return 0;
 }
index b3ad168a0bfc97906dd1fa556b61297250faae58..5440bab2363565e5c50399eb32b9f6e8ed103728 100644 (file)
@@ -88,13 +88,14 @@ static noinline int cow_file_range(struct inode *inode,
                                   u64 start, u64 end, int *page_started,
                                   unsigned long *nr_written, int unlock);
 
-static int btrfs_init_inode_security(struct inode *inode,  struct inode *dir)
+static int btrfs_init_inode_security(struct btrfs_trans_handle *trans,
+                                    struct inode *inode,  struct inode *dir)
 {
        int err;
 
-       err = btrfs_init_acl(inode, dir);
+       err = btrfs_init_acl(trans, inode, dir);
        if (!err)
-               err = btrfs_xattr_security_init(inode, dir);
+               err = btrfs_xattr_security_init(trans, inode, dir);
        return err;
 }
 
@@ -188,8 +189,18 @@ static noinline int insert_inline_extent(struct btrfs_trans_handle *trans,
        btrfs_mark_buffer_dirty(leaf);
        btrfs_free_path(path);
 
+       /*
+        * we're an inline extent, so nobody can
+        * extend the file past i_size without locking
+        * a page we already have locked.
+        *
+        * We must do any isize and inode updates
+        * before we unlock the pages.  Otherwise we
+        * could end up racing with unlink.
+        */
        BTRFS_I(inode)->disk_i_size = inode->i_size;
        btrfs_update_inode(trans, root, inode);
+
        return 0;
 fail:
        btrfs_free_path(path);
@@ -230,8 +241,7 @@ static noinline int cow_file_range_inline(struct btrfs_trans_handle *trans,
                return 1;
        }
 
-       ret = btrfs_drop_extents(trans, root, inode, start,
-                                aligned_end, aligned_end, start,
+       ret = btrfs_drop_extents(trans, inode, start, aligned_end,
                                 &hint_byte, 1);
        BUG_ON(ret);
 
@@ -416,7 +426,6 @@ again:
                                                    start, end,
                                                    total_compressed, pages);
                }
-               btrfs_end_transaction(trans, root);
                if (ret == 0) {
                        /*
                         * inline extent creation worked, we don't need
@@ -430,9 +439,11 @@ again:
                             EXTENT_CLEAR_DELALLOC |
                             EXTENT_CLEAR_ACCOUNTING |
                             EXTENT_SET_WRITEBACK | EXTENT_END_WRITEBACK);
-                       ret = 0;
+
+                       btrfs_end_transaction(trans, root);
                        goto free_pages_out;
                }
+               btrfs_end_transaction(trans, root);
        }
 
        if (will_compress) {
@@ -543,7 +554,6 @@ static noinline int submit_compressed_extents(struct inode *inode,
        if (list_empty(&async_cow->extents))
                return 0;
 
-       trans = btrfs_join_transaction(root, 1);
 
        while (!list_empty(&async_cow->extents)) {
                async_extent = list_entry(async_cow->extents.next,
@@ -590,19 +600,15 @@ retry:
                lock_extent(io_tree, async_extent->start,
                            async_extent->start + async_extent->ram_size - 1,
                            GFP_NOFS);
-               /*
-                * here we're doing allocation and writeback of the
-                * compressed pages
-                */
-               btrfs_drop_extent_cache(inode, async_extent->start,
-                                       async_extent->start +
-                                       async_extent->ram_size - 1, 0);
 
+               trans = btrfs_join_transaction(root, 1);
                ret = btrfs_reserve_extent(trans, root,
                                           async_extent->compressed_size,
                                           async_extent->compressed_size,
                                           0, alloc_hint,
                                           (u64)-1, &ins, 1);
+               btrfs_end_transaction(trans, root);
+
                if (ret) {
                        int i;
                        for (i = 0; i < async_extent->nr_pages; i++) {
@@ -618,6 +624,14 @@ retry:
                        goto retry;
                }
 
+               /*
+                * here we're doing allocation and writeback of the
+                * compressed pages
+                */
+               btrfs_drop_extent_cache(inode, async_extent->start,
+                                       async_extent->start +
+                                       async_extent->ram_size - 1, 0);
+
                em = alloc_extent_map(GFP_NOFS);
                em->start = async_extent->start;
                em->len = async_extent->ram_size;
@@ -649,8 +663,6 @@ retry:
                                               BTRFS_ORDERED_COMPRESSED);
                BUG_ON(ret);
 
-               btrfs_end_transaction(trans, root);
-
                /*
                 * clear dirty, set writeback and unlock the pages.
                 */
@@ -672,13 +684,11 @@ retry:
                                    async_extent->nr_pages);
 
                BUG_ON(ret);
-               trans = btrfs_join_transaction(root, 1);
                alloc_hint = ins.objectid + ins.offset;
                kfree(async_extent);
                cond_resched();
        }
 
-       btrfs_end_transaction(trans, root);
        return 0;
 }
 
@@ -742,6 +752,7 @@ static noinline int cow_file_range(struct inode *inode,
                                     EXTENT_CLEAR_DIRTY |
                                     EXTENT_SET_WRITEBACK |
                                     EXTENT_END_WRITEBACK);
+
                        *nr_written = *nr_written +
                             (end - start + PAGE_CACHE_SIZE) / PAGE_CACHE_SIZE;
                        *page_started = 1;
@@ -1596,7 +1607,6 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
                                       struct inode *inode, u64 file_pos,
                                       u64 disk_bytenr, u64 disk_num_bytes,
                                       u64 num_bytes, u64 ram_bytes,
-                                      u64 locked_end,
                                       u8 compression, u8 encryption,
                                       u16 other_encoding, int extent_type)
 {
@@ -1622,9 +1632,8 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
         * the caller is expected to unpin it and allow it to be merged
         * with the others.
         */
-       ret = btrfs_drop_extents(trans, root, inode, file_pos,
-                                file_pos + num_bytes, locked_end,
-                                file_pos, &hint, 0);
+       ret = btrfs_drop_extents(trans, inode, file_pos, file_pos + num_bytes,
+                                &hint, 0);
        BUG_ON(ret);
 
        ins.objectid = inode->i_ino;
@@ -1730,23 +1739,32 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end)
                }
        }
 
-       trans = btrfs_join_transaction(root, 1);
-
        if (!ordered_extent)
                ordered_extent = btrfs_lookup_ordered_extent(inode, start);
        BUG_ON(!ordered_extent);
-       if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags))
-               goto nocow;
+       if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) {
+               BUG_ON(!list_empty(&ordered_extent->list));
+               ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent);
+               if (!ret) {
+                       trans = btrfs_join_transaction(root, 1);
+                       ret = btrfs_update_inode(trans, root, inode);
+                       BUG_ON(ret);
+                       btrfs_end_transaction(trans, root);
+               }
+               goto out;
+       }
 
        lock_extent(io_tree, ordered_extent->file_offset,
                    ordered_extent->file_offset + ordered_extent->len - 1,
                    GFP_NOFS);
 
+       trans = btrfs_join_transaction(root, 1);
+
        if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags))
                compressed = 1;
        if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) {
                BUG_ON(compressed);
-               ret = btrfs_mark_extent_written(trans, root, inode,
+               ret = btrfs_mark_extent_written(trans, inode,
                                                ordered_extent->file_offset,
                                                ordered_extent->file_offset +
                                                ordered_extent->len);
@@ -1758,8 +1776,6 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end)
                                                ordered_extent->disk_len,
                                                ordered_extent->len,
                                                ordered_extent->len,
-                                               ordered_extent->file_offset +
-                                               ordered_extent->len,
                                                compressed, 0, 0,
                                                BTRFS_FILE_EXTENT_REG);
                unpin_extent_cache(&BTRFS_I(inode)->extent_tree,
@@ -1770,22 +1786,20 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end)
        unlock_extent(io_tree, ordered_extent->file_offset,
                    ordered_extent->file_offset + ordered_extent->len - 1,
                    GFP_NOFS);
-nocow:
        add_pending_csums(trans, inode, ordered_extent->file_offset,
                          &ordered_extent->list);
 
-       mutex_lock(&BTRFS_I(inode)->extent_mutex);
-       btrfs_ordered_update_i_size(inode, ordered_extent);
-       btrfs_update_inode(trans, root, inode);
-       btrfs_remove_ordered_extent(inode, ordered_extent);
-       mutex_unlock(&BTRFS_I(inode)->extent_mutex);
-
+       /* this also removes the ordered extent from the tree */
+       btrfs_ordered_update_i_size(inode, 0, ordered_extent);
+       ret = btrfs_update_inode(trans, root, inode);
+       BUG_ON(ret);
+       btrfs_end_transaction(trans, root);
+out:
        /* once for us */
        btrfs_put_ordered_extent(ordered_extent);
        /* once for the tree */
        btrfs_put_ordered_extent(ordered_extent);
 
-       btrfs_end_transaction(trans, root);
        return 0;
 }
 
@@ -2008,6 +2022,54 @@ zeroit:
        return -EIO;
 }
 
+struct delayed_iput {
+       struct list_head list;
+       struct inode *inode;
+};
+
+void btrfs_add_delayed_iput(struct inode *inode)
+{
+       struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
+       struct delayed_iput *delayed;
+
+       if (atomic_add_unless(&inode->i_count, -1, 1))
+               return;
+
+       delayed = kmalloc(sizeof(*delayed), GFP_NOFS | __GFP_NOFAIL);
+       delayed->inode = inode;
+
+       spin_lock(&fs_info->delayed_iput_lock);
+       list_add_tail(&delayed->list, &fs_info->delayed_iputs);
+       spin_unlock(&fs_info->delayed_iput_lock);
+}
+
+void btrfs_run_delayed_iputs(struct btrfs_root *root)
+{
+       LIST_HEAD(list);
+       struct btrfs_fs_info *fs_info = root->fs_info;
+       struct delayed_iput *delayed;
+       int empty;
+
+       spin_lock(&fs_info->delayed_iput_lock);
+       empty = list_empty(&fs_info->delayed_iputs);
+       spin_unlock(&fs_info->delayed_iput_lock);
+       if (empty)
+               return;
+
+       down_read(&root->fs_info->cleanup_work_sem);
+       spin_lock(&fs_info->delayed_iput_lock);
+       list_splice_init(&fs_info->delayed_iputs, &list);
+       spin_unlock(&fs_info->delayed_iput_lock);
+
+       while (!list_empty(&list)) {
+               delayed = list_entry(list.next, struct delayed_iput, list);
+               list_del(&delayed->list);
+               iput(delayed->inode);
+               kfree(delayed);
+       }
+       up_read(&root->fs_info->cleanup_work_sem);
+}
+
 /*
  * This creates an orphan entry for the given inode in case something goes
  * wrong in the middle of an unlink/truncate.
@@ -2080,16 +2142,17 @@ void btrfs_orphan_cleanup(struct btrfs_root *root)
        struct inode *inode;
        int ret = 0, nr_unlink = 0, nr_truncate = 0;
 
-       path = btrfs_alloc_path();
-       if (!path)
+       if (!xchg(&root->clean_orphans, 0))
                return;
+
+       path = btrfs_alloc_path();
+       BUG_ON(!path);
        path->reada = -1;
 
        key.objectid = BTRFS_ORPHAN_OBJECTID;
        btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY);
        key.offset = (u64)-1;
 
-
        while (1) {
                ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
                if (ret < 0) {
@@ -2834,37 +2897,40 @@ out:
  * min_type is the minimum key type to truncate down to.  If set to 0, this
  * will kill all the items on this inode, including the INODE_ITEM_KEY.
  */
-noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
-                                       struct btrfs_root *root,
-                                       struct inode *inode,
-                                       u64 new_size, u32 min_type)
+int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
+                              struct btrfs_root *root,
+                              struct inode *inode,
+                              u64 new_size, u32 min_type)
 {
-       int ret;
        struct btrfs_path *path;
-       struct btrfs_key key;
-       struct btrfs_key found_key;
-       u32 found_type = (u8)-1;
        struct extent_buffer *leaf;
        struct btrfs_file_extent_item *fi;
+       struct btrfs_key key;
+       struct btrfs_key found_key;
        u64 extent_start = 0;
        u64 extent_num_bytes = 0;
        u64 extent_offset = 0;
        u64 item_end = 0;
+       u64 mask = root->sectorsize - 1;
+       u32 found_type = (u8)-1;
        int found_extent;
        int del_item;
        int pending_del_nr = 0;
        int pending_del_slot = 0;
        int extent_type = -1;
        int encoding;
-       u64 mask = root->sectorsize - 1;
+       int ret;
+       int err = 0;
+
+       BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY);
 
        if (root->ref_cows)
                btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0);
+
        path = btrfs_alloc_path();
        BUG_ON(!path);
        path->reada = -1;
 
-       /* FIXME, add redo link to tree so we don't leak on crash */
        key.objectid = inode->i_ino;
        key.offset = (u64)-1;
        key.type = (u8)-1;
@@ -2872,17 +2938,17 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
 search_again:
        path->leave_spinning = 1;
        ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
-       if (ret < 0)
-               goto error;
+       if (ret < 0) {
+               err = ret;
+               goto out;
+       }
 
        if (ret > 0) {
                /* there are no items in the tree for us to truncate, we're
                 * done
                 */
-               if (path->slots[0] == 0) {
-                       ret = 0;
-                       goto error;
-               }
+               if (path->slots[0] == 0)
+                       goto out;
                path->slots[0]--;
        }
 
@@ -2917,28 +2983,17 @@ search_again:
                        }
                        item_end--;
                }
-               if (item_end < new_size) {
-                       if (found_type == BTRFS_DIR_ITEM_KEY)
-                               found_type = BTRFS_INODE_ITEM_KEY;
-                       else if (found_type == BTRFS_EXTENT_ITEM_KEY)
-                               found_type = BTRFS_EXTENT_DATA_KEY;
-                       else if (found_type == BTRFS_EXTENT_DATA_KEY)
-                               found_type = BTRFS_XATTR_ITEM_KEY;
-                       else if (found_type == BTRFS_XATTR_ITEM_KEY)
-                               found_type = BTRFS_INODE_REF_KEY;
-                       else if (found_type)
-                               found_type--;
-                       else
+               if (found_type > min_type) {
+                       del_item = 1;
+               } else {
+                       if (item_end < new_size)
                                break;
-                       btrfs_set_key_type(&key, found_type);
-                       goto next;
+                       if (found_key.offset >= new_size)
+                               del_item = 1;
+                       else
+                               del_item = 0;
                }
-               if (found_key.offset >= new_size)
-                       del_item = 1;
-               else
-                       del_item = 0;
                found_extent = 0;
-
                /* FIXME, shrink the extent if the ref count is only 1 */
                if (found_type != BTRFS_EXTENT_DATA_KEY)
                        goto delete;
@@ -3025,42 +3080,36 @@ delete:
                                                inode->i_ino, extent_offset);
                        BUG_ON(ret);
                }
-next:
-               if (path->slots[0] == 0) {
-                       if (pending_del_nr)
-                               goto del_pending;
-                       btrfs_release_path(root, path);
-                       if (found_type == BTRFS_INODE_ITEM_KEY)
-                               break;
-                       goto search_again;
-               }
 
-               path->slots[0]--;
-               if (pending_del_nr &&
-                   path->slots[0] + 1 != pending_del_slot) {
-                       struct btrfs_key debug;
-del_pending:
-                       btrfs_item_key_to_cpu(path->nodes[0], &debug,
-                                             pending_del_slot);
-                       ret = btrfs_del_items(trans, root, path,
-                                             pending_del_slot,
-                                             pending_del_nr);
-                       BUG_ON(ret);
-                       pending_del_nr = 0;
+               if (found_type == BTRFS_INODE_ITEM_KEY)
+                       break;
+
+               if (path->slots[0] == 0 ||
+                   path->slots[0] != pending_del_slot) {
+                       if (root->ref_cows) {
+                               err = -EAGAIN;
+                               goto out;
+                       }
+                       if (pending_del_nr) {
+                               ret = btrfs_del_items(trans, root, path,
+                                               pending_del_slot,
+                                               pending_del_nr);
+                               BUG_ON(ret);
+                               pending_del_nr = 0;
+                       }
                        btrfs_release_path(root, path);
-                       if (found_type == BTRFS_INODE_ITEM_KEY)
-                               break;
                        goto search_again;
+               } else {
+                       path->slots[0]--;
                }
        }
-       ret = 0;
-error:
+out:
        if (pending_del_nr) {
                ret = btrfs_del_items(trans, root, path, pending_del_slot,
                                      pending_del_nr);
        }
        btrfs_free_path(path);
-       return ret;
+       return err;
 }
 
 /*
@@ -3180,10 +3229,6 @@ int btrfs_cont_expand(struct inode *inode, loff_t size)
        if (size <= hole_start)
                return 0;
 
-       err = btrfs_truncate_page(inode->i_mapping, inode->i_size);
-       if (err)
-               return err;
-
        while (1) {
                struct btrfs_ordered_extent *ordered;
                btrfs_wait_ordered_range(inode, hole_start,
@@ -3196,9 +3241,6 @@ int btrfs_cont_expand(struct inode *inode, loff_t size)
                btrfs_put_ordered_extent(ordered);
        }
 
-       trans = btrfs_start_transaction(root, 1);
-       btrfs_set_trans_block_group(trans, inode);
-
        cur_offset = hole_start;
        while (1) {
                em = btrfs_get_extent(inode, NULL, 0, cur_offset,
@@ -3206,40 +3248,120 @@ int btrfs_cont_expand(struct inode *inode, loff_t size)
                BUG_ON(IS_ERR(em) || !em);
                last_byte = min(extent_map_end(em), block_end);
                last_byte = (last_byte + mask) & ~mask;
-               if (test_bit(EXTENT_FLAG_VACANCY, &em->flags)) {
+               if (!test_bit(EXTENT_FLAG_PREALLOC, &em->flags)) {
                        u64 hint_byte = 0;
                        hole_size = last_byte - cur_offset;
-                       err = btrfs_drop_extents(trans, root, inode,
-                                                cur_offset,
-                                                cur_offset + hole_size,
-                                                block_end,
-                                                cur_offset, &hint_byte, 1);
-                       if (err)
-                               break;
 
-                       err = btrfs_reserve_metadata_space(root, 1);
+                       err = btrfs_reserve_metadata_space(root, 2);
                        if (err)
                                break;
 
+                       trans = btrfs_start_transaction(root, 1);
+                       btrfs_set_trans_block_group(trans, inode);
+
+                       err = btrfs_drop_extents(trans, inode, cur_offset,
+                                                cur_offset + hole_size,
+                                                &hint_byte, 1);
+                       BUG_ON(err);
+
                        err = btrfs_insert_file_extent(trans, root,
                                        inode->i_ino, cur_offset, 0,
                                        0, hole_size, 0, hole_size,
                                        0, 0, 0);
+                       BUG_ON(err);
+
                        btrfs_drop_extent_cache(inode, hole_start,
                                        last_byte - 1, 0);
-                       btrfs_unreserve_metadata_space(root, 1);
+
+                       btrfs_end_transaction(trans, root);
+                       btrfs_unreserve_metadata_space(root, 2);
                }
                free_extent_map(em);
                cur_offset = last_byte;
-               if (err || cur_offset >= block_end)
+               if (cur_offset >= block_end)
                        break;
        }
 
-       btrfs_end_transaction(trans, root);
        unlock_extent(io_tree, hole_start, block_end - 1, GFP_NOFS);
        return err;
 }
 
+static int btrfs_setattr_size(struct inode *inode, struct iattr *attr)
+{
+       struct btrfs_root *root = BTRFS_I(inode)->root;
+       struct btrfs_trans_handle *trans;
+       unsigned long nr;
+       int ret;
+
+       if (attr->ia_size == inode->i_size)
+               return 0;
+
+       if (attr->ia_size > inode->i_size) {
+               unsigned long limit;
+               limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
+               if (attr->ia_size > inode->i_sb->s_maxbytes)
+                       return -EFBIG;
+               if (limit != RLIM_INFINITY && attr->ia_size > limit) {
+                       send_sig(SIGXFSZ, current, 0);
+                       return -EFBIG;
+               }
+       }
+
+       ret = btrfs_reserve_metadata_space(root, 1);
+       if (ret)
+               return ret;
+
+       trans = btrfs_start_transaction(root, 1);
+       btrfs_set_trans_block_group(trans, inode);
+
+       ret = btrfs_orphan_add(trans, inode);
+       BUG_ON(ret);
+
+       nr = trans->blocks_used;
+       btrfs_end_transaction(trans, root);
+       btrfs_unreserve_metadata_space(root, 1);
+       btrfs_btree_balance_dirty(root, nr);
+
+       if (attr->ia_size > inode->i_size) {
+               ret = btrfs_cont_expand(inode, attr->ia_size);
+               if (ret) {
+                       btrfs_truncate(inode);
+                       return ret;
+               }
+
+               i_size_write(inode, attr->ia_size);
+               btrfs_ordered_update_i_size(inode, inode->i_size, NULL);
+
+               trans = btrfs_start_transaction(root, 1);
+               btrfs_set_trans_block_group(trans, inode);
+
+               ret = btrfs_update_inode(trans, root, inode);
+               BUG_ON(ret);
+               if (inode->i_nlink > 0) {
+                       ret = btrfs_orphan_del(trans, inode);
+                       BUG_ON(ret);
+               }
+               nr = trans->blocks_used;
+               btrfs_end_transaction(trans, root);
+               btrfs_btree_balance_dirty(root, nr);
+               return 0;
+       }
+
+       /*
+        * We're truncating a file that used to have good data down to
+        * zero. Make sure it gets into the ordered flush list so that
+        * any new writes get down to disk quickly.
+        */
+       if (attr->ia_size == 0)
+               BTRFS_I(inode)->ordered_data_close = 1;
+
+       /* we don't support swapfiles, so vmtruncate shouldn't fail */
+       ret = vmtruncate(inode, attr->ia_size);
+       BUG_ON(ret);
+
+       return 0;
+}
+
 static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
 {
        struct inode *inode = dentry->d_inode;
@@ -3250,23 +3372,14 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
                return err;
 
        if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) {
-               if (attr->ia_size > inode->i_size) {
-                       err = btrfs_cont_expand(inode, attr->ia_size);
-                       if (err)
-                               return err;
-               } else if (inode->i_size > 0 &&
-                          attr->ia_size == 0) {
-
-                       /* we're truncating a file that used to have good
-                        * data down to zero.  Make sure it gets into
-                        * the ordered flush list so that any new writes
-                        * get down to disk quickly.
-                        */
-                       BTRFS_I(inode)->ordered_data_close = 1;
-               }
+               err = btrfs_setattr_size(inode, attr);
+               if (err)
+                       return err;
        }
+       attr->ia_valid &= ~ATTR_SIZE;
 
-       err = inode_setattr(inode, attr);
+       if (attr->ia_valid)
+               err = inode_setattr(inode, attr);
 
        if (!err && ((attr->ia_valid & ATTR_MODE)))
                err = btrfs_acl_chmod(inode);
@@ -3287,36 +3400,43 @@ void btrfs_delete_inode(struct inode *inode)
        }
        btrfs_wait_ordered_range(inode, 0, (u64)-1);
 
+       if (root->fs_info->log_root_recovering) {
+               BUG_ON(!list_empty(&BTRFS_I(inode)->i_orphan));
+               goto no_delete;
+       }
+
        if (inode->i_nlink > 0) {
                BUG_ON(btrfs_root_refs(&root->root_item) != 0);
                goto no_delete;
        }
 
        btrfs_i_size_write(inode, 0);
-       trans = btrfs_join_transaction(root, 1);
 
-       btrfs_set_trans_block_group(trans, inode);
-       ret = btrfs_truncate_inode_items(trans, root, inode, inode->i_size, 0);
-       if (ret) {
-               btrfs_orphan_del(NULL, inode);
-               goto no_delete_lock;
-       }
+       while (1) {
+               trans = btrfs_start_transaction(root, 1);
+               btrfs_set_trans_block_group(trans, inode);
+               ret = btrfs_truncate_inode_items(trans, root, inode, 0, 0);
 
-       btrfs_orphan_del(trans, inode);
+               if (ret != -EAGAIN)
+                       break;
 
-       nr = trans->blocks_used;
-       clear_inode(inode);
+               nr = trans->blocks_used;
+               btrfs_end_transaction(trans, root);
+               trans = NULL;
+               btrfs_btree_balance_dirty(root, nr);
+       }
 
-       btrfs_end_transaction(trans, root);
-       btrfs_btree_balance_dirty(root, nr);
-       return;
+       if (ret == 0) {
+               ret = btrfs_orphan_del(trans, inode);
+               BUG_ON(ret);
+       }
 
-no_delete_lock:
        nr = trans->blocks_used;
        btrfs_end_transaction(trans, root);
        btrfs_btree_balance_dirty(root, nr);
 no_delete:
        clear_inode(inode);
+       return;
 }
 
 /*
@@ -3569,7 +3689,6 @@ static noinline void init_btrfs_i(struct inode *inode)
        INIT_LIST_HEAD(&BTRFS_I(inode)->ordered_operations);
        RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
        btrfs_ordered_inode_tree_init(&BTRFS_I(inode)->ordered_tree);
-       mutex_init(&BTRFS_I(inode)->extent_mutex);
        mutex_init(&BTRFS_I(inode)->log_mutex);
 }
 
@@ -3695,6 +3814,13 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
        }
        srcu_read_unlock(&root->fs_info->subvol_srcu, index);
 
+       if (root != sub_root) {
+               down_read(&root->fs_info->cleanup_work_sem);
+               if (!(inode->i_sb->s_flags & MS_RDONLY))
+                       btrfs_orphan_cleanup(sub_root);
+               up_read(&root->fs_info->cleanup_work_sem);
+       }
+
        return inode;
 }
 
@@ -4219,7 +4345,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
        if (IS_ERR(inode))
                goto out_unlock;
 
-       err = btrfs_init_inode_security(inode, dir);
+       err = btrfs_init_inode_security(trans, inode, dir);
        if (err) {
                drop_inode = 1;
                goto out_unlock;
@@ -4290,7 +4416,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
        if (IS_ERR(inode))
                goto out_unlock;
 
-       err = btrfs_init_inode_security(inode, dir);
+       err = btrfs_init_inode_security(trans, inode, dir);
        if (err) {
                drop_inode = 1;
                goto out_unlock;
@@ -4336,6 +4462,10 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
        if (inode->i_nlink == 0)
                return -ENOENT;
 
+       /* do not allow sys_link's with other subvols of the same device */
+       if (root->objectid != BTRFS_I(inode)->root->objectid)
+               return -EPERM;
+
        /*
         * 1 item for inode ref
         * 2 items for dir items
@@ -4423,7 +4553,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 
        drop_on_err = 1;
 
-       err = btrfs_init_inode_security(inode, dir);
+       err = btrfs_init_inode_security(trans, inode, dir);
        if (err)
                goto out_fail;
 
@@ -5074,17 +5204,20 @@ static void btrfs_truncate(struct inode *inode)
        unsigned long nr;
        u64 mask = root->sectorsize - 1;
 
-       if (!S_ISREG(inode->i_mode))
-               return;
-       if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
+       if (!S_ISREG(inode->i_mode)) {
+               WARN_ON(1);
                return;
+       }
 
        ret = btrfs_truncate_page(inode->i_mapping, inode->i_size);
        if (ret)
                return;
+
        btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1);
+       btrfs_ordered_update_i_size(inode, inode->i_size, NULL);
 
        trans = btrfs_start_transaction(root, 1);
+       btrfs_set_trans_block_group(trans, inode);
 
        /*
         * setattr is responsible for setting the ordered_data_close flag,
@@ -5106,21 +5239,32 @@ static void btrfs_truncate(struct inode *inode)
        if (inode->i_size == 0 && BTRFS_I(inode)->ordered_data_close)
                btrfs_add_ordered_operation(trans, root, inode);
 
-       btrfs_set_trans_block_group(trans, inode);
-       btrfs_i_size_write(inode, inode->i_size);
+       while (1) {
+               ret = btrfs_truncate_inode_items(trans, root, inode,
+                                                inode->i_size,
+                                                BTRFS_EXTENT_DATA_KEY);
+               if (ret != -EAGAIN)
+                       break;
 
-       ret = btrfs_orphan_add(trans, inode);
-       if (ret)
-               goto out;
-       /* FIXME, add redo link to tree so we don't leak on crash */
-       ret = btrfs_truncate_inode_items(trans, root, inode, inode->i_size,
-                                     BTRFS_EXTENT_DATA_KEY);
-       btrfs_update_inode(trans, root, inode);
+               ret = btrfs_update_inode(trans, root, inode);
+               BUG_ON(ret);
+
+               nr = trans->blocks_used;
+               btrfs_end_transaction(trans, root);
+               btrfs_btree_balance_dirty(root, nr);
+
+               trans = btrfs_start_transaction(root, 1);
+               btrfs_set_trans_block_group(trans, inode);
+       }
 
-       ret = btrfs_orphan_del(trans, inode);
+       if (ret == 0 && inode->i_nlink > 0) {
+               ret = btrfs_orphan_del(trans, inode);
+               BUG_ON(ret);
+       }
+
+       ret = btrfs_update_inode(trans, root, inode);
        BUG_ON(ret);
 
-out:
        nr = trans->blocks_used;
        ret = btrfs_end_transaction_throttle(trans, root);
        BUG_ON(ret);
@@ -5217,9 +5361,9 @@ void btrfs_destroy_inode(struct inode *inode)
 
        spin_lock(&root->list_lock);
        if (!list_empty(&BTRFS_I(inode)->i_orphan)) {
-               printk(KERN_ERR "BTRFS: inode %lu: inode still on the orphan"
-                      " list\n", inode->i_ino);
-               dump_stack();
+               printk(KERN_INFO "BTRFS: inode %lu still on the orphan list\n",
+                      inode->i_ino);
+               list_del_init(&BTRFS_I(inode)->i_orphan);
        }
        spin_unlock(&root->list_lock);
 
@@ -5476,7 +5620,7 @@ out_fail:
  * some fairly slow code that needs optimization. This walks the list
  * of all the inodes with pending delalloc and forces them to disk.
  */
-int btrfs_start_delalloc_inodes(struct btrfs_root *root)
+int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput)
 {
        struct list_head *head = &root->fs_info->delalloc_inodes;
        struct btrfs_inode *binode;
@@ -5495,7 +5639,10 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root)
                spin_unlock(&root->fs_info->delalloc_lock);
                if (inode) {
                        filemap_flush(inode->i_mapping);
-                       iput(inode);
+                       if (delay_iput)
+                               btrfs_add_delayed_iput(inode);
+                       else
+                               iput(inode);
                }
                cond_resched();
                spin_lock(&root->fs_info->delalloc_lock);
@@ -5569,7 +5716,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
        if (IS_ERR(inode))
                goto out_unlock;
 
-       err = btrfs_init_inode_security(inode, dir);
+       err = btrfs_init_inode_security(trans, inode, dir);
        if (err) {
                drop_inode = 1;
                goto out_unlock;
@@ -5641,10 +5788,10 @@ out_fail:
        return err;
 }
 
-static int prealloc_file_range(struct btrfs_trans_handle *trans,
-                              struct inode *inode, u64 start, u64 end,
-                              u64 locked_end, u64 alloc_hint, int mode)
+static int prealloc_file_range(struct inode *inode, u64 start, u64 end,
+                              u64 alloc_hint, int mode)
 {
+       struct btrfs_trans_handle *trans;
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct btrfs_key ins;
        u64 alloc_size;
@@ -5655,43 +5802,56 @@ static int prealloc_file_range(struct btrfs_trans_handle *trans,
        while (num_bytes > 0) {
                alloc_size = min(num_bytes, root->fs_info->max_extent);
 
-               ret = btrfs_reserve_metadata_space(root, 1);
-               if (ret)
-                       goto out;
+               trans = btrfs_start_transaction(root, 1);
 
                ret = btrfs_reserve_extent(trans, root, alloc_size,
                                           root->sectorsize, 0, alloc_hint,
                                           (u64)-1, &ins, 1);
                if (ret) {
                        WARN_ON(1);
-                       goto out;
+                       goto stop_trans;
+               }
+
+               ret = btrfs_reserve_metadata_space(root, 3);
+               if (ret) {
+                       btrfs_free_reserved_extent(root, ins.objectid,
+                                                  ins.offset);
+                       goto stop_trans;
                }
+
                ret = insert_reserved_file_extent(trans, inode,
                                                  cur_offset, ins.objectid,
                                                  ins.offset, ins.offset,
-                                                 ins.offset, locked_end,
-                                                 0, 0, 0,
+                                                 ins.offset, 0, 0, 0,
                                                  BTRFS_FILE_EXTENT_PREALLOC);
                BUG_ON(ret);
                btrfs_drop_extent_cache(inode, cur_offset,
                                        cur_offset + ins.offset -1, 0);
+
                num_bytes -= ins.offset;
                cur_offset += ins.offset;
                alloc_hint = ins.objectid + ins.offset;
-               btrfs_unreserve_metadata_space(root, 1);
-       }
-out:
-       if (cur_offset > start) {
+
                inode->i_ctime = CURRENT_TIME;
                BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC;
                if (!(mode & FALLOC_FL_KEEP_SIZE) &&
-                   cur_offset > i_size_read(inode))
-                       btrfs_i_size_write(inode, cur_offset);
+                   cur_offset > inode->i_size) {
+                       i_size_write(inode, cur_offset);
+                       btrfs_ordered_update_i_size(inode, cur_offset, NULL);
+               }
+
                ret = btrfs_update_inode(trans, root, inode);
                BUG_ON(ret);
+
+               btrfs_end_transaction(trans, root);
+               btrfs_unreserve_metadata_space(root, 3);
        }
+       return ret;
 
+stop_trans:
+       btrfs_end_transaction(trans, root);
        return ret;
+
 }
 
 static long btrfs_fallocate(struct inode *inode, int mode,
@@ -5705,8 +5865,6 @@ static long btrfs_fallocate(struct inode *inode, int mode,
        u64 locked_end;
        u64 mask = BTRFS_I(inode)->root->sectorsize - 1;
        struct extent_map *em;
-       struct btrfs_trans_handle *trans;
-       struct btrfs_root *root;
        int ret;
 
        alloc_start = offset & ~mask;
@@ -5725,9 +5883,7 @@ static long btrfs_fallocate(struct inode *inode, int mode,
                        goto out;
        }
 
-       root = BTRFS_I(inode)->root;
-
-       ret = btrfs_check_data_free_space(root, inode,
+       ret = btrfs_check_data_free_space(BTRFS_I(inode)->root, inode,
                                          alloc_end - alloc_start);
        if (ret)
                goto out;
@@ -5736,12 +5892,6 @@ static long btrfs_fallocate(struct inode *inode, int mode,
        while (1) {
                struct btrfs_ordered_extent *ordered;
 
-               trans = btrfs_start_transaction(BTRFS_I(inode)->root, 1);
-               if (!trans) {
-                       ret = -EIO;
-                       goto out_free;
-               }
-
                /* the extent lock is ordered inside the running
                 * transaction
                 */
@@ -5755,8 +5905,6 @@ static long btrfs_fallocate(struct inode *inode, int mode,
                        btrfs_put_ordered_extent(ordered);
                        unlock_extent(&BTRFS_I(inode)->io_tree,
                                      alloc_start, locked_end, GFP_NOFS);
-                       btrfs_end_transaction(trans, BTRFS_I(inode)->root);
-
                        /*
                         * we can't wait on the range with the transaction
                         * running or with the extent lock held
@@ -5777,10 +5925,12 @@ static long btrfs_fallocate(struct inode *inode, int mode,
                BUG_ON(IS_ERR(em) || !em);
                last_byte = min(extent_map_end(em), alloc_end);
                last_byte = (last_byte + mask) & ~mask;
-               if (em->block_start == EXTENT_MAP_HOLE) {
-                       ret = prealloc_file_range(trans, inode, cur_offset,
-                                       last_byte, locked_end + 1,
-                                       alloc_hint, mode);
+               if (em->block_start == EXTENT_MAP_HOLE ||
+                   (cur_offset >= inode->i_size &&
+                    !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) {
+                       ret = prealloc_file_range(inode,
+                                                 cur_offset, last_byte,
+                                                 alloc_hint, mode);
                        if (ret < 0) {
                                free_extent_map(em);
                                break;
@@ -5799,9 +5949,8 @@ static long btrfs_fallocate(struct inode *inode, int mode,
        unlock_extent(&BTRFS_I(inode)->io_tree, alloc_start, locked_end,
                      GFP_NOFS);
 
-       btrfs_end_transaction(trans, BTRFS_I(inode)->root);
-out_free:
-       btrfs_free_reserved_data_space(root, inode, alloc_end - alloc_start);
+       btrfs_free_reserved_data_space(BTRFS_I(inode)->root, inode,
+                                      alloc_end - alloc_start);
 out:
        mutex_unlock(&inode->i_mutex);
        return ret;
index cdbb054102b9f860ee4d119dfff39e891ac29438..645a17927a8f7c8edf9b9b1866695f3ab6982b23 100644 (file)
@@ -237,7 +237,6 @@ static noinline int create_subvol(struct btrfs_root *root,
        u64 objectid;
        u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID;
        u64 index = 0;
-       unsigned long nr = 1;
 
        /*
         * 1 - inode item
@@ -290,7 +289,7 @@ static noinline int create_subvol(struct btrfs_root *root,
        btrfs_set_root_generation(&root_item, trans->transid);
        btrfs_set_root_level(&root_item, 0);
        btrfs_set_root_refs(&root_item, 1);
-       btrfs_set_root_used(&root_item, 0);
+       btrfs_set_root_used(&root_item, leaf->len);
        btrfs_set_root_last_snapshot(&root_item, 0);
 
        memset(&root_item.drop_progress, 0, sizeof(root_item.drop_progress));
@@ -342,24 +341,21 @@ static noinline int create_subvol(struct btrfs_root *root,
 
        d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry));
 fail:
-       nr = trans->blocks_used;
        err = btrfs_commit_transaction(trans, root);
        if (err && !ret)
                ret = err;
 
        btrfs_unreserve_metadata_space(root, 6);
-       btrfs_btree_balance_dirty(root, nr);
        return ret;
 }
 
 static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
                           char *name, int namelen)
 {
+       struct inode *inode;
        struct btrfs_pending_snapshot *pending_snapshot;
        struct btrfs_trans_handle *trans;
-       int ret = 0;
-       int err;
-       unsigned long nr = 0;
+       int ret;
 
        if (!root->ref_cows)
                return -EINVAL;
@@ -372,20 +368,20 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
         */
        ret = btrfs_reserve_metadata_space(root, 6);
        if (ret)
-               goto fail_unlock;
+               goto fail;
 
        pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_NOFS);
        if (!pending_snapshot) {
                ret = -ENOMEM;
                btrfs_unreserve_metadata_space(root, 6);
-               goto fail_unlock;
+               goto fail;
        }
        pending_snapshot->name = kmalloc(namelen + 1, GFP_NOFS);
        if (!pending_snapshot->name) {
                ret = -ENOMEM;
                kfree(pending_snapshot);
                btrfs_unreserve_metadata_space(root, 6);
-               goto fail_unlock;
+               goto fail;
        }
        memcpy(pending_snapshot->name, name, namelen);
        pending_snapshot->name[namelen] = '\0';
@@ -395,10 +391,19 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
        pending_snapshot->root = root;
        list_add(&pending_snapshot->list,
                 &trans->transaction->pending_snapshots);
-       err = btrfs_commit_transaction(trans, root);
+       ret = btrfs_commit_transaction(trans, root);
+       BUG_ON(ret);
+       btrfs_unreserve_metadata_space(root, 6);
 
-fail_unlock:
-       btrfs_btree_balance_dirty(root, nr);
+       inode = btrfs_lookup_dentry(dentry->d_parent->d_inode, dentry);
+       if (IS_ERR(inode)) {
+               ret = PTR_ERR(inode);
+               goto fail;
+       }
+       BUG_ON(!inode);
+       d_instantiate(dentry, inode);
+       ret = 0;
+fail:
        return ret;
 }
 
@@ -1027,8 +1032,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
        BUG_ON(!trans);
 
        /* punch hole in destination first */
-       btrfs_drop_extents(trans, root, inode, off, off + len,
-                          off + len, 0, &hint_byte, 1);
+       btrfs_drop_extents(trans, inode, off, off + len, &hint_byte, 1);
 
        /* clone data */
        key.objectid = src->i_ino;
index 5799bc46a30993a1cb477fb3a4dd9db23dcad6da..b10a49d4bc6a258d1439825388e4685fbb7abb8a 100644 (file)
@@ -291,16 +291,16 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
 
 /*
  * remove an ordered extent from the tree.  No references are dropped
- * but, anyone waiting on this extent is woken up.
+ * and you must wake_up entry->wait.  You must hold the tree mutex
+ * while you call this function.
  */
-int btrfs_remove_ordered_extent(struct inode *inode,
+static int __btrfs_remove_ordered_extent(struct inode *inode,
                                struct btrfs_ordered_extent *entry)
 {
        struct btrfs_ordered_inode_tree *tree;
        struct rb_node *node;
 
        tree = &BTRFS_I(inode)->ordered_tree;
-       mutex_lock(&tree->mutex);
        node = &entry->rb_node;
        rb_erase(node, &tree->tree);
        tree->last = NULL;
@@ -326,16 +326,34 @@ int btrfs_remove_ordered_extent(struct inode *inode,
        }
        spin_unlock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock);
 
+       return 0;
+}
+
+/*
+ * remove an ordered extent from the tree.  No references are dropped
+ * but any waiters are woken.
+ */
+int btrfs_remove_ordered_extent(struct inode *inode,
+                               struct btrfs_ordered_extent *entry)
+{
+       struct btrfs_ordered_inode_tree *tree;
+       int ret;
+
+       tree = &BTRFS_I(inode)->ordered_tree;
+       mutex_lock(&tree->mutex);
+       ret = __btrfs_remove_ordered_extent(inode, entry);
        mutex_unlock(&tree->mutex);
        wake_up(&entry->wait);
-       return 0;
+
+       return ret;
 }
 
 /*
  * wait for all the ordered extents in a root.  This is done when balancing
  * space between drives.
  */
-int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only)
+int btrfs_wait_ordered_extents(struct btrfs_root *root,
+                              int nocow_only, int delay_iput)
 {
        struct list_head splice;
        struct list_head *cur;
@@ -372,7 +390,10 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only)
                if (inode) {
                        btrfs_start_ordered_extent(inode, ordered, 1);
                        btrfs_put_ordered_extent(ordered);
-                       iput(inode);
+                       if (delay_iput)
+                               btrfs_add_delayed_iput(inode);
+                       else
+                               iput(inode);
                } else {
                        btrfs_put_ordered_extent(ordered);
                }
@@ -430,7 +451,7 @@ again:
                                btrfs_wait_ordered_range(inode, 0, (u64)-1);
                        else
                                filemap_flush(inode->i_mapping);
-                       iput(inode);
+                       btrfs_add_delayed_iput(inode);
                }
 
                cond_resched();
@@ -589,7 +610,7 @@ out:
  * After an extent is done, call this to conditionally update the on disk
  * i_size.  i_size is updated to cover any fully written part of the file.
  */
-int btrfs_ordered_update_i_size(struct inode *inode,
+int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
                                struct btrfs_ordered_extent *ordered)
 {
        struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree;
@@ -597,18 +618,30 @@ int btrfs_ordered_update_i_size(struct inode *inode,
        u64 disk_i_size;
        u64 new_i_size;
        u64 i_size_test;
+       u64 i_size = i_size_read(inode);
        struct rb_node *node;
+       struct rb_node *prev = NULL;
        struct btrfs_ordered_extent *test;
+       int ret = 1;
+
+       if (ordered)
+               offset = entry_end(ordered);
 
        mutex_lock(&tree->mutex);
        disk_i_size = BTRFS_I(inode)->disk_i_size;
 
+       /* truncate file */
+       if (disk_i_size > i_size) {
+               BTRFS_I(inode)->disk_i_size = i_size;
+               ret = 0;
+               goto out;
+       }
+
        /*
         * if the disk i_size is already at the inode->i_size, or
         * this ordered extent is inside the disk i_size, we're done
         */
-       if (disk_i_size >= inode->i_size ||
-           ordered->file_offset + ordered->len <= disk_i_size) {
+       if (disk_i_size == i_size || offset <= disk_i_size) {
                goto out;
        }
 
@@ -616,8 +649,7 @@ int btrfs_ordered_update_i_size(struct inode *inode,
         * we can't update the disk_isize if there are delalloc bytes
         * between disk_i_size and  this ordered extent
         */
-       if (test_range_bit(io_tree, disk_i_size,
-                          ordered->file_offset + ordered->len - 1,
+       if (test_range_bit(io_tree, disk_i_size, offset - 1,
                           EXTENT_DELALLOC, 0, NULL)) {
                goto out;
        }
@@ -626,20 +658,32 @@ int btrfs_ordered_update_i_size(struct inode *inode,
         * if we find an ordered extent then we can't update disk i_size
         * yet
         */
-       node = &ordered->rb_node;
-       while (1) {
-               node = rb_prev(node);
-               if (!node)
-                       break;
+       if (ordered) {
+               node = rb_prev(&ordered->rb_node);
+       } else {
+               prev = tree_search(tree, offset);
+               /*
+                * we insert file extents without involving ordered struct,
+                * so there should be no ordered struct cover this offset
+                */
+               if (prev) {
+                       test = rb_entry(prev, struct btrfs_ordered_extent,
+                                       rb_node);
+                       BUG_ON(offset_in_entry(test, offset));
+               }
+               node = prev;
+       }
+       while (node) {
                test = rb_entry(node, struct btrfs_ordered_extent, rb_node);
                if (test->file_offset + test->len <= disk_i_size)
                        break;
-               if (test->file_offset >= inode->i_size)
+               if (test->file_offset >= i_size)
                        break;
                if (test->file_offset >= disk_i_size)
                        goto out;
+               node = rb_prev(node);
        }
-       new_i_size = min_t(u64, entry_end(ordered), i_size_read(inode));
+       new_i_size = min_t(u64, offset, i_size);
 
        /*
         * at this point, we know we can safely update i_size to at least
@@ -647,7 +691,14 @@ int btrfs_ordered_update_i_size(struct inode *inode,
         * walk forward and see if ios from higher up in the file have
         * finished.
         */
-       node = rb_next(&ordered->rb_node);
+       if (ordered) {
+               node = rb_next(&ordered->rb_node);
+       } else {
+               if (prev)
+                       node = rb_next(prev);
+               else
+                       node = rb_first(&tree->tree);
+       }
        i_size_test = 0;
        if (node) {
                /*
@@ -655,10 +706,10 @@ int btrfs_ordered_update_i_size(struct inode *inode,
                 * between our ordered extent and the next one.
                 */
                test = rb_entry(node, struct btrfs_ordered_extent, rb_node);
-               if (test->file_offset > entry_end(ordered))
+               if (test->file_offset > offset)
                        i_size_test = test->file_offset;
        } else {
-               i_size_test = i_size_read(inode);
+               i_size_test = i_size;
        }
 
        /*
@@ -667,15 +718,25 @@ int btrfs_ordered_update_i_size(struct inode *inode,
         * are no delalloc bytes in this area, it is safe to update
         * disk_i_size to the end of the region.
         */
-       if (i_size_test > entry_end(ordered) &&
-           !test_range_bit(io_tree, entry_end(ordered), i_size_test - 1,
-                          EXTENT_DELALLOC, 0, NULL)) {
-               new_i_size = min_t(u64, i_size_test, i_size_read(inode));
+       if (i_size_test > offset &&
+           !test_range_bit(io_tree, offset, i_size_test - 1,
+                           EXTENT_DELALLOC, 0, NULL)) {
+               new_i_size = min_t(u64, i_size_test, i_size);
        }
        BTRFS_I(inode)->disk_i_size = new_i_size;
+       ret = 0;
 out:
+       /*
+        * we need to remove the ordered extent with the tree lock held
+        * so that other people calling this function don't find our fully
+        * processed ordered entry and skip updating the i_size
+        */
+       if (ordered)
+               __btrfs_remove_ordered_extent(inode, ordered);
        mutex_unlock(&tree->mutex);
-       return 0;
+       if (ordered)
+               wake_up(&ordered->wait);
+       return ret;
 }
 
 /*
index f82e87488ca8f47d158c37281a3aafa746d5031d..1fe1282ef47c998aa9cde1c0c43e4f088e7e767c 100644 (file)
@@ -150,12 +150,13 @@ void btrfs_start_ordered_extent(struct inode *inode,
 int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len);
 struct btrfs_ordered_extent *
 btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset);
-int btrfs_ordered_update_i_size(struct inode *inode,
+int btrfs_ordered_update_i_size(struct inode *inode, u64 offset,
                                struct btrfs_ordered_extent *ordered);
 int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum);
-int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only);
 int btrfs_run_ordered_operations(struct btrfs_root *root, int wait);
 int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans,
                                struct btrfs_root *root,
                                struct inode *inode);
+int btrfs_wait_ordered_extents(struct btrfs_root *root,
+                              int nocow_only, int delay_iput);
 #endif
index cfcc93c93a7b4db99b87ef3b91b30cc8d2f7e36b..a9728680eca8ed299deb7fc322be97deeeb6f51b 100644 (file)
@@ -1561,6 +1561,20 @@ static int invalidate_extent_cache(struct btrfs_root *root,
        return 0;
 }
 
+static void put_inodes(struct list_head *list)
+{
+       struct inodevec *ivec;
+       while (!list_empty(list)) {
+               ivec = list_entry(list->next, struct inodevec, list);
+               list_del(&ivec->list);
+               while (ivec->nr > 0) {
+                       ivec->nr--;
+                       iput(ivec->inode[ivec->nr]);
+               }
+               kfree(ivec);
+       }
+}
+
 static int find_next_key(struct btrfs_path *path, int level,
                         struct btrfs_key *key)
 
@@ -1723,6 +1737,11 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
 
                btrfs_btree_balance_dirty(root, nr);
 
+               /*
+                * put inodes outside transaction, otherwise we may deadlock.
+                */
+               put_inodes(&inode_list);
+
                if (replaced && rc->stage == UPDATE_DATA_PTRS)
                        invalidate_extent_cache(root, &key, &next_key);
        }
@@ -1752,19 +1771,7 @@ out:
 
        btrfs_btree_balance_dirty(root, nr);
 
-       /*
-        * put inodes while we aren't holding the tree locks
-        */
-       while (!list_empty(&inode_list)) {
-               struct inodevec *ivec;
-               ivec = list_entry(inode_list.next, struct inodevec, list);
-               list_del(&ivec->list);
-               while (ivec->nr > 0) {
-                       ivec->nr--;
-                       iput(ivec->inode[ivec->nr]);
-               }
-               kfree(ivec);
-       }
+       put_inodes(&inode_list);
 
        if (replaced && rc->stage == UPDATE_DATA_PTRS)
                invalidate_extent_cache(root, &key, &next_key);
@@ -3534,8 +3541,8 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
               (unsigned long long)rc->block_group->key.objectid,
               (unsigned long long)rc->block_group->flags);
 
-       btrfs_start_delalloc_inodes(fs_info->tree_root);
-       btrfs_wait_ordered_extents(fs_info->tree_root, 0);
+       btrfs_start_delalloc_inodes(fs_info->tree_root, 0);
+       btrfs_wait_ordered_extents(fs_info->tree_root, 0, 0);
 
        while (1) {
                rc->extents_found = 0;
@@ -3755,6 +3762,7 @@ out:
                                       BTRFS_DATA_RELOC_TREE_OBJECTID);
                if (IS_ERR(fs_root))
                        err = PTR_ERR(fs_root);
+               btrfs_orphan_cleanup(fs_root);
        }
        return err;
 }
index 752a5463bf53aee147068c2a0a9f678e12250f38..3f9b45704fcdfb83eeda6a55740c56de7a048ce5 100644 (file)
@@ -128,6 +128,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
        substring_t args[MAX_OPT_ARGS];
        char *p, *num;
        int intarg;
+       int ret = 0;
 
        if (!options)
                return 0;
@@ -262,12 +263,18 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
                case Opt_discard:
                        btrfs_set_opt(info->mount_opt, DISCARD);
                        break;
+               case Opt_err:
+                       printk(KERN_INFO "btrfs: unrecognized mount option "
+                              "'%s'\n", p);
+                       ret = -EINVAL;
+                       goto out;
                default:
                        break;
                }
        }
+out:
        kfree(options);
-       return 0;
+       return ret;
 }
 
 /*
@@ -405,8 +412,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
                return 0;
        }
 
-       btrfs_start_delalloc_inodes(root);
-       btrfs_wait_ordered_extents(root, 0);
+       btrfs_start_delalloc_inodes(root, 0);
+       btrfs_wait_ordered_extents(root, 0, 0);
 
        trans = btrfs_start_transaction(root, 1);
        ret = btrfs_commit_transaction(trans, root);
@@ -450,6 +457,8 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
                seq_puts(seq, ",notreelog");
        if (btrfs_test_opt(root, FLUSHONCOMMIT))
                seq_puts(seq, ",flushoncommit");
+       if (btrfs_test_opt(root, DISCARD))
+               seq_puts(seq, ",discard");
        if (!(root->fs_info->sb->s_flags & MS_POSIXACL))
                seq_puts(seq, ",noacl");
        return 0;
index c207e8c32c9bfc5212e111edb440adf4b59f2059..b2acc79f1b342e651a4c31da168c2952efa57ff2 100644 (file)
@@ -333,6 +333,9 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
        memset(trans, 0, sizeof(*trans));
        kmem_cache_free(btrfs_trans_handle_cachep, trans);
 
+       if (throttle)
+               btrfs_run_delayed_iputs(root);
+
        return 0;
 }
 
@@ -354,7 +357,7 @@ int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans,
  * those extents are sent to disk but does not wait on them
  */
 int btrfs_write_marked_extents(struct btrfs_root *root,
-                              struct extent_io_tree *dirty_pages)
+                              struct extent_io_tree *dirty_pages, int mark)
 {
        int ret;
        int err = 0;
@@ -367,7 +370,7 @@ int btrfs_write_marked_extents(struct btrfs_root *root,
 
        while (1) {
                ret = find_first_extent_bit(dirty_pages, start, &start, &end,
-                                           EXTENT_DIRTY);
+                                           mark);
                if (ret)
                        break;
                while (start <= end) {
@@ -413,7 +416,7 @@ int btrfs_write_marked_extents(struct btrfs_root *root,
  * on all the pages and clear them from the dirty pages state tree
  */
 int btrfs_wait_marked_extents(struct btrfs_root *root,
-                             struct extent_io_tree *dirty_pages)
+                             struct extent_io_tree *dirty_pages, int mark)
 {
        int ret;
        int err = 0;
@@ -425,12 +428,12 @@ int btrfs_wait_marked_extents(struct btrfs_root *root,
        unsigned long index;
 
        while (1) {
-               ret = find_first_extent_bit(dirty_pages, 0, &start, &end,
-                                           EXTENT_DIRTY);
+               ret = find_first_extent_bit(dirty_pages, start, &start, &end,
+                                           mark);
                if (ret)
                        break;
 
-               clear_extent_dirty(dirty_pages, start, end, GFP_NOFS);
+               clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS);
                while (start <= end) {
                        index = start >> PAGE_CACHE_SHIFT;
                        start = (u64)(index + 1) << PAGE_CACHE_SHIFT;
@@ -460,13 +463,13 @@ int btrfs_wait_marked_extents(struct btrfs_root *root,
  * those extents are on disk for transaction or log commit
  */
 int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,
-                                       struct extent_io_tree *dirty_pages)
+                               struct extent_io_tree *dirty_pages, int mark)
 {
        int ret;
        int ret2;
 
-       ret = btrfs_write_marked_extents(root, dirty_pages);
-       ret2 = btrfs_wait_marked_extents(root, dirty_pages);
+       ret = btrfs_write_marked_extents(root, dirty_pages, mark);
+       ret2 = btrfs_wait_marked_extents(root, dirty_pages, mark);
        return ret || ret2;
 }
 
@@ -479,7 +482,8 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
                return filemap_write_and_wait(btree_inode->i_mapping);
        }
        return btrfs_write_and_wait_marked_extents(root,
-                                          &trans->transaction->dirty_pages);
+                                          &trans->transaction->dirty_pages,
+                                          EXTENT_DIRTY);
 }
 
 /*
@@ -497,13 +501,16 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
 {
        int ret;
        u64 old_root_bytenr;
+       u64 old_root_used;
        struct btrfs_root *tree_root = root->fs_info->tree_root;
 
+       old_root_used = btrfs_root_used(&root->root_item);
        btrfs_write_dirty_block_groups(trans, root);
 
        while (1) {
                old_root_bytenr = btrfs_root_bytenr(&root->root_item);
-               if (old_root_bytenr == root->node->start)
+               if (old_root_bytenr == root->node->start &&
+                   old_root_used == btrfs_root_used(&root->root_item))
                        break;
 
                btrfs_set_root_node(&root->root_item, root->node);
@@ -512,6 +519,7 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
                                        &root->root_item);
                BUG_ON(ret);
 
+               old_root_used = btrfs_root_used(&root->root_item);
                ret = btrfs_write_dirty_block_groups(trans, root);
                BUG_ON(ret);
        }
@@ -795,7 +803,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        memcpy(&pending->root_key, &key, sizeof(key));
 fail:
        kfree(new_root_item);
-       btrfs_unreserve_metadata_space(root, 6);
        return ret;
 }
 
@@ -807,7 +814,6 @@ static noinline int finish_pending_snapshot(struct btrfs_fs_info *fs_info,
        u64 index = 0;
        struct btrfs_trans_handle *trans;
        struct inode *parent_inode;
-       struct inode *inode;
        struct btrfs_root *parent_root;
 
        parent_inode = pending->dentry->d_parent->d_inode;
@@ -839,8 +845,6 @@ static noinline int finish_pending_snapshot(struct btrfs_fs_info *fs_info,
 
        BUG_ON(ret);
 
-       inode = btrfs_lookup_dentry(parent_inode, pending->dentry);
-       d_instantiate(pending->dentry, inode);
 fail:
        btrfs_end_transaction(trans, fs_info->fs_root);
        return ret;
@@ -994,11 +998,11 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
                mutex_unlock(&root->fs_info->trans_mutex);
 
                if (flush_on_commit) {
-                       btrfs_start_delalloc_inodes(root);
-                       ret = btrfs_wait_ordered_extents(root, 0);
+                       btrfs_start_delalloc_inodes(root, 1);
+                       ret = btrfs_wait_ordered_extents(root, 0, 1);
                        BUG_ON(ret);
                } else if (snap_pending) {
-                       ret = btrfs_wait_ordered_extents(root, 1);
+                       ret = btrfs_wait_ordered_extents(root, 0, 1);
                        BUG_ON(ret);
                }
 
@@ -1116,6 +1120,10 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
                current->journal_info = NULL;
 
        kmem_cache_free(btrfs_trans_handle_cachep, trans);
+
+       if (current != root->fs_info->transaction_kthread)
+               btrfs_run_delayed_iputs(root);
+
        return ret;
 }
 
index d4e3e7a6938cddebb56e05ae4131b7055f08be05..93c7ccb33118f38d420c00c3b790fe0040b7f0ca 100644 (file)
@@ -107,10 +107,10 @@ void btrfs_throttle(struct btrfs_root *root);
 int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,
                                struct btrfs_root *root);
 int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,
-                                       struct extent_io_tree *dirty_pages);
+                               struct extent_io_tree *dirty_pages, int mark);
 int btrfs_write_marked_extents(struct btrfs_root *root,
-                                       struct extent_io_tree *dirty_pages);
+                               struct extent_io_tree *dirty_pages, int mark);
 int btrfs_wait_marked_extents(struct btrfs_root *root,
-                                       struct extent_io_tree *dirty_pages);
+                               struct extent_io_tree *dirty_pages, int mark);
 int btrfs_transaction_in_commit(struct btrfs_fs_info *info);
 #endif
index 741666a7676a80a6553f5b22a37a41dd31971d3e..4a9434b622ecfc0f571c32ea3abf54df3d878123 100644 (file)
@@ -542,8 +542,8 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
 
        saved_nbytes = inode_get_bytes(inode);
        /* drop any overlapping extents */
-       ret = btrfs_drop_extents(trans, root, inode,
-                        start, extent_end, extent_end, start, &alloc_hint, 1);
+       ret = btrfs_drop_extents(trans, inode, start, extent_end,
+                                &alloc_hint, 1);
        BUG_ON(ret);
 
        if (found_type == BTRFS_FILE_EXTENT_REG ||
@@ -930,6 +930,17 @@ out_nowrite:
        return 0;
 }
 
+static int insert_orphan_item(struct btrfs_trans_handle *trans,
+                             struct btrfs_root *root, u64 offset)
+{
+       int ret;
+       ret = btrfs_find_orphan_item(root, offset);
+       if (ret > 0)
+               ret = btrfs_insert_orphan_item(trans, root, offset);
+       return ret;
+}
+
+
 /*
  * There are a few corners where the link count of the file can't
  * be properly maintained during replay.  So, instead of adding
@@ -997,9 +1008,13 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
        }
        BTRFS_I(inode)->index_cnt = (u64)-1;
 
-       if (inode->i_nlink == 0 && S_ISDIR(inode->i_mode)) {
-               ret = replay_dir_deletes(trans, root, NULL, path,
-                                        inode->i_ino, 1);
+       if (inode->i_nlink == 0) {
+               if (S_ISDIR(inode->i_mode)) {
+                       ret = replay_dir_deletes(trans, root, NULL, path,
+                                                inode->i_ino, 1);
+                       BUG_ON(ret);
+               }
+               ret = insert_orphan_item(trans, root, inode->i_ino);
                BUG_ON(ret);
        }
        btrfs_free_path(path);
@@ -1587,7 +1602,6 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb,
                /* inode keys are done during the first stage */
                if (key.type == BTRFS_INODE_ITEM_KEY &&
                    wc->stage == LOG_WALK_REPLAY_INODES) {
-                       struct inode *inode;
                        struct btrfs_inode_item *inode_item;
                        u32 mode;
 
@@ -1603,31 +1617,16 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb,
                                             eb, i, &key);
                        BUG_ON(ret);
 
-                       /* for regular files, truncate away
-                        * extents past the new EOF
+                       /* for regular files, make sure corresponding
+                        * orhpan item exist. extents past the new EOF
+                        * will be truncated later by orphan cleanup.
                         */
                        if (S_ISREG(mode)) {
-                               inode = read_one_inode(root,
-                                                      key.objectid);
-                               BUG_ON(!inode);
-
-                               ret = btrfs_truncate_inode_items(wc->trans,
-                                       root, inode, inode->i_size,
-                                       BTRFS_EXTENT_DATA_KEY);
+                               ret = insert_orphan_item(wc->trans, root,
+                                                        key.objectid);
                                BUG_ON(ret);
-
-                               /* if the nlink count is zero here, the iput
-                                * will free the inode.  We bump it to make
-                                * sure it doesn't get freed until the link
-                                * count fixup is done
-                                */
-                               if (inode->i_nlink == 0) {
-                                       btrfs_inc_nlink(inode);
-                                       btrfs_update_inode(wc->trans,
-                                                          root, inode);
-                               }
-                               iput(inode);
                        }
+
                        ret = link_to_fixup_dir(wc->trans, root,
                                                path, key.objectid);
                        BUG_ON(ret);
@@ -1977,10 +1976,11 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 {
        int index1;
        int index2;
+       int mark;
        int ret;
        struct btrfs_root *log = root->log_root;
        struct btrfs_root *log_root_tree = root->fs_info->log_root_tree;
-       u64 log_transid = 0;
+       unsigned long log_transid = 0;
 
        mutex_lock(&root->log_mutex);
        index1 = root->log_transid % 2;
@@ -2014,24 +2014,29 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
                goto out;
        }
 
+       log_transid = root->log_transid;
+       if (log_transid % 2 == 0)
+               mark = EXTENT_DIRTY;
+       else
+               mark = EXTENT_NEW;
+
        /* we start IO on  all the marked extents here, but we don't actually
         * wait for them until later.
         */
-       ret = btrfs_write_marked_extents(log, &log->dirty_log_pages);
+       ret = btrfs_write_marked_extents(log, &log->dirty_log_pages, mark);
        BUG_ON(ret);
 
        btrfs_set_root_node(&log->root_item, log->node);
 
        root->log_batch = 0;
-       log_transid = root->log_transid;
        root->log_transid++;
        log->log_transid = root->log_transid;
        root->log_start_pid = 0;
        smp_mb();
        /*
-        * log tree has been flushed to disk, new modifications of
-        * the log will be written to new positions. so it's safe to
-        * allow log writers to go in.
+        * IO has been started, blocks of the log tree have WRITTEN flag set
+        * in their headers. new modifications of the log will be written to
+        * new positions. so it's safe to allow log writers to go in.
         */
        mutex_unlock(&root->log_mutex);
 
@@ -2052,7 +2057,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 
        index2 = log_root_tree->log_transid % 2;
        if (atomic_read(&log_root_tree->log_commit[index2])) {
-               btrfs_wait_marked_extents(log, &log->dirty_log_pages);
+               btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
                wait_log_commit(trans, log_root_tree,
                                log_root_tree->log_transid);
                mutex_unlock(&log_root_tree->log_mutex);
@@ -2072,16 +2077,17 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
         * check the full commit flag again
         */
        if (root->fs_info->last_trans_log_full_commit == trans->transid) {
-               btrfs_wait_marked_extents(log, &log->dirty_log_pages);
+               btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
                mutex_unlock(&log_root_tree->log_mutex);
                ret = -EAGAIN;
                goto out_wake_log_root;
        }
 
        ret = btrfs_write_and_wait_marked_extents(log_root_tree,
-                               &log_root_tree->dirty_log_pages);
+                               &log_root_tree->dirty_log_pages,
+                               EXTENT_DIRTY | EXTENT_NEW);
        BUG_ON(ret);
-       btrfs_wait_marked_extents(log, &log->dirty_log_pages);
+       btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark);
 
        btrfs_set_super_log_root(&root->fs_info->super_for_commit,
                                log_root_tree->node->start);
@@ -2147,12 +2153,12 @@ int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root)
 
        while (1) {
                ret = find_first_extent_bit(&log->dirty_log_pages,
-                                   0, &start, &end, EXTENT_DIRTY);
+                               0, &start, &end, EXTENT_DIRTY | EXTENT_NEW);
                if (ret)
                        break;
 
-               clear_extent_dirty(&log->dirty_log_pages,
-                                  start, end, GFP_NOFS);
+               clear_extent_bits(&log->dirty_log_pages, start, end,
+                                 EXTENT_DIRTY | EXTENT_NEW, GFP_NOFS);
        }
 
        if (log->log_transid > 0) {
index 7eda483d7b5aa0cd5e5bd96d149cca6fe2fc8f16..198cff28766d494f3a919673775fe679d560722f 100644 (file)
@@ -2209,7 +2209,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
                max_chunk_size = 10 * calc_size;
                min_stripe_size = 64 * 1024 * 1024;
        } else if (type & BTRFS_BLOCK_GROUP_METADATA) {
-               max_chunk_size = 4 * calc_size;
+               max_chunk_size = 256 * 1024 * 1024;
                min_stripe_size = 32 * 1024 * 1024;
        } else if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
                calc_size = 8 * 1024 * 1024;
index b6dd5967c48a2785074f75db2dacd6a7370a9ec2..193b58f7d3f3b36d027a85756c917aa7191f99b2 100644 (file)
@@ -85,22 +85,23 @@ out:
        return ret;
 }
 
-int __btrfs_setxattr(struct inode *inode, const char *name,
-                           const void *value, size_t size, int flags)
+static int do_setxattr(struct btrfs_trans_handle *trans,
+                      struct inode *inode, const char *name,
+                      const void *value, size_t size, int flags)
 {
        struct btrfs_dir_item *di;
        struct btrfs_root *root = BTRFS_I(inode)->root;
-       struct btrfs_trans_handle *trans;
        struct btrfs_path *path;
-       int ret = 0, mod = 0;
+       size_t name_len = strlen(name);
+       int ret = 0;
+
+       if (name_len + size > BTRFS_MAX_XATTR_SIZE(root))
+               return -ENOSPC;
 
        path = btrfs_alloc_path();
        if (!path)
                return -ENOMEM;
 
-       trans = btrfs_join_transaction(root, 1);
-       btrfs_set_trans_block_group(trans, inode);
-
        /* first lets see if we already have this xattr */
        di = btrfs_lookup_xattr(trans, root, path, inode->i_ino, name,
                                strlen(name), -1);
@@ -118,15 +119,12 @@ int __btrfs_setxattr(struct inode *inode, const char *name,
                }
 
                ret = btrfs_delete_one_dir_name(trans, root, path, di);
-               if (ret)
-                       goto out;
+               BUG_ON(ret);
                btrfs_release_path(root, path);
 
                /* if we don't have a value then we are removing the xattr */
-               if (!value) {
-                       mod = 1;
+               if (!value)
                        goto out;
-               }
        } else {
                btrfs_release_path(root, path);
 
@@ -138,20 +136,45 @@ int __btrfs_setxattr(struct inode *inode, const char *name,
        }
 
        /* ok we have to create a completely new xattr */
-       ret = btrfs_insert_xattr_item(trans, root, name, strlen(name),
-                                     value, size, inode->i_ino);
+       ret = btrfs_insert_xattr_item(trans, root, path, inode->i_ino,
+                                     name, name_len, value, size);
+       BUG_ON(ret);
+out:
+       btrfs_free_path(path);
+       return ret;
+}
+
+int __btrfs_setxattr(struct btrfs_trans_handle *trans,
+                    struct inode *inode, const char *name,
+                    const void *value, size_t size, int flags)
+{
+       struct btrfs_root *root = BTRFS_I(inode)->root;
+       int ret;
+
+       if (trans)
+               return do_setxattr(trans, inode, name, value, size, flags);
+
+       ret = btrfs_reserve_metadata_space(root, 2);
        if (ret)
-               goto out;
-       mod = 1;
+               return ret;
 
-out:
-       if (mod) {
-               inode->i_ctime = CURRENT_TIME;
-               ret = btrfs_update_inode(trans, root, inode);
+       trans = btrfs_start_transaction(root, 1);
+       if (!trans) {
+               ret = -ENOMEM;
+               goto out;
        }
+       btrfs_set_trans_block_group(trans, inode);
 
-       btrfs_end_transaction(trans, root);
-       btrfs_free_path(path);
+       ret = do_setxattr(trans, inode, name, value, size, flags);
+       if (ret)
+               goto out;
+
+       inode->i_ctime = CURRENT_TIME;
+       ret = btrfs_update_inode(trans, root, inode);
+       BUG_ON(ret);
+out:
+       btrfs_end_transaction_throttle(trans, root);
+       btrfs_unreserve_metadata_space(root, 2);
        return ret;
 }
 
@@ -314,7 +337,9 @@ int btrfs_setxattr(struct dentry *dentry, const char *name, const void *value,
 
        if (size == 0)
                value = "";  /* empty EA, do not remove */
-       return __btrfs_setxattr(dentry->d_inode, name, value, size, flags);
+
+       return __btrfs_setxattr(NULL, dentry->d_inode, name, value, size,
+                               flags);
 }
 
 int btrfs_removexattr(struct dentry *dentry, const char *name)
@@ -329,10 +354,13 @@ int btrfs_removexattr(struct dentry *dentry, const char *name)
 
        if (!btrfs_is_valid_xattr(name))
                return -EOPNOTSUPP;
-       return __btrfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE);
+
+       return __btrfs_setxattr(NULL, dentry->d_inode, name, NULL, 0,
+                               XATTR_REPLACE);
 }
 
-int btrfs_xattr_security_init(struct inode *inode, struct inode *dir)
+int btrfs_xattr_security_init(struct btrfs_trans_handle *trans,
+                             struct inode *inode, struct inode *dir)
 {
        int err;
        size_t len;
@@ -354,7 +382,7 @@ int btrfs_xattr_security_init(struct inode *inode, struct inode *dir)
        } else {
                strcpy(name, XATTR_SECURITY_PREFIX);
                strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix);
-               err = __btrfs_setxattr(inode, name, value, len, 0);
+               err = __btrfs_setxattr(trans, inode, name, value, len, 0);
                kfree(name);
        }
 
index c71e9c3cf3f749e8981d19433bef8ada685383aa..721efa0346e037c2f6f32c91d7f284fbc580c87f 100644 (file)
@@ -27,15 +27,16 @@ extern struct xattr_handler *btrfs_xattr_handlers[];
 
 extern ssize_t __btrfs_getxattr(struct inode *inode, const char *name,
                void *buffer, size_t size);
-extern int __btrfs_setxattr(struct inode *inode, const char *name,
-               const void *value, size_t size, int flags);
-
+extern int __btrfs_setxattr(struct btrfs_trans_handle *trans,
+                           struct inode *inode, const char *name,
+                           const void *value, size_t size, int flags);
 extern ssize_t btrfs_getxattr(struct dentry *dentry, const char *name,
                void *buffer, size_t size);
 extern int btrfs_setxattr(struct dentry *dentry, const char *name,
                const void *value, size_t size, int flags);
 extern int btrfs_removexattr(struct dentry *dentry, const char *name);
 
-extern int btrfs_xattr_security_init(struct inode *inode, struct inode *dir);
+extern int btrfs_xattr_security_init(struct btrfs_trans_handle *trans,
+                                    struct inode *inode, struct inode *dir);
 
 #endif /* __XATTR__ */
index 3797e0077b356b4f3c0c7400cd5918ca7f4e8f1a..2906077ac798a529b3a0527bb57f6c43cbae782e 100644 (file)
@@ -84,7 +84,7 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
 static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
 {
        struct cachefiles_object *fsdef;
-       struct nameidata nd;
+       struct path path;
        struct kstatfs stats;
        struct dentry *graveyard, *cachedir, *root;
        const struct cred *saved_cred;
@@ -114,15 +114,12 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
        _debug("- fsdef %p", fsdef);
 
        /* look up the directory at the root of the cache */
-       memset(&nd, 0, sizeof(nd));
-
-       ret = path_lookup(cache->rootdirname, LOOKUP_DIRECTORY, &nd);
+       ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path);
        if (ret < 0)
                goto error_open_root;
 
-       cache->mnt = mntget(nd.path.mnt);
-       root = dget(nd.path.dentry);
-       path_put(&nd.path);
+       cache->mnt = path.mnt;
+       root = path.dentry;
 
        /* check parameters */
        ret = -EOPNOTSUPP;
index 4618516dd994b3c2da8a44c13d83a877d89fb220..c2413561ea753f4ede277ec6736c49db738456f5 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/mount.h>
 #include <linux/statfs.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/fs_struct.h>
 #include "internal.h"
 
@@ -257,8 +258,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
                if (args == data)
                        goto error;
                *args = '\0';
-               for (args++; isspace(*args); args++)
-                       continue;
+               args = skip_spaces(++args);
        }
 
        /* run the appropriate command handler */
index a6c8c6fe8df9ca5d54625a07496c8b2b42dd771f..1d8332563863ce5d858971a68f4a7463c72385c2 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/mount.h>
 #include <linux/file.h>
-#include <linux/ima.h>
 #include "internal.h"
 
 /*
@@ -923,7 +922,6 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
        if (IS_ERR(file)) {
                ret = PTR_ERR(file);
        } else {
-               ima_counts_get(file);
                ret = -EIO;
                if (file->f_op->write) {
                        pos = (loff_t) page->index << PAGE_SHIFT;
index 75949d6a5f1b33484635f6019d08a6f66402cefd..6177f7cca16af1e71969ea72173056dcd5e37afd 100644 (file)
@@ -24,7 +24,7 @@
  */
 
  /*
-  * See Documentation/filesystems/Exporting
+  * See Documentation/filesystems/nfs/Exporting
   * and examples in fs/exportfs
   *
   * Since cifs is a network file system, an "fsid" must be included for
index 6c19040ffeefecdd520fc1093b5ed9db31e8aa7f..00d90c2e66f0cf531eced73b49c0c5e10a02829e 100644 (file)
@@ -38,8 +38,6 @@
 #include <linux/dirent.h>
 #include <linux/fsnotify.h>
 #include <linux/highuid.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
 #include <linux/nfsd/syscall.h>
 #include <linux/personality.h>
 #include <linux/rwsem.h>
index 14cbc831422a1cb84026bfe90d7c2a68cc43d99f..332dd00f08944c375f2f335dff4dcb3bfd5b3ab5 100644 (file)
@@ -1600,8 +1600,6 @@ static long do_ioctl_trans(int fd, unsigned int cmd,
        case KDSKBMETA:
        case KDSKBLED:
        case KDSETLED:
-       /* SG stuff */
-       case SG_SET_TRANSFORM:
        /* AUTOFS */
        case AUTOFS_IOC_READY:
        case AUTOFS_IOC_FAIL:
index a100fa35a48f3702fbe5522e2636501dc8eb93f3..953173a293a93e3d8174e7d5955a70f535a75fb5 100644 (file)
@@ -978,6 +978,7 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name)
        q.hash = full_name_hash(q.name, q.len);
        return d_alloc(parent, &q);
 }
+EXPORT_SYMBOL(d_alloc_name);
 
 /* the caller must hold dcache_lock */
 static void __d_instantiate(struct dentry *dentry, struct inode *inode)
index b912270942fa9197e315703ac6a145d44ca3dfaa..e82adc2debb73de9ae9ca916e65c6e2bed317ef2 100644 (file)
  *
  * If blkfactor is zero then the user's request was aligned to the filesystem's
  * blocksize.
- *
- * lock_type is DIO_LOCKING for regular files on direct-IO-naive filesystems.
- * This determines whether we need to do the fancy locking which prevents
- * direct-IO from being able to read uninitialised disk blocks.  If its zero
- * (blockdev) this locking is not done, and if it is DIO_OWN_LOCKING i_mutex is
- * not held for the entire direct write (taken briefly, initially, during a
- * direct read though, but its never held for the duration of a direct-IO).
  */
 
 struct dio {
@@ -68,7 +61,7 @@ struct dio {
        struct inode *inode;
        int rw;
        loff_t i_size;                  /* i_size when submitted */
-       int lock_type;                  /* doesn't change */
+       int flags;                      /* doesn't change */
        unsigned blkbits;               /* doesn't change */
        unsigned blkfactor;             /* When we're using an alignment which
                                           is finer than the filesystem's soft
@@ -104,6 +97,18 @@ struct dio {
        unsigned cur_page_len;          /* Nr of bytes at cur_page_offset */
        sector_t cur_page_block;        /* Where it starts */
 
+       /* BIO completion state */
+       spinlock_t bio_lock;            /* protects BIO fields below */
+       unsigned long refcount;         /* direct_io_worker() and bios */
+       struct bio *bio_list;           /* singly linked via bi_private */
+       struct task_struct *waiter;     /* waiting task (NULL if none) */
+
+       /* AIO related stuff */
+       struct kiocb *iocb;             /* kiocb */
+       int is_async;                   /* is IO async ? */
+       int io_error;                   /* IO error in completion path */
+       ssize_t result;                 /* IO result */
+
        /*
         * Page fetching state. These variables belong to dio_refill_pages().
         */
@@ -115,22 +120,16 @@ struct dio {
         * Page queue.  These variables belong to dio_refill_pages() and
         * dio_get_page().
         */
-       struct page *pages[DIO_PAGES];  /* page buffer */
        unsigned head;                  /* next page to process */
        unsigned tail;                  /* last valid page + 1 */
        int page_errors;                /* errno from get_user_pages() */
 
-       /* BIO completion state */
-       spinlock_t bio_lock;            /* protects BIO fields below */
-       unsigned long refcount;         /* direct_io_worker() and bios */
-       struct bio *bio_list;           /* singly linked via bi_private */
-       struct task_struct *waiter;     /* waiting task (NULL if none) */
-
-       /* AIO related stuff */
-       struct kiocb *iocb;             /* kiocb */
-       int is_async;                   /* is IO async ? */
-       int io_error;                   /* IO error in completion path */
-       ssize_t result;                 /* IO result */
+       /*
+        * pages[] (and any fields placed after it) are not zeroed out at
+        * allocation time.  Don't add new fields after pages[] unless you
+        * wish that they not be zeroed.
+        */
+       struct page *pages[DIO_PAGES];  /* page buffer */
 };
 
 /*
@@ -240,7 +239,8 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret)
        if (dio->end_io && dio->result)
                dio->end_io(dio->iocb, offset, transferred,
                            dio->map_bh.b_private);
-       if (dio->lock_type == DIO_LOCKING)
+
+       if (dio->flags & DIO_LOCKING)
                /* lockdep: non-owner release */
                up_read_non_owner(&dio->inode->i_alloc_sem);
 
@@ -515,21 +515,24 @@ static int get_more_blocks(struct dio *dio)
                map_bh->b_state = 0;
                map_bh->b_size = fs_count << dio->inode->i_blkbits;
 
+               /*
+                * For writes inside i_size on a DIO_SKIP_HOLES filesystem we
+                * forbid block creations: only overwrites are permitted.
+                * We will return early to the caller once we see an
+                * unmapped buffer head returned, and the caller will fall
+                * back to buffered I/O.
+                *
+                * Otherwise the decision is left to the get_blocks method,
+                * which may decide to handle it or also return an unmapped
+                * buffer head.
+                */
                create = dio->rw & WRITE;
-               if (dio->lock_type == DIO_LOCKING) {
+               if (dio->flags & DIO_SKIP_HOLES) {
                        if (dio->block_in_file < (i_size_read(dio->inode) >>
                                                        dio->blkbits))
                                create = 0;
-               } else if (dio->lock_type == DIO_NO_LOCKING) {
-                       create = 0;
                }
 
-               /*
-                * For writes inside i_size we forbid block creations: only
-                * overwrites are permitted.  We fall back to buffered writes
-                * at a higher level for inside-i_size block-instantiating
-                * writes.
-                */
                ret = (*dio->get_block)(dio->inode, fs_startblk,
                                                map_bh, create);
        }
@@ -1039,7 +1042,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
         * we can let i_mutex go now that its achieved its purpose
         * of protecting us from looking up uninitialized blocks.
         */
-       if ((rw == READ) && (dio->lock_type == DIO_LOCKING))
+       if (rw == READ && (dio->flags & DIO_LOCKING))
                mutex_unlock(&dio->inode->i_mutex);
 
        /*
@@ -1086,30 +1089,28 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
 
 /*
  * This is a library function for use by filesystem drivers.
- * The locking rules are governed by the dio_lock_type parameter.
  *
- * DIO_NO_LOCKING (no locking, for raw block device access)
- * For writes, i_mutex is not held on entry; it is never taken.
+ * The locking rules are governed by the flags parameter:
+ *  - if the flags value contains DIO_LOCKING we use a fancy locking
+ *    scheme for dumb filesystems.
+ *    For writes this function is called under i_mutex and returns with
+ *    i_mutex held, for reads, i_mutex is not held on entry, but it is
+ *    taken and dropped again before returning.
+ *    For reads and writes i_alloc_sem is taken in shared mode and released
+ *    on I/O completion (which may happen asynchronously after returning to
+ *    the caller).
  *
- * DIO_LOCKING (simple locking for regular files)
- * For writes we are called under i_mutex and return with i_mutex held, even
- * though it is internally dropped.
- * For reads, i_mutex is not held on entry, but it is taken and dropped before
- * returning.
- *
- * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of
- *     uninitialised data, allowing parallel direct readers and writers)
- * For writes we are called without i_mutex, return without it, never touch it.
- * For reads we are called under i_mutex and return with i_mutex held, even
- * though it may be internally dropped.
- *
- * Additional i_alloc_sem locking requirements described inline below.
+ *  - if the flags value does NOT contain DIO_LOCKING we don't use any
+ *    internal locking but rather rely on the filesystem to synchronize
+ *    direct I/O reads/writes versus each other and truncate.
+ *    For reads and writes both i_mutex and i_alloc_sem are not held on
+ *    entry and are never taken.
  */
 ssize_t
 __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
        struct block_device *bdev, const struct iovec *iov, loff_t offset, 
        unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io,
-       int dio_lock_type)
+       int flags)
 {
        int seg;
        size_t size;
@@ -1120,8 +1121,6 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
        ssize_t retval = -EINVAL;
        loff_t end = offset;
        struct dio *dio;
-       int release_i_mutex = 0;
-       int acquire_i_mutex = 0;
 
        if (rw & WRITE)
                rw = WRITE_ODIRECT_PLUG;
@@ -1151,48 +1150,41 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
                }
        }
 
-       dio = kzalloc(sizeof(*dio), GFP_KERNEL);
+       dio = kmalloc(sizeof(*dio), GFP_KERNEL);
        retval = -ENOMEM;
        if (!dio)
                goto out;
-
        /*
-        * For block device access DIO_NO_LOCKING is used,
-        *      neither readers nor writers do any locking at all
-        * For regular files using DIO_LOCKING,
-        *      readers need to grab i_mutex and i_alloc_sem
-        *      writers need to grab i_alloc_sem only (i_mutex is already held)
-        * For regular files using DIO_OWN_LOCKING,
-        *      neither readers nor writers take any locks here
+        * Believe it or not, zeroing out the page array caused a .5%
+        * performance regression in a database benchmark.  So, we take
+        * care to only zero out what's needed.
         */
-       dio->lock_type = dio_lock_type;
-       if (dio_lock_type != DIO_NO_LOCKING) {
+       memset(dio, 0, offsetof(struct dio, pages));
+
+       dio->flags = flags;
+       if (dio->flags & DIO_LOCKING) {
                /* watch out for a 0 len io from a tricksy fs */
                if (rw == READ && end > offset) {
-                       struct address_space *mapping;
+                       struct address_space *mapping =
+                                       iocb->ki_filp->f_mapping;
 
-                       mapping = iocb->ki_filp->f_mapping;
-                       if (dio_lock_type != DIO_OWN_LOCKING) {
-                               mutex_lock(&inode->i_mutex);
-                               release_i_mutex = 1;
-                       }
+                       /* will be released by direct_io_worker */
+                       mutex_lock(&inode->i_mutex);
 
                        retval = filemap_write_and_wait_range(mapping, offset,
                                                              end - 1);
                        if (retval) {
+                               mutex_unlock(&inode->i_mutex);
                                kfree(dio);
                                goto out;
                        }
-
-                       if (dio_lock_type == DIO_OWN_LOCKING) {
-                               mutex_unlock(&inode->i_mutex);
-                               acquire_i_mutex = 1;
-                       }
                }
 
-               if (dio_lock_type == DIO_LOCKING)
-                       /* lockdep: not the owner will release it */
-                       down_read_non_owner(&inode->i_alloc_sem);
+               /*
+                * Will be released at I/O completion, possibly in a
+                * different thread.
+                */
+               down_read_non_owner(&inode->i_alloc_sem);
        }
 
        /*
@@ -1210,24 +1202,19 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
        /*
         * In case of error extending write may have instantiated a few
         * blocks outside i_size. Trim these off again for DIO_LOCKING.
-        * NOTE: DIO_NO_LOCK/DIO_OWN_LOCK callers have to handle this by
-        * it's own meaner.
+        *
+        * NOTE: filesystems with their own locking have to handle this
+        * on their own.
         */
-       if (unlikely(retval < 0 && (rw & WRITE))) {
-               loff_t isize = i_size_read(inode);
-
-               if (end > isize && dio_lock_type == DIO_LOCKING)
-                       vmtruncate(inode, isize);
+       if (flags & DIO_LOCKING) {
+               if (unlikely((rw & WRITE) && retval < 0)) {
+                       loff_t isize = i_size_read(inode);
+                       if (end > isize)
+                               vmtruncate(inode, isize);
+               }
        }
 
-       if (rw == READ && dio_lock_type == DIO_LOCKING)
-               release_i_mutex = 0;
-
 out:
-       if (release_i_mutex)
-               mutex_unlock(&inode->i_mutex);
-       else if (acquire_i_mutex)
-               mutex_lock(&inode->i_mutex);
        return retval;
 }
 EXPORT_SYMBOL(__blockdev_direct_IO);
index 2dda5ade75bc78a06461d0b62fbb9f74bde28678..8f006a0d6076f3dbe61ce9d2dd956e7b853d0132 100644 (file)
@@ -62,7 +62,7 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
                struct inode *lower_inode =
                        ecryptfs_inode_to_lower(dentry->d_inode);
 
-               fsstack_copy_attr_all(dentry->d_inode, lower_inode, NULL);
+               fsstack_copy_attr_all(dentry->d_inode, lower_inode);
        }
 out:
        return rc;
index 056fed62d0de8beb39f6a0ab6f195bb2577976e1..429ca0b3ba0872f3be95bfc08417d0b8647298f5 100644 (file)
@@ -626,9 +626,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        lower_new_dir_dentry->d_inode, lower_new_dentry);
        if (rc)
                goto out_lock;
-       fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode, NULL);
+       fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode);
        if (new_dir != old_dir)
-               fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode, NULL);
+               fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode);
 out_lock:
        unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
        dput(lower_new_dentry->d_parent);
@@ -967,7 +967,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
        rc = notify_change(lower_dentry, ia);
        mutex_unlock(&lower_dentry->d_inode->i_mutex);
 out:
-       fsstack_copy_attr_all(inode, lower_inode, NULL);
+       fsstack_copy_attr_all(inode, lower_inode);
        return rc;
 }
 
index c6ac85d6c701f5b7d82e069c9a3f82a67a51d0b3..567bc4b9f70a52029b4e6095a522a0b2f944b307 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/key.h>
 #include <linux/parser.h>
 #include <linux/fs_stack.h>
-#include <linux/ima.h>
 #include "ecryptfs_kernel.h"
 
 /**
@@ -119,7 +118,6 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry)
        const struct cred *cred = current_cred();
        struct ecryptfs_inode_info *inode_info =
                ecryptfs_inode_to_private(ecryptfs_dentry->d_inode);
-       int opened_lower_file = 0;
        int rc = 0;
 
        mutex_lock(&inode_info->lower_file_mutex);
@@ -136,12 +134,9 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry)
                               "for lower_dentry [0x%p] and lower_mnt [0x%p]; "
                               "rc = [%d]\n", lower_dentry, lower_mnt, rc);
                        inode_info->lower_file = NULL;
-               } else
-                       opened_lower_file = 1;
+               }
        }
        mutex_unlock(&inode_info->lower_file_mutex);
-       if (opened_lower_file)
-               ima_counts_get(inode_info->lower_file);
        return rc;
 }
 
@@ -194,7 +189,7 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
                init_special_inode(inode, lower_inode->i_mode,
                                   lower_inode->i_rdev);
        dentry->d_op = &ecryptfs_dops;
-       fsstack_copy_attr_all(inode, lower_inode, NULL);
+       fsstack_copy_attr_all(inode, lower_inode);
        /* This size will be overwritten for real files w/ headers and
         * other metadata */
        fsstack_copy_inode_size(inode, lower_inode);
index 8b47e4200e65e00a64be1bb60a80091b6940ddb2..d26402ff06eaa1fbef5e347e627b029cc8239e8c 100644 (file)
@@ -339,7 +339,7 @@ struct file *eventfd_file_create(unsigned int count, int flags)
        ctx->flags = flags;
 
        file = anon_inode_getfile("[eventfd]", &eventfd_fops, ctx,
-                                 flags & EFD_SHARED_FCNTL_FLAGS);
+                                 O_RDWR | (flags & EFD_SHARED_FCNTL_FLAGS));
        if (IS_ERR(file))
                eventfd_free_ctx(ctx);
 
index 366c503f9657376e969b590cf182da5939dcb1ca..bd056a5b4efc59ceccb8b121100d40e2bb16cf3f 100644 (file)
@@ -1206,7 +1206,7 @@ SYSCALL_DEFINE1(epoll_create1, int, flags)
         * a file structure and a free file descriptor.
         */
        error = anon_inode_getfd("[eventpoll]", &eventpoll_fops, ep,
-                                flags & O_CLOEXEC);
+                                O_RDWR | (flags & O_CLOEXEC));
        if (error < 0)
                ep_free(ep);
 
index c0c636e34f60f5b347407f1c43599e088d7fedca..632b02e34ec72b17564602f9c944996e4889a9cf 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -826,7 +826,9 @@ static int de_thread(struct task_struct *tsk)
                attach_pid(tsk, PIDTYPE_PID,  task_pid(leader));
                transfer_pid(leader, tsk, PIDTYPE_PGID);
                transfer_pid(leader, tsk, PIDTYPE_SID);
+
                list_replace_rcu(&leader->tasks, &tsk->tasks);
+               list_replace_init(&leader->sibling, &tsk->sibling);
 
                tsk->group_leader = tsk;
                leader->group_leader = tsk;
@@ -923,6 +925,15 @@ char *get_task_comm(char *buf, struct task_struct *tsk)
 void set_task_comm(struct task_struct *tsk, char *buf)
 {
        task_lock(tsk);
+
+       /*
+        * Threads may access current->comm without holding
+        * the task lock, so write the string carefully.
+        * Readers without a lock may see incomplete new
+        * names but are safe from non-terminating string reads.
+        */
+       memset(tsk->comm, 0, TASK_COMM_LEN);
+       wmb();
        strlcpy(tsk->comm, buf, sizeof(tsk->comm));
        task_unlock(tsk);
        perf_event_comm(tsk);
@@ -1752,17 +1763,20 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
        struct mm_struct *mm = current->mm;
        struct linux_binfmt * binfmt;
        struct inode * inode;
-       struct file * file;
        const struct cred *old_cred;
        struct cred *cred;
        int retval = 0;
        int flag = 0;
        int ispipe = 0;
-       unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
        char **helper_argv = NULL;
        int helper_argc = 0;
        int dump_count = 0;
        static atomic_t core_dump_count = ATOMIC_INIT(0);
+       struct coredump_params cprm = {
+               .signr = signr,
+               .regs = regs,
+               .limit = current->signal->rlim[RLIMIT_CORE].rlim_cur,
+       };
 
        audit_core_dumps(signr);
 
@@ -1818,15 +1832,15 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
        ispipe = format_corename(corename, signr);
        unlock_kernel();
 
-       if ((!ispipe) && (core_limit < binfmt->min_coredump))
+       if ((!ispipe) && (cprm.limit < binfmt->min_coredump))
                goto fail_unlock;
 
        if (ispipe) {
-               if (core_limit == 0) {
+               if (cprm.limit == 0) {
                        /*
                         * Normally core limits are irrelevant to pipes, since
                         * we're not writing to the file system, but we use
-                        * core_limit of 0 here as a speacial value. Any
+                        * cprm.limit of 0 here as a speacial value. Any
                         * non-zero limit gets set to RLIM_INFINITY below, but
                         * a limit of 0 skips the dump.  This is a consistent
                         * way to catch recursive crashes.  We can still crash
@@ -1859,25 +1873,25 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
                        goto fail_dropcount;
                }
 
-               core_limit = RLIM_INFINITY;
+               cprm.limit = RLIM_INFINITY;
 
                /* SIGPIPE can happen, but it's just never processed */
                if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL,
-                               &file)) {
+                               &cprm.file)) {
                        printk(KERN_INFO "Core dump to %s pipe failed\n",
                               corename);
                        goto fail_dropcount;
                }
        } else
-               file = filp_open(corename,
+               cprm.file = filp_open(corename,
                                 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
                                 0600);
-       if (IS_ERR(file))
+       if (IS_ERR(cprm.file))
                goto fail_dropcount;
-       inode = file->f_path.dentry->d_inode;
+       inode = cprm.file->f_path.dentry->d_inode;
        if (inode->i_nlink > 1)
                goto close_fail;        /* multiple links - don't dump */
-       if (!ispipe && d_unhashed(file->f_path.dentry))
+       if (!ispipe && d_unhashed(cprm.file->f_path.dentry))
                goto close_fail;
 
        /* AK: actually i see no reason to not allow this for named pipes etc.,
@@ -1890,21 +1904,22 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
         */
        if (inode->i_uid != current_fsuid())
                goto close_fail;
-       if (!file->f_op)
+       if (!cprm.file->f_op)
                goto close_fail;
-       if (!file->f_op->write)
+       if (!cprm.file->f_op->write)
                goto close_fail;
-       if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
+       if (!ispipe &&
+           do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file) != 0)
                goto close_fail;
 
-       retval = binfmt->core_dump(signr, regs, file, core_limit);
+       retval = binfmt->core_dump(&cprm);
 
        if (retval)
                current->signal->group_exit_code |= 0x80;
 close_fail:
        if (ispipe && core_pipe_limit)
-               wait_for_dump_helpers(file);
-       filp_close(file, NULL);
+               wait_for_dump_helpers(cprm.file);
+       filp_close(cprm.file, NULL);
 fail_dropcount:
        if (dump_count)
                atomic_dec(&core_dump_count);
index 197c7db583c716f1f33544ae372331c842b9c730..e9e175949a637822a8689e757362673284af0d29 100644 (file)
@@ -6,7 +6,7 @@
  * and for mapping back from file handles to dentries.
  *
  * For details on why we do all the strange and hairy things in here
- * take a look at Documentation/filesystems/Exporting.
+ * take a look at Documentation/filesystems/nfs/Exporting.
  */
 #include <linux/exportfs.h>
 #include <linux/fs.h>
index a63d44256a70eb7412114ffced765c548ad2b7ab..a99e54318c3d3570c8953b7bde1625e1060254de 100644 (file)
@@ -339,12 +339,12 @@ ext2_acl_chmod(struct inode *inode)
  * Extended attribut handlers
  */
 static size_t
-ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size,
-                          const char *name, size_t name_len)
+ext2_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_size,
+                          const char *name, size_t name_len, int type)
 {
        const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return 0;
        if (list && size <= list_size)
                memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
@@ -352,12 +352,12 @@ ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size,
 }
 
 static size_t
-ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size,
-                           const char *name, size_t name_len)
+ext2_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_size,
+                           const char *name, size_t name_len, int type)
 {
        const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return 0;
        if (list && size <= list_size)
                memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
@@ -365,15 +365,18 @@ ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
+ext2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
+                  size_t size, int type)
 {
        struct posix_acl *acl;
        int error;
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return -EOPNOTSUPP;
 
-       acl = ext2_get_acl(inode, type);
+       acl = ext2_get_acl(dentry->d_inode, type);
        if (IS_ERR(acl))
                return PTR_ERR(acl);
        if (acl == NULL)
@@ -385,33 +388,17 @@ ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
 }
 
 static int
-ext2_xattr_get_acl_access(struct inode *inode, const char *name,
-                         void *buffer, size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
-}
-
-static int
-ext2_xattr_get_acl_default(struct inode *inode, const char *name,
-                          void *buffer, size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
-}
-
-static int
-ext2_xattr_set_acl(struct inode *inode, int type, const void *value,
-                  size_t size)
+ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
+                  size_t size, int flags, int type)
 {
        struct posix_acl *acl;
        int error;
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return -EOPNOTSUPP;
-       if (!is_owner_or_cap(inode))
+       if (!is_owner_or_cap(dentry->d_inode))
                return -EPERM;
 
        if (value) {
@@ -426,41 +413,25 @@ ext2_xattr_set_acl(struct inode *inode, int type, const void *value,
        } else
                acl = NULL;
 
-       error = ext2_set_acl(inode, type, acl);
+       error = ext2_set_acl(dentry->d_inode, type, acl);
 
 release_and_out:
        posix_acl_release(acl);
        return error;
 }
 
-static int
-ext2_xattr_set_acl_access(struct inode *inode, const char *name,
-                         const void *value, size_t size, int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
-}
-
-static int
-ext2_xattr_set_acl_default(struct inode *inode, const char *name,
-                          const void *value, size_t size, int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
-}
-
 struct xattr_handler ext2_xattr_acl_access_handler = {
        .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags  = ACL_TYPE_ACCESS,
        .list   = ext2_xattr_list_acl_access,
-       .get    = ext2_xattr_get_acl_access,
-       .set    = ext2_xattr_set_acl_access,
+       .get    = ext2_xattr_get_acl,
+       .set    = ext2_xattr_set_acl,
 };
 
 struct xattr_handler ext2_xattr_acl_default_handler = {
        .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags  = ACL_TYPE_DEFAULT,
        .list   = ext2_xattr_list_acl_default,
-       .get    = ext2_xattr_get_acl_default,
-       .set    = ext2_xattr_set_acl_default,
+       .get    = ext2_xattr_get_acl,
+       .set    = ext2_xattr_set_acl,
 };
index fc2bd05d35591103587c53bb9dbbfe3348c51c9a..7516957273ed7c4bccc516c0b48c204841f56f71 100644 (file)
@@ -721,5 +721,5 @@ const struct file_operations ext2_dir_operations = {
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = ext2_compat_ioctl,
 #endif
-       .fsync          = simple_fsync,
+       .fsync          = ext2_fsync,
 };
index da318b0fa6370f0ff266ccb4117aa5556767725e..061914add3cffe038f3f2d3d86e2214cf8df3ea9 100644 (file)
@@ -155,6 +155,7 @@ extern void ext2_write_super (struct super_block *);
 extern const struct file_operations ext2_dir_operations;
 
 /* file.c */
+extern int ext2_fsync(struct file *file, struct dentry *dentry, int datasync);
 extern const struct inode_operations ext2_file_inode_operations;
 extern const struct file_operations ext2_file_operations;
 extern const struct file_operations ext2_xip_file_operations;
index a2f3afd1a1c1a32ec18f3c0e1385dcb38a9a9ad7..586e3589d4c2c4f2c4f0de1f1bc4e4fbec0816ed 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 #include <linux/time.h>
+#include <linux/pagemap.h>
 #include "ext2.h"
 #include "xattr.h"
 #include "acl.h"
@@ -38,6 +39,22 @@ static int ext2_release_file (struct inode * inode, struct file * filp)
        return 0;
 }
 
+int ext2_fsync(struct file *file, struct dentry *dentry, int datasync)
+{
+       int ret;
+       struct super_block *sb = dentry->d_inode->i_sb;
+       struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
+
+       ret = simple_fsync(file, dentry, datasync);
+       if (ret == -EIO || test_and_clear_bit(AS_EIO, &mapping->flags)) {
+               /* We don't really know where the IO error happened... */
+               ext2_error(sb, __func__,
+                          "detected IO error when writing metadata buffers");
+               ret = -EIO;
+       }
+       return ret;
+}
+
 /*
  * We have mostly NULL's here: the current defaults are ok for
  * the ext2 filesystem.
@@ -55,7 +72,7 @@ const struct file_operations ext2_file_operations = {
        .mmap           = generic_file_mmap,
        .open           = generic_file_open,
        .release        = ext2_release_file,
-       .fsync          = simple_fsync,
+       .fsync          = ext2_fsync,
        .splice_read    = generic_file_splice_read,
        .splice_write   = generic_file_splice_write,
 };
@@ -72,7 +89,7 @@ const struct file_operations ext2_xip_file_operations = {
        .mmap           = xip_file_mmap,
        .open           = generic_file_open,
        .release        = ext2_release_file,
-       .fsync          = simple_fsync,
+       .fsync          = ext2_fsync,
 };
 #endif
 
index 1388802b78030802f419bb1a31f7bd913a2442ab..f9cb54a585ce8298e7b2fb9bf90169f8323de289 100644 (file)
@@ -1105,9 +1105,30 @@ failed_sbi:
        return ret;
 }
 
+static void ext2_clear_super_error(struct super_block *sb)
+{
+       struct buffer_head *sbh = EXT2_SB(sb)->s_sbh;
+
+       if (buffer_write_io_error(sbh)) {
+               /*
+                * Oh, dear.  A previous attempt to write the
+                * superblock failed.  This could happen because the
+                * USB device was yanked out.  Or it could happen to
+                * be a transient write error and maybe the block will
+                * be remapped.  Nothing we can do but to retry the
+                * write and hope for the best.
+                */
+               printk(KERN_ERR "EXT2-fs: %s previous I/O error to "
+                      "superblock detected", sb->s_id);
+               clear_buffer_write_io_error(sbh);
+               set_buffer_uptodate(sbh);
+       }
+}
+
 static void ext2_commit_super (struct super_block * sb,
                               struct ext2_super_block * es)
 {
+       ext2_clear_super_error(sb);
        es->s_wtime = cpu_to_le32(get_seconds());
        mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
        sb->s_dirt = 0;
@@ -1115,6 +1136,7 @@ static void ext2_commit_super (struct super_block * sb,
 
 static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es)
 {
+       ext2_clear_super_error(sb);
        es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb));
        es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb));
        es->s_wtime = cpu_to_le32(get_seconds());
index 7913531ec6d5d1c7c750bb13b6912d4c844fa448..904f00642f84456496114eb1aad86ef7974cee6b 100644 (file)
@@ -60,6 +60,7 @@
 #include <linux/mbcache.h>
 #include <linux/quotaops.h>
 #include <linux/rwsem.h>
+#include <linux/security.h>
 #include "ext2.h"
 #include "xattr.h"
 #include "acl.h"
@@ -249,8 +250,9 @@ cleanup:
  * used / required on success.
  */
 static int
-ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
+ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
+       struct inode *inode = dentry->d_inode;
        struct buffer_head *bh = NULL;
        struct ext2_xattr_entry *entry;
        char *end;
@@ -300,9 +302,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
                        ext2_xattr_handler(entry->e_name_index);
 
                if (handler) {
-                       size_t size = handler->list(inode, buffer, rest,
+                       size_t size = handler->list(dentry, buffer, rest,
                                                    entry->e_name,
-                                                   entry->e_name_len);
+                                                   entry->e_name_len,
+                                                   handler->flags);
                        if (buffer) {
                                if (size > rest) {
                                        error = -ERANGE;
@@ -330,7 +333,7 @@ cleanup:
 ssize_t
 ext2_listxattr(struct dentry *dentry, char *buffer, size_t size)
 {
-       return ext2_xattr_list(dentry->d_inode, buffer, size);
+       return ext2_xattr_list(dentry, buffer, size);
 }
 
 /*
index 70c0dbdcdcb75447cb73602151c2166e0805bb57..c8155845ac0518e8665e122be57fcfe988a9fa56 100644 (file)
@@ -11,8 +11,8 @@
 #include "xattr.h"
 
 static size_t
-ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size,
-                        const char *name, size_t name_len)
+ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
+                        const char *name, size_t name_len, int type)
 {
        const int prefix_len = XATTR_SECURITY_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
@@ -26,22 +26,22 @@ ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext2_xattr_security_get(struct inode *inode, const char *name,
-                      void *buffer, size_t size)
+ext2_xattr_security_get(struct dentry *dentry, const char *name,
+                      void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name,
+       return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name,
                              buffer, size);
 }
 
 static int
-ext2_xattr_security_set(struct inode *inode, const char *name,
-                      const void *value, size_t size, int flags)
+ext2_xattr_security_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, name,
+       return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name,
                              value, size, flags);
 }
 
index e8219f8eae9f293bff015a07c1dd11cccc00febf..2a26d71f47713031764c3ed19d82881f6d0a6712 100644 (file)
@@ -13,8 +13,8 @@
 #include "xattr.h"
 
 static size_t
-ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
-                       const char *name, size_t name_len)
+ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
+               const char *name, size_t name_len, int type)
 {
        const int prefix_len = XATTR_TRUSTED_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
@@ -31,22 +31,22 @@ ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext2_xattr_trusted_get(struct inode *inode, const char *name,
-                      void *buffer, size_t size)
+ext2_xattr_trusted_get(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
+       return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name,
                              buffer, size);
 }
 
 static int
-ext2_xattr_trusted_set(struct inode *inode, const char *name,
-                      const void *value, size_t size, int flags)
+ext2_xattr_trusted_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
+       return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name,
                              value, size, flags);
 }
 
index 92495d28c62f0b43da553efba59e482d16d388bc..3f6caf3684b47ebc42c1dfd310067eb07d18b8c0 100644 (file)
 #include "xattr.h"
 
 static size_t
-ext2_xattr_user_list(struct inode *inode, char *list, size_t list_size,
-                    const char *name, size_t name_len)
+ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
+               const char *name, size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_USER_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
 
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return 0;
 
        if (list && total_len <= list_size) {
@@ -30,27 +30,28 @@ ext2_xattr_user_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext2_xattr_user_get(struct inode *inode, const char *name,
-                   void *buffer, size_t size)
+ext2_xattr_user_get(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return -EOPNOTSUPP;
-       return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name, buffer, size);
+       return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_USER,
+                             name, buffer, size);
 }
 
 static int
-ext2_xattr_user_set(struct inode *inode, const char *name,
-                   const void *value, size_t size, int flags)
+ext2_xattr_user_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return -EOPNOTSUPP;
 
-       return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name,
-                             value, size, flags);
+       return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_USER,
+                             name, value, size, flags);
 }
 
 struct xattr_handler ext2_xattr_user_handler = {
index c9b0df376b5f751050c616a96ed0c79c697c7008..82ba34158661f89a323cda8e86c85d9b8652cbe9 100644 (file)
@@ -366,12 +366,12 @@ out:
  * Extended attribute handlers
  */
 static size_t
-ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
-                          const char *name, size_t name_len)
+ext3_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len,
+                          const char *name, size_t name_len, int type)
 {
        const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return 0;
        if (list && size <= list_len)
                memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
@@ -379,12 +379,12 @@ ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
 }
 
 static size_t
-ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
-                           const char *name, size_t name_len)
+ext3_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len,
+                           const char *name, size_t name_len, int type)
 {
        const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return 0;
        if (list && size <= list_len)
                memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
@@ -392,15 +392,18 @@ ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
 }
 
 static int
-ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
+ext3_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
+                  size_t size, int type)
 {
        struct posix_acl *acl;
        int error;
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return -EOPNOTSUPP;
 
-       acl = ext3_get_acl(inode, type);
+       acl = ext3_get_acl(dentry->d_inode, type);
        if (IS_ERR(acl))
                return PTR_ERR(acl);
        if (acl == NULL)
@@ -412,31 +415,16 @@ ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
 }
 
 static int
-ext3_xattr_get_acl_access(struct inode *inode, const char *name,
-                         void *buffer, size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext3_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
-}
-
-static int
-ext3_xattr_get_acl_default(struct inode *inode, const char *name,
-                          void *buffer, size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext3_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
-}
-
-static int
-ext3_xattr_set_acl(struct inode *inode, int type, const void *value,
-                  size_t size)
+ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
+                  size_t size, int flags, int type)
 {
+       struct inode *inode = dentry->d_inode;
        handle_t *handle;
        struct posix_acl *acl;
        int error, retries = 0;
 
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
        if (!test_opt(inode->i_sb, POSIX_ACL))
                return -EOPNOTSUPP;
        if (!is_owner_or_cap(inode))
@@ -468,34 +456,18 @@ release_and_out:
        return error;
 }
 
-static int
-ext3_xattr_set_acl_access(struct inode *inode, const char *name,
-                         const void *value, size_t size, int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext3_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
-}
-
-static int
-ext3_xattr_set_acl_default(struct inode *inode, const char *name,
-                          const void *value, size_t size, int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext3_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
-}
-
 struct xattr_handler ext3_xattr_acl_access_handler = {
        .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags  = ACL_TYPE_ACCESS,
        .list   = ext3_xattr_list_acl_access,
-       .get    = ext3_xattr_get_acl_access,
-       .set    = ext3_xattr_set_acl_access,
+       .get    = ext3_xattr_get_acl,
+       .set    = ext3_xattr_set_acl,
 };
 
 struct xattr_handler ext3_xattr_acl_default_handler = {
        .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags  = ACL_TYPE_DEFAULT,
        .list   = ext3_xattr_list_acl_default,
-       .get    = ext3_xattr_get_acl_default,
-       .set    = ext3_xattr_set_acl_default,
+       .get    = ext3_xattr_get_acl,
+       .set    = ext3_xattr_set_acl,
 };
index ad14227f509e8ed5bb11d9d8249a842f47bbf94f..455e6e6e5cb993912ab0ddae5dd1b6e16d60a7fa 100644 (file)
@@ -970,7 +970,7 @@ static int ext3_get_block(struct inode *inode, sector_t iblock,
                if (max_blocks > DIO_MAX_BLOCKS)
                        max_blocks = DIO_MAX_BLOCKS;
                handle = ext3_journal_start(inode, DIO_CREDITS +
-                               2 * EXT3_QUOTA_TRANS_BLOCKS(inode->i_sb));
+                               EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb));
                if (IS_ERR(handle)) {
                        ret = PTR_ERR(handle);
                        goto out;
@@ -3146,8 +3146,8 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)
 
                /* (user+group)*(old+new) structure, inode write (sb,
                 * inode block, ? - but truncate inode update has it) */
-               handle = ext3_journal_start(inode, 2*(EXT3_QUOTA_INIT_BLOCKS(inode->i_sb)+
-                                       EXT3_QUOTA_DEL_BLOCKS(inode->i_sb))+3);
+               handle = ext3_journal_start(inode, EXT3_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)+
+                                       EXT3_MAXQUOTAS_DEL_BLOCKS(inode->i_sb)+3);
                if (IS_ERR(handle)) {
                        error = PTR_ERR(handle);
                        goto err_out;
@@ -3239,7 +3239,7 @@ static int ext3_writepage_trans_blocks(struct inode *inode)
 #ifdef CONFIG_QUOTA
        /* We know that structure was already allocated during vfs_dq_init so
         * we will be updating only the data blocks + inodes */
-       ret += 2*EXT3_QUOTA_TRANS_BLOCKS(inode->i_sb);
+       ret += EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
 #endif
 
        return ret;
index aad6400c9b77e17010b3a9588ea5a19e5d0b4bdf..7b0e44f7d66fb839c7c8002fb6e3928b5e3e04a8 100644 (file)
@@ -1699,7 +1699,7 @@ static int ext3_create (struct inode * dir, struct dentry * dentry, int mode,
 retry:
        handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
                                        EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
-                                       2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb));
+                                       EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
        if (IS_ERR(handle))
                return PTR_ERR(handle);
 
@@ -1733,7 +1733,7 @@ static int ext3_mknod (struct inode * dir, struct dentry *dentry,
 retry:
        handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
                                        EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
-                                       2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb));
+                                       EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
        if (IS_ERR(handle))
                return PTR_ERR(handle);
 
@@ -1769,7 +1769,7 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode)
 retry:
        handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
                                        EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
-                                       2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb));
+                                       EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
        if (IS_ERR(handle))
                return PTR_ERR(handle);
 
@@ -1920,7 +1920,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
        struct ext3_iloc iloc;
        int err = 0, rc;
 
-       lock_super(sb);
+       mutex_lock(&EXT3_SB(sb)->s_orphan_lock);
        if (!list_empty(&EXT3_I(inode)->i_orphan))
                goto out_unlock;
 
@@ -1929,9 +1929,13 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
 
        /* @@@ FIXME: Observation from aviro:
         * I think I can trigger J_ASSERT in ext3_orphan_add().  We block
-        * here (on lock_super()), so race with ext3_link() which might bump
+        * here (on s_orphan_lock), so race with ext3_link() which might bump
         * ->i_nlink. For, say it, character device. Not a regular file,
         * not a directory, not a symlink and ->i_nlink > 0.
+        *
+        * tytso, 4/25/2009: I'm not sure how that could happen;
+        * shouldn't the fs core protect us from these sort of
+        * unlink()/link() races?
         */
        J_ASSERT ((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
                S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
@@ -1968,7 +1972,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
        jbd_debug(4, "orphan inode %lu will point to %d\n",
                        inode->i_ino, NEXT_ORPHAN(inode));
 out_unlock:
-       unlock_super(sb);
+       mutex_unlock(&EXT3_SB(sb)->s_orphan_lock);
        ext3_std_error(inode->i_sb, err);
        return err;
 }
@@ -1986,11 +1990,9 @@ int ext3_orphan_del(handle_t *handle, struct inode *inode)
        struct ext3_iloc iloc;
        int err = 0;
 
-       lock_super(inode->i_sb);
-       if (list_empty(&ei->i_orphan)) {
-               unlock_super(inode->i_sb);
-               return 0;
-       }
+       mutex_lock(&EXT3_SB(inode->i_sb)->s_orphan_lock);
+       if (list_empty(&ei->i_orphan))
+               goto out;
 
        ino_next = NEXT_ORPHAN(inode);
        prev = ei->i_orphan.prev;
@@ -2040,7 +2042,7 @@ int ext3_orphan_del(handle_t *handle, struct inode *inode)
 out_err:
        ext3_std_error(inode->i_sb, err);
 out:
-       unlock_super(inode->i_sb);
+       mutex_unlock(&EXT3_SB(inode->i_sb)->s_orphan_lock);
        return err;
 
 out_brelse:
@@ -2175,7 +2177,7 @@ static int ext3_symlink (struct inode * dir,
 retry:
        handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
                                        EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 +
-                                       2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb));
+                                       EXT3_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
        if (IS_ERR(handle))
                return PTR_ERR(handle);
 
index 5f83b61791786a06eba1d5014697bfbf31fa47ab..54351ac7cef92deba61a0473ee4ef01589c67c39 100644 (file)
@@ -209,7 +209,7 @@ static int setup_new_group_blocks(struct super_block *sb,
        if (IS_ERR(handle))
                return PTR_ERR(handle);
 
-       lock_super(sb);
+       mutex_lock(&sbi->s_resize_lock);
        if (input->group != sbi->s_groups_count) {
                err = -EBUSY;
                goto exit_journal;
@@ -324,7 +324,7 @@ exit_bh:
        brelse(bh);
 
 exit_journal:
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_resize_lock);
        if ((err2 = ext3_journal_stop(handle)) && !err)
                err = err2;
 
@@ -662,11 +662,12 @@ exit_free:
  * important part is that the new block and inode counts are in the backup
  * superblocks, and the location of the new group metadata in the GDT backups.
  *
- * We do not need lock_super() for this, because these blocks are not
- * otherwise touched by the filesystem code when it is mounted.  We don't
- * need to worry about last changing from sbi->s_groups_count, because the
- * worst that can happen is that we do not copy the full number of backups
- * at this time.  The resize which changed s_groups_count will backup again.
+ * We do not need take the s_resize_lock for this, because these
+ * blocks are not otherwise touched by the filesystem code when it is
+ * mounted.  We don't need to worry about last changing from
+ * sbi->s_groups_count, because the worst that can happen is that we
+ * do not copy the full number of backups at this time.  The resize
+ * which changed s_groups_count will backup again.
  */
 static void update_backups(struct super_block *sb,
                           int blk_off, char *data, int size)
@@ -825,7 +826,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
                goto exit_put;
        }
 
-       lock_super(sb);
+       mutex_lock(&sbi->s_resize_lock);
        if (input->group != sbi->s_groups_count) {
                ext3_warning(sb, __func__,
                             "multiple resizers run on filesystem!");
@@ -856,7 +857,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
        /*
         * OK, now we've set up the new group.  Time to make it active.
         *
-        * Current kernels don't lock all allocations via lock_super(),
+        * We do not lock all allocations via s_resize_lock
         * so we have to be safe wrt. concurrent accesses the group
         * data.  So we need to be careful to set all of the relevant
         * group descriptor data etc. *before* we enable the group.
@@ -900,12 +901,12 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
         *
         * The precise rules we use are:
         *
-        * * Writers of s_groups_count *must* hold lock_super
+        * * Writers of s_groups_count *must* hold s_resize_lock
         * AND
         * * Writers must perform a smp_wmb() after updating all dependent
         *   data and before modifying the groups count
         *
-        * * Readers must hold lock_super() over the access
+        * * Readers must hold s_resize_lock over the access
         * OR
         * * Readers must perform an smp_rmb() after reading the groups count
         *   and before reading any dependent data.
@@ -936,7 +937,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
        ext3_journal_dirty_metadata(handle, sbi->s_sbh);
 
 exit_journal:
-       unlock_super(sb);
+       mutex_unlock(&sbi->s_resize_lock);
        if ((err2 = ext3_journal_stop(handle)) && !err)
                err = err2;
        if (!err) {
@@ -973,7 +974,7 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
 
        /* We don't need to worry about locking wrt other resizers just
         * yet: we're going to revalidate es->s_blocks_count after
-        * taking lock_super() below. */
+        * taking the s_resize_lock below. */
        o_blocks_count = le32_to_cpu(es->s_blocks_count);
        o_groups_count = EXT3_SB(sb)->s_groups_count;
 
@@ -1045,11 +1046,11 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
                goto exit_put;
        }
 
-       lock_super(sb);
+       mutex_lock(&EXT3_SB(sb)->s_resize_lock);
        if (o_blocks_count != le32_to_cpu(es->s_blocks_count)) {
                ext3_warning(sb, __func__,
                             "multiple resizers run on filesystem!");
-               unlock_super(sb);
+               mutex_unlock(&EXT3_SB(sb)->s_resize_lock);
                ext3_journal_stop(handle);
                err = -EBUSY;
                goto exit_put;
@@ -1059,13 +1060,13 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
                                                 EXT3_SB(sb)->s_sbh))) {
                ext3_warning(sb, __func__,
                             "error %d on journal write access", err);
-               unlock_super(sb);
+               mutex_unlock(&EXT3_SB(sb)->s_resize_lock);
                ext3_journal_stop(handle);
                goto exit_put;
        }
        es->s_blocks_count = cpu_to_le32(o_blocks_count + add);
        ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
-       unlock_super(sb);
+       mutex_unlock(&EXT3_SB(sb)->s_resize_lock);
        ext3_debug("freeing blocks %lu through "E3FSBLK"\n", o_blocks_count,
                   o_blocks_count + add);
        ext3_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks);
index 7ad1e8c30bd0a2adbfdc0268dc34377e47578684..afa2b569da101094dee07e58fda0f40391f8e045 100644 (file)
@@ -1928,6 +1928,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
        sb->dq_op = &ext3_quota_operations;
 #endif
        INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
+       mutex_init(&sbi->s_orphan_lock);
+       mutex_init(&sbi->s_resize_lock);
 
        sb->s_root = NULL;
 
@@ -2014,14 +2016,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
        }
 
        ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY);
-       /*
-        * akpm: core read_super() calls in here with the superblock locked.
-        * That deadlocks, because orphan cleanup needs to lock the superblock
-        * in numerous places.  Here we just pop the lock - it's relatively
-        * harmless, because we are now ready to accept write_super() requests,
-        * and aviro says that's the only reason for hanging onto the
-        * superblock lock.
-        */
+
        EXT3_SB(sb)->s_mount_state |= EXT3_ORPHAN_FS;
        ext3_orphan_cleanup(sb, es);
        EXT3_SB(sb)->s_mount_state &= ~EXT3_ORPHAN_FS;
@@ -2403,13 +2398,11 @@ static void ext3_mark_recovery_complete(struct super_block * sb,
        if (journal_flush(journal) < 0)
                goto out;
 
-       lock_super(sb);
        if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER) &&
            sb->s_flags & MS_RDONLY) {
                EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
                ext3_commit_super(sb, es, 1);
        }
-       unlock_super(sb);
 
 out:
        journal_unlock_updates(journal);
@@ -2601,13 +2594,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
                            (sbi->s_mount_state & EXT3_VALID_FS))
                                es->s_state = cpu_to_le16(sbi->s_mount_state);
 
-                       /*
-                        * We have to unlock super so that we can wait for
-                        * transactions.
-                        */
-                       unlock_super(sb);
                        ext3_mark_recovery_complete(sb, es);
-                       lock_super(sb);
                } else {
                        __le32 ret;
                        if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb,
index 387d92d00b977cd271bdab9416323909908242e3..66895ccf76c7a26afe8a63ef3d295a316a854d9e 100644 (file)
@@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_cache_find(struct inode *,
                                                 struct mb_cache_entry **);
 static void ext3_xattr_rehash(struct ext3_xattr_header *,
                              struct ext3_xattr_entry *);
-static int ext3_xattr_list(struct inode *inode, char *buffer,
+static int ext3_xattr_list(struct dentry *dentry, char *buffer,
                           size_t buffer_size);
 
 static struct mb_cache *ext3_xattr_cache;
@@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index)
 ssize_t
 ext3_listxattr(struct dentry *dentry, char *buffer, size_t size)
 {
-       return ext3_xattr_list(dentry->d_inode, buffer, size);
+       return ext3_xattr_list(dentry, buffer, size);
 }
 
 static int
@@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int name_index, const char *name,
 }
 
 static int
-ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry,
+ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
                        char *buffer, size_t buffer_size)
 {
        size_t rest = buffer_size;
@@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry,
                        ext3_xattr_handler(entry->e_name_index);
 
                if (handler) {
-                       size_t size = handler->list(inode, buffer, rest,
+                       size_t size = handler->list(dentry, buffer, rest,
                                                    entry->e_name,
-                                                   entry->e_name_len);
+                                                   entry->e_name_len,
+                                                   handler->flags);
                        if (buffer) {
                                if (size > rest)
                                        return -ERANGE;
@@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry,
 }
 
 static int
-ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
+ext3_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
+       struct inode *inode = dentry->d_inode;
        struct buffer_head *bh = NULL;
        int error;
 
@@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
                goto cleanup;
        }
        ext3_xattr_cache_insert(bh);
-       error = ext3_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size);
+       error = ext3_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
 
 cleanup:
        brelse(bh);
@@ -392,8 +394,9 @@ cleanup:
 }
 
 static int
-ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size)
+ext3_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
+       struct inode *inode = dentry->d_inode;
        struct ext3_xattr_ibody_header *header;
        struct ext3_inode *raw_inode;
        struct ext3_iloc iloc;
@@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size)
        error = ext3_xattr_check_names(IFIRST(header), end);
        if (error)
                goto cleanup;
-       error = ext3_xattr_list_entries(inode, IFIRST(header),
+       error = ext3_xattr_list_entries(dentry, IFIRST(header),
                                        buffer, buffer_size);
 
 cleanup:
@@ -430,12 +433,12 @@ cleanup:
  * used / required on success.
  */
 static int
-ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
+ext3_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
        int i_error, b_error;
 
-       down_read(&EXT3_I(inode)->xattr_sem);
-       i_error = ext3_xattr_ibody_list(inode, buffer, buffer_size);
+       down_read(&EXT3_I(dentry->d_inode)->xattr_sem);
+       i_error = ext3_xattr_ibody_list(dentry, buffer, buffer_size);
        if (i_error < 0) {
                b_error = 0;
        } else {
@@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
                        buffer += i_error;
                        buffer_size -= i_error;
                }
-               b_error = ext3_xattr_block_list(inode, buffer, buffer_size);
+               b_error = ext3_xattr_block_list(dentry, buffer, buffer_size);
                if (b_error < 0)
                        i_error = 0;
        }
-       up_read(&EXT3_I(inode)->xattr_sem);
+       up_read(&EXT3_I(dentry->d_inode)->xattr_sem);
        return i_error + b_error;
 }
 
index 37b81097bdf2a147b6bd2e7720e9ae8efe8170a7..474348788dd96ed35fb8ac771509a930212d11c2 100644 (file)
@@ -12,8 +12,8 @@
 #include "xattr.h"
 
 static size_t
-ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size,
-                        const char *name, size_t name_len)
+ext3_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
+                        const char *name, size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
@@ -28,23 +28,23 @@ ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext3_xattr_security_get(struct inode *inode, const char *name,
-                      void *buffer, size_t size)
+ext3_xattr_security_get(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext3_xattr_get(inode, EXT3_XATTR_INDEX_SECURITY, name,
-                             buffer, size);
+       return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY,
+                             name, buffer, size);
 }
 
 static int
-ext3_xattr_security_set(struct inode *inode, const char *name,
-                      const void *value, size_t size, int flags)
+ext3_xattr_security_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext3_xattr_set(inode, EXT3_XATTR_INDEX_SECURITY, name,
-                             value, size, flags);
+       return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY,
+                             name, value, size, flags);
 }
 
 int
index c7c41a410c4bfed2761ade463b9c34957f4bf5f5..e5562845ed9624f57d3ce8bd80c87cd4e2113f68 100644 (file)
@@ -14,8 +14,8 @@
 #include "xattr.h"
 
 static size_t
-ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
-                       const char *name, size_t name_len)
+ext3_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
+               const char *name, size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
@@ -32,22 +32,22 @@ ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext3_xattr_trusted_get(struct inode *inode, const char *name,
-                      void *buffer, size_t size)
+ext3_xattr_trusted_get(struct dentry *dentry, const char *name,
+                      void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, name,
-                             buffer, size);
+       return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED,
+                             name, buffer, size);
 }
 
 static int
-ext3_xattr_trusted_set(struct inode *inode, const char *name,
-                      const void *value, size_t size, int flags)
+ext3_xattr_trusted_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext3_xattr_set(inode, EXT3_XATTR_INDEX_TRUSTED, name,
+       return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED, name,
                              value, size, flags);
 }
 
index 430fe63b31b397d37370758ac119eeb2139469bd..3bcfe9ee0a68bfe35191ffc1e29df26ef3f0c964 100644 (file)
 #include "xattr.h"
 
 static size_t
-ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size,
-                    const char *name, size_t name_len)
+ext3_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
+               const char *name, size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_USER_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
 
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return 0;
 
        if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext3_xattr_user_get(struct inode *inode, const char *name,
-                   void *buffer, size_t size)
+ext3_xattr_user_get(struct dentry *dentry, const char *name, void *buffer,
+               size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return -EOPNOTSUPP;
-       return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name, buffer, size);
+       return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_USER,
+                             name, buffer, size);
 }
 
 static int
-ext3_xattr_user_set(struct inode *inode, const char *name,
-                   const void *value, size_t size, int flags)
+ext3_xattr_user_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return -EOPNOTSUPP;
-       return ext3_xattr_set(inode, EXT3_XATTR_INDEX_USER, name,
-                             value, size, flags);
+       return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_USER,
+                             name, value, size, flags);
 }
 
 struct xattr_handler ext3_xattr_user_handler = {
index 9acf7e808139d3df688da7d66ffb33b5cf081d8e..9ed1bb1f319f381b700a6386a4d8d068d04e0fdf 100644 (file)
@@ -28,6 +28,7 @@ config EXT4_FS
 
 config EXT4_USE_FOR_EXT23
        bool "Use ext4 for ext2/ext3 file systems"
+       depends on EXT4_FS
        depends on EXT3_FS=n || EXT2_FS=n
        default y
        help
index 0df88b2a69b0e4b5a7d90c5762447414f1e875e9..8a2a29d35a6fe57598d306b06df5eed01489cc7b 100644 (file)
@@ -364,12 +364,12 @@ out:
  * Extended attribute handlers
  */
 static size_t
-ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
-                          const char *name, size_t name_len)
+ext4_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len,
+                          const char *name, size_t name_len, int type)
 {
        const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return 0;
        if (list && size <= list_len)
                memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
@@ -377,12 +377,12 @@ ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len,
 }
 
 static size_t
-ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
-                           const char *name, size_t name_len)
+ext4_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len,
+                           const char *name, size_t name_len, int type)
 {
        const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return 0;
        if (list && size <= list_len)
                memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
@@ -390,15 +390,18 @@ ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len,
 }
 
 static int
-ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
+ext4_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
+                  size_t size, int type)
 {
        struct posix_acl *acl;
        int error;
 
-       if (!test_opt(inode->i_sb, POSIX_ACL))
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+       if (!test_opt(dentry->d_sb, POSIX_ACL))
                return -EOPNOTSUPP;
 
-       acl = ext4_get_acl(inode, type);
+       acl = ext4_get_acl(dentry->d_inode, type);
        if (IS_ERR(acl))
                return PTR_ERR(acl);
        if (acl == NULL)
@@ -410,31 +413,16 @@ ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
 }
 
 static int
-ext4_xattr_get_acl_access(struct inode *inode, const char *name,
-                         void *buffer, size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext4_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
-}
-
-static int
-ext4_xattr_get_acl_default(struct inode *inode, const char *name,
-                          void *buffer, size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext4_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
-}
-
-static int
-ext4_xattr_set_acl(struct inode *inode, int type, const void *value,
-                  size_t size)
+ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
+                  size_t size, int flags, int type)
 {
+       struct inode *inode = dentry->d_inode;
        handle_t *handle;
        struct posix_acl *acl;
        int error, retries = 0;
 
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
        if (!test_opt(inode->i_sb, POSIX_ACL))
                return -EOPNOTSUPP;
        if (!is_owner_or_cap(inode))
@@ -466,34 +454,18 @@ release_and_out:
        return error;
 }
 
-static int
-ext4_xattr_set_acl_access(struct inode *inode, const char *name,
-                         const void *value, size_t size, int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext4_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
-}
-
-static int
-ext4_xattr_set_acl_default(struct inode *inode, const char *name,
-                          const void *value, size_t size, int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ext4_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
-}
-
 struct xattr_handler ext4_xattr_acl_access_handler = {
        .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags  = ACL_TYPE_ACCESS,
        .list   = ext4_xattr_list_acl_access,
-       .get    = ext4_xattr_get_acl_access,
-       .set    = ext4_xattr_set_acl_access,
+       .get    = ext4_xattr_get_acl,
+       .set    = ext4_xattr_set_acl,
 };
 
 struct xattr_handler ext4_xattr_acl_default_handler = {
        .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags  = ACL_TYPE_DEFAULT,
        .list   = ext4_xattr_list_acl_default,
-       .get    = ext4_xattr_get_acl_default,
-       .set    = ext4_xattr_set_acl_default,
+       .get    = ext4_xattr_get_acl,
+       .set    = ext4_xattr_set_acl,
 };
index 4df8621ec31cff1f5c8eef0211942750b92fd009..a60ab9aad57d4f5807adb72b702042056132e08a 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/module.h>
 #include <linux/swap.h>
 #include <linux/pagemap.h>
-#include <linux/version.h>
 #include <linux/blkdev.h>
 #include <linux/mutex.h>
 #include "ext4.h"
index ab31e65d46d017880644a540e23f05bca5398a92..56f9271ee8cce5bed485e539f6f7b4e7cdaeb8c4 100644 (file)
@@ -704,6 +704,10 @@ struct ext4_inode_info {
        __u16 i_extra_isize;
 
        spinlock_t i_block_reservation_lock;
+#ifdef CONFIG_QUOTA
+       /* quota space reservation, managed internally by quota code */
+       qsize_t i_reserved_quota;
+#endif
 
        /* completed async DIOs that might need unwritten extents handling */
        struct list_head i_aio_dio_complete_list;
@@ -1435,7 +1439,7 @@ extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
 extern int ext4_block_truncate_page(handle_t *handle,
                struct address_space *mapping, loff_t from);
 extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
-extern qsize_t ext4_get_reserved_space(struct inode *inode);
+extern qsize_t *ext4_get_reserved_space(struct inode *inode);
 extern int flush_aio_dio_completed_IO(struct inode *inode);
 /* ioctl.c */
 extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
index 3a7928f825e45f8fb244587cbe7c8921f6a3269b..91ae46098ea4a54727f5d5d114b2f2b3c878307f 100644 (file)
@@ -3023,6 +3023,14 @@ out:
        return err;
 }
 
+static void unmap_underlying_metadata_blocks(struct block_device *bdev,
+                       sector_t block, int count)
+{
+       int i;
+       for (i = 0; i < count; i++)
+                unmap_underlying_metadata(bdev, block + i);
+}
+
 static int
 ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
                        ext4_lblk_t iblock, unsigned int max_blocks,
@@ -3098,6 +3106,18 @@ out:
        } else
                allocated = ret;
        set_buffer_new(bh_result);
+       /*
+        * if we allocated more blocks than requested
+        * we need to make sure we unmap the extra block
+        * allocated. The actual needed block will get
+        * unmapped later when we find the buffer_head marked
+        * new.
+        */
+       if (allocated > max_blocks) {
+               unmap_underlying_metadata_blocks(inode->i_sb->s_bdev,
+                                       newblock + max_blocks,
+                                       allocated - max_blocks);
+       }
 map_out:
        set_buffer_mapped(bh_result);
 out1:
@@ -3190,7 +3210,13 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
         * this situation is possible, though, _during_ tree modification;
         * this is why assert can't be put in ext4_ext_find_extent()
         */
-       BUG_ON(path[depth].p_ext == NULL && depth != 0);
+       if (path[depth].p_ext == NULL && depth != 0) {
+               ext4_error(inode->i_sb, __func__, "bad extent address "
+                          "inode: %lu, iblock: %d, depth: %d",
+                          inode->i_ino, iblock, depth);
+               err = -EIO;
+               goto out2;
+       }
        eh = path[depth].p_hdr;
 
        ex = path[depth].p_ext;
index 0b22497d92e1b079e2eb10c22eb7a6ce6f546153..98bd140aad01148b07a85d2ca7ee59b97c1ac8c4 100644 (file)
@@ -88,9 +88,21 @@ int ext4_sync_file(struct file *file, struct dentry *dentry, int datasync)
                return ext4_force_commit(inode->i_sb);
 
        commit_tid = datasync ? ei->i_datasync_tid : ei->i_sync_tid;
-       if (jbd2_log_start_commit(journal, commit_tid))
+       if (jbd2_log_start_commit(journal, commit_tid)) {
+               /*
+                * When the journal is on a different device than the
+                * fs data disk, we need to issue the barrier in
+                * writeback mode.  (In ordered mode, the jbd2 layer
+                * will take care of issuing the barrier.  In
+                * data=journal, all of the data blocks are written to
+                * the journal device.)
+                */
+               if (ext4_should_writeback_data(inode) &&
+                   (journal->j_fs_dev != journal->j_dev) &&
+                   (journal->j_flags & JBD2_BARRIER))
+                       blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
                jbd2_log_wait_commit(journal, commit_tid);
-       else if (journal->j_flags & JBD2_BARRIER)
+       else if (journal->j_flags & JBD2_BARRIER)
                blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
        return ret;
 }
index 5352db1a3086a075f777652b1ac496a1f2c84aaa..84eeb8f515a388dc12387a735b5d97245b7ab3e4 100644 (file)
@@ -1003,17 +1003,12 @@ out:
        return err;
 }
 
-qsize_t ext4_get_reserved_space(struct inode *inode)
+#ifdef CONFIG_QUOTA
+qsize_t *ext4_get_reserved_space(struct inode *inode)
 {
-       unsigned long long total;
-
-       spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
-       total = EXT4_I(inode)->i_reserved_data_blocks +
-               EXT4_I(inode)->i_reserved_meta_blocks;
-       spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
-
-       return (total << inode->i_blkbits);
+       return &EXT4_I(inode)->i_reserved_quota;
 }
+#endif
 /*
  * Calculate the number of metadata blocks need to reserve
  * to allocate @blocks for non extent file based file
@@ -1048,38 +1043,47 @@ static int ext4_calc_metadata_amount(struct inode *inode, int blocks)
        return ext4_indirect_calc_metadata_amount(inode, blocks);
 }
 
+/*
+ * Called with i_data_sem down, which is important since we can call
+ * ext4_discard_preallocations() from here.
+ */
 static void ext4_da_update_reserve_space(struct inode *inode, int used)
 {
        struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-       int total, mdb, mdb_free;
-
-       spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
-       /* recalculate the number of metablocks still need to be reserved */
-       total = EXT4_I(inode)->i_reserved_data_blocks - used;
-       mdb = ext4_calc_metadata_amount(inode, total);
-
-       /* figure out how many metablocks to release */
-       BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks);
-       mdb_free = EXT4_I(inode)->i_reserved_meta_blocks - mdb;
-
-       if (mdb_free) {
-               /* Account for allocated meta_blocks */
-               mdb_free -= EXT4_I(inode)->i_allocated_meta_blocks;
-
-               /* update fs dirty blocks counter */
+       struct ext4_inode_info *ei = EXT4_I(inode);
+       int mdb_free = 0;
+
+       spin_lock(&ei->i_block_reservation_lock);
+       if (unlikely(used > ei->i_reserved_data_blocks)) {
+               ext4_msg(inode->i_sb, KERN_NOTICE, "%s: ino %lu, used %d "
+                        "with only %d reserved data blocks\n",
+                        __func__, inode->i_ino, used,
+                        ei->i_reserved_data_blocks);
+               WARN_ON(1);
+               used = ei->i_reserved_data_blocks;
+       }
+
+       /* Update per-inode reservations */
+       ei->i_reserved_data_blocks -= used;
+       used += ei->i_allocated_meta_blocks;
+       ei->i_reserved_meta_blocks -= ei->i_allocated_meta_blocks;
+       ei->i_allocated_meta_blocks = 0;
+       percpu_counter_sub(&sbi->s_dirtyblocks_counter, used);
+
+       if (ei->i_reserved_data_blocks == 0) {
+               /*
+                * We can release all of the reserved metadata blocks
+                * only when we have written all of the delayed
+                * allocation blocks.
+                */
+               mdb_free = ei->i_allocated_meta_blocks;
                percpu_counter_sub(&sbi->s_dirtyblocks_counter, mdb_free);
-               EXT4_I(inode)->i_allocated_meta_blocks = 0;
-               EXT4_I(inode)->i_reserved_meta_blocks = mdb;
+               ei->i_allocated_meta_blocks = 0;
        }
-
-       /* update per-inode reservations */
-       BUG_ON(used  > EXT4_I(inode)->i_reserved_data_blocks);
-       EXT4_I(inode)->i_reserved_data_blocks -= used;
        spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
 
-       /*
-        * free those over-booking quota for metadata blocks
-        */
+       /* Update quota subsystem */
+       vfs_dq_claim_block(inode, used);
        if (mdb_free)
                vfs_dq_release_reservation_block(inode, mdb_free);
 
@@ -1088,7 +1092,8 @@ static void ext4_da_update_reserve_space(struct inode *inode, int used)
         * there aren't any writers on the inode, we can discard the
         * inode's preallocations.
         */
-       if (!total && (atomic_read(&inode->i_writecount) == 0))
+       if ((ei->i_reserved_data_blocks == 0) &&
+           (atomic_read(&inode->i_writecount) == 0))
                ext4_discard_preallocations(inode);
 }
 
@@ -1801,7 +1806,8 @@ static int ext4_da_reserve_space(struct inode *inode, int nrblocks)
 {
        int retries = 0;
        struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-       unsigned long md_needed, mdblocks, total = 0;
+       struct ext4_inode_info *ei = EXT4_I(inode);
+       unsigned long md_needed, md_reserved, total = 0;
 
        /*
         * recalculate the amount of metadata blocks to reserve
@@ -1809,13 +1815,11 @@ static int ext4_da_reserve_space(struct inode *inode, int nrblocks)
         * worse case is one extent per block
         */
 repeat:
-       spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
-       total = EXT4_I(inode)->i_reserved_data_blocks + nrblocks;
-       mdblocks = ext4_calc_metadata_amount(inode, total);
-       BUG_ON(mdblocks < EXT4_I(inode)->i_reserved_meta_blocks);
-
-       md_needed = mdblocks - EXT4_I(inode)->i_reserved_meta_blocks;
+       spin_lock(&ei->i_block_reservation_lock);
+       md_reserved = ei->i_reserved_meta_blocks;
+       md_needed = ext4_calc_metadata_amount(inode, nrblocks);
        total = md_needed + nrblocks;
+       spin_unlock(&ei->i_block_reservation_lock);
 
        /*
         * Make quota reservation here to prevent quota overflow
@@ -1823,72 +1827,78 @@ repeat:
         * time.
         */
        if (vfs_dq_reserve_block(inode, total)) {
-               spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+               /* 
+                * We tend to badly over-estimate the amount of
+                * metadata blocks which are needed, so if we have
+                * reserved any metadata blocks, try to force out the
+                * inode and see if we have any better luck.
+                */
+               if (md_reserved && retries++ <= 3)
+                       goto retry;
                return -EDQUOT;
        }
 
        if (ext4_claim_free_blocks(sbi, total)) {
-               spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
                vfs_dq_release_reservation_block(inode, total);
                if (ext4_should_retry_alloc(inode->i_sb, &retries)) {
+               retry:
+                       if (md_reserved)
+                               write_inode_now(inode, (retries == 3));
                        yield();
                        goto repeat;
                }
                return -ENOSPC;
        }
-       EXT4_I(inode)->i_reserved_data_blocks += nrblocks;
-       EXT4_I(inode)->i_reserved_meta_blocks = mdblocks;
+       spin_lock(&ei->i_block_reservation_lock);
+       ei->i_reserved_data_blocks += nrblocks;
+       ei->i_reserved_meta_blocks += md_needed;
+       spin_unlock(&ei->i_block_reservation_lock);
 
-       spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
        return 0;       /* success */
 }
 
 static void ext4_da_release_space(struct inode *inode, int to_free)
 {
        struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-       int total, mdb, mdb_free, release;
+       struct ext4_inode_info *ei = EXT4_I(inode);
 
        if (!to_free)
                return;         /* Nothing to release, exit */
 
        spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
 
-       if (!EXT4_I(inode)->i_reserved_data_blocks) {
+       if (unlikely(to_free > ei->i_reserved_data_blocks)) {
                /*
-                * if there is no reserved blocks, but we try to free some
-                * then the counter is messed up somewhere.
-                * but since this function is called from invalidate
-                * page, it's harmless to return without any action
+                * if there aren't enough reserved blocks, then the
+                * counter is messed up somewhere.  Since this
+                * function is called from invalidate page, it's
+                * harmless to return without any action.
                 */
-               printk(KERN_INFO "ext4 delalloc try to release %d reserved "
-                           "blocks for inode %lu, but there is no reserved "
-                           "data blocks\n", to_free, inode->i_ino);
-               spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
-               return;
+               ext4_msg(inode->i_sb, KERN_NOTICE, "ext4_da_release_space: "
+                        "ino %lu, to_free %d with only %d reserved "
+                        "data blocks\n", inode->i_ino, to_free,
+                        ei->i_reserved_data_blocks);
+               WARN_ON(1);
+               to_free = ei->i_reserved_data_blocks;
        }
+       ei->i_reserved_data_blocks -= to_free;
 
-       /* recalculate the number of metablocks still need to be reserved */
-       total = EXT4_I(inode)->i_reserved_data_blocks - to_free;
-       mdb = ext4_calc_metadata_amount(inode, total);
-
-       /* figure out how many metablocks to release */
-       BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks);
-       mdb_free = EXT4_I(inode)->i_reserved_meta_blocks - mdb;
-
-       release = to_free + mdb_free;
-
-       /* update fs dirty blocks counter for truncate case */
-       percpu_counter_sub(&sbi->s_dirtyblocks_counter, release);
+       if (ei->i_reserved_data_blocks == 0) {
+               /*
+                * We can release all of the reserved metadata blocks
+                * only when we have written all of the delayed
+                * allocation blocks.
+                */
+               to_free += ei->i_allocated_meta_blocks;
+               ei->i_allocated_meta_blocks = 0;
+       }
 
-       /* update per-inode reservations */
-       BUG_ON(to_free > EXT4_I(inode)->i_reserved_data_blocks);
-       EXT4_I(inode)->i_reserved_data_blocks -= to_free;
+       /* update fs dirty blocks counter */
+       percpu_counter_sub(&sbi->s_dirtyblocks_counter, to_free);
 
-       BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks);
-       EXT4_I(inode)->i_reserved_meta_blocks = mdb;
        spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
 
-       vfs_dq_release_reservation_block(inode, release);
+       vfs_dq_release_reservation_block(inode, to_free);
 }
 
 static void ext4_da_page_release_reservation(struct page *page,
@@ -2968,8 +2978,7 @@ retry:
 out_writepages:
        if (!no_nrwrite_index_update)
                wbc->no_nrwrite_index_update = 0;
-       if (wbc->nr_to_write > nr_to_writebump)
-               wbc->nr_to_write -= nr_to_writebump;
+       wbc->nr_to_write -= nr_to_writebump;
        wbc->range_start = range_start;
        trace_ext4_da_writepages_result(inode, wbc, ret, pages_written);
        return ret;
@@ -2994,11 +3003,18 @@ static int ext4_nonda_switch(struct super_block *sb)
        if (2 * free_blocks < 3 * dirty_blocks ||
                free_blocks < (dirty_blocks + EXT4_FREEBLOCKS_WATERMARK)) {
                /*
-                * free block count is less that 150% of dirty blocks
-                * or free blocks is less that watermark
+                * free block count is less than 150% of dirty blocks
+                * or free blocks is less than watermark
                 */
                return 1;
        }
+       /*
+        * Even if we don't switch but are nearing capacity,
+        * start pushing delalloc when 1/2 of free blocks are dirty.
+        */
+       if (free_blocks < 2 * dirty_blocks)
+               writeback_inodes_sb_if_idle(sb);
+
        return 0;
 }
 
@@ -4794,6 +4810,9 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
                        ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
        inode->i_size = ext4_isize(raw_inode);
        ei->i_disksize = inode->i_size;
+#ifdef CONFIG_QUOTA
+       ei->i_reserved_quota = 0;
+#endif
        inode->i_generation = le32_to_cpu(raw_inode->i_generation);
        ei->i_block_group = iloc.block_group;
        ei->i_last_alloc_group = ~0;
index b1fd3daadc9c50522894fd00ec62bb8e600f9fd0..d34afad3e1371b89c3bfb600c51d55e714f00419 100644 (file)
@@ -2755,12 +2755,6 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
        if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED))
                /* release all the reserved blocks if non delalloc */
                percpu_counter_sub(&sbi->s_dirtyblocks_counter, reserv_blks);
-       else {
-               percpu_counter_sub(&sbi->s_dirtyblocks_counter,
-                                               ac->ac_b_ex.fe_len);
-               /* convert reserved quota blocks to real quota blocks */
-               vfs_dq_claim_block(ac->ac_inode, ac->ac_b_ex.fe_len);
-       }
 
        if (sbi->s_log_groups_per_flex) {
                ext4_group_t flex_group = ext4_flex_group(sbi,
index 0ca811061bc72eca18b46ca025b660f32ce87138..436521cae45662629d02871d5ff8429aee92065b 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/proc_fs.h>
 #include <linux/pagemap.h>
 #include <linux/seq_file.h>
-#include <linux/version.h>
 #include <linux/blkdev.h>
 #include <linux/mutex.h>
 #include "ext4_jbd2.h"
index 768c111a77ec16a84427544c9aa2ce0faf81d8b0..7cccb35c0f4d349ffacf28aefd0f67ff401f6f49 100644 (file)
@@ -704,6 +704,9 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
        ei->i_allocated_meta_blocks = 0;
        ei->i_delalloc_reserved_flag = 0;
        spin_lock_init(&(ei->i_block_reservation_lock));
+#ifdef CONFIG_QUOTA
+       ei->i_reserved_quota = 0;
+#endif
        INIT_LIST_HEAD(&ei->i_aio_dio_complete_list);
        ei->cur_aio_dio = NULL;
        ei->i_sync_tid = 0;
@@ -1014,7 +1017,9 @@ static const struct dquot_operations ext4_quota_operations = {
        .reserve_space  = dquot_reserve_space,
        .claim_space    = dquot_claim_space,
        .release_rsv    = dquot_release_reserved_space,
+#ifdef CONFIG_QUOTA
        .get_reserved_space = ext4_get_reserved_space,
+#endif
        .alloc_inode    = dquot_alloc_inode,
        .free_space     = dquot_free_space,
        .free_inode     = dquot_free_inode,
@@ -2137,11 +2142,8 @@ static int parse_strtoul(const char *buf,
 {
        char *endp;
 
-       while (*buf && isspace(*buf))
-               buf++;
-       *value = simple_strtoul(buf, &endp, 0);
-       while (*endp && isspace(*endp))
-               endp++;
+       *value = simple_strtoul(skip_spaces(buf), &endp, 0);
+       endp = skip_spaces(endp);
        if (*endp || *value > max)
                return -EINVAL;
 
@@ -2172,9 +2174,9 @@ static ssize_t lifetime_write_kbytes_show(struct ext4_attr *a,
        struct super_block *sb = sbi->s_buddy_cache->i_sb;
 
        return snprintf(buf, PAGE_SIZE, "%llu\n",
-                       sbi->s_kbytes_written + 
+                       (unsigned long long)(sbi->s_kbytes_written +
                        ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
-                         EXT4_SB(sb)->s_sectors_written_start) >> 1));
+                         EXT4_SB(sb)->s_sectors_written_start) >> 1)));
 }
 
 static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
@@ -4003,6 +4005,7 @@ static inline void unregister_as_ext2(void)
 {
        unregister_filesystem(&ext2_fs_type);
 }
+MODULE_ALIAS("ext2");
 #else
 static inline void register_as_ext2(void) { }
 static inline void unregister_as_ext2(void) { }
@@ -4029,6 +4032,7 @@ static inline void unregister_as_ext3(void)
 {
        unregister_filesystem(&ext3_fs_type);
 }
+MODULE_ALIAS("ext3");
 #else
 static inline void register_as_ext3(void) { }
 static inline void unregister_as_ext3(void) { }
index 910bf9a59cb39c6018d7c7f4d31c0bc00ef26749..f3a2f7ed45aabc13e3ea4a28fc9baa098131cbb4 100644 (file)
@@ -92,7 +92,7 @@ static struct buffer_head *ext4_xattr_cache_find(struct inode *,
                                                 struct mb_cache_entry **);
 static void ext4_xattr_rehash(struct ext4_xattr_header *,
                              struct ext4_xattr_entry *);
-static int ext4_xattr_list(struct inode *inode, char *buffer,
+static int ext4_xattr_list(struct dentry *dentry, char *buffer,
                           size_t buffer_size);
 
 static struct mb_cache *ext4_xattr_cache;
@@ -140,7 +140,7 @@ ext4_xattr_handler(int name_index)
 ssize_t
 ext4_listxattr(struct dentry *dentry, char *buffer, size_t size)
 {
-       return ext4_xattr_list(dentry->d_inode, buffer, size);
+       return ext4_xattr_list(dentry, buffer, size);
 }
 
 static int
@@ -325,7 +325,7 @@ ext4_xattr_get(struct inode *inode, int name_index, const char *name,
 }
 
 static int
-ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry,
+ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
                        char *buffer, size_t buffer_size)
 {
        size_t rest = buffer_size;
@@ -335,9 +335,10 @@ ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry,
                        ext4_xattr_handler(entry->e_name_index);
 
                if (handler) {
-                       size_t size = handler->list(inode, buffer, rest,
+                       size_t size = handler->list(dentry, buffer, rest,
                                                    entry->e_name,
-                                                   entry->e_name_len);
+                                                   entry->e_name_len,
+                                                   handler->flags);
                        if (buffer) {
                                if (size > rest)
                                        return -ERANGE;
@@ -350,8 +351,9 @@ ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry,
 }
 
 static int
-ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
+ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
+       struct inode *inode = dentry->d_inode;
        struct buffer_head *bh = NULL;
        int error;
 
@@ -376,7 +378,7 @@ ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
                goto cleanup;
        }
        ext4_xattr_cache_insert(bh);
-       error = ext4_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size);
+       error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size);
 
 cleanup:
        brelse(bh);
@@ -385,8 +387,9 @@ cleanup:
 }
 
 static int
-ext4_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size)
+ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
+       struct inode *inode = dentry->d_inode;
        struct ext4_xattr_ibody_header *header;
        struct ext4_inode *raw_inode;
        struct ext4_iloc iloc;
@@ -404,7 +407,7 @@ ext4_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size)
        error = ext4_xattr_check_names(IFIRST(header), end);
        if (error)
                goto cleanup;
-       error = ext4_xattr_list_entries(inode, IFIRST(header),
+       error = ext4_xattr_list_entries(dentry, IFIRST(header),
                                        buffer, buffer_size);
 
 cleanup:
@@ -423,12 +426,12 @@ cleanup:
  * used / required on success.
  */
 static int
-ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
+ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
        int i_error, b_error;
 
-       down_read(&EXT4_I(inode)->xattr_sem);
-       i_error = ext4_xattr_ibody_list(inode, buffer, buffer_size);
+       down_read(&EXT4_I(dentry->d_inode)->xattr_sem);
+       i_error = ext4_xattr_ibody_list(dentry, buffer, buffer_size);
        if (i_error < 0) {
                b_error = 0;
        } else {
@@ -436,11 +439,11 @@ ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
                        buffer += i_error;
                        buffer_size -= i_error;
                }
-               b_error = ext4_xattr_block_list(inode, buffer, buffer_size);
+               b_error = ext4_xattr_block_list(dentry, buffer, buffer_size);
                if (b_error < 0)
                        i_error = 0;
        }
-       up_read(&EXT4_I(inode)->xattr_sem);
+       up_read(&EXT4_I(dentry->d_inode)->xattr_sem);
        return i_error + b_error;
 }
 
@@ -1329,6 +1332,8 @@ retry:
                        goto cleanup;
                kfree(b_entry_name);
                kfree(buffer);
+               b_entry_name = NULL;
+               buffer = NULL;
                brelse(is->iloc.bh);
                kfree(is);
                kfree(bs);
index ca5f89fc6caeba31ee41a15a3843452a1c0f56c6..983c253999a7f32965a384ae116aa856f25011ed 100644 (file)
@@ -12,8 +12,8 @@
 #include "xattr.h"
 
 static size_t
-ext4_xattr_security_list(struct inode *inode, char *list, size_t list_size,
-                        const char *name, size_t name_len)
+ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
+               const char *name, size_t name_len, int type)
 {
        const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1;
        const size_t total_len = prefix_len + name_len + 1;
@@ -28,23 +28,23 @@ ext4_xattr_security_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext4_xattr_security_get(struct inode *inode, const char *name,
-                      void *buffer, size_t size)
+ext4_xattr_security_get(struct dentry *dentry, const char *name,
+                      void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext4_xattr_get(inode, EXT4_XATTR_INDEX_SECURITY, name,
-                             buffer, size);
+       return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_SECURITY,
+                             name, buffer, size);
 }
 
 static int
-ext4_xattr_security_set(struct inode *inode, const char *name,
-                      const void *value, size_t size, int flags)
+ext4_xattr_security_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext4_xattr_set(inode, EXT4_XATTR_INDEX_SECURITY, name,
-                             value, size, flags);
+       return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_SECURITY,
+                             name, value, size, flags);
 }
 
 int
index ac1a52cf2a37dedde562cf4d35984ea49746683e..15b50edc6587ddccf1751ab25ce162812f8bb507 100644 (file)
@@ -14,8 +14,8 @@
 #include "xattr.h"
 
 static size_t
-ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
-                       const char *name, size_t name_len)
+ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
+               const char *name, size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
@@ -32,23 +32,23 @@ ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext4_xattr_trusted_get(struct inode *inode, const char *name,
-                      void *buffer, size_t size)
+ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer,
+               size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED, name,
-                             buffer, size);
+       return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_TRUSTED,
+                             name, buffer, size);
 }
 
 static int
-ext4_xattr_trusted_set(struct inode *inode, const char *name,
-                      const void *value, size_t size, int flags)
+ext4_xattr_trusted_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED, name,
-                             value, size, flags);
+       return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_TRUSTED,
+                             name, value, size, flags);
 }
 
 struct xattr_handler ext4_xattr_trusted_handler = {
index d91aa61b42aae34545a1fab88b9f54e5f405a0a6..c4ce05746ce122b897a19a3cc5b1dbf70ff0261a 100644 (file)
 #include "xattr.h"
 
 static size_t
-ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size,
-                    const char *name, size_t name_len)
+ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size,
+                    const char *name, size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_USER_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
 
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return 0;
 
        if (list && total_len <= list_size) {
@@ -31,26 +31,27 @@ ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size,
 }
 
 static int
-ext4_xattr_user_get(struct inode *inode, const char *name,
-                   void *buffer, size_t size)
+ext4_xattr_user_get(struct dentry *dentry, const char *name,
+                   void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return -EOPNOTSUPP;
-       return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, name, buffer, size);
+       return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_USER,
+                             name, buffer, size);
 }
 
 static int
-ext4_xattr_user_set(struct inode *inode, const char *name,
-                   const void *value, size_t size, int flags)
+ext4_xattr_user_set(struct dentry *dentry, const char *name,
+                   const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       if (!test_opt(inode->i_sb, XATTR_USER))
+       if (!test_opt(dentry->d_sb, XATTR_USER))
                return -EOPNOTSUPP;
-       return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER, name,
-                             value, size, flags);
+       return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_USER,
+                             name, value, size, flags);
 }
 
 struct xattr_handler ext4_xattr_user_handler = {
index 7db0979c6b72f0d16e19c77d6e73af5642992f83..e6efdfa0f6db5d1dbff9fe9e1c24b65af52e0596 100644 (file)
@@ -44,7 +44,8 @@ struct fat_mount_options {
                 nocase:1,        /* Does this need case conversion? 0=need case conversion*/
                 usefree:1,       /* Use free_clusters for FAT32 */
                 tz_utc:1,        /* Filesystem timestamps are in UTC */
-                rodir:1;         /* allow ATTR_RO for directory */
+                rodir:1,         /* allow ATTR_RO for directory */
+                discard:1;       /* Issue discard requests on deletions */
 };
 
 #define FAT_HASH_BITS  8
index a81037721a6f12cb7e11d85f188c408ae2907699..81184d3b75a3a50e5917c64f0bc4a5faac64cebd 100644 (file)
@@ -566,16 +566,21 @@ int fat_free_clusters(struct inode *inode, int cluster)
                        goto error;
                }
 
-               /* 
-                * Issue discard for the sectors we no longer care about,
-                * batching contiguous clusters into one request
-                */
-               if (cluster != fatent.entry + 1) {
-                       int nr_clus = fatent.entry - first_cl + 1;
-
-                       sb_issue_discard(sb, fat_clus_to_blknr(sbi, first_cl),
-                                        nr_clus * sbi->sec_per_clus);
-                       first_cl = cluster;
+               if (sbi->options.discard) {
+                       /*
+                        * Issue discard for the sectors we no longer
+                        * care about, batching contiguous clusters
+                        * into one request
+                        */
+                       if (cluster != fatent.entry + 1) {
+                               int nr_clus = fatent.entry - first_cl + 1;
+
+                               sb_issue_discard(sb,
+                                       fat_clus_to_blknr(sbi, first_cl),
+                                       nr_clus * sbi->sec_per_clus);
+
+                               first_cl = cluster;
+                       }
                }
 
                ops->ent_put(&fatent, FAT_ENT_FREE);
index 76b7961ab6632e5d955a9139eaa4b0652e11ff8c..14da530b05cae63e189e3303dddc0caa2018638c 100644 (file)
@@ -858,6 +858,8 @@ static int fat_show_options(struct seq_file *m, struct vfsmount *mnt)
                seq_puts(m, ",errors=panic");
        else
                seq_puts(m, ",errors=remount-ro");
+       if (opts->discard)
+               seq_puts(m, ",discard");
 
        return 0;
 }
@@ -871,7 +873,7 @@ enum {
        Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes,
        Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes,
        Opt_obsolate, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont,
-       Opt_err_panic, Opt_err_ro, Opt_err,
+       Opt_err_panic, Opt_err_ro, Opt_discard, Opt_err,
 };
 
 static const match_table_t fat_tokens = {
@@ -899,6 +901,7 @@ static const match_table_t fat_tokens = {
        {Opt_err_cont, "errors=continue"},
        {Opt_err_panic, "errors=panic"},
        {Opt_err_ro, "errors=remount-ro"},
+       {Opt_discard, "discard"},
        {Opt_obsolate, "conv=binary"},
        {Opt_obsolate, "conv=text"},
        {Opt_obsolate, "conv=auto"},
@@ -1136,6 +1139,9 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug,
                case Opt_rodir:
                        opts->rodir = 1;
                        break;
+               case Opt_discard:
+                       opts->discard = 1;
+                       break;
 
                /* obsolete mount options */
                case Opt_obsolate:
index 0f55f5cb732f24078af99a605e4fa764eabad6bf..d3da05f2646587a09e52bc4243d3ac7fd82588fa 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
+#include <linux/time.h>
 #include "fat.h"
 
 /*
@@ -157,10 +158,6 @@ extern struct timezone sys_tz;
 #define SECS_PER_MIN   60
 #define SECS_PER_HOUR  (60 * 60)
 #define SECS_PER_DAY   (SECS_PER_HOUR * 24)
-#define UNIX_SECS_1980 315532800L
-#if BITS_PER_LONG == 64
-#define UNIX_SECS_2108 4354819200L
-#endif
 /* days between 1.1.70 and 1.1.80 (2 leap days) */
 #define DAYS_DELTA     (365 * 10 + 2)
 /* 120 (2100 - 1980) isn't leap year */
@@ -213,58 +210,35 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts,
 void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts,
                       __le16 *time, __le16 *date, u8 *time_cs)
 {
-       time_t second = ts->tv_sec;
-       time_t day, leap_day, month, year;
+       struct tm tm;
+       time_to_tm(ts->tv_sec, sbi->options.tz_utc ? 0 :
+                  -sys_tz.tz_minuteswest * 60, &tm);
 
-       if (!sbi->options.tz_utc)
-               second -= sys_tz.tz_minuteswest * SECS_PER_MIN;
-
-       /* Jan 1 GMT 00:00:00 1980. But what about another time zone? */
-       if (second < UNIX_SECS_1980) {
+       /*  FAT can only support year between 1980 to 2107 */
+       if (tm.tm_year < 1980 - 1900) {
                *time = 0;
                *date = cpu_to_le16((0 << 9) | (1 << 5) | 1);
                if (time_cs)
                        *time_cs = 0;
                return;
        }
-#if BITS_PER_LONG == 64
-       if (second >= UNIX_SECS_2108) {
+       if (tm.tm_year > 2107 - 1900) {
                *time = cpu_to_le16((23 << 11) | (59 << 5) | 29);
                *date = cpu_to_le16((127 << 9) | (12 << 5) | 31);
                if (time_cs)
                        *time_cs = 199;
                return;
        }
-#endif
 
-       day = second / SECS_PER_DAY - DAYS_DELTA;
-       year = day / 365;
-       leap_day = (year + 3) / 4;
-       if (year > YEAR_2100)           /* 2100 isn't leap year */
-               leap_day--;
-       if (year * 365 + leap_day > day)
-               year--;
-       leap_day = (year + 3) / 4;
-       if (year > YEAR_2100)           /* 2100 isn't leap year */
-               leap_day--;
-       day -= year * 365 + leap_day;
-
-       if (IS_LEAP_YEAR(year) && day == days_in_year[3]) {
-               month = 2;
-       } else {
-               if (IS_LEAP_YEAR(year) && day > days_in_year[3])
-                       day--;
-               for (month = 1; month < 12; month++) {
-                       if (days_in_year[month + 1] > day)
-                               break;
-               }
-       }
-       day -= days_in_year[month];
+       /* from 1900 -> from 1980 */
+       tm.tm_year -= 80;
+       /* 0~11 -> 1~12 */
+       tm.tm_mon++;
+       /* 0~59 -> 0~29(2sec counts) */
+       tm.tm_sec >>= 1;
 
-       *time = cpu_to_le16(((second / SECS_PER_HOUR) % 24) << 11
-                           | ((second / SECS_PER_MIN) % 60) << 5
-                           | (second % SECS_PER_MIN) >> 1);
-       *date = cpu_to_le16((year << 9) | (month << 5) | (day + 1));
+       *time = cpu_to_le16(tm.tm_hour << 11 | tm.tm_min << 5 | tm.tm_sec);
+       *date = cpu_to_le16(tm.tm_year << 9 | tm.tm_mon << 5 | tm.tm_mday);
        if (time_cs)
                *time_cs = (ts->tv_sec & 1) * 100 + ts->tv_nsec / 10000000;
 }
@@ -285,4 +259,3 @@ int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs)
        }
        return err;
 }
-
index 4bef4c01ec6ff4b0ef7ce00816f3c124517031c0..69652c5bd5f0ad83b983324d4dc2d31b7a1cd689 100644 (file)
 #include <linux/fsnotify.h>
 #include <linux/sysctl.h>
 #include <linux/percpu_counter.h>
+#include <linux/ima.h>
 
 #include <asm/atomic.h>
 
+#include "internal.h"
+
 /* sysctl tunables... */
 struct files_stat_struct files_stat = {
        .max_files = NR_FILE
@@ -147,8 +150,6 @@ fail:
        return NULL;
 }
 
-EXPORT_SYMBOL(get_empty_filp);
-
 /**
  * alloc_file - allocate and initialize a 'struct file'
  * @mnt: the vfsmount on which the file will reside
@@ -164,8 +165,8 @@ EXPORT_SYMBOL(get_empty_filp);
  * If all the callers of init_file() are eliminated, its
  * code should be moved into this function.
  */
-struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry,
-               fmode_t mode, const struct file_operations *fop)
+struct file *alloc_file(struct path *path, fmode_t mode,
+               const struct file_operations *fop)
 {
        struct file *file;
 
@@ -173,35 +174,8 @@ struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry,
        if (!file)
                return NULL;
 
-       init_file(file, mnt, dentry, mode, fop);
-       return file;
-}
-EXPORT_SYMBOL(alloc_file);
-
-/**
- * init_file - initialize a 'struct file'
- * @file: the already allocated 'struct file' to initialized
- * @mnt: the vfsmount on which the file resides
- * @dentry: the dentry representing this file
- * @mode: the mode the file is opened with
- * @fop: the 'struct file_operations' for this file
- *
- * Use this instead of setting the members directly.  Doing so
- * avoids making mistakes like forgetting the mntget() or
- * forgetting to take a write on the mnt.
- *
- * Note: This is a crappy interface.  It is here to make
- * merging with the existing users of get_empty_filp()
- * who have complex failure logic easier.  All users
- * of this should be moving to alloc_file().
- */
-int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry,
-          fmode_t mode, const struct file_operations *fop)
-{
-       int error = 0;
-       file->f_path.dentry = dentry;
-       file->f_path.mnt = mntget(mnt);
-       file->f_mapping = dentry->d_inode->i_mapping;
+       file->f_path = *path;
+       file->f_mapping = path->dentry->d_inode->i_mapping;
        file->f_mode = mode;
        file->f_op = fop;
 
@@ -211,14 +185,14 @@ int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry,
         * visible.  We do this for consistency, and so
         * that we can do debugging checks at __fput()
         */
-       if ((mode & FMODE_WRITE) && !special_file(dentry->d_inode->i_mode)) {
+       if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) {
                file_take_write(file);
-               error = mnt_clone_write(mnt);
-               WARN_ON(error);
+               WARN_ON(mnt_clone_write(path->mnt));
        }
-       return error;
+       ima_counts_get(file);
+       return file;
 }
-EXPORT_SYMBOL(init_file);
+EXPORT_SYMBOL(alloc_file);
 
 void fput(struct file *file)
 {
index 49bc1b8e8f1945f1a282f162cd00037a5cefcbb9..f6c2155e00267724c94513af7972b2322bad9741 100644 (file)
@@ -1186,6 +1186,23 @@ void writeback_inodes_sb(struct super_block *sb)
 }
 EXPORT_SYMBOL(writeback_inodes_sb);
 
+/**
+ * writeback_inodes_sb_if_idle -       start writeback if none underway
+ * @sb: the superblock
+ *
+ * Invoke writeback_inodes_sb if no writeback is currently underway.
+ * Returns 1 if writeback was started, 0 if not.
+ */
+int writeback_inodes_sb_if_idle(struct super_block *sb)
+{
+       if (!writeback_in_progress(sb->s_bdi)) {
+               writeback_inodes_sb(sb);
+               return 1;
+       } else
+               return 0;
+}
+EXPORT_SYMBOL(writeback_inodes_sb_if_idle);
+
 /**
  * sync_inodes_sb      -       sync sb inode pages
  * @sb: the superblock
index e590242fa41a2ac26497dd260ed79401efb40ec6..3221a0c7944e32fbe02c5d8c6c759b5766d6ce69 100644 (file)
@@ -91,7 +91,7 @@ EXPORT_SYMBOL(fscache_object_destroy);
  */
 static struct fscache_object *fscache_objlist_lookup(loff_t *_pos)
 {
-       struct fscache_object *pobj, *obj, *minobj = NULL;
+       struct fscache_object *pobj, *obj = NULL, *minobj = NULL;
        struct rb_node *p;
        unsigned long pos;
 
index e0b53aa7bbec11037ba8f9c2bd35f33392249ecd..55458031e501405b06371b04f958323d44e12549 100644 (file)
@@ -1,62 +1,58 @@
 /*
- * fs/generic_acl.c
- *
  * (C) 2005 Andreas Gruenbacher <agruen@suse.de>
  *
  * This file is released under the GPL.
+ *
+ * Generic ACL support for in-memory filesystems.
  */
 
 #include <linux/sched.h>
 #include <linux/fs.h>
 #include <linux/generic_acl.h>
+#include <linux/posix_acl.h>
+#include <linux/posix_acl_xattr.h>
 
-/**
- * generic_acl_list  -  Generic xattr_handler->list() operation
- * @ops:       Filesystem specific getacl and setacl callbacks
- */
-size_t
-generic_acl_list(struct inode *inode, struct generic_acl_operations *ops,
-                int type, char *list, size_t list_size)
+
+static size_t
+generic_acl_list(struct dentry *dentry, char *list, size_t list_size,
+               const char *name, size_t name_len, int type)
 {
        struct posix_acl *acl;
-       const char *name;
+       const char *xname;
        size_t size;
 
-       acl = ops->getacl(inode, type);
+       acl = get_cached_acl(dentry->d_inode, type);
        if (!acl)
                return 0;
        posix_acl_release(acl);
 
-       switch(type) {
-               case ACL_TYPE_ACCESS:
-                       name = POSIX_ACL_XATTR_ACCESS;
-                       break;
-
-               case ACL_TYPE_DEFAULT:
-                       name = POSIX_ACL_XATTR_DEFAULT;
-                       break;
-
-               default:
-                       return 0;
+       switch (type) {
+       case ACL_TYPE_ACCESS:
+               xname = POSIX_ACL_XATTR_ACCESS;
+               break;
+       case ACL_TYPE_DEFAULT:
+               xname = POSIX_ACL_XATTR_DEFAULT;
+               break;
+       default:
+               return 0;
        }
-       size = strlen(name) + 1;
+       size = strlen(xname) + 1;
        if (list && size <= list_size)
-               memcpy(list, name, size);
+               memcpy(list, xname, size);
        return size;
 }
 
-/**
- * generic_acl_get  -  Generic xattr_handler->get() operation
- * @ops:       Filesystem specific getacl and setacl callbacks
- */
-int
-generic_acl_get(struct inode *inode, struct generic_acl_operations *ops,
-               int type, void *buffer, size_t size)
+static int
+generic_acl_get(struct dentry *dentry, const char *name, void *buffer,
+                    size_t size, int type)
 {
        struct posix_acl *acl;
        int error;
 
-       acl = ops->getacl(inode, type);
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
+
+       acl = get_cached_acl(dentry->d_inode, type);
        if (!acl)
                return -ENODATA;
        error = posix_acl_to_xattr(acl, buffer, size);
@@ -65,17 +61,16 @@ generic_acl_get(struct inode *inode, struct generic_acl_operations *ops,
        return error;
 }
 
-/**
- * generic_acl_set  -  Generic xattr_handler->set() operation
- * @ops:       Filesystem specific getacl and setacl callbacks
- */
-int
-generic_acl_set(struct inode *inode, struct generic_acl_operations *ops,
-               int type, const void *value, size_t size)
+static int
+generic_acl_set(struct dentry *dentry, const char *name, const void *value,
+                    size_t size, int flags, int type)
 {
+       struct inode *inode = dentry->d_inode;
        struct posix_acl *acl = NULL;
        int error;
 
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
        if (!is_owner_or_cap(inode))
@@ -91,28 +86,27 @@ generic_acl_set(struct inode *inode, struct generic_acl_operations *ops,
                error = posix_acl_valid(acl);
                if (error)
                        goto failed;
-               switch(type) {
-                       case ACL_TYPE_ACCESS:
-                               mode = inode->i_mode;
-                               error = posix_acl_equiv_mode(acl, &mode);
-                               if (error < 0)
-                                       goto failed;
-                               inode->i_mode = mode;
-                               if (error == 0) {
-                                       posix_acl_release(acl);
-                                       acl = NULL;
-                               }
-                               break;
-
-                       case ACL_TYPE_DEFAULT:
-                               if (!S_ISDIR(inode->i_mode)) {
-                                       error = -EINVAL;
-                                       goto failed;
-                               }
-                               break;
+               switch (type) {
+               case ACL_TYPE_ACCESS:
+                       mode = inode->i_mode;
+                       error = posix_acl_equiv_mode(acl, &mode);
+                       if (error < 0)
+                               goto failed;
+                       inode->i_mode = mode;
+                       if (error == 0) {
+                               posix_acl_release(acl);
+                               acl = NULL;
+                       }
+                       break;
+               case ACL_TYPE_DEFAULT:
+                       if (!S_ISDIR(inode->i_mode)) {
+                               error = -EINVAL;
+                               goto failed;
+                       }
+                       break;
                }
        }
-       ops->setacl(inode, type, acl);
+       set_cached_acl(inode, type, acl);
        error = 0;
 failed:
        posix_acl_release(acl);
@@ -121,14 +115,12 @@ failed:
 
 /**
  * generic_acl_init  -  Take care of acl inheritance at @inode create time
- * @ops:       Filesystem specific getacl and setacl callbacks
  *
  * Files created inside a directory with a default ACL inherit the
  * directory's default ACL.
  */
 int
-generic_acl_init(struct inode *inode, struct inode *dir,
-                struct generic_acl_operations *ops)
+generic_acl_init(struct inode *inode, struct inode *dir)
 {
        struct posix_acl *acl = NULL;
        mode_t mode = inode->i_mode;
@@ -136,7 +128,7 @@ generic_acl_init(struct inode *inode, struct inode *dir,
 
        inode->i_mode = mode & ~current_umask();
        if (!S_ISLNK(inode->i_mode))
-               acl = ops->getacl(dir, ACL_TYPE_DEFAULT);
+               acl = get_cached_acl(dir, ACL_TYPE_DEFAULT);
        if (acl) {
                struct posix_acl *clone;
 
@@ -145,7 +137,7 @@ generic_acl_init(struct inode *inode, struct inode *dir,
                        error = -ENOMEM;
                        if (!clone)
                                goto cleanup;
-                       ops->setacl(inode, ACL_TYPE_DEFAULT, clone);
+                       set_cached_acl(inode, ACL_TYPE_DEFAULT, clone);
                        posix_acl_release(clone);
                }
                clone = posix_acl_clone(acl, GFP_KERNEL);
@@ -156,7 +148,7 @@ generic_acl_init(struct inode *inode, struct inode *dir,
                if (error >= 0) {
                        inode->i_mode = mode;
                        if (error > 0)
-                               ops->setacl(inode, ACL_TYPE_ACCESS, clone);
+                               set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
                }
                posix_acl_release(clone);
        }
@@ -169,20 +161,19 @@ cleanup:
 
 /**
  * generic_acl_chmod  -  change the access acl of @inode upon chmod()
- * @ops:       FIlesystem specific getacl and setacl callbacks
  *
  * A chmod also changes the permissions of the owner, group/mask, and
  * other ACL entries.
  */
 int
-generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops)
+generic_acl_chmod(struct inode *inode)
 {
        struct posix_acl *acl, *clone;
        int error = 0;
 
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
-       acl = ops->getacl(inode, ACL_TYPE_ACCESS);
+       acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
        if (acl) {
                clone = posix_acl_clone(acl, GFP_KERNEL);
                posix_acl_release(acl);
@@ -190,8 +181,37 @@ generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops)
                        return -ENOMEM;
                error = posix_acl_chmod_masq(clone, inode->i_mode);
                if (!error)
-                       ops->setacl(inode, ACL_TYPE_ACCESS, clone);
+                       set_cached_acl(inode, ACL_TYPE_ACCESS, clone);
                posix_acl_release(clone);
        }
        return error;
 }
+
+int
+generic_check_acl(struct inode *inode, int mask)
+{
+       struct posix_acl *acl = get_cached_acl(inode, ACL_TYPE_ACCESS);
+
+       if (acl) {
+               int error = posix_acl_permission(inode, acl, mask);
+               posix_acl_release(acl);
+               return error;
+       }
+       return -EAGAIN;
+}
+
+struct xattr_handler generic_acl_access_handler = {
+       .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags  = ACL_TYPE_ACCESS,
+       .list   = generic_acl_list,
+       .get    = generic_acl_get,
+       .set    = generic_acl_set,
+};
+
+struct xattr_handler generic_acl_default_handler = {
+       .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags  = ACL_TYPE_DEFAULT,
+       .list   = generic_acl_list,
+       .get    = generic_acl_get,
+       .set    = generic_acl_set,
+};
index 3eb1ea846173548a7bf266936deae21296fad9ad..87ee309d4c24d10e6dcac60f7d8bca17558553b2 100644 (file)
@@ -126,7 +126,7 @@ static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl)
        error = posix_acl_to_xattr(acl, data, len);
        if (error < 0)
                goto out;
-       error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, data, len, 0);
+       error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS);
        if (!error)
                set_cached_acl(inode, type, acl);
 out:
@@ -232,9 +232,10 @@ static int gfs2_acl_type(const char *name)
        return -EINVAL;
 }
 
-static int gfs2_xattr_system_get(struct inode *inode, const char *name,
-                                void *buffer, size_t size)
+static int gfs2_xattr_system_get(struct dentry *dentry, const char *name,
+                                void *buffer, size_t size, int xtype)
 {
+       struct inode *inode = dentry->d_inode;
        struct posix_acl *acl;
        int type;
        int error;
@@ -255,9 +256,11 @@ static int gfs2_xattr_system_get(struct inode *inode, const char *name,
        return error;
 }
 
-static int gfs2_xattr_system_set(struct inode *inode, const char *name,
-                                const void *value, size_t size, int flags)
+static int gfs2_xattr_system_set(struct dentry *dentry, const char *name,
+                                const void *value, size_t size, int flags,
+                                int xtype)
 {
+       struct inode *inode = dentry->d_inode;
        struct gfs2_sbd *sdp = GFS2_SB(inode);
        struct posix_acl *acl = NULL;
        int error = 0, type;
@@ -319,7 +322,7 @@ static int gfs2_xattr_system_set(struct inode *inode, const char *name,
        }
 
 set_acl:
-       error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, value, size, 0);
+       error = __gfs2_xattr_set(inode, name, value, size, 0, GFS2_EATYPE_SYS);
        if (!error) {
                if (acl)
                        set_cached_acl(inode, type, acl);
@@ -334,6 +337,7 @@ out:
 
 struct xattr_handler gfs2_xattr_system_handler = {
        .prefix = XATTR_SYSTEM_PREFIX,
+       .flags  = GFS2_EATYPE_SYS,
        .get    = gfs2_xattr_system_get,
        .set    = gfs2_xattr_system_set,
 };
index 26ba2a4c4a2dafb84a19af6a87a2da965cd18591..6e220f4eee7dbadc3ec5c8070533458429bec71a 100644 (file)
@@ -125,7 +125,7 @@ static struct inode *gfs2_iget_skip(struct super_block *sb,
  * directory entry when gfs2_inode_lookup() is invoked. Part of the code
  * segment inside gfs2_inode_lookup code needs to get moved around.
  *
- * Clean up I_LOCK and I_NEW as well.
+ * Clears I_NEW as well.
  **/
 
 void gfs2_set_iop(struct inode *inode)
@@ -801,7 +801,8 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip)
                return err;
        }
 
-       err = gfs2_xattr_set(&ip->i_inode, GFS2_EATYPE_SECURITY, name, value, len, 0);
+       err = __gfs2_xattr_set(&ip->i_inode, name, value, len, 0,
+                              GFS2_EATYPE_SECURITY);
        kfree(value);
        kfree(name);
 
index c5dad1eb7b916d34884883abe192b9cb89134746..0dc34621f6a6ecf73acddc3c82d0a90c731ff601 100644 (file)
@@ -85,11 +85,7 @@ static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf)
        buf[0] = '\0';
        if (!gfs2_uuid_valid(uuid))
                return 0;
-       return snprintf(buf, PAGE_SIZE, "%02X%02X%02X%02X-%02X%02X-"
-                       "%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",
-                       uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5],
-                       uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11],
-                       uuid[12], uuid[13], uuid[14], uuid[15]);
+       return snprintf(buf, PAGE_SIZE, "%pUB\n", uuid);
 }
 
 static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf)
@@ -575,14 +571,8 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,
        add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name);
        if (!sdp->sd_args.ar_spectator)
                add_uevent_var(env, "JOURNALID=%u", sdp->sd_lockstruct.ls_jid);
-       if (gfs2_uuid_valid(uuid)) {
-               add_uevent_var(env, "UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-"
-                              "%02X%02X-%02X%02X%02X%02X%02X%02X",
-                              uuid[0], uuid[1], uuid[2], uuid[3], uuid[4],
-                              uuid[5], uuid[6], uuid[7], uuid[8], uuid[9],
-                              uuid[10], uuid[11], uuid[12], uuid[13],
-                              uuid[14], uuid[15]);
-       }
+       if (gfs2_uuid_valid(uuid))
+               add_uevent_var(env, "UUID=%pUB", uuid);
        return 0;
 }
 
index 912f5cbc4740170e32c56f63ac2d6ecf2ec9d4ac..8a04108e0c22fff076b8dbae79ad87dab98f8eff 100644 (file)
@@ -567,18 +567,17 @@ out:
 /**
  * gfs2_xattr_get - Get a GFS2 extended attribute
  * @inode: The inode
- * @type: The type of extended attribute
  * @name: The name of the extended attribute
  * @buffer: The buffer to write the result into
  * @size: The size of the buffer
+ * @type: The type of extended attribute
  *
  * Returns: actual size of data on success, -errno on error
  */
-
-int gfs2_xattr_get(struct inode *inode, int type, const char *name,
-                  void *buffer, size_t size)
+static int gfs2_xattr_get(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
-       struct gfs2_inode *ip = GFS2_I(inode);
+       struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
        struct gfs2_ea_location el;
        int error;
 
@@ -1119,7 +1118,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
 
 /**
  * gfs2_xattr_remove - Remove a GFS2 extended attribute
- * @inode: The inode
+ * @ip: The inode
  * @type: The type of the extended attribute
  * @name: The name of the extended attribute
  *
@@ -1130,9 +1129,8 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
  * Returns: 0, or errno on failure
  */
 
-static int gfs2_xattr_remove(struct inode *inode, int type, const char *name)
+static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name)
 {
-       struct gfs2_inode *ip = GFS2_I(inode);
        struct gfs2_ea_location el;
        int error;
 
@@ -1156,24 +1154,24 @@ static int gfs2_xattr_remove(struct inode *inode, int type, const char *name)
 }
 
 /**
- * gfs2_xattr_set - Set (or remove) a GFS2 extended attribute
- * @inode: The inode
- * @type: The type of the extended attribute
+ * __gfs2_xattr_set - Set (or remove) a GFS2 extended attribute
+ * @ip: The inode
  * @name: The name of the extended attribute
  * @value: The value of the extended attribute (NULL for remove)
  * @size: The size of the @value argument
  * @flags: Create or Replace
+ * @type: The type of the extended attribute
  *
  * See gfs2_xattr_remove() for details of the removal of xattrs.
  *
  * Returns: 0 or errno on failure
  */
 
-int gfs2_xattr_set(struct inode *inode, int type, const char *name,
-                  const void *value, size_t size, int flags)
+int __gfs2_xattr_set(struct inode *inode, const char *name,
+                  const void *value, size_t size, int flags, int type)
 {
-       struct gfs2_sbd *sdp = GFS2_SB(inode);
        struct gfs2_inode *ip = GFS2_I(inode);
+       struct gfs2_sbd *sdp = GFS2_SB(inode);
        struct gfs2_ea_location el;
        unsigned int namel = strlen(name);
        int error;
@@ -1184,7 +1182,7 @@ int gfs2_xattr_set(struct inode *inode, int type, const char *name,
                return -ERANGE;
 
        if (value == NULL)
-               return gfs2_xattr_remove(inode, type, name);
+               return gfs2_xattr_remove(ip, type, name);
 
        if (ea_check_size(sdp, namel, size))
                return -ERANGE;
@@ -1224,6 +1222,13 @@ int gfs2_xattr_set(struct inode *inode, int type, const char *name,
        return error;
 }
 
+static int gfs2_xattr_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
+{
+       return __gfs2_xattr_set(dentry->d_inode, name, value,
+                               size, flags, type);
+}
+
 static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
                                  struct gfs2_ea_header *ea, char *data)
 {
@@ -1529,40 +1534,18 @@ out_alloc:
        return error;
 }
 
-static int gfs2_xattr_user_get(struct inode *inode, const char *name,
-                              void *buffer, size_t size)
-{
-       return gfs2_xattr_get(inode, GFS2_EATYPE_USR, name, buffer, size);
-}
-
-static int gfs2_xattr_user_set(struct inode *inode, const char *name,
-                              const void *value, size_t size, int flags)
-{
-       return gfs2_xattr_set(inode, GFS2_EATYPE_USR, name, value, size, flags);
-}
-
-static int gfs2_xattr_security_get(struct inode *inode, const char *name,
-                                  void *buffer, size_t size)
-{
-       return gfs2_xattr_get(inode, GFS2_EATYPE_SECURITY, name, buffer, size);
-}
-
-static int gfs2_xattr_security_set(struct inode *inode, const char *name,
-                                  const void *value, size_t size, int flags)
-{
-       return gfs2_xattr_set(inode, GFS2_EATYPE_SECURITY, name, value, size, flags);
-}
-
 static struct xattr_handler gfs2_xattr_user_handler = {
        .prefix = XATTR_USER_PREFIX,
-       .get    = gfs2_xattr_user_get,
-       .set    = gfs2_xattr_user_set,
+       .flags  = GFS2_EATYPE_USR,
+       .get    = gfs2_xattr_get,
+       .set    = gfs2_xattr_set,
 };
 
 static struct xattr_handler gfs2_xattr_security_handler = {
        .prefix = XATTR_SECURITY_PREFIX,
-       .get    = gfs2_xattr_security_get,
-       .set    = gfs2_xattr_security_set,
+       .flags  = GFS2_EATYPE_SECURITY,
+       .get    = gfs2_xattr_get,
+       .set    = gfs2_xattr_set,
 };
 
 struct xattr_handler *gfs2_xattr_handlers[] = {
index 8d6ae5813c4d42317d10600f37d41c708c27d1cb..d392f8358f2ff0e47687aee4a1cf1b664d5b1589 100644 (file)
@@ -53,10 +53,9 @@ struct gfs2_ea_location {
        struct gfs2_ea_header *el_prev;
 };
 
-extern int gfs2_xattr_get(struct inode *inode, int type, const char *name,
-                         void *buffer, size_t size);
-extern int gfs2_xattr_set(struct inode *inode, int type, const char *name,
-                         const void *value, size_t size, int flags);
+extern int __gfs2_xattr_set(struct inode *inode, const char *name,
+                           const void *value, size_t size,
+                           int flags, int type);
 extern ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size);
 extern int gfs2_ea_dealloc(struct gfs2_inode *ip);
 
index 6d98f116ca03d610a1477dc77558c899f5abe48d..424b0337f5244b150fcad3fb67b9ef8cb93ae932 100644 (file)
@@ -289,6 +289,10 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name,
        err = hfs_brec_find(&src_fd);
        if (err)
                goto out;
+       if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
+               err = -EIO;
+               goto out;
+       }
 
        hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
                            src_fd.entrylength);
index 7c69b98a2e45b679cc97b87e00247fa40442c2d8..2b3b8611b41b5010daf2392a522834075654a4ef 100644 (file)
@@ -79,6 +79,11 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                filp->f_pos++;
                /* fall through */
        case 1:
+               if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+                       err = -EIO;
+                       goto out;
+               }
+
                hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
                if (entry.type != HFS_CDR_THD) {
                        printk(KERN_ERR "hfs: bad catalog folder thread\n");
@@ -109,6 +114,12 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                        err = -EIO;
                        goto out;
                }
+
+               if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
+                       err = -EIO;
+                       goto out;
+               }
+
                hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength);
                type = entry.type;
                len = hfs_mac2asc(sb, strbuf, &fd.key->cat.CName);
index f7fcbe49da723c40b56c816c8f04bea6e8d24616..5ed7252b7b23246aabdb015341ba19cbb101379a 100644 (file)
@@ -409,8 +409,13 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
        /* try to get the root inode */
        hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
        res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd);
-       if (!res)
+       if (!res) {
+               if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
+                       res =  -EIO;
+                       goto bail;
+               }
                hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength);
+       }
        if (res) {
                hfs_find_exit(&fd);
                goto bail_no_root;
index f2feaa06bf26c5839d0bdb7e566bc7bd9fbeea65..cadc4ce48656674358e44eeb62e16f4f5bdc9b01 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/magic.h>
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
+#include <linux/bitmap.h>
 
 /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */
 
@@ -115,15 +116,13 @@ static void hpfs_put_super(struct super_block *s)
 unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno)
 {
        struct quad_buffer_head qbh;
-       unsigned *bits;
-       unsigned i, count;
-       if (!(bits = hpfs_map_4sectors(s, secno, &qbh, 4))) return 0;
-       count = 0;
-       for (i = 0; i < 2048 / sizeof(unsigned); i++) {
-               unsigned b; 
-               if (!bits[i]) continue;
-               for (b = bits[i]; b; b>>=1) count += b & 1;
-       }
+       unsigned long *bits;
+       unsigned count;
+
+       bits = hpfs_map_4sectors(s, secno, &qbh, 4);
+       if (!bits)
+               return 0;
+       count = bitmap_weight(bits, 2048 * BITS_PER_BYTE);
        hpfs_brelse4(&qbh);
        return count;
 }
index 87a1258953b8e387fe49367acfd6d2ff5c164ca1..a0bbd3d1b41a29338fe9cef80e8da032f44b15fe 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/dnotify.h>
 #include <linux/statfs.h>
 #include <linux/security.h>
-#include <linux/ima.h>
 #include <linux/magic.h>
 
 #include <asm/uaccess.h>
@@ -922,7 +921,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
        int error = -ENOMEM;
        struct file *file;
        struct inode *inode;
-       struct dentry *dentry, *root;
+       struct path path;
+       struct dentry *root;
        struct qstr quick_string;
 
        *user = NULL;
@@ -944,10 +944,11 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
        quick_string.name = name;
        quick_string.len = strlen(quick_string.name);
        quick_string.hash = 0;
-       dentry = d_alloc(root, &quick_string);
-       if (!dentry)
+       path.dentry = d_alloc(root, &quick_string);
+       if (!path.dentry)
                goto out_shm_unlock;
 
+       path.mnt = mntget(hugetlbfs_vfsmount);
        error = -ENOSPC;
        inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(),
                                current_fsgid(), S_IFREG | S_IRWXUGO, 0);
@@ -960,24 +961,22 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
                        acctflag))
                goto out_inode;
 
-       d_instantiate(dentry, inode);
+       d_instantiate(path.dentry, inode);
        inode->i_size = size;
        inode->i_nlink = 0;
 
        error = -ENFILE;
-       file = alloc_file(hugetlbfs_vfsmount, dentry,
-                       FMODE_WRITE | FMODE_READ,
+       file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
                        &hugetlbfs_file_operations);
        if (!file)
                goto out_dentry; /* inode is already attached */
-       ima_counts_get(file);
 
        return file;
 
 out_inode:
        iput(inode);
 out_dentry:
-       dput(dentry);
+       path_put(&path);
 out_shm_unlock:
        if (*user) {
                user_shm_unlock(size, *user);
index 06c1f02de611d51bc8d4218b29e083bc15eb9c43..03dfeb2e39287a75b2fccbe6c71d1451ebade3a0 100644 (file)
@@ -113,7 +113,7 @@ static void wake_up_inode(struct inode *inode)
         * Prevent speculative execution through spin_unlock(&inode_lock);
         */
        smp_mb();
-       wake_up_bit(&inode->i_state, __I_LOCK);
+       wake_up_bit(&inode->i_state, __I_NEW);
 }
 
 /**
@@ -690,17 +690,17 @@ void unlock_new_inode(struct inode *inode)
        }
 #endif
        /*
-        * This is special!  We do not need the spinlock when clearing I_LOCK,
+        * This is special!  We do not need the spinlock when clearing I_NEW,
         * because we're guaranteed that nobody else tries to do anything about
         * the state of the inode when it is locked, as we just created it (so
-        * there can be no old holders that haven't tested I_LOCK).
+        * there can be no old holders that haven't tested I_NEW).
         * However we must emit the memory barrier so that other CPUs reliably
-        * see the clearing of I_LOCK after the other inode initialisation has
+        * see the clearing of I_NEW after the other inode initialisation has
         * completed.
         */
        smp_mb();
-       WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW));
-       inode->i_state &= ~(I_LOCK|I_NEW);
+       WARN_ON(!(inode->i_state & I_NEW));
+       inode->i_state &= ~I_NEW;
        wake_up_inode(inode);
 }
 EXPORT_SYMBOL(unlock_new_inode);
@@ -731,7 +731,7 @@ static struct inode *get_new_inode(struct super_block *sb,
                                goto set_failed;
 
                        __inode_add_to_lists(sb, head, inode);
-                       inode->i_state = I_LOCK|I_NEW;
+                       inode->i_state = I_NEW;
                        spin_unlock(&inode_lock);
 
                        /* Return the locked inode with I_NEW set, the
@@ -778,7 +778,7 @@ static struct inode *get_new_inode_fast(struct super_block *sb,
                if (!old) {
                        inode->i_ino = ino;
                        __inode_add_to_lists(sb, head, inode);
-                       inode->i_state = I_LOCK|I_NEW;
+                       inode->i_state = I_NEW;
                        spin_unlock(&inode_lock);
 
                        /* Return the locked inode with I_NEW set, the
@@ -1083,7 +1083,7 @@ int insert_inode_locked(struct inode *inode)
        ino_t ino = inode->i_ino;
        struct hlist_head *head = inode_hashtable + hash(sb, ino);
 
-       inode->i_state |= I_LOCK|I_NEW;
+       inode->i_state |= I_NEW;
        while (1) {
                struct hlist_node *node;
                struct inode *old = NULL;
@@ -1120,7 +1120,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval,
        struct super_block *sb = inode->i_sb;
        struct hlist_head *head = inode_hashtable + hash(sb, hashval);
 
-       inode->i_state |= I_LOCK|I_NEW;
+       inode->i_state |= I_NEW;
 
        while (1) {
                struct hlist_node *node;
@@ -1510,7 +1510,7 @@ EXPORT_SYMBOL(inode_wait);
  * until the deletion _might_ have completed.  Callers are responsible
  * to recheck inode state.
  *
- * It doesn't matter if I_LOCK is not set initially, a call to
+ * It doesn't matter if I_NEW is not set initially, a call to
  * wake_up_inode() after removing from the hash list will DTRT.
  *
  * This is called with inode_lock held.
@@ -1518,8 +1518,8 @@ EXPORT_SYMBOL(inode_wait);
 static void __wait_on_freeing_inode(struct inode *inode)
 {
        wait_queue_head_t *wq;
-       DEFINE_WAIT_BIT(wait, &inode->i_state, __I_LOCK);
-       wq = bit_waitqueue(&inode->i_state, __I_LOCK);
+       DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW);
+       wq = bit_waitqueue(&inode->i_state, __I_NEW);
        prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
        spin_unlock(&inode_lock);
        schedule();
index 515175b8b72e95f47893d3b1f32017da481e0aec..e96a1667d749d5efa59b659fea5d1f0057ffb973 100644 (file)
@@ -79,8 +79,16 @@ extern void chroot_fs_refs(struct path *, struct path *);
  * file_table.c
  */
 extern void mark_files_ro(struct super_block *);
+extern struct file *get_empty_filp(void);
 
 /*
  * super.c
  */
 extern int do_remount_sb(struct super_block *, int, void *, int);
+
+/*
+ * open.c
+ */
+struct nameidata;
+extern struct file *nameidata_to_filp(struct nameidata *);
+extern void release_open_intent(struct nameidata *);
index e81a30593ba9aa1b1e857032f3a6a6faac82aea8..ed752cb3847426f108803af94566ba79d80786ed 100644 (file)
@@ -9,7 +9,7 @@
  *
  * The following files are helpful:
  *
- *     Documentation/filesystems/Exporting
+ *     Documentation/filesystems/nfs/Exporting
  *     fs/exportfs/expfs.c.
  */
 
index 4160afad6d00fc4b8812ac497d2a3bcac28efc60..bd224eec9b072d5ebe0a075c57e203b9fde61c1d 100644 (file)
@@ -1913,7 +1913,7 @@ static void __init jbd_create_debugfs_entry(void)
 {
        jbd_debugfs_dir = debugfs_create_dir("jbd", NULL);
        if (jbd_debugfs_dir)
-               jbd_debug = debugfs_create_u8("jbd-debug", S_IRUGO,
+               jbd_debug = debugfs_create_u8("jbd-debug", S_IRUGO | S_IWUSR,
                                               jbd_debugfs_dir,
                                               &journal_enable_debug);
 }
index ca0f5eb62b20e450b38ef84b52c64bc2a214bc17..886849370950f462627f0a9d2df692ec4d117d97 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/jbd2.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
+#include <linux/blkdev.h>
 #include <trace/events/jbd2.h>
 
 /*
@@ -515,6 +516,20 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
        journal->j_tail_sequence = first_tid;
        journal->j_tail = blocknr;
        spin_unlock(&journal->j_state_lock);
+
+       /*
+        * If there is an external journal, we need to make sure that
+        * any data blocks that were recently written out --- perhaps
+        * by jbd2_log_do_checkpoint() --- are flushed out before we
+        * drop the transactions from the external journal.  It's
+        * unlikely this will be necessary, especially with a
+        * appropriately sized journal, but we need this to guarantee
+        * correctness.  Fortunately jbd2_cleanup_journal_tail()
+        * doesn't get called all that often.
+        */
+       if ((journal->j_fs_dev != journal->j_dev) &&
+           (journal->j_flags & JBD2_BARRIER))
+               blkdev_issue_flush(journal->j_fs_dev, NULL);
        if (!(journal->j_flags & JBD2_ABORT))
                jbd2_journal_update_superblock(journal, 1);
        return 0;
index 6a10238d2c63d3f7c7945d1d6cbe6a4adcb57d04..1bc74b6f26d2cbb9d159f9f49aef102fa7dda30e 100644 (file)
@@ -259,6 +259,7 @@ static int journal_submit_data_buffers(journal_t *journal,
                        ret = err;
                spin_lock(&journal->j_list_lock);
                J_ASSERT(jinode->i_transaction == commit_transaction);
+               commit_transaction->t_flushed_data_blocks = 1;
                jinode->i_flags &= ~JI_COMMIT_RUNNING;
                wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
        }
@@ -708,8 +709,17 @@ start_journal_io:
                }
        }
 
-       /* Done it all: now write the commit record asynchronously. */
+       /* 
+        * If the journal is not located on the file system device,
+        * then we must flush the file system device before we issue
+        * the commit record
+        */
+       if (commit_transaction->t_flushed_data_blocks &&
+           (journal->j_fs_dev != journal->j_dev) &&
+           (journal->j_flags & JBD2_BARRIER))
+               blkdev_issue_flush(journal->j_fs_dev, NULL);
 
+       /* Done it all: now write the commit record asynchronously. */
        if (JBD2_HAS_INCOMPAT_FEATURE(journal,
                                      JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) {
                err = journal_submit_commit_record(journal, commit_transaction,
@@ -720,13 +730,6 @@ start_journal_io:
                        blkdev_issue_flush(journal->j_dev, NULL);
        }
 
-       /*
-        * This is the right place to wait for data buffers both for ASYNC
-        * and !ASYNC commit. If commit is ASYNC, we need to wait only after
-        * the commit block went to disk (which happens above). If commit is
-        * SYNC, we need to wait for data buffers before we start writing
-        * commit block, which happens below in such setting.
-        */
        err = journal_finish_inode_data_buffers(journal, commit_transaction);
        if (err) {
                printk(KERN_WARNING
index b7ca3a92a4dba0b23f555a75cac79fea1b6ae9e4..ac0d027595d00bf28e55f00b040d26e295023602 100644 (file)
@@ -814,7 +814,7 @@ static journal_t * journal_init_common (void)
        journal_t *journal;
        int err;
 
-       journal = kzalloc(sizeof(*journal), GFP_KERNEL|__GFP_NOFAIL);
+       journal = kzalloc(sizeof(*journal), GFP_KERNEL);
        if (!journal)
                goto fail;
 
@@ -2115,7 +2115,8 @@ static void __init jbd2_create_debugfs_entry(void)
 {
        jbd2_debugfs_dir = debugfs_create_dir("jbd2", NULL);
        if (jbd2_debugfs_dir)
-               jbd2_debug = debugfs_create_u8(JBD2_DEBUG_NAME, S_IRUGO,
+               jbd2_debug = debugfs_create_u8(JBD2_DEBUG_NAME,
+                                              S_IRUGO | S_IWUSR,
                                               jbd2_debugfs_dir,
                                               &jbd2_journal_enable_debug);
 }
index 7edb62e97419c57d9e1ba28de2ca810798bfed6a..7cdc3196476ace72ef11fb53bbe80fb86b3dfbeb 100644 (file)
@@ -350,8 +350,8 @@ int jffs2_acl_chmod(struct inode *inode)
        return rc;
 }
 
-static size_t jffs2_acl_access_listxattr(struct inode *inode, char *list, size_t list_size,
-                                        const char *name, size_t name_len)
+static size_t jffs2_acl_access_listxattr(struct dentry *dentry, char *list,
+               size_t list_size, const char *name, size_t name_len, int type)
 {
        const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS);
 
@@ -360,8 +360,8 @@ static size_t jffs2_acl_access_listxattr(struct inode *inode, char *list, size_t
        return retlen;
 }
 
-static size_t jffs2_acl_default_listxattr(struct inode *inode, char *list, size_t list_size,
-                                         const char *name, size_t name_len)
+static size_t jffs2_acl_default_listxattr(struct dentry *dentry, char *list,
+               size_t list_size, const char *name, size_t name_len, int type)
 {
        const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT);
 
@@ -370,12 +370,16 @@ static size_t jffs2_acl_default_listxattr(struct inode *inode, char *list, size_
        return retlen;
 }
 
-static int jffs2_acl_getxattr(struct inode *inode, int type, void *buffer, size_t size)
+static int jffs2_acl_getxattr(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
        struct posix_acl *acl;
        int rc;
 
-       acl = jffs2_get_acl(inode, type);
+       if (name[0] != '\0')
+               return -EINVAL;
+
+       acl = jffs2_get_acl(dentry->d_inode, type);
        if (IS_ERR(acl))
                return PTR_ERR(acl);
        if (!acl)
@@ -386,26 +390,15 @@ static int jffs2_acl_getxattr(struct inode *inode, int type, void *buffer, size_
        return rc;
 }
 
-static int jffs2_acl_access_getxattr(struct inode *inode, const char *name, void *buffer, size_t size)
-{
-       if (name[0] != '\0')
-               return -EINVAL;
-       return jffs2_acl_getxattr(inode, ACL_TYPE_ACCESS, buffer, size);
-}
-
-static int jffs2_acl_default_getxattr(struct inode *inode, const char *name, void *buffer, size_t size)
-{
-       if (name[0] != '\0')
-               return -EINVAL;
-       return jffs2_acl_getxattr(inode, ACL_TYPE_DEFAULT, buffer, size);
-}
-
-static int jffs2_acl_setxattr(struct inode *inode, int type, const void *value, size_t size)
+static int jffs2_acl_setxattr(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        struct posix_acl *acl;
        int rc;
 
-       if (!is_owner_or_cap(inode))
+       if (name[0] != '\0')
+               return -EINVAL;
+       if (!is_owner_or_cap(dentry->d_inode))
                return -EPERM;
 
        if (value) {
@@ -420,38 +413,24 @@ static int jffs2_acl_setxattr(struct inode *inode, int type, const void *value,
        } else {
                acl = NULL;
        }
-       rc = jffs2_set_acl(inode, type, acl);
+       rc = jffs2_set_acl(dentry->d_inode, type, acl);
  out:
        posix_acl_release(acl);
        return rc;
 }
 
-static int jffs2_acl_access_setxattr(struct inode *inode, const char *name,
-                                    const void *buffer, size_t size, int flags)
-{
-       if (name[0] != '\0')
-               return -EINVAL;
-       return jffs2_acl_setxattr(inode, ACL_TYPE_ACCESS, buffer, size);
-}
-
-static int jffs2_acl_default_setxattr(struct inode *inode, const char *name,
-                                     const void *buffer, size_t size, int flags)
-{
-       if (name[0] != '\0')
-               return -EINVAL;
-       return jffs2_acl_setxattr(inode, ACL_TYPE_DEFAULT, buffer, size);
-}
-
 struct xattr_handler jffs2_acl_access_xattr_handler = {
        .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags  = ACL_TYPE_DEFAULT,
        .list   = jffs2_acl_access_listxattr,
-       .get    = jffs2_acl_access_getxattr,
-       .set    = jffs2_acl_access_setxattr,
+       .get    = jffs2_acl_getxattr,
+       .set    = jffs2_acl_setxattr,
 };
 
 struct xattr_handler jffs2_acl_default_xattr_handler = {
        .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags  = ACL_TYPE_DEFAULT,
        .list   = jffs2_acl_default_listxattr,
-       .get    = jffs2_acl_default_getxattr,
-       .set    = jffs2_acl_default_setxattr,
+       .get    = jffs2_acl_getxattr,
+       .set    = jffs2_acl_setxattr,
 };
index 090c556ffed28c7861b957efacf30099716ac465..3b6f2fa12cff16df800dee5ebb9b89fe93698eb5 100644 (file)
@@ -700,7 +700,8 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
        struct jffs2_raw_inode ri;
        struct jffs2_node_frag *last_frag;
        union jffs2_device_node dev;
-       char *mdata = NULL, mdatalen = 0;
+       char *mdata = NULL;
+       int mdatalen = 0;
        uint32_t alloclen, ilen;
        int ret;
 
index 378991cfe40f98f60f4cc5bae7e3079e9b8197d5..e22de8397b7430f3e48bcd2ae32ca0af70fe0a12 100644 (file)
@@ -1284,7 +1284,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
                                f->target = NULL;
                                mutex_unlock(&f->sem);
                                jffs2_do_clear_inode(c, f);
-                               return -ret;
+                               return ret;
                        }
 
                        f->target[je32_to_cpu(latest_node->csize)] = '\0';
index 02c39c64ecb391e734d18362aa074b5ea2a401db..eaccee05858357d1ceb82503010ff3481c07f835 100644 (file)
@@ -44,26 +44,28 @@ int jffs2_init_security(struct inode *inode, struct inode *dir)
 }
 
 /* ---- XATTR Handler for "security.*" ----------------- */
-static int jffs2_security_getxattr(struct inode *inode, const char *name,
-                                  void *buffer, size_t size)
+static int jffs2_security_getxattr(struct dentry *dentry, const char *name,
+                                  void *buffer, size_t size, int type)
 {
        if (!strcmp(name, ""))
                return -EINVAL;
 
-       return do_jffs2_getxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size);
+       return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_SECURITY,
+                                name, buffer, size);
 }
 
-static int jffs2_security_setxattr(struct inode *inode, const char *name, const void *buffer,
-                                  size_t size, int flags)
+static int jffs2_security_setxattr(struct dentry *dentry, const char *name,
+               const void *buffer, size_t size, int flags, int type)
 {
        if (!strcmp(name, ""))
                return -EINVAL;
 
-       return do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size, flags);
+       return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_SECURITY,
+                                name, buffer, size, flags);
 }
 
-static size_t jffs2_security_listxattr(struct inode *inode, char *list, size_t list_size,
-                                      const char *name, size_t name_len)
+static size_t jffs2_security_listxattr(struct dentry *dentry, char *list,
+               size_t list_size, const char *name, size_t name_len, int type)
 {
        size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1;
 
index 6caf1e1ee26d33951e2d013c4710ed3b21c9d3e2..800171dca53b2b24c00ce803686e38e72f6a931c 100644 (file)
@@ -23,7 +23,7 @@
 
 int jffs2_sum_init(struct jffs2_sb_info *c)
 {
-       uint32_t sum_size = max_t(uint32_t, c->sector_size, MAX_SUMMARY_SIZE);
+       uint32_t sum_size = min_t(uint32_t, c->sector_size, MAX_SUMMARY_SIZE);
 
        c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
 
index 4b107881acd5fd0adca0f7fb7de3d03dfc535395..9e75c62c85d6c4005e7b4ae8bab7c9a18e69bec3 100644 (file)
@@ -990,9 +990,11 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size)
                if (!xhandle)
                        continue;
                if (buffer) {
-                       rc = xhandle->list(inode, buffer+len, size-len, xd->xname, xd->name_len);
+                       rc = xhandle->list(dentry, buffer+len, size-len,
+                                          xd->xname, xd->name_len, xd->flags);
                } else {
-                       rc = xhandle->list(inode, NULL, 0, xd->xname, xd->name_len);
+                       rc = xhandle->list(dentry, NULL, 0, xd->xname,
+                                          xd->name_len, xd->flags);
                }
                if (rc < 0)
                        goto out;
index 8ec5765ef3488ef4d97ed29a6586db7b087066be..3e5a5e356e058f276bba8dc2f133be73c7a0bb72 100644 (file)
 #include <linux/mtd/mtd.h>
 #include "nodelist.h"
 
-static int jffs2_trusted_getxattr(struct inode *inode, const char *name,
-                                 void *buffer, size_t size)
+static int jffs2_trusted_getxattr(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
        if (!strcmp(name, ""))
                return -EINVAL;
-       return do_jffs2_getxattr(inode, JFFS2_XPREFIX_TRUSTED, name, buffer, size);
+       return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_TRUSTED,
+                                name, buffer, size);
 }
 
-static int jffs2_trusted_setxattr(struct inode *inode, const char *name, const void *buffer,
-                                 size_t size, int flags)
+static int jffs2_trusted_setxattr(struct dentry *dentry, const char *name,
+               const void *buffer, size_t size, int flags, int type)
 {
        if (!strcmp(name, ""))
                return -EINVAL;
-       return do_jffs2_setxattr(inode, JFFS2_XPREFIX_TRUSTED, name, buffer, size, flags);
+       return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_TRUSTED,
+                                name, buffer, size, flags);
 }
 
-static size_t jffs2_trusted_listxattr(struct inode *inode, char *list, size_t list_size,
-                                     const char *name, size_t name_len)
+static size_t jffs2_trusted_listxattr(struct dentry *dentry, char *list,
+               size_t list_size, const char *name, size_t name_len, int type)
 {
        size_t retlen = XATTR_TRUSTED_PREFIX_LEN + name_len + 1;
 
index 8bbeab90ada130981737ae6c4a0032c74556c007..8544af67dffe66b5f36dd5ebabec416a355a90bb 100644 (file)
 #include <linux/mtd/mtd.h>
 #include "nodelist.h"
 
-static int jffs2_user_getxattr(struct inode *inode, const char *name,
-                              void *buffer, size_t size)
+static int jffs2_user_getxattr(struct dentry *dentry, const char *name,
+                              void *buffer, size_t size, int type)
 {
        if (!strcmp(name, ""))
                return -EINVAL;
-       return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size);
+       return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_USER,
+                                name, buffer, size);
 }
 
-static int jffs2_user_setxattr(struct inode *inode, const char *name, const void *buffer,
-                              size_t size, int flags)
+static int jffs2_user_setxattr(struct dentry *dentry, const char *name,
+               const void *buffer, size_t size, int flags, int type)
 {
        if (!strcmp(name, ""))
                return -EINVAL;
-       return do_jffs2_setxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size, flags);
+       return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_USER,
+                                name, buffer, size, flags);
 }
 
-static size_t jffs2_user_listxattr(struct inode *inode, char *list, size_t list_size,
-                                  const char *name, size_t name_len)
+static size_t jffs2_user_listxattr(struct dentry *dentry, char *list,
+               size_t list_size, const char *name, size_t name_len, int type)
 {
        size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1;
 
index f26e4d03ada50aabc2e9870235cf297a838a1486..d945ea76b445249de68fece3be7dea631cf2b6b1 100644 (file)
@@ -1292,7 +1292,7 @@ int txCommit(tid_t tid,           /* transaction identifier */
                 */
                /*
                 * I believe this code is no longer needed.  Splitting I_LOCK
-                * into two bits, I_LOCK and I_SYNC should prevent this
+                * into two bits, I_NEW and I_SYNC should prevent this
                 * deadlock as well.  But since I don't have a JFS testload
                 * to verify this, only a trivial s/I_LOCK/I_SYNC/ was done.
                 * Joern
index 2234c73fc5773531bd59ee81b3bbdf45d05a83ff..d929a822a74e6410fd89727f4351e164f8e65ede 100644 (file)
@@ -524,7 +524,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
         * Page cache is indexed by long.
         * I would use MAX_LFS_FILESIZE, but it's only half as big
         */
-       sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1, sb->s_maxbytes);
+       sb->s_maxbytes = min(((u64) PAGE_CACHE_SIZE << 32) - 1, (u64)sb->s_maxbytes);
 #endif
        sb->s_time_gran = 1;
        return 0;
index 219576c52d807e15b779d53be3a42dfa1baae9ae..6e8d17e1dc4c95db609308d2ef59c8e314be79fe 100644 (file)
@@ -848,7 +848,6 @@ EXPORT_SYMBOL(simple_write_end);
 EXPORT_SYMBOL(simple_dir_inode_operations);
 EXPORT_SYMBOL(simple_dir_operations);
 EXPORT_SYMBOL(simple_empty);
-EXPORT_SYMBOL(d_alloc_name);
 EXPORT_SYMBOL(simple_fill_super);
 EXPORT_SYMBOL(simple_getattr);
 EXPORT_SYMBOL(simple_link);
index bd173a6ca3b1b0723b29d796ca77d6883f4fd25f..a7966eed3c17a2bfe34ec4bb6ed6ea492e1b9021 100644 (file)
 #include <linux/time.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
-#include <linux/in.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/sunrpc/clnt.h>
-#include <linux/nfsd/nfsd.h>
 #include <linux/lockd/lockd.h>
 #include <linux/lockd/share.h>
 
index e1d28ddd21699060a8b1e0907a8806bea9e62f95..56c9519d900a32ea203112f24b4866227b1bdd33 100644 (file)
 #include <linux/time.h>
 #include <linux/slab.h>
 #include <linux/smp_lock.h>
-#include <linux/in.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/sunrpc/clnt.h>
-#include <linux/nfsd/nfsd.h>
 #include <linux/lockd/lockd.h>
 #include <linux/lockd/share.h>
 
index 87f97ba90ad17d271baf15b2b2e65381a583c163..b55440baf7ab832e9d05ae8fdddc2337da57b5ed 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/fs_struct.h>
 #include <asm/uaccess.h>
 
-#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
+#include "internal.h"
 
 /* [Feb-1997 T. Schoebel-Theuer]
  * Fundamental changes in the pathname lookup mechanisms (namei)
  * any extra contention...
  */
 
-static int __link_path_walk(const char *name, struct nameidata *nd);
-
 /* In order to reduce some races, while at the same time doing additional
  * checking and hopefully speeding things up, we copy filenames to the
  * kernel data space before using them..
@@ -234,6 +232,7 @@ int generic_permission(struct inode *inode, int mask,
        /*
         * Searching includes executable on directories, else just read.
         */
+       mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
        if (mask == MAY_READ || (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE)))
                if (capable(CAP_DAC_READ_SEARCH))
                        return 0;
@@ -414,36 +413,55 @@ do_revalidate(struct dentry *dentry, struct nameidata *nd)
 }
 
 /*
- * Internal lookup() using the new generic dcache.
- * SMP-safe
+ * force_reval_path - force revalidation of a dentry
+ *
+ * In some situations the path walking code will trust dentries without
+ * revalidating them. This causes problems for filesystems that depend on
+ * d_revalidate to handle file opens (e.g. NFSv4). When FS_REVAL_DOT is set
+ * (which indicates that it's possible for the dentry to go stale), force
+ * a d_revalidate call before proceeding.
+ *
+ * Returns 0 if the revalidation was successful. If the revalidation fails,
+ * either return the error returned by d_revalidate or -ESTALE if the
+ * revalidation it just returned 0. If d_revalidate returns 0, we attempt to
+ * invalidate the dentry. It's up to the caller to handle putting references
+ * to the path if necessary.
  */
-static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd)
+static int
+force_reval_path(struct path *path, struct nameidata *nd)
 {
-       struct dentry * dentry = __d_lookup(parent, name);
+       int status;
+       struct dentry *dentry = path->dentry;
 
-       /* lockess __d_lookup may fail due to concurrent d_move() 
-        * in some unrelated directory, so try with d_lookup
+       /*
+        * only check on filesystems where it's possible for the dentry to
+        * become stale. It's assumed that if this flag is set then the
+        * d_revalidate op will also be defined.
         */
-       if (!dentry)
-               dentry = d_lookup(parent, name);
+       if (!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT))
+               return 0;
 
-       if (dentry && dentry->d_op && dentry->d_op->d_revalidate)
-               dentry = do_revalidate(dentry, nd);
+       status = dentry->d_op->d_revalidate(dentry, nd);
+       if (status > 0)
+               return 0;
 
-       return dentry;
+       if (!status) {
+               d_invalidate(dentry);
+               status = -ESTALE;
+       }
+       return status;
 }
 
 /*
- * Short-cut version of permission(), for calling by
- * path_walk(), when dcache lock is held.  Combines parts
- * of permission() and generic_permission(), and tests ONLY for
- * MAY_EXEC permission.
+ * Short-cut version of permission(), for calling on directories
+ * during pathname resolution.  Combines parts of permission()
+ * and generic_permission(), and tests ONLY for MAY_EXEC permission.
  *
  * If appropriate, check DAC only.  If not appropriate, or
- * short-cut DAC fails, then call permission() to do more
+ * short-cut DAC fails, then call ->permission() to do more
  * complete permission check.
  */
-static int exec_permission_lite(struct inode *inode)
+static int exec_permission(struct inode *inode)
 {
        int ret;
 
@@ -465,99 +483,6 @@ ok:
        return security_inode_permission(inode, MAY_EXEC);
 }
 
-/*
- * This is called when everything else fails, and we actually have
- * to go to the low-level filesystem to find out what we should do..
- *
- * We get the directory semaphore, and after getting that we also
- * make sure that nobody added the entry to the dcache in the meantime..
- * SMP-safe
- */
-static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd)
-{
-       struct dentry * result;
-       struct inode *dir = parent->d_inode;
-
-       mutex_lock(&dir->i_mutex);
-       /*
-        * First re-do the cached lookup just in case it was created
-        * while we waited for the directory semaphore..
-        *
-        * FIXME! This could use version numbering or similar to
-        * avoid unnecessary cache lookups.
-        *
-        * The "dcache_lock" is purely to protect the RCU list walker
-        * from concurrent renames at this point (we mustn't get false
-        * negatives from the RCU list walk here, unlike the optimistic
-        * fast walk).
-        *
-        * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup
-        */
-       result = d_lookup(parent, name);
-       if (!result) {
-               struct dentry *dentry;
-
-               /* Don't create child dentry for a dead directory. */
-               result = ERR_PTR(-ENOENT);
-               if (IS_DEADDIR(dir))
-                       goto out_unlock;
-
-               dentry = d_alloc(parent, name);
-               result = ERR_PTR(-ENOMEM);
-               if (dentry) {
-                       result = dir->i_op->lookup(dir, dentry, nd);
-                       if (result)
-                               dput(dentry);
-                       else
-                               result = dentry;
-               }
-out_unlock:
-               mutex_unlock(&dir->i_mutex);
-               return result;
-       }
-
-       /*
-        * Uhhuh! Nasty case: the cache was re-populated while
-        * we waited on the semaphore. Need to revalidate.
-        */
-       mutex_unlock(&dir->i_mutex);
-       if (result->d_op && result->d_op->d_revalidate) {
-               result = do_revalidate(result, nd);
-               if (!result)
-                       result = ERR_PTR(-ENOENT);
-       }
-       return result;
-}
-
-/*
- * Wrapper to retry pathname resolution whenever the underlying
- * file system returns an ESTALE.
- *
- * Retry the whole path once, forcing real lookup requests
- * instead of relying on the dcache.
- */
-static __always_inline int link_path_walk(const char *name, struct nameidata *nd)
-{
-       struct path save = nd->path;
-       int result;
-
-       /* make sure the stuff we saved doesn't go away */
-       path_get(&save);
-
-       result = __link_path_walk(name, nd);
-       if (result == -ESTALE) {
-               /* nd->path had been dropped */
-               nd->path = save;
-               path_get(&nd->path);
-               nd->flags |= LOOKUP_REVAL;
-               result = __link_path_walk(name, nd);
-       }
-
-       path_put(&save);
-
-       return result;
-}
-
 static __always_inline void set_root(struct nameidata *nd)
 {
        if (!nd->root.mnt) {
@@ -569,6 +494,8 @@ static __always_inline void set_root(struct nameidata *nd)
        }
 }
 
+static int link_path_walk(const char *, struct nameidata *);
+
 static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link)
 {
        int res = 0;
@@ -641,11 +568,14 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata
                error = 0;
                if (s)
                        error = __vfs_follow_link(nd, s);
+               else if (nd->last_type == LAST_BIND) {
+                       error = force_reval_path(&nd->path, nd);
+                       if (error)
+                               path_put(&nd->path);
+               }
                if (dentry->d_inode->i_op->put_link)
                        dentry->d_inode->i_op->put_link(dentry, nd, cookie);
        }
-       path_put(path);
-
        return error;
 }
 
@@ -672,6 +602,7 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd)
        current->total_link_count++;
        nd->depth++;
        err = __do_follow_link(path, nd);
+       path_put(path);
        current->link_count--;
        nd->depth--;
        return err;
@@ -797,8 +728,19 @@ static int do_lookup(struct nameidata *nd, struct qstr *name,
                     struct path *path)
 {
        struct vfsmount *mnt = nd->path.mnt;
-       struct dentry *dentry = __d_lookup(nd->path.dentry, name);
+       struct dentry *dentry, *parent;
+       struct inode *dir;
+       /*
+        * See if the low-level filesystem might want
+        * to use its own hash..
+        */
+       if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) {
+               int err = nd->path.dentry->d_op->d_hash(nd->path.dentry, name);
+               if (err < 0)
+                       return err;
+       }
 
+       dentry = __d_lookup(nd->path.dentry, name);
        if (!dentry)
                goto need_lookup;
        if (dentry->d_op && dentry->d_op->d_revalidate)
@@ -810,7 +752,59 @@ done:
        return 0;
 
 need_lookup:
-       dentry = real_lookup(nd->path.dentry, name, nd);
+       parent = nd->path.dentry;
+       dir = parent->d_inode;
+
+       mutex_lock(&dir->i_mutex);
+       /*
+        * First re-do the cached lookup just in case it was created
+        * while we waited for the directory semaphore..
+        *
+        * FIXME! This could use version numbering or similar to
+        * avoid unnecessary cache lookups.
+        *
+        * The "dcache_lock" is purely to protect the RCU list walker
+        * from concurrent renames at this point (we mustn't get false
+        * negatives from the RCU list walk here, unlike the optimistic
+        * fast walk).
+        *
+        * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup
+        */
+       dentry = d_lookup(parent, name);
+       if (!dentry) {
+               struct dentry *new;
+
+               /* Don't create child dentry for a dead directory. */
+               dentry = ERR_PTR(-ENOENT);
+               if (IS_DEADDIR(dir))
+                       goto out_unlock;
+
+               new = d_alloc(parent, name);
+               dentry = ERR_PTR(-ENOMEM);
+               if (new) {
+                       dentry = dir->i_op->lookup(dir, new, nd);
+                       if (dentry)
+                               dput(new);
+                       else
+                               dentry = new;
+               }
+out_unlock:
+               mutex_unlock(&dir->i_mutex);
+               if (IS_ERR(dentry))
+                       goto fail;
+               goto done;
+       }
+
+       /*
+        * Uhhuh! Nasty case: the cache was re-populated while
+        * we waited on the semaphore. Need to revalidate.
+        */
+       mutex_unlock(&dir->i_mutex);
+       if (dentry->d_op && dentry->d_op->d_revalidate) {
+               dentry = do_revalidate(dentry, nd);
+               if (!dentry)
+                       dentry = ERR_PTR(-ENOENT);
+       }
        if (IS_ERR(dentry))
                goto fail;
        goto done;
@@ -835,7 +829,7 @@ fail:
  * Returns 0 and nd will have valid dentry and mnt on success.
  * Returns error and drops reference to input namei data on failure.
  */
-static int __link_path_walk(const char *name, struct nameidata *nd)
+static int link_path_walk(const char *name, struct nameidata *nd)
 {
        struct path next;
        struct inode *inode;
@@ -858,7 +852,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
                unsigned int c;
 
                nd->flags |= LOOKUP_CONTINUE;
-               err = exec_permission_lite(inode);
+               err = exec_permission(inode);
                if (err)
                        break;
 
@@ -898,16 +892,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
                        case 1:
                                continue;
                }
-               /*
-                * See if the low-level filesystem might want
-                * to use its own hash..
-                */
-               if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) {
-                       err = nd->path.dentry->d_op->d_hash(nd->path.dentry,
-                                                           &this);
-                       if (err < 0)
-                               break;
-               }
                /* This does the actual lookups.. */
                err = do_lookup(nd, &this, &next);
                if (err)
@@ -953,12 +937,6 @@ last_component:
                        case 1:
                                goto return_reval;
                }
-               if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) {
-                       err = nd->path.dentry->d_op->d_hash(nd->path.dentry,
-                                                           &this);
-                       if (err < 0)
-                               break;
-               }
                err = do_lookup(nd, &this, &next);
                if (err)
                        break;
@@ -1017,8 +995,27 @@ return_err:
 
 static int path_walk(const char *name, struct nameidata *nd)
 {
+       struct path save = nd->path;
+       int result;
+
        current->total_link_count = 0;
-       return link_path_walk(name, nd);
+
+       /* make sure the stuff we saved doesn't go away */
+       path_get(&save);
+
+       result = link_path_walk(name, nd);
+       if (result == -ESTALE) {
+               /* nd->path had been dropped */
+               current->total_link_count = 0;
+               nd->path = save;
+               path_get(&nd->path);
+               nd->flags |= LOOKUP_REVAL;
+               result = link_path_walk(name, nd);
+       }
+
+       path_put(&save);
+
+       return result;
 }
 
 static int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd)
@@ -1141,36 +1138,6 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
        return retval;
 }
 
-/**
- * path_lookup_open - lookup a file path with open intent
- * @dfd: the directory to use as base, or AT_FDCWD
- * @name: pointer to file name
- * @lookup_flags: lookup intent flags
- * @nd: pointer to nameidata
- * @open_flags: open intent flags
- */
-static int path_lookup_open(int dfd, const char *name,
-               unsigned int lookup_flags, struct nameidata *nd, int open_flags)
-{
-       struct file *filp = get_empty_filp();
-       int err;
-
-       if (filp == NULL)
-               return -ENFILE;
-       nd->intent.open.file = filp;
-       nd->intent.open.flags = open_flags;
-       nd->intent.open.create_mode = 0;
-       err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd);
-       if (IS_ERR(nd->intent.open.file)) {
-               if (err == 0) {
-                       err = PTR_ERR(nd->intent.open.file);
-                       path_put(&nd->path);
-               }
-       } else if (err != 0)
-               release_open_intent(nd);
-       return err;
-}
-
 static struct dentry *__lookup_hash(struct qstr *name,
                struct dentry *base, struct nameidata *nd)
 {
@@ -1191,7 +1158,17 @@ static struct dentry *__lookup_hash(struct qstr *name,
                        goto out;
        }
 
-       dentry = cached_lookup(base, name, nd);
+       dentry = __d_lookup(base, name);
+
+       /* lockess __d_lookup may fail due to concurrent d_move()
+        * in some unrelated directory, so try with d_lookup
+        */
+       if (!dentry)
+               dentry = d_lookup(base, name);
+
+       if (dentry && dentry->d_op && dentry->d_op->d_revalidate)
+               dentry = do_revalidate(dentry, nd);
+
        if (!dentry) {
                struct dentry *new;
 
@@ -1223,7 +1200,7 @@ static struct dentry *lookup_hash(struct nameidata *nd)
 {
        int err;
 
-       err = inode_permission(nd->path.dentry->d_inode, MAY_EXEC);
+       err = exec_permission(nd->path.dentry->d_inode);
        if (err)
                return ERR_PTR(err);
        return __lookup_hash(&nd->last, nd->path.dentry, nd);
@@ -1273,7 +1250,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len)
        if (err)
                return ERR_PTR(err);
 
-       err = inode_permission(base->d_inode, MAY_EXEC);
+       err = exec_permission(base->d_inode);
        if (err)
                return ERR_PTR(err);
        return __lookup_hash(&this, base, NULL);
@@ -1511,69 +1488,45 @@ int may_open(struct path *path, int acc_mode, int flag)
        if (error)
                return error;
 
-       error = ima_path_check(path, acc_mode ?
-                              acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) :
-                              ACC_MODE(flag) & (MAY_READ | MAY_WRITE),
-                              IMA_COUNT_UPDATE);
-
-       if (error)
-               return error;
        /*
         * An append-only file must be opened in append mode for writing.
         */
        if (IS_APPEND(inode)) {
-               error = -EPERM;
                if  ((flag & FMODE_WRITE) && !(flag & O_APPEND))
-                       goto err_out;
+                       return -EPERM;
                if (flag & O_TRUNC)
-                       goto err_out;
+                       return -EPERM;
        }
 
        /* O_NOATIME can only be set by the owner or superuser */
-       if (flag & O_NOATIME)
-               if (!is_owner_or_cap(inode)) {
-                       error = -EPERM;
-                       goto err_out;
-               }
+       if (flag & O_NOATIME && !is_owner_or_cap(inode))
+               return -EPERM;
 
        /*
         * Ensure there are no outstanding leases on the file.
         */
-       error = break_lease(inode, flag);
-       if (error)
-               goto err_out;
-
-       if (flag & O_TRUNC) {
-               error = get_write_access(inode);
-               if (error)
-                       goto err_out;
-
-               /*
-                * Refuse to truncate files with mandatory locks held on them.
-                */
-               error = locks_verify_locked(inode);
-               if (!error)
-                       error = security_path_truncate(path, 0,
-                                              ATTR_MTIME|ATTR_CTIME|ATTR_OPEN);
-               if (!error) {
-                       vfs_dq_init(inode);
-
-                       error = do_truncate(dentry, 0,
-                                           ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
-                                           NULL);
-               }
-               put_write_access(inode);
-               if (error)
-                       goto err_out;
-       } else
-               if (flag & FMODE_WRITE)
-                       vfs_dq_init(inode);
+       return break_lease(inode, flag);
+}
 
-       return 0;
-err_out:
-       ima_counts_put(path, acc_mode ?
-                      acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) :
-                      ACC_MODE(flag) & (MAY_READ | MAY_WRITE));
+static int handle_truncate(struct path *path)
+{
+       struct inode *inode = path->dentry->d_inode;
+       int error = get_write_access(inode);
+       if (error)
+               return error;
+       /*
+        * Refuse to truncate files with mandatory locks held on them.
+        */
+       error = locks_verify_locked(inode);
+       if (!error)
+               error = security_path_truncate(path, 0,
+                                      ATTR_MTIME|ATTR_CTIME|ATTR_OPEN);
+       if (!error) {
+               error = do_truncate(path->dentry, 0,
+                                   ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
+                                   NULL);
+       }
+       put_write_access(inode);
        return error;
 }
 
@@ -1628,7 +1581,7 @@ static inline int open_to_namei_flags(int flag)
        return flag;
 }
 
-static int open_will_write_to_fs(int flag, struct inode *inode)
+static int open_will_truncate(int flag, struct inode *inode)
 {
        /*
         * We'll never write to the fs underlying
@@ -1650,10 +1603,10 @@ struct file *do_filp_open(int dfd, const char *pathname,
        struct file *filp;
        struct nameidata nd;
        int error;
-       struct path path;
+       struct path path, save;
        struct dentry *dir;
        int count = 0;
-       int will_write;
+       int will_truncate;
        int flag = open_to_namei_flags(open_flag);
 
        /*
@@ -1681,8 +1634,23 @@ struct file *do_filp_open(int dfd, const char *pathname,
         * The simplest case - just a plain lookup.
         */
        if (!(flag & O_CREAT)) {
-               error = path_lookup_open(dfd, pathname, lookup_flags(flag),
-                                        &nd, flag);
+               filp = get_empty_filp();
+
+               if (filp == NULL)
+                       return ERR_PTR(-ENFILE);
+               nd.intent.open.file = filp;
+               filp->f_flags = open_flag;
+               nd.intent.open.flags = flag;
+               nd.intent.open.create_mode = 0;
+               error = do_path_lookup(dfd, pathname,
+                                       lookup_flags(flag)|LOOKUP_OPEN, &nd);
+               if (IS_ERR(nd.intent.open.file)) {
+                       if (error == 0) {
+                               error = PTR_ERR(nd.intent.open.file);
+                               path_put(&nd.path);
+                       }
+               } else if (error)
+                       release_open_intent(&nd);
                if (error)
                        return ERR_PTR(error);
                goto ok;
@@ -1717,6 +1685,7 @@ struct file *do_filp_open(int dfd, const char *pathname,
        if (filp == NULL)
                goto exit_parent;
        nd.intent.open.file = filp;
+       filp->f_flags = open_flag;
        nd.intent.open.flags = flag;
        nd.intent.open.create_mode = mode;
        dir = nd.path.dentry;
@@ -1757,14 +1726,18 @@ do_last:
                        mnt_drop_write(nd.path.mnt);
                        goto exit;
                }
-               filp = nameidata_to_filp(&nd, open_flag);
-               if (IS_ERR(filp))
-                       ima_counts_put(&nd.path,
-                                      acc_mode & (MAY_READ | MAY_WRITE |
-                                                  MAY_EXEC));
+               filp = nameidata_to_filp(&nd);
                mnt_drop_write(nd.path.mnt);
                if (nd.root.mnt)
                        path_put(&nd.root);
+               if (!IS_ERR(filp)) {
+                       error = ima_path_check(&filp->f_path, filp->f_mode &
+                                      (MAY_READ | MAY_WRITE | MAY_EXEC));
+                       if (error) {
+                               fput(filp);
+                               filp = ERR_PTR(error);
+                       }
+               }
                return filp;
        }
 
@@ -1792,7 +1765,7 @@ do_last:
 
        path_to_nameidata(&path, &nd);
        error = -EISDIR;
-       if (path.dentry->d_inode && S_ISDIR(path.dentry->d_inode->i_mode))
+       if (S_ISDIR(path.dentry->d_inode->i_mode))
                goto exit;
 ok:
        /*
@@ -1805,28 +1778,45 @@ ok:
         * be avoided. Taking this mnt write here
         * ensures that (2) can not occur.
         */
-       will_write = open_will_write_to_fs(flag, nd.path.dentry->d_inode);
-       if (will_write) {
+       will_truncate = open_will_truncate(flag, nd.path.dentry->d_inode);
+       if (will_truncate) {
                error = mnt_want_write(nd.path.mnt);
                if (error)
                        goto exit;
        }
        error = may_open(&nd.path, acc_mode, flag);
        if (error) {
-               if (will_write)
+               if (will_truncate)
                        mnt_drop_write(nd.path.mnt);
                goto exit;
        }
-       filp = nameidata_to_filp(&nd, open_flag);
-       if (IS_ERR(filp))
-               ima_counts_put(&nd.path,
-                              acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC));
+       filp = nameidata_to_filp(&nd);
+       if (!IS_ERR(filp)) {
+               error = ima_path_check(&filp->f_path, filp->f_mode &
+                              (MAY_READ | MAY_WRITE | MAY_EXEC));
+               if (error) {
+                       fput(filp);
+                       filp = ERR_PTR(error);
+               }
+       }
+       if (!IS_ERR(filp)) {
+               if (acc_mode & MAY_WRITE)
+                       vfs_dq_init(nd.path.dentry->d_inode);
+
+               if (will_truncate) {
+                       error = handle_truncate(&nd.path);
+                       if (error) {
+                               fput(filp);
+                               filp = ERR_PTR(error);
+                       }
+               }
+       }
        /*
         * It is now safe to drop the mnt write
         * because the filp has had a write taken
         * on its behalf.
         */
-       if (will_write)
+       if (will_truncate)
                mnt_drop_write(nd.path.mnt);
        if (nd.root.mnt)
                path_put(&nd.root);
@@ -1863,7 +1853,18 @@ do_link:
        error = security_inode_follow_link(path.dentry, &nd);
        if (error)
                goto exit_dput;
+       save = nd.path;
+       path_get(&save);
        error = __do_follow_link(&path, &nd);
+       if (error == -ESTALE) {
+               /* nd.path had been dropped */
+               nd.path = save;
+               path_get(&nd.path);
+               nd.flags |= LOOKUP_REVAL;
+               error = __do_follow_link(&path, &nd);
+       }
+       path_put(&save);
+       path_put(&path);
        if (error) {
                /* Does someone understand code flow here? Or it is only
                 * me so stupid? Anathema to whoever designed this non-sense
index 2a77bc25d5afc81d9510c9f1825d842deb727b80..59e5673b45975f03fdd2ea0f24b4541ba9c2dfc2 100644 (file)
@@ -90,7 +90,7 @@ config ROOT_NFS
          If you want your system to mount its root file system via NFS,
          choose Y here.  This is common practice for managing systems
          without local permanent storage.  For details, read
-         <file:Documentation/filesystems/nfsroot.txt>.
+         <file:Documentation/filesystems/nfs/nfsroot.txt>.
 
          Most people say N here.
 
index 7e57b04e40141f5971dfabd63f848d07cc7ceeb2..865265bdca03acc9f1e106593304a6daf99ef0bd 100644 (file)
@@ -108,6 +108,10 @@ enum {
        NFS_OWNER_RECLAIM_NOGRACE
 };
 
+#define NFS_LOCK_NEW           0
+#define NFS_LOCK_RECLAIM       1
+#define NFS_LOCK_EXPIRED       2
+
 /*
  * struct nfs4_state maintains the client-side state for a given
  * (state_owner,inode) tuple (OPEN) or state_owner (LOCK).
@@ -282,6 +286,7 @@ extern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter);
 extern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task);
 extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid);
 extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid);
+extern void nfs_release_seqid(struct nfs_seqid *seqid);
 extern void nfs_free_seqid(struct nfs_seqid *seqid);
 
 extern const nfs4_stateid zero_stateid;
index 9f5f11ecfd93853ac3e18fe5b19a95f4b24d8645..198d51d17c135e1b41564636511ff0119e0a7219 100644 (file)
@@ -64,6 +64,7 @@
 
 struct nfs4_opendata;
 static int _nfs4_proc_open(struct nfs4_opendata *data);
+static int _nfs4_recover_proc_open(struct nfs4_opendata *data);
 static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *);
 static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *, struct nfs4_state *);
 static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr);
@@ -341,6 +342,27 @@ nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid)
                free_slotid, tbl->highest_used_slotid);
 }
 
+/*
+ * Signal state manager thread if session is drained
+ */
+static void nfs41_check_drain_session_complete(struct nfs4_session *ses)
+{
+       struct rpc_task *task;
+
+       if (!test_bit(NFS4CLNT_SESSION_DRAINING, &ses->clp->cl_state)) {
+               task = rpc_wake_up_next(&ses->fc_slot_table.slot_tbl_waitq);
+               if (task)
+                       rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED);
+               return;
+       }
+
+       if (ses->fc_slot_table.highest_used_slotid != -1)
+               return;
+
+       dprintk("%s COMPLETE: Session Drained\n", __func__);
+       complete(&ses->complete);
+}
+
 static void nfs41_sequence_free_slot(const struct nfs_client *clp,
                              struct nfs4_sequence_res *res)
 {
@@ -356,15 +378,7 @@ static void nfs41_sequence_free_slot(const struct nfs_client *clp,
 
        spin_lock(&tbl->slot_tbl_lock);
        nfs4_free_slot(tbl, res->sr_slotid);
-
-       /* Signal state manager thread if session is drained */
-       if (test_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) {
-               if (tbl->highest_used_slotid == -1) {
-                       dprintk("%s COMPLETE: Session Drained\n", __func__);
-                       complete(&clp->cl_session->complete);
-               }
-       } else
-               rpc_wake_up_next(&tbl->slot_tbl_waitq);
+       nfs41_check_drain_session_complete(clp->cl_session);
        spin_unlock(&tbl->slot_tbl_lock);
        res->sr_slotid = NFS4_MAX_SLOT_TABLE;
 }
@@ -421,7 +435,7 @@ out:
  * Note: must be called with under the slot_tbl_lock.
  */
 static u8
-nfs4_find_slot(struct nfs4_slot_table *tbl, struct rpc_task *task)
+nfs4_find_slot(struct nfs4_slot_table *tbl)
 {
        int slotid;
        u8 ret_id = NFS4_MAX_SLOT_TABLE;
@@ -463,7 +477,8 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
        tbl = &session->fc_slot_table;
 
        spin_lock(&tbl->slot_tbl_lock);
-       if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state)) {
+       if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state) &&
+           !rpc_task_has_priority(task, RPC_PRIORITY_PRIVILEGED)) {
                /*
                 * The state manager will wait until the slot table is empty.
                 * Schedule the reset thread
@@ -474,7 +489,15 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
                return -EAGAIN;
        }
 
-       slotid = nfs4_find_slot(tbl, task);
+       if (!rpc_queue_empty(&tbl->slot_tbl_waitq) &&
+           !rpc_task_has_priority(task, RPC_PRIORITY_PRIVILEGED)) {
+               rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
+               spin_unlock(&tbl->slot_tbl_lock);
+               dprintk("%s enforce FIFO order\n", __func__);
+               return -EAGAIN;
+       }
+
+       slotid = nfs4_find_slot(tbl);
        if (slotid == NFS4_MAX_SLOT_TABLE) {
                rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
                spin_unlock(&tbl->slot_tbl_lock);
@@ -483,6 +506,7 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
        }
        spin_unlock(&tbl->slot_tbl_lock);
 
+       rpc_task_set_priority(task, RPC_PRIORITY_NORMAL);
        slot = tbl->slots + slotid;
        args->sa_session = session;
        args->sa_slotid = slotid;
@@ -545,6 +569,12 @@ static void nfs41_call_sync_prepare(struct rpc_task *task, void *calldata)
        rpc_call_start(task);
 }
 
+static void nfs41_call_priv_sync_prepare(struct rpc_task *task, void *calldata)
+{
+       rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED);
+       nfs41_call_sync_prepare(task, calldata);
+}
+
 static void nfs41_call_sync_done(struct rpc_task *task, void *calldata)
 {
        struct nfs41_call_sync_data *data = calldata;
@@ -557,12 +587,18 @@ struct rpc_call_ops nfs41_call_sync_ops = {
        .rpc_call_done = nfs41_call_sync_done,
 };
 
+struct rpc_call_ops nfs41_call_priv_sync_ops = {
+       .rpc_call_prepare = nfs41_call_priv_sync_prepare,
+       .rpc_call_done = nfs41_call_sync_done,
+};
+
 static int nfs4_call_sync_sequence(struct nfs_client *clp,
                                   struct rpc_clnt *clnt,
                                   struct rpc_message *msg,
                                   struct nfs4_sequence_args *args,
                                   struct nfs4_sequence_res *res,
-                                  int cache_reply)
+                                  int cache_reply,
+                                  int privileged)
 {
        int ret;
        struct rpc_task *task;
@@ -580,6 +616,8 @@ static int nfs4_call_sync_sequence(struct nfs_client *clp,
        };
 
        res->sr_slotid = NFS4_MAX_SLOT_TABLE;
+       if (privileged)
+               task_setup.callback_ops = &nfs41_call_priv_sync_ops;
        task = rpc_run_task(&task_setup);
        if (IS_ERR(task))
                ret = PTR_ERR(task);
@@ -597,7 +635,7 @@ int _nfs4_call_sync_session(struct nfs_server *server,
                            int cache_reply)
 {
        return nfs4_call_sync_sequence(server->nfs_client, server->client,
-                                      msg, args, res, cache_reply);
+                                      msg, args, res, cache_reply, 0);
 }
 
 #endif /* CONFIG_NFS_V4_1 */
@@ -1035,7 +1073,7 @@ static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, fmode_t fmod
        memset(&opendata->o_res, 0, sizeof(opendata->o_res));
        memset(&opendata->c_res, 0, sizeof(opendata->c_res));
        nfs4_init_opendata_res(opendata);
-       ret = _nfs4_proc_open(opendata);
+       ret = _nfs4_recover_proc_open(opendata);
        if (ret != 0)
                return ret; 
        newstate = nfs4_opendata_to_nfs4_state(opendata);
@@ -1326,6 +1364,12 @@ out_no_action:
 
 }
 
+static void nfs4_recover_open_prepare(struct rpc_task *task, void *calldata)
+{
+       rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED);
+       nfs4_open_prepare(task, calldata);
+}
+
 static void nfs4_open_done(struct rpc_task *task, void *calldata)
 {
        struct nfs4_opendata *data = calldata;
@@ -1384,10 +1428,13 @@ static const struct rpc_call_ops nfs4_open_ops = {
        .rpc_release = nfs4_open_release,
 };
 
-/*
- * Note: On error, nfs4_proc_open will free the struct nfs4_opendata
- */
-static int _nfs4_proc_open(struct nfs4_opendata *data)
+static const struct rpc_call_ops nfs4_recover_open_ops = {
+       .rpc_call_prepare = nfs4_recover_open_prepare,
+       .rpc_call_done = nfs4_open_done,
+       .rpc_release = nfs4_open_release,
+};
+
+static int nfs4_run_open_task(struct nfs4_opendata *data, int isrecover)
 {
        struct inode *dir = data->dir->d_inode;
        struct nfs_server *server = NFS_SERVER(dir);
@@ -1414,21 +1461,57 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
        data->rpc_done = 0;
        data->rpc_status = 0;
        data->cancelled = 0;
+       if (isrecover)
+               task_setup_data.callback_ops = &nfs4_recover_open_ops;
        task = rpc_run_task(&task_setup_data);
-       if (IS_ERR(task))
-               return PTR_ERR(task);
-       status = nfs4_wait_for_completion_rpc_task(task);
-       if (status != 0) {
-               data->cancelled = 1;
-               smp_wmb();
-       } else
-               status = data->rpc_status;
-       rpc_put_task(task);
+        if (IS_ERR(task))
+                return PTR_ERR(task);
+        status = nfs4_wait_for_completion_rpc_task(task);
+        if (status != 0) {
+                data->cancelled = 1;
+                smp_wmb();
+        } else
+                status = data->rpc_status;
+        rpc_put_task(task);
+
+       return status;
+}
+
+static int _nfs4_recover_proc_open(struct nfs4_opendata *data)
+{
+       struct inode *dir = data->dir->d_inode;
+       struct nfs_openres *o_res = &data->o_res;
+        int status;
+
+       status = nfs4_run_open_task(data, 1);
        if (status != 0 || !data->rpc_done)
                return status;
 
-       if (o_res->fh.size == 0)
-               _nfs4_proc_lookup(dir, o_arg->name, &o_res->fh, o_res->f_attr);
+       nfs_refresh_inode(dir, o_res->dir_attr);
+
+       if (o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) {
+               status = _nfs4_proc_open_confirm(data);
+               if (status != 0)
+                       return status;
+       }
+
+       return status;
+}
+
+/*
+ * Note: On error, nfs4_proc_open will free the struct nfs4_opendata
+ */
+static int _nfs4_proc_open(struct nfs4_opendata *data)
+{
+       struct inode *dir = data->dir->d_inode;
+       struct nfs_server *server = NFS_SERVER(dir);
+       struct nfs_openargs *o_arg = &data->o_arg;
+       struct nfs_openres *o_res = &data->o_res;
+       int status;
+
+       status = nfs4_run_open_task(data, 0);
+       if (status != 0 || !data->rpc_done)
+               return status;
 
        if (o_arg->open_flags & O_CREAT) {
                update_changeattr(dir, &o_res->cinfo);
@@ -1752,11 +1835,10 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
                        if (calldata->arg.fmode == 0)
                                break;
                default:
-                       if (nfs4_async_handle_error(task, server, state) == -EAGAIN) {
-                               nfs_restart_rpc(task, server->nfs_client);
-                               return;
-                       }
+                       if (nfs4_async_handle_error(task, server, state) == -EAGAIN)
+                               rpc_restart_call_prepare(task);
        }
+       nfs_release_seqid(calldata->arg.seqid);
        nfs_refresh_inode(calldata->inode, calldata->res.fattr);
 }
 
@@ -1848,8 +1930,6 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
        calldata->state = state;
        calldata->arg.fh = NFS_FH(state->inode);
        calldata->arg.stateid = &state->open_stateid;
-       if (nfs4_has_session(server->nfs_client))
-               memset(calldata->arg.stateid->data, 0, 4);    /* clear seqid */
        /* Serialization for the sequence id */
        calldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid);
        if (calldata->arg.seqid == NULL)
@@ -3941,6 +4021,12 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
        dprintk("%s: done!, ret = %d\n", __func__, data->rpc_status);
 }
 
+static void nfs4_recover_lock_prepare(struct rpc_task *task, void *calldata)
+{
+       rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED);
+       nfs4_lock_prepare(task, calldata);
+}
+
 static void nfs4_lock_done(struct rpc_task *task, void *calldata)
 {
        struct nfs4_lockdata *data = calldata;
@@ -3996,7 +4082,13 @@ static const struct rpc_call_ops nfs4_lock_ops = {
        .rpc_release = nfs4_lock_release,
 };
 
-static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int reclaim)
+static const struct rpc_call_ops nfs4_recover_lock_ops = {
+       .rpc_call_prepare = nfs4_recover_lock_prepare,
+       .rpc_call_done = nfs4_lock_done,
+       .rpc_release = nfs4_lock_release,
+};
+
+static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int recovery_type)
 {
        struct nfs4_lockdata *data;
        struct rpc_task *task;
@@ -4020,8 +4112,11 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
                return -ENOMEM;
        if (IS_SETLKW(cmd))
                data->arg.block = 1;
-       if (reclaim != 0)
-               data->arg.reclaim = 1;
+       if (recovery_type > NFS_LOCK_NEW) {
+               if (recovery_type == NFS_LOCK_RECLAIM)
+                       data->arg.reclaim = NFS_LOCK_RECLAIM;
+               task_setup_data.callback_ops = &nfs4_recover_lock_ops;
+       }
        msg.rpc_argp = &data->arg,
        msg.rpc_resp = &data->res,
        task_setup_data.callback_data = data;
@@ -4048,7 +4143,7 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request
                /* Cache the lock if possible... */
                if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0)
                        return 0;
-               err = _nfs4_do_setlk(state, F_SETLK, request, 1);
+               err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_RECLAIM);
                if (err != -NFS4ERR_DELAY)
                        break;
                nfs4_handle_exception(server, err, &exception);
@@ -4068,7 +4163,7 @@ static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request
        do {
                if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0)
                        return 0;
-               err = _nfs4_do_setlk(state, F_SETLK, request, 0);
+               err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_EXPIRED);
                switch (err) {
                default:
                        goto out;
@@ -4104,7 +4199,7 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
                status = do_vfs_lock(request->fl_file, request);
                goto out_unlock;
        }
-       status = _nfs4_do_setlk(state, cmd, request, 0);
+       status = _nfs4_do_setlk(state, cmd, request, NFS_LOCK_NEW);
        if (status != 0)
                goto out_unlock;
        /* Note: we always want to sleep here! */
@@ -4187,7 +4282,7 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl)
        if (err != 0)
                goto out;
        do {
-               err = _nfs4_do_setlk(state, F_SETLK, fl, 0);
+               err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW);
                switch (err) {
                        default:
                                printk(KERN_ERR "%s: unhandled error %d.\n",
@@ -4395,11 +4490,12 @@ static void nfs4_get_lease_time_prepare(struct rpc_task *task,
                        (struct nfs4_get_lease_time_data *)calldata;
 
        dprintk("--> %s\n", __func__);
+       rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED);
        /* just setup sequence, do not trigger session recovery
           since we're invoked within one */
        ret = nfs41_setup_sequence(data->clp->cl_session,
-                                       &data->args->la_seq_args,
-                                       &data->res->lr_seq_res, 0, task);
+                                  &data->args->la_seq_args,
+                                  &data->res->lr_seq_res, 0, task);
 
        BUG_ON(ret == -EAGAIN);
        rpc_call_start(task);
@@ -4619,7 +4715,7 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
        tbl = &session->fc_slot_table;
        tbl->highest_used_slotid = -1;
        spin_lock_init(&tbl->slot_tbl_lock);
-       rpc_init_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table");
+       rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table");
 
        tbl = &session->bc_slot_table;
        tbl->highest_used_slotid = -1;
@@ -4838,14 +4934,22 @@ int nfs4_init_session(struct nfs_server *server)
 {
        struct nfs_client *clp = server->nfs_client;
        struct nfs4_session *session;
+       unsigned int rsize, wsize;
        int ret;
 
        if (!nfs4_has_session(clp))
                return 0;
 
+       rsize = server->rsize;
+       if (rsize == 0)
+               rsize = NFS_MAX_FILE_IO_SIZE;
+       wsize = server->wsize;
+       if (wsize == 0)
+               wsize = NFS_MAX_FILE_IO_SIZE;
+
        session = clp->cl_session;
-       session->fc_attrs.max_rqst_sz = server->wsize + nfs41_maxwrite_overhead;
-       session->fc_attrs.max_resp_sz = server->rsize + nfs41_maxread_overhead;
+       session->fc_attrs.max_rqst_sz = wsize + nfs41_maxwrite_overhead;
+       session->fc_attrs.max_resp_sz = rsize + nfs41_maxread_overhead;
 
        ret = nfs4_recover_expired_lease(server);
        if (!ret)
@@ -4871,7 +4975,7 @@ static int nfs4_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred)
        args.sa_cache_this = 0;
 
        return nfs4_call_sync_sequence(clp, clp->cl_rpcclient, &msg, &args,
-                                      &res, 0);
+                                      &res, args.sa_cache_this, 1);
 }
 
 void nfs41_sequence_call_done(struct rpc_task *task, void *data)
@@ -4953,6 +5057,7 @@ static void nfs4_reclaim_complete_prepare(struct rpc_task *task, void *data)
 {
        struct nfs4_reclaim_complete_data *calldata = data;
 
+       rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED);
        if (nfs4_setup_sequence(calldata->clp, &calldata->arg.seq_args,
                                &calldata->res.seq_res, 0, task))
                return;
index e76427e6346fc136a413b324a83d6c9994a14830..6d263ed79e92d56f8e65deca2ff12d24226f7926 100644 (file)
@@ -135,16 +135,30 @@ static int nfs41_setup_state_renewal(struct nfs_client *clp)
        return status;
 }
 
-static void nfs41_end_drain_session(struct nfs_client *clp,
-               struct nfs4_session *ses)
+static void nfs4_end_drain_session(struct nfs_client *clp)
 {
-       if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state))
-               rpc_wake_up(&ses->fc_slot_table.slot_tbl_waitq);
+       struct nfs4_session *ses = clp->cl_session;
+       int max_slots;
+
+       if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) {
+               spin_lock(&ses->fc_slot_table.slot_tbl_lock);
+               max_slots = ses->fc_slot_table.max_slots;
+               while (max_slots--) {
+                       struct rpc_task *task;
+
+                       task = rpc_wake_up_next(&ses->fc_slot_table.
+                                               slot_tbl_waitq);
+                       if (!task)
+                               break;
+                       rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED);
+               }
+               spin_unlock(&ses->fc_slot_table.slot_tbl_lock);
+       }
 }
 
-static int nfs41_begin_drain_session(struct nfs_client *clp,
-               struct nfs4_session *ses)
+static int nfs4_begin_drain_session(struct nfs_client *clp)
 {
+       struct nfs4_session *ses = clp->cl_session;
        struct nfs4_slot_table *tbl = &ses->fc_slot_table;
 
        spin_lock(&tbl->slot_tbl_lock);
@@ -162,16 +176,13 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
 {
        int status;
 
-       status = nfs41_begin_drain_session(clp, clp->cl_session);
-       if (status != 0)
-               goto out;
+       nfs4_begin_drain_session(clp);
        status = nfs4_proc_exchange_id(clp, cred);
        if (status != 0)
                goto out;
        status = nfs4_proc_create_session(clp);
        if (status != 0)
                goto out;
-       nfs41_end_drain_session(clp, clp->cl_session);
        nfs41_setup_state_renewal(clp);
        nfs_mark_client_ready(clp, NFS_CS_READY);
 out:
@@ -755,16 +766,21 @@ struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter)
        return new;
 }
 
-void nfs_free_seqid(struct nfs_seqid *seqid)
+void nfs_release_seqid(struct nfs_seqid *seqid)
 {
        if (!list_empty(&seqid->list)) {
                struct rpc_sequence *sequence = seqid->sequence->sequence;
 
                spin_lock(&sequence->lock);
-               list_del(&seqid->list);
+               list_del_init(&seqid->list);
                spin_unlock(&sequence->lock);
                rpc_wake_up(&sequence->wait);
        }
+}
+
+void nfs_free_seqid(struct nfs_seqid *seqid)
+{
+       nfs_release_seqid(seqid);
        kfree(seqid);
 }
 
@@ -1257,13 +1273,9 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
 
 static int nfs4_reset_session(struct nfs_client *clp)
 {
-       struct nfs4_session *ses = clp->cl_session;
        int status;
 
-       status = nfs41_begin_drain_session(clp, ses);
-       if (status != 0)
-               return status;
-
+       nfs4_begin_drain_session(clp);
        status = nfs4_proc_destroy_session(clp->cl_session);
        if (status && status != -NFS4ERR_BADSESSION &&
            status != -NFS4ERR_DEADSESSION) {
@@ -1279,19 +1291,17 @@ static int nfs4_reset_session(struct nfs_client *clp)
 out:
        /*
         * Let the state manager reestablish state
-        * without waking other tasks yet.
         */
-       if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) {
-               /* Wake up the next rpc task */
-               nfs41_end_drain_session(clp, ses);
-               if (status == 0)
-                       nfs41_setup_state_renewal(clp);
-       }
+       if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) &&
+           status == 0)
+               nfs41_setup_state_renewal(clp);
+
        return status;
 }
 
 #else /* CONFIG_NFS_V4_1 */
 static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
+static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; }
 #endif /* CONFIG_NFS_V4_1 */
 
 /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors
@@ -1382,6 +1392,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
                                goto out_error;
                }
 
+               nfs4_end_drain_session(clp);
                if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) {
                        nfs_client_return_marked_delegations(clp);
                        continue;
@@ -1398,6 +1409,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
 out_error:
        printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s"
                        " with error %d\n", clp->cl_hostname, -status);
+       nfs4_end_drain_session(clp);
        nfs4_clear_state_manager_bit(clp);
 }
 
index 8f9a20556f798931ee906c4e3a08660e55778f60..d3854d94b7cf367cad8a04b665f0c18271355368 100644 (file)
@@ -7,8 +7,6 @@
 #include <linux/types.h>
 #include <linux/file.h>
 #include <linux/fs.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
 #include <linux/nfsd/syscall.h>
 #include <linux/cred.h>
 #include <linux/sched.h>
index 36fcabbf5186452023707c360fe16e3f168200a2..79717a40daba2e57cb8460f885dc09b8db63ccc8 100644 (file)
@@ -1,15 +1,7 @@
-/*
- * linux/fs/nfsd/auth.c
- *
- * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
- */
+/* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
 
-#include <linux/types.h>
 #include <linux/sched.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/sunrpc/svcauth.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/export.h>
+#include "nfsd.h"
 #include "auth.h"
 
 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
similarity index 95%
rename from include/linux/nfsd/cache.h
rename to fs/nfsd/cache.h
index 3a3f58934f5ea2d59fa21a468b60a59bb2aa2f2f..d892be61016c3f0331f6071e6c95ab6c4695c23f 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * include/linux/nfsd/cache.h
- *
  * Request reply cache. This was heavily inspired by the
  * implementation in 4.3BSD/4.4BSD.
  *
@@ -10,8 +8,7 @@
 #ifndef NFSCACHE_H
 #define NFSCACHE_H
 
-#include <linux/in.h>
-#include <linux/uio.h>
+#include <linux/sunrpc/svc.h>
 
 /*
  * Representation of a reply cache entry.
index c1c9e035d4a4777e483872ed82ae4b68056c49b1..c487810a2366feed1d7018085296ccf371ab0947 100644 (file)
@@ -1,7 +1,5 @@
 #define MSNFS  /* HACK HACK */
 /*
- * linux/fs/nfsd/export.c
- *
  * NFS exporting and validation.
  *
  * We maintain a list of clients, each of which has a list of
  * Copyright (C) 1995, 1996 Olaf Kirch, <okir@monad.swb.de>
  */
 
-#include <linux/unistd.h>
-#include <linux/slab.h>
-#include <linux/stat.h>
-#include <linux/in.h>
-#include <linux/seq_file.h>
-#include <linux/syscalls.h>
-#include <linux/rwsem.h>
-#include <linux/dcache.h>
 #include <linux/namei.h>
-#include <linux/mount.h>
-#include <linux/hash.h>
 #include <linux/module.h>
 #include <linux/exportfs.h>
 
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/nfsfh.h>
 #include <linux/nfsd/syscall.h>
-#include <linux/lockd/bind.h>
-#include <linux/sunrpc/msg_prot.h>
-#include <linux/sunrpc/gss_api.h>
 #include <net/ipv6.h>
 
+#include "nfsd.h"
+#include "nfsfh.h"
+
 #define NFSDDBG_FACILITY       NFSDDBG_EXPORT
 
 typedef struct auth_domain     svc_client;
@@ -369,16 +354,25 @@ static struct svc_export *svc_export_update(struct svc_export *new,
                                            struct svc_export *old);
 static struct svc_export *svc_export_lookup(struct svc_export *);
 
-static int check_export(struct inode *inode, int flags, unsigned char *uuid)
+static int check_export(struct inode *inode, int *flags, unsigned char *uuid)
 {
 
-       /* We currently export only dirs and regular files.
-        * This is what umountd does.
+       /*
+        * We currently export only dirs, regular files, and (for v4
+        * pseudoroot) symlinks.
         */
        if (!S_ISDIR(inode->i_mode) &&
+           !S_ISLNK(inode->i_mode) &&
            !S_ISREG(inode->i_mode))
                return -ENOTDIR;
 
+       /*
+        * Mountd should never pass down a writeable V4ROOT export, but,
+        * just to make sure:
+        */
+       if (*flags & NFSEXP_V4ROOT)
+               *flags |= NFSEXP_READONLY;
+
        /* There are two requirements on a filesystem to be exportable.
         * 1:  We must be able to identify the filesystem from a number.
         *       either a device number (so FS_REQUIRES_DEV needed)
@@ -387,7 +381,7 @@ static int check_export(struct inode *inode, int flags, unsigned char *uuid)
         *       This means that s_export_op must be set.
         */
        if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) &&
-           !(flags & NFSEXP_FSID) &&
+           !(*flags & NFSEXP_FSID) &&
            uuid == NULL) {
                dprintk("exp_export: export of non-dev fs without fsid\n");
                return -EINVAL;
@@ -602,7 +596,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
                                goto out4;
                }
 
-               err = check_export(exp.ex_path.dentry->d_inode, exp.ex_flags,
+               err = check_export(exp.ex_path.dentry->d_inode, &exp.ex_flags,
                                   exp.ex_uuid);
                if (err)
                        goto out4;
@@ -1041,7 +1035,7 @@ exp_export(struct nfsctl_export *nxp)
                goto finish;
        }
 
-       err = check_export(path.dentry->d_inode, nxp->ex_flags, NULL);
+       err = check_export(path.dentry->d_inode, &nxp->ex_flags, NULL);
        if (err) goto finish;
 
        err = -ENOMEM;
@@ -1320,6 +1314,23 @@ rqst_exp_parent(struct svc_rqst *rqstp, struct path *path)
        return exp;
 }
 
+static struct svc_export *find_fsidzero_export(struct svc_rqst *rqstp)
+{
+       struct svc_export *exp;
+       u32 fsidv[2];
+
+       mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);
+
+       exp = rqst_exp_find(rqstp, FSID_NUM, fsidv);
+       /*
+        * We shouldn't have accepting an nfsv4 request at all if we
+        * don't have a pseudoexport!:
+        */
+       if (IS_ERR(exp) && PTR_ERR(exp) == -ENOENT)
+               exp = ERR_PTR(-ESERVERFAULT);
+       return exp;
+}
+
 /*
  * Called when we need the filehandle for the root of the pseudofs,
  * for a given NFSv4 client.   The root is defined to be the
@@ -1330,11 +1341,8 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
 {
        struct svc_export *exp;
        __be32 rv;
-       u32 fsidv[2];
 
-       mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);
-
-       exp = rqst_exp_find(rqstp, FSID_NUM, fsidv);
+       exp = find_fsidzero_export(rqstp);
        if (IS_ERR(exp))
                return nfserrno(PTR_ERR(exp));
        rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL);
@@ -1425,6 +1433,7 @@ static struct flags {
        { NFSEXP_CROSSMOUNT, {"crossmnt", ""}},
        { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}},
        { NFSEXP_NOAUTHNLM, {"insecure_locks", ""}},
+       { NFSEXP_V4ROOT, {"v4root", ""}},
 #ifdef MSNFS
        { NFSEXP_MSNFS, {"msnfs", ""}},
 #endif
index b2786a5f9afefaaea3573303339cd7154ad54bd7..0c6d8167013749dce9028af641315dac7c3e4fa2 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/fs/nfsd/lockd.c
- *
  * This file contains all the stubs needed when communicating with lockd.
  * This level of indirection is necessary so we can run nfsd+lockd without
  * requiring the nfs client to be compiled in/loaded, and vice versa.
@@ -8,14 +6,10 @@
  * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
  */
 
-#include <linux/types.h>
-#include <linux/fs.h>
 #include <linux/file.h>
-#include <linux/mount.h>
-#include <linux/sunrpc/clnt.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
 #include <linux/lockd/bind.h>
+#include "nfsd.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_LOCKD
 
index 4e3219e84116a17a8a89dbc11c8d1075f14f2c38..f20589d2ae27be2aab0379b7d0ba1e2674490182 100644 (file)
@@ -1,19 +1,15 @@
 /*
- * linux/fs/nfsd/nfs2acl.c
- *
  * Process version 2 NFSACL requests.
  *
  * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de>
  */
 
-#include <linux/sunrpc/svc.h>
-#include <linux/nfs.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfsd/xdr.h>
-#include <linux/nfsd/xdr3.h>
-#include <linux/posix_acl.h>
+#include "nfsd.h"
+/* FIXME: nfsacl.h is a broken header */
 #include <linux/nfsacl.h>
+#include "cache.h"
+#include "xdr3.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_PROC
 #define RETURN_STATUS(st)      { resp->status = (st); return (st); }
@@ -217,6 +213,16 @@ static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p,
  * XDR encode functions
  */
 
+/*
+ * There must be an encoding function for void results so svc_process
+ * will work properly.
+ */
+int
+nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy)
+{
+       return xdr_ressize_check(rqstp, p);
+}
+
 /* GETACL */
 static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
                struct nfsd3_getaclres *resp)
@@ -308,7 +314,6 @@ static int nfsaclsvc_release_access(struct svc_rqst *rqstp, __be32 *p,
 }
 
 #define nfsaclsvc_decode_voidargs      NULL
-#define nfsaclsvc_encode_voidres       NULL
 #define nfsaclsvc_release_void         NULL
 #define nfsd3_fhandleargs      nfsd_fhandle
 #define nfsd3_attrstatres      nfsd_attrstat
@@ -346,5 +351,5 @@ struct svc_version  nfsd_acl_version2 = {
                .vs_proc        = nfsd_acl_procedures2,
                .vs_dispatch    = nfsd_dispatch,
                .vs_xdrsize     = NFS3_SVC_XDRSIZE,
-               .vs_hidden      = 1,
+               .vs_hidden      = 0,
 };
index 9981dbb377a3c9baa560ee2f11ca6b0cf2ba2956..e0c4846bad922be3307add94510a9b96330f691b 100644 (file)
@@ -1,18 +1,15 @@
 /*
- * linux/fs/nfsd/nfs3acl.c
- *
  * Process version 3 NFSACL requests.
  *
  * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de>
  */
 
-#include <linux/sunrpc/svc.h>
-#include <linux/nfs3.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfsd/xdr3.h>
-#include <linux/posix_acl.h>
+#include "nfsd.h"
+/* FIXME: nfsacl.h is a broken header */
 #include <linux/nfsacl.h>
+#include "cache.h"
+#include "xdr3.h"
+#include "vfs.h"
 
 #define RETURN_STATUS(st)      { resp->status = (st); return (st); }
 
@@ -264,6 +261,6 @@ struct svc_version  nfsd_acl_version3 = {
                .vs_proc        = nfsd_acl_procedures3,
                .vs_dispatch    = nfsd_dispatch,
                .vs_xdrsize     = NFS3_SVC_XDRSIZE,
-               .vs_hidden      = 1,
+               .vs_hidden      = 0,
 };
 
index a713c418a92236651a7d6a1e3c7dc3353dbd7a36..3d68f45a37b931027ef1e5e729305a4f7645fcf5 100644 (file)
@@ -1,30 +1,16 @@
 /*
- * linux/fs/nfsd/nfs3proc.c
- *
  * Process version 3 NFS requests.
  *
  * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include <linux/linkage.h>
-#include <linux/time.h>
-#include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/ext2_fs.h>
-#include <linux/stat.h>
-#include <linux/fcntl.h>
-#include <linux/net.h>
-#include <linux/in.h>
-#include <linux/unistd.h>
-#include <linux/slab.h>
-#include <linux/major.h>
 #include <linux/magic.h>
 
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfsd/xdr3.h>
-#include <linux/nfs3.h>
+#include "cache.h"
+#include "xdr3.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_PROC
 
index d0a2ce1b43248a6eacbff2b4804314c57b898cbc..2a533a0af2a98ed91afb84e71669d328cb67a866 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/fs/nfsd/nfs3xdr.c
- *
  * XDR support for nfsd/protocol version 3.
  *
  * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
@@ -8,19 +6,8 @@
  * 2003-08-09 Jamie Lokier: Use htonl() for nanoseconds, not htons()!
  */
 
-#include <linux/types.h>
-#include <linux/time.h>
-#include <linux/nfs3.h>
-#include <linux/list.h>
-#include <linux/spinlock.h>
-#include <linux/dcache.h>
 #include <linux/namei.h>
-#include <linux/mm.h>
-#include <linux/vfs.h>
-#include <linux/sunrpc/xdr.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/xdr3.h>
+#include "xdr3.h"
 #include "auth.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
index 725d02f210e272bc3c99306c1e2400f201095fb5..88150685df349e6abbc44d57d75c1d65fcc9649f 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  fs/nfs4acl/acl.c
- *
  *  Common NFSv4 ACL handling code.
  *
  *  Copyright (c) 2002, 2003 The Regents of the University of Michigan.
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-#include <linux/types.h>
-#include <linux/fs.h>
-#include <linux/module.h>
 #include <linux/nfs_fs.h>
-#include <linux/posix_acl.h>
-#include <linux/nfs4.h>
 #include <linux/nfs4_acl.h>
 
 
@@ -389,7 +379,7 @@ sort_pacl(struct posix_acl *pacl)
        sort_pacl_range(pacl, 1, i-1);
 
        BUG_ON(pacl->a_entries[i].e_tag != ACL_GROUP_OBJ);
-       j = i++;
+       j = ++i;
        while (pacl->a_entries[j].e_tag == ACL_GROUP)
                j++;
        sort_pacl_range(pacl, i, j-1);
index 24e8d78f8ddeb8a547827e259a7b60170dce3ee1..c6eed2a3b0935f4de0363339878e097094f45024 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  linux/fs/nfsd/nfs4callback.c
- *
  *  Copyright (c) 2001 The Regents of the University of Michigan.
  *  All rights reserved.
  *
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <linux/module.h>
-#include <linux/list.h>
-#include <linux/inet.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/kthread.h>
-#include <linux/sunrpc/xdr.h>
-#include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/clnt.h>
-#include <linux/sunrpc/svcsock.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/state.h>
-#include <linux/sunrpc/sched.h>
-#include <linux/nfs4.h>
-#include <linux/sunrpc/xprtsock.h>
+#include "nfsd.h"
+#include "state.h"
 
 #define NFSDDBG_FACILITY                NFSDDBG_PROC
 
index ba2c199592fd450d41c9778f70cf4fbcb3d46f16..6e2983b27f3ca4e6db8529da74adfeaffe09f4a4 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  fs/nfsd/nfs4idmap.c
- *
  *  Mapping of UID/GIDs to name and vice versa.
  *
  *  Copyright (c) 2002, 2003 The Regents of the University of
  */
 
 #include <linux/module.h>
-#include <linux/init.h>
-
-#include <linux/mm.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/sunrpc/clnt.h>
-#include <linux/nfs.h>
-#include <linux/nfs4.h>
-#include <linux/nfs_fs.h>
-#include <linux/nfs_page.h>
-#include <linux/sunrpc/cache.h>
 #include <linux/nfsd_idmap.h>
-#include <linux/list.h>
-#include <linux/time.h>
 #include <linux/seq_file.h>
-#include <linux/sunrpc/svcauth.h>
+#include <linux/sched.h>
 
 /*
  * Cache entry
index bebc0c2e1b0a9022dbd1dcf4d9204de8f9ef0434..37514c46984611467c95f89b82c2aa097779311b 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  fs/nfsd/nfs4proc.c
- *
  *  Server-side procedures for NFSv4.
  *
  *  Copyright (c) 2002 The Regents of the University of Michigan.
  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
-#include <linux/param.h>
-#include <linux/major.h>
-#include <linux/slab.h>
 #include <linux/file.h>
 
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfs4.h>
-#include <linux/nfsd/state.h>
-#include <linux/nfsd/xdr4.h>
-#include <linux/nfs4_acl.h>
-#include <linux/sunrpc/gss_api.h>
+#include "cache.h"
+#include "xdr4.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_PROC
 
@@ -170,7 +159,7 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
                accmode |= NFSD_MAY_READ;
        if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE)
                accmode |= (NFSD_MAY_WRITE | NFSD_MAY_TRUNC);
-       if (open->op_share_deny & NFS4_SHARE_DENY_WRITE)
+       if (open->op_share_deny & NFS4_SHARE_DENY_READ)
                accmode |= NFSD_MAY_WRITE;
 
        status = fh_verify(rqstp, current_fh, S_IFREG, accmode);
index b5348405046b5e2831cdcc9cd32a7f0c3d2e6f8f..5a754f7b71ed34a84717903f018523e2008f31f5 100644 (file)
@@ -1,6 +1,4 @@
 /*
-*  linux/fs/nfsd/nfs4recover.c
-*
 *  Copyright (c) 2004 The Regents of the University of Michigan.
 *  All rights reserved.
 *
 *
 */
 
-#include <linux/err.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfs4.h>
-#include <linux/nfsd/state.h>
-#include <linux/nfsd/xdr4.h>
-#include <linux/param.h>
 #include <linux/file.h>
 #include <linux/namei.h>
-#include <asm/uaccess.h>
-#include <linux/scatterlist.h>
 #include <linux/crypto.h>
 #include <linux/sched.h>
-#include <linux/mount.h>
+
+#include "nfsd.h"
+#include "state.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY                NFSDDBG_PROC
 
index 2153f9bdbebdcb3cb094a76c73b9948815b30e2d..f19ed866c95fd18ef5da370b9cd09387c6d71c8a 100644 (file)
@@ -1,6 +1,4 @@
 /*
-*  linux/fs/nfsd/nfs4state.c
-*
 *  Copyright (c) 2001 The Regents of the University of Michigan.
 *  All rights reserved.
 *
 *
 */
 
-#include <linux/param.h>
-#include <linux/major.h>
-#include <linux/slab.h>
-
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
 #include <linux/file.h>
-#include <linux/mount.h>
-#include <linux/workqueue.h>
 #include <linux/smp_lock.h>
-#include <linux/kthread.h>
-#include <linux/nfs4.h>
-#include <linux/nfsd/state.h>
-#include <linux/nfsd/xdr4.h>
 #include <linux/namei.h>
 #include <linux/swap.h>
-#include <linux/mutex.h>
-#include <linux/lockd/bind.h>
-#include <linux/module.h>
 #include <linux/sunrpc/svcauth_gss.h>
 #include <linux/sunrpc/clnt.h>
+#include "xdr4.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY                NFSDDBG_PROC
 
@@ -477,13 +461,14 @@ static int set_forechannel_drc_size(struct nfsd4_channel_attrs *fchan)
 
 /*
  * fchan holds the client values on input, and the server values on output
+ * sv_max_mesg is the maximum payload plus one page for overhead.
  */
 static int init_forechannel_attrs(struct svc_rqst *rqstp,
                                  struct nfsd4_channel_attrs *session_fchan,
                                  struct nfsd4_channel_attrs *fchan)
 {
        int status = 0;
-       __u32   maxcount = svc_max_payload(rqstp);
+       __u32   maxcount = nfsd_serv->sv_max_mesg;
 
        /* headerpadsz set to zero in encode routine */
 
@@ -523,6 +508,15 @@ free_session_slots(struct nfsd4_session *ses)
                kfree(ses->se_slots[i]);
 }
 
+/*
+ * We don't actually need to cache the rpc and session headers, so we
+ * can allocate a little less for each slot:
+ */
+static inline int slot_bytes(struct nfsd4_channel_attrs *ca)
+{
+       return ca->maxresp_cached - NFSD_MIN_HDR_SEQ_SZ;
+}
+
 static int
 alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp,
                   struct nfsd4_create_session *cses)
@@ -554,7 +548,7 @@ alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp,
        memcpy(new, &tmp, sizeof(*new));
 
        /* allocate each struct nfsd4_slot and data cache in one piece */
-       cachesize = new->se_fchannel.maxresp_cached - NFSD_MIN_HDR_SEQ_SZ;
+       cachesize = slot_bytes(&new->se_fchannel);
        for (i = 0; i < new->se_fchannel.maxreqs; i++) {
                sp = kzalloc(sizeof(*sp) + cachesize, GFP_KERNEL);
                if (!sp)
@@ -628,10 +622,12 @@ void
 free_session(struct kref *kref)
 {
        struct nfsd4_session *ses;
+       int mem;
 
        ses = container_of(kref, struct nfsd4_session, se_ref);
        spin_lock(&nfsd_drc_lock);
-       nfsd_drc_mem_used -= ses->se_fchannel.maxreqs * NFSD_SLOT_CACHE_SIZE;
+       mem = ses->se_fchannel.maxreqs * slot_bytes(&ses->se_fchannel);
+       nfsd_drc_mem_used -= mem;
        spin_unlock(&nfsd_drc_lock);
        free_session_slots(ses);
        kfree(ses);
@@ -2404,11 +2400,8 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_sta
 
        memcpy(&open->op_delegate_stateid, &dp->dl_stateid, sizeof(dp->dl_stateid));
 
-       dprintk("NFSD: delegation stateid=(%08x/%08x/%08x/%08x)\n\n",
-                    dp->dl_stateid.si_boot,
-                    dp->dl_stateid.si_stateownerid,
-                    dp->dl_stateid.si_fileid,
-                    dp->dl_stateid.si_generation);
+       dprintk("NFSD: delegation stateid=" STATEID_FMT "\n",
+               STATEID_VAL(&dp->dl_stateid));
 out:
        if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS
                        && flag == NFS4_OPEN_DELEGATE_NONE
@@ -2498,9 +2491,8 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
 
        status = nfs_ok;
 
-       dprintk("nfs4_process_open2: stateid=(%08x/%08x/%08x/%08x)\n",
-                   stp->st_stateid.si_boot, stp->st_stateid.si_stateownerid,
-                   stp->st_stateid.si_fileid, stp->st_stateid.si_generation);
+       dprintk("%s: stateid=" STATEID_FMT "\n", __func__,
+               STATEID_VAL(&stp->st_stateid));
 out:
        if (fp)
                put_nfs4_file(fp);
@@ -2666,9 +2658,8 @@ STALE_STATEID(stateid_t *stateid)
 {
        if (time_after((unsigned long)boot_time,
                        (unsigned long)stateid->si_boot)) {
-               dprintk("NFSD: stale stateid (%08x/%08x/%08x/%08x)!\n",
-                       stateid->si_boot, stateid->si_stateownerid,
-                       stateid->si_fileid, stateid->si_generation);
+               dprintk("NFSD: stale stateid " STATEID_FMT "!\n",
+                       STATEID_VAL(stateid));
                return 1;
        }
        return 0;
@@ -2680,9 +2671,8 @@ EXPIRED_STATEID(stateid_t *stateid)
        if (time_before((unsigned long)boot_time,
                        ((unsigned long)stateid->si_boot)) &&
            time_before((unsigned long)(stateid->si_boot + lease_time), get_seconds())) {
-               dprintk("NFSD: expired stateid (%08x/%08x/%08x/%08x)!\n",
-                       stateid->si_boot, stateid->si_stateownerid,
-                       stateid->si_fileid, stateid->si_generation);
+               dprintk("NFSD: expired stateid " STATEID_FMT "!\n",
+                       STATEID_VAL(stateid));
                return 1;
        }
        return 0;
@@ -2696,9 +2686,8 @@ stateid_error_map(stateid_t *stateid)
        if (EXPIRED_STATEID(stateid))
                return nfserr_expired;
 
-       dprintk("NFSD: bad stateid (%08x/%08x/%08x/%08x)!\n",
-               stateid->si_boot, stateid->si_stateownerid,
-               stateid->si_fileid, stateid->si_generation);
+       dprintk("NFSD: bad stateid " STATEID_FMT "!\n",
+               STATEID_VAL(stateid));
        return nfserr_bad_stateid;
 }
 
@@ -2884,10 +2873,8 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
        struct svc_fh *current_fh = &cstate->current_fh;
        __be32 status;
 
-       dprintk("NFSD: preprocess_seqid_op: seqid=%d " 
-                       "stateid = (%08x/%08x/%08x/%08x)\n", seqid,
-               stateid->si_boot, stateid->si_stateownerid, stateid->si_fileid,
-               stateid->si_generation);
+       dprintk("NFSD: %s: seqid=%d stateid = " STATEID_FMT "\n", __func__,
+               seqid, STATEID_VAL(stateid));
 
        *stpp = NULL;
        *sopp = NULL;
@@ -3019,12 +3006,8 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        sop->so_confirmed = 1;
        update_stateid(&stp->st_stateid);
        memcpy(&oc->oc_resp_stateid, &stp->st_stateid, sizeof(stateid_t));
-       dprintk("NFSD: nfsd4_open_confirm: success, seqid=%d " 
-               "stateid=(%08x/%08x/%08x/%08x)\n", oc->oc_seqid,
-                        stp->st_stateid.si_boot,
-                        stp->st_stateid.si_stateownerid,
-                        stp->st_stateid.si_fileid,
-                        stp->st_stateid.si_generation);
+       dprintk("NFSD: %s: success, seqid=%d stateid=" STATEID_FMT "\n",
+               __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stateid));
 
        nfsd4_create_clid_dir(sop->so_client);
 out:
@@ -3283,9 +3266,8 @@ find_delegation_stateid(struct inode *ino, stateid_t *stid)
        struct nfs4_file *fp;
        struct nfs4_delegation *dl;
 
-       dprintk("NFSD:find_delegation_stateid stateid=(%08x/%08x/%08x/%08x)\n",
-                    stid->si_boot, stid->si_stateownerid,
-                    stid->si_fileid, stid->si_generation);
+       dprintk("NFSD: %s: stateid=" STATEID_FMT "\n", __func__,
+               STATEID_VAL(stid));
 
        fp = find_file(ino);
        if (!fp)
index 0fbd50cee1f60e8c437102fb4b2cb2cee53afbe1..a8587e90fd5a837bfce993d9cebaeb9f1697f825 100644 (file)
  * at the end of nfs4svc_decode_compoundargs.
  */
 
-#include <linux/param.h>
-#include <linux/smp.h>
-#include <linux/fs.h>
 #include <linux/namei.h>
-#include <linux/vfs.h>
+#include <linux/statfs.h>
 #include <linux/utsname.h>
-#include <linux/sunrpc/xdr.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/sunrpc/clnt.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/state.h>
-#include <linux/nfsd/xdr4.h>
 #include <linux/nfsd_idmap.h>
-#include <linux/nfs4.h>
 #include <linux/nfs4_acl.h>
-#include <linux/sunrpc/gss_api.h>
 #include <linux/sunrpc/svcauth_gss.h>
 
+#include "xdr4.h"
+#include "vfs.h"
+
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
 
 /*
@@ -2204,11 +2196,14 @@ nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd,
         * we will not follow the cross mount and will fill the attribtutes
         * directly from the mountpoint dentry.
         */
-       if (d_mountpoint(dentry) && !attributes_need_mount(cd->rd_bmval))
-               ignore_crossmnt = 1;
-       else if (d_mountpoint(dentry)) {
+       if (nfsd_mountpoint(dentry, exp)) {
                int err;
 
+               if (!(exp->ex_flags & NFSEXP_V4ROOT)
+                               && !attributes_need_mount(cd->rd_bmval)) {
+                       ignore_crossmnt = 1;
+                       goto out_encode;
+               }
                /*
                 * Why the heck aren't we just using nfsd_lookup??
                 * Different "."/".." handling?  Something else?
@@ -2224,6 +2219,7 @@ nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd,
                        goto out_put;
 
        }
+out_encode:
        nfserr = nfsd4_encode_fattr(NULL, exp, dentry, p, buflen, cd->rd_bmval,
                                        cd->rd_rqstp, ignore_crossmnt);
 out_put:
index 4638635c5d87d217ea813c9f83b0a07a57624089..da08560c4818defa358feb7b75e88b4d33dee70b 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/fs/nfsd/nfscache.c
- *
  * Request reply cache. This is currently a global cache, but this may
  * change in the future and be a per-client cache.
  *
@@ -10,16 +8,8 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/spinlock.h>
-#include <linux/list.h>
-
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
+#include "nfsd.h"
+#include "cache.h"
 
 /* Size of reply cache. Common values are:
  * 4.3BSD:     128
index 5c01fc148ce880e02a557a3ade47a00056d563f3..2604c3e70ea547f69e19146afbc11fe769f6ba5a 100644 (file)
@@ -1,46 +1,20 @@
 /*
- * linux/fs/nfsd/nfsctl.c
- *
  * Syscall interface to knfsd.
  *
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include <linux/module.h>
-
-#include <linux/linkage.h>
-#include <linux/time.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
 #include <linux/namei.h>
-#include <linux/fcntl.h>
-#include <linux/net.h>
-#include <linux/in.h>
-#include <linux/syscalls.h>
-#include <linux/unistd.h>
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <linux/pagemap.h>
-#include <linux/init.h>
-#include <linux/inet.h>
-#include <linux/string.h>
 #include <linux/ctype.h>
 
-#include <linux/nfs.h>
 #include <linux/nfsd_idmap.h>
-#include <linux/lockd/bind.h>
-#include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/svcsock.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfsd/xdr.h>
 #include <linux/nfsd/syscall.h>
 #include <linux/lockd/lockd.h>
 #include <linux/sunrpc/clnt.h>
 
-#include <asm/uaccess.h>
-#include <net/ipv6.h>
+#include "nfsd.h"
+#include "cache.h"
 
 /*
  *     We have a single directory with 9 nodes in it.
@@ -55,6 +29,7 @@ enum {
        NFSD_Getfd,
        NFSD_Getfs,
        NFSD_List,
+       NFSD_Export_features,
        NFSD_Fh,
        NFSD_FO_UnlockIP,
        NFSD_FO_UnlockFS,
@@ -173,6 +148,24 @@ static const struct file_operations exports_operations = {
        .owner          = THIS_MODULE,
 };
 
+static int export_features_show(struct seq_file *m, void *v)
+{
+       seq_printf(m, "0x%x 0x%x\n", NFSEXP_ALLFLAGS, NFSEXP_SECINFO_FLAGS);
+       return 0;
+}
+
+static int export_features_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, export_features_show, NULL);
+}
+
+static struct file_operations export_features_operations = {
+       .open           = export_features_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 extern int nfsd_pool_stats_open(struct inode *inode, struct file *file);
 extern int nfsd_pool_stats_release(struct inode *inode, struct file *file);
 
@@ -1330,6 +1323,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent)
                [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR},
                [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR},
                [NFSD_List] = {"exports", &exports_operations, S_IRUGO},
+               [NFSD_Export_features] = {"export_features",
+                                       &export_features_operations, S_IRUGO},
                [NFSD_FO_UnlockIP] = {"unlock_ip",
                                        &transaction_ops, S_IWUSR|S_IRUSR},
                [NFSD_FO_UnlockFS] = {"unlock_filesystem",
similarity index 79%
rename from include/linux/nfsd/nfsd.h
rename to fs/nfsd/nfsd.h
index 510ffdd5020ea21f75b14fc7ad33d8e26e6d4c1e..e942a1aaac925d187bb2479fad0c2cf5cb03d14c 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/include/linux/nfsd/nfsd.h
- *
  * Hodge-podge collection of knfsd-related stuff.
  * I will sort this out later.
  *
@@ -11,13 +9,9 @@
 #define LINUX_NFSD_NFSD_H
 
 #include <linux/types.h>
-#include <linux/unistd.h>
-#include <linux/fs.h>
-#include <linux/posix_acl.h>
 #include <linux/mount.h>
 
 #include <linux/nfsd/debug.h>
-#include <linux/nfsd/nfsfh.h>
 #include <linux/nfsd/export.h>
 #include <linux/nfsd/stats.h>
 /*
  */
 #define NFSD_SUPPORTED_MINOR_VERSION   1
 
-/*
- * Flags for nfsd_permission
- */
-#define NFSD_MAY_NOP           0
-#define NFSD_MAY_EXEC          1 /* == MAY_EXEC */
-#define NFSD_MAY_WRITE         2 /* == MAY_WRITE */
-#define NFSD_MAY_READ          4 /* == MAY_READ */
-#define NFSD_MAY_SATTR         8
-#define NFSD_MAY_TRUNC         16
-#define NFSD_MAY_LOCK          32
-#define NFSD_MAY_OWNER_OVERRIDE        64
-#define NFSD_MAY_LOCAL_ACCESS  128 /* IRIX doing local access check on device special file*/
-#define NFSD_MAY_BYPASS_GSS_ON_ROOT 256
-
-#define NFSD_MAY_CREATE                (NFSD_MAY_EXEC|NFSD_MAY_WRITE)
-#define NFSD_MAY_REMOVE                (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC)
-
-/*
- * Callback function for readdir
- */
 struct readdir_cd {
        __be32                  err;    /* 0, nfserr, or nfserr_eof */
 };
-typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
+
 
 extern struct svc_program      nfsd_program;
 extern struct svc_version      nfsd_version2, nfsd_version3,
@@ -73,69 +47,6 @@ int          nfsd_nrpools(void);
 int            nfsd_get_nrthreads(int n, int *);
 int            nfsd_set_nrthreads(int n, int *);
 
-/* nfsd/vfs.c */
-int            fh_lock_parent(struct svc_fh *, struct dentry *);
-int            nfsd_racache_init(int);
-void           nfsd_racache_shutdown(void);
-int            nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
-                               struct svc_export **expp);
-__be32         nfsd_lookup(struct svc_rqst *, struct svc_fh *,
-                               const char *, unsigned int, struct svc_fh *);
-__be32          nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *,
-                               const char *, unsigned int,
-                               struct svc_export **, struct dentry **);
-__be32         nfsd_setattr(struct svc_rqst *, struct svc_fh *,
-                               struct iattr *, int, time_t);
-#ifdef CONFIG_NFSD_V4
-__be32          nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *,
-                    struct nfs4_acl *);
-int             nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **);
-#endif /* CONFIG_NFSD_V4 */
-__be32         nfsd_create(struct svc_rqst *, struct svc_fh *,
-                               char *name, int len, struct iattr *attrs,
-                               int type, dev_t rdev, struct svc_fh *res);
-#ifdef CONFIG_NFSD_V3
-__be32         nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
-__be32         nfsd_create_v3(struct svc_rqst *, struct svc_fh *,
-                               char *name, int len, struct iattr *attrs,
-                               struct svc_fh *res, int createmode,
-                               u32 *verifier, int *truncp, int *created);
-__be32         nfsd_commit(struct svc_rqst *, struct svc_fh *,
-                               loff_t, unsigned long);
-#endif /* CONFIG_NFSD_V3 */
-__be32         nfsd_open(struct svc_rqst *, struct svc_fh *, int,
-                               int, struct file **);
-void           nfsd_close(struct file *);
-__be32                 nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *,
-                               loff_t, struct kvec *, int, unsigned long *);
-__be32                 nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *,
-                               loff_t, struct kvec *,int, unsigned long *, int *);
-__be32         nfsd_readlink(struct svc_rqst *, struct svc_fh *,
-                               char *, int *);
-__be32         nfsd_symlink(struct svc_rqst *, struct svc_fh *,
-                               char *name, int len, char *path, int plen,
-                               struct svc_fh *res, struct iattr *);
-__be32         nfsd_link(struct svc_rqst *, struct svc_fh *,
-                               char *, int, struct svc_fh *);
-__be32         nfsd_rename(struct svc_rqst *,
-                               struct svc_fh *, char *, int,
-                               struct svc_fh *, char *, int);
-__be32         nfsd_remove(struct svc_rqst *,
-                               struct svc_fh *, char *, int);
-__be32         nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
-                               char *name, int len);
-int            nfsd_truncate(struct svc_rqst *, struct svc_fh *,
-                               unsigned long size);
-__be32         nfsd_readdir(struct svc_rqst *, struct svc_fh *,
-                            loff_t *, struct readdir_cd *, filldir_t);
-__be32         nfsd_statfs(struct svc_rqst *, struct svc_fh *,
-                               struct kstatfs *, int access);
-
-int            nfsd_notify_change(struct inode *, struct iattr *);
-__be32         nfsd_permission(struct svc_rqst *, struct svc_export *,
-                               struct dentry *, int);
-int            nfsd_sync_dir(struct dentry *dp);
-
 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
 #ifdef CONFIG_NFSD_V2_ACL
 extern struct svc_version nfsd_acl_version2;
@@ -147,8 +58,6 @@ extern struct svc_version nfsd_acl_version3;
 #else
 #define nfsd_acl_version3 NULL
 #endif
-struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int);
-int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *);
 #endif
 
 enum vers_op {NFSD_SET, NFSD_CLEAR, NFSD_TEST, NFSD_AVAIL };
@@ -159,6 +68,11 @@ int nfsd_create_serv(void);
 
 extern int nfsd_max_blksize;
 
+static inline int nfsd_v4client(struct svc_rqst *rq)
+{
+       return rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
+}
+
 /* 
  * NFSv4 State
  */
index 01965b2f3a7697e28598346e1fc32c6535a7fa2d..55c8e63af0be76d566e7723916675a0627145a12 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/fs/nfsd/nfsfh.c
- *
  * NFS server file handle treatment.
  *
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
@@ -9,19 +7,11 @@
  * ... and again Southern-Winter 2001 to support export_operations
  */
 
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/unistd.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/dcache.h>
 #include <linux/exportfs.h>
-#include <linux/mount.h>
 
-#include <linux/sunrpc/clnt.h>
-#include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/svcauth_gss.h>
-#include <linux/nfsd/nfsd.h>
+#include "nfsd.h"
+#include "vfs.h"
 #include "auth.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_FH
@@ -96,8 +86,10 @@ nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type)
 static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,
                                          struct svc_export *exp)
 {
+       int flags = nfsexp_flags(rqstp, exp);
+
        /* Check if the request originated from a secure port. */
-       if (!rqstp->rq_secure && EX_SECURE(exp)) {
+       if (!rqstp->rq_secure && !(flags & NFSEXP_INSECURE_PORT)) {
                RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
                dprintk(KERN_WARNING
                       "nfsd: request from insecure port %s!\n",
@@ -109,6 +101,36 @@ static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,
        return nfserrno(nfsd_setuser(rqstp, exp));
 }
 
+static inline __be32 check_pseudo_root(struct svc_rqst *rqstp,
+       struct dentry *dentry, struct svc_export *exp)
+{
+       if (!(exp->ex_flags & NFSEXP_V4ROOT))
+               return nfs_ok;
+       /*
+        * v2/v3 clients have no need for the V4ROOT export--they use
+        * the mount protocl instead; also, further V4ROOT checks may be
+        * in v4-specific code, in which case v2/v3 clients could bypass
+        * them.
+        */
+       if (!nfsd_v4client(rqstp))
+               return nfserr_stale;
+       /*
+        * We're exposing only the directories and symlinks that have to be
+        * traversed on the way to real exports:
+        */
+       if (unlikely(!S_ISDIR(dentry->d_inode->i_mode) &&
+                    !S_ISLNK(dentry->d_inode->i_mode)))
+               return nfserr_stale;
+       /*
+        * A pseudoroot export gives permission to access only one
+        * single directory; the kernel has to make another upcall
+        * before granting access to anything else under it:
+        */
+       if (unlikely(dentry != exp->ex_path.dentry))
+               return nfserr_stale;
+       return nfs_ok;
+}
+
 /*
  * Use the given filehandle to look up the corresponding export and
  * dentry.  On success, the results are used to set fh_export and
@@ -232,14 +254,6 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
                goto out;
        }
 
-       if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) {
-               error = nfsd_setuser_and_check_port(rqstp, exp);
-               if (error) {
-                       dput(dentry);
-                       goto out;
-               }
-       }
-
        if (S_ISDIR(dentry->d_inode->i_mode) &&
                        (dentry->d_flags & DCACHE_DISCONNECTED)) {
                printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n",
@@ -294,28 +308,32 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
                error = nfsd_set_fh_dentry(rqstp, fhp);
                if (error)
                        goto out;
-               dentry = fhp->fh_dentry;
-               exp = fhp->fh_export;
-       } else {
-               /*
-                * just rechecking permissions
-                * (e.g. nfsproc_create calls fh_verify, then nfsd_create
-                * does as well)
-                */
-               dprintk("nfsd: fh_verify - just checking\n");
-               dentry = fhp->fh_dentry;
-               exp = fhp->fh_export;
-               /*
-                * Set user creds for this exportpoint; necessary even
-                * in the "just checking" case because this may be a
-                * filehandle that was created by fh_compose, and that
-                * is about to be used in another nfsv4 compound
-                * operation.
-                */
-               error = nfsd_setuser_and_check_port(rqstp, exp);
-               if (error)
-                       goto out;
        }
+       dentry = fhp->fh_dentry;
+       exp = fhp->fh_export;
+       /*
+        * We still have to do all these permission checks, even when
+        * fh_dentry is already set:
+        *      - fh_verify may be called multiple times with different
+        *        "access" arguments (e.g. nfsd_proc_create calls
+        *        fh_verify(...,NFSD_MAY_EXEC) first, then later (in
+        *        nfsd_create) calls fh_verify(...,NFSD_MAY_CREATE).
+        *      - in the NFSv4 case, the filehandle may have been filled
+        *        in by fh_compose, and given a dentry, but further
+        *        compound operations performed with that filehandle
+        *        still need permissions checks.  In the worst case, a
+        *        mountpoint crossing may have changed the export
+        *        options, and we may now need to use a different uid
+        *        (for example, if different id-squashing options are in
+        *        effect on the new filesystem).
+        */
+       error = check_pseudo_root(rqstp, dentry, exp);
+       if (error)
+               goto out;
+
+       error = nfsd_setuser_and_check_port(rqstp, exp);
+       if (error)
+               goto out;
 
        error = nfsd_mode_check(rqstp, dentry->d_inode->i_mode, type);
        if (error)
diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h
new file mode 100644 (file)
index 0000000..cdfb8c6
--- /dev/null
@@ -0,0 +1,208 @@
+/* Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> */
+
+#ifndef _LINUX_NFSD_FH_INT_H
+#define _LINUX_NFSD_FH_INT_H
+
+#include <linux/nfsd/nfsfh.h>
+
+enum nfsd_fsid {
+       FSID_DEV = 0,
+       FSID_NUM,
+       FSID_MAJOR_MINOR,
+       FSID_ENCODE_DEV,
+       FSID_UUID4_INUM,
+       FSID_UUID8,
+       FSID_UUID16,
+       FSID_UUID16_INUM,
+};
+
+enum fsid_source {
+       FSIDSOURCE_DEV,
+       FSIDSOURCE_FSID,
+       FSIDSOURCE_UUID,
+};
+extern enum fsid_source fsid_source(struct svc_fh *fhp);
+
+
+/* This might look a little large to "inline" but in all calls except
+ * one, 'vers' is constant so moste of the function disappears.
+ */
+static inline void mk_fsid(int vers, u32 *fsidv, dev_t dev, ino_t ino,
+                          u32 fsid, unsigned char *uuid)
+{
+       u32 *up;
+       switch(vers) {
+       case FSID_DEV:
+               fsidv[0] = htonl((MAJOR(dev)<<16) |
+                                MINOR(dev));
+               fsidv[1] = ino_t_to_u32(ino);
+               break;
+       case FSID_NUM:
+               fsidv[0] = fsid;
+               break;
+       case FSID_MAJOR_MINOR:
+               fsidv[0] = htonl(MAJOR(dev));
+               fsidv[1] = htonl(MINOR(dev));
+               fsidv[2] = ino_t_to_u32(ino);
+               break;
+
+       case FSID_ENCODE_DEV:
+               fsidv[0] = new_encode_dev(dev);
+               fsidv[1] = ino_t_to_u32(ino);
+               break;
+
+       case FSID_UUID4_INUM:
+               /* 4 byte fsid and inode number */
+               up = (u32*)uuid;
+               fsidv[0] = ino_t_to_u32(ino);
+               fsidv[1] = up[0] ^ up[1] ^ up[2] ^ up[3];
+               break;
+
+       case FSID_UUID8:
+               /* 8 byte fsid  */
+               up = (u32*)uuid;
+               fsidv[0] = up[0] ^ up[2];
+               fsidv[1] = up[1] ^ up[3];
+               break;
+
+       case FSID_UUID16:
+               /* 16 byte fsid - NFSv3+ only */
+               memcpy(fsidv, uuid, 16);
+               break;
+
+       case FSID_UUID16_INUM:
+               /* 8 byte inode and 16 byte fsid */
+               *(u64*)fsidv = (u64)ino;
+               memcpy(fsidv+2, uuid, 16);
+               break;
+       default: BUG();
+       }
+}
+
+static inline int key_len(int type)
+{
+       switch(type) {
+       case FSID_DEV:          return 8;
+       case FSID_NUM:          return 4;
+       case FSID_MAJOR_MINOR:  return 12;
+       case FSID_ENCODE_DEV:   return 8;
+       case FSID_UUID4_INUM:   return 8;
+       case FSID_UUID8:        return 8;
+       case FSID_UUID16:       return 16;
+       case FSID_UUID16_INUM:  return 24;
+       default: return 0;
+       }
+}
+
+/*
+ * Shorthand for dprintk()'s
+ */
+extern char * SVCFH_fmt(struct svc_fh *fhp);
+
+/*
+ * Function prototypes
+ */
+__be32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int);
+__be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
+__be32 fh_update(struct svc_fh *);
+void   fh_put(struct svc_fh *);
+
+static __inline__ struct svc_fh *
+fh_copy(struct svc_fh *dst, struct svc_fh *src)
+{
+       WARN_ON(src->fh_dentry || src->fh_locked);
+                       
+       *dst = *src;
+       return dst;
+}
+
+static inline void
+fh_copy_shallow(struct knfsd_fh *dst, struct knfsd_fh *src)
+{
+       dst->fh_size = src->fh_size;
+       memcpy(&dst->fh_base, &src->fh_base, src->fh_size);
+}
+
+static __inline__ struct svc_fh *
+fh_init(struct svc_fh *fhp, int maxsize)
+{
+       memset(fhp, 0, sizeof(*fhp));
+       fhp->fh_maxsize = maxsize;
+       return fhp;
+}
+
+#ifdef CONFIG_NFSD_V3
+/*
+ * Fill in the pre_op attr for the wcc data
+ */
+static inline void
+fill_pre_wcc(struct svc_fh *fhp)
+{
+       struct inode    *inode;
+
+       inode = fhp->fh_dentry->d_inode;
+       if (!fhp->fh_pre_saved) {
+               fhp->fh_pre_mtime = inode->i_mtime;
+               fhp->fh_pre_ctime = inode->i_ctime;
+               fhp->fh_pre_size  = inode->i_size;
+               fhp->fh_pre_change = inode->i_version;
+               fhp->fh_pre_saved = 1;
+       }
+}
+
+extern void fill_post_wcc(struct svc_fh *);
+#else
+#define        fill_pre_wcc(ignored)
+#define fill_post_wcc(notused)
+#endif /* CONFIG_NFSD_V3 */
+
+
+/*
+ * Lock a file handle/inode
+ * NOTE: both fh_lock and fh_unlock are done "by hand" in
+ * vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once
+ * so, any changes here should be reflected there.
+ */
+
+static inline void
+fh_lock_nested(struct svc_fh *fhp, unsigned int subclass)
+{
+       struct dentry   *dentry = fhp->fh_dentry;
+       struct inode    *inode;
+
+       BUG_ON(!dentry);
+
+       if (fhp->fh_locked) {
+               printk(KERN_WARNING "fh_lock: %s/%s already locked!\n",
+                       dentry->d_parent->d_name.name, dentry->d_name.name);
+               return;
+       }
+
+       inode = dentry->d_inode;
+       mutex_lock_nested(&inode->i_mutex, subclass);
+       fill_pre_wcc(fhp);
+       fhp->fh_locked = 1;
+}
+
+static inline void
+fh_lock(struct svc_fh *fhp)
+{
+       fh_lock_nested(fhp, I_MUTEX_NORMAL);
+}
+
+/*
+ * Unlock a file handle/inode
+ */
+static inline void
+fh_unlock(struct svc_fh *fhp)
+{
+       BUG_ON(!fhp->fh_dentry);
+
+       if (fhp->fh_locked) {
+               fill_post_wcc(fhp);
+               mutex_unlock(&fhp->fh_dentry->d_inode->i_mutex);
+               fhp->fh_locked = 0;
+       }
+}
+
+#endif /* _LINUX_NFSD_FH_INT_H */
index 0eb9c820b7a6282340df2f840f5e8ed86dcdff0e..a047ad6111ef2e1c6820097ee3b01a77de8ce20b 100644 (file)
@@ -1,29 +1,14 @@
 /*
- * nfsproc2.c  Process version 2 NFS requests.
- * linux/fs/nfsd/nfs2proc.c
- * 
  * Process version 2 NFS requests.
  *
  * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include <linux/linkage.h>
-#include <linux/time.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <linux/fcntl.h>
-#include <linux/net.h>
-#include <linux/in.h>
 #include <linux/namei.h>
-#include <linux/unistd.h>
-#include <linux/slab.h>
 
-#include <linux/sunrpc/clnt.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfsd/xdr.h>
+#include "cache.h"
+#include "xdr.h"
+#include "vfs.h"
 
 typedef struct svc_rqst        svc_rqst;
 typedef struct svc_buf svc_buf;
@@ -758,6 +743,7 @@ nfserrno (int errno)
                { nfserr_io, -ETXTBSY },
                { nfserr_notsupp, -EOPNOTSUPP },
                { nfserr_toosmall, -ETOOSMALL },
+               { nfserr_serverfault, -ESERVERFAULT },
        };
        int     i;
 
index 67ea83eedd43eb7b69e896e1db54f8fd995a0d9e..171699eb07c879893d1e874470c4f5922f570709 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/fs/nfsd/nfssvc.c
- *
  * Central processing for nfsd.
  *
  * Authors:    Olaf Kirch (okir@monad.swb.de)
@@ -8,33 +6,19 @@
  * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include <linux/module.h>
 #include <linux/sched.h>
-#include <linux/time.h>
-#include <linux/errno.h>
-#include <linux/nfs.h>
-#include <linux/in.h>
-#include <linux/uio.h>
-#include <linux/unistd.h>
-#include <linux/slab.h>
-#include <linux/smp.h>
 #include <linux/freezer.h>
 #include <linux/fs_struct.h>
-#include <linux/kthread.h>
 #include <linux/swap.h>
 
-#include <linux/sunrpc/types.h>
 #include <linux/sunrpc/stats.h>
-#include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/svcsock.h>
-#include <linux/sunrpc/cache.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/stats.h>
-#include <linux/nfsd/cache.h>
-#include <linux/nfsd/syscall.h>
 #include <linux/lockd/bind.h>
 #include <linux/nfsacl.h>
 #include <linux/seq_file.h>
+#include "nfsd.h"
+#include "cache.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY       NFSDDBG_SVC
 
index afd08e2c90a54624e690ea2ffc4e0186005256e8..4ce005dbf3e66b9df71ce3d2009a2d249cc3555e 100644 (file)
@@ -1,20 +1,10 @@
 /*
- * linux/fs/nfsd/nfsxdr.c
- *
  * XDR support for nfsd
  *
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include <linux/types.h>
-#include <linux/time.h>
-#include <linux/nfs.h>
-#include <linux/vfs.h>
-#include <linux/sunrpc/xdr.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#include <linux/nfsd/xdr.h>
-#include <linux/mm.h>
+#include "xdr.h"
 #include "auth.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_XDR
similarity index 98%
rename from include/linux/nfsd/state.h
rename to fs/nfsd/state.h
index b38d113241899df6da6464369e6c6a8f87e5bb5a..fefeae27f25e62a784b8e67a483154b283542c64 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  linux/include/nfsd/state.h
- *
  *  Copyright (c) 2001 The Regents of the University of Michigan.
  *  All rights reserved.
  *
@@ -37,9 +35,8 @@
 #ifndef _NFSD4_STATE_H
 #define _NFSD4_STATE_H
 
-#include <linux/list.h>
-#include <linux/kref.h>
-#include <linux/sunrpc/clnt.h>
+#include <linux/nfsd/nfsfh.h>
+#include "nfsfh.h"
 
 typedef struct {
        u32             cl_boot;
@@ -60,6 +57,13 @@ typedef struct {
 #define si_stateownerid   si_opaque.so_stateownerid
 #define si_fileid         si_opaque.so_fileid
 
+#define STATEID_FMT    "(%08x/%08x/%08x/%08x)"
+#define STATEID_VAL(s) \
+       (s)->si_boot, \
+       (s)->si_stateownerid, \
+       (s)->si_fileid, \
+       (s)->si_generation
+
 struct nfsd4_cb_sequence {
        /* args/res */
        u32                     cbs_minorversion;
index 71944cddf680993773475402aced0a8c6892643b..5232d3e8fb2f0f2a28be0e25ff73b0e6dde170c4 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/fs/nfsd/stats.c
- *
  * procfs-based user access to knfsd statistics
  *
  * /proc/net/rpc/nfsd
  * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
  */
 
-#include <linux/kernel.h>
-#include <linux/time.h>
-#include <linux/proc_fs.h>
 #include <linux/seq_file.h>
-#include <linux/stat.h>
 #include <linux/module.h>
-
-#include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/stats.h>
-#include <linux/nfsd/nfsd.h>
 #include <linux/nfsd/stats.h>
 
+#include "nfsd.h"
+
 struct nfsd_stats      nfsdstats;
 struct svc_stat                nfsd_svcstats = {
        .program        = &nfsd_program,
index a293f0273263fb18dd1837a2a906769b8a9b71d6..7c2e337d05af58fb2d733a6b688580f40d1221b5 100644 (file)
@@ -1,7 +1,5 @@
 #define MSNFS  /* HACK HACK */
 /*
- * linux/fs/nfsd/vfs.c
- *
  * File operations used by nfsd. Some of these have been ripped from
  * other parts of the kernel because they weren't exported, others
  * are partial duplicates with added or changed functionality.
  * Zerocpy NFS support (C) 2002 Hirokazu Takahashi <taka@valinux.co.jp>
  */
 
-#include <linux/string.h>
-#include <linux/time.h>
-#include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/file.h>
-#include <linux/mount.h>
-#include <linux/major.h>
 #include <linux/splice.h>
-#include <linux/proc_fs.h>
-#include <linux/stat.h>
 #include <linux/fcntl.h>
-#include <linux/net.h>
-#include <linux/unistd.h>
-#include <linux/slab.h>
-#include <linux/pagemap.h>
-#include <linux/in.h>
-#include <linux/module.h>
 #include <linux/namei.h>
-#include <linux/vfs.h>
 #include <linux/delay.h>
-#include <linux/sunrpc/svc.h>
-#include <linux/nfsd/nfsd.h>
-#ifdef CONFIG_NFSD_V3
-#include <linux/nfs3.h>
-#include <linux/nfsd/xdr3.h>
-#endif /* CONFIG_NFSD_V3 */
-#include <linux/nfsd/nfsfh.h>
 #include <linux/quotaops.h>
 #include <linux/fsnotify.h>
-#include <linux/posix_acl.h>
 #include <linux/posix_acl_xattr.h>
 #include <linux/xattr.h>
+#include <linux/jhash.h>
+#include <linux/ima.h>
+#include <asm/uaccess.h>
+
+#ifdef CONFIG_NFSD_V3
+#include "xdr3.h"
+#endif /* CONFIG_NFSD_V3 */
+
 #ifdef CONFIG_NFSD_V4
-#include <linux/nfs4.h>
 #include <linux/nfs4_acl.h>
 #include <linux/nfsd_idmap.h>
-#include <linux/security.h>
 #endif /* CONFIG_NFSD_V4 */
-#include <linux/jhash.h>
-#include <linux/ima.h>
 
-#include <asm/uaccess.h>
+#include "nfsd.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_FILEOP
 
@@ -89,12 +70,6 @@ struct raparm_hbucket {
 #define RAPARM_HASH_MASK       (RAPARM_HASH_SIZE-1)
 static struct raparm_hbucket   raparm_hash[RAPARM_HASH_SIZE];
 
-static inline int
-nfsd_v4client(struct svc_rqst *rq)
-{
-    return rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
-}
-
 /* 
  * Called from nfsd_lookup and encode_dirent. Check if we have crossed 
  * a mount point.
@@ -116,8 +91,16 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
 
        exp2 = rqst_exp_get_by_name(rqstp, &path);
        if (IS_ERR(exp2)) {
-               if (PTR_ERR(exp2) != -ENOENT)
-                       err = PTR_ERR(exp2);
+               err = PTR_ERR(exp2);
+               /*
+                * We normally allow NFS clients to continue
+                * "underneath" a mountpoint that is not exported.
+                * The exception is V4ROOT, where no traversal is ever
+                * allowed without an explicit export of the new
+                * directory.
+                */
+               if (err == -ENOENT && !(exp->ex_flags & NFSEXP_V4ROOT))
+                       err = 0;
                path_put(&path);
                goto out;
        }
@@ -141,6 +124,53 @@ out:
        return err;
 }
 
+static void follow_to_parent(struct path *path)
+{
+       struct dentry *dp;
+
+       while (path->dentry == path->mnt->mnt_root && follow_up(path))
+               ;
+       dp = dget_parent(path->dentry);
+       dput(path->dentry);
+       path->dentry = dp;
+}
+
+static int nfsd_lookup_parent(struct svc_rqst *rqstp, struct dentry *dparent, struct svc_export **exp, struct dentry **dentryp)
+{
+       struct svc_export *exp2;
+       struct path path = {.mnt = mntget((*exp)->ex_path.mnt),
+                           .dentry = dget(dparent)};
+
+       follow_to_parent(&path);
+
+       exp2 = rqst_exp_parent(rqstp, &path);
+       if (PTR_ERR(exp2) == -ENOENT) {
+               *dentryp = dget(dparent);
+       } else if (IS_ERR(exp2)) {
+               path_put(&path);
+               return PTR_ERR(exp2);
+       } else {
+               *dentryp = dget(path.dentry);
+               exp_put(*exp);
+               *exp = exp2;
+       }
+       path_put(&path);
+       return 0;
+}
+
+/*
+ * For nfsd purposes, we treat V4ROOT exports as though there was an
+ * export at *every* directory.
+ */
+int nfsd_mountpoint(struct dentry *dentry, struct svc_export *exp)
+{
+       if (d_mountpoint(dentry))
+               return 1;
+       if (!(exp->ex_flags & NFSEXP_V4ROOT))
+               return 0;
+       return dentry->d_inode != NULL;
+}
+
 __be32
 nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
                   const char *name, unsigned int len,
@@ -169,35 +199,13 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
                        dentry = dget(dparent);
                else if (dparent != exp->ex_path.dentry)
                        dentry = dget_parent(dparent);
-               else if (!EX_NOHIDE(exp))
+               else if (!EX_NOHIDE(exp) && !nfsd_v4client(rqstp))
                        dentry = dget(dparent); /* .. == . just like at / */
                else {
                        /* checking mountpoint crossing is very different when stepping up */
-                       struct svc_export *exp2 = NULL;
-                       struct dentry *dp;
-                       struct path path = {.mnt = mntget(exp->ex_path.mnt),
-                                           .dentry = dget(dparent)};
-
-                       while (path.dentry == path.mnt->mnt_root &&
-                              follow_up(&path))
-                               ;
-                       dp = dget_parent(path.dentry);
-                       dput(path.dentry);
-                       path.dentry = dp;
-
-                       exp2 = rqst_exp_parent(rqstp, &path);
-                       if (PTR_ERR(exp2) == -ENOENT) {
-                               dentry = dget(dparent);
-                       } else if (IS_ERR(exp2)) {
-                               host_err = PTR_ERR(exp2);
-                               path_put(&path);
+                       host_err = nfsd_lookup_parent(rqstp, dparent, &exp, &dentry);
+                       if (host_err)
                                goto out_nfserr;
-                       } else {
-                               dentry = dget(path.dentry);
-                               exp_put(exp);
-                               exp = exp2;
-                       }
-                       path_put(&path);
                }
        } else {
                fh_lock(fhp);
@@ -208,7 +216,7 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
                /*
                 * check if we have crossed a mount point ...
                 */
-               if (d_mountpoint(dentry)) {
+               if (nfsd_mountpoint(dentry, exp)) {
                        if ((host_err = nfsd_cross_mnt(rqstp, &dentry, &exp))) {
                                dput(dentry);
                                goto out_nfserr;
@@ -744,8 +752,6 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
                            flags, current_cred());
        if (IS_ERR(*filp))
                host_err = PTR_ERR(*filp);
-       else
-               ima_counts_get(*filp);
 out_nfserr:
        err = nfserrno(host_err);
 out:
@@ -2124,8 +2130,7 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp,
         */
        path.mnt = exp->ex_path.mnt;
        path.dentry = dentry;
-       err = ima_path_check(&path, acc & (MAY_READ | MAY_WRITE | MAY_EXEC),
-                            IMA_COUNT_LEAVE);
+       err = ima_path_check(&path, acc & (MAY_READ | MAY_WRITE | MAY_EXEC));
 nfsd_out:
        return err? nfserrno(err) : 0;
 }
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
new file mode 100644 (file)
index 0000000..4b1de0a
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
+ */
+
+#ifndef LINUX_NFSD_VFS_H
+#define LINUX_NFSD_VFS_H
+
+#include "nfsfh.h"
+
+/*
+ * Flags for nfsd_permission
+ */
+#define NFSD_MAY_NOP           0
+#define NFSD_MAY_EXEC          1 /* == MAY_EXEC */
+#define NFSD_MAY_WRITE         2 /* == MAY_WRITE */
+#define NFSD_MAY_READ          4 /* == MAY_READ */
+#define NFSD_MAY_SATTR         8
+#define NFSD_MAY_TRUNC         16
+#define NFSD_MAY_LOCK          32
+#define NFSD_MAY_OWNER_OVERRIDE        64
+#define NFSD_MAY_LOCAL_ACCESS  128 /* IRIX doing local access check on device special file*/
+#define NFSD_MAY_BYPASS_GSS_ON_ROOT 256
+
+#define NFSD_MAY_CREATE                (NFSD_MAY_EXEC|NFSD_MAY_WRITE)
+#define NFSD_MAY_REMOVE                (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC)
+
+/*
+ * Callback function for readdir
+ */
+typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int);
+
+/* nfsd/vfs.c */
+int            fh_lock_parent(struct svc_fh *, struct dentry *);
+int            nfsd_racache_init(int);
+void           nfsd_racache_shutdown(void);
+int            nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
+                               struct svc_export **expp);
+__be32         nfsd_lookup(struct svc_rqst *, struct svc_fh *,
+                               const char *, unsigned int, struct svc_fh *);
+__be32          nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *,
+                               const char *, unsigned int,
+                               struct svc_export **, struct dentry **);
+__be32         nfsd_setattr(struct svc_rqst *, struct svc_fh *,
+                               struct iattr *, int, time_t);
+int nfsd_mountpoint(struct dentry *, struct svc_export *);
+#ifdef CONFIG_NFSD_V4
+__be32          nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *,
+                    struct nfs4_acl *);
+int             nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **);
+#endif /* CONFIG_NFSD_V4 */
+__be32         nfsd_create(struct svc_rqst *, struct svc_fh *,
+                               char *name, int len, struct iattr *attrs,
+                               int type, dev_t rdev, struct svc_fh *res);
+#ifdef CONFIG_NFSD_V3
+__be32         nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *);
+__be32         nfsd_create_v3(struct svc_rqst *, struct svc_fh *,
+                               char *name, int len, struct iattr *attrs,
+                               struct svc_fh *res, int createmode,
+                               u32 *verifier, int *truncp, int *created);
+__be32         nfsd_commit(struct svc_rqst *, struct svc_fh *,
+                               loff_t, unsigned long);
+#endif /* CONFIG_NFSD_V3 */
+__be32         nfsd_open(struct svc_rqst *, struct svc_fh *, int,
+                               int, struct file **);
+void           nfsd_close(struct file *);
+__be32                 nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *,
+                               loff_t, struct kvec *, int, unsigned long *);
+__be32                 nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *,
+                               loff_t, struct kvec *,int, unsigned long *, int *);
+__be32         nfsd_readlink(struct svc_rqst *, struct svc_fh *,
+                               char *, int *);
+__be32         nfsd_symlink(struct svc_rqst *, struct svc_fh *,
+                               char *name, int len, char *path, int plen,
+                               struct svc_fh *res, struct iattr *);
+__be32         nfsd_link(struct svc_rqst *, struct svc_fh *,
+                               char *, int, struct svc_fh *);
+__be32         nfsd_rename(struct svc_rqst *,
+                               struct svc_fh *, char *, int,
+                               struct svc_fh *, char *, int);
+__be32         nfsd_remove(struct svc_rqst *,
+                               struct svc_fh *, char *, int);
+__be32         nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type,
+                               char *name, int len);
+int            nfsd_truncate(struct svc_rqst *, struct svc_fh *,
+                               unsigned long size);
+__be32         nfsd_readdir(struct svc_rqst *, struct svc_fh *,
+                            loff_t *, struct readdir_cd *, filldir_t);
+__be32         nfsd_statfs(struct svc_rqst *, struct svc_fh *,
+                               struct kstatfs *, int access);
+
+int            nfsd_notify_change(struct inode *, struct iattr *);
+__be32         nfsd_permission(struct svc_rqst *, struct svc_export *,
+                               struct dentry *, int);
+int            nfsd_sync_dir(struct dentry *dp);
+
+#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
+struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int);
+int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *);
+#endif
+
+#endif /* LINUX_NFSD_VFS_H */
similarity index 96%
rename from include/linux/nfsd/xdr.h
rename to fs/nfsd/xdr.h
index a0132ef58f2128c9fe25f1412f9959355db92d58..53b1863dd8f67b2e86fda47490a773fa3b5d41f7 100644 (file)
@@ -1,15 +1,11 @@
-/*
- * linux/include/linux/nfsd/xdr.h
- *
- * XDR types for nfsd. This is mainly a typing exercise.
- */
+/* XDR types for nfsd. This is mainly a typing exercise. */
 
 #ifndef LINUX_NFSD_H
 #define LINUX_NFSD_H
 
-#include <linux/fs.h>
 #include <linux/vfs.h>
-#include <linux/nfs.h>
+#include "nfsd.h"
+#include "nfsfh.h"
 
 struct nfsd_fhandle {
        struct svc_fh           fh;
similarity index 99%
rename from include/linux/nfsd/xdr3.h
rename to fs/nfsd/xdr3.h
index 421eddd65a25a7968b8abe94d4f041e4f9aa0319..7df980eb05628789a336f0dea422c4ac49904609 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * linux/include/linux/nfsd/xdr3.h
- *
  * XDR types for NFSv3 in nfsd.
  *
  * Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de>
@@ -9,7 +7,7 @@
 #ifndef _LINUX_NFSD_XDR3_H
 #define _LINUX_NFSD_XDR3_H
 
-#include <linux/nfsd/xdr.h>
+#include "xdr.h"
 
 struct nfsd3_sattrargs {
        struct svc_fh           fh;
similarity index 99%
rename from include/linux/nfsd/xdr4.h
rename to fs/nfsd/xdr4.h
index 73164c2b3d295eeb339b71018ffdee4bb7126474..efa337739534c62f55ef834e1c9dd3721b232fbb 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  include/linux/nfsd/xdr4.h
- *
  *  Server-side types for NFSv4.
  *
  *  Copyright (c) 2002 The Regents of the University of Michigan.
@@ -39,7 +37,8 @@
 #ifndef _LINUX_NFSD_XDR4_H
 #define _LINUX_NFSD_XDR4_H
 
-#include <linux/nfs4.h>
+#include "state.h"
+#include "nfsd.h"
 
 #define NFSD4_MAX_TAGLEN       128
 #define XDR_LEN(n)                     (((n) + 3) & ~3)
index 5403b3ef3a42bd745b80b2e550a7f57a7c3d2c48..8173faee31e64b9ceacc91d3169d806a4ce22eab 100644 (file)
@@ -1118,8 +1118,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags,
        /* Abandoning the newly allocated superblock */
        mutex_unlock(&nilfs->ns_mount_mutex);
        put_nilfs(nilfs);
-       up_write(&s->s_umount);
-       deactivate_super(s);
+       deactivate_locked_super(s);
        /*
         * deactivate_super() invokes close_bdev_exclusive().
         * We must finish all post-cleaning before this call;
index 5ef5f365a5c86acb32813e7ff9b11d713f54f21b..8271cf05c9577856e427fcd8046be33497ba9265 100644 (file)
@@ -646,6 +646,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
        struct fsnotify_group *group;
        struct user_struct *user;
        struct file *filp;
+       struct path path;
        int fd, ret;
 
        /* Check the IN_* constants for consistency.  */
@@ -659,12 +660,6 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
        if (fd < 0)
                return fd;
 
-       filp = get_empty_filp();
-       if (!filp) {
-               ret = -ENFILE;
-               goto out_put_fd;
-       }
-
        user = get_current_user();
        if (unlikely(atomic_read(&user->inotify_devs) >=
                        inotify_max_user_instances)) {
@@ -679,24 +674,28 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
                goto out_free_uid;
        }
 
-       filp->f_op = &inotify_fops;
-       filp->f_path.mnt = mntget(inotify_mnt);
-       filp->f_path.dentry = dget(inotify_mnt->mnt_root);
-       filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping;
-       filp->f_mode = FMODE_READ;
+       atomic_inc(&user->inotify_devs);
+
+       path.mnt = inotify_mnt;
+       path.dentry = inotify_mnt->mnt_root;
+       path_get(&path);
+       filp = alloc_file(&path, FMODE_READ, &inotify_fops);
+       if (!filp)
+               goto Enfile;
+
        filp->f_flags = O_RDONLY | (flags & O_NONBLOCK);
        filp->private_data = group;
 
-       atomic_inc(&user->inotify_devs);
-
        fd_install(fd, filp);
 
        return fd;
 
+Enfile:
+       ret = -ENFILE;
+       path_put(&path);
+       atomic_dec(&user->inotify_devs);
 out_free_uid:
        free_uid(user);
-       put_filp(filp);
-out_put_fd:
        put_unused_fd(fd);
        return ret;
 }
index 9938034762cca7867007dc841af663b0f097c574..dc2505abb6d7fd4b513cf63c3429863511b70e1d 100644 (file)
@@ -530,7 +530,7 @@ err_corrupt_attr:
  * the ntfs inode.
  *
  * Q: What locks are held when the function is called?
- * A: i_state has I_LOCK set, hence the inode is locked, also
+ * A: i_state has I_NEW set, hence the inode is locked, also
  *    i_count is set to 1, so it is not going to go away
  *    i_flags is set to 0 and we have no business touching it.  Only an ioctl()
  *    is allowed to write to them. We should of course be honouring them but
@@ -1207,7 +1207,7 @@ err_out:
  * necessary fields in @vi as well as initializing the ntfs inode.
  *
  * Q: What locks are held when the function is called?
- * A: i_state has I_LOCK set, hence the inode is locked, also
+ * A: i_state has I_NEW set, hence the inode is locked, also
  *    i_count is set to 1, so it is not going to go away
  *
  * Return 0 on success and -errno on error.  In the error case, the inode will
@@ -1474,7 +1474,7 @@ err_out:
  * normal directory inodes.
  *
  * Q: What locks are held when the function is called?
- * A: i_state has I_LOCK set, hence the inode is locked, also
+ * A: i_state has I_NEW set, hence the inode is locked, also
  *    i_count is set to 1, so it is not going to go away
  *
  * Return 0 on success and -errno on error.  In the error case, the inode will
index 701b7a3a872e9e77cd4d8e09b306a6b5460a8501..0d840669698ea7584c5eb860a1430206e76712c1 100644 (file)
@@ -6,6 +6,7 @@ config OCFS2_FS
        select CRC32
        select QUOTA
        select QUOTA_TREE
+       select FS_POSIX_ACL
        help
          OCFS2 is a general purpose extent based shared disk cluster file
          system with many similarities to ext3. It supports 64 bit inode
@@ -74,12 +75,3 @@ config OCFS2_DEBUG_FS
          This option will enable expensive consistency checks. Enable
          this option for debugging only as it is likely to decrease
          performance of the filesystem.
-
-config OCFS2_FS_POSIX_ACL
-       bool "OCFS2 POSIX Access Control Lists"
-       depends on OCFS2_FS
-       select FS_POSIX_ACL
-       default n
-       help
-         Posix Access Control Lists (ACLs) support permissions for users and
-         groups beyond the owner/group/world scheme.
index 31f25ce32c977442b108b5be22db50cd2fcca094..600d2d2ade11b945e395458d820f546d6fe979e8 100644 (file)
@@ -39,11 +39,8 @@ ocfs2-objs := \
        ver.o                   \
        quota_local.o           \
        quota_global.o          \
-       xattr.o
-
-ifeq ($(CONFIG_OCFS2_FS_POSIX_ACL),y)
-ocfs2-objs += acl.o
-endif
+       xattr.o                 \
+       acl.o
 
 ocfs2_stackglue-objs := stackglue.o
 ocfs2_stack_o2cb-objs := stack_o2cb.o
index fbeaec762103a91eacd396f47a999244303954ee..0501974bedd0d3b96764b48b5725054fbe7ca412 100644 (file)
@@ -98,15 +98,11 @@ static struct posix_acl *ocfs2_get_acl_nolock(struct inode *inode,
                                              int type,
                                              struct buffer_head *di_bh)
 {
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        int name_index;
        char *value = NULL;
        struct posix_acl *acl;
        int retval;
 
-       if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
-               return NULL;
-
        switch (type) {
        case ACL_TYPE_ACCESS:
                name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -331,13 +327,14 @@ cleanup:
        return ret;
 }
 
-static size_t ocfs2_xattr_list_acl_access(struct inode *inode,
+static size_t ocfs2_xattr_list_acl_access(struct dentry *dentry,
                                          char *list,
                                          size_t list_len,
                                          const char *name,
-                                         size_t name_len)
+                                         size_t name_len,
+                                         int type)
 {
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
        const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
 
        if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
@@ -348,13 +345,14 @@ static size_t ocfs2_xattr_list_acl_access(struct inode *inode,
        return size;
 }
 
-static size_t ocfs2_xattr_list_acl_default(struct inode *inode,
+static size_t ocfs2_xattr_list_acl_default(struct dentry *dentry,
                                           char *list,
                                           size_t list_len,
                                           const char *name,
-                                          size_t name_len)
+                                          size_t name_len,
+                                          int type)
 {
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
        const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
 
        if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
@@ -365,19 +363,19 @@ static size_t ocfs2_xattr_list_acl_default(struct inode *inode,
        return size;
 }
 
-static int ocfs2_xattr_get_acl(struct inode *inode,
-                              int type,
-                              void *buffer,
-                              size_t size)
+static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
        struct posix_acl *acl;
        int ret;
 
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
        if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
                return -EOPNOTSUPP;
 
-       acl = ocfs2_get_acl(inode, type);
+       acl = ocfs2_get_acl(dentry->d_inode, type);
        if (IS_ERR(acl))
                return PTR_ERR(acl);
        if (acl == NULL)
@@ -388,35 +386,16 @@ static int ocfs2_xattr_get_acl(struct inode *inode,
        return ret;
 }
 
-static int ocfs2_xattr_get_acl_access(struct inode *inode,
-                                     const char *name,
-                                     void *buffer,
-                                     size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ocfs2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
-}
-
-static int ocfs2_xattr_get_acl_default(struct inode *inode,
-                                      const char *name,
-                                      void *buffer,
-                                      size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ocfs2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
-}
-
-static int ocfs2_xattr_set_acl(struct inode *inode,
-                              int type,
-                              const void *value,
-                              size_t size)
+static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
+       struct inode *inode = dentry->d_inode;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
        struct posix_acl *acl;
        int ret = 0;
 
+       if (strcmp(name, "") != 0)
+               return -EINVAL;
        if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
                return -EOPNOTSUPP;
 
@@ -442,38 +421,18 @@ cleanup:
        return ret;
 }
 
-static int ocfs2_xattr_set_acl_access(struct inode *inode,
-                                     const char *name,
-                                     const void *value,
-                                     size_t size,
-                                     int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ocfs2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
-}
-
-static int ocfs2_xattr_set_acl_default(struct inode *inode,
-                                      const char *name,
-                                      const void *value,
-                                      size_t size,
-                                      int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return ocfs2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
-}
-
 struct xattr_handler ocfs2_xattr_acl_access_handler = {
        .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags  = ACL_TYPE_ACCESS,
        .list   = ocfs2_xattr_list_acl_access,
-       .get    = ocfs2_xattr_get_acl_access,
-       .set    = ocfs2_xattr_set_acl_access,
+       .get    = ocfs2_xattr_get_acl,
+       .set    = ocfs2_xattr_set_acl,
 };
 
 struct xattr_handler ocfs2_xattr_acl_default_handler = {
        .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags  = ACL_TYPE_DEFAULT,
        .list   = ocfs2_xattr_list_acl_default,
-       .get    = ocfs2_xattr_get_acl_default,
-       .set    = ocfs2_xattr_set_acl_default,
+       .get    = ocfs2_xattr_get_acl,
+       .set    = ocfs2_xattr_set_acl,
 };
index 8f6389ed4da5ee03d3bc65831ff2b97a9ae3c59e..5c5d31f05853175476cc0c9ed4c2460c67f40da9 100644 (file)
@@ -26,8 +26,6 @@ struct ocfs2_acl_entry {
        __le32 e_id;
 };
 
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
-
 extern int ocfs2_check_acl(struct inode *, int);
 extern int ocfs2_acl_chmod(struct inode *);
 extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *,
@@ -35,24 +33,4 @@ extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *,
                          struct ocfs2_alloc_context *,
                          struct ocfs2_alloc_context *);
 
-#else /* CONFIG_OCFS2_FS_POSIX_ACL*/
-
-#define ocfs2_check_acl NULL
-static inline int ocfs2_acl_chmod(struct inode *inode)
-{
-       return 0;
-}
-static inline int ocfs2_init_acl(handle_t *handle,
-                                struct inode *inode,
-                                struct inode *dir,
-                                struct buffer_head *di_bh,
-                                struct buffer_head *dir_bh,
-                                struct ocfs2_alloc_context *meta_ac,
-                                struct ocfs2_alloc_context *data_ac)
-{
-       return 0;
-}
-
-#endif /* CONFIG_OCFS2_FS_POSIX_ACL*/
-
 #endif /* OCFS2_ACL_H */
index 7c7198a5bc9031ba7481c6ec1f1c682514a04256..d17bdc718f74b3820f0381ed770e85a86217c5e0 100644 (file)
@@ -1765,9 +1765,9 @@ set_and_inc:
  *
  * The array index of the subtree root is passed back.
  */
-static int ocfs2_find_subtree_root(struct ocfs2_extent_tree *et,
-                                  struct ocfs2_path *left,
-                                  struct ocfs2_path *right)
+int ocfs2_find_subtree_root(struct ocfs2_extent_tree *et,
+                           struct ocfs2_path *left,
+                           struct ocfs2_path *right)
 {
        int i = 0;
 
@@ -2872,8 +2872,8 @@ out:
  * This looks similar, but is subtly different to
  * ocfs2_find_cpos_for_left_leaf().
  */
-static int ocfs2_find_cpos_for_right_leaf(struct super_block *sb,
-                                         struct ocfs2_path *path, u32 *cpos)
+int ocfs2_find_cpos_for_right_leaf(struct super_block *sb,
+                                  struct ocfs2_path *path, u32 *cpos)
 {
        int i, j, ret = 0;
        u64 blkno;
@@ -7190,8 +7190,8 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle,
         * wait on them - the truncate_inode_pages() call later will
         * do that for us.
         */
-       ret = do_sync_mapping_range(inode->i_mapping, range_start,
-                                   range_end - 1, SYNC_FILE_RANGE_WRITE);
+       ret = filemap_fdatawrite_range(inode->i_mapping, range_start,
+                                      range_end - 1);
        if (ret)
                mlog_errno(ret);
 
index 9c122d574464284ef5c998e53f3685939c76213b..1db4359ccb90b61521a0167be7581eb91e823d83 100644 (file)
@@ -317,4 +317,9 @@ int ocfs2_path_bh_journal_access(handle_t *handle,
 int ocfs2_journal_access_path(struct ocfs2_caching_info *ci,
                              handle_t *handle,
                              struct ocfs2_path *path);
+int ocfs2_find_cpos_for_right_leaf(struct super_block *sb,
+                                  struct ocfs2_path *path, u32 *cpos);
+int ocfs2_find_subtree_root(struct ocfs2_extent_tree *et,
+                           struct ocfs2_path *left,
+                           struct ocfs2_path *right);
 #endif /* OCFS2_ALLOC_H */
index deb2b132ae5ed42b68fd11f58413f2ffa4779b83..3dae4a13f6e48c968dcad4ddcf28672c807068c6 100644 (file)
@@ -547,6 +547,9 @@ bail:
  *
  * called like this: dio->get_blocks(dio->inode, fs_startblk,
  *                                     fs_count, map_bh, dio->rw == WRITE);
+ *
+ * Note that we never bother to allocate blocks here, and thus ignore the
+ * create argument.
  */
 static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
                                     struct buffer_head *bh_result, int create)
@@ -563,14 +566,6 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
 
        inode_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
 
-       /*
-        * Any write past EOF is not allowed because we'd be extending.
-        */
-       if (create && (iblock + max_blocks) > inode_blocks) {
-               ret = -EIO;
-               goto bail;
-       }
-
        /* This figures out the size of the next contiguous block, and
         * our logical offset */
        ret = ocfs2_extent_map_get_blocks(inode, iblock, &p_blkno,
@@ -582,15 +577,6 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
                goto bail;
        }
 
-       if (!ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)) && !p_blkno && create) {
-               ocfs2_error(inode->i_sb,
-                           "Inode %llu has a hole at block %llu\n",
-                           (unsigned long long)OCFS2_I(inode)->ip_blkno,
-                           (unsigned long long)iblock);
-               ret = -EROFS;
-               goto bail;
-       }
-
        /* We should already CoW the refcounted extent. */
        BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED);
        /*
@@ -601,20 +587,8 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock,
         */
        if (p_blkno && !(ext_flags & OCFS2_EXT_UNWRITTEN))
                map_bh(bh_result, inode->i_sb, p_blkno);
-       else {
-               /*
-                * ocfs2_prepare_inode_for_write() should have caught
-                * the case where we'd be filling a hole and triggered
-                * a buffered write instead.
-                */
-               if (create) {
-                       ret = -EIO;
-                       mlog_errno(ret);
-                       goto bail;
-               }
-
+       else
                clear_buffer_mapped(bh_result);
-       }
 
        /* make sure we don't map more than max_blocks blocks here as
           that's all the kernel will handle at this point. */
index c452d116b89251690bcc393681340bf743a5ac20..eda5b8bcddd5db3a43a56a7965b9dffeeb193e16 100644 (file)
@@ -176,7 +176,8 @@ static void o2hb_write_timeout(struct work_struct *work)
 
 static void o2hb_arm_write_timeout(struct o2hb_region *reg)
 {
-       mlog(0, "Queue write timeout for %u ms\n", O2HB_MAX_WRITE_TIMEOUT_MS);
+       mlog(ML_HEARTBEAT, "Queue write timeout for %u ms\n",
+            O2HB_MAX_WRITE_TIMEOUT_MS);
 
        cancel_delayed_work(&reg->hr_write_timeout_work);
        reg->hr_last_timeout_start = jiffies;
@@ -874,7 +875,8 @@ static int o2hb_thread(void *data)
                do_gettimeofday(&after_hb);
                elapsed_msec = o2hb_elapsed_msecs(&before_hb, &after_hb);
 
-               mlog(0, "start = %lu.%lu, end = %lu.%lu, msec = %u\n",
+               mlog(ML_HEARTBEAT,
+                    "start = %lu.%lu, end = %lu.%lu, msec = %u\n",
                     before_hb.tv_sec, (unsigned long) before_hb.tv_usec,
                     after_hb.tv_sec, (unsigned long) after_hb.tv_usec,
                     elapsed_msec);
index 7ee6188bc79a76ebc939b738bcfc3914c99b3ef6..c81142e3ef844def09ef96725f2ebb68247aaecc 100644 (file)
  * cluster references throughout where nodes are looked up */
 struct o2nm_cluster *o2nm_single_cluster = NULL;
 
+char *o2nm_fence_method_desc[O2NM_FENCE_METHODS] = {
+               "reset",        /* O2NM_FENCE_RESET */
+               "panic",        /* O2NM_FENCE_PANIC */
+};
 
 struct o2nm_node *o2nm_get_node_by_num(u8 node_num)
 {
@@ -579,6 +583,43 @@ static ssize_t o2nm_cluster_attr_reconnect_delay_ms_write(
        return o2nm_cluster_attr_write(page, count,
                                       &cluster->cl_reconnect_delay_ms);
 }
+
+static ssize_t o2nm_cluster_attr_fence_method_read(
+       struct o2nm_cluster *cluster, char *page)
+{
+       ssize_t ret = 0;
+
+       if (cluster)
+               ret = sprintf(page, "%s\n",
+                             o2nm_fence_method_desc[cluster->cl_fence_method]);
+       return ret;
+}
+
+static ssize_t o2nm_cluster_attr_fence_method_write(
+       struct o2nm_cluster *cluster, const char *page, size_t count)
+{
+       unsigned int i;
+
+       if (page[count - 1] != '\n')
+               goto bail;
+
+       for (i = 0; i < O2NM_FENCE_METHODS; ++i) {
+               if (count != strlen(o2nm_fence_method_desc[i]) + 1)
+                       continue;
+               if (strncasecmp(page, o2nm_fence_method_desc[i], count - 1))
+                       continue;
+               if (cluster->cl_fence_method != i) {
+                       printk(KERN_INFO "ocfs2: Changing fence method to %s\n",
+                              o2nm_fence_method_desc[i]);
+                       cluster->cl_fence_method = i;
+               }
+               return count;
+       }
+
+bail:
+       return -EINVAL;
+}
+
 static struct o2nm_cluster_attribute o2nm_cluster_attr_idle_timeout_ms = {
        .attr   = { .ca_owner = THIS_MODULE,
                    .ca_name = "idle_timeout_ms",
@@ -603,10 +644,19 @@ static struct o2nm_cluster_attribute o2nm_cluster_attr_reconnect_delay_ms = {
        .store  = o2nm_cluster_attr_reconnect_delay_ms_write,
 };
 
+static struct o2nm_cluster_attribute o2nm_cluster_attr_fence_method = {
+       .attr   = { .ca_owner = THIS_MODULE,
+                   .ca_name = "fence_method",
+                   .ca_mode = S_IRUGO | S_IWUSR },
+       .show   = o2nm_cluster_attr_fence_method_read,
+       .store  = o2nm_cluster_attr_fence_method_write,
+};
+
 static struct configfs_attribute *o2nm_cluster_attrs[] = {
        &o2nm_cluster_attr_idle_timeout_ms.attr,
        &o2nm_cluster_attr_keepalive_delay_ms.attr,
        &o2nm_cluster_attr_reconnect_delay_ms.attr,
+       &o2nm_cluster_attr_fence_method.attr,
        NULL,
 };
 static ssize_t o2nm_cluster_show(struct config_item *item,
@@ -778,6 +828,7 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
        cluster->cl_reconnect_delay_ms = O2NET_RECONNECT_DELAY_MS_DEFAULT;
        cluster->cl_idle_timeout_ms    = O2NET_IDLE_TIMEOUT_MS_DEFAULT;
        cluster->cl_keepalive_delay_ms = O2NET_KEEPALIVE_DELAY_MS_DEFAULT;
+       cluster->cl_fence_method       = O2NM_FENCE_RESET;
 
        ret = &cluster->cl_group;
        o2nm_single_cluster = cluster;
index c992ea0da4add8295528b2e8b02c907ab9337df0..09ea2d388bbb564e176155057b64b989314ef2a0 100644 (file)
 #include <linux/configfs.h>
 #include <linux/rbtree.h>
 
+enum o2nm_fence_method {
+       O2NM_FENCE_RESET        = 0,
+       O2NM_FENCE_PANIC,
+       O2NM_FENCE_METHODS,     /* Number of fence methods */
+};
+
 struct o2nm_node {
        spinlock_t              nd_lock;
        struct config_item      nd_item;
@@ -58,6 +64,7 @@ struct o2nm_cluster {
        unsigned int            cl_idle_timeout_ms;
        unsigned int            cl_keepalive_delay_ms;
        unsigned int            cl_reconnect_delay_ms;
+       enum o2nm_fence_method  cl_fence_method;
 
        /* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */
        unsigned long   cl_nodes_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
index bbacf7da48a4ea9d3fb3df86c86e6b6ccc843a44..639024033fceeea6cc5978bcdcf3c3a65f216986 100644 (file)
@@ -74,8 +74,20 @@ static void o2quo_fence_self(void)
         * threads can still schedule, etc, etc */
        o2hb_stop_all_regions();
 
-       printk("ocfs2 is very sorry to be fencing this system by restarting\n");
-       emergency_restart();
+       switch (o2nm_single_cluster->cl_fence_method) {
+       case O2NM_FENCE_PANIC:
+               panic("*** ocfs2 is very sorry to be fencing this system by "
+                     "panicing ***\n");
+               break;
+       default:
+               WARN_ON(o2nm_single_cluster->cl_fence_method >=
+                       O2NM_FENCE_METHODS);
+       case O2NM_FENCE_RESET:
+               printk(KERN_ERR "*** ocfs2 is very sorry to be fencing this "
+                      "system by restarting ***\n");
+               emergency_restart();
+               break;
+       };
 }
 
 /* Indicate that a timeout occured on a hearbeat region write. The
index d9fa3d22e17c6d27134327d3fd96199038913ed0..2f9e4e19a4f2a3ca95bc82607ce369fd1dd43b59 100644 (file)
@@ -2589,6 +2589,14 @@ retry:
                             "begin reco msg (%d)\n", dlm->name, nodenum, ret);
                        ret = 0;
                }
+               if (ret == -EAGAIN) {
+                       mlog(0, "%s: trying to start recovery of node "
+                            "%u, but node %u is waiting for last recovery "
+                            "to complete, backoff for a bit\n", dlm->name,
+                            dead_node, nodenum);
+                       msleep(100);
+                       goto retry;
+               }
                if (ret < 0) {
                        struct dlm_lock_resource *res;
                        /* this is now a serious problem, possibly ENOMEM 
@@ -2608,14 +2616,6 @@ retry:
                         * another ENOMEM */
                        msleep(100);
                        goto retry;
-               } else if (ret == EAGAIN) {
-                       mlog(0, "%s: trying to start recovery of node "
-                            "%u, but node %u is waiting for last recovery "
-                            "to complete, backoff for a bit\n", dlm->name,
-                            dead_node, nodenum);
-                       /* TODO Look into replacing msleep with cond_resched() */
-                       msleep(100);
-                       goto retry;
                }
        }
 
@@ -2639,7 +2639,7 @@ int dlm_begin_reco_handler(struct o2net_msg *msg, u32 len, void *data,
                     dlm->name, br->node_idx, br->dead_node,
                     dlm->reco.dead_node, dlm->reco.new_master);
                spin_unlock(&dlm->spinlock);
-               return EAGAIN;
+               return -EAGAIN;
        }
        spin_unlock(&dlm->spinlock);
 
index 843db64e9d4ae9d5b9a353a3e7b3d001c3456297..d35a27f4523e13e2ec00411e08e6ebb2e1afbf76 100644 (file)
@@ -37,6 +37,7 @@
 #include "extent_map.h"
 #include "inode.h"
 #include "super.h"
+#include "symlink.h"
 
 #include "buffer_head_io.h"
 
@@ -703,6 +704,12 @@ out:
        return ret;
 }
 
+/*
+ * The ocfs2_fiemap_inline() may be a little bit misleading, since
+ * it not only handles the fiemap for inlined files, but also deals
+ * with the fast symlink, cause they have no difference for extent
+ * mapping per se.
+ */
 static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh,
                               struct fiemap_extent_info *fieinfo,
                               u64 map_start)
@@ -715,11 +722,18 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh,
        struct ocfs2_inode_info *oi = OCFS2_I(inode);
 
        di = (struct ocfs2_dinode *)di_bh->b_data;
-       id_count = le16_to_cpu(di->id2.i_data.id_count);
+       if (ocfs2_inode_is_fast_symlink(inode))
+               id_count = ocfs2_fast_symlink_chars(inode->i_sb);
+       else
+               id_count = le16_to_cpu(di->id2.i_data.id_count);
 
        if (map_start < id_count) {
                phys = oi->ip_blkno << inode->i_sb->s_blocksize_bits;
-               phys += offsetof(struct ocfs2_dinode, id2.i_data.id_data);
+               if (ocfs2_inode_is_fast_symlink(inode))
+                       phys += offsetof(struct ocfs2_dinode, id2.i_symlink);
+               else
+                       phys += offsetof(struct ocfs2_dinode,
+                                        id2.i_data.id_data);
 
                ret = fiemap_fill_next_extent(fieinfo, 0, phys, id_count,
                                              flags);
@@ -756,9 +770,10 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
        down_read(&OCFS2_I(inode)->ip_alloc_sem);
 
        /*
-        * Handle inline-data separately.
+        * Handle inline-data and fast symlink separately.
         */
-       if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
+       if ((OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) ||
+           ocfs2_inode_is_fast_symlink(inode)) {
                ret = ocfs2_fiemap_inline(inode, di_bh, fieinfo, map_start);
                goto out_unlock;
        }
@@ -786,6 +801,8 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                fe_flags = 0;
                if (rec.e_flags & OCFS2_EXT_UNWRITTEN)
                        fe_flags |= FIEMAP_EXTENT_UNWRITTEN;
+               if (rec.e_flags & OCFS2_EXT_REFCOUNTED)
+                       fe_flags |= FIEMAP_EXTENT_SHARED;
                if (is_last)
                        fe_flags |= FIEMAP_EXTENT_LAST;
                len_bytes = (u64)le16_to_cpu(rec.e_leaf_clusters) << osb->s_clustersize_bits;
index f010b22b1c4412046a56c24c100efdf032ddf52d..50fb26a6a5f55f88a93c84e29b9d4386e181cbdb 100644 (file)
@@ -2108,6 +2108,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
        }
        did_quota_inode = 1;
 
+       inode->i_nlink = 0;
        /* do the real work now. */
        status = ocfs2_mknod_locked(osb, dir, inode,
                                    0, &new_di_bh, parent_di_bh, handle,
@@ -2136,6 +2137,7 @@ int ocfs2_create_inode_in_orphan(struct inode *dir,
        if (status < 0)
                mlog_errno(status);
 
+       insert_inode_hash(inode);
 leave:
        if (status < 0 && did_quota_inode)
                vfs_dq_free_inode(inode);
@@ -2267,6 +2269,8 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
        di = (struct ocfs2_dinode *)di_bh->b_data;
        le32_add_cpu(&di->i_flags, -OCFS2_ORPHANED_FL);
        di->i_orphaned_slot = 0;
+       inode->i_nlink = 1;
+       ocfs2_set_links_count(di, inode->i_nlink);
        ocfs2_journal_dirty(handle, di_bh);
 
        status = ocfs2_add_entry(handle, dentry, inode,
@@ -2284,7 +2288,6 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
                goto out_commit;
        }
 
-       insert_inode_hash(inode);
        dentry->d_op = &ocfs2_dentry_ops;
        d_instantiate(dentry, inode);
        status = 0;
@@ -2326,4 +2329,5 @@ const struct inode_operations ocfs2_dir_iops = {
        .getxattr       = generic_getxattr,
        .listxattr      = ocfs2_listxattr,
        .removexattr    = generic_removexattr,
+       .fiemap         = ocfs2_fiemap,
 };
index d963d863870994075b8af17c84484c09cb0b84d8..9362eea7424be2421b461b76032d85733573c731 100644 (file)
@@ -245,9 +245,11 @@ enum ocfs2_mount_options
        OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */
        OCFS2_MOUNT_NOUSERXATTR = 1 << 6, /* No user xattr */
        OCFS2_MOUNT_INODE64 = 1 << 7,   /* Allow inode numbers > 2^32 */
-       OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* POSIX access control lists */
-       OCFS2_MOUNT_USRQUOTA = 1 << 9, /* We support user quotas */
-       OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
+       OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* Force POSIX access control lists */
+       OCFS2_MOUNT_NO_POSIX_ACL = 1 << 9,      /* Disable POSIX access
+                                                  control lists */
+       OCFS2_MOUNT_USRQUOTA = 1 << 10, /* We support user quotas */
+       OCFS2_MOUNT_GRPQUOTA = 1 << 11, /* We support group quotas */
 };
 
 #define OCFS2_OSB_SOFT_RO                      0x0001
index e9431e4a5e7cf16f2e4bf299ed0866392d6bf361..1a1a679e51b5dd235a8bef0d45212fb8626eae9b 100644 (file)
@@ -1202,7 +1202,7 @@ struct ocfs2_local_disk_dqinfo {
 /* Header of one chunk of a quota file */
 struct ocfs2_local_disk_chunk {
        __le32 dqc_free;        /* Number of free entries in the bitmap */
-       u8 dqc_bitmap[0];       /* Bitmap of entries in the corresponding
+       __u8 dqc_bitmap[0];     /* Bitmap of entries in the corresponding
                                 * chunk of quota file */
 };
 
index 30967e3f5e43175ed54f44f62b91bfb70f4eef55..74db2be75dd686220913207662dd0c04ea7c755d 100644 (file)
@@ -276,7 +276,7 @@ static void ocfs2_erase_refcount_tree_from_list(struct ocfs2_super *osb,
        spin_unlock(&osb->osb_lock);
 }
 
-void ocfs2_kref_remove_refcount_tree(struct kref *kref)
+static void ocfs2_kref_remove_refcount_tree(struct kref *kref)
 {
        struct ocfs2_refcount_tree *tree =
                container_of(kref, struct ocfs2_refcount_tree, rf_getcnt);
@@ -524,23 +524,6 @@ out:
        return ret;
 }
 
-int ocfs2_lock_refcount_tree_by_inode(struct inode *inode, int rw,
-                                     struct ocfs2_refcount_tree **ret_tree,
-                                     struct buffer_head **ref_bh)
-{
-       int ret;
-       u64 ref_blkno;
-
-       ret = ocfs2_get_refcount_block(inode, &ref_blkno);
-       if (ret) {
-               mlog_errno(ret);
-               return ret;
-       }
-
-       return ocfs2_lock_refcount_tree(OCFS2_SB(inode->i_sb), ref_blkno,
-                                       rw, ret_tree, ref_bh);
-}
-
 void ocfs2_unlock_refcount_tree(struct ocfs2_super *osb,
                                struct ocfs2_refcount_tree *tree, int rw)
 {
@@ -968,6 +951,103 @@ out:
        return 0;
 }
 
+/*
+ * Find the end range for a leaf refcount block indicated by
+ * el->l_recs[index].e_blkno.
+ */
+static int ocfs2_get_refcount_cpos_end(struct ocfs2_caching_info *ci,
+                                      struct buffer_head *ref_root_bh,
+                                      struct ocfs2_extent_block *eb,
+                                      struct ocfs2_extent_list *el,
+                                      int index,  u32 *cpos_end)
+{
+       int ret, i, subtree_root;
+       u32 cpos;
+       u64 blkno;
+       struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
+       struct ocfs2_path *left_path = NULL, *right_path = NULL;
+       struct ocfs2_extent_tree et;
+       struct ocfs2_extent_list *tmp_el;
+
+       if (index < le16_to_cpu(el->l_next_free_rec) - 1) {
+               /*
+                * We have a extent rec after index, so just use the e_cpos
+                * of the next extent rec.
+                */
+               *cpos_end = le32_to_cpu(el->l_recs[index+1].e_cpos);
+               return 0;
+       }
+
+       if (!eb || (eb && !eb->h_next_leaf_blk)) {
+               /*
+                * We are the last extent rec, so any high cpos should
+                * be stored in this leaf refcount block.
+                */
+               *cpos_end = UINT_MAX;
+               return 0;
+       }
+
+       /*
+        * If the extent block isn't the last one, we have to find
+        * the subtree root between this extent block and the next
+        * leaf extent block and get the corresponding e_cpos from
+        * the subroot. Otherwise we may corrupt the b-tree.
+        */
+       ocfs2_init_refcount_extent_tree(&et, ci, ref_root_bh);
+
+       left_path = ocfs2_new_path_from_et(&et);
+       if (!left_path) {
+               ret = -ENOMEM;
+               mlog_errno(ret);
+               goto out;
+       }
+
+       cpos = le32_to_cpu(eb->h_list.l_recs[index].e_cpos);
+       ret = ocfs2_find_path(ci, left_path, cpos);
+       if (ret) {
+               mlog_errno(ret);
+               goto out;
+       }
+
+       right_path = ocfs2_new_path_from_path(left_path);
+       if (!right_path) {
+               ret = -ENOMEM;
+               mlog_errno(ret);
+               goto out;
+       }
+
+       ret = ocfs2_find_cpos_for_right_leaf(sb, left_path, &cpos);
+       if (ret) {
+               mlog_errno(ret);
+               goto out;
+       }
+
+       ret = ocfs2_find_path(ci, right_path, cpos);
+       if (ret) {
+               mlog_errno(ret);
+               goto out;
+       }
+
+       subtree_root = ocfs2_find_subtree_root(&et, left_path,
+                                              right_path);
+
+       tmp_el = left_path->p_node[subtree_root].el;
+       blkno = left_path->p_node[subtree_root+1].bh->b_blocknr;
+       for (i = 0; i < le32_to_cpu(tmp_el->l_next_free_rec); i++) {
+               if (le64_to_cpu(tmp_el->l_recs[i].e_blkno) == blkno) {
+                       *cpos_end = le32_to_cpu(tmp_el->l_recs[i+1].e_cpos);
+                       break;
+               }
+       }
+
+       BUG_ON(i == le32_to_cpu(tmp_el->l_next_free_rec));
+
+out:
+       ocfs2_free_path(left_path);
+       ocfs2_free_path(right_path);
+       return ret;
+}
+
 /*
  * Given a cpos and len, try to find the refcount record which contains cpos.
  * 1. If cpos can be found in one refcount record, return the record.
@@ -983,10 +1063,10 @@ static int ocfs2_get_refcount_rec(struct ocfs2_caching_info *ci,
                                  struct buffer_head **ret_bh)
 {
        int ret = 0, i, found;
-       u32 low_cpos;
+       u32 low_cpos, uninitialized_var(cpos_end);
        struct ocfs2_extent_list *el;
-       struct ocfs2_extent_rec *tmp, *rec = NULL;
-       struct ocfs2_extent_block *eb;
+       struct ocfs2_extent_rec *rec = NULL;
+       struct ocfs2_extent_block *eb = NULL;
        struct buffer_head *eb_bh = NULL, *ref_leaf_bh = NULL;
        struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
        struct ocfs2_refcount_block *rb =
@@ -1034,12 +1114,16 @@ static int ocfs2_get_refcount_rec(struct ocfs2_caching_info *ci,
                }
        }
 
-       /* adjust len when we have ocfs2_extent_rec after it. */
-       if (found && i < le16_to_cpu(el->l_next_free_rec) - 1) {
-               tmp = &el->l_recs[i+1];
+       if (found) {
+               ret = ocfs2_get_refcount_cpos_end(ci, ref_root_bh,
+                                                 eb, el, i, &cpos_end);
+               if (ret) {
+                       mlog_errno(ret);
+                       goto out;
+               }
 
-               if (le32_to_cpu(tmp->e_cpos) < cpos + len)
-                       len = le32_to_cpu(tmp->e_cpos) - cpos;
+               if (cpos_end < low_cpos + len)
+                       len = cpos_end - low_cpos;
        }
 
        ret = ocfs2_read_refcount_block(ci, le64_to_cpu(rec->e_blkno),
@@ -1418,7 +1502,7 @@ static int ocfs2_divide_leaf_refcount_block(struct buffer_head *ref_leaf_bh,
 
        /* change old and new rl_used accordingly. */
        le16_add_cpu(&rl->rl_used, -num_moved);
-       new_rl->rl_used = cpu_to_le32(num_moved);
+       new_rl->rl_used = cpu_to_le16(num_moved);
 
        sort(&rl->rl_recs, le16_to_cpu(rl->rl_used),
             sizeof(struct ocfs2_refcount_rec),
@@ -1797,7 +1881,8 @@ static int ocfs2_split_refcount_rec(handle_t *handle,
                recs_need++;
 
        /* If the leaf block don't have enough record, expand it. */
-       if (le16_to_cpu(rf_list->rl_used) + recs_need > rf_list->rl_count) {
+       if (le16_to_cpu(rf_list->rl_used) + recs_need >
+                                        le16_to_cpu(rf_list->rl_count)) {
                struct ocfs2_refcount_rec tmp_rec;
                u64 cpos = le64_to_cpu(orig_rec->r_cpos);
                len = le32_to_cpu(orig_rec->r_clusters);
@@ -1859,7 +1944,7 @@ static int ocfs2_split_refcount_rec(handle_t *handle,
                memcpy(tail_rec, orig_rec, sizeof(struct ocfs2_refcount_rec));
                le64_add_cpu(&tail_rec->r_cpos,
                             le32_to_cpu(tail_rec->r_clusters) - len);
-               tail_rec->r_clusters = le32_to_cpu(len);
+               tail_rec->r_clusters = cpu_to_le32(len);
        }
 
        /*
@@ -3840,8 +3925,7 @@ static int ocfs2_add_refcounted_extent(struct inode *inode,
        }
 
        ret = ocfs2_insert_extent(handle, et, cpos,
-                       cpu_to_le64(ocfs2_clusters_to_blocks(inode->i_sb,
-                                                            p_cluster)),
+                       ocfs2_clusters_to_blocks(inode->i_sb, p_cluster),
                        num_clusters, ext_flags, meta_ac);
        if (ret) {
                mlog_errno(ret);
@@ -4253,8 +4337,8 @@ static int ocfs2_user_path_parent(const char __user *path,
  * @new_dentry:        target dentry
  * @preserve:  if true, preserve all file attributes
  */
-int ocfs2_vfs_reflink(struct dentry *old_dentry, struct inode *dir,
-                     struct dentry *new_dentry, bool preserve)
+static int ocfs2_vfs_reflink(struct dentry *old_dentry, struct inode *dir,
+                            struct dentry *new_dentry, bool preserve)
 {
        struct inode *inode = old_dentry->d_inode;
        int error;
index ff4c798a5635f23d64739356b2fc8277c370e1b9..da78a2a334fdfcf486df2724acd3352deff58cb2 100644 (file)
@@ -814,7 +814,7 @@ static int fs_protocol_compare(struct ocfs2_protocol_version *existing,
 static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 {
        dlm_lockspace_t *fsdlm;
-       struct ocfs2_live_connection *control;
+       struct ocfs2_live_connection *uninitialized_var(control);
        int rc = 0;
 
        BUG_ON(conn == NULL);
index 14f47d2bfe02eb6500666e8a63a227a2d4ee10f2..26069917a9f51752a18c8dea60940d0b00ca1054 100644 (file)
@@ -100,6 +100,8 @@ struct mount_options
 static int ocfs2_parse_options(struct super_block *sb, char *options,
                               struct mount_options *mopt,
                               int is_remount);
+static int ocfs2_check_set_options(struct super_block *sb,
+                                  struct mount_options *options);
 static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt);
 static void ocfs2_put_super(struct super_block *sb);
 static int ocfs2_mount_volume(struct super_block *sb);
@@ -600,7 +602,8 @@ static int ocfs2_remount(struct super_block *sb, int *flags, char *data)
 
        lock_kernel();
 
-       if (!ocfs2_parse_options(sb, data, &parsed_options, 1)) {
+       if (!ocfs2_parse_options(sb, data, &parsed_options, 1) ||
+           !ocfs2_check_set_options(sb, &parsed_options)) {
                ret = -EINVAL;
                goto out;
        }
@@ -691,8 +694,6 @@ unlock_osb:
        if (!ret) {
                /* Only save off the new mount options in case of a successful
                 * remount. */
-               if (!(osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_XATTR))
-                       parsed_options.mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
                osb->s_mount_opt = parsed_options.mount_opt;
                osb->s_atime_quantum = parsed_options.atime_quantum;
                osb->preferred_slot = parsed_options.slot;
@@ -701,6 +702,10 @@ unlock_osb:
 
                if (!ocfs2_is_hard_readonly(osb))
                        ocfs2_set_journal_params(osb);
+
+               sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
+                       ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) ?
+                                                       MS_POSIXACL : 0);
        }
 out:
        unlock_kernel();
@@ -1011,31 +1016,16 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
        brelse(bh);
        bh = NULL;
 
-       if (!(osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_XATTR))
-               parsed_options.mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
-
+       if (!ocfs2_check_set_options(sb, &parsed_options)) {
+               status = -EINVAL;
+               goto read_super_error;
+       }
        osb->s_mount_opt = parsed_options.mount_opt;
        osb->s_atime_quantum = parsed_options.atime_quantum;
        osb->preferred_slot = parsed_options.slot;
        osb->osb_commit_interval = parsed_options.commit_interval;
        osb->local_alloc_default_bits = ocfs2_megabytes_to_clusters(sb, parsed_options.localalloc_opt);
        osb->local_alloc_bits = osb->local_alloc_default_bits;
-       if (osb->s_mount_opt & OCFS2_MOUNT_USRQUOTA &&
-           !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
-                                        OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
-               status = -EINVAL;
-               mlog(ML_ERROR, "User quotas were requested, but this "
-                    "filesystem does not have the feature enabled.\n");
-               goto read_super_error;
-       }
-       if (osb->s_mount_opt & OCFS2_MOUNT_GRPQUOTA &&
-           !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
-                                        OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
-               status = -EINVAL;
-               mlog(ML_ERROR, "Group quotas were requested, but this "
-                    "filesystem does not have the feature enabled.\n");
-               goto read_super_error;
-       }
 
        status = ocfs2_verify_userspace_stack(osb, &parsed_options);
        if (status)
@@ -1245,6 +1235,40 @@ static struct file_system_type ocfs2_fs_type = {
        .next           = NULL
 };
 
+static int ocfs2_check_set_options(struct super_block *sb,
+                                  struct mount_options *options)
+{
+       if (options->mount_opt & OCFS2_MOUNT_USRQUOTA &&
+           !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
+                                        OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
+               mlog(ML_ERROR, "User quotas were requested, but this "
+                    "filesystem does not have the feature enabled.\n");
+               return 0;
+       }
+       if (options->mount_opt & OCFS2_MOUNT_GRPQUOTA &&
+           !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
+                                        OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
+               mlog(ML_ERROR, "Group quotas were requested, but this "
+                    "filesystem does not have the feature enabled.\n");
+               return 0;
+       }
+       if (options->mount_opt & OCFS2_MOUNT_POSIX_ACL &&
+           !OCFS2_HAS_INCOMPAT_FEATURE(sb, OCFS2_FEATURE_INCOMPAT_XATTR)) {
+               mlog(ML_ERROR, "ACL support requested but extended attributes "
+                    "feature is not enabled\n");
+               return 0;
+       }
+       /* No ACL setting specified? Use XATTR feature... */
+       if (!(options->mount_opt & (OCFS2_MOUNT_POSIX_ACL |
+                                   OCFS2_MOUNT_NO_POSIX_ACL))) {
+               if (OCFS2_HAS_INCOMPAT_FEATURE(sb, OCFS2_FEATURE_INCOMPAT_XATTR))
+                       options->mount_opt |= OCFS2_MOUNT_POSIX_ACL;
+               else
+                       options->mount_opt |= OCFS2_MOUNT_NO_POSIX_ACL;
+       }
+       return 1;
+}
+
 static int ocfs2_parse_options(struct super_block *sb,
                               char *options,
                               struct mount_options *mopt,
@@ -1392,40 +1416,19 @@ static int ocfs2_parse_options(struct super_block *sb,
                        mopt->mount_opt |= OCFS2_MOUNT_INODE64;
                        break;
                case Opt_usrquota:
-                       /* We check only on remount, otherwise features
-                        * aren't yet initialized. */
-                       if (is_remount && !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
-                           OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
-                               mlog(ML_ERROR, "User quota requested but "
-                                    "filesystem feature is not set\n");
-                               status = 0;
-                               goto bail;
-                       }
                        mopt->mount_opt |= OCFS2_MOUNT_USRQUOTA;
                        break;
                case Opt_grpquota:
-                       if (is_remount && !OCFS2_HAS_RO_COMPAT_FEATURE(sb,
-                           OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
-                               mlog(ML_ERROR, "Group quota requested but "
-                                    "filesystem feature is not set\n");
-                               status = 0;
-                               goto bail;
-                       }
                        mopt->mount_opt |= OCFS2_MOUNT_GRPQUOTA;
                        break;
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
                case Opt_acl:
                        mopt->mount_opt |= OCFS2_MOUNT_POSIX_ACL;
+                       mopt->mount_opt &= ~OCFS2_MOUNT_NO_POSIX_ACL;
                        break;
                case Opt_noacl:
+                       mopt->mount_opt |= OCFS2_MOUNT_NO_POSIX_ACL;
                        mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL;
                        break;
-#else
-               case Opt_acl:
-               case Opt_noacl:
-                       printk(KERN_INFO "ocfs2 (no)acl options not supported\n");
-                       break;
-#endif
                default:
                        mlog(ML_ERROR,
                             "Unrecognized mount option \"%s\" "
@@ -1502,12 +1505,10 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
        if (opts & OCFS2_MOUNT_INODE64)
                seq_printf(s, ",inode64");
 
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
        if (opts & OCFS2_MOUNT_POSIX_ACL)
                seq_printf(s, ",acl");
        else
                seq_printf(s, ",noacl");
-#endif
 
        return 0;
 }
index e3421030a69f713971a78e7d5d525098a4e44416..49b133ccbf113f79a62b58298b2e65405f3e4601 100644 (file)
@@ -163,6 +163,7 @@ const struct inode_operations ocfs2_symlink_inode_operations = {
        .getxattr       = generic_getxattr,
        .listxattr      = ocfs2_listxattr,
        .removexattr    = generic_removexattr,
+       .fiemap         = ocfs2_fiemap,
 };
 const struct inode_operations ocfs2_fast_symlink_inode_operations = {
        .readlink       = ocfs2_readlink,
@@ -174,4 +175,5 @@ const struct inode_operations ocfs2_fast_symlink_inode_operations = {
        .getxattr       = generic_getxattr,
        .listxattr      = ocfs2_listxattr,
        .removexattr    = generic_removexattr,
+       .fiemap         = ocfs2_fiemap,
 };
index fe3419068df2efa5ed33ff7cdc424327d04431f0..8fc6fb071c6d13c33dd24401a13308ab737e0b1a 100644 (file)
@@ -98,10 +98,8 @@ static struct ocfs2_xattr_def_value_root def_xv = {
 
 struct xattr_handler *ocfs2_xattr_handlers[] = {
        &ocfs2_xattr_user_handler,
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
        &ocfs2_xattr_acl_access_handler,
        &ocfs2_xattr_acl_default_handler,
-#endif
        &ocfs2_xattr_trusted_handler,
        &ocfs2_xattr_security_handler,
        NULL
@@ -109,12 +107,10 @@ struct xattr_handler *ocfs2_xattr_handlers[] = {
 
 static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = {
        [OCFS2_XATTR_INDEX_USER]        = &ocfs2_xattr_user_handler,
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
        [OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS]
                                        = &ocfs2_xattr_acl_access_handler,
        [OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT]
                                        = &ocfs2_xattr_acl_default_handler,
-#endif
        [OCFS2_XATTR_INDEX_TRUSTED]     = &ocfs2_xattr_trusted_handler,
        [OCFS2_XATTR_INDEX_SECURITY]    = &ocfs2_xattr_security_handler,
 };
@@ -205,8 +201,6 @@ static int ocfs2_get_xattr_tree_value_root(struct super_block *sb,
                                           int offset,
                                           struct ocfs2_xattr_value_root **xv,
                                           struct buffer_head **bh);
-static int ocfs2_xattr_security_set(struct inode *inode, const char *name,
-                                   const void *value, size_t size, int flags);
 
 static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb)
 {
@@ -6066,7 +6060,7 @@ static int ocfs2_value_metas_in_xattr_header(struct super_block *sb,
                 * to the extent block, so just calculate a maximum record num.
                 */
                if (!xv->xr_list.l_tree_depth)
-                       *num_recs += xv->xr_list.l_next_free_rec;
+                       *num_recs += le16_to_cpu(xv->xr_list.l_next_free_rec);
                else
                        *num_recs += ocfs2_clusters_for_bytes(sb,
                                                              XATTR_SIZE_MAX);
@@ -6978,9 +6972,9 @@ int ocfs2_init_security_and_acl(struct inode *dir,
 
        ret = ocfs2_init_security_get(inode, dir, &si);
        if (!ret) {
-               ret = ocfs2_xattr_security_set(inode, si.name,
-                                              si.value, si.value_len,
-                                              XATTR_CREATE);
+               ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY,
+                                     si.name, si.value, si.value_len,
+                                     XATTR_CREATE);
                if (ret) {
                        mlog_errno(ret);
                        goto leave;
@@ -7008,9 +7002,9 @@ leave:
 /*
  * 'security' attributes support
  */
-static size_t ocfs2_xattr_security_list(struct inode *inode, char *list,
+static size_t ocfs2_xattr_security_list(struct dentry *dentry, char *list,
                                        size_t list_size, const char *name,
-                                       size_t name_len)
+                                       size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
@@ -7023,23 +7017,23 @@ static size_t ocfs2_xattr_security_list(struct inode *inode, char *list,
        return total_len;
 }
 
-static int ocfs2_xattr_security_get(struct inode *inode, const char *name,
-                                   void *buffer, size_t size)
+static int ocfs2_xattr_security_get(struct dentry *dentry, const char *name,
+                                   void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY, name,
-                              buffer, size);
+       return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY,
+                              name, buffer, size);
 }
 
-static int ocfs2_xattr_security_set(struct inode *inode, const char *name,
-                                   const void *value, size_t size, int flags)
+static int ocfs2_xattr_security_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
 
-       return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, name, value,
-                              size, flags);
+       return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY,
+                              name, value, size, flags);
 }
 
 int ocfs2_init_security_get(struct inode *inode,
@@ -7076,9 +7070,9 @@ struct xattr_handler ocfs2_xattr_security_handler = {
 /*
  * 'trusted' attributes support
  */
-static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
+static size_t ocfs2_xattr_trusted_list(struct dentry *dentry, char *list,
                                       size_t list_size, const char *name,
-                                      size_t name_len)
+                                      size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
@@ -7091,23 +7085,23 @@ static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list,
        return total_len;
 }
 
-static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name,
-                                  void *buffer, size_t size)
+static int ocfs2_xattr_trusted_get(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name,
-                              buffer, size);
+       return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED,
+                              name, buffer, size);
 }
 
-static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name,
-                                  const void *value, size_t size, int flags)
+static int ocfs2_xattr_trusted_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
 
-       return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value,
-                              size, flags);
+       return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED,
+                              name, value, size, flags);
 }
 
 struct xattr_handler ocfs2_xattr_trusted_handler = {
@@ -7120,13 +7114,13 @@ struct xattr_handler ocfs2_xattr_trusted_handler = {
 /*
  * 'user' attributes support
  */
-static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
+static size_t ocfs2_xattr_user_list(struct dentry *dentry, char *list,
                                    size_t list_size, const char *name,
-                                   size_t name_len)
+                                   size_t name_len, int type)
 {
        const size_t prefix_len = XATTR_USER_PREFIX_LEN;
        const size_t total_len = prefix_len + name_len + 1;
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
 
        if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
                return 0;
@@ -7139,31 +7133,31 @@ static size_t ocfs2_xattr_user_list(struct inode *inode, char *list,
        return total_len;
 }
 
-static int ocfs2_xattr_user_get(struct inode *inode, const char *name,
-                               void *buffer, size_t size)
+static int ocfs2_xattr_user_get(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int type)
 {
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
 
        if (strcmp(name, "") == 0)
                return -EINVAL;
        if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
                return -EOPNOTSUPP;
-       return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name,
+       return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_USER, name,
                               buffer, size);
 }
 
-static int ocfs2_xattr_user_set(struct inode *inode, const char *name,
-                               const void *value, size_t size, int flags)
+static int ocfs2_xattr_user_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
-       struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+       struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
 
        if (strcmp(name, "") == 0)
                return -EINVAL;
        if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR)
                return -EOPNOTSUPP;
 
-       return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value,
-                              size, flags);
+       return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_USER,
+                              name, value, size, flags);
 }
 
 struct xattr_handler ocfs2_xattr_user_handler = {
index 08e36389f56d025858dc377d0294911682e657fe..abd72a47f5209b31809f1c51b74bb1f3f93175be 100644 (file)
@@ -40,10 +40,8 @@ struct ocfs2_security_xattr_info {
 extern struct xattr_handler ocfs2_xattr_user_handler;
 extern struct xattr_handler ocfs2_xattr_trusted_handler;
 extern struct xattr_handler ocfs2_xattr_security_handler;
-#ifdef CONFIG_OCFS2_FS_POSIX_ACL
 extern struct xattr_handler ocfs2_xattr_acl_access_handler;
 extern struct xattr_handler ocfs2_xattr_acl_default_handler;
-#endif
 extern struct xattr_handler *ocfs2_xattr_handlers[];
 
 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
index b4b31d277f3aa537efe1ebaa9d847dca86835214..040cef72bc00e46a0c58790f1c18cef7722756c8 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -30,6 +30,9 @@
 #include <linux/audit.h>
 #include <linux/falloc.h>
 #include <linux/fs_struct.h>
+#include <linux/ima.h>
+
+#include "internal.h"
 
 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
@@ -818,15 +821,14 @@ static inline int __get_file_write_access(struct inode *inode,
 }
 
 static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
-                                       int flags, struct file *f,
+                                       struct file *f,
                                        int (*open)(struct inode *, struct file *),
                                        const struct cred *cred)
 {
        struct inode *inode;
        int error;
 
-       f->f_flags = flags;
-       f->f_mode = (__force fmode_t)((flags+1) & O_ACCMODE) | FMODE_LSEEK |
+       f->f_mode = OPEN_FMODE(f->f_flags) | FMODE_LSEEK |
                                FMODE_PREAD | FMODE_PWRITE;
        inode = dentry->d_inode;
        if (f->f_mode & FMODE_WRITE) {
@@ -855,6 +857,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
                if (error)
                        goto cleanup_all;
        }
+       ima_counts_get(f);
 
        f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
 
@@ -926,7 +929,6 @@ struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry
        if (IS_ERR(dentry))
                goto out_err;
        nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt),
-                                            nd->intent.open.flags - 1,
                                             nd->intent.open.file,
                                             open, cred);
 out:
@@ -945,7 +947,7 @@ EXPORT_SYMBOL_GPL(lookup_instantiate_filp);
  *
  * Note that this function destroys the original nameidata
  */
-struct file *nameidata_to_filp(struct nameidata *nd, int flags)
+struct file *nameidata_to_filp(struct nameidata *nd)
 {
        const struct cred *cred = current_cred();
        struct file *filp;
@@ -954,7 +956,7 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags)
        filp = nd->intent.open.file;
        /* Has the filesystem initialised the file for us? */
        if (filp->f_path.dentry == NULL)
-               filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp,
+               filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp,
                                     NULL, cred);
        else
                path_put(&nd->path);
@@ -993,7 +995,8 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags,
                return ERR_PTR(error);
        }
 
-       return __dentry_open(dentry, mnt, flags, f, NULL, cred);
+       f->f_flags = flags;
+       return __dentry_open(dentry, mnt, f, NULL, cred);
 }
 EXPORT_SYMBOL(dentry_open);
 
index ae17d026aaa3f496fc0bf9d8522f52d027d8dadb..37ba29ff3158aca16ff0febd65fdb3cce24152d6 100644 (file)
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -906,17 +906,6 @@ void free_pipe_info(struct inode *inode)
 }
 
 static struct vfsmount *pipe_mnt __read_mostly;
-static int pipefs_delete_dentry(struct dentry *dentry)
-{
-       /*
-        * At creation time, we pretended this dentry was hashed
-        * (by clearing DCACHE_UNHASHED bit in d_flags)
-        * At delete time, we restore the truth : not hashed.
-        * (so that dput() can proceed correctly)
-        */
-       dentry->d_flags |= DCACHE_UNHASHED;
-       return 0;
-}
 
 /*
  * pipefs_dname() is called from d_path().
@@ -928,7 +917,6 @@ static char *pipefs_dname(struct dentry *dentry, char *buffer, int buflen)
 }
 
 static const struct dentry_operations pipefs_dentry_operations = {
-       .d_delete       = pipefs_delete_dentry,
        .d_dname        = pipefs_dname,
 };
 
@@ -974,7 +962,7 @@ struct file *create_write_pipe(int flags)
        int err;
        struct inode *inode;
        struct file *f;
-       struct dentry *dentry;
+       struct path path;
        struct qstr name = { .name = "" };
 
        err = -ENFILE;
@@ -983,21 +971,16 @@ struct file *create_write_pipe(int flags)
                goto err;
 
        err = -ENOMEM;
-       dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name);
-       if (!dentry)
+       path.dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name);
+       if (!path.dentry)
                goto err_inode;
+       path.mnt = mntget(pipe_mnt);
 
-       dentry->d_op = &pipefs_dentry_operations;
-       /*
-        * We dont want to publish this dentry into global dentry hash table.
-        * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
-        * This permits a working /proc/$pid/fd/XXX on pipes
-        */
-       dentry->d_flags &= ~DCACHE_UNHASHED;
-       d_instantiate(dentry, inode);
+       path.dentry->d_op = &pipefs_dentry_operations;
+       d_instantiate(path.dentry, inode);
 
        err = -ENFILE;
-       f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops);
+       f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops);
        if (!f)
                goto err_dentry;
        f->f_mapping = inode->i_mapping;
@@ -1009,7 +992,7 @@ struct file *create_write_pipe(int flags)
 
  err_dentry:
        free_pipe_info(inode);
-       dput(dentry);
+       path_put(&path);
        return ERR_PTR(err);
 
  err_inode:
@@ -1028,20 +1011,14 @@ void free_write_pipe(struct file *f)
 
 struct file *create_read_pipe(struct file *wrf, int flags)
 {
-       struct file *f = get_empty_filp();
+       /* Grab pipe from the writer */
+       struct file *f = alloc_file(&wrf->f_path, FMODE_READ,
+                                   &read_pipefifo_fops);
        if (!f)
                return ERR_PTR(-ENFILE);
 
-       /* Grab pipe from the writer */
-       f->f_path = wrf->f_path;
        path_get(&wrf->f_path);
-       f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping;
-
-       f->f_pos = 0;
        f->f_flags = O_RDONLY | (flags & O_NONBLOCK);
-       f->f_op = &read_pipefifo_fops;
-       f->f_mode = FMODE_READ;
-       f->f_version = 0;
 
        return f;
 }
index 4badde179b18ff8d1a3c5406dc393227b30918f1..f560325c444f0c10e6258ce7c5d9836c58d703b9 100644 (file)
@@ -134,13 +134,16 @@ static inline void task_name(struct seq_file *m, struct task_struct *p)
  * simple bit tests.
  */
 static const char *task_state_array[] = {
-       "R (running)",          /*  0 */
-       "S (sleeping)",         /*  1 */
-       "D (disk sleep)",       /*  2 */
-       "T (stopped)",          /*  4 */
-       "T (tracing stop)",     /*  8 */
-       "Z (zombie)",           /* 16 */
-       "X (dead)"              /* 32 */
+       "R (running)",          /*   0 */
+       "S (sleeping)",         /*   1 */
+       "D (disk sleep)",       /*   2 */
+       "T (stopped)",          /*   4 */
+       "t (tracing stop)",     /*   8 */
+       "Z (zombie)",           /*  16 */
+       "X (dead)",             /*  32 */
+       "x (dead)",             /*  64 */
+       "K (wakekill)",         /* 128 */
+       "W (waking)",           /* 256 */
 };
 
 static inline const char *get_task_state(struct task_struct *tsk)
@@ -148,6 +151,8 @@ static inline const char *get_task_state(struct task_struct *tsk)
        unsigned int state = (tsk->state & TASK_REPORT) | tsk->exit_state;
        const char **p = &task_state_array[0];
 
+       BUILD_BUG_ON(1 + ilog2(TASK_STATE_MAX) != ARRAY_SIZE(task_state_array));
+
        while (state) {
                p++;
                state >>= 1;
index af643b5aefe8909e25b1f741ad1b24a5f53f7a81..18d5cc62d8ed92ebefb2a85cb26642ecc78d796d 100644 (file)
@@ -1265,6 +1265,72 @@ static const struct file_operations proc_pid_sched_operations = {
 
 #endif
 
+static ssize_t comm_write(struct file *file, const char __user *buf,
+                               size_t count, loff_t *offset)
+{
+       struct inode *inode = file->f_path.dentry->d_inode;
+       struct task_struct *p;
+       char buffer[TASK_COMM_LEN];
+
+       memset(buffer, 0, sizeof(buffer));
+       if (count > sizeof(buffer) - 1)
+               count = sizeof(buffer) - 1;
+       if (copy_from_user(buffer, buf, count))
+               return -EFAULT;
+
+       p = get_proc_task(inode);
+       if (!p)
+               return -ESRCH;
+
+       if (same_thread_group(current, p))
+               set_task_comm(p, buffer);
+       else
+               count = -EINVAL;
+
+       put_task_struct(p);
+
+       return count;
+}
+
+static int comm_show(struct seq_file *m, void *v)
+{
+       struct inode *inode = m->private;
+       struct task_struct *p;
+
+       p = get_proc_task(inode);
+       if (!p)
+               return -ESRCH;
+
+       task_lock(p);
+       seq_printf(m, "%s\n", p->comm);
+       task_unlock(p);
+
+       put_task_struct(p);
+
+       return 0;
+}
+
+static int comm_open(struct inode *inode, struct file *filp)
+{
+       int ret;
+
+       ret = single_open(filp, comm_show, NULL);
+       if (!ret) {
+               struct seq_file *m = filp->private_data;
+
+               m->private = inode;
+       }
+       return ret;
+}
+
+static const struct file_operations proc_pid_set_comm_operations = {
+       .open           = comm_open,
+       .read           = seq_read,
+       .write          = comm_write,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 /*
  * We added or removed a vma mapping the executable. The vmas are only mapped
  * during exec and are not mapped with the mmap system call.
@@ -2200,7 +2266,7 @@ static const struct inode_operations proc_attr_dir_inode_operations = {
 
 #endif
 
-#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
+#ifdef CONFIG_ELF_CORE
 static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
                                         size_t count, loff_t *ppos)
 {
@@ -2504,6 +2570,7 @@ static const struct pid_entry tgid_base_stuff[] = {
 #ifdef CONFIG_SCHED_DEBUG
        REG("sched",      S_IRUGO|S_IWUSR, proc_pid_sched_operations),
 #endif
+       REG("comm",      S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
 #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
        INF("syscall",    S_IRUSR, proc_pid_syscall),
 #endif
@@ -2556,7 +2623,7 @@ static const struct pid_entry tgid_base_stuff[] = {
 #ifdef CONFIG_FAULT_INJECTION
        REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations),
 #endif
-#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
+#ifdef CONFIG_ELF_CORE
        REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations),
 #endif
 #ifdef CONFIG_TASK_IO_ACCOUNTING
@@ -2838,6 +2905,7 @@ static const struct pid_entry tid_base_stuff[] = {
 #ifdef CONFIG_SCHED_DEBUG
        REG("sched",     S_IRUGO|S_IWUSR, proc_pid_sched_operations),
 #endif
+       REG("comm",      S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
 #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
        INF("syscall",   S_IRUSR, proc_pid_syscall),
 #endif
index fa678abc9db1524c35cd543c9b32a1b49e713faf..480cb1065eec8a65d9224075ffc66858dd4d738f 100644 (file)
@@ -429,7 +429,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
                        unsigned int ino;
 
                        ino = de->low_ino;
-                       de_get(de);
+                       pde_get(de);
                        spin_unlock(&proc_subdir_lock);
                        error = -EINVAL;
                        inode = proc_get_inode(dir->i_sb, ino, de);
@@ -445,7 +445,7 @@ out_unlock:
                return NULL;
        }
        if (de)
-               de_put(de);
+               pde_put(de);
        return ERR_PTR(error);
 }
 
@@ -509,17 +509,17 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
                                struct proc_dir_entry *next;
 
                                /* filldir passes info to user space */
-                               de_get(de);
+                               pde_get(de);
                                spin_unlock(&proc_subdir_lock);
                                if (filldir(dirent, de->name, de->namelen, filp->f_pos,
                                            de->low_ino, de->mode >> 12) < 0) {
-                                       de_put(de);
+                                       pde_put(de);
                                        goto out;
                                }
                                spin_lock(&proc_subdir_lock);
                                filp->f_pos++;
                                next = de->next;
-                               de_put(de);
+                               pde_put(de);
                                de = next;
                        } while (de);
                        spin_unlock(&proc_subdir_lock);
@@ -763,7 +763,7 @@ out:
        return NULL;
 }
 
-void free_proc_entry(struct proc_dir_entry *de)
+static void free_proc_entry(struct proc_dir_entry *de)
 {
        unsigned int ino = de->low_ino;
 
@@ -777,6 +777,12 @@ void free_proc_entry(struct proc_dir_entry *de)
        kfree(de);
 }
 
+void pde_put(struct proc_dir_entry *pde)
+{
+       if (atomic_dec_and_test(&pde->count))
+               free_proc_entry(pde);
+}
+
 /*
  * Remove a /proc entry and free it if it's not currently in use.
  */
@@ -845,6 +851,5 @@ continue_removing:
        WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory "
                        "'%s/%s', leaking at least '%s'\n", __func__,
                        de->parent->name, de->name, de->subdir->name);
-       if (atomic_dec_and_test(&de->count))
-               free_proc_entry(de);
+       pde_put(de);
 }
index d78ade305541d84a0a7b7682f203cd649c1e5a6a..445a02bcaab31d88963e1d0c7deeeb25572efb97 100644 (file)
 
 #include "internal.h"
 
-struct proc_dir_entry *de_get(struct proc_dir_entry *de)
-{
-       atomic_inc(&de->count);
-       return de;
-}
-
-/*
- * Decrements the use count and checks for deferred deletion.
- */
-void de_put(struct proc_dir_entry *de)
-{
-       if (!atomic_read(&de->count)) {
-               printk("de_put: entry %s already free!\n", de->name);
-               return;
-       }
-
-       if (atomic_dec_and_test(&de->count))
-               free_proc_entry(de);
-}
-
-/*
- * Decrement the use count of the proc_dir_entry.
- */
 static void proc_delete_inode(struct inode *inode)
 {
        struct proc_dir_entry *de;
@@ -59,7 +36,7 @@ static void proc_delete_inode(struct inode *inode)
        /* Let go of any associated proc directory entry */
        de = PROC_I(inode)->pde;
        if (de)
-               de_put(de);
+               pde_put(de);
        if (PROC_I(inode)->sysctl)
                sysctl_head_put(PROC_I(inode)->sysctl);
        clear_inode(inode);
@@ -480,7 +457,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
                }
                unlock_new_inode(inode);
        } else
-              de_put(de);
+              pde_put(de);
        return inode;
 }                      
 
@@ -495,7 +472,7 @@ int proc_fill_super(struct super_block *s)
        s->s_op = &proc_sops;
        s->s_time_gran = 1;
        
-       de_get(&proc_root);
+       pde_get(&proc_root);
        root_inode = proc_get_inode(s, PROC_ROOT_INO, &proc_root);
        if (!root_inode)
                goto out_no_root;
@@ -509,6 +486,6 @@ int proc_fill_super(struct super_block *s)
 out_no_root:
        printk("proc_read_super: get root inode failed\n");
        iput(root_inode);
-       de_put(&proc_root);
+       pde_put(&proc_root);
        return -ENOMEM;
 }
index 753ca37002c8cb1c912648efa609224bb2482ef2..1f24a3eddd122aae276efd1809a5983cf282a69e 100644 (file)
@@ -61,8 +61,6 @@ extern const struct file_operations proc_pagemap_operations;
 extern const struct file_operations proc_net_operations;
 extern const struct inode_operations proc_net_inode_operations;
 
-void free_proc_entry(struct proc_dir_entry *de);
-
 void proc_init_inodecache(void);
 
 static inline struct pid *proc_pid(struct inode *inode)
@@ -101,8 +99,12 @@ unsigned long task_vsize(struct mm_struct *);
 int task_statm(struct mm_struct *, int *, int *, int *, int *);
 void task_mem(struct seq_file *, struct mm_struct *);
 
-struct proc_dir_entry *de_get(struct proc_dir_entry *de);
-void de_put(struct proc_dir_entry *de);
+static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
+{
+       atomic_inc(&pde->count);
+       return pde;
+}
+void pde_put(struct proc_dir_entry *pde);
 
 extern struct vfsmount *proc_mnt;
 int proc_fill_super(struct super_block *);
index 5033ce0d254b90dcd0ca19162c6cbe9df254c87d..180cf5a0bd67119218c170b265cf944c103b889b 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/hugetlb.h>
+#include <linux/kernel-page-flags.h>
 #include <asm/uaccess.h>
 #include "internal.h"
 
@@ -71,52 +72,12 @@ static const struct file_operations proc_kpagecount_operations = {
  * physical page flags.
  */
 
-/* These macros are used to decouple internal flags from exported ones */
-
-#define KPF_LOCKED             0
-#define KPF_ERROR              1
-#define KPF_REFERENCED         2
-#define KPF_UPTODATE           3
-#define KPF_DIRTY              4
-#define KPF_LRU                        5
-#define KPF_ACTIVE             6
-#define KPF_SLAB               7
-#define KPF_WRITEBACK          8
-#define KPF_RECLAIM            9
-#define KPF_BUDDY              10
-
-/* 11-20: new additions in 2.6.31 */
-#define KPF_MMAP               11
-#define KPF_ANON               12
-#define KPF_SWAPCACHE          13
-#define KPF_SWAPBACKED         14
-#define KPF_COMPOUND_HEAD      15
-#define KPF_COMPOUND_TAIL      16
-#define KPF_HUGE               17
-#define KPF_UNEVICTABLE                18
-#define KPF_HWPOISON           19
-#define KPF_NOPAGE             20
-
-#define KPF_KSM                        21
-
-/* kernel hacking assistances
- * WARNING: subject to change, never rely on them!
- */
-#define KPF_RESERVED           32
-#define KPF_MLOCKED            33
-#define KPF_MAPPEDTODISK       34
-#define KPF_PRIVATE            35
-#define KPF_PRIVATE_2          36
-#define KPF_OWNER_PRIVATE      37
-#define KPF_ARCH               38
-#define KPF_UNCACHED           39
-
 static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit)
 {
        return ((kflags >> kbit) & 1) << ubit;
 }
 
-static u64 get_uflags(struct page *page)
+u64 stable_page_flags(struct page *page)
 {
        u64 k;
        u64 u;
@@ -219,7 +180,7 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
                else
                        ppage = NULL;
 
-               if (put_user(get_uflags(ppage), out)) {
+               if (put_user(stable_page_flags(ppage), out)) {
                        ret = -EFAULT;
                        break;
                }
index 2a1bef9203c6e73734e7fa359873bbb45456d0ae..47c03f4336b843ed1ba9a7f28b3f4824e1c663d1 100644 (file)
@@ -650,6 +650,50 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
        return err;
 }
 
+static u64 huge_pte_to_pagemap_entry(pte_t pte, int offset)
+{
+       u64 pme = 0;
+       if (pte_present(pte))
+               pme = PM_PFRAME(pte_pfn(pte) + offset)
+                       | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT;
+       return pme;
+}
+
+static int pagemap_hugetlb_range(pte_t *pte, unsigned long addr,
+                                unsigned long end, struct mm_walk *walk)
+{
+       struct vm_area_struct *vma;
+       struct pagemapread *pm = walk->private;
+       struct hstate *hs = NULL;
+       int err = 0;
+
+       vma = find_vma(walk->mm, addr);
+       if (vma)
+               hs = hstate_vma(vma);
+       for (; addr != end; addr += PAGE_SIZE) {
+               u64 pfn = PM_NOT_PRESENT;
+
+               if (vma && (addr >= vma->vm_end)) {
+                       vma = find_vma(walk->mm, addr);
+                       if (vma)
+                               hs = hstate_vma(vma);
+               }
+
+               if (vma && (vma->vm_start <= addr) && is_vm_hugetlb_page(vma)) {
+                       /* calculate pfn of the "raw" page in the hugepage. */
+                       int offset = (addr & ~huge_page_mask(hs)) >> PAGE_SHIFT;
+                       pfn = huge_pte_to_pagemap_entry(*pte, offset);
+               }
+               err = add_to_pagemap(addr, pfn, pm);
+               if (err)
+                       return err;
+       }
+
+       cond_resched();
+
+       return err;
+}
+
 /*
  * /proc/pid/pagemap - an array mapping virtual pages to pfns
  *
@@ -742,6 +786,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
 
        pagemap_walk.pmd_entry = pagemap_pte_range;
        pagemap_walk.pte_hole = pagemap_pte_hole;
+       pagemap_walk.hugetlb_entry = pagemap_hugetlb_range;
        pagemap_walk.mm = mm;
        pagemap_walk.private = &pm;
 
index 8f5c05d3dbd3e2aaa4abcd3fcc92af79e324daca..5d9fd64ef81a9ad76b1525943cc34a79b0a6a33d 100644 (file)
@@ -110,9 +110,13 @@ int task_statm(struct mm_struct *mm, int *shared, int *text,
                }
        }
 
-       size += (*text = mm->end_code - mm->start_code);
-       size += (*data = mm->start_stack - mm->start_data);
+       *text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
+               >> PAGE_SHIFT;
+       *data = (PAGE_ALIGN(mm->start_stack) - (mm->start_data & PAGE_MASK))
+               >> PAGE_SHIFT;
        up_read(&mm->mmap_sem);
+       size >>= PAGE_SHIFT;
+       size += *text + *data;
        *resident = size;
        return size;
 }
index 32f5d131a6441c694ba41304fc28a673744365aa..22e0d60e53efbe3072ade881ec69251062df83c9 100644 (file)
 #include <linux/bitops.h>
 #include "qnx4.h"
 
-#if 0
-int qnx4_new_block(struct super_block *sb)
-{
-       return 0;
-}
-#endif  /*  0  */
-
 static void count_bits(register const char *bmPart, register int size,
                       int *const tf)
 {
@@ -35,22 +28,7 @@ static void count_bits(register const char *bmPart, register int size,
        }
        do {
                b = *bmPart++;
-               if ((b & 1) == 0)
-                       tot++;
-               if ((b & 2) == 0)
-                       tot++;
-               if ((b & 4) == 0)
-                       tot++;
-               if ((b & 8) == 0)
-                       tot++;
-               if ((b & 16) == 0)
-                       tot++;
-               if ((b & 32) == 0)
-                       tot++;
-               if ((b & 64) == 0)
-                       tot++;
-               if ((b & 128) == 0)
-                       tot++;
+               tot += 8 - hweight8(b);
                size--;
        } while (size != 0);
        *tf = tot;
index 449f5a66dd34e5650ab8639ff148509244b0d4dd..ebf3440d28cae26df7fcff9f7d1da3c6b897bc3e 100644 (file)
@@ -64,25 +64,7 @@ static struct buffer_head *qnx4_getblk(struct inode *inode, int nr,
                result = sb_getblk(inode->i_sb, nr);
                return result;
        }
-       if (!create) {
-               return NULL;
-       }
-#if 0
-       tmp = qnx4_new_block(inode->i_sb);
-       if (!tmp) {
-               return NULL;
-       }
-       result = sb_getblk(inode->i_sb, tmp);
-       if (tst) {
-               qnx4_free_block(inode->i_sb, tmp);
-               brelse(result);
-               goto repeat;
-       }
-       tst = tmp;
-#endif
-       inode->i_ctime = CURRENT_TIME_SEC;
-       mark_inode_dirty(inode);
-       return result;
+       return NULL;
 }
 
 struct buffer_head *qnx4_bread(struct inode *inode, int block, int create)
@@ -113,8 +95,6 @@ static int qnx4_get_block( struct inode *inode, sector_t iblock, struct buffer_h
        if ( phys ) {
                // logical block is before EOF
                map_bh(bh, inode->i_sb, phys);
-       } else if ( create ) {
-               // to be done.
        }
        return 0;
 }
index cd6bb9a33c131f3ab2ee5cb7d4654069777f3ad6..dea86abdf2e7fe8ca6589dc0ba22210357a28d01 100644 (file)
@@ -323,6 +323,30 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
 }
 EXPORT_SYMBOL(dquot_mark_dquot_dirty);
 
+/* Dirtify all the dquots - this can block when journalling */
+static inline int mark_all_dquot_dirty(struct dquot * const *dquot)
+{
+       int ret, err, cnt;
+
+       ret = err = 0;
+       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
+               if (dquot[cnt])
+                       /* Even in case of error we have to continue */
+                       ret = mark_dquot_dirty(dquot[cnt]);
+               if (!err)
+                       err = ret;
+       }
+       return err;
+}
+
+static inline void dqput_all(struct dquot **dquot)
+{
+       unsigned int cnt;
+
+       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
+               dqput(dquot[cnt]);
+}
+
 /* This function needs dq_list_lock */
 static inline int clear_dquot_dirty(struct dquot *dquot)
 {
@@ -1268,8 +1292,7 @@ int dquot_initialize(struct inode *inode, int type)
 out_err:
        up_write(&sb_dqopt(sb)->dqptr_sem);
        /* Drop unused references */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-               dqput(got[cnt]);
+       dqput_all(got);
        return ret;
 }
 EXPORT_SYMBOL(dquot_initialize);
@@ -1288,9 +1311,7 @@ int dquot_drop(struct inode *inode)
                inode->i_dquot[cnt] = NULL;
        }
        up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
-
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-               dqput(put[cnt]);
+       dqput_all(put);
        return 0;
 }
 EXPORT_SYMBOL(dquot_drop);
@@ -1318,6 +1339,67 @@ void vfs_dq_drop(struct inode *inode)
 }
 EXPORT_SYMBOL(vfs_dq_drop);
 
+/*
+ * inode_reserved_space is managed internally by quota, and protected by
+ * i_lock similar to i_blocks+i_bytes.
+ */
+static qsize_t *inode_reserved_space(struct inode * inode)
+{
+       /* Filesystem must explicitly define it's own method in order to use
+        * quota reservation interface */
+       BUG_ON(!inode->i_sb->dq_op->get_reserved_space);
+       return inode->i_sb->dq_op->get_reserved_space(inode);
+}
+
+static void inode_add_rsv_space(struct inode *inode, qsize_t number)
+{
+       spin_lock(&inode->i_lock);
+       *inode_reserved_space(inode) += number;
+       spin_unlock(&inode->i_lock);
+}
+
+
+static void inode_claim_rsv_space(struct inode *inode, qsize_t number)
+{
+       spin_lock(&inode->i_lock);
+       *inode_reserved_space(inode) -= number;
+       __inode_add_bytes(inode, number);
+       spin_unlock(&inode->i_lock);
+}
+
+static void inode_sub_rsv_space(struct inode *inode, qsize_t number)
+{
+       spin_lock(&inode->i_lock);
+       *inode_reserved_space(inode) -= number;
+       spin_unlock(&inode->i_lock);
+}
+
+static qsize_t inode_get_rsv_space(struct inode *inode)
+{
+       qsize_t ret;
+       spin_lock(&inode->i_lock);
+       ret = *inode_reserved_space(inode);
+       spin_unlock(&inode->i_lock);
+       return ret;
+}
+
+static void inode_incr_space(struct inode *inode, qsize_t number,
+                               int reserve)
+{
+       if (reserve)
+               inode_add_rsv_space(inode, number);
+       else
+               inode_add_bytes(inode, number);
+}
+
+static void inode_decr_space(struct inode *inode, qsize_t number, int reserve)
+{
+       if (reserve)
+               inode_sub_rsv_space(inode, number);
+       else
+               inode_sub_bytes(inode, number);
+}
+
 /*
  * Following four functions update i_blocks+i_bytes fields and
  * quota information (together with appropriate checks)
@@ -1336,6 +1418,21 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number,
        int cnt, ret = QUOTA_OK;
        char warntype[MAXQUOTAS];
 
+       /*
+        * First test before acquiring mutex - solves deadlocks when we
+        * re-enter the quota code and are already holding the mutex
+        */
+       if (IS_NOQUOTA(inode)) {
+               inode_incr_space(inode, number, reserve);
+               goto out;
+       }
+
+       down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
+       if (IS_NOQUOTA(inode)) {
+               inode_incr_space(inode, number, reserve);
+               goto out_unlock;
+       }
+
        for (cnt = 0; cnt < MAXQUOTAS; cnt++)
                warntype[cnt] = QUOTA_NL_NOWARN;
 
@@ -1346,7 +1443,8 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number,
                if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt)
                    == NO_QUOTA) {
                        ret = NO_QUOTA;
-                       goto out_unlock;
+                       spin_unlock(&dq_data_lock);
+                       goto out_flush_warn;
                }
        }
        for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
@@ -1357,64 +1455,29 @@ int __dquot_alloc_space(struct inode *inode, qsize_t number,
                else
                        dquot_incr_space(inode->i_dquot[cnt], number);
        }
-       if (!reserve)
-               inode_add_bytes(inode, number);
-out_unlock:
+       inode_incr_space(inode, number, reserve);
        spin_unlock(&dq_data_lock);
+
+       if (reserve)
+               goto out_flush_warn;
+       mark_all_dquot_dirty(inode->i_dquot);
+out_flush_warn:
        flush_warnings(inode->i_dquot, warntype);
+out_unlock:
+       up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
+out:
        return ret;
 }
 
 int dquot_alloc_space(struct inode *inode, qsize_t number, int warn)
 {
-       int cnt, ret = QUOTA_OK;
-
-       /*
-        * First test before acquiring mutex - solves deadlocks when we
-        * re-enter the quota code and are already holding the mutex
-        */
-       if (IS_NOQUOTA(inode)) {
-               inode_add_bytes(inode, number);
-               goto out;
-       }
-
-       down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-       if (IS_NOQUOTA(inode)) {
-               inode_add_bytes(inode, number);
-               goto out_unlock;
-       }
-
-       ret = __dquot_alloc_space(inode, number, warn, 0);
-       if (ret == NO_QUOTA)
-               goto out_unlock;
-
-       /* Dirtify all the dquots - this can block when journalling */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-               if (inode->i_dquot[cnt])
-                       mark_dquot_dirty(inode->i_dquot[cnt]);
-out_unlock:
-       up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-out:
-       return ret;
+       return __dquot_alloc_space(inode, number, warn, 0);
 }
 EXPORT_SYMBOL(dquot_alloc_space);
 
 int dquot_reserve_space(struct inode *inode, qsize_t number, int warn)
 {
-       int ret = QUOTA_OK;
-
-       if (IS_NOQUOTA(inode))
-               goto out;
-
-       down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-       if (IS_NOQUOTA(inode))
-               goto out_unlock;
-
-       ret = __dquot_alloc_space(inode, number, warn, 1);
-out_unlock:
-       up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-out:
-       return ret;
+       return __dquot_alloc_space(inode, number, warn, 1);
 }
 EXPORT_SYMBOL(dquot_reserve_space);
 
@@ -1455,10 +1518,7 @@ int dquot_alloc_inode(const struct inode *inode, qsize_t number)
 warn_put_all:
        spin_unlock(&dq_data_lock);
        if (ret == QUOTA_OK)
-               /* Dirtify all the dquots - this can block when journalling */
-               for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-                       if (inode->i_dquot[cnt])
-                               mark_dquot_dirty(inode->i_dquot[cnt]);
+               mark_all_dquot_dirty(inode->i_dquot);
        flush_warnings(inode->i_dquot, warntype);
        up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
        return ret;
@@ -1471,14 +1531,14 @@ int dquot_claim_space(struct inode *inode, qsize_t number)
        int ret = QUOTA_OK;
 
        if (IS_NOQUOTA(inode)) {
-               inode_add_bytes(inode, number);
+               inode_claim_rsv_space(inode, number);
                goto out;
        }
 
        down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
        if (IS_NOQUOTA(inode))  {
                up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-               inode_add_bytes(inode, number);
+               inode_claim_rsv_space(inode, number);
                goto out;
        }
 
@@ -1490,51 +1550,19 @@ int dquot_claim_space(struct inode *inode, qsize_t number)
                                                        number);
        }
        /* Update inode bytes */
-       inode_add_bytes(inode, number);
+       inode_claim_rsv_space(inode, number);
        spin_unlock(&dq_data_lock);
-       /* Dirtify all the dquots - this can block when journalling */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-               if (inode->i_dquot[cnt])
-                       mark_dquot_dirty(inode->i_dquot[cnt]);
+       mark_all_dquot_dirty(inode->i_dquot);
        up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
 out:
        return ret;
 }
 EXPORT_SYMBOL(dquot_claim_space);
 
-/*
- * Release reserved quota space
- */
-void dquot_release_reserved_space(struct inode *inode, qsize_t number)
-{
-       int cnt;
-
-       if (IS_NOQUOTA(inode))
-               goto out;
-
-       down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-       if (IS_NOQUOTA(inode))
-               goto out_unlock;
-
-       spin_lock(&dq_data_lock);
-       /* Release reserved dquots */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-               if (inode->i_dquot[cnt])
-                       dquot_free_reserved_space(inode->i_dquot[cnt], number);
-       }
-       spin_unlock(&dq_data_lock);
-
-out_unlock:
-       up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
-out:
-       return;
-}
-EXPORT_SYMBOL(dquot_release_reserved_space);
-
 /*
  * This operation can block, but only after everything is updated
  */
-int dquot_free_space(struct inode *inode, qsize_t number)
+int __dquot_free_space(struct inode *inode, qsize_t number, int reserve)
 {
        unsigned int cnt;
        char warntype[MAXQUOTAS];
@@ -1543,7 +1571,7 @@ int dquot_free_space(struct inode *inode, qsize_t number)
          * re-enter the quota code and are already holding the mutex */
        if (IS_NOQUOTA(inode)) {
 out_sub:
-               inode_sub_bytes(inode, number);
+               inode_decr_space(inode, number, reserve);
                return QUOTA_OK;
        }
 
@@ -1558,20 +1586,39 @@ out_sub:
                if (!inode->i_dquot[cnt])
                        continue;
                warntype[cnt] = info_bdq_free(inode->i_dquot[cnt], number);
-               dquot_decr_space(inode->i_dquot[cnt], number);
+               if (reserve)
+                       dquot_free_reserved_space(inode->i_dquot[cnt], number);
+               else
+                       dquot_decr_space(inode->i_dquot[cnt], number);
        }
-       inode_sub_bytes(inode, number);
+       inode_decr_space(inode, number, reserve);
        spin_unlock(&dq_data_lock);
-       /* Dirtify all the dquots - this can block when journalling */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-               if (inode->i_dquot[cnt])
-                       mark_dquot_dirty(inode->i_dquot[cnt]);
+
+       if (reserve)
+               goto out_unlock;
+       mark_all_dquot_dirty(inode->i_dquot);
+out_unlock:
        flush_warnings(inode->i_dquot, warntype);
        up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
        return QUOTA_OK;
 }
+
+int dquot_free_space(struct inode *inode, qsize_t number)
+{
+       return  __dquot_free_space(inode, number, 0);
+}
 EXPORT_SYMBOL(dquot_free_space);
 
+/*
+ * Release reserved quota space
+ */
+void dquot_release_reserved_space(struct inode *inode, qsize_t number)
+{
+       __dquot_free_space(inode, number, 1);
+
+}
+EXPORT_SYMBOL(dquot_release_reserved_space);
+
 /*
  * This operation can block, but only after everything is updated
  */
@@ -1599,29 +1646,13 @@ int dquot_free_inode(const struct inode *inode, qsize_t number)
                dquot_decr_inodes(inode->i_dquot[cnt], number);
        }
        spin_unlock(&dq_data_lock);
-       /* Dirtify all the dquots - this can block when journalling */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
-               if (inode->i_dquot[cnt])
-                       mark_dquot_dirty(inode->i_dquot[cnt]);
+       mark_all_dquot_dirty(inode->i_dquot);
        flush_warnings(inode->i_dquot, warntype);
        up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
        return QUOTA_OK;
 }
 EXPORT_SYMBOL(dquot_free_inode);
 
-/*
- * call back function, get reserved quota space from underlying fs
- */
-qsize_t dquot_get_reserved_space(struct inode *inode)
-{
-       qsize_t reserved_space = 0;
-
-       if (sb_any_quota_active(inode->i_sb) &&
-           inode->i_sb->dq_op->get_reserved_space)
-               reserved_space = inode->i_sb->dq_op->get_reserved_space(inode);
-       return reserved_space;
-}
-
 /*
  * Transfer the number of inode and blocks from one diskquota to an other.
  *
@@ -1665,7 +1696,7 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
        }
        spin_lock(&dq_data_lock);
        cur_space = inode_get_bytes(inode);
-       rsv_space = dquot_get_reserved_space(inode);
+       rsv_space = inode_get_rsv_space(inode);
        space = cur_space + rsv_space;
        /* Build the transfer_from list and check the limits */
        for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
@@ -1709,25 +1740,18 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
        spin_unlock(&dq_data_lock);
        up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
 
-       /* Dirtify all the dquots - this can block when journalling */
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-               if (transfer_from[cnt])
-                       mark_dquot_dirty(transfer_from[cnt]);
-               if (transfer_to[cnt]) {
-                       mark_dquot_dirty(transfer_to[cnt]);
-                       /* The reference we got is transferred to the inode */
-                       transfer_to[cnt] = NULL;
-               }
-       }
+       mark_all_dquot_dirty(transfer_from);
+       mark_all_dquot_dirty(transfer_to);
+       /* The reference we got is transferred to the inode */
+       for (cnt = 0; cnt < MAXQUOTAS; cnt++)
+               transfer_to[cnt] = NULL;
 warn_put_all:
        flush_warnings(transfer_to, warntype_to);
        flush_warnings(transfer_from, warntype_from_inodes);
        flush_warnings(transfer_from, warntype_from_space);
 put_all:
-       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-               dqput(transfer_from[cnt]);
-               dqput(transfer_to[cnt]);
-       }
+       dqput_all(transfer_from);
+       dqput_all(transfer_to);
        return ret;
 over_quota:
        spin_unlock(&dq_data_lock);
index 3dfc23e021351980693ea24b48d6d46dc5aa1e5e..e3da02f4986f3029c4ab51a30d30fa991a91c6a3 100644 (file)
@@ -97,8 +97,11 @@ static int v2_read_file_info(struct super_block *sb, int type)
        unsigned int version;
 
        if (!v2_read_header(sb, type, &dqhead))
-               return 0;
+               return -1;
        version = le32_to_cpu(dqhead.dqh_version);
+       if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) ||
+           (info->dqi_fmt_id == QFMT_VFS_V1 && version != 1))
+               return -1;
 
        size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
               sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
@@ -120,8 +123,8 @@ static int v2_read_file_info(struct super_block *sb, int type)
                info->dqi_maxilimit = 0xffffffff;
        } else {
                /* used space is stored as unsigned 64-bit value */
-               info->dqi_maxblimit = 0xffffffffffffffff;       /* 2^64-1 */
-               info->dqi_maxilimit = 0xffffffffffffffff;
+               info->dqi_maxblimit = 0xffffffffffffffffULL;    /* 2^64-1 */
+               info->dqi_maxilimit = 0xffffffffffffffffULL;
        }
        info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
        info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
index 32fae4040ebf46a94bc84cf1260c2edebce0c330..2efc57173fd703b74bfc1adaad5289df1ff1f179 100644 (file)
@@ -60,7 +60,7 @@ const struct inode_operations ramfs_file_inode_operations = {
  */
 int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
 {
-       unsigned long npages, xpages, loop, limit;
+       unsigned long npages, xpages, loop;
        struct page *pages;
        unsigned order;
        void *data;
index 6a9e30c041dda2a52a44bbe14d9aa664dae14bb7..792b3cb2cd18a745772e8d6e138656c1c5314eaf 100644 (file)
@@ -7,7 +7,11 @@ obj-$(CONFIG_REISERFS_FS) += reiserfs.o
 reiserfs-objs := bitmap.o do_balan.o namei.o inode.o file.o dir.o fix_node.o \
                 super.o prints.o objectid.o lbalance.o ibalance.o stree.o \
                 hashes.o tail_conversion.o journal.o resize.o \
-                item_ops.o ioctl.o procfs.o xattr.o lock.o
+                item_ops.o ioctl.o xattr.o lock.o
+
+ifeq ($(CONFIG_REISERFS_PROC_INFO),y)
+reiserfs-objs += procfs.o
+endif
 
 ifeq ($(CONFIG_REISERFS_FS_XATTR),y)
 reiserfs-objs += xattr_user.o xattr_trusted.o
index 3a28e7751b3c714da6e3b2c0b7fe9ad89e82a87b..290ae38fca8ae915c749c287ce3e4a19307d3d89 100644 (file)
@@ -2538,6 +2538,12 @@ static int reiserfs_writepage(struct page *page, struct writeback_control *wbc)
        return reiserfs_write_full_page(page, wbc);
 }
 
+static void reiserfs_truncate_failed_write(struct inode *inode)
+{
+       truncate_inode_pages(inode->i_mapping, inode->i_size);
+       reiserfs_truncate_file(inode, 0);
+}
+
 static int reiserfs_write_begin(struct file *file,
                                struct address_space *mapping,
                                loff_t pos, unsigned len, unsigned flags,
@@ -2604,6 +2610,8 @@ static int reiserfs_write_begin(struct file *file,
        if (ret) {
                unlock_page(page);
                page_cache_release(page);
+               /* Truncate allocated blocks */
+               reiserfs_truncate_failed_write(inode);
        }
        return ret;
 }
@@ -2701,9 +2709,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
         ** transaction tracking stuff when the size changes.  So, we have
         ** to do the i_size updates here.
         */
-       pos += copied;
-
-       if (pos > inode->i_size) {
+       if (pos + copied > inode->i_size) {
                struct reiserfs_transaction_handle myth;
                lock_depth = reiserfs_write_lock_once(inode->i_sb);
                locked = true;
@@ -2721,7 +2727,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
                        goto journal_error;
 
                reiserfs_update_inode_transaction(inode);
-               inode->i_size = pos;
+               inode->i_size = pos + copied;
                /*
                 * this will just nest into our transaction.  It's important
                 * to use mark_inode_dirty so the inode gets pushed around on the
@@ -2751,6 +2757,10 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping,
                reiserfs_write_unlock_once(inode->i_sb, lock_depth);
        unlock_page(page);
        page_cache_release(page);
+
+       if (pos + len > inode->i_size)
+               reiserfs_truncate_failed_write(inode);
+
        return ret == 0 ? copied : ret;
 
       journal_error:
index 9229e5514a4e13eef0fbaaef47f547bc90989a10..7a9981196c1cda061bf086610b5d71ef17121949 100644 (file)
@@ -17,8 +17,6 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 
-#ifdef CONFIG_REISERFS_PROC_INFO
-
 /*
  * LOCKING:
  *
@@ -48,14 +46,6 @@ static int show_version(struct seq_file *m, struct super_block *sb)
        return 0;
 }
 
-int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
-                                   int count, int *eof, void *data)
-{
-       *start = buffer;
-       *eof = 1;
-       return 0;
-}
-
 #define SF( x ) ( r -> x )
 #define SFP( x ) SF( s_proc_info_data.x )
 #define SFPL( x ) SFP( x[ level ] )
@@ -538,19 +528,6 @@ int reiserfs_proc_info_done(struct super_block *sb)
        return 0;
 }
 
-struct proc_dir_entry *reiserfs_proc_register_global(char *name,
-                                                    read_proc_t * func)
-{
-       return (proc_info_root) ? create_proc_read_entry(name, 0,
-                                                        proc_info_root,
-                                                        func, NULL) : NULL;
-}
-
-void reiserfs_proc_unregister_global(const char *name)
-{
-       remove_proc_entry(name, proc_info_root);
-}
-
 int reiserfs_proc_info_global_init(void)
 {
        if (proc_info_root == NULL) {
@@ -572,48 +549,6 @@ int reiserfs_proc_info_global_done(void)
        }
        return 0;
 }
-
-/* REISERFS_PROC_INFO */
-#else
-
-int reiserfs_proc_info_init(struct super_block *sb)
-{
-       return 0;
-}
-int reiserfs_proc_info_done(struct super_block *sb)
-{
-       return 0;
-}
-
-struct proc_dir_entry *reiserfs_proc_register_global(char *name,
-                                                    read_proc_t * func)
-{
-       return NULL;
-}
-
-void reiserfs_proc_unregister_global(const char *name)
-{;
-}
-
-int reiserfs_proc_info_global_init(void)
-{
-       return 0;
-}
-int reiserfs_proc_info_global_done(void)
-{
-       return 0;
-}
-
-int reiserfs_global_version_in_proc(char *buffer, char **start,
-                                   off_t offset,
-                                   int count, int *eof, void *data)
-{
-       return 0;
-}
-
-/* REISERFS_PROC_INFO */
-#endif
-
 /*
  * Revision 1.1.8.2  2001/07/15 17:08:42  god
  *  . use get_super() in procfs.c
index 339b0baf2af6ed0a721c3aa3b1f4941f633ec59a..b4a7dd03bdb9b9e49931f7a2fc360f35fbe1a561 100644 (file)
@@ -2222,8 +2222,6 @@ static int __init init_reiserfs_fs(void)
        }
 
        reiserfs_proc_info_global_init();
-       reiserfs_proc_register_global("version",
-                                     reiserfs_global_version_in_proc);
 
        ret = register_filesystem(&reiserfs_fs_type);
 
@@ -2231,7 +2229,6 @@ static int __init init_reiserfs_fs(void)
                return 0;
        }
 
-       reiserfs_proc_unregister_global("version");
        reiserfs_proc_info_global_done();
        destroy_inodecache();
 
@@ -2240,7 +2237,6 @@ static int __init init_reiserfs_fs(void)
 
 static void __exit exit_reiserfs_fs(void)
 {
-       reiserfs_proc_unregister_global("version");
        reiserfs_proc_info_global_done();
        unregister_filesystem(&reiserfs_fs_type);
        destroy_inodecache();
index 58aa8e75f7f5a8de1608dd7df0d6e4cf707d7a54..8c7033a8b67e43bed5d0acef901875fc2a22aa14 100644 (file)
@@ -48,6 +48,7 @@
 #include <net/checksum.h>
 #include <linux/stat.h>
 #include <linux/quotaops.h>
+#include <linux/security.h>
 
 #define PRIVROOT_NAME ".reiserfs_priv"
 #define XAROOT_NAME   "xattrs"
@@ -726,15 +727,14 @@ ssize_t
 reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
                  size_t size)
 {
-       struct inode *inode = dentry->d_inode;
        struct xattr_handler *handler;
 
-       handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
+       handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
 
-       if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
+       if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
 
-       return handler->get(inode, name, buffer, size);
+       return handler->get(dentry, name, buffer, size, handler->flags);
 }
 
 /*
@@ -746,15 +746,14 @@ int
 reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
                  size_t size, int flags)
 {
-       struct inode *inode = dentry->d_inode;
        struct xattr_handler *handler;
 
-       handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
+       handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
 
-       if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
+       if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
 
-       return handler->set(inode, name, value, size, flags);
+       return handler->set(dentry, name, value, size, flags, handler->flags);
 }
 
 /*
@@ -764,21 +763,20 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
  */
 int reiserfs_removexattr(struct dentry *dentry, const char *name)
 {
-       struct inode *inode = dentry->d_inode;
        struct xattr_handler *handler;
-       handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name);
+       handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
 
-       if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1)
+       if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
                return -EOPNOTSUPP;
 
-       return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
+       return handler->set(dentry, name, NULL, 0, XATTR_REPLACE, handler->flags);
 }
 
 struct listxattr_buf {
        size_t size;
        size_t pos;
        char *buf;
-       struct inode *inode;
+       struct dentry *dentry;
 };
 
 static int listxattr_filler(void *buf, const char *name, int namelen,
@@ -789,17 +787,19 @@ static int listxattr_filler(void *buf, const char *name, int namelen,
        if (name[0] != '.' ||
            (namelen != 1 && (name[1] != '.' || namelen != 2))) {
                struct xattr_handler *handler;
-               handler = find_xattr_handler_prefix(b->inode->i_sb->s_xattr,
+               handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr,
                                                    name);
                if (!handler)   /* Unsupported xattr name */
                        return 0;
                if (b->buf) {
-                       size = handler->list(b->inode, b->buf + b->pos,
-                                        b->size, name, namelen);
+                       size = handler->list(b->dentry, b->buf + b->pos,
+                                        b->size, name, namelen,
+                                        handler->flags);
                        if (size > b->size)
                                return -ERANGE;
                } else {
-                       size = handler->list(b->inode, NULL, 0, name, namelen);
+                       size = handler->list(b->dentry, NULL, 0, name,
+                                            namelen, handler->flags);
                }
 
                b->pos += size;
@@ -820,7 +820,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
        int err = 0;
        loff_t pos = 0;
        struct listxattr_buf buf = {
-               .inode = dentry->d_inode,
+               .dentry = dentry,
                .buf = buffer,
                .size = buffer ? size : 0,
        };
index 35d6e672a2796f7aaed49b31f96621c25593c51b..cc32e6ada67b3330aa0a9e3fc3bacfd0ca7c7c61 100644 (file)
@@ -15,8 +15,10 @@ static int reiserfs_set_acl(struct reiserfs_transaction_handle *th,
                            struct posix_acl *acl);
 
 static int
-xattr_set_acl(struct inode *inode, int type, const void *value, size_t size)
+posix_acl_set(struct dentry *dentry, const char *name, const void *value,
+               size_t size, int flags, int type)
 {
+       struct inode *inode = dentry->d_inode;
        struct posix_acl *acl;
        int error, error2;
        struct reiserfs_transaction_handle th;
@@ -60,15 +62,16 @@ xattr_set_acl(struct inode *inode, int type, const void *value, size_t size)
 }
 
 static int
-xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
+posix_acl_get(struct dentry *dentry, const char *name, void *buffer,
+               size_t size, int type)
 {
        struct posix_acl *acl;
        int error;
 
-       if (!reiserfs_posixacl(inode->i_sb))
+       if (!reiserfs_posixacl(dentry->d_sb))
                return -EOPNOTSUPP;
 
-       acl = reiserfs_get_acl(inode, type);
+       acl = reiserfs_get_acl(dentry->d_inode, type);
        if (IS_ERR(acl))
                return PTR_ERR(acl);
        if (acl == NULL)
@@ -482,30 +485,12 @@ int reiserfs_acl_chmod(struct inode *inode)
        return error;
 }
 
-static int
-posix_acl_access_get(struct inode *inode, const char *name,
-                    void *buffer, size_t size)
-{
-       if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1)
-               return -EINVAL;
-       return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
-}
-
-static int
-posix_acl_access_set(struct inode *inode, const char *name,
-                    const void *value, size_t size, int flags)
-{
-       if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1)
-               return -EINVAL;
-       return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
-}
-
-static size_t posix_acl_access_list(struct inode *inode, char *list,
+static size_t posix_acl_access_list(struct dentry *dentry, char *list,
                                    size_t list_size, const char *name,
-                                   size_t name_len)
+                                   size_t name_len, int type)
 {
        const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
-       if (!reiserfs_posixacl(inode->i_sb))
+       if (!reiserfs_posixacl(dentry->d_sb))
                return 0;
        if (list && size <= list_size)
                memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
@@ -514,35 +499,18 @@ static size_t posix_acl_access_list(struct inode *inode, char *list,
 
 struct xattr_handler reiserfs_posix_acl_access_handler = {
        .prefix = POSIX_ACL_XATTR_ACCESS,
-       .get = posix_acl_access_get,
-       .set = posix_acl_access_set,
+       .flags = ACL_TYPE_ACCESS,
+       .get = posix_acl_get,
+       .set = posix_acl_set,
        .list = posix_acl_access_list,
 };
 
-static int
-posix_acl_default_get(struct inode *inode, const char *name,
-                     void *buffer, size_t size)
-{
-       if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1)
-               return -EINVAL;
-       return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
-}
-
-static int
-posix_acl_default_set(struct inode *inode, const char *name,
-                     const void *value, size_t size, int flags)
-{
-       if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1)
-               return -EINVAL;
-       return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
-}
-
-static size_t posix_acl_default_list(struct inode *inode, char *list,
+static size_t posix_acl_default_list(struct dentry *dentry, char *list,
                                     size_t list_size, const char *name,
-                                    size_t name_len)
+                                    size_t name_len, int type)
 {
        const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
-       if (!reiserfs_posixacl(inode->i_sb))
+       if (!reiserfs_posixacl(dentry->d_sb))
                return 0;
        if (list && size <= list_size)
                memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
@@ -551,7 +519,8 @@ static size_t posix_acl_default_list(struct inode *inode, char *list,
 
 struct xattr_handler reiserfs_posix_acl_default_handler = {
        .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .get = posix_acl_default_get,
-       .set = posix_acl_default_set,
+       .flags = ACL_TYPE_DEFAULT,
+       .get = posix_acl_get,
+       .set = posix_acl_set,
        .list = posix_acl_default_list,
 };
index a92c8792c0f6d82d95fe00b8b3acbdc54802fd80..d8b5bfcbdd30b027aae6c9eae937b566b7b2043d 100644 (file)
@@ -8,36 +8,37 @@
 #include <asm/uaccess.h>
 
 static int
-security_get(struct inode *inode, const char *name, void *buffer, size_t size)
+security_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
+               int handler_flags)
 {
        if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
                return -EINVAL;
 
-       if (IS_PRIVATE(inode))
+       if (IS_PRIVATE(dentry->d_inode))
                return -EPERM;
 
-       return reiserfs_xattr_get(inode, name, buffer, size);
+       return reiserfs_xattr_get(dentry->d_inode, name, buffer, size);
 }
 
 static int
-security_set(struct inode *inode, const char *name, const void *buffer,
-            size_t size, int flags)
+security_set(struct dentry *dentry, const char *name, const void *buffer,
+            size_t size, int flags, int handler_flags)
 {
        if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
                return -EINVAL;
 
-       if (IS_PRIVATE(inode))
+       if (IS_PRIVATE(dentry->d_inode))
                return -EPERM;
 
-       return reiserfs_xattr_set(inode, name, buffer, size, flags);
+       return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags);
 }
 
-static size_t security_list(struct inode *inode, char *list, size_t list_len,
-                           const char *name, size_t namelen)
+static size_t security_list(struct dentry *dentry, char *list, size_t list_len,
+                           const char *name, size_t namelen, int handler_flags)
 {
        const size_t len = namelen + 1;
 
-       if (IS_PRIVATE(inode))
+       if (IS_PRIVATE(dentry->d_inode))
                return 0;
 
        if (list && len <= list_len) {
index a865042f75e2e2c0cbb46150e150e1b0911e31b0..5b08aaca3dafaf4c8e1d4b89de06d0ec25f6928b 100644 (file)
@@ -8,36 +8,37 @@
 #include <asm/uaccess.h>
 
 static int
-trusted_get(struct inode *inode, const char *name, void *buffer, size_t size)
+trusted_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
+           int handler_flags)
 {
        if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
                return -EINVAL;
 
-       if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
+       if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode))
                return -EPERM;
 
-       return reiserfs_xattr_get(inode, name, buffer, size);
+       return reiserfs_xattr_get(dentry->d_inode, name, buffer, size);
 }
 
 static int
-trusted_set(struct inode *inode, const char *name, const void *buffer,
-           size_t size, int flags)
+trusted_set(struct dentry *dentry, const char *name, const void *buffer,
+           size_t size, int flags, int handler_flags)
 {
        if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX))
                return -EINVAL;
 
-       if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
+       if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode))
                return -EPERM;
 
-       return reiserfs_xattr_set(inode, name, buffer, size, flags);
+       return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags);
 }
 
-static size_t trusted_list(struct inode *inode, char *list, size_t list_size,
-                          const char *name, size_t name_len)
+static size_t trusted_list(struct dentry *dentry, char *list, size_t list_size,
+                          const char *name, size_t name_len, int handler_flags)
 {
        const size_t len = name_len + 1;
 
-       if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode))
+       if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode))
                return 0;
 
        if (list && len <= list_size) {
index e3238dc4f3db941ebf3108d347402fbc9a8281df..75d59c49b9114d4f059b96b50b35e9e2f0d7a9c6 100644 (file)
@@ -7,34 +7,35 @@
 #include <asm/uaccess.h>
 
 static int
-user_get(struct inode *inode, const char *name, void *buffer, size_t size)
+user_get(struct dentry *dentry, const char *name, void *buffer, size_t size,
+        int handler_flags)
 {
 
        if (strlen(name) < sizeof(XATTR_USER_PREFIX))
                return -EINVAL;
-       if (!reiserfs_xattrs_user(inode->i_sb))
+       if (!reiserfs_xattrs_user(dentry->d_sb))
                return -EOPNOTSUPP;
-       return reiserfs_xattr_get(inode, name, buffer, size);
+       return reiserfs_xattr_get(dentry->d_inode, name, buffer, size);
 }
 
 static int
-user_set(struct inode *inode, const char *name, const void *buffer,
-        size_t size, int flags)
+user_set(struct dentry *dentry, const char *name, const void *buffer,
+        size_t size, int flags, int handler_flags)
 {
        if (strlen(name) < sizeof(XATTR_USER_PREFIX))
                return -EINVAL;
 
-       if (!reiserfs_xattrs_user(inode->i_sb))
+       if (!reiserfs_xattrs_user(dentry->d_sb))
                return -EOPNOTSUPP;
-       return reiserfs_xattr_set(inode, name, buffer, size, flags);
+       return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags);
 }
 
-static size_t user_list(struct inode *inode, char *list, size_t list_size,
-                       const char *name, size_t name_len)
+static size_t user_list(struct dentry *dentry, char *list, size_t list_size,
+                       const char *name, size_t name_len, int handler_flags)
 {
        const size_t len = name_len + 1;
 
-       if (!reiserfs_xattrs_user(inode->i_sb))
+       if (!reiserfs_xattrs_user(dentry->d_sb))
                return 0;
        if (list && len <= list_size) {
                memcpy(list, name, name_len);
index b07565c9438672015aa041e3fb57e4b01ca6e27c..1dabe4ee02fe93931ae741344405bee1daca3cd0 100644 (file)
@@ -236,7 +236,7 @@ SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask,
                 * anon_inode_getfd() will install the fd.
                 */
                ufd = anon_inode_getfd("[signalfd]", &signalfd_fops, ctx,
-                                      flags & (O_CLOEXEC | O_NONBLOCK));
+                                      O_RDWR | (flags & (O_CLOEXEC | O_NONBLOCK)));
                if (ufd < 0)
                        kfree(ctx);
        } else {
index 67716f6a1a4a29ddb5e59dda194f837cedbfe210..4a6f7f440658d4461a1f441a78516efe13a2c855 100644 (file)
@@ -7,18 +7,63 @@
  * This function cannot be inlined since i_size_{read,write} is rather
  * heavy-weight on 32-bit systems
  */
-void fsstack_copy_inode_size(struct inode *dst, const struct inode *src)
+void fsstack_copy_inode_size(struct inode *dst, struct inode *src)
 {
-       i_size_write(dst, i_size_read((struct inode *)src));
-       dst->i_blocks = src->i_blocks;
+       loff_t i_size;
+       blkcnt_t i_blocks;
+
+       /*
+        * i_size_read() includes its own seqlocking and protection from
+        * preemption (see include/linux/fs.h): we need nothing extra for
+        * that here, and prefer to avoid nesting locks than attempt to keep
+        * i_size and i_blocks in sync together.
+        */
+       i_size = i_size_read(src);
+
+       /*
+        * But if CONFIG_LBDAF (on 32-bit), we ought to make an effort to
+        * keep the two halves of i_blocks in sync despite SMP or PREEMPT -
+        * though stat's generic_fillattr() doesn't bother, and we won't be
+        * applying quotas (where i_blocks does become important) at the
+        * upper level.
+        *
+        * We don't actually know what locking is used at the lower level;
+        * but if it's a filesystem that supports quotas, it will be using
+        * i_lock as in inode_add_bytes().  tmpfs uses other locking, and
+        * its 32-bit is (just) able to exceed 2TB i_size with the aid of
+        * holes; but its i_blocks cannot carry into the upper long without
+        * almost 2TB swap - let's ignore that case.
+        */
+       if (sizeof(i_blocks) > sizeof(long))
+               spin_lock(&src->i_lock);
+       i_blocks = src->i_blocks;
+       if (sizeof(i_blocks) > sizeof(long))
+               spin_unlock(&src->i_lock);
+
+       /*
+        * If CONFIG_SMP or CONFIG_PREEMPT on 32-bit, it's vital for
+        * fsstack_copy_inode_size() to hold some lock around
+        * i_size_write(), otherwise i_size_read() may spin forever (see
+        * include/linux/fs.h).  We don't necessarily hold i_mutex when this
+        * is called, so take i_lock for that case.
+        *
+        * And if CONFIG_LBADF (on 32-bit), continue our effort to keep the
+        * two halves of i_blocks in sync despite SMP or PREEMPT: use i_lock
+        * for that case too, and do both at once by combining the tests.
+        *
+        * There is none of this locking overhead in the 64-bit case.
+        */
+       if (sizeof(i_size) > sizeof(long) || sizeof(i_blocks) > sizeof(long))
+               spin_lock(&dst->i_lock);
+       i_size_write(dst, i_size);
+       dst->i_blocks = i_blocks;
+       if (sizeof(i_size) > sizeof(long) || sizeof(i_blocks) > sizeof(long))
+               spin_unlock(&dst->i_lock);
 }
 EXPORT_SYMBOL_GPL(fsstack_copy_inode_size);
 
-/* copy all attributes; get_nlinks is optional way to override the i_nlink
- * copying
- */
-void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
-                               int (*get_nlinks)(struct inode *))
+/* copy all attributes */
+void fsstack_copy_attr_all(struct inode *dest, const struct inode *src)
 {
        dest->i_mode = src->i_mode;
        dest->i_uid = src->i_uid;
@@ -29,14 +74,6 @@ void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
        dest->i_ctime = src->i_ctime;
        dest->i_blkbits = src->i_blkbits;
        dest->i_flags = src->i_flags;
-
-       /*
-        * Update the nlinks AFTER updating the above fields, because the
-        * get_links callback may depend on them.
-        */
-       if (!get_nlinks)
-               dest->i_nlink = src->i_nlink;
-       else
-               dest->i_nlink = (*get_nlinks)(dest);
+       dest->i_nlink = src->i_nlink;
 }
 EXPORT_SYMBOL_GPL(fsstack_copy_attr_all);
index 075694e31d8b62fbcf6c935fd0b74220844abfe6..c4ecd52c5737b5aeb8c8bfd671d05b8a76f995a8 100644 (file)
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -401,9 +401,9 @@ SYSCALL_DEFINE4(fstatat64, int, dfd, char __user *, filename,
 }
 #endif /* __ARCH_WANT_STAT64 */
 
-void inode_add_bytes(struct inode *inode, loff_t bytes)
+/* Caller is here responsible for sufficient locking (ie. inode->i_lock) */
+void __inode_add_bytes(struct inode *inode, loff_t bytes)
 {
-       spin_lock(&inode->i_lock);
        inode->i_blocks += bytes >> 9;
        bytes &= 511;
        inode->i_bytes += bytes;
@@ -411,6 +411,12 @@ void inode_add_bytes(struct inode *inode, loff_t bytes)
                inode->i_blocks++;
                inode->i_bytes -= 512;
        }
+}
+
+void inode_add_bytes(struct inode *inode, loff_t bytes)
+{
+       spin_lock(&inode->i_lock);
+       __inode_add_bytes(inode, bytes);
        spin_unlock(&inode->i_lock);
 }
 
index 19eb70b374bcb3239cd7a75ee901336f942b02e4..aff046b0fe78b8be88b7a81a10f2ed39b38e2f85 100644 (file)
@@ -901,8 +901,9 @@ int get_sb_single(struct file_system_type *fs_type,
                        return error;
                }
                s->s_flags |= MS_ACTIVE;
+       } else {
+               do_remount_sb(s, flags, data, 0);
        }
-       do_remount_sb(s, flags, data, 0);
        simple_set_mnt(mnt, s);
        return 0;
 }
index 36752a683481533566fda6910e11d4c8a0d66a41..418727a2a2390f435d68b1fad91dede88dc4c17f 100644 (file)
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -355,6 +355,7 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes,
 {
        int ret;
        struct file *file;
+       struct address_space *mapping;
        loff_t endbyte;                 /* inclusive */
        int fput_needed;
        umode_t i_mode;
@@ -405,7 +406,28 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes,
                        !S_ISLNK(i_mode))
                goto out_put;
 
-       ret = do_sync_mapping_range(file->f_mapping, offset, endbyte, flags);
+       mapping = file->f_mapping;
+       if (!mapping) {
+               ret = -EINVAL;
+               goto out_put;
+       }
+
+       ret = 0;
+       if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
+               ret = filemap_fdatawait_range(mapping, offset, endbyte);
+               if (ret < 0)
+                       goto out_put;
+       }
+
+       if (flags & SYNC_FILE_RANGE_WRITE) {
+               ret = filemap_fdatawrite_range(mapping, offset, endbyte);
+               if (ret < 0)
+                       goto out_put;
+       }
+
+       if (flags & SYNC_FILE_RANGE_WAIT_AFTER)
+               ret = filemap_fdatawait_range(mapping, offset, endbyte);
+
 out_put:
        fput_light(file, fput_needed);
 out:
@@ -437,38 +459,3 @@ asmlinkage long SyS_sync_file_range2(long fd, long flags,
 }
 SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2);
 #endif
-
-/*
- * `endbyte' is inclusive
- */
-int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
-                         loff_t endbyte, unsigned int flags)
-{
-       int ret;
-
-       if (!mapping) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       ret = 0;
-       if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
-               ret = filemap_fdatawait_range(mapping, offset, endbyte);
-               if (ret < 0)
-                       goto out;
-       }
-
-       if (flags & SYNC_FILE_RANGE_WRITE) {
-               ret = __filemap_fdatawrite_range(mapping, offset, endbyte,
-                                               WB_SYNC_ALL);
-               if (ret < 0)
-                       goto out;
-       }
-
-       if (flags & SYNC_FILE_RANGE_WAIT_AFTER) {
-               ret = filemap_fdatawait_range(mapping, offset, endbyte);
-       }
-out:
-       return ret;
-}
-EXPORT_SYMBOL_GPL(do_sync_mapping_range);
index 60c702bc10ae43c9fe85be8105ca3e856a7ff533..a0a500af24a14d81f13d121f39915bd9dc1e59a2 100644 (file)
@@ -483,7 +483,8 @@ void unmap_bin_file(struct sysfs_dirent *attr_sd)
  *     @attr:  attribute descriptor.
  */
 
-int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
+int sysfs_create_bin_file(struct kobject *kobj,
+                         const struct bin_attribute *attr)
 {
        BUG_ON(!kobj || !kobj->sd || !attr);
 
@@ -497,7 +498,8 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
  *     @attr:  attribute descriptor.
  */
 
-void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
+void sysfs_remove_bin_file(struct kobject *kobj,
+                          const struct bin_attribute *attr)
 {
        sysfs_hash_and_remove(kobj->sd, attr->attr.name);
 }
index b042bd7034b1fc74d6cd6399e24b3a2057689a2f..1bfc95ad5f716a70dda692a250aee1231b4f608e 100644 (file)
@@ -200,7 +200,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
        hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS);
 
        ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx,
-                              flags & TFD_SHARED_FCNTL_FLAGS);
+                              O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS));
        if (ufd < 0)
                kfree(ctx);
 
index 8a771c59ac3eab2e460f5d6f337155215ee014a2..90492327b3835c476eb52ba0399c20c581e1e19f 100644 (file)
@@ -350,13 +350,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
                       le32_to_cpu(sup->fmt_version));
                printk(KERN_DEBUG "\ttime_gran      %u\n",
                       le32_to_cpu(sup->time_gran));
-               printk(KERN_DEBUG "\tUUID           %02X%02X%02X%02X-%02X%02X"
-                      "-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n",
-                      sup->uuid[0], sup->uuid[1], sup->uuid[2], sup->uuid[3],
-                      sup->uuid[4], sup->uuid[5], sup->uuid[6], sup->uuid[7],
-                      sup->uuid[8], sup->uuid[9], sup->uuid[10], sup->uuid[11],
-                      sup->uuid[12], sup->uuid[13], sup->uuid[14],
-                      sup->uuid[15]);
+               printk(KERN_DEBUG "\tUUID           %pUB\n",
+                      sup->uuid);
                break;
        }
        case UBIFS_MST_NODE:
index 39849f887e724602fa54d1feedf0d63090fe3d6e..16a6444330ec65b79488ceea7bd82295c4fde5b0 100644 (file)
@@ -45,7 +45,7 @@
  *
  * Similarly, @i_mutex is not always locked in 'ubifs_readpage()', e.g., the
  * read-ahead path does not lock it ("sys_read -> generic_file_aio_read ->
- * ondemand_readahead -> readpage"). In case of readahead, @I_LOCK flag is not
+ * ondemand_readahead -> readpage"). In case of readahead, @I_SYNC flag is not
  * set as well. However, UBIFS disables readahead.
  */
 
index 943ad5624530bfc65d8d47f9d1b5c9721939d454..43f9d19a6f3313ec3df7f358138e153703d4895b 100644 (file)
@@ -1393,12 +1393,7 @@ static int mount_ubifs(struct ubifs_info *c)
                c->leb_size, c->leb_size >> 10);
        dbg_msg("data journal heads:  %d",
                c->jhead_cnt - NONDATA_JHEADS_CNT);
-       dbg_msg("UUID:                %02X%02X%02X%02X-%02X%02X"
-              "-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
-              c->uuid[0], c->uuid[1], c->uuid[2], c->uuid[3],
-              c->uuid[4], c->uuid[5], c->uuid[6], c->uuid[7],
-              c->uuid[8], c->uuid[9], c->uuid[10], c->uuid[11],
-              c->uuid[12], c->uuid[13], c->uuid[14], c->uuid[15]);
+       dbg_msg("UUID:                %pUB", c->uuid);
        dbg_msg("big_lpt              %d", c->big_lpt);
        dbg_msg("log LEBs:            %d (%d - %d)",
                c->log_lebs, UBIFS_LOG_LNUM, c->log_last);
index 6f671f1ac27122ee1ae3a9b289958d88f39ac604..22af68f8b6825e4be3343ecb79ed4dbec587f61b 100644 (file)
@@ -70,13 +70,13 @@ static inline unsigned long ufs_dir_pages(struct inode *inode)
        return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT;
 }
 
-ino_t ufs_inode_by_name(struct inode *dir, struct dentry *dentry)
+ino_t ufs_inode_by_name(struct inode *dir, struct qstr *qstr)
 {
        ino_t res = 0;
        struct ufs_dir_entry *de;
        struct page *page;
        
-       de = ufs_find_entry(dir, dentry, &page);
+       de = ufs_find_entry(dir, qstr, &page);
        if (de) {
                res = fs32_to_cpu(dir->i_sb, de->d_ino);
                ufs_put_page(page);
@@ -249,12 +249,12 @@ struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p)
  * (as a parameter - res_dir). Page is returned mapped and unlocked.
  * Entry is guaranteed to be valid.
  */
-struct ufs_dir_entry *ufs_find_entry(struct inode *dir, struct dentry *dentry,
+struct ufs_dir_entry *ufs_find_entry(struct inode *dir, struct qstr *qstr,
                                     struct page **res_page)
 {
        struct super_block *sb = dir->i_sb;
-       const char *name = dentry->d_name.name;
-       int namelen = dentry->d_name.len;
+       const char *name = qstr->name;
+       int namelen = qstr->len;
        unsigned reclen = UFS_DIR_REC_LEN(namelen);
        unsigned long start, n;
        unsigned long npages = ufs_dir_pages(dir);
index 23119fe7ad6241e504f4bc7063c22988882d8a0c..4c26d9e8bc94f8f24578495985e14202cce5be8e 100644 (file)
@@ -56,7 +56,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru
                return ERR_PTR(-ENAMETOOLONG);
 
        lock_kernel();
-       ino = ufs_inode_by_name(dir, dentry);
+       ino = ufs_inode_by_name(dir, &dentry->d_name);
        if (ino) {
                inode = ufs_iget(dir->i_sb, ino);
                if (IS_ERR(inode)) {
@@ -237,7 +237,7 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry)
        struct page *page;
        int err = -ENOENT;
 
-       de = ufs_find_entry(dir, dentry, &page);
+       de = ufs_find_entry(dir, &dentry->d_name, &page);
        if (!de)
                goto out;
 
@@ -281,7 +281,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
        struct ufs_dir_entry *old_de;
        int err = -ENOENT;
 
-       old_de = ufs_find_entry(old_dir, old_dentry, &old_page);
+       old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page);
        if (!old_de)
                goto out;
 
@@ -301,7 +301,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        goto out_dir;
 
                err = -ENOENT;
-               new_de = ufs_find_entry(new_dir, new_dentry, &new_page);
+               new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page);
                if (!new_de)
                        goto out_dir;
                inode_inc_link_count(old_inode);
index 5faed7954d0a15165b9223fcc3c30fc3c5946846..143c20bfb04b084a73f1814a23ed2b69a3614e2d 100644 (file)
@@ -66,6 +66,7 @@
  */
 
 
+#include <linux/exportfs.h>
 #include <linux/module.h>
 #include <linux/bitops.h>
 
 #include "swab.h"
 #include "util.h"
 
+static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation)
+{
+       struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
+       struct inode *inode;
+
+       if (ino < UFS_ROOTINO || ino > uspi->s_ncg * uspi->s_ipg)
+               return ERR_PTR(-ESTALE);
+
+       inode = ufs_iget(sb, ino);
+       if (IS_ERR(inode))
+               return ERR_CAST(inode);
+       if (generation && inode->i_generation != generation) {
+               iput(inode);
+               return ERR_PTR(-ESTALE);
+       }
+       return inode;
+}
+
+static struct dentry *ufs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+                                      int fh_len, int fh_type)
+{
+       return generic_fh_to_dentry(sb, fid, fh_len, fh_type, ufs_nfs_get_inode);
+}
+
+static struct dentry *ufs_fh_to_parent(struct super_block *sb, struct fid *fid,
+                                      int fh_len, int fh_type)
+{
+       return generic_fh_to_parent(sb, fid, fh_len, fh_type, ufs_nfs_get_inode);
+}
+
+static struct dentry *ufs_get_parent(struct dentry *child)
+{
+       struct qstr dot_dot = {
+               .name   = "..",
+               .len    = 2,
+       };
+       ino_t ino;
+
+       ino = ufs_inode_by_name(child->d_inode, &dot_dot);
+       if (!ino)
+               return ERR_PTR(-ENOENT);
+       return d_obtain_alias(ufs_iget(child->d_inode->i_sb, ino));
+}
+
+static const struct export_operations ufs_export_ops = {
+       .fh_to_dentry   = ufs_fh_to_dentry,
+       .fh_to_parent   = ufs_fh_to_parent,
+       .get_parent     = ufs_get_parent,
+};
+
 #ifdef CONFIG_UFS_DEBUG
 /*
  * Print contents of ufs_super_block, useful for debugging
@@ -990,6 +1041,7 @@ magic_found:
         * Read ufs_super_block into internal data structures
         */
        sb->s_op = &ufs_super_ops;
+       sb->s_export_op = &ufs_export_ops;
        sb->dq_op = NULL; /***/
        sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic);
 
index 644e77e1359912d502bcc05dc50e476b6abe5e68..0b4c39bc0d9ef716b3a81b9ee44dc09f87f48e57 100644 (file)
@@ -86,9 +86,9 @@ extern void ufs_put_cylinder (struct super_block *, unsigned);
 /* dir.c */
 extern const struct inode_operations ufs_dir_inode_operations;
 extern int ufs_add_link (struct dentry *, struct inode *);
-extern ino_t ufs_inode_by_name(struct inode *, struct dentry *);
+extern ino_t ufs_inode_by_name(struct inode *, struct qstr *);
 extern int ufs_make_empty(struct inode *, struct inode *);
-extern struct ufs_dir_entry *ufs_find_entry(struct inode *, struct dentry *, struct page **);
+extern struct ufs_dir_entry *ufs_find_entry(struct inode *, struct qstr *, struct page **);
 extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *);
 extern int ufs_empty_dir (struct inode *);
 extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **);
index 6d4f6d3449fbb8f3749e86148c3ee0d3c28c26eb..46f87e828b484ebabf84422150eb8b9938481971 100644 (file)
@@ -615,12 +615,11 @@ ssize_t
 generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size)
 {
        struct xattr_handler *handler;
-       struct inode *inode = dentry->d_inode;
 
-       handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
+       handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
        if (!handler)
                return -EOPNOTSUPP;
-       return handler->get(inode, name, buffer, size);
+       return handler->get(dentry, name, buffer, size, handler->flags);
 }
 
 /*
@@ -630,18 +629,20 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s
 ssize_t
 generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
-       struct inode *inode = dentry->d_inode;
-       struct xattr_handler *handler, **handlers = inode->i_sb->s_xattr;
+       struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr;
        unsigned int size = 0;
 
        if (!buffer) {
-               for_each_xattr_handler(handlers, handler)
-                       size += handler->list(inode, NULL, 0, NULL, 0);
+               for_each_xattr_handler(handlers, handler) {
+                       size += handler->list(dentry, NULL, 0, NULL, 0,
+                                             handler->flags);
+               }
        } else {
                char *buf = buffer;
 
                for_each_xattr_handler(handlers, handler) {
-                       size = handler->list(inode, buf, buffer_size, NULL, 0);
+                       size = handler->list(dentry, buf, buffer_size,
+                                            NULL, 0, handler->flags);
                        if (size > buffer_size)
                                return -ERANGE;
                        buf += size;
@@ -659,14 +660,13 @@ int
 generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
 {
        struct xattr_handler *handler;
-       struct inode *inode = dentry->d_inode;
 
        if (size == 0)
                value = "";  /* empty EA, do not remove */
-       handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
+       handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
        if (!handler)
                return -EOPNOTSUPP;
-       return handler->set(inode, name, value, size, flags);
+       return handler->set(dentry, name, value, size, 0, handler->flags);
 }
 
 /*
@@ -677,12 +677,12 @@ int
 generic_removexattr(struct dentry *dentry, const char *name)
 {
        struct xattr_handler *handler;
-       struct inode *inode = dentry->d_inode;
 
-       handler = xattr_resolve_name(inode->i_sb->s_xattr, &name);
+       handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
        if (!handler)
                return -EOPNOTSUPP;
-       return handler->set(inode, name, NULL, 0, XATTR_REPLACE);
+       return handler->set(dentry, name, NULL, 0,
+                           XATTR_REPLACE, handler->flags);
 }
 
 EXPORT_SYMBOL(generic_getxattr);
index 7a59daed1782898901b0fbd333618efc8c515eec..56641fe52a23be696f492639fe19ebbaf97466e5 100644 (file)
@@ -26,6 +26,8 @@ endif
 
 obj-$(CONFIG_XFS_FS)           += xfs.o
 
+xfs-y                          += linux-2.6/xfs_trace.o
+
 xfs-$(CONFIG_XFS_QUOTA)                += $(addprefix quota/, \
                                   xfs_dquot.o \
                                   xfs_dquot_item.o \
@@ -90,8 +92,7 @@ xfs-y                         += xfs_alloc.o \
                                   xfs_rw.o \
                                   xfs_dmops.o
 
-xfs-$(CONFIG_XFS_TRACE)                += xfs_btree_trace.o \
-                                  xfs_dir2_trace.o
+xfs-$(CONFIG_XFS_TRACE)                += xfs_btree_trace.o
 
 # Objects in linux/
 xfs-y                          += $(addprefix $(XFS_LINUX)/, \
@@ -113,6 +114,3 @@ xfs-y                               += $(addprefix $(XFS_LINUX)/, \
 xfs-y                          += $(addprefix support/, \
                                   debug.o \
                                   uuid.o)
-
-xfs-$(CONFIG_XFS_TRACE)                += support/ktrace.o
-
index b23a5450644608fddbc7d5146e6c20f638209450..2512125dfa7c9eadba5e440afea5250124fcbe28 100644 (file)
@@ -21,6 +21,7 @@
 #include "xfs_bmap_btree.h"
 #include "xfs_inode.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 #include <linux/xattr.h>
 #include <linux/posix_acl_xattr.h>
 
@@ -353,37 +354,14 @@ xfs_acl_chmod(struct inode *inode)
        return error;
 }
 
-/*
- * System xattr handlers.
- *
- * Currently Posix ACLs are the only system namespace extended attribute
- * handlers supported by XFS, so we just implement the handlers here.
- * If we ever support other system extended attributes this will need
- * some refactoring.
- */
-
 static int
-xfs_decode_acl(const char *name)
-{
-       if (strcmp(name, "posix_acl_access") == 0)
-               return ACL_TYPE_ACCESS;
-       else if (strcmp(name, "posix_acl_default") == 0)
-               return ACL_TYPE_DEFAULT;
-       return -EINVAL;
-}
-
-static int
-xfs_xattr_system_get(struct inode *inode, const char *name,
-               void *value, size_t size)
+xfs_xattr_acl_get(struct dentry *dentry, const char *name,
+               void *value, size_t size, int type)
 {
        struct posix_acl *acl;
-       int type, error;
-
-       type = xfs_decode_acl(name);
-       if (type < 0)
-               return type;
+       int error;
 
-       acl = xfs_get_acl(inode, type);
+       acl = xfs_get_acl(dentry->d_inode, type);
        if (IS_ERR(acl))
                return PTR_ERR(acl);
        if (acl == NULL)
@@ -396,15 +374,13 @@ xfs_xattr_system_get(struct inode *inode, const char *name,
 }
 
 static int
-xfs_xattr_system_set(struct inode *inode, const char *name,
-               const void *value, size_t size, int flags)
+xfs_xattr_acl_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int type)
 {
+       struct inode *inode = dentry->d_inode;
        struct posix_acl *acl = NULL;
-       int error = 0, type;
+       int error = 0;
 
-       type = xfs_decode_acl(name);
-       if (type < 0)
-               return type;
        if (flags & XATTR_CREATE)
                return -EINVAL;
        if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
@@ -461,8 +437,16 @@ xfs_xattr_system_set(struct inode *inode, const char *name,
        return error;
 }
 
-struct xattr_handler xfs_xattr_system_handler = {
-       .prefix = XATTR_SYSTEM_PREFIX,
-       .get    = xfs_xattr_system_get,
-       .set    = xfs_xattr_system_set,
+struct xattr_handler xfs_xattr_acl_access_handler = {
+       .prefix = POSIX_ACL_XATTR_ACCESS,
+       .flags  = ACL_TYPE_ACCESS,
+       .get    = xfs_xattr_acl_get,
+       .set    = xfs_xattr_acl_set,
+};
+
+struct xattr_handler xfs_xattr_acl_default_handler = {
+       .prefix = POSIX_ACL_XATTR_DEFAULT,
+       .flags  = ACL_TYPE_DEFAULT,
+       .get    = xfs_xattr_acl_get,
+       .set    = xfs_xattr_acl_set,
 };
index 87813e405cef811ddc303608b51ea94d869e84d7..66abe36c1213e60ae49e483c82193c72a0d57758 100644 (file)
@@ -38,6 +38,7 @@
 #include "xfs_rw.h"
 #include "xfs_iomap.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 #include <linux/mpage.h>
 #include <linux/pagevec.h>
 #include <linux/writeback.h>
@@ -76,7 +77,7 @@ xfs_ioend_wake(
                wake_up(to_ioend_wq(ip));
 }
 
-STATIC void
+void
 xfs_count_page_state(
        struct page             *page,
        int                     *delalloc,
@@ -98,48 +99,6 @@ xfs_count_page_state(
        } while ((bh = bh->b_this_page) != head);
 }
 
-#if defined(XFS_RW_TRACE)
-void
-xfs_page_trace(
-       int             tag,
-       struct inode    *inode,
-       struct page     *page,
-       unsigned long   pgoff)
-{
-       xfs_inode_t     *ip;
-       loff_t          isize = i_size_read(inode);
-       loff_t          offset = page_offset(page);
-       int             delalloc = -1, unmapped = -1, unwritten = -1;
-
-       if (page_has_buffers(page))
-               xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
-
-       ip = XFS_I(inode);
-       if (!ip->i_rwtrace)
-               return;
-
-       ktrace_enter(ip->i_rwtrace,
-               (void *)((unsigned long)tag),
-               (void *)ip,
-               (void *)inode,
-               (void *)page,
-               (void *)pgoff,
-               (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
-               (void *)((unsigned long)((isize >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(isize & 0xffffffff)),
-               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(offset & 0xffffffff)),
-               (void *)((unsigned long)delalloc),
-               (void *)((unsigned long)unmapped),
-               (void *)((unsigned long)unwritten),
-               (void *)((unsigned long)current_pid()),
-               (void *)NULL);
-}
-#else
-#define xfs_page_trace(tag, inode, page, pgoff)
-#endif
-
 STATIC struct block_device *
 xfs_find_bdev_for_inode(
        struct xfs_inode        *ip)
@@ -1202,7 +1161,7 @@ xfs_vm_writepage(
        int                     delalloc, unmapped, unwritten;
        struct inode            *inode = page->mapping->host;
 
-       xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
+       trace_xfs_writepage(inode, page, 0);
 
        /*
         * We need a transaction if:
@@ -1307,7 +1266,7 @@ xfs_vm_releasepage(
                .nr_to_write = 1,
        };
 
-       xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, 0);
+       trace_xfs_releasepage(inode, page, 0);
 
        if (!page_has_buffers(page))
                return 0;
@@ -1515,19 +1474,13 @@ xfs_vm_direct_IO(
 
        bdev = xfs_find_bdev_for_inode(XFS_I(inode));
 
-       if (rw == WRITE) {
-               iocb->private = xfs_alloc_ioend(inode, IOMAP_UNWRITTEN);
-               ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
-                       bdev, iov, offset, nr_segs,
-                       xfs_get_blocks_direct,
-                       xfs_end_io_direct);
-       } else {
-               iocb->private = xfs_alloc_ioend(inode, IOMAP_READ);
-               ret = blockdev_direct_IO_no_locking(rw, iocb, inode,
-                       bdev, iov, offset, nr_segs,
-                       xfs_get_blocks_direct,
-                       xfs_end_io_direct);
-       }
+       iocb->private = xfs_alloc_ioend(inode, rw == WRITE ?
+                                       IOMAP_UNWRITTEN : IOMAP_READ);
+
+       ret = blockdev_direct_IO_no_locking(rw, iocb, inode, bdev, iov,
+                                           offset, nr_segs,
+                                           xfs_get_blocks_direct,
+                                           xfs_end_io_direct);
 
        if (unlikely(ret != -EIOCBQUEUED && iocb->private))
                xfs_destroy_ioend(iocb->private);
@@ -1587,8 +1540,7 @@ xfs_vm_invalidatepage(
        struct page             *page,
        unsigned long           offset)
 {
-       xfs_page_trace(XFS_INVALIDPAGE_ENTER,
-                       page->mapping->host, page, offset);
+       trace_xfs_invalidatepage(page->mapping->host, page, offset);
        block_invalidatepage(page, offset);
 }
 
index 221b3e66ceef3dd3e42db058991334eeb09d1d7e..4cfc6ea87df8c4c34564da66ee31aba497dad902 100644 (file)
@@ -45,4 +45,6 @@ extern int xfs_get_blocks(struct inode *, sector_t, struct buffer_head *, int);
 extern void xfs_ioend_init(void);
 extern void xfs_ioend_wait(struct xfs_inode *);
 
+extern void xfs_count_page_state(struct page *, int *, int *, int *);
+
 #endif /* __XFS_AOPS_H__ */
index 4ddc973aea7ab0a99e67e97a0fadb97b3567f31f..77b8be81c76900559d8e382ee9e7a42710ae86e5 100644 (file)
@@ -39,6 +39,7 @@
 #include "xfs_ag.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
+#include "xfs_trace.h"
 
 static kmem_zone_t *xfs_buf_zone;
 STATIC int xfsbufd(void *);
@@ -53,34 +54,6 @@ static struct workqueue_struct *xfslogd_workqueue;
 struct workqueue_struct *xfsdatad_workqueue;
 struct workqueue_struct *xfsconvertd_workqueue;
 
-#ifdef XFS_BUF_TRACE
-void
-xfs_buf_trace(
-       xfs_buf_t       *bp,
-       char            *id,
-       void            *data,
-       void            *ra)
-{
-       ktrace_enter(xfs_buf_trace_buf,
-               bp, id,
-               (void *)(unsigned long)bp->b_flags,
-               (void *)(unsigned long)bp->b_hold.counter,
-               (void *)(unsigned long)bp->b_sema.count,
-               (void *)current,
-               data, ra,
-               (void *)(unsigned long)((bp->b_file_offset>>32) & 0xffffffff),
-               (void *)(unsigned long)(bp->b_file_offset & 0xffffffff),
-               (void *)(unsigned long)bp->b_buffer_length,
-               NULL, NULL, NULL, NULL, NULL);
-}
-ktrace_t *xfs_buf_trace_buf;
-#define XFS_BUF_TRACE_SIZE     4096
-#define XB_TRACE(bp, id, data) \
-       xfs_buf_trace(bp, id, (void *)data, (void *)__builtin_return_address(0))
-#else
-#define XB_TRACE(bp, id, data) do { } while (0)
-#endif
-
 #ifdef XFS_BUF_LOCK_TRACKING
 # define XB_SET_OWNER(bp)      ((bp)->b_last_holder = current->pid)
 # define XB_CLEAR_OWNER(bp)    ((bp)->b_last_holder = -1)
@@ -279,7 +252,8 @@ _xfs_buf_initialize(
        init_waitqueue_head(&bp->b_waiters);
 
        XFS_STATS_INC(xb_create);
-       XB_TRACE(bp, "initialize", target);
+
+       trace_xfs_buf_init(bp, _RET_IP_);
 }
 
 /*
@@ -318,6 +292,7 @@ _xfs_buf_free_pages(
 {
        if (bp->b_pages != bp->b_page_array) {
                kmem_free(bp->b_pages);
+               bp->b_pages = NULL;
        }
 }
 
@@ -332,7 +307,7 @@ void
 xfs_buf_free(
        xfs_buf_t               *bp)
 {
-       XB_TRACE(bp, "free", 0);
+       trace_xfs_buf_free(bp, _RET_IP_);
 
        ASSERT(list_empty(&bp->b_hash_list));
 
@@ -349,9 +324,8 @@ xfs_buf_free(
                                ASSERT(!PagePrivate(page));
                        page_cache_release(page);
                }
-               _xfs_buf_free_pages(bp);
        }
-
+       _xfs_buf_free_pages(bp);
        xfs_buf_deallocate(bp);
 }
 
@@ -445,7 +419,6 @@ _xfs_buf_lookup_pages(
        if (page_count == bp->b_page_count)
                bp->b_flags |= XBF_DONE;
 
-       XB_TRACE(bp, "lookup_pages", (long)page_count);
        return error;
 }
 
@@ -548,7 +521,6 @@ found:
        if (down_trylock(&bp->b_sema)) {
                if (!(flags & XBF_TRYLOCK)) {
                        /* wait for buffer ownership */
-                       XB_TRACE(bp, "get_lock", 0);
                        xfs_buf_lock(bp);
                        XFS_STATS_INC(xb_get_locked_waited);
                } else {
@@ -571,7 +543,8 @@ found:
                ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0);
                bp->b_flags &= XBF_MAPPED;
        }
-       XB_TRACE(bp, "got_lock", 0);
+
+       trace_xfs_buf_find(bp, flags, _RET_IP_);
        XFS_STATS_INC(xb_get_locked);
        return bp;
 }
@@ -627,7 +600,7 @@ xfs_buf_get(
        bp->b_bn = ioff;
        bp->b_count_desired = bp->b_buffer_length;
 
-       XB_TRACE(bp, "get", (unsigned long)flags);
+       trace_xfs_buf_get(bp, flags, _RET_IP_);
        return bp;
 
  no_buffer:
@@ -644,8 +617,6 @@ _xfs_buf_read(
 {
        int                     status;
 
-       XB_TRACE(bp, "_xfs_buf_read", (unsigned long)flags);
-
        ASSERT(!(flags & (XBF_DELWRI|XBF_WRITE)));
        ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL);
 
@@ -673,19 +644,18 @@ xfs_buf_read(
 
        bp = xfs_buf_get(target, ioff, isize, flags);
        if (bp) {
+               trace_xfs_buf_read(bp, flags, _RET_IP_);
+
                if (!XFS_BUF_ISDONE(bp)) {
-                       XB_TRACE(bp, "read", (unsigned long)flags);
                        XFS_STATS_INC(xb_get_read);
                        _xfs_buf_read(bp, flags);
                } else if (flags & XBF_ASYNC) {
-                       XB_TRACE(bp, "read_async", (unsigned long)flags);
                        /*
                         * Read ahead call which is already satisfied,
                         * drop the buffer
                         */
                        goto no_buffer;
                } else {
-                       XB_TRACE(bp, "read_done", (unsigned long)flags);
                        /* We do not want read in the flags */
                        bp->b_flags &= ~XBF_READ;
                }
@@ -823,7 +793,7 @@ xfs_buf_get_noaddr(
 
        xfs_buf_unlock(bp);
 
-       XB_TRACE(bp, "no_daddr", len);
+       trace_xfs_buf_get_noaddr(bp, _RET_IP_);
        return bp;
 
  fail_free_mem:
@@ -845,8 +815,8 @@ void
 xfs_buf_hold(
        xfs_buf_t               *bp)
 {
+       trace_xfs_buf_hold(bp, _RET_IP_);
        atomic_inc(&bp->b_hold);
-       XB_TRACE(bp, "hold", 0);
 }
 
 /*
@@ -859,7 +829,7 @@ xfs_buf_rele(
 {
        xfs_bufhash_t           *hash = bp->b_hash;
 
-       XB_TRACE(bp, "rele", bp->b_relse);
+       trace_xfs_buf_rele(bp, _RET_IP_);
 
        if (unlikely(!hash)) {
                ASSERT(!bp->b_relse);
@@ -909,21 +879,19 @@ xfs_buf_cond_lock(
        int                     locked;
 
        locked = down_trylock(&bp->b_sema) == 0;
-       if (locked) {
+       if (locked)
                XB_SET_OWNER(bp);
-       }
-       XB_TRACE(bp, "cond_lock", (long)locked);
+
+       trace_xfs_buf_cond_lock(bp, _RET_IP_);
        return locked ? 0 : -EBUSY;
 }
 
-#if defined(DEBUG) || defined(XFS_BLI_TRACE)
 int
 xfs_buf_lock_value(
        xfs_buf_t               *bp)
 {
        return bp->b_sema.count;
 }
-#endif
 
 /*
  *     Locks a buffer object.
@@ -935,12 +903,14 @@ void
 xfs_buf_lock(
        xfs_buf_t               *bp)
 {
-       XB_TRACE(bp, "lock", 0);
+       trace_xfs_buf_lock(bp, _RET_IP_);
+
        if (atomic_read(&bp->b_io_remaining))
                blk_run_address_space(bp->b_target->bt_mapping);
        down(&bp->b_sema);
        XB_SET_OWNER(bp);
-       XB_TRACE(bp, "locked", 0);
+
+       trace_xfs_buf_lock_done(bp, _RET_IP_);
 }
 
 /*
@@ -962,7 +932,8 @@ xfs_buf_unlock(
 
        XB_CLEAR_OWNER(bp);
        up(&bp->b_sema);
-       XB_TRACE(bp, "unlock", 0);
+
+       trace_xfs_buf_unlock(bp, _RET_IP_);
 }
 
 
@@ -974,17 +945,18 @@ void
 xfs_buf_pin(
        xfs_buf_t               *bp)
 {
+       trace_xfs_buf_pin(bp, _RET_IP_);
        atomic_inc(&bp->b_pin_count);
-       XB_TRACE(bp, "pin", (long)bp->b_pin_count.counter);
 }
 
 void
 xfs_buf_unpin(
        xfs_buf_t               *bp)
 {
+       trace_xfs_buf_unpin(bp, _RET_IP_);
+
        if (atomic_dec_and_test(&bp->b_pin_count))
                wake_up_all(&bp->b_waiters);
-       XB_TRACE(bp, "unpin", (long)bp->b_pin_count.counter);
 }
 
 int
@@ -1035,7 +1007,7 @@ xfs_buf_iodone_work(
         */
        if ((bp->b_error == EOPNOTSUPP) &&
            (bp->b_flags & (XBF_ORDERED|XBF_ASYNC)) == (XBF_ORDERED|XBF_ASYNC)) {
-               XB_TRACE(bp, "ordered_retry", bp->b_iodone);
+               trace_xfs_buf_ordered_retry(bp, _RET_IP_);
                bp->b_flags &= ~XBF_ORDERED;
                bp->b_flags |= _XFS_BARRIER_FAILED;
                xfs_buf_iorequest(bp);
@@ -1050,12 +1022,12 @@ xfs_buf_ioend(
        xfs_buf_t               *bp,
        int                     schedule)
 {
+       trace_xfs_buf_iodone(bp, _RET_IP_);
+
        bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD);
        if (bp->b_error == 0)
                bp->b_flags |= XBF_DONE;
 
-       XB_TRACE(bp, "iodone", bp->b_iodone);
-
        if ((bp->b_iodone) || (bp->b_flags & XBF_ASYNC)) {
                if (schedule) {
                        INIT_WORK(&bp->b_iodone_work, xfs_buf_iodone_work);
@@ -1075,7 +1047,7 @@ xfs_buf_ioerror(
 {
        ASSERT(error >= 0 && error <= 0xffff);
        bp->b_error = (unsigned short)error;
-       XB_TRACE(bp, "ioerror", (unsigned long)error);
+       trace_xfs_buf_ioerror(bp, error, _RET_IP_);
 }
 
 int
@@ -1083,7 +1055,7 @@ xfs_bawrite(
        void                    *mp,
        struct xfs_buf          *bp)
 {
-       XB_TRACE(bp, "bawrite", 0);
+       trace_xfs_buf_bawrite(bp, _RET_IP_);
 
        ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL);
 
@@ -1102,7 +1074,7 @@ xfs_bdwrite(
        void                    *mp,
        struct xfs_buf          *bp)
 {
-       XB_TRACE(bp, "bdwrite", 0);
+       trace_xfs_buf_bdwrite(bp, _RET_IP_);
 
        bp->b_strat = xfs_bdstrat_cb;
        bp->b_mount = mp;
@@ -1177,10 +1149,14 @@ _xfs_buf_ioapply(
        if (bp->b_flags & XBF_ORDERED) {
                ASSERT(!(bp->b_flags & XBF_READ));
                rw = WRITE_BARRIER;
-       } else if (bp->b_flags & _XBF_RUN_QUEUES) {
+       } else if (bp->b_flags & XBF_LOG_BUFFER) {
                ASSERT(!(bp->b_flags & XBF_READ_AHEAD));
                bp->b_flags &= ~_XBF_RUN_QUEUES;
                rw = (bp->b_flags & XBF_WRITE) ? WRITE_SYNC : READ_SYNC;
+       } else if (bp->b_flags & _XBF_RUN_QUEUES) {
+               ASSERT(!(bp->b_flags & XBF_READ_AHEAD));
+               bp->b_flags &= ~_XBF_RUN_QUEUES;
+               rw = (bp->b_flags & XBF_WRITE) ? WRITE_META : READ_META;
        } else {
                rw = (bp->b_flags & XBF_WRITE) ? WRITE :
                     (bp->b_flags & XBF_READ_AHEAD) ? READA : READ;
@@ -1253,7 +1229,7 @@ int
 xfs_buf_iorequest(
        xfs_buf_t               *bp)
 {
-       XB_TRACE(bp, "iorequest", 0);
+       trace_xfs_buf_iorequest(bp, _RET_IP_);
 
        if (bp->b_flags & XBF_DELWRI) {
                xfs_buf_delwri_queue(bp, 1);
@@ -1287,11 +1263,13 @@ int
 xfs_buf_iowait(
        xfs_buf_t               *bp)
 {
-       XB_TRACE(bp, "iowait", 0);
+       trace_xfs_buf_iowait(bp, _RET_IP_);
+
        if (atomic_read(&bp->b_io_remaining))
                blk_run_address_space(bp->b_target->bt_mapping);
        wait_for_completion(&bp->b_iowait);
-       XB_TRACE(bp, "iowaited", (long)bp->b_error);
+
+       trace_xfs_buf_iowait_done(bp, _RET_IP_);
        return bp->b_error;
 }
 
@@ -1604,7 +1582,8 @@ xfs_buf_delwri_queue(
        struct list_head        *dwq = &bp->b_target->bt_delwrite_queue;
        spinlock_t              *dwlk = &bp->b_target->bt_delwrite_lock;
 
-       XB_TRACE(bp, "delwri_q", (long)unlock);
+       trace_xfs_buf_delwri_queue(bp, _RET_IP_);
+
        ASSERT((bp->b_flags&(XBF_DELWRI|XBF_ASYNC)) == (XBF_DELWRI|XBF_ASYNC));
 
        spin_lock(dwlk);
@@ -1644,7 +1623,7 @@ xfs_buf_delwri_dequeue(
        if (dequeued)
                xfs_buf_rele(bp);
 
-       XB_TRACE(bp, "delwri_dq", (long)dequeued);
+       trace_xfs_buf_delwri_dequeue(bp, _RET_IP_);
 }
 
 STATIC void
@@ -1692,7 +1671,7 @@ xfs_buf_delwri_split(
        INIT_LIST_HEAD(list);
        spin_lock(dwlk);
        list_for_each_entry_safe(bp, n, dwq, b_list) {
-               XB_TRACE(bp, "walkq1", (long)xfs_buf_ispin(bp));
+               trace_xfs_buf_delwri_split(bp, _RET_IP_);
                ASSERT(bp->b_flags & XBF_DELWRI);
 
                if (!xfs_buf_ispin(bp) && !xfs_buf_cond_lock(bp)) {
@@ -1816,14 +1795,10 @@ xfs_flush_buftarg(
 int __init
 xfs_buf_init(void)
 {
-#ifdef XFS_BUF_TRACE
-       xfs_buf_trace_buf = ktrace_alloc(XFS_BUF_TRACE_SIZE, KM_NOFS);
-#endif
-
        xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf",
                                                KM_ZONE_HWALIGN, NULL);
        if (!xfs_buf_zone)
-               goto out_free_trace_buf;
+               goto out;
 
        xfslogd_workqueue = create_workqueue("xfslogd");
        if (!xfslogd_workqueue)
@@ -1846,10 +1821,7 @@ xfs_buf_init(void)
        destroy_workqueue(xfslogd_workqueue);
  out_free_buf_zone:
        kmem_zone_destroy(xfs_buf_zone);
- out_free_trace_buf:
-#ifdef XFS_BUF_TRACE
-       ktrace_free(xfs_buf_trace_buf);
-#endif
+ out:
        return -ENOMEM;
 }
 
@@ -1861,9 +1833,6 @@ xfs_buf_terminate(void)
        destroy_workqueue(xfsdatad_workqueue);
        destroy_workqueue(xfslogd_workqueue);
        kmem_zone_destroy(xfs_buf_zone);
-#ifdef XFS_BUF_TRACE
-       ktrace_free(xfs_buf_trace_buf);
-#endif
 }
 
 #ifdef CONFIG_KDB_MODULES
index 5f07dd91c5fad311f1fb2bba0c9df8cfed91ec19..a34c7b54822ddac53adff85f9c27ae045835e31c 100644 (file)
@@ -55,6 +55,7 @@ typedef enum {
        XBF_FS_MANAGED = (1 << 8),  /* filesystem controls freeing memory  */
        XBF_ORDERED = (1 << 11),    /* use ordered writes                  */
        XBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead             */
+       XBF_LOG_BUFFER = (1 << 13), /* this is a buffer used for the log   */
 
        /* flags used only as arguments to access routines */
        XBF_LOCK = (1 << 14),       /* lock requested                      */
@@ -95,6 +96,28 @@ typedef enum {
        _XFS_BARRIER_FAILED = (1 << 23),
 } xfs_buf_flags_t;
 
+#define XFS_BUF_FLAGS \
+       { XBF_READ,             "READ" }, \
+       { XBF_WRITE,            "WRITE" }, \
+       { XBF_MAPPED,           "MAPPED" }, \
+       { XBF_ASYNC,            "ASYNC" }, \
+       { XBF_DONE,             "DONE" }, \
+       { XBF_DELWRI,           "DELWRI" }, \
+       { XBF_STALE,            "STALE" }, \
+       { XBF_FS_MANAGED,       "FS_MANAGED" }, \
+       { XBF_ORDERED,          "ORDERED" }, \
+       { XBF_READ_AHEAD,       "READ_AHEAD" }, \
+       { XBF_LOCK,             "LOCK" },       /* should never be set */\
+       { XBF_TRYLOCK,          "TRYLOCK" },    /* ditto */\
+       { XBF_DONT_BLOCK,       "DONT_BLOCK" }, /* ditto */\
+       { _XBF_PAGE_CACHE,      "PAGE_CACHE" }, \
+       { _XBF_PAGES,           "PAGES" }, \
+       { _XBF_RUN_QUEUES,      "RUN_QUEUES" }, \
+       { _XBF_DELWRI_Q,        "DELWRI_Q" }, \
+       { _XBF_PAGE_LOCKED,     "PAGE_LOCKED" }, \
+       { _XFS_BARRIER_FAILED,  "BARRIER_FAILED" }
+
+
 typedef enum {
        XBT_FORCE_SLEEP = 0,
        XBT_FORCE_FLUSH = 1,
@@ -243,13 +266,6 @@ extern void xfs_buf_delwri_dequeue(xfs_buf_t *);
 extern int xfs_buf_init(void);
 extern void xfs_buf_terminate(void);
 
-#ifdef XFS_BUF_TRACE
-extern ktrace_t *xfs_buf_trace_buf;
-extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *);
-#else
-#define xfs_buf_trace(bp,id,ptr,ra)    do { } while (0)
-#endif
-
 #define xfs_buf_target_name(target)    \
        ({ char __b[BDEVNAME_SIZE]; bdevname((target)->bt_bdev, __b); __b; })
 
@@ -365,10 +381,6 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
 
 #define xfs_bpin(bp)           xfs_buf_pin(bp)
 #define xfs_bunpin(bp)         xfs_buf_unpin(bp)
-
-#define xfs_buftrace(id, bp)   \
-           xfs_buf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
-
 #define xfs_biodone(bp)                xfs_buf_ioend(bp, 0)
 
 #define xfs_biomove(bp, off, len, data, rw) \
index 08be36d7326c1ee84830046b2b8a7a0d7a058b8a..7501b85fd8606bb94d8983f3175505bf580ec456 100644 (file)
@@ -19,6 +19,7 @@
 #include "xfs_vnodeops.h"
 #include "xfs_bmap_btree.h"
 #include "xfs_inode.h"
+#include "xfs_trace.h"
 
 int  fs_noerr(void) { return 0; }
 int  fs_nosys(void) { return ENOSYS; }
@@ -51,6 +52,8 @@ xfs_flushinval_pages(
        struct address_space *mapping = VFS_I(ip)->i_mapping;
        int             ret = 0;
 
+       trace_xfs_pagecache_inval(ip, first, last);
+
        if (mapping->nrpages) {
                xfs_iflags_clear(ip, XFS_ITRUNCATED);
                ret = filemap_write_and_wait(mapping);
index 5bb523d7f37e9263399444379f9ac16451b4dd62..a034cf62443702283af914a073239a1ee530a8da 100644 (file)
@@ -51,6 +51,7 @@
 #include "xfs_quota.h"
 #include "xfs_inode_item.h"
 #include "xfs_export.h"
+#include "xfs_trace.h"
 
 #include <linux/capability.h>
 #include <linux/dcache.h>
index eafcc7c1870687817c663816995894f0cfa4c127..be1527b1670ccbb36e2dc1c963133efa75975405 100644 (file)
@@ -46,6 +46,7 @@
 #include "xfs_attr.h"
 #include "xfs_ioctl.h"
 #include "xfs_ioctl32.h"
+#include "xfs_trace.h"
 
 #define  _NATIVE_IOC(cmd, type) \
          _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(type))
index 1f3b4b8f7dd45195b71e41f6ea4df2a6a0b110c9..225946012d0b3d2015e72a81d62a751ac0a1df84 100644 (file)
@@ -47,6 +47,7 @@
 #include "xfs_buf_item.h"
 #include "xfs_utils.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 #include <linux/capability.h>
 #include <linux/xattr.h>
@@ -793,7 +794,7 @@ xfs_setup_inode(
        struct inode            *inode = &ip->i_vnode;
 
        inode->i_ino = ip->i_ino;
-       inode->i_state = I_NEW|I_LOCK;
+       inode->i_state = I_NEW;
        inode_add_to_lists(ip->i_mount->m_super, inode);
 
        inode->i_mode   = ip->i_d.di_mode;
index 6127e24062d0cc060f0d0a05789ffca0e4b2ea74..5af0c81ca1ae1d61b978d70dc437843db35cb75e 100644 (file)
@@ -40,7 +40,6 @@
 #include <sv.h>
 #include <time.h>
 
-#include <support/ktrace.h>
 #include <support/debug.h>
 #include <support/uuid.h>
 
index 1bf47f219c971c9da83b6a8208531d47d2f58921..0d32457abef16cc557c691d5e037e2853a0367da 100644 (file)
 #include "xfs_utils.h"
 #include "xfs_iomap.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 #include <linux/capability.h>
 #include <linux/writeback.h>
 
 
-#if defined(XFS_RW_TRACE)
-void
-xfs_rw_enter_trace(
-       int                     tag,
-       xfs_inode_t             *ip,
-       void                    *data,
-       size_t                  segs,
-       loff_t                  offset,
-       int                     ioflags)
-{
-       if (ip->i_rwtrace == NULL)
-               return;
-       ktrace_enter(ip->i_rwtrace,
-               (void *)(unsigned long)tag,
-               (void *)ip,
-               (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
-               (void *)data,
-               (void *)((unsigned long)segs),
-               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(offset & 0xffffffff)),
-               (void *)((unsigned long)ioflags),
-               (void *)((unsigned long)((ip->i_new_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(ip->i_new_size & 0xffffffff)),
-               (void *)((unsigned long)current_pid()),
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL);
-}
-
-void
-xfs_inval_cached_trace(
-       xfs_inode_t     *ip,
-       xfs_off_t       offset,
-       xfs_off_t       len,
-       xfs_off_t       first,
-       xfs_off_t       last)
-{
-
-       if (ip->i_rwtrace == NULL)
-               return;
-       ktrace_enter(ip->i_rwtrace,
-               (void *)(__psint_t)XFS_INVAL_CACHED,
-               (void *)ip,
-               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(offset & 0xffffffff)),
-               (void *)((unsigned long)((len >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(len & 0xffffffff)),
-               (void *)((unsigned long)((first >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(first & 0xffffffff)),
-               (void *)((unsigned long)((last >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(last & 0xffffffff)),
-               (void *)((unsigned long)current_pid()),
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL);
-}
-#endif
-
 /*
  *     xfs_iozero
  *
@@ -250,8 +189,7 @@ xfs_read(
                }
        }
 
-       xfs_rw_enter_trace(XFS_READ_ENTER, ip,
-                               (void *)iovp, segs, *offset, ioflags);
+       trace_xfs_file_read(ip, size, *offset, ioflags);
 
        iocb->ki_pos = *offset;
        ret = generic_file_aio_read(iocb, iovp, segs, *offset);
@@ -292,8 +230,9 @@ xfs_splice_read(
                        return -error;
                }
        }
-       xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, ip,
-                          pipe, count, *ppos, ioflags);
+
+       trace_xfs_file_splice_read(ip, count, *ppos, ioflags);
+
        ret = generic_file_splice_read(infilp, ppos, pipe, count, flags);
        if (ret > 0)
                XFS_STATS_ADD(xs_read_bytes, ret);
@@ -342,8 +281,8 @@ xfs_splice_write(
                ip->i_new_size = new_size;
        xfs_iunlock(ip, XFS_ILOCK_EXCL);
 
-       xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, ip,
-                          pipe, count, *ppos, ioflags);
+       trace_xfs_file_splice_write(ip, count, *ppos, ioflags);
+
        ret = generic_file_splice_write(pipe, outfilp, ppos, count, flags);
        if (ret > 0)
                XFS_STATS_ADD(xs_write_bytes, ret);
@@ -710,8 +649,6 @@ start:
        if ((ioflags & IO_ISDIRECT)) {
                if (mapping->nrpages) {
                        WARN_ON(need_i_mutex == 0);
-                       xfs_inval_cached_trace(xip, pos, -1,
-                                       (pos & PAGE_CACHE_MASK), -1);
                        error = xfs_flushinval_pages(xip,
                                        (pos & PAGE_CACHE_MASK),
                                        -1, FI_REMAPF_LOCKED);
@@ -728,8 +665,7 @@ start:
                        need_i_mutex = 0;
                }
 
-               xfs_rw_enter_trace(XFS_DIOWR_ENTER, xip, (void *)iovp, segs,
-                               *offset, ioflags);
+               trace_xfs_file_direct_write(xip, count, *offset, ioflags);
                ret = generic_file_direct_write(iocb, iovp,
                                &segs, pos, offset, count, ocount);
 
@@ -752,8 +688,7 @@ start:
                ssize_t ret2 = 0;
 
 write_retry:
-               xfs_rw_enter_trace(XFS_WRITE_ENTER, xip, (void *)iovp, segs,
-                               *offset, ioflags);
+               trace_xfs_file_buffered_write(xip, count, *offset, ioflags);
                ret2 = generic_file_buffered_write(iocb, iovp, segs,
                                pos, offset, count, ret);
                /*
@@ -858,7 +793,7 @@ int
 xfs_bdstrat_cb(struct xfs_buf *bp)
 {
        if (XFS_FORCED_SHUTDOWN(bp->b_mount)) {
-               xfs_buftrace("XFS__BDSTRAT IOERROR", bp);
+               trace_xfs_bdstrat_shut(bp, _RET_IP_);
                /*
                 * Metadata write that didn't get logged but
                 * written delayed anyway. These aren't associated
@@ -891,7 +826,7 @@ xfsbdstrat(
                return;
        }
 
-       xfs_buftrace("XFSBDSTRAT IOERROR", bp);
+       trace_xfs_bdstrat_shut(bp, _RET_IP_);
        xfs_bioerror_relse(bp);
 }
 
index e6be37dbd0e9f8865e81e5b442758d2c7d24dcaa..d1f7789c7ffb74994932015a48c133fda97054e9 100644 (file)
 
 struct xfs_mount;
 struct xfs_inode;
-struct xfs_bmbt_irec;
 struct xfs_buf;
-struct xfs_iomap;
-
-#if defined(XFS_RW_TRACE)
-/*
- * Defines for the trace mechanisms in xfs_lrw.c.
- */
-#define        XFS_RW_KTRACE_SIZE      128
-
-#define        XFS_READ_ENTER          1
-#define        XFS_WRITE_ENTER         2
-#define XFS_IOMAP_READ_ENTER   3
-#define        XFS_IOMAP_WRITE_ENTER   4
-#define        XFS_IOMAP_READ_MAP      5
-#define        XFS_IOMAP_WRITE_MAP     6
-#define        XFS_IOMAP_WRITE_NOSPACE 7
-#define        XFS_ITRUNC_START        8
-#define        XFS_ITRUNC_FINISH1      9
-#define        XFS_ITRUNC_FINISH2      10
-#define        XFS_CTRUNC1             11
-#define        XFS_CTRUNC2             12
-#define        XFS_CTRUNC3             13
-#define        XFS_CTRUNC4             14
-#define        XFS_CTRUNC5             15
-#define        XFS_CTRUNC6             16
-#define        XFS_BUNMAP              17
-#define        XFS_INVAL_CACHED        18
-#define        XFS_DIORD_ENTER         19
-#define        XFS_DIOWR_ENTER         20
-#define        XFS_WRITEPAGE_ENTER     22
-#define        XFS_RELEASEPAGE_ENTER   23
-#define        XFS_INVALIDPAGE_ENTER   24
-#define        XFS_IOMAP_ALLOC_ENTER   25
-#define        XFS_IOMAP_ALLOC_MAP     26
-#define        XFS_IOMAP_UNWRITTEN     27
-#define XFS_SPLICE_READ_ENTER  28
-#define XFS_SPLICE_WRITE_ENTER 29
-extern void xfs_rw_enter_trace(int, struct xfs_inode *,
-               void *, size_t, loff_t, int);
-extern void xfs_inval_cached_trace(struct xfs_inode *,
-               xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t);
-#else
-#define xfs_rw_enter_trace(tag, ip, data, size, offset, ioflags)
-#define xfs_inval_cached_trace(ip, offset, len, first, last)
-#endif
 
 /* errors from xfsbdstrat() must be extracted from the buffer */
 extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
index 1bfb0e98019319a84b10e9f148b73874ae979b0c..09783cc444ac036cc3782d65f3dde39565e75e40 100644 (file)
@@ -15,6 +15,7 @@
  * along with this program; if not, write the Free Software Foundation,
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
 #include "xfs.h"
 #include "xfs_bit.h"
 #include "xfs_log.h"
 #include "xfs_trans_priv.h"
 #include "xfs_filestream.h"
 #include "xfs_da_btree.h"
-#include "xfs_dir2_trace.h"
 #include "xfs_extfree_item.h"
 #include "xfs_mru_cache.h"
 #include "xfs_inode_item.h"
 #include "xfs_sync.h"
+#include "xfs_trace.h"
 
 #include <linux/namei.h>
 #include <linux/init.h>
@@ -1525,8 +1526,6 @@ xfs_fs_fill_super(
                goto fail_vnrele;
 
        kfree(mtpt);
-
-       xfs_itrace_exit(XFS_I(sb->s_root->d_inode));
        return 0;
 
  out_filestream_unmount:
@@ -1601,94 +1600,6 @@ static struct file_system_type xfs_fs_type = {
        .fs_flags               = FS_REQUIRES_DEV,
 };
 
-STATIC int __init
-xfs_alloc_trace_bufs(void)
-{
-#ifdef XFS_ALLOC_TRACE
-       xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL);
-       if (!xfs_alloc_trace_buf)
-               goto out;
-#endif
-#ifdef XFS_BMAP_TRACE
-       xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL);
-       if (!xfs_bmap_trace_buf)
-               goto out_free_alloc_trace;
-#endif
-#ifdef XFS_BTREE_TRACE
-       xfs_allocbt_trace_buf = ktrace_alloc(XFS_ALLOCBT_TRACE_SIZE,
-                                            KM_MAYFAIL);
-       if (!xfs_allocbt_trace_buf)
-               goto out_free_bmap_trace;
-
-       xfs_inobt_trace_buf = ktrace_alloc(XFS_INOBT_TRACE_SIZE, KM_MAYFAIL);
-       if (!xfs_inobt_trace_buf)
-               goto out_free_allocbt_trace;
-
-       xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL);
-       if (!xfs_bmbt_trace_buf)
-               goto out_free_inobt_trace;
-#endif
-#ifdef XFS_ATTR_TRACE
-       xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL);
-       if (!xfs_attr_trace_buf)
-               goto out_free_bmbt_trace;
-#endif
-#ifdef XFS_DIR2_TRACE
-       xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL);
-       if (!xfs_dir2_trace_buf)
-               goto out_free_attr_trace;
-#endif
-
-       return 0;
-
-#ifdef XFS_DIR2_TRACE
- out_free_attr_trace:
-#endif
-#ifdef XFS_ATTR_TRACE
-       ktrace_free(xfs_attr_trace_buf);
- out_free_bmbt_trace:
-#endif
-#ifdef XFS_BTREE_TRACE
-       ktrace_free(xfs_bmbt_trace_buf);
- out_free_inobt_trace:
-       ktrace_free(xfs_inobt_trace_buf);
- out_free_allocbt_trace:
-       ktrace_free(xfs_allocbt_trace_buf);
- out_free_bmap_trace:
-#endif
-#ifdef XFS_BMAP_TRACE
-       ktrace_free(xfs_bmap_trace_buf);
- out_free_alloc_trace:
-#endif
-#ifdef XFS_ALLOC_TRACE
-       ktrace_free(xfs_alloc_trace_buf);
- out:
-#endif
-       return -ENOMEM;
-}
-
-STATIC void
-xfs_free_trace_bufs(void)
-{
-#ifdef XFS_DIR2_TRACE
-       ktrace_free(xfs_dir2_trace_buf);
-#endif
-#ifdef XFS_ATTR_TRACE
-       ktrace_free(xfs_attr_trace_buf);
-#endif
-#ifdef XFS_BTREE_TRACE
-       ktrace_free(xfs_bmbt_trace_buf);
-       ktrace_free(xfs_inobt_trace_buf);
-       ktrace_free(xfs_allocbt_trace_buf);
-#endif
-#ifdef XFS_BMAP_TRACE
-       ktrace_free(xfs_bmap_trace_buf);
-#endif
-#ifdef XFS_ALLOC_TRACE
-       ktrace_free(xfs_alloc_trace_buf);
-#endif
-}
-
 STATIC int __init
 xfs_init_zones(void)
 {
@@ -1830,7 +1741,6 @@ init_xfs_fs(void)
        printk(KERN_INFO XFS_VERSION_STRING " with "
                         XFS_BUILD_OPTIONS " enabled\n");
 
-       ktrace_init(64);
        xfs_ioend_init();
        xfs_dir_startup();
 
@@ -1838,13 +1748,9 @@ init_xfs_fs(void)
        if (error)
                goto out;
 
-       error = xfs_alloc_trace_bufs();
-       if (error)
-               goto out_destroy_zones;
-
        error = xfs_mru_cache_init();
        if (error)
-               goto out_free_trace_buffers;
+               goto out_destroy_zones;
 
        error = xfs_filestream_init();
        if (error)
@@ -1879,8 +1785,6 @@ init_xfs_fs(void)
        xfs_filestream_uninit();
  out_mru_cache_uninit:
        xfs_mru_cache_uninit();
- out_free_trace_buffers:
-       xfs_free_trace_bufs();
  out_destroy_zones:
        xfs_destroy_zones();
  out:
@@ -1897,9 +1801,7 @@ exit_xfs_fs(void)
        xfs_buf_terminate();
        xfs_filestream_uninit();
        xfs_mru_cache_uninit();
-       xfs_free_trace_bufs();
        xfs_destroy_zones();
-       ktrace_uninit();
 }
 
 module_init(init_xfs_fs);
index 18175ebd58eda0206f6d659cab9b4dddd9d19489..233d4b9881b11b52bd1d2fb3d5df83865d320186 100644 (file)
@@ -56,12 +56,6 @@ extern void xfs_qm_exit(void);
 # define XFS_BIGFS_STRING
 #endif
 
-#ifdef CONFIG_XFS_TRACE
-# define XFS_TRACE_STRING      "tracing, "
-#else
-# define XFS_TRACE_STRING
-#endif
-
 #ifdef CONFIG_XFS_DMAPI
 # define XFS_DMAPI_STRING      "dmapi support, "
 #else
@@ -78,7 +72,6 @@ extern void xfs_qm_exit(void);
                                XFS_SECURITY_STRING \
                                XFS_REALTIME_STRING \
                                XFS_BIGFS_STRING \
-                               XFS_TRACE_STRING \
                                XFS_DMAPI_STRING \
                                XFS_DBG_STRING /* DBG must be last */
 
index d895a3a960f5116f64d5931d03d18944ada862dd..6fed97a8cd3e29ef46791c24ebecf16b6ef5ba11 100644 (file)
@@ -44,6 +44,7 @@
 #include "xfs_inode_item.h"
 #include "xfs_rw.h"
 #include "xfs_quota.h"
+#include "xfs_trace.h"
 
 #include <linux/kthread.h>
 #include <linux/freezer.h>
diff --git a/fs/xfs/linux-2.6/xfs_trace.c b/fs/xfs/linux-2.6/xfs_trace.c
new file mode 100644 (file)
index 0000000..856eb3c
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2009, Christoph Hellwig
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+#include "xfs.h"
+#include "xfs_fs.h"
+#include "xfs_types.h"
+#include "xfs_bit.h"
+#include "xfs_log.h"
+#include "xfs_inum.h"
+#include "xfs_trans.h"
+#include "xfs_sb.h"
+#include "xfs_ag.h"
+#include "xfs_dir2.h"
+#include "xfs_da_btree.h"
+#include "xfs_bmap_btree.h"
+#include "xfs_alloc_btree.h"
+#include "xfs_ialloc_btree.h"
+#include "xfs_dir2_sf.h"
+#include "xfs_attr_sf.h"
+#include "xfs_dinode.h"
+#include "xfs_inode.h"
+#include "xfs_btree.h"
+#include "xfs_dmapi.h"
+#include "xfs_mount.h"
+#include "xfs_ialloc.h"
+#include "xfs_itable.h"
+#include "xfs_alloc.h"
+#include "xfs_bmap.h"
+#include "xfs_attr.h"
+#include "xfs_attr_sf.h"
+#include "xfs_attr_leaf.h"
+#include "xfs_log_priv.h"
+#include "xfs_buf_item.h"
+#include "xfs_quota.h"
+#include "xfs_iomap.h"
+#include "xfs_aops.h"
+#include "quota/xfs_dquot_item.h"
+#include "quota/xfs_dquot.h"
+
+/*
+ * Format fsblock number into a static buffer & return it.
+ */
+STATIC char *xfs_fmtfsblock(xfs_fsblock_t bno)
+{
+       static char rval[50];
+
+       if (bno == NULLFSBLOCK)
+               sprintf(rval, "NULLFSBLOCK");
+       else if (isnullstartblock(bno))
+               sprintf(rval, "NULLSTARTBLOCK(%lld)", startblockval(bno));
+       else
+               sprintf(rval, "%lld", (xfs_dfsbno_t)bno);
+       return rval;
+}
+
+/*
+ * We include this last to have the helpers above available for the trace
+ * event implementations.
+ */
+#define CREATE_TRACE_POINTS
+#include "xfs_trace.h"
diff --git a/fs/xfs/linux-2.6/xfs_trace.h b/fs/xfs/linux-2.6/xfs_trace.h
new file mode 100644 (file)
index 0000000..c40834b
--- /dev/null
@@ -0,0 +1,1369 @@
+/*
+ * Copyright (c) 2009, Christoph Hellwig
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM xfs
+
+#if !defined(_TRACE_XFS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_XFS_H
+
+#include <linux/tracepoint.h>
+
+struct xfs_agf;
+struct xfs_alloc_arg;
+struct xfs_attr_list_context;
+struct xfs_buf_log_item;
+struct xfs_da_args;
+struct xfs_da_node_entry;
+struct xfs_dquot;
+struct xlog_ticket;
+struct log;
+
+#define DEFINE_ATTR_LIST_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_attr_list_context *ctx), \
+       TP_ARGS(ctx), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(u32, hashval) \
+               __field(u32, blkno) \
+               __field(u32, offset) \
+               __field(void *, alist) \
+               __field(int, bufsize) \
+               __field(int, count) \
+               __field(int, firstu) \
+               __field(int, dupcnt) \
+               __field(int, flags) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(ctx->dp)->i_sb->s_dev; \
+               __entry->ino = ctx->dp->i_ino; \
+               __entry->hashval = ctx->cursor->hashval; \
+               __entry->blkno = ctx->cursor->blkno; \
+               __entry->offset = ctx->cursor->offset; \
+               __entry->alist = ctx->alist; \
+               __entry->bufsize = ctx->bufsize; \
+               __entry->count = ctx->count; \
+               __entry->firstu = ctx->firstu; \
+               __entry->flags = ctx->flags; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u " \
+                 "alist 0x%p size %u count %u firstu %u flags %d %s", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                  __entry->ino, \
+                  __entry->hashval, \
+                  __entry->blkno, \
+                  __entry->offset, \
+                  __entry->dupcnt, \
+                  __entry->alist, \
+                  __entry->bufsize, \
+                  __entry->count, \
+                  __entry->firstu, \
+                  __entry->flags, \
+                  __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS) \
+       ) \
+)
+DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf);
+DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf_all);
+DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf);
+DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf_end);
+DEFINE_ATTR_LIST_EVENT(xfs_attr_list_full);
+DEFINE_ATTR_LIST_EVENT(xfs_attr_list_add);
+DEFINE_ATTR_LIST_EVENT(xfs_attr_list_wrong_blk);
+DEFINE_ATTR_LIST_EVENT(xfs_attr_list_notfound);
+
+TRACE_EVENT(xfs_attr_list_node_descend,
+       TP_PROTO(struct xfs_attr_list_context *ctx,
+                struct xfs_da_node_entry *btree),
+       TP_ARGS(ctx, btree),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(u32, hashval)
+               __field(u32, blkno)
+               __field(u32, offset)
+               __field(void *, alist)
+               __field(int, bufsize)
+               __field(int, count)
+               __field(int, firstu)
+               __field(int, dupcnt)
+               __field(int, flags)
+               __field(u32, bt_hashval)
+               __field(u32, bt_before)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ctx->dp)->i_sb->s_dev;
+               __entry->ino = ctx->dp->i_ino;
+               __entry->hashval = ctx->cursor->hashval;
+               __entry->blkno = ctx->cursor->blkno;
+               __entry->offset = ctx->cursor->offset;
+               __entry->alist = ctx->alist;
+               __entry->bufsize = ctx->bufsize;
+               __entry->count = ctx->count;
+               __entry->firstu = ctx->firstu;
+               __entry->flags = ctx->flags;
+               __entry->bt_hashval = be32_to_cpu(btree->hashval);
+               __entry->bt_before = be32_to_cpu(btree->before);
+       ),
+       TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u "
+                 "alist 0x%p size %u count %u firstu %u flags %d %s "
+                 "node hashval %u, node before %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                  __entry->ino,
+                  __entry->hashval,
+                  __entry->blkno,
+                  __entry->offset,
+                  __entry->dupcnt,
+                  __entry->alist,
+                  __entry->bufsize,
+                  __entry->count,
+                  __entry->firstu,
+                  __entry->flags,
+                  __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS),
+                  __entry->bt_hashval,
+                  __entry->bt_before)
+);
+
+TRACE_EVENT(xfs_iext_insert,
+       TP_PROTO(struct xfs_inode *ip, xfs_extnum_t idx,
+                struct xfs_bmbt_irec *r, int state, unsigned long caller_ip),
+       TP_ARGS(ip, idx, r, state, caller_ip),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(xfs_extnum_t, idx)
+               __field(xfs_fileoff_t, startoff)
+               __field(xfs_fsblock_t, startblock)
+               __field(xfs_filblks_t, blockcount)
+               __field(xfs_exntst_t, state)
+               __field(int, bmap_state)
+               __field(unsigned long, caller_ip)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ip)->i_sb->s_dev;
+               __entry->ino = ip->i_ino;
+               __entry->idx = idx;
+               __entry->startoff = r->br_startoff;
+               __entry->startblock = r->br_startblock;
+               __entry->blockcount = r->br_blockcount;
+               __entry->state = r->br_state;
+               __entry->bmap_state = state;
+               __entry->caller_ip = caller_ip;
+       ),
+       TP_printk("dev %d:%d ino 0x%llx state %s idx %ld "
+                 "offset %lld block %s count %lld flag %d caller %pf",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino,
+                 __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS),
+                 (long)__entry->idx,
+                 __entry->startoff,
+                 xfs_fmtfsblock(__entry->startblock),
+                 __entry->blockcount,
+                 __entry->state,
+                 (char *)__entry->caller_ip)
+);
+
+#define DEFINE_BMAP_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_inode *ip, xfs_extnum_t idx, int state, \
+                unsigned long caller_ip), \
+       TP_ARGS(ip, idx, state, caller_ip), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(xfs_extnum_t, idx) \
+               __field(xfs_fileoff_t, startoff) \
+               __field(xfs_fsblock_t, startblock) \
+               __field(xfs_filblks_t, blockcount) \
+               __field(xfs_exntst_t, state) \
+               __field(int, bmap_state) \
+               __field(unsigned long, caller_ip) \
+       ), \
+       TP_fast_assign( \
+               struct xfs_ifork        *ifp = (state & BMAP_ATTRFORK) ? \
+                                               ip->i_afp : &ip->i_df; \
+               struct xfs_bmbt_irec    r; \
+       \
+               xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &r); \
+               __entry->dev = VFS_I(ip)->i_sb->s_dev; \
+               __entry->ino = ip->i_ino; \
+               __entry->idx = idx; \
+               __entry->startoff = r.br_startoff; \
+               __entry->startblock = r.br_startblock; \
+               __entry->blockcount = r.br_blockcount; \
+               __entry->state = r.br_state; \
+               __entry->bmap_state = state; \
+               __entry->caller_ip = caller_ip; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx state %s idx %ld " \
+                 "offset %lld block %s count %lld flag %d caller %pf", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS), \
+                 (long)__entry->idx, \
+                 __entry->startoff, \
+                 xfs_fmtfsblock(__entry->startblock), \
+                 __entry->blockcount, \
+                 __entry->state, \
+                 (char *)__entry->caller_ip) \
+)
+
+DEFINE_BMAP_EVENT(xfs_iext_remove);
+DEFINE_BMAP_EVENT(xfs_bmap_pre_update);
+DEFINE_BMAP_EVENT(xfs_bmap_post_update);
+DEFINE_BMAP_EVENT(xfs_extlist);
+
+#define DEFINE_BUF_EVENT(tname) \
+TRACE_EVENT(tname, \
+       TP_PROTO(struct xfs_buf *bp, unsigned long caller_ip), \
+       TP_ARGS(bp, caller_ip), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_daddr_t, bno) \
+               __field(size_t, buffer_length) \
+               __field(int, hold) \
+               __field(int, pincount) \
+               __field(unsigned, lockval) \
+               __field(unsigned, flags) \
+               __field(unsigned long, caller_ip) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = bp->b_target->bt_dev; \
+               __entry->bno = bp->b_bn; \
+               __entry->buffer_length = bp->b_buffer_length; \
+               __entry->hold = atomic_read(&bp->b_hold); \
+               __entry->pincount = atomic_read(&bp->b_pin_count); \
+               __entry->lockval = xfs_buf_lock_value(bp); \
+               __entry->flags = bp->b_flags; \
+               __entry->caller_ip = caller_ip; \
+       ), \
+       TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " \
+                 "lock %d flags %s caller %pf", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 (unsigned long long)__entry->bno, \
+                 __entry->buffer_length, \
+                 __entry->hold, \
+                 __entry->pincount, \
+                 __entry->lockval, \
+                 __print_flags(__entry->flags, "|", XFS_BUF_FLAGS), \
+                 (void *)__entry->caller_ip) \
+)
+DEFINE_BUF_EVENT(xfs_buf_init);
+DEFINE_BUF_EVENT(xfs_buf_free);
+DEFINE_BUF_EVENT(xfs_buf_hold);
+DEFINE_BUF_EVENT(xfs_buf_rele);
+DEFINE_BUF_EVENT(xfs_buf_pin);
+DEFINE_BUF_EVENT(xfs_buf_unpin);
+DEFINE_BUF_EVENT(xfs_buf_iodone);
+DEFINE_BUF_EVENT(xfs_buf_iorequest);
+DEFINE_BUF_EVENT(xfs_buf_bawrite);
+DEFINE_BUF_EVENT(xfs_buf_bdwrite);
+DEFINE_BUF_EVENT(xfs_buf_lock);
+DEFINE_BUF_EVENT(xfs_buf_lock_done);
+DEFINE_BUF_EVENT(xfs_buf_cond_lock);
+DEFINE_BUF_EVENT(xfs_buf_unlock);
+DEFINE_BUF_EVENT(xfs_buf_ordered_retry);
+DEFINE_BUF_EVENT(xfs_buf_iowait);
+DEFINE_BUF_EVENT(xfs_buf_iowait_done);
+DEFINE_BUF_EVENT(xfs_buf_delwri_queue);
+DEFINE_BUF_EVENT(xfs_buf_delwri_dequeue);
+DEFINE_BUF_EVENT(xfs_buf_delwri_split);
+DEFINE_BUF_EVENT(xfs_buf_get_noaddr);
+DEFINE_BUF_EVENT(xfs_bdstrat_shut);
+DEFINE_BUF_EVENT(xfs_buf_item_relse);
+DEFINE_BUF_EVENT(xfs_buf_item_iodone);
+DEFINE_BUF_EVENT(xfs_buf_item_iodone_async);
+DEFINE_BUF_EVENT(xfs_buf_error_relse);
+DEFINE_BUF_EVENT(xfs_trans_read_buf_io);
+DEFINE_BUF_EVENT(xfs_trans_read_buf_shut);
+
+/* not really buffer traces, but the buf provides useful information */
+DEFINE_BUF_EVENT(xfs_btree_corrupt);
+DEFINE_BUF_EVENT(xfs_da_btree_corrupt);
+DEFINE_BUF_EVENT(xfs_reset_dqcounts);
+DEFINE_BUF_EVENT(xfs_inode_item_push);
+
+/* pass flags explicitly */
+#define DEFINE_BUF_FLAGS_EVENT(tname) \
+TRACE_EVENT(tname, \
+       TP_PROTO(struct xfs_buf *bp, unsigned flags, unsigned long caller_ip), \
+       TP_ARGS(bp, flags, caller_ip), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_daddr_t, bno) \
+               __field(size_t, buffer_length) \
+               __field(int, hold) \
+               __field(int, pincount) \
+               __field(unsigned, lockval) \
+               __field(unsigned, flags) \
+               __field(unsigned long, caller_ip) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = bp->b_target->bt_dev; \
+               __entry->bno = bp->b_bn; \
+               __entry->buffer_length = bp->b_buffer_length; \
+               __entry->flags = flags; \
+               __entry->hold = atomic_read(&bp->b_hold); \
+               __entry->pincount = atomic_read(&bp->b_pin_count); \
+               __entry->lockval = xfs_buf_lock_value(bp); \
+               __entry->caller_ip = caller_ip; \
+       ), \
+       TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " \
+                 "lock %d flags %s caller %pf", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 (unsigned long long)__entry->bno, \
+                 __entry->buffer_length, \
+                 __entry->hold, \
+                 __entry->pincount, \
+                 __entry->lockval, \
+                 __print_flags(__entry->flags, "|", XFS_BUF_FLAGS), \
+                 (void *)__entry->caller_ip) \
+)
+DEFINE_BUF_FLAGS_EVENT(xfs_buf_find);
+DEFINE_BUF_FLAGS_EVENT(xfs_buf_get);
+DEFINE_BUF_FLAGS_EVENT(xfs_buf_read);
+
+TRACE_EVENT(xfs_buf_ioerror,
+       TP_PROTO(struct xfs_buf *bp, int error, unsigned long caller_ip),
+       TP_ARGS(bp, error, caller_ip),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_daddr_t, bno)
+               __field(size_t, buffer_length)
+               __field(unsigned, flags)
+               __field(int, hold)
+               __field(int, pincount)
+               __field(unsigned, lockval)
+               __field(int, error)
+               __field(unsigned long, caller_ip)
+       ),
+       TP_fast_assign(
+               __entry->dev = bp->b_target->bt_dev;
+               __entry->bno = bp->b_bn;
+               __entry->buffer_length = bp->b_buffer_length;
+               __entry->hold = atomic_read(&bp->b_hold);
+               __entry->pincount = atomic_read(&bp->b_pin_count);
+               __entry->lockval = xfs_buf_lock_value(bp);
+               __entry->error = error;
+               __entry->flags = bp->b_flags;
+               __entry->caller_ip = caller_ip;
+       ),
+       TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
+                 "lock %d error %d flags %s caller %pf",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long long)__entry->bno,
+                 __entry->buffer_length,
+                 __entry->hold,
+                 __entry->pincount,
+                 __entry->lockval,
+                 __entry->error,
+                 __print_flags(__entry->flags, "|", XFS_BUF_FLAGS),
+                 (void *)__entry->caller_ip)
+);
+
+#define DEFINE_BUF_ITEM_EVENT(tname) \
+TRACE_EVENT(tname, \
+       TP_PROTO(struct xfs_buf_log_item *bip), \
+       TP_ARGS(bip), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_daddr_t, buf_bno) \
+               __field(size_t, buf_len) \
+               __field(int, buf_hold) \
+               __field(int, buf_pincount) \
+               __field(int, buf_lockval) \
+               __field(unsigned, buf_flags) \
+               __field(unsigned, bli_recur) \
+               __field(int, bli_refcount) \
+               __field(unsigned, bli_flags) \
+               __field(void *, li_desc) \
+               __field(unsigned, li_flags) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = bip->bli_buf->b_target->bt_dev; \
+               __entry->bli_flags = bip->bli_flags; \
+               __entry->bli_recur = bip->bli_recur; \
+               __entry->bli_refcount = atomic_read(&bip->bli_refcount); \
+               __entry->buf_bno = bip->bli_buf->b_bn; \
+               __entry->buf_len = bip->bli_buf->b_buffer_length; \
+               __entry->buf_flags = bip->bli_buf->b_flags; \
+               __entry->buf_hold = atomic_read(&bip->bli_buf->b_hold); \
+               __entry->buf_pincount = \
+                       atomic_read(&bip->bli_buf->b_pin_count); \
+               __entry->buf_lockval = xfs_buf_lock_value(bip->bli_buf); \
+               __entry->li_desc = bip->bli_item.li_desc; \
+               __entry->li_flags = bip->bli_item.li_flags; \
+       ), \
+       TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " \
+                 "lock %d flags %s recur %d refcount %d bliflags %s " \
+                 "lidesc 0x%p liflags %s", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 (unsigned long long)__entry->buf_bno, \
+                 __entry->buf_len, \
+                 __entry->buf_hold, \
+                 __entry->buf_pincount, \
+                 __entry->buf_lockval, \
+                 __print_flags(__entry->buf_flags, "|", XFS_BUF_FLAGS), \
+                 __entry->bli_recur, \
+                 __entry->bli_refcount, \
+                 __print_flags(__entry->bli_flags, "|", XFS_BLI_FLAGS), \
+                 __entry->li_desc, \
+                 __print_flags(__entry->li_flags, "|", XFS_LI_FLAGS)) \
+)
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_trylock);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock_stale);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed);
+DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf_recur);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb_recur);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf_recur);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_log_buf);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_brelse);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_bjoin);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release);
+DEFINE_BUF_ITEM_EVENT(xfs_trans_binval);
+
+#define DEFINE_LOCK_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, \
+                unsigned long caller_ip), \
+       TP_ARGS(ip,  lock_flags, caller_ip), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(int, lock_flags) \
+               __field(unsigned long, caller_ip) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(ip)->i_sb->s_dev; \
+               __entry->ino = ip->i_ino; \
+               __entry->lock_flags = lock_flags; \
+               __entry->caller_ip = caller_ip; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx flags %s caller %pf", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __print_flags(__entry->lock_flags, "|", XFS_LOCK_FLAGS), \
+                 (void *)__entry->caller_ip) \
+)
+
+DEFINE_LOCK_EVENT(xfs_ilock);
+DEFINE_LOCK_EVENT(xfs_ilock_nowait);
+DEFINE_LOCK_EVENT(xfs_ilock_demote);
+DEFINE_LOCK_EVENT(xfs_iunlock);
+
+#define DEFINE_IGET_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_inode *ip), \
+       TP_ARGS(ip), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(ip)->i_sb->s_dev; \
+               __entry->ino = ip->i_ino; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino) \
+)
+DEFINE_IGET_EVENT(xfs_iget_skip);
+DEFINE_IGET_EVENT(xfs_iget_reclaim);
+DEFINE_IGET_EVENT(xfs_iget_found);
+DEFINE_IGET_EVENT(xfs_iget_alloc);
+
+#define DEFINE_INODE_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), \
+       TP_ARGS(ip, caller_ip), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(int, count) \
+               __field(unsigned long, caller_ip) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(ip)->i_sb->s_dev; \
+               __entry->ino = ip->i_ino; \
+               __entry->count = atomic_read(&VFS_I(ip)->i_count); \
+               __entry->caller_ip = caller_ip; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx count %d caller %pf", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __entry->count, \
+                 (char *)__entry->caller_ip) \
+)
+DEFINE_INODE_EVENT(xfs_ihold);
+DEFINE_INODE_EVENT(xfs_irele);
+/* the old xfs_itrace_entry tracer - to be replaced by s.th. in the VFS */
+DEFINE_INODE_EVENT(xfs_inode);
+#define xfs_itrace_entry(ip)    \
+       trace_xfs_inode(ip, _THIS_IP_)
+
+#define DEFINE_DQUOT_EVENT(tname) \
+TRACE_EVENT(tname, \
+       TP_PROTO(struct xfs_dquot *dqp), \
+       TP_ARGS(dqp), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(__be32, id) \
+               __field(unsigned, flags) \
+               __field(unsigned, nrefs) \
+               __field(unsigned long long, res_bcount) \
+               __field(unsigned long long, bcount) \
+               __field(unsigned long long, icount) \
+               __field(unsigned long long, blk_hardlimit) \
+               __field(unsigned long long, blk_softlimit) \
+               __field(unsigned long long, ino_hardlimit) \
+               __field(unsigned long long, ino_softlimit) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = dqp->q_mount->m_super->s_dev; \
+               __entry->id = dqp->q_core.d_id; \
+               __entry->flags = dqp->dq_flags; \
+               __entry->nrefs = dqp->q_nrefs; \
+               __entry->res_bcount = dqp->q_res_bcount; \
+               __entry->bcount = be64_to_cpu(dqp->q_core.d_bcount); \
+               __entry->icount = be64_to_cpu(dqp->q_core.d_icount); \
+               __entry->blk_hardlimit = \
+                       be64_to_cpu(dqp->q_core.d_blk_hardlimit); \
+               __entry->blk_softlimit = \
+                       be64_to_cpu(dqp->q_core.d_blk_softlimit); \
+               __entry->ino_hardlimit = \
+                       be64_to_cpu(dqp->q_core.d_ino_hardlimit); \
+               __entry->ino_softlimit = \
+                       be64_to_cpu(dqp->q_core.d_ino_softlimit); \
+       ), \
+       TP_printk("dev %d:%d id 0x%x flags %s nrefs %u res_bc 0x%llx " \
+                 "bcnt 0x%llx [hard 0x%llx | soft 0x%llx] " \
+                 "icnt 0x%llx [hard 0x%llx | soft 0x%llx]", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 be32_to_cpu(__entry->id), \
+                 __print_flags(__entry->flags, "|", XFS_DQ_FLAGS), \
+                 __entry->nrefs, \
+                 __entry->res_bcount, \
+                 __entry->bcount, \
+                 __entry->blk_hardlimit, \
+                 __entry->blk_softlimit, \
+                 __entry->icount, \
+                 __entry->ino_hardlimit, \
+                 __entry->ino_softlimit) \
+)
+DEFINE_DQUOT_EVENT(xfs_dqadjust);
+DEFINE_DQUOT_EVENT(xfs_dqshake_dirty);
+DEFINE_DQUOT_EVENT(xfs_dqshake_unlink);
+DEFINE_DQUOT_EVENT(xfs_dqreclaim_want);
+DEFINE_DQUOT_EVENT(xfs_dqreclaim_dirty);
+DEFINE_DQUOT_EVENT(xfs_dqreclaim_unlink);
+DEFINE_DQUOT_EVENT(xfs_dqattach_found);
+DEFINE_DQUOT_EVENT(xfs_dqattach_get);
+DEFINE_DQUOT_EVENT(xfs_dqinit);
+DEFINE_DQUOT_EVENT(xfs_dqreuse);
+DEFINE_DQUOT_EVENT(xfs_dqalloc);
+DEFINE_DQUOT_EVENT(xfs_dqtobp_read);
+DEFINE_DQUOT_EVENT(xfs_dqread);
+DEFINE_DQUOT_EVENT(xfs_dqread_fail);
+DEFINE_DQUOT_EVENT(xfs_dqlookup_found);
+DEFINE_DQUOT_EVENT(xfs_dqlookup_want);
+DEFINE_DQUOT_EVENT(xfs_dqlookup_freelist);
+DEFINE_DQUOT_EVENT(xfs_dqlookup_move);
+DEFINE_DQUOT_EVENT(xfs_dqlookup_done);
+DEFINE_DQUOT_EVENT(xfs_dqget_hit);
+DEFINE_DQUOT_EVENT(xfs_dqget_miss);
+DEFINE_DQUOT_EVENT(xfs_dqput);
+DEFINE_DQUOT_EVENT(xfs_dqput_wait);
+DEFINE_DQUOT_EVENT(xfs_dqput_free);
+DEFINE_DQUOT_EVENT(xfs_dqrele);
+DEFINE_DQUOT_EVENT(xfs_dqflush);
+DEFINE_DQUOT_EVENT(xfs_dqflush_force);
+DEFINE_DQUOT_EVENT(xfs_dqflush_done);
+/* not really iget events, but we re-use the format */
+DEFINE_IGET_EVENT(xfs_dquot_dqalloc);
+DEFINE_IGET_EVENT(xfs_dquot_dqdetach);
+
+
+#define DEFINE_LOGGRANT_EVENT(tname) \
+TRACE_EVENT(tname, \
+       TP_PROTO(struct log *log, struct xlog_ticket *tic), \
+       TP_ARGS(log, tic), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(unsigned, trans_type) \
+               __field(char, ocnt) \
+               __field(char, cnt) \
+               __field(int, curr_res) \
+               __field(int, unit_res) \
+               __field(unsigned int, flags) \
+               __field(void *, reserve_headq) \
+               __field(void *, write_headq) \
+               __field(int, grant_reserve_cycle) \
+               __field(int, grant_reserve_bytes) \
+               __field(int, grant_write_cycle) \
+               __field(int, grant_write_bytes) \
+               __field(int, curr_cycle) \
+               __field(int, curr_block) \
+               __field(xfs_lsn_t, tail_lsn) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = log->l_mp->m_super->s_dev; \
+               __entry->trans_type = tic->t_trans_type; \
+               __entry->ocnt = tic->t_ocnt; \
+               __entry->cnt = tic->t_cnt; \
+               __entry->curr_res = tic->t_curr_res; \
+               __entry->unit_res = tic->t_unit_res; \
+               __entry->flags = tic->t_flags; \
+               __entry->reserve_headq = log->l_reserve_headq; \
+               __entry->write_headq = log->l_write_headq; \
+               __entry->grant_reserve_cycle = log->l_grant_reserve_cycle; \
+               __entry->grant_reserve_bytes = log->l_grant_reserve_bytes; \
+               __entry->grant_write_cycle = log->l_grant_write_cycle; \
+               __entry->grant_write_bytes = log->l_grant_write_bytes; \
+               __entry->curr_cycle = log->l_curr_cycle; \
+               __entry->curr_block = log->l_curr_block; \
+               __entry->tail_lsn = log->l_tail_lsn; \
+       ), \
+       TP_printk("dev %d:%d type %s t_ocnt %u t_cnt %u t_curr_res %u " \
+                 "t_unit_res %u t_flags %s reserve_headq 0x%p " \
+                 "write_headq 0x%p grant_reserve_cycle %d " \
+                 "grant_reserve_bytes %d grant_write_cycle %d " \
+                 "grant_write_bytes %d curr_cycle %d curr_block %d " \
+                 "tail_cycle %d tail_block %d", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __print_symbolic(__entry->trans_type, XFS_TRANS_TYPES), \
+                 __entry->ocnt, \
+                 __entry->cnt, \
+                 __entry->curr_res, \
+                 __entry->unit_res, \
+                 __print_flags(__entry->flags, "|", XLOG_TIC_FLAGS), \
+                 __entry->reserve_headq, \
+                 __entry->write_headq, \
+                 __entry->grant_reserve_cycle, \
+                 __entry->grant_reserve_bytes, \
+                 __entry->grant_write_cycle, \
+                 __entry->grant_write_bytes, \
+                 __entry->curr_cycle, \
+                 __entry->curr_block, \
+                 CYCLE_LSN(__entry->tail_lsn), \
+                 BLOCK_LSN(__entry->tail_lsn) \
+       ) \
+)
+DEFINE_LOGGRANT_EVENT(xfs_log_done_nonperm);
+DEFINE_LOGGRANT_EVENT(xfs_log_done_perm);
+DEFINE_LOGGRANT_EVENT(xfs_log_reserve);
+DEFINE_LOGGRANT_EVENT(xfs_log_umount_write);
+DEFINE_LOGGRANT_EVENT(xfs_log_grant_enter);
+DEFINE_LOGGRANT_EVENT(xfs_log_grant_exit);
+DEFINE_LOGGRANT_EVENT(xfs_log_grant_error);
+DEFINE_LOGGRANT_EVENT(xfs_log_grant_sleep1);
+DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake1);
+DEFINE_LOGGRANT_EVENT(xfs_log_grant_sleep2);
+DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake2);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_enter);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_exit);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_error);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_sleep1);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_wake1);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_sleep2);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_wake2);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_enter);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_exit);
+DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_sub);
+DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_enter);
+DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_exit);
+DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_sub);
+
+#define DEFINE_RW_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_inode *ip, size_t count, loff_t offset, int flags), \
+       TP_ARGS(ip, count, offset, flags), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(xfs_fsize_t, size) \
+               __field(xfs_fsize_t, new_size) \
+               __field(loff_t, offset) \
+               __field(size_t, count) \
+               __field(int, flags) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(ip)->i_sb->s_dev; \
+               __entry->ino = ip->i_ino; \
+               __entry->size = ip->i_d.di_size; \
+               __entry->new_size = ip->i_new_size; \
+               __entry->offset = offset; \
+               __entry->count = count; \
+               __entry->flags = flags; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx " \
+                 "offset 0x%llx count 0x%zx ioflags %s", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __entry->size, \
+                 __entry->new_size, \
+                 __entry->offset, \
+                 __entry->count, \
+                 __print_flags(__entry->flags, "|", XFS_IO_FLAGS)) \
+)
+DEFINE_RW_EVENT(xfs_file_read);
+DEFINE_RW_EVENT(xfs_file_buffered_write);
+DEFINE_RW_EVENT(xfs_file_direct_write);
+DEFINE_RW_EVENT(xfs_file_splice_read);
+DEFINE_RW_EVENT(xfs_file_splice_write);
+
+
+#define DEFINE_PAGE_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct inode *inode, struct page *page, unsigned long off), \
+       TP_ARGS(inode, page, off), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(pgoff_t, pgoff) \
+               __field(loff_t, size) \
+               __field(unsigned long, offset) \
+               __field(int, delalloc) \
+               __field(int, unmapped) \
+               __field(int, unwritten) \
+       ), \
+       TP_fast_assign( \
+               int delalloc = -1, unmapped = -1, unwritten = -1; \
+       \
+               if (page_has_buffers(page)) \
+                       xfs_count_page_state(page, &delalloc, \
+                                            &unmapped, &unwritten); \
+               __entry->dev = inode->i_sb->s_dev; \
+               __entry->ino = XFS_I(inode)->i_ino; \
+               __entry->pgoff = page_offset(page); \
+               __entry->size = i_size_read(inode); \
+               __entry->offset = off; \
+               __entry->delalloc = delalloc; \
+               __entry->unmapped = unmapped; \
+               __entry->unwritten = unwritten; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx pgoff 0x%lx size 0x%llx offset %lx " \
+                 "delalloc %d unmapped %d unwritten %d", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __entry->pgoff, \
+                 __entry->size, \
+                 __entry->offset, \
+                 __entry->delalloc, \
+                 __entry->unmapped, \
+                 __entry->unwritten) \
+)
+DEFINE_PAGE_EVENT(xfs_writepage);
+DEFINE_PAGE_EVENT(xfs_releasepage);
+DEFINE_PAGE_EVENT(xfs_invalidatepage);
+
+#define DEFINE_IOMAP_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count, \
+                int flags, struct xfs_bmbt_irec *irec), \
+       TP_ARGS(ip, offset, count, flags, irec), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(loff_t, size) \
+               __field(loff_t, new_size) \
+               __field(loff_t, offset) \
+               __field(size_t, count) \
+               __field(int, flags) \
+               __field(xfs_fileoff_t, startoff) \
+               __field(xfs_fsblock_t, startblock) \
+               __field(xfs_filblks_t, blockcount) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(ip)->i_sb->s_dev; \
+               __entry->ino = ip->i_ino; \
+               __entry->size = ip->i_d.di_size; \
+               __entry->new_size = ip->i_new_size; \
+               __entry->offset = offset; \
+               __entry->count = count; \
+               __entry->flags = flags; \
+               __entry->startoff = irec ? irec->br_startoff : 0; \
+               __entry->startblock = irec ? irec->br_startblock : 0; \
+               __entry->blockcount = irec ? irec->br_blockcount : 0; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx " \
+                 "offset 0x%llx count %zd flags %s " \
+                 "startoff 0x%llx startblock 0x%llx blockcount 0x%llx", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __entry->size, \
+                 __entry->new_size, \
+                 __entry->offset, \
+                 __entry->count, \
+                 __print_flags(__entry->flags, "|", BMAPI_FLAGS), \
+                 __entry->startoff, \
+                 __entry->startblock, \
+                 __entry->blockcount) \
+)
+DEFINE_IOMAP_EVENT(xfs_iomap_enter);
+DEFINE_IOMAP_EVENT(xfs_iomap_found);
+DEFINE_IOMAP_EVENT(xfs_iomap_alloc);
+
+#define DEFINE_SIMPLE_IO_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count), \
+       TP_ARGS(ip, offset, count), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(loff_t, size) \
+               __field(loff_t, new_size) \
+               __field(loff_t, offset) \
+               __field(size_t, count) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(ip)->i_sb->s_dev; \
+               __entry->ino = ip->i_ino; \
+               __entry->size = ip->i_d.di_size; \
+               __entry->new_size = ip->i_new_size; \
+               __entry->offset = offset; \
+               __entry->count = count; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx " \
+                 "offset 0x%llx count %zd", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __entry->size, \
+                 __entry->new_size, \
+                 __entry->offset, \
+                 __entry->count) \
+);
+DEFINE_SIMPLE_IO_EVENT(xfs_delalloc_enospc);
+DEFINE_SIMPLE_IO_EVENT(xfs_unwritten_convert);
+
+
+TRACE_EVENT(xfs_itruncate_start,
+       TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size, int flag,
+                xfs_off_t toss_start, xfs_off_t toss_finish),
+       TP_ARGS(ip, new_size, flag, toss_start, toss_finish),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(xfs_fsize_t, size)
+               __field(xfs_fsize_t, new_size)
+               __field(xfs_off_t, toss_start)
+               __field(xfs_off_t, toss_finish)
+               __field(int, flag)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ip)->i_sb->s_dev;
+               __entry->ino = ip->i_ino;
+               __entry->size = ip->i_d.di_size;
+               __entry->new_size = new_size;
+               __entry->toss_start = toss_start;
+               __entry->toss_finish = toss_finish;
+               __entry->flag = flag;
+       ),
+       TP_printk("dev %d:%d ino 0x%llx %s size 0x%llx new_size 0x%llx "
+                 "toss start 0x%llx toss finish 0x%llx",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino,
+                 __print_flags(__entry->flag, "|", XFS_ITRUNC_FLAGS),
+                 __entry->size,
+                 __entry->new_size,
+                 __entry->toss_start,
+                 __entry->toss_finish)
+);
+
+#define DEFINE_ITRUNC_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), \
+       TP_ARGS(ip, new_size), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(xfs_fsize_t, size) \
+               __field(xfs_fsize_t, new_size) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(ip)->i_sb->s_dev; \
+               __entry->ino = ip->i_ino; \
+               __entry->size = ip->i_d.di_size; \
+               __entry->new_size = new_size; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __entry->size, \
+                 __entry->new_size) \
+)
+DEFINE_ITRUNC_EVENT(xfs_itruncate_finish_start);
+DEFINE_ITRUNC_EVENT(xfs_itruncate_finish_end);
+
+TRACE_EVENT(xfs_pagecache_inval,
+       TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish),
+       TP_ARGS(ip, start, finish),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(xfs_fsize_t, size)
+               __field(xfs_off_t, start)
+               __field(xfs_off_t, finish)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ip)->i_sb->s_dev;
+               __entry->ino = ip->i_ino;
+               __entry->size = ip->i_d.di_size;
+               __entry->start = start;
+               __entry->finish = finish;
+       ),
+       TP_printk("dev %d:%d ino 0x%llx size 0x%llx start 0x%llx finish 0x%llx",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino,
+                 __entry->size,
+                 __entry->start,
+                 __entry->finish)
+);
+
+TRACE_EVENT(xfs_bunmap,
+       TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t bno, xfs_filblks_t len,
+                int flags, unsigned long caller_ip),
+       TP_ARGS(ip, bno, len, flags, caller_ip),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(xfs_fsize_t, size)
+               __field(xfs_fileoff_t, bno)
+               __field(xfs_filblks_t, len)
+               __field(unsigned long, caller_ip)
+               __field(int, flags)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(ip)->i_sb->s_dev;
+               __entry->ino = ip->i_ino;
+               __entry->size = ip->i_d.di_size;
+               __entry->bno = bno;
+               __entry->len = len;
+               __entry->caller_ip = caller_ip;
+               __entry->flags = flags;
+       ),
+       TP_printk("dev %d:%d ino 0x%llx size 0x%llx bno 0x%llx len 0x%llx"
+                 "flags %s caller %pf",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino,
+                 __entry->size,
+                 __entry->bno,
+                 __entry->len,
+                 __print_flags(__entry->flags, "|", XFS_BMAPI_FLAGS),
+                 (void *)__entry->caller_ip)
+
+);
+
+TRACE_EVENT(xfs_alloc_busy,
+       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
+                xfs_extlen_t len, int slot),
+       TP_ARGS(mp, agno, agbno, len, slot),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_agnumber_t, agno)
+               __field(xfs_agblock_t, agbno)
+               __field(xfs_extlen_t, len)
+               __field(int, slot)
+       ),
+       TP_fast_assign(
+               __entry->dev = mp->m_super->s_dev;
+               __entry->agno = agno;
+               __entry->agbno = agbno;
+               __entry->len = len;
+               __entry->slot = slot;
+       ),
+       TP_printk("dev %d:%d agno %u agbno %u len %u slot %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->agno,
+                 __entry->agbno,
+                 __entry->len,
+                 __entry->slot)
+
+);
+
+#define XFS_BUSY_STATES \
+       { 0,    "found" }, \
+       { 1,    "missing" }
+
+TRACE_EVENT(xfs_alloc_unbusy,
+       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
+                int slot, int found),
+       TP_ARGS(mp, agno, slot, found),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_agnumber_t, agno)
+               __field(int, slot)
+               __field(int, found)
+       ),
+       TP_fast_assign(
+               __entry->dev = mp->m_super->s_dev;
+               __entry->agno = agno;
+               __entry->slot = slot;
+               __entry->found = found;
+       ),
+       TP_printk("dev %d:%d agno %u slot %d %s",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->agno,
+                 __entry->slot,
+                 __print_symbolic(__entry->found, XFS_BUSY_STATES))
+);
+
+TRACE_EVENT(xfs_alloc_busysearch,
+       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
+                xfs_extlen_t len, int found),
+       TP_ARGS(mp, agno, agbno, len, found),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_agnumber_t, agno)
+               __field(xfs_agblock_t, agbno)
+               __field(xfs_extlen_t, len)
+               __field(int, found)
+       ),
+       TP_fast_assign(
+               __entry->dev = mp->m_super->s_dev;
+               __entry->agno = agno;
+               __entry->agbno = agbno;
+               __entry->len = len;
+               __entry->found = found;
+       ),
+       TP_printk("dev %d:%d agno %u agbno %u len %u %s",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->agno,
+                 __entry->agbno,
+                 __entry->len,
+                 __print_symbolic(__entry->found, XFS_BUSY_STATES))
+);
+
+TRACE_EVENT(xfs_agf,
+       TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags,
+                unsigned long caller_ip),
+       TP_ARGS(mp, agf, flags, caller_ip),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_agnumber_t, agno)
+               __field(int, flags)
+               __field(__u32, length)
+               __field(__u32, bno_root)
+               __field(__u32, cnt_root)
+               __field(__u32, bno_level)
+               __field(__u32, cnt_level)
+               __field(__u32, flfirst)
+               __field(__u32, fllast)
+               __field(__u32, flcount)
+               __field(__u32, freeblks)
+               __field(__u32, longest)
+               __field(unsigned long, caller_ip)
+       ),
+       TP_fast_assign(
+               __entry->dev = mp->m_super->s_dev;
+               __entry->agno = be32_to_cpu(agf->agf_seqno),
+               __entry->flags = flags;
+               __entry->length = be32_to_cpu(agf->agf_length),
+               __entry->bno_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]),
+               __entry->cnt_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]),
+               __entry->bno_level =
+                               be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]),
+               __entry->cnt_level =
+                               be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]),
+               __entry->flfirst = be32_to_cpu(agf->agf_flfirst),
+               __entry->fllast = be32_to_cpu(agf->agf_fllast),
+               __entry->flcount = be32_to_cpu(agf->agf_flcount),
+               __entry->freeblks = be32_to_cpu(agf->agf_freeblks),
+               __entry->longest = be32_to_cpu(agf->agf_longest);
+               __entry->caller_ip = caller_ip;
+       ),
+       TP_printk("dev %d:%d agno %u flags %s length %u roots b %u c %u "
+                 "levels b %u c %u flfirst %u fllast %u flcount %u "
+                 "freeblks %u longest %u caller %pf",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->agno,
+                 __print_flags(__entry->flags, "|", XFS_AGF_FLAGS),
+                 __entry->length,
+                 __entry->bno_root,
+                 __entry->cnt_root,
+                 __entry->bno_level,
+                 __entry->cnt_level,
+                 __entry->flfirst,
+                 __entry->fllast,
+                 __entry->flcount,
+                 __entry->freeblks,
+                 __entry->longest,
+                 (void *)__entry->caller_ip)
+);
+
+TRACE_EVENT(xfs_free_extent,
+       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno,
+                xfs_extlen_t len, bool isfl, int haveleft, int haveright),
+       TP_ARGS(mp, agno, agbno, len, isfl, haveleft, haveright),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_agnumber_t, agno)
+               __field(xfs_agblock_t, agbno)
+               __field(xfs_extlen_t, len)
+               __field(int, isfl)
+               __field(int, haveleft)
+               __field(int, haveright)
+       ),
+       TP_fast_assign(
+               __entry->dev = mp->m_super->s_dev;
+               __entry->agno = agno;
+               __entry->agbno = agbno;
+               __entry->len = len;
+               __entry->isfl = isfl;
+               __entry->haveleft = haveleft;
+               __entry->haveright = haveright;
+       ),
+       TP_printk("dev %d:%d agno %u agbno %u len %u isfl %d %s",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->agno,
+                 __entry->agbno,
+                 __entry->len,
+                 __entry->isfl,
+                 __entry->haveleft ?
+                       (__entry->haveright ? "both" : "left") :
+                       (__entry->haveright ? "right" : "none"))
+
+);
+
+#define DEFINE_ALLOC_EVENT(name) \
+TRACE_EVENT(name, \
+       TP_PROTO(struct xfs_alloc_arg *args), \
+       TP_ARGS(args), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_agnumber_t, agno) \
+               __field(xfs_agblock_t, agbno) \
+               __field(xfs_extlen_t, minlen) \
+               __field(xfs_extlen_t, maxlen) \
+               __field(xfs_extlen_t, mod) \
+               __field(xfs_extlen_t, prod) \
+               __field(xfs_extlen_t, minleft) \
+               __field(xfs_extlen_t, total) \
+               __field(xfs_extlen_t, alignment) \
+               __field(xfs_extlen_t, minalignslop) \
+               __field(xfs_extlen_t, len) \
+               __field(short, type) \
+               __field(short, otype) \
+               __field(char, wasdel) \
+               __field(char, wasfromfl) \
+               __field(char, isfl) \
+               __field(char, userdata) \
+               __field(xfs_fsblock_t, firstblock) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = args->mp->m_super->s_dev; \
+               __entry->agno = args->agno; \
+               __entry->agbno = args->agbno; \
+               __entry->minlen = args->minlen; \
+               __entry->maxlen = args->maxlen; \
+               __entry->mod = args->mod; \
+               __entry->prod = args->prod; \
+               __entry->minleft = args->minleft; \
+               __entry->total = args->total; \
+               __entry->alignment = args->alignment; \
+               __entry->minalignslop = args->minalignslop; \
+               __entry->len = args->len; \
+               __entry->type = args->type; \
+               __entry->otype = args->otype; \
+               __entry->wasdel = args->wasdel; \
+               __entry->wasfromfl = args->wasfromfl; \
+               __entry->isfl = args->isfl; \
+               __entry->userdata = args->userdata; \
+               __entry->firstblock = args->firstblock; \
+       ), \
+       TP_printk("dev %d:%d agno %u agbno %u minlen %u maxlen %u mod %u " \
+                 "prod %u minleft %u total %u alignment %u minalignslop %u " \
+                 "len %u type %s otype %s wasdel %d wasfromfl %d isfl %d " \
+                 "userdata %d firstblock 0x%llx", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->agno, \
+                 __entry->agbno, \
+                 __entry->minlen, \
+                 __entry->maxlen, \
+                 __entry->mod, \
+                 __entry->prod, \
+                 __entry->minleft, \
+                 __entry->total, \
+                 __entry->alignment, \
+                 __entry->minalignslop, \
+                 __entry->len, \
+                 __print_symbolic(__entry->type, XFS_ALLOC_TYPES), \
+                 __print_symbolic(__entry->otype, XFS_ALLOC_TYPES), \
+                 __entry->wasdel, \
+                 __entry->wasfromfl, \
+                 __entry->isfl, \
+                 __entry->userdata, \
+                 __entry->firstblock) \
+)
+
+DEFINE_ALLOC_EVENT(xfs_alloc_exact_done);
+DEFINE_ALLOC_EVENT(xfs_alloc_exact_error);
+DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft);
+DEFINE_ALLOC_EVENT(xfs_alloc_near_first);
+DEFINE_ALLOC_EVENT(xfs_alloc_near_greater);
+DEFINE_ALLOC_EVENT(xfs_alloc_near_lesser);
+DEFINE_ALLOC_EVENT(xfs_alloc_near_error);
+DEFINE_ALLOC_EVENT(xfs_alloc_size_neither);
+DEFINE_ALLOC_EVENT(xfs_alloc_size_noentry);
+DEFINE_ALLOC_EVENT(xfs_alloc_size_nominleft);
+DEFINE_ALLOC_EVENT(xfs_alloc_size_done);
+DEFINE_ALLOC_EVENT(xfs_alloc_size_error);
+DEFINE_ALLOC_EVENT(xfs_alloc_small_freelist);
+DEFINE_ALLOC_EVENT(xfs_alloc_small_notenough);
+DEFINE_ALLOC_EVENT(xfs_alloc_small_done);
+DEFINE_ALLOC_EVENT(xfs_alloc_small_error);
+DEFINE_ALLOC_EVENT(xfs_alloc_vextent_badargs);
+DEFINE_ALLOC_EVENT(xfs_alloc_vextent_nofix);
+DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp);
+DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed);
+DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed);
+
+#define DEFINE_DIR2_TRACE(tname) \
+TRACE_EVENT(tname, \
+       TP_PROTO(struct xfs_da_args *args), \
+       TP_ARGS(args), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __dynamic_array(char, name, args->namelen) \
+               __field(int, namelen) \
+               __field(xfs_dahash_t, hashval) \
+               __field(xfs_ino_t, inumber) \
+               __field(int, op_flags) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(args->dp)->i_sb->s_dev; \
+               __entry->ino = args->dp->i_ino; \
+               if (args->namelen) \
+                       memcpy(__get_str(name), args->name, args->namelen); \
+               __entry->namelen = args->namelen; \
+               __entry->hashval = args->hashval; \
+               __entry->inumber = args->inumber; \
+               __entry->op_flags = args->op_flags; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d hashval 0x%x " \
+                 "inumber 0x%llx op_flags %s", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __entry->namelen, \
+                 __entry->namelen ? __get_str(name) : NULL, \
+                 __entry->namelen, \
+                 __entry->hashval, \
+                 __entry->inumber, \
+                 __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS)) \
+)
+DEFINE_DIR2_TRACE(xfs_dir2_sf_addname);
+DEFINE_DIR2_TRACE(xfs_dir2_sf_create);
+DEFINE_DIR2_TRACE(xfs_dir2_sf_lookup);
+DEFINE_DIR2_TRACE(xfs_dir2_sf_replace);
+DEFINE_DIR2_TRACE(xfs_dir2_sf_removename);
+DEFINE_DIR2_TRACE(xfs_dir2_sf_toino4);
+DEFINE_DIR2_TRACE(xfs_dir2_sf_toino8);
+DEFINE_DIR2_TRACE(xfs_dir2_sf_to_block);
+DEFINE_DIR2_TRACE(xfs_dir2_block_addname);
+DEFINE_DIR2_TRACE(xfs_dir2_block_lookup);
+DEFINE_DIR2_TRACE(xfs_dir2_block_replace);
+DEFINE_DIR2_TRACE(xfs_dir2_block_removename);
+DEFINE_DIR2_TRACE(xfs_dir2_block_to_sf);
+DEFINE_DIR2_TRACE(xfs_dir2_block_to_leaf);
+DEFINE_DIR2_TRACE(xfs_dir2_leaf_addname);
+DEFINE_DIR2_TRACE(xfs_dir2_leaf_lookup);
+DEFINE_DIR2_TRACE(xfs_dir2_leaf_replace);
+DEFINE_DIR2_TRACE(xfs_dir2_leaf_removename);
+DEFINE_DIR2_TRACE(xfs_dir2_leaf_to_block);
+DEFINE_DIR2_TRACE(xfs_dir2_leaf_to_node);
+DEFINE_DIR2_TRACE(xfs_dir2_node_addname);
+DEFINE_DIR2_TRACE(xfs_dir2_node_lookup);
+DEFINE_DIR2_TRACE(xfs_dir2_node_replace);
+DEFINE_DIR2_TRACE(xfs_dir2_node_removename);
+DEFINE_DIR2_TRACE(xfs_dir2_node_to_leaf);
+
+#define DEFINE_DIR2_SPACE_TRACE(tname) \
+TRACE_EVENT(tname, \
+       TP_PROTO(struct xfs_da_args *args, int idx), \
+       TP_ARGS(args, idx), \
+       TP_STRUCT__entry( \
+               __field(dev_t, dev) \
+               __field(xfs_ino_t, ino) \
+               __field(int, op_flags) \
+               __field(int, idx) \
+       ), \
+       TP_fast_assign( \
+               __entry->dev = VFS_I(args->dp)->i_sb->s_dev; \
+               __entry->ino = args->dp->i_ino; \
+               __entry->op_flags = args->op_flags; \
+               __entry->idx = idx; \
+       ), \
+       TP_printk("dev %d:%d ino 0x%llx op_flags %s index %d", \
+                 MAJOR(__entry->dev), MINOR(__entry->dev), \
+                 __entry->ino, \
+                 __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS), \
+                 __entry->idx) \
+)
+DEFINE_DIR2_SPACE_TRACE(xfs_dir2_leafn_add);
+DEFINE_DIR2_SPACE_TRACE(xfs_dir2_leafn_remove);
+DEFINE_DIR2_SPACE_TRACE(xfs_dir2_grow_inode);
+DEFINE_DIR2_SPACE_TRACE(xfs_dir2_shrink_inode);
+
+TRACE_EVENT(xfs_dir2_leafn_moveents,
+       TP_PROTO(struct xfs_da_args *args, int src_idx, int dst_idx, int count),
+       TP_ARGS(args, src_idx, dst_idx, count),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_ino_t, ino)
+               __field(int, op_flags)
+               __field(int, src_idx)
+               __field(int, dst_idx)
+               __field(int, count)
+       ),
+       TP_fast_assign(
+               __entry->dev = VFS_I(args->dp)->i_sb->s_dev;
+               __entry->ino = args->dp->i_ino;
+               __entry->op_flags = args->op_flags;
+               __entry->src_idx = src_idx;
+               __entry->dst_idx = dst_idx;
+               __entry->count = count;
+       ),
+       TP_printk("dev %d:%d ino 0x%llx op_flags %s "
+                 "src_idx %d dst_idx %d count %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->ino,
+                 __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS),
+                 __entry->src_idx,
+                 __entry->dst_idx,
+                 __entry->count)
+);
+
+#endif /* _TRACE_XFS_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#define TRACE_INCLUDE_FILE xfs_trace
+#include <trace/define_trace.h>
index 00cabf5354d265aa4cc73e442844454f96fd9739..7c220b4227bc7f817cf507b84a1721a7d0091e2f 100644 (file)
@@ -39,6 +39,10 @@ struct attrlist_cursor_kern;
 #define IO_ISDIRECT    0x00004         /* bypass page cache */
 #define IO_INVIS       0x00020         /* don't update inode timestamps */
 
+#define XFS_IO_FLAGS \
+       { IO_ISDIRECT,  "DIRECT" }, \
+       { IO_INVIS,     "INVIS"}
+
 /*
  * Flush/Invalidate options for vop_toss/flush/flushinval_pages.
  */
index 497c7fb75cc18f95cd1b746c36cef2b1a4e1b227..0b1878857fc3cb56ca31e7dbe27a901a2243dfce 100644 (file)
 
 
 static int
-__xfs_xattr_get(struct inode *inode, const char *name,
+xfs_xattr_get(struct dentry *dentry, const char *name,
                void *value, size_t size, int xflags)
 {
-       struct xfs_inode *ip = XFS_I(inode);
+       struct xfs_inode *ip = XFS_I(dentry->d_inode);
        int error, asize = size;
 
        if (strcmp(name, "") == 0)
@@ -52,10 +52,10 @@ __xfs_xattr_get(struct inode *inode, const char *name,
 }
 
 static int
-__xfs_xattr_set(struct inode *inode, const char *name, const void *value,
+xfs_xattr_set(struct dentry *dentry, const char *name, const void *value,
                size_t size, int flags, int xflags)
 {
-       struct xfs_inode *ip = XFS_I(inode);
+       struct xfs_inode *ip = XFS_I(dentry->d_inode);
 
        if (strcmp(name, "") == 0)
                return -EINVAL;
@@ -71,75 +71,34 @@ __xfs_xattr_set(struct inode *inode, const char *name, const void *value,
        return -xfs_attr_set(ip, name, (void *)value, size, xflags);
 }
 
-static int
-xfs_xattr_user_get(struct inode *inode, const char *name,
-               void *value, size_t size)
-{
-       return __xfs_xattr_get(inode, name, value, size, 0);
-}
-
-static int
-xfs_xattr_user_set(struct inode *inode, const char *name,
-               const void *value, size_t size, int flags)
-{
-       return __xfs_xattr_set(inode, name, value, size, flags, 0);
-}
-
 static struct xattr_handler xfs_xattr_user_handler = {
        .prefix = XATTR_USER_PREFIX,
-       .get    = xfs_xattr_user_get,
-       .set    = xfs_xattr_user_set,
+       .flags  = 0, /* no flags implies user namespace */
+       .get    = xfs_xattr_get,
+       .set    = xfs_xattr_set,
 };
 
-
-static int
-xfs_xattr_trusted_get(struct inode *inode, const char *name,
-               void *value, size_t size)
-{
-       return __xfs_xattr_get(inode, name, value, size, ATTR_ROOT);
-}
-
-static int
-xfs_xattr_trusted_set(struct inode *inode, const char *name,
-               const void *value, size_t size, int flags)
-{
-       return __xfs_xattr_set(inode, name, value, size, flags, ATTR_ROOT);
-}
-
 static struct xattr_handler xfs_xattr_trusted_handler = {
        .prefix = XATTR_TRUSTED_PREFIX,
-       .get    = xfs_xattr_trusted_get,
-       .set    = xfs_xattr_trusted_set,
+       .flags  = ATTR_ROOT,
+       .get    = xfs_xattr_get,
+       .set    = xfs_xattr_set,
 };
 
-
-static int
-xfs_xattr_secure_get(struct inode *inode, const char *name,
-               void *value, size_t size)
-{
-       return __xfs_xattr_get(inode, name, value, size, ATTR_SECURE);
-}
-
-static int
-xfs_xattr_secure_set(struct inode *inode, const char *name,
-               const void *value, size_t size, int flags)
-{
-       return __xfs_xattr_set(inode, name, value, size, flags, ATTR_SECURE);
-}
-
 static struct xattr_handler xfs_xattr_security_handler = {
        .prefix = XATTR_SECURITY_PREFIX,
-       .get    = xfs_xattr_secure_get,
-       .set    = xfs_xattr_secure_set,
+       .flags  = ATTR_SECURE,
+       .get    = xfs_xattr_get,
+       .set    = xfs_xattr_set,
 };
 
-
 struct xattr_handler *xfs_xattr_handlers[] = {
        &xfs_xattr_user_handler,
        &xfs_xattr_trusted_handler,
        &xfs_xattr_security_handler,
 #ifdef CONFIG_XFS_POSIX_ACL
-       &xfs_xattr_system_handler,
+       &xfs_xattr_acl_access_handler,
+       &xfs_xattr_acl_default_handler,
 #endif
        NULL
 };
index 2f3f2229eaaf16c68e57a37b2e373fe2e131e26b..d7c7eea09fc2083cc10d7249f5ed6d219e66db18 100644 (file)
@@ -47,6 +47,7 @@
 #include "xfs_trans_space.h"
 #include "xfs_trans_priv.h"
 #include "xfs_qm.h"
+#include "xfs_trace.h"
 
 
 /*
@@ -112,10 +113,7 @@ xfs_qm_dqinit(
                init_completion(&dqp->q_flush);
                complete(&dqp->q_flush);
 
-#ifdef XFS_DQUOT_TRACE
-               dqp->q_trace = ktrace_alloc(DQUOT_TRACE_SIZE, KM_NOFS);
-               xfs_dqtrace_entry(dqp, "DQINIT");
-#endif
+               trace_xfs_dqinit(dqp);
        } else {
                /*
                 * Only the q_core portion was zeroed in dqreclaim_one().
@@ -136,10 +134,7 @@ xfs_qm_dqinit(
                 dqp->q_hash = NULL;
                 ASSERT(dqp->dq_flnext == dqp->dq_flprev);
 
-#ifdef XFS_DQUOT_TRACE
-                ASSERT(dqp->q_trace);
-                xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT");
-#endif
+               trace_xfs_dqreuse(dqp);
        }
 
        /*
@@ -167,13 +162,8 @@ xfs_qm_dqdestroy(
 
        mutex_destroy(&dqp->q_qlock);
        sv_destroy(&dqp->q_pinwait);
-
-#ifdef XFS_DQUOT_TRACE
-       if (dqp->q_trace)
-            ktrace_free(dqp->q_trace);
-       dqp->q_trace = NULL;
-#endif
        kmem_zone_free(xfs_Gqm->qm_dqzone, dqp);
+
        atomic_dec(&xfs_Gqm->qm_totaldquots);
 }
 
@@ -195,49 +185,6 @@ xfs_qm_dqinit_core(
        d->dd_diskdq.d_flags = type;
 }
 
-
-#ifdef XFS_DQUOT_TRACE
-/*
- * Dquot tracing for debugging.
- */
-/* ARGSUSED */
-void
-__xfs_dqtrace_entry(
-       xfs_dquot_t     *dqp,
-       char            *func,
-       void            *retaddr,
-       xfs_inode_t     *ip)
-{
-       xfs_dquot_t     *udqp = NULL;
-       xfs_ino_t       ino = 0;
-
-       ASSERT(dqp->q_trace);
-       if (ip) {
-               ino = ip->i_ino;
-               udqp = ip->i_udquot;
-       }
-       ktrace_enter(dqp->q_trace,
-                    (void *)(__psint_t)DQUOT_KTRACE_ENTRY,
-                    (void *)func,
-                    (void *)(__psint_t)dqp->q_nrefs,
-                    (void *)(__psint_t)dqp->dq_flags,
-                    (void *)(__psint_t)dqp->q_res_bcount,
-                    (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_bcount),
-                    (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_icount),
-                    (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_hardlimit),
-                    (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_softlimit),
-                    (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_hardlimit),
-                    (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_softlimit),
-                    (void *)(__psint_t)be32_to_cpu(dqp->q_core.d_id),
-                    (void *)(__psint_t)current_pid(),
-                    (void *)(__psint_t)ino,
-                    (void *)(__psint_t)retaddr,
-                    (void *)(__psint_t)udqp);
-       return;
-}
-#endif
-
-
 /*
  * If default limits are in force, push them into the dquot now.
  * We overwrite the dquot limits only if they are zero and this
@@ -425,7 +372,8 @@ xfs_qm_dqalloc(
        xfs_trans_t     *tp = *tpp;
 
        ASSERT(tp != NULL);
-       xfs_dqtrace_entry(dqp, "DQALLOC");
+
+       trace_xfs_dqalloc(dqp);
 
        /*
         * Initialize the bmap freelist prior to calling bmapi code.
@@ -612,7 +560,8 @@ xfs_qm_dqtobp(
         * (in which case we already have the buf).
         */
        if (! newdquot) {
-               xfs_dqtrace_entry(dqp, "DQTOBP READBUF");
+               trace_xfs_dqtobp_read(dqp);
+
                if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
                                               dqp->q_blkno,
                                               XFS_QI_DQCHUNKLEN(mp),
@@ -670,11 +619,12 @@ xfs_qm_dqread(
 
        ASSERT(tpp);
 
+       trace_xfs_dqread(dqp);
+
        /*
         * get a pointer to the on-disk dquot and the buffer containing it
         * dqp already knows its own type (GROUP/USER).
         */
-       xfs_dqtrace_entry(dqp, "DQREAD");
        if ((error = xfs_qm_dqtobp(tpp, dqp, &ddqp, &bp, flags))) {
                return (error);
        }
@@ -763,7 +713,7 @@ xfs_qm_idtodq(
                 * or if the dquot didn't exist on disk and we ask to
                 * allocate (ENOENT).
                 */
-               xfs_dqtrace_entry(dqp, "DQREAD FAIL");
+               trace_xfs_dqread_fail(dqp);
                cancelflags |= XFS_TRANS_ABORT;
                goto error0;
        }
@@ -817,7 +767,8 @@ xfs_qm_dqlookup(
                 * id can't be modified without the hashlock anyway.
                 */
                if (be32_to_cpu(dqp->q_core.d_id) == id && dqp->q_mount == mp) {
-                       xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP");
+                       trace_xfs_dqlookup_found(dqp);
+
                        /*
                         * All in core dquots must be on the dqlist of mp
                         */
@@ -827,7 +778,7 @@ xfs_qm_dqlookup(
                        if (dqp->q_nrefs == 0) {
                                ASSERT (XFS_DQ_IS_ON_FREELIST(dqp));
                                if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) {
-                                       xfs_dqtrace_entry(dqp, "DQLOOKUP: WANT");
+                                       trace_xfs_dqlookup_want(dqp);
 
                                        /*
                                         * We may have raced with dqreclaim_one()
@@ -857,8 +808,7 @@ xfs_qm_dqlookup(
                                        /*
                                         * take it off the freelist
                                         */
-                                       xfs_dqtrace_entry(dqp,
-                                                       "DQLOOKUP: TAKEOFF FL");
+                                       trace_xfs_dqlookup_freelist(dqp);
                                        XQM_FREELIST_REMOVE(dqp);
                                        /* xfs_qm_freelist_print(&(xfs_Gqm->
                                                        qm_dqfreelist),
@@ -878,8 +828,7 @@ xfs_qm_dqlookup(
                         */
                        ASSERT(mutex_is_locked(&qh->qh_lock));
                        if (dqp->HL_PREVP != &qh->qh_next) {
-                               xfs_dqtrace_entry(dqp,
-                                                 "DQLOOKUP: HASH MOVETOFRONT");
+                               trace_xfs_dqlookup_move(dqp);
                                if ((d = dqp->HL_NEXT))
                                        d->HL_PREVP = dqp->HL_PREVP;
                                *(dqp->HL_PREVP) = d;
@@ -889,7 +838,7 @@ xfs_qm_dqlookup(
                                dqp->HL_PREVP = &qh->qh_next;
                                qh->qh_next = dqp;
                        }
-                       xfs_dqtrace_entry(dqp, "LOOKUP END");
+                       trace_xfs_dqlookup_done(dqp);
                        *O_dqpp = dqp;
                        ASSERT(mutex_is_locked(&qh->qh_lock));
                        return (0);
@@ -971,7 +920,7 @@ xfs_qm_dqget(
                ASSERT(*O_dqpp);
                ASSERT(XFS_DQ_IS_LOCKED(*O_dqpp));
                mutex_unlock(&h->qh_lock);
-               xfs_dqtrace_entry(*O_dqpp, "DQGET DONE (FROM CACHE)");
+               trace_xfs_dqget_hit(*O_dqpp);
                return (0);     /* success */
        }
        XQM_STATS_INC(xqmstats.xs_qm_dqcachemisses);
@@ -1104,7 +1053,7 @@ xfs_qm_dqget(
        mutex_unlock(&h->qh_lock);
  dqret:
        ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL));
-       xfs_dqtrace_entry(dqp, "DQGET DONE");
+       trace_xfs_dqget_miss(dqp);
        *O_dqpp = dqp;
        return (0);
 }
@@ -1124,7 +1073,8 @@ xfs_qm_dqput(
 
        ASSERT(dqp->q_nrefs > 0);
        ASSERT(XFS_DQ_IS_LOCKED(dqp));
-       xfs_dqtrace_entry(dqp, "DQPUT");
+
+       trace_xfs_dqput(dqp);
 
        if (dqp->q_nrefs != 1) {
                dqp->q_nrefs--;
@@ -1137,7 +1087,7 @@ xfs_qm_dqput(
         * in the right order; but try to get it out-of-order first
         */
        if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) {
-               xfs_dqtrace_entry(dqp, "DQPUT: FLLOCK-WAIT");
+               trace_xfs_dqput_wait(dqp);
                xfs_dqunlock(dqp);
                xfs_qm_freelist_lock(xfs_Gqm);
                xfs_dqlock(dqp);
@@ -1148,7 +1098,8 @@ xfs_qm_dqput(
 
                /* We can't depend on nrefs being == 1 here */
                if (--dqp->q_nrefs == 0) {
-                       xfs_dqtrace_entry(dqp, "DQPUT: ON FREELIST");
+                       trace_xfs_dqput_free(dqp);
+
                        /*
                         * insert at end of the freelist.
                         */
@@ -1196,7 +1147,7 @@ xfs_qm_dqrele(
        if (!dqp)
                return;
 
-       xfs_dqtrace_entry(dqp, "DQRELE");
+       trace_xfs_dqrele(dqp);
 
        xfs_dqlock(dqp);
        /*
@@ -1229,7 +1180,7 @@ xfs_qm_dqflush(
 
        ASSERT(XFS_DQ_IS_LOCKED(dqp));
        ASSERT(!completion_done(&dqp->q_flush));
-       xfs_dqtrace_entry(dqp, "DQFLUSH");
+       trace_xfs_dqflush(dqp);
 
        /*
         * If not dirty, or it's pinned and we are not supposed to
@@ -1259,7 +1210,6 @@ xfs_qm_dqflush(
         * the ondisk-dquot has already been allocated for.
         */
        if ((error = xfs_qm_dqtobp(NULL, dqp, &ddqp, &bp, XFS_QMOPT_DOWARN))) {
-               xfs_dqtrace_entry(dqp, "DQTOBP FAIL");
                ASSERT(error != ENOENT);
                /*
                 * Quotas could have gotten turned off (ESRCH)
@@ -1297,7 +1247,7 @@ xfs_qm_dqflush(
         * get stuck waiting in the write for too long.
         */
        if (XFS_BUF_ISPINNED(bp)) {
-               xfs_dqtrace_entry(dqp, "DQFLUSH LOG FORCE");
+               trace_xfs_dqflush_force(dqp);
                xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE);
        }
 
@@ -1308,7 +1258,9 @@ xfs_qm_dqflush(
        } else {
                error = xfs_bwrite(mp, bp);
        }
-       xfs_dqtrace_entry(dqp, "DQFLUSH END");
+
+       trace_xfs_dqflush_done(dqp);
+
        /*
         * dqp is still locked, but caller is free to unlock it now.
         */
@@ -1483,7 +1435,7 @@ xfs_qm_dqpurge(
         */
        if (XFS_DQ_IS_DIRTY(dqp)) {
                int     error;
-               xfs_dqtrace_entry(dqp, "DQPURGE ->DQFLUSH: DQDIRTY");
+
                /* dqflush unlocks dqflock */
                /*
                 * Given that dqpurge is a very rare occurrence, it is OK
index a2c16bcee90b0ad974b1772760edaea263fd9f88..a0f7da586d1ba44b0901917923af5f11ca0e2183 100644 (file)
@@ -85,9 +85,6 @@ typedef struct xfs_dquot {
        struct completion q_flush;      /* flush completion queue */
        atomic_t          q_pincount;   /* dquot pin count */
        wait_queue_head_t q_pinwait;    /* dquot pinning wait queue */
-#ifdef XFS_DQUOT_TRACE
-       struct ktrace   *q_trace;       /* trace header structure */
-#endif
 } xfs_dquot_t;
 
 
@@ -144,24 +141,6 @@ static inline void xfs_dqfunlock(xfs_dquot_t *dqp)
                                     (XFS_IS_UQUOTA_ON((d)->q_mount)) : \
                                     (XFS_IS_OQUOTA_ON((d)->q_mount))))
 
-#ifdef XFS_DQUOT_TRACE
-/*
- * Dquot Tracing stuff.
- */
-#define DQUOT_TRACE_SIZE       64
-#define DQUOT_KTRACE_ENTRY     1
-
-extern void            __xfs_dqtrace_entry(xfs_dquot_t *dqp, char *func,
-                                           void *, xfs_inode_t *);
-#define xfs_dqtrace_entry_ino(a,b,ip) \
-               __xfs_dqtrace_entry((a), (b), (void*)__return_address, (ip))
-#define xfs_dqtrace_entry(a,b) \
-               __xfs_dqtrace_entry((a), (b), (void*)__return_address, NULL)
-#else
-#define xfs_dqtrace_entry(a,b)
-#define xfs_dqtrace_entry_ino(a,b,ip)
-#endif
-
 #ifdef QUOTADEBUG
 extern void            xfs_qm_dqprint(xfs_dquot_t *);
 #else
index 45b1bfef73884ce7ea6740fffc934db6140feded..9e627a8b5b0e08284b03c3643e4c3219c252fba7 100644 (file)
@@ -47,6 +47,7 @@
 #include "xfs_trans_space.h"
 #include "xfs_utils.h"
 #include "xfs_qm.h"
+#include "xfs_trace.h"
 
 /*
  * The global quota manager. There is only one of these for the entire
@@ -453,7 +454,7 @@ again:
                        xfs_dqunlock(dqp);
                        continue;
                }
-               xfs_dqtrace_entry(dqp, "FLUSHALL: DQDIRTY");
+
                /* XXX a sentinel would be better */
                recl = XFS_QI_MPLRECLAIMS(mp);
                if (!xfs_dqflock_nowait(dqp)) {
@@ -651,7 +652,7 @@ xfs_qm_dqattach_one(
         */
        dqp = *IO_idqpp;
        if (dqp) {
-               xfs_dqtrace_entry(dqp, "DQATTACH: found in ip");
+               trace_xfs_dqattach_found(dqp);
                return 0;
        }
 
@@ -704,7 +705,7 @@ xfs_qm_dqattach_one(
        if (error)
                return error;
 
-       xfs_dqtrace_entry(dqp, "DQATTACH: found by dqget");
+       trace_xfs_dqattach_get(dqp);
 
        /*
         * dqget may have dropped and re-acquired the ilock, but it guarantees
@@ -890,15 +891,15 @@ xfs_qm_dqdetach(
        if (!(ip->i_udquot || ip->i_gdquot))
                return;
 
+       trace_xfs_dquot_dqdetach(ip);
+
        ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_uquotino);
        ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_gquotino);
        if (ip->i_udquot) {
-               xfs_dqtrace_entry_ino(ip->i_udquot, "DQDETTACH", ip);
                xfs_qm_dqrele(ip->i_udquot);
                ip->i_udquot = NULL;
        }
        if (ip->i_gdquot) {
-               xfs_dqtrace_entry_ino(ip->i_gdquot, "DQDETTACH", ip);
                xfs_qm_dqrele(ip->i_gdquot);
                ip->i_gdquot = NULL;
        }
@@ -977,7 +978,6 @@ xfs_qm_sync(
                 * across a disk write
                 */
                xfs_qm_mplist_unlock(mp);
-               xfs_dqtrace_entry(dqp, "XQM_SYNC: DQFLUSH");
                error = xfs_qm_dqflush(dqp, flush_flags);
                xfs_dqunlock(dqp);
                if (error && XFS_FORCED_SHUTDOWN(mp))
@@ -1350,7 +1350,8 @@ xfs_qm_reset_dqcounts(
        xfs_disk_dquot_t        *ddq;
        int                     j;
 
-       xfs_buftrace("RESET DQUOTS", bp);
+       trace_xfs_reset_dqcounts(bp, _RET_IP_);
+
        /*
         * Reset all counters and timers. They'll be
         * started afresh by xfs_qm_quotacheck.
@@ -1543,7 +1544,9 @@ xfs_qm_quotacheck_dqadjust(
        xfs_qcnt_t              rtblks)
 {
        ASSERT(XFS_DQ_IS_LOCKED(dqp));
-       xfs_dqtrace_entry(dqp, "QCHECK DQADJUST");
+
+       trace_xfs_dqadjust(dqp);
+
        /*
         * Adjust the inode count and the block count to reflect this inode's
         * resource usage.
@@ -1994,7 +1997,9 @@ xfs_qm_shake_freelist(
                 */
                if (XFS_DQ_IS_DIRTY(dqp)) {
                        int     error;
-                       xfs_dqtrace_entry(dqp, "DQSHAKE: DQDIRTY");
+
+                       trace_xfs_dqshake_dirty(dqp);
+
                        /*
                         * We flush it delayed write, so don't bother
                         * releasing the mplock.
@@ -2038,7 +2043,9 @@ xfs_qm_shake_freelist(
                                return nreclaimed;
                        goto tryagain;
                }
-               xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
+
+               trace_xfs_dqshake_unlink(dqp);
+
 #ifdef QUOTADEBUG
                cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n",
                        dqp, be32_to_cpu(dqp->q_core.d_id));
@@ -2125,7 +2132,9 @@ xfs_qm_dqreclaim_one(void)
                 */
                if (dqp->dq_flags & XFS_DQ_WANT) {
                        ASSERT(! (dqp->dq_flags & XFS_DQ_INACTIVE));
-                       xfs_dqtrace_entry(dqp, "DQRECLAIM: DQWANT");
+
+                       trace_xfs_dqreclaim_want(dqp);
+
                        xfs_dqunlock(dqp);
                        xfs_qm_freelist_unlock(xfs_Gqm);
                        if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
@@ -2171,7 +2180,9 @@ xfs_qm_dqreclaim_one(void)
                 */
                if (XFS_DQ_IS_DIRTY(dqp)) {
                        int     error;
-                       xfs_dqtrace_entry(dqp, "DQRECLAIM: DQDIRTY");
+
+                       trace_xfs_dqreclaim_dirty(dqp);
+
                        /*
                         * We flush it delayed write, so don't bother
                         * releasing the freelist lock.
@@ -2194,8 +2205,9 @@ xfs_qm_dqreclaim_one(void)
                if (!mutex_trylock(&dqp->q_hash->qh_lock))
                        goto mplistunlock;
 
+               trace_xfs_dqreclaim_unlink(dqp);
+
                ASSERT(dqp->q_nrefs == 0);
-               xfs_dqtrace_entry(dqp, "DQRECLAIM: UNLINKING");
                XQM_MPLIST_REMOVE(&(XFS_QI_MPL_LIST(dqp->q_mount)), dqp);
                XQM_HASHLIST_REMOVE(dqp->q_hash, dqp);
                XQM_FREELIST_REMOVE(dqp);
@@ -2430,7 +2442,7 @@ xfs_qm_vop_dqalloc(
                }
        }
        if (uq)
-               xfs_dqtrace_entry_ino(uq, "DQALLOC", ip);
+               trace_xfs_dquot_dqalloc(ip);
 
        xfs_iunlock(ip, lockflags);
        if (O_udqpp)
index 5d1a3b98a6e68875a47dc283483a9be376cdce42..71af76fe8a2369e47fbbc9f3dcb6ebd547bfc449 100644 (file)
@@ -49,6 +49,7 @@
 #include "xfs_buf_item.h"
 #include "xfs_utils.h"
 #include "xfs_qm.h"
+#include "xfs_trace.h"
 
 #ifdef DEBUG
 # define qdprintk(s, args...)  cmn_err(CE_DEBUG, s, ## args)
@@ -496,7 +497,6 @@ xfs_qm_scall_setqlim(
                ASSERT(error != ENOENT);
                return (error);
        }
-       xfs_dqtrace_entry(dqp, "Q_SETQLIM: AFT DQGET");
        xfs_trans_dqjoin(tp, dqp);
        ddq = &dqp->q_core;
 
@@ -602,7 +602,6 @@ xfs_qm_scall_setqlim(
        dqp->dq_flags |= XFS_DQ_DIRTY;
        xfs_trans_log_dquot(tp, dqp);
 
-       xfs_dqtrace_entry(dqp, "Q_SETQLIM: COMMIT");
        error = xfs_trans_commit(tp, 0);
        xfs_qm_dqprint(dqp);
        xfs_qm_dqrele(dqp);
@@ -630,7 +629,6 @@ xfs_qm_scall_getquota(
                return (error);
        }
 
-       xfs_dqtrace_entry(dqp, "Q_GETQUOTA SUCCESS");
        /*
         * If everything's NULL, this dquot doesn't quite exist as far as
         * our utility programs are concerned.
diff --git a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c
deleted file mode 100644 (file)
index 2d494c2..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#include <xfs.h>
-
-static kmem_zone_t *ktrace_hdr_zone;
-static kmem_zone_t *ktrace_ent_zone;
-static int          ktrace_zentries;
-
-void __init
-ktrace_init(int zentries)
-{
-       ktrace_zentries = roundup_pow_of_two(zentries);
-
-       ktrace_hdr_zone = kmem_zone_init(sizeof(ktrace_t),
-                                       "ktrace_hdr");
-       ASSERT(ktrace_hdr_zone);
-
-       ktrace_ent_zone = kmem_zone_init(ktrace_zentries
-                                       * sizeof(ktrace_entry_t),
-                                       "ktrace_ent");
-       ASSERT(ktrace_ent_zone);
-}
-
-void __exit
-ktrace_uninit(void)
-{
-       kmem_zone_destroy(ktrace_hdr_zone);
-       kmem_zone_destroy(ktrace_ent_zone);
-}
-
-/*
- * ktrace_alloc()
- *
- * Allocate a ktrace header and enough buffering for the given
- * number of entries. Round the number of entries up to a
- * power of 2 so we can do fast masking to get the index from
- * the atomic index counter.
- */
-ktrace_t *
-ktrace_alloc(int nentries, unsigned int __nocast sleep)
-{
-       ktrace_t        *ktp;
-       ktrace_entry_t  *ktep;
-       int             entries;
-
-       ktp = (ktrace_t*)kmem_zone_alloc(ktrace_hdr_zone, sleep);
-
-       if (ktp == (ktrace_t*)NULL) {
-               /*
-                * KM_SLEEP callers don't expect failure.
-                */
-               if (sleep & KM_SLEEP)
-                       panic("ktrace_alloc: NULL memory on KM_SLEEP request!");
-
-               return NULL;
-       }
-
-       /*
-        * Special treatment for buffers with the ktrace_zentries entries
-        */
-       entries = roundup_pow_of_two(nentries);
-       if (entries == ktrace_zentries) {
-               ktep = (ktrace_entry_t*)kmem_zone_zalloc(ktrace_ent_zone,
-                                                           sleep);
-       } else {
-               ktep = (ktrace_entry_t*)kmem_zalloc((entries * sizeof(*ktep)),
-                                                           sleep | KM_LARGE);
-       }
-
-       if (ktep == NULL) {
-               /*
-                * KM_SLEEP callers don't expect failure.
-                */
-               if (sleep & KM_SLEEP)
-                       panic("ktrace_alloc: NULL memory on KM_SLEEP request!");
-
-               kmem_free(ktp);
-
-               return NULL;
-       }
-
-       ktp->kt_entries  = ktep;
-       ktp->kt_nentries = entries;
-       ASSERT(is_power_of_2(entries));
-       ktp->kt_index_mask = entries - 1;
-       atomic_set(&ktp->kt_index, 0);
-       ktp->kt_rollover = 0;
-       return ktp;
-}
-
-
-/*
- * ktrace_free()
- *
- * Free up the ktrace header and buffer.  It is up to the caller
- * to ensure that no-one is referencing it.
- */
-void
-ktrace_free(ktrace_t *ktp)
-{
-       if (ktp == (ktrace_t *)NULL)
-               return;
-
-       /*
-        * Special treatment for the Vnode trace buffer.
-        */
-       if (ktp->kt_nentries == ktrace_zentries)
-               kmem_zone_free(ktrace_ent_zone, ktp->kt_entries);
-       else
-               kmem_free(ktp->kt_entries);
-
-       kmem_zone_free(ktrace_hdr_zone, ktp);
-}
-
-
-/*
- * Enter the given values into the "next" entry in the trace buffer.
- * kt_index is always the index of the next entry to be filled.
- */
-void
-ktrace_enter(
-       ktrace_t        *ktp,
-       void            *val0,
-       void            *val1,
-       void            *val2,
-       void            *val3,
-       void            *val4,
-       void            *val5,
-       void            *val6,
-       void            *val7,
-       void            *val8,
-       void            *val9,
-       void            *val10,
-       void            *val11,
-       void            *val12,
-       void            *val13,
-       void            *val14,
-       void            *val15)
-{
-       int             index;
-       ktrace_entry_t  *ktep;
-
-       ASSERT(ktp != NULL);
-
-       /*
-        * Grab an entry by pushing the index up to the next one.
-        */
-       index = atomic_add_return(1, &ktp->kt_index);
-       index = (index - 1) & ktp->kt_index_mask;
-       if (!ktp->kt_rollover && index == ktp->kt_nentries - 1)
-               ktp->kt_rollover = 1;
-
-       ASSERT((index >= 0) && (index < ktp->kt_nentries));
-
-       ktep = &(ktp->kt_entries[index]);
-
-       ktep->val[0]  = val0;
-       ktep->val[1]  = val1;
-       ktep->val[2]  = val2;
-       ktep->val[3]  = val3;
-       ktep->val[4]  = val4;
-       ktep->val[5]  = val5;
-       ktep->val[6]  = val6;
-       ktep->val[7]  = val7;
-       ktep->val[8]  = val8;
-       ktep->val[9]  = val9;
-       ktep->val[10] = val10;
-       ktep->val[11] = val11;
-       ktep->val[12] = val12;
-       ktep->val[13] = val13;
-       ktep->val[14] = val14;
-       ktep->val[15] = val15;
-}
-
-/*
- * Return the number of entries in the trace buffer.
- */
-int
-ktrace_nentries(
-       ktrace_t        *ktp)
-{
-       int     index;
-       if (ktp == NULL)
-               return 0;
-
-       index = atomic_read(&ktp->kt_index) & ktp->kt_index_mask;
-       return (ktp->kt_rollover ? ktp->kt_nentries : index);
-}
-
-/*
- * ktrace_first()
- *
- * This is used to find the start of the trace buffer.
- * In conjunction with ktrace_next() it can be used to
- * iterate through the entire trace buffer.  This code does
- * not do any locking because it is assumed that it is called
- * from the debugger.
- *
- * The caller must pass in a pointer to a ktrace_snap
- * structure in which we will keep some state used to
- * iterate through the buffer.  This state must not touched
- * by any code outside of this module.
- */
-ktrace_entry_t *
-ktrace_first(ktrace_t   *ktp, ktrace_snap_t     *ktsp)
-{
-       ktrace_entry_t  *ktep;
-       int             index;
-       int             nentries;
-
-       if (ktp->kt_rollover)
-               index = atomic_read(&ktp->kt_index) & ktp->kt_index_mask;
-       else
-               index = 0;
-
-       ktsp->ks_start = index;
-       ktep = &(ktp->kt_entries[index]);
-
-       nentries = ktrace_nentries(ktp);
-       index++;
-       if (index < nentries) {
-               ktsp->ks_index = index;
-       } else {
-               ktsp->ks_index = 0;
-               if (index > nentries)
-                       ktep = NULL;
-       }
-       return ktep;
-}
-
-/*
- * ktrace_next()
- *
- * This is used to iterate through the entries of the given
- * trace buffer.  The caller must pass in the ktrace_snap_t
- * structure initialized by ktrace_first().  The return value
- * will be either a pointer to the next ktrace_entry or NULL
- * if all of the entries have been traversed.
- */
-ktrace_entry_t *
-ktrace_next(
-       ktrace_t        *ktp,
-       ktrace_snap_t   *ktsp)
-{
-       int             index;
-       ktrace_entry_t  *ktep;
-
-       index = ktsp->ks_index;
-       if (index == ktsp->ks_start) {
-               ktep = NULL;
-       } else {
-               ktep = &ktp->kt_entries[index];
-       }
-
-       index++;
-       if (index == ktrace_nentries(ktp)) {
-               ktsp->ks_index = 0;
-       } else {
-               ktsp->ks_index = index;
-       }
-
-       return ktep;
-}
-
-/*
- * ktrace_skip()
- *
- * Skip the next "count" entries and return the entry after that.
- * Return NULL if this causes us to iterate past the beginning again.
- */
-ktrace_entry_t *
-ktrace_skip(
-       ktrace_t        *ktp,
-       int             count,
-       ktrace_snap_t   *ktsp)
-{
-       int             index;
-       int             new_index;
-       ktrace_entry_t  *ktep;
-       int             nentries = ktrace_nentries(ktp);
-
-       index = ktsp->ks_index;
-       new_index = index + count;
-       while (new_index >= nentries) {
-               new_index -= nentries;
-       }
-       if (index == ktsp->ks_start) {
-               /*
-                * We've iterated around to the start, so we're done.
-                */
-               ktep = NULL;
-       } else if ((new_index < index) && (index < ktsp->ks_index)) {
-               /*
-                * We've skipped past the start again, so we're done.
-                */
-               ktep = NULL;
-               ktsp->ks_index = ktsp->ks_start;
-       } else {
-               ktep = &(ktp->kt_entries[new_index]);
-               new_index++;
-               if (new_index == nentries) {
-                       ktsp->ks_index = 0;
-               } else {
-                       ktsp->ks_index = new_index;
-               }
-       }
-       return ktep;
-}
diff --git a/fs/xfs/support/ktrace.h b/fs/xfs/support/ktrace.h
deleted file mode 100644 (file)
index 741d694..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#ifndef __XFS_SUPPORT_KTRACE_H__
-#define __XFS_SUPPORT_KTRACE_H__
-
-/*
- * Trace buffer entry structure.
- */
-typedef struct ktrace_entry {
-       void    *val[16];
-} ktrace_entry_t;
-
-/*
- * Trace buffer header structure.
- */
-typedef struct ktrace {
-       int             kt_nentries;    /* number of entries in trace buf */
-       atomic_t        kt_index;       /* current index in entries */
-       unsigned int    kt_index_mask;
-       int             kt_rollover;
-       ktrace_entry_t  *kt_entries;    /* buffer of entries */
-} ktrace_t;
-
-/*
- * Trace buffer snapshot structure.
- */
-typedef struct ktrace_snap {
-       int             ks_start;       /* kt_index at time of snap */
-       int             ks_index;       /* current index */
-} ktrace_snap_t;
-
-
-#ifdef CONFIG_XFS_TRACE
-
-extern void ktrace_init(int zentries);
-extern void ktrace_uninit(void);
-
-extern ktrace_t *ktrace_alloc(int, unsigned int __nocast);
-extern void ktrace_free(ktrace_t *);
-
-extern void ktrace_enter(
-       ktrace_t        *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *,
-       void            *);
-
-extern ktrace_entry_t   *ktrace_first(ktrace_t *, ktrace_snap_t *);
-extern int              ktrace_nentries(ktrace_t *);
-extern ktrace_entry_t   *ktrace_next(ktrace_t *, ktrace_snap_t *);
-extern ktrace_entry_t   *ktrace_skip(ktrace_t *, int, ktrace_snap_t *);
-
-#else
-#define ktrace_init(x) do { } while (0)
-#define ktrace_uninit()        do { } while (0)
-#endif /* CONFIG_XFS_TRACE */
-
-#endif /* __XFS_SUPPORT_KTRACE_H__ */
index 17254b529c54de506e8969826e1f905051763b80..5ad8ad3a1dcd6f10194251d088966016a2d0ea35 100644 (file)
 /* #define QUOTADEBUG 1 */
 #endif
 
-#ifdef CONFIG_XFS_TRACE
-#define XFS_ALLOC_TRACE 1
-#define XFS_ATTR_TRACE 1
-#define XFS_BLI_TRACE 1
-#define XFS_BMAP_TRACE 1
-#define XFS_BTREE_TRACE 1
-#define XFS_DIR2_TRACE 1
-#define XFS_DQUOT_TRACE 1
-#define XFS_ILOCK_TRACE 1
-#define XFS_LOG_TRACE 1
-#define XFS_RW_TRACE 1
-#define XFS_BUF_TRACE 1
-#define XFS_INODE_TRACE 1
-#define XFS_FILESTREAMS_TRACE 1
-#endif
-
 #include <linux-2.6/xfs_linux.h>
 #endif /* __XFS_H__ */
index 947b150df8ede4576550f6f5d8f10a618348ca7e..00fd357c3e46104aeb7349d69931b9c58d2fa8f9 100644 (file)
@@ -49,7 +49,8 @@ extern int xfs_acl_chmod(struct inode *inode);
 extern int posix_acl_access_exists(struct inode *inode);
 extern int posix_acl_default_exists(struct inode *inode);
 
-extern struct xattr_handler xfs_xattr_system_handler;
+extern struct xattr_handler xfs_xattr_acl_access_handler;
+extern struct xattr_handler xfs_xattr_acl_default_handler;
 #else
 # define xfs_check_acl                                 NULL
 # define xfs_get_acl(inode, type)                      NULL
index a5d54bf4931b583dfd3729d670cd0694e7b7c507..6702bd865811d49fc09cda25bb176da256153599 100644 (file)
@@ -86,6 +86,20 @@ typedef struct xfs_agf {
 #define        XFS_AGF_NUM_BITS        12
 #define        XFS_AGF_ALL_BITS        ((1 << XFS_AGF_NUM_BITS) - 1)
 
+#define XFS_AGF_FLAGS \
+       { XFS_AGF_MAGICNUM,     "MAGICNUM" }, \
+       { XFS_AGF_VERSIONNUM,   "VERSIONNUM" }, \
+       { XFS_AGF_SEQNO,        "SEQNO" }, \
+       { XFS_AGF_LENGTH,       "LENGTH" }, \
+       { XFS_AGF_ROOTS,        "ROOTS" }, \
+       { XFS_AGF_LEVELS,       "LEVELS" }, \
+       { XFS_AGF_FLFIRST,      "FLFIRST" }, \
+       { XFS_AGF_FLLAST,       "FLLAST" }, \
+       { XFS_AGF_FLCOUNT,      "FLCOUNT" }, \
+       { XFS_AGF_FREEBLKS,     "FREEBLKS" }, \
+       { XFS_AGF_LONGEST,      "LONGEST" }, \
+       { XFS_AGF_BTREEBLKS,    "BTREEBLKS" }
+
 /* disk block (xfs_daddr_t) in the AG */
 #define XFS_AGF_DADDR(mp)      ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
 #define        XFS_AGF_BLOCK(mp)       XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
index 2cf944eb796daf4ca455865d3dd22c83ee6d13ee..a1c65fc6d9c4dfc382da05ddbc0f66d1cac6e8cb 100644 (file)
@@ -38,6 +38,7 @@
 #include "xfs_ialloc.h"
 #include "xfs_alloc.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 
 #define XFS_ABSDIFF(a,b)       (((a) <= (b)) ? ((b) - (a)) : ((a) - (b)))
@@ -51,30 +52,6 @@ xfs_alloc_search_busy(xfs_trans_t *tp,
                    xfs_agblock_t bno,
                    xfs_extlen_t len);
 
-#if defined(XFS_ALLOC_TRACE)
-ktrace_t *xfs_alloc_trace_buf;
-
-#define        TRACE_ALLOC(s,a)        \
-       xfs_alloc_trace_alloc(__func__, s, a, __LINE__)
-#define        TRACE_FREE(s,a,b,x,f)   \
-       xfs_alloc_trace_free(__func__, s, mp, a, b, x, f, __LINE__)
-#define        TRACE_MODAGF(s,a,f)     \
-       xfs_alloc_trace_modagf(__func__, s, mp, a, f, __LINE__)
-#define        TRACE_BUSY(__func__,s,ag,agb,l,sl,tp)   \
-       xfs_alloc_trace_busy(__func__, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSY, __LINE__)
-#define        TRACE_UNBUSY(__func__,s,ag,sl,tp)       \
-       xfs_alloc_trace_busy(__func__, s, mp, ag, -1, -1, sl, tp, XFS_ALLOC_KTRACE_UNBUSY, __LINE__)
-#define        TRACE_BUSYSEARCH(__func__,s,ag,agb,l,tp)        \
-       xfs_alloc_trace_busy(__func__, s, mp, ag, agb, l, 0, tp, XFS_ALLOC_KTRACE_BUSYSEARCH, __LINE__)
-#else
-#define        TRACE_ALLOC(s,a)
-#define        TRACE_FREE(s,a,b,x,f)
-#define        TRACE_MODAGF(s,a,f)
-#define        TRACE_BUSY(s,a,ag,agb,l,sl,tp)
-#define        TRACE_UNBUSY(fname,s,ag,sl,tp)
-#define        TRACE_BUSYSEARCH(fname,s,ag,agb,l,tp)
-#endif /* XFS_ALLOC_TRACE */
-
 /*
  * Prototypes for per-ag allocation routines
  */
@@ -498,124 +475,6 @@ xfs_alloc_read_agfl(
        return 0;
 }
 
-#if defined(XFS_ALLOC_TRACE)
-/*
- * Add an allocation trace entry for an alloc call.
- */
-STATIC void
-xfs_alloc_trace_alloc(
-       const char      *name,          /* function tag string */
-       char            *str,           /* additional string */
-       xfs_alloc_arg_t *args,          /* allocation argument structure */
-       int             line)           /* source line number */
-{
-       ktrace_enter(xfs_alloc_trace_buf,
-               (void *)(__psint_t)(XFS_ALLOC_KTRACE_ALLOC | (line << 16)),
-               (void *)name,
-               (void *)str,
-               (void *)args->mp,
-               (void *)(__psunsigned_t)args->agno,
-               (void *)(__psunsigned_t)args->agbno,
-               (void *)(__psunsigned_t)args->minlen,
-               (void *)(__psunsigned_t)args->maxlen,
-               (void *)(__psunsigned_t)args->mod,
-               (void *)(__psunsigned_t)args->prod,
-               (void *)(__psunsigned_t)args->minleft,
-               (void *)(__psunsigned_t)args->total,
-               (void *)(__psunsigned_t)args->alignment,
-               (void *)(__psunsigned_t)args->len,
-               (void *)((((__psint_t)args->type) << 16) |
-                        (__psint_t)args->otype),
-               (void *)(__psint_t)((args->wasdel << 3) |
-                                   (args->wasfromfl << 2) |
-                                   (args->isfl << 1) |
-                                   (args->userdata << 0)));
-}
-
-/*
- * Add an allocation trace entry for a free call.
- */
-STATIC void
-xfs_alloc_trace_free(
-       const char      *name,          /* function tag string */
-       char            *str,           /* additional string */
-       xfs_mount_t     *mp,            /* file system mount point */
-       xfs_agnumber_t  agno,           /* allocation group number */
-       xfs_agblock_t   agbno,          /* a.g. relative block number */
-       xfs_extlen_t    len,            /* length of extent */
-       int             isfl,           /* set if is freelist allocation/free */
-       int             line)           /* source line number */
-{
-       ktrace_enter(xfs_alloc_trace_buf,
-               (void *)(__psint_t)(XFS_ALLOC_KTRACE_FREE | (line << 16)),
-               (void *)name,
-               (void *)str,
-               (void *)mp,
-               (void *)(__psunsigned_t)agno,
-               (void *)(__psunsigned_t)agbno,
-               (void *)(__psunsigned_t)len,
-               (void *)(__psint_t)isfl,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-}
-
-/*
- * Add an allocation trace entry for modifying an agf.
- */
-STATIC void
-xfs_alloc_trace_modagf(
-       const char      *name,          /* function tag string */
-       char            *str,           /* additional string */
-       xfs_mount_t     *mp,            /* file system mount point */
-       xfs_agf_t       *agf,           /* new agf value */
-       int             flags,          /* logging flags for agf */
-       int             line)           /* source line number */
-{
-       ktrace_enter(xfs_alloc_trace_buf,
-               (void *)(__psint_t)(XFS_ALLOC_KTRACE_MODAGF | (line << 16)),
-               (void *)name,
-               (void *)str,
-               (void *)mp,
-               (void *)(__psint_t)flags,
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_seqno),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_length),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flfirst),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_fllast),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flcount),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_freeblks),
-               (void *)(__psunsigned_t)be32_to_cpu(agf->agf_longest));
-}
-
-STATIC void
-xfs_alloc_trace_busy(
-       const char      *name,          /* function tag string */
-       char            *str,           /* additional string */
-       xfs_mount_t     *mp,            /* file system mount point */
-       xfs_agnumber_t  agno,           /* allocation group number */
-       xfs_agblock_t   agbno,          /* a.g. relative block number */
-       xfs_extlen_t    len,            /* length of extent */
-       int             slot,           /* perag Busy slot */
-       xfs_trans_t     *tp,
-       int             trtype,         /* type: add, delete, search */
-       int             line)           /* source line number */
-{
-       ktrace_enter(xfs_alloc_trace_buf,
-               (void *)(__psint_t)(trtype | (line << 16)),
-               (void *)name,
-               (void *)str,
-               (void *)mp,
-               (void *)(__psunsigned_t)agno,
-               (void *)(__psunsigned_t)agbno,
-               (void *)(__psunsigned_t)len,
-               (void *)(__psint_t)slot,
-               (void *)tp,
-               NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-}
-#endif /* XFS_ALLOC_TRACE */
-
 /*
  * Allocation group level functions.
  */
@@ -665,9 +524,6 @@ xfs_alloc_ag_vextent(
         */
        if (args->agbno != NULLAGBLOCK) {
                xfs_agf_t       *agf;   /* allocation group freelist header */
-#ifdef XFS_ALLOC_TRACE
-               xfs_mount_t     *mp = args->mp;
-#endif
                long            slen = (long)args->len;
 
                ASSERT(args->len >= args->minlen && args->len <= args->maxlen);
@@ -682,7 +538,6 @@ xfs_alloc_ag_vextent(
                        args->pag->pagf_freeblks -= args->len;
                        ASSERT(be32_to_cpu(agf->agf_freeblks) <=
                                be32_to_cpu(agf->agf_length));
-                       TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS);
                        xfs_alloc_log_agf(args->tp, args->agbp,
                                                XFS_AGF_FREEBLKS);
                        /* search the busylist for these blocks */
@@ -792,13 +647,14 @@ xfs_alloc_ag_vextent_exact(
        }
        xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
        xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
-       TRACE_ALLOC("normal", args);
+
+       trace_xfs_alloc_exact_done(args);
        args->wasfromfl = 0;
        return 0;
 
 error0:
        xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR);
-       TRACE_ALLOC("error", args);
+       trace_xfs_alloc_exact_error(args);
        return error;
 }
 
@@ -958,7 +814,7 @@ xfs_alloc_ag_vextent_near(
                args->len = blen;
                if (!xfs_alloc_fix_minleft(args)) {
                        xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
-                       TRACE_ALLOC("nominleft", args);
+                       trace_xfs_alloc_near_nominleft(args);
                        return 0;
                }
                blen = args->len;
@@ -981,7 +837,8 @@ xfs_alloc_ag_vextent_near(
                        goto error0;
                xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
                xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR);
-               TRACE_ALLOC("first", args);
+
+               trace_xfs_alloc_near_first(args);
                return 0;
        }
        /*
@@ -1272,7 +1129,7 @@ xfs_alloc_ag_vextent_near(
         * If we couldn't get anything, give up.
         */
        if (bno_cur_lt == NULL && bno_cur_gt == NULL) {
-               TRACE_ALLOC("neither", args);
+               trace_xfs_alloc_size_neither(args);
                args->agbno = NULLAGBLOCK;
                return 0;
        }
@@ -1299,7 +1156,7 @@ xfs_alloc_ag_vextent_near(
        args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen);
        xfs_alloc_fix_len(args);
        if (!xfs_alloc_fix_minleft(args)) {
-               TRACE_ALLOC("nominleft", args);
+               trace_xfs_alloc_near_nominleft(args);
                xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR);
                xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
                return 0;
@@ -1314,13 +1171,18 @@ xfs_alloc_ag_vextent_near(
        if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen,
                        ltnew, rlen, XFSA_FIXUP_BNO_OK)))
                goto error0;
-       TRACE_ALLOC(j ? "gt" : "lt", args);
+
+       if (j)
+               trace_xfs_alloc_near_greater(args);
+       else
+               trace_xfs_alloc_near_lesser(args);
+
        xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
        xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR);
        return 0;
 
  error0:
-       TRACE_ALLOC("error", args);
+       trace_xfs_alloc_near_error(args);
        if (cnt_cur != NULL)
                xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR);
        if (bno_cur_lt != NULL)
@@ -1371,7 +1233,7 @@ xfs_alloc_ag_vextent_size(
                        goto error0;
                if (i == 0 || flen == 0) {
                        xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
-                       TRACE_ALLOC("noentry", args);
+                       trace_xfs_alloc_size_noentry(args);
                        return 0;
                }
                ASSERT(i == 1);
@@ -1448,7 +1310,7 @@ xfs_alloc_ag_vextent_size(
        xfs_alloc_fix_len(args);
        if (rlen < args->minlen || !xfs_alloc_fix_minleft(args)) {
                xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);
-               TRACE_ALLOC("nominleft", args);
+               trace_xfs_alloc_size_nominleft(args);
                args->agbno = NULLAGBLOCK;
                return 0;
        }
@@ -1471,11 +1333,11 @@ xfs_alloc_ag_vextent_size(
                args->agbno + args->len <=
                        be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
                error0);
-       TRACE_ALLOC("normal", args);
+       trace_xfs_alloc_size_done(args);
        return 0;
 
 error0:
-       TRACE_ALLOC("error", args);
+       trace_xfs_alloc_size_error(args);
        if (cnt_cur)
                xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR);
        if (bno_cur)
@@ -1534,7 +1396,7 @@ xfs_alloc_ag_vextent_small(
                                be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length),
                                error0);
                        args->wasfromfl = 1;
-                       TRACE_ALLOC("freelist", args);
+                       trace_xfs_alloc_small_freelist(args);
                        *stat = 0;
                        return 0;
                }
@@ -1556,17 +1418,17 @@ xfs_alloc_ag_vextent_small(
         */
        if (flen < args->minlen) {
                args->agbno = NULLAGBLOCK;
-               TRACE_ALLOC("notenough", args);
+               trace_xfs_alloc_small_notenough(args);
                flen = 0;
        }
        *fbnop = fbno;
        *flenp = flen;
        *stat = 1;
-       TRACE_ALLOC("normal", args);
+       trace_xfs_alloc_small_done(args);
        return 0;
 
 error0:
-       TRACE_ALLOC("error", args);
+       trace_xfs_alloc_small_error(args);
        return error;
 }
 
@@ -1809,17 +1671,14 @@ xfs_free_ag_extent(
                        be32_to_cpu(agf->agf_freeblks) <=
                        be32_to_cpu(agf->agf_length),
                        error0);
-               TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS);
                xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
                if (!isfl)
                        xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (long)len);
                XFS_STATS_INC(xs_freex);
                XFS_STATS_ADD(xs_freeb, len);
        }
-       TRACE_FREE(haveleft ?
-                       (haveright ? "both" : "left") :
-                       (haveright ? "right" : "none"),
-               agno, bno, len, isfl);
+
+       trace_xfs_free_extent(mp, agno, bno, len, isfl, haveleft, haveright);
 
        /*
         * Since blocks move to the free list without the coordination
@@ -1836,7 +1695,7 @@ xfs_free_ag_extent(
        return 0;
 
  error0:
-       TRACE_FREE("error", agno, bno, len, isfl);
+       trace_xfs_free_extent(mp, agno, bno, len, isfl, -1, -1);
        if (bno_cur)
                xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR);
        if (cnt_cur)
@@ -2122,7 +1981,6 @@ xfs_alloc_get_freelist(
                logflags |= XFS_AGF_BTREEBLKS;
        }
 
-       TRACE_MODAGF(NULL, agf, logflags);
        xfs_alloc_log_agf(tp, agbp, logflags);
        *bnop = bno;
 
@@ -2165,6 +2023,8 @@ xfs_alloc_log_agf(
                sizeof(xfs_agf_t)
        };
 
+       trace_xfs_agf(tp->t_mountp, XFS_BUF_TO_AGF(bp), fields, _RET_IP_);
+
        xfs_btree_offsets(fields, offsets, XFS_AGF_NUM_BITS, &first, &last);
        xfs_trans_log_buf(tp, bp, (uint)first, (uint)last);
 }
@@ -2230,13 +2090,11 @@ xfs_alloc_put_freelist(
                logflags |= XFS_AGF_BTREEBLKS;
        }
 
-       TRACE_MODAGF(NULL, agf, logflags);
        xfs_alloc_log_agf(tp, agbp, logflags);
 
        ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp));
        blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)];
        *blockp = cpu_to_be32(bno);
-       TRACE_MODAGF(NULL, agf, logflags);
        xfs_alloc_log_agf(tp, agbp, logflags);
        xfs_trans_log_buf(tp, agflbp,
                (int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl),
@@ -2399,7 +2257,7 @@ xfs_alloc_vextent(
            args->minlen > args->maxlen || args->minlen > agsize ||
            args->mod >= args->prod) {
                args->fsbno = NULLFSBLOCK;
-               TRACE_ALLOC("badargs", args);
+               trace_xfs_alloc_vextent_badargs(args);
                return 0;
        }
        minleft = args->minleft;
@@ -2418,12 +2276,12 @@ xfs_alloc_vextent(
                error = xfs_alloc_fix_freelist(args, 0);
                args->minleft = minleft;
                if (error) {
-                       TRACE_ALLOC("nofix", args);
+                       trace_xfs_alloc_vextent_nofix(args);
                        goto error0;
                }
                if (!args->agbp) {
                        up_read(&mp->m_peraglock);
-                       TRACE_ALLOC("noagbp", args);
+                       trace_xfs_alloc_vextent_noagbp(args);
                        break;
                }
                args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno);
@@ -2488,7 +2346,7 @@ xfs_alloc_vextent(
                        error = xfs_alloc_fix_freelist(args, flags);
                        args->minleft = minleft;
                        if (error) {
-                               TRACE_ALLOC("nofix", args);
+                               trace_xfs_alloc_vextent_nofix(args);
                                goto error0;
                        }
                        /*
@@ -2499,7 +2357,9 @@ xfs_alloc_vextent(
                                        goto error0;
                                break;
                        }
-                       TRACE_ALLOC("loopfailed", args);
+
+                       trace_xfs_alloc_vextent_loopfailed(args);
+
                        /*
                         * Didn't work, figure out the next iteration.
                         */
@@ -2526,7 +2386,7 @@ xfs_alloc_vextent(
                        if (args->agno == sagno) {
                                if (no_min == 1) {
                                        args->agbno = NULLAGBLOCK;
-                                       TRACE_ALLOC("allfailed", args);
+                                       trace_xfs_alloc_vextent_allfailed(args);
                                        break;
                                }
                                if (flags == 0) {
@@ -2642,16 +2502,16 @@ xfs_alloc_mark_busy(xfs_trans_t *tp,
                }
        }
 
+       trace_xfs_alloc_busy(mp, agno, bno, len, n);
+
        if (n < XFS_PAGB_NUM_SLOTS) {
                bsy = &mp->m_perag[agno].pagb_list[n];
                mp->m_perag[agno].pagb_count++;
-               TRACE_BUSY("xfs_alloc_mark_busy", "got", agno, bno, len, n, tp);
                bsy->busy_start = bno;
                bsy->busy_length = len;
                bsy->busy_tp = tp;
                xfs_trans_add_busy(tp, agno, n);
        } else {
-               TRACE_BUSY("xfs_alloc_mark_busy", "FULL", agno, bno, len, -1, tp);
                /*
                 * The busy list is full!  Since it is now not possible to
                 * track the free block, make this a synchronous transaction
@@ -2678,12 +2538,12 @@ xfs_alloc_clear_busy(xfs_trans_t *tp,
        list = mp->m_perag[agno].pagb_list;
 
        ASSERT(idx < XFS_PAGB_NUM_SLOTS);
+
+       trace_xfs_alloc_unbusy(mp, agno, idx, list[idx].busy_tp == tp);
+
        if (list[idx].busy_tp == tp) {
-               TRACE_UNBUSY("xfs_alloc_clear_busy", "found", agno, idx, tp);
                list[idx].busy_tp = NULL;
                mp->m_perag[agno].pagb_count--;
-       } else {
-               TRACE_UNBUSY("xfs_alloc_clear_busy", "missing", agno, idx, tp);
        }
 
        spin_unlock(&mp->m_perag[agno].pagb_lock);
@@ -2724,24 +2584,22 @@ xfs_alloc_search_busy(xfs_trans_t *tp,
                        if ((bno > bend) || (uend < bsy->busy_start)) {
                                cnt--;
                        } else {
-                               TRACE_BUSYSEARCH("xfs_alloc_search_busy",
-                                        "found1", agno, bno, len, tp);
                                break;
                        }
                }
        }
 
+       trace_xfs_alloc_busysearch(mp, agno, bno, len, !!cnt);
+
        /*
         * If a block was found, force the log through the LSN of the
         * transaction that freed the block
         */
        if (cnt) {
-               TRACE_BUSYSEARCH("xfs_alloc_search_busy", "found", agno, bno, len, tp);
                lsn = bsy->busy_tp->t_commit_lsn;
                spin_unlock(&mp->m_perag[agno].pagb_lock);
                xfs_log_force(mp, lsn, XFS_LOG_FORCE|XFS_LOG_SYNC);
        } else {
-               TRACE_BUSYSEARCH("xfs_alloc_search_busy", "not-found", agno, bno, len, tp);
                spin_unlock(&mp->m_perag[agno].pagb_lock);
        }
 }
index e704caee10dfaa2bca339969ad840cfc233e9003..599bffa39784d4f425304036d152072115f77b26 100644 (file)
@@ -37,6 +37,15 @@ typedef enum xfs_alloctype
        XFS_ALLOCTYPE_THIS_BNO          /* at exactly this block */
 } xfs_alloctype_t;
 
+#define XFS_ALLOC_TYPES \
+       { XFS_ALLOCTYPE_ANY_AG,         "ANY_AG" }, \
+       { XFS_ALLOCTYPE_FIRST_AG,       "FIRST_AG" }, \
+       { XFS_ALLOCTYPE_START_AG,       "START_AG" }, \
+       { XFS_ALLOCTYPE_THIS_AG,        "THIS_AG" }, \
+       { XFS_ALLOCTYPE_START_BNO,      "START_BNO" }, \
+       { XFS_ALLOCTYPE_NEAR_BNO,       "NEAR_BNO" }, \
+       { XFS_ALLOCTYPE_THIS_BNO,       "THIS_BNO" }
+
 /*
  * Flags for xfs_alloc_fix_freelist.
  */
@@ -109,24 +118,6 @@ xfs_alloc_longest_free_extent(struct xfs_mount *mp,
 
 #ifdef __KERNEL__
 
-#if defined(XFS_ALLOC_TRACE)
-/*
- * Allocation tracing buffer size.
- */
-#define        XFS_ALLOC_TRACE_SIZE    4096
-extern ktrace_t *xfs_alloc_trace_buf;
-
-/*
- * Types for alloc tracing.
- */
-#define        XFS_ALLOC_KTRACE_ALLOC  1
-#define        XFS_ALLOC_KTRACE_FREE   2
-#define        XFS_ALLOC_KTRACE_MODAGF 3
-#define        XFS_ALLOC_KTRACE_BUSY   4
-#define        XFS_ALLOC_KTRACE_UNBUSY 5
-#define        XFS_ALLOC_KTRACE_BUSYSEARCH     6
-#endif
-
 void
 xfs_alloc_mark_busy(xfs_trans_t *tp,
                xfs_agnumber_t agno,
index c10c3a292d30dc57191fe04527c459c73ea91615..adbd9141aea165158b490cb3d3bbed19aa0a3bb7 100644 (file)
@@ -39,6 +39,7 @@
 #include "xfs_ialloc.h"
 #include "xfs_alloc.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 
 STATIC struct xfs_btree_cur *
index 8fe6f6b78a4a3709815e44d9584b6315ba07b9df..e953b6cfb2a85e3f35116180e52ae473e26466a9 100644 (file)
@@ -47,6 +47,7 @@
 #include "xfs_trans_space.h"
 #include "xfs_rw.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 /*
  * xfs_attr.c
@@ -89,10 +90,6 @@ STATIC int xfs_attr_rmtval_remove(xfs_da_args_t *args);
 
 #define ATTR_RMTVALUE_MAPSIZE  1       /* # of map entries at once */
 
-#if defined(XFS_ATTR_TRACE)
-ktrace_t *xfs_attr_trace_buf;
-#endif
-
 STATIC int
 xfs_attr_name_to_xname(
        struct xfs_name *xname,
@@ -640,7 +637,6 @@ xfs_attr_list_int(xfs_attr_list_context_t *context)
                return EIO;
 
        xfs_ilock(dp, XFS_ILOCK_SHARED);
-       xfs_attr_trace_l_c("syscall start", context);
 
        /*
         * Decide on what work routines to call based on the inode size.
@@ -656,7 +652,6 @@ xfs_attr_list_int(xfs_attr_list_context_t *context)
        }
 
        xfs_iunlock(dp, XFS_ILOCK_SHARED);
-       xfs_attr_trace_l_c("syscall end", context);
 
        return error;
 }
@@ -702,7 +697,7 @@ xfs_attr_put_listent(xfs_attr_list_context_t *context, int flags,
                        context->count * sizeof(alist->al_offset[0]);
        context->firstu -= ATTR_ENTSIZE(namelen);
        if (context->firstu < arraytop) {
-               xfs_attr_trace_l_c("buffer full", context);
+               trace_xfs_attr_list_full(context);
                alist->al_more = 1;
                context->seen_enough = 1;
                return 1;
@@ -714,7 +709,7 @@ xfs_attr_put_listent(xfs_attr_list_context_t *context, int flags,
        aep->a_name[namelen] = 0;
        alist->al_offset[context->count++] = context->firstu;
        alist->al_count = context->count;
-       xfs_attr_trace_l_c("add", context);
+       trace_xfs_attr_list_add(context);
        return 0;
 }
 
@@ -1853,7 +1848,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                        node = bp->data;
                        switch (be16_to_cpu(node->hdr.info.magic)) {
                        case XFS_DA_NODE_MAGIC:
-                               xfs_attr_trace_l_cn("wrong blk", context, node);
+                               trace_xfs_attr_list_wrong_blk(context);
                                xfs_da_brelse(NULL, bp);
                                bp = NULL;
                                break;
@@ -1861,20 +1856,18 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                                leaf = bp->data;
                                if (cursor->hashval > be32_to_cpu(leaf->entries[
                                    be16_to_cpu(leaf->hdr.count)-1].hashval)) {
-                                       xfs_attr_trace_l_cl("wrong blk",
-                                                          context, leaf);
+                                       trace_xfs_attr_list_wrong_blk(context);
                                        xfs_da_brelse(NULL, bp);
                                        bp = NULL;
                                } else if (cursor->hashval <=
                                             be32_to_cpu(leaf->entries[0].hashval)) {
-                                       xfs_attr_trace_l_cl("maybe wrong blk",
-                                                          context, leaf);
+                                       trace_xfs_attr_list_wrong_blk(context);
                                        xfs_da_brelse(NULL, bp);
                                        bp = NULL;
                                }
                                break;
                        default:
-                               xfs_attr_trace_l_c("wrong blk - ??", context);
+                               trace_xfs_attr_list_wrong_blk(context);
                                xfs_da_brelse(NULL, bp);
                                bp = NULL;
                        }
@@ -1919,8 +1912,8 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                                if (cursor->hashval
                                                <= be32_to_cpu(btree->hashval)) {
                                        cursor->blkno = be32_to_cpu(btree->before);
-                                       xfs_attr_trace_l_cb("descending",
-                                                           context, btree);
+                                       trace_xfs_attr_list_node_descend(context,
+                                                                        btree);
                                        break;
                                }
                        }
@@ -2270,85 +2263,3 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
        }
        return(0);
 }
-
-#if defined(XFS_ATTR_TRACE)
-/*
- * Add a trace buffer entry for an attr_list context structure.
- */
-void
-xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context)
-{
-       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_C, where, context,
-               (__psunsigned_t)NULL,
-               (__psunsigned_t)NULL,
-               (__psunsigned_t)NULL);
-}
-
-/*
- * Add a trace buffer entry for a context structure and a Btree node.
- */
-void
-xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
-                        struct xfs_da_intnode *node)
-{
-       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CN, where, context,
-               (__psunsigned_t)be16_to_cpu(node->hdr.count),
-               (__psunsigned_t)be32_to_cpu(node->btree[0].hashval),
-               (__psunsigned_t)be32_to_cpu(node->btree[
-                                   be16_to_cpu(node->hdr.count)-1].hashval));
-}
-
-/*
- * Add a trace buffer entry for a context structure and a Btree element.
- */
-void
-xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
-                         struct xfs_da_node_entry *btree)
-{
-       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CB, where, context,
-               (__psunsigned_t)be32_to_cpu(btree->hashval),
-               (__psunsigned_t)be32_to_cpu(btree->before),
-               (__psunsigned_t)NULL);
-}
-
-/*
- * Add a trace buffer entry for a context structure and a leaf block.
- */
-void
-xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
-                             struct xfs_attr_leafblock *leaf)
-{
-       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CL, where, context,
-               (__psunsigned_t)be16_to_cpu(leaf->hdr.count),
-               (__psunsigned_t)be32_to_cpu(leaf->entries[0].hashval),
-               (__psunsigned_t)be32_to_cpu(leaf->entries[
-                               be16_to_cpu(leaf->hdr.count)-1].hashval));
-}
-
-/*
- * Add a trace buffer entry for the arguments given to the routine,
- * generic form.
- */
-void
-xfs_attr_trace_enter(int type, char *where,
-                        struct xfs_attr_list_context *context,
-                        __psunsigned_t a13, __psunsigned_t a14,
-                        __psunsigned_t a15)
-{
-       ASSERT(xfs_attr_trace_buf);
-       ktrace_enter(xfs_attr_trace_buf, (void *)((__psunsigned_t)type),
-               (void *)((__psunsigned_t)where),
-               (void *)((__psunsigned_t)context->dp),
-               (void *)((__psunsigned_t)context->cursor->hashval),
-               (void *)((__psunsigned_t)context->cursor->blkno),
-               (void *)((__psunsigned_t)context->cursor->offset),
-               (void *)((__psunsigned_t)context->alist),
-               (void *)((__psunsigned_t)context->bufsize),
-               (void *)((__psunsigned_t)context->count),
-               (void *)((__psunsigned_t)context->firstu),
-               NULL,
-               (void *)((__psunsigned_t)context->dupcnt),
-               (void *)((__psunsigned_t)context->flags),
-               (void *)a13, (void *)a14, (void *)a15);
-}
-#endif /* XFS_ATTR_TRACE */
index 12f0be3a73d42d5c60f1ba3b3beda8f2078d85c1..59b410ce69a1e631ac11aa6f2c447c4e2bac8805 100644 (file)
@@ -48,6 +48,16 @@ struct xfs_attr_list_context;
 #define ATTR_KERNOTIME 0x1000  /* [kernel] don't update inode timestamps */
 #define ATTR_KERNOVAL  0x2000  /* [kernel] get attr size only, not value */
 
+#define XFS_ATTR_FLAGS \
+       { ATTR_DONTFOLLOW,      "DONTFOLLOW" }, \
+       { ATTR_ROOT,            "ROOT" }, \
+       { ATTR_TRUST,           "TRUST" }, \
+       { ATTR_SECURE,          "SECURE" }, \
+       { ATTR_CREATE,          "CREATE" }, \
+       { ATTR_REPLACE,         "REPLACE" }, \
+       { ATTR_KERNOTIME,       "KERNOTIME" }, \
+       { ATTR_KERNOVAL,        "KERNOVAL" }
+
 /*
  * The maximum size (into the kernel or returned from the kernel) of an
  * attribute value or the buffer used for an attr_list() call.  Larger
index 0b687351293febc2aecfc2282d84adb17ed2bde8..baf41b5af756fdd4da628b45f64ad805e913cba0 100644 (file)
@@ -42,6 +42,7 @@
 #include "xfs_attr.h"
 #include "xfs_attr_leaf.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 /*
  * xfs_attr_leaf.c
@@ -594,7 +595,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        cursor = context->cursor;
        ASSERT(cursor != NULL);
 
-       xfs_attr_trace_l_c("sf start", context);
+       trace_xfs_attr_list_sf(context);
 
        /*
         * If the buffer is large enough and the cursor is at the start,
@@ -627,7 +628,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                                return error;
                        sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
                }
-               xfs_attr_trace_l_c("sf big-gulp", context);
+               trace_xfs_attr_list_sf_all(context);
                return(0);
        }
 
@@ -653,7 +654,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                        XFS_CORRUPTION_ERROR("xfs_attr_shortform_list",
                                             XFS_ERRLEVEL_LOW,
                                             context->dp->i_mount, sfe);
-                       xfs_attr_trace_l_c("sf corrupted", context);
                        kmem_free(sbuf);
                        return XFS_ERROR(EFSCORRUPTED);
                }
@@ -693,7 +693,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        }
        if (i == nsbuf) {
                kmem_free(sbuf);
-               xfs_attr_trace_l_c("blk end", context);
                return(0);
        }
 
@@ -719,7 +718,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
        }
 
        kmem_free(sbuf);
-       xfs_attr_trace_l_c("sf E-O-F", context);
        return(0);
 }
 
@@ -2323,7 +2321,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
        cursor = context->cursor;
        cursor->initted = 1;
 
-       xfs_attr_trace_l_cl("blk start", context, leaf);
+       trace_xfs_attr_list_leaf(context);
 
        /*
         * Re-find our place in the leaf block if this is a new syscall.
@@ -2344,7 +2342,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
                        }
                }
                if (i == be16_to_cpu(leaf->hdr.count)) {
-                       xfs_attr_trace_l_c("not found", context);
+                       trace_xfs_attr_list_notfound(context);
                        return(0);
                }
        } else {
@@ -2419,7 +2417,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
                        break;
                cursor->offset++;
        }
-       xfs_attr_trace_l_cl("blk end", context, leaf);
+       trace_xfs_attr_list_leaf_end(context);
        return(retval);
 }
 
index ea22839caed22757a5076a6997afe66666f14edd..76ab7b0cbb3adac0c0d7e42eac9c364e913e382b 100644 (file)
@@ -25,8 +25,6 @@
  * to fit into the literal area of the inode.
  */
 
-struct xfs_inode;
-
 /*
  * Entries are packed toward the top as tight as possible.
  */
@@ -69,42 +67,4 @@ typedef struct xfs_attr_sf_sort {
        (be16_to_cpu(((xfs_attr_shortform_t *)  \
                ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
 
-#if defined(XFS_ATTR_TRACE)
-/*
- * Kernel tracing support for attribute lists
- */
-struct xfs_attr_list_context;
-struct xfs_da_intnode;
-struct xfs_da_node_entry;
-struct xfs_attr_leafblock;
-
-#define        XFS_ATTR_TRACE_SIZE     4096    /* size of global trace buffer */
-extern ktrace_t        *xfs_attr_trace_buf;
-
-/*
- * Trace record types.
- */
-#define        XFS_ATTR_KTRACE_L_C     1       /* context */
-#define        XFS_ATTR_KTRACE_L_CN    2       /* context, node */
-#define        XFS_ATTR_KTRACE_L_CB    3       /* context, btree */
-#define        XFS_ATTR_KTRACE_L_CL    4       /* context, leaf */
-
-void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context);
-void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
-                             struct xfs_da_intnode *node);
-void xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
-                             struct xfs_da_node_entry *btree);
-void xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
-                             struct xfs_attr_leafblock *leaf);
-void xfs_attr_trace_enter(int type, char *where,
-                            struct xfs_attr_list_context *context,
-                            __psunsigned_t a13, __psunsigned_t a14,
-                            __psunsigned_t a15);
-#else
-#define        xfs_attr_trace_l_c(w,c)
-#define        xfs_attr_trace_l_cn(w,c,n)
-#define        xfs_attr_trace_l_cb(w,c,b)
-#define        xfs_attr_trace_l_cl(w,c,l)
-#endif /* XFS_ATTR_TRACE */
-
 #endif /* __XFS_ATTR_SF_H__ */
index 8971fb09d3879b49e82ffc5b9a3c2e3cb278431b..98251cdc52aa92e2c1557ce71dfd0d9382935887 100644 (file)
@@ -54,6 +54,7 @@
 #include "xfs_buf_item.h"
 #include "xfs_filestream.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 
 #ifdef DEBUG
@@ -272,71 +273,6 @@ xfs_bmap_isaeof(
        int             whichfork,      /* data or attribute fork */
        char            *aeof);         /* return value */
 
-#ifdef XFS_BMAP_TRACE
-/*
- * Add bmap trace entry prior to a call to xfs_iext_remove.
- */
-STATIC void
-xfs_bmap_trace_delete(
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry(entries) deleted */
-       xfs_extnum_t    cnt,            /* count of entries deleted, 1 or 2 */
-       int             whichfork);     /* data or attr fork */
-
-/*
- * Add bmap trace entry prior to a call to xfs_iext_insert, or
- * reading in the extents list from the disk (in the btree).
- */
-STATIC void
-xfs_bmap_trace_insert(
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry(entries) inserted */
-       xfs_extnum_t    cnt,            /* count of entries inserted, 1 or 2 */
-       xfs_bmbt_irec_t *r1,            /* inserted record 1 */
-       xfs_bmbt_irec_t *r2,            /* inserted record 2 or null */
-       int             whichfork);     /* data or attr fork */
-
-/*
- * Add bmap trace entry after updating an extent record in place.
- */
-STATIC void
-xfs_bmap_trace_post_update(
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry updated */
-       int             whichfork);     /* data or attr fork */
-
-/*
- * Add bmap trace entry prior to updating an extent record in place.
- */
-STATIC void
-xfs_bmap_trace_pre_update(
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry to be updated */
-       int             whichfork);     /* data or attr fork */
-
-#define        XFS_BMAP_TRACE_DELETE(d,ip,i,c,w)       \
-       xfs_bmap_trace_delete(__func__,d,ip,i,c,w)
-#define        XFS_BMAP_TRACE_INSERT(d,ip,i,c,r1,r2,w) \
-       xfs_bmap_trace_insert(__func__,d,ip,i,c,r1,r2,w)
-#define        XFS_BMAP_TRACE_POST_UPDATE(d,ip,i,w)    \
-       xfs_bmap_trace_post_update(__func__,d,ip,i,w)
-#define        XFS_BMAP_TRACE_PRE_UPDATE(d,ip,i,w)     \
-       xfs_bmap_trace_pre_update(__func__,d,ip,i,w)
-#else
-#define        XFS_BMAP_TRACE_DELETE(d,ip,i,c,w)
-#define        XFS_BMAP_TRACE_INSERT(d,ip,i,c,r1,r2,w)
-#define        XFS_BMAP_TRACE_POST_UPDATE(d,ip,i,w)
-#define        XFS_BMAP_TRACE_PRE_UPDATE(d,ip,i,w)
-#endif /* XFS_BMAP_TRACE */
-
 /*
  * Compute the worst-case number of indirect blocks that will be used
  * for ip's delayed extent of length "len".
@@ -363,18 +299,6 @@ xfs_bmap_validate_ret(
 #define        xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
 #endif /* DEBUG */
 
-#if defined(XFS_RW_TRACE)
-STATIC void
-xfs_bunmap_trace(
-       xfs_inode_t             *ip,
-       xfs_fileoff_t           bno,
-       xfs_filblks_t           len,
-       int                     flags,
-       inst_t                  *ra);
-#else
-#define        xfs_bunmap_trace(ip, bno, len, flags, ra)
-#endif /* XFS_RW_TRACE */
-
 STATIC int
 xfs_bmap_count_tree(
        xfs_mount_t     *mp,
@@ -590,9 +514,9 @@ xfs_bmap_add_extent(
         * already extents in the list.
         */
        if (nextents == 0) {
-               XFS_BMAP_TRACE_INSERT("insert empty", ip, 0, 1, new, NULL,
-                       whichfork);
-               xfs_iext_insert(ifp, 0, 1, new);
+               xfs_iext_insert(ip, 0, 1, new,
+                               whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0);
+
                ASSERT(cur == NULL);
                ifp->if_lastex = 0;
                if (!isnullstartblock(new->br_startblock)) {
@@ -759,26 +683,10 @@ xfs_bmap_add_extent_delay_real(
        xfs_filblks_t           temp=0; /* value for dnew calculations */
        xfs_filblks_t           temp2=0;/* value for dnew calculations */
        int                     tmp_rval;       /* partial logging flags */
-       enum {                          /* bit number definitions for state */
-               LEFT_CONTIG,    RIGHT_CONTIG,
-               LEFT_FILLING,   RIGHT_FILLING,
-               LEFT_DELAY,     RIGHT_DELAY,
-               LEFT_VALID,     RIGHT_VALID
-       };
 
 #define        LEFT            r[0]
 #define        RIGHT           r[1]
 #define        PREV            r[2]
-#define        MASK(b)         (1 << (b))
-#define        MASK2(a,b)      (MASK(a) | MASK(b))
-#define        MASK3(a,b,c)    (MASK2(a,b) | MASK(c))
-#define        MASK4(a,b,c,d)  (MASK3(a,b,c) | MASK(d))
-#define        STATE_SET(b,v)  ((v) ? (state |= MASK(b)) : (state &= ~MASK(b)))
-#define        STATE_TEST(b)   (state & MASK(b))
-#define        STATE_SET_TEST(b,v)     ((v) ? ((state |= MASK(b)), 1) : \
-                                      ((state &= ~MASK(b)), 0))
-#define        SWITCH_STATE            \
-       (state & MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG))
 
        /*
         * Set up a bunch of variables to make the tests simpler.
@@ -790,69 +698,80 @@ xfs_bmap_add_extent_delay_real(
        new_endoff = new->br_startoff + new->br_blockcount;
        ASSERT(PREV.br_startoff <= new->br_startoff);
        ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff);
+
        /*
         * Set flags determining what part of the previous delayed allocation
         * extent is being replaced by a real allocation.
         */
-       STATE_SET(LEFT_FILLING, PREV.br_startoff == new->br_startoff);
-       STATE_SET(RIGHT_FILLING,
-               PREV.br_startoff + PREV.br_blockcount == new_endoff);
+       if (PREV.br_startoff == new->br_startoff)
+               state |= BMAP_LEFT_FILLING;
+       if (PREV.br_startoff + PREV.br_blockcount == new_endoff)
+               state |= BMAP_RIGHT_FILLING;
+
        /*
         * Check and set flags if this segment has a left neighbor.
         * Don't set contiguous if the combined extent would be too large.
         */
-       if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
+       if (idx > 0) {
+               state |= BMAP_LEFT_VALID;
                xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT);
-               STATE_SET(LEFT_DELAY, isnullstartblock(LEFT.br_startblock));
+
+               if (isnullstartblock(LEFT.br_startblock))
+                       state |= BMAP_LEFT_DELAY;
        }
-       STATE_SET(LEFT_CONTIG,
-               STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) &&
-               LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff &&
-               LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock &&
-               LEFT.br_state == new->br_state &&
-               LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN);
+
+       if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) &&
+           LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff &&
+           LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock &&
+           LEFT.br_state == new->br_state &&
+           LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN)
+               state |= BMAP_LEFT_CONTIG;
+
        /*
         * Check and set flags if this segment has a right neighbor.
         * Don't set contiguous if the combined extent would be too large.
         * Also check for all-three-contiguous being too large.
         */
-       if (STATE_SET_TEST(RIGHT_VALID,
-                       idx <
-                       ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) {
+       if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
+               state |= BMAP_RIGHT_VALID;
                xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT);
-               STATE_SET(RIGHT_DELAY, isnullstartblock(RIGHT.br_startblock));
+
+               if (isnullstartblock(RIGHT.br_startblock))
+                       state |= BMAP_RIGHT_DELAY;
        }
-       STATE_SET(RIGHT_CONTIG,
-               STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) &&
-               new_endoff == RIGHT.br_startoff &&
-               new->br_startblock + new->br_blockcount ==
-                   RIGHT.br_startblock &&
-               new->br_state == RIGHT.br_state &&
-               new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN &&
-               ((state & MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING)) !=
-                 MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING) ||
-                LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount
-                    <= MAXEXTLEN));
+
+       if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) &&
+           new_endoff == RIGHT.br_startoff &&
+           new->br_startblock + new->br_blockcount == RIGHT.br_startblock &&
+           new->br_state == RIGHT.br_state &&
+           new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN &&
+           ((state & (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING |
+                      BMAP_RIGHT_FILLING)) !=
+                     (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING |
+                      BMAP_RIGHT_FILLING) ||
+            LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount
+                       <= MAXEXTLEN))
+               state |= BMAP_RIGHT_CONTIG;
+
        error = 0;
        /*
         * Switch out based on the FILLING and CONTIG state bits.
         */
-       switch (SWITCH_STATE) {
-
-       case MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG):
+       switch (state & (BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG |
+                        BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG)) {
+       case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG |
+            BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
                /*
                 * Filling in all of a previously delayed allocation extent.
                 * The left and right neighbors are both contiguous with new.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC|RC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
                        LEFT.br_blockcount + PREV.br_blockcount +
                        RIGHT.br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1,
-                       XFS_DATA_FORK);
-               XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK);
-               xfs_iext_remove(ifp, idx, 2);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
+               xfs_iext_remove(ip, idx, 2, state);
                ip->i_df.if_lastex = idx - 1;
                ip->i_d.di_nextents--;
                if (cur == NULL)
@@ -885,20 +804,18 @@ xfs_bmap_add_extent_delay_real(
                        RIGHT.br_blockcount;
                break;
 
-       case MASK3(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG):
+       case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG:
                /*
                 * Filling in all of a previously delayed allocation extent.
                 * The left neighbor is contiguous, the right is not.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
                        LEFT.br_blockcount + PREV.br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx - 1;
-               XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK);
-               xfs_iext_remove(ifp, idx, 1);
+               xfs_iext_remove(ip, idx, 1, state);
                if (cur == NULL)
                        rval = XFS_ILOG_DEXT;
                else {
@@ -921,19 +838,19 @@ xfs_bmap_add_extent_delay_real(
                        PREV.br_blockcount;
                break;
 
-       case MASK3(LEFT_FILLING, RIGHT_FILLING, RIGHT_CONTIG):
+       case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
                /*
                 * Filling in all of a previously delayed allocation extent.
                 * The right neighbor is contiguous, the left is not.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|RC", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_startblock(ep, new->br_startblock);
                xfs_bmbt_set_blockcount(ep,
                        PREV.br_blockcount + RIGHT.br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|RF|RC", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx;
-               XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK);
-               xfs_iext_remove(ifp, idx + 1, 1);
+               xfs_iext_remove(ip, idx + 1, 1, state);
                if (cur == NULL)
                        rval = XFS_ILOG_DEXT;
                else {
@@ -956,15 +873,16 @@ xfs_bmap_add_extent_delay_real(
                        RIGHT.br_blockcount;
                break;
 
-       case MASK2(LEFT_FILLING, RIGHT_FILLING):
+       case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING:
                /*
                 * Filling in all of a previously delayed allocation extent.
                 * Neither the left nor right neighbors are contiguous with
                 * the new one.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|RF", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_startblock(ep, new->br_startblock);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|RF", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx;
                ip->i_d.di_nextents++;
                if (cur == NULL)
@@ -987,19 +905,20 @@ xfs_bmap_add_extent_delay_real(
                temp2 = new->br_blockcount;
                break;
 
-       case MASK2(LEFT_FILLING, LEFT_CONTIG):
+       case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG:
                /*
                 * Filling in the first part of a previous delayed allocation.
                 * The left neighbor is contiguous.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx - 1, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
                        LEFT.br_blockcount + new->br_blockcount);
                xfs_bmbt_set_startoff(ep,
                        PREV.br_startoff + new->br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx - 1, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
                temp = PREV.br_blockcount - new->br_blockcount;
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep, temp);
                ip->i_df.if_lastex = idx - 1;
                if (cur == NULL)
@@ -1021,7 +940,7 @@ xfs_bmap_add_extent_delay_real(
                temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
                        startblockval(PREV.br_startblock));
                xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
-               XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                *dnew = temp;
                /* DELTA: The boundary between two in-core extents moved. */
                temp = LEFT.br_startoff;
@@ -1029,18 +948,16 @@ xfs_bmap_add_extent_delay_real(
                        PREV.br_blockcount;
                break;
 
-       case MASK(LEFT_FILLING):
+       case BMAP_LEFT_FILLING:
                /*
                 * Filling in the first part of a previous delayed allocation.
                 * The left neighbor is not contiguous.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_startoff(ep, new_endoff);
                temp = PREV.br_blockcount - new->br_blockcount;
                xfs_bmbt_set_blockcount(ep, temp);
-               XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL,
-                       XFS_DATA_FORK);
-               xfs_iext_insert(ifp, idx, 1, new);
+               xfs_iext_insert(ip, idx, 1, new, state);
                ip->i_df.if_lastex = idx;
                ip->i_d.di_nextents++;
                if (cur == NULL)
@@ -1071,27 +988,27 @@ xfs_bmap_add_extent_delay_real(
                        (cur ? cur->bc_private.b.allocated : 0));
                ep = xfs_iext_get_ext(ifp, idx + 1);
                xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
-               XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx + 1, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx + 1, state, _THIS_IP_);
                *dnew = temp;
                /* DELTA: One in-core extent is split in two. */
                temp = PREV.br_startoff;
                temp2 = PREV.br_blockcount;
                break;
 
-       case MASK2(RIGHT_FILLING, RIGHT_CONTIG):
+       case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
                /*
                 * Filling in the last part of a previous delayed allocation.
                 * The right neighbor is contiguous with the new allocation.
                 */
                temp = PREV.br_blockcount - new->br_blockcount;
-               XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx, XFS_DATA_FORK);
-               XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx + 1, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
+               trace_xfs_bmap_pre_update(ip, idx + 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep, temp);
                xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1),
                        new->br_startoff, new->br_startblock,
                        new->br_blockcount + RIGHT.br_blockcount,
                        RIGHT.br_state);
-               XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx + 1, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx + 1, state, _THIS_IP_);
                ip->i_df.if_lastex = idx + 1;
                if (cur == NULL)
                        rval = XFS_ILOG_DEXT;
@@ -1112,7 +1029,7 @@ xfs_bmap_add_extent_delay_real(
                temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
                        startblockval(PREV.br_startblock));
                xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
-               XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                *dnew = temp;
                /* DELTA: The boundary between two in-core extents moved. */
                temp = PREV.br_startoff;
@@ -1120,17 +1037,15 @@ xfs_bmap_add_extent_delay_real(
                        RIGHT.br_blockcount;
                break;
 
-       case MASK(RIGHT_FILLING):
+       case BMAP_RIGHT_FILLING:
                /*
                 * Filling in the last part of a previous delayed allocation.
                 * The right neighbor is not contiguous.
                 */
                temp = PREV.br_blockcount - new->br_blockcount;
-               XFS_BMAP_TRACE_PRE_UPDATE("RF", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep, temp);
-               XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL,
-                       XFS_DATA_FORK);
-               xfs_iext_insert(ifp, idx + 1, 1, new);
+               xfs_iext_insert(ip, idx + 1, 1, new, state);
                ip->i_df.if_lastex = idx + 1;
                ip->i_d.di_nextents++;
                if (cur == NULL)
@@ -1161,7 +1076,7 @@ xfs_bmap_add_extent_delay_real(
                        (cur ? cur->bc_private.b.allocated : 0));
                ep = xfs_iext_get_ext(ifp, idx);
                xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
-               XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                *dnew = temp;
                /* DELTA: One in-core extent is split in two. */
                temp = PREV.br_startoff;
@@ -1175,7 +1090,7 @@ xfs_bmap_add_extent_delay_real(
                 * This case is avoided almost all the time.
                 */
                temp = new->br_startoff - PREV.br_startoff;
-               XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, 0, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep, temp);
                r[0] = *new;
                r[1].br_state = PREV.br_state;
@@ -1183,9 +1098,7 @@ xfs_bmap_add_extent_delay_real(
                r[1].br_startoff = new_endoff;
                temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff;
                r[1].br_blockcount = temp2;
-               XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1],
-                       XFS_DATA_FORK);
-               xfs_iext_insert(ifp, idx + 1, 2, &r[0]);
+               xfs_iext_insert(ip, idx + 1, 2, &r[0], state);
                ip->i_df.if_lastex = idx + 1;
                ip->i_d.di_nextents++;
                if (cur == NULL)
@@ -1242,24 +1155,24 @@ xfs_bmap_add_extent_delay_real(
                }
                ep = xfs_iext_get_ext(ifp, idx);
                xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
-               XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, XFS_DATA_FORK);
-               XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx + 2, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+               trace_xfs_bmap_pre_update(ip, idx + 2, state, _THIS_IP_);
                xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2),
                        nullstartblock((int)temp2));
-               XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx + 2, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx + 2, state, _THIS_IP_);
                *dnew = temp + temp2;
                /* DELTA: One in-core extent is split in three. */
                temp = PREV.br_startoff;
                temp2 = PREV.br_blockcount;
                break;
 
-       case MASK3(LEFT_FILLING, LEFT_CONTIG, RIGHT_CONTIG):
-       case MASK3(RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG):
-       case MASK2(LEFT_FILLING, RIGHT_CONTIG):
-       case MASK2(RIGHT_FILLING, LEFT_CONTIG):
-       case MASK2(LEFT_CONTIG, RIGHT_CONTIG):
-       case MASK(LEFT_CONTIG):
-       case MASK(RIGHT_CONTIG):
+       case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
+       case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
+       case BMAP_LEFT_FILLING | BMAP_RIGHT_CONTIG:
+       case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG:
+       case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
+       case BMAP_LEFT_CONTIG:
+       case BMAP_RIGHT_CONTIG:
                /*
                 * These cases are all impossible.
                 */
@@ -1279,14 +1192,6 @@ done:
 #undef LEFT
 #undef RIGHT
 #undef PREV
-#undef MASK
-#undef MASK2
-#undef MASK3
-#undef MASK4
-#undef STATE_SET
-#undef STATE_TEST
-#undef STATE_SET_TEST
-#undef SWITCH_STATE
 }
 
 /*
@@ -1316,27 +1221,10 @@ xfs_bmap_add_extent_unwritten_real(
        int                     state = 0;/* state bits, accessed thru macros */
        xfs_filblks_t           temp=0;
        xfs_filblks_t           temp2=0;
-       enum {                          /* bit number definitions for state */
-               LEFT_CONTIG,    RIGHT_CONTIG,
-               LEFT_FILLING,   RIGHT_FILLING,
-               LEFT_DELAY,     RIGHT_DELAY,
-               LEFT_VALID,     RIGHT_VALID
-       };
 
 #define        LEFT            r[0]
 #define        RIGHT           r[1]
 #define        PREV            r[2]
-#define        MASK(b)         (1 << (b))
-#define        MASK2(a,b)      (MASK(a) | MASK(b))
-#define        MASK3(a,b,c)    (MASK2(a,b) | MASK(c))
-#define        MASK4(a,b,c,d)  (MASK3(a,b,c) | MASK(d))
-#define        STATE_SET(b,v)  ((v) ? (state |= MASK(b)) : (state &= ~MASK(b)))
-#define        STATE_TEST(b)   (state & MASK(b))
-#define        STATE_SET_TEST(b,v)     ((v) ? ((state |= MASK(b)), 1) : \
-                                      ((state &= ~MASK(b)), 0))
-#define        SWITCH_STATE            \
-       (state & MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG))
-
        /*
         * Set up a bunch of variables to make the tests simpler.
         */
@@ -1352,68 +1240,78 @@ xfs_bmap_add_extent_unwritten_real(
        new_endoff = new->br_startoff + new->br_blockcount;
        ASSERT(PREV.br_startoff <= new->br_startoff);
        ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff);
+
        /*
         * Set flags determining what part of the previous oldext allocation
         * extent is being replaced by a newext allocation.
         */
-       STATE_SET(LEFT_FILLING, PREV.br_startoff == new->br_startoff);
-       STATE_SET(RIGHT_FILLING,
-               PREV.br_startoff + PREV.br_blockcount == new_endoff);
+       if (PREV.br_startoff == new->br_startoff)
+               state |= BMAP_LEFT_FILLING;
+       if (PREV.br_startoff + PREV.br_blockcount == new_endoff)
+               state |= BMAP_RIGHT_FILLING;
+
        /*
         * Check and set flags if this segment has a left neighbor.
         * Don't set contiguous if the combined extent would be too large.
         */
-       if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
+       if (idx > 0) {
+               state |= BMAP_LEFT_VALID;
                xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT);
-               STATE_SET(LEFT_DELAY, isnullstartblock(LEFT.br_startblock));
+
+               if (isnullstartblock(LEFT.br_startblock))
+                       state |= BMAP_LEFT_DELAY;
        }
-       STATE_SET(LEFT_CONTIG,
-               STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) &&
-               LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff &&
-               LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock &&
-               LEFT.br_state == newext &&
-               LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN);
+
+       if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) &&
+           LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff &&
+           LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock &&
+           LEFT.br_state == newext &&
+           LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN)
+               state |= BMAP_LEFT_CONTIG;
+
        /*
         * Check and set flags if this segment has a right neighbor.
         * Don't set contiguous if the combined extent would be too large.
         * Also check for all-three-contiguous being too large.
         */
-       if (STATE_SET_TEST(RIGHT_VALID,
-                       idx <
-                       ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) {
+       if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
+               state |= BMAP_RIGHT_VALID;
                xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT);
-               STATE_SET(RIGHT_DELAY, isnullstartblock(RIGHT.br_startblock));
+               if (isnullstartblock(RIGHT.br_startblock))
+                       state |= BMAP_RIGHT_DELAY;
        }
-       STATE_SET(RIGHT_CONTIG,
-               STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) &&
-               new_endoff == RIGHT.br_startoff &&
-               new->br_startblock + new->br_blockcount ==
-                   RIGHT.br_startblock &&
-               newext == RIGHT.br_state &&
-               new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN &&
-               ((state & MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING)) !=
-                 MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING) ||
-                LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount
-                    <= MAXEXTLEN));
+
+       if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) &&
+           new_endoff == RIGHT.br_startoff &&
+           new->br_startblock + new->br_blockcount == RIGHT.br_startblock &&
+           newext == RIGHT.br_state &&
+           new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN &&
+           ((state & (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING |
+                      BMAP_RIGHT_FILLING)) !=
+                     (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING |
+                      BMAP_RIGHT_FILLING) ||
+            LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount
+                       <= MAXEXTLEN))
+               state |= BMAP_RIGHT_CONTIG;
+
        /*
         * Switch out based on the FILLING and CONTIG state bits.
         */
-       switch (SWITCH_STATE) {
-
-       case MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG):
+       switch (state & (BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG |
+                        BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG)) {
+       case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG |
+            BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
                /*
                 * Setting all of a previous oldext extent to newext.
                 * The left and right neighbors are both contiguous with new.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC|RC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
                        LEFT.br_blockcount + PREV.br_blockcount +
                        RIGHT.br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1,
-                       XFS_DATA_FORK);
-               XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK);
-               xfs_iext_remove(ifp, idx, 2);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
+               xfs_iext_remove(ip, idx, 2, state);
                ip->i_df.if_lastex = idx - 1;
                ip->i_d.di_nextents -= 2;
                if (cur == NULL)
@@ -1450,20 +1348,18 @@ xfs_bmap_add_extent_unwritten_real(
                        RIGHT.br_blockcount;
                break;
 
-       case MASK3(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG):
+       case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG:
                /*
                 * Setting all of a previous oldext extent to newext.
                 * The left neighbor is contiguous, the right is not.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
                        LEFT.br_blockcount + PREV.br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx - 1;
-               XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK);
-               xfs_iext_remove(ifp, idx, 1);
+               xfs_iext_remove(ip, idx, 1, state);
                ip->i_d.di_nextents--;
                if (cur == NULL)
                        rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
@@ -1492,21 +1388,18 @@ xfs_bmap_add_extent_unwritten_real(
                        PREV.br_blockcount;
                break;
 
-       case MASK3(LEFT_FILLING, RIGHT_FILLING, RIGHT_CONTIG):
+       case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
                /*
                 * Setting all of a previous oldext extent to newext.
                 * The right neighbor is contiguous, the left is not.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|RC", ip, idx,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep,
                        PREV.br_blockcount + RIGHT.br_blockcount);
                xfs_bmbt_set_state(ep, newext);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|RF|RC", ip, idx,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                ip->i_df.if_lastex = idx;
-               XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK);
-               xfs_iext_remove(ifp, idx + 1, 1);
+               xfs_iext_remove(ip, idx + 1, 1, state);
                ip->i_d.di_nextents--;
                if (cur == NULL)
                        rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
@@ -1535,17 +1428,16 @@ xfs_bmap_add_extent_unwritten_real(
                        RIGHT.br_blockcount;
                break;
 
-       case MASK2(LEFT_FILLING, RIGHT_FILLING):
+       case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING:
                /*
                 * Setting all of a previous oldext extent to newext.
                 * Neither the left nor right neighbors are contiguous with
                 * the new one.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|RF", ip, idx,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_state(ep, newext);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|RF", ip, idx,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx;
                if (cur == NULL)
                        rval = XFS_ILOG_DEXT;
@@ -1566,27 +1458,25 @@ xfs_bmap_add_extent_unwritten_real(
                temp2 = new->br_blockcount;
                break;
 
-       case MASK2(LEFT_FILLING, LEFT_CONTIG):
+       case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG:
                /*
                 * Setting the first part of a previous oldext extent to newext.
                 * The left neighbor is contiguous.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
                        LEFT.br_blockcount + new->br_blockcount);
                xfs_bmbt_set_startoff(ep,
                        PREV.br_startoff + new->br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx - 1,
-                       XFS_DATA_FORK);
-               XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_startblock(ep,
                        new->br_startblock + new->br_blockcount);
                xfs_bmbt_set_blockcount(ep,
                        PREV.br_blockcount - new->br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx - 1;
                if (cur == NULL)
                        rval = XFS_ILOG_DEXT;
@@ -1617,22 +1507,21 @@ xfs_bmap_add_extent_unwritten_real(
                        PREV.br_blockcount;
                break;
 
-       case MASK(LEFT_FILLING):
+       case BMAP_LEFT_FILLING:
                /*
                 * Setting the first part of a previous oldext extent to newext.
                 * The left neighbor is not contiguous.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LF", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                ASSERT(ep && xfs_bmbt_get_state(ep) == oldext);
                xfs_bmbt_set_startoff(ep, new_endoff);
                xfs_bmbt_set_blockcount(ep,
                        PREV.br_blockcount - new->br_blockcount);
                xfs_bmbt_set_startblock(ep,
                        new->br_startblock + new->br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx, XFS_DATA_FORK);
-               XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL,
-                       XFS_DATA_FORK);
-               xfs_iext_insert(ifp, idx, 1, new);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
+               xfs_iext_insert(ip, idx, 1, new, state);
                ip->i_df.if_lastex = idx;
                ip->i_d.di_nextents++;
                if (cur == NULL)
@@ -1660,24 +1549,21 @@ xfs_bmap_add_extent_unwritten_real(
                temp2 = PREV.br_blockcount;
                break;
 
-       case MASK2(RIGHT_FILLING, RIGHT_CONTIG):
+       case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
                /*
                 * Setting the last part of a previous oldext extent to newext.
                 * The right neighbor is contiguous with the new allocation.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx,
-                       XFS_DATA_FORK);
-               XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx + 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
+               trace_xfs_bmap_pre_update(ip, idx + 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep,
                        PREV.br_blockcount - new->br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1),
                        new->br_startoff, new->br_startblock,
                        new->br_blockcount + RIGHT.br_blockcount, newext);
-               XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx + 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx + 1, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx + 1;
                if (cur == NULL)
                        rval = XFS_ILOG_DEXT;
@@ -1707,18 +1593,17 @@ xfs_bmap_add_extent_unwritten_real(
                        RIGHT.br_blockcount;
                break;
 
-       case MASK(RIGHT_FILLING):
+       case BMAP_RIGHT_FILLING:
                /*
                 * Setting the last part of a previous oldext extent to newext.
                 * The right neighbor is not contiguous.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("RF", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep,
                        PREV.br_blockcount - new->br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK);
-               XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL,
-                       XFS_DATA_FORK);
-               xfs_iext_insert(ifp, idx + 1, 1, new);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
+               xfs_iext_insert(ip, idx + 1, 1, new, state);
                ip->i_df.if_lastex = idx + 1;
                ip->i_d.di_nextents++;
                if (cur == NULL)
@@ -1756,19 +1641,18 @@ xfs_bmap_add_extent_unwritten_real(
                 * newext.  Contiguity is impossible here.
                 * One extent becomes three extents.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep,
                        new->br_startoff - PREV.br_startoff);
-               XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
                r[0] = *new;
                r[1].br_startoff = new_endoff;
                r[1].br_blockcount =
                        PREV.br_startoff + PREV.br_blockcount - new_endoff;
                r[1].br_startblock = new->br_startblock + new->br_blockcount;
                r[1].br_state = oldext;
-               XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1],
-                       XFS_DATA_FORK);
-               xfs_iext_insert(ifp, idx + 1, 2, &r[0]);
+               xfs_iext_insert(ip, idx + 1, 2, &r[0], state);
                ip->i_df.if_lastex = idx + 1;
                ip->i_d.di_nextents += 2;
                if (cur == NULL)
@@ -1813,13 +1697,13 @@ xfs_bmap_add_extent_unwritten_real(
                temp2 = PREV.br_blockcount;
                break;
 
-       case MASK3(LEFT_FILLING, LEFT_CONTIG, RIGHT_CONTIG):
-       case MASK3(RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG):
-       case MASK2(LEFT_FILLING, RIGHT_CONTIG):
-       case MASK2(RIGHT_FILLING, LEFT_CONTIG):
-       case MASK2(LEFT_CONTIG, RIGHT_CONTIG):
-       case MASK(LEFT_CONTIG):
-       case MASK(RIGHT_CONTIG):
+       case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
+       case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
+       case BMAP_LEFT_FILLING | BMAP_RIGHT_CONTIG:
+       case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG:
+       case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
+       case BMAP_LEFT_CONTIG:
+       case BMAP_RIGHT_CONTIG:
                /*
                 * These cases are all impossible.
                 */
@@ -1839,14 +1723,6 @@ done:
 #undef LEFT
 #undef RIGHT
 #undef PREV
-#undef MASK
-#undef MASK2
-#undef MASK3
-#undef MASK4
-#undef STATE_SET
-#undef STATE_TEST
-#undef STATE_SET_TEST
-#undef SWITCH_STATE
 }
 
 /*
@@ -1872,62 +1748,57 @@ xfs_bmap_add_extent_hole_delay(
        int                     state;  /* state bits, accessed thru macros */
        xfs_filblks_t           temp=0; /* temp for indirect calculations */
        xfs_filblks_t           temp2=0;
-       enum {                          /* bit number definitions for state */
-               LEFT_CONTIG,    RIGHT_CONTIG,
-               LEFT_DELAY,     RIGHT_DELAY,
-               LEFT_VALID,     RIGHT_VALID
-       };
-
-#define        MASK(b)                 (1 << (b))
-#define        MASK2(a,b)              (MASK(a) | MASK(b))
-#define        STATE_SET(b,v)          ((v) ? (state |= MASK(b)) : (state &= ~MASK(b)))
-#define        STATE_TEST(b)           (state & MASK(b))
-#define        STATE_SET_TEST(b,v)     ((v) ? ((state |= MASK(b)), 1) : \
-                                      ((state &= ~MASK(b)), 0))
-#define        SWITCH_STATE            (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG))
 
        ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
        ep = xfs_iext_get_ext(ifp, idx);
        state = 0;
        ASSERT(isnullstartblock(new->br_startblock));
+
        /*
         * Check and set flags if this segment has a left neighbor
         */
-       if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
+       if (idx > 0) {
+               state |= BMAP_LEFT_VALID;
                xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left);
-               STATE_SET(LEFT_DELAY, isnullstartblock(left.br_startblock));
+
+               if (isnullstartblock(left.br_startblock))
+                       state |= BMAP_LEFT_DELAY;
        }
+
        /*
         * Check and set flags if the current (right) segment exists.
         * If it doesn't exist, we're converting the hole at end-of-file.
         */
-       if (STATE_SET_TEST(RIGHT_VALID,
-                          idx <
-                          ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) {
+       if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
+               state |= BMAP_RIGHT_VALID;
                xfs_bmbt_get_all(ep, &right);
-               STATE_SET(RIGHT_DELAY, isnullstartblock(right.br_startblock));
+
+               if (isnullstartblock(right.br_startblock))
+                       state |= BMAP_RIGHT_DELAY;
        }
+
        /*
         * Set contiguity flags on the left and right neighbors.
         * Don't let extents get too large, even if the pieces are contiguous.
         */
-       STATE_SET(LEFT_CONTIG,
-               STATE_TEST(LEFT_VALID) && STATE_TEST(LEFT_DELAY) &&
-               left.br_startoff + left.br_blockcount == new->br_startoff &&
-               left.br_blockcount + new->br_blockcount <= MAXEXTLEN);
-       STATE_SET(RIGHT_CONTIG,
-               STATE_TEST(RIGHT_VALID) && STATE_TEST(RIGHT_DELAY) &&
-               new->br_startoff + new->br_blockcount == right.br_startoff &&
-               new->br_blockcount + right.br_blockcount <= MAXEXTLEN &&
-               (!STATE_TEST(LEFT_CONTIG) ||
-                (left.br_blockcount + new->br_blockcount +
-                    right.br_blockcount <= MAXEXTLEN)));
+       if ((state & BMAP_LEFT_VALID) && (state & BMAP_LEFT_DELAY) &&
+           left.br_startoff + left.br_blockcount == new->br_startoff &&
+           left.br_blockcount + new->br_blockcount <= MAXEXTLEN)
+               state |= BMAP_LEFT_CONTIG;
+
+       if ((state & BMAP_RIGHT_VALID) && (state & BMAP_RIGHT_DELAY) &&
+           new->br_startoff + new->br_blockcount == right.br_startoff &&
+           new->br_blockcount + right.br_blockcount <= MAXEXTLEN &&
+           (!(state & BMAP_LEFT_CONTIG) ||
+            (left.br_blockcount + new->br_blockcount +
+             right.br_blockcount <= MAXEXTLEN)))
+               state |= BMAP_RIGHT_CONTIG;
+
        /*
         * Switch out based on the contiguity flags.
         */
-       switch (SWITCH_STATE) {
-
-       case MASK2(LEFT_CONTIG, RIGHT_CONTIG):
+       switch (state & (BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG)) {
+       case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
                /*
                 * New allocation is contiguous with delayed allocations
                 * on the left and on the right.
@@ -1935,8 +1806,8 @@ xfs_bmap_add_extent_hole_delay(
                 */
                temp = left.br_blockcount + new->br_blockcount +
                        right.br_blockcount;
-               XFS_BMAP_TRACE_PRE_UPDATE("LC|RC", ip, idx - 1,
-                       XFS_DATA_FORK);
+
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp);
                oldlen = startblockval(left.br_startblock) +
                        startblockval(new->br_startblock) +
@@ -1944,53 +1815,52 @@ xfs_bmap_add_extent_hole_delay(
                newlen = xfs_bmap_worst_indlen(ip, temp);
                xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1),
                        nullstartblock((int)newlen));
-               XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1,
-                       XFS_DATA_FORK);
-               XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, XFS_DATA_FORK);
-               xfs_iext_remove(ifp, idx, 1);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
+               xfs_iext_remove(ip, idx, 1, state);
                ip->i_df.if_lastex = idx - 1;
                /* DELTA: Two in-core extents were replaced by one. */
                temp2 = temp;
                temp = left.br_startoff;
                break;
 
-       case MASK(LEFT_CONTIG):
+       case BMAP_LEFT_CONTIG:
                /*
                 * New allocation is contiguous with a delayed allocation
                 * on the left.
                 * Merge the new allocation with the left neighbor.
                 */
                temp = left.br_blockcount + new->br_blockcount;
-               XFS_BMAP_TRACE_PRE_UPDATE("LC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp);
                oldlen = startblockval(left.br_startblock) +
                        startblockval(new->br_startblock);
                newlen = xfs_bmap_worst_indlen(ip, temp);
                xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1),
                        nullstartblock((int)newlen));
-               XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1,
-                       XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx - 1;
                /* DELTA: One in-core extent grew into a hole. */
                temp2 = temp;
                temp = left.br_startoff;
                break;
 
-       case MASK(RIGHT_CONTIG):
+       case BMAP_RIGHT_CONTIG:
                /*
                 * New allocation is contiguous with a delayed allocation
                 * on the right.
                 * Merge the new allocation with the right neighbor.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("RC", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                temp = new->br_blockcount + right.br_blockcount;
                oldlen = startblockval(new->br_startblock) +
                        startblockval(right.br_startblock);
                newlen = xfs_bmap_worst_indlen(ip, temp);
                xfs_bmbt_set_allf(ep, new->br_startoff,
                        nullstartblock((int)newlen), temp, right.br_state);
-               XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, XFS_DATA_FORK);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
                ip->i_df.if_lastex = idx;
                /* DELTA: One in-core extent grew into a hole. */
                temp2 = temp;
@@ -2004,9 +1874,7 @@ xfs_bmap_add_extent_hole_delay(
                 * Insert a new entry.
                 */
                oldlen = newlen = 0;
-               XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL,
-                       XFS_DATA_FORK);
-               xfs_iext_insert(ifp, idx, 1, new);
+               xfs_iext_insert(ip, idx, 1, new, state);
                ip->i_df.if_lastex = idx;
                /* DELTA: A new in-core extent was added in a hole. */
                temp2 = new->br_blockcount;
@@ -2030,12 +1898,6 @@ xfs_bmap_add_extent_hole_delay(
        }
        *logflagsp = 0;
        return 0;
-#undef MASK
-#undef MASK2
-#undef STATE_SET
-#undef STATE_TEST
-#undef STATE_SET_TEST
-#undef SWITCH_STATE
 }
 
 /*
@@ -2062,83 +1924,75 @@ xfs_bmap_add_extent_hole_real(
        int                     state;  /* state bits, accessed thru macros */
        xfs_filblks_t           temp=0;
        xfs_filblks_t           temp2=0;
-       enum {                          /* bit number definitions for state */
-               LEFT_CONTIG,    RIGHT_CONTIG,
-               LEFT_DELAY,     RIGHT_DELAY,
-               LEFT_VALID,     RIGHT_VALID
-       };
-
-#define        MASK(b)                 (1 << (b))
-#define        MASK2(a,b)              (MASK(a) | MASK(b))
-#define        STATE_SET(b,v)          ((v) ? (state |= MASK(b)) : (state &= ~MASK(b)))
-#define        STATE_TEST(b)           (state & MASK(b))
-#define        STATE_SET_TEST(b,v)     ((v) ? ((state |= MASK(b)), 1) : \
-                                      ((state &= ~MASK(b)), 0))
-#define        SWITCH_STATE            (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG))
 
        ifp = XFS_IFORK_PTR(ip, whichfork);
        ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t));
        ep = xfs_iext_get_ext(ifp, idx);
        state = 0;
+
+       if (whichfork == XFS_ATTR_FORK)
+               state |= BMAP_ATTRFORK;
+
        /*
         * Check and set flags if this segment has a left neighbor.
         */
-       if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
+       if (idx > 0) {
+               state |= BMAP_LEFT_VALID;
                xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left);
-               STATE_SET(LEFT_DELAY, isnullstartblock(left.br_startblock));
+               if (isnullstartblock(left.br_startblock))
+                       state |= BMAP_LEFT_DELAY;
        }
+
        /*
         * Check and set flags if this segment has a current value.
         * Not true if we're inserting into the "hole" at eof.
         */
-       if (STATE_SET_TEST(RIGHT_VALID,
-                          idx <
-                          ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) {
+       if (idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) {
+               state |= BMAP_RIGHT_VALID;
                xfs_bmbt_get_all(ep, &right);
-               STATE_SET(RIGHT_DELAY, isnullstartblock(right.br_startblock));
+               if (isnullstartblock(right.br_startblock))
+                       state |= BMAP_RIGHT_DELAY;
        }
+
        /*
         * We're inserting a real allocation between "left" and "right".
         * Set the contiguity flags.  Don't let extents get too large.
         */
-       STATE_SET(LEFT_CONTIG,
-               STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) &&
-               left.br_startoff + left.br_blockcount == new->br_startoff &&
-               left.br_startblock + left.br_blockcount == new->br_startblock &&
-               left.br_state == new->br_state &&
-               left.br_blockcount + new->br_blockcount <= MAXEXTLEN);
-       STATE_SET(RIGHT_CONTIG,
-               STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) &&
-               new->br_startoff + new->br_blockcount == right.br_startoff &&
-               new->br_startblock + new->br_blockcount ==
-                   right.br_startblock &&
-               new->br_state == right.br_state &&
-               new->br_blockcount + right.br_blockcount <= MAXEXTLEN &&
-               (!STATE_TEST(LEFT_CONTIG) ||
-                left.br_blockcount + new->br_blockcount +
-                    right.br_blockcount <= MAXEXTLEN));
+       if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) &&
+           left.br_startoff + left.br_blockcount == new->br_startoff &&
+           left.br_startblock + left.br_blockcount == new->br_startblock &&
+           left.br_state == new->br_state &&
+           left.br_blockcount + new->br_blockcount <= MAXEXTLEN)
+               state |= BMAP_LEFT_CONTIG;
+
+       if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) &&
+           new->br_startoff + new->br_blockcount == right.br_startoff &&
+           new->br_startblock + new->br_blockcount == right.br_startblock &&
+           new->br_state == right.br_state &&
+           new->br_blockcount + right.br_blockcount <= MAXEXTLEN &&
+           (!(state & BMAP_LEFT_CONTIG) ||
+            left.br_blockcount + new->br_blockcount +
+            right.br_blockcount <= MAXEXTLEN))
+               state |= BMAP_RIGHT_CONTIG;
 
        error = 0;
        /*
         * Select which case we're in here, and implement it.
         */
-       switch (SWITCH_STATE) {
-
-       case MASK2(LEFT_CONTIG, RIGHT_CONTIG):
+       switch (state & (BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG)) {
+       case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
                /*
                 * New allocation is contiguous with real allocations on the
                 * left and on the right.
                 * Merge all three into a single extent record.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LC|RC", ip, idx - 1,
-                       whichfork);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
                        left.br_blockcount + new->br_blockcount +
                        right.br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1,
-                       whichfork);
-               XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, whichfork);
-               xfs_iext_remove(ifp, idx, 1);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
+               xfs_iext_remove(ip, idx, 1, state);
                ifp->if_lastex = idx - 1;
                XFS_IFORK_NEXT_SET(ip, whichfork,
                        XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
@@ -2173,16 +2027,17 @@ xfs_bmap_add_extent_hole_real(
                        right.br_blockcount;
                break;
 
-       case MASK(LEFT_CONTIG):
+       case BMAP_LEFT_CONTIG:
                /*
                 * New allocation is contiguous with a real allocation
                 * on the left.
                 * Merge the new allocation with the left neighbor.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("LC", ip, idx - 1, whichfork);
+               trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
                        left.br_blockcount + new->br_blockcount);
-               XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1, whichfork);
+               trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_);
+
                ifp->if_lastex = idx - 1;
                if (cur == NULL) {
                        rval = xfs_ilog_fext(whichfork);
@@ -2207,17 +2062,18 @@ xfs_bmap_add_extent_hole_real(
                        new->br_blockcount;
                break;
 
-       case MASK(RIGHT_CONTIG):
+       case BMAP_RIGHT_CONTIG:
                /*
                 * New allocation is contiguous with a real allocation
                 * on the right.
                 * Merge the new allocation with the right neighbor.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("RC", ip, idx, whichfork);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_allf(ep, new->br_startoff, new->br_startblock,
                        new->br_blockcount + right.br_blockcount,
                        right.br_state);
-               XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, whichfork);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+
                ifp->if_lastex = idx;
                if (cur == NULL) {
                        rval = xfs_ilog_fext(whichfork);
@@ -2248,8 +2104,7 @@ xfs_bmap_add_extent_hole_real(
                 * real allocation.
                 * Insert a new entry.
                 */
-               XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL, whichfork);
-               xfs_iext_insert(ifp, idx, 1, new);
+               xfs_iext_insert(ip, idx, 1, new, state);
                ifp->if_lastex = idx;
                XFS_IFORK_NEXT_SET(ip, whichfork,
                        XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
@@ -2283,12 +2138,6 @@ xfs_bmap_add_extent_hole_real(
 done:
        *logflagsp = rval;
        return error;
-#undef MASK
-#undef MASK2
-#undef STATE_SET
-#undef STATE_TEST
-#undef STATE_SET_TEST
-#undef SWITCH_STATE
 }
 
 /*
@@ -3115,8 +2964,13 @@ xfs_bmap_del_extent(
        uint                    qfield; /* quota field to update */
        xfs_filblks_t           temp;   /* for indirect length calculations */
        xfs_filblks_t           temp2;  /* for indirect length calculations */
+       int                     state = 0;
 
        XFS_STATS_INC(xs_del_exlist);
+
+       if (whichfork == XFS_ATTR_FORK)
+               state |= BMAP_ATTRFORK;
+
        mp = ip->i_mount;
        ifp = XFS_IFORK_PTR(ip, whichfork);
        ASSERT((idx >= 0) && (idx < ifp->if_bytes /
@@ -3196,8 +3050,8 @@ xfs_bmap_del_extent(
                /*
                 * Matches the whole extent.  Delete the entry.
                 */
-               XFS_BMAP_TRACE_DELETE("3", ip, idx, 1, whichfork);
-               xfs_iext_remove(ifp, idx, 1);
+               xfs_iext_remove(ip, idx, 1,
+                               whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0);
                ifp->if_lastex = idx;
                if (delay)
                        break;
@@ -3217,7 +3071,7 @@ xfs_bmap_del_extent(
                /*
                 * Deleting the first part of the extent.
                 */
-               XFS_BMAP_TRACE_PRE_UPDATE("2", ip, idx, whichfork);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_startoff(ep, del_endoff);
                temp = got.br_blockcount - del->br_blockcount;
                xfs_bmbt_set_blockcount(ep, temp);
@@ -3226,13 +3080,12 @@ xfs_bmap_del_extent(
                        temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
                                da_old);
                        xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
-                       XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx,
-                               whichfork);
+                       trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                        da_new = temp;
                        break;
                }
                xfs_bmbt_set_startblock(ep, del_endblock);
-               XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx, whichfork);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                if (!cur) {
                        flags |= xfs_ilog_fext(whichfork);
                        break;
@@ -3248,19 +3101,18 @@ xfs_bmap_del_extent(
                 * Deleting the last part of the extent.
                 */
                temp = got.br_blockcount - del->br_blockcount;
-               XFS_BMAP_TRACE_PRE_UPDATE("1", ip, idx, whichfork);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep, temp);
                ifp->if_lastex = idx;
                if (delay) {
                        temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
                                da_old);
                        xfs_bmbt_set_startblock(ep, nullstartblock((int)temp));
-                       XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx,
-                               whichfork);
+                       trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                        da_new = temp;
                        break;
                }
-               XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx, whichfork);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
                if (!cur) {
                        flags |= xfs_ilog_fext(whichfork);
                        break;
@@ -3277,7 +3129,7 @@ xfs_bmap_del_extent(
                 * Deleting the middle of the extent.
                 */
                temp = del->br_startoff - got.br_startoff;
-               XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, whichfork);
+               trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_);
                xfs_bmbt_set_blockcount(ep, temp);
                new.br_startoff = del_endoff;
                temp2 = got_endoff - del_endoff;
@@ -3364,10 +3216,8 @@ xfs_bmap_del_extent(
                                }
                        }
                }
-               XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, whichfork);
-               XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 1, &new, NULL,
-                       whichfork);
-               xfs_iext_insert(ifp, idx + 1, 1, &new);
+               trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_);
+               xfs_iext_insert(ip, idx + 1, 1, &new, state);
                ifp->if_lastex = idx + 1;
                break;
        }
@@ -3687,7 +3537,9 @@ xfs_bmap_local_to_extents(
                xfs_iext_add(ifp, 0, 1);
                ep = xfs_iext_get_ext(ifp, 0);
                xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM);
-               XFS_BMAP_TRACE_POST_UPDATE("new", ip, 0, whichfork);
+               trace_xfs_bmap_post_update(ip, 0,
+                               whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0,
+                               _THIS_IP_);
                XFS_IFORK_NEXT_SET(ip, whichfork, 1);
                ip->i_d.di_nblocks = 1;
                xfs_trans_mod_dquot_byino(tp, ip,
@@ -3800,158 +3652,6 @@ xfs_bmap_search_extents(
        return ep;
 }
 
-
-#ifdef XFS_BMAP_TRACE
-ktrace_t       *xfs_bmap_trace_buf;
-
-/*
- * Add a bmap trace buffer entry.  Base routine for the others.
- */
-STATIC void
-xfs_bmap_trace_addentry(
-       int             opcode,         /* operation */
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry(ies) */
-       xfs_extnum_t    cnt,            /* count of entries, 1 or 2 */
-       xfs_bmbt_rec_host_t *r1,        /* first record */
-       xfs_bmbt_rec_host_t *r2,        /* second record or null */
-       int             whichfork)      /* data or attr fork */
-{
-       xfs_bmbt_rec_host_t tr2;
-
-       ASSERT(cnt == 1 || cnt == 2);
-       ASSERT(r1 != NULL);
-       if (cnt == 1) {
-               ASSERT(r2 == NULL);
-               r2 = &tr2;
-               memset(&tr2, 0, sizeof(tr2));
-       } else
-               ASSERT(r2 != NULL);
-       ktrace_enter(xfs_bmap_trace_buf,
-               (void *)(__psint_t)(opcode | (whichfork << 16)),
-               (void *)fname, (void *)desc, (void *)ip,
-               (void *)(__psint_t)idx,
-               (void *)(__psint_t)cnt,
-               (void *)(__psunsigned_t)(ip->i_ino >> 32),
-               (void *)(__psunsigned_t)(unsigned)ip->i_ino,
-               (void *)(__psunsigned_t)(r1->l0 >> 32),
-               (void *)(__psunsigned_t)(unsigned)(r1->l0),
-               (void *)(__psunsigned_t)(r1->l1 >> 32),
-               (void *)(__psunsigned_t)(unsigned)(r1->l1),
-               (void *)(__psunsigned_t)(r2->l0 >> 32),
-               (void *)(__psunsigned_t)(unsigned)(r2->l0),
-               (void *)(__psunsigned_t)(r2->l1 >> 32),
-               (void *)(__psunsigned_t)(unsigned)(r2->l1)
-               );
-       ASSERT(ip->i_xtrace);
-       ktrace_enter(ip->i_xtrace,
-               (void *)(__psint_t)(opcode | (whichfork << 16)),
-               (void *)fname, (void *)desc, (void *)ip,
-               (void *)(__psint_t)idx,
-               (void *)(__psint_t)cnt,
-               (void *)(__psunsigned_t)(ip->i_ino >> 32),
-               (void *)(__psunsigned_t)(unsigned)ip->i_ino,
-               (void *)(__psunsigned_t)(r1->l0 >> 32),
-               (void *)(__psunsigned_t)(unsigned)(r1->l0),
-               (void *)(__psunsigned_t)(r1->l1 >> 32),
-               (void *)(__psunsigned_t)(unsigned)(r1->l1),
-               (void *)(__psunsigned_t)(r2->l0 >> 32),
-               (void *)(__psunsigned_t)(unsigned)(r2->l0),
-               (void *)(__psunsigned_t)(r2->l1 >> 32),
-               (void *)(__psunsigned_t)(unsigned)(r2->l1)
-               );
-}
-
-/*
- * Add bmap trace entry prior to a call to xfs_iext_remove.
- */
-STATIC void
-xfs_bmap_trace_delete(
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry(entries) deleted */
-       xfs_extnum_t    cnt,            /* count of entries deleted, 1 or 2 */
-       int             whichfork)      /* data or attr fork */
-{
-       xfs_ifork_t     *ifp;           /* inode fork pointer */
-
-       ifp = XFS_IFORK_PTR(ip, whichfork);
-       xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_DELETE, fname, desc, ip, idx,
-               cnt, xfs_iext_get_ext(ifp, idx),
-               cnt == 2 ? xfs_iext_get_ext(ifp, idx + 1) : NULL,
-               whichfork);
-}
-
-/*
- * Add bmap trace entry prior to a call to xfs_iext_insert, or
- * reading in the extents list from the disk (in the btree).
- */
-STATIC void
-xfs_bmap_trace_insert(
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry(entries) inserted */
-       xfs_extnum_t    cnt,            /* count of entries inserted, 1 or 2 */
-       xfs_bmbt_irec_t *r1,            /* inserted record 1 */
-       xfs_bmbt_irec_t *r2,            /* inserted record 2 or null */
-       int             whichfork)      /* data or attr fork */
-{
-       xfs_bmbt_rec_host_t tr1;        /* compressed record 1 */
-       xfs_bmbt_rec_host_t tr2;        /* compressed record 2 if needed */
-
-       xfs_bmbt_set_all(&tr1, r1);
-       if (cnt == 2) {
-               ASSERT(r2 != NULL);
-               xfs_bmbt_set_all(&tr2, r2);
-       } else {
-               ASSERT(cnt == 1);
-               ASSERT(r2 == NULL);
-       }
-       xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_INSERT, fname, desc, ip, idx,
-               cnt, &tr1, cnt == 2 ? &tr2 : NULL, whichfork);
-}
-
-/*
- * Add bmap trace entry after updating an extent record in place.
- */
-STATIC void
-xfs_bmap_trace_post_update(
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry updated */
-       int             whichfork)      /* data or attr fork */
-{
-       xfs_ifork_t     *ifp;           /* inode fork pointer */
-
-       ifp = XFS_IFORK_PTR(ip, whichfork);
-       xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_POST_UP, fname, desc, ip, idx,
-               1, xfs_iext_get_ext(ifp, idx), NULL, whichfork);
-}
-
-/*
- * Add bmap trace entry prior to updating an extent record in place.
- */
-STATIC void
-xfs_bmap_trace_pre_update(
-       const char      *fname,         /* function name */
-       char            *desc,          /* operation description */
-       xfs_inode_t     *ip,            /* incore inode pointer */
-       xfs_extnum_t    idx,            /* index of entry to be updated */
-       int             whichfork)      /* data or attr fork */
-{
-       xfs_ifork_t     *ifp;           /* inode fork pointer */
-
-       ifp = XFS_IFORK_PTR(ip, whichfork);
-       xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_PRE_UP, fname, desc, ip, idx, 1,
-               xfs_iext_get_ext(ifp, idx), NULL, whichfork);
-}
-#endif /* XFS_BMAP_TRACE */
-
 /*
  * Compute the worst-case number of indirect blocks that will be used
  * for ip's delayed extent of length "len".
@@ -3983,37 +3683,6 @@ xfs_bmap_worst_indlen(
        return rval;
 }
 
-#if defined(XFS_RW_TRACE)
-STATIC void
-xfs_bunmap_trace(
-       xfs_inode_t             *ip,
-       xfs_fileoff_t           bno,
-       xfs_filblks_t           len,
-       int                     flags,
-       inst_t                  *ra)
-{
-       if (ip->i_rwtrace == NULL)
-               return;
-       ktrace_enter(ip->i_rwtrace,
-               (void *)(__psint_t)XFS_BUNMAP,
-               (void *)ip,
-               (void *)(__psint_t)((ip->i_d.di_size >> 32) & 0xffffffff),
-               (void *)(__psint_t)(ip->i_d.di_size & 0xffffffff),
-               (void *)(__psint_t)(((xfs_dfiloff_t)bno >> 32) & 0xffffffff),
-               (void *)(__psint_t)((xfs_dfiloff_t)bno & 0xffffffff),
-               (void *)(__psint_t)len,
-               (void *)(__psint_t)flags,
-               (void *)(unsigned long)current_cpu(),
-               (void *)ra,
-               (void *)0,
-               (void *)0,
-               (void *)0,
-               (void *)0,
-               (void *)0,
-               (void *)0);
-}
-#endif
-
 /*
  * Convert inode from non-attributed to attributed.
  * Must not be in a transaction, ip must not be locked.
@@ -4702,34 +4371,30 @@ error0:
        return XFS_ERROR(EFSCORRUPTED);
 }
 
-#ifdef XFS_BMAP_TRACE
+#ifdef DEBUG
 /*
  * Add bmap trace insert entries for all the contents of the extent records.
  */
 void
 xfs_bmap_trace_exlist(
-       const char      *fname,         /* function name */
        xfs_inode_t     *ip,            /* incore inode pointer */
        xfs_extnum_t    cnt,            /* count of entries in the list */
-       int             whichfork)      /* data or attr fork */
+       int             whichfork,      /* data or attr fork */
+       unsigned long   caller_ip)
 {
-       xfs_bmbt_rec_host_t *ep;        /* current extent record */
        xfs_extnum_t    idx;            /* extent record index */
        xfs_ifork_t     *ifp;           /* inode fork pointer */
-       xfs_bmbt_irec_t s;              /* file extent record */
+       int             state = 0;
+
+       if (whichfork == XFS_ATTR_FORK)
+               state |= BMAP_ATTRFORK;
 
        ifp = XFS_IFORK_PTR(ip, whichfork);
        ASSERT(cnt == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)));
-       for (idx = 0; idx < cnt; idx++) {
-               ep = xfs_iext_get_ext(ifp, idx);
-               xfs_bmbt_get_all(ep, &s);
-               XFS_BMAP_TRACE_INSERT("exlist", ip, idx, 1, &s, NULL,
-                       whichfork);
-       }
+       for (idx = 0; idx < cnt; idx++)
+               trace_xfs_extlist(ip, idx, whichfork, caller_ip);
 }
-#endif
 
-#ifdef DEBUG
 /*
  * Validate that the bmbt_irecs being returned from bmapi are valid
  * given the callers original parameters.  Specifically check the
@@ -5478,7 +5143,8 @@ xfs_bunmapi(
        int                     rsvd;           /* OK to allocate reserved blocks */
        xfs_fsblock_t           sum;
 
-       xfs_bunmap_trace(ip, bno, len, flags, (inst_t *)__return_address);
+       trace_xfs_bunmap(ip, bno, len, flags, _RET_IP_);
+
        whichfork = (flags & XFS_BMAPI_ATTRFORK) ?
                XFS_ATTR_FORK : XFS_DATA_FORK;
        ifp = XFS_IFORK_PTR(ip, whichfork);
index 56f62d2edc35b884ed26067436a791a75c9f0a52..419dafb9d87d4a2a79b440c30a54e672a571b55f 100644 (file)
@@ -95,6 +95,21 @@ typedef      struct xfs_bmap_free
                                        /* need write cache flushing and no */
                                        /* additional allocation alignments */
 
+#define XFS_BMAPI_FLAGS \
+       { XFS_BMAPI_WRITE,      "WRITE" }, \
+       { XFS_BMAPI_DELAY,      "DELAY" }, \
+       { XFS_BMAPI_ENTIRE,     "ENTIRE" }, \
+       { XFS_BMAPI_METADATA,   "METADATA" }, \
+       { XFS_BMAPI_EXACT,      "EXACT" }, \
+       { XFS_BMAPI_ATTRFORK,   "ATTRFORK" }, \
+       { XFS_BMAPI_ASYNC,      "ASYNC" }, \
+       { XFS_BMAPI_RSVBLOCKS,  "RSVBLOCKS" }, \
+       { XFS_BMAPI_PREALLOC,   "PREALLOC" }, \
+       { XFS_BMAPI_IGSTATE,    "IGSTATE" }, \
+       { XFS_BMAPI_CONTIG,     "CONTIG" }, \
+       { XFS_BMAPI_CONVERT,    "CONVERT" }
+
+
 static inline int xfs_bmapi_aflag(int w)
 {
        return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0);
@@ -135,36 +150,43 @@ typedef struct xfs_bmalloca {
        char                    conv;   /* overwriting unwritten extents */
 } xfs_bmalloca_t;
 
-#if defined(__KERNEL__) && defined(XFS_BMAP_TRACE)
 /*
- * Trace operations for bmap extent tracing
+ * Flags for xfs_bmap_add_extent*.
  */
-#define        XFS_BMAP_KTRACE_DELETE  1
-#define        XFS_BMAP_KTRACE_INSERT  2
-#define        XFS_BMAP_KTRACE_PRE_UP  3
-#define        XFS_BMAP_KTRACE_POST_UP 4
-
-#define        XFS_BMAP_TRACE_SIZE     4096    /* size of global trace buffer */
-#define        XFS_BMAP_KTRACE_SIZE    32      /* size of per-inode trace buffer */
-extern ktrace_t        *xfs_bmap_trace_buf;
+#define BMAP_LEFT_CONTIG       (1 << 0)
+#define BMAP_RIGHT_CONTIG      (1 << 1)
+#define BMAP_LEFT_FILLING      (1 << 2)
+#define BMAP_RIGHT_FILLING     (1 << 3)
+#define BMAP_LEFT_DELAY                (1 << 4)
+#define BMAP_RIGHT_DELAY       (1 << 5)
+#define BMAP_LEFT_VALID                (1 << 6)
+#define BMAP_RIGHT_VALID       (1 << 7)
+#define BMAP_ATTRFORK          (1 << 8)
+
+#define XFS_BMAP_EXT_FLAGS \
+       { BMAP_LEFT_CONTIG,     "LC" }, \
+       { BMAP_RIGHT_CONTIG,    "RC" }, \
+       { BMAP_LEFT_FILLING,    "LF" }, \
+       { BMAP_RIGHT_FILLING,   "RF" }, \
+       { BMAP_ATTRFORK,        "ATTR" }
 
 /*
  * Add bmap trace insert entries for all the contents of the extent list.
+ *
+ * Quite excessive tracing.  Only do this for debug builds.
  */
+#if defined(__KERNEL) && defined(DEBUG)
 void
 xfs_bmap_trace_exlist(
-       const char              *fname,         /* function name */
        struct xfs_inode        *ip,            /* incore inode pointer */
        xfs_extnum_t            cnt,            /* count of entries in list */
-       int                     whichfork);     /* data or attr fork */
+       int                     whichfork,
+       unsigned long           caller_ip);     /* data or attr fork */
 #define        XFS_BMAP_TRACE_EXLIST(ip,c,w)   \
-       xfs_bmap_trace_exlist(__func__,ip,c,w)
-
-#else  /* __KERNEL__ && XFS_BMAP_TRACE */
-
+       xfs_bmap_trace_exlist(ip,c,w, _THIS_IP_)
+#else
 #define        XFS_BMAP_TRACE_EXLIST(ip,c,w)
-
-#endif /* __KERNEL__ && XFS_BMAP_TRACE */
+#endif
 
 /*
  * Convert inode from non-attributed to attributed.
index 6f5ccede63f9868e7d359251f457c4f155f74407..38751d5fac6fdf5486568728ed5c11c26dd4a067 100644 (file)
@@ -768,12 +768,6 @@ xfs_bmbt_trace_enter(
                (void *)a0, (void *)a1, (void *)a2, (void *)a3,
                (void *)a4, (void *)a5, (void *)a6, (void *)a7,
                (void *)a8, (void *)a9, (void *)a10);
-       ktrace_enter(ip->i_btrace,
-               (void *)((__psint_t)type | (whichfork << 8) | (line << 16)),
-               (void *)func, (void *)s, (void *)ip, (void *)cur,
-               (void *)a0, (void *)a1, (void *)a2, (void *)a3,
-               (void *)a4, (void *)a5, (void *)a6, (void *)a7,
-               (void *)a8, (void *)a9, (void *)a10);
 }
 
 STATIC void
index 5549d495947f4d3e9949c2c15fbc2982282ebe35..cf07ca7c22e73e70340da1d061e09b33c1234f4f 100644 (file)
@@ -46,20 +46,12 @@ typedef struct xfs_bmdr_block {
 #define BMBT_STARTBLOCK_BITLEN 52
 #define BMBT_BLOCKCOUNT_BITLEN 21
 
-
-#define BMBT_USE_64    1
-
-typedef struct xfs_bmbt_rec_32
-{
-       __uint32_t              l0, l1, l2, l3;
-} xfs_bmbt_rec_32_t;
-typedef struct xfs_bmbt_rec_64
-{
+typedef struct xfs_bmbt_rec {
        __be64                  l0, l1;
-} xfs_bmbt_rec_64_t;
+} xfs_bmbt_rec_t;
 
 typedef __uint64_t     xfs_bmbt_rec_base_t;    /* use this for casts */
-typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t;
+typedef xfs_bmbt_rec_t xfs_bmdr_rec_t;
 
 typedef struct xfs_bmbt_rec_host {
        __uint64_t              l0, l1;
index 52b5f14d0c32ef4573074b4e5962d5055aaec643..36a0992dd66991d1cd9c1908398eb7ea42b15c46 100644 (file)
@@ -39,6 +39,7 @@
 #include "xfs_btree_trace.h"
 #include "xfs_ialloc.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 /*
  * Cursor allocation zone.
@@ -81,7 +82,7 @@ xfs_btree_check_lblock(
                        XFS_ERRTAG_BTREE_CHECK_LBLOCK,
                        XFS_RANDOM_BTREE_CHECK_LBLOCK))) {
                if (bp)
-                       xfs_buftrace("LBTREE ERROR", bp);
+                       trace_xfs_btree_corrupt(bp, _RET_IP_);
                XFS_ERROR_REPORT("xfs_btree_check_lblock", XFS_ERRLEVEL_LOW,
                                 mp);
                return XFS_ERROR(EFSCORRUPTED);
@@ -119,7 +120,7 @@ xfs_btree_check_sblock(
                        XFS_ERRTAG_BTREE_CHECK_SBLOCK,
                        XFS_RANDOM_BTREE_CHECK_SBLOCK))) {
                if (bp)
-                       xfs_buftrace("SBTREE ERROR", bp);
+                       trace_xfs_btree_corrupt(bp, _RET_IP_);
                XFS_CORRUPTION_ERROR("xfs_btree_check_sblock",
                        XFS_ERRLEVEL_LOW, cur->bc_mp, block);
                return XFS_ERROR(EFSCORRUPTED);
index b3f5eb3c3c6c009c7fb23214e983a6e377603e86..2d8a309873ea619c2fa616639d2e43ab215490b4 100644 (file)
@@ -58,8 +58,6 @@ void xfs_btree_trace_argbi(const char *, struct xfs_btree_cur *,
                struct xfs_buf *, int, int);
 void xfs_btree_trace_argbii(const char *, struct xfs_btree_cur *,
                struct xfs_buf *, int, int, int);
-void xfs_btree_trace_argfffi(const char *, struct xfs_btree_cur *,
-               xfs_dfiloff_t, xfs_dfsbno_t, xfs_dfilblks_t, int, int);
 void xfs_btree_trace_argi(const char *, struct xfs_btree_cur *, int, int);
 void xfs_btree_trace_argipk(const char *, struct xfs_btree_cur *, int,
                union xfs_btree_ptr, union xfs_btree_key *, int);
@@ -71,24 +69,10 @@ void xfs_btree_trace_argr(const char *, struct xfs_btree_cur *,
                union xfs_btree_rec *, int);
 void xfs_btree_trace_cursor(const char *, struct xfs_btree_cur *, int, int);
 
-
-#define XFS_ALLOCBT_TRACE_SIZE 4096    /* size of global trace buffer */
-extern ktrace_t        *xfs_allocbt_trace_buf;
-
-#define XFS_INOBT_TRACE_SIZE   4096    /* size of global trace buffer */
-extern ktrace_t        *xfs_inobt_trace_buf;
-
-#define XFS_BMBT_TRACE_SIZE    4096    /* size of global trace buffer */
-#define XFS_BMBT_KTRACE_SIZE   32      /* size of per-inode trace buffer */
-extern ktrace_t        *xfs_bmbt_trace_buf;
-
-
 #define        XFS_BTREE_TRACE_ARGBI(c, b, i)  \
        xfs_btree_trace_argbi(__func__, c, b, i, __LINE__)
 #define        XFS_BTREE_TRACE_ARGBII(c, b, i, j)      \
        xfs_btree_trace_argbii(__func__, c, b, i, j, __LINE__)
-#define        XFS_BTREE_TRACE_ARGFFFI(c, o, b, i, j)  \
-       xfs_btree_trace_argfffi(__func__, c, o, b, i, j, __LINE__)
 #define        XFS_BTREE_TRACE_ARGI(c, i)      \
        xfs_btree_trace_argi(__func__, c, i, __LINE__)
 #define        XFS_BTREE_TRACE_ARGIPK(c, i, p, k)      \
@@ -104,7 +88,6 @@ extern ktrace_t      *xfs_bmbt_trace_buf;
 #else
 #define        XFS_BTREE_TRACE_ARGBI(c, b, i)
 #define        XFS_BTREE_TRACE_ARGBII(c, b, i, j)
-#define        XFS_BTREE_TRACE_ARGFFFI(c, o, b, i, j)
 #define        XFS_BTREE_TRACE_ARGI(c, i)
 #define        XFS_BTREE_TRACE_ARGIPK(c, i, p, s)
 #define        XFS_BTREE_TRACE_ARGIPR(c, i, p, r)
index 92af4098c7e848043b74443d04d29d32597fd46b..a30f7e9eb2b96df6ab35aeb349430d4ddcc3a77a 100644 (file)
@@ -29,6 +29,7 @@
 #include "xfs_buf_item.h"
 #include "xfs_trans_priv.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 
 kmem_zone_t    *xfs_buf_item_zone;
@@ -164,7 +165,7 @@ xfs_buf_item_size(
                 * is the buf log format structure with the
                 * cancel flag in it.
                 */
-               xfs_buf_item_trace("SIZE STALE", bip);
+               trace_xfs_buf_item_size_stale(bip);
                ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
                return 1;
        }
@@ -206,7 +207,7 @@ xfs_buf_item_size(
                }
        }
 
-       xfs_buf_item_trace("SIZE NORM", bip);
+       trace_xfs_buf_item_size(bip);
        return nvecs;
 }
 
@@ -259,7 +260,7 @@ xfs_buf_item_format(
                 * is the buf log format structure with the
                 * cancel flag in it.
                 */
-               xfs_buf_item_trace("FORMAT STALE", bip);
+               trace_xfs_buf_item_format_stale(bip);
                ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
                bip->bli_format.blf_size = nvecs;
                return;
@@ -335,7 +336,7 @@ xfs_buf_item_format(
        /*
         * Check to make sure everything is consistent.
         */
-       xfs_buf_item_trace("FORMAT NORM", bip);
+       trace_xfs_buf_item_format(bip);
        xfs_buf_item_log_check(bip);
 }
 
@@ -355,8 +356,7 @@ xfs_buf_item_pin(
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
        ASSERT((bip->bli_flags & XFS_BLI_LOGGED) ||
               (bip->bli_flags & XFS_BLI_STALE));
-       xfs_buf_item_trace("PIN", bip);
-       xfs_buftrace("XFS_PIN", bp);
+       trace_xfs_buf_item_pin(bip);
        xfs_bpin(bp);
 }
 
@@ -383,8 +383,7 @@ xfs_buf_item_unpin(
        ASSERT(bp != NULL);
        ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip);
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
-       xfs_buf_item_trace("UNPIN", bip);
-       xfs_buftrace("XFS_UNPIN", bp);
+       trace_xfs_buf_item_unpin(bip);
 
        freed = atomic_dec_and_test(&bip->bli_refcount);
        ailp = bip->bli_item.li_ailp;
@@ -395,8 +394,8 @@ xfs_buf_item_unpin(
                ASSERT(!(XFS_BUF_ISDELAYWRITE(bp)));
                ASSERT(XFS_BUF_ISSTALE(bp));
                ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
-               xfs_buf_item_trace("UNPIN STALE", bip);
-               xfs_buftrace("XFS_UNPIN STALE", bp);
+               trace_xfs_buf_item_unpin_stale(bip);
+
                /*
                 * If we get called here because of an IO error, we may
                 * or may not have the item on the AIL. xfs_trans_ail_delete()
@@ -440,8 +439,8 @@ xfs_buf_item_unpin_remove(
        if ((atomic_read(&bip->bli_refcount) == 1) &&
            (bip->bli_flags & XFS_BLI_STALE)) {
                ASSERT(XFS_BUF_VALUSEMA(bip->bli_buf) <= 0);
-               xfs_buf_item_trace("UNPIN REMOVE", bip);
-               xfs_buftrace("XFS_UNPIN_REMOVE", bp);
+               trace_xfs_buf_item_unpin_stale(bip);
+
                /*
                 * yes -- clear the xaction descriptor in-use flag
                 * and free the chunk if required.  We can safely
@@ -495,7 +494,7 @@ xfs_buf_item_trylock(
        XFS_BUF_HOLD(bp);
 
        ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
-       xfs_buf_item_trace("TRYLOCK SUCCESS", bip);
+       trace_xfs_buf_item_trylock(bip);
        return XFS_ITEM_SUCCESS;
 }
 
@@ -524,7 +523,6 @@ xfs_buf_item_unlock(
        uint            hold;
 
        bp = bip->bli_buf;
-       xfs_buftrace("XFS_UNLOCK", bp);
 
        /*
         * Clear the buffer's association with this transaction.
@@ -547,7 +545,7 @@ xfs_buf_item_unlock(
         */
        if (bip->bli_flags & XFS_BLI_STALE) {
                bip->bli_flags &= ~XFS_BLI_LOGGED;
-               xfs_buf_item_trace("UNLOCK STALE", bip);
+               trace_xfs_buf_item_unlock_stale(bip);
                ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
                if (!aborted)
                        return;
@@ -574,7 +572,7 @@ xfs_buf_item_unlock(
         * release the buffer at the end of this routine.
         */
        hold = bip->bli_flags & XFS_BLI_HOLD;
-       xfs_buf_item_trace("UNLOCK", bip);
+       trace_xfs_buf_item_unlock(bip);
 
        /*
         * If the buf item isn't tracking any data, free it.
@@ -618,7 +616,8 @@ xfs_buf_item_committed(
        xfs_buf_log_item_t      *bip,
        xfs_lsn_t               lsn)
 {
-       xfs_buf_item_trace("COMMITTED", bip);
+       trace_xfs_buf_item_committed(bip);
+
        if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
            (bip->bli_item.li_lsn != 0)) {
                return bip->bli_item.li_lsn;
@@ -640,7 +639,7 @@ xfs_buf_item_push(
        xfs_buf_t       *bp;
 
        ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
-       xfs_buf_item_trace("PUSH", bip);
+       trace_xfs_buf_item_push(bip);
 
        bp = bip->bli_buf;
 
@@ -738,9 +737,6 @@ xfs_buf_item_init(
        bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp);
        bip->bli_format.blf_len = (ushort)BTOBB(XFS_BUF_COUNT(bp));
        bip->bli_format.blf_map_size = map_size;
-#ifdef XFS_BLI_TRACE
-       bip->bli_trace = ktrace_alloc(XFS_BLI_TRACE_SIZE, KM_NOFS);
-#endif
 
 #ifdef XFS_TRANS_DEBUG
        /*
@@ -878,9 +874,6 @@ xfs_buf_item_free(
        kmem_free(bip->bli_logged);
 #endif /* XFS_TRANS_DEBUG */
 
-#ifdef XFS_BLI_TRACE
-       ktrace_free(bip->bli_trace);
-#endif
        kmem_zone_free(xfs_buf_item_zone, bip);
 }
 
@@ -897,7 +890,8 @@ xfs_buf_item_relse(
 {
        xfs_buf_log_item_t      *bip;
 
-       xfs_buftrace("XFS_RELSE", bp);
+       trace_xfs_buf_item_relse(bp, _RET_IP_);
+
        bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*);
        XFS_BUF_SET_FSPRIVATE(bp, bip->bli_item.li_bio_list);
        if ((XFS_BUF_FSPRIVATE(bp, void *) == NULL) &&
@@ -994,7 +988,7 @@ xfs_buf_iodone_callbacks(
                if (XFS_FORCED_SHUTDOWN(mp)) {
                        ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp);
                        XFS_BUF_SUPER_STALE(bp);
-                       xfs_buftrace("BUF_IODONE_CB", bp);
+                       trace_xfs_buf_item_iodone(bp, _RET_IP_);
                        xfs_buf_do_callbacks(bp, lip);
                        XFS_BUF_SET_FSPRIVATE(bp, NULL);
                        XFS_BUF_CLR_IODONE_FUNC(bp);
@@ -1030,7 +1024,7 @@ xfs_buf_iodone_callbacks(
                                XFS_BUF_SET_START(bp);
                        }
                        ASSERT(XFS_BUF_IODONE_FUNC(bp));
-                       xfs_buftrace("BUF_IODONE ASYNC", bp);
+                       trace_xfs_buf_item_iodone_async(bp, _RET_IP_);
                        xfs_buf_relse(bp);
                } else {
                        /*
@@ -1053,9 +1047,7 @@ xfs_buf_iodone_callbacks(
                }
                return;
        }
-#ifdef XFSERRORDEBUG
-       xfs_buftrace("XFS BUFCB NOERR", bp);
-#endif
+
        xfs_buf_do_callbacks(bp, lip);
        XFS_BUF_SET_FSPRIVATE(bp, NULL);
        XFS_BUF_CLR_IODONE_FUNC(bp);
@@ -1081,7 +1073,9 @@ xfs_buf_error_relse(
        XFS_BUF_DONE(bp);
        XFS_BUF_UNDELAYWRITE(bp);
        XFS_BUF_ERROR(bp,0);
-       xfs_buftrace("BUF_ERROR_RELSE", bp);
+
+       trace_xfs_buf_error_relse(bp, _RET_IP_);
+
        if (! XFS_FORCED_SHUTDOWN(mp))
                xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
        /*
@@ -1128,34 +1122,3 @@ xfs_buf_iodone(
        xfs_trans_ail_delete(ailp, (xfs_log_item_t *)bip);
        xfs_buf_item_free(bip);
 }
-
-#if defined(XFS_BLI_TRACE)
-void
-xfs_buf_item_trace(
-       char                    *id,
-       xfs_buf_log_item_t      *bip)
-{
-       xfs_buf_t               *bp;
-       ASSERT(bip->bli_trace != NULL);
-
-       bp = bip->bli_buf;
-       ktrace_enter(bip->bli_trace,
-                    (void *)id,
-                    (void *)bip->bli_buf,
-                    (void *)((unsigned long)bip->bli_flags),
-                    (void *)((unsigned long)bip->bli_recur),
-                    (void *)((unsigned long)atomic_read(&bip->bli_refcount)),
-                    (void *)((unsigned long)
-                               (0xFFFFFFFF & XFS_BUF_ADDR(bp) >> 32)),
-                    (void *)((unsigned long)(0xFFFFFFFF & XFS_BUF_ADDR(bp))),
-                    (void *)((unsigned long)XFS_BUF_COUNT(bp)),
-                    (void *)((unsigned long)XFS_BUF_BFLAGS(bp)),
-                    XFS_BUF_FSPRIVATE(bp, void *),
-                    XFS_BUF_FSPRIVATE2(bp, void *),
-                    (void *)(unsigned long)XFS_BUF_ISPINNED(bp),
-                    (void *)XFS_BUF_IODONE_FUNC(bp),
-                    (void *)((unsigned long)(XFS_BUF_VALUSEMA(bp))),
-                    (void *)bip->bli_item.li_desc,
-                    (void *)((unsigned long)bip->bli_item.li_flags));
-}
-#endif /* XFS_BLI_TRACE */
index 5a41c348bb1ce7f6b2d7e55a7d096ae17ebc4ba8..217f34af00cbe563aefe229116261416193e3b0f 100644 (file)
@@ -70,22 +70,21 @@ typedef struct xfs_buf_log_format_t {
 #define        XFS_BLI_INODE_ALLOC_BUF 0x10
 #define XFS_BLI_STALE_INODE    0x20
 
+#define XFS_BLI_FLAGS \
+       { XFS_BLI_HOLD,         "HOLD" }, \
+       { XFS_BLI_DIRTY,        "DIRTY" }, \
+       { XFS_BLI_STALE,        "STALE" }, \
+       { XFS_BLI_LOGGED,       "LOGGED" }, \
+       { XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \
+       { XFS_BLI_STALE_INODE,  "STALE_INODE" }
+
 
 #ifdef __KERNEL__
 
 struct xfs_buf;
-struct ktrace;
 struct xfs_mount;
 struct xfs_buf_log_item;
 
-#if defined(XFS_BLI_TRACE)
-#define        XFS_BLI_TRACE_SIZE      32
-
-void   xfs_buf_item_trace(char *, struct xfs_buf_log_item *);
-#else
-#define        xfs_buf_item_trace(id, bip)
-#endif
-
 /*
  * This is the in core log item structure used to track information
  * needed to log buffers.  It tracks how many times the lock has been
@@ -97,9 +96,6 @@ typedef struct xfs_buf_log_item {
        unsigned int            bli_flags;      /* misc flags */
        unsigned int            bli_recur;      /* lock recursion count */
        atomic_t                bli_refcount;   /* cnt of tp refs */
-#ifdef XFS_BLI_TRACE
-       struct ktrace           *bli_trace;     /* event trace buf */
-#endif
 #ifdef XFS_TRANS_DEBUG
        char                    *bli_orig;      /* original buffer copy */
        char                    *bli_logged;    /* bytes logged (bitmap) */
index 2847bbc1c534db4b9e2b3bd49645773678d15e07..c0c8869115b1644c1512485464fb383a830faf8c 100644 (file)
@@ -46,6 +46,7 @@
 #include "xfs_dir2_block.h"
 #include "xfs_dir2_node.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 /*
  * xfs_da_btree.c
@@ -2107,7 +2108,7 @@ xfs_da_do_buf(
                                   (be32_to_cpu(free->hdr.magic) != XFS_DIR2_FREE_MAGIC),
                                mp, XFS_ERRTAG_DA_READ_BUF,
                                XFS_RANDOM_DA_READ_BUF))) {
-                       xfs_buftrace("DA READ ERROR", rbp->bps[0]);
+                       trace_xfs_da_btree_corrupt(rbp->bps[0], _RET_IP_);
                        XFS_CORRUPTION_ERROR("xfs_da_do_buf(2)",
                                             XFS_ERRLEVEL_LOW, mp, info);
                        error = XFS_ERROR(EFSCORRUPTED);
index 8c536167bf754b030dcd333ed2c06c5a72c887a6..30cd08f56a3a0c7cce557a5535b6fcccceaa6239 100644 (file)
@@ -125,6 +125,13 @@ typedef struct xfs_da_args {
 #define XFS_DA_OP_OKNOENT      0x0008  /* lookup/add op, ENOENT ok, else die */
 #define XFS_DA_OP_CILOOKUP     0x0010  /* lookup to return CI name if found */
 
+#define XFS_DA_OP_FLAGS \
+       { XFS_DA_OP_JUSTCHECK,  "JUSTCHECK" }, \
+       { XFS_DA_OP_RENAME,     "RENAME" }, \
+       { XFS_DA_OP_ADDNAME,    "ADDNAME" }, \
+       { XFS_DA_OP_OKNOENT,    "OKNOENT" }, \
+       { XFS_DA_OP_CILOOKUP,   "CILOOKUP" }
+
 /*
  * Structure to describe buffer(s) for a block.
  * This is needed in the directory version 2 format case, when
index ab89a7e94a0fd4b861114f656b99e5fcf0355a14..d1483a4f71b8d2cb4adac62e88945a1dcc273a72 100644 (file)
@@ -43,6 +43,7 @@
 #include "xfs_error.h"
 #include "xfs_rw.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 /*
  * Syssgi interface for swapext
@@ -168,7 +169,6 @@ xfs_swap_extents(
        }
 
        if (VN_CACHED(VFS_I(tip)) != 0) {
-               xfs_inval_cached_trace(tip, 0, -1, 0, -1);
                error = xfs_flushinval_pages(tip, 0, -1,
                                FI_REMAPF_LOCKED);
                if (error)
index bb1d58eb398238e5e485a8f0bad9ce51ba141e63..93634a7e90e9c84ad1319e0e862e7c3e40839678 100644 (file)
@@ -40,9 +40,9 @@
 #include "xfs_dir2_leaf.h"
 #include "xfs_dir2_block.h"
 #include "xfs_dir2_node.h"
-#include "xfs_dir2_trace.h"
 #include "xfs_error.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 struct xfs_name xfs_name_dotdot = {"..", 2};
 
@@ -525,7 +525,8 @@ xfs_dir2_grow_inode(
        xfs_trans_t     *tp;
        xfs_drfsbno_t   nblks;
 
-       xfs_dir2_trace_args_s("grow_inode", args, space);
+       trace_xfs_dir2_grow_inode(args, space);
+
        dp = args->dp;
        tp = args->trans;
        mp = dp->i_mount;
@@ -703,7 +704,8 @@ xfs_dir2_shrink_inode(
        xfs_mount_t     *mp;
        xfs_trans_t     *tp;
 
-       xfs_dir2_trace_args_db("shrink_inode", args, db, bp);
+       trace_xfs_dir2_shrink_inode(args, db);
+
        dp = args->dp;
        mp = dp->i_mount;
        tp = args->trans;
index ab52e9e1c1eedd9c115161a4f786bf37d5bcff66..ddc4ecc7807fdabf748b621557bece3cfc22c10a 100644 (file)
@@ -36,8 +36,8 @@
 #include "xfs_dir2_data.h"
 #include "xfs_dir2_leaf.h"
 #include "xfs_dir2_block.h"
-#include "xfs_dir2_trace.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 /*
  * Local function prototypes.
@@ -94,7 +94,8 @@ xfs_dir2_block_addname(
        __be16                  *tagp;          /* pointer to tag value */
        xfs_trans_t             *tp;            /* transaction structure */
 
-       xfs_dir2_trace_args("block_addname", args);
+       trace_xfs_dir2_block_addname(args);
+
        dp = args->dp;
        tp = args->trans;
        mp = dp->i_mount;
@@ -590,7 +591,8 @@ xfs_dir2_block_lookup(
        int                     error;          /* error return value */
        xfs_mount_t             *mp;            /* filesystem mount point */
 
-       xfs_dir2_trace_args("block_lookup", args);
+       trace_xfs_dir2_block_lookup(args);
+
        /*
         * Get the buffer, look up the entry.
         * If not found (ENOENT) then return, have no buffer.
@@ -747,7 +749,8 @@ xfs_dir2_block_removename(
        int                     size;           /* shortform size */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args("block_removename", args);
+       trace_xfs_dir2_block_removename(args);
+
        /*
         * Look up the entry in the block.  Gets the buffer and entry index.
         * It will always be there, the vnodeops level does a lookup first.
@@ -823,7 +826,8 @@ xfs_dir2_block_replace(
        int                     error;          /* error return value */
        xfs_mount_t             *mp;            /* filesystem mount point */
 
-       xfs_dir2_trace_args("block_replace", args);
+       trace_xfs_dir2_block_replace(args);
+
        /*
         * Lookup the entry in the directory.  Get buffer and entry index.
         * This will always succeed since the caller has already done a lookup.
@@ -897,7 +901,8 @@ xfs_dir2_leaf_to_block(
        int                     to;             /* block/leaf to index */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args_bb("leaf_to_block", args, lbp, dbp);
+       trace_xfs_dir2_leaf_to_block(args);
+
        dp = args->dp;
        tp = args->trans;
        mp = dp->i_mount;
@@ -1044,7 +1049,8 @@ xfs_dir2_sf_to_block(
        xfs_trans_t             *tp;            /* transaction pointer */
        struct xfs_name         name;
 
-       xfs_dir2_trace_args("sf_to_block", args);
+       trace_xfs_dir2_sf_to_block(args);
+
        dp = args->dp;
        tp = args->trans;
        mp = dp->i_mount;
index 41ad537c49e983a8ec052bfe38c68814f9a0d796..29f484c11b3ac11f5f9f89d7e54cf5e332aab2f6 100644 (file)
@@ -38,8 +38,8 @@
 #include "xfs_dir2_leaf.h"
 #include "xfs_dir2_block.h"
 #include "xfs_dir2_node.h"
-#include "xfs_dir2_trace.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 /*
  * Local function declarations.
@@ -80,7 +80,8 @@ xfs_dir2_block_to_leaf(
        int                     needscan;       /* need to rescan bestfree */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args_b("block_to_leaf", args, dbp);
+       trace_xfs_dir2_block_to_leaf(args);
+
        dp = args->dp;
        mp = dp->i_mount;
        tp = args->trans;
@@ -188,7 +189,8 @@ xfs_dir2_leaf_addname(
        xfs_trans_t             *tp;            /* transaction pointer */
        xfs_dir2_db_t           use_block;      /* data block number */
 
-       xfs_dir2_trace_args("leaf_addname", args);
+       trace_xfs_dir2_leaf_addname(args);
+
        dp = args->dp;
        tp = args->trans;
        mp = dp->i_mount;
@@ -1266,7 +1268,8 @@ xfs_dir2_leaf_lookup(
        xfs_dir2_leaf_entry_t   *lep;           /* leaf entry */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args("leaf_lookup", args);
+       trace_xfs_dir2_leaf_lookup(args);
+
        /*
         * Look up name in the leaf block, returning both buffers and index.
         */
@@ -1454,7 +1457,8 @@ xfs_dir2_leaf_removename(
        xfs_dir2_data_off_t     oldbest;        /* old value of best free */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args("leaf_removename", args);
+       trace_xfs_dir2_leaf_removename(args);
+
        /*
         * Lookup the leaf entry, get the leaf and data blocks read in.
         */
@@ -1586,7 +1590,8 @@ xfs_dir2_leaf_replace(
        xfs_dir2_leaf_entry_t   *lep;           /* leaf entry */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args("leaf_replace", args);
+       trace_xfs_dir2_leaf_replace(args);
+
        /*
         * Look up the entry.
         */
@@ -1766,7 +1771,9 @@ xfs_dir2_node_to_leaf(
        if (state->path.active > 1)
                return 0;
        args = state->args;
-       xfs_dir2_trace_args("node_to_leaf", args);
+
+       trace_xfs_dir2_node_to_leaf(args);
+
        mp = state->mp;
        dp = args->dp;
        tp = args->trans;
index 5a81ccd1045b11ac762fc0978d6b4043c6d451b6..ce6e355199b5fa4edfd0977480916408e3e4085e 100644 (file)
@@ -37,8 +37,8 @@
 #include "xfs_dir2_leaf.h"
 #include "xfs_dir2_block.h"
 #include "xfs_dir2_node.h"
-#include "xfs_dir2_trace.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 /*
  * Function declarations.
@@ -123,7 +123,8 @@ xfs_dir2_leaf_to_node(
        __be16                  *to;            /* pointer to freespace entry */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args_b("leaf_to_node", args, lbp);
+       trace_xfs_dir2_leaf_to_node(args);
+
        dp = args->dp;
        mp = dp->i_mount;
        tp = args->trans;
@@ -196,7 +197,8 @@ xfs_dir2_leafn_add(
        xfs_mount_t             *mp;            /* filesystem mount point */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args_sb("leafn_add", args, index, bp);
+       trace_xfs_dir2_leafn_add(args, index);
+
        dp = args->dp;
        mp = dp->i_mount;
        tp = args->trans;
@@ -711,8 +713,8 @@ xfs_dir2_leafn_moveents(
        int             stale;                  /* count stale leaves copied */
        xfs_trans_t     *tp;                    /* transaction pointer */
 
-       xfs_dir2_trace_args_bibii("leafn_moveents", args, bp_s, start_s, bp_d,
-               start_d, count);
+       trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count);
+
        /*
         * Silently return if nothing to do.
         */
@@ -933,7 +935,8 @@ xfs_dir2_leafn_remove(
        int                     needscan;       /* need to rescan data frees */
        xfs_trans_t             *tp;            /* transaction pointer */
 
-       xfs_dir2_trace_args_sb("leafn_remove", args, index, bp);
+       trace_xfs_dir2_leafn_remove(args, index);
+
        dp = args->dp;
        tp = args->trans;
        mp = dp->i_mount;
@@ -1363,7 +1366,8 @@ xfs_dir2_node_addname(
        int                     rval;           /* sub-return value */
        xfs_da_state_t          *state;         /* btree cursor */
 
-       xfs_dir2_trace_args("node_addname", args);
+       trace_xfs_dir2_node_addname(args);
+
        /*
         * Allocate and initialize the state (btree cursor).
         */
@@ -1822,7 +1826,8 @@ xfs_dir2_node_lookup(
        int             rval;                   /* operation return value */
        xfs_da_state_t  *state;                 /* btree cursor */
 
-       xfs_dir2_trace_args("node_lookup", args);
+       trace_xfs_dir2_node_lookup(args);
+
        /*
         * Allocate and initialize the btree cursor.
         */
@@ -1875,7 +1880,8 @@ xfs_dir2_node_removename(
        int                     rval;           /* operation return value */
        xfs_da_state_t          *state;         /* btree cursor */
 
-       xfs_dir2_trace_args("node_removename", args);
+       trace_xfs_dir2_node_removename(args);
+
        /*
         * Allocate and initialize the btree cursor.
         */
@@ -1944,7 +1950,8 @@ xfs_dir2_node_replace(
        int                     rval;           /* internal return value */
        xfs_da_state_t          *state;         /* btree cursor */
 
-       xfs_dir2_trace_args("node_replace", args);
+       trace_xfs_dir2_node_replace(args);
+
        /*
         * Allocate and initialize the btree cursor.
         */
index e89734e8464610a67797cc473951d91d1ce2fb90..9d4f17a69676bfb01d2fe698353ceea501c14deb 100644 (file)
@@ -37,7 +37,7 @@
 #include "xfs_dir2_data.h"
 #include "xfs_dir2_leaf.h"
 #include "xfs_dir2_block.h"
-#include "xfs_dir2_trace.h"
+#include "xfs_trace.h"
 
 /*
  * Prototypes for internal functions.
@@ -169,7 +169,8 @@ xfs_dir2_block_to_sf(
        xfs_dir2_sf_t           *sfp;           /* shortform structure */
        xfs_ino_t               temp;
 
-       xfs_dir2_trace_args_sb("block_to_sf", args, size, bp);
+       trace_xfs_dir2_block_to_sf(args);
+
        dp = args->dp;
        mp = dp->i_mount;
 
@@ -281,7 +282,8 @@ xfs_dir2_sf_addname(
        xfs_dir2_sf_t           *sfp;           /* shortform structure */
        xfs_dir2_sf_entry_t     *sfep = NULL;   /* shortform entry */
 
-       xfs_dir2_trace_args("sf_addname", args);
+       trace_xfs_dir2_sf_addname(args);
+
        ASSERT(xfs_dir2_sf_lookup(args) == ENOENT);
        dp = args->dp;
        ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
@@ -654,7 +656,8 @@ xfs_dir2_sf_create(
        xfs_dir2_sf_t   *sfp;           /* shortform structure */
        int             size;           /* directory size */
 
-       xfs_dir2_trace_args_i("sf_create", args, pino);
+       trace_xfs_dir2_sf_create(args);
+
        dp = args->dp;
 
        ASSERT(dp != NULL);
@@ -808,7 +811,8 @@ xfs_dir2_sf_lookup(
        enum xfs_dacmp          cmp;            /* comparison result */
        xfs_dir2_sf_entry_t     *ci_sfep;       /* case-insens. entry */
 
-       xfs_dir2_trace_args("sf_lookup", args);
+       trace_xfs_dir2_sf_lookup(args);
+
        xfs_dir2_sf_check(args);
        dp = args->dp;
 
@@ -891,7 +895,8 @@ xfs_dir2_sf_removename(
        xfs_dir2_sf_entry_t     *sfep;          /* shortform directory entry */
        xfs_dir2_sf_t           *sfp;           /* shortform structure */
 
-       xfs_dir2_trace_args("sf_removename", args);
+       trace_xfs_dir2_sf_removename(args);
+
        dp = args->dp;
 
        ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
@@ -982,7 +987,8 @@ xfs_dir2_sf_replace(
        xfs_dir2_sf_entry_t     *sfep;          /* shortform directory entry */
        xfs_dir2_sf_t           *sfp;           /* shortform structure */
 
-       xfs_dir2_trace_args("sf_replace", args);
+       trace_xfs_dir2_sf_replace(args);
+
        dp = args->dp;
 
        ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
@@ -1125,7 +1131,8 @@ xfs_dir2_sf_toino4(
        xfs_dir2_sf_entry_t     *sfep;          /* new sf entry */
        xfs_dir2_sf_t           *sfp;           /* new sf directory */
 
-       xfs_dir2_trace_args("sf_toino4", args);
+       trace_xfs_dir2_sf_toino4(args);
+
        dp = args->dp;
 
        /*
@@ -1202,7 +1209,8 @@ xfs_dir2_sf_toino8(
        xfs_dir2_sf_entry_t     *sfep;          /* new sf entry */
        xfs_dir2_sf_t           *sfp;           /* new sf directory */
 
-       xfs_dir2_trace_args("sf_toino8", args);
+       trace_xfs_dir2_sf_toino8(args);
+
        dp = args->dp;
 
        /*
diff --git a/fs/xfs/xfs_dir2_trace.c b/fs/xfs/xfs_dir2_trace.c
deleted file mode 100644 (file)
index 6cc7c0c..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#include "xfs.h"
-#include "xfs_fs.h"
-#include "xfs_types.h"
-#include "xfs_inum.h"
-#include "xfs_dir2.h"
-#include "xfs_da_btree.h"
-#include "xfs_bmap_btree.h"
-#include "xfs_dir2_sf.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dinode.h"
-#include "xfs_inode.h"
-#include "xfs_dir2_trace.h"
-
-#ifdef XFS_DIR2_TRACE
-ktrace_t       *xfs_dir2_trace_buf;
-
-/*
- * Enter something in the trace buffers.
- */
-static void
-xfs_dir2_trace_enter(
-       xfs_inode_t     *dp,
-       int             type,
-       char            *where,
-       char            *name,
-       int             namelen,
-       void            *a0,
-       void            *a1,
-       void            *a2,
-       void            *a3,
-       void            *a4,
-       void            *a5,
-       void            *a6,
-       void            *a7)
-{
-       void            *n[5];
-
-       ASSERT(xfs_dir2_trace_buf);
-       ASSERT(dp->i_dir_trace);
-       if (name)
-               memcpy(n, name, min((int)sizeof(n), namelen));
-       else
-               memset((char *)n, 0, sizeof(n));
-       ktrace_enter(xfs_dir2_trace_buf,
-               (void *)(long)type, (void *)where,
-               (void *)a0, (void *)a1, (void *)a2, (void *)a3,
-               (void *)a4, (void *)a5, (void *)a6, (void *)a7,
-               (void *)(long)namelen,
-               (void *)n[0], (void *)n[1], (void *)n[2],
-               (void *)n[3], (void *)n[4]);
-       ktrace_enter(dp->i_dir_trace,
-               (void *)(long)type, (void *)where,
-               (void *)a0, (void *)a1, (void *)a2, (void *)a3,
-               (void *)a4, (void *)a5, (void *)a6, (void *)a7,
-               (void *)(long)namelen,
-               (void *)n[0], (void *)n[1], (void *)n[2],
-               (void *)n[3], (void *)n[4]);
-}
-
-void
-xfs_dir2_trace_args(
-       char            *where,
-       xfs_da_args_t   *args)
-{
-       xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS, where,
-               (char *)args->name, (int)args->namelen,
-               (void *)(unsigned long)args->hashval,
-               (void *)((unsigned long)(args->inumber >> 32)),
-               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
-               (void *)args->dp, (void *)args->trans,
-               (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
-               NULL, NULL);
-}
-
-void
-xfs_dir2_trace_args_b(
-       char            *where,
-       xfs_da_args_t   *args,
-       xfs_dabuf_t     *bp)
-{
-       xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_B, where,
-               (char *)args->name, (int)args->namelen,
-               (void *)(unsigned long)args->hashval,
-               (void *)((unsigned long)(args->inumber >> 32)),
-               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
-               (void *)args->dp, (void *)args->trans,
-               (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
-               (void *)(bp ? bp->bps[0] : NULL), NULL);
-}
-
-void
-xfs_dir2_trace_args_bb(
-       char            *where,
-       xfs_da_args_t   *args,
-       xfs_dabuf_t     *lbp,
-       xfs_dabuf_t     *dbp)
-{
-       xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BB, where,
-               (char *)args->name, (int)args->namelen,
-               (void *)(unsigned long)args->hashval,
-               (void *)((unsigned long)(args->inumber >> 32)),
-               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
-               (void *)args->dp, (void *)args->trans,
-               (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
-               (void *)(lbp ? lbp->bps[0] : NULL),
-               (void *)(dbp ? dbp->bps[0] : NULL));
-}
-
-void
-xfs_dir2_trace_args_bibii(
-       char            *where,
-       xfs_da_args_t   *args,
-       xfs_dabuf_t     *bs,
-       int             ss,
-       xfs_dabuf_t     *bd,
-       int             sd,
-       int             c)
-{
-       xfs_buf_t       *bpbs = bs ? bs->bps[0] : NULL;
-       xfs_buf_t       *bpbd = bd ? bd->bps[0] : NULL;
-
-       xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BIBII, where,
-               (char *)args->name, (int)args->namelen,
-               (void *)args->dp, (void *)args->trans,
-               (void *)bpbs, (void *)(long)ss, (void *)bpbd, (void *)(long)sd,
-               (void *)(long)c, NULL);
-}
-
-void
-xfs_dir2_trace_args_db(
-       char            *where,
-       xfs_da_args_t   *args,
-       xfs_dir2_db_t   db,
-       xfs_dabuf_t     *bp)
-{
-       xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
-
-       xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_DB, where,
-               (char *)args->name, (int)args->namelen,
-               (void *)(unsigned long)args->hashval,
-               (void *)((unsigned long)(args->inumber >> 32)),
-               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
-               (void *)args->dp, (void *)args->trans,
-               (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
-               (void *)(long)db, (void *)dbp);
-}
-
-void
-xfs_dir2_trace_args_i(
-       char            *where,
-       xfs_da_args_t   *args,
-       xfs_ino_t       i)
-{
-       xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_I, where,
-               (char *)args->name, (int)args->namelen,
-               (void *)(unsigned long)args->hashval,
-               (void *)((unsigned long)(args->inumber >> 32)),
-               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
-               (void *)args->dp, (void *)args->trans,
-               (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
-               (void *)((unsigned long)(i >> 32)),
-               (void *)((unsigned long)(i & 0xFFFFFFFF)));
-}
-
-void
-xfs_dir2_trace_args_s(
-       char            *where,
-       xfs_da_args_t   *args,
-       int             s)
-{
-       xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_S, where,
-               (char *)args->name, (int)args->namelen,
-               (void *)(unsigned long)args->hashval,
-               (void *)((unsigned long)(args->inumber >> 32)),
-               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
-               (void *)args->dp, (void *)args->trans,
-               (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
-               (void *)(long)s, NULL);
-}
-
-void
-xfs_dir2_trace_args_sb(
-       char            *where,
-       xfs_da_args_t   *args,
-       int             s,
-       xfs_dabuf_t     *bp)
-{
-       xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
-
-       xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_SB, where,
-               (char *)args->name, (int)args->namelen,
-               (void *)(unsigned long)args->hashval,
-               (void *)((unsigned long)(args->inumber >> 32)),
-               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
-               (void *)args->dp, (void *)args->trans,
-               (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
-               (void *)(long)s, (void *)dbp);
-}
-#endif /* XFS_DIR2_TRACE */
diff --git a/fs/xfs/xfs_dir2_trace.h b/fs/xfs/xfs_dir2_trace.h
deleted file mode 100644 (file)
index ca3c754..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2000,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#ifndef __XFS_DIR2_TRACE_H__
-#define __XFS_DIR2_TRACE_H__
-
-/*
- * Tracing for xfs v2 directories.
- */
-
-#if defined(XFS_DIR2_TRACE)
-
-struct ktrace;
-struct xfs_dabuf;
-struct xfs_da_args;
-
-#define        XFS_DIR2_GTRACE_SIZE            4096    /* global buffer */
-#define        XFS_DIR2_KTRACE_SIZE            32      /* per-inode buffer */
-extern struct ktrace *xfs_dir2_trace_buf;
-
-#define        XFS_DIR2_KTRACE_ARGS            1       /* args only */
-#define        XFS_DIR2_KTRACE_ARGS_B          2       /* args + buffer */
-#define        XFS_DIR2_KTRACE_ARGS_BB         3       /* args + 2 buffers */
-#define        XFS_DIR2_KTRACE_ARGS_DB         4       /* args, db, buffer */
-#define        XFS_DIR2_KTRACE_ARGS_I          5       /* args, inum */
-#define        XFS_DIR2_KTRACE_ARGS_S          6       /* args, int */
-#define        XFS_DIR2_KTRACE_ARGS_SB         7       /* args, int, buffer */
-#define        XFS_DIR2_KTRACE_ARGS_BIBII      8       /* args, buf/int/buf/int/int */
-
-void xfs_dir2_trace_args(char *where, struct xfs_da_args *args);
-void xfs_dir2_trace_args_b(char *where, struct xfs_da_args *args,
-                          struct xfs_dabuf *bp);
-void xfs_dir2_trace_args_bb(char *where, struct xfs_da_args *args,
-                           struct xfs_dabuf *lbp, struct xfs_dabuf *dbp);
-void xfs_dir2_trace_args_bibii(char *where, struct xfs_da_args *args,
-                              struct xfs_dabuf *bs, int ss,
-                              struct xfs_dabuf *bd, int sd, int c);
-void xfs_dir2_trace_args_db(char *where, struct xfs_da_args *args,
-                           xfs_dir2_db_t db, struct xfs_dabuf *bp);
-void xfs_dir2_trace_args_i(char *where, struct xfs_da_args *args, xfs_ino_t i);
-void xfs_dir2_trace_args_s(char *where, struct xfs_da_args *args, int s);
-void xfs_dir2_trace_args_sb(char *where, struct xfs_da_args *args, int s,
-                           struct xfs_dabuf *bp);
-
-#else  /* XFS_DIR2_TRACE */
-
-#define        xfs_dir2_trace_args(where, args)
-#define        xfs_dir2_trace_args_b(where, args, bp)
-#define        xfs_dir2_trace_args_bb(where, args, lbp, dbp)
-#define        xfs_dir2_trace_args_bibii(where, args, bs, ss, bd, sd, c)
-#define        xfs_dir2_trace_args_db(where, args, db, bp)
-#define        xfs_dir2_trace_args_i(where, args, i)
-#define        xfs_dir2_trace_args_s(where, args, s)
-#define        xfs_dir2_trace_args_sb(where, args, s, bp)
-
-#endif /* XFS_DIR2_TRACE */
-
-#endif /* __XFS_DIR2_TRACE_H__ */
index edf8bdf4141fdbd626acf69dc8db4b2d471c568d..a631e1451abb992e21d08639e1f9fcfc428b86c4 100644 (file)
@@ -34,6 +34,7 @@
 #include "xfs_utils.h"
 #include "xfs_mru_cache.h"
 #include "xfs_filestream.h"
+#include "xfs_trace.h"
 
 #ifdef XFS_FILESTREAMS_TRACE
 
@@ -394,9 +395,7 @@ xfs_filestream_init(void)
        item_zone = kmem_zone_init(sizeof(fstrm_item_t), "fstrm_item");
        if (!item_zone)
                return -ENOMEM;
-#ifdef XFS_FILESTREAMS_TRACE
-       xfs_filestreams_trace_buf = ktrace_alloc(XFS_FSTRM_KTRACE_SIZE, KM_NOFS);
-#endif
+
        return 0;
 }
 
@@ -407,9 +406,6 @@ xfs_filestream_init(void)
 void
 xfs_filestream_uninit(void)
 {
-#ifdef XFS_FILESTREAMS_TRACE
-       ktrace_free(xfs_filestreams_trace_buf);
-#endif
        kmem_zone_destroy(item_zone);
 }
 
index 36079aa91344bc7e338ddb83c4f4d292d3f85c0a..a13919a6a364124d45ea209f77f863d1e268144c 100644 (file)
@@ -45,6 +45,7 @@
 #include "xfs_rtalloc.h"
 #include "xfs_rw.h"
 #include "xfs_filestream.h"
+#include "xfs_trace.h"
 
 /*
  * File system operations
@@ -347,6 +348,7 @@ xfs_growfs_data_private(
                be32_add_cpu(&agf->agf_length, new);
                ASSERT(be32_to_cpu(agf->agf_length) ==
                       be32_to_cpu(agi->agi_length));
+
                xfs_alloc_log_agf(tp, bp, XFS_AGF_LENGTH);
                /*
                 * Free the new space.
index 073bb4a26b194a8e1508c9b50f4363b444e84b54..fa402a6bbbcf3272ee002700aa85ca118cbbc86e 100644 (file)
@@ -43,7 +43,7 @@
 #include "xfs_inode_item.h"
 #include "xfs_bmap.h"
 #include "xfs_btree_trace.h"
-#include "xfs_dir2_trace.h"
+#include "xfs_trace.h"
 
 
 /*
@@ -90,30 +90,8 @@ xfs_inode_alloc(
        ip->i_size = 0;
        ip->i_new_size = 0;
 
-       /*
-        * Initialize inode's trace buffers.
-        */
-#ifdef XFS_INODE_TRACE
-       ip->i_trace = ktrace_alloc(INODE_TRACE_SIZE, KM_NOFS);
-#endif
-#ifdef XFS_BMAP_TRACE
-       ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_NOFS);
-#endif
-#ifdef XFS_BTREE_TRACE
-       ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_NOFS);
-#endif
-#ifdef XFS_RW_TRACE
-       ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_NOFS);
-#endif
-#ifdef XFS_ILOCK_TRACE
-       ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_NOFS);
-#endif
-#ifdef XFS_DIR2_TRACE
-       ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_NOFS);
-#endif
-
        /* prevent anyone from using this yet */
-       VFS_I(ip)->i_state = I_NEW|I_LOCK;
+       VFS_I(ip)->i_state = I_NEW;
 
        return ip;
 }
@@ -133,25 +111,6 @@ xfs_inode_free(
        if (ip->i_afp)
                xfs_idestroy_fork(ip, XFS_ATTR_FORK);
 
-#ifdef XFS_INODE_TRACE
-       ktrace_free(ip->i_trace);
-#endif
-#ifdef XFS_BMAP_TRACE
-       ktrace_free(ip->i_xtrace);
-#endif
-#ifdef XFS_BTREE_TRACE
-       ktrace_free(ip->i_btrace);
-#endif
-#ifdef XFS_RW_TRACE
-       ktrace_free(ip->i_rwtrace);
-#endif
-#ifdef XFS_ILOCK_TRACE
-       ktrace_free(ip->i_lock_trace);
-#endif
-#ifdef XFS_DIR2_TRACE
-       ktrace_free(ip->i_dir_trace);
-#endif
-
        if (ip->i_itemp) {
                /*
                 * Only if we are shutting down the fs will we see an
@@ -210,6 +169,7 @@ xfs_iget_cache_hit(
         *           instead of polling for it.
         */
        if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) {
+               trace_xfs_iget_skip(ip);
                XFS_STATS_INC(xs_ig_frecycle);
                error = EAGAIN;
                goto out_error;
@@ -228,7 +188,7 @@ xfs_iget_cache_hit(
         * Need to carefully get it back into useable state.
         */
        if (ip->i_flags & XFS_IRECLAIMABLE) {
-               xfs_itrace_exit_tag(ip, "xfs_iget.alloc");
+               trace_xfs_iget_reclaim(ip);
 
                /*
                 * We need to set XFS_INEW atomically with clearing the
@@ -254,9 +214,10 @@ xfs_iget_cache_hit(
                        ip->i_flags &= ~XFS_INEW;
                        ip->i_flags |= XFS_IRECLAIMABLE;
                        __xfs_inode_set_reclaim_tag(pag, ip);
+                       trace_xfs_iget_reclaim(ip);
                        goto out_error;
                }
-               inode->i_state = I_LOCK|I_NEW;
+               inode->i_state = I_NEW;
        } else {
                /* If the VFS inode is being torn down, pause and try again. */
                if (!igrab(inode)) {
@@ -273,8 +234,9 @@ xfs_iget_cache_hit(
                xfs_ilock(ip, lock_flags);
 
        xfs_iflags_clear(ip, XFS_ISTALE);
-       xfs_itrace_exit_tag(ip, "xfs_iget.found");
        XFS_STATS_INC(xs_ig_found);
+
+       trace_xfs_iget_found(ip);
        return 0;
 
 out_error:
@@ -308,7 +270,7 @@ xfs_iget_cache_miss(
        if (error)
                goto out_destroy;
 
-       xfs_itrace_exit_tag(ip, "xfs_iget.alloc");
+       xfs_itrace_entry(ip);
 
        if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) {
                error = ENOENT;
@@ -353,6 +315,8 @@ xfs_iget_cache_miss(
 
        write_unlock(&pag->pag_ici_lock);
        radix_tree_preload_end();
+
+       trace_xfs_iget_alloc(ip);
        *ipp = ip;
        return 0;
 
@@ -514,17 +478,21 @@ xfs_ireclaim(
 {
        struct xfs_mount        *mp = ip->i_mount;
        struct xfs_perag        *pag;
+       xfs_agino_t             agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
 
        XFS_STATS_INC(xs_ig_reclaims);
 
        /*
-        * Remove the inode from the per-AG radix tree.  It doesn't matter
-        * if it was never added to it because radix_tree_delete can deal
-        * with that case just fine.
+        * Remove the inode from the per-AG radix tree.
+        *
+        * Because radix_tree_delete won't complain even if the item was never
+        * added to the tree assert that it's been there before to catch
+        * problems with the inode life time early on.
         */
        pag = xfs_get_perag(mp, ip->i_ino);
        write_lock(&pag->pag_ici_lock);
-       radix_tree_delete(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino));
+       if (!radix_tree_delete(&pag->pag_ici_root, agino))
+               ASSERT(0);
        write_unlock(&pag->pag_ici_lock);
        xfs_put_perag(mp, pag);
 
@@ -639,7 +607,7 @@ xfs_ilock(
        else if (lock_flags & XFS_ILOCK_SHARED)
                mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags));
 
-       xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)__return_address);
+       trace_xfs_ilock(ip, lock_flags, _RET_IP_);
 }
 
 /*
@@ -684,7 +652,7 @@ xfs_ilock_nowait(
                if (!mrtryaccess(&ip->i_lock))
                        goto out_undo_iolock;
        }
-       xfs_ilock_trace(ip, 2, lock_flags, (inst_t *)__return_address);
+       trace_xfs_ilock_nowait(ip, lock_flags, _RET_IP_);
        return 1;
 
  out_undo_iolock:
@@ -746,7 +714,7 @@ xfs_iunlock(
                xfs_trans_unlocked_item(ip->i_itemp->ili_item.li_ailp,
                                        (xfs_log_item_t*)(ip->i_itemp));
        }
-       xfs_ilock_trace(ip, 3, lock_flags, (inst_t *)__return_address);
+       trace_xfs_iunlock(ip, lock_flags, _RET_IP_);
 }
 
 /*
@@ -765,6 +733,8 @@ xfs_ilock_demote(
                mrdemote(&ip->i_lock);
        if (lock_flags & XFS_IOLOCK_EXCL)
                mrdemote(&ip->i_iolock);
+
+       trace_xfs_ilock_demote(ip, lock_flags, _RET_IP_);
 }
 
 #ifdef DEBUG
@@ -795,52 +765,3 @@ xfs_isilocked(
        return 1;
 }
 #endif
-
-#ifdef XFS_INODE_TRACE
-
-#define KTRACE_ENTER(ip, vk, s, line, ra)                      \
-       ktrace_enter((ip)->i_trace,                             \
-/*  0 */               (void *)(__psint_t)(vk),                \
-/*  1 */               (void *)(s),                            \
-/*  2 */               (void *)(__psint_t) line,               \
-/*  3 */               (void *)(__psint_t)atomic_read(&VFS_I(ip)->i_count), \
-/*  4 */               (void *)(ra),                           \
-/*  5 */               NULL,                                   \
-/*  6 */               (void *)(__psint_t)current_cpu(),       \
-/*  7 */               (void *)(__psint_t)current_pid(),       \
-/*  8 */               (void *)__return_address,               \
-/*  9 */               NULL, NULL, NULL, NULL, NULL, NULL, NULL)
-
-/*
- * Vnode tracing code.
- */
-void
-_xfs_itrace_entry(xfs_inode_t *ip, const char *func, inst_t *ra)
-{
-       KTRACE_ENTER(ip, INODE_KTRACE_ENTRY, func, 0, ra);
-}
-
-void
-_xfs_itrace_exit(xfs_inode_t *ip, const char *func, inst_t *ra)
-{
-       KTRACE_ENTER(ip, INODE_KTRACE_EXIT, func, 0, ra);
-}
-
-void
-xfs_itrace_hold(xfs_inode_t *ip, char *file, int line, inst_t *ra)
-{
-       KTRACE_ENTER(ip, INODE_KTRACE_HOLD, file, line, ra);
-}
-
-void
-_xfs_itrace_ref(xfs_inode_t *ip, char *file, int line, inst_t *ra)
-{
-       KTRACE_ENTER(ip, INODE_KTRACE_REF, file, line, ra);
-}
-
-void
-xfs_itrace_rele(xfs_inode_t *ip, char *file, int line, inst_t *ra)
-{
-       KTRACE_ENTER(ip, INODE_KTRACE_RELE, file, line, ra);
-}
-#endif /* XFS_INODE_TRACE */
index b92a4fa2a0a12eda161c2ff897bd820f5cbde1e8..ce278b3ae7fcb607ff1f6d5e9e13b621744e95bb 100644 (file)
 #include "xfs_rw.h"
 #include "xfs_error.h"
 #include "xfs_utils.h"
-#include "xfs_dir2_trace.h"
 #include "xfs_quota.h"
 #include "xfs_filestream.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 kmem_zone_t *xfs_ifork_zone;
 kmem_zone_t *xfs_inode_zone;
@@ -1291,42 +1291,6 @@ xfs_file_last_byte(
        return last_byte;
 }
 
-#if defined(XFS_RW_TRACE)
-STATIC void
-xfs_itrunc_trace(
-       int             tag,
-       xfs_inode_t     *ip,
-       int             flag,
-       xfs_fsize_t     new_size,
-       xfs_off_t       toss_start,
-       xfs_off_t       toss_finish)
-{
-       if (ip->i_rwtrace == NULL) {
-               return;
-       }
-
-       ktrace_enter(ip->i_rwtrace,
-                    (void*)((long)tag),
-                    (void*)ip,
-                    (void*)(unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff),
-                    (void*)(unsigned long)(ip->i_d.di_size & 0xffffffff),
-                    (void*)((long)flag),
-                    (void*)(unsigned long)((new_size >> 32) & 0xffffffff),
-                    (void*)(unsigned long)(new_size & 0xffffffff),
-                    (void*)(unsigned long)((toss_start >> 32) & 0xffffffff),
-                    (void*)(unsigned long)(toss_start & 0xffffffff),
-                    (void*)(unsigned long)((toss_finish >> 32) & 0xffffffff),
-                    (void*)(unsigned long)(toss_finish & 0xffffffff),
-                    (void*)(unsigned long)current_cpu(),
-                    (void*)(unsigned long)current_pid(),
-                    (void*)NULL,
-                    (void*)NULL,
-                    (void*)NULL);
-}
-#else
-#define        xfs_itrunc_trace(tag, ip, flag, new_size, toss_start, toss_finish)
-#endif
-
 /*
  * Start the truncation of the file to new_size.  The new size
  * must be smaller than the current size.  This routine will
@@ -1409,8 +1373,7 @@ xfs_itruncate_start(
                return 0;
        }
        last_byte = xfs_file_last_byte(ip);
-       xfs_itrunc_trace(XFS_ITRUNC_START, ip, flags, new_size, toss_start,
-                        last_byte);
+       trace_xfs_itruncate_start(ip, flags, new_size, toss_start, last_byte);
        if (last_byte > toss_start) {
                if (flags & XFS_ITRUNC_DEFINITE) {
                        xfs_tosspages(ip, toss_start,
@@ -1514,7 +1477,8 @@ xfs_itruncate_finish(
                new_size = 0LL;
        }
        first_unmap_block = XFS_B_TO_FSB(mp, (xfs_ufsize_t)new_size);
-       xfs_itrunc_trace(XFS_ITRUNC_FINISH1, ip, 0, new_size, 0, 0);
+       trace_xfs_itruncate_finish_start(ip, new_size);
+
        /*
         * The first thing we do is set the size to new_size permanently
         * on disk.  This way we don't have to worry about anyone ever
@@ -1731,7 +1695,7 @@ xfs_itruncate_finish(
        ASSERT((new_size != 0) ||
               (fork == XFS_ATTR_FORK) ||
               (ip->i_d.di_nextents == 0));
-       xfs_itrunc_trace(XFS_ITRUNC_FINISH2, ip, 0, new_size, 0, 0);
+       trace_xfs_itruncate_finish_end(ip, new_size);
        return 0;
 }
 
@@ -3252,23 +3216,6 @@ corrupt_out:
        return XFS_ERROR(EFSCORRUPTED);
 }
 
-
-
-#ifdef XFS_ILOCK_TRACE
-void
-xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra)
-{
-       ktrace_enter(ip->i_lock_trace,
-                    (void *)ip,
-                    (void *)(unsigned long)lock, /* 1 = LOCK, 3=UNLOCK, etc */
-                    (void *)(unsigned long)lockflags, /* XFS_ILOCK_EXCL etc */
-                    (void *)ra,                /* caller of ilock */
-                    (void *)(unsigned long)current_cpu(),
-                    (void *)(unsigned long)current_pid(),
-                    NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
-}
-#endif
-
 /*
  * Return a pointer to the extent record at file index idx.
  */
@@ -3300,13 +3247,17 @@ xfs_iext_get_ext(
  */
 void
 xfs_iext_insert(
-       xfs_ifork_t     *ifp,           /* inode fork pointer */
+       xfs_inode_t     *ip,            /* incore inode pointer */
        xfs_extnum_t    idx,            /* starting index of new items */
        xfs_extnum_t    count,          /* number of inserted items */
-       xfs_bmbt_irec_t *new)           /* items to insert */
+       xfs_bmbt_irec_t *new,           /* items to insert */
+       int             state)          /* type of extent conversion */
 {
+       xfs_ifork_t     *ifp = (state & BMAP_ATTRFORK) ? ip->i_afp : &ip->i_df;
        xfs_extnum_t    i;              /* extent record index */
 
+       trace_xfs_iext_insert(ip, idx, new, state, _RET_IP_);
+
        ASSERT(ifp->if_flags & XFS_IFEXTENTS);
        xfs_iext_add(ifp, idx, count);
        for (i = idx; i < idx + count; i++, new++)
@@ -3549,13 +3500,17 @@ xfs_iext_add_indirect_multi(
  */
 void
 xfs_iext_remove(
-       xfs_ifork_t     *ifp,           /* inode fork pointer */
+       xfs_inode_t     *ip,            /* incore inode pointer */
        xfs_extnum_t    idx,            /* index to begin removing exts */
-       int             ext_diff)       /* number of extents to remove */
+       int             ext_diff,       /* number of extents to remove */
+       int             state)          /* type of extent conversion */
 {
+       xfs_ifork_t     *ifp = (state & BMAP_ATTRFORK) ? ip->i_afp : &ip->i_df;
        xfs_extnum_t    nextents;       /* number of extents in file */
        int             new_size;       /* size of extents after removal */
 
+       trace_xfs_iext_remove(ip, idx, state, _RET_IP_);
+
        ASSERT(ext_diff > 0);
        nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
        new_size = (nextents - ext_diff) * sizeof(xfs_bmbt_rec_t);
index 41555de1d1dbd4e6befcd64840712de5beff8235..ec1f28c4fc4f695753c41d5e3ed8c678d3e9bb0b 100644 (file)
@@ -213,7 +213,6 @@ typedef struct xfs_icdinode {
 
 struct bhv_desc;
 struct cred;
-struct ktrace;
 struct xfs_buf;
 struct xfs_bmap_free;
 struct xfs_bmbt_irec;
@@ -222,13 +221,6 @@ struct xfs_mount;
 struct xfs_trans;
 struct xfs_dquot;
 
-#if defined(XFS_ILOCK_TRACE)
-#define XFS_ILOCK_KTRACE_SIZE  32
-extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
-#else
-#define        xfs_ilock_trace(i,n,f,ra)
-#endif
-
 typedef struct dm_attrs_s {
        __uint32_t      da_dmevmask;    /* DMIG event mask */
        __uint16_t      da_dmstate;     /* DMIG state info */
@@ -271,26 +263,6 @@ typedef struct xfs_inode {
 
        /* VFS inode */
        struct inode            i_vnode;        /* embedded VFS inode */
-
-       /* Trace buffers per inode. */
-#ifdef XFS_INODE_TRACE
-       struct ktrace           *i_trace;       /* general inode trace */
-#endif
-#ifdef XFS_BMAP_TRACE
-       struct ktrace           *i_xtrace;      /* inode extent list trace */
-#endif
-#ifdef XFS_BTREE_TRACE
-       struct ktrace           *i_btrace;      /* inode bmap btree trace */
-#endif
-#ifdef XFS_RW_TRACE
-       struct ktrace           *i_rwtrace;     /* inode read/write trace */
-#endif
-#ifdef XFS_ILOCK_TRACE
-       struct ktrace           *i_lock_trace;  /* inode lock/unlock trace */
-#endif
-#ifdef XFS_DIR2_TRACE
-       struct ktrace           *i_dir_trace;   /* inode directory trace */
-#endif
 } xfs_inode_t;
 
 #define XFS_ISIZE(ip)  (((ip)->i_d.di_mode & S_IFMT) == S_IFREG) ? \
@@ -406,6 +378,14 @@ static inline void xfs_ifunlock(xfs_inode_t *ip)
 #define XFS_LOCK_MASK          (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED \
                                | XFS_ILOCK_EXCL | XFS_ILOCK_SHARED)
 
+#define XFS_LOCK_FLAGS \
+       { XFS_IOLOCK_EXCL,      "IOLOCK_EXCL" }, \
+       { XFS_IOLOCK_SHARED,    "IOLOCK_SHARED" }, \
+       { XFS_ILOCK_EXCL,       "ILOCK_EXCL" }, \
+       { XFS_ILOCK_SHARED,     "ILOCK_SHARED" }, \
+       { XFS_IUNLOCK_NONOTIFY, "IUNLOCK_NONOTIFY" }
+
+
 /*
  * Flags for lockdep annotations.
  *
@@ -455,6 +435,10 @@ static inline void xfs_ifunlock(xfs_inode_t *ip)
 #define        XFS_ITRUNC_DEFINITE     0x1
 #define        XFS_ITRUNC_MAYBE        0x2
 
+#define XFS_ITRUNC_FLAGS \
+       { XFS_ITRUNC_DEFINITE,  "DEFINITE" }, \
+       { XFS_ITRUNC_MAYBE,     "MAYBE" }
+
 /*
  * For multiple groups support: if S_ISGID bit is set in the parent
  * directory, group of new file is set to that of the parent, and
@@ -507,48 +491,16 @@ void              xfs_lock_two_inodes(xfs_inode_t *, xfs_inode_t *, uint);
 void           xfs_synchronize_times(xfs_inode_t *);
 void           xfs_mark_inode_dirty_sync(xfs_inode_t *);
 
-#if defined(XFS_INODE_TRACE)
-
-#define        INODE_TRACE_SIZE        16              /* number of trace entries */
-#define        INODE_KTRACE_ENTRY      1
-#define        INODE_KTRACE_EXIT       2
-#define        INODE_KTRACE_HOLD       3
-#define        INODE_KTRACE_REF        4
-#define        INODE_KTRACE_RELE       5
-
-extern void _xfs_itrace_entry(struct xfs_inode *, const char *, inst_t *);
-extern void _xfs_itrace_exit(struct xfs_inode *, const char *, inst_t *);
-extern void xfs_itrace_hold(struct xfs_inode *, char *, int, inst_t *);
-extern void _xfs_itrace_ref(struct xfs_inode *, char *, int, inst_t *);
-extern void xfs_itrace_rele(struct xfs_inode *, char *, int, inst_t *);
-#define xfs_itrace_entry(ip)   \
-       _xfs_itrace_entry(ip, __func__, (inst_t *)__return_address)
-#define xfs_itrace_exit(ip)    \
-       _xfs_itrace_exit(ip, __func__, (inst_t *)__return_address)
-#define xfs_itrace_exit_tag(ip, tag)   \
-       _xfs_itrace_exit(ip, tag, (inst_t *)__return_address)
-#define xfs_itrace_ref(ip)     \
-       _xfs_itrace_ref(ip, __FILE__, __LINE__, (inst_t *)__return_address)
-
-#else
-#define        xfs_itrace_entry(a)
-#define        xfs_itrace_exit(a)
-#define        xfs_itrace_exit_tag(a, b)
-#define        xfs_itrace_hold(a, b, c, d)
-#define        xfs_itrace_ref(a)
-#define        xfs_itrace_rele(a, b, c, d)
-#endif
-
 #define IHOLD(ip) \
 do { \
        ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \
        atomic_inc(&(VFS_I(ip)->i_count)); \
-       xfs_itrace_hold((ip), __FILE__, __LINE__, (inst_t *)__return_address); \
+       trace_xfs_ihold(ip, _THIS_IP_); \
 } while (0)
 
 #define IRELE(ip) \
 do { \
-       xfs_itrace_rele((ip), __FILE__, __LINE__, (inst_t *)__return_address); \
+       trace_xfs_irele(ip, _THIS_IP_); \
        iput(VFS_I(ip)); \
 } while (0)
 
@@ -577,11 +529,11 @@ int               xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int);
 int            xfs_iextents_copy(struct xfs_inode *, xfs_bmbt_rec_t *, int);
 
 xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t);
-void           xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t,
-                               xfs_bmbt_irec_t *);
+void           xfs_iext_insert(xfs_inode_t *, xfs_extnum_t, xfs_extnum_t,
+                               xfs_bmbt_irec_t *, int);
 void           xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int);
 void           xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int);
-void           xfs_iext_remove(xfs_ifork_t *, xfs_extnum_t, int);
+void           xfs_iext_remove(xfs_inode_t *, xfs_extnum_t, int, int);
 void           xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int);
 void           xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int);
 void           xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int);
index 9794b876d6ff65e34336e390a9becca46fa8e330..f38855d21ea5a87cd8aa83304f9b8644f2cbfe6a 100644 (file)
@@ -41,6 +41,7 @@
 #include "xfs_ialloc.h"
 #include "xfs_rw.h"
 #include "xfs_error.h"
+#include "xfs_trace.h"
 
 
 kmem_zone_t    *xfs_ili_zone;          /* inode log item zone */
@@ -800,7 +801,9 @@ xfs_inode_item_pushbuf(
                                  !completion_done(&ip->i_flush));
                        iip->ili_pushbuf_flag = 0;
                        xfs_iunlock(ip, XFS_ILOCK_SHARED);
-                       xfs_buftrace("INODE ITEM PUSH", bp);
+
+                       trace_xfs_inode_item_push(bp, _RET_IP_);
+
                        if (XFS_BUF_ISPINNED(bp)) {
                                xfs_log_force(mp, (xfs_lsn_t)0,
                                              XFS_LOG_FORCE);
index 65bae4c9b8bf3ddb87abb525a38b81687e9932aa..cc8df1ac7783e7407b235f4eeddd8e43f5fb10e6 100644 (file)
@@ -127,7 +127,7 @@ static inline int xfs_ilog_fdata(int w)
 #ifdef __KERNEL__
 
 struct xfs_buf;
-struct xfs_bmbt_rec_64;
+struct xfs_bmbt_rec;
 struct xfs_inode;
 struct xfs_mount;
 
@@ -140,9 +140,9 @@ typedef struct xfs_inode_log_item {
        unsigned short          ili_flags;         /* misc flags */
        unsigned short          ili_logged;        /* flushed logged data */
        unsigned int            ili_last_fields;   /* fields when flushed */
-       struct xfs_bmbt_rec_64  *ili_extents_buf;  /* array of logged
+       struct xfs_bmbt_rec     *ili_extents_buf;  /* array of logged
                                                      data exts */
-       struct xfs_bmbt_rec_64  *ili_aextents_buf; /* array of logged
+       struct xfs_bmbt_rec     *ili_aextents_buf; /* array of logged
                                                      attr exts */
        unsigned int            ili_pushbuf_flag;  /* one bit used in push_ail */
 
index 7294abce6ef2f4d7d7e7ecae29dd377b14a4a2b3..0b65039951a0cb926869eb334d57afea920fc43e 100644 (file)
 #include "xfs_trans_space.h"
 #include "xfs_utils.h"
 #include "xfs_iomap.h"
+#include "xfs_trace.h"
 
-#if defined(XFS_RW_TRACE)
-void
-xfs_iomap_enter_trace(
-       int             tag,
-       xfs_inode_t     *ip,
-       xfs_off_t       offset,
-       ssize_t         count)
-{
-       if (!ip->i_rwtrace)
-               return;
-
-       ktrace_enter(ip->i_rwtrace,
-               (void *)((unsigned long)tag),
-               (void *)ip,
-               (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
-               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(offset & 0xffffffff)),
-               (void *)((unsigned long)count),
-               (void *)((unsigned long)((ip->i_new_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(ip->i_new_size & 0xffffffff)),
-               (void *)((unsigned long)current_pid()),
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL,
-               (void *)NULL);
-}
-
-void
-xfs_iomap_map_trace(
-       int             tag,
-       xfs_inode_t     *ip,
-       xfs_off_t       offset,
-       ssize_t         count,
-       xfs_iomap_t     *iomapp,
-       xfs_bmbt_irec_t *imapp,
-       int             flags)
-{
-       if (!ip->i_rwtrace)
-               return;
-
-       ktrace_enter(ip->i_rwtrace,
-               (void *)((unsigned long)tag),
-               (void *)ip,
-               (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
-               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(offset & 0xffffffff)),
-               (void *)((unsigned long)count),
-               (void *)((unsigned long)flags),
-               (void *)((unsigned long)((iomapp->iomap_offset >> 32) & 0xffffffff)),
-               (void *)((unsigned long)(iomapp->iomap_offset & 0xffffffff)),
-               (void *)((unsigned long)(iomapp->iomap_delta)),
-               (void *)((unsigned long)(iomapp->iomap_bsize)),
-               (void *)((unsigned long)(iomapp->iomap_bn)),
-               (void *)(__psint_t)(imapp->br_startoff),
-               (void *)((unsigned long)(imapp->br_blockcount)),
-               (void *)(__psint_t)(imapp->br_startblock));
-}
-#else
-#define xfs_iomap_enter_trace(tag, io, offset, count)
-#define xfs_iomap_map_trace(tag, io, offset, count, iomapp, imapp, flags)
-#endif
 
 #define XFS_WRITEIO_ALIGN(mp,off)      (((off) >> mp->m_writeio_log) \
                                                << mp->m_writeio_log)
@@ -187,21 +123,20 @@ xfs_iomap(
        if (XFS_FORCED_SHUTDOWN(mp))
                return XFS_ERROR(EIO);
 
+       trace_xfs_iomap_enter(ip, offset, count, flags, NULL);
+
        switch (flags & (BMAPI_READ | BMAPI_WRITE | BMAPI_ALLOCATE)) {
        case BMAPI_READ:
-               xfs_iomap_enter_trace(XFS_IOMAP_READ_ENTER, ip, offset, count);
                lockmode = xfs_ilock_map_shared(ip);
                bmapi_flags = XFS_BMAPI_ENTIRE;
                break;
        case BMAPI_WRITE:
-               xfs_iomap_enter_trace(XFS_IOMAP_WRITE_ENTER, ip, offset, count);
                lockmode = XFS_ILOCK_EXCL;
                if (flags & BMAPI_IGNSTATE)
                        bmapi_flags |= XFS_BMAPI_IGSTATE|XFS_BMAPI_ENTIRE;
                xfs_ilock(ip, lockmode);
                break;
        case BMAPI_ALLOCATE:
-               xfs_iomap_enter_trace(XFS_IOMAP_ALLOC_ENTER, ip, offset, count);
                lockmode = XFS_ILOCK_SHARED;
                bmapi_flags = XFS_BMAPI_ENTIRE;
 
@@ -237,8 +172,7 @@ xfs_iomap(
                if (nimaps &&
                    (imap.br_startblock != HOLESTARTBLOCK) &&
                    (imap.br_startblock != DELAYSTARTBLOCK)) {
-                       xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, ip,
-                                       offset, count, iomapp, &imap, flags);
+                       trace_xfs_iomap_found(ip, offset, count, flags, &imap);
                        break;
                }
 
@@ -250,8 +184,7 @@ xfs_iomap(
                                                      &imap, &nimaps);
                }
                if (!error) {
-                       xfs_iomap_map_trace(XFS_IOMAP_ALLOC_MAP, ip,
-                                       offset, count, iomapp, &imap, flags);
+                       trace_xfs_iomap_alloc(ip, offset, count, flags, &imap);
                }
                iomap_flags = IOMAP_NEW;
                break;
@@ -261,8 +194,7 @@ xfs_iomap(
                lockmode = 0;
 
                if (nimaps && !isnullstartblock(imap.br_startblock)) {
-                       xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, ip,
-                                       offset, count, iomapp, &imap, flags);
+                       trace_xfs_iomap_found(ip, offset, count, flags, &imap);
                        break;
                }
 
@@ -623,8 +555,7 @@ retry:
         * delalloc blocks and retry without EOF preallocation.
         */
        if (nimaps == 0) {
-               xfs_iomap_enter_trace(XFS_IOMAP_WRITE_NOSPACE,
-                                       ip, offset, count);
+               trace_xfs_delalloc_enospc(ip, offset, count);
                if (flushed)
                        return XFS_ERROR(ENOSPC);
 
@@ -837,7 +768,7 @@ xfs_iomap_write_unwritten(
        int             committed;
        int             error;
 
-       xfs_iomap_enter_trace(XFS_IOMAP_UNWRITTEN, ip, offset, count);
+       trace_xfs_unwritten_convert(ip, offset, count);
 
        offset_fsb = XFS_B_TO_FSBT(mp, offset);
        count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
index fdcf7b82747f696b78bdc0b8a5f62d20fc831bb9..174f29990991612122b3a927d70d0dc0235867db 100644 (file)
@@ -43,6 +43,14 @@ typedef enum {
        BMAPI_TRYLOCK = (1 << 7),       /* non-blocking request */
 } bmapi_flags_t;
 
+#define BMAPI_FLAGS \
+       { BMAPI_READ,           "READ" }, \
+       { BMAPI_WRITE,          "WRITE" }, \
+       { BMAPI_ALLOCATE,       "ALLOCATE" }, \
+       { BMAPI_IGNSTATE,       "IGNSTATE" }, \
+       { BMAPI_DIRECT,         "DIRECT" }, \
+       { BMAPI_MMAP,           "MMAP" }, \
+       { BMAPI_TRYLOCK,        "TRYLOCK" }
 
 /*
  * xfs_iomap_t:  File system I/O map
index 9dbdff3ea484bf008d1b634a53a2f42aedb3effc..600b5b06aaebb405420524c1c6f50ed17e199ef3 100644 (file)
@@ -40,6 +40,7 @@
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
 #include "xfs_rw.h"
+#include "xfs_trace.h"
 
 kmem_zone_t    *xfs_log_ticket_zone;
 
@@ -122,85 +123,6 @@ STATIC void        xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog,
 
 STATIC int     xlog_iclogs_empty(xlog_t *log);
 
-#if defined(XFS_LOG_TRACE)
-
-#define XLOG_TRACE_LOGGRANT_SIZE       2048
-#define XLOG_TRACE_ICLOG_SIZE          256
-
-void
-xlog_trace_loggrant_alloc(xlog_t *log)
-{
-       log->l_grant_trace = ktrace_alloc(XLOG_TRACE_LOGGRANT_SIZE, KM_NOFS);
-}
-
-void
-xlog_trace_loggrant_dealloc(xlog_t *log)
-{
-       ktrace_free(log->l_grant_trace);
-}
-
-void
-xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string)
-{
-       unsigned long cnts;
-
-       /* ticket counts are 1 byte each */
-       cnts = ((unsigned long)tic->t_ocnt) | ((unsigned long)tic->t_cnt) << 8;
-
-       ktrace_enter(log->l_grant_trace,
-                    (void *)tic,
-                    (void *)log->l_reserve_headq,
-                    (void *)log->l_write_headq,
-                    (void *)((unsigned long)log->l_grant_reserve_cycle),
-                    (void *)((unsigned long)log->l_grant_reserve_bytes),
-                    (void *)((unsigned long)log->l_grant_write_cycle),
-                    (void *)((unsigned long)log->l_grant_write_bytes),
-                    (void *)((unsigned long)log->l_curr_cycle),
-                    (void *)((unsigned long)log->l_curr_block),
-                    (void *)((unsigned long)CYCLE_LSN(log->l_tail_lsn)),
-                    (void *)((unsigned long)BLOCK_LSN(log->l_tail_lsn)),
-                    (void *)string,
-                    (void *)((unsigned long)tic->t_trans_type),
-                    (void *)cnts,
-                    (void *)((unsigned long)tic->t_curr_res),
-                    (void *)((unsigned long)tic->t_unit_res));
-}
-
-void
-xlog_trace_iclog_alloc(xlog_in_core_t *iclog)
-{
-       iclog->ic_trace = ktrace_alloc(XLOG_TRACE_ICLOG_SIZE, KM_NOFS);
-}
-
-void
-xlog_trace_iclog_dealloc(xlog_in_core_t *iclog)
-{
-       ktrace_free(iclog->ic_trace);
-}
-
-void
-xlog_trace_iclog(xlog_in_core_t *iclog, uint state)
-{
-       ktrace_enter(iclog->ic_trace,
-                    (void *)((unsigned long)state),
-                    (void *)((unsigned long)current_pid()),
-                    (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,
-                    (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,
-                    (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,
-                    (void *)NULL, (void *)NULL);
-}
-#else
-
-#define        xlog_trace_loggrant_alloc(log)
-#define        xlog_trace_loggrant_dealloc(log)
-#define        xlog_trace_loggrant(log,tic,string)
-
-#define        xlog_trace_iclog_alloc(iclog)
-#define        xlog_trace_iclog_dealloc(iclog)
-#define        xlog_trace_iclog(iclog,state)
-
-#endif /* XFS_LOG_TRACE */
-
 
 static void
 xlog_ins_ticketq(struct xlog_ticket **qp, struct xlog_ticket *tic)
@@ -353,15 +275,17 @@ xfs_log_done(xfs_mount_t  *mp,
 
        if ((ticket->t_flags & XLOG_TIC_PERM_RESERV) == 0 ||
            (flags & XFS_LOG_REL_PERM_RESERV)) {
+               trace_xfs_log_done_nonperm(log, ticket);
+
                /*
                 * Release ticket if not permanent reservation or a specific
                 * request has been made to release a permanent reservation.
                 */
-               xlog_trace_loggrant(log, ticket, "xfs_log_done: (non-permanent)");
                xlog_ungrant_log_space(log, ticket);
                xfs_log_ticket_put(ticket);
        } else {
-               xlog_trace_loggrant(log, ticket, "xfs_log_done: (permanent)");
+               trace_xfs_log_done_perm(log, ticket);
+
                xlog_regrant_reserve_log_space(log, ticket);
                /* If this ticket was a permanent reservation and we aren't
                 * trying to release it, reset the inited flags; so next time
@@ -505,10 +429,13 @@ xfs_log_reserve(xfs_mount_t        *mp,
 
        XFS_STATS_INC(xs_try_logspace);
 
+
        if (*ticket != NULL) {
                ASSERT(flags & XFS_LOG_PERM_RESERV);
                internal_ticket = (xlog_ticket_t *)*ticket;
-               xlog_trace_loggrant(log, internal_ticket, "xfs_log_reserve: existing ticket (permanent trans)");
+
+               trace_xfs_log_reserve(log, internal_ticket);
+
                xlog_grant_push_ail(mp, internal_ticket->t_unit_res);
                retval = xlog_regrant_write_log_space(log, internal_ticket);
        } else {
@@ -519,10 +446,9 @@ xfs_log_reserve(xfs_mount_t         *mp,
                        return XFS_ERROR(ENOMEM);
                internal_ticket->t_trans_type = t_type;
                *ticket = internal_ticket;
-               xlog_trace_loggrant(log, internal_ticket, 
-                       (internal_ticket->t_flags & XLOG_TIC_PERM_RESERV) ?
-                       "xfs_log_reserve: create new ticket (permanent trans)" :
-                       "xfs_log_reserve: create new ticket");
+
+               trace_xfs_log_reserve(log, internal_ticket);
+
                xlog_grant_push_ail(mp,
                                    (internal_ticket->t_unit_res *
                                     internal_ticket->t_cnt));
@@ -734,7 +660,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
                        spin_unlock(&log->l_icloglock);
                }
                if (tic) {
-                       xlog_trace_loggrant(log, tic, "unmount rec");
+                       trace_xfs_log_umount_write(log, tic);
                        xlog_ungrant_log_space(log, tic);
                        xfs_log_ticket_put(tic);
                }
@@ -1030,7 +956,6 @@ xlog_iodone(xfs_buf_t *bp)
                xfs_fs_cmn_err(CE_WARN, l->l_mp,
                                "xlog_iodone: Barriers are no longer supported"
                                " by device. Disabling barriers\n");
-               xfs_buftrace("XLOG_IODONE BARRIERS OFF", bp);
        }
 
        /*
@@ -1085,13 +1010,10 @@ xlog_bdstrat_cb(struct xfs_buf *bp)
                return 0;
        }
 
-       xfs_buftrace("XLOG__BDSTRAT IOERROR", bp);
        XFS_BUF_ERROR(bp, EIO);
        XFS_BUF_STALE(bp);
        xfs_biodone(bp);
        return XFS_ERROR(EIO);
-
-
 }
 
 /*
@@ -1246,7 +1168,6 @@ xlog_alloc_log(xfs_mount_t        *mp,
        spin_lock_init(&log->l_grant_lock);
        sv_init(&log->l_flush_wait, 0, "flush_wait");
 
-       xlog_trace_loggrant_alloc(log);
        /* log record size must be multiple of BBSIZE; see xlog_rec_header_t */
        ASSERT((XFS_BUF_SIZE(bp) & BBMASK) == 0);
 
@@ -1305,8 +1226,6 @@ xlog_alloc_log(xfs_mount_t        *mp,
                sv_init(&iclog->ic_force_wait, SV_DEFAULT, "iclog-force");
                sv_init(&iclog->ic_write_wait, SV_DEFAULT, "iclog-write");
 
-               xlog_trace_iclog_alloc(iclog);
-
                iclogp = &iclog->ic_next;
        }
        *iclogp = log->l_iclog;                 /* complete ring */
@@ -1321,13 +1240,11 @@ out_free_iclog:
                        sv_destroy(&iclog->ic_force_wait);
                        sv_destroy(&iclog->ic_write_wait);
                        xfs_buf_free(iclog->ic_bp);
-                       xlog_trace_iclog_dealloc(iclog);
                }
                kmem_free(iclog);
        }
        spinlock_destroy(&log->l_icloglock);
        spinlock_destroy(&log->l_grant_lock);
-       xlog_trace_loggrant_dealloc(log);
        xfs_buf_free(log->l_xbuf);
 out_free_log:
        kmem_free(log);
@@ -1524,6 +1441,7 @@ xlog_sync(xlog_t          *log,
        XFS_BUF_ZEROFLAGS(bp);
        XFS_BUF_BUSY(bp);
        XFS_BUF_ASYNC(bp);
+       bp->b_flags |= XBF_LOG_BUFFER;
        /*
         * Do an ordered write for the log block.
         * Its unnecessary to flush the first split block in the log wrap case.
@@ -1561,6 +1479,7 @@ xlog_sync(xlog_t          *log,
                XFS_BUF_ZEROFLAGS(bp);
                XFS_BUF_BUSY(bp);
                XFS_BUF_ASYNC(bp);
+               bp->b_flags |= XBF_LOG_BUFFER;
                if (log->l_mp->m_flags & XFS_MOUNT_BARRIER)
                        XFS_BUF_ORDERED(bp);
                dptr = XFS_BUF_PTR(bp);
@@ -1607,7 +1526,6 @@ xlog_dealloc_log(xlog_t *log)
                sv_destroy(&iclog->ic_force_wait);
                sv_destroy(&iclog->ic_write_wait);
                xfs_buf_free(iclog->ic_bp);
-               xlog_trace_iclog_dealloc(iclog);
                next_iclog = iclog->ic_next;
                kmem_free(iclog);
                iclog = next_iclog;
@@ -1616,7 +1534,6 @@ xlog_dealloc_log(xlog_t *log)
        spinlock_destroy(&log->l_grant_lock);
 
        xfs_buf_free(log->l_xbuf);
-       xlog_trace_loggrant_dealloc(log);
        log->l_mp->m_log = NULL;
        kmem_free(log);
 }      /* xlog_dealloc_log */
@@ -2414,7 +2331,6 @@ restart:
 
        iclog = log->l_iclog;
        if (iclog->ic_state != XLOG_STATE_ACTIVE) {
-               xlog_trace_iclog(iclog, XLOG_TRACE_SLEEP_FLUSH);
                XFS_STATS_INC(xs_log_noiclogs);
 
                /* Wait for log writes to have flushed */
@@ -2520,13 +2436,15 @@ xlog_grant_log_space(xlog_t        *log,
 
        /* Is there space or do we need to sleep? */
        spin_lock(&log->l_grant_lock);
-       xlog_trace_loggrant(log, tic, "xlog_grant_log_space: enter");
+
+       trace_xfs_log_grant_enter(log, tic);
 
        /* something is already sleeping; insert new transaction at end */
        if (log->l_reserve_headq) {
                xlog_ins_ticketq(&log->l_reserve_headq, tic);
-               xlog_trace_loggrant(log, tic,
-                                   "xlog_grant_log_space: sleep 1");
+
+               trace_xfs_log_grant_sleep1(log, tic);
+
                /*
                 * Gotta check this before going to sleep, while we're
                 * holding the grant lock.
@@ -2540,8 +2458,7 @@ xlog_grant_log_space(xlog_t          *log,
                 * If we got an error, and the filesystem is shutting down,
                 * we'll catch it down below. So just continue...
                 */
-               xlog_trace_loggrant(log, tic,
-                                   "xlog_grant_log_space: wake 1");
+               trace_xfs_log_grant_wake1(log, tic);
                spin_lock(&log->l_grant_lock);
        }
        if (tic->t_flags & XFS_LOG_PERM_RESERV)
@@ -2558,8 +2475,9 @@ redo:
        if (free_bytes < need_bytes) {
                if ((tic->t_flags & XLOG_TIC_IN_Q) == 0)
                        xlog_ins_ticketq(&log->l_reserve_headq, tic);
-               xlog_trace_loggrant(log, tic,
-                                   "xlog_grant_log_space: sleep 2");
+
+               trace_xfs_log_grant_sleep2(log, tic);
+
                spin_unlock(&log->l_grant_lock);
                xlog_grant_push_ail(log->l_mp, need_bytes);
                spin_lock(&log->l_grant_lock);
@@ -2571,8 +2489,8 @@ redo:
                if (XLOG_FORCED_SHUTDOWN(log))
                        goto error_return;
 
-               xlog_trace_loggrant(log, tic,
-                                   "xlog_grant_log_space: wake 2");
+               trace_xfs_log_grant_wake2(log, tic);
+
                goto redo;
        } else if (tic->t_flags & XLOG_TIC_IN_Q)
                xlog_del_ticketq(&log->l_reserve_headq, tic);
@@ -2592,7 +2510,7 @@ redo:
                ASSERT(log->l_grant_write_bytes <= BBTOB(BLOCK_LSN(tail_lsn)));
        }
 #endif
-       xlog_trace_loggrant(log, tic, "xlog_grant_log_space: exit");
+       trace_xfs_log_grant_exit(log, tic);
        xlog_verify_grant_head(log, 1);
        spin_unlock(&log->l_grant_lock);
        return 0;
@@ -2600,7 +2518,9 @@ redo:
  error_return:
        if (tic->t_flags & XLOG_TIC_IN_Q)
                xlog_del_ticketq(&log->l_reserve_headq, tic);
-       xlog_trace_loggrant(log, tic, "xlog_grant_log_space: err_ret");
+
+       trace_xfs_log_grant_error(log, tic);
+
        /*
         * If we are failing, make sure the ticket doesn't have any
         * current reservations. We don't want to add this back when
@@ -2640,7 +2560,8 @@ xlog_regrant_write_log_space(xlog_t          *log,
 #endif
 
        spin_lock(&log->l_grant_lock);
-       xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: enter");
+
+       trace_xfs_log_regrant_write_enter(log, tic);
 
        if (XLOG_FORCED_SHUTDOWN(log))
                goto error_return;
@@ -2669,8 +2590,8 @@ xlog_regrant_write_log_space(xlog_t          *log,
                        if ((tic->t_flags & XLOG_TIC_IN_Q) == 0)
                                xlog_ins_ticketq(&log->l_write_headq, tic);
 
-                       xlog_trace_loggrant(log, tic,
-                                   "xlog_regrant_write_log_space: sleep 1");
+                       trace_xfs_log_regrant_write_sleep1(log, tic);
+
                        spin_unlock(&log->l_grant_lock);
                        xlog_grant_push_ail(log->l_mp, need_bytes);
                        spin_lock(&log->l_grant_lock);
@@ -2685,8 +2606,7 @@ xlog_regrant_write_log_space(xlog_t          *log,
                        if (XLOG_FORCED_SHUTDOWN(log))
                                goto error_return;
 
-                       xlog_trace_loggrant(log, tic,
-                                   "xlog_regrant_write_log_space: wake 1");
+                       trace_xfs_log_regrant_write_wake1(log, tic);
                }
        }
 
@@ -2704,6 +2624,8 @@ redo:
                spin_lock(&log->l_grant_lock);
 
                XFS_STATS_INC(xs_sleep_logspace);
+               trace_xfs_log_regrant_write_sleep2(log, tic);
+
                sv_wait(&tic->t_wait, PINOD|PLTWAIT, &log->l_grant_lock, s);
 
                /* If we're shutting down, this tic is already off the queue */
@@ -2711,8 +2633,7 @@ redo:
                if (XLOG_FORCED_SHUTDOWN(log))
                        goto error_return;
 
-               xlog_trace_loggrant(log, tic,
-                                   "xlog_regrant_write_log_space: wake 2");
+               trace_xfs_log_regrant_write_wake2(log, tic);
                goto redo;
        } else if (tic->t_flags & XLOG_TIC_IN_Q)
                xlog_del_ticketq(&log->l_write_headq, tic);
@@ -2727,7 +2648,8 @@ redo:
        }
 #endif
 
-       xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: exit");
+       trace_xfs_log_regrant_write_exit(log, tic);
+
        xlog_verify_grant_head(log, 1);
        spin_unlock(&log->l_grant_lock);
        return 0;
@@ -2736,7 +2658,9 @@ redo:
  error_return:
        if (tic->t_flags & XLOG_TIC_IN_Q)
                xlog_del_ticketq(&log->l_reserve_headq, tic);
-       xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: err_ret");
+
+       trace_xfs_log_regrant_write_error(log, tic);
+
        /*
         * If we are failing, make sure the ticket doesn't have any
         * current reservations. We don't want to add this back when
@@ -2760,8 +2684,8 @@ STATIC void
 xlog_regrant_reserve_log_space(xlog_t       *log,
                               xlog_ticket_t *ticket)
 {
-       xlog_trace_loggrant(log, ticket,
-                           "xlog_regrant_reserve_log_space: enter");
+       trace_xfs_log_regrant_reserve_enter(log, ticket);
+
        if (ticket->t_cnt > 0)
                ticket->t_cnt--;
 
@@ -2769,8 +2693,9 @@ xlog_regrant_reserve_log_space(xlog_t          *log,
        xlog_grant_sub_space(log, ticket->t_curr_res);
        ticket->t_curr_res = ticket->t_unit_res;
        xlog_tic_reset_res(ticket);
-       xlog_trace_loggrant(log, ticket,
-                           "xlog_regrant_reserve_log_space: sub current res");
+
+       trace_xfs_log_regrant_reserve_sub(log, ticket);
+
        xlog_verify_grant_head(log, 1);
 
        /* just return if we still have some of the pre-reserved space */
@@ -2780,8 +2705,9 @@ xlog_regrant_reserve_log_space(xlog_t          *log,
        }
 
        xlog_grant_add_space_reserve(log, ticket->t_unit_res);
-       xlog_trace_loggrant(log, ticket,
-                           "xlog_regrant_reserve_log_space: exit");
+
+       trace_xfs_log_regrant_reserve_exit(log, ticket);
+
        xlog_verify_grant_head(log, 0);
        spin_unlock(&log->l_grant_lock);
        ticket->t_curr_res = ticket->t_unit_res;
@@ -2811,11 +2737,11 @@ xlog_ungrant_log_space(xlog_t        *log,
                ticket->t_cnt--;
 
        spin_lock(&log->l_grant_lock);
-       xlog_trace_loggrant(log, ticket, "xlog_ungrant_log_space: enter");
+       trace_xfs_log_ungrant_enter(log, ticket);
 
        xlog_grant_sub_space(log, ticket->t_curr_res);
 
-       xlog_trace_loggrant(log, ticket, "xlog_ungrant_log_space: sub current");
+       trace_xfs_log_ungrant_sub(log, ticket);
 
        /* If this is a permanent reservation ticket, we may be able to free
         * up more space based on the remaining count.
@@ -2825,7 +2751,8 @@ xlog_ungrant_log_space(xlog_t          *log,
                xlog_grant_sub_space(log, ticket->t_unit_res*ticket->t_cnt);
        }
 
-       xlog_trace_loggrant(log, ticket, "xlog_ungrant_log_space: exit");
+       trace_xfs_log_ungrant_exit(log, ticket);
+
        xlog_verify_grant_head(log, 1);
        spin_unlock(&log->l_grant_lock);
        xfs_log_move_tail(log->l_mp, 1);
index 679c7c4926a2a6e3858366704fa4d1b93887807c..d55662db7077780fd83619f046dd93693b3aad14 100644 (file)
@@ -19,7 +19,6 @@
 #define __XFS_LOG_PRIV_H__
 
 struct xfs_buf;
-struct ktrace;
 struct log;
 struct xlog_ticket;
 struct xfs_buf_cancel;
@@ -135,6 +134,12 @@ static inline uint xlog_get_client_id(__be32 i)
 #define XLOG_TIC_INITED                0x1     /* has been initialized */
 #define XLOG_TIC_PERM_RESERV   0x2     /* permanent reservation */
 #define XLOG_TIC_IN_Q          0x4
+
+#define XLOG_TIC_FLAGS \
+       { XLOG_TIC_INITED,      "XLOG_TIC_INITED" }, \
+       { XLOG_TIC_PERM_RESERV, "XLOG_TIC_PERM_RESERV" }, \
+       { XLOG_TIC_IN_Q,        "XLOG_TIC_IN_Q" }
+
 #endif /* __KERNEL__ */
 
 #define XLOG_UNMOUNT_TYPE      0x556e  /* Un for Unmount */
@@ -361,9 +366,6 @@ typedef struct xlog_in_core {
        int                     ic_bwritecnt;
        unsigned short          ic_state;
        char                    *ic_datap;      /* pointer to iclog data */
-#ifdef XFS_LOG_TRACE
-       struct ktrace           *ic_trace;
-#endif
 
        /* Callback structures need their own cacheline */
        spinlock_t              ic_callback_lock ____cacheline_aligned_in_smp;
@@ -429,10 +431,6 @@ typedef struct log {
        int                     l_grant_write_cycle;
        int                     l_grant_write_bytes;
 
-#ifdef XFS_LOG_TRACE
-       struct ktrace           *l_grant_trace;
-#endif
-
        /* The following field are used for debugging; need to hold icloglock */
 #ifdef DEBUG
        char                    *l_iclog_bak[XLOG_MAX_ICLOGS];
@@ -456,12 +454,6 @@ extern void         xlog_put_bp(struct xfs_buf *);
 
 extern kmem_zone_t     *xfs_log_ticket_zone;
 
-/* iclog tracing */
-#define XLOG_TRACE_GRAB_FLUSH  1
-#define XLOG_TRACE_REL_FLUSH   2
-#define XLOG_TRACE_SLEEP_FLUSH 3
-#define XLOG_TRACE_WAKE_FLUSH  4
-
 /*
  * Unmount record type is used as a pseudo transaction type for the ticket.
  * It's value must be outside the range of XFS_TRANS_* values.
index 1ec98ed914d4c951461dcff2ff4ae1a23fa2d55c..69ac2e5ef20c6197d0ef47225ddeda77897e1743 100644 (file)
@@ -46,6 +46,7 @@
 #include "xfs_quota.h"
 #include "xfs_rw.h"
 #include "xfs_utils.h"
+#include "xfs_trace.h"
 
 STATIC int     xlog_find_zeroed(xlog_t *, xfs_daddr_t *);
 STATIC int     xlog_clear_stale_blocks(xlog_t *, xfs_lsn_t);
@@ -225,16 +226,10 @@ xlog_header_check_dump(
        xfs_mount_t             *mp,
        xlog_rec_header_t       *head)
 {
-       int                     b;
-
-       cmn_err(CE_DEBUG, "%s:  SB : uuid = ", __func__);
-       for (b = 0; b < 16; b++)
-               cmn_err(CE_DEBUG, "%02x", ((__uint8_t *)&mp->m_sb.sb_uuid)[b]);
-       cmn_err(CE_DEBUG, ", fmt = %d\n", XLOG_FMT);
-       cmn_err(CE_DEBUG, "    log : uuid = ");
-       for (b = 0; b < 16; b++)
-               cmn_err(CE_DEBUG, "%02x", ((__uint8_t *)&head->h_fs_uuid)[b]);
-       cmn_err(CE_DEBUG, ", fmt = %d\n", be32_to_cpu(head->h_fmt));
+       cmn_err(CE_DEBUG, "%s:  SB : uuid = %pU, fmt = %d\n",
+               __func__, &mp->m_sb.sb_uuid, XLOG_FMT);
+       cmn_err(CE_DEBUG, "    log : uuid = %pU, fmt = %d\n",
+               &head->h_fs_uuid, be32_to_cpu(head->h_fmt));
 }
 #else
 #define xlog_header_check_dump(mp, head)
index bfffd6334abbfae37d804174241bc1a1c17760d3..eb403b40e120d5f20661445b7fab21a58a8c31bd 100644 (file)
@@ -44,6 +44,8 @@
 #include "xfs_quota.h"
 #include "xfs_fsops.h"
 #include "xfs_utils.h"
+#include "xfs_trace.h"
+
 
 STATIC void    xfs_unmountfs_wait(xfs_mount_t *);
 
index 3ec91ac74c2af0182ff4bbc0839d100a99347947..91bfd60f4c74b582bf3c0a0e17197537dfcb20cf 100644 (file)
@@ -92,6 +92,14 @@ typedef struct xfs_dqblk {
 
 #define XFS_DQ_ALLTYPES                (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP)
 
+#define XFS_DQ_FLAGS \
+       { XFS_DQ_USER,          "USER" }, \
+       { XFS_DQ_PROJ,          "PROJ" }, \
+       { XFS_DQ_GROUP,         "GROUP" }, \
+       { XFS_DQ_DIRTY,         "DIRTY" }, \
+       { XFS_DQ_WANT,          "WANT" }, \
+       { XFS_DQ_INACTIVE,      "INACTIVE" }
+
 /*
  * In the worst case, when both user and group quotas are on,
  * we can have a max of three dquots changing in a single transaction.
index b81deea0ce1944ec4f34e0a1b020128274eaf4e4..fc1cda23b8171552ff6fd99d34adebf6be782bb3 100644 (file)
@@ -39,6 +39,7 @@
 #include "xfs_utils.h"
 #include "xfs_trans_space.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 
 /*
index 385f6dceba5db357a8bf7361fc24adde3e1185a2..9e15a11853623838b91894b2a89f3778211511f4 100644 (file)
@@ -45,6 +45,7 @@
 #include "xfs_inode_item.h"
 #include "xfs_trans_space.h"
 #include "xfs_utils.h"
+#include "xfs_trace.h"
 
 
 /*
index 4c199d18f8505a774da899dcbb097599ec0e08f7..5aa07caea5f15b06b607f222be591f49e16ff7bd 100644 (file)
@@ -44,6 +44,7 @@
 #include "xfs_error.h"
 #include "xfs_buf_item.h"
 #include "xfs_rw.h"
+#include "xfs_trace.h"
 
 /*
  * This is a subroutine for xfs_write() and other writers (xfs_ioctl)
@@ -171,7 +172,6 @@ xfs_bioerror(
         * No need to wait until the buffer is unpinned.
         * We aren't flushing it.
         */
-       xfs_buftrace("XFS IOERROR", bp);
        XFS_BUF_ERROR(bp, EIO);
        /*
         * We're calling biodone, so delete B_DONE flag. Either way
@@ -205,7 +205,6 @@ xfs_bioerror_relse(
        ASSERT(XFS_BUF_IODONE_FUNC(bp) != xfs_buf_iodone_callbacks);
        ASSERT(XFS_BUF_IODONE_FUNC(bp) != xlog_iodone);
 
-       xfs_buftrace("XFS IOERRELSE", bp);
        fl = XFS_BUF_BFLAGS(bp);
        /*
         * No need to wait until the buffer is unpinned.
index a0574f593f5272764adf820c12ad724c9d90011e..ca64f33c63a30530666b7b9ee0a681765929072f 100644 (file)
@@ -100,6 +100,49 @@ typedef struct xfs_trans_header {
 #define        XFS_TRANS_TYPE_MAX              41
 /* new transaction types need to be reflected in xfs_logprint(8) */
 
+#define XFS_TRANS_TYPES \
+       { XFS_TRANS_SETATTR_NOT_SIZE,   "SETATTR_NOT_SIZE" }, \
+       { XFS_TRANS_SETATTR_SIZE,       "SETATTR_SIZE" }, \
+       { XFS_TRANS_INACTIVE,           "INACTIVE" }, \
+       { XFS_TRANS_CREATE,             "CREATE" }, \
+       { XFS_TRANS_CREATE_TRUNC,       "CREATE_TRUNC" }, \
+       { XFS_TRANS_TRUNCATE_FILE,      "TRUNCATE_FILE" }, \
+       { XFS_TRANS_REMOVE,             "REMOVE" }, \
+       { XFS_TRANS_LINK,               "LINK" }, \
+       { XFS_TRANS_RENAME,             "RENAME" }, \
+       { XFS_TRANS_MKDIR,              "MKDIR" }, \
+       { XFS_TRANS_RMDIR,              "RMDIR" }, \
+       { XFS_TRANS_SYMLINK,            "SYMLINK" }, \
+       { XFS_TRANS_SET_DMATTRS,        "SET_DMATTRS" }, \
+       { XFS_TRANS_GROWFS,             "GROWFS" }, \
+       { XFS_TRANS_STRAT_WRITE,        "STRAT_WRITE" }, \
+       { XFS_TRANS_DIOSTRAT,           "DIOSTRAT" }, \
+       { XFS_TRANS_WRITEID,            "WRITEID" }, \
+       { XFS_TRANS_ADDAFORK,           "ADDAFORK" }, \
+       { XFS_TRANS_ATTRINVAL,          "ATTRINVAL" }, \
+       { XFS_TRANS_ATRUNCATE,          "ATRUNCATE" }, \
+       { XFS_TRANS_ATTR_SET,           "ATTR_SET" }, \
+       { XFS_TRANS_ATTR_RM,            "ATTR_RM" }, \
+       { XFS_TRANS_ATTR_FLAG,          "ATTR_FLAG" }, \
+       { XFS_TRANS_CLEAR_AGI_BUCKET,   "CLEAR_AGI_BUCKET" }, \
+       { XFS_TRANS_QM_SBCHANGE,        "QM_SBCHANGE" }, \
+       { XFS_TRANS_QM_QUOTAOFF,        "QM_QUOTAOFF" }, \
+       { XFS_TRANS_QM_DQALLOC,         "QM_DQALLOC" }, \
+       { XFS_TRANS_QM_SETQLIM,         "QM_SETQLIM" }, \
+       { XFS_TRANS_QM_DQCLUSTER,       "QM_DQCLUSTER" }, \
+       { XFS_TRANS_QM_QINOCREATE,      "QM_QINOCREATE" }, \
+       { XFS_TRANS_QM_QUOTAOFF_END,    "QM_QOFF_END" }, \
+       { XFS_TRANS_SB_UNIT,            "SB_UNIT" }, \
+       { XFS_TRANS_FSYNC_TS,           "FSYNC_TS" }, \
+       { XFS_TRANS_GROWFSRT_ALLOC,     "GROWFSRT_ALLOC" }, \
+       { XFS_TRANS_GROWFSRT_ZERO,      "GROWFSRT_ZERO" }, \
+       { XFS_TRANS_GROWFSRT_FREE,      "GROWFSRT_FREE" }, \
+       { XFS_TRANS_SWAPEXT,            "SWAPEXT" }, \
+       { XFS_TRANS_SB_COUNT,           "SB_COUNT" }, \
+       { XFS_TRANS_DUMMY1,             "DUMMY1" }, \
+       { XFS_TRANS_DUMMY2,             "DUMMY2" }, \
+       { XLOG_UNMOUNT_REC_TYPE,        "UNMOUNT" }
+
 /*
  * This structure is used to track log items associated with
  * a transaction.  It points to the log item and keeps some
@@ -782,6 +825,10 @@ typedef struct xfs_log_item {
 #define        XFS_LI_IN_AIL   0x1
 #define XFS_LI_ABORTED 0x2
 
+#define XFS_LI_FLAGS \
+       { XFS_LI_IN_AIL,        "IN_AIL" }, \
+       { XFS_LI_ABORTED,       "ABORTED" }
+
 typedef struct xfs_item_ops {
        uint (*iop_size)(xfs_log_item_t *);
        void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *);
index 03a1f701fea8aaaae39cc36df9306750d262988c..49130628d5efdbcc961dbe0e66e64fd5397846de 100644 (file)
@@ -38,6 +38,7 @@
 #include "xfs_trans_priv.h"
 #include "xfs_error.h"
 #include "xfs_rw.h"
+#include "xfs_trace.h"
 
 
 STATIC xfs_buf_t *xfs_trans_buf_item_match(xfs_trans_t *, xfs_buftarg_t *,
@@ -95,26 +96,23 @@ xfs_trans_get_buf(xfs_trans_t       *tp,
        }
        if (bp != NULL) {
                ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
-               if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) {
-                       xfs_buftrace("TRANS GET RECUR SHUT", bp);
+               if (XFS_FORCED_SHUTDOWN(tp->t_mountp))
                        XFS_BUF_SUPER_STALE(bp);
-               }
+
                /*
                 * If the buffer is stale then it was binval'ed
                 * since last read.  This doesn't matter since the
                 * caller isn't allowed to use the data anyway.
                 */
-               else if (XFS_BUF_ISSTALE(bp)) {
-                       xfs_buftrace("TRANS GET RECUR STALE", bp);
+               else if (XFS_BUF_ISSTALE(bp))
                        ASSERT(!XFS_BUF_ISDELAYWRITE(bp));
-               }
+
                ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp);
                bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
                ASSERT(bip != NULL);
                ASSERT(atomic_read(&bip->bli_refcount) > 0);
                bip->bli_recur++;
-               xfs_buftrace("TRANS GET RECUR", bp);
-               xfs_buf_item_trace("GET RECUR", bip);
+               trace_xfs_trans_get_buf_recur(bip);
                return (bp);
        }
 
@@ -166,8 +164,7 @@ xfs_trans_get_buf(xfs_trans_t       *tp,
         */
        XFS_BUF_SET_FSPRIVATE2(bp, tp);
 
-       xfs_buftrace("TRANS GET", bp);
-       xfs_buf_item_trace("GET", bip);
+       trace_xfs_trans_get_buf(bip);
        return (bp);
 }
 
@@ -207,7 +204,7 @@ xfs_trans_getsb(xfs_trans_t *tp,
                ASSERT(bip != NULL);
                ASSERT(atomic_read(&bip->bli_refcount) > 0);
                bip->bli_recur++;
-               xfs_buf_item_trace("GETSB RECUR", bip);
+               trace_xfs_trans_getsb_recur(bip);
                return (bp);
        }
 
@@ -249,7 +246,7 @@ xfs_trans_getsb(xfs_trans_t *tp,
         */
        XFS_BUF_SET_FSPRIVATE2(bp, tp);
 
-       xfs_buf_item_trace("GETSB", bip);
+       trace_xfs_trans_getsb(bip);
        return (bp);
 }
 
@@ -347,7 +344,7 @@ xfs_trans_read_buf(
                ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL);
                ASSERT((XFS_BUF_ISERROR(bp)) == 0);
                if (!(XFS_BUF_ISDONE(bp))) {
-                       xfs_buftrace("READ_BUF_INCORE !DONE", bp);
+                       trace_xfs_trans_read_buf_io(bp, _RET_IP_);
                        ASSERT(!XFS_BUF_ISASYNC(bp));
                        XFS_BUF_READ(bp);
                        xfsbdstrat(tp->t_mountp, bp);
@@ -372,7 +369,7 @@ xfs_trans_read_buf(
                 * brelse it either. Just get out.
                 */
                if (XFS_FORCED_SHUTDOWN(mp)) {
-                       xfs_buftrace("READ_BUF_INCORE XFSSHUTDN", bp);
+                       trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
                        *bpp = NULL;
                        return XFS_ERROR(EIO);
                }
@@ -382,7 +379,7 @@ xfs_trans_read_buf(
                bip->bli_recur++;
 
                ASSERT(atomic_read(&bip->bli_refcount) > 0);
-               xfs_buf_item_trace("READ RECUR", bip);
+               trace_xfs_trans_read_buf_recur(bip);
                *bpp = bp;
                return 0;
        }
@@ -402,7 +399,6 @@ xfs_trans_read_buf(
        }
        if (XFS_BUF_GETERROR(bp) != 0) {
            XFS_BUF_SUPER_STALE(bp);
-               xfs_buftrace("READ ERROR", bp);
                error = XFS_BUF_GETERROR(bp);
 
                xfs_ioerror_alert("xfs_trans_read_buf", mp,
@@ -461,8 +457,7 @@ xfs_trans_read_buf(
         */
        XFS_BUF_SET_FSPRIVATE2(bp, tp);
 
-       xfs_buftrace("TRANS READ", bp);
-       xfs_buf_item_trace("READ", bip);
+       trace_xfs_trans_read_buf(bip);
        *bpp = bp;
        return 0;
 
@@ -480,7 +475,7 @@ shutdown_abort:
        ASSERT((XFS_BUF_BFLAGS(bp) & (XFS_B_STALE|XFS_B_DELWRI)) !=
                                                (XFS_B_STALE|XFS_B_DELWRI));
 
-       xfs_buftrace("READ_BUF XFSSHUTDN", bp);
+       trace_xfs_trans_read_buf_shut(bp, _RET_IP_);
        xfs_buf_relse(bp);
        *bpp = NULL;
        return XFS_ERROR(EIO);
@@ -546,13 +541,14 @@ xfs_trans_brelse(xfs_trans_t      *tp,
        lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip);
        ASSERT(lidp != NULL);
 
+       trace_xfs_trans_brelse(bip);
+
        /*
         * If the release is just for a recursive lock,
         * then decrement the count and return.
         */
        if (bip->bli_recur > 0) {
                bip->bli_recur--;
-               xfs_buf_item_trace("RELSE RECUR", bip);
                return;
        }
 
@@ -560,10 +556,8 @@ xfs_trans_brelse(xfs_trans_t       *tp,
         * If the buffer is dirty within this transaction, we can't
         * release it until we commit.
         */
-       if (lidp->lid_flags & XFS_LID_DIRTY) {
-               xfs_buf_item_trace("RELSE DIRTY", bip);
+       if (lidp->lid_flags & XFS_LID_DIRTY)
                return;
-       }
 
        /*
         * If the buffer has been invalidated, then we can't release
@@ -571,13 +565,10 @@ xfs_trans_brelse(xfs_trans_t      *tp,
         * as part of this transaction.  This prevents us from pulling
         * the item from the AIL before we should.
         */
-       if (bip->bli_flags & XFS_BLI_STALE) {
-               xfs_buf_item_trace("RELSE STALE", bip);
+       if (bip->bli_flags & XFS_BLI_STALE)
                return;
-       }
 
        ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
-       xfs_buf_item_trace("RELSE", bip);
 
        /*
         * Free up the log item descriptor tracking the released item.
@@ -674,7 +665,7 @@ xfs_trans_bjoin(xfs_trans_t *tp,
         */
        XFS_BUF_SET_FSPRIVATE2(bp, tp);
 
-       xfs_buf_item_trace("BJOIN", bip);
+       trace_xfs_trans_bjoin(bip);
 }
 
 /*
@@ -698,7 +689,7 @@ xfs_trans_bhold(xfs_trans_t *tp,
        ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL));
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
        bip->bli_flags |= XFS_BLI_HOLD;
-       xfs_buf_item_trace("BHOLD", bip);
+       trace_xfs_trans_bhold(bip);
 }
 
 /*
@@ -721,7 +712,8 @@ xfs_trans_bhold_release(xfs_trans_t *tp,
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
        ASSERT(bip->bli_flags & XFS_BLI_HOLD);
        bip->bli_flags &= ~XFS_BLI_HOLD;
-       xfs_buf_item_trace("BHOLD RELEASE", bip);
+
+       trace_xfs_trans_bhold_release(bip);
 }
 
 /*
@@ -767,6 +759,8 @@ xfs_trans_log_buf(xfs_trans_t       *tp,
        XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks);
        bip->bli_item.li_cb = (void(*)(xfs_buf_t*,xfs_log_item_t*))xfs_buf_iodone;
 
+       trace_xfs_trans_log_buf(bip);
+
        /*
         * If we invalidated the buffer within this transaction, then
         * cancel the invalidation now that we're dirtying the buffer
@@ -774,7 +768,6 @@ xfs_trans_log_buf(xfs_trans_t       *tp,
         * because we have a reference to the buffer this entire time.
         */
        if (bip->bli_flags & XFS_BLI_STALE) {
-               xfs_buf_item_trace("BLOG UNSTALE", bip);
                bip->bli_flags &= ~XFS_BLI_STALE;
                ASSERT(XFS_BUF_ISSTALE(bp));
                XFS_BUF_UNSTALE(bp);
@@ -789,7 +782,6 @@ xfs_trans_log_buf(xfs_trans_t       *tp,
        lidp->lid_flags &= ~XFS_LID_BUF_STALE;
        bip->bli_flags |= XFS_BLI_LOGGED;
        xfs_buf_item_log(bip, first, last);
-       xfs_buf_item_trace("BLOG", bip);
 }
 
 
@@ -828,6 +820,8 @@ xfs_trans_binval(
        ASSERT(lidp != NULL);
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
 
+       trace_xfs_trans_binval(bip);
+
        if (bip->bli_flags & XFS_BLI_STALE) {
                /*
                 * If the buffer is already invalidated, then
@@ -840,8 +834,6 @@ xfs_trans_binval(
                ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL);
                ASSERT(lidp->lid_flags & XFS_LID_DIRTY);
                ASSERT(tp->t_flags & XFS_TRANS_DIRTY);
-               xfs_buftrace("XFS_BINVAL RECUR", bp);
-               xfs_buf_item_trace("BINVAL RECUR", bip);
                return;
        }
 
@@ -875,8 +867,6 @@ xfs_trans_binval(
              (bip->bli_format.blf_map_size * sizeof(uint)));
        lidp->lid_flags |= XFS_LID_DIRTY|XFS_LID_BUF_STALE;
        tp->t_flags |= XFS_TRANS_DIRTY;
-       xfs_buftrace("XFS_BINVAL", bp);
-       xfs_buf_item_trace("BINVAL", bip);
 }
 
 /*
index 578f3f59b789e7783c1c33343e0b8579eab46048..6558ffd8d140683bdb1eaebb0e201dcdba3b04e7 100644 (file)
@@ -53,6 +53,7 @@
 #include "xfs_log_priv.h"
 #include "xfs_filestream.h"
 #include "xfs_vnodeops.h"
+#include "xfs_trace.h"
 
 int
 xfs_setattr(
@@ -1397,7 +1398,6 @@ xfs_lookup(
        if (error)
                goto out_free_name;
 
-       xfs_itrace_ref(*ipp);
        return 0;
 
 out_free_name:
@@ -1543,7 +1543,6 @@ xfs_create(
         * At this point, we've gotten a newly allocated inode.
         * It is locked (and joined to the transaction).
         */
-       xfs_itrace_ref(ip);
        ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
 
        /*
@@ -2003,9 +2002,6 @@ xfs_remove(
        if (!is_dir && link_zero && xfs_inode_is_filestream(ip))
                xfs_filestream_deassociate(ip);
 
-       xfs_itrace_exit(ip);
-       xfs_itrace_exit(dp);
-
  std_return:
        if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTREMOVE)) {
                XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, dp, DM_RIGHT_NULL,
@@ -2302,7 +2298,6 @@ xfs_symlink(
                        goto error_return;
                goto error1;
        }
-       xfs_itrace_ref(ip);
 
        /*
         * An error after we've joined dp to the transaction will result in the
@@ -2845,7 +2840,6 @@ xfs_free_file_space(
        ioffset = offset & ~(rounding - 1);
 
        if (VN_CACHED(VFS_I(ip)) != 0) {
-               xfs_inval_cached_trace(ip, ioffset, -1, ioffset, -1);
                error = xfs_flushinval_pages(ip, ioffset, -1, FI_REMAPF_LOCKED);
                if (error)
                        goto out_unlock_iolock;
index 5c823d5ab7839f003f34f702992411f35d0e0a21..d814da4b5365dbcd0ccb5cc978b775c8ad27ab6c 100644 (file)
@@ -85,7 +85,8 @@
 #define ACPI_LV_INIT                0x00000001
 #define ACPI_LV_DEBUG_OBJECT        0x00000002
 #define ACPI_LV_INFO                0x00000004
-#define ACPI_LV_ALL_EXCEPTIONS      0x00000007
+#define ACPI_LV_REPAIR              0x00000008
+#define ACPI_LV_ALL_EXCEPTIONS      0x0000000F
 
 /* Trace verbosity level 1 [Standard Trace Level] */
 
 #define ACPI_DB_INIT                ACPI_DEBUG_LEVEL (ACPI_LV_INIT)
 #define ACPI_DB_DEBUG_OBJECT        ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT)
 #define ACPI_DB_INFO                ACPI_DEBUG_LEVEL (ACPI_LV_INFO)
+#define ACPI_DB_REPAIR              ACPI_DEBUG_LEVEL (ACPI_LV_REPAIR)
 #define ACPI_DB_ALL_EXCEPTIONS      ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS)
 
 /* Trace level -- also used in the global "DebugLevel" */
 
 /* Defaults for debug_level, debug and normal */
 
-#define ACPI_DEBUG_DEFAULT          (ACPI_LV_INFO)
-#define ACPI_NORMAL_DEFAULT         (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT)
+#define ACPI_DEBUG_DEFAULT          (ACPI_LV_INFO | ACPI_LV_REPAIR)
+#define ACPI_NORMAL_DEFAULT         (ACPI_LV_INIT | ACPI_LV_DEBUG_OBJECT | ACPI_LV_REPAIR)
 #define ACPI_DEBUG_ALL              (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
 
 #if defined (ACPI_DEBUG_OUTPUT) || !defined (ACPI_NO_ERROR_MESSAGES)
index 5e1ad3cd1bbdceb2c9cfb2fff64948fe04b72a2c..86e9735a96bd3df7a57e8af1a44a3eca78715fe5 100644 (file)
@@ -47,7 +47,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20091112
+#define ACPI_CA_VERSION                 0x20091214
 
 #include "actypes.h"
 #include "actbl.h"
index 8b668ead6d6e84a55f7cd9c743524cbeace28e1a..0ea5ef4eb6a94aaaa593003d0138ce1381f13e89 100644 (file)
@@ -224,8 +224,6 @@ struct acpi_processor {
        struct acpi_processor_throttling throttling;
        struct acpi_processor_limit limit;
        struct thermal_cooling_device *cdev;
-       /* the _PDC objects for this processor, if any */
-       struct acpi_object_list *pdc;
 };
 
 struct acpi_processor_errata {
@@ -257,9 +255,6 @@ int acpi_processor_notify_smm(struct module *calling_module);
 DECLARE_PER_CPU(struct acpi_processor *, processors);
 extern struct acpi_processor_errata errata;
 
-void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
-void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr);
-
 #ifdef ARCH_HAS_POWER_INIT
 void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
                                        unsigned int cpu);
@@ -294,7 +289,7 @@ static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
 #ifdef CONFIG_CPU_FREQ
 void acpi_processor_ppc_init(void);
 void acpi_processor_ppc_exit(void);
-int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
+int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag);
 extern int acpi_processor_get_bios_limit(int cpu, unsigned int *limit);
 #else
 static inline void acpi_processor_ppc_init(void)
@@ -305,7 +300,8 @@ static inline void acpi_processor_ppc_exit(void)
 {
        return;
 }
-static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
+static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr,
+                                                               int event_flag)
 {
        static unsigned int printout = 1;
        if (printout) {
@@ -324,6 +320,9 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
 
 #endif                         /* CONFIG_CPU_FREQ */
 
+/* in processor_pdc.c */
+void acpi_processor_set_pdc(acpi_handle handle);
+
 /* in processor_throttling.c */
 int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
 int acpi_processor_get_throttling_info(struct acpi_processor *pr);
index c8946465e63ac872113c74241e06028aba8086f3..ecc44a8e2b4466fbbf86b5a1e374ae15b2ef50aa 100644 (file)
 #  define ATOMIC_HASH_SIZE 4
 #  define ATOMIC_HASH(a) (&(__atomic_hash[ (((unsigned long) a)/L1_CACHE_BYTES) & (ATOMIC_HASH_SIZE-1) ]))
 
-extern raw_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
+extern arch_spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] __lock_aligned;
 
 /* Can't use raw_spin_lock_irq because of #include problems, so
  * this is the substitute */
 #define _atomic_spin_lock_irqsave(l,f) do {    \
-       raw_spinlock_t *s = ATOMIC_HASH(l);     \
+       arch_spinlock_t *s = ATOMIC_HASH(l);    \
        local_irq_save(f);                      \
-       __raw_spin_lock(s);                     \
+       arch_spin_lock(s);                      \
 } while(0)
 
 #define _atomic_spin_unlock_irqrestore(l,f) do {       \
-       raw_spinlock_t *s = ATOMIC_HASH(l);             \
-       __raw_spin_unlock(s);                           \
+       arch_spinlock_t *s = ATOMIC_HASH(l);            \
+       arch_spin_unlock(s);                            \
        local_irq_restore(f);                           \
 } while(0)
 
index 4b6755984d241261941334dcf5f8c8431a5c6e54..18c435d7c082e387fdeca7a436e1e98f7ee3c2e3 100644 (file)
@@ -113,22 +113,22 @@ extern void warn_slowpath_null(const char *file, const int line);
 #endif
 
 #define WARN_ON_ONCE(condition)        ({                              \
-       static int __warned;                                    \
+       static bool __warned;                                   \
        int __ret_warn_once = !!(condition);                    \
                                                                \
        if (unlikely(__ret_warn_once))                          \
                if (WARN_ON(!__warned))                         \
-                       __warned = 1;                           \
+                       __warned = true;                        \
        unlikely(__ret_warn_once);                              \
 })
 
 #define WARN_ONCE(condition, format...)        ({                      \
-       static int __warned;                                    \
+       static bool __warned;                                   \
        int __ret_warn_once = !!(condition);                    \
                                                                \
        if (unlikely(__ret_warn_once))                          \
                if (WARN(!__warned, format))                    \
-                       __warned = 1;                           \
+                       __warned = true;                        \
        unlikely(__ret_warn_once);                              \
 })
 
index 681ddf3e844c1fde1c1db04dbfe1629daaaf9108..fcd268ce06744ab616aeb6a5e429c723426906f6 100644 (file)
@@ -51,7 +51,7 @@
 #endif
 
 /*
- * Before Linux 2.6.32 only O_DSYNC semantics were implemented, but using
+ * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using
  * the O_SYNC flag.  We continue to use the existing numerical value
  * for O_DSYNC semantics now, but using the correct symbolic name for it.
  * This new value is used to request true Posix O_SYNC semantics.  It is
index 204bed37e82d3b090ca20f2030fbf9d3870a5446..485eeb6c4ef3da76a15777943c62f890ea79b99f 100644 (file)
@@ -145,6 +145,7 @@ extern int __gpio_to_irq(unsigned gpio);
 extern int gpio_export(unsigned gpio, bool direction_may_change);
 extern int gpio_export_link(struct device *dev, const char *name,
                        unsigned gpio);
+extern int gpio_sysfs_set_active_low(unsigned gpio, int value);
 extern void gpio_unexport(unsigned gpio);
 
 #endif /* CONFIG_GPIO_SYSFS */
@@ -197,6 +198,11 @@ static inline int gpio_export_link(struct device *dev, const char *name,
        return -ENOSYS;
 }
 
+static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
+{
+       return -ENOSYS;
+}
+
 static inline void gpio_unexport(unsigned gpio)
 {
 }
index 5ee13b2fd223599422446b509227eadb24b7f7e8..3da9e2742fa0ec2e7c80a0490ec7c783bdda7f7b 100644 (file)
 #define MAP_TYPE       0x0f            /* Mask for type of mapping */
 #define MAP_FIXED      0x10            /* Interpret addr exactly */
 #define MAP_ANONYMOUS  0x20            /* don't use a file */
+#ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED
+# define MAP_UNINITIALIZED 0x4000000   /* For anonymous mmap, memory could be uninitialized */
+#else
+# define MAP_UNINITIALIZED 0x0         /* Don't support this flag */
+#endif
 
 #define MS_ASYNC       1               /* sync memory asynchronously */
 #define MS_INVALIDATE  2               /* invalidate the caches */
@@ -35,6 +40,7 @@
 #define MADV_DONTFORK  10              /* don't inherit across fork */
 #define MADV_DOFORK    11              /* do inherit across fork */
 #define MADV_HWPOISON  100             /* poison a page for testing */
+#define MADV_SOFT_OFFLINE 101          /* soft offline page for testing */
 
 #define MADV_MERGEABLE   12            /* KSM may merge identical pages */
 #define MADV_UNMERGEABLE 13            /* KSM may not merge identical pages */
index b6e818f4b24756a4a7eeb570260a9894490acb4c..67e652068e0e45b8031cafd2fb236be5e692c7c4 100644 (file)
 #define LOAD_OFFSET 0
 #endif
 
-#ifndef VMLINUX_SYMBOL
-#define VMLINUX_SYMBOL(_sym_) _sym_
+#ifndef SYMBOL_PREFIX
+#define VMLINUX_SYMBOL(sym) sym
+#else
+#define PASTE2(x,y) x##y
+#define PASTE(x,y) PASTE2(x,y)
+#define VMLINUX_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym)
 #endif
 
 /* Align . to a 8 byte boundary equals to maximum function alignment. */
index cfa6af43c9ea49b0d9e00768f1b0a2027b9dd699..bd3a1c2fbdb40f342d026c766d90eaecc891fa23 100644 (file)
@@ -7,5 +7,6 @@ unifdef-y += r128_drm.h
 unifdef-y += radeon_drm.h
 unifdef-y += sis_drm.h
 unifdef-y += savage_drm.h
+unifdef-y += vmwgfx_drm.h
 unifdef-y += via_drm.h
 unifdef-y += nouveau_drm.h
index 19ef8ebdc6621c24346b5354764a7d9ba98848f8..71dafb69cfeb2fc5baf60d639f6c3210a826cc2d 100644 (file)
@@ -296,6 +296,7 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
 #define        DRM_MASTER      0x2
 #define DRM_ROOT_ONLY  0x4
 #define DRM_CONTROL_ALLOW 0x8
+#define DRM_UNLOCKED   0x10
 
 struct drm_ioctl_desc {
        unsigned int cmd;
@@ -1128,8 +1129,8 @@ static inline int drm_mtrr_del(int handle, unsigned long offset,
                                /* Driver support (drm_drv.h) */
 extern int drm_init(struct drm_driver *driver);
 extern void drm_exit(struct drm_driver *driver);
-extern int drm_ioctl(struct inode *inode, struct file *filp,
-                    unsigned int cmd, unsigned long arg);
+extern long drm_ioctl(struct file *filp,
+                     unsigned int cmd, unsigned long arg);
 extern long drm_compat_ioctl(struct file *filp,
                             unsigned int cmd, unsigned long arg);
 extern int drm_lastclose(struct drm_device *dev);
index 703ca4db0a297615f84064ee736ddd191b5f3b83..0d9db099978b778e14301f04dac41a197d7ec88a 100644 (file)
@@ -77,7 +77,11 @@ enum ttm_object_type {
        ttm_buffer_type,
        ttm_lock_type,
        ttm_driver_type0 = 256,
-       ttm_driver_type1
+       ttm_driver_type1,
+       ttm_driver_type2,
+       ttm_driver_type3,
+       ttm_driver_type4,
+       ttm_driver_type5
 };
 
 struct ttm_object_file;
diff --git a/include/drm/vmwgfx_drm.h b/include/drm/vmwgfx_drm.h
new file mode 100644 (file)
index 0000000..2be7e12
--- /dev/null
@@ -0,0 +1,574 @@
+/**************************************************************************
+ *
+ * Copyright Â© 2009 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef __VMWGFX_DRM_H__
+#define __VMWGFX_DRM_H__
+
+#define DRM_VMW_MAX_SURFACE_FACES 6
+#define DRM_VMW_MAX_MIP_LEVELS 24
+
+#define DRM_VMW_EXT_NAME_LEN 128
+
+#define DRM_VMW_GET_PARAM            0
+#define DRM_VMW_ALLOC_DMABUF         1
+#define DRM_VMW_UNREF_DMABUF         2
+#define DRM_VMW_CURSOR_BYPASS        3
+/* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
+#define DRM_VMW_CONTROL_STREAM       4
+#define DRM_VMW_CLAIM_STREAM         5
+#define DRM_VMW_UNREF_STREAM         6
+/* guarded by DRM_VMW_PARAM_3D == 1 */
+#define DRM_VMW_CREATE_CONTEXT       7
+#define DRM_VMW_UNREF_CONTEXT        8
+#define DRM_VMW_CREATE_SURFACE       9
+#define DRM_VMW_UNREF_SURFACE        10
+#define DRM_VMW_REF_SURFACE          11
+#define DRM_VMW_EXECBUF              12
+#define DRM_VMW_FIFO_DEBUG           13
+#define DRM_VMW_FENCE_WAIT           14
+
+
+/*************************************************************************/
+/**
+ * DRM_VMW_GET_PARAM - get device information.
+ *
+ * DRM_VMW_PARAM_FIFO_OFFSET:
+ * Offset to use to map the first page of the FIFO read-only.
+ * The fifo is mapped using the mmap() system call on the drm device.
+ *
+ * DRM_VMW_PARAM_OVERLAY_IOCTL:
+ * Does the driver support the overlay ioctl.
+ */
+
+#define DRM_VMW_PARAM_NUM_STREAMS      0
+#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
+#define DRM_VMW_PARAM_3D               2
+#define DRM_VMW_PARAM_FIFO_OFFSET      3
+
+
+/**
+ * struct drm_vmw_getparam_arg
+ *
+ * @value: Returned value. //Out
+ * @param: Parameter to query. //In.
+ *
+ * Argument to the DRM_VMW_GET_PARAM Ioctl.
+ */
+
+struct drm_vmw_getparam_arg {
+       uint64_t value;
+       uint32_t param;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_EXTENSION - Query device extensions.
+ */
+
+/**
+ * struct drm_vmw_extension_rep
+ *
+ * @exists: The queried extension exists.
+ * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
+ * @driver_sarea_offset: Offset to any space in the DRI SAREA
+ * used by the extension.
+ * @major: Major version number of the extension.
+ * @minor: Minor version number of the extension.
+ * @pl: Patch level version number of the extension.
+ *
+ * Output argument to the DRM_VMW_EXTENSION Ioctl.
+ */
+
+struct drm_vmw_extension_rep {
+       int32_t exists;
+       uint32_t driver_ioctl_offset;
+       uint32_t driver_sarea_offset;
+       uint32_t major;
+       uint32_t minor;
+       uint32_t pl;
+       uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_extension_arg
+ *
+ * @extension - Ascii name of the extension to be queried. //In
+ * @rep - Reply as defined above. //Out
+ *
+ * Argument to the DRM_VMW_EXTENSION Ioctl.
+ */
+
+union drm_vmw_extension_arg {
+       char extension[DRM_VMW_EXT_NAME_LEN];
+       struct drm_vmw_extension_rep rep;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CREATE_CONTEXT - Create a host context.
+ *
+ * Allocates a device unique context id, and queues a create context command
+ * for the host. Does not wait for host completion.
+ */
+
+/**
+ * struct drm_vmw_context_arg
+ *
+ * @cid: Device unique context ID.
+ *
+ * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
+ * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
+ */
+
+struct drm_vmw_context_arg {
+       int32_t cid;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_CONTEXT - Create a host context.
+ *
+ * Frees a global context id, and queues a destroy host command for the host.
+ * Does not wait for host completion. The context ID can be used directly
+ * in the command stream and shows up as the same context ID on the host.
+ */
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CREATE_SURFACE - Create a host suface.
+ *
+ * Allocates a device unique surface id, and queues a create surface command
+ * for the host. Does not wait for host completion. The surface ID can be
+ * used directly in the command stream and shows up as the same surface
+ * ID on the host.
+ */
+
+/**
+ * struct drm_wmv_surface_create_req
+ *
+ * @flags: Surface flags as understood by the host.
+ * @format: Surface format as understood by the host.
+ * @mip_levels: Number of mip levels for each face.
+ * An unused face should have 0 encoded.
+ * @size_addr: Address of a user-space array of sruct drm_vmw_size
+ * cast to an uint64_t for 32-64 bit compatibility.
+ * The size of the array should equal the total number of mipmap levels.
+ * @shareable: Boolean whether other clients (as identified by file descriptors)
+ * may reference this surface.
+ *
+ * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
+ * Output data from the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+struct drm_vmw_surface_create_req {
+       uint32_t flags;
+       uint32_t format;
+       uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
+       uint64_t size_addr;
+       int32_t shareable;
+       uint32_t pad64;
+};
+
+/**
+ * struct drm_wmv_surface_arg
+ *
+ * @sid: Surface id of created surface or surface to destroy or reference.
+ *
+ * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
+ * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
+ * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+struct drm_vmw_surface_arg {
+       int32_t sid;
+       uint32_t pad64;
+};
+
+/**
+ * struct drm_vmw_size ioctl.
+ *
+ * @width - mip level width
+ * @height - mip level height
+ * @depth - mip level depth
+ *
+ * Description of a mip level.
+ * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
+ */
+
+struct drm_vmw_size {
+       uint32_t width;
+       uint32_t height;
+       uint32_t depth;
+       uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_surface_create_arg
+ *
+ * @rep: Output data as described above.
+ * @req: Input data as described above.
+ *
+ * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
+ */
+
+union drm_vmw_surface_create_arg {
+       struct drm_vmw_surface_arg rep;
+       struct drm_vmw_surface_create_req req;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_REF_SURFACE - Reference a host surface.
+ *
+ * Puts a reference on a host surface with a give sid, as previously
+ * returned by the DRM_VMW_CREATE_SURFACE ioctl.
+ * A reference will make sure the surface isn't destroyed while we hold
+ * it and will allow the calling client to use the surface ID in the command
+ * stream.
+ *
+ * On successful return, the Ioctl returns the surface information given
+ * in the DRM_VMW_CREATE_SURFACE ioctl.
+ */
+
+/**
+ * union drm_vmw_surface_reference_arg
+ *
+ * @rep: Output data as described above.
+ * @req: Input data as described above.
+ *
+ * Argument to the DRM_VMW_REF_SURFACE Ioctl.
+ */
+
+union drm_vmw_surface_reference_arg {
+       struct drm_vmw_surface_create_req rep;
+       struct drm_vmw_surface_arg req;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
+ *
+ * Clear a reference previously put on a host surface.
+ * When all references are gone, including the one implicitly placed
+ * on creation,
+ * a destroy surface command will be queued for the host.
+ * Does not wait for completion.
+ */
+
+/*************************************************************************/
+/**
+ * DRM_VMW_EXECBUF
+ *
+ * Submit a command buffer for execution on the host, and return a
+ * fence sequence that when signaled, indicates that the command buffer has
+ * executed.
+ */
+
+/**
+ * struct drm_vmw_execbuf_arg
+ *
+ * @commands: User-space address of a command buffer cast to an uint64_t.
+ * @command-size: Size in bytes of the command buffer.
+ * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
+ * uint64_t.
+ *
+ * Argument to the DRM_VMW_EXECBUF Ioctl.
+ */
+
+struct drm_vmw_execbuf_arg {
+       uint64_t commands;
+       uint32_t command_size;
+       uint32_t pad64;
+       uint64_t fence_rep;
+};
+
+/**
+ * struct drm_vmw_fence_rep
+ *
+ * @fence_seq: Fence sequence associated with a command submission.
+ * @error: This member should've been set to -EFAULT on submission.
+ * The following actions should be take on completion:
+ * error == -EFAULT: Fence communication failed. The host is synchronized.
+ * Use the last fence id read from the FIFO fence register.
+ * error != 0 && error != -EFAULT:
+ * Fence submission failed. The host is synchronized. Use the fence_seq member.
+ * error == 0: All is OK, The host may not be synchronized.
+ * Use the fence_seq member.
+ *
+ * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
+ */
+
+struct drm_vmw_fence_rep {
+       uint64_t fence_seq;
+       int32_t error;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_ALLOC_DMABUF
+ *
+ * Allocate a DMA buffer that is visible also to the host.
+ * NOTE: The buffer is
+ * identified by a handle and an offset, which are private to the guest, but
+ * useable in the command stream. The guest kernel may translate these
+ * and patch up the command stream accordingly. In the future, the offset may
+ * be zero at all times, or it may disappear from the interface before it is
+ * fixed.
+ *
+ * The DMA buffer may stay user-space mapped in the guest at all times,
+ * and is thus suitable for sub-allocation.
+ *
+ * DMA buffers are mapped using the mmap() syscall on the drm device.
+ */
+
+/**
+ * struct drm_vmw_alloc_dmabuf_req
+ *
+ * @size: Required minimum size of the buffer.
+ *
+ * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+struct drm_vmw_alloc_dmabuf_req {
+       uint32_t size;
+       uint32_t pad64;
+};
+
+/**
+ * struct drm_vmw_dmabuf_rep
+ *
+ * @map_handle: Offset to use in the mmap() call used to map the buffer.
+ * @handle: Handle unique to this buffer. Used for unreferencing.
+ * @cur_gmr_id: GMR id to use in the command stream when this buffer is
+ * referenced. See not above.
+ * @cur_gmr_offset: Offset to use in the command stream when this buffer is
+ * referenced. See note above.
+ *
+ * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+struct drm_vmw_dmabuf_rep {
+       uint64_t map_handle;
+       uint32_t handle;
+       uint32_t cur_gmr_id;
+       uint32_t cur_gmr_offset;
+       uint32_t pad64;
+};
+
+/**
+ * union drm_vmw_dmabuf_arg
+ *
+ * @req: Input data as described above.
+ * @rep: Output data as described above.
+ *
+ * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
+ */
+
+union drm_vmw_alloc_dmabuf_arg {
+       struct drm_vmw_alloc_dmabuf_req req;
+       struct drm_vmw_dmabuf_rep rep;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
+ *
+ */
+
+/**
+ * struct drm_vmw_unref_dmabuf_arg
+ *
+ * @handle: Handle indicating what buffer to free. Obtained from the
+ * DRM_VMW_ALLOC_DMABUF Ioctl.
+ *
+ * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
+ */
+
+struct drm_vmw_unref_dmabuf_arg {
+       uint32_t handle;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
+ *
+ * This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
+ */
+
+/**
+ * struct drm_vmw_fifo_debug_arg
+ *
+ * @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
+ * @debug_buffer_size: Size in bytes of debug buffer //In
+ * @used_size: Number of bytes copied to the buffer // Out
+ * @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
+ *
+ * Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
+ */
+
+struct drm_vmw_fifo_debug_arg {
+       uint64_t debug_buffer;
+       uint32_t debug_buffer_size;
+       uint32_t used_size;
+       int32_t did_not_fit;
+       uint32_t pad64;
+};
+
+struct drm_vmw_fence_wait_arg {
+       uint64_t sequence;
+       uint64_t kernel_cookie;
+       int32_t cookie_valid;
+       int32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
+ *
+ * This IOCTL controls the overlay units of the svga device.
+ * The SVGA overlay units does not work like regular hardware units in
+ * that they do not automaticaly read back the contents of the given dma
+ * buffer. But instead only read back for each call to this ioctl, and
+ * at any point between this call being made and a following call that
+ * either changes the buffer or disables the stream.
+ */
+
+/**
+ * struct drm_vmw_rect
+ *
+ * Defines a rectangle. Used in the overlay ioctl to define
+ * source and destination rectangle.
+ */
+
+struct drm_vmw_rect {
+       int32_t x;
+       int32_t y;
+       uint32_t w;
+       uint32_t h;
+};
+
+/**
+ * struct drm_vmw_control_stream_arg
+ *
+ * @stream_id: Stearm to control
+ * @enabled: If false all following arguments are ignored.
+ * @handle: Handle to buffer for getting data from.
+ * @format: Format of the overlay as understood by the host.
+ * @width: Width of the overlay.
+ * @height: Height of the overlay.
+ * @size: Size of the overlay in bytes.
+ * @pitch: Array of pitches, the two last are only used for YUV12 formats.
+ * @offset: Offset from start of dma buffer to overlay.
+ * @src: Source rect, must be within the defined area above.
+ * @dst: Destination rect, x and y may be negative.
+ *
+ * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
+ */
+
+struct drm_vmw_control_stream_arg {
+       uint32_t stream_id;
+       uint32_t enabled;
+
+       uint32_t flags;
+       uint32_t color_key;
+
+       uint32_t handle;
+       uint32_t offset;
+       int32_t format;
+       uint32_t size;
+       uint32_t width;
+       uint32_t height;
+       uint32_t pitch[3];
+
+       uint32_t pad64;
+       struct drm_vmw_rect src;
+       struct drm_vmw_rect dst;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
+ *
+ */
+
+#define DRM_VMW_CURSOR_BYPASS_ALL    (1 << 0)
+#define DRM_VMW_CURSOR_BYPASS_FLAGS       (1)
+
+/**
+ * struct drm_vmw_cursor_bypass_arg
+ *
+ * @flags: Flags.
+ * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
+ * @xpos: X position of cursor.
+ * @ypos: Y position of cursor.
+ * @xhot: X hotspot.
+ * @yhot: Y hotspot.
+ *
+ * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
+ */
+
+struct drm_vmw_cursor_bypass_arg {
+       uint32_t flags;
+       uint32_t crtc_id;
+       int32_t xpos;
+       int32_t ypos;
+       int32_t xhot;
+       int32_t yhot;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_CLAIM_STREAM - Claim a single stream.
+ */
+
+/**
+ * struct drm_vmw_context_arg
+ *
+ * @stream_id: Device unique context ID.
+ *
+ * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
+ * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
+ */
+
+struct drm_vmw_stream_arg {
+       uint32_t stream_id;
+       uint32_t pad64;
+};
+
+/*************************************************************************/
+/**
+ * DRM_VMW_UNREF_STREAM - Unclaim a stream.
+ *
+ * Return a single stream that was claimed by this process. Also makes
+ * sure that the stream has been stopped.
+ */
+
+#endif
index f72914db2a115f0fb7ad2b074300272f699c696b..756f831cbdd557236057ede228bfdb9481559c97 100644 (file)
@@ -118,6 +118,7 @@ header-y += mtio.h
 header-y += ncp_no.h
 header-y += neighbour.h
 header-y += net_dropmon.h
+header-y += net_tstamp.h
 header-y += netfilter_arp.h
 header-y += netrom.h
 header-y += nfs2.h
index dfcd920c3e5495cc9aeb0296714bb192bf80105f..36924255c0d541ad97dc0d8525c3481a7d60478f 100644 (file)
@@ -240,7 +240,7 @@ extern int pnpacpi_disabled;
 #define PXM_INVAL      (-1)
 #define NID_INVAL      (-1)
 
-int acpi_check_resource_conflict(struct resource *res);
+int acpi_check_resource_conflict(const struct resource *res);
 
 int acpi_check_region(resource_size_t start, resource_size_t n,
                      const char *name);
@@ -251,12 +251,19 @@ int acpi_check_mem_region(resource_size_t start, resource_size_t n,
 void __init acpi_no_s4_hw_signature(void);
 void __init acpi_old_suspend_ordering(void);
 void __init acpi_s4_no_nvs(void);
+void __init acpi_set_sci_en_on_resume(void);
 #endif /* CONFIG_PM_SLEEP */
 
+struct acpi_osc_context {
+       char *uuid_str; /* uuid string */
+       int rev;
+       struct acpi_buffer cap; /* arg2/arg3 */
+       struct acpi_buffer ret; /* free by caller if success */
+};
+
 #define OSC_QUERY_TYPE                 0
 #define OSC_SUPPORT_TYPE               1
 #define OSC_CONTROL_TYPE               2
-#define OSC_SUPPORT_MASKS              0x1f
 
 /* _OSC DW0 Definition */
 #define OSC_QUERY_ENABLE               1
@@ -265,12 +272,23 @@ void __init acpi_s4_no_nvs(void);
 #define OSC_INVALID_REVISION_ERROR     8
 #define OSC_CAPABILITIES_MASK_ERROR    16
 
+acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
+
+/* platform-wide _OSC bits */
+#define OSC_SB_PAD_SUPPORT             1
+#define OSC_SB_PPC_OST_SUPPORT         2
+#define OSC_SB_PR3_SUPPORT             4
+#define OSC_SB_CPUHP_OST_SUPPORT       8
+#define OSC_SB_APEI_SUPPORT            16
+
+/* PCI defined _OSC bits */
 /* _OSC DW1 Definition (OS Support Fields) */
 #define OSC_EXT_PCI_CONFIG_SUPPORT             1
 #define OSC_ACTIVE_STATE_PWR_SUPPORT           2
 #define OSC_CLOCK_PWR_CAPABILITY_SUPPORT       4
 #define OSC_PCI_SEGMENT_GROUPS_SUPPORT         8
 #define OSC_MSI_SUPPORT                                16
+#define OSC_PCI_SUPPORT_MASKS                  0x1f
 
 /* _OSC DW1 Definition (OS Control Fields) */
 #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL      1
@@ -279,7 +297,7 @@ void __init acpi_s4_no_nvs(void);
 #define OSC_PCI_EXPRESS_AER_CONTROL            8
 #define OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL  16
 
-#define OSC_CONTROL_MASKS      (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL |    \
+#define OSC_PCI_CONTROL_MASKS  (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL |    \
                                OSC_SHPC_NATIVE_HP_CONTROL |            \
                                OSC_PCI_EXPRESS_PME_CONTROL |           \
                                OSC_PCI_EXPRESS_AER_CONTROL |           \
index aea219d7d8d1afec462b546df8c3412c915eecf2..811dbb369379ff463110289bba1d44b9bb14a2a2 100644 (file)
@@ -102,7 +102,6 @@ struct kiocb {
        } ki_obj;
 
        __u64                   ki_user_data;   /* user's data for completion */
-       wait_queue_t            ki_wait;
        loff_t                  ki_pos;
 
        void                    *private;
@@ -140,7 +139,6 @@ struct kiocb {
                (x)->ki_dtor = NULL;                    \
                (x)->ki_obj.tsk = tsk;                  \
                (x)->ki_user_data = 0;                  \
-               init_wait((&(x)->ki_wait));             \
        } while (0)
 
 #define AIO_RING_MAGIC                 0xa10a10a1
@@ -223,8 +221,6 @@ struct mm_struct;
 static inline void exit_aio(struct mm_struct *mm) { }
 #endif /* CONFIG_AIO */
 
-#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
-
 static inline struct kiocb *list_kiocb(struct list_head *h)
 {
        return list_entry(h, struct kiocb, ki_list);
index 57b1846a3c876baf138214b2d511c693143fefa8..3e09b345f4d675ffddcab95e6d6b72039d141237 100644 (file)
@@ -3,8 +3,6 @@
 
 #define ATMEL_MCI_MAX_NR_SLOTS 2
 
-#include <linux/dw_dmac.h>
-
 /**
  * struct mci_slot_pdata - board-specific per-slot configuration
  * @bus_width: Number of data lines wired up the slot
@@ -34,7 +32,7 @@ struct mci_slot_pdata {
  * @slot: Per-slot configuration data.
  */
 struct mci_platform_data {
-       struct dw_dma_slave     dma_slave;
+       struct mci_dma_data     *dma_slave;
        struct mci_slot_pdata   slot[ATMEL_MCI_MAX_NR_SLOTS];
 };
 
index 0f5f57858a237bb16335b90bafbe9ece0cf9d8f8..8c4f884db6b40044a5934985656551b1dee22d8d 100644 (file)
@@ -36,18 +36,18 @@ struct backlight_device;
 struct fb_info;
 
 struct backlight_ops {
-       unsigned int options;
+       const unsigned int options;
 
 #define BL_CORE_SUSPENDRESUME  (1 << 0)
 
        /* Notify the backlight driver some property has changed */
-       int (*update_status)(struct backlight_device *);
+       int (* const update_status)(struct backlight_device *);
        /* Return the current backlight brightness (accounting for power,
           fb_blank etc.) */
-       int (*get_brightness)(struct backlight_device *);
+       int (* const get_brightness)(struct backlight_device *);
        /* Check if given framebuffer device is the one bound to this backlight;
           return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */
-       int (*check_fb)(struct fb_info *);
+       int (* const check_fb)(struct fb_info *);
 };
 
 /* This structure defines all the properties of a backlight */
@@ -86,7 +86,7 @@ struct backlight_device {
           registered this device has been unloaded, and if class_get_devdata()
           points to something in the body of that driver, it is also invalid. */
        struct mutex ops_lock;
-       struct backlight_ops *ops;
+       const struct backlight_ops *ops;
 
        /* The framebuffer notifier block */
        struct notifier_block fb_notif;
@@ -103,7 +103,7 @@ static inline void backlight_update_status(struct backlight_device *bd)
 }
 
 extern struct backlight_device *backlight_device_register(const char *name,
-       struct device *dev, void *devdata, struct backlight_ops *ops);
+       struct device *dev, void *devdata, const struct backlight_ops *ops);
 extern void backlight_device_unregister(struct backlight_device *bd);
 extern void backlight_force_update(struct backlight_device *bd,
                                   enum backlight_update_reason reason);
index aece486ac7349b8463ace95585b2fa9379a04ab3..cd4349bdc34efd2b5044eb8f83e0e4f98e211817 100644 (file)
@@ -68,6 +68,14 @@ struct linux_binprm{
 
 #define BINPRM_MAX_RECURSION 4
 
+/* Function parameter for binfmt->coredump */
+struct coredump_params {
+       long signr;
+       struct pt_regs *regs;
+       struct file *file;
+       unsigned long limit;
+};
+
 /*
  * This structure defines the functions that are used to load the binary formats that
  * linux accepts.
@@ -77,7 +85,7 @@ struct linux_binfmt {
        struct module *module;
        int (*load_binary)(struct linux_binprm *, struct  pt_regs * regs);
        int (*load_shlib)(struct file *);
-       int (*core_dump)(long signr, struct pt_regs *regs, struct file *file, unsigned long limit);
+       int (*core_dump)(struct coredump_params *cprm);
        unsigned long min_coredump;     /* minimal dump size */
        int hasvdso;
 };
index 756d78b8c1c5e52195fc4b0db951c883c1a07122..daf8c480c7867e9a60f3cdd715e9b4a8c030942c 100644 (file)
@@ -42,6 +42,9 @@
  * bitmap_empty(src, nbits)                    Are all bits zero in *src?
  * bitmap_full(src, nbits)                     Are all bits set in *src?
  * bitmap_weight(src, nbits)                   Hamming Weight: number set bits
+ * bitmap_set(dst, pos, nbits)                 Set specified bit area
+ * bitmap_clear(dst, pos, nbits)               Clear specified bit area
+ * bitmap_find_next_zero_area(buf, len, pos, n, mask)  Find bit free area
  * bitmap_shift_right(dst, src, n, nbits)      *dst = *src >> n
  * bitmap_shift_left(dst, src, n, nbits)       *dst = *src << n
  * bitmap_remap(dst, src, old, new, nbits)     *dst = map(old, new)(src)
@@ -108,6 +111,14 @@ extern int __bitmap_subset(const unsigned long *bitmap1,
                        const unsigned long *bitmap2, int bits);
 extern int __bitmap_weight(const unsigned long *bitmap, int bits);
 
+extern void bitmap_set(unsigned long *map, int i, int len);
+extern void bitmap_clear(unsigned long *map, int start, int nr);
+extern unsigned long bitmap_find_next_zero_area(unsigned long *map,
+                                        unsigned long size,
+                                        unsigned long start,
+                                        unsigned int nr,
+                                        unsigned long align_mask);
+
 extern int bitmap_scnprintf(char *buf, unsigned int len,
                        const unsigned long *src, int nbits);
 extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user,
index 784a919aa0d0e05bf978f56f97a2f6eb4e6451e1..9b98173a81845bc4dc61b0bb30a516e738c4ec5d 100644 (file)
@@ -845,7 +845,6 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
  * blk_rq_err_bytes()          : bytes left till the next error boundary
  * blk_rq_sectors()            : sectors left in the entire request
  * blk_rq_cur_sectors()                : sectors left in the current segment
- * blk_rq_err_sectors()                : sectors left till the next error boundary
  */
 static inline sector_t blk_rq_pos(const struct request *rq)
 {
@@ -874,11 +873,6 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
        return blk_rq_cur_bytes(rq) >> 9;
 }
 
-static inline unsigned int blk_rq_err_sectors(const struct request *rq)
-{
-       return blk_rq_err_bytes(rq) >> 9;
-}
-
 /*
  * Request issue related functions.
  */
@@ -1116,11 +1110,18 @@ static inline int queue_alignment_offset(struct request_queue *q)
        return q->limits.alignment_offset;
 }
 
+static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t offset)
+{
+       unsigned int granularity = max(lim->physical_block_size, lim->io_min);
+
+       offset &= granularity - 1;
+       return (granularity + lim->alignment_offset - offset) & (granularity - 1);
+}
+
 static inline int queue_sector_alignment_offset(struct request_queue *q,
                                                sector_t sector)
 {
-       return ((sector << 9) - q->limits.alignment_offset)
-               & (q->limits.io_min - 1);
+       return queue_limit_alignment_offset(&q->limits, sector << 9);
 }
 
 static inline int bdev_alignment_offset(struct block_device *bdev)
index 1ed2a5cc03f5fb00dca89368b0d72cd42b85acf9..3db7767d2a175b9caf61ec4d98de415f7c24f6b6 100644 (file)
@@ -51,6 +51,15 @@ struct can_priv {
        struct sk_buff **echo_skb;
 };
 
+/*
+ * get_can_dlc(value) - helper macro to cast a given data length code (dlc)
+ * to __u8 and ensure the dlc value to be max. 8 bytes.
+ *
+ * To be used in the CAN netdriver receive path to ensure conformance with
+ * ISO 11898-1 Chapter 8.4.2.3 (DLC field)
+ */
+#define get_can_dlc(i) (min_t(__u8, (i), 8))
+
 struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
 void free_candev(struct net_device *dev);
 
diff --git a/include/linux/cs5535.h b/include/linux/cs5535.h
new file mode 100644 (file)
index 0000000..d5a1d48
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * AMD CS5535/CS5536 definitions
+ * Copyright (C) 2006  Advanced Micro Devices, Inc.
+ * Copyright (C) 2009  Andres Salomon <dilinger@collabora.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ */
+
+#ifndef _CS5535_H
+#define _CS5535_H
+
+/* MSRs */
+#define MSR_GLIU_P2D_RO0       0x10000029
+
+#define MSR_LX_GLD_MSR_CONFIG  0x48002001
+#define MSR_LX_MSR_PADSEL      0x48002011      /* NOT 0x48000011; the data
+                                                * sheet has the wrong value */
+#define MSR_GLCP_SYS_RSTPLL    0x4C000014
+#define MSR_GLCP_DOTPLL                0x4C000015
+
+#define MSR_LBAR_SMB           0x5140000B
+#define MSR_LBAR_GPIO          0x5140000C
+#define MSR_LBAR_MFGPT         0x5140000D
+#define MSR_LBAR_ACPI          0x5140000E
+#define MSR_LBAR_PMS           0x5140000F
+
+#define MSR_DIVIL_SOFT_RESET   0x51400017
+
+#define MSR_PIC_YSEL_LOW       0x51400020
+#define MSR_PIC_YSEL_HIGH      0x51400021
+#define MSR_PIC_ZSEL_LOW       0x51400022
+#define MSR_PIC_ZSEL_HIGH      0x51400023
+#define MSR_PIC_IRQM_LPC       0x51400025
+
+#define MSR_MFGPT_IRQ          0x51400028
+#define MSR_MFGPT_NR           0x51400029
+#define MSR_MFGPT_SETUP                0x5140002B
+
+#define MSR_LX_SPARE_MSR       0x80000011      /* DC-specific */
+
+#define MSR_GX_GLD_MSR_CONFIG  0xC0002001
+#define MSR_GX_MSR_PADSEL      0xC0002011
+
+/* resource sizes */
+#define LBAR_GPIO_SIZE         0xFF
+#define LBAR_MFGPT_SIZE                0x40
+#define LBAR_ACPI_SIZE         0x40
+#define LBAR_PMS_SIZE          0x80
+
+/* VSA2 magic values */
+#define VSA_VRC_INDEX          0xAC1C
+#define VSA_VRC_DATA           0xAC1E
+#define VSA_VR_UNLOCK          0xFC53  /* unlock virtual register */
+#define VSA_VR_SIGNATURE       0x0003
+#define VSA_VR_MEM_SIZE                0x0200
+#define AMD_VSA_SIG            0x4132  /* signature is ascii 'VSA2' */
+#define GSW_VSA_SIG            0x534d  /* General Software signature */
+
+#include <linux/io.h>
+
+static inline int cs5535_has_vsa2(void)
+{
+       static int has_vsa2 = -1;
+
+       if (has_vsa2 == -1) {
+               uint16_t val;
+
+               /*
+                * The VSA has virtual registers that we can query for a
+                * signature.
+                */
+               outw(VSA_VR_UNLOCK, VSA_VRC_INDEX);
+               outw(VSA_VR_SIGNATURE, VSA_VRC_INDEX);
+
+               val = inw(VSA_VRC_DATA);
+               has_vsa2 = (val == AMD_VSA_SIG || val == GSW_VSA_SIG);
+       }
+
+       return has_vsa2;
+}
+
+/* GPIOs */
+#define GPIO_OUTPUT_VAL                0x00
+#define GPIO_OUTPUT_ENABLE     0x04
+#define GPIO_OUTPUT_OPEN_DRAIN 0x08
+#define GPIO_OUTPUT_INVERT     0x0C
+#define GPIO_OUTPUT_AUX1       0x10
+#define GPIO_OUTPUT_AUX2       0x14
+#define GPIO_PULL_UP           0x18
+#define GPIO_PULL_DOWN         0x1C
+#define GPIO_INPUT_ENABLE      0x20
+#define GPIO_INPUT_INVERT      0x24
+#define GPIO_INPUT_FILTER      0x28
+#define GPIO_INPUT_EVENT_COUNT 0x2C
+#define GPIO_READ_BACK         0x30
+#define GPIO_INPUT_AUX1                0x34
+#define GPIO_EVENTS_ENABLE     0x38
+#define GPIO_LOCK_ENABLE       0x3C
+#define GPIO_POSITIVE_EDGE_EN  0x40
+#define GPIO_NEGATIVE_EDGE_EN  0x44
+#define GPIO_POSITIVE_EDGE_STS 0x48
+#define GPIO_NEGATIVE_EDGE_STS 0x4C
+
+#define GPIO_MAP_X             0xE0
+#define GPIO_MAP_Y             0xE4
+#define GPIO_MAP_Z             0xE8
+#define GPIO_MAP_W             0xEC
+
+void cs5535_gpio_set(unsigned offset, unsigned int reg);
+void cs5535_gpio_clear(unsigned offset, unsigned int reg);
+int cs5535_gpio_isset(unsigned offset, unsigned int reg);
+
+/* MFGPTs */
+
+#define MFGPT_MAX_TIMERS       8
+#define MFGPT_TIMER_ANY                (-1)
+
+#define MFGPT_DOMAIN_WORKING   1
+#define MFGPT_DOMAIN_STANDBY   2
+#define MFGPT_DOMAIN_ANY       (MFGPT_DOMAIN_WORKING | MFGPT_DOMAIN_STANDBY)
+
+#define MFGPT_CMP1             0
+#define MFGPT_CMP2             1
+
+#define MFGPT_EVENT_IRQ                0
+#define MFGPT_EVENT_NMI                1
+#define MFGPT_EVENT_RESET      3
+
+#define MFGPT_REG_CMP1         0
+#define MFGPT_REG_CMP2         2
+#define MFGPT_REG_COUNTER      4
+#define MFGPT_REG_SETUP                6
+
+#define MFGPT_SETUP_CNTEN      (1 << 15)
+#define MFGPT_SETUP_CMP2       (1 << 14)
+#define MFGPT_SETUP_CMP1       (1 << 13)
+#define MFGPT_SETUP_SETUP      (1 << 12)
+#define MFGPT_SETUP_STOPEN     (1 << 11)
+#define MFGPT_SETUP_EXTEN      (1 << 10)
+#define MFGPT_SETUP_REVEN      (1 << 5)
+#define MFGPT_SETUP_CLKSEL     (1 << 4)
+
+struct cs5535_mfgpt_timer;
+
+extern uint16_t cs5535_mfgpt_read(struct cs5535_mfgpt_timer *timer,
+               uint16_t reg);
+extern void cs5535_mfgpt_write(struct cs5535_mfgpt_timer *timer, uint16_t reg,
+               uint16_t value);
+
+extern int cs5535_mfgpt_toggle_event(struct cs5535_mfgpt_timer *timer, int cmp,
+               int event, int enable);
+extern int cs5535_mfgpt_set_irq(struct cs5535_mfgpt_timer *timer, int cmp,
+               int *irq, int enable);
+extern struct cs5535_mfgpt_timer *cs5535_mfgpt_alloc_timer(int timer,
+               int domain);
+extern void cs5535_mfgpt_free_timer(struct cs5535_mfgpt_timer *timer);
+
+static inline int cs5535_mfgpt_setup_irq(struct cs5535_mfgpt_timer *timer,
+               int cmp, int *irq)
+{
+       return cs5535_mfgpt_set_irq(timer, cmp, irq, 1);
+}
+
+static inline int cs5535_mfgpt_release_irq(struct cs5535_mfgpt_timer *timer,
+               int cmp, int *irq)
+{
+       return cs5535_mfgpt_set_irq(timer, cmp, irq, 0);
+}
+
+#endif
index afa36392297a341ce79e7d52a0231453776b7a89..a3d6ee0044f974ebf12236de4c5ecd5678d26a6c 100644 (file)
@@ -15,7 +15,7 @@
 #define _X     0x40    /* hex digit */
 #define _SP    0x80    /* hard space (0x20) */
 
-extern unsigned char _ctype[];
+extern const unsigned char _ctype[];
 
 #define __ismask(x) (_ctype[(int)(unsigned char)(x)])
 
@@ -27,6 +27,7 @@ extern unsigned char _ctype[];
 #define islower(c)     ((__ismask(c)&(_L)) != 0)
 #define isprint(c)     ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
 #define ispunct(c)     ((__ismask(c)&(_P)) != 0)
+/* Note: isspace() must return false for %NUL-terminator */
 #define isspace(c)     ((__ismask(c)&(_S)) != 0)
 #define isupper(c)     ((__ismask(c)&(_U)) != 0)
 #define isxdigit(c)    ((__ismask(c)&(_D|_X)) != 0)
index 12ff8c3f1d053f471c14e5f74ad50bf0355ebfa8..5032b9a31ae7b81dc51a008a660487a381b83169 100644 (file)
@@ -25,7 +25,7 @@ static void *malloc(int size)
        void *p;
 
        if (size < 0)
-               error("Malloc error");
+               return NULL;
        if (!malloc_ptr)
                malloc_ptr = free_mem_ptr;
 
@@ -35,7 +35,7 @@ static void *malloc(int size)
        malloc_ptr += size;
 
        if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
-               error("Out of memory");
+               return NULL;
 
        malloc_count++;
        return p;
index df7607e6dce80ec188d061524103fbdf822cd2a7..d4c9c0b88adcea7fd8f9de8c5c315dcd64a68bca 100644 (file)
@@ -235,7 +235,7 @@ void dm_uevent_add(struct mapped_device *md, struct list_head *elist);
 const char *dm_device_name(struct mapped_device *md);
 int dm_copy_name_and_uuid(struct mapped_device *md, char *name, char *uuid);
 struct gendisk *dm_disk(struct mapped_device *md);
-int dm_suspended(struct mapped_device *md);
+int dm_suspended(struct dm_target *ti);
 int dm_noflush_suspending(struct dm_target *ti);
 union map_info *dm_get_mapinfo(struct bio *bio);
 union map_info *dm_get_rq_mapinfo(struct request *rq);
@@ -276,7 +276,7 @@ void dm_table_unplug_all(struct dm_table *t);
 /*
  * Table reference counting.
  */
-struct dm_table *dm_get_table(struct mapped_device *md);
+struct dm_table *dm_get_live_table(struct mapped_device *md);
 void dm_table_get(struct dm_table *t);
 void dm_table_put(struct dm_table *t);
 
@@ -295,8 +295,10 @@ void dm_table_event(struct dm_table *t);
 
 /*
  * The device must be suspended before calling this method.
+ * Returns the previous table, which the caller must destroy.
  */
-int dm_swap_table(struct mapped_device *md, struct dm_table *t);
+struct dm_table *dm_swap_table(struct mapped_device *md,
+                              struct dm_table *t);
 
 /*
  * A wrapper around vmalloc.
index 2a73d9bcbc9c9f02fee174ef4d7cd3419e00c930..a62799f2ab0019863d30e4f55f7677c5bd97d124 100644 (file)
@@ -166,9 +166,9 @@ struct driver_attribute driver_attr_##_name =               \
        __ATTR(_name, _mode, _show, _store)
 
 extern int __must_check driver_create_file(struct device_driver *driver,
-                                          struct driver_attribute *attr);
+                                       const struct driver_attribute *attr);
 extern void driver_remove_file(struct device_driver *driver,
-                              struct driver_attribute *attr);
+                              const struct driver_attribute *attr);
 
 extern int __must_check driver_add_kobj(struct device_driver *drv,
                                        struct kobject *kobj,
@@ -319,13 +319,13 @@ struct device_attribute {
 struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
 
 extern int __must_check device_create_file(struct device *device,
-                                          struct device_attribute *entry);
+                                       const struct device_attribute *entry);
 extern void device_remove_file(struct device *dev,
-                              struct device_attribute *attr);
+                              const struct device_attribute *attr);
 extern int __must_check device_create_bin_file(struct device *dev,
-                                              struct bin_attribute *attr);
+                                       const struct bin_attribute *attr);
 extern void device_remove_bin_file(struct device *dev,
-                                  struct bin_attribute *attr);
+                                  const struct bin_attribute *attr);
 extern int device_schedule_callback_owner(struct device *dev,
                void (*func)(struct device *dev), struct module *owner);
 
index 5e8b11d88f6f891a5c56328ca54ecb0fa4e2ce57..7084503c3405f80cd94f9fc261f9b7cd1530f499 100644 (file)
@@ -21,6 +21,7 @@ struct dm_dirty_log_type;
 
 struct dm_dirty_log {
        struct dm_dirty_log_type *type;
+       int (*flush_callback_fn)(struct dm_target *ti);
        void *context;
 };
 
@@ -136,8 +137,9 @@ int dm_dirty_log_type_unregister(struct dm_dirty_log_type *type);
  * type->constructor/destructor() directly.
  */
 struct dm_dirty_log *dm_dirty_log_create(const char *type_name,
-                                        struct dm_target *ti,
-                                        unsigned argc, char **argv);
+                       struct dm_target *ti,
+                       int (*flush_callback_fn)(struct dm_target *ti),
+                       unsigned argc, char **argv);
 void dm_dirty_log_destroy(struct dm_dirty_log *log);
 
 #endif /* __KERNEL__ */
index 2ab84c83c31a9d7d11b8c18ee744cb85ca520fd8..aa95508d2f9547e23722d9b67f91b9705fe95033 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
- * Copyright (C) 2004 - 2005 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004 - 2009 Red Hat, Inc. All rights reserved.
  *
  * This file is released under the LGPL.
  */
@@ -266,9 +266,9 @@ enum {
 #define DM_DEV_SET_GEOMETRY    _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
 
 #define DM_VERSION_MAJOR       4
-#define DM_VERSION_MINOR       15
+#define DM_VERSION_MINOR       16
 #define DM_VERSION_PATCHLEVEL  0
-#define DM_VERSION_EXTRA       "-ioctl (2009-04-01)"
+#define DM_VERSION_EXTRA       "-ioctl (2009-11-05)"
 
 /* Status bits */
 #define DM_READONLY_FLAG       (1 << 0) /* In/Out */
@@ -309,4 +309,11 @@ enum {
  */
 #define DM_NOFLUSH_FLAG                (1 << 11) /* In */
 
+/*
+ * If set, any table information returned will relate to the inactive
+ * table instead of the live one.  Always check DM_INACTIVE_PRESENT_FLAG
+ * is set before using the data returned.
+ */
+#define DM_QUERY_INACTIVE_TABLE_FLAG   (1 << 12) /* In */
+
 #endif                         /* _LINUX_DM_IOCTL_H */
index a9e652a4137370e19fe24e0ab619a18a131074f0..9e2a7a401df50577c604bc99ed70eba43ffae833 100644 (file)
@@ -78,8 +78,7 @@ void dm_rh_dec(struct dm_region_hash *rh, region_t region);
 /* Delay bios on regions. */
 void dm_rh_delay(struct dm_region_hash *rh, struct bio *bio);
 
-void dm_rh_mark_nosync(struct dm_region_hash *rh,
-                      struct bio *bio, unsigned done, int error);
+void dm_rh_mark_nosync(struct dm_region_hash *rh, struct bio *bio);
 
 /*
  * Region recovery control.
index 2b9f2ac7ed60f0e8c61e79f2f7791545f877e1ef..78784982b33e36906dd47afd404287cdccdbc0f9 100644 (file)
@@ -74,7 +74,7 @@ enum dma_transaction_type {
  *  control completion, and communicate status.
  * @DMA_PREP_INTERRUPT - trigger an interrupt (callback) upon completion of
  *  this transaction
- * @DMA_CTRL_ACK - the descriptor cannot be reused until the client
+ * @DMA_CTRL_ACK - if clear, the descriptor cannot be reused until the client
  *  acknowledges receipt, i.e. has has a chance to establish any dependency
  *  chains
  * @DMA_COMPL_SKIP_SRC_UNMAP - set to disable dma-unmapping the source buffer(s)
diff --git a/include/linux/dst.h b/include/linux/dst.h
deleted file mode 100644 (file)
index e26fed8..0000000
+++ /dev/null
@@ -1,587 +0,0 @@
-/*
- * 2007+ Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#ifndef __DST_H
-#define __DST_H
-
-#include <linux/types.h>
-#include <linux/connector.h>
-
-#define DST_NAMELEN            32
-#define DST_NAME               "dst"
-
-enum {
-       /* Remove node with given id from storage */
-       DST_DEL_NODE    = 0,
-       /* Add remote node with given id to the storage */
-       DST_ADD_REMOTE,
-       /* Add local node with given id to the storage to be exported and used by remote peers */
-       DST_ADD_EXPORT,
-       /* Crypto initialization command (hash/cipher used to protect the connection) */
-       DST_CRYPTO,
-       /* Security attributes for given connection (permissions for example) */
-       DST_SECURITY,
-       /* Register given node in the block layer subsystem */
-       DST_START,
-       DST_CMD_MAX
-};
-
-struct dst_ctl
-{
-       /* Storage name */
-       char                    name[DST_NAMELEN];
-       /* Command flags */
-       __u32                   flags;
-       /* Command itself (see above) */
-       __u32                   cmd;
-       /* Maximum number of pages per single request in this device */
-       __u32                   max_pages;
-       /* Stale/error transaction scanning timeout in milliseconds */
-       __u32                   trans_scan_timeout;
-       /* Maximum number of retry sends before completing transaction as broken */
-       __u32                   trans_max_retries;
-       /* Storage size */
-       __u64                   size;
-};
-
-/* Reply command carries completion status */
-struct dst_ctl_ack
-{
-       struct cn_msg           msg;
-       int                     error;
-       int                     unused[3];
-};
-
-/*
- * Unfortunaltely socket address structure is not exported to userspace
- * and is redefined there.
- */
-#define SADDR_MAX_DATA 128
-
-struct saddr {
-       /* address family, AF_xxx       */
-       unsigned short          sa_family;
-       /* 14 bytes of protocol address */
-       char                    sa_data[SADDR_MAX_DATA];
-       /* Number of bytes used in sa_data */
-       unsigned short          sa_data_len;
-};
-
-/* Address structure */
-struct dst_network_ctl
-{
-       /* Socket type: datagram, stream...*/
-       unsigned int            type;
-       /* Let me guess, is it a Jupiter diameter? */
-       unsigned int            proto;
-       /* Peer's address */
-       struct saddr            addr;
-};
-
-struct dst_crypto_ctl
-{
-       /* Cipher and hash names */
-       char                    cipher_algo[DST_NAMELEN];
-       char                    hash_algo[DST_NAMELEN];
-
-       /* Key sizes. Can be zero for digest for example */
-       unsigned int            cipher_keysize, hash_keysize;
-       /* Alignment. Calculated by the DST itself. */
-       unsigned int            crypto_attached_size;
-       /* Number of threads to perform crypto operations */
-       int                     thread_num;
-};
-
-/* Export security attributes have this bits checked in when client connects */
-#define DST_PERM_READ          (1<<0)
-#define DST_PERM_WRITE         (1<<1)
-
-/*
- * Right now it is simple model, where each remote address
- * is assigned to set of permissions it is allowed to perform.
- * In real world block device does not know anything but
- * reading and writing, so it should be more than enough.
- */
-struct dst_secure_user
-{
-       unsigned int            permissions;
-       struct saddr            addr;
-};
-
-/*
- * Export control command: device to export and network address to accept
- * clients to work with given device
- */
-struct dst_export_ctl
-{
-       char                    device[DST_NAMELEN];
-       struct dst_network_ctl  ctl;
-};
-
-enum {
-       DST_CFG = 1,            /* Request remote configuration */
-       DST_IO,                 /* IO command */
-       DST_IO_RESPONSE,        /* IO response */
-       DST_PING,               /* Keepalive message */
-       DST_NCMD_MAX,
-};
-
-struct dst_cmd
-{
-       /* Network command itself, see above */
-       __u32                   cmd;
-       /*
-        * Size of the attached data
-        * (in most cases, for READ command it means how many bytes were requested)
-        */
-       __u32                   size;
-       /* Crypto size: number of attached bytes with digest/hmac */
-       __u32                   csize;
-       /* Here we can carry secret data */
-       __u32                   reserved;
-       /* Read/write bits, see how they are encoded in bio structure */
-       __u64                   rw;
-       /* BIO flags */
-       __u64                   flags;
-       /* Unique command id (like transaction ID) */
-       __u64                   id;
-       /* Sector to start IO from */
-       __u64                   sector;
-       /* Hash data is placed after this header */
-       __u8                    hash[0];
-};
-
-/*
- * Convert command to/from network byte order.
- * We do not use hton*() functions, since there is
- * no 64-bit implementation.
- */
-static inline void dst_convert_cmd(struct dst_cmd *c)
-{
-       c->cmd = __cpu_to_be32(c->cmd);
-       c->csize = __cpu_to_be32(c->csize);
-       c->size = __cpu_to_be32(c->size);
-       c->sector = __cpu_to_be64(c->sector);
-       c->id = __cpu_to_be64(c->id);
-       c->flags = __cpu_to_be64(c->flags);
-       c->rw = __cpu_to_be64(c->rw);
-}
-
-/* Transaction id */
-typedef __u64 dst_gen_t;
-
-#ifdef __KERNEL__
-
-#include <linux/blkdev.h>
-#include <linux/bio.h>
-#include <linux/device.h>
-#include <linux/mempool.h>
-#include <linux/net.h>
-#include <linux/poll.h>
-#include <linux/rbtree.h>
-
-#ifdef CONFIG_DST_DEBUG
-#define dprintk(f, a...) printk(KERN_NOTICE f, ##a)
-#else
-static inline void __attribute__ ((format (printf, 1, 2)))
-       dprintk(const char *fmt, ...) {}
-#endif
-
-struct dst_node;
-
-struct dst_trans
-{
-       /* DST node we are working with */
-       struct dst_node         *n;
-
-       /* Entry inside transaction tree */
-       struct rb_node          trans_entry;
-
-       /* Merlin kills this transaction when this memory cell equals zero */
-       atomic_t                refcnt;
-
-       /* How this transaction should be processed by crypto engine */
-       short                   enc;
-       /* How many times this transaction was resent */
-       short                   retries;
-       /* Completion status */
-       int                     error;
-
-       /* When did we send it to the remote peer */
-       long                    send_time;
-
-       /* My name is...
-        * Well, computers does not speak, they have unique id instead */
-       dst_gen_t               gen;
-
-       /* Block IO we are working with */
-       struct bio              *bio;
-
-       /* Network command for above block IO request */
-       struct dst_cmd          cmd;
-};
-
-struct dst_crypto_engine
-{
-       /* What should we do with all block requests */
-       struct crypto_hash      *hash;
-       struct crypto_ablkcipher        *cipher;
-
-       /* Pool of pages used to encrypt data into before sending */
-       int                     page_num;
-       struct page             **pages;
-
-       /* What to do with current request */
-       int                     enc;
-       /* Who we are and where do we go */
-       struct scatterlist      *src, *dst;
-
-       /* Maximum timeout waiting for encryption to be completed */
-       long                    timeout;
-       /* IV is a 64-bit sequential counter */
-       u64                     iv;
-
-       /* Secret data */
-       void                    *private;
-
-       /* Cached temporary data lives here */
-       int                     size;
-       void                    *data;
-};
-
-struct dst_state
-{
-       /* The main state protection */
-       struct mutex            state_lock;
-
-       /* Polling machinery for sockets */
-       wait_queue_t            wait;
-       wait_queue_head_t       *whead;
-       /* Most of events are being waited here */
-       wait_queue_head_t       thread_wait;
-
-       /* Who owns this? */
-       struct dst_node         *node;
-
-       /* Network address for this state */
-       struct dst_network_ctl  ctl;
-
-       /* Permissions to work with: read-only or rw connection */
-       u32                     permissions;
-
-       /* Called when we need to clean private data */
-       void                    (* cleanup)(struct dst_state *st);
-
-       /* Used by the server: BIO completion queues BIOs here */
-       struct list_head        request_list;
-       spinlock_t              request_lock;
-
-       /* Guess what? No, it is not number of planets */
-       atomic_t                refcnt;
-
-       /* This flags is set when connection should be dropped */
-       int                     need_exit;
-
-       /*
-        * Socket to work with. Second pointer is used for
-        * lockless check if socket was changed before performing
-        * next action (like working with cached polling result)
-        */
-       struct socket           *socket, *read_socket;
-
-       /* Cached preallocated data */
-       void                    *data;
-       unsigned int            size;
-
-       /* Currently processed command */
-       struct dst_cmd          cmd;
-};
-
-struct dst_info
-{
-       /* Device size */
-       u64                     size;
-
-       /* Local device name for export devices */
-       char                    local[DST_NAMELEN];
-
-       /* Network setup */
-       struct dst_network_ctl  net;
-
-       /* Sysfs bits use this */
-       struct device           device;
-};
-
-struct dst_node
-{
-       struct list_head        node_entry;
-
-       /* Hi, my name is stored here */
-       char                    name[DST_NAMELEN];
-       /* My cache name is stored here */
-       char                    cache_name[DST_NAMELEN];
-
-       /* Block device attached to given node.
-        * Only valid for exporting nodes */
-       struct block_device     *bdev;
-       /* Network state machine for given peer */
-       struct dst_state        *state;
-
-       /* Block IO machinery */
-       struct request_queue    *queue;
-       struct gendisk          *disk;
-
-       /* Number of threads in processing pool */
-       int                     thread_num;
-       /* Maximum number of pages in single IO */
-       int                     max_pages;
-
-       /* I'm that big in bytes */
-       loff_t                  size;
-
-       /* Exported to userspace node information */
-       struct dst_info         *info;
-
-       /*
-        * Security attribute list.
-        * Used only by exporting node currently.
-        */
-       struct list_head        security_list;
-       struct mutex            security_lock;
-
-       /*
-        * When this unerflows below zero, university collapses.
-        * But this will not happen, since node will be freed,
-        * when reference counter reaches zero.
-        */
-       atomic_t                refcnt;
-
-       /* How precisely should I be started? */
-       int                     (*start)(struct dst_node *);
-
-       /* Crypto capabilities */
-       struct dst_crypto_ctl   crypto;
-       u8                      *hash_key;
-       u8                      *cipher_key;
-
-       /* Pool of processing thread */
-       struct thread_pool      *pool;
-
-       /* Transaction IDs live here */
-       atomic_long_t           gen;
-
-       /*
-        * How frequently and how many times transaction
-        * tree should be scanned to drop stale objects.
-        */
-       long                    trans_scan_timeout;
-       int                     trans_max_retries;
-
-       /* Small gnomes live here */
-       struct rb_root          trans_root;
-       struct mutex            trans_lock;
-
-       /*
-        * Transaction cache/memory pool.
-        * It is big enough to contain not only transaction
-        * itself, but additional crypto data (digest/hmac).
-        */
-       struct kmem_cache       *trans_cache;
-       mempool_t               *trans_pool;
-
-       /* This entity scans transaction tree */
-       struct delayed_work     trans_work;
-
-       wait_queue_head_t       wait;
-};
-
-/* Kernel representation of the security attribute */
-struct dst_secure
-{
-       struct list_head        sec_entry;
-       struct dst_secure_user  sec;
-};
-
-int dst_process_bio(struct dst_node *n, struct bio *bio);
-
-int dst_node_init_connected(struct dst_node *n, struct dst_network_ctl *r);
-int dst_node_init_listened(struct dst_node *n, struct dst_export_ctl *le);
-
-static inline struct dst_state *dst_state_get(struct dst_state *st)
-{
-       BUG_ON(atomic_read(&st->refcnt) == 0);
-       atomic_inc(&st->refcnt);
-       return st;
-}
-
-void dst_state_put(struct dst_state *st);
-
-struct dst_state *dst_state_alloc(struct dst_node *n);
-int dst_state_socket_create(struct dst_state *st);
-void dst_state_socket_release(struct dst_state *st);
-
-void dst_state_exit_connected(struct dst_state *st);
-
-int dst_state_schedule_receiver(struct dst_state *st);
-
-void dst_dump_addr(struct socket *sk, struct sockaddr *sa, char *str);
-
-static inline void dst_state_lock(struct dst_state *st)
-{
-       mutex_lock(&st->state_lock);
-}
-
-static inline void dst_state_unlock(struct dst_state *st)
-{
-       mutex_unlock(&st->state_lock);
-}
-
-void dst_poll_exit(struct dst_state *st);
-int dst_poll_init(struct dst_state *st);
-
-static inline unsigned int dst_state_poll(struct dst_state *st)
-{
-       unsigned int revents = POLLHUP | POLLERR;
-
-       dst_state_lock(st);
-       if (st->socket)
-               revents = st->socket->ops->poll(NULL, st->socket, NULL);
-       dst_state_unlock(st);
-
-       return revents;
-}
-
-static inline int dst_thread_setup(void *private, void *data)
-{
-       return 0;
-}
-
-void dst_node_put(struct dst_node *n);
-
-static inline struct dst_node *dst_node_get(struct dst_node *n)
-{
-       atomic_inc(&n->refcnt);
-       return n;
-}
-
-int dst_data_recv(struct dst_state *st, void *data, unsigned int size);
-int dst_recv_cdata(struct dst_state *st, void *cdata);
-int dst_data_send_header(struct socket *sock,
-               void *data, unsigned int size, int more);
-
-int dst_send_bio(struct dst_state *st, struct dst_cmd *cmd, struct bio *bio);
-
-int dst_process_io(struct dst_state *st);
-int dst_export_crypto(struct dst_node *n, struct bio *bio);
-int dst_export_send_bio(struct bio *bio);
-int dst_start_export(struct dst_node *n);
-
-int __init dst_export_init(void);
-void dst_export_exit(void);
-
-/* Private structure for export block IO requests */
-struct dst_export_priv
-{
-       struct list_head                request_entry;
-       struct dst_state                *state;
-       struct bio                      *bio;
-       struct dst_cmd                  cmd;
-};
-
-static inline void dst_trans_get(struct dst_trans *t)
-{
-       atomic_inc(&t->refcnt);
-}
-
-struct dst_trans *dst_trans_search(struct dst_node *node, dst_gen_t gen);
-int dst_trans_remove(struct dst_trans *t);
-int dst_trans_remove_nolock(struct dst_trans *t);
-void dst_trans_put(struct dst_trans *t);
-
-/*
- * Convert bio into network command.
- */
-static inline void dst_bio_to_cmd(struct bio *bio, struct dst_cmd *cmd,
-               u32 command, u64 id)
-{
-       cmd->cmd = command;
-       cmd->flags = (bio->bi_flags << BIO_POOL_BITS) >> BIO_POOL_BITS;
-       cmd->rw = bio->bi_rw;
-       cmd->size = bio->bi_size;
-       cmd->csize = 0;
-       cmd->id = id;
-       cmd->sector = bio->bi_sector;
-};
-
-int dst_trans_send(struct dst_trans *t);
-int dst_trans_crypto(struct dst_trans *t);
-
-int dst_node_crypto_init(struct dst_node *n, struct dst_crypto_ctl *ctl);
-void dst_node_crypto_exit(struct dst_node *n);
-
-static inline int dst_need_crypto(struct dst_node *n)
-{
-       struct dst_crypto_ctl *c = &n->crypto;
-       /*
-        * Logical OR is appropriate here, but boolean one produces
-        * more optimal code, so it is used instead.
-        */
-       return (c->hash_algo[0] | c->cipher_algo[0]);
-}
-
-int dst_node_trans_init(struct dst_node *n, unsigned int size);
-void dst_node_trans_exit(struct dst_node *n);
-
-/*
- * Pool of threads.
- * Ready list contains threads currently free to be used,
- * active one contains threads with some work scheduled for them.
- * Caller can wait in given queue when thread is ready.
- */
-struct thread_pool
-{
-       int                     thread_num;
-       struct mutex            thread_lock;
-       struct list_head        ready_list, active_list;
-
-       wait_queue_head_t       wait;
-};
-
-void thread_pool_del_worker(struct thread_pool *p);
-void thread_pool_del_worker_id(struct thread_pool *p, unsigned int id);
-int thread_pool_add_worker(struct thread_pool *p,
-               char *name,
-               unsigned int id,
-               void *(* init)(void *data),
-               void (* cleanup)(void *data),
-               void *data);
-
-void thread_pool_destroy(struct thread_pool *p);
-struct thread_pool *thread_pool_create(int num, char *name,
-               void *(* init)(void *data),
-               void (* cleanup)(void *data),
-               void *data);
-
-int thread_pool_schedule(struct thread_pool *p,
-               int (* setup)(void *stored_private, void *setup_data),
-               int (* action)(void *stored_private, void *setup_data),
-               void *setup_data, long timeout);
-int thread_pool_schedule_private(struct thread_pool *p,
-               int (* setup)(void *private, void *data),
-               int (* action)(void *private, void *data),
-               void *data, long timeout, void *id);
-
-#endif /* __KERNEL__ */
-#endif /* __DST_H */
index a0d9422a15693cdd5ab978bdff8c18985f570c9a..f8c2e17675002ec1508742ad629610a3e76f19da 100644 (file)
@@ -57,8 +57,7 @@ extern int ddebug_remove_module(char *mod_name);
        { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH,  \
                DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT };        \
        if (__dynamic_dbg_enabled(descriptor))                          \
-               printk(KERN_DEBUG KBUILD_MODNAME ":" pr_fmt(fmt),       \
-                               ##__VA_ARGS__);                         \
+               printk(KERN_DEBUG pr_fmt(fmt),  ##__VA_ARGS__);         \
        } while (0)
 
 
@@ -69,9 +68,7 @@ extern int ddebug_remove_module(char *mod_name);
        { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH,  \
                DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT };        \
        if (__dynamic_dbg_enabled(descriptor))                          \
-                       dev_printk(KERN_DEBUG, dev,                     \
-                                       KBUILD_MODNAME ": " fmt,        \
-                                       ##__VA_ARGS__);                 \
+               dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);        \
        } while (0)
 
 #else
@@ -81,8 +78,10 @@ static inline int ddebug_remove_module(char *mod)
        return 0;
 }
 
-#define dynamic_pr_debug(fmt, ...)  do { } while (0)
-#define dynamic_dev_dbg(dev, format, ...)  do { } while (0)
+#define dynamic_pr_debug(fmt, ...)                                     \
+       do { if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); } while (0)
+#define dynamic_dev_dbg(dev, format, ...)                              \
+       do { if (0) dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); } while (0)
 #endif
 
 #endif
index ce4581fbc08beec42b44882b367f9ef49f3389c4..fb737bc19a8ce233fa016e71ccf77461c5e81dbc 100644 (file)
@@ -280,11 +280,7 @@ efi_guidcmp (efi_guid_t left, efi_guid_t right)
 static inline char *
 efi_guid_unparse(efi_guid_t *guid, char *out)
 {
-       sprintf(out, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-               guid->b[3], guid->b[2], guid->b[1], guid->b[0],
-               guid->b[5], guid->b[4], guid->b[7], guid->b[6],
-               guid->b[8], guid->b[9], guid->b[10], guid->b[11],
-               guid->b[12], guid->b[13], guid->b[14], guid->b[15]);
+       sprintf(out, "%pUl", guid->b);
         return out;
 }
 
index 90a4ed0ea0e5201c21cd475dc52a330f97b0a67b..0cc4d55151b7cbcc37071ea04fe6f57f94401bca 100644 (file)
@@ -361,7 +361,7 @@ typedef struct elf64_shdr {
 #define NT_PPC_VSX     0x102           /* PowerPC VSX registers */
 #define NT_386_TLS     0x200           /* i386 TLS slots (struct user_desc) */
 #define NT_386_IOPERM  0x201           /* x86 io permission bitmap (1=deny) */
-#define NT_PRXSTATUS   0x300           /* s390 upper register halves */
+#define NT_S390_HIGH_GPRS      0x300   /* s390 upper register halves */
 
 
 /* Note header in a PT_NOTE section */
index 90d1c21841125484021456f6aeba65e7cae7d0f9..9a33c5f7e1265fd23ee74462e3e93944cf414997 100644 (file)
@@ -42,6 +42,8 @@ enum enclosure_status {
        ENCLOSURE_STATUS_NOT_INSTALLED,
        ENCLOSURE_STATUS_UNKNOWN,
        ENCLOSURE_STATUS_UNAVAILABLE,
+       /* last element for counting purposes */
+       ENCLOSURE_STATUS_MAX
 };
 
 /* SFF-8485 activity light settings */
index ec87f3142bf30940c31911e71e6638d749de8f04..1b12642636c7a121f3a3797676cf8d4746ca13a9 100644 (file)
@@ -34,6 +34,11 @@ static inline long IS_ERR(const void *ptr)
        return IS_ERR_VALUE((unsigned long)ptr);
 }
 
+static inline long IS_ERR_OR_NULL(const void *ptr)
+{
+       return !ptr || IS_ERR_VALUE((unsigned long)ptr);
+}
+
 /**
  * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
  * @ptr: The pointer to cast.
index 27e772cefb6a5b88e7f8605b3fb817c341d12e4a..dc12f416a49f6ed9054a1f59c0c91a9ea4f58d4e 100644 (file)
@@ -97,7 +97,7 @@ struct fid {
  * @get_name:       find the name for a given inode in a given directory
  * @get_parent:     find the parent of a given directory
  *
- * See Documentation/filesystems/Exporting for details on how to use
+ * See Documentation/filesystems/nfs/Exporting for details on how to use
  * this interface correctly.
  *
  * encode_fh:
index f07f34de2f0ecb7ed987c49c604ce3efce4690e6..258088ab3c6bab4e3bad8ce5b5c987532dc9a90d 100644 (file)
@@ -72,6 +72,8 @@ struct ext3_sb_info {
        struct inode * s_journal_inode;
        struct journal_s * s_journal;
        struct list_head s_orphan;
+       struct mutex s_orphan_lock;
+       struct mutex s_resize_lock;
        unsigned long s_commit_interval;
        struct block_device *journal_bdev;
 #ifdef CONFIG_JBD_DEBUG
index cf82d519be408b7b97a2a0edd3e796d5eff8c2b5..d7b5ddca99c2467b6d05c6e7b6253bb75c3be567 100644 (file)
 
 #define EXT3_DATA_TRANS_BLOCKS(sb)     (EXT3_SINGLEDATA_TRANS_BLOCKS + \
                                         EXT3_XATTR_TRANS_BLOCKS - 2 + \
-                                        2*EXT3_QUOTA_TRANS_BLOCKS(sb))
+                                        EXT3_MAXQUOTAS_TRANS_BLOCKS(sb))
 
 /* Delete operations potentially hit one directory's namespace plus an
  * entire inode, plus arbitrary amounts of bitmap/indirection data.  Be
  * generous.  We can grow the delete transaction later if necessary. */
 
-#define EXT3_DELETE_TRANS_BLOCKS(sb)   (2 * EXT3_DATA_TRANS_BLOCKS(sb) + 64)
+#define EXT3_DELETE_TRANS_BLOCKS(sb)   (EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) + 64)
 
 /* Define an arbitrary limit for the amount of data we will anticipate
  * writing to any given transaction.  For unbounded transactions such as
@@ -86,6 +86,9 @@
 #define EXT3_QUOTA_INIT_BLOCKS(sb) 0
 #define EXT3_QUOTA_DEL_BLOCKS(sb) 0
 #endif
+#define EXT3_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_TRANS_BLOCKS(sb))
+#define EXT3_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_INIT_BLOCKS(sb))
+#define EXT3_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT3_QUOTA_DEL_BLOCKS(sb))
 
 int
 ext3_mark_iloc_dirty(handle_t *handle,
index 934e22d65801e508f03774f5cb86fd4ae7b35e68..d830747f5c0b077e7ac894a687258ec82979af69 100644 (file)
@@ -62,5 +62,7 @@ struct fiemap {
 #define FIEMAP_EXTENT_MERGED           0x00001000 /* File does not natively
                                                    * support extents. Result
                                                    * merged for efficiency. */
+#define FIEMAP_EXTENT_SHARED           0x00002000 /* Space shared with other
+                                                   * files. */
 
 #endif /* _LINUX_FIEMAP_H */
index 335a0a5c316e4b8fa66864af63059fa59c3ad506..5555508fd5171f6c7a546c2d7364876223e7c9cc 100644 (file)
@@ -18,11 +18,9 @@ extern void drop_file_write_access(struct file *file);
 struct file_operations;
 struct vfsmount;
 struct dentry;
-extern int init_file(struct file *, struct vfsmount *mnt,
-               struct dentry *dentry, fmode_t mode,
-               const struct file_operations *fop);
-extern struct file *alloc_file(struct vfsmount *, struct dentry *dentry,
-               fmode_t mode, const struct file_operations *fop);
+struct path;
+extern struct file *alloc_file(struct path *, fmode_t mode,
+       const struct file_operations *fop);
 
 static inline void fput_light(struct file *file, int fput_needed)
 {
index a057f48eb156ca2fb015ddedabd3dbb1da473f1b..9147ca88f253ec1bd35b70b5313cd9f63c0a61d5 100644 (file)
@@ -152,6 +152,7 @@ struct inodes_stat_t {
 #define WRITE_SYNC_PLUG        (WRITE | (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_NOIDLE))
 #define WRITE_SYNC     (WRITE_SYNC_PLUG | (1 << BIO_RW_UNPLUG))
 #define WRITE_ODIRECT_PLUG     (WRITE | (1 << BIO_RW_SYNCIO))
+#define WRITE_META     (WRITE | (1 << BIO_RW_META))
 #define SWRITE_SYNC_PLUG       \
                        (SWRITE | (1 << BIO_RW_SYNCIO) | (1 << BIO_RW_NOIDLE))
 #define SWRITE_SYNC    (SWRITE_SYNC_PLUG | (1 << BIO_RW_UNPLUG))
@@ -1094,10 +1095,6 @@ struct file_lock {
 
 extern void send_sigio(struct fown_struct *fown, int fd, int band);
 
-/* fs/sync.c */
-extern int do_sync_mapping_range(struct address_space *mapping, loff_t offset,
-                       loff_t endbyte, unsigned int flags);
-
 #ifdef CONFIG_FILE_LOCKING
 extern int fcntl_getlk(struct file *, struct flock __user *);
 extern int fcntl_setlk(unsigned int, struct file *, unsigned int,
@@ -1590,7 +1587,7 @@ struct super_operations {
  * until that flag is cleared.  I_WILL_FREE, I_FREEING and I_CLEAR are set at
  * various stages of removing an inode.
  *
- * Two bits are used for locking and completion notification, I_LOCK and I_SYNC.
+ * Two bits are used for locking and completion notification, I_NEW and I_SYNC.
  *
  * I_DIRTY_SYNC                Inode is dirty, but doesn't have to be written on
  *                     fdatasync().  i_atime is the usual cause.
@@ -1599,8 +1596,14 @@ struct super_operations {
  *                     don't have to write inode on fdatasync() when only
  *                     mtime has changed in it.
  * I_DIRTY_PAGES       Inode has dirty pages.  Inode itself may be clean.
- * I_NEW               get_new_inode() sets i_state to I_LOCK|I_NEW.  Both
- *                     are cleared by unlock_new_inode(), called from iget().
+ * I_NEW               Serves as both a mutex and completion notification.
+ *                     New inodes set I_NEW.  If two processes both create
+ *                     the same inode, one of them will release its inode and
+ *                     wait for I_NEW to be released before returning.
+ *                     Inodes in I_WILL_FREE, I_FREEING or I_CLEAR state can
+ *                     also cause waiting on I_NEW, without I_NEW actually
+ *                     being set.  find_inode() uses this to prevent returning
+ *                     nearly-dead inodes.
  * I_WILL_FREE         Must be set when calling write_inode_now() if i_count
  *                     is zero.  I_FREEING must be set when I_WILL_FREE is
  *                     cleared.
@@ -1614,35 +1617,23 @@ struct super_operations {
  *                     prohibited for many purposes.  iget() must wait for
  *                     the inode to be completely released, then create it
  *                     anew.  Other functions will just ignore such inodes,
- *                     if appropriate.  I_LOCK is used for waiting.
+ *                     if appropriate.  I_NEW is used for waiting.
  *
- * I_LOCK              Serves as both a mutex and completion notification.
- *                     New inodes set I_LOCK.  If two processes both create
- *                     the same inode, one of them will release its inode and
- *                     wait for I_LOCK to be released before returning.
- *                     Inodes in I_WILL_FREE, I_FREEING or I_CLEAR state can
- *                     also cause waiting on I_LOCK, without I_LOCK actually
- *                     being set.  find_inode() uses this to prevent returning
- *                     nearly-dead inodes.
- * I_SYNC              Similar to I_LOCK, but limited in scope to writeback
- *                     of inode dirty data.  Having a separate lock for this
- *                     purpose reduces latency and prevents some filesystem-
- *                     specific deadlocks.
+ * I_SYNC              Synchonized write of dirty inode data.  The bits is
+ *                     set during data writeback, and cleared with a wakeup
+ *                     on the bit address once it is done.
  *
  * Q: What is the difference between I_WILL_FREE and I_FREEING?
- * Q: igrab() only checks on (I_FREEING|I_WILL_FREE).  Should it also check on
- *    I_CLEAR?  If not, why?
  */
 #define I_DIRTY_SYNC           1
 #define I_DIRTY_DATASYNC       2
 #define I_DIRTY_PAGES          4
-#define I_NEW                  8
+#define __I_NEW                        3
+#define I_NEW                  (1 << __I_NEW)
 #define I_WILL_FREE            16
 #define I_FREEING              32
 #define I_CLEAR                        64
-#define __I_LOCK               7
-#define I_LOCK                 (1 << __I_LOCK)
-#define __I_SYNC               8
+#define __I_SYNC               7
 #define I_SYNC                 (1 << __I_SYNC)
 
 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
@@ -2189,7 +2180,6 @@ static inline void insert_inode_hash(struct inode *inode) {
        __insert_inode_hash(inode, inode->i_ino);
 }
 
-extern struct file * get_empty_filp(void);
 extern void file_move(struct file *f, struct list_head *list);
 extern void file_kill(struct file *f);
 #ifdef CONFIG_BLOCK
@@ -2264,9 +2254,11 @@ ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
        int lock_type);
 
 enum {
-       DIO_LOCKING = 1, /* need locking between buffered and direct access */
-       DIO_NO_LOCKING,  /* bdev; no locking at all between buffered/direct */
-       DIO_OWN_LOCKING, /* filesystem locks buffered and direct internally */
+       /* need locking between buffered and direct access */
+       DIO_LOCKING     = 0x01,
+
+       /* filesystem does not support filling holes */
+       DIO_SKIP_HOLES  = 0x02,
 };
 
 static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
@@ -2275,7 +2267,8 @@ static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
        dio_iodone_t end_io)
 {
        return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
-                               nr_segs, get_block, end_io, DIO_LOCKING);
+                                   nr_segs, get_block, end_io,
+                                   DIO_LOCKING | DIO_SKIP_HOLES);
 }
 
 static inline ssize_t blockdev_direct_IO_no_locking(int rw, struct kiocb *iocb,
@@ -2284,16 +2277,7 @@ static inline ssize_t blockdev_direct_IO_no_locking(int rw, struct kiocb *iocb,
        dio_iodone_t end_io)
 {
        return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
-                               nr_segs, get_block, end_io, DIO_NO_LOCKING);
-}
-
-static inline ssize_t blockdev_direct_IO_own_locking(int rw, struct kiocb *iocb,
-       struct inode *inode, struct block_device *bdev, const struct iovec *iov,
-       loff_t offset, unsigned long nr_segs, get_block_t get_block,
-       dio_iodone_t end_io)
-{
-       return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset,
-                               nr_segs, get_block, end_io, DIO_OWN_LOCKING);
+                               nr_segs, get_block, end_io, 0);
 }
 #endif
 
@@ -2313,6 +2297,7 @@ extern const struct inode_operations page_symlink_inode_operations;
 extern int generic_readlink(struct dentry *, char __user *, int);
 extern void generic_fillattr(struct inode *, struct kstat *);
 extern int vfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
+void __inode_add_bytes(struct inode *inode, loff_t bytes);
 void inode_add_bytes(struct inode *inode, loff_t bytes);
 void inode_sub_bytes(struct inode *inode, loff_t bytes);
 loff_t inode_get_bytes(struct inode *inode);
@@ -2478,5 +2463,8 @@ int proc_nr_files(struct ctl_table *table, int write,
 
 int __init get_filesystem_list(char *buf);
 
+#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
+#define OPEN_FMODE(flag) ((__force fmode_t)((flag + 1) & O_ACCMODE))
+
 #endif /* __KERNEL__ */
 #endif /* _LINUX_FS_H */
index bb516ceeefc91835d083c2184eec9761ebdd7c87..da317c7163ab55c4ff6e3552c58ecb7db916ce7e 100644 (file)
@@ -8,10 +8,8 @@
 #include <linux/fs.h>
 
 /* externs for fs/stack.c */
-extern void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
-                               int (*get_nlinks)(struct inode *));
-
-extern void fsstack_copy_inode_size(struct inode *dst, const struct inode *src);
+extern void fsstack_copy_attr_all(struct inode *dest, const struct inode *src);
+extern void fsstack_copy_inode_size(struct inode *dst, struct inode *src);
 
 /* inlines */
 static inline void fsstack_copy_attr_atime(struct inode *dest,
index 38f8d6553831a6a9ee2839ac56071b795700d917..2233c98d80df5f473ba2f8616f8f3b55e6afd0a4 100644 (file)
@@ -131,7 +131,7 @@ struct ftrace_event_call {
        void                    *mod;
        void                    *data;
 
-       atomic_t                profile_count;
+       int                     profile_count;
        int                     (*profile_enable)(struct ftrace_event_call *);
        void                    (*profile_disable)(struct ftrace_event_call *);
 };
@@ -158,7 +158,7 @@ enum {
        FILTER_PTR_STRING,
 };
 
-extern int trace_define_common_fields(struct ftrace_event_call *call);
+extern int trace_event_raw_init(struct ftrace_event_call *call);
 extern int trace_define_field(struct ftrace_event_call *call, const char *type,
                              const char *name, int offset, int size,
                              int is_signed, int filter_type);
index 886f5faa08cb6f1ff8c84ff2da04e9144d01c9df..ca666d18ed6769418d1de90e45b690ec9e9eae36 100644 (file)
@@ -1,36 +1,15 @@
-/*
- * include/linux/generic_acl.h
- *
- * (C) 2005 Andreas Gruenbacher <agruen@suse.de>
- *
- * This file is released under the GPL.
- */
+#ifndef LINUX_GENERIC_ACL_H
+#define LINUX_GENERIC_ACL_H
 
-#ifndef GENERIC_ACL_H
-#define GENERIC_ACL_H
+#include <linux/xattr.h>
 
-#include <linux/posix_acl.h>
-#include <linux/posix_acl_xattr.h>
+struct inode;
 
-/**
- * struct generic_acl_operations  -  filesystem operations
- *
- * Filesystems must make these operations available to the generic
- * operations.
- */
-struct generic_acl_operations {
-       struct posix_acl *(*getacl)(struct inode *, int);
-       void (*setacl)(struct inode *, int, struct posix_acl *);
-};
+extern struct xattr_handler generic_acl_access_handler;
+extern struct xattr_handler generic_acl_default_handler;
 
-size_t generic_acl_list(struct inode *, struct generic_acl_operations *, int,
-                       char *, size_t);
-int generic_acl_get(struct inode *, struct generic_acl_operations *, int,
-                   void *, size_t);
-int generic_acl_set(struct inode *, struct generic_acl_operations *, int,
-                   const void *, size_t);
-int generic_acl_init(struct inode *, struct inode *,
-                    struct generic_acl_operations *);
-int generic_acl_chmod(struct inode *, struct generic_acl_operations *);
+int generic_acl_init(struct inode *, struct inode *);
+int generic_acl_chmod(struct inode *);
+int generic_check_acl(struct inode *inode, int mask);
 
-#endif
+#endif /* LINUX_GENERIC_ACL_H */
index 059bd189d35ddd1d1e6931b0aa4ddc2c95a9c9a3..4e949a5b5b85d810938561328210598ac2055512 100644 (file)
@@ -99,6 +99,12 @@ static inline int gpio_export_link(struct device *dev, const char *name,
        return -EINVAL;
 }
 
+static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
+{
+       /* GPIO can never have been requested */
+       WARN_ON(1);
+       return -EINVAL;
+}
 
 static inline void gpio_unexport(unsigned gpio)
 {
index af634e95871deb2dca0b4ef2d2d5a116bc83b0c2..5d86fb2309d254664188129eab654b4d94f15b8e 100644 (file)
@@ -169,7 +169,7 @@ struct hrtimer_clock_base {
  * @max_hang_time:     Maximum time spent in hrtimer_interrupt
  */
 struct hrtimer_cpu_base {
-       spinlock_t                      lock;
+       raw_spinlock_t                  lock;
        struct hrtimer_clock_base       clock_base[HRTIMER_MAX_CLOCK_BASES];
 #ifdef CONFIG_HIGH_RES_TIMERS
        ktime_t                         expires_next;
index 41a59afc70faffdccd55fa9d0a0616df15fcb7ff..78b4bc64c0064f19bccce02de2862813d56ff7e0 100644 (file)
@@ -23,6 +23,12 @@ void reset_vma_resv_huge_pages(struct vm_area_struct *vma);
 int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
 int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
 int hugetlb_treat_movable_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
+
+#ifdef CONFIG_NUMA
+int hugetlb_mempolicy_sysctl_handler(struct ctl_table *, int,
+                                       void __user *, size_t *, loff_t *);
+#endif
+
 int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
 int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *,
                        struct page **, struct vm_area_struct **,
index 419ab546b2661909149eed8f362e40f75c240898..02fc617782ef7b5f5046cc9b6ac7df88536e24b9 100644 (file)
@@ -110,7 +110,7 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client,
  * @driver: Device driver model driver
  * @id_table: List of I2C devices supported by this driver
  * @detect: Callback for device detection
- * @address_data: The I2C addresses to probe (for detect)
+ * @address_list: The I2C addresses to probe (for detect)
  * @clients: List of detected clients we created (for i2c-core use only)
  *
  * The driver.owner field should be set to the module owner of this driver.
@@ -161,8 +161,8 @@ struct i2c_driver {
        const struct i2c_device_id *id_table;
 
        /* Device detection callback for automatic device creation */
-       int (*detect)(struct i2c_client *, int kind, struct i2c_board_info *);
-       const struct i2c_client_address_data *address_data;
+       int (*detect)(struct i2c_client *, struct i2c_board_info *);
+       const unsigned short *address_list;
        struct list_head clients;
 };
 #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
@@ -391,14 +391,6 @@ static inline void i2c_unlock_adapter(struct i2c_adapter *adapter)
 #define I2C_CLASS_DDC          (1<<3)  /* DDC bus on graphics adapters */
 #define I2C_CLASS_SPD          (1<<7)  /* SPD EEPROMs and similar */
 
-/* i2c_client_address_data is the struct for holding default client
- * addresses for a driver and for the parameters supplied on the
- * command line
- */
-struct i2c_client_address_data {
-       const unsigned short *normal_i2c;
-};
-
 /* Internal numbers to terminate lists */
 #define I2C_CLIENT_END         0xfffeU
 
@@ -576,82 +568,4 @@ union i2c_smbus_data {
 #define I2C_SMBUS_BLOCK_PROC_CALL   7          /* SMBus 2.0 */
 #define I2C_SMBUS_I2C_BLOCK_DATA    8
 
-
-#ifdef __KERNEL__
-
-/* These defines are used for probing i2c client addresses */
-/* The length of the option lists */
-#define I2C_CLIENT_MAX_OPTS 48
-
-/* Default fill of many variables */
-#define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
-                            I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END}
-
-/* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the
-   module header */
-
-#define I2C_CLIENT_MODULE_PARM(var,desc) \
-  static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
-  static unsigned int var##_num; \
-  module_param_array(var, short, &var##_num, 0); \
-  MODULE_PARM_DESC(var, desc)
-
-#define I2C_CLIENT_INSMOD_COMMON                                       \
-static const struct i2c_client_address_data addr_data = {              \
-       .normal_i2c     = normal_i2c,                                   \
-}
-
-/* These are the ones you want to use in your own drivers. Pick the one
-   which matches the number of devices the driver differenciates between. */
-#define I2C_CLIENT_INSMOD                                              \
-I2C_CLIENT_INSMOD_COMMON
-
-#define I2C_CLIENT_INSMOD_1(chip1)                                     \
-enum chips { any_chip, chip1 };                                                \
-I2C_CLIENT_INSMOD_COMMON
-
-#define I2C_CLIENT_INSMOD_2(chip1, chip2)                              \
-enum chips { any_chip, chip1, chip2 };                                 \
-I2C_CLIENT_INSMOD_COMMON
-
-#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3)                       \
-enum chips { any_chip, chip1, chip2, chip3 };                          \
-I2C_CLIENT_INSMOD_COMMON
-
-#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4)                        \
-enum chips { any_chip, chip1, chip2, chip3, chip4 };                   \
-I2C_CLIENT_INSMOD_COMMON
-
-#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5)         \
-enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 };            \
-I2C_CLIENT_INSMOD_COMMON
-
-#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6)  \
-enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 };     \
-I2C_CLIENT_INSMOD_COMMON
-
-#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \
-enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6,       \
-            chip7 };                                                   \
-I2C_CLIENT_INSMOD_COMMON
-
-#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \
-enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6,       \
-            chip7, chip8 };                                            \
-I2C_CLIENT_INSMOD_COMMON
-#endif /* __KERNEL__ */
 #endif /* _LINUX_I2C_H */
index d9724a28c0c295db1ceeeb7427d1a7873ae45e00..163c840437d604ca9993b3fc70e3349a3fabd199 100644 (file)
@@ -832,7 +832,7 @@ struct ieee80211_ht_cap {
 #define IEEE80211_HT_CAP_DELAY_BA              0x0400
 #define IEEE80211_HT_CAP_MAX_AMSDU             0x0800
 #define IEEE80211_HT_CAP_DSSSCCK40             0x1000
-#define IEEE80211_HT_CAP_PSMP_SUPPORT          0x2000
+#define IEEE80211_HT_CAP_RESERVED              0x2000
 #define IEEE80211_HT_CAP_40MHZ_INTOLERANT      0x4000
 #define IEEE80211_HT_CAP_LSIG_TXOP_PROT                0x8000
 
index 0e3f2a4c25f6ef0270f8e007a985a21cb74d6234..99dc6d5cf7e59bc0412fbbd7afad788f04db933f 100644 (file)
 #include <linux/fs.h>
 struct linux_binprm;
 
-#define IMA_COUNT_UPDATE 1
-#define IMA_COUNT_LEAVE 0
-
 #ifdef CONFIG_IMA
 extern int ima_bprm_check(struct linux_binprm *bprm);
 extern int ima_inode_alloc(struct inode *inode);
 extern void ima_inode_free(struct inode *inode);
-extern int ima_path_check(struct path *path, int mask, int update_counts);
+extern int ima_path_check(struct path *path, int mask);
 extern void ima_file_free(struct file *file);
 extern int ima_file_mmap(struct file *file, unsigned long prot);
 extern void ima_counts_get(struct file *file);
-extern void ima_counts_put(struct path *path, int mask);
 
 #else
 static inline int ima_bprm_check(struct linux_binprm *bprm)
@@ -42,7 +38,7 @@ static inline void ima_inode_free(struct inode *inode)
        return;
 }
 
-static inline int ima_path_check(struct path *path, int mask, int update_counts)
+static inline int ima_path_check(struct path *path, int mask)
 {
        return 0;
 }
@@ -62,9 +58,5 @@ static inline void ima_counts_get(struct file *file)
        return;
 }
 
-static inline void ima_counts_put(struct path *path, int mask)
-{
-       return;
-}
 #endif /* CONFIG_IMA_H */
 #endif /* _LINUX_IMA_H */
index 699e85c01a4d78efcf0df4ac0fb61f01e736ee5c..b2304929434e27591a750ff7b8dbb066fa2b5759 100644 (file)
@@ -81,6 +81,7 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev)
 #define IN_DEV_FORWARD(in_dev)         IN_DEV_CONF_GET((in_dev), FORWARDING)
 #define IN_DEV_MFORWARD(in_dev)                IN_DEV_ANDCONF((in_dev), MC_FORWARDING)
 #define IN_DEV_RPFILTER(in_dev)                IN_DEV_MAXCONF((in_dev), RP_FILTER)
+#define IN_DEV_SRC_VMARK(in_dev)       IN_DEV_ORCONF((in_dev), SRC_VMARK)
 #define IN_DEV_SOURCE_ROUTE(in_dev)    IN_DEV_ANDCONF((in_dev), \
                                                       ACCEPT_SOURCE_ROUTE)
 #define IN_DEV_ACCEPT_LOCAL(in_dev)    IN_DEV_ORCONF((in_dev), ACCEPT_LOCAL)
index ff8bde520d03b078c5e343dd9437f005fe915fa2..ab1d31f9352bbcefb46369667c145c3615b29a2c 100644 (file)
@@ -149,6 +149,8 @@ void prepare_namespace(void);
 
 extern void (*late_time_init)(void);
 
+extern int initcall_debug;
+
 #endif
   
 #ifndef MODULE
index 8d10aa7fd4c983c6efec569096f82092c837ea3d..abec69b63d7e3a5d65f2bc430a0cd389138367b0 100644 (file)
@@ -165,7 +165,7 @@ extern struct cred init_cred;
        .journal_info   = NULL,                                         \
        .cpu_timers     = INIT_CPU_TIMERS(tsk.cpu_timers),              \
        .fs_excl        = ATOMIC_INIT(0),                               \
-       .pi_lock        = __SPIN_LOCK_UNLOCKED(tsk.pi_lock),            \
+       .pi_lock        = __RAW_SPIN_LOCK_UNLOCKED(tsk.pi_lock),        \
        .timer_slack_ns = 50000, /* 50 usec default slack */            \
        .pids = {                                                       \
                [PIDTYPE_PID]  = INIT_PID_LINK(PIDTYPE_PID),            \
index 4f0a72a9740cfa86220e3a22816445e36a986705..9310c699a37d451d2f2a24e961b7fab5545753ac 100644 (file)
@@ -332,6 +332,7 @@ struct intel_iommu {
 #ifdef CONFIG_INTR_REMAP
        struct ir_table *ir_table;      /* Interrupt remapping info */
 #endif
+       int             node;
 };
 
 static inline void __iommu_flush_cache(
index 3b068e5b56710222f43bd86a3a5f849128526171..64d1b638745d63bc0ac7569427e583db3236a0cc 100644 (file)
@@ -14,14 +14,11 @@ static inline unsigned long iommu_device_max_index(unsigned long size,
 extern int iommu_is_span_boundary(unsigned int index, unsigned int nr,
                                  unsigned long shift,
                                  unsigned long boundary_size);
-extern void iommu_area_reserve(unsigned long *map, unsigned long i, int len);
 extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
                                      unsigned long start, unsigned int nr,
                                      unsigned long shift,
                                      unsigned long boundary_size,
                                      unsigned long align_mask);
-extern void iommu_area_free(unsigned long *map, unsigned long start,
-                           unsigned int nr);
 
 extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len,
                                     unsigned long io_page_size);
index 83aa81297ea35c693e15b14b54bf2690d9af9648..7129504e053d29c722706990059c77596f3e7c2d 100644 (file)
@@ -126,11 +126,11 @@ extern int allocate_resource(struct resource *root, struct resource *new,
 int adjust_resource(struct resource *res, resource_size_t start,
                    resource_size_t size);
 resource_size_t resource_alignment(struct resource *res);
-static inline resource_size_t resource_size(struct resource *res)
+static inline resource_size_t resource_size(const struct resource *res)
 {
        return res->end - res->start + 1;
 }
-static inline unsigned long resource_type(struct resource *res)
+static inline unsigned long resource_type(const struct resource *res)
 {
        return res->flags & IORESOURCE_TYPE_BITS;
 }
index e408722a84c7bf34754af56a0182eee87855fbc4..07baa38bce3708b52921b2baccd45f095dc753df 100644 (file)
@@ -87,7 +87,7 @@ extern int mq_init_ns(struct ipc_namespace *ns);
 /* default values */
 #define DFLT_QUEUESMAX 256     /* max number of message queues */
 #define DFLT_MSGMAX    10      /* max number of messages in each queue */
-#define HARD_MSGMAX    (131072/sizeof(void *))
+#define HARD_MSGMAX    (32768*sizeof(void *)/4)
 #define DFLT_MSGSIZEMAX 8192   /* max message size */
 #else
 static inline int mq_init_ns(struct ipc_namespace *ns) { return 0; }
index a287cfc0b1a60a65aa9d5055ffa8e049a0923629..451481c082b55c3f571e4dadc1d2b7b386bdfa9a 100644 (file)
@@ -192,7 +192,7 @@ struct irq_desc {
        unsigned int            irq_count;      /* For detecting broken IRQs */
        unsigned long           last_unhandled; /* Aging timer for unhandled count */
        unsigned int            irqs_unhandled;
-       spinlock_t              lock;
+       raw_spinlock_t          lock;
 #ifdef CONFIG_SMP
        cpumask_var_t           affinity;
        unsigned int            node;
index f1011f7f3d4142bf5771007661cec4cd8a6c3315..638ce4554c76e903d632720b3d25dea3350c745b 100644 (file)
@@ -653,6 +653,7 @@ struct transaction_s
         * waiting for it to finish.
         */
        unsigned int t_synchronous_commit:1;
+       unsigned int t_flushed_data_blocks:1;
 
        /*
         * For use by the filesystem to store fs-specific data
index 792274269f2b38bfa288af12b87ec952f742966c..d8e9b3d1c23c3b698081c669e07484496d54960b 100644 (file)
@@ -107,18 +107,6 @@ static inline void print_symbol(const char *fmt, unsigned long addr)
                       __builtin_extract_return_addr((void *)addr));
 }
 
-/*
- * Pretty-print a function pointer.  This function is deprecated.
- * Please use the "%pF" vsprintf format instead.
- */
-static inline void __deprecated print_fn_descriptor_symbol(const char *fmt, void *addr)
-{
-#if defined(CONFIG_IA64) || defined(CONFIG_PPC64)
-       addr = *(void **)addr;
-#endif
-       print_symbol(fmt, (unsigned long)addr);
-}
-
 static inline void print_ip_sym(unsigned long ip)
 {
        printk("[<%p>] %pS\n", (void *) ip, (void *) ip);
diff --git a/include/linux/kernel-page-flags.h b/include/linux/kernel-page-flags.h
new file mode 100644 (file)
index 0000000..bd92a89
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef LINUX_KERNEL_PAGE_FLAGS_H
+#define LINUX_KERNEL_PAGE_FLAGS_H
+
+/*
+ * Stable page flag bits exported to user space
+ */
+
+#define KPF_LOCKED             0
+#define KPF_ERROR              1
+#define KPF_REFERENCED         2
+#define KPF_UPTODATE           3
+#define KPF_DIRTY              4
+#define KPF_LRU                        5
+#define KPF_ACTIVE             6
+#define KPF_SLAB               7
+#define KPF_WRITEBACK          8
+#define KPF_RECLAIM            9
+#define KPF_BUDDY              10
+
+/* 11-20: new additions in 2.6.31 */
+#define KPF_MMAP               11
+#define KPF_ANON               12
+#define KPF_SWAPCACHE          13
+#define KPF_SWAPBACKED         14
+#define KPF_COMPOUND_HEAD      15
+#define KPF_COMPOUND_TAIL      16
+#define KPF_HUGE               17
+#define KPF_UNEVICTABLE                18
+#define KPF_HWPOISON           19
+#define KPF_NOPAGE             20
+
+#define KPF_KSM                        21
+
+/* kernel hacking assistances
+ * WARNING: subject to change, never rely on them!
+ */
+#define KPF_RESERVED           32
+#define KPF_MLOCKED            33
+#define KPF_MAPPEDTODISK       34
+#define KPF_PRIVATE            35
+#define KPF_PRIVATE_2          36
+#define KPF_OWNER_PRIVATE      37
+#define KPF_ARCH               38
+#define KPF_UNCACHED           39
+
+#endif /* LINUX_KERNEL_PAGE_FLAGS_H */
index 3fa4c590cf12de7aef9dd89cf3af1c5dc9661c88..3fc9f5aab5f8fd5f6deb82d464bf78f72940b40d 100644 (file)
@@ -251,10 +251,10 @@ extern int printk_delay_msec;
  * Print a one-time message (analogous to WARN_ONCE() et al):
  */
 #define printk_once(x...) ({                   \
-       static bool __print_once = true;        \
+       static bool __print_once;               \
                                                \
-       if (__print_once) {                     \
-               __print_once = false;           \
+       if (!__print_once) {                    \
+               __print_once = true;            \
                printk(x);                      \
        }                                       \
 })
@@ -397,14 +397,57 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
        printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 #elif defined(CONFIG_DYNAMIC_DEBUG)
 /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
-#define pr_debug(fmt, ...) do { \
-       dynamic_pr_debug(fmt, ##__VA_ARGS__); \
-       } while (0)
+#define pr_debug(fmt, ...) \
+       dynamic_pr_debug(fmt, ##__VA_ARGS__)
 #else
 #define pr_debug(fmt, ...) \
        ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
 #endif
 
+/*
+ * ratelimited messages with local ratelimit_state,
+ * no local ratelimit_state used in the !PRINTK case
+ */
+#ifdef CONFIG_PRINTK
+#define printk_ratelimited(fmt, ...)  ({               \
+       static struct ratelimit_state _rs = {           \
+               .interval = DEFAULT_RATELIMIT_INTERVAL, \
+               .burst = DEFAULT_RATELIMIT_BURST,       \
+       };                                              \
+                                                       \
+       if (!__ratelimit(&_rs))                         \
+               printk(fmt, ##__VA_ARGS__);             \
+})
+#else
+/* No effect, but we still get type checking even in the !PRINTK case: */
+#define printk_ratelimited printk
+#endif
+
+#define pr_emerg_ratelimited(fmt, ...) \
+       printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert_ratelimited(fmt, ...) \
+       printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit_ratelimited(fmt, ...) \
+       printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err_ratelimited(fmt, ...) \
+       printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning_ratelimited(fmt, ...) \
+       printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice_ratelimited(fmt, ...) \
+       printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info_ratelimited(fmt, ...) \
+       printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+/* no pr_cont_ratelimited, don't do that... */
+/* If you are writing a driver, please use dev_dbg instead */
+#if defined(DEBUG)
+#define pr_debug_ratelimited(fmt, ...) \
+       printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#define pr_debug_ratelimited(fmt, ...) \
+       ({ if (0) printk_ratelimited(KERN_DEBUG pr_fmt(fmt), \
+                                    ##__VA_ARGS__); 0; })
+#endif
+
 /*
  * General tracing related utility functions - trace_printk(),
  * tracing_on/tracing_off and tracing_start()/tracing_stop
@@ -492,6 +535,8 @@ extern int
 __trace_printk(unsigned long ip, const char *fmt, ...)
        __attribute__ ((format (printf, 2, 3)));
 
+extern void trace_dump_stack(void);
+
 /*
  * The double __builtin_constant_p is because gcc will give us an error
  * if we try to allocate the static variable to fmt if it is not a
@@ -525,6 +570,7 @@ trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 static inline void tracing_start(void) { }
 static inline void tracing_stop(void) { }
 static inline void ftrace_off_permanent(void) { }
+static inline void trace_dump_stack(void) { }
 static inline int
 trace_printk(const char *fmt, ...)
 {
index adc34f2c6eff9eb9dd3eb5e159cf730f5baba457..c356b6914ffd8ea9c08475b5395f63501548d943 100644 (file)
@@ -206,6 +206,8 @@ extern size_t vmcoreinfo_max_size;
 
 int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
                unsigned long long *crash_size, unsigned long long *crash_base);
+int crash_shrink_memory(unsigned long new_size);
+size_t crash_get_memory_size(void);
 
 #else /* !CONFIG_KEXEC */
 struct pt_regs;
index ad6bdf5a5970c5fdbceb6b5c440a196b7a620b22..7c6b32a1421c000b33f1fa924f3f7ec43b32c551 100644 (file)
@@ -1,6 +1,7 @@
 /*
- * A simple kernel FIFO implementation.
+ * A generic kernel FIFO implementation.
  *
+ * Copyright (C) 2009 Stefani Seibold <stefani@seibold.net>
  * Copyright (C) 2004 Stelian Pop <stelian@popies.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  */
+
+/*
+ * Howto porting drivers to the new generic fifo API:
+ *
+ * - Modify the declaration of the "struct kfifo *" object into a
+ *   in-place "struct kfifo" object
+ * - Init the in-place object with kfifo_alloc() or kfifo_init()
+ *   Note: The address of the in-place "struct kfifo" object must be
+ *   passed as the first argument to this functions
+ * - Replace the use of __kfifo_put into kfifo_in and __kfifo_get
+ *   into kfifo_out
+ * - Replace the use of kfifo_put into kfifo_in_locked and kfifo_get
+ *   into kfifo_out_locked
+ *   Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc
+ *   must be passed now to the kfifo_in_locked and kfifo_out_locked
+ *   as the last parameter.
+ * - All formerly name __kfifo_* functions has been renamed into kfifo_*
+ */
+
 #ifndef _LINUX_KFIFO_H
 #define _LINUX_KFIFO_H
 
@@ -29,124 +49,562 @@ struct kfifo {
        unsigned int size;      /* the size of the allocated buffer */
        unsigned int in;        /* data is added at offset (in % size) */
        unsigned int out;       /* data is extracted from off. (out % size) */
-       spinlock_t *lock;       /* protects concurrent modifications */
 };
 
-extern struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
-                               gfp_t gfp_mask, spinlock_t *lock);
-extern struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask,
-                                spinlock_t *lock);
+/*
+ * Macros for declaration and initialization of the kfifo datatype
+ */
+
+/* helper macro */
+#define __kfifo_initializer(s, b) \
+       (struct kfifo) { \
+               .size   = s, \
+               .in     = 0, \
+               .out    = 0, \
+               .buffer = b \
+       }
+
+/**
+ * DECLARE_KFIFO - macro to declare a kfifo and the associated buffer
+ * @name: name of the declared kfifo datatype
+ * @size: size of the fifo buffer
+ *
+ * Note1: the macro can be used inside struct or union declaration
+ * Note2: the macro creates two objects:
+ *  A kfifo object with the given name and a buffer for the kfifo
+ *  object named name##kfifo_buffer
+ */
+#define DECLARE_KFIFO(name, size) \
+union { \
+       struct kfifo name; \
+       unsigned char name##kfifo_buffer[size + sizeof(struct kfifo)]; \
+}
+
+/**
+ * INIT_KFIFO - Initialize a kfifo declared by DECLARE_KFIFO
+ * @name: name of the declared kfifo datatype
+ */
+#define INIT_KFIFO(name) \
+       name = __kfifo_initializer(sizeof(name##kfifo_buffer) - \
+                               sizeof(struct kfifo), name##kfifo_buffer)
+
+/**
+ * DEFINE_KFIFO - macro to define and initialize a kfifo
+ * @name: name of the declared kfifo datatype
+ * @size: size of the fifo buffer
+ *
+ * Note1: the macro can be used for global and local kfifo data type variables
+ * Note2: the macro creates two objects:
+ *  A kfifo object with the given name and a buffer for the kfifo
+ *  object named name##kfifo_buffer
+ */
+#define DEFINE_KFIFO(name, size) \
+       unsigned char name##kfifo_buffer[size]; \
+       struct kfifo name = __kfifo_initializer(size, name##kfifo_buffer)
+
+#undef __kfifo_initializer
+
+extern void kfifo_init(struct kfifo *fifo, unsigned char *buffer,
+                       unsigned int size);
+extern __must_check int kfifo_alloc(struct kfifo *fifo, unsigned int size,
+                       gfp_t gfp_mask);
 extern void kfifo_free(struct kfifo *fifo);
-extern unsigned int __kfifo_put(struct kfifo *fifo,
-                               const unsigned char *buffer, unsigned int len);
-extern unsigned int __kfifo_get(struct kfifo *fifo,
-                               unsigned char *buffer, unsigned int len);
+extern unsigned int kfifo_in(struct kfifo *fifo,
+                               const unsigned char *from, unsigned int len);
+extern __must_check unsigned int kfifo_out(struct kfifo *fifo,
+                               unsigned char *to, unsigned int len);
 
 /**
- * __kfifo_reset - removes the entire FIFO contents, no locking version
+ * kfifo_reset - removes the entire FIFO contents
  * @fifo: the fifo to be emptied.
  */
-static inline void __kfifo_reset(struct kfifo *fifo)
+static inline void kfifo_reset(struct kfifo *fifo)
 {
        fifo->in = fifo->out = 0;
 }
 
 /**
- * kfifo_reset - removes the entire FIFO contents
+ * kfifo_reset_out - skip FIFO contents
  * @fifo: the fifo to be emptied.
  */
-static inline void kfifo_reset(struct kfifo *fifo)
+static inline void kfifo_reset_out(struct kfifo *fifo)
 {
-       unsigned long flags;
+       smp_mb();
+       fifo->out = fifo->in;
+}
 
-       spin_lock_irqsave(fifo->lock, flags);
+/**
+ * kfifo_size - returns the size of the fifo in bytes
+ * @fifo: the fifo to be used.
+ */
+static inline __must_check unsigned int kfifo_size(struct kfifo *fifo)
+{
+       return fifo->size;
+}
 
-       __kfifo_reset(fifo);
+/**
+ * kfifo_len - returns the number of used bytes in the FIFO
+ * @fifo: the fifo to be used.
+ */
+static inline unsigned int kfifo_len(struct kfifo *fifo)
+{
+       register unsigned int   out;
 
-       spin_unlock_irqrestore(fifo->lock, flags);
+       out = fifo->out;
+       smp_rmb();
+       return fifo->in - out;
 }
 
 /**
- * kfifo_put - puts some data into the FIFO
+ * kfifo_is_empty - returns true if the fifo is empty
  * @fifo: the fifo to be used.
- * @buffer: the data to be added.
- * @len: the length of the data to be added.
+ */
+static inline __must_check int kfifo_is_empty(struct kfifo *fifo)
+{
+       return fifo->in == fifo->out;
+}
+
+/**
+ * kfifo_is_full - returns true if the fifo is full
+ * @fifo: the fifo to be used.
+ */
+static inline __must_check int kfifo_is_full(struct kfifo *fifo)
+{
+       return kfifo_len(fifo) == kfifo_size(fifo);
+}
+
+/**
+ * kfifo_avail - returns the number of bytes available in the FIFO
+ * @fifo: the fifo to be used.
+ */
+static inline __must_check unsigned int kfifo_avail(struct kfifo *fifo)
+{
+       return kfifo_size(fifo) - kfifo_len(fifo);
+}
+
+/**
+ * kfifo_in_locked - puts some data into the FIFO using a spinlock for locking
+ * @fifo: the fifo to be used.
+ * @from: the data to be added.
+ * @n: the length of the data to be added.
+ * @lock: pointer to the spinlock to use for locking.
  *
- * This function copies at most @len bytes from the @buffer into
+ * This function copies at most @len bytes from the @from buffer into
  * the FIFO depending on the free space, and returns the number of
  * bytes copied.
  */
-static inline unsigned int kfifo_put(struct kfifo *fifo,
-                               const unsigned char *buffer, unsigned int len)
+static inline unsigned int kfifo_in_locked(struct kfifo *fifo,
+               const unsigned char *from, unsigned int n, spinlock_t *lock)
 {
        unsigned long flags;
        unsigned int ret;
 
-       spin_lock_irqsave(fifo->lock, flags);
+       spin_lock_irqsave(lock, flags);
 
-       ret = __kfifo_put(fifo, buffer, len);
+       ret = kfifo_in(fifo, from, n);
 
-       spin_unlock_irqrestore(fifo->lock, flags);
+       spin_unlock_irqrestore(lock, flags);
 
        return ret;
 }
 
 /**
- * kfifo_get - gets some data from the FIFO
+ * kfifo_out_locked - gets some data from the FIFO using a spinlock for locking
  * @fifo: the fifo to be used.
- * @buffer: where the data must be copied.
- * @len: the size of the destination buffer.
+ * @to: where the data must be copied.
+ * @n: the size of the destination buffer.
+ * @lock: pointer to the spinlock to use for locking.
  *
  * This function copies at most @len bytes from the FIFO into the
- * @buffer and returns the number of copied bytes.
+ * @to buffer and returns the number of copied bytes.
  */
-static inline unsigned int kfifo_get(struct kfifo *fifo,
-                                    unsigned char *buffer, unsigned int len)
+static inline __must_check unsigned int kfifo_out_locked(struct kfifo *fifo,
+       unsigned char *to, unsigned int n, spinlock_t *lock)
 {
        unsigned long flags;
        unsigned int ret;
 
-       spin_lock_irqsave(fifo->lock, flags);
+       spin_lock_irqsave(lock, flags);
 
-       ret = __kfifo_get(fifo, buffer, len);
+       ret = kfifo_out(fifo, to, n);
 
        /*
         * optimization: if the FIFO is empty, set the indices to 0
         * so we don't wrap the next time
         */
-       if (fifo->in == fifo->out)
-               fifo->in = fifo->out = 0;
+       if (kfifo_is_empty(fifo))
+               kfifo_reset(fifo);
+
+       spin_unlock_irqrestore(lock, flags);
+
+       return ret;
+}
+
+extern void kfifo_skip(struct kfifo *fifo, unsigned int len);
+
+extern __must_check unsigned int kfifo_from_user(struct kfifo *fifo,
+       const void __user *from, unsigned int n);
+
+extern __must_check unsigned int kfifo_to_user(struct kfifo *fifo,
+       void __user *to, unsigned int n);
+
+/*
+ * __kfifo_add_out internal helper function for updating the out offset
+ */
+static inline void __kfifo_add_out(struct kfifo *fifo,
+                               unsigned int off)
+{
+       smp_mb();
+       fifo->out += off;
+}
+
+/*
+ * __kfifo_add_in internal helper function for updating the in offset
+ */
+static inline void __kfifo_add_in(struct kfifo *fifo,
+                               unsigned int off)
+{
+       smp_wmb();
+       fifo->in += off;
+}
+
+/*
+ * __kfifo_off internal helper function for calculating the index of a
+ * given offeset
+ */
+static inline unsigned int __kfifo_off(struct kfifo *fifo, unsigned int off)
+{
+       return off & (fifo->size - 1);
+}
+
+/*
+ * __kfifo_peek_n internal helper function for determinate the length of
+ * the next record in the fifo
+ */
+static inline unsigned int __kfifo_peek_n(struct kfifo *fifo,
+                               unsigned int recsize)
+{
+#define __KFIFO_GET(fifo, off, shift) \
+       ((fifo)->buffer[__kfifo_off((fifo), (fifo)->out+(off))] << (shift))
+
+       unsigned int l;
+
+       l = __KFIFO_GET(fifo, 0, 0);
+
+       if (--recsize)
+               l |= __KFIFO_GET(fifo, 1, 8);
+
+       return l;
+#undef __KFIFO_GET
+}
+
+/*
+ * __kfifo_poke_n internal helper function for storing the length of
+ * the next record into the fifo
+ */
+static inline void __kfifo_poke_n(struct kfifo *fifo,
+                       unsigned int recsize, unsigned int n)
+{
+#define __KFIFO_PUT(fifo, off, val, shift) \
+               ( \
+               (fifo)->buffer[__kfifo_off((fifo), (fifo)->in+(off))] = \
+               (unsigned char)((val) >> (shift)) \
+               )
 
-       spin_unlock_irqrestore(fifo->lock, flags);
+       __KFIFO_PUT(fifo, 0, n, 0);
 
+       if (--recsize)
+               __KFIFO_PUT(fifo, 1, n, 8);
+#undef __KFIFO_PUT
+}
+
+/*
+ * __kfifo_in_... internal functions for put date into the fifo
+ * do not call it directly, use kfifo_in_rec() instead
+ */
+extern unsigned int __kfifo_in_n(struct kfifo *fifo,
+       const void *from, unsigned int n, unsigned int recsize);
+
+extern unsigned int __kfifo_in_generic(struct kfifo *fifo,
+       const void *from, unsigned int n, unsigned int recsize);
+
+static inline unsigned int __kfifo_in_rec(struct kfifo *fifo,
+       const void *from, unsigned int n, unsigned int recsize)
+{
+       unsigned int ret;
+
+       ret = __kfifo_in_n(fifo, from, n, recsize);
+
+       if (likely(ret == 0)) {
+               if (recsize)
+                       __kfifo_poke_n(fifo, recsize, n);
+               __kfifo_add_in(fifo, n + recsize);
+       }
        return ret;
 }
 
 /**
- * __kfifo_len - returns the number of bytes available in the FIFO, no locking version
+ * kfifo_in_rec - puts some record data into the FIFO
  * @fifo: the fifo to be used.
+ * @from: the data to be added.
+ * @n: the length of the data to be added.
+ * @recsize: size of record field
+ *
+ * This function copies @n bytes from the @from into the FIFO and returns
+ * the number of bytes which cannot be copied.
+ * A returned value greater than the @n value means that the record doesn't
+ * fit into the buffer.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
  */
-static inline unsigned int __kfifo_len(struct kfifo *fifo)
+static inline __must_check unsigned int kfifo_in_rec(struct kfifo *fifo,
+       void *from, unsigned int n, unsigned int recsize)
 {
-       return fifo->in - fifo->out;
+       if (!__builtin_constant_p(recsize))
+               return __kfifo_in_generic(fifo, from, n, recsize);
+       return __kfifo_in_rec(fifo, from, n, recsize);
+}
+
+/*
+ * __kfifo_out_... internal functions for get date from the fifo
+ * do not call it directly, use kfifo_out_rec() instead
+ */
+extern unsigned int __kfifo_out_n(struct kfifo *fifo,
+       void *to, unsigned int reclen, unsigned int recsize);
+
+extern unsigned int __kfifo_out_generic(struct kfifo *fifo,
+       void *to, unsigned int n,
+       unsigned int recsize, unsigned int *total);
+
+static inline unsigned int __kfifo_out_rec(struct kfifo *fifo,
+       void *to, unsigned int n, unsigned int recsize,
+       unsigned int *total)
+{
+       unsigned int l;
+
+       if (!recsize) {
+               l = n;
+               if (total)
+                       *total = l;
+       } else {
+               l = __kfifo_peek_n(fifo, recsize);
+               if (total)
+                       *total = l;
+               if (n < l)
+                       return l;
+       }
+
+       return __kfifo_out_n(fifo, to, l, recsize);
 }
 
 /**
- * kfifo_len - returns the number of bytes available in the FIFO
+ * kfifo_out_rec - gets some record data from the FIFO
  * @fifo: the fifo to be used.
+ * @to: where the data must be copied.
+ * @n: the size of the destination buffer.
+ * @recsize: size of record field
+ * @total: pointer where the total number of to copied bytes should stored
+ *
+ * This function copies at most @n bytes from the FIFO to @to and returns the
+ * number of bytes which cannot be copied.
+ * A returned value greater than the @n value means that the record doesn't
+ * fit into the @to buffer.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
  */
-static inline unsigned int kfifo_len(struct kfifo *fifo)
+static inline __must_check unsigned int kfifo_out_rec(struct kfifo *fifo,
+       void *to, unsigned int n, unsigned int recsize,
+       unsigned int *total)
+
 {
-       unsigned long flags;
-       unsigned int ret;
+       if (!__builtin_constant_p(recsize))
+               return __kfifo_out_generic(fifo, to, n, recsize, total);
+       return __kfifo_out_rec(fifo, to, n, recsize, total);
+}
+
+/*
+ * __kfifo_from_user_... internal functions for transfer from user space into
+ * the fifo. do not call it directly, use kfifo_from_user_rec() instead
+ */
+extern unsigned int __kfifo_from_user_n(struct kfifo *fifo,
+       const void __user *from, unsigned int n, unsigned int recsize);
 
-       spin_lock_irqsave(fifo->lock, flags);
+extern unsigned int __kfifo_from_user_generic(struct kfifo *fifo,
+       const void __user *from, unsigned int n, unsigned int recsize);
 
-       ret = __kfifo_len(fifo);
+static inline unsigned int __kfifo_from_user_rec(struct kfifo *fifo,
+       const void __user *from, unsigned int n, unsigned int recsize)
+{
+       unsigned int ret;
 
-       spin_unlock_irqrestore(fifo->lock, flags);
+       ret = __kfifo_from_user_n(fifo, from, n, recsize);
 
+       if (likely(ret == 0)) {
+               if (recsize)
+                       __kfifo_poke_n(fifo, recsize, n);
+               __kfifo_add_in(fifo, n + recsize);
+       }
        return ret;
 }
 
+/**
+ * kfifo_from_user_rec - puts some data from user space into the FIFO
+ * @fifo: the fifo to be used.
+ * @from: pointer to the data to be added.
+ * @n: the length of the data to be added.
+ * @recsize: size of record field
+ *
+ * This function copies @n bytes from the @from into the
+ * FIFO and returns the number of bytes which cannot be copied.
+ *
+ * If the returned value is equal or less the @n value, the copy_from_user()
+ * functions has failed. Otherwise the record doesn't fit into the buffer.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
+ */
+static inline __must_check unsigned int kfifo_from_user_rec(struct kfifo *fifo,
+       const void __user *from, unsigned int n, unsigned int recsize)
+{
+       if (!__builtin_constant_p(recsize))
+               return __kfifo_from_user_generic(fifo, from, n, recsize);
+       return __kfifo_from_user_rec(fifo, from, n, recsize);
+}
+
+/*
+ * __kfifo_to_user_... internal functions for transfer fifo data into user space
+ * do not call it directly, use kfifo_to_user_rec() instead
+ */
+extern unsigned int __kfifo_to_user_n(struct kfifo *fifo,
+       void __user *to, unsigned int n, unsigned int reclen,
+       unsigned int recsize);
+
+extern unsigned int __kfifo_to_user_generic(struct kfifo *fifo,
+       void __user *to, unsigned int n, unsigned int recsize,
+       unsigned int *total);
+
+static inline unsigned int __kfifo_to_user_rec(struct kfifo *fifo,
+       void __user *to, unsigned int n,
+       unsigned int recsize, unsigned int *total)
+{
+       unsigned int l;
+
+       if (!recsize) {
+               l = n;
+               if (total)
+                       *total = l;
+       } else {
+               l = __kfifo_peek_n(fifo, recsize);
+               if (total)
+                       *total = l;
+               if (n < l)
+                       return l;
+       }
+
+       return __kfifo_to_user_n(fifo, to, n, l, recsize);
+}
+
+/**
+ * kfifo_to_user_rec - gets data from the FIFO and write it to user space
+ * @fifo: the fifo to be used.
+ * @to: where the data must be copied.
+ * @n: the size of the destination buffer.
+ * @recsize: size of record field
+ * @total: pointer where the total number of to copied bytes should stored
+ *
+ * This function copies at most @n bytes from the FIFO to the @to.
+ * In case of an error, the function returns the number of bytes which cannot
+ * be copied.
+ * If the returned value is equal or less the @n value, the copy_to_user()
+ * functions has failed. Otherwise the record doesn't fit into the @to buffer.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
+ */
+static inline __must_check unsigned int kfifo_to_user_rec(struct kfifo *fifo,
+               void __user *to, unsigned int n, unsigned int recsize,
+               unsigned int *total)
+{
+       if (!__builtin_constant_p(recsize))
+               return __kfifo_to_user_generic(fifo, to, n, recsize, total);
+       return __kfifo_to_user_rec(fifo, to, n, recsize, total);
+}
+
+/*
+ * __kfifo_peek_... internal functions for peek into the next fifo record
+ * do not call it directly, use kfifo_peek_rec() instead
+ */
+extern unsigned int __kfifo_peek_generic(struct kfifo *fifo,
+                               unsigned int recsize);
+
+/**
+ * kfifo_peek_rec - gets the size of the next FIFO record data
+ * @fifo: the fifo to be used.
+ * @recsize: size of record field
+ *
+ * This function returns the size of the next FIFO record in number of bytes
+ */
+static inline __must_check unsigned int kfifo_peek_rec(struct kfifo *fifo,
+       unsigned int recsize)
+{
+       if (!__builtin_constant_p(recsize))
+               return __kfifo_peek_generic(fifo, recsize);
+       if (!recsize)
+               return kfifo_len(fifo);
+       return __kfifo_peek_n(fifo, recsize);
+}
+
+/*
+ * __kfifo_skip_... internal functions for skip the next fifo record
+ * do not call it directly, use kfifo_skip_rec() instead
+ */
+extern void __kfifo_skip_generic(struct kfifo *fifo, unsigned int recsize);
+
+static inline void __kfifo_skip_rec(struct kfifo *fifo,
+       unsigned int recsize)
+{
+       unsigned int l;
+
+       if (recsize) {
+               l = __kfifo_peek_n(fifo, recsize);
+
+               if (l + recsize <= kfifo_len(fifo)) {
+                       __kfifo_add_out(fifo, l + recsize);
+                       return;
+               }
+       }
+       kfifo_reset_out(fifo);
+}
+
+/**
+ * kfifo_skip_rec - skip the next fifo out record
+ * @fifo: the fifo to be used.
+ * @recsize: size of record field
+ *
+ * This function skips the next FIFO record
+ */
+static inline void kfifo_skip_rec(struct kfifo *fifo,
+       unsigned int recsize)
+{
+       if (!__builtin_constant_p(recsize))
+               __kfifo_skip_generic(fifo, recsize);
+       else
+               __kfifo_skip_rec(fifo, recsize);
+}
+
+/**
+ * kfifo_avail_rec - returns the number of bytes available in a record FIFO
+ * @fifo: the fifo to be used.
+ * @recsize: size of record field
+ */
+static inline __must_check unsigned int kfifo_avail_rec(struct kfifo *fifo,
+       unsigned int recsize)
+{
+       unsigned int l = kfifo_size(fifo) - kfifo_len(fifo);
+
+       return (l > recsize) ? l - recsize : 0;
+}
+
 #endif
index 3c7497d46ee9655fa86f7bb42f1637a023d6fd25..99d9a6766f7ec055feca4a25d7d5e4c89fd9b058 100644 (file)
@@ -32,8 +32,7 @@ extern void kmemleak_padding(const void *ptr, unsigned long offset,
                             size_t size) __ref;
 extern void kmemleak_not_leak(const void *ptr) __ref;
 extern void kmemleak_ignore(const void *ptr) __ref;
-extern void kmemleak_scan_area(const void *ptr, unsigned long offset,
-                              size_t length, gfp_t gfp) __ref;
+extern void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) __ref;
 extern void kmemleak_no_scan(const void *ptr) __ref;
 
 static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
@@ -84,8 +83,7 @@ static inline void kmemleak_not_leak(const void *ptr)
 static inline void kmemleak_ignore(const void *ptr)
 {
 }
-static inline void kmemleak_scan_area(const void *ptr, unsigned long offset,
-                                     size_t length, gfp_t gfp)
+static inline void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp)
 {
 }
 static inline void kmemleak_erase(void **ptr)
diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h
new file mode 100644 (file)
index 0000000..e32aa26
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * linux/include/kmsg_dump.h
+ *
+ * Copyright (C) 2009 Net Insight AB
+ *
+ * Author: Simon Kagstrom <simon.kagstrom@netinsight.net>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+#ifndef _LINUX_KMSG_DUMP_H
+#define _LINUX_KMSG_DUMP_H
+
+#include <linux/list.h>
+
+enum kmsg_dump_reason {
+       KMSG_DUMP_OOPS,
+       KMSG_DUMP_PANIC,
+};
+
+/**
+ * struct kmsg_dumper - kernel crash message dumper structure
+ * @dump:      The callback which gets called on crashes. The buffer is passed
+ *             as two sections, where s1 (length l1) contains the older
+ *             messages and s2 (length l2) contains the newer.
+ * @list:      Entry in the dumper list (private)
+ * @registered:        Flag that specifies if this is already registered
+ */
+struct kmsg_dumper {
+       void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason,
+                       const char *s1, unsigned long l1,
+                       const char *s2, unsigned long l2);
+       struct list_head list;
+       int registered;
+};
+
+#ifdef CONFIG_PRINTK
+void kmsg_dump(enum kmsg_dump_reason reason);
+
+int kmsg_dump_register(struct kmsg_dumper *dumper);
+
+int kmsg_dump_unregister(struct kmsg_dumper *dumper);
+#else
+static inline void kmsg_dump(enum kmsg_dump_reason reason)
+{
+}
+
+static inline int kmsg_dump_register(struct kmsg_dumper *dumper)
+{
+       return -EINVAL;
+}
+
+static inline int kmsg_dump_unregister(struct kmsg_dumper *dumper)
+{
+       return -EINVAL;
+}
+#endif
+
+#endif /* _LINUX_KMSG_DUMP_H */
index a485c14ecd5d52f892cbfe5ca3e22f0463c42a48..43bdab769fc358091f90315d2613c40ada107da0 100644 (file)
@@ -9,8 +9,12 @@
 
 #include <linux/bitops.h>
 #include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/rmap.h>
 #include <linux/sched.h>
-#include <linux/vmstat.h>
+
+struct stable_node;
+struct mem_cgroup;
 
 #ifdef CONFIG_KSM
 int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
@@ -34,46 +38,110 @@ static inline void ksm_exit(struct mm_struct *mm)
 /*
  * A KSM page is one of those write-protected "shared pages" or "merged pages"
  * which KSM maps into multiple mms, wherever identical anonymous page content
- * is found in VM_MERGEABLE vmas.  It's a PageAnon page, with NULL anon_vma.
+ * is found in VM_MERGEABLE vmas.  It's a PageAnon page, pointing not to any
+ * anon_vma, but to that page's node of the stable tree.
  */
 static inline int PageKsm(struct page *page)
 {
-       return ((unsigned long)page->mapping == PAGE_MAPPING_ANON);
+       return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) ==
+                               (PAGE_MAPPING_ANON | PAGE_MAPPING_KSM);
+}
+
+static inline struct stable_node *page_stable_node(struct page *page)
+{
+       return PageKsm(page) ? page_rmapping(page) : NULL;
+}
+
+static inline void set_page_stable_node(struct page *page,
+                                       struct stable_node *stable_node)
+{
+       page->mapping = (void *)stable_node +
+                               (PAGE_MAPPING_ANON | PAGE_MAPPING_KSM);
 }
 
 /*
- * But we have to avoid the checking which page_add_anon_rmap() performs.
+ * When do_swap_page() first faults in from swap what used to be a KSM page,
+ * no problem, it will be assigned to this vma's anon_vma; but thereafter,
+ * it might be faulted into a different anon_vma (or perhaps to a different
+ * offset in the same anon_vma).  do_swap_page() cannot do all the locking
+ * needed to reconstitute a cross-anon_vma KSM page: for now it has to make
+ * a copy, and leave remerging the pages to a later pass of ksmd.
+ *
+ * We'd like to make this conditional on vma->vm_flags & VM_MERGEABLE,
+ * but what if the vma was unmerged while the page was swapped out?
  */
-static inline void page_add_ksm_rmap(struct page *page)
+struct page *ksm_does_need_to_copy(struct page *page,
+                       struct vm_area_struct *vma, unsigned long address);
+static inline struct page *ksm_might_need_to_copy(struct page *page,
+                       struct vm_area_struct *vma, unsigned long address)
 {
-       if (atomic_inc_and_test(&page->_mapcount)) {
-               page->mapping = (void *) PAGE_MAPPING_ANON;
-               __inc_zone_page_state(page, NR_ANON_PAGES);
-       }
+       struct anon_vma *anon_vma = page_anon_vma(page);
+
+       if (!anon_vma ||
+           (anon_vma == vma->anon_vma &&
+            page->index == linear_page_index(vma, address)))
+               return page;
+
+       return ksm_does_need_to_copy(page, vma, address);
 }
+
+int page_referenced_ksm(struct page *page,
+                       struct mem_cgroup *memcg, unsigned long *vm_flags);
+int try_to_unmap_ksm(struct page *page, enum ttu_flags flags);
+int rmap_walk_ksm(struct page *page, int (*rmap_one)(struct page *,
+                 struct vm_area_struct *, unsigned long, void *), void *arg);
+void ksm_migrate_page(struct page *newpage, struct page *oldpage);
+
 #else  /* !CONFIG_KSM */
 
+static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
+{
+       return 0;
+}
+
+static inline void ksm_exit(struct mm_struct *mm)
+{
+}
+
+static inline int PageKsm(struct page *page)
+{
+       return 0;
+}
+
+#ifdef CONFIG_MMU
 static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
                unsigned long end, int advice, unsigned long *vm_flags)
 {
        return 0;
 }
 
-static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
+static inline struct page *ksm_might_need_to_copy(struct page *page,
+                       struct vm_area_struct *vma, unsigned long address)
+{
+       return page;
+}
+
+static inline int page_referenced_ksm(struct page *page,
+                       struct mem_cgroup *memcg, unsigned long *vm_flags)
 {
        return 0;
 }
 
-static inline void ksm_exit(struct mm_struct *mm)
+static inline int try_to_unmap_ksm(struct page *page, enum ttu_flags flags)
 {
+       return 0;
 }
 
-static inline int PageKsm(struct page *page)
+static inline int rmap_walk_ksm(struct page *page, int (*rmap_one)(struct page*,
+               struct vm_area_struct *, unsigned long, void *), void *arg)
 {
        return 0;
 }
 
-/* No stub required for page_add_ksm_rmap(page) */
+static inline void ksm_migrate_page(struct page *newpage, struct page *oldpage)
+{
+}
+#endif /* CONFIG_MMU */
 #endif /* !CONFIG_KSM */
 
-#endif
+#endif /* __LINUX_KSM_H */
index afc9f9fd70f516a47bfceb4a49cc1e5d3b9bb492..2618aa9063bcc6f1a0fdf83727f234ad83448920 100644 (file)
@@ -12,9 +12,6 @@
 #ifndef __LINUX_LEDS_LP3944_H
 #define __LINUX_LEDS_LP3944_H
 
-#include <linux/leds.h>
-#include <linux/workqueue.h>
-
 #define LP3944_LED0 0
 #define LP3944_LED1 1
 #define LP3944_LED2 2
index 96eea90f01a87711440b6fd3162e2d40d38269b4..f158eb1149aa8b6cd0029ca92ac2645a672a3928 100644 (file)
@@ -32,7 +32,7 @@ struct pca9532_led {
        struct i2c_client *client;
        char *name;
        struct led_classdev ldev;
-       struct work_struct work;
+       struct work_struct work;
        enum pca9532_type type;
        enum pca9532_state state;
 };
diff --git a/include/linux/leds-regulator.h b/include/linux/leds-regulator.h
new file mode 100644 (file)
index 0000000..5a8eb38
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * leds-regulator.h - platform data structure for regulator driven LEDs.
+ *
+ * Copyright (C) 2009 Antonio Ospite <ospite@studenti.unina.it>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#ifndef __LINUX_LEDS_REGULATOR_H
+#define __LINUX_LEDS_REGULATOR_H
+
+/*
+ * Use "vled" as supply id when declaring the regulator consumer:
+ *
+ * static struct regulator_consumer_supply pcap_regulator_VVIB_consumers [] = {
+ *     { .dev_name = "leds-regulator.0", supply = "vled" },
+ * };
+ *
+ * If you have several regulator driven LEDs, you can append a numerical id to
+ * .dev_name as done above, and use the same id when declaring the platform
+ * device:
+ *
+ * static struct led_regulator_platform_data a780_vibrator_data = {
+ *     .name   = "a780::vibrator",
+ * };
+ *
+ * static struct platform_device a780_vibrator = {
+ *     .name = "leds-regulator",
+ *     .id   = 0,
+ *     .dev  = {
+ *             .platform_data = &a780_vibrator_data,
+ *     },
+ * };
+ */
+
+#include <linux/leds.h>
+
+struct led_regulator_platform_data {
+       char *name;                     /* LED name as expected by LED class */
+       enum led_brightness brightness; /* initial brightness value */
+};
+
+#endif /* __LINUX_LEDS_REGULATOR_H */
index 3cc2f2c53e4c699abeefed5869c3ca8da1ef6481..f1ca0dcc162877513d922ee69e3b9ee2465df1d8 100644 (file)
@@ -43,6 +43,21 @@ struct lis3lv02d_platform_data {
 #define LIS3_WAKEUP_Z_HI       (1 << 5)
        unsigned char wakeup_flags;
        unsigned char wakeup_thresh;
+#define LIS3_NO_MAP            0
+#define LIS3_DEV_X             1
+#define LIS3_DEV_Y             2
+#define LIS3_DEV_Z             3
+#define LIS3_INV_DEV_X        -1
+#define LIS3_INV_DEV_Y        -2
+#define LIS3_INV_DEV_Z        -3
+       s8 axis_x;
+       s8 axis_y;
+       s8 axis_z;
+       int (*setup_resources)(void);
+       int (*release_resources)(void);
+       /* Limits for selftest are specified in chip data sheet */
+       s16 st_min_limits[3]; /* min pass limit x, y, z */
+       s16 st_max_limits[3]; /* max pass limit x, y, z */
 };
 
 #endif /* __LIS3LV02D_H_ */
index 2442e3f3d03335ff5e515d0876f64cadfa3f6dbe..ef82b8fcbddbdf169d9c71eae0db4b78c5e4b110 100644 (file)
@@ -54,6 +54,7 @@ extern u64 __init lmb_phys_mem_size(void);
 extern u64 lmb_end_of_DRAM(void);
 extern void __init lmb_enforce_memory_limit(u64 memory_limit);
 extern int __init lmb_is_reserved(u64 addr);
+extern int lmb_is_region_reserved(u64 base, u64 size);
 extern int lmb_find(struct lmb_property *res);
 
 extern void lmb_dump_all(void);
index bf9213b2db8f2da2a443d8788d2d70eb0a003af8..1f9b119f4ace3624e492bb6cb88495b3e9d0f5e2 100644 (file)
@@ -54,6 +54,11 @@ extern void mem_cgroup_rotate_lru_list(struct page *page, enum lru_list lru);
 extern void mem_cgroup_del_lru(struct page *page);
 extern void mem_cgroup_move_lists(struct page *page,
                                  enum lru_list from, enum lru_list to);
+
+/* For coalescing uncharge for reducing memcg' overhead*/
+extern void mem_cgroup_uncharge_start(void);
+extern void mem_cgroup_uncharge_end(void);
+
 extern void mem_cgroup_uncharge_page(struct page *page);
 extern void mem_cgroup_uncharge_cache_page(struct page *page);
 extern int mem_cgroup_shmem_charge_fallback(struct page *page,
@@ -68,6 +73,7 @@ extern unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
 extern void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask);
 int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem);
 
+extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
 
 static inline
@@ -80,6 +86,8 @@ int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
        return cgroup == mem;
 }
 
+extern struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *mem);
+
 extern int
 mem_cgroup_prepare_migration(struct page *page, struct mem_cgroup **ptr);
 extern void mem_cgroup_end_migration(struct mem_cgroup *mem,
@@ -117,7 +125,7 @@ static inline bool mem_cgroup_disabled(void)
 }
 
 extern bool mem_cgroup_oom_called(struct task_struct *task);
-void mem_cgroup_update_mapped_file_stat(struct page *page, int val);
+void mem_cgroup_update_file_mapped(struct page *page, int val);
 unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
                                                gfp_t gfp_mask, int nid,
                                                int zid);
@@ -151,6 +159,14 @@ static inline void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *ptr)
 {
 }
 
+static inline void mem_cgroup_uncharge_start(void)
+{
+}
+
+static inline void mem_cgroup_uncharge_end(void)
+{
+}
+
 static inline void mem_cgroup_uncharge_page(struct page *page)
 {
 }
@@ -189,6 +205,11 @@ mem_cgroup_move_lists(struct page *page, enum lru_list from, enum lru_list to)
 {
 }
 
+static inline struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
+{
+       return NULL;
+}
+
 static inline int mm_match_cgroup(struct mm_struct *mm, struct mem_cgroup *mem)
 {
        return 1;
@@ -200,6 +221,11 @@ static inline int task_in_mem_cgroup(struct task_struct *task,
        return 1;
 }
 
+static inline struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *mem)
+{
+       return NULL;
+}
+
 static inline int
 mem_cgroup_prepare_migration(struct page *page, struct mem_cgroup **ptr)
 {
@@ -274,7 +300,7 @@ mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
 {
 }
 
-static inline void mem_cgroup_update_mapped_file_stat(struct page *page,
+static inline void mem_cgroup_update_file_mapped(struct page *page,
                                                        int val)
 {
 }
index 37fa19b34ef584bcd8626059675a33baef2df939..1adfe779eb99123a91c4141bd1974654db8d5880 100644 (file)
@@ -50,6 +50,19 @@ struct memory_notify {
        int status_change_nid;
 };
 
+/*
+ * During pageblock isolation, count the number of pages within the
+ * range [start_pfn, start_pfn + nr_pages) which are owned by code
+ * in the notifier chain.
+ */
+#define MEM_ISOLATE_COUNT      (1<<0)
+
+struct memory_isolate_notify {
+       unsigned long start_pfn;        /* Start of range to check */
+       unsigned int nr_pages;          /* # pages in range to check */
+       unsigned int pages_found;       /* # pages owned found by callbacks */
+};
+
 struct notifier_block;
 struct mem_section;
 
@@ -76,14 +89,28 @@ static inline int memory_notify(unsigned long val, void *v)
 {
        return 0;
 }
+static inline int register_memory_isolate_notifier(struct notifier_block *nb)
+{
+       return 0;
+}
+static inline void unregister_memory_isolate_notifier(struct notifier_block *nb)
+{
+}
+static inline int memory_isolate_notify(unsigned long val, void *v)
+{
+       return 0;
+}
 #else
 extern int register_memory_notifier(struct notifier_block *nb);
 extern void unregister_memory_notifier(struct notifier_block *nb);
+extern int register_memory_isolate_notifier(struct notifier_block *nb);
+extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
 extern int register_new_memory(int, struct mem_section *);
 extern int unregister_memory_section(struct mem_section *);
 extern int memory_dev_init(void);
 extern int remove_memory_block(unsigned long, struct mem_section *, int);
 extern int memory_notify(unsigned long val, void *v);
+extern int memory_isolate_notify(unsigned long val, void *v);
 extern struct memory_block *find_memory_block(struct mem_section *);
 #define CONFIG_MEM_BLOCK_SIZE  (PAGES_PER_SECTION<<PAGE_SHIFT)
 enum mem_add_context { BOOT, HOTPLUG };
index fed969281a418bde82db04885c2e3499f4e4c485..35b07b773e6cbf90589b90b69897bc2043f7495d 100644 (file)
@@ -69,7 +69,6 @@ extern void online_page(struct page *page);
 /* VM interface that may be used by firmware interface */
 extern int online_pages(unsigned long, unsigned long);
 extern void __offline_isolated_pages(unsigned long, unsigned long);
-extern int offline_pages(unsigned long, unsigned long, unsigned long);
 
 /* reasonably generic interface to expand the physical pages in a zone  */
 extern int __add_pages(int nid, struct zone *zone, unsigned long start_pfn,
index 085c903fe0f1832ce0f46debd8ffcd3f9d5d0564..1cc966cd3e5fff90b3cf893a2f91a6ec8747b0f7 100644 (file)
@@ -201,6 +201,7 @@ extern void mpol_fix_fork_child_flag(struct task_struct *p);
 extern struct zonelist *huge_zonelist(struct vm_area_struct *vma,
                                unsigned long addr, gfp_t gfp_flags,
                                struct mempolicy **mpol, nodemask_t **nodemask);
+extern bool init_nodemask_of_mempolicy(nodemask_t *mask);
 extern unsigned slab_node(struct mempolicy *policy);
 
 extern enum zone_type policy_zone;
@@ -328,6 +329,8 @@ static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma,
        return node_zonelist(0, gfp_flags);
 }
 
+static inline bool init_nodemask_of_mempolicy(nodemask_t *m) { return false; }
+
 static inline int do_migrate_pages(struct mm_struct *mm,
                        const nodemask_t *from_nodes,
                        const nodemask_t *to_nodes, int flags)
index d9034cc87f187b764979ecad8d27cd9ef77514b5..3398bd9aab1199a859559bc5acf7d99300cf6e5c 100644 (file)
@@ -29,7 +29,12 @@ struct pcf50633_platform_data {
        char **batteries;
        int num_batteries;
 
-       int charging_restart_interval;
+       /*
+        * Should be set accordingly to the reference resistor used, see
+        * I_{ch(ref)} charger reference current in the pcf50633 User
+        * Manual.
+        */
+       int charger_reference_current_ma;
 
        /* Callbacks */
        void (*probe_done)(struct pcf50633 *);
index 4119579acf2c447d15472f3e35cdb34f727d31d6..df4f5fa88de351c6aebaa11f51a1e8cd05df238b 100644 (file)
@@ -128,6 +128,7 @@ enum pcf50633_reg_mbcs3 {
 int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma);
 
 int pcf50633_mbc_get_status(struct pcf50633 *);
+int pcf50633_mbc_get_usb_online_status(struct pcf50633 *);
 
 #endif
 
index 415c228743d562f3e93bc2c67a49b8dfbbe58a5b..fd322aca33ba89a9cec62eb7f3909f813b2267a5 100644 (file)
@@ -41,6 +41,23 @@ struct wm831x_battery_pdata {
        int timeout;        /** Charge cycle timeout, in minutes */
 };
 
+/**
+ * Configuration for the WM831x DC-DC BuckWise convertors.  This
+ * should be passed as driver_data in the regulator_init_data.
+ *
+ * Currently all the configuration is for the fast DVS switching
+ * support of the devices.  This allows MFPs on the device to be
+ * configured as an input to switch between two output voltages,
+ * allowing voltage transitions without the expense of an access over
+ * I2C or SPI buses.
+ */
+struct wm831x_buckv_pdata {
+       int dvs_gpio;        /** CPU GPIO to use for DVS switching */
+       int dvs_control_src; /** Hardware DVS source to use (1 or 2) */
+       int dvs_init_state;  /** DVS state to expect on startup */
+       int dvs_state_gpio;  /** CPU GPIO to use for monitoring status */
+};
+
 /* Sources for status LED configuration.  Values are register values
  * plus 1 to allow for a zero default for preserve.
  */
index 527602cdea1c57211f028d0b81cff7d60934a85d..7f085c97c799dac22dadaf9844ae31424e14816d 100644 (file)
@@ -12,7 +12,8 @@ typedef struct page *new_page_t(struct page *, unsigned long private, int **);
 extern int putback_lru_pages(struct list_head *l);
 extern int migrate_page(struct address_space *,
                        struct page *, struct page *);
-extern int migrate_pages(struct list_head *l, new_page_t x, unsigned long);
+extern int migrate_pages(struct list_head *l, new_page_t x,
+                       unsigned long private, int offlining);
 
 extern int fail_migrate_page(struct address_space *,
                        struct page *, struct page *);
@@ -26,10 +27,7 @@ extern int migrate_vmas(struct mm_struct *mm,
 
 static inline int putback_lru_pages(struct list_head *l) { return 0; }
 static inline int migrate_pages(struct list_head *l, new_page_t x,
-               unsigned long private) { return -ENOSYS; }
-
-static inline int migrate_pages_to(struct list_head *pagelist,
-                       struct vm_area_struct *vma, int dest) { return 0; }
+               unsigned long private, int offlining) { return -ENOSYS; }
 
 static inline int migrate_prep(void) { return -ENOSYS; }
 
index ce7cc6c7bcbb6eaa12d818311723d97190e324d5..e92d1bfdb3309689699a936a13281c2f1b4096dc 100644 (file)
@@ -61,6 +61,7 @@ enum {
        MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR = 1 <<  8,
        MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR = 1 <<  9,
        MLX4_DEV_CAP_FLAG_DPDP          = 1 << 12,
+       MLX4_DEV_CAP_FLAG_BLH           = 1 << 15,
        MLX4_DEV_CAP_FLAG_MEM_WINDOW    = 1 << 16,
        MLX4_DEV_CAP_FLAG_APM           = 1 << 17,
        MLX4_DEV_CAP_FLAG_ATOMIC        = 1 << 18,
index 24c395694f4d3fbbc935287018e8dce157215afb..2265f28eb47a92bd858c0bf664b37a46d41b1831 100644 (file)
@@ -620,13 +620,22 @@ void page_address_init(void);
 /*
  * On an anonymous page mapped into a user virtual memory area,
  * page->mapping points to its anon_vma, not to a struct address_space;
- * with the PAGE_MAPPING_ANON bit set to distinguish it.
+ * with the PAGE_MAPPING_ANON bit set to distinguish it.  See rmap.h.
+ *
+ * On an anonymous page in a VM_MERGEABLE area, if CONFIG_KSM is enabled,
+ * the PAGE_MAPPING_KSM bit may be set along with the PAGE_MAPPING_ANON bit;
+ * and then page->mapping points, not to an anon_vma, but to a private
+ * structure which KSM associates with that merged page.  See ksm.h.
+ *
+ * PAGE_MAPPING_KSM without PAGE_MAPPING_ANON is currently never used.
  *
  * Please note that, confusingly, "page_mapping" refers to the inode
  * address_space which maps the page from disk; whereas "page_mapped"
  * refers to user virtual address space into which the page is mapped.
  */
 #define PAGE_MAPPING_ANON      1
+#define PAGE_MAPPING_KSM       2
+#define PAGE_MAPPING_FLAGS     (PAGE_MAPPING_ANON | PAGE_MAPPING_KSM)
 
 extern struct address_space swapper_space;
 static inline struct address_space *page_mapping(struct page *page)
@@ -634,16 +643,19 @@ static inline struct address_space *page_mapping(struct page *page)
        struct address_space *mapping = page->mapping;
 
        VM_BUG_ON(PageSlab(page));
-#ifdef CONFIG_SWAP
        if (unlikely(PageSwapCache(page)))
                mapping = &swapper_space;
-       else
-#endif
-       if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON))
+       else if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON))
                mapping = NULL;
        return mapping;
 }
 
+/* Neutral page->mapping pointer to address_space or anon_vma or other */
+static inline void *page_rmapping(struct page *page)
+{
+       return (void *)((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS);
+}
+
 static inline int PageAnon(struct page *page)
 {
        return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
@@ -758,6 +770,7 @@ unsigned long unmap_vmas(struct mmu_gather **tlb,
  * @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry
  * @pte_entry: if set, called for each non-empty PTE (4th-level) entry
  * @pte_hole: if set, called for each hole at all levels
+ * @hugetlb_entry: if set, called for each hugetlb entry
  *
  * (see walk_page_range for more details)
  */
@@ -767,6 +780,8 @@ struct mm_walk {
        int (*pmd_entry)(pmd_t *, unsigned long, unsigned long, struct mm_walk *);
        int (*pte_entry)(pte_t *, unsigned long, unsigned long, struct mm_walk *);
        int (*pte_hole)(unsigned long, unsigned long, struct mm_walk *);
+       int (*hugetlb_entry)(pte_t *, unsigned long, unsigned long,
+                            struct mm_walk *);
        struct mm_struct *mm;
        void *private;
 };
@@ -1022,6 +1037,9 @@ extern void add_active_range(unsigned int nid, unsigned long start_pfn,
 extern void remove_active_range(unsigned int nid, unsigned long start_pfn,
                                        unsigned long end_pfn);
 extern void remove_all_active_ranges(void);
+void sort_node_map(void);
+unsigned long __absent_pages_in_range(int nid, unsigned long start_pfn,
+                                               unsigned long end_pfn);
 extern unsigned long absent_pages_in_range(unsigned long start_pfn,
                                                unsigned long end_pfn);
 extern void get_pfn_range_for_nid(unsigned int nid,
@@ -1316,11 +1334,17 @@ extern int account_locked_memory(struct mm_struct *mm, struct rlimit *rlim,
                                 size_t size);
 extern void refund_locked_memory(struct mm_struct *mm, size_t size);
 
+enum mf_flags {
+       MF_COUNT_INCREASED = 1 << 0,
+};
 extern void memory_failure(unsigned long pfn, int trapno);
-extern int __memory_failure(unsigned long pfn, int trapno, int ref);
+extern int __memory_failure(unsigned long pfn, int trapno, int flags);
+extern int unpoison_memory(unsigned long pfn);
 extern int sysctl_memory_failure_early_kill;
 extern int sysctl_memory_failure_recovery;
+extern void shake_page(struct page *p, int access);
 extern atomic_long_t mce_bad_pages;
+extern int soft_offline_page(struct page *page, int flags);
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_MM_H */
index 8a5509877192b903390b7851ae77df96c9e7fad1..ee24ef8ab616e6b48f6ac6cd0d9ff0c038c19bc1 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef LINUX_MM_DEBUG_H
 #define LINUX_MM_DEBUG_H 1
 
-#include <linux/autoconf.h>
-
 #ifdef CONFIG_DEBUG_VM
 #define VM_BUG_ON(cond) BUG_ON(cond)
 #else
index 6f7561730d88c3b8c816e34e76b140cb9612ce8c..30fe668c25425eaf1e1464c6a49d8b170ccc60ca 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/seqlock.h>
 #include <linux/nodemask.h>
 #include <linux/pageblock-flags.h>
-#include <linux/bounds.h>
+#include <generated/bounds.h>
 #include <asm/atomic.h>
 #include <asm/page.h>
 
index 482efc865acf272994b4de7906a8d403a1c1454a..6cb1a3cab5d373e14513497ea0a375055cb2daf4 100644 (file)
 /* Not Yet Implemented */
 #define MODULE_SUPPORTED_DEVICE(name)
 
-/* some toolchains uses a `_' prefix for all user symbols */
-#ifndef MODULE_SYMBOL_PREFIX
+/* Some toolchains use a `_' prefix for all user symbols. */
+#ifdef CONFIG_SYMBOL_PREFIX
+#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
+#else
 #define MODULE_SYMBOL_PREFIX ""
 #endif
 
index fff8c53e54341a106592f210fe8fc78bfb170967..9c3757c5759db88a21501bf69285ab5277818344 100644 (file)
 
 /**
  * struct nand_bbt_descr - bad block table descriptor
- * @options:           options for this descriptor
- * @pages:             the page(s) where we find the bbt, used with
- *                     option BBT_ABSPAGE when bbt is searched,
- *                     then we store the found bbts pages here.
- *                     Its an array and supports up to 8 chips now
- * @offs:              offset of the pattern in the oob area of the page
- * @veroffs:           offset of the bbt version counter in the oob area of the page
- * @version:           version read from the bbt page during scan
- * @len:               length of the pattern, if 0 no pattern check is performed
- * @maxblocks:         maximum number of blocks to search for a bbt. This
- *                     number of blocks is reserved at the end of the device
- *                     where the tables are written.
- * @reserved_block_code: if non-0, this pattern denotes a reserved
- *                     (rather than bad) block in the stored bbt
- * @pattern:           pattern to identify bad block table or factory marked
- *                     good / bad blocks, can be NULL, if len = 0
+ * @options:   options for this descriptor
+ * @pages:     the page(s) where we find the bbt, used with option BBT_ABSPAGE
+ *             when bbt is searched, then we store the found bbts pages here.
+ *             Its an array and supports up to 8 chips now
+ * @offs:      offset of the pattern in the oob area of the page
+ * @veroffs:   offset of the bbt version counter in the oob are of the page
+ * @version:   version read from the bbt page during scan
+ * @len:       length of the pattern, if 0 no pattern check is performed
+ * @maxblocks: maximum number of blocks to search for a bbt. This number of
+ *             blocks is reserved at the end of the device where the tables are
+ *             written.
+ * @reserved_block_code: if non-0, this pattern denotes a reserved (rather than
+ *              bad) block in the stored bbt
+ * @pattern:   pattern to identify bad block table or factory marked good /
+ *             bad blocks, can be NULL, if len = 0
  *
  * Descriptor for the bad block table marker and the descriptor for the
  * pattern which identifies good and bad blocks. The assumption is made
@@ -90,7 +89,9 @@ struct nand_bbt_descr {
 /*
  * Constants for oob configuration
  */
-#define ONENAND_BADBLOCK_POS   0
+#define NAND_SMALL_BADBLOCK_POS                5
+#define NAND_LARGE_BADBLOCK_POS                0
+#define ONENAND_BADBLOCK_POS           0
 
 /*
  * Bad block scanning errors
index 88d3d8fbf9f2d502855af56d8d800a52f7b1e129..df89f42752322a3a522222efaf8b9be472c04639 100644 (file)
@@ -518,10 +518,11 @@ struct cfi_fixup {
 #define CFI_MFR_ANY 0xffff
 #define CFI_ID_ANY  0xffff
 
-#define CFI_MFR_AMD 0x0001
-#define CFI_MFR_ATMEL 0x001F
-#define CFI_MFR_SAMSUNG 0x00EC
-#define CFI_MFR_ST  0x0020     /* STMicroelectronics */
+#define CFI_MFR_AMD    0x0001
+#define CFI_MFR_INTEL  0x0089
+#define CFI_MFR_ATMEL  0x001F
+#define CFI_MFR_SAMSUNG        0x00EC
+#define CFI_MFR_ST     0x0020 /* STMicroelectronics */
 
 void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);
 
index d4f38c5fd44ec1d1affcc5876e23dfaadc727fd8..d0bf422ae374a19ae41d81e41db3c1b60447d293 100644 (file)
@@ -38,6 +38,15 @@ typedef enum {
        FL_XIP_WHILE_ERASING,
        FL_XIP_WHILE_WRITING,
        FL_SHUTDOWN,
+       /* These 2 come from nand_state_t, which has been unified here */
+       FL_READING,
+       FL_CACHEDPRG,
+       /* These 4 come from onenand_state_t, which has been unified here */
+       FL_RESETING,
+       FL_OTPING,
+       FL_PREPARING_ERASE,
+       FL_VERIFYING_ERASE,
+
        FL_UNKNOWN
 } flstate_t;
 
index 7a232a9bdd6230e0db32e93b582af621c88a02ba..ccab9dfc52178a91e015a2373d4f5e25cc8a3fb0 100644 (file)
@@ -21,6 +21,8 @@
 #include <linux/wait.h>
 #include <linux/spinlock.h>
 #include <linux/mtd/mtd.h>
+#include <linux/mtd/flashchip.h>
+#include <linux/mtd/bbm.h>
 
 struct mtd_info;
 /* Scan and identify a NAND device */
@@ -168,7 +170,6 @@ typedef enum {
 /* Chip does not allow subpage writes */
 #define NAND_NO_SUBPAGE_WRITE  0x00000200
 
-
 /* Options valid for Samsung large page devices */
 #define NAND_SAMSUNG_LP_OPTIONS \
        (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK)
@@ -194,6 +195,9 @@ typedef enum {
 /* This option is defined if the board driver allocates its own buffers
    (e.g. because it needs them DMA-coherent */
 #define NAND_OWN_BUFFERS       0x00040000
+/* Chip may not exist, so silence any errors in scan */
+#define NAND_SCAN_SILENT_NODEV 0x00080000
+
 /* Options set by nand scan */
 /* Nand scan has allocated controller struct */
 #define NAND_CONTROLLER_ALLOC  0x80000000
@@ -202,20 +206,6 @@ typedef enum {
 #define NAND_CI_CHIPNR_MSK     0x03
 #define NAND_CI_CELLTYPE_MSK   0x0C
 
-/*
- * nand_state_t - chip states
- * Enumeration for NAND flash chip state
- */
-typedef enum {
-       FL_READY,
-       FL_READING,
-       FL_WRITING,
-       FL_ERASING,
-       FL_SYNCING,
-       FL_CACHEDPRG,
-       FL_PM_SUSPENDED,
-} nand_state_t;
-
 /* Keep gcc happy */
 struct nand_chip;
 
@@ -402,7 +392,7 @@ struct nand_chip {
        uint8_t         cellinfo;
        int             badblockpos;
 
-       nand_state_t    state;
+       flstate_t       state;
 
        uint8_t         *oob_poi;
        struct nand_hw_control  *controller;
@@ -470,75 +460,6 @@ struct nand_manufacturers {
 extern struct nand_flash_dev nand_flash_ids[];
 extern struct nand_manufacturers nand_manuf_ids[];
 
-/**
- * struct nand_bbt_descr - bad block table descriptor
- * @options:   options for this descriptor
- * @pages:     the page(s) where we find the bbt, used with option BBT_ABSPAGE
- *             when bbt is searched, then we store the found bbts pages here.
- *             Its an array and supports up to 8 chips now
- * @offs:      offset of the pattern in the oob area of the page
- * @veroffs:   offset of the bbt version counter in the oob are of the page
- * @version:   version read from the bbt page during scan
- * @len:       length of the pattern, if 0 no pattern check is performed
- * @maxblocks: maximum number of blocks to search for a bbt. This number of
- *             blocks is reserved at the end of the device where the tables are
- *             written.
- * @reserved_block_code: if non-0, this pattern denotes a reserved (rather than
- *              bad) block in the stored bbt
- * @pattern:   pattern to identify bad block table or factory marked good /
- *             bad blocks, can be NULL, if len = 0
- *
- * Descriptor for the bad block table marker and the descriptor for the
- * pattern which identifies good and bad blocks. The assumption is made
- * that the pattern and the version count are always located in the oob area
- * of the first block.
- */
-struct nand_bbt_descr {
-       int     options;
-       int     pages[NAND_MAX_CHIPS];
-       int     offs;
-       int     veroffs;
-       uint8_t version[NAND_MAX_CHIPS];
-       int     len;
-       int     maxblocks;
-       int     reserved_block_code;
-       uint8_t *pattern;
-};
-
-/* Options for the bad block table descriptors */
-
-/* The number of bits used per block in the bbt on the device */
-#define NAND_BBT_NRBITS_MSK    0x0000000F
-#define NAND_BBT_1BIT          0x00000001
-#define NAND_BBT_2BIT          0x00000002
-#define NAND_BBT_4BIT          0x00000004
-#define NAND_BBT_8BIT          0x00000008
-/* The bad block table is in the last good block of the device */
-#define        NAND_BBT_LASTBLOCK      0x00000010
-/* The bbt is at the given page, else we must scan for the bbt */
-#define NAND_BBT_ABSPAGE       0x00000020
-/* The bbt is at the given page, else we must scan for the bbt */
-#define NAND_BBT_SEARCH                0x00000040
-/* bbt is stored per chip on multichip devices */
-#define NAND_BBT_PERCHIP       0x00000080
-/* bbt has a version counter at offset veroffs */
-#define NAND_BBT_VERSION       0x00000100
-/* Create a bbt if none axists */
-#define NAND_BBT_CREATE                0x00000200
-/* Search good / bad pattern through all pages of a block */
-#define NAND_BBT_SCANALLPAGES  0x00000400
-/* Scan block empty during good / bad block scan */
-#define NAND_BBT_SCANEMPTY     0x00000800
-/* Write bbt if neccecary */
-#define NAND_BBT_WRITE         0x00001000
-/* Read and write back block contents when writing bbt */
-#define NAND_BBT_SAVECONTENT   0x00002000
-/* Search good / bad pattern on the first and the second page */
-#define NAND_BBT_SCAN2NDPAGE   0x00004000
-
-/* The maximum number of blocks to scan for a bbt */
-#define NAND_BBT_SCAN_MAXBLOCKS        4
-
 extern int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd);
 extern int nand_update_bbt(struct mtd_info *mtd, loff_t offs);
 extern int nand_default_bbt(struct mtd_info *mtd);
@@ -548,12 +469,6 @@ extern int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
 extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
                        size_t * retlen, uint8_t * buf);
 
-/*
-* Constants for oob configuration
-*/
-#define NAND_SMALL_BADBLOCK_POS                5
-#define NAND_LARGE_BADBLOCK_POS                0
-
 /**
  * struct platform_nand_chip - chip level device structure
  * @nr_chips:          max. number of chips to scan for
index 052ea8ca24347c83a7bfb4df0032ebec54fd9c83..41bc013571d05eaa7a3dce82ea8eb00c53cb44af 100644 (file)
 struct mtd_info;
 
 /*
- * Calculate 3 byte ECC code for 256 byte block
+ * Calculate 3 byte ECC code for eccsize byte block
+ */
+void __nand_calculate_ecc(const u_char *dat, unsigned int eccsize,
+                               u_char *ecc_code);
+
+/*
+ * Calculate 3 byte ECC code for 256/512 byte block
  */
 int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code);
 
@@ -27,7 +33,7 @@ int __nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc,
                        unsigned int eccsize);
 
 /*
- * Detect and correct a 1 bit error for 256 byte block
+ * Detect and correct a 1 bit error for 256/512 byte block
  */
 int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc);
 
index 4e49f3350678c63ee2b1c48908498bee0cdb6ffc..5509eb06b326975c6080c16f983a01d541d6eea1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  linux/include/linux/mtd/onenand.h
  *
- *  Copyright (C) 2005-2007 Samsung Electronics
+ *  Copyright Â© 2005-2009 Samsung Electronics
  *  Kyungmin Park <kyungmin.park@samsung.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -14,6 +14,7 @@
 
 #include <linux/spinlock.h>
 #include <linux/completion.h>
+#include <linux/mtd/flashchip.h>
 #include <linux/mtd/onenand_regs.h>
 #include <linux/mtd/bbm.h>
 
@@ -25,22 +26,6 @@ extern int onenand_scan(struct mtd_info *mtd, int max_chips);
 /* Free resources held by the OneNAND device */
 extern void onenand_release(struct mtd_info *mtd);
 
-/*
- * onenand_state_t - chip states
- * Enumeration for OneNAND flash chip state
- */
-typedef enum {
-       FL_READY,
-       FL_READING,
-       FL_WRITING,
-       FL_ERASING,
-       FL_SYNCING,
-       FL_LOCKING,
-       FL_RESETING,
-       FL_OTPING,
-       FL_PM_SUSPENDED,
-} onenand_state_t;
-
 /**
  * struct onenand_bufferram - OneNAND BufferRAM Data
  * @blockpage:         block & page address in BufferRAM
@@ -137,7 +122,7 @@ struct onenand_chip {
 
        spinlock_t              chip_lock;
        wait_queue_head_t       wq;
-       onenand_state_t         state;
+       flstate_t               state;
        unsigned char           *page_buf;
        unsigned char           *oob_buf;
 
@@ -152,6 +137,8 @@ struct onenand_chip {
 /*
  * Helper macros
  */
+#define ONENAND_PAGES_PER_BLOCK        (1<<6)
+
 #define ONENAND_CURRENT_BUFFERRAM(this)                (this->bufferram_index)
 #define ONENAND_NEXT_BUFFERRAM(this)           (this->bufferram_index ^ 1)
 #define ONENAND_SET_NEXT_BUFFERRAM(this)       (this->bufferram_index ^= 1)
index acadbf53a69f519f021e4943e07c5ac2163f4db2..cd6f3b4311951cb841061c33ef33802f13773194 100644 (file)
 #define ONENAND_CMD_LOCK_TIGHT         (0x2C)
 #define ONENAND_CMD_UNLOCK_ALL         (0x27)
 #define ONENAND_CMD_ERASE              (0x94)
+#define ONENAND_CMD_MULTIBLOCK_ERASE   (0x95)
+#define ONENAND_CMD_ERASE_VERIFY       (0x71)
 #define ONENAND_CMD_RESET              (0xF0)
 #define ONENAND_CMD_OTP_ACCESS         (0x65)
 #define ONENAND_CMD_READID             (0x90)
index 028946750289eaa9c7764c6d5cf77ee903c8da22..05b441d9364202ff09ccaa4db7ca28044db30290 100644 (file)
@@ -72,8 +72,6 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
 
 extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
                int (*open)(struct inode *, struct file *));
-extern struct file *nameidata_to_filp(struct nameidata *nd, int flags);
-extern void release_open_intent(struct nameidata *);
 
 extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
 
index 51071b335751daa2723a849a23f0595748a7878e..89b28812ec241002463621d75d93b3621f079221 100644 (file)
@@ -2,6 +2,7 @@
 #define _LINUX_NFS_XDR_H
 
 #include <linux/nfsacl.h>
+#include <linux/nfs3.h>
 
 /*
  * To change the maximum rsize and wsize supported by the NFS client, adjust
index 43011b69297c39adb95e9afbfae4990e17620fe3..f321b578edeb452358497e832815d6cae6b36886 100644 (file)
@@ -29,6 +29,7 @@
 #ifdef __KERNEL__
 
 #include <linux/posix_acl.h>
+#include <linux/sunrpc/xdr.h>
 
 /* Maximum number of ACL entries over NFS */
 #define NFS_ACL_MAX_ENTRIES    1024
index a6d9ef2bb34a9c4bb2f832ec5badea200b439678..8ae78a61eea4f2eaa8f0c137a1f77b27b3d880e8 100644 (file)
@@ -12,7 +12,7 @@
 
 # include <linux/types.h>
 #ifdef __KERNEL__
-# include <linux/in.h>
+# include <linux/nfsd/nfsfh.h>
 #endif
 
 /*
 #define NFSEXP_FSID            0x2000
 #define        NFSEXP_CROSSMOUNT       0x4000
 #define        NFSEXP_NOACL            0x8000  /* reserved for possible ACL related use */
-#define NFSEXP_ALLFLAGS                0xFE3F
+/*
+ * The NFSEXP_V4ROOT flag causes the kernel to give access only to NFSv4
+ * clients, and only to the single directory that is the root of the
+ * export; further lookup and readdir operations are treated as if every
+ * subdirectory was a mountpoint, and ignored if they are not themselves
+ * exported.  This is used by nfsd and mountd to construct the NFSv4
+ * pseudofilesystem, which provides access only to paths leading to each
+ * exported filesystem.
+ */
+#define        NFSEXP_V4ROOT           0x10000
+/* All flags that we claim to support.  (Note we don't support NOACL.) */
+#define NFSEXP_ALLFLAGS                0x17E3F
 
 /* The flags that may vary depending on security flavor: */
 #define NFSEXP_SECINFO_FLAGS   (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \
-                                       | NFSEXP_ALLSQUASH)
+                                       | NFSEXP_ALLSQUASH \
+                                       | NFSEXP_INSECURE_PORT)
 
 #ifdef __KERNEL__
 
@@ -108,7 +120,6 @@ struct svc_expkey {
        struct path             ek_path;
 };
 
-#define EX_SECURE(exp)         (!((exp)->ex_flags & NFSEXP_INSECURE_PORT))
 #define EX_ISSYNC(exp)         (!((exp)->ex_flags & NFSEXP_ASYNC))
 #define EX_NOHIDE(exp)         ((exp)->ex_flags & NFSEXP_NOHIDE)
 #define EX_WGATHER(exp)                ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
index 8f641c908450414b6c65bff05af4ef1a6636418e..65e333afaee41fb93740aed7f4ace5c17aa891d3 100644 (file)
 
 # include <linux/types.h>
 #ifdef __KERNEL__
-# include <linux/string.h>
-# include <linux/fs.h>
+# include <linux/sunrpc/svc.h>
 #endif
 #include <linux/nfsd/const.h>
-#include <linux/nfsd/debug.h>
 
 /*
  * This is the old "dentry style" Linux NFSv2 file handle.
@@ -164,208 +162,6 @@ typedef struct svc_fh {
 
 } svc_fh;
 
-enum nfsd_fsid {
-       FSID_DEV = 0,
-       FSID_NUM,
-       FSID_MAJOR_MINOR,
-       FSID_ENCODE_DEV,
-       FSID_UUID4_INUM,
-       FSID_UUID8,
-       FSID_UUID16,
-       FSID_UUID16_INUM,
-};
-
-enum fsid_source {
-       FSIDSOURCE_DEV,
-       FSIDSOURCE_FSID,
-       FSIDSOURCE_UUID,
-};
-extern enum fsid_source fsid_source(struct svc_fh *fhp);
-
-
-/* This might look a little large to "inline" but in all calls except
- * one, 'vers' is constant so moste of the function disappears.
- */
-static inline void mk_fsid(int vers, u32 *fsidv, dev_t dev, ino_t ino,
-                          u32 fsid, unsigned char *uuid)
-{
-       u32 *up;
-       switch(vers) {
-       case FSID_DEV:
-               fsidv[0] = htonl((MAJOR(dev)<<16) |
-                                MINOR(dev));
-               fsidv[1] = ino_t_to_u32(ino);
-               break;
-       case FSID_NUM:
-               fsidv[0] = fsid;
-               break;
-       case FSID_MAJOR_MINOR:
-               fsidv[0] = htonl(MAJOR(dev));
-               fsidv[1] = htonl(MINOR(dev));
-               fsidv[2] = ino_t_to_u32(ino);
-               break;
-
-       case FSID_ENCODE_DEV:
-               fsidv[0] = new_encode_dev(dev);
-               fsidv[1] = ino_t_to_u32(ino);
-               break;
-
-       case FSID_UUID4_INUM:
-               /* 4 byte fsid and inode number */
-               up = (u32*)uuid;
-               fsidv[0] = ino_t_to_u32(ino);
-               fsidv[1] = up[0] ^ up[1] ^ up[2] ^ up[3];
-               break;
-
-       case FSID_UUID8:
-               /* 8 byte fsid  */
-               up = (u32*)uuid;
-               fsidv[0] = up[0] ^ up[2];
-               fsidv[1] = up[1] ^ up[3];
-               break;
-
-       case FSID_UUID16:
-               /* 16 byte fsid - NFSv3+ only */
-               memcpy(fsidv, uuid, 16);
-               break;
-
-       case FSID_UUID16_INUM:
-               /* 8 byte inode and 16 byte fsid */
-               *(u64*)fsidv = (u64)ino;
-               memcpy(fsidv+2, uuid, 16);
-               break;
-       default: BUG();
-       }
-}
-
-static inline int key_len(int type)
-{
-       switch(type) {
-       case FSID_DEV:          return 8;
-       case FSID_NUM:          return 4;
-       case FSID_MAJOR_MINOR:  return 12;
-       case FSID_ENCODE_DEV:   return 8;
-       case FSID_UUID4_INUM:   return 8;
-       case FSID_UUID8:        return 8;
-       case FSID_UUID16:       return 16;
-       case FSID_UUID16_INUM:  return 24;
-       default: return 0;
-       }
-}
-
-/*
- * Shorthand for dprintk()'s
- */
-extern char * SVCFH_fmt(struct svc_fh *fhp);
-
-/*
- * Function prototypes
- */
-__be32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int);
-__be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
-__be32 fh_update(struct svc_fh *);
-void   fh_put(struct svc_fh *);
-
-static __inline__ struct svc_fh *
-fh_copy(struct svc_fh *dst, struct svc_fh *src)
-{
-       WARN_ON(src->fh_dentry || src->fh_locked);
-                       
-       *dst = *src;
-       return dst;
-}
-
-static inline void
-fh_copy_shallow(struct knfsd_fh *dst, struct knfsd_fh *src)
-{
-       dst->fh_size = src->fh_size;
-       memcpy(&dst->fh_base, &src->fh_base, src->fh_size);
-}
-
-static __inline__ struct svc_fh *
-fh_init(struct svc_fh *fhp, int maxsize)
-{
-       memset(fhp, 0, sizeof(*fhp));
-       fhp->fh_maxsize = maxsize;
-       return fhp;
-}
-
-#ifdef CONFIG_NFSD_V3
-/*
- * Fill in the pre_op attr for the wcc data
- */
-static inline void
-fill_pre_wcc(struct svc_fh *fhp)
-{
-       struct inode    *inode;
-
-       inode = fhp->fh_dentry->d_inode;
-       if (!fhp->fh_pre_saved) {
-               fhp->fh_pre_mtime = inode->i_mtime;
-               fhp->fh_pre_ctime = inode->i_ctime;
-               fhp->fh_pre_size  = inode->i_size;
-               fhp->fh_pre_change = inode->i_version;
-               fhp->fh_pre_saved = 1;
-       }
-}
-
-extern void fill_post_wcc(struct svc_fh *);
-#else
-#define        fill_pre_wcc(ignored)
-#define fill_post_wcc(notused)
-#endif /* CONFIG_NFSD_V3 */
-
-
-/*
- * Lock a file handle/inode
- * NOTE: both fh_lock and fh_unlock are done "by hand" in
- * vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once
- * so, any changes here should be reflected there.
- */
-
-static inline void
-fh_lock_nested(struct svc_fh *fhp, unsigned int subclass)
-{
-       struct dentry   *dentry = fhp->fh_dentry;
-       struct inode    *inode;
-
-       dfprintk(FILEOP, "nfsd: fh_lock(%s) locked = %d\n",
-                       SVCFH_fmt(fhp), fhp->fh_locked);
-
-       BUG_ON(!dentry);
-
-       if (fhp->fh_locked) {
-               printk(KERN_WARNING "fh_lock: %s/%s already locked!\n",
-                       dentry->d_parent->d_name.name, dentry->d_name.name);
-               return;
-       }
-
-       inode = dentry->d_inode;
-       mutex_lock_nested(&inode->i_mutex, subclass);
-       fill_pre_wcc(fhp);
-       fhp->fh_locked = 1;
-}
-
-static inline void
-fh_lock(struct svc_fh *fhp)
-{
-       fh_lock_nested(fhp, I_MUTEX_NORMAL);
-}
-
-/*
- * Unlock a file handle/inode
- */
-static inline void
-fh_unlock(struct svc_fh *fhp)
-{
-       BUG_ON(!fhp->fh_dentry);
-
-       if (fhp->fh_locked) {
-               fill_post_wcc(fhp);
-               mutex_unlock(&fhp->fh_dentry->d_inode->i_mutex);
-               fhp->fh_locked = 0;
-       }
-}
 #endif /* __KERNEL__ */
 
 
index 7a3b565b898f76042d81c5ea00a235bd7dc31b93..812bc1e160dc3086388bf66cddbe5e1ad3a11e2f 100644 (file)
@@ -9,14 +9,8 @@
 #ifndef NFSD_SYSCALL_H
 #define NFSD_SYSCALL_H
 
-# include <linux/types.h>
-#ifdef __KERNEL__
-# include <linux/in.h>
-#endif 
-#include <linux/posix_types.h>
-#include <linux/nfsd/const.h>
+#include <linux/types.h>
 #include <linux/nfsd/export.h>
-#include <linux/nfsd/nfsfh.h>
 
 /*
  * Version of the syscall interface
index 681a697b9a8624b0df39c21c9cda475203b91615..06292dac3eab15ea6f4b82ddc868e7f955889e7e 100644 (file)
 
 #include <linux/sysdev.h>
 #include <linux/cpumask.h>
+#include <linux/workqueue.h>
 
 struct node {
        struct sys_device       sysdev;
+
+#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
+       struct work_struct      node_work;
+#endif
 };
 
 struct memory_block;
 extern struct node node_devices[];
+typedef  void (*node_registration_func_t)(struct node *);
 
 extern int register_node(struct node *, int, struct node *);
 extern void unregister_node(struct node *node);
@@ -39,6 +45,11 @@ extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
 extern int register_mem_sect_under_node(struct memory_block *mem_blk,
                                                int nid);
 extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk);
+
+#ifdef CONFIG_HUGETLBFS
+extern void register_hugetlbfs_with_node(node_registration_func_t doregister,
+                                        node_registration_func_t unregister);
+#endif
 #else
 static inline int register_one_node(int nid)
 {
@@ -65,6 +76,11 @@ static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk)
 {
        return 0;
 }
+
+static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
+                                               node_registration_func_t unreg)
+{
+}
 #endif
 
 #define to_node(sys_device) container_of(sys_device, struct node, sysdev)
index b359c4a9ec9e8decdaef46083c78d045dc5d156e..454997cccbd8c795aa0210dbd50bc0a7606e06d1 100644 (file)
@@ -245,14 +245,19 @@ static inline int __next_node(int n, const nodemask_t *srcp)
        return min_t(int,MAX_NUMNODES,find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
 }
 
+static inline void init_nodemask_of_node(nodemask_t *mask, int node)
+{
+       nodes_clear(*mask);
+       node_set(node, *mask);
+}
+
 #define nodemask_of_node(node)                                         \
 ({                                                                     \
        typeof(_unused_nodemask_arg_) m;                                \
        if (sizeof(m) == sizeof(unsigned long)) {                       \
-               m.bits[0] = 1UL<<(node);                                \
+               m.bits[0] = 1UL << (node);                              \
        } else {                                                        \
-               nodes_clear(m);                                         \
-               node_set((node), m);                                    \
+               init_nodemask_of_node(&m, (node));                      \
        }                                                               \
        m;                                                              \
 })
@@ -480,15 +485,17 @@ static inline int num_node_state(enum node_states state)
 #define for_each_online_node(node) for_each_node_state(node, N_ONLINE)
 
 /*
- * For nodemask scrach area.(See CPUMASK_ALLOC() in cpumask.h)
+ * For nodemask scrach area.
+ * NODEMASK_ALLOC(type, name) allocates an object with a specified type and
+ * name.
  */
-
-#if NODES_SHIFT > 8 /* nodemask_t > 64 bytes */
-#define NODEMASK_ALLOC(x, m) struct x *m = kmalloc(sizeof(*m), GFP_KERNEL)
-#define NODEMASK_FREE(m) kfree(m)
+#if NODES_SHIFT > 8 /* nodemask_t > 256 bytes */
+#define NODEMASK_ALLOC(type, name, gfp_flags)  \
+                       type *name = kmalloc(sizeof(*name), gfp_flags)
+#define NODEMASK_FREE(m)                       kfree(m)
 #else
-#define NODEMASK_ALLOC(x, m) struct x _m, *m = &_m
-#define NODEMASK_FREE(m)
+#define NODEMASK_ALLOC(type, name, gfp_flags)  type _name, *name = &_name
+#define NODEMASK_FREE(m)                       do {} while (0)
 #endif
 
 /* A example struture for using NODEMASK_ALLOC, used in mempolicy. */
@@ -497,8 +504,10 @@ struct nodemask_scratch {
        nodemask_t      mask2;
 };
 
-#define NODEMASK_SCRATCH(x) NODEMASK_ALLOC(nodemask_scratch, x)
-#define NODEMASK_SCRATCH_FREE(x)  NODEMASK_FREE(x)
+#define NODEMASK_SCRATCH(x)                                            \
+                       NODEMASK_ALLOC(struct nodemask_scratch, x,      \
+                                       GFP_KERNEL | __GFP_NORETRY)
+#define NODEMASK_SCRATCH_FREE(x)       NODEMASK_FREE(x)
 
 
 #endif /* __LINUX_NODEMASK_H */
index a31a7301b159e8b1b8036a14cf734dd55ec0d0e2..3aaa31603a861a98d44f0d2b7862c582c589d934 100644 (file)
@@ -10,4 +10,6 @@
 
 #define MAX_NUMNODES    (1 << NODES_SHIFT)
 
+#define        NUMA_NO_NODE    (-1)
+
 #endif /* _LINUX_NUMA_H */
index 6aac5fe4f6f120db2b2c9b5199d69e7d820d5856..537662315627375555939bbcea2375fa7928968b 100644 (file)
@@ -10,6 +10,7 @@
 #ifdef __KERNEL__
 
 #include <linux/types.h>
+#include <linux/nodemask.h>
 
 struct zonelist;
 struct notifier_block;
@@ -26,7 +27,8 @@ enum oom_constraint {
 extern int try_set_zone_oom(struct zonelist *zonelist, gfp_t gfp_flags);
 extern void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_flags);
 
-extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order);
+extern void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
+               int order, nodemask_t *mask);
 extern int register_oom_notifier(struct notifier_block *nb);
 extern int unregister_oom_notifier(struct notifier_block *nb);
 
index 6b202b173955541adbe03ebd8137af6749f1c214..5b59f35dcb8fdd3ef12c4bc4f2cd5f439e63053b 100644 (file)
@@ -8,7 +8,7 @@
 #include <linux/types.h>
 #ifndef __GENERATING_BOUNDS_H
 #include <linux/mm_types.h>
-#include <linux/bounds.h>
+#include <generated/bounds.h>
 #endif /* !__GENERATING_BOUNDS_H */
 
 /*
@@ -99,7 +99,7 @@ enum pageflags {
        PG_buddy,               /* Page is free, on buddy lists */
        PG_swapbacked,          /* Page is backed by RAM/swap */
        PG_unevictable,         /* Page is "unevictable"  */
-#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
+#ifdef CONFIG_MMU
        PG_mlocked,             /* Page is vma mlocked */
 #endif
 #ifdef CONFIG_ARCH_USES_PG_UNCACHED
@@ -259,12 +259,10 @@ PAGEFLAG_FALSE(SwapCache)
 PAGEFLAG(Unevictable, unevictable) __CLEARPAGEFLAG(Unevictable, unevictable)
        TESTCLEARFLAG(Unevictable, unevictable)
 
-#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
-#define MLOCK_PAGES 1
+#ifdef CONFIG_MMU
 PAGEFLAG(Mlocked, mlocked) __CLEARPAGEFLAG(Mlocked, mlocked)
        TESTSCFLAG(Mlocked, mlocked) __TESTCLEARFLAG(Mlocked, mlocked)
 #else
-#define MLOCK_PAGES 0
 PAGEFLAG_FALSE(Mlocked) SETPAGEFLAG_NOOP(Mlocked)
        TESTCLEARFLAG_FALSE(Mlocked) __TESTCLEARFLAG_FALSE(Mlocked)
 #endif
@@ -277,13 +275,15 @@ PAGEFLAG_FALSE(Uncached)
 
 #ifdef CONFIG_MEMORY_FAILURE
 PAGEFLAG(HWPoison, hwpoison)
-TESTSETFLAG(HWPoison, hwpoison)
+TESTSCFLAG(HWPoison, hwpoison)
 #define __PG_HWPOISON (1UL << PG_hwpoison)
 #else
 PAGEFLAG_FALSE(HWPoison)
 #define __PG_HWPOISON 0
 #endif
 
+u64 stable_page_flags(struct page *page);
+
 static inline int PageUptodate(struct page *page)
 {
        int ret = test_bit(PG_uptodate, &(page)->flags);
@@ -393,7 +393,7 @@ static inline void __ClearPageTail(struct page *page)
 
 #endif /* !PAGEFLAGS_EXTENDED */
 
-#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
+#ifdef CONFIG_MMU
 #define __PG_MLOCKED           (1 << PG_mlocked)
 #else
 #define __PG_MLOCKED           0
index 4b938d4f3ac2eff57736a6b8ced5a32f0c260d6a..b0e4eb1262364c9cad92eb7600afbfba0b2afa02 100644 (file)
@@ -57,6 +57,8 @@ static inline void ClearPageCgroup##uname(struct page_cgroup *pc)     \
 static inline int TestClearPageCgroup##uname(struct page_cgroup *pc)   \
        { return test_and_clear_bit(PCG_##lname, &pc->flags);  }
 
+TESTPCGFLAG(Locked, LOCK)
+
 /* Cache flag is set only once (at allocation) */
 TESTPCGFLAG(Cache, CACHE)
 CLEARPCGFLAG(Cache, CACHE)
@@ -86,11 +88,6 @@ static inline void lock_page_cgroup(struct page_cgroup *pc)
        bit_spin_lock(PCG_LOCK, &pc->flags);
 }
 
-static inline int trylock_page_cgroup(struct page_cgroup *pc)
-{
-       return bit_spin_trylock(PCG_LOCK, &pc->flags);
-}
-
 static inline void unlock_page_cgroup(struct page_cgroup *pc)
 {
        bit_spin_unlock(PCG_LOCK, &pc->flags);
index bf1e6708084909b786f19a6fdb095b1573b53df4..5da0690d9cee9796f897b99a155f8a708067c0d0 100644 (file)
@@ -566,6 +566,9 @@ void pcibios_align_resource(void *, struct resource *, resource_size_t,
                                resource_size_t);
 void pcibios_update_irq(struct pci_dev *, int irq);
 
+/* Weak but can be overriden by arch */
+void pci_fixup_cardbus(struct pci_bus *);
+
 /* Generic PCI functions used internally */
 
 extern struct pci_bus *pci_find_bus(int domain, int busnr);
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
deleted file mode 100644 (file)
index e3fb256..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- *  NOTE: this file will be removed in a future kernel release, it is
- *  provided as a courtesy copy of user-space code that relies on the
- *  old (pre-rename) symbols and constants.
- *
- *  Performance events:
- *
- *    Copyright (C) 2008-2009, Thomas Gleixner <tglx@linutronix.de>
- *    Copyright (C) 2008-2009, Red Hat, Inc., Ingo Molnar
- *    Copyright (C) 2008-2009, Red Hat, Inc., Peter Zijlstra
- *
- *  Data type definitions, declarations, prototypes.
- *
- *    Started by: Thomas Gleixner and Ingo Molnar
- *
- *  For licencing details see kernel-base/COPYING
- */
-#ifndef _LINUX_PERF_COUNTER_H
-#define _LINUX_PERF_COUNTER_H
-
-#include <linux/types.h>
-#include <linux/ioctl.h>
-#include <asm/byteorder.h>
-
-/*
- * User-space ABI bits:
- */
-
-/*
- * attr.type
- */
-enum perf_type_id {
-       PERF_TYPE_HARDWARE                      = 0,
-       PERF_TYPE_SOFTWARE                      = 1,
-       PERF_TYPE_TRACEPOINT                    = 2,
-       PERF_TYPE_HW_CACHE                      = 3,
-       PERF_TYPE_RAW                           = 4,
-
-       PERF_TYPE_MAX,                          /* non-ABI */
-};
-
-/*
- * Generalized performance counter event types, used by the
- * attr.event_id parameter of the sys_perf_counter_open()
- * syscall:
- */
-enum perf_hw_id {
-       /*
-        * Common hardware events, generalized by the kernel:
-        */
-       PERF_COUNT_HW_CPU_CYCLES                = 0,
-       PERF_COUNT_HW_INSTRUCTIONS              = 1,
-       PERF_COUNT_HW_CACHE_REFERENCES          = 2,
-       PERF_COUNT_HW_CACHE_MISSES              = 3,
-       PERF_COUNT_HW_BRANCH_INSTRUCTIONS       = 4,
-       PERF_COUNT_HW_BRANCH_MISSES             = 5,
-       PERF_COUNT_HW_BUS_CYCLES                = 6,
-
-       PERF_COUNT_HW_MAX,                      /* non-ABI */
-};
-
-/*
- * Generalized hardware cache counters:
- *
- *       { L1-D, L1-I, LLC, ITLB, DTLB, BPU } x
- *       { read, write, prefetch } x
- *       { accesses, misses }
- */
-enum perf_hw_cache_id {
-       PERF_COUNT_HW_CACHE_L1D                 = 0,
-       PERF_COUNT_HW_CACHE_L1I                 = 1,
-       PERF_COUNT_HW_CACHE_LL                  = 2,
-       PERF_COUNT_HW_CACHE_DTLB                = 3,
-       PERF_COUNT_HW_CACHE_ITLB                = 4,
-       PERF_COUNT_HW_CACHE_BPU                 = 5,
-
-       PERF_COUNT_HW_CACHE_MAX,                /* non-ABI */
-};
-
-enum perf_hw_cache_op_id {
-       PERF_COUNT_HW_CACHE_OP_READ             = 0,
-       PERF_COUNT_HW_CACHE_OP_WRITE            = 1,
-       PERF_COUNT_HW_CACHE_OP_PREFETCH         = 2,
-
-       PERF_COUNT_HW_CACHE_OP_MAX,             /* non-ABI */
-};
-
-enum perf_hw_cache_op_result_id {
-       PERF_COUNT_HW_CACHE_RESULT_ACCESS       = 0,
-       PERF_COUNT_HW_CACHE_RESULT_MISS         = 1,
-
-       PERF_COUNT_HW_CACHE_RESULT_MAX,         /* non-ABI */
-};
-
-/*
- * Special "software" counters provided by the kernel, even if the hardware
- * does not support performance counters. These counters measure various
- * physical and sw events of the kernel (and allow the profiling of them as
- * well):
- */
-enum perf_sw_ids {
-       PERF_COUNT_SW_CPU_CLOCK                 = 0,
-       PERF_COUNT_SW_TASK_CLOCK                = 1,
-       PERF_COUNT_SW_PAGE_FAULTS               = 2,
-       PERF_COUNT_SW_CONTEXT_SWITCHES          = 3,
-       PERF_COUNT_SW_CPU_MIGRATIONS            = 4,
-       PERF_COUNT_SW_PAGE_FAULTS_MIN           = 5,
-       PERF_COUNT_SW_PAGE_FAULTS_MAJ           = 6,
-       PERF_COUNT_SW_ALIGNMENT_FAULTS          = 7,
-       PERF_COUNT_SW_EMULATION_FAULTS          = 8,
-
-       PERF_COUNT_SW_MAX,                      /* non-ABI */
-};
-
-/*
- * Bits that can be set in attr.sample_type to request information
- * in the overflow packets.
- */
-enum perf_counter_sample_format {
-       PERF_SAMPLE_IP                          = 1U << 0,
-       PERF_SAMPLE_TID                         = 1U << 1,
-       PERF_SAMPLE_TIME                        = 1U << 2,
-       PERF_SAMPLE_ADDR                        = 1U << 3,
-       PERF_SAMPLE_READ                        = 1U << 4,
-       PERF_SAMPLE_CALLCHAIN                   = 1U << 5,
-       PERF_SAMPLE_ID                          = 1U << 6,
-       PERF_SAMPLE_CPU                         = 1U << 7,
-       PERF_SAMPLE_PERIOD                      = 1U << 8,
-       PERF_SAMPLE_STREAM_ID                   = 1U << 9,
-       PERF_SAMPLE_RAW                         = 1U << 10,
-
-       PERF_SAMPLE_MAX = 1U << 11,             /* non-ABI */
-};
-
-/*
- * The format of the data returned by read() on a perf counter fd,
- * as specified by attr.read_format:
- *
- * struct read_format {
- *     { u64           value;
- *       { u64         time_enabled; } && PERF_FORMAT_ENABLED
- *       { u64         time_running; } && PERF_FORMAT_RUNNING
- *       { u64         id;           } && PERF_FORMAT_ID
- *     } && !PERF_FORMAT_GROUP
- *
- *     { u64           nr;
- *       { u64         time_enabled; } && PERF_FORMAT_ENABLED
- *       { u64         time_running; } && PERF_FORMAT_RUNNING
- *       { u64         value;
- *         { u64       id;           } && PERF_FORMAT_ID
- *       }             cntr[nr];
- *     } && PERF_FORMAT_GROUP
- * };
- */
-enum perf_counter_read_format {
-       PERF_FORMAT_TOTAL_TIME_ENABLED          = 1U << 0,
-       PERF_FORMAT_TOTAL_TIME_RUNNING          = 1U << 1,
-       PERF_FORMAT_ID                          = 1U << 2,
-       PERF_FORMAT_GROUP                       = 1U << 3,
-
-       PERF_FORMAT_MAX = 1U << 4,              /* non-ABI */
-};
-
-#define PERF_ATTR_SIZE_VER0    64      /* sizeof first published struct */
-
-/*
- * Hardware event to monitor via a performance monitoring counter:
- */
-struct perf_counter_attr {
-
-       /*
-        * Major type: hardware/software/tracepoint/etc.
-        */
-       __u32                   type;
-
-       /*
-        * Size of the attr structure, for fwd/bwd compat.
-        */
-       __u32                   size;
-
-       /*
-        * Type specific configuration information.
-        */
-       __u64                   config;
-
-       union {
-               __u64           sample_period;
-               __u64           sample_freq;
-       };
-
-       __u64                   sample_type;
-       __u64                   read_format;
-
-       __u64                   disabled       :  1, /* off by default        */
-                               inherit        :  1, /* children inherit it   */
-                               pinned         :  1, /* must always be on PMU */
-                               exclusive      :  1, /* only group on PMU     */
-                               exclude_user   :  1, /* don't count user      */
-                               exclude_kernel :  1, /* ditto kernel          */
-                               exclude_hv     :  1, /* ditto hypervisor      */
-                               exclude_idle   :  1, /* don't count when idle */
-                               mmap           :  1, /* include mmap data     */
-                               comm           :  1, /* include comm data     */
-                               freq           :  1, /* use freq, not period  */
-                               inherit_stat   :  1, /* per task counts       */
-                               enable_on_exec :  1, /* next exec enables     */
-                               task           :  1, /* trace fork/exit       */
-                               watermark      :  1, /* wakeup_watermark      */
-
-                               __reserved_1   : 49;
-
-       union {
-               __u32           wakeup_events;    /* wakeup every n events */
-               __u32           wakeup_watermark; /* bytes before wakeup   */
-       };
-       __u32                   __reserved_2;
-
-       __u64                   __reserved_3;
-};
-
-/*
- * Ioctls that can be done on a perf counter fd:
- */
-#define PERF_COUNTER_IOC_ENABLE                _IO ('$', 0)
-#define PERF_COUNTER_IOC_DISABLE       _IO ('$', 1)
-#define PERF_COUNTER_IOC_REFRESH       _IO ('$', 2)
-#define PERF_COUNTER_IOC_RESET         _IO ('$', 3)
-#define PERF_COUNTER_IOC_PERIOD                _IOW('$', 4, u64)
-#define PERF_COUNTER_IOC_SET_OUTPUT    _IO ('$', 5)
-#define PERF_COUNTER_IOC_SET_FILTER    _IOW('$', 6, char *)
-
-enum perf_counter_ioc_flags {
-       PERF_IOC_FLAG_GROUP             = 1U << 0,
-};
-
-/*
- * Structure of the page that can be mapped via mmap
- */
-struct perf_counter_mmap_page {
-       __u32   version;                /* version number of this structure */
-       __u32   compat_version;         /* lowest version this is compat with */
-
-       /*
-        * Bits needed to read the hw counters in user-space.
-        *
-        *   u32 seq;
-        *   s64 count;
-        *
-        *   do {
-        *     seq = pc->lock;
-        *
-        *     barrier()
-        *     if (pc->index) {
-        *       count = pmc_read(pc->index - 1);
-        *       count += pc->offset;
-        *     } else
-        *       goto regular_read;
-        *
-        *     barrier();
-        *   } while (pc->lock != seq);
-        *
-        * NOTE: for obvious reason this only works on self-monitoring
-        *       processes.
-        */
-       __u32   lock;                   /* seqlock for synchronization */
-       __u32   index;                  /* hardware counter identifier */
-       __s64   offset;                 /* add to hardware counter value */
-       __u64   time_enabled;           /* time counter active */
-       __u64   time_running;           /* time counter on cpu */
-
-               /*
-                * Hole for extension of the self monitor capabilities
-                */
-
-       __u64   __reserved[123];        /* align to 1k */
-
-       /*
-        * Control data for the mmap() data buffer.
-        *
-        * User-space reading the @data_head value should issue an rmb(), on
-        * SMP capable platforms, after reading this value -- see
-        * perf_counter_wakeup().
-        *
-        * When the mapping is PROT_WRITE the @data_tail value should be
-        * written by userspace to reflect the last read data. In this case
-        * the kernel will not over-write unread data.
-        */
-       __u64   data_head;              /* head in the data section */
-       __u64   data_tail;              /* user-space written tail */
-};
-
-#define PERF_EVENT_MISC_CPUMODE_MASK           (3 << 0)
-#define PERF_EVENT_MISC_CPUMODE_UNKNOWN                (0 << 0)
-#define PERF_EVENT_MISC_KERNEL                 (1 << 0)
-#define PERF_EVENT_MISC_USER                   (2 << 0)
-#define PERF_EVENT_MISC_HYPERVISOR             (3 << 0)
-
-struct perf_event_header {
-       __u32   type;
-       __u16   misc;
-       __u16   size;
-};
-
-enum perf_event_type {
-
-       /*
-        * The MMAP events record the PROT_EXEC mappings so that we can
-        * correlate userspace IPs to code. They have the following structure:
-        *
-        * struct {
-        *      struct perf_event_header        header;
-        *
-        *      u32                             pid, tid;
-        *      u64                             addr;
-        *      u64                             len;
-        *      u64                             pgoff;
-        *      char                            filename[];
-        * };
-        */
-       PERF_EVENT_MMAP                 = 1,
-
-       /*
-        * struct {
-        *      struct perf_event_header        header;
-        *      u64                             id;
-        *      u64                             lost;
-        * };
-        */
-       PERF_EVENT_LOST                 = 2,
-
-       /*
-        * struct {
-        *      struct perf_event_header        header;
-        *
-        *      u32                             pid, tid;
-        *      char                            comm[];
-        * };
-        */
-       PERF_EVENT_COMM                 = 3,
-
-       /*
-        * struct {
-        *      struct perf_event_header        header;
-        *      u32                             pid, ppid;
-        *      u32                             tid, ptid;
-        *      u64                             time;
-        * };
-        */
-       PERF_EVENT_EXIT                 = 4,
-
-       /*
-        * struct {
-        *      struct perf_event_header        header;
-        *      u64                             time;
-        *      u64                             id;
-        *      u64                             stream_id;
-        * };
-        */
-       PERF_EVENT_THROTTLE             = 5,
-       PERF_EVENT_UNTHROTTLE           = 6,
-
-       /*
-        * struct {
-        *      struct perf_event_header        header;
-        *      u32                             pid, ppid;
-        *      u32                             tid, ptid;
-        *      u64                             time;
-        * };
-        */
-       PERF_EVENT_FORK                 = 7,
-
-       /*
-        * struct {
-        *      struct perf_event_header        header;
-        *      u32                             pid, tid;
-        *
-        *      struct read_format              values;
-        * };
-        */
-       PERF_EVENT_READ                 = 8,
-
-       /*
-        * struct {
-        *      struct perf_event_header        header;
-        *
-        *      { u64                   ip;       } && PERF_SAMPLE_IP
-        *      { u32                   pid, tid; } && PERF_SAMPLE_TID
-        *      { u64                   time;     } && PERF_SAMPLE_TIME
-        *      { u64                   addr;     } && PERF_SAMPLE_ADDR
-        *      { u64                   id;       } && PERF_SAMPLE_ID
-        *      { u64                   stream_id;} && PERF_SAMPLE_STREAM_ID
-        *      { u32                   cpu, res; } && PERF_SAMPLE_CPU
-        *      { u64                   period;   } && PERF_SAMPLE_PERIOD
-        *
-        *      { struct read_format    values;   } && PERF_SAMPLE_READ
-        *
-        *      { u64                   nr,
-        *        u64                   ips[nr];  } && PERF_SAMPLE_CALLCHAIN
-        *
-        *      #
-        *      # The RAW record below is opaque data wrt the ABI
-        *      #
-        *      # That is, the ABI doesn't make any promises wrt to
-        *      # the stability of its content, it may vary depending
-        *      # on event, hardware, kernel version and phase of
-        *      # the moon.
-        *      #
-        *      # In other words, PERF_SAMPLE_RAW contents are not an ABI.
-        *      #
-        *
-        *      { u32                   size;
-        *        char                  data[size];}&& PERF_SAMPLE_RAW
-        * };
-        */
-       PERF_EVENT_SAMPLE               = 9,
-
-       PERF_EVENT_MAX,                 /* non-ABI */
-};
-
-enum perf_callchain_context {
-       PERF_CONTEXT_HV                 = (__u64)-32,
-       PERF_CONTEXT_KERNEL             = (__u64)-128,
-       PERF_CONTEXT_USER               = (__u64)-512,
-
-       PERF_CONTEXT_GUEST              = (__u64)-2048,
-       PERF_CONTEXT_GUEST_KERNEL       = (__u64)-2176,
-       PERF_CONTEXT_GUEST_USER         = (__u64)-2560,
-
-       PERF_CONTEXT_MAX                = (__u64)-4095,
-};
-
-#define PERF_FLAG_FD_NO_GROUP          (1U << 0)
-#define PERF_FLAG_FD_OUTPUT            (1U << 1)
-
-/*
- * In case some app still references the old symbols:
- */
-
-#define __NR_perf_counter_open         __NR_perf_event_open
-
-#define PR_TASK_PERF_COUNTERS_DISABLE  PR_TASK_PERF_EVENTS_DISABLE
-#define PR_TASK_PERF_COUNTERS_ENABLE   PR_TASK_PERF_EVENTS_ENABLE
-
-#endif /* _LINUX_PERF_COUNTER_H */
index 64a53f74c9a91d140331863bbc4a1e0423fbb7ee..c66b34f75eea5f82662cbe3dcba81198248ee56e 100644 (file)
@@ -211,17 +211,11 @@ struct perf_event_attr {
                __u32           wakeup_watermark; /* bytes before wakeup   */
        };
 
-       struct { /* Hardware breakpoint info */
-               __u64           bp_addr;
-               __u32           bp_type;
-               __u32           bp_len;
-               __u64           __bp_reserved_1;
-               __u64           __bp_reserved_2;
-       };
-
        __u32                   __reserved_2;
 
-       __u64                   __reserved_3;
+       __u64                   bp_addr;
+       __u32                   bp_type;
+       __u32                   bp_len;
 };
 
 /*
@@ -681,7 +675,7 @@ struct perf_event_context {
         * Protect the states of the events in the list,
         * nr_active, and the list:
         */
-       spinlock_t                      lock;
+       raw_spinlock_t                  lock;
        /*
         * Protect the list of events.  Locking either mutex or lock
         * is sufficient to ensure the list doesn't change; to change
index 45926d77d6ac8241ae045ebba4e310ed109d47dd..8227f717c70fbf021fd16c104e2950b646ccdc6e 100644 (file)
@@ -81,7 +81,8 @@ struct plist_head {
        struct list_head prio_list;
        struct list_head node_list;
 #ifdef CONFIG_DEBUG_PI_LIST
-       spinlock_t *lock;
+       raw_spinlock_t *rawlock;
+       spinlock_t *spinlock;
 #endif
 };
 
@@ -91,9 +92,11 @@ struct plist_node {
 };
 
 #ifdef CONFIG_DEBUG_PI_LIST
-# define PLIST_HEAD_LOCK_INIT(_lock)   .lock = _lock
+# define PLIST_HEAD_LOCK_INIT(_lock)           .spinlock = _lock
+# define PLIST_HEAD_LOCK_INIT_RAW(_lock)       .rawlock = _lock
 #else
 # define PLIST_HEAD_LOCK_INIT(_lock)
+# define PLIST_HEAD_LOCK_INIT_RAW(_lock)
 #endif
 
 #define _PLIST_HEAD_INIT(head)                         \
@@ -107,10 +110,21 @@ struct plist_node {
  */
 #define PLIST_HEAD_INIT(head, _lock)                   \
 {                                                      \
-        _PLIST_HEAD_INIT(head),                         \
+       _PLIST_HEAD_INIT(head),                         \
        PLIST_HEAD_LOCK_INIT(&(_lock))                  \
 }
 
+/**
+ * PLIST_HEAD_INIT_RAW - static struct plist_head initializer
+ * @head:      struct plist_head variable name
+ * @_lock:     lock to initialize for this list
+ */
+#define PLIST_HEAD_INIT_RAW(head, _lock)               \
+{                                                      \
+       _PLIST_HEAD_INIT(head),                         \
+       PLIST_HEAD_LOCK_INIT_RAW(&(_lock))              \
+}
+
 /**
  * PLIST_NODE_INIT - static struct plist_node initializer
  * @node:      struct plist_node variable name
@@ -119,13 +133,13 @@ struct plist_node {
 #define PLIST_NODE_INIT(node, __prio)                  \
 {                                                      \
        .prio  = (__prio),                              \
-       .plist = { _PLIST_HEAD_INIT((node).plist) },    \
+       .plist = { _PLIST_HEAD_INIT((node).plist) },    \
 }
 
 /**
  * plist_head_init - dynamic struct plist_head initializer
  * @head:      &struct plist_head pointer
- * @lock:      list spinlock, remembered for debugging
+ * @lock:      spinlock protecting the list (debugging)
  */
 static inline void
 plist_head_init(struct plist_head *head, spinlock_t *lock)
@@ -133,7 +147,24 @@ plist_head_init(struct plist_head *head, spinlock_t *lock)
        INIT_LIST_HEAD(&head->prio_list);
        INIT_LIST_HEAD(&head->node_list);
 #ifdef CONFIG_DEBUG_PI_LIST
-       head->lock = lock;
+       head->spinlock = lock;
+       head->rawlock = NULL;
+#endif
+}
+
+/**
+ * plist_head_init_raw - dynamic struct plist_head initializer
+ * @head:      &struct plist_head pointer
+ * @lock:      raw_spinlock protecting the list (debugging)
+ */
+static inline void
+plist_head_init_raw(struct plist_head *head, raw_spinlock_t *lock)
+{
+       INIT_LIST_HEAD(&head->prio_list);
+       INIT_LIST_HEAD(&head->node_list);
+#ifdef CONFIG_DEBUG_PI_LIST
+       head->rawlock = lock;
+       head->spinlock = NULL;
 #endif
 }
 
index 0d65934246af8c3ba0997c05059009de684b27ea..198b8f9fe05ec2ab97d351fbfba053f980869100 100644 (file)
@@ -219,7 +219,7 @@ struct dev_pm_ops {
  * to RAM and hibernation.
  */
 #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
-struct dev_pm_ops name = { \
+const struct dev_pm_ops name = { \
        .suspend = suspend_fn, \
        .resume = resume_fn, \
        .freeze = suspend_fn, \
index fddfafaed0247318ca33482513c89fc7d6ef42ed..7c4193eb007248f31307d58b333edc11d0233bc3 100644 (file)
@@ -334,6 +334,19 @@ extern struct pnp_protocol pnpbios_protocol;
 #define pnp_device_is_pnpbios(dev) 0
 #endif
 
+#ifdef CONFIG_PNPACPI
+extern struct pnp_protocol pnpacpi_protocol;
+
+static inline struct acpi_device *pnp_acpi_device(struct pnp_dev *dev)
+{
+       if (dev->protocol == &pnpacpi_protocol)
+               return dev->data;
+       return NULL;
+}
+#else
+#define pnp_acpi_device(dev) 0
+#endif
+
 /* status */
 #define PNP_READY              0x0000
 #define PNP_ATTACHED           0x0001
index 7456d7d87a19869daec62c199c09087f1b30177c..56f2d63a5cbb6b6794959fe1553aa779e79912dd 100644 (file)
@@ -105,12 +105,7 @@ static inline int ptrace_reparented(struct task_struct *child)
 {
        return child->real_parent != child->parent;
 }
-static inline void ptrace_link(struct task_struct *child,
-                              struct task_struct *new_parent)
-{
-       if (unlikely(child->ptrace))
-               __ptrace_link(child, new_parent);
-}
+
 static inline void ptrace_unlink(struct task_struct *child)
 {
        if (unlikely(child->ptrace))
@@ -169,9 +164,9 @@ static inline void ptrace_init_task(struct task_struct *child, bool ptrace)
        INIT_LIST_HEAD(&child->ptraced);
        child->parent = child->real_parent;
        child->ptrace = 0;
-       if (unlikely(ptrace)) {
+       if (unlikely(ptrace) && (current->ptrace & PT_PTRACED)) {
                child->ptrace = current->ptrace;
-               ptrace_link(child, current->parent);
+               __ptrace_link(child, current->parent);
        }
 }
 
@@ -278,6 +273,18 @@ static inline void user_enable_block_step(struct task_struct *task)
 }
 #endif /* arch_has_block_step */
 
+#ifdef ARCH_HAS_USER_SINGLE_STEP_INFO
+extern void user_single_step_siginfo(struct task_struct *tsk,
+                               struct pt_regs *regs, siginfo_t *info);
+#else
+static inline void user_single_step_siginfo(struct task_struct *tsk,
+                               struct pt_regs *regs, siginfo_t *info)
+{
+       memset(info, 0, sizeof(*info));
+       info->si_signo = SIGTRAP;
+}
+#endif
+
 #ifndef arch_ptrace_stop_needed
 /**
  * arch_ptrace_stop_needed - Decide whether arch_ptrace_stop() should be called
index 7a9754c96775091d1ac9ef9c002682e29c38ca88..01b3d759f1fccec7f88e1b276973aa6f70e5bae5 100644 (file)
@@ -10,7 +10,7 @@ struct platform_pwm_backlight_data {
        unsigned int dft_brightness;
        unsigned int pwm_period_ns;
        int (*init)(struct device *dev);
-       int (*notify)(int brightness);
+       int (*notify)(struct device *dev, int brightness);
        void (*exit)(struct device *dev);
 };
 
index e70e62194243f1a255b83cf930e9d69b9bc6f1fc..a6861f11748044d2c666c6f94edf463c8c47660a 100644 (file)
@@ -315,8 +315,9 @@ struct dquot_operations {
        int (*claim_space) (struct inode *, qsize_t);
        /* release rsved quota for delayed alloc */
        void (*release_rsv) (struct inode *, qsize_t);
-       /* get reserved quota for delayed alloc */
-       qsize_t (*get_reserved_space) (struct inode *);
+       /* get reserved quota for delayed alloc, value returned is managed by
+        * quota code only */
+       qsize_t *(*get_reserved_space) (struct inode *);
 };
 
 /* Operations handling requests from userspace */
index c4ba9a78721e1f4130526255050a1ed7f888ca4b..96cc307ed9f4ef0c85ffdf7509ad107dd73f77f2 100644 (file)
@@ -101,4 +101,9 @@ static inline void exit_rcu(void)
 {
 }
 
+static inline int rcu_preempt_depth(void)
+{
+       return 0;
+}
+
 #endif /* __LINUX_RCUTINY_H */
index c93eee5911b0760ab81ae3791a31c7c340f800eb..8044b1b9433381ebd77dfa11cf4838c37690facb 100644 (file)
@@ -45,6 +45,12 @@ extern void __rcu_read_unlock(void);
 extern void synchronize_rcu(void);
 extern void exit_rcu(void);
 
+/*
+ * Defined as macro as it is a very low level header
+ * included from areas that don't even know about current
+ */
+#define rcu_preempt_depth() (current->rcu_read_lock_nesting)
+
 #else /* #ifdef CONFIG_TREE_PREEMPT_RCU */
 
 static inline void __rcu_read_lock(void)
@@ -63,6 +69,11 @@ static inline void exit_rcu(void)
 {
 }
 
+static inline int rcu_preempt_depth(void)
+{
+       return 0;
+}
+
 #endif /* #else #ifdef CONFIG_TREE_PREEMPT_RCU */
 
 static inline void __rcu_read_lock_bh(void)
index 490c5b37b6d7f02f2f25003b4e7f4d4356a4bed9..030d92255c7a09b8fd6175f93e0a1862b96c21a5 100644 (file)
@@ -35,6 +35,8 @@
 #ifndef __LINUX_REGULATOR_CONSUMER_H_
 #define __LINUX_REGULATOR_CONSUMER_H_
 
+#include <linux/device.h>
+
 /*
  * Regulator operating modes.
  *
index 87f5f176d4ef31c521e133a9b24c92471d5d5eeb..234a8476cba8a5acadb627236819e89333838eec 100644 (file)
@@ -43,16 +43,20 @@ struct regulator;
 /**
  * struct regulator_state - regulator state during low power system states
  *
- * This describes a regulators state during a system wide low power state.
+ * This describes a regulators state during a system wide low power
+ * state.  One of enabled or disabled must be set for the
+ * configuration to be applied.
  *
  * @uV: Operating voltage during suspend.
  * @mode: Operating mode during suspend.
  * @enabled: Enabled during suspend.
+ * @disabled: Disabled during suspend.
  */
 struct regulator_state {
        int uV; /* suspend voltage */
        unsigned int mode; /* suspend regulator operating mode */
        int enabled; /* is regulator enabled in this suspend state */
+       int disabled; /* is the regulator disbled in this suspend state */
 };
 
 /**
diff --git a/include/linux/regulator/max8660.h b/include/linux/regulator/max8660.h
new file mode 100644 (file)
index 0000000..9936763
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * max8660.h  --  Voltage regulation for the Maxim 8660/8661
+ *
+ * Copyright (C) 2009 Wolfram Sang, Pengutronix e.K.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __LINUX_REGULATOR_MAX8660_H
+#define __LINUX_REGULATOR_MAX8660_H
+
+#include <linux/regulator/machine.h>
+
+enum {
+       MAX8660_V3,
+       MAX8660_V4,
+       MAX8660_V5,
+       MAX8660_V6,
+       MAX8660_V7,
+       MAX8660_V_END,
+};
+
+/**
+ * max8660_subdev_data - regulator subdev data
+ * @id: regulator id
+ * @name: regulator name
+ * @platform_data: regulator init data
+ */
+struct max8660_subdev_data {
+       int                             id;
+       char                            *name;
+       struct regulator_init_data      *platform_data;
+};
+
+/**
+ * max8660_platform_data - platform data for max8660
+ * @num_subdevs: number of regulators used
+ * @subdevs: pointer to regulators used
+ * @en34_is_high: if EN34 is driven high, regulators cannot be en-/disabled.
+ */
+struct max8660_platform_data {
+       int num_subdevs;
+       struct max8660_subdev_data *subdevs;
+       unsigned en34_is_high:1;
+};
+#endif
index a05b4a20768d9026c939f1244ec2897dbdf4ab74..c96c1858fe2c404673810c33560ce0c56701d566 100644 (file)
@@ -2051,25 +2051,12 @@ void set_de_name_and_namelen(struct reiserfs_dir_entry *de);
 int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,
                        struct treepath *path, struct reiserfs_dir_entry *de);
 struct dentry *reiserfs_get_parent(struct dentry *);
-/* procfs.c */
-
-#if defined( CONFIG_PROC_FS ) && defined( CONFIG_REISERFS_PROC_INFO )
-#define REISERFS_PROC_INFO
-#else
-#undef REISERFS_PROC_INFO
-#endif
 
+#ifdef CONFIG_REISERFS_PROC_INFO
 int reiserfs_proc_info_init(struct super_block *sb);
 int reiserfs_proc_info_done(struct super_block *sb);
-struct proc_dir_entry *reiserfs_proc_register_global(char *name,
-                                                    read_proc_t * func);
-void reiserfs_proc_unregister_global(const char *name);
 int reiserfs_proc_info_global_init(void);
 int reiserfs_proc_info_global_done(void);
-int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
-                                   int count, int *eof, void *data);
-
-#if defined( REISERFS_PROC_INFO )
 
 #define PROC_EXP( e )   e
 
@@ -2084,6 +2071,26 @@ int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset,
     PROC_INFO_ADD( sb, free_at[ ( level ) ], B_FREE_SPACE( bh ) );     \
     PROC_INFO_ADD( sb, items_at[ ( level ) ], B_NR_ITEMS( bh ) )
 #else
+static inline int reiserfs_proc_info_init(struct super_block *sb)
+{
+       return 0;
+}
+
+static inline int reiserfs_proc_info_done(struct super_block *sb)
+{
+       return 0;
+}
+
+static inline int reiserfs_proc_info_global_init(void)
+{
+       return 0;
+}
+
+static inline int reiserfs_proc_info_global_done(void)
+{
+       return 0;
+}
+
 #define PROC_EXP( e )
 #define VOID_V ( ( void ) 0 )
 #define PROC_INFO_MAX( sb, field, value ) VOID_V
index cb0ba7032609d5602a709a54f4b012413b981587..b019ae64e2ab1d356daf92aaa7e92547227246c7 100644 (file)
@@ -26,6 +26,9 @@
  */
 struct anon_vma {
        spinlock_t lock;        /* Serialize access to vma list */
+#ifdef CONFIG_KSM
+       atomic_t ksm_refcount;
+#endif
        /*
         * NOTE: the LSB of the head.next is set by
         * mm_take_all_locks() _after_ taking the above lock. So the
@@ -38,6 +41,34 @@ struct anon_vma {
 };
 
 #ifdef CONFIG_MMU
+#ifdef CONFIG_KSM
+static inline void ksm_refcount_init(struct anon_vma *anon_vma)
+{
+       atomic_set(&anon_vma->ksm_refcount, 0);
+}
+
+static inline int ksm_refcount(struct anon_vma *anon_vma)
+{
+       return atomic_read(&anon_vma->ksm_refcount);
+}
+#else
+static inline void ksm_refcount_init(struct anon_vma *anon_vma)
+{
+}
+
+static inline int ksm_refcount(struct anon_vma *anon_vma)
+{
+       return 0;
+}
+#endif /* CONFIG_KSM */
+
+static inline struct anon_vma *page_anon_vma(struct page *page)
+{
+       if (((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) !=
+                                           PAGE_MAPPING_ANON)
+               return NULL;
+       return page_rmapping(page);
+}
 
 static inline void anon_vma_lock(struct vm_area_struct *vma)
 {
@@ -62,6 +93,7 @@ void __anon_vma_merge(struct vm_area_struct *, struct vm_area_struct *);
 void anon_vma_unlink(struct vm_area_struct *);
 void anon_vma_link(struct vm_area_struct *);
 void __anon_vma_link(struct vm_area_struct *);
+void anon_vma_free(struct anon_vma *);
 
 /*
  * rmap interfaces called when adding or removing pte of page
@@ -81,6 +113,9 @@ static inline void page_dup_rmap(struct page *page)
  */
 int page_referenced(struct page *, int is_locked,
                        struct mem_cgroup *cnt, unsigned long *vm_flags);
+int page_referenced_one(struct page *, struct vm_area_struct *,
+       unsigned long address, unsigned int *mapcount, unsigned long *vm_flags);
+
 enum ttu_flags {
        TTU_UNMAP = 0,                  /* unmap mode */
        TTU_MIGRATION = 1,              /* migration mode */
@@ -94,6 +129,8 @@ enum ttu_flags {
 #define TTU_ACTION(x) ((x) & TTU_ACTION_MASK)
 
 int try_to_unmap(struct page *, enum ttu_flags flags);
+int try_to_unmap_one(struct page *, struct vm_area_struct *,
+                       unsigned long address, enum ttu_flags flags);
 
 /*
  * Called from mm/filemap_xip.c to unmap empty zero page
@@ -127,6 +164,12 @@ struct anon_vma *page_lock_anon_vma(struct page *page);
 void page_unlock_anon_vma(struct anon_vma *anon_vma);
 int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma);
 
+/*
+ * Called by migrate.c to remove migration ptes, but might be used more later.
+ */
+int rmap_walk(struct page *page, int (*rmap_one)(struct page *,
+               struct vm_area_struct *, unsigned long, void *), void *arg);
+
 #else  /* !CONFIG_MMU */
 
 #define anon_vma_init()                do {} while (0)
index f19b00b7d530a8e60f67e77c5f1c5ac5270e8d9b..281d8fd775e8aa1648171b1247d753e0595a1d16 100644 (file)
@@ -24,7 +24,7 @@
  * @owner:     the mutex owner
  */
 struct rt_mutex {
-       spinlock_t              wait_lock;
+       raw_spinlock_t          wait_lock;
        struct plist_head       wait_list;
        struct task_struct      *owner;
 #ifdef CONFIG_DEBUG_RT_MUTEXES
@@ -63,8 +63,8 @@ struct hrtimer_sleeper;
 #endif
 
 #define __RT_MUTEX_INITIALIZER(mutexname) \
-       { .wait_lock = __SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \
-       , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \
+       { .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \
+       , .wait_list = PLIST_HEAD_INIT_RAW(mutexname.wait_list, mutexname.wait_lock) \
        , .owner = NULL \
        __DEBUG_RT_MUTEX_INITIALIZER(mutexname)}
 
index 14fc906ed6029edc67f93bd60b6ba3052c45bb29..05330fc5b436034aa1b361934e2180bd96266938 100644 (file)
@@ -368,11 +368,9 @@ enum {
 #define RTAX_MAX (__RTAX_MAX - 1)
 
 #define RTAX_FEATURE_ECN       0x00000001
-#define RTAX_FEATURE_NO_SACK   0x00000002
-#define RTAX_FEATURE_NO_TSTAMP 0x00000004
+#define RTAX_FEATURE_SACK      0x00000002
+#define RTAX_FEATURE_TIMESTAMP 0x00000004
 #define RTAX_FEATURE_ALLFRAG   0x00000008
-#define RTAX_FEATURE_NO_WSCALE 0x00000010
-#define RTAX_FEATURE_NO_DSACK  0x00000020
 
 struct rta_session {
        __u8    proto;
diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h
new file mode 100644 (file)
index 0000000..71e0b00
--- /dev/null
@@ -0,0 +1,125 @@
+#ifndef __LINUX_RWLOCK_H
+#define __LINUX_RWLOCK_H
+
+#ifndef __LINUX_SPINLOCK_H
+# error "please don't include this file directly"
+#endif
+
+/*
+ * rwlock related methods
+ *
+ * split out from spinlock.h
+ *
+ * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
+ * Released under the General Public License (GPL).
+ */
+
+#ifdef CONFIG_DEBUG_SPINLOCK
+  extern void __rwlock_init(rwlock_t *lock, const char *name,
+                           struct lock_class_key *key);
+# define rwlock_init(lock)                                     \
+do {                                                           \
+       static struct lock_class_key __key;                     \
+                                                               \
+       __rwlock_init((lock), #lock, &__key);                   \
+} while (0)
+#else
+# define rwlock_init(lock)                                     \
+       do { *(lock) = __RW_LOCK_UNLOCKED(lock); } while (0)
+#endif
+
+#ifdef CONFIG_DEBUG_SPINLOCK
+ extern void do_raw_read_lock(rwlock_t *lock);
+#define do_raw_read_lock_flags(lock, flags) do_raw_read_lock(lock)
+ extern int do_raw_read_trylock(rwlock_t *lock);
+ extern void do_raw_read_unlock(rwlock_t *lock);
+ extern void do_raw_write_lock(rwlock_t *lock);
+#define do_raw_write_lock_flags(lock, flags) do_raw_write_lock(lock)
+ extern int do_raw_write_trylock(rwlock_t *lock);
+ extern void do_raw_write_unlock(rwlock_t *lock);
+#else
+# define do_raw_read_lock(rwlock)      arch_read_lock(&(rwlock)->raw_lock)
+# define do_raw_read_lock_flags(lock, flags) \
+               arch_read_lock_flags(&(lock)->raw_lock, *(flags))
+# define do_raw_read_trylock(rwlock)   arch_read_trylock(&(rwlock)->raw_lock)
+# define do_raw_read_unlock(rwlock)    arch_read_unlock(&(rwlock)->raw_lock)
+# define do_raw_write_lock(rwlock)     arch_write_lock(&(rwlock)->raw_lock)
+# define do_raw_write_lock_flags(lock, flags) \
+               arch_write_lock_flags(&(lock)->raw_lock, *(flags))
+# define do_raw_write_trylock(rwlock)  arch_write_trylock(&(rwlock)->raw_lock)
+# define do_raw_write_unlock(rwlock)   arch_write_unlock(&(rwlock)->raw_lock)
+#endif
+
+#define read_can_lock(rwlock)          arch_read_can_lock(&(rwlock)->raw_lock)
+#define write_can_lock(rwlock)         arch_write_can_lock(&(rwlock)->raw_lock)
+
+/*
+ * Define the various rw_lock methods.  Note we define these
+ * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various
+ * methods are defined as nops in the case they are not required.
+ */
+#define read_trylock(lock)     __cond_lock(lock, _raw_read_trylock(lock))
+#define write_trylock(lock)    __cond_lock(lock, _raw_write_trylock(lock))
+
+#define write_lock(lock)       _raw_write_lock(lock)
+#define read_lock(lock)                _raw_read_lock(lock)
+
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
+
+#define read_lock_irqsave(lock, flags)                 \
+       do {                                            \
+               typecheck(unsigned long, flags);        \
+               flags = _raw_read_lock_irqsave(lock);   \
+       } while (0)
+#define write_lock_irqsave(lock, flags)                        \
+       do {                                            \
+               typecheck(unsigned long, flags);        \
+               flags = _raw_write_lock_irqsave(lock);  \
+       } while (0)
+
+#else
+
+#define read_lock_irqsave(lock, flags)                 \
+       do {                                            \
+               typecheck(unsigned long, flags);        \
+               _raw_read_lock_irqsave(lock, flags);    \
+       } while (0)
+#define write_lock_irqsave(lock, flags)                        \
+       do {                                            \
+               typecheck(unsigned long, flags);        \
+               _raw_write_lock_irqsave(lock, flags);   \
+       } while (0)
+
+#endif
+
+#define read_lock_irq(lock)            _raw_read_lock_irq(lock)
+#define read_lock_bh(lock)             _raw_read_lock_bh(lock)
+#define write_lock_irq(lock)           _raw_write_lock_irq(lock)
+#define write_lock_bh(lock)            _raw_write_lock_bh(lock)
+#define read_unlock(lock)              _raw_read_unlock(lock)
+#define write_unlock(lock)             _raw_write_unlock(lock)
+#define read_unlock_irq(lock)          _raw_read_unlock_irq(lock)
+#define write_unlock_irq(lock)         _raw_write_unlock_irq(lock)
+
+#define read_unlock_irqrestore(lock, flags)                    \
+       do {                                                    \
+               typecheck(unsigned long, flags);                \
+               _raw_read_unlock_irqrestore(lock, flags);       \
+       } while (0)
+#define read_unlock_bh(lock)           _raw_read_unlock_bh(lock)
+
+#define write_unlock_irqrestore(lock, flags)           \
+       do {                                            \
+               typecheck(unsigned long, flags);        \
+               _raw_write_unlock_irqrestore(lock, flags);      \
+       } while (0)
+#define write_unlock_bh(lock)          _raw_write_unlock_bh(lock)
+
+#define write_trylock_irqsave(lock, flags) \
+({ \
+       local_irq_save(flags); \
+       write_trylock(lock) ? \
+       1 : ({ local_irq_restore(flags); 0; }); \
+})
+
+#endif /* __LINUX_RWLOCK_H */
diff --git a/include/linux/rwlock_api_smp.h b/include/linux/rwlock_api_smp.h
new file mode 100644 (file)
index 0000000..9c9f049
--- /dev/null
@@ -0,0 +1,282 @@
+#ifndef __LINUX_RWLOCK_API_SMP_H
+#define __LINUX_RWLOCK_API_SMP_H
+
+#ifndef __LINUX_SPINLOCK_API_SMP_H
+# error "please don't include this file directly"
+#endif
+
+/*
+ * include/linux/rwlock_api_smp.h
+ *
+ * spinlock API declarations on SMP (and debug)
+ * (implemented in kernel/spinlock.c)
+ *
+ * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
+ * Released under the General Public License (GPL).
+ */
+
+void __lockfunc _raw_read_lock(rwlock_t *lock)         __acquires(lock);
+void __lockfunc _raw_write_lock(rwlock_t *lock)                __acquires(lock);
+void __lockfunc _raw_read_lock_bh(rwlock_t *lock)      __acquires(lock);
+void __lockfunc _raw_write_lock_bh(rwlock_t *lock)     __acquires(lock);
+void __lockfunc _raw_read_lock_irq(rwlock_t *lock)     __acquires(lock);
+void __lockfunc _raw_write_lock_irq(rwlock_t *lock)    __acquires(lock);
+unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock)
+                                                       __acquires(lock);
+unsigned long __lockfunc _raw_write_lock_irqsave(rwlock_t *lock)
+                                                       __acquires(lock);
+int __lockfunc _raw_read_trylock(rwlock_t *lock);
+int __lockfunc _raw_write_trylock(rwlock_t *lock);
+void __lockfunc _raw_read_unlock(rwlock_t *lock)       __releases(lock);
+void __lockfunc _raw_write_unlock(rwlock_t *lock)      __releases(lock);
+void __lockfunc _raw_read_unlock_bh(rwlock_t *lock)    __releases(lock);
+void __lockfunc _raw_write_unlock_bh(rwlock_t *lock)   __releases(lock);
+void __lockfunc _raw_read_unlock_irq(rwlock_t *lock)   __releases(lock);
+void __lockfunc _raw_write_unlock_irq(rwlock_t *lock)  __releases(lock);
+void __lockfunc
+_raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
+                                                       __releases(lock);
+void __lockfunc
+_raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
+                                                       __releases(lock);
+
+#ifdef CONFIG_INLINE_READ_LOCK
+#define _raw_read_lock(lock) __raw_read_lock(lock)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_LOCK
+#define _raw_write_lock(lock) __raw_write_lock(lock)
+#endif
+
+#ifdef CONFIG_INLINE_READ_LOCK_BH
+#define _raw_read_lock_bh(lock) __raw_read_lock_bh(lock)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_LOCK_BH
+#define _raw_write_lock_bh(lock) __raw_write_lock_bh(lock)
+#endif
+
+#ifdef CONFIG_INLINE_READ_LOCK_IRQ
+#define _raw_read_lock_irq(lock) __raw_read_lock_irq(lock)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_LOCK_IRQ
+#define _raw_write_lock_irq(lock) __raw_write_lock_irq(lock)
+#endif
+
+#ifdef CONFIG_INLINE_READ_LOCK_IRQSAVE
+#define _raw_read_lock_irqsave(lock) __raw_read_lock_irqsave(lock)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_LOCK_IRQSAVE
+#define _raw_write_lock_irqsave(lock) __raw_write_lock_irqsave(lock)
+#endif
+
+#ifdef CONFIG_INLINE_READ_TRYLOCK
+#define _raw_read_trylock(lock) __raw_read_trylock(lock)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_TRYLOCK
+#define _raw_write_trylock(lock) __raw_write_trylock(lock)
+#endif
+
+#ifdef CONFIG_INLINE_READ_UNLOCK
+#define _raw_read_unlock(lock) __raw_read_unlock(lock)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_UNLOCK
+#define _raw_write_unlock(lock) __raw_write_unlock(lock)
+#endif
+
+#ifdef CONFIG_INLINE_READ_UNLOCK_BH
+#define _raw_read_unlock_bh(lock) __raw_read_unlock_bh(lock)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_UNLOCK_BH
+#define _raw_write_unlock_bh(lock) __raw_write_unlock_bh(lock)
+#endif
+
+#ifdef CONFIG_INLINE_READ_UNLOCK_IRQ
+#define _raw_read_unlock_irq(lock) __raw_read_unlock_irq(lock)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_UNLOCK_IRQ
+#define _raw_write_unlock_irq(lock) __raw_write_unlock_irq(lock)
+#endif
+
+#ifdef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE
+#define _raw_read_unlock_irqrestore(lock, flags) \
+       __raw_read_unlock_irqrestore(lock, flags)
+#endif
+
+#ifdef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE
+#define _raw_write_unlock_irqrestore(lock, flags) \
+       __raw_write_unlock_irqrestore(lock, flags)
+#endif
+
+static inline int __raw_read_trylock(rwlock_t *lock)
+{
+       preempt_disable();
+       if (do_raw_read_trylock(lock)) {
+               rwlock_acquire_read(&lock->dep_map, 0, 1, _RET_IP_);
+               return 1;
+       }
+       preempt_enable();
+       return 0;
+}
+
+static inline int __raw_write_trylock(rwlock_t *lock)
+{
+       preempt_disable();
+       if (do_raw_write_trylock(lock)) {
+               rwlock_acquire(&lock->dep_map, 0, 1, _RET_IP_);
+               return 1;
+       }
+       preempt_enable();
+       return 0;
+}
+
+/*
+ * If lockdep is enabled then we use the non-preemption spin-ops
+ * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are
+ * not re-enabled during lock-acquire (which the preempt-spin-ops do):
+ */
+#if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC)
+
+static inline void __raw_read_lock(rwlock_t *lock)
+{
+       preempt_disable();
+       rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
+       LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock);
+}
+
+static inline unsigned long __raw_read_lock_irqsave(rwlock_t *lock)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       preempt_disable();
+       rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
+       LOCK_CONTENDED_FLAGS(lock, do_raw_read_trylock, do_raw_read_lock,
+                            do_raw_read_lock_flags, &flags);
+       return flags;
+}
+
+static inline void __raw_read_lock_irq(rwlock_t *lock)
+{
+       local_irq_disable();
+       preempt_disable();
+       rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
+       LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock);
+}
+
+static inline void __raw_read_lock_bh(rwlock_t *lock)
+{
+       local_bh_disable();
+       preempt_disable();
+       rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
+       LOCK_CONTENDED(lock, do_raw_read_trylock, do_raw_read_lock);
+}
+
+static inline unsigned long __raw_write_lock_irqsave(rwlock_t *lock)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       preempt_disable();
+       rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
+       LOCK_CONTENDED_FLAGS(lock, do_raw_write_trylock, do_raw_write_lock,
+                            do_raw_write_lock_flags, &flags);
+       return flags;
+}
+
+static inline void __raw_write_lock_irq(rwlock_t *lock)
+{
+       local_irq_disable();
+       preempt_disable();
+       rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
+       LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);
+}
+
+static inline void __raw_write_lock_bh(rwlock_t *lock)
+{
+       local_bh_disable();
+       preempt_disable();
+       rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
+       LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);
+}
+
+static inline void __raw_write_lock(rwlock_t *lock)
+{
+       preempt_disable();
+       rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
+       LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock);
+}
+
+#endif /* CONFIG_PREEMPT */
+
+static inline void __raw_write_unlock(rwlock_t *lock)
+{
+       rwlock_release(&lock->dep_map, 1, _RET_IP_);
+       do_raw_write_unlock(lock);
+       preempt_enable();
+}
+
+static inline void __raw_read_unlock(rwlock_t *lock)
+{
+       rwlock_release(&lock->dep_map, 1, _RET_IP_);
+       do_raw_read_unlock(lock);
+       preempt_enable();
+}
+
+static inline void
+__raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
+{
+       rwlock_release(&lock->dep_map, 1, _RET_IP_);
+       do_raw_read_unlock(lock);
+       local_irq_restore(flags);
+       preempt_enable();
+}
+
+static inline void __raw_read_unlock_irq(rwlock_t *lock)
+{
+       rwlock_release(&lock->dep_map, 1, _RET_IP_);
+       do_raw_read_unlock(lock);
+       local_irq_enable();
+       preempt_enable();
+}
+
+static inline void __raw_read_unlock_bh(rwlock_t *lock)
+{
+       rwlock_release(&lock->dep_map, 1, _RET_IP_);
+       do_raw_read_unlock(lock);
+       preempt_enable_no_resched();
+       local_bh_enable_ip((unsigned long)__builtin_return_address(0));
+}
+
+static inline void __raw_write_unlock_irqrestore(rwlock_t *lock,
+                                            unsigned long flags)
+{
+       rwlock_release(&lock->dep_map, 1, _RET_IP_);
+       do_raw_write_unlock(lock);
+       local_irq_restore(flags);
+       preempt_enable();
+}
+
+static inline void __raw_write_unlock_irq(rwlock_t *lock)
+{
+       rwlock_release(&lock->dep_map, 1, _RET_IP_);
+       do_raw_write_unlock(lock);
+       local_irq_enable();
+       preempt_enable();
+}
+
+static inline void __raw_write_unlock_bh(rwlock_t *lock)
+{
+       rwlock_release(&lock->dep_map, 1, _RET_IP_);
+       do_raw_write_unlock(lock);
+       preempt_enable_no_resched();
+       local_bh_enable_ip((unsigned long)__builtin_return_address(0));
+}
+
+#endif /* __LINUX_RWLOCK_API_SMP_H */
diff --git a/include/linux/rwlock_types.h b/include/linux/rwlock_types.h
new file mode 100644 (file)
index 0000000..bd31808
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef __LINUX_RWLOCK_TYPES_H
+#define __LINUX_RWLOCK_TYPES_H
+
+/*
+ * include/linux/rwlock_types.h - generic rwlock type definitions
+ *                               and initializers
+ *
+ * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
+ * Released under the General Public License (GPL).
+ */
+typedef struct {
+       arch_rwlock_t raw_lock;
+#ifdef CONFIG_GENERIC_LOCKBREAK
+       unsigned int break_lock;
+#endif
+#ifdef CONFIG_DEBUG_SPINLOCK
+       unsigned int magic, owner_cpu;
+       void *owner;
+#endif
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+       struct lockdep_map dep_map;
+#endif
+} rwlock_t;
+
+#define RWLOCK_MAGIC           0xdeaf1eed
+
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+# define RW_DEP_MAP_INIT(lockname)     .dep_map = { .name = #lockname }
+#else
+# define RW_DEP_MAP_INIT(lockname)
+#endif
+
+#ifdef CONFIG_DEBUG_SPINLOCK
+#define __RW_LOCK_UNLOCKED(lockname)                                   \
+       (rwlock_t)      {       .raw_lock = __ARCH_RW_LOCK_UNLOCKED,    \
+                               .magic = RWLOCK_MAGIC,                  \
+                               .owner = SPINLOCK_OWNER_INIT,           \
+                               .owner_cpu = -1,                        \
+                               RW_DEP_MAP_INIT(lockname) }
+#else
+#define __RW_LOCK_UNLOCKED(lockname) \
+       (rwlock_t)      {       .raw_lock = __ARCH_RW_LOCK_UNLOCKED,    \
+                               RW_DEP_MAP_INIT(lockname) }
+#endif
+
+/*
+ * RW_LOCK_UNLOCKED defeat lockdep state tracking and is hence
+ * deprecated.
+ *
+ * Please use DEFINE_RWLOCK() or __RW_LOCK_UNLOCKED() as appropriate.
+ */
+#define RW_LOCK_UNLOCKED       __RW_LOCK_UNLOCKED(old_style_rw_init)
+
+#define DEFINE_RWLOCK(x)       rwlock_t x = __RW_LOCK_UNLOCKED(x)
+
+#endif /* __LINUX_RWLOCK_TYPES_H */
index 6c3c0f6c261f456ae3b5058cc6a2bcfea200f9a9..bdfcc2527970d04ed2e3b3ee773519075d2da23a 100644 (file)
@@ -68,11 +68,7 @@ extern int __down_write_trylock(struct rw_semaphore *sem);
 extern void __up_read(struct rw_semaphore *sem);
 extern void __up_write(struct rw_semaphore *sem);
 extern void __downgrade_write(struct rw_semaphore *sem);
-
-static inline int rwsem_is_locked(struct rw_semaphore *sem)
-{
-       return (sem->activity != 0);
-}
+extern int rwsem_is_locked(struct rw_semaphore *sem);
 
 #endif /* __KERNEL__ */
 #endif /* _LINUX_RWSEM_SPINLOCK_H */
index 294eb2f8014411540d7be6cf233cd78b1391d5ef..f2f842db03cea4e1d082f6d45596ba3c3c52e1a1 100644 (file)
@@ -192,6 +192,12 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
 #define TASK_DEAD              64
 #define TASK_WAKEKILL          128
 #define TASK_WAKING            256
+#define TASK_STATE_MAX         512
+
+#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW"
+
+extern char ___assert_task_state[1 - 2*!!(
+               sizeof(TASK_STATE_TO_CHAR_STR)-1 != ilog2(TASK_STATE_MAX)+1)];
 
 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE          (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
@@ -1091,7 +1097,8 @@ struct sched_class {
                              enum cpu_idle_type idle);
        void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
        void (*post_schedule) (struct rq *this_rq);
-       void (*task_wake_up) (struct rq *this_rq, struct task_struct *task);
+       void (*task_waking) (struct rq *this_rq, struct task_struct *task);
+       void (*task_woken) (struct rq *this_rq, struct task_struct *task);
 
        void (*set_cpus_allowed)(struct task_struct *p,
                                 const struct cpumask *newmask);
@@ -1115,7 +1122,7 @@ struct sched_class {
                                         struct task_struct *task);
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
-       void (*moved_group) (struct task_struct *p);
+       void (*moved_group) (struct task_struct *p, int on_rq);
 #endif
 };
 
@@ -1409,7 +1416,7 @@ struct task_struct {
 #endif
 
        /* Protection of the PI data structures: */
-       spinlock_t pi_lock;
+       raw_spinlock_t pi_lock;
 
 #ifdef CONFIG_RT_MUTEXES
        /* PI waiters blocked on a rt_mutex held by this task */
@@ -1542,10 +1549,18 @@ struct task_struct {
        unsigned long trace_recursion;
 #endif /* CONFIG_TRACING */
        unsigned long stack_start;
+#ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */
+       struct memcg_batch_info {
+               int do_batch;   /* incremented when batch uncharge started */
+               struct mem_cgroup *memcg; /* target memcg of uncharge */
+               unsigned long bytes;            /* uncharged usage */
+               unsigned long memsw_bytes; /* uncharged mem+swap usage */
+       } memcg_batch;
+#endif
 };
 
 /* Future-safe accessor for struct task_struct's cpus_allowed. */
-#define tsk_cpumask(tsk) (&(tsk)->cpus_allowed)
+#define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
 
 /*
  * Priority of a process goes from 0..MAX_PRIO-1, valid RT
@@ -2073,7 +2088,6 @@ extern int kill_proc_info(int, struct siginfo *, pid_t);
 extern int do_notify_parent(struct task_struct *, int);
 extern void __wake_up_parent(struct task_struct *p, struct task_struct *parent);
 extern void force_sig(int, struct task_struct *);
-extern void force_sig_specific(int, struct task_struct *);
 extern int send_sig(int, struct task_struct *, int);
 extern void zap_other_threads(struct task_struct *p);
 extern struct sigqueue *sigqueue_alloc(void);
@@ -2092,11 +2106,6 @@ static inline int kill_cad_pid(int sig, int priv)
 #define SEND_SIG_PRIV  ((struct siginfo *) 1)
 #define SEND_SIG_FORCED        ((struct siginfo *) 2)
 
-static inline int is_si_special(const struct siginfo *info)
-{
-       return info <= SEND_SIG_FORCED;
-}
-
 /*
  * True if we are on the alternate signal stack.
  */
@@ -2592,8 +2601,6 @@ static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
 }
 #endif /* CONFIG_MM_OWNER */
 
-#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
-
 #endif /* __KERNEL__ */
 
 #endif
index 466cbadbd1efe1b5daa543d7bb99dd91d39aab08..2c627d361c023570a881b0b19adb509beadd2552 100644 (file)
@@ -95,8 +95,13 @@ struct seq_file;
 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
 extern int cap_netlink_recv(struct sk_buff *skb, int cap);
 
+#ifdef CONFIG_MMU
 extern unsigned long mmap_min_addr;
 extern unsigned long dac_mmap_min_addr;
+#else
+#define dac_mmap_min_addr      0UL
+#endif
+
 /*
  * Values used in the task_security_ops calls
  */
@@ -121,6 +126,7 @@ struct request_sock;
 #define LSM_UNSAFE_PTRACE      2
 #define LSM_UNSAFE_PTRACE_CAP  4
 
+#ifdef CONFIG_MMU
 /*
  * If a hint addr is less than mmap_min_addr change hint to be as
  * low as possible but still greater than mmap_min_addr
@@ -135,6 +141,7 @@ static inline unsigned long round_hint_to_min(unsigned long hint)
 }
 extern int mmap_min_addr_handler(struct ctl_table *table, int write,
                                 void __user *buffer, size_t *lenp, loff_t *ppos);
+#endif
 
 #ifdef CONFIG_SECURITY
 
index 1b191c176bcd33ecfe5f16d41ff53376635e52c0..8a4adbef8a0fd65b13964b780418b6d7dd84c154 100644 (file)
@@ -86,6 +86,7 @@ struct task_struct;
 struct sem {
        int     semval;         /* current value */
        int     sempid;         /* pid of last operation */
+       struct list_head sem_pending; /* pending single-sop operations */
 };
 
 /* One sem_array data structure for each set of semaphores in the system. */
@@ -96,11 +97,13 @@ struct sem_array {
        struct sem              *sem_base;      /* ptr to first semaphore in array */
        struct list_head        sem_pending;    /* pending operations to be processed */
        struct list_head        list_id;        /* undo requests on this array */
-       unsigned long           sem_nsems;      /* no. of semaphores in array */
+       int                     sem_nsems;      /* no. of semaphores in array */
+       int                     complex_count;  /* pending complex operations */
 };
 
 /* One queue for each sleeping process in the system. */
 struct sem_queue {
+       struct list_head        simple_list; /* queue of pending operations */
        struct list_head        list;    /* queue of pending operations */
        struct task_struct      *sleeper; /* this process */
        struct sem_undo         *undo;   /* undo structure */
index deee7afd8d660865e1fb9e3bff044cef5cc4e30b..e164291fb3e7562307cb8d0f5e51984eeb934bcc 100644 (file)
@@ -41,20 +41,4 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
 extern int init_tmpfs(void);
 extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
 
-#ifdef CONFIG_TMPFS_POSIX_ACL
-int shmem_check_acl(struct inode *, int);
-int shmem_acl_init(struct inode *, struct inode *);
-
-extern struct xattr_handler shmem_xattr_acl_access_handler;
-extern struct xattr_handler shmem_xattr_acl_default_handler;
-
-extern struct generic_acl_operations shmem_acl_ops;
-
-#else
-static inline int shmem_acl_init(struct inode *inode, struct inode *dir)
-{
-       return 0;
-}
-#endif  /* CONFIG_TMPFS_POSIX_ACL */
-
 #endif
index d53642d2d8992d33e234d4f24f7dbe366d86cab7..67ed2c54283164081a2f7b1b6bd7e48115d9b15b 100644 (file)
@@ -31,6 +31,8 @@
 #define SM501_SYSCTRL_PCI_SUBSYS_LOCK  (1<<11)
 #define SM501_SYSCTRL_PCI_BURST_READ_EN        (1<<15)
 
+#define SM501_SYSCTRL_2D_ENGINE_STATUS (1<<19)
+
 /* miscellaneous control */
 
 #define SM501_MISC_CONTROL             (0x000004)
index 34c4475ac4a201767392bca52f642a17a6000860..4f95c1aac2fde62b3ddb6294d836243a23119146 100644 (file)
 #define SONYPI_EVENT_VOLUME_INC_PRESSED                69
 #define SONYPI_EVENT_VOLUME_DEC_PRESSED                70
 #define SONYPI_EVENT_BRIGHTNESS_PRESSED                71
+#define SONYPI_EVENT_MEDIA_PRESSED             72
 
 /* get/set brightness */
 #define SONYPI_IOCGBRT         _IOR('v', 0, __u8)
diff --git a/include/linux/spi/dw_spi.h b/include/linux/spi/dw_spi.h
new file mode 100644 (file)
index 0000000..51b3e77
--- /dev/null
@@ -0,0 +1,212 @@
+#ifndef DW_SPI_HEADER_H
+#define DW_SPI_HEADER_H
+#include <linux/io.h>
+
+/* Bit fields in CTRLR0 */
+#define SPI_DFS_OFFSET                 0
+
+#define SPI_FRF_OFFSET                 4
+#define SPI_FRF_SPI                    0x0
+#define SPI_FRF_SSP                    0x1
+#define SPI_FRF_MICROWIRE              0x2
+#define SPI_FRF_RESV                   0x3
+
+#define SPI_MODE_OFFSET                        6
+#define SPI_SCPH_OFFSET                        6
+#define SPI_SCOL_OFFSET                        7
+#define SPI_TMOD_OFFSET                        8
+#define        SPI_TMOD_TR                     0x0             /* xmit & recv */
+#define SPI_TMOD_TO                    0x1             /* xmit only */
+#define SPI_TMOD_RO                    0x2             /* recv only */
+#define SPI_TMOD_EPROMREAD             0x3             /* eeprom read mode */
+
+#define SPI_SLVOE_OFFSET               10
+#define SPI_SRL_OFFSET                 11
+#define SPI_CFS_OFFSET                 12
+
+/* Bit fields in SR, 7 bits */
+#define SR_MASK                                0x7f            /* cover 7 bits */
+#define SR_BUSY                                (1 << 0)
+#define SR_TF_NOT_FULL                 (1 << 1)
+#define SR_TF_EMPT                     (1 << 2)
+#define SR_RF_NOT_EMPT                 (1 << 3)
+#define SR_RF_FULL                     (1 << 4)
+#define SR_TX_ERR                      (1 << 5)
+#define SR_DCOL                                (1 << 6)
+
+/* Bit fields in ISR, IMR, RISR, 7 bits */
+#define SPI_INT_TXEI                   (1 << 0)
+#define SPI_INT_TXOI                   (1 << 1)
+#define SPI_INT_RXUI                   (1 << 2)
+#define SPI_INT_RXOI                   (1 << 3)
+#define SPI_INT_RXFI                   (1 << 4)
+#define SPI_INT_MSTI                   (1 << 5)
+
+/* TX RX interrupt level threshhold, max can be 256 */
+#define SPI_INT_THRESHOLD              32
+
+enum dw_ssi_type {
+       SSI_MOTO_SPI = 0,
+       SSI_TI_SSP,
+       SSI_NS_MICROWIRE,
+};
+
+struct dw_spi_reg {
+       u32     ctrl0;
+       u32     ctrl1;
+       u32     ssienr;
+       u32     mwcr;
+       u32     ser;
+       u32     baudr;
+       u32     txfltr;
+       u32     rxfltr;
+       u32     txflr;
+       u32     rxflr;
+       u32     sr;
+       u32     imr;
+       u32     isr;
+       u32     risr;
+       u32     txoicr;
+       u32     rxoicr;
+       u32     rxuicr;
+       u32     msticr;
+       u32     icr;
+       u32     dmacr;
+       u32     dmatdlr;
+       u32     dmardlr;
+       u32     idr;
+       u32     version;
+       u32     dr;             /* Currently oper as 32 bits,
+                               though only low 16 bits matters */
+} __packed;
+
+struct dw_spi {
+       struct spi_master       *master;
+       struct spi_device       *cur_dev;
+       struct device           *parent_dev;
+       enum dw_ssi_type        type;
+
+       void __iomem            *regs;
+       unsigned long           paddr;
+       u32                     iolen;
+       int                     irq;
+       u32                     max_freq;       /* max bus freq supported */
+
+       u16                     bus_num;
+       u16                     num_cs;         /* supported slave numbers */
+
+       /* Driver message queue */
+       struct workqueue_struct *workqueue;
+       struct work_struct      pump_messages;
+       spinlock_t              lock;
+       struct list_head        queue;
+       int                     busy;
+       int                     run;
+
+       /* Message Transfer pump */
+       struct tasklet_struct   pump_transfers;
+
+       /* Current message transfer state info */
+       struct spi_message      *cur_msg;
+       struct spi_transfer     *cur_transfer;
+       struct chip_data        *cur_chip;
+       struct chip_data        *prev_chip;
+       size_t                  len;
+       void                    *tx;
+       void                    *tx_end;
+       void                    *rx;
+       void                    *rx_end;
+       int                     dma_mapped;
+       dma_addr_t              rx_dma;
+       dma_addr_t              tx_dma;
+       size_t                  rx_map_len;
+       size_t                  tx_map_len;
+       u8                      n_bytes;        /* current is a 1/2 bytes op */
+       u8                      max_bits_per_word;      /* maxim is 16b */
+       u32                     dma_width;
+       int                     cs_change;
+       int                     (*write)(struct dw_spi *dws);
+       int                     (*read)(struct dw_spi *dws);
+       irqreturn_t             (*transfer_handler)(struct dw_spi *dws);
+       void                    (*cs_control)(u32 command);
+
+       /* Dma info */
+       int                     dma_inited;
+       struct dma_chan         *txchan;
+       struct dma_chan         *rxchan;
+       int                     txdma_done;
+       int                     rxdma_done;
+       u64                     tx_param;
+       u64                     rx_param;
+       struct device           *dma_dev;
+       dma_addr_t              dma_addr;
+
+       /* Bus interface info */
+       void                    *priv;
+#ifdef CONFIG_DEBUG_FS
+       struct dentry *debugfs;
+#endif
+};
+
+#define dw_readl(dw, name) \
+       __raw_readl(&(((struct dw_spi_reg *)dw->regs)->name))
+#define dw_writel(dw, name, val) \
+       __raw_writel((val), &(((struct dw_spi_reg *)dw->regs)->name))
+#define dw_readw(dw, name) \
+       __raw_readw(&(((struct dw_spi_reg *)dw->regs)->name))
+#define dw_writew(dw, name, val) \
+       __raw_writew((val), &(((struct dw_spi_reg *)dw->regs)->name))
+
+static inline void spi_enable_chip(struct dw_spi *dws, int enable)
+{
+       dw_writel(dws, ssienr, (enable ? 1 : 0));
+}
+
+static inline void spi_set_clk(struct dw_spi *dws, u16 div)
+{
+       dw_writel(dws, baudr, div);
+}
+
+static inline void spi_chip_sel(struct dw_spi *dws, u16 cs)
+{
+       if (cs > dws->num_cs)
+               return;
+       dw_writel(dws, ser, 1 << cs);
+}
+
+/* Disable IRQ bits */
+static inline void spi_mask_intr(struct dw_spi *dws, u32 mask)
+{
+       u32 new_mask;
+
+       new_mask = dw_readl(dws, imr) & ~mask;
+       dw_writel(dws, imr, new_mask);
+}
+
+/* Enable IRQ bits */
+static inline void spi_umask_intr(struct dw_spi *dws, u32 mask)
+{
+       u32 new_mask;
+
+       new_mask = dw_readl(dws, imr) | mask;
+       dw_writel(dws, imr, new_mask);
+}
+
+/*
+ * Each SPI slave device to work with dw_api controller should
+ * has such a structure claiming its working mode (PIO/DMA etc),
+ * which can be save in the "controller_data" member of the
+ * struct spi_device
+ */
+struct dw_spi_chip {
+       u8 poll_mode;   /* 0 for contoller polling mode */
+       u8 type;        /* SPI/SSP/Micrwire */
+       u8 enable_dma;
+       void (*cs_control)(u32 command);
+};
+
+extern int dw_spi_add_host(struct dw_spi *dws);
+extern void dw_spi_remove_host(struct dw_spi *dws);
+extern int dw_spi_suspend_host(struct dw_spi *dws);
+extern int dw_spi_resume_host(struct dw_spi *dws);
+#endif /* DW_SPI_HEADER_H */
index 71dccfeb0d88de34d2a84ed34d2e587e17a11616..86088213334a48d3a0617d59af49af1610ecb2db 100644 (file)
@@ -8,13 +8,13 @@
  *
  * on SMP builds:
  *
- *  asm/spinlock_types.h: contains the raw_spinlock_t/raw_rwlock_t and the
+ *  asm/spinlock_types.h: contains the arch_spinlock_t/arch_rwlock_t and the
  *                        initializers
  *
  *  linux/spinlock_types.h:
  *                        defines the generic type and initializers
  *
- *  asm/spinlock.h:       contains the __raw_spin_*()/etc. lowlevel
+ *  asm/spinlock.h:       contains the arch_spin_*()/etc. lowlevel
  *                        implementations, mostly inline assembly code
  *
  *   (also included on UP-debug builds:)
@@ -34,7 +34,7 @@
  *                        defines the generic type and initializers
  *
  *  linux/spinlock_up.h:
- *                        contains the __raw_spin_*()/etc. version of UP
+ *                        contains the arch_spin_*()/etc. version of UP
  *                        builds. (which are NOPs on non-debug, non-preempt
  *                        builds)
  *
 #define __lockfunc __attribute__((section(".spinlock.text")))
 
 /*
- * Pull the raw_spinlock_t and raw_rwlock_t definitions:
+ * Pull the arch_spinlock_t and arch_rwlock_t definitions:
  */
 #include <linux/spinlock_types.h>
 
 /*
- * Pull the __raw*() functions/declarations (UP-nondebug doesnt need them):
+ * Pull the arch_spin*() functions/declarations (UP-nondebug doesnt need them):
  */
 #ifdef CONFIG_SMP
 # include <asm/spinlock.h>
 #endif
 
 #ifdef CONFIG_DEBUG_SPINLOCK
-  extern void __spin_lock_init(spinlock_t *lock, const char *name,
-                              struct lock_class_key *key);
-# define spin_lock_init(lock)                                  \
+  extern void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
+                                  struct lock_class_key *key);
+# define raw_spin_lock_init(lock)                              \
 do {                                                           \
        static struct lock_class_key __key;                     \
                                                                \
-       __spin_lock_init((lock), #lock, &__key);                \
+       __raw_spin_lock_init((lock), #lock, &__key);            \
 } while (0)
 
 #else
-# define spin_lock_init(lock)                                  \
-       do { *(lock) = __SPIN_LOCK_UNLOCKED(lock); } while (0)
+# define raw_spin_lock_init(lock)                              \
+       do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)
 #endif
 
-#ifdef CONFIG_DEBUG_SPINLOCK
-  extern void __rwlock_init(rwlock_t *lock, const char *name,
-                           struct lock_class_key *key);
-# define rwlock_init(lock)                                     \
-do {                                                           \
-       static struct lock_class_key __key;                     \
-                                                               \
-       __rwlock_init((lock), #lock, &__key);                   \
-} while (0)
-#else
-# define rwlock_init(lock)                                     \
-       do { *(lock) = __RW_LOCK_UNLOCKED(lock); } while (0)
-#endif
-
-#define spin_is_locked(lock)   __raw_spin_is_locked(&(lock)->raw_lock)
+#define raw_spin_is_locked(lock)       arch_spin_is_locked(&(lock)->raw_lock)
 
 #ifdef CONFIG_GENERIC_LOCKBREAK
-#define spin_is_contended(lock) ((lock)->break_lock)
+#define raw_spin_is_contended(lock) ((lock)->break_lock)
 #else
 
-#ifdef __raw_spin_is_contended
-#define spin_is_contended(lock)        __raw_spin_is_contended(&(lock)->raw_lock)
+#ifdef arch_spin_is_contended
+#define raw_spin_is_contended(lock)    arch_spin_is_contended(&(lock)->raw_lock)
 #else
-#define spin_is_contended(lock)        (((void)(lock), 0))
-#endif /*__raw_spin_is_contended*/
+#define raw_spin_is_contended(lock)    (((void)(lock), 0))
+#endif /*arch_spin_is_contended*/
 #endif
 
 /* The lock does not imply full memory barrier. */
@@ -136,182 +122,260 @@ static inline void smp_mb__after_lock(void) { smp_mb(); }
 #endif
 
 /**
- * spin_unlock_wait - wait until the spinlock gets unlocked
+ * raw_spin_unlock_wait - wait until the spinlock gets unlocked
  * @lock: the spinlock in question.
  */
-#define spin_unlock_wait(lock) __raw_spin_unlock_wait(&(lock)->raw_lock)
+#define raw_spin_unlock_wait(lock)     arch_spin_unlock_wait(&(lock)->raw_lock)
 
 #ifdef CONFIG_DEBUG_SPINLOCK
- extern void _raw_spin_lock(spinlock_t *lock);
-#define _raw_spin_lock_flags(lock, flags) _raw_spin_lock(lock)
- extern int _raw_spin_trylock(spinlock_t *lock);
- extern void _raw_spin_unlock(spinlock_t *lock);
- extern void _raw_read_lock(rwlock_t *lock);
-#define _raw_read_lock_flags(lock, flags) _raw_read_lock(lock)
- extern int _raw_read_trylock(rwlock_t *lock);
- extern void _raw_read_unlock(rwlock_t *lock);
- extern void _raw_write_lock(rwlock_t *lock);
-#define _raw_write_lock_flags(lock, flags) _raw_write_lock(lock)
- extern int _raw_write_trylock(rwlock_t *lock);
- extern void _raw_write_unlock(rwlock_t *lock);
+ extern void do_raw_spin_lock(raw_spinlock_t *lock);
+#define do_raw_spin_lock_flags(lock, flags) do_raw_spin_lock(lock)
+ extern int do_raw_spin_trylock(raw_spinlock_t *lock);
+ extern void do_raw_spin_unlock(raw_spinlock_t *lock);
 #else
-# define _raw_spin_lock(lock)          __raw_spin_lock(&(lock)->raw_lock)
-# define _raw_spin_lock_flags(lock, flags) \
-               __raw_spin_lock_flags(&(lock)->raw_lock, *(flags))
-# define _raw_spin_trylock(lock)       __raw_spin_trylock(&(lock)->raw_lock)
-# define _raw_spin_unlock(lock)                __raw_spin_unlock(&(lock)->raw_lock)
-# define _raw_read_lock(rwlock)                __raw_read_lock(&(rwlock)->raw_lock)
-# define _raw_read_lock_flags(lock, flags) \
-               __raw_read_lock_flags(&(lock)->raw_lock, *(flags))
-# define _raw_read_trylock(rwlock)     __raw_read_trylock(&(rwlock)->raw_lock)
-# define _raw_read_unlock(rwlock)      __raw_read_unlock(&(rwlock)->raw_lock)
-# define _raw_write_lock(rwlock)       __raw_write_lock(&(rwlock)->raw_lock)
-# define _raw_write_lock_flags(lock, flags) \
-               __raw_write_lock_flags(&(lock)->raw_lock, *(flags))
-# define _raw_write_trylock(rwlock)    __raw_write_trylock(&(rwlock)->raw_lock)
-# define _raw_write_unlock(rwlock)     __raw_write_unlock(&(rwlock)->raw_lock)
+static inline void do_raw_spin_lock(raw_spinlock_t *lock)
+{
+       arch_spin_lock(&lock->raw_lock);
+}
+
+static inline void
+do_raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long *flags)
+{
+       arch_spin_lock_flags(&lock->raw_lock, *flags);
+}
+
+static inline int do_raw_spin_trylock(raw_spinlock_t *lock)
+{
+       return arch_spin_trylock(&(lock)->raw_lock);
+}
+
+static inline void do_raw_spin_unlock(raw_spinlock_t *lock)
+{
+       arch_spin_unlock(&lock->raw_lock);
+}
 #endif
 
-#define read_can_lock(rwlock)          __raw_read_can_lock(&(rwlock)->raw_lock)
-#define write_can_lock(rwlock)         __raw_write_can_lock(&(rwlock)->raw_lock)
-
 /*
- * Define the various spin_lock and rw_lock methods.  Note we define these
- * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various
- * methods are defined as nops in the case they are not required.
+ * Define the various spin_lock methods.  Note we define these
+ * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The
+ * various methods are defined as nops in the case they are not
+ * required.
  */
-#define spin_trylock(lock)             __cond_lock(lock, _spin_trylock(lock))
-#define read_trylock(lock)             __cond_lock(lock, _read_trylock(lock))
-#define write_trylock(lock)            __cond_lock(lock, _write_trylock(lock))
+#define raw_spin_trylock(lock) __cond_lock(lock, _raw_spin_trylock(lock))
 
-#define spin_lock(lock)                        _spin_lock(lock)
+#define raw_spin_lock(lock)    _raw_spin_lock(lock)
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
-# define spin_lock_nested(lock, subclass) _spin_lock_nested(lock, subclass)
-# define spin_lock_nest_lock(lock, nest_lock)                          \
+# define raw_spin_lock_nested(lock, subclass) \
+       _raw_spin_lock_nested(lock, subclass)
+
+# define raw_spin_lock_nest_lock(lock, nest_lock)                      \
         do {                                                           \
                 typecheck(struct lockdep_map *, &(nest_lock)->dep_map);\
-                _spin_lock_nest_lock(lock, &(nest_lock)->dep_map);     \
+                _raw_spin_lock_nest_lock(lock, &(nest_lock)->dep_map); \
         } while (0)
 #else
-# define spin_lock_nested(lock, subclass) _spin_lock(lock)
-# define spin_lock_nest_lock(lock, nest_lock) _spin_lock(lock)
+# define raw_spin_lock_nested(lock, subclass)          _raw_spin_lock(lock)
+# define raw_spin_lock_nest_lock(lock, nest_lock)      _raw_spin_lock(lock)
 #endif
 
-#define write_lock(lock)               _write_lock(lock)
-#define read_lock(lock)                        _read_lock(lock)
-
 #if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
 
-#define spin_lock_irqsave(lock, flags)                 \
+#define raw_spin_lock_irqsave(lock, flags)                     \
        do {                                            \
                typecheck(unsigned long, flags);        \
-               flags = _spin_lock_irqsave(lock);       \
-       } while (0)
-#define read_lock_irqsave(lock, flags)                 \
-       do {                                            \
-               typecheck(unsigned long, flags);        \
-               flags = _read_lock_irqsave(lock);       \
-       } while (0)
-#define write_lock_irqsave(lock, flags)                        \
-       do {                                            \
-               typecheck(unsigned long, flags);        \
-               flags = _write_lock_irqsave(lock);      \
+               flags = _raw_spin_lock_irqsave(lock);   \
        } while (0)
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
-#define spin_lock_irqsave_nested(lock, flags, subclass)                        \
+#define raw_spin_lock_irqsave_nested(lock, flags, subclass)            \
        do {                                                            \
                typecheck(unsigned long, flags);                        \
-               flags = _spin_lock_irqsave_nested(lock, subclass);      \
+               flags = _raw_spin_lock_irqsave_nested(lock, subclass);  \
        } while (0)
 #else
-#define spin_lock_irqsave_nested(lock, flags, subclass)                        \
+#define raw_spin_lock_irqsave_nested(lock, flags, subclass)            \
        do {                                                            \
                typecheck(unsigned long, flags);                        \
-               flags = _spin_lock_irqsave(lock);                       \
+               flags = _raw_spin_lock_irqsave(lock);                   \
        } while (0)
 #endif
 
 #else
 
-#define spin_lock_irqsave(lock, flags)                 \
-       do {                                            \
-               typecheck(unsigned long, flags);        \
-               _spin_lock_irqsave(lock, flags);        \
-       } while (0)
-#define read_lock_irqsave(lock, flags)                 \
-       do {                                            \
-               typecheck(unsigned long, flags);        \
-               _read_lock_irqsave(lock, flags);        \
-       } while (0)
-#define write_lock_irqsave(lock, flags)                        \
+#define raw_spin_lock_irqsave(lock, flags)             \
        do {                                            \
                typecheck(unsigned long, flags);        \
-               _write_lock_irqsave(lock, flags);       \
+               _raw_spin_lock_irqsave(lock, flags);    \
        } while (0)
-#define spin_lock_irqsave_nested(lock, flags, subclass)        \
-       spin_lock_irqsave(lock, flags)
 
-#endif
+#define raw_spin_lock_irqsave_nested(lock, flags, subclass)    \
+       raw_spin_lock_irqsave(lock, flags)
 
-#define spin_lock_irq(lock)            _spin_lock_irq(lock)
-#define spin_lock_bh(lock)             _spin_lock_bh(lock)
-#define read_lock_irq(lock)            _read_lock_irq(lock)
-#define read_lock_bh(lock)             _read_lock_bh(lock)
-#define write_lock_irq(lock)           _write_lock_irq(lock)
-#define write_lock_bh(lock)            _write_lock_bh(lock)
-#define spin_unlock(lock)              _spin_unlock(lock)
-#define read_unlock(lock)              _read_unlock(lock)
-#define write_unlock(lock)             _write_unlock(lock)
-#define spin_unlock_irq(lock)          _spin_unlock_irq(lock)
-#define read_unlock_irq(lock)          _read_unlock_irq(lock)
-#define write_unlock_irq(lock)         _write_unlock_irq(lock)
-
-#define spin_unlock_irqrestore(lock, flags)            \
-       do {                                            \
-               typecheck(unsigned long, flags);        \
-               _spin_unlock_irqrestore(lock, flags);   \
-       } while (0)
-#define spin_unlock_bh(lock)           _spin_unlock_bh(lock)
+#endif
 
-#define read_unlock_irqrestore(lock, flags)            \
-       do {                                            \
-               typecheck(unsigned long, flags);        \
-               _read_unlock_irqrestore(lock, flags);   \
-       } while (0)
-#define read_unlock_bh(lock)           _read_unlock_bh(lock)
+#define raw_spin_lock_irq(lock)                _raw_spin_lock_irq(lock)
+#define raw_spin_lock_bh(lock)         _raw_spin_lock_bh(lock)
+#define raw_spin_unlock(lock)          _raw_spin_unlock(lock)
+#define raw_spin_unlock_irq(lock)      _raw_spin_unlock_irq(lock)
 
-#define write_unlock_irqrestore(lock, flags)           \
-       do {                                            \
-               typecheck(unsigned long, flags);        \
-               _write_unlock_irqrestore(lock, flags);  \
+#define raw_spin_unlock_irqrestore(lock, flags)                \
+       do {                                                    \
+               typecheck(unsigned long, flags);                \
+               _raw_spin_unlock_irqrestore(lock, flags);       \
        } while (0)
-#define write_unlock_bh(lock)          _write_unlock_bh(lock)
+#define raw_spin_unlock_bh(lock)       _raw_spin_unlock_bh(lock)
 
-#define spin_trylock_bh(lock)  __cond_lock(lock, _spin_trylock_bh(lock))
+#define raw_spin_trylock_bh(lock) \
+       __cond_lock(lock, _raw_spin_trylock_bh(lock))
 
-#define spin_trylock_irq(lock) \
+#define raw_spin_trylock_irq(lock) \
 ({ \
        local_irq_disable(); \
-       spin_trylock(lock) ? \
+       raw_spin_trylock(lock) ? \
        1 : ({ local_irq_enable(); 0;  }); \
 })
 
-#define spin_trylock_irqsave(lock, flags) \
+#define raw_spin_trylock_irqsave(lock, flags) \
 ({ \
        local_irq_save(flags); \
-       spin_trylock(lock) ? \
+       raw_spin_trylock(lock) ? \
        1 : ({ local_irq_restore(flags); 0; }); \
 })
 
-#define write_trylock_irqsave(lock, flags) \
-({ \
-       local_irq_save(flags); \
-       write_trylock(lock) ? \
-       1 : ({ local_irq_restore(flags); 0; }); \
+/**
+ * raw_spin_can_lock - would raw_spin_trylock() succeed?
+ * @lock: the spinlock in question.
+ */
+#define raw_spin_can_lock(lock)        (!raw_spin_is_locked(lock))
+
+/* Include rwlock functions */
+#include <linux/rwlock.h>
+
+/*
+ * Pull the _spin_*()/_read_*()/_write_*() functions/declarations:
+ */
+#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
+# include <linux/spinlock_api_smp.h>
+#else
+# include <linux/spinlock_api_up.h>
+#endif
+
+/*
+ * Map the spin_lock functions to the raw variants for PREEMPT_RT=n
+ */
+
+static inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
+{
+       return &lock->rlock;
+}
+
+#define spin_lock_init(_lock)                          \
+do {                                                   \
+       spinlock_check(_lock);                          \
+       raw_spin_lock_init(&(_lock)->rlock);            \
+} while (0)
+
+static inline void spin_lock(spinlock_t *lock)
+{
+       raw_spin_lock(&lock->rlock);
+}
+
+static inline void spin_lock_bh(spinlock_t *lock)
+{
+       raw_spin_lock_bh(&lock->rlock);
+}
+
+static inline int spin_trylock(spinlock_t *lock)
+{
+       return raw_spin_trylock(&lock->rlock);
+}
+
+#define spin_lock_nested(lock, subclass)                       \
+do {                                                           \
+       raw_spin_lock_nested(spinlock_check(lock), subclass);   \
+} while (0)
+
+#define spin_lock_nest_lock(lock, nest_lock)                           \
+do {                                                                   \
+       raw_spin_lock_nest_lock(spinlock_check(lock), nest_lock);       \
+} while (0)
+
+static inline void spin_lock_irq(spinlock_t *lock)
+{
+       raw_spin_lock_irq(&lock->rlock);
+}
+
+#define spin_lock_irqsave(lock, flags)                         \
+do {                                                           \
+       raw_spin_lock_irqsave(spinlock_check(lock), flags);     \
+} while (0)
+
+#define spin_lock_irqsave_nested(lock, flags, subclass)                        \
+do {                                                                   \
+       raw_spin_lock_irqsave_nested(spinlock_check(lock), flags, subclass); \
+} while (0)
+
+static inline void spin_unlock(spinlock_t *lock)
+{
+       raw_spin_unlock(&lock->rlock);
+}
+
+static inline void spin_unlock_bh(spinlock_t *lock)
+{
+       raw_spin_unlock_bh(&lock->rlock);
+}
+
+static inline void spin_unlock_irq(spinlock_t *lock)
+{
+       raw_spin_unlock_irq(&lock->rlock);
+}
+
+static inline void spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
+{
+       raw_spin_unlock_irqrestore(&lock->rlock, flags);
+}
+
+static inline int spin_trylock_bh(spinlock_t *lock)
+{
+       return raw_spin_trylock_bh(&lock->rlock);
+}
+
+static inline int spin_trylock_irq(spinlock_t *lock)
+{
+       return raw_spin_trylock_irq(&lock->rlock);
+}
+
+#define spin_trylock_irqsave(lock, flags)                      \
+({                                                             \
+       raw_spin_trylock_irqsave(spinlock_check(lock), flags); \
 })
 
+static inline void spin_unlock_wait(spinlock_t *lock)
+{
+       raw_spin_unlock_wait(&lock->rlock);
+}
+
+static inline int spin_is_locked(spinlock_t *lock)
+{
+       return raw_spin_is_locked(&lock->rlock);
+}
+
+static inline int spin_is_contended(spinlock_t *lock)
+{
+       return raw_spin_is_contended(&lock->rlock);
+}
+
+static inline int spin_can_lock(spinlock_t *lock)
+{
+       return raw_spin_can_lock(&lock->rlock);
+}
+
+static inline void assert_spin_locked(spinlock_t *lock)
+{
+       assert_raw_spin_locked(&lock->rlock);
+}
+
 /*
  * Pull the atomic_t declaration:
  * (asm-mips/atomic.h needs above definitions)
@@ -329,19 +393,4 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
 #define atomic_dec_and_lock(atomic, lock) \
                __cond_lock(lock, _atomic_dec_and_lock(atomic, lock))
 
-/**
- * spin_can_lock - would spin_trylock() succeed?
- * @lock: the spinlock in question.
- */
-#define spin_can_lock(lock)    (!spin_is_locked(lock))
-
-/*
- * Pull the _spin_*()/_read_*()/_write_*() functions/declarations:
- */
-#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
-# include <linux/spinlock_api_smp.h>
-#else
-# include <linux/spinlock_api_up.h>
-#endif
-
 #endif /* __LINUX_SPINLOCK_H */
index 8264a7f459bc578d5988759c285868a75c0e91e5..e253ccd7a604c83e003a0db3475bd895b752765b 100644 (file)
 
 int in_lock_functions(unsigned long addr);
 
-#define assert_spin_locked(x)  BUG_ON(!spin_is_locked(x))
-
-void __lockfunc _spin_lock(spinlock_t *lock)           __acquires(lock);
-void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass)
-                                                       __acquires(lock);
-void __lockfunc _spin_lock_nest_lock(spinlock_t *lock, struct lockdep_map *map)
-                                                       __acquires(lock);
-void __lockfunc _read_lock(rwlock_t *lock)             __acquires(lock);
-void __lockfunc _write_lock(rwlock_t *lock)            __acquires(lock);
-void __lockfunc _spin_lock_bh(spinlock_t *lock)                __acquires(lock);
-void __lockfunc _read_lock_bh(rwlock_t *lock)          __acquires(lock);
-void __lockfunc _write_lock_bh(rwlock_t *lock)         __acquires(lock);
-void __lockfunc _spin_lock_irq(spinlock_t *lock)       __acquires(lock);
-void __lockfunc _read_lock_irq(rwlock_t *lock)         __acquires(lock);
-void __lockfunc _write_lock_irq(rwlock_t *lock)                __acquires(lock);
-unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock)
-                                                       __acquires(lock);
-unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock, int subclass)
-                                                       __acquires(lock);
-unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock)
-                                                       __acquires(lock);
-unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock)
-                                                       __acquires(lock);
-int __lockfunc _spin_trylock(spinlock_t *lock);
-int __lockfunc _read_trylock(rwlock_t *lock);
-int __lockfunc _write_trylock(rwlock_t *lock);
-int __lockfunc _spin_trylock_bh(spinlock_t *lock);
-void __lockfunc _spin_unlock(spinlock_t *lock)         __releases(lock);
-void __lockfunc _read_unlock(rwlock_t *lock)           __releases(lock);
-void __lockfunc _write_unlock(rwlock_t *lock)          __releases(lock);
-void __lockfunc _spin_unlock_bh(spinlock_t *lock)      __releases(lock);
-void __lockfunc _read_unlock_bh(rwlock_t *lock)                __releases(lock);
-void __lockfunc _write_unlock_bh(rwlock_t *lock)       __releases(lock);
-void __lockfunc _spin_unlock_irq(spinlock_t *lock)     __releases(lock);
-void __lockfunc _read_unlock_irq(rwlock_t *lock)       __releases(lock);
-void __lockfunc _write_unlock_irq(rwlock_t *lock)      __releases(lock);
-void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
-                                                       __releases(lock);
-void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
-                                                       __releases(lock);
-void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
-                                                       __releases(lock);
+#define assert_raw_spin_locked(x)      BUG_ON(!raw_spin_is_locked(x))
+
+void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)           __acquires(lock);
+void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
+                                                               __acquires(lock);
+void __lockfunc
+_raw_spin_lock_nest_lock(raw_spinlock_t *lock, struct lockdep_map *map)
+                                                               __acquires(lock);
+void __lockfunc _raw_spin_lock_bh(raw_spinlock_t *lock)                __acquires(lock);
+void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
+                                                               __acquires(lock);
+
+unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
+                                                               __acquires(lock);
+unsigned long __lockfunc
+_raw_spin_lock_irqsave_nested(raw_spinlock_t *lock, int subclass)
+                                                               __acquires(lock);
+int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock);
+int __lockfunc _raw_spin_trylock_bh(raw_spinlock_t *lock);
+void __lockfunc _raw_spin_unlock(raw_spinlock_t *lock)         __releases(lock);
+void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock)      __releases(lock);
+void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)     __releases(lock);
+void __lockfunc
+_raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
+                                                               __releases(lock);
 
 #ifdef CONFIG_INLINE_SPIN_LOCK
-#define _spin_lock(lock) __spin_lock(lock)
-#endif
-
-#ifdef CONFIG_INLINE_READ_LOCK
-#define _read_lock(lock) __read_lock(lock)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_LOCK
-#define _write_lock(lock) __write_lock(lock)
+#define _raw_spin_lock(lock) __raw_spin_lock(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_LOCK_BH
-#define _spin_lock_bh(lock) __spin_lock_bh(lock)
-#endif
-
-#ifdef CONFIG_INLINE_READ_LOCK_BH
-#define _read_lock_bh(lock) __read_lock_bh(lock)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_LOCK_BH
-#define _write_lock_bh(lock) __write_lock_bh(lock)
+#define _raw_spin_lock_bh(lock) __raw_spin_lock_bh(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_LOCK_IRQ
-#define _spin_lock_irq(lock) __spin_lock_irq(lock)
-#endif
-
-#ifdef CONFIG_INLINE_READ_LOCK_IRQ
-#define _read_lock_irq(lock) __read_lock_irq(lock)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_LOCK_IRQ
-#define _write_lock_irq(lock) __write_lock_irq(lock)
+#define _raw_spin_lock_irq(lock) __raw_spin_lock_irq(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
-#define _spin_lock_irqsave(lock) __spin_lock_irqsave(lock)
-#endif
-
-#ifdef CONFIG_INLINE_READ_LOCK_IRQSAVE
-#define _read_lock_irqsave(lock) __read_lock_irqsave(lock)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_LOCK_IRQSAVE
-#define _write_lock_irqsave(lock) __write_lock_irqsave(lock)
+#define _raw_spin_lock_irqsave(lock) __raw_spin_lock_irqsave(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_TRYLOCK
-#define _spin_trylock(lock) __spin_trylock(lock)
-#endif
-
-#ifdef CONFIG_INLINE_READ_TRYLOCK
-#define _read_trylock(lock) __read_trylock(lock)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_TRYLOCK
-#define _write_trylock(lock) __write_trylock(lock)
+#define _raw_spin_trylock(lock) __raw_spin_trylock(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_TRYLOCK_BH
-#define _spin_trylock_bh(lock) __spin_trylock_bh(lock)
+#define _raw_spin_trylock_bh(lock) __raw_spin_trylock_bh(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_UNLOCK
-#define _spin_unlock(lock) __spin_unlock(lock)
-#endif
-
-#ifdef CONFIG_INLINE_READ_UNLOCK
-#define _read_unlock(lock) __read_unlock(lock)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_UNLOCK
-#define _write_unlock(lock) __write_unlock(lock)
+#define _raw_spin_unlock(lock) __raw_spin_unlock(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_UNLOCK_BH
-#define _spin_unlock_bh(lock) __spin_unlock_bh(lock)
-#endif
-
-#ifdef CONFIG_INLINE_READ_UNLOCK_BH
-#define _read_unlock_bh(lock) __read_unlock_bh(lock)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_UNLOCK_BH
-#define _write_unlock_bh(lock) __write_unlock_bh(lock)
+#define _raw_spin_unlock_bh(lock) __raw_spin_unlock_bh(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQ
-#define _spin_unlock_irq(lock) __spin_unlock_irq(lock)
-#endif
-
-#ifdef CONFIG_INLINE_READ_UNLOCK_IRQ
-#define _read_unlock_irq(lock) __read_unlock_irq(lock)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_UNLOCK_IRQ
-#define _write_unlock_irq(lock) __write_unlock_irq(lock)
+#define _raw_spin_unlock_irq(lock) __raw_spin_unlock_irq(lock)
 #endif
 
 #ifdef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
-#define _spin_unlock_irqrestore(lock, flags) __spin_unlock_irqrestore(lock, flags)
-#endif
-
-#ifdef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE
-#define _read_unlock_irqrestore(lock, flags) __read_unlock_irqrestore(lock, flags)
-#endif
-
-#ifdef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE
-#define _write_unlock_irqrestore(lock, flags) __write_unlock_irqrestore(lock, flags)
+#define _raw_spin_unlock_irqrestore(lock, flags) __raw_spin_unlock_irqrestore(lock, flags)
 #endif
 
-static inline int __spin_trylock(spinlock_t *lock)
+static inline int __raw_spin_trylock(raw_spinlock_t *lock)
 {
        preempt_disable();
-       if (_raw_spin_trylock(lock)) {
+       if (do_raw_spin_trylock(lock)) {
                spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
                return 1;
        }
@@ -183,28 +94,6 @@ static inline int __spin_trylock(spinlock_t *lock)
        return 0;
 }
 
-static inline int __read_trylock(rwlock_t *lock)
-{
-       preempt_disable();
-       if (_raw_read_trylock(lock)) {
-               rwlock_acquire_read(&lock->dep_map, 0, 1, _RET_IP_);
-               return 1;
-       }
-       preempt_enable();
-       return 0;
-}
-
-static inline int __write_trylock(rwlock_t *lock)
-{
-       preempt_disable();
-       if (_raw_write_trylock(lock)) {
-               rwlock_acquire(&lock->dep_map, 0, 1, _RET_IP_);
-               return 1;
-       }
-       preempt_enable();
-       return 0;
-}
-
 /*
  * If lockdep is enabled then we use the non-preemption spin-ops
  * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are
@@ -212,14 +101,7 @@ static inline int __write_trylock(rwlock_t *lock)
  */
 #if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC)
 
-static inline void __read_lock(rwlock_t *lock)
-{
-       preempt_disable();
-       rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock);
-}
-
-static inline unsigned long __spin_lock_irqsave(spinlock_t *lock)
+static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t *lock)
 {
        unsigned long flags;
 
@@ -228,205 +110,79 @@ static inline unsigned long __spin_lock_irqsave(spinlock_t *lock)
        spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
        /*
         * On lockdep we dont want the hand-coded irq-enable of
-        * _raw_spin_lock_flags() code, because lockdep assumes
+        * do_raw_spin_lock_flags() code, because lockdep assumes
         * that interrupts are not re-enabled during lock-acquire:
         */
 #ifdef CONFIG_LOCKDEP
-       LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
+       LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
 #else
-       _raw_spin_lock_flags(lock, &flags);
+       do_raw_spin_lock_flags(lock, &flags);
 #endif
        return flags;
 }
 
-static inline void __spin_lock_irq(spinlock_t *lock)
+static inline void __raw_spin_lock_irq(raw_spinlock_t *lock)
 {
        local_irq_disable();
        preempt_disable();
        spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
+       LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
 }
 
-static inline void __spin_lock_bh(spinlock_t *lock)
+static inline void __raw_spin_lock_bh(raw_spinlock_t *lock)
 {
        local_bh_disable();
        preempt_disable();
        spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
-}
-
-static inline unsigned long __read_lock_irqsave(rwlock_t *lock)
-{
-       unsigned long flags;
-
-       local_irq_save(flags);
-       preempt_disable();
-       rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED_FLAGS(lock, _raw_read_trylock, _raw_read_lock,
-                            _raw_read_lock_flags, &flags);
-       return flags;
-}
-
-static inline void __read_lock_irq(rwlock_t *lock)
-{
-       local_irq_disable();
-       preempt_disable();
-       rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock);
-}
-
-static inline void __read_lock_bh(rwlock_t *lock)
-{
-       local_bh_disable();
-       preempt_disable();
-       rwlock_acquire_read(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_read_trylock, _raw_read_lock);
-}
-
-static inline unsigned long __write_lock_irqsave(rwlock_t *lock)
-{
-       unsigned long flags;
-
-       local_irq_save(flags);
-       preempt_disable();
-       rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED_FLAGS(lock, _raw_write_trylock, _raw_write_lock,
-                            _raw_write_lock_flags, &flags);
-       return flags;
-}
-
-static inline void __write_lock_irq(rwlock_t *lock)
-{
-       local_irq_disable();
-       preempt_disable();
-       rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
+       LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
 }
 
-static inline void __write_lock_bh(rwlock_t *lock)
-{
-       local_bh_disable();
-       preempt_disable();
-       rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
-}
-
-static inline void __spin_lock(spinlock_t *lock)
+static inline void __raw_spin_lock(raw_spinlock_t *lock)
 {
        preempt_disable();
        spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
-}
-
-static inline void __write_lock(rwlock_t *lock)
-{
-       preempt_disable();
-       rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
+       LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
 }
 
 #endif /* CONFIG_PREEMPT */
 
-static inline void __spin_unlock(spinlock_t *lock)
+static inline void __raw_spin_unlock(raw_spinlock_t *lock)
 {
        spin_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_spin_unlock(lock);
-       preempt_enable();
-}
-
-static inline void __write_unlock(rwlock_t *lock)
-{
-       rwlock_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_write_unlock(lock);
-       preempt_enable();
-}
-
-static inline void __read_unlock(rwlock_t *lock)
-{
-       rwlock_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_read_unlock(lock);
+       do_raw_spin_unlock(lock);
        preempt_enable();
 }
 
-static inline void __spin_unlock_irqrestore(spinlock_t *lock,
+static inline void __raw_spin_unlock_irqrestore(raw_spinlock_t *lock,
                                            unsigned long flags)
 {
        spin_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_spin_unlock(lock);
+       do_raw_spin_unlock(lock);
        local_irq_restore(flags);
        preempt_enable();
 }
 
-static inline void __spin_unlock_irq(spinlock_t *lock)
+static inline void __raw_spin_unlock_irq(raw_spinlock_t *lock)
 {
        spin_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_spin_unlock(lock);
+       do_raw_spin_unlock(lock);
        local_irq_enable();
        preempt_enable();
 }
 
-static inline void __spin_unlock_bh(spinlock_t *lock)
+static inline void __raw_spin_unlock_bh(raw_spinlock_t *lock)
 {
        spin_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_spin_unlock(lock);
-       preempt_enable_no_resched();
-       local_bh_enable_ip((unsigned long)__builtin_return_address(0));
-}
-
-static inline void __read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
-{
-       rwlock_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_read_unlock(lock);
-       local_irq_restore(flags);
-       preempt_enable();
-}
-
-static inline void __read_unlock_irq(rwlock_t *lock)
-{
-       rwlock_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_read_unlock(lock);
-       local_irq_enable();
-       preempt_enable();
-}
-
-static inline void __read_unlock_bh(rwlock_t *lock)
-{
-       rwlock_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_read_unlock(lock);
+       do_raw_spin_unlock(lock);
        preempt_enable_no_resched();
        local_bh_enable_ip((unsigned long)__builtin_return_address(0));
 }
 
-static inline void __write_unlock_irqrestore(rwlock_t *lock,
-                                            unsigned long flags)
-{
-       rwlock_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_write_unlock(lock);
-       local_irq_restore(flags);
-       preempt_enable();
-}
-
-static inline void __write_unlock_irq(rwlock_t *lock)
-{
-       rwlock_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_write_unlock(lock);
-       local_irq_enable();
-       preempt_enable();
-}
-
-static inline void __write_unlock_bh(rwlock_t *lock)
-{
-       rwlock_release(&lock->dep_map, 1, _RET_IP_);
-       _raw_write_unlock(lock);
-       preempt_enable_no_resched();
-       local_bh_enable_ip((unsigned long)__builtin_return_address(0));
-}
-
-static inline int __spin_trylock_bh(spinlock_t *lock)
+static inline int __raw_spin_trylock_bh(raw_spinlock_t *lock)
 {
        local_bh_disable();
        preempt_disable();
-       if (_raw_spin_trylock(lock)) {
+       if (do_raw_spin_trylock(lock)) {
                spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
                return 1;
        }
@@ -435,4 +191,6 @@ static inline int __spin_trylock_bh(spinlock_t *lock)
        return 0;
 }
 
+#include <linux/rwlock_api_smp.h>
+
 #endif /* __LINUX_SPINLOCK_API_SMP_H */
index 04e1d3164576eac1a5137b0620da7c1aa1959d89..af1f47229e70292ec2ec63556c4a484f41d4bc18 100644 (file)
@@ -16,7 +16,7 @@
 
 #define in_lock_functions(ADDR)                0
 
-#define assert_spin_locked(lock)       do { (void)(lock); } while (0)
+#define assert_raw_spin_locked(lock)   do { (void)(lock); } while (0)
 
 /*
  * In the UP-nondebug case there's no real locking going on, so the
@@ -40,7 +40,8 @@
   do { preempt_enable(); __release(lock); (void)(lock); } while (0)
 
 #define __UNLOCK_BH(lock) \
-  do { preempt_enable_no_resched(); local_bh_enable(); __release(lock); (void)(lock); } while (0)
+  do { preempt_enable_no_resched(); local_bh_enable(); \
+         __release(lock); (void)(lock); } while (0)
 
 #define __UNLOCK_IRQ(lock) \
   do { local_irq_enable(); __UNLOCK(lock); } while (0)
 #define __UNLOCK_IRQRESTORE(lock, flags) \
   do { local_irq_restore(flags); __UNLOCK(lock); } while (0)
 
-#define _spin_lock(lock)                       __LOCK(lock)
-#define _spin_lock_nested(lock, subclass)      __LOCK(lock)
-#define _read_lock(lock)                       __LOCK(lock)
-#define _write_lock(lock)                      __LOCK(lock)
-#define _spin_lock_bh(lock)                    __LOCK_BH(lock)
-#define _read_lock_bh(lock)                    __LOCK_BH(lock)
-#define _write_lock_bh(lock)                   __LOCK_BH(lock)
-#define _spin_lock_irq(lock)                   __LOCK_IRQ(lock)
-#define _read_lock_irq(lock)                   __LOCK_IRQ(lock)
-#define _write_lock_irq(lock)                  __LOCK_IRQ(lock)
-#define _spin_lock_irqsave(lock, flags)                __LOCK_IRQSAVE(lock, flags)
-#define _read_lock_irqsave(lock, flags)                __LOCK_IRQSAVE(lock, flags)
-#define _write_lock_irqsave(lock, flags)       __LOCK_IRQSAVE(lock, flags)
-#define _spin_trylock(lock)                    ({ __LOCK(lock); 1; })
-#define _read_trylock(lock)                    ({ __LOCK(lock); 1; })
-#define _write_trylock(lock)                   ({ __LOCK(lock); 1; })
-#define _spin_trylock_bh(lock)                 ({ __LOCK_BH(lock); 1; })
-#define _spin_unlock(lock)                     __UNLOCK(lock)
-#define _read_unlock(lock)                     __UNLOCK(lock)
-#define _write_unlock(lock)                    __UNLOCK(lock)
-#define _spin_unlock_bh(lock)                  __UNLOCK_BH(lock)
-#define _write_unlock_bh(lock)                 __UNLOCK_BH(lock)
-#define _read_unlock_bh(lock)                  __UNLOCK_BH(lock)
-#define _spin_unlock_irq(lock)                 __UNLOCK_IRQ(lock)
-#define _read_unlock_irq(lock)                 __UNLOCK_IRQ(lock)
-#define _write_unlock_irq(lock)                        __UNLOCK_IRQ(lock)
-#define _spin_unlock_irqrestore(lock, flags)   __UNLOCK_IRQRESTORE(lock, flags)
-#define _read_unlock_irqrestore(lock, flags)   __UNLOCK_IRQRESTORE(lock, flags)
-#define _write_unlock_irqrestore(lock, flags)  __UNLOCK_IRQRESTORE(lock, flags)
+#define _raw_spin_lock(lock)                   __LOCK(lock)
+#define _raw_spin_lock_nested(lock, subclass)  __LOCK(lock)
+#define _raw_read_lock(lock)                   __LOCK(lock)
+#define _raw_write_lock(lock)                  __LOCK(lock)
+#define _raw_spin_lock_bh(lock)                        __LOCK_BH(lock)
+#define _raw_read_lock_bh(lock)                        __LOCK_BH(lock)
+#define _raw_write_lock_bh(lock)               __LOCK_BH(lock)
+#define _raw_spin_lock_irq(lock)               __LOCK_IRQ(lock)
+#define _raw_read_lock_irq(lock)               __LOCK_IRQ(lock)
+#define _raw_write_lock_irq(lock)              __LOCK_IRQ(lock)
+#define _raw_spin_lock_irqsave(lock, flags)    __LOCK_IRQSAVE(lock, flags)
+#define _raw_read_lock_irqsave(lock, flags)    __LOCK_IRQSAVE(lock, flags)
+#define _raw_write_lock_irqsave(lock, flags)   __LOCK_IRQSAVE(lock, flags)
+#define _raw_spin_trylock(lock)                        ({ __LOCK(lock); 1; })
+#define _raw_read_trylock(lock)                        ({ __LOCK(lock); 1; })
+#define _raw_write_trylock(lock)                       ({ __LOCK(lock); 1; })
+#define _raw_spin_trylock_bh(lock)             ({ __LOCK_BH(lock); 1; })
+#define _raw_spin_unlock(lock)                 __UNLOCK(lock)
+#define _raw_read_unlock(lock)                 __UNLOCK(lock)
+#define _raw_write_unlock(lock)                        __UNLOCK(lock)
+#define _raw_spin_unlock_bh(lock)              __UNLOCK_BH(lock)
+#define _raw_write_unlock_bh(lock)             __UNLOCK_BH(lock)
+#define _raw_read_unlock_bh(lock)              __UNLOCK_BH(lock)
+#define _raw_spin_unlock_irq(lock)             __UNLOCK_IRQ(lock)
+#define _raw_read_unlock_irq(lock)             __UNLOCK_IRQ(lock)
+#define _raw_write_unlock_irq(lock)            __UNLOCK_IRQ(lock)
+#define _raw_spin_unlock_irqrestore(lock, flags) \
+                                       __UNLOCK_IRQRESTORE(lock, flags)
+#define _raw_read_unlock_irqrestore(lock, flags) \
+                                       __UNLOCK_IRQRESTORE(lock, flags)
+#define _raw_write_unlock_irqrestore(lock, flags) \
+                                       __UNLOCK_IRQRESTORE(lock, flags)
 
 #endif /* __LINUX_SPINLOCK_API_UP_H */
index 68d88f71f1a2049c2f8be89c47aab85978f21054..851b7783720d89685f7a0653f1efa43263118585 100644 (file)
@@ -17,8 +17,8 @@
 
 #include <linux/lockdep.h>
 
-typedef struct {
-       raw_spinlock_t raw_lock;
+typedef struct raw_spinlock {
+       arch_spinlock_t raw_lock;
 #ifdef CONFIG_GENERIC_LOCKBREAK
        unsigned int break_lock;
 #endif
@@ -29,26 +29,10 @@ typedef struct {
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
        struct lockdep_map dep_map;
 #endif
-} spinlock_t;
+} raw_spinlock_t;
 
 #define SPINLOCK_MAGIC         0xdead4ead
 
-typedef struct {
-       raw_rwlock_t raw_lock;
-#ifdef CONFIG_GENERIC_LOCKBREAK
-       unsigned int break_lock;
-#endif
-#ifdef CONFIG_DEBUG_SPINLOCK
-       unsigned int magic, owner_cpu;
-       void *owner;
-#endif
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
-       struct lockdep_map dep_map;
-#endif
-} rwlock_t;
-
-#define RWLOCK_MAGIC           0xdeaf1eed
-
 #define SPINLOCK_OWNER_INIT    ((void *)-1L)
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -57,44 +41,56 @@ typedef struct {
 # define SPIN_DEP_MAP_INIT(lockname)
 #endif
 
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
-# define RW_DEP_MAP_INIT(lockname)     .dep_map = { .name = #lockname }
+#ifdef CONFIG_DEBUG_SPINLOCK
+# define SPIN_DEBUG_INIT(lockname)             \
+       .magic = SPINLOCK_MAGIC,                \
+       .owner_cpu = -1,                        \
+       .owner = SPINLOCK_OWNER_INIT,
 #else
-# define RW_DEP_MAP_INIT(lockname)
+# define SPIN_DEBUG_INIT(lockname)
 #endif
 
-#ifdef CONFIG_DEBUG_SPINLOCK
-# define __SPIN_LOCK_UNLOCKED(lockname)                                        \
-       (spinlock_t)    {       .raw_lock = __RAW_SPIN_LOCK_UNLOCKED,   \
-                               .magic = SPINLOCK_MAGIC,                \
-                               .owner = SPINLOCK_OWNER_INIT,           \
-                               .owner_cpu = -1,                        \
-                               SPIN_DEP_MAP_INIT(lockname) }
-#define __RW_LOCK_UNLOCKED(lockname)                                   \
-       (rwlock_t)      {       .raw_lock = __RAW_RW_LOCK_UNLOCKED,     \
-                               .magic = RWLOCK_MAGIC,                  \
-                               .owner = SPINLOCK_OWNER_INIT,           \
-                               .owner_cpu = -1,                        \
-                               RW_DEP_MAP_INIT(lockname) }
-#else
-# define __SPIN_LOCK_UNLOCKED(lockname) \
-       (spinlock_t)    {       .raw_lock = __RAW_SPIN_LOCK_UNLOCKED,   \
-                               SPIN_DEP_MAP_INIT(lockname) }
-#define __RW_LOCK_UNLOCKED(lockname) \
-       (rwlock_t)      {       .raw_lock = __RAW_RW_LOCK_UNLOCKED,     \
-                               RW_DEP_MAP_INIT(lockname) }
+#define __RAW_SPIN_LOCK_INITIALIZER(lockname)  \
+       {                                       \
+       .raw_lock = __ARCH_SPIN_LOCK_UNLOCKED,  \
+       SPIN_DEBUG_INIT(lockname)               \
+       SPIN_DEP_MAP_INIT(lockname) }
+
+#define __RAW_SPIN_LOCK_UNLOCKED(lockname)     \
+       (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname)
+
+#define DEFINE_RAW_SPINLOCK(x) raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x)
+
+typedef struct spinlock {
+       union {
+               struct raw_spinlock rlock;
+
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+# define LOCK_PADSIZE (offsetof(struct raw_spinlock, dep_map))
+               struct {
+                       u8 __padding[LOCK_PADSIZE];
+                       struct lockdep_map dep_map;
+               };
 #endif
+       };
+} spinlock_t;
+
+#define __SPIN_LOCK_INITIALIZER(lockname) \
+       { { .rlock = __RAW_SPIN_LOCK_INITIALIZER(lockname) } }
+
+#define __SPIN_LOCK_UNLOCKED(lockname) \
+       (spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname)
 
 /*
- * SPIN_LOCK_UNLOCKED and RW_LOCK_UNLOCKED defeat lockdep state tracking and
- * are hence deprecated.
- * Please use DEFINE_SPINLOCK()/DEFINE_RWLOCK() or
- * __SPIN_LOCK_UNLOCKED()/__RW_LOCK_UNLOCKED() as appropriate.
+ * SPIN_LOCK_UNLOCKED defeats lockdep state tracking and is hence
+ * deprecated.
+ * Please use DEFINE_SPINLOCK() or __SPIN_LOCK_UNLOCKED() as
+ * appropriate.
  */
 #define SPIN_LOCK_UNLOCKED     __SPIN_LOCK_UNLOCKED(old_style_spin_init)
-#define RW_LOCK_UNLOCKED       __RW_LOCK_UNLOCKED(old_style_rw_init)
 
 #define DEFINE_SPINLOCK(x)     spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
-#define DEFINE_RWLOCK(x)       rwlock_t x = __RW_LOCK_UNLOCKED(x)
+
+#include <linux/rwlock_types.h>
 
 #endif /* __LINUX_SPINLOCK_TYPES_H */
index 04135b0e198e31bfca6c3d1bea508d9af638f4b4..c09b6407ae1b3cd633ac9bcc30030249f520b872 100644 (file)
 
 typedef struct {
        volatile unsigned int slock;
-} raw_spinlock_t;
+} arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED { 1 }
+#define __ARCH_SPIN_LOCK_UNLOCKED { 1 }
 
 #else
 
-typedef struct { } raw_spinlock_t;
+typedef struct { } arch_spinlock_t;
 
-#define __RAW_SPIN_LOCK_UNLOCKED { }
+#define __ARCH_SPIN_LOCK_UNLOCKED { }
 
 #endif
 
 typedef struct {
        /* no debug version on UP */
-} raw_rwlock_t;
+} arch_rwlock_t;
 
-#define __RAW_RW_LOCK_UNLOCKED { }
+#define __ARCH_RW_LOCK_UNLOCKED { }
 
 #endif /* __LINUX_SPINLOCK_TYPES_UP_H */
index d4841ed8215b755ae2a291245687187479d4d27c..b14f6a91e19f33c214446d442667665aa2cd6310 100644 (file)
  */
 
 #ifdef CONFIG_DEBUG_SPINLOCK
-#define __raw_spin_is_locked(x)                ((x)->slock == 0)
+#define arch_spin_is_locked(x)         ((x)->slock == 0)
 
-static inline void __raw_spin_lock(raw_spinlock_t *lock)
+static inline void arch_spin_lock(arch_spinlock_t *lock)
 {
        lock->slock = 0;
 }
 
 static inline void
-__raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
+arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
 {
        local_irq_save(flags);
        lock->slock = 0;
 }
 
-static inline int __raw_spin_trylock(raw_spinlock_t *lock)
+static inline int arch_spin_trylock(arch_spinlock_t *lock)
 {
        char oldval = lock->slock;
 
@@ -41,7 +41,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
        return oldval > 0;
 }
 
-static inline void __raw_spin_unlock(raw_spinlock_t *lock)
+static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
        lock->slock = 1;
 }
@@ -49,28 +49,28 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
 /*
  * Read-write spinlocks. No debug version.
  */
-#define __raw_read_lock(lock)          do { (void)(lock); } while (0)
-#define __raw_write_lock(lock)         do { (void)(lock); } while (0)
-#define __raw_read_trylock(lock)       ({ (void)(lock); 1; })
-#define __raw_write_trylock(lock)      ({ (void)(lock); 1; })
-#define __raw_read_unlock(lock)                do { (void)(lock); } while (0)
-#define __raw_write_unlock(lock)       do { (void)(lock); } while (0)
+#define arch_read_lock(lock)           do { (void)(lock); } while (0)
+#define arch_write_lock(lock)          do { (void)(lock); } while (0)
+#define arch_read_trylock(lock)        ({ (void)(lock); 1; })
+#define arch_write_trylock(lock)       ({ (void)(lock); 1; })
+#define arch_read_unlock(lock)         do { (void)(lock); } while (0)
+#define arch_write_unlock(lock)        do { (void)(lock); } while (0)
 
 #else /* DEBUG_SPINLOCK */
-#define __raw_spin_is_locked(lock)     ((void)(lock), 0)
+#define arch_spin_is_locked(lock)      ((void)(lock), 0)
 /* for sched.c and kernel_lock.c: */
-# define __raw_spin_lock(lock)         do { (void)(lock); } while (0)
-# define __raw_spin_lock_flags(lock, flags)    do { (void)(lock); } while (0)
-# define __raw_spin_unlock(lock)       do { (void)(lock); } while (0)
-# define __raw_spin_trylock(lock)      ({ (void)(lock); 1; })
+# define arch_spin_lock(lock)          do { (void)(lock); } while (0)
+# define arch_spin_lock_flags(lock, flags)     do { (void)(lock); } while (0)
+# define arch_spin_unlock(lock)        do { (void)(lock); } while (0)
+# define arch_spin_trylock(lock)       ({ (void)(lock); 1; })
 #endif /* DEBUG_SPINLOCK */
 
-#define __raw_spin_is_contended(lock)  (((void)(lock), 0))
+#define arch_spin_is_contended(lock)   (((void)(lock), 0))
 
-#define __raw_read_can_lock(lock)      (((void)(lock), 1))
-#define __raw_write_can_lock(lock)     (((void)(lock), 1))
+#define arch_read_can_lock(lock)       (((void)(lock), 1))
+#define arch_write_can_lock(lock)      (((void)(lock), 1))
 
-#define __raw_spin_unlock_wait(lock) \
-               do { cpu_relax(); } while (__raw_spin_is_locked(lock))
+#define arch_spin_unlock_wait(lock) \
+               do { cpu_relax(); } while (arch_spin_is_locked(lock))
 
 #endif /* __LINUX_SPINLOCK_UP_H */
index b8508868d5ad428ab0c220ee2b39296e92eceb89..651839a2a755ffa63aa862367fb502897df94e3c 100644 (file)
@@ -62,7 +62,15 @@ extern char * strnchr(const char *, size_t, int);
 #ifndef __HAVE_ARCH_STRRCHR
 extern char * strrchr(const char *,int);
 #endif
-extern char * __must_check strstrip(char *);
+extern char * __must_check skip_spaces(const char *);
+
+extern char *strim(char *);
+
+static inline __must_check char *strstrip(char *str)
+{
+       return strim(str);
+}
+
 #ifndef __HAVE_ARCH_STRSTR
 extern char * strstr(const char *,const char *);
 #endif
index 10709cbe96fdb88419a87b15bf32fc81fef7c06a..c2786f20016f9184f0849c2ca9e94636efeaff9e 100644 (file)
@@ -28,9 +28,6 @@
 
 #ifdef __KERNEL__
 
-#include <linux/timer.h>
-#include <linux/workqueue.h>
-
 /*
  * Enable RPC debugging/profiling.
  */
index 87b895d5c786eb0256eae604e9d1efa9979e3756..b78f16b1dea3a0d6a38262e7f1dd3845efce22b6 100644 (file)
@@ -40,6 +40,8 @@
 #ifndef _LINUX_SUNRPC_RPC_RDMA_H
 #define _LINUX_SUNRPC_RPC_RDMA_H
 
+#include <linux/types.h>
+
 struct rpcrdma_segment {
        __be32 rs_handle;       /* Registered memory handle */
        __be32 rs_length;       /* Length of the chunk in bytes */
index 1906782ec86bc6b668998e17bc3a68d6c244a334..7bc7fd5291ce37d6abcbe7f44e96156540beb46d 100644 (file)
@@ -173,7 +173,8 @@ struct rpc_task_setup {
 #define RPC_PRIORITY_LOW       (-1)
 #define RPC_PRIORITY_NORMAL    (0)
 #define RPC_PRIORITY_HIGH      (1)
-#define RPC_NR_PRIORITY                (1 + RPC_PRIORITY_HIGH - RPC_PRIORITY_LOW)
+#define RPC_PRIORITY_PRIVILEGED        (2)
+#define RPC_NR_PRIORITY                (1 + RPC_PRIORITY_PRIVILEGED - RPC_PRIORITY_LOW)
 
 struct rpc_timer {
        struct timer_list timer;
@@ -229,6 +230,7 @@ void                rpc_wake_up_queued_task(struct rpc_wait_queue *,
 void           rpc_wake_up(struct rpc_wait_queue *);
 struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *);
 void           rpc_wake_up_status(struct rpc_wait_queue *, int);
+int            rpc_queue_empty(struct rpc_wait_queue *);
 void           rpc_delay(struct rpc_task *, unsigned long);
 void *         rpc_malloc(struct rpc_task *, size_t);
 void           rpc_free(void *);
@@ -254,6 +256,16 @@ static inline int rpc_wait_for_completion_task(struct rpc_task *task)
        return __rpc_wait_for_completion_task(task, NULL);
 }
 
+static inline void rpc_task_set_priority(struct rpc_task *task, unsigned char prio)
+{
+       task->tk_priority = prio - RPC_PRIORITY_LOW;
+}
+
+static inline int rpc_task_has_priority(struct rpc_task *task, unsigned char prio)
+{
+       return (task->tk_priority + RPC_PRIORITY_LOW == prio);
+}
+
 #ifdef RPC_DEBUG
 static inline const char * rpc_qname(struct rpc_wait_queue *q)
 {
index 52e8cb0a756993e0f095372b9e200d663d9da1ab..5a3085b9b3941d8f67fd9dec1c0584f360cfb3f6 100644 (file)
@@ -29,7 +29,6 @@ struct svc_pool_stats {
        unsigned long   packets;
        unsigned long   sockets_queued;
        unsigned long   threads_woken;
-       unsigned long   overloads_avoided;
        unsigned long   threads_timedout;
 };
 
@@ -50,7 +49,6 @@ struct svc_pool {
        struct list_head        sp_sockets;     /* pending sockets */
        unsigned int            sp_nrthreads;   /* # of threads in pool */
        struct list_head        sp_all_threads; /* all server threads */
-       int                     sp_nwaking;     /* number of threads woken but not yet active */
        struct svc_pool_stats   sp_stats;       /* statistics on pool operation */
 } ____cacheline_aligned_in_smp;
 
@@ -275,16 +273,11 @@ struct svc_rqst {
        struct auth_domain *    rq_client;      /* RPC peer info */
        struct auth_domain *    rq_gssclient;   /* "gss/"-style peer info */
        struct svc_cacherep *   rq_cacherep;    /* cache info */
-       struct knfsd_fh *       rq_reffh;       /* Referrence filehandle, used to
-                                                * determine what device number
-                                                * to report (real or virtual)
-                                                */
        int                     rq_splice_ok;   /* turned off in gss privacy
                                                 * to prevent encrypting page
                                                 * cache pages */
        wait_queue_head_t       rq_wait;        /* synchronization */
        struct task_struct      *rq_task;       /* service thread */
-       int                     rq_waking;      /* 1 if thread is being woken */
 };
 
 /*
index 4ec90019c1a4c3997c8da80dd3d36f3b31d09b11..a2602a8207a615ab21abce5f8b0165f90664798d 100644 (file)
@@ -145,38 +145,43 @@ enum {
        SWP_DISCARDABLE = (1 << 2),     /* blkdev supports discard */
        SWP_DISCARDING  = (1 << 3),     /* now discarding a free cluster */
        SWP_SOLIDSTATE  = (1 << 4),     /* blkdev seeks are cheap */
+       SWP_CONTINUED   = (1 << 5),     /* swap_map has count continuation */
                                        /* add others here before... */
        SWP_SCANNING    = (1 << 8),     /* refcount in scan_swap_map */
 };
 
 #define SWAP_CLUSTER_MAX 32
 
-#define SWAP_MAP_MAX   0x7ffe
-#define SWAP_MAP_BAD   0x7fff
-#define SWAP_HAS_CACHE  0x8000         /* There is a swap cache of entry. */
-#define SWAP_COUNT_MASK (~SWAP_HAS_CACHE)
+#define SWAP_MAP_MAX   0x3e    /* Max duplication count, in first swap_map */
+#define SWAP_MAP_BAD   0x3f    /* Note pageblock is bad, in first swap_map */
+#define SWAP_HAS_CACHE 0x40    /* Flag page is cached, in first swap_map */
+#define SWAP_CONT_MAX  0x7f    /* Max count, in each swap_map continuation */
+#define COUNT_CONTINUED        0x80    /* See swap_map continuation for full count */
+#define SWAP_MAP_SHMEM 0xbf    /* Owned by shmem/tmpfs, in first swap_map */
+
 /*
  * The in-memory structure used to track swap areas.
  */
 struct swap_info_struct {
-       unsigned long flags;
-       int prio;                       /* swap priority */
-       int next;                       /* next entry on swap list */
-       struct file *swap_file;
-       struct block_device *bdev;
-       struct list_head extent_list;
-       struct swap_extent *curr_swap_extent;
-       unsigned short *swap_map;
-       unsigned int lowest_bit;
-       unsigned int highest_bit;
+       unsigned long   flags;          /* SWP_USED etc: see above */
+       signed short    prio;           /* swap priority of this type */
+       signed char     type;           /* strange name for an index */
+       signed char     next;           /* next type on the swap list */
+       unsigned int    max;            /* extent of the swap_map */
+       unsigned char *swap_map;        /* vmalloc'ed array of usage counts */
+       unsigned int lowest_bit;        /* index of first free in swap_map */
+       unsigned int highest_bit;       /* index of last free in swap_map */
+       unsigned int pages;             /* total of usable pages of swap */
+       unsigned int inuse_pages;       /* number of those currently in use */
+       unsigned int cluster_next;      /* likely index for next allocation */
+       unsigned int cluster_nr;        /* countdown to next cluster search */
        unsigned int lowest_alloc;      /* while preparing discard cluster */
        unsigned int highest_alloc;     /* while preparing discard cluster */
-       unsigned int cluster_next;
-       unsigned int cluster_nr;
-       unsigned int pages;
-       unsigned int max;
-       unsigned int inuse_pages;
-       unsigned int old_block_size;
+       struct swap_extent *curr_swap_extent;
+       struct swap_extent first_swap_extent;
+       struct block_device *bdev;      /* swap device or bdev of swap file */
+       struct file *swap_file;         /* seldom referenced */
+       unsigned int old_block_size;    /* seldom referenced */
 };
 
 struct swap_list_t {
@@ -273,6 +278,7 @@ extern int scan_unevictable_register_node(struct node *node);
 extern void scan_unevictable_unregister_node(struct node *node);
 
 extern int kswapd_run(int nid);
+extern void kswapd_stop(int nid);
 
 #ifdef CONFIG_MMU
 /* linux/mm/shmem.c */
@@ -309,17 +315,18 @@ extern long total_swap_pages;
 extern void si_swapinfo(struct sysinfo *);
 extern swp_entry_t get_swap_page(void);
 extern swp_entry_t get_swap_page_of_type(int);
-extern void swap_duplicate(swp_entry_t);
-extern int swapcache_prepare(swp_entry_t);
 extern int valid_swaphandles(swp_entry_t, unsigned long *);
+extern int add_swap_count_continuation(swp_entry_t, gfp_t);
+extern void swap_shmem_alloc(swp_entry_t);
+extern int swap_duplicate(swp_entry_t);
+extern int swapcache_prepare(swp_entry_t);
 extern void swap_free(swp_entry_t);
 extern void swapcache_free(swp_entry_t, struct page *page);
 extern int free_swap_and_cache(swp_entry_t);
 extern int swap_type_of(dev_t, sector_t, struct block_device **);
 extern unsigned int count_swap_pages(int, int);
-extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
+extern sector_t map_swap_page(struct page *, struct block_device **);
 extern sector_t swapdev_block(int, pgoff_t);
-extern struct swap_info_struct *get_swap_info_struct(unsigned);
 extern int reuse_swap_page(struct page *);
 extern int try_to_free_swap(struct page *);
 struct backing_dev_info;
@@ -384,8 +391,18 @@ static inline void show_swap_cache_info(void)
 #define free_swap_and_cache(swp)       is_migration_entry(swp)
 #define swapcache_prepare(swp)         is_migration_entry(swp)
 
-static inline void swap_duplicate(swp_entry_t swp)
+static inline int add_swap_count_continuation(swp_entry_t swp, gfp_t gfp_mask)
 {
+       return 0;
+}
+
+static inline void swap_shmem_alloc(swp_entry_t swp)
+{
+}
+
+static inline int swap_duplicate(swp_entry_t swp)
+{
+       return 0;
 }
 
 static inline void swap_free(swp_entry_t swp)
index 939a61507ac5a64d73743784138e26d343ed05ed..65793e90d6f64f1865230412638a8b52679d1431 100644 (file)
@@ -102,12 +102,10 @@ struct perf_event_attr;
 #ifdef CONFIG_EVENT_PROFILE
 
 #define TRACE_SYS_ENTER_PROFILE_INIT(sname)                                   \
-       .profile_count = ATOMIC_INIT(-1),                                      \
        .profile_enable = prof_sysenter_enable,                                \
        .profile_disable = prof_sysenter_disable,
 
 #define TRACE_SYS_EXIT_PROFILE_INIT(sname)                                    \
-       .profile_count = ATOMIC_INIT(-1),                                      \
        .profile_enable = prof_sysexit_enable,                                 \
        .profile_disable = prof_sysexit_disable,
 #else
@@ -145,7 +143,7 @@ struct perf_event_attr;
                .name                   = "sys_enter"#sname,            \
                .system                 = "syscalls",                   \
                .event                  = &enter_syscall_print_##sname, \
-               .raw_init               = init_syscall_trace,           \
+               .raw_init               = trace_event_raw_init,         \
                .show_format            = syscall_enter_format,         \
                .define_fields          = syscall_enter_define_fields,  \
                .regfunc                = reg_event_syscall_enter,      \
@@ -167,7 +165,7 @@ struct perf_event_attr;
                .name                   = "sys_exit"#sname,             \
                .system                 = "syscalls",                   \
                .event                  = &exit_syscall_print_##sname,  \
-               .raw_init               = init_syscall_trace,           \
+               .raw_init               = trace_event_raw_init,         \
                .show_format            = syscall_exit_format,          \
                .define_fields          = syscall_exit_define_fields,   \
                .regfunc                = reg_event_syscall_exit,       \
index 877ba039e6a4b04a2adec72db41c429fc38c2a37..bd27fbc9db621eb6e96f365ed610d9a736cfcb3e 100644 (file)
@@ -482,6 +482,7 @@ enum
        NET_IPV4_CONF_ARP_ACCEPT=21,
        NET_IPV4_CONF_ARP_NOTIFY=22,
        NET_IPV4_CONF_ACCEPT_LOCAL=23,
+       NET_IPV4_CONF_SRC_VMARK=24,
        __NET_IPV4_CONF_MAX
 };
 
index 9d68fed50f119423904db7d7f608fd4baede5a82..cfa83083a2d4f3673e58223ab061d86daa56bc30 100644 (file)
@@ -99,8 +99,9 @@ int __must_check sysfs_chmod_file(struct kobject *kobj, struct attribute *attr,
 void sysfs_remove_file(struct kobject *kobj, const struct attribute *attr);
 
 int __must_check sysfs_create_bin_file(struct kobject *kobj,
-                                      struct bin_attribute *attr);
-void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr);
+                                      const struct bin_attribute *attr);
+void sysfs_remove_bin_file(struct kobject *kobj,
+                          const struct bin_attribute *attr);
 
 int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
                                   const char *name);
@@ -175,13 +176,13 @@ static inline void sysfs_remove_file(struct kobject *kobj,
 }
 
 static inline int sysfs_create_bin_file(struct kobject *kobj,
-                                       struct bin_attribute *attr)
+                                       const struct bin_attribute *attr)
 {
        return 0;
 }
 
 static inline void sysfs_remove_bin_file(struct kobject *kobj,
-                                        struct bin_attribute *attr)
+                                        const struct bin_attribute *attr)
 {
 }
 
diff --git a/include/linux/timb_gpio.h b/include/linux/timb_gpio.h
new file mode 100644 (file)
index 0000000..ce456ea
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * timb_gpio.h timberdale FPGA GPIO driver, platform data definition
+ * Copyright (c) 2009 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef _LINUX_TIMB_GPIO_H
+#define _LINUX_TIMB_GPIO_H
+
+/**
+ * struct timbgpio_platform_data - Platform data of the Timberdale GPIO driver
+ * @gpio_base          The number of the first GPIO pin, set to -1 for
+ *                     dynamic number allocation.
+ * @nr_pins            Number of pins that is supported by the hardware (1-32)
+ * @irq_base           If IRQ is supported by the hardware, this is the base
+ *                     number of IRQ:s. One IRQ per pin will be used. Set to
+ *                     -1 if IRQ:s is not supported.
+ */
+struct timbgpio_platform_data {
+       int gpio_base;
+       int nr_pins;
+       int irq_base;
+};
+
+#endif
index 1eb44a924e5643066677f7d3edef90d6ef9cce0d..10db0102a890b8baa7905cf2b73cded2314f7f30 100644 (file)
@@ -134,6 +134,13 @@ static inline __must_check int tracehook_report_syscall_entry(
  */
 static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
 {
+       if (step) {
+               siginfo_t info;
+               user_single_step_siginfo(current, regs, &info);
+               force_sig_info(SIGTRAP, &info, current);
+               return;
+       }
+
        ptrace_report_syscall(regs);
 }
 
index 405a9035fe40601114e02d77a98aa0090bcd8646..ef3a2947b1026a43dfebf0945132d0b1e1fc91c2 100644 (file)
@@ -350,8 +350,6 @@ extern void tty_write_flush(struct tty_struct *);
 
 extern struct ktermios tty_std_termios;
 
-extern int kmsg_redirect;
-
 extern void console_init(void);
 extern int vcs_init(void);
 
index acf6e457c04b17c695b701febae74415812c5671..1819396ed5015df55d335934e1b2cff8fff4da0f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kref.h>
 #include <linux/mutex.h>
 #include <linux/sysrq.h>
+#include <linux/kfifo.h>
 
 #define SERIAL_TTY_MAJOR       188     /* Nice legal number now */
 #define SERIAL_TTY_MINORS      254     /* loads of devices :) */
@@ -94,7 +95,7 @@ struct usb_serial_port {
        unsigned char           *bulk_out_buffer;
        int                     bulk_out_size;
        struct urb              *write_urb;
-       struct kfifo            *write_fifo;
+       struct kfifo            write_fifo;
        int                     write_urb_busy;
        __u8                    bulk_out_endpointAddress;
 
index 79b9837d9ca079b809405ae7d0a6ed93d5cf273c..cf97b5b9d1fe8928bca85db1e5ae888681a39519 100644 (file)
@@ -1,4 +1,4 @@
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/module.h>
 
 /* Simply sanity version stamp for modules. */
index 32b92298fd79ea1bad423157add31b788bb496e0..d4962a782b8abbb8db66c30db0f42ab4129658d2 100644 (file)
@@ -294,6 +294,7 @@ struct v4l2_pix_format {
 
 /* Grey formats */
 #define V4L2_PIX_FMT_GREY    v4l2_fourcc('G', 'R', 'E', 'Y') /*  8  Greyscale     */
+#define V4L2_PIX_FMT_Y10     v4l2_fourcc('Y', '1', '0', ' ') /* 10  Greyscale     */
 #define V4L2_PIX_FMT_Y16     v4l2_fourcc('Y', '1', '6', ' ') /* 16  Greyscale     */
 
 /* Palette formats */
@@ -329,7 +330,11 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B', 'A', '8', '1') /*  8  BGBG.. GRGR.. */
 #define V4L2_PIX_FMT_SGBRG8  v4l2_fourcc('G', 'B', 'R', 'G') /*  8  GBGB.. RGRG.. */
 #define V4L2_PIX_FMT_SGRBG8  v4l2_fourcc('G', 'R', 'B', 'G') /*  8  GRGR.. BGBG.. */
-#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10bit raw bayer */
+#define V4L2_PIX_FMT_SRGGB8  v4l2_fourcc('R', 'G', 'G', 'B') /*  8  RGRG.. GBGB.. */
+#define V4L2_PIX_FMT_SBGGR10 v4l2_fourcc('B', 'G', '1', '0') /* 10  BGBG.. GRGR.. */
+#define V4L2_PIX_FMT_SGBRG10 v4l2_fourcc('G', 'B', '1', '0') /* 10  GBGB.. RGRG.. */
+#define V4L2_PIX_FMT_SGRBG10 v4l2_fourcc('B', 'A', '1', '0') /* 10  GRGR.. BGBG.. */
+#define V4L2_PIX_FMT_SRGGB10 v4l2_fourcc('R', 'G', '1', '0') /* 10  RGRG.. GBGB.. */
        /* 10bit raw bayer DPCM compressed to 8 bits */
 #define V4L2_PIX_FMT_SGRBG10DPCM8 v4l2_fourcc('B', 'D', '1', '0')
        /*
@@ -731,6 +736,99 @@ struct v4l2_standard {
        __u32                reserved[4];
 };
 
+/*
+ *     V I D E O       T I M I N G S   D V     P R E S E T
+ */
+struct v4l2_dv_preset {
+       __u32   preset;
+       __u32   reserved[4];
+};
+
+/*
+ *     D V     P R E S E T S   E N U M E R A T I O N
+ */
+struct v4l2_dv_enum_preset {
+       __u32   index;
+       __u32   preset;
+       __u8    name[32]; /* Name of the preset timing */
+       __u32   width;
+       __u32   height;
+       __u32   reserved[4];
+};
+
+/*
+ *     D V     P R E S E T     V A L U E S
+ */
+#define                V4L2_DV_INVALID         0
+#define                V4L2_DV_480P59_94       1 /* BT.1362 */
+#define                V4L2_DV_576P50          2 /* BT.1362 */
+#define                V4L2_DV_720P24          3 /* SMPTE 296M */
+#define                V4L2_DV_720P25          4 /* SMPTE 296M */
+#define                V4L2_DV_720P30          5 /* SMPTE 296M */
+#define                V4L2_DV_720P50          6 /* SMPTE 296M */
+#define                V4L2_DV_720P59_94       7 /* SMPTE 274M */
+#define                V4L2_DV_720P60          8 /* SMPTE 274M/296M */
+#define                V4L2_DV_1080I29_97      9 /* BT.1120/ SMPTE 274M */
+#define                V4L2_DV_1080I30         10 /* BT.1120/ SMPTE 274M */
+#define                V4L2_DV_1080I25         11 /* BT.1120 */
+#define                V4L2_DV_1080I50         12 /* SMPTE 296M */
+#define                V4L2_DV_1080I60         13 /* SMPTE 296M */
+#define                V4L2_DV_1080P24         14 /* SMPTE 296M */
+#define                V4L2_DV_1080P25         15 /* SMPTE 296M */
+#define                V4L2_DV_1080P30         16 /* SMPTE 296M */
+#define                V4L2_DV_1080P50         17 /* BT.1120 */
+#define                V4L2_DV_1080P60         18 /* BT.1120 */
+
+/*
+ *     D V     B T     T I M I N G S
+ */
+
+/* BT.656/BT.1120 timing data */
+struct v4l2_bt_timings {
+       __u32   width;          /* width in pixels */
+       __u32   height;         /* height in lines */
+       __u32   interlaced;     /* Interlaced or progressive */
+       __u32   polarities;     /* Positive or negative polarity */
+       __u64   pixelclock;     /* Pixel clock in HZ. Ex. 74.25MHz->74250000 */
+       __u32   hfrontporch;    /* Horizpontal front porch in pixels */
+       __u32   hsync;          /* Horizontal Sync length in pixels */
+       __u32   hbackporch;     /* Horizontal back porch in pixels */
+       __u32   vfrontporch;    /* Vertical front porch in pixels */
+       __u32   vsync;          /* Vertical Sync length in lines */
+       __u32   vbackporch;     /* Vertical back porch in lines */
+       __u32   il_vfrontporch; /* Vertical front porch for bottom field of
+                                * interlaced field formats
+                                */
+       __u32   il_vsync;       /* Vertical sync length for bottom field of
+                                * interlaced field formats
+                                */
+       __u32   il_vbackporch;  /* Vertical back porch for bottom field of
+                                * interlaced field formats
+                                */
+       __u32   reserved[16];
+} __attribute__ ((packed));
+
+/* Interlaced or progressive format */
+#define        V4L2_DV_PROGRESSIVE     0
+#define        V4L2_DV_INTERLACED      1
+
+/* Polarities. If bit is not set, it is assumed to be negative polarity */
+#define V4L2_DV_VSYNC_POS_POL  0x00000001
+#define V4L2_DV_HSYNC_POS_POL  0x00000002
+
+
+/* DV timings */
+struct v4l2_dv_timings {
+       __u32 type;
+       union {
+               struct v4l2_bt_timings  bt;
+               __u32   reserved[32];
+       };
+} __attribute__ ((packed));
+
+/* Values for the type field */
+#define V4L2_DV_BT_656_1120    0       /* BT.656/1120 timing type */
+
 /*
  *     V I D E O   I N P U T S
  */
@@ -742,7 +840,8 @@ struct v4l2_input {
        __u32        tuner;             /*  Associated tuner */
        v4l2_std_id  std;
        __u32        status;
-       __u32        reserved[4];
+       __u32        capabilities;
+       __u32        reserved[3];
 };
 
 /*  Values for the 'type' field */
@@ -773,6 +872,11 @@ struct v4l2_input {
 #define V4L2_IN_ST_NO_ACCESS   0x02000000  /* Conditional access denied */
 #define V4L2_IN_ST_VTR         0x04000000  /* VTR time constant */
 
+/* capabilities flags */
+#define V4L2_IN_CAP_PRESETS            0x00000001 /* Supports S_DV_PRESET */
+#define V4L2_IN_CAP_CUSTOM_TIMINGS     0x00000002 /* Supports S_DV_TIMINGS */
+#define V4L2_IN_CAP_STD                        0x00000004 /* Supports S_STD */
+
 /*
  *     V I D E O   O U T P U T S
  */
@@ -783,13 +887,19 @@ struct v4l2_output {
        __u32        audioset;          /*  Associated audios (bitfield) */
        __u32        modulator;         /*  Associated modulator */
        v4l2_std_id  std;
-       __u32        reserved[4];
+       __u32        capabilities;
+       __u32        reserved[3];
 };
 /*  Values for the 'type' field */
 #define V4L2_OUTPUT_TYPE_MODULATOR             1
 #define V4L2_OUTPUT_TYPE_ANALOG                        2
 #define V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY      3
 
+/* capabilities flags */
+#define V4L2_OUT_CAP_PRESETS           0x00000001 /* Supports S_DV_PRESET */
+#define V4L2_OUT_CAP_CUSTOM_TIMINGS    0x00000002 /* Supports S_DV_TIMINGS */
+#define V4L2_OUT_CAP_STD               0x00000004 /* Supports S_STD */
+
 /*
  *     C O N T R O L S
  */
@@ -1624,6 +1734,13 @@ struct v4l2_dbg_chip_ident {
 #endif
 
 #define VIDIOC_S_HW_FREQ_SEEK   _IOW('V', 82, struct v4l2_hw_freq_seek)
+#define        VIDIOC_ENUM_DV_PRESETS  _IOWR('V', 83, struct v4l2_dv_enum_preset)
+#define        VIDIOC_S_DV_PRESET      _IOWR('V', 84, struct v4l2_dv_preset)
+#define        VIDIOC_G_DV_PRESET      _IOWR('V', 85, struct v4l2_dv_preset)
+#define        VIDIOC_QUERY_DV_PRESET  _IOR('V',  86, struct v4l2_dv_preset)
+#define        VIDIOC_S_DV_TIMINGS     _IOWR('V', 87, struct v4l2_dv_timings)
+#define        VIDIOC_G_DV_TIMINGS     _IOWR('V', 88, struct v4l2_dv_timings)
+
 /* Reminder: when adding new ioctls please add support for them to
    drivers/media/video/v4l2-compat-ioctl32.c as well! */
 
index d85889710f9b6a4fbf5040fd941c1cfca7847428..ee03bba9c5df8e9d0b0586fcfff5ef39e254c717 100644 (file)
@@ -40,6 +40,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                PGSCAN_ZONE_RECLAIM_FAILED,
 #endif
                PGINODESTEAL, SLABS_SCANNED, KSWAPD_STEAL, KSWAPD_INODESTEAL,
+               KSWAPD_LOW_WMARK_HIT_QUICKLY, KSWAPD_HIGH_WMARK_HIT_QUICKLY,
+               KSWAPD_SKIP_CONGESTION_WAIT,
                PAGEOUTRUN, ALLOCSTALL, PGROTATED,
 #ifdef CONFIG_HUGETLB_PAGE
                HTLB_BUDDY_PGALLOC, HTLB_BUDDY_PGALLOC_FAIL,
index 7ffa11f062324de1b79bb0d3093dac8523aaee0c..d5dd0bc408fd4e7b1e79ea8326841a8a187f2738 100644 (file)
@@ -84,4 +84,23 @@ struct vt_setactivate {
 
 #define VT_SETACTIVATE 0x560F  /* Activate and set the mode of a console */
 
+#ifdef __KERNEL__
+
+#ifdef CONFIG_VT_CONSOLE
+
+extern int vt_kmsg_redirect(int new);
+
+#else
+
+static inline int vt_kmsg_redirect(int new)
+{
+       return 0;
+}
+
+#endif
+
+#endif /* __KERNEL__ */
+
+#define vt_get_kmsg_redirect() vt_kmsg_redirect(-1)
+
 #endif /* _LINUX_VT_H */
index 705f01fe413a5f982538bf58fe6c524f4828635a..76e8903cd204d4b2a21a8577a00150532c3dc24f 100644 (file)
@@ -70,6 +70,7 @@ struct writeback_control {
 struct bdi_writeback;
 int inode_wait(void *);
 void writeback_inodes_sb(struct super_block *);
+int writeback_inodes_sb_if_idle(struct super_block *);
 void sync_inodes_sb(struct super_block *);
 void writeback_inodes_wbc(struct writeback_control *wbc);
 long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
@@ -79,8 +80,7 @@ void wakeup_flusher_threads(long nr_pages);
 static inline void wait_on_inode(struct inode *inode)
 {
        might_sleep();
-       wait_on_bit(&inode->i_state, __I_LOCK, inode_wait,
-                                                       TASK_UNINTERRUPTIBLE);
+       wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE);
 }
 static inline void inode_sync_wait(struct inode *inode)
 {
index 5c84af8c5f6fd7014439570a8d958f9b83eadecb..fb9b7e6e1e2d74f5750248efff6cb9cc956b2a18 100644 (file)
@@ -38,12 +38,13 @@ struct dentry;
 
 struct xattr_handler {
        char *prefix;
-       size_t (*list)(struct inode *inode, char *list, size_t list_size,
-                      const char *name, size_t name_len);
-       int (*get)(struct inode *inode, const char *name, void *buffer,
-                  size_t size);
-       int (*set)(struct inode *inode, const char *name, const void *buffer,
-                  size_t size, int flags);
+       int flags;      /* fs private flags passed back to the handlers */
+       size_t (*list)(struct dentry *dentry, char *list, size_t list_size,
+                      const char *name, size_t name_len, int handler_flags);
+       int (*get)(struct dentry *dentry, const char *name, void *buffer,
+                  size_t size, int handler_flags);
+       int (*set)(struct dentry *dentry, const char *name, const void *buffer,
+                  size_t size, int flags, int handler_flags);
 };
 
 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
index e41a99ee353e594a06efbad282bfd992f401e059..2c6af24b905e364097acc57209c236f31cf31268 100644 (file)
 #include <linux/input.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
-#include <linux/spinlock.h>
-
-extern int media_ir_debug;    /* media_ir_debug level (0,1,2) */
-#define IR_dprintk(level, fmt, arg...) if (media_ir_debug >= level) \
-       printk(KERN_DEBUG "%s: " fmt , __func__, ## arg)
-
-#define IR_TYPE_RC5     1
-#define IR_TYPE_PD      2 /* Pulse distance encoded IR */
-#define IR_TYPE_OTHER  99
-
-struct ir_scancode {
-       u16     scancode;
-       u32     keycode;
-};
-
-struct ir_scancode_table {
-       struct ir_scancode *scan;
-       int size;
-       spinlock_t lock;
-};
+#include <media/ir-core.h>
 
 #define RC5_START(x)   (((x)>>12)&3)
 #define RC5_TOGGLE(x)  (((x)>>11)&1)
@@ -56,8 +37,6 @@ struct ir_input_state {
        /* configuration */
        int                ir_type;
 
-       struct ir_scancode_table keytable;
-
        /* key info */
        u32                ir_key;      /* ir scancode */
        u32                keycode;     /* linux key code */
@@ -105,7 +84,7 @@ struct card_ir {
 /* Routines from ir-functions.c */
 
 int ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
-                  int ir_type, struct ir_scancode_table *ir_codes);
+                  int ir_type);
 void ir_input_nokey(struct input_dev *dev, struct ir_input_state *ir);
 void ir_input_keydown(struct input_dev *dev, struct ir_input_state *ir,
                      u32 ir_key);
@@ -118,19 +97,6 @@ u32  ir_rc5_decode(unsigned int code);
 void ir_rc5_timer_end(unsigned long data);
 void ir_rc5_timer_keyup(unsigned long data);
 
-/* Routines from ir-keytable.c */
-
-u32 ir_g_keycode_from_table(struct input_dev *input_dev,
-                           u32 scancode);
-
-int ir_set_keycode_table(struct input_dev *input_dev,
-                        struct ir_scancode_table *rc_tab);
-
-int ir_roundup_tablesize(int n_elems);
-int ir_copy_table(struct ir_scancode_table *destin,
-                const struct ir_scancode_table *origin);
-void ir_input_free(struct input_dev *input_dev);
-
 /* scancode->keycode map tables from ir-keymaps.c */
 
 extern struct ir_scancode_table ir_codes_empty_table;
@@ -195,4 +161,5 @@ extern struct ir_scancode_table ir_codes_evga_indtube_table;
 extern struct ir_scancode_table ir_codes_terratec_cinergy_xs_table;
 extern struct ir_scancode_table ir_codes_videomate_s350_table;
 extern struct ir_scancode_table ir_codes_gadmei_rm008z_table;
+extern struct ir_scancode_table ir_codes_nec_terratec_cinergy_xs_table;
 #endif
diff --git a/include/media/ir-core.h b/include/media/ir-core.h
new file mode 100644 (file)
index 0000000..299d201
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Remote Controller core header
+ *
+ * This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ */
+
+#ifndef _IR_CORE
+#define _IR_CORE
+
+#include <linux/input.h>
+#include <linux/spinlock.h>
+
+extern int ir_core_debug;
+#define IR_dprintk(level, fmt, arg...) if (ir_core_debug >= level) \
+       printk(KERN_DEBUG "%s: " fmt , __func__, ## arg)
+
+enum ir_type {
+       IR_TYPE_UNKNOWN = 0,
+       IR_TYPE_RC5     = 1,
+       IR_TYPE_PD      = 2,             /* Pulse distance encoded IR */
+       IR_TYPE_NEC     = 3,
+       IR_TYPE_OTHER   = 99,
+};
+
+struct ir_scancode {
+       u16     scancode;
+       u32     keycode;
+};
+
+struct ir_scancode_table {
+       struct ir_scancode      *scan;
+       int                     size;
+       enum                    ir_type ir_type;
+       spinlock_t              lock;
+};
+
+struct ir_input_dev {
+       struct input_dev                *dev;
+       struct ir_scancode_table        rc_tab;
+};
+
+/* Routines from ir-keytable.c */
+
+u32 ir_g_keycode_from_table(struct input_dev *input_dev,
+                           u32 scancode);
+
+int ir_set_keycode_table(struct input_dev *input_dev,
+                        struct ir_scancode_table *rc_tab);
+
+int ir_roundup_tablesize(int n_elems);
+int ir_input_register(struct input_dev *dev,
+                     struct ir_scancode_table *ir_codes);
+void ir_input_unregister(struct input_dev *input_dev);
+
+#endif
diff --git a/include/media/mt9t112.h b/include/media/mt9t112.h
new file mode 100644 (file)
index 0000000..a43c74a
--- /dev/null
@@ -0,0 +1,30 @@
+/* mt9t112 Camera
+ *
+ * Copyright (C) 2009 Renesas Solutions Corp.
+ * Kuninori Morimoto <morimoto.kuninori@renesas.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __MT9T112_H__
+#define __MT9T112_H__
+
+#define MT9T112_FLAG_PCLK_RISING_EDGE  (1 << 0)
+#define MT9T112_FLAG_DATAWIDTH_8       (1 << 1) /* default width is 10 */
+
+struct mt9t112_pll_divider {
+       u8 m, n;
+       u8 p1, p2, p3, p4, p5, p6, p7;
+};
+
+/*
+ * mt9t112 camera info
+ */
+struct mt9t112_camera_info {
+       u32 flags;
+       struct mt9t112_pll_divider divider;
+};
+
+#endif /* __MT9T112_H__ */
index 30d9629198ef6170e42450fbfc8255c17dc8c821..14c77efd6a85297e2599da5cc08ad30a8f9ce83e 100644 (file)
@@ -1,4 +1,5 @@
-/* ov772x Camera
+/*
+ * ov772x Camera
  *
  * Copyright (C) 2008 Renesas Solutions Corp.
  * Kuninori Morimoto <morimoto.kuninori@renesas.com>
@@ -54,7 +55,6 @@ struct ov772x_edge_ctrl {
 struct ov772x_camera_info {
        unsigned long          buswidth;
        unsigned long          flags;
-       struct soc_camera_link link;
        struct ov772x_edge_ctrl edgectrl;
 };
 
diff --git a/include/media/rj54n1cb0c.h b/include/media/rj54n1cb0c.h
new file mode 100644 (file)
index 0000000..8ae3288
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * RJ54N1CB0C Private data
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __RJ54N1CB0C_H__
+#define __RJ54N1CB0C_H__
+
+struct rj54n1_pdata {
+       unsigned int    mclk_freq;
+       bool            ioctl_high;
+};
+
+#endif
index eed5fccc83f3c242e2ff95766ab2bbbd0fd669b4..4aeff96ff7d8105f7bfe5e97b69ec94e1db6d4e8 100644 (file)
@@ -108,8 +108,6 @@ struct saa7146_fh {
 
 struct saa7146_vv
 {
-       int vbi_minor;
-
        /* vbi capture */
        struct saa7146_dmaqueue         vbi_q;
        /* vbi workaround interrupt queue */
@@ -117,8 +115,6 @@ struct saa7146_vv
        int                             vbi_fieldcount;
        struct saa7146_fh               *vbi_streaming;
 
-       int video_minor;
-
        int                             video_status;
        struct saa7146_fh               *video_fh;
 
index 0f3524cff4355df94cba4c4e13eeba361ed3a706..b67747836878acd00544c38d3870bb35ed277c7c 100644 (file)
@@ -3,6 +3,8 @@
 
 #define SH_CEU_FLAG_USE_8BIT_BUS       (1 << 0) /* use  8bit bus width */
 #define SH_CEU_FLAG_USE_16BIT_BUS      (1 << 1) /* use 16bit bus width */
+#define SH_CEU_FLAG_HSYNC_LOW          (1 << 2) /* default High if possible */
+#define SH_CEU_FLAG_VSYNC_LOW          (1 << 3) /* default High if possible */
 
 struct sh_mobile_ceu_info {
        unsigned long flags;
index 3d74e60032ddf27ff02403bc18d8f98f9e8f5c7d..dcc5b86bcb6cce2cd9efa685b25252df5b3abd10 100644 (file)
@@ -24,18 +24,13 @@ struct soc_camera_device {
        struct device *pdev;            /* Platform device */
        s32 user_width;
        s32 user_height;
-       unsigned short width_min;
-       unsigned short height_min;
-       unsigned short y_skip_top;      /* Lines to skip at the top */
+       enum v4l2_colorspace colorspace;
        unsigned char iface;            /* Host number */
        unsigned char devnum;           /* Device number per host */
-       unsigned char buswidth;         /* See comment in .c */
        struct soc_camera_sense *sense; /* See comment in struct definition */
        struct soc_camera_ops *ops;
        struct video_device *vdev;
-       const struct soc_camera_data_format *current_fmt;
-       const struct soc_camera_data_format *formats;
-       int num_formats;
+       const struct soc_camera_format_xlate *current_fmt;
        struct soc_camera_format_xlate *user_formats;
        int num_user_formats;
        enum v4l2_field field;          /* Preserve field over close() */
@@ -107,6 +102,8 @@ struct soc_camera_link {
        int i2c_adapter_id;
        struct i2c_board_info *board_info;
        const char *module_name;
+       void *priv;
+
        /*
         * For non-I2C devices platform platform has to provide methods to
         * add a device to the system and to remove
@@ -162,23 +159,13 @@ static inline struct v4l2_subdev *soc_camera_to_subdev(
 int soc_camera_host_register(struct soc_camera_host *ici);
 void soc_camera_host_unregister(struct soc_camera_host *ici);
 
-const struct soc_camera_data_format *soc_camera_format_by_fourcc(
-       struct soc_camera_device *icd, unsigned int fourcc);
 const struct soc_camera_format_xlate *soc_camera_xlate_by_fourcc(
        struct soc_camera_device *icd, unsigned int fourcc);
 
-struct soc_camera_data_format {
-       const char *name;
-       unsigned int depth;
-       __u32 fourcc;
-       enum v4l2_colorspace colorspace;
-};
-
 /**
  * struct soc_camera_format_xlate - match between host and sensor formats
- * @cam_fmt: sensor format provided by the sensor
- * @host_fmt: host format after host translation from cam_fmt
- * @buswidth: bus width for this format
+ * @code: code of a sensor provided format
+ * @host_fmt: host format after host translation from code
  *
  * Host and sensor translation structure. Used in table of host and sensor
  * formats matchings in soc_camera_device. A host can override the generic list
@@ -186,9 +173,8 @@ struct soc_camera_data_format {
  * format setup.
  */
 struct soc_camera_format_xlate {
-       const struct soc_camera_data_format *cam_fmt;
-       const struct soc_camera_data_format *host_fmt;
-       unsigned char buswidth;
+       enum v4l2_mbus_pixelcode code;
+       const struct soc_mbus_pixelfmt *host_fmt;
 };
 
 struct soc_camera_ops {
index bb70401b81413f19f8a8d16e91ab3219c094af25..0ecefe227b767c3894847e1bbb5b7225e5bd6af7 100644 (file)
@@ -19,11 +19,10 @@ struct device;
 struct soc_camera_platform_info {
        const char *format_name;
        unsigned long format_depth;
-       struct v4l2_pix_format format;
+       struct v4l2_mbus_framefmt format;
        unsigned long bus_param;
        struct device *dev;
        int (*set_capture)(struct soc_camera_platform_info *info, int enable);
-       struct soc_camera_link link;
 };
 
 #endif /* __SOC_CAMERA_H__ */
diff --git a/include/media/soc_mediabus.h b/include/media/soc_mediabus.h
new file mode 100644 (file)
index 0000000..037cd7b
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * SoC-camera Media Bus API extensions
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef SOC_MEDIABUS_H
+#define SOC_MEDIABUS_H
+
+#include <linux/videodev2.h>
+
+#include <media/v4l2-mediabus.h>
+
+/**
+ * enum soc_mbus_packing - data packing types on the media-bus
+ * @SOC_MBUS_PACKING_NONE:     no packing, bit-for-bit transfer to RAM
+ * @SOC_MBUS_PACKING_2X8_PADHI:        16 bits transferred in 2 8-bit samples, in the
+ *                             possibly incomplete byte high bits are padding
+ * @SOC_MBUS_PACKING_2X8_PADLO:        as above, but low bits are padding
+ * @SOC_MBUS_PACKING_EXTEND16: sample width (e.g., 10 bits) has to be extended
+ *                             to 16 bits
+ */
+enum soc_mbus_packing {
+       SOC_MBUS_PACKING_NONE,
+       SOC_MBUS_PACKING_2X8_PADHI,
+       SOC_MBUS_PACKING_2X8_PADLO,
+       SOC_MBUS_PACKING_EXTEND16,
+};
+
+/**
+ * enum soc_mbus_order - sample order on the media bus
+ * @SOC_MBUS_ORDER_LE:         least significant sample first
+ * @SOC_MBUS_ORDER_BE:         most significant sample first
+ */
+enum soc_mbus_order {
+       SOC_MBUS_ORDER_LE,
+       SOC_MBUS_ORDER_BE,
+};
+
+/**
+ * struct soc_mbus_pixelfmt - Data format on the media bus
+ * @name:              Name of the format
+ * @fourcc:            Fourcc code, that will be obtained if the data is
+ *                     stored in memory in the following way:
+ * @packing:           Type of sample-packing, that has to be used
+ * @order:             Sample order when storing in memory
+ * @bits_per_sample:   How many bits the bridge has to sample
+ */
+struct soc_mbus_pixelfmt {
+       const char              *name;
+       u32                     fourcc;
+       enum soc_mbus_packing   packing;
+       enum soc_mbus_order     order;
+       u8                      bits_per_sample;
+};
+
+const struct soc_mbus_pixelfmt *soc_mbus_get_fmtdesc(
+       enum v4l2_mbus_pixelcode code);
+s32 soc_mbus_bytes_per_line(u32 width, const struct soc_mbus_pixelfmt *mf);
+
+#endif
index 73231e7880d80dcdc72c015f2cfa9047039cea51..5e2895a05e6b258e42bb74fdef9af3e4f4044098 100644 (file)
@@ -32,7 +32,6 @@ enum tw9910_mpout_pin {
 struct tw9910_video_info {
        unsigned long          buswidth;
        enum tw9910_mpout_pin  mpout;
-       struct soc_camera_link link;
 };
 
 
index 91942dbe64e3bc87212e048b0ea97970343adf7d..6cc107d198a0dc28afe231427feb22edd668280b 100644 (file)
@@ -267,6 +267,8 @@ enum {
        V4L2_IDENT_MT9V022IX7ATC        = 45010, /* No way to detect "normal" I77ATx */
        V4L2_IDENT_MT9V022IX7ATM        = 45015, /* and "lead free" IA7ATx chips */
        V4L2_IDENT_MT9T031              = 45020,
+       V4L2_IDENT_MT9T111              = 45021,
+       V4L2_IDENT_MT9T112              = 45022,
        V4L2_IDENT_MT9V111              = 45031,
        V4L2_IDENT_MT9V112              = 45032,
 
index 1c25b10da34bbc70b5aafe79ac3a132f32b73184..1c7b259f341cd6031bf33dd89bdf47c7f4aeacbe 100644 (file)
@@ -212,5 +212,5 @@ void v4l_bound_align_image(unsigned int *w, unsigned int wmin,
                           unsigned int *h, unsigned int hmin,
                           unsigned int hmax, unsigned int halign,
                           unsigned int salign);
-
+int v4l_fill_dv_preset_info(u32 preset, struct v4l2_dv_enum_preset *info);
 #endif /* V4L2_COMMON_H_ */
index 73c9867d744c16ec4bf9b565da8901d20ed034ca..2dee93892ea2feb5ea3e34412b89cf17effabdf4 100644 (file)
@@ -28,10 +28,10 @@ struct v4l2_ioctl_callbacks;
 struct video_device;
 struct v4l2_device;
 
-/* Flag to mark the video_device struct as unregistered.
-   Drivers can set this flag if they want to block all future
-   device access. It is set by video_unregister_device. */
-#define V4L2_FL_UNREGISTERED   (0)
+/* Flag to mark the video_device struct as registered.
+   Drivers can clear this flag if they want to block all future
+   device access. It is cleared by video_unregister_device. */
+#define V4L2_FL_REGISTERED     (0)
 
 struct v4l2_file_operations {
        struct module *owner;
@@ -96,9 +96,7 @@ struct video_device
 /* Register video devices. Note that if video_register_device fails,
    the release() callback of the video_device structure is *not* called, so
    the caller is responsible for freeing any data. Usually that means that
-   you call video_device_release() on failure.
-
-   Also note that vdev->minor is set to -1 if the registration failed. */
+   you call video_device_release() on failure. */
 int __must_check video_register_device(struct video_device *vdev, int type, int nr);
 
 /* Same as video_register_device, but no warning is issued if the desired
@@ -106,7 +104,7 @@ int __must_check video_register_device(struct video_device *vdev, int type, int
 int __must_check video_register_device_no_warn(struct video_device *vdev, int type, int nr);
 
 /* Unregister video devices. Will do nothing if vdev == NULL or
-   vdev->minor < 0. */
+   video_is_registered() returns false. */
 void video_unregister_device(struct video_device *vdev);
 
 /* helper functions to alloc/release struct video_device, the
@@ -141,9 +139,14 @@ static inline void *video_drvdata(struct file *file)
        return video_get_drvdata(video_devdata(file));
 }
 
-static inline int video_is_unregistered(struct video_device *vdev)
+static inline const char *video_device_node_name(struct video_device *vdev)
+{
+       return dev_name(&vdev->dev);
+}
+
+static inline int video_is_registered(struct video_device *vdev)
 {
-       return test_bit(V4L2_FL_UNREGISTERED, &vdev->flags);
+       return test_bit(V4L2_FL_REGISTERED, &vdev->flags);
 }
 
 #endif /* _V4L2_DEV_H */
index 7a4529defa8841ffa606d8af52d2dac289e5de29..e8ba0f2efbae559887d7f75cfb1d70a19861245c 100644 (file)
@@ -239,6 +239,21 @@ struct v4l2_ioctl_ops {
        int (*vidioc_enum_frameintervals) (struct file *file, void *fh,
                                           struct v4l2_frmivalenum *fival);
 
+       /* DV Timings IOCTLs */
+       int (*vidioc_enum_dv_presets) (struct file *file, void *fh,
+                                      struct v4l2_dv_enum_preset *preset);
+
+       int (*vidioc_s_dv_preset) (struct file *file, void *fh,
+                                  struct v4l2_dv_preset *preset);
+       int (*vidioc_g_dv_preset) (struct file *file, void *fh,
+                                  struct v4l2_dv_preset *preset);
+       int (*vidioc_query_dv_preset) (struct file *file, void *fh,
+                                       struct v4l2_dv_preset *qpreset);
+       int (*vidioc_s_dv_timings) (struct file *file, void *fh,
+                                   struct v4l2_dv_timings *timings);
+       int (*vidioc_g_dv_timings) (struct file *file, void *fh,
+                                   struct v4l2_dv_timings *timings);
+
        /* For other private ioctls */
        long (*vidioc_default)         (struct file *file, void *fh,
                                        int cmd, void *arg);
diff --git a/include/media/v4l2-mediabus.h b/include/media/v4l2-mediabus.h
new file mode 100644 (file)
index 0000000..0dbe02a
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Media Bus API header
+ *
+ * Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef V4L2_MEDIABUS_H
+#define V4L2_MEDIABUS_H
+
+/*
+ * These pixel codes uniquely identify data formats on the media bus. Mostly
+ * they correspond to similarly named V4L2_PIX_FMT_* formats, format 0 is
+ * reserved, V4L2_MBUS_FMT_FIXED shall be used by host-client pairs, where the
+ * data format is fixed. Additionally, "2X8" means that one pixel is transferred
+ * in two 8-bit samples, "BE" or "LE" specify in which order those samples are
+ * transferred over the bus: "LE" means that the least significant bits are
+ * transferred first, "BE" means that the most significant bits are transferred
+ * first, and "PADHI" and "PADLO" define which bits - low or high, in the
+ * incomplete high byte, are filled with padding bits.
+ */
+enum v4l2_mbus_pixelcode {
+       V4L2_MBUS_FMT_FIXED = 1,
+       V4L2_MBUS_FMT_YUYV8_2X8_LE,
+       V4L2_MBUS_FMT_YVYU8_2X8_LE,
+       V4L2_MBUS_FMT_YUYV8_2X8_BE,
+       V4L2_MBUS_FMT_YVYU8_2X8_BE,
+       V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE,
+       V4L2_MBUS_FMT_RGB555_2X8_PADHI_BE,
+       V4L2_MBUS_FMT_RGB565_2X8_LE,
+       V4L2_MBUS_FMT_RGB565_2X8_BE,
+       V4L2_MBUS_FMT_SBGGR8_1X8,
+       V4L2_MBUS_FMT_SBGGR10_1X10,
+       V4L2_MBUS_FMT_GREY8_1X8,
+       V4L2_MBUS_FMT_Y10_1X10,
+       V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE,
+       V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_LE,
+       V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_BE,
+       V4L2_MBUS_FMT_SBGGR10_2X8_PADLO_BE,
+};
+
+/**
+ * struct v4l2_mbus_framefmt - frame format on the media bus
+ * @width:     frame width
+ * @height:    frame height
+ * @code:      data format code
+ * @field:     used interlacing type
+ * @colorspace:        colorspace of the data
+ */
+struct v4l2_mbus_framefmt {
+       __u32                           width;
+       __u32                           height;
+       enum v4l2_mbus_pixelcode        code;
+       enum v4l2_field                 field;
+       enum v4l2_colorspace            colorspace;
+};
+
+#endif
index 00bf17608453360c841d83b03be8b27df7f50faf..9ba99cd39ee7815c121e2be2f06f787bb1bffc30 100644 (file)
@@ -22,6 +22,7 @@
 #define _V4L2_SUBDEV_H
 
 #include <media/v4l2-common.h>
+#include <media/v4l2-mediabus.h>
 
 /* generic v4l2_device notify callback notification values */
 #define V4L2_SUBDEV_IR_RX_NOTIFY               _IOW('v', 0, u32)
@@ -207,7 +208,7 @@ struct v4l2_subdev_audio_ops {
    s_std_output: set v4l2_std_id for video OUTPUT devices. This is ignored by
        video input devices.
 
-  s_crystal_freq: sets the frequency of the crystal used to generate the
+   s_crystal_freq: sets the frequency of the crystal used to generate the
        clocks in Hz. An extra flags field allows device specific configuration
        regarding clock frequency dividers, etc. If not used, then set flags
        to 0. If the frequency is not supported, then -EINVAL is returned.
@@ -217,6 +218,26 @@ struct v4l2_subdev_audio_ops {
 
    s_routing: see s_routing in audio_ops, except this version is for video
        devices.
+
+   s_dv_preset: set dv (Digital Video) preset in the sub device. Similar to
+       s_std()
+
+   query_dv_preset: query dv preset in the sub device. This is similar to
+       querystd()
+
+   s_dv_timings(): Set custom dv timings in the sub device. This is used
+       when sub device is capable of setting detailed timing information
+       in the hardware to generate/detect the video signal.
+
+   g_dv_timings(): Get custom dv timings in the sub device.
+
+   enum_mbus_fmt: enumerate pixel formats, provided by a video data source
+
+   g_mbus_fmt: get the current pixel format, provided by a video data source
+
+   try_mbus_fmt: try to set a pixel format on a video data source
+
+   s_mbus_fmt: set a pixel format on a video data source
  */
 struct v4l2_subdev_video_ops {
        int (*s_routing)(struct v4l2_subdev *sd, u32 input, u32 output, u32 config);
@@ -240,6 +261,33 @@ struct v4l2_subdev_video_ops {
        int (*s_parm)(struct v4l2_subdev *sd, struct v4l2_streamparm *param);
        int (*enum_framesizes)(struct v4l2_subdev *sd, struct v4l2_frmsizeenum *fsize);
        int (*enum_frameintervals)(struct v4l2_subdev *sd, struct v4l2_frmivalenum *fival);
+       int (*s_dv_preset)(struct v4l2_subdev *sd,
+                       struct v4l2_dv_preset *preset);
+       int (*query_dv_preset)(struct v4l2_subdev *sd,
+                       struct v4l2_dv_preset *preset);
+       int (*s_dv_timings)(struct v4l2_subdev *sd,
+                       struct v4l2_dv_timings *timings);
+       int (*g_dv_timings)(struct v4l2_subdev *sd,
+                       struct v4l2_dv_timings *timings);
+       int (*enum_mbus_fmt)(struct v4l2_subdev *sd, int index,
+                            enum v4l2_mbus_pixelcode *code);
+       int (*g_mbus_fmt)(struct v4l2_subdev *sd,
+                         struct v4l2_mbus_framefmt *fmt);
+       int (*try_mbus_fmt)(struct v4l2_subdev *sd,
+                           struct v4l2_mbus_framefmt *fmt);
+       int (*s_mbus_fmt)(struct v4l2_subdev *sd,
+                         struct v4l2_mbus_framefmt *fmt);
+};
+
+/**
+ * struct v4l2_subdev_sensor_ops - v4l2-subdev sensor operations
+ * @g_skip_top_lines: number of lines at the top of the image to be skipped.
+ *                   This is needed for some sensors, which always corrupt
+ *                   several top lines of the output image, or which send their
+ *                   metadata in them.
+ */
+struct v4l2_subdev_sensor_ops {
+       int (*g_skip_top_lines)(struct v4l2_subdev *sd, u32 *lines);
 };
 
 /*
@@ -326,11 +374,12 @@ struct v4l2_subdev_ir_ops {
 };
 
 struct v4l2_subdev_ops {
-       const struct v4l2_subdev_core_ops  *core;
-       const struct v4l2_subdev_tuner_ops *tuner;
-       const struct v4l2_subdev_audio_ops *audio;
-       const struct v4l2_subdev_video_ops *video;
-       const struct v4l2_subdev_ir_ops    *ir;
+       const struct v4l2_subdev_core_ops       *core;
+       const struct v4l2_subdev_tuner_ops      *tuner;
+       const struct v4l2_subdev_audio_ops      *audio;
+       const struct v4l2_subdev_video_ops      *video;
+       const struct v4l2_subdev_ir_ops         *ir;
+       const struct v4l2_subdev_sensor_ops     *sensor;
 };
 
 #define V4L2_SUBDEV_NAME_SIZE 32
index 387cb3cfde7ece63c4b8626ba3beb30ab526444d..39c4a5963e12a8cece4cd7c4d2bd9a8ee192361d 100644 (file)
@@ -113,7 +113,7 @@ dst_metric(const struct dst_entry *dst, int metric)
 static inline u32
 dst_feature(const struct dst_entry *dst, u32 feature)
 {
-       return (dst ? dst_metric(dst, RTAX_FEATURES) & feature : 0);
+       return dst_metric(dst, RTAX_FEATURES) & feature;
 }
 
 static inline u32 dst_mtu(const struct dst_entry *dst)
index e6b9d12d5f620ba939a814c14d8c25ce53aed569..85108cfbb1ae85e09bc762f29665545d87b1a5db 100644 (file)
@@ -337,6 +337,7 @@ enum ip_defrag_users {
        IP_DEFRAG_CALL_RA_CHAIN,
        IP_DEFRAG_CONNTRACK_IN,
        IP_DEFRAG_CONNTRACK_OUT,
+       IP_DEFRAG_CONNTRACK_BRIDGE_IN,
        IP_DEFRAG_VS_IN,
        IP_DEFRAG_VS_OUT,
        IP_DEFRAG_VS_FWD
index 92db8617d18842092c8ee635b33e35cfecba33d9..ccab5946c830da21409190aac9b854f0f905264a 100644 (file)
@@ -350,8 +350,16 @@ static inline int ipv6_prefix_equal(const struct in6_addr *a1,
 
 struct inet_frag_queue;
 
+enum ip6_defrag_users {
+       IP6_DEFRAG_LOCAL_DELIVER,
+       IP6_DEFRAG_CONNTRACK_IN,
+       IP6_DEFRAG_CONNTRACK_OUT,
+       IP6_DEFRAG_CONNTRACK_BRIDGE_IN,
+};
+
 struct ip6_create_arg {
        __be32 id;
+       u32 user;
        struct in6_addr *src;
        struct in6_addr *dst;
 };
index 2aff4906b2aeec8011b9de98e744d0b396a8232e..0bf369752274f39658ded037e961900895431058 100644 (file)
@@ -547,7 +547,6 @@ enum mac80211_rx_flags {
  *     unspecified depending on the hardware capabilities flags
  *     @IEEE80211_HW_SIGNAL_*
  * @noise: noise when receiving this frame, in dBm.
- * @qual: overall signal quality indication, in percent (0-100).
  * @antenna: antenna used
  * @rate_idx: index of data rate into band's supported rates or MCS index if
  *     HT rates are use (RX_FLAG_HT)
@@ -559,7 +558,6 @@ struct ieee80211_rx_status {
        int freq;
        int signal;
        int noise;
-       int __deprecated qual;
        int antenna;
        int rate_idx;
        int flag;
@@ -1737,6 +1735,12 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw,
        local_bh_enable();
 }
 
+/*
+ * The TX headroom reserved by mac80211 for its own tx_status functions.
+ * This is enough for the radiotap header.
+ */
+#define IEEE80211_TX_STATUS_HEADROOM   13
+
 /**
  * ieee80211_tx_status - transmit status callback
  *
index abc55ad75c2b849b1b22e036275133785588c151..1ee717eb5b099f6fa1fc782506c05e0dd59addb8 100644 (file)
@@ -9,7 +9,7 @@ extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6;
 
 extern int nf_ct_frag6_init(void);
 extern void nf_ct_frag6_cleanup(void);
-extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb);
+extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user);
 extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
                               struct net_device *in,
                               struct net_device *out,
index 1b6f7d348ceed85dac011ccfc8bc7f0a1dfee1cb..34f5cc24d903332f9c29f2cb0484ade46dad0f54 100644 (file)
@@ -408,8 +408,7 @@ extern int                  tcp_recvmsg(struct kiocb *iocb, struct sock *sk,
 extern void                    tcp_parse_options(struct sk_buff *skb,
                                                  struct tcp_options_received *opt_rx,
                                                  u8 **hvpp,
-                                                 int estab,
-                                                 struct dst_entry *dst);
+                                                 int estab);
 
 extern u8                      *tcp_parse_md5sig_option(struct tcphdr *th);
 
index 483057b2f4b40487805d84163c5013a385dc04aa..fa0d52b8e622cd55c0cc1f8f58e0e9e53231c969 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <linux/in.h>
 #include <linux/in6.h>
+#include <linux/if_arp.h>
 #include <linux/netdevice.h>
 #include <linux/socket.h>
 #include <rdma/ib_verbs.h>
@@ -60,8 +61,8 @@ struct rdma_dev_addr {
        unsigned char src_dev_addr[MAX_ADDR_LEN];
        unsigned char dst_dev_addr[MAX_ADDR_LEN];
        unsigned char broadcast[MAX_ADDR_LEN];
-       enum rdma_node_type dev_type;
-       struct net_device *src_dev;
+       unsigned short dev_type;
+       int bound_dev_if;
 };
 
 /**
@@ -121,40 +122,29 @@ static inline void ib_addr_get_mgid(struct rdma_dev_addr *dev_addr,
        memcpy(gid, dev_addr->broadcast + 4, sizeof *gid);
 }
 
-static inline void ib_addr_get_sgid(struct rdma_dev_addr *dev_addr,
-                                   union ib_gid *gid)
+static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr)
 {
-       memcpy(gid, dev_addr->src_dev_addr + 4, sizeof *gid);
+       return dev_addr->dev_type == ARPHRD_INFINIBAND ? 4 : 0;
 }
 
-static inline void ib_addr_set_sgid(struct rdma_dev_addr *dev_addr,
-                                   union ib_gid *gid)
+static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
 {
-       memcpy(dev_addr->src_dev_addr + 4, gid, sizeof *gid);
+       memcpy(gid, dev_addr->src_dev_addr + rdma_addr_gid_offset(dev_addr), sizeof *gid);
 }
 
-static inline void ib_addr_get_dgid(struct rdma_dev_addr *dev_addr,
-                                   union ib_gid *gid)
+static inline void rdma_addr_set_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
 {
-       memcpy(gid, dev_addr->dst_dev_addr + 4, sizeof *gid);
+       memcpy(dev_addr->src_dev_addr + rdma_addr_gid_offset(dev_addr), gid, sizeof *gid);
 }
 
-static inline void ib_addr_set_dgid(struct rdma_dev_addr *dev_addr,
-                                   union ib_gid *gid)
+static inline void rdma_addr_get_dgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
 {
-       memcpy(dev_addr->dst_dev_addr + 4, gid, sizeof *gid);
+       memcpy(gid, dev_addr->dst_dev_addr + rdma_addr_gid_offset(dev_addr), sizeof *gid);
 }
 
-static inline void iw_addr_get_sgid(struct rdma_dev_addr *dev_addr,
-                                   union ib_gid *gid)
-{
-       memcpy(gid, dev_addr->src_dev_addr, sizeof *gid);
-}
-
-static inline void iw_addr_get_dgid(struct rdma_dev_addr *dev_addr,
-                                   union ib_gid *gid)
+static inline void rdma_addr_set_dgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
 {
-       memcpy(gid, dev_addr->dst_dev_addr, sizeof *gid);
+       memcpy(dev_addr->dst_dev_addr + rdma_addr_gid_offset(dev_addr), gid, sizeof *gid);
 }
 
 #endif /* IB_ADDR_H */
index 3841c1aff692556ed4518bfd79c56cd4f6fdce59..1082afaed15878aff3e37317501377f96604b746 100644 (file)
@@ -379,4 +379,10 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
                         struct ib_sa_path_rec *rec,
                         struct ib_ah_attr *ah_attr);
 
+/**
+ * ib_sa_unpack_path - Convert a path record from MAD format to struct
+ * ib_sa_path_rec.
+ */
+void ib_sa_unpack_path(void *attribute, struct ib_sa_path_rec *rec);
+
 #endif /* IB_SA_H */
index 659120157e14b320c13c16e09fe2dc331db92514..cfc7c9ba781e629d0b30a6b5e3d6d4ead7112479 100644 (file)
 
 #include <linux/types.h>
 
+enum {
+       IB_PATH_GMP             = 1,
+       IB_PATH_PRIMARY         = (1<<1),
+       IB_PATH_ALTERNATE       = (1<<2),
+       IB_PATH_OUTBOUND        = (1<<3),
+       IB_PATH_INBOUND         = (1<<4),
+       IB_PATH_INBOUND_REVERSE = (1<<5),
+       IB_PATH_BIDIRECTIONAL   = IB_PATH_OUTBOUND | IB_PATH_INBOUND_REVERSE
+};
+
+struct ib_path_rec_data {
+       __u32   flags;
+       __u32   reserved;
+       __u32   path_rec[16];
+};
+
 struct ib_user_path_rec {
        __u8    dgid[16];
        __u8    sgid[16];
index c179318edd92dff17813627160ae9c973fafa08a..09509edb1c5fde72e0cec15d7a6f3391076c188b 100644 (file)
@@ -1425,6 +1425,11 @@ int ib_destroy_qp(struct ib_qp *qp);
  * @send_wr: A list of work requests to post on the send queue.
  * @bad_send_wr: On an immediate failure, this parameter will reference
  *   the work request that failed to be posted on the QP.
+ *
+ * While IBA Vol. 1 section 11.4.1.1 specifies that if an immediate
+ * error is returned, the QP state shall not be affected,
+ * ib_post_send() will return an immediate error after queueing any
+ * earlier work requests in the list.
  */
 static inline int ib_post_send(struct ib_qp *qp,
                               struct ib_send_wr *send_wr,
index c55705460b87f1f57995798c6f2aa6a63bc71aaf..1d165022c02d55880b16b42111ba590983141bab 100644 (file)
@@ -215,12 +215,14 @@ struct rdma_ucm_event_resp {
 
 /* Option levels */
 enum {
-       RDMA_OPTION_ID          = 0
+       RDMA_OPTION_ID          = 0,
+       RDMA_OPTION_IB          = 1
 };
 
 /* Option details */
 enum {
-       RDMA_OPTION_ID_TOS      = 0
+       RDMA_OPTION_ID_TOS      = 0,
+       RDMA_OPTION_IB_PATH     = 1
 };
 
 struct rdma_ucm_set_option {
index 7394e3bc8f4ba84ed723ac7b257b97ec08e65e3a..ff92b46f5153455501d4446648bfeafe712cde10 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/mutex.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
+#include <linux/kfifo.h>
 #include <scsi/iscsi_proto.h>
 #include <scsi/iscsi_if.h>
 #include <scsi/scsi_transport_iscsi.h>
@@ -231,7 +232,7 @@ struct iscsi_conn {
 };
 
 struct iscsi_pool {
-       struct kfifo            *queue;         /* FIFO Queue */
+       struct kfifo            queue;          /* FIFO Queue */
        void                    **pool;         /* Pool of elements */
        int                     max;            /* Max number of elements */
 };
index 9e3182e659dbda6f7f86237757102aa53ca00b39..741ae7ed43947e484b22781cce13383ca1197461 100644 (file)
@@ -80,7 +80,7 @@ struct iscsi_tcp_task {
        int                     data_offset;
        struct iscsi_r2t_info   *r2t;           /* in progress solict R2T */
        struct iscsi_pool       r2tpool;
-       struct kfifo            *r2tqueue;
+       struct kfifo            r2tqueue;
        void                    *dd_data;
 };
 
index ba615e4c1d7c324ee93e59c78c17f027c3fb3dd4..f4105c91af532d05de69b80cf513f52392b1a4a6 100644 (file)
@@ -2,6 +2,7 @@
 #define __LIBSRP_H__
 
 #include <linux/list.h>
+#include <linux/kfifo.h>
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_host.h>
 #include <scsi/srp.h>
@@ -21,7 +22,7 @@ struct srp_buf {
 struct srp_queue {
        void *pool;
        void *items;
-       struct kfifo *queue;
+       struct kfifo queue;
        spinlock_t lock;
 };
 
index 39d6d1097153952a7eb9ffb36cfcd1d232de5ba6..a8f37012663209020b30baeecabde62512465993 100644 (file)
@@ -142,6 +142,7 @@ struct osd_request {
        struct _osd_io_info {
                struct bio *bio;
                u64 total_bytes;
+               u64 residual;
                struct request *req;
                struct _osd_req_data_segment *last_seg;
                u8 *pad_buff;
@@ -150,12 +151,14 @@ struct osd_request {
        gfp_t alloc_flags;
        unsigned timeout;
        unsigned retries;
+       unsigned sense_len;
        u8 sense[OSD_MAX_SENSE_LEN];
        enum osd_attributes_mode attributes_mode;
 
        osd_req_done_fn *async_done;
        void *async_private;
        int async_error;
+       int req_errors;
 };
 
 static inline bool osd_req_is_ver1(struct osd_request *or)
@@ -297,8 +300,6 @@ enum osd_err_priority {
 };
 
 struct osd_sense_info {
-       u64 out_resid;          /* Zero on success otherwise out residual */
-       u64 in_resid;           /* Zero on success otherwise in residual */
        enum osd_err_priority osd_err_pri;
 
        int key;                /* one of enum scsi_sense_keys */
index d1b3de9c1a714f7624956c01fb60bd22898d4c6a..73523151a731f61598702d7ccd2ab51fefb39aa7 100644 (file)
@@ -436,10 +436,6 @@ ftrace_define_fields_##call(struct ftrace_event_call *event_call)  \
        struct ftrace_raw_##call field;                                 \
        int ret;                                                        \
                                                                        \
-       ret = trace_define_common_fields(event_call);                   \
-       if (ret)                                                        \
-               return ret;                                             \
-                                                                       \
        tstruct;                                                        \
                                                                        \
        return ret;                                                     \
@@ -559,13 +555,7 @@ static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
  *
  * static int ftrace_reg_event_<call>(struct ftrace_event_call *unused)
  * {
- *     int ret;
- *
- *     ret = register_trace_<call>(ftrace_event_<call>);
- *     if (!ret)
- *             pr_info("event trace: Could not activate trace point "
- *                     "probe to  <call>");
- *     return ret;
+ *     return register_trace_<call>(ftrace_event_<call>);
  * }
  *
  * static void ftrace_unreg_event_<call>(struct ftrace_event_call *unused)
@@ -623,23 +613,12 @@ static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
  *     .trace                  = ftrace_raw_output_<call>, <-- stage 2
  * };
  *
- * static int ftrace_raw_init_event_<call>(struct ftrace_event_call *unused)
- * {
- *     int id;
- *
- *     id = register_ftrace_event(&ftrace_event_type_<call>);
- *     if (!id)
- *             return -ENODEV;
- *     event_<call>.id = id;
- *     return 0;
- * }
- *
  * static struct ftrace_event_call __used
  * __attribute__((__aligned__(4)))
  * __attribute__((section("_ftrace_events"))) event_<call> = {
  *     .name                   = "<call>",
  *     .system                 = "<system>",
- *     .raw_init               = ftrace_raw_init_event_<call>,
+ *     .raw_init               = trace_event_raw_init,
  *     .regfunc                = ftrace_reg_event_<call>,
  *     .unregfunc              = ftrace_unreg_event_<call>,
  *     .show_format            = ftrace_format_<call>,
@@ -647,13 +626,9 @@ static void ftrace_profile_disable_##name(struct ftrace_event_call *unused)\
  *
  */
 
-#undef TP_FMT
-#define TP_FMT(fmt, args...)   fmt "\n", ##args
-
 #ifdef CONFIG_EVENT_PROFILE
 
 #define _TRACE_PROFILE_INIT(call)                                      \
-       .profile_count = ATOMIC_INIT(-1),                               \
        .profile_enable = ftrace_profile_enable_##call,                 \
        .profile_disable = ftrace_profile_disable_##call,
 
@@ -728,13 +703,7 @@ static void ftrace_raw_event_##call(proto)                         \
                                                                        \
 static int ftrace_raw_reg_event_##call(struct ftrace_event_call *unused)\
 {                                                                      \
-       int ret;                                                        \
-                                                                       \
-       ret = register_trace_##call(ftrace_raw_event_##call);           \
-       if (ret)                                                        \
-               pr_info("event trace: Could not activate trace point "  \
-                       "probe to " #call "\n");                        \
-       return ret;                                                     \
+       return register_trace_##call(ftrace_raw_event_##call);          \
 }                                                                      \
                                                                        \
 static void ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused)\
@@ -744,19 +713,7 @@ static void ftrace_raw_unreg_event_##call(struct ftrace_event_call *unused)\
                                                                        \
 static struct trace_event ftrace_event_type_##call = {                 \
        .trace                  = ftrace_raw_output_##call,             \
-};                                                                     \
-                                                                       \
-static int ftrace_raw_init_event_##call(struct ftrace_event_call *unused)\
-{                                                                      \
-       int id;                                                         \
-                                                                       \
-       id = register_ftrace_event(&ftrace_event_type_##call);          \
-       if (!id)                                                        \
-               return -ENODEV;                                         \
-       event_##call.id = id;                                           \
-       INIT_LIST_HEAD(&event_##call.fields);                           \
-       return 0;                                                       \
-}
+};
 
 #undef DEFINE_EVENT_PRINT
 #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
@@ -776,7 +733,7 @@ __attribute__((section("_ftrace_events"))) event_##call = {         \
        .name                   = #call,                                \
        .system                 = __stringify(TRACE_SYSTEM),            \
        .event                  = &ftrace_event_type_##call,            \
-       .raw_init               = ftrace_raw_init_event_##call,         \
+       .raw_init               = trace_event_raw_init,                 \
        .regfunc                = ftrace_raw_reg_event_##call,          \
        .unregfunc              = ftrace_raw_unreg_event_##call,        \
        .show_format            = ftrace_format_##template,             \
@@ -793,7 +750,7 @@ __attribute__((section("_ftrace_events"))) event_##call = {         \
        .name                   = #call,                                \
        .system                 = __stringify(TRACE_SYSTEM),            \
        .event                  = &ftrace_event_type_##call,            \
-       .raw_init               = ftrace_raw_init_event_##call,         \
+       .raw_init               = trace_event_raw_init,                 \
        .regfunc                = ftrace_raw_reg_event_##call,          \
        .unregfunc              = ftrace_raw_unreg_event_##call,        \
        .show_format            = ftrace_format_##call,                 \
@@ -953,7 +910,6 @@ end:                                                                        \
        perf_swevent_put_recursion_context(rctx);                       \
 end_recursion:                                                         \
        local_irq_restore(irq_flags);                                   \
-                                                                       \
 }
 
 #undef DEFINE_EVENT
index c051a50ed528292df75924167abb4ebdc8fa5181..89d43b3d4cb9e3fe713fe5b8eaeb2de0616eb9fa 100644 (file)
@@ -38,6 +38,7 @@ struct da8xx_lcdc_platform_data {
        const char manu_name[10];
        void *controller_data;
        const char type[25];
+       void (*panel_power_ctrl)(int);
 };
 
 struct lcd_ctrl_config {
index 25144ab22b95615df87e58f317a7f5c97a8b2a4b..288205457713bab6191e42e7a8f99bd01861ec51 100644 (file)
@@ -50,6 +50,8 @@ struct sh_mobile_lcdc_board_cfg {
        void *board_data;
        int (*setup_sys)(void *board_data, void *sys_ops_handle,
                         struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
+       void (*start_transfer)(void *board_data, void *sys_ops_handle,
+                              struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
        void (*display_on)(void *board_data);
        void (*display_off)(void *board_data);
 };
index 54c655ce9c049f56da32c4157917e0b6caffd48f..a23da9f0180341dd0cb8809f6108a2911336897a 100644 (file)
@@ -1079,6 +1079,28 @@ config SLOB
 
 endchoice
 
+config MMAP_ALLOW_UNINITIALIZED
+       bool "Allow mmapped anonymous memory to be uninitialized"
+       depends on EMBEDDED && !MMU
+       default n
+       help
+         Normally, and according to the Linux spec, anonymous memory obtained
+         from mmap() has it's contents cleared before it is passed to
+         userspace.  Enabling this config option allows you to request that
+         mmap() skip that if it is given an MAP_UNINITIALIZED flag, thus
+         providing a huge performance boost.  If this option is not enabled,
+         then the flag will be ignored.
+
+         This is taken advantage of by uClibc's malloc(), and also by
+         ELF-FDPIC binfmt's brk and stack allocator.
+
+         Because of the obvious security issues, this option should only be
+         enabled on embedded devices where you control what is run in
+         userspace.  Since that isn't generally a problem on no-MMU systems,
+         it is normally safe to say Y here.
+
+         See Documentation/nommu-mmap.txt for more information.
+
 config PROFILING
        bool "Profiling support (EXPERIMENTAL)"
        help
index 4a243df426f70b9f3fbe366f1b94dbb8f4cdd1cf..0bf677aa0872f8c9f61c411b5adb6f1c395a8910 100644 (file)
@@ -15,12 +15,8 @@ mounts-$(CONFIG_BLK_DEV_RAM) += do_mounts_rd.o
 mounts-$(CONFIG_BLK_DEV_INITRD)        += do_mounts_initrd.o
 mounts-$(CONFIG_BLK_DEV_MD)    += do_mounts_md.o
 
-# files to be removed upon make clean
-clean-files := ../include/linux/compile.h
-
 # dependencies on generated files need to be listed explicitly
-
-$(obj)/version.o: include/linux/compile.h
+$(obj)/version.o: include/generated/compile.h
 
 # compile.h changes depending on hostname, generation number, etc,
 # so we regenerate it always.
@@ -30,7 +26,7 @@ $(obj)/version.o: include/linux/compile.h
        chk_compile.h = :
  quiet_chk_compile.h = echo '  CHK     $@'
 silent_chk_compile.h = :
-include/linux/compile.h: FORCE
+include/generated/compile.h: FORCE
        @$($(quiet)chk_compile.h)
        $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
        "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)"
index 4c00edc59689034895ad6728c9b5b4505a8386b3..b37d34beb90bb0b3f490731d641ab3a2a07e45d7 100644 (file)
@@ -413,7 +413,7 @@ static unsigned my_inptr;   /* index of next byte to be processed in inbuf */
 
 static char * __init unpack_to_rootfs(char *buf, unsigned len)
 {
-       int written;
+       int written, res;
        decompress_fn decompress;
        const char *compress_name;
        static __initdata char msg_buf[64];
@@ -445,10 +445,12 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len)
                }
                this_header = 0;
                decompress = decompress_method(buf, len, &compress_name);
-               if (decompress)
-                       decompress(buf, len, NULL, flush_buffer, NULL,
+               if (decompress) {
+                       res = decompress(buf, len, NULL, flush_buffer, NULL,
                                   &my_inptr, error);
-               else if (compress_name) {
+                       if (res)
+                               error("decompressor failed");
+               } else if (compress_name) {
                        if (!message) {
                                snprintf(msg_buf, sizeof msg_buf,
                                         "compression method %s not configured",
index 4051d75dd2d64e765b5d2856eac0da7fa796ef95..dac44a9356a52637e56669989c303f0b792aaa11 100644 (file)
@@ -369,12 +369,6 @@ static void __init smp_init(void)
 {
        unsigned int cpu;
 
-       /*
-        * Set up the current CPU as possible to migrate to.
-        * The other ones will be done by cpu_up/cpu_down()
-        */
-       set_cpu_active(smp_processor_id(), true);
-
        /* FIXME: This should be done in userspace --RR */
        for_each_present_cpu(cpu) {
                if (num_online_cpus() >= setup_max_cpus)
@@ -486,6 +480,7 @@ static void __init boot_cpu_init(void)
        int cpu = smp_processor_id();
        /* Mark the boot cpu "present", "online" etc for SMP and UP case */
        set_cpu_online(cpu, true);
+       set_cpu_active(cpu, true);
        set_cpu_present(cpu, true);
        set_cpu_possible(cpu, true);
 }
@@ -691,10 +686,10 @@ asmlinkage void __init start_kernel(void)
 static void __init do_ctors(void)
 {
 #ifdef CONFIG_CONSTRUCTORS
-       ctor_fn_t *call = (ctor_fn_t *) __ctors_start;
+       ctor_fn_t *fn = (ctor_fn_t *) __ctors_start;
 
-       for (; call < (ctor_fn_t *) __ctors_end; call++)
-               (*call)();
+       for (; fn < (ctor_fn_t *) __ctors_end; fn++)
+               (*fn)();
 #endif
 }
 
@@ -755,10 +750,10 @@ extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];
 
 static void __init do_initcalls(void)
 {
-       initcall_t *call;
+       initcall_t *fn;
 
-       for (call = __early_initcall_end; call < __initcall_end; call++)
-               do_one_initcall(*call);
+       for (fn = __early_initcall_end; fn < __initcall_end; fn++)
+               do_one_initcall(*fn);
 
        /* Make sure there is no pending stuff from the initcall sequence */
        flush_scheduled_work();
@@ -785,10 +780,10 @@ static void __init do_basic_setup(void)
 
 static void __init do_pre_smp_initcalls(void)
 {
-       initcall_t *call;
+       initcall_t *fn;
 
-       for (call = __initcall_start; call < __early_initcall_end; call++)
-               do_one_initcall(*call);
+       for (fn = __initcall_start; fn < __early_initcall_end; fn++)
+               do_one_initcall(*fn);
 }
 
 static void run_init_process(char *init_filename)
index 52a8b98642b8fb78343dfd63e20d1f448acb5866..adff586401a50c2e6de2ee145ae6a047fd03c6ba 100644 (file)
@@ -6,11 +6,11 @@
  *  May be freely distributed as part of Linux.
  */
 
-#include <linux/compile.h>
+#include <generated/compile.h>
 #include <linux/module.h>
 #include <linux/uts.h>
 #include <linux/utsname.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/version.h>
 
 #ifndef CONFIG_KALLSYMS
index ee9d69707c0afafc9d5a6d0d9b46146e4fafe3e4..c79bd57353e73e0e68af8ca8fe1c41da787c7a61 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/nsproxy.h>
 #include <linux/pid.h>
 #include <linux/ipc_namespace.h>
-#include <linux/ima.h>
 
 #include <net/sock.h>
 #include "util.h"
@@ -734,7 +733,6 @@ SYSCALL_DEFINE4(mq_open, const char __user *, u_name, int, oflag, mode_t, mode,
                error = PTR_ERR(filp);
                goto out_putfd;
        }
-       ima_counts_get(filp);
 
        fd_install(fd, filp);
        goto out_upsem;
index 085bd58f2f07a348746f917dc491031f3f1c19af..af42ef8900a6418e3dce715316800e1bbb6da4df 100644 (file)
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -125,6 +125,7 @@ void msg_init_ns(struct ipc_namespace *ns)
 void msg_exit_ns(struct ipc_namespace *ns)
 {
        free_ipcs(ns, &msg_ids(ns), freeque);
+       idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr);
 }
 #endif
 
index 87c2b641fd7b475b192adf281fcdc1f5cf249893..dbef95b1594122c2a6276d504d206805d39879f7 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -129,6 +129,7 @@ void sem_init_ns(struct ipc_namespace *ns)
 void sem_exit_ns(struct ipc_namespace *ns)
 {
        free_ipcs(ns, &sem_ids(ns), freeary);
+       idr_destroy(&ns->ids[IPC_SEM_IDS].ipcs_idr);
 }
 #endif
 
@@ -240,6 +241,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
        key_t key = params->key;
        int nsems = params->u.nsems;
        int semflg = params->flg;
+       int i;
 
        if (!nsems)
                return -EINVAL;
@@ -272,6 +274,11 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
        ns->used_sems += nsems;
 
        sma->sem_base = (struct sem *) &sma[1];
+
+       for (i = 0; i < nsems; i++)
+               INIT_LIST_HEAD(&sma->sem_base[i].sem_pending);
+
+       sma->complex_count = 0;
        INIT_LIST_HEAD(&sma->sem_pending);
        INIT_LIST_HEAD(&sma->list_id);
        sma->sem_nsems = nsems;
@@ -397,63 +404,109 @@ undo:
        return result;
 }
 
-/* Go through the pending queue for the indicated semaphore
- * looking for tasks that can be completed.
+/*
+ * Wake up a process waiting on the sem queue with a given error.
+ * The queue is invalid (may not be accessed) after the function returns.
  */
-static void update_queue (struct sem_array * sma)
+static void wake_up_sem_queue(struct sem_queue *q, int error)
 {
-       int error;
-       struct sem_queue * q;
+       /*
+        * Hold preempt off so that we don't get preempted and have the
+        * wakee busy-wait until we're scheduled back on. We're holding
+        * locks here so it may not strictly be needed, however if the
+        * locks become preemptible then this prevents such a problem.
+        */
+       preempt_disable();
+       q->status = IN_WAKEUP;
+       wake_up_process(q->sleeper);
+       /* hands-off: q can disappear immediately after writing q->status. */
+       smp_wmb();
+       q->status = error;
+       preempt_enable();
+}
+
+static void unlink_queue(struct sem_array *sma, struct sem_queue *q)
+{
+       list_del(&q->list);
+       if (q->nsops == 1)
+               list_del(&q->simple_list);
+       else
+               sma->complex_count--;
+}
+
+
+/**
+ * update_queue(sma, semnum): Look for tasks that can be completed.
+ * @sma: semaphore array.
+ * @semnum: semaphore that was modified.
+ *
+ * update_queue must be called after a semaphore in a semaphore array
+ * was modified. If multiple semaphore were modified, then @semnum
+ * must be set to -1.
+ */
+static void update_queue(struct sem_array *sma, int semnum)
+{
+       struct sem_queue *q;
+       struct list_head *walk;
+       struct list_head *pending_list;
+       int offset;
+
+       /* if there are complex operations around, then knowing the semaphore
+        * that was modified doesn't help us. Assume that multiple semaphores
+        * were modified.
+        */
+       if (sma->complex_count)
+               semnum = -1;
+
+       if (semnum == -1) {
+               pending_list = &sma->sem_pending;
+               offset = offsetof(struct sem_queue, list);
+       } else {
+               pending_list = &sma->sem_base[semnum].sem_pending;
+               offset = offsetof(struct sem_queue, simple_list);
+       }
+
+again:
+       walk = pending_list->next;
+       while (walk != pending_list) {
+               int error, alter;
+
+               q = (struct sem_queue *)((char *)walk - offset);
+               walk = walk->next;
+
+               /* If we are scanning the single sop, per-semaphore list of
+                * one semaphore and that semaphore is 0, then it is not
+                * necessary to scan the "alter" entries: simple increments
+                * that affect only one entry succeed immediately and cannot
+                * be in the  per semaphore pending queue, and decrements
+                * cannot be successful if the value is already 0.
+                */
+               if (semnum != -1 && sma->sem_base[semnum].semval == 0 &&
+                               q->alter)
+                       break;
 
-       q = list_entry(sma->sem_pending.next, struct sem_queue, list);
-       while (&q->list != &sma->sem_pending) {
                error = try_atomic_semop(sma, q->sops, q->nsops,
                                         q->undo, q->pid);
 
                /* Does q->sleeper still need to sleep? */
-               if (error <= 0) {
-                       struct sem_queue *n;
-
-                       /*
-                        * Continue scanning. The next operation
-                        * that must be checked depends on the type of the
-                        * completed operation:
-                        * - if the operation modified the array, then
-                        *   restart from the head of the queue and
-                        *   check for threads that might be waiting
-                        *   for semaphore values to become 0.
-                        * - if the operation didn't modify the array,
-                        *   then just continue.
-                        * The order of list_del() and reading ->next
-                        * is crucial: In the former case, the list_del()
-                        * must be done first [because we might be the
-                        * first entry in ->sem_pending], in the latter
-                        * case the list_del() must be done last
-                        * [because the list is invalid after the list_del()]
-                        */
-                       if (q->alter) {
-                               list_del(&q->list);
-                               n = list_entry(sma->sem_pending.next,
-                                               struct sem_queue, list);
-                       } else {
-                               n = list_entry(q->list.next, struct sem_queue,
-                                               list);
-                               list_del(&q->list);
-                       }
-
-                       /* wake up the waiting thread */
-                       q->status = IN_WAKEUP;
+               if (error > 0)
+                       continue;
 
-                       wake_up_process(q->sleeper);
-                       /* hands-off: q will disappear immediately after
-                        * writing q->status.
-                        */
-                       smp_wmb();
-                       q->status = error;
-                       q = n;
-               } else {
-                       q = list_entry(q->list.next, struct sem_queue, list);
-               }
+               unlink_queue(sma, q);
+
+               /*
+                * The next operation that must be checked depends on the type
+                * of the completed operation:
+                * - if the operation modified the array, then restart from the
+                *   head of the queue and check for threads that might be
+                *   waiting for the new semaphore values.
+                * - if the operation didn't modify the array, then just
+                *   continue.
+                */
+               alter = q->alter;
+               wake_up_sem_queue(q, error);
+               if (alter && !error)
+                       goto again;
        }
 }
 
@@ -533,12 +586,8 @@ static void freeary(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
 
        /* Wake up all pending processes and let them fail with EIDRM. */
        list_for_each_entry_safe(q, tq, &sma->sem_pending, list) {
-               list_del(&q->list);
-
-               q->status = IN_WAKEUP;
-               wake_up_process(q->sleeper); /* doesn't sleep */
-               smp_wmb();
-               q->status = -EIDRM;     /* hands-off q */
+               unlink_queue(sma, q);
+               wake_up_sem_queue(q, -EIDRM);
        }
 
        /* Remove the semaphore set from the IDR */
@@ -575,7 +624,7 @@ static unsigned long copy_semid_to_user(void __user *buf, struct semid64_ds *in,
 static int semctl_nolock(struct ipc_namespace *ns, int semid,
                         int cmd, int version, union semun arg)
 {
-       int err = -EINVAL;
+       int err;
        struct sem_array *sma;
 
        switch(cmd) {
@@ -652,7 +701,6 @@ static int semctl_nolock(struct ipc_namespace *ns, int semid,
        default:
                return -EINVAL;
        }
-       return err;
 out_unlock:
        sem_unlock(sma);
        return err;
@@ -759,7 +807,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                }
                sma->sem_ctime = get_seconds();
                /* maybe some queued-up processes were waiting for this */
-               update_queue(sma);
+               update_queue(sma, -1);
                err = 0;
                goto out_unlock;
        }
@@ -801,7 +849,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                curr->sempid = task_tgid_vnr(current);
                sma->sem_ctime = get_seconds();
                /* maybe some queued-up processes were waiting for this */
-               update_queue(sma);
+               update_queue(sma, semnum);
                err = 0;
                goto out_unlock;
        }
@@ -961,17 +1009,31 @@ static inline int get_undo_list(struct sem_undo_list **undo_listp)
        return 0;
 }
 
-static struct sem_undo *lookup_undo(struct sem_undo_list *ulp, int semid)
+static struct sem_undo *__lookup_undo(struct sem_undo_list *ulp, int semid)
 {
-       struct sem_undo *walk;
+       struct sem_undo *un;
 
-       list_for_each_entry_rcu(walk, &ulp->list_proc, list_proc) {
-               if (walk->semid == semid)
-                       return walk;
+       list_for_each_entry_rcu(un, &ulp->list_proc, list_proc) {
+               if (un->semid == semid)
+                       return un;
        }
        return NULL;
 }
 
+static struct sem_undo *lookup_undo(struct sem_undo_list *ulp, int semid)
+{
+       struct sem_undo *un;
+
+       assert_spin_locked(&ulp->lock);
+
+       un = __lookup_undo(ulp, semid);
+       if (un) {
+               list_del_rcu(&un->list_proc);
+               list_add_rcu(&un->list_proc, &ulp->list_proc);
+       }
+       return un;
+}
+
 /**
  * find_alloc_undo - Lookup (and if not present create) undo array
  * @ns: namespace
@@ -1163,7 +1225,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
        error = try_atomic_semop (sma, sops, nsops, un, task_tgid_vnr(current));
        if (error <= 0) {
                if (alter && error == 0)
-                       update_queue (sma);
+                       update_queue(sma, (nsops == 1) ? sops[0].sem_num : -1);
+
                goto out_unlock_free;
        }
 
@@ -1181,6 +1244,19 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
        else
                list_add(&queue.list, &sma->sem_pending);
 
+       if (nsops == 1) {
+               struct sem *curr;
+               curr = &sma->sem_base[sops->sem_num];
+
+               if (alter)
+                       list_add_tail(&queue.simple_list, &curr->sem_pending);
+               else
+                       list_add(&queue.simple_list, &curr->sem_pending);
+       } else {
+               INIT_LIST_HEAD(&queue.simple_list);
+               sma->complex_count++;
+       }
+
        queue.status = -EINTR;
        queue.sleeper = current;
        current->state = TASK_INTERRUPTIBLE;
@@ -1222,7 +1298,7 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
         */
        if (timeout && jiffies_left == 0)
                error = -EAGAIN;
-       list_del(&queue.list);
+       unlink_queue(sma, &queue);
 
 out_unlock_free:
        sem_unlock(sma);
@@ -1307,7 +1383,7 @@ void exit_sem(struct task_struct *tsk)
                if (IS_ERR(sma))
                        continue;
 
-               un = lookup_undo(ulp, semid);
+               un = __lookup_undo(ulp, semid);
                if (un == NULL) {
                        /* exit_sem raced with IPC_RMID+semget() that created
                         * exactly the same semid. Nothing to do.
@@ -1351,7 +1427,7 @@ void exit_sem(struct task_struct *tsk)
                }
                sma->sem_otime = get_seconds();
                /* maybe some queued-up processes were waiting for this */
-               update_queue(sma);
+               update_queue(sma, -1);
                sem_unlock(sma);
 
                call_rcu(&un->rcu, free_un);
@@ -1365,7 +1441,7 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it)
        struct sem_array *sma = it;
 
        return seq_printf(s,
-                         "%10d %10d  %4o %10lu %5u %5u %5u %5u %10lu %10lu\n",
+                         "%10d %10d  %4o %10u %5u %5u %5u %5u %10lu %10lu\n",
                          sma->sem_perm.key,
                          sma->sem_perm.id,
                          sma->sem_perm.mode,
index 11bec626c228c98d5f3e0512f9c6f0dd40f424dc..92fe9236258b15192fe78ae615891c624b91c036 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -39,7 +39,6 @@
 #include <linux/nsproxy.h>
 #include <linux/mount.h>
 #include <linux/ipc_namespace.h>
-#include <linux/ima.h>
 
 #include <asm/uaccess.h>
 
@@ -101,6 +100,7 @@ static void do_shm_rmid(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
 void shm_exit_ns(struct ipc_namespace *ns)
 {
        free_ipcs(ns, &shm_ids(ns), do_shm_rmid);
+       idr_destroy(&ns->ids[IPC_SHM_IDS].ipcs_idr);
 }
 #endif
 
@@ -878,8 +878,8 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
        if (err)
                goto out_unlock;
 
-       path.dentry = dget(shp->shm_file->f_path.dentry);
-       path.mnt    = shp->shm_file->f_path.mnt;
+       path = shp->shm_file->f_path;
+       path_get(&path);
        shp->shm_nattch++;
        size = i_size_read(path.dentry->d_inode);
        shm_unlock(shp);
@@ -889,13 +889,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
        if (!sfd)
                goto out_put_dentry;
 
-       file = alloc_file(path.mnt, path.dentry, f_mode,
-                       is_file_hugepages(shp->shm_file) ?
+       file = alloc_file(&path, f_mode,
+                         is_file_hugepages(shp->shm_file) ?
                                &shm_file_operations_huge :
                                &shm_file_operations);
        if (!file)
                goto out_free;
-       ima_counts_get(file);
 
        file->private_data = sfd;
        file->f_mapping = shp->shm_file->f_mapping;
@@ -950,7 +949,7 @@ out_unlock:
 out_free:
        kfree(sfd);
 out_put_dentry:
-       dput(path.dentry);
+       path_put(&path);
        goto out_nattch;
 }
 
index 9a4715a2f6bf67ecfc35310bdf7e42ead2ee11c8..a6605ca921b6a6a9538ac645dadee177ef34f9b9 100644 (file)
@@ -536,7 +536,8 @@ static void do_acct_process(struct bsd_acct_struct *acct,
        do_div(elapsed, AHZ);
        ac.ac_btime = get_seconds() - elapsed;
        /* we really need to bite the bullet and change layout */
-       current_uid_gid(&ac.ac_uid, &ac.ac_gid);
+       ac.ac_uid = orig_cred->uid;
+       ac.ac_gid = orig_cred->gid;
 #if ACCT_VERSION==2
        ac.ac_ahz = AHZ;
 #endif
index 2451dc6f328211d173747865cde60fd49b6c9bbd..4b05bd9479dbc3d20cee5d658407d4cccb4a4727 100644 (file)
@@ -277,7 +277,7 @@ static void untag_chunk(struct node *p)
                owner->root = NULL;
        }
 
-       for (i = j = 0; i < size; i++, j++) {
+       for (i = j = 0; j <= size; i++, j++) {
                struct audit_tree *s;
                if (&chunk->owners[j] == p) {
                        list_del_init(&p->list);
@@ -290,7 +290,7 @@ static void untag_chunk(struct node *p)
                if (!s) /* result of earlier fallback */
                        continue;
                get_tree(s);
-               list_replace_init(&chunk->owners[i].list, &new->owners[j].list);
+               list_replace_init(&chunk->owners[j].list, &new->owners[i].list);
        }
 
        list_replace_rcu(&chunk->hash, &new->hash);
@@ -373,15 +373,17 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
        for (n = 0; n < old->count; n++) {
                if (old->owners[n].owner == tree) {
                        spin_unlock(&hash_lock);
-                       put_inotify_watch(watch);
+                       put_inotify_watch(&old->watch);
                        return 0;
                }
        }
        spin_unlock(&hash_lock);
 
        chunk = alloc_chunk(old->count + 1);
-       if (!chunk)
+       if (!chunk) {
+               put_inotify_watch(&old->watch);
                return -ENOMEM;
+       }
 
        mutex_lock(&inode->inotify_mutex);
        if (inotify_clone_watch(&old->watch, &chunk->watch) < 0) {
@@ -425,7 +427,8 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
        spin_unlock(&hash_lock);
        inotify_evict_watch(&old->watch);
        mutex_unlock(&inode->inotify_mutex);
-       put_inotify_watch(&old->watch);
+       put_inotify_watch(&old->watch); /* pair to inotify_find_watch */
+       put_inotify_watch(&old->watch); /* and kill it */
        return 0;
 }
 
index 267e484f019817b87187c74bfa7aa12275411b0c..fc0f928167e78b49d0a96b6a4f6e15e80ed90c6b 100644 (file)
@@ -250,7 +250,6 @@ struct audit_context {
 #endif
 };
 
-#define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE])
 static inline int open_arg(int flags, int mask)
 {
        int n = ACC_MODE(flags);
index 3c5301381837407d986f06cddaf665eca71fb412..98a51f26c13691b9f6f5955cdc83840f8932c2be 100644 (file)
@@ -12,7 +12,7 @@
 
 void foo(void)
 {
-       /* The enum constants to put into include/linux/bounds.h */
+       /* The enum constants to put into include/generated/bounds.h */
        DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS);
        DEFINE(MAX_NR_ZONES, __MAX_NR_ZONES);
        /* End of constants */
index 291ac586f37ff93e047391be46b3db90d5f80445..1c8ddd6ee9402fdf2f6853c6142f3a8d0cb57da6 100644 (file)
@@ -209,6 +209,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
                return -ENOMEM;
 
        cpu_hotplug_begin();
+       set_cpu_active(cpu, false);
        err = __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_PREPARE | mod,
                                        hcpu, -1, &nr_calls);
        if (err == NOTIFY_BAD) {
@@ -280,18 +281,6 @@ int __ref cpu_down(unsigned int cpu)
                goto out;
        }
 
-       set_cpu_active(cpu, false);
-
-       /*
-        * Make sure the all cpus did the reschedule and are not
-        * using stale version of the cpu_active_mask.
-        * This is not strictly necessary becuase stop_machine()
-        * that we run down the line already provides the required
-        * synchronization. But it's really a side effect and we do not
-        * want to depend on the innards of the stop_machine here.
-        */
-       synchronize_sched();
-
        err = _cpu_down(cpu, 0);
 
 out:
@@ -382,19 +371,12 @@ int disable_nonboot_cpus(void)
                return error;
        cpu_maps_update_begin();
        first_cpu = cpumask_first(cpu_online_mask);
-       /* We take down all of the non-boot CPUs in one shot to avoid races
+       /*
+        * We take down all of the non-boot CPUs in one shot to avoid races
         * with the userspace trying to use the CPU hotplug at the same time
         */
        cpumask_clear(frozen_cpus);
 
-       for_each_online_cpu(cpu) {
-               if (cpu == first_cpu)
-                       continue;
-               set_cpu_active(cpu, false);
-       }
-
-       synchronize_sched();
-
        printk("Disabling non-boot CPUs ...\n");
        for_each_online_cpu(cpu) {
                if (cpu == first_cpu)
index 6f50ef55a6f39221cd66aff3c44c476cd5a2cf3b..546774a31a66752a698faa02c4e54f7c39fbef9e 100644 (file)
@@ -68,10 +68,10 @@ static void __unhash_process(struct task_struct *p)
                detach_pid(p, PIDTYPE_SID);
 
                list_del_rcu(&p->tasks);
+               list_del_init(&p->sibling);
                __get_cpu_var(process_counts)--;
        }
        list_del_rcu(&p->thread_group);
-       list_del_init(&p->sibling);
 }
 
 /*
@@ -736,12 +736,9 @@ static struct task_struct *find_new_reaper(struct task_struct *father)
 /*
 * Any that need to be release_task'd are put on the @dead list.
  */
-static void reparent_thread(struct task_struct *father, struct task_struct *p,
+static void reparent_leader(struct task_struct *father, struct task_struct *p,
                                struct list_head *dead)
 {
-       if (p->pdeath_signal)
-               group_send_sig_info(p->pdeath_signal, SEND_SIG_NOINFO, p);
-
        list_move_tail(&p->sibling, &p->real_parent->children);
 
        if (task_detached(p))
@@ -780,12 +777,18 @@ static void forget_original_parent(struct task_struct *father)
        reaper = find_new_reaper(father);
 
        list_for_each_entry_safe(p, n, &father->children, sibling) {
-               p->real_parent = reaper;
-               if (p->parent == father) {
-                       BUG_ON(task_ptrace(p));
-                       p->parent = p->real_parent;
-               }
-               reparent_thread(father, p, &dead_children);
+               struct task_struct *t = p;
+               do {
+                       t->real_parent = reaper;
+                       if (t->parent == father) {
+                               BUG_ON(task_ptrace(t));
+                               t->parent = t->real_parent;
+                       }
+                       if (t->pdeath_signal)
+                               group_send_sig_info(t->pdeath_signal,
+                                                   SEND_SIG_NOINFO, t);
+               } while_each_thread(p, t);
+               reparent_leader(father, p, &dead_children);
        }
        write_unlock_irq(&tasklist_lock);
 
@@ -933,7 +936,7 @@ NORET_TYPE void do_exit(long code)
         * an exiting task cleaning up the robust pi futexes.
         */
        smp_mb();
-       spin_unlock_wait(&tsk->pi_lock);
+       raw_spin_unlock_wait(&tsk->pi_lock);
 
        if (unlikely(in_atomic()))
                printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n",
@@ -1551,14 +1554,9 @@ static int do_wait_thread(struct wait_opts *wo, struct task_struct *tsk)
        struct task_struct *p;
 
        list_for_each_entry(p, &tsk->children, sibling) {
-               /*
-                * Do not consider detached threads.
-                */
-               if (!task_detached(p)) {
-                       int ret = wait_consider_task(wo, 0, p);
-                       if (ret)
-                               return ret;
-               }
+               int ret = wait_consider_task(wo, 0, p);
+               if (ret)
+                       return ret;
        }
 
        return 0;
index 1415dc4598aef6f1824382c3a4c5859d82e574fd..5b2959b3ffc2c239244c25548f3d5c5506baf674 100644 (file)
@@ -939,9 +939,9 @@ SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr)
 
 static void rt_mutex_init_task(struct task_struct *p)
 {
-       spin_lock_init(&p->pi_lock);
+       raw_spin_lock_init(&p->pi_lock);
 #ifdef CONFIG_RT_MUTEXES
-       plist_head_init(&p->pi_waiters, &p->pi_lock);
+       plist_head_init_raw(&p->pi_waiters, &p->pi_lock);
        p->pi_blocked_on = NULL;
 #endif
 }
@@ -1127,6 +1127,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 #ifdef CONFIG_DEBUG_MUTEXES
        p->blocked_on = NULL; /* not blocked yet */
 #endif
+#ifdef CONFIG_CGROUP_MEM_RES_CTLR
+       p->memcg_batch.do_batch = 0;
+       p->memcg_batch.memcg = NULL;
+#endif
 
        p->bts = NULL;
 
@@ -1206,9 +1210,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,
                p->sas_ss_sp = p->sas_ss_size = 0;
 
        /*
-        * Syscall tracing should be turned off in the child regardless
-        * of CLONE_PTRACE.
+        * Syscall tracing and stepping should be turned off in the
+        * child regardless of CLONE_PTRACE.
         */
+       user_disable_single_step(p);
        clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE);
 #ifdef TIF_SYSCALL_EMU
        clear_tsk_thread_flag(p, TIF_SYSCALL_EMU);
@@ -1286,7 +1291,6 @@ static struct task_struct *copy_process(unsigned long clone_flags,
        }
 
        if (likely(p->pid)) {
-               list_add_tail(&p->sibling, &p->real_parent->children);
                tracehook_finish_clone(p, clone_flags, trace);
 
                if (thread_group_leader(p)) {
@@ -1298,6 +1302,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
                        p->signal->tty = tty_kref_get(current->signal->tty);
                        attach_pid(p, PIDTYPE_PGID, task_pgrp(current));
                        attach_pid(p, PIDTYPE_SID, task_session(current));
+                       list_add_tail(&p->sibling, &p->real_parent->children);
                        list_add_tail_rcu(&p->tasks, &init_task.tasks);
                        __get_cpu_var(process_counts)++;
                }
index d73ef1f3e55db35748c444701ff856219612b93b..8e3c3ffe1b9a57ea0110b36c089a5131760d0314 100644 (file)
@@ -403,9 +403,9 @@ static void free_pi_state(struct futex_pi_state *pi_state)
         * and has cleaned up the pi_state already
         */
        if (pi_state->owner) {
-               spin_lock_irq(&pi_state->owner->pi_lock);
+               raw_spin_lock_irq(&pi_state->owner->pi_lock);
                list_del_init(&pi_state->list);
-               spin_unlock_irq(&pi_state->owner->pi_lock);
+               raw_spin_unlock_irq(&pi_state->owner->pi_lock);
 
                rt_mutex_proxy_unlock(&pi_state->pi_mutex, pi_state->owner);
        }
@@ -470,18 +470,18 @@ void exit_pi_state_list(struct task_struct *curr)
         * pi_state_list anymore, but we have to be careful
         * versus waiters unqueueing themselves:
         */
-       spin_lock_irq(&curr->pi_lock);
+       raw_spin_lock_irq(&curr->pi_lock);
        while (!list_empty(head)) {
 
                next = head->next;
                pi_state = list_entry(next, struct futex_pi_state, list);
                key = pi_state->key;
                hb = hash_futex(&key);
-               spin_unlock_irq(&curr->pi_lock);
+               raw_spin_unlock_irq(&curr->pi_lock);
 
                spin_lock(&hb->lock);
 
-               spin_lock_irq(&curr->pi_lock);
+               raw_spin_lock_irq(&curr->pi_lock);
                /*
                 * We dropped the pi-lock, so re-check whether this
                 * task still owns the PI-state:
@@ -495,15 +495,15 @@ void exit_pi_state_list(struct task_struct *curr)
                WARN_ON(list_empty(&pi_state->list));
                list_del_init(&pi_state->list);
                pi_state->owner = NULL;
-               spin_unlock_irq(&curr->pi_lock);
+               raw_spin_unlock_irq(&curr->pi_lock);
 
                rt_mutex_unlock(&pi_state->pi_mutex);
 
                spin_unlock(&hb->lock);
 
-               spin_lock_irq(&curr->pi_lock);
+               raw_spin_lock_irq(&curr->pi_lock);
        }
-       spin_unlock_irq(&curr->pi_lock);
+       raw_spin_unlock_irq(&curr->pi_lock);
 }
 
 static int
@@ -558,7 +558,7 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
         * change of the task flags, we do this protected by
         * p->pi_lock:
         */
-       spin_lock_irq(&p->pi_lock);
+       raw_spin_lock_irq(&p->pi_lock);
        if (unlikely(p->flags & PF_EXITING)) {
                /*
                 * The task is on the way out. When PF_EXITPIDONE is
@@ -567,7 +567,7 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
                 */
                int ret = (p->flags & PF_EXITPIDONE) ? -ESRCH : -EAGAIN;
 
-               spin_unlock_irq(&p->pi_lock);
+               raw_spin_unlock_irq(&p->pi_lock);
                put_task_struct(p);
                return ret;
        }
@@ -586,7 +586,7 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
        WARN_ON(!list_empty(&pi_state->list));
        list_add(&pi_state->list, &p->pi_state_list);
        pi_state->owner = p;
-       spin_unlock_irq(&p->pi_lock);
+       raw_spin_unlock_irq(&p->pi_lock);
 
        put_task_struct(p);
 
@@ -760,7 +760,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
        if (!pi_state)
                return -EINVAL;
 
-       spin_lock(&pi_state->pi_mutex.wait_lock);
+       raw_spin_lock(&pi_state->pi_mutex.wait_lock);
        new_owner = rt_mutex_next_owner(&pi_state->pi_mutex);
 
        /*
@@ -789,23 +789,23 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
                else if (curval != uval)
                        ret = -EINVAL;
                if (ret) {
-                       spin_unlock(&pi_state->pi_mutex.wait_lock);
+                       raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
                        return ret;
                }
        }
 
-       spin_lock_irq(&pi_state->owner->pi_lock);
+       raw_spin_lock_irq(&pi_state->owner->pi_lock);
        WARN_ON(list_empty(&pi_state->list));
        list_del_init(&pi_state->list);
-       spin_unlock_irq(&pi_state->owner->pi_lock);
+       raw_spin_unlock_irq(&pi_state->owner->pi_lock);
 
-       spin_lock_irq(&new_owner->pi_lock);
+       raw_spin_lock_irq(&new_owner->pi_lock);
        WARN_ON(!list_empty(&pi_state->list));
        list_add(&pi_state->list, &new_owner->pi_state_list);
        pi_state->owner = new_owner;
-       spin_unlock_irq(&new_owner->pi_lock);
+       raw_spin_unlock_irq(&new_owner->pi_lock);
 
-       spin_unlock(&pi_state->pi_mutex.wait_lock);
+       raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
        rt_mutex_unlock(&pi_state->pi_mutex);
 
        return 0;
@@ -1010,7 +1010,7 @@ void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1,
                plist_add(&q->list, &hb2->chain);
                q->lock_ptr = &hb2->lock;
 #ifdef CONFIG_DEBUG_PI_LIST
-               q->list.plist.lock = &hb2->lock;
+               q->list.plist.spinlock = &hb2->lock;
 #endif
        }
        get_futex_key_refs(key2);
@@ -1046,7 +1046,7 @@ void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,
 
        q->lock_ptr = &hb->lock;
 #ifdef CONFIG_DEBUG_PI_LIST
-       q->list.plist.lock = &hb->lock;
+       q->list.plist.spinlock = &hb->lock;
 #endif
 
        wake_up_state(q->task, TASK_NORMAL);
@@ -1394,7 +1394,7 @@ static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
 
        plist_node_init(&q->list, prio);
 #ifdef CONFIG_DEBUG_PI_LIST
-       q->list.plist.lock = &hb->lock;
+       q->list.plist.spinlock = &hb->lock;
 #endif
        plist_add(&q->list, &hb->chain);
        q->task = current;
@@ -1529,18 +1529,18 @@ retry:
         * itself.
         */
        if (pi_state->owner != NULL) {
-               spin_lock_irq(&pi_state->owner->pi_lock);
+               raw_spin_lock_irq(&pi_state->owner->pi_lock);
                WARN_ON(list_empty(&pi_state->list));
                list_del_init(&pi_state->list);
-               spin_unlock_irq(&pi_state->owner->pi_lock);
+               raw_spin_unlock_irq(&pi_state->owner->pi_lock);
        }
 
        pi_state->owner = newowner;
 
-       spin_lock_irq(&newowner->pi_lock);
+       raw_spin_lock_irq(&newowner->pi_lock);
        WARN_ON(!list_empty(&pi_state->list));
        list_add(&pi_state->list, &newowner->pi_state_list);
-       spin_unlock_irq(&newowner->pi_lock);
+       raw_spin_unlock_irq(&newowner->pi_lock);
        return 0;
 
        /*
index d2f9239dc6ba51f7d2652f948b46fb01153f8aa6..0086628b6e9772b675ee5cd9bbd37d4b4d035534 100644 (file)
@@ -127,11 +127,11 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,
        for (;;) {
                base = timer->base;
                if (likely(base != NULL)) {
-                       spin_lock_irqsave(&base->cpu_base->lock, *flags);
+                       raw_spin_lock_irqsave(&base->cpu_base->lock, *flags);
                        if (likely(base == timer->base))
                                return base;
                        /* The timer has migrated to another CPU: */
-                       spin_unlock_irqrestore(&base->cpu_base->lock, *flags);
+                       raw_spin_unlock_irqrestore(&base->cpu_base->lock, *flags);
                }
                cpu_relax();
        }
@@ -208,13 +208,13 @@ again:
 
                /* See the comment in lock_timer_base() */
                timer->base = NULL;
-               spin_unlock(&base->cpu_base->lock);
-               spin_lock(&new_base->cpu_base->lock);
+               raw_spin_unlock(&base->cpu_base->lock);
+               raw_spin_lock(&new_base->cpu_base->lock);
 
                if (cpu != this_cpu && hrtimer_check_target(timer, new_base)) {
                        cpu = this_cpu;
-                       spin_unlock(&new_base->cpu_base->lock);
-                       spin_lock(&base->cpu_base->lock);
+                       raw_spin_unlock(&new_base->cpu_base->lock);
+                       raw_spin_lock(&base->cpu_base->lock);
                        timer->base = base;
                        goto again;
                }
@@ -230,7 +230,7 @@ lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
 {
        struct hrtimer_clock_base *base = timer->base;
 
-       spin_lock_irqsave(&base->cpu_base->lock, *flags);
+       raw_spin_lock_irqsave(&base->cpu_base->lock, *flags);
 
        return base;
 }
@@ -628,12 +628,12 @@ static void retrigger_next_event(void *arg)
        base = &__get_cpu_var(hrtimer_bases);
 
        /* Adjust CLOCK_REALTIME offset */
-       spin_lock(&base->lock);
+       raw_spin_lock(&base->lock);
        base->clock_base[CLOCK_REALTIME].offset =
                timespec_to_ktime(realtime_offset);
 
        hrtimer_force_reprogram(base, 0);
-       spin_unlock(&base->lock);
+       raw_spin_unlock(&base->lock);
 }
 
 /*
@@ -694,9 +694,9 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
 {
        if (base->cpu_base->hres_active && hrtimer_reprogram(timer, base)) {
                if (wakeup) {
-                       spin_unlock(&base->cpu_base->lock);
+                       raw_spin_unlock(&base->cpu_base->lock);
                        raise_softirq_irqoff(HRTIMER_SOFTIRQ);
-                       spin_lock(&base->cpu_base->lock);
+                       raw_spin_lock(&base->cpu_base->lock);
                } else
                        __raise_softirq_irqoff(HRTIMER_SOFTIRQ);
 
@@ -790,7 +790,7 @@ static inline void timer_stats_account_hrtimer(struct hrtimer *timer)
 static inline
 void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
 {
-       spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags);
+       raw_spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags);
 }
 
 /**
@@ -1123,7 +1123,7 @@ ktime_t hrtimer_get_next_event(void)
        unsigned long flags;
        int i;
 
-       spin_lock_irqsave(&cpu_base->lock, flags);
+       raw_spin_lock_irqsave(&cpu_base->lock, flags);
 
        if (!hrtimer_hres_active()) {
                for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++, base++) {
@@ -1140,7 +1140,7 @@ ktime_t hrtimer_get_next_event(void)
                }
        }
 
-       spin_unlock_irqrestore(&cpu_base->lock, flags);
+       raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
 
        if (mindelta.tv64 < 0)
                mindelta.tv64 = 0;
@@ -1222,11 +1222,11 @@ static void __run_hrtimer(struct hrtimer *timer, ktime_t *now)
         * they get migrated to another cpu, therefore its safe to unlock
         * the timer base.
         */
-       spin_unlock(&cpu_base->lock);
+       raw_spin_unlock(&cpu_base->lock);
        trace_hrtimer_expire_entry(timer, now);
        restart = fn(timer);
        trace_hrtimer_expire_exit(timer);
-       spin_lock(&cpu_base->lock);
+       raw_spin_lock(&cpu_base->lock);
 
        /*
         * Note: We clear the CALLBACK bit after enqueue_hrtimer and
@@ -1261,7 +1261,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
 retry:
        expires_next.tv64 = KTIME_MAX;
 
-       spin_lock(&cpu_base->lock);
+       raw_spin_lock(&cpu_base->lock);
        /*
         * We set expires_next to KTIME_MAX here with cpu_base->lock
         * held to prevent that a timer is enqueued in our queue via
@@ -1317,7 +1317,7 @@ retry:
         * against it.
         */
        cpu_base->expires_next = expires_next;
-       spin_unlock(&cpu_base->lock);
+       raw_spin_unlock(&cpu_base->lock);
 
        /* Reprogramming necessary ? */
        if (expires_next.tv64 == KTIME_MAX ||
@@ -1457,7 +1457,7 @@ void hrtimer_run_queues(void)
                        gettime = 0;
                }
 
-               spin_lock(&cpu_base->lock);
+               raw_spin_lock(&cpu_base->lock);
 
                while ((node = base->first)) {
                        struct hrtimer *timer;
@@ -1469,7 +1469,7 @@ void hrtimer_run_queues(void)
 
                        __run_hrtimer(timer, &base->softirq_time);
                }
-               spin_unlock(&cpu_base->lock);
+               raw_spin_unlock(&cpu_base->lock);
        }
 }
 
@@ -1625,7 +1625,7 @@ static void __cpuinit init_hrtimers_cpu(int cpu)
        struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
        int i;
 
-       spin_lock_init(&cpu_base->lock);
+       raw_spin_lock_init(&cpu_base->lock);
 
        for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++)
                cpu_base->clock_base[i].cpu_base = cpu_base;
@@ -1683,16 +1683,16 @@ static void migrate_hrtimers(int scpu)
         * The caller is globally serialized and nobody else
         * takes two locks at once, deadlock is not possible.
         */
-       spin_lock(&new_base->lock);
-       spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);
+       raw_spin_lock(&new_base->lock);
+       raw_spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);
 
        for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
                migrate_hrtimer_list(&old_base->clock_base[i],
                                     &new_base->clock_base[i]);
        }
 
-       spin_unlock(&old_base->lock);
-       spin_unlock(&new_base->lock);
+       raw_spin_unlock(&old_base->lock);
+       raw_spin_unlock(&new_base->lock);
 
        /* Check, if we got expired work to do */
        __hrtimer_peek_ahead_timers();
index 366eedf949c0a47380af9050463dae76431aa063..dbcbf6a33a08d4f3a0d9b50469fa15162d81787b 100644 (file)
@@ -96,7 +96,7 @@ static int task_bp_pinned(struct task_struct *tsk)
 
        list = &ctx->event_list;
 
-       spin_lock_irqsave(&ctx->lock, flags);
+       raw_spin_lock_irqsave(&ctx->lock, flags);
 
        /*
         * The current breakpoint counter is not included in the list
@@ -107,7 +107,7 @@ static int task_bp_pinned(struct task_struct *tsk)
                        count++;
        }
 
-       spin_unlock_irqrestore(&ctx->lock, flags);
+       raw_spin_unlock_irqrestore(&ctx->lock, flags);
 
        return count;
 }
index 1de9700f416e48e11861e08c42b0ea99216f9e42..2295a31ef110dab62a6e665358a9cb290fbe990e 100644 (file)
@@ -45,7 +45,7 @@ unsigned long probe_irq_on(void)
         * flush such a longstanding irq before considering it as spurious.
         */
        for_each_irq_desc_reverse(i, desc) {
-               spin_lock_irq(&desc->lock);
+               raw_spin_lock_irq(&desc->lock);
                if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
                        /*
                         * An old-style architecture might still have
@@ -61,7 +61,7 @@ unsigned long probe_irq_on(void)
                                desc->chip->set_type(i, IRQ_TYPE_PROBE);
                        desc->chip->startup(i);
                }
-               spin_unlock_irq(&desc->lock);
+               raw_spin_unlock_irq(&desc->lock);
        }
 
        /* Wait for longstanding interrupts to trigger. */
@@ -73,13 +73,13 @@ unsigned long probe_irq_on(void)
         * happened in the previous stage, it may have masked itself)
         */
        for_each_irq_desc_reverse(i, desc) {
-               spin_lock_irq(&desc->lock);
+               raw_spin_lock_irq(&desc->lock);
                if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
                        desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
                        if (desc->chip->startup(i))
                                desc->status |= IRQ_PENDING;
                }
-               spin_unlock_irq(&desc->lock);
+               raw_spin_unlock_irq(&desc->lock);
        }
 
        /*
@@ -91,7 +91,7 @@ unsigned long probe_irq_on(void)
         * Now filter out any obviously spurious interrupts
         */
        for_each_irq_desc(i, desc) {
-               spin_lock_irq(&desc->lock);
+               raw_spin_lock_irq(&desc->lock);
                status = desc->status;
 
                if (status & IRQ_AUTODETECT) {
@@ -103,7 +103,7 @@ unsigned long probe_irq_on(void)
                                if (i < 32)
                                        mask |= 1 << i;
                }
-               spin_unlock_irq(&desc->lock);
+               raw_spin_unlock_irq(&desc->lock);
        }
 
        return mask;
@@ -129,7 +129,7 @@ unsigned int probe_irq_mask(unsigned long val)
        int i;
 
        for_each_irq_desc(i, desc) {
-               spin_lock_irq(&desc->lock);
+               raw_spin_lock_irq(&desc->lock);
                status = desc->status;
 
                if (status & IRQ_AUTODETECT) {
@@ -139,7 +139,7 @@ unsigned int probe_irq_mask(unsigned long val)
                        desc->status = status & ~IRQ_AUTODETECT;
                        desc->chip->shutdown(i);
                }
-               spin_unlock_irq(&desc->lock);
+               raw_spin_unlock_irq(&desc->lock);
        }
        mutex_unlock(&probing_active);
 
@@ -171,7 +171,7 @@ int probe_irq_off(unsigned long val)
        unsigned int status;
 
        for_each_irq_desc(i, desc) {
-               spin_lock_irq(&desc->lock);
+               raw_spin_lock_irq(&desc->lock);
                status = desc->status;
 
                if (status & IRQ_AUTODETECT) {
@@ -183,7 +183,7 @@ int probe_irq_off(unsigned long val)
                        desc->status = status & ~IRQ_AUTODETECT;
                        desc->chip->shutdown(i);
                }
-               spin_unlock_irq(&desc->lock);
+               raw_spin_unlock_irq(&desc->lock);
        }
        mutex_unlock(&probing_active);
 
index ba566c261adc3dc3fbf001af3d630fd7e4a9c771..ecc3fa28f66640ddc662e40340c634323f2196e9 100644 (file)
@@ -34,7 +34,7 @@ void dynamic_irq_init(unsigned int irq)
        }
 
        /* Ensure we don't have left over values from a previous use of this irq */
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        desc->status = IRQ_DISABLED;
        desc->chip = &no_irq_chip;
        desc->handle_irq = handle_bad_irq;
@@ -51,7 +51,7 @@ void dynamic_irq_init(unsigned int irq)
        cpumask_clear(desc->pending_mask);
 #endif
 #endif
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 /**
@@ -68,9 +68,9 @@ void dynamic_irq_cleanup(unsigned int irq)
                return;
        }
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        if (desc->action) {
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
                WARN(1, KERN_ERR "Destroying IRQ%d without calling free_irq\n",
                        irq);
                return;
@@ -82,7 +82,7 @@ void dynamic_irq_cleanup(unsigned int irq)
        desc->chip = &no_irq_chip;
        desc->name = NULL;
        clear_kstat_irqs(desc);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 
@@ -104,10 +104,10 @@ int set_irq_chip(unsigned int irq, struct irq_chip *chip)
        if (!chip)
                chip = &no_irq_chip;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        irq_chip_set_defaults(chip);
        desc->chip = chip;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 
        return 0;
 }
@@ -133,9 +133,9 @@ int set_irq_type(unsigned int irq, unsigned int type)
        if (type == IRQ_TYPE_NONE)
                return 0;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        ret = __irq_set_trigger(desc, irq, type);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        return ret;
 }
 EXPORT_SYMBOL(set_irq_type);
@@ -158,9 +158,9 @@ int set_irq_data(unsigned int irq, void *data)
                return -EINVAL;
        }
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        desc->handler_data = data;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        return 0;
 }
 EXPORT_SYMBOL(set_irq_data);
@@ -183,11 +183,11 @@ int set_irq_msi(unsigned int irq, struct msi_desc *entry)
                return -EINVAL;
        }
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        desc->msi_desc = entry;
        if (entry)
                entry->irq = irq;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        return 0;
 }
 
@@ -214,9 +214,9 @@ int set_irq_chip_data(unsigned int irq, void *data)
                return -EINVAL;
        }
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        desc->chip_data = data;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 
        return 0;
 }
@@ -241,12 +241,12 @@ void set_irq_nested_thread(unsigned int irq, int nest)
        if (!desc)
                return;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        if (nest)
                desc->status |= IRQ_NESTED_THREAD;
        else
                desc->status &= ~IRQ_NESTED_THREAD;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 EXPORT_SYMBOL_GPL(set_irq_nested_thread);
 
@@ -343,7 +343,7 @@ void handle_nested_irq(unsigned int irq)
 
        might_sleep();
 
-       spin_lock_irq(&desc->lock);
+       raw_spin_lock_irq(&desc->lock);
 
        kstat_incr_irqs_this_cpu(irq, desc);
 
@@ -352,17 +352,17 @@ void handle_nested_irq(unsigned int irq)
                goto out_unlock;
 
        desc->status |= IRQ_INPROGRESS;
-       spin_unlock_irq(&desc->lock);
+       raw_spin_unlock_irq(&desc->lock);
 
        action_ret = action->thread_fn(action->irq, action->dev_id);
        if (!noirqdebug)
                note_interrupt(irq, desc, action_ret);
 
-       spin_lock_irq(&desc->lock);
+       raw_spin_lock_irq(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
 
 out_unlock:
-       spin_unlock_irq(&desc->lock);
+       raw_spin_unlock_irq(&desc->lock);
 }
 EXPORT_SYMBOL_GPL(handle_nested_irq);
 
@@ -384,7 +384,7 @@ handle_simple_irq(unsigned int irq, struct irq_desc *desc)
        struct irqaction *action;
        irqreturn_t action_ret;
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
 
        if (unlikely(desc->status & IRQ_INPROGRESS))
                goto out_unlock;
@@ -396,16 +396,16 @@ handle_simple_irq(unsigned int irq, struct irq_desc *desc)
                goto out_unlock;
 
        desc->status |= IRQ_INPROGRESS;
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        action_ret = handle_IRQ_event(irq, action);
        if (!noirqdebug)
                note_interrupt(irq, desc, action_ret);
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
 out_unlock:
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 
 /**
@@ -424,7 +424,7 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc)
        struct irqaction *action;
        irqreturn_t action_ret;
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        mask_ack_irq(desc, irq);
 
        if (unlikely(desc->status & IRQ_INPROGRESS))
@@ -441,13 +441,13 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc)
                goto out_unlock;
 
        desc->status |= IRQ_INPROGRESS;
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        action_ret = handle_IRQ_event(irq, action);
        if (!noirqdebug)
                note_interrupt(irq, desc, action_ret);
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
 
        if (unlikely(desc->status & IRQ_ONESHOT))
@@ -455,7 +455,7 @@ handle_level_irq(unsigned int irq, struct irq_desc *desc)
        else if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask)
                desc->chip->unmask(irq);
 out_unlock:
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 EXPORT_SYMBOL_GPL(handle_level_irq);
 
@@ -475,7 +475,7 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
        struct irqaction *action;
        irqreturn_t action_ret;
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
 
        if (unlikely(desc->status & IRQ_INPROGRESS))
                goto out;
@@ -497,18 +497,18 @@ handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
 
        desc->status |= IRQ_INPROGRESS;
        desc->status &= ~IRQ_PENDING;
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        action_ret = handle_IRQ_event(irq, action);
        if (!noirqdebug)
                note_interrupt(irq, desc, action_ret);
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        desc->status &= ~IRQ_INPROGRESS;
 out:
        desc->chip->eoi(irq);
 
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 
 /**
@@ -530,7 +530,7 @@ out:
 void
 handle_edge_irq(unsigned int irq, struct irq_desc *desc)
 {
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
 
        desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
 
@@ -576,17 +576,17 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc)
                }
 
                desc->status &= ~IRQ_PENDING;
-               spin_unlock(&desc->lock);
+               raw_spin_unlock(&desc->lock);
                action_ret = handle_IRQ_event(irq, action);
                if (!noirqdebug)
                        note_interrupt(irq, desc, action_ret);
-               spin_lock(&desc->lock);
+               raw_spin_lock(&desc->lock);
 
        } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
 
        desc->status &= ~IRQ_INPROGRESS;
 out_unlock:
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 }
 
 /**
@@ -643,7 +643,7 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
        }
 
        chip_bus_lock(irq, desc);
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
 
        /* Uninstall? */
        if (handle == handle_bad_irq) {
@@ -661,7 +661,7 @@ __set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
                desc->depth = 0;
                desc->chip->startup(irq);
        }
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        chip_bus_sync_unlock(irq, desc);
 }
 EXPORT_SYMBOL_GPL(__set_irq_handler);
@@ -692,9 +692,9 @@ void __init set_irq_noprobe(unsigned int irq)
                return;
        }
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        desc->status |= IRQ_NOPROBE;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
 
 void __init set_irq_probe(unsigned int irq)
@@ -707,7 +707,7 @@ void __init set_irq_probe(unsigned int irq)
                return;
        }
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        desc->status &= ~IRQ_NOPROBE;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 }
index 17c71bb565c6ed287901aaef1c201a3c70f79aef..814940e7f48501430516ca75eca3dcb463c7e9d7 100644 (file)
@@ -80,7 +80,7 @@ static struct irq_desc irq_desc_init = {
        .chip       = &no_irq_chip,
        .handle_irq = handle_bad_irq,
        .depth      = 1,
-       .lock       = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
+       .lock       = __RAW_SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
 };
 
 void __ref init_kstat_irqs(struct irq_desc *desc, int node, int nr)
@@ -108,7 +108,7 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int node)
 {
        memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
 
-       spin_lock_init(&desc->lock);
+       raw_spin_lock_init(&desc->lock);
        desc->irq = irq;
 #ifdef CONFIG_SMP
        desc->node = node;
@@ -130,7 +130,7 @@ static void init_one_irq_desc(int irq, struct irq_desc *desc, int node)
 /*
  * Protect the sparse_irqs:
  */
-DEFINE_SPINLOCK(sparse_irq_lock);
+DEFINE_RAW_SPINLOCK(sparse_irq_lock);
 
 struct irq_desc **irq_desc_ptrs __read_mostly;
 
@@ -141,7 +141,7 @@ static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_sm
                .chip       = &no_irq_chip,
                .handle_irq = handle_bad_irq,
                .depth      = 1,
-               .lock       = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
+               .lock       = __RAW_SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
        }
 };
 
@@ -212,7 +212,7 @@ struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
        if (desc)
                return desc;
 
-       spin_lock_irqsave(&sparse_irq_lock, flags);
+       raw_spin_lock_irqsave(&sparse_irq_lock, flags);
 
        /* We have to check it to avoid races with another CPU */
        desc = irq_desc_ptrs[irq];
@@ -234,7 +234,7 @@ struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
        irq_desc_ptrs[irq] = desc;
 
 out_unlock:
-       spin_unlock_irqrestore(&sparse_irq_lock, flags);
+       raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
 
        return desc;
 }
@@ -247,7 +247,7 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
                .chip = &no_irq_chip,
                .handle_irq = handle_bad_irq,
                .depth = 1,
-               .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
+               .lock = __RAW_SPIN_LOCK_UNLOCKED(irq_desc->lock),
        }
 };
 
@@ -473,7 +473,7 @@ unsigned int __do_IRQ(unsigned int irq)
                return 1;
        }
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        if (desc->chip->ack)
                desc->chip->ack(irq);
        /*
@@ -517,13 +517,13 @@ unsigned int __do_IRQ(unsigned int irq)
        for (;;) {
                irqreturn_t action_ret;
 
-               spin_unlock(&desc->lock);
+               raw_spin_unlock(&desc->lock);
 
                action_ret = handle_IRQ_event(irq, action);
                if (!noirqdebug)
                        note_interrupt(irq, desc, action_ret);
 
-               spin_lock(&desc->lock);
+               raw_spin_lock(&desc->lock);
                if (likely(!(desc->status & IRQ_PENDING)))
                        break;
                desc->status &= ~IRQ_PENDING;
@@ -536,7 +536,7 @@ out:
         * disabled while the handler was running.
         */
        desc->chip->end(irq);
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        return 1;
 }
index 1b5d742c6a773943bc4679d35e2317c109540439..b2821f070a3d01b6bc378e7fa54f1998a815dde9 100644 (file)
@@ -18,7 +18,7 @@ extern void __enable_irq(struct irq_desc *desc, unsigned int irq, bool resume);
 extern struct lock_class_key irq_desc_lock_class;
 extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
 extern void clear_kstat_irqs(struct irq_desc *desc);
-extern spinlock_t sparse_irq_lock;
+extern raw_spinlock_t sparse_irq_lock;
 
 #ifdef CONFIG_SPARSE_IRQ
 /* irq_desc_ptrs allocated at boot time */
index 7305b297d1eb99a8d7fd2674e1bfc2adcbe7e43f..eb6078ca60c7f548a052aa42c247dbb8b24d9620 100644 (file)
@@ -46,9 +46,9 @@ void synchronize_irq(unsigned int irq)
                        cpu_relax();
 
                /* Ok, that indicated we're done: double-check carefully. */
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                status = desc->status;
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
 
                /* Oops, that failed? */
        } while (status & IRQ_INPROGRESS);
@@ -114,7 +114,7 @@ int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
        if (!desc->chip->set_affinity)
                return -EINVAL;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
 
 #ifdef CONFIG_GENERIC_PENDING_IRQ
        if (desc->status & IRQ_MOVE_PCNTXT) {
@@ -134,7 +134,7 @@ int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask)
        }
 #endif
        desc->status |= IRQ_AFFINITY_SET;
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        return 0;
 }
 
@@ -181,11 +181,11 @@ int irq_select_affinity_usr(unsigned int irq)
        unsigned long flags;
        int ret;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        ret = setup_affinity(irq, desc);
        if (!ret)
                irq_set_thread_affinity(desc);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 
        return ret;
 }
@@ -231,9 +231,9 @@ void disable_irq_nosync(unsigned int irq)
                return;
 
        chip_bus_lock(irq, desc);
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        __disable_irq(desc, irq, false);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        chip_bus_sync_unlock(irq, desc);
 }
 EXPORT_SYMBOL(disable_irq_nosync);
@@ -308,9 +308,9 @@ void enable_irq(unsigned int irq)
                return;
 
        chip_bus_lock(irq, desc);
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        __enable_irq(desc, irq, false);
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        chip_bus_sync_unlock(irq, desc);
 }
 EXPORT_SYMBOL(enable_irq);
@@ -347,7 +347,7 @@ int set_irq_wake(unsigned int irq, unsigned int on)
        /* wakeup-capable irqs can be shared between drivers that
         * don't need to have the same sleep mode behaviors.
         */
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        if (on) {
                if (desc->wake_depth++ == 0) {
                        ret = set_irq_wake_real(irq, on);
@@ -368,7 +368,7 @@ int set_irq_wake(unsigned int irq, unsigned int on)
                }
        }
 
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        return ret;
 }
 EXPORT_SYMBOL(set_irq_wake);
@@ -484,12 +484,12 @@ static int irq_wait_for_interrupt(struct irqaction *action)
 static void irq_finalize_oneshot(unsigned int irq, struct irq_desc *desc)
 {
        chip_bus_lock(irq, desc);
-       spin_lock_irq(&desc->lock);
+       raw_spin_lock_irq(&desc->lock);
        if (!(desc->status & IRQ_DISABLED) && (desc->status & IRQ_MASKED)) {
                desc->status &= ~IRQ_MASKED;
                desc->chip->unmask(irq);
        }
-       spin_unlock_irq(&desc->lock);
+       raw_spin_unlock_irq(&desc->lock);
        chip_bus_sync_unlock(irq, desc);
 }
 
@@ -514,9 +514,9 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
                return;
        }
 
-       spin_lock_irq(&desc->lock);
+       raw_spin_lock_irq(&desc->lock);
        cpumask_copy(mask, desc->affinity);
-       spin_unlock_irq(&desc->lock);
+       raw_spin_unlock_irq(&desc->lock);
 
        set_cpus_allowed_ptr(current, mask);
        free_cpumask_var(mask);
@@ -545,7 +545,7 @@ static int irq_thread(void *data)
 
                atomic_inc(&desc->threads_active);
 
-               spin_lock_irq(&desc->lock);
+               raw_spin_lock_irq(&desc->lock);
                if (unlikely(desc->status & IRQ_DISABLED)) {
                        /*
                         * CHECKME: We might need a dedicated
@@ -555,9 +555,9 @@ static int irq_thread(void *data)
                         * retriggers the interrupt itself --- tglx
                         */
                        desc->status |= IRQ_PENDING;
-                       spin_unlock_irq(&desc->lock);
+                       raw_spin_unlock_irq(&desc->lock);
                } else {
-                       spin_unlock_irq(&desc->lock);
+                       raw_spin_unlock_irq(&desc->lock);
 
                        action->thread_fn(action->irq, action->dev_id);
 
@@ -679,7 +679,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
        /*
         * The following block of code has to be executed atomically
         */
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        old_ptr = &desc->action;
        old = *old_ptr;
        if (old) {
@@ -775,7 +775,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
                __enable_irq(desc, irq, false);
        }
 
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 
        /*
         * Strictly no need to wake it up, but hung_task complains
@@ -802,7 +802,7 @@ mismatch:
        ret = -EBUSY;
 
 out_thread:
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        if (new->thread) {
                struct task_struct *t = new->thread;
 
@@ -844,7 +844,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
        if (!desc)
                return NULL;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
 
        /*
         * There can be multiple actions per IRQ descriptor, find the right
@@ -856,7 +856,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
 
                if (!action) {
                        WARN(1, "Trying to free already-free IRQ %d\n", irq);
-                       spin_unlock_irqrestore(&desc->lock, flags);
+                       raw_spin_unlock_irqrestore(&desc->lock, flags);
 
                        return NULL;
                }
@@ -884,7 +884,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
                        desc->chip->disable(irq);
        }
 
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
 
        unregister_handler_proc(irq, action);
 
index fcb6c96f2627297654e9c3336e7f349846205752..241962280836ff73e8143dc8ebc63a83f53d9115 100644 (file)
@@ -27,7 +27,7 @@ void move_masked_irq(int irq)
        if (!desc->chip->set_affinity)
                return;
 
-       assert_spin_locked(&desc->lock);
+       assert_raw_spin_locked(&desc->lock);
 
        /*
         * If there was a valid mask to work with, please
index 3fd30197da2e285d1cdc6f10f037bff9cbc6f25d..26bac9d8f8609127ea654cede01a1a70aaf0bd29 100644 (file)
@@ -42,7 +42,7 @@ static bool init_copy_one_irq_desc(int irq, struct irq_desc *old_desc,
                                "for migration.\n", irq);
                return false;
        }
-       spin_lock_init(&desc->lock);
+       raw_spin_lock_init(&desc->lock);
        desc->node = node;
        lockdep_set_class(&desc->lock, &irq_desc_lock_class);
        init_copy_kstat_irqs(old_desc, desc, node, nr_cpu_ids);
@@ -67,7 +67,7 @@ static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
 
        irq = old_desc->irq;
 
-       spin_lock_irqsave(&sparse_irq_lock, flags);
+       raw_spin_lock_irqsave(&sparse_irq_lock, flags);
 
        /* We have to check it to avoid races with another CPU */
        desc = irq_desc_ptrs[irq];
@@ -91,7 +91,7 @@ static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
        }
 
        irq_desc_ptrs[irq] = desc;
-       spin_unlock_irqrestore(&sparse_irq_lock, flags);
+       raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
 
        /* free the old one */
        free_one_irq_desc(old_desc, desc);
@@ -100,7 +100,7 @@ static struct irq_desc *__real_move_irq_desc(struct irq_desc *old_desc,
        return desc;
 
 out_unlock:
-       spin_unlock_irqrestore(&sparse_irq_lock, flags);
+       raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
 
        return desc;
 }
index a0bb09e798671ff9924cb4198c2dc1a0cc8569de..0d4005d85b03243746f6c45d54cf1600bc3e5acf 100644 (file)
@@ -28,9 +28,9 @@ void suspend_device_irqs(void)
        for_each_irq_desc(irq, desc) {
                unsigned long flags;
 
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                __disable_irq(desc, irq, true);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 
        for_each_irq_desc(irq, desc)
@@ -56,9 +56,9 @@ void resume_device_irqs(void)
                if (!(desc->status & IRQ_SUSPENDED))
                        continue;
 
-               spin_lock_irqsave(&desc->lock, flags);
+               raw_spin_lock_irqsave(&desc->lock, flags);
                __enable_irq(desc, irq, true);
-               spin_unlock_irqrestore(&desc->lock, flags);
+               raw_spin_unlock_irqrestore(&desc->lock, flags);
        }
 }
 EXPORT_SYMBOL_GPL(resume_device_irqs);
index 0832145fea977546db87a1b69887c9b24a685b8c..6f50eccc79c01e4f7b80a0a107d9a1adb183328d 100644 (file)
@@ -179,7 +179,7 @@ static int name_unique(unsigned int irq, struct irqaction *new_action)
        unsigned long flags;
        int ret = 1;
 
-       spin_lock_irqsave(&desc->lock, flags);
+       raw_spin_lock_irqsave(&desc->lock, flags);
        for (action = desc->action ; action; action = action->next) {
                if ((action != new_action) && action->name &&
                                !strcmp(new_action->name, action->name)) {
@@ -187,7 +187,7 @@ static int name_unique(unsigned int irq, struct irqaction *new_action)
                        break;
                }
        }
-       spin_unlock_irqrestore(&desc->lock, flags);
+       raw_spin_unlock_irqrestore(&desc->lock, flags);
        return ret;
 }
 
index e49ea1c5232d82bce90b0cbcf708cf685e82b80f..89fb90ae534f551defdda8e43d7f1d274cb12b9e 100644 (file)
@@ -28,7 +28,7 @@ static int try_one_irq(int irq, struct irq_desc *desc)
        struct irqaction *action;
        int ok = 0, work = 0;
 
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        /* Already running on another processor */
        if (desc->status & IRQ_INPROGRESS) {
                /*
@@ -37,13 +37,13 @@ static int try_one_irq(int irq, struct irq_desc *desc)
                 */
                if (desc->action && (desc->action->flags & IRQF_SHARED))
                        desc->status |= IRQ_PENDING;
-               spin_unlock(&desc->lock);
+               raw_spin_unlock(&desc->lock);
                return ok;
        }
        /* Honour the normal IRQ locking */
        desc->status |= IRQ_INPROGRESS;
        action = desc->action;
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        while (action) {
                /* Only shared IRQ handlers are safe to call */
@@ -56,7 +56,7 @@ static int try_one_irq(int irq, struct irq_desc *desc)
        }
        local_irq_disable();
        /* Now clean up the flags */
-       spin_lock(&desc->lock);
+       raw_spin_lock(&desc->lock);
        action = desc->action;
 
        /*
@@ -68,9 +68,9 @@ static int try_one_irq(int irq, struct irq_desc *desc)
                 * Perform real IRQ processing for the IRQ we deferred
                 */
                work = 1;
-               spin_unlock(&desc->lock);
+               raw_spin_unlock(&desc->lock);
                handle_IRQ_event(irq, action);
-               spin_lock(&desc->lock);
+               raw_spin_lock(&desc->lock);
                desc->status &= ~IRQ_PENDING;
        }
        desc->status &= ~IRQ_INPROGRESS;
@@ -80,7 +80,7 @@ static int try_one_irq(int irq, struct irq_desc *desc)
         */
        if (work && desc->chip && desc->chip->end)
                desc->chip->end(irq);
-       spin_unlock(&desc->lock);
+       raw_spin_unlock(&desc->lock);
 
        return ok;
 }
index f336e2107f980e2546ecc118d2dd3239f655ebae..a9a93d9ee7a78e70068bca678826873376afd8a7 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/hardirq.h>
 #include <linux/elf.h>
 #include <linux/elfcore.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/utsname.h>
 #include <linux/numa.h>
 #include <linux/suspend.h>
@@ -31,6 +31,7 @@
 #include <linux/cpu.h>
 #include <linux/console.h>
 #include <linux/vmalloc.h>
+#include <linux/swap.h>
 
 #include <asm/page.h>
 #include <asm/uaccess.h>
@@ -1082,6 +1083,64 @@ void crash_kexec(struct pt_regs *regs)
        }
 }
 
+size_t crash_get_memory_size(void)
+{
+       size_t size;
+       mutex_lock(&kexec_mutex);
+       size = crashk_res.end - crashk_res.start + 1;
+       mutex_unlock(&kexec_mutex);
+       return size;
+}
+
+static void free_reserved_phys_range(unsigned long begin, unsigned long end)
+{
+       unsigned long addr;
+
+       for (addr = begin; addr < end; addr += PAGE_SIZE) {
+               ClearPageReserved(pfn_to_page(addr >> PAGE_SHIFT));
+               init_page_count(pfn_to_page(addr >> PAGE_SHIFT));
+               free_page((unsigned long)__va(addr));
+               totalram_pages++;
+       }
+}
+
+int crash_shrink_memory(unsigned long new_size)
+{
+       int ret = 0;
+       unsigned long start, end;
+
+       mutex_lock(&kexec_mutex);
+
+       if (kexec_crash_image) {
+               ret = -ENOENT;
+               goto unlock;
+       }
+       start = crashk_res.start;
+       end = crashk_res.end;
+
+       if (new_size >= end - start + 1) {
+               ret = -EINVAL;
+               if (new_size == end - start + 1)
+                       ret = 0;
+               goto unlock;
+       }
+
+       start = roundup(start, PAGE_SIZE);
+       end = roundup(start + new_size, PAGE_SIZE);
+
+       free_reserved_phys_range(end, crashk_res.end);
+
+       if (start == end) {
+               crashk_res.end = end;
+               release_resource(&crashk_res);
+       } else
+               crashk_res.end = end - 1;
+
+unlock:
+       mutex_unlock(&kexec_mutex);
+       return ret;
+}
+
 static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
                            size_t data_len)
 {
index 3765ff3c1bbe780118d6c04ec6391056dfda8f8a..e92d519f93b13e2721f25fb6e1b5d6cbf2af0125 100644 (file)
@@ -1,6 +1,7 @@
 /*
- * A simple kernel FIFO implementation.
+ * A generic kernel FIFO implementation.
  *
+ * Copyright (C) 2009 Stefani Seibold <stefani@seibold.net>
  * Copyright (C) 2004 Stelian Pop <stelian@popies.net>
  *
  * This program is free software; you can redistribute it and/or modify
 #include <linux/err.h>
 #include <linux/kfifo.h>
 #include <linux/log2.h>
+#include <linux/uaccess.h>
+
+static void _kfifo_init(struct kfifo *fifo, unsigned char *buffer,
+               unsigned int size)
+{
+       fifo->buffer = buffer;
+       fifo->size = size;
+
+       kfifo_reset(fifo);
+}
 
 /**
- * kfifo_init - allocates a new FIFO using a preallocated buffer
+ * kfifo_init - initialize a FIFO using a preallocated buffer
+ * @fifo: the fifo to assign the buffer
  * @buffer: the preallocated buffer to be used.
  * @size: the size of the internal buffer, this have to be a power of 2.
- * @gfp_mask: get_free_pages mask, passed to kmalloc()
- * @lock: the lock to be used to protect the fifo buffer
  *
- * Do NOT pass the kfifo to kfifo_free() after use! Simply free the
- * &struct kfifo with kfree().
  */
-struct kfifo *kfifo_init(unsigned char *buffer, unsigned int size,
-                        gfp_t gfp_mask, spinlock_t *lock)
+void kfifo_init(struct kfifo *fifo, unsigned char *buffer, unsigned int size)
 {
-       struct kfifo *fifo;
-
        /* size must be a power of 2 */
        BUG_ON(!is_power_of_2(size));
 
-       fifo = kmalloc(sizeof(struct kfifo), gfp_mask);
-       if (!fifo)
-               return ERR_PTR(-ENOMEM);
-
-       fifo->buffer = buffer;
-       fifo->size = size;
-       fifo->in = fifo->out = 0;
-       fifo->lock = lock;
-
-       return fifo;
+       _kfifo_init(fifo, buffer, size);
 }
 EXPORT_SYMBOL(kfifo_init);
 
 /**
- * kfifo_alloc - allocates a new FIFO and its internal buffer
- * @size: the size of the internal buffer to be allocated.
+ * kfifo_alloc - allocates a new FIFO internal buffer
+ * @fifo: the fifo to assign then new buffer
+ * @size: the size of the buffer to be allocated, this have to be a power of 2.
  * @gfp_mask: get_free_pages mask, passed to kmalloc()
- * @lock: the lock to be used to protect the fifo buffer
+ *
+ * This function dynamically allocates a new fifo internal buffer
  *
  * The size will be rounded-up to a power of 2.
+ * The buffer will be release with kfifo_free().
+ * Return 0 if no error, otherwise the an error code
  */
-struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock)
+int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask)
 {
        unsigned char *buffer;
-       struct kfifo *ret;
 
        /*
         * round up to the next power of 2, since our 'let the indices
@@ -80,48 +79,91 @@ struct kfifo *kfifo_alloc(unsigned int size, gfp_t gfp_mask, spinlock_t *lock)
        }
 
        buffer = kmalloc(size, gfp_mask);
-       if (!buffer)
-               return ERR_PTR(-ENOMEM);
-
-       ret = kfifo_init(buffer, size, gfp_mask, lock);
+       if (!buffer) {
+               _kfifo_init(fifo, 0, 0);
+               return -ENOMEM;
+       }
 
-       if (IS_ERR(ret))
-               kfree(buffer);
+       _kfifo_init(fifo, buffer, size);
 
-       return ret;
+       return 0;
 }
 EXPORT_SYMBOL(kfifo_alloc);
 
 /**
- * kfifo_free - frees the FIFO
+ * kfifo_free - frees the FIFO internal buffer
  * @fifo: the fifo to be freed.
  */
 void kfifo_free(struct kfifo *fifo)
 {
        kfree(fifo->buffer);
-       kfree(fifo);
 }
 EXPORT_SYMBOL(kfifo_free);
 
 /**
- * __kfifo_put - puts some data into the FIFO, no locking version
+ * kfifo_skip - skip output data
  * @fifo: the fifo to be used.
- * @buffer: the data to be added.
- * @len: the length of the data to be added.
- *
- * This function copies at most @len bytes from the @buffer into
- * the FIFO depending on the free space, and returns the number of
- * bytes copied.
- *
- * Note that with only one concurrent reader and one concurrent
- * writer, you don't need extra locking to use these functions.
+ * @len: number of bytes to skip
  */
-unsigned int __kfifo_put(struct kfifo *fifo,
-                       const unsigned char *buffer, unsigned int len)
+void kfifo_skip(struct kfifo *fifo, unsigned int len)
+{
+       if (len < kfifo_len(fifo)) {
+               __kfifo_add_out(fifo, len);
+               return;
+       }
+       kfifo_reset_out(fifo);
+}
+EXPORT_SYMBOL(kfifo_skip);
+
+static inline void __kfifo_in_data(struct kfifo *fifo,
+               const void *from, unsigned int len, unsigned int off)
 {
        unsigned int l;
 
-       len = min(len, fifo->size - fifo->in + fifo->out);
+       /*
+        * Ensure that we sample the fifo->out index -before- we
+        * start putting bytes into the kfifo.
+        */
+
+       smp_mb();
+
+       off = __kfifo_off(fifo, fifo->in + off);
+
+       /* first put the data starting from fifo->in to buffer end */
+       l = min(len, fifo->size - off);
+       memcpy(fifo->buffer + off, from, l);
+
+       /* then put the rest (if any) at the beginning of the buffer */
+       memcpy(fifo->buffer, from + l, len - l);
+}
+
+static inline void __kfifo_out_data(struct kfifo *fifo,
+               void *to, unsigned int len, unsigned int off)
+{
+       unsigned int l;
+
+       /*
+        * Ensure that we sample the fifo->in index -before- we
+        * start removing bytes from the kfifo.
+        */
+
+       smp_rmb();
+
+       off = __kfifo_off(fifo, fifo->out + off);
+
+       /* first get the data from fifo->out until the end of the buffer */
+       l = min(len, fifo->size - off);
+       memcpy(to, fifo->buffer + off, l);
+
+       /* then get the rest (if any) from the beginning of the buffer */
+       memcpy(to + l, fifo->buffer, len - l);
+}
+
+static inline unsigned int __kfifo_from_user_data(struct kfifo *fifo,
+        const void __user *from, unsigned int len, unsigned int off)
+{
+       unsigned int l;
+       int ret;
 
        /*
         * Ensure that we sample the fifo->out index -before- we
@@ -130,68 +172,229 @@ unsigned int __kfifo_put(struct kfifo *fifo,
 
        smp_mb();
 
+       off = __kfifo_off(fifo, fifo->in + off);
+
        /* first put the data starting from fifo->in to buffer end */
-       l = min(len, fifo->size - (fifo->in & (fifo->size - 1)));
-       memcpy(fifo->buffer + (fifo->in & (fifo->size - 1)), buffer, l);
+       l = min(len, fifo->size - off);
+       ret = copy_from_user(fifo->buffer + off, from, l);
+
+       if (unlikely(ret))
+               return ret + len - l;
 
        /* then put the rest (if any) at the beginning of the buffer */
-       memcpy(fifo->buffer, buffer + l, len - l);
+       return copy_from_user(fifo->buffer, from + l, len - l);
+}
+
+static inline unsigned int __kfifo_to_user_data(struct kfifo *fifo,
+               void __user *to, unsigned int len, unsigned int off)
+{
+       unsigned int l;
+       int ret;
 
        /*
-        * Ensure that we add the bytes to the kfifo -before-
-        * we update the fifo->in index.
+        * Ensure that we sample the fifo->in index -before- we
+        * start removing bytes from the kfifo.
         */
 
-       smp_wmb();
+       smp_rmb();
+
+       off = __kfifo_off(fifo, fifo->out + off);
+
+       /* first get the data from fifo->out until the end of the buffer */
+       l = min(len, fifo->size - off);
+       ret = copy_to_user(to, fifo->buffer + off, l);
+
+       if (unlikely(ret))
+               return ret + len - l;
+
+       /* then get the rest (if any) from the beginning of the buffer */
+       return copy_to_user(to + l, fifo->buffer, len - l);
+}
+
+unsigned int __kfifo_in_n(struct kfifo *fifo,
+       const void *from, unsigned int len, unsigned int recsize)
+{
+       if (kfifo_avail(fifo) < len + recsize)
+               return len + 1;
+
+       __kfifo_in_data(fifo, from, len, recsize);
+       return 0;
+}
+EXPORT_SYMBOL(__kfifo_in_n);
 
-       fifo->in += len;
+/**
+ * kfifo_in - puts some data into the FIFO
+ * @fifo: the fifo to be used.
+ * @from: the data to be added.
+ * @len: the length of the data to be added.
+ *
+ * This function copies at most @len bytes from the @from buffer into
+ * the FIFO depending on the free space, and returns the number of
+ * bytes copied.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
+ */
+unsigned int kfifo_in(struct kfifo *fifo, const unsigned char *from,
+                               unsigned int len)
+{
+       len = min(kfifo_avail(fifo), len);
 
+       __kfifo_in_data(fifo, from, len, 0);
+       __kfifo_add_in(fifo, len);
        return len;
 }
-EXPORT_SYMBOL(__kfifo_put);
+EXPORT_SYMBOL(kfifo_in);
+
+unsigned int __kfifo_in_generic(struct kfifo *fifo,
+       const void *from, unsigned int len, unsigned int recsize)
+{
+       return __kfifo_in_rec(fifo, from, len, recsize);
+}
+EXPORT_SYMBOL(__kfifo_in_generic);
+
+unsigned int __kfifo_out_n(struct kfifo *fifo,
+       void *to, unsigned int len, unsigned int recsize)
+{
+       if (kfifo_len(fifo) < len + recsize)
+               return len;
+
+       __kfifo_out_data(fifo, to, len, recsize);
+       __kfifo_add_out(fifo, len + recsize);
+       return 0;
+}
+EXPORT_SYMBOL(__kfifo_out_n);
 
 /**
- * __kfifo_get - gets some data from the FIFO, no locking version
+ * kfifo_out - gets some data from the FIFO
  * @fifo: the fifo to be used.
- * @buffer: where the data must be copied.
+ * @to: where the data must be copied.
  * @len: the size of the destination buffer.
  *
  * This function copies at most @len bytes from the FIFO into the
- * @buffer and returns the number of copied bytes.
+ * @to buffer and returns the number of copied bytes.
  *
  * Note that with only one concurrent reader and one concurrent
  * writer, you don't need extra locking to use these functions.
  */
-unsigned int __kfifo_get(struct kfifo *fifo,
-                        unsigned char *buffer, unsigned int len)
+unsigned int kfifo_out(struct kfifo *fifo, unsigned char *to, unsigned int len)
 {
-       unsigned int l;
+       len = min(kfifo_len(fifo), len);
 
-       len = min(len, fifo->in - fifo->out);
+       __kfifo_out_data(fifo, to, len, 0);
+       __kfifo_add_out(fifo, len);
 
-       /*
-        * Ensure that we sample the fifo->in index -before- we
-        * start removing bytes from the kfifo.
-        */
+       return len;
+}
+EXPORT_SYMBOL(kfifo_out);
 
-       smp_rmb();
+unsigned int __kfifo_out_generic(struct kfifo *fifo,
+       void *to, unsigned int len, unsigned int recsize,
+       unsigned int *total)
+{
+       return __kfifo_out_rec(fifo, to, len, recsize, total);
+}
+EXPORT_SYMBOL(__kfifo_out_generic);
 
-       /* first get the data from fifo->out until the end of the buffer */
-       l = min(len, fifo->size - (fifo->out & (fifo->size - 1)));
-       memcpy(buffer, fifo->buffer + (fifo->out & (fifo->size - 1)), l);
+unsigned int __kfifo_from_user_n(struct kfifo *fifo,
+       const void __user *from, unsigned int len, unsigned int recsize)
+{
+       if (kfifo_avail(fifo) < len + recsize)
+               return len + 1;
 
-       /* then get the rest (if any) from the beginning of the buffer */
-       memcpy(buffer + l, fifo->buffer, len - l);
+       return __kfifo_from_user_data(fifo, from, len, recsize);
+}
+EXPORT_SYMBOL(__kfifo_from_user_n);
 
-       /*
-        * Ensure that we remove the bytes from the kfifo -before-
-        * we update the fifo->out index.
-        */
+/**
+ * kfifo_from_user - puts some data from user space into the FIFO
+ * @fifo: the fifo to be used.
+ * @from: pointer to the data to be added.
+ * @len: the length of the data to be added.
+ *
+ * This function copies at most @len bytes from the @from into the
+ * FIFO depending and returns the number of copied bytes.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
+ */
+unsigned int kfifo_from_user(struct kfifo *fifo,
+       const void __user *from, unsigned int len)
+{
+       len = min(kfifo_avail(fifo), len);
+       len -= __kfifo_from_user_data(fifo, from, len, 0);
+       __kfifo_add_in(fifo, len);
+       return len;
+}
+EXPORT_SYMBOL(kfifo_from_user);
 
-       smp_mb();
+unsigned int __kfifo_from_user_generic(struct kfifo *fifo,
+       const void __user *from, unsigned int len, unsigned int recsize)
+{
+       return __kfifo_from_user_rec(fifo, from, len, recsize);
+}
+EXPORT_SYMBOL(__kfifo_from_user_generic);
 
-       fifo->out += len;
+unsigned int __kfifo_to_user_n(struct kfifo *fifo,
+       void __user *to, unsigned int len, unsigned int reclen,
+       unsigned int recsize)
+{
+       unsigned int ret;
+
+       if (kfifo_len(fifo) < reclen + recsize)
+               return len;
+
+       ret = __kfifo_to_user_data(fifo, to, reclen, recsize);
 
+       if (likely(ret == 0))
+               __kfifo_add_out(fifo, reclen + recsize);
+
+       return ret;
+}
+EXPORT_SYMBOL(__kfifo_to_user_n);
+
+/**
+ * kfifo_to_user - gets data from the FIFO and write it to user space
+ * @fifo: the fifo to be used.
+ * @to: where the data must be copied.
+ * @len: the size of the destination buffer.
+ *
+ * This function copies at most @len bytes from the FIFO into the
+ * @to buffer and returns the number of copied bytes.
+ *
+ * Note that with only one concurrent reader and one concurrent
+ * writer, you don't need extra locking to use these functions.
+ */
+unsigned int kfifo_to_user(struct kfifo *fifo,
+       void __user *to, unsigned int len)
+{
+       len = min(kfifo_len(fifo), len);
+       len -= __kfifo_to_user_data(fifo, to, len, 0);
+       __kfifo_add_out(fifo, len);
        return len;
 }
-EXPORT_SYMBOL(__kfifo_get);
+EXPORT_SYMBOL(kfifo_to_user);
+
+unsigned int __kfifo_to_user_generic(struct kfifo *fifo,
+       void __user *to, unsigned int len, unsigned int recsize,
+       unsigned int *total)
+{
+       return __kfifo_to_user_rec(fifo, to, len, recsize, total);
+}
+EXPORT_SYMBOL(__kfifo_to_user_generic);
+
+unsigned int __kfifo_peek_generic(struct kfifo *fifo, unsigned int recsize)
+{
+       if (recsize == 0)
+               return kfifo_avail(fifo);
+
+       return __kfifo_peek_n(fifo, recsize);
+}
+EXPORT_SYMBOL(__kfifo_peek_generic);
+
+void __kfifo_skip_generic(struct kfifo *fifo, unsigned int recsize)
+{
+       __kfifo_skip_rec(fifo, recsize);
+}
+EXPORT_SYMBOL(__kfifo_skip_generic);
+
index 528dd78e7e7e94595106d70c6eefb35d3a5b89aa..3feaf5a745140512f1e13a0bf6a6e46683ab4915 100644 (file)
@@ -100,6 +100,26 @@ static ssize_t kexec_crash_loaded_show(struct kobject *kobj,
 }
 KERNEL_ATTR_RO(kexec_crash_loaded);
 
+static ssize_t kexec_crash_size_show(struct kobject *kobj,
+                                      struct kobj_attribute *attr, char *buf)
+{
+       return sprintf(buf, "%zu\n", crash_get_memory_size());
+}
+static ssize_t kexec_crash_size_store(struct kobject *kobj,
+                                  struct kobj_attribute *attr,
+                                  const char *buf, size_t count)
+{
+       unsigned long cnt;
+       int ret;
+
+       if (strict_strtoul(buf, 0, &cnt))
+               return -EINVAL;
+
+       ret = crash_shrink_memory(cnt);
+       return ret < 0 ? ret : count;
+}
+KERNEL_ATTR_RW(kexec_crash_size);
+
 static ssize_t vmcoreinfo_show(struct kobject *kobj,
                               struct kobj_attribute *attr, char *buf)
 {
@@ -147,6 +167,7 @@ static struct attribute * kernel_attrs[] = {
 #ifdef CONFIG_KEXEC
        &kexec_loaded_attr.attr,
        &kexec_crash_loaded_attr.attr,
+       &kexec_crash_size_attr.attr,
        &vmcoreinfo_attr.attr,
 #endif
        NULL
index ab7ae57773e1b41f263407eb4a3bad1c95b41289..fbb6222fe7e04d6dd863ea7975e70c4f3f78636d 100644 (file)
@@ -149,6 +149,29 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
 }
 EXPORT_SYMBOL(kthread_create);
 
+/**
+ * kthread_bind - bind a just-created kthread to a cpu.
+ * @p: thread created by kthread_create().
+ * @cpu: cpu (might not be online, must be possible) for @k to run on.
+ *
+ * Description: This function is equivalent to set_cpus_allowed(),
+ * except that @cpu doesn't need to be online, and the thread must be
+ * stopped (i.e., just returned from kthread_create()).
+ */
+void kthread_bind(struct task_struct *p, unsigned int cpu)
+{
+       /* Must have done schedule() in kthread() before we set_task_cpu */
+       if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE)) {
+               WARN_ON(1);
+               return;
+       }
+
+       p->cpus_allowed = cpumask_of_cpu(cpu);
+       p->rt.nr_cpus_allowed = 1;
+       p->flags |= PF_THREAD_BOUND;
+}
+EXPORT_SYMBOL(kthread_bind);
+
 /**
  * kthread_stop - stop a thread created by kthread_create().
  * @k: thread created by kthread_create().
index 429540c70d3f497ae7fc58998b0f248817a2cbf9..5feaddcdbe492f6fb3cb49f4175a0434d5b9c2a8 100644 (file)
@@ -73,11 +73,11 @@ module_param(lock_stat, int, 0644);
  * to use a raw spinlock - we really dont want the spinlock
  * code to recurse back into the lockdep code...
  */
-static raw_spinlock_t lockdep_lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+static arch_spinlock_t lockdep_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
 
 static int graph_lock(void)
 {
-       __raw_spin_lock(&lockdep_lock);
+       arch_spin_lock(&lockdep_lock);
        /*
         * Make sure that if another CPU detected a bug while
         * walking the graph we dont change it (while the other
@@ -85,7 +85,7 @@ static int graph_lock(void)
         * dropped already)
         */
        if (!debug_locks) {
-               __raw_spin_unlock(&lockdep_lock);
+               arch_spin_unlock(&lockdep_lock);
                return 0;
        }
        /* prevent any recursions within lockdep from causing deadlocks */
@@ -95,11 +95,11 @@ static int graph_lock(void)
 
 static inline int graph_unlock(void)
 {
-       if (debug_locks && !__raw_spin_is_locked(&lockdep_lock))
+       if (debug_locks && !arch_spin_is_locked(&lockdep_lock))
                return DEBUG_LOCKS_WARN_ON(1);
 
        current->lockdep_recursion--;
-       __raw_spin_unlock(&lockdep_lock);
+       arch_spin_unlock(&lockdep_lock);
        return 0;
 }
 
@@ -111,7 +111,7 @@ static inline int debug_locks_off_graph_unlock(void)
 {
        int ret = debug_locks_off();
 
-       __raw_spin_unlock(&lockdep_lock);
+       arch_spin_unlock(&lockdep_lock);
 
        return ret;
 }
@@ -1170,9 +1170,9 @@ unsigned long lockdep_count_forward_deps(struct lock_class *class)
        this.class = class;
 
        local_irq_save(flags);
-       __raw_spin_lock(&lockdep_lock);
+       arch_spin_lock(&lockdep_lock);
        ret = __lockdep_count_forward_deps(&this);
-       __raw_spin_unlock(&lockdep_lock);
+       arch_spin_unlock(&lockdep_lock);
        local_irq_restore(flags);
 
        return ret;
@@ -1197,9 +1197,9 @@ unsigned long lockdep_count_backward_deps(struct lock_class *class)
        this.class = class;
 
        local_irq_save(flags);
-       __raw_spin_lock(&lockdep_lock);
+       arch_spin_lock(&lockdep_lock);
        ret = __lockdep_count_backward_deps(&this);
-       __raw_spin_unlock(&lockdep_lock);
+       arch_spin_unlock(&lockdep_lock);
        local_irq_restore(flags);
 
        return ret;
index 12afc5a3ddd3a73972604050695ff4ab4ef708f6..e96b8ed1cb6aff09033114dd219157b84e8b23a3 100644 (file)
@@ -880,11 +880,23 @@ static int try_to_force_load(struct module *mod, const char *reason)
 }
 
 #ifdef CONFIG_MODVERSIONS
+/* If the arch applies (non-zero) relocations to kernel kcrctab, unapply it. */
+static unsigned long maybe_relocated(unsigned long crc,
+                                    const struct module *crc_owner)
+{
+#ifdef ARCH_RELOCATES_KCRCTAB
+       if (crc_owner == NULL)
+               return crc - (unsigned long)reloc_start;
+#endif
+       return crc;
+}
+
 static int check_version(Elf_Shdr *sechdrs,
                         unsigned int versindex,
                         const char *symname,
                         struct module *mod, 
-                        const unsigned long *crc)
+                        const unsigned long *crc,
+                        const struct module *crc_owner)
 {
        unsigned int i, num_versions;
        struct modversion_info *versions;
@@ -905,10 +917,10 @@ static int check_version(Elf_Shdr *sechdrs,
                if (strcmp(versions[i].name, symname) != 0)
                        continue;
 
-               if (versions[i].crc == *crc)
+               if (versions[i].crc == maybe_relocated(*crc, crc_owner))
                        return 1;
                DEBUGP("Found checksum %lX vs module %lX\n",
-                      *crc, versions[i].crc);
+                      maybe_relocated(*crc, crc_owner), versions[i].crc);
                goto bad_version;
        }
 
@@ -931,7 +943,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
        if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
                         &crc, true, false))
                BUG();
-       return check_version(sechdrs, versindex, "module_layout", mod, crc);
+       return check_version(sechdrs, versindex, "module_layout", mod, crc,
+                            NULL);
 }
 
 /* First part is kernel version, which we ignore if module has crcs. */
@@ -949,7 +962,8 @@ static inline int check_version(Elf_Shdr *sechdrs,
                                unsigned int versindex,
                                const char *symname,
                                struct module *mod, 
-                               const unsigned long *crc)
+                               const unsigned long *crc,
+                               const struct module *crc_owner)
 {
        return 1;
 }
@@ -984,8 +998,8 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs,
        /* use_module can fail due to OOM,
           or module initialization or unloading */
        if (sym) {
-               if (!check_version(sechdrs, versindex, name, mod, crc) ||
-                   !use_module(mod, owner))
+               if (!check_version(sechdrs, versindex, name, mod, crc, owner)
+                   || !use_module(mod, owner))
                        sym = NULL;
        }
        return sym;
@@ -1896,9 +1910,7 @@ static void kmemleak_load_module(struct module *mod, Elf_Ehdr *hdr,
        unsigned int i;
 
        /* only scan the sections containing data */
-       kmemleak_scan_area(mod->module_core, (unsigned long)mod -
-                          (unsigned long)mod->module_core,
-                          sizeof(struct module), GFP_KERNEL);
+       kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL);
 
        for (i = 1; i < hdr->e_shnum; i++) {
                if (!(sechdrs[i].sh_flags & SHF_ALLOC))
@@ -1907,8 +1919,7 @@ static void kmemleak_load_module(struct module *mod, Elf_Ehdr *hdr,
                    && strncmp(secstrings + sechdrs[i].sh_name, ".bss", 4) != 0)
                        continue;
 
-               kmemleak_scan_area(mod->module_core, sechdrs[i].sh_addr -
-                                  (unsigned long)mod->module_core,
+               kmemleak_scan_area((void *)sechdrs[i].sh_addr,
                                   sechdrs[i].sh_size, GFP_KERNEL);
        }
 }
@@ -2236,6 +2247,12 @@ static noinline struct module *load_module(void __user *umod,
                                         "_ftrace_events",
                                         sizeof(*mod->trace_events),
                                         &mod->num_trace_events);
+       /*
+        * This section contains pointers to allocated objects in the trace
+        * code and not scanning it leads to false positives.
+        */
+       kmemleak_scan_area(mod->trace_events, sizeof(*mod->trace_events) *
+                          mod->num_trace_events, GFP_KERNEL);
 #endif
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
        /* sechdrs[0].sh_size is always zero */
index 6b2d735846a56f17425749b6501fe2023c0e6cdb..57d527a16f9d1058bb9aacf3fa7ebba64a7c032b 100644 (file)
@@ -43,13 +43,13 @@ static inline void mutex_clear_owner(struct mutex *lock)
                                                        \
                DEBUG_LOCKS_WARN_ON(in_interrupt());    \
                local_irq_save(flags);                  \
-               __raw_spin_lock(&(lock)->raw_lock);     \
+               arch_spin_lock(&(lock)->rlock.raw_lock);\
                DEBUG_LOCKS_WARN_ON(l->magic != l);     \
        } while (0)
 
-#define spin_unlock_mutex(lock, flags)                 \
-       do {                                            \
-               __raw_spin_unlock(&(lock)->raw_lock);   \
-               local_irq_restore(flags);               \
-               preempt_check_resched();                \
+#define spin_unlock_mutex(lock, flags)                         \
+       do {                                                    \
+               arch_spin_unlock(&(lock)->rlock.raw_lock);      \
+               local_irq_restore(flags);                       \
+               preempt_check_resched();                        \
        } while (0)
index 96b45d0b4ba50853030c295f5b0dbcf9bf33cc88..5827f7b972542f10d9accb69e218af4f7b105c91 100644 (file)
@@ -10,6 +10,7 @@
  */
 #include <linux/debug_locks.h>
 #include <linux/interrupt.h>
+#include <linux/kmsg_dump.h>
 #include <linux/kallsyms.h>
 #include <linux/notifier.h>
 #include <linux/module.h>
@@ -74,6 +75,7 @@ NORET_TYPE void panic(const char * fmt, ...)
        dump_stack();
 #endif
 
+       kmsg_dump(KMSG_DUMP_PANIC);
        /*
         * If we have crashed and we have a crash kernel loaded let it handle
         * everything else.
@@ -339,6 +341,7 @@ void oops_exit(void)
 {
        do_oops_enter_exit();
        print_oops_end_marker();
+       kmsg_dump(KMSG_DUMP_OOPS);
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
index d656c276508de6a9bbeb62407b59e477ff7ff61e..cf1b691831275f85247ebd93628b8015fac1c70d 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 
 #if 0
 #define DEBUGP printk
@@ -122,9 +123,7 @@ static char *next_arg(char *args, char **param, char **val)
                next = args + i;
 
        /* Chew up trailing spaces. */
-       while (isspace(*next))
-               next++;
-       return next;
+       return skip_spaces(next);
 }
 
 /* Args looks like "foo=bar,bar2 baz=fuz wiz". */
@@ -139,8 +138,7 @@ int parse_args(const char *name,
        DEBUGP("Parsing ARGS: %s\n", args);
 
        /* Chew leading spaces */
-       while (isspace(*args))
-               args++;
+       args = skip_spaces(args);
 
        while (*args) {
                int ret;
index e73e53c7582f9a3d872622b277187e31de3db206..1f38270f08c7d62613665ac6cbb07fccef1c51b6 100644 (file)
@@ -203,14 +203,14 @@ perf_lock_task_context(struct task_struct *task, unsigned long *flags)
                 * if so.  If we locked the right context, then it
                 * can't get swapped on us any more.
                 */
-               spin_lock_irqsave(&ctx->lock, *flags);
+               raw_spin_lock_irqsave(&ctx->lock, *flags);
                if (ctx != rcu_dereference(task->perf_event_ctxp)) {
-                       spin_unlock_irqrestore(&ctx->lock, *flags);
+                       raw_spin_unlock_irqrestore(&ctx->lock, *flags);
                        goto retry;
                }
 
                if (!atomic_inc_not_zero(&ctx->refcount)) {
-                       spin_unlock_irqrestore(&ctx->lock, *flags);
+                       raw_spin_unlock_irqrestore(&ctx->lock, *flags);
                        ctx = NULL;
                }
        }
@@ -231,7 +231,7 @@ static struct perf_event_context *perf_pin_task_context(struct task_struct *task
        ctx = perf_lock_task_context(task, &flags);
        if (ctx) {
                ++ctx->pin_count;
-               spin_unlock_irqrestore(&ctx->lock, flags);
+               raw_spin_unlock_irqrestore(&ctx->lock, flags);
        }
        return ctx;
 }
@@ -240,9 +240,9 @@ static void perf_unpin_context(struct perf_event_context *ctx)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&ctx->lock, flags);
+       raw_spin_lock_irqsave(&ctx->lock, flags);
        --ctx->pin_count;
-       spin_unlock_irqrestore(&ctx->lock, flags);
+       raw_spin_unlock_irqrestore(&ctx->lock, flags);
        put_ctx(ctx);
 }
 
@@ -427,7 +427,7 @@ static void __perf_event_remove_from_context(void *info)
        if (ctx->task && cpuctx->task_ctx != ctx)
                return;
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
        /*
         * Protect the list operation against NMI by disabling the
         * events on a global level.
@@ -449,7 +449,7 @@ static void __perf_event_remove_from_context(void *info)
        }
 
        perf_enable();
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 }
 
 
@@ -488,12 +488,12 @@ retry:
        task_oncpu_function_call(task, __perf_event_remove_from_context,
                                 event);
 
-       spin_lock_irq(&ctx->lock);
+       raw_spin_lock_irq(&ctx->lock);
        /*
         * If the context is active we need to retry the smp call.
         */
        if (ctx->nr_active && !list_empty(&event->group_entry)) {
-               spin_unlock_irq(&ctx->lock);
+               raw_spin_unlock_irq(&ctx->lock);
                goto retry;
        }
 
@@ -504,7 +504,7 @@ retry:
         */
        if (!list_empty(&event->group_entry))
                list_del_event(event, ctx);
-       spin_unlock_irq(&ctx->lock);
+       raw_spin_unlock_irq(&ctx->lock);
 }
 
 /*
@@ -535,7 +535,7 @@ static void __perf_event_disable(void *info)
        if (ctx->task && cpuctx->task_ctx != ctx)
                return;
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
 
        /*
         * If the event is on, turn it off.
@@ -551,7 +551,7 @@ static void __perf_event_disable(void *info)
                event->state = PERF_EVENT_STATE_OFF;
        }
 
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 }
 
 /*
@@ -584,12 +584,12 @@ void perf_event_disable(struct perf_event *event)
  retry:
        task_oncpu_function_call(task, __perf_event_disable, event);
 
-       spin_lock_irq(&ctx->lock);
+       raw_spin_lock_irq(&ctx->lock);
        /*
         * If the event is still active, we need to retry the cross-call.
         */
        if (event->state == PERF_EVENT_STATE_ACTIVE) {
-               spin_unlock_irq(&ctx->lock);
+               raw_spin_unlock_irq(&ctx->lock);
                goto retry;
        }
 
@@ -602,7 +602,7 @@ void perf_event_disable(struct perf_event *event)
                event->state = PERF_EVENT_STATE_OFF;
        }
 
-       spin_unlock_irq(&ctx->lock);
+       raw_spin_unlock_irq(&ctx->lock);
 }
 
 static int
@@ -770,7 +770,7 @@ static void __perf_install_in_context(void *info)
                cpuctx->task_ctx = ctx;
        }
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
        ctx->is_active = 1;
        update_context_time(ctx);
 
@@ -782,6 +782,9 @@ static void __perf_install_in_context(void *info)
 
        add_event_to_ctx(event, ctx);
 
+       if (event->cpu != -1 && event->cpu != smp_processor_id())
+               goto unlock;
+
        /*
         * Don't put the event on if it is disabled or if
         * it is in a group and the group isn't on.
@@ -820,7 +823,7 @@ static void __perf_install_in_context(void *info)
  unlock:
        perf_enable();
 
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 }
 
 /*
@@ -856,12 +859,12 @@ retry:
        task_oncpu_function_call(task, __perf_install_in_context,
                                 event);
 
-       spin_lock_irq(&ctx->lock);
+       raw_spin_lock_irq(&ctx->lock);
        /*
         * we need to retry the smp call.
         */
        if (ctx->is_active && list_empty(&event->group_entry)) {
-               spin_unlock_irq(&ctx->lock);
+               raw_spin_unlock_irq(&ctx->lock);
                goto retry;
        }
 
@@ -872,7 +875,7 @@ retry:
         */
        if (list_empty(&event->group_entry))
                add_event_to_ctx(event, ctx);
-       spin_unlock_irq(&ctx->lock);
+       raw_spin_unlock_irq(&ctx->lock);
 }
 
 /*
@@ -917,7 +920,7 @@ static void __perf_event_enable(void *info)
                cpuctx->task_ctx = ctx;
        }
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
        ctx->is_active = 1;
        update_context_time(ctx);
 
@@ -925,6 +928,9 @@ static void __perf_event_enable(void *info)
                goto unlock;
        __perf_event_mark_enabled(event, ctx);
 
+       if (event->cpu != -1 && event->cpu != smp_processor_id())
+               goto unlock;
+
        /*
         * If the event is in a group and isn't the group leader,
         * then don't put it on unless the group is on.
@@ -959,7 +965,7 @@ static void __perf_event_enable(void *info)
        }
 
  unlock:
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 }
 
 /*
@@ -985,7 +991,7 @@ void perf_event_enable(struct perf_event *event)
                return;
        }
 
-       spin_lock_irq(&ctx->lock);
+       raw_spin_lock_irq(&ctx->lock);
        if (event->state >= PERF_EVENT_STATE_INACTIVE)
                goto out;
 
@@ -1000,10 +1006,10 @@ void perf_event_enable(struct perf_event *event)
                event->state = PERF_EVENT_STATE_OFF;
 
  retry:
-       spin_unlock_irq(&ctx->lock);
+       raw_spin_unlock_irq(&ctx->lock);
        task_oncpu_function_call(task, __perf_event_enable, event);
 
-       spin_lock_irq(&ctx->lock);
+       raw_spin_lock_irq(&ctx->lock);
 
        /*
         * If the context is active and the event is still off,
@@ -1020,7 +1026,7 @@ void perf_event_enable(struct perf_event *event)
                __perf_event_mark_enabled(event, ctx);
 
  out:
-       spin_unlock_irq(&ctx->lock);
+       raw_spin_unlock_irq(&ctx->lock);
 }
 
 static int perf_event_refresh(struct perf_event *event, int refresh)
@@ -1042,7 +1048,7 @@ void __perf_event_sched_out(struct perf_event_context *ctx,
 {
        struct perf_event *event;
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
        ctx->is_active = 0;
        if (likely(!ctx->nr_events))
                goto out;
@@ -1055,7 +1061,7 @@ void __perf_event_sched_out(struct perf_event_context *ctx,
        }
        perf_enable();
  out:
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 }
 
 /*
@@ -1193,8 +1199,8 @@ void perf_event_task_sched_out(struct task_struct *task,
                 * order we take the locks because no other cpu could
                 * be trying to lock both of these tasks.
                 */
-               spin_lock(&ctx->lock);
-               spin_lock_nested(&next_ctx->lock, SINGLE_DEPTH_NESTING);
+               raw_spin_lock(&ctx->lock);
+               raw_spin_lock_nested(&next_ctx->lock, SINGLE_DEPTH_NESTING);
                if (context_equiv(ctx, next_ctx)) {
                        /*
                         * XXX do we need a memory barrier of sorts
@@ -1208,8 +1214,8 @@ void perf_event_task_sched_out(struct task_struct *task,
 
                        perf_event_sync_stat(ctx, next_ctx);
                }
-               spin_unlock(&next_ctx->lock);
-               spin_unlock(&ctx->lock);
+               raw_spin_unlock(&next_ctx->lock);
+               raw_spin_unlock(&ctx->lock);
        }
        rcu_read_unlock();
 
@@ -1251,7 +1257,7 @@ __perf_event_sched_in(struct perf_event_context *ctx,
        struct perf_event *event;
        int can_add_hw = 1;
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
        ctx->is_active = 1;
        if (likely(!ctx->nr_events))
                goto out;
@@ -1306,7 +1312,7 @@ __perf_event_sched_in(struct perf_event_context *ctx,
        }
        perf_enable();
  out:
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 }
 
 /*
@@ -1370,11 +1376,14 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx)
        struct hw_perf_event *hwc;
        u64 interrupts, freq;
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
        list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
                if (event->state != PERF_EVENT_STATE_ACTIVE)
                        continue;
 
+               if (event->cpu != -1 && event->cpu != smp_processor_id())
+                       continue;
+
                hwc = &event->hw;
 
                interrupts = hwc->interrupts;
@@ -1425,7 +1434,7 @@ static void perf_ctx_adjust_freq(struct perf_event_context *ctx)
                        perf_enable();
                }
        }
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 }
 
 /*
@@ -1438,7 +1447,7 @@ static void rotate_ctx(struct perf_event_context *ctx)
        if (!ctx->nr_events)
                return;
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
        /*
         * Rotate the first entry last (works just fine for group events too):
         */
@@ -1449,7 +1458,7 @@ static void rotate_ctx(struct perf_event_context *ctx)
        }
        perf_enable();
 
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 }
 
 void perf_event_task_tick(struct task_struct *curr, int cpu)
@@ -1498,7 +1507,7 @@ static void perf_event_enable_on_exec(struct task_struct *task)
 
        __perf_event_task_sched_out(ctx);
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
 
        list_for_each_entry(event, &ctx->group_list, group_entry) {
                if (!event->attr.enable_on_exec)
@@ -1516,7 +1525,7 @@ static void perf_event_enable_on_exec(struct task_struct *task)
        if (enabled)
                unclone_ctx(ctx);
 
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 
        perf_event_task_sched_in(task, smp_processor_id());
  out:
@@ -1542,10 +1551,10 @@ static void __perf_event_read(void *info)
        if (ctx->task && cpuctx->task_ctx != ctx)
                return;
 
-       spin_lock(&ctx->lock);
+       raw_spin_lock(&ctx->lock);
        update_context_time(ctx);
        update_event_times(event);
-       spin_unlock(&ctx->lock);
+       raw_spin_unlock(&ctx->lock);
 
        event->pmu->read(event);
 }
@@ -1563,10 +1572,10 @@ static u64 perf_event_read(struct perf_event *event)
                struct perf_event_context *ctx = event->ctx;
                unsigned long flags;
 
-               spin_lock_irqsave(&ctx->lock, flags);
+               raw_spin_lock_irqsave(&ctx->lock, flags);
                update_context_time(ctx);
                update_event_times(event);
-               spin_unlock_irqrestore(&ctx->lock, flags);
+               raw_spin_unlock_irqrestore(&ctx->lock, flags);
        }
 
        return atomic64_read(&event->count);
@@ -1579,7 +1588,7 @@ static void
 __perf_event_init_context(struct perf_event_context *ctx,
                            struct task_struct *task)
 {
-       spin_lock_init(&ctx->lock);
+       raw_spin_lock_init(&ctx->lock);
        mutex_init(&ctx->mutex);
        INIT_LIST_HEAD(&ctx->group_list);
        INIT_LIST_HEAD(&ctx->event_list);
@@ -1595,15 +1604,12 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu)
        unsigned long flags;
        int err;
 
-       /*
-        * If cpu is not a wildcard then this is a percpu event:
-        */
-       if (cpu != -1) {
+       if (pid == -1 && cpu != -1) {
                /* Must be root to operate on a CPU event: */
                if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
                        return ERR_PTR(-EACCES);
 
-               if (cpu < 0 || cpu > num_possible_cpus())
+               if (cpu < 0 || cpu >= nr_cpumask_bits)
                        return ERR_PTR(-EINVAL);
 
                /*
@@ -1611,7 +1617,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu)
                 * offline CPU and activate it when the CPU comes up, but
                 * that's for later.
                 */
-               if (!cpu_isset(cpu, cpu_online_map))
+               if (!cpu_online(cpu))
                        return ERR_PTR(-ENODEV);
 
                cpuctx = &per_cpu(perf_cpu_context, cpu);
@@ -1649,7 +1655,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu)
        ctx = perf_lock_task_context(task, &flags);
        if (ctx) {
                unclone_ctx(ctx);
-               spin_unlock_irqrestore(&ctx->lock, flags);
+               raw_spin_unlock_irqrestore(&ctx->lock, flags);
        }
 
        if (!ctx) {
@@ -1987,7 +1993,7 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
        if (!value)
                return -EINVAL;
 
-       spin_lock_irq(&ctx->lock);
+       raw_spin_lock_irq(&ctx->lock);
        if (event->attr.freq) {
                if (value > sysctl_perf_event_sample_rate) {
                        ret = -EINVAL;
@@ -2000,7 +2006,7 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg)
                event->hw.sample_period = value;
        }
 unlock:
-       spin_unlock_irq(&ctx->lock);
+       raw_spin_unlock_irq(&ctx->lock);
 
        return ret;
 }
@@ -3262,6 +3268,9 @@ static void perf_event_task_output(struct perf_event *event,
 
 static int perf_event_task_match(struct perf_event *event)
 {
+       if (event->cpu != -1 && event->cpu != smp_processor_id())
+               return 0;
+
        if (event->attr.comm || event->attr.mmap || event->attr.task)
                return 1;
 
@@ -3287,12 +3296,11 @@ static void perf_event_task_event(struct perf_task_event *task_event)
        rcu_read_lock();
        cpuctx = &get_cpu_var(perf_cpu_context);
        perf_event_task_ctx(&cpuctx->ctx, task_event);
-       put_cpu_var(perf_cpu_context);
-
        if (!ctx)
                ctx = rcu_dereference(task_event->task->perf_event_ctxp);
        if (ctx)
                perf_event_task_ctx(ctx, task_event);
+       put_cpu_var(perf_cpu_context);
        rcu_read_unlock();
 }
 
@@ -3369,6 +3377,9 @@ static void perf_event_comm_output(struct perf_event *event,
 
 static int perf_event_comm_match(struct perf_event *event)
 {
+       if (event->cpu != -1 && event->cpu != smp_processor_id())
+               return 0;
+
        if (event->attr.comm)
                return 1;
 
@@ -3405,15 +3416,10 @@ static void perf_event_comm_event(struct perf_comm_event *comm_event)
        rcu_read_lock();
        cpuctx = &get_cpu_var(perf_cpu_context);
        perf_event_comm_ctx(&cpuctx->ctx, comm_event);
-       put_cpu_var(perf_cpu_context);
-
-       /*
-        * doesn't really matter which of the child contexts the
-        * events ends up in.
-        */
        ctx = rcu_dereference(current->perf_event_ctxp);
        if (ctx)
                perf_event_comm_ctx(ctx, comm_event);
+       put_cpu_var(perf_cpu_context);
        rcu_read_unlock();
 }
 
@@ -3488,6 +3494,9 @@ static void perf_event_mmap_output(struct perf_event *event,
 static int perf_event_mmap_match(struct perf_event *event,
                                   struct perf_mmap_event *mmap_event)
 {
+       if (event->cpu != -1 && event->cpu != smp_processor_id())
+               return 0;
+
        if (event->attr.mmap)
                return 1;
 
@@ -3561,15 +3570,10 @@ got_name:
        rcu_read_lock();
        cpuctx = &get_cpu_var(perf_cpu_context);
        perf_event_mmap_ctx(&cpuctx->ctx, mmap_event);
-       put_cpu_var(perf_cpu_context);
-
-       /*
-        * doesn't really matter which of the child contexts the
-        * events ends up in.
-        */
        ctx = rcu_dereference(current->perf_event_ctxp);
        if (ctx)
                perf_event_mmap_ctx(ctx, mmap_event);
+       put_cpu_var(perf_cpu_context);
        rcu_read_unlock();
 
        kfree(buf);
@@ -3860,6 +3864,9 @@ static int perf_swevent_match(struct perf_event *event,
                                struct perf_sample_data *data,
                                struct pt_regs *regs)
 {
+       if (event->cpu != -1 && event->cpu != smp_processor_id())
+               return 0;
+
        if (!perf_swevent_is_counting(event))
                return 0;
 
@@ -4564,7 +4571,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
        if (attr->type >= PERF_TYPE_MAX)
                return -EINVAL;
 
-       if (attr->__reserved_1 || attr->__reserved_2 || attr->__reserved_3)
+       if (attr->__reserved_1 || attr->__reserved_2)
                return -EINVAL;
 
        if (attr->sample_type & ~(PERF_SAMPLE_MAX-1))
@@ -4717,7 +4724,7 @@ SYSCALL_DEFINE5(perf_event_open,
        if (IS_ERR(event))
                goto err_put_context;
 
-       err = anon_inode_getfd("[perf_event]", &perf_fops, event, 0);
+       err = anon_inode_getfd("[perf_event]", &perf_fops, event, O_RDWR);
        if (err < 0)
                goto err_free_put_context;
 
@@ -4992,7 +4999,7 @@ void perf_event_exit_task(struct task_struct *child)
         * reading child->perf_event_ctxp, we wait until it has
         * incremented the context's refcount before we do put_ctx below.
         */
-       spin_lock(&child_ctx->lock);
+       raw_spin_lock(&child_ctx->lock);
        child->perf_event_ctxp = NULL;
        /*
         * If this context is a clone; unclone it so it can't get
@@ -5001,7 +5008,7 @@ void perf_event_exit_task(struct task_struct *child)
         */
        unclone_ctx(child_ctx);
        update_context_time(child_ctx);
-       spin_unlock_irqrestore(&child_ctx->lock, flags);
+       raw_spin_unlock_irqrestore(&child_ctx->lock, flags);
 
        /*
         * Report the task dead after unscheduling the events so that we
@@ -5292,11 +5299,11 @@ perf_set_reserve_percpu(struct sysdev_class *class,
        perf_reserved_percpu = val;
        for_each_online_cpu(cpu) {
                cpuctx = &per_cpu(perf_cpu_context, cpu);
-               spin_lock_irq(&cpuctx->ctx.lock);
+               raw_spin_lock_irq(&cpuctx->ctx.lock);
                mpt = min(perf_max_events - cpuctx->ctx.nr_events,
                          perf_max_events - perf_reserved_percpu);
                cpuctx->max_pertask = mpt;
-               spin_unlock_irq(&cpuctx->ctx.lock);
+               raw_spin_unlock_irq(&cpuctx->ctx.lock);
        }
        spin_unlock(&perf_resource_lock);
 
index d3f722d20f9c6e8d849693a1754b616d3ba74bea..2e17c9c92cbec3ff3ab5afbb9ec30ce0fbafcb21 100644 (file)
@@ -141,11 +141,12 @@ static int alloc_pidmap(struct pid_namespace *pid_ns)
                         * installing it:
                         */
                        spin_lock_irq(&pidmap_lock);
-                       if (map->page)
-                               kfree(page);
-                       else
+                       if (!map->page) {
                                map->page = page;
+                               page = NULL;
+                       }
                        spin_unlock_irq(&pidmap_lock);
+                       kfree(page);
                        if (unlikely(!map->page))
                                break;
                }
@@ -268,12 +269,11 @@ struct pid *alloc_pid(struct pid_namespace *ns)
        for (type = 0; type < PIDTYPE_MAX; ++type)
                INIT_HLIST_HEAD(&pid->tasks[type]);
 
+       upid = pid->numbers + ns->level;
        spin_lock_irq(&pidmap_lock);
-       for (i = ns->level; i >= 0; i--) {
-               upid = &pid->numbers[i];
+       for ( ; upid >= pid->numbers; --upid)
                hlist_add_head_rcu(&upid->pid_chain,
                                &pid_hash[pid_hashfn(upid->nr, upid->ns)]);
-       }
        spin_unlock_irq(&pidmap_lock);
 
 out:
index 5187136fe1de961a4ceaee2e8729b9aaa39daa38..218e5af9015637af8808caad1aaf05c476428371 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <linux/vt_kern.h>
 #include <linux/kbd_kern.h>
-#include <linux/console.h>
+#include <linux/vt.h>
 #include <linux/module.h>
 #include "power.h"
 
@@ -21,8 +21,7 @@ int pm_prepare_console(void)
        if (orig_fgconsole < 0)
                return 1;
 
-       orig_kmsg = kmsg_redirect;
-       kmsg_redirect = SUSPEND_CONSOLE;
+       orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
        return 0;
 }
 
@@ -30,7 +29,7 @@ void pm_restore_console(void)
 {
        if (orig_fgconsole >= 0) {
                vt_move_to_console(orig_fgconsole, 0);
-               kmsg_redirect = orig_kmsg;
+               vt_kmsg_redirect(orig_kmsg);
        }
 }
 #endif
index b5ac4d99c667c96ba55542f69963baf7b151f838..17463ca2e2292038027318222177979f83ee6bdb 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/syscalls.h>
 #include <linux/kexec.h>
 #include <linux/ratelimit.h>
+#include <linux/kmsg_dump.h>
 
 #include <asm/uaccess.h>
 
@@ -1405,4 +1406,122 @@ bool printk_timed_ratelimit(unsigned long *caller_jiffies,
        return false;
 }
 EXPORT_SYMBOL(printk_timed_ratelimit);
+
+static DEFINE_SPINLOCK(dump_list_lock);
+static LIST_HEAD(dump_list);
+
+/**
+ * kmsg_dump_register - register a kernel log dumper.
+ * @dumper: pointer to the kmsg_dumper structure
+ *
+ * Adds a kernel log dumper to the system. The dump callback in the
+ * structure will be called when the kernel oopses or panics and must be
+ * set. Returns zero on success and %-EINVAL or %-EBUSY otherwise.
+ */
+int kmsg_dump_register(struct kmsg_dumper *dumper)
+{
+       unsigned long flags;
+       int err = -EBUSY;
+
+       /* The dump callback needs to be set */
+       if (!dumper->dump)
+               return -EINVAL;
+
+       spin_lock_irqsave(&dump_list_lock, flags);
+       /* Don't allow registering multiple times */
+       if (!dumper->registered) {
+               dumper->registered = 1;
+               list_add_tail(&dumper->list, &dump_list);
+               err = 0;
+       }
+       spin_unlock_irqrestore(&dump_list_lock, flags);
+
+       return err;
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_register);
+
+/**
+ * kmsg_dump_unregister - unregister a kmsg dumper.
+ * @dumper: pointer to the kmsg_dumper structure
+ *
+ * Removes a dump device from the system. Returns zero on success and
+ * %-EINVAL otherwise.
+ */
+int kmsg_dump_unregister(struct kmsg_dumper *dumper)
+{
+       unsigned long flags;
+       int err = -EINVAL;
+
+       spin_lock_irqsave(&dump_list_lock, flags);
+       if (dumper->registered) {
+               dumper->registered = 0;
+               list_del(&dumper->list);
+               err = 0;
+       }
+       spin_unlock_irqrestore(&dump_list_lock, flags);
+
+       return err;
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_unregister);
+
+static const char const *kmsg_reasons[] = {
+       [KMSG_DUMP_OOPS]        = "oops",
+       [KMSG_DUMP_PANIC]       = "panic",
+};
+
+static const char *kmsg_to_str(enum kmsg_dump_reason reason)
+{
+       if (reason >= ARRAY_SIZE(kmsg_reasons) || reason < 0)
+               return "unknown";
+
+       return kmsg_reasons[reason];
+}
+
+/**
+ * kmsg_dump - dump kernel log to kernel message dumpers.
+ * @reason: the reason (oops, panic etc) for dumping
+ *
+ * Iterate through each of the dump devices and call the oops/panic
+ * callbacks with the log buffer.
+ */
+void kmsg_dump(enum kmsg_dump_reason reason)
+{
+       unsigned long end;
+       unsigned chars;
+       struct kmsg_dumper *dumper;
+       const char *s1, *s2;
+       unsigned long l1, l2;
+       unsigned long flags;
+
+       /* Theoretically, the log could move on after we do this, but
+          there's not a lot we can do about that. The new messages
+          will overwrite the start of what we dump. */
+       spin_lock_irqsave(&logbuf_lock, flags);
+       end = log_end & LOG_BUF_MASK;
+       chars = logged_chars;
+       spin_unlock_irqrestore(&logbuf_lock, flags);
+
+       if (logged_chars > end) {
+               s1 = log_buf + log_buf_len - logged_chars + end;
+               l1 = logged_chars - end;
+
+               s2 = log_buf;
+               l2 = end;
+       } else {
+               s1 = "";
+               l1 = 0;
+
+               s2 = log_buf + end - logged_chars;
+               l2 = logged_chars;
+       }
+
+       if (!spin_trylock_irqsave(&dump_list_lock, flags)) {
+               printk(KERN_ERR "dump_kmsg: dump list lock is held during %s, skipping dump\n",
+                               kmsg_to_str(reason));
+               return;
+       }
+       list_for_each_entry(dumper, &dump_list, list)
+               dumper->dump(dumper, reason, s1, l1, s2, l2);
+       spin_unlock_irqrestore(&dump_list_lock, flags);
+}
 #endif
index 760c26209a3c4b49442a3d12d8759b7a66c1903a..c705a41b4ba396082e719c1b7fef9539742837ab 100644 (file)
@@ -1198,7 +1198,7 @@ static void relay_pipe_buf_release(struct pipe_inode_info *pipe,
        relay_consume_bytes(rbuf, buf->private);
 }
 
-static struct pipe_buf_operations relay_pipe_buf_ops = {
+static const struct pipe_buf_operations relay_pipe_buf_ops = {
        .can_merge = 0,
        .map = generic_pipe_buf_map,
        .unmap = generic_pipe_buf_unmap,
index dc15686b7a7783927e28f5866064bdaba10d39e6..af96c1e4b54b11b27fe445b834e3106b5b76b472 100644 (file)
@@ -308,37 +308,37 @@ static int find_resource(struct resource *root, struct resource *new,
                         void *alignf_data)
 {
        struct resource *this = root->child;
-       resource_size_t start, end;
+       struct resource tmp = *new;
 
-       start = root->start;
+       tmp.start = root->start;
        /*
         * Skip past an allocated resource that starts at 0, since the assignment
-        * of this->start - 1 to new->end below would cause an underflow.
+        * of this->start - 1 to tmp->end below would cause an underflow.
         */
        if (this && this->start == 0) {
-               start = this->end + 1;
+               tmp.start = this->end + 1;
                this = this->sibling;
        }
        for(;;) {
                if (this)
-                       end = this->start - 1;
+                       tmp.end = this->start - 1;
                else
-                       end = root->end;
-               if (start < min)
-                       start = min;
-               if (end > max)
-                       end = max;
-               start = ALIGN(start, align);
+                       tmp.end = root->end;
+               if (tmp.start < min)
+                       tmp.start = min;
+               if (tmp.end > max)
+                       tmp.end = max;
+               tmp.start = ALIGN(tmp.start, align);
                if (alignf)
-                       alignf(alignf_data, new, size, align);
-               if (start < end && end - start >= size - 1) {
-                       new->start = start;
-                       new->end = start + size - 1;
+                       alignf(alignf_data, &tmp, size, align);
+               if (tmp.start < tmp.end && tmp.end - tmp.start >= size - 1) {
+                       new->start = tmp.start;
+                       new->end = tmp.start + size - 1;
                        return 0;
                }
                if (!this)
                        break;
-               start = this->end + 1;
+               tmp.start = this->end + 1;
                this = this->sibling;
        }
        return -EBUSY;
index 5fcb4fe645e245a4a6c043aedbf1c212dbefadf0..ddabb54bb5c81c70958a441d302e80543cbcae37 100644 (file)
@@ -37,8 +37,8 @@ do {                                                          \
        if (rt_trace_on) {                                      \
                rt_trace_on = 0;                                \
                console_verbose();                              \
-               if (spin_is_locked(&current->pi_lock))          \
-                       spin_unlock(&current->pi_lock);         \
+               if (raw_spin_is_locked(&current->pi_lock))      \
+                       raw_spin_unlock(&current->pi_lock);     \
        }                                                       \
 } while (0)
 
index 29bd4baf9e756d848895a868bd25c103f6ee1f85..a9604815786afcf781b0dc5787335aee4fd54e7f 100644 (file)
@@ -138,9 +138,9 @@ static void rt_mutex_adjust_prio(struct task_struct *task)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&task->pi_lock, flags);
+       raw_spin_lock_irqsave(&task->pi_lock, flags);
        __rt_mutex_adjust_prio(task);
-       spin_unlock_irqrestore(&task->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&task->pi_lock, flags);
 }
 
 /*
@@ -195,7 +195,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
        /*
         * Task can not go away as we did a get_task() before !
         */
-       spin_lock_irqsave(&task->pi_lock, flags);
+       raw_spin_lock_irqsave(&task->pi_lock, flags);
 
        waiter = task->pi_blocked_on;
        /*
@@ -231,8 +231,8 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
                goto out_unlock_pi;
 
        lock = waiter->lock;
-       if (!spin_trylock(&lock->wait_lock)) {
-               spin_unlock_irqrestore(&task->pi_lock, flags);
+       if (!raw_spin_trylock(&lock->wait_lock)) {
+               raw_spin_unlock_irqrestore(&task->pi_lock, flags);
                cpu_relax();
                goto retry;
        }
@@ -240,7 +240,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
        /* Deadlock detection */
        if (lock == orig_lock || rt_mutex_owner(lock) == top_task) {
                debug_rt_mutex_deadlock(deadlock_detect, orig_waiter, lock);
-               spin_unlock(&lock->wait_lock);
+               raw_spin_unlock(&lock->wait_lock);
                ret = deadlock_detect ? -EDEADLK : 0;
                goto out_unlock_pi;
        }
@@ -253,13 +253,13 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
        plist_add(&waiter->list_entry, &lock->wait_list);
 
        /* Release the task */
-       spin_unlock_irqrestore(&task->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&task->pi_lock, flags);
        put_task_struct(task);
 
        /* Grab the next task */
        task = rt_mutex_owner(lock);
        get_task_struct(task);
-       spin_lock_irqsave(&task->pi_lock, flags);
+       raw_spin_lock_irqsave(&task->pi_lock, flags);
 
        if (waiter == rt_mutex_top_waiter(lock)) {
                /* Boost the owner */
@@ -277,10 +277,10 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
                __rt_mutex_adjust_prio(task);
        }
 
-       spin_unlock_irqrestore(&task->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&task->pi_lock, flags);
 
        top_waiter = rt_mutex_top_waiter(lock);
-       spin_unlock(&lock->wait_lock);
+       raw_spin_unlock(&lock->wait_lock);
 
        if (!detect_deadlock && waiter != top_waiter)
                goto out_put_task;
@@ -288,7 +288,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task,
        goto again;
 
  out_unlock_pi:
-       spin_unlock_irqrestore(&task->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&task->pi_lock, flags);
  out_put_task:
        put_task_struct(task);
 
@@ -313,9 +313,9 @@ static inline int try_to_steal_lock(struct rt_mutex *lock,
        if (pendowner == task)
                return 1;
 
-       spin_lock_irqsave(&pendowner->pi_lock, flags);
+       raw_spin_lock_irqsave(&pendowner->pi_lock, flags);
        if (task->prio >= pendowner->prio) {
-               spin_unlock_irqrestore(&pendowner->pi_lock, flags);
+               raw_spin_unlock_irqrestore(&pendowner->pi_lock, flags);
                return 0;
        }
 
@@ -325,7 +325,7 @@ static inline int try_to_steal_lock(struct rt_mutex *lock,
         * priority.
         */
        if (likely(!rt_mutex_has_waiters(lock))) {
-               spin_unlock_irqrestore(&pendowner->pi_lock, flags);
+               raw_spin_unlock_irqrestore(&pendowner->pi_lock, flags);
                return 1;
        }
 
@@ -333,7 +333,7 @@ static inline int try_to_steal_lock(struct rt_mutex *lock,
        next = rt_mutex_top_waiter(lock);
        plist_del(&next->pi_list_entry, &pendowner->pi_waiters);
        __rt_mutex_adjust_prio(pendowner);
-       spin_unlock_irqrestore(&pendowner->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&pendowner->pi_lock, flags);
 
        /*
         * We are going to steal the lock and a waiter was
@@ -350,10 +350,10 @@ static inline int try_to_steal_lock(struct rt_mutex *lock,
         * might be task:
         */
        if (likely(next->task != task)) {
-               spin_lock_irqsave(&task->pi_lock, flags);
+               raw_spin_lock_irqsave(&task->pi_lock, flags);
                plist_add(&next->pi_list_entry, &task->pi_waiters);
                __rt_mutex_adjust_prio(task);
-               spin_unlock_irqrestore(&task->pi_lock, flags);
+               raw_spin_unlock_irqrestore(&task->pi_lock, flags);
        }
        return 1;
 }
@@ -420,7 +420,7 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
        unsigned long flags;
        int chain_walk = 0, res;
 
-       spin_lock_irqsave(&task->pi_lock, flags);
+       raw_spin_lock_irqsave(&task->pi_lock, flags);
        __rt_mutex_adjust_prio(task);
        waiter->task = task;
        waiter->lock = lock;
@@ -434,17 +434,17 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
 
        task->pi_blocked_on = waiter;
 
-       spin_unlock_irqrestore(&task->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&task->pi_lock, flags);
 
        if (waiter == rt_mutex_top_waiter(lock)) {
-               spin_lock_irqsave(&owner->pi_lock, flags);
+               raw_spin_lock_irqsave(&owner->pi_lock, flags);
                plist_del(&top_waiter->pi_list_entry, &owner->pi_waiters);
                plist_add(&waiter->pi_list_entry, &owner->pi_waiters);
 
                __rt_mutex_adjust_prio(owner);
                if (owner->pi_blocked_on)
                        chain_walk = 1;
-               spin_unlock_irqrestore(&owner->pi_lock, flags);
+               raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
        }
        else if (debug_rt_mutex_detect_deadlock(waiter, detect_deadlock))
                chain_walk = 1;
@@ -459,12 +459,12 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
         */
        get_task_struct(owner);
 
-       spin_unlock(&lock->wait_lock);
+       raw_spin_unlock(&lock->wait_lock);
 
        res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock, waiter,
                                         task);
 
-       spin_lock(&lock->wait_lock);
+       raw_spin_lock(&lock->wait_lock);
 
        return res;
 }
@@ -483,7 +483,7 @@ static void wakeup_next_waiter(struct rt_mutex *lock)
        struct task_struct *pendowner;
        unsigned long flags;
 
-       spin_lock_irqsave(&current->pi_lock, flags);
+       raw_spin_lock_irqsave(&current->pi_lock, flags);
 
        waiter = rt_mutex_top_waiter(lock);
        plist_del(&waiter->list_entry, &lock->wait_list);
@@ -500,7 +500,7 @@ static void wakeup_next_waiter(struct rt_mutex *lock)
 
        rt_mutex_set_owner(lock, pendowner, RT_MUTEX_OWNER_PENDING);
 
-       spin_unlock_irqrestore(&current->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&current->pi_lock, flags);
 
        /*
         * Clear the pi_blocked_on variable and enqueue a possible
@@ -509,7 +509,7 @@ static void wakeup_next_waiter(struct rt_mutex *lock)
         * waiter with higher priority than pending-owner->normal_prio
         * is blocked on the unboosted (pending) owner.
         */
-       spin_lock_irqsave(&pendowner->pi_lock, flags);
+       raw_spin_lock_irqsave(&pendowner->pi_lock, flags);
 
        WARN_ON(!pendowner->pi_blocked_on);
        WARN_ON(pendowner->pi_blocked_on != waiter);
@@ -523,7 +523,7 @@ static void wakeup_next_waiter(struct rt_mutex *lock)
                next = rt_mutex_top_waiter(lock);
                plist_add(&next->pi_list_entry, &pendowner->pi_waiters);
        }
-       spin_unlock_irqrestore(&pendowner->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&pendowner->pi_lock, flags);
 
        wake_up_process(pendowner);
 }
@@ -541,15 +541,15 @@ static void remove_waiter(struct rt_mutex *lock,
        unsigned long flags;
        int chain_walk = 0;
 
-       spin_lock_irqsave(&current->pi_lock, flags);
+       raw_spin_lock_irqsave(&current->pi_lock, flags);
        plist_del(&waiter->list_entry, &lock->wait_list);
        waiter->task = NULL;
        current->pi_blocked_on = NULL;
-       spin_unlock_irqrestore(&current->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&current->pi_lock, flags);
 
        if (first && owner != current) {
 
-               spin_lock_irqsave(&owner->pi_lock, flags);
+               raw_spin_lock_irqsave(&owner->pi_lock, flags);
 
                plist_del(&waiter->pi_list_entry, &owner->pi_waiters);
 
@@ -564,7 +564,7 @@ static void remove_waiter(struct rt_mutex *lock,
                if (owner->pi_blocked_on)
                        chain_walk = 1;
 
-               spin_unlock_irqrestore(&owner->pi_lock, flags);
+               raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
        }
 
        WARN_ON(!plist_node_empty(&waiter->pi_list_entry));
@@ -575,11 +575,11 @@ static void remove_waiter(struct rt_mutex *lock,
        /* gets dropped in rt_mutex_adjust_prio_chain()! */
        get_task_struct(owner);
 
-       spin_unlock(&lock->wait_lock);
+       raw_spin_unlock(&lock->wait_lock);
 
        rt_mutex_adjust_prio_chain(owner, 0, lock, NULL, current);
 
-       spin_lock(&lock->wait_lock);
+       raw_spin_lock(&lock->wait_lock);
 }
 
 /*
@@ -592,15 +592,15 @@ void rt_mutex_adjust_pi(struct task_struct *task)
        struct rt_mutex_waiter *waiter;
        unsigned long flags;
 
-       spin_lock_irqsave(&task->pi_lock, flags);
+       raw_spin_lock_irqsave(&task->pi_lock, flags);
 
        waiter = task->pi_blocked_on;
        if (!waiter || waiter->list_entry.prio == task->prio) {
-               spin_unlock_irqrestore(&task->pi_lock, flags);
+               raw_spin_unlock_irqrestore(&task->pi_lock, flags);
                return;
        }
 
-       spin_unlock_irqrestore(&task->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&task->pi_lock, flags);
 
        /* gets dropped in rt_mutex_adjust_prio_chain()! */
        get_task_struct(task);
@@ -672,14 +672,14 @@ __rt_mutex_slowlock(struct rt_mutex *lock, int state,
                                break;
                }
 
-               spin_unlock(&lock->wait_lock);
+               raw_spin_unlock(&lock->wait_lock);
 
                debug_rt_mutex_print_deadlock(waiter);
 
                if (waiter->task)
                        schedule_rt_mutex(lock);
 
-               spin_lock(&lock->wait_lock);
+               raw_spin_lock(&lock->wait_lock);
                set_current_state(state);
        }
 
@@ -700,11 +700,11 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
        debug_rt_mutex_init_waiter(&waiter);
        waiter.task = NULL;
 
-       spin_lock(&lock->wait_lock);
+       raw_spin_lock(&lock->wait_lock);
 
        /* Try to acquire the lock again: */
        if (try_to_take_rt_mutex(lock)) {
-               spin_unlock(&lock->wait_lock);
+               raw_spin_unlock(&lock->wait_lock);
                return 0;
        }
 
@@ -731,7 +731,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
         */
        fixup_rt_mutex_waiters(lock);
 
-       spin_unlock(&lock->wait_lock);
+       raw_spin_unlock(&lock->wait_lock);
 
        /* Remove pending timer: */
        if (unlikely(timeout))
@@ -758,7 +758,7 @@ rt_mutex_slowtrylock(struct rt_mutex *lock)
 {
        int ret = 0;
 
-       spin_lock(&lock->wait_lock);
+       raw_spin_lock(&lock->wait_lock);
 
        if (likely(rt_mutex_owner(lock) != current)) {
 
@@ -770,7 +770,7 @@ rt_mutex_slowtrylock(struct rt_mutex *lock)
                fixup_rt_mutex_waiters(lock);
        }
 
-       spin_unlock(&lock->wait_lock);
+       raw_spin_unlock(&lock->wait_lock);
 
        return ret;
 }
@@ -781,7 +781,7 @@ rt_mutex_slowtrylock(struct rt_mutex *lock)
 static void __sched
 rt_mutex_slowunlock(struct rt_mutex *lock)
 {
-       spin_lock(&lock->wait_lock);
+       raw_spin_lock(&lock->wait_lock);
 
        debug_rt_mutex_unlock(lock);
 
@@ -789,13 +789,13 @@ rt_mutex_slowunlock(struct rt_mutex *lock)
 
        if (!rt_mutex_has_waiters(lock)) {
                lock->owner = NULL;
-               spin_unlock(&lock->wait_lock);
+               raw_spin_unlock(&lock->wait_lock);
                return;
        }
 
        wakeup_next_waiter(lock);
 
-       spin_unlock(&lock->wait_lock);
+       raw_spin_unlock(&lock->wait_lock);
 
        /* Undo pi boosting if necessary: */
        rt_mutex_adjust_prio(current);
@@ -970,8 +970,8 @@ EXPORT_SYMBOL_GPL(rt_mutex_destroy);
 void __rt_mutex_init(struct rt_mutex *lock, const char *name)
 {
        lock->owner = NULL;
-       spin_lock_init(&lock->wait_lock);
-       plist_head_init(&lock->wait_list, &lock->wait_lock);
+       raw_spin_lock_init(&lock->wait_lock);
+       plist_head_init_raw(&lock->wait_list, &lock->wait_lock);
 
        debug_rt_mutex_init(lock, name);
 }
@@ -1032,7 +1032,7 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
 {
        int ret;
 
-       spin_lock(&lock->wait_lock);
+       raw_spin_lock(&lock->wait_lock);
 
        mark_rt_mutex_waiters(lock);
 
@@ -1040,7 +1040,7 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
                /* We got the lock for task. */
                debug_rt_mutex_lock(lock);
                rt_mutex_set_owner(lock, task, 0);
-               spin_unlock(&lock->wait_lock);
+               raw_spin_unlock(&lock->wait_lock);
                rt_mutex_deadlock_account_lock(lock, task);
                return 1;
        }
@@ -1056,7 +1056,7 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
                 */
                ret = 0;
        }
-       spin_unlock(&lock->wait_lock);
+       raw_spin_unlock(&lock->wait_lock);
 
        debug_rt_mutex_print_deadlock(waiter);
 
@@ -1106,7 +1106,7 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
 {
        int ret;
 
-       spin_lock(&lock->wait_lock);
+       raw_spin_lock(&lock->wait_lock);
 
        set_current_state(TASK_INTERRUPTIBLE);
 
@@ -1124,7 +1124,7 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
         */
        fixup_rt_mutex_waiters(lock);
 
-       spin_unlock(&lock->wait_lock);
+       raw_spin_unlock(&lock->wait_lock);
 
        /*
         * Readjust priority, when we did not get the lock. We might have been
index fd05861b2111005a5a88b386d7d77ee036f5e160..c535cc4f6428bcd09405c2f4a3322f9b41de7eaa 100644 (file)
@@ -141,7 +141,7 @@ struct rt_prio_array {
 
 struct rt_bandwidth {
        /* nests inside the rq lock: */
-       spinlock_t              rt_runtime_lock;
+       raw_spinlock_t          rt_runtime_lock;
        ktime_t                 rt_period;
        u64                     rt_runtime;
        struct hrtimer          rt_period_timer;
@@ -178,7 +178,7 @@ void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime)
        rt_b->rt_period = ns_to_ktime(period);
        rt_b->rt_runtime = runtime;
 
-       spin_lock_init(&rt_b->rt_runtime_lock);
+       raw_spin_lock_init(&rt_b->rt_runtime_lock);
 
        hrtimer_init(&rt_b->rt_period_timer,
                        CLOCK_MONOTONIC, HRTIMER_MODE_REL);
@@ -200,7 +200,7 @@ static void start_rt_bandwidth(struct rt_bandwidth *rt_b)
        if (hrtimer_active(&rt_b->rt_period_timer))
                return;
 
-       spin_lock(&rt_b->rt_runtime_lock);
+       raw_spin_lock(&rt_b->rt_runtime_lock);
        for (;;) {
                unsigned long delta;
                ktime_t soft, hard;
@@ -217,7 +217,7 @@ static void start_rt_bandwidth(struct rt_bandwidth *rt_b)
                __hrtimer_start_range_ns(&rt_b->rt_period_timer, soft, delta,
                                HRTIMER_MODE_ABS_PINNED, 0);
        }
-       spin_unlock(&rt_b->rt_runtime_lock);
+       raw_spin_unlock(&rt_b->rt_runtime_lock);
 }
 
 #ifdef CONFIG_RT_GROUP_SCHED
@@ -470,7 +470,7 @@ struct rt_rq {
        u64 rt_time;
        u64 rt_runtime;
        /* Nests inside the rq lock: */
-       spinlock_t rt_runtime_lock;
+       raw_spinlock_t rt_runtime_lock;
 
 #ifdef CONFIG_RT_GROUP_SCHED
        unsigned long rt_nr_boosted;
@@ -525,7 +525,7 @@ static struct root_domain def_root_domain;
  */
 struct rq {
        /* runqueue lock: */
-       spinlock_t lock;
+       raw_spinlock_t lock;
 
        /*
         * nr_running and cpu_load should be in the same cacheline because
@@ -685,7 +685,7 @@ inline void update_rq_clock(struct rq *rq)
  */
 int runqueue_is_locked(int cpu)
 {
-       return spin_is_locked(&cpu_rq(cpu)->lock);
+       return raw_spin_is_locked(&cpu_rq(cpu)->lock);
 }
 
 /*
@@ -893,7 +893,7 @@ static inline void finish_lock_switch(struct rq *rq, struct task_struct *prev)
         */
        spin_acquire(&rq->lock.dep_map, 0, 0, _THIS_IP_);
 
-       spin_unlock_irq(&rq->lock);
+       raw_spin_unlock_irq(&rq->lock);
 }
 
 #else /* __ARCH_WANT_UNLOCKED_CTXSW */
@@ -917,9 +917,9 @@ static inline void prepare_lock_switch(struct rq *rq, struct task_struct *next)
        next->oncpu = 1;
 #endif
 #ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW
-       spin_unlock_irq(&rq->lock);
+       raw_spin_unlock_irq(&rq->lock);
 #else
-       spin_unlock(&rq->lock);
+       raw_spin_unlock(&rq->lock);
 #endif
 }
 
@@ -949,10 +949,10 @@ static inline struct rq *__task_rq_lock(struct task_struct *p)
 {
        for (;;) {
                struct rq *rq = task_rq(p);
-               spin_lock(&rq->lock);
+               raw_spin_lock(&rq->lock);
                if (likely(rq == task_rq(p)))
                        return rq;
-               spin_unlock(&rq->lock);
+               raw_spin_unlock(&rq->lock);
        }
 }
 
@@ -969,10 +969,10 @@ static struct rq *task_rq_lock(struct task_struct *p, unsigned long *flags)
        for (;;) {
                local_irq_save(*flags);
                rq = task_rq(p);
-               spin_lock(&rq->lock);
+               raw_spin_lock(&rq->lock);
                if (likely(rq == task_rq(p)))
                        return rq;
-               spin_unlock_irqrestore(&rq->lock, *flags);
+               raw_spin_unlock_irqrestore(&rq->lock, *flags);
        }
 }
 
@@ -981,19 +981,19 @@ void task_rq_unlock_wait(struct task_struct *p)
        struct rq *rq = task_rq(p);
 
        smp_mb(); /* spin-unlock-wait is not a full memory barrier */
-       spin_unlock_wait(&rq->lock);
+       raw_spin_unlock_wait(&rq->lock);
 }
 
 static void __task_rq_unlock(struct rq *rq)
        __releases(rq->lock)
 {
-       spin_unlock(&rq->lock);
+       raw_spin_unlock(&rq->lock);
 }
 
 static inline void task_rq_unlock(struct rq *rq, unsigned long *flags)
        __releases(rq->lock)
 {
-       spin_unlock_irqrestore(&rq->lock, *flags);
+       raw_spin_unlock_irqrestore(&rq->lock, *flags);
 }
 
 /*
@@ -1006,7 +1006,7 @@ static struct rq *this_rq_lock(void)
 
        local_irq_disable();
        rq = this_rq();
-       spin_lock(&rq->lock);
+       raw_spin_lock(&rq->lock);
 
        return rq;
 }
@@ -1053,10 +1053,10 @@ static enum hrtimer_restart hrtick(struct hrtimer *timer)
 
        WARN_ON_ONCE(cpu_of(rq) != smp_processor_id());
 
-       spin_lock(&rq->lock);
+       raw_spin_lock(&rq->lock);
        update_rq_clock(rq);
        rq->curr->sched_class->task_tick(rq, rq->curr, 1);
-       spin_unlock(&rq->lock);
+       raw_spin_unlock(&rq->lock);
 
        return HRTIMER_NORESTART;
 }
@@ -1069,10 +1069,10 @@ static void __hrtick_start(void *arg)
 {
        struct rq *rq = arg;
 
-       spin_lock(&rq->lock);
+       raw_spin_lock(&rq->lock);
        hrtimer_restart(&rq->hrtick_timer);
        rq->hrtick_csd_pending = 0;
-       spin_unlock(&rq->lock);
+       raw_spin_unlock(&rq->lock);
 }
 
 /*
@@ -1179,7 +1179,7 @@ static void resched_task(struct task_struct *p)
 {
        int cpu;
 
-       assert_spin_locked(&task_rq(p)->lock);
+       assert_raw_spin_locked(&task_rq(p)->lock);
 
        if (test_tsk_need_resched(p))
                return;
@@ -1201,10 +1201,10 @@ static void resched_cpu(int cpu)
        struct rq *rq = cpu_rq(cpu);
        unsigned long flags;
 
-       if (!spin_trylock_irqsave(&rq->lock, flags))
+       if (!raw_spin_trylock_irqsave(&rq->lock, flags))
                return;
        resched_task(cpu_curr(cpu));
-       spin_unlock_irqrestore(&rq->lock, flags);
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
 
 #ifdef CONFIG_NO_HZ
@@ -1273,7 +1273,7 @@ static void sched_rt_avg_update(struct rq *rq, u64 rt_delta)
 #else /* !CONFIG_SMP */
 static void resched_task(struct task_struct *p)
 {
-       assert_spin_locked(&task_rq(p)->lock);
+       assert_raw_spin_locked(&task_rq(p)->lock);
        set_tsk_need_resched(p);
 }
 
@@ -1600,11 +1600,11 @@ static void update_group_shares_cpu(struct task_group *tg, int cpu,
                struct rq *rq = cpu_rq(cpu);
                unsigned long flags;
 
-               spin_lock_irqsave(&rq->lock, flags);
+               raw_spin_lock_irqsave(&rq->lock, flags);
                tg->cfs_rq[cpu]->rq_weight = boost ? 0 : rq_weight;
                tg->cfs_rq[cpu]->shares = boost ? 0 : shares;
                __set_se_shares(tg->se[cpu], shares);
-               spin_unlock_irqrestore(&rq->lock, flags);
+               raw_spin_unlock_irqrestore(&rq->lock, flags);
        }
 }
 
@@ -1706,9 +1706,9 @@ static void update_shares_locked(struct rq *rq, struct sched_domain *sd)
        if (root_task_group_empty())
                return;
 
-       spin_unlock(&rq->lock);
+       raw_spin_unlock(&rq->lock);
        update_shares(sd);
-       spin_lock(&rq->lock);
+       raw_spin_lock(&rq->lock);
 }
 
 static void update_h_load(long cpu)
@@ -1748,7 +1748,7 @@ static inline int _double_lock_balance(struct rq *this_rq, struct rq *busiest)
        __acquires(busiest->lock)
        __acquires(this_rq->lock)
 {
-       spin_unlock(&this_rq->lock);
+       raw_spin_unlock(&this_rq->lock);
        double_rq_lock(this_rq, busiest);
 
        return 1;
@@ -1769,14 +1769,16 @@ static int _double_lock_balance(struct rq *this_rq, struct rq *busiest)
 {
        int ret = 0;
 
-       if (unlikely(!spin_trylock(&busiest->lock))) {
+       if (unlikely(!raw_spin_trylock(&busiest->lock))) {
                if (busiest < this_rq) {
-                       spin_unlock(&this_rq->lock);
-                       spin_lock(&busiest->lock);
-                       spin_lock_nested(&this_rq->lock, SINGLE_DEPTH_NESTING);
+                       raw_spin_unlock(&this_rq->lock);
+                       raw_spin_lock(&busiest->lock);
+                       raw_spin_lock_nested(&this_rq->lock,
+                                             SINGLE_DEPTH_NESTING);
                        ret = 1;
                } else
-                       spin_lock_nested(&busiest->lock, SINGLE_DEPTH_NESTING);
+                       raw_spin_lock_nested(&busiest->lock,
+                                             SINGLE_DEPTH_NESTING);
        }
        return ret;
 }
@@ -1790,7 +1792,7 @@ static int double_lock_balance(struct rq *this_rq, struct rq *busiest)
 {
        if (unlikely(!irqs_disabled())) {
                /* printk() doesn't work good under rq->lock */
-               spin_unlock(&this_rq->lock);
+               raw_spin_unlock(&this_rq->lock);
                BUG_ON(1);
        }
 
@@ -1800,7 +1802,7 @@ static int double_lock_balance(struct rq *this_rq, struct rq *busiest)
 static inline void double_unlock_balance(struct rq *this_rq, struct rq *busiest)
        __releases(busiest->lock)
 {
-       spin_unlock(&busiest->lock);
+       raw_spin_unlock(&busiest->lock);
        lock_set_subclass(&this_rq->lock.dep_map, 0, _RET_IP_);
 }
 #endif
@@ -2000,39 +2002,6 @@ static inline void check_class_changed(struct rq *rq, struct task_struct *p,
                p->sched_class->prio_changed(rq, p, oldprio, running);
 }
 
-/**
- * kthread_bind - bind a just-created kthread to a cpu.
- * @p: thread created by kthread_create().
- * @cpu: cpu (might not be online, must be possible) for @k to run on.
- *
- * Description: This function is equivalent to set_cpus_allowed(),
- * except that @cpu doesn't need to be online, and the thread must be
- * stopped (i.e., just returned from kthread_create()).
- *
- * Function lives here instead of kthread.c because it messes with
- * scheduler internals which require locking.
- */
-void kthread_bind(struct task_struct *p, unsigned int cpu)
-{
-       struct rq *rq = cpu_rq(cpu);
-       unsigned long flags;
-
-       /* Must have done schedule() in kthread() before we set_task_cpu */
-       if (!wait_task_inactive(p, TASK_UNINTERRUPTIBLE)) {
-               WARN_ON(1);
-               return;
-       }
-
-       spin_lock_irqsave(&rq->lock, flags);
-       update_rq_clock(rq);
-       set_task_cpu(p, cpu);
-       p->cpus_allowed = cpumask_of_cpu(cpu);
-       p->rt.nr_cpus_allowed = 1;
-       p->flags |= PF_THREAD_BOUND;
-       spin_unlock_irqrestore(&rq->lock, flags);
-}
-EXPORT_SYMBOL(kthread_bind);
-
 #ifdef CONFIG_SMP
 /*
  * Is this task likely cache-hot:
@@ -2042,6 +2011,9 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
 {
        s64 delta;
 
+       if (p->sched_class != &fair_sched_class)
+               return 0;
+
        /*
         * Buddy candidates are cache hot:
         */
@@ -2050,9 +2022,6 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
                         &p->se == cfs_rq_of(&p->se)->last))
                return 1;
 
-       if (p->sched_class != &fair_sched_class)
-               return 0;
-
        if (sysctl_sched_migration_cost == -1)
                return 1;
        if (sysctl_sched_migration_cost == 0)
@@ -2063,22 +2032,23 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
        return delta < (s64)sysctl_sched_migration_cost;
 }
 
-
 void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
 {
-       int old_cpu = task_cpu(p);
-       struct cfs_rq *old_cfsrq = task_cfs_rq(p),
-                     *new_cfsrq = cpu_cfs_rq(old_cfsrq, new_cpu);
+#ifdef CONFIG_SCHED_DEBUG
+       /*
+        * We should never call set_task_cpu() on a blocked task,
+        * ttwu() will sort out the placement.
+        */
+       WARN_ON_ONCE(p->state != TASK_RUNNING && p->state != TASK_WAKING &&
+                       !(task_thread_info(p)->preempt_count & PREEMPT_ACTIVE));
+#endif
 
        trace_sched_migrate_task(p, new_cpu);
 
-       if (old_cpu != new_cpu) {
+       if (task_cpu(p) != new_cpu) {
                p->se.nr_migrations++;
-               perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS,
-                                    1, 1, NULL, 0);
+               perf_sw_event(PERF_COUNT_SW_CPU_MIGRATIONS, 1, 1, NULL, 0);
        }
-       p->se.vruntime -= old_cfsrq->min_vruntime -
-                                        new_cfsrq->min_vruntime;
 
        __set_task_cpu(p, new_cpu);
 }
@@ -2103,13 +2073,10 @@ migrate_task(struct task_struct *p, int dest_cpu, struct migration_req *req)
 
        /*
         * If the task is not on a runqueue (and not running), then
-        * it is sufficient to simply update the task's cpu field.
+        * the next wake-up will properly place the task.
         */
-       if (!p->se.on_rq && !task_running(rq, p)) {
-               update_rq_clock(rq);
-               set_task_cpu(p, dest_cpu);
+       if (!p->se.on_rq && !task_running(rq, p))
                return 0;
-       }
 
        init_completion(&req->done);
        req->task = p;
@@ -2315,10 +2282,73 @@ void task_oncpu_function_call(struct task_struct *p,
 }
 
 #ifdef CONFIG_SMP
+static int select_fallback_rq(int cpu, struct task_struct *p)
+{
+       int dest_cpu;
+       const struct cpumask *nodemask = cpumask_of_node(cpu_to_node(cpu));
+
+       /* Look for allowed, online CPU in same node. */
+       for_each_cpu_and(dest_cpu, nodemask, cpu_active_mask)
+               if (cpumask_test_cpu(dest_cpu, &p->cpus_allowed))
+                       return dest_cpu;
+
+       /* Any allowed, online CPU? */
+       dest_cpu = cpumask_any_and(&p->cpus_allowed, cpu_active_mask);
+       if (dest_cpu < nr_cpu_ids)
+               return dest_cpu;
+
+       /* No more Mr. Nice Guy. */
+       if (dest_cpu >= nr_cpu_ids) {
+               rcu_read_lock();
+               cpuset_cpus_allowed_locked(p, &p->cpus_allowed);
+               rcu_read_unlock();
+               dest_cpu = cpumask_any_and(cpu_active_mask, &p->cpus_allowed);
+
+               /*
+                * Don't tell them about moving exiting tasks or
+                * kernel threads (both mm NULL), since they never
+                * leave kernel.
+                */
+               if (p->mm && printk_ratelimit()) {
+                       printk(KERN_INFO "process %d (%s) no "
+                              "longer affine to cpu%d\n",
+                              task_pid_nr(p), p->comm, cpu);
+               }
+       }
+
+       return dest_cpu;
+}
+
+/*
+ * Called from:
+ *
+ *  - fork, @p is stable because it isn't on the tasklist yet
+ *
+ *  - exec, @p is unstable, retry loop
+ *
+ *  - wake-up, we serialize ->cpus_allowed against TASK_WAKING so
+ *             we should be good.
+ */
 static inline
 int select_task_rq(struct task_struct *p, int sd_flags, int wake_flags)
 {
-       return p->sched_class->select_task_rq(p, sd_flags, wake_flags);
+       int cpu = p->sched_class->select_task_rq(p, sd_flags, wake_flags);
+
+       /*
+        * In order not to call set_task_cpu() on a blocking task we need
+        * to rely on ttwu() to place the task on a valid ->cpus_allowed
+        * cpu.
+        *
+        * Since this is common to all placement strategies, this lives here.
+        *
+        * [ this allows ->select_task() to simply return task_cpu(p) and
+        *   not worry about this generic constraint ]
+        */
+       if (unlikely(!cpumask_test_cpu(cpu, &p->cpus_allowed) ||
+                    !cpu_online(cpu)))
+               cpu = select_fallback_rq(task_cpu(p), p);
+
+       return cpu;
 }
 #endif
 
@@ -2373,6 +2403,10 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state,
        if (task_contributes_to_load(p))
                rq->nr_uninterruptible--;
        p->state = TASK_WAKING;
+
+       if (p->sched_class->task_waking)
+               p->sched_class->task_waking(rq, p);
+
        __task_rq_unlock(rq);
 
        cpu = select_task_rq(p, SD_BALANCE_WAKE, wake_flags);
@@ -2436,8 +2470,8 @@ out_running:
 
        p->state = TASK_RUNNING;
 #ifdef CONFIG_SMP
-       if (p->sched_class->task_wake_up)
-               p->sched_class->task_wake_up(rq, p);
+       if (p->sched_class->task_woken)
+               p->sched_class->task_woken(rq, p);
 
        if (unlikely(rq->idle_stamp)) {
                u64 delta = rq->clock - rq->idle_stamp;
@@ -2536,14 +2570,6 @@ static void __sched_fork(struct task_struct *p)
 #ifdef CONFIG_PREEMPT_NOTIFIERS
        INIT_HLIST_HEAD(&p->preempt_notifiers);
 #endif
-
-       /*
-        * We mark the process as running here, but have not actually
-        * inserted it onto the runqueue yet. This guarantees that
-        * nobody will actually run it, and a signal or other external
-        * event cannot wake it up and insert it on the runqueue either.
-        */
-       p->state = TASK_RUNNING;
 }
 
 /*
@@ -2554,6 +2580,12 @@ void sched_fork(struct task_struct *p, int clone_flags)
        int cpu = get_cpu();
 
        __sched_fork(p);
+       /*
+        * We mark the process as waking here. This guarantees that
+        * nobody will actually run it, and a signal or other external
+        * event cannot wake it up and insert it on the runqueue either.
+        */
+       p->state = TASK_WAKING;
 
        /*
         * Revert to default priority/policy on fork if requested.
@@ -2622,14 +2654,15 @@ void wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
        struct rq *rq;
 
        rq = task_rq_lock(p, &flags);
-       BUG_ON(p->state != TASK_RUNNING);
+       BUG_ON(p->state != TASK_WAKING);
+       p->state = TASK_RUNNING;
        update_rq_clock(rq);
        activate_task(rq, p, 0);
        trace_sched_wakeup_new(rq, p, 1);
        check_preempt_curr(rq, p, WF_FORK);
 #ifdef CONFIG_SMP
-       if (p->sched_class->task_wake_up)
-               p->sched_class->task_wake_up(rq, p);
+       if (p->sched_class->task_woken)
+               p->sched_class->task_woken(rq, p);
 #endif
        task_rq_unlock(rq, &flags);
 }
@@ -2781,10 +2814,10 @@ static inline void post_schedule(struct rq *rq)
        if (rq->post_schedule) {
                unsigned long flags;
 
-               spin_lock_irqsave(&rq->lock, flags);
+               raw_spin_lock_irqsave(&rq->lock, flags);
                if (rq->curr->sched_class->post_schedule)
                        rq->curr->sched_class->post_schedule(rq);
-               spin_unlock_irqrestore(&rq->lock, flags);
+               raw_spin_unlock_irqrestore(&rq->lock, flags);
 
                rq->post_schedule = 0;
        }
@@ -3066,15 +3099,15 @@ static void double_rq_lock(struct rq *rq1, struct rq *rq2)
 {
        BUG_ON(!irqs_disabled());
        if (rq1 == rq2) {
-               spin_lock(&rq1->lock);
+               raw_spin_lock(&rq1->lock);
                __acquire(rq2->lock);   /* Fake it out ;) */
        } else {
                if (rq1 < rq2) {
-                       spin_lock(&rq1->lock);
-                       spin_lock_nested(&rq2->lock, SINGLE_DEPTH_NESTING);
+                       raw_spin_lock(&rq1->lock);
+                       raw_spin_lock_nested(&rq2->lock, SINGLE_DEPTH_NESTING);
                } else {
-                       spin_lock(&rq2->lock);
-                       spin_lock_nested(&rq1->lock, SINGLE_DEPTH_NESTING);
+                       raw_spin_lock(&rq2->lock);
+                       raw_spin_lock_nested(&rq1->lock, SINGLE_DEPTH_NESTING);
                }
        }
        update_rq_clock(rq1);
@@ -3091,29 +3124,44 @@ static void double_rq_unlock(struct rq *rq1, struct rq *rq2)
        __releases(rq1->lock)
        __releases(rq2->lock)
 {
-       spin_unlock(&rq1->lock);
+       raw_spin_unlock(&rq1->lock);
        if (rq1 != rq2)
-               spin_unlock(&rq2->lock);
+               raw_spin_unlock(&rq2->lock);
        else
                __release(rq2->lock);
 }
 
 /*
- * If dest_cpu is allowed for this process, migrate the task to it.
- * This is accomplished by forcing the cpu_allowed mask to only
- * allow dest_cpu, which will force the cpu onto dest_cpu. Then
- * the cpu_allowed mask is restored.
+ * sched_exec - execve() is a valuable balancing opportunity, because at
+ * this point the task has the smallest effective memory and cache footprint.
  */
-static void sched_migrate_task(struct task_struct *p, int dest_cpu)
+void sched_exec(void)
 {
+       struct task_struct *p = current;
        struct migration_req req;
+       int dest_cpu, this_cpu;
        unsigned long flags;
        struct rq *rq;
 
+again:
+       this_cpu = get_cpu();
+       dest_cpu = select_task_rq(p, SD_BALANCE_EXEC, 0);
+       if (dest_cpu == this_cpu) {
+               put_cpu();
+               return;
+       }
+
        rq = task_rq_lock(p, &flags);
+       put_cpu();
+
+       /*
+        * select_task_rq() can race against ->cpus_allowed
+        */
        if (!cpumask_test_cpu(dest_cpu, &p->cpus_allowed)
-           || unlikely(!cpu_active(dest_cpu)))
-               goto out;
+           || unlikely(!cpu_active(dest_cpu))) {
+               task_rq_unlock(rq, &flags);
+               goto again;
+       }
 
        /* force the process onto the specified CPU */
        if (migrate_task(p, dest_cpu, &req)) {
@@ -3128,23 +3176,9 @@ static void sched_migrate_task(struct task_struct *p, int dest_cpu)
 
                return;
        }
-out:
        task_rq_unlock(rq, &flags);
 }
 
-/*
- * sched_exec - execve() is a valuable balancing opportunity, because at
- * this point the task has the smallest effective memory and cache footprint.
- */
-void sched_exec(void)
-{
-       int new_cpu, this_cpu = get_cpu();
-       new_cpu = select_task_rq(current, SD_BALANCE_EXEC, 0);
-       put_cpu();
-       if (new_cpu != this_cpu)
-               sched_migrate_task(current, new_cpu);
-}
-
 /*
  * pull_task - move a task from a remote runqueue to the local runqueue.
  * Both runqueues must be locked.
@@ -4186,14 +4220,15 @@ redo:
 
                if (unlikely(sd->nr_balance_failed > sd->cache_nice_tries+2)) {
 
-                       spin_lock_irqsave(&busiest->lock, flags);
+                       raw_spin_lock_irqsave(&busiest->lock, flags);
 
                        /* don't kick the migration_thread, if the curr
                         * task on busiest cpu can't be moved to this_cpu
                         */
                        if (!cpumask_test_cpu(this_cpu,
                                              &busiest->curr->cpus_allowed)) {
-                               spin_unlock_irqrestore(&busiest->lock, flags);
+                               raw_spin_unlock_irqrestore(&busiest->lock,
+                                                           flags);
                                all_pinned = 1;
                                goto out_one_pinned;
                        }
@@ -4203,7 +4238,7 @@ redo:
                                busiest->push_cpu = this_cpu;
                                active_balance = 1;
                        }
-                       spin_unlock_irqrestore(&busiest->lock, flags);
+                       raw_spin_unlock_irqrestore(&busiest->lock, flags);
                        if (active_balance)
                                wake_up_process(busiest->migration_thread);
 
@@ -4385,10 +4420,10 @@ redo:
                /*
                 * Should not call ttwu while holding a rq->lock
                 */
-               spin_unlock(&this_rq->lock);
+               raw_spin_unlock(&this_rq->lock);
                if (active_balance)
                        wake_up_process(busiest->migration_thread);
-               spin_lock(&this_rq->lock);
+               raw_spin_lock(&this_rq->lock);
 
        } else
                sd->nr_balance_failed = 0;
@@ -5257,11 +5292,11 @@ void scheduler_tick(void)
 
        sched_clock_tick();
 
-       spin_lock(&rq->lock);
+       raw_spin_lock(&rq->lock);
        update_rq_clock(rq);
        update_cpu_load(rq);
        curr->sched_class->task_tick(rq, curr, 0);
-       spin_unlock(&rq->lock);
+       raw_spin_unlock(&rq->lock);
 
        perf_event_task_tick(curr, cpu);
 
@@ -5455,7 +5490,7 @@ need_resched_nonpreemptible:
        if (sched_feat(HRTICK))
                hrtick_clear(rq);
 
-       spin_lock_irq(&rq->lock);
+       raw_spin_lock_irq(&rq->lock);
        update_rq_clock(rq);
        clear_tsk_need_resched(prev);
 
@@ -5491,7 +5526,7 @@ need_resched_nonpreemptible:
                cpu = smp_processor_id();
                rq = cpu_rq(cpu);
        } else
-               spin_unlock_irq(&rq->lock);
+               raw_spin_unlock_irq(&rq->lock);
 
        post_schedule(rq);
 
@@ -5908,14 +5943,15 @@ EXPORT_SYMBOL(wait_for_completion_killable);
  */
 bool try_wait_for_completion(struct completion *x)
 {
+       unsigned long flags;
        int ret = 1;
 
-       spin_lock_irq(&x->wait.lock);
+       spin_lock_irqsave(&x->wait.lock, flags);
        if (!x->done)
                ret = 0;
        else
                x->done--;
-       spin_unlock_irq(&x->wait.lock);
+       spin_unlock_irqrestore(&x->wait.lock, flags);
        return ret;
 }
 EXPORT_SYMBOL(try_wait_for_completion);
@@ -5930,12 +5966,13 @@ EXPORT_SYMBOL(try_wait_for_completion);
  */
 bool completion_done(struct completion *x)
 {
+       unsigned long flags;
        int ret = 1;
 
-       spin_lock_irq(&x->wait.lock);
+       spin_lock_irqsave(&x->wait.lock, flags);
        if (!x->done)
                ret = 0;
-       spin_unlock_irq(&x->wait.lock);
+       spin_unlock_irqrestore(&x->wait.lock, flags);
        return ret;
 }
 EXPORT_SYMBOL(completion_done);
@@ -6320,7 +6357,7 @@ recheck:
         * make sure no PI-waiters arrive (or leave) while we are
         * changing the priority of the task:
         */
-       spin_lock_irqsave(&p->pi_lock, flags);
+       raw_spin_lock_irqsave(&p->pi_lock, flags);
        /*
         * To be able to change p->policy safely, the apropriate
         * runqueue lock must be held.
@@ -6330,7 +6367,7 @@ recheck:
        if (unlikely(oldpolicy != -1 && oldpolicy != p->policy)) {
                policy = oldpolicy = -1;
                __task_rq_unlock(rq);
-               spin_unlock_irqrestore(&p->pi_lock, flags);
+               raw_spin_unlock_irqrestore(&p->pi_lock, flags);
                goto recheck;
        }
        update_rq_clock(rq);
@@ -6354,7 +6391,7 @@ recheck:
                check_class_changed(rq, p, prev_class, oldprio, running);
        }
        __task_rq_unlock(rq);
-       spin_unlock_irqrestore(&p->pi_lock, flags);
+       raw_spin_unlock_irqrestore(&p->pi_lock, flags);
 
        rt_mutex_adjust_pi(p);
 
@@ -6454,7 +6491,7 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
                return -EINVAL;
 
        retval = -ESRCH;
-       read_lock(&tasklist_lock);
+       rcu_read_lock();
        p = find_process_by_pid(pid);
        if (p) {
                retval = security_task_getscheduler(p);
@@ -6462,7 +6499,7 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
                        retval = p->policy
                                | (p->sched_reset_on_fork ? SCHED_RESET_ON_FORK : 0);
        }
-       read_unlock(&tasklist_lock);
+       rcu_read_unlock();
        return retval;
 }
 
@@ -6480,7 +6517,7 @@ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
        if (!param || pid < 0)
                return -EINVAL;
 
-       read_lock(&tasklist_lock);
+       rcu_read_lock();
        p = find_process_by_pid(pid);
        retval = -ESRCH;
        if (!p)
@@ -6491,7 +6528,7 @@ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
                goto out_unlock;
 
        lp.sched_priority = p->rt_priority;
-       read_unlock(&tasklist_lock);
+       rcu_read_unlock();
 
        /*
         * This one might sleep, we cannot do it with a spinlock held ...
@@ -6501,7 +6538,7 @@ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
        return retval;
 
 out_unlock:
-       read_unlock(&tasklist_lock);
+       rcu_read_unlock();
        return retval;
 }
 
@@ -6512,22 +6549,18 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
        int retval;
 
        get_online_cpus();
-       read_lock(&tasklist_lock);
+       rcu_read_lock();
 
        p = find_process_by_pid(pid);
        if (!p) {
-               read_unlock(&tasklist_lock);
+               rcu_read_unlock();
                put_online_cpus();
                return -ESRCH;
        }
 
-       /*
-        * It is not safe to call set_cpus_allowed with the
-        * tasklist_lock held. We will bump the task_struct's
-        * usage count and then drop tasklist_lock.
-        */
+       /* Prevent p going away */
        get_task_struct(p);
-       read_unlock(&tasklist_lock);
+       rcu_read_unlock();
 
        if (!alloc_cpumask_var(&cpus_allowed, GFP_KERNEL)) {
                retval = -ENOMEM;
@@ -6613,7 +6646,7 @@ long sched_getaffinity(pid_t pid, struct cpumask *mask)
        int retval;
 
        get_online_cpus();
-       read_lock(&tasklist_lock);
+       rcu_read_lock();
 
        retval = -ESRCH;
        p = find_process_by_pid(pid);
@@ -6629,7 +6662,7 @@ long sched_getaffinity(pid_t pid, struct cpumask *mask)
        task_rq_unlock(rq, &flags);
 
 out_unlock:
-       read_unlock(&tasklist_lock);
+       rcu_read_unlock();
        put_online_cpus();
 
        return retval;
@@ -6684,7 +6717,7 @@ SYSCALL_DEFINE0(sched_yield)
         */
        __release(rq->lock);
        spin_release(&rq->lock.dep_map, 1, _THIS_IP_);
-       _raw_spin_unlock(&rq->lock);
+       do_raw_spin_unlock(&rq->lock);
        preempt_enable_no_resched();
 
        schedule();
@@ -6873,7 +6906,7 @@ SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
                return -EINVAL;
 
        retval = -ESRCH;
-       read_lock(&tasklist_lock);
+       rcu_read_lock();
        p = find_process_by_pid(pid);
        if (!p)
                goto out_unlock;
@@ -6886,13 +6919,13 @@ SYSCALL_DEFINE2(sched_rr_get_interval, pid_t, pid,
        time_slice = p->sched_class->get_rr_interval(rq, p);
        task_rq_unlock(rq, &flags);
 
-       read_unlock(&tasklist_lock);
+       rcu_read_unlock();
        jiffies_to_timespec(time_slice, &t);
        retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0;
        return retval;
 
 out_unlock:
-       read_unlock(&tasklist_lock);
+       rcu_read_unlock();
        return retval;
 }
 
@@ -6980,9 +7013,10 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu)
        struct rq *rq = cpu_rq(cpu);
        unsigned long flags;
 
-       spin_lock_irqsave(&rq->lock, flags);
+       raw_spin_lock_irqsave(&rq->lock, flags);
 
        __sched_fork(idle);
+       idle->state = TASK_RUNNING;
        idle->se.exec_start = sched_clock();
 
        cpumask_copy(&idle->cpus_allowed, cpumask_of(cpu));
@@ -6992,7 +7026,7 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu)
 #if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW)
        idle->oncpu = 1;
 #endif
-       spin_unlock_irqrestore(&rq->lock, flags);
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
 
        /* Set the preempt count _outside_ the spinlocks! */
 #if defined(CONFIG_PREEMPT)
@@ -7097,7 +7131,23 @@ int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask)
        struct rq *rq;
        int ret = 0;
 
+       /*
+        * Since we rely on wake-ups to migrate sleeping tasks, don't change
+        * the ->cpus_allowed mask from under waking tasks, which would be
+        * possible when we change rq->lock in ttwu(), so synchronize against
+        * TASK_WAKING to avoid that.
+        */
+again:
+       while (p->state == TASK_WAKING)
+               cpu_relax();
+
        rq = task_rq_lock(p, &flags);
+
+       if (p->state == TASK_WAKING) {
+               task_rq_unlock(rq, &flags);
+               goto again;
+       }
+
        if (!cpumask_intersects(new_mask, cpu_active_mask)) {
                ret = -EINVAL;
                goto out;
@@ -7153,7 +7203,7 @@ EXPORT_SYMBOL_GPL(set_cpus_allowed_ptr);
 static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
 {
        struct rq *rq_dest, *rq_src;
-       int ret = 0, on_rq;
+       int ret = 0;
 
        if (unlikely(!cpu_active(dest_cpu)))
                return ret;
@@ -7169,12 +7219,13 @@ static int __migrate_task(struct task_struct *p, int src_cpu, int dest_cpu)
        if (!cpumask_test_cpu(dest_cpu, &p->cpus_allowed))
                goto fail;
 
-       on_rq = p->se.on_rq;
-       if (on_rq)
+       /*
+        * If we're not on a rq, the next wake-up will ensure we're
+        * placed properly.
+        */
+       if (p->se.on_rq) {
                deactivate_task(rq_src, p, 0);
-
-       set_task_cpu(p, dest_cpu);
-       if (on_rq) {
+               set_task_cpu(p, dest_cpu);
                activate_task(rq_dest, p, 0);
                check_preempt_curr(rq_dest, p, 0);
        }
@@ -7209,10 +7260,10 @@ static int migration_thread(void *data)
                struct migration_req *req;
                struct list_head *head;
 
-               spin_lock_irq(&rq->lock);
+               raw_spin_lock_irq(&rq->lock);
 
                if (cpu_is_offline(cpu)) {
-                       spin_unlock_irq(&rq->lock);
+                       raw_spin_unlock_irq(&rq->lock);
                        break;
                }
 
@@ -7224,7 +7275,7 @@ static int migration_thread(void *data)
                head = &rq->migration_queue;
 
                if (list_empty(head)) {
-                       spin_unlock_irq(&rq->lock);
+                       raw_spin_unlock_irq(&rq->lock);
                        schedule();
                        set_current_state(TASK_INTERRUPTIBLE);
                        continue;
@@ -7233,14 +7284,14 @@ static int migration_thread(void *data)
                list_del_init(head->next);
 
                if (req->task != NULL) {
-                       spin_unlock(&rq->lock);
+                       raw_spin_unlock(&rq->lock);
                        __migrate_task(req->task, cpu, req->dest_cpu);
                } else if (likely(cpu == (badcpu = smp_processor_id()))) {
                        req->dest_cpu = RCU_MIGRATION_GOT_QS;
-                       spin_unlock(&rq->lock);
+                       raw_spin_unlock(&rq->lock);
                } else {
                        req->dest_cpu = RCU_MIGRATION_MUST_SYNC;
-                       spin_unlock(&rq->lock);
+                       raw_spin_unlock(&rq->lock);
                        WARN_ONCE(1, "migration_thread() on CPU %d, expected %d\n", badcpu, cpu);
                }
                local_irq_enable();
@@ -7270,37 +7321,10 @@ static int __migrate_task_irq(struct task_struct *p, int src_cpu, int dest_cpu)
 static void move_task_off_dead_cpu(int dead_cpu, struct task_struct *p)
 {
        int dest_cpu;
-       const struct cpumask *nodemask = cpumask_of_node(cpu_to_node(dead_cpu));
 
 again:
-       /* Look for allowed, online CPU in same node. */
-       for_each_cpu_and(dest_cpu, nodemask, cpu_active_mask)
-               if (cpumask_test_cpu(dest_cpu, &p->cpus_allowed))
-                       goto move;
-
-       /* Any allowed, online CPU? */
-       dest_cpu = cpumask_any_and(&p->cpus_allowed, cpu_active_mask);
-       if (dest_cpu < nr_cpu_ids)
-               goto move;
-
-       /* No more Mr. Nice Guy. */
-       if (dest_cpu >= nr_cpu_ids) {
-               cpuset_cpus_allowed_locked(p, &p->cpus_allowed);
-               dest_cpu = cpumask_any_and(cpu_active_mask, &p->cpus_allowed);
-
-               /*
-                * Don't tell them about moving exiting tasks or
-                * kernel threads (both mm NULL), since they never
-                * leave kernel.
-                */
-               if (p->mm && printk_ratelimit()) {
-                       printk(KERN_INFO "process %d (%s) no "
-                              "longer affine to cpu%d\n",
-                              task_pid_nr(p), p->comm, dead_cpu);
-               }
-       }
+       dest_cpu = select_fallback_rq(dead_cpu, p);
 
-move:
        /* It can have affinity changed while we were choosing. */
        if (unlikely(!__migrate_task_irq(p, dead_cpu, dest_cpu)))
                goto again;
@@ -7363,14 +7387,14 @@ void sched_idle_next(void)
         * Strictly not necessary since rest of the CPUs are stopped by now
         * and interrupts disabled on the current cpu.
         */
-       spin_lock_irqsave(&rq->lock, flags);
+       raw_spin_lock_irqsave(&rq->lock, flags);
 
        __setscheduler(rq, p, SCHED_FIFO, MAX_RT_PRIO-1);
 
        update_rq_clock(rq);
        activate_task(rq, p, 0);
 
-       spin_unlock_irqrestore(&rq->lock, flags);
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
 
 /*
@@ -7406,9 +7430,9 @@ static void migrate_dead(unsigned int dead_cpu, struct task_struct *p)
         * that's OK. No task can be added to this CPU, so iteration is
         * fine.
         */
-       spin_unlock_irq(&rq->lock);
+       raw_spin_unlock_irq(&rq->lock);
        move_task_off_dead_cpu(dead_cpu, p);
-       spin_lock_irq(&rq->lock);
+       raw_spin_lock_irq(&rq->lock);
 
        put_task_struct(p);
 }
@@ -7674,13 +7698,13 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
 
                /* Update our root-domain */
                rq = cpu_rq(cpu);
-               spin_lock_irqsave(&rq->lock, flags);
+               raw_spin_lock_irqsave(&rq->lock, flags);
                if (rq->rd) {
                        BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
 
                        set_rq_online(rq);
                }
-               spin_unlock_irqrestore(&rq->lock, flags);
+               raw_spin_unlock_irqrestore(&rq->lock, flags);
                break;
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -7705,13 +7729,13 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
                put_task_struct(rq->migration_thread);
                rq->migration_thread = NULL;
                /* Idle task back to normal (off runqueue, low prio) */
-               spin_lock_irq(&rq->lock);
+               raw_spin_lock_irq(&rq->lock);
                update_rq_clock(rq);
                deactivate_task(rq, rq->idle, 0);
                __setscheduler(rq, rq->idle, SCHED_NORMAL, 0);
                rq->idle->sched_class = &idle_sched_class;
                migrate_dead_tasks(cpu);
-               spin_unlock_irq(&rq->lock);
+               raw_spin_unlock_irq(&rq->lock);
                cpuset_unlock();
                migrate_nr_uninterruptible(rq);
                BUG_ON(rq->nr_running != 0);
@@ -7721,30 +7745,30 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
                 * they didn't take sched_hotcpu_mutex. Just wake up
                 * the requestors.
                 */
-               spin_lock_irq(&rq->lock);
+               raw_spin_lock_irq(&rq->lock);
                while (!list_empty(&rq->migration_queue)) {
                        struct migration_req *req;
 
                        req = list_entry(rq->migration_queue.next,
                                         struct migration_req, list);
                        list_del_init(&req->list);
-                       spin_unlock_irq(&rq->lock);
+                       raw_spin_unlock_irq(&rq->lock);
                        complete(&req->done);
-                       spin_lock_irq(&rq->lock);
+                       raw_spin_lock_irq(&rq->lock);
                }
-               spin_unlock_irq(&rq->lock);
+               raw_spin_unlock_irq(&rq->lock);
                break;
 
        case CPU_DYING:
        case CPU_DYING_FROZEN:
                /* Update our root-domain */
                rq = cpu_rq(cpu);
-               spin_lock_irqsave(&rq->lock, flags);
+               raw_spin_lock_irqsave(&rq->lock, flags);
                if (rq->rd) {
                        BUG_ON(!cpumask_test_cpu(cpu, rq->rd->span));
                        set_rq_offline(rq);
                }
-               spin_unlock_irqrestore(&rq->lock, flags);
+               raw_spin_unlock_irqrestore(&rq->lock, flags);
                break;
 #endif
        }
@@ -7974,7 +7998,7 @@ static void rq_attach_root(struct rq *rq, struct root_domain *rd)
        struct root_domain *old_rd = NULL;
        unsigned long flags;
 
-       spin_lock_irqsave(&rq->lock, flags);
+       raw_spin_lock_irqsave(&rq->lock, flags);
 
        if (rq->rd) {
                old_rd = rq->rd;
@@ -8000,7 +8024,7 @@ static void rq_attach_root(struct rq *rq, struct root_domain *rd)
        if (cpumask_test_cpu(rq->cpu, cpu_active_mask))
                set_rq_online(rq);
 
-       spin_unlock_irqrestore(&rq->lock, flags);
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
 
        if (old_rd)
                free_rootdomain(old_rd);
@@ -9357,13 +9381,13 @@ static void init_rt_rq(struct rt_rq *rt_rq, struct rq *rq)
 #ifdef CONFIG_SMP
        rt_rq->rt_nr_migratory = 0;
        rt_rq->overloaded = 0;
-       plist_head_init(&rt_rq->pushable_tasks, &rq->lock);
+       plist_head_init_raw(&rt_rq->pushable_tasks, &rq->lock);
 #endif
 
        rt_rq->rt_time = 0;
        rt_rq->rt_throttled = 0;
        rt_rq->rt_runtime = 0;
-       spin_lock_init(&rt_rq->rt_runtime_lock);
+       raw_spin_lock_init(&rt_rq->rt_runtime_lock);
 
 #ifdef CONFIG_RT_GROUP_SCHED
        rt_rq->rt_nr_boosted = 0;
@@ -9523,7 +9547,7 @@ void __init sched_init(void)
                struct rq *rq;
 
                rq = cpu_rq(i);
-               spin_lock_init(&rq->lock);
+               raw_spin_lock_init(&rq->lock);
                rq->nr_running = 0;
                rq->calc_load_active = 0;
                rq->calc_load_update = jiffies + LOAD_FREQ;
@@ -9621,7 +9645,7 @@ void __init sched_init(void)
 #endif
 
 #ifdef CONFIG_RT_MUTEXES
-       plist_head_init(&init_task.pi_waiters, &init_task.pi_lock);
+       plist_head_init_raw(&init_task.pi_waiters, &init_task.pi_lock);
 #endif
 
        /*
@@ -9665,7 +9689,7 @@ void __init sched_init(void)
 #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
 static inline int preempt_count_equals(int preempt_offset)
 {
-       int nested = preempt_count() & ~PREEMPT_ACTIVE;
+       int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
 
        return (nested == PREEMPT_INATOMIC_BASE + preempt_offset);
 }
@@ -9746,13 +9770,13 @@ void normalize_rt_tasks(void)
                        continue;
                }
 
-               spin_lock(&p->pi_lock);
+               raw_spin_lock(&p->pi_lock);
                rq = __task_rq_lock(p);
 
                normalize_task(rq, p);
 
                __task_rq_unlock(rq);
-               spin_unlock(&p->pi_lock);
+               raw_spin_unlock(&p->pi_lock);
        } while_each_thread(g, p);
 
        read_unlock_irqrestore(&tasklist_lock, flags);
@@ -10080,7 +10104,7 @@ void sched_move_task(struct task_struct *tsk)
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
        if (tsk->sched_class->moved_group)
-               tsk->sched_class->moved_group(tsk);
+               tsk->sched_class->moved_group(tsk, on_rq);
 #endif
 
        if (unlikely(running))
@@ -10115,9 +10139,9 @@ static void set_se_shares(struct sched_entity *se, unsigned long shares)
        struct rq *rq = cfs_rq->rq;
        unsigned long flags;
 
-       spin_lock_irqsave(&rq->lock, flags);
+       raw_spin_lock_irqsave(&rq->lock, flags);
        __set_se_shares(se, shares);
-       spin_unlock_irqrestore(&rq->lock, flags);
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
 
 static DEFINE_MUTEX(shares_mutex);
@@ -10302,18 +10326,18 @@ static int tg_set_bandwidth(struct task_group *tg,
        if (err)
                goto unlock;
 
-       spin_lock_irq(&tg->rt_bandwidth.rt_runtime_lock);
+       raw_spin_lock_irq(&tg->rt_bandwidth.rt_runtime_lock);
        tg->rt_bandwidth.rt_period = ns_to_ktime(rt_period);
        tg->rt_bandwidth.rt_runtime = rt_runtime;
 
        for_each_possible_cpu(i) {
                struct rt_rq *rt_rq = tg->rt_rq[i];
 
-               spin_lock(&rt_rq->rt_runtime_lock);
+               raw_spin_lock(&rt_rq->rt_runtime_lock);
                rt_rq->rt_runtime = rt_runtime;
-               spin_unlock(&rt_rq->rt_runtime_lock);
+               raw_spin_unlock(&rt_rq->rt_runtime_lock);
        }
-       spin_unlock_irq(&tg->rt_bandwidth.rt_runtime_lock);
+       raw_spin_unlock_irq(&tg->rt_bandwidth.rt_runtime_lock);
  unlock:
        read_unlock(&tasklist_lock);
        mutex_unlock(&rt_constraints_mutex);
@@ -10418,15 +10442,15 @@ static int sched_rt_global_constraints(void)
        if (sysctl_sched_rt_runtime == 0)
                return -EBUSY;
 
-       spin_lock_irqsave(&def_rt_bandwidth.rt_runtime_lock, flags);
+       raw_spin_lock_irqsave(&def_rt_bandwidth.rt_runtime_lock, flags);
        for_each_possible_cpu(i) {
                struct rt_rq *rt_rq = &cpu_rq(i)->rt;
 
-               spin_lock(&rt_rq->rt_runtime_lock);
+               raw_spin_lock(&rt_rq->rt_runtime_lock);
                rt_rq->rt_runtime = global_rt_runtime();
-               spin_unlock(&rt_rq->rt_runtime_lock);
+               raw_spin_unlock(&rt_rq->rt_runtime_lock);
        }
-       spin_unlock_irqrestore(&def_rt_bandwidth.rt_runtime_lock, flags);
+       raw_spin_unlock_irqrestore(&def_rt_bandwidth.rt_runtime_lock, flags);
 
        return 0;
 }
@@ -10717,9 +10741,9 @@ static u64 cpuacct_cpuusage_read(struct cpuacct *ca, int cpu)
        /*
         * Take rq->lock to make 64-bit read safe on 32-bit platforms.
         */
-       spin_lock_irq(&cpu_rq(cpu)->lock);
+       raw_spin_lock_irq(&cpu_rq(cpu)->lock);
        data = *cpuusage;
-       spin_unlock_irq(&cpu_rq(cpu)->lock);
+       raw_spin_unlock_irq(&cpu_rq(cpu)->lock);
 #else
        data = *cpuusage;
 #endif
@@ -10735,9 +10759,9 @@ static void cpuacct_cpuusage_write(struct cpuacct *ca, int cpu, u64 val)
        /*
         * Take rq->lock to make 64-bit write safe on 32-bit platforms.
         */
-       spin_lock_irq(&cpu_rq(cpu)->lock);
+       raw_spin_lock_irq(&cpu_rq(cpu)->lock);
        *cpuusage = val;
-       spin_unlock_irq(&cpu_rq(cpu)->lock);
+       raw_spin_unlock_irq(&cpu_rq(cpu)->lock);
 #else
        *cpuusage = val;
 #endif
@@ -10971,9 +10995,9 @@ void synchronize_sched_expedited(void)
                init_completion(&req->done);
                req->task = NULL;
                req->dest_cpu = RCU_MIGRATION_NEED_QS;
-               spin_lock_irqsave(&rq->lock, flags);
+               raw_spin_lock_irqsave(&rq->lock, flags);
                list_add(&req->list, &rq->migration_queue);
-               spin_unlock_irqrestore(&rq->lock, flags);
+               raw_spin_unlock_irqrestore(&rq->lock, flags);
                wake_up_process(rq->migration_thread);
        }
        for_each_online_cpu(cpu) {
@@ -10981,11 +11005,11 @@ void synchronize_sched_expedited(void)
                req = &per_cpu(rcu_migration_req, cpu);
                rq = cpu_rq(cpu);
                wait_for_completion(&req->done);
-               spin_lock_irqsave(&rq->lock, flags);
+               raw_spin_lock_irqsave(&rq->lock, flags);
                if (unlikely(req->dest_cpu == RCU_MIGRATION_MUST_SYNC))
                        need_full_sync = 1;
                req->dest_cpu = RCU_MIGRATION_IDLE;
-               spin_unlock_irqrestore(&rq->lock, flags);
+               raw_spin_unlock_irqrestore(&rq->lock, flags);
        }
        rcu_expedited_state = RCU_EXPEDITED_STATE_IDLE;
        synchronize_sched_expedited_count++;
index 479ce5682d7c41c858557086de9113b0d71fa00c..5b496132c28a1baca2a6353c6a6b0216a0f02508 100644 (file)
@@ -236,6 +236,18 @@ void sched_clock_idle_wakeup_event(u64 delta_ns)
 }
 EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);
 
+unsigned long long cpu_clock(int cpu)
+{
+       unsigned long long clock;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       clock = sched_clock_cpu(cpu);
+       local_irq_restore(flags);
+
+       return clock;
+}
+
 #else /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
 
 void sched_clock_init(void)
@@ -251,17 +263,12 @@ u64 sched_clock_cpu(int cpu)
        return sched_clock();
 }
 
-#endif /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
 
 unsigned long long cpu_clock(int cpu)
 {
-       unsigned long long clock;
-       unsigned long flags;
+       return sched_clock_cpu(cpu);
+}
 
-       local_irq_save(flags);
-       clock = sched_clock_cpu(cpu);
-       local_irq_restore(flags);
+#endif /* CONFIG_HAVE_UNSTABLE_SCHED_CLOCK */
 
-       return clock;
-}
 EXPORT_SYMBOL_GPL(cpu_clock);
index 0f052fc674d5a0c49c4086c03fb950539edcfa48..597b33099dfa690617a812b3899e731bf7d5c792 100644 (file)
@@ -135,26 +135,26 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri)
        if (likely(newpri != CPUPRI_INVALID)) {
                struct cpupri_vec *vec = &cp->pri_to_cpu[newpri];
 
-               spin_lock_irqsave(&vec->lock, flags);
+               raw_spin_lock_irqsave(&vec->lock, flags);
 
                cpumask_set_cpu(cpu, vec->mask);
                vec->count++;
                if (vec->count == 1)
                        set_bit(newpri, cp->pri_active);
 
-               spin_unlock_irqrestore(&vec->lock, flags);
+               raw_spin_unlock_irqrestore(&vec->lock, flags);
        }
        if (likely(oldpri != CPUPRI_INVALID)) {
                struct cpupri_vec *vec  = &cp->pri_to_cpu[oldpri];
 
-               spin_lock_irqsave(&vec->lock, flags);
+               raw_spin_lock_irqsave(&vec->lock, flags);
 
                vec->count--;
                if (!vec->count)
                        clear_bit(oldpri, cp->pri_active);
                cpumask_clear_cpu(cpu, vec->mask);
 
-               spin_unlock_irqrestore(&vec->lock, flags);
+               raw_spin_unlock_irqrestore(&vec->lock, flags);
        }
 
        *currpri = newpri;
@@ -180,7 +180,7 @@ int cpupri_init(struct cpupri *cp, bool bootmem)
        for (i = 0; i < CPUPRI_NR_PRIORITIES; i++) {
                struct cpupri_vec *vec = &cp->pri_to_cpu[i];
 
-               spin_lock_init(&vec->lock);
+               raw_spin_lock_init(&vec->lock);
                vec->count = 0;
                if (!zalloc_cpumask_var(&vec->mask, gfp))
                        goto cleanup;
index 9a7e859b8fbfdd753f09a4bc0949cf5345e2ae75..7cb5bb6b95be5a4be62c7a7f937388a0fe8ae1e1 100644 (file)
@@ -12,7 +12,7 @@
 /* values 2-101 are RT priorities 0-99 */
 
 struct cpupri_vec {
-       spinlock_t lock;
+       raw_spinlock_t lock;
        int        count;
        cpumask_var_t mask;
 };
index 5ae24fc65d75c7f9435040b90851c6cdcdd4a579..67f95aada4b95637b75432278b9d7391401a62d6 100644 (file)
@@ -184,7 +184,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
        SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "exec_clock",
                        SPLIT_NS(cfs_rq->exec_clock));
 
-       spin_lock_irqsave(&rq->lock, flags);
+       raw_spin_lock_irqsave(&rq->lock, flags);
        if (cfs_rq->rb_leftmost)
                MIN_vruntime = (__pick_next_entity(cfs_rq))->vruntime;
        last = __pick_last_entity(cfs_rq);
@@ -192,7 +192,7 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
                max_vruntime = last->vruntime;
        min_vruntime = cfs_rq->min_vruntime;
        rq0_min_vruntime = cpu_rq(0)->cfs.min_vruntime;
-       spin_unlock_irqrestore(&rq->lock, flags);
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
        SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "MIN_vruntime",
                        SPLIT_NS(MIN_vruntime));
        SEQ_printf(m, "  .%-30s: %Ld.%06ld\n", "min_vruntime",
index 804a411838f12e68690ff9db41796aa4f2a3eefe..42ac3c9f66f68868bb651f6c163483d6713b6eea 100644 (file)
@@ -510,6 +510,7 @@ __update_curr(struct cfs_rq *cfs_rq, struct sched_entity *curr,
        curr->sum_exec_runtime += delta_exec;
        schedstat_add(cfs_rq, exec_clock, delta_exec);
        delta_exec_weighted = calc_delta_fair(delta_exec, curr);
+
        curr->vruntime += delta_exec_weighted;
        update_min_vruntime(cfs_rq);
 }
@@ -765,16 +766,26 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
        se->vruntime = vruntime;
 }
 
+#define ENQUEUE_WAKEUP 1
+#define ENQUEUE_MIGRATE 2
+
 static void
-enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int wakeup)
+enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
 {
+       /*
+        * Update the normalized vruntime before updating min_vruntime
+        * through callig update_curr().
+        */
+       if (!(flags & ENQUEUE_WAKEUP) || (flags & ENQUEUE_MIGRATE))
+               se->vruntime += cfs_rq->min_vruntime;
+
        /*
         * Update run-time statistics of the 'current'.
         */
        update_curr(cfs_rq);
        account_entity_enqueue(cfs_rq, se);
 
-       if (wakeup) {
+       if (flags & ENQUEUE_WAKEUP) {
                place_entity(cfs_rq, se, 0);
                enqueue_sleeper(cfs_rq, se);
        }
@@ -828,6 +839,14 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int sleep)
                __dequeue_entity(cfs_rq, se);
        account_entity_dequeue(cfs_rq, se);
        update_min_vruntime(cfs_rq);
+
+       /*
+        * Normalize the entity after updating the min_vruntime because the
+        * update can refer to the ->curr item and we need to reflect this
+        * movement in our normalized position.
+        */
+       if (!sleep)
+               se->vruntime -= cfs_rq->min_vruntime;
 }
 
 /*
@@ -1038,13 +1057,19 @@ static void enqueue_task_fair(struct rq *rq, struct task_struct *p, int wakeup)
 {
        struct cfs_rq *cfs_rq;
        struct sched_entity *se = &p->se;
+       int flags = 0;
+
+       if (wakeup)
+               flags |= ENQUEUE_WAKEUP;
+       if (p->state == TASK_WAKING)
+               flags |= ENQUEUE_MIGRATE;
 
        for_each_sched_entity(se) {
                if (se->on_rq)
                        break;
                cfs_rq = cfs_rq_of(se);
-               enqueue_entity(cfs_rq, se, wakeup);
-               wakeup = 1;
+               enqueue_entity(cfs_rq, se, flags);
+               flags = ENQUEUE_WAKEUP;
        }
 
        hrtick_update(rq);
@@ -1120,6 +1145,14 @@ static void yield_task_fair(struct rq *rq)
 
 #ifdef CONFIG_SMP
 
+static void task_waking_fair(struct rq *rq, struct task_struct *p)
+{
+       struct sched_entity *se = &p->se;
+       struct cfs_rq *cfs_rq = cfs_rq_of(se);
+
+       se->vruntime -= cfs_rq->min_vruntime;
+}
+
 #ifdef CONFIG_FAIR_GROUP_SCHED
 /*
  * effective_load() calculates the load change as seen from the root_task_group
@@ -1429,6 +1462,9 @@ static int select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flag
        }
 
        for_each_domain(cpu, tmp) {
+               if (!(tmp->flags & SD_LOAD_BALANCE))
+                       continue;
+
                /*
                 * If power savings logic is enabled for a domain, see if we
                 * are not overloaded, if so, don't balance wider.
@@ -1955,7 +1991,7 @@ static void task_fork_fair(struct task_struct *p)
        struct rq *rq = this_rq();
        unsigned long flags;
 
-       spin_lock_irqsave(&rq->lock, flags);
+       raw_spin_lock_irqsave(&rq->lock, flags);
 
        if (unlikely(task_cpu(p) != this_cpu))
                __set_task_cpu(p, this_cpu);
@@ -1975,7 +2011,9 @@ static void task_fork_fair(struct task_struct *p)
                resched_task(rq->curr);
        }
 
-       spin_unlock_irqrestore(&rq->lock, flags);
+       se->vruntime -= cfs_rq->min_vruntime;
+
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
 
 /*
@@ -2028,12 +2066,13 @@ static void set_curr_task_fair(struct rq *rq)
 }
 
 #ifdef CONFIG_FAIR_GROUP_SCHED
-static void moved_group_fair(struct task_struct *p)
+static void moved_group_fair(struct task_struct *p, int on_rq)
 {
        struct cfs_rq *cfs_rq = task_cfs_rq(p);
 
        update_curr(cfs_rq);
-       place_entity(cfs_rq, &p->se, 1);
+       if (!on_rq)
+               place_entity(cfs_rq, &p->se, 1);
 }
 #endif
 
@@ -2073,6 +2112,8 @@ static const struct sched_class fair_sched_class = {
        .move_one_task          = move_one_task_fair,
        .rq_online              = rq_online_fair,
        .rq_offline             = rq_offline_fair,
+
+       .task_waking            = task_waking_fair,
 #endif
 
        .set_curr_task          = set_curr_task_fair,
index 33d5384a73a86b09a0493600ce4e4b06cf1b9ac5..5f93b570d3832cf47068e01942cdd8f36685a078 100644 (file)
@@ -34,10 +34,10 @@ static struct task_struct *pick_next_task_idle(struct rq *rq)
 static void
 dequeue_task_idle(struct rq *rq, struct task_struct *p, int sleep)
 {
-       spin_unlock_irq(&rq->lock);
+       raw_spin_unlock_irq(&rq->lock);
        printk(KERN_ERR "bad: scheduling from the idle thread!\n");
        dump_stack();
-       spin_lock_irq(&rq->lock);
+       raw_spin_lock_irq(&rq->lock);
 }
 
 static void put_prev_task_idle(struct rq *rq, struct task_struct *prev)
index aecbd9c6b20c47e081fcffd5c93f396a38ffd04d..f48328ac216f7769e6e456bda664e48e28ff9fbe 100644 (file)
@@ -327,7 +327,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq)
 
        weight = cpumask_weight(rd->span);
 
-       spin_lock(&rt_b->rt_runtime_lock);
+       raw_spin_lock(&rt_b->rt_runtime_lock);
        rt_period = ktime_to_ns(rt_b->rt_period);
        for_each_cpu(i, rd->span) {
                struct rt_rq *iter = sched_rt_period_rt_rq(rt_b, i);
@@ -336,7 +336,7 @@ static int do_balance_runtime(struct rt_rq *rt_rq)
                if (iter == rt_rq)
                        continue;
 
-               spin_lock(&iter->rt_runtime_lock);
+               raw_spin_lock(&iter->rt_runtime_lock);
                /*
                 * Either all rqs have inf runtime and there's nothing to steal
                 * or __disable_runtime() below sets a specific rq to inf to
@@ -358,14 +358,14 @@ static int do_balance_runtime(struct rt_rq *rt_rq)
                        rt_rq->rt_runtime += diff;
                        more = 1;
                        if (rt_rq->rt_runtime == rt_period) {
-                               spin_unlock(&iter->rt_runtime_lock);
+                               raw_spin_unlock(&iter->rt_runtime_lock);
                                break;
                        }
                }
 next:
-               spin_unlock(&iter->rt_runtime_lock);
+               raw_spin_unlock(&iter->rt_runtime_lock);
        }
-       spin_unlock(&rt_b->rt_runtime_lock);
+       raw_spin_unlock(&rt_b->rt_runtime_lock);
 
        return more;
 }
@@ -386,8 +386,8 @@ static void __disable_runtime(struct rq *rq)
                s64 want;
                int i;
 
-               spin_lock(&rt_b->rt_runtime_lock);
-               spin_lock(&rt_rq->rt_runtime_lock);
+               raw_spin_lock(&rt_b->rt_runtime_lock);
+               raw_spin_lock(&rt_rq->rt_runtime_lock);
                /*
                 * Either we're all inf and nobody needs to borrow, or we're
                 * already disabled and thus have nothing to do, or we have
@@ -396,7 +396,7 @@ static void __disable_runtime(struct rq *rq)
                if (rt_rq->rt_runtime == RUNTIME_INF ||
                                rt_rq->rt_runtime == rt_b->rt_runtime)
                        goto balanced;
-               spin_unlock(&rt_rq->rt_runtime_lock);
+               raw_spin_unlock(&rt_rq->rt_runtime_lock);
 
                /*
                 * Calculate the difference between what we started out with
@@ -418,7 +418,7 @@ static void __disable_runtime(struct rq *rq)
                        if (iter == rt_rq || iter->rt_runtime == RUNTIME_INF)
                                continue;
 
-                       spin_lock(&iter->rt_runtime_lock);
+                       raw_spin_lock(&iter->rt_runtime_lock);
                        if (want > 0) {
                                diff = min_t(s64, iter->rt_runtime, want);
                                iter->rt_runtime -= diff;
@@ -427,13 +427,13 @@ static void __disable_runtime(struct rq *rq)
                                iter->rt_runtime -= want;
                                want -= want;
                        }
-                       spin_unlock(&iter->rt_runtime_lock);
+                       raw_spin_unlock(&iter->rt_runtime_lock);
 
                        if (!want)
                                break;
                }
 
-               spin_lock(&rt_rq->rt_runtime_lock);
+               raw_spin_lock(&rt_rq->rt_runtime_lock);
                /*
                 * We cannot be left wanting - that would mean some runtime
                 * leaked out of the system.
@@ -445,8 +445,8 @@ balanced:
                 * runtime - in which case borrowing doesn't make sense.
                 */
                rt_rq->rt_runtime = RUNTIME_INF;
-               spin_unlock(&rt_rq->rt_runtime_lock);
-               spin_unlock(&rt_b->rt_runtime_lock);
+               raw_spin_unlock(&rt_rq->rt_runtime_lock);
+               raw_spin_unlock(&rt_b->rt_runtime_lock);
        }
 }
 
@@ -454,9 +454,9 @@ static void disable_runtime(struct rq *rq)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&rq->lock, flags);
+       raw_spin_lock_irqsave(&rq->lock, flags);
        __disable_runtime(rq);
-       spin_unlock_irqrestore(&rq->lock, flags);
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
 
 static void __enable_runtime(struct rq *rq)
@@ -472,13 +472,13 @@ static void __enable_runtime(struct rq *rq)
        for_each_leaf_rt_rq(rt_rq, rq) {
                struct rt_bandwidth *rt_b = sched_rt_bandwidth(rt_rq);
 
-               spin_lock(&rt_b->rt_runtime_lock);
-               spin_lock(&rt_rq->rt_runtime_lock);
+               raw_spin_lock(&rt_b->rt_runtime_lock);
+               raw_spin_lock(&rt_rq->rt_runtime_lock);
                rt_rq->rt_runtime = rt_b->rt_runtime;
                rt_rq->rt_time = 0;
                rt_rq->rt_throttled = 0;
-               spin_unlock(&rt_rq->rt_runtime_lock);
-               spin_unlock(&rt_b->rt_runtime_lock);
+               raw_spin_unlock(&rt_rq->rt_runtime_lock);
+               raw_spin_unlock(&rt_b->rt_runtime_lock);
        }
 }
 
@@ -486,9 +486,9 @@ static void enable_runtime(struct rq *rq)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&rq->lock, flags);
+       raw_spin_lock_irqsave(&rq->lock, flags);
        __enable_runtime(rq);
-       spin_unlock_irqrestore(&rq->lock, flags);
+       raw_spin_unlock_irqrestore(&rq->lock, flags);
 }
 
 static int balance_runtime(struct rt_rq *rt_rq)
@@ -496,9 +496,9 @@ static int balance_runtime(struct rt_rq *rt_rq)
        int more = 0;
 
        if (rt_rq->rt_time > rt_rq->rt_runtime) {
-               spin_unlock(&rt_rq->rt_runtime_lock);
+               raw_spin_unlock(&rt_rq->rt_runtime_lock);
                more = do_balance_runtime(rt_rq);
-               spin_lock(&rt_rq->rt_runtime_lock);
+               raw_spin_lock(&rt_rq->rt_runtime_lock);
        }
 
        return more;
@@ -524,11 +524,11 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
                struct rt_rq *rt_rq = sched_rt_period_rt_rq(rt_b, i);
                struct rq *rq = rq_of_rt_rq(rt_rq);
 
-               spin_lock(&rq->lock);
+               raw_spin_lock(&rq->lock);
                if (rt_rq->rt_time) {
                        u64 runtime;
 
-                       spin_lock(&rt_rq->rt_runtime_lock);
+                       raw_spin_lock(&rt_rq->rt_runtime_lock);
                        if (rt_rq->rt_throttled)
                                balance_runtime(rt_rq);
                        runtime = rt_rq->rt_runtime;
@@ -539,13 +539,13 @@ static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun)
                        }
                        if (rt_rq->rt_time || rt_rq->rt_nr_running)
                                idle = 0;
-                       spin_unlock(&rt_rq->rt_runtime_lock);
+                       raw_spin_unlock(&rt_rq->rt_runtime_lock);
                } else if (rt_rq->rt_nr_running)
                        idle = 0;
 
                if (enqueue)
                        sched_rt_rq_enqueue(rt_rq);
-               spin_unlock(&rq->lock);
+               raw_spin_unlock(&rq->lock);
        }
 
        return idle;
@@ -624,11 +624,11 @@ static void update_curr_rt(struct rq *rq)
                rt_rq = rt_rq_of_se(rt_se);
 
                if (sched_rt_runtime(rt_rq) != RUNTIME_INF) {
-                       spin_lock(&rt_rq->rt_runtime_lock);
+                       raw_spin_lock(&rt_rq->rt_runtime_lock);
                        rt_rq->rt_time += delta_exec;
                        if (sched_rt_runtime_exceeded(rt_rq))
                                resched_task(curr);
-                       spin_unlock(&rt_rq->rt_runtime_lock);
+                       raw_spin_unlock(&rt_rq->rt_runtime_lock);
                }
        }
 }
@@ -1246,7 +1246,7 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)
                                     task_running(rq, task) ||
                                     !task->se.on_rq)) {
 
-                               spin_unlock(&lowest_rq->lock);
+                               raw_spin_unlock(&lowest_rq->lock);
                                lowest_rq = NULL;
                                break;
                        }
@@ -1472,7 +1472,7 @@ static void post_schedule_rt(struct rq *rq)
  * If we are not running and we are not going to reschedule soon, we should
  * try to push tasks away now
  */
-static void task_wake_up_rt(struct rq *rq, struct task_struct *p)
+static void task_woken_rt(struct rq *rq, struct task_struct *p)
 {
        if (!task_running(rq, p) &&
            !test_tsk_need_resched(rq->curr) &&
@@ -1753,7 +1753,7 @@ static const struct sched_class rt_sched_class = {
        .rq_offline             = rq_offline_rt,
        .pre_schedule           = pre_schedule_rt,
        .post_schedule          = post_schedule_rt,
-       .task_wake_up           = task_wake_up_rt,
+       .task_woken             = task_woken_rt,
        .switched_from          = switched_from_rt,
 #endif
 
index 6b982f2cf524d82e6b72f276f7d9010df9007e47..d09692b4037614cf8a596ec229002018ebee9aac 100644 (file)
@@ -218,13 +218,13 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
        struct user_struct *user;
 
        /*
-        * We won't get problems with the target's UID changing under us
-        * because changing it requires RCU be used, and if t != current, the
-        * caller must be holding the RCU readlock (by way of a spinlock) and
-        * we use RCU protection here
+        * Protect access to @t credentials. This can go away when all
+        * callers hold rcu read lock.
         */
+       rcu_read_lock();
        user = get_uid(__task_cred(t)->user);
        atomic_inc(&user->sigpending);
+       rcu_read_unlock();
 
        if (override_rlimit ||
            atomic_read(&user->sigpending) <=
@@ -423,7 +423,7 @@ still_pending:
                 */
                info->si_signo = sig;
                info->si_errno = 0;
-               info->si_code = 0;
+               info->si_code = SI_USER;
                info->si_pid = 0;
                info->si_uid = 0;
        }
@@ -607,6 +607,17 @@ static int rm_from_queue(unsigned long mask, struct sigpending *s)
        return 1;
 }
 
+static inline int is_si_special(const struct siginfo *info)
+{
+       return info <= SEND_SIG_FORCED;
+}
+
+static inline bool si_fromuser(const struct siginfo *info)
+{
+       return info == SEND_SIG_NOINFO ||
+               (!is_si_special(info) && SI_FROMUSER(info));
+}
+
 /*
  * Bad permissions for sending the signal
  * - the caller must hold at least the RCU read lock
@@ -621,7 +632,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
        if (!valid_signal(sig))
                return -EINVAL;
 
-       if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
+       if (!si_fromuser(info))
                return 0;
 
        error = audit_signal_info(sig, t); /* Let audit system see the signal */
@@ -949,9 +960,8 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
        int from_ancestor_ns = 0;
 
 #ifdef CONFIG_PID_NS
-       if (!is_si_special(info) && SI_FROMUSER(info) &&
-                       task_pid_nr_ns(current, task_active_pid_ns(t)) <= 0)
-               from_ancestor_ns = 1;
+       from_ancestor_ns = si_fromuser(info) &&
+                          !task_pid_nr_ns(current, task_active_pid_ns(t));
 #endif
 
        return __send_signal(sig, info, t, group, from_ancestor_ns);
@@ -1052,12 +1062,6 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
        return ret;
 }
 
-void
-force_sig_specific(int sig, struct task_struct *t)
-{
-       force_sig_info(sig, SEND_SIG_FORCED, t);
-}
-
 /*
  * Nuke all other threads in the group.
  */
@@ -1175,19 +1179,19 @@ int kill_pid_info_as_uid(int sig, struct siginfo *info, struct pid *pid,
        int ret = -EINVAL;
        struct task_struct *p;
        const struct cred *pcred;
+       unsigned long flags;
 
        if (!valid_signal(sig))
                return ret;
 
-       read_lock(&tasklist_lock);
+       rcu_read_lock();
        p = pid_task(pid, PIDTYPE_PID);
        if (!p) {
                ret = -ESRCH;
                goto out_unlock;
        }
        pcred = __task_cred(p);
-       if ((info == SEND_SIG_NOINFO ||
-            (!is_si_special(info) && SI_FROMUSER(info))) &&
+       if (si_fromuser(info) &&
            euid != pcred->suid && euid != pcred->uid &&
            uid  != pcred->suid && uid  != pcred->uid) {
                ret = -EPERM;
@@ -1196,14 +1200,16 @@ int kill_pid_info_as_uid(int sig, struct siginfo *info, struct pid *pid,
        ret = security_task_kill(p, info, sig, secid);
        if (ret)
                goto out_unlock;
-       if (sig && p->sighand) {
-               unsigned long flags;
-               spin_lock_irqsave(&p->sighand->siglock, flags);
-               ret = __send_signal(sig, info, p, 1, 0);
-               spin_unlock_irqrestore(&p->sighand->siglock, flags);
+
+       if (sig) {
+               if (lock_task_sighand(p, &flags)) {
+                       ret = __send_signal(sig, info, p, 1, 0);
+                       unlock_task_sighand(p, &flags);
+               } else
+                       ret = -ESRCH;
        }
 out_unlock:
-       read_unlock(&tasklist_lock);
+       rcu_read_unlock();
        return ret;
 }
 EXPORT_SYMBOL_GPL(kill_pid_info_as_uid);
@@ -1837,11 +1843,6 @@ relock:
 
        for (;;) {
                struct k_sigaction *ka;
-
-               if (unlikely(signal->group_stop_count > 0) &&
-                   do_signal_stop(0))
-                       goto relock;
-
                /*
                 * Tracing can induce an artifical signal and choose sigaction.
                 * The return value in @signr determines the default action,
@@ -1853,6 +1854,10 @@ relock:
                if (unlikely(signr != 0))
                        ka = return_ka;
                else {
+                       if (unlikely(signal->group_stop_count > 0) &&
+                           do_signal_stop(0))
+                               goto relock;
+
                        signr = dequeue_signal(current, &current->blocked,
                                               info);
 
index a8c76069cf5042008d5b85b957a132acbeacdad6..de735a6637d0cddafc39f5f80fa571e5a9145936 100644 (file)
@@ -16,11 +16,11 @@ static DEFINE_PER_CPU(struct call_single_queue, call_single_queue);
 
 static struct {
        struct list_head        queue;
-       spinlock_t              lock;
+       raw_spinlock_t          lock;
 } call_function __cacheline_aligned_in_smp =
        {
                .queue          = LIST_HEAD_INIT(call_function.queue),
-               .lock           = __SPIN_LOCK_UNLOCKED(call_function.lock),
+               .lock           = __RAW_SPIN_LOCK_UNLOCKED(call_function.lock),
        };
 
 enum {
@@ -35,7 +35,7 @@ struct call_function_data {
 
 struct call_single_queue {
        struct list_head        list;
-       spinlock_t              lock;
+       raw_spinlock_t          lock;
 };
 
 static DEFINE_PER_CPU(struct call_function_data, cfd_data);
@@ -80,7 +80,7 @@ static int __cpuinit init_call_single_data(void)
        for_each_possible_cpu(i) {
                struct call_single_queue *q = &per_cpu(call_single_queue, i);
 
-               spin_lock_init(&q->lock);
+               raw_spin_lock_init(&q->lock);
                INIT_LIST_HEAD(&q->list);
        }
 
@@ -141,10 +141,10 @@ void generic_exec_single(int cpu, struct call_single_data *data, int wait)
        unsigned long flags;
        int ipi;
 
-       spin_lock_irqsave(&dst->lock, flags);
+       raw_spin_lock_irqsave(&dst->lock, flags);
        ipi = list_empty(&dst->list);
        list_add_tail(&data->list, &dst->list);
-       spin_unlock_irqrestore(&dst->lock, flags);
+       raw_spin_unlock_irqrestore(&dst->lock, flags);
 
        /*
         * The list addition should be visible before sending the IPI
@@ -171,7 +171,7 @@ void generic_exec_single(int cpu, struct call_single_data *data, int wait)
 void generic_smp_call_function_interrupt(void)
 {
        struct call_function_data *data;
-       int cpu = get_cpu();
+       int cpu = smp_processor_id();
 
        /*
         * Shouldn't receive this interrupt on a cpu that is not yet online.
@@ -201,9 +201,9 @@ void generic_smp_call_function_interrupt(void)
                refs = atomic_dec_return(&data->refs);
                WARN_ON(refs < 0);
                if (!refs) {
-                       spin_lock(&call_function.lock);
+                       raw_spin_lock(&call_function.lock);
                        list_del_rcu(&data->csd.list);
-                       spin_unlock(&call_function.lock);
+                       raw_spin_unlock(&call_function.lock);
                }
 
                if (refs)
@@ -212,7 +212,6 @@ void generic_smp_call_function_interrupt(void)
                csd_unlock(&data->csd);
        }
 
-       put_cpu();
 }
 
 /*
@@ -230,9 +229,9 @@ void generic_smp_call_function_single_interrupt(void)
         */
        WARN_ON_ONCE(!cpu_online(smp_processor_id()));
 
-       spin_lock(&q->lock);
+       raw_spin_lock(&q->lock);
        list_replace_init(&q->list, &list);
-       spin_unlock(&q->lock);
+       raw_spin_unlock(&q->lock);
 
        while (!list_empty(&list)) {
                struct call_single_data *data;
@@ -449,14 +448,14 @@ void smp_call_function_many(const struct cpumask *mask,
        cpumask_clear_cpu(this_cpu, data->cpumask);
        atomic_set(&data->refs, cpumask_weight(data->cpumask));
 
-       spin_lock_irqsave(&call_function.lock, flags);
+       raw_spin_lock_irqsave(&call_function.lock, flags);
        /*
         * Place entry at the _HEAD_ of the list, so that any cpu still
         * observing the entry in generic_smp_call_function_interrupt()
         * will not miss any other list entries:
         */
        list_add_rcu(&data->csd.list, &call_function.queue);
-       spin_unlock_irqrestore(&call_function.lock, flags);
+       raw_spin_unlock_irqrestore(&call_function.lock, flags);
 
        /*
         * Make the list addition visible before sending the ipi.
@@ -501,20 +500,20 @@ EXPORT_SYMBOL(smp_call_function);
 
 void ipi_call_lock(void)
 {
-       spin_lock(&call_function.lock);
+       raw_spin_lock(&call_function.lock);
 }
 
 void ipi_call_unlock(void)
 {
-       spin_unlock(&call_function.lock);
+       raw_spin_unlock(&call_function.lock);
 }
 
 void ipi_call_lock_irq(void)
 {
-       spin_lock_irq(&call_function.lock);
+       raw_spin_lock_irq(&call_function.lock);
 }
 
 void ipi_call_unlock_irq(void)
 {
-       spin_unlock_irq(&call_function.lock);
+       raw_spin_unlock_irq(&call_function.lock);
 }
index 41e042219ff664e23bf7697da27f50bb3bc49594..be6517fb9c14e66b4b4b0d7d40e91ac8b56ee06a 100644 (file)
@@ -32,6 +32,8 @@
  * include/linux/spinlock_api_smp.h
  */
 #else
+#define raw_read_can_lock(l)   read_can_lock(l)
+#define raw_write_can_lock(l)  write_can_lock(l)
 /*
  * We build the __lock_function inlines here. They are too large for
  * inlining all over the place, but here is only one user per function
  * towards that other CPU that it should break the lock ASAP.
  */
 #define BUILD_LOCK_OPS(op, locktype)                                   \
-void __lockfunc __##op##_lock(locktype##_t *lock)                      \
+void __lockfunc __raw_##op##_lock(locktype##_t *lock)                  \
 {                                                                      \
        for (;;) {                                                      \
                preempt_disable();                                      \
-               if (likely(_raw_##op##_trylock(lock)))                  \
+               if (likely(do_raw_##op##_trylock(lock)))                \
                        break;                                          \
                preempt_enable();                                       \
                                                                        \
                if (!(lock)->break_lock)                                \
                        (lock)->break_lock = 1;                         \
-               while (!op##_can_lock(lock) && (lock)->break_lock)      \
-                       _raw_##op##_relax(&lock->raw_lock);             \
+               while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
+                       arch_##op##_relax(&lock->raw_lock);             \
        }                                                               \
        (lock)->break_lock = 0;                                         \
 }                                                                      \
                                                                        \
-unsigned long __lockfunc __##op##_lock_irqsave(locktype##_t *lock)     \
+unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lock) \
 {                                                                      \
        unsigned long flags;                                            \
                                                                        \
        for (;;) {                                                      \
                preempt_disable();                                      \
                local_irq_save(flags);                                  \
-               if (likely(_raw_##op##_trylock(lock)))                  \
+               if (likely(do_raw_##op##_trylock(lock)))                \
                        break;                                          \
                local_irq_restore(flags);                               \
                preempt_enable();                                       \
                                                                        \
                if (!(lock)->break_lock)                                \
                        (lock)->break_lock = 1;                         \
-               while (!op##_can_lock(lock) && (lock)->break_lock)      \
-                       _raw_##op##_relax(&lock->raw_lock);             \
+               while (!raw_##op##_can_lock(lock) && (lock)->break_lock)\
+                       arch_##op##_relax(&lock->raw_lock);             \
        }                                                               \
        (lock)->break_lock = 0;                                         \
        return flags;                                                   \
 }                                                                      \
                                                                        \
-void __lockfunc __##op##_lock_irq(locktype##_t *lock)                  \
+void __lockfunc __raw_##op##_lock_irq(locktype##_t *lock)              \
 {                                                                      \
-       _##op##_lock_irqsave(lock);                                     \
+       _raw_##op##_lock_irqsave(lock);                                 \
 }                                                                      \
                                                                        \
-void __lockfunc __##op##_lock_bh(locktype##_t *lock)                   \
+void __lockfunc __raw_##op##_lock_bh(locktype##_t *lock)               \
 {                                                                      \
        unsigned long flags;                                            \
                                                                        \
@@ -93,7 +95,7 @@ void __lockfunc __##op##_lock_bh(locktype##_t *lock)                  \
        /* irq-disabling. We use the generic preemption-aware   */      \
        /* function:                                            */      \
        /**/                                                            \
-       flags = _##op##_lock_irqsave(lock);                             \
+       flags = _raw_##op##_lock_irqsave(lock);                         \
        local_bh_disable();                                             \
        local_irq_restore(flags);                                       \
 }                                                                      \
@@ -107,269 +109,269 @@ void __lockfunc __##op##_lock_bh(locktype##_t *lock)                    \
  *         __[spin|read|write]_lock_irqsave()
  *         __[spin|read|write]_lock_bh()
  */
-BUILD_LOCK_OPS(spin, spinlock);
+BUILD_LOCK_OPS(spin, raw_spinlock);
 BUILD_LOCK_OPS(read, rwlock);
 BUILD_LOCK_OPS(write, rwlock);
 
 #endif
 
-#ifdef CONFIG_DEBUG_LOCK_ALLOC
-
-void __lockfunc _spin_lock_nested(spinlock_t *lock, int subclass)
+#ifndef CONFIG_INLINE_SPIN_TRYLOCK
+int __lockfunc _raw_spin_trylock(raw_spinlock_t *lock)
 {
-       preempt_disable();
-       spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
+       return __raw_spin_trylock(lock);
 }
-EXPORT_SYMBOL(_spin_lock_nested);
+EXPORT_SYMBOL(_raw_spin_trylock);
+#endif
 
-unsigned long __lockfunc _spin_lock_irqsave_nested(spinlock_t *lock,
-                                                  int subclass)
+#ifndef CONFIG_INLINE_SPIN_TRYLOCK_BH
+int __lockfunc _raw_spin_trylock_bh(raw_spinlock_t *lock)
 {
-       unsigned long flags;
-
-       local_irq_save(flags);
-       preempt_disable();
-       spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
-       LOCK_CONTENDED_FLAGS(lock, _raw_spin_trylock, _raw_spin_lock,
-                               _raw_spin_lock_flags, &flags);
-       return flags;
+       return __raw_spin_trylock_bh(lock);
 }
-EXPORT_SYMBOL(_spin_lock_irqsave_nested);
+EXPORT_SYMBOL(_raw_spin_trylock_bh);
+#endif
 
-void __lockfunc _spin_lock_nest_lock(spinlock_t *lock,
-                                    struct lockdep_map *nest_lock)
+#ifndef CONFIG_INLINE_SPIN_LOCK
+void __lockfunc _raw_spin_lock(raw_spinlock_t *lock)
 {
-       preempt_disable();
-       spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_);
-       LOCK_CONTENDED(lock, _raw_spin_trylock, _raw_spin_lock);
+       __raw_spin_lock(lock);
 }
-EXPORT_SYMBOL(_spin_lock_nest_lock);
-
+EXPORT_SYMBOL(_raw_spin_lock);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_TRYLOCK
-int __lockfunc _spin_trylock(spinlock_t *lock)
+#ifndef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
+unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
 {
-       return __spin_trylock(lock);
+       return __raw_spin_lock_irqsave(lock);
 }
-EXPORT_SYMBOL(_spin_trylock);
+EXPORT_SYMBOL(_raw_spin_lock_irqsave);
 #endif
 
-#ifndef CONFIG_INLINE_READ_TRYLOCK
-int __lockfunc _read_trylock(rwlock_t *lock)
+#ifndef CONFIG_INLINE_SPIN_LOCK_IRQ
+void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
 {
-       return __read_trylock(lock);
+       __raw_spin_lock_irq(lock);
 }
-EXPORT_SYMBOL(_read_trylock);
+EXPORT_SYMBOL(_raw_spin_lock_irq);
 #endif
 
-#ifndef CONFIG_INLINE_WRITE_TRYLOCK
-int __lockfunc _write_trylock(rwlock_t *lock)
+#ifndef CONFIG_INLINE_SPIN_LOCK_BH
+void __lockfunc _raw_spin_lock_bh(raw_spinlock_t *lock)
 {
-       return __write_trylock(lock);
+       __raw_spin_lock_bh(lock);
 }
-EXPORT_SYMBOL(_write_trylock);
+EXPORT_SYMBOL(_raw_spin_lock_bh);
 #endif
 
-#ifndef CONFIG_INLINE_READ_LOCK
-void __lockfunc _read_lock(rwlock_t *lock)
+#ifndef CONFIG_INLINE_SPIN_UNLOCK
+void __lockfunc _raw_spin_unlock(raw_spinlock_t *lock)
 {
-       __read_lock(lock);
+       __raw_spin_unlock(lock);
 }
-EXPORT_SYMBOL(_read_lock);
+EXPORT_SYMBOL(_raw_spin_unlock);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_LOCK_IRQSAVE
-unsigned long __lockfunc _spin_lock_irqsave(spinlock_t *lock)
+#ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
+void __lockfunc _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
 {
-       return __spin_lock_irqsave(lock);
+       __raw_spin_unlock_irqrestore(lock, flags);
 }
-EXPORT_SYMBOL(_spin_lock_irqsave);
+EXPORT_SYMBOL(_raw_spin_unlock_irqrestore);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_LOCK_IRQ
-void __lockfunc _spin_lock_irq(spinlock_t *lock)
+#ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQ
+void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)
 {
-       __spin_lock_irq(lock);
+       __raw_spin_unlock_irq(lock);
 }
-EXPORT_SYMBOL(_spin_lock_irq);
+EXPORT_SYMBOL(_raw_spin_unlock_irq);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_LOCK_BH
-void __lockfunc _spin_lock_bh(spinlock_t *lock)
+#ifndef CONFIG_INLINE_SPIN_UNLOCK_BH
+void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock)
 {
-       __spin_lock_bh(lock);
+       __raw_spin_unlock_bh(lock);
 }
-EXPORT_SYMBOL(_spin_lock_bh);
+EXPORT_SYMBOL(_raw_spin_unlock_bh);
 #endif
 
-#ifndef CONFIG_INLINE_READ_LOCK_IRQSAVE
-unsigned long __lockfunc _read_lock_irqsave(rwlock_t *lock)
+#ifndef CONFIG_INLINE_READ_TRYLOCK
+int __lockfunc _raw_read_trylock(rwlock_t *lock)
 {
-       return __read_lock_irqsave(lock);
+       return __raw_read_trylock(lock);
 }
-EXPORT_SYMBOL(_read_lock_irqsave);
+EXPORT_SYMBOL(_raw_read_trylock);
 #endif
 
-#ifndef CONFIG_INLINE_READ_LOCK_IRQ
-void __lockfunc _read_lock_irq(rwlock_t *lock)
+#ifndef CONFIG_INLINE_READ_LOCK
+void __lockfunc _raw_read_lock(rwlock_t *lock)
 {
-       __read_lock_irq(lock);
+       __raw_read_lock(lock);
 }
-EXPORT_SYMBOL(_read_lock_irq);
+EXPORT_SYMBOL(_raw_read_lock);
 #endif
 
-#ifndef CONFIG_INLINE_READ_LOCK_BH
-void __lockfunc _read_lock_bh(rwlock_t *lock)
+#ifndef CONFIG_INLINE_READ_LOCK_IRQSAVE
+unsigned long __lockfunc _raw_read_lock_irqsave(rwlock_t *lock)
 {
-       __read_lock_bh(lock);
+       return __raw_read_lock_irqsave(lock);
 }
-EXPORT_SYMBOL(_read_lock_bh);
+EXPORT_SYMBOL(_raw_read_lock_irqsave);
 #endif
 
-#ifndef CONFIG_INLINE_WRITE_LOCK_IRQSAVE
-unsigned long __lockfunc _write_lock_irqsave(rwlock_t *lock)
+#ifndef CONFIG_INLINE_READ_LOCK_IRQ
+void __lockfunc _raw_read_lock_irq(rwlock_t *lock)
 {
-       return __write_lock_irqsave(lock);
+       __raw_read_lock_irq(lock);
 }
-EXPORT_SYMBOL(_write_lock_irqsave);
+EXPORT_SYMBOL(_raw_read_lock_irq);
 #endif
 
-#ifndef CONFIG_INLINE_WRITE_LOCK_IRQ
-void __lockfunc _write_lock_irq(rwlock_t *lock)
+#ifndef CONFIG_INLINE_READ_LOCK_BH
+void __lockfunc _raw_read_lock_bh(rwlock_t *lock)
 {
-       __write_lock_irq(lock);
+       __raw_read_lock_bh(lock);
 }
-EXPORT_SYMBOL(_write_lock_irq);
+EXPORT_SYMBOL(_raw_read_lock_bh);
 #endif
 
-#ifndef CONFIG_INLINE_WRITE_LOCK_BH
-void __lockfunc _write_lock_bh(rwlock_t *lock)
+#ifndef CONFIG_INLINE_READ_UNLOCK
+void __lockfunc _raw_read_unlock(rwlock_t *lock)
 {
-       __write_lock_bh(lock);
+       __raw_read_unlock(lock);
 }
-EXPORT_SYMBOL(_write_lock_bh);
+EXPORT_SYMBOL(_raw_read_unlock);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_LOCK
-void __lockfunc _spin_lock(spinlock_t *lock)
+#ifndef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE
+void __lockfunc _raw_read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
 {
-       __spin_lock(lock);
+       __raw_read_unlock_irqrestore(lock, flags);
 }
-EXPORT_SYMBOL(_spin_lock);
+EXPORT_SYMBOL(_raw_read_unlock_irqrestore);
 #endif
 
-#ifndef CONFIG_INLINE_WRITE_LOCK
-void __lockfunc _write_lock(rwlock_t *lock)
+#ifndef CONFIG_INLINE_READ_UNLOCK_IRQ
+void __lockfunc _raw_read_unlock_irq(rwlock_t *lock)
 {
-       __write_lock(lock);
+       __raw_read_unlock_irq(lock);
 }
-EXPORT_SYMBOL(_write_lock);
+EXPORT_SYMBOL(_raw_read_unlock_irq);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_UNLOCK
-void __lockfunc _spin_unlock(spinlock_t *lock)
+#ifndef CONFIG_INLINE_READ_UNLOCK_BH
+void __lockfunc _raw_read_unlock_bh(rwlock_t *lock)
 {
-       __spin_unlock(lock);
+       __raw_read_unlock_bh(lock);
 }
-EXPORT_SYMBOL(_spin_unlock);
+EXPORT_SYMBOL(_raw_read_unlock_bh);
 #endif
 
-#ifndef CONFIG_INLINE_WRITE_UNLOCK
-void __lockfunc _write_unlock(rwlock_t *lock)
+#ifndef CONFIG_INLINE_WRITE_TRYLOCK
+int __lockfunc _raw_write_trylock(rwlock_t *lock)
 {
-       __write_unlock(lock);
+       return __raw_write_trylock(lock);
 }
-EXPORT_SYMBOL(_write_unlock);
+EXPORT_SYMBOL(_raw_write_trylock);
 #endif
 
-#ifndef CONFIG_INLINE_READ_UNLOCK
-void __lockfunc _read_unlock(rwlock_t *lock)
+#ifndef CONFIG_INLINE_WRITE_LOCK
+void __lockfunc _raw_write_lock(rwlock_t *lock)
 {
-       __read_unlock(lock);
+       __raw_write_lock(lock);
 }
-EXPORT_SYMBOL(_read_unlock);
+EXPORT_SYMBOL(_raw_write_lock);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE
-void __lockfunc _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
+#ifndef CONFIG_INLINE_WRITE_LOCK_IRQSAVE
+unsigned long __lockfunc _raw_write_lock_irqsave(rwlock_t *lock)
 {
-       __spin_unlock_irqrestore(lock, flags);
+       return __raw_write_lock_irqsave(lock);
 }
-EXPORT_SYMBOL(_spin_unlock_irqrestore);
+EXPORT_SYMBOL(_raw_write_lock_irqsave);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQ
-void __lockfunc _spin_unlock_irq(spinlock_t *lock)
+#ifndef CONFIG_INLINE_WRITE_LOCK_IRQ
+void __lockfunc _raw_write_lock_irq(rwlock_t *lock)
 {
-       __spin_unlock_irq(lock);
+       __raw_write_lock_irq(lock);
 }
-EXPORT_SYMBOL(_spin_unlock_irq);
+EXPORT_SYMBOL(_raw_write_lock_irq);
 #endif
 
-#ifndef CONFIG_INLINE_SPIN_UNLOCK_BH
-void __lockfunc _spin_unlock_bh(spinlock_t *lock)
+#ifndef CONFIG_INLINE_WRITE_LOCK_BH
+void __lockfunc _raw_write_lock_bh(rwlock_t *lock)
 {
-       __spin_unlock_bh(lock);
+       __raw_write_lock_bh(lock);
 }
-EXPORT_SYMBOL(_spin_unlock_bh);
+EXPORT_SYMBOL(_raw_write_lock_bh);
 #endif
 
-#ifndef CONFIG_INLINE_READ_UNLOCK_IRQRESTORE
-void __lockfunc _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
+#ifndef CONFIG_INLINE_WRITE_UNLOCK
+void __lockfunc _raw_write_unlock(rwlock_t *lock)
 {
-       __read_unlock_irqrestore(lock, flags);
+       __raw_write_unlock(lock);
 }
-EXPORT_SYMBOL(_read_unlock_irqrestore);
+EXPORT_SYMBOL(_raw_write_unlock);
 #endif
 
-#ifndef CONFIG_INLINE_READ_UNLOCK_IRQ
-void __lockfunc _read_unlock_irq(rwlock_t *lock)
+#ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE
+void __lockfunc _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
 {
-       __read_unlock_irq(lock);
+       __raw_write_unlock_irqrestore(lock, flags);
 }
-EXPORT_SYMBOL(_read_unlock_irq);
+EXPORT_SYMBOL(_raw_write_unlock_irqrestore);
 #endif
 
-#ifndef CONFIG_INLINE_READ_UNLOCK_BH
-void __lockfunc _read_unlock_bh(rwlock_t *lock)
+#ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQ
+void __lockfunc _raw_write_unlock_irq(rwlock_t *lock)
 {
-       __read_unlock_bh(lock);
+       __raw_write_unlock_irq(lock);
 }
-EXPORT_SYMBOL(_read_unlock_bh);
+EXPORT_SYMBOL(_raw_write_unlock_irq);
 #endif
 
-#ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE
-void __lockfunc _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
+#ifndef CONFIG_INLINE_WRITE_UNLOCK_BH
+void __lockfunc _raw_write_unlock_bh(rwlock_t *lock)
 {
-       __write_unlock_irqrestore(lock, flags);
+       __raw_write_unlock_bh(lock);
 }
-EXPORT_SYMBOL(_write_unlock_irqrestore);
+EXPORT_SYMBOL(_raw_write_unlock_bh);
 #endif
 
-#ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQ
-void __lockfunc _write_unlock_irq(rwlock_t *lock)
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+
+void __lockfunc _raw_spin_lock_nested(raw_spinlock_t *lock, int subclass)
 {
-       __write_unlock_irq(lock);
+       preempt_disable();
+       spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
+       LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
 }
-EXPORT_SYMBOL(_write_unlock_irq);
-#endif
+EXPORT_SYMBOL(_raw_spin_lock_nested);
 
-#ifndef CONFIG_INLINE_WRITE_UNLOCK_BH
-void __lockfunc _write_unlock_bh(rwlock_t *lock)
+unsigned long __lockfunc _raw_spin_lock_irqsave_nested(raw_spinlock_t *lock,
+                                                  int subclass)
 {
-       __write_unlock_bh(lock);
+       unsigned long flags;
+
+       local_irq_save(flags);
+       preempt_disable();
+       spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
+       LOCK_CONTENDED_FLAGS(lock, do_raw_spin_trylock, do_raw_spin_lock,
+                               do_raw_spin_lock_flags, &flags);
+       return flags;
 }
-EXPORT_SYMBOL(_write_unlock_bh);
-#endif
+EXPORT_SYMBOL(_raw_spin_lock_irqsave_nested);
 
-#ifndef CONFIG_INLINE_SPIN_TRYLOCK_BH
-int __lockfunc _spin_trylock_bh(spinlock_t *lock)
+void __lockfunc _raw_spin_lock_nest_lock(raw_spinlock_t *lock,
+                                    struct lockdep_map *nest_lock)
 {
-       return __spin_trylock_bh(lock);
+       preempt_disable();
+       spin_acquire_nest(&lock->dep_map, 0, 0, nest_lock, _RET_IP_);
+       LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock);
 }
-EXPORT_SYMBOL(_spin_trylock_bh);
+EXPORT_SYMBOL(_raw_spin_lock_nest_lock);
+
 #endif
 
 notrace int in_lock_functions(unsigned long addr)
index 585d6cd10040b8a5bf93eafb6a3dc4893cc48cc6..26a6b73a6b85bbc2a4ee1e1392d3aa86d1e9a850 100644 (file)
@@ -162,6 +162,7 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
        if (niceval > 19)
                niceval = 19;
 
+       rcu_read_lock();
        read_lock(&tasklist_lock);
        switch (which) {
                case PRIO_PROCESS:
@@ -189,16 +190,17 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
                                 !(user = find_user(who)))
                                goto out_unlock;        /* No processes for this user */
 
-                       do_each_thread(g, p)
+                       do_each_thread(g, p) {
                                if (__task_cred(p)->uid == who)
                                        error = set_one_prio(p, niceval, error);
-                       while_each_thread(g, p);
+                       while_each_thread(g, p);
                        if (who != cred->uid)
                                free_uid(user);         /* For find_user() */
                        break;
        }
 out_unlock:
        read_unlock(&tasklist_lock);
+       rcu_read_unlock();
 out:
        return error;
 }
@@ -252,13 +254,13 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)
                                 !(user = find_user(who)))
                                goto out_unlock;        /* No processes for this user */
 
-                       do_each_thread(g, p)
+                       do_each_thread(g, p) {
                                if (__task_cred(p)->uid == who) {
                                        niceval = 20 - task_nice(p);
                                        if (niceval > retval)
                                                retval = niceval;
                                }
-                       while_each_thread(g, p);
+                       while_each_thread(g, p);
                        if (who != cred->uid)
                                free_uid(user);         /* for find_user() */
                        break;
index 554ac4894f0f893a6f1e26a06e3076510f6dffe9..8a68b244846805869e90f242fb563913ff485d5c 100644 (file)
@@ -1051,7 +1051,7 @@ static struct ctl_table vm_table[] = {
                .extra2         = &one_hundred,
        },
 #ifdef CONFIG_HUGETLB_PAGE
-        {
+       {
                .procname       = "nr_hugepages",
                .data           = NULL,
                .maxlen         = sizeof(unsigned long),
@@ -1059,7 +1059,18 @@ static struct ctl_table vm_table[] = {
                .proc_handler   = hugetlb_sysctl_handler,
                .extra1         = (void *)&hugetlb_zero,
                .extra2         = (void *)&hugetlb_infinity,
-        },
+       },
+#ifdef CONFIG_NUMA
+       {
+               .procname       = "nr_hugepages_mempolicy",
+               .data           = NULL,
+               .maxlen         = sizeof(unsigned long),
+               .mode           = 0644,
+               .proc_handler   = &hugetlb_mempolicy_sysctl_handler,
+               .extra1         = (void *)&hugetlb_zero,
+               .extra2         = (void *)&hugetlb_infinity,
+       },
+#endif
         {
                .procname       = "hugetlb_shm_group",
                .data           = &sysctl_hugetlb_shm_group,
@@ -1120,7 +1131,8 @@ static struct ctl_table vm_table[] = {
                .data           = &sysctl_max_map_count,
                .maxlen         = sizeof(sysctl_max_map_count),
                .mode           = 0644,
-               .proc_handler   = proc_dointvec
+               .proc_handler   = proc_dointvec_minmax,
+               .extra1         = &zero,
        },
 #else
        {
@@ -1202,6 +1214,7 @@ static struct ctl_table vm_table[] = {
                .proc_handler   = proc_dointvec_jiffies,
        },
 #endif
+#ifdef CONFIG_MMU
        {
                .procname       = "mmap_min_addr",
                .data           = &dac_mmap_min_addr,
@@ -1209,6 +1222,7 @@ static struct ctl_table vm_table[] = {
                .mode           = 0644,
                .proc_handler   = mmap_min_addr_handler,
        },
+#endif
 #ifdef CONFIG_NUMA
        {
                .procname       = "numa_zonelist_order",
index b75dbf40f5733411780b79bbce43c84f8918687e..8f5d16e0707a403bac2f30887e3b43538328c825 100644 (file)
@@ -1399,6 +1399,13 @@ static void deprecated_sysctl_warning(const int *name, int nlen)
 {
        int i;
 
+       /*
+        * CTL_KERN/KERN_VERSION is used by older glibc and cannot
+        * ever go away.
+        */
+       if (name[0] == CTL_KERN && name[1] == KERN_VERSION)
+               return;
+
        if (printk_ratelimit()) {
                printk(KERN_INFO
                        "warning: process `%s' used the deprecated sysctl "
@@ -1410,6 +1417,35 @@ static void deprecated_sysctl_warning(const int *name, int nlen)
        return;
 }
 
+#define WARN_ONCE_HASH_BITS 8
+#define WARN_ONCE_HASH_SIZE (1<<WARN_ONCE_HASH_BITS)
+
+static DECLARE_BITMAP(warn_once_bitmap, WARN_ONCE_HASH_SIZE);
+
+#define FNV32_OFFSET 2166136261U
+#define FNV32_PRIME 0x01000193
+
+/*
+ * Print each legacy sysctl (approximately) only once.
+ * To avoid making the tables non-const use a external
+ * hash-table instead.
+ * Worst case hash collision: 6, but very rarely.
+ * NOTE! We don't use the SMP-safe bit tests. We simply
+ * don't care enough.
+ */
+static void warn_on_bintable(const int *name, int nlen)
+{
+       int i;
+       u32 hash = FNV32_OFFSET;
+
+       for (i = 0; i < nlen; i++)
+               hash = (hash ^ name[i]) * FNV32_PRIME;
+       hash %= WARN_ONCE_HASH_SIZE;
+       if (__test_and_set_bit(hash, warn_once_bitmap))
+               return;
+       deprecated_sysctl_warning(name, nlen);
+}
+
 static ssize_t do_sysctl(int __user *args_name, int nlen,
        void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
 {
@@ -1424,7 +1460,7 @@ static ssize_t do_sysctl(int __user *args_name, int nlen,
                if (get_user(name[i], args_name + i))
                        return -EFAULT;
 
-       deprecated_sysctl_warning(name, nlen);
+       warn_on_bintable(name, nlen);
 
        return binary_sysctl(name, nlen, oldval, oldlen, newval, newlen);
 }
index c6324d96009ec20214ce0be3c7e468b5c7679bb1..804798005d19846d449fcb5b2b81439135c6c62a 100644 (file)
@@ -136,6 +136,7 @@ static inline void warp_clock(void)
        write_seqlock_irq(&xtime_lock);
        wall_to_monotonic.tv_sec -= sys_tz.tz_minuteswest * 60;
        xtime.tv_sec += sys_tz.tz_minuteswest * 60;
+       update_xtime_cache(0);
        write_sequnlock_irq(&xtime_lock);
        clock_was_set();
 }
index 20a8920029eeedbb0a66d896af445c370c2f854b..6f740d9f09485a3843086d20472c169b86c232aa 100644 (file)
@@ -30,7 +30,7 @@ static LIST_HEAD(clockevents_released);
 static RAW_NOTIFIER_HEAD(clockevents_chain);
 
 /* Protection for the above */
-static DEFINE_SPINLOCK(clockevents_lock);
+static DEFINE_RAW_SPINLOCK(clockevents_lock);
 
 /**
  * clockevents_delta2ns - Convert a latch value (device ticks) to nanoseconds
@@ -141,9 +141,9 @@ int clockevents_register_notifier(struct notifier_block *nb)
        unsigned long flags;
        int ret;
 
-       spin_lock_irqsave(&clockevents_lock, flags);
+       raw_spin_lock_irqsave(&clockevents_lock, flags);
        ret = raw_notifier_chain_register(&clockevents_chain, nb);
-       spin_unlock_irqrestore(&clockevents_lock, flags);
+       raw_spin_unlock_irqrestore(&clockevents_lock, flags);
 
        return ret;
 }
@@ -185,13 +185,13 @@ void clockevents_register_device(struct clock_event_device *dev)
        BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
        BUG_ON(!dev->cpumask);
 
-       spin_lock_irqsave(&clockevents_lock, flags);
+       raw_spin_lock_irqsave(&clockevents_lock, flags);
 
        list_add(&dev->list, &clockevent_devices);
        clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);
        clockevents_notify_released();
 
-       spin_unlock_irqrestore(&clockevents_lock, flags);
+       raw_spin_unlock_irqrestore(&clockevents_lock, flags);
 }
 EXPORT_SYMBOL_GPL(clockevents_register_device);
 
@@ -238,10 +238,11 @@ void clockevents_exchange_device(struct clock_event_device *old,
  */
 void clockevents_notify(unsigned long reason, void *arg)
 {
-       struct list_head *node, *tmp;
+       struct clock_event_device *dev, *tmp;
        unsigned long flags;
+       int cpu;
 
-       spin_lock_irqsave(&clockevents_lock, flags);
+       raw_spin_lock_irqsave(&clockevents_lock, flags);
        clockevents_do_notify(reason, arg);
 
        switch (reason) {
@@ -250,13 +251,24 @@ void clockevents_notify(unsigned long reason, void *arg)
                 * Unregister the clock event devices which were
                 * released from the users in the notify chain.
                 */
-               list_for_each_safe(node, tmp, &clockevents_released)
-                       list_del(node);
+               list_for_each_entry_safe(dev, tmp, &clockevents_released, list)
+                       list_del(&dev->list);
+               /*
+                * Now check whether the CPU has left unused per cpu devices
+                */
+               cpu = *((int *)arg);
+               list_for_each_entry_safe(dev, tmp, &clockevent_devices, list) {
+                       if (cpumask_test_cpu(cpu, dev->cpumask) &&
+                           cpumask_weight(dev->cpumask) == 1) {
+                               BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
+                               list_del(&dev->list);
+                       }
+               }
                break;
        default:
                break;
        }
-       spin_unlock_irqrestore(&clockevents_lock, flags);
+       raw_spin_unlock_irqrestore(&clockevents_lock, flags);
 }
 EXPORT_SYMBOL_GPL(clockevents_notify);
 #endif
index c2ec25087a35a0cbf265258caf953d83424314f9..b3bafd5fc66d947aaa77982b0213b9321a8c0329 100644 (file)
@@ -31,7 +31,7 @@ static struct tick_device tick_broadcast_device;
 /* FIXME: Use cpumask_var_t. */
 static DECLARE_BITMAP(tick_broadcast_mask, NR_CPUS);
 static DECLARE_BITMAP(tmpmask, NR_CPUS);
-static DEFINE_SPINLOCK(tick_broadcast_lock);
+static DEFINE_RAW_SPINLOCK(tick_broadcast_lock);
 static int tick_broadcast_force;
 
 #ifdef CONFIG_TICK_ONESHOT
@@ -96,7 +96,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
        unsigned long flags;
        int ret = 0;
 
-       spin_lock_irqsave(&tick_broadcast_lock, flags);
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        /*
         * Devices might be registered with both periodic and oneshot
@@ -122,7 +122,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
                        tick_broadcast_clear_oneshot(cpu);
                }
        }
-       spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
        return ret;
 }
 
@@ -161,13 +161,13 @@ static void tick_do_broadcast(struct cpumask *mask)
  */
 static void tick_do_periodic_broadcast(void)
 {
-       spin_lock(&tick_broadcast_lock);
+       raw_spin_lock(&tick_broadcast_lock);
 
        cpumask_and(to_cpumask(tmpmask),
                    cpu_online_mask, tick_get_broadcast_mask());
        tick_do_broadcast(to_cpumask(tmpmask));
 
-       spin_unlock(&tick_broadcast_lock);
+       raw_spin_unlock(&tick_broadcast_lock);
 }
 
 /*
@@ -212,7 +212,7 @@ static void tick_do_broadcast_on_off(unsigned long *reason)
        unsigned long flags;
        int cpu, bc_stopped;
 
-       spin_lock_irqsave(&tick_broadcast_lock, flags);
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        cpu = smp_processor_id();
        td = &per_cpu(tick_cpu_device, cpu);
@@ -263,7 +263,7 @@ static void tick_do_broadcast_on_off(unsigned long *reason)
                        tick_broadcast_setup_oneshot(bc);
        }
 out:
-       spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
 /*
@@ -299,7 +299,7 @@ void tick_shutdown_broadcast(unsigned int *cpup)
        unsigned long flags;
        unsigned int cpu = *cpup;
 
-       spin_lock_irqsave(&tick_broadcast_lock, flags);
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        bc = tick_broadcast_device.evtdev;
        cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
@@ -309,7 +309,7 @@ void tick_shutdown_broadcast(unsigned int *cpup)
                        clockevents_shutdown(bc);
        }
 
-       spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
 void tick_suspend_broadcast(void)
@@ -317,13 +317,13 @@ void tick_suspend_broadcast(void)
        struct clock_event_device *bc;
        unsigned long flags;
 
-       spin_lock_irqsave(&tick_broadcast_lock, flags);
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        bc = tick_broadcast_device.evtdev;
        if (bc)
                clockevents_shutdown(bc);
 
-       spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
 int tick_resume_broadcast(void)
@@ -332,7 +332,7 @@ int tick_resume_broadcast(void)
        unsigned long flags;
        int broadcast = 0;
 
-       spin_lock_irqsave(&tick_broadcast_lock, flags);
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        bc = tick_broadcast_device.evtdev;
 
@@ -351,7 +351,7 @@ int tick_resume_broadcast(void)
                        break;
                }
        }
-       spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 
        return broadcast;
 }
@@ -405,7 +405,7 @@ static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
        ktime_t now, next_event;
        int cpu;
 
-       spin_lock(&tick_broadcast_lock);
+       raw_spin_lock(&tick_broadcast_lock);
 again:
        dev->next_event.tv64 = KTIME_MAX;
        next_event.tv64 = KTIME_MAX;
@@ -443,7 +443,7 @@ again:
                if (tick_broadcast_set_event(next_event, 0))
                        goto again;
        }
-       spin_unlock(&tick_broadcast_lock);
+       raw_spin_unlock(&tick_broadcast_lock);
 }
 
 /*
@@ -457,7 +457,7 @@ void tick_broadcast_oneshot_control(unsigned long reason)
        unsigned long flags;
        int cpu;
 
-       spin_lock_irqsave(&tick_broadcast_lock, flags);
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        /*
         * Periodic mode does not care about the enter/exit of power
@@ -492,7 +492,7 @@ void tick_broadcast_oneshot_control(unsigned long reason)
        }
 
 out:
-       spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
 /*
@@ -563,13 +563,13 @@ void tick_broadcast_switch_to_oneshot(void)
        struct clock_event_device *bc;
        unsigned long flags;
 
-       spin_lock_irqsave(&tick_broadcast_lock, flags);
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT;
        bc = tick_broadcast_device.evtdev;
        if (bc)
                tick_broadcast_setup_oneshot(bc);
-       spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
 
@@ -581,7 +581,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup)
        unsigned long flags;
        unsigned int cpu = *cpup;
 
-       spin_lock_irqsave(&tick_broadcast_lock, flags);
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
 
        /*
         * Clear the broadcast mask flag for the dead cpu, but do not
@@ -589,7 +589,7 @@ void tick_shutdown_broadcast_oneshot(unsigned int *cpup)
         */
        cpumask_clear_cpu(cpu, tick_get_broadcast_oneshot_mask());
 
-       spin_unlock_irqrestore(&tick_broadcast_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }
 
 /*
index 83c4417b6a3cccd734c8f7f9386670641babd0c8..b6b898d2eeefc1b0627c613b3d23a9bd4b21876e 100644 (file)
@@ -34,7 +34,7 @@ DEFINE_PER_CPU(struct tick_device, tick_cpu_device);
 ktime_t tick_next_period;
 ktime_t tick_period;
 int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT;
-DEFINE_SPINLOCK(tick_device_lock);
+static DEFINE_RAW_SPINLOCK(tick_device_lock);
 
 /*
  * Debugging: see timer_list.c
@@ -209,7 +209,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
        int cpu, ret = NOTIFY_OK;
        unsigned long flags;
 
-       spin_lock_irqsave(&tick_device_lock, flags);
+       raw_spin_lock_irqsave(&tick_device_lock, flags);
 
        cpu = smp_processor_id();
        if (!cpumask_test_cpu(cpu, newdev->cpumask))
@@ -268,7 +268,7 @@ static int tick_check_new_device(struct clock_event_device *newdev)
        if (newdev->features & CLOCK_EVT_FEAT_ONESHOT)
                tick_oneshot_notify();
 
-       spin_unlock_irqrestore(&tick_device_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_device_lock, flags);
        return NOTIFY_STOP;
 
 out_bc:
@@ -278,7 +278,7 @@ out_bc:
        if (tick_check_broadcast_device(newdev))
                ret = NOTIFY_STOP;
 
-       spin_unlock_irqrestore(&tick_device_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_device_lock, flags);
 
        return ret;
 }
@@ -311,7 +311,7 @@ static void tick_shutdown(unsigned int *cpup)
        struct clock_event_device *dev = td->evtdev;
        unsigned long flags;
 
-       spin_lock_irqsave(&tick_device_lock, flags);
+       raw_spin_lock_irqsave(&tick_device_lock, flags);
        td->mode = TICKDEV_MODE_PERIODIC;
        if (dev) {
                /*
@@ -322,7 +322,7 @@ static void tick_shutdown(unsigned int *cpup)
                clockevents_exchange_device(dev, NULL);
                td->evtdev = NULL;
        }
-       spin_unlock_irqrestore(&tick_device_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_device_lock, flags);
 }
 
 static void tick_suspend(void)
@@ -330,9 +330,9 @@ static void tick_suspend(void)
        struct tick_device *td = &__get_cpu_var(tick_cpu_device);
        unsigned long flags;
 
-       spin_lock_irqsave(&tick_device_lock, flags);
+       raw_spin_lock_irqsave(&tick_device_lock, flags);
        clockevents_shutdown(td->evtdev);
-       spin_unlock_irqrestore(&tick_device_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_device_lock, flags);
 }
 
 static void tick_resume(void)
@@ -341,7 +341,7 @@ static void tick_resume(void)
        unsigned long flags;
        int broadcast = tick_resume_broadcast();
 
-       spin_lock_irqsave(&tick_device_lock, flags);
+       raw_spin_lock_irqsave(&tick_device_lock, flags);
        clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME);
 
        if (!broadcast) {
@@ -350,7 +350,7 @@ static void tick_resume(void)
                else
                        tick_resume_oneshot();
        }
-       spin_unlock_irqrestore(&tick_device_lock, flags);
+       raw_spin_unlock_irqrestore(&tick_device_lock, flags);
 }
 
 /*
index b1c05bf75ee0ce36e0664d3e2e71d00ac0e09edd..290eefbc1f608ec4d9c957fb5798eb53490f9e7c 100644 (file)
@@ -6,7 +6,6 @@
 #define TICK_DO_TIMER_BOOT     -2
 
 DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
-extern spinlock_t tick_device_lock;
 extern ktime_t tick_next_period;
 extern ktime_t tick_period;
 extern int tick_do_timer_cpu __read_mostly;
index 96ff643a5a59bdf1745e776434115cd430fa3935..12f5c55090bea159652c299d0db1a0a2969a3424 100644 (file)
@@ -89,7 +89,7 @@ int timecompare_offset(struct timecompare *sync,
                         * source time
                         */
                        sample.offset =
-                               ktime_to_ns(ktime_add(end, start)) / 2 -
+                               (ktime_to_ns(end) + ktime_to_ns(start)) / 2 -
                                ts;
 
                        /* simple insertion sort based on duration */
index af4135f058254b0607fc2594f2c52ae6355e76b1..7faaa32fbf4f37d1d2efdedf9a3087a98455f7b6 100644 (file)
@@ -165,6 +165,13 @@ struct timespec raw_time;
 /* flag for if timekeeping is suspended */
 int __read_mostly timekeeping_suspended;
 
+static struct timespec xtime_cache __attribute__ ((aligned (16)));
+void update_xtime_cache(u64 nsec)
+{
+       xtime_cache = xtime;
+       timespec_add_ns(&xtime_cache, nsec);
+}
+
 /* must hold xtime_lock */
 void timekeeping_leap_insert(int leapsecond)
 {
@@ -325,6 +332,8 @@ int do_settimeofday(struct timespec *tv)
 
        xtime = *tv;
 
+       update_xtime_cache(0);
+
        timekeeper.ntp_error = 0;
        ntp_clear();
 
@@ -550,6 +559,7 @@ void __init timekeeping_init(void)
        }
        set_normalized_timespec(&wall_to_monotonic,
                                -boot.tv_sec, -boot.tv_nsec);
+       update_xtime_cache(0);
        total_sleep_time.tv_sec = 0;
        total_sleep_time.tv_nsec = 0;
        write_sequnlock_irqrestore(&xtime_lock, flags);
@@ -583,6 +593,7 @@ static int timekeeping_resume(struct sys_device *dev)
                wall_to_monotonic = timespec_sub(wall_to_monotonic, ts);
                total_sleep_time = timespec_add_safe(total_sleep_time, ts);
        }
+       update_xtime_cache(0);
        /* re-base the last cycle value */
        timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock);
        timekeeper.ntp_error = 0;
@@ -722,6 +733,7 @@ static void timekeeping_adjust(s64 offset)
                                timekeeper.ntp_error_shift;
 }
 
+
 /**
  * logarithmic_accumulation - shifted accumulation of cycles
  *
@@ -765,6 +777,7 @@ static cycle_t logarithmic_accumulation(cycle_t offset, int shift)
        return offset;
 }
 
+
 /**
  * update_wall_time - Uses the current clocksource to increment the wall time
  *
@@ -774,6 +787,7 @@ void update_wall_time(void)
 {
        struct clocksource *clock;
        cycle_t offset;
+       u64 nsecs;
        int shift = 0, maxshift;
 
        /* Make sure we're fully resumed: */
@@ -839,6 +853,9 @@ void update_wall_time(void)
        timekeeper.ntp_error += timekeeper.xtime_nsec <<
                                timekeeper.ntp_error_shift;
 
+       nsecs = clocksource_cyc2ns(offset, timekeeper.mult, timekeeper.shift);
+       update_xtime_cache(nsecs);
+
        /* check to see if there is a new clocksource to use */
        update_vsyscall(&xtime, timekeeper.clock, timekeeper.mult);
 }
@@ -875,13 +892,13 @@ void monotonic_to_bootbased(struct timespec *ts)
 
 unsigned long get_seconds(void)
 {
-       return xtime.tv_sec;
+       return xtime_cache.tv_sec;
 }
 EXPORT_SYMBOL(get_seconds);
 
 struct timespec __current_kernel_time(void)
 {
-       return xtime;
+       return xtime_cache;
 }
 
 struct timespec current_kernel_time(void)
@@ -891,7 +908,8 @@ struct timespec current_kernel_time(void)
 
        do {
                seq = read_seqbegin(&xtime_lock);
-               now = xtime;
+
+               now = xtime_cache;
        } while (read_seqretry(&xtime_lock, seq));
 
        return now;
@@ -905,7 +923,8 @@ struct timespec get_monotonic_coarse(void)
 
        do {
                seq = read_seqbegin(&xtime_lock);
-               now = xtime;
+
+               now = xtime_cache;
                mono = wall_to_monotonic;
        } while (read_seqretry(&xtime_lock, seq));
 
index 9d80db4747d4d6371dc023cde7f5cbc73e20d4fa..bdfb8dd1050cfb64f4cca35f22b749b06a294dd1 100644 (file)
@@ -84,7 +84,7 @@ print_active_timers(struct seq_file *m, struct hrtimer_clock_base *base,
 
 next_one:
        i = 0;
-       spin_lock_irqsave(&base->cpu_base->lock, flags);
+       raw_spin_lock_irqsave(&base->cpu_base->lock, flags);
 
        curr = base->first;
        /*
@@ -100,13 +100,13 @@ next_one:
 
                timer = rb_entry(curr, struct hrtimer, node);
                tmp = *timer;
-               spin_unlock_irqrestore(&base->cpu_base->lock, flags);
+               raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags);
 
                print_timer(m, timer, &tmp, i, now);
                next++;
                goto next_one;
        }
-       spin_unlock_irqrestore(&base->cpu_base->lock, flags);
+       raw_spin_unlock_irqrestore(&base->cpu_base->lock, flags);
 }
 
 static void
@@ -237,10 +237,10 @@ static void timer_list_show_tickdevices(struct seq_file *m)
 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
        print_tickdevice(m, tick_get_broadcast_device(), -1);
        SEQ_printf(m, "tick_broadcast_mask: %08lx\n",
-                  tick_get_broadcast_mask()->bits[0]);
+                  cpumask_bits(tick_get_broadcast_mask())[0]);
 #ifdef CONFIG_TICK_ONESHOT
        SEQ_printf(m, "tick_broadcast_oneshot_mask: %08lx\n",
-                  tick_get_broadcast_oneshot_mask()->bits[0]);
+                  cpumask_bits(tick_get_broadcast_oneshot_mask())[0]);
 #endif
        SEQ_printf(m, "\n");
 #endif
index 63b117e9eba13fb430372601bdc36ff7d3ef42a2..2f3b585b8d7d2f9b728cc86469c7188dfe232b23 100644 (file)
@@ -86,7 +86,7 @@ static DEFINE_SPINLOCK(table_lock);
 /*
  * Per-CPU lookup locks for fast hash lookup:
  */
-static DEFINE_PER_CPU(spinlock_t, tstats_lookup_lock);
+static DEFINE_PER_CPU(raw_spinlock_t, tstats_lookup_lock);
 
 /*
  * Mutex to serialize state changes with show-stats activities:
@@ -238,7 +238,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
        /*
         * It doesnt matter which lock we take:
         */
-       spinlock_t *lock;
+       raw_spinlock_t *lock;
        struct entry *entry, input;
        unsigned long flags;
 
@@ -253,7 +253,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
        input.pid = pid;
        input.timer_flag = timer_flag;
 
-       spin_lock_irqsave(lock, flags);
+       raw_spin_lock_irqsave(lock, flags);
        if (!timer_stats_active)
                goto out_unlock;
 
@@ -264,7 +264,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
                atomic_inc(&overflow_count);
 
  out_unlock:
-       spin_unlock_irqrestore(lock, flags);
+       raw_spin_unlock_irqrestore(lock, flags);
 }
 
 static void print_name_offset(struct seq_file *m, unsigned long addr)
@@ -348,10 +348,11 @@ static void sync_access(void)
        int cpu;
 
        for_each_online_cpu(cpu) {
-               spinlock_t *lock = &per_cpu(tstats_lookup_lock, cpu);
-               spin_lock_irqsave(lock, flags);
+               raw_spinlock_t *lock = &per_cpu(tstats_lookup_lock, cpu);
+
+               raw_spin_lock_irqsave(lock, flags);
                /* nothing */
-               spin_unlock_irqrestore(lock, flags);
+               raw_spin_unlock_irqrestore(lock, flags);
        }
 }
 
@@ -409,7 +410,7 @@ void __init init_timer_stats(void)
        int cpu;
 
        for_each_possible_cpu(cpu)
-               spin_lock_init(&per_cpu(tstats_lookup_lock, cpu));
+               raw_spin_lock_init(&per_cpu(tstats_lookup_lock, cpu));
 }
 
 static int __init init_tstats_procfs(void)
index 5db5a8d2681168cfcf9c571d2da69629245c92ba..15533b792397be532ddcce7f2d24c04f78efba75 100644 (file)
@@ -656,8 +656,6 @@ __mod_timer(struct timer_list *timer, unsigned long expires,
 
        debug_activate(timer, expires);
 
-       new_base = __get_cpu_var(tvec_bases);
-
        cpu = smp_processor_id();
 
 #if defined(CONFIG_NO_HZ) && defined(CONFIG_SMP)
index e51a1bcb7bed3e8dc93430d37d89d2179e7e5d2a..7968762c8167062d1f05d2e14531b349ba840518 100644 (file)
@@ -1724,7 +1724,7 @@ ftrace_match_record(struct dyn_ftrace *rec, char *regex, int len, int type)
        return ftrace_match(str, regex, len, type);
 }
 
-static void ftrace_match_records(char *buff, int len, int enable)
+static int ftrace_match_records(char *buff, int len, int enable)
 {
        unsigned int search_len;
        struct ftrace_page *pg;
@@ -1733,6 +1733,7 @@ static void ftrace_match_records(char *buff, int len, int enable)
        char *search;
        int type;
        int not;
+       int found = 0;
 
        flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE;
        type = filter_parse_regex(buff, len, &search, &not);
@@ -1750,6 +1751,7 @@ static void ftrace_match_records(char *buff, int len, int enable)
                                rec->flags &= ~flag;
                        else
                                rec->flags |= flag;
+                       found = 1;
                }
                /*
                 * Only enable filtering if we have a function that
@@ -1759,6 +1761,8 @@ static void ftrace_match_records(char *buff, int len, int enable)
                        ftrace_filtered = 1;
        } while_for_each_ftrace_rec();
        mutex_unlock(&ftrace_lock);
+
+       return found;
 }
 
 static int
@@ -1780,7 +1784,7 @@ ftrace_match_module_record(struct dyn_ftrace *rec, char *mod,
                return 1;
 }
 
-static void ftrace_match_module_records(char *buff, char *mod, int enable)
+static int ftrace_match_module_records(char *buff, char *mod, int enable)
 {
        unsigned search_len = 0;
        struct ftrace_page *pg;
@@ -1789,6 +1793,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable)
        char *search = buff;
        unsigned long flag;
        int not = 0;
+       int found = 0;
 
        flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE;
 
@@ -1819,12 +1824,15 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable)
                                rec->flags &= ~flag;
                        else
                                rec->flags |= flag;
+                       found = 1;
                }
                if (enable && (rec->flags & FTRACE_FL_FILTER))
                        ftrace_filtered = 1;
 
        } while_for_each_ftrace_rec();
        mutex_unlock(&ftrace_lock);
+
+       return found;
 }
 
 /*
@@ -1853,8 +1861,9 @@ ftrace_mod_callback(char *func, char *cmd, char *param, int enable)
        if (!strlen(mod))
                return -EINVAL;
 
-       ftrace_match_module_records(func, mod, enable);
-       return 0;
+       if (ftrace_match_module_records(func, mod, enable))
+               return 0;
+       return -EINVAL;
 }
 
 static struct ftrace_func_command ftrace_mod_cmd = {
@@ -2151,8 +2160,9 @@ static int ftrace_process_regex(char *buff, int len, int enable)
        func = strsep(&next, ":");
 
        if (!next) {
-               ftrace_match_records(func, len, enable);
-               return 0;
+               if (ftrace_match_records(func, len, enable))
+                       return 0;
+               return ret;
        }
 
        /* command found */
@@ -2198,10 +2208,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
            !trace_parser_cont(parser)) {
                ret = ftrace_process_regex(parser->buffer,
                                           parser->idx, enable);
+               trace_parser_clear(parser);
                if (ret)
                        goto out_unlock;
-
-               trace_parser_clear(parser);
        }
 
        ret = read;
@@ -2543,10 +2552,9 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)
                                        exists = true;
                                        break;
                                }
-                       if (!exists) {
+                       if (!exists)
                                array[(*idx)++] = rec->ip;
-                               found = 1;
-                       }
+                       found = 1;
                }
        } while_for_each_ftrace_rec();
 
index e06c6e3d56a3057a62bac39e169b77c79b8d6fd4..9f4f565b01e67e59bfd906f950ebea9f863252a6 100644 (file)
@@ -14,7 +14,5 @@
 #define CREATE_TRACE_POINTS
 #include <trace/events/power.h>
 
-EXPORT_TRACEPOINT_SYMBOL_GPL(power_start);
-EXPORT_TRACEPOINT_SYMBOL_GPL(power_end);
 EXPORT_TRACEPOINT_SYMBOL_GPL(power_frequency);
 
index a1ca4956ab5ec3673b04ddd839dd9edec26d1bf4..2326b04c95c493fec48418746c0194980ad4b4fa 100644 (file)
@@ -423,7 +423,7 @@ struct ring_buffer_per_cpu {
        int                             cpu;
        struct ring_buffer              *buffer;
        spinlock_t                      reader_lock;    /* serialize readers */
-       raw_spinlock_t                  lock;
+       arch_spinlock_t                 lock;
        struct lock_class_key           lock_key;
        struct list_head                *pages;
        struct buffer_page              *head_page;     /* read from head */
@@ -998,7 +998,7 @@ rb_allocate_cpu_buffer(struct ring_buffer *buffer, int cpu)
        cpu_buffer->buffer = buffer;
        spin_lock_init(&cpu_buffer->reader_lock);
        lockdep_set_class(&cpu_buffer->reader_lock, buffer->reader_lock_key);
-       cpu_buffer->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+       cpu_buffer->lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
 
        bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()),
                            GFP_KERNEL, cpu_to_node(cpu));
@@ -1193,9 +1193,6 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
        struct list_head *p;
        unsigned i;
 
-       atomic_inc(&cpu_buffer->record_disabled);
-       synchronize_sched();
-
        spin_lock_irq(&cpu_buffer->reader_lock);
        rb_head_page_deactivate(cpu_buffer);
 
@@ -1211,12 +1208,9 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned nr_pages)
                return;
 
        rb_reset_cpu(cpu_buffer);
-       spin_unlock_irq(&cpu_buffer->reader_lock);
-
        rb_check_pages(cpu_buffer);
 
-       atomic_dec(&cpu_buffer->record_disabled);
-
+       spin_unlock_irq(&cpu_buffer->reader_lock);
 }
 
 static void
@@ -1227,9 +1221,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
        struct list_head *p;
        unsigned i;
 
-       atomic_inc(&cpu_buffer->record_disabled);
-       synchronize_sched();
-
        spin_lock_irq(&cpu_buffer->reader_lock);
        rb_head_page_deactivate(cpu_buffer);
 
@@ -1242,11 +1233,9 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
                list_add_tail(&bpage->list, cpu_buffer->pages);
        }
        rb_reset_cpu(cpu_buffer);
-       spin_unlock_irq(&cpu_buffer->reader_lock);
-
        rb_check_pages(cpu_buffer);
 
-       atomic_dec(&cpu_buffer->record_disabled);
+       spin_unlock_irq(&cpu_buffer->reader_lock);
 }
 
 /**
@@ -1254,11 +1243,6 @@ rb_insert_pages(struct ring_buffer_per_cpu *cpu_buffer,
  * @buffer: the buffer to resize.
  * @size: the new size.
  *
- * The tracer is responsible for making sure that the buffer is
- * not being used while changing the size.
- * Note: We may be able to change the above requirement by using
- *  RCU synchronizations.
- *
  * Minimum size is 2 * BUF_PAGE_SIZE.
  *
  * Returns -1 on failure.
@@ -1290,6 +1274,11 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
        if (size == buffer_size)
                return size;
 
+       atomic_inc(&buffer->record_disabled);
+
+       /* Make sure all writers are done with this buffer. */
+       synchronize_sched();
+
        mutex_lock(&buffer->mutex);
        get_online_cpus();
 
@@ -1352,6 +1341,8 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
        put_online_cpus();
        mutex_unlock(&buffer->mutex);
 
+       atomic_dec(&buffer->record_disabled);
+
        return size;
 
  free_pages:
@@ -1361,6 +1352,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
        }
        put_online_cpus();
        mutex_unlock(&buffer->mutex);
+       atomic_dec(&buffer->record_disabled);
        return -ENOMEM;
 
        /*
@@ -1370,6 +1362,7 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size)
  out_fail:
        put_online_cpus();
        mutex_unlock(&buffer->mutex);
+       atomic_dec(&buffer->record_disabled);
        return -1;
 }
 EXPORT_SYMBOL_GPL(ring_buffer_resize);
@@ -2834,7 +2827,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
        int ret;
 
        local_irq_save(flags);
-       __raw_spin_lock(&cpu_buffer->lock);
+       arch_spin_lock(&cpu_buffer->lock);
 
  again:
        /*
@@ -2923,7 +2916,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
        goto again;
 
  out:
-       __raw_spin_unlock(&cpu_buffer->lock);
+       arch_spin_unlock(&cpu_buffer->lock);
        local_irq_restore(flags);
 
        return reader;
@@ -3286,9 +3279,9 @@ ring_buffer_read_start(struct ring_buffer *buffer, int cpu)
        synchronize_sched();
 
        spin_lock_irqsave(&cpu_buffer->reader_lock, flags);
-       __raw_spin_lock(&cpu_buffer->lock);
+       arch_spin_lock(&cpu_buffer->lock);
        rb_iter_reset(iter);
-       __raw_spin_unlock(&cpu_buffer->lock);
+       arch_spin_unlock(&cpu_buffer->lock);
        spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
 
        return iter;
@@ -3408,11 +3401,11 @@ void ring_buffer_reset_cpu(struct ring_buffer *buffer, int cpu)
        if (RB_WARN_ON(cpu_buffer, local_read(&cpu_buffer->committing)))
                goto out;
 
-       __raw_spin_lock(&cpu_buffer->lock);
+       arch_spin_lock(&cpu_buffer->lock);
 
        rb_reset_cpu(cpu_buffer);
 
-       __raw_spin_unlock(&cpu_buffer->lock);
+       arch_spin_unlock(&cpu_buffer->lock);
 
  out:
        spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags);
index c82dfd92fdfd8d663b6146ea6a584d42ea715508..8b9f20ab8eed9acc1b3d2529e377668951125723 100644 (file)
@@ -12,7 +12,7 @@
  *  Copyright (C) 2004 William Lee Irwin III
  */
 #include <linux/ring_buffer.h>
-#include <linux/utsrelease.h>
+#include <generated/utsrelease.h>
 #include <linux/stacktrace.h>
 #include <linux/writeback.h>
 #include <linux/kallsyms.h>
@@ -313,7 +313,6 @@ static const char *trace_options[] = {
        "bin",
        "block",
        "stacktrace",
-       "sched-tree",
        "trace_printk",
        "ftrace_preempt",
        "branch",
@@ -493,15 +492,15 @@ static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
  * protected by per_cpu spinlocks. But the action of the swap
  * needs its own lock.
  *
- * This is defined as a raw_spinlock_t in order to help
+ * This is defined as a arch_spinlock_t in order to help
  * with performance when lockdep debugging is enabled.
  *
  * It is also used in other places outside the update_max_tr
  * so it needs to be defined outside of the
  * CONFIG_TRACER_MAX_TRACE.
  */
-static raw_spinlock_t ftrace_max_lock =
-       (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+static arch_spinlock_t ftrace_max_lock =
+       (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
 
 #ifdef CONFIG_TRACER_MAX_TRACE
 unsigned long __read_mostly    tracing_max_latency;
@@ -555,13 +554,13 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
                return;
 
        WARN_ON_ONCE(!irqs_disabled());
-       __raw_spin_lock(&ftrace_max_lock);
+       arch_spin_lock(&ftrace_max_lock);
 
        tr->buffer = max_tr.buffer;
        max_tr.buffer = buf;
 
        __update_max_tr(tr, tsk, cpu);
-       __raw_spin_unlock(&ftrace_max_lock);
+       arch_spin_unlock(&ftrace_max_lock);
 }
 
 /**
@@ -581,7 +580,7 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
                return;
 
        WARN_ON_ONCE(!irqs_disabled());
-       __raw_spin_lock(&ftrace_max_lock);
+       arch_spin_lock(&ftrace_max_lock);
 
        ftrace_disable_cpu();
 
@@ -603,7 +602,7 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
        WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY);
 
        __update_max_tr(tr, tsk, cpu);
-       __raw_spin_unlock(&ftrace_max_lock);
+       arch_spin_unlock(&ftrace_max_lock);
 }
 #endif /* CONFIG_TRACER_MAX_TRACE */
 
@@ -802,7 +801,7 @@ static unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1];
 static unsigned map_cmdline_to_pid[SAVED_CMDLINES];
 static char saved_cmdlines[SAVED_CMDLINES][TASK_COMM_LEN];
 static int cmdline_idx;
-static raw_spinlock_t trace_cmdline_lock = __RAW_SPIN_LOCK_UNLOCKED;
+static arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED;
 
 /* temporary disable recording */
 static atomic_t trace_record_cmdline_disabled __read_mostly;
@@ -915,7 +914,7 @@ static void trace_save_cmdline(struct task_struct *tsk)
         * nor do we want to disable interrupts,
         * so if we miss here, then better luck next time.
         */
-       if (!__raw_spin_trylock(&trace_cmdline_lock))
+       if (!arch_spin_trylock(&trace_cmdline_lock))
                return;
 
        idx = map_pid_to_cmdline[tsk->pid];
@@ -940,7 +939,7 @@ static void trace_save_cmdline(struct task_struct *tsk)
 
        memcpy(&saved_cmdlines[idx], tsk->comm, TASK_COMM_LEN);
 
-       __raw_spin_unlock(&trace_cmdline_lock);
+       arch_spin_unlock(&trace_cmdline_lock);
 }
 
 void trace_find_cmdline(int pid, char comm[])
@@ -958,14 +957,14 @@ void trace_find_cmdline(int pid, char comm[])
        }
 
        preempt_disable();
-       __raw_spin_lock(&trace_cmdline_lock);
+       arch_spin_lock(&trace_cmdline_lock);
        map = map_pid_to_cmdline[pid];
        if (map != NO_CMDLINE_MAP)
                strcpy(comm, saved_cmdlines[map]);
        else
                strcpy(comm, "<...>");
 
-       __raw_spin_unlock(&trace_cmdline_lock);
+       arch_spin_unlock(&trace_cmdline_lock);
        preempt_enable();
 }
 
@@ -1151,6 +1150,22 @@ void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
        __ftrace_trace_stack(tr->buffer, flags, skip, pc);
 }
 
+/**
+ * trace_dump_stack - record a stack back trace in the trace buffer
+ */
+void trace_dump_stack(void)
+{
+       unsigned long flags;
+
+       if (tracing_disabled || tracing_selftest_running)
+               return;
+
+       local_save_flags(flags);
+
+       /* skipping 3 traces, seems to get us at the caller of this function */
+       __ftrace_trace_stack(global_trace.buffer, flags, 3, preempt_count());
+}
+
 void
 ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc)
 {
@@ -1251,8 +1266,8 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3)
  */
 int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
 {
-       static raw_spinlock_t trace_buf_lock =
-               (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+       static arch_spinlock_t trace_buf_lock =
+               (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
        static u32 trace_buf[TRACE_BUF_SIZE];
 
        struct ftrace_event_call *call = &event_bprint;
@@ -1283,7 +1298,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
 
        /* Lockdep uses trace_printk for lock tracing */
        local_irq_save(flags);
-       __raw_spin_lock(&trace_buf_lock);
+       arch_spin_lock(&trace_buf_lock);
        len = vbin_printf(trace_buf, TRACE_BUF_SIZE, fmt, args);
 
        if (len > TRACE_BUF_SIZE || len < 0)
@@ -1304,7 +1319,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
                ring_buffer_unlock_commit(buffer, event);
 
 out_unlock:
-       __raw_spin_unlock(&trace_buf_lock);
+       arch_spin_unlock(&trace_buf_lock);
        local_irq_restore(flags);
 
 out:
@@ -1334,7 +1349,7 @@ int trace_array_printk(struct trace_array *tr,
 int trace_array_vprintk(struct trace_array *tr,
                        unsigned long ip, const char *fmt, va_list args)
 {
-       static raw_spinlock_t trace_buf_lock = __RAW_SPIN_LOCK_UNLOCKED;
+       static arch_spinlock_t trace_buf_lock = __ARCH_SPIN_LOCK_UNLOCKED;
        static char trace_buf[TRACE_BUF_SIZE];
 
        struct ftrace_event_call *call = &event_print;
@@ -1360,7 +1375,7 @@ int trace_array_vprintk(struct trace_array *tr,
 
        pause_graph_tracing();
        raw_local_irq_save(irq_flags);
-       __raw_spin_lock(&trace_buf_lock);
+       arch_spin_lock(&trace_buf_lock);
        len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
 
        size = sizeof(*entry) + len + 1;
@@ -1378,7 +1393,7 @@ int trace_array_vprintk(struct trace_array *tr,
                ring_buffer_unlock_commit(buffer, event);
 
  out_unlock:
-       __raw_spin_unlock(&trace_buf_lock);
+       arch_spin_unlock(&trace_buf_lock);
        raw_local_irq_restore(irq_flags);
        unpause_graph_tracing();
  out:
@@ -2279,7 +2294,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
        mutex_lock(&tracing_cpumask_update_lock);
 
        local_irq_disable();
-       __raw_spin_lock(&ftrace_max_lock);
+       arch_spin_lock(&ftrace_max_lock);
        for_each_tracing_cpu(cpu) {
                /*
                 * Increase/decrease the disabled counter if we are
@@ -2294,7 +2309,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
                        atomic_dec(&global_trace.data[cpu]->disabled);
                }
        }
-       __raw_spin_unlock(&ftrace_max_lock);
+       arch_spin_unlock(&ftrace_max_lock);
        local_irq_enable();
 
        cpumask_copy(tracing_cpumask, tracing_cpumask_new);
@@ -2316,67 +2331,49 @@ static const struct file_operations tracing_cpumask_fops = {
        .write          = tracing_cpumask_write,
 };
 
-static ssize_t
-tracing_trace_options_read(struct file *filp, char __user *ubuf,
-                      size_t cnt, loff_t *ppos)
+static int tracing_trace_options_show(struct seq_file *m, void *v)
 {
        struct tracer_opt *trace_opts;
        u32 tracer_flags;
-       int len = 0;
-       char *buf;
-       int r = 0;
        int i;
 
-
-       /* calculate max size */
-       for (i = 0; trace_options[i]; i++) {
-               len += strlen(trace_options[i]);
-               len += 3; /* "no" and newline */
-       }
-
        mutex_lock(&trace_types_lock);
        tracer_flags = current_trace->flags->val;
        trace_opts = current_trace->flags->opts;
 
-       /*
-        * Increase the size with names of options specific
-        * of the current tracer.
-        */
-       for (i = 0; trace_opts[i].name; i++) {
-               len += strlen(trace_opts[i].name);
-               len += 3; /* "no" and newline */
-       }
-
-       /* +1 for \0 */
-       buf = kmalloc(len + 1, GFP_KERNEL);
-       if (!buf) {
-               mutex_unlock(&trace_types_lock);
-               return -ENOMEM;
-       }
-
        for (i = 0; trace_options[i]; i++) {
                if (trace_flags & (1 << i))
-                       r += sprintf(buf + r, "%s\n", trace_options[i]);
+                       seq_printf(m, "%s\n", trace_options[i]);
                else
-                       r += sprintf(buf + r, "no%s\n", trace_options[i]);
+                       seq_printf(m, "no%s\n", trace_options[i]);
        }
 
        for (i = 0; trace_opts[i].name; i++) {
                if (tracer_flags & trace_opts[i].bit)
-                       r += sprintf(buf + r, "%s\n",
-                               trace_opts[i].name);
+                       seq_printf(m, "%s\n", trace_opts[i].name);
                else
-                       r += sprintf(buf + r, "no%s\n",
-                               trace_opts[i].name);
+                       seq_printf(m, "no%s\n", trace_opts[i].name);
        }
        mutex_unlock(&trace_types_lock);
 
-       WARN_ON(r >= len + 1);
+       return 0;
+}
 
-       r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
+static int __set_tracer_option(struct tracer *trace,
+                              struct tracer_flags *tracer_flags,
+                              struct tracer_opt *opts, int neg)
+{
+       int ret;
 
-       kfree(buf);
-       return r;
+       ret = trace->set_flag(tracer_flags->val, opts->bit, !neg);
+       if (ret)
+               return ret;
+
+       if (neg)
+               tracer_flags->val &= ~opts->bit;
+       else
+               tracer_flags->val |= opts->bit;
+       return 0;
 }
 
 /* Try to assign a tracer specific option */
@@ -2384,33 +2381,17 @@ static int set_tracer_option(struct tracer *trace, char *cmp, int neg)
 {
        struct tracer_flags *tracer_flags = trace->flags;
        struct tracer_opt *opts = NULL;
-       int ret = 0, i = 0;
-       int len;
+       int i;
 
        for (i = 0; tracer_flags->opts[i].name; i++) {
                opts = &tracer_flags->opts[i];
-               len = strlen(opts->name);
 
-               if (strncmp(cmp, opts->name, len) == 0) {
-                       ret = trace->set_flag(tracer_flags->val,
-                               opts->bit, !neg);
-                       break;
-               }
+               if (strcmp(cmp, opts->name) == 0)
+                       return __set_tracer_option(trace, trace->flags,
+                                                  opts, neg);
        }
-       /* Not found */
-       if (!tracer_flags->opts[i].name)
-               return -EINVAL;
-
-       /* Refused to handle */
-       if (ret)
-               return ret;
-
-       if (neg)
-               tracer_flags->val &= ~opts->bit;
-       else
-               tracer_flags->val |= opts->bit;
 
-       return 0;
+       return -EINVAL;
 }
 
 static void set_tracer_flags(unsigned int mask, int enabled)
@@ -2430,7 +2411,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
                        size_t cnt, loff_t *ppos)
 {
        char buf[64];
-       char *cmp = buf;
+       char *cmp;
        int neg = 0;
        int ret;
        int i;
@@ -2442,16 +2423,15 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
                return -EFAULT;
 
        buf[cnt] = 0;
+       cmp = strstrip(buf);
 
-       if (strncmp(buf, "no", 2) == 0) {
+       if (strncmp(cmp, "no", 2) == 0) {
                neg = 1;
                cmp += 2;
        }
 
        for (i = 0; trace_options[i]; i++) {
-               int len = strlen(trace_options[i]);
-
-               if (strncmp(cmp, trace_options[i], len) == 0) {
+               if (strcmp(cmp, trace_options[i]) == 0) {
                        set_tracer_flags(1 << i, !neg);
                        break;
                }
@@ -2471,9 +2451,18 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
        return cnt;
 }
 
+static int tracing_trace_options_open(struct inode *inode, struct file *file)
+{
+       if (tracing_disabled)
+               return -ENODEV;
+       return single_open(file, tracing_trace_options_show, NULL);
+}
+
 static const struct file_operations tracing_iter_fops = {
-       .open           = tracing_open_generic,
-       .read           = tracing_trace_options_read,
+       .open           = tracing_trace_options_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
        .write          = tracing_trace_options_write,
 };
 
@@ -3133,7 +3122,7 @@ static void tracing_spd_release_pipe(struct splice_pipe_desc *spd,
        __free_page(spd->pages[idx]);
 }
 
-static struct pipe_buf_operations tracing_pipe_buf_ops = {
+static const struct pipe_buf_operations tracing_pipe_buf_ops = {
        .can_merge              = 0,
        .map                    = generic_pipe_buf_map,
        .unmap                  = generic_pipe_buf_unmap,
@@ -3392,21 +3381,18 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
        return cnt;
 }
 
-static ssize_t tracing_clock_read(struct file *filp, char __user *ubuf,
-                                 size_t cnt, loff_t *ppos)
+static int tracing_clock_show(struct seq_file *m, void *v)
 {
-       char buf[64];
-       int bufiter = 0;
        int i;
 
        for (i = 0; i < ARRAY_SIZE(trace_clocks); i++)
-               bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter,
+               seq_printf(m,
                        "%s%s%s%s", i ? " " : "",
                        i == trace_clock_id ? "[" : "", trace_clocks[i].name,
                        i == trace_clock_id ? "]" : "");
-       bufiter += snprintf(buf + bufiter, sizeof(buf) - bufiter, "\n");
+       seq_putc(m, '\n');
 
-       return simple_read_from_buffer(ubuf, cnt, ppos, buf, bufiter);
+       return 0;
 }
 
 static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
@@ -3448,6 +3434,13 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
        return cnt;
 }
 
+static int tracing_clock_open(struct inode *inode, struct file *file)
+{
+       if (tracing_disabled)
+               return -ENODEV;
+       return single_open(file, tracing_clock_show, NULL);
+}
+
 static const struct file_operations tracing_max_lat_fops = {
        .open           = tracing_open_generic,
        .read           = tracing_max_lat_read,
@@ -3486,8 +3479,10 @@ static const struct file_operations tracing_mark_fops = {
 };
 
 static const struct file_operations trace_clock_fops = {
-       .open           = tracing_open_generic,
-       .read           = tracing_clock_read,
+       .open           = tracing_clock_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
        .write          = tracing_clock_write,
 };
 
@@ -3617,7 +3612,7 @@ static void buffer_pipe_buf_get(struct pipe_inode_info *pipe,
 }
 
 /* Pipe buffer operations for a buffer. */
-static struct pipe_buf_operations buffer_pipe_buf_ops = {
+static const struct pipe_buf_operations buffer_pipe_buf_ops = {
        .can_merge              = 0,
        .map                    = generic_pipe_buf_map,
        .unmap                  = generic_pipe_buf_unmap,
@@ -3948,39 +3943,16 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt,
        if (ret < 0)
                return ret;
 
-       ret = 0;
-       switch (val) {
-       case 0:
-               /* do nothing if already cleared */
-               if (!(topt->flags->val & topt->opt->bit))
-                       break;
-
-               mutex_lock(&trace_types_lock);
-               if (current_trace->set_flag)
-                       ret = current_trace->set_flag(topt->flags->val,
-                                                     topt->opt->bit, 0);
-               mutex_unlock(&trace_types_lock);
-               if (ret)
-                       return ret;
-               topt->flags->val &= ~topt->opt->bit;
-               break;
-       case 1:
-               /* do nothing if already set */
-               if (topt->flags->val & topt->opt->bit)
-                       break;
+       if (val != 0 && val != 1)
+               return -EINVAL;
 
+       if (!!(topt->flags->val & topt->opt->bit) != val) {
                mutex_lock(&trace_types_lock);
-               if (current_trace->set_flag)
-                       ret = current_trace->set_flag(topt->flags->val,
-                                                     topt->opt->bit, 1);
+               ret = __set_tracer_option(current_trace, topt->flags,
+                                         topt->opt, val);
                mutex_unlock(&trace_types_lock);
                if (ret)
                        return ret;
-               topt->flags->val |= topt->opt->bit;
-               break;
-
-       default:
-               return -EINVAL;
        }
 
        *ppos += cnt;
@@ -4307,8 +4279,8 @@ trace_printk_seq(struct trace_seq *s)
 
 static void __ftrace_dump(bool disable_tracing)
 {
-       static raw_spinlock_t ftrace_dump_lock =
-               (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+       static arch_spinlock_t ftrace_dump_lock =
+               (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
        /* use static because iter can be a bit big for the stack */
        static struct trace_iterator iter;
        unsigned int old_userobj;
@@ -4318,7 +4290,7 @@ static void __ftrace_dump(bool disable_tracing)
 
        /* only one dump */
        local_irq_save(flags);
-       __raw_spin_lock(&ftrace_dump_lock);
+       arch_spin_lock(&ftrace_dump_lock);
        if (dump_ran)
                goto out;
 
@@ -4393,7 +4365,7 @@ static void __ftrace_dump(bool disable_tracing)
        }
 
  out:
-       __raw_spin_unlock(&ftrace_dump_lock);
+       arch_spin_unlock(&ftrace_dump_lock);
        local_irq_restore(flags);
 }
 
index a52bed2eedd848ec5e7c249d479baa8d14a98ad6..4df6a77eb1966bd4ea12779121f12e96ddf1d3f6 100644 (file)
@@ -597,18 +597,17 @@ enum trace_iterator_flags {
        TRACE_ITER_BIN                  = 0x40,
        TRACE_ITER_BLOCK                = 0x80,
        TRACE_ITER_STACKTRACE           = 0x100,
-       TRACE_ITER_SCHED_TREE           = 0x200,
-       TRACE_ITER_PRINTK               = 0x400,
-       TRACE_ITER_PREEMPTONLY          = 0x800,
-       TRACE_ITER_BRANCH               = 0x1000,
-       TRACE_ITER_ANNOTATE             = 0x2000,
-       TRACE_ITER_USERSTACKTRACE       = 0x4000,
-       TRACE_ITER_SYM_USEROBJ          = 0x8000,
-       TRACE_ITER_PRINTK_MSGONLY       = 0x10000,
-       TRACE_ITER_CONTEXT_INFO         = 0x20000, /* Print pid/cpu/time */
-       TRACE_ITER_LATENCY_FMT          = 0x40000,
-       TRACE_ITER_SLEEP_TIME           = 0x80000,
-       TRACE_ITER_GRAPH_TIME           = 0x100000,
+       TRACE_ITER_PRINTK               = 0x200,
+       TRACE_ITER_PREEMPTONLY          = 0x400,
+       TRACE_ITER_BRANCH               = 0x800,
+       TRACE_ITER_ANNOTATE             = 0x1000,
+       TRACE_ITER_USERSTACKTRACE       = 0x2000,
+       TRACE_ITER_SYM_USEROBJ          = 0x4000,
+       TRACE_ITER_PRINTK_MSGONLY       = 0x8000,
+       TRACE_ITER_CONTEXT_INFO         = 0x10000, /* Print pid/cpu/time */
+       TRACE_ITER_LATENCY_FMT          = 0x20000,
+       TRACE_ITER_SLEEP_TIME           = 0x40000,
+       TRACE_ITER_GRAPH_TIME           = 0x80000,
 };
 
 /*
index 878c03f386baef4b998cd9e0f6a7db2d02e6d692..84a3a7ba072ac92507f98d1011c5f15a85b96703 100644 (file)
@@ -71,10 +71,10 @@ u64 notrace trace_clock(void)
 /* keep prev_time and lock in the same cacheline. */
 static struct {
        u64 prev_time;
-       raw_spinlock_t lock;
+       arch_spinlock_t lock;
 } trace_clock_struct ____cacheline_aligned_in_smp =
        {
-               .lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED,
+               .lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED,
        };
 
 u64 notrace trace_clock_global(void)
@@ -94,7 +94,7 @@ u64 notrace trace_clock_global(void)
        if (unlikely(in_nmi()))
                goto out;
 
-       __raw_spin_lock(&trace_clock_struct.lock);
+       arch_spin_lock(&trace_clock_struct.lock);
 
        /*
         * TODO: if this happens often then maybe we should reset
@@ -106,7 +106,7 @@ u64 notrace trace_clock_global(void)
 
        trace_clock_struct.prev_time = now;
 
-       __raw_spin_unlock(&trace_clock_struct.lock);
+       arch_spin_unlock(&trace_clock_struct.lock);
 
  out:
        raw_local_irq_restore(flags);
index d9c60f80aa0d20958c647a86310b29701b4bcdcc..9e25573242cff54733fee9a49a820b1bf5f29d52 100644 (file)
@@ -25,7 +25,7 @@ static int ftrace_profile_enable_event(struct ftrace_event_call *event)
        char *buf;
        int ret = -ENOMEM;
 
-       if (atomic_inc_return(&event->profile_count))
+       if (event->profile_count++ > 0)
                return 0;
 
        if (!total_profile_count) {
@@ -56,7 +56,7 @@ fail_buf_nmi:
                perf_trace_buf = NULL;
        }
 fail_buf:
-       atomic_dec(&event->profile_count);
+       event->profile_count--;
 
        return ret;
 }
@@ -83,7 +83,7 @@ static void ftrace_profile_disable_event(struct ftrace_event_call *event)
 {
        char *buf, *nmi_buf;
 
-       if (!atomic_add_negative(-1, &event->profile_count))
+       if (--event->profile_count > 0)
                return;
 
        event->profile_disable(event);
index 1d18315dc836e6e15d50cc8d17b4eacec56fd6ba..189b09baf4fbfd1bb6a2340897c477d83d6de800 100644 (file)
@@ -78,7 +78,7 @@ EXPORT_SYMBOL_GPL(trace_define_field);
        if (ret)                                                        \
                return ret;
 
-int trace_define_common_fields(struct ftrace_event_call *call)
+static int trace_define_common_fields(struct ftrace_event_call *call)
 {
        int ret;
        struct trace_entry ent;
@@ -91,7 +91,6 @@ int trace_define_common_fields(struct ftrace_event_call *call)
 
        return ret;
 }
-EXPORT_SYMBOL_GPL(trace_define_common_fields);
 
 void trace_destroy_fields(struct ftrace_event_call *call)
 {
@@ -105,9 +104,25 @@ void trace_destroy_fields(struct ftrace_event_call *call)
        }
 }
 
-static void ftrace_event_enable_disable(struct ftrace_event_call *call,
+int trace_event_raw_init(struct ftrace_event_call *call)
+{
+       int id;
+
+       id = register_ftrace_event(call->event);
+       if (!id)
+               return -ENODEV;
+       call->id = id;
+       INIT_LIST_HEAD(&call->fields);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(trace_event_raw_init);
+
+static int ftrace_event_enable_disable(struct ftrace_event_call *call,
                                        int enable)
 {
+       int ret = 0;
+
        switch (enable) {
        case 0:
                if (call->enabled) {
@@ -118,12 +133,20 @@ static void ftrace_event_enable_disable(struct ftrace_event_call *call,
                break;
        case 1:
                if (!call->enabled) {
-                       call->enabled = 1;
                        tracing_start_cmdline_record();
-                       call->regfunc(call);
+                       ret = call->regfunc(call);
+                       if (ret) {
+                               tracing_stop_cmdline_record();
+                               pr_info("event trace: Could not enable event "
+                                       "%s\n", call->name);
+                               break;
+                       }
+                       call->enabled = 1;
                }
                break;
        }
+
+       return ret;
 }
 
 static void ftrace_clear_events(void)
@@ -402,7 +425,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
        case 0:
        case 1:
                mutex_lock(&event_mutex);
-               ftrace_event_enable_disable(call, val);
+               ret = ftrace_event_enable_disable(call, val);
                mutex_unlock(&event_mutex);
                break;
 
@@ -412,7 +435,7 @@ event_enable_write(struct file *filp, const char __user *ubuf, size_t cnt,
 
        *ppos += cnt;
 
-       return cnt;
+       return ret ? ret : cnt;
 }
 
 static ssize_t
@@ -913,7 +936,9 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
                                  id);
 
        if (call->define_fields) {
-               ret = call->define_fields(call);
+               ret = trace_define_common_fields(call);
+               if (!ret)
+                       ret = call->define_fields(call);
                if (ret < 0) {
                        pr_warning("Could not initialize trace point"
                                   " events/%s\n", call->name);
index dff8c84ddf17589543ca90e71af630cf7b0755b7..458e5bfe26d0f700a9a913b204d53d761ae69b7f 100644 (file)
@@ -184,10 +184,6 @@ ftrace_define_fields_##name(struct ftrace_event_call *event_call)  \
        struct struct_name field;                                       \
        int ret;                                                        \
                                                                        \
-       ret = trace_define_common_fields(event_call);                   \
-       if (ret)                                                        \
-               return ret;                                             \
-                                                                       \
        tstruct;                                                        \
                                                                        \
        return ret;                                                     \
index 3aa7eaa2114ce2abc5ae411725c7cfaa71fb137a..2974bc7538c74603b15f85b75a62f74e70f7bb4d 100644 (file)
@@ -151,6 +151,8 @@ check_critical_timing(struct trace_array *tr,
                goto out_unlock;
 
        trace_function(tr, CALLER_ADDR0, parent_ip, flags, pc);
+       /* Skip 5 functions to get to the irq/preempt enable function */
+       __trace_stack(tr, flags, 5, pc);
 
        if (data->critical_sequence != max_sequence)
                goto out_unlock;
index b52d397e57ebefbdbc40c84e66460847e8041fd5..375f81a568dc267cfc847009418c056cfb24469f 100644 (file)
@@ -282,6 +282,18 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs);
 static int kretprobe_dispatcher(struct kretprobe_instance *ri,
                                struct pt_regs *regs);
 
+/* Check the name is good for event/group */
+static int check_event_name(const char *name)
+{
+       if (!isalpha(*name) && *name != '_')
+               return 0;
+       while (*++name != '\0') {
+               if (!isalpha(*name) && !isdigit(*name) && *name != '_')
+                       return 0;
+       }
+       return 1;
+}
+
 /*
  * Allocate new trace_probe and initialize it (including kprobes).
  */
@@ -293,10 +305,11 @@ static struct trace_probe *alloc_trace_probe(const char *group,
                                             int nargs, int is_return)
 {
        struct trace_probe *tp;
+       int ret = -ENOMEM;
 
        tp = kzalloc(SIZEOF_TRACE_PROBE(nargs), GFP_KERNEL);
        if (!tp)
-               return ERR_PTR(-ENOMEM);
+               return ERR_PTR(ret);
 
        if (symbol) {
                tp->symbol = kstrdup(symbol, GFP_KERNEL);
@@ -312,14 +325,20 @@ static struct trace_probe *alloc_trace_probe(const char *group,
        else
                tp->rp.kp.pre_handler = kprobe_dispatcher;
 
-       if (!event)
+       if (!event || !check_event_name(event)) {
+               ret = -EINVAL;
                goto error;
+       }
+
        tp->call.name = kstrdup(event, GFP_KERNEL);
        if (!tp->call.name)
                goto error;
 
-       if (!group)
+       if (!group || !check_event_name(group)) {
+               ret = -EINVAL;
                goto error;
+       }
+
        tp->call.system = kstrdup(group, GFP_KERNEL);
        if (!tp->call.system)
                goto error;
@@ -330,7 +349,7 @@ error:
        kfree(tp->call.name);
        kfree(tp->symbol);
        kfree(tp);
-       return ERR_PTR(-ENOMEM);
+       return ERR_PTR(ret);
 }
 
 static void free_probe_arg(struct probe_arg *arg)
@@ -695,10 +714,10 @@ static int create_trace_probe(int argc, char **argv)
        if (!event) {
                /* Make a new event name */
                if (symbol)
-                       snprintf(buf, MAX_EVENT_NAME_LEN, "%c@%s%+ld",
+                       snprintf(buf, MAX_EVENT_NAME_LEN, "%c_%s_%ld",
                                 is_return ? 'r' : 'p', symbol, offset);
                else
-                       snprintf(buf, MAX_EVENT_NAME_LEN, "%c@0x%p",
+                       snprintf(buf, MAX_EVENT_NAME_LEN, "%c_0x%p",
                                 is_return ? 'r' : 'p', addr);
                event = buf;
        }
@@ -1132,10 +1151,6 @@ static int kprobe_event_define_fields(struct ftrace_event_call *event_call)
        struct kprobe_trace_entry field;
        struct trace_probe *tp = (struct trace_probe *)event_call->data;
 
-       ret = trace_define_common_fields(event_call);
-       if (ret)
-               return ret;
-
        DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0);
        DEFINE_FIELD(int, nargs, FIELD_STRING_NARGS, 1);
        /* Set argument names as fields */
@@ -1150,10 +1165,6 @@ static int kretprobe_event_define_fields(struct ftrace_event_call *event_call)
        struct kretprobe_trace_entry field;
        struct trace_probe *tp = (struct trace_probe *)event_call->data;
 
-       ret = trace_define_common_fields(event_call);
-       if (ret)
-               return ret;
-
        DEFINE_FIELD(unsigned long, func, FIELD_STRING_FUNC, 0);
        DEFINE_FIELD(unsigned long, ret_ip, FIELD_STRING_RETIP, 0);
        DEFINE_FIELD(int, nargs, FIELD_STRING_NARGS, 1);
@@ -1453,7 +1464,6 @@ static int register_probe_event(struct trace_probe *tp)
        call->unregfunc = probe_event_disable;
 
 #ifdef CONFIG_EVENT_PROFILE
-       atomic_set(&call->profile_count, -1);
        call->profile_enable = probe_profile_enable;
        call->profile_disable = probe_profile_disable;
 #endif
index acb87d4a4ac15e8127fc64138918111a1e948936..faf37fa4408c3b7d87a357a64dfc6532a9545c76 100644 (file)
@@ -236,7 +236,8 @@ static ssize_t ksym_trace_filter_read(struct file *filp, char __user *ubuf,
        mutex_lock(&ksym_tracer_mutex);
 
        hlist_for_each_entry(entry, node, &ksym_filter_head, ksym_hlist) {
-               ret = trace_seq_printf(s, "%pS:", (void *)entry->attr.bp_addr);
+               ret = trace_seq_printf(s, "%pS:",
+                               (void *)(unsigned long)entry->attr.bp_addr);
                if (entry->attr.bp_type == HW_BREAKPOINT_R)
                        ret = trace_seq_puts(s, "r--\n");
                else if (entry->attr.bp_type == HW_BREAKPOINT_W)
@@ -278,21 +279,20 @@ static ssize_t ksym_trace_filter_write(struct file *file,
 {
        struct trace_ksym *entry;
        struct hlist_node *node;
-       char *input_string, *ksymname = NULL;
+       char *buf, *input_string, *ksymname = NULL;
        unsigned long ksym_addr = 0;
        int ret, op, changed = 0;
 
-       input_string = kzalloc(count + 1, GFP_KERNEL);
-       if (!input_string)
+       buf = kzalloc(count + 1, GFP_KERNEL);
+       if (!buf)
                return -ENOMEM;
 
-       if (copy_from_user(input_string, buffer, count)) {
-               kfree(input_string);
-               return -EFAULT;
-       }
-       input_string[count] = '\0';
+       ret = -EFAULT;
+       if (copy_from_user(buf, buffer, count))
+               goto out;
 
-       strstrip(input_string);
+       buf[count] = '\0';
+       input_string = strstrip(buf);
 
        /*
         * Clear all breakpoints if:
@@ -300,18 +300,16 @@ static ssize_t ksym_trace_filter_write(struct file *file,
         * 2: echo 0 > ksym_trace_filter
         * 3: echo "*:---" > ksym_trace_filter
         */
-       if (!input_string[0] || !strcmp(input_string, "0") ||
-           !strcmp(input_string, "*:---")) {
+       if (!buf[0] || !strcmp(buf, "0") ||
+           !strcmp(buf, "*:---")) {
                __ksym_trace_reset();
-               kfree(input_string);
-               return count;
+               ret = 0;
+               goto out;
        }
 
        ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr);
-       if (ret < 0) {
-               kfree(input_string);
-               return ret;
-       }
+       if (ret < 0)
+               goto out;
 
        mutex_lock(&ksym_tracer_mutex);
 
@@ -322,7 +320,7 @@ static ssize_t ksym_trace_filter_write(struct file *file,
                        if (entry->attr.bp_type != op)
                                changed = 1;
                        else
-                               goto out;
+                               goto out_unlock;
                        break;
                }
        }
@@ -337,28 +335,24 @@ static ssize_t ksym_trace_filter_write(struct file *file,
                        if (IS_ERR(entry->ksym_hbp))
                                ret = PTR_ERR(entry->ksym_hbp);
                        else
-                               goto out;
+                               goto out_unlock;
                }
                /* Error or "symbol:---" case: drop it */
                ksym_filter_entry_count--;
                hlist_del_rcu(&(entry->ksym_hlist));
                synchronize_rcu();
                kfree(entry);
-               goto out;
+               goto out_unlock;
        } else {
                /* Check for malformed request: (4) */
-               if (op == 0)
-                       goto out;
-               ret = process_new_ksym_entry(ksymname, op, ksym_addr);
+               if (op)
+                       ret = process_new_ksym_entry(ksymname, op, ksym_addr);
        }
-out:
+out_unlock:
        mutex_unlock(&ksym_tracer_mutex);
-
-       kfree(input_string);
-
-       if (!ret)
-               ret = count;
-       return ret;
+out:
+       kfree(buf);
+       return !ret ? count : ret;
 }
 
 static const struct file_operations ksym_tracing_fops = {
index 26185d727676b0620496a9eb5a4832e9c3fdbd01..0271742abb8d1188e34c19905c89a4cc169843e0 100644 (file)
@@ -28,8 +28,8 @@ static int                    wakeup_current_cpu;
 static unsigned                        wakeup_prio = -1;
 static int                     wakeup_rt;
 
-static raw_spinlock_t wakeup_lock =
-       (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+static arch_spinlock_t wakeup_lock =
+       (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
 
 static void __wakeup_reset(struct trace_array *tr);
 
@@ -143,7 +143,7 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,
                goto out;
 
        local_irq_save(flags);
-       __raw_spin_lock(&wakeup_lock);
+       arch_spin_lock(&wakeup_lock);
 
        /* We could race with grabbing wakeup_lock */
        if (unlikely(!tracer_enabled || next != wakeup_task))
@@ -169,7 +169,7 @@ probe_wakeup_sched_switch(struct rq *rq, struct task_struct *prev,
 
 out_unlock:
        __wakeup_reset(wakeup_trace);
-       __raw_spin_unlock(&wakeup_lock);
+       arch_spin_unlock(&wakeup_lock);
        local_irq_restore(flags);
 out:
        atomic_dec(&wakeup_trace->data[cpu]->disabled);
@@ -193,9 +193,9 @@ static void wakeup_reset(struct trace_array *tr)
        tracing_reset_online_cpus(tr);
 
        local_irq_save(flags);
-       __raw_spin_lock(&wakeup_lock);
+       arch_spin_lock(&wakeup_lock);
        __wakeup_reset(tr);
-       __raw_spin_unlock(&wakeup_lock);
+       arch_spin_unlock(&wakeup_lock);
        local_irq_restore(flags);
 }
 
@@ -225,7 +225,7 @@ probe_wakeup(struct rq *rq, struct task_struct *p, int success)
                goto out;
 
        /* interrupts should be off from try_to_wake_up */
-       __raw_spin_lock(&wakeup_lock);
+       arch_spin_lock(&wakeup_lock);
 
        /* check for races. */
        if (!tracer_enabled || p->prio >= wakeup_prio)
@@ -255,7 +255,7 @@ probe_wakeup(struct rq *rq, struct task_struct *p, int success)
        trace_function(wakeup_trace, CALLER_ADDR1, CALLER_ADDR2, flags, pc);
 
 out_locked:
-       __raw_spin_unlock(&wakeup_lock);
+       arch_spin_unlock(&wakeup_lock);
 out:
        atomic_dec(&wakeup_trace->data[cpu]->disabled);
 }
index dc98309e839a7ca63ff20b05786e87d51e350c92..280fea470d67ea603f230d8bfc7868d5d48e62b2 100644 (file)
@@ -67,7 +67,7 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
 
        /* Don't allow flipping of max traces now */
        local_irq_save(flags);
-       __raw_spin_lock(&ftrace_max_lock);
+       arch_spin_lock(&ftrace_max_lock);
 
        cnt = ring_buffer_entries(tr->buffer);
 
@@ -85,7 +85,7 @@ static int trace_test_buffer(struct trace_array *tr, unsigned long *count)
                        break;
        }
        tracing_on();
-       __raw_spin_unlock(&ftrace_max_lock);
+       arch_spin_unlock(&ftrace_max_lock);
        local_irq_restore(flags);
 
        if (count)
index 8504ac71e4e8f9831edd7cc0d3186f98fdcad6c1..678a5120ee301bf1d22d051f710c03ccff60f236 100644 (file)
@@ -27,8 +27,8 @@ static struct stack_trace max_stack_trace = {
 };
 
 static unsigned long max_stack_size;
-static raw_spinlock_t max_stack_lock =
-       (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+static arch_spinlock_t max_stack_lock =
+       (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
 
 static int stack_trace_disabled __read_mostly;
 static DEFINE_PER_CPU(int, trace_active);
@@ -54,7 +54,7 @@ static inline void check_stack(void)
                return;
 
        local_irq_save(flags);
-       __raw_spin_lock(&max_stack_lock);
+       arch_spin_lock(&max_stack_lock);
 
        /* a race could have already updated it */
        if (this_size <= max_stack_size)
@@ -103,7 +103,7 @@ static inline void check_stack(void)
        }
 
  out:
-       __raw_spin_unlock(&max_stack_lock);
+       arch_spin_unlock(&max_stack_lock);
        local_irq_restore(flags);
 }
 
@@ -171,9 +171,9 @@ stack_max_size_write(struct file *filp, const char __user *ubuf,
                return ret;
 
        local_irq_save(flags);
-       __raw_spin_lock(&max_stack_lock);
+       arch_spin_lock(&max_stack_lock);
        *ptr = val;
-       __raw_spin_unlock(&max_stack_lock);
+       arch_spin_unlock(&max_stack_lock);
        local_irq_restore(flags);
 
        return count;
@@ -207,7 +207,7 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
 static void *t_start(struct seq_file *m, loff_t *pos)
 {
        local_irq_disable();
-       __raw_spin_lock(&max_stack_lock);
+       arch_spin_lock(&max_stack_lock);
 
        if (*pos == 0)
                return SEQ_START_TOKEN;
@@ -217,7 +217,7 @@ static void *t_start(struct seq_file *m, loff_t *pos)
 
 static void t_stop(struct seq_file *m, void *p)
 {
-       __raw_spin_unlock(&max_stack_lock);
+       arch_spin_unlock(&max_stack_lock);
        local_irq_enable();
 }
 
index 57501d90096abbba5ee3a87de54476a794ba176e..75289f372dd270816742e7dd94c1d5c2474442d8 100644 (file)
@@ -217,10 +217,6 @@ int syscall_enter_define_fields(struct ftrace_event_call *call)
        int i;
        int offset = offsetof(typeof(trace), args);
 
-       ret = trace_define_common_fields(call);
-       if (ret)
-               return ret;
-
        ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER);
        if (ret)
                return ret;
@@ -241,10 +237,6 @@ int syscall_exit_define_fields(struct ftrace_event_call *call)
        struct syscall_trace_exit trace;
        int ret;
 
-       ret = trace_define_common_fields(call);
-       if (ret)
-               return ret;
-
        ret = trace_define_field(call, SYSCALL_FIELD(int, nr), FILTER_OTHER);
        if (ret)
                return ret;
@@ -333,10 +325,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
        mutex_lock(&syscall_trace_lock);
        if (!sys_refcount_enter)
                ret = register_trace_sys_enter(ftrace_syscall_enter);
-       if (ret) {
-               pr_info("event trace: Could not activate"
-                               "syscall entry trace point");
-       } else {
+       if (!ret) {
                set_bit(num, enabled_enter_syscalls);
                sys_refcount_enter++;
        }
@@ -370,10 +359,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
        mutex_lock(&syscall_trace_lock);
        if (!sys_refcount_exit)
                ret = register_trace_sys_exit(ftrace_syscall_exit);
-       if (ret) {
-               pr_info("event trace: Could not activate"
-                               "syscall exit trace point");
-       } else {
+       if (!ret) {
                set_bit(num, enabled_exit_syscalls);
                sys_refcount_exit++;
        }
index f6693969287d83e716733f0d21c6356f70ec8ff5..a7974a552ca90689f3ff358f96b6eb2622c5748c 100644 (file)
@@ -93,6 +93,7 @@ static const struct stacktrace_ops backtrace_ops = {
        .warning_symbol         = backtrace_warning_symbol,
        .stack                  = backtrace_stack,
        .address                = backtrace_address,
+       .walk_stack             = print_context_stack,
 };
 
 static int
index 2f22cf4576dbe719754d329adf18e041c19e2f19..25c3ed594c547966c1c291750d8adeb3b9e5674b 100644 (file)
@@ -360,6 +360,7 @@ config DEBUG_KMEMLEAK
        select DEBUG_FS if SYSFS
        select STACKTRACE if STACKTRACE_SUPPORT
        select KALLSYMS
+       select CRC32
        help
          Say Y here if you want to enable the memory leak
          detector. The memory allocation/freeing is traced in a way
@@ -575,7 +576,7 @@ config DEBUG_BUGVERBOSE
        depends on BUG
        depends on ARM || AVR32 || M32R || M68K || SPARC32 || SPARC64 || \
                   FRV || SUPERH || GENERIC_BUG || BLACKFIN || MN10300
-       default !EMBEDDED
+       default y
        help
          Say Y here to make BUG() panics output the file name and line number
          of the BUG call as well as the EIP and oops trace.  This aids
index 5205a8dae5bc08c51a4f0f283dd812e2fab25a04..4b1b083f219cd68fd0424ff6e4c6c84f6d685d25 100644 (file)
@@ -4,17 +4,10 @@
 
 #include <linux/kernel.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 
-static const char *skip_sep(const char *cp)
-{
-       while (*cp && isspace(*cp))
-               cp++;
-
-       return cp;
-}
-
 static const char *skip_arg(const char *cp)
 {
        while (*cp && !isspace(*cp))
@@ -28,7 +21,7 @@ static int count_argc(const char *str)
        int count = 0;
 
        while (*str) {
-               str = skip_sep(str);
+               str = skip_spaces(str);
                if (*str) {
                        count++;
                        str = skip_arg(str);
@@ -82,7 +75,7 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp)
        argvp = argv;
 
        while (*str) {
-               str = skip_sep(str);
+               str = skip_spaces(str);
 
                if (*str) {
                        const char *p = str;
index 702565821c9976fb4588dac793d84008bf93b229..11bf49750583af6087e5a65674a4c74247071ea5 100644 (file)
@@ -271,6 +271,87 @@ int __bitmap_weight(const unsigned long *bitmap, int bits)
 }
 EXPORT_SYMBOL(__bitmap_weight);
 
+#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
+
+void bitmap_set(unsigned long *map, int start, int nr)
+{
+       unsigned long *p = map + BIT_WORD(start);
+       const int size = start + nr;
+       int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
+       unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
+
+       while (nr - bits_to_set >= 0) {
+               *p |= mask_to_set;
+               nr -= bits_to_set;
+               bits_to_set = BITS_PER_LONG;
+               mask_to_set = ~0UL;
+               p++;
+       }
+       if (nr) {
+               mask_to_set &= BITMAP_LAST_WORD_MASK(size);
+               *p |= mask_to_set;
+       }
+}
+EXPORT_SYMBOL(bitmap_set);
+
+void bitmap_clear(unsigned long *map, int start, int nr)
+{
+       unsigned long *p = map + BIT_WORD(start);
+       const int size = start + nr;
+       int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
+       unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
+
+       while (nr - bits_to_clear >= 0) {
+               *p &= ~mask_to_clear;
+               nr -= bits_to_clear;
+               bits_to_clear = BITS_PER_LONG;
+               mask_to_clear = ~0UL;
+               p++;
+       }
+       if (nr) {
+               mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
+               *p &= ~mask_to_clear;
+       }
+}
+EXPORT_SYMBOL(bitmap_clear);
+
+/*
+ * bitmap_find_next_zero_area - find a contiguous aligned zero area
+ * @map: The address to base the search on
+ * @size: The bitmap size in bits
+ * @start: The bitnumber to start searching at
+ * @nr: The number of zeroed bits we're looking for
+ * @align_mask: Alignment mask for zero area
+ *
+ * The @align_mask should be one less than a power of 2; the effect is that
+ * the bit offset of all zero areas this function finds is multiples of that
+ * power of 2. A @align_mask of 0 means no alignment is required.
+ */
+unsigned long bitmap_find_next_zero_area(unsigned long *map,
+                                        unsigned long size,
+                                        unsigned long start,
+                                        unsigned int nr,
+                                        unsigned long align_mask)
+{
+       unsigned long index, end, i;
+again:
+       index = find_next_zero_bit(map, size, start);
+
+       /* Align allocation */
+       index = __ALIGN_MASK(index, align_mask);
+
+       end = index + nr;
+       if (end > size)
+               return end;
+       i = find_next_bit(map, end, index);
+       if (i < end) {
+               start = i + 1;
+               goto again;
+       }
+       return index;
+}
+EXPORT_SYMBOL(bitmap_find_next_zero_area);
+
 /*
  * Bitmap printing & parsing functions: first version by Bill Irwin,
  * second version by Paul Jackson, third by Joe Korty.
index 49d1c9e3ce3820ccb8dd3d01cec5e11ac39cd7cc..02e3b31b3a79003514138cf5c6a1cad19e3d3cf9 100644 (file)
@@ -42,6 +42,48 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch@dell.com>");
 MODULE_DESCRIPTION("Ethernet CRC32 calculations");
 MODULE_LICENSE("GPL");
 
+#if CRC_LE_BITS == 8 || CRC_BE_BITS == 8
+
+static inline u32
+crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 *tab)
+{
+# ifdef __LITTLE_ENDIAN
+#  define DO_CRC(x) crc = tab[(crc ^ (x)) & 255 ] ^ (crc >> 8)
+# else
+#  define DO_CRC(x) crc = tab[((crc >> 24) ^ (x)) & 255] ^ (crc << 8)
+# endif
+       const u32 *b = (const u32 *)buf;
+       size_t    rem_len;
+
+       /* Align it */
+       if (unlikely((long)b & 3 && len)) {
+               u8 *p = (u8 *)b;
+               do {
+                       DO_CRC(*p++);
+               } while ((--len) && ((long)p)&3);
+               b = (u32 *)p;
+       }
+       rem_len = len & 3;
+       /* load data 32 bits wide, xor data 32 bits wide. */
+       len = len >> 2;
+       for (--b; len; --len) {
+               crc ^= *++b; /* use pre increment for speed */
+               DO_CRC(0);
+               DO_CRC(0);
+               DO_CRC(0);
+               DO_CRC(0);
+       }
+       len = rem_len;
+       /* And the last few bytes */
+       if (len) {
+               u8 *p = (u8 *)(b + 1) - 1;
+               do {
+                       DO_CRC(*++p); /* use pre increment for speed */
+               } while (--len);
+       }
+       return crc;
+}
+#endif
 /**
  * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
  * @crc: seed value for computation.  ~0 for Ethernet, sometimes 0 for
@@ -72,48 +114,10 @@ u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len)
 u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len)
 {
 # if CRC_LE_BITS == 8
-       const u32      *b =(u32 *)p;
        const u32      *tab = crc32table_le;
 
-# ifdef __LITTLE_ENDIAN
-#  define DO_CRC(x) crc = tab[ (crc ^ (x)) & 255 ] ^ (crc>>8)
-# else
-#  define DO_CRC(x) crc = tab[ ((crc >> 24) ^ (x)) & 255] ^ (crc<<8)
-# endif
-
        crc = __cpu_to_le32(crc);
-       /* Align it */
-       if(unlikely(((long)b)&3 && len)){
-               do {
-                       u8 *p = (u8 *)b;
-                       DO_CRC(*p++);
-                       b = (void *)p;
-               } while ((--len) && ((long)b)&3 );
-       }
-       if(likely(len >= 4)){
-               /* load data 32 bits wide, xor data 32 bits wide. */
-               size_t save_len = len & 3;
-               len = len >> 2;
-               --b; /* use pre increment below(*++b) for speed */
-               do {
-                       crc ^= *++b;
-                       DO_CRC(0);
-                       DO_CRC(0);
-                       DO_CRC(0);
-                       DO_CRC(0);
-               } while (--len);
-               b++; /* point to next byte(s) */
-               len = save_len;
-       }
-       /* And the last few bytes */
-       if(len){
-               do {
-                       u8 *p = (u8 *)b;
-                       DO_CRC(*p++);
-                       b = (void *)p;
-               } while (--len);
-       }
-
+       crc = crc32_body(crc, p, len, tab);
        return __le32_to_cpu(crc);
 #undef ENDIAN_SHIFT
 #undef DO_CRC
@@ -170,47 +174,10 @@ u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len)
 u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len)
 {
 # if CRC_BE_BITS == 8
-       const u32      *b =(u32 *)p;
        const u32      *tab = crc32table_be;
 
-# ifdef __LITTLE_ENDIAN
-#  define DO_CRC(x) crc = tab[ (crc ^ (x)) & 255 ] ^ (crc>>8)
-# else
-#  define DO_CRC(x) crc = tab[ ((crc >> 24) ^ (x)) & 255] ^ (crc<<8)
-# endif
-
        crc = __cpu_to_be32(crc);
-       /* Align it */
-       if(unlikely(((long)b)&3 && len)){
-               do {
-                       u8 *p = (u8 *)b;
-                       DO_CRC(*p++);
-                       b = (u32 *)p;
-               } while ((--len) && ((long)b)&3 );
-       }
-       if(likely(len >= 4)){
-               /* load data 32 bits wide, xor data 32 bits wide. */
-               size_t save_len = len & 3;
-               len = len >> 2;
-               --b; /* use pre increment below(*++b) for speed */
-               do {
-                       crc ^= *++b;
-                       DO_CRC(0);
-                       DO_CRC(0);
-                       DO_CRC(0);
-                       DO_CRC(0);
-               } while (--len);
-               b++; /* point to next byte(s) */
-               len = save_len;
-       }
-       /* And the last few bytes */
-       if(len){
-               do {
-                       u8 *p = (u8 *)b;
-                       DO_CRC(*p++);
-                       b = (void *)p;
-               } while (--len);
-       }
+       crc = crc32_body(crc, p, len, tab);
        return __be32_to_cpu(crc);
 #undef ENDIAN_SHIFT
 #undef DO_CRC
index d02ace14a322e5f85788238865ee70a6b1443e97..26baa620e95b5c57cdd127cb83f2db3f9449f8a2 100644 (file)
@@ -7,30 +7,30 @@
 #include <linux/ctype.h>
 #include <linux/module.h>
 
-unsigned char _ctype[] = {
-_C,_C,_C,_C,_C,_C,_C,_C,                       /* 0-7 */
-_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C,                /* 8-15 */
-_C,_C,_C,_C,_C,_C,_C,_C,                       /* 16-23 */
-_C,_C,_C,_C,_C,_C,_C,_C,                       /* 24-31 */
-_S|_SP,_P,_P,_P,_P,_P,_P,_P,                   /* 32-39 */
-_P,_P,_P,_P,_P,_P,_P,_P,                       /* 40-47 */
-_D,_D,_D,_D,_D,_D,_D,_D,                       /* 48-55 */
-_D,_D,_P,_P,_P,_P,_P,_P,                       /* 56-63 */
-_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U,     /* 64-71 */
-_U,_U,_U,_U,_U,_U,_U,_U,                       /* 72-79 */
-_U,_U,_U,_U,_U,_U,_U,_U,                       /* 80-87 */
-_U,_U,_U,_P,_P,_P,_P,_P,                       /* 88-95 */
-_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L,     /* 96-103 */
-_L,_L,_L,_L,_L,_L,_L,_L,                       /* 104-111 */
-_L,_L,_L,_L,_L,_L,_L,_L,                       /* 112-119 */
-_L,_L,_L,_P,_P,_P,_P,_C,                       /* 120-127 */
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,               /* 128-143 */
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,               /* 144-159 */
-_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,   /* 160-175 */
-_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,       /* 176-191 */
-_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
-_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
-_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
-_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
+const unsigned char _ctype[] = {
+_C,_C,_C,_C,_C,_C,_C,_C,                               /* 0-7 */
+_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C,                        /* 8-15 */
+_C,_C,_C,_C,_C,_C,_C,_C,                               /* 16-23 */
+_C,_C,_C,_C,_C,_C,_C,_C,                               /* 24-31 */
+_S|_SP,_P,_P,_P,_P,_P,_P,_P,                           /* 32-39 */
+_P,_P,_P,_P,_P,_P,_P,_P,                               /* 40-47 */
+_D,_D,_D,_D,_D,_D,_D,_D,                               /* 48-55 */
+_D,_D,_P,_P,_P,_P,_P,_P,                               /* 56-63 */
+_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U,             /* 64-71 */
+_U,_U,_U,_U,_U,_U,_U,_U,                               /* 72-79 */
+_U,_U,_U,_U,_U,_U,_U,_U,                               /* 80-87 */
+_U,_U,_U,_P,_P,_P,_P,_P,                               /* 88-95 */
+_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L,             /* 96-103 */
+_L,_L,_L,_L,_L,_L,_L,_L,                               /* 104-111 */
+_L,_L,_L,_L,_L,_L,_L,_L,                               /* 112-119 */
+_L,_L,_L,_P,_P,_P,_P,_C,                               /* 120-127 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,                       /* 128-143 */
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,                       /* 144-159 */
+_S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,   /* 160-175 */
+_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,       /* 176-191 */
+_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,       /* 192-207 */
+_U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L,       /* 208-223 */
+_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,       /* 224-239 */
+_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L};      /* 240-255 */
 
 EXPORT_SYMBOL(_ctype);
index eae56fddfa3bd6517653e9387de92c4e56875044..a9a8996d286a8e64f5ac23aec220b7645356cfac 100644 (file)
 
 struct debug_bucket {
        struct hlist_head       list;
-       spinlock_t              lock;
+       raw_spinlock_t          lock;
 };
 
 static struct debug_bucket     obj_hash[ODEBUG_HASH_SIZE];
 
 static struct debug_obj                obj_static_pool[ODEBUG_POOL_SIZE] __initdata;
 
-static DEFINE_SPINLOCK(pool_lock);
+static DEFINE_RAW_SPINLOCK(pool_lock);
 
 static HLIST_HEAD(obj_pool);
 
@@ -96,10 +96,10 @@ static int fill_pool(void)
                if (!new)
                        return obj_pool_free;
 
-               spin_lock_irqsave(&pool_lock, flags);
+               raw_spin_lock_irqsave(&pool_lock, flags);
                hlist_add_head(&new->node, &obj_pool);
                obj_pool_free++;
-               spin_unlock_irqrestore(&pool_lock, flags);
+               raw_spin_unlock_irqrestore(&pool_lock, flags);
        }
        return obj_pool_free;
 }
@@ -133,7 +133,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
 {
        struct debug_obj *obj = NULL;
 
-       spin_lock(&pool_lock);
+       raw_spin_lock(&pool_lock);
        if (obj_pool.first) {
                obj         = hlist_entry(obj_pool.first, typeof(*obj), node);
 
@@ -152,7 +152,7 @@ alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
                if (obj_pool_free < obj_pool_min_free)
                        obj_pool_min_free = obj_pool_free;
        }
-       spin_unlock(&pool_lock);
+       raw_spin_unlock(&pool_lock);
 
        return obj;
 }
@@ -165,7 +165,7 @@ static void free_obj_work(struct work_struct *work)
        struct debug_obj *obj;
        unsigned long flags;
 
-       spin_lock_irqsave(&pool_lock, flags);
+       raw_spin_lock_irqsave(&pool_lock, flags);
        while (obj_pool_free > ODEBUG_POOL_SIZE) {
                obj = hlist_entry(obj_pool.first, typeof(*obj), node);
                hlist_del(&obj->node);
@@ -174,11 +174,11 @@ static void free_obj_work(struct work_struct *work)
                 * We release pool_lock across kmem_cache_free() to
                 * avoid contention on pool_lock.
                 */
-               spin_unlock_irqrestore(&pool_lock, flags);
+               raw_spin_unlock_irqrestore(&pool_lock, flags);
                kmem_cache_free(obj_cache, obj);
-               spin_lock_irqsave(&pool_lock, flags);
+               raw_spin_lock_irqsave(&pool_lock, flags);
        }
-       spin_unlock_irqrestore(&pool_lock, flags);
+       raw_spin_unlock_irqrestore(&pool_lock, flags);
 }
 
 /*
@@ -190,7 +190,7 @@ static void free_object(struct debug_obj *obj)
        unsigned long flags;
        int sched = 0;
 
-       spin_lock_irqsave(&pool_lock, flags);
+       raw_spin_lock_irqsave(&pool_lock, flags);
        /*
         * schedule work when the pool is filled and the cache is
         * initialized:
@@ -200,7 +200,7 @@ static void free_object(struct debug_obj *obj)
        hlist_add_head(&obj->node, &obj_pool);
        obj_pool_free++;
        obj_pool_used--;
-       spin_unlock_irqrestore(&pool_lock, flags);
+       raw_spin_unlock_irqrestore(&pool_lock, flags);
        if (sched)
                schedule_work(&debug_obj_work);
 }
@@ -221,9 +221,9 @@ static void debug_objects_oom(void)
        printk(KERN_WARNING "ODEBUG: Out of memory. ODEBUG disabled\n");
 
        for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
-               spin_lock_irqsave(&db->lock, flags);
+               raw_spin_lock_irqsave(&db->lock, flags);
                hlist_move_list(&db->list, &freelist);
-               spin_unlock_irqrestore(&db->lock, flags);
+               raw_spin_unlock_irqrestore(&db->lock, flags);
 
                /* Now free them */
                hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) {
@@ -303,14 +303,14 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)
 
        db = get_bucket((unsigned long) addr);
 
-       spin_lock_irqsave(&db->lock, flags);
+       raw_spin_lock_irqsave(&db->lock, flags);
 
        obj = lookup_object(addr, db);
        if (!obj) {
                obj = alloc_object(addr, db, descr);
                if (!obj) {
                        debug_objects_enabled = 0;
-                       spin_unlock_irqrestore(&db->lock, flags);
+                       raw_spin_unlock_irqrestore(&db->lock, flags);
                        debug_objects_oom();
                        return;
                }
@@ -327,7 +327,7 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)
        case ODEBUG_STATE_ACTIVE:
                debug_print_object(obj, "init");
                state = obj->state;
-               spin_unlock_irqrestore(&db->lock, flags);
+               raw_spin_unlock_irqrestore(&db->lock, flags);
                debug_object_fixup(descr->fixup_init, addr, state);
                return;
 
@@ -338,7 +338,7 @@ __debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)
                break;
        }
 
-       spin_unlock_irqrestore(&db->lock, flags);
+       raw_spin_unlock_irqrestore(&db->lock, flags);
 }
 
 /**
@@ -385,7 +385,7 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr)
 
        db = get_bucket((unsigned long) addr);
 
-       spin_lock_irqsave(&db->lock, flags);
+       raw_spin_lock_irqsave(&db->lock, flags);
 
        obj = lookup_object(addr, db);
        if (obj) {
@@ -398,7 +398,7 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr)
                case ODEBUG_STATE_ACTIVE:
                        debug_print_object(obj, "activate");
                        state = obj->state;
-                       spin_unlock_irqrestore(&db->lock, flags);
+                       raw_spin_unlock_irqrestore(&db->lock, flags);
                        debug_object_fixup(descr->fixup_activate, addr, state);
                        return;
 
@@ -408,11 +408,11 @@ void debug_object_activate(void *addr, struct debug_obj_descr *descr)
                default:
                        break;
                }
-               spin_unlock_irqrestore(&db->lock, flags);
+               raw_spin_unlock_irqrestore(&db->lock, flags);
                return;
        }
 
-       spin_unlock_irqrestore(&db->lock, flags);
+       raw_spin_unlock_irqrestore(&db->lock, flags);
        /*
         * This happens when a static object is activated. We
         * let the type specific code decide whether this is
@@ -438,7 +438,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr)
 
        db = get_bucket((unsigned long) addr);
 
-       spin_lock_irqsave(&db->lock, flags);
+       raw_spin_lock_irqsave(&db->lock, flags);
 
        obj = lookup_object(addr, db);
        if (obj) {
@@ -463,7 +463,7 @@ void debug_object_deactivate(void *addr, struct debug_obj_descr *descr)
                debug_print_object(&o, "deactivate");
        }
 
-       spin_unlock_irqrestore(&db->lock, flags);
+       raw_spin_unlock_irqrestore(&db->lock, flags);
 }
 
 /**
@@ -483,7 +483,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr)
 
        db = get_bucket((unsigned long) addr);
 
-       spin_lock_irqsave(&db->lock, flags);
+       raw_spin_lock_irqsave(&db->lock, flags);
 
        obj = lookup_object(addr, db);
        if (!obj)
@@ -498,7 +498,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr)
        case ODEBUG_STATE_ACTIVE:
                debug_print_object(obj, "destroy");
                state = obj->state;
-               spin_unlock_irqrestore(&db->lock, flags);
+               raw_spin_unlock_irqrestore(&db->lock, flags);
                debug_object_fixup(descr->fixup_destroy, addr, state);
                return;
 
@@ -509,7 +509,7 @@ void debug_object_destroy(void *addr, struct debug_obj_descr *descr)
                break;
        }
 out_unlock:
-       spin_unlock_irqrestore(&db->lock, flags);
+       raw_spin_unlock_irqrestore(&db->lock, flags);
 }
 
 /**
@@ -529,7 +529,7 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr)
 
        db = get_bucket((unsigned long) addr);
 
-       spin_lock_irqsave(&db->lock, flags);
+       raw_spin_lock_irqsave(&db->lock, flags);
 
        obj = lookup_object(addr, db);
        if (!obj)
@@ -539,17 +539,17 @@ void debug_object_free(void *addr, struct debug_obj_descr *descr)
        case ODEBUG_STATE_ACTIVE:
                debug_print_object(obj, "free");
                state = obj->state;
-               spin_unlock_irqrestore(&db->lock, flags);
+               raw_spin_unlock_irqrestore(&db->lock, flags);
                debug_object_fixup(descr->fixup_free, addr, state);
                return;
        default:
                hlist_del(&obj->node);
-               spin_unlock_irqrestore(&db->lock, flags);
+               raw_spin_unlock_irqrestore(&db->lock, flags);
                free_object(obj);
                return;
        }
 out_unlock:
-       spin_unlock_irqrestore(&db->lock, flags);
+       raw_spin_unlock_irqrestore(&db->lock, flags);
 }
 
 #ifdef CONFIG_DEBUG_OBJECTS_FREE
@@ -575,7 +575,7 @@ static void __debug_check_no_obj_freed(const void *address, unsigned long size)
 
 repeat:
                cnt = 0;
-               spin_lock_irqsave(&db->lock, flags);
+               raw_spin_lock_irqsave(&db->lock, flags);
                hlist_for_each_entry_safe(obj, node, tmp, &db->list, node) {
                        cnt++;
                        oaddr = (unsigned long) obj->object;
@@ -587,7 +587,7 @@ repeat:
                                debug_print_object(obj, "free");
                                descr = obj->descr;
                                state = obj->state;
-                               spin_unlock_irqrestore(&db->lock, flags);
+                               raw_spin_unlock_irqrestore(&db->lock, flags);
                                debug_object_fixup(descr->fixup_free,
                                                   (void *) oaddr, state);
                                goto repeat;
@@ -597,7 +597,7 @@ repeat:
                                break;
                        }
                }
-               spin_unlock_irqrestore(&db->lock, flags);
+               raw_spin_unlock_irqrestore(&db->lock, flags);
 
                /* Now free them */
                hlist_for_each_entry_safe(obj, node, tmp, &freelist, node) {
@@ -783,7 +783,7 @@ check_results(void *addr, enum debug_obj_state state, int fixups, int warnings)
 
        db = get_bucket((unsigned long) addr);
 
-       spin_lock_irqsave(&db->lock, flags);
+       raw_spin_lock_irqsave(&db->lock, flags);
 
        obj = lookup_object(addr, db);
        if (!obj && state != ODEBUG_STATE_NONE) {
@@ -807,7 +807,7 @@ check_results(void *addr, enum debug_obj_state state, int fixups, int warnings)
        }
        res = 0;
 out:
-       spin_unlock_irqrestore(&db->lock, flags);
+       raw_spin_unlock_irqrestore(&db->lock, flags);
        if (res)
                debug_objects_enabled = 0;
        return res;
@@ -907,7 +907,7 @@ void __init debug_objects_early_init(void)
        int i;
 
        for (i = 0; i < ODEBUG_HASH_SIZE; i++)
-               spin_lock_init(&obj_hash[i].lock);
+               raw_spin_lock_init(&obj_hash[i].lock);
 
        for (i = 0; i < ODEBUG_POOL_SIZE; i++)
                hlist_add_head(&obj_static_pool[i].node, &obj_pool);
index 76074209f9a2eecdc0cdab8278916aa3de1fcdf2..a4e971dee102b23f3e6e09b656cc24ec81415faa 100644 (file)
@@ -637,6 +637,8 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len,
 
        /* Allocate bunzip_data.  Most fields initialize to zero. */
        bd = *bdp = malloc(i);
+       if (!bd)
+               return RETVAL_OUT_OF_MEMORY;
        memset(bd, 0, sizeof(struct bunzip_data));
        /* Setup input buffer */
        bd->inbuf = inbuf;
@@ -664,6 +666,8 @@ static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len,
        bd->dbufSize = 100000*(i-BZh0);
 
        bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
+       if (!bd->dbuf)
+               return RETVAL_OUT_OF_MEMORY;
        return RETVAL_OK;
 }
 
@@ -686,7 +690,7 @@ STATIC int INIT bunzip2(unsigned char *buf, int len,
 
        if (!outbuf) {
                error("Could not allocate output bufer");
-               return -1;
+               return RETVAL_OUT_OF_MEMORY;
        }
        if (buf)
                inbuf = buf;
@@ -694,6 +698,7 @@ STATIC int INIT bunzip2(unsigned char *buf, int len,
                inbuf = malloc(BZIP2_IOBUF_SIZE);
        if (!inbuf) {
                error("Could not allocate input bufer");
+               i = RETVAL_OUT_OF_MEMORY;
                goto exit_0;
        }
        i = start_bunzip(&bd, inbuf, len, fill);
@@ -720,11 +725,14 @@ STATIC int INIT bunzip2(unsigned char *buf, int len,
        } else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) {
                error("Compressed file ends unexpectedly");
        }
+       if (!bd)
+               goto exit_1;
        if (bd->dbuf)
                large_free(bd->dbuf);
        if (pos)
                *pos = bd->inbufPos;
        free(bd);
+exit_1:
        if (!buf)
                free(inbuf);
 exit_0:
index e22c148e4b7fff7605e605689561df66d018c6fa..f9350291598825a214068eb338e41f07edffb8c8 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/list.h>
 #include <linux/sysctl.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/uaccess.h>
 #include <linux/dynamic_debug.h>
 #include <linux/debugfs.h>
@@ -209,8 +210,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
                char *end;
 
                /* Skip leading whitespace */
-               while (*buf && isspace(*buf))
-                       buf++;
+               buf = skip_spaces(buf);
                if (!*buf)
                        break;  /* oh, it was trailing whitespace */
 
index eed2bdb865e76673bfe24834301de8406d9cfc88..e67f97495dd53c6a479f0a7a0ac3f2f68814f2e1 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/bitmap.h>
 #include <linux/genalloc.h>
 
 
@@ -114,7 +115,7 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
        struct gen_pool_chunk *chunk;
        unsigned long addr, flags;
        int order = pool->min_alloc_order;
-       int nbits, bit, start_bit, end_bit;
+       int nbits, start_bit, end_bit;
 
        if (size == 0)
                return 0;
@@ -129,29 +130,19 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size)
                end_bit -= nbits + 1;
 
                spin_lock_irqsave(&chunk->lock, flags);
-               bit = -1;
-               while (bit + 1 < end_bit) {
-                       bit = find_next_zero_bit(chunk->bits, end_bit, bit + 1);
-                       if (bit >= end_bit)
-                               break;
-
-                       start_bit = bit;
-                       if (nbits > 1) {
-                               bit = find_next_bit(chunk->bits, bit + nbits,
-                                                       bit + 1);
-                               if (bit - start_bit < nbits)
-                                       continue;
-                       }
-
-                       addr = chunk->start_addr +
-                                           ((unsigned long)start_bit << order);
-                       while (nbits--)
-                               __set_bit(start_bit++, chunk->bits);
+               start_bit = bitmap_find_next_zero_area(chunk->bits, end_bit, 0,
+                                               nbits, 0);
+               if (start_bit >= end_bit) {
                        spin_unlock_irqrestore(&chunk->lock, flags);
-                       read_unlock(&pool->lock);
-                       return addr;
+                       continue;
                }
+
+               addr = chunk->start_addr + ((unsigned long)start_bit << order);
+
+               bitmap_set(chunk->bits, start_bit, nbits);
                spin_unlock_irqrestore(&chunk->lock, flags);
+               read_unlock(&pool->lock);
+               return addr;
        }
        read_unlock(&pool->lock);
        return 0;
index 75dbda03f4fb99a92ef8cc3ead817afefd707702..c0251f4ad08b05fec688f97ea2e771095cfdb89c 100644 (file)
@@ -3,41 +3,7 @@
  */
 
 #include <linux/module.h>
-#include <linux/bitops.h>
-
-static unsigned long find_next_zero_area(unsigned long *map,
-                                        unsigned long size,
-                                        unsigned long start,
-                                        unsigned int nr,
-                                        unsigned long align_mask)
-{
-       unsigned long index, end, i;
-again:
-       index = find_next_zero_bit(map, size, start);
-
-       /* Align allocation */
-       index = (index + align_mask) & ~align_mask;
-
-       end = index + nr;
-       if (end >= size)
-               return -1;
-       for (i = index; i < end; i++) {
-               if (test_bit(i, map)) {
-                       start = i+1;
-                       goto again;
-               }
-       }
-       return index;
-}
-
-void iommu_area_reserve(unsigned long *map, unsigned long i, int len)
-{
-       unsigned long end = i + len;
-       while (i < end) {
-               __set_bit(i, map);
-               i++;
-       }
-}
+#include <linux/bitmap.h>
 
 int iommu_is_span_boundary(unsigned int index, unsigned int nr,
                           unsigned long shift,
@@ -55,31 +21,24 @@ unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
                               unsigned long align_mask)
 {
        unsigned long index;
+
+       /* We don't want the last of the limit */
+       size -= 1;
 again:
-       index = find_next_zero_area(map, size, start, nr, align_mask);
-       if (index != -1) {
+       index = bitmap_find_next_zero_area(map, size, start, nr, align_mask);
+       if (index < size) {
                if (iommu_is_span_boundary(index, nr, shift, boundary_size)) {
                        /* we could do more effectively */
                        start = index + 1;
                        goto again;
                }
-               iommu_area_reserve(map, index, nr);
+               bitmap_set(map, index, nr);
+               return index;
        }
-       return index;
+       return -1;
 }
 EXPORT_SYMBOL(iommu_area_alloc);
 
-void iommu_area_free(unsigned long *map, unsigned long start, unsigned int nr)
-{
-       unsigned long end = start + nr;
-
-       while (start < end) {
-               __clear_bit(start, map);
-               start++;
-       }
-}
-EXPORT_SYMBOL(iommu_area_free);
-
 unsigned long iommu_num_pages(unsigned long addr, unsigned long len,
                              unsigned long io_page_size)
 {
index 5526b46aba9457598bd091f55863da63fce26aa5..b135d04aa48ab6d6875571714eb5844291686a36 100644 (file)
@@ -23,7 +23,7 @@
  *
  * Don't use in new code.
  */
-static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(kernel_flag);
+static  __cacheline_aligned_in_smp DEFINE_RAW_SPINLOCK(kernel_flag);
 
 
 /*
@@ -36,12 +36,12 @@ static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(kernel_flag);
  * If it successfully gets the lock, it should increment
  * the preemption count like any spinlock does.
  *
- * (This works on UP too - _raw_spin_trylock will never
+ * (This works on UP too - do_raw_spin_trylock will never
  * return false in that case)
  */
 int __lockfunc __reacquire_kernel_lock(void)
 {
-       while (!_raw_spin_trylock(&kernel_flag)) {
+       while (!do_raw_spin_trylock(&kernel_flag)) {
                if (need_resched())
                        return -EAGAIN;
                cpu_relax();
@@ -52,27 +52,27 @@ int __lockfunc __reacquire_kernel_lock(void)
 
 void __lockfunc __release_kernel_lock(void)
 {
-       _raw_spin_unlock(&kernel_flag);
+       do_raw_spin_unlock(&kernel_flag);
        preempt_enable_no_resched();
 }
 
 /*
  * These are the BKL spinlocks - we try to be polite about preemption.
  * If SMP is not on (ie UP preemption), this all goes away because the
- * _raw_spin_trylock() will always succeed.
+ * do_raw_spin_trylock() will always succeed.
  */
 #ifdef CONFIG_PREEMPT
 static inline void __lock_kernel(void)
 {
        preempt_disable();
-       if (unlikely(!_raw_spin_trylock(&kernel_flag))) {
+       if (unlikely(!do_raw_spin_trylock(&kernel_flag))) {
                /*
                 * If preemption was disabled even before this
                 * was called, there's nothing we can be polite
                 * about - just spin.
                 */
                if (preempt_count() > 1) {
-                       _raw_spin_lock(&kernel_flag);
+                       do_raw_spin_lock(&kernel_flag);
                        return;
                }
 
@@ -82,10 +82,10 @@ static inline void __lock_kernel(void)
                 */
                do {
                        preempt_enable();
-                       while (spin_is_locked(&kernel_flag))
+                       while (raw_spin_is_locked(&kernel_flag))
                                cpu_relax();
                        preempt_disable();
-               } while (!_raw_spin_trylock(&kernel_flag));
+               } while (!do_raw_spin_trylock(&kernel_flag));
        }
 }
 
@@ -96,7 +96,7 @@ static inline void __lock_kernel(void)
  */
 static inline void __lock_kernel(void)
 {
-       _raw_spin_lock(&kernel_flag);
+       do_raw_spin_lock(&kernel_flag);
 }
 #endif
 
@@ -106,7 +106,7 @@ static inline void __unlock_kernel(void)
         * the BKL is not covered by lockdep, so we open-code the
         * unlocking sequence (and thus avoid the dep-chain ops):
         */
-       _raw_spin_unlock(&kernel_flag);
+       do_raw_spin_unlock(&kernel_flag);
        preempt_enable();
 }
 
index 0343c05609f0d62f9b48b259bf3018db728b11a5..9cee17142b2cdc6d2d7a78c8b6ca5fd6573eb4b8 100644 (file)
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -263,7 +263,7 @@ long __init lmb_reserve(u64 base, u64 size)
        return lmb_add_region(_rgn, base, size);
 }
 
-long __init lmb_overlaps_region(struct lmb_region *rgn, u64 base, u64 size)
+long lmb_overlaps_region(struct lmb_region *rgn, u64 base, u64 size)
 {
        unsigned long i;
 
@@ -493,6 +493,11 @@ int __init lmb_is_reserved(u64 addr)
        return 0;
 }
 
+int lmb_is_region_reserved(u64 base, u64 size)
+{
+       return lmb_overlaps_region(&lmb.reserved, base, size);
+}
+
 /*
  * Given a <base, len>, find which memory regions belong to this range.
  * Adjust the request and return a contiguous chunk.
index b00d02059a5f8acc3a58a6290251aa487f2cca2e..fb34977246bb052923d5fad6341c2ba80315fdfe 100644 (file)
@@ -56,13 +56,16 @@ static int match_one(char *s, const char *p, substring_t args[])
 
                args[argc].from = s;
                switch (*p++) {
-               case 's':
-                       if (strlen(s) == 0)
+               case 's': {
+                       size_t str_len = strlen(s);
+
+                       if (str_len == 0)
                                return 0;
-                       else if (len == -1 || len > strlen(s))
-                               len = strlen(s);
+                       if (len == -1 || len > str_len)
+                               len = str_len;
                        args[argc].to = s + len;
                        break;
+               }
                case 'd':
                        simple_strtol(s, &args[argc].to, 0);
                        goto num;
index d6c64a824e1d70b7b3a83cde573d8fc7c16b2ada..1471988d9190db351355faa35a21ab10f85c262a 100644 (file)
@@ -54,9 +54,11 @@ static void plist_check_list(struct list_head *top)
 
 static void plist_check_head(struct plist_head *head)
 {
-       WARN_ON(!head->lock);
-       if (head->lock)
-               WARN_ON_SMP(!spin_is_locked(head->lock));
+       WARN_ON(!head->rawlock && !head->spinlock);
+       if (head->rawlock)
+               WARN_ON_SMP(!raw_spin_is_locked(head->rawlock));
+       if (head->spinlock)
+               WARN_ON_SMP(!spin_is_locked(head->spinlock));
        plist_check_list(&head->prio_list);
        plist_check_list(&head->node_list);
 }
index 9df3ca56db11455f39c436a6fa79f423b7e35b67..ccf95bff798439c7afead0834370864ff41a735c 100644 (file)
@@ -17,6 +17,19 @@ struct rwsem_waiter {
 #define RWSEM_WAITING_FOR_WRITE        0x00000002
 };
 
+int rwsem_is_locked(struct rw_semaphore *sem)
+{
+       int ret = 1;
+       unsigned long flags;
+
+       if (spin_trylock_irqsave(&sem->wait_lock, flags)) {
+               ret = (sem->activity != 0);
+               spin_unlock_irqrestore(&sem->wait_lock, flags);
+       }
+       return ret;
+}
+EXPORT_SYMBOL(rwsem_is_locked);
+
 /*
  * initialise the semaphore
  */
@@ -34,6 +47,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name,
        spin_lock_init(&sem->wait_lock);
        INIT_LIST_HEAD(&sem->wait_list);
 }
+EXPORT_SYMBOL(__init_rwsem);
 
 /*
  * handle the lock release when processes blocked on it that can now run
@@ -305,12 +319,3 @@ void __downgrade_write(struct rw_semaphore *sem)
        spin_unlock_irqrestore(&sem->wait_lock, flags);
 }
 
-EXPORT_SYMBOL(__init_rwsem);
-EXPORT_SYMBOL(__down_read);
-EXPORT_SYMBOL(__down_read_trylock);
-EXPORT_SYMBOL(__down_write_nested);
-EXPORT_SYMBOL(__down_write);
-EXPORT_SYMBOL(__down_write_trylock);
-EXPORT_SYMBOL(__up_read);
-EXPORT_SYMBOL(__up_write);
-EXPORT_SYMBOL(__downgrade_write);
index 9c4b0256490bd240b37f8811915e873463c88537..4755b98b6dfb83b01055a1856739b7a805839466 100644 (file)
@@ -13,8 +13,8 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 
-void __spin_lock_init(spinlock_t *lock, const char *name,
-                     struct lock_class_key *key)
+void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
+                         struct lock_class_key *key)
 {
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
        /*
@@ -23,13 +23,13 @@ void __spin_lock_init(spinlock_t *lock, const char *name,
        debug_check_no_locks_freed((void *)lock, sizeof(*lock));
        lockdep_init_map(&lock->dep_map, name, key, 0);
 #endif
-       lock->raw_lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
+       lock->raw_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
        lock->magic = SPINLOCK_MAGIC;
        lock->owner = SPINLOCK_OWNER_INIT;
        lock->owner_cpu = -1;
 }
 
-EXPORT_SYMBOL(__spin_lock_init);
+EXPORT_SYMBOL(__raw_spin_lock_init);
 
 void __rwlock_init(rwlock_t *lock, const char *name,
                   struct lock_class_key *key)
@@ -41,7 +41,7 @@ void __rwlock_init(rwlock_t *lock, const char *name,
        debug_check_no_locks_freed((void *)lock, sizeof(*lock));
        lockdep_init_map(&lock->dep_map, name, key, 0);
 #endif
-       lock->raw_lock = (raw_rwlock_t) __RAW_RW_LOCK_UNLOCKED;
+       lock->raw_lock = (arch_rwlock_t) __ARCH_RW_LOCK_UNLOCKED;
        lock->magic = RWLOCK_MAGIC;
        lock->owner = SPINLOCK_OWNER_INIT;
        lock->owner_cpu = -1;
@@ -49,7 +49,7 @@ void __rwlock_init(rwlock_t *lock, const char *name,
 
 EXPORT_SYMBOL(__rwlock_init);
 
-static void spin_bug(spinlock_t *lock, const char *msg)
+static void spin_bug(raw_spinlock_t *lock, const char *msg)
 {
        struct task_struct *owner = NULL;
 
@@ -73,7 +73,7 @@ static void spin_bug(spinlock_t *lock, const char *msg)
 #define SPIN_BUG_ON(cond, lock, msg) if (unlikely(cond)) spin_bug(lock, msg)
 
 static inline void
-debug_spin_lock_before(spinlock_t *lock)
+debug_spin_lock_before(raw_spinlock_t *lock)
 {
        SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic");
        SPIN_BUG_ON(lock->owner == current, lock, "recursion");
@@ -81,16 +81,16 @@ debug_spin_lock_before(spinlock_t *lock)
                                                        lock, "cpu recursion");
 }
 
-static inline void debug_spin_lock_after(spinlock_t *lock)
+static inline void debug_spin_lock_after(raw_spinlock_t *lock)
 {
        lock->owner_cpu = raw_smp_processor_id();
        lock->owner = current;
 }
 
-static inline void debug_spin_unlock(spinlock_t *lock)
+static inline void debug_spin_unlock(raw_spinlock_t *lock)
 {
        SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic");
-       SPIN_BUG_ON(!spin_is_locked(lock), lock, "already unlocked");
+       SPIN_BUG_ON(!raw_spin_is_locked(lock), lock, "already unlocked");
        SPIN_BUG_ON(lock->owner != current, lock, "wrong owner");
        SPIN_BUG_ON(lock->owner_cpu != raw_smp_processor_id(),
                                                        lock, "wrong CPU");
@@ -98,7 +98,7 @@ static inline void debug_spin_unlock(spinlock_t *lock)
        lock->owner_cpu = -1;
 }
 
-static void __spin_lock_debug(spinlock_t *lock)
+static void __spin_lock_debug(raw_spinlock_t *lock)
 {
        u64 i;
        u64 loops = loops_per_jiffy * HZ;
@@ -106,7 +106,7 @@ static void __spin_lock_debug(spinlock_t *lock)
 
        for (;;) {
                for (i = 0; i < loops; i++) {
-                       if (__raw_spin_trylock(&lock->raw_lock))
+                       if (arch_spin_trylock(&lock->raw_lock))
                                return;
                        __delay(1);
                }
@@ -125,17 +125,17 @@ static void __spin_lock_debug(spinlock_t *lock)
        }
 }
 
-void _raw_spin_lock(spinlock_t *lock)
+void do_raw_spin_lock(raw_spinlock_t *lock)
 {
        debug_spin_lock_before(lock);
-       if (unlikely(!__raw_spin_trylock(&lock->raw_lock)))
+       if (unlikely(!arch_spin_trylock(&lock->raw_lock)))
                __spin_lock_debug(lock);
        debug_spin_lock_after(lock);
 }
 
-int _raw_spin_trylock(spinlock_t *lock)
+int do_raw_spin_trylock(raw_spinlock_t *lock)
 {
-       int ret = __raw_spin_trylock(&lock->raw_lock);
+       int ret = arch_spin_trylock(&lock->raw_lock);
 
        if (ret)
                debug_spin_lock_after(lock);
@@ -148,10 +148,10 @@ int _raw_spin_trylock(spinlock_t *lock)
        return ret;
 }
 
-void _raw_spin_unlock(spinlock_t *lock)
+void do_raw_spin_unlock(raw_spinlock_t *lock)
 {
        debug_spin_unlock(lock);
-       __raw_spin_unlock(&lock->raw_lock);
+       arch_spin_unlock(&lock->raw_lock);
 }
 
 static void rwlock_bug(rwlock_t *lock, const char *msg)
@@ -176,7 +176,7 @@ static void __read_lock_debug(rwlock_t *lock)
 
        for (;;) {
                for (i = 0; i < loops; i++) {
-                       if (__raw_read_trylock(&lock->raw_lock))
+                       if (arch_read_trylock(&lock->raw_lock))
                                return;
                        __delay(1);
                }
@@ -193,15 +193,15 @@ static void __read_lock_debug(rwlock_t *lock)
 }
 #endif
 
-void _raw_read_lock(rwlock_t *lock)
+void do_raw_read_lock(rwlock_t *lock)
 {
        RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
-       __raw_read_lock(&lock->raw_lock);
+       arch_read_lock(&lock->raw_lock);
 }
 
-int _raw_read_trylock(rwlock_t *lock)
+int do_raw_read_trylock(rwlock_t *lock)
 {
-       int ret = __raw_read_trylock(&lock->raw_lock);
+       int ret = arch_read_trylock(&lock->raw_lock);
 
 #ifndef CONFIG_SMP
        /*
@@ -212,10 +212,10 @@ int _raw_read_trylock(rwlock_t *lock)
        return ret;
 }
 
-void _raw_read_unlock(rwlock_t *lock)
+void do_raw_read_unlock(rwlock_t *lock)
 {
        RWLOCK_BUG_ON(lock->magic != RWLOCK_MAGIC, lock, "bad magic");
-       __raw_read_unlock(&lock->raw_lock);
+       arch_read_unlock(&lock->raw_lock);
 }
 
 static inline void debug_write_lock_before(rwlock_t *lock)
@@ -251,7 +251,7 @@ static void __write_lock_debug(rwlock_t *lock)
 
        for (;;) {
                for (i = 0; i < loops; i++) {
-                       if (__raw_write_trylock(&lock->raw_lock))
+                       if (arch_write_trylock(&lock->raw_lock))
                                return;
                        __delay(1);
                }
@@ -268,16 +268,16 @@ static void __write_lock_debug(rwlock_t *lock)
 }
 #endif
 
-void _raw_write_lock(rwlock_t *lock)
+void do_raw_write_lock(rwlock_t *lock)
 {
        debug_write_lock_before(lock);
-       __raw_write_lock(&lock->raw_lock);
+       arch_write_lock(&lock->raw_lock);
        debug_write_lock_after(lock);
 }
 
-int _raw_write_trylock(rwlock_t *lock)
+int do_raw_write_trylock(rwlock_t *lock)
 {
-       int ret = __raw_write_trylock(&lock->raw_lock);
+       int ret = arch_write_trylock(&lock->raw_lock);
 
        if (ret)
                debug_write_lock_after(lock);
@@ -290,8 +290,8 @@ int _raw_write_trylock(rwlock_t *lock)
        return ret;
 }
 
-void _raw_write_unlock(rwlock_t *lock)
+void do_raw_write_unlock(rwlock_t *lock)
 {
        debug_write_unlock(lock);
-       __raw_write_unlock(&lock->raw_lock);
+       arch_write_unlock(&lock->raw_lock);
 }
index e96421ab9a9a0a1a8ddd4496e32789acdc4b0749..9f75b4ec50b87a7f337ccd200098816bdee2cce6 100644 (file)
@@ -338,20 +338,34 @@ EXPORT_SYMBOL(strnchr);
 #endif
 
 /**
- * strstrip - Removes leading and trailing whitespace from @s.
+ * skip_spaces - Removes leading whitespace from @str.
+ * @str: The string to be stripped.
+ *
+ * Returns a pointer to the first non-whitespace character in @str.
+ */
+char *skip_spaces(const char *str)
+{
+       while (isspace(*str))
+               ++str;
+       return (char *)str;
+}
+EXPORT_SYMBOL(skip_spaces);
+
+/**
+ * strim - Removes leading and trailing whitespace from @s.
  * @s: The string to be stripped.
  *
  * Note that the first trailing whitespace is replaced with a %NUL-terminator
  * in the given string @s. Returns a pointer to the first non-whitespace
  * character in @s.
  */
-char *strstrip(char *s)
+char *strim(char *s)
 {
        size_t size;
        char *end;
 
+       s = skip_spaces(s);
        size = strlen(s);
-
        if (!size)
                return s;
 
@@ -360,12 +374,9 @@ char *strstrip(char *s)
                end--;
        *(end + 1) = '\0';
 
-       while (*s && isspace(*s))
-               s++;
-
        return s;
 }
-EXPORT_SYMBOL(strstrip);
+EXPORT_SYMBOL(strim);
 
 #ifndef __HAVE_ARCH_STRLEN
 /**
index 5bc01803f8f85bf29557bddc77afa04b60bdb8ad..437eedb5a53ba1feae04f98b5def86798462f920 100644 (file)
@@ -549,7 +549,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
                dma_mask = hwdev->coherent_dma_mask;
 
        ret = (void *)__get_free_pages(flags, order);
-       if (ret && swiotlb_virt_to_bus(hwdev, ret) + size > dma_mask) {
+       if (ret && swiotlb_virt_to_bus(hwdev, ret) + size - 1 > dma_mask) {
                /*
                 * The allocated memory isn't reachable by the device.
                 */
@@ -571,7 +571,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size,
        dev_addr = swiotlb_virt_to_bus(hwdev, ret);
 
        /* Confirm address can be DMA'd by device */
-       if (dev_addr + size > dma_mask) {
+       if (dev_addr + size - 1 > dma_mask) {
                printk("hwdev DMA mask = 0x%016Lx, dev_addr = 0x%016Lx\n",
                       (unsigned long long)dma_mask,
                       (unsigned long long)dev_addr);
index 6438cd5599eefe583451b9b5bd858b9ab5a0ca38..d4996cf46eb6ac0b2227a28ff26c734568b86f99 100644 (file)
@@ -9,7 +9,7 @@
  * Wirzenius wrote this portably, Torvalds fucked it up :-)
  */
 
-/* 
+/*
  * Fri Jul 13 2001 Crutcher Dunnavant <crutcher+kernel@datastacks.com>
  * - changed to provide snprintf and vsnprintf functions
  * So Feb  1 16:51:32 CET 2004 Juergen Quade <quade@hsnr.de>
@@ -47,14 +47,14 @@ static unsigned int simple_guess_base(const char *cp)
 }
 
 /**
- * simple_strtoul - convert a string to an unsigned long
+ * simple_strtoull - convert a string to an unsigned long long
  * @cp: The start of the string
  * @endp: A pointer to the end of the parsed string will be placed here
  * @base: The number base to use
  */
-unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
+unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
 {
-       unsigned long result = 0;
+       unsigned long long result = 0;
 
        if (!base)
                base = simple_guess_base(cp);
@@ -71,58 +71,39 @@ unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
                result = result * base + value;
                cp++;
        }
-
        if (endp)
                *endp = (char *)cp;
+
        return result;
 }
-EXPORT_SYMBOL(simple_strtoul);
+EXPORT_SYMBOL(simple_strtoull);
 
 /**
- * simple_strtol - convert a string to a signed long
+ * simple_strtoul - convert a string to an unsigned long
  * @cp: The start of the string
  * @endp: A pointer to the end of the parsed string will be placed here
  * @base: The number base to use
  */
-long simple_strtol(const char *cp, char **endp, unsigned int base)
+unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
 {
-       if(*cp == '-')
-               return -simple_strtoul(cp + 1, endp, base);
-       return simple_strtoul(cp, endp, base);
+       return simple_strtoull(cp, endp, base);
 }
-EXPORT_SYMBOL(simple_strtol);
+EXPORT_SYMBOL(simple_strtoul);
 
 /**
- * simple_strtoull - convert a string to an unsigned long long
+ * simple_strtol - convert a string to a signed long
  * @cp: The start of the string
  * @endp: A pointer to the end of the parsed string will be placed here
  * @base: The number base to use
  */
-unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base)
+long simple_strtol(const char *cp, char **endp, unsigned int base)
 {
-       unsigned long long result = 0;
-
-       if (!base)
-               base = simple_guess_base(cp);
-
-       if (base == 16 && cp[0] == '0' && TOLOWER(cp[1]) == 'x')
-               cp += 2;
-
-       while (isxdigit(*cp)) {
-               unsigned int value;
-
-               value = isdigit(*cp) ? *cp - '0' : TOLOWER(*cp) - 'a' + 10;
-               if (value >= base)
-                       break;
-               result = result * base + value;
-               cp++;
-       }
+       if (*cp == '-')
+               return -simple_strtoul(cp + 1, endp, base);
 
-       if (endp)
-               *endp = (char *)cp;
-       return result;
+       return simple_strtoul(cp, endp, base);
 }
-EXPORT_SYMBOL(simple_strtoull);
+EXPORT_SYMBOL(simple_strtol);
 
 /**
  * simple_strtoll - convert a string to a signed long long
@@ -132,8 +113,9 @@ EXPORT_SYMBOL(simple_strtoull);
  */
 long long simple_strtoll(const char *cp, char **endp, unsigned int base)
 {
-       if(*cp=='-')
+       if (*cp == '-')
                return -simple_strtoull(cp + 1, endp, base);
+
        return simple_strtoull(cp, endp, base);
 }
 
@@ -173,6 +155,7 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
        val = simple_strtoul(cp, &tail, base);
        if (tail == cp)
                return -EINVAL;
+
        if ((*tail == '\0') ||
                ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
                *res = val;
@@ -285,10 +268,11 @@ EXPORT_SYMBOL(strict_strtoll);
 
 static int skip_atoi(const char **s)
 {
-       int i=0;
+       int i = 0;
 
        while (isdigit(**s))
                i = i*10 + *((*s)++) - '0';
+
        return i;
 }
 
@@ -302,7 +286,7 @@ static int skip_atoi(const char **s)
 /* Formats correctly any integer in [0,99999].
  * Outputs from one to five digits depending on input.
  * On i386 gcc 4.1.2 -O2: ~250 bytes of code. */
-static charput_dec_trunc(char *buf, unsigned q)
+static char *put_dec_trunc(char *buf, unsigned q)
 {
        unsigned d3, d2, d1, d0;
        d1 = (q>>4) & 0xf;
@@ -331,14 +315,15 @@ static char* put_dec_trunc(char *buf, unsigned q)
                                d3 = d3 - 10*q;
                                *buf++ = d3 + '0';  /* next digit */
                                if (q != 0)
-                                       *buf++ = q + '0';  /* most sign. digit */
+                                       *buf++ = q + '0'; /* most sign. digit */
                        }
                }
        }
+
        return buf;
 }
 /* Same with if's removed. Always emits five digits */
-static charput_dec_full(char *buf, unsigned q)
+static char *put_dec_full(char *buf, unsigned q)
 {
        /* BTW, if q is in [0,9999], 8-bit ints will be enough, */
        /* but anyway, gcc produces better code with full-sized ints */
@@ -347,14 +332,15 @@ static char* put_dec_full(char *buf, unsigned q)
        d2 = (q>>8) & 0xf;
        d3 = (q>>12);
 
-       /* Possible ways to approx. divide by 10 */
-       /* gcc -O2 replaces multiply with shifts and adds */
-       // (x * 0xcd) >> 11: 11001101 - shorter code than * 0x67 (on i386)
-       // (x * 0x67) >> 10:  1100111
-       // (x * 0x34) >> 9:    110100 - same
-       // (x * 0x1a) >> 8:     11010 - same
-       // (x * 0x0d) >> 7:      1101 - same, shortest code (on i386)
-
+       /*
+        * Possible ways to approx. divide by 10
+        * gcc -O2 replaces multiply with shifts and adds
+        * (x * 0xcd) >> 11: 11001101 - shorter code than * 0x67 (on i386)
+        * (x * 0x67) >> 10:  1100111
+        * (x * 0x34) >> 9:    110100 - same
+        * (x * 0x1a) >> 8:     11010 - same
+        * (x * 0x0d) >> 7:      1101 - same, shortest code (on i386)
+        */
        d0 = 6*(d3 + d2 + d1) + (q & 0xf);
        q = (d0 * 0xcd) >> 11;
        d0 = d0 - 10*q;
@@ -375,10 +361,11 @@ static char* put_dec_full(char *buf, unsigned q)
                                d3 = d3 - 10*q;
                                *buf++ = d3 + '0';
                                        *buf++ = q + '0';
+
        return buf;
 }
 /* No inlining helps gcc to use registers better */
-static noinline charput_dec(char *buf, unsigned long long num)
+static noinline char *put_dec(char *buf, unsigned long long num)
 {
        while (1) {
                unsigned rem;
@@ -448,9 +435,9 @@ static char *number(char *buf, char *end, unsigned long long num,
                spec.flags &= ~ZEROPAD;
        sign = 0;
        if (spec.flags & SIGN) {
-               if ((signed long long) num < 0) {
+               if ((signed long long)num < 0) {
                        sign = '-';
-                       num = - (signed long long) num;
+                       num = -(signed long long)num;
                        spec.field_width--;
                } else if (spec.flags & PLUS) {
                        sign = '+';
@@ -478,7 +465,9 @@ static char *number(char *buf, char *end, unsigned long long num,
        else if (spec.base != 10) { /* 8 or 16 */
                int mask = spec.base - 1;
                int shift = 3;
-               if (spec.base == 16) shift = 4;
+
+               if (spec.base == 16)
+                       shift = 4;
                do {
                        tmp[i++] = (digits[((unsigned char)num) & mask] | locase);
                        num >>= shift;
@@ -493,7 +482,7 @@ static char *number(char *buf, char *end, unsigned long long num,
        /* leading space padding */
        spec.field_width -= spec.precision;
        if (!(spec.flags & (ZEROPAD+LEFT))) {
-               while(--spec.field_width >= 0) {
+               while (--spec.field_width >= 0) {
                        if (buf < end)
                                *buf = ' ';
                        ++buf;
@@ -543,15 +532,16 @@ static char *number(char *buf, char *end, unsigned long long num,
                        *buf = ' ';
                ++buf;
        }
+
        return buf;
 }
 
-static char *string(char *buf, char *end, char *s, struct printf_spec spec)
+static char *string(char *buf, char *end, const char *s, struct printf_spec spec)
 {
        int len, i;
 
        if ((unsigned long)s < PAGE_SIZE)
-               s = "<NULL>";
+               s = "(null)";
 
        len = strnlen(s, spec.precision);
 
@@ -572,6 +562,7 @@ static char *string(char *buf, char *end, char *s, struct printf_spec spec)
                        *buf = ' ';
                ++buf;
        }
+
        return buf;
 }
 
@@ -585,11 +576,13 @@ static char *symbol_string(char *buf, char *end, void *ptr,
                sprint_symbol(sym, value);
        else
                kallsyms_lookup(value, NULL, NULL, NULL, sym);
+
        return string(buf, end, sym, spec);
 #else
-       spec.field_width = 2*sizeof(void *);
+       spec.field_width = 2 * sizeof(void *);
        spec.flags |= SPECIAL | SMALL | ZEROPAD;
        spec.base = 16;
+
        return number(buf, end, value, spec);
 #endif
 }
@@ -718,22 +711,19 @@ static char *ip4_string(char *p, const u8 *addr, bool leading_zeros)
                if (i < 3)
                        *p++ = '.';
        }
-
        *p = '\0';
+
        return p;
 }
 
 static char *ip6_compressed_string(char *p, const char *addr)
 {
-       int i;
-       int j;
-       int range;
+       int i, j, range;
        unsigned char zerolength[8];
        int longest = 1;
        int colonpos = -1;
        u16 word;
-       u8 hi;
-       u8 lo;
+       u8 hi, lo;
        bool needcolon = false;
        bool useIPv4;
        struct in6_addr in6;
@@ -787,8 +777,9 @@ static char *ip6_compressed_string(char *p, const char *addr)
                                p = pack_hex_byte(p, hi);
                        else
                                *p++ = hex_asc_lo(hi);
+                       p = pack_hex_byte(p, lo);
                }
-               if (hi || lo > 0x0f)
+               else if (lo > 0x0f)
                        p = pack_hex_byte(p, lo);
                else
                        *p++ = hex_asc_lo(lo);
@@ -800,22 +791,23 @@ static char *ip6_compressed_string(char *p, const char *addr)
                        *p++ = ':';
                p = ip4_string(p, &in6.s6_addr[12], false);
        }
-
        *p = '\0';
+
        return p;
 }
 
 static char *ip6_string(char *p, const char *addr, const char *fmt)
 {
        int i;
+
        for (i = 0; i < 8; i++) {
                p = pack_hex_byte(p, *addr++);
                p = pack_hex_byte(p, *addr++);
                if (fmt[0] == 'I' && i != 7)
                        *p++ = ':';
        }
-
        *p = '\0';
+
        return p;
 }
 
@@ -842,6 +834,52 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,
        return string(buf, end, ip4_addr, spec);
 }
 
+static char *uuid_string(char *buf, char *end, const u8 *addr,
+                        struct printf_spec spec, const char *fmt)
+{
+       char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
+       char *p = uuid;
+       int i;
+       static const u8 be[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+       static const u8 le[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
+       const u8 *index = be;
+       bool uc = false;
+
+       switch (*(++fmt)) {
+       case 'L':
+               uc = true;              /* fall-through */
+       case 'l':
+               index = le;
+               break;
+       case 'B':
+               uc = true;
+               break;
+       }
+
+       for (i = 0; i < 16; i++) {
+               p = pack_hex_byte(p, addr[index[i]]);
+               switch (i) {
+               case 3:
+               case 5:
+               case 7:
+               case 9:
+                       *p++ = '-';
+                       break;
+               }
+       }
+
+       *p = 0;
+
+       if (uc) {
+               p = uuid;
+               do {
+                       *p = toupper(*p);
+               } while (*(++p));
+       }
+
+       return string(buf, end, uuid, spec);
+}
+
 /*
  * Show a '%p' thing.  A kernel extension is that the '%p' is followed
  * by an extra set of alphanumeric characters that are extended format
@@ -866,6 +904,18 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,
  *       IPv4 uses dot-separated decimal with leading 0's (010.123.045.006)
  * - 'I6c' for IPv6 addresses printed as specified by
  *       http://www.ietf.org/id/draft-kawamura-ipv6-text-representation-03.txt
+ * - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form
+ *       "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+ *       Options for %pU are:
+ *         b big endian lower case hex (default)
+ *         B big endian UPPER case hex
+ *         l little endian lower case hex
+ *         L little endian UPPER case hex
+ *           big endian output byte order is:
+ *             [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15]
+ *           little endian output byte order is:
+ *             [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15]
+ *
  * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
  * function pointers are really function descriptors, which contain a
  * pointer to the real address.
@@ -880,9 +930,9 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
        case 'F':
        case 'f':
                ptr = dereference_function_descriptor(ptr);
-       case 's':
                /* Fallthrough */
        case 'S':
+       case 's':
                return symbol_string(buf, end, ptr, spec, *fmt);
        case 'R':
        case 'r':
@@ -906,6 +956,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
                        return ip4_addr_string(buf, end, ptr, spec, fmt);
                }
                break;
+       case 'U':
+               return uuid_string(buf, end, ptr, spec, fmt);
        }
        spec.flags |= SMALL;
        if (spec.field_width == -1) {
@@ -1023,8 +1075,8 @@ precision:
 qualifier:
        /* get the conversion qualifier */
        spec->qualifier = -1;
-       if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
-           *fmt == 'Z' || *fmt == 'z' || *fmt == 't') {
+       if (*fmt == 'h' || TOLOWER(*fmt) == 'l' ||
+           TOLOWER(*fmt) == 'z' || *fmt == 't') {
                spec->qualifier = *fmt++;
                if (unlikely(spec->qualifier == *fmt)) {
                        if (spec->qualifier == 'l') {
@@ -1091,7 +1143,7 @@ qualifier:
                        spec->type = FORMAT_TYPE_LONG;
                else
                        spec->type = FORMAT_TYPE_ULONG;
-       } else if (spec->qualifier == 'Z' || spec->qualifier == 'z') {
+       } else if (TOLOWER(spec->qualifier) == 'z') {
                spec->type = FORMAT_TYPE_SIZE_T;
        } else if (spec->qualifier == 't') {
                spec->type = FORMAT_TYPE_PTRDIFF;
@@ -1127,7 +1179,18 @@ qualifier:
  * %ps output the name of a text symbol without offset
  * %pF output the name of a function pointer with its offset
  * %pf output the name of a function pointer without its offset
- * %pR output the address range in a struct resource
+ * %pR output the address range in a struct resource with decoded flags
+ * %pr output the address range in a struct resource with raw flags
+ * %pM output a 6-byte MAC address with colons
+ * %pm output a 6-byte MAC address without colons
+ * %pI4 print an IPv4 address without leading zeros
+ * %pi4 print an IPv4 address with leading zeros
+ * %pI6 print an IPv6 address with colons
+ * %pi6 print an IPv6 address without colons
+ * %pI6c print an IPv6 address as specified by
+ *   http://www.ietf.org/id/draft-kawamura-ipv6-text-representation-03.txt
+ * %pU[bBlL] print a UUID/GUID in big or little endian using lower or upper
+ *   case.
  * %n is ignored
  *
  * The return value is the number of characters which would
@@ -1144,8 +1207,7 @@ qualifier:
 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 {
        unsigned long long num;
-       char *str, *end, c;
-       int read;
+       char *str, *end;
        struct printf_spec spec = {0};
 
        /* Reject out-of-range values early.  Large positive sizes are
@@ -1164,8 +1226,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 
        while (*fmt) {
                const char *old_fmt = fmt;
-
-               read = format_decode(fmt, &spec);
+               int read = format_decode(fmt, &spec);
 
                fmt += read;
 
@@ -1189,7 +1250,9 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
                        spec.precision = va_arg(args, int);
                        break;
 
-               case FORMAT_TYPE_CHAR:
+               case FORMAT_TYPE_CHAR: {
+                       char c;
+
                        if (!(spec.flags & LEFT)) {
                                while (--spec.field_width > 0) {
                                        if (str < end)
@@ -1208,6 +1271,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
                                ++str;
                        }
                        break;
+               }
 
                case FORMAT_TYPE_STR:
                        str = string(str, end, va_arg(args, char *), spec);
@@ -1238,8 +1302,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
                        if (qualifier == 'l') {
                                long *ip = va_arg(args, long *);
                                *ip = (str - buf);
-                       } else if (qualifier == 'Z' ||
-                                       qualifier == 'z') {
+                       } else if (TOLOWER(qualifier) == 'z') {
                                size_t *ip = va_arg(args, size_t *);
                                *ip = (str - buf);
                        } else {
@@ -1322,7 +1385,8 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
 {
        int i;
 
-       i=vsnprintf(buf,size,fmt,args);
+       i = vsnprintf(buf, size, fmt, args);
+
        return (i >= size) ? (size - 1) : i;
 }
 EXPORT_SYMBOL(vscnprintf);
@@ -1341,14 +1405,15 @@ EXPORT_SYMBOL(vscnprintf);
  *
  * See the vsnprintf() documentation for format string extensions over C99.
  */
-int snprintf(char * buf, size_t size, const char *fmt, ...)
+int snprintf(char *buf, size_t size, const char *fmt, ...)
 {
        va_list args;
        int i;
 
        va_start(args, fmt);
-       i=vsnprintf(buf,size,fmt,args);
+       i = vsnprintf(buf, size, fmt, args);
        va_end(args);
+
        return i;
 }
 EXPORT_SYMBOL(snprintf);
@@ -1364,7 +1429,7 @@ EXPORT_SYMBOL(snprintf);
  * the trailing '\0'. If @size is <= 0 the function returns 0.
  */
 
-int scnprintf(char * buf, size_t size, const char *fmt, ...)
+int scnprintf(char *buf, size_t size, const char *fmt, ...)
 {
        va_list args;
        int i;
@@ -1372,6 +1437,7 @@ int scnprintf(char * buf, size_t size, const char *fmt, ...)
        va_start(args, fmt);
        i = vsnprintf(buf, size, fmt, args);
        va_end(args);
+
        return (i >= size) ? (size - 1) : i;
 }
 EXPORT_SYMBOL(scnprintf);
@@ -1409,14 +1475,15 @@ EXPORT_SYMBOL(vsprintf);
  *
  * See the vsnprintf() documentation for format string extensions over C99.
  */
-int sprintf(char * buf, const char *fmt, ...)
+int sprintf(char *buf, const char *fmt, ...)
 {
        va_list args;
        int i;
 
        va_start(args, fmt);
-       i=vsnprintf(buf, INT_MAX, fmt, args);
+       i = vsnprintf(buf, INT_MAX, fmt, args);
        va_end(args);
+
        return i;
 }
 EXPORT_SYMBOL(sprintf);
@@ -1449,7 +1516,6 @@ int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args)
 {
        struct printf_spec spec = {0};
        char *str, *end;
-       int read;
 
        str = (char *)bin_buf;
        end = (char *)(bin_buf + size);
@@ -1474,14 +1540,15 @@ do {                                                                    \
        str += sizeof(type);                                            \
 } while (0)
 
-
        while (*fmt) {
-               read = format_decode(fmt, &spec);
+               int read = format_decode(fmt, &spec);
 
                fmt += read;
 
                switch (spec.type) {
                case FORMAT_TYPE_NONE:
+               case FORMAT_TYPE_INVALID:
+               case FORMAT_TYPE_PERCENT_CHAR:
                        break;
 
                case FORMAT_TYPE_WIDTH:
@@ -1496,13 +1563,14 @@ do {                                                                    \
                case FORMAT_TYPE_STR: {
                        const char *save_str = va_arg(args, char *);
                        size_t len;
+
                        if ((unsigned long)save_str > (unsigned long)-PAGE_SIZE
                                        || (unsigned long)save_str < PAGE_SIZE)
-                               save_str = "<NULL>";
-                       len = strlen(save_str);
-                       if (str + len + 1 < end)
-                               memcpy(str, save_str, len + 1);
-                       str += len + 1;
+                               save_str = "(null)";
+                       len = strlen(save_str) + 1;
+                       if (str + len < end)
+                               memcpy(str, save_str, len);
+                       str += len;
                        break;
                }
 
@@ -1513,19 +1581,13 @@ do {                                                                    \
                                fmt++;
                        break;
 
-               case FORMAT_TYPE_PERCENT_CHAR:
-                       break;
-
-               case FORMAT_TYPE_INVALID:
-                       break;
-
                case FORMAT_TYPE_NRCHARS: {
                        /* skip %n 's argument */
                        int qualifier = spec.qualifier;
                        void *skip_arg;
                        if (qualifier == 'l')
                                skip_arg = va_arg(args, long *);
-                       else if (qualifier == 'Z' || qualifier == 'z')
+                       else if (TOLOWER(qualifier) == 'z')
                                skip_arg = va_arg(args, size_t *);
                        else
                                skip_arg = va_arg(args, int *);
@@ -1561,8 +1623,8 @@ do {                                                                      \
                        }
                }
        }
-       return (u32 *)(PTR_ALIGN(str, sizeof(u32))) - bin_buf;
 
+       return (u32 *)(PTR_ALIGN(str, sizeof(u32))) - bin_buf;
 #undef save_arg
 }
 EXPORT_SYMBOL_GPL(vbin_printf);
@@ -1591,11 +1653,9 @@ EXPORT_SYMBOL_GPL(vbin_printf);
  */
 int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
 {
-       unsigned long long num;
-       char *str, *end, c;
-       const char *args = (const char *)bin_buf;
-
        struct printf_spec spec = {0};
+       char *str, *end;
+       const char *args = (const char *)bin_buf;
 
        if (WARN_ON_ONCE((int) size < 0))
                return 0;
@@ -1625,10 +1685,8 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
        }
 
        while (*fmt) {
-               int read;
                const char *old_fmt = fmt;
-
-               read = format_decode(fmt, &spec);
+               int read = format_decode(fmt, &spec);
 
                fmt += read;
 
@@ -1652,7 +1710,9 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
                        spec.precision = get_arg(int);
                        break;
 
-               case FORMAT_TYPE_CHAR:
+               case FORMAT_TYPE_CHAR: {
+                       char c;
+
                        if (!(spec.flags & LEFT)) {
                                while (--spec.field_width > 0) {
                                        if (str < end)
@@ -1670,11 +1730,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
                                ++str;
                        }
                        break;
+               }
 
                case FORMAT_TYPE_STR: {
                        const char *str_arg = args;
-                       size_t len = strlen(str_arg);
-                       args += len + 1;
+                       args += strlen(str_arg) + 1;
                        str = string(str, end, (char *)str_arg, spec);
                        break;
                }
@@ -1686,11 +1746,6 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
                        break;
 
                case FORMAT_TYPE_PERCENT_CHAR:
-                       if (str < end)
-                               *str = '%';
-                       ++str;
-                       break;
-
                case FORMAT_TYPE_INVALID:
                        if (str < end)
                                *str = '%';
@@ -1701,15 +1756,15 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
                        /* skip */
                        break;
 
-               default:
+               default: {
+                       unsigned long long num;
+
                        switch (spec.type) {
 
                        case FORMAT_TYPE_LONG_LONG:
                                num = get_arg(long long);
                                break;
                        case FORMAT_TYPE_ULONG:
-                               num = get_arg(unsigned long);
-                               break;
                        case FORMAT_TYPE_LONG:
                                num = get_arg(unsigned long);
                                break;
@@ -1739,8 +1794,9 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
                        }
 
                        str = number(str, end, num, spec);
-               }
-       }
+               } /* default: */
+               } /* switch(spec.type) */
+       } /* while(*fmt) */
 
        if (size > 0) {
                if (str < end)
@@ -1774,6 +1830,7 @@ int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...)
        va_start(args, fmt);
        ret = vbin_printf(bin_buf, size, fmt, args);
        va_end(args);
+
        return ret;
 }
 EXPORT_SYMBOL_GPL(bprintf);
@@ -1786,27 +1843,23 @@ EXPORT_SYMBOL_GPL(bprintf);
  * @fmt:       format of buffer
  * @args:      arguments
  */
-int vsscanf(const char * buf, const char * fmt, va_list args)
+int vsscanf(const char *buf, const char *fmt, va_list args)
 {
        const char *str = buf;
        char *next;
        char digit;
        int num = 0;
-       int qualifier;
-       int base;
-       int field_width;
-       int is_sign = 0;
+       int qualifier, base, field_width;
+       bool is_sign;
 
-       while(*fmt && *str) {
+       while (*fmt && *str) {
                /* skip any white space in format */
                /* white space in format matchs any amount of
                 * white space, including none, in the input.
                 */
                if (isspace(*fmt)) {
-                       while (isspace(*fmt))
-                               ++fmt;
-                       while (isspace(*str))
-                               ++str;
+                       fmt = skip_spaces(++fmt);
+                       str = skip_spaces(str);
                }
 
                /* anything that is not a conversion must match exactly */
@@ -1819,7 +1872,7 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
                if (!*fmt)
                        break;
                ++fmt;
-               
+
                /* skip this conversion.
                 * advance both strings to next white space
                 */
@@ -1838,8 +1891,8 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
 
                /* get conversion qualifier */
                qualifier = -1;
-               if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
-                   *fmt == 'Z' || *fmt == 'z') {
+               if (*fmt == 'h' || TOLOWER(*fmt) == 'l' ||
+                   TOLOWER(*fmt) == 'z') {
                        qualifier = *fmt++;
                        if (unlikely(qualifier == *fmt)) {
                                if (qualifier == 'h') {
@@ -1851,16 +1904,17 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
                                }
                        }
                }
-               base = 10;
-               is_sign = 0;
 
                if (!*fmt || !*str)
                        break;
 
-               switch(*fmt++) {
+               base = 10;
+               is_sign = 0;
+
+               switch (*fmt++) {
                case 'c':
                {
-                       char *s = (char *) va_arg(args,char*);
+                       char *s = (char *)va_arg(args, char*);
                        if (field_width == -1)
                                field_width = 1;
                        do {
@@ -1871,17 +1925,15 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
                continue;
                case 's':
                {
-                       char *s = (char *) va_arg(args, char *);
-                       if(field_width == -1)
+                       char *s = (char *)va_arg(args, char *);
+                       if (field_width == -1)
                                field_width = INT_MAX;
                        /* first, skip leading white space in buffer */
-                       while (isspace(*str))
-                               str++;
+                       str = skip_spaces(str);
 
                        /* now copy until next white space */
-                       while (*str && !isspace(*str) && field_width--) {
+                       while (*str && !isspace(*str) && field_width--)
                                *s++ = *str++;
-                       }
                        *s = '\0';
                        num++;
                }
@@ -1889,7 +1941,7 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
                case 'n':
                        /* return number of characters read so far */
                {
-                       int *i = (int *)va_arg(args,int*);
+                       int *i = (int *)va_arg(args, int*);
                        *i = str - buf;
                }
                continue;
@@ -1901,14 +1953,14 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
                        base = 16;
                        break;
                case 'i':
-                        base = 0;
+                       base = 0;
                case 'd':
                        is_sign = 1;
                case 'u':
                        break;
                case '%':
                        /* looking for '%' in str */
-                       if (*str++ != '%') 
+                       if (*str++ != '%')
                                return num;
                        continue;
                default:
@@ -1919,71 +1971,70 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
                /* have some sort of integer conversion.
                 * first, skip white space in buffer.
                 */
-               while (isspace(*str))
-                       str++;
+               str = skip_spaces(str);
 
                digit = *str;
                if (is_sign && digit == '-')
                        digit = *(str + 1);
 
                if (!digit
-                    || (base == 16 && !isxdigit(digit))
-                    || (base == 10 && !isdigit(digit))
-                    || (base == 8 && (!isdigit(digit) || digit > '7'))
-                    || (base == 0 && !isdigit(digit)))
-                               break;
+                   || (base == 16 && !isxdigit(digit))
+                   || (base == 10 && !isdigit(digit))
+                   || (base == 8 && (!isdigit(digit) || digit > '7'))
+                   || (base == 0 && !isdigit(digit)))
+                       break;
 
-               switch(qualifier) {
+               switch (qualifier) {
                case 'H':       /* that's 'hh' in format */
                        if (is_sign) {
-                               signed char *s = (signed char *) va_arg(args,signed char *);
-                               *s = (signed char) simple_strtol(str,&next,base);
+                               signed char *s = (signed char *)va_arg(args, signed char *);
+                               *s = (signed char)simple_strtol(str, &next, base);
                        } else {
-                               unsigned char *s = (unsigned char *) va_arg(args, unsigned char *);
-                               *s = (unsigned char) simple_strtoul(str, &next, base);
+                               unsigned char *s = (unsigned char *)va_arg(args, unsigned char *);
+                               *s = (unsigned char)simple_strtoul(str, &next, base);
                        }
                        break;
                case 'h':
                        if (is_sign) {
-                               short *s = (short *) va_arg(args,short *);
-                               *s = (short) simple_strtol(str,&next,base);
+                               short *s = (short *)va_arg(args, short *);
+                               *s = (short)simple_strtol(str, &next, base);
                        } else {
-                               unsigned short *s = (unsigned short *) va_arg(args, unsigned short *);
-                               *s = (unsigned short) simple_strtoul(str, &next, base);
+                               unsigned short *s = (unsigned short *)va_arg(args, unsigned short *);
+                               *s = (unsigned short)simple_strtoul(str, &next, base);
                        }
                        break;
                case 'l':
                        if (is_sign) {
-                               long *l = (long *) va_arg(args,long *);
-                               *l = simple_strtol(str,&next,base);
+                               long *l = (long *)va_arg(args, long *);
+                               *l = simple_strtol(str, &next, base);
                        } else {
-                               unsigned long *l = (unsigned long*) va_arg(args,unsigned long*);
-                               *l = simple_strtoul(str,&next,base);
+                               unsigned long *l = (unsigned long *)va_arg(args, unsigned long *);
+                               *l = simple_strtoul(str, &next, base);
                        }
                        break;
                case 'L':
                        if (is_sign) {
-                               long long *l = (long long*) va_arg(args,long long *);
-                               *l = simple_strtoll(str,&next,base);
+                               long long *l = (long long *)va_arg(args, long long *);
+                               *l = simple_strtoll(str, &next, base);
                        } else {
-                               unsigned long long *l = (unsigned long long*) va_arg(args,unsigned long long*);
-                               *l = simple_strtoull(str,&next,base);
+                               unsigned long long *l = (unsigned long long *)va_arg(args, unsigned long long *);
+                               *l = simple_strtoull(str, &next, base);
                        }
                        break;
                case 'Z':
                case 'z':
                {
-                       size_t *s = (size_t*) va_arg(args,size_t*);
-                       *s = (size_t) simple_strtoul(str,&next,base);
+                       size_t *s = (size_t *)va_arg(args, size_t *);
+                       *s = (size_t)simple_strtoul(str, &next, base);
                }
                break;
                default:
                        if (is_sign) {
-                               int *i = (int *) va_arg(args, int*);
-                               *i = (int) simple_strtol(str,&next,base);
+                               int *i = (int *)va_arg(args, int *);
+                               *i = (int)simple_strtol(str, &next, base);
                        } else {
-                               unsigned int *i = (unsigned int*) va_arg(args, unsigned int*);
-                               *i = (unsigned int) simple_strtoul(str,&next,base);
+                               unsigned int *i = (unsigned int *)va_arg(args, unsigned int*);
+                               *i = (unsigned int)simple_strtoul(str, &next, base);
                        }
                        break;
                }
@@ -2014,14 +2065,15 @@ EXPORT_SYMBOL(vsscanf);
  * @fmt:       formatting of buffer
  * @...:       resulting arguments
  */
-int sscanf(const char * buf, const char * fmt, ...)
+int sscanf(const char *buf, const char *fmt, ...)
 {
        va_list args;
        int i;
 
-       va_start(args,fmt);
-       i = vsscanf(buf,fmt,args);
+       va_start(args, fmt);
+       i = vsscanf(buf, fmt, args);
        va_end(args);
+
        return i;
 }
 EXPORT_SYMBOL(sscanf);
index 44cf6f0a3a6d34f1cdf90a0f4e65dabf3b9c0623..17b8947aa7daff59f0a92713f1fe97c8cf9fa721 100644 (file)
@@ -158,11 +158,13 @@ config PAGEFLAGS_EXTENDED
 # Default to 4 for wider testing, though 8 might be more appropriate.
 # ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock.
 # PA-RISC 7xxx's spinlock_t would enlarge struct page from 32 to 44 bytes.
+# DEBUG_SPINLOCK and DEBUG_LOCK_ALLOC spinlock_t also enlarge struct page.
 #
 config SPLIT_PTLOCK_CPUS
        int
-       default "4096" if ARM && !CPU_CACHE_VIPT
-       default "4096" if PARISC && !PA20
+       default "999999" if ARM && !CPU_CACHE_VIPT
+       default "999999" if PARISC && !PA20
+       default "999999" if DEBUG_SPINLOCK || DEBUG_LOCK_ALLOC
        default "4"
 
 #
@@ -200,14 +202,6 @@ config VIRT_TO_BUS
        def_bool y
        depends on !ARCH_NO_VIRT_TO_BUS
 
-config HAVE_MLOCK
-       bool
-       default y if MMU=y
-
-config HAVE_MLOCKED_PAGE_BIT
-       bool
-       default y if HAVE_MLOCK=y
-
 config MMU_NOTIFIER
        bool
 
@@ -218,7 +212,7 @@ config KSM
          Enable Kernel Samepage Merging: KSM periodically scans those areas
          of an application's address space that an app has advised may be
          mergeable.  When it finds pages of identical content, it replaces
-         the many instances by a single resident page with that content, so
+         the many instances by a single page with that content, so
          saving memory until one or another app needs to modify the content.
          Recommended for use with KVM, or with other duplicative applications.
          See Documentation/vm/ksm.txt for more information: KSM is inactive
@@ -227,6 +221,7 @@ config KSM
 
 config DEFAULT_MMAP_MIN_ADDR
         int "Low address space to protect from user allocation"
+       depends on MMU
         default 4096
         help
          This is the portion of low virtual memory which should be protected
@@ -257,8 +252,9 @@ config MEMORY_FAILURE
          special hardware support and typically ECC memory.
 
 config HWPOISON_INJECT
-       tristate "Poison pages injector"
-       depends on MEMORY_FAILURE && DEBUG_KERNEL
+       tristate "HWPoison pages injector"
+       depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
+       select PROC_PAGE_MONITOR
 
 config NOMMU_INITIAL_TRIM_EXCESS
        int "Turn on mmap() excess space trimming before booting"
index 82131d0f8d85fbfb007e084e882333771dd47c10..7a68d2ab556093ab3398cbb95d8386c65357e07a 100644 (file)
@@ -22,7 +22,6 @@ obj-$(CONFIG_HUGETLBFS)       += hugetlb.o
 obj-$(CONFIG_NUMA)     += mempolicy.o
 obj-$(CONFIG_SPARSEMEM)        += sparse.o
 obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o
-obj-$(CONFIG_TMPFS_POSIX_ACL) += shmem_acl.o
 obj-$(CONFIG_SLOB) += slob.o
 obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
 obj-$(CONFIG_KSM) += ksm.o
index d1dc23cc7f10e78e9598c87c70337bd3d2577d6a..7d1486875e1cc04c1297b4cbb2743412dd553025 100644 (file)
@@ -432,8 +432,8 @@ int __init reserve_bootmem(unsigned long addr, unsigned long size,
        return mark_bootmem(start, end, 1, flags);
 }
 
-static unsigned long align_idx(struct bootmem_data *bdata, unsigned long idx,
-                       unsigned long step)
+static unsigned long __init align_idx(struct bootmem_data *bdata,
+                                     unsigned long idx, unsigned long step)
 {
        unsigned long base = bdata->node_min_pfn;
 
@@ -445,8 +445,8 @@ static unsigned long align_idx(struct bootmem_data *bdata, unsigned long idx,
        return ALIGN(base + idx, step) - base;
 }
 
-static unsigned long align_off(struct bootmem_data *bdata, unsigned long off,
-                       unsigned long align)
+static unsigned long __init align_off(struct bootmem_data *bdata,
+                                     unsigned long off, unsigned long align)
 {
        unsigned long base = PFN_PHYS(bdata->node_min_pfn);
 
index 8b4d88f9249ee848c82080a0341e80cbd5c92588..96ac6b0eb6cb2e542f52d13d99d544a986dfde28 100644 (file)
@@ -2240,7 +2240,6 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
                size_t count, ssize_t written)
 {
        struct file *file = iocb->ki_filp;
-       struct address_space *mapping = file->f_mapping;
        ssize_t status;
        struct iov_iter i;
 
@@ -2252,15 +2251,6 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
                *ppos = pos + status;
        }
        
-       /*
-        * If we get here for O_DIRECT writes then we must have fallen through
-        * to buffered writes (block instantiation inside i_size).  So we sync
-        * the file data here, to try to honour O_DIRECT expectations.
-        */
-       if (unlikely(file->f_flags & O_DIRECT) && written)
-               status = filemap_write_and_wait_range(mapping,
-                                       pos, pos + written - 1);
-
        return written ? written : status;
 }
 EXPORT_SYMBOL(generic_file_buffered_write);
@@ -2359,10 +2349,7 @@ ssize_t __generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
                 * semantics.
                 */
                endbyte = pos + written_buffered - written - 1;
-               err = do_sync_mapping_range(file->f_mapping, pos, endbyte,
-                                           SYNC_FILE_RANGE_WAIT_BEFORE|
-                                           SYNC_FILE_RANGE_WRITE|
-                                           SYNC_FILE_RANGE_WAIT_AFTER);
+               err = filemap_write_and_wait_range(file->f_mapping, pos, endbyte);
                if (err == 0) {
                        written = written_buffered;
                        invalidate_mapping_pages(mapping,
index 5d7601b0287487321314c1d969f17425b339f9b1..65f38c218207231e0bf5b612ccacc5858be1b4e0 100644 (file)
@@ -24,6 +24,7 @@
 #include <asm/io.h>
 
 #include <linux/hugetlb.h>
+#include <linux/node.h>
 #include "internal.h"
 
 const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
@@ -622,42 +623,66 @@ static struct page *alloc_fresh_huge_page_node(struct hstate *h, int nid)
 }
 
 /*
- * Use a helper variable to find the next node and then
- * copy it back to next_nid_to_alloc afterwards:
- * otherwise there's a window in which a racer might
- * pass invalid nid MAX_NUMNODES to alloc_pages_exact_node.
- * But we don't need to use a spin_lock here: it really
- * doesn't matter if occasionally a racer chooses the
- * same nid as we do.  Move nid forward in the mask even
- * if we just successfully allocated a hugepage so that
- * the next caller gets hugepages on the next node.
+ * common helper functions for hstate_next_node_to_{alloc|free}.
+ * We may have allocated or freed a huge page based on a different
+ * nodes_allowed previously, so h->next_node_to_{alloc|free} might
+ * be outside of *nodes_allowed.  Ensure that we use an allowed
+ * node for alloc or free.
  */
-static int hstate_next_node_to_alloc(struct hstate *h)
+static int next_node_allowed(int nid, nodemask_t *nodes_allowed)
 {
-       int next_nid;
-       next_nid = next_node(h->next_nid_to_alloc, node_online_map);
-       if (next_nid == MAX_NUMNODES)
-               next_nid = first_node(node_online_map);
-       h->next_nid_to_alloc = next_nid;
-       return next_nid;
+       nid = next_node(nid, *nodes_allowed);
+       if (nid == MAX_NUMNODES)
+               nid = first_node(*nodes_allowed);
+       VM_BUG_ON(nid >= MAX_NUMNODES);
+
+       return nid;
+}
+
+static int get_valid_node_allowed(int nid, nodemask_t *nodes_allowed)
+{
+       if (!node_isset(nid, *nodes_allowed))
+               nid = next_node_allowed(nid, nodes_allowed);
+       return nid;
+}
+
+/*
+ * returns the previously saved node ["this node"] from which to
+ * allocate a persistent huge page for the pool and advance the
+ * next node from which to allocate, handling wrap at end of node
+ * mask.
+ */
+static int hstate_next_node_to_alloc(struct hstate *h,
+                                       nodemask_t *nodes_allowed)
+{
+       int nid;
+
+       VM_BUG_ON(!nodes_allowed);
+
+       nid = get_valid_node_allowed(h->next_nid_to_alloc, nodes_allowed);
+       h->next_nid_to_alloc = next_node_allowed(nid, nodes_allowed);
+
+       return nid;
 }
 
-static int alloc_fresh_huge_page(struct hstate *h)
+static int alloc_fresh_huge_page(struct hstate *h, nodemask_t *nodes_allowed)
 {
        struct page *page;
        int start_nid;
        int next_nid;
        int ret = 0;
 
-       start_nid = h->next_nid_to_alloc;
+       start_nid = hstate_next_node_to_alloc(h, nodes_allowed);
        next_nid = start_nid;
 
        do {
                page = alloc_fresh_huge_page_node(h, next_nid);
-               if (page)
+               if (page) {
                        ret = 1;
-               next_nid = hstate_next_node_to_alloc(h);
-       } while (!page && next_nid != start_nid);
+                       break;
+               }
+               next_nid = hstate_next_node_to_alloc(h, nodes_allowed);
+       } while (next_nid != start_nid);
 
        if (ret)
                count_vm_event(HTLB_BUDDY_PGALLOC);
@@ -668,17 +693,21 @@ static int alloc_fresh_huge_page(struct hstate *h)
 }
 
 /*
- * helper for free_pool_huge_page() - find next node
- * from which to free a huge page
+ * helper for free_pool_huge_page() - return the previously saved
+ * node ["this node"] from which to free a huge page.  Advance the
+ * next node id whether or not we find a free huge page to free so
+ * that the next attempt to free addresses the next node.
  */
-static int hstate_next_node_to_free(struct hstate *h)
+static int hstate_next_node_to_free(struct hstate *h, nodemask_t *nodes_allowed)
 {
-       int next_nid;
-       next_nid = next_node(h->next_nid_to_free, node_online_map);
-       if (next_nid == MAX_NUMNODES)
-               next_nid = first_node(node_online_map);
-       h->next_nid_to_free = next_nid;
-       return next_nid;
+       int nid;
+
+       VM_BUG_ON(!nodes_allowed);
+
+       nid = get_valid_node_allowed(h->next_nid_to_free, nodes_allowed);
+       h->next_nid_to_free = next_node_allowed(nid, nodes_allowed);
+
+       return nid;
 }
 
 /*
@@ -687,13 +716,14 @@ static int hstate_next_node_to_free(struct hstate *h)
  * balanced over allowed nodes.
  * Called with hugetlb_lock locked.
  */
-static int free_pool_huge_page(struct hstate *h, bool acct_surplus)
+static int free_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed,
+                                                        bool acct_surplus)
 {
        int start_nid;
        int next_nid;
        int ret = 0;
 
-       start_nid = h->next_nid_to_free;
+       start_nid = hstate_next_node_to_free(h, nodes_allowed);
        next_nid = start_nid;
 
        do {
@@ -715,9 +745,10 @@ static int free_pool_huge_page(struct hstate *h, bool acct_surplus)
                        }
                        update_and_free_page(h, page);
                        ret = 1;
+                       break;
                }
-               next_nid = hstate_next_node_to_free(h);
-       } while (!ret && next_nid != start_nid);
+               next_nid = hstate_next_node_to_free(h, nodes_allowed);
+       } while (next_nid != start_nid);
 
        return ret;
 }
@@ -911,14 +942,14 @@ static void return_unused_surplus_pages(struct hstate *h,
 
        /*
         * We want to release as many surplus pages as possible, spread
-        * evenly across all nodes. Iterate across all nodes until we
-        * can no longer free unreserved surplus pages. This occurs when
-        * the nodes with surplus pages have no free pages.
-        * free_pool_huge_page() will balance the the frees across the
-        * on-line nodes for us and will handle the hstate accounting.
+        * evenly across all nodes with memory. Iterate across these nodes
+        * until we can no longer free unreserved surplus pages. This occurs
+        * when the nodes with surplus pages have no free pages.
+        * free_pool_huge_page() will balance the the freed pages across the
+        * on-line nodes with memory and will handle the hstate accounting.
         */
        while (nr_pages--) {
-               if (!free_pool_huge_page(h, 1))
+               if (!free_pool_huge_page(h, &node_states[N_HIGH_MEMORY], 1))
                        break;
        }
 }
@@ -1022,16 +1053,16 @@ static struct page *alloc_huge_page(struct vm_area_struct *vma,
 int __weak alloc_bootmem_huge_page(struct hstate *h)
 {
        struct huge_bootmem_page *m;
-       int nr_nodes = nodes_weight(node_online_map);
+       int nr_nodes = nodes_weight(node_states[N_HIGH_MEMORY]);
 
        while (nr_nodes) {
                void *addr;
 
                addr = __alloc_bootmem_node_nopanic(
-                               NODE_DATA(h->next_nid_to_alloc),
+                               NODE_DATA(hstate_next_node_to_alloc(h,
+                                               &node_states[N_HIGH_MEMORY])),
                                huge_page_size(h), huge_page_size(h), 0);
 
-               hstate_next_node_to_alloc(h);
                if (addr) {
                        /*
                         * Use the beginning of the huge page to store the
@@ -1084,7 +1115,8 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h)
                if (h->order >= MAX_ORDER) {
                        if (!alloc_bootmem_huge_page(h))
                                break;
-               } else if (!alloc_fresh_huge_page(h))
+               } else if (!alloc_fresh_huge_page(h,
+                                        &node_states[N_HIGH_MEMORY]))
                        break;
        }
        h->max_huge_pages = i;
@@ -1126,14 +1158,15 @@ static void __init report_hugepages(void)
 }
 
 #ifdef CONFIG_HIGHMEM
-static void try_to_free_low(struct hstate *h, unsigned long count)
+static void try_to_free_low(struct hstate *h, unsigned long count,
+                                               nodemask_t *nodes_allowed)
 {
        int i;
 
        if (h->order >= MAX_ORDER)
                return;
 
-       for (i = 0; i < MAX_NUMNODES; ++i) {
+       for_each_node_mask(i, *nodes_allowed) {
                struct page *page, *next;
                struct list_head *freel = &h->hugepage_freelists[i];
                list_for_each_entry_safe(page, next, freel, lru) {
@@ -1149,7 +1182,8 @@ static void try_to_free_low(struct hstate *h, unsigned long count)
        }
 }
 #else
-static inline void try_to_free_low(struct hstate *h, unsigned long count)
+static inline void try_to_free_low(struct hstate *h, unsigned long count,
+                                               nodemask_t *nodes_allowed)
 {
 }
 #endif
@@ -1159,7 +1193,8 @@ static inline void try_to_free_low(struct hstate *h, unsigned long count)
  * balanced by operating on them in a round-robin fashion.
  * Returns 1 if an adjustment was made.
  */
-static int adjust_pool_surplus(struct hstate *h, int delta)
+static int adjust_pool_surplus(struct hstate *h, nodemask_t *nodes_allowed,
+                               int delta)
 {
        int start_nid, next_nid;
        int ret = 0;
@@ -1167,29 +1202,33 @@ static int adjust_pool_surplus(struct hstate *h, int delta)
        VM_BUG_ON(delta != -1 && delta != 1);
 
        if (delta < 0)
-               start_nid = h->next_nid_to_alloc;
+               start_nid = hstate_next_node_to_alloc(h, nodes_allowed);
        else
-               start_nid = h->next_nid_to_free;
+               start_nid = hstate_next_node_to_free(h, nodes_allowed);
        next_nid = start_nid;
 
        do {
                int nid = next_nid;
                if (delta < 0)  {
-                       next_nid = hstate_next_node_to_alloc(h);
                        /*
                         * To shrink on this node, there must be a surplus page
                         */
-                       if (!h->surplus_huge_pages_node[nid])
+                       if (!h->surplus_huge_pages_node[nid]) {
+                               next_nid = hstate_next_node_to_alloc(h,
+                                                               nodes_allowed);
                                continue;
+                       }
                }
                if (delta > 0) {
-                       next_nid = hstate_next_node_to_free(h);
                        /*
                         * Surplus cannot exceed the total number of pages
                         */
                        if (h->surplus_huge_pages_node[nid] >=
-                                               h->nr_huge_pages_node[nid])
+                                               h->nr_huge_pages_node[nid]) {
+                               next_nid = hstate_next_node_to_free(h,
+                                                               nodes_allowed);
                                continue;
+                       }
                }
 
                h->surplus_huge_pages += delta;
@@ -1202,7 +1241,8 @@ static int adjust_pool_surplus(struct hstate *h, int delta)
 }
 
 #define persistent_huge_pages(h) (h->nr_huge_pages - h->surplus_huge_pages)
-static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count)
+static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count,
+                                               nodemask_t *nodes_allowed)
 {
        unsigned long min_count, ret;
 
@@ -1222,7 +1262,7 @@ static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count)
         */
        spin_lock(&hugetlb_lock);
        while (h->surplus_huge_pages && count > persistent_huge_pages(h)) {
-               if (!adjust_pool_surplus(h, -1))
+               if (!adjust_pool_surplus(h, nodes_allowed, -1))
                        break;
        }
 
@@ -1233,11 +1273,14 @@ static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count)
                 * and reducing the surplus.
                 */
                spin_unlock(&hugetlb_lock);
-               ret = alloc_fresh_huge_page(h);
+               ret = alloc_fresh_huge_page(h, nodes_allowed);
                spin_lock(&hugetlb_lock);
                if (!ret)
                        goto out;
 
+               /* Bail for signals. Probably ctrl-c from user */
+               if (signal_pending(current))
+                       goto out;
        }
 
        /*
@@ -1257,13 +1300,13 @@ static unsigned long set_max_huge_pages(struct hstate *h, unsigned long count)
         */
        min_count = h->resv_huge_pages + h->nr_huge_pages - h->free_huge_pages;
        min_count = max(count, min_count);
-       try_to_free_low(h, min_count);
+       try_to_free_low(h, min_count, nodes_allowed);
        while (min_count < persistent_huge_pages(h)) {
-               if (!free_pool_huge_page(h, 0))
+               if (!free_pool_huge_page(h, nodes_allowed, 0))
                        break;
        }
        while (count < persistent_huge_pages(h)) {
-               if (!adjust_pool_surplus(h, 1))
+               if (!adjust_pool_surplus(h, nodes_allowed, 1))
                        break;
        }
 out:
@@ -1282,43 +1325,117 @@ out:
 static struct kobject *hugepages_kobj;
 static struct kobject *hstate_kobjs[HUGE_MAX_HSTATE];
 
-static struct hstate *kobj_to_hstate(struct kobject *kobj)
+static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp);
+
+static struct hstate *kobj_to_hstate(struct kobject *kobj, int *nidp)
 {
        int i;
+
        for (i = 0; i < HUGE_MAX_HSTATE; i++)
-               if (hstate_kobjs[i] == kobj)
+               if (hstate_kobjs[i] == kobj) {
+                       if (nidp)
+                               *nidp = NUMA_NO_NODE;
                        return &hstates[i];
-       BUG();
-       return NULL;
+               }
+
+       return kobj_to_node_hstate(kobj, nidp);
 }
 
-static ssize_t nr_hugepages_show(struct kobject *kobj,
+static ssize_t nr_hugepages_show_common(struct kobject *kobj,
                                        struct kobj_attribute *attr, char *buf)
 {
-       struct hstate *h = kobj_to_hstate(kobj);
-       return sprintf(buf, "%lu\n", h->nr_huge_pages);
+       struct hstate *h;
+       unsigned long nr_huge_pages;
+       int nid;
+
+       h = kobj_to_hstate(kobj, &nid);
+       if (nid == NUMA_NO_NODE)
+               nr_huge_pages = h->nr_huge_pages;
+       else
+               nr_huge_pages = h->nr_huge_pages_node[nid];
+
+       return sprintf(buf, "%lu\n", nr_huge_pages);
 }
-static ssize_t nr_hugepages_store(struct kobject *kobj,
-               struct kobj_attribute *attr, const char *buf, size_t count)
+static ssize_t nr_hugepages_store_common(bool obey_mempolicy,
+                       struct kobject *kobj, struct kobj_attribute *attr,
+                       const char *buf, size_t len)
 {
        int err;
-       unsigned long input;
-       struct hstate *h = kobj_to_hstate(kobj);
+       int nid;
+       unsigned long count;
+       struct hstate *h;
+       NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY);
 
-       err = strict_strtoul(buf, 10, &input);
+       err = strict_strtoul(buf, 10, &count);
        if (err)
                return 0;
 
-       h->max_huge_pages = set_max_huge_pages(h, input);
+       h = kobj_to_hstate(kobj, &nid);
+       if (nid == NUMA_NO_NODE) {
+               /*
+                * global hstate attribute
+                */
+               if (!(obey_mempolicy &&
+                               init_nodemask_of_mempolicy(nodes_allowed))) {
+                       NODEMASK_FREE(nodes_allowed);
+                       nodes_allowed = &node_states[N_HIGH_MEMORY];
+               }
+       } else if (nodes_allowed) {
+               /*
+                * per node hstate attribute: adjust count to global,
+                * but restrict alloc/free to the specified node.
+                */
+               count += h->nr_huge_pages - h->nr_huge_pages_node[nid];
+               init_nodemask_of_node(nodes_allowed, nid);
+       } else
+               nodes_allowed = &node_states[N_HIGH_MEMORY];
+
+       h->max_huge_pages = set_max_huge_pages(h, count, nodes_allowed);
 
-       return count;
+       if (nodes_allowed != &node_states[N_HIGH_MEMORY])
+               NODEMASK_FREE(nodes_allowed);
+
+       return len;
+}
+
+static ssize_t nr_hugepages_show(struct kobject *kobj,
+                                      struct kobj_attribute *attr, char *buf)
+{
+       return nr_hugepages_show_common(kobj, attr, buf);
+}
+
+static ssize_t nr_hugepages_store(struct kobject *kobj,
+              struct kobj_attribute *attr, const char *buf, size_t len)
+{
+       return nr_hugepages_store_common(false, kobj, attr, buf, len);
 }
 HSTATE_ATTR(nr_hugepages);
 
+#ifdef CONFIG_NUMA
+
+/*
+ * hstate attribute for optionally mempolicy-based constraint on persistent
+ * huge page alloc/free.
+ */
+static ssize_t nr_hugepages_mempolicy_show(struct kobject *kobj,
+                                      struct kobj_attribute *attr, char *buf)
+{
+       return nr_hugepages_show_common(kobj, attr, buf);
+}
+
+static ssize_t nr_hugepages_mempolicy_store(struct kobject *kobj,
+              struct kobj_attribute *attr, const char *buf, size_t len)
+{
+       return nr_hugepages_store_common(true, kobj, attr, buf, len);
+}
+HSTATE_ATTR(nr_hugepages_mempolicy);
+#endif
+
+
 static ssize_t nr_overcommit_hugepages_show(struct kobject *kobj,
                                        struct kobj_attribute *attr, char *buf)
 {
-       struct hstate *h = kobj_to_hstate(kobj);
+       struct hstate *h = kobj_to_hstate(kobj, NULL);
        return sprintf(buf, "%lu\n", h->nr_overcommit_huge_pages);
 }
 static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj,
@@ -1326,7 +1443,7 @@ static ssize_t nr_overcommit_hugepages_store(struct kobject *kobj,
 {
        int err;
        unsigned long input;
-       struct hstate *h = kobj_to_hstate(kobj);
+       struct hstate *h = kobj_to_hstate(kobj, NULL);
 
        err = strict_strtoul(buf, 10, &input);
        if (err)
@@ -1343,15 +1460,24 @@ HSTATE_ATTR(nr_overcommit_hugepages);
 static ssize_t free_hugepages_show(struct kobject *kobj,
                                        struct kobj_attribute *attr, char *buf)
 {
-       struct hstate *h = kobj_to_hstate(kobj);
-       return sprintf(buf, "%lu\n", h->free_huge_pages);
+       struct hstate *h;
+       unsigned long free_huge_pages;
+       int nid;
+
+       h = kobj_to_hstate(kobj, &nid);
+       if (nid == NUMA_NO_NODE)
+               free_huge_pages = h->free_huge_pages;
+       else
+               free_huge_pages = h->free_huge_pages_node[nid];
+
+       return sprintf(buf, "%lu\n", free_huge_pages);
 }
 HSTATE_ATTR_RO(free_hugepages);
 
 static ssize_t resv_hugepages_show(struct kobject *kobj,
                                        struct kobj_attribute *attr, char *buf)
 {
-       struct hstate *h = kobj_to_hstate(kobj);
+       struct hstate *h = kobj_to_hstate(kobj, NULL);
        return sprintf(buf, "%lu\n", h->resv_huge_pages);
 }
 HSTATE_ATTR_RO(resv_hugepages);
@@ -1359,8 +1485,17 @@ HSTATE_ATTR_RO(resv_hugepages);
 static ssize_t surplus_hugepages_show(struct kobject *kobj,
                                        struct kobj_attribute *attr, char *buf)
 {
-       struct hstate *h = kobj_to_hstate(kobj);
-       return sprintf(buf, "%lu\n", h->surplus_huge_pages);
+       struct hstate *h;
+       unsigned long surplus_huge_pages;
+       int nid;
+
+       h = kobj_to_hstate(kobj, &nid);
+       if (nid == NUMA_NO_NODE)
+               surplus_huge_pages = h->surplus_huge_pages;
+       else
+               surplus_huge_pages = h->surplus_huge_pages_node[nid];
+
+       return sprintf(buf, "%lu\n", surplus_huge_pages);
 }
 HSTATE_ATTR_RO(surplus_hugepages);
 
@@ -1370,6 +1505,9 @@ static struct attribute *hstate_attrs[] = {
        &free_hugepages_attr.attr,
        &resv_hugepages_attr.attr,
        &surplus_hugepages_attr.attr,
+#ifdef CONFIG_NUMA
+       &nr_hugepages_mempolicy_attr.attr,
+#endif
        NULL,
 };
 
@@ -1377,19 +1515,21 @@ static struct attribute_group hstate_attr_group = {
        .attrs = hstate_attrs,
 };
 
-static int __init hugetlb_sysfs_add_hstate(struct hstate *h)
+static int __init hugetlb_sysfs_add_hstate(struct hstate *h,
+                               struct kobject *parent,
+                               struct kobject **hstate_kobjs,
+                               struct attribute_group *hstate_attr_group)
 {
        int retval;
+       int hi = h - hstates;
 
-       hstate_kobjs[h - hstates] = kobject_create_and_add(h->name,
-                                                       hugepages_kobj);
-       if (!hstate_kobjs[h - hstates])
+       hstate_kobjs[hi] = kobject_create_and_add(h->name, parent);
+       if (!hstate_kobjs[hi])
                return -ENOMEM;
 
-       retval = sysfs_create_group(hstate_kobjs[h - hstates],
-                                                       &hstate_attr_group);
+       retval = sysfs_create_group(hstate_kobjs[hi], hstate_attr_group);
        if (retval)
-               kobject_put(hstate_kobjs[h - hstates]);
+               kobject_put(hstate_kobjs[hi]);
 
        return retval;
 }
@@ -1404,17 +1544,184 @@ static void __init hugetlb_sysfs_init(void)
                return;
 
        for_each_hstate(h) {
-               err = hugetlb_sysfs_add_hstate(h);
+               err = hugetlb_sysfs_add_hstate(h, hugepages_kobj,
+                                        hstate_kobjs, &hstate_attr_group);
                if (err)
                        printk(KERN_ERR "Hugetlb: Unable to add hstate %s",
                                                                h->name);
        }
 }
 
+#ifdef CONFIG_NUMA
+
+/*
+ * node_hstate/s - associate per node hstate attributes, via their kobjects,
+ * with node sysdevs in node_devices[] using a parallel array.  The array
+ * index of a node sysdev or _hstate == node id.
+ * This is here to avoid any static dependency of the node sysdev driver, in
+ * the base kernel, on the hugetlb module.
+ */
+struct node_hstate {
+       struct kobject          *hugepages_kobj;
+       struct kobject          *hstate_kobjs[HUGE_MAX_HSTATE];
+};
+struct node_hstate node_hstates[MAX_NUMNODES];
+
+/*
+ * A subset of global hstate attributes for node sysdevs
+ */
+static struct attribute *per_node_hstate_attrs[] = {
+       &nr_hugepages_attr.attr,
+       &free_hugepages_attr.attr,
+       &surplus_hugepages_attr.attr,
+       NULL,
+};
+
+static struct attribute_group per_node_hstate_attr_group = {
+       .attrs = per_node_hstate_attrs,
+};
+
+/*
+ * kobj_to_node_hstate - lookup global hstate for node sysdev hstate attr kobj.
+ * Returns node id via non-NULL nidp.
+ */
+static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp)
+{
+       int nid;
+
+       for (nid = 0; nid < nr_node_ids; nid++) {
+               struct node_hstate *nhs = &node_hstates[nid];
+               int i;
+               for (i = 0; i < HUGE_MAX_HSTATE; i++)
+                       if (nhs->hstate_kobjs[i] == kobj) {
+                               if (nidp)
+                                       *nidp = nid;
+                               return &hstates[i];
+                       }
+       }
+
+       BUG();
+       return NULL;
+}
+
+/*
+ * Unregister hstate attributes from a single node sysdev.
+ * No-op if no hstate attributes attached.
+ */
+void hugetlb_unregister_node(struct node *node)
+{
+       struct hstate *h;
+       struct node_hstate *nhs = &node_hstates[node->sysdev.id];
+
+       if (!nhs->hugepages_kobj)
+               return;         /* no hstate attributes */
+
+       for_each_hstate(h)
+               if (nhs->hstate_kobjs[h - hstates]) {
+                       kobject_put(nhs->hstate_kobjs[h - hstates]);
+                       nhs->hstate_kobjs[h - hstates] = NULL;
+               }
+
+       kobject_put(nhs->hugepages_kobj);
+       nhs->hugepages_kobj = NULL;
+}
+
+/*
+ * hugetlb module exit:  unregister hstate attributes from node sysdevs
+ * that have them.
+ */
+static void hugetlb_unregister_all_nodes(void)
+{
+       int nid;
+
+       /*
+        * disable node sysdev registrations.
+        */
+       register_hugetlbfs_with_node(NULL, NULL);
+
+       /*
+        * remove hstate attributes from any nodes that have them.
+        */
+       for (nid = 0; nid < nr_node_ids; nid++)
+               hugetlb_unregister_node(&node_devices[nid]);
+}
+
+/*
+ * Register hstate attributes for a single node sysdev.
+ * No-op if attributes already registered.
+ */
+void hugetlb_register_node(struct node *node)
+{
+       struct hstate *h;
+       struct node_hstate *nhs = &node_hstates[node->sysdev.id];
+       int err;
+
+       if (nhs->hugepages_kobj)
+               return;         /* already allocated */
+
+       nhs->hugepages_kobj = kobject_create_and_add("hugepages",
+                                                       &node->sysdev.kobj);
+       if (!nhs->hugepages_kobj)
+               return;
+
+       for_each_hstate(h) {
+               err = hugetlb_sysfs_add_hstate(h, nhs->hugepages_kobj,
+                                               nhs->hstate_kobjs,
+                                               &per_node_hstate_attr_group);
+               if (err) {
+                       printk(KERN_ERR "Hugetlb: Unable to add hstate %s"
+                                       " for node %d\n",
+                                               h->name, node->sysdev.id);
+                       hugetlb_unregister_node(node);
+                       break;
+               }
+       }
+}
+
+/*
+ * hugetlb init time:  register hstate attributes for all registered node
+ * sysdevs of nodes that have memory.  All on-line nodes should have
+ * registered their associated sysdev by this time.
+ */
+static void hugetlb_register_all_nodes(void)
+{
+       int nid;
+
+       for_each_node_state(nid, N_HIGH_MEMORY) {
+               struct node *node = &node_devices[nid];
+               if (node->sysdev.id == nid)
+                       hugetlb_register_node(node);
+       }
+
+       /*
+        * Let the node sysdev driver know we're here so it can
+        * [un]register hstate attributes on node hotplug.
+        */
+       register_hugetlbfs_with_node(hugetlb_register_node,
+                                    hugetlb_unregister_node);
+}
+#else  /* !CONFIG_NUMA */
+
+static struct hstate *kobj_to_node_hstate(struct kobject *kobj, int *nidp)
+{
+       BUG();
+       if (nidp)
+               *nidp = -1;
+       return NULL;
+}
+
+static void hugetlb_unregister_all_nodes(void) { }
+
+static void hugetlb_register_all_nodes(void) { }
+
+#endif
+
 static void __exit hugetlb_exit(void)
 {
        struct hstate *h;
 
+       hugetlb_unregister_all_nodes();
+
        for_each_hstate(h) {
                kobject_put(hstate_kobjs[h - hstates]);
        }
@@ -1449,6 +1756,8 @@ static int __init hugetlb_init(void)
 
        hugetlb_sysfs_init();
 
+       hugetlb_register_all_nodes();
+
        return 0;
 }
 module_init(hugetlb_init);
@@ -1472,8 +1781,8 @@ void __init hugetlb_add_hstate(unsigned order)
        h->free_huge_pages = 0;
        for (i = 0; i < MAX_NUMNODES; ++i)
                INIT_LIST_HEAD(&h->hugepage_freelists[i]);
-       h->next_nid_to_alloc = first_node(node_online_map);
-       h->next_nid_to_free = first_node(node_online_map);
+       h->next_nid_to_alloc = first_node(node_states[N_HIGH_MEMORY]);
+       h->next_nid_to_free = first_node(node_states[N_HIGH_MEMORY]);
        snprintf(h->name, HSTATE_NAME_LEN, "hugepages-%lukB",
                                        huge_page_size(h)/1024);
 
@@ -1536,9 +1845,9 @@ static unsigned int cpuset_mems_nr(unsigned int *array)
 }
 
 #ifdef CONFIG_SYSCTL
-int hugetlb_sysctl_handler(struct ctl_table *table, int write,
-                          void __user *buffer,
-                          size_t *length, loff_t *ppos)
+static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
+                        struct ctl_table *table, int write,
+                        void __user *buffer, size_t *length, loff_t *ppos)
 {
        struct hstate *h = &default_hstate;
        unsigned long tmp;
@@ -1550,12 +1859,40 @@ int hugetlb_sysctl_handler(struct ctl_table *table, int write,
        table->maxlen = sizeof(unsigned long);
        proc_doulongvec_minmax(table, write, buffer, length, ppos);
 
-       if (write)
-               h->max_huge_pages = set_max_huge_pages(h, tmp);
+       if (write) {
+               NODEMASK_ALLOC(nodemask_t, nodes_allowed,
+                                               GFP_KERNEL | __GFP_NORETRY);
+               if (!(obey_mempolicy &&
+                              init_nodemask_of_mempolicy(nodes_allowed))) {
+                       NODEMASK_FREE(nodes_allowed);
+                       nodes_allowed = &node_states[N_HIGH_MEMORY];
+               }
+               h->max_huge_pages = set_max_huge_pages(h, tmp, nodes_allowed);
+
+               if (nodes_allowed != &node_states[N_HIGH_MEMORY])
+                       NODEMASK_FREE(nodes_allowed);
+       }
 
        return 0;
 }
 
+int hugetlb_sysctl_handler(struct ctl_table *table, int write,
+                         void __user *buffer, size_t *length, loff_t *ppos)
+{
+
+       return hugetlb_sysctl_handler_common(false, table, write,
+                                                       buffer, length, ppos);
+}
+
+#ifdef CONFIG_NUMA
+int hugetlb_mempolicy_sysctl_handler(struct ctl_table *table, int write,
+                         void __user *buffer, size_t *length, loff_t *ppos)
+{
+       return hugetlb_sysctl_handler_common(true, table, write,
+                                                       buffer, length, ppos);
+}
+#endif /* CONFIG_NUMA */
+
 int hugetlb_treat_movable_handler(struct ctl_table *table, int write,
                        void __user *buffer,
                        size_t *length, loff_t *ppos)
@@ -1903,6 +2240,12 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
                + (vma->vm_pgoff >> PAGE_SHIFT);
        mapping = (struct address_space *)page_private(page);
 
+       /*
+        * Take the mapping lock for the duration of the table walk. As
+        * this mapping should be shared between all the VMAs,
+        * __unmap_hugepage_range() is called as the lock is already held
+        */
+       spin_lock(&mapping->i_mmap_lock);
        vma_prio_tree_foreach(iter_vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
                /* Do not unmap the current VMA */
                if (iter_vma == vma)
@@ -1916,10 +2259,11 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
                 * from the time of fork. This would look like data corruption
                 */
                if (!is_vma_resv_set(iter_vma, HPAGE_RESV_OWNER))
-                       unmap_hugepage_range(iter_vma,
+                       __unmap_hugepage_range(iter_vma,
                                address, address + huge_page_size(h),
                                page);
        }
+       spin_unlock(&mapping->i_mmap_lock);
 
        return 1;
 }
@@ -1959,6 +2303,9 @@ retry_avoidcopy:
                outside_reserve = 1;
 
        page_cache_get(old_page);
+
+       /* Drop page_table_lock as buddy allocator may be called */
+       spin_unlock(&mm->page_table_lock);
        new_page = alloc_huge_page(vma, address, outside_reserve);
 
        if (IS_ERR(new_page)) {
@@ -1976,19 +2323,25 @@ retry_avoidcopy:
                        if (unmap_ref_private(mm, vma, old_page, address)) {
                                BUG_ON(page_count(old_page) != 1);
                                BUG_ON(huge_pte_none(pte));
+                               spin_lock(&mm->page_table_lock);
                                goto retry_avoidcopy;
                        }
                        WARN_ON_ONCE(1);
                }
 
+               /* Caller expects lock to be held */
+               spin_lock(&mm->page_table_lock);
                return -PTR_ERR(new_page);
        }
 
-       spin_unlock(&mm->page_table_lock);
        copy_huge_page(new_page, old_page, address, vma);
        __SetPageUptodate(new_page);
-       spin_lock(&mm->page_table_lock);
 
+       /*
+        * Retake the page_table_lock to check for racing updates
+        * before the page tables are altered
+        */
+       spin_lock(&mm->page_table_lock);
        ptep = huge_pte_offset(mm, address & huge_page_mask(h));
        if (likely(pte_same(huge_ptep_get(ptep), pte))) {
                /* Break COW */
index e1d85137f0864ba459609f8b26b0a95ffc97eedd..10ea71905c1fbbb8a9582737e05f78fefa86012e 100644 (file)
@@ -3,18 +3,68 @@
 #include <linux/debugfs.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/pagemap.h>
+#include "internal.h"
 
-static struct dentry *hwpoison_dir, *corrupt_pfn;
+static struct dentry *hwpoison_dir;
 
 static int hwpoison_inject(void *data, u64 val)
+{
+       unsigned long pfn = val;
+       struct page *p;
+       int err;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       if (!hwpoison_filter_enable)
+               goto inject;
+       if (!pfn_valid(pfn))
+               return -ENXIO;
+
+       p = pfn_to_page(pfn);
+       /*
+        * This implies unable to support free buddy pages.
+        */
+       if (!get_page_unless_zero(p))
+               return 0;
+
+       if (!PageLRU(p))
+               shake_page(p, 0);
+       /*
+        * This implies unable to support non-LRU pages.
+        */
+       if (!PageLRU(p))
+               return 0;
+
+       /*
+        * do a racy check with elevated page count, to make sure PG_hwpoison
+        * will only be set for the targeted owner (or on a free page).
+        * We temporarily take page lock for try_get_mem_cgroup_from_page().
+        * __memory_failure() will redo the check reliably inside page lock.
+        */
+       lock_page(p);
+       err = hwpoison_filter(p);
+       unlock_page(p);
+       if (err)
+               return 0;
+
+inject:
+       printk(KERN_INFO "Injecting memory failure at pfn %lx\n", pfn);
+       return __memory_failure(pfn, 18, MF_COUNT_INCREASED);
+}
+
+static int hwpoison_unpoison(void *data, u64 val)
 {
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
-       printk(KERN_INFO "Injecting memory failure at pfn %Lx\n", val);
-       return __memory_failure(val, 18, 0);
+
+       return unpoison_memory(val);
 }
 
 DEFINE_SIMPLE_ATTRIBUTE(hwpoison_fops, NULL, hwpoison_inject, "%lli\n");
+DEFINE_SIMPLE_ATTRIBUTE(unpoison_fops, NULL, hwpoison_unpoison, "%lli\n");
 
 static void pfn_inject_exit(void)
 {
@@ -24,16 +74,63 @@ static void pfn_inject_exit(void)
 
 static int pfn_inject_init(void)
 {
+       struct dentry *dentry;
+
        hwpoison_dir = debugfs_create_dir("hwpoison", NULL);
        if (hwpoison_dir == NULL)
                return -ENOMEM;
-       corrupt_pfn = debugfs_create_file("corrupt-pfn", 0600, hwpoison_dir,
+
+       /*
+        * Note that the below poison/unpoison interfaces do not involve
+        * hardware status change, hence do not require hardware support.
+        * They are mainly for testing hwpoison in software level.
+        */
+       dentry = debugfs_create_file("corrupt-pfn", 0600, hwpoison_dir,
                                          NULL, &hwpoison_fops);
-       if (corrupt_pfn == NULL) {
-               pfn_inject_exit();
-               return -ENOMEM;
-       }
+       if (!dentry)
+               goto fail;
+
+       dentry = debugfs_create_file("unpoison-pfn", 0600, hwpoison_dir,
+                                    NULL, &unpoison_fops);
+       if (!dentry)
+               goto fail;
+
+       dentry = debugfs_create_u32("corrupt-filter-enable", 0600,
+                                   hwpoison_dir, &hwpoison_filter_enable);
+       if (!dentry)
+               goto fail;
+
+       dentry = debugfs_create_u32("corrupt-filter-dev-major", 0600,
+                                   hwpoison_dir, &hwpoison_filter_dev_major);
+       if (!dentry)
+               goto fail;
+
+       dentry = debugfs_create_u32("corrupt-filter-dev-minor", 0600,
+                                   hwpoison_dir, &hwpoison_filter_dev_minor);
+       if (!dentry)
+               goto fail;
+
+       dentry = debugfs_create_u64("corrupt-filter-flags-mask", 0600,
+                                   hwpoison_dir, &hwpoison_filter_flags_mask);
+       if (!dentry)
+               goto fail;
+
+       dentry = debugfs_create_u64("corrupt-filter-flags-value", 0600,
+                                   hwpoison_dir, &hwpoison_filter_flags_value);
+       if (!dentry)
+               goto fail;
+
+#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
+       dentry = debugfs_create_u64("corrupt-filter-memcg", 0600,
+                                   hwpoison_dir, &hwpoison_filter_memcg);
+       if (!dentry)
+               goto fail;
+#endif
+
        return 0;
+fail:
+       pfn_inject_exit();
+       return -ENOMEM;
 }
 
 module_init(pfn_inject_init);
index 22ec8d2b0fb8d641dabc76090b9062e9a5c557be..6a697bb97fc589fcdd71ad56a61d43f88862786b 100644 (file)
@@ -50,6 +50,9 @@ extern void putback_lru_page(struct page *page);
  */
 extern void __free_pages_bootmem(struct page *page, unsigned int order);
 extern void prep_compound_page(struct page *page, unsigned long order);
+#ifdef CONFIG_MEMORY_FAILURE
+extern bool is_free_buddy_page(struct page *page);
+#endif
 
 
 /*
@@ -63,7 +66,7 @@ static inline unsigned long page_order(struct page *page)
        return page_private(page);
 }
 
-#ifdef CONFIG_HAVE_MLOCK
+#ifdef CONFIG_MMU
 extern long mlock_vma_pages_range(struct vm_area_struct *vma,
                        unsigned long start, unsigned long end);
 extern void munlock_vma_pages_range(struct vm_area_struct *vma,
@@ -72,21 +75,7 @@ static inline void munlock_vma_pages_all(struct vm_area_struct *vma)
 {
        munlock_vma_pages_range(vma, vma->vm_start, vma->vm_end);
 }
-#endif
 
-/*
- * unevictable_migrate_page() called only from migrate_page_copy() to
- * migrate unevictable flag to new page.
- * Note that the old page has been isolated from the LRU lists at this
- * point so we don't need to worry about LRU statistics.
- */
-static inline void unevictable_migrate_page(struct page *new, struct page *old)
-{
-       if (TestClearPageUnevictable(old))
-               SetPageUnevictable(new);
-}
-
-#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
 /*
  * Called only in fault path via page_evictable() for a new page
  * to determine if it's being mapped into a LOCKED vma.
@@ -107,9 +96,10 @@ static inline int is_mlocked_vma(struct vm_area_struct *vma, struct page *page)
 }
 
 /*
- * must be called with vma's mmap_sem held for read, and page locked.
+ * must be called with vma's mmap_sem held for read or write, and page locked.
  */
 extern void mlock_vma_page(struct page *page);
+extern void munlock_vma_page(struct page *page);
 
 /*
  * Clear the page's PageMlocked().  This can be useful in a situation where
@@ -144,7 +134,7 @@ static inline void mlock_migrate_page(struct page *newpage, struct page *page)
        }
 }
 
-#else /* CONFIG_HAVE_MLOCKED_PAGE_BIT */
+#else /* !CONFIG_MMU */
 static inline int is_mlocked_vma(struct vm_area_struct *v, struct page *p)
 {
        return 0;
@@ -153,7 +143,7 @@ static inline void clear_page_mlock(struct page *page) { }
 static inline void mlock_vma_page(struct page *page) { }
 static inline void mlock_migrate_page(struct page *new, struct page *old) { }
 
-#endif /* CONFIG_HAVE_MLOCKED_PAGE_BIT */
+#endif /* !CONFIG_MMU */
 
 /*
  * Return the mem_map entry representing the 'offset' subpage within
@@ -260,3 +250,12 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 #define ZONE_RECLAIM_SOME      0
 #define ZONE_RECLAIM_SUCCESS   1
 #endif
+
+extern int hwpoison_filter(struct page *p);
+
+extern u32 hwpoison_filter_dev_major;
+extern u32 hwpoison_filter_dev_minor;
+extern u64 hwpoison_filter_flags_mask;
+extern u64 hwpoison_filter_flags_value;
+extern u64 hwpoison_filter_memcg;
+extern u32 hwpoison_filter_enable;
index 13f33b3081ec2794afdae74d9071a88ec6aa9df3..5b069e4f5e485ac8f5906c4a0cad7dbdeef75f7e 100644 (file)
@@ -93,6 +93,7 @@
 #include <linux/nodemask.h>
 #include <linux/mm.h>
 #include <linux/workqueue.h>
+#include <linux/crc32.h>
 
 #include <asm/sections.h>
 #include <asm/processor.h>
 #define MSECS_MIN_AGE          5000    /* minimum object age for reporting */
 #define SECS_FIRST_SCAN                60      /* delay before the first scan */
 #define SECS_SCAN_WAIT         600     /* subsequent auto scanning delay */
-#define GRAY_LIST_PASSES       25      /* maximum number of gray list scans */
 #define MAX_SCAN_SIZE          4096    /* maximum size of a scanned block */
 
 #define BYTES_PER_POINTER      sizeof(void *)
 /* scanning area inside a memory block */
 struct kmemleak_scan_area {
        struct hlist_node node;
-       unsigned long offset;
-       size_t length;
+       unsigned long start;
+       size_t size;
 };
 
 #define KMEMLEAK_GREY  0
@@ -149,6 +149,8 @@ struct kmemleak_object {
        int min_count;
        /* the total number of pointers found pointing to this object */
        int count;
+       /* checksum for detecting modified objects */
+       u32 checksum;
        /* memory ranges to be scanned inside an object (empty for all) */
        struct hlist_head area_list;
        unsigned long trace[MAX_TRACE];
@@ -164,8 +166,6 @@ struct kmemleak_object {
 #define OBJECT_REPORTED                (1 << 1)
 /* flag set to not scan the object */
 #define OBJECT_NO_SCAN         (1 << 2)
-/* flag set on newly allocated objects */
-#define OBJECT_NEW             (1 << 3)
 
 /* number of bytes to print per line; must be 16 or 32 */
 #define HEX_ROW_SIZE           16
@@ -241,8 +241,6 @@ struct early_log {
        const void *ptr;                /* allocated/freed memory block */
        size_t size;                    /* memory block size */
        int min_count;                  /* minimum reference count */
-       unsigned long offset;           /* scan area offset */
-       size_t length;                  /* scan area length */
        unsigned long trace[MAX_TRACE]; /* stack trace */
        unsigned int trace_len;         /* stack trace length */
 };
@@ -323,11 +321,6 @@ static bool color_gray(const struct kmemleak_object *object)
                object->count >= object->min_count;
 }
 
-static bool color_black(const struct kmemleak_object *object)
-{
-       return object->min_count == KMEMLEAK_BLACK;
-}
-
 /*
  * Objects are considered unreferenced only if their color is white, they have
  * not be deleted and have a minimum age to avoid false positives caused by
@@ -335,7 +328,7 @@ static bool color_black(const struct kmemleak_object *object)
  */
 static bool unreferenced_object(struct kmemleak_object *object)
 {
-       return (object->flags & OBJECT_ALLOCATED) && color_white(object) &&
+       return (color_white(object) && object->flags & OBJECT_ALLOCATED) &&
                time_before_eq(object->jiffies + jiffies_min_age,
                               jiffies_last_scan);
 }
@@ -348,11 +341,13 @@ static void print_unreferenced(struct seq_file *seq,
                               struct kmemleak_object *object)
 {
        int i;
+       unsigned int msecs_age = jiffies_to_msecs(jiffies - object->jiffies);
 
        seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n",
                   object->pointer, object->size);
-       seq_printf(seq, "  comm \"%s\", pid %d, jiffies %lu\n",
-                  object->comm, object->pid, object->jiffies);
+       seq_printf(seq, "  comm \"%s\", pid %d, jiffies %lu (age %d.%03ds)\n",
+                  object->comm, object->pid, object->jiffies,
+                  msecs_age / 1000, msecs_age % 1000);
        hex_dump_object(seq, object);
        seq_printf(seq, "  backtrace:\n");
 
@@ -381,6 +376,7 @@ static void dump_object_info(struct kmemleak_object *object)
        pr_notice("  min_count = %d\n", object->min_count);
        pr_notice("  count = %d\n", object->count);
        pr_notice("  flags = 0x%lx\n", object->flags);
+       pr_notice("  checksum = %d\n", object->checksum);
        pr_notice("  backtrace:\n");
        print_stack_trace(&trace, 4);
 }
@@ -522,12 +518,13 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,
        INIT_HLIST_HEAD(&object->area_list);
        spin_lock_init(&object->lock);
        atomic_set(&object->use_count, 1);
-       object->flags = OBJECT_ALLOCATED | OBJECT_NEW;
+       object->flags = OBJECT_ALLOCATED;
        object->pointer = ptr;
        object->size = size;
        object->min_count = min_count;
-       object->count = -1;                     /* no color initially */
+       object->count = 0;                      /* white color initially */
        object->jiffies = jiffies;
+       object->checksum = 0;
 
        /* task information */
        if (in_irq()) {
@@ -720,14 +717,13 @@ static void make_black_object(unsigned long ptr)
  * Add a scanning area to the object. If at least one such area is added,
  * kmemleak will only scan these ranges rather than the whole memory block.
  */
-static void add_scan_area(unsigned long ptr, unsigned long offset,
-                         size_t length, gfp_t gfp)
+static void add_scan_area(unsigned long ptr, size_t size, gfp_t gfp)
 {
        unsigned long flags;
        struct kmemleak_object *object;
        struct kmemleak_scan_area *area;
 
-       object = find_and_get_object(ptr, 0);
+       object = find_and_get_object(ptr, 1);
        if (!object) {
                kmemleak_warn("Adding scan area to unknown object at 0x%08lx\n",
                              ptr);
@@ -741,7 +737,7 @@ static void add_scan_area(unsigned long ptr, unsigned long offset,
        }
 
        spin_lock_irqsave(&object->lock, flags);
-       if (offset + length > object->size) {
+       if (ptr + size > object->pointer + object->size) {
                kmemleak_warn("Scan area larger than object 0x%08lx\n", ptr);
                dump_object_info(object);
                kmem_cache_free(scan_area_cache, area);
@@ -749,8 +745,8 @@ static void add_scan_area(unsigned long ptr, unsigned long offset,
        }
 
        INIT_HLIST_NODE(&area->node);
-       area->offset = offset;
-       area->length = length;
+       area->start = ptr;
+       area->size = size;
 
        hlist_add_head(&area->node, &object->area_list);
 out_unlock:
@@ -786,7 +782,7 @@ static void object_no_scan(unsigned long ptr)
  * processed later once kmemleak is fully initialized.
  */
 static void __init log_early(int op_type, const void *ptr, size_t size,
-                            int min_count, unsigned long offset, size_t length)
+                            int min_count)
 {
        unsigned long flags;
        struct early_log *log;
@@ -808,8 +804,6 @@ static void __init log_early(int op_type, const void *ptr, size_t size,
        log->ptr = ptr;
        log->size = size;
        log->min_count = min_count;
-       log->offset = offset;
-       log->length = length;
        if (op_type == KMEMLEAK_ALLOC)
                log->trace_len = __save_stack_trace(log->trace);
        crt_early_log++;
@@ -858,7 +852,7 @@ void __ref kmemleak_alloc(const void *ptr, size_t size, int min_count,
        if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
                create_object((unsigned long)ptr, size, min_count, gfp);
        else if (atomic_read(&kmemleak_early_log))
-               log_early(KMEMLEAK_ALLOC, ptr, size, min_count, 0, 0);
+               log_early(KMEMLEAK_ALLOC, ptr, size, min_count);
 }
 EXPORT_SYMBOL_GPL(kmemleak_alloc);
 
@@ -873,7 +867,7 @@ void __ref kmemleak_free(const void *ptr)
        if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
                delete_object_full((unsigned long)ptr);
        else if (atomic_read(&kmemleak_early_log))
-               log_early(KMEMLEAK_FREE, ptr, 0, 0, 0, 0);
+               log_early(KMEMLEAK_FREE, ptr, 0, 0);
 }
 EXPORT_SYMBOL_GPL(kmemleak_free);
 
@@ -888,7 +882,7 @@ void __ref kmemleak_free_part(const void *ptr, size_t size)
        if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
                delete_object_part((unsigned long)ptr, size);
        else if (atomic_read(&kmemleak_early_log))
-               log_early(KMEMLEAK_FREE_PART, ptr, size, 0, 0, 0);
+               log_early(KMEMLEAK_FREE_PART, ptr, size, 0);
 }
 EXPORT_SYMBOL_GPL(kmemleak_free_part);
 
@@ -903,7 +897,7 @@ void __ref kmemleak_not_leak(const void *ptr)
        if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
                make_gray_object((unsigned long)ptr);
        else if (atomic_read(&kmemleak_early_log))
-               log_early(KMEMLEAK_NOT_LEAK, ptr, 0, 0, 0, 0);
+               log_early(KMEMLEAK_NOT_LEAK, ptr, 0, 0);
 }
 EXPORT_SYMBOL(kmemleak_not_leak);
 
@@ -919,22 +913,21 @@ void __ref kmemleak_ignore(const void *ptr)
        if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
                make_black_object((unsigned long)ptr);
        else if (atomic_read(&kmemleak_early_log))
-               log_early(KMEMLEAK_IGNORE, ptr, 0, 0, 0, 0);
+               log_early(KMEMLEAK_IGNORE, ptr, 0, 0);
 }
 EXPORT_SYMBOL(kmemleak_ignore);
 
 /*
  * Limit the range to be scanned in an allocated memory block.
  */
-void __ref kmemleak_scan_area(const void *ptr, unsigned long offset,
-                             size_t length, gfp_t gfp)
+void __ref kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp)
 {
        pr_debug("%s(0x%p)\n", __func__, ptr);
 
        if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
-               add_scan_area((unsigned long)ptr, offset, length, gfp);
+               add_scan_area((unsigned long)ptr, size, gfp);
        else if (atomic_read(&kmemleak_early_log))
-               log_early(KMEMLEAK_SCAN_AREA, ptr, 0, 0, offset, length);
+               log_early(KMEMLEAK_SCAN_AREA, ptr, size, 0);
 }
 EXPORT_SYMBOL(kmemleak_scan_area);
 
@@ -948,10 +941,24 @@ void __ref kmemleak_no_scan(const void *ptr)
        if (atomic_read(&kmemleak_enabled) && ptr && !IS_ERR(ptr))
                object_no_scan((unsigned long)ptr);
        else if (atomic_read(&kmemleak_early_log))
-               log_early(KMEMLEAK_NO_SCAN, ptr, 0, 0, 0, 0);
+               log_early(KMEMLEAK_NO_SCAN, ptr, 0, 0);
 }
 EXPORT_SYMBOL(kmemleak_no_scan);
 
+/*
+ * Update an object's checksum and return true if it was modified.
+ */
+static bool update_checksum(struct kmemleak_object *object)
+{
+       u32 old_csum = object->checksum;
+
+       if (!kmemcheck_is_obj_initialized(object->pointer, object->size))
+               return false;
+
+       object->checksum = crc32(0, (void *)object->pointer, object->size);
+       return object->checksum != old_csum;
+}
+
 /*
  * Memory scanning is a long process and it needs to be interruptable. This
  * function checks whether such interrupt condition occured.
@@ -1031,11 +1038,14 @@ static void scan_block(void *_start, void *_end,
                 * added to the gray_list.
                 */
                object->count++;
-               if (color_gray(object))
+               if (color_gray(object)) {
                        list_add_tail(&object->gray_list, &gray_list);
-               else
-                       put_object(object);
+                       spin_unlock_irqrestore(&object->lock, flags);
+                       continue;
+               }
+
                spin_unlock_irqrestore(&object->lock, flags);
+               put_object(object);
        }
 }
 
@@ -1075,13 +1085,46 @@ static void scan_object(struct kmemleak_object *object)
                }
        } else
                hlist_for_each_entry(area, elem, &object->area_list, node)
-                       scan_block((void *)(object->pointer + area->offset),
-                                  (void *)(object->pointer + area->offset
-                                           + area->length), object, 0);
+                       scan_block((void *)area->start,
+                                  (void *)(area->start + area->size),
+                                  object, 0);
 out:
        spin_unlock_irqrestore(&object->lock, flags);
 }
 
+/*
+ * Scan the objects already referenced (gray objects). More objects will be
+ * referenced and, if there are no memory leaks, all the objects are scanned.
+ */
+static void scan_gray_list(void)
+{
+       struct kmemleak_object *object, *tmp;
+
+       /*
+        * The list traversal is safe for both tail additions and removals
+        * from inside the loop. The kmemleak objects cannot be freed from
+        * outside the loop because their use_count was incremented.
+        */
+       object = list_entry(gray_list.next, typeof(*object), gray_list);
+       while (&object->gray_list != &gray_list) {
+               cond_resched();
+
+               /* may add new objects to the list */
+               if (!scan_should_stop())
+                       scan_object(object);
+
+               tmp = list_entry(object->gray_list.next, typeof(*object),
+                                gray_list);
+
+               /* remove the object from the list and release it */
+               list_del(&object->gray_list);
+               put_object(object);
+
+               object = tmp;
+       }
+       WARN_ON(!list_empty(&gray_list));
+}
+
 /*
  * Scan data sections and all the referenced memory blocks allocated via the
  * kernel's standard allocators. This function must be called with the
@@ -1090,10 +1133,9 @@ out:
 static void kmemleak_scan(void)
 {
        unsigned long flags;
-       struct kmemleak_object *object, *tmp;
+       struct kmemleak_object *object;
        int i;
        int new_leaks = 0;
-       int gray_list_pass = 0;
 
        jiffies_last_scan = jiffies;
 
@@ -1114,7 +1156,6 @@ static void kmemleak_scan(void)
 #endif
                /* reset the reference count (whiten the object) */
                object->count = 0;
-               object->flags &= ~OBJECT_NEW;
                if (color_gray(object) && get_object(object))
                        list_add_tail(&object->gray_list, &gray_list);
 
@@ -1172,62 +1213,36 @@ static void kmemleak_scan(void)
 
        /*
         * Scan the objects already referenced from the sections scanned
-        * above. More objects will be referenced and, if there are no memory
-        * leaks, all the objects will be scanned. The list traversal is safe
-        * for both tail additions and removals from inside the loop. The
-        * kmemleak objects cannot be freed from outside the loop because their
-        * use_count was increased.
+        * above.
         */
-repeat:
-       object = list_entry(gray_list.next, typeof(*object), gray_list);
-       while (&object->gray_list != &gray_list) {
-               cond_resched();
-
-               /* may add new objects to the list */
-               if (!scan_should_stop())
-                       scan_object(object);
-
-               tmp = list_entry(object->gray_list.next, typeof(*object),
-                                gray_list);
-
-               /* remove the object from the list and release it */
-               list_del(&object->gray_list);
-               put_object(object);
-
-               object = tmp;
-       }
-
-       if (scan_should_stop() || ++gray_list_pass >= GRAY_LIST_PASSES)
-               goto scan_end;
+       scan_gray_list();
 
        /*
-        * Check for new objects allocated during this scanning and add them
-        * to the gray list.
+        * Check for new or unreferenced objects modified since the previous
+        * scan and color them gray until the next scan.
         */
        rcu_read_lock();
        list_for_each_entry_rcu(object, &object_list, object_list) {
                spin_lock_irqsave(&object->lock, flags);
-               if ((object->flags & OBJECT_NEW) && !color_black(object) &&
-                   get_object(object)) {
-                       object->flags &= ~OBJECT_NEW;
+               if (color_white(object) && (object->flags & OBJECT_ALLOCATED)
+                   && update_checksum(object) && get_object(object)) {
+                       /* color it gray temporarily */
+                       object->count = object->min_count;
                        list_add_tail(&object->gray_list, &gray_list);
                }
                spin_unlock_irqrestore(&object->lock, flags);
        }
        rcu_read_unlock();
 
-       if (!list_empty(&gray_list))
-               goto repeat;
-
-scan_end:
-       WARN_ON(!list_empty(&gray_list));
+       /*
+        * Re-scan the gray list for modified unreferenced objects.
+        */
+       scan_gray_list();
 
        /*
-        * If scanning was stopped or new objects were being allocated at a
-        * higher rate than gray list scanning, do not report any new
-        * unreferenced objects.
+        * If scanning was stopped do not report any new unreferenced objects.
         */
-       if (scan_should_stop() || gray_list_pass >= GRAY_LIST_PASSES)
+       if (scan_should_stop())
                return;
 
        /*
@@ -1642,8 +1657,7 @@ void __init kmemleak_init(void)
                        kmemleak_ignore(log->ptr);
                        break;
                case KMEMLEAK_SCAN_AREA:
-                       kmemleak_scan_area(log->ptr, log->offset, log->length,
-                                          GFP_KERNEL);
+                       kmemleak_scan_area(log->ptr, log->size, GFP_KERNEL);
                        break;
                case KMEMLEAK_NO_SCAN:
                        kmemleak_no_scan(log->ptr);
index 5575f8628fef5306611055092e47ed9f472f4027..56a0da1f9979d7eaa9d85cbc0b20ef76215e4abf 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
 #include <linux/wait.h>
 #include <linux/slab.h>
 #include <linux/rbtree.h>
+#include <linux/memory.h>
 #include <linux/mmu_notifier.h>
 #include <linux/swap.h>
 #include <linux/ksm.h>
 
 #include <asm/tlbflush.h>
+#include "internal.h"
 
 /*
  * A few notes about the KSM scanning process,
  * struct mm_slot - ksm information per mm that is being scanned
  * @link: link to the mm_slots hash list
  * @mm_list: link into the mm_slots list, rooted in ksm_mm_head
- * @rmap_list: head for this mm_slot's list of rmap_items
+ * @rmap_list: head for this mm_slot's singly-linked list of rmap_items
  * @mm: the mm that this information is valid for
  */
 struct mm_slot {
        struct hlist_node link;
        struct list_head mm_list;
-       struct list_head rmap_list;
+       struct rmap_item *rmap_list;
        struct mm_struct *mm;
 };
 
@@ -93,7 +95,7 @@ struct mm_slot {
  * struct ksm_scan - cursor for scanning
  * @mm_slot: the current mm_slot we are scanning
  * @address: the next address inside that to be scanned
- * @rmap_item: the current rmap that we are scanning inside the rmap_list
+ * @rmap_list: link to the next rmap to be scanned in the rmap_list
  * @seqnr: count of completed full scans (needed when removing unstable node)
  *
  * There is only the one ksm_scan instance of this cursor structure.
@@ -101,37 +103,51 @@ struct mm_slot {
 struct ksm_scan {
        struct mm_slot *mm_slot;
        unsigned long address;
-       struct rmap_item *rmap_item;
+       struct rmap_item **rmap_list;
        unsigned long seqnr;
 };
 
+/**
+ * struct stable_node - node of the stable rbtree
+ * @node: rb node of this ksm page in the stable tree
+ * @hlist: hlist head of rmap_items using this ksm page
+ * @kpfn: page frame number of this ksm page
+ */
+struct stable_node {
+       struct rb_node node;
+       struct hlist_head hlist;
+       unsigned long kpfn;
+};
+
 /**
  * struct rmap_item - reverse mapping item for virtual addresses
- * @link: link into mm_slot's rmap_list (rmap_list is per mm)
+ * @rmap_list: next rmap_item in mm_slot's singly-linked rmap_list
+ * @anon_vma: pointer to anon_vma for this mm,address, when in stable tree
  * @mm: the memory structure this rmap_item is pointing into
  * @address: the virtual address this rmap_item tracks (+ flags in low bits)
  * @oldchecksum: previous checksum of the page at that virtual address
- * @node: rb_node of this rmap_item in either unstable or stable tree
- * @next: next rmap_item hanging off the same node of the stable tree
- * @prev: previous rmap_item hanging off the same node of the stable tree
+ * @node: rb node of this rmap_item in the unstable tree
+ * @head: pointer to stable_node heading this list in the stable tree
+ * @hlist: link into hlist of rmap_items hanging off that stable_node
  */
 struct rmap_item {
-       struct list_head link;
+       struct rmap_item *rmap_list;
+       struct anon_vma *anon_vma;      /* when stable */
        struct mm_struct *mm;
        unsigned long address;          /* + low bits used for flags below */
+       unsigned int oldchecksum;       /* when unstable */
        union {
-               unsigned int oldchecksum;               /* when unstable */
-               struct rmap_item *next;                 /* when stable */
-       };
-       union {
-               struct rb_node node;                    /* when tree node */
-               struct rmap_item *prev;                 /* in stable list */
+               struct rb_node node;    /* when node of unstable tree */
+               struct {                /* when listed from stable tree */
+                       struct stable_node *head;
+                       struct hlist_node hlist;
+               };
        };
 };
 
 #define SEQNR_MASK     0x0ff   /* low bits of unstable tree seqnr */
-#define NODE_FLAG      0x100   /* is a node of unstable or stable tree */
-#define STABLE_FLAG    0x200   /* is a node or list item of stable tree */
+#define UNSTABLE_FLAG  0x100   /* is a node of the unstable tree */
+#define STABLE_FLAG    0x200   /* is listed from the stable tree */
 
 /* The stable and unstable tree heads */
 static struct rb_root root_stable_tree = RB_ROOT;
@@ -148,6 +164,7 @@ static struct ksm_scan ksm_scan = {
 };
 
 static struct kmem_cache *rmap_item_cache;
+static struct kmem_cache *stable_node_cache;
 static struct kmem_cache *mm_slot_cache;
 
 /* The number of nodes in the stable tree */
@@ -162,9 +179,6 @@ static unsigned long ksm_pages_unshared;
 /* The number of rmap_items in use: to calculate pages_volatile */
 static unsigned long ksm_rmap_items;
 
-/* Limit on the number of unswappable pages used */
-static unsigned long ksm_max_kernel_pages;
-
 /* Number of pages ksmd should scan in one batch */
 static unsigned int ksm_thread_pages_to_scan = 100;
 
@@ -190,13 +204,19 @@ static int __init ksm_slab_init(void)
        if (!rmap_item_cache)
                goto out;
 
+       stable_node_cache = KSM_KMEM_CACHE(stable_node, 0);
+       if (!stable_node_cache)
+               goto out_free1;
+
        mm_slot_cache = KSM_KMEM_CACHE(mm_slot, 0);
        if (!mm_slot_cache)
-               goto out_free;
+               goto out_free2;
 
        return 0;
 
-out_free:
+out_free2:
+       kmem_cache_destroy(stable_node_cache);
+out_free1:
        kmem_cache_destroy(rmap_item_cache);
 out:
        return -ENOMEM;
@@ -205,6 +225,7 @@ out:
 static void __init ksm_slab_free(void)
 {
        kmem_cache_destroy(mm_slot_cache);
+       kmem_cache_destroy(stable_node_cache);
        kmem_cache_destroy(rmap_item_cache);
        mm_slot_cache = NULL;
 }
@@ -226,6 +247,16 @@ static inline void free_rmap_item(struct rmap_item *rmap_item)
        kmem_cache_free(rmap_item_cache, rmap_item);
 }
 
+static inline struct stable_node *alloc_stable_node(void)
+{
+       return kmem_cache_alloc(stable_node_cache, GFP_KERNEL);
+}
+
+static inline void free_stable_node(struct stable_node *stable_node)
+{
+       kmem_cache_free(stable_node_cache, stable_node);
+}
+
 static inline struct mm_slot *alloc_mm_slot(void)
 {
        if (!mm_slot_cache)     /* initialization failed */
@@ -275,7 +306,6 @@ static void insert_to_mm_slots_hash(struct mm_struct *mm,
        bucket = &mm_slots_hash[((unsigned long)mm / sizeof(struct mm_struct))
                                % MM_SLOTS_HASH_HEADS];
        mm_slot->mm = mm;
-       INIT_LIST_HEAD(&mm_slot->rmap_list);
        hlist_add_head(&mm_slot->link, bucket);
 }
 
@@ -284,6 +314,25 @@ static inline int in_stable_tree(struct rmap_item *rmap_item)
        return rmap_item->address & STABLE_FLAG;
 }
 
+static void hold_anon_vma(struct rmap_item *rmap_item,
+                         struct anon_vma *anon_vma)
+{
+       rmap_item->anon_vma = anon_vma;
+       atomic_inc(&anon_vma->ksm_refcount);
+}
+
+static void drop_anon_vma(struct rmap_item *rmap_item)
+{
+       struct anon_vma *anon_vma = rmap_item->anon_vma;
+
+       if (atomic_dec_and_lock(&anon_vma->ksm_refcount, &anon_vma->lock)) {
+               int empty = list_empty(&anon_vma->head);
+               spin_unlock(&anon_vma->lock);
+               if (empty)
+                       anon_vma_free(anon_vma);
+       }
+}
+
 /*
  * ksmd, and unmerge_and_remove_all_rmap_items(), must not touch an mm's
  * page tables after it has passed through ksm_exit() - which, if necessary,
@@ -356,10 +405,18 @@ static int break_ksm(struct vm_area_struct *vma, unsigned long addr)
        return (ret & VM_FAULT_OOM) ? -ENOMEM : 0;
 }
 
-static void break_cow(struct mm_struct *mm, unsigned long addr)
+static void break_cow(struct rmap_item *rmap_item)
 {
+       struct mm_struct *mm = rmap_item->mm;
+       unsigned long addr = rmap_item->address;
        struct vm_area_struct *vma;
 
+       /*
+        * It is not an accident that whenever we want to break COW
+        * to undo, we also need to drop a reference to the anon_vma.
+        */
+       drop_anon_vma(rmap_item);
+
        down_read(&mm->mmap_sem);
        if (ksm_test_exit(mm))
                goto out;
@@ -403,21 +460,77 @@ out:              page = NULL;
        return page;
 }
 
+static void remove_node_from_stable_tree(struct stable_node *stable_node)
+{
+       struct rmap_item *rmap_item;
+       struct hlist_node *hlist;
+
+       hlist_for_each_entry(rmap_item, hlist, &stable_node->hlist, hlist) {
+               if (rmap_item->hlist.next)
+                       ksm_pages_sharing--;
+               else
+                       ksm_pages_shared--;
+               drop_anon_vma(rmap_item);
+               rmap_item->address &= PAGE_MASK;
+               cond_resched();
+       }
+
+       rb_erase(&stable_node->node, &root_stable_tree);
+       free_stable_node(stable_node);
+}
+
 /*
- * get_ksm_page: checks if the page at the virtual address in rmap_item
- * is still PageKsm, in which case we can trust the content of the page,
- * and it returns the gotten page; but NULL if the page has been zapped.
+ * get_ksm_page: checks if the page indicated by the stable node
+ * is still its ksm page, despite having held no reference to it.
+ * In which case we can trust the content of the page, and it
+ * returns the gotten page; but if the page has now been zapped,
+ * remove the stale node from the stable tree and return NULL.
+ *
+ * You would expect the stable_node to hold a reference to the ksm page.
+ * But if it increments the page's count, swapping out has to wait for
+ * ksmd to come around again before it can free the page, which may take
+ * seconds or even minutes: much too unresponsive.  So instead we use a
+ * "keyhole reference": access to the ksm page from the stable node peeps
+ * out through its keyhole to see if that page still holds the right key,
+ * pointing back to this stable node.  This relies on freeing a PageAnon
+ * page to reset its page->mapping to NULL, and relies on no other use of
+ * a page to put something that might look like our key in page->mapping.
+ *
+ * include/linux/pagemap.h page_cache_get_speculative() is a good reference,
+ * but this is different - made simpler by ksm_thread_mutex being held, but
+ * interesting for assuming that no other use of the struct page could ever
+ * put our expected_mapping into page->mapping (or a field of the union which
+ * coincides with page->mapping).  The RCU calls are not for KSM at all, but
+ * to keep the page_count protocol described with page_cache_get_speculative.
+ *
+ * Note: it is possible that get_ksm_page() will return NULL one moment,
+ * then page the next, if the page is in between page_freeze_refs() and
+ * page_unfreeze_refs(): this shouldn't be a problem anywhere, the page
+ * is on its way to being freed; but it is an anomaly to bear in mind.
  */
-static struct page *get_ksm_page(struct rmap_item *rmap_item)
+static struct page *get_ksm_page(struct stable_node *stable_node)
 {
        struct page *page;
-
-       page = get_mergeable_page(rmap_item);
-       if (page && !PageKsm(page)) {
+       void *expected_mapping;
+
+       page = pfn_to_page(stable_node->kpfn);
+       expected_mapping = (void *)stable_node +
+                               (PAGE_MAPPING_ANON | PAGE_MAPPING_KSM);
+       rcu_read_lock();
+       if (page->mapping != expected_mapping)
+               goto stale;
+       if (!get_page_unless_zero(page))
+               goto stale;
+       if (page->mapping != expected_mapping) {
                put_page(page);
-               page = NULL;
+               goto stale;
        }
+       rcu_read_unlock();
        return page;
+stale:
+       rcu_read_unlock();
+       remove_node_from_stable_tree(stable_node);
+       return NULL;
 }
 
 /*
@@ -426,35 +539,29 @@ static struct page *get_ksm_page(struct rmap_item *rmap_item)
  */
 static void remove_rmap_item_from_tree(struct rmap_item *rmap_item)
 {
-       if (in_stable_tree(rmap_item)) {
-               struct rmap_item *next_item = rmap_item->next;
-
-               if (rmap_item->address & NODE_FLAG) {
-                       if (next_item) {
-                               rb_replace_node(&rmap_item->node,
-                                               &next_item->node,
-                                               &root_stable_tree);
-                               next_item->address |= NODE_FLAG;
-                               ksm_pages_sharing--;
-                       } else {
-                               rb_erase(&rmap_item->node, &root_stable_tree);
-                               ksm_pages_shared--;
-                       }
-               } else {
-                       struct rmap_item *prev_item = rmap_item->prev;
+       if (rmap_item->address & STABLE_FLAG) {
+               struct stable_node *stable_node;
+               struct page *page;
 
-                       BUG_ON(prev_item->next != rmap_item);
-                       prev_item->next = next_item;
-                       if (next_item) {
-                               BUG_ON(next_item->prev != rmap_item);
-                               next_item->prev = rmap_item->prev;
-                       }
+               stable_node = rmap_item->head;
+               page = get_ksm_page(stable_node);
+               if (!page)
+                       goto out;
+
+               lock_page(page);
+               hlist_del(&rmap_item->hlist);
+               unlock_page(page);
+               put_page(page);
+
+               if (stable_node->hlist.first)
                        ksm_pages_sharing--;
-               }
+               else
+                       ksm_pages_shared--;
 
-               rmap_item->next = NULL;
+               drop_anon_vma(rmap_item);
+               rmap_item->address &= PAGE_MASK;
 
-       } else if (rmap_item->address & NODE_FLAG) {
+       } else if (rmap_item->address & UNSTABLE_FLAG) {
                unsigned char age;
                /*
                 * Usually ksmd can and must skip the rb_erase, because
@@ -467,24 +574,21 @@ static void remove_rmap_item_from_tree(struct rmap_item *rmap_item)
                BUG_ON(age > 1);
                if (!age)
                        rb_erase(&rmap_item->node, &root_unstable_tree);
+
                ksm_pages_unshared--;
+               rmap_item->address &= PAGE_MASK;
        }
-
-       rmap_item->address &= PAGE_MASK;
-
+out:
        cond_resched();         /* we're called from many long loops */
 }
 
 static void remove_trailing_rmap_items(struct mm_slot *mm_slot,
-                                      struct list_head *cur)
+                                      struct rmap_item **rmap_list)
 {
-       struct rmap_item *rmap_item;
-
-       while (cur != &mm_slot->rmap_list) {
-               rmap_item = list_entry(cur, struct rmap_item, link);
-               cur = cur->next;
+       while (*rmap_list) {
+               struct rmap_item *rmap_item = *rmap_list;
+               *rmap_list = rmap_item->rmap_list;
                remove_rmap_item_from_tree(rmap_item);
-               list_del(&rmap_item->link);
                free_rmap_item(rmap_item);
        }
 }
@@ -550,7 +654,7 @@ static int unmerge_and_remove_all_rmap_items(void)
                                goto error;
                }
 
-               remove_trailing_rmap_items(mm_slot, mm_slot->rmap_list.next);
+               remove_trailing_rmap_items(mm_slot, &mm_slot->rmap_list);
 
                spin_lock(&ksm_mmlist_lock);
                ksm_scan.mm_slot = list_entry(mm_slot->mm_list.next,
@@ -646,7 +750,7 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page,
                 * Check that no O_DIRECT or similar I/O is in progress on the
                 * page
                 */
-               if ((page_mapcount(page) + 2 + swapped) != page_count(page)) {
+               if (page_mapcount(page) + 1 + swapped != page_count(page)) {
                        set_pte_at_notify(mm, addr, ptep, entry);
                        goto out_unlock;
                }
@@ -664,15 +768,15 @@ out:
 
 /**
  * replace_page - replace page in vma by new ksm page
- * @vma:      vma that holds the pte pointing to oldpage
- * @oldpage:  the page we are replacing by newpage
- * @newpage:  the ksm page we replace oldpage by
+ * @vma:      vma that holds the pte pointing to page
+ * @page:     the page we are replacing by kpage
+ * @kpage:    the ksm page we replace page by
  * @orig_pte: the original value of the pte
  *
  * Returns 0 on success, -EFAULT on failure.
  */
-static int replace_page(struct vm_area_struct *vma, struct page *oldpage,
-                       struct page *newpage, pte_t orig_pte)
+static int replace_page(struct vm_area_struct *vma, struct page *page,
+                       struct page *kpage, pte_t orig_pte)
 {
        struct mm_struct *mm = vma->vm_mm;
        pgd_t *pgd;
@@ -681,12 +785,9 @@ static int replace_page(struct vm_area_struct *vma, struct page *oldpage,
        pte_t *ptep;
        spinlock_t *ptl;
        unsigned long addr;
-       pgprot_t prot;
        int err = -EFAULT;
 
-       prot = vm_get_page_prot(vma->vm_flags & ~VM_WRITE);
-
-       addr = page_address_in_vma(oldpage, vma);
+       addr = page_address_in_vma(page, vma);
        if (addr == -EFAULT)
                goto out;
 
@@ -708,15 +809,15 @@ static int replace_page(struct vm_area_struct *vma, struct page *oldpage,
                goto out;
        }
 
-       get_page(newpage);
-       page_add_ksm_rmap(newpage);
+       get_page(kpage);
+       page_add_anon_rmap(kpage, vma, addr);
 
        flush_cache_page(vma, addr, pte_pfn(*ptep));
        ptep_clear_flush(vma, addr, ptep);
-       set_pte_at_notify(mm, addr, ptep, mk_pte(newpage, prot));
+       set_pte_at_notify(mm, addr, ptep, mk_pte(kpage, vma->vm_page_prot));
 
-       page_remove_rmap(oldpage);
-       put_page(oldpage);
+       page_remove_rmap(page);
+       put_page(page);
 
        pte_unmap_unlock(ptep, ptl);
        err = 0;
@@ -726,32 +827,27 @@ out:
 
 /*
  * try_to_merge_one_page - take two pages and merge them into one
- * @vma: the vma that hold the pte pointing into oldpage
- * @oldpage: the page that we want to replace with newpage
- * @newpage: the page that we want to map instead of oldpage
- *
- * Note:
- * oldpage should be a PageAnon page, while newpage should be a PageKsm page,
- * or a newly allocated kernel page which page_add_ksm_rmap will make PageKsm.
+ * @vma: the vma that holds the pte pointing to page
+ * @page: the PageAnon page that we want to replace with kpage
+ * @kpage: the PageKsm page that we want to map instead of page,
+ *         or NULL the first time when we want to use page as kpage.
  *
  * This function returns 0 if the pages were merged, -EFAULT otherwise.
  */
 static int try_to_merge_one_page(struct vm_area_struct *vma,
-                                struct page *oldpage,
-                                struct page *newpage)
+                                struct page *page, struct page *kpage)
 {
        pte_t orig_pte = __pte(0);
        int err = -EFAULT;
 
+       if (page == kpage)                      /* ksm page forked */
+               return 0;
+
        if (!(vma->vm_flags & VM_MERGEABLE))
                goto out;
-
-       if (!PageAnon(oldpage))
+       if (!PageAnon(page))
                goto out;
 
-       get_page(newpage);
-       get_page(oldpage);
-
        /*
         * We need the page lock to read a stable PageSwapCache in
         * write_protect_page().  We use trylock_page() instead of
@@ -759,26 +855,39 @@ static int try_to_merge_one_page(struct vm_area_struct *vma,
         * prefer to continue scanning and merging different pages,
         * then come back to this page when it is unlocked.
         */
-       if (!trylock_page(oldpage))
-               goto out_putpage;
+       if (!trylock_page(page))
+               goto out;
        /*
         * If this anonymous page is mapped only here, its pte may need
         * to be write-protected.  If it's mapped elsewhere, all of its
         * ptes are necessarily already write-protected.  But in either
         * case, we need to lock and check page_count is not raised.
         */
-       if (write_protect_page(vma, oldpage, &orig_pte)) {
-               unlock_page(oldpage);
-               goto out_putpage;
+       if (write_protect_page(vma, page, &orig_pte) == 0) {
+               if (!kpage) {
+                       /*
+                        * While we hold page lock, upgrade page from
+                        * PageAnon+anon_vma to PageKsm+NULL stable_node:
+                        * stable_tree_insert() will update stable_node.
+                        */
+                       set_page_stable_node(page, NULL);
+                       mark_page_accessed(page);
+                       err = 0;
+               } else if (pages_identical(page, kpage))
+                       err = replace_page(vma, page, kpage, orig_pte);
        }
-       unlock_page(oldpage);
 
-       if (pages_identical(oldpage, newpage))
-               err = replace_page(vma, oldpage, newpage, orig_pte);
+       if ((vma->vm_flags & VM_LOCKED) && kpage && !err) {
+               munlock_vma_page(page);
+               if (!PageMlocked(kpage)) {
+                       unlock_page(page);
+                       lock_page(kpage);
+                       mlock_vma_page(kpage);
+                       page = kpage;           /* for final unlock */
+               }
+       }
 
-out_putpage:
-       put_page(oldpage);
-       put_page(newpage);
+       unlock_page(page);
 out:
        return err;
 }
@@ -786,26 +895,31 @@ out:
 /*
  * try_to_merge_with_ksm_page - like try_to_merge_two_pages,
  * but no new kernel page is allocated: kpage must already be a ksm page.
+ *
+ * This function returns 0 if the pages were merged, -EFAULT otherwise.
  */
-static int try_to_merge_with_ksm_page(struct mm_struct *mm1,
-                                     unsigned long addr1,
-                                     struct page *page1,
-                                     struct page *kpage)
+static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item,
+                                     struct page *page, struct page *kpage)
 {
+       struct mm_struct *mm = rmap_item->mm;
        struct vm_area_struct *vma;
        int err = -EFAULT;
 
-       down_read(&mm1->mmap_sem);
-       if (ksm_test_exit(mm1))
+       down_read(&mm->mmap_sem);
+       if (ksm_test_exit(mm))
+               goto out;
+       vma = find_vma(mm, rmap_item->address);
+       if (!vma || vma->vm_start > rmap_item->address)
                goto out;
 
-       vma = find_vma(mm1, addr1);
-       if (!vma || vma->vm_start > addr1)
+       err = try_to_merge_one_page(vma, page, kpage);
+       if (err)
                goto out;
 
-       err = try_to_merge_one_page(vma, page1, kpage);
+       /* Must get reference to anon_vma while still holding mmap_sem */
+       hold_anon_vma(rmap_item, vma->anon_vma);
 out:
-       up_read(&mm1->mmap_sem);
+       up_read(&mm->mmap_sem);
        return err;
 }
 
@@ -813,109 +927,73 @@ out:
  * try_to_merge_two_pages - take two identical pages and prepare them
  * to be merged into one page.
  *
- * This function returns 0 if we successfully mapped two identical pages
- * into one page, -EFAULT otherwise.
+ * This function returns the kpage if we successfully merged two identical
+ * pages into one ksm page, NULL otherwise.
  *
- * Note that this function allocates a new kernel page: if one of the pages
+ * Note that this function upgrades page to ksm page: if one of the pages
  * is already a ksm page, try_to_merge_with_ksm_page should be used.
  */
-static int try_to_merge_two_pages(struct mm_struct *mm1, unsigned long addr1,
-                                 struct page *page1, struct mm_struct *mm2,
-                                 unsigned long addr2, struct page *page2)
+static struct page *try_to_merge_two_pages(struct rmap_item *rmap_item,
+                                          struct page *page,
+                                          struct rmap_item *tree_rmap_item,
+                                          struct page *tree_page)
 {
-       struct vm_area_struct *vma;
-       struct page *kpage;
-       int err = -EFAULT;
-
-       /*
-        * The number of nodes in the stable tree
-        * is the number of kernel pages that we hold.
-        */
-       if (ksm_max_kernel_pages &&
-           ksm_max_kernel_pages <= ksm_pages_shared)
-               return err;
-
-       kpage = alloc_page(GFP_HIGHUSER);
-       if (!kpage)
-               return err;
-
-       down_read(&mm1->mmap_sem);
-       if (ksm_test_exit(mm1)) {
-               up_read(&mm1->mmap_sem);
-               goto out;
-       }
-       vma = find_vma(mm1, addr1);
-       if (!vma || vma->vm_start > addr1) {
-               up_read(&mm1->mmap_sem);
-               goto out;
-       }
-
-       copy_user_highpage(kpage, page1, addr1, vma);
-       err = try_to_merge_one_page(vma, page1, kpage);
-       up_read(&mm1->mmap_sem);
+       int err;
 
+       err = try_to_merge_with_ksm_page(rmap_item, page, NULL);
        if (!err) {
-               err = try_to_merge_with_ksm_page(mm2, addr2, page2, kpage);
+               err = try_to_merge_with_ksm_page(tree_rmap_item,
+                                                       tree_page, page);
                /*
                 * If that fails, we have a ksm page with only one pte
                 * pointing to it: so break it.
                 */
                if (err)
-                       break_cow(mm1, addr1);
+                       break_cow(rmap_item);
        }
-out:
-       put_page(kpage);
-       return err;
+       return err ? NULL : page;
 }
 
 /*
- * stable_tree_search - search page inside the stable tree
- * @page: the page that we are searching identical pages to.
- * @page2: pointer into identical page that we are holding inside the stable
- *        tree that we have found.
- * @rmap_item: the reverse mapping item
+ * stable_tree_search - search for page inside the stable tree
  *
  * This function checks if there is a page inside the stable tree
  * with identical content to the page that we are scanning right now.
  *
- * This function return rmap_item pointer to the identical item if found,
+ * This function returns the stable tree node of identical content if found,
  * NULL otherwise.
  */
-static struct rmap_item *stable_tree_search(struct page *page,
-                                           struct page **page2,
-                                           struct rmap_item *rmap_item)
+static struct page *stable_tree_search(struct page *page)
 {
        struct rb_node *node = root_stable_tree.rb_node;
+       struct stable_node *stable_node;
+
+       stable_node = page_stable_node(page);
+       if (stable_node) {                      /* ksm page forked */
+               get_page(page);
+               return page;
+       }
 
        while (node) {
-               struct rmap_item *tree_rmap_item, *next_rmap_item;
+               struct page *tree_page;
                int ret;
 
-               tree_rmap_item = rb_entry(node, struct rmap_item, node);
-               while (tree_rmap_item) {
-                       BUG_ON(!in_stable_tree(tree_rmap_item));
-                       cond_resched();
-                       page2[0] = get_ksm_page(tree_rmap_item);
-                       if (page2[0])
-                               break;
-                       next_rmap_item = tree_rmap_item->next;
-                       remove_rmap_item_from_tree(tree_rmap_item);
-                       tree_rmap_item = next_rmap_item;
-               }
-               if (!tree_rmap_item)
+               cond_resched();
+               stable_node = rb_entry(node, struct stable_node, node);
+               tree_page = get_ksm_page(stable_node);
+               if (!tree_page)
                        return NULL;
 
-               ret = memcmp_pages(page, page2[0]);
+               ret = memcmp_pages(page, tree_page);
 
                if (ret < 0) {
-                       put_page(page2[0]);
+                       put_page(tree_page);
                        node = node->rb_left;
                } else if (ret > 0) {
-                       put_page(page2[0]);
+                       put_page(tree_page);
                        node = node->rb_right;
-               } else {
-                       return tree_rmap_item;
-               }
+               } else
+                       return tree_page;
        }
 
        return NULL;
@@ -925,38 +1003,26 @@ static struct rmap_item *stable_tree_search(struct page *page,
  * stable_tree_insert - insert rmap_item pointing to new ksm page
  * into the stable tree.
  *
- * @page: the page that we are searching identical page to inside the stable
- *       tree.
- * @rmap_item: pointer to the reverse mapping item.
- *
- * This function returns rmap_item if success, NULL otherwise.
+ * This function returns the stable tree node just allocated on success,
+ * NULL otherwise.
  */
-static struct rmap_item *stable_tree_insert(struct page *page,
-                                           struct rmap_item *rmap_item)
+static struct stable_node *stable_tree_insert(struct page *kpage)
 {
        struct rb_node **new = &root_stable_tree.rb_node;
        struct rb_node *parent = NULL;
+       struct stable_node *stable_node;
 
        while (*new) {
-               struct rmap_item *tree_rmap_item, *next_rmap_item;
                struct page *tree_page;
                int ret;
 
-               tree_rmap_item = rb_entry(*new, struct rmap_item, node);
-               while (tree_rmap_item) {
-                       BUG_ON(!in_stable_tree(tree_rmap_item));
-                       cond_resched();
-                       tree_page = get_ksm_page(tree_rmap_item);
-                       if (tree_page)
-                               break;
-                       next_rmap_item = tree_rmap_item->next;
-                       remove_rmap_item_from_tree(tree_rmap_item);
-                       tree_rmap_item = next_rmap_item;
-               }
-               if (!tree_rmap_item)
+               cond_resched();
+               stable_node = rb_entry(*new, struct stable_node, node);
+               tree_page = get_ksm_page(stable_node);
+               if (!tree_page)
                        return NULL;
 
-               ret = memcmp_pages(page, tree_page);
+               ret = memcmp_pages(kpage, tree_page);
                put_page(tree_page);
 
                parent = *new;
@@ -974,22 +1040,24 @@ static struct rmap_item *stable_tree_insert(struct page *page,
                }
        }
 
-       rmap_item->address |= NODE_FLAG | STABLE_FLAG;
-       rmap_item->next = NULL;
-       rb_link_node(&rmap_item->node, parent, new);
-       rb_insert_color(&rmap_item->node, &root_stable_tree);
+       stable_node = alloc_stable_node();
+       if (!stable_node)
+               return NULL;
 
-       ksm_pages_shared++;
-       return rmap_item;
+       rb_link_node(&stable_node->node, parent, new);
+       rb_insert_color(&stable_node->node, &root_stable_tree);
+
+       INIT_HLIST_HEAD(&stable_node->hlist);
+
+       stable_node->kpfn = page_to_pfn(kpage);
+       set_page_stable_node(kpage, stable_node);
+
+       return stable_node;
 }
 
 /*
- * unstable_tree_search_insert - search and insert items into the unstable tree.
- *
- * @page: the page that we are going to search for identical page or to insert
- *       into the unstable tree
- * @page2: pointer into identical page that was found inside the unstable tree
- * @rmap_item: the reverse mapping item of page
+ * unstable_tree_search_insert - search for identical page,
+ * else insert rmap_item into the unstable tree.
  *
  * This function searches for a page in the unstable tree identical to the
  * page currently being scanned; and if no identical page is found in the
@@ -1001,47 +1069,50 @@ static struct rmap_item *stable_tree_insert(struct page *page,
  * This function does both searching and inserting, because they share
  * the same walking algorithm in an rbtree.
  */
-static struct rmap_item *unstable_tree_search_insert(struct page *page,
-                                               struct page **page2,
-                                               struct rmap_item *rmap_item)
+static
+struct rmap_item *unstable_tree_search_insert(struct rmap_item *rmap_item,
+                                             struct page *page,
+                                             struct page **tree_pagep)
+
 {
        struct rb_node **new = &root_unstable_tree.rb_node;
        struct rb_node *parent = NULL;
 
        while (*new) {
                struct rmap_item *tree_rmap_item;
+               struct page *tree_page;
                int ret;
 
                cond_resched();
                tree_rmap_item = rb_entry(*new, struct rmap_item, node);
-               page2[0] = get_mergeable_page(tree_rmap_item);
-               if (!page2[0])
+               tree_page = get_mergeable_page(tree_rmap_item);
+               if (!tree_page)
                        return NULL;
 
                /*
-                * Don't substitute an unswappable ksm page
-                * just for one good swappable forked page.
+                * Don't substitute a ksm page for a forked page.
                 */
-               if (page == page2[0]) {
-                       put_page(page2[0]);
+               if (page == tree_page) {
+                       put_page(tree_page);
                        return NULL;
                }
 
-               ret = memcmp_pages(page, page2[0]);
+               ret = memcmp_pages(page, tree_page);
 
                parent = *new;
                if (ret < 0) {
-                       put_page(page2[0]);
+                       put_page(tree_page);
                        new = &parent->rb_left;
                } else if (ret > 0) {
-                       put_page(page2[0]);
+                       put_page(tree_page);
                        new = &parent->rb_right;
                } else {
+                       *tree_pagep = tree_page;
                        return tree_rmap_item;
                }
        }
 
-       rmap_item->address |= NODE_FLAG;
+       rmap_item->address |= UNSTABLE_FLAG;
        rmap_item->address |= (ksm_scan.seqnr & SEQNR_MASK);
        rb_link_node(&rmap_item->node, parent, new);
        rb_insert_color(&rmap_item->node, &root_unstable_tree);
@@ -1056,18 +1127,16 @@ static struct rmap_item *unstable_tree_search_insert(struct page *page,
  * the same ksm page.
  */
 static void stable_tree_append(struct rmap_item *rmap_item,
-                              struct rmap_item *tree_rmap_item)
+                              struct stable_node *stable_node)
 {
-       rmap_item->next = tree_rmap_item->next;
-       rmap_item->prev = tree_rmap_item;
-
-       if (tree_rmap_item->next)
-               tree_rmap_item->next->prev = rmap_item;
-
-       tree_rmap_item->next = rmap_item;
+       rmap_item->head = stable_node;
        rmap_item->address |= STABLE_FLAG;
+       hlist_add_head(&rmap_item->hlist, &stable_node->hlist);
 
-       ksm_pages_sharing++;
+       if (rmap_item->hlist.next)
+               ksm_pages_sharing++;
+       else
+               ksm_pages_shared++;
 }
 
 /*
@@ -1081,49 +1150,37 @@ static void stable_tree_append(struct rmap_item *rmap_item,
  */
 static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
 {
-       struct page *page2[1];
        struct rmap_item *tree_rmap_item;
+       struct page *tree_page = NULL;
+       struct stable_node *stable_node;
+       struct page *kpage;
        unsigned int checksum;
        int err;
 
-       if (in_stable_tree(rmap_item))
-               remove_rmap_item_from_tree(rmap_item);
+       remove_rmap_item_from_tree(rmap_item);
 
        /* We first start with searching the page inside the stable tree */
-       tree_rmap_item = stable_tree_search(page, page2, rmap_item);
-       if (tree_rmap_item) {
-               if (page == page2[0])                   /* forked */
-                       err = 0;
-               else
-                       err = try_to_merge_with_ksm_page(rmap_item->mm,
-                                                        rmap_item->address,
-                                                        page, page2[0]);
-               put_page(page2[0]);
-
+       kpage = stable_tree_search(page);
+       if (kpage) {
+               err = try_to_merge_with_ksm_page(rmap_item, page, kpage);
                if (!err) {
                        /*
                         * The page was successfully merged:
                         * add its rmap_item to the stable tree.
                         */
-                       stable_tree_append(rmap_item, tree_rmap_item);
+                       lock_page(kpage);
+                       stable_tree_append(rmap_item, page_stable_node(kpage));
+                       unlock_page(kpage);
                }
+               put_page(kpage);
                return;
        }
 
        /*
-        * A ksm page might have got here by fork, but its other
-        * references have already been removed from the stable tree.
-        * Or it might be left over from a break_ksm which failed
-        * when the mem_cgroup had reached its limit: try again now.
-        */
-       if (PageKsm(page))
-               break_cow(rmap_item->mm, rmap_item->address);
-
-       /*
-        * In case the hash value of the page was changed from the last time we
-        * have calculated it, this page to be changed frequely, therefore we
-        * don't want to insert it to the unstable tree, and we don't want to
-        * waste our time to search if there is something identical to it there.
+        * If the hash value of the page has changed from the last time
+        * we calculated it, this page is changing frequently: therefore we
+        * don't want to insert it in the unstable tree, and we don't want
+        * to waste our time searching for something identical to it there.
         */
        checksum = calc_checksum(page);
        if (rmap_item->oldchecksum != checksum) {
@@ -1131,21 +1188,27 @@ static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
                return;
        }
 
-       tree_rmap_item = unstable_tree_search_insert(page, page2, rmap_item);
+       tree_rmap_item =
+               unstable_tree_search_insert(rmap_item, page, &tree_page);
        if (tree_rmap_item) {
-               err = try_to_merge_two_pages(rmap_item->mm,
-                                            rmap_item->address, page,
-                                            tree_rmap_item->mm,
-                                            tree_rmap_item->address, page2[0]);
+               kpage = try_to_merge_two_pages(rmap_item, page,
+                                               tree_rmap_item, tree_page);
+               put_page(tree_page);
                /*
                 * As soon as we merge this page, we want to remove the
                 * rmap_item of the page we have merged with from the unstable
                 * tree, and insert it instead as new node in the stable tree.
                 */
-               if (!err) {
-                       rb_erase(&tree_rmap_item->node, &root_unstable_tree);
-                       tree_rmap_item->address &= ~NODE_FLAG;
-                       ksm_pages_unshared--;
+               if (kpage) {
+                       remove_rmap_item_from_tree(tree_rmap_item);
+
+                       lock_page(kpage);
+                       stable_node = stable_tree_insert(kpage);
+                       if (stable_node) {
+                               stable_tree_append(tree_rmap_item, stable_node);
+                               stable_tree_append(rmap_item, stable_node);
+                       }
+                       unlock_page(kpage);
 
                        /*
                         * If we fail to insert the page into the stable tree,
@@ -1153,37 +1216,28 @@ static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
                         * to a ksm page left outside the stable tree,
                         * in which case we need to break_cow on both.
                         */
-                       if (stable_tree_insert(page2[0], tree_rmap_item))
-                               stable_tree_append(rmap_item, tree_rmap_item);
-                       else {
-                               break_cow(tree_rmap_item->mm,
-                                               tree_rmap_item->address);
-                               break_cow(rmap_item->mm, rmap_item->address);
+                       if (!stable_node) {
+                               break_cow(tree_rmap_item);
+                               break_cow(rmap_item);
                        }
                }
-
-               put_page(page2[0]);
        }
 }
 
 static struct rmap_item *get_next_rmap_item(struct mm_slot *mm_slot,
-                                           struct list_head *cur,
+                                           struct rmap_item **rmap_list,
                                            unsigned long addr)
 {
        struct rmap_item *rmap_item;
 
-       while (cur != &mm_slot->rmap_list) {
-               rmap_item = list_entry(cur, struct rmap_item, link);
-               if ((rmap_item->address & PAGE_MASK) == addr) {
-                       if (!in_stable_tree(rmap_item))
-                               remove_rmap_item_from_tree(rmap_item);
+       while (*rmap_list) {
+               rmap_item = *rmap_list;
+               if ((rmap_item->address & PAGE_MASK) == addr)
                        return rmap_item;
-               }
                if (rmap_item->address > addr)
                        break;
-               cur = cur->next;
+               *rmap_list = rmap_item->rmap_list;
                remove_rmap_item_from_tree(rmap_item);
-               list_del(&rmap_item->link);
                free_rmap_item(rmap_item);
        }
 
@@ -1192,7 +1246,8 @@ static struct rmap_item *get_next_rmap_item(struct mm_slot *mm_slot,
                /* It has already been zeroed */
                rmap_item->mm = mm_slot->mm;
                rmap_item->address = addr;
-               list_add_tail(&rmap_item->link, cur);
+               rmap_item->rmap_list = *rmap_list;
+               *rmap_list = rmap_item;
        }
        return rmap_item;
 }
@@ -1217,8 +1272,7 @@ static struct rmap_item *scan_get_next_rmap_item(struct page **page)
                spin_unlock(&ksm_mmlist_lock);
 next_mm:
                ksm_scan.address = 0;
-               ksm_scan.rmap_item = list_entry(&slot->rmap_list,
-                                               struct rmap_item, link);
+               ksm_scan.rmap_list = &slot->rmap_list;
        }
 
        mm = slot->mm;
@@ -1244,10 +1298,10 @@ next_mm:
                                flush_anon_page(vma, *page, ksm_scan.address);
                                flush_dcache_page(*page);
                                rmap_item = get_next_rmap_item(slot,
-                                       ksm_scan.rmap_item->link.next,
-                                       ksm_scan.address);
+                                       ksm_scan.rmap_list, ksm_scan.address);
                                if (rmap_item) {
-                                       ksm_scan.rmap_item = rmap_item;
+                                       ksm_scan.rmap_list =
+                                                       &rmap_item->rmap_list;
                                        ksm_scan.address += PAGE_SIZE;
                                } else
                                        put_page(*page);
@@ -1263,14 +1317,13 @@ next_mm:
 
        if (ksm_test_exit(mm)) {
                ksm_scan.address = 0;
-               ksm_scan.rmap_item = list_entry(&slot->rmap_list,
-                                               struct rmap_item, link);
+               ksm_scan.rmap_list = &slot->rmap_list;
        }
        /*
         * Nuke all the rmap_items that are above this current rmap:
         * because there were no VM_MERGEABLE vmas with such addresses.
         */
-       remove_trailing_rmap_items(slot, ksm_scan.rmap_item->link.next);
+       remove_trailing_rmap_items(slot, ksm_scan.rmap_list);
 
        spin_lock(&ksm_mmlist_lock);
        ksm_scan.mm_slot = list_entry(slot->mm_list.next,
@@ -1323,14 +1376,6 @@ static void ksm_do_scan(unsigned int scan_npages)
                        return;
                if (!PageKsm(page) || !in_stable_tree(rmap_item))
                        cmp_and_merge_page(page, rmap_item);
-               else if (page_mapcount(page) == 1) {
-                       /*
-                        * Replace now-unshared ksm page by ordinary page.
-                        */
-                       break_cow(rmap_item->mm, rmap_item->address);
-                       remove_rmap_item_from_tree(rmap_item);
-                       rmap_item->oldchecksum = calc_checksum(page);
-               }
                put_page(page);
        }
 }
@@ -1375,7 +1420,7 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
                if (*vm_flags & (VM_MERGEABLE | VM_SHARED  | VM_MAYSHARE   |
                                 VM_PFNMAP    | VM_IO      | VM_DONTEXPAND |
                                 VM_RESERVED  | VM_HUGETLB | VM_INSERTPAGE |
-                                VM_MIXEDMAP  | VM_SAO))
+                                VM_NONLINEAR | VM_MIXEDMAP | VM_SAO))
                        return 0;               /* just ignore the advice */
 
                if (!test_bit(MMF_VM_MERGEABLE, &mm->flags)) {
@@ -1452,7 +1497,7 @@ void __ksm_exit(struct mm_struct *mm)
        spin_lock(&ksm_mmlist_lock);
        mm_slot = get_mm_slot(mm);
        if (mm_slot && ksm_scan.mm_slot != mm_slot) {
-               if (list_empty(&mm_slot->rmap_list)) {
+               if (!mm_slot->rmap_list) {
                        hlist_del(&mm_slot->link);
                        list_del(&mm_slot->mm_list);
                        easy_to_free = 1;
@@ -1473,6 +1518,249 @@ void __ksm_exit(struct mm_struct *mm)
        }
 }
 
+struct page *ksm_does_need_to_copy(struct page *page,
+                       struct vm_area_struct *vma, unsigned long address)
+{
+       struct page *new_page;
+
+       unlock_page(page);      /* any racers will COW it, not modify it */
+
+       new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
+       if (new_page) {
+               copy_user_highpage(new_page, page, address, vma);
+
+               SetPageDirty(new_page);
+               __SetPageUptodate(new_page);
+               SetPageSwapBacked(new_page);
+               __set_page_locked(new_page);
+
+               if (page_evictable(new_page, vma))
+                       lru_cache_add_lru(new_page, LRU_ACTIVE_ANON);
+               else
+                       add_page_to_unevictable_list(new_page);
+       }
+
+       page_cache_release(page);
+       return new_page;
+}
+
+int page_referenced_ksm(struct page *page, struct mem_cgroup *memcg,
+                       unsigned long *vm_flags)
+{
+       struct stable_node *stable_node;
+       struct rmap_item *rmap_item;
+       struct hlist_node *hlist;
+       unsigned int mapcount = page_mapcount(page);
+       int referenced = 0;
+       int search_new_forks = 0;
+
+       VM_BUG_ON(!PageKsm(page));
+       VM_BUG_ON(!PageLocked(page));
+
+       stable_node = page_stable_node(page);
+       if (!stable_node)
+               return 0;
+again:
+       hlist_for_each_entry(rmap_item, hlist, &stable_node->hlist, hlist) {
+               struct anon_vma *anon_vma = rmap_item->anon_vma;
+               struct vm_area_struct *vma;
+
+               spin_lock(&anon_vma->lock);
+               list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
+                       if (rmap_item->address < vma->vm_start ||
+                           rmap_item->address >= vma->vm_end)
+                               continue;
+                       /*
+                        * Initially we examine only the vma which covers this
+                        * rmap_item; but later, if there is still work to do,
+                        * we examine covering vmas in other mms: in case they
+                        * were forked from the original since ksmd passed.
+                        */
+                       if ((rmap_item->mm == vma->vm_mm) == search_new_forks)
+                               continue;
+
+                       if (memcg && !mm_match_cgroup(vma->vm_mm, memcg))
+                               continue;
+
+                       referenced += page_referenced_one(page, vma,
+                               rmap_item->address, &mapcount, vm_flags);
+                       if (!search_new_forks || !mapcount)
+                               break;
+               }
+               spin_unlock(&anon_vma->lock);
+               if (!mapcount)
+                       goto out;
+       }
+       if (!search_new_forks++)
+               goto again;
+out:
+       return referenced;
+}
+
+int try_to_unmap_ksm(struct page *page, enum ttu_flags flags)
+{
+       struct stable_node *stable_node;
+       struct hlist_node *hlist;
+       struct rmap_item *rmap_item;
+       int ret = SWAP_AGAIN;
+       int search_new_forks = 0;
+
+       VM_BUG_ON(!PageKsm(page));
+       VM_BUG_ON(!PageLocked(page));
+
+       stable_node = page_stable_node(page);
+       if (!stable_node)
+               return SWAP_FAIL;
+again:
+       hlist_for_each_entry(rmap_item, hlist, &stable_node->hlist, hlist) {
+               struct anon_vma *anon_vma = rmap_item->anon_vma;
+               struct vm_area_struct *vma;
+
+               spin_lock(&anon_vma->lock);
+               list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
+                       if (rmap_item->address < vma->vm_start ||
+                           rmap_item->address >= vma->vm_end)
+                               continue;
+                       /*
+                        * Initially we examine only the vma which covers this
+                        * rmap_item; but later, if there is still work to do,
+                        * we examine covering vmas in other mms: in case they
+                        * were forked from the original since ksmd passed.
+                        */
+                       if ((rmap_item->mm == vma->vm_mm) == search_new_forks)
+                               continue;
+
+                       ret = try_to_unmap_one(page, vma,
+                                       rmap_item->address, flags);
+                       if (ret != SWAP_AGAIN || !page_mapped(page)) {
+                               spin_unlock(&anon_vma->lock);
+                               goto out;
+                       }
+               }
+               spin_unlock(&anon_vma->lock);
+       }
+       if (!search_new_forks++)
+               goto again;
+out:
+       return ret;
+}
+
+#ifdef CONFIG_MIGRATION
+int rmap_walk_ksm(struct page *page, int (*rmap_one)(struct page *,
+                 struct vm_area_struct *, unsigned long, void *), void *arg)
+{
+       struct stable_node *stable_node;
+       struct hlist_node *hlist;
+       struct rmap_item *rmap_item;
+       int ret = SWAP_AGAIN;
+       int search_new_forks = 0;
+
+       VM_BUG_ON(!PageKsm(page));
+       VM_BUG_ON(!PageLocked(page));
+
+       stable_node = page_stable_node(page);
+       if (!stable_node)
+               return ret;
+again:
+       hlist_for_each_entry(rmap_item, hlist, &stable_node->hlist, hlist) {
+               struct anon_vma *anon_vma = rmap_item->anon_vma;
+               struct vm_area_struct *vma;
+
+               spin_lock(&anon_vma->lock);
+               list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
+                       if (rmap_item->address < vma->vm_start ||
+                           rmap_item->address >= vma->vm_end)
+                               continue;
+                       /*
+                        * Initially we examine only the vma which covers this
+                        * rmap_item; but later, if there is still work to do,
+                        * we examine covering vmas in other mms: in case they
+                        * were forked from the original since ksmd passed.
+                        */
+                       if ((rmap_item->mm == vma->vm_mm) == search_new_forks)
+                               continue;
+
+                       ret = rmap_one(page, vma, rmap_item->address, arg);
+                       if (ret != SWAP_AGAIN) {
+                               spin_unlock(&anon_vma->lock);
+                               goto out;
+                       }
+               }
+               spin_unlock(&anon_vma->lock);
+       }
+       if (!search_new_forks++)
+               goto again;
+out:
+       return ret;
+}
+
+void ksm_migrate_page(struct page *newpage, struct page *oldpage)
+{
+       struct stable_node *stable_node;
+
+       VM_BUG_ON(!PageLocked(oldpage));
+       VM_BUG_ON(!PageLocked(newpage));
+       VM_BUG_ON(newpage->mapping != oldpage->mapping);
+
+       stable_node = page_stable_node(newpage);
+       if (stable_node) {
+               VM_BUG_ON(stable_node->kpfn != page_to_pfn(oldpage));
+               stable_node->kpfn = page_to_pfn(newpage);
+       }
+}
+#endif /* CONFIG_MIGRATION */
+
+#ifdef CONFIG_MEMORY_HOTREMOVE
+static struct stable_node *ksm_check_stable_tree(unsigned long start_pfn,
+                                                unsigned long end_pfn)
+{
+       struct rb_node *node;
+
+       for (node = rb_first(&root_stable_tree); node; node = rb_next(node)) {
+               struct stable_node *stable_node;
+
+               stable_node = rb_entry(node, struct stable_node, node);
+               if (stable_node->kpfn >= start_pfn &&
+                   stable_node->kpfn < end_pfn)
+                       return stable_node;
+       }
+       return NULL;
+}
+
+static int ksm_memory_callback(struct notifier_block *self,
+                              unsigned long action, void *arg)
+{
+       struct memory_notify *mn = arg;
+       struct stable_node *stable_node;
+
+       switch (action) {
+       case MEM_GOING_OFFLINE:
+               /*
+                * Keep it very simple for now: just lock out ksmd and
+                * MADV_UNMERGEABLE while any memory is going offline.
+                */
+               mutex_lock(&ksm_thread_mutex);
+               break;
+
+       case MEM_OFFLINE:
+               /*
+                * Most of the work is done by page migration; but there might
+                * be a few stable_nodes left over, still pointing to struct
+                * pages which have been offlined: prune those from the tree.
+                */
+               while ((stable_node = ksm_check_stable_tree(mn->start_pfn,
+                                       mn->start_pfn + mn->nr_pages)) != NULL)
+                       remove_node_from_stable_tree(stable_node);
+               /* fallthrough */
+
+       case MEM_CANCEL_OFFLINE:
+               mutex_unlock(&ksm_thread_mutex);
+               break;
+       }
+       return NOTIFY_OK;
+}
+#endif /* CONFIG_MEMORY_HOTREMOVE */
+
 #ifdef CONFIG_SYSFS
 /*
  * This all compiles without CONFIG_SYSFS, but is a waste of space.
@@ -1551,8 +1839,8 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
        /*
         * KSM_RUN_MERGE sets ksmd running, and 0 stops it running.
         * KSM_RUN_UNMERGE stops it running and unmerges all rmap_items,
-        * breaking COW to free the unswappable pages_shared (but leaves
-        * mm_slots on the list for when ksmd may be set running again).
+        * breaking COW to free the pages_shared (but leaves mm_slots
+        * on the list for when ksmd may be set running again).
         */
 
        mutex_lock(&ksm_thread_mutex);
@@ -1577,29 +1865,6 @@ static ssize_t run_store(struct kobject *kobj, struct kobj_attribute *attr,
 }
 KSM_ATTR(run);
 
-static ssize_t max_kernel_pages_store(struct kobject *kobj,
-                                     struct kobj_attribute *attr,
-                                     const char *buf, size_t count)
-{
-       int err;
-       unsigned long nr_pages;
-
-       err = strict_strtoul(buf, 10, &nr_pages);
-       if (err)
-               return -EINVAL;
-
-       ksm_max_kernel_pages = nr_pages;
-
-       return count;
-}
-
-static ssize_t max_kernel_pages_show(struct kobject *kobj,
-                                    struct kobj_attribute *attr, char *buf)
-{
-       return sprintf(buf, "%lu\n", ksm_max_kernel_pages);
-}
-KSM_ATTR(max_kernel_pages);
-
 static ssize_t pages_shared_show(struct kobject *kobj,
                                 struct kobj_attribute *attr, char *buf)
 {
@@ -1649,7 +1914,6 @@ static struct attribute *ksm_attrs[] = {
        &sleep_millisecs_attr.attr,
        &pages_to_scan_attr.attr,
        &run_attr.attr,
-       &max_kernel_pages_attr.attr,
        &pages_shared_attr.attr,
        &pages_sharing_attr.attr,
        &pages_unshared_attr.attr,
@@ -1669,8 +1933,6 @@ static int __init ksm_init(void)
        struct task_struct *ksm_thread;
        int err;
 
-       ksm_max_kernel_pages = totalram_pages / 4;
-
        err = ksm_slab_init();
        if (err)
                goto out;
@@ -1698,6 +1960,13 @@ static int __init ksm_init(void)
 
 #endif /* CONFIG_SYSFS */
 
+#ifdef CONFIG_MEMORY_HOTREMOVE
+       /*
+        * Choose a high priority since the callback takes ksm_thread_mutex:
+        * later callbacks could only be taking locks which nest within that.
+        */
+       hotplug_memory_notifier(ksm_memory_callback, 100);
+#endif
        return 0;
 
 out_free2:
index 35b1479b7c9d080ed97b772da44603c4f757093c..319528b8db74c8d0c7cd10c8468acb5539aea7dd 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/pagemap.h>
 #include <linux/syscalls.h>
 #include <linux/mempolicy.h>
+#include <linux/page-isolation.h>
 #include <linux/hugetlb.h>
 #include <linux/sched.h>
 #include <linux/ksm.h>
@@ -222,7 +223,7 @@ static long madvise_remove(struct vm_area_struct *vma,
 /*
  * Error injection support for memory error handling.
  */
-static int madvise_hwpoison(unsigned long start, unsigned long end)
+static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end)
 {
        int ret = 0;
 
@@ -230,15 +231,21 @@ static int madvise_hwpoison(unsigned long start, unsigned long end)
                return -EPERM;
        for (; start < end; start += PAGE_SIZE) {
                struct page *p;
-               int ret = get_user_pages(current, current->mm, start, 1,
-                                               0, 0, &p, NULL);
+               int ret = get_user_pages_fast(start, 1, 0, &p);
                if (ret != 1)
                        return ret;
+               if (bhv == MADV_SOFT_OFFLINE) {
+                       printk(KERN_INFO "Soft offlining page %lx at %lx\n",
+                               page_to_pfn(p), start);
+                       ret = soft_offline_page(p, MF_COUNT_INCREASED);
+                       if (ret)
+                               break;
+                       continue;
+               }
                printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n",
                       page_to_pfn(p), start);
                /* Ignore return value for now */
-               __memory_failure(page_to_pfn(p), 0, 1);
-               put_page(p);
+               __memory_failure(page_to_pfn(p), 0, MF_COUNT_INCREASED);
        }
        return ret;
 }
@@ -335,8 +342,8 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
        size_t len;
 
 #ifdef CONFIG_MEMORY_FAILURE
-       if (behavior == MADV_HWPOISON)
-               return madvise_hwpoison(start, start+len_in);
+       if (behavior == MADV_HWPOISON || behavior == MADV_SOFT_OFFLINE)
+               return madvise_hwpoison(behavior, start, start+len_in);
 #endif
        if (!madvise_behavior_valid(behavior))
                return error;
index c31a310aa146213d822060ad716a7d94b65a349f..488b644e0e8ef8f55ddc877b5359567b9cb82874 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/vmalloc.h>
 #include <linux/mm_inline.h>
 #include <linux/page_cgroup.h>
+#include <linux/cpu.h>
 #include "internal.h"
 
 #include <asm/uaccess.h>
@@ -54,7 +55,6 @@ static int really_do_swap_account __initdata = 1; /* for remember boot option*/
 #define do_swap_account                (0)
 #endif
 
-static DEFINE_MUTEX(memcg_tasklist);   /* can be hold under cgroup_mutex */
 #define SOFTLIMIT_EVENTS_THRESH (1000)
 
 /*
@@ -66,7 +66,7 @@ enum mem_cgroup_stat_index {
         */
        MEM_CGROUP_STAT_CACHE,     /* # of pages charged as cache */
        MEM_CGROUP_STAT_RSS,       /* # of pages charged as anon rss */
-       MEM_CGROUP_STAT_MAPPED_FILE,  /* # of pages charged as file rss */
+       MEM_CGROUP_STAT_FILE_MAPPED,  /* # of pages charged as file rss */
        MEM_CGROUP_STAT_PGPGIN_COUNT,   /* # of pages paged in */
        MEM_CGROUP_STAT_PGPGOUT_COUNT,  /* # of pages paged out */
        MEM_CGROUP_STAT_EVENTS, /* sum of pagein + pageout for internal use */
@@ -275,6 +275,7 @@ enum charge_type {
 static void mem_cgroup_get(struct mem_cgroup *mem);
 static void mem_cgroup_put(struct mem_cgroup *mem);
 static struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *mem);
+static void drain_all_stock_async(void);
 
 static struct mem_cgroup_per_zone *
 mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid)
@@ -282,6 +283,11 @@ mem_cgroup_zoneinfo(struct mem_cgroup *mem, int nid, int zid)
        return &mem->info.nodeinfo[nid]->zoneinfo[zid];
 }
 
+struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *mem)
+{
+       return &mem->css;
+}
+
 static struct mem_cgroup_per_zone *
 page_cgroup_zoneinfo(struct page_cgroup *pc)
 {
@@ -758,7 +764,13 @@ int task_in_mem_cgroup(struct task_struct *task, const struct mem_cgroup *mem)
        task_unlock(task);
        if (!curr)
                return 0;
-       if (curr->use_hierarchy)
+       /*
+        * We should check use_hierarchy of "mem" not "curr". Because checking
+        * use_hierarchy of "curr" here make this function true if hierarchy is
+        * enabled in "curr" and "curr" is a child of "mem" in *cgroup*
+        * hierarchy(even if use_hierarchy is disabled in "mem").
+        */
+       if (mem->use_hierarchy)
                ret = css_is_ancestor(&curr->css, &mem->css);
        else
                ret = (curr == mem);
@@ -1007,7 +1019,7 @@ void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
        static char memcg_name[PATH_MAX];
        int ret;
 
-       if (!memcg)
+       if (!memcg || !p)
                return;
 
 
@@ -1137,6 +1149,8 @@ static int mem_cgroup_hierarchical_reclaim(struct mem_cgroup *root_mem,
                victim = mem_cgroup_select_victim(root_mem);
                if (victim == root_mem) {
                        loop++;
+                       if (loop >= 1)
+                               drain_all_stock_async();
                        if (loop >= 2) {
                                /*
                                 * If we have not been able to reclaim
@@ -1223,7 +1237,7 @@ static void record_last_oom(struct mem_cgroup *mem)
  * Currently used to update mapped file statistics, but the routine can be
  * generalized to update other statistics as well.
  */
-void mem_cgroup_update_mapped_file_stat(struct page *page, int val)
+void mem_cgroup_update_file_mapped(struct page *page, int val)
 {
        struct mem_cgroup *mem;
        struct mem_cgroup_stat *stat;
@@ -1231,9 +1245,6 @@ void mem_cgroup_update_mapped_file_stat(struct page *page, int val)
        int cpu;
        struct page_cgroup *pc;
 
-       if (!page_is_file_cache(page))
-               return;
-
        pc = lookup_page_cgroup(page);
        if (unlikely(!pc))
                return;
@@ -1253,11 +1264,138 @@ void mem_cgroup_update_mapped_file_stat(struct page *page, int val)
        stat = &mem->stat;
        cpustat = &stat->cpustat[cpu];
 
-       __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE, val);
+       __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_FILE_MAPPED, val);
 done:
        unlock_page_cgroup(pc);
 }
 
+/*
+ * size of first charge trial. "32" comes from vmscan.c's magic value.
+ * TODO: maybe necessary to use big numbers in big irons.
+ */
+#define CHARGE_SIZE    (32 * PAGE_SIZE)
+struct memcg_stock_pcp {
+       struct mem_cgroup *cached; /* this never be root cgroup */
+       int charge;
+       struct work_struct work;
+};
+static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock);
+static atomic_t memcg_drain_count;
+
+/*
+ * Try to consume stocked charge on this cpu. If success, PAGE_SIZE is consumed
+ * from local stock and true is returned. If the stock is 0 or charges from a
+ * cgroup which is not current target, returns false. This stock will be
+ * refilled.
+ */
+static bool consume_stock(struct mem_cgroup *mem)
+{
+       struct memcg_stock_pcp *stock;
+       bool ret = true;
+
+       stock = &get_cpu_var(memcg_stock);
+       if (mem == stock->cached && stock->charge)
+               stock->charge -= PAGE_SIZE;
+       else /* need to call res_counter_charge */
+               ret = false;
+       put_cpu_var(memcg_stock);
+       return ret;
+}
+
+/*
+ * Returns stocks cached in percpu to res_counter and reset cached information.
+ */
+static void drain_stock(struct memcg_stock_pcp *stock)
+{
+       struct mem_cgroup *old = stock->cached;
+
+       if (stock->charge) {
+               res_counter_uncharge(&old->res, stock->charge);
+               if (do_swap_account)
+                       res_counter_uncharge(&old->memsw, stock->charge);
+       }
+       stock->cached = NULL;
+       stock->charge = 0;
+}
+
+/*
+ * This must be called under preempt disabled or must be called by
+ * a thread which is pinned to local cpu.
+ */
+static void drain_local_stock(struct work_struct *dummy)
+{
+       struct memcg_stock_pcp *stock = &__get_cpu_var(memcg_stock);
+       drain_stock(stock);
+}
+
+/*
+ * Cache charges(val) which is from res_counter, to local per_cpu area.
+ * This will be consumed by consumt_stock() function, later.
+ */
+static void refill_stock(struct mem_cgroup *mem, int val)
+{
+       struct memcg_stock_pcp *stock = &get_cpu_var(memcg_stock);
+
+       if (stock->cached != mem) { /* reset if necessary */
+               drain_stock(stock);
+               stock->cached = mem;
+       }
+       stock->charge += val;
+       put_cpu_var(memcg_stock);
+}
+
+/*
+ * Tries to drain stocked charges in other cpus. This function is asynchronous
+ * and just put a work per cpu for draining localy on each cpu. Caller can
+ * expects some charges will be back to res_counter later but cannot wait for
+ * it.
+ */
+static void drain_all_stock_async(void)
+{
+       int cpu;
+       /* This function is for scheduling "drain" in asynchronous way.
+        * The result of "drain" is not directly handled by callers. Then,
+        * if someone is calling drain, we don't have to call drain more.
+        * Anyway, WORK_STRUCT_PENDING check in queue_work_on() will catch if
+        * there is a race. We just do loose check here.
+        */
+       if (atomic_read(&memcg_drain_count))
+               return;
+       /* Notify other cpus that system-wide "drain" is running */
+       atomic_inc(&memcg_drain_count);
+       get_online_cpus();
+       for_each_online_cpu(cpu) {
+               struct memcg_stock_pcp *stock = &per_cpu(memcg_stock, cpu);
+               schedule_work_on(cpu, &stock->work);
+       }
+       put_online_cpus();
+       atomic_dec(&memcg_drain_count);
+       /* We don't wait for flush_work */
+}
+
+/* This is a synchronous drain interface. */
+static void drain_all_stock_sync(void)
+{
+       /* called when force_empty is called */
+       atomic_inc(&memcg_drain_count);
+       schedule_on_each_cpu(drain_local_stock);
+       atomic_dec(&memcg_drain_count);
+}
+
+static int __cpuinit memcg_stock_cpu_callback(struct notifier_block *nb,
+                                       unsigned long action,
+                                       void *hcpu)
+{
+       int cpu = (unsigned long)hcpu;
+       struct memcg_stock_pcp *stock;
+
+       if (action != CPU_DEAD)
+               return NOTIFY_OK;
+       stock = &per_cpu(memcg_stock, cpu);
+       drain_stock(stock);
+       return NOTIFY_OK;
+}
+
 /*
  * Unlike exported interface, "oom" parameter is added. if oom==true,
  * oom-killer can be invoked.
@@ -1269,6 +1407,7 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
        struct mem_cgroup *mem, *mem_over_limit;
        int nr_retries = MEM_CGROUP_RECLAIM_RETRIES;
        struct res_counter *fail_res;
+       int csize = CHARGE_SIZE;
 
        if (unlikely(test_thread_flag(TIF_MEMDIE))) {
                /* Don't account this! */
@@ -1293,23 +1432,25 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
                return 0;
 
        VM_BUG_ON(css_is_removed(&mem->css));
+       if (mem_cgroup_is_root(mem))
+               goto done;
 
        while (1) {
                int ret = 0;
                unsigned long flags = 0;
 
-               if (mem_cgroup_is_root(mem))
-                       goto done;
-               ret = res_counter_charge(&mem->res, PAGE_SIZE, &fail_res);
+               if (consume_stock(mem))
+                       goto charged;
+
+               ret = res_counter_charge(&mem->res, csize, &fail_res);
                if (likely(!ret)) {
                        if (!do_swap_account)
                                break;
-                       ret = res_counter_charge(&mem->memsw, PAGE_SIZE,
-                                                       &fail_res);
+                       ret = res_counter_charge(&mem->memsw, csize, &fail_res);
                        if (likely(!ret))
                                break;
                        /* mem+swap counter fails */
-                       res_counter_uncharge(&mem->res, PAGE_SIZE);
+                       res_counter_uncharge(&mem->res, csize);
                        flags |= MEM_CGROUP_RECLAIM_NOSWAP;
                        mem_over_limit = mem_cgroup_from_res_counter(fail_res,
                                                                        memsw);
@@ -1318,6 +1459,11 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
                        mem_over_limit = mem_cgroup_from_res_counter(fail_res,
                                                                        res);
 
+               /* reduce request size and retry */
+               if (csize > PAGE_SIZE) {
+                       csize = PAGE_SIZE;
+                       continue;
+               }
                if (!(gfp_mask & __GFP_WAIT))
                        goto nomem;
 
@@ -1339,14 +1485,15 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
 
                if (!nr_retries--) {
                        if (oom) {
-                               mutex_lock(&memcg_tasklist);
                                mem_cgroup_out_of_memory(mem_over_limit, gfp_mask);
-                               mutex_unlock(&memcg_tasklist);
                                record_last_oom(mem_over_limit);
                        }
                        goto nomem;
                }
        }
+       if (csize > PAGE_SIZE)
+               refill_stock(mem, csize - PAGE_SIZE);
+charged:
        /*
         * Insert ancestor (and ancestor's ancestors), to softlimit RB-tree.
         * if they exceeds softlimit.
@@ -1360,6 +1507,21 @@ nomem:
        return -ENOMEM;
 }
 
+/*
+ * Somemtimes we have to undo a charge we got by try_charge().
+ * This function is for that and do uncharge, put css's refcnt.
+ * gotten by try_charge().
+ */
+static void mem_cgroup_cancel_charge(struct mem_cgroup *mem)
+{
+       if (!mem_cgroup_is_root(mem)) {
+               res_counter_uncharge(&mem->res, PAGE_SIZE);
+               if (do_swap_account)
+                       res_counter_uncharge(&mem->memsw, PAGE_SIZE);
+       }
+       css_put(&mem->css);
+}
+
 /*
  * A helper function to get mem_cgroup from ID. must be called under
  * rcu_read_lock(). The caller must check css_is_removed() or some if
@@ -1379,25 +1541,22 @@ static struct mem_cgroup *mem_cgroup_lookup(unsigned short id)
        return container_of(css, struct mem_cgroup, css);
 }
 
-static struct mem_cgroup *try_get_mem_cgroup_from_swapcache(struct page *page)
+struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
 {
-       struct mem_cgroup *mem;
+       struct mem_cgroup *mem = NULL;
        struct page_cgroup *pc;
        unsigned short id;
        swp_entry_t ent;
 
        VM_BUG_ON(!PageLocked(page));
 
-       if (!PageSwapCache(page))
-               return NULL;
-
        pc = lookup_page_cgroup(page);
        lock_page_cgroup(pc);
        if (PageCgroupUsed(pc)) {
                mem = pc->mem_cgroup;
                if (mem && !css_tryget(&mem->css))
                        mem = NULL;
-       } else {
+       } else if (PageSwapCache(page)) {
                ent.val = page_private(page);
                id = lookup_swap_cgroup(ent);
                rcu_read_lock();
@@ -1426,12 +1585,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *mem,
        lock_page_cgroup(pc);
        if (unlikely(PageCgroupUsed(pc))) {
                unlock_page_cgroup(pc);
-               if (!mem_cgroup_is_root(mem)) {
-                       res_counter_uncharge(&mem->res, PAGE_SIZE);
-                       if (do_swap_account)
-                               res_counter_uncharge(&mem->memsw, PAGE_SIZE);
-               }
-               css_put(&mem->css);
+               mem_cgroup_cancel_charge(mem);
                return;
        }
 
@@ -1464,27 +1618,22 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *mem,
 }
 
 /**
- * mem_cgroup_move_account - move account of the page
+ * __mem_cgroup_move_account - move account of the page
  * @pc:        page_cgroup of the page.
  * @from: mem_cgroup which the page is moved from.
  * @to:        mem_cgroup which the page is moved to. @from != @to.
  *
  * The caller must confirm following.
  * - page is not on LRU (isolate_page() is useful.)
- *
- * returns 0 at success,
- * returns -EBUSY when lock is busy or "pc" is unstable.
+ * - the pc is locked, used, and ->mem_cgroup points to @from.
  *
  * This function does "uncharge" from old cgroup but doesn't do "charge" to
  * new cgroup. It should be done by a caller.
  */
 
-static int mem_cgroup_move_account(struct page_cgroup *pc,
+static void __mem_cgroup_move_account(struct page_cgroup *pc,
        struct mem_cgroup *from, struct mem_cgroup *to)
 {
-       struct mem_cgroup_per_zone *from_mz, *to_mz;
-       int nid, zid;
-       int ret = -EBUSY;
        struct page *page;
        int cpu;
        struct mem_cgroup_stat *stat;
@@ -1492,38 +1641,27 @@ static int mem_cgroup_move_account(struct page_cgroup *pc,
 
        VM_BUG_ON(from == to);
        VM_BUG_ON(PageLRU(pc->page));
-
-       nid = page_cgroup_nid(pc);
-       zid = page_cgroup_zid(pc);
-       from_mz =  mem_cgroup_zoneinfo(from, nid, zid);
-       to_mz =  mem_cgroup_zoneinfo(to, nid, zid);
-
-       if (!trylock_page_cgroup(pc))
-               return ret;
-
-       if (!PageCgroupUsed(pc))
-               goto out;
-
-       if (pc->mem_cgroup != from)
-               goto out;
+       VM_BUG_ON(!PageCgroupLocked(pc));
+       VM_BUG_ON(!PageCgroupUsed(pc));
+       VM_BUG_ON(pc->mem_cgroup != from);
 
        if (!mem_cgroup_is_root(from))
                res_counter_uncharge(&from->res, PAGE_SIZE);
        mem_cgroup_charge_statistics(from, pc, false);
 
        page = pc->page;
-       if (page_is_file_cache(page) && page_mapped(page)) {
+       if (page_mapped(page) && !PageAnon(page)) {
                cpu = smp_processor_id();
                /* Update mapped_file data for mem_cgroup "from" */
                stat = &from->stat;
                cpustat = &stat->cpustat[cpu];
-               __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE,
+               __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_FILE_MAPPED,
                                                -1);
 
                /* Update mapped_file data for mem_cgroup "to" */
                stat = &to->stat;
                cpustat = &stat->cpustat[cpu];
-               __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_MAPPED_FILE,
+               __mem_cgroup_stat_add_safe(cpustat, MEM_CGROUP_STAT_FILE_MAPPED,
                                                1);
        }
 
@@ -1534,15 +1672,28 @@ static int mem_cgroup_move_account(struct page_cgroup *pc,
        css_get(&to->css);
        pc->mem_cgroup = to;
        mem_cgroup_charge_statistics(to, pc, true);
-       ret = 0;
-out:
-       unlock_page_cgroup(pc);
        /*
         * We charges against "to" which may not have any tasks. Then, "to"
         * can be under rmdir(). But in current implementation, caller of
         * this function is just force_empty() and it's garanteed that
         * "to" is never removed. So, we don't check rmdir status here.
         */
+}
+
+/*
+ * check whether the @pc is valid for moving account and call
+ * __mem_cgroup_move_account()
+ */
+static int mem_cgroup_move_account(struct page_cgroup *pc,
+                               struct mem_cgroup *from, struct mem_cgroup *to)
+{
+       int ret = -EINVAL;
+       lock_page_cgroup(pc);
+       if (PageCgroupUsed(pc) && pc->mem_cgroup == from) {
+               __mem_cgroup_move_account(pc, from, to);
+               ret = 0;
+       }
+       unlock_page_cgroup(pc);
        return ret;
 }
 
@@ -1564,45 +1715,27 @@ static int mem_cgroup_move_parent(struct page_cgroup *pc,
        if (!pcg)
                return -EINVAL;
 
+       ret = -EBUSY;
+       if (!get_page_unless_zero(page))
+               goto out;
+       if (isolate_lru_page(page))
+               goto put;
 
        parent = mem_cgroup_from_cont(pcg);
-
-
        ret = __mem_cgroup_try_charge(NULL, gfp_mask, &parent, false, page);
        if (ret || !parent)
-               return ret;
-
-       if (!get_page_unless_zero(page)) {
-               ret = -EBUSY;
-               goto uncharge;
-       }
-
-       ret = isolate_lru_page(page);
-
-       if (ret)
-               goto cancel;
+               goto put_back;
 
        ret = mem_cgroup_move_account(pc, child, parent);
-
+       if (!ret)
+               css_put(&parent->css);  /* drop extra refcnt by try_charge() */
+       else
+               mem_cgroup_cancel_charge(parent);       /* does css_put */
+put_back:
        putback_lru_page(page);
-       if (!ret) {
-               put_page(page);
-               /* drop extra refcnt by try_charge() */
-               css_put(&parent->css);
-               return 0;
-       }
-
-cancel:
+put:
        put_page(page);
-uncharge:
-       /* drop extra refcnt by try_charge() */
-       css_put(&parent->css);
-       /* uncharge if move fails */
-       if (!mem_cgroup_is_root(parent)) {
-               res_counter_uncharge(&parent->res, PAGE_SIZE);
-               if (do_swap_account)
-                       res_counter_uncharge(&parent->memsw, PAGE_SIZE);
-       }
+out:
        return ret;
 }
 
@@ -1737,12 +1870,13 @@ int mem_cgroup_try_charge_swapin(struct mm_struct *mm,
                goto charge_cur_mm;
        /*
         * A racing thread's fault, or swapoff, may have already updated
-        * the pte, and even removed page from swap cache: return success
-        * to go on to do_swap_page()'s pte_same() test, which should fail.
+        * the pte, and even removed page from swap cache: in those cases
+        * do_swap_page()'s pte_same() test will fail; but there's also a
+        * KSM case which does need to charge the page.
         */
        if (!PageSwapCache(page))
-               return 0;
-       mem = try_get_mem_cgroup_from_swapcache(page);
+               goto charge_cur_mm;
+       mem = try_get_mem_cgroup_from_page(page);
        if (!mem)
                goto charge_cur_mm;
        *ptr = mem;
@@ -1818,14 +1952,53 @@ void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *mem)
                return;
        if (!mem)
                return;
-       if (!mem_cgroup_is_root(mem)) {
-               res_counter_uncharge(&mem->res, PAGE_SIZE);
-               if (do_swap_account)
-                       res_counter_uncharge(&mem->memsw, PAGE_SIZE);
-       }
-       css_put(&mem->css);
+       mem_cgroup_cancel_charge(mem);
 }
 
+static void
+__do_uncharge(struct mem_cgroup *mem, const enum charge_type ctype)
+{
+       struct memcg_batch_info *batch = NULL;
+       bool uncharge_memsw = true;
+       /* If swapout, usage of swap doesn't decrease */
+       if (!do_swap_account || ctype == MEM_CGROUP_CHARGE_TYPE_SWAPOUT)
+               uncharge_memsw = false;
+       /*
+        * do_batch > 0 when unmapping pages or inode invalidate/truncate.
+        * In those cases, all pages freed continously can be expected to be in
+        * the same cgroup and we have chance to coalesce uncharges.
+        * But we do uncharge one by one if this is killed by OOM(TIF_MEMDIE)
+        * because we want to do uncharge as soon as possible.
+        */
+       if (!current->memcg_batch.do_batch || test_thread_flag(TIF_MEMDIE))
+               goto direct_uncharge;
+
+       batch = &current->memcg_batch;
+       /*
+        * In usual, we do css_get() when we remember memcg pointer.
+        * But in this case, we keep res->usage until end of a series of
+        * uncharges. Then, it's ok to ignore memcg's refcnt.
+        */
+       if (!batch->memcg)
+               batch->memcg = mem;
+       /*
+        * In typical case, batch->memcg == mem. This means we can
+        * merge a series of uncharges to an uncharge of res_counter.
+        * If not, we uncharge res_counter ony by one.
+        */
+       if (batch->memcg != mem)
+               goto direct_uncharge;
+       /* remember freed charge and uncharge it later */
+       batch->bytes += PAGE_SIZE;
+       if (uncharge_memsw)
+               batch->memsw_bytes += PAGE_SIZE;
+       return;
+direct_uncharge:
+       res_counter_uncharge(&mem->res, PAGE_SIZE);
+       if (uncharge_memsw)
+               res_counter_uncharge(&mem->memsw, PAGE_SIZE);
+       return;
+}
 
 /*
  * uncharge if !page_mapped(page)
@@ -1874,12 +2047,8 @@ __mem_cgroup_uncharge_common(struct page *page, enum charge_type ctype)
                break;
        }
 
-       if (!mem_cgroup_is_root(mem)) {
-               res_counter_uncharge(&mem->res, PAGE_SIZE);
-               if (do_swap_account &&
-                               (ctype != MEM_CGROUP_CHARGE_TYPE_SWAPOUT))
-                       res_counter_uncharge(&mem->memsw, PAGE_SIZE);
-       }
+       if (!mem_cgroup_is_root(mem))
+               __do_uncharge(mem, ctype);
        if (ctype == MEM_CGROUP_CHARGE_TYPE_SWAPOUT)
                mem_cgroup_swap_statistics(mem, true);
        mem_cgroup_charge_statistics(mem, pc, false);
@@ -1925,6 +2094,50 @@ void mem_cgroup_uncharge_cache_page(struct page *page)
        __mem_cgroup_uncharge_common(page, MEM_CGROUP_CHARGE_TYPE_CACHE);
 }
 
+/*
+ * Batch_start/batch_end is called in unmap_page_range/invlidate/trucate.
+ * In that cases, pages are freed continuously and we can expect pages
+ * are in the same memcg. All these calls itself limits the number of
+ * pages freed at once, then uncharge_start/end() is called properly.
+ * This may be called prural(2) times in a context,
+ */
+
+void mem_cgroup_uncharge_start(void)
+{
+       current->memcg_batch.do_batch++;
+       /* We can do nest. */
+       if (current->memcg_batch.do_batch == 1) {
+               current->memcg_batch.memcg = NULL;
+               current->memcg_batch.bytes = 0;
+               current->memcg_batch.memsw_bytes = 0;
+       }
+}
+
+void mem_cgroup_uncharge_end(void)
+{
+       struct memcg_batch_info *batch = &current->memcg_batch;
+
+       if (!batch->do_batch)
+               return;
+
+       batch->do_batch--;
+       if (batch->do_batch) /* If stacked, do nothing. */
+               return;
+
+       if (!batch->memcg)
+               return;
+       /*
+        * This "batch->memcg" is valid without any css_get/put etc...
+        * bacause we hide charges behind us.
+        */
+       if (batch->bytes)
+               res_counter_uncharge(&batch->memcg->res, batch->bytes);
+       if (batch->memsw_bytes)
+               res_counter_uncharge(&batch->memcg->memsw, batch->memsw_bytes);
+       /* forget this pointer (for sanity check) */
+       batch->memcg = NULL;
+}
+
 #ifdef CONFIG_SWAP
 /*
  * called after __delete_from_swap_cache() and drop "page" account.
@@ -2100,7 +2313,6 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
                                unsigned long long val)
 {
        int retry_count;
-       int progress;
        u64 memswlimit;
        int ret = 0;
        int children = mem_cgroup_count_children(memcg);
@@ -2144,8 +2356,7 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
                if (!ret)
                        break;
 
-               progress = mem_cgroup_hierarchical_reclaim(memcg, NULL,
-                                               GFP_KERNEL,
+               mem_cgroup_hierarchical_reclaim(memcg, NULL, GFP_KERNEL,
                                                MEM_CGROUP_RECLAIM_SHRINK);
                curusage = res_counter_read_u64(&memcg->res, RES_USAGE);
                /* Usage is reduced ? */
@@ -2384,6 +2595,7 @@ move_account:
                        goto out;
                /* This is for making all *used* pages to be on LRU. */
                lru_add_drain_all();
+               drain_all_stock_sync();
                ret = 0;
                for_each_node_state(node, N_HIGH_MEMORY) {
                        for (zid = 0; !ret && zid < MAX_NR_ZONES; zid++) {
@@ -2541,6 +2753,7 @@ static u64 mem_cgroup_read(struct cgroup *cont, struct cftype *cft)
                        val += idx_val;
                        mem_cgroup_get_recursive_idx_stat(mem,
                                MEM_CGROUP_STAT_SWAPOUT, &idx_val);
+                       val += idx_val;
                        val <<= PAGE_SHIFT;
                } else
                        val = res_counter_read_u64(&mem->memsw, name);
@@ -2660,7 +2873,7 @@ static int mem_cgroup_reset(struct cgroup *cont, unsigned int event)
 enum {
        MCS_CACHE,
        MCS_RSS,
-       MCS_MAPPED_FILE,
+       MCS_FILE_MAPPED,
        MCS_PGPGIN,
        MCS_PGPGOUT,
        MCS_SWAP,
@@ -2704,8 +2917,8 @@ static int mem_cgroup_get_local_stat(struct mem_cgroup *mem, void *data)
        s->stat[MCS_CACHE] += val * PAGE_SIZE;
        val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_RSS);
        s->stat[MCS_RSS] += val * PAGE_SIZE;
-       val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_MAPPED_FILE);
-       s->stat[MCS_MAPPED_FILE] += val * PAGE_SIZE;
+       val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_FILE_MAPPED);
+       s->stat[MCS_FILE_MAPPED] += val * PAGE_SIZE;
        val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGIN_COUNT);
        s->stat[MCS_PGPGIN] += val;
        val = mem_cgroup_read_stat(&mem->stat, MEM_CGROUP_STAT_PGPGOUT_COUNT);
@@ -3097,11 +3310,18 @@ mem_cgroup_create(struct cgroup_subsys *ss, struct cgroup *cont)
 
        /* root ? */
        if (cont->parent == NULL) {
+               int cpu;
                enable_swap_cgroup();
                parent = NULL;
                root_mem_cgroup = mem;
                if (mem_cgroup_soft_limit_tree_init())
                        goto free_out;
+               for_each_possible_cpu(cpu) {
+                       struct memcg_stock_pcp *stock =
+                                               &per_cpu(memcg_stock, cpu);
+                       INIT_WORK(&stock->work, drain_local_stock);
+               }
+               hotcpu_notifier(memcg_stock_cpu_callback, 0);
 
        } else {
                parent = mem_cgroup_from_cont(cont->parent);
@@ -3170,12 +3390,10 @@ static void mem_cgroup_move_task(struct cgroup_subsys *ss,
                                struct task_struct *p,
                                bool threadgroup)
 {
-       mutex_lock(&memcg_tasklist);
        /*
         * FIXME: It's better to move charges of this process from old
         * memcg to new memcg. But it's just on TODO-List now.
         */
-       mutex_unlock(&memcg_tasklist);
 }
 
 struct cgroup_subsys mem_cgroup_subsys = {
index 1ac49fef95ab43b716979a360375c66be706160c..17299fd4577c6fc903b5fcb15e52f7fba4f2149d 100644 (file)
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/page-flags.h>
+#include <linux/kernel-page-flags.h>
 #include <linux/sched.h>
 #include <linux/ksm.h>
 #include <linux/rmap.h>
 #include <linux/pagemap.h>
 #include <linux/swap.h>
 #include <linux/backing-dev.h>
+#include <linux/migrate.h>
+#include <linux/page-isolation.h>
+#include <linux/suspend.h>
 #include "internal.h"
 
 int sysctl_memory_failure_early_kill __read_mostly = 0;
@@ -48,6 +52,129 @@ int sysctl_memory_failure_recovery __read_mostly = 1;
 
 atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
 
+#if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
+
+u32 hwpoison_filter_enable = 0;
+u32 hwpoison_filter_dev_major = ~0U;
+u32 hwpoison_filter_dev_minor = ~0U;
+u64 hwpoison_filter_flags_mask;
+u64 hwpoison_filter_flags_value;
+EXPORT_SYMBOL_GPL(hwpoison_filter_enable);
+EXPORT_SYMBOL_GPL(hwpoison_filter_dev_major);
+EXPORT_SYMBOL_GPL(hwpoison_filter_dev_minor);
+EXPORT_SYMBOL_GPL(hwpoison_filter_flags_mask);
+EXPORT_SYMBOL_GPL(hwpoison_filter_flags_value);
+
+static int hwpoison_filter_dev(struct page *p)
+{
+       struct address_space *mapping;
+       dev_t dev;
+
+       if (hwpoison_filter_dev_major == ~0U &&
+           hwpoison_filter_dev_minor == ~0U)
+               return 0;
+
+       /*
+        * page_mapping() does not accept slab page
+        */
+       if (PageSlab(p))
+               return -EINVAL;
+
+       mapping = page_mapping(p);
+       if (mapping == NULL || mapping->host == NULL)
+               return -EINVAL;
+
+       dev = mapping->host->i_sb->s_dev;
+       if (hwpoison_filter_dev_major != ~0U &&
+           hwpoison_filter_dev_major != MAJOR(dev))
+               return -EINVAL;
+       if (hwpoison_filter_dev_minor != ~0U &&
+           hwpoison_filter_dev_minor != MINOR(dev))
+               return -EINVAL;
+
+       return 0;
+}
+
+static int hwpoison_filter_flags(struct page *p)
+{
+       if (!hwpoison_filter_flags_mask)
+               return 0;
+
+       if ((stable_page_flags(p) & hwpoison_filter_flags_mask) ==
+                                   hwpoison_filter_flags_value)
+               return 0;
+       else
+               return -EINVAL;
+}
+
+/*
+ * This allows stress tests to limit test scope to a collection of tasks
+ * by putting them under some memcg. This prevents killing unrelated/important
+ * processes such as /sbin/init. Note that the target task may share clean
+ * pages with init (eg. libc text), which is harmless. If the target task
+ * share _dirty_ pages with another task B, the test scheme must make sure B
+ * is also included in the memcg. At last, due to race conditions this filter
+ * can only guarantee that the page either belongs to the memcg tasks, or is
+ * a freed page.
+ */
+#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
+u64 hwpoison_filter_memcg;
+EXPORT_SYMBOL_GPL(hwpoison_filter_memcg);
+static int hwpoison_filter_task(struct page *p)
+{
+       struct mem_cgroup *mem;
+       struct cgroup_subsys_state *css;
+       unsigned long ino;
+
+       if (!hwpoison_filter_memcg)
+               return 0;
+
+       mem = try_get_mem_cgroup_from_page(p);
+       if (!mem)
+               return -EINVAL;
+
+       css = mem_cgroup_css(mem);
+       /* root_mem_cgroup has NULL dentries */
+       if (!css->cgroup->dentry)
+               return -EINVAL;
+
+       ino = css->cgroup->dentry->d_inode->i_ino;
+       css_put(css);
+
+       if (ino != hwpoison_filter_memcg)
+               return -EINVAL;
+
+       return 0;
+}
+#else
+static int hwpoison_filter_task(struct page *p) { return 0; }
+#endif
+
+int hwpoison_filter(struct page *p)
+{
+       if (!hwpoison_filter_enable)
+               return 0;
+
+       if (hwpoison_filter_dev(p))
+               return -EINVAL;
+
+       if (hwpoison_filter_flags(p))
+               return -EINVAL;
+
+       if (hwpoison_filter_task(p))
+               return -EINVAL;
+
+       return 0;
+}
+#else
+int hwpoison_filter(struct page *p)
+{
+       return 0;
+}
+#endif
+
+EXPORT_SYMBOL_GPL(hwpoison_filter);
+
 /*
  * Send all the processes who have the page mapped an ``action optional''
  * signal.
@@ -82,6 +209,36 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
        return ret;
 }
 
+/*
+ * When a unknown page type is encountered drain as many buffers as possible
+ * in the hope to turn the page into a LRU or free page, which we can handle.
+ */
+void shake_page(struct page *p, int access)
+{
+       if (!PageSlab(p)) {
+               lru_add_drain_all();
+               if (PageLRU(p))
+                       return;
+               drain_all_pages();
+               if (PageLRU(p) || is_free_buddy_page(p))
+                       return;
+       }
+
+       /*
+        * Only all shrink_slab here (which would also
+        * shrink other caches) if access is not potentially fatal.
+        */
+       if (access) {
+               int nr;
+               do {
+                       nr = shrink_slab(1000, GFP_KERNEL, 1000);
+                       if (page_count(p) == 0)
+                               break;
+               } while (nr > 10);
+       }
+}
+EXPORT_SYMBOL_GPL(shake_page);
+
 /*
  * Kill all processes that have a poisoned page mapped and then isolate
  * the page.
@@ -177,7 +334,6 @@ static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno,
                         * In case something went wrong with munmapping
                         * make sure the process doesn't catch the
                         * signal and then access the memory. Just kill it.
-                        * the signal handlers
                         */
                        if (fail || tk->addr_valid == 0) {
                                printk(KERN_ERR
@@ -314,33 +470,49 @@ static void collect_procs(struct page *page, struct list_head *tokill)
  */
 
 enum outcome {
-       FAILED,         /* Error handling failed */
+       IGNORED,        /* Error: cannot be handled */
+       FAILED,         /* Error: handling failed */
        DELAYED,        /* Will be handled later */
-       IGNORED,        /* Error safely ignored */
        RECOVERED,      /* Successfully recovered */
 };
 
 static const char *action_name[] = {
+       [IGNORED] = "Ignored",
        [FAILED] = "Failed",
        [DELAYED] = "Delayed",
-       [IGNORED] = "Ignored",
        [RECOVERED] = "Recovered",
 };
 
 /*
- * Error hit kernel page.
- * Do nothing, try to be lucky and not touch this instead. For a few cases we
- * could be more sophisticated.
+ * XXX: It is possible that a page is isolated from LRU cache,
+ * and then kept in swap cache or failed to remove from page cache.
+ * The page count will stop it from being freed by unpoison.
+ * Stress tests should be aware of this memory leak problem.
  */
-static int me_kernel(struct page *p, unsigned long pfn)
+static int delete_from_lru_cache(struct page *p)
 {
-       return DELAYED;
+       if (!isolate_lru_page(p)) {
+               /*
+                * Clear sensible page flags, so that the buddy system won't
+                * complain when the page is unpoison-and-freed.
+                */
+               ClearPageActive(p);
+               ClearPageUnevictable(p);
+               /*
+                * drop the page count elevated by isolate_lru_page()
+                */
+               page_cache_release(p);
+               return 0;
+       }
+       return -EIO;
 }
 
 /*
- * Already poisoned page.
+ * Error hit kernel page.
+ * Do nothing, try to be lucky and not touch this instead. For a few cases we
+ * could be more sophisticated.
  */
-static int me_ignore(struct page *p, unsigned long pfn)
+static int me_kernel(struct page *p, unsigned long pfn)
 {
        return IGNORED;
 }
@@ -354,14 +526,6 @@ static int me_unknown(struct page *p, unsigned long pfn)
        return FAILED;
 }
 
-/*
- * Free memory
- */
-static int me_free(struct page *p, unsigned long pfn)
-{
-       return DELAYED;
-}
-
 /*
  * Clean (or cleaned) page cache page.
  */
@@ -371,6 +535,8 @@ static int me_pagecache_clean(struct page *p, unsigned long pfn)
        int ret = FAILED;
        struct address_space *mapping;
 
+       delete_from_lru_cache(p);
+
        /*
         * For anonymous pages we're done the only reference left
         * should be the one m_f() holds.
@@ -500,14 +666,20 @@ static int me_swapcache_dirty(struct page *p, unsigned long pfn)
        /* Trigger EIO in shmem: */
        ClearPageUptodate(p);
 
-       return DELAYED;
+       if (!delete_from_lru_cache(p))
+               return DELAYED;
+       else
+               return FAILED;
 }
 
 static int me_swapcache_clean(struct page *p, unsigned long pfn)
 {
        delete_from_swap_cache(p);
 
-       return RECOVERED;
+       if (!delete_from_lru_cache(p))
+               return RECOVERED;
+       else
+               return FAILED;
 }
 
 /*
@@ -550,7 +722,6 @@ static int me_huge_page(struct page *p, unsigned long pfn)
 #define tail           (1UL << PG_tail)
 #define compound       (1UL << PG_compound)
 #define slab           (1UL << PG_slab)
-#define buddy          (1UL << PG_buddy)
 #define reserved       (1UL << PG_reserved)
 
 static struct page_state {
@@ -559,8 +730,11 @@ static struct page_state {
        char *msg;
        int (*action)(struct page *p, unsigned long pfn);
 } error_states[] = {
-       { reserved,     reserved,       "reserved kernel",      me_ignore },
-       { buddy,        buddy,          "free kernel",  me_free },
+       { reserved,     reserved,       "reserved kernel",      me_kernel },
+       /*
+        * free pages are specially detected outside this table:
+        * PG_buddy pages only make a small fraction of all free pages.
+        */
 
        /*
         * Could in theory check if slab page is free or if we can drop
@@ -582,14 +756,11 @@ static struct page_state {
        { unevict|dirty, unevict|dirty, "unevictable LRU", me_pagecache_dirty},
        { unevict,      unevict,        "unevictable LRU", me_pagecache_clean},
 
-#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
        { mlock|dirty,  mlock|dirty,    "mlocked LRU",  me_pagecache_dirty },
        { mlock,        mlock,          "mlocked LRU",  me_pagecache_clean },
-#endif
 
        { lru|dirty,    lru|dirty,      "LRU",          me_pagecache_dirty },
        { lru|dirty,    lru,            "clean LRU",    me_pagecache_clean },
-       { swapbacked,   swapbacked,     "anonymous",    me_pagecache_clean },
 
        /*
         * Catchall entry: must be at end.
@@ -597,20 +768,31 @@ static struct page_state {
        { 0,            0,              "unknown page state",   me_unknown },
 };
 
+#undef dirty
+#undef sc
+#undef unevict
+#undef mlock
+#undef writeback
+#undef lru
+#undef swapbacked
+#undef head
+#undef tail
+#undef compound
+#undef slab
+#undef reserved
+
 static void action_result(unsigned long pfn, char *msg, int result)
 {
-       struct page *page = NULL;
-       if (pfn_valid(pfn))
-               page = pfn_to_page(pfn);
+       struct page *page = pfn_to_page(pfn);
 
        printk(KERN_ERR "MCE %#lx: %s%s page recovery: %s\n",
                pfn,
-               page && PageDirty(page) ? "dirty " : "",
+               PageDirty(page) ? "dirty " : "",
                msg, action_name[result]);
 }
 
 static int page_action(struct page_state *ps, struct page *p,
-                       unsigned long pfn, int ref)
+                       unsigned long pfn)
 {
        int result;
        int count;
@@ -618,18 +800,22 @@ static int page_action(struct page_state *ps, struct page *p,
        result = ps->action(p, pfn);
        action_result(pfn, ps->msg, result);
 
-       count = page_count(p) - 1 - ref;
-       if (count != 0)
+       count = page_count(p) - 1;
+       if (ps->action == me_swapcache_dirty && result == DELAYED)
+               count--;
+       if (count != 0) {
                printk(KERN_ERR
                       "MCE %#lx: %s page still referenced by %d users\n",
                       pfn, ps->msg, count);
+               result = FAILED;
+       }
 
        /* Could do more checks here if page looks ok */
        /*
         * Could adjust zone counters here to correct for the missing page.
         */
 
-       return result == RECOVERED ? 0 : -EBUSY;
+       return (result == RECOVERED || result == DELAYED) ? 0 : -EBUSY;
 }
 
 #define N_UNMAP_TRIES 5
@@ -638,7 +824,7 @@ static int page_action(struct page_state *ps, struct page *p,
  * Do all that is necessary to remove user space mappings. Unmap
  * the pages and send SIGBUS to the processes if the data was dirty.
  */
-static void hwpoison_user_mappings(struct page *p, unsigned long pfn,
+static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
                                  int trapno)
 {
        enum ttu_flags ttu = TTU_UNMAP | TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS;
@@ -648,15 +834,18 @@ static void hwpoison_user_mappings(struct page *p, unsigned long pfn,
        int i;
        int kill = 1;
 
-       if (PageReserved(p) || PageCompound(p) || PageSlab(p) || PageKsm(p))
-               return;
+       if (PageReserved(p) || PageSlab(p))
+               return SWAP_SUCCESS;
 
        /*
         * This check implies we don't kill processes if their pages
         * are in the swap cache early. Those are always late kills.
         */
        if (!page_mapped(p))
-               return;
+               return SWAP_SUCCESS;
+
+       if (PageCompound(p) || PageKsm(p))
+               return SWAP_FAIL;
 
        if (PageSwapCache(p)) {
                printk(KERN_ERR
@@ -667,6 +856,8 @@ static void hwpoison_user_mappings(struct page *p, unsigned long pfn,
        /*
         * Propagate the dirty bit from PTEs to struct page first, because we
         * need this to decide if we should kill or just drop the page.
+        * XXX: the dirty test could be racy: set_page_dirty() may not always
+        * be called inside page lock (it's recommended but not enforced).
         */
        mapping = page_mapping(p);
        if (!PageDirty(p) && mapping && mapping_cap_writeback_dirty(mapping)) {
@@ -718,11 +909,12 @@ static void hwpoison_user_mappings(struct page *p, unsigned long pfn,
         */
        kill_procs_ao(&tokill, !!PageDirty(p), trapno,
                      ret != SWAP_SUCCESS, pfn);
+
+       return ret;
 }
 
-int __memory_failure(unsigned long pfn, int trapno, int ref)
+int __memory_failure(unsigned long pfn, int trapno, int flags)
 {
-       unsigned long lru_flag;
        struct page_state *ps;
        struct page *p;
        int res;
@@ -731,13 +923,15 @@ int __memory_failure(unsigned long pfn, int trapno, int ref)
                panic("Memory failure from trap %d on page %lx", trapno, pfn);
 
        if (!pfn_valid(pfn)) {
-               action_result(pfn, "memory outside kernel control", IGNORED);
-               return -EIO;
+               printk(KERN_ERR
+                      "MCE %#lx: memory outside kernel control\n",
+                      pfn);
+               return -ENXIO;
        }
 
        p = pfn_to_page(pfn);
        if (TestSetPageHWPoison(p)) {
-               action_result(pfn, "already hardware poisoned", IGNORED);
+               printk(KERN_ERR "MCE %#lx: already hardware poisoned\n", pfn);
                return 0;
        }
 
@@ -754,9 +948,15 @@ int __memory_failure(unsigned long pfn, int trapno, int ref)
         * In fact it's dangerous to directly bump up page count from 0,
         * that may make page_freeze_refs()/page_unfreeze_refs() mismatch.
         */
-       if (!get_page_unless_zero(compound_head(p))) {
-               action_result(pfn, "free or high order kernel", IGNORED);
-               return PageBuddy(compound_head(p)) ? 0 : -EBUSY;
+       if (!(flags & MF_COUNT_INCREASED) &&
+               !get_page_unless_zero(compound_head(p))) {
+               if (is_free_buddy_page(p)) {
+                       action_result(pfn, "free buddy", DELAYED);
+                       return 0;
+               } else {
+                       action_result(pfn, "high order kernel", IGNORED);
+                       return -EBUSY;
+               }
        }
 
        /*
@@ -768,14 +968,19 @@ int __memory_failure(unsigned long pfn, int trapno, int ref)
         * walked by the page reclaim code, however that's not a big loss.
         */
        if (!PageLRU(p))
-               lru_add_drain_all();
-       lru_flag = p->flags & lru;
-       if (isolate_lru_page(p)) {
+               shake_page(p, 0);
+       if (!PageLRU(p)) {
+               /*
+                * shake_page could have turned it free.
+                */
+               if (is_free_buddy_page(p)) {
+                       action_result(pfn, "free buddy, 2nd try", DELAYED);
+                       return 0;
+               }
                action_result(pfn, "non LRU", IGNORED);
                put_page(p);
                return -EBUSY;
        }
-       page_cache_release(p);
 
        /*
         * Lock the page and wait for writeback to finish.
@@ -783,26 +988,48 @@ int __memory_failure(unsigned long pfn, int trapno, int ref)
         * and in many cases impossible, so we just avoid it here.
         */
        lock_page_nosync(p);
+
+       /*
+        * unpoison always clear PG_hwpoison inside page lock
+        */
+       if (!PageHWPoison(p)) {
+               printk(KERN_ERR "MCE %#lx: just unpoisoned\n", pfn);
+               res = 0;
+               goto out;
+       }
+       if (hwpoison_filter(p)) {
+               if (TestClearPageHWPoison(p))
+                       atomic_long_dec(&mce_bad_pages);
+               unlock_page(p);
+               put_page(p);
+               return 0;
+       }
+
        wait_on_page_writeback(p);
 
        /*
         * Now take care of user space mappings.
+        * Abort on fail: __remove_from_page_cache() assumes unmapped page.
         */
-       hwpoison_user_mappings(p, pfn, trapno);
+       if (hwpoison_user_mappings(p, pfn, trapno) != SWAP_SUCCESS) {
+               printk(KERN_ERR "MCE %#lx: cannot unmap page, give up\n", pfn);
+               res = -EBUSY;
+               goto out;
+       }
 
        /*
         * Torn down by someone else?
         */
-       if ((lru_flag & lru) && !PageSwapCache(p) && p->mapping == NULL) {
+       if (PageLRU(p) && !PageSwapCache(p) && p->mapping == NULL) {
                action_result(pfn, "already truncated LRU", IGNORED);
-               res = 0;
+               res = -EBUSY;
                goto out;
        }
 
        res = -EBUSY;
        for (ps = error_states;; ps++) {
-               if (((p->flags | lru_flag)& ps->mask) == ps->res) {
-                       res = page_action(ps, p, pfn, ref);
+               if ((p->flags & ps->mask) == ps->res) {
+                       res = page_action(ps, p, pfn);
                        break;
                }
        }
@@ -833,3 +1060,235 @@ void memory_failure(unsigned long pfn, int trapno)
 {
        __memory_failure(pfn, trapno, 0);
 }
+
+/**
+ * unpoison_memory - Unpoison a previously poisoned page
+ * @pfn: Page number of the to be unpoisoned page
+ *
+ * Software-unpoison a page that has been poisoned by
+ * memory_failure() earlier.
+ *
+ * This is only done on the software-level, so it only works
+ * for linux injected failures, not real hardware failures
+ *
+ * Returns 0 for success, otherwise -errno.
+ */
+int unpoison_memory(unsigned long pfn)
+{
+       struct page *page;
+       struct page *p;
+       int freeit = 0;
+
+       if (!pfn_valid(pfn))
+               return -ENXIO;
+
+       p = pfn_to_page(pfn);
+       page = compound_head(p);
+
+       if (!PageHWPoison(p)) {
+               pr_debug("MCE: Page was already unpoisoned %#lx\n", pfn);
+               return 0;
+       }
+
+       if (!get_page_unless_zero(page)) {
+               if (TestClearPageHWPoison(p))
+                       atomic_long_dec(&mce_bad_pages);
+               pr_debug("MCE: Software-unpoisoned free page %#lx\n", pfn);
+               return 0;
+       }
+
+       lock_page_nosync(page);
+       /*
+        * This test is racy because PG_hwpoison is set outside of page lock.
+        * That's acceptable because that won't trigger kernel panic. Instead,
+        * the PG_hwpoison page will be caught and isolated on the entrance to
+        * the free buddy page pool.
+        */
+       if (TestClearPageHWPoison(p)) {
+               pr_debug("MCE: Software-unpoisoned page %#lx\n", pfn);
+               atomic_long_dec(&mce_bad_pages);
+               freeit = 1;
+       }
+       unlock_page(page);
+
+       put_page(page);
+       if (freeit)
+               put_page(page);
+
+       return 0;
+}
+EXPORT_SYMBOL(unpoison_memory);
+
+static struct page *new_page(struct page *p, unsigned long private, int **x)
+{
+       int nid = page_to_nid(p);
+       return alloc_pages_exact_node(nid, GFP_HIGHUSER_MOVABLE, 0);
+}
+
+/*
+ * Safely get reference count of an arbitrary page.
+ * Returns 0 for a free page, -EIO for a zero refcount page
+ * that is not free, and 1 for any other page type.
+ * For 1 the page is returned with increased page count, otherwise not.
+ */
+static int get_any_page(struct page *p, unsigned long pfn, int flags)
+{
+       int ret;
+
+       if (flags & MF_COUNT_INCREASED)
+               return 1;
+
+       /*
+        * The lock_system_sleep prevents a race with memory hotplug,
+        * because the isolation assumes there's only a single user.
+        * This is a big hammer, a better would be nicer.
+        */
+       lock_system_sleep();
+
+       /*
+        * Isolate the page, so that it doesn't get reallocated if it
+        * was free.
+        */
+       set_migratetype_isolate(p);
+       if (!get_page_unless_zero(compound_head(p))) {
+               if (is_free_buddy_page(p)) {
+                       pr_debug("get_any_page: %#lx free buddy page\n", pfn);
+                       /* Set hwpoison bit while page is still isolated */
+                       SetPageHWPoison(p);
+                       ret = 0;
+               } else {
+                       pr_debug("get_any_page: %#lx: unknown zero refcount page type %lx\n",
+                               pfn, p->flags);
+                       ret = -EIO;
+               }
+       } else {
+               /* Not a free page */
+               ret = 1;
+       }
+       unset_migratetype_isolate(p);
+       unlock_system_sleep();
+       return ret;
+}
+
+/**
+ * soft_offline_page - Soft offline a page.
+ * @page: page to offline
+ * @flags: flags. Same as memory_failure().
+ *
+ * Returns 0 on success, otherwise negated errno.
+ *
+ * Soft offline a page, by migration or invalidation,
+ * without killing anything. This is for the case when
+ * a page is not corrupted yet (so it's still valid to access),
+ * but has had a number of corrected errors and is better taken
+ * out.
+ *
+ * The actual policy on when to do that is maintained by
+ * user space.
+ *
+ * This should never impact any application or cause data loss,
+ * however it might take some time.
+ *
+ * This is not a 100% solution for all memory, but tries to be
+ * ``good enough'' for the majority of memory.
+ */
+int soft_offline_page(struct page *page, int flags)
+{
+       int ret;
+       unsigned long pfn = page_to_pfn(page);
+
+       ret = get_any_page(page, pfn, flags);
+       if (ret < 0)
+               return ret;
+       if (ret == 0)
+               goto done;
+
+       /*
+        * Page cache page we can handle?
+        */
+       if (!PageLRU(page)) {
+               /*
+                * Try to free it.
+                */
+               put_page(page);
+               shake_page(page, 1);
+
+               /*
+                * Did it turn free?
+                */
+               ret = get_any_page(page, pfn, 0);
+               if (ret < 0)
+                       return ret;
+               if (ret == 0)
+                       goto done;
+       }
+       if (!PageLRU(page)) {
+               pr_debug("soft_offline: %#lx: unknown non LRU page type %lx\n",
+                               pfn, page->flags);
+               return -EIO;
+       }
+
+       lock_page(page);
+       wait_on_page_writeback(page);
+
+       /*
+        * Synchronized using the page lock with memory_failure()
+        */
+       if (PageHWPoison(page)) {
+               unlock_page(page);
+               put_page(page);
+               pr_debug("soft offline: %#lx page already poisoned\n", pfn);
+               return -EBUSY;
+       }
+
+       /*
+        * Try to invalidate first. This should work for
+        * non dirty unmapped page cache pages.
+        */
+       ret = invalidate_inode_page(page);
+       unlock_page(page);
+
+       /*
+        * Drop count because page migration doesn't like raised
+        * counts. The page could get re-allocated, but if it becomes
+        * LRU the isolation will just fail.
+        * RED-PEN would be better to keep it isolated here, but we
+        * would need to fix isolation locking first.
+        */
+       put_page(page);
+       if (ret == 1) {
+               ret = 0;
+               pr_debug("soft_offline: %#lx: invalidated\n", pfn);
+               goto done;
+       }
+
+       /*
+        * Simple invalidation didn't work.
+        * Try to migrate to a new page instead. migrate.c
+        * handles a large number of cases for us.
+        */
+       ret = isolate_lru_page(page);
+       if (!ret) {
+               LIST_HEAD(pagelist);
+
+               list_add(&page->lru, &pagelist);
+               ret = migrate_pages(&pagelist, new_page, MPOL_MF_MOVE_ALL, 0);
+               if (ret) {
+                       pr_debug("soft offline: %#lx: migration failed %d, type %lx\n",
+                               pfn, ret, page->flags);
+                       if (ret > 0)
+                               ret = -EIO;
+               }
+       } else {
+               pr_debug("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
+                               pfn, ret, page_count(page), page->flags);
+       }
+       if (ret)
+               return ret;
+
+done:
+       atomic_long_add(1, &mce_bad_pages);
+       SetPageHWPoison(page);
+       /* keep elevated page count for bad page */
+       return ret;
+}
index 6ab19dd4a1990f3f463c1db3eee4f19ce4f5a3de..09e4b1be7b67ddda8336eee4bd76bbbf304a82b3 100644 (file)
@@ -572,7 +572,7 @@ out:
  * covered by this vma.
  */
 
-static inline void
+static inline unsigned long
 copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
                pte_t *dst_pte, pte_t *src_pte, struct vm_area_struct *vma,
                unsigned long addr, int *rss)
@@ -586,7 +586,9 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
                if (!pte_file(pte)) {
                        swp_entry_t entry = pte_to_swp_entry(pte);
 
-                       swap_duplicate(entry);
+                       if (swap_duplicate(entry) < 0)
+                               return entry.val;
+
                        /* make sure dst_mm is on swapoff's mmlist. */
                        if (unlikely(list_empty(&dst_mm->mmlist))) {
                                spin_lock(&mmlist_lock);
@@ -635,6 +637,7 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 
 out_set_pte:
        set_pte_at(dst_mm, addr, dst_pte, pte);
+       return 0;
 }
 
 static int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
@@ -646,6 +649,7 @@ static int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
        spinlock_t *src_ptl, *dst_ptl;
        int progress = 0;
        int rss[2];
+       swp_entry_t entry = (swp_entry_t){0};
 
 again:
        rss[1] = rss[0] = 0;
@@ -674,7 +678,10 @@ again:
                        progress++;
                        continue;
                }
-               copy_one_pte(dst_mm, src_mm, dst_pte, src_pte, vma, addr, rss);
+               entry.val = copy_one_pte(dst_mm, src_mm, dst_pte, src_pte,
+                                                       vma, addr, rss);
+               if (entry.val)
+                       break;
                progress += 8;
        } while (dst_pte++, src_pte++, addr += PAGE_SIZE, addr != end);
 
@@ -684,6 +691,12 @@ again:
        add_mm_rss(dst_mm, rss[0], rss[1]);
        pte_unmap_unlock(orig_dst_pte, dst_ptl);
        cond_resched();
+
+       if (entry.val) {
+               if (add_swap_count_continuation(entry, GFP_KERNEL) < 0)
+                       return -ENOMEM;
+               progress = 0;
+       }
        if (addr != end)
                goto again;
        return 0;
@@ -943,6 +956,7 @@ static unsigned long unmap_page_range(struct mmu_gather *tlb,
                details = NULL;
 
        BUG_ON(addr >= end);
+       mem_cgroup_uncharge_start();
        tlb_start_vma(tlb, vma);
        pgd = pgd_offset(vma->vm_mm, addr);
        do {
@@ -955,6 +969,7 @@ static unsigned long unmap_page_range(struct mmu_gather *tlb,
                                                zap_work, details);
        } while (pgd++, addr = next, (addr != end && *zap_work > 0));
        tlb_end_vma(tlb, vma);
+       mem_cgroup_uncharge_end();
 
        return addr;
 }
@@ -2514,7 +2529,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
                        ret = VM_FAULT_HWPOISON;
                } else {
                        print_bad_pte(vma, address, orig_pte, NULL);
-                       ret = VM_FAULT_OOM;
+                       ret = VM_FAULT_SIGBUS;
                }
                goto out;
        }
@@ -2540,6 +2555,10 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
                ret = VM_FAULT_MAJOR;
                count_vm_event(PGMAJFAULT);
        } else if (PageHWPoison(page)) {
+               /*
+                * hwpoisoned dirty swapcache pages are kept for killing
+                * owner processes (which may be unknown at hwpoison time)
+                */
                ret = VM_FAULT_HWPOISON;
                delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
                goto out_release;
@@ -2548,6 +2567,12 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
        lock_page(page);
        delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
 
+       page = ksm_might_need_to_copy(page, vma, address);
+       if (!page) {
+               ret = VM_FAULT_OOM;
+               goto out;
+       }
+
        if (mem_cgroup_try_charge_swapin(mm, page, GFP_KERNEL, &ptr)) {
                ret = VM_FAULT_OOM;
                goto out_page;
@@ -2910,7 +2935,7 @@ static int do_nonlinear_fault(struct mm_struct *mm, struct vm_area_struct *vma,
                 * Page table corrupted: show pte and kill process.
                 */
                print_bad_pte(vma, address, orig_pte, NULL);
-               return VM_FAULT_OOM;
+               return VM_FAULT_SIGBUS;
        }
 
        pgoff = pte_to_pgoff(orig_pte);
index 2047465cd27cf5b1829979057459857184a42b2e..030ce8a5bb0e758e7ea04cc0c851955275356426 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/page-isolation.h>
 #include <linux/pfn.h>
 #include <linux/suspend.h>
+#include <linux/mm_inline.h>
 
 #include <asm/tlbflush.h>
 
@@ -71,7 +72,9 @@ static void get_page_bootmem(unsigned long info,  struct page *page, int type)
        atomic_inc(&page->_count);
 }
 
-void put_page_bootmem(struct page *page)
+/* reference to __meminit __free_pages_bootmem is valid
+ * so use __ref to tell modpost not to generate a warning */
+void __ref put_page_bootmem(struct page *page)
 {
        int type;
 
@@ -672,6 +675,9 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
                if (!ret) { /* Success */
                        list_add_tail(&page->lru, &source);
                        move_pages--;
+                       inc_zone_page_state(page, NR_ISOLATED_ANON +
+                                           page_is_file_cache(page));
+
                } else {
                        /* Becasue we don't have big zone->lock. we should
                           check this again here. */
@@ -694,7 +700,7 @@ do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
        if (list_empty(&source))
                goto out;
        /* this function returns # of failed pages */
-       ret = migrate_pages(&source, hotremove_migrate_alloc, 0);
+       ret = migrate_pages(&source, hotremove_migrate_alloc, 0, 1);
 
 out:
        return ret;
@@ -747,7 +753,7 @@ check_pages_isolated(unsigned long start_pfn, unsigned long end_pfn)
        return offlined;
 }
 
-int offline_pages(unsigned long start_pfn,
+static int offline_pages(unsigned long start_pfn,
                  unsigned long end_pfn, unsigned long timeout)
 {
        unsigned long pfn, nr_pages, expire;
@@ -849,6 +855,10 @@ repeat:
 
        setup_per_zone_wmarks();
        calculate_zone_inactive_ratio(zone);
+       if (!node_present_pages(node)) {
+               node_clear_state(node, N_HIGH_MEMORY);
+               kswapd_stop(node);
+       }
 
        vm_total_pages = nr_free_pagecache_pages();
        writeback_set_ratelimit();
index 4545d59442431e33d7d64e2f98c8f9d1a403780b..290fb5bf0440f7a5e0f05f4adeffd3decb785d00 100644 (file)
 #include <linux/seq_file.h>
 #include <linux/proc_fs.h>
 #include <linux/migrate.h>
+#include <linux/ksm.h>
 #include <linux/rmap.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/ctype.h>
+#include <linux/mm_inline.h>
 
 #include <asm/tlbflush.h>
 #include <asm/uaccess.h>
@@ -412,17 +414,11 @@ static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
                if (!page)
                        continue;
                /*
-                * The check for PageReserved here is important to avoid
-                * handling zero pages and other pages that may have been
-                * marked special by the system.
-                *
-                * If the PageReserved would not be checked here then f.e.
-                * the location of the zero page could have an influence
-                * on MPOL_MF_STRICT, zero pages would be counted for
-                * the per node stats, and there would be useless attempts
-                * to put zero pages on the migration list.
+                * vm_normal_page() filters out zero pages, but there might
+                * still be PageReserved pages to skip, perhaps in a VDSO.
+                * And we cannot move PageKsm pages sensibly or safely yet.
                 */
-               if (PageReserved(page))
+               if (PageReserved(page) || PageKsm(page))
                        continue;
                nid = page_to_nid(page);
                if (node_isset(nid, *nodes) == !!(flags & MPOL_MF_INVERT))
@@ -809,6 +805,8 @@ static void migrate_page_add(struct page *page, struct list_head *pagelist,
        if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(page) == 1) {
                if (!isolate_lru_page(page)) {
                        list_add_tail(&page->lru, pagelist);
+                       inc_zone_page_state(page, NR_ISOLATED_ANON +
+                                           page_is_file_cache(page));
                }
        }
 }
@@ -836,7 +834,7 @@ static int migrate_to_node(struct mm_struct *mm, int source, int dest,
                        flags | MPOL_MF_DISCONTIG_OK, &pagelist);
 
        if (!list_empty(&pagelist))
-               err = migrate_pages(&pagelist, new_node_page, dest);
+               err = migrate_pages(&pagelist, new_node_page, dest, 0);
 
        return err;
 }
@@ -1053,7 +1051,7 @@ static long do_mbind(unsigned long start, unsigned long len,
 
                if (!list_empty(&pagelist))
                        nr_failed = migrate_pages(&pagelist, new_vma_page,
-                                               (unsigned long)vma);
+                                               (unsigned long)vma, 0);
 
                if (!err && nr_failed && (flags & MPOL_MF_STRICT))
                        err = -EIO;
@@ -1565,6 +1563,53 @@ struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr,
        }
        return zl;
 }
+
+/*
+ * init_nodemask_of_mempolicy
+ *
+ * If the current task's mempolicy is "default" [NULL], return 'false'
+ * to indicate default policy.  Otherwise, extract the policy nodemask
+ * for 'bind' or 'interleave' policy into the argument nodemask, or
+ * initialize the argument nodemask to contain the single node for
+ * 'preferred' or 'local' policy and return 'true' to indicate presence
+ * of non-default mempolicy.
+ *
+ * We don't bother with reference counting the mempolicy [mpol_get/put]
+ * because the current task is examining it's own mempolicy and a task's
+ * mempolicy is only ever changed by the task itself.
+ *
+ * N.B., it is the caller's responsibility to free a returned nodemask.
+ */
+bool init_nodemask_of_mempolicy(nodemask_t *mask)
+{
+       struct mempolicy *mempolicy;
+       int nid;
+
+       if (!(mask && current->mempolicy))
+               return false;
+
+       mempolicy = current->mempolicy;
+       switch (mempolicy->mode) {
+       case MPOL_PREFERRED:
+               if (mempolicy->flags & MPOL_F_LOCAL)
+                       nid = numa_node_id();
+               else
+                       nid = mempolicy->v.preferred_node;
+               init_nodemask_of_node(mask, nid);
+               break;
+
+       case MPOL_BIND:
+               /* Fall through */
+       case MPOL_INTERLEAVE:
+               *mask =  mempolicy->v.nodes;
+               break;
+
+       default:
+               BUG();
+       }
+
+       return true;
+}
 #endif
 
 /* Allocate a page in interleaved policy.
index 0bc640fd68fa64c38915d40fe20db545c1784799..efddbf0926b283ae5ef292e076ff9900842c4dd5 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/mm_inline.h>
 #include <linux/nsproxy.h>
 #include <linux/pagevec.h>
+#include <linux/ksm.h>
 #include <linux/rmap.h>
 #include <linux/topology.h>
 #include <linux/cpu.h>
@@ -78,8 +79,8 @@ int putback_lru_pages(struct list_head *l)
 /*
  * Restore a potential migration pte to a working pte entry
  */
-static void remove_migration_pte(struct vm_area_struct *vma,
-               struct page *old, struct page *new)
+static int remove_migration_pte(struct page *new, struct vm_area_struct *vma,
+                                unsigned long addr, void *old)
 {
        struct mm_struct *mm = vma->vm_mm;
        swp_entry_t entry;
@@ -88,40 +89,37 @@ static void remove_migration_pte(struct vm_area_struct *vma,
        pmd_t *pmd;
        pte_t *ptep, pte;
        spinlock_t *ptl;
-       unsigned long addr = page_address_in_vma(new, vma);
-
-       if (addr == -EFAULT)
-               return;
 
        pgd = pgd_offset(mm, addr);
        if (!pgd_present(*pgd))
-                return;
+               goto out;
 
        pud = pud_offset(pgd, addr);
        if (!pud_present(*pud))
-                return;
+               goto out;
 
        pmd = pmd_offset(pud, addr);
        if (!pmd_present(*pmd))
-               return;
+               goto out;
 
        ptep = pte_offset_map(pmd, addr);
 
        if (!is_swap_pte(*ptep)) {
                pte_unmap(ptep);
-               return;
+               goto out;
        }
 
        ptl = pte_lockptr(mm, pmd);
        spin_lock(ptl);
        pte = *ptep;
        if (!is_swap_pte(pte))
-               goto out;
+               goto unlock;
 
        entry = pte_to_swp_entry(pte);
 
-       if (!is_migration_entry(entry) || migration_entry_to_page(entry) != old)
-               goto out;
+       if (!is_migration_entry(entry) ||
+           migration_entry_to_page(entry) != old)
+               goto unlock;
 
        get_page(new);
        pte = pte_mkold(mk_pte(new, vma->vm_page_prot));
@@ -137,58 +135,10 @@ static void remove_migration_pte(struct vm_area_struct *vma,
 
        /* No need to invalidate - it was non-present before */
        update_mmu_cache(vma, addr, pte);
-
-out:
+unlock:
        pte_unmap_unlock(ptep, ptl);
-}
-
-/*
- * Note that remove_file_migration_ptes will only work on regular mappings,
- * Nonlinear mappings do not use migration entries.
- */
-static void remove_file_migration_ptes(struct page *old, struct page *new)
-{
-       struct vm_area_struct *vma;
-       struct address_space *mapping = new->mapping;
-       struct prio_tree_iter iter;
-       pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
-
-       if (!mapping)
-               return;
-
-       spin_lock(&mapping->i_mmap_lock);
-
-       vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff)
-               remove_migration_pte(vma, old, new);
-
-       spin_unlock(&mapping->i_mmap_lock);
-}
-
-/*
- * Must hold mmap_sem lock on at least one of the vmas containing
- * the page so that the anon_vma cannot vanish.
- */
-static void remove_anon_migration_ptes(struct page *old, struct page *new)
-{
-       struct anon_vma *anon_vma;
-       struct vm_area_struct *vma;
-       unsigned long mapping;
-
-       mapping = (unsigned long)new->mapping;
-
-       if (!mapping || (mapping & PAGE_MAPPING_ANON) == 0)
-               return;
-
-       /*
-        * We hold the mmap_sem lock. So no need to call page_lock_anon_vma.
-        */
-       anon_vma = (struct anon_vma *) (mapping - PAGE_MAPPING_ANON);
-       spin_lock(&anon_vma->lock);
-
-       list_for_each_entry(vma, &anon_vma->head, anon_vma_node)
-               remove_migration_pte(vma, old, new);
-
-       spin_unlock(&anon_vma->lock);
+out:
+       return SWAP_AGAIN;
 }
 
 /*
@@ -197,10 +147,7 @@ static void remove_anon_migration_ptes(struct page *old, struct page *new)
  */
 static void remove_migration_ptes(struct page *old, struct page *new)
 {
-       if (PageAnon(new))
-               remove_anon_migration_ptes(old, new);
-       else
-               remove_file_migration_ptes(old, new);
+       rmap_walk(new, remove_migration_pte, old);
 }
 
 /*
@@ -341,8 +288,8 @@ static void migrate_page_copy(struct page *newpage, struct page *page)
        if (TestClearPageActive(page)) {
                VM_BUG_ON(PageUnevictable(page));
                SetPageActive(newpage);
-       } else
-               unevictable_migrate_page(newpage, page);
+       } else if (TestClearPageUnevictable(page))
+               SetPageUnevictable(newpage);
        if (PageChecked(page))
                SetPageChecked(newpage);
        if (PageMappedToDisk(page))
@@ -361,6 +308,7 @@ static void migrate_page_copy(struct page *newpage, struct page *page)
        }
 
        mlock_migrate_page(newpage, page);
+       ksm_migrate_page(newpage, page);
 
        ClearPageSwapCache(page);
        ClearPagePrivate(page);
@@ -580,9 +528,9 @@ static int move_to_new_page(struct page *newpage, struct page *page)
        else
                rc = fallback_migrate_page(mapping, newpage, page);
 
-       if (!rc) {
+       if (!rc)
                remove_migration_ptes(page, newpage);
-       else
+       else
                newpage->mapping = NULL;
 
        unlock_page(newpage);
@@ -595,7 +543,7 @@ static int move_to_new_page(struct page *newpage, struct page *page)
  * to the newly allocated page in newpage.
  */
 static int unmap_and_move(new_page_t get_new_page, unsigned long private,
-                       struct page *page, int force)
+                       struct page *page, int force, int offlining)
 {
        int rc = 0;
        int *result = NULL;
@@ -621,6 +569,20 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
                lock_page(page);
        }
 
+       /*
+        * Only memory hotplug's offline_pages() caller has locked out KSM,
+        * and can safely migrate a KSM page.  The other cases have skipped
+        * PageKsm along with PageReserved - but it is only now when we have
+        * the page lock that we can be certain it will not go KSM beneath us
+        * (KSM will not upgrade a page from PageAnon to PageKsm when it sees
+        * its pagecount raised, but only here do we take the page lock which
+        * serializes that).
+        */
+       if (PageKsm(page) && !offlining) {
+               rc = -EBUSY;
+               goto unlock;
+       }
+
        /* charge against new page */
        charge = mem_cgroup_prepare_migration(page, &mem);
        if (charge == -ENOMEM) {
@@ -737,7 +699,7 @@ move_newpage:
  * Return: Number of pages not migrated or error code.
  */
 int migrate_pages(struct list_head *from,
-               new_page_t get_new_page, unsigned long private)
+               new_page_t get_new_page, unsigned long private, int offlining)
 {
        int retry = 1;
        int nr_failed = 0;
@@ -746,13 +708,6 @@ int migrate_pages(struct list_head *from,
        struct page *page2;
        int swapwrite = current->flags & PF_SWAPWRITE;
        int rc;
-       unsigned long flags;
-
-       local_irq_save(flags);
-       list_for_each_entry(page, from, lru)
-               __inc_zone_page_state(page, NR_ISOLATED_ANON +
-                               page_is_file_cache(page));
-       local_irq_restore(flags);
 
        if (!swapwrite)
                current->flags |= PF_SWAPWRITE;
@@ -764,7 +719,7 @@ int migrate_pages(struct list_head *from,
                        cond_resched();
 
                        rc = unmap_and_move(get_new_page, private,
-                                               page, pass > 2);
+                                               page, pass > 2, offlining);
 
                        switch(rc) {
                        case -ENOMEM:
@@ -860,7 +815,8 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
                if (!page)
                        goto set_status;
 
-               if (PageReserved(page))         /* Check for zero page */
+               /* Use PageReserved to check for zero page */
+               if (PageReserved(page) || PageKsm(page))
                        goto put_and_set;
 
                pp->page = page;
@@ -878,8 +834,11 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
                        goto put_and_set;
 
                err = isolate_lru_page(page);
-               if (!err)
+               if (!err) {
                        list_add_tail(&page->lru, &pagelist);
+                       inc_zone_page_state(page, NR_ISOLATED_ANON +
+                                           page_is_file_cache(page));
+               }
 put_and_set:
                /*
                 * Either remove the duplicate refcount from
@@ -894,7 +853,7 @@ set_status:
        err = 0;
        if (!list_empty(&pagelist))
                err = migrate_pages(&pagelist, new_page_node,
-                               (unsigned long)pm);
+                               (unsigned long)pm, 0);
 
        up_read(&mm->mmap_sem);
        return err;
@@ -1015,7 +974,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,
 
                err = -ENOENT;
                /* Use PageReserved to check for zero page */
-               if (!page || PageReserved(page))
+               if (!page || PageReserved(page) || PageKsm(page))
                        goto set_status;
 
                err = page_to_nid(page);
index 8cb508f84ea49ca03a7005574208ab3ec4a4e567..7a3436ef39eba1ace01efca158e93599aaea5bb7 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/syscalls.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
+#include <linux/hugetlb.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -72,6 +73,42 @@ static long do_mincore(unsigned long addr, unsigned char *vec, unsigned long pag
        if (!vma || addr < vma->vm_start)
                return -ENOMEM;
 
+#ifdef CONFIG_HUGETLB_PAGE
+       if (is_vm_hugetlb_page(vma)) {
+               struct hstate *h;
+               unsigned long nr_huge;
+               unsigned char present;
+
+               i = 0;
+               nr = min(pages, (vma->vm_end - addr) >> PAGE_SHIFT);
+               h = hstate_vma(vma);
+               nr_huge = ((addr + pages * PAGE_SIZE - 1) >> huge_page_shift(h))
+                         - (addr >> huge_page_shift(h)) + 1;
+               nr_huge = min(nr_huge,
+                             (vma->vm_end - addr) >> huge_page_shift(h));
+               while (1) {
+                       /* hugepage always in RAM for now,
+                        * but generally it needs to be check */
+                       ptep = huge_pte_offset(current->mm,
+                                              addr & huge_page_mask(h));
+                       present = !!(ptep &&
+                                    !huge_pte_none(huge_ptep_get(ptep)));
+                       while (1) {
+                               vec[i++] = present;
+                               addr += PAGE_SIZE;
+                               /* reach buffer limit */
+                               if (i == nr)
+                                       return nr;
+                               /* check hugepage border */
+                               if (!((addr & ~huge_page_mask(h))
+                                     >> PAGE_SHIFT))
+                                       break;
+                       }
+               }
+               return nr;
+       }
+#endif
+
        /*
         * Calculate how many pages there are left in the last level of the
         * PTE array for our address.
index bd6f0e466f6c4f1c51b4bbbe1e605140bb3e6493..2b8335a8940052874a18a9b3657c830c61e13284 100644 (file)
@@ -88,25 +88,22 @@ void mlock_vma_page(struct page *page)
        }
 }
 
-/*
- * called from munlock()/munmap() path with page supposedly on the LRU.
+/**
+ * munlock_vma_page - munlock a vma page
+ * @page - page to be unlocked
  *
- * Note:  unlike mlock_vma_page(), we can't just clear the PageMlocked
- * [in try_to_munlock()] and then attempt to isolate the page.  We must
- * isolate the page to keep others from messing with its unevictable
- * and mlocked state while trying to munlock.  However, we pre-clear the
- * mlocked state anyway as we might lose the isolation race and we might
- * not get another chance to clear PageMlocked.  If we successfully
- * isolate the page and try_to_munlock() detects other VM_LOCKED vmas
- * mapping the page, it will restore the PageMlocked state, unless the page
- * is mapped in a non-linear vma.  So, we go ahead and SetPageMlocked(),
- * perhaps redundantly.
- * If we lose the isolation race, and the page is mapped by other VM_LOCKED
- * vmas, we'll detect this in vmscan--via try_to_munlock() or try_to_unmap()
- * either of which will restore the PageMlocked state by calling
- * mlock_vma_page() above, if it can grab the vma's mmap sem.
+ * called from munlock()/munmap() path with page supposedly on the LRU.
+ * When we munlock a page, because the vma where we found the page is being
+ * munlock()ed or munmap()ed, we want to check whether other vmas hold the
+ * page locked so that we can leave it on the unevictable lru list and not
+ * bother vmscan with it.  However, to walk the page's rmap list in
+ * try_to_munlock() we must isolate the page from the LRU.  If some other
+ * task has removed the page from the LRU, we won't be able to do that.
+ * So we clear the PageMlocked as we might not get another chance.  If we
+ * can't isolate the page, we leave it for putback_lru_page() and vmscan
+ * [page_referenced()/try_to_unmap()] to deal with.
  */
-static void munlock_vma_page(struct page *page)
+void munlock_vma_page(struct page *page)
 {
        BUG_ON(!PageLocked(page));
 
@@ -117,18 +114,18 @@ static void munlock_vma_page(struct page *page)
                        /*
                         * did try_to_unlock() succeed or punt?
                         */
-                       if (ret == SWAP_SUCCESS || ret == SWAP_AGAIN)
+                       if (ret != SWAP_MLOCK)
                                count_vm_event(UNEVICTABLE_PGMUNLOCKED);
 
                        putback_lru_page(page);
                } else {
                        /*
-                        * We lost the race.  let try_to_unmap() deal
-                        * with it.  At least we get the page state and
-                        * mlock stats right.  However, page is still on
-                        * the noreclaim list.  We'll fix that up when
-                        * the page is eventually freed or we scan the
-                        * noreclaim list.
+                        * Some other task has removed the page from the LRU.
+                        * putback_lru_page() will take care of removing the
+                        * page from the unevictable list, if necessary.
+                        * vmscan [page_referenced()] will move the page back
+                        * to the unevictable list if some other vma has it
+                        * mlocked.
                         */
                        if (PageUnevictable(page))
                                count_vm_event(UNEVICTABLE_PGSTRANDED);
index ed70a68e882af069988cfcbe5c54a9a0af88d9fa..ee2298936fe677870ad4979b98bd8d6ada7c3439 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1043,6 +1043,46 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
 }
 EXPORT_SYMBOL(do_mmap_pgoff);
 
+SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
+               unsigned long, prot, unsigned long, flags,
+               unsigned long, fd, unsigned long, pgoff)
+{
+       struct file *file = NULL;
+       unsigned long retval = -EBADF;
+
+       if (!(flags & MAP_ANONYMOUS)) {
+               if (unlikely(flags & MAP_HUGETLB))
+                       return -EINVAL;
+               file = fget(fd);
+               if (!file)
+                       goto out;
+       } else if (flags & MAP_HUGETLB) {
+               struct user_struct *user = NULL;
+               /*
+                * VM_NORESERVE is used because the reservations will be
+                * taken when vm_ops->mmap() is called
+                * A dummy user value is used because we are not locking
+                * memory so no accounting is necessary
+                */
+               len = ALIGN(len, huge_page_size(&default_hstate));
+               file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
+                                               &user, HUGETLB_ANONHUGE_INODE);
+               if (IS_ERR(file))
+                       return PTR_ERR(file);
+       }
+
+       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+
+       down_write(&current->mm->mmap_sem);
+       retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+       up_write(&current->mm->mmap_sem);
+
+       if (file)
+               fput(file);
+out:
+       return retval;
+}
+
 /*
  * Some shared mappigns will want the pages marked read-only
  * to track write events. If so, we'll downgrade vm_page_prot
@@ -1198,8 +1238,20 @@ munmap_back:
                        goto free_vma;
        }
 
-       if (vma_wants_writenotify(vma))
+       if (vma_wants_writenotify(vma)) {
+               pgprot_t pprot = vma->vm_page_prot;
+
+               /* Can vma->vm_page_prot have changed??
+                *
+                * Answer: Yes, drivers may have changed it in their
+                *         f_op->mmap method.
+                *
+                * Ensures that vmas marked as uncached stay that way.
+                */
                vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
+               if (pgprot_val(pprot) == pgprot_val(pgprot_noncached(pprot)))
+                       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+       }
 
        vma_link(mm, vma, prev, rb_link, rb_parent);
        file = vma->vm_file;
@@ -1811,10 +1863,10 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
 }
 
 /*
- * Split a vma into two pieces at address 'addr', a new vma is allocated
- * either for the first part or the tail.
+ * __split_vma() bypasses sysctl_max_map_count checking.  We use this on the
+ * munmap path where it doesn't make sense to fail.
  */
-int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
+static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
              unsigned long addr, int new_below)
 {
        struct mempolicy *pol;
@@ -1824,9 +1876,6 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
                                        ~(huge_page_mask(hstate_vma(vma)))))
                return -EINVAL;
 
-       if (mm->map_count >= sysctl_max_map_count)
-               return -ENOMEM;
-
        new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (!new)
                return -ENOMEM;
@@ -1866,6 +1915,19 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
        return 0;
 }
 
+/*
+ * Split a vma into two pieces at address 'addr', a new vma is allocated
+ * either for the first part or the tail.
+ */
+int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
+             unsigned long addr, int new_below)
+{
+       if (mm->map_count >= sysctl_max_map_count)
+               return -ENOMEM;
+
+       return __split_vma(mm, vma, addr, new_below);
+}
+
 /* Munmap is split into 2 main parts -- this part which finds
  * what needs doing, and the areas themselves, which do the
  * work.  This now handles partial unmappings.
@@ -1901,7 +1963,17 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
         * places tmp vma above, and higher split_vma places tmp vma below.
         */
        if (start > vma->vm_start) {
-               int error = split_vma(mm, vma, start, 0);
+               int error;
+
+               /*
+                * Make sure that map_count on return from munmap() will
+                * not exceed its limit; but let map_count go just above
+                * its limit temporarily, to help free resources as expected.
+                */
+               if (end < vma->vm_end && mm->map_count >= sysctl_max_map_count)
+                       return -ENOMEM;
+
+               error = __split_vma(mm, vma, start, 0);
                if (error)
                        return error;
                prev = vma;
@@ -1910,7 +1982,7 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
        /* Does it split the last one? */
        last = find_vma(mm, end);
        if (last && end > last->vm_start) {
-               int error = split_vma(mm, last, end, 1);
+               int error = __split_vma(mm, last, end, 1);
                if (error)
                        return error;
        }
index 9876fa0c3ad30e75d842f965ac4417e66be6f07a..6f9248f89bdefbd6470bb0c4b68fb50b134866d2 100644 (file)
@@ -1143,9 +1143,6 @@ static int do_mmap_private(struct vm_area_struct *vma,
                if (ret < rlen)
                        memset(base + ret, 0, rlen - ret);
 
-       } else {
-               /* if it's an anonymous mapping, then just clear it */
-               memset(base, 0, rlen);
        }
 
        return 0;
@@ -1343,6 +1340,11 @@ unsigned long do_mmap_pgoff(struct file *file,
                goto error_just_free;
        add_nommu_region(region);
 
+       /* clear anonymous mappings that don't ask for uninitialized data */
+       if (!vma->vm_file && !(flags & MAP_UNINITIALIZED))
+               memset((void *)region->vm_start, 0,
+                      region->vm_end - region->vm_start);
+
        /* okay... we have a mapping; now we have to register it */
        result = vma->vm_start;
 
@@ -1396,6 +1398,31 @@ error_getting_region:
 }
 EXPORT_SYMBOL(do_mmap_pgoff);
 
+SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
+               unsigned long, prot, unsigned long, flags,
+               unsigned long, fd, unsigned long, pgoff)
+{
+       struct file *file = NULL;
+       unsigned long retval = -EBADF;
+
+       if (!(flags & MAP_ANONYMOUS)) {
+               file = fget(fd);
+               if (!file)
+                       goto out;
+       }
+
+       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
+
+       down_write(&current->mm->mmap_sem);
+       retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+       up_write(&current->mm->mmap_sem);
+
+       if (file)
+               fput(file);
+out:
+       return retval;
+}
+
 /*
  * split a vma into two pieces at address 'addr', a new vma is allocated either
  * for the first part or the tail.
index ea2147dabba60febfb381b8fb788c9a0cbf9ed30..f52481b1c1e5442c9a5b16b06b22221b75b9bb7c 100644 (file)
@@ -196,27 +196,46 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
 /*
  * Determine the type of allocation constraint.
  */
-static inline enum oom_constraint constrained_alloc(struct zonelist *zonelist,
-                                                   gfp_t gfp_mask)
-{
 #ifdef CONFIG_NUMA
+static enum oom_constraint constrained_alloc(struct zonelist *zonelist,
+                                   gfp_t gfp_mask, nodemask_t *nodemask)
+{
        struct zone *zone;
        struct zoneref *z;
        enum zone_type high_zoneidx = gfp_zone(gfp_mask);
-       nodemask_t nodes = node_states[N_HIGH_MEMORY];
 
-       for_each_zone_zonelist(zone, z, zonelist, high_zoneidx)
-               if (cpuset_zone_allowed_softwall(zone, gfp_mask))
-                       node_clear(zone_to_nid(zone), nodes);
-               else
-                       return CONSTRAINT_CPUSET;
+       /*
+        * Reach here only when __GFP_NOFAIL is used. So, we should avoid
+        * to kill current.We have to random task kill in this case.
+        * Hopefully, CONSTRAINT_THISNODE...but no way to handle it, now.
+        */
+       if (gfp_mask & __GFP_THISNODE)
+               return CONSTRAINT_NONE;
 
-       if (!nodes_empty(nodes))
+       /*
+        * The nodemask here is a nodemask passed to alloc_pages(). Now,
+        * cpuset doesn't use this nodemask for its hardwall/softwall/hierarchy
+        * feature. mempolicy is an only user of nodemask here.
+        * check mempolicy's nodemask contains all N_HIGH_MEMORY
+        */
+       if (nodemask && !nodes_subset(node_states[N_HIGH_MEMORY], *nodemask))
                return CONSTRAINT_MEMORY_POLICY;
-#endif
 
+       /* Check this allocation failure is caused by cpuset's wall function */
+       for_each_zone_zonelist_nodemask(zone, z, zonelist,
+                       high_zoneidx, nodemask)
+               if (!cpuset_zone_allowed_softwall(zone, gfp_mask))
+                       return CONSTRAINT_CPUSET;
+
+       return CONSTRAINT_NONE;
+}
+#else
+static enum oom_constraint constrained_alloc(struct zonelist *zonelist,
+                               gfp_t gfp_mask, nodemask_t *nodemask)
+{
        return CONSTRAINT_NONE;
 }
+#endif
 
 /*
  * Simple selection loop. We chose the process with the highest
@@ -337,6 +356,24 @@ static void dump_tasks(const struct mem_cgroup *mem)
        } while_each_thread(g, p);
 }
 
+static void dump_header(struct task_struct *p, gfp_t gfp_mask, int order,
+                                                       struct mem_cgroup *mem)
+{
+       pr_warning("%s invoked oom-killer: gfp_mask=0x%x, order=%d, "
+               "oom_adj=%d\n",
+               current->comm, gfp_mask, order, current->signal->oom_adj);
+       task_lock(current);
+       cpuset_print_task_mems_allowed(current);
+       task_unlock(current);
+       dump_stack();
+       mem_cgroup_print_oom_info(mem, p);
+       show_mem();
+       if (sysctl_oom_dump_tasks)
+               dump_tasks(mem);
+}
+
+#define K(x) ((x) << (PAGE_SHIFT-10))
+
 /*
  * Send SIGKILL to the selected  process irrespective of  CAP_SYS_RAW_IO
  * flag though it's unlikely that  we select a process with CAP_SYS_RAW_IO
@@ -350,15 +387,23 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
                return;
        }
 
+       task_lock(p);
        if (!p->mm) {
                WARN_ON(1);
-               printk(KERN_WARNING "tried to kill an mm-less task!\n");
+               printk(KERN_WARNING "tried to kill an mm-less task %d (%s)!\n",
+                       task_pid_nr(p), p->comm);
+               task_unlock(p);
                return;
        }
 
        if (verbose)
-               printk(KERN_ERR "Killed process %d (%s)\n",
-                               task_pid_nr(p), p->comm);
+               printk(KERN_ERR "Killed process %d (%s) "
+                      "vsz:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
+                      task_pid_nr(p), p->comm,
+                      K(p->mm->total_vm),
+                      K(get_mm_counter(p->mm, anon_rss)),
+                      K(get_mm_counter(p->mm, file_rss)));
+       task_unlock(p);
 
        /*
         * We give our sacrificial lamb high priority and access to
@@ -395,20 +440,8 @@ static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
 {
        struct task_struct *c;
 
-       if (printk_ratelimit()) {
-               printk(KERN_WARNING "%s invoked oom-killer: "
-                       "gfp_mask=0x%x, order=%d, oom_adj=%d\n",
-                       current->comm, gfp_mask, order,
-                       current->signal->oom_adj);
-               task_lock(current);
-               cpuset_print_task_mems_allowed(current);
-               task_unlock(current);
-               dump_stack();
-               mem_cgroup_print_oom_info(mem, current);
-               show_mem();
-               if (sysctl_oom_dump_tasks)
-                       dump_tasks(mem);
-       }
+       if (printk_ratelimit())
+               dump_header(p, gfp_mask, order, mem);
 
        /*
         * If the task is already exiting, don't alarm the sysadmin or kill
@@ -544,6 +577,7 @@ retry:
        /* Found nothing?!?! Either we hang forever, or we panic. */
        if (!p) {
                read_unlock(&tasklist_lock);
+               dump_header(NULL, gfp_mask, order, NULL);
                panic("Out of memory and no killable processes...\n");
        }
 
@@ -599,7 +633,8 @@ rest_and_return:
  * OR try to be smart about which process to kill. Note that we
  * don't have to be perfect here, we just have to be good.
  */
-void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
+void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask,
+               int order, nodemask_t *nodemask)
 {
        unsigned long freed = 0;
        enum oom_constraint constraint;
@@ -609,14 +644,16 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
                /* Got some memory back in the last second. */
                return;
 
-       if (sysctl_panic_on_oom == 2)
+       if (sysctl_panic_on_oom == 2) {
+               dump_header(NULL, gfp_mask, order, NULL);
                panic("out of memory. Compulsory panic_on_oom is selected.\n");
+       }
 
        /*
         * Check if there were limitations on the allocation (only relevant for
         * NUMA) that may require different handling.
         */
-       constraint = constrained_alloc(zonelist, gfp_mask);
+       constraint = constrained_alloc(zonelist, gfp_mask, nodemask);
        read_lock(&tasklist_lock);
 
        switch (constraint) {
@@ -626,8 +663,10 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
                break;
 
        case CONSTRAINT_NONE:
-               if (sysctl_panic_on_oom)
+               if (sysctl_panic_on_oom) {
+                       dump_header(NULL, gfp_mask, order, NULL);
                        panic("out of memory. panic_on_oom is selected\n");
+               }
                /* Fall-through */
        case CONSTRAINT_CPUSET:
                __out_of_memory(gfp_mask, order);
index 2bc2ac63f41ef8329774a5e444d0be8181ea83bd..4e9f5cc5fb59d166c57477771790106d1818c059 100644 (file)
@@ -48,6 +48,7 @@
 #include <linux/page_cgroup.h>
 #include <linux/debugobjects.h>
 #include <linux/kmemleak.h>
+#include <linux/memory.h>
 #include <trace/events/kmem.h>
 
 #include <asm/tlbflush.h>
@@ -486,7 +487,6 @@ static inline void __free_one_page(struct page *page,
        zone->free_area[order].nr_free++;
 }
 
-#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
 /*
  * free_page_mlock() -- clean up attempts to free and mlocked() page.
  * Page should not be on lru, so no need to fix that up.
@@ -497,9 +497,6 @@ static inline void free_page_mlock(struct page *page)
        __dec_zone_page_state(page, NR_MLOCK);
        __count_vm_event(UNEVICTABLE_MLOCKFREED);
 }
-#else
-static void free_page_mlock(struct page *page) { }
-#endif
 
 static inline int free_pages_check(struct page *page)
 {
@@ -1658,12 +1655,22 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
        if (page)
                goto out;
 
-       /* The OOM killer will not help higher order allocs */
-       if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_NOFAIL))
-               goto out;
-
+       if (!(gfp_mask & __GFP_NOFAIL)) {
+               /* The OOM killer will not help higher order allocs */
+               if (order > PAGE_ALLOC_COSTLY_ORDER)
+                       goto out;
+               /*
+                * GFP_THISNODE contains __GFP_NORETRY and we never hit this.
+                * Sanity check for bare calls of __GFP_THISNODE, not real OOM.
+                * The caller should handle page allocation failure by itself if
+                * it specifies __GFP_THISNODE.
+                * Note: Hugepage uses it but will hit PAGE_ALLOC_COSTLY_ORDER.
+                */
+               if (gfp_mask & __GFP_THISNODE)
+                       goto out;
+       }
        /* Exhausted what can be done so it's blamo time */
-       out_of_memory(zonelist, gfp_mask, order);
+       out_of_memory(zonelist, gfp_mask, order, nodemask);
 
 out:
        clear_zonelist_oom(zonelist, gfp_mask);
@@ -2395,13 +2402,14 @@ int numa_zonelist_order_handler(ctl_table *table, int write,
 {
        char saved_string[NUMA_ZONELIST_ORDER_LEN];
        int ret;
+       static DEFINE_MUTEX(zl_order_mutex);
 
+       mutex_lock(&zl_order_mutex);
        if (write)
-               strncpy(saved_string, (char*)table->data,
-                       NUMA_ZONELIST_ORDER_LEN);
+               strcpy(saved_string, (char*)table->data);
        ret = proc_dostring(table, write, buffer, length, ppos);
        if (ret)
-               return ret;
+               goto out;
        if (write) {
                int oldval = user_zonelist_order;
                if (__parse_numa_zonelist_order((char*)table->data)) {
@@ -2414,7 +2422,9 @@ int numa_zonelist_order_handler(ctl_table *table, int write,
                } else if (oldval != user_zonelist_order)
                        build_all_zonelists();
        }
-       return 0;
+out:
+       mutex_unlock(&zl_order_mutex);
+       return ret;
 }
 
 
@@ -3127,7 +3137,7 @@ static int __cpuinit process_zones(int cpu)
 
                if (percpu_pagelist_fraction)
                        setup_pagelist_highmark(zone_pcp(zone, cpu),
-                               (zone->present_pages / percpu_pagelist_fraction));
+                           (zone->present_pages / percpu_pagelist_fraction));
        }
 
        return 0;
@@ -3573,7 +3583,7 @@ static unsigned long __meminit zone_spanned_pages_in_node(int nid,
  * Return the number of holes in a range on a node. If nid is MAX_NUMNODES,
  * then all holes in the requested range will be accounted for.
  */
-static unsigned long __meminit __absent_pages_in_range(int nid,
+unsigned long __meminit __absent_pages_in_range(int nid,
                                unsigned long range_start_pfn,
                                unsigned long range_end_pfn)
 {
@@ -4102,7 +4112,7 @@ static int __init cmp_node_active_region(const void *a, const void *b)
 }
 
 /* sort the node_map by start_pfn */
-static void __init sort_node_map(void)
+void __init sort_node_map(void)
 {
        sort(early_node_map, (size_t)nr_nodemap_entries,
                        sizeof(struct node_active_region),
@@ -5002,23 +5012,65 @@ void set_pageblock_flags_group(struct page *page, unsigned long flags,
 int set_migratetype_isolate(struct page *page)
 {
        struct zone *zone;
-       unsigned long flags;
+       struct page *curr_page;
+       unsigned long flags, pfn, iter;
+       unsigned long immobile = 0;
+       struct memory_isolate_notify arg;
+       int notifier_ret;
        int ret = -EBUSY;
        int zone_idx;
 
        zone = page_zone(page);
        zone_idx = zone_idx(zone);
+
        spin_lock_irqsave(&zone->lock, flags);
+       if (get_pageblock_migratetype(page) == MIGRATE_MOVABLE ||
+           zone_idx == ZONE_MOVABLE) {
+               ret = 0;
+               goto out;
+       }
+
+       pfn = page_to_pfn(page);
+       arg.start_pfn = pfn;
+       arg.nr_pages = pageblock_nr_pages;
+       arg.pages_found = 0;
+
        /*
-        * In future, more migrate types will be able to be isolation target.
+        * It may be possible to isolate a pageblock even if the
+        * migratetype is not MIGRATE_MOVABLE. The memory isolation
+        * notifier chain is used by balloon drivers to return the
+        * number of pages in a range that are held by the balloon
+        * driver to shrink memory. If all the pages are accounted for
+        * by balloons, are free, or on the LRU, isolation can continue.
+        * Later, for example, when memory hotplug notifier runs, these
+        * pages reported as "can be isolated" should be isolated(freed)
+        * by the balloon driver through the memory notifier chain.
         */
-       if (get_pageblock_migratetype(page) != MIGRATE_MOVABLE &&
-           zone_idx != ZONE_MOVABLE)
+       notifier_ret = memory_isolate_notify(MEM_ISOLATE_COUNT, &arg);
+       notifier_ret = notifier_to_errno(notifier_ret);
+       if (notifier_ret || !arg.pages_found)
                goto out;
-       set_pageblock_migratetype(page, MIGRATE_ISOLATE);
-       move_freepages_block(zone, page, MIGRATE_ISOLATE);
-       ret = 0;
+
+       for (iter = pfn; iter < (pfn + pageblock_nr_pages); iter++) {
+               if (!pfn_valid_within(pfn))
+                       continue;
+
+               curr_page = pfn_to_page(iter);
+               if (!page_count(curr_page) || PageLRU(curr_page))
+                       continue;
+
+               immobile++;
+       }
+
+       if (arg.pages_found == immobile)
+               ret = 0;
+
 out:
+       if (!ret) {
+               set_pageblock_migratetype(page, MIGRATE_ISOLATE);
+               move_freepages_block(zone, page, MIGRATE_ISOLATE);
+       }
+
        spin_unlock_irqrestore(&zone->lock, flags);
        if (!ret)
                drain_all_pages();
@@ -5085,3 +5137,24 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
        spin_unlock_irqrestore(&zone->lock, flags);
 }
 #endif
+
+#ifdef CONFIG_MEMORY_FAILURE
+bool is_free_buddy_page(struct page *page)
+{
+       struct zone *zone = page_zone(page);
+       unsigned long pfn = page_to_pfn(page);
+       unsigned long flags;
+       int order;
+
+       spin_lock_irqsave(&zone->lock, flags);
+       for (order = 0; order < MAX_ORDER; order++) {
+               struct page *page_head = page - (pfn & ((1 << order) - 1));
+
+               if (PageBuddy(page_head) && page_order(page_head) >= order)
+                       break;
+       }
+       spin_unlock_irqrestore(&zone->lock, flags);
+
+       return order < MAX_ORDER;
+}
+#endif
index c6f3e5071de3bb57c737cef88ab32c3cbdac4aee..a19af956ee1bb6f55d87df3a3905a486820a49a7 100644 (file)
 #include <linux/writeback.h>
 #include <asm/pgtable.h>
 
-static struct bio *get_swap_bio(gfp_t gfp_flags, pgoff_t index,
+static struct bio *get_swap_bio(gfp_t gfp_flags,
                                struct page *page, bio_end_io_t end_io)
 {
        struct bio *bio;
 
        bio = bio_alloc(gfp_flags, 1);
        if (bio) {
-               struct swap_info_struct *sis;
-               swp_entry_t entry = { .val = index, };
-
-               sis = get_swap_info_struct(swp_type(entry));
-               bio->bi_sector = map_swap_page(sis, swp_offset(entry)) *
-                                       (PAGE_SIZE >> 9);
-               bio->bi_bdev = sis->bdev;
+               bio->bi_sector = map_swap_page(page, &bio->bi_bdev);
+               bio->bi_sector <<= PAGE_SHIFT - 9;
                bio->bi_io_vec[0].bv_page = page;
                bio->bi_io_vec[0].bv_len = PAGE_SIZE;
                bio->bi_io_vec[0].bv_offset = 0;
@@ -102,8 +97,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
                unlock_page(page);
                goto out;
        }
-       bio = get_swap_bio(GFP_NOIO, page_private(page), page,
-                               end_swap_bio_write);
+       bio = get_swap_bio(GFP_NOIO, page, end_swap_bio_write);
        if (bio == NULL) {
                set_page_dirty(page);
                unlock_page(page);
@@ -127,8 +121,7 @@ int swap_readpage(struct page *page)
 
        VM_BUG_ON(!PageLocked(page));
        VM_BUG_ON(PageUptodate(page));
-       bio = get_swap_bio(GFP_KERNEL, page_private(page), page,
-                               end_swap_bio_read);
+       bio = get_swap_bio(GFP_KERNEL, page, end_swap_bio_read);
        if (bio == NULL) {
                unlock_page(page);
                ret = -ENOMEM;
index d5878bed78412542b82c03022756db62c9d73d63..7b47a57b66462dae3d9ae42929a1bba543d2c290 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>
 #include <linux/sched.h>
+#include <linux/hugetlb.h>
 
 static int walk_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
                          struct mm_walk *walk)
@@ -107,6 +108,7 @@ int walk_page_range(unsigned long addr, unsigned long end,
        pgd_t *pgd;
        unsigned long next;
        int err = 0;
+       struct vm_area_struct *vma;
 
        if (addr >= end)
                return err;
@@ -117,11 +119,38 @@ int walk_page_range(unsigned long addr, unsigned long end,
        pgd = pgd_offset(walk->mm, addr);
        do {
                next = pgd_addr_end(addr, end);
+
+               /*
+                * handle hugetlb vma individually because pagetable walk for
+                * the hugetlb page is dependent on the architecture and
+                * we can't handled it in the same manner as non-huge pages.
+                */
+               vma = find_vma(walk->mm, addr);
+#ifdef CONFIG_HUGETLB_PAGE
+               if (vma && is_vm_hugetlb_page(vma)) {
+                       pte_t *pte;
+                       struct hstate *hs;
+
+                       if (vma->vm_end < next)
+                               next = vma->vm_end;
+                       hs = hstate_vma(vma);
+                       pte = huge_pte_offset(walk->mm,
+                                             addr & huge_page_mask(hs));
+                       if (pte && !huge_pte_none(huge_ptep_get(pte))
+                           && walk->hugetlb_entry)
+                               err = walk->hugetlb_entry(pte, addr,
+                                                         next, walk);
+                       if (err)
+                               break;
+                       continue;
+               }
+#endif
                if (pgd_none_or_clear_bad(pgd)) {
                        if (walk->pte_hole)
                                err = walk->pte_hole(addr, next, walk);
                        if (err)
                                break;
+                       pgd++;
                        continue;
                }
                if (walk->pgd_entry)
@@ -131,7 +160,8 @@ int walk_page_range(unsigned long addr, unsigned long end,
                        err = walk_pud_range(pgd, addr, next, walk);
                if (err)
                        break;
-       } while (pgd++, addr = next, addr != end);
+               pgd++;
+       } while (addr = next, addr != end);
 
        return err;
 }
index aa1aa23452355067af9d62179cd41d62c64e68fc..033bc135a41f3885cae863ca0c9f5185d6c5d665 100644 (file)
@@ -547,5 +547,17 @@ page_cache_async_readahead(struct address_space *mapping,
 
        /* do read-ahead */
        ondemand_readahead(mapping, ra, filp, true, offset, req_size);
+
+#ifdef CONFIG_BLOCK
+       /*
+        * Normally the current page is !uptodate and lock_page() will be
+        * immediately called to implicitly unplug the device. However this
+        * is not always true for RAID conifgurations, where data arrives
+        * not strictly in their submission order. In this case we need to
+        * explicitly kick off the IO.
+        */
+       if (PageUptodate(page))
+               blk_run_backing_dev(mapping->backing_dev_info, NULL);
+#endif
 }
 EXPORT_SYMBOL_GPL(page_cache_async_readahead);
index dd43373a483fa764ce35a3bdc541ea4148653af4..278cd277bdec75cfb3de7bb01157ad2e092f622a 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -49,6 +49,7 @@
 #include <linux/swapops.h>
 #include <linux/slab.h>
 #include <linux/init.h>
+#include <linux/ksm.h>
 #include <linux/rmap.h>
 #include <linux/rcupdate.h>
 #include <linux/module.h>
@@ -67,7 +68,7 @@ static inline struct anon_vma *anon_vma_alloc(void)
        return kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
 }
 
-static inline void anon_vma_free(struct anon_vma *anon_vma)
+void anon_vma_free(struct anon_vma *anon_vma)
 {
        kmem_cache_free(anon_vma_cachep, anon_vma);
 }
@@ -171,7 +172,7 @@ void anon_vma_unlink(struct vm_area_struct *vma)
        list_del(&vma->anon_vma_node);
 
        /* We must garbage collect the anon_vma if it's empty */
-       empty = list_empty(&anon_vma->head);
+       empty = list_empty(&anon_vma->head) && !ksm_refcount(anon_vma);
        spin_unlock(&anon_vma->lock);
 
        if (empty)
@@ -183,6 +184,7 @@ static void anon_vma_ctor(void *data)
        struct anon_vma *anon_vma = data;
 
        spin_lock_init(&anon_vma->lock);
+       ksm_refcount_init(anon_vma);
        INIT_LIST_HEAD(&anon_vma->head);
 }
 
@@ -202,8 +204,8 @@ struct anon_vma *page_lock_anon_vma(struct page *page)
        unsigned long anon_mapping;
 
        rcu_read_lock();
-       anon_mapping = (unsigned long) page->mapping;
-       if (!(anon_mapping & PAGE_MAPPING_ANON))
+       anon_mapping = (unsigned long) ACCESS_ONCE(page->mapping);
+       if ((anon_mapping & PAGE_MAPPING_FLAGS) != PAGE_MAPPING_ANON)
                goto out;
        if (!page_mapped(page))
                goto out;
@@ -248,8 +250,7 @@ vma_address(struct page *page, struct vm_area_struct *vma)
 unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
 {
        if (PageAnon(page)) {
-               if ((void *)vma->anon_vma !=
-                   (void *)page->mapping - PAGE_MAPPING_ANON)
+               if (vma->anon_vma != page_anon_vma(page))
                        return -EFAULT;
        } else if (page->mapping && !(vma->vm_flags & VM_NONLINEAR)) {
                if (!vma->vm_file ||
@@ -337,21 +338,15 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma)
  * Subfunctions of page_referenced: page_referenced_one called
  * repeatedly from either page_referenced_anon or page_referenced_file.
  */
-static int page_referenced_one(struct page *page,
-                              struct vm_area_struct *vma,
-                              unsigned int *mapcount,
-                              unsigned long *vm_flags)
+int page_referenced_one(struct page *page, struct vm_area_struct *vma,
+                       unsigned long address, unsigned int *mapcount,
+                       unsigned long *vm_flags)
 {
        struct mm_struct *mm = vma->vm_mm;
-       unsigned long address;
        pte_t *pte;
        spinlock_t *ptl;
        int referenced = 0;
 
-       address = vma_address(page, vma);
-       if (address == -EFAULT)
-               goto out;
-
        pte = page_check_address(page, mm, address, &ptl, 0);
        if (!pte)
                goto out;
@@ -388,9 +383,10 @@ static int page_referenced_one(struct page *page,
 out_unmap:
        (*mapcount)--;
        pte_unmap_unlock(pte, ptl);
-out:
+
        if (referenced)
                *vm_flags |= vma->vm_flags;
+out:
        return referenced;
 }
 
@@ -409,6 +405,9 @@ static int page_referenced_anon(struct page *page,
 
        mapcount = page_mapcount(page);
        list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
+               unsigned long address = vma_address(page, vma);
+               if (address == -EFAULT)
+                       continue;
                /*
                 * If we are reclaiming on behalf of a cgroup, skip
                 * counting on behalf of references from different
@@ -416,7 +415,7 @@ static int page_referenced_anon(struct page *page,
                 */
                if (mem_cont && !mm_match_cgroup(vma->vm_mm, mem_cont))
                        continue;
-               referenced += page_referenced_one(page, vma,
+               referenced += page_referenced_one(page, vma, address,
                                                  &mapcount, vm_flags);
                if (!mapcount)
                        break;
@@ -474,6 +473,9 @@ static int page_referenced_file(struct page *page,
        mapcount = page_mapcount(page);
 
        vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
+               unsigned long address = vma_address(page, vma);
+               if (address == -EFAULT)
+                       continue;
                /*
                 * If we are reclaiming on behalf of a cgroup, skip
                 * counting on behalf of references from different
@@ -481,7 +483,7 @@ static int page_referenced_file(struct page *page,
                 */
                if (mem_cont && !mm_match_cgroup(vma->vm_mm, mem_cont))
                        continue;
-               referenced += page_referenced_one(page, vma,
+               referenced += page_referenced_one(page, vma, address,
                                                  &mapcount, vm_flags);
                if (!mapcount)
                        break;
@@ -507,46 +509,47 @@ int page_referenced(struct page *page,
                    unsigned long *vm_flags)
 {
        int referenced = 0;
+       int we_locked = 0;
 
        if (TestClearPageReferenced(page))
                referenced++;
 
        *vm_flags = 0;
-       if (page_mapped(page) && page->mapping) {
-               if (PageAnon(page))
+       if (page_mapped(page) && page_rmapping(page)) {
+               if (!is_locked && (!PageAnon(page) || PageKsm(page))) {
+                       we_locked = trylock_page(page);
+                       if (!we_locked) {
+                               referenced++;
+                               goto out;
+                       }
+               }
+               if (unlikely(PageKsm(page)))
+                       referenced += page_referenced_ksm(page, mem_cont,
+                                                               vm_flags);
+               else if (PageAnon(page))
                        referenced += page_referenced_anon(page, mem_cont,
                                                                vm_flags);
-               else if (is_locked)
+               else if (page->mapping)
                        referenced += page_referenced_file(page, mem_cont,
                                                                vm_flags);
-               else if (!trylock_page(page))
-                       referenced++;
-               else {
-                       if (page->mapping)
-                               referenced += page_referenced_file(page,
-                                                       mem_cont, vm_flags);
+               if (we_locked)
                        unlock_page(page);
-               }
        }
-
+out:
        if (page_test_and_clear_young(page))
                referenced++;
 
        return referenced;
 }
 
-static int page_mkclean_one(struct page *page, struct vm_area_struct *vma)
+static int page_mkclean_one(struct page *page, struct vm_area_struct *vma,
+                           unsigned long address)
 {
        struct mm_struct *mm = vma->vm_mm;
-       unsigned long address;
        pte_t *pte;
        spinlock_t *ptl;
        int ret = 0;
 
-       address = vma_address(page, vma);
-       if (address == -EFAULT)
-               goto out;
-
        pte = page_check_address(page, mm, address, &ptl, 1);
        if (!pte)
                goto out;
@@ -578,8 +581,12 @@ static int page_mkclean_file(struct address_space *mapping, struct page *page)
 
        spin_lock(&mapping->i_mmap_lock);
        vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
-               if (vma->vm_flags & VM_SHARED)
-                       ret += page_mkclean_one(page, vma);
+               if (vma->vm_flags & VM_SHARED) {
+                       unsigned long address = vma_address(page, vma);
+                       if (address == -EFAULT)
+                               continue;
+                       ret += page_mkclean_one(page, vma, address);
+               }
        }
        spin_unlock(&mapping->i_mmap_lock);
        return ret;
@@ -620,14 +627,7 @@ static void __page_set_anon_rmap(struct page *page,
        BUG_ON(!anon_vma);
        anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
        page->mapping = (struct address_space *) anon_vma;
-
        page->index = linear_page_index(vma, address);
-
-       /*
-        * nr_mapped state can be updated without turning off
-        * interrupts because it is not modified via interrupt.
-        */
-       __inc_zone_page_state(page, NR_ANON_PAGES);
 }
 
 /**
@@ -665,14 +665,23 @@ static void __page_check_anon_rmap(struct page *page,
  * @vma:       the vm area in which the mapping is added
  * @address:   the user virtual address mapped
  *
- * The caller needs to hold the pte lock and the page must be locked.
+ * The caller needs to hold the pte lock, and the page must be locked in
+ * the anon_vma case: to serialize mapping,index checking after setting,
+ * and to ensure that PageAnon is not being upgraded racily to PageKsm
+ * (but PageKsm is never downgraded to PageAnon).
  */
 void page_add_anon_rmap(struct page *page,
        struct vm_area_struct *vma, unsigned long address)
 {
+       int first = atomic_inc_and_test(&page->_mapcount);
+       if (first)
+               __inc_zone_page_state(page, NR_ANON_PAGES);
+       if (unlikely(PageKsm(page)))
+               return;
+
        VM_BUG_ON(!PageLocked(page));
        VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
-       if (atomic_inc_and_test(&page->_mapcount))
+       if (first)
                __page_set_anon_rmap(page, vma, address);
        else
                __page_check_anon_rmap(page, vma, address);
@@ -694,6 +703,7 @@ void page_add_new_anon_rmap(struct page *page,
        VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
        SetPageSwapBacked(page);
        atomic_set(&page->_mapcount, 0); /* increment count (starts at -1) */
+       __inc_zone_page_state(page, NR_ANON_PAGES);
        __page_set_anon_rmap(page, vma, address);
        if (page_evictable(page, vma))
                lru_cache_add_lru(page, LRU_ACTIVE_ANON);
@@ -711,7 +721,7 @@ void page_add_file_rmap(struct page *page)
 {
        if (atomic_inc_and_test(&page->_mapcount)) {
                __inc_zone_page_state(page, NR_FILE_MAPPED);
-               mem_cgroup_update_mapped_file_stat(page, 1);
+               mem_cgroup_update_file_mapped(page, 1);
        }
 }
 
@@ -743,8 +753,8 @@ void page_remove_rmap(struct page *page)
                __dec_zone_page_state(page, NR_ANON_PAGES);
        } else {
                __dec_zone_page_state(page, NR_FILE_MAPPED);
+               mem_cgroup_update_file_mapped(page, -1);
        }
-       mem_cgroup_update_mapped_file_stat(page, -1);
        /*
         * It would be tidy to reset the PageAnon mapping here,
         * but that might overwrite a racing page_add_anon_rmap
@@ -760,20 +770,15 @@ void page_remove_rmap(struct page *page)
  * Subfunctions of try_to_unmap: try_to_unmap_one called
  * repeatedly from either try_to_unmap_anon or try_to_unmap_file.
  */
-static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
-                               enum ttu_flags flags)
+int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
+                    unsigned long address, enum ttu_flags flags)
 {
        struct mm_struct *mm = vma->vm_mm;
-       unsigned long address;
        pte_t *pte;
        pte_t pteval;
        spinlock_t *ptl;
        int ret = SWAP_AGAIN;
 
-       address = vma_address(page, vma);
-       if (address == -EFAULT)
-               goto out;
-
        pte = page_check_address(page, mm, address, &ptl, 0);
        if (!pte)
                goto out;
@@ -784,10 +789,11 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
         * skipped over this mm) then we should reactivate it.
         */
        if (!(flags & TTU_IGNORE_MLOCK)) {
-               if (vma->vm_flags & VM_LOCKED) {
-                       ret = SWAP_MLOCK;
+               if (vma->vm_flags & VM_LOCKED)
+                       goto out_mlock;
+
+               if (TTU_ACTION(flags) == TTU_MUNLOCK)
                        goto out_unmap;
-               }
        }
        if (!(flags & TTU_IGNORE_ACCESS)) {
                if (ptep_clear_flush_young_notify(vma, address, pte)) {
@@ -822,7 +828,11 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                         * Store the swap location in the pte.
                         * See handle_pte_fault() ...
                         */
-                       swap_duplicate(entry);
+                       if (swap_duplicate(entry) < 0) {
+                               set_pte_at(mm, address, pte, pteval);
+                               ret = SWAP_FAIL;
+                               goto out_unmap;
+                       }
                        if (list_empty(&mm->mmlist)) {
                                spin_lock(&mmlist_lock);
                                if (list_empty(&mm->mmlist))
@@ -849,7 +859,6 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
        } else
                dec_mm_counter(mm, file_rss);
 
-
        page_remove_rmap(page);
        page_cache_release(page);
 
@@ -857,6 +866,27 @@ out_unmap:
        pte_unmap_unlock(pte, ptl);
 out:
        return ret;
+
+out_mlock:
+       pte_unmap_unlock(pte, ptl);
+
+
+       /*
+        * We need mmap_sem locking, Otherwise VM_LOCKED check makes
+        * unstable result and race. Plus, We can't wait here because
+        * we now hold anon_vma->lock or mapping->i_mmap_lock.
+        * if trylock failed, the page remain in evictable lru and later
+        * vmscan could retry to move the page to unevictable lru if the
+        * page is actually mlocked.
+        */
+       if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
+               if (vma->vm_flags & VM_LOCKED) {
+                       mlock_vma_page(page);
+                       ret = SWAP_MLOCK;
+               }
+               up_read(&vma->vm_mm->mmap_sem);
+       }
+       return ret;
 }
 
 /*
@@ -922,11 +952,10 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
                return ret;
 
        /*
-        * MLOCK_PAGES => feature is configured.
-        * if we can acquire the mmap_sem for read, and vma is VM_LOCKED,
+        * If we can acquire the mmap_sem for read, and vma is VM_LOCKED,
         * keep the sem while scanning the cluster for mlocking pages.
         */
-       if (MLOCK_PAGES && down_read_trylock(&vma->vm_mm->mmap_sem)) {
+       if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
                locked_vma = (vma->vm_flags & VM_LOCKED);
                if (!locked_vma)
                        up_read(&vma->vm_mm->mmap_sem); /* don't need it */
@@ -976,29 +1005,11 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
        return ret;
 }
 
-/*
- * common handling for pages mapped in VM_LOCKED vmas
- */
-static int try_to_mlock_page(struct page *page, struct vm_area_struct *vma)
-{
-       int mlocked = 0;
-
-       if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
-               if (vma->vm_flags & VM_LOCKED) {
-                       mlock_vma_page(page);
-                       mlocked++;      /* really mlocked the page */
-               }
-               up_read(&vma->vm_mm->mmap_sem);
-       }
-       return mlocked;
-}
-
 /**
  * try_to_unmap_anon - unmap or unlock anonymous page using the object-based
  * rmap method
  * @page: the page to unmap/unlock
- * @unlock:  request for unlock rather than unmap [unlikely]
- * @migration:  unmapping for migration - ignored if @unlock
+ * @flags: action and flags
  *
  * Find all the mappings of a page using the mapping pointer and the vma chains
  * contained in the anon_vma struct it points to.
@@ -1014,42 +1025,22 @@ static int try_to_unmap_anon(struct page *page, enum ttu_flags flags)
 {
        struct anon_vma *anon_vma;
        struct vm_area_struct *vma;
-       unsigned int mlocked = 0;
        int ret = SWAP_AGAIN;
-       int unlock = TTU_ACTION(flags) == TTU_MUNLOCK;
-
-       if (MLOCK_PAGES && unlikely(unlock))
-               ret = SWAP_SUCCESS;     /* default for try_to_munlock() */
 
        anon_vma = page_lock_anon_vma(page);
        if (!anon_vma)
                return ret;
 
        list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
-               if (MLOCK_PAGES && unlikely(unlock)) {
-                       if (!((vma->vm_flags & VM_LOCKED) &&
-                             page_mapped_in_vma(page, vma)))
-                               continue;  /* must visit all unlocked vmas */
-                       ret = SWAP_MLOCK;  /* saw at least one mlocked vma */
-               } else {
-                       ret = try_to_unmap_one(page, vma, flags);
-                       if (ret == SWAP_FAIL || !page_mapped(page))
-                               break;
-               }
-               if (ret == SWAP_MLOCK) {
-                       mlocked = try_to_mlock_page(page, vma);
-                       if (mlocked)
-                               break;  /* stop if actually mlocked page */
-               }
+               unsigned long address = vma_address(page, vma);
+               if (address == -EFAULT)
+                       continue;
+               ret = try_to_unmap_one(page, vma, address, flags);
+               if (ret != SWAP_AGAIN || !page_mapped(page))
+                       break;
        }
 
        page_unlock_anon_vma(anon_vma);
-
-       if (mlocked)
-               ret = SWAP_MLOCK;       /* actually mlocked the page */
-       else if (ret == SWAP_MLOCK)
-               ret = SWAP_AGAIN;       /* saw VM_LOCKED vma */
-
        return ret;
 }
 
@@ -1079,48 +1070,30 @@ static int try_to_unmap_file(struct page *page, enum ttu_flags flags)
        unsigned long max_nl_cursor = 0;
        unsigned long max_nl_size = 0;
        unsigned int mapcount;
-       unsigned int mlocked = 0;
-       int unlock = TTU_ACTION(flags) == TTU_MUNLOCK;
-
-       if (MLOCK_PAGES && unlikely(unlock))
-               ret = SWAP_SUCCESS;     /* default for try_to_munlock() */
 
        spin_lock(&mapping->i_mmap_lock);
        vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
-               if (MLOCK_PAGES && unlikely(unlock)) {
-                       if (!((vma->vm_flags & VM_LOCKED) &&
-                                               page_mapped_in_vma(page, vma)))
-                               continue;       /* must visit all vmas */
-                       ret = SWAP_MLOCK;
-               } else {
-                       ret = try_to_unmap_one(page, vma, flags);
-                       if (ret == SWAP_FAIL || !page_mapped(page))
-                               goto out;
-               }
-               if (ret == SWAP_MLOCK) {
-                       mlocked = try_to_mlock_page(page, vma);
-                       if (mlocked)
-                               break;  /* stop if actually mlocked page */
-               }
+               unsigned long address = vma_address(page, vma);
+               if (address == -EFAULT)
+                       continue;
+               ret = try_to_unmap_one(page, vma, address, flags);
+               if (ret != SWAP_AGAIN || !page_mapped(page))
+                       goto out;
        }
 
-       if (mlocked)
+       if (list_empty(&mapping->i_mmap_nonlinear))
                goto out;
 
-       if (list_empty(&mapping->i_mmap_nonlinear))
+       /*
+        * We don't bother to try to find the munlocked page in nonlinears.
+        * It's costly. Instead, later, page reclaim logic may call
+        * try_to_unmap(TTU_MUNLOCK) and recover PG_mlocked lazily.
+        */
+       if (TTU_ACTION(flags) == TTU_MUNLOCK)
                goto out;
 
        list_for_each_entry(vma, &mapping->i_mmap_nonlinear,
                                                shared.vm_set.list) {
-               if (MLOCK_PAGES && unlikely(unlock)) {
-                       if (!(vma->vm_flags & VM_LOCKED))
-                               continue;       /* must visit all vmas */
-                       ret = SWAP_MLOCK;       /* leave mlocked == 0 */
-                       goto out;               /* no need to look further */
-               }
-               if (!MLOCK_PAGES && !(flags & TTU_IGNORE_MLOCK) &&
-                       (vma->vm_flags & VM_LOCKED))
-                       continue;
                cursor = (unsigned long) vma->vm_private_data;
                if (cursor > max_nl_cursor)
                        max_nl_cursor = cursor;
@@ -1153,16 +1126,12 @@ static int try_to_unmap_file(struct page *page, enum ttu_flags flags)
        do {
                list_for_each_entry(vma, &mapping->i_mmap_nonlinear,
                                                shared.vm_set.list) {
-                       if (!MLOCK_PAGES && !(flags & TTU_IGNORE_MLOCK) &&
-                           (vma->vm_flags & VM_LOCKED))
-                               continue;
                        cursor = (unsigned long) vma->vm_private_data;
                        while ( cursor < max_nl_cursor &&
                                cursor < vma->vm_end - vma->vm_start) {
-                               ret = try_to_unmap_cluster(cursor, &mapcount,
-                                                               vma, page);
-                               if (ret == SWAP_MLOCK)
-                                       mlocked = 2;    /* to return below */
+                               if (try_to_unmap_cluster(cursor, &mapcount,
+                                               vma, page) == SWAP_MLOCK)
+                                       ret = SWAP_MLOCK;
                                cursor += CLUSTER_SIZE;
                                vma->vm_private_data = (void *) cursor;
                                if ((int)mapcount <= 0)
@@ -1183,10 +1152,6 @@ static int try_to_unmap_file(struct page *page, enum ttu_flags flags)
                vma->vm_private_data = NULL;
 out:
        spin_unlock(&mapping->i_mmap_lock);
-       if (mlocked)
-               ret = SWAP_MLOCK;       /* actually mlocked the page */
-       else if (ret == SWAP_MLOCK)
-               ret = SWAP_AGAIN;       /* saw VM_LOCKED vma */
        return ret;
 }
 
@@ -1210,7 +1175,9 @@ int try_to_unmap(struct page *page, enum ttu_flags flags)
 
        BUG_ON(!PageLocked(page));
 
-       if (PageAnon(page))
+       if (unlikely(PageKsm(page)))
+               ret = try_to_unmap_ksm(page, flags);
+       else if (PageAnon(page))
                ret = try_to_unmap_anon(page, flags);
        else
                ret = try_to_unmap_file(page, flags);
@@ -1229,17 +1196,98 @@ int try_to_unmap(struct page *page, enum ttu_flags flags)
  *
  * Return values are:
  *
- * SWAP_SUCCESS        - no vma's holding page mlocked.
+ * SWAP_AGAIN  - no vma is holding page mlocked, or,
  * SWAP_AGAIN  - page mapped in mlocked vma -- couldn't acquire mmap sem
+ * SWAP_FAIL   - page cannot be located at present
  * SWAP_MLOCK  - page is now mlocked.
  */
 int try_to_munlock(struct page *page)
 {
        VM_BUG_ON(!PageLocked(page) || PageLRU(page));
 
-       if (PageAnon(page))
+       if (unlikely(PageKsm(page)))
+               return try_to_unmap_ksm(page, TTU_MUNLOCK);
+       else if (PageAnon(page))
                return try_to_unmap_anon(page, TTU_MUNLOCK);
        else
                return try_to_unmap_file(page, TTU_MUNLOCK);
 }
 
+#ifdef CONFIG_MIGRATION
+/*
+ * rmap_walk() and its helpers rmap_walk_anon() and rmap_walk_file():
+ * Called by migrate.c to remove migration ptes, but might be used more later.
+ */
+static int rmap_walk_anon(struct page *page, int (*rmap_one)(struct page *,
+               struct vm_area_struct *, unsigned long, void *), void *arg)
+{
+       struct anon_vma *anon_vma;
+       struct vm_area_struct *vma;
+       int ret = SWAP_AGAIN;
+
+       /*
+        * Note: remove_migration_ptes() cannot use page_lock_anon_vma()
+        * because that depends on page_mapped(); but not all its usages
+        * are holding mmap_sem, which also gave the necessary guarantee
+        * (that this anon_vma's slab has not already been destroyed).
+        * This needs to be reviewed later: avoiding page_lock_anon_vma()
+        * is risky, and currently limits the usefulness of rmap_walk().
+        */
+       anon_vma = page_anon_vma(page);
+       if (!anon_vma)
+               return ret;
+       spin_lock(&anon_vma->lock);
+       list_for_each_entry(vma, &anon_vma->head, anon_vma_node) {
+               unsigned long address = vma_address(page, vma);
+               if (address == -EFAULT)
+                       continue;
+               ret = rmap_one(page, vma, address, arg);
+               if (ret != SWAP_AGAIN)
+                       break;
+       }
+       spin_unlock(&anon_vma->lock);
+       return ret;
+}
+
+static int rmap_walk_file(struct page *page, int (*rmap_one)(struct page *,
+               struct vm_area_struct *, unsigned long, void *), void *arg)
+{
+       struct address_space *mapping = page->mapping;
+       pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
+       struct vm_area_struct *vma;
+       struct prio_tree_iter iter;
+       int ret = SWAP_AGAIN;
+
+       if (!mapping)
+               return ret;
+       spin_lock(&mapping->i_mmap_lock);
+       vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
+               unsigned long address = vma_address(page, vma);
+               if (address == -EFAULT)
+                       continue;
+               ret = rmap_one(page, vma, address, arg);
+               if (ret != SWAP_AGAIN)
+                       break;
+       }
+       /*
+        * No nonlinear handling: being always shared, nonlinear vmas
+        * never contain migration ptes.  Decide what to do about this
+        * limitation to linear when we need rmap_walk() on nonlinear.
+        */
+       spin_unlock(&mapping->i_mmap_lock);
+       return ret;
+}
+
+int rmap_walk(struct page *page, int (*rmap_one)(struct page *,
+               struct vm_area_struct *, unsigned long, void *), void *arg)
+{
+       VM_BUG_ON(!PageLocked(page));
+
+       if (unlikely(PageKsm(page)))
+               return rmap_walk_ksm(page, rmap_one, arg);
+       else if (PageAnon(page))
+               return rmap_walk_anon(page, rmap_one, arg);
+       else
+               return rmap_walk_file(page, rmap_one, arg);
+}
+#endif /* CONFIG_MIGRATION */
index 356dd99566ecb671cd324ba3dddcee10441312f0..eef4ebea51581f9aa8a6d2244f8ce5fa57f99c22 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/swap.h>
-#include <linux/ima.h>
 
 static struct vfsmount *shm_mnt;
 
@@ -42,6 +41,7 @@ static struct vfsmount *shm_mnt;
 
 #include <linux/xattr.h>
 #include <linux/exportfs.h>
+#include <linux/posix_acl.h>
 #include <linux/generic_acl.h>
 #include <linux/mman.h>
 #include <linux/string.h>
@@ -810,7 +810,7 @@ static int shmem_notify_change(struct dentry *dentry, struct iattr *attr)
                error = inode_setattr(inode, attr);
 #ifdef CONFIG_TMPFS_POSIX_ACL
        if (!error && (attr->ia_valid & ATTR_MODE))
-               error = generic_acl_chmod(inode, &shmem_acl_ops);
+               error = generic_acl_chmod(inode);
 #endif
        if (page)
                page_cache_release(page);
@@ -1017,7 +1017,14 @@ int shmem_unuse(swp_entry_t entry, struct page *page)
                        goto out;
        }
        mutex_unlock(&shmem_swaplist_mutex);
-out:   return found;   /* 0 or 1 or -ENOMEM */
+       /*
+        * Can some race bring us here?  We've been holding page lock,
+        * so I think not; but would rather try again later than BUG()
+        */
+       unlock_page(page);
+       page_cache_release(page);
+out:
+       return (found < 0) ? found : 0;
 }
 
 /*
@@ -1080,7 +1087,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
                else
                        inode = NULL;
                spin_unlock(&info->lock);
-               swap_duplicate(swap);
+               swap_shmem_alloc(swap);
                BUG_ON(page_mapped(page));
                page_cache_release(page);       /* pagecache ref */
                swap_writepage(page, wbc);
@@ -1817,11 +1824,15 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
                                return error;
                        }
                }
-               error = shmem_acl_init(inode, dir);
+#ifdef CONFIG_TMPFS_POSIX_ACL
+               error = generic_acl_init(inode, dir);
                if (error) {
                        iput(inode);
                        return error;
                }
+#else
+               error = 0;
+#endif
                if (dir->i_mode & S_ISGID) {
                        inode->i_gid = dir->i_gid;
                        if (S_ISDIR(mode))
@@ -2036,27 +2047,28 @@ static const struct inode_operations shmem_symlink_inode_operations = {
  * filesystem level, though.
  */
 
-static size_t shmem_xattr_security_list(struct inode *inode, char *list,
+static size_t shmem_xattr_security_list(struct dentry *dentry, char *list,
                                        size_t list_len, const char *name,
-                                       size_t name_len)
+                                       size_t name_len, int handler_flags)
 {
-       return security_inode_listsecurity(inode, list, list_len);
+       return security_inode_listsecurity(dentry->d_inode, list, list_len);
 }
 
-static int shmem_xattr_security_get(struct inode *inode, const char *name,
-                                   void *buffer, size_t size)
+static int shmem_xattr_security_get(struct dentry *dentry, const char *name,
+               void *buffer, size_t size, int handler_flags)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return xattr_getsecurity(inode, name, buffer, size);
+       return xattr_getsecurity(dentry->d_inode, name, buffer, size);
 }
 
-static int shmem_xattr_security_set(struct inode *inode, const char *name,
-                                   const void *value, size_t size, int flags)
+static int shmem_xattr_security_set(struct dentry *dentry, const char *name,
+               const void *value, size_t size, int flags, int handler_flags)
 {
        if (strcmp(name, "") == 0)
                return -EINVAL;
-       return security_inode_setsecurity(inode, name, value, size, flags);
+       return security_inode_setsecurity(dentry->d_inode, name, value,
+                                         size, flags);
 }
 
 static struct xattr_handler shmem_xattr_security_handler = {
@@ -2067,8 +2079,8 @@ static struct xattr_handler shmem_xattr_security_handler = {
 };
 
 static struct xattr_handler *shmem_xattr_handlers[] = {
-       &shmem_xattr_acl_access_handler,
-       &shmem_xattr_acl_default_handler,
+       &generic_acl_access_handler,
+       &generic_acl_default_handler,
        &shmem_xattr_security_handler,
        NULL
 };
@@ -2447,7 +2459,7 @@ static const struct inode_operations shmem_inode_operations = {
        .getxattr       = generic_getxattr,
        .listxattr      = generic_listxattr,
        .removexattr    = generic_removexattr,
-       .check_acl      = shmem_check_acl,
+       .check_acl      = generic_check_acl,
 #endif
 
 };
@@ -2470,7 +2482,7 @@ static const struct inode_operations shmem_dir_inode_operations = {
        .getxattr       = generic_getxattr,
        .listxattr      = generic_listxattr,
        .removexattr    = generic_removexattr,
-       .check_acl      = shmem_check_acl,
+       .check_acl      = generic_check_acl,
 #endif
 };
 
@@ -2481,7 +2493,7 @@ static const struct inode_operations shmem_special_inode_operations = {
        .getxattr       = generic_getxattr,
        .listxattr      = generic_listxattr,
        .removexattr    = generic_removexattr,
-       .check_acl      = shmem_check_acl,
+       .check_acl      = generic_check_acl,
 #endif
 };
 
@@ -2619,7 +2631,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
        int error;
        struct file *file;
        struct inode *inode;
-       struct dentry *dentry, *root;
+       struct path path;
+       struct dentry *root;
        struct qstr this;
 
        if (IS_ERR(shm_mnt))
@@ -2636,38 +2649,35 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
        this.len = strlen(name);
        this.hash = 0; /* will go */
        root = shm_mnt->mnt_root;
-       dentry = d_alloc(root, &this);
-       if (!dentry)
+       path.dentry = d_alloc(root, &this);
+       if (!path.dentry)
                goto put_memory;
-
-       error = -ENFILE;
-       file = get_empty_filp();
-       if (!file)
-               goto put_dentry;
+       path.mnt = mntget(shm_mnt);
 
        error = -ENOSPC;
        inode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0, flags);
        if (!inode)
-               goto close_file;
+               goto put_dentry;
 
-       d_instantiate(dentry, inode);
+       d_instantiate(path.dentry, inode);
        inode->i_size = size;
        inode->i_nlink = 0;     /* It is unlinked */
-       init_file(file, shm_mnt, dentry, FMODE_WRITE | FMODE_READ,
-                 &shmem_file_operations);
-
 #ifndef CONFIG_MMU
        error = ramfs_nommu_expand_for_mapping(inode, size);
        if (error)
-               goto close_file;
+               goto put_dentry;
 #endif
-       ima_counts_get(file);
+
+       error = -ENFILE;
+       file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
+                 &shmem_file_operations);
+       if (!file)
+               goto put_dentry;
+
        return file;
 
-close_file:
-       put_filp(file);
 put_dentry:
-       dput(dentry);
+       path_put(&path);
 put_memory:
        shmem_unacct_size(flags, size);
        return ERR_PTR(error);
diff --git a/mm/shmem_acl.c b/mm/shmem_acl.c
deleted file mode 100644 (file)
index df2c87f..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * mm/shmem_acl.c
- *
- * (C) 2005 Andreas Gruenbacher <agruen@suse.de>
- *
- * This file is released under the GPL.
- */
-
-#include <linux/fs.h>
-#include <linux/shmem_fs.h>
-#include <linux/xattr.h>
-#include <linux/generic_acl.h>
-
-/**
- * shmem_get_acl  -   generic_acl_operations->getacl() operation
- */
-static struct posix_acl *
-shmem_get_acl(struct inode *inode, int type)
-{
-       struct posix_acl *acl = NULL;
-
-       spin_lock(&inode->i_lock);
-       switch(type) {
-               case ACL_TYPE_ACCESS:
-                       acl = posix_acl_dup(inode->i_acl);
-                       break;
-
-               case ACL_TYPE_DEFAULT:
-                       acl = posix_acl_dup(inode->i_default_acl);
-                       break;
-       }
-       spin_unlock(&inode->i_lock);
-
-       return acl;
-}
-
-/**
- * shmem_set_acl  -   generic_acl_operations->setacl() operation
- */
-static void
-shmem_set_acl(struct inode *inode, int type, struct posix_acl *acl)
-{
-       struct posix_acl *free = NULL;
-
-       spin_lock(&inode->i_lock);
-       switch(type) {
-               case ACL_TYPE_ACCESS:
-                       free = inode->i_acl;
-                       inode->i_acl = posix_acl_dup(acl);
-                       break;
-
-               case ACL_TYPE_DEFAULT:
-                       free = inode->i_default_acl;
-                       inode->i_default_acl = posix_acl_dup(acl);
-                       break;
-       }
-       spin_unlock(&inode->i_lock);
-       posix_acl_release(free);
-}
-
-struct generic_acl_operations shmem_acl_ops = {
-       .getacl = shmem_get_acl,
-       .setacl = shmem_set_acl,
-};
-
-/**
- * shmem_list_acl_access, shmem_get_acl_access, shmem_set_acl_access,
- * shmem_xattr_acl_access_handler  -  plumbing code to implement the
- * system.posix_acl_access xattr using the generic acl functions.
- */
-
-static size_t
-shmem_list_acl_access(struct inode *inode, char *list, size_t list_size,
-                     const char *name, size_t name_len)
-{
-       return generic_acl_list(inode, &shmem_acl_ops, ACL_TYPE_ACCESS,
-                               list, list_size);
-}
-
-static int
-shmem_get_acl_access(struct inode *inode, const char *name, void *buffer,
-                    size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return generic_acl_get(inode, &shmem_acl_ops, ACL_TYPE_ACCESS, buffer,
-                              size);
-}
-
-static int
-shmem_set_acl_access(struct inode *inode, const char *name, const void *value,
-                    size_t size, int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return generic_acl_set(inode, &shmem_acl_ops, ACL_TYPE_ACCESS, value,
-                              size);
-}
-
-struct xattr_handler shmem_xattr_acl_access_handler = {
-       .prefix = POSIX_ACL_XATTR_ACCESS,
-       .list   = shmem_list_acl_access,
-       .get    = shmem_get_acl_access,
-       .set    = shmem_set_acl_access,
-};
-
-/**
- * shmem_list_acl_default, shmem_get_acl_default, shmem_set_acl_default,
- * shmem_xattr_acl_default_handler  -  plumbing code to implement the
- * system.posix_acl_default xattr using the generic acl functions.
- */
-
-static size_t
-shmem_list_acl_default(struct inode *inode, char *list, size_t list_size,
-                      const char *name, size_t name_len)
-{
-       return generic_acl_list(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT,
-                               list, list_size);
-}
-
-static int
-shmem_get_acl_default(struct inode *inode, const char *name, void *buffer,
-                     size_t size)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return generic_acl_get(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT, buffer,
-                              size);
-}
-
-static int
-shmem_set_acl_default(struct inode *inode, const char *name, const void *value,
-                     size_t size, int flags)
-{
-       if (strcmp(name, "") != 0)
-               return -EINVAL;
-       return generic_acl_set(inode, &shmem_acl_ops, ACL_TYPE_DEFAULT, value,
-                              size);
-}
-
-struct xattr_handler shmem_xattr_acl_default_handler = {
-       .prefix = POSIX_ACL_XATTR_DEFAULT,
-       .list   = shmem_list_acl_default,
-       .get    = shmem_get_acl_default,
-       .set    = shmem_set_acl_default,
-};
-
-/**
- * shmem_acl_init  -  Inizialize the acl(s) of a new inode
- */
-int
-shmem_acl_init(struct inode *inode, struct inode *dir)
-{
-       return generic_acl_init(inode, dir, &shmem_acl_ops);
-}
-
-/**
- * shmem_check_acl  -  check_acl() callback for generic_permission()
- */
-int
-shmem_check_acl(struct inode *inode, int mask)
-{
-       struct posix_acl *acl = shmem_get_acl(inode, ACL_TYPE_ACCESS);
-
-       if (acl) {
-               int error = posix_acl_permission(inode, acl, mask);
-               posix_acl_release(acl);
-               return error;
-       }
-       return -EAGAIN;
-}
index 3f4822938f4605f4e6e1cf55f996f812332cd4a6..7451bdacaf18875044ea97ed3d49da8c401d8249 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -654,7 +654,7 @@ static void init_node_lock_keys(int q)
 
                l3 = s->cs_cachep->nodelists[q];
                if (!l3 || OFF_SLAB(s->cs_cachep))
-                       return;
+                       continue;
                lockdep_set_class(&l3->list_lock, &on_slab_l3_key);
                alc = l3->alien;
                /*
@@ -665,7 +665,7 @@ static void init_node_lock_keys(int q)
                 * for alloc_alien_cache,
                 */
                if (!alc || (unsigned long)alc == BAD_ALIEN_MAGIC)
-                       return;
+                       continue;
                for_each_node(r) {
                        if (alc[r])
                                lockdep_set_class(&alc[r]->lock,
@@ -1132,7 +1132,7 @@ static void __cpuinit cpuup_canceled(long cpu)
                if (nc)
                        free_block(cachep, nc->entry, nc->avail, node);
 
-               if (!cpus_empty(*mask)) {
+               if (!cpumask_empty(mask)) {
                        spin_unlock_irq(&l3->list_lock);
                        goto free_array_cache;
                }
@@ -2275,9 +2275,11 @@ kmem_cache_create (const char *name, size_t size, size_t align,
        /*
         * Determine if the slab management is 'on' or 'off' slab.
         * (bootstrapping cannot cope with offslab caches so don't do
-        * it too early on.)
+        * it too early on. Always use on-slab management when
+        * SLAB_NOLEAKTRACE to avoid recursive calls into kmemleak)
         */
-       if ((size >= (PAGE_SIZE >> 3)) && !slab_early_init)
+       if ((size >= (PAGE_SIZE >> 3)) && !slab_early_init &&
+           !(flags & SLAB_NOLEAKTRACE))
                /*
                 * Size is large, assume best to place the slab management obj
                 * off-slab (should allow better packing of objs).
@@ -2596,8 +2598,8 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
                 * kmemleak does not treat the ->s_mem pointer as a reference
                 * to the object. Otherwise we will not report the leak.
                 */
-               kmemleak_scan_area(slabp, offsetof(struct slab, list),
-                                  sizeof(struct list_head), local_flags);
+               kmemleak_scan_area(&slabp->list, sizeof(struct list_head),
+                                  local_flags);
                if (!slabp)
                        return NULL;
        } else {
index 9c590eef79122dc0597dac27912f60e6b7dc6a72..6c0585b16418661529ef1c0399450bf4b9128a45 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/seq_file.h>
 #include <linux/init.h>
 #include <linux/module.h>
+#include <linux/ksm.h>
 #include <linux/rmap.h>
 #include <linux/security.h>
 #include <linux/backing-dev.h>
 #include <linux/swapops.h>
 #include <linux/page_cgroup.h>
 
+static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
+                                unsigned char);
+static void free_swap_count_continuations(struct swap_info_struct *);
+static sector_t map_swap_entry(swp_entry_t, struct block_device**);
+
 static DEFINE_SPINLOCK(swap_lock);
 static unsigned int nr_swapfiles;
 long nr_swap_pages;
 long total_swap_pages;
-static int swap_overflow;
 static int least_priority;
 
 static const char Bad_file[] = "Bad swap file entry ";
@@ -49,42 +54,20 @@ static const char Unused_offset[] = "Unused swap offset entry ";
 
 static struct swap_list_t swap_list = {-1, -1};
 
-static struct swap_info_struct swap_info[MAX_SWAPFILES];
+static struct swap_info_struct *swap_info[MAX_SWAPFILES];
 
 static DEFINE_MUTEX(swapon_mutex);
 
-/* For reference count accounting in swap_map */
-/* enum for swap_map[] handling. internal use only */
-enum {
-       SWAP_MAP = 0,   /* ops for reference from swap users */
-       SWAP_CACHE,     /* ops for reference from swap cache */
-};
-
-static inline int swap_count(unsigned short ent)
-{
-       return ent & SWAP_COUNT_MASK;
-}
-
-static inline bool swap_has_cache(unsigned short ent)
+static inline unsigned char swap_count(unsigned char ent)
 {
-       return !!(ent & SWAP_HAS_CACHE);
+       return ent & ~SWAP_HAS_CACHE;   /* may include SWAP_HAS_CONT flag */
 }
 
-static inline unsigned short encode_swapmap(int count, bool has_cache)
-{
-       unsigned short ret = count;
-
-       if (has_cache)
-               return SWAP_HAS_CACHE | ret;
-       return ret;
-}
-
-/* returnes 1 if swap entry is freed */
+/* returns 1 if swap entry is freed */
 static int
 __try_to_reclaim_swap(struct swap_info_struct *si, unsigned long offset)
 {
-       int type = si - swap_info;
-       swp_entry_t entry = swp_entry(type, offset);
+       swp_entry_t entry = swp_entry(si->type, offset);
        struct page *page;
        int ret = 0;
 
@@ -120,7 +103,7 @@ void swap_unplug_io_fn(struct backing_dev_info *unused_bdi, struct page *page)
        down_read(&swap_unplug_sem);
        entry.val = page_private(page);
        if (PageSwapCache(page)) {
-               struct block_device *bdev = swap_info[swp_type(entry)].bdev;
+               struct block_device *bdev = swap_info[swp_type(entry)]->bdev;
                struct backing_dev_info *bdi;
 
                /*
@@ -146,23 +129,28 @@ void swap_unplug_io_fn(struct backing_dev_info *unused_bdi, struct page *page)
 static int discard_swap(struct swap_info_struct *si)
 {
        struct swap_extent *se;
+       sector_t start_block;
+       sector_t nr_blocks;
        int err = 0;
 
-       list_for_each_entry(se, &si->extent_list, list) {
-               sector_t start_block = se->start_block << (PAGE_SHIFT - 9);
-               sector_t nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9);
+       /* Do not discard the swap header page! */
+       se = &si->first_swap_extent;
+       start_block = (se->start_block + 1) << (PAGE_SHIFT - 9);
+       nr_blocks = ((sector_t)se->nr_pages - 1) << (PAGE_SHIFT - 9);
+       if (nr_blocks) {
+               err = blkdev_issue_discard(si->bdev, start_block,
+                               nr_blocks, GFP_KERNEL, DISCARD_FL_BARRIER);
+               if (err)
+                       return err;
+               cond_resched();
+       }
 
-               if (se->start_page == 0) {
-                       /* Do not discard the swap header page! */
-                       start_block += 1 << (PAGE_SHIFT - 9);
-                       nr_blocks -= 1 << (PAGE_SHIFT - 9);
-                       if (!nr_blocks)
-                               continue;
-               }
+       list_for_each_entry(se, &si->first_swap_extent.list, list) {
+               start_block = se->start_block << (PAGE_SHIFT - 9);
+               nr_blocks = (sector_t)se->nr_pages << (PAGE_SHIFT - 9);
 
                err = blkdev_issue_discard(si->bdev, start_block,
-                                               nr_blocks, GFP_KERNEL,
-                                               DISCARD_FL_BARRIER);
+                               nr_blocks, GFP_KERNEL, DISCARD_FL_BARRIER);
                if (err)
                        break;
 
@@ -201,14 +189,11 @@ static void discard_swap_cluster(struct swap_info_struct *si,
                        start_block <<= PAGE_SHIFT - 9;
                        nr_blocks <<= PAGE_SHIFT - 9;
                        if (blkdev_issue_discard(si->bdev, start_block,
-                                                       nr_blocks, GFP_NOIO,
-                                                       DISCARD_FL_BARRIER))
+                                   nr_blocks, GFP_NOIO, DISCARD_FL_BARRIER))
                                break;
                }
 
                lh = se->list.next;
-               if (lh == &si->extent_list)
-                       lh = lh->next;
                se = list_entry(lh, struct swap_extent, list);
        }
 }
@@ -223,7 +208,7 @@ static int wait_for_discard(void *word)
 #define LATENCY_LIMIT          256
 
 static inline unsigned long scan_swap_map(struct swap_info_struct *si,
-                                         int cache)
+                                         unsigned char usage)
 {
        unsigned long offset;
        unsigned long scan_base;
@@ -354,10 +339,7 @@ checks:
                si->lowest_bit = si->max;
                si->highest_bit = 0;
        }
-       if (cache == SWAP_CACHE) /* at usual swap-out via vmscan.c */
-               si->swap_map[offset] = encode_swapmap(0, true);
-       else /* at suspend */
-               si->swap_map[offset] = encode_swapmap(1, false);
+       si->swap_map[offset] = usage;
        si->cluster_next = offset + 1;
        si->flags -= SWP_SCANNING;
 
@@ -467,10 +449,10 @@ swp_entry_t get_swap_page(void)
        nr_swap_pages--;
 
        for (type = swap_list.next; type >= 0 && wrapped < 2; type = next) {
-               si = swap_info + type;
+               si = swap_info[type];
                next = si->next;
                if (next < 0 ||
-                   (!wrapped && si->prio != swap_info[next].prio)) {
+                   (!wrapped && si->prio != swap_info[next]->prio)) {
                        next = swap_list.head;
                        wrapped++;
                }
@@ -482,7 +464,7 @@ swp_entry_t get_swap_page(void)
 
                swap_list.next = next;
                /* This is called for allocating swap entry for cache */
-               offset = scan_swap_map(si, SWAP_CACHE);
+               offset = scan_swap_map(si, SWAP_HAS_CACHE);
                if (offset) {
                        spin_unlock(&swap_lock);
                        return swp_entry(type, offset);
@@ -503,11 +485,11 @@ swp_entry_t get_swap_page_of_type(int type)
        pgoff_t offset;
 
        spin_lock(&swap_lock);
-       si = swap_info + type;
-       if (si->flags & SWP_WRITEOK) {
+       si = swap_info[type];
+       if (si && (si->flags & SWP_WRITEOK)) {
                nr_swap_pages--;
                /* This is called for allocating swap entry, not cache */
-               offset = scan_swap_map(si, SWAP_MAP);
+               offset = scan_swap_map(si, 1);
                if (offset) {
                        spin_unlock(&swap_lock);
                        return swp_entry(type, offset);
@@ -518,9 +500,9 @@ swp_entry_t get_swap_page_of_type(int type)
        return (swp_entry_t) {0};
 }
 
-static struct swap_info_struct * swap_info_get(swp_entry_t entry)
+static struct swap_info_struct *swap_info_get(swp_entry_t entry)
 {
-       struct swap_info_struct * p;
+       struct swap_info_struct *p;
        unsigned long offset, type;
 
        if (!entry.val)
@@ -528,7 +510,7 @@ static struct swap_info_struct * swap_info_get(swp_entry_t entry)
        type = swp_type(entry);
        if (type >= nr_swapfiles)
                goto bad_nofile;
-       p = swap_info[type];
+       p = swap_info[type];
        if (!(p->flags & SWP_USED))
                goto bad_device;
        offset = swp_offset(entry);
@@ -554,41 +536,56 @@ out:
        return NULL;
 }
 
-static int swap_entry_free(struct swap_info_struct *p,
-                          swp_entry_t ent, int cache)
+static unsigned char swap_entry_free(struct swap_info_struct *p,
+                                    swp_entry_t entry, unsigned char usage)
 {
-       unsigned long offset = swp_offset(ent);
-       int count = swap_count(p->swap_map[offset]);
-       bool has_cache;
+       unsigned long offset = swp_offset(entry);
+       unsigned char count;
+       unsigned char has_cache;
 
-       has_cache = swap_has_cache(p->swap_map[offset]);
+       count = p->swap_map[offset];
+       has_cache = count & SWAP_HAS_CACHE;
+       count &= ~SWAP_HAS_CACHE;
 
-       if (cache == SWAP_MAP) { /* dropping usage count of swap */
-               if (count < SWAP_MAP_MAX) {
-                       count--;
-                       p->swap_map[offset] = encode_swapmap(count, has_cache);
-               }
-       } else { /* dropping swap cache flag */
+       if (usage == SWAP_HAS_CACHE) {
                VM_BUG_ON(!has_cache);
-               p->swap_map[offset] = encode_swapmap(count, false);
-
+               has_cache = 0;
+       } else if (count == SWAP_MAP_SHMEM) {
+               /*
+                * Or we could insist on shmem.c using a special
+                * swap_shmem_free() and free_shmem_swap_and_cache()...
+                */
+               count = 0;
+       } else if ((count & ~COUNT_CONTINUED) <= SWAP_MAP_MAX) {
+               if (count == COUNT_CONTINUED) {
+                       if (swap_count_continued(p, offset, count))
+                               count = SWAP_MAP_MAX | COUNT_CONTINUED;
+                       else
+                               count = SWAP_MAP_MAX;
+               } else
+                       count--;
        }
-       /* return code. */
-       count = p->swap_map[offset];
+
+       if (!count)
+               mem_cgroup_uncharge_swap(entry);
+
+       usage = count | has_cache;
+       p->swap_map[offset] = usage;
+
        /* free if no reference */
-       if (!count) {
+       if (!usage) {
                if (offset < p->lowest_bit)
                        p->lowest_bit = offset;
                if (offset > p->highest_bit)
                        p->highest_bit = offset;
-               if (p->prio > swap_info[swap_list.next].prio)
-                       swap_list.next = p - swap_info;
+               if (swap_list.next >= 0 &&
+                   p->prio > swap_info[swap_list.next]->prio)
+                       swap_list.next = p->type;
                nr_swap_pages++;
                p->inuse_pages--;
        }
-       if (!swap_count(count))
-               mem_cgroup_uncharge_swap(ent);
-       return count;
+
+       return usage;
 }
 
 /*
@@ -597,11 +594,11 @@ static int swap_entry_free(struct swap_info_struct *p,
  */
 void swap_free(swp_entry_t entry)
 {
-       struct swap_info_struct * p;
+       struct swap_info_struct *p;
 
        p = swap_info_get(entry);
        if (p) {
-               swap_entry_free(p, entry, SWAP_MAP);
+               swap_entry_free(p, entry, 1);
                spin_unlock(&swap_lock);
        }
 }
@@ -612,26 +609,21 @@ void swap_free(swp_entry_t entry)
 void swapcache_free(swp_entry_t entry, struct page *page)
 {
        struct swap_info_struct *p;
-       int ret;
+       unsigned char count;
 
        p = swap_info_get(entry);
        if (p) {
-               ret = swap_entry_free(p, entry, SWAP_CACHE);
-               if (page) {
-                       bool swapout;
-                       if (ret)
-                               swapout = true; /* the end of swap out */
-                       else
-                               swapout = false; /* no more swap users! */
-                       mem_cgroup_uncharge_swapcache(page, entry, swapout);
-               }
+               count = swap_entry_free(p, entry, SWAP_HAS_CACHE);
+               if (page)
+                       mem_cgroup_uncharge_swapcache(page, entry, count != 0);
                spin_unlock(&swap_lock);
        }
-       return;
 }
 
 /*
  * How many references to page are currently swapped out?
+ * This does not give an exact answer when swap count is continued,
+ * but does include the high COUNT_CONTINUED flag to allow for that.
  */
 static inline int page_swapcount(struct page *page)
 {
@@ -659,6 +651,8 @@ int reuse_swap_page(struct page *page)
        int count;
 
        VM_BUG_ON(!PageLocked(page));
+       if (unlikely(PageKsm(page)))
+               return 0;
        count = page_mapcount(page);
        if (count <= 1 && PageSwapCache(page)) {
                count += page_swapcount(page);
@@ -667,7 +661,7 @@ int reuse_swap_page(struct page *page)
                        SetPageDirty(page);
                }
        }
-       return count == 1;
+       return count <= 1;
 }
 
 /*
@@ -704,7 +698,7 @@ int free_swap_and_cache(swp_entry_t entry)
 
        p = swap_info_get(entry);
        if (p) {
-               if (swap_entry_free(p, entry, SWAP_MAP) == SWAP_HAS_CACHE) {
+               if (swap_entry_free(p, entry, 1) == SWAP_HAS_CACHE) {
                        page = find_get_page(&swapper_space, entry.val);
                        if (page && !trylock_page(page)) {
                                page_cache_release(page);
@@ -741,14 +735,14 @@ int free_swap_and_cache(swp_entry_t entry)
 int swap_type_of(dev_t device, sector_t offset, struct block_device **bdev_p)
 {
        struct block_device *bdev = NULL;
-       int i;
+       int type;
 
        if (device)
                bdev = bdget(device);
 
        spin_lock(&swap_lock);
-       for (i = 0; i < nr_swapfiles; i++) {
-               struct swap_info_struct *sis = swap_info + i;
+       for (type = 0; type < nr_swapfiles; type++) {
+               struct swap_info_struct *sis = swap_info[type];
 
                if (!(sis->flags & SWP_WRITEOK))
                        continue;
@@ -758,20 +752,18 @@ int swap_type_of(dev_t device, sector_t offset, struct block_device **bdev_p)
                                *bdev_p = bdgrab(sis->bdev);
 
                        spin_unlock(&swap_lock);
-                       return i;
+                       return type;
                }
                if (bdev == sis->bdev) {
-                       struct swap_extent *se;
+                       struct swap_extent *se = &sis->first_swap_extent;
 
-                       se = list_entry(sis->extent_list.next,
-                                       struct swap_extent, list);
                        if (se->start_block == offset) {
                                if (bdev_p)
                                        *bdev_p = bdgrab(sis->bdev);
 
                                spin_unlock(&swap_lock);
                                bdput(bdev);
-                               return i;
+                               return type;
                        }
                }
        }
@@ -782,6 +774,21 @@ int swap_type_of(dev_t device, sector_t offset, struct block_device **bdev_p)
        return -ENODEV;
 }
 
+/*
+ * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
+ * corresponding to given index in swap_info (swap type).
+ */
+sector_t swapdev_block(int type, pgoff_t offset)
+{
+       struct block_device *bdev;
+
+       if ((unsigned int)type >= nr_swapfiles)
+               return 0;
+       if (!(swap_info[type]->flags & SWP_WRITEOK))
+               return 0;
+       return map_swap_entry(swp_entry(type, offset), &bdev);
+}
+
 /*
  * Return either the total number of swap pages of given type, or the number
  * of free pages of that type (depending on @free)
@@ -792,18 +799,20 @@ unsigned int count_swap_pages(int type, int free)
 {
        unsigned int n = 0;
 
-       if (type < nr_swapfiles) {
-               spin_lock(&swap_lock);
-               if (swap_info[type].flags & SWP_WRITEOK) {
-                       n = swap_info[type].pages;
+       spin_lock(&swap_lock);
+       if ((unsigned int)type < nr_swapfiles) {
+               struct swap_info_struct *sis = swap_info[type];
+
+               if (sis->flags & SWP_WRITEOK) {
+                       n = sis->pages;
                        if (free)
-                               n -= swap_info[type].inuse_pages;
+                               n -= sis->inuse_pages;
                }
-               spin_unlock(&swap_lock);
        }
+       spin_unlock(&swap_lock);
        return n;
 }
-#endif
+#endif /* CONFIG_HIBERNATION */
 
 /*
  * No need to decide whether this PTE shares the swap entry with others,
@@ -932,7 +941,7 @@ static int unuse_vma(struct vm_area_struct *vma,
        unsigned long addr, end, next;
        int ret;
 
-       if (page->mapping) {
+       if (page_anon_vma(page)) {
                addr = page_address_in_vma(page, vma);
                if (addr == -EFAULT)
                        return 0;
@@ -988,7 +997,7 @@ static unsigned int find_next_to_unuse(struct swap_info_struct *si,
 {
        unsigned int max = si->max;
        unsigned int i = prev;
-       int count;
+       unsigned char count;
 
        /*
         * No need for swap_lock here: we're just looking
@@ -1024,16 +1033,14 @@ static unsigned int find_next_to_unuse(struct swap_info_struct *si,
  */
 static int try_to_unuse(unsigned int type)
 {
-       struct swap_info_struct * si = &swap_info[type];
+       struct swap_info_struct *si = swap_info[type];
        struct mm_struct *start_mm;
-       unsigned short *swap_map;
-       unsigned short swcount;
+       unsigned char *swap_map;
+       unsigned char swcount;
        struct page *page;
        swp_entry_t entry;
        unsigned int i = 0;
        int retval = 0;
-       int reset_overflow = 0;
-       int shmem;
 
        /*
         * When searching mms for an entry, a good strategy is to
@@ -1047,8 +1054,7 @@ static int try_to_unuse(unsigned int type)
         * together, child after parent.  If we race with dup_mmap(), we
         * prefer to resolve parent before child, lest we miss entries
         * duplicated after we scanned child: using last mm would invert
-        * that.  Though it's only a serious concern when an overflowed
-        * swap count is reset from SWAP_MAP_MAX, preventing a rescan.
+        * that.
         */
        start_mm = &init_mm;
        atomic_inc(&init_mm.mm_users);
@@ -1110,17 +1116,18 @@ static int try_to_unuse(unsigned int type)
 
                /*
                 * Remove all references to entry.
-                * Whenever we reach init_mm, there's no address space
-                * to search, but use it as a reminder to search shmem.
                 */
-               shmem = 0;
                swcount = *swap_map;
-               if (swap_count(swcount)) {
-                       if (start_mm == &init_mm)
-                               shmem = shmem_unuse(entry, page);
-                       else
-                               retval = unuse_mm(start_mm, entry, page);
+               if (swap_count(swcount) == SWAP_MAP_SHMEM) {
+                       retval = shmem_unuse(entry, page);
+                       /* page has already been unlocked and released */
+                       if (retval < 0)
+                               break;
+                       continue;
                }
+               if (swap_count(swcount) && start_mm != &init_mm)
+                       retval = unuse_mm(start_mm, entry, page);
+
                if (swap_count(*swap_map)) {
                        int set_start_mm = (*swap_map >= swcount);
                        struct list_head *p = &start_mm->mmlist;
@@ -1131,7 +1138,7 @@ static int try_to_unuse(unsigned int type)
                        atomic_inc(&new_start_mm->mm_users);
                        atomic_inc(&prev_mm->mm_users);
                        spin_lock(&mmlist_lock);
-                       while (swap_count(*swap_map) && !retval && !shmem &&
+                       while (swap_count(*swap_map) && !retval &&
                                        (p = p->next) != &start_mm->mmlist) {
                                mm = list_entry(p, struct mm_struct, mmlist);
                                if (!atomic_inc_not_zero(&mm->mm_users))
@@ -1145,10 +1152,9 @@ static int try_to_unuse(unsigned int type)
                                swcount = *swap_map;
                                if (!swap_count(swcount)) /* any usage ? */
                                        ;
-                               else if (mm == &init_mm) {
+                               else if (mm == &init_mm)
                                        set_start_mm = 1;
-                                       shmem = shmem_unuse(entry, page);
-                               } else
+                               else
                                        retval = unuse_mm(mm, entry, page);
 
                                if (set_start_mm && *swap_map < swcount) {
@@ -1164,43 +1170,12 @@ static int try_to_unuse(unsigned int type)
                        mmput(start_mm);
                        start_mm = new_start_mm;
                }
-               if (shmem) {
-                       /* page has already been unlocked and released */
-                       if (shmem > 0)
-                               continue;
-                       retval = shmem;
-                       break;
-               }
                if (retval) {
                        unlock_page(page);
                        page_cache_release(page);
                        break;
                }
 
-               /*
-                * How could swap count reach 0x7ffe ?
-                * There's no way to repeat a swap page within an mm
-                * (except in shmem, where it's the shared object which takes
-                * the reference count)?
-                * We believe SWAP_MAP_MAX cannot occur.(if occur, unsigned
-                * short is too small....)
-                * If that's wrong, then we should worry more about
-                * exit_mmap() and do_munmap() cases described above:
-                * we might be resetting SWAP_MAP_MAX too early here.
-                * We know "Undead"s can happen, they're okay, so don't
-                * report them; but do report if we reset SWAP_MAP_MAX.
-                */
-               /* We might release the lock_page() in unuse_mm(). */
-               if (!PageSwapCache(page) || page_private(page) != entry.val)
-                       goto retry;
-
-               if (swap_count(*swap_map) == SWAP_MAP_MAX) {
-                       spin_lock(&swap_lock);
-                       *swap_map = encode_swapmap(0, true);
-                       spin_unlock(&swap_lock);
-                       reset_overflow = 1;
-               }
-
                /*
                 * If a reference remains (rare), we would like to leave
                 * the page in the swap cache; but try_to_unmap could
@@ -1213,6 +1188,12 @@ static int try_to_unuse(unsigned int type)
                 * read from disk into another page.  Splitting into two
                 * pages would be incorrect if swap supported "shared
                 * private" pages, but they are handled by tmpfs files.
+                *
+                * Given how unuse_vma() targets one particular offset
+                * in an anon_vma, once the anon_vma has been determined,
+                * this splitting happens to be just what is needed to
+                * handle where KSM pages have been swapped out: re-reading
+                * is unnecessarily slow, but we can fix that later on.
                 */
                if (swap_count(*swap_map) &&
                     PageDirty(page) && PageSwapCache(page)) {
@@ -1242,7 +1223,6 @@ static int try_to_unuse(unsigned int type)
                 * mark page dirty so shrink_page_list will preserve it.
                 */
                SetPageDirty(page);
-retry:
                unlock_page(page);
                page_cache_release(page);
 
@@ -1254,10 +1234,6 @@ retry:
        }
 
        mmput(start_mm);
-       if (reset_overflow) {
-               printk(KERN_WARNING "swapoff: cleared swap entry overflow\n");
-               swap_overflow = 0;
-       }
        return retval;
 }
 
@@ -1270,10 +1246,10 @@ retry:
 static void drain_mmlist(void)
 {
        struct list_head *p, *next;
-       unsigned int i;
+       unsigned int type;
 
-       for (i = 0; i < nr_swapfiles; i++)
-               if (swap_info[i].inuse_pages)
+       for (type = 0; type < nr_swapfiles; type++)
+               if (swap_info[type]->inuse_pages)
                        return;
        spin_lock(&mmlist_lock);
        list_for_each_safe(p, next, &init_mm.mmlist)
@@ -1283,12 +1259,23 @@ static void drain_mmlist(void)
 
 /*
  * Use this swapdev's extent info to locate the (PAGE_SIZE) block which
- * corresponds to page offset `offset'.
+ * corresponds to page offset for the specified swap entry.
+ * Note that the type of this function is sector_t, but it returns page offset
+ * into the bdev, not sector offset.
  */
-sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
+static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev)
 {
-       struct swap_extent *se = sis->curr_swap_extent;
-       struct swap_extent *start_se = se;
+       struct swap_info_struct *sis;
+       struct swap_extent *start_se;
+       struct swap_extent *se;
+       pgoff_t offset;
+
+       sis = swap_info[swp_type(entry)];
+       *bdev = sis->bdev;
+
+       offset = swp_offset(entry);
+       start_se = sis->curr_swap_extent;
+       se = start_se;
 
        for ( ; ; ) {
                struct list_head *lh;
@@ -1298,40 +1285,31 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
                        return se->start_block + (offset - se->start_page);
                }
                lh = se->list.next;
-               if (lh == &sis->extent_list)
-                       lh = lh->next;
                se = list_entry(lh, struct swap_extent, list);
                sis->curr_swap_extent = se;
                BUG_ON(se == start_se);         /* It *must* be present */
        }
 }
 
-#ifdef CONFIG_HIBERNATION
 /*
- * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
- * corresponding to given index in swap_info (swap type).
+ * Returns the page offset into bdev for the specified page's swap entry.
  */
-sector_t swapdev_block(int swap_type, pgoff_t offset)
+sector_t map_swap_page(struct page *page, struct block_device **bdev)
 {
-       struct swap_info_struct *sis;
-
-       if (swap_type >= nr_swapfiles)
-               return 0;
-
-       sis = swap_info + swap_type;
-       return (sis->flags & SWP_WRITEOK) ? map_swap_page(sis, offset) : 0;
+       swp_entry_t entry;
+       entry.val = page_private(page);
+       return map_swap_entry(entry, bdev);
 }
-#endif /* CONFIG_HIBERNATION */
 
 /*
  * Free all of a swapdev's extent information
  */
 static void destroy_swap_extents(struct swap_info_struct *sis)
 {
-       while (!list_empty(&sis->extent_list)) {
+       while (!list_empty(&sis->first_swap_extent.list)) {
                struct swap_extent *se;
 
-               se = list_entry(sis->extent_list.next,
+               se = list_entry(sis->first_swap_extent.list.next,
                                struct swap_extent, list);
                list_del(&se->list);
                kfree(se);
@@ -1352,8 +1330,15 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
        struct swap_extent *new_se;
        struct list_head *lh;
 
-       lh = sis->extent_list.prev;     /* The highest page extent */
-       if (lh != &sis->extent_list) {
+       if (start_page == 0) {
+               se = &sis->first_swap_extent;
+               sis->curr_swap_extent = se;
+               se->start_page = 0;
+               se->nr_pages = nr_pages;
+               se->start_block = start_block;
+               return 1;
+       } else {
+               lh = sis->first_swap_extent.list.prev;  /* Highest extent */
                se = list_entry(lh, struct swap_extent, list);
                BUG_ON(se->start_page + se->nr_pages != start_page);
                if (se->start_block + se->nr_pages == start_block) {
@@ -1373,7 +1358,7 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
        new_se->nr_pages = nr_pages;
        new_se->start_block = start_block;
 
-       list_add_tail(&new_se->list, &sis->extent_list);
+       list_add_tail(&new_se->list, &sis->first_swap_extent.list);
        return 1;
 }
 
@@ -1425,7 +1410,7 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
        if (S_ISBLK(inode->i_mode)) {
                ret = add_swap_extent(sis, 0, sis->max, 0);
                *span = sis->pages;
-               goto done;
+               goto out;
        }
 
        blkbits = inode->i_blkbits;
@@ -1496,25 +1481,22 @@ reprobe:
        sis->max = page_no;
        sis->pages = page_no - 1;
        sis->highest_bit = page_no - 1;
-done:
-       sis->curr_swap_extent = list_entry(sis->extent_list.prev,
-                                       struct swap_extent, list);
-       goto out;
+out:
+       return ret;
 bad_bmap:
        printk(KERN_ERR "swapon: swapfile has holes\n");
        ret = -EINVAL;
-out:
-       return ret;
+       goto out;
 }
 
 SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
 {
-       struct swap_info_struct * p = NULL;
-       unsigned short *swap_map;
+       struct swap_info_struct *p = NULL;
+       unsigned char *swap_map;
        struct file *swap_file, *victim;
        struct address_space *mapping;
        struct inode *inode;
-       char * pathname;
+       char *pathname;
        int i, type, prev;
        int err;
 
@@ -1535,8 +1517,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
        mapping = victim->f_mapping;
        prev = -1;
        spin_lock(&swap_lock);
-       for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
-               p = swap_info + type;
+       for (type = swap_list.head; type >= 0; type = swap_info[type]->next) {
+               p = swap_info[type];
                if (p->flags & SWP_WRITEOK) {
                        if (p->swap_file->f_mapping == mapping)
                                break;
@@ -1555,18 +1537,17 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
                spin_unlock(&swap_lock);
                goto out_dput;
        }
-       if (prev < 0) {
+       if (prev < 0)
                swap_list.head = p->next;
-       } else {
-               swap_info[prev].next = p->next;
-       }
+       else
+               swap_info[prev]->next = p->next;
        if (type == swap_list.next) {
                /* just pick something that's safe... */
                swap_list.next = swap_list.head;
        }
        if (p->prio < 0) {
-               for (i = p->next; i >= 0; i = swap_info[i].next)
-                       swap_info[i].prio = p->prio--;
+               for (i = p->next; i >= 0; i = swap_info[i]->next)
+                       swap_info[i]->prio = p->prio--;
                least_priority++;
        }
        nr_swap_pages -= p->pages;
@@ -1584,16 +1565,16 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
                if (p->prio < 0)
                        p->prio = --least_priority;
                prev = -1;
-               for (i = swap_list.head; i >= 0; i = swap_info[i].next) {
-                       if (p->prio >= swap_info[i].prio)
+               for (i = swap_list.head; i >= 0; i = swap_info[i]->next) {
+                       if (p->prio >= swap_info[i]->prio)
                                break;
                        prev = i;
                }
                p->next = i;
                if (prev < 0)
-                       swap_list.head = swap_list.next = p - swap_info;
+                       swap_list.head = swap_list.next = type;
                else
-                       swap_info[prev].next = p - swap_info;
+                       swap_info[prev]->next = type;
                nr_swap_pages += p->pages;
                total_swap_pages += p->pages;
                p->flags |= SWP_WRITEOK;
@@ -1606,6 +1587,9 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
        up_write(&swap_unplug_sem);
 
        destroy_swap_extents(p);
+       if (p->flags & SWP_CONTINUED)
+               free_swap_count_continuations(p);
+
        mutex_lock(&swapon_mutex);
        spin_lock(&swap_lock);
        drain_mmlist();
@@ -1653,8 +1637,8 @@ out:
 /* iterator */
 static void *swap_start(struct seq_file *swap, loff_t *pos)
 {
-       struct swap_info_struct *ptr = swap_info;
-       int i;
+       struct swap_info_struct *si;
+       int type;
        loff_t l = *pos;
 
        mutex_lock(&swapon_mutex);
@@ -1662,11 +1646,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
        if (!l)
                return SEQ_START_TOKEN;
 
-       for (i = 0; i < nr_swapfiles; i++, ptr++) {
-               if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
+       for (type = 0; type < nr_swapfiles; type++) {
+               smp_rmb();      /* read nr_swapfiles before swap_info[type] */
+               si = swap_info[type];
+               if (!(si->flags & SWP_USED) || !si->swap_map)
                        continue;
                if (!--l)
-                       return ptr;
+                       return si;
        }
 
        return NULL;
@@ -1674,21 +1660,21 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
 
 static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
 {
-       struct swap_info_struct *ptr;
-       struct swap_info_struct *endptr = swap_info + nr_swapfiles;
+       struct swap_info_struct *si = v;
+       int type;
 
        if (v == SEQ_START_TOKEN)
-               ptr = swap_info;
-       else {
-               ptr = v;
-               ptr++;
-       }
+               type = 0;
+       else
+               type = si->type + 1;
 
-       for (; ptr < endptr; ptr++) {
-               if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
+       for (; type < nr_swapfiles; type++) {
+               smp_rmb();      /* read nr_swapfiles before swap_info[type] */
+               si = swap_info[type];
+               if (!(si->flags & SWP_USED) || !si->swap_map)
                        continue;
                ++*pos;
-               return ptr;
+               return si;
        }
 
        return NULL;
@@ -1701,24 +1687,24 @@ static void swap_stop(struct seq_file *swap, void *v)
 
 static int swap_show(struct seq_file *swap, void *v)
 {
-       struct swap_info_struct *ptr = v;
+       struct swap_info_struct *si = v;
        struct file *file;
        int len;
 
-       if (ptr == SEQ_START_TOKEN) {
+       if (si == SEQ_START_TOKEN) {
                seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
                return 0;
        }
 
-       file = ptr->swap_file;
+       file = si->swap_file;
        len = seq_path(swap, &file->f_path, " \t\n\\");
        seq_printf(swap, "%*s%s\t%u\t%u\t%d\n",
                        len < 40 ? 40 - len : 1, " ",
                        S_ISBLK(file->f_path.dentry->d_inode->i_mode) ?
                                "partition" : "file\t",
-                       ptr->pages << (PAGE_SHIFT - 10),
-                       ptr->inuse_pages << (PAGE_SHIFT - 10),
-                       ptr->prio);
+                       si->pages << (PAGE_SHIFT - 10),
+                       si->inuse_pages << (PAGE_SHIFT - 10),
+                       si->prio);
        return 0;
 }
 
@@ -1765,7 +1751,7 @@ late_initcall(max_swapfiles_check);
  */
 SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 {
-       struct swap_info_struct * p;
+       struct swap_info_struct *p;
        char *name = NULL;
        struct block_device *bdev = NULL;
        struct file *swap_file = NULL;
@@ -1779,30 +1765,52 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
        sector_t span;
        unsigned long maxpages = 1;
        unsigned long swapfilepages;
-       unsigned short *swap_map = NULL;
+       unsigned char *swap_map = NULL;
        struct page *page = NULL;
        struct inode *inode = NULL;
        int did_down = 0;
 
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
+
+       p = kzalloc(sizeof(*p), GFP_KERNEL);
+       if (!p)
+               return -ENOMEM;
+
        spin_lock(&swap_lock);
-       p = swap_info;
-       for (type = 0 ; type < nr_swapfiles ; type++,p++)
-               if (!(p->flags & SWP_USED))
+       for (type = 0; type < nr_swapfiles; type++) {
+               if (!(swap_info[type]->flags & SWP_USED))
                        break;
+       }
        error = -EPERM;
        if (type >= MAX_SWAPFILES) {
                spin_unlock(&swap_lock);
+               kfree(p);
                goto out;
        }
-       if (type >= nr_swapfiles)
-               nr_swapfiles = type+1;
-       memset(p, 0, sizeof(*p));
-       INIT_LIST_HEAD(&p->extent_list);
+       if (type >= nr_swapfiles) {
+               p->type = type;
+               swap_info[type] = p;
+               /*
+                * Write swap_info[type] before nr_swapfiles, in case a
+                * racing procfs swap_start() or swap_next() is reading them.
+                * (We never shrink nr_swapfiles, we never free this entry.)
+                */
+               smp_wmb();
+               nr_swapfiles++;
+       } else {
+               kfree(p);
+               p = swap_info[type];
+               /*
+                * Do not memset this entry: a racing procfs swap_next()
+                * would be relying on p->type to remain valid.
+                */
+       }
+       INIT_LIST_HEAD(&p->first_swap_extent.list);
        p->flags = SWP_USED;
        p->next = -1;
        spin_unlock(&swap_lock);
+
        name = getname(specialfile);
        error = PTR_ERR(name);
        if (IS_ERR(name)) {
@@ -1822,7 +1830,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 
        error = -EBUSY;
        for (i = 0; i < nr_swapfiles; i++) {
-               struct swap_info_struct *q = &swap_info[i];
+               struct swap_info_struct *q = swap_info[i];
 
                if (i == type || !q->swap_file)
                        continue;
@@ -1897,6 +1905,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 
        p->lowest_bit  = 1;
        p->cluster_next = 1;
+       p->cluster_nr = 0;
 
        /*
         * Find out how many pages are allowed for a single swap
@@ -1932,13 +1941,13 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
                goto bad_swap;
 
        /* OK, set up the swap map and apply the bad block list */
-       swap_map = vmalloc(maxpages * sizeof(short));
+       swap_map = vmalloc(maxpages);
        if (!swap_map) {
                error = -ENOMEM;
                goto bad_swap;
        }
 
-       memset(swap_map, 0, maxpages * sizeof(short));
+       memset(swap_map, 0, maxpages);
        for (i = 0; i < swap_header->info.nr_badpages; i++) {
                int page_nr = swap_header->info.badpages[i];
                if (page_nr <= 0 || page_nr >= swap_header->info.last_page) {
@@ -2003,18 +2012,16 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
 
        /* insert swap space into swap_list: */
        prev = -1;
-       for (i = swap_list.head; i >= 0; i = swap_info[i].next) {
-               if (p->prio >= swap_info[i].prio) {
+       for (i = swap_list.head; i >= 0; i = swap_info[i]->next) {
+               if (p->prio >= swap_info[i]->prio)
                        break;
-               }
                prev = i;
        }
        p->next = i;
-       if (prev < 0) {
-               swap_list.head = swap_list.next = p - swap_info;
-       } else {
-               swap_info[prev].next = p - swap_info;
-       }
+       if (prev < 0)
+               swap_list.head = swap_list.next = type;
+       else
+               swap_info[prev]->next = type;
        spin_unlock(&swap_lock);
        mutex_unlock(&swapon_mutex);
        error = 0;
@@ -2051,15 +2058,15 @@ out:
 
 void si_swapinfo(struct sysinfo *val)
 {
-       unsigned int i;
+       unsigned int type;
        unsigned long nr_to_be_unused = 0;
 
        spin_lock(&swap_lock);
-       for (i = 0; i < nr_swapfiles; i++) {
-               if (!(swap_info[i].flags & SWP_USED) ||
-                    (swap_info[i].flags & SWP_WRITEOK))
-                       continue;
-               nr_to_be_unused += swap_info[i].inuse_pages;
+       for (type = 0; type < nr_swapfiles; type++) {
+               struct swap_info_struct *si = swap_info[type];
+
+               if ((si->flags & SWP_USED) && !(si->flags & SWP_WRITEOK))
+                       nr_to_be_unused += si->inuse_pages;
        }
        val->freeswap = nr_swap_pages + nr_to_be_unused;
        val->totalswap = total_swap_pages + nr_to_be_unused;
@@ -2069,101 +2076,107 @@ void si_swapinfo(struct sysinfo *val)
 /*
  * Verify that a swap entry is valid and increment its swap map count.
  *
- * Note: if swap_map[] reaches SWAP_MAP_MAX the entries are treated as
- * "permanent", but will be reclaimed by the next swapoff.
  * Returns error code in following case.
  * - success -> 0
  * - swp_entry is invalid -> EINVAL
  * - swp_entry is migration entry -> EINVAL
  * - swap-cache reference is requested but there is already one. -> EEXIST
  * - swap-cache reference is requested but the entry is not used. -> ENOENT
+ * - swap-mapped reference requested but needs continued swap count. -> ENOMEM
  */
-static int __swap_duplicate(swp_entry_t entry, bool cache)
+static int __swap_duplicate(swp_entry_t entry, unsigned char usage)
 {
-       struct swap_info_struct * p;
+       struct swap_info_struct *p;
        unsigned long offset, type;
-       int result = -EINVAL;
-       int count;
-       bool has_cache;
+       unsigned char count;
+       unsigned char has_cache;
+       int err = -EINVAL;
 
        if (non_swap_entry(entry))
-               return -EINVAL;
+               goto out;
 
        type = swp_type(entry);
        if (type >= nr_swapfiles)
                goto bad_file;
-       p = type + swap_info;
+       p = swap_info[type];
        offset = swp_offset(entry);
 
        spin_lock(&swap_lock);
-
        if (unlikely(offset >= p->max))
                goto unlock_out;
 
-       count = swap_count(p->swap_map[offset]);
-       has_cache = swap_has_cache(p->swap_map[offset]);
+       count = p->swap_map[offset];
+       has_cache = count & SWAP_HAS_CACHE;
+       count &= ~SWAP_HAS_CACHE;
+       err = 0;
 
-       if (cache == SWAP_CACHE) { /* called for swapcache/swapin-readahead */
+       if (usage == SWAP_HAS_CACHE) {
 
                /* set SWAP_HAS_CACHE if there is no cache and entry is used */
-               if (!has_cache && count) {
-                       p->swap_map[offset] = encode_swapmap(count, true);
-                       result = 0;
-               } else if (has_cache) /* someone added cache */
-                       result = -EEXIST;
-               else if (!count) /* no users */
-                       result = -ENOENT;
+               if (!has_cache && count)
+                       has_cache = SWAP_HAS_CACHE;
+               else if (has_cache)             /* someone else added cache */
+                       err = -EEXIST;
+               else                            /* no users remaining */
+                       err = -ENOENT;
 
        } else if (count || has_cache) {
-               if (count < SWAP_MAP_MAX - 1) {
-                       p->swap_map[offset] = encode_swapmap(count + 1,
-                                                            has_cache);
-                       result = 0;
-               } else if (count <= SWAP_MAP_MAX) {
-                       if (swap_overflow++ < 5)
-                               printk(KERN_WARNING
-                                      "swap_dup: swap entry overflow\n");
-                       p->swap_map[offset] = encode_swapmap(SWAP_MAP_MAX,
-                                                             has_cache);
-                       result = 0;
-               }
+
+               if ((count & ~COUNT_CONTINUED) < SWAP_MAP_MAX)
+                       count += usage;
+               else if ((count & ~COUNT_CONTINUED) > SWAP_MAP_MAX)
+                       err = -EINVAL;
+               else if (swap_count_continued(p, offset, count))
+                       count = COUNT_CONTINUED;
+               else
+                       err = -ENOMEM;
        } else
-               result = -ENOENT; /* unused swap entry */
+               err = -ENOENT;                  /* unused swap entry */
+
+       p->swap_map[offset] = count | has_cache;
+
 unlock_out:
        spin_unlock(&swap_lock);
 out:
-       return result;
+       return err;
 
 bad_file:
        printk(KERN_ERR "swap_dup: %s%08lx\n", Bad_file, entry.val);
        goto out;
 }
+
+/*
+ * Help swapoff by noting that swap entry belongs to shmem/tmpfs
+ * (in which case its reference count is never incremented).
+ */
+void swap_shmem_alloc(swp_entry_t entry)
+{
+       __swap_duplicate(entry, SWAP_MAP_SHMEM);
+}
+
 /*
  * increase reference count of swap entry by 1.
  */
-void swap_duplicate(swp_entry_t entry)
+int swap_duplicate(swp_entry_t entry)
 {
-       __swap_duplicate(entry, SWAP_MAP);
+       int err = 0;
+
+       while (!err && __swap_duplicate(entry, 1) == -ENOMEM)
+               err = add_swap_count_continuation(entry, GFP_ATOMIC);
+       return err;
 }
 
 /*
  * @entry: swap entry for which we allocate swap cache.
  *
- * Called when allocating swap cache for exising swap entry,
+ * Called when allocating swap cache for existing swap entry,
  * This can return error codes. Returns 0 at success.
  * -EBUSY means there is a swap cache.
  * Note: return code is different from swap_duplicate().
  */
 int swapcache_prepare(swp_entry_t entry)
 {
-       return __swap_duplicate(entry, SWAP_CACHE);
-}
-
-
-struct swap_info_struct *
-get_swap_info_struct(unsigned type)
-{
-       return &swap_info[type];
+       return __swap_duplicate(entry, SWAP_HAS_CACHE);
 }
 
 /*
@@ -2181,7 +2194,7 @@ int valid_swaphandles(swp_entry_t entry, unsigned long *offset)
        if (!our_page_cluster)  /* no readahead */
                return 0;
 
-       si = &swap_info[swp_type(entry)];
+       si = swap_info[swp_type(entry)];
        target = swp_offset(entry);
        base = (target >> our_page_cluster) << our_page_cluster;
        end = base + (1 << our_page_cluster);
@@ -2217,3 +2230,219 @@ int valid_swaphandles(swp_entry_t entry, unsigned long *offset)
        *offset = ++toff;
        return nr_pages? ++nr_pages: 0;
 }
+
+/*
+ * add_swap_count_continuation - called when a swap count is duplicated
+ * beyond SWAP_MAP_MAX, it allocates a new page and links that to the entry's
+ * page of the original vmalloc'ed swap_map, to hold the continuation count
+ * (for that entry and for its neighbouring PAGE_SIZE swap entries).  Called
+ * again when count is duplicated beyond SWAP_MAP_MAX * SWAP_CONT_MAX, etc.
+ *
+ * These continuation pages are seldom referenced: the common paths all work
+ * on the original swap_map, only referring to a continuation page when the
+ * low "digit" of a count is incremented or decremented through SWAP_MAP_MAX.
+ *
+ * add_swap_count_continuation(, GFP_ATOMIC) can be called while holding
+ * page table locks; if it fails, add_swap_count_continuation(, GFP_KERNEL)
+ * can be called after dropping locks.
+ */
+int add_swap_count_continuation(swp_entry_t entry, gfp_t gfp_mask)
+{
+       struct swap_info_struct *si;
+       struct page *head;
+       struct page *page;
+       struct page *list_page;
+       pgoff_t offset;
+       unsigned char count;
+
+       /*
+        * When debugging, it's easier to use __GFP_ZERO here; but it's better
+        * for latency not to zero a page while GFP_ATOMIC and holding locks.
+        */
+       page = alloc_page(gfp_mask | __GFP_HIGHMEM);
+
+       si = swap_info_get(entry);
+       if (!si) {
+               /*
+                * An acceptable race has occurred since the failing
+                * __swap_duplicate(): the swap entry has been freed,
+                * perhaps even the whole swap_map cleared for swapoff.
+                */
+               goto outer;
+       }
+
+       offset = swp_offset(entry);
+       count = si->swap_map[offset] & ~SWAP_HAS_CACHE;
+
+       if ((count & ~COUNT_CONTINUED) != SWAP_MAP_MAX) {
+               /*
+                * The higher the swap count, the more likely it is that tasks
+                * will race to add swap count continuation: we need to avoid
+                * over-provisioning.
+                */
+               goto out;
+       }
+
+       if (!page) {
+               spin_unlock(&swap_lock);
+               return -ENOMEM;
+       }
+
+       /*
+        * We are fortunate that although vmalloc_to_page uses pte_offset_map,
+        * no architecture is using highmem pages for kernel pagetables: so it
+        * will not corrupt the GFP_ATOMIC caller's atomic pagetable kmaps.
+        */
+       head = vmalloc_to_page(si->swap_map + offset);
+       offset &= ~PAGE_MASK;
+
+       /*
+        * Page allocation does not initialize the page's lru field,
+        * but it does always reset its private field.
+        */
+       if (!page_private(head)) {
+               BUG_ON(count & COUNT_CONTINUED);
+               INIT_LIST_HEAD(&head->lru);
+               set_page_private(head, SWP_CONTINUED);
+               si->flags |= SWP_CONTINUED;
+       }
+
+       list_for_each_entry(list_page, &head->lru, lru) {
+               unsigned char *map;
+
+               /*
+                * If the previous map said no continuation, but we've found
+                * a continuation page, free our allocation and use this one.
+                */
+               if (!(count & COUNT_CONTINUED))
+                       goto out;
+
+               map = kmap_atomic(list_page, KM_USER0) + offset;
+               count = *map;
+               kunmap_atomic(map, KM_USER0);
+
+               /*
+                * If this continuation count now has some space in it,
+                * free our allocation and use this one.
+                */
+               if ((count & ~COUNT_CONTINUED) != SWAP_CONT_MAX)
+                       goto out;
+       }
+
+       list_add_tail(&page->lru, &head->lru);
+       page = NULL;                    /* now it's attached, don't free it */
+out:
+       spin_unlock(&swap_lock);
+outer:
+       if (page)
+               __free_page(page);
+       return 0;
+}
+
+/*
+ * swap_count_continued - when the original swap_map count is incremented
+ * from SWAP_MAP_MAX, check if there is already a continuation page to carry
+ * into, carry if so, or else fail until a new continuation page is allocated;
+ * when the original swap_map count is decremented from 0 with continuation,
+ * borrow from the continuation and report whether it still holds more.
+ * Called while __swap_duplicate() or swap_entry_free() holds swap_lock.
+ */
+static bool swap_count_continued(struct swap_info_struct *si,
+                                pgoff_t offset, unsigned char count)
+{
+       struct page *head;
+       struct page *page;
+       unsigned char *map;
+
+       head = vmalloc_to_page(si->swap_map + offset);
+       if (page_private(head) != SWP_CONTINUED) {
+               BUG_ON(count & COUNT_CONTINUED);
+               return false;           /* need to add count continuation */
+       }
+
+       offset &= ~PAGE_MASK;
+       page = list_entry(head->lru.next, struct page, lru);
+       map = kmap_atomic(page, KM_USER0) + offset;
+
+       if (count == SWAP_MAP_MAX)      /* initial increment from swap_map */
+               goto init_map;          /* jump over SWAP_CONT_MAX checks */
+
+       if (count == (SWAP_MAP_MAX | COUNT_CONTINUED)) { /* incrementing */
+               /*
+                * Think of how you add 1 to 999
+                */
+               while (*map == (SWAP_CONT_MAX | COUNT_CONTINUED)) {
+                       kunmap_atomic(map, KM_USER0);
+                       page = list_entry(page->lru.next, struct page, lru);
+                       BUG_ON(page == head);
+                       map = kmap_atomic(page, KM_USER0) + offset;
+               }
+               if (*map == SWAP_CONT_MAX) {
+                       kunmap_atomic(map, KM_USER0);
+                       page = list_entry(page->lru.next, struct page, lru);
+                       if (page == head)
+                               return false;   /* add count continuation */
+                       map = kmap_atomic(page, KM_USER0) + offset;
+init_map:              *map = 0;               /* we didn't zero the page */
+               }
+               *map += 1;
+               kunmap_atomic(map, KM_USER0);
+               page = list_entry(page->lru.prev, struct page, lru);
+               while (page != head) {
+                       map = kmap_atomic(page, KM_USER0) + offset;
+                       *map = COUNT_CONTINUED;
+                       kunmap_atomic(map, KM_USER0);
+                       page = list_entry(page->lru.prev, struct page, lru);
+               }
+               return true;                    /* incremented */
+
+       } else {                                /* decrementing */
+               /*
+                * Think of how you subtract 1 from 1000
+                */
+               BUG_ON(count != COUNT_CONTINUED);
+               while (*map == COUNT_CONTINUED) {
+                       kunmap_atomic(map, KM_USER0);
+                       page = list_entry(page->lru.next, struct page, lru);
+                       BUG_ON(page == head);
+                       map = kmap_atomic(page, KM_USER0) + offset;
+               }
+               BUG_ON(*map == 0);
+               *map -= 1;
+               if (*map == 0)
+                       count = 0;
+               kunmap_atomic(map, KM_USER0);
+               page = list_entry(page->lru.prev, struct page, lru);
+               while (page != head) {
+                       map = kmap_atomic(page, KM_USER0) + offset;
+                       *map = SWAP_CONT_MAX | count;
+                       count = COUNT_CONTINUED;
+                       kunmap_atomic(map, KM_USER0);
+                       page = list_entry(page->lru.prev, struct page, lru);
+               }
+               return count == COUNT_CONTINUED;
+       }
+}
+
+/*
+ * free_swap_count_continuations - swapoff free all the continuation pages
+ * appended to the swap_map, after swap_map is quiesced, before vfree'ing it.
+ */
+static void free_swap_count_continuations(struct swap_info_struct *si)
+{
+       pgoff_t offset;
+
+       for (offset = 0; offset < si->max; offset += PAGE_SIZE) {
+               struct page *head;
+               head = vmalloc_to_page(si->swap_map + offset);
+               if (page_private(head)) {
+                       struct list_head *this, *next;
+                       list_for_each_safe(this, next, &head->lru) {
+                               struct page *page;
+                               page = list_entry(this, struct page, lru);
+                               list_del(this);
+                               __free_page(page);
+                       }
+               }
+       }
+}
index 2c147a7e5f2ce7e882e8510d7a1f2088d7f7380a..342deee22684ffdfded563506d684ef0f2b18191 100644 (file)
@@ -272,6 +272,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
                        pagevec_release(&pvec);
                        break;
                }
+               mem_cgroup_uncharge_start();
                for (i = 0; i < pagevec_count(&pvec); i++) {
                        struct page *page = pvec.pages[i];
 
@@ -286,6 +287,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
                        unlock_page(page);
                }
                pagevec_release(&pvec);
+               mem_cgroup_uncharge_end();
        }
 }
 EXPORT_SYMBOL(truncate_inode_pages_range);
@@ -327,6 +329,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
        pagevec_init(&pvec, 0);
        while (next <= end &&
                        pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) {
+               mem_cgroup_uncharge_start();
                for (i = 0; i < pagevec_count(&pvec); i++) {
                        struct page *page = pvec.pages[i];
                        pgoff_t index;
@@ -354,6 +357,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
                                break;
                }
                pagevec_release(&pvec);
+               mem_cgroup_uncharge_end();
                cond_resched();
        }
        return ret;
@@ -428,6 +432,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
        while (next <= end && !wrapped &&
                pagevec_lookup(&pvec, mapping, next,
                        min(end - next, (pgoff_t)PAGEVEC_SIZE - 1) + 1)) {
+               mem_cgroup_uncharge_start();
                for (i = 0; i < pagevec_count(&pvec); i++) {
                        struct page *page = pvec.pages[i];
                        pgoff_t page_index;
@@ -477,6 +482,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
                        unlock_page(page);
                }
                pagevec_release(&pvec);
+               mem_cgroup_uncharge_end();
                cond_resched();
        }
        return ret;
index b377ce43080312411a8910ea21a5f2867a7c7007..7c35ad95f92756d1473bbc2ae658f5bb27de2ca9 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -4,10 +4,6 @@
 #include <linux/module.h>
 #include <linux/err.h>
 #include <linux/sched.h>
-#include <linux/hugetlb.h>
-#include <linux/syscalls.h>
-#include <linux/mman.h>
-#include <linux/file.h>
 #include <asm/uaccess.h>
 
 #define CREATE_TRACE_POINTS
@@ -272,46 +268,6 @@ int __attribute__((weak)) get_user_pages_fast(unsigned long start,
 }
 EXPORT_SYMBOL_GPL(get_user_pages_fast);
 
-SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
-               unsigned long, prot, unsigned long, flags,
-               unsigned long, fd, unsigned long, pgoff)
-{
-       struct file * file = NULL;
-       unsigned long retval = -EBADF;
-
-       if (!(flags & MAP_ANONYMOUS)) {
-               if (unlikely(flags & MAP_HUGETLB))
-                       return -EINVAL;
-               file = fget(fd);
-               if (!file)
-                       goto out;
-       } else if (flags & MAP_HUGETLB) {
-               struct user_struct *user = NULL;
-               /*
-                * VM_NORESERVE is used because the reservations will be
-                * taken when vm_ops->mmap() is called
-                * A dummy user value is used because we are not locking
-                * memory so no accounting is necessary
-                */
-               len = ALIGN(len, huge_page_size(&default_hstate));
-               file = hugetlb_file_setup(HUGETLB_ANON_FILE, len, VM_NORESERVE,
-                                               &user, HUGETLB_ANONHUGE_INODE);
-               if (IS_ERR(file))
-                       return PTR_ERR(file);
-       }
-
-       flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
-
-       down_write(&current->mm->mmap_sem);
-       retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
-       up_write(&current->mm->mmap_sem);
-
-       if (file)
-               fput(file);
-out:
-       return retval;
-}
-
 /* Tracepoints definitions. */
 EXPORT_TRACEPOINT_SYMBOL(kmalloc);
 EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc);
index 9b08d790df6fe441a2b8c2002ed9f0e1a4677641..37e69295f250d585b1a2f7e9bf38f80b7186cdbb 100644 (file)
@@ -1411,6 +1411,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
 {
        struct page **pages;
        unsigned int nr_pages, array_size, i;
+       gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
 
        nr_pages = (area->size - PAGE_SIZE) >> PAGE_SHIFT;
        array_size = (nr_pages * sizeof(struct page *));
@@ -1418,13 +1419,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
        area->nr_pages = nr_pages;
        /* Please note that the recursion is strictly bounded. */
        if (array_size > PAGE_SIZE) {
-               pages = __vmalloc_node(array_size, 1, gfp_mask | __GFP_ZERO,
+               pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM,
                                PAGE_KERNEL, node, caller);
                area->flags |= VM_VPAGES;
        } else {
-               pages = kmalloc_node(array_size,
-                               (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO,
-                               node);
+               pages = kmalloc_node(array_size, nested_gfp, node);
        }
        area->pages = pages;
        area->caller = caller;
index 777af57fd8c8c80971d7abaf4edb974e360288c9..885207a6b6b735cb7ca0dd276b907312300b5df1 100644 (file)
@@ -55,6 +55,11 @@ struct scan_control {
        /* Number of pages freed so far during a call to shrink_zones() */
        unsigned long nr_reclaimed;
 
+       /* How many pages shrink_list() should reclaim */
+       unsigned long nr_to_reclaim;
+
+       unsigned long hibernation_mode;
+
        /* This context's GFP mask */
        gfp_t gfp_mask;
 
@@ -66,12 +71,6 @@ struct scan_control {
        /* Can pages be swapped as part of reclaim? */
        int may_swap;
 
-       /* This context's SWAP_CLUSTER_MAX. If freeing memory for
-        * suspend, we effectively ignore SWAP_CLUSTER_MAX.
-        * In this context, it doesn't matter that we scan the
-        * whole list at once. */
-       int swap_cluster_max;
-
        int swappiness;
 
        int all_unreclaimable;
@@ -358,7 +357,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,
         * stalls if we need to run get_block().  We could test
         * PagePrivate for that.
         *
-        * If this process is currently in generic_file_write() against
+        * If this process is currently in __generic_file_aio_write() against
         * this page's queue, we can perform writeback even if that
         * will block.
         *
@@ -1132,7 +1131,7 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
                unsigned long nr_anon;
                unsigned long nr_file;
 
-               nr_taken = sc->isolate_pages(sc->swap_cluster_max,
+               nr_taken = sc->isolate_pages(SWAP_CLUSTER_MAX,
                             &page_list, &nr_scan, sc->order, mode,
                                zone, sc->mem_cgroup, 0, file);
 
@@ -1166,10 +1165,8 @@ static unsigned long shrink_inactive_list(unsigned long max_scan,
                __mod_zone_page_state(zone, NR_ISOLATED_ANON, nr_anon);
                __mod_zone_page_state(zone, NR_ISOLATED_FILE, nr_file);
 
-               reclaim_stat->recent_scanned[0] += count[LRU_INACTIVE_ANON];
-               reclaim_stat->recent_scanned[0] += count[LRU_ACTIVE_ANON];
-               reclaim_stat->recent_scanned[1] += count[LRU_INACTIVE_FILE];
-               reclaim_stat->recent_scanned[1] += count[LRU_ACTIVE_FILE];
+               reclaim_stat->recent_scanned[0] += nr_anon;
+               reclaim_stat->recent_scanned[1] += nr_file;
 
                spin_unlock_irq(&zone->lru_lock);
 
@@ -1464,20 +1461,26 @@ static int inactive_file_is_low(struct zone *zone, struct scan_control *sc)
        return low;
 }
 
+static int inactive_list_is_low(struct zone *zone, struct scan_control *sc,
+                               int file)
+{
+       if (file)
+               return inactive_file_is_low(zone, sc);
+       else
+               return inactive_anon_is_low(zone, sc);
+}
+
 static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
        struct zone *zone, struct scan_control *sc, int priority)
 {
        int file = is_file_lru(lru);
 
-       if (lru == LRU_ACTIVE_FILE && inactive_file_is_low(zone, sc)) {
-               shrink_active_list(nr_to_scan, zone, sc, priority, file);
+       if (is_active_lru(lru)) {
+               if (inactive_list_is_low(zone, sc, file))
+                   shrink_active_list(nr_to_scan, zone, sc, priority, file);
                return 0;
        }
 
-       if (lru == LRU_ACTIVE_ANON && inactive_anon_is_low(zone, sc)) {
-               shrink_active_list(nr_to_scan, zone, sc, priority, file);
-               return 0;
-       }
        return shrink_inactive_list(nr_to_scan, zone, sc, priority, file);
 }
 
@@ -1567,15 +1570,14 @@ static void get_scan_ratio(struct zone *zone, struct scan_control *sc,
  * until we collected @swap_cluster_max pages to scan.
  */
 static unsigned long nr_scan_try_batch(unsigned long nr_to_scan,
-                                      unsigned long *nr_saved_scan,
-                                      unsigned long swap_cluster_max)
+                                      unsigned long *nr_saved_scan)
 {
        unsigned long nr;
 
        *nr_saved_scan += nr_to_scan;
        nr = *nr_saved_scan;
 
-       if (nr >= swap_cluster_max)
+       if (nr >= SWAP_CLUSTER_MAX)
                *nr_saved_scan = 0;
        else
                nr = 0;
@@ -1594,7 +1596,7 @@ static void shrink_zone(int priority, struct zone *zone,
        unsigned long percent[2];       /* anon @ 0; file @ 1 */
        enum lru_list l;
        unsigned long nr_reclaimed = sc->nr_reclaimed;
-       unsigned long swap_cluster_max = sc->swap_cluster_max;
+       unsigned long nr_to_reclaim = sc->nr_to_reclaim;
        struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(zone, sc);
        int noswap = 0;
 
@@ -1616,15 +1618,15 @@ static void shrink_zone(int priority, struct zone *zone,
                        scan = (scan * percent[file]) / 100;
                }
                nr[l] = nr_scan_try_batch(scan,
-                                         &reclaim_stat->nr_saved_scan[l],
-                                         swap_cluster_max);
+                                         &reclaim_stat->nr_saved_scan[l]);
        }
 
        while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||
                                        nr[LRU_INACTIVE_FILE]) {
                for_each_evictable_lru(l) {
                        if (nr[l]) {
-                               nr_to_scan = min(nr[l], swap_cluster_max);
+                               nr_to_scan = min_t(unsigned long,
+                                                  nr[l], SWAP_CLUSTER_MAX);
                                nr[l] -= nr_to_scan;
 
                                nr_reclaimed += shrink_list(l, nr_to_scan,
@@ -1639,8 +1641,7 @@ static void shrink_zone(int priority, struct zone *zone,
                 * with multiple processes reclaiming pages, the total
                 * freeing target can get unreasonably large.
                 */
-               if (nr_reclaimed > swap_cluster_max &&
-                       priority < DEF_PRIORITY && !current_is_kswapd())
+               if (nr_reclaimed >= nr_to_reclaim && priority < DEF_PRIORITY)
                        break;
        }
 
@@ -1738,6 +1739,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
        struct zoneref *z;
        struct zone *zone;
        enum zone_type high_zoneidx = gfp_zone(sc->gfp_mask);
+       unsigned long writeback_threshold;
 
        delayacct_freepages_start();
 
@@ -1773,7 +1775,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
                        }
                }
                total_scanned += sc->nr_scanned;
-               if (sc->nr_reclaimed >= sc->swap_cluster_max) {
+               if (sc->nr_reclaimed >= sc->nr_to_reclaim) {
                        ret = sc->nr_reclaimed;
                        goto out;
                }
@@ -1785,14 +1787,15 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
                 * that's undesirable in laptop mode, where we *want* lumpy
                 * writeout.  So in laptop mode, write out the whole world.
                 */
-               if (total_scanned > sc->swap_cluster_max +
-                                       sc->swap_cluster_max / 2) {
+               writeback_threshold = sc->nr_to_reclaim + sc->nr_to_reclaim / 2;
+               if (total_scanned > writeback_threshold) {
                        wakeup_flusher_threads(laptop_mode ? 0 : total_scanned);
                        sc->may_writepage = 1;
                }
 
                /* Take a nap, wait for some writeback to complete */
-               if (sc->nr_scanned && priority < DEF_PRIORITY - 2)
+               if (!sc->hibernation_mode && sc->nr_scanned &&
+                   priority < DEF_PRIORITY - 2)
                        congestion_wait(BLK_RW_ASYNC, HZ/10);
        }
        /* top priority shrink_zones still had more to do? don't OOM, then */
@@ -1831,7 +1834,7 @@ unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
        struct scan_control sc = {
                .gfp_mask = gfp_mask,
                .may_writepage = !laptop_mode,
-               .swap_cluster_max = SWAP_CLUSTER_MAX,
+               .nr_to_reclaim = SWAP_CLUSTER_MAX,
                .may_unmap = 1,
                .may_swap = 1,
                .swappiness = vm_swappiness,
@@ -1855,7 +1858,6 @@ unsigned long mem_cgroup_shrink_node_zone(struct mem_cgroup *mem,
                .may_writepage = !laptop_mode,
                .may_unmap = 1,
                .may_swap = !noswap,
-               .swap_cluster_max = SWAP_CLUSTER_MAX,
                .swappiness = swappiness,
                .order = 0,
                .mem_cgroup = mem,
@@ -1889,7 +1891,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
                .may_writepage = !laptop_mode,
                .may_unmap = 1,
                .may_swap = !noswap,
-               .swap_cluster_max = SWAP_CLUSTER_MAX,
+               .nr_to_reclaim = SWAP_CLUSTER_MAX,
                .swappiness = swappiness,
                .order = 0,
                .mem_cgroup = mem_cont,
@@ -1904,6 +1906,30 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *mem_cont,
 }
 #endif
 
+/* is kswapd sleeping prematurely? */
+static int sleeping_prematurely(pg_data_t *pgdat, int order, long remaining)
+{
+       int i;
+
+       /* If a direct reclaimer woke kswapd within HZ/10, it's premature */
+       if (remaining)
+               return 1;
+
+       /* If after HZ/10, a zone is below the high mark, it's premature */
+       for (i = 0; i < pgdat->nr_zones; i++) {
+               struct zone *zone = pgdat->node_zones + i;
+
+               if (!populated_zone(zone))
+                       continue;
+
+               if (!zone_watermark_ok(zone, order, high_wmark_pages(zone),
+                                                               0, 0))
+                       return 1;
+       }
+
+       return 0;
+}
+
 /*
  * For kswapd, balance_pgdat() will work across all this node's zones until
  * they are all at high_wmark_pages(zone).
@@ -1936,7 +1962,11 @@ static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
                .gfp_mask = GFP_KERNEL,
                .may_unmap = 1,
                .may_swap = 1,
-               .swap_cluster_max = SWAP_CLUSTER_MAX,
+               /*
+                * kswapd doesn't want to be bailed out while reclaim. because
+                * we want to put equal scanning pressure on each zone.
+                */
+               .nr_to_reclaim = ULONG_MAX,
                .swappiness = vm_swappiness,
                .order = order,
                .mem_cgroup = NULL,
@@ -1961,6 +1991,7 @@ loop_again:
        for (priority = DEF_PRIORITY; priority >= 0; priority--) {
                int end_zone = 0;       /* Inclusive.  0 = ZONE_DMA */
                unsigned long lru_pages = 0;
+               int has_under_min_watermark_zone = 0;
 
                /* The swap token gets in the way of swapout... */
                if (!priority)
@@ -2067,6 +2098,15 @@ loop_again:
                        if (total_scanned > SWAP_CLUSTER_MAX * 2 &&
                            total_scanned > sc.nr_reclaimed + sc.nr_reclaimed / 2)
                                sc.may_writepage = 1;
+
+                       /*
+                        * We are still under min water mark. it mean we have
+                        * GFP_ATOMIC allocation failure risk. Hurry up!
+                        */
+                       if (!zone_watermark_ok(zone, order, min_wmark_pages(zone),
+                                             end_zone, 0))
+                               has_under_min_watermark_zone = 1;
+
                }
                if (all_zones_ok)
                        break;          /* kswapd: all done */
@@ -2074,8 +2114,12 @@ loop_again:
                 * OK, kswapd is getting into trouble.  Take a nap, then take
                 * another pass across the zones.
                 */
-               if (total_scanned && priority < DEF_PRIORITY - 2)
-                       congestion_wait(BLK_RW_ASYNC, HZ/10);
+               if (total_scanned && (priority < DEF_PRIORITY - 2)) {
+                       if (has_under_min_watermark_zone)
+                               count_vm_event(KSWAPD_SKIP_CONGESTION_WAIT);
+                       else
+                               congestion_wait(BLK_RW_ASYNC, HZ/10);
+               }
 
                /*
                 * We do this so kswapd doesn't build up large priorities for
@@ -2173,6 +2217,7 @@ static int kswapd(void *p)
        order = 0;
        for ( ; ; ) {
                unsigned long new_order;
+               int ret;
 
                prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
                new_order = pgdat->kswapd_max_order;
@@ -2184,19 +2229,45 @@ static int kswapd(void *p)
                         */
                        order = new_order;
                } else {
-                       if (!freezing(current))
-                               schedule();
+                       if (!freezing(current) && !kthread_should_stop()) {
+                               long remaining = 0;
+
+                               /* Try to sleep for a short interval */
+                               if (!sleeping_prematurely(pgdat, order, remaining)) {
+                                       remaining = schedule_timeout(HZ/10);
+                                       finish_wait(&pgdat->kswapd_wait, &wait);
+                                       prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
+                               }
+
+                               /*
+                                * After a short sleep, check if it was a
+                                * premature sleep. If not, then go fully
+                                * to sleep until explicitly woken up
+                                */
+                               if (!sleeping_prematurely(pgdat, order, remaining))
+                                       schedule();
+                               else {
+                                       if (remaining)
+                                               count_vm_event(KSWAPD_LOW_WMARK_HIT_QUICKLY);
+                                       else
+                                               count_vm_event(KSWAPD_HIGH_WMARK_HIT_QUICKLY);
+                               }
+                       }
 
                        order = pgdat->kswapd_max_order;
                }
                finish_wait(&pgdat->kswapd_wait, &wait);
 
-               if (!try_to_freeze()) {
-                       /* We can speed up thawing tasks if we don't call
-                        * balance_pgdat after returning from the refrigerator
-                        */
+               ret = try_to_freeze();
+               if (kthread_should_stop())
+                       break;
+
+               /*
+                * We can speed up thawing tasks if we don't call balance_pgdat
+                * after returning from the refrigerator
+                */
+               if (!ret)
                        balance_pgdat(pgdat, order);
-               }
        }
        return 0;
 }
@@ -2260,148 +2331,43 @@ unsigned long zone_reclaimable_pages(struct zone *zone)
 
 #ifdef CONFIG_HIBERNATION
 /*
- * Helper function for shrink_all_memory().  Tries to reclaim 'nr_pages' pages
- * from LRU lists system-wide, for given pass and priority.
- *
- * For pass > 3 we also try to shrink the LRU lists that contain a few pages
- */
-static void shrink_all_zones(unsigned long nr_pages, int prio,
-                                     int pass, struct scan_control *sc)
-{
-       struct zone *zone;
-       unsigned long nr_reclaimed = 0;
-       struct zone_reclaim_stat *reclaim_stat;
-
-       for_each_populated_zone(zone) {
-               enum lru_list l;
-
-               if (zone_is_all_unreclaimable(zone) && prio != DEF_PRIORITY)
-                       continue;
-
-               for_each_evictable_lru(l) {
-                       enum zone_stat_item ls = NR_LRU_BASE + l;
-                       unsigned long lru_pages = zone_page_state(zone, ls);
-
-                       /* For pass = 0, we don't shrink the active list */
-                       if (pass == 0 && (l == LRU_ACTIVE_ANON ||
-                                               l == LRU_ACTIVE_FILE))
-                               continue;
-
-                       reclaim_stat = get_reclaim_stat(zone, sc);
-                       reclaim_stat->nr_saved_scan[l] +=
-                                               (lru_pages >> prio) + 1;
-                       if (reclaim_stat->nr_saved_scan[l]
-                                               >= nr_pages || pass > 3) {
-                               unsigned long nr_to_scan;
-
-                               reclaim_stat->nr_saved_scan[l] = 0;
-                               nr_to_scan = min(nr_pages, lru_pages);
-                               nr_reclaimed += shrink_list(l, nr_to_scan, zone,
-                                                               sc, prio);
-                               if (nr_reclaimed >= nr_pages) {
-                                       sc->nr_reclaimed += nr_reclaimed;
-                                       return;
-                               }
-                       }
-               }
-       }
-       sc->nr_reclaimed += nr_reclaimed;
-}
-
-/*
- * Try to free `nr_pages' of memory, system-wide, and return the number of
+ * Try to free `nr_to_reclaim' of memory, system-wide, and return the number of
  * freed pages.
  *
  * Rather than trying to age LRUs the aim is to preserve the overall
  * LRU order by reclaiming preferentially
  * inactive > active > active referenced > active mapped
  */
-unsigned long shrink_all_memory(unsigned long nr_pages)
+unsigned long shrink_all_memory(unsigned long nr_to_reclaim)
 {
-       unsigned long lru_pages, nr_slab;
-       int pass;
        struct reclaim_state reclaim_state;
        struct scan_control sc = {
-               .gfp_mask = GFP_KERNEL,
-               .may_unmap = 0,
+               .gfp_mask = GFP_HIGHUSER_MOVABLE,
+               .may_swap = 1,
+               .may_unmap = 1,
                .may_writepage = 1,
+               .nr_to_reclaim = nr_to_reclaim,
+               .hibernation_mode = 1,
+               .swappiness = vm_swappiness,
+               .order = 0,
                .isolate_pages = isolate_pages_global,
-               .nr_reclaimed = 0,
        };
+       struct zonelist * zonelist = node_zonelist(numa_node_id(), sc.gfp_mask);
+       struct task_struct *p = current;
+       unsigned long nr_reclaimed;
 
-       current->reclaim_state = &reclaim_state;
-
-       lru_pages = global_reclaimable_pages();
-       nr_slab = global_page_state(NR_SLAB_RECLAIMABLE);
-       /* If slab caches are huge, it's better to hit them first */
-       while (nr_slab >= lru_pages) {
-               reclaim_state.reclaimed_slab = 0;
-               shrink_slab(nr_pages, sc.gfp_mask, lru_pages);
-               if (!reclaim_state.reclaimed_slab)
-                       break;
-
-               sc.nr_reclaimed += reclaim_state.reclaimed_slab;
-               if (sc.nr_reclaimed >= nr_pages)
-                       goto out;
-
-               nr_slab -= reclaim_state.reclaimed_slab;
-       }
-
-       /*
-        * We try to shrink LRUs in 5 passes:
-        * 0 = Reclaim from inactive_list only
-        * 1 = Reclaim from active list but don't reclaim mapped
-        * 2 = 2nd pass of type 1
-        * 3 = Reclaim mapped (normal reclaim)
-        * 4 = 2nd pass of type 3
-        */
-       for (pass = 0; pass < 5; pass++) {
-               int prio;
-
-               /* Force reclaiming mapped pages in the passes #3 and #4 */
-               if (pass > 2)
-                       sc.may_unmap = 1;
-
-               for (prio = DEF_PRIORITY; prio >= 0; prio--) {
-                       unsigned long nr_to_scan = nr_pages - sc.nr_reclaimed;
-
-                       sc.nr_scanned = 0;
-                       sc.swap_cluster_max = nr_to_scan;
-                       shrink_all_zones(nr_to_scan, prio, pass, &sc);
-                       if (sc.nr_reclaimed >= nr_pages)
-                               goto out;
-
-                       reclaim_state.reclaimed_slab = 0;
-                       shrink_slab(sc.nr_scanned, sc.gfp_mask,
-                                   global_reclaimable_pages());
-                       sc.nr_reclaimed += reclaim_state.reclaimed_slab;
-                       if (sc.nr_reclaimed >= nr_pages)
-                               goto out;
-
-                       if (sc.nr_scanned && prio < DEF_PRIORITY - 2)
-                               congestion_wait(BLK_RW_ASYNC, HZ / 10);
-               }
-       }
-
-       /*
-        * If sc.nr_reclaimed = 0, we could not shrink LRUs, but there may be
-        * something in slab caches
-        */
-       if (!sc.nr_reclaimed) {
-               do {
-                       reclaim_state.reclaimed_slab = 0;
-                       shrink_slab(nr_pages, sc.gfp_mask,
-                                   global_reclaimable_pages());
-                       sc.nr_reclaimed += reclaim_state.reclaimed_slab;
-               } while (sc.nr_reclaimed < nr_pages &&
-                               reclaim_state.reclaimed_slab > 0);
-       }
+       p->flags |= PF_MEMALLOC;
+       lockdep_set_current_reclaim_state(sc.gfp_mask);
+       reclaim_state.reclaimed_slab = 0;
+       p->reclaim_state = &reclaim_state;
 
+       nr_reclaimed = do_try_to_free_pages(zonelist, &sc);
 
-out:
-       current->reclaim_state = NULL;
+       p->reclaim_state = NULL;
+       lockdep_clear_current_reclaim_state();
+       p->flags &= ~PF_MEMALLOC;
 
-       return sc.nr_reclaimed;
+       return nr_reclaimed;
 }
 #endif /* CONFIG_HIBERNATION */
 
@@ -2451,6 +2417,17 @@ int kswapd_run(int nid)
        return ret;
 }
 
+/*
+ * Called by memory hotplug when all memory in a node is offlined.
+ */
+void kswapd_stop(int nid)
+{
+       struct task_struct *kswapd = NODE_DATA(nid)->kswapd;
+
+       if (kswapd)
+               kthread_stop(kswapd);
+}
+
 static int __init kswapd_init(void)
 {
        int nid;
@@ -2553,8 +2530,8 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
                .may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE),
                .may_unmap = !!(zone_reclaim_mode & RECLAIM_SWAP),
                .may_swap = 1,
-               .swap_cluster_max = max_t(unsigned long, nr_pages,
-                                       SWAP_CLUSTER_MAX),
+               .nr_to_reclaim = max_t(unsigned long, nr_pages,
+                                      SWAP_CLUSTER_MAX),
                .gfp_mask = gfp_mask,
                .swappiness = vm_swappiness,
                .order = order,
index dad2327e45804e16a8ff07564a80eb0cac79f482..6051fbab67ba26533594103c62790f779cd21c08 100644 (file)
@@ -683,6 +683,9 @@ static const char * const vmstat_text[] = {
        "slabs_scanned",
        "kswapd_steal",
        "kswapd_inodesteal",
+       "kswapd_low_wmark_hit_quickly",
+       "kswapd_high_wmark_hit_quickly",
+       "kswapd_skip_congestion_wait",
        "pageoutrun",
        "allocstall",
 
index 4dd873e3a1bb185554fb2bd702b53b49758ec0b2..be1cb909d8c00e5e9cac2a910fa2d8f793249779 100644 (file)
@@ -42,6 +42,8 @@
 #include <net/9p/client.h>
 #include <net/9p/transport.h>
 
+#include <linux/syscalls.h> /* killme */
+
 #define P9_PORT 564
 #define MAX_SOCK_BUF (64*1024)
 #define MAXPOLLWADDR   2
@@ -788,24 +790,41 @@ static int p9_fd_open(struct p9_client *client, int rfd, int wfd)
 
 static int p9_socket_open(struct p9_client *client, struct socket *csocket)
 {
-       int fd, ret;
+       struct p9_trans_fd *p;
+       int ret, fd;
+
+       p = kmalloc(sizeof(struct p9_trans_fd), GFP_KERNEL);
+       if (!p)
+               return -ENOMEM;
 
        csocket->sk->sk_allocation = GFP_NOIO;
        fd = sock_map_fd(csocket, 0);
        if (fd < 0) {
                P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to map fd\n");
+               sock_release(csocket);
+               kfree(p);
                return fd;
        }
 
-       ret = p9_fd_open(client, fd, fd);
-       if (ret < 0) {
-               P9_EPRINTK(KERN_ERR, "p9_socket_open: failed to open fd\n");
+       get_file(csocket->file);
+       get_file(csocket->file);
+       p->wr = p->rd = csocket->file;
+       client->trans = p;
+       client->status = Connected;
+
+       sys_close(fd);  /* still racy */
+
+       p->rd->f_flags |= O_NONBLOCK;
+
+       p->conn = p9_conn_create(client);
+       if (IS_ERR(p->conn)) {
+               ret = PTR_ERR(p->conn);
+               p->conn = NULL;
+               kfree(p);
+               sockfd_put(csocket);
                sockfd_put(csocket);
                return ret;
        }
-
-       ((struct p9_trans_fd *)client->trans)->rd->f_flags |= O_NONBLOCK;
-
        return 0;
 }
 
@@ -883,7 +902,6 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
        struct socket *csocket;
        struct sockaddr_in sin_server;
        struct p9_fd_opts opts;
-       struct p9_trans_fd *p = NULL; /* this gets allocated in p9_fd_open */
 
        err = parse_opts(args, &opts);
        if (err < 0)
@@ -897,12 +915,11 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
        sin_server.sin_family = AF_INET;
        sin_server.sin_addr.s_addr = in_aton(addr);
        sin_server.sin_port = htons(opts.port);
-       sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket);
+       err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket);
 
-       if (!csocket) {
+       if (err) {
                P9_EPRINTK(KERN_ERR, "p9_trans_tcp: problem creating socket\n");
-               err = -EIO;
-               goto error;
+               return err;
        }
 
        err = csocket->ops->connect(csocket,
@@ -912,30 +929,11 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
                P9_EPRINTK(KERN_ERR,
                        "p9_trans_tcp: problem connecting socket to %s\n",
                        addr);
-               goto error;
-       }
-
-       err = p9_socket_open(client, csocket);
-       if (err < 0)
-               goto error;
-
-       p = (struct p9_trans_fd *) client->trans;
-       p->conn = p9_conn_create(client);
-       if (IS_ERR(p->conn)) {
-               err = PTR_ERR(p->conn);
-               p->conn = NULL;
-               goto error;
-       }
-
-       return 0;
-
-error:
-       if (csocket)
                sock_release(csocket);
+               return err;
+       }
 
-       kfree(p);
-
-       return err;
+       return p9_socket_open(client, csocket);
 }
 
 static int
@@ -944,49 +942,33 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args)
        int err;
        struct socket *csocket;
        struct sockaddr_un sun_server;
-       struct p9_trans_fd *p = NULL; /* this gets allocated in p9_fd_open */
 
        csocket = NULL;
 
        if (strlen(addr) > UNIX_PATH_MAX) {
                P9_EPRINTK(KERN_ERR, "p9_trans_unix: address too long: %s\n",
                        addr);
-               err = -ENAMETOOLONG;
-               goto error;
+               return -ENAMETOOLONG;
        }
 
        sun_server.sun_family = PF_UNIX;
        strcpy(sun_server.sun_path, addr);
-       sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket);
+       err = sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket);
+       if (err < 0) {
+               P9_EPRINTK(KERN_ERR, "p9_trans_unix: problem creating socket\n");
+               return err;
+       }
        err = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server,
                        sizeof(struct sockaddr_un) - 1, 0);
        if (err < 0) {
                P9_EPRINTK(KERN_ERR,
                        "p9_trans_unix: problem connecting socket: %s: %d\n",
                        addr, err);
-               goto error;
-       }
-
-       err = p9_socket_open(client, csocket);
-       if (err < 0)
-               goto error;
-
-       p = (struct p9_trans_fd *) client->trans;
-       p->conn = p9_conn_create(client);
-       if (IS_ERR(p->conn)) {
-               err = PTR_ERR(p->conn);
-               p->conn = NULL;
-               goto error;
-       }
-
-       return 0;
-
-error:
-       if (csocket)
                sock_release(csocket);
+               return err;
+       }
 
-       kfree(p);
-       return err;
+       return p9_socket_open(client, csocket);
 }
 
 static int
@@ -994,7 +976,7 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
 {
        int err;
        struct p9_fd_opts opts;
-       struct p9_trans_fd *p = NULL; /* this get allocated in p9_fd_open */
+       struct p9_trans_fd *p;
 
        parse_opts(args, &opts);
 
@@ -1005,21 +987,19 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
 
        err = p9_fd_open(client, opts.rfd, opts.wfd);
        if (err < 0)
-               goto error;
+               return err;
 
        p = (struct p9_trans_fd *) client->trans;
        p->conn = p9_conn_create(client);
        if (IS_ERR(p->conn)) {
                err = PTR_ERR(p->conn);
                p->conn = NULL;
-               goto error;
+               fput(p->rd);
+               fput(p->wr);
+               return err;
        }
 
        return 0;
-
-error:
-       kfree(p);
-       return err;
 }
 
 static struct p9_trans_module p9_tcp_trans = {
index 569750010fd320518001adf61ea501a577f5feb7..18e7f5a43dc4fd8eda8d34a7b65e98752c86946f 100644 (file)
@@ -770,7 +770,7 @@ static int hidp_setup_hid(struct hidp_session *session,
 
        hid = hid_allocate_device();
        if (IS_ERR(hid))
-               return PTR_ERR(session->hid);
+               return PTR_ERR(hid);
 
        session->hid = hid;
        session->req = req;
index 5129b88c8e5ba6cfc57b4ad5472937a43e98c2d8..1120cf14a5484b0bd9ac3ba331874e81121c1182 100644 (file)
@@ -1212,6 +1212,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
        bh_lock_sock(sk);
        if (l2cap_pi(sk)->retry_count >= l2cap_pi(sk)->remote_max_tx) {
                l2cap_send_disconn_req(l2cap_pi(sk)->conn, sk);
+               bh_unlock_sock(sk);
                return;
        }
 
@@ -3435,8 +3436,8 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str
                            (pi->unacked_frames > 0))
                                __mod_retrans_timer();
 
-                       l2cap_ertm_send(sk);
                        pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY;
+                       l2cap_ertm_send(sk);
                }
                break;
 
@@ -3471,9 +3472,9 @@ static inline int l2cap_data_channel_sframe(struct sock *sk, u16 rx_control, str
                pi->conn_state &= ~L2CAP_CONN_REMOTE_BUSY;
 
                if (rx_control & L2CAP_CTRL_POLL) {
-                       l2cap_retransmit_frame(sk, tx_seq);
                        pi->expected_ack_seq = tx_seq;
                        l2cap_drop_acked_frames(sk);
+                       l2cap_retransmit_frame(sk, tx_seq);
                        l2cap_ertm_send(sk);
                        if (pi->conn_state & L2CAP_CONN_WAIT_F) {
                                pi->srej_save_reqseq = tx_seq;
index 6fe7d739e59bdf1fc4ebe10f427b7c3d0d8308ec..be9924f60ec34bafa135916455595e794a7fe86c 100644 (file)
@@ -5035,6 +5035,11 @@ int register_netdevice(struct net_device *dev)
                rollback_registered(dev);
                dev->reg_state = NETREG_UNREGISTERED;
        }
+       /*
+        *      Prevent userspace races by waiting until the network
+        *      device is fully setup before sending notifications.
+        */
+       rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
 
 out:
        return ret;
@@ -5597,6 +5602,12 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
        /* Notify protocols, that a new device appeared. */
        call_netdevice_notifiers(NETDEV_REGISTER, dev);
 
+       /*
+        *      Prevent userspace races by waiting until the network
+        *      device is fully setup before sending notifications.
+        */
+       rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
+
        synchronize_net();
        err = 0;
 out:
index a23b45f08ec9ce6644cfc350cb3bc393c167ab92..de0c2c726420e2044c55fd6235e15e915de16a51 100644 (file)
@@ -250,8 +250,7 @@ struct pktgen_dev {
        __u64 count;            /* Default No packets to send */
        __u64 sofar;            /* How many pkts we've sent so far */
        __u64 tx_bytes;         /* How many bytes we've transmitted */
-       __u64 errors;           /* Errors when trying to transmit,
-                                  pkts will be re-sent */
+       __u64 errors;           /* Errors when trying to transmit, */
 
        /* runtime counters relating to clone_skb */
 
@@ -3465,6 +3464,12 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
                pkt_dev->seq_num++;
                pkt_dev->tx_bytes += pkt_dev->last_pkt_size;
                break;
+       case NET_XMIT_DROP:
+       case NET_XMIT_CN:
+       case NET_XMIT_POLICED:
+               /* skb has been consumed */
+               pkt_dev->errors++;
+               break;
        default: /* Drivers are not supposed to return other values! */
                if (net_ratelimit())
                        pr_info("pktgen: %s xmit error: %d\n",
index 33148a568199c7215b87e63f68a39b4a02afb4cd..794bcb897ff000eeff119df41e72864958b304d3 100644 (file)
@@ -1364,15 +1364,15 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
        case NETDEV_UNREGISTER:
                rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
                break;
-       case NETDEV_REGISTER:
-               rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
-               break;
        case NETDEV_UP:
        case NETDEV_DOWN:
                rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING);
                break;
+       case NETDEV_POST_INIT:
+       case NETDEV_REGISTER:
        case NETDEV_CHANGE:
        case NETDEV_GOING_DOWN:
+       case NETDEV_UNREGISTER_BATCH:
                break;
        default:
                rtmsg_ifinfo(RTM_NEWLINK, dev, 0);
index bfa3e7865a8c92fe397b4a2636233deee5633fc4..93c4e060c91e7bffb121d51eeccd264337214491 100644 (file)
@@ -93,7 +93,7 @@ static int sock_pipe_buf_steal(struct pipe_inode_info *pipe,
 
 
 /* Pipe buffer operations for a socket. */
-static struct pipe_buf_operations sock_pipe_buf_ops = {
+static const struct pipe_buf_operations sock_pipe_buf_ops = {
        .can_merge = 0,
        .map = generic_pipe_buf_map,
        .unmap = generic_pipe_buf_unmap,
index dc328425fa20ddfcde71163ef299b2c84f105538..a1362dc8abb0778716c296f767c8d4714225bc32 100644 (file)
@@ -43,7 +43,7 @@ static int bufsize = 64 * 1024;
 static const char procname[] = "dccpprobe";
 
 static struct {
-       struct kfifo      *fifo;
+       struct kfifo      fifo;
        spinlock_t        lock;
        wait_queue_head_t wait;
        struct timespec   tstart;
@@ -67,7 +67,7 @@ static void printl(const char *fmt, ...)
        len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args);
        va_end(args);
 
-       kfifo_put(dccpw.fifo, tbuf, len);
+       kfifo_in_locked(&dccpw.fifo, tbuf, len, &dccpw.lock);
        wake_up(&dccpw.wait);
 }
 
@@ -109,7 +109,7 @@ static struct jprobe dccp_send_probe = {
 
 static int dccpprobe_open(struct inode *inode, struct file *file)
 {
-       kfifo_reset(dccpw.fifo);
+       kfifo_reset(&dccpw.fifo);
        getnstimeofday(&dccpw.tstart);
        return 0;
 }
@@ -131,11 +131,11 @@ static ssize_t dccpprobe_read(struct file *file, char __user *buf,
                return -ENOMEM;
 
        error = wait_event_interruptible(dccpw.wait,
-                                        __kfifo_len(dccpw.fifo) != 0);
+                                        kfifo_len(&dccpw.fifo) != 0);
        if (error)
                goto out_free;
 
-       cnt = kfifo_get(dccpw.fifo, tbuf, len);
+       cnt = kfifo_out_locked(&dccpw.fifo, tbuf, len, &dccpw.lock);
        error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0;
 
 out_free:
@@ -156,10 +156,8 @@ static __init int dccpprobe_init(void)
 
        init_waitqueue_head(&dccpw.wait);
        spin_lock_init(&dccpw.lock);
-       dccpw.fifo = kfifo_alloc(bufsize, GFP_KERNEL, &dccpw.lock);
-       if (IS_ERR(dccpw.fifo))
-               return PTR_ERR(dccpw.fifo);
-
+       if (kfifo_alloc(&dccpw.fifo, bufsize, GFP_KERNEL))
+               return ret;
        if (!proc_net_fops_create(&init_net, procname, S_IRUSR, &dccpprobe_fops))
                goto err0;
 
@@ -172,14 +170,14 @@ static __init int dccpprobe_init(void)
 err1:
        proc_net_remove(&init_net, procname);
 err0:
-       kfifo_free(dccpw.fifo);
+       kfifo_free(&dccpw.fifo);
        return ret;
 }
 module_init(dccpprobe_init);
 
 static __exit void dccpprobe_exit(void)
 {
-       kfifo_free(dccpw.fifo);
+       kfifo_free(&dccpw.fifo);
        proc_net_remove(&init_net, procname);
        unregister_jprobe(&dccp_send_probe);
 
index 70491d9035eb40e3496d98e805690aff1329eed1..0c94a1ac29464247e2dfdd6c4ac14c1dbed3bf79 100644 (file)
@@ -166,7 +166,7 @@ config IP_PNP_DHCP
 
          If unsure, say Y. Note that if you want to use DHCP, a DHCP server
          must be operating on your network.  Read
-         <file:Documentation/filesystems/nfsroot.txt> for details.
+         <file:Documentation/filesystems/nfs/nfsroot.txt> for details.
 
 config IP_PNP_BOOTP
        bool "IP: BOOTP support"
@@ -181,7 +181,7 @@ config IP_PNP_BOOTP
          does BOOTP itself, providing all necessary information on the kernel
          command line, you can say N here. If unsure, say Y. Note that if you
          want to use BOOTP, a BOOTP server must be operating on your network.
-         Read <file:Documentation/filesystems/nfsroot.txt> for details.
+         Read <file:Documentation/filesystems/nfs/nfsroot.txt> for details.
 
 config IP_PNP_RARP
        bool "IP: RARP support"
@@ -194,7 +194,7 @@ config IP_PNP_RARP
          older protocol which is being obsoleted by BOOTP and DHCP), say Y
          here. Note that if you want to use RARP, a RARP server must be
          operating on your network. Read
-         <file:Documentation/filesystems/nfsroot.txt> for details.
+         <file:Documentation/filesystems/nfs/nfsroot.txt> for details.
 
 # not yet ready..
 #   bool '    IP: ARP support' CONFIG_IP_PNP_ARP
index 5cdbc102a4187a274106c9ec6a8ad830c11d2bd6..040c4f05b65321b6b2c6023bb0eba66eecb7c26a 100644 (file)
@@ -1397,6 +1397,7 @@ static struct devinet_sysctl_table {
                DEVINET_SYSCTL_RW_ENTRY(ACCEPT_SOURCE_ROUTE,
                                        "accept_source_route"),
                DEVINET_SYSCTL_RW_ENTRY(ACCEPT_LOCAL, "accept_local"),
+               DEVINET_SYSCTL_RW_ENTRY(SRC_VMARK, "src_valid_mark"),
                DEVINET_SYSCTL_RW_ENTRY(PROXY_ARP, "proxy_arp"),
                DEVINET_SYSCTL_RW_ENTRY(MEDIUM_ID, "medium_id"),
                DEVINET_SYSCTL_RW_ENTRY(BOOTP_RELAY, "bootp_relay"),
index 3323168ee52d8774c6cb0258acbd807e7646a203..82dbf711d6d0ef2a704e6a636131242f379011c8 100644 (file)
@@ -252,6 +252,8 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
                no_addr = in_dev->ifa_list == NULL;
                rpf = IN_DEV_RPFILTER(in_dev);
                accept_local = IN_DEV_ACCEPT_LOCAL(in_dev);
+               if (mark && !IN_DEV_SRC_VMARK(in_dev))
+                       fl.mark = 0;
        }
        rcu_read_unlock();
 
index 4e08b7f2331cdd65105fac2bad84bd87c2ac1c02..10a6a604bf32bee0aa1f4a7d591557173919d296 100644 (file)
@@ -1446,7 +1446,7 @@ late_initcall(ip_auto_config);
 
 /*
  *  Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel
- *  command line parameter.  See Documentation/filesystems/nfsroot.txt.
+ *  command line parameter.  See Documentation/filesystems/nfs/nfsroot.txt.
  */
 static int __init ic_proto_name(char *name)
 {
index fa2d6b6fc3e581524181d88a1402df6289eb42c8..331ead3ebd1be98c93ec5bd15cfcb68171c080a7 100644 (file)
@@ -14,6 +14,7 @@
 #include <net/route.h>
 #include <net/ip.h>
 
+#include <linux/netfilter_bridge.h>
 #include <linux/netfilter_ipv4.h>
 #include <net/netfilter/ipv4/nf_defrag_ipv4.h>
 
@@ -34,6 +35,20 @@ static int nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user)
        return err;
 }
 
+static enum ip_defrag_users nf_ct_defrag_user(unsigned int hooknum,
+                                             struct sk_buff *skb)
+{
+#ifdef CONFIG_BRIDGE_NETFILTER
+       if (skb->nf_bridge &&
+           skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)
+               return IP_DEFRAG_CONNTRACK_BRIDGE_IN;
+#endif
+       if (hooknum == NF_INET_PRE_ROUTING)
+               return IP_DEFRAG_CONNTRACK_IN;
+       else
+               return IP_DEFRAG_CONNTRACK_OUT;
+}
+
 static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
                                          struct sk_buff *skb,
                                          const struct net_device *in,
@@ -50,10 +65,8 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum,
 #endif
        /* Gather fragments. */
        if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
-               if (nf_ct_ipv4_gather_frags(skb,
-                                           hooknum == NF_INET_PRE_ROUTING ?
-                                           IP_DEFRAG_CONNTRACK_IN :
-                                           IP_DEFRAG_CONNTRACK_OUT))
+               enum ip_defrag_users user = nf_ct_defrag_user(hooknum, skb);
+               if (nf_ct_ipv4_gather_frags(skb, user))
                        return NF_STOLEN;
        }
        return NF_ACCEPT;
index 26399ad2a289ba199f8a9df086d0ef5c62635af6..66fd80ef247337d03f84fd264aab748f60346297 100644 (file)
@@ -277,6 +277,13 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
 
        NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV);
 
+       /* check for timestamp cookie support */
+       memset(&tcp_opt, 0, sizeof(tcp_opt));
+       tcp_parse_options(skb, &tcp_opt, &hash_location, 0);
+
+       if (tcp_opt.saw_tstamp)
+               cookie_check_timestamp(&tcp_opt);
+
        ret = NULL;
        req = inet_reqsk_alloc(&tcp_request_sock_ops); /* for safety */
        if (!req)
@@ -292,6 +299,12 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
        ireq->loc_addr          = ip_hdr(skb)->daddr;
        ireq->rmt_addr          = ip_hdr(skb)->saddr;
        ireq->ecn_ok            = 0;
+       ireq->snd_wscale        = tcp_opt.snd_wscale;
+       ireq->rcv_wscale        = tcp_opt.rcv_wscale;
+       ireq->sack_ok           = tcp_opt.sack_ok;
+       ireq->wscale_ok         = tcp_opt.wscale_ok;
+       ireq->tstamp_ok         = tcp_opt.saw_tstamp;
+       req->ts_recent          = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
 
        /* We throwed the options of the initial SYN away, so we hope
         * the ACK carries the same options again (see RFC1122 4.2.3.8)
@@ -340,20 +353,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
                }
        }
 
-       /* check for timestamp cookie support */
-       memset(&tcp_opt, 0, sizeof(tcp_opt));
-       tcp_parse_options(skb, &tcp_opt, &hash_location, 0, &rt->u.dst);
-
-       if (tcp_opt.saw_tstamp)
-               cookie_check_timestamp(&tcp_opt);
-
-       ireq->snd_wscale        = tcp_opt.snd_wscale;
-       ireq->rcv_wscale        = tcp_opt.rcv_wscale;
-       ireq->sack_ok           = tcp_opt.sack_ok;
-       ireq->wscale_ok         = tcp_opt.wscale_ok;
-       ireq->tstamp_ok         = tcp_opt.saw_tstamp;
-       req->ts_recent          = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
-
        /* Try to redo what tcp_v4_send_synack did. */
        req->window_clamp = tp->window_clamp ? :dst_metric(&rt->u.dst, RTAX_WINDOW);
 
index 12cab7d74dba2a5ecacf226256da5e7fa60910a2..28e029632493629ca409b02d094c18de56279eaf 100644 (file)
@@ -3727,7 +3727,7 @@ old_ack:
  * the fast version below fails.
  */
 void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
-                      u8 **hvpp, int estab,  struct dst_entry *dst)
+                      u8 **hvpp, int estab)
 {
        unsigned char *ptr;
        struct tcphdr *th = tcp_hdr(skb);
@@ -3766,8 +3766,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                                break;
                        case TCPOPT_WINDOW:
                                if (opsize == TCPOLEN_WINDOW && th->syn &&
-                                   !estab && sysctl_tcp_window_scaling &&
-                                   !dst_feature(dst, RTAX_FEATURE_NO_WSCALE)) {
+                                   !estab && sysctl_tcp_window_scaling) {
                                        __u8 snd_wscale = *(__u8 *)ptr;
                                        opt_rx->wscale_ok = 1;
                                        if (snd_wscale > 14) {
@@ -3783,8 +3782,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                        case TCPOPT_TIMESTAMP:
                                if ((opsize == TCPOLEN_TIMESTAMP) &&
                                    ((estab && opt_rx->tstamp_ok) ||
-                                    (!estab && sysctl_tcp_timestamps &&
-                                     !dst_feature(dst, RTAX_FEATURE_NO_TSTAMP)))) {
+                                    (!estab && sysctl_tcp_timestamps))) {
                                        opt_rx->saw_tstamp = 1;
                                        opt_rx->rcv_tsval = get_unaligned_be32(ptr);
                                        opt_rx->rcv_tsecr = get_unaligned_be32(ptr + 4);
@@ -3792,8 +3790,7 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                                break;
                        case TCPOPT_SACK_PERM:
                                if (opsize == TCPOLEN_SACK_PERM && th->syn &&
-                                   !estab && sysctl_tcp_sack &&
-                                   !dst_feature(dst, RTAX_FEATURE_NO_SACK)) {
+                                   !estab && sysctl_tcp_sack) {
                                        opt_rx->sack_ok = 1;
                                        tcp_sack_reset(opt_rx);
                                }
@@ -3878,7 +3875,7 @@ static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th,
                if (tcp_parse_aligned_timestamp(tp, th))
                        return 1;
        }
-       tcp_parse_options(skb, &tp->rx_opt, hvpp, 1, NULL);
+       tcp_parse_options(skb, &tp->rx_opt, hvpp, 1);
        return 1;
 }
 
@@ -4133,10 +4130,8 @@ static inline int tcp_sack_extend(struct tcp_sack_block *sp, u32 seq,
 static void tcp_dsack_set(struct sock *sk, u32 seq, u32 end_seq)
 {
        struct tcp_sock *tp = tcp_sk(sk);
-       struct dst_entry *dst = __sk_dst_get(sk);
 
-       if (tcp_is_sack(tp) && sysctl_tcp_dsack &&
-           !dst_feature(dst, RTAX_FEATURE_NO_DSACK)) {
+       if (tcp_is_sack(tp) && sysctl_tcp_dsack) {
                int mib_idx;
 
                if (before(seq, tp->rcv_nxt))
@@ -4165,15 +4160,13 @@ static void tcp_dsack_extend(struct sock *sk, u32 seq, u32 end_seq)
 static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb)
 {
        struct tcp_sock *tp = tcp_sk(sk);
-       struct dst_entry *dst = __sk_dst_get(sk);
 
        if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
            before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
                NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_DELAYEDACKLOST);
                tcp_enter_quickack_mode(sk);
 
-               if (tcp_is_sack(tp) && sysctl_tcp_dsack &&
-                   !dst_feature(dst, RTAX_FEATURE_NO_DSACK)) {
+               if (tcp_is_sack(tp) && sysctl_tcp_dsack) {
                        u32 end_seq = TCP_SKB_CB(skb)->end_seq;
 
                        if (after(TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt))
@@ -5428,11 +5421,10 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
        u8 *hash_location;
        struct inet_connection_sock *icsk = inet_csk(sk);
        struct tcp_sock *tp = tcp_sk(sk);
-       struct dst_entry *dst = __sk_dst_get(sk);
        struct tcp_cookie_values *cvp = tp->cookie_values;
        int saved_clamp = tp->rx_opt.mss_clamp;
 
-       tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0, dst);
+       tcp_parse_options(skb, &tp->rx_opt, &hash_location, 0);
 
        if (th->ack) {
                /* rfc793:
index 15e96030ce47d16fdd1095807d7b8283a02d1215..65b8ebfd078a35e909c7cbf0c4e1c7bda594ac2f 100644 (file)
@@ -1262,20 +1262,10 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
        tcp_rsk(req)->af_specific = &tcp_request_sock_ipv4_ops;
 #endif
 
-       ireq = inet_rsk(req);
-       ireq->loc_addr = daddr;
-       ireq->rmt_addr = saddr;
-       ireq->no_srccheck = inet_sk(sk)->transparent;
-       ireq->opt = tcp_v4_save_options(sk, skb);
-
-       dst = inet_csk_route_req(sk, req);
-       if(!dst)
-               goto drop_and_free;
-
        tcp_clear_options(&tmp_opt);
        tmp_opt.mss_clamp = TCP_MSS_DEFAULT;
        tmp_opt.user_mss  = tp->rx_opt.user_mss;
-       tcp_parse_options(skb, &tmp_opt, &hash_location, 0, dst);
+       tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
 
        if (tmp_opt.cookie_plus > 0 &&
            tmp_opt.saw_tstamp &&
@@ -1319,8 +1309,14 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
        tmp_opt.tstamp_ok = tmp_opt.saw_tstamp;
        tcp_openreq_init(req, &tmp_opt, skb);
 
+       ireq = inet_rsk(req);
+       ireq->loc_addr = daddr;
+       ireq->rmt_addr = saddr;
+       ireq->no_srccheck = inet_sk(sk)->transparent;
+       ireq->opt = tcp_v4_save_options(sk, skb);
+
        if (security_inet_conn_request(sk, skb, req))
-               goto drop_and_release;
+               goto drop_and_free;
 
        if (!want_cookie)
                TCP_ECN_create_request(req, tcp_hdr(skb));
@@ -1345,6 +1341,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
                 */
                if (tmp_opt.saw_tstamp &&
                    tcp_death_row.sysctl_tw_recycle &&
+                   (dst = inet_csk_route_req(sk, req)) != NULL &&
                    (peer = rt_get_peer((struct rtable *)dst)) != NULL &&
                    peer->v4daddr == saddr) {
                        if ((u32)get_seconds() - peer->tcp_ts_stamp < TCP_PAWS_MSL &&
index 87accec8d09727f0914a5f67c4cf3018a7c46738..f206ee5dda80b4e8c29f6576276bb1452e09c53e 100644 (file)
@@ -95,9 +95,9 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
        struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw);
        int paws_reject = 0;
 
+       tmp_opt.saw_tstamp = 0;
        if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) {
-               tmp_opt.tstamp_ok = 1;
-               tcp_parse_options(skb, &tmp_opt, &hash_location, 1, NULL);
+               tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
 
                if (tmp_opt.saw_tstamp) {
                        tmp_opt.ts_recent       = tcptw->tw_ts_recent;
@@ -526,9 +526,9 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,
        __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK);
        int paws_reject = 0;
 
-       if ((th->doff > (sizeof(*th) >> 2)) && (req->ts_recent)) {
-               tmp_opt.tstamp_ok = 1;
-               tcp_parse_options(skb, &tmp_opt, &hash_location, 1, NULL);
+       tmp_opt.saw_tstamp = 0;
+       if (th->doff > (sizeof(struct tcphdr)>>2)) {
+               tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
 
                if (tmp_opt.saw_tstamp) {
                        tmp_opt.ts_recent = req->ts_recent;
index 93316a96d820f5afc16984af390b2460e1b37904..383ce237640fdb8b2d79d205fd8cb8a7f123ee7f 100644 (file)
@@ -553,7 +553,6 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
                                struct tcp_md5sig_key **md5) {
        struct tcp_sock *tp = tcp_sk(sk);
        struct tcp_cookie_values *cvp = tp->cookie_values;
-       struct dst_entry *dst = __sk_dst_get(sk);
        unsigned remaining = MAX_TCP_OPTION_SPACE;
        u8 cookie_size = (!tp->rx_opt.cookie_out_never && cvp != NULL) ?
                         tcp_cookie_size_check(cvp->cookie_desired) :
@@ -581,22 +580,18 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb,
        opts->mss = tcp_advertise_mss(sk);
        remaining -= TCPOLEN_MSS_ALIGNED;
 
-       if (likely(sysctl_tcp_timestamps &&
-                  !dst_feature(dst, RTAX_FEATURE_NO_TSTAMP) &&
-                  *md5 == NULL)) {
+       if (likely(sysctl_tcp_timestamps && *md5 == NULL)) {
                opts->options |= OPTION_TS;
                opts->tsval = TCP_SKB_CB(skb)->when;
                opts->tsecr = tp->rx_opt.ts_recent;
                remaining -= TCPOLEN_TSTAMP_ALIGNED;
        }
-       if (likely(sysctl_tcp_window_scaling &&
-                  !dst_feature(dst, RTAX_FEATURE_NO_WSCALE))) {
+       if (likely(sysctl_tcp_window_scaling)) {
                opts->ws = tp->rx_opt.rcv_wscale;
                opts->options |= OPTION_WSCALE;
                remaining -= TCPOLEN_WSCALE_ALIGNED;
        }
-       if (likely(sysctl_tcp_sack &&
-                  !dst_feature(dst, RTAX_FEATURE_NO_SACK))) {
+       if (likely(sysctl_tcp_sack)) {
                opts->options |= OPTION_SACK_ADVERTISE;
                if (unlikely(!(OPTION_TS & opts->options)))
                        remaining -= TCPOLEN_SACKPERM_ALIGNED;
@@ -2527,9 +2522,7 @@ static void tcp_connect_init(struct sock *sk)
         * See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT.
         */
        tp->tcp_header_len = sizeof(struct tcphdr) +
-               (sysctl_tcp_timestamps &&
-               (!dst_feature(dst, RTAX_FEATURE_NO_TSTAMP) ?
-                 TCPOLEN_TSTAMP_ALIGNED : 0));
+               (sysctl_tcp_timestamps ? TCPOLEN_TSTAMP_ALIGNED : 0);
 
 #ifdef CONFIG_TCP_MD5SIG
        if (tp->af_specific->md5_lookup(sk, sk) != NULL)
@@ -2555,8 +2548,7 @@ static void tcp_connect_init(struct sock *sk)
                                  tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0),
                                  &tp->rcv_wnd,
                                  &tp->window_clamp,
-                                 (sysctl_tcp_window_scaling &&
-                                  !dst_feature(dst, RTAX_FEATURE_NO_WSCALE)),
+                                 sysctl_tcp_window_scaling,
                                  &rcv_wscale);
 
        tp->rx_opt.rcv_wscale = rcv_wscale;
index 1f9534846ca9a3b457e00266cd84ba7b2cb42450..f0126fdd7e04ba8fd3da4b90aadd663411b0617d 100644 (file)
@@ -216,9 +216,8 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
                 * force rand to be an odd multiple of UDP_HTABLE_SIZE
                 */
                rand = (rand | 1) * (udptable->mask + 1);
-               for (last = first + udptable->mask + 1;
-                    first != last;
-                    first++) {
+               last = first + udptable->mask + 1;
+               do {
                        hslot = udp_hashslot(udptable, net, first);
                        bitmap_zero(bitmap, PORTS_PER_CHAIN);
                        spin_lock_bh(&hslot->lock);
@@ -238,7 +237,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
                                snum += rand;
                        } while (snum != first);
                        spin_unlock_bh(&hslot->lock);
-               }
+               } while (++first != last);
                goto fail;
        } else {
                hslot = udp_hashslot(udptable, net, snum);
index 5f2ec208a8c3a5ff4a8b889f6c3c63e4f1f91b34..0956ebabbff2a604d809678074ce6e338c00d501 100644 (file)
@@ -20,6 +20,7 @@
 #include <net/ipv6.h>
 #include <net/inet_frag.h>
 
+#include <linux/netfilter_bridge.h>
 #include <linux/netfilter_ipv6.h>
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_helper.h>
@@ -187,6 +188,21 @@ out:
        return nf_conntrack_confirm(skb);
 }
 
+static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum,
+                                               struct sk_buff *skb)
+{
+#ifdef CONFIG_BRIDGE_NETFILTER
+       if (skb->nf_bridge &&
+           skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)
+               return IP6_DEFRAG_CONNTRACK_BRIDGE_IN;
+#endif
+       if (hooknum == NF_INET_PRE_ROUTING)
+               return IP6_DEFRAG_CONNTRACK_IN;
+       else
+               return IP6_DEFRAG_CONNTRACK_OUT;
+
+}
+
 static unsigned int ipv6_defrag(unsigned int hooknum,
                                struct sk_buff *skb,
                                const struct net_device *in,
@@ -199,8 +215,7 @@ static unsigned int ipv6_defrag(unsigned int hooknum,
        if (skb->nfct)
                return NF_ACCEPT;
 
-       reasm = nf_ct_frag6_gather(skb);
-
+       reasm = nf_ct_frag6_gather(skb, nf_ct6_defrag_user(hooknum, skb));
        /* queued */
        if (reasm == NULL)
                return NF_STOLEN;
index e0b9424fa1b2b3457cc99051b49c22105f5f3aff..312c20adc83f4fe93469010c511acf6b82aa42d2 100644 (file)
@@ -168,13 +168,14 @@ out:
 /* Creation primitives. */
 
 static __inline__ struct nf_ct_frag6_queue *
-fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst)
+fq_find(__be32 id, u32 user, struct in6_addr *src, struct in6_addr *dst)
 {
        struct inet_frag_queue *q;
        struct ip6_create_arg arg;
        unsigned int hash;
 
        arg.id = id;
+       arg.user = user;
        arg.src = src;
        arg.dst = dst;
 
@@ -559,7 +560,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
        return 0;
 }
 
-struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
+struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user)
 {
        struct sk_buff *clone;
        struct net_device *dev = skb->dev;
@@ -605,7 +606,7 @@ struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
        if (atomic_read(&nf_init_frags.mem) > nf_init_frags.high_thresh)
                nf_ct_frag6_evictor();
 
-       fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr);
+       fq = fq_find(fhdr->identification, user, &hdr->saddr, &hdr->daddr);
        if (fq == NULL) {
                pr_debug("Can't find and can't create new queue\n");
                goto ret_orig;
index 4d98549a68683d89b946a3cd0fa50eb5a1f58019..2cddea3bd6be9fcb935669ec26678e3b0c368b2e 100644 (file)
@@ -72,6 +72,7 @@ struct frag_queue
        struct inet_frag_queue  q;
 
        __be32                  id;             /* fragment id          */
+       u32                     user;
        struct in6_addr         saddr;
        struct in6_addr         daddr;
 
@@ -141,7 +142,7 @@ int ip6_frag_match(struct inet_frag_queue *q, void *a)
        struct ip6_create_arg *arg = a;
 
        fq = container_of(q, struct frag_queue, q);
-       return (fq->id == arg->id &&
+       return (fq->id == arg->id && fq->user == arg->user &&
                        ipv6_addr_equal(&fq->saddr, arg->src) &&
                        ipv6_addr_equal(&fq->daddr, arg->dst));
 }
@@ -163,6 +164,7 @@ void ip6_frag_init(struct inet_frag_queue *q, void *a)
        struct ip6_create_arg *arg = a;
 
        fq->id = arg->id;
+       fq->user = arg->user;
        ipv6_addr_copy(&fq->saddr, arg->src);
        ipv6_addr_copy(&fq->daddr, arg->dst);
 }
@@ -243,6 +245,7 @@ fq_find(struct net *net, __be32 id, struct in6_addr *src, struct in6_addr *dst,
        unsigned int hash;
 
        arg.id = id;
+       arg.user = IP6_DEFRAG_LOCAL_DELIVER;
        arg.src = src;
        arg.dst = dst;
 
@@ -705,7 +708,8 @@ static void ip6_frags_ns_sysctl_unregister(struct net *net)
 
        table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;
        unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr);
-       kfree(table);
+       if (!net_eq(net, &init_net))
+               kfree(table);
 }
 
 static struct ctl_table_header *ip6_ctl_header;
index db3b273038904be10b8c160d8f1b7226993acd42..c2bd74c5f8d979dee714b169750250250f1022e6 100644 (file)
@@ -2630,6 +2630,7 @@ struct ctl_table *ipv6_route_sysctl_init(struct net *net)
                table[6].data = &net->ipv6.sysctl.ip6_rt_gc_elasticity;
                table[7].data = &net->ipv6.sysctl.ip6_rt_mtu_expires;
                table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
+               table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
        }
 
        return table;
index 5b9af508b8f2b83f51945d93451fc9cf81d63cc4..7208a06576c6843996a02796804d33e61a524ee8 100644 (file)
@@ -185,6 +185,13 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
 
        NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESRECV);
 
+       /* check for timestamp cookie support */
+       memset(&tcp_opt, 0, sizeof(tcp_opt));
+       tcp_parse_options(skb, &tcp_opt, &hash_location, 0);
+
+       if (tcp_opt.saw_tstamp)
+               cookie_check_timestamp(&tcp_opt);
+
        ret = NULL;
        req = inet6_reqsk_alloc(&tcp6_request_sock_ops);
        if (!req)
@@ -218,6 +225,12 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
        req->expires = 0UL;
        req->retrans = 0;
        ireq->ecn_ok            = 0;
+       ireq->snd_wscale        = tcp_opt.snd_wscale;
+       ireq->rcv_wscale        = tcp_opt.rcv_wscale;
+       ireq->sack_ok           = tcp_opt.sack_ok;
+       ireq->wscale_ok         = tcp_opt.wscale_ok;
+       ireq->tstamp_ok         = tcp_opt.saw_tstamp;
+       req->ts_recent          = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
        treq->rcv_isn = ntohl(th->seq) - 1;
        treq->snt_isn = cookie;
 
@@ -253,21 +266,6 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
                        goto out_free;
        }
 
-       /* check for timestamp cookie support */
-       memset(&tcp_opt, 0, sizeof(tcp_opt));
-       tcp_parse_options(skb, &tcp_opt, &hash_location, 0, dst);
-
-       if (tcp_opt.saw_tstamp)
-               cookie_check_timestamp(&tcp_opt);
-
-       req->ts_recent          = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval : 0;
-
-       ireq->snd_wscale        = tcp_opt.snd_wscale;
-       ireq->rcv_wscale        = tcp_opt.rcv_wscale;
-       ireq->sack_ok           = tcp_opt.sack_ok;
-       ireq->wscale_ok         = tcp_opt.wscale_ok;
-       ireq->tstamp_ok         = tcp_opt.saw_tstamp;
-
        req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW);
        tcp_select_initial_window(tcp_full_space(sk), req->mss,
                                  &req->rcv_wnd, &req->window_clamp,
index ee9cf62458d4bb1f97c5f04f1639badb9ceda262..febfd595a40dd517d9deb5b2c574a0912669fff7 100644 (file)
@@ -1169,7 +1169,6 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
        struct inet6_request_sock *treq;
        struct ipv6_pinfo *np = inet6_sk(sk);
        struct tcp_sock *tp = tcp_sk(sk);
-       struct dst_entry *dst = __sk_dst_get(sk);
        __u32 isn = TCP_SKB_CB(skb)->when;
 #ifdef CONFIG_SYN_COOKIES
        int want_cookie = 0;
@@ -1208,7 +1207,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
        tcp_clear_options(&tmp_opt);
        tmp_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr);
        tmp_opt.user_mss = tp->rx_opt.user_mss;
-       tcp_parse_options(skb, &tmp_opt, &hash_location, 0, dst);
+       tcp_parse_options(skb, &tmp_opt, &hash_location, 0);
 
        if (tmp_opt.cookie_plus > 0 &&
            tmp_opt.saw_tstamp &&
index b001c361ad30976ff3a1de5bfe80fe2f0142b6f9..4300df35d37d0fee2796aa58c53467efa05b7799 100644 (file)
 #include <linux/poll.h>
 #include <linux/capability.h>
 #include <linux/ctype.h>       /* isspace() */
+#include <linux/string.h>      /* skip_spaces() */
 #include <asm/uaccess.h>
 #include <linux/init.h>
 
index 7dea882dbb750649b10616f00dcb9bb68697ec64..156020d138b507685633feda14fa747d11c90538 100644 (file)
@@ -76,9 +76,8 @@ irnet_ctrl_write(irnet_socket *       ap,
       /* Look at the next command */
       start = next;
 
-      /* Scrap whitespaces before the command */
-      while(isspace(*start))
-       start++;
+       /* Scrap whitespaces before the command */
+       start = skip_spaces(start);
 
       /* ',' is our command separator */
       next = strchr(start, ',');
@@ -133,8 +132,7 @@ irnet_ctrl_write(irnet_socket *     ap,
              char *    endp;
 
              /* Scrap whitespaces before the command */
-             while(isspace(*begp))
-               begp++;
+             begp = skip_spaces(begp);
 
              /* Convert argument to a number (last arg is the base) */
              addr = simple_strtoul(begp, &endp, 16);
index 1e428863574fe280966af5f04755f87bc1a4887f..c18286a2167b9987f15dd0f765d1ed8e2aa1625b 100644 (file)
@@ -221,7 +221,7 @@ static int afiucv_pm_restore_thaw(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops afiucv_pm_ops = {
+static const struct dev_pm_ops afiucv_pm_ops = {
        .prepare = afiucv_pm_prepare,
        .complete = afiucv_pm_complete,
        .freeze = afiucv_pm_freeze,
index 3b1f5f5f8de717e79c67576df739f604ea7c3dcf..fd8b28361a6415eaf4d98251a7be40fbc478f7bc 100644 (file)
@@ -93,7 +93,7 @@ static int iucv_pm_freeze(struct device *);
 static int iucv_pm_thaw(struct device *);
 static int iucv_pm_restore(struct device *);
 
-static struct dev_pm_ops iucv_pm_ops = {
+static const struct dev_pm_ops iucv_pm_ops = {
        .prepare = iucv_pm_prepare,
        .complete = iucv_pm_complete,
        .freeze = iucv_pm_freeze,
index 3787455fb69637b9f60a84e0afe09b7b5bba40ac..d7dcee68072820764d0910c79e740db052512073 100644 (file)
@@ -34,9 +34,28 @@ void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband,
 
        ht_cap->ht_supported = true;
 
-       ht_cap->cap = le16_to_cpu(ht_cap_ie->cap_info) & sband->ht_cap.cap;
-       ht_cap->cap &= ~IEEE80211_HT_CAP_SM_PS;
-       ht_cap->cap |= sband->ht_cap.cap & IEEE80211_HT_CAP_SM_PS;
+       /*
+        * The bits listed in this expression should be
+        * the same for the peer and us, if the station
+        * advertises more then we can't use those thus
+        * we mask them out.
+        */
+       ht_cap->cap = le16_to_cpu(ht_cap_ie->cap_info) &
+               (sband->ht_cap.cap |
+                ~(IEEE80211_HT_CAP_LDPC_CODING |
+                  IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
+                  IEEE80211_HT_CAP_GRN_FLD |
+                  IEEE80211_HT_CAP_SGI_20 |
+                  IEEE80211_HT_CAP_SGI_40 |
+                  IEEE80211_HT_CAP_DSSSCCK40));
+       /*
+        * The STBC bits are asymmetric -- if we don't have
+        * TX then mask out the peer's RX and vice versa.
+        */
+       if (!(sband->ht_cap.cap & IEEE80211_HT_CAP_TX_STBC))
+               ht_cap->cap &= ~IEEE80211_HT_CAP_RX_STBC;
+       if (!(sband->ht_cap.cap & IEEE80211_HT_CAP_RX_STBC))
+               ht_cap->cap &= ~IEEE80211_HT_CAP_TX_STBC;
 
        ampdu_info = ht_cap_ie->ampdu_params_info;
        ht_cap->ampdu_factor =
index 10d13856f86c5f338c2923e887e34ecf090f35d8..1f2db647bb5ccd3526d8fc40ef3e6aeb3cb68da6 100644 (file)
@@ -382,6 +382,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
 struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
                                        u8 *bssid,u8 *addr, u32 supp_rates)
 {
+       struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta;
        int band = local->hw.conf.channel->band;
@@ -397,6 +398,9 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
                return NULL;
        }
 
+       if (ifibss->state == IEEE80211_IBSS_MLME_SEARCH)
+               return NULL;
+
        if (compare_ether_addr(bssid, sdata->u.ibss.bssid))
                return NULL;
 
index 8116d1a96a4afc2f2d3e0bf19afb4b2232b5d815..0d2d94881f1f14fd3d42b692c144fea3b66909e3 100644 (file)
@@ -515,6 +515,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
         * and we need some headroom for passing the frame to monitor
         * interfaces, but never both at the same time.
         */
+       BUILD_BUG_ON(IEEE80211_TX_STATUS_HEADROOM !=
+                       sizeof(struct ieee80211_tx_status_rtap_hdr));
        local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
                                   sizeof(struct ieee80211_tx_status_rtap_hdr));
 
index d8d50fb5e823e395b5d160a6cf560f1678574847..c79e59f82fd9933bd98024d4d9b8551244c1f4a6 100644 (file)
@@ -915,6 +915,14 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
        sdata->u.mgd.flags &= ~(IEEE80211_STA_CONNECTION_POLL |
                                IEEE80211_STA_BEACON_POLL);
 
+       /*
+        * Always handle WMM once after association regardless
+        * of the first value the AP uses. Setting -1 here has
+        * that effect because the AP values is an unsigned
+        * 4-bit value.
+        */
+       sdata->u.mgd.wmm_last_param_set = -1;
+
        ieee80211_led_assoc(local, 1);
 
        sdata->vif.bss_conf.assoc = 1;
index 8834cc93c71691d993339ee99d285e392f7806ba..27ceaefd7bc8d3cb71a49bf51626192e8aacd3bd 100644 (file)
@@ -1419,6 +1419,10 @@ static bool need_dynamic_ps(struct ieee80211_local *local)
        if (!local->ps_sdata)
                return false;
 
+       /* No point if we're going to suspend */
+       if (local->quiescing)
+               return false;
+
        return true;
 }
 
index 78a6e924c7e13d11ae31b2acb42e4a2c2c1671af..dc76267e436ece4f322187d0170593ad5d9598d1 100644 (file)
@@ -1039,7 +1039,19 @@ int ieee80211_reconfig(struct ieee80211_local *local)
 
        /* restart hardware */
        if (local->open_count) {
+               /*
+                * Upon resume hardware can sometimes be goofy due to
+                * various platform / driver / bus issues, so restarting
+                * the device may at times not work immediately. Propagate
+                * the error.
+                */
                res = drv_start(local);
+               if (res) {
+                       WARN(local->suspended, "Harware became unavailable "
+                            "upon resume. This is could be a software issue"
+                            "prior to suspend or a harware issue\n");
+                       return res;
+               }
 
                ieee80211_led_radio(local, true);
        }
index b95699f00545a1f5f5733590071a813599bcae2f..847ffca401841e57e5ffec634c78a2dc472b82fa 100644 (file)
@@ -1366,6 +1366,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb,
               == sysctl_ip_vs_sync_threshold[0])) ||
             ((cp->protocol == IPPROTO_TCP) && (cp->old_state != cp->state) &&
              ((cp->state == IP_VS_TCP_S_FIN_WAIT) ||
+              (cp->state == IP_VS_TCP_S_CLOSE) ||
               (cp->state == IP_VS_TCP_S_CLOSE_WAIT) ||
               (cp->state == IP_VS_TCP_S_TIME_WAIT)))))
                ip_vs_sync_conn(cp);
index e55a6861d26f76ad7c1276cd6662e13cfda04ff1..6bde12da2fe0038660f6d3b7b195e8596c289e1e 100644 (file)
@@ -2714,6 +2714,8 @@ static int ip_vs_genl_parse_service(struct ip_vs_service_user_kern *usvc,
        if (!(nla_af && (nla_fwmark || (nla_port && nla_protocol && nla_addr))))
                return -EINVAL;
 
+       memset(usvc, 0, sizeof(*usvc));
+
        usvc->af = nla_get_u16(nla_af);
 #ifdef CONFIG_IP_VS_IPV6
        if (usvc->af != AF_INET && usvc->af != AF_INET6)
@@ -2901,6 +2903,8 @@ static int ip_vs_genl_parse_dest(struct ip_vs_dest_user_kern *udest,
        if (!(nla_addr && nla_port))
                return -EINVAL;
 
+       memset(udest, 0, sizeof(*udest));
+
        nla_memcpy(&udest->addr, nla_addr, sizeof(udest->addr));
        udest->port = nla_get_u16(nla_port);
 
index eb0ceb8465270d355d44842b1b82e91e41b6830e..fc70a49c0afd5a4effb35d67eaa4ddf2137d4d44 100644 (file)
@@ -482,8 +482,7 @@ static ssize_t recent_old_proc_write(struct file *file,
        if (copy_from_user(buf, input, size))
                return -EFAULT;
 
-       while (isspace(*c))
-               c++;
+       c = skip_spaces(c);
 
        if (size - (c - buf) < 5)
                return c - buf;
index 020562164b56efa584a29c7571925c3371021735..e0516a22be2e06052da233423be8b88dde1680f4 100644 (file)
@@ -415,7 +415,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
 {
        struct sock *sk = sock->sk;
        struct sockaddr_pkt *saddr = (struct sockaddr_pkt *)msg->msg_name;
-       struct sk_buff *skb;
+       struct sk_buff *skb = NULL;
        struct net_device *dev;
        __be16 proto = 0;
        int err;
@@ -437,6 +437,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
         */
 
        saddr->spkt_device[13] = 0;
+retry:
        rcu_read_lock();
        dev = dev_get_by_name_rcu(sock_net(sk), saddr->spkt_device);
        err = -ENODEV;
@@ -456,58 +457,48 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
        if (len > dev->mtu + dev->hard_header_len)
                goto out_unlock;
 
-       err = -ENOBUFS;
-       skb = sock_wmalloc(sk, len + LL_RESERVED_SPACE(dev), 0, GFP_KERNEL);
-
-       /*
-        * If the write buffer is full, then tough. At this level the user
-        * gets to deal with the problem - do your own algorithmic backoffs.
-        * That's far more flexible.
-        */
-
-       if (skb == NULL)
-               goto out_unlock;
-
-       /*
-        *      Fill it in
-        */
-
-       /* FIXME: Save some space for broken drivers that write a
-        * hard header at transmission time by themselves. PPP is the
-        * notable one here. This should really be fixed at the driver level.
-        */
-       skb_reserve(skb, LL_RESERVED_SPACE(dev));
-       skb_reset_network_header(skb);
-
-       /* Try to align data part correctly */
-       if (dev->header_ops) {
-               skb->data -= dev->hard_header_len;
-               skb->tail -= dev->hard_header_len;
-               if (len < dev->hard_header_len)
-                       skb_reset_network_header(skb);
+       if (!skb) {
+               size_t reserved = LL_RESERVED_SPACE(dev);
+               unsigned int hhlen = dev->header_ops ? dev->hard_header_len : 0;
+
+               rcu_read_unlock();
+               skb = sock_wmalloc(sk, len + reserved, 0, GFP_KERNEL);
+               if (skb == NULL)
+                       return -ENOBUFS;
+               /* FIXME: Save some space for broken drivers that write a hard
+                * header at transmission time by themselves. PPP is the notable
+                * one here. This should really be fixed at the driver level.
+                */
+               skb_reserve(skb, reserved);
+               skb_reset_network_header(skb);
+
+               /* Try to align data part correctly */
+               if (hhlen) {
+                       skb->data -= hhlen;
+                       skb->tail -= hhlen;
+                       if (len < hhlen)
+                               skb_reset_network_header(skb);
+               }
+               err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
+               if (err)
+                       goto out_free;
+               goto retry;
        }
 
-       /* Returns -EFAULT on error */
-       err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
+
        skb->protocol = proto;
        skb->dev = dev;
        skb->priority = sk->sk_priority;
        skb->mark = sk->sk_mark;
-       if (err)
-               goto out_free;
-
-       /*
-        *      Now send it
-        */
 
        dev_queue_xmit(skb);
        rcu_read_unlock();
        return len;
 
-out_free:
-       kfree_skb(skb);
 out_unlock:
        rcu_read_unlock();
+out_free:
+       kfree_skb(skb);
        return err;
 }
 
index 536ebe5d3f6bc1003a8fa7beef137345d7dea0a3..3b8992361042f62c0deca22b542e458670667782 100644 (file)
@@ -182,8 +182,8 @@ static int rds_ib_conn_info_visitor(struct rds_connection *conn,
                ic = conn->c_transport_data;
                dev_addr = &ic->i_cm_id->route.addr.dev_addr;
 
-               ib_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid);
-               ib_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid);
+               rdma_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid);
+               rdma_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid);
 
                rds_ibdev = ib_get_client_data(ic->i_cm_id->device, &rds_ib_client);
                iinfo->max_send_wr = ic->i_send_ring.w_nr;
index db224f7c2937115612f5b572725035951da56aca..b28fa8525b24029ffdfb026ee19a76d3597fc668 100644 (file)
@@ -184,8 +184,8 @@ static int rds_iw_conn_info_visitor(struct rds_connection *conn,
                ic = conn->c_transport_data;
                dev_addr = &ic->i_cm_id->route.addr.dev_addr;
 
-               ib_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid);
-               ib_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid);
+               rdma_addr_get_sgid(dev_addr, (union ib_gid *) &iinfo->src_gid);
+               rdma_addr_get_dgid(dev_addr, (union ib_gid *) &iinfo->dst_gid);
 
                rds_iwdev = ib_get_client_data(ic->i_cm_id->device, &rds_iw_client);
                iinfo->max_send_wr = ic->i_send_ring.w_nr;
index b94c3dd71015f8443b122706fcd08388ebe57247..769c386bd4288758635acde6ca77c401a49c61a8 100644 (file)
@@ -312,18 +312,6 @@ static struct file_system_type sock_fs_type = {
        .kill_sb =      kill_anon_super,
 };
 
-static int sockfs_delete_dentry(struct dentry *dentry)
-{
-       /*
-        * At creation time, we pretended this dentry was hashed
-        * (by clearing DCACHE_UNHASHED bit in d_flags)
-        * At delete time, we restore the truth : not hashed.
-        * (so that dput() can proceed correctly)
-        */
-       dentry->d_flags |= DCACHE_UNHASHED;
-       return 0;
-}
-
 /*
  * sockfs_dname() is called from d_path().
  */
@@ -334,7 +322,6 @@ static char *sockfs_dname(struct dentry *dentry, char *buffer, int buflen)
 }
 
 static const struct dentry_operations sockfs_dentry_operations = {
-       .d_delete = sockfs_delete_dentry,
        .d_dname  = sockfs_dname,
 };
 
@@ -355,68 +342,55 @@ static const struct dentry_operations sockfs_dentry_operations = {
  *     but we take care of internal coherence yet.
  */
 
-static int sock_alloc_fd(struct file **filep, int flags)
+static int sock_alloc_file(struct socket *sock, struct file **f, int flags)
 {
+       struct qstr name = { .name = "" };
+       struct path path;
+       struct file *file;
        int fd;
 
        fd = get_unused_fd_flags(flags);
-       if (likely(fd >= 0)) {
-               struct file *file = get_empty_filp();
-
-               *filep = file;
-               if (unlikely(!file)) {
-                       put_unused_fd(fd);
-                       return -ENFILE;
-               }
-       } else
-               *filep = NULL;
-       return fd;
-}
-
-static int sock_attach_fd(struct socket *sock, struct file *file, int flags)
-{
-       struct dentry *dentry;
-       struct qstr name = { .name = "" };
+       if (unlikely(fd < 0))
+               return fd;
 
-       dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name);
-       if (unlikely(!dentry))
+       path.dentry = d_alloc(sock_mnt->mnt_sb->s_root, &name);
+       if (unlikely(!path.dentry)) {
+               put_unused_fd(fd);
                return -ENOMEM;
+       }
+       path.mnt = mntget(sock_mnt);
 
-       dentry->d_op = &sockfs_dentry_operations;
-       /*
-        * We dont want to push this dentry into global dentry hash table.
-        * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
-        * This permits a working /proc/$pid/fd/XXX on sockets
-        */
-       dentry->d_flags &= ~DCACHE_UNHASHED;
-       d_instantiate(dentry, SOCK_INODE(sock));
+       path.dentry->d_op = &sockfs_dentry_operations;
+       d_instantiate(path.dentry, SOCK_INODE(sock));
+       SOCK_INODE(sock)->i_fop = &socket_file_ops;
 
-       sock->file = file;
-       init_file(file, sock_mnt, dentry, FMODE_READ | FMODE_WRITE,
+       file = alloc_file(&path, FMODE_READ | FMODE_WRITE,
                  &socket_file_ops);
-       SOCK_INODE(sock)->i_fop = &socket_file_ops;
+       if (unlikely(!file)) {
+               /* drop dentry, keep inode */
+               atomic_inc(&path.dentry->d_inode->i_count);
+               path_put(&path);
+               put_unused_fd(fd);
+               return -ENFILE;
+       }
+
+       sock->file = file;
        file->f_flags = O_RDWR | (flags & O_NONBLOCK);
        file->f_pos = 0;
        file->private_data = sock;
 
-       return 0;
+       *f = file;
+       return fd;
 }
 
 int sock_map_fd(struct socket *sock, int flags)
 {
        struct file *newfile;
-       int fd = sock_alloc_fd(&newfile, flags);
+       int fd = sock_alloc_file(sock, &newfile, flags);
 
-       if (likely(fd >= 0)) {
-               int err = sock_attach_fd(sock, newfile, flags);
-
-               if (unlikely(err < 0)) {
-                       put_filp(newfile);
-                       put_unused_fd(fd);
-                       return err;
-               }
+       if (likely(fd >= 0))
                fd_install(fd, newfile);
-       }
+
        return fd;
 }
 
@@ -1390,29 +1364,19 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol,
        if (err < 0)
                goto out_release_both;
 
-       fd1 = sock_alloc_fd(&newfile1, flags & O_CLOEXEC);
+       fd1 = sock_alloc_file(sock1, &newfile1, flags);
        if (unlikely(fd1 < 0)) {
                err = fd1;
                goto out_release_both;
        }
 
-       fd2 = sock_alloc_fd(&newfile2, flags & O_CLOEXEC);
+       fd2 = sock_alloc_file(sock2, &newfile2, flags);
        if (unlikely(fd2 < 0)) {
                err = fd2;
-               put_filp(newfile1);
-               put_unused_fd(fd1);
-               goto out_release_both;
-       }
-
-       err = sock_attach_fd(sock1, newfile1, flags & O_NONBLOCK);
-       if (unlikely(err < 0)) {
-               goto out_fd2;
-       }
-
-       err = sock_attach_fd(sock2, newfile2, flags & O_NONBLOCK);
-       if (unlikely(err < 0)) {
                fput(newfile1);
-               goto out_fd1;
+               put_unused_fd(fd1);
+               sock_release(sock2);
+               goto out;
        }
 
        audit_fd_pair(fd1, fd2);
@@ -1438,16 +1402,6 @@ out_release_1:
        sock_release(sock1);
 out:
        return err;
-
-out_fd2:
-       put_filp(newfile1);
-       sock_release(sock1);
-out_fd1:
-       put_filp(newfile2);
-       sock_release(sock2);
-       put_unused_fd(fd1);
-       put_unused_fd(fd2);
-       goto out;
 }
 
 /*
@@ -1551,17 +1505,13 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
         */
        __module_get(newsock->ops->owner);
 
-       newfd = sock_alloc_fd(&newfile, flags & O_CLOEXEC);
+       newfd = sock_alloc_file(newsock, &newfile, flags);
        if (unlikely(newfd < 0)) {
                err = newfd;
                sock_release(newsock);
                goto out_put;
        }
 
-       err = sock_attach_fd(newsock, newfile, flags & O_NONBLOCK);
-       if (err < 0)
-               goto out_fd_simple;
-
        err = security_socket_accept(sock, newsock);
        if (err)
                goto out_fd;
@@ -1591,11 +1541,6 @@ out_put:
        fput_light(sock->file, fput_needed);
 out:
        return err;
-out_fd_simple:
-       sock_release(newsock);
-       put_filp(newfile);
-       put_unused_fd(newfd);
-       goto out_put;
 out_fd:
        fput(newfile);
        put_unused_fd(newfd);
index cef74ba0666c2c7cab9a755a29c8ce5985a5dde7..aae6907fd546916317e69615dc1cb5e8040259c4 100644 (file)
@@ -210,6 +210,7 @@ void rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qnam
 {
        __rpc_init_priority_wait_queue(queue, qname, RPC_NR_PRIORITY);
 }
+EXPORT_SYMBOL_GPL(rpc_init_priority_wait_queue);
 
 void rpc_init_wait_queue(struct rpc_wait_queue *queue, const char *qname)
 {
@@ -384,6 +385,20 @@ static void rpc_wake_up_task_queue_locked(struct rpc_wait_queue *queue, struct r
                __rpc_do_wake_up_task(queue, task);
 }
 
+/*
+ * Tests whether rpc queue is empty
+ */
+int rpc_queue_empty(struct rpc_wait_queue *queue)
+{
+       int res;
+
+       spin_lock_bh(&queue->lock);
+       res = queue->qlen;
+       spin_unlock_bh(&queue->lock);
+       return (res == 0);
+}
+EXPORT_SYMBOL_GPL(rpc_queue_empty);
+
 /*
  * Wake up a task on a specific queue
  */
index b845e2293dfed933528f002f535213d25ff6478a..1c924ee0a1ef804105ec092d99badd880ca38b43 100644 (file)
@@ -16,8 +16,6 @@
 
 #define RPCDBG_FACILITY        RPCDBG_SVCXPRT
 
-#define SVC_MAX_WAKING 5
-
 static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt);
 static int svc_deferred_recv(struct svc_rqst *rqstp);
 static struct cache_deferred_req *svc_defer(struct cache_req *req);
@@ -306,7 +304,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
        struct svc_pool *pool;
        struct svc_rqst *rqstp;
        int cpu;
-       int thread_avail;
 
        if (!(xprt->xpt_flags &
              ((1<<XPT_CONN)|(1<<XPT_DATA)|(1<<XPT_CLOSE)|(1<<XPT_DEFERRED))))
@@ -318,6 +315,12 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
 
        spin_lock_bh(&pool->sp_lock);
 
+       if (!list_empty(&pool->sp_threads) &&
+           !list_empty(&pool->sp_sockets))
+               printk(KERN_ERR
+                      "svc_xprt_enqueue: "
+                      "threads and transports both waiting??\n");
+
        if (test_bit(XPT_DEAD, &xprt->xpt_flags)) {
                /* Don't enqueue dead transports */
                dprintk("svc: transport %p is dead, not enqueued\n", xprt);
@@ -358,15 +361,7 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
        }
 
  process:
-       /* Work out whether threads are available */
-       thread_avail = !list_empty(&pool->sp_threads);  /* threads are asleep */
-       if (pool->sp_nwaking >= SVC_MAX_WAKING) {
-               /* too many threads are runnable and trying to wake up */
-               thread_avail = 0;
-               pool->sp_stats.overloads_avoided++;
-       }
-
-       if (thread_avail) {
+       if (!list_empty(&pool->sp_threads)) {
                rqstp = list_entry(pool->sp_threads.next,
                                   struct svc_rqst,
                                   rq_list);
@@ -381,8 +376,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
                svc_xprt_get(xprt);
                rqstp->rq_reserved = serv->sv_max_mesg;
                atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
-               rqstp->rq_waking = 1;
-               pool->sp_nwaking++;
                pool->sp_stats.threads_woken++;
                BUG_ON(xprt->xpt_pool != pool);
                wake_up(&rqstp->rq_wait);
@@ -651,11 +644,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
                return -EINTR;
 
        spin_lock_bh(&pool->sp_lock);
-       if (rqstp->rq_waking) {
-               rqstp->rq_waking = 0;
-               pool->sp_nwaking--;
-               BUG_ON(pool->sp_nwaking < 0);
-       }
        xprt = svc_xprt_dequeue(pool);
        if (xprt) {
                rqstp->rq_xprt = xprt;
@@ -1204,16 +1192,15 @@ static int svc_pool_stats_show(struct seq_file *m, void *p)
        struct svc_pool *pool = p;
 
        if (p == SEQ_START_TOKEN) {
-               seq_puts(m, "# pool packets-arrived sockets-enqueued threads-woken overloads-avoided threads-timedout\n");
+               seq_puts(m, "# pool packets-arrived sockets-enqueued threads-woken threads-timedout\n");
                return 0;
        }
 
-       seq_printf(m, "%u %lu %lu %lu %lu %lu\n",
+       seq_printf(m, "%u %lu %lu %lu %lu\n",
                pool->sp_id,
                pool->sp_stats.packets,
                pool->sp_stats.sockets_queued,
                pool->sp_stats.threads_woken,
-               pool->sp_stats.overloads_avoided,
                pool->sp_stats.threads_timedout);
 
        return 0;
index 4a8f6558718ab501980e9b70dfd660a73fc869d2..d8c0411144978c22bfded676d3303b260bf84897 100644 (file)
@@ -655,23 +655,25 @@ static struct unix_gid *unix_gid_lookup(uid_t uid)
                return NULL;
 }
 
-static int unix_gid_find(uid_t uid, struct group_info **gip,
-                        struct svc_rqst *rqstp)
+static struct group_info *unix_gid_find(uid_t uid, struct svc_rqst *rqstp)
 {
-       struct unix_gid *ug = unix_gid_lookup(uid);
+       struct unix_gid *ug;
+       struct group_info *gi;
+       int ret;
+
+       ug = unix_gid_lookup(uid);
        if (!ug)
-               return -EAGAIN;
-       switch (cache_check(&unix_gid_cache, &ug->h, &rqstp->rq_chandle)) {
+               return ERR_PTR(-EAGAIN);
+       ret = cache_check(&unix_gid_cache, &ug->h, &rqstp->rq_chandle);
+       switch (ret) {
        case -ENOENT:
-               *gip = NULL;
-               return 0;
+               return ERR_PTR(-ENOENT);
        case 0:
-               *gip = ug->gi;
-               get_group_info(*gip);
+               gi = get_group_info(ug->gi);
                cache_put(&ug->h, &unix_gid_cache);
-               return 0;
+               return gi;
        default:
-               return -EAGAIN;
+               return ERR_PTR(-EAGAIN);
        }
 }
 
@@ -681,6 +683,8 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
        struct sockaddr_in *sin;
        struct sockaddr_in6 *sin6, sin6_storage;
        struct ip_map *ipm;
+       struct group_info *gi;
+       struct svc_cred *cred = &rqstp->rq_cred;
 
        switch (rqstp->rq_addr.ss_family) {
        case AF_INET:
@@ -721,6 +725,17 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
                        ip_map_cached_put(rqstp, ipm);
                        break;
        }
+
+       gi = unix_gid_find(cred->cr_uid, rqstp);
+       switch (PTR_ERR(gi)) {
+       case -EAGAIN:
+               return SVC_DROP;
+       case -ENOENT:
+               break;
+       default:
+               put_group_info(cred->cr_group_info);
+               cred->cr_group_info = gi;
+       }
        return SVC_OK;
 }
 
@@ -817,19 +832,11 @@ svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp)
        slen = svc_getnl(argv);                 /* gids length */
        if (slen > 16 || (len -= (slen + 2)*4) < 0)
                goto badcred;
-       if (unix_gid_find(cred->cr_uid, &cred->cr_group_info, rqstp)
-           == -EAGAIN)
+       cred->cr_group_info = groups_alloc(slen);
+       if (cred->cr_group_info == NULL)
                return SVC_DROP;
-       if (cred->cr_group_info == NULL) {
-               cred->cr_group_info = groups_alloc(slen);
-               if (cred->cr_group_info == NULL)
-                       return SVC_DROP;
-               for (i = 0; i < slen; i++)
-                       GROUP_AT(cred->cr_group_info, i) = svc_getnl(argv);
-       } else {
-               for (i = 0; i < slen ; i++)
-                       svc_getnl(argv);
-       }
+       for (i = 0; i < slen; i++)
+               GROUP_AT(cred->cr_group_info, i) = svc_getnl(argv);
        if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) {
                *authp = rpc_autherr_badverf;
                return SVC_DENIED;
index 1001db4912f723bada113e61d9211c1ce9a35998..82e6002c8d678654f2cdfd7c88baa4ee53586a0b 100644 (file)
@@ -93,7 +93,18 @@ void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len)
                        }
                }
 
-               WARN_ON(!bss);
+               /*
+                * We might be coming here because the driver reported
+                * a successful association at the same time as the
+                * user requested a deauth. In that case, we will have
+                * removed the BSS from the auth_bsses list due to the
+                * deauth request when the assoc response makes it. If
+                * the two code paths acquire the lock the other way
+                * around, that's just the standard situation of a
+                * deauth being requested while connected.
+                */
+               if (!bss)
+                       goto out;
        } else if (wdev->conn) {
                cfg80211_sme_failed_assoc(wdev);
                /*
index 12dfa62aad18da8d74b6652dcef2c85c120fc896..0c2cbbebca95572d3897a30285aa03f9032f814e 100644 (file)
@@ -601,7 +601,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
        struct cfg80211_registered_device *rdev;
        struct wiphy *wiphy;
        struct iw_scan_req *wreq = NULL;
-       struct cfg80211_scan_request *creq;
+       struct cfg80211_scan_request *creq = NULL;
        int i, err, n_channels = 0;
        enum ieee80211_band band;
 
@@ -694,8 +694,10 @@ int cfg80211_wext_siwscan(struct net_device *dev,
        /* translate "Scan for SSID" request */
        if (wreq) {
                if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
-                       if (wreq->essid_len > IEEE80211_MAX_SSID_LEN)
-                               return -EINVAL;
+                       if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) {
+                               err = -EINVAL;
+                               goto out;
+                       }
                        memcpy(creq->ssids[0].ssid, wreq->essid, wreq->essid_len);
                        creq->ssids[0].ssid_len = wreq->essid_len;
                }
@@ -707,12 +709,15 @@ int cfg80211_wext_siwscan(struct net_device *dev,
        err = rdev->ops->scan(wiphy, dev, creq);
        if (err) {
                rdev->scan_req = NULL;
-               kfree(creq);
+               /* creq will be freed below */
        } else {
                nl80211_send_scan_start(rdev, dev);
+               /* creq now owned by driver */
+               creq = NULL;
                dev_hold(dev);
        }
  out:
+       kfree(creq);
        cfg80211_unlock_rdev(rdev);
        return err;
 }
index cb81ca35b0d6eae85ecac2f7967d556971519afb..4725a549ad4d52bc1c791425413b21bfe9af9929 100644 (file)
@@ -1445,7 +1445,7 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
        if (!dev)
                goto free_dst;
 
-       /* Copy neighbout for reachability confirmation */
+       /* Copy neighbour for reachability confirmation */
        dst0->neighbour = neigh_clone(dst->neighbour);
 
        xfrm_init_path((struct xfrm_dst *)dst0, dst, nfheader_len);
index c67e73ecd5beac46e7212922737479568a95f919..ed2773edfe71bae99adc0a7b64a454912dfd4477 100644 (file)
@@ -149,6 +149,12 @@ ld-option = $(call try-run,\
 # $(Q)$(MAKE) $(build)=dir
 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
 
+###
+# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
+# Usage:
+# $(Q)$(MAKE) $(modbuiltin)=dir
+modbuiltin := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.modbuiltin obj
+
 # Prefix -I with $(srctree) if it is not an absolute path.
 # skip if -I has no parameter
 addtree = $(if $(patsubst -I%,%,$(1)), \
index 341b58902ffced6d70801f6e90ea85f60bcee88d..0b94d2fa3a883ce4cf1b9bdd6219e30bc338f480 100644 (file)
@@ -207,6 +207,7 @@ endif
 
 ifdef CONFIG_FTRACE_MCOUNT_RECORD
 cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
+       "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
        "$(if $(CONFIG_64BIT),64,32)" \
        "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" \
        "$(if $(part-of-module),1,0)" "$(@)";
index ffdafb26f5390b414d74ec07a1dde3078fd9a540..cd815ac2a50b41da74f32d950b7e759e60f28605 100644 (file)
@@ -127,6 +127,11 @@ _c_flags += $(if $(patsubst n%,, \
                $(CFLAGS_GCOV))
 endif
 
+ifdef CONFIG_SYMBOL_PREFIX
+_cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
+endif
+
+
 # If building the kernel in a separate objtree expand all occurrences
 # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
 
@@ -208,7 +213,7 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \
 
 # Bzip2 and LZMA do not include size in file... so we have to fake that;
 # append the size as a 32-bit littleendian number as gzip does.
-size_append = /bin/echo -ne $(shell                                    \
+size_append = printf $(shell                                           \
 dec_size=0;                                                            \
 for F in $1; do                                                                \
        fsize=$$(stat -c "%s" $$F);                                     \
diff --git a/scripts/Makefile.modbuiltin b/scripts/Makefile.modbuiltin
new file mode 100644 (file)
index 0000000..102a276
--- /dev/null
@@ -0,0 +1,55 @@
+# ==========================================================================
+# Generating modules.builtin
+# ==========================================================================
+
+src := $(obj)
+
+PHONY := __modbuiltin
+__modbuiltin:
+
+-include include/config/auto.conf
+# tristate.conf sets tristate variables to uppercase 'Y' or 'M'
+# That way, we get the list of built-in modules in obj-Y
+-include include/config/tristate.conf
+
+include scripts/Kbuild.include
+
+# The filename Kbuild has precedence over Makefile
+kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
+kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
+include $(kbuild-file)
+
+include scripts/Makefile.lib
+__subdir-Y     := $(patsubst %/,%,$(filter %/, $(obj-Y)))
+subdir-Y       += $(__subdir-Y)
+subdir-ym      := $(sort $(subdir-y) $(subdir-Y) $(subdir-m))
+subdir-ym      := $(addprefix $(obj)/,$(subdir-ym))
+obj-Y          := $(addprefix $(obj)/,$(obj-Y))
+
+modbuiltin-subdirs := $(patsubst %,%/modules.builtin, $(subdir-ym))
+modbuiltin-mods    := $(filter %.ko, $(obj-Y:.o=.ko))
+modbuiltin-target  := $(obj)/modules.builtin
+
+__modbuiltin: $(modbuiltin-target) $(subdir-ym)
+       @:
+
+$(modbuiltin-target): $(subdir-ym) FORCE
+       $(Q)(for m in $(modbuiltin-mods); do echo kernel/$$m; done;     \
+       cat /dev/null $(modbuiltin-subdirs)) > $@
+
+PHONY += FORCE
+
+FORCE:
+
+# Descending
+# ---------------------------------------------------------------------------
+
+PHONY += $(subdir-ym)
+$(subdir-ym):
+       $(Q)$(MAKE) $(modbuiltin)=$@
+
+
+# Declare the contents of the .PHONY variable as phony.  We keep that
+# information in a variable se we can use it in if_changed and friends.
+
+.PHONY: $(PHONY)
index 6bf21f83837dff5a42893d57dde41e8d225948e4..ea26b23de082b03cfa99483c52118f962a019a0e 100644 (file)
  * tells make when to remake a file.
  *
  * To use this list as-is however has the drawback that virtually
- * every file in the kernel includes <linux/autoconf.h>.
+ * every file in the kernel includes autoconf.h.
  *
- * If the user re-runs make *config, linux/autoconf.h will be
+ * If the user re-runs make *config, autoconf.h will be
  * regenerated.  make notices that and will rebuild every file which
  * includes autoconf.h, i.e. basically all files. This is extremely
  * annoying if the user just changed CONFIG_HIS_DRIVER from n to m.
  *
  * So we play the same trick that "mkdep" played before. We replace
- * the dependency on linux/autoconf.h by a dependency on every config
+ * the dependency on autoconf.h by a dependency on every config
  * option which is mentioned in any of the listed prequisites.
  *
  * kconfig populates a tree in include/config/ with an empty file
@@ -73,7 +73,7 @@
  *   cmd_<target> = <cmdline>
  *
  * and then basically copies the .<target>.d file to stdout, in the
- * process filtering out the dependency on linux/autoconf.h and adding
+ * process filtering out the dependency on autoconf.h and adding
  * dependencies on include/config/my/option.h for every
  * CONFIG_MY_OPTION encountered in any of the prequisites.
  *
@@ -324,7 +324,7 @@ static void parse_dep_file(void *map, size_t len)
                        p++;
                }
                memcpy(s, m, p-m); s[p-m] = 0;
-               if (strrcmp(s, "include/linux/autoconf.h") &&
+               if (strrcmp(s, "include/generated/autoconf.h") &&
                    strrcmp(s, "arch/um/include/uml-config.h") &&
                    strrcmp(s, ".ver")) {
                        printf("  %s \\\n", s);
index 287467a2e8c7afe3334105e6adf61afbe75a87cb..8060e06798b32990c58bba036161f01a74f3b789 100644 (file)
@@ -1,4 +1,4 @@
-/* ANSI-C code produced by gperf version 3.0.3 */
+/* ANSI-C code produced by gperf version 3.0.4 */
 /* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf  */
 
 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -34,7 +34,7 @@ struct resword;
 static const struct resword *is_reserved_word(register const char *str, register unsigned int len);
 #line 5 "scripts/genksyms/keywords.gperf"
 struct resword { const char *name; int token; };
-/* maximum key range = 62, duplicates = 0 */
+/* maximum key range = 64, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -48,39 +48,39 @@ is_reserved_hash (register const char *str, register unsigned int len)
 {
   static const unsigned char asso_values[] =
     {
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65,  5,
-      65, 65, 65, 65, 65, 65, 35, 65, 65, 65,
-       0, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65,  0, 65,  0, 65,  5,
-      20, 15, 10, 30, 65, 15, 65, 65, 20,  0,
-      10, 35, 20, 65, 10,  5,  0, 10,  5, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
-      65, 65, 65, 65, 65, 65
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67,  0,
+      67, 67, 67, 67, 67, 67, 15, 67, 67, 67,
+       0, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67,  0, 67,  0, 67,  5,
+      25, 20, 15, 30, 67, 15, 67, 67, 10,  0,
+      10, 40, 20, 67, 10,  5,  0, 10, 15, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
+      67, 67, 67, 67, 67, 67
     };
   return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]];
 }
 
 #ifdef __GNUC__
 __inline
-#ifdef __GNUC_STDC_INLINE__
+#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
 __attribute__ ((__gnu_inline__))
 #endif
 #endif
@@ -89,116 +89,119 @@ is_reserved_word (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 43,
+      TOTAL_KEYWORDS = 45,
       MIN_WORD_LENGTH = 3,
       MAX_WORD_LENGTH = 24,
       MIN_HASH_VALUE = 3,
-      MAX_HASH_VALUE = 64
+      MAX_HASH_VALUE = 66
     };
 
   static const struct resword wordlist[] =
     {
       {""}, {""}, {""},
-#line 28 "scripts/genksyms/keywords.gperf"
+#line 30 "scripts/genksyms/keywords.gperf"
       {"asm", ASM_KEYW},
       {""},
-#line 10 "scripts/genksyms/keywords.gperf"
+#line 12 "scripts/genksyms/keywords.gperf"
       {"__asm", ASM_KEYW},
       {""},
-#line 11 "scripts/genksyms/keywords.gperf"
+#line 13 "scripts/genksyms/keywords.gperf"
       {"__asm__", ASM_KEYW},
       {""}, {""},
-#line 54 "scripts/genksyms/keywords.gperf"
+#line 56 "scripts/genksyms/keywords.gperf"
       {"__typeof__", TYPEOF_KEYW},
       {""},
-#line 14 "scripts/genksyms/keywords.gperf"
+#line 16 "scripts/genksyms/keywords.gperf"
       {"__const", CONST_KEYW},
-#line 13 "scripts/genksyms/keywords.gperf"
-      {"__attribute__", ATTRIBUTE_KEYW},
 #line 15 "scripts/genksyms/keywords.gperf"
+      {"__attribute__", ATTRIBUTE_KEYW},
+#line 17 "scripts/genksyms/keywords.gperf"
       {"__const__", CONST_KEYW},
-#line 20 "scripts/genksyms/keywords.gperf"
+#line 22 "scripts/genksyms/keywords.gperf"
       {"__signed__", SIGNED_KEYW},
-#line 46 "scripts/genksyms/keywords.gperf"
+#line 48 "scripts/genksyms/keywords.gperf"
       {"static", STATIC_KEYW},
-#line 22 "scripts/genksyms/keywords.gperf"
-      {"__volatile__", VOLATILE_KEYW},
-#line 41 "scripts/genksyms/keywords.gperf"
+      {""},
+#line 43 "scripts/genksyms/keywords.gperf"
       {"int", INT_KEYW},
-#line 34 "scripts/genksyms/keywords.gperf"
+#line 36 "scripts/genksyms/keywords.gperf"
       {"char", CHAR_KEYW},
-#line 35 "scripts/genksyms/keywords.gperf"
+#line 37 "scripts/genksyms/keywords.gperf"
       {"const", CONST_KEYW},
-#line 47 "scripts/genksyms/keywords.gperf"
+#line 49 "scripts/genksyms/keywords.gperf"
       {"struct", STRUCT_KEYW},
-#line 26 "scripts/genksyms/keywords.gperf"
+#line 28 "scripts/genksyms/keywords.gperf"
       {"__restrict__", RESTRICT_KEYW},
-#line 27 "scripts/genksyms/keywords.gperf"
+#line 29 "scripts/genksyms/keywords.gperf"
       {"restrict", RESTRICT_KEYW},
-#line 25 "scripts/genksyms/keywords.gperf"
-      {"_restrict", RESTRICT_KEYW},
-#line 18 "scripts/genksyms/keywords.gperf"
+#line 9 "scripts/genksyms/keywords.gperf"
+      {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW},
+#line 20 "scripts/genksyms/keywords.gperf"
       {"__inline__", INLINE_KEYW},
-#line 12 "scripts/genksyms/keywords.gperf"
-      {"__attribute", ATTRIBUTE_KEYW},
       {""},
-#line 16 "scripts/genksyms/keywords.gperf"
+#line 24 "scripts/genksyms/keywords.gperf"
+      {"__volatile__", VOLATILE_KEYW},
+#line 7 "scripts/genksyms/keywords.gperf"
+      {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW},
+#line 27 "scripts/genksyms/keywords.gperf"
+      {"_restrict", RESTRICT_KEYW},
+      {""},
+#line 14 "scripts/genksyms/keywords.gperf"
+      {"__attribute", ATTRIBUTE_KEYW},
+#line 8 "scripts/genksyms/keywords.gperf"
+      {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW},
+#line 18 "scripts/genksyms/keywords.gperf"
       {"__extension__", EXTENSION_KEYW},
-#line 37 "scripts/genksyms/keywords.gperf"
+#line 39 "scripts/genksyms/keywords.gperf"
       {"enum", ENUM_KEYW},
-#line 21 "scripts/genksyms/keywords.gperf"
-      {"__volatile", VOLATILE_KEYW},
-#line 38 "scripts/genksyms/keywords.gperf"
+#line 10 "scripts/genksyms/keywords.gperf"
+      {"EXPORT_UNUSED_SYMBOL", EXPORT_SYMBOL_KEYW},
+#line 40 "scripts/genksyms/keywords.gperf"
       {"extern", EXTERN_KEYW},
       {""},
-#line 19 "scripts/genksyms/keywords.gperf"
+#line 21 "scripts/genksyms/keywords.gperf"
       {"__signed", SIGNED_KEYW},
-#line 9 "scripts/genksyms/keywords.gperf"
-      {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW},
-      {""},
-#line 53 "scripts/genksyms/keywords.gperf"
+#line 11 "scripts/genksyms/keywords.gperf"
+      {"EXPORT_UNUSED_SYMBOL_GPL", EXPORT_SYMBOL_KEYW},
+#line 51 "scripts/genksyms/keywords.gperf"
+      {"union", UNION_KEYW},
+#line 55 "scripts/genksyms/keywords.gperf"
       {"typeof", TYPEOF_KEYW},
-#line 48 "scripts/genksyms/keywords.gperf"
+#line 50 "scripts/genksyms/keywords.gperf"
       {"typedef", TYPEDEF_KEYW},
-#line 17 "scripts/genksyms/keywords.gperf"
+#line 19 "scripts/genksyms/keywords.gperf"
       {"__inline", INLINE_KEYW},
-#line 33 "scripts/genksyms/keywords.gperf"
+#line 35 "scripts/genksyms/keywords.gperf"
       {"auto", AUTO_KEYW},
-#line 49 "scripts/genksyms/keywords.gperf"
-      {"union", UNION_KEYW},
-      {""}, {""},
-#line 50 "scripts/genksyms/keywords.gperf"
-      {"unsigned", UNSIGNED_KEYW},
-#line 51 "scripts/genksyms/keywords.gperf"
-      {"void", VOID_KEYW},
-#line 44 "scripts/genksyms/keywords.gperf"
-      {"short", SHORT_KEYW},
+#line 23 "scripts/genksyms/keywords.gperf"
+      {"__volatile", VOLATILE_KEYW},
       {""}, {""},
 #line 52 "scripts/genksyms/keywords.gperf"
-      {"volatile", VOLATILE_KEYW},
-      {""},
-#line 39 "scripts/genksyms/keywords.gperf"
-      {"float", FLOAT_KEYW},
-#line 36 "scripts/genksyms/keywords.gperf"
-      {"double", DOUBLE_KEYW},
+      {"unsigned", UNSIGNED_KEYW},
       {""},
-#line 7 "scripts/genksyms/keywords.gperf"
-      {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW},
-      {""}, {""},
-#line 40 "scripts/genksyms/keywords.gperf"
+#line 46 "scripts/genksyms/keywords.gperf"
+      {"short", SHORT_KEYW},
+#line 42 "scripts/genksyms/keywords.gperf"
       {"inline", INLINE_KEYW},
-#line 8 "scripts/genksyms/keywords.gperf"
-      {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW},
-#line 43 "scripts/genksyms/keywords.gperf"
-      {"register", REGISTER_KEYW},
       {""},
-#line 24 "scripts/genksyms/keywords.gperf"
+#line 54 "scripts/genksyms/keywords.gperf"
+      {"volatile", VOLATILE_KEYW},
+#line 44 "scripts/genksyms/keywords.gperf"
+      {"long", LONG_KEYW},
+#line 26 "scripts/genksyms/keywords.gperf"
       {"_Bool", BOOL_KEYW},
-#line 45 "scripts/genksyms/keywords.gperf"
-      {"signed", SIGNED_KEYW},
       {""}, {""},
-#line 42 "scripts/genksyms/keywords.gperf"
-      {"long", LONG_KEYW}
+#line 45 "scripts/genksyms/keywords.gperf"
+      {"register", REGISTER_KEYW},
+#line 53 "scripts/genksyms/keywords.gperf"
+      {"void", VOID_KEYW},
+#line 41 "scripts/genksyms/keywords.gperf"
+      {"float", FLOAT_KEYW},
+#line 38 "scripts/genksyms/keywords.gperf"
+      {"double", DOUBLE_KEYW},
+      {""}, {""}, {""}, {""},
+#line 47 "scripts/genksyms/keywords.gperf"
+      {"signed", SIGNED_KEYW}
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
index 8fe977a4d57b7ada0480074e91ed01b298c61dc2..e6349acb6f2f36994071acd1c30889f1e4a2d583 100644 (file)
@@ -7,6 +7,8 @@ struct resword { const char *name; int token; }
 EXPORT_SYMBOL, EXPORT_SYMBOL_KEYW
 EXPORT_SYMBOL_GPL, EXPORT_SYMBOL_KEYW
 EXPORT_SYMBOL_GPL_FUTURE, EXPORT_SYMBOL_KEYW
+EXPORT_UNUSED_SYMBOL, EXPORT_SYMBOL_KEYW
+EXPORT_UNUSED_SYMBOL_GPL, EXPORT_SYMBOL_KEYW
 __asm, ASM_KEYW
 __asm__, ASM_KEYW
 __attribute, ATTRIBUTE_KEYW
index 81a67a458e78ddd494343e5746a195ef4e821440..445e8845f0a4c06ee5109e63471bab7769d2f3d5 100755 (executable)
@@ -13,7 +13,7 @@
 use strict;
 
 my $P = $0;
-my $V = '0.21';
+my $V = '0.23';
 
 use Getopt::Long qw(:config no_auto_abbrev);
 
@@ -23,16 +23,19 @@ my $email_usename = 1;
 my $email_maintainer = 1;
 my $email_list = 1;
 my $email_subscriber_list = 0;
-my $email_git = 1;
 my $email_git_penguin_chiefs = 0;
+my $email_git = 1;
+my $email_git_blame = 0;
 my $email_git_min_signatures = 1;
 my $email_git_max_maintainers = 5;
 my $email_git_min_percent = 5;
 my $email_git_since = "1-year-ago";
-my $email_git_blame = 0;
+my $email_hg_since = "-365";
 my $email_remove_duplicates = 1;
 my $output_multiline = 1;
 my $output_separator = ", ";
+my $output_roles = 0;
+my $output_rolestats = 0;
 my $scm = 0;
 my $web = 0;
 my $subsystem = 0;
@@ -64,21 +67,52 @@ my $penguin_chiefs = "\(" . join("|",@penguin_chief_names) . "\)";
 my $rfc822_lwsp = "(?:(?:\\r\\n)?[ \\t])";
 my $rfc822_char = '[\\000-\\377]';
 
+# VCS command support: class-like functions and strings
+
+my %VCS_cmds;
+
+my %VCS_cmds_git = (
+    "execute_cmd" => \&git_execute_cmd,
+    "available" => '(which("git") ne "") && (-d ".git")',
+    "find_signers_cmd" => "git log --since=\$email_git_since -- \$file",
+    "find_commit_signers_cmd" => "git log -1 \$commit",
+    "blame_range_cmd" => "git blame -l -L \$diff_start,+\$diff_length \$file",
+    "blame_file_cmd" => "git blame -l \$file",
+    "commit_pattern" => "^commit [0-9a-f]{40,40}",
+    "blame_commit_pattern" => "^([0-9a-f]+) "
+);
+
+my %VCS_cmds_hg = (
+    "execute_cmd" => \&hg_execute_cmd,
+    "available" => '(which("hg") ne "") && (-d ".hg")',
+    "find_signers_cmd" =>
+       "hg log --date=\$email_hg_since" .
+               " --template='commit {node}\\n{desc}\\n' -- \$file",
+    "find_commit_signers_cmd" => "hg log --template='{desc}\\n' -r \$commit",
+    "blame_range_cmd" => "",           # not supported
+    "blame_file_cmd" => "hg blame -c \$file",
+    "commit_pattern" => "^commit [0-9a-f]{40,40}",
+    "blame_commit_pattern" => "^([0-9a-f]+):"
+);
+
 if (!GetOptions(
                'email!' => \$email,
                'git!' => \$email_git,
+               'git-blame!' => \$email_git_blame,
                'git-chief-penguins!' => \$email_git_penguin_chiefs,
                'git-min-signatures=i' => \$email_git_min_signatures,
                'git-max-maintainers=i' => \$email_git_max_maintainers,
                'git-min-percent=i' => \$email_git_min_percent,
                'git-since=s' => \$email_git_since,
-               'git-blame!' => \$email_git_blame,
+               'hg-since=s' => \$email_hg_since,
                'remove-duplicates!' => \$email_remove_duplicates,
                'm!' => \$email_maintainer,
                'n!' => \$email_usename,
                'l!' => \$email_list,
                's!' => \$email_subscriber_list,
                'multiline!' => \$output_multiline,
+               'roles!' => \$output_roles,
+               'rolestats!' => \$output_rolestats,
                'separator=s' => \$output_separator,
                'subsystem!' => \$subsystem,
                'status!' => \$status,
@@ -90,8 +124,7 @@ if (!GetOptions(
                'v|version' => \$version,
                'h|help' => \$help,
                )) {
-    usage();
-    die "$P: invalid argument\n";
+    die "$P: invalid argument - use --help if necessary\n";
 }
 
 if ($help != 0) {
@@ -113,6 +146,10 @@ if ($output_separator ne ", ") {
     $output_multiline = 0;
 }
 
+if ($output_rolestats) {
+    $output_roles = 1;
+}
+
 my $selections = $email + $scm + $status + $subsystem + $web;
 if ($selections == 0) {
     usage();
@@ -175,7 +212,7 @@ if ($email_remove_duplicates) {
        next if ($line =~ m/^\s*$/);
 
        my ($name, $address) = parse_email($line);
-       $line = format_email($name, $address);
+       $line = format_email($name, $address, $email_usename);
 
        next if ($line =~ m/^\s*$/);
 
@@ -207,12 +244,10 @@ foreach my $file (@ARGV) {
        push(@files, $file);
        if (-f $file && $keywords) {
            open(FILE, "<$file") or die "$P: Can't open ${file}\n";
-           while (<FILE>) {
-               my $patch_line = $_;
-               foreach my $line (keys %keyword_hash) {
-                   if ($patch_line =~ m/^.*$keyword_hash{$line}/x) {
-                       push(@keyword_tvi, $line);
-                   }
+           my $text = do { local($/) ; <FILE> };
+           foreach my $line (keys %keyword_hash) {
+               if ($text =~ m/$keyword_hash{$line}/x) {
+                   push(@keyword_tvi, $line);
                }
            }
            close(FILE);
@@ -304,11 +339,11 @@ foreach my $file (@files) {
     }
 
     if ($email && $email_git) {
-       recent_git_signoffs($file);
+       vcs_file_signoffs($file);
     }
 
     if ($email && $email_git_blame) {
-       git_assign_blame($file);
+       vcs_file_blame($file);
     }
 }
 
@@ -324,11 +359,11 @@ if ($email) {
        if ($chief =~ m/^(.*):(.*)/) {
            my $email_address;
 
-           $email_address = format_email($1, $2);
+           $email_address = format_email($1, $2, $email_usename);
            if ($email_git_penguin_chiefs) {
-               push(@email_to, $email_address);
+               push(@email_to, [$email_address, 'chief penguin']);
            } else {
-               @email_to = grep(!/${email_address}/, @email_to);
+               @email_to = grep($_->[0] !~ /${email_address}/, @email_to);
            }
        }
     }
@@ -342,7 +377,7 @@ if ($email || $email_list) {
     if ($email_list) {
        @to = (@to, @list_to);
     }
-    output(uniq(@to));
+    output(merge_email(@to));
 }
 
 if ($scm) {
@@ -398,13 +433,16 @@ MAINTAINER field selection options:
     --git-min-signatures => number of signatures required (default: 1)
     --git-max-maintainers => maximum maintainers to add (default: 5)
     --git-min-percent => minimum percentage of commits required (default: 5)
-    --git-since => git history to use (default: 1-year-ago)
     --git-blame => use git blame to find modified commits for patch or file
+    --git-since => git history to use (default: 1-year-ago)
+    --hg-since => hg history to use (default: -365)
     --m => include maintainer(s) if any
     --n => include name 'Full Name <addr\@domain.tld>'
     --l => include list(s) if any
     --s => include subscriber only list(s) if any
     --remove-duplicates => minimize duplicate email names/addresses
+    --roles => show roles (status:subsystem, git-signer, list, etc...)
+    --rolestats => show roles and statistics (commits/total_commits, %)
   --scm => print SCM tree(s) if any
   --status => print status if any
   --subsystem => print subsystem name if any
@@ -430,11 +468,24 @@ Notes:
           directory are examined as git recurses directories.
           Any specified X: (exclude) pattern matches are _not_ ignored.
       Used with "--nogit", directory is used as a pattern match,
-         no individual file within the directory or subdirectory
-         is matched.
+          no individual file within the directory or subdirectory
+          is matched.
       Used with "--git-blame", does not iterate all files in directory
   Using "--git-blame" is slow and may add old committers and authors
       that are no longer active maintainers to the output.
+  Using "--roles" or "--rolestats" with git send-email --cc-cmd or any
+      other automated tools that expect only ["name"] <email address>
+      may not work because of additional output after <email address>.
+  Using "--rolestats" and "--git-blame" shows the #/total=% commits,
+      not the percentage of the entire file authored.  # of commits is
+      not a good measure of amount of code authored.  1 major commit may
+      contain a thousand lines, 5 trivial commits may modify a single line.
+  If git is not installed, but mercurial (hg) is installed and an .hg
+      repository exists, the following options apply to mercurial:
+          --git,
+          --git-min-signatures, --git-max-maintainers, --git-min-percent, and
+          --git-blame
+      Use --hg-since not --git-since to control date selection
 EOT
 }
 
@@ -493,7 +544,7 @@ sub parse_email {
 }
 
 sub format_email {
-    my ($name, $address) = @_;
+    my ($name, $address, $usename) = @_;
 
     my $formatted_email;
 
@@ -506,11 +557,11 @@ sub format_email {
        $name = "\"$name\"";
     }
 
-    if ($email_usename) {
+    if ($usename) {
        if ("$name" eq "") {
            $formatted_email = "$address";
        } else {
-           $formatted_email = "$name <${address}>";
+           $formatted_email = "$name <$address>";
        }
     } else {
        $formatted_email = $address;
@@ -547,6 +598,71 @@ sub find_ending_index {
     return $index;
 }
 
+sub get_maintainer_role {
+    my ($index) = @_;
+
+    my $i;
+    my $start = find_starting_index($index);
+    my $end = find_ending_index($index);
+
+    my $role;
+    my $subsystem = $typevalue[$start];
+    if (length($subsystem) > 20) {
+       $subsystem = substr($subsystem, 0, 17);
+       $subsystem =~ s/\s*$//;
+       $subsystem = $subsystem . "...";
+    }
+
+    for ($i = $start + 1; $i < $end; $i++) {
+       my $tv = $typevalue[$i];
+       if ($tv =~ m/^(\C):\s*(.*)/) {
+           my $ptype = $1;
+           my $pvalue = $2;
+           if ($ptype eq "S") {
+               $role = $pvalue;
+           }
+       }
+    }
+
+    $role = lc($role);
+    if      ($role eq "supported") {
+       $role = "supporter";
+    } elsif ($role eq "maintained") {
+       $role = "maintainer";
+    } elsif ($role eq "odd fixes") {
+       $role = "odd fixer";
+    } elsif ($role eq "orphan") {
+       $role = "orphan minder";
+    } elsif ($role eq "obsolete") {
+       $role = "obsolete minder";
+    } elsif ($role eq "buried alive in reporters") {
+       $role = "chief penguin";
+    }
+
+    return $role . ":" . $subsystem;
+}
+
+sub get_list_role {
+    my ($index) = @_;
+
+    my $i;
+    my $start = find_starting_index($index);
+    my $end = find_ending_index($index);
+
+    my $subsystem = $typevalue[$start];
+    if (length($subsystem) > 20) {
+       $subsystem = substr($subsystem, 0, 17);
+       $subsystem =~ s/\s*$//;
+       $subsystem = $subsystem . "...";
+    }
+
+    if ($subsystem eq "THE REST") {
+       $subsystem = "";
+    }
+
+    return $subsystem;
+}
+
 sub add_categories {
     my ($index) = @_;
 
@@ -564,17 +680,22 @@ sub add_categories {
            if ($ptype eq "L") {
                my $list_address = $pvalue;
                my $list_additional = "";
+               my $list_role = get_list_role($i);
+
+               if ($list_role ne "") {
+                   $list_role = ":" . $list_role;
+               }
                if ($list_address =~ m/([^\s]+)\s+(.*)$/) {
                    $list_address = $1;
                    $list_additional = $2;
                }
                if ($list_additional =~ m/subscribers-only/) {
                    if ($email_subscriber_list) {
-                       push(@list_to, $list_address);
+                       push(@list_to, [$list_address, "subscriber list${list_role}"]);
                    }
                } else {
                    if ($email_list) {
-                       push(@list_to, $list_address);
+                       push(@list_to, [$list_address, "open list${list_role}"]);
                    }
                }
            } elsif ($ptype eq "M") {
@@ -585,13 +706,14 @@ sub add_categories {
                        if ($tv =~ m/^(\C):\s*(.*)/) {
                            if ($1 eq "P") {
                                $name = $2;
-                               $pvalue = format_email($name, $address);
+                               $pvalue = format_email($name, $address, $email_usename);
                            }
                        }
                    }
                }
                if ($email_maintainer) {
-                   push_email_addresses($pvalue);
+                   my $role = get_maintainer_role($i);
+                   push_email_addresses($pvalue, $role);
                }
            } elsif ($ptype eq "T") {
                push(@scm, $pvalue);
@@ -618,7 +740,7 @@ sub email_inuse {
 }
 
 sub push_email_address {
-    my ($line) = @_;
+    my ($line, $role) = @_;
 
     my ($name, $address) = parse_email($line);
 
@@ -627,9 +749,9 @@ sub push_email_address {
     }
 
     if (!$email_remove_duplicates) {
-       push(@email_to, format_email($name, $address));
+       push(@email_to, [format_email($name, $address, $email_usename), $role]);
     } elsif (!email_inuse($name, $address)) {
-       push(@email_to, format_email($name, $address));
+       push(@email_to, [format_email($name, $address, $email_usename), $role]);
        $email_hash_name{$name}++;
        $email_hash_address{$address}++;
     }
@@ -638,24 +760,52 @@ sub push_email_address {
 }
 
 sub push_email_addresses {
-    my ($address) = @_;
+    my ($address, $role) = @_;
 
     my @address_list = ();
 
     if (rfc822_valid($address)) {
-       push_email_address($address);
+       push_email_address($address, $role);
     } elsif (@address_list = rfc822_validlist($address)) {
        my $array_count = shift(@address_list);
        while (my $entry = shift(@address_list)) {
-           push_email_address($entry);
+           push_email_address($entry, $role);
        }
     } else {
-       if (!push_email_address($address)) {
+       if (!push_email_address($address, $role)) {
            warn("Invalid MAINTAINERS address: '" . $address . "'\n");
        }
     }
 }
 
+sub add_role {
+    my ($line, $role) = @_;
+
+    my ($name, $address) = parse_email($line);
+    my $email = format_email($name, $address, $email_usename);
+
+    foreach my $entry (@email_to) {
+       if ($email_remove_duplicates) {
+           my ($entry_name, $entry_address) = parse_email($entry->[0]);
+           if ($name eq $entry_name || $address eq $entry_address) {
+               if ($entry->[1] eq "") {
+                   $entry->[1] = "$role";
+               } else {
+                   $entry->[1] = "$entry->[1],$role";
+               }
+           }
+       } else {
+           if ($email eq $entry->[0]) {
+               if ($entry->[1] eq "") {
+                   $entry->[1] = "$role";
+               } else {
+                   $entry->[1] = "$entry->[1],$role";
+               }
+           }
+       }
+    }
+}
+
 sub which {
     my ($bin) = @_;
 
@@ -669,7 +819,7 @@ sub which {
 }
 
 sub mailmap {
-    my @lines = @_;
+    my (@lines) = @_;
     my %hash;
 
     foreach my $line (@lines) {
@@ -678,14 +828,14 @@ sub mailmap {
            $hash{$name} = $address;
        } elsif ($address ne $hash{$name}) {
            $address = $hash{$name};
-           $line = format_email($name, $address);
+           $line = format_email($name, $address, $email_usename);
        }
        if (exists($mailmap{$name})) {
            my $obj = $mailmap{$name};
            foreach my $map_address (@$obj) {
                if (($map_address eq $address) &&
                    ($map_address ne $hash{$name})) {
-                   $line = format_email($name, $hash{$name});
+                   $line = format_email($name, $hash{$name}, $email_usename);
                }
            }
        }
@@ -694,34 +844,38 @@ sub mailmap {
     return @lines;
 }
 
-sub recent_git_signoffs {
-    my ($file) = @_;
-
-    my $sign_offs = "";
-    my $cmd = "";
-    my $output = "";
-    my $count = 0;
+sub git_execute_cmd {
+    my ($cmd) = @_;
     my @lines = ();
-    my %hash;
-    my $total_sign_offs;
 
-    if (which("git") eq "") {
-       warn("$P: git not found.  Add --nogit to options?\n");
-       return;
-    }
-    if (!(-d ".git")) {
-       warn("$P: .git directory not found.  Use a git repository for better results.\n");
-       warn("$P: perhaps 'git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git'\n");
-       return;
-    }
+    my $output = `$cmd`;
+    $output =~ s/^\s*//gm;
+    @lines = split("\n", $output);
 
-    $cmd = "git log --since=${email_git_since} -- ${file}";
+    return @lines;
+}
 
-    $output = `${cmd}`;
-    $output =~ s/^\s*//gm;
+sub hg_execute_cmd {
+    my ($cmd) = @_;
+    my @lines = ();
 
+    my $output = `$cmd`;
     @lines = split("\n", $output);
 
+    return @lines;
+}
+
+sub vcs_find_signers {
+    my ($cmd) = @_;
+    my @lines = ();
+    my $commits;
+
+    @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
+
+    my $pattern = $VCS_cmds{"commit_pattern"};
+
+    $commits = grep(/$pattern/, @lines);       # of commits
+
     @lines = grep(/^[-_        a-z]+by:.*\@.*$/i, @lines);
     if (!$email_git_penguin_chiefs) {
        @lines = grep(!/${penguin_chiefs}/i, @lines);
@@ -729,111 +883,183 @@ sub recent_git_signoffs {
     # cut -f2- -d":"
     s/.*:\s*(.+)\s*/$1/ for (@lines);
 
-    $total_sign_offs = @lines;
+## Reformat email addresses (with names) to avoid badly written signatures
 
-    if ($email_remove_duplicates) {
-       @lines = mailmap(@lines);
+    foreach my $line (@lines) {
+       my ($name, $address) = parse_email($line);
+       $line = format_email($name, $address, 1);
     }
 
-    @lines = sort(@lines);
-
-    # uniq -c
-    $hash{$_}++ for @lines;
-
-    # sort -rn
-    foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
-       my $sign_offs = $hash{$line};
-       $count++;
-       last if ($sign_offs < $email_git_min_signatures ||
-                $count > $email_git_max_maintainers ||
-                $sign_offs * 100 / $total_sign_offs < $email_git_min_percent);
-       push_email_address($line);
-    }
+    return ($commits, @lines);
 }
 
-sub save_commits {
-    my ($cmd, @commits) = @_;
-    my $output;
+sub vcs_save_commits {
+    my ($cmd) = @_;
     my @lines = ();
+    my @commits = ();
 
-    $output = `${cmd}`;
+    @lines = &{$VCS_cmds{"execute_cmd"}}($cmd);
 
-    @lines = split("\n", $output);
     foreach my $line (@lines) {
-       if ($line =~ m/^(\w+) /) {
-           push (@commits, $1);
+       if ($line =~ m/$VCS_cmds{"blame_commit_pattern"}/) {
+           push(@commits, $1);
        }
     }
+
     return @commits;
 }
 
-sub git_assign_blame {
+sub vcs_blame {
     my ($file) = @_;
-
-    my @lines = ();
-    my @commits = ();
     my $cmd;
-    my $output;
-    my %hash;
-    my $total_sign_offs;
-    my $count;
+    my @commits = ();
+
+    return @commits if (!(-f $file));
+
+    if (@range && $VCS_cmds{"blame_range_cmd"} eq "") {
+       my @all_commits = ();
+
+       $cmd = $VCS_cmds{"blame_file_cmd"};
+       $cmd =~ s/(\$\w+)/$1/eeg;               #interpolate $cmd
+       @all_commits = vcs_save_commits($cmd);
 
-    if (@range) {
        foreach my $file_range_diff (@range) {
            next if (!($file_range_diff =~ m/(.+):(.+):(.+)/));
            my $diff_file = $1;
            my $diff_start = $2;
            my $diff_length = $3;
-           next if (!("$file" eq "$diff_file"));
-           $cmd = "git blame -l -L $diff_start,+$diff_length $file";
-           @commits = save_commits($cmd, @commits);
+           next if ("$file" ne "$diff_file");
+           for (my $i = $diff_start; $i < $diff_start + $diff_length; $i++) {
+               push(@commits, $all_commits[$i]);
+           }
        }
-    } else {
-       if (-f $file) {
-           $cmd = "git blame -l $file";
-           @commits = save_commits($cmd, @commits);
+    } elsif (@range) {
+       foreach my $file_range_diff (@range) {
+           next if (!($file_range_diff =~ m/(.+):(.+):(.+)/));
+           my $diff_file = $1;
+           my $diff_start = $2;
+           my $diff_length = $3;
+           next if ("$file" ne "$diff_file");
+           $cmd = $VCS_cmds{"blame_range_cmd"};
+           $cmd =~ s/(\$\w+)/$1/eeg;           #interpolate $cmd
+           push(@commits, vcs_save_commits($cmd));
        }
+    } else {
+       $cmd = $VCS_cmds{"blame_file_cmd"};
+       $cmd =~ s/(\$\w+)/$1/eeg;               #interpolate $cmd
+       @commits = vcs_save_commits($cmd);
     }
 
-    $total_sign_offs = 0;
-    @commits = uniq(@commits);
-    foreach my $commit (@commits) {
-       $cmd = "git log -1 ${commit}";
+    return @commits;
+}
 
-       $output = `${cmd}`;
-       $output =~ s/^\s*//gm;
-       @lines = split("\n", $output);
+my $printed_novcs = 0;
+sub vcs_exists {
+    %VCS_cmds = %VCS_cmds_git;
+    return 1 if eval $VCS_cmds{"available"};
+    %VCS_cmds = %VCS_cmds_hg;
+    return 1 if eval $VCS_cmds{"available"};
+    %VCS_cmds = ();
+    if (!$printed_novcs) {
+       warn("$P: No supported VCS found.  Add --nogit to options?\n");
+       warn("Using a git repository produces better results.\n");
+       warn("Try Linus Torvalds' latest git repository using:\n");
+       warn("git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git\n");
+       $printed_novcs = 1;
+    }
+    return 0;
+}
 
-       @lines = grep(/^[-_     a-z]+by:.*\@.*$/i, @lines);
-       if (!$email_git_penguin_chiefs) {
-           @lines = grep(!/${penguin_chiefs}/i, @lines);
-       }
+sub vcs_assign {
+    my ($role, $divisor, @lines) = @_;
 
-       # cut -f2- -d":"
-       s/.*:\s*(.+)\s*/$1/ for (@lines);
+    my %hash;
+    my $count = 0;
 
-       $total_sign_offs += @lines;
+    return if (@lines <= 0);
 
-       if ($email_remove_duplicates) {
-           @lines = mailmap(@lines);
-       }
+    if ($divisor <= 0) {
+       warn("Bad divisor in " . (caller(0))[3] . ": $divisor\n");
+       $divisor = 1;
+    }
 
-       $hash{$_}++ for @lines;
+    if ($email_remove_duplicates) {
+       @lines = mailmap(@lines);
     }
 
-    $count = 0;
+    @lines = sort(@lines);
+
+    # uniq -c
+    $hash{$_}++ for @lines;
+
+    # sort -rn
     foreach my $line (sort {$hash{$b} <=> $hash{$a}} keys %hash) {
        my $sign_offs = $hash{$line};
+       my $percent = $sign_offs * 100 / $divisor;
+
+       $percent = 100 if ($percent > 100);
        $count++;
        last if ($sign_offs < $email_git_min_signatures ||
                 $count > $email_git_max_maintainers ||
-                $sign_offs * 100 / $total_sign_offs < $email_git_min_percent);
-       push_email_address($line);
+                $percent < $email_git_min_percent);
+       push_email_address($line, '');
+       if ($output_rolestats) {
+           my $fmt_percent = sprintf("%.0f", $percent);
+           add_role($line, "$role:$sign_offs/$divisor=$fmt_percent%");
+       } else {
+           add_role($line, $role);
+       }
+    }
+}
+
+sub vcs_file_signoffs {
+    my ($file) = @_;
+
+    my @signers = ();
+    my $commits;
+
+    return if (!vcs_exists());
+
+    my $cmd = $VCS_cmds{"find_signers_cmd"};
+    $cmd =~ s/(\$\w+)/$1/eeg;          # interpolate $cmd
+
+    ($commits, @signers) = vcs_find_signers($cmd);
+    vcs_assign("commit_signer", $commits, @signers);
+}
+
+sub vcs_file_blame {
+    my ($file) = @_;
+
+    my @signers = ();
+    my @commits = ();
+    my $total_commits;
+
+    return if (!vcs_exists());
+
+    @commits = vcs_blame($file);
+    @commits = uniq(@commits);
+    $total_commits = @commits;
+
+    foreach my $commit (@commits) {
+       my $commit_count;
+       my @commit_signers = ();
+
+       my $cmd = $VCS_cmds{"find_commit_signers_cmd"};
+       $cmd =~ s/(\$\w+)/$1/eeg;       #interpolate $cmd
+
+       ($commit_count, @commit_signers) = vcs_find_signers($cmd);
+       push(@signers, @commit_signers);
+    }
+
+    if ($from_filename) {
+       vcs_assign("commits", $total_commits, @signers);
+    } else {
+       vcs_assign("modified commits", $total_commits, @signers);
     }
 }
 
 sub uniq {
-    my @parms = @_;
+    my (@parms) = @_;
 
     my %saw;
     @parms = grep(!$saw{$_}++, @parms);
@@ -841,7 +1067,7 @@ sub uniq {
 }
 
 sub sort_and_uniq {
-    my @parms = @_;
+    my (@parms) = @_;
 
     my %saw;
     @parms = sort @parms;
@@ -849,8 +1075,27 @@ sub sort_and_uniq {
     return @parms;
 }
 
+sub merge_email {
+    my @lines;
+    my %saw;
+
+    for (@_) {
+       my ($address, $role) = @$_;
+       if (!$saw{$address}) {
+           if ($output_roles) {
+               push(@lines, "$address ($role)");
+           } else {
+               push(@lines, $address);
+           }
+           $saw{$address} = 1;
+       }
+    }
+
+    return @lines;
+}
+
 sub output {
-    my @parms = @_;
+    my (@parms) = @_;
 
     if ($output_multiline) {
        foreach my $line (@parms) {
@@ -947,11 +1192,9 @@ sub rfc822_validlist ($) {
     if ($s =~ m/^(?:$rfc822re)?(?:,(?:$rfc822re)?)*$/so &&
        $s =~ m/^$rfc822_char*$/) {
         while ($s =~ m/(?:^|,$rfc822_lwsp*)($rfc822re)/gos) {
-            push @r, $1;
+            push(@r, $1);
         }
         return wantarray ? (scalar(@r), @r) : 1;
     }
-    else {
-        return wantarray ? () : 0;
-    }
+    return wantarray ? () : 0;
 }
index 0308ecc10d5b133858a15bf9f46b3cb2f424d4d6..1ddcdd38d97ffb7c599c9ec940202ee18de55e64 100755 (executable)
@@ -8,8 +8,6 @@ do_command()
 {
        if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
                make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
-       elif [ -f ${srctree}/include/asm-$2/Kbuild ]; then
-               make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
        else
                printf "Ignoring arch: %s\n" ${arch}
        fi
index 80599e3a7994107cfa06f04e6a70c2d3ff2acbda..999e8a7d5bf7e1be6aa473bc865c4a4d2df36d75 100644 (file)
@@ -27,6 +27,7 @@ oldconfig: $(obj)/conf
        $< -o $(Kconfig)
 
 silentoldconfig: $(obj)/conf
+       $(Q)mkdir -p include/generated
        $< -s $(Kconfig)
 
 localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
index b55e72ff2fc676d4ae36ebe9028c6dee5b44d715..c4dec80cfd8e14a94792af807da0e9705256257d 100644 (file)
@@ -677,7 +677,7 @@ int conf_write_autoconf(void)
        struct symbol *sym;
        const char *str;
        const char *name;
-       FILE *out, *out_h;
+       FILE *out, *tristate, *out_h;
        time_t now;
        int i, l;
 
@@ -692,9 +692,16 @@ int conf_write_autoconf(void)
        if (!out)
                return 1;
 
+       tristate = fopen(".tmpconfig_tristate", "w");
+       if (!tristate) {
+               fclose(out);
+               return 1;
+       }
+
        out_h = fopen(".tmpconfig.h", "w");
        if (!out_h) {
                fclose(out);
+               fclose(tristate);
                return 1;
        }
 
@@ -707,6 +714,9 @@ int conf_write_autoconf(void)
                     "# %s"
                     "#\n",
                     sym_get_string_value(sym), ctime(&now));
+       fprintf(tristate, "#\n"
+                         "# Automatically generated - do not edit\n"
+                         "\n");
        fprintf(out_h, "/*\n"
                       " * Automatically generated C config: don't edit\n"
                       " * Linux kernel version: %s\n"
@@ -727,10 +737,14 @@ int conf_write_autoconf(void)
                                break;
                        case mod:
                                fprintf(out, "CONFIG_%s=m\n", sym->name);
+                               fprintf(tristate, "CONFIG_%s=M\n", sym->name);
                                fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name);
                                break;
                        case yes:
                                fprintf(out, "CONFIG_%s=y\n", sym->name);
+                               if (sym->type == S_TRISTATE)
+                                       fprintf(tristate, "CONFIG_%s=Y\n",
+                                                       sym->name);
                                fprintf(out_h, "#define CONFIG_%s 1\n", sym->name);
                                break;
                        }
@@ -772,13 +786,19 @@ int conf_write_autoconf(void)
                }
        }
        fclose(out);
+       fclose(tristate);
        fclose(out_h);
 
        name = getenv("KCONFIG_AUTOHEADER");
        if (!name)
-               name = "include/linux/autoconf.h";
+               name = "include/generated/autoconf.h";
        if (rename(".tmpconfig.h", name))
                return 1;
+       name = getenv("KCONFIG_TRISTATE");
+       if (!name)
+               name = "include/config/tristate.conf";
+       if (rename(".tmpconfig_tristate", name))
+               return 1;
        name = conf_get_autoconfig_name();
        /*
         * This must be the last step, kbuild has a dependency on auto.conf
index bce3d0fe6fbd8d3f51918098b16c2da45456987e..23dbad80cce9e16ce885d61163a5f79c1ca2b981 100755 (executable)
@@ -14,7 +14,7 @@ vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
 # So "sudo make install" won't change the "compiled by <user>"
 # do "compiled by root"
 
-if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then
+if [ -r $TARGET -a ! -O include/generated/autoconf.h ]; then
   vecho "  SKIPPED $TARGET"
   exit 0
 fi
index 11d69c35e5b4a182bf21acf5dda8f00fdecc148f..ff954f8168c1b58f9cb00d3909dcf25f76125f03 100644 (file)
@@ -8,7 +8,7 @@ modpost-objs    := modpost.o file2alias.o sumversion.o
 $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
 
 quiet_cmd_elfconfig = MKELF   $@
-      cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@
+      cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@
 
 $(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
        $(call if_changed,elfconfig)
index 6a96d47bd1e6e8cdb9ded3b0f0551fdf621dade9..639bca7ba559198f4b3013e72556e0e24ba557c6 100644 (file)
@@ -9,9 +9,6 @@ main(int argc, char **argv)
        unsigned char ei[EI_NIDENT];
        union { short s; char c[2]; } endian_test;
 
-       if (argc != 2) {
-               fprintf(stderr, "Error: no arch\n");
-       }
        if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
                fprintf(stderr, "Error: input truncated\n");
                return 1;
@@ -55,12 +52,6 @@ main(int argc, char **argv)
        else
                exit(1);
 
-       if ((strcmp(argv[1], "h8300") == 0)
-           || (strcmp(argv[1], "blackfin") == 0))
-               printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
-       else
-               printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
-
        return 0;
 }
 
index 801a16a1754532cee8f647ef178772209973120d..20923613467cf376db195e17a9df754e934ab470 100644 (file)
 #include <stdio.h>
 #include <ctype.h>
 #include "modpost.h"
+#include "../../include/generated/autoconf.h"
 #include "../../include/linux/license.h"
 
+/* Some toolchains use a `_' prefix for all user symbols. */
+#ifdef CONFIG_SYMBOL_PREFIX
+#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
+#else
+#define MODULE_SYMBOL_PREFIX ""
+#endif
+
+
 /* Are we using CONFIG_MODVERSIONS? */
 int modversions = 0;
 /* Warn about undefined symbols? (do so if we have vmlinux) */
@@ -451,8 +460,6 @@ static int parse_elf(struct elf_info *info, const char *filename)
                        info->export_unused_gpl_sec = i;
                else if (strcmp(secname, "__ksymtab_gpl_future") == 0)
                        info->export_gpl_future_sec = i;
-               else if (strcmp(secname, "__markers_strings") == 0)
-                       info->markers_strings_sec = i;
 
                if (sechdrs[i].sh_type != SHT_SYMTAB)
                        continue;
@@ -515,7 +522,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
                break;
        case SHN_ABS:
                /* CRC'd symbol */
-               if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
+               if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
                        crc = (unsigned int) sym->st_value;
                        sym_update_crc(symname + strlen(CRC_PFX), mod, crc,
                                        export);
@@ -559,7 +566,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
                break;
        default:
                /* All exported symbols */
-               if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
+               if (strncmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
                        sym_add_exported(symname + strlen(KSYMTAB_PFX), mod,
                                        export);
                }
@@ -1509,62 +1516,6 @@ static void check_sec_ref(struct module *mod, const char *modname,
        }
 }
 
-static void get_markers(struct elf_info *info, struct module *mod)
-{
-       const Elf_Shdr *sh = &info->sechdrs[info->markers_strings_sec];
-       const char *strings = (const char *) info->hdr + sh->sh_offset;
-       const Elf_Sym *sym, *first_sym, *last_sym;
-       size_t n;
-
-       if (!info->markers_strings_sec)
-               return;
-
-       /*
-        * First count the strings.  We look for all the symbols defined
-        * in the __markers_strings section named __mstrtab_*.  For
-        * these local names, the compiler puts a random .NNN suffix on,
-        * so the names don't correspond exactly.
-        */
-       first_sym = last_sym = NULL;
-       n = 0;
-       for (sym = info->symtab_start; sym < info->symtab_stop; sym++)
-               if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT &&
-                   sym->st_shndx == info->markers_strings_sec &&
-                   !strncmp(info->strtab + sym->st_name,
-                            "__mstrtab_", sizeof "__mstrtab_" - 1)) {
-                       if (first_sym == NULL)
-                               first_sym = sym;
-                       last_sym = sym;
-                       ++n;
-               }
-
-       if (n == 0)
-               return;
-
-       /*
-        * Now collect each name and format into a line for the output.
-        * Lines look like:
-        *      marker_name     vmlinux marker %s format %d
-        * The format string after the second \t can use whitespace.
-        */
-       mod->markers = NOFAIL(malloc(sizeof mod->markers[0] * n));
-       mod->nmarkers = n;
-
-       n = 0;
-       for (sym = first_sym; sym <= last_sym; sym++)
-               if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT &&
-                   sym->st_shndx == info->markers_strings_sec &&
-                   !strncmp(info->strtab + sym->st_name,
-                            "__mstrtab_", sizeof "__mstrtab_" - 1)) {
-                       const char *name = strings + sym->st_value;
-                       const char *fmt = strchr(name, '\0') + 1;
-                       char *line = NULL;
-                       asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
-                       NOFAIL(line);
-                       mod->markers[n++] = line;
-               }
-}
-
 static void read_symbols(char *modname)
 {
        const char *symname;
@@ -1620,8 +1571,6 @@ static void read_symbols(char *modname)
                get_src_version(modname, mod->srcversion,
                                sizeof(mod->srcversion)-1);
 
-       get_markers(&info, mod);
-
        parse_elf_finish(&info);
 
        /* Our trick to get versioning for module struct etc. - it's
@@ -1976,96 +1925,6 @@ static void write_dump(const char *fname)
        write_if_changed(&buf, fname);
 }
 
-static void add_marker(struct module *mod, const char *name, const char *fmt)
-{
-       char *line = NULL;
-       asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt);
-       NOFAIL(line);
-
-       mod->markers = NOFAIL(realloc(mod->markers, ((mod->nmarkers + 1) *
-                                                    sizeof mod->markers[0])));
-       mod->markers[mod->nmarkers++] = line;
-}
-
-static void read_markers(const char *fname)
-{
-       unsigned long size, pos = 0;
-       void *file = grab_file(fname, &size);
-       char *line;
-
-       if (!file)              /* No old markers, silently ignore */
-               return;
-
-       while ((line = get_next_line(&pos, file, size))) {
-               char *marker, *modname, *fmt;
-               struct module *mod;
-
-               marker = line;
-               modname = strchr(marker, '\t');
-               if (!modname)
-                       goto fail;
-               *modname++ = '\0';
-               fmt = strchr(modname, '\t');
-               if (!fmt)
-                       goto fail;
-               *fmt++ = '\0';
-               if (*marker == '\0' || *modname == '\0')
-                       goto fail;
-
-               mod = find_module(modname);
-               if (!mod) {
-                       mod = new_module(modname);
-                       mod->skip = 1;
-               }
-               if (is_vmlinux(modname)) {
-                       have_vmlinux = 1;
-                       mod->skip = 0;
-               }
-
-               if (!mod->skip)
-                       add_marker(mod, marker, fmt);
-       }
-       release_file(file, size);
-       return;
-fail:
-       fatal("parse error in markers list file\n");
-}
-
-static int compare_strings(const void *a, const void *b)
-{
-       return strcmp(*(const char **) a, *(const char **) b);
-}
-
-static void write_markers(const char *fname)
-{
-       struct buffer buf = { };
-       struct module *mod;
-       size_t i;
-
-       for (mod = modules; mod; mod = mod->next)
-               if ((!external_module || !mod->skip) && mod->markers != NULL) {
-                       /*
-                        * Sort the strings so we can skip duplicates when
-                        * we write them out.
-                        */
-                       qsort(mod->markers, mod->nmarkers,
-                             sizeof mod->markers[0], &compare_strings);
-                       for (i = 0; i < mod->nmarkers; ++i) {
-                               char *line = mod->markers[i];
-                               buf_write(&buf, line, strlen(line));
-                               while (i + 1 < mod->nmarkers &&
-                                      !strcmp(mod->markers[i],
-                                              mod->markers[i + 1]))
-                                       free(mod->markers[i++]);
-                               free(mod->markers[i]);
-                       }
-                       free(mod->markers);
-                       mod->markers = NULL;
-               }
-
-       write_if_changed(&buf, fname);
-}
-
 struct ext_sym_list {
        struct ext_sym_list *next;
        const char *file;
@@ -2077,8 +1936,6 @@ int main(int argc, char **argv)
        struct buffer buf = { };
        char *kernel_read = NULL, *module_read = NULL;
        char *dump_write = NULL;
-       char *markers_read = NULL;
-       char *markers_write = NULL;
        int opt;
        int err;
        struct ext_sym_list *extsym_iter;
@@ -2122,12 +1979,6 @@ int main(int argc, char **argv)
                case 'w':
                        warn_unresolved = 1;
                        break;
-                       case 'M':
-                               markers_write = optarg;
-                               break;
-                       case 'K':
-                               markers_read = optarg;
-                               break;
                default:
                        exit(1);
                }
@@ -2182,11 +2033,5 @@ int main(int argc, char **argv)
                     "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n",
                     sec_mismatch_count);
 
-       if (markers_read)
-               read_markers(markers_read);
-
-       if (markers_write)
-               write_markers(markers_write);
-
        return err;
 }
index 09f58e33d227bf3fecb88d555f33cd52fc4375a7..be987a44f2502139871c559654f479dd1bf05b50 100644 (file)
@@ -112,8 +112,6 @@ struct module {
        int has_init;
        int has_cleanup;
        struct buffer dev_table_buf;
-       char **markers;
-       size_t nmarkers;
        char         srcversion[25];
 };
 
@@ -128,7 +126,6 @@ struct elf_info {
        Elf_Section  export_gpl_sec;
        Elf_Section  export_unused_gpl_sec;
        Elf_Section  export_gpl_future_sec;
-       Elf_Section  markers_strings_sec;
        const char   *strtab;
        char         *modinfo;
        unsigned int modinfo_len;
index f67cc885c807f0649b508a534d19566dd4de9abe..62fcc3a7f4d35f4ae29c959baac684f154c9aafd 100644 (file)
@@ -77,9 +77,27 @@ clean-files += $(objtree)/binkernel.spec
 
 # Deb target
 # ---------------------------------------------------------------------------
+quiet_cmd_builddeb = BUILDDEB
+      cmd_builddeb = set -e; \
+       test `id -u` = 0 || \
+       test -n "$(KBUILD_PKG_ROOTCMD)" || { \
+               which fakeroot >/dev/null 2>&1 && \
+               KBUILD_PKG_ROOTCMD="fakeroot -u"; \
+       } || { \
+               echo; \
+               echo "builddeb must be run as root (or using fakeroot)."; \
+               echo "KBUILD_PKG_ROOTCMD is unset and fakeroot not found."; \
+               echo "Try setting KBUILD_PKG_ROOTCMD to a command to acquire"; \
+               echo "root privileges (e.g., 'fakeroot -u' or 'sudo')."; \
+               false; \
+       } && \
+       \
+       $$KBUILD_PKG_ROOTCMD $(CONFIG_SHELL) \
+               $(srctree)/scripts/package/builddeb
+
 deb-pkg: FORCE
        $(MAKE) KBUILD_SRC=
-       $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
+       $(call cmd,builddeb)
 
 clean-dirs += $(objtree)/debian/
 
index b1fd48db1640d50320de63ede7e3a7e699794408..51b2aa0acb82db959b67ca1170439c436ae0ab3b 100644 (file)
@@ -101,7 +101,11 @@ esac
 #
 (
        cd "${tmpdir}"
-       tar cf - . | ${compress} > "${tarball}${file_ext}"
+       opts=
+       if tar --owner=root --group=root --help >/dev/null 2>&1; then
+               opts="--owner=root --group=root"
+       fi
+       tar cf - . $opts | ${compress} > "${tarball}${file_ext}"
 )
 
 echo "Tarball successfully created in ${tarball}${file_ext}"
index 9cf0a6fad6ba8bc03a11dca5e658fde8ed8f6af4..92f09fe9639ecdab0884330d049ae6b391765be7 100755 (executable)
@@ -113,13 +113,13 @@ $P =~ s@.*/@@g;
 
 my $V = '0.1';
 
-if ($#ARGV != 10) {
-       print "usage: $P arch bits objdump objcopy cc ld nm rm mv is_module inputfile\n";
+if ($#ARGV != 11) {
+       print "usage: $P arch endian bits objdump objcopy cc ld nm rm mv is_module inputfile\n";
        print "version: $V\n";
        exit(1);
 }
 
-my ($arch, $bits, $objdump, $objcopy, $cc,
+my ($arch, $endian, $bits, $objdump, $objcopy, $cc,
     $ld, $nm, $rm, $mv, $is_module, $inputfile) = @ARGV;
 
 # This file refers to mcount and shouldn't be ftraced, so lets' ignore it
@@ -295,6 +295,58 @@ if ($arch eq "x86_64") {
     $ld .= " -m elf64_sparc";
     $cc .= " -m64";
     $objcopy .= " -O elf64-sparc";
+} elsif ($arch eq "mips") {
+    # To enable module support, we need to enable the -mlong-calls option
+    # of gcc for module, after using this option, we can not get the real
+    # offset of the calling to _mcount, but the offset of the lui
+    # instruction or the addiu one. herein, we record the address of the
+    # first one, and then we can replace this instruction by a branch
+    # instruction to jump over the profiling function to filter the
+    # indicated functions, or swith back to the lui instruction to trace
+    # them, which means dynamic tracing.
+    #
+    #       c: 3c030000        lui     v1,0x0
+    #                  c: R_MIPS_HI16  _mcount
+    #                  c: R_MIPS_NONE  *ABS*
+    #                  c: R_MIPS_NONE  *ABS*
+    #      10: 64630000        daddiu  v1,v1,0
+    #                  10: R_MIPS_LO16 _mcount
+    #                  10: R_MIPS_NONE *ABS*
+    #                  10: R_MIPS_NONE *ABS*
+    #      14: 03e0082d        move    at,ra
+    #      18: 0060f809        jalr    v1
+    #
+    # for the kernel:
+    #
+    #     10:   03e0082d        move    at,ra
+    #    14:   0c000000        jal     0 <loongson_halt>
+    #                    14: R_MIPS_26   _mcount
+    #                    14: R_MIPS_NONE *ABS*
+    #                    14: R_MIPS_NONE *ABS*
+    #   18:   00020021        nop
+    if ($is_module eq "0") {
+           $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
+    } else {
+           $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$";
+    }
+    $objdump .= " -Melf-trad".$endian."mips ";
+
+    if ($endian eq "big") {
+           $endian = " -EB ";
+           $ld .= " -melf".$bits."btsmip";
+    } else {
+           $endian = " -EL ";
+           $ld .= " -melf".$bits."ltsmip";
+    }
+
+    $cc .= " -mno-abicalls -fno-pic -mabi=" . $bits . $endian;
+    $ld .= $endian;
+
+    if ($bits == 64) {
+           $function_regex =
+               "^([0-9a-fA-F]+)\\s+<(.|[^\$]L.*?|\$[^L].*?|[^\$][^L].*?)>:";
+           $type = ".dword";
+    }
 } elsif ($arch eq "microblaze") {
     # Microblaze calls '_mcount' instead of plain 'mcount'.
     $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
index d52f7a01557c1b28cf3155a640c175ce613558aa..1a0c44d7c4a75308ca6addf915a6951cf30a603d 100755 (executable)
@@ -89,7 +89,13 @@ all_defconfigs()
 
 docscope()
 {
-       (echo \-k; echo \-q; all_sources) > cscope.files
+       # always use absolute paths for cscope, as recommended by cscope
+       # upstream
+       case "$tree" in
+               /*) ;;
+               *) tree=$PWD/$tree ;;
+       esac
+       (cd /; echo \-k; echo \-q; all_sources) > cscope.files
        cscope -b -f cscope.out
 }
 
index 30d459fb0709a70a97d6ddd5f8d635e8bb467490..44d39785e50da4a67bdde65a86e55b6a795e55b3 100644 (file)
@@ -1,13 +1,5 @@
 /*
- * Copyright (c) 2002 - 2005 Tony Finch <dot@dotat.at>.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by Dave Yost.
- * It was rewritten to support ANSI C by Tony Finch. The original version of
- * unifdef carried the following copyright notice. None of its code remains
- * in this version (though some of the names remain).
- *
- * Copyright (c) 1985, 1993
- *     The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 2002 - 2009 Tony Finch <dot@dotat.at>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * SUCH DAMAGE.
  */
 
-#include <sys/cdefs.h>
+/*
+ * This code was derived from software contributed to Berkeley by Dave Yost.
+ * It was rewritten to support ANSI C by Tony Finch. The original version
+ * of unifdef carried the 4-clause BSD copyright licence. None of its code
+ * remains in this version (though some of the names remain) so it now
+ * carries a more liberal licence.
+ *
+ * The latest version is available from http://dotat.at/prog/unifdef
+ */
 
-#ifndef lint
-#if 0
-static const char copyright[] =
-"@(#) Copyright (c) 1985, 1993\n\
-       The Regents of the University of California.  All rights reserved.\n";
-#endif
-#ifdef __IDSTRING
-__IDSTRING(Berkeley, "@(#)unifdef.c    8.1 (Berkeley) 6/6/93");
-__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.8 2000/07/03 02:51:36 matt Exp $");
-__IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.171 2005/03/08 12:38:48 fanf2 Exp $");
-#endif
-#endif /* not lint */
-#ifdef __FBSDID
-__FBSDID("$FreeBSD: /repoman/r/ncvs/src/usr.bin/unifdef/unifdef.c,v 1.20 2005/05/21 09:55:09 ru Exp $");
-#endif
+static const char * const copyright[] = {
+    "@(#) Copyright (c) 2002 - 2009 Tony Finch <dot@dotat.at>\n",
+    "$dotat: unifdef/unifdef.c,v 1.190 2009/11/27 17:21:26 fanf2 Exp $",
+};
 
 /*
  * unifdef - remove ifdef'ed lines
@@ -72,8 +61,6 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/usr.bin/unifdef/unifdef.c,v 1.20 2005/05
 #include <string.h>
 #include <unistd.h>
 
-size_t strlcpy(char *dst, const char *src, size_t siz);
-
 /* types of input lines: */
 typedef enum {
        LT_TRUEI,               /* a true #if with ignore flag */
@@ -90,6 +77,7 @@ typedef enum {
        LT_DODGY_LAST = LT_DODGY + LT_ENDIF,
        LT_PLAIN,               /* ordinary line */
        LT_EOF,                 /* end of file */
+       LT_ERROR,               /* unevaluable #if */
        LT_COUNT
 } Linetype;
 
@@ -100,7 +88,7 @@ static char const * const linetype_name[] = {
        "DODGY IF", "DODGY TRUE", "DODGY FALSE",
        "DODGY ELIF", "DODGY ELTRUE", "DODGY ELFALSE",
        "DODGY ELSE", "DODGY ENDIF",
-       "PLAIN", "EOF"
+       "PLAIN", "EOF", "ERROR"
 };
 
 /* state of #if processing */
@@ -168,11 +156,13 @@ static char const * const linestate_name[] = {
  * Globals.
  */
 
+static bool             compblank;             /* -B: compress blank lines */
+static bool             lnblank;               /* -b: blank deleted lines */
 static bool             complement;            /* -c: do the complement */
 static bool             debugging;             /* -d: debugging reports */
 static bool             iocccok;               /* -e: fewer IOCCC errors */
+static bool             strictlogic;           /* -K: keep ambiguous #ifs */
 static bool             killconsts;            /* -k: eval constant #ifs */
-static bool             lnblank;               /* -l: blank deleted lines */
 static bool             lnnum;                 /* -n: add #line directives */
 static bool             symlist;               /* -s: output symbol list */
 static bool             text;                  /* -t: this is a text file */
@@ -196,7 +186,9 @@ static bool             ignoring[MAXDEPTH]; /* ignore comments state */
 static int              stifline[MAXDEPTH];    /* start of current #if */
 static int              depth;                 /* current #if nesting */
 static int              delcount;              /* count of deleted lines */
-static bool             keepthis;              /* don't delete constant #if */
+static unsigned         blankcount;            /* count of blank lines */
+static unsigned         blankmax;              /* maximum recent blankcount */
+static bool             constexpr;             /* constant #if expression */
 
 static int              exitstat;              /* program exit status */
 
@@ -206,13 +198,14 @@ static void             done(void);
 static void             error(const char *);
 static int              findsym(const char *);
 static void             flushline(bool);
-static Linetype         get_line(void);
+static Linetype         parseline(void);
 static Linetype         ifeval(const char **);
 static void             ignoreoff(void);
 static void             ignoreon(void);
 static void             keywordedit(const char *);
 static void             nest(void);
 static void             process(void);
+static const char      *skipargs(const char *);
 static const char      *skipcomment(const char *);
 static const char      *skipsym(const char *);
 static void             state(Ifstate);
@@ -220,7 +213,7 @@ static int              strlcmp(const char *, const char *, size_t);
 static void             unnest(void);
 static void             usage(void);
 
-#define endsym(c) (!isalpha((unsigned char)c) && !isdigit((unsigned char)c) && c != '_')
+#define endsym(c) (!isalnum((unsigned char)c) && c != '_')
 
 /*
  * The main program.
@@ -230,7 +223,7 @@ main(int argc, char *argv[])
 {
        int opt;
 
-       while ((opt = getopt(argc, argv, "i:D:U:I:cdeklnst")) != -1)
+       while ((opt = getopt(argc, argv, "i:D:U:I:BbcdeKklnst")) != -1)
                switch (opt) {
                case 'i': /* treat stuff controlled by these symbols as text */
                        /*
@@ -255,6 +248,13 @@ main(int argc, char *argv[])
                case 'I':
                        /* no-op for compatibility with cpp */
                        break;
+               case 'B': /* compress blank lines around removed section */
+                       compblank = true;
+                       break;
+               case 'b': /* blank deleted lines instead of omitting them */
+               case 'l': /* backwards compatibility */
+                       lnblank = true;
+                       break;
                case 'c': /* treat -D as -U and vice versa */
                        complement = true;
                        break;
@@ -264,12 +264,12 @@ main(int argc, char *argv[])
                case 'e': /* fewer errors from dodgy lines */
                        iocccok = true;
                        break;
+               case 'K': /* keep ambiguous #ifs */
+                       strictlogic = true;
+                       break;
                case 'k': /* process constant #ifs */
                        killconsts = true;
                        break;
-               case 'l': /* blank deleted lines instead of omitting them */
-                       lnblank = true;
-                       break;
                case 'n': /* add #line directive after deleted lines */
                        lnnum = true;
                        break;
@@ -284,6 +284,8 @@ main(int argc, char *argv[])
                }
        argc -= optind;
        argv += optind;
+       if (compblank && lnblank)
+               errx(2, "-B and -b are mutually exclusive");
        if (argc > 1) {
                errx(2, "can only do one file");
        } else if (argc == 1 && strcmp(*argv, "-") != 0) {
@@ -302,7 +304,7 @@ main(int argc, char *argv[])
 static void
 usage(void)
 {
-       fprintf(stderr, "usage: unifdef [-cdeklnst] [-Ipath]"
+       fprintf(stderr, "usage: unifdef [-BbcdeKknst] [-Ipath]"
            " [-Dsym[=val]] [-Usym] [-iDsym[=val]] [-iUsym] ... [file]\n");
        exit(2);
 }
@@ -383,46 +385,46 @@ static state_fn * const trans_table[IS_COUNT][LT_COUNT] = {
 /* IS_OUTSIDE */
 { Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Eendif,
   Oiffy, Oiffy, Fpass, Oif,   Oif,   Eelif, Eelif, Eelif, Eelse, Eendif,
-  print, done },
+  print, done,  abort },
 /* IS_FALSE_PREFIX */
 { Idrop, Idrop, Fdrop, Fdrop, Fdrop, Mpass, Strue, Sfalse,Selse, Dendif,
   Idrop, Idrop, Fdrop, Fdrop, Fdrop, Mpass, Eioccc,Eioccc,Eioccc,Eioccc,
-  drop,  Eeof },
+  drop,  Eeof,  abort },
 /* IS_TRUE_PREFIX */
 { Itrue, Ifalse,Fpass, Ftrue, Ffalse,Dfalse,Dfalse,Dfalse,Delse, Dendif,
   Oiffy, Oiffy, Fpass, Oif,   Oif,   Eioccc,Eioccc,Eioccc,Eioccc,Eioccc,
-  print, Eeof },
+  print, Eeof,  abort },
 /* IS_PASS_MIDDLE */
 { Itrue, Ifalse,Fpass, Ftrue, Ffalse,Pelif, Mtrue, Delif, Pelse, Pendif,
   Oiffy, Oiffy, Fpass, Oif,   Oif,   Pelif, Oelif, Oelif, Pelse, Pendif,
-  print, Eeof },
+  print, Eeof,  abort },
 /* IS_FALSE_MIDDLE */
 { Idrop, Idrop, Fdrop, Fdrop, Fdrop, Pelif, Mtrue, Delif, Pelse, Pendif,
   Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eioccc,Eioccc,Eioccc,Eioccc,Eioccc,
-  drop,  Eeof },
+  drop,  Eeof,  abort },
 /* IS_TRUE_MIDDLE */
 { Itrue, Ifalse,Fpass, Ftrue, Ffalse,Melif, Melif, Melif, Melse, Pendif,
   Oiffy, Oiffy, Fpass, Oif,   Oif,   Eioccc,Eioccc,Eioccc,Eioccc,Pendif,
-  print, Eeof },
+  print, Eeof,  abort },
 /* IS_PASS_ELSE */
 { Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Pendif,
   Oiffy, Oiffy, Fpass, Oif,   Oif,   Eelif, Eelif, Eelif, Eelse, Pendif,
-  print, Eeof },
+  print, Eeof,  abort },
 /* IS_FALSE_ELSE */
 { Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eelif, Eelif, Eelif, Eelse, Dendif,
   Idrop, Idrop, Fdrop, Fdrop, Fdrop, Eelif, Eelif, Eelif, Eelse, Eioccc,
-  drop,  Eeof },
+  drop,  Eeof,  abort },
 /* IS_TRUE_ELSE */
 { Itrue, Ifalse,Fpass, Ftrue, Ffalse,Eelif, Eelif, Eelif, Eelse, Dendif,
   Oiffy, Oiffy, Fpass, Oif,   Oif,   Eelif, Eelif, Eelif, Eelse, Eioccc,
-  print, Eeof },
+  print, Eeof,  abort },
 /* IS_FALSE_TRAILER */
 { Idrop, Idrop, Fdrop, Fdrop, Fdrop, Dfalse,Dfalse,Dfalse,Delse, Dendif,
   Idrop, Idrop, Fdrop, Fdrop, Fdrop, Dfalse,Dfalse,Dfalse,Delse, Eioccc,
-  drop,  Eeof }
+  drop,  Eeof,  abort }
 /*TRUEI  FALSEI IF     TRUE   FALSE  ELIF   ELTRUE ELFALSE ELSE  ENDIF
   TRUEI  FALSEI IF     TRUE   FALSE  ELIF   ELTRUE ELFALSE ELSE  ENDIF (DODGY)
-  PLAIN  EOF */
+  PLAIN  EOF    ERROR */
 };
 
 /*
@@ -463,9 +465,11 @@ keywordedit(const char *replacement)
 static void
 nest(void)
 {
-       depth += 1;
-       if (depth >= MAXDEPTH)
+       if (depth > MAXDEPTH-1)
+               abort(); /* bug */
+       if (depth == MAXDEPTH-1)
                error("Too many levels of nesting");
+       depth += 1;
        stifline[depth] = linenum;
 }
 static void
@@ -490,15 +494,23 @@ flushline(bool keep)
        if (symlist)
                return;
        if (keep ^ complement) {
-               if (lnnum && delcount > 0)
-                       printf("#line %d\n", linenum);
-               fputs(tline, stdout);
-               delcount = 0;
+               bool blankline = tline[strspn(tline, " \t\n")] == '\0';
+               if (blankline && compblank && blankcount != blankmax) {
+                       delcount += 1;
+                       blankcount += 1;
+               } else {
+                       if (lnnum && delcount > 0)
+                               printf("#line %d\n", linenum);
+                       fputs(tline, stdout);
+                       delcount = 0;
+                       blankmax = blankcount = blankline ? blankcount + 1 : 0;
+               }
        } else {
                if (lnblank)
                        putc('\n', stdout);
                exitstat = 1;
                delcount += 1;
+               blankcount = 0;
        }
 }
 
@@ -510,9 +522,12 @@ process(void)
 {
        Linetype lineval;
 
+       /* When compressing blank lines, act as if the file
+          is preceded by a large number of blank lines. */
+       blankmax = blankcount = 1000;
        for (;;) {
                linenum++;
-               lineval = get_line();
+               lineval = parseline();
                trans_table[ifstate[depth]][lineval]();
                debug("process %s -> %s depth %d",
                    linetype_name[lineval],
@@ -526,7 +541,7 @@ process(void)
  * help from skipcomment().
  */
 static Linetype
-get_line(void)
+parseline(void)
 {
        const char *cp;
        int cursym;
@@ -595,9 +610,21 @@ get_line(void)
                        if (incomment)
                                linestate = LS_DIRTY;
                }
-               /* skipcomment should have changed the state */
-               if (linestate == LS_HASH)
-                       abort(); /* bug */
+               /* skipcomment normally changes the state, except
+                  if the last line of the file lacks a newline, or
+                  if there is too much whitespace in a directive */
+               if (linestate == LS_HASH) {
+                       size_t len = cp - tline;
+                       if (fgets(tline + len, MAXLINE - len, input) == NULL) {
+                               /* append the missing newline */
+                               tline[len+0] = '\n';
+                               tline[len+1] = '\0';
+                               cp++;
+                               linestate = LS_START;
+                       } else {
+                               linestate = LS_DIRTY;
+                       }
+               }
        }
        if (linestate == LS_DIRTY) {
                while (*cp != '\0')
@@ -610,17 +637,40 @@ get_line(void)
 
 /*
  * These are the binary operators that are supported by the expression
- * evaluator. Note that if support for division is added then we also
- * need short-circuiting booleans because of divide-by-zero.
+ * evaluator.
  */
-static int op_lt(int a, int b) { return (a < b); }
-static int op_gt(int a, int b) { return (a > b); }
-static int op_le(int a, int b) { return (a <= b); }
-static int op_ge(int a, int b) { return (a >= b); }
-static int op_eq(int a, int b) { return (a == b); }
-static int op_ne(int a, int b) { return (a != b); }
-static int op_or(int a, int b) { return (a || b); }
-static int op_and(int a, int b) { return (a && b); }
+static Linetype op_strict(int *p, int v, Linetype at, Linetype bt) {
+       if(at == LT_IF || bt == LT_IF) return (LT_IF);
+       return (*p = v, v ? LT_TRUE : LT_FALSE);
+}
+static Linetype op_lt(int *p, Linetype at, int a, Linetype bt, int b) {
+       return op_strict(p, a < b, at, bt);
+}
+static Linetype op_gt(int *p, Linetype at, int a, Linetype bt, int b) {
+       return op_strict(p, a > b, at, bt);
+}
+static Linetype op_le(int *p, Linetype at, int a, Linetype bt, int b) {
+       return op_strict(p, a <= b, at, bt);
+}
+static Linetype op_ge(int *p, Linetype at, int a, Linetype bt, int b) {
+       return op_strict(p, a >= b, at, bt);
+}
+static Linetype op_eq(int *p, Linetype at, int a, Linetype bt, int b) {
+       return op_strict(p, a == b, at, bt);
+}
+static Linetype op_ne(int *p, Linetype at, int a, Linetype bt, int b) {
+       return op_strict(p, a != b, at, bt);
+}
+static Linetype op_or(int *p, Linetype at, int a, Linetype bt, int b) {
+       if (!strictlogic && (at == LT_TRUE || bt == LT_TRUE))
+               return (*p = 1, LT_TRUE);
+       return op_strict(p, a || b, at, bt);
+}
+static Linetype op_and(int *p, Linetype at, int a, Linetype bt, int b) {
+       if (!strictlogic && (at == LT_FALSE || bt == LT_FALSE))
+               return (*p = 0, LT_FALSE);
+       return op_strict(p, a && b, at, bt);
+}
 
 /*
  * An evaluation function takes three arguments, as follows: (1) a pointer to
@@ -629,8 +679,8 @@ static int op_and(int a, int b) { return (a && b); }
  * value of the expression; and (3) a pointer to a char* that points to the
  * expression to be evaluated and that is updated to the end of the expression
  * when evaluation is complete. The function returns LT_FALSE if the value of
- * the expression is zero, LT_TRUE if it is non-zero, or LT_IF if the
- * expression could not be evaluated.
+ * the expression is zero, LT_TRUE if it is non-zero, LT_IF if the expression
+ * depends on an unknown symbol, or LT_ERROR if there is a parse failure.
  */
 struct ops;
 
@@ -649,7 +699,7 @@ static const struct ops {
        eval_fn *inner;
        struct op {
                const char *str;
-               int (*fn)(int, int);
+               Linetype (*fn)(int *, Linetype, int, Linetype, int);
        } op[5];
 } eval_ops[] = {
        { eval_table, { { "||", op_or } } },
@@ -664,8 +714,8 @@ static const struct ops {
 
 /*
  * Function for evaluating the innermost parts of expressions,
- * viz. !expr (expr) defined(symbol) symbol number
- * We reset the keepthis flag when we find a non-constant subexpression.
+ * viz. !expr (expr) number defined(symbol) symbol
+ * We reset the constexpr flag in the last two cases.
  */
 static Linetype
 eval_unary(const struct ops *ops, int *valp, const char **cpp)
@@ -673,68 +723,83 @@ eval_unary(const struct ops *ops, int *valp, const char **cpp)
        const char *cp;
        char *ep;
        int sym;
+       bool defparen;
+       Linetype lt;
 
        cp = skipcomment(*cpp);
        if (*cp == '!') {
                debug("eval%d !", ops - eval_ops);
                cp++;
-               if (eval_unary(ops, valp, &cp) == LT_IF) {
-                       *cpp = cp;
-                       return (LT_IF);
+               lt = eval_unary(ops, valp, &cp);
+               if (lt == LT_ERROR)
+                       return (LT_ERROR);
+               if (lt != LT_IF) {
+                       *valp = !*valp;
+                       lt = *valp ? LT_TRUE : LT_FALSE;
                }
-               *valp = !*valp;
        } else if (*cp == '(') {
                cp++;
                debug("eval%d (", ops - eval_ops);
-               if (eval_table(eval_ops, valp, &cp) == LT_IF)
-                       return (LT_IF);
+               lt = eval_table(eval_ops, valp, &cp);
+               if (lt == LT_ERROR)
+                       return (LT_ERROR);
                cp = skipcomment(cp);
                if (*cp++ != ')')
-                       return (LT_IF);
+                       return (LT_ERROR);
        } else if (isdigit((unsigned char)*cp)) {
                debug("eval%d number", ops - eval_ops);
                *valp = strtol(cp, &ep, 0);
+               if (ep == cp)
+                       return (LT_ERROR);
+               lt = *valp ? LT_TRUE : LT_FALSE;
                cp = skipsym(cp);
        } else if (strncmp(cp, "defined", 7) == 0 && endsym(cp[7])) {
                cp = skipcomment(cp+7);
                debug("eval%d defined", ops - eval_ops);
-               if (*cp++ != '(')
-                       return (LT_IF);
-               cp = skipcomment(cp);
+               if (*cp == '(') {
+                       cp = skipcomment(cp+1);
+                       defparen = true;
+               } else {
+                       defparen = false;
+               }
                sym = findsym(cp);
-               cp = skipsym(cp);
-               cp = skipcomment(cp);
-               if (*cp++ != ')')
-                       return (LT_IF);
-               if (sym >= 0)
+               if (sym < 0) {
+                       lt = LT_IF;
+               } else {
                        *valp = (value[sym] != NULL);
-               else {
-                       *cpp = cp;
-                       return (LT_IF);
+                       lt = *valp ? LT_TRUE : LT_FALSE;
                }
-               keepthis = false;
+               cp = skipsym(cp);
+               cp = skipcomment(cp);
+               if (defparen && *cp++ != ')')
+                       return (LT_ERROR);
+               constexpr = false;
        } else if (!endsym(*cp)) {
                debug("eval%d symbol", ops - eval_ops);
                sym = findsym(cp);
-               if (sym < 0)
-                       return (LT_IF);
-               if (value[sym] == NULL)
+               cp = skipsym(cp);
+               if (sym < 0) {
+                       lt = LT_IF;
+                       cp = skipargs(cp);
+               } else if (value[sym] == NULL) {
                        *valp = 0;
-               else {
+                       lt = LT_FALSE;
+               } else {
                        *valp = strtol(value[sym], &ep, 0);
                        if (*ep != '\0' || ep == value[sym])
-                               return (LT_IF);
+                               return (LT_ERROR);
+                       lt = *valp ? LT_TRUE : LT_FALSE;
+                       cp = skipargs(cp);
                }
-               cp = skipsym(cp);
-               keepthis = false;
+               constexpr = false;
        } else {
                debug("eval%d bad expr", ops - eval_ops);
-               return (LT_IF);
+               return (LT_ERROR);
        }
 
        *cpp = cp;
        debug("eval%d = %d", ops - eval_ops, *valp);
-       return (*valp ? LT_TRUE : LT_FALSE);
+       return (lt);
 }
 
 /*
@@ -746,11 +811,13 @@ eval_table(const struct ops *ops, int *valp, const char **cpp)
        const struct op *op;
        const char *cp;
        int val;
-       Linetype lhs, rhs;
+       Linetype lt, rt;
 
        debug("eval%d", ops - eval_ops);
        cp = *cpp;
-       lhs = ops->inner(ops+1, valp, &cp);
+       lt = ops->inner(ops+1, valp, &cp);
+       if (lt == LT_ERROR)
+               return (LT_ERROR);
        for (;;) {
                cp = skipcomment(cp);
                for (op = ops->op; op->str != NULL; op++)
@@ -760,32 +827,16 @@ eval_table(const struct ops *ops, int *valp, const char **cpp)
                        break;
                cp += strlen(op->str);
                debug("eval%d %s", ops - eval_ops, op->str);
-               rhs = ops->inner(ops+1, &val, &cp);
-               if (op->fn == op_and && (lhs == LT_FALSE || rhs == LT_FALSE)) {
-                       debug("eval%d: and always false", ops - eval_ops);
-                       if (lhs == LT_IF)
-                               *valp = val;
-                       lhs = LT_FALSE;
-                       continue;
-               }
-               if (op->fn == op_or && (lhs == LT_TRUE || rhs == LT_TRUE)) {
-                       debug("eval%d: or always true", ops - eval_ops);
-                       if (lhs == LT_IF)
-                               *valp = val;
-                       lhs = LT_TRUE;
-                       continue;
-               }
-               if (rhs == LT_IF)
-                       lhs = LT_IF;
-               if (lhs != LT_IF)
-                       *valp = op->fn(*valp, val);
+               rt = ops->inner(ops+1, &val, &cp);
+               if (rt == LT_ERROR)
+                       return (LT_ERROR);
+               lt = op->fn(valp, lt, *valp, rt, val);
        }
 
        *cpp = cp;
        debug("eval%d = %d", ops - eval_ops, *valp);
-       if (lhs != LT_IF)
-               lhs = (*valp ? LT_TRUE : LT_FALSE);
-       return lhs;
+       debug("eval%d lt = %s", ops - eval_ops, linetype_name[lt]);
+       return (lt);
 }
 
 /*
@@ -796,17 +847,14 @@ eval_table(const struct ops *ops, int *valp, const char **cpp)
 static Linetype
 ifeval(const char **cpp)
 {
-       const char *cp = *cpp;
        int ret;
-       int val;
+       int val = 0;
 
        debug("eval %s", *cpp);
-       keepthis = killconsts ? false : true;
-       ret = eval_table(eval_ops, &val, &cp);
-       if (ret != LT_IF)
-               *cpp = cp;
+       constexpr = killconsts ? false : true;
+       ret = eval_table(eval_ops, &val, cpp);
        debug("eval = %d", val);
-       return (keepthis ? LT_IF : ret);
+       return (constexpr ? LT_IF : ret == LT_ERROR ? LT_IF : ret);
 }
 
 /*
@@ -917,6 +965,31 @@ skipcomment(const char *cp)
        return (cp);
 }
 
+/*
+ * Skip macro arguments.
+ */
+static const char *
+skipargs(const char *cp)
+{
+       const char *ocp = cp;
+       int level = 0;
+       cp = skipcomment(cp);
+       if (*cp != '(')
+               return (cp);
+       do {
+               if (*cp == '(')
+                       level++;
+               if (*cp == ')')
+                       level--;
+               cp = skipcomment(cp+1);
+       } while (level != 0 && *cp != '\0');
+       if (level == 0)
+               return (cp);
+       else
+       /* Rewind and re-detect the syntax error later. */
+               return (ocp);
+}
+
 /*
  * Skip over an identifier.
  */
@@ -929,7 +1002,7 @@ skipsym(const char *cp)
 }
 
 /*
- * Look for the symbol in the symbol table. If is is found, we return
+ * Look for the symbol in the symbol table. If it is found, we return
  * the symbol table index, else we return -1.
  */
 static int
index bb44e350c6181bac5e366ee2108d62f27754556d..da20a193c8dd6623d834ef9bb1396fcaacfd9bd0 100644 (file)
@@ -8,7 +8,8 @@ subdir-$(CONFIG_SECURITY_SMACK)         += smack
 subdir-$(CONFIG_SECURITY_TOMOYO)        += tomoyo
 
 # always enable default capabilities
-obj-y          += commoncap.o min_addr.o
+obj-y                                  += commoncap.o
+obj-$(CONFIG_MMU)                      += min_addr.o
 
 # Object file lists
 obj-$(CONFIG_SECURITY)                 += security.o capability.o
index 165eb5397ea5fd0179960908f2fb647cf7b9a638..c41afe6639a09559248f36eb672bcedf141eca49 100644 (file)
@@ -97,7 +97,6 @@ static inline unsigned long ima_hash_key(u8 *digest)
 
 /* iint cache flags */
 #define IMA_MEASURED           1
-#define IMA_IINT_DUMP_STACK    512
 
 /* integrity data associated with an inode */
 struct ima_iint_cache {
@@ -128,8 +127,6 @@ void ima_template_show(struct seq_file *m, void *e,
  */
 struct ima_iint_cache *ima_iint_insert(struct inode *inode);
 struct ima_iint_cache *ima_iint_find_get(struct inode *inode);
-struct ima_iint_cache *ima_iint_find_insert_get(struct inode *inode);
-void ima_iint_delete(struct inode *inode);
 void iint_free(struct kref *kref);
 void iint_rcu_free(struct rcu_head *rcu);
 
index a4e2b1dac943b8ed05ee39dd23df2fbe56a80844..fa592ff1ac1c4f7b24394baf6a2155dc1fb911a6 100644 (file)
@@ -19,8 +19,6 @@
 #include <linux/radix-tree.h>
 #include "ima.h"
 
-#define ima_iint_delete ima_inode_free
-
 RADIX_TREE(ima_iint_store, GFP_ATOMIC);
 DEFINE_SPINLOCK(ima_iint_lock);
 
@@ -45,22 +43,21 @@ out:
        return iint;
 }
 
-/* Allocate memory for the iint associated with the inode
- * from the iint_cache slab, initialize the iint, and
- * insert it into the radix tree.
- *
- * On success return a pointer to the iint; on failure return NULL.
+/**
+ * ima_inode_alloc - allocate an iint associated with an inode
+ * @inode: pointer to the inode
  */
-struct ima_iint_cache *ima_iint_insert(struct inode *inode)
+int ima_inode_alloc(struct inode *inode)
 {
        struct ima_iint_cache *iint = NULL;
        int rc = 0;
 
        if (!ima_initialized)
-               return iint;
+               return 0;
+
        iint = kmem_cache_alloc(iint_cache, GFP_NOFS);
        if (!iint)
-               return iint;
+               return -ENOMEM;
 
        rc = radix_tree_preload(GFP_NOFS);
        if (rc < 0)
@@ -70,65 +67,13 @@ struct ima_iint_cache *ima_iint_insert(struct inode *inode)
        rc = radix_tree_insert(&ima_iint_store, (unsigned long)inode, iint);
        spin_unlock(&ima_iint_lock);
 out:
-       if (rc < 0) {
+       if (rc < 0)
                kmem_cache_free(iint_cache, iint);
-               if (rc == -EEXIST) {
-                       spin_lock(&ima_iint_lock);
-                       iint = radix_tree_lookup(&ima_iint_store,
-                                                (unsigned long)inode);
-                       spin_unlock(&ima_iint_lock);
-               } else
-                       iint = NULL;
-       }
-       radix_tree_preload_end();
-       return iint;
-}
-
-/**
- * ima_inode_alloc - allocate an iint associated with an inode
- * @inode: pointer to the inode
- *
- * Return 0 on success, 1 on failure.
- */
-int ima_inode_alloc(struct inode *inode)
-{
-       struct ima_iint_cache *iint;
-
-       if (!ima_initialized)
-               return 0;
-
-       iint = ima_iint_insert(inode);
-       if (!iint)
-               return 1;
-       return 0;
-}
-
-/* ima_iint_find_insert_get - get the iint associated with an inode
- *
- * Most insertions are done at inode_alloc, except those allocated
- * before late_initcall. When the iint does not exist, allocate it,
- * initialize and insert it, and increment the iint refcount.
- *
- * (Can't initialize at security_initcall before any inodes are
- * allocated, got to wait at least until proc_init.)
- *
- *  Return the iint.
- */
-struct ima_iint_cache *ima_iint_find_insert_get(struct inode *inode)
-{
-       struct ima_iint_cache *iint = NULL;
 
-       iint = ima_iint_find_get(inode);
-       if (iint)
-               return iint;
-
-       iint = ima_iint_insert(inode);
-       if (iint)
-               kref_get(&iint->refcount);
+       radix_tree_preload_end();
 
-       return iint;
+       return rc;
 }
-EXPORT_SYMBOL_GPL(ima_iint_find_insert_get);
 
 /* iint_free - called when the iint refcount goes to zero */
 void iint_free(struct kref *kref)
@@ -164,12 +109,12 @@ void iint_rcu_free(struct rcu_head *rcu_head)
 }
 
 /**
- * ima_iint_delete - called on integrity_inode_free
+ * ima_inode_free - called on security_inode_free
  * @inode: pointer to the inode
  *
  * Free the integrity information(iint) associated with an inode.
  */
-void ima_iint_delete(struct inode *inode)
+void ima_inode_free(struct inode *inode)
 {
        struct ima_iint_cache *iint;
 
index b85e61bcf246c45be863baff63420012d6c765c1..a89f44d5e0306fe173b14a8120919cb6ad805093 100644 (file)
@@ -13,8 +13,8 @@
  * License.
  *
  * File: ima_main.c
- *             implements the IMA hooks: ima_bprm_check, ima_file_mmap,
- *             and ima_path_check.
+ *     implements the IMA hooks: ima_bprm_check, ima_file_mmap,
+ *     and ima_path_check.
  */
 #include <linux/module.h>
 #include <linux/file.h>
@@ -35,6 +35,100 @@ static int __init hash_setup(char *str)
 }
 __setup("ima_hash=", hash_setup);
 
+struct ima_imbalance {
+       struct hlist_node node;
+       unsigned long fsmagic;
+};
+
+/*
+ * ima_limit_imbalance - emit one imbalance message per filesystem type
+ *
+ * Maintain list of filesystem types that do not measure files properly.
+ * Return false if unknown, true if known.
+ */
+static bool ima_limit_imbalance(struct file *file)
+{
+       static DEFINE_SPINLOCK(ima_imbalance_lock);
+       static HLIST_HEAD(ima_imbalance_list);
+
+       struct super_block *sb = file->f_dentry->d_sb;
+       struct ima_imbalance *entry;
+       struct hlist_node *node;
+       bool found = false;
+
+       rcu_read_lock();
+       hlist_for_each_entry_rcu(entry, node, &ima_imbalance_list, node) {
+               if (entry->fsmagic == sb->s_magic) {
+                       found = true;
+                       break;
+               }
+       }
+       rcu_read_unlock();
+       if (found)
+               goto out;
+
+       entry = kmalloc(sizeof(*entry), GFP_NOFS);
+       if (!entry)
+               goto out;
+       entry->fsmagic = sb->s_magic;
+       spin_lock(&ima_imbalance_lock);
+       /*
+        * we could have raced and something else might have added this fs
+        * to the list, but we don't really care
+        */
+       hlist_add_head_rcu(&entry->node, &ima_imbalance_list);
+       spin_unlock(&ima_imbalance_lock);
+       printk(KERN_INFO "IMA: unmeasured files on fsmagic: %lX\n",
+              entry->fsmagic);
+out:
+       return found;
+}
+
+/*
+ * Update the counts given an fmode_t
+ */
+static void ima_inc_counts(struct ima_iint_cache *iint, fmode_t mode)
+{
+       BUG_ON(!mutex_is_locked(&iint->mutex));
+
+       iint->opencount++;
+       if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
+               iint->readcount++;
+       if (mode & FMODE_WRITE)
+               iint->writecount++;
+}
+
+/*
+ * Decrement ima counts
+ */
+static void ima_dec_counts(struct ima_iint_cache *iint, struct inode *inode,
+                          struct file *file)
+{
+       mode_t mode = file->f_mode;
+       BUG_ON(!mutex_is_locked(&iint->mutex));
+
+       iint->opencount--;
+       if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
+               iint->readcount--;
+       if (mode & FMODE_WRITE) {
+               iint->writecount--;
+               if (iint->writecount == 0) {
+                       if (iint->version != inode->i_version)
+                               iint->flags &= ~IMA_MEASURED;
+               }
+       }
+
+       if (((iint->opencount < 0) ||
+            (iint->readcount < 0) ||
+            (iint->writecount < 0)) &&
+           !ima_limit_imbalance(file)) {
+               printk(KERN_INFO "%s: open/free imbalance (r:%ld w:%ld o:%ld)\n",
+                      __FUNCTION__, iint->readcount, iint->writecount,
+                      iint->opencount);
+               dump_stack();
+       }
+}
+
 /**
  * ima_file_free - called on __fput()
  * @file: pointer to file structure being freed
@@ -54,29 +148,7 @@ void ima_file_free(struct file *file)
                return;
 
        mutex_lock(&iint->mutex);
-       if (iint->opencount <= 0) {
-               printk(KERN_INFO
-                      "%s: %s open/free imbalance (r:%ld w:%ld o:%ld f:%ld)\n",
-                      __FUNCTION__, file->f_dentry->d_name.name,
-                      iint->readcount, iint->writecount,
-                      iint->opencount, atomic_long_read(&file->f_count));
-               if (!(iint->flags & IMA_IINT_DUMP_STACK)) {
-                       dump_stack();
-                       iint->flags |= IMA_IINT_DUMP_STACK;
-               }
-       }
-       iint->opencount--;
-
-       if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
-               iint->readcount--;
-
-       if (file->f_mode & FMODE_WRITE) {
-               iint->writecount--;
-               if (iint->writecount == 0) {
-                       if (iint->version != inode->i_version)
-                               iint->flags &= ~IMA_MEASURED;
-               }
-       }
+       ima_dec_counts(iint, inode, file);
        mutex_unlock(&iint->mutex);
        kref_put(&iint->refcount, iint_free);
 }
@@ -116,8 +188,7 @@ static int get_path_measurement(struct ima_iint_cache *iint, struct file *file,
 {
        int rc = 0;
 
-       iint->opencount++;
-       iint->readcount++;
+       ima_inc_counts(iint, file->f_mode);
 
        rc = ima_collect_measurement(iint, file);
        if (!rc)
@@ -125,15 +196,6 @@ static int get_path_measurement(struct ima_iint_cache *iint, struct file *file,
        return rc;
 }
 
-static void ima_update_counts(struct ima_iint_cache *iint, int mask)
-{
-       iint->opencount++;
-       if ((mask & MAY_WRITE) || (mask == 0))
-               iint->writecount++;
-       else if (mask & (MAY_READ | MAY_EXEC))
-               iint->readcount++;
-}
-
 /**
  * ima_path_check - based on policy, collect/store measurement.
  * @path: contains a pointer to the path to be measured
@@ -152,7 +214,7 @@ static void ima_update_counts(struct ima_iint_cache *iint, int mask)
  * Always return 0 and audit dentry_open failures.
  * (Return code will be based upon measurement appraisal.)
  */
-int ima_path_check(struct path *path, int mask, int update_counts)
+int ima_path_check(struct path *path, int mask)
 {
        struct inode *inode = path->dentry->d_inode;
        struct ima_iint_cache *iint;
@@ -161,13 +223,11 @@ int ima_path_check(struct path *path, int mask, int update_counts)
 
        if (!ima_initialized || !S_ISREG(inode->i_mode))
                return 0;
-       iint = ima_iint_find_insert_get(inode);
+       iint = ima_iint_find_get(inode);
        if (!iint)
                return 0;
 
        mutex_lock(&iint->mutex);
-       if (update_counts)
-               ima_update_counts(iint, mask);
 
        rc = ima_must_measure(iint, inode, MAY_READ, PATH_CHECK);
        if (rc < 0)
@@ -219,7 +279,7 @@ static int process_measurement(struct file *file, const unsigned char *filename,
 
        if (!ima_initialized || !S_ISREG(inode->i_mode))
                return 0;
-       iint = ima_iint_find_insert_get(inode);
+       iint = ima_iint_find_get(inode);
        if (!iint)
                return -ENOMEM;
 
@@ -237,39 +297,6 @@ out:
        return rc;
 }
 
-/*
- * ima_counts_put - decrement file counts
- *
- * File counts are incremented in ima_path_check. On file open
- * error, such as ETXTBSY, decrement the counts to prevent
- * unnecessary imbalance messages.
- */
-void ima_counts_put(struct path *path, int mask)
-{
-       struct inode *inode = path->dentry->d_inode;
-       struct ima_iint_cache *iint;
-
-       /* The inode may already have been freed, freeing the iint
-        * with it. Verify the inode is not NULL before dereferencing
-        * it.
-        */
-       if (!ima_initialized || !inode || !S_ISREG(inode->i_mode))
-               return;
-       iint = ima_iint_find_insert_get(inode);
-       if (!iint)
-               return;
-
-       mutex_lock(&iint->mutex);
-       iint->opencount--;
-       if ((mask & MAY_WRITE) || (mask == 0))
-               iint->writecount--;
-       else if (mask & (MAY_READ | MAY_EXEC))
-               iint->readcount--;
-       mutex_unlock(&iint->mutex);
-
-       kref_put(&iint->refcount, iint_free);
-}
-
 /*
  * ima_counts_get - increment file counts
  *
@@ -286,16 +313,11 @@ void ima_counts_get(struct file *file)
 
        if (!ima_initialized || !S_ISREG(inode->i_mode))
                return;
-       iint = ima_iint_find_insert_get(inode);
+       iint = ima_iint_find_get(inode);
        if (!iint)
                return;
        mutex_lock(&iint->mutex);
-       iint->opencount++;
-       if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
-               iint->readcount++;
-
-       if (file->f_mode & FMODE_WRITE)
-               iint->writecount++;
+       ima_inc_counts(iint, file->f_mode);
        mutex_unlock(&iint->mutex);
 
        kref_put(&iint->refcount, iint_free);
index 06ec722897be2107db29ea64db6627b090495af0..e9c2e7c584d9482c4349fb9966cab0c6f43a2ce3 100644 (file)
@@ -1194,7 +1194,7 @@ long keyctl_get_security(key_serial_t keyid,
                 * have the authorisation token handy */
                instkey = key_get_instantiation_authkey(keyid);
                if (IS_ERR(instkey))
-                       return PTR_ERR(key_ref);
+                       return PTR_ERR(instkey);
                key_put(instkey);
 
                key_ref = lookup_user_key(keyid, KEY_LOOKUP_PARTIAL, 0);
@@ -1236,6 +1236,7 @@ long keyctl_get_security(key_serial_t keyid,
  */
 long keyctl_session_to_parent(void)
 {
+#ifdef TIF_NOTIFY_RESUME
        struct task_struct *me, *parent;
        const struct cred *mycred, *pcred;
        struct cred *cred, *oldcred;
@@ -1326,6 +1327,15 @@ not_permitted:
 error_keyring:
        key_ref_put(keyring_r);
        return ret;
+
+#else /* !TIF_NOTIFY_RESUME */
+       /*
+        * To be removed when TIF_NOTIFY_RESUME has been implemented on
+        * m68k/xtensa
+        */
+#warning TIF_NOTIFY_RESUME not implemented
+       return -EOPNOTSUPP;
+#endif /* !TIF_NOTIFY_RESUME */
 }
 
 /*****************************************************************************/
index fc43c9d37084599056680e55c5e8c38491b117ba..e86f297522bfb9ea91de0ad929034bcccd59d57f 100644 (file)
@@ -43,7 +43,7 @@ int mmap_min_addr_handler(struct ctl_table *table, int write,
        return ret;
 }
 
-int __init init_mmap_min_addr(void)
+static int __init init_mmap_min_addr(void)
 {
        update_mmap_min_addr();
 
index 8346938809b133802ee5b2a2b8068659c0500495..9a6c58881c0a37562090a345f91b86afab76248a 100644 (file)
@@ -12,7 +12,6 @@
 #include "common.h"
 #include "tomoyo.h"
 #include "realpath.h"
-#define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
 
 /*
  * tomoyo_globally_readable_file_entry is a structure which is used for holding
index 1497dce1b04a7498ac5e28e41774cfc09a28375c..656e474dca47f1a20d0ed473ebdfc1e8eb0c1a7f 100644 (file)
@@ -172,14 +172,15 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
        return v;
 }
 
-static inline void aaci_chan_wait_ready(struct aaci_runtime *aacirun)
+static inline void
+aaci_chan_wait_ready(struct aaci_runtime *aacirun, unsigned long mask)
 {
        u32 val;
        int timeout = 5000;
 
        do {
                val = readl(aacirun->base + AACI_SR);
-       } while (val & (SR_TXB|SR_RXB) && timeout--);
+       } while (val & mask && timeout--);
 }
 
 
@@ -208,8 +209,10 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
                        writel(0, aacirun->base + AACI_IE);
                        return;
                }
-               ptr = aacirun->ptr;
 
+               spin_lock(&aacirun->lock);
+
+               ptr = aacirun->ptr;
                do {
                        unsigned int len = aacirun->fifosz;
                        u32 val;
@@ -217,9 +220,9 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
                        if (aacirun->bytes <= 0) {
                                aacirun->bytes += aacirun->period;
                                aacirun->ptr = ptr;
-                               spin_unlock(&aaci->lock);
+                               spin_unlock(&aacirun->lock);
                                snd_pcm_period_elapsed(aacirun->substream);
-                               spin_lock(&aaci->lock);
+                               spin_lock(&aacirun->lock);
                        }
                        if (!(aacirun->cr & CR_EN))
                                break;
@@ -245,7 +248,10 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
                                        ptr = aacirun->start;
                        }
                } while(1);
+
                aacirun->ptr = ptr;
+
+               spin_unlock(&aacirun->lock);
        }
 
        if (mask & ISR_URINTR) {
@@ -263,6 +269,8 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
                        return;
                }
 
+               spin_lock(&aacirun->lock);
+
                ptr = aacirun->ptr;
                do {
                        unsigned int len = aacirun->fifosz;
@@ -271,9 +279,9 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
                        if (aacirun->bytes <= 0) {
                                aacirun->bytes += aacirun->period;
                                aacirun->ptr = ptr;
-                               spin_unlock(&aaci->lock);
+                               spin_unlock(&aacirun->lock);
                                snd_pcm_period_elapsed(aacirun->substream);
-                               spin_lock(&aaci->lock);
+                               spin_lock(&aacirun->lock);
                        }
                        if (!(aacirun->cr & CR_EN))
                                break;
@@ -301,6 +309,8 @@ static void aaci_fifo_irq(struct aaci *aaci, int channel, u32 mask)
                } while (1);
 
                aacirun->ptr = ptr;
+
+               spin_unlock(&aacirun->lock);
        }
 }
 
@@ -310,7 +320,6 @@ static irqreturn_t aaci_irq(int irq, void *devid)
        u32 mask;
        int i;
 
-       spin_lock(&aaci->lock);
        mask = readl(aaci->base + AACI_ALLINTS);
        if (mask) {
                u32 m = mask;
@@ -320,7 +329,6 @@ static irqreturn_t aaci_irq(int irq, void *devid)
                        }
                }
        }
-       spin_unlock(&aaci->lock);
 
        return mask ? IRQ_HANDLED : IRQ_NONE;
 }
@@ -330,63 +338,6 @@ static irqreturn_t aaci_irq(int irq, void *devid)
 /*
  * ALSA support.
  */
-
-struct aaci_stream {
-       unsigned char codec_idx;
-       unsigned char rate_idx;
-};
-
-static struct aaci_stream aaci_streams[] = {
-       [ACSTREAM_FRONT] = {
-               .codec_idx      = 0,
-               .rate_idx       = AC97_RATES_FRONT_DAC,
-       },
-       [ACSTREAM_SURROUND] = {
-               .codec_idx      = 0,
-               .rate_idx       = AC97_RATES_SURR_DAC,
-       },
-       [ACSTREAM_LFE] = {
-               .codec_idx      = 0,
-               .rate_idx       = AC97_RATES_LFE_DAC,
-       },
-};
-
-static inline unsigned int aaci_rate_mask(struct aaci *aaci, int streamid)
-{
-       struct aaci_stream *s = aaci_streams + streamid;
-       return aaci->ac97_bus->codec[s->codec_idx]->rates[s->rate_idx];
-}
-
-static unsigned int rate_list[] = {
-       5512, 8000, 11025, 16000, 22050, 32000, 44100,
-       48000, 64000, 88200, 96000, 176400, 192000
-};
-
-/*
- * Double-rate rule: we can support double rate iff channels == 2
- *  (unimplemented)
- */
-static int
-aaci_rule_rate_by_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule)
-{
-       struct aaci *aaci = rule->private;
-       unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512;
-       struct snd_interval *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS);
-
-       switch (c->max) {
-       case 6:
-               rate_mask &= aaci_rate_mask(aaci, ACSTREAM_LFE);
-       case 4:
-               rate_mask &= aaci_rate_mask(aaci, ACSTREAM_SURROUND);
-       case 2:
-               rate_mask &= aaci_rate_mask(aaci, ACSTREAM_FRONT);
-       }
-
-       return snd_interval_list(hw_param_interval(p, rule->var),
-                                ARRAY_SIZE(rate_list), rate_list,
-                                rate_mask);
-}
-
 static struct snd_pcm_hardware aaci_hw_info = {
        .info                   = SNDRV_PCM_INFO_MMAP |
                                  SNDRV_PCM_INFO_MMAP_VALID |
@@ -400,10 +351,7 @@ static struct snd_pcm_hardware aaci_hw_info = {
         */
        .formats                = SNDRV_PCM_FMTBIT_S16_LE,
 
-       /* should this be continuous or knot? */
-       .rates                  = SNDRV_PCM_RATE_CONTINUOUS,
-       .rate_max               = 48000,
-       .rate_min               = 4000,
+       /* rates are setup from the AC'97 codec */
        .channels_min           = 2,
        .channels_max           = 6,
        .buffer_bytes_max       = 64 * 1024,
@@ -423,6 +371,12 @@ static int __aaci_pcm_open(struct aaci *aaci,
        aacirun->substream = substream;
        runtime->private_data = aacirun;
        runtime->hw = aaci_hw_info;
+       runtime->hw.rates = aacirun->pcm->rates;
+       snd_pcm_limit_hw_rates(runtime);
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
+           aacirun->pcm->r[1].slots)
+               snd_ac97_pcm_double_rate_rules(runtime);
 
        /*
         * FIXME: ALSA specifies fifo_size in bytes.  If we're in normal
@@ -433,17 +387,6 @@ static int __aaci_pcm_open(struct aaci *aaci,
         */
        runtime->hw.fifo_size = aaci->fifosize * 2;
 
-       /*
-        * Add rule describing hardware rate dependency
-        * on the number of channels.
-        */
-       ret = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
-                                 aaci_rule_rate_by_channels, aaci,
-                                 SNDRV_PCM_HW_PARAM_CHANNELS,
-                                 SNDRV_PCM_HW_PARAM_RATE, -1);
-       if (ret)
-               goto out;
-
        ret = request_irq(aaci->dev->irq[0], aaci_irq, IRQF_SHARED|IRQF_DISABLED,
                          DRIVER_NAME, aaci);
        if (ret)
@@ -498,6 +441,7 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream,
                              struct snd_pcm_hw_params *params)
 {
        int err;
+       struct aaci *aaci = substream->private_data;
 
        aaci_pcm_hw_free(substream);
        if (aacirun->pcm_open) {
@@ -507,18 +451,22 @@ static int aaci_pcm_hw_params(struct snd_pcm_substream *substream,
 
        err = snd_pcm_lib_malloc_pages(substream,
                                       params_buffer_bytes(params));
-       if (err < 0)
-               goto out;
+       if (err >= 0) {
+               unsigned int rate = params_rate(params);
+               int dbl = rate > 48000;
 
-       err = snd_ac97_pcm_open(aacirun->pcm, params_rate(params),
-                               params_channels(params),
-                               aacirun->pcm->r[0].slots);
-       if (err)
-               goto out;
+               err = snd_ac97_pcm_open(aacirun->pcm, rate,
+                                       params_channels(params),
+                                       aacirun->pcm->r[dbl].slots);
 
-       aacirun->pcm_open = 1;
+               aacirun->pcm_open = err == 0;
+               aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16;
+               aacirun->fifosz = aaci->fifosize * 4;
+
+               if (aacirun->cr & CR_COMPACT)
+                       aacirun->fifosz >>= 1;
+       }
 
- out:
        return err;
 }
 
@@ -527,7 +475,7 @@ static int aaci_pcm_prepare(struct snd_pcm_substream *substream)
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct aaci_runtime *aacirun = runtime->private_data;
 
-       aacirun->start  = (void *)runtime->dma_area;
+       aacirun->start  = runtime->dma_area;
        aacirun->end    = aacirun->start + snd_pcm_lib_buffer_bytes(substream);
        aacirun->ptr    = aacirun->start;
        aacirun->period =
@@ -613,7 +561,6 @@ static int aaci_pcm_open(struct snd_pcm_substream *substream)
 static int aaci_pcm_playback_hw_params(struct snd_pcm_substream *substream,
                                       struct snd_pcm_hw_params *params)
 {
-       struct aaci *aaci = substream->private_data;
        struct aaci_runtime *aacirun = substream->runtime->private_data;
        unsigned int channels = params_channels(params);
        int ret;
@@ -627,14 +574,9 @@ static int aaci_pcm_playback_hw_params(struct snd_pcm_substream *substream,
         * Enable FIFO, compact mode, 16 bits per sample.
         * FIXME: double rate slots?
         */
-       if (ret >= 0) {
-               aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16;
+       if (ret >= 0)
                aacirun->cr |= channels_to_txmask[channels];
 
-               aacirun->fifosz = aaci->fifosize * 4;
-               if (aacirun->cr & CR_COMPACT)
-                       aacirun->fifosz >>= 1;
-       }
        return ret;
 }
 
@@ -646,7 +588,7 @@ static void aaci_pcm_playback_stop(struct aaci_runtime *aacirun)
        ie &= ~(IE_URIE|IE_TXIE);
        writel(ie, aacirun->base + AACI_IE);
        aacirun->cr &= ~CR_EN;
-       aaci_chan_wait_ready(aacirun);
+       aaci_chan_wait_ready(aacirun, SR_TXB);
        writel(aacirun->cr, aacirun->base + AACI_TXCR);
 }
 
@@ -654,7 +596,7 @@ static void aaci_pcm_playback_start(struct aaci_runtime *aacirun)
 {
        u32 ie;
 
-       aaci_chan_wait_ready(aacirun);
+       aaci_chan_wait_ready(aacirun, SR_TXB);
        aacirun->cr |= CR_EN;
 
        ie = readl(aacirun->base + AACI_IE);
@@ -665,12 +607,12 @@ static void aaci_pcm_playback_start(struct aaci_runtime *aacirun)
 
 static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd)
 {
-       struct aaci *aaci = substream->private_data;
        struct aaci_runtime *aacirun = substream->runtime->private_data;
        unsigned long flags;
        int ret = 0;
 
-       spin_lock_irqsave(&aaci->lock, flags);
+       spin_lock_irqsave(&aacirun->lock, flags);
+
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
                aaci_pcm_playback_start(aacirun);
@@ -697,7 +639,8 @@ static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cm
        default:
                ret = -EINVAL;
        }
-       spin_unlock_irqrestore(&aaci->lock, flags);
+
+       spin_unlock_irqrestore(&aacirun->lock, flags);
 
        return ret;
 }
@@ -716,23 +659,14 @@ static struct snd_pcm_ops aaci_playback_ops = {
 static int aaci_pcm_capture_hw_params(struct snd_pcm_substream *substream,
                                      struct snd_pcm_hw_params *params)
 {
-       struct aaci *aaci = substream->private_data;
        struct aaci_runtime *aacirun = substream->runtime->private_data;
        int ret;
 
        ret = aaci_pcm_hw_params(substream, aacirun, params);
-
-       if (ret >= 0) {
-               aacirun->cr = CR_FEN | CR_COMPACT | CR_SZ16;
-
+       if (ret >= 0)
                /* Line in record: slot 3 and 4 */
                aacirun->cr |= CR_SL3 | CR_SL4;
 
-               aacirun->fifosz = aaci->fifosize * 4;
-
-               if (aacirun->cr & CR_COMPACT)
-                       aacirun->fifosz >>= 1;
-       }
        return ret;
 }
 
@@ -740,7 +674,7 @@ static void aaci_pcm_capture_stop(struct aaci_runtime *aacirun)
 {
        u32 ie;
 
-       aaci_chan_wait_ready(aacirun);
+       aaci_chan_wait_ready(aacirun, SR_RXB);
 
        ie = readl(aacirun->base + AACI_IE);
        ie &= ~(IE_ORIE | IE_RXIE);
@@ -755,7 +689,7 @@ static void aaci_pcm_capture_start(struct aaci_runtime *aacirun)
 {
        u32 ie;
 
-       aaci_chan_wait_ready(aacirun);
+       aaci_chan_wait_ready(aacirun, SR_RXB);
 
 #ifdef DEBUG
        /* RX Timeout value: bits 28:17 in RXCR */
@@ -772,12 +706,11 @@ static void aaci_pcm_capture_start(struct aaci_runtime *aacirun)
 
 static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd)
 {
-       struct aaci *aaci = substream->private_data;
        struct aaci_runtime *aacirun = substream->runtime->private_data;
        unsigned long flags;
        int ret = 0;
 
-       spin_lock_irqsave(&aaci->lock, flags);
+       spin_lock_irqsave(&aacirun->lock, flags);
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -806,7 +739,7 @@ static int aaci_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd
                ret = -EINVAL;
        }
 
-       spin_unlock_irqrestore(&aaci->lock, flags);
+       spin_unlock_irqrestore(&aacirun->lock, flags);
 
        return ret;
 }
@@ -889,6 +822,12 @@ static struct ac97_pcm ac97_defs[] __devinitdata = {
                                          (1 << AC97_SLOT_PCM_SRIGHT) |
                                          (1 << AC97_SLOT_LFE),
                        },
+                       [1] = {
+                               .slots  = (1 << AC97_SLOT_PCM_LEFT) |
+                                         (1 << AC97_SLOT_PCM_RIGHT) |
+                                         (1 << AC97_SLOT_PCM_LEFT_0) |
+                                         (1 << AC97_SLOT_PCM_RIGHT_0),
+                       },
                },
        },
        [1] = { /* PCM in */
@@ -1001,7 +940,6 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev)
 
        aaci = card->private_data;
        mutex_init(&aaci->ac97_sem);
-       spin_lock_init(&aaci->lock);
        aaci->card = card;
        aaci->dev = dev;
 
@@ -1028,7 +966,7 @@ static int __devinit aaci_init_pcm(struct aaci *aaci)
                snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops);
                snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops);
                snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
-                                                     NULL, 0, 64 * 104);
+                                                     NULL, 0, 64 * 1024);
        }
 
        return ret;
@@ -1088,12 +1026,14 @@ static int __devinit aaci_probe(struct amba_device *dev, struct amba_id *id)
        /*
         * Playback uses AACI channel 0
         */
+       spin_lock_init(&aaci->playback.lock);
        aaci->playback.base = aaci->base + AACI_CSCH1;
        aaci->playback.fifo = aaci->base + AACI_DR1;
 
        /*
         * Capture uses AACI channel 0
         */
+       spin_lock_init(&aaci->capture.lock);
        aaci->capture.base = aaci->base + AACI_CSCH1;
        aaci->capture.fifo = aaci->base + AACI_DR1;
 
index 924f69c1c44c4bd39340c006db12572ab80a341e..6a4a2eebdda1c46955215b434022699e4819556e 100644 (file)
 struct aaci_runtime {
        void                    __iomem *base;
        void                    __iomem *fifo;
+       spinlock_t              lock;
 
        struct ac97_pcm         *pcm;
        int                     pcm_open;
@@ -232,7 +233,6 @@ struct aaci {
        struct snd_ac97         *ac97;
 
        u32                     maincr;
-       spinlock_t              lock;
 
        struct aaci_runtime     playback;
        struct aaci_runtime     capture;
index b4b48afb6de6087474ae6adf4f5076c4d8877d4b..5d9411839cd7494c54586380ebf6262ebb633227 100644 (file)
@@ -159,7 +159,7 @@ static int pxa2xx_ac97_resume(struct device *dev)
        return ret;
 }
 
-static struct dev_pm_ops pxa2xx_ac97_pm_ops = {
+static const struct dev_pm_ops pxa2xx_ac97_pm_ops = {
        .suspend        = pxa2xx_ac97_suspend,
        .resume         = pxa2xx_ac97_resume,
 };
index c15682a2f9dbd743db935ca682be3ba1a669bb63..475455c76610cdd2ac7c227be01babda6ab72bd8 100644 (file)
@@ -5,6 +5,7 @@ config SND_TIMER
 config SND_PCM
        tristate
        select SND_TIMER
+       select GCD
 
 config SND_HWDEP
        tristate
index 30f410832a25991c44e2f71efcebb63abdb2b232..a27545b23ee9ff031e8eb98346a492516db42b8b 100644 (file)
@@ -758,7 +758,7 @@ int snd_interval_ratnum(struct snd_interval *i,
                int diff;
                if (q == 0)
                        q = 1;
-               den = div_down(num, q);
+               den = div_up(num, q);
                if (den < rats[k].den_min)
                        continue;
                if (den > rats[k].den_max)
@@ -794,7 +794,7 @@ int snd_interval_ratnum(struct snd_interval *i,
                        i->empty = 1;
                        return -EINVAL;
                }
-               den = div_up(num, q);
+               den = div_down(num, q);
                if (den > rats[k].den_max)
                        continue;
                if (den < rats[k].den_min)
index 29ab46a12e11cda66ff86a2865c74b9286274761..25b0641e6b8c28b7afefb3e54648990f6618e80c 100644 (file)
@@ -1918,13 +1918,13 @@ int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream)
 
        err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE,
                                           hw->rate_min, hw->rate_max);
-        if (err < 0)
-                return err;
+       if (err < 0)
+               return err;
 
        err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
                                           hw->period_bytes_min, hw->period_bytes_max);
-        if (err < 0)
-                return err;
+       if (err < 0)
+               return err;
 
        err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS,
                                           hw->periods_min, hw->periods_max);
index ca8068b63d6c1bc413d16a2309d7d33fbe378893..b01d9481d632c4245d3403a445e6e641b9b2e2aa 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <linux/time.h>
+#include <linux/gcd.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/timer.h>
  *  Timer functions
  */
 
-/* Greatest common divisor */
-static unsigned long gcd(unsigned long a, unsigned long b)
-{
-       unsigned long r;
-       if (a < b) {
-               r = a;
-               a = b;
-               b = r;
-       }
-       while ((r = a % b) != 0) {
-               a = b;
-               b = r;
-       }
-       return b;
-}
-
 void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream)
 {
        unsigned long rate, mult, fsize, l, post;
index 661205c4dceab85b97dc6693067dd17a888c4b7f..af888a022fc0807a8011a3b28f1738c6f07723de 100644 (file)
@@ -127,7 +127,8 @@ static struct snd_gf1_mem_block *snd_gf1_mem_share(struct snd_gf1_mem * alloc,
            !share_id[2] && !share_id[3])
                return NULL;
        for (block = alloc->first; block; block = block->next)
-               if (!memcmp(share_id, block->share_id, sizeof(share_id)))
+               if (!memcmp(share_id, block->share_id,
+                               sizeof(block->share_id)))
                        return block;
        return NULL;
 }
index cb9aa4c4edd08ad895f1be5b688aa93bee6dedab..4be562b2cf219bd12402ddb7778fd50f4f684abe 100644 (file)
@@ -162,7 +162,7 @@ int snd_msndmidi_new(struct snd_card *card, int device)
        err = snd_rawmidi_new(card, "MSND-MIDI", device, 1, 1, &rmidi);
        if (err < 0)
                return err;
-       mpu = kcalloc(1, sizeof(*mpu), GFP_KERNEL);
+       mpu = kzalloc(sizeof(*mpu), GFP_KERNEL);
        if (mpu == NULL) {
                snd_device_free(card, rmidi);
                return -ENOMEM;
index 96678d5d3834863fbfe440df54b8170cfa088095..751762f1c59a13aa69e66e533b5b4c2b97f2c0a4 100644 (file)
@@ -393,8 +393,6 @@ size_dram(struct snd_emu8000 *emu)
 
        while (size < EMU8000_MAX_DRAM) {
 
-               size += 512 * 1024;  /* increment 512kbytes */
-
                /* Write a unique data on the test address.
                 * if the address is out of range, the data is written on
                 * 0x200000(=EMU8000_DRAM_OFFSET).  Then the id word is
@@ -414,7 +412,9 @@ size_dram(struct snd_emu8000 *emu)
                /*snd_emu8000_read_wait(emu);*/
                EMU8000_SMLD_READ(emu); /* discard stale data  */
                if (EMU8000_SMLD_READ(emu) != UNIQUE_ID2)
-                       break; /* we must have wrapped around */
+                       break; /* no memory at this address */
+
+               size += 512 * 1024;  /* increment 512kbytes */
 
                snd_emu8000_read_wait(emu);
 
index 8691f4cf6191fc8500d4995c42e227bd8680a6c6..f1d9d16b54864258ce47868556f4b2f5888909f7 100644 (file)
@@ -609,7 +609,7 @@ static int snd_sgio2audio_pcm_hw_params(struct snd_pcm_substream *substream,
        /* alloc virtual 'dma' area */
        if (runtime->dma_area)
                vfree(runtime->dma_area);
-       runtime->dma_area = vmalloc(size);
+       runtime->dma_area = vmalloc_user(size);
        if (runtime->dma_area == NULL)
                return -ENOMEM;
        runtime->dma_bytes = size;
index 83f5ee236b127cbe7c003eabfd97e426e0619145..e19dd5dcc2debd9e3b4a7fa9ec481849f8442a30 100644 (file)
@@ -269,7 +269,7 @@ static int pss_reset_dsp(pss_confdata * devc)
        unsigned long   i, limit = jiffies + HZ/10;
 
        outw(0x2000, REG(PSS_CONTROL));
-       for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
+       for (i = 0; i < 32768 && time_after_eq(limit, jiffies); i++)
                inw(REG(PSS_CONTROL));
        outw(0x0000, REG(PSS_CONTROL));
        return 1;
@@ -369,11 +369,11 @@ static int pss_download_boot(pss_confdata * devc, unsigned char *block, int size
                outw(0, REG(PSS_DATA));
 
                limit = jiffies + HZ/10;
-               for (i = 0; i < 32768 && (limit - jiffies >= 0); i++)
+               for (i = 0; i < 32768 && time_after_eq(limit, jiffies); i++)
                        val = inw(REG(PSS_STATUS));
 
                limit = jiffies + HZ/10;
-               for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
+               for (i = 0; i < 32768 && time_after_eq(limit, jiffies); i++)
                {
                        val = inw(REG(PSS_STATUS));
                        if (val & 0x4000)
index 20cb60afb200c4661b26cdc87a5e76d7604805b1..c11920623009198e555a48d2fbb22d3b4d1f8ce0 100644 (file)
@@ -2122,7 +2122,7 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
                }
                /* nothing should be in powerdown mode */
                snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0);
-               end_time = jiffies + msecs_to_jiffies(120);
+               end_time = jiffies + msecs_to_jiffies(5000);
                do {
                        if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f)
                                goto __ready_ok;
index fda7a94c992f1094f8b8d2c8d91dcb97fe868876..ccc642269b9e6a71a108df9f03d39d54f5df9029 100644 (file)
@@ -4,9 +4,7 @@
 
 snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o
 snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o
-ifdef CONFIG_MGEODE_LX
 snd-cs5535audio-$(CONFIG_OLPC) += cs5535audio_olpc.o
-endif
 
 # Toplevel Module Dependency
 obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o
index 05f56e04849b8e083e05def751b3d17bdb2e96a3..91e7faf69bbb3732dc7eb224635c6728fec31396 100644 (file)
@@ -389,6 +389,7 @@ probefail_out:
 
 static void __devexit snd_cs5535audio_remove(struct pci_dev *pci)
 {
+       olpc_quirks_cleanup();
        snd_card_free(pci_get_drvdata(pci));
        pci_set_drvdata(pci, NULL);
 }
index 7a298ac662e322e768cec22c5d3e7cadbe4fe3d9..51966d782a3cb45f02a4186b726f8cdcbc42df40 100644 (file)
@@ -99,10 +99,11 @@ int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state);
 int snd_cs5535audio_resume(struct pci_dev *pci);
 #endif
 
-#if defined(CONFIG_OLPC) && defined(CONFIG_MGEODE_LX)
+#ifdef CONFIG_OLPC
 void __devinit olpc_prequirks(struct snd_card *card,
                struct snd_ac97_template *ac97);
 int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97);
+void __devexit olpc_quirks_cleanup(void);
 void olpc_analog_input(struct snd_ac97 *ac97, int on);
 void olpc_mic_bias(struct snd_ac97 *ac97, int on);
 
@@ -128,6 +129,7 @@ static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
 {
        return 0;
 }
+static inline void olpc_quirks_cleanup(void) { }
 static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { }
 static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { }
 static inline void olpc_capture_open(struct snd_ac97 *ac97) { }
index 5c6814335cd727a83e55c58a73ef85965f633841..50da49be9ae5be7e18a5fc65be87bcfa4b0dabb1 100644 (file)
 #include <sound/info.h>
 #include <sound/control.h>
 #include <sound/ac97_codec.h>
+#include <linux/gpio.h>
 
 #include <asm/olpc.h>
 #include "cs5535audio.h"
 
+#define DRV_NAME "cs5535audio-olpc"
+
 /*
  * OLPC has an additional feature on top of the regular AD1888 codec features.
  * It has an Analog Input mode that is switched into (after disabling the
@@ -38,10 +41,7 @@ void olpc_analog_input(struct snd_ac97 *ac97, int on)
        }
 
        /* set Analog Input through GPIO */
-       if (on)
-               geode_gpio_set(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL);
-       else
-               geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL);
+       gpio_set_value(OLPC_GPIO_MIC_AC, on);
 }
 
 /*
@@ -73,8 +73,7 @@ static int olpc_dc_info(struct snd_kcontrol *kctl,
 
 static int olpc_dc_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v)
 {
-       v->value.integer.value[0] = geode_gpio_isset(OLPC_GPIO_MIC_AC,
-                       GPIO_OUTPUT_VAL);
+       v->value.integer.value[0] = gpio_get_value(OLPC_GPIO_MIC_AC);
        return 0;
 }
 
@@ -153,6 +152,12 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
        if (!machine_is_olpc())
                return 0;
 
+       if (gpio_request(OLPC_GPIO_MIC_AC, DRV_NAME)) {
+               printk(KERN_ERR DRV_NAME ": unable to allocate MIC GPIO\n");
+               return -EIO;
+       }
+       gpio_direction_output(OLPC_GPIO_MIC_AC, 0);
+
        /* drop the original AD1888 HPF control */
        memset(&elem, 0, sizeof(elem));
        elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
@@ -169,11 +174,18 @@ int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97)
        for (i = 0; i < ARRAY_SIZE(olpc_cs5535audio_ctls); i++) {
                err = snd_ctl_add(card, snd_ctl_new1(&olpc_cs5535audio_ctls[i],
                                ac97->private_data));
-               if (err < 0)
+               if (err < 0) {
+                       gpio_free(OLPC_GPIO_MIC_AC);
                        return err;
+               }
        }
 
        /* turn off the mic by default */
        olpc_mic_bias(ac97, 0);
        return 0;
 }
+
+void __devexit olpc_quirks_cleanup(void)
+{
+       gpio_free(OLPC_GPIO_MIC_AC);
+}
index 5fe34a8d8c816ae6df99d80753a97a8afed1cd3e..e4581a42ace56e62ba0e530f5a6cbd360f43b2d3 100644 (file)
@@ -42,7 +42,7 @@ static void snd_hda_generate_beep(struct work_struct *work)
                return;
 
        /* generate tone */
-       snd_hda_codec_write_cache(codec, beep->nid, 0,
+       snd_hda_codec_write(codec, beep->nid, 0,
                        AC_VERB_SET_BEEP_CONTROL, beep->tone);
 }
 
@@ -119,7 +119,7 @@ static void snd_hda_do_detach(struct hda_beep *beep)
        beep->dev = NULL;
        cancel_work_sync(&beep->beep_work);
        /* turn off beep for sure */
-       snd_hda_codec_write_cache(beep->codec, beep->nid, 0,
+       snd_hda_codec_write(beep->codec, beep->nid, 0,
                                  AC_VERB_SET_BEEP_CONTROL, 0);
 }
 
@@ -192,7 +192,7 @@ int snd_hda_enable_beep_device(struct hda_codec *codec, int enable)
                beep->enabled = enable;
                if (!enable) {
                        /* turn off beep */
-                       snd_hda_codec_write_cache(beep->codec, beep->nid, 0,
+                       snd_hda_codec_write(beep->codec, beep->nid, 0,
                                                  AC_VERB_SET_BEEP_CONTROL, 0);
                }
                if (beep->mode == HDA_BEEP_MODE_SWREG) {
@@ -239,8 +239,12 @@ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid)
        mutex_init(&beep->mutex);
 
        if (beep->mode == HDA_BEEP_MODE_ON) {
-               beep->enabled = 1;
-               snd_hda_do_register(&beep->register_work);
+               int err = snd_hda_do_attach(beep);
+               if (err < 0) {
+                       kfree(beep);
+                       codec->beep = NULL;
+                       return err;
+               }
        }
 
        return 0;
@@ -253,7 +257,7 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
        if (beep) {
                cancel_work_sync(&beep->register_work);
                cancel_delayed_work(&beep->unregister_work);
-               if (beep->enabled)
+               if (beep->dev)
                        snd_hda_do_detach(beep);
                codec->beep = NULL;
                kfree(beep);
index 9cfdb771928c81c444850fec6d7bb477017e0aeb..f98b47cd6cfb38fc97335c3788a8f7f5cc3afca1 100644 (file)
@@ -1086,11 +1086,6 @@ int snd_hda_codec_configure(struct hda_codec *codec)
                if (err < 0)
                        return err;
        }
-       /* audio codec should override the mixer name */
-       if (codec->afg || !*codec->bus->card->mixername)
-               snprintf(codec->bus->card->mixername,
-                        sizeof(codec->bus->card->mixername),
-                        "%s %s", codec->vendor_name, codec->chip_name);
 
        if (is_generic_config(codec)) {
                err = snd_hda_parse_generic_codec(codec);
@@ -1109,6 +1104,11 @@ int snd_hda_codec_configure(struct hda_codec *codec)
  patched:
        if (!err && codec->patch_ops.unsol_event)
                err = init_unsol_queue(codec->bus);
+       /* audio codec should override the mixer name */
+       if (!err && (codec->afg || !*codec->bus->card->mixername))
+               snprintf(codec->bus->card->mixername,
+                        sizeof(codec->bus->card->mixername),
+                        "%s %s", codec->vendor_name, codec->chip_name);
        return err;
 }
 EXPORT_SYMBOL_HDA(snd_hda_codec_configure);
@@ -1327,11 +1327,13 @@ EXPORT_SYMBOL_HDA(snd_hda_query_pin_caps);
  */
 u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)
 {
-       u32 pincap = snd_hda_query_pin_caps(codec, nid);
-
-       if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
-               snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
+       u32 pincap;
 
+       if (!codec->no_trigger_sense) {
+               pincap = snd_hda_query_pin_caps(codec, nid);
+               if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
+                       snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
+       }
        return snd_hda_codec_read(codec, nid, 0,
                                  AC_VERB_GET_PIN_SENSE, 0);
 }
index 1d541b7f5547cde1e3871d45e44e7cae4931a435..0a770a28e71f8b66a6c225bf08133dcec5d99390 100644 (file)
@@ -817,6 +817,7 @@ struct hda_codec {
        unsigned int pin_amp_workaround:1; /* pin out-amp takes index
                                            * (e.g. Conexant codecs)
                                            */
+       unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */
 #ifdef CONFIG_SND_HDA_POWER_SAVE
        unsigned int power_on :1;       /* current (global) power-state */
        unsigned int power_transition :1; /* power-state in transition */
index d24328661c6a8f27a935f244d31234726fd906df..40ccb419b6e97a83bdd253a05c529ad8adfec9d2 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/compat.h>
 #include <linux/mutex.h>
 #include <linux/ctype.h>
+#include <linux/string.h>
 #include <linux/firmware.h>
 #include <sound/core.h>
 #include "hda_codec.h"
@@ -428,8 +429,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf)
        char *key, *val;
        struct hda_hint *hint;
 
-       while (isspace(*buf))
-               buf++;
+       buf = skip_spaces(buf);
        if (!*buf || *buf == '#' || *buf == '\n')
                return 0;
        if (*buf == '=')
@@ -444,8 +444,7 @@ static int parse_hints(struct hda_codec *codec, const char *buf)
                return -EINVAL;
        }
        *val++ = 0;
-       while (isspace(*val))
-               val++;
+       val = skip_spaces(val);
        remove_trail_spaces(key);
        remove_trail_spaces(val);
        hint = get_hint(codec, key);
index e54420e691ae7c9e41da79f26ee277b2f0786357..ec9c348336cc383d5bb2902bc1e525bdda1afd96 100644 (file)
@@ -356,6 +356,7 @@ struct azx_dev {
                                         */
        unsigned char stream_tag;       /* assigned stream */
        unsigned char index;            /* stream index */
+       int device;                     /* last device number assigned to */
 
        unsigned int opened :1;
        unsigned int running :1;
@@ -1441,10 +1442,13 @@ static int __devinit azx_codec_configure(struct azx *chip)
  */
 
 /* assign a stream for the PCM */
-static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream)
+static inline struct azx_dev *
+azx_assign_device(struct azx *chip, struct snd_pcm_substream *substream)
 {
        int dev, i, nums;
-       if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+       struct azx_dev *res = NULL;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
                dev = chip->playback_index_offset;
                nums = chip->playback_streams;
        } else {
@@ -1453,10 +1457,15 @@ static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream)
        }
        for (i = 0; i < nums; i++, dev++)
                if (!chip->azx_dev[dev].opened) {
-                       chip->azx_dev[dev].opened = 1;
-                       return &chip->azx_dev[dev];
+                       res = &chip->azx_dev[dev];
+                       if (res->device == substream->pcm->device)
+                               break;
                }
-       return NULL;
+       if (res) {
+               res->opened = 1;
+               res->device = substream->pcm->device;
+       }
+       return res;
 }
 
 /* release the assigned stream */
@@ -1505,7 +1514,7 @@ static int azx_pcm_open(struct snd_pcm_substream *substream)
        int err;
 
        mutex_lock(&chip->open_mutex);
-       azx_dev = azx_assign_device(chip, substream->stream);
+       azx_dev = azx_assign_device(chip, substream);
        if (azx_dev == NULL) {
                mutex_unlock(&chip->open_mutex);
                return -EBUSY;
@@ -2322,6 +2331,7 @@ static void __devinit check_probe_mask(struct azx *chip, int dev)
  * white/black-list for enable_msi
  */
 static struct snd_pci_quirk msi_black_list[] __devinitdata = {
+       SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */
        {}
 };
 
@@ -2713,6 +2723,9 @@ static struct pci_device_id azx_ids[] = {
        { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
        { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
        { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
+       { PCI_DEVICE(0x10de, 0x0be2), .driver_data = AZX_DRIVER_NVIDIA },
+       { PCI_DEVICE(0x10de, 0x0be3), .driver_data = AZX_DRIVER_NVIDIA },
+       { PCI_DEVICE(0x10de, 0x0be4), .driver_data = AZX_DRIVER_NVIDIA },
        { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA },
        { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA },
        { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA },
index 447eda1f6770bb494101c7e1aba7ade9ef0a4596..69a941c7b1588b7db4a9acd0fe79da65824c8944 100644 (file)
@@ -1186,6 +1186,8 @@ static int patch_ad1986a(struct hda_codec *codec)
         */
        spec->multiout.no_share_stream = 1;
 
+       codec->no_trigger_sense = 1;
+
        return 0;
 }
 
@@ -1371,6 +1373,8 @@ static int patch_ad1983(struct hda_codec *codec)
 
        codec->patch_ops = ad198x_patch_ops;
 
+       codec->no_trigger_sense = 1;
+
        return 0;
 }
 
@@ -1789,6 +1793,14 @@ static int patch_ad1981(struct hda_codec *codec)
 
                codec->patch_ops.init = ad1981_hp_init;
                codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
+               /* set the upper-limit for mixer amp to 0dB for avoiding the
+                * possible damage by overloading
+                */
+               snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT,
+                                         (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
+                                         (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
+                                         (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
+                                         (1 << AC_AMPCAP_MUTE_SHIFT));
                break;
        case AD1981_THINKPAD:
                spec->mixers[0] = ad1981_thinkpad_mixers;
@@ -1805,6 +1817,9 @@ static int patch_ad1981(struct hda_codec *codec)
                codec->patch_ops.unsol_event = ad1981_hp_unsol_event;
                break;
        }
+
+       codec->no_trigger_sense = 1;
+
        return 0;
 }
 
@@ -3110,6 +3125,8 @@ static int patch_ad1988(struct hda_codec *codec)
 #endif
        spec->vmaster_nid = 0x04;
 
+       codec->no_trigger_sense = 1;
+
        return 0;
 }
 
@@ -3322,6 +3339,8 @@ static int patch_ad1884(struct hda_codec *codec)
 
        codec->patch_ops = ad198x_patch_ops;
 
+       codec->no_trigger_sense = 1;
+
        return 0;
 }
 
@@ -4279,6 +4298,8 @@ static int patch_ad1884a(struct hda_codec *codec)
                break;
        }
 
+       codec->no_trigger_sense = 1;
+
        return 0;
 }
 
@@ -4615,6 +4636,9 @@ static int patch_ad1882(struct hda_codec *codec)
                spec->mixers[2] = ad1882_6stack_mixers;
                break;
        }
+
+       codec->no_trigger_sense = 1;
+
        return 0;
 }
 
index 4b200da1bd18dd5524517b7feb94fc7010948966..fe0423c39598b9a98fca8f1f7af48c5bb9c7eaa9 100644 (file)
@@ -66,6 +66,7 @@ struct cs_spec {
 /* available models */
 enum {
        CS420X_MBP55,
+       CS420X_IMAC27,
        CS420X_AUTO,
        CS420X_MODELS
 };
@@ -827,7 +828,8 @@ static void cs_automute(struct hda_codec *codec)
                                    AC_VERB_SET_PIN_WIDGET_CONTROL,
                                    hp_present ? 0 : PIN_OUT);
        }
-       if (spec->board_config == CS420X_MBP55) {
+       if (spec->board_config == CS420X_MBP55 ||
+           spec->board_config == CS420X_IMAC27) {
                unsigned int gpio = hp_present ? 0x02 : 0x08;
                snd_hda_codec_write(codec, 0x01, 0,
                                    AC_VERB_SET_GPIO_DATA, gpio);
@@ -1069,12 +1071,14 @@ static int cs_parse_auto_config(struct hda_codec *codec)
 
 static const char *cs420x_models[CS420X_MODELS] = {
        [CS420X_MBP55] = "mbp55",
+       [CS420X_IMAC27] = "imac27",
        [CS420X_AUTO] = "auto",
 };
 
 
 static struct snd_pci_quirk cs420x_cfg_tbl[] = {
        SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55),
+       SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),
        {} /* terminator */
 };
 
@@ -1097,8 +1101,23 @@ static struct cs_pincfg mbp55_pincfgs[] = {
        {} /* terminator */
 };
 
+static struct cs_pincfg imac27_pincfgs[] = {
+       { 0x09, 0x012b4050 },
+       { 0x0a, 0x90100140 },
+       { 0x0b, 0x90100142 },
+       { 0x0c, 0x018b3020 },
+       { 0x0d, 0x90a00110 },
+       { 0x0e, 0x400000f0 },
+       { 0x0f, 0x01cbe030 },
+       { 0x10, 0x014be060 },
+       { 0x12, 0x01ab9070 },
+       { 0x15, 0x400000f0 },
+       {} /* terminator */
+};
+
 static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = {
        [CS420X_MBP55] = mbp55_pincfgs,
+       [CS420X_IMAC27] = imac27_pincfgs,
 };
 
 static void fix_pincfg(struct hda_codec *codec, int model)
@@ -1128,6 +1147,7 @@ static int patch_cs420x(struct hda_codec *codec)
                fix_pincfg(codec, spec->board_config);
 
        switch (spec->board_config) {
+       case CS420X_IMAC27:
        case CS420X_MBP55:
                /* GPIO1 = headphones */
                /* GPIO3 = speakers */
index a09c03c3f62bdf5df0ebece70777d5a12705d239..c578c28f368eba10cc6baacb4ea81e549436af14 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "hda_codec.h"
 #include "hda_local.h"
+#include "hda_beep.h"
 
 #define CXT_PIN_DIR_IN              0x00
 #define CXT_PIN_DIR_OUT             0x01
@@ -111,6 +112,7 @@ struct conexant_spec {
        unsigned int dell_automute;
        unsigned int port_d_mode;
        unsigned char ext_mic_bias;
+       unsigned int dell_vostro;
 };
 
 static int conexant_playback_pcm_open(struct hda_pcm_stream *hinfo,
@@ -476,6 +478,7 @@ static void conexant_free(struct hda_codec *codec)
                snd_array_free(&spec->jacks);
        }
 #endif
+       snd_hda_detach_beep_device(codec);
        kfree(codec->spec);
 }
 
@@ -2109,9 +2112,12 @@ static int cxt5066_mic_boost_mux_enum_get(struct snd_kcontrol *kcontrol,
 {
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        int val;
+       hda_nid_t nid = kcontrol->private_value & 0xff;
+       int inout = (kcontrol->private_value & 0x100) ?
+               AC_AMP_GET_INPUT : AC_AMP_GET_OUTPUT;
 
-       val = snd_hda_codec_read(codec, 0x17, 0,
-               AC_VERB_GET_AMP_GAIN_MUTE, AC_AMP_GET_OUTPUT);
+       val = snd_hda_codec_read(codec, nid, 0,
+               AC_VERB_GET_AMP_GAIN_MUTE, inout);
 
        ucontrol->value.enumerated.item[0] = val & AC_AMP_GAIN;
        return 0;
@@ -2123,6 +2129,9 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol,
        struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
        const struct hda_input_mux *imux = &cxt5066_analog_mic_boost;
        unsigned int idx;
+       hda_nid_t nid = kcontrol->private_value & 0xff;
+       int inout = (kcontrol->private_value & 0x100) ?
+               AC_AMP_SET_INPUT : AC_AMP_SET_OUTPUT;
 
        if (!imux->num_items)
                return 0;
@@ -2130,9 +2139,9 @@ static int cxt5066_mic_boost_mux_enum_put(struct snd_kcontrol *kcontrol,
        if (idx >= imux->num_items)
                idx = imux->num_items - 1;
 
-       snd_hda_codec_write_cache(codec, 0x17, 0,
+       snd_hda_codec_write_cache(codec, nid, 0,
                AC_VERB_SET_AMP_GAIN_MUTE,
-               AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | AC_AMP_SET_OUTPUT |
+               AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | inout |
                        imux->items[idx].index);
 
        return 1;
@@ -2201,10 +2210,11 @@ static struct snd_kcontrol_new cxt5066_mixers[] = {
 
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-               .name = "Analog Mic Boost Capture Enum",
+               .name = "Ext Mic Boost Capture Enum",
                .info = cxt5066_mic_boost_mux_enum_info,
                .get = cxt5066_mic_boost_mux_enum_get,
                .put = cxt5066_mic_boost_mux_enum_put,
+               .private_value = 0x17,
        },
 
        HDA_BIND_VOL("Capture Volume", &cxt5066_bind_capture_vol_others),
@@ -2212,6 +2222,19 @@ static struct snd_kcontrol_new cxt5066_mixers[] = {
        {}
 };
 
+static struct snd_kcontrol_new cxt5066_vostro_mixers[] = {
+       {
+               .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name = "Int Mic Boost Capture Enum",
+               .info = cxt5066_mic_boost_mux_enum_info,
+               .get = cxt5066_mic_boost_mux_enum_get,
+               .put = cxt5066_mic_boost_mux_enum_put,
+               .private_value = 0x23 | 0x100,
+       },
+       HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0x13, 1, 0x0, HDA_OUTPUT),
+       {}
+};
+
 static struct hda_verb cxt5066_init_verbs[] = {
        {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port B */
        {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, /* Port C */
@@ -2397,11 +2420,16 @@ static struct hda_verb cxt5066_init_verbs_portd_lo[] = {
 /* initialize jack-sensing, too */
 static int cxt5066_init(struct hda_codec *codec)
 {
+       struct conexant_spec *spec = codec->spec;
+
        snd_printdd("CXT5066: init\n");
        conexant_init(codec);
        if (codec->patch_ops.unsol_event) {
                cxt5066_hp_automute(codec);
-               cxt5066_automic(codec);
+               if (spec->dell_vostro)
+                       cxt5066_vostro_automic(codec);
+               else
+                       cxt5066_automic(codec);
        }
        return 0;
 }
@@ -2500,7 +2528,10 @@ static int patch_cxt5066(struct hda_codec *codec)
                spec->init_verbs[0] = cxt5066_init_verbs_vostro;
                spec->mixers[spec->num_mixers++] = cxt5066_mixer_master_olpc;
                spec->mixers[spec->num_mixers++] = cxt5066_mixers;
+               spec->mixers[spec->num_mixers++] = cxt5066_vostro_mixers;
                spec->port_d_mode = 0;
+               spec->dell_vostro = 1;
+               snd_hda_attach_beep_device(codec, 0x13);
 
                /* no S/PDIF out */
                spec->multiout.dig_out_nid = 0;
index 888b6313eecad1c7e017db46c5d6ef046795f338..c7465053d6bbe338cbbad141cc565726982cf5d5 100644 (file)
@@ -131,8 +131,8 @@ enum {
 enum {
        ALC269_BASIC,
        ALC269_QUANTA_FL1,
-       ALC269_ASUS_EEEPC_P703,
-       ALC269_ASUS_EEEPC_P901,
+       ALC269_ASUS_AMIC,
+       ALC269_ASUS_DMIC,
        ALC269_FUJITSU,
        ALC269_LIFEBOOK,
        ALC269_AUTO,
@@ -188,6 +188,8 @@ enum {
        ALC663_ASUS_MODE4,
        ALC663_ASUS_MODE5,
        ALC663_ASUS_MODE6,
+       ALC663_ASUS_MODE7,
+       ALC663_ASUS_MODE8,
        ALC272_DELL,
        ALC272_DELL_ZM1,
        ALC272_SAMSUNG_NC10,
@@ -335,6 +337,9 @@ struct alc_spec {
        /* hooks */
        void (*init_hook)(struct hda_codec *codec);
        void (*unsol_event)(struct hda_codec *codec, unsigned int res);
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+       void (*power_hook)(struct hda_codec *codec, int power);
+#endif
 
        /* for pin sensing */
        unsigned int sense_updated: 1;
@@ -386,6 +391,7 @@ struct alc_config_preset {
        void (*init_hook)(struct hda_codec *);
 #ifdef CONFIG_SND_HDA_POWER_SAVE
        struct hda_amp_list *loopbacks;
+       void (*power_hook)(struct hda_codec *codec, int power);
 #endif
 };
 
@@ -898,6 +904,7 @@ static void setup_preset(struct hda_codec *codec,
        spec->unsol_event = preset->unsol_event;
        spec->init_hook = preset->init_hook;
 #ifdef CONFIG_SND_HDA_POWER_SAVE
+       spec->power_hook = preset->power_hook;
        spec->loopback.amplist = preset->loopbacks;
 #endif
 
@@ -1663,9 +1670,6 @@ static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
 /*  some bit here disables the other DACs. Init=0x4900 */
        {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
        {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
-/* Enable amplifiers */
-       {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
-       {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
 /* DMIC fix
  * This laptop has a stereo digital microphone. The mics are only 1cm apart
  * which makes the stereo useless. However, either the mic or the ALC889
@@ -1778,6 +1782,25 @@ static struct snd_kcontrol_new alc888_base_mixer[] = {
        { } /* end */
 };
 
+static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
+       HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
+               HDA_OUTPUT),
+       HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
+       HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
+       HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
+       HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       { } /* end */
+};
+
+
 static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
 {
        struct alc_spec *spec = codec->spec;
@@ -1808,6 +1831,16 @@ static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
        spec->autocfg.speaker_pins[2] = 0x1b;
 }
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+static void alc889_power_eapd(struct hda_codec *codec, int power)
+{
+       snd_hda_codec_write(codec, 0x14, 0,
+                           AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0);
+       snd_hda_codec_write(codec, 0x15, 0,
+                           AC_VERB_SET_EAPD_BTLENABLE, power ? 2 : 0);
+}
+#endif
+
 /*
  * ALC880 3-stack model
  *
@@ -3601,12 +3634,29 @@ static void alc_free(struct hda_codec *codec)
        snd_hda_detach_beep_device(codec);
 }
 
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+static int alc_suspend(struct hda_codec *codec, pm_message_t state)
+{
+       struct alc_spec *spec = codec->spec;
+       if (spec && spec->power_hook)
+               spec->power_hook(codec, 0);
+       return 0;
+}
+#endif
+
 #ifdef SND_HDA_NEEDS_RESUME
 static int alc_resume(struct hda_codec *codec)
 {
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+       struct alc_spec *spec = codec->spec;
+#endif
        codec->patch_ops.init(codec);
        snd_hda_codec_resume_amp(codec);
        snd_hda_codec_resume_cache(codec);
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+       if (spec && spec->power_hook)
+               spec->power_hook(codec, 1);
+#endif
        return 0;
 }
 #endif
@@ -3623,6 +3673,7 @@ static struct hda_codec_ops alc_patch_ops = {
        .resume = alc_resume,
 #endif
 #ifdef CONFIG_SND_HDA_POWER_SAVE
+       .suspend = alc_suspend,
        .check_power_status = alc_check_power_status,
 #endif
 };
@@ -6248,6 +6299,7 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
 
 static struct snd_pci_quirk alc260_cfg_tbl[] = {
        SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
+       SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
        SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
        SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
        SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
@@ -8918,7 +8970,7 @@ static struct snd_pci_quirk alc882_cfg_tbl[] = {
        SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
        SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
        SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8  */
-       SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
+       SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
        SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
        SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
        SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
@@ -9281,6 +9333,7 @@ static struct alc_config_preset alc882_presets[] = {
                .dac_nids = alc883_dac_nids,
                .adc_nids = alc883_adc_nids_alt,
                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
+               .capsrc_nids = alc883_capsrc_nids,
                .dig_out_nid = ALC883_DIGOUT_NID,
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
                .channel_mode = alc883_3ST_2ch_modes,
@@ -9377,10 +9430,11 @@ static struct alc_config_preset alc882_presets[] = {
                .init_hook = alc_automute_amp,
        },
        [ALC888_ACER_ASPIRE_8930G] = {
-               .mixers = { alc888_base_mixer,
+               .mixers = { alc889_acer_aspire_8930g_mixer,
                                alc883_chmode_mixer },
                .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
-                               alc889_acer_aspire_8930g_verbs },
+                               alc889_acer_aspire_8930g_verbs,
+                               alc889_eapd_verbs},
                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
                .dac_nids = alc883_dac_nids,
                .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
@@ -9397,6 +9451,9 @@ static struct alc_config_preset alc882_presets[] = {
                .unsol_event = alc_automute_amp_unsol_event,
                .setup = alc889_acer_aspire_8930g_setup,
                .init_hook = alc_automute_amp,
+#ifdef CONFIG_SND_HDA_POWER_SAVE
+               .power_hook = alc889_power_eapd,
+#endif
        },
        [ALC888_ACER_ASPIRE_7730G] = {
                .mixers = { alc883_3ST_6ch_mixer,
@@ -9427,6 +9484,7 @@ static struct alc_config_preset alc882_presets[] = {
                .dac_nids = alc883_dac_nids,
                .adc_nids = alc883_adc_nids_alt,
                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
+               .capsrc_nids = alc883_capsrc_nids,
                .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
                .channel_mode = alc883_sixstack_modes,
                .input_mux = &alc883_capture_source,
@@ -9488,6 +9546,7 @@ static struct alc_config_preset alc882_presets[] = {
                .dac_nids = alc883_dac_nids,
                .adc_nids = alc883_adc_nids_alt,
                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
+               .capsrc_nids = alc883_capsrc_nids,
                .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
                .channel_mode = alc883_3ST_2ch_modes,
                .input_mux = &alc883_lenovo_101e_capture_source,
@@ -9667,6 +9726,7 @@ static struct alc_config_preset alc882_presets[] = {
                        alc880_gpio1_init_verbs },
                .adc_nids = alc883_adc_nids,
                .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
+               .capsrc_nids = alc883_capsrc_nids,
                .dac_nids = alc883_dac_nids,
                .num_dacs = ARRAY_SIZE(alc883_dac_nids),
                .channel_mode = alc889A_mb31_6ch_modes,
@@ -10677,6 +10737,13 @@ static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
        {}
 };
 
+static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
+       /* Front Mic pin: input vref at 50% */
+       {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
+       {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
+       {}
+};
+
 static struct hda_input_mux alc262_fujitsu_capture_source = {
        .num_items = 3,
        .items = {
@@ -11719,7 +11786,8 @@ static struct alc_config_preset alc262_presets[] = {
        [ALC262_LENOVO_3000] = {
                .mixers = { alc262_lenovo_3000_mixer },
                .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
-                               alc262_lenovo_3000_unsol_verbs },
+                               alc262_lenovo_3000_unsol_verbs,
+                               alc262_lenovo_3000_init_verbs },
                .num_dacs = ARRAY_SIZE(alc262_dac_nids),
                .dac_nids = alc262_dac_nids,
                .hp_nid = 0x03,
@@ -12856,7 +12924,7 @@ static int patch_alc268(struct hda_codec *codec)
        int board_config;
        int i, has_beep, err;
 
-       spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
+       spec = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
                return -ENOMEM;
 
@@ -13231,10 +13299,12 @@ static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
 /* toggle speaker-output according to the hp-jack state */
 static void alc269_speaker_automute(struct hda_codec *codec)
 {
+       struct alc_spec *spec = codec->spec;
+       unsigned int nid = spec->autocfg.hp_pins[0];
        unsigned int present;
        unsigned char bits;
 
-       present = snd_hda_jack_detect(codec, 0x15);
+       present = snd_hda_jack_detect(codec, nid);
        bits = present ? AMP_IN_MUTE(0) : 0;
        snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
                                AMP_IN_MUTE(0), bits);
@@ -13459,8 +13529,8 @@ static void alc269_auto_init(struct hda_codec *codec)
 static const char *alc269_models[ALC269_MODEL_LAST] = {
        [ALC269_BASIC]                  = "basic",
        [ALC269_QUANTA_FL1]             = "quanta",
-       [ALC269_ASUS_EEEPC_P703]        = "eeepc-p703",
-       [ALC269_ASUS_EEEPC_P901]        = "eeepc-p901",
+       [ALC269_ASUS_AMIC]              = "asus-amic",
+       [ALC269_ASUS_DMIC]              = "asus-dmic",
        [ALC269_FUJITSU]                = "fujitsu",
        [ALC269_LIFEBOOK]               = "lifebook",
        [ALC269_AUTO]                   = "auto",
@@ -13469,18 +13539,41 @@ static const char *alc269_models[ALC269_MODEL_LAST] = {
 static struct snd_pci_quirk alc269_cfg_tbl[] = {
        SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
        SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
-                     ALC269_ASUS_EEEPC_P703),
-        SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
-        SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
-        SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
-        SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
-        SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
-        SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
+                     ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80JT", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_DMIC),
+       SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_AMIC),
+       SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_AMIC),
        SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
-                     ALC269_ASUS_EEEPC_P901),
+                     ALC269_ASUS_DMIC),
        SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
-                     ALC269_ASUS_EEEPC_P901),
-        SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
+                     ALC269_ASUS_DMIC),
+       SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_ASUS_DMIC),
+       SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_ASUS_DMIC),
        SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
        SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
        {}
@@ -13510,7 +13603,7 @@ static struct alc_config_preset alc269_presets[] = {
                .setup = alc269_quanta_fl1_setup,
                .init_hook = alc269_quanta_fl1_init_hook,
        },
-       [ALC269_ASUS_EEEPC_P703] = {
+       [ALC269_ASUS_AMIC] = {
                .mixers = { alc269_eeepc_mixer },
                .cap_mixer = alc269_epc_capture_mixer,
                .init_verbs = { alc269_init_verbs,
@@ -13524,7 +13617,7 @@ static struct alc_config_preset alc269_presets[] = {
                .setup = alc269_eeepc_amic_setup,
                .init_hook = alc269_eeepc_inithook,
        },
-       [ALC269_ASUS_EEEPC_P901] = {
+       [ALC269_ASUS_DMIC] = {
                .mixers = { alc269_eeepc_mixer },
                .cap_mixer = alc269_epc_capture_mixer,
                .init_verbs = { alc269_init_verbs,
@@ -16159,6 +16252,52 @@ static struct snd_kcontrol_new alc663_g50v_mixer[] = {
        { } /* end */
 };
 
+static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
+       .ops = &snd_hda_bind_sw,
+       .values = {
+               HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
+               HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
+               HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
+               HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
+               HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
+               0
+       },
+};
+
+static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
+       .ops = &snd_hda_bind_sw,
+       .values = {
+               HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
+               HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
+               0
+       },
+};
+
+static struct snd_kcontrol_new alc663_mode7_mixer[] = {
+       HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
+       HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
+       HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
+       HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
+       { } /* end */
+};
+
+static struct snd_kcontrol_new alc663_mode8_mixer[] = {
+       HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
+       HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
+       HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
+       HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
+       HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
+       HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
+       HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
+       { } /* end */
+};
+
+
 static struct snd_kcontrol_new alc662_chmode_mixer[] = {
        {
                .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -16446,6 +16585,45 @@ static struct hda_verb alc272_dell_init_verbs[] = {
        {}
 };
 
+static struct hda_verb alc663_mode7_init_verbs[] = {
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
+       {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Headphone */
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
+       {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
+       {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {}
+};
+
+static struct hda_verb alc663_mode8_init_verbs[] = {
+       {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
+       {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
+       {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
+       {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
+       {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
+       {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},  /* Headphone */
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
+       {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
+       {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
+       {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
+       {}
+};
+
 static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
        HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
        HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
@@ -16625,6 +16803,54 @@ static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
        }
 }
 
+static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
+{
+       unsigned int present1, present2;
+
+       present1 = snd_hda_codec_read(codec, 0x1b, 0,
+                       AC_VERB_GET_PIN_SENSE, 0)
+                       & AC_PINSENSE_PRESENCE;
+       present2 = snd_hda_codec_read(codec, 0x21, 0,
+                       AC_VERB_GET_PIN_SENSE, 0)
+                       & AC_PINSENSE_PRESENCE;
+
+       if (present1 || present2) {
+               snd_hda_codec_write_cache(codec, 0x14, 0,
+                       AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+               snd_hda_codec_write_cache(codec, 0x17, 0,
+                       AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+       } else {
+               snd_hda_codec_write_cache(codec, 0x14, 0,
+                       AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
+               snd_hda_codec_write_cache(codec, 0x17, 0,
+                       AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
+       }
+}
+
+static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
+{
+       unsigned int present1, present2;
+
+       present1 = snd_hda_codec_read(codec, 0x21, 0,
+                       AC_VERB_GET_PIN_SENSE, 0)
+                       & AC_PINSENSE_PRESENCE;
+       present2 = snd_hda_codec_read(codec, 0x15, 0,
+                       AC_VERB_GET_PIN_SENSE, 0)
+                       & AC_PINSENSE_PRESENCE;
+
+       if (present1 || present2) {
+               snd_hda_codec_write_cache(codec, 0x14, 0,
+                       AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+               snd_hda_codec_write_cache(codec, 0x17, 0,
+                       AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
+       } else {
+               snd_hda_codec_write_cache(codec, 0x14, 0,
+                       AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
+               snd_hda_codec_write_cache(codec, 0x17, 0,
+                       AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
+       }
+}
+
 static void alc663_m51va_unsol_event(struct hda_codec *codec,
                                           unsigned int res)
 {
@@ -16644,7 +16870,7 @@ static void alc663_m51va_setup(struct hda_codec *codec)
        spec->ext_mic.pin = 0x18;
        spec->ext_mic.mux_idx = 0;
        spec->int_mic.pin = 0x12;
-       spec->int_mic.mux_idx = 1;
+       spec->int_mic.mux_idx = 9;
        spec->auto_mic = 1;
 }
 
@@ -16656,7 +16882,17 @@ static void alc663_m51va_inithook(struct hda_codec *codec)
 
 /* ***************** Mode1 ******************************/
 #define alc663_mode1_unsol_event       alc663_m51va_unsol_event
-#define alc663_mode1_setup             alc663_m51va_setup
+
+static void alc663_mode1_setup(struct hda_codec *codec)
+{
+       struct alc_spec *spec = codec->spec;
+       spec->ext_mic.pin = 0x18;
+       spec->ext_mic.mux_idx = 0;
+       spec->int_mic.pin = 0x19;
+       spec->int_mic.mux_idx = 1;
+       spec->auto_mic = 1;
+}
+
 #define alc663_mode1_inithook          alc663_m51va_inithook
 
 /* ***************** Mode2 ******************************/
@@ -16673,7 +16909,7 @@ static void alc662_mode2_unsol_event(struct hda_codec *codec,
        }
 }
 
-#define alc662_mode2_setup     alc663_m51va_setup
+#define alc662_mode2_setup     alc663_mode1_setup
 
 static void alc662_mode2_inithook(struct hda_codec *codec)
 {
@@ -16694,7 +16930,7 @@ static void alc663_mode3_unsol_event(struct hda_codec *codec,
        }
 }
 
-#define alc663_mode3_setup     alc663_m51va_setup
+#define alc663_mode3_setup     alc663_mode1_setup
 
 static void alc663_mode3_inithook(struct hda_codec *codec)
 {
@@ -16715,7 +16951,7 @@ static void alc663_mode4_unsol_event(struct hda_codec *codec,
        }
 }
 
-#define alc663_mode4_setup     alc663_m51va_setup
+#define alc663_mode4_setup     alc663_mode1_setup
 
 static void alc663_mode4_inithook(struct hda_codec *codec)
 {
@@ -16736,7 +16972,7 @@ static void alc663_mode5_unsol_event(struct hda_codec *codec,
        }
 }
 
-#define alc663_mode5_setup     alc663_m51va_setup
+#define alc663_mode5_setup     alc663_mode1_setup
 
 static void alc663_mode5_inithook(struct hda_codec *codec)
 {
@@ -16757,7 +16993,7 @@ static void alc663_mode6_unsol_event(struct hda_codec *codec,
        }
 }
 
-#define alc663_mode6_setup     alc663_m51va_setup
+#define alc663_mode6_setup     alc663_mode1_setup
 
 static void alc663_mode6_inithook(struct hda_codec *codec)
 {
@@ -16765,6 +17001,50 @@ static void alc663_mode6_inithook(struct hda_codec *codec)
        alc_mic_automute(codec);
 }
 
+/* ***************** Mode7 ******************************/
+static void alc663_mode7_unsol_event(struct hda_codec *codec,
+                                          unsigned int res)
+{
+       switch (res >> 26) {
+       case ALC880_HP_EVENT:
+               alc663_two_hp_m7_speaker_automute(codec);
+               break;
+       case ALC880_MIC_EVENT:
+               alc_mic_automute(codec);
+               break;
+       }
+}
+
+#define alc663_mode7_setup     alc663_mode1_setup
+
+static void alc663_mode7_inithook(struct hda_codec *codec)
+{
+       alc663_two_hp_m7_speaker_automute(codec);
+       alc_mic_automute(codec);
+}
+
+/* ***************** Mode8 ******************************/
+static void alc663_mode8_unsol_event(struct hda_codec *codec,
+                                          unsigned int res)
+{
+       switch (res >> 26) {
+       case ALC880_HP_EVENT:
+               alc663_two_hp_m8_speaker_automute(codec);
+               break;
+       case ALC880_MIC_EVENT:
+               alc_mic_automute(codec);
+               break;
+       }
+}
+
+#define alc663_mode8_setup     alc663_m51va_setup
+
+static void alc663_mode8_inithook(struct hda_codec *codec)
+{
+       alc663_two_hp_m8_speaker_automute(codec);
+       alc_mic_automute(codec);
+}
+
 static void alc663_g71v_hp_automute(struct hda_codec *codec)
 {
        unsigned int present;
@@ -16899,6 +17179,8 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
        [ALC663_ASUS_MODE4] = "asus-mode4",
        [ALC663_ASUS_MODE5] = "asus-mode5",
        [ALC663_ASUS_MODE6] = "asus-mode6",
+       [ALC663_ASUS_MODE7] = "asus-mode7",
+       [ALC663_ASUS_MODE8] = "asus-mode8",
        [ALC272_DELL]           = "dell",
        [ALC272_DELL_ZM1]       = "dell-zm1",
        [ALC272_SAMSUNG_NC10]   = "samsung-nc10",
@@ -16915,12 +17197,22 @@ static struct snd_pci_quirk alc662_cfg_tbl[] = {
        SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
        SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
        SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
+       SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
+       SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
        SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
+       SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
+       SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
+       SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
+       SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
+       SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
        SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
+       SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
+       SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
        SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
        SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
        SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
        SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
+       SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
        SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
        SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
        SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
@@ -17204,6 +17496,36 @@ static struct alc_config_preset alc662_presets[] = {
                .setup = alc663_mode6_setup,
                .init_hook = alc663_mode6_inithook,
        },
+       [ALC663_ASUS_MODE7] = {
+               .mixers = { alc663_mode7_mixer },
+               .cap_mixer = alc662_auto_capture_mixer,
+               .init_verbs = { alc662_init_verbs,
+                               alc663_mode7_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc662_dac_nids),
+               .hp_nid = 0x03,
+               .dac_nids = alc662_dac_nids,
+               .dig_out_nid = ALC662_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
+               .channel_mode = alc662_3ST_2ch_modes,
+               .unsol_event = alc663_mode7_unsol_event,
+               .setup = alc663_mode7_setup,
+               .init_hook = alc663_mode7_inithook,
+       },
+       [ALC663_ASUS_MODE8] = {
+               .mixers = { alc663_mode8_mixer },
+               .cap_mixer = alc662_auto_capture_mixer,
+               .init_verbs = { alc662_init_verbs,
+                               alc663_mode8_init_verbs },
+               .num_dacs = ARRAY_SIZE(alc662_dac_nids),
+               .hp_nid = 0x03,
+               .dac_nids = alc662_dac_nids,
+               .dig_out_nid = ALC662_DIGOUT_NID,
+               .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
+               .channel_mode = alc662_3ST_2ch_modes,
+               .unsol_event = alc663_mode8_unsol_event,
+               .setup = alc663_mode8_setup,
+               .init_hook = alc663_mode8_inithook,
+       },
        [ALC272_DELL] = {
                .mixers = { alc663_m51va_mixer },
                .cap_mixer = alc272_auto_capture_mixer,
@@ -17687,7 +18009,9 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = {
        { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
        { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
        { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
+       { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
        { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
+       { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
        { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
          .patch = patch_alc861 },
        { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
index 3d59f83258489d4d89d7bb2399e78430afaff2d8..2291a839681795606ee9333920627966c577069d 100644 (file)
@@ -2104,6 +2104,7 @@ static unsigned int ref9205_pin_configs[12] = {
     10280204
     1028021F
     10280228 (Dell Vostro 1500)
+    10280229 (Dell Vostro 1700)
 */
 static unsigned int dell_9205_m42_pin_configs[12] = {
        0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
@@ -2189,6 +2190,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
                      "Dell Inspiron", STAC_9205_DELL_M44),
        SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
                      "Dell Vostro 1500", STAC_9205_DELL_M42),
+       SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
+                     "Dell Vostro 1700", STAC_9205_DELL_M42),
        /* Gateway */
        SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
        SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
@@ -3779,15 +3782,16 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                err = snd_hda_attach_beep_device(codec, nid);
                if (err < 0)
                        return err;
-               /* IDT/STAC codecs have linear beep tone parameter */
-               codec->beep->linear_tone = 1;
-               /* if no beep switch is available, make its own one */
-               caps = query_amp_caps(codec, nid, HDA_OUTPUT);
-               if (codec->beep &&
-                   !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
-                       err = stac92xx_beep_switch_ctl(codec);
-                       if (err < 0)
-                               return err;
+               if (codec->beep) {
+                       /* IDT/STAC codecs have linear beep tone parameter */
+                       codec->beep->linear_tone = 1;
+                       /* if no beep switch is available, make its own one */
+                       caps = query_amp_caps(codec, nid, HDA_OUTPUT);
+                       if (!(caps & AC_AMPCAP_MUTE)) {
+                               err = stac92xx_beep_switch_ctl(codec);
+                               if (err < 0)
+                                       return err;
+                       }
                }
        }
 #endif
@@ -4449,14 +4453,7 @@ static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
 {
        if (!nid)
                return 0;
-       /* NOTE: we can't use snd_hda_jack_detect() here because STAC/IDT
-        * codecs behave wrongly when SET_PIN_SENSE is triggered, although
-        * the pincap gives TRIG_REQ bit.
-        */
-       if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0) &
-           AC_PINSENSE_PRESENCE)
-               return 1;
-       return 0;
+       return snd_hda_jack_detect(codec, nid);
 }
 
 static void stac92xx_line_out_detect(struct hda_codec *codec,
@@ -4958,6 +4955,7 @@ static int patch_stac9200(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
        spec->pin_nids = stac9200_pin_nids;
@@ -5020,6 +5018,7 @@ static int patch_stac925x(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
        spec->pin_nids = stac925x_pin_nids;
@@ -5104,6 +5103,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
        spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
@@ -5251,6 +5251,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
        spec->digbeep_nid = 0x21;
@@ -5414,6 +5415,7 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        codec->patch_ops = stac92xx_patch_ops;
        spec->num_pins = STAC92HD71BXX_NUM_PINS;
@@ -5657,6 +5659,7 @@ static int patch_stac922x(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
        spec->pin_nids = stac922x_pin_nids;
@@ -5760,6 +5763,7 @@ static int patch_stac927x(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        codec->slave_dig_outs = stac927x_slave_dig_outs;
        spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
@@ -5894,6 +5898,7 @@ static int patch_stac9205(struct hda_codec *codec)
        if (spec == NULL)
                return -ENOMEM;
 
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
        spec->pin_nids = stac9205_pin_nids;
@@ -6049,6 +6054,7 @@ static int patch_stac9872(struct hda_codec *codec)
        spec  = kzalloc(sizeof(*spec), GFP_KERNEL);
        if (spec == NULL)
                return -ENOMEM;
+       codec->no_trigger_sense = 1;
        codec->spec = spec;
        spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
        spec->pin_nids = stac9872_pin_nids;
index d057e648964389a53c7905a68311ecf35aff552a..5cfa608823f78d65e3f80d9e6b9ff08e377acb31 100644 (file)
@@ -51,7 +51,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t s
                        return 0; /* already enough large */
                vfree(runtime->dma_area);
        }
-       runtime->dma_area = vmalloc_32(size);
+       runtime->dma_area = vmalloc_32_user(size);
        if (! runtime->dma_area)
                return -ENOMEM;
        runtime->dma_bytes = size;
index b69861d521610d9c4ba16ec7e4d8542202e798fc..3ef16bbc8c8397a3e808f63901c12fddd3135ad8 100644 (file)
@@ -470,7 +470,7 @@ EXPORT_SYMBOL_GPL(soc_codec_dev_ak4642);
 
 static int __init ak4642_modinit(void)
 {
-       int ret;
+       int ret = 0;
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
        ret = i2c_add_driver(&ak4642_i2c_driver);
 #endif
index bbc72c2ddfca0292f536638cfd62dc278610b045..81b8c9dfe7fc3253034c034afd288d500cd26848 100644 (file)
@@ -191,6 +191,7 @@ static int ac97_analog_prepare(struct snd_pcm_substream *substream,
        vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS);
 
        vra |= 0x1; /* enable variable rate audio */
+       vra &= ~0x4; /* disable SPDIF output */
 
        stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra);
 
@@ -221,22 +222,6 @@ static int ac97_digital_prepare(struct snd_pcm_substream *substream,
        return stac9766_ac97_write(codec, reg, runtime->rate);
 }
 
-static int ac97_digital_trigger(struct snd_pcm_substream *substream,
-                               int cmd, struct snd_soc_dai *dai)
-{
-       struct snd_soc_codec *codec = dai->codec;
-       unsigned short vra;
-
-       switch (cmd) {
-       case SNDRV_PCM_TRIGGER_STOP:
-               vra = stac9766_ac97_read(codec, AC97_EXTENDED_STATUS);
-               vra &= !0x04;
-               stac9766_ac97_write(codec, AC97_EXTENDED_STATUS, vra);
-               break;
-       }
-       return 0;
-}
-
 static int stac9766_set_bias_level(struct snd_soc_codec *codec,
                                   enum snd_soc_bias_level level)
 {
@@ -315,7 +300,6 @@ static struct snd_soc_dai_ops stac9766_dai_ops_analog = {
 
 static struct snd_soc_dai_ops stac9766_dai_ops_digital = {
        .prepare = ac97_digital_prepare,
-       .trigger = ac97_digital_trigger,
 };
 
 struct snd_soc_dai stac9766_dai[] = {
index c9438dd62df34afc439d17728d9aaa18e81d9f53..dbc368c08263adab922dfbbd62570cb73409926f 100644 (file)
@@ -199,7 +199,7 @@ static void wm8900_reset(struct snd_soc_codec *codec)
        snd_soc_write(codec, WM8900_REG_RESET, 0);
 
        memcpy(codec->reg_cache, wm8900_reg_defaults,
-              sizeof(codec->reg_cache));
+              sizeof(wm8900_reg_defaults));
 }
 
 static int wm8900_hp_event(struct snd_soc_dapm_widget *w,
index 81c57b5c591c5d35676eae9d3dfa5f1858326149..a808675388fc99d6e9a03cca06e0ce2f5114d829 100644 (file)
@@ -47,7 +47,7 @@ static const u16 wm8974_reg[WM8974_CACHEREGNUM] = {
 };
 
 #define WM8974_POWER1_BIASEN  0x08
-#define WM8974_POWER1_BUFIOEN 0x10
+#define WM8974_POWER1_BUFIOEN 0x04
 
 struct wm8974_priv {
        struct snd_soc_codec codec;
index 0ac1215dcd9b5e3140b4fa662d44c91f4ec8bc30..e237bf615129cb7e32799f85762842bd683898a4 100644 (file)
@@ -463,7 +463,8 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg,
 {
        u16 *cache = codec->reg_cache;
 
-       soc_ac97_ops.write(codec->ac97, reg, val);
+       if (reg < 0x7c)
+               soc_ac97_ops.write(codec->ac97, reg, val);
        reg = reg >> 1;
        if (reg < (ARRAY_SIZE(wm9712_reg)))
                cache[reg] = val;
index 0267d2d91685775ff6f5e957df424794180ae781..07d2a248438c059ec3d5c8c5f1ebf28fa8f03895 100644 (file)
@@ -180,7 +180,8 @@ static int mx27vis_hifi_hw_free(struct snd_pcm_substream *substream)
        struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
 
        /* disable the PLL */
-       return codec_dai->ops->set_pll(codec_dai, IGNORED_ARG, 0, 0);
+       return codec_dai->ops->set_pll(codec_dai, IGNORED_ARG, IGNORED_ARG,
+                                      0, 0);
 }
 
 /*
index c071f9603a380b4688e36fe8525ad87301e1b5cb..3c85c0f92823b82a87affec967b663966c279f4d 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <linux/clk.h>
 #include <linux/platform_device.h>
-#include <linux/i2c/twl4030.h>
+#include <linux/i2c/twl.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/soc.h>
@@ -321,11 +321,11 @@ static int __init sdp3430_soc_init(void)
        *(unsigned int *)sdp3430_dai[1].cpu_dai->private_data = 2; /* McBSP3 */
 
        /* Set TWL4030 GPIO6 as EXTMUTE signal */
-       twl4030_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux,
+       twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux,
                                                TWL4030_INTBR_PMBR1);
        pin_mux &= ~TWL4030_GPIO6_PWM0_MUTE(0x03);
        pin_mux |= TWL4030_GPIO6_PWM0_MUTE(0x02);
-       twl4030_i2c_write_u8(TWL4030_MODULE_INTBR, pin_mux,
+       twl_i2c_write_u8(TWL4030_MODULE_INTBR, pin_mux,
                                                TWL4030_INTBR_PMBR1);
 
        ret = platform_device_add(sdp3430_snd_device);
index d441c3b646317799000c046b10648dc60b3cae5b..4984754f3298dac412f9ee22dfbce4de5f5804f8 100644 (file)
@@ -312,7 +312,7 @@ int simtec_audio_resume(struct device *dev)
        return 0;
 }
 
-struct dev_pm_ops simtec_audio_pmops = {
+const struct dev_pm_ops simtec_audio_pmops = {
        .resume = simtec_audio_resume,
 };
 EXPORT_SYMBOL_GPL(simtec_audio_pmops);
index 2714203af161b369c839d470e673bb500266959c..e18faee30cce0a388b2d06d2ba9a676200117d16 100644 (file)
@@ -15,7 +15,7 @@ extern int simtec_audio_core_probe(struct platform_device *pdev,
 extern int simtec_audio_remove(struct platform_device *pdev);
 
 #ifdef CONFIG_PM
-extern struct dev_pm_ops simtec_audio_pmops;
+extern const struct dev_pm_ops simtec_audio_pmops;
 #define simtec_audio_pm &simtec_audio_pmops
 #else
 #define simtec_audio_pm NULL
index 9c49c11c43ce4da1af6a122bd041dfce9e228838..42813b80838988c96b62cf5a91f06d870dbc2f6e 100644 (file)
@@ -876,7 +876,7 @@ static int fsi_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
-       if (!res || !irq) {
+       if (!res || (int)irq <= 0) {
                dev_err(&pdev->dev, "Not enough FSI platform resources.\n");
                ret = -ENODEV;
                goto exit;
index ef8f28284cb900372c7bf536a4d835b6e1ab9306..0a6440c6f54a80a9af52aa10ffe9d898fe5c456d 100644 (file)
@@ -1236,7 +1236,7 @@ static int soc_poweroff(struct device *dev)
        return 0;
 }
 
-static struct dev_pm_ops soc_pm_ops = {
+static const struct dev_pm_ops soc_pm_ops = {
        .suspend = soc_suspend,
        .resume = soc_resume,
        .poweroff = soc_poweroff,
index b074a594c595444994824c9384350ae3d019859d..4963defee18a210632ea8a8fd7c2b1e2d54f5476 100644 (file)
@@ -752,7 +752,7 @@ static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t s
                        return 0; /* already large enough */
                vfree(runtime->dma_area);
        }
-       runtime->dma_area = vmalloc(size);
+       runtime->dma_area = vmalloc_user(size);
        if (!runtime->dma_area)
                return -ENOMEM;
        runtime->dma_bytes = size;
diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
new file mode 100644 (file)
index 0000000..8974e20
--- /dev/null
@@ -0,0 +1,55 @@
+perf-diff(1)
+==============
+
+NAME
+----
+perf-diff - Read two perf.data files and display the differential profile
+
+SYNOPSIS
+--------
+[verse]
+'perf diff' [oldfile] [newfile]
+
+DESCRIPTION
+-----------
+This command displays the performance difference amongst two perf.data files
+captured via perf record.
+
+If no parameters are passed it will assume perf.data.old and perf.data.
+
+OPTIONS
+-------
+-d::
+--dsos=::
+       Only consider symbols in these dsos. CSV that understands
+       file://filename entries.
+
+-C::
+--comms=::
+       Only consider symbols in these comms. CSV that understands
+       file://filename entries.
+
+-S::
+--symbols=::
+       Only consider these symbols. CSV that understands
+       file://filename entries.
+
+-s::
+--sort=::
+       Sort by key(s): pid, comm, dso, symbol.
+
+-t::
+--field-separator=::
+
+       Use a special separator character and don't pad with spaces, replacing
+       all occurances of this separator in symbol names (and other output)
+       with a '.' character, that thus it's the only non valid separator.
+
+-v::
+--verbose::
+       Be verbose, for instance, show the raw counts in addition to the
+       diff.
+
+SEE ALSO
+--------
+linkperf:perf-record[1]
index 8fa6bf99fcb570c334424627df4021671e2e1d97..250e391b4bc838691f13e4c407193935ccfb83e8 100644 (file)
@@ -49,8 +49,9 @@ PROBE SYNTAX
 ------------
 Probe points are defined by following syntax.
 
- "FUNC[+OFFS|:RLN|%return][@SRC]|SRC:ALN [ARG ...]"
+ "[EVENT=]FUNC[+OFFS|:RLN|%return][@SRC]|SRC:ALN [ARG ...]"
 
+'EVENT' specifies the name of new event, if omitted, it will be set the name of the probed function. Currently, event group name is set as 'probe'.
 'FUNC' specifies a probed function name, and it may have one of the following options; '+OFFS' is the offset from function entry address in bytes, 'RLN' is the relative-line number from function entry line, and '%return' means that it probes function return. In addition, 'SRC' specifies a source file which has that function.
 It is also possible to specify a probe point by the source line number by using 'SRC:ALN' syntax, where 'SRC' is the source file path and 'ALN' is the line number.
 'ARG' specifies the arguments of this probe point. You can use the name of local variable, or kprobe-tracer argument format (e.g. $retval, %ax, etc).
index 9dccb180b7af3c878e41b8807de2533efbe269c4..abfabe9147a4f2a48b6fd47bfdb758de2a3f3eea 100644 (file)
@@ -39,6 +39,10 @@ OPTIONS
        Only consider these symbols. CSV that understands
        file://filename entries.
 
+-s::
+--sort=::
+       Sort by key(s): pid, comm, dso, symbol, parent.
+
 -w::
 --field-width=::
        Force each column width to the provided list, for large terminal
index 07065efa60e09b9a8ca3559583b7cdfd63ac2c0a..60e5900da483edb91da41dc3a149aff62092c7a8 100644 (file)
@@ -8,18 +8,43 @@ perf-trace - Read perf.data (created by perf record) and display trace output
 SYNOPSIS
 --------
 [verse]
-'perf trace' [-i <file> | --input=file] symbol_name
+'perf trace' {record <script> | report <script> [args] }
 
 DESCRIPTION
 -----------
 This command reads the input file and displays the trace recorded.
 
+There are several variants of perf trace:
+
+  'perf trace' to see a detailed trace of the workload that was
+  recorded.
+
+  'perf trace record <script>' to record the events required for 'perf
+  trace report'.  <script> is the name displayed in the output of
+  'perf trace --list' i.e. the actual script name minus any language
+  extension.
+
+  'perf trace report <script>' to run and display the results of
+  <script>.  <script> is the name displayed in the output of 'perf
+  trace --list' i.e. the actual script name minus any language
+  extension.  The perf.data output from a previous run of 'perf trace
+  record <script>' is used and should be present for this command to
+  succeed.
+
 OPTIONS
 -------
 -D::
 --dump-raw-trace=::
         Display verbose dump of the trace data.
 
+-L::
+--Latency=::
+        Show latency attributes (irqs/preemption disabled, etc).
+
+-l::
+--list=::
+        Display a list of available trace scripts.
+
 -s::
 --script=::
         Process trace data with the given script ([lang]:script[.ext]).
index 406999668cab5b4538317898cd5ebf1c21718109..4390d225686d63360cf9c5e8bbc87b9bebdec8af 100644 (file)
@@ -370,7 +370,6 @@ LIB_H += util/values.h
 LIB_H += util/sort.h
 LIB_H += util/hist.h
 LIB_H += util/thread.h
-LIB_H += util/data_map.h
 LIB_H += util/probe-finder.h
 LIB_H += util/probe-event.h
 
@@ -428,6 +427,7 @@ BUILTIN_OBJS += bench/sched-messaging.o
 BUILTIN_OBJS += bench/sched-pipe.o
 BUILTIN_OBJS += bench/mem-memcpy.o
 
+BUILTIN_OBJS += builtin-diff.o
 BUILTIN_OBJS += builtin-help.o
 BUILTIN_OBJS += builtin-sched.o
 BUILTIN_OBJS += builtin-buildid-list.o
@@ -487,10 +487,11 @@ else
        msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
 endif
 
-ifneq ($(shell sh -c "(echo '\#include <libdwarf/dwarf.h>'; echo '\#include <libdwarf/libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
+ifneq ($(shell sh -c "(echo '\#ifndef _MIPS_SZLONG'; echo '\#define _MIPS_SZLONG 0'; echo '\#endif'; echo '\#include <dwarf.h>'; echo '\#include <libdwarf.h>'; echo 'int main(void) { Dwarf_Debug dbg; Dwarf_Error err; Dwarf_Ranges *rng; dwarf_init(0, DW_DLC_READ, 0, 0, &dbg, &err); dwarf_get_ranges(dbg, 0, &rng, 0, 0, &err); return (long)dbg; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libdwarf -ldwarf -lelf -o /dev/null $(ALL_LDFLAGS) $(EXTLIBS) "$(QUIET_STDERR)" && echo y"), y)
        msg := $(warning No libdwarf.h found or old libdwarf.h found, disables dwarf support. Please install libdwarf-dev/libdwarf-devel >= 20081231);
        BASIC_CFLAGS += -DNO_LIBDWARF
 else
+       BASIC_CFLAGS += -I/usr/include/libdwarf
        EXTLIBS += -lelf -ldwarf
        LIB_OBJS += util/probe-finder.o
 endif
@@ -996,8 +997,6 @@ install: all
        $(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'
        $(INSTALL) scripts/perl/*.pl -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'
        $(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
-       $(INSTALL) scripts/perl/Perf-Trace-Util/Makefile.PL -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util'
-       $(INSTALL) scripts/perl/Perf-Trace-Util/README -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util'
 ifdef BUILT_INS
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
        $(INSTALL) $(BUILT_INS) '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
index 21a78d30d53dcf584a27ede521b34ddeb53118a3..593ff25006defbd405713e1c1c24653911760a4f 100644 (file)
@@ -26,7 +26,6 @@
 #include "util/sort.h"
 #include "util/hist.h"
 #include "util/session.h"
-#include "util/data_map.h"
 
 static char            const *input_name = "perf.data";
 
@@ -52,11 +51,6 @@ struct sym_priv {
        struct sym_ext  *ext;
 };
 
-static struct symbol_conf symbol_conf = {
-       .priv_size        = sizeof(struct sym_priv),
-       .try_vmlinux_path = true,
-};
-
 static const char *sym_hist_filter;
 
 static int symbol_filter(struct map *map __used, struct symbol *sym)
@@ -122,30 +116,32 @@ static void hist_hit(struct hist_entry *he, u64 ip)
                        h->ip[offset]);
 }
 
-static int hist_entry__add(struct addr_location *al, u64 count)
+static int perf_session__add_hist_entry(struct perf_session *self,
+                                       struct addr_location *al, u64 count)
 {
        bool hit;
-       struct hist_entry *he = __hist_entry__add(al, NULL, count, &hit);
+       struct hist_entry *he = __perf_session__add_hist_entry(self, al, NULL,
+                                                              count, &hit);
        if (he == NULL)
                return -ENOMEM;
        hist_hit(he, al->addr);
        return 0;
 }
 
-static int process_sample_event(event_t *event)
+static int process_sample_event(event_t *event, struct perf_session *session)
 {
        struct addr_location al;
 
        dump_printf("(IP, %d): %d: %p\n", event->header.misc,
                    event->ip.pid, (void *)(long)event->ip.ip);
 
-       if (event__preprocess_sample(event, &al, symbol_filter) < 0) {
+       if (event__preprocess_sample(event, session, &al, symbol_filter) < 0) {
                fprintf(stderr, "problem processing %d event, skipping it.\n",
                        event->header.type);
                return -1;
        }
 
-       if (hist_entry__add(&al, 1)) {
+       if (!al.filtered && perf_session__add_hist_entry(session, &al, 1)) {
                fprintf(stderr, "problem incrementing symbol count, "
                                "skipping event\n");
                return -1;
@@ -429,11 +425,11 @@ static void annotate_sym(struct hist_entry *he)
                free_source_line(he, len);
 }
 
-static void find_annotations(void)
+static void perf_session__find_annotations(struct perf_session *self)
 {
        struct rb_node *nd;
 
-       for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) {
+       for (nd = rb_first(&self->hists); nd; nd = rb_next(nd)) {
                struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node);
                struct sym_priv *priv;
 
@@ -454,7 +450,7 @@ static void find_annotations(void)
        }
 }
 
-static struct perf_file_handler file_handler = {
+static struct perf_event_ops event_ops = {
        .process_sample_event   = process_sample_event,
        .process_mmap_event     = event__process_mmap,
        .process_comm_event     = event__process_comm,
@@ -463,17 +459,14 @@ static struct perf_file_handler file_handler = {
 
 static int __cmd_annotate(void)
 {
-       struct perf_session *session = perf_session__new(input_name, O_RDONLY, force);
-       struct thread *idle;
        int ret;
+       struct perf_session *session;
 
+       session = perf_session__new(input_name, O_RDONLY, force);
        if (session == NULL)
                return -ENOMEM;
 
-       idle = register_idle_thread();
-       register_perf_file_handler(&file_handler);
-
-       ret = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
+       ret = perf_session__process_events(session, &event_ops);
        if (ret)
                goto out_delete;
 
@@ -483,15 +476,14 @@ static int __cmd_annotate(void)
        }
 
        if (verbose > 3)
-               threads__fprintf(stdout);
+               perf_session__fprintf(session, stdout);
 
        if (verbose > 2)
                dsos__fprintf(stdout);
 
-       collapse__resort();
-       output__resort(event__total[0]);
-
-       find_annotations();
+       perf_session__collapse_resort(session);
+       perf_session__output_resort(session, session->event_total[0]);
+       perf_session__find_annotations(session);
 out_delete:
        perf_session__delete(session);
 
@@ -524,29 +516,17 @@ static const struct option options[] = {
        OPT_END()
 };
 
-static void setup_sorting(void)
+int cmd_annotate(int argc, const char **argv, const char *prefix __used)
 {
-       char *tmp, *tok, *str = strdup(sort_order);
-
-       for (tok = strtok_r(str, ", ", &tmp);
-                       tok; tok = strtok_r(NULL, ", ", &tmp)) {
-               if (sort_dimension__add(tok) < 0) {
-                       error("Unknown --sort key: `%s'", tok);
-                       usage_with_options(annotate_usage, options);
-               }
-       }
+       argc = parse_options(argc, argv, options, annotate_usage, 0);
 
-       free(str);
-}
+       symbol_conf.priv_size = sizeof(struct sym_priv);
+       symbol_conf.try_vmlinux_path = true;
 
-int cmd_annotate(int argc, const char **argv, const char *prefix __used)
-{
-       if (symbol__init(&symbol_conf) < 0)
+       if (symbol__init() < 0)
                return -1;
 
-       argc = parse_options(argc, argv, options, annotate_usage, 0);
-
-       setup_sorting();
+       setup_sorting(annotate_usage, options);
 
        if (argc) {
                /*
index bfd16a1594e4abbcca6d0970eb6bc14571c75c6b..e693e6777af5a3418d3f0b542a4197b2383aa741 100644 (file)
@@ -9,7 +9,6 @@
 #include "builtin.h"
 #include "perf.h"
 #include "util/cache.h"
-#include "util/data_map.h"
 #include "util/debug.h"
 #include "util/parse-options.h"
 #include "util/session.h"
@@ -55,8 +54,9 @@ static int perf_file_section__process_buildids(struct perf_file_section *self,
 static int __cmd_buildid_list(void)
 {
        int err = -1;
-       struct perf_session *session = perf_session__new(input_name, O_RDONLY, force);
+       struct perf_session *session;
 
+       session = perf_session__new(input_name, O_RDONLY, force);
        if (session == NULL)
                return -1;
 
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
new file mode 100644 (file)
index 0000000..4d33b55
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ * builtin-diff.c
+ *
+ * Builtin diff command: Analyze two perf.data input files, look up and read
+ * DSOs and symbol information, sort them and produce a diff.
+ */
+#include "builtin.h"
+
+#include "util/debug.h"
+#include "util/event.h"
+#include "util/hist.h"
+#include "util/session.h"
+#include "util/sort.h"
+#include "util/symbol.h"
+#include "util/util.h"
+
+#include <stdlib.h>
+
+static char const *input_old = "perf.data.old",
+                 *input_new = "perf.data";
+static char      diff__default_sort_order[] = "dso,symbol";
+static int  force;
+static bool show_displacement;
+
+static int perf_session__add_hist_entry(struct perf_session *self,
+                                       struct addr_location *al, u64 count)
+{
+       bool hit;
+       struct hist_entry *he = __perf_session__add_hist_entry(self, al, NULL,
+                                                              count, &hit);
+       if (he == NULL)
+               return -ENOMEM;
+
+       if (hit)
+               he->count += count;
+
+       return 0;
+}
+
+static int diff__process_sample_event(event_t *event, struct perf_session *session)
+{
+       struct addr_location al;
+       struct sample_data data = { .period = 1, };
+
+       dump_printf("(IP, %d): %d: %p\n", event->header.misc,
+                   event->ip.pid, (void *)(long)event->ip.ip);
+
+       if (event__preprocess_sample(event, session, &al, NULL) < 0) {
+               pr_warning("problem processing %d event, skipping it.\n",
+                          event->header.type);
+               return -1;
+       }
+
+       if (al.filtered)
+               return 0;
+
+       event__parse_sample(event, session->sample_type, &data);
+
+       if (al.sym && perf_session__add_hist_entry(session, &al, data.period)) {
+               pr_warning("problem incrementing symbol count, skipping event\n");
+               return -1;
+       }
+
+       session->events_stats.total += data.period;
+       return 0;
+}
+
+static struct perf_event_ops event_ops = {
+       .process_sample_event = diff__process_sample_event,
+       .process_mmap_event   = event__process_mmap,
+       .process_comm_event   = event__process_comm,
+       .process_exit_event   = event__process_task,
+       .process_fork_event   = event__process_task,
+       .process_lost_event   = event__process_lost,
+};
+
+static void perf_session__insert_hist_entry_by_name(struct rb_root *root,
+                                                   struct hist_entry *he)
+{
+       struct rb_node **p = &root->rb_node;
+       struct rb_node *parent = NULL;
+       struct hist_entry *iter;
+
+       while (*p != NULL) {
+               int cmp;
+               parent = *p;
+               iter = rb_entry(parent, struct hist_entry, rb_node);
+
+               cmp = strcmp(he->map->dso->name, iter->map->dso->name);
+               if (cmp > 0)
+                       p = &(*p)->rb_left;
+               else if (cmp < 0)
+                       p = &(*p)->rb_right;
+               else {
+                       cmp = strcmp(he->sym->name, iter->sym->name);
+                       if (cmp > 0)
+                               p = &(*p)->rb_left;
+                       else
+                               p = &(*p)->rb_right;
+               }
+       }
+
+       rb_link_node(&he->rb_node, parent, p);
+       rb_insert_color(&he->rb_node, root);
+}
+
+static void perf_session__resort_by_name(struct perf_session *self)
+{
+       unsigned long position = 1;
+       struct rb_root tmp = RB_ROOT;
+       struct rb_node *next = rb_first(&self->hists);
+
+       while (next != NULL) {
+               struct hist_entry *n = rb_entry(next, struct hist_entry, rb_node);
+
+               next = rb_next(&n->rb_node);
+               rb_erase(&n->rb_node, &self->hists);
+               n->position = position++;
+               perf_session__insert_hist_entry_by_name(&tmp, n);
+       }
+
+       self->hists = tmp;
+}
+
+static struct hist_entry *
+perf_session__find_hist_entry_by_name(struct perf_session *self,
+                                     struct hist_entry *he)
+{
+       struct rb_node *n = self->hists.rb_node;
+
+       while (n) {
+               struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node);
+               int cmp = strcmp(he->map->dso->name, iter->map->dso->name);
+
+               if (cmp > 0)
+                       n = n->rb_left;
+               else if (cmp < 0)
+                       n = n->rb_right;
+               else {
+                       cmp = strcmp(he->sym->name, iter->sym->name);
+                       if (cmp > 0)
+                               n = n->rb_left;
+                       else if (cmp < 0)
+                               n = n->rb_right;
+                       else
+                               return iter;
+               }
+       }
+
+       return NULL;
+}
+
+static void perf_session__match_hists(struct perf_session *old_session,
+                                     struct perf_session *new_session)
+{
+       struct rb_node *nd;
+
+       perf_session__resort_by_name(old_session);
+
+       for (nd = rb_first(&new_session->hists); nd; nd = rb_next(nd)) {
+               struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node);
+               pos->pair = perf_session__find_hist_entry_by_name(old_session, pos);
+       }
+}
+
+static int __cmd_diff(void)
+{
+       int ret, i;
+       struct perf_session *session[2];
+
+       session[0] = perf_session__new(input_old, O_RDONLY, force);
+       session[1] = perf_session__new(input_new, O_RDONLY, force);
+       if (session[0] == NULL || session[1] == NULL)
+               return -ENOMEM;
+
+       for (i = 0; i < 2; ++i) {
+               ret = perf_session__process_events(session[i], &event_ops);
+               if (ret)
+                       goto out_delete;
+               perf_session__output_resort(session[i], session[i]->events_stats.total);
+       }
+
+       perf_session__match_hists(session[0], session[1]);
+       perf_session__fprintf_hists(session[1], session[0],
+                                   show_displacement, stdout);
+out_delete:
+       for (i = 0; i < 2; ++i)
+               perf_session__delete(session[i]);
+       return ret;
+}
+
+static const char *const diff_usage[] = {
+       "perf diff [<options>] [old_file] [new_file]",
+};
+
+static const struct option options[] = {
+       OPT_BOOLEAN('v', "verbose", &verbose,
+                   "be more verbose (show symbol address, etc)"),
+       OPT_BOOLEAN('m', "displacement", &show_displacement,
+                   "Show position displacement relative to baseline"),
+       OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
+                   "dump raw trace in ASCII"),
+       OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
+       OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
+                   "load module symbols - WARNING: use only with -k and LIVE kernel"),
+       OPT_BOOLEAN('P', "full-paths", &event_ops.full_paths,
+                   "Don't shorten the pathnames taking into account the cwd"),
+       OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
+                  "only consider symbols in these dsos"),
+       OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
+                  "only consider symbols in these comms"),
+       OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
+                  "only consider these symbols"),
+       OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
+                  "sort by key(s): pid, comm, dso, symbol, parent"),
+       OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
+                  "separator for columns, no spaces will be added between "
+                  "columns '.' is reserved."),
+       OPT_END()
+};
+
+int cmd_diff(int argc, const char **argv, const char *prefix __used)
+{
+       sort_order = diff__default_sort_order;
+       argc = parse_options(argc, argv, options, diff_usage, 0);
+       if (argc) {
+               if (argc > 2)
+                       usage_with_options(diff_usage, options);
+               if (argc == 2) {
+                       input_old = argv[0];
+                       input_new = argv[1];
+               } else
+                       input_new = argv[0];
+       }
+
+       symbol_conf.exclude_other = false;
+       if (symbol__init() < 0)
+               return -1;
+
+       setup_sorting(diff_usage, options);
+       setup_pager();
+
+       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", NULL);
+       sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", NULL);
+       sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", NULL);
+
+       return __cmd_diff();
+}
index 2071d248591334f8acfe97802ab12e33b3bbbe30..fc21ad79dd83e25a7520f00e6d3611587650ee79 100644 (file)
@@ -12,7 +12,6 @@
 #include "util/trace-event.h"
 
 #include "util/debug.h"
-#include "util/data_map.h"
 
 #include <linux/rbtree.h>
 
@@ -21,8 +20,6 @@ typedef int (*sort_fn_t)(struct alloc_stat *, struct alloc_stat *);
 
 static char const              *input_name = "perf.data";
 
-static u64                     sample_type;
-
 static int                     alloc_flag;
 static int                     caller_flag;
 
@@ -312,7 +309,7 @@ process_raw_event(event_t *raw_event __used, void *data,
        }
 }
 
-static int process_sample_event(event_t *event)
+static int process_sample_event(event_t *event, struct perf_session *session)
 {
        struct sample_data data;
        struct thread *thread;
@@ -322,7 +319,7 @@ static int process_sample_event(event_t *event)
        data.cpu = -1;
        data.period = 1;
 
-       event__parse_sample(event, sample_type, &data);
+       event__parse_sample(event, session->sample_type, &data);
 
        dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
                event->header.misc,
@@ -330,7 +327,7 @@ static int process_sample_event(event_t *event)
                (void *)(long)data.ip,
                (long long)data.period);
 
-       thread = threads__findnew(event->ip.pid);
+       thread = perf_session__findnew(session, event->ip.pid);
        if (thread == NULL) {
                pr_debug("problem processing %d event, skipping it.\n",
                         event->header.type);
@@ -345,11 +342,9 @@ static int process_sample_event(event_t *event)
        return 0;
 }
 
-static int sample_type_check(u64 type)
+static int sample_type_check(struct perf_session *session)
 {
-       sample_type = type;
-
-       if (!(sample_type & PERF_SAMPLE_RAW)) {
+       if (!(session->sample_type & PERF_SAMPLE_RAW)) {
                fprintf(stderr,
                        "No trace sample to read. Did you call perf record "
                        "without -R?");
@@ -359,28 +354,12 @@ static int sample_type_check(u64 type)
        return 0;
 }
 
-static struct perf_file_handler file_handler = {
+static struct perf_event_ops event_ops = {
        .process_sample_event   = process_sample_event,
        .process_comm_event     = event__process_comm,
        .sample_type_check      = sample_type_check,
 };
 
-static int read_events(void)
-{
-       int err;
-       struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
-
-       if (session == NULL)
-               return -ENOMEM;
-
-       register_idle_thread();
-       register_perf_file_handler(&file_handler);
-
-       err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
-       perf_session__delete(session);
-       return err;
-}
-
 static double fragmentation(unsigned long n_req, unsigned long n_alloc)
 {
        if (n_alloc == 0)
@@ -389,7 +368,8 @@ static double fragmentation(unsigned long n_req, unsigned long n_alloc)
                return 100.0 - (100.0 * n_req / n_alloc);
 }
 
-static void __print_result(struct rb_root *root, int n_lines, int is_caller)
+static void __print_result(struct rb_root *root, struct perf_session *session,
+                          int n_lines, int is_caller)
 {
        struct rb_node *next;
 
@@ -410,7 +390,7 @@ static void __print_result(struct rb_root *root, int n_lines, int is_caller)
                if (is_caller) {
                        addr = data->call_site;
                        if (!raw_ip)
-                               sym = map_groups__find_function(kmaps, addr, NULL);
+                               sym = map_groups__find_function(&session->kmaps, session, addr, NULL);
                } else
                        addr = data->ptr;
 
@@ -451,12 +431,12 @@ static void print_summary(void)
        printf("Cross CPU allocations: %lu/%lu\n", nr_cross_allocs, nr_allocs);
 }
 
-static void print_result(void)
+static void print_result(struct perf_session *session)
 {
        if (caller_flag)
-               __print_result(&root_caller_sorted, caller_lines, 1);
+               __print_result(&root_caller_sorted, session, caller_lines, 1);
        if (alloc_flag)
-               __print_result(&root_alloc_sorted, alloc_lines, 0);
+               __print_result(&root_alloc_sorted, session, alloc_lines, 0);
        print_summary();
 }
 
@@ -524,12 +504,20 @@ static void sort_result(void)
 
 static int __cmd_kmem(void)
 {
+       int err;
+       struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
+       if (session == NULL)
+               return -ENOMEM;
+
        setup_pager();
-       read_events();
+       err = perf_session__process_events(session, &event_ops);
+       if (err != 0)
+               goto out_delete;
        sort_result();
-       print_result();
-
-       return 0;
+       print_result(session);
+out_delete:
+       perf_session__delete(session);
+       return err;
 }
 
 static const char * const kmem_usage[] = {
@@ -778,13 +766,13 @@ static int __cmd_record(int argc, const char **argv)
 
 int cmd_kmem(int argc, const char **argv, const char *prefix __used)
 {
-       symbol__init(0);
-
        argc = parse_options(argc, argv, kmem_options, kmem_usage, 0);
 
        if (!argc)
                usage_with_options(kmem_usage, kmem_options);
 
+       symbol__init();
+
        if (!strncmp(argv[0], "rec", 3)) {
                return __cmd_record(argc, argv);
        } else if (!strcmp(argv[0], "stat")) {
index 5a47c1e11f77738b6f770f8e3b67f7a085a0362a..c1e6774fd3ed316171118cb6598ac8e2dbf7a36c 100644 (file)
 #include "util/strlist.h"
 #include "util/event.h"
 #include "util/debug.h"
+#include "util/debugfs.h"
+#include "util/symbol.h"
+#include "util/thread.h"
+#include "util/session.h"
 #include "util/parse-options.h"
 #include "util/parse-events.h" /* For debugfs_path */
 #include "util/probe-finder.h"
 #include "util/probe-event.h"
 
-/* Default vmlinux search paths */
-#define NR_SEARCH_PATH 4
-const char *default_search_path[NR_SEARCH_PATH] = {
-"/lib/modules/%s/build/vmlinux",               /* Custom build kernel */
-"/usr/lib/debug/lib/modules/%s/vmlinux",       /* Red Hat debuginfo */
-"/boot/vmlinux-debug-%s",                      /* Ubuntu */
-"./vmlinux",                                   /* CWD */
-};
-
 #define MAX_PATH_LEN 256
 #define MAX_PROBES 128
 
 /* Session management structure */
 static struct {
-       char *vmlinux;
-       char *release;
-       int need_dwarf;
+       bool need_dwarf;
+       bool list_events;
+       bool force_add;
        int nr_probe;
        struct probe_point probes[MAX_PROBES];
        struct strlist *dellist;
+       struct perf_session *psession;
+       struct map *kmap;
 } session;
 
-static bool listing;
 
 /* Parse an event definition. Note that any error must die. */
 static void parse_probe_event(const char *str)
@@ -77,7 +73,7 @@ static void parse_probe_event(const char *str)
                die("Too many probes (> %d) are specified.", MAX_PROBES);
 
        /* Parse perf-probe event into probe_point */
-       session.need_dwarf = parse_perf_probe_event(str, pp);
+       parse_perf_probe_event(str, pp, &session.need_dwarf);
 
        pr_debug("%d arguments\n", pp->nr_args);
 }
@@ -120,34 +116,26 @@ static int opt_del_probe_event(const struct option *opt __used,
        return 0;
 }
 
+/* Currently just checking function name from symbol map */
+static void evaluate_probe_point(struct probe_point *pp)
+{
+       struct symbol *sym;
+       sym = map__find_symbol_by_name(session.kmap, pp->function,
+                                      session.psession, NULL);
+       if (!sym)
+               die("Kernel symbol \'%s\' not found - probe not added.",
+                   pp->function);
+}
+
 #ifndef NO_LIBDWARF
-static int open_default_vmlinux(void)
+static int open_vmlinux(void)
 {
-       struct utsname uts;
-       char fname[MAX_PATH_LEN];
-       int fd, ret, i;
-
-       ret = uname(&uts);
-       if (ret) {
-               pr_debug("uname() failed.\n");
-               return -errno;
-       }
-       session.release = uts.release;
-       for (i = 0; i < NR_SEARCH_PATH; i++) {
-               ret = snprintf(fname, MAX_PATH_LEN,
-                              default_search_path[i], session.release);
-               if (ret >= MAX_PATH_LEN || ret < 0) {
-                       pr_debug("Filename(%d,%s) is too long.\n", i,
-                               uts.release);
-                       errno = E2BIG;
-                       return -E2BIG;
-               }
-               pr_debug("try to open %s\n", fname);
-               fd = open(fname, O_RDONLY);
-               if (fd >= 0)
-                       break;
+       if (map__load(session.kmap, session.psession, NULL) < 0) {
+               pr_debug("Failed to load kernel map.\n");
+               return -EINVAL;
        }
-       return fd;
+       pr_debug("Try to open %s\n", session.kmap->dso->long_name);
+       return open(session.kmap->dso->long_name, O_RDONLY);
 }
 #endif
 
@@ -163,21 +151,22 @@ static const struct option options[] = {
        OPT_BOOLEAN('v', "verbose", &verbose,
                    "be more verbose (show parsed arguments, etc)"),
 #ifndef NO_LIBDWARF
-       OPT_STRING('k', "vmlinux", &session.vmlinux, "file",
-               "vmlinux/module pathname"),
+       OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
+                  "file", "vmlinux pathname"),
 #endif
-       OPT_BOOLEAN('l', "list", &listing, "list up current probe events"),
+       OPT_BOOLEAN('l', "list", &session.list_events,
+                   "list up current probe events"),
        OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.",
                opt_del_probe_event),
        OPT_CALLBACK('a', "add", NULL,
 #ifdef NO_LIBDWARF
-               "FUNC[+OFFS|%return] [ARG ...]",
+               "[EVENT=]FUNC[+OFFS|%return] [ARG ...]",
 #else
-               "FUNC[+OFFS|%return|:RLN][@SRC]|SRC:ALN [ARG ...]",
+               "[EVENT=]FUNC[+OFFS|%return|:RLN][@SRC]|SRC:ALN [ARG ...]",
 #endif
                "probe point definition, where\n"
-               "\t\tGRP:\tGroup name (optional)\n"
-               "\t\tNAME:\tEvent name\n"
+               "\t\tGROUP:\tGroup name (optional)\n"
+               "\t\tEVENT:\tEvent name\n"
                "\t\tFUNC:\tFunction name\n"
                "\t\tOFFS:\tOffset from function entry (in byte)\n"
                "\t\t%return:\tPut the probe at function return\n"
@@ -191,6 +180,8 @@ static const struct option options[] = {
 #endif
                "\t\t\tkprobe-tracer argument format.)\n",
                opt_add_probe_event),
+       OPT_BOOLEAN('f', "force", &session.force_add, "forcibly add events"
+                   " with existing name"),
        OPT_END()
 };
 
@@ -204,13 +195,21 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
 
        argc = parse_options(argc, argv, options, probe_usage,
                             PARSE_OPT_STOP_AT_NON_OPTION);
-       if (argc > 0)
+       if (argc > 0) {
+               if (strcmp(argv[0], "-") == 0) {
+                       pr_warning("  Error: '-' is not supported.\n");
+                       usage_with_options(probe_usage, options);
+               }
                parse_probe_event_argv(argc, argv);
+       }
 
-       if ((session.nr_probe == 0 && !session.dellist && !listing))
+       if ((!session.nr_probe && !session.dellist && !session.list_events))
                usage_with_options(probe_usage, options);
 
-       if (listing) {
+       if (debugfs_valid_mountpoint(debugfs_path) < 0)
+               die("Failed to find debugfs path.");
+
+       if (session.list_events) {
                if (session.nr_probe != 0 || session.dellist) {
                        pr_warning("  Error: Don't use --list with"
                                   " --add/--del.\n");
@@ -227,17 +226,28 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
                        return 0;
        }
 
+       /* Initialize symbol maps for vmlinux */
+       symbol_conf.sort_by_name = true;
+       if (symbol_conf.vmlinux_name == NULL)
+               symbol_conf.try_vmlinux_path = true;
+       if (symbol__init() < 0)
+               die("Failed to init symbol map.");
+       session.psession = perf_session__new(NULL, O_WRONLY, false);
+       if (session.psession == NULL)
+               die("Failed to init perf_session.");
+       session.kmap = map_groups__find_by_name(&session.psession->kmaps,
+                                               MAP__FUNCTION,
+                                               "[kernel.kallsyms]");
+       if (!session.kmap)
+               die("Could not find kernel map.\n");
+
        if (session.need_dwarf)
 #ifdef NO_LIBDWARF
                die("Debuginfo-analysis is not supported");
 #else  /* !NO_LIBDWARF */
                pr_debug("Some probes require debuginfo.\n");
 
-       if (session.vmlinux) {
-               pr_debug("Try to open %s.", session.vmlinux);
-               fd = open(session.vmlinux, O_RDONLY);
-       } else
-               fd = open_default_vmlinux();
+       fd = open_vmlinux();
        if (fd < 0) {
                if (session.need_dwarf)
                        die("Could not open debuginfo file.");
@@ -255,15 +265,22 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
 
                lseek(fd, SEEK_SET, 0);
                ret = find_probepoint(fd, pp);
-               if (ret < 0) {
-                       if (session.need_dwarf)
-                               die("Could not analyze debuginfo.");
-
-                       pr_warning("An error occurred in debuginfo analysis. Try to use symbols.\n");
-                       break;
+               if (ret > 0)
+                       continue;
+               if (ret == 0) { /* No error but failed to find probe point. */
+                       synthesize_perf_probe_point(pp);
+                       die("Probe point '%s' not found. - probe not added.",
+                           pp->probes[0]);
                }
-               if (ret == 0)   /* No error but failed to find probe point. */
-                       die("No probe point found.");
+               /* Error path */
+               if (session.need_dwarf) {
+                       if (ret == -ENOENT)
+                               pr_warning("No dwarf info found in the vmlinux - please rebuild with CONFIG_DEBUG_INFO=y.\n");
+                       die("Could not analyze debuginfo.");
+               }
+               pr_debug("An error occurred in debuginfo analysis."
+                        " Try to use symbols.\n");
+               break;
        }
        close(fd);
 
@@ -276,6 +293,7 @@ end_dwarf:
                if (pp->found)  /* This probe is already found. */
                        continue;
 
+               evaluate_probe_point(pp);
                ret = synthesize_trace_kprobe_event(pp);
                if (ret == -E2BIG)
                        die("probe point definition becomes too long.");
@@ -284,7 +302,8 @@ end_dwarf:
        }
 
        /* Settng up probe points */
-       add_trace_kprobe_events(session.probes, session.nr_probe);
+       add_trace_kprobe_events(session.probes, session.nr_probe,
+                               session.force_add);
        return 0;
 }
 
index 4decbd14eaed080ac046b8a10c793b721280c1df..63136d0534d450ef18a6bf65ee1d78275f41333b 100644 (file)
@@ -123,7 +123,8 @@ static void write_event(event_t *buf, size_t size)
        write_output(buf, size);
 }
 
-static int process_synthesized_event(event_t *event)
+static int process_synthesized_event(event_t *event,
+                                    struct perf_session *self __used)
 {
        write_event(event, event->header.size);
        return 0;
@@ -277,7 +278,7 @@ static void create_counter(int counter, int cpu, pid_t pid)
 
        attr->mmap              = track;
        attr->comm              = track;
-       attr->inherit           = (cpu < 0) && inherit;
+       attr->inherit           = inherit;
        attr->disabled          = 1;
 
 try_again:
@@ -401,7 +402,7 @@ static void atexit_header(void)
        perf_header__write(&session->header, output, true);
 }
 
-static int __cmd_record(int argc, const char **argv)
+static int __cmd_record(int argc __used, const char **argv)
 {
        int i, counter;
        struct stat st;
@@ -409,6 +410,8 @@ static int __cmd_record(int argc, const char **argv)
        int flags;
        int err;
        unsigned long waking = 0;
+       int child_ready_pipe[2], go_pipe[2];
+       char buf;
 
        page_size = sysconf(_SC_PAGE_SIZE);
        nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
@@ -419,11 +422,25 @@ static int __cmd_record(int argc, const char **argv)
        signal(SIGCHLD, sig_handler);
        signal(SIGINT, sig_handler);
 
+       if (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0) {
+               perror("failed to create pipes");
+               exit(-1);
+       }
+
        if (!stat(output_name, &st) && st.st_size) {
-               if (!force && !append_file) {
-                       fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
-                                       output_name);
-                       exit(-1);
+               if (!force) {
+                       if (!append_file) {
+                               pr_err("Error, output file %s exists, use -A "
+                                      "to append or -f to overwrite.\n",
+                                      output_name);
+                               exit(-1);
+                       }
+               } else {
+                       char oldname[PATH_MAX];
+                       snprintf(oldname, sizeof(oldname), "%s.old",
+                                output_name);
+                       unlink(oldname);
+                       rename(output_name, oldname);
                }
        } else {
                append_file = 0;
@@ -466,19 +483,65 @@ static int __cmd_record(int argc, const char **argv)
 
        atexit(atexit_header);
 
-       if (!system_wide) {
-               pid = target_pid;
-               if (pid == -1)
-                       pid = getpid();
+       if (target_pid == -1) {
+               pid = fork();
+               if (pid < 0) {
+                       perror("failed to fork");
+                       exit(-1);
+               }
 
-               open_counters(profile_cpu, pid);
-       } else {
-               if (profile_cpu != -1) {
-                       open_counters(profile_cpu, target_pid);
-               } else {
-                       for (i = 0; i < nr_cpus; i++)
-                               open_counters(i, target_pid);
+               if (!pid) {
+                       close(child_ready_pipe[0]);
+                       close(go_pipe[1]);
+                       fcntl(go_pipe[0], F_SETFD, FD_CLOEXEC);
+
+                       /*
+                        * Do a dummy execvp to get the PLT entry resolved,
+                        * so we avoid the resolver overhead on the real
+                        * execvp call.
+                        */
+                       execvp("", (char **)argv);
+
+                       /*
+                        * Tell the parent we're ready to go
+                        */
+                       close(child_ready_pipe[1]);
+
+                       /*
+                        * Wait until the parent tells us to go.
+                        */
+                       if (read(go_pipe[0], &buf, 1) == -1)
+                               perror("unable to read pipe");
+
+                       execvp(argv[0], (char **)argv);
+
+                       perror(argv[0]);
+                       exit(-1);
                }
+
+               child_pid = pid;
+
+               if (!system_wide)
+                       target_pid = pid;
+
+               close(child_ready_pipe[1]);
+               close(go_pipe[0]);
+               /*
+                * wait for child to settle
+                */
+               if (read(child_ready_pipe[0], &buf, 1) == -1) {
+                       perror("unable to read pipe");
+                       exit(-1);
+               }
+               close(child_ready_pipe[0]);
+       }
+
+
+       if ((!system_wide && !inherit) || profile_cpu != -1) {
+               open_counters(profile_cpu, target_pid);
+       } else {
+               for (i = 0; i < nr_cpus; i++)
+                       open_counters(i, target_pid);
        }
 
        if (file_new) {
@@ -488,33 +551,10 @@ static int __cmd_record(int argc, const char **argv)
        }
 
        if (!system_wide)
-               event__synthesize_thread(pid, process_synthesized_event);
+               event__synthesize_thread(pid, process_synthesized_event,
+                                        session);
        else
-               event__synthesize_threads(process_synthesized_event);
-
-       if (target_pid == -1 && argc) {
-               pid = fork();
-               if (pid < 0)
-                       die("failed to fork");
-
-               if (!pid) {
-                       if (execvp(argv[0], (char **)argv)) {
-                               perror(argv[0]);
-                               exit(-1);
-                       }
-               } else {
-                       /*
-                        * Wait a bit for the execv'ed child to appear
-                        * and be updated in /proc
-                        * FIXME: Do you know a less heuristical solution?
-                        */
-                       usleep(1000);
-                       event__synthesize_thread(pid,
-                                                process_synthesized_event);
-               }
-
-               child_pid = pid;
-       }
+               event__synthesize_threads(process_synthesized_event, session);
 
        if (realtime_prio) {
                struct sched_param param;
@@ -526,6 +566,11 @@ static int __cmd_record(int argc, const char **argv)
                }
        }
 
+       /*
+        * Let the child rip
+        */
+       close(go_pipe[1]);
+
        for (;;) {
                int hits = samples;
 
@@ -620,13 +665,13 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
 {
        int counter;
 
-       symbol__init(0);
-
        argc = parse_options(argc, argv, options, record_usage,
-               PARSE_OPT_STOP_AT_NON_OPTION);
-       if (!argc && target_pid == -1 && !system_wide)
+                           PARSE_OPT_STOP_AT_NON_OPTION);
+       if (!argc && target_pid == -1 && (!system_wide || profile_cpu == -1))
                usage_with_options(record_usage, options);
 
+       symbol__init();
+
        if (!nr_counters) {
                nr_counters     = 1;
                attrs[0].type   = PERF_TYPE_HARDWARE;
index e2ec49a9b731eab6bb2de7419680107433b7b697..5c2ab5357ec689b4047689fa6281a1d1a99f78fb 100644 (file)
 #include "util/parse-options.h"
 #include "util/parse-events.h"
 
-#include "util/data_map.h"
 #include "util/thread.h"
 #include "util/sort.h"
 #include "util/hist.h"
 
 static char            const *input_name = "perf.data";
 
-static char            *dso_list_str, *comm_list_str, *sym_list_str,
-                       *col_width_list_str;
-static struct strlist  *dso_list, *comm_list, *sym_list;
-
 static int             force;
 
-static int             full_paths;
-static int             show_nr_samples;
-
 static int             show_threads;
 static struct perf_read_values show_threads_values;
 
 static char            default_pretty_printing_style[] = "normal";
 static char            *pretty_printing_style = default_pretty_printing_style;
 
-static int             exclude_other = 1;
-
 static char            callchain_default_opt[] = "fractal,0.5";
 
-static struct perf_session *session;
-
-static u64             sample_type;
-
-struct symbol_conf     symbol_conf;
-
-
-static size_t
-callchain__fprintf_left_margin(FILE *fp, int left_margin)
-{
-       int i;
-       int ret;
-
-       ret = fprintf(fp, "            ");
-
-       for (i = 0; i < left_margin; i++)
-               ret += fprintf(fp, " ");
-
-       return ret;
-}
-
-static size_t ipchain__fprintf_graph_line(FILE *fp, int depth, int depth_mask,
-                                         int left_margin)
-{
-       int i;
-       size_t ret = 0;
-
-       ret += callchain__fprintf_left_margin(fp, left_margin);
-
-       for (i = 0; i < depth; i++)
-               if (depth_mask & (1 << i))
-                       ret += fprintf(fp, "|          ");
-               else
-                       ret += fprintf(fp, "           ");
-
-       ret += fprintf(fp, "\n");
-
-       return ret;
-}
-static size_t
-ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain, int depth,
-                      int depth_mask, int count, u64 total_samples,
-                      int hits, int left_margin)
-{
-       int i;
-       size_t ret = 0;
-
-       ret += callchain__fprintf_left_margin(fp, left_margin);
-       for (i = 0; i < depth; i++) {
-               if (depth_mask & (1 << i))
-                       ret += fprintf(fp, "|");
-               else
-                       ret += fprintf(fp, " ");
-               if (!count && i == depth - 1) {
-                       double percent;
-
-                       percent = hits * 100.0 / total_samples;
-                       ret += percent_color_fprintf(fp, "--%2.2f%%-- ", percent);
-               } else
-                       ret += fprintf(fp, "%s", "          ");
-       }
-       if (chain->sym)
-               ret += fprintf(fp, "%s\n", chain->sym->name);
-       else
-               ret += fprintf(fp, "%p\n", (void *)(long)chain->ip);
-
-       return ret;
-}
-
-static struct symbol *rem_sq_bracket;
-static struct callchain_list rem_hits;
-
-static void init_rem_hits(void)
-{
-       rem_sq_bracket = malloc(sizeof(*rem_sq_bracket) + 6);
-       if (!rem_sq_bracket) {
-               fprintf(stderr, "Not enough memory to display remaining hits\n");
-               return;
-       }
-
-       strcpy(rem_sq_bracket->name, "[...]");
-       rem_hits.sym = rem_sq_bracket;
-}
-
-static size_t
-__callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
-                          u64 total_samples, int depth, int depth_mask,
-                          int left_margin)
-{
-       struct rb_node *node, *next;
-       struct callchain_node *child;
-       struct callchain_list *chain;
-       int new_depth_mask = depth_mask;
-       u64 new_total;
-       u64 remaining;
-       size_t ret = 0;
-       int i;
-
-       if (callchain_param.mode == CHAIN_GRAPH_REL)
-               new_total = self->children_hit;
-       else
-               new_total = total_samples;
-
-       remaining = new_total;
-
-       node = rb_first(&self->rb_root);
-       while (node) {
-               u64 cumul;
-
-               child = rb_entry(node, struct callchain_node, rb_node);
-               cumul = cumul_hits(child);
-               remaining -= cumul;
-
-               /*
-                * The depth mask manages the output of pipes that show
-                * the depth. We don't want to keep the pipes of the current
-                * level for the last child of this depth.
-                * Except if we have remaining filtered hits. They will
-                * supersede the last child
-                */
-               next = rb_next(node);
-               if (!next && (callchain_param.mode != CHAIN_GRAPH_REL || !remaining))
-                       new_depth_mask &= ~(1 << (depth - 1));
-
-               /*
-                * But we keep the older depth mask for the line seperator
-                * to keep the level link until we reach the last child
-                */
-               ret += ipchain__fprintf_graph_line(fp, depth, depth_mask,
-                                                  left_margin);
-               i = 0;
-               list_for_each_entry(chain, &child->val, list) {
-                       if (chain->ip >= PERF_CONTEXT_MAX)
-                               continue;
-                       ret += ipchain__fprintf_graph(fp, chain, depth,
-                                                     new_depth_mask, i++,
-                                                     new_total,
-                                                     cumul,
-                                                     left_margin);
-               }
-               ret += __callchain__fprintf_graph(fp, child, new_total,
-                                                 depth + 1,
-                                                 new_depth_mask | (1 << depth),
-                                                 left_margin);
-               node = next;
-       }
-
-       if (callchain_param.mode == CHAIN_GRAPH_REL &&
-               remaining && remaining != new_total) {
-
-               if (!rem_sq_bracket)
-                       return ret;
-
-               new_depth_mask &= ~(1 << (depth - 1));
-
-               ret += ipchain__fprintf_graph(fp, &rem_hits, depth,
-                                             new_depth_mask, 0, new_total,
-                                             remaining, left_margin);
-       }
-
-       return ret;
-}
-
-
-static size_t
-callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
-                        u64 total_samples, int left_margin)
-{
-       struct callchain_list *chain;
-       bool printed = false;
-       int i = 0;
-       int ret = 0;
-
-       list_for_each_entry(chain, &self->val, list) {
-               if (chain->ip >= PERF_CONTEXT_MAX)
-                       continue;
-
-               if (!i++ && sort__first_dimension == SORT_SYM)
-                       continue;
-
-               if (!printed) {
-                       ret += callchain__fprintf_left_margin(fp, left_margin);
-                       ret += fprintf(fp, "|\n");
-                       ret += callchain__fprintf_left_margin(fp, left_margin);
-                       ret += fprintf(fp, "---");
-
-                       left_margin += 3;
-                       printed = true;
-               } else
-                       ret += callchain__fprintf_left_margin(fp, left_margin);
-
-               if (chain->sym)
-                       ret += fprintf(fp, " %s\n", chain->sym->name);
-               else
-                       ret += fprintf(fp, " %p\n", (void *)(long)chain->ip);
-       }
-
-       ret += __callchain__fprintf_graph(fp, self, total_samples, 1, 1, left_margin);
-
-       return ret;
-}
-
-static size_t
-callchain__fprintf_flat(FILE *fp, struct callchain_node *self,
-                       u64 total_samples)
-{
-       struct callchain_list *chain;
-       size_t ret = 0;
-
-       if (!self)
-               return 0;
-
-       ret += callchain__fprintf_flat(fp, self->parent, total_samples);
-
-
-       list_for_each_entry(chain, &self->val, list) {
-               if (chain->ip >= PERF_CONTEXT_MAX)
-                       continue;
-               if (chain->sym)
-                       ret += fprintf(fp, "                %s\n", chain->sym->name);
-               else
-                       ret += fprintf(fp, "                %p\n",
-                                       (void *)(long)chain->ip);
-       }
-
-       return ret;
-}
-
-static size_t
-hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self,
-                             u64 total_samples, int left_margin)
-{
-       struct rb_node *rb_node;
-       struct callchain_node *chain;
-       size_t ret = 0;
-
-       rb_node = rb_first(&self->sorted_chain);
-       while (rb_node) {
-               double percent;
-
-               chain = rb_entry(rb_node, struct callchain_node, rb_node);
-               percent = chain->hit * 100.0 / total_samples;
-               switch (callchain_param.mode) {
-               case CHAIN_FLAT:
-                       ret += percent_color_fprintf(fp, "           %6.2f%%\n",
-                                                    percent);
-                       ret += callchain__fprintf_flat(fp, chain, total_samples);
-                       break;
-               case CHAIN_GRAPH_ABS: /* Falldown */
-               case CHAIN_GRAPH_REL:
-                       ret += callchain__fprintf_graph(fp, chain, total_samples,
-                                                       left_margin);
-               case CHAIN_NONE:
-               default:
-                       break;
-               }
-               ret += fprintf(fp, "\n");
-               rb_node = rb_next(rb_node);
-       }
-
-       return ret;
-}
-
-static size_t
-hist_entry__fprintf(FILE *fp, struct hist_entry *self, u64 total_samples)
-{
-       struct sort_entry *se;
-       size_t ret;
-
-       if (exclude_other && !self->parent)
-               return 0;
-
-       if (total_samples)
-               ret = percent_color_fprintf(fp,
-                                           field_sep ? "%.2f" : "   %6.2f%%",
-                                       (self->count * 100.0) / total_samples);
-       else
-               ret = fprintf(fp, field_sep ? "%lld" : "%12lld ", self->count);
-
-       if (show_nr_samples) {
-               if (field_sep)
-                       fprintf(fp, "%c%lld", *field_sep, self->count);
-               else
-                       fprintf(fp, "%11lld", self->count);
-       }
-
-       list_for_each_entry(se, &hist_entry__sort_list, list) {
-               if (se->elide)
-                       continue;
-
-               fprintf(fp, "%s", field_sep ?: "  ");
-               ret += se->print(fp, self, se->width ? *se->width : 0);
-       }
-
-       ret += fprintf(fp, "\n");
-
-       if (callchain) {
-               int left_margin = 0;
-
-               if (sort__first_dimension == SORT_COMM) {
-                       se = list_first_entry(&hist_entry__sort_list, typeof(*se),
-                                               list);
-                       left_margin = se->width ? *se->width : 0;
-                       left_margin -= thread__comm_len(self->thread);
-               }
-
-               hist_entry_callchain__fprintf(fp, self, total_samples,
-                                             left_margin);
-       }
-
-       return ret;
-}
-
-/*
- *
- */
-
-static void dso__calc_col_width(struct dso *self)
-{
-       if (!col_width_list_str && !field_sep &&
-           (!dso_list || strlist__has_entry(dso_list, self->name))) {
-               unsigned int slen = strlen(self->name);
-               if (slen > dsos__col_width)
-                       dsos__col_width = slen;
-       }
-
-       self->slen_calculated = 1;
-}
-
-static void thread__comm_adjust(struct thread *self)
-{
-       char *comm = self->comm;
-
-       if (!col_width_list_str && !field_sep &&
-           (!comm_list || strlist__has_entry(comm_list, comm))) {
-               unsigned int slen = strlen(comm);
-
-               if (slen > comms__col_width) {
-                       comms__col_width = slen;
-                       threads__col_width = slen + 6;
-               }
-       }
-}
-
-static int thread__set_comm_adjust(struct thread *self, const char *comm)
-{
-       int ret = thread__set_comm(self, comm);
-
-       if (ret)
-               return ret;
-
-       thread__comm_adjust(self);
-
-       return 0;
-}
-
-static int call__match(struct symbol *sym)
-{
-       if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0))
-               return 1;
-
-       return 0;
-}
-
-static struct symbol **resolve_callchain(struct thread *thread,
-                                        struct ip_callchain *chain,
-                                        struct symbol **parent)
-{
-       u8 cpumode = PERF_RECORD_MISC_USER;
-       struct symbol **syms = NULL;
-       unsigned int i;
-
-       if (callchain) {
-               syms = calloc(chain->nr, sizeof(*syms));
-               if (!syms) {
-                       fprintf(stderr, "Can't allocate memory for symbols\n");
-                       exit(-1);
-               }
-       }
-
-       for (i = 0; i < chain->nr; i++) {
-               u64 ip = chain->ips[i];
-               struct addr_location al;
-
-               if (ip >= PERF_CONTEXT_MAX) {
-                       switch (ip) {
-                       case PERF_CONTEXT_HV:
-                               cpumode = PERF_RECORD_MISC_HYPERVISOR;  break;
-                       case PERF_CONTEXT_KERNEL:
-                               cpumode = PERF_RECORD_MISC_KERNEL;      break;
-                       case PERF_CONTEXT_USER:
-                               cpumode = PERF_RECORD_MISC_USER;        break;
-                       default:
-                               break;
-                       }
-                       continue;
-               }
-
-               thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
-                                          ip, &al, NULL);
-               if (al.sym != NULL) {
-                       if (sort__has_parent && !*parent &&
-                           call__match(al.sym))
-                               *parent = al.sym;
-                       if (!callchain)
-                               break;
-                       syms[i] = al.sym;
-               }
-       }
-
-       return syms;
-}
-
-/*
- * collect histogram counts
- */
-
-static int hist_entry__add(struct addr_location *al,
-                          struct ip_callchain *chain, u64 count)
+static int perf_session__add_hist_entry(struct perf_session *self,
+                                       struct addr_location *al,
+                                       struct ip_callchain *chain, u64 count)
 {
        struct symbol **syms = NULL, *parent = NULL;
        bool hit;
        struct hist_entry *he;
 
-       if ((sort__has_parent || callchain) && chain)
-               syms = resolve_callchain(al->thread, chain, &parent);
-
-       he = __hist_entry__add(al, parent, count, &hit);
+       if ((sort__has_parent || symbol_conf.use_callchain) && chain)
+               syms = perf_session__resolve_callchain(self, al->thread,
+                                                      chain, &parent);
+       he = __perf_session__add_hist_entry(self, al, parent, count, &hit);
        if (he == NULL)
                return -ENOMEM;
 
        if (hit)
                he->count += count;
 
-       if (callchain) {
+       if (symbol_conf.use_callchain) {
                if (!hit)
                        callchain_init(&he->callchain);
                append_chain(&he->callchain, chain, syms);
@@ -497,100 +71,6 @@ static int hist_entry__add(struct addr_location *al,
        return 0;
 }
 
-static size_t output__fprintf(FILE *fp, u64 total_samples)
-{
-       struct hist_entry *pos;
-       struct sort_entry *se;
-       struct rb_node *nd;
-       size_t ret = 0;
-       unsigned int width;
-       char *col_width = col_width_list_str;
-       int raw_printing_style;
-
-       raw_printing_style = !strcmp(pretty_printing_style, "raw");
-
-       init_rem_hits();
-
-       fprintf(fp, "# Samples: %Ld\n", (u64)total_samples);
-       fprintf(fp, "#\n");
-
-       fprintf(fp, "# Overhead");
-       if (show_nr_samples) {
-               if (field_sep)
-                       fprintf(fp, "%cSamples", *field_sep);
-               else
-                       fputs("  Samples  ", fp);
-       }
-       list_for_each_entry(se, &hist_entry__sort_list, list) {
-               if (se->elide)
-                       continue;
-               if (field_sep) {
-                       fprintf(fp, "%c%s", *field_sep, se->header);
-                       continue;
-               }
-               width = strlen(se->header);
-               if (se->width) {
-                       if (col_width_list_str) {
-                               if (col_width) {
-                                       *se->width = atoi(col_width);
-                                       col_width = strchr(col_width, ',');
-                                       if (col_width)
-                                               ++col_width;
-                               }
-                       }
-                       width = *se->width = max(*se->width, width);
-               }
-               fprintf(fp, "  %*s", width, se->header);
-       }
-       fprintf(fp, "\n");
-
-       if (field_sep)
-               goto print_entries;
-
-       fprintf(fp, "# ........");
-       if (show_nr_samples)
-               fprintf(fp, " ..........");
-       list_for_each_entry(se, &hist_entry__sort_list, list) {
-               unsigned int i;
-
-               if (se->elide)
-                       continue;
-
-               fprintf(fp, "  ");
-               if (se->width)
-                       width = *se->width;
-               else
-                       width = strlen(se->header);
-               for (i = 0; i < width; i++)
-                       fprintf(fp, ".");
-       }
-       fprintf(fp, "\n");
-
-       fprintf(fp, "#\n");
-
-print_entries:
-       for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) {
-               pos = rb_entry(nd, struct hist_entry, rb_node);
-               ret += hist_entry__fprintf(fp, pos, total_samples);
-       }
-
-       if (sort_order == default_sort_order &&
-                       parent_pattern == default_parent_pattern) {
-               fprintf(fp, "#\n");
-               fprintf(fp, "# (For a higher level overview, try: perf report --sort comm,dso)\n");
-               fprintf(fp, "#\n");
-       }
-       fprintf(fp, "\n");
-
-       free(rem_sq_bracket);
-
-       if (show_threads)
-               perf_read_values_display(fp, &show_threads_values,
-                                        raw_printing_style);
-
-       return ret;
-}
-
 static int validate_chain(struct ip_callchain *chain, event_t *event)
 {
        unsigned int chain_size;
@@ -604,17 +84,12 @@ static int validate_chain(struct ip_callchain *chain, event_t *event)
        return 0;
 }
 
-static int process_sample_event(event_t *event)
+static int process_sample_event(event_t *event, struct perf_session *session)
 {
-       struct sample_data data;
-       int cpumode;
+       struct sample_data data = { .period = 1, };
        struct addr_location al;
-       struct thread *thread;
-
-       memset(&data, 0, sizeof(data));
-       data.period = 1;
 
-       event__parse_sample(event, sample_type, &data);
+       event__parse_sample(event, session->sample_type, &data);
 
        dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
                event->header.misc,
@@ -622,7 +97,7 @@ static int process_sample_event(event_t *event)
                (void *)(long)data.ip,
                (long long)data.period);
 
-       if (sample_type & PERF_SAMPLE_CALLCHAIN) {
+       if (session->sample_type & PERF_SAMPLE_CALLCHAIN) {
                unsigned int i;
 
                dump_printf("... chain: nr:%Lu\n", data.callchain->nr);
@@ -640,65 +115,25 @@ static int process_sample_event(event_t *event)
                }
        }
 
-       thread = threads__findnew(data.pid);
-       if (thread == NULL) {
-               pr_debug("problem processing %d event, skipping it.\n",
+       if (event__preprocess_sample(event, session, &al, NULL) < 0) {
+               fprintf(stderr, "problem processing %d event, skipping it.\n",
                        event->header.type);
                return -1;
        }
 
-       dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
-
-       if (comm_list && !strlist__has_entry(comm_list, thread->comm))
-               return 0;
-
-       cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
-
-       thread__find_addr_location(thread, cpumode,
-                                  MAP__FUNCTION, data.ip, &al, NULL);
-       /*
-        * We have to do this here as we may have a dso with no symbol hit that
-        * has a name longer than the ones with symbols sampled.
-        */
-       if (al.map && !sort_dso.elide && !al.map->dso->slen_calculated)
-               dso__calc_col_width(al.map->dso);
-
-       if (dso_list &&
-           (!al.map || !al.map->dso ||
-            !(strlist__has_entry(dso_list, al.map->dso->short_name) ||
-              (al.map->dso->short_name != al.map->dso->long_name &&
-               strlist__has_entry(dso_list, al.map->dso->long_name)))))
-               return 0;
-
-       if (sym_list && al.sym && !strlist__has_entry(sym_list, al.sym->name))
+       if (al.filtered)
                return 0;
 
-       if (hist_entry__add(&al, data.callchain, data.period)) {
+       if (perf_session__add_hist_entry(session, &al, data.callchain, data.period)) {
                pr_debug("problem incrementing symbol count, skipping event\n");
                return -1;
        }
 
-       event__stats.total += data.period;
-
+       session->events_stats.total += data.period;
        return 0;
 }
 
-static int process_comm_event(event_t *event)
-{
-       struct thread *thread = threads__findnew(event->comm.pid);
-
-       dump_printf(": %s:%d\n", event->comm.comm, event->comm.pid);
-
-       if (thread == NULL ||
-           thread__set_comm_adjust(thread, event->comm.comm)) {
-               dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
-               return -1;
-       }
-
-       return 0;
-}
-
-static int process_read_event(event_t *event)
+static int process_read_event(event_t *event, struct perf_session *session __used)
 {
        struct perf_event_attr *attr;
 
@@ -721,25 +156,23 @@ static int process_read_event(event_t *event)
        return 0;
 }
 
-static int sample_type_check(u64 type)
+static int sample_type_check(struct perf_session *session)
 {
-       sample_type = type;
-
-       if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) {
+       if (!(session->sample_type & PERF_SAMPLE_CALLCHAIN)) {
                if (sort__has_parent) {
                        fprintf(stderr, "selected --sort parent, but no"
                                        " callchain data. Did you call"
                                        " perf record without -g?\n");
                        return -1;
                }
-               if (callchain) {
+               if (symbol_conf.use_callchain) {
                        fprintf(stderr, "selected -g but no callchain data."
                                        " Did you call perf record without"
                                        " -g?\n");
                        return -1;
                }
-       } else if (callchain_param.mode != CHAIN_NONE && !callchain) {
-                       callchain = 1;
+       } else if (callchain_param.mode != CHAIN_NONE && !symbol_conf.use_callchain) {
+                       symbol_conf.use_callchain = true;
                        if (register_callchain_param(&callchain_param) < 0) {
                                fprintf(stderr, "Can't register callchain"
                                                " params\n");
@@ -750,10 +183,10 @@ static int sample_type_check(u64 type)
        return 0;
 }
 
-static struct perf_file_handler file_handler = {
+static struct perf_event_ops event_ops = {
        .process_sample_event   = process_sample_event,
        .process_mmap_event     = event__process_mmap,
-       .process_comm_event     = process_comm_event,
+       .process_comm_event     = event__process_comm,
        .process_exit_event     = event__process_task,
        .process_fork_event     = event__process_task,
        .process_lost_event     = event__process_lost,
@@ -764,23 +197,17 @@ static struct perf_file_handler file_handler = {
 
 static int __cmd_report(void)
 {
-       struct thread *idle;
        int ret;
+       struct perf_session *session;
 
        session = perf_session__new(input_name, O_RDONLY, force);
        if (session == NULL)
                return -ENOMEM;
 
-       idle = register_idle_thread();
-       thread__comm_adjust(idle);
-
        if (show_threads)
                perf_read_values_init(&show_threads_values);
 
-       register_perf_file_handler(&file_handler);
-
-       ret = perf_session__process_events(session, full_paths,
-                                          &event__cwdlen, &event__cwd);
+       ret = perf_session__process_events(session, &event_ops);
        if (ret)
                goto out_delete;
 
@@ -790,17 +217,25 @@ static int __cmd_report(void)
        }
 
        if (verbose > 3)
-               threads__fprintf(stdout);
+               perf_session__fprintf(session, stdout);
 
        if (verbose > 2)
                dsos__fprintf(stdout);
 
-       collapse__resort();
-       output__resort(event__stats.total);
-       output__fprintf(stdout, event__stats.total);
+       perf_session__collapse_resort(session);
+       perf_session__output_resort(session, session->events_stats.total);
+       fprintf(stdout, "# Samples: %Ld\n#\n", session->events_stats.total);
+       perf_session__fprintf_hists(session, NULL, false, stdout);
+       if (sort_order == default_sort_order &&
+           parent_pattern == default_parent_pattern)
+               fprintf(stdout, "#\n# (For a higher level overview, try: perf report --sort comm,dso)\n#\n");
 
-       if (show_threads)
+       if (show_threads) {
+               bool raw_printing_style = !strcmp(pretty_printing_style, "raw");
+               perf_read_values_display(stdout, &show_threads_values,
+                                        raw_printing_style);
                perf_read_values_destroy(&show_threads_values);
+       }
 out_delete:
        perf_session__delete(session);
        return ret;
@@ -813,7 +248,7 @@ parse_callchain_opt(const struct option *opt __used, const char *arg,
        char *tok;
        char *endptr;
 
-       callchain = 1;
+       symbol_conf.use_callchain = true;
 
        if (!arg)
                return 0;
@@ -834,7 +269,7 @@ parse_callchain_opt(const struct option *opt __used, const char *arg,
 
        else if (!strncmp(tok, "none", strlen(arg))) {
                callchain_param.mode = CHAIN_NONE;
-               callchain = 0;
+               symbol_conf.use_callchain = true;
 
                return 0;
        }
@@ -877,7 +312,7 @@ static const struct option options[] = {
        OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
        OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
                    "load module symbols - WARNING: use only with -k and LIVE kernel"),
-       OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples,
+       OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
                    "Show a column with the number of samples"),
        OPT_BOOLEAN('T', "threads", &show_threads,
                    "Show per-thread event counters"),
@@ -885,78 +320,46 @@ static const struct option options[] = {
                   "pretty printing style key: normal raw"),
        OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
                   "sort by key(s): pid, comm, dso, symbol, parent"),
-       OPT_BOOLEAN('P', "full-paths", &full_paths,
+       OPT_BOOLEAN('P', "full-paths", &event_ops.full_paths,
                    "Don't shorten the pathnames taking into account the cwd"),
        OPT_STRING('p', "parent", &parent_pattern, "regex",
                   "regex filter to identify parent, see: '--sort parent'"),
-       OPT_BOOLEAN('x', "exclude-other", &exclude_other,
+       OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other,
                    "Only display entries with parent-match"),
        OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent",
                     "Display callchains using output_type and min percent threshold. "
                     "Default: fractal,0.5", &parse_callchain_opt, callchain_default_opt),
-       OPT_STRING('d', "dsos", &dso_list_str, "dso[,dso...]",
+       OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
                   "only consider symbols in these dsos"),
-       OPT_STRING('C', "comms", &comm_list_str, "comm[,comm...]",
+       OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
                   "only consider symbols in these comms"),
-       OPT_STRING('S', "symbols", &sym_list_str, "symbol[,symbol...]",
+       OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
                   "only consider these symbols"),
-       OPT_STRING('w', "column-widths", &col_width_list_str,
+       OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str,
                   "width[,width...]",
                   "don't try to adjust column width, use these fixed values"),
-       OPT_STRING('t', "field-separator", &field_sep, "separator",
+       OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
                   "separator for columns, no spaces will be added between "
                   "columns '.' is reserved."),
        OPT_END()
 };
 
-static void setup_sorting(void)
+int cmd_report(int argc, const char **argv, const char *prefix __used)
 {
-       char *tmp, *tok, *str = strdup(sort_order);
-
-       for (tok = strtok_r(str, ", ", &tmp);
-                       tok; tok = strtok_r(NULL, ", ", &tmp)) {
-               if (sort_dimension__add(tok) < 0) {
-                       error("Unknown --sort key: `%s'", tok);
-                       usage_with_options(report_usage, options);
-               }
-       }
-
-       free(str);
-}
+       argc = parse_options(argc, argv, options, report_usage, 0);
 
-static void setup_list(struct strlist **list, const char *list_str,
-                      struct sort_entry *se, const char *list_name,
-                      FILE *fp)
-{
-       if (list_str) {
-               *list = strlist__new(true, list_str);
-               if (!*list) {
-                       fprintf(stderr, "problems parsing %s list\n",
-                               list_name);
-                       exit(129);
-               }
-               if (strlist__nr_entries(*list) == 1) {
-                       fprintf(fp, "# %s: %s\n", list_name,
-                               strlist__entry(*list, 0)->s);
-                       se->elide = true;
-               }
-       }
-}
+       setup_pager();
 
-int cmd_report(int argc, const char **argv, const char *prefix __used)
-{
-       if (symbol__init(&symbol_conf) < 0)
+       if (symbol__init() < 0)
                return -1;
 
-       argc = parse_options(argc, argv, options, report_usage, 0);
-
-       setup_sorting();
+       setup_sorting(report_usage, options);
 
        if (parent_pattern != default_parent_pattern) {
                sort_dimension__add("parent");
                sort_parent.elide = 1;
        } else
-               exclude_other = 0;
+               symbol_conf.exclude_other = false;
 
        /*
         * Any (unrecognized) arguments left?
@@ -964,17 +367,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
        if (argc)
                usage_with_options(report_usage, options);
 
-       setup_pager();
-
-       setup_list(&dso_list, dso_list_str, &sort_dso, "dso", stdout);
-       setup_list(&comm_list, comm_list_str, &sort_comm, "comm", stdout);
-       setup_list(&sym_list, sym_list_str, &sort_sym, "symbol", stdout);
-
-       if (field_sep && *field_sep == '.') {
-               fputs("'.' is the only non valid --field-separator argument\n",
-                     stderr);
-               exit(129);
-       }
+       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
+       sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);
+       sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
 
        return __cmd_report();
 }
index 65021fe1361e0ae712614fcf0d966d89fcb8789e..80209df6cfe8df3267050c8bb64f5974748a8ce7 100644 (file)
@@ -12,7 +12,6 @@
 #include "util/trace-event.h"
 
 #include "util/debug.h"
-#include "util/data_map.h"
 
 #include <sys/prctl.h>
 
@@ -22,8 +21,6 @@
 
 static char                    const *input_name = "perf.data";
 
-static u64                     sample_type;
-
 static char                    default_sort_order[] = "avg, max, switch, runtime";
 static char                    *sort_order = default_sort_order;
 
@@ -731,18 +728,21 @@ struct trace_migrate_task_event {
 
 struct trace_sched_handler {
        void (*switch_event)(struct trace_switch_event *,
+                            struct perf_session *,
                             struct event *,
                             int cpu,
                             u64 timestamp,
                             struct thread *thread);
 
        void (*runtime_event)(struct trace_runtime_event *,
+                             struct perf_session *,
                              struct event *,
                              int cpu,
                              u64 timestamp,
                              struct thread *thread);
 
        void (*wakeup_event)(struct trace_wakeup_event *,
+                            struct perf_session *,
                             struct event *,
                             int cpu,
                             u64 timestamp,
@@ -755,6 +755,7 @@ struct trace_sched_handler {
                           struct thread *thread);
 
        void (*migrate_task_event)(struct trace_migrate_task_event *,
+                          struct perf_session *session,
                           struct event *,
                           int cpu,
                           u64 timestamp,
@@ -764,6 +765,7 @@ struct trace_sched_handler {
 
 static void
 replay_wakeup_event(struct trace_wakeup_event *wakeup_event,
+                   struct perf_session *session __used,
                    struct event *event,
                    int cpu __used,
                    u64 timestamp __used,
@@ -790,6 +792,7 @@ static u64 cpu_last_switched[MAX_CPUS];
 
 static void
 replay_switch_event(struct trace_switch_event *switch_event,
+                   struct perf_session *session __used,
                    struct event *event,
                    int cpu,
                    u64 timestamp,
@@ -1023,6 +1026,7 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp)
 
 static void
 latency_switch_event(struct trace_switch_event *switch_event,
+                    struct perf_session *session,
                     struct event *event __used,
                     int cpu,
                     u64 timestamp,
@@ -1046,8 +1050,8 @@ latency_switch_event(struct trace_switch_event *switch_event,
                die("hm, delta: %Ld < 0 ?\n", delta);
 
 
-       sched_out = threads__findnew(switch_event->prev_pid);
-       sched_in = threads__findnew(switch_event->next_pid);
+       sched_out = perf_session__findnew(session, switch_event->prev_pid);
+       sched_in = perf_session__findnew(session, switch_event->next_pid);
 
        out_events = thread_atoms_search(&atom_root, sched_out, &cmp_pid);
        if (!out_events) {
@@ -1075,12 +1079,13 @@ latency_switch_event(struct trace_switch_event *switch_event,
 
 static void
 latency_runtime_event(struct trace_runtime_event *runtime_event,
+                    struct perf_session *session,
                     struct event *event __used,
                     int cpu,
                     u64 timestamp,
                     struct thread *this_thread __used)
 {
-       struct thread *thread = threads__findnew(runtime_event->pid);
+       struct thread *thread = perf_session__findnew(session, runtime_event->pid);
        struct work_atoms *atoms = thread_atoms_search(&atom_root, thread, &cmp_pid);
 
        BUG_ON(cpu >= MAX_CPUS || cpu < 0);
@@ -1097,6 +1102,7 @@ latency_runtime_event(struct trace_runtime_event *runtime_event,
 
 static void
 latency_wakeup_event(struct trace_wakeup_event *wakeup_event,
+                    struct perf_session *session,
                     struct event *__event __used,
                     int cpu __used,
                     u64 timestamp,
@@ -1110,7 +1116,7 @@ latency_wakeup_event(struct trace_wakeup_event *wakeup_event,
        if (!wakeup_event->success)
                return;
 
-       wakee = threads__findnew(wakeup_event->pid);
+       wakee = perf_session__findnew(session, wakeup_event->pid);
        atoms = thread_atoms_search(&atom_root, wakee, &cmp_pid);
        if (!atoms) {
                thread_atoms_insert(wakee);
@@ -1144,6 +1150,7 @@ latency_wakeup_event(struct trace_wakeup_event *wakeup_event,
 
 static void
 latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event,
+                    struct perf_session *session,
                     struct event *__event __used,
                     int cpu __used,
                     u64 timestamp,
@@ -1159,7 +1166,7 @@ latency_migrate_task_event(struct trace_migrate_task_event *migrate_task_event,
        if (profile_cpu == -1)
                return;
 
-       migrant = threads__findnew(migrate_task_event->pid);
+       migrant = perf_session__findnew(session, migrate_task_event->pid);
        atoms = thread_atoms_search(&atom_root, migrant, &cmp_pid);
        if (!atoms) {
                thread_atoms_insert(migrant);
@@ -1354,7 +1361,7 @@ static void sort_lat(void)
 static struct trace_sched_handler *trace_handler;
 
 static void
-process_sched_wakeup_event(void *data,
+process_sched_wakeup_event(void *data, struct perf_session *session,
                           struct event *event,
                           int cpu __used,
                           u64 timestamp __used,
@@ -1371,7 +1378,8 @@ process_sched_wakeup_event(void *data,
        FILL_FIELD(wakeup_event, cpu, event, data);
 
        if (trace_handler->wakeup_event)
-               trace_handler->wakeup_event(&wakeup_event, event, cpu, timestamp, thread);
+               trace_handler->wakeup_event(&wakeup_event, session, event,
+                                           cpu, timestamp, thread);
 }
 
 /*
@@ -1389,6 +1397,7 @@ static char next_shortname2 = '0';
 
 static void
 map_switch_event(struct trace_switch_event *switch_event,
+                struct perf_session *session,
                 struct event *event __used,
                 int this_cpu,
                 u64 timestamp,
@@ -1416,8 +1425,8 @@ map_switch_event(struct trace_switch_event *switch_event,
                die("hm, delta: %Ld < 0 ?\n", delta);
 
 
-       sched_out = threads__findnew(switch_event->prev_pid);
-       sched_in = threads__findnew(switch_event->next_pid);
+       sched_out = perf_session__findnew(session, switch_event->prev_pid);
+       sched_in = perf_session__findnew(session, switch_event->next_pid);
 
        curr_thread[this_cpu] = sched_in;
 
@@ -1467,7 +1476,7 @@ map_switch_event(struct trace_switch_event *switch_event,
 
 
 static void
-process_sched_switch_event(void *data,
+process_sched_switch_event(void *data, struct perf_session *session,
                           struct event *event,
                           int this_cpu,
                           u64 timestamp __used,
@@ -1494,13 +1503,14 @@ process_sched_switch_event(void *data,
                        nr_context_switch_bugs++;
        }
        if (trace_handler->switch_event)
-               trace_handler->switch_event(&switch_event, event, this_cpu, timestamp, thread);
+               trace_handler->switch_event(&switch_event, session, event,
+                                           this_cpu, timestamp, thread);
 
        curr_pid[this_cpu] = switch_event.next_pid;
 }
 
 static void
-process_sched_runtime_event(void *data,
+process_sched_runtime_event(void *data, struct perf_session *session,
                           struct event *event,
                           int cpu __used,
                           u64 timestamp __used,
@@ -1514,7 +1524,7 @@ process_sched_runtime_event(void *data,
        FILL_FIELD(runtime_event, vruntime, event, data);
 
        if (trace_handler->runtime_event)
-               trace_handler->runtime_event(&runtime_event, event, cpu, timestamp, thread);
+               trace_handler->runtime_event(&runtime_event, session, event, cpu, timestamp, thread);
 }
 
 static void
@@ -1534,7 +1544,8 @@ process_sched_fork_event(void *data,
        FILL_FIELD(fork_event, child_pid, event, data);
 
        if (trace_handler->fork_event)
-               trace_handler->fork_event(&fork_event, event, cpu, timestamp, thread);
+               trace_handler->fork_event(&fork_event, event,
+                                         cpu, timestamp, thread);
 }
 
 static void
@@ -1548,7 +1559,7 @@ process_sched_exit_event(struct event *event,
 }
 
 static void
-process_sched_migrate_task_event(void *data,
+process_sched_migrate_task_event(void *data, struct perf_session *session,
                           struct event *event,
                           int cpu __used,
                           u64 timestamp __used,
@@ -1564,12 +1575,13 @@ process_sched_migrate_task_event(void *data,
        FILL_FIELD(migrate_task_event, cpu, event, data);
 
        if (trace_handler->migrate_task_event)
-               trace_handler->migrate_task_event(&migrate_task_event, event, cpu, timestamp, thread);
+               trace_handler->migrate_task_event(&migrate_task_event, session,
+                                                event, cpu, timestamp, thread);
 }
 
 static void
-process_raw_event(event_t *raw_event __used, void *data,
-                 int cpu, u64 timestamp, struct thread *thread)
+process_raw_event(event_t *raw_event __used, struct perf_session *session,
+                 void *data, int cpu, u64 timestamp, struct thread *thread)
 {
        struct event *event;
        int type;
@@ -1579,27 +1591,27 @@ process_raw_event(event_t *raw_event __used, void *data,
        event = trace_find_event(type);
 
        if (!strcmp(event->name, "sched_switch"))
-               process_sched_switch_event(data, event, cpu, timestamp, thread);
+               process_sched_switch_event(data, session, event, cpu, timestamp, thread);
        if (!strcmp(event->name, "sched_stat_runtime"))
-               process_sched_runtime_event(data, event, cpu, timestamp, thread);
+               process_sched_runtime_event(data, session, event, cpu, timestamp, thread);
        if (!strcmp(event->name, "sched_wakeup"))
-               process_sched_wakeup_event(data, event, cpu, timestamp, thread);
+               process_sched_wakeup_event(data, session, event, cpu, timestamp, thread);
        if (!strcmp(event->name, "sched_wakeup_new"))
-               process_sched_wakeup_event(data, event, cpu, timestamp, thread);
+               process_sched_wakeup_event(data, session, event, cpu, timestamp, thread);
        if (!strcmp(event->name, "sched_process_fork"))
                process_sched_fork_event(data, event, cpu, timestamp, thread);
        if (!strcmp(event->name, "sched_process_exit"))
                process_sched_exit_event(event, cpu, timestamp, thread);
        if (!strcmp(event->name, "sched_migrate_task"))
-               process_sched_migrate_task_event(data, event, cpu, timestamp, thread);
+               process_sched_migrate_task_event(data, session, event, cpu, timestamp, thread);
 }
 
-static int process_sample_event(event_t *event)
+static int process_sample_event(event_t *event, struct perf_session *session)
 {
        struct sample_data data;
        struct thread *thread;
 
-       if (!(sample_type & PERF_SAMPLE_RAW))
+       if (!(session->sample_type & PERF_SAMPLE_RAW))
                return 0;
 
        memset(&data, 0, sizeof(data));
@@ -1607,7 +1619,7 @@ static int process_sample_event(event_t *event)
        data.cpu = -1;
        data.period = -1;
 
-       event__parse_sample(event, sample_type, &data);
+       event__parse_sample(event, session->sample_type, &data);
 
        dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
                event->header.misc,
@@ -1615,7 +1627,7 @@ static int process_sample_event(event_t *event)
                (void *)(long)data.ip,
                (long long)data.period);
 
-       thread = threads__findnew(data.pid);
+       thread = perf_session__findnew(session, data.pid);
        if (thread == NULL) {
                pr_debug("problem processing %d event, skipping it.\n",
                         event->header.type);
@@ -1627,12 +1639,13 @@ static int process_sample_event(event_t *event)
        if (profile_cpu != -1 && profile_cpu != (int)data.cpu)
                return 0;
 
-       process_raw_event(event, data.raw_data, data.cpu, data.time, thread);
+       process_raw_event(event, session, data.raw_data, data.cpu, data.time, thread);
 
        return 0;
 }
 
-static int process_lost_event(event_t *event __used)
+static int process_lost_event(event_t *event __used,
+                             struct perf_session *session __used)
 {
        nr_lost_chunks++;
        nr_lost_events += event->lost.lost;
@@ -1640,11 +1653,9 @@ static int process_lost_event(event_t *event __used)
        return 0;
 }
 
-static int sample_type_check(u64 type)
+static int sample_type_check(struct perf_session *session __used)
 {
-       sample_type = type;
-
-       if (!(sample_type & PERF_SAMPLE_RAW)) {
+       if (!(session->sample_type & PERF_SAMPLE_RAW)) {
                fprintf(stderr,
                        "No trace sample to read. Did you call perf record "
                        "without -R?");
@@ -1654,7 +1665,7 @@ static int sample_type_check(u64 type)
        return 0;
 }
 
-static struct perf_file_handler file_handler = {
+static struct perf_event_ops event_ops = {
        .process_sample_event   = process_sample_event,
        .process_comm_event     = event__process_comm,
        .process_lost_event     = process_lost_event,
@@ -1665,14 +1676,10 @@ static int read_events(void)
 {
        int err;
        struct perf_session *session = perf_session__new(input_name, O_RDONLY, 0);
-
        if (session == NULL)
                return -ENOMEM;
 
-       register_idle_thread();
-       register_perf_file_handler(&file_handler);
-
-       err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
+       err = perf_session__process_events(session, &event_ops);
        perf_session__delete(session);
        return err;
 }
@@ -1904,7 +1911,7 @@ int cmd_sched(int argc, const char **argv, const char *prefix __used)
        if (!strcmp(argv[0], "trace"))
                return cmd_trace(argc, argv, prefix);
 
-       symbol__init(0);
+       symbol__init();
        if (!strncmp(argv[0], "rec", 3)) {
                return __cmd_record(argc, argv);
        } else if (!strncmp(argv[0], "lat", 3)) {
index 759dd2b35fdbce539944627043b0922b7b711982..a589a43112d67f7b764ae02365a1b53e2e8119a7 100644 (file)
 #include "util/parse-options.h"
 #include "util/parse-events.h"
 #include "util/event.h"
-#include "util/data_map.h"
+#include "util/session.h"
 #include "util/svghelper.h"
 
 static char            const *input_name = "perf.data";
 static char            const *output_name = "output.svg";
 
-
-static u64             sample_type;
-
 static unsigned int    numcpus;
 static u64             min_freq;       /* Lowest CPU frequency seen */
 static u64             max_freq;       /* Highest CPU frequency seen */
@@ -281,21 +278,19 @@ static int cpus_cstate_state[MAX_CPUS];
 static u64 cpus_pstate_start_times[MAX_CPUS];
 static u64 cpus_pstate_state[MAX_CPUS];
 
-static int
-process_comm_event(event_t *event)
+static int process_comm_event(event_t *event, struct perf_session *session __used)
 {
        pid_set_comm(event->comm.pid, event->comm.comm);
        return 0;
 }
-static int
-process_fork_event(event_t *event)
+
+static int process_fork_event(event_t *event, struct perf_session *session __used)
 {
        pid_fork(event->fork.pid, event->fork.ppid, event->fork.time);
        return 0;
 }
 
-static int
-process_exit_event(event_t *event)
+static int process_exit_event(event_t *event, struct perf_session *session __used)
 {
        pid_exit(event->fork.pid, event->fork.time);
        return 0;
@@ -480,17 +475,16 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)
 }
 
 
-static int
-process_sample_event(event_t *event)
+static int process_sample_event(event_t *event, struct perf_session *session)
 {
        struct sample_data data;
        struct trace_entry *te;
 
        memset(&data, 0, sizeof(data));
 
-       event__parse_sample(event, sample_type, &data);
+       event__parse_sample(event, session->sample_type, &data);
 
-       if (sample_type & PERF_SAMPLE_TIME) {
+       if (session->sample_type & PERF_SAMPLE_TIME) {
                if (!first_time || first_time > data.time)
                        first_time = data.time;
                if (last_time < data.time)
@@ -498,7 +492,7 @@ process_sample_event(event_t *event)
        }
 
        te = (void *)data.raw_data;
-       if (sample_type & PERF_SAMPLE_RAW && data.raw_size > 0) {
+       if (session->sample_type & PERF_SAMPLE_RAW && data.raw_size > 0) {
                char *event_str;
                struct power_entry *pe;
 
@@ -575,16 +569,16 @@ static void end_sample_processing(void)
        }
 }
 
-static u64 sample_time(event_t *event)
+static u64 sample_time(event_t *event, const struct perf_session *session)
 {
        int cursor;
 
        cursor = 0;
-       if (sample_type & PERF_SAMPLE_IP)
+       if (session->sample_type & PERF_SAMPLE_IP)
                cursor++;
-       if (sample_type & PERF_SAMPLE_TID)
+       if (session->sample_type & PERF_SAMPLE_TID)
                cursor++;
-       if (sample_type & PERF_SAMPLE_TIME)
+       if (session->sample_type & PERF_SAMPLE_TIME)
                return event->sample.array[cursor];
        return 0;
 }
@@ -594,8 +588,7 @@ static u64 sample_time(event_t *event)
  * We first queue all events, sorted backwards by insertion.
  * The order will get flipped later.
  */
-static int
-queue_sample_event(event_t *event)
+static int queue_sample_event(event_t *event, struct perf_session *session)
 {
        struct sample_wrapper *copy, *prev;
        int size;
@@ -609,7 +602,7 @@ queue_sample_event(event_t *event)
        memset(copy, 0, size);
 
        copy->next = NULL;
-       copy->timestamp = sample_time(event);
+       copy->timestamp = sample_time(event, session);
 
        memcpy(&copy->data, event, event->sample.header.size);
 
@@ -1021,7 +1014,7 @@ static void write_svg_file(const char *filename)
        svg_close();
 }
 
-static void process_samples(void)
+static void process_samples(struct perf_session *session)
 {
        struct sample_wrapper *cursor;
        event_t *event;
@@ -1032,15 +1025,13 @@ static void process_samples(void)
        while (cursor) {
                event = (void *)&cursor->data;
                cursor = cursor->next;
-               process_sample_event(event);
+               process_sample_event(event, session);
        }
 }
 
-static int sample_type_check(u64 type)
+static int sample_type_check(struct perf_session *session)
 {
-       sample_type = type;
-
-       if (!(sample_type & PERF_SAMPLE_RAW)) {
+       if (!(session->sample_type & PERF_SAMPLE_RAW)) {
                fprintf(stderr, "No trace samples found in the file.\n"
                                "Have you used 'perf timechart record' to record it?\n");
                return -1;
@@ -1049,7 +1040,7 @@ static int sample_type_check(u64 type)
        return 0;
 }
 
-static struct perf_file_handler file_handler = {
+static struct perf_event_ops event_ops = {
        .process_comm_event     = process_comm_event,
        .process_fork_event     = process_fork_event,
        .process_exit_event     = process_exit_event,
@@ -1065,13 +1056,11 @@ static int __cmd_timechart(void)
        if (session == NULL)
                return -ENOMEM;
 
-       register_perf_file_handler(&file_handler);
-
-       ret = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
+       ret = perf_session__process_events(session, &event_ops);
        if (ret)
                goto out_delete;
 
-       process_samples();
+       process_samples(session);
 
        end_sample_processing();
 
@@ -1148,11 +1137,11 @@ static const struct option options[] = {
 
 int cmd_timechart(int argc, const char **argv, const char *prefix __used)
 {
-       symbol__init(0);
-
        argc = parse_options(argc, argv, options, timechart_usage,
                        PARSE_OPT_STOP_AT_NON_OPTION);
 
+       symbol__init();
+
        if (argc && !strncmp(argv[0], "rec", 3))
                return __cmd_record(argc, argv);
        else if (argc)
index e0a374d0e43a8da197177a7ccccbc3ada6349a2e..ddc584b64871019f0eb08dcd447ff511ce639983 100644 (file)
@@ -20,8 +20,9 @@
 
 #include "perf.h"
 
-#include "util/symbol.h"
 #include "util/color.h"
+#include "util/session.h"
+#include "util/symbol.h"
 #include "util/thread.h"
 #include "util/util.h"
 #include <linux/rbtree.h>
@@ -79,7 +80,6 @@ static int                    dump_symtab                     =      0;
 static bool                    hide_kernel_symbols             =  false;
 static bool                    hide_user_symbols               =  false;
 static struct winsize          winsize;
-struct symbol_conf             symbol_conf;
 
 /*
  * Source
@@ -926,7 +926,8 @@ static int symbol_filter(struct map *map, struct symbol *sym)
        return 0;
 }
 
-static void event__process_sample(const event_t *self, int counter)
+static void event__process_sample(const event_t *self,
+                                struct perf_session *session, int counter)
 {
        u64 ip = self->ip.ip;
        struct sym_entry *syme;
@@ -946,8 +947,8 @@ static void event__process_sample(const event_t *self, int counter)
                return;
        }
 
-       if (event__preprocess_sample(self, &al, symbol_filter) < 0 ||
-           al.sym == NULL)
+       if (event__preprocess_sample(self, session, &al, symbol_filter) < 0 ||
+           al.sym == NULL || al.filtered)
                return;
 
        syme = symbol__priv(al.sym);
@@ -965,14 +966,14 @@ static void event__process_sample(const event_t *self, int counter)
        }
 }
 
-static int event__process(event_t *event)
+static int event__process(event_t *event, struct perf_session *session)
 {
        switch (event->header.type) {
        case PERF_RECORD_COMM:
-               event__process_comm(event);
+               event__process_comm(event, session);
                break;
        case PERF_RECORD_MMAP:
-               event__process_mmap(event);
+               event__process_mmap(event, session);
                break;
        default:
                break;
@@ -999,7 +1000,8 @@ static unsigned int mmap_read_head(struct mmap_data *md)
        return head;
 }
 
-static void mmap_read_counter(struct mmap_data *md)
+static void perf_session__mmap_read_counter(struct perf_session *self,
+                                           struct mmap_data *md)
 {
        unsigned int head = mmap_read_head(md);
        unsigned int old = md->prev;
@@ -1052,9 +1054,9 @@ static void mmap_read_counter(struct mmap_data *md)
                }
 
                if (event->header.type == PERF_RECORD_SAMPLE)
-                       event__process_sample(event, md->counter);
+                       event__process_sample(event, self, md->counter);
                else
-                       event__process(event);
+                       event__process(event, self);
                old += size;
        }
 
@@ -1064,13 +1066,13 @@ static void mmap_read_counter(struct mmap_data *md)
 static struct pollfd event_array[MAX_NR_CPUS * MAX_COUNTERS];
 static struct mmap_data mmap_array[MAX_NR_CPUS][MAX_COUNTERS];
 
-static void mmap_read(void)
+static void perf_session__mmap_read(struct perf_session *self)
 {
        int i, counter;
 
        for (i = 0; i < nr_cpus; i++) {
                for (counter = 0; counter < nr_counters; counter++)
-                       mmap_read_counter(&mmap_array[i][counter]);
+                       perf_session__mmap_read_counter(self, &mmap_array[i][counter]);
        }
 }
 
@@ -1155,11 +1157,18 @@ static int __cmd_top(void)
        pthread_t thread;
        int i, counter;
        int ret;
+       /*
+        * FIXME: perf_session__new should allow passing a O_MMAP, so that all this
+        * mmap reading, etc is encapsulated in it. Use O_WRONLY for now.
+        */
+       struct perf_session *session = perf_session__new(NULL, O_WRONLY, false);
+       if (session == NULL)
+               return -ENOMEM;
 
        if (target_pid != -1)
-               event__synthesize_thread(target_pid, event__process);
+               event__synthesize_thread(target_pid, event__process, session);
        else
-               event__synthesize_threads(event__process);
+               event__synthesize_threads(event__process, session);
 
        for (i = 0; i < nr_cpus; i++) {
                group_fd = -1;
@@ -1170,7 +1179,7 @@ static int __cmd_top(void)
        /* Wait for a minimal set of events before starting the snapshot */
        poll(event_array, nr_poll, 100);
 
-       mmap_read();
+       perf_session__mmap_read(session);
 
        if (pthread_create(&thread, NULL, display_thread, NULL)) {
                printf("Could not create display thread.\n");
@@ -1190,7 +1199,7 @@ static int __cmd_top(void)
        while (1) {
                int hits = samples;
 
-               mmap_read();
+               perf_session__mmap_read(session);
 
                if (hits == samples)
                        ret = poll(event_array, nr_poll, 100);
@@ -1273,7 +1282,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
                                 (nr_counters + 1) * sizeof(unsigned long));
        if (symbol_conf.vmlinux_name == NULL)
                symbol_conf.try_vmlinux_path = true;
-       if (symbol__init(&symbol_conf) < 0)
+       if (symbol__init() < 0)
                return -1;
 
        if (delay_secs < 1)
index 0756664666f1021289ac3f610bc06ab685ecac12..e2285e28720fe2cb076240edc53fdd90913ee748 100644 (file)
@@ -12,7 +12,9 @@
 static char const              *script_name;
 static char const              *generate_script_lang;
 
-static int default_start_script(const char *script __attribute((unused)))
+static int default_start_script(const char *script __unused,
+                               int argc __unused,
+                               const char **argv __unused)
 {
        return 0;
 }
@@ -22,7 +24,7 @@ static int default_stop_script(void)
        return 0;
 }
 
-static int default_generate_script(const char *outfile __attribute ((unused)))
+static int default_generate_script(const char *outfile __unused)
 {
        return 0;
 }
@@ -57,15 +59,11 @@ static int cleanup_scripting(void)
 #include "util/debug.h"
 
 #include "util/trace-event.h"
-#include "util/data_map.h"
 #include "util/exec_cmd.h"
 
 static char const              *input_name = "perf.data";
 
-static struct perf_session     *session;
-static u64                     sample_type;
-
-static int process_sample_event(event_t *event)
+static int process_sample_event(event_t *event, struct perf_session *session)
 {
        struct sample_data data;
        struct thread *thread;
@@ -75,7 +73,7 @@ static int process_sample_event(event_t *event)
        data.cpu = -1;
        data.period = 1;
 
-       event__parse_sample(event, sample_type, &data);
+       event__parse_sample(event, session->sample_type, &data);
 
        dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
                event->header.misc,
@@ -83,14 +81,14 @@ static int process_sample_event(event_t *event)
                (void *)(long)data.ip,
                (long long)data.period);
 
-       thread = threads__findnew(event->ip.pid);
+       thread = perf_session__findnew(session, event->ip.pid);
        if (thread == NULL) {
                pr_debug("problem processing %d event, skipping it.\n",
                         event->header.type);
                return -1;
        }
 
-       if (sample_type & PERF_SAMPLE_RAW) {
+       if (session->sample_type & PERF_SAMPLE_RAW) {
                /*
                 * FIXME: better resolve from pid from the struct trace_entry
                 * field, although it should be the same than this perf
@@ -100,16 +98,14 @@ static int process_sample_event(event_t *event)
                                             data.raw_size,
                                             data.time, thread->comm);
        }
-       event__stats.total += data.period;
 
+       session->events_stats.total += data.period;
        return 0;
 }
 
-static int sample_type_check(u64 type)
+static int sample_type_check(struct perf_session *session)
 {
-       sample_type = type;
-
-       if (!(sample_type & PERF_SAMPLE_RAW)) {
+       if (!(session->sample_type & PERF_SAMPLE_RAW)) {
                fprintf(stderr,
                        "No trace sample to read. Did you call perf record "
                        "without -R?");
@@ -119,26 +115,15 @@ static int sample_type_check(u64 type)
        return 0;
 }
 
-static struct perf_file_handler file_handler = {
+static struct perf_event_ops event_ops = {
        .process_sample_event   = process_sample_event,
        .process_comm_event     = event__process_comm,
        .sample_type_check      = sample_type_check,
 };
 
-static int __cmd_trace(void)
+static int __cmd_trace(struct perf_session *session)
 {
-       int err;
-
-       session = perf_session__new(input_name, O_RDONLY, 0);
-       if (session == NULL)
-               return -ENOMEM;
-
-       register_idle_thread();
-       register_perf_file_handler(&file_handler);
-
-       err = perf_session__process_events(session, 0, &event__cwdlen, &event__cwd);
-       perf_session__delete(session);
-       return err;
+       return perf_session__process_events(session, &event_ops);
 }
 
 struct script_spec {
@@ -289,6 +274,244 @@ static int parse_scriptname(const struct option *opt __used,
        return 0;
 }
 
+#define for_each_lang(scripts_dir, lang_dirent, lang_next)             \
+       while (!readdir_r(scripts_dir, &lang_dirent, &lang_next) &&     \
+              lang_next)                                               \
+               if (lang_dirent.d_type == DT_DIR &&                     \
+                   (strcmp(lang_dirent.d_name, ".")) &&                \
+                   (strcmp(lang_dirent.d_name, "..")))
+
+#define for_each_script(lang_dir, script_dirent, script_next)          \
+       while (!readdir_r(lang_dir, &script_dirent, &script_next) &&    \
+              script_next)                                             \
+               if (script_dirent.d_type != DT_DIR)
+
+
+#define RECORD_SUFFIX                  "-record"
+#define REPORT_SUFFIX                  "-report"
+
+struct script_desc {
+       struct list_head        node;
+       char                    *name;
+       char                    *half_liner;
+       char                    *args;
+};
+
+LIST_HEAD(script_descs);
+
+static struct script_desc *script_desc__new(const char *name)
+{
+       struct script_desc *s = zalloc(sizeof(*s));
+
+       if (s != NULL)
+               s->name = strdup(name);
+
+       return s;
+}
+
+static void script_desc__delete(struct script_desc *s)
+{
+       free(s->name);
+       free(s);
+}
+
+static void script_desc__add(struct script_desc *s)
+{
+       list_add_tail(&s->node, &script_descs);
+}
+
+static struct script_desc *script_desc__find(const char *name)
+{
+       struct script_desc *s;
+
+       list_for_each_entry(s, &script_descs, node)
+               if (strcasecmp(s->name, name) == 0)
+                       return s;
+       return NULL;
+}
+
+static struct script_desc *script_desc__findnew(const char *name)
+{
+       struct script_desc *s = script_desc__find(name);
+
+       if (s)
+               return s;
+
+       s = script_desc__new(name);
+       if (!s)
+               goto out_delete_desc;
+
+       script_desc__add(s);
+
+       return s;
+
+out_delete_desc:
+       script_desc__delete(s);
+
+       return NULL;
+}
+
+static char *ends_with(char *str, const char *suffix)
+{
+       size_t suffix_len = strlen(suffix);
+       char *p = str;
+
+       if (strlen(str) > suffix_len) {
+               p = str + strlen(str) - suffix_len;
+               if (!strncmp(p, suffix, suffix_len))
+                       return p;
+       }
+
+       return NULL;
+}
+
+static char *ltrim(char *str)
+{
+       int len = strlen(str);
+
+       while (len && isspace(*str)) {
+               len--;
+               str++;
+       }
+
+       return str;
+}
+
+static int read_script_info(struct script_desc *desc, const char *filename)
+{
+       char line[BUFSIZ], *p;
+       FILE *fp;
+
+       fp = fopen(filename, "r");
+       if (!fp)
+               return -1;
+
+       while (fgets(line, sizeof(line), fp)) {
+               p = ltrim(line);
+               if (strlen(p) == 0)
+                       continue;
+               if (*p != '#')
+                       continue;
+               p++;
+               if (strlen(p) && *p == '!')
+                       continue;
+
+               p = ltrim(p);
+               if (strlen(p) && p[strlen(p) - 1] == '\n')
+                       p[strlen(p) - 1] = '\0';
+
+               if (!strncmp(p, "description:", strlen("description:"))) {
+                       p += strlen("description:");
+                       desc->half_liner = strdup(ltrim(p));
+                       continue;
+               }
+
+               if (!strncmp(p, "args:", strlen("args:"))) {
+                       p += strlen("args:");
+                       desc->args = strdup(ltrim(p));
+                       continue;
+               }
+       }
+
+       fclose(fp);
+
+       return 0;
+}
+
+static int list_available_scripts(const struct option *opt __used,
+                                 const char *s __used, int unset __used)
+{
+       struct dirent *script_next, *lang_next, script_dirent, lang_dirent;
+       char scripts_path[MAXPATHLEN];
+       DIR *scripts_dir, *lang_dir;
+       char script_path[MAXPATHLEN];
+       char lang_path[MAXPATHLEN];
+       struct script_desc *desc;
+       char first_half[BUFSIZ];
+       char *script_root;
+       char *str;
+
+       snprintf(scripts_path, MAXPATHLEN, "%s/scripts", perf_exec_path());
+
+       scripts_dir = opendir(scripts_path);
+       if (!scripts_dir)
+               return -1;
+
+       for_each_lang(scripts_dir, lang_dirent, lang_next) {
+               snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
+                        lang_dirent.d_name);
+               lang_dir = opendir(lang_path);
+               if (!lang_dir)
+                       continue;
+
+               for_each_script(lang_dir, script_dirent, script_next) {
+                       script_root = strdup(script_dirent.d_name);
+                       str = ends_with(script_root, REPORT_SUFFIX);
+                       if (str) {
+                               *str = '\0';
+                               desc = script_desc__findnew(script_root);
+                               snprintf(script_path, MAXPATHLEN, "%s/%s",
+                                        lang_path, script_dirent.d_name);
+                               read_script_info(desc, script_path);
+                       }
+                       free(script_root);
+               }
+       }
+
+       fprintf(stdout, "List of available trace scripts:\n");
+       list_for_each_entry(desc, &script_descs, node) {
+               sprintf(first_half, "%s %s", desc->name,
+                       desc->args ? desc->args : "");
+               fprintf(stdout, "  %-36s %s\n", first_half,
+                       desc->half_liner ? desc->half_liner : "");
+       }
+
+       exit(0);
+}
+
+static char *get_script_path(const char *script_root, const char *suffix)
+{
+       struct dirent *script_next, *lang_next, script_dirent, lang_dirent;
+       char scripts_path[MAXPATHLEN];
+       char script_path[MAXPATHLEN];
+       DIR *scripts_dir, *lang_dir;
+       char lang_path[MAXPATHLEN];
+       char *str, *__script_root;
+       char *path = NULL;
+
+       snprintf(scripts_path, MAXPATHLEN, "%s/scripts", perf_exec_path());
+
+       scripts_dir = opendir(scripts_path);
+       if (!scripts_dir)
+               return NULL;
+
+       for_each_lang(scripts_dir, lang_dirent, lang_next) {
+               snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
+                        lang_dirent.d_name);
+               lang_dir = opendir(lang_path);
+               if (!lang_dir)
+                       continue;
+
+               for_each_script(lang_dir, script_dirent, script_next) {
+                       __script_root = strdup(script_dirent.d_name);
+                       str = ends_with(__script_root, suffix);
+                       if (str) {
+                               *str = '\0';
+                               if (strcmp(__script_root, script_root))
+                                       continue;
+                               snprintf(script_path, MAXPATHLEN, "%s/%s",
+                                        lang_path, script_dirent.d_name);
+                               path = strdup(script_path);
+                               free(__script_root);
+                               break;
+                       }
+                       free(__script_root);
+               }
+       }
+
+       return path;
+}
+
 static const char * const annotate_usage[] = {
        "perf trace [<options>] <command>",
        NULL
@@ -299,8 +522,10 @@ static const struct option options[] = {
                    "dump raw trace in ASCII"),
        OPT_BOOLEAN('v', "verbose", &verbose,
                    "be more verbose (show symbol address, etc)"),
-       OPT_BOOLEAN('l', "latency", &latency_format,
+       OPT_BOOLEAN('L', "Latency", &latency_format,
                    "show latency attributes (irqs/preemption disabled, etc)"),
+       OPT_CALLBACK_NOOPT('l', "list", NULL, NULL, "list available scripts",
+                          list_available_scripts),
        OPT_CALLBACK('s', "script", NULL, "name",
                     "script file name (lang:script name, script name, or *)",
                     parse_scriptname),
@@ -312,24 +537,61 @@ static const struct option options[] = {
 
 int cmd_trace(int argc, const char **argv, const char *prefix __used)
 {
-       int err;
+       struct perf_session *session;
+       const char *suffix = NULL;
+       const char **__argv;
+       char *script_path;
+       int i, err;
+
+       if (argc >= 2 && strncmp(argv[1], "rec", strlen("rec")) == 0) {
+               if (argc < 3) {
+                       fprintf(stderr,
+                               "Please specify a record script\n");
+                       return -1;
+               }
+               suffix = RECORD_SUFFIX;
+       }
 
-       symbol__init(0);
+       if (argc >= 2 && strncmp(argv[1], "rep", strlen("rep")) == 0) {
+               if (argc < 3) {
+                       fprintf(stderr,
+                               "Please specify a report script\n");
+                       return -1;
+               }
+               suffix = REPORT_SUFFIX;
+       }
 
-       setup_scripting();
+       if (suffix) {
+               script_path = get_script_path(argv[2], suffix);
+               if (!script_path) {
+                       fprintf(stderr, "script not found\n");
+                       return -1;
+               }
 
-       argc = parse_options(argc, argv, options, annotate_usage, 0);
-       if (argc) {
-               /*
-                * Special case: if there's an argument left then assume tha
-                * it's a symbol filter:
-                */
-               if (argc > 1)
-                       usage_with_options(annotate_usage, options);
+               __argv = malloc((argc + 1) * sizeof(const char *));
+               __argv[0] = "/bin/sh";
+               __argv[1] = script_path;
+               for (i = 3; i < argc; i++)
+                       __argv[i - 1] = argv[i];
+               __argv[argc - 1] = NULL;
+
+               execvp("/bin/sh", (char **)__argv);
+               exit(-1);
        }
 
+       setup_scripting();
+
+       argc = parse_options(argc, argv, options, annotate_usage,
+                            PARSE_OPT_STOP_AT_NON_OPTION);
+
+       if (symbol__init() < 0)
+               return -1;
        setup_pager();
 
+       session = perf_session__new(input_name, O_RDONLY, 0);
+       if (session == NULL)
+               return -ENOMEM;
+
        if (generate_script_lang) {
                struct stat perf_stat;
 
@@ -362,13 +624,14 @@ int cmd_trace(int argc, const char **argv, const char *prefix __used)
        }
 
        if (script_name) {
-               err = scripting_ops->start_script(script_name);
+               err = scripting_ops->start_script(script_name, argc, argv);
                if (err)
                        goto out;
        }
 
-       err = __cmd_trace();
+       err = __cmd_trace(session);
 
+       perf_session__delete(session);
        cleanup_scripting();
 out:
        return err;
index a3d8bf65f26c2a0466bd76ab02d5e48db02ce0dc..18035b1f16c79eca09add0eb9a34c5540823faf1 100644 (file)
@@ -17,6 +17,7 @@ extern int check_pager_config(const char *cmd);
 extern int cmd_annotate(int argc, const char **argv, const char *prefix);
 extern int cmd_bench(int argc, const char **argv, const char *prefix);
 extern int cmd_buildid_list(int argc, const char **argv, const char *prefix);
+extern int cmd_diff(int argc, const char **argv, const char *prefix);
 extern int cmd_help(int argc, const char **argv, const char *prefix);
 extern int cmd_sched(int argc, const char **argv, const char *prefix);
 extern int cmd_list(int argc, const char **argv, const char *prefix);
index 02b09ea17a3ecad604cd970edf28b386fb22a15b..71dc7c3fe7b266c1ba8bca6cb05dc34de3044b1f 100644 (file)
@@ -5,6 +5,7 @@
 perf-annotate                  mainporcelain common
 perf-bench                     mainporcelain common
 perf-buildid-list              mainporcelain common
+perf-diff                      mainporcelain common
 perf-list                      mainporcelain common
 perf-sched                     mainporcelain common
 perf-record                    mainporcelain common
index cf64049bc9bdd71e4c97c68a59e5b754bf9311ad..873e55fab375d253d4b80d4fb1862053f21080a4 100644 (file)
@@ -286,6 +286,7 @@ static void handle_internal_command(int argc, const char **argv)
        const char *cmd = argv[0];
        static struct cmd_struct commands[] = {
                { "buildid-list", cmd_buildid_list, 0 },
+               { "diff",       cmd_diff,       0 },
                { "help",       cmd_help,       0 },
                { "list",       cmd_list,       0 },
                { "record",     cmd_record,     0 },
index 89948b015020f4780a23f2c33f51dd6302e4fb6b..7fc4a033dd494caa8d994baec7c1a29130f66878 100644 (file)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# description: useless but exhaustive test script
 perf trace -s ~/libexec/perf-core/scripts/perl/check-perf-trace.pl
 
 
index f5dcf9cb5bd25dbc7f5314c2cad254c41d1c6b8d..eddb9ccce6a59111a2a1a61a566b45774b111536 100644 (file)
@@ -1,5 +1,7 @@
 #!/bin/bash
-perf trace -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl
+# description: r/w activity for a program, by file
+# args: <comm>
+perf trace -s ~/libexec/perf-core/scripts/perl/rw-by-file.pl $1
 
 
 
index cea16f78a3a2fb10f6a05b196f619a176137c80f..7f44c25cc857ca6fbb1a4f8f220c9767b64c2468 100644 (file)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# description: system-wide r/w activity
 perf trace -s ~/libexec/perf-core/scripts/perl/rw-by-pid.pl
 
 
index 85769dc456eb8a4247f59951decf6800b46633bd..fce3adcb3249a4c2971a53ad8286ffb83736cbe8 100644 (file)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# description: system-wide min/max/avg wakeup latency
 perf trace -s ~/libexec/perf-core/scripts/perl/wakeup-latency.pl
 
 
index aa68435be92603451cb8c8d0b448602e2b85a3b4..71cfbd182fb99946185562cb8809f9ce53d309a8 100644 (file)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# description: workqueue stats (ins/exe/create/destroy)
 perf trace -s ~/libexec/perf-core/scripts/perl/workqueue-stats.pl
 
 
index 61f91561d848b91d766b5df0bb49a0131095687f..2a39097687b9f70dffb2fe83f4477539ff8e98b4 100644 (file)
@@ -18,8 +18,9 @@ use lib "./Perf-Trace-Util/lib";
 use Perf::Trace::Core;
 use Perf::Trace::Util;
 
-# change this to the comm of the program you're interested in
-my $for_comm = "perf";
+my $usage = "perf trace -s rw-by-file.pl <comm>\n";
+
+my $for_comm = shift or die $usage;
 
 my %reads;
 my %writes;
index 6d46dda53a29db2fe73c8ddeb22ffd8f0648b034..b557b836de3dca6e44543d7b851b62ff9cc42546 100644 (file)
@@ -1,20 +1,17 @@
-#include "data_map.h"
 #include "symbol.h"
 #include "util.h"
 #include "debug.h"
+#include "thread.h"
+#include "session.h"
 
-
-static struct perf_file_handler *curr_handler;
-static unsigned long   mmap_window = 32;
-static char            __cwd[PATH_MAX];
-
-static int process_event_stub(event_t *event __used)
+static int process_event_stub(event_t *event __used,
+                             struct perf_session *session __used)
 {
        dump_printf(": unhandled!\n");
        return 0;
 }
 
-void register_perf_file_handler(struct perf_file_handler *handler)
+static void perf_event_ops__fill_defaults(struct perf_event_ops *handler)
 {
        if (!handler->process_sample_event)
                handler->process_sample_event = process_event_stub;
@@ -34,8 +31,6 @@ void register_perf_file_handler(struct perf_file_handler *handler)
                handler->process_throttle_event = process_event_stub;
        if (!handler->process_unthrottle_event)
                handler->process_unthrottle_event = process_event_stub;
-
-       curr_handler = handler;
 }
 
 static const char *event__name[] = {
@@ -61,8 +56,9 @@ void event__print_totals(void)
                        event__name[i], event__total[i]);
 }
 
-static int
-process_event(event_t *event, unsigned long offset, unsigned long head)
+static int process_event(event_t *event, struct perf_session *session,
+                        struct perf_event_ops *ops,
+                        unsigned long offset, unsigned long head)
 {
        trace_event(event);
 
@@ -77,25 +73,25 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
 
        switch (event->header.type) {
        case PERF_RECORD_SAMPLE:
-               return curr_handler->process_sample_event(event);
+               return ops->process_sample_event(event, session);
        case PERF_RECORD_MMAP:
-               return curr_handler->process_mmap_event(event);
+               return ops->process_mmap_event(event, session);
        case PERF_RECORD_COMM:
-               return curr_handler->process_comm_event(event);
+               return ops->process_comm_event(event, session);
        case PERF_RECORD_FORK:
-               return curr_handler->process_fork_event(event);
+               return ops->process_fork_event(event, session);
        case PERF_RECORD_EXIT:
-               return curr_handler->process_exit_event(event);
+               return ops->process_exit_event(event, session);
        case PERF_RECORD_LOST:
-               return curr_handler->process_lost_event(event);
+               return ops->process_lost_event(event, session);
        case PERF_RECORD_READ:
-               return curr_handler->process_read_event(event);
+               return ops->process_read_event(event, session);
        case PERF_RECORD_THROTTLE:
-               return curr_handler->process_throttle_event(event);
+               return ops->process_throttle_event(event, session);
        case PERF_RECORD_UNTHROTTLE:
-               return curr_handler->process_unthrottle_event(event);
+               return ops->process_unthrottle_event(event, session);
        default:
-               curr_handler->total_unknown++;
+               ops->total_unknown++;
                return -1;
        }
 }
@@ -129,44 +125,58 @@ out:
        return err;
 }
 
+static struct thread *perf_session__register_idle_thread(struct perf_session *self)
+{
+       struct thread *thread = perf_session__findnew(self, 0);
+
+       if (!thread || thread__set_comm(thread, "swapper")) {
+               pr_err("problem inserting idle task.\n");
+               thread = NULL;
+       }
+
+       return thread;
+}
+
 int perf_session__process_events(struct perf_session *self,
-                                int full_paths, int *cwdlen, char **cwd)
+                                struct perf_event_ops *ops)
 {
        int err;
        unsigned long head, shift;
        unsigned long offset = 0;
        size_t  page_size;
-       u64 sample_type;
        event_t *event;
        uint32_t size;
        char *buf;
 
-       if (curr_handler == NULL) {
-               pr_debug("Forgot to register perf file handler\n");
-               return -EINVAL;
-       }
+       if (perf_session__register_idle_thread(self) == NULL)
+               return -ENOMEM;
+
+       perf_event_ops__fill_defaults(ops);
 
        page_size = getpagesize();
 
        head = self->header.data_offset;
-       sample_type = perf_header__sample_type(&self->header);
+       self->sample_type = perf_header__sample_type(&self->header);
 
        err = -EINVAL;
-       if (curr_handler->sample_type_check &&
-           curr_handler->sample_type_check(sample_type) < 0)
+       if (ops->sample_type_check && ops->sample_type_check(self) < 0)
                goto out_err;
 
-       if (!full_paths) {
-               if (getcwd(__cwd, sizeof(__cwd)) == NULL) {
-                       pr_err("failed to get the current directory\n");
+       if (!ops->full_paths) {
+               char bf[PATH_MAX];
+
+               if (getcwd(bf, sizeof(bf)) == NULL) {
                        err = -errno;
+out_getcwd_err:
+                       pr_err("failed to get the current directory\n");
                        goto out_err;
                }
-               *cwd = __cwd;
-               *cwdlen = strlen(*cwd);
-       } else {
-               *cwd = NULL;
-               *cwdlen = 0;
+               self->cwd = strdup(bf);
+               if (self->cwd == NULL) {
+                       err = -ENOMEM;
+                       goto out_getcwd_err;
+               }
+               self->cwdlen = strlen(self->cwd);
        }
 
        shift = page_size * (head / page_size);
@@ -174,7 +184,7 @@ int perf_session__process_events(struct perf_session *self,
        head -= shift;
 
 remap:
-       buf = mmap(NULL, page_size * mmap_window, PROT_READ,
+       buf = mmap(NULL, page_size * self->mmap_window, PROT_READ,
                   MAP_SHARED, self->fd, offset);
        if (buf == MAP_FAILED) {
                pr_err("failed to mmap file\n");
@@ -189,12 +199,12 @@ more:
        if (!size)
                size = 8;
 
-       if (head + event->header.size >= page_size * mmap_window) {
+       if (head + event->header.size >= page_size * self->mmap_window) {
                int munmap_ret;
 
                shift = page_size * (head / page_size);
 
-               munmap_ret = munmap(buf, page_size * mmap_window);
+               munmap_ret = munmap(buf, page_size * self->mmap_window);
                assert(munmap_ret == 0);
 
                offset += shift;
@@ -209,7 +219,7 @@ more:
                        (void *)(long)event->header.size,
                        event->header.type);
 
-       if (!size || process_event(event, offset, head) < 0) {
+       if (!size || process_event(event, self, ops, offset, head) < 0) {
 
                dump_printf("%p [%p]: skipping unknown header type: %d\n",
                        (void *)(offset + head),
diff --git a/tools/perf/util/data_map.h b/tools/perf/util/data_map.h
deleted file mode 100644 (file)
index 98c5b82..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __PERF_DATAMAP_H
-#define __PERF_DATAMAP_H
-
-#include "event.h"
-#include "header.h"
-#include "session.h"
-
-typedef int (*event_type_handler_t)(event_t *);
-
-struct perf_file_handler {
-       event_type_handler_t    process_sample_event;
-       event_type_handler_t    process_mmap_event;
-       event_type_handler_t    process_comm_event;
-       event_type_handler_t    process_fork_event;
-       event_type_handler_t    process_exit_event;
-       event_type_handler_t    process_lost_event;
-       event_type_handler_t    process_read_event;
-       event_type_handler_t    process_throttle_event;
-       event_type_handler_t    process_unthrottle_event;
-       int                     (*sample_type_check)(u64 sample_type);
-       unsigned long           total_unknown;
-};
-
-void register_perf_file_handler(struct perf_file_handler *handler);
-int perf_session__process_events(struct perf_session *self,
-                                int full_paths, int *cwdlen, char **cwd);
-int perf_header__read_build_ids(int input, u64 offset, u64 file_size);
-
-#endif
index ba0de90cd3d4ea6163f699233845fea5fb2b6976..bb0fd6da2d56f3850885d1d51df089dccc15d1d6 100644 (file)
@@ -1,11 +1,16 @@
 #include <linux/types.h>
 #include "event.h"
 #include "debug.h"
+#include "session.h"
+#include "sort.h"
 #include "string.h"
+#include "strlist.h"
 #include "thread.h"
 
 static pid_t event__synthesize_comm(pid_t pid, int full,
-                                   int (*process)(event_t *event))
+                                   int (*process)(event_t *event,
+                                                  struct perf_session *session),
+                                   struct perf_session *session)
 {
        event_t ev;
        char filename[PATH_MAX];
@@ -54,7 +59,7 @@ out_race:
        if (!full) {
                ev.comm.tid = pid;
 
-               process(&ev);
+               process(&ev, session);
                goto out_fclose;
        }
 
@@ -72,7 +77,7 @@ out_race:
 
                ev.comm.tid = pid;
 
-               process(&ev);
+               process(&ev, session);
        }
        closedir(tasks);
 
@@ -86,7 +91,9 @@ out_failure:
 }
 
 static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
-                                        int (*process)(event_t *event))
+                                        int (*process)(event_t *event,
+                                                       struct perf_session *session),
+                                        struct perf_session *session)
 {
        char filename[PATH_MAX];
        FILE *fp;
@@ -141,7 +148,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
                        ev.mmap.pid = tgid;
                        ev.mmap.tid = pid;
 
-                       process(&ev);
+                       process(&ev, session);
                }
        }
 
@@ -149,15 +156,20 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
        return 0;
 }
 
-int event__synthesize_thread(pid_t pid, int (*process)(event_t *event))
+int event__synthesize_thread(pid_t pid,
+                            int (*process)(event_t *event,
+                                           struct perf_session *session),
+                            struct perf_session *session)
 {
-       pid_t tgid = event__synthesize_comm(pid, 1, process);
+       pid_t tgid = event__synthesize_comm(pid, 1, process, session);
        if (tgid == -1)
                return -1;
-       return event__synthesize_mmap_events(pid, tgid, process);
+       return event__synthesize_mmap_events(pid, tgid, process, session);
 }
 
-void event__synthesize_threads(int (*process)(event_t *event))
+void event__synthesize_threads(int (*process)(event_t *event,
+                                             struct perf_session *session),
+                              struct perf_session *session)
 {
        DIR *proc;
        struct dirent dirent, *next;
@@ -171,24 +183,47 @@ void event__synthesize_threads(int (*process)(event_t *event))
                if (*end) /* only interested in proper numerical dirents */
                        continue;
 
-               event__synthesize_thread(pid, process);
+               event__synthesize_thread(pid, process, session);
        }
 
        closedir(proc);
 }
 
-char *event__cwd;
-int  event__cwdlen;
+static void thread__comm_adjust(struct thread *self)
+{
+       char *comm = self->comm;
 
-struct events_stats event__stats;
+       if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
+           (!symbol_conf.comm_list ||
+            strlist__has_entry(symbol_conf.comm_list, comm))) {
+               unsigned int slen = strlen(comm);
 
-int event__process_comm(event_t *self)
+               if (slen > comms__col_width) {
+                       comms__col_width = slen;
+                       threads__col_width = slen + 6;
+               }
+       }
+}
+
+static int thread__set_comm_adjust(struct thread *self, const char *comm)
 {
-       struct thread *thread = threads__findnew(self->comm.pid);
+       int ret = thread__set_comm(self, comm);
+
+       if (ret)
+               return ret;
+
+       thread__comm_adjust(self);
+
+       return 0;
+}
+
+int event__process_comm(event_t *self, struct perf_session *session)
+{
+       struct thread *thread = perf_session__findnew(session, self->comm.pid);
 
        dump_printf(": %s:%d\n", self->comm.comm, self->comm.pid);
 
-       if (thread == NULL || thread__set_comm(thread, self->comm.comm)) {
+       if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm)) {
                dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
                return -1;
        }
@@ -196,18 +231,18 @@ int event__process_comm(event_t *self)
        return 0;
 }
 
-int event__process_lost(event_t *self)
+int event__process_lost(event_t *self, struct perf_session *session)
 {
        dump_printf(": id:%Ld: lost:%Ld\n", self->lost.id, self->lost.lost);
-       event__stats.lost += self->lost.lost;
+       session->events_stats.lost += self->lost.lost;
        return 0;
 }
 
-int event__process_mmap(event_t *self)
+int event__process_mmap(event_t *self, struct perf_session *session)
 {
-       struct thread *thread = threads__findnew(self->mmap.pid);
+       struct thread *thread = perf_session__findnew(session, self->mmap.pid);
        struct map *map = map__new(&self->mmap, MAP__FUNCTION,
-                                  event__cwd, event__cwdlen);
+                                  session->cwd, session->cwdlen);
 
        dump_printf(" %d/%d: [%p(%p) @ %p]: %s\n",
                    self->mmap.pid, self->mmap.tid,
@@ -224,10 +259,10 @@ int event__process_mmap(event_t *self)
        return 0;
 }
 
-int event__process_task(event_t *self)
+int event__process_task(event_t *self, struct perf_session *session)
 {
-       struct thread *thread = threads__findnew(self->fork.pid);
-       struct thread *parent = threads__findnew(self->fork.ppid);
+       struct thread *thread = perf_session__findnew(session, self->fork.pid);
+       struct thread *parent = perf_session__findnew(session, self->fork.ppid);
 
        dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid,
                    self->fork.ppid, self->fork.ptid);
@@ -249,7 +284,8 @@ int event__process_task(event_t *self)
        return 0;
 }
 
-void thread__find_addr_location(struct thread *self, u8 cpumode,
+void thread__find_addr_location(struct thread *self,
+                               struct perf_session *session, u8 cpumode,
                                enum map_type type, u64 addr,
                                struct addr_location *al,
                                symbol_filter_t filter)
@@ -261,7 +297,7 @@ void thread__find_addr_location(struct thread *self, u8 cpumode,
 
        if (cpumode & PERF_RECORD_MISC_KERNEL) {
                al->level = 'k';
-               mg = kmaps;
+               mg = &session->kmaps;
        } else if (cpumode & PERF_RECORD_MISC_USER)
                al->level = '.';
        else {
@@ -282,33 +318,73 @@ try_again:
                 * "[vdso]" dso, but for now lets use the old trick of looking
                 * in the whole kernel symbol list.
                 */
-               if ((long long)al->addr < 0 && mg != kmaps) {
-                       mg = kmaps;
+               if ((long long)al->addr < 0 && mg != &session->kmaps) {
+                       mg = &session->kmaps;
                        goto try_again;
                }
                al->sym = NULL;
        } else {
                al->addr = al->map->map_ip(al->map, al->addr);
-               al->sym = map__find_symbol(al->map, al->addr, filter);
+               al->sym = map__find_symbol(al->map, session, al->addr, filter);
        }
 }
 
-int event__preprocess_sample(const event_t *self, struct addr_location *al,
-                            symbol_filter_t filter)
+static void dso__calc_col_width(struct dso *self)
+{
+       if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
+           (!symbol_conf.dso_list ||
+            strlist__has_entry(symbol_conf.dso_list, self->name))) {
+               unsigned int slen = strlen(self->name);
+               if (slen > dsos__col_width)
+                       dsos__col_width = slen;
+       }
+
+       self->slen_calculated = 1;
+}
+
+int event__preprocess_sample(const event_t *self, struct perf_session *session,
+                            struct addr_location *al, symbol_filter_t filter)
 {
        u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
-       struct thread *thread = threads__findnew(self->ip.pid);
+       struct thread *thread = perf_session__findnew(session, self->ip.pid);
 
        if (thread == NULL)
                return -1;
 
+       if (symbol_conf.comm_list &&
+           !strlist__has_entry(symbol_conf.comm_list, thread->comm))
+               goto out_filtered;
+
        dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
 
-       thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
+       thread__find_addr_location(thread, session, cpumode, MAP__FUNCTION,
                                   self->ip.ip, al, filter);
        dump_printf(" ...... dso: %s\n",
                    al->map ? al->map->dso->long_name :
                        al->level == 'H' ? "[hypervisor]" : "<not found>");
+       /*
+        * We have to do this here as we may have a dso with no symbol hit that
+        * has a name longer than the ones with symbols sampled.
+        */
+       if (al->map && !sort_dso.elide && !al->map->dso->slen_calculated)
+               dso__calc_col_width(al->map->dso);
+
+       if (symbol_conf.dso_list &&
+           (!al->map || !al->map->dso ||
+            !(strlist__has_entry(symbol_conf.dso_list, al->map->dso->short_name) ||
+              (al->map->dso->short_name != al->map->dso->long_name &&
+               strlist__has_entry(symbol_conf.dso_list, al->map->dso->long_name)))))
+               goto out_filtered;
+
+       if (symbol_conf.sym_list && al->sym &&
+           !strlist__has_entry(symbol_conf.sym_list, al->sym->name))
+               goto out_filtered;
+
+       al->filtered = false;
+       return 0;
+
+out_filtered:
+       al->filtered = true;
        return 0;
 }
 
index 51a96c2effdea662c4a77e5b5a2ed3cde1e61b64..690a96d0467c2325f4162092a2c2698f61f427f7 100644 (file)
@@ -95,8 +95,8 @@ typedef union event_union {
 } event_t;
 
 struct events_stats {
-       unsigned long total;
-       unsigned long lost;
+       u64 total;
+       u64 lost;
 };
 
 void event__print_totals(void);
@@ -149,29 +149,35 @@ void map__delete(struct map *self);
 struct map *map__clone(struct map *self);
 int map__overlap(struct map *l, struct map *r);
 size_t map__fprintf(struct map *self, FILE *fp);
-struct symbol *map__find_symbol(struct map *self, u64 addr,
-                               symbol_filter_t filter);
+
+struct perf_session;
+
+int map__load(struct map *self, struct perf_session *session,
+             symbol_filter_t filter);
+struct symbol *map__find_symbol(struct map *self, struct perf_session *session,
+                               u64 addr, symbol_filter_t filter);
 struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
+                                       struct perf_session *session,
                                        symbol_filter_t filter);
 void map__fixup_start(struct map *self);
 void map__fixup_end(struct map *self);
 
-int event__synthesize_thread(pid_t pid, int (*process)(event_t *event));
-void event__synthesize_threads(int (*process)(event_t *event));
-
-extern char *event__cwd;
-extern int  event__cwdlen;
-extern struct events_stats event__stats;
-extern unsigned long event__total[PERF_RECORD_MAX];
+int event__synthesize_thread(pid_t pid,
+                            int (*process)(event_t *event,
+                                           struct perf_session *session),
+                            struct perf_session *session);
+void event__synthesize_threads(int (*process)(event_t *event,
+                                             struct perf_session *session),
+                              struct perf_session *session);
 
-int event__process_comm(event_t *self);
-int event__process_lost(event_t *self);
-int event__process_mmap(event_t *self);
-int event__process_task(event_t *self);
+int event__process_comm(event_t *self, struct perf_session *session);
+int event__process_lost(event_t *self, struct perf_session *session);
+int event__process_mmap(event_t *self, struct perf_session *session);
+int event__process_task(event_t *self, struct perf_session *session);
 
 struct addr_location;
-int event__preprocess_sample(const event_t *self, struct addr_location *al,
-                            symbol_filter_t filter);
+int event__preprocess_sample(const event_t *self, struct perf_session *session,
+                            struct addr_location *al, symbol_filter_t filter);
 int event__parse_sample(event_t *event, u64 type, struct sample_data *data);
 
 #endif /* __PERF_RECORD_H */
index f2e8d87151116c94a78868ba580e56be24382264..8a0bca55106f8d4ddb15492404367ef5b3f3de88 100644 (file)
@@ -8,8 +8,8 @@
 #include "header.h"
 #include "../perf.h"
 #include "trace-event.h"
+#include "session.h"
 #include "symbol.h"
-#include "data_map.h"
 #include "debug.h"
 
 /*
index 0ebf6ee16caa4f4714aedce18ddb77eb1592962e..e8daf5ca6fd20dee79b5652c61ad48f59d109e30 100644 (file)
@@ -1,9 +1,7 @@
 #include "hist.h"
-
-struct rb_root hist;
-struct rb_root collapse_hists;
-struct rb_root output_hists;
-int callchain;
+#include "session.h"
+#include "sort.h"
+#include <math.h>
 
 struct callchain_param callchain_param = {
        .mode   = CHAIN_GRAPH_REL,
@@ -14,11 +12,12 @@ struct callchain_param      callchain_param = {
  * histogram, sorted on item, collects counts
  */
 
-struct hist_entry *__hist_entry__add(struct addr_location *al,
-                                    struct symbol *sym_parent,
-                                    u64 count, bool *hit)
+struct hist_entry *__perf_session__add_hist_entry(struct perf_session *self,
+                                                 struct addr_location *al,
+                                                 struct symbol *sym_parent,
+                                                 u64 count, bool *hit)
 {
-       struct rb_node **p = &hist.rb_node;
+       struct rb_node **p = &self->hists.rb_node;
        struct rb_node *parent = NULL;
        struct hist_entry *he;
        struct hist_entry entry = {
@@ -54,7 +53,7 @@ struct hist_entry *__hist_entry__add(struct addr_location *al,
                return NULL;
        *he = entry;
        rb_link_node(&he->rb_node, parent, p);
-       rb_insert_color(&he->rb_node, &hist);
+       rb_insert_color(&he->rb_node, &self->hists);
        *hit = false;
        return he;
 }
@@ -102,9 +101,9 @@ void hist_entry__free(struct hist_entry *he)
  * collapse the histogram
  */
 
-void collapse__insert_entry(struct hist_entry *he)
+static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
 {
-       struct rb_node **p = &collapse_hists.rb_node;
+       struct rb_node **p = &root->rb_node;
        struct rb_node *parent = NULL;
        struct hist_entry *iter;
        int64_t cmp;
@@ -128,38 +127,45 @@ void collapse__insert_entry(struct hist_entry *he)
        }
 
        rb_link_node(&he->rb_node, parent, p);
-       rb_insert_color(&he->rb_node, &collapse_hists);
+       rb_insert_color(&he->rb_node, root);
 }
 
-void collapse__resort(void)
+void perf_session__collapse_resort(struct perf_session *self)
 {
+       struct rb_root tmp;
        struct rb_node *next;
        struct hist_entry *n;
 
        if (!sort__need_collapse)
                return;
 
-       next = rb_first(&hist);
+       tmp = RB_ROOT;
+       next = rb_first(&self->hists);
+
        while (next) {
                n = rb_entry(next, struct hist_entry, rb_node);
                next = rb_next(&n->rb_node);
 
-               rb_erase(&n->rb_node, &hist);
-               collapse__insert_entry(n);
+               rb_erase(&n->rb_node, &self->hists);
+               collapse__insert_entry(&tmp, n);
        }
+
+       self->hists = tmp;
 }
 
 /*
  * reverse the map, sort on count.
  */
 
-void output__insert_entry(struct hist_entry *he, u64 min_callchain_hits)
+static void perf_session__insert_output_hist_entry(struct rb_root *root,
+                                                  struct hist_entry *he,
+                                                  u64 min_callchain_hits)
 {
-       struct rb_node **p = &output_hists.rb_node;
+       struct rb_node **p = &root->rb_node;
        struct rb_node *parent = NULL;
        struct hist_entry *iter;
 
-       if (callchain)
+       if (symbol_conf.use_callchain)
                callchain_param.sort(&he->sorted_chain, &he->callchain,
                                      min_callchain_hits, &callchain_param);
 
@@ -174,29 +180,483 @@ void output__insert_entry(struct hist_entry *he, u64 min_callchain_hits)
        }
 
        rb_link_node(&he->rb_node, parent, p);
-       rb_insert_color(&he->rb_node, &output_hists);
+       rb_insert_color(&he->rb_node, root);
 }
 
-void output__resort(u64 total_samples)
+void perf_session__output_resort(struct perf_session *self, u64 total_samples)
 {
+       struct rb_root tmp;
        struct rb_node *next;
        struct hist_entry *n;
-       struct rb_root *tree = &hist;
        u64 min_callchain_hits;
 
        min_callchain_hits =
                total_samples * (callchain_param.min_percent / 100);
 
-       if (sort__need_collapse)
-               tree = &collapse_hists;
-
-       next = rb_first(tree);
+       tmp = RB_ROOT;
+       next = rb_first(&self->hists);
 
        while (next) {
                n = rb_entry(next, struct hist_entry, rb_node);
                next = rb_next(&n->rb_node);
 
-               rb_erase(&n->rb_node, tree);
-               output__insert_entry(n, min_callchain_hits);
+               rb_erase(&n->rb_node, &self->hists);
+               perf_session__insert_output_hist_entry(&tmp, n,
+                                                      min_callchain_hits);
+       }
+
+       self->hists = tmp;
+}
+
+static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
+{
+       int i;
+       int ret = fprintf(fp, "            ");
+
+       for (i = 0; i < left_margin; i++)
+               ret += fprintf(fp, " ");
+
+       return ret;
+}
+
+static size_t ipchain__fprintf_graph_line(FILE *fp, int depth, int depth_mask,
+                                         int left_margin)
+{
+       int i;
+       size_t ret = callchain__fprintf_left_margin(fp, left_margin);
+
+       for (i = 0; i < depth; i++)
+               if (depth_mask & (1 << i))
+                       ret += fprintf(fp, "|          ");
+               else
+                       ret += fprintf(fp, "           ");
+
+       ret += fprintf(fp, "\n");
+
+       return ret;
+}
+
+static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain,
+                                    int depth, int depth_mask, int count,
+                                    u64 total_samples, int hits,
+                                    int left_margin)
+{
+       int i;
+       size_t ret = 0;
+
+       ret += callchain__fprintf_left_margin(fp, left_margin);
+       for (i = 0; i < depth; i++) {
+               if (depth_mask & (1 << i))
+                       ret += fprintf(fp, "|");
+               else
+                       ret += fprintf(fp, " ");
+               if (!count && i == depth - 1) {
+                       double percent;
+
+                       percent = hits * 100.0 / total_samples;
+                       ret += percent_color_fprintf(fp, "--%2.2f%%-- ", percent);
+               } else
+                       ret += fprintf(fp, "%s", "          ");
+       }
+       if (chain->sym)
+               ret += fprintf(fp, "%s\n", chain->sym->name);
+       else
+               ret += fprintf(fp, "%p\n", (void *)(long)chain->ip);
+
+       return ret;
+}
+
+static struct symbol *rem_sq_bracket;
+static struct callchain_list rem_hits;
+
+static void init_rem_hits(void)
+{
+       rem_sq_bracket = malloc(sizeof(*rem_sq_bracket) + 6);
+       if (!rem_sq_bracket) {
+               fprintf(stderr, "Not enough memory to display remaining hits\n");
+               return;
+       }
+
+       strcpy(rem_sq_bracket->name, "[...]");
+       rem_hits.sym = rem_sq_bracket;
+}
+
+static size_t __callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
+                                        u64 total_samples, int depth,
+                                        int depth_mask, int left_margin)
+{
+       struct rb_node *node, *next;
+       struct callchain_node *child;
+       struct callchain_list *chain;
+       int new_depth_mask = depth_mask;
+       u64 new_total;
+       u64 remaining;
+       size_t ret = 0;
+       int i;
+
+       if (callchain_param.mode == CHAIN_GRAPH_REL)
+               new_total = self->children_hit;
+       else
+               new_total = total_samples;
+
+       remaining = new_total;
+
+       node = rb_first(&self->rb_root);
+       while (node) {
+               u64 cumul;
+
+               child = rb_entry(node, struct callchain_node, rb_node);
+               cumul = cumul_hits(child);
+               remaining -= cumul;
+
+               /*
+                * The depth mask manages the output of pipes that show
+                * the depth. We don't want to keep the pipes of the current
+                * level for the last child of this depth.
+                * Except if we have remaining filtered hits. They will
+                * supersede the last child
+                */
+               next = rb_next(node);
+               if (!next && (callchain_param.mode != CHAIN_GRAPH_REL || !remaining))
+                       new_depth_mask &= ~(1 << (depth - 1));
+
+               /*
+                * But we keep the older depth mask for the line seperator
+                * to keep the level link until we reach the last child
+                */
+               ret += ipchain__fprintf_graph_line(fp, depth, depth_mask,
+                                                  left_margin);
+               i = 0;
+               list_for_each_entry(chain, &child->val, list) {
+                       if (chain->ip >= PERF_CONTEXT_MAX)
+                               continue;
+                       ret += ipchain__fprintf_graph(fp, chain, depth,
+                                                     new_depth_mask, i++,
+                                                     new_total,
+                                                     cumul,
+                                                     left_margin);
+               }
+               ret += __callchain__fprintf_graph(fp, child, new_total,
+                                                 depth + 1,
+                                                 new_depth_mask | (1 << depth),
+                                                 left_margin);
+               node = next;
+       }
+
+       if (callchain_param.mode == CHAIN_GRAPH_REL &&
+               remaining && remaining != new_total) {
+
+               if (!rem_sq_bracket)
+                       return ret;
+
+               new_depth_mask &= ~(1 << (depth - 1));
+
+               ret += ipchain__fprintf_graph(fp, &rem_hits, depth,
+                                             new_depth_mask, 0, new_total,
+                                             remaining, left_margin);
+       }
+
+       return ret;
+}
+
+static size_t callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
+                                      u64 total_samples, int left_margin)
+{
+       struct callchain_list *chain;
+       bool printed = false;
+       int i = 0;
+       int ret = 0;
+
+       list_for_each_entry(chain, &self->val, list) {
+               if (chain->ip >= PERF_CONTEXT_MAX)
+                       continue;
+
+               if (!i++ && sort__first_dimension == SORT_SYM)
+                       continue;
+
+               if (!printed) {
+                       ret += callchain__fprintf_left_margin(fp, left_margin);
+                       ret += fprintf(fp, "|\n");
+                       ret += callchain__fprintf_left_margin(fp, left_margin);
+                       ret += fprintf(fp, "---");
+
+                       left_margin += 3;
+                       printed = true;
+               } else
+                       ret += callchain__fprintf_left_margin(fp, left_margin);
+
+               if (chain->sym)
+                       ret += fprintf(fp, " %s\n", chain->sym->name);
+               else
+                       ret += fprintf(fp, " %p\n", (void *)(long)chain->ip);
+       }
+
+       ret += __callchain__fprintf_graph(fp, self, total_samples, 1, 1, left_margin);
+
+       return ret;
+}
+
+static size_t callchain__fprintf_flat(FILE *fp, struct callchain_node *self,
+                                     u64 total_samples)
+{
+       struct callchain_list *chain;
+       size_t ret = 0;
+
+       if (!self)
+               return 0;
+
+       ret += callchain__fprintf_flat(fp, self->parent, total_samples);
+
+
+       list_for_each_entry(chain, &self->val, list) {
+               if (chain->ip >= PERF_CONTEXT_MAX)
+                       continue;
+               if (chain->sym)
+                       ret += fprintf(fp, "                %s\n", chain->sym->name);
+               else
+                       ret += fprintf(fp, "                %p\n",
+                                       (void *)(long)chain->ip);
+       }
+
+       return ret;
+}
+
+static size_t hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self,
+                                           u64 total_samples, int left_margin)
+{
+       struct rb_node *rb_node;
+       struct callchain_node *chain;
+       size_t ret = 0;
+
+       rb_node = rb_first(&self->sorted_chain);
+       while (rb_node) {
+               double percent;
+
+               chain = rb_entry(rb_node, struct callchain_node, rb_node);
+               percent = chain->hit * 100.0 / total_samples;
+               switch (callchain_param.mode) {
+               case CHAIN_FLAT:
+                       ret += percent_color_fprintf(fp, "           %6.2f%%\n",
+                                                    percent);
+                       ret += callchain__fprintf_flat(fp, chain, total_samples);
+                       break;
+               case CHAIN_GRAPH_ABS: /* Falldown */
+               case CHAIN_GRAPH_REL:
+                       ret += callchain__fprintf_graph(fp, chain, total_samples,
+                                                       left_margin);
+               case CHAIN_NONE:
+               default:
+                       break;
+               }
+               ret += fprintf(fp, "\n");
+               rb_node = rb_next(rb_node);
+       }
+
+       return ret;
+}
+
+static size_t hist_entry__fprintf(struct hist_entry *self,
+                                 struct perf_session *session,
+                                 struct perf_session *pair_session,
+                                 bool show_displacement,
+                                 long displacement, FILE *fp)
+{
+       struct sort_entry *se;
+       u64 count, total;
+       const char *sep = symbol_conf.field_sep;
+       size_t ret;
+
+       if (symbol_conf.exclude_other && !self->parent)
+               return 0;
+
+       if (pair_session) {
+               count = self->pair ? self->pair->count : 0;
+               total = pair_session->events_stats.total;
+       } else {
+               count = self->count;
+               total = session->events_stats.total;
+       }
+
+       if (total)
+               ret = percent_color_fprintf(fp, sep ? "%.2f" : "   %6.2f%%",
+                                           (count * 100.0) / total);
+       else
+               ret = fprintf(fp, sep ? "%lld" : "%12lld ", count);
+
+       if (symbol_conf.show_nr_samples) {
+               if (sep)
+                       fprintf(fp, "%c%lld", *sep, count);
+               else
+                       fprintf(fp, "%11lld", count);
+       }
+
+       if (pair_session) {
+               char bf[32];
+               double old_percent = 0, new_percent = 0, diff;
+
+               if (total > 0)
+                       old_percent = (count * 100.0) / total;
+               if (session->events_stats.total > 0)
+                       new_percent = (self->count * 100.0) / session->events_stats.total;
+
+               diff = new_percent - old_percent;
+
+               if (fabs(diff) >= 0.01)
+                       snprintf(bf, sizeof(bf), "%+4.2F%%", diff);
+               else
+                       snprintf(bf, sizeof(bf), " ");
+
+               if (sep)
+                       ret += fprintf(fp, "%c%s", *sep, bf);
+               else
+                       ret += fprintf(fp, "%11.11s", bf);
+
+               if (show_displacement) {
+                       if (displacement)
+                               snprintf(bf, sizeof(bf), "%+4ld", displacement);
+                       else
+                               snprintf(bf, sizeof(bf), " ");
+
+                       if (sep)
+                               fprintf(fp, "%c%s", *sep, bf);
+                       else
+                               fprintf(fp, "%6.6s", bf);
+               }
+       }
+
+       list_for_each_entry(se, &hist_entry__sort_list, list) {
+               if (se->elide)
+                       continue;
+
+               fprintf(fp, "%s", sep ?: "  ");
+               ret += se->print(fp, self, se->width ? *se->width : 0);
+       }
+
+       ret += fprintf(fp, "\n");
+
+       if (symbol_conf.use_callchain) {
+               int left_margin = 0;
+
+               if (sort__first_dimension == SORT_COMM) {
+                       se = list_first_entry(&hist_entry__sort_list, typeof(*se),
+                                               list);
+                       left_margin = se->width ? *se->width : 0;
+                       left_margin -= thread__comm_len(self->thread);
+               }
+
+               hist_entry_callchain__fprintf(fp, self, session->events_stats.total,
+                                             left_margin);
+       }
+
+       return ret;
+}
+
+size_t perf_session__fprintf_hists(struct perf_session *self,
+                                  struct perf_session *pair,
+                                  bool show_displacement, FILE *fp)
+{
+       struct sort_entry *se;
+       struct rb_node *nd;
+       size_t ret = 0;
+       unsigned long position = 1;
+       long displacement = 0;
+       unsigned int width;
+       const char *sep = symbol_conf.field_sep;
+       char *col_width = symbol_conf.col_width_list_str;
+
+       init_rem_hits();
+
+       fprintf(fp, "# %s", pair ? "Baseline" : "Overhead");
+
+       if (symbol_conf.show_nr_samples) {
+               if (sep)
+                       fprintf(fp, "%cSamples", *sep);
+               else
+                       fputs("  Samples  ", fp);
+       }
+
+       if (pair) {
+               if (sep)
+                       ret += fprintf(fp, "%cDelta", *sep);
+               else
+                       ret += fprintf(fp, "  Delta    ");
+
+               if (show_displacement) {
+                       if (sep)
+                               ret += fprintf(fp, "%cDisplacement", *sep);
+                       else
+                               ret += fprintf(fp, " Displ");
+               }
+       }
+
+       list_for_each_entry(se, &hist_entry__sort_list, list) {
+               if (se->elide)
+                       continue;
+               if (sep) {
+                       fprintf(fp, "%c%s", *sep, se->header);
+                       continue;
+               }
+               width = strlen(se->header);
+               if (se->width) {
+                       if (symbol_conf.col_width_list_str) {
+                               if (col_width) {
+                                       *se->width = atoi(col_width);
+                                       col_width = strchr(col_width, ',');
+                                       if (col_width)
+                                               ++col_width;
+                               }
+                       }
+                       width = *se->width = max(*se->width, width);
+               }
+               fprintf(fp, "  %*s", width, se->header);
+       }
+       fprintf(fp, "\n");
+
+       if (sep)
+               goto print_entries;
+
+       fprintf(fp, "# ........");
+       if (symbol_conf.show_nr_samples)
+               fprintf(fp, " ..........");
+       if (pair) {
+               fprintf(fp, " ..........");
+               if (show_displacement)
+                       fprintf(fp, " .....");
+       }
+       list_for_each_entry(se, &hist_entry__sort_list, list) {
+               unsigned int i;
+
+               if (se->elide)
+                       continue;
+
+               fprintf(fp, "  ");
+               if (se->width)
+                       width = *se->width;
+               else
+                       width = strlen(se->header);
+               for (i = 0; i < width; i++)
+                       fprintf(fp, ".");
+       }
+
+       fprintf(fp, "\n#\n");
+
+print_entries:
+       for (nd = rb_first(&self->hists); nd; nd = rb_next(nd)) {
+               struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
+
+               if (show_displacement) {
+                       if (h->pair != NULL)
+                               displacement = ((long)h->pair->position -
+                                               (long)position);
+                       else
+                               displacement = 0;
+                       ++position;
+               }
+               ret += hist_entry__fprintf(h, self, pair, show_displacement,
+                                          displacement, fp);
        }
+
+       free(rem_sq_bracket);
+
+       return ret;
 }
index 3020db0c92927354168c129c63bbf5d474ca793f..e5f99b24048b4574e410f9ee8621e0a1638545ac 100644 (file)
@@ -1,50 +1,27 @@
 #ifndef __PERF_HIST_H
 #define __PERF_HIST_H
-#include "../builtin.h"
 
-#include "util.h"
-
-#include "color.h"
-#include <linux/list.h>
-#include "cache.h"
-#include <linux/rbtree.h>
-#include "symbol.h"
-#include "string.h"
+#include <linux/types.h>
 #include "callchain.h"
-#include "strlist.h"
-#include "values.h"
-
-#include "../perf.h"
-#include "debug.h"
-#include "header.h"
-
-#include "parse-options.h"
-#include "parse-events.h"
 
-#include "thread.h"
-#include "sort.h"
-
-extern struct rb_root hist;
-extern struct rb_root collapse_hists;
-extern struct rb_root output_hists;
-extern int callchain;
 extern struct callchain_param callchain_param;
-extern unsigned long total;
-extern unsigned long total_mmap;
-extern unsigned long total_comm;
-extern unsigned long total_fork;
-extern unsigned long total_unknown;
-extern unsigned long total_lost;
 
-struct hist_entry *__hist_entry__add(struct addr_location *al,
-                                    struct symbol *parent,
-                                    u64 count, bool *hit);
+struct perf_session;
+struct hist_entry;
+struct addr_location;
+struct symbol;
+
+struct hist_entry *__perf_session__add_hist_entry(struct perf_session *self,
+                                                 struct addr_location *al,
+                                                 struct symbol *parent,
+                                                 u64 count, bool *hit);
 extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);
 extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *);
-extern void hist_entry__free(struct hist_entry *);
-extern void collapse__insert_entry(struct hist_entry *);
-extern void collapse__resort(void);
-extern void output__insert_entry(struct hist_entry *, u64);
-extern void output__resort(u64);
+void hist_entry__free(struct hist_entry *);
 
+void perf_session__output_resort(struct perf_session *self, u64 total_samples);
+void perf_session__collapse_resort(struct perf_session *self);
+size_t perf_session__fprintf_hists(struct perf_session *self,
+                                  struct perf_session *pair,
+                                  bool show_displacement, FILE *fp);
 #endif /* __PERF_HIST_H */
index 76bdca640a9b5fcde2f7206f39940dc23e4750e8..c4d55a0da2eae66ff2ba31fe0fcfa9293604e50f 100644 (file)
@@ -104,11 +104,16 @@ void map__fixup_end(struct map *self)
 
 #define DSO__DELETED "(deleted)"
 
-static int map__load(struct map *self, symbol_filter_t filter)
+int map__load(struct map *self, struct perf_session *session,
+             symbol_filter_t filter)
 {
        const char *name = self->dso->long_name;
-       int nr = dso__load(self->dso, self, filter);
+       int nr;
 
+       if (dso__loaded(self->dso, self->type))
+               return 0;
+
+       nr = dso__load(self->dso, self, session, filter);
        if (nr < 0) {
                if (self->dso->has_build_id) {
                        char sbuild_id[BUILD_ID_SIZE * 2 + 1];
@@ -143,19 +148,20 @@ static int map__load(struct map *self, symbol_filter_t filter)
        return 0;
 }
 
-struct symbol *map__find_symbol(struct map *self, u64 addr,
-                               symbol_filter_t filter)
+struct symbol *map__find_symbol(struct map *self, struct perf_session *session,
+                               u64 addr, symbol_filter_t filter)
 {
-       if (!dso__loaded(self->dso, self->type) && map__load(self, filter) < 0)
+       if (map__load(self, session, filter) < 0)
                return NULL;
 
        return dso__find_symbol(self->dso, self->type, addr);
 }
 
 struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
+                                       struct perf_session *session,
                                        symbol_filter_t filter)
 {
-       if (!dso__loaded(self->dso, self->type) && map__load(self, filter) < 0)
+       if (map__load(self, session, filter) < 0)
                return NULL;
 
        if (!dso__sorted_by_name(self->dso, self->type))
index d14a4585bcafb53fd8a9f664ff50e32e8ca9f95b..29465d440043587462c61cb7dc3483bc68203b07 100644 (file)
@@ -62,6 +62,18 @@ static int e_snprintf(char *str, size_t size, const char *format, ...)
        return ret;
 }
 
+/* Check the name is good for event/group */
+static bool check_event_name(const char *name)
+{
+       if (!isalpha(*name) && *name != '_')
+               return false;
+       while (*++name != '\0') {
+               if (!isalpha(*name) && !isdigit(*name) && *name != '_')
+                       return false;
+       }
+       return true;
+}
+
 /* Parse probepoint definition. */
 static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
 {
@@ -69,10 +81,26 @@ static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
        char c, nc = 0;
        /*
         * <Syntax>
-        * perf probe SRC:LN
-        * perf probe FUNC[+OFFS|%return][@SRC]
+        * perf probe [EVENT=]SRC:LN
+        * perf probe [EVENT=]FUNC[+OFFS|%return][@SRC]
+        *
+        * TODO:Group name support
         */
 
+       ptr = strchr(arg, '=');
+       if (ptr) {      /* Event name */
+               *ptr = '\0';
+               tmp = ptr + 1;
+               ptr = strchr(arg, ':');
+               if (ptr)        /* Group name is not supported yet. */
+                       semantic_error("Group name is not supported yet.");
+               if (!check_event_name(arg))
+                       semantic_error("%s is bad for event name -it must "
+                                      "follow C symbol-naming rule.", arg);
+               pp->event = strdup(arg);
+               arg = tmp;
+       }
+
        ptr = strpbrk(arg, ":+@%");
        if (ptr) {
                nc = *ptr;
@@ -150,10 +178,13 @@ static void parse_perf_probe_probepoint(char *arg, struct probe_point *pp)
 }
 
 /* Parse perf-probe event definition */
-int parse_perf_probe_event(const char *str, struct probe_point *pp)
+void parse_perf_probe_event(const char *str, struct probe_point *pp,
+                           bool *need_dwarf)
 {
        char **argv;
-       int argc, i, need_dwarf = 0;
+       int argc, i;
+
+       *need_dwarf = false;
 
        argv = argv_split(str, &argc);
        if (!argv)
@@ -164,7 +195,7 @@ int parse_perf_probe_event(const char *str, struct probe_point *pp)
        /* Parse probe point */
        parse_perf_probe_probepoint(argv[0], pp);
        if (pp->file || pp->line)
-               need_dwarf = 1;
+               *need_dwarf = true;
 
        /* Copy arguments and ensure return probe has no C argument */
        pp->nr_args = argc - 1;
@@ -177,17 +208,15 @@ int parse_perf_probe_event(const char *str, struct probe_point *pp)
                        if (pp->retprobe)
                                semantic_error("You can't specify local"
                                                " variable for kretprobe");
-                       need_dwarf = 1;
+                       *need_dwarf = true;
                }
        }
 
        argv_free(argv);
-       return need_dwarf;
 }
 
 /* Parse kprobe_events event into struct probe_point */
-void parse_trace_kprobe_event(const char *str, char **group, char **event,
-                             struct probe_point *pp)
+void parse_trace_kprobe_event(const char *str, struct probe_point *pp)
 {
        char pr;
        char *p;
@@ -203,18 +232,17 @@ void parse_trace_kprobe_event(const char *str, char **group, char **event,
 
        /* Scan event and group name. */
        ret = sscanf(argv[0], "%c:%a[^/ \t]/%a[^ \t]",
-                    &pr, (float *)(void *)group, (float *)(void *)event);
+                    &pr, (float *)(void *)&pp->group,
+                    (float *)(void *)&pp->event);
        if (ret != 3)
                semantic_error("Failed to parse event name: %s", argv[0]);
-       pr_debug("Group:%s Event:%s probe:%c\n", *group, *event, pr);
-
-       if (!pp)
-               goto end;
+       pr_debug("Group:%s Event:%s probe:%c\n", pp->group, pp->event, pr);
 
        pp->retprobe = (pr == 'r');
 
        /* Scan function name and offset */
-       ret = sscanf(argv[1], "%a[^+]+%d", (float *)(void *)&pp->function, &pp->offset);
+       ret = sscanf(argv[1], "%a[^+]+%d", (float *)(void *)&pp->function,
+                    &pp->offset);
        if (ret == 1)
                pp->offset = 0;
 
@@ -233,15 +261,15 @@ void parse_trace_kprobe_event(const char *str, char **group, char **event,
                        die("Failed to copy argument.");
        }
 
-end:
        argv_free(argv);
 }
 
-int synthesize_perf_probe_event(struct probe_point *pp)
+/* Synthesize only probe point (not argument) */
+int synthesize_perf_probe_point(struct probe_point *pp)
 {
        char *buf;
        char offs[64] = "", line[64] = "";
-       int i, len, ret;
+       int ret;
 
        pp->probes[0] = buf = zalloc(MAX_CMDLEN);
        if (!buf)
@@ -262,10 +290,24 @@ int synthesize_perf_probe_event(struct probe_point *pp)
                                 offs, pp->retprobe ? "%return" : "", line);
        else
                ret = e_snprintf(buf, MAX_CMDLEN, "%s%s", pp->file, line);
-       if (ret <= 0)
-               goto error;
-       len = ret;
+       if (ret <= 0) {
+error:
+               free(pp->probes[0]);
+               pp->probes[0] = NULL;
+       }
+       return ret;
+}
+
+int synthesize_perf_probe_event(struct probe_point *pp)
+{
+       char *buf;
+       int i, len, ret;
+
+       len = synthesize_perf_probe_point(pp);
+       if (len < 0)
+               return 0;
 
+       buf = pp->probes[0];
        for (i = 0; i < pp->nr_args; i++) {
                ret = e_snprintf(&buf[len], MAX_CMDLEN - len, " %s",
                                 pp->args[i]);
@@ -278,6 +320,7 @@ int synthesize_perf_probe_event(struct probe_point *pp)
        return pp->found;
 error:
        free(pp->probes[0]);
+       pp->probes[0] = NULL;
 
        return ret;
 }
@@ -307,6 +350,7 @@ int synthesize_trace_kprobe_event(struct probe_point *pp)
        return pp->found;
 error:
        free(pp->probes[0]);
+       pp->probes[0] = NULL;
 
        return ret;
 }
@@ -366,6 +410,10 @@ static void clear_probe_point(struct probe_point *pp)
 {
        int i;
 
+       if (pp->event)
+               free(pp->event);
+       if (pp->group)
+               free(pp->group);
        if (pp->function)
                free(pp->function);
        if (pp->file)
@@ -380,13 +428,15 @@ static void clear_probe_point(struct probe_point *pp)
 }
 
 /* Show an event */
-static void show_perf_probe_event(const char *group, const char *event,
-                                 const char *place, struct probe_point *pp)
+static void show_perf_probe_event(const char *event, const char *place,
+                                 struct probe_point *pp)
 {
-       int i;
+       int i, ret;
        char buf[128];
 
-       e_snprintf(buf, 128, "%s:%s", group, event);
+       ret = e_snprintf(buf, 128, "%s:%s", pp->group, event);
+       if (ret < 0)
+               die("Failed to copy event: %s", strerror(-ret));
        printf("  %-40s (on %s", buf, place);
 
        if (pp->nr_args > 0) {
@@ -400,9 +450,7 @@ static void show_perf_probe_event(const char *group, const char *event,
 /* List up current perf-probe events */
 void show_perf_probe_events(void)
 {
-       unsigned int i;
-       int fd, nr;
-       char *group, *event;
+       int fd;
        struct probe_point pp;
        struct strlist *rawlist;
        struct str_node *ent;
@@ -411,18 +459,12 @@ void show_perf_probe_events(void)
        rawlist = get_trace_kprobe_event_rawlist(fd);
        close(fd);
 
-       for (i = 0; i < strlist__nr_entries(rawlist); i++) {
-               ent = strlist__entry(rawlist, i);
-               parse_trace_kprobe_event(ent->s, &group, &event, &pp);
+       strlist__for_each(ent, rawlist) {
+               parse_trace_kprobe_event(ent->s, &pp);
                /* Synthesize only event probe point */
-               nr = pp.nr_args;
-               pp.nr_args = 0;
-               synthesize_perf_probe_event(&pp);
-               pp.nr_args = nr;
+               synthesize_perf_probe_point(&pp);
                /* Show an event */
-               show_perf_probe_event(group, event, pp.probes[0], &pp);
-               free(group);
-               free(event);
+               show_perf_probe_event(pp.event, pp.probes[0], &pp);
                clear_probe_point(&pp);
        }
 
@@ -432,26 +474,25 @@ void show_perf_probe_events(void)
 /* Get current perf-probe event names */
 static struct strlist *get_perf_event_names(int fd, bool include_group)
 {
-       unsigned int i;
-       char *group, *event;
        char buf[128];
        struct strlist *sl, *rawlist;
        struct str_node *ent;
+       struct probe_point pp;
 
+       memset(&pp, 0, sizeof(pp));
        rawlist = get_trace_kprobe_event_rawlist(fd);
 
        sl = strlist__new(true, NULL);
-       for (i = 0; i < strlist__nr_entries(rawlist); i++) {
-               ent = strlist__entry(rawlist, i);
-               parse_trace_kprobe_event(ent->s, &group, &event, NULL);
+       strlist__for_each(ent, rawlist) {
+               parse_trace_kprobe_event(ent->s, &pp);
                if (include_group) {
-                       if (e_snprintf(buf, 128, "%s:%s", group, event) < 0)
+                       if (e_snprintf(buf, 128, "%s:%s", pp.group,
+                                      pp.event) < 0)
                                die("Failed to copy group:event name.");
                        strlist__add(sl, buf);
                } else
-                       strlist__add(sl, event);
-               free(group);
-               free(event);
+                       strlist__add(sl, pp.event);
+               clear_probe_point(&pp);
        }
 
        strlist__delete(rawlist);
@@ -470,7 +511,7 @@ static void write_trace_kprobe_event(int fd, const char *buf)
 }
 
 static void get_new_event_name(char *buf, size_t len, const char *base,
-                              struct strlist *namelist)
+                              struct strlist *namelist, bool allow_suffix)
 {
        int i, ret;
 
@@ -481,6 +522,12 @@ static void get_new_event_name(char *buf, size_t len, const char *base,
        if (!strlist__has_entry(namelist, buf))
                return;
 
+       if (!allow_suffix) {
+               pr_warning("Error: event \"%s\" already exists. "
+                          "(Use -f to force duplicates.)\n", base);
+               die("Can't add new event.");
+       }
+
        /* Try to add suffix */
        for (i = 1; i < MAX_EVENT_INDEX; i++) {
                ret = e_snprintf(buf, len, "%s_%d", base, i);
@@ -493,13 +540,15 @@ static void get_new_event_name(char *buf, size_t len, const char *base,
                die("Too many events are on the same function.");
 }
 
-void add_trace_kprobe_events(struct probe_point *probes, int nr_probes)
+void add_trace_kprobe_events(struct probe_point *probes, int nr_probes,
+                            bool force_add)
 {
        int i, j, fd;
        struct probe_point *pp;
        char buf[MAX_CMDLEN];
        char event[64];
        struct strlist *namelist;
+       bool allow_suffix;
 
        fd = open_kprobe_events(O_RDWR, O_APPEND);
        /* Get current event names */
@@ -507,21 +556,35 @@ void add_trace_kprobe_events(struct probe_point *probes, int nr_probes)
 
        for (j = 0; j < nr_probes; j++) {
                pp = probes + j;
+               if (!pp->event)
+                       pp->event = strdup(pp->function);
+               if (!pp->group)
+                       pp->group = strdup(PERFPROBE_GROUP);
+               DIE_IF(!pp->event || !pp->group);
+               /* If force_add is true, suffix search is allowed */
+               allow_suffix = force_add;
                for (i = 0; i < pp->found; i++) {
                        /* Get an unused new event name */
-                       get_new_event_name(event, 64, pp->function, namelist);
+                       get_new_event_name(event, 64, pp->event, namelist,
+                                          allow_suffix);
                        snprintf(buf, MAX_CMDLEN, "%c:%s/%s %s\n",
                                 pp->retprobe ? 'r' : 'p',
-                                PERFPROBE_GROUP, event,
+                                pp->group, event,
                                 pp->probes[i]);
                        write_trace_kprobe_event(fd, buf);
                        printf("Added new event:\n");
                        /* Get the first parameter (probe-point) */
                        sscanf(pp->probes[i], "%s", buf);
-                       show_perf_probe_event(PERFPROBE_GROUP, event,
-                                             buf, pp);
+                       show_perf_probe_event(event, buf, pp);
                        /* Add added event name to namelist */
                        strlist__add(namelist, event);
+                       /*
+                        * Probes after the first probe which comes from same
+                        * user input are always allowed to add suffix, because
+                        * there might be several addresses corresponding to
+                        * one code line.
+                        */
+                       allow_suffix = true;
                }
        }
        /* Show how to use the event. */
@@ -532,29 +595,55 @@ void add_trace_kprobe_events(struct probe_point *probes, int nr_probes)
        close(fd);
 }
 
+static void __del_trace_kprobe_event(int fd, struct str_node *ent)
+{
+       char *p;
+       char buf[128];
+
+       /* Convert from perf-probe event to trace-kprobe event */
+       if (e_snprintf(buf, 128, "-:%s", ent->s) < 0)
+               die("Failed to copy event.");
+       p = strchr(buf + 2, ':');
+       if (!p)
+               die("Internal error: %s should have ':' but not.", ent->s);
+       *p = '/';
+
+       write_trace_kprobe_event(fd, buf);
+       printf("Remove event: %s\n", ent->s);
+}
+
 static void del_trace_kprobe_event(int fd, const char *group,
                                   const char *event, struct strlist *namelist)
 {
        char buf[128];
+       struct str_node *ent, *n;
+       int found = 0;
 
        if (e_snprintf(buf, 128, "%s:%s", group, event) < 0)
                die("Failed to copy event.");
-       if (!strlist__has_entry(namelist, buf)) {
-               pr_warning("Warning: event \"%s\" is not found.\n", buf);
-               return;
-       }
-       /* Convert from perf-probe event to trace-kprobe event */
-       if (e_snprintf(buf, 128, "-:%s/%s", group, event) < 0)
-               die("Failed to copy event.");
 
-       write_trace_kprobe_event(fd, buf);
-       printf("Remove event: %s:%s\n", group, event);
+       if (strpbrk(buf, "*?")) { /* Glob-exp */
+               strlist__for_each_safe(ent, n, namelist)
+                       if (strglobmatch(ent->s, buf)) {
+                               found++;
+                               __del_trace_kprobe_event(fd, ent);
+                               strlist__remove(namelist, ent);
+                       }
+       } else {
+               ent = strlist__find(namelist, buf);
+               if (ent) {
+                       found++;
+                       __del_trace_kprobe_event(fd, ent);
+                       strlist__remove(namelist, ent);
+               }
+       }
+       if (found == 0)
+               pr_info("Info: event \"%s\" does not exist, could not remove it.\n", buf);
 }
 
 void del_trace_kprobe_events(struct strlist *dellist)
 {
        int fd;
-       unsigned int i;
        const char *group, *event;
        char *p, *str;
        struct str_node *ent;
@@ -564,20 +653,21 @@ void del_trace_kprobe_events(struct strlist *dellist)
        /* Get current event names */
        namelist = get_perf_event_names(fd, true);
 
-       for (i = 0; i < strlist__nr_entries(dellist); i++) {
-               ent = strlist__entry(dellist, i);
+       strlist__for_each(ent, dellist) {
                str = strdup(ent->s);
                if (!str)
                        die("Failed to copy event.");
+               pr_debug("Parsing: %s\n", str);
                p = strchr(str, ':');
                if (p) {
                        group = str;
                        *p = '\0';
                        event = p + 1;
                } else {
-                       group = PERFPROBE_GROUP;
+                       group = "*";
                        event = str;
                }
+               pr_debug("Group: %s, Event: %s\n", group, event);
                del_trace_kprobe_event(fd, group, event, namelist);
                free(str);
        }
index f752159124aef11a6a092e7afe497c5c2b6400af..7f1d499118c0d421920e97c5b4e1ebda06cfdd3e 100644 (file)
@@ -1,15 +1,18 @@
 #ifndef _PROBE_EVENT_H
 #define _PROBE_EVENT_H
 
+#include <stdbool.h>
 #include "probe-finder.h"
 #include "strlist.h"
 
-extern int parse_perf_probe_event(const char *str, struct probe_point *pp);
+extern void parse_perf_probe_event(const char *str, struct probe_point *pp,
+                                  bool *need_dwarf);
+extern int synthesize_perf_probe_point(struct probe_point *pp);
 extern int synthesize_perf_probe_event(struct probe_point *pp);
-extern void parse_trace_kprobe_event(const char *str, char **group,
-                                    char **event, struct probe_point *pp);
+extern void parse_trace_kprobe_event(const char *str, struct probe_point *pp);
 extern int synthesize_trace_kprobe_event(struct probe_point *pp);
-extern void add_trace_kprobe_events(struct probe_point *probes, int nr_probes);
+extern void add_trace_kprobe_events(struct probe_point *probes, int nr_probes,
+                                   bool force_add);
 extern void del_trace_kprobe_events(struct strlist *dellist);
 extern void show_perf_probe_events(void);
 
index 4585f1d867927db60d5ec9ad5abc1744ef871175..4b852c0d16a5b24a37589b2dd8a2f52f40c28169 100644 (file)
@@ -687,10 +687,8 @@ int find_probepoint(int fd, struct probe_point *pp)
        struct probe_finder pf = {.pp = pp};
 
        ret = dwarf_init(fd, DW_DLC_READ, 0, 0, &__dw_debug, &__dw_error);
-       if (ret != DW_DLV_OK) {
-               pr_warning("No dwarf info found in the vmlinux - please rebuild with CONFIG_DEBUG_INFO.\n");
+       if (ret != DW_DLV_OK)
                return -ENOENT;
-       }
 
        pp->found = 0;
        while (++cu_number) {
index bdebca6697d24a637f583295779f3c2697f8b319..a4086aaddb73da2458047d13209a897e7faec172 100644 (file)
@@ -1,9 +1,9 @@
 #ifndef _PROBE_FINDER_H
 #define _PROBE_FINDER_H
 
-#define MAX_PATH_LEN 256
-#define MAX_PROBE_BUFFER 1024
-#define MAX_PROBES 128
+#define MAX_PATH_LEN            256
+#define MAX_PROBE_BUFFER       1024
+#define MAX_PROBES              128
 
 static inline int is_c_varname(const char *name)
 {
@@ -12,45 +12,53 @@ static inline int is_c_varname(const char *name)
 }
 
 struct probe_point {
+       char                    *event;                 /* Event name */
+       char                    *group;                 /* Event group */
+
        /* Inputs */
-       char    *file;          /* File name */
-       int     line;           /* Line number */
+       char                    *file;                  /* File name */
+       int                     line;                   /* Line number */
 
-       char    *function;      /* Function name */
-       int     offset;         /* Offset bytes */
+       char                    *function;              /* Function name */
+       int                     offset;                 /* Offset bytes */
 
-       int     nr_args;        /* Number of arguments */
-       char    **args;         /* Arguments */
+       int                     nr_args;                /* Number of arguments */
+       char                    **args;                 /* Arguments */
 
-       int     retprobe;       /* Return probe */
+       int                     retprobe;               /* Return probe */
 
        /* Output */
-       int     found;          /* Number of found probe points */
-       char    *probes[MAX_PROBES];    /* Output buffers (will be allocated)*/
+       int                     found;                  /* Number of found probe points */
+       char                    *probes[MAX_PROBES];    /* Output buffers (will be allocated)*/
 };
 
 #ifndef NO_LIBDWARF
 extern int find_probepoint(int fd, struct probe_point *pp);
 
-#include <libdwarf/dwarf.h>
-#include <libdwarf/libdwarf.h>
+/* Workaround for undefined _MIPS_SZLONG bug in libdwarf.h: */
+#ifndef _MIPS_SZLONG
+# define _MIPS_SZLONG          0
+#endif
+
+#include <dwarf.h>
+#include <libdwarf.h>
 
 struct probe_finder {
-       struct probe_point      *pp;    /* Target probe point */
+       struct probe_point      *pp;                    /* Target probe point */
 
        /* For function searching */
-       Dwarf_Addr      addr;           /* Address */
-       Dwarf_Unsigned  fno;            /* File number */
-       Dwarf_Unsigned  lno;            /* Line number */
-       Dwarf_Off       inl_offs;       /* Inline offset */
-       Dwarf_Die       cu_die;         /* Current CU */
+       Dwarf_Addr              addr;                   /* Address */
+       Dwarf_Unsigned          fno;                    /* File number */
+       Dwarf_Unsigned          lno;                    /* Line number */
+       Dwarf_Off               inl_offs;               /* Inline offset */
+       Dwarf_Die               cu_die;                 /* Current CU */
 
        /* For variable searching */
-       Dwarf_Addr      cu_base;        /* Current CU base address */
-       Dwarf_Locdesc   fbloc;          /* Location of Current Frame Base */
-       const char      *var;           /* Current variable name */
-       char            *buf;           /* Current output buffer */
-       int             len;            /* Length of output buffer */
+       Dwarf_Addr              cu_base;                /* Current CU base address */
+       Dwarf_Locdesc           fbloc;                  /* Location of Current Frame Base */
+       const char              *var;                   /* Current variable name */
+       char                    *buf;                   /* Current output buffer */
+       int                     len;                    /* Length of output buffer */
 };
 #endif /* NO_LIBDWARF */
 
index 707ce1cb1621b3710ac26c16876479bbb086edab..ce3a6c8abe76c93fd5791aa295ef338f83db69ae 100644 (file)
@@ -4,6 +4,7 @@
 #include <sys/types.h>
 
 #include "session.h"
+#include "sort.h"
 #include "util.h"
 
 static int perf_session__open(struct perf_session *self, bool force)
@@ -50,31 +51,100 @@ out_close:
 
 struct perf_session *perf_session__new(const char *filename, int mode, bool force)
 {
-       size_t len = strlen(filename) + 1;
+       size_t len = filename ? strlen(filename) + 1 : 0;
        struct perf_session *self = zalloc(sizeof(*self) + len);
 
        if (self == NULL)
                goto out;
 
        if (perf_header__init(&self->header) < 0)
-               goto out_delete;
+               goto out_free;
 
        memcpy(self->filename, filename, len);
+       self->threads = RB_ROOT;
+       self->last_match = NULL;
+       self->mmap_window = 32;
+       self->cwd = NULL;
+       self->cwdlen = 0;
+       map_groups__init(&self->kmaps);
+
+       if (perf_session__create_kernel_maps(self) < 0)
+               goto out_delete;
 
-       if (mode == O_RDONLY && perf_session__open(self, force) < 0) {
-               perf_session__delete(self);
-               self = NULL;
-       }
+       if (mode == O_RDONLY && perf_session__open(self, force) < 0)
+               goto out_delete;
 out:
        return self;
-out_delete:
+out_free:
        free(self);
        return NULL;
+out_delete:
+       perf_session__delete(self);
+       return NULL;
 }
 
 void perf_session__delete(struct perf_session *self)
 {
        perf_header__exit(&self->header);
        close(self->fd);
+       free(self->cwd);
        free(self);
 }
+
+static bool symbol__match_parent_regex(struct symbol *sym)
+{
+       if (sym->name && !regexec(&parent_regex, sym->name, 0, NULL, 0))
+               return 1;
+
+       return 0;
+}
+
+struct symbol **perf_session__resolve_callchain(struct perf_session *self,
+                                               struct thread *thread,
+                                               struct ip_callchain *chain,
+                                               struct symbol **parent)
+{
+       u8 cpumode = PERF_RECORD_MISC_USER;
+       struct symbol **syms = NULL;
+       unsigned int i;
+
+       if (symbol_conf.use_callchain) {
+               syms = calloc(chain->nr, sizeof(*syms));
+               if (!syms) {
+                       fprintf(stderr, "Can't allocate memory for symbols\n");
+                       exit(-1);
+               }
+       }
+
+       for (i = 0; i < chain->nr; i++) {
+               u64 ip = chain->ips[i];
+               struct addr_location al;
+
+               if (ip >= PERF_CONTEXT_MAX) {
+                       switch (ip) {
+                       case PERF_CONTEXT_HV:
+                               cpumode = PERF_RECORD_MISC_HYPERVISOR;  break;
+                       case PERF_CONTEXT_KERNEL:
+                               cpumode = PERF_RECORD_MISC_KERNEL;      break;
+                       case PERF_CONTEXT_USER:
+                               cpumode = PERF_RECORD_MISC_USER;        break;
+                       default:
+                               break;
+                       }
+                       continue;
+               }
+
+               thread__find_addr_location(thread, self, cpumode,
+                                          MAP__FUNCTION, ip, &al, NULL);
+               if (al.sym != NULL) {
+                       if (sort__has_parent && !*parent &&
+                           symbol__match_parent_regex(al.sym))
+                               *parent = al.sym;
+                       if (!symbol_conf.use_callchain)
+                               break;
+                       syms[i] = al.sym;
+               }
+       }
+
+       return syms;
+}
index f3699c8c8ed4da77e3e1a87a058dcd20049eebe2..32eaa1bada062a108ddaebed928489b5bf3d5da6 100644 (file)
@@ -1,16 +1,61 @@
 #ifndef __PERF_SESSION_H
 #define __PERF_SESSION_H
 
+#include "event.h"
 #include "header.h"
+#include "thread.h"
+#include <linux/rbtree.h>
+#include "../../../include/linux/perf_event.h"
+
+struct ip_callchain;
+struct thread;
+struct symbol;
 
 struct perf_session {
        struct perf_header      header;
        unsigned long           size;
+       unsigned long           mmap_window;
+       struct map_groups       kmaps;
+       struct rb_root          threads;
+       struct thread           *last_match;
+       struct events_stats     events_stats;
+       unsigned long           event_total[PERF_RECORD_MAX];
+       struct rb_root          hists;
+       u64                     sample_type;
        int                     fd;
+       int                     cwdlen;
+       char                    *cwd;
        char filename[0];
 };
 
+typedef int (*event_op)(event_t *self, struct perf_session *session);
+
+struct perf_event_ops {
+       event_op        process_sample_event;
+       event_op        process_mmap_event;
+       event_op        process_comm_event;
+       event_op        process_fork_event;
+       event_op        process_exit_event;
+       event_op        process_lost_event;
+       event_op        process_read_event;
+       event_op        process_throttle_event;
+       event_op        process_unthrottle_event;
+       int             (*sample_type_check)(struct perf_session *session);
+       unsigned long   total_unknown;
+       bool            full_paths;
+};
+
 struct perf_session *perf_session__new(const char *filename, int mode, bool force);
 void perf_session__delete(struct perf_session *self);
 
+int perf_session__process_events(struct perf_session *self,
+                                struct perf_event_ops *event_ops);
+
+struct symbol **perf_session__resolve_callchain(struct perf_session *self,
+                                               struct thread *thread,
+                                               struct ip_callchain *chain,
+                                               struct symbol **parent);
+
+int perf_header__read_build_ids(int input, u64 offset, u64 file_size);
+
 #endif /* __PERF_SESSION_H */
index b490354d1b23d31e1d6a977c4801b2f34c97acea..cb0f327de9e86f73f08c63cce689f63f5fb137fc 100644 (file)
@@ -288,3 +288,29 @@ int sort_dimension__add(const char *tok)
 
        return -ESRCH;
 }
+
+void setup_sorting(const char * const usagestr[], const struct option *opts)
+{
+       char *tmp, *tok, *str = strdup(sort_order);
+
+       for (tok = strtok_r(str, ", ", &tmp);
+                       tok; tok = strtok_r(NULL, ", ", &tmp)) {
+               if (sort_dimension__add(tok) < 0) {
+                       error("Unknown --sort key: `%s'", tok);
+                       usage_with_options(usagestr, opts);
+               }
+       }
+
+       free(str);
+}
+
+void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
+                            const char *list_name, FILE *fp)
+{
+       if (list && strlist__nr_entries(list) == 1) {
+               if (fp != NULL)
+                       fprintf(fp, "# %s: %s\n", list_name,
+                               strlist__entry(list, 0)->s);
+               self->elide = true;
+       }
+}
index 333e664ff45fddfe9838f113dda25dc0a26c3860..753f9ea99fb0a72ebdec32aedbe5dc55df8dedc1 100644 (file)
@@ -49,9 +49,13 @@ struct hist_entry {
        struct symbol           *sym;
        u64                     ip;
        char                    level;
-       struct symbol           *parent;
+       struct symbol     *parent;
        struct callchain_node   callchain;
-       struct rb_root          sorted_chain;
+       union {
+               unsigned long     position;
+               struct hist_entry *pair;
+               struct rb_root    sorted_chain;
+       };
 };
 
 enum sort_type {
@@ -81,6 +85,8 @@ struct sort_entry {
 extern struct sort_entry sort_thread;
 extern struct list_head hist_entry__sort_list;
 
+void setup_sorting(const char * const usagestr[], const struct option *opts);
+
 extern int repsep_fprintf(FILE *fp, const char *fmt, ...);
 extern size_t sort__thread_print(FILE *, struct hist_entry *, unsigned int);
 extern size_t sort__comm_print(FILE *, struct hist_entry *, unsigned int);
@@ -95,5 +101,7 @@ extern int64_t sort__sym_cmp(struct hist_entry *, struct hist_entry *);
 extern int64_t sort__parent_cmp(struct hist_entry *, struct hist_entry *);
 extern size_t sort__parent_print(FILE *, struct hist_entry *, unsigned int);
 extern int sort_dimension__add(const char *);
+void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
+                            const char *list_name, FILE *fp);
 
 #endif /* __PERF_SORT_H */
index f24a8cc933d5f1aeede2875f774efc00b8610328..5352d7dccc61adab23a12ad60b9ec982e280d97e 100644 (file)
@@ -226,3 +226,28 @@ fail:
        argv_free(argv);
        return NULL;
 }
+
+/* Glob expression pattern matching */
+bool strglobmatch(const char *str, const char *pat)
+{
+       while (*str && *pat && *pat != '*') {
+               if (*pat == '?') {
+                       str++;
+                       pat++;
+               } else
+                       if (*str++ != *pat++)
+                               return false;
+       }
+       /* Check wild card */
+       if (*pat == '*') {
+               while (*pat == '*')
+                       pat++;
+               if (!*pat)      /* Tail wild card matches all */
+                       return true;
+               while (*str)
+                       if (strglobmatch(str++, pat))
+                               return true;
+       }
+       return !*str && !*pat;
+}
+
index bfecec265a1a423e3e2816b725f0540f234f5be4..02ede58c54b4e2593a1aa4e5d4f240d4912a55cf 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef __PERF_STRING_H_
 #define __PERF_STRING_H_
 
+#include <stdbool.h>
 #include "types.h"
 
 int hex2u64(const char *ptr, u64 *val);
@@ -8,6 +9,7 @@ char *strxfrchar(char *s, char from, char to);
 s64 perf_atoll(const char *str);
 char **argv_split(const char *str, int *argcp);
 void argv_free(char **argv);
+bool strglobmatch(const char *str, const char *pat);
 
 #define _STR(x) #x
 #define STR(x) _STR(x)
index 7ad38171dc2b9c6a6fb7c8474a1faf24101443cc..6783a2043555404f393bcb3bd41e6a13d3495bc6 100644 (file)
@@ -102,7 +102,7 @@ void strlist__remove(struct strlist *self, struct str_node *sn)
        str_node__delete(sn, self->dupstr);
 }
 
-bool strlist__has_entry(struct strlist *self, const char *entry)
+struct str_node *strlist__find(struct strlist *self, const char *entry)
 {
        struct rb_node **p = &self->entries.rb_node;
        struct rb_node *parent = NULL;
@@ -120,10 +120,10 @@ bool strlist__has_entry(struct strlist *self, const char *entry)
                else if (rc < 0)
                        p = &(*p)->rb_right;
                else
-                       return true;
+                       return sn;
        }
 
-       return false;
+       return NULL;
 }
 
 static int strlist__parse_list_entry(struct strlist *self, const char *s)
index cb4659306d7bd02221091716e6cc4151d560d1ef..3ba839007d2c975c49e4f3f286e9d64eff3d3f60 100644 (file)
@@ -23,7 +23,12 @@ int strlist__load(struct strlist *self, const char *filename);
 int strlist__add(struct strlist *self, const char *str);
 
 struct str_node *strlist__entry(const struct strlist *self, unsigned int idx);
-bool strlist__has_entry(struct strlist *self, const char *entry);
+struct str_node *strlist__find(struct strlist *self, const char *entry);
+
+static inline bool strlist__has_entry(struct strlist *self, const char *entry)
+{
+       return strlist__find(self, entry) != NULL;
+}
 
 static inline bool strlist__empty(const struct strlist *self)
 {
@@ -35,5 +40,39 @@ static inline unsigned int strlist__nr_entries(const struct strlist *self)
        return self->nr_entries;
 }
 
+/* For strlist iteration */
+static inline struct str_node *strlist__first(struct strlist *self)
+{
+       struct rb_node *rn = rb_first(&self->entries);
+       return rn ? rb_entry(rn, struct str_node, rb_node) : NULL;
+}
+static inline struct str_node *strlist__next(struct str_node *sn)
+{
+       struct rb_node *rn;
+       if (!sn)
+               return NULL;
+       rn = rb_next(&sn->rb_node);
+       return rn ? rb_entry(rn, struct str_node, rb_node) : NULL;
+}
+
+/**
+ * strlist_for_each      - iterate over a strlist
+ * @pos:       the &struct str_node to use as a loop cursor.
+ * @self:      the &struct strlist for loop.
+ */
+#define strlist__for_each(pos, self)   \
+       for (pos = strlist__first(self); pos; pos = strlist__next(pos))
+
+/**
+ * strlist_for_each_safe - iterate over a strlist safe against removal of
+ *                         str_node
+ * @pos:       the &struct str_node to use as a loop cursor.
+ * @n:         another &struct str_node to use as temporary storage.
+ * @self:      the &struct strlist for loop.
+ */
+#define strlist__for_each_safe(pos, n, self)   \
+       for (pos = strlist__first(self), n = strlist__next(pos); pos;\
+            pos = n, n = strlist__next(n))
+
 int strlist__parse_list(struct strlist *self, const char *s);
 #endif /* __PERF_STRLIST_H */
index d3d9fed74f1dbcb56fc1ba66aa5cbc09e53e426c..ab92763edb03f757e2941f95040133f96f84da02 100644 (file)
@@ -1,5 +1,7 @@
 #include "util.h"
 #include "../perf.h"
+#include "session.h"
+#include "sort.h"
 #include "string.h"
 #include "symbol.h"
 #include "thread.h"
@@ -31,19 +33,16 @@ enum dso_origin {
 static void dsos__add(struct list_head *head, struct dso *dso);
 static struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
 static int dso__load_kernel_sym(struct dso *self, struct map *map,
-                               struct map_groups *mg, symbol_filter_t filter);
-unsigned int symbol__priv_size;
+                               struct perf_session *session, symbol_filter_t filter);
 static int vmlinux_path__nr_entries;
 static char **vmlinux_path;
 
-static struct symbol_conf symbol_conf__defaults = {
+struct symbol_conf symbol_conf = {
+       .exclude_other    = true,
        .use_modules      = true,
        .try_vmlinux_path = true,
 };
 
-static struct map_groups kmaps_mem;
-struct map_groups *kmaps = &kmaps_mem;
-
 bool dso__loaded(const struct dso *self, enum map_type type)
 {
        return self->loaded & (1 << type);
@@ -132,13 +131,13 @@ static void map_groups__fixup_end(struct map_groups *self)
 static struct symbol *symbol__new(u64 start, u64 len, const char *name)
 {
        size_t namelen = strlen(name) + 1;
-       struct symbol *self = zalloc(symbol__priv_size +
+       struct symbol *self = zalloc(symbol_conf.priv_size +
                                     sizeof(*self) + namelen);
        if (self == NULL)
                return NULL;
 
-       if (symbol__priv_size)
-               self = ((void *)self) + symbol__priv_size;
+       if (symbol_conf.priv_size)
+               self = ((void *)self) + symbol_conf.priv_size;
 
        self->start = start;
        self->end   = len ? start + len - 1 : start;
@@ -152,7 +151,7 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name)
 
 static void symbol__delete(struct symbol *self)
 {
-       free(((void *)self) - symbol__priv_size);
+       free(((void *)self) - symbol_conf.priv_size);
 }
 
 static size_t symbol__fprintf(struct symbol *self, FILE *fp)
@@ -456,7 +455,7 @@ out_failure:
  * the original ELF section names vmlinux have.
  */
 static int dso__split_kallsyms(struct dso *self, struct map *map,
-                              struct map_groups *mg, symbol_filter_t filter)
+                              struct perf_session *session, symbol_filter_t filter)
 {
        struct map *curr_map = map;
        struct symbol *pos;
@@ -473,13 +472,13 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
 
                module = strchr(pos->name, '\t');
                if (module) {
-                       if (!mg->use_modules)
+                       if (!symbol_conf.use_modules)
                                goto discard_symbol;
 
                        *module++ = '\0';
 
                        if (strcmp(self->name, module)) {
-                               curr_map = map_groups__find_by_name(mg, map->type, module);
+                               curr_map = map_groups__find_by_name(&session->kmaps, map->type, module);
                                if (curr_map == NULL) {
                                        pr_debug("/proc/{kallsyms,modules} "
                                                 "inconsistency!\n");
@@ -510,7 +509,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
                        }
 
                        curr_map->map_ip = curr_map->unmap_ip = identity__map_ip;
-                       map_groups__insert(mg, curr_map);
+                       map_groups__insert(&session->kmaps, curr_map);
                        ++kernel_range;
                }
 
@@ -531,7 +530,7 @@ discard_symbol:             rb_erase(&pos->rb_node, root);
 
 
 static int dso__load_kallsyms(struct dso *self, struct map *map,
-                             struct map_groups *mg, symbol_filter_t filter)
+                             struct perf_session *session, symbol_filter_t filter)
 {
        if (dso__load_all_kallsyms(self, map) < 0)
                return -1;
@@ -539,14 +538,7 @@ static int dso__load_kallsyms(struct dso *self, struct map *map,
        symbols__fixup_end(&self->symbols[map->type]);
        self->origin = DSO__ORIG_KERNEL;
 
-       return dso__split_kallsyms(self, map, mg, filter);
-}
-
-size_t kernel_maps__fprintf(FILE *fp)
-{
-       size_t printed = fprintf(fp, "Kernel maps:\n");
-       printed += map_groups__fprintf_maps(kmaps, fp);
-       return printed + fprintf(fp, "END kernel maps\n");
+       return dso__split_kallsyms(self, map, session, filter);
 }
 
 static int dso__load_perf_map(struct dso *self, struct map *map,
@@ -873,7 +865,7 @@ static bool elf_sec__is_a(GElf_Shdr *self, Elf_Data *secstrs, enum map_type type
 }
 
 static int dso__load_sym(struct dso *self, struct map *map,
-                        struct map_groups *mg, const char *name, int fd,
+                        struct perf_session *session, const char *name, int fd,
                         symbol_filter_t filter, int kernel, int kmodule)
 {
        struct map *curr_map = map;
@@ -977,7 +969,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
                        snprintf(dso_name, sizeof(dso_name),
                                 "%s%s", self->short_name, section_name);
 
-                       curr_map = map_groups__find_by_name(mg, map->type, dso_name);
+                       curr_map = map_groups__find_by_name(&session->kmaps, map->type, dso_name);
                        if (curr_map == NULL) {
                                u64 start = sym.st_value;
 
@@ -996,7 +988,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
                                curr_map->map_ip = identity__map_ip;
                                curr_map->unmap_ip = identity__map_ip;
                                curr_dso->origin = DSO__ORIG_KERNEL;
-                               map_groups__insert(kmaps, curr_map);
+                               map_groups__insert(&session->kmaps, curr_map);
                                dsos__add(&dsos__kernel, curr_dso);
                        } else
                                curr_dso = curr_map->dso;
@@ -1211,7 +1203,8 @@ char dso__symtab_origin(const struct dso *self)
        return origin[self->origin];
 }
 
-int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
+int dso__load(struct dso *self, struct map *map, struct perf_session *session,
+             symbol_filter_t filter)
 {
        int size = PATH_MAX;
        char *name;
@@ -1222,7 +1215,7 @@ int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
        dso__set_loaded(self, map->type);
 
        if (self->kernel)
-               return dso__load_kernel_sym(self, map, kmaps, filter);
+               return dso__load_kernel_sym(self, map, session, filter);
 
        name = malloc(size);
        if (!name)
@@ -1323,7 +1316,7 @@ struct map *map_groups__find_by_name(struct map_groups *self,
        return NULL;
 }
 
-static int dsos__set_modules_path_dir(char *dirname)
+static int perf_session__set_modules_path_dir(struct perf_session *self, char *dirname)
 {
        struct dirent *dent;
        DIR *dir = opendir(dirname);
@@ -1343,7 +1336,7 @@ static int dsos__set_modules_path_dir(char *dirname)
 
                        snprintf(path, sizeof(path), "%s/%s",
                                 dirname, dent->d_name);
-                       if (dsos__set_modules_path_dir(path) < 0)
+                       if (perf_session__set_modules_path_dir(self, path) < 0)
                                goto failure;
                } else {
                        char *dot = strrchr(dent->d_name, '.'),
@@ -1357,7 +1350,7 @@ static int dsos__set_modules_path_dir(char *dirname)
                                 (int)(dot - dent->d_name), dent->d_name);
 
                        strxfrchar(dso_name, '-', '_');
-                       map = map_groups__find_by_name(kmaps, MAP__FUNCTION, dso_name);
+                       map = map_groups__find_by_name(&self->kmaps, MAP__FUNCTION, dso_name);
                        if (map == NULL)
                                continue;
 
@@ -1377,7 +1370,7 @@ failure:
        return -1;
 }
 
-static int dsos__set_modules_path(void)
+static int perf_session__set_modules_path(struct perf_session *self)
 {
        struct utsname uts;
        char modules_path[PATH_MAX];
@@ -1388,7 +1381,7 @@ static int dsos__set_modules_path(void)
        snprintf(modules_path, sizeof(modules_path), "/lib/modules/%s/kernel",
                 uts.release);
 
-       return dsos__set_modules_path_dir(modules_path);
+       return perf_session__set_modules_path_dir(self, modules_path);
 }
 
 /*
@@ -1410,7 +1403,7 @@ static struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
        return self;
 }
 
-static int map_groups__create_module_maps(struct map_groups *self)
+static int perf_session__create_module_maps(struct perf_session *self)
 {
        char *line = NULL;
        size_t n;
@@ -1467,14 +1460,14 @@ static int map_groups__create_module_maps(struct map_groups *self)
                        dso->has_build_id = true;
 
                dso->origin = DSO__ORIG_KMODULE;
-               map_groups__insert(self, map);
+               map_groups__insert(&self->kmaps, map);
                dsos__add(&dsos__kernel, dso);
        }
 
        free(line);
        fclose(file);
 
-       return dsos__set_modules_path();
+       return perf_session__set_modules_path(self);
 
 out_delete_line:
        free(line);
@@ -1483,7 +1476,7 @@ out_failure:
 }
 
 static int dso__load_vmlinux(struct dso *self, struct map *map,
-                            struct map_groups *mg,
+                            struct perf_session *session,
                             const char *vmlinux, symbol_filter_t filter)
 {
        int err = -1, fd;
@@ -1517,14 +1510,14 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
                return -1;
 
        dso__set_loaded(self, map->type);
-       err = dso__load_sym(self, map, mg, self->long_name, fd, filter, 1, 0);
+       err = dso__load_sym(self, map, session, self->long_name, fd, filter, 1, 0);
        close(fd);
 
        return err;
 }
 
 static int dso__load_kernel_sym(struct dso *self, struct map *map,
-                               struct map_groups *mg, symbol_filter_t filter)
+                               struct perf_session *session, symbol_filter_t filter)
 {
        int err;
        bool is_kallsyms;
@@ -1534,7 +1527,7 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
                pr_debug("Looking at the vmlinux_path (%d entries long)\n",
                         vmlinux_path__nr_entries);
                for (i = 0; i < vmlinux_path__nr_entries; ++i) {
-                       err = dso__load_vmlinux(self, map, mg,
+                       err = dso__load_vmlinux(self, map, session,
                                                vmlinux_path[i], filter);
                        if (err > 0) {
                                pr_debug("Using %s for symbols\n",
@@ -1550,12 +1543,12 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
        if (is_kallsyms)
                goto do_kallsyms;
 
-       err = dso__load_vmlinux(self, map, mg, self->long_name, filter);
+       err = dso__load_vmlinux(self, map, session, self->long_name, filter);
        if (err <= 0) {
                pr_info("The file %s cannot be used, "
                        "trying to use /proc/kallsyms...", self->long_name);
 do_kallsyms:
-               err = dso__load_kallsyms(self, map, mg, filter);
+               err = dso__load_kallsyms(self, map, session, filter);
                if (err > 0 && !is_kallsyms)
                         dso__set_long_name(self, strdup("[kernel.kallsyms]"));
        }
@@ -1748,32 +1741,69 @@ out_fail:
        return -1;
 }
 
-int symbol__init(struct symbol_conf *conf)
+static int setup_list(struct strlist **list, const char *list_str,
+                     const char *list_name)
 {
-       const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults;
+       if (list_str == NULL)
+               return 0;
+
+       *list = strlist__new(true, list_str);
+       if (!*list) {
+               pr_err("problems parsing %s list\n", list_name);
+               return -1;
+       }
+       return 0;
+}
 
+int symbol__init(void)
+{
        elf_version(EV_CURRENT);
-       symbol__priv_size = pconf->priv_size;
-       if (pconf->sort_by_name)
-               symbol__priv_size += (sizeof(struct symbol_name_rb_node) -
-                                     sizeof(struct symbol));
-       map_groups__init(kmaps);
+       if (symbol_conf.sort_by_name)
+               symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) -
+                                         sizeof(struct symbol));
 
-       if (pconf->try_vmlinux_path && vmlinux_path__init() < 0)
+       if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0)
                return -1;
 
-       if (map_groups__create_kernel_maps(kmaps, pconf->vmlinux_name) < 0) {
-               vmlinux_path__exit();
+       if (symbol_conf.field_sep && *symbol_conf.field_sep == '.') {
+               pr_err("'.' is the only non valid --field-separator argument\n");
                return -1;
        }
 
-       kmaps->use_modules = pconf->use_modules;
-       if (pconf->use_modules && map_groups__create_module_maps(kmaps) < 0)
-               pr_debug("Failed to load list of modules in use, "
-                        "continuing...\n");
+       if (setup_list(&symbol_conf.dso_list,
+                      symbol_conf.dso_list_str, "dso") < 0)
+               return -1;
+
+       if (setup_list(&symbol_conf.comm_list,
+                      symbol_conf.comm_list_str, "comm") < 0)
+               goto out_free_dso_list;
+
+       if (setup_list(&symbol_conf.sym_list,
+                      symbol_conf.sym_list_str, "symbol") < 0)
+               goto out_free_comm_list;
+
+       return 0;
+
+out_free_dso_list:
+       strlist__delete(symbol_conf.dso_list);
+out_free_comm_list:
+       strlist__delete(symbol_conf.comm_list);
+       return -1;
+}
+
+int perf_session__create_kernel_maps(struct perf_session *self)
+{
+       if (map_groups__create_kernel_maps(&self->kmaps,
+                                          symbol_conf.vmlinux_name) < 0)
+               return -1;
+
+       if (symbol_conf.use_modules &&
+           perf_session__create_module_maps(self) < 0)
+               pr_debug("Failed to load list of modules for session %s, "
+                        "continuing...\n", self->filename);
        /*
         * Now that we have all the maps created, just set the ->end of them:
         */
-       map_groups__fixup_end(kmaps);
+       map_groups__fixup_end(&self->kmaps);
        return 0;
 }
index cf99f88adf39c52d2010e8b6e0c580307dbc69fa..8aded2356f7961458b8a3d18635a0ca4c66d2ae2 100644 (file)
@@ -49,19 +49,32 @@ struct symbol {
        char            name[0];
 };
 
+struct strlist;
+
 struct symbol_conf {
        unsigned short  priv_size;
        bool            try_vmlinux_path,
                        use_modules,
-                       sort_by_name;
-       const char      *vmlinux_name;
+                       sort_by_name,
+                       show_nr_samples,
+                       use_callchain,
+                       exclude_other;
+       const char      *vmlinux_name,
+                       *field_sep;
+       char            *dso_list_str,
+                       *comm_list_str,
+                       *sym_list_str,
+                       *col_width_list_str;
+       struct strlist  *dso_list,
+                       *comm_list,
+                       *sym_list;
 };
 
-extern unsigned int symbol__priv_size;
+extern struct symbol_conf symbol_conf;
 
 static inline void *symbol__priv(struct symbol *self)
 {
-       return ((void *)self) - symbol__priv_size;
+       return ((void *)self) - symbol_conf.priv_size;
 }
 
 struct addr_location {
@@ -70,6 +83,7 @@ struct addr_location {
        struct symbol *sym;
        u64           addr;
        char          level;
+       bool          filtered;
 };
 
 struct dso {
@@ -98,8 +112,11 @@ bool dso__sorted_by_name(const struct dso *self, enum map_type type);
 
 void dso__sort_by_name(struct dso *self, enum map_type type);
 
+struct perf_session;
+
 struct dso *dsos__findnew(const char *name);
-int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
+int dso__load(struct dso *self, struct map *map, struct perf_session *session,
+             symbol_filter_t filter);
 void dsos__fprintf(FILE *fp);
 size_t dsos__fprintf_buildid(FILE *fp);
 
@@ -116,12 +133,9 @@ int sysfs__read_build_id(const char *filename, void *bf, size_t size);
 bool dsos__read_build_ids(void);
 int build_id__sprintf(u8 *self, int len, char *bf);
 
-size_t kernel_maps__fprintf(FILE *fp);
-
-int symbol__init(struct symbol_conf *conf);
+int symbol__init(void);
+int perf_session__create_kernel_maps(struct perf_session *self);
 
-struct map_groups;
-struct map_groups *kmaps;
 extern struct list_head dsos__user, dsos__kernel;
 extern struct dso *vdso;
 #endif /* __PERF_SYMBOL */
index b68a00ea41210cbb69a80d41794700d0bfaccb97..4a08dcf50b68c4bd9858c17fd569ae6acdec8257 100644 (file)
@@ -2,13 +2,11 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include "session.h"
 #include "thread.h"
 #include "util.h"
 #include "debug.h"
 
-static struct rb_root threads;
-static struct thread *last_match;
-
 void map_groups__init(struct map_groups *self)
 {
        int i;
@@ -122,9 +120,9 @@ static size_t thread__fprintf(struct thread *self, FILE *fp)
               map_groups__fprintf(&self->mg, fp);
 }
 
-struct thread *threads__findnew(pid_t pid)
+struct thread *perf_session__findnew(struct perf_session *self, pid_t pid)
 {
-       struct rb_node **p = &threads.rb_node;
+       struct rb_node **p = &self->threads.rb_node;
        struct rb_node *parent = NULL;
        struct thread *th;
 
@@ -133,15 +131,15 @@ struct thread *threads__findnew(pid_t pid)
         * so most of the time we dont have to look up
         * the full rbtree:
         */
-       if (last_match && last_match->pid == pid)
-               return last_match;
+       if (self->last_match && self->last_match->pid == pid)
+               return self->last_match;
 
        while (*p != NULL) {
                parent = *p;
                th = rb_entry(parent, struct thread, rb_node);
 
                if (th->pid == pid) {
-                       last_match = th;
+                       self->last_match = th;
                        return th;
                }
 
@@ -154,25 +152,13 @@ struct thread *threads__findnew(pid_t pid)
        th = thread__new(pid);
        if (th != NULL) {
                rb_link_node(&th->rb_node, parent, p);
-               rb_insert_color(&th->rb_node, &threads);
-               last_match = th;
+               rb_insert_color(&th->rb_node, &self->threads);
+               self->last_match = th;
        }
 
        return th;
 }
 
-struct thread *register_idle_thread(void)
-{
-       struct thread *thread = threads__findnew(0);
-
-       if (!thread || thread__set_comm(thread, "swapper")) {
-               fprintf(stderr, "problem inserting idle task.\n");
-               exit(-1);
-       }
-
-       return thread;
-}
-
 static void map_groups__remove_overlappings(struct map_groups *self,
                                            struct map *map)
 {
@@ -281,12 +267,12 @@ int thread__fork(struct thread *self, struct thread *parent)
        return 0;
 }
 
-size_t threads__fprintf(FILE *fp)
+size_t perf_session__fprintf(struct perf_session *self, FILE *fp)
 {
        size_t ret = 0;
        struct rb_node *nd;
 
-       for (nd = rb_first(&threads); nd; nd = rb_next(nd)) {
+       for (nd = rb_first(&self->threads); nd; nd = rb_next(nd)) {
                struct thread *pos = rb_entry(nd, struct thread, rb_node);
 
                ret += thread__fprintf(pos, fp);
@@ -296,13 +282,14 @@ size_t threads__fprintf(FILE *fp)
 }
 
 struct symbol *map_groups__find_symbol(struct map_groups *self,
+                                      struct perf_session *session,
                                       enum map_type type, u64 addr,
                                       symbol_filter_t filter)
 {
        struct map *map = map_groups__find(self, type, addr);
 
        if (map != NULL)
-               return map__find_symbol(map, map->map_ip(map, addr), filter);
+               return map__find_symbol(map, session, map->map_ip(map, addr), filter);
 
        return NULL;
 }
index 1751802a09ba41aef3fb1e985d94110aff516a12..c206f72c88811fb959d26d984b2e7a3506621d9a 100644 (file)
@@ -8,7 +8,6 @@
 struct map_groups {
        struct rb_root          maps[MAP__NR_TYPES];
        struct list_head        removed_maps[MAP__NR_TYPES];
-       bool                    use_modules;
 };
 
 struct thread {
@@ -23,12 +22,11 @@ struct thread {
 void map_groups__init(struct map_groups *self);
 int thread__set_comm(struct thread *self, const char *comm);
 int thread__comm_len(struct thread *self);
-struct thread *threads__findnew(pid_t pid);
-struct thread *register_idle_thread(void);
+struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
 void thread__insert_map(struct thread *self, struct map *map);
 int thread__fork(struct thread *self, struct thread *parent);
 size_t map_groups__fprintf_maps(struct map_groups *self, FILE *fp);
-size_t threads__fprintf(FILE *fp);
+size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
 
 void maps__insert(struct rb_root *maps, struct map *map);
 struct map *maps__find(struct rb_root *maps, u64 addr);
@@ -50,19 +48,21 @@ static inline struct map *thread__find_map(struct thread *self,
        return self ? map_groups__find(&self->mg, type, addr) : NULL;
 }
 
-void thread__find_addr_location(struct thread *self, u8 cpumode,
+void thread__find_addr_location(struct thread *self,
+                               struct perf_session *session, u8 cpumode,
                                enum map_type type, u64 addr,
                                struct addr_location *al,
                                symbol_filter_t filter);
 struct symbol *map_groups__find_symbol(struct map_groups *self,
+                                      struct perf_session *session,
                                       enum map_type type, u64 addr,
                                       symbol_filter_t filter);
 
 static inline struct symbol *
-map_groups__find_function(struct map_groups *self, u64 addr,
-                         symbol_filter_t filter)
+map_groups__find_function(struct map_groups *self, struct perf_session *session,
+                         u64 addr, symbol_filter_t filter)
 {
-       return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
+       return map_groups__find_symbol(self, session, MAP__FUNCTION, addr, filter);
 }
 
 struct map *map_groups__find_by_name(struct map_groups *self,
index a5ffe60db5d6e55f227ab171c3729c82d7eef78b..6d6d76b8a21e5d1b2af22f2c3995c669d27b967b 100644 (file)
@@ -267,7 +267,7 @@ int common_lock_depth(struct scripting_context *context)
 }
 
 static void perl_process_event(int cpu, void *data,
-                              int size __attribute((unused)),
+                              int size __unused,
                               unsigned long long nsecs, char *comm)
 {
        struct format_field *field;
@@ -359,28 +359,46 @@ static void run_start_sub(void)
 /*
  * Start trace script
  */
-static int perl_start_script(const char *script)
+static int perl_start_script(const char *script, int argc, const char **argv)
 {
-       const char *command_line[2] = { "", NULL };
+       const char **command_line;
+       int i, err = 0;
 
+       command_line = malloc((argc + 2) * sizeof(const char *));
+       command_line[0] = "";
        command_line[1] = script;
+       for (i = 2; i < argc + 2; i++)
+               command_line[i] = argv[i - 2];
 
        my_perl = perl_alloc();
        perl_construct(my_perl);
 
-       if (perl_parse(my_perl, xs_init, 2, (char **)command_line,
-                      (char **)NULL))
-               return -1;
+       if (perl_parse(my_perl, xs_init, argc + 2, (char **)command_line,
+                      (char **)NULL)) {
+               err = -1;
+               goto error;
+       }
 
-       perl_run(my_perl);
-       if (SvTRUE(ERRSV))
-               return -1;
+       if (perl_run(my_perl)) {
+               err = -1;
+               goto error;
+       }
+
+       if (SvTRUE(ERRSV)) {
+               err = -1;
+               goto error;
+       }
 
        run_start_sub();
 
+       free(command_line);
        fprintf(stderr, "perf trace started with Perl script %s\n\n", script);
-
        return 0;
+error:
+       perl_free(my_perl);
+       free(command_line);
+
+       return err;
 }
 
 /*
@@ -579,7 +597,9 @@ static void print_unsupported_msg(void)
                "\n  etc.\n");
 }
 
-static int perl_start_script_unsupported(const char *script __unused)
+static int perl_start_script_unsupported(const char *script __unused,
+                                        int argc __unused,
+                                        const char **argv __unused)
 {
        print_unsupported_msg();
 
index 81698d5e65039b1c299e92f413dd5f2bf844af7c..6ad405620c9b835852becb0e4d363b4d5c5990f5 100644 (file)
@@ -270,7 +270,7 @@ enum trace_flag_type {
 
 struct scripting_ops {
        const char *name;
-       int (*start_script) (const char *);
+       int (*start_script) (const char *script, int argc, const char **argv);
        int (*stop_script) (void);
        void (*process_event) (int cpu, void *data, int size,
                               unsigned long long nsecs, char *comm);
index 83b3dde1a83b74a5f1e75cb2d98a44787e33bca2..b2b3c2d1cf8bd37849d92b9a1d06131f1cf14f96 100644 (file)
@@ -354,7 +354,10 @@ static int cpio_mkfile(const char *name, const char *location,
                push_pad();
 
                if (size) {
-                       fwrite(filebuf, size, 1, stdout);
+                       if (fwrite(filebuf, size, 1, stdout) != 1) {
+                               fprintf(stderr, "writing filebuf failed\n");
+                               goto error;
+                       }
                        offset += size;
                        push_pad();
                }
index fd9c097b760ae909c0425dbfe6d2b8aa034fc24d..f73de631e3eef53d6a5c50b95b21f037969d2f95 100644 (file)
@@ -508,8 +508,8 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
        struct kvm_assigned_dev_kernel *match;
        struct pci_dev *dev;
 
-       down_read(&kvm->slots_lock);
        mutex_lock(&kvm->lock);
+       down_read(&kvm->slots_lock);
 
        match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head,
                                      assigned_dev->assigned_dev_id);
@@ -573,8 +573,8 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm,
        }
 
 out:
-       mutex_unlock(&kvm->lock);
        up_read(&kvm->slots_lock);
+       mutex_unlock(&kvm->lock);
        return r;
 out_list_del:
        list_del(&match->list);
@@ -585,8 +585,8 @@ out_put:
        pci_dev_put(dev);
 out_free:
        kfree(match);
-       mutex_unlock(&kvm->lock);
        up_read(&kvm->slots_lock);
+       mutex_unlock(&kvm->lock);
        return r;
 }
 
index e1f2bf8d7b1e06903ea499df764a2c0dbe1a66e1..a944be392d6e9420aa38d833cbc736bf9f07d22e 100644 (file)
@@ -64,7 +64,7 @@ MODULE_LICENSE("GPL");
 /*
  * Ordering of locks:
  *
- *             kvm->slots_lock --> kvm->lock --> kvm->irq_lock
+ *             kvm->lock --> kvm->slots_lock --> kvm->irq_lock
  */
 
 DEFINE_SPINLOCK(kvm_lock);
@@ -406,8 +406,11 @@ static struct kvm *kvm_create_vm(void)
 out:
        return kvm;
 
+#if defined(KVM_COALESCED_MMIO_PAGE_OFFSET) || \
+    (defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER))
 out_err:
        hardware_disable_all();
+#endif
 out_err_nodisable:
        kfree(kvm);
        return ERR_PTR(r);
@@ -1177,7 +1180,7 @@ static struct file_operations kvm_vcpu_fops = {
  */
 static int create_vcpu_fd(struct kvm_vcpu *vcpu)
 {
-       return anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu, 0);
+       return anon_inode_getfd("kvm-vcpu", &kvm_vcpu_fops, vcpu, O_RDWR);
 }
 
 /*
@@ -1638,7 +1641,7 @@ static int kvm_dev_ioctl_create_vm(void)
        kvm = kvm_create_vm();
        if (IS_ERR(kvm))
                return PTR_ERR(kvm);
-       fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, 0);
+       fd = anon_inode_getfd("kvm-vm", &kvm_vm_fops, kvm, O_RDWR);
        if (fd < 0)
                kvm_put_kvm(kvm);